@objectstack/service-automation 4.0.4 → 4.0.5

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/src/index.ts DELETED
@@ -1,14 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- // Core engine
4
- export { AutomationEngine } from './engine.js';
5
- export type { NodeExecutor, NodeExecutionResult, FlowTrigger } from './engine.js';
6
-
7
- // Kernel plugin
8
- export { AutomationServicePlugin } from './plugin.js';
9
- export type { AutomationServicePluginOptions } from './plugin.js';
10
-
11
- // Node plugins
12
- export { CrudNodesPlugin } from './plugins/crud-nodes-plugin.js';
13
- export { LogicNodesPlugin } from './plugins/logic-nodes-plugin.js';
14
- export { HttpConnectorPlugin } from './plugins/http-connector-plugin.js';
package/src/plugin.ts DELETED
@@ -1,80 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import type { Plugin, PluginContext } from '@objectstack/core';
4
- import { AutomationEngine } from './engine.js';
5
-
6
- /**
7
- * Configuration options for the AutomationServicePlugin.
8
- */
9
- export interface AutomationServicePluginOptions {
10
- /** Enable debug logging for flow execution */
11
- debug?: boolean;
12
- }
13
-
14
- /**
15
- * AutomationServicePlugin — Core engine plugin
16
- *
17
- * Responsibilities:
18
- * 1. init phase: Create engine instance, register as 'automation' service
19
- * 2. start phase: Trigger 'automation:ready' hook for node plugin registration
20
- * 3. destroy phase: Clean up resources
21
- *
22
- * Does NOT implement any specific nodes — nodes are registered by other plugins
23
- * via the engine's extension API.
24
- *
25
- * @example
26
- * ```ts
27
- * import { LiteKernel } from '@objectstack/core';
28
- * import { AutomationServicePlugin } from '@objectstack/service-automation';
29
- *
30
- * const kernel = new LiteKernel();
31
- * kernel.use(new AutomationServicePlugin());
32
- * await kernel.bootstrap();
33
- *
34
- * const automation = kernel.getService('automation');
35
- * ```
36
- */
37
- export class AutomationServicePlugin implements Plugin {
38
- name = 'com.objectstack.service-automation';
39
- version = '1.0.0';
40
- type = 'standard' as const;
41
- dependencies: string[] = [];
42
-
43
- private engine?: AutomationEngine;
44
- private readonly options: AutomationServicePluginOptions;
45
-
46
- constructor(options: AutomationServicePluginOptions = {}) {
47
- this.options = options;
48
- }
49
-
50
- async init(ctx: PluginContext): Promise<void> {
51
- this.engine = new AutomationEngine(ctx.logger);
52
-
53
- // Register as global service — other plugins access via ctx.getService('automation')
54
- ctx.registerService('automation', this.engine);
55
-
56
- if (this.options.debug) {
57
- ctx.hook('automation:beforeExecute', async (flowName: string) => {
58
- ctx.logger.debug(`[Automation] Before execute: ${flowName}`);
59
- });
60
- }
61
-
62
- ctx.logger.info('[Automation] Engine initialized');
63
- }
64
-
65
- async start(ctx: PluginContext): Promise<void> {
66
- if (!this.engine) return;
67
-
68
- // Trigger hook to notify engine is ready — other plugins can start registering nodes
69
- await ctx.trigger('automation:ready', this.engine);
70
-
71
- const nodeTypes = this.engine.getRegisteredNodeTypes();
72
- ctx.logger.info(
73
- `[Automation] Engine started with ${nodeTypes.length} node types: ${nodeTypes.join(', ') || '(none)'}`,
74
- );
75
- }
76
-
77
- async destroy(): Promise<void> {
78
- this.engine = undefined;
79
- }
80
- }
@@ -1,68 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import type { Plugin, PluginContext } from '@objectstack/core';
4
- import type { AutomationEngine } from '../engine.js';
5
-
6
- /**
7
- * CRUD Node Plugin — Provides get_record / create_record / update_record / delete_record
8
- *
9
- * Dependencies: service-automation (engine)
10
- *
11
- * In a full runtime environment these nodes would delegate to ObjectQL (data layer).
12
- * This MVP implementation provides the extension point structure.
13
- */
14
- export class CrudNodesPlugin implements Plugin {
15
- name = 'com.objectstack.automation.crud-nodes';
16
- version = '1.0.0';
17
- type = 'standard' as const;
18
- dependencies = ['com.objectstack.service-automation'];
19
-
20
- async init(ctx: PluginContext): Promise<void> {
21
- const engine = ctx.getService<AutomationEngine>('automation');
22
-
23
- // get_record node executor
24
- engine.registerNodeExecutor({
25
- type: 'get_record',
26
- async execute(node, _variables, _context) {
27
- const config = node.config as Record<string, unknown> | undefined;
28
- // In production, this would query via ObjectQL:
29
- // const ql = ctx.getService('objectql');
30
- // const records = await ql.find(config.object, config.filters);
31
- return {
32
- success: true,
33
- output: { records: [], object: config?.object },
34
- };
35
- },
36
- });
37
-
38
- // create_record node executor
39
- engine.registerNodeExecutor({
40
- type: 'create_record',
41
- async execute(node, _variables, _context) {
42
- const config = node.config as Record<string, unknown> | undefined;
43
- return {
44
- success: true,
45
- output: { id: 'new-record-id', object: config?.object },
46
- };
47
- },
48
- });
49
-
50
- // update_record node executor
51
- engine.registerNodeExecutor({
52
- type: 'update_record',
53
- async execute(_node, _variables, _context) {
54
- return { success: true };
55
- },
56
- });
57
-
58
- // delete_record node executor
59
- engine.registerNodeExecutor({
60
- type: 'delete_record',
61
- async execute(_node, _variables, _context) {
62
- return { success: true };
63
- },
64
- });
65
-
66
- ctx.logger.info('[CRUD Nodes] 4 node executors registered');
67
- }
68
- }
@@ -1,70 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import type { Plugin, PluginContext } from '@objectstack/core';
4
- import type { AutomationEngine } from '../engine.js';
5
-
6
- /**
7
- * HTTP + Connector Node Plugin — Provides http_request / connector_action nodes
8
- *
9
- * Dependencies: service-automation (engine)
10
- */
11
- export class HttpConnectorPlugin implements Plugin {
12
- name = 'com.objectstack.automation.http-connector';
13
- version = '1.0.0';
14
- type = 'standard' as const;
15
- dependencies = ['com.objectstack.service-automation'];
16
-
17
- async init(ctx: PluginContext): Promise<void> {
18
- const engine = ctx.getService<AutomationEngine>('automation');
19
-
20
- // http_request node executor
21
- engine.registerNodeExecutor({
22
- type: 'http_request',
23
- async execute(node, _variables, _context) {
24
- const config = node.config as Record<string, unknown> | undefined;
25
- const url = config?.url as string | undefined;
26
- const method = (config?.method as string) ?? 'GET';
27
- const headers = config?.headers as Record<string, string> | undefined;
28
- const body = config?.body;
29
-
30
- if (!url) {
31
- return { success: false, error: 'http_request: url is required' };
32
- }
33
-
34
- const response = await fetch(url, {
35
- method,
36
- headers,
37
- body: body ? JSON.stringify(body) : undefined,
38
- });
39
- const data = await response.json();
40
-
41
- return {
42
- success: response.ok,
43
- output: { response: data, status: response.status },
44
- error: response.ok ? undefined : `HTTP ${response.status}`,
45
- };
46
- },
47
- });
48
-
49
- // connector_action node — calls a registered connector
50
- engine.registerNodeExecutor({
51
- type: 'connector_action',
52
- async execute(node, _variables, _context) {
53
- const connectorConfig = node.connectorConfig;
54
- if (!connectorConfig) {
55
- return { success: false, error: 'connector_action: connectorConfig is required' };
56
- }
57
-
58
- ctx.logger.info(
59
- `Connector action: ${connectorConfig.connectorId}.${connectorConfig.actionId}`,
60
- );
61
-
62
- // In production, this would look up the connector from a registry
63
- // and execute the specified action with the mapped inputs
64
- return { success: true, output: { connectorResult: {} } };
65
- },
66
- });
67
-
68
- ctx.logger.info('[HTTP Connector] 2 node executors registered');
69
- }
70
- }
@@ -1,67 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import type { Plugin, PluginContext } from '@objectstack/core';
4
- import type { AutomationEngine } from '../engine.js';
5
-
6
- /**
7
- * Logic Node Plugin — Provides decision / assignment / loop nodes
8
- *
9
- * Dependencies: service-automation (engine)
10
- */
11
- export class LogicNodesPlugin implements Plugin {
12
- name = 'com.objectstack.automation.logic-nodes';
13
- version = '1.0.0';
14
- type = 'standard' as const;
15
- dependencies = ['com.objectstack.service-automation'];
16
-
17
- async init(ctx: PluginContext): Promise<void> {
18
- const engine = ctx.getService<AutomationEngine>('automation');
19
-
20
- // decision node — conditional branching
21
- engine.registerNodeExecutor({
22
- type: 'decision',
23
- async execute(node, variables, _context) {
24
- const config = node.config as Record<string, unknown> | undefined;
25
- const conditions = (config?.conditions ?? []) as Array<{ label: string; expression: string }>;
26
-
27
- for (const cond of conditions) {
28
- if (engine.evaluateCondition(cond.expression, variables)) {
29
- return { success: true, branchLabel: cond.label };
30
- }
31
- }
32
- return { success: true, branchLabel: 'default' };
33
- },
34
- });
35
-
36
- // assignment node — set variables
37
- engine.registerNodeExecutor({
38
- type: 'assignment',
39
- async execute(node, variables, _context) {
40
- const config = (node.config ?? {}) as Record<string, unknown>;
41
- for (const [key, value] of Object.entries(config)) {
42
- variables.set(key, value);
43
- }
44
- return { success: true };
45
- },
46
- });
47
-
48
- // loop node — iterate over a collection
49
- engine.registerNodeExecutor({
50
- type: 'loop',
51
- async execute(node, variables, _context) {
52
- const config = node.config as Record<string, unknown> | undefined;
53
- const collectionName = config?.collection as string | undefined;
54
- if (collectionName) {
55
- const collection = variables.get(collectionName);
56
- if (Array.isArray(collection)) {
57
- variables.set('$loopItems', collection);
58
- variables.set('$loopIndex', 0);
59
- }
60
- }
61
- return { success: true };
62
- },
63
- });
64
-
65
- ctx.logger.info('[Logic Nodes] 3 node executors registered');
66
- }
67
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "types": [
7
- "node"
8
- ]
9
- },
10
- "include": [
11
- "src"
12
- ],
13
- "exclude": [
14
- "node_modules",
15
- "dist"
16
- ]
17
- }