@objectstack/trigger-record-change 9.7.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -106,7 +106,6 @@ var RecordChangeTrigger = class {
|
|
|
106
106
|
// wins for every field it DOES return (id, DB-computed values).
|
|
107
107
|
{ ...inputDoc ?? {}, ...after }
|
|
108
108
|
) : inputDoc ?? (previous && typeof previous === "object" ? previous : {});
|
|
109
|
-
console.log("[dbg-bc] ctx.input=", JSON.stringify(ctx.input), "after=", JSON.stringify(after), "record=", JSON.stringify(record));
|
|
110
109
|
const session = ctx.session ?? {};
|
|
111
110
|
return {
|
|
112
111
|
record,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/record-change-trigger.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nexport { RecordChangeTriggerPlugin } from './plugin.js';\nexport {\n RecordChangeTrigger,\n triggerTypeToHookEvent,\n} from './record-change-trigger.js';\nexport type {\n FlowTrigger,\n FlowTriggerBinding,\n RecordChangeDataEngine,\n TriggerLogger,\n} from './record-change-trigger.js';\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { AutomationContext } from '@objectstack/spec/contracts';\nimport type { HookContext } from '@objectstack/spec/data';\n\n/**\n * Structural mirror of the automation engine's `FlowTriggerBinding`\n * (service-automation/src/engine.ts). Declared locally so this trigger plugin\n * stays decoupled from the automation package — same pattern the connector /\n * messaging integrations use to avoid a hard build edge. The engine parses the\n * flow's start node and hands us one of these per activated flow.\n */\nexport interface FlowTriggerBinding {\n readonly flowName: string;\n readonly object?: string;\n readonly event?: string;\n readonly condition?: string | { dialect?: string; source?: string; ast?: unknown };\n readonly schedule?: unknown;\n readonly config?: Record<string, unknown>;\n}\n\n/**\n * Structural mirror of the engine's `FlowTrigger` extension point. The engine\n * calls {@link start} with a parsed binding + a callback that runs the flow,\n * and {@link stop} when the flow is unregistered/disabled.\n */\nexport interface FlowTrigger {\n readonly type: string;\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void;\n stop(flowName: string): void;\n}\n\n/**\n * The slice of the ObjectQL data engine this trigger needs: subscribe to a\n * lifecycle hook, and (for teardown) drop all hooks owned by a packageId.\n * Typed structurally because `IDataEngine` (the public contract) doesn't model\n * the hook surface, but the concrete engine implements both.\n */\nexport interface RecordChangeDataEngine {\n registerHook(\n event: string,\n handler: (ctx: HookContext) => unknown | Promise<unknown>,\n options?: { object?: string | string[]; priority?: number; packageId?: string },\n ): void;\n unregisterHooksByPackage?(packageId: string): number;\n}\n\n/** Minimal logger surface (matches core's `ctx.logger`). */\nexport interface TriggerLogger {\n info(msg: string, ...args: unknown[]): void;\n warn(msg: string, ...args: unknown[]): void;\n debug?(msg: string, ...args: unknown[]): void;\n}\n\nconst TRIGGER_PREFIX = 'com.objectstack.trigger.record-change';\n\n/**\n * Map a flow start node's `triggerType` (e.g. `record-after-update`) to an\n * ObjectQL `HookEvent` (e.g. `afterUpdate`). Returns `null` for anything that\n * isn't a `record-(before|after)-(create|insert|update|delete)` token.\n */\nexport function triggerTypeToHookEvent(triggerType: string | undefined): string | null {\n if (!triggerType) return null;\n const m = /^record-(before|after)-(create|insert|update|delete)$/.exec(triggerType.trim());\n if (!m) return null;\n const phase = m[1]; // 'before' | 'after'\n const op = m[2]; // create|insert|update|delete\n const verb = op === 'create' || op === 'insert' ? 'Insert' : op.charAt(0).toUpperCase() + op.slice(1);\n return `${phase}${verb}`; // e.g. 'afterUpdate', 'beforeDelete'\n}\n\n/**\n * RecordChangeTrigger\n *\n * Bridges the automation engine's {@link FlowTrigger} extension point to\n * ObjectQL lifecycle hooks. For each flow the engine activates, it subscribes\n * to the matching hook event (filtered to the flow's target object) and, when\n * the hook fires, builds an {@link AutomationContext} from the new/old record\n * and invokes the engine-supplied callback (which runs the flow — the engine\n * owns the start-node condition gate, so we don't re-evaluate it here).\n *\n * Each flow's hooks are registered under a per-flow packageId so {@link stop}\n * can tear exactly that flow's subscription down via\n * `unregisterHooksByPackage`, without touching other flows or audit hooks.\n */\nexport class RecordChangeTrigger implements FlowTrigger {\n readonly type = 'record_change';\n\n private readonly engine: RecordChangeDataEngine;\n private readonly logger: TriggerLogger;\n /** flowName → packageId used for its hook(s), so stop() can unregister it. */\n private readonly bound = new Map<string, string>();\n\n constructor(engine: RecordChangeDataEngine, logger: TriggerLogger) {\n this.engine = engine;\n this.logger = logger;\n }\n\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void {\n const hookEvent = triggerTypeToHookEvent(binding.event);\n if (!hookEvent) {\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' has unsupported trigger event '${binding.event ?? '(none)'}' — not bound`,\n );\n return;\n }\n\n // Idempotent: drop any prior subscription for this flow before re-binding\n // (covers disable→enable cycles and hot reload).\n this.stop(binding.flowName);\n\n const packageId = `${TRIGGER_PREFIX}:${binding.flowName}`;\n\n const handler = async (ctx: HookContext): Promise<void> => {\n try {\n const automationCtx = this.buildContext(binding, ctx);\n await callback(automationCtx);\n } catch (err) {\n // Error isolation: a flow failure must NEVER break the CRUD write\n // that triggered it. Log and swallow.\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' execution failed: ${(err as Error)?.message ?? String(err)}`,\n );\n }\n };\n\n this.engine.registerHook(hookEvent, handler, {\n object: binding.object,\n packageId,\n });\n this.bound.set(binding.flowName, packageId);\n this.logger.info(\n `[record-change] bound flow '${binding.flowName}' → ${hookEvent}${binding.object ? ` on '${binding.object}'` : ''}`,\n );\n }\n\n stop(flowName: string): void {\n const packageId = this.bound.get(flowName);\n if (!packageId) return;\n try {\n this.engine.unregisterHooksByPackage?.(packageId);\n } catch (err) {\n this.logger.warn(\n `[record-change] failed to unbind flow '${flowName}': ${(err as Error)?.message ?? String(err)}`,\n );\n }\n this.bound.delete(flowName);\n this.logger.debug?.(`[record-change] unbound flow '${flowName}'`);\n }\n\n /**\n * Build the flow execution context from an ObjectQL hook context. The new\n * record comes from `ctx.result` (after-hooks) or falls back to the\n * mutation input doc / previous row; the old record from `ctx.previous`\n * (with the `__previous` stash audit also uses as a fallback).\n */\n private buildContext(binding: FlowTriggerBinding, ctx: HookContext): AutomationContext {\n // objectql lifecycle hooks carry the written row under `input.data` (insert /\n // update payload); `id` is on update. (`doc` kept only as a defensive alias.)\n const input = (ctx.input ?? {}) as { data?: Record<string, unknown>; doc?: Record<string, unknown>; id?: unknown };\n const after = ctx.result as Record<string, unknown> | undefined;\n const previous =\n (ctx.previous as Record<string, unknown> | undefined) ??\n ((ctx as unknown as { __previous?: Record<string, unknown> }).__previous ?? undefined);\n\n const inputDoc =\n input.data && typeof input.data === 'object'\n ? input.data\n : input.doc && typeof input.doc === 'object'\n ? input.doc\n : undefined;\n const record: Record<string, unknown> =\n after && typeof after === 'object'\n ? // #1872 — overlay the after-row on the input doc so fields the\n // driver did not echo back (notably `multiple: true` lookups,\n // stored as an array column) stay visible to the flow's start\n // condition and `{record.<field>}` interpolation. The after-row\n // wins for every field it DOES return (id, DB-computed values).\n { ...(inputDoc ?? {}), ...after }\n : inputDoc ?? (previous && typeof previous === 'object' ? previous : {});\n\n // eslint-disable-next-line no-console\n console.log('[dbg-bc] ctx.input=', JSON.stringify(ctx.input), 'after=', JSON.stringify(after), 'record=', JSON.stringify(record));\n const session = (ctx.session ?? {}) as { userId?: string };\n\n return {\n record,\n previous,\n object: binding.object ?? ctx.object,\n event: binding.event,\n userId: session.userId,\n // Expose the record as params too, so flows with named `isInput`\n // variables matching record fields get them seeded.\n params: record,\n };\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { RecordChangeTrigger } from './record-change-trigger.js';\nimport type { FlowTrigger, RecordChangeDataEngine } from './record-change-trigger.js';\n\n/**\n * The slice of the automation engine this plugin needs: register a trigger on\n * its `FlowTrigger` extension point. Declared structurally so the plugin does\n * not take a build dependency on `@objectstack/service-automation`.\n */\ninterface AutomationTriggerRegistry {\n registerTrigger(trigger: FlowTrigger): void;\n unregisterTrigger?(type: string): void;\n}\n\n/**\n * RecordChangeTriggerPlugin\n *\n * Makes record-change-triggered flows actually fire. The automation engine\n * ships the `FlowTrigger` wiring (it parses each flow's start node into a\n * binding and calls `trigger.start(...)`), but the *concrete* record-change\n * trigger — the one that subscribes to ObjectQL lifecycle hooks — lives here as\n * a plugin. This mirrors the connector split (engine baseline + connector-rest\n * plugin) and reuses plugin-audit's `kernel:ready` → `getService('objectql')`\n * pattern to reach the data engine's hook surface.\n *\n * With this plugin installed, a flow whose start node declares\n * `config: { objectName, triggerType: 'record-after-update', condition }`\n * auto-launches on the matching mutation — no manual `engine.execute()`.\n */\nexport class RecordChangeTriggerPlugin implements Plugin {\n name = 'com.objectstack.trigger.record-change';\n type = 'standard';\n version = '7.3.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n ctx.logger.info('Record-change trigger plugin initialized');\n }\n\n async start(ctx: PluginContext): Promise<void> {\n // ObjectQL engine + the automation service are only resolvable once the\n // kernel is ready (kernel:ready fires after AutomationServicePlugin.start()\n // has pulled flows into the engine, so binding order is correct).\n ctx.hook('kernel:ready', async () => {\n const automation = this.resolveService<AutomationTriggerRegistry>(ctx, 'automation');\n if (!automation || typeof automation.registerTrigger !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: automation service not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const engine = this.resolveDataEngine(ctx);\n if (!engine || typeof engine.registerHook !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: ObjectQL engine not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const trigger = new RecordChangeTrigger(engine, ctx.logger);\n automation.registerTrigger(trigger);\n ctx.logger.info('RecordChangeTriggerPlugin: record-change trigger registered');\n });\n }\n\n private resolveService<T>(ctx: PluginContext, name: string): T | null {\n try {\n return ctx.getService<T>(name) ?? null;\n } catch {\n return null;\n }\n }\n\n private resolveDataEngine(ctx: PluginContext): RecordChangeDataEngine | null {\n // Primary alias 'objectql', fallback 'data' (some kernels register the\n // engine under both) — same lookup plugin-audit uses.\n return (\n this.resolveService<RecordChangeDataEngine>(ctx, 'objectql') ??\n this.resolveService<RecordChangeDataEngine>(ctx, 'data')\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsDA,IAAM,iBAAiB;AAOhB,SAAS,uBAAuB,aAAgD;AACnF,MAAI,CAAC,YAAa,QAAO;AACzB,QAAM,IAAI,wDAAwD,KAAK,YAAY,KAAK,CAAC;AACzF,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,QAAQ,EAAE,CAAC;AACjB,QAAM,KAAK,EAAE,CAAC;AACd,QAAM,OAAO,OAAO,YAAY,OAAO,WAAW,WAAW,GAAG,OAAO,CAAC,EAAE,YAAY,IAAI,GAAG,MAAM,CAAC;AACpG,SAAO,GAAG,KAAK,GAAG,IAAI;AAC1B;AAgBO,IAAM,sBAAN,MAAiD;AAAA,EAQpD,YAAY,QAAgC,QAAuB;AAPnE,SAAS,OAAO;AAKhB;AAAA,SAAiB,QAAQ,oBAAI,IAAoB;AAG7C,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,SAA6B,UAA2D;AAC1F,UAAM,YAAY,uBAAuB,QAAQ,KAAK;AACtD,QAAI,CAAC,WAAW;AACZ,WAAK,OAAO;AAAA,QACR,yBAAyB,QAAQ,QAAQ,oCAAoC,QAAQ,SAAS,QAAQ;AAAA,MAC1G;AACA;AAAA,IACJ;AAIA,SAAK,KA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;AAAA,EAEQ,eAAkB,KAAoB,MAAwB;AAClE,QAAI;AACA,aAAO,IAAI,WAAc,IAAI,KAAK;AAAA,IACtC,QAAQ;AACJ,aAAO;AAAA,IACX;AAAA,EACJ;AAAA,EAEQ,kBAAkB,KAAmD;AAGzE,WACI,KAAK,eAAuC,KAAK,UAAU,KAC3D,KAAK,eAAuC,KAAK,MAAM;AAAA,EAE/D;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/record-change-trigger.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nexport { RecordChangeTriggerPlugin } from './plugin.js';\nexport {\n RecordChangeTrigger,\n triggerTypeToHookEvent,\n} from './record-change-trigger.js';\nexport type {\n FlowTrigger,\n FlowTriggerBinding,\n RecordChangeDataEngine,\n TriggerLogger,\n} from './record-change-trigger.js';\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { AutomationContext } from '@objectstack/spec/contracts';\nimport type { HookContext } from '@objectstack/spec/data';\n\n/**\n * Structural mirror of the automation engine's `FlowTriggerBinding`\n * (service-automation/src/engine.ts). Declared locally so this trigger plugin\n * stays decoupled from the automation package — same pattern the connector /\n * messaging integrations use to avoid a hard build edge. The engine parses the\n * flow's start node and hands us one of these per activated flow.\n */\nexport interface FlowTriggerBinding {\n readonly flowName: string;\n readonly object?: string;\n readonly event?: string;\n readonly condition?: string | { dialect?: string; source?: string; ast?: unknown };\n readonly schedule?: unknown;\n readonly config?: Record<string, unknown>;\n}\n\n/**\n * Structural mirror of the engine's `FlowTrigger` extension point. The engine\n * calls {@link start} with a parsed binding + a callback that runs the flow,\n * and {@link stop} when the flow is unregistered/disabled.\n */\nexport interface FlowTrigger {\n readonly type: string;\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void;\n stop(flowName: string): void;\n}\n\n/**\n * The slice of the ObjectQL data engine this trigger needs: subscribe to a\n * lifecycle hook, and (for teardown) drop all hooks owned by a packageId.\n * Typed structurally because `IDataEngine` (the public contract) doesn't model\n * the hook surface, but the concrete engine implements both.\n */\nexport interface RecordChangeDataEngine {\n registerHook(\n event: string,\n handler: (ctx: HookContext) => unknown | Promise<unknown>,\n options?: { object?: string | string[]; priority?: number; packageId?: string },\n ): void;\n unregisterHooksByPackage?(packageId: string): number;\n}\n\n/** Minimal logger surface (matches core's `ctx.logger`). */\nexport interface TriggerLogger {\n info(msg: string, ...args: unknown[]): void;\n warn(msg: string, ...args: unknown[]): void;\n debug?(msg: string, ...args: unknown[]): void;\n}\n\nconst TRIGGER_PREFIX = 'com.objectstack.trigger.record-change';\n\n/**\n * Map a flow start node's `triggerType` (e.g. `record-after-update`) to an\n * ObjectQL `HookEvent` (e.g. `afterUpdate`). Returns `null` for anything that\n * isn't a `record-(before|after)-(create|insert|update|delete)` token.\n */\nexport function triggerTypeToHookEvent(triggerType: string | undefined): string | null {\n if (!triggerType) return null;\n const m = /^record-(before|after)-(create|insert|update|delete)$/.exec(triggerType.trim());\n if (!m) return null;\n const phase = m[1]; // 'before' | 'after'\n const op = m[2]; // create|insert|update|delete\n const verb = op === 'create' || op === 'insert' ? 'Insert' : op.charAt(0).toUpperCase() + op.slice(1);\n return `${phase}${verb}`; // e.g. 'afterUpdate', 'beforeDelete'\n}\n\n/**\n * RecordChangeTrigger\n *\n * Bridges the automation engine's {@link FlowTrigger} extension point to\n * ObjectQL lifecycle hooks. For each flow the engine activates, it subscribes\n * to the matching hook event (filtered to the flow's target object) and, when\n * the hook fires, builds an {@link AutomationContext} from the new/old record\n * and invokes the engine-supplied callback (which runs the flow — the engine\n * owns the start-node condition gate, so we don't re-evaluate it here).\n *\n * Each flow's hooks are registered under a per-flow packageId so {@link stop}\n * can tear exactly that flow's subscription down via\n * `unregisterHooksByPackage`, without touching other flows or audit hooks.\n */\nexport class RecordChangeTrigger implements FlowTrigger {\n readonly type = 'record_change';\n\n private readonly engine: RecordChangeDataEngine;\n private readonly logger: TriggerLogger;\n /** flowName → packageId used for its hook(s), so stop() can unregister it. */\n private readonly bound = new Map<string, string>();\n\n constructor(engine: RecordChangeDataEngine, logger: TriggerLogger) {\n this.engine = engine;\n this.logger = logger;\n }\n\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void {\n const hookEvent = triggerTypeToHookEvent(binding.event);\n if (!hookEvent) {\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' has unsupported trigger event '${binding.event ?? '(none)'}' — not bound`,\n );\n return;\n }\n\n // Idempotent: drop any prior subscription for this flow before re-binding\n // (covers disable→enable cycles and hot reload).\n this.stop(binding.flowName);\n\n const packageId = `${TRIGGER_PREFIX}:${binding.flowName}`;\n\n const handler = async (ctx: HookContext): Promise<void> => {\n try {\n const automationCtx = this.buildContext(binding, ctx);\n await callback(automationCtx);\n } catch (err) {\n // Error isolation: a flow failure must NEVER break the CRUD write\n // that triggered it. Log and swallow.\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' execution failed: ${(err as Error)?.message ?? String(err)}`,\n );\n }\n };\n\n this.engine.registerHook(hookEvent, handler, {\n object: binding.object,\n packageId,\n });\n this.bound.set(binding.flowName, packageId);\n this.logger.info(\n `[record-change] bound flow '${binding.flowName}' → ${hookEvent}${binding.object ? ` on '${binding.object}'` : ''}`,\n );\n }\n\n stop(flowName: string): void {\n const packageId = this.bound.get(flowName);\n if (!packageId) return;\n try {\n this.engine.unregisterHooksByPackage?.(packageId);\n } catch (err) {\n this.logger.warn(\n `[record-change] failed to unbind flow '${flowName}': ${(err as Error)?.message ?? String(err)}`,\n );\n }\n this.bound.delete(flowName);\n this.logger.debug?.(`[record-change] unbound flow '${flowName}'`);\n }\n\n /**\n * Build the flow execution context from an ObjectQL hook context. The new\n * record comes from `ctx.result` (after-hooks) or falls back to the\n * mutation input doc / previous row; the old record from `ctx.previous`\n * (with the `__previous` stash audit also uses as a fallback).\n */\n private buildContext(binding: FlowTriggerBinding, ctx: HookContext): AutomationContext {\n // objectql lifecycle hooks carry the written row under `input.data` (insert /\n // update payload); `id` is on update. (`doc` kept only as a defensive alias.)\n const input = (ctx.input ?? {}) as { data?: Record<string, unknown>; doc?: Record<string, unknown>; id?: unknown };\n const after = ctx.result as Record<string, unknown> | undefined;\n const previous =\n (ctx.previous as Record<string, unknown> | undefined) ??\n ((ctx as unknown as { __previous?: Record<string, unknown> }).__previous ?? undefined);\n\n const inputDoc =\n input.data && typeof input.data === 'object'\n ? input.data\n : input.doc && typeof input.doc === 'object'\n ? input.doc\n : undefined;\n const record: Record<string, unknown> =\n after && typeof after === 'object'\n ? // #1872 — overlay the after-row on the input doc so fields the\n // driver did not echo back (notably `multiple: true` lookups,\n // stored as an array column) stay visible to the flow's start\n // condition and `{record.<field>}` interpolation. The after-row\n // wins for every field it DOES return (id, DB-computed values).\n { ...(inputDoc ?? {}), ...after }\n : inputDoc ?? (previous && typeof previous === 'object' ? previous : {});\n\n const session = (ctx.session ?? {}) as { userId?: string };\n\n return {\n record,\n previous,\n object: binding.object ?? ctx.object,\n event: binding.event,\n userId: session.userId,\n // Expose the record as params too, so flows with named `isInput`\n // variables matching record fields get them seeded.\n params: record,\n };\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { RecordChangeTrigger } from './record-change-trigger.js';\nimport type { FlowTrigger, RecordChangeDataEngine } from './record-change-trigger.js';\n\n/**\n * The slice of the automation engine this plugin needs: register a trigger on\n * its `FlowTrigger` extension point. Declared structurally so the plugin does\n * not take a build dependency on `@objectstack/service-automation`.\n */\ninterface AutomationTriggerRegistry {\n registerTrigger(trigger: FlowTrigger): void;\n unregisterTrigger?(type: string): void;\n}\n\n/**\n * RecordChangeTriggerPlugin\n *\n * Makes record-change-triggered flows actually fire. The automation engine\n * ships the `FlowTrigger` wiring (it parses each flow's start node into a\n * binding and calls `trigger.start(...)`), but the *concrete* record-change\n * trigger — the one that subscribes to ObjectQL lifecycle hooks — lives here as\n * a plugin. This mirrors the connector split (engine baseline + connector-rest\n * plugin) and reuses plugin-audit's `kernel:ready` → `getService('objectql')`\n * pattern to reach the data engine's hook surface.\n *\n * With this plugin installed, a flow whose start node declares\n * `config: { objectName, triggerType: 'record-after-update', condition }`\n * auto-launches on the matching mutation — no manual `engine.execute()`.\n */\nexport class RecordChangeTriggerPlugin implements Plugin {\n name = 'com.objectstack.trigger.record-change';\n type = 'standard';\n version = '7.3.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n ctx.logger.info('Record-change trigger plugin initialized');\n }\n\n async start(ctx: PluginContext): Promise<void> {\n // ObjectQL engine + the automation service are only resolvable once the\n // kernel is ready (kernel:ready fires after AutomationServicePlugin.start()\n // has pulled flows into the engine, so binding order is correct).\n ctx.hook('kernel:ready', async () => {\n const automation = this.resolveService<AutomationTriggerRegistry>(ctx, 'automation');\n if (!automation || typeof automation.registerTrigger !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: automation service not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const engine = this.resolveDataEngine(ctx);\n if (!engine || typeof engine.registerHook !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: ObjectQL engine not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const trigger = new RecordChangeTrigger(engine, ctx.logger);\n automation.registerTrigger(trigger);\n ctx.logger.info('RecordChangeTriggerPlugin: record-change trigger registered');\n });\n }\n\n private resolveService<T>(ctx: PluginContext, name: string): T | null {\n try {\n return ctx.getService<T>(name) ?? null;\n } catch {\n return null;\n }\n }\n\n private resolveDataEngine(ctx: PluginContext): RecordChangeDataEngine | null {\n // Primary alias 'objectql', fallback 'data' (some kernels register the\n // engine under both) — same lookup plugin-audit uses.\n return (\n this.resolveService<RecordChangeDataEngine>(ctx, 'objectql') ??\n this.resolveService<RecordChangeDataEngine>(ctx, 'data')\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;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;ACnKO,IAAM,4BAAN,MAAkD;AAAA,EAAlD;AACH,gBAAO;AACP,gBAAO;AACP,mBAAU;AACV,wBAAe,CAAC,iCAAiC;AAAA;AAAA,EAEjD,MAAM,KAAK,KAAmC;AAC1C,QAAI,OAAO,KAAK,0CAA0C;AAAA,EAC9D;AAAA,EAEA,MAAM,MAAM,KAAmC;AAI3C,QAAI,KAAK,gBAAgB,YAAY;AACjC,YAAM,aAAa,KAAK,eAA0C,KAAK,YAAY;AACnF,UAAI,CAAC,cAAc,OAAO,WAAW,oBAAoB,YAAY;AACjE,YAAI,OAAO;AAAA,UACP;AAAA,QACJ;AACA;AAAA,MACJ;AAEA,YAAM,SAAS,KAAK,kBAAkB,GAAG;AACzC,UAAI,CAAC,UAAU,OAAO,OAAO,iBAAiB,YAAY;AACtD,YAAI,OAAO;AAAA,UACP;AAAA,QACJ;AACA;AAAA,MACJ;AAEA,YAAM,UAAU,IAAI,oBAAoB,QAAQ,IAAI,MAAM;AAC1D,iBAAW,gBAAgB,OAAO;AAClC,UAAI,OAAO,KAAK,6DAA6D;AAAA,IACjF,CAAC;AAAA,EACL;AAAA,EAEQ,eAAkB,KAAoB,MAAwB;AAClE,QAAI;AACA,aAAO,IAAI,WAAc,IAAI,KAAK;AAAA,IACtC,QAAQ;AACJ,aAAO;AAAA,IACX;AAAA,EACJ;AAAA,EAEQ,kBAAkB,KAAmD;AAGzE,WACI,KAAK,eAAuC,KAAK,UAAU,KAC3D,KAAK,eAAuC,KAAK,MAAM;AAAA,EAE/D;AACJ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -78,7 +78,6 @@ var RecordChangeTrigger = class {
|
|
|
78
78
|
// wins for every field it DOES return (id, DB-computed values).
|
|
79
79
|
{ ...inputDoc ?? {}, ...after }
|
|
80
80
|
) : inputDoc ?? (previous && typeof previous === "object" ? previous : {});
|
|
81
|
-
console.log("[dbg-bc] ctx.input=", JSON.stringify(ctx.input), "after=", JSON.stringify(after), "record=", JSON.stringify(record));
|
|
82
81
|
const session = ctx.session ?? {};
|
|
83
82
|
return {
|
|
84
83
|
record,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/record-change-trigger.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { AutomationContext } from '@objectstack/spec/contracts';\nimport type { HookContext } from '@objectstack/spec/data';\n\n/**\n * Structural mirror of the automation engine's `FlowTriggerBinding`\n * (service-automation/src/engine.ts). Declared locally so this trigger plugin\n * stays decoupled from the automation package — same pattern the connector /\n * messaging integrations use to avoid a hard build edge. The engine parses the\n * flow's start node and hands us one of these per activated flow.\n */\nexport interface FlowTriggerBinding {\n readonly flowName: string;\n readonly object?: string;\n readonly event?: string;\n readonly condition?: string | { dialect?: string; source?: string; ast?: unknown };\n readonly schedule?: unknown;\n readonly config?: Record<string, unknown>;\n}\n\n/**\n * Structural mirror of the engine's `FlowTrigger` extension point. The engine\n * calls {@link start} with a parsed binding + a callback that runs the flow,\n * and {@link stop} when the flow is unregistered/disabled.\n */\nexport interface FlowTrigger {\n readonly type: string;\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void;\n stop(flowName: string): void;\n}\n\n/**\n * The slice of the ObjectQL data engine this trigger needs: subscribe to a\n * lifecycle hook, and (for teardown) drop all hooks owned by a packageId.\n * Typed structurally because `IDataEngine` (the public contract) doesn't model\n * the hook surface, but the concrete engine implements both.\n */\nexport interface RecordChangeDataEngine {\n registerHook(\n event: string,\n handler: (ctx: HookContext) => unknown | Promise<unknown>,\n options?: { object?: string | string[]; priority?: number; packageId?: string },\n ): void;\n unregisterHooksByPackage?(packageId: string): number;\n}\n\n/** Minimal logger surface (matches core's `ctx.logger`). */\nexport interface TriggerLogger {\n info(msg: string, ...args: unknown[]): void;\n warn(msg: string, ...args: unknown[]): void;\n debug?(msg: string, ...args: unknown[]): void;\n}\n\nconst TRIGGER_PREFIX = 'com.objectstack.trigger.record-change';\n\n/**\n * Map a flow start node's `triggerType` (e.g. `record-after-update`) to an\n * ObjectQL `HookEvent` (e.g. `afterUpdate`). Returns `null` for anything that\n * isn't a `record-(before|after)-(create|insert|update|delete)` token.\n */\nexport function triggerTypeToHookEvent(triggerType: string | undefined): string | null {\n if (!triggerType) return null;\n const m = /^record-(before|after)-(create|insert|update|delete)$/.exec(triggerType.trim());\n if (!m) return null;\n const phase = m[1]; // 'before' | 'after'\n const op = m[2]; // create|insert|update|delete\n const verb = op === 'create' || op === 'insert' ? 'Insert' : op.charAt(0).toUpperCase() + op.slice(1);\n return `${phase}${verb}`; // e.g. 'afterUpdate', 'beforeDelete'\n}\n\n/**\n * RecordChangeTrigger\n *\n * Bridges the automation engine's {@link FlowTrigger} extension point to\n * ObjectQL lifecycle hooks. For each flow the engine activates, it subscribes\n * to the matching hook event (filtered to the flow's target object) and, when\n * the hook fires, builds an {@link AutomationContext} from the new/old record\n * and invokes the engine-supplied callback (which runs the flow — the engine\n * owns the start-node condition gate, so we don't re-evaluate it here).\n *\n * Each flow's hooks are registered under a per-flow packageId so {@link stop}\n * can tear exactly that flow's subscription down via\n * `unregisterHooksByPackage`, without touching other flows or audit hooks.\n */\nexport class RecordChangeTrigger implements FlowTrigger {\n readonly type = 'record_change';\n\n private readonly engine: RecordChangeDataEngine;\n private readonly logger: TriggerLogger;\n /** flowName → packageId used for its hook(s), so stop() can unregister it. */\n private readonly bound = new Map<string, string>();\n\n constructor(engine: RecordChangeDataEngine, logger: TriggerLogger) {\n this.engine = engine;\n this.logger = logger;\n }\n\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void {\n const hookEvent = triggerTypeToHookEvent(binding.event);\n if (!hookEvent) {\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' has unsupported trigger event '${binding.event ?? '(none)'}' — not bound`,\n );\n return;\n }\n\n // Idempotent: drop any prior subscription for this flow before re-binding\n // (covers disable→enable cycles and hot reload).\n this.stop(binding.flowName);\n\n const packageId = `${TRIGGER_PREFIX}:${binding.flowName}`;\n\n const handler = async (ctx: HookContext): Promise<void> => {\n try {\n const automationCtx = this.buildContext(binding, ctx);\n await callback(automationCtx);\n } catch (err) {\n // Error isolation: a flow failure must NEVER break the CRUD write\n // that triggered it. Log and swallow.\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' execution failed: ${(err as Error)?.message ?? String(err)}`,\n );\n }\n };\n\n this.engine.registerHook(hookEvent, handler, {\n object: binding.object,\n packageId,\n });\n this.bound.set(binding.flowName, packageId);\n this.logger.info(\n `[record-change] bound flow '${binding.flowName}' → ${hookEvent}${binding.object ? ` on '${binding.object}'` : ''}`,\n );\n }\n\n stop(flowName: string): void {\n const packageId = this.bound.get(flowName);\n if (!packageId) return;\n try {\n this.engine.unregisterHooksByPackage?.(packageId);\n } catch (err) {\n this.logger.warn(\n `[record-change] failed to unbind flow '${flowName}': ${(err as Error)?.message ?? String(err)}`,\n );\n }\n this.bound.delete(flowName);\n this.logger.debug?.(`[record-change] unbound flow '${flowName}'`);\n }\n\n /**\n * Build the flow execution context from an ObjectQL hook context. The new\n * record comes from `ctx.result` (after-hooks) or falls back to the\n * mutation input doc / previous row; the old record from `ctx.previous`\n * (with the `__previous` stash audit also uses as a fallback).\n */\n private buildContext(binding: FlowTriggerBinding, ctx: HookContext): AutomationContext {\n // objectql lifecycle hooks carry the written row under `input.data` (insert /\n // update payload); `id` is on update. (`doc` kept only as a defensive alias.)\n const input = (ctx.input ?? {}) as { data?: Record<string, unknown>; doc?: Record<string, unknown>; id?: unknown };\n const after = ctx.result as Record<string, unknown> | undefined;\n const previous =\n (ctx.previous as Record<string, unknown> | undefined) ??\n ((ctx as unknown as { __previous?: Record<string, unknown> }).__previous ?? undefined);\n\n const inputDoc =\n input.data && typeof input.data === 'object'\n ? input.data\n : input.doc && typeof input.doc === 'object'\n ? input.doc\n : undefined;\n const record: Record<string, unknown> =\n after && typeof after === 'object'\n ? // #1872 — overlay the after-row on the input doc so fields the\n // driver did not echo back (notably `multiple: true` lookups,\n // stored as an array column) stay visible to the flow's start\n // condition and `{record.<field>}` interpolation. The after-row\n // wins for every field it DOES return (id, DB-computed values).\n { ...(inputDoc ?? {}), ...after }\n : inputDoc ?? (previous && typeof previous === 'object' ? previous : {});\n\n // eslint-disable-next-line no-console\n console.log('[dbg-bc] ctx.input=', JSON.stringify(ctx.input), 'after=', JSON.stringify(after), 'record=', JSON.stringify(record));\n const session = (ctx.session ?? {}) as { userId?: string };\n\n return {\n record,\n previous,\n object: binding.object ?? ctx.object,\n event: binding.event,\n userId: session.userId,\n // Expose the record as params too, so flows with named `isInput`\n // variables matching record fields get them seeded.\n params: record,\n };\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { RecordChangeTrigger } from './record-change-trigger.js';\nimport type { FlowTrigger, RecordChangeDataEngine } from './record-change-trigger.js';\n\n/**\n * The slice of the automation engine this plugin needs: register a trigger on\n * its `FlowTrigger` extension point. Declared structurally so the plugin does\n * not take a build dependency on `@objectstack/service-automation`.\n */\ninterface AutomationTriggerRegistry {\n registerTrigger(trigger: FlowTrigger): void;\n unregisterTrigger?(type: string): void;\n}\n\n/**\n * RecordChangeTriggerPlugin\n *\n * Makes record-change-triggered flows actually fire. The automation engine\n * ships the `FlowTrigger` wiring (it parses each flow's start node into a\n * binding and calls `trigger.start(...)`), but the *concrete* record-change\n * trigger — the one that subscribes to ObjectQL lifecycle hooks — lives here as\n * a plugin. This mirrors the connector split (engine baseline + connector-rest\n * plugin) and reuses plugin-audit's `kernel:ready` → `getService('objectql')`\n * pattern to reach the data engine's hook surface.\n *\n * With this plugin installed, a flow whose start node declares\n * `config: { objectName, triggerType: 'record-after-update', condition }`\n * auto-launches on the matching mutation — no manual `engine.execute()`.\n */\nexport class RecordChangeTriggerPlugin implements Plugin {\n name = 'com.objectstack.trigger.record-change';\n type = 'standard';\n version = '7.3.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n ctx.logger.info('Record-change trigger plugin initialized');\n }\n\n async start(ctx: PluginContext): Promise<void> {\n // ObjectQL engine + the automation service are only resolvable once the\n // kernel is ready (kernel:ready fires after AutomationServicePlugin.start()\n // has pulled flows into the engine, so binding order is correct).\n ctx.hook('kernel:ready', async () => {\n const automation = this.resolveService<AutomationTriggerRegistry>(ctx, 'automation');\n if (!automation || typeof automation.registerTrigger !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: automation service not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const engine = this.resolveDataEngine(ctx);\n if (!engine || typeof engine.registerHook !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: ObjectQL engine not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const trigger = new RecordChangeTrigger(engine, ctx.logger);\n automation.registerTrigger(trigger);\n ctx.logger.info('RecordChangeTriggerPlugin: record-change trigger registered');\n });\n }\n\n private resolveService<T>(ctx: PluginContext, name: string): T | null {\n try {\n return ctx.getService<T>(name) ?? null;\n } catch {\n return null;\n }\n }\n\n private resolveDataEngine(ctx: PluginContext): RecordChangeDataEngine | null {\n // Primary alias 'objectql', fallback 'data' (some kernels register the\n // engine under both) — same lookup plugin-audit uses.\n return (\n this.resolveService<RecordChangeDataEngine>(ctx, 'objectql') ??\n this.resolveService<RecordChangeDataEngine>(ctx, 'data')\n );\n }\n}\n"],"mappings":";AAsDA,IAAM,iBAAiB;AAOhB,SAAS,uBAAuB,aAAgD;AACnF,MAAI,CAAC,YAAa,QAAO;AACzB,QAAM,IAAI,wDAAwD,KAAK,YAAY,KAAK,CAAC;AACzF,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,QAAQ,EAAE,CAAC;AACjB,QAAM,KAAK,EAAE,CAAC;AACd,QAAM,OAAO,OAAO,YAAY,OAAO,WAAW,WAAW,GAAG,OAAO,CAAC,EAAE,YAAY,IAAI,G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gBAAgB,YAAY;AACjC,YAAM,aAAa,KAAK,eAA0C,KAAK,YAAY;AACnF,UAAI,CAAC,cAAc,OAAO,WAAW,oBAAoB,YAAY;AACjE,YAAI,OAAO;AAAA,UACP;AAAA,QACJ;AACA;AAAA,MACJ;AAEA,YAAM,SAAS,KAAK,kBAAkB,GAAG;AACzC,UAAI,CAAC,UAAU,OAAO,OAAO,iBAAiB,YAAY;AACtD,YAAI,OAAO;AAAA,UACP;AAAA,QACJ;AACA;AAAA,MACJ;AAEA,YAAM,UAAU,IAAI,oBAAoB,QAAQ,IAAI,MAAM;AAC1D,iBAAW,gBAAgB,OAAO;AAClC,UAAI,OAAO,KAAK,6DAA6D;AAAA,IACjF,CAAC;AAAA,EACL;AAAA,EAEQ,eAAkB,KAAoB,MAAwB;AAClE,QAAI;AACA,aAAO,IAAI,WAAc,IAAI,KAAK;AAAA,IACtC,QAAQ;AACJ,aAAO;AAAA,IACX;AAAA,EACJ;AAAA,EAEQ,kBAAkB,KAAmD;AAGzE,WACI,KAAK,eAAuC,KAAK,UAAU,KAC3D,KAAK,eAAuC,KAAK,MAAM;AAAA,EAE/D;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/record-change-trigger.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { AutomationContext } from '@objectstack/spec/contracts';\nimport type { HookContext } from '@objectstack/spec/data';\n\n/**\n * Structural mirror of the automation engine's `FlowTriggerBinding`\n * (service-automation/src/engine.ts). Declared locally so this trigger plugin\n * stays decoupled from the automation package — same pattern the connector /\n * messaging integrations use to avoid a hard build edge. The engine parses the\n * flow's start node and hands us one of these per activated flow.\n */\nexport interface FlowTriggerBinding {\n readonly flowName: string;\n readonly object?: string;\n readonly event?: string;\n readonly condition?: string | { dialect?: string; source?: string; ast?: unknown };\n readonly schedule?: unknown;\n readonly config?: Record<string, unknown>;\n}\n\n/**\n * Structural mirror of the engine's `FlowTrigger` extension point. The engine\n * calls {@link start} with a parsed binding + a callback that runs the flow,\n * and {@link stop} when the flow is unregistered/disabled.\n */\nexport interface FlowTrigger {\n readonly type: string;\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void;\n stop(flowName: string): void;\n}\n\n/**\n * The slice of the ObjectQL data engine this trigger needs: subscribe to a\n * lifecycle hook, and (for teardown) drop all hooks owned by a packageId.\n * Typed structurally because `IDataEngine` (the public contract) doesn't model\n * the hook surface, but the concrete engine implements both.\n */\nexport interface RecordChangeDataEngine {\n registerHook(\n event: string,\n handler: (ctx: HookContext) => unknown | Promise<unknown>,\n options?: { object?: string | string[]; priority?: number; packageId?: string },\n ): void;\n unregisterHooksByPackage?(packageId: string): number;\n}\n\n/** Minimal logger surface (matches core's `ctx.logger`). */\nexport interface TriggerLogger {\n info(msg: string, ...args: unknown[]): void;\n warn(msg: string, ...args: unknown[]): void;\n debug?(msg: string, ...args: unknown[]): void;\n}\n\nconst TRIGGER_PREFIX = 'com.objectstack.trigger.record-change';\n\n/**\n * Map a flow start node's `triggerType` (e.g. `record-after-update`) to an\n * ObjectQL `HookEvent` (e.g. `afterUpdate`). Returns `null` for anything that\n * isn't a `record-(before|after)-(create|insert|update|delete)` token.\n */\nexport function triggerTypeToHookEvent(triggerType: string | undefined): string | null {\n if (!triggerType) return null;\n const m = /^record-(before|after)-(create|insert|update|delete)$/.exec(triggerType.trim());\n if (!m) return null;\n const phase = m[1]; // 'before' | 'after'\n const op = m[2]; // create|insert|update|delete\n const verb = op === 'create' || op === 'insert' ? 'Insert' : op.charAt(0).toUpperCase() + op.slice(1);\n return `${phase}${verb}`; // e.g. 'afterUpdate', 'beforeDelete'\n}\n\n/**\n * RecordChangeTrigger\n *\n * Bridges the automation engine's {@link FlowTrigger} extension point to\n * ObjectQL lifecycle hooks. For each flow the engine activates, it subscribes\n * to the matching hook event (filtered to the flow's target object) and, when\n * the hook fires, builds an {@link AutomationContext} from the new/old record\n * and invokes the engine-supplied callback (which runs the flow — the engine\n * owns the start-node condition gate, so we don't re-evaluate it here).\n *\n * Each flow's hooks are registered under a per-flow packageId so {@link stop}\n * can tear exactly that flow's subscription down via\n * `unregisterHooksByPackage`, without touching other flows or audit hooks.\n */\nexport class RecordChangeTrigger implements FlowTrigger {\n readonly type = 'record_change';\n\n private readonly engine: RecordChangeDataEngine;\n private readonly logger: TriggerLogger;\n /** flowName → packageId used for its hook(s), so stop() can unregister it. */\n private readonly bound = new Map<string, string>();\n\n constructor(engine: RecordChangeDataEngine, logger: TriggerLogger) {\n this.engine = engine;\n this.logger = logger;\n }\n\n start(binding: FlowTriggerBinding, callback: (ctx: AutomationContext) => Promise<void>): void {\n const hookEvent = triggerTypeToHookEvent(binding.event);\n if (!hookEvent) {\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' has unsupported trigger event '${binding.event ?? '(none)'}' — not bound`,\n );\n return;\n }\n\n // Idempotent: drop any prior subscription for this flow before re-binding\n // (covers disable→enable cycles and hot reload).\n this.stop(binding.flowName);\n\n const packageId = `${TRIGGER_PREFIX}:${binding.flowName}`;\n\n const handler = async (ctx: HookContext): Promise<void> => {\n try {\n const automationCtx = this.buildContext(binding, ctx);\n await callback(automationCtx);\n } catch (err) {\n // Error isolation: a flow failure must NEVER break the CRUD write\n // that triggered it. Log and swallow.\n this.logger.warn(\n `[record-change] flow '${binding.flowName}' execution failed: ${(err as Error)?.message ?? String(err)}`,\n );\n }\n };\n\n this.engine.registerHook(hookEvent, handler, {\n object: binding.object,\n packageId,\n });\n this.bound.set(binding.flowName, packageId);\n this.logger.info(\n `[record-change] bound flow '${binding.flowName}' → ${hookEvent}${binding.object ? ` on '${binding.object}'` : ''}`,\n );\n }\n\n stop(flowName: string): void {\n const packageId = this.bound.get(flowName);\n if (!packageId) return;\n try {\n this.engine.unregisterHooksByPackage?.(packageId);\n } catch (err) {\n this.logger.warn(\n `[record-change] failed to unbind flow '${flowName}': ${(err as Error)?.message ?? String(err)}`,\n );\n }\n this.bound.delete(flowName);\n this.logger.debug?.(`[record-change] unbound flow '${flowName}'`);\n }\n\n /**\n * Build the flow execution context from an ObjectQL hook context. The new\n * record comes from `ctx.result` (after-hooks) or falls back to the\n * mutation input doc / previous row; the old record from `ctx.previous`\n * (with the `__previous` stash audit also uses as a fallback).\n */\n private buildContext(binding: FlowTriggerBinding, ctx: HookContext): AutomationContext {\n // objectql lifecycle hooks carry the written row under `input.data` (insert /\n // update payload); `id` is on update. (`doc` kept only as a defensive alias.)\n const input = (ctx.input ?? {}) as { data?: Record<string, unknown>; doc?: Record<string, unknown>; id?: unknown };\n const after = ctx.result as Record<string, unknown> | undefined;\n const previous =\n (ctx.previous as Record<string, unknown> | undefined) ??\n ((ctx as unknown as { __previous?: Record<string, unknown> }).__previous ?? undefined);\n\n const inputDoc =\n input.data && typeof input.data === 'object'\n ? input.data\n : input.doc && typeof input.doc === 'object'\n ? input.doc\n : undefined;\n const record: Record<string, unknown> =\n after && typeof after === 'object'\n ? // #1872 — overlay the after-row on the input doc so fields the\n // driver did not echo back (notably `multiple: true` lookups,\n // stored as an array column) stay visible to the flow's start\n // condition and `{record.<field>}` interpolation. The after-row\n // wins for every field it DOES return (id, DB-computed values).\n { ...(inputDoc ?? {}), ...after }\n : inputDoc ?? (previous && typeof previous === 'object' ? previous : {});\n\n const session = (ctx.session ?? {}) as { userId?: string };\n\n return {\n record,\n previous,\n object: binding.object ?? ctx.object,\n event: binding.event,\n userId: session.userId,\n // Expose the record as params too, so flows with named `isInput`\n // variables matching record fields get them seeded.\n params: record,\n };\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { RecordChangeTrigger } from './record-change-trigger.js';\nimport type { FlowTrigger, RecordChangeDataEngine } from './record-change-trigger.js';\n\n/**\n * The slice of the automation engine this plugin needs: register a trigger on\n * its `FlowTrigger` extension point. Declared structurally so the plugin does\n * not take a build dependency on `@objectstack/service-automation`.\n */\ninterface AutomationTriggerRegistry {\n registerTrigger(trigger: FlowTrigger): void;\n unregisterTrigger?(type: string): void;\n}\n\n/**\n * RecordChangeTriggerPlugin\n *\n * Makes record-change-triggered flows actually fire. The automation engine\n * ships the `FlowTrigger` wiring (it parses each flow's start node into a\n * binding and calls `trigger.start(...)`), but the *concrete* record-change\n * trigger — the one that subscribes to ObjectQL lifecycle hooks — lives here as\n * a plugin. This mirrors the connector split (engine baseline + connector-rest\n * plugin) and reuses plugin-audit's `kernel:ready` → `getService('objectql')`\n * pattern to reach the data engine's hook surface.\n *\n * With this plugin installed, a flow whose start node declares\n * `config: { objectName, triggerType: 'record-after-update', condition }`\n * auto-launches on the matching mutation — no manual `engine.execute()`.\n */\nexport class RecordChangeTriggerPlugin implements Plugin {\n name = 'com.objectstack.trigger.record-change';\n type = 'standard';\n version = '7.3.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n ctx.logger.info('Record-change trigger plugin initialized');\n }\n\n async start(ctx: PluginContext): Promise<void> {\n // ObjectQL engine + the automation service are only resolvable once the\n // kernel is ready (kernel:ready fires after AutomationServicePlugin.start()\n // has pulled flows into the engine, so binding order is correct).\n ctx.hook('kernel:ready', async () => {\n const automation = this.resolveService<AutomationTriggerRegistry>(ctx, 'automation');\n if (!automation || typeof automation.registerTrigger !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: automation service not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const engine = this.resolveDataEngine(ctx);\n if (!engine || typeof engine.registerHook !== 'function') {\n ctx.logger.warn(\n 'RecordChangeTriggerPlugin: ObjectQL engine not available — record-change trigger NOT installed',\n );\n return;\n }\n\n const trigger = new RecordChangeTrigger(engine, ctx.logger);\n automation.registerTrigger(trigger);\n ctx.logger.info('RecordChangeTriggerPlugin: record-change trigger registered');\n });\n }\n\n private resolveService<T>(ctx: PluginContext, name: string): T | null {\n try {\n return ctx.getService<T>(name) ?? null;\n } catch {\n return null;\n }\n }\n\n private resolveDataEngine(ctx: PluginContext): RecordChangeDataEngine | null {\n // Primary alias 'objectql', fallback 'data' (some kernels register the\n // engine under both) — same lookup plugin-audit uses.\n return (\n this.resolveService<RecordChangeDataEngine>(ctx, 'objectql') ??\n this.resolveService<RecordChangeDataEngine>(ctx, 'data')\n );\n }\n}\n"],"mappings":";AAsDA,IAAM,iBAAiB;AAOhB,SAAS,uBAAuB,aAAgD;AACnF,MAAI,CAAC,YAAa,QAAO;AACzB,QAAM,IAAI,wDAAwD,KAAK,YAAY,KAAK,CAAC;AACzF,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,QAAQ,EAAE,CAAC;AACjB,QAAM,KAAK,EAAE,CAAC;AACd,QAAM,OAAO,OAAO,YAAY,OAAO,WAAW,WAAW,GAAG,OAAO,CAAC,EAAE,YAAY,IAAI,GAAG,MAAM,CAAC;AACpG,SAAO,GAAG,KAAK,GAAG,IAAI;AAC1B;AAgBO,IAAM,sBAAN,MAAiD;AAAA,EAQpD,YAAY,QAAgC,QAAuB;AAPnE,SAAS,OAAO;AAKhB;AAAA,SAAiB,QAAQ,oBAAI,IAAoB;AAG7C,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,SAA6B,UAA2D;AAC1F,UAAM,YAAY,uBAAuB,QAAQ,KAAK;AACtD,QAAI,CAAC,WAAW;AACZ,WAAK,OAAO;AAAA,QACR,yBAAyB,QAAQ,QAAQ,oCAAoC,QAAQ,SAAS,QAAQ;AAAA,MAC1G;AACA;AAAA,IACJ;AAIA,SAAK,KAAK,QAAQ,QAAQ;AAE1B,UAAM,YAAY,GAAG,cAAc,IAAI,QAAQ,QAAQ;AAEvD,UAAM,UAAU,OAAO,QAAoC;AACvD,UAAI;AACA,cAAM,gBAAgB,KAAK,aAAa,SAAS,GAAG;AACpD,cAAM,SAAS,aAAa;AAAA,MAChC,SAAS,KAAK;AAGV,aAAK,OAAO;AAAA,UACR,yBAAyB,QAAQ,QAAQ,uBAAwB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
+
"version": "9.9.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Record-change flow trigger for ObjectStack — auto-launches flows on object insert/update/delete via ObjectQL lifecycle hooks (ADR-0018)",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@objectstack/core": "9.
|
|
17
|
-
"@objectstack/spec": "9.
|
|
16
|
+
"@objectstack/core": "9.9.0",
|
|
17
|
+
"@objectstack/spec": "9.9.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^25.9.3",
|
|
21
21
|
"typescript": "^6.0.3",
|
|
22
22
|
"vitest": "^4.1.9",
|
|
23
|
-
"@objectstack/objectql": "9.
|
|
24
|
-
"@objectstack/service-automation": "9.
|
|
23
|
+
"@objectstack/objectql": "9.9.0",
|
|
24
|
+
"@objectstack/service-automation": "9.9.0"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"objectstack",
|