Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,33 @@
{
"extends": [
"../../../../.eslintrc.base.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-base44
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build pieces-base44` to build the library.

View File

@@ -0,0 +1,83 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "@activepieces/piece-base44",
"dependencies": {
"@base44/sdk": "^0.8.4",
"tslib": "^2.3.0",
},
},
},
"packages": {
"@base44/sdk": ["@base44/sdk@0.8.4", "", { "dependencies": { "axios": "^1.6.2", "socket.io-client": "^4.7.5", "uuid": "^13.0.0" } }, "sha512-d2g6v0p4ySKODYea0IwO2pU9f/GzuNlUEJ+eJj5LDZsSyvE+Zsj6A29ELfj3f2CpwD23nsrWBRo6UJ0se3Qhug=="],
"@socket.io/component-emitter": ["@socket.io/component-emitter@3.1.2", "", {}, "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA=="],
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
"axios": ["axios@1.13.2", "", { "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA=="],
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
"debug": ["debug@4.3.7", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ=="],
"delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
"engine.io-client": ["engine.io-client@6.6.3", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", "ws": "~8.17.1", "xmlhttprequest-ssl": "~2.1.1" } }, "sha512-T0iLjnyNWahNyv/lcjS2y4oE358tVS/SYQNxYXGAJ9/GLgH4VCvOQ/mhTjqU88mLZCQgiG8RIegFHYCdVC+j5w=="],
"engine.io-parser": ["engine.io-parser@5.2.3", "", {}, "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q=="],
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
"es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
"follow-redirects": ["follow-redirects@1.15.11", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
"has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
"mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
"mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
"socket.io-client": ["socket.io-client@4.8.1", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.2", "engine.io-client": "~6.6.1", "socket.io-parser": "~4.2.4" } }, "sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ=="],
"socket.io-parser": ["socket.io-parser@4.2.4", "", { "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" } }, "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew=="],
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"uuid": ["uuid@13.0.0", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w=="],
"ws": ["ws@8.17.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ=="],
"xmlhttprequest-ssl": ["xmlhttprequest-ssl@2.1.2", "", {}, "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ=="],
}
}

View File

@@ -0,0 +1,11 @@
{
"name": "@activepieces/piece-base44",
"version": "0.0.1",
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"dependencies": {
"@base44/sdk": "^0.8.4",
"tslib": "^2.3.0"
}
}

View File

@@ -0,0 +1,65 @@
{
"name": "pieces-base44",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/base44/src",
"projectType": "library",
"release": {
"version": {
"manifestRootsToUpdate": [
"dist/{projectRoot}"
],
"currentVersionResolver": "git-tag",
"fallbackCurrentVersionResolver": "disk"
}
},
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/base44",
"tsConfig": "packages/pieces/community/base44/tsconfig.lib.json",
"packageJson": "packages/pieces/community/base44/package.json",
"main": "packages/pieces/community/base44/src/index.ts",
"assets": [
"packages/pieces/community/base44/*.md",
{
"input": "packages/pieces/community/base44/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"prebuild",
"^build"
]
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"prebuild": {
"dependsOn": [
"^build"
],
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/base44",
"command": "bun install --no-save --silent"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
}
}
}

View File

@@ -0,0 +1,47 @@
import { createPiece, PieceAuth, Property } from "@activepieces/pieces-framework";
import { PieceCategory } from "@activepieces/shared";
import { createEntity } from "./lib/actions/create-entity";
import { findOrCreateEntity } from "./lib/actions/find-or-create-entity";
import { findEntity } from "./lib/actions/find-entity";
import { entityEvent } from "./lib/triggers/entity-event";
export const base44Auth = PieceAuth.CustomAuth({
description: `Authenticate with your Base44 app using your App ID and API token.
**App ID**: Your Base44 application ID (required)
**Token**: Your Base44 user token or service token (optional but recommended)
You can find these in your Base44 app settings or dashboard.`,
displayName: 'Authentication',
required: true,
props: {
appId: Property.ShortText({
displayName: 'App ID',
description: 'Your Base44 application ID',
required: true,
}),
token: PieceAuth.SecretText({
displayName: 'API Token',
description: 'Your Base44 user token or service token (optional but recommended for full access)',
required: false,
}),
},
});
export const base44 = createPiece({
displayName: "Base44",
description: "Build and manage custom apps with databases and entities",
auth: base44Auth,
minimumSupportedRelease: '0.36.1',
logoUrl: "https://cdn.activepieces.com/pieces/base44.png",
categories: [PieceCategory.DEVELOPER_TOOLS, PieceCategory.PRODUCTIVITY],
authors: ["onyedikachi-david"],
actions: [
createEntity,
findEntity,
findOrCreateEntity,
],
triggers: [
entityEvent,
],
});

View File

@@ -0,0 +1,58 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { base44Auth } from '../..';
import { createClient, Base44Error, type Base44Client } from '@base44/sdk';
export const createEntity = createAction({
auth: base44Auth,
name: 'create_entity',
displayName: 'Create Entity',
description: 'Creates an entity (record) in your Base44 app',
props: {
entityType: Property.ShortText({
displayName: 'Entity Type',
description: 'The name of the entity type (e.g. "Product", "User", "Order")',
required: true,
}),
entityData: Property.Json({
displayName: 'Entity Data',
description: 'The data to create the entity with',
required: true,
defaultValue: {},
}),
},
async run({ auth, propsValue }) {
const appId = auth.props.appId;
const token = auth.props.token;
const { entityType, entityData } = propsValue;
if (!appId) {
throw new Error('App ID is required.');
}
const base44: Base44Client = createClient({
appId,
token,
serviceToken: token,
});
try {
const entitiesModule = token
? base44.asServiceRole.entities as Record<string, { create: (data: Record<string, unknown>) => Promise<unknown> }>
: base44.entities as Record<string, { create: (data: Record<string, unknown>) => Promise<unknown> }>;
const result = await entitiesModule[entityType].create(entityData as Record<string, unknown>);
return result;
} catch (error: unknown) {
if (error instanceof Base44Error) {
if (error.status === 404) {
throw new Error(`Entity type "${entityType}" not found. Please check the name.`);
}
if (error.status === 401 || error.status === 403) {
throw new Error('Authentication failed. Please check your credentials.');
}
throw new Error(`Failed to create entity: ${error.message}`);
}
throw new Error(`Failed to create entity: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
},
});

View File

@@ -0,0 +1,67 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { base44Auth } from '../..';
import { createClient, Base44Error, type Base44Client } from '@base44/sdk';
export const findEntity = createAction({
auth: base44Auth,
name: 'find_entity',
displayName: 'Find Entity Record',
description: 'Find a matching entity record in your Base44 app',
props: {
entityType: Property.ShortText({
displayName: 'Entity Type',
description: 'The name of the entity type (e.g. "Product", "User", "Order")',
required: true,
}),
searchQuery: Property.Json({
displayName: 'Search Query',
description: 'Query to find the entity (e.g. {"email": "john@example.com"})',
required: true,
defaultValue: {},
}),
},
async run({ auth, propsValue }) {
const appId = auth.props.appId;
const token = auth.props.token;
const { entityType, searchQuery } = propsValue;
if (!appId) {
throw new Error('App ID is required.');
}
const base44: Base44Client = createClient({
appId,
token,
serviceToken: token,
});
try {
const entitiesModule = token
? base44.asServiceRole.entities as Record<string, {
filter: (query: Record<string, unknown>) => Promise<unknown[]>;
}>
: base44.entities as Record<string, {
filter: (query: Record<string, unknown>) => Promise<unknown[]>;
}>;
const results = await entitiesModule[entityType].filter(searchQuery as Record<string, unknown>);
return {
found: Array.isArray(results) && results.length > 0,
count: Array.isArray(results) ? results.length : 0,
results: results,
};
} catch (error: unknown) {
if (error instanceof Base44Error) {
if (error.status === 404) {
throw new Error(`Entity type "${entityType}" not found. Please check the name.`);
}
if (error.status === 401 || error.status === 403) {
throw new Error('Authentication failed. Please check your credentials.');
}
throw new Error(`Failed to find entity: ${error.message}`);
}
throw new Error(`Failed to find entity: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
},
});

View File

@@ -0,0 +1,85 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { base44Auth } from '../..';
import { createClient, Base44Error, type Base44Client } from '@base44/sdk';
export const findOrCreateEntity = createAction({
auth: base44Auth,
name: 'find_or_create_entity',
displayName: 'Find or Create Entity',
description: 'Find a matching entity record, or create one if not found',
props: {
entityType: Property.ShortText({
displayName: 'Entity Type',
description: 'The name of the entity type (e.g. "Product", "User", "Order")',
required: true,
}),
searchQuery: Property.Json({
displayName: 'Search Query',
description: 'Query to find the entity (e.g. {"email": "john@example.com"})',
required: true,
defaultValue: {},
}),
createData: Property.Json({
displayName: 'Create Data',
description: 'Data to create the entity with if not found',
required: true,
defaultValue: {},
}),
},
async run({ auth, propsValue }) {
const appId = auth.props.appId;
const token = auth.props.token;
const { entityType, searchQuery, createData } = propsValue;
if (!appId) {
throw new Error('App ID is required.');
}
const base44: Base44Client = createClient({
appId,
token,
serviceToken: token,
});
try {
const entitiesModule = token
? base44.asServiceRole.entities as Record<string, {
filter: (query: Record<string, unknown>) => Promise<unknown[]>;
create: (data: Record<string, unknown>) => Promise<unknown>;
}>
: base44.entities as Record<string, {
filter: (query: Record<string, unknown>) => Promise<unknown[]>;
create: (data: Record<string, unknown>) => Promise<unknown>;
}>;
const results = await entitiesModule[entityType].filter(searchQuery as Record<string, unknown>);
if (Array.isArray(results) && results.length > 0) {
return {
found: true,
created: false,
entity: results[0],
};
}
const newEntity = await entitiesModule[entityType].create(createData as Record<string, unknown>);
return {
found: false,
created: true,
entity: newEntity,
};
} catch (error: unknown) {
if (error instanceof Base44Error) {
if (error.status === 404) {
throw new Error(`Entity type "${entityType}" not found. Please check the name.`);
}
if (error.status === 401 || error.status === 403) {
throw new Error('Authentication failed. Please check your credentials.');
}
throw new Error(`Failed: ${error.message}`);
}
throw new Error(`Failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
},
});

View File

@@ -0,0 +1,138 @@
import {
createTrigger,
TriggerStrategy,
Property,
AppConnectionValueForAuthProperty,
} from '@activepieces/pieces-framework';
import {
DedupeStrategy,
pollingHelper,
Polling,
} from '@activepieces/pieces-common';
import { base44Auth } from '../..';
import { createClient, Base44Error, type Base44Client } from '@base44/sdk';
type Base44AuthType = AppConnectionValueForAuthProperty<typeof base44Auth>;
const polling: Polling<Base44AuthType, { entityType: string; eventType: string }> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth, propsValue, lastFetchEpochMS }) => {
const appId = auth.props.appId;
const token = auth.props.token;
const { entityType, eventType } = propsValue;
const base44: Base44Client = createClient({
appId,
token,
serviceToken: token,
});
try {
const entitiesModule = token
? base44.asServiceRole.entities as Record<string, {
list: (sort?: string, limit?: number, skip?: number) => Promise<unknown[]>;
}>
: base44.entities as Record<string, {
list: (sort?: string, limit?: number, skip?: number) => Promise<unknown[]>;
}>;
const sortField = eventType === 'created' ? '-created_date' : '-updated_date';
const results = await entitiesModule[entityType].list(sortField, 100);
if (!Array.isArray(results)) {
return [];
}
return results
.filter((item: any) => {
const timestamp = eventType === 'created'
? new Date(item.created_date).getTime()
: new Date(item.updated_date).getTime();
return timestamp > lastFetchEpochMS;
})
.map((item: any) => {
const timestamp = eventType === 'created'
? new Date(item.created_date).getTime()
: new Date(item.updated_date).getTime();
return {
epochMilliSeconds: timestamp,
data: {
...item,
_eventType: eventType,
_entityType: entityType,
},
};
});
} catch (error) {
if (error instanceof Base44Error) {
console.error(`Base44 Error: ${error.message}`);
}
return [];
}
},
};
export const entityEvent = createTrigger({
auth: base44Auth,
name: 'entity_event',
displayName: 'Entity Event',
description: 'Triggers when an entity is created or updated',
props: {
entityType: Property.ShortText({
displayName: 'Entity Type',
description: 'The name of the entity type (e.g. "Product", "User", "Order")',
required: true,
}),
eventType: Property.StaticDropdown({
displayName: 'Event Type',
description: 'When to trigger',
required: true,
defaultValue: 'created',
options: {
disabled: false,
options: [
{ label: 'Created', value: 'created' },
{ label: 'Updated', value: 'updated' },
],
},
}),
},
sampleData: {
id: 'sample-entity-id',
created_date: '2024-01-01T00:00:00.000Z',
updated_date: '2024-01-01T00:00:00.000Z',
_eventType: 'created',
_entityType: 'Product',
},
type: TriggerStrategy.POLLING,
async test(ctx) {
return await pollingHelper.test(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
files: ctx.files,
});
},
async onEnable(ctx) {
await pollingHelper.onEnable(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
});
},
async onDisable(ctx) {
await pollingHelper.onDisable(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
});
},
async run(ctx) {
return await pollingHelper.poll(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
files: ctx.files,
});
},
});

View File

@@ -0,0 +1,20 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"importHelpers": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"]
}