@orgloop/sdk 0.1.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/LICENSE.md +21 -0
- package/dist/connector.d.ts +174 -0
- package/dist/connector.d.ts.map +1 -0
- package/dist/connector.js +8 -0
- package/dist/connector.js.map +1 -0
- package/dist/event.d.ts +43 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +87 -0
- package/dist/event.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +40 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/module.d.ts +214 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +125 -0
- package/dist/module.js.map +1 -0
- package/dist/testing.d.ts +104 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +188 -0
- package/dist/testing.js.map +1 -0
- package/dist/transform.d.ts +50 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +8 -0
- package/dist/transform.js.map +1 -0
- package/dist/types.d.ts +299 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module types for OrgLoop.
|
|
3
|
+
*
|
|
4
|
+
* A module is a bundled workflow: connectors + routes + transforms + SOPs —
|
|
5
|
+
* installable as a single npm package. Modules reference connectors; they
|
|
6
|
+
* don't create them. Users wire connectors; modules declare what they need.
|
|
7
|
+
*/
|
|
8
|
+
/** Root module manifest (orgloop-module.yaml) */
|
|
9
|
+
export interface ModuleManifest {
|
|
10
|
+
apiVersion: string;
|
|
11
|
+
kind: 'Module';
|
|
12
|
+
metadata: ModuleMetadata;
|
|
13
|
+
requires?: ModuleRequirements;
|
|
14
|
+
parameters?: ModuleParameter[];
|
|
15
|
+
provides?: ModuleProvides;
|
|
16
|
+
}
|
|
17
|
+
/** Module metadata */
|
|
18
|
+
export interface ModuleMetadata {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
version: string;
|
|
22
|
+
}
|
|
23
|
+
/** What the module requires to function */
|
|
24
|
+
export interface ModuleRequirements {
|
|
25
|
+
connectors?: ModuleConnectorRequirement[];
|
|
26
|
+
services?: ModuleServiceRequirement[];
|
|
27
|
+
credentials?: ModuleCredentialRequirement[];
|
|
28
|
+
hooks?: ModuleHookRequirement[];
|
|
29
|
+
}
|
|
30
|
+
/** A connector the module needs */
|
|
31
|
+
export interface ModuleConnectorRequirement {
|
|
32
|
+
type: 'source' | 'actor';
|
|
33
|
+
id: string;
|
|
34
|
+
connector: string;
|
|
35
|
+
required?: boolean;
|
|
36
|
+
fallback?: 'queue' | 'skip';
|
|
37
|
+
}
|
|
38
|
+
/** A service dependency (informational for doctor/orgctl) */
|
|
39
|
+
export interface ModuleServiceRequirement {
|
|
40
|
+
name: string;
|
|
41
|
+
detect?: {
|
|
42
|
+
http?: string;
|
|
43
|
+
};
|
|
44
|
+
install?: {
|
|
45
|
+
brew?: string;
|
|
46
|
+
docs?: string;
|
|
47
|
+
};
|
|
48
|
+
provides_credentials?: string[];
|
|
49
|
+
}
|
|
50
|
+
/** A credential the module needs (informational for doctor/orgctl) */
|
|
51
|
+
export interface ModuleCredentialRequirement {
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
required?: boolean;
|
|
55
|
+
create_url?: string;
|
|
56
|
+
validate?: string;
|
|
57
|
+
}
|
|
58
|
+
/** A hook requirement (informational for doctor/orgctl) */
|
|
59
|
+
export interface ModuleHookRequirement {
|
|
60
|
+
type: string;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
scope?: 'global' | 'project';
|
|
63
|
+
}
|
|
64
|
+
/** A parameter the user provides when installing the module */
|
|
65
|
+
export interface ModuleParameter {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
type: 'string' | 'number' | 'boolean';
|
|
69
|
+
required?: boolean;
|
|
70
|
+
default?: string | number | boolean;
|
|
71
|
+
}
|
|
72
|
+
/** What the module provides (informational) */
|
|
73
|
+
export interface ModuleProvides {
|
|
74
|
+
routes?: number;
|
|
75
|
+
transforms?: number;
|
|
76
|
+
sops?: number;
|
|
77
|
+
}
|
|
78
|
+
/** A module entry in orgloop.yaml's modules: array */
|
|
79
|
+
export interface InstalledModule {
|
|
80
|
+
/** npm package name or local path */
|
|
81
|
+
package: string;
|
|
82
|
+
/** User-provided parameter values */
|
|
83
|
+
params: Record<string, string | number | boolean>;
|
|
84
|
+
}
|
|
85
|
+
/** Context available during template expansion */
|
|
86
|
+
export interface ModuleExpansionContext {
|
|
87
|
+
/** Module metadata */
|
|
88
|
+
module: {
|
|
89
|
+
name: string;
|
|
90
|
+
path: string;
|
|
91
|
+
};
|
|
92
|
+
/** User-provided parameter values */
|
|
93
|
+
params: Record<string, string | number | boolean>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Expand `{{ variable }}` placeholders in a string.
|
|
97
|
+
*
|
|
98
|
+
* Supports:
|
|
99
|
+
* - {{ params.X }} — user-provided parameter
|
|
100
|
+
* - {{ module.name }} — module name from manifest
|
|
101
|
+
* - {{ module.path }} — resolved filesystem path to the module
|
|
102
|
+
*
|
|
103
|
+
* Throws if a referenced variable is not found in the context.
|
|
104
|
+
*/
|
|
105
|
+
export declare function expandTemplate(template: string, context: ModuleExpansionContext): string;
|
|
106
|
+
/**
|
|
107
|
+
* Deep-expand all string values in an object tree.
|
|
108
|
+
* Non-string values pass through unchanged.
|
|
109
|
+
*/
|
|
110
|
+
export declare function expandTemplateDeep(value: unknown, context: ModuleExpansionContext): unknown;
|
|
111
|
+
/** JSON Schema for validating orgloop-module.yaml */
|
|
112
|
+
export declare const moduleManifestSchema: {
|
|
113
|
+
readonly type: "object";
|
|
114
|
+
readonly required: readonly ["apiVersion", "kind", "metadata"];
|
|
115
|
+
readonly properties: {
|
|
116
|
+
readonly apiVersion: {
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
};
|
|
119
|
+
readonly kind: {
|
|
120
|
+
readonly const: "Module";
|
|
121
|
+
};
|
|
122
|
+
readonly metadata: {
|
|
123
|
+
readonly type: "object";
|
|
124
|
+
readonly required: readonly ["name", "description", "version"];
|
|
125
|
+
readonly properties: {
|
|
126
|
+
readonly name: {
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
readonly pattern: "^[a-z0-9][a-z0-9-]*$";
|
|
129
|
+
};
|
|
130
|
+
readonly description: {
|
|
131
|
+
readonly type: "string";
|
|
132
|
+
};
|
|
133
|
+
readonly version: {
|
|
134
|
+
readonly type: "string";
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
readonly requires: {
|
|
139
|
+
readonly type: "object";
|
|
140
|
+
readonly properties: {
|
|
141
|
+
readonly connectors: {
|
|
142
|
+
readonly type: "array";
|
|
143
|
+
readonly items: {
|
|
144
|
+
readonly type: "object";
|
|
145
|
+
readonly required: readonly ["type", "id", "connector"];
|
|
146
|
+
readonly properties: {
|
|
147
|
+
readonly type: {
|
|
148
|
+
readonly enum: readonly ["source", "actor"];
|
|
149
|
+
};
|
|
150
|
+
readonly id: {
|
|
151
|
+
readonly type: "string";
|
|
152
|
+
};
|
|
153
|
+
readonly connector: {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
};
|
|
156
|
+
readonly required: {
|
|
157
|
+
readonly type: "boolean";
|
|
158
|
+
};
|
|
159
|
+
readonly fallback: {
|
|
160
|
+
readonly enum: readonly ["queue", "skip"];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
readonly services: {
|
|
166
|
+
readonly type: "array";
|
|
167
|
+
};
|
|
168
|
+
readonly credentials: {
|
|
169
|
+
readonly type: "array";
|
|
170
|
+
};
|
|
171
|
+
readonly hooks: {
|
|
172
|
+
readonly type: "array";
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
readonly parameters: {
|
|
177
|
+
readonly type: "array";
|
|
178
|
+
readonly items: {
|
|
179
|
+
readonly type: "object";
|
|
180
|
+
readonly required: readonly ["name", "description", "type"];
|
|
181
|
+
readonly properties: {
|
|
182
|
+
readonly name: {
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
};
|
|
185
|
+
readonly description: {
|
|
186
|
+
readonly type: "string";
|
|
187
|
+
};
|
|
188
|
+
readonly type: {
|
|
189
|
+
readonly enum: readonly ["string", "number", "boolean"];
|
|
190
|
+
};
|
|
191
|
+
readonly required: {
|
|
192
|
+
readonly type: "boolean";
|
|
193
|
+
};
|
|
194
|
+
readonly default: {};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
readonly provides: {
|
|
199
|
+
readonly type: "object";
|
|
200
|
+
readonly properties: {
|
|
201
|
+
readonly routes: {
|
|
202
|
+
readonly type: "number";
|
|
203
|
+
};
|
|
204
|
+
readonly transforms: {
|
|
205
|
+
readonly type: "number";
|
|
206
|
+
};
|
|
207
|
+
readonly sops: {
|
|
208
|
+
readonly type: "number";
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DvB,CAAC"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module types for OrgLoop.
|
|
3
|
+
*
|
|
4
|
+
* A module is a bundled workflow: connectors + routes + transforms + SOPs —
|
|
5
|
+
* installable as a single npm package. Modules reference connectors; they
|
|
6
|
+
* don't create them. Users wire connectors; modules declare what they need.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Expand `{{ variable }}` placeholders in a string.
|
|
10
|
+
*
|
|
11
|
+
* Supports:
|
|
12
|
+
* - {{ params.X }} — user-provided parameter
|
|
13
|
+
* - {{ module.name }} — module name from manifest
|
|
14
|
+
* - {{ module.path }} — resolved filesystem path to the module
|
|
15
|
+
*
|
|
16
|
+
* Throws if a referenced variable is not found in the context.
|
|
17
|
+
*/
|
|
18
|
+
export function expandTemplate(template, context) {
|
|
19
|
+
return template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_match, expr) => {
|
|
20
|
+
const parts = expr.split('.');
|
|
21
|
+
if (parts.length !== 2) {
|
|
22
|
+
throw new Error(`Invalid template expression: {{ ${expr} }}`);
|
|
23
|
+
}
|
|
24
|
+
const [namespace, key] = parts;
|
|
25
|
+
if (namespace === 'module') {
|
|
26
|
+
const value = context.module[key];
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
throw new Error(`Unknown module variable: {{ ${expr} }}`);
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
if (namespace === 'params') {
|
|
33
|
+
const value = context.params[key];
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
throw new Error(`Missing parameter: {{ ${expr} }}`);
|
|
36
|
+
}
|
|
37
|
+
return String(value);
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Unknown namespace "${namespace}" in template expression: {{ ${expr} }}`);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deep-expand all string values in an object tree.
|
|
44
|
+
* Non-string values pass through unchanged.
|
|
45
|
+
*/
|
|
46
|
+
export function expandTemplateDeep(value, context) {
|
|
47
|
+
if (typeof value === 'string') {
|
|
48
|
+
return expandTemplate(value, context);
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
return value.map((item) => expandTemplateDeep(item, context));
|
|
52
|
+
}
|
|
53
|
+
if (value !== null && typeof value === 'object') {
|
|
54
|
+
const result = {};
|
|
55
|
+
for (const [k, v] of Object.entries(value)) {
|
|
56
|
+
result[k] = expandTemplateDeep(v, context);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
// ─── Module Manifest JSON Schema ──────────────────────────────────────────────
|
|
63
|
+
/** JSON Schema for validating orgloop-module.yaml */
|
|
64
|
+
export const moduleManifestSchema = {
|
|
65
|
+
type: 'object',
|
|
66
|
+
required: ['apiVersion', 'kind', 'metadata'],
|
|
67
|
+
properties: {
|
|
68
|
+
apiVersion: { type: 'string' },
|
|
69
|
+
kind: { const: 'Module' },
|
|
70
|
+
metadata: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
required: ['name', 'description', 'version'],
|
|
73
|
+
properties: {
|
|
74
|
+
name: { type: 'string', pattern: '^[a-z0-9][a-z0-9-]*$' },
|
|
75
|
+
description: { type: 'string' },
|
|
76
|
+
version: { type: 'string' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
requires: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
connectors: {
|
|
83
|
+
type: 'array',
|
|
84
|
+
items: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
required: ['type', 'id', 'connector'],
|
|
87
|
+
properties: {
|
|
88
|
+
type: { enum: ['source', 'actor'] },
|
|
89
|
+
id: { type: 'string' },
|
|
90
|
+
connector: { type: 'string' },
|
|
91
|
+
required: { type: 'boolean' },
|
|
92
|
+
fallback: { enum: ['queue', 'skip'] },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
services: { type: 'array' },
|
|
97
|
+
credentials: { type: 'array' },
|
|
98
|
+
hooks: { type: 'array' },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
parameters: {
|
|
102
|
+
type: 'array',
|
|
103
|
+
items: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
required: ['name', 'description', 'type'],
|
|
106
|
+
properties: {
|
|
107
|
+
name: { type: 'string' },
|
|
108
|
+
description: { type: 'string' },
|
|
109
|
+
type: { enum: ['string', 'number', 'boolean'] },
|
|
110
|
+
required: { type: 'boolean' },
|
|
111
|
+
default: {},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
provides: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
routes: { type: 'number' },
|
|
119
|
+
transforms: { type: 'number' },
|
|
120
|
+
sops: { type: 'number' },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqGH;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,OAA+B;IAC/E,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE;QAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,KAAK,CAAC,CAAC;QAC/D,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AAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;4BAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;yBACrC;qBACD;iBACD;gBACD,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;gBAC3B,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;gBAC9B,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;aACxB;SACD;QACD,UAAU,EAAE;YACX,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;gBACzC,UAAU,EAAE;oBACX,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE;oBAC/C,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;oBAC7B,OAAO,EAAE,EAAE;iBACX;aACD;SACD;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACX,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aACxB;SACD;KACD;CACQ,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test harness for OrgLoop plugin authors.
|
|
3
|
+
*
|
|
4
|
+
* Provides mock implementations and helpers for testing connectors,
|
|
5
|
+
* transforms, and loggers in isolation.
|
|
6
|
+
*/
|
|
7
|
+
import type { ActorConnector, DeliveryResult, PollResult, SourceConnector } from './connector.js';
|
|
8
|
+
import { type BuildEventOptions } from './event.js';
|
|
9
|
+
import type { Logger } from './logger.js';
|
|
10
|
+
import type { Transform, TransformContext } from './transform.js';
|
|
11
|
+
import type { ActorConfig, LogEntry, OrgLoopEvent, RouteDeliveryConfig, SourceConfig } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Mock source connector for testing.
|
|
14
|
+
* Returns pre-configured events on poll().
|
|
15
|
+
*/
|
|
16
|
+
export declare class MockSource implements SourceConnector {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
private events;
|
|
19
|
+
private pollCount;
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
shutdownCalled: boolean;
|
|
22
|
+
constructor(id?: string);
|
|
23
|
+
init(_config: SourceConfig): Promise<void>;
|
|
24
|
+
/** Add events that will be returned on the next poll */
|
|
25
|
+
addEvents(...events: OrgLoopEvent[]): void;
|
|
26
|
+
poll(_checkpoint: string | null): Promise<PollResult>;
|
|
27
|
+
shutdown(): Promise<void>;
|
|
28
|
+
get totalPolls(): number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Mock actor connector for testing.
|
|
32
|
+
* Records all delivered events for assertion.
|
|
33
|
+
*/
|
|
34
|
+
export declare class MockActor implements ActorConnector {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly delivered: Array<{
|
|
37
|
+
event: OrgLoopEvent;
|
|
38
|
+
config: RouteDeliveryConfig;
|
|
39
|
+
}>;
|
|
40
|
+
private shouldReject;
|
|
41
|
+
private shouldError;
|
|
42
|
+
initialized: boolean;
|
|
43
|
+
shutdownCalled: boolean;
|
|
44
|
+
constructor(id?: string);
|
|
45
|
+
init(_config: ActorConfig): Promise<void>;
|
|
46
|
+
/** Make subsequent deliveries reject */
|
|
47
|
+
setReject(reject: boolean): void;
|
|
48
|
+
/** Make subsequent deliveries error */
|
|
49
|
+
setError(error: boolean): void;
|
|
50
|
+
deliver(event: OrgLoopEvent, routeConfig: RouteDeliveryConfig): Promise<DeliveryResult>;
|
|
51
|
+
shutdown(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Mock transform for testing.
|
|
55
|
+
* Can be configured to pass, drop, or modify events.
|
|
56
|
+
*/
|
|
57
|
+
export declare class MockTransform implements Transform {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly processed: Array<{
|
|
60
|
+
event: OrgLoopEvent;
|
|
61
|
+
context: TransformContext;
|
|
62
|
+
}>;
|
|
63
|
+
private dropAll;
|
|
64
|
+
private modifier?;
|
|
65
|
+
initialized: boolean;
|
|
66
|
+
shutdownCalled: boolean;
|
|
67
|
+
constructor(id?: string);
|
|
68
|
+
init(_config: Record<string, unknown>): Promise<void>;
|
|
69
|
+
/** Make the transform drop all events */
|
|
70
|
+
setDrop(drop: boolean): void;
|
|
71
|
+
/** Set a modifier function that transforms events */
|
|
72
|
+
setModifier(fn: (event: OrgLoopEvent) => OrgLoopEvent): void;
|
|
73
|
+
execute(event: OrgLoopEvent, context: TransformContext): Promise<OrgLoopEvent | null>;
|
|
74
|
+
shutdown(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mock logger for testing.
|
|
78
|
+
* Records all log entries for assertion.
|
|
79
|
+
*/
|
|
80
|
+
export declare class MockLogger implements Logger {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly entries: LogEntry[];
|
|
83
|
+
initialized: boolean;
|
|
84
|
+
flushed: boolean;
|
|
85
|
+
shutdownCalled: boolean;
|
|
86
|
+
constructor(id?: string);
|
|
87
|
+
init(_config: Record<string, unknown>): Promise<void>;
|
|
88
|
+
log(entry: LogEntry): Promise<void>;
|
|
89
|
+
flush(): Promise<void>;
|
|
90
|
+
shutdown(): Promise<void>;
|
|
91
|
+
/** Get entries for a specific phase */
|
|
92
|
+
entriesForPhase(phase: LogEntry['phase']): LogEntry[];
|
|
93
|
+
/** Get entries for a specific event */
|
|
94
|
+
entriesForEvent(eventId: string): LogEntry[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a test event with sensible defaults.
|
|
98
|
+
*/
|
|
99
|
+
export declare function createTestEvent(overrides?: Partial<BuildEventOptions>): OrgLoopEvent;
|
|
100
|
+
/**
|
|
101
|
+
* Create a test transform context with sensible defaults.
|
|
102
|
+
*/
|
|
103
|
+
export declare function createTestContext(overrides?: Partial<TransformContext>): TransformContext;
|
|
104
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EACX,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAK;IACtB,WAAW,UAAS;IACpB,cAAc,UAAS;gBAEX,EAAE,SAAgB;IAIxB,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,wDAAwD;IACxD,SAAS,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI;IAIpC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAUrD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;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transforms, and loggers in isolation.
|
|
6
|
+
*/
|
|
7
|
+
import { buildEvent } from './event.js';
|
|
8
|
+
// ─── Mock Source ──────────────────────────────────────────────────────────────
|
|
9
|
+
/**
|
|
10
|
+
* Mock source connector for testing.
|
|
11
|
+
* Returns pre-configured events on poll().
|
|
12
|
+
*/
|
|
13
|
+
export class MockSource {
|
|
14
|
+
id;
|
|
15
|
+
events = [];
|
|
16
|
+
pollCount = 0;
|
|
17
|
+
initialized = false;
|
|
18
|
+
shutdownCalled = false;
|
|
19
|
+
constructor(id = 'mock-source') {
|
|
20
|
+
this.id = id;
|
|
21
|
+
}
|
|
22
|
+
async init(_config) {
|
|
23
|
+
this.initialized = true;
|
|
24
|
+
}
|
|
25
|
+
/** Add events that will be returned on the next poll */
|
|
26
|
+
addEvents(...events) {
|
|
27
|
+
this.events.push(...events);
|
|
28
|
+
}
|
|
29
|
+
async poll(_checkpoint) {
|
|
30
|
+
this.pollCount++;
|
|
31
|
+
const events = [...this.events];
|
|
32
|
+
this.events = [];
|
|
33
|
+
return {
|
|
34
|
+
events,
|
|
35
|
+
checkpoint: `mock-checkpoint-${this.pollCount}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async shutdown() {
|
|
39
|
+
this.shutdownCalled = true;
|
|
40
|
+
}
|
|
41
|
+
get totalPolls() {
|
|
42
|
+
return this.pollCount;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// ─── Mock Actor ───────────────────────────────────────────────────────────────
|
|
46
|
+
/**
|
|
47
|
+
* Mock actor connector for testing.
|
|
48
|
+
* Records all delivered events for assertion.
|
|
49
|
+
*/
|
|
50
|
+
export class MockActor {
|
|
51
|
+
id;
|
|
52
|
+
delivered = [];
|
|
53
|
+
shouldReject = false;
|
|
54
|
+
shouldError = false;
|
|
55
|
+
initialized = false;
|
|
56
|
+
shutdownCalled = false;
|
|
57
|
+
constructor(id = 'mock-actor') {
|
|
58
|
+
this.id = id;
|
|
59
|
+
}
|
|
60
|
+
async init(_config) {
|
|
61
|
+
this.initialized = true;
|
|
62
|
+
}
|
|
63
|
+
/** Make subsequent deliveries reject */
|
|
64
|
+
setReject(reject) {
|
|
65
|
+
this.shouldReject = reject;
|
|
66
|
+
}
|
|
67
|
+
/** Make subsequent deliveries error */
|
|
68
|
+
setError(error) {
|
|
69
|
+
this.shouldError = error;
|
|
70
|
+
}
|
|
71
|
+
async deliver(event, routeConfig) {
|
|
72
|
+
this.delivered.push({ event, config: routeConfig });
|
|
73
|
+
if (this.shouldError) {
|
|
74
|
+
return { status: 'error', error: new Error('Mock delivery error') };
|
|
75
|
+
}
|
|
76
|
+
if (this.shouldReject) {
|
|
77
|
+
return { status: 'rejected' };
|
|
78
|
+
}
|
|
79
|
+
return { status: 'delivered' };
|
|
80
|
+
}
|
|
81
|
+
async shutdown() {
|
|
82
|
+
this.shutdownCalled = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// ─── Mock Transform ───────────────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* Mock transform for testing.
|
|
88
|
+
* Can be configured to pass, drop, or modify events.
|
|
89
|
+
*/
|
|
90
|
+
export class MockTransform {
|
|
91
|
+
id;
|
|
92
|
+
processed = [];
|
|
93
|
+
dropAll = false;
|
|
94
|
+
modifier;
|
|
95
|
+
initialized = false;
|
|
96
|
+
shutdownCalled = false;
|
|
97
|
+
constructor(id = 'mock-transform') {
|
|
98
|
+
this.id = id;
|
|
99
|
+
}
|
|
100
|
+
async init(_config) {
|
|
101
|
+
this.initialized = true;
|
|
102
|
+
}
|
|
103
|
+
/** Make the transform drop all events */
|
|
104
|
+
setDrop(drop) {
|
|
105
|
+
this.dropAll = drop;
|
|
106
|
+
}
|
|
107
|
+
/** Set a modifier function that transforms events */
|
|
108
|
+
setModifier(fn) {
|
|
109
|
+
this.modifier = fn;
|
|
110
|
+
}
|
|
111
|
+
async execute(event, context) {
|
|
112
|
+
this.processed.push({ event, context });
|
|
113
|
+
if (this.dropAll)
|
|
114
|
+
return null;
|
|
115
|
+
if (this.modifier)
|
|
116
|
+
return this.modifier(event);
|
|
117
|
+
return event;
|
|
118
|
+
}
|
|
119
|
+
async shutdown() {
|
|
120
|
+
this.shutdownCalled = true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ─── Mock Logger ──────────────────────────────────────────────────────────────
|
|
124
|
+
/**
|
|
125
|
+
* Mock logger for testing.
|
|
126
|
+
* Records all log entries for assertion.
|
|
127
|
+
*/
|
|
128
|
+
export class MockLogger {
|
|
129
|
+
id;
|
|
130
|
+
entries = [];
|
|
131
|
+
initialized = false;
|
|
132
|
+
flushed = false;
|
|
133
|
+
shutdownCalled = false;
|
|
134
|
+
constructor(id = 'mock-logger') {
|
|
135
|
+
this.id = id;
|
|
136
|
+
}
|
|
137
|
+
async init(_config) {
|
|
138
|
+
this.initialized = true;
|
|
139
|
+
}
|
|
140
|
+
async log(entry) {
|
|
141
|
+
this.entries.push(entry);
|
|
142
|
+
}
|
|
143
|
+
async flush() {
|
|
144
|
+
this.flushed = true;
|
|
145
|
+
}
|
|
146
|
+
async shutdown() {
|
|
147
|
+
this.flushed = true;
|
|
148
|
+
this.shutdownCalled = true;
|
|
149
|
+
}
|
|
150
|
+
/** Get entries for a specific phase */
|
|
151
|
+
entriesForPhase(phase) {
|
|
152
|
+
return this.entries.filter((e) => e.phase === phase);
|
|
153
|
+
}
|
|
154
|
+
/** Get entries for a specific event */
|
|
155
|
+
entriesForEvent(eventId) {
|
|
156
|
+
return this.entries.filter((e) => e.event_id === eventId);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// ─── Test Event Factory ───────────────────────────────────────────────────────
|
|
160
|
+
/**
|
|
161
|
+
* Create a test event with sensible defaults.
|
|
162
|
+
*/
|
|
163
|
+
export function createTestEvent(overrides) {
|
|
164
|
+
return buildEvent({
|
|
165
|
+
source: 'test-source',
|
|
166
|
+
type: 'resource.changed',
|
|
167
|
+
provenance: {
|
|
168
|
+
platform: 'test',
|
|
169
|
+
author: 'test-author',
|
|
170
|
+
author_type: 'team_member',
|
|
171
|
+
},
|
|
172
|
+
payload: { test: true },
|
|
173
|
+
...overrides,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a test transform context with sensible defaults.
|
|
178
|
+
*/
|
|
179
|
+
export function createTestContext(overrides) {
|
|
180
|
+
return {
|
|
181
|
+
source: 'test-source',
|
|
182
|
+
target: 'test-actor',
|
|
183
|
+
eventType: 'resource.changed',
|
|
184
|
+
routeName: 'test-route',
|
|
185
|
+
...overrides,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAA0B,UAAU,EAAE,MAAM,YAAY,CAAC;AAWhE,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,EAAE,CAAS;IACZ,MAAM,GAAmB,EAAE,CAAC;IAC5B,SAAS,GAAG,CAAC,CAAC;IACtB,WAAW,GAAG,KAAK,CAAC;IACpB,cAAc,GAAG,KAAK,CAAC;IAEvB,YAAY,EAAE,GAAG,aAAa;QAC7B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAqB;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,wDAAwD;IACxD,SAAS,CAAC,GAAG,MAAsB;QAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAA0B;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,IA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