@orgloop/core 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/bus.d.ts +35 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +76 -0
- package/dist/bus.js.map +1 -0
- package/dist/engine.d.ts +88 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +401 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +55 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +75 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +49 -0
- package/dist/logger.js.map +1 -0
- package/dist/router.d.ts +17 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +55 -0
- package/dist/router.js.map +1 -0
- package/dist/scheduler.d.ts +27 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +62 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/schema.d.ts +24 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +186 -0
- package/dist/schema.js.map +1 -0
- package/dist/store.d.ts +51 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +133 -0
- package/dist/store.js.map +1 -0
- package/dist/transform.d.ts +32 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +158 -0
- package/dist/transform.js.map +1 -0
- package/package.json +38 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error taxonomy for OrgLoop.
|
|
3
|
+
*
|
|
4
|
+
* Every error in the system extends OrgLoopError, giving callers
|
|
5
|
+
* a consistent shape to catch and inspect.
|
|
6
|
+
*/
|
|
7
|
+
export declare class OrgLoopError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
constructor(code: string, message: string, options?: ErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
export declare class ConfigError extends OrgLoopError {
|
|
12
|
+
constructor(message: string, options?: ErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
export declare class ConnectorError extends OrgLoopError {
|
|
15
|
+
readonly connectorId: string;
|
|
16
|
+
constructor(connectorId: string, message: string, options?: ErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
export declare class TransformError extends OrgLoopError {
|
|
19
|
+
readonly transformId: string;
|
|
20
|
+
constructor(transformId: string, message: string, options?: ErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
export declare class DeliveryError extends OrgLoopError {
|
|
23
|
+
readonly actorId: string;
|
|
24
|
+
readonly routeName: string;
|
|
25
|
+
constructor(actorId: string, routeName: string, message: string, options?: ErrorOptions);
|
|
26
|
+
}
|
|
27
|
+
export declare class SchemaError extends OrgLoopError {
|
|
28
|
+
readonly validationErrors: string[];
|
|
29
|
+
constructor(message: string, validationErrors?: string[], options?: ErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,YAAa,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKjE;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAInD;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKxE;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKxE;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAMvF;AAED,qBAAa,WAAY,SAAQ,YAAY;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAM,EAAO,EAAE,OAAO,CAAC,EAAE,YAAY;CAKpF"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error taxonomy for OrgLoop.
|
|
3
|
+
*
|
|
4
|
+
* Every error in the system extends OrgLoopError, giving callers
|
|
5
|
+
* a consistent shape to catch and inspect.
|
|
6
|
+
*/
|
|
7
|
+
export class OrgLoopError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = 'OrgLoopError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class ConfigError extends OrgLoopError {
|
|
16
|
+
constructor(message, options) {
|
|
17
|
+
super('CONFIG_ERROR', message, options);
|
|
18
|
+
this.name = 'ConfigError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class ConnectorError extends OrgLoopError {
|
|
22
|
+
connectorId;
|
|
23
|
+
constructor(connectorId, message, options) {
|
|
24
|
+
super('CONNECTOR_ERROR', `[${connectorId}] ${message}`, options);
|
|
25
|
+
this.name = 'ConnectorError';
|
|
26
|
+
this.connectorId = connectorId;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class TransformError extends OrgLoopError {
|
|
30
|
+
transformId;
|
|
31
|
+
constructor(transformId, message, options) {
|
|
32
|
+
super('TRANSFORM_ERROR', `[${transformId}] ${message}`, options);
|
|
33
|
+
this.name = 'TransformError';
|
|
34
|
+
this.transformId = transformId;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class DeliveryError extends OrgLoopError {
|
|
38
|
+
actorId;
|
|
39
|
+
routeName;
|
|
40
|
+
constructor(actorId, routeName, message, options) {
|
|
41
|
+
super('DELIVERY_ERROR', `[${actorId}/${routeName}] ${message}`, options);
|
|
42
|
+
this.name = 'DeliveryError';
|
|
43
|
+
this.actorId = actorId;
|
|
44
|
+
this.routeName = routeName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class SchemaError extends OrgLoopError {
|
|
48
|
+
validationErrors;
|
|
49
|
+
constructor(message, validationErrors = [], options) {
|
|
50
|
+
super('SCHEMA_ERROR', message, options);
|
|
51
|
+
this.name = 'SchemaError';
|
|
52
|
+
this.validationErrors = validationErrors;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC7B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe,EAAE,OAAsB;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,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C,gBAAgB,CAAW;IAEpC,YAAY,OAAe,EAAE,mBAA6B,EAAE,EAAE,OAAsB;QACnF,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,CAAC;CACD"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebhookServer — lightweight HTTP server for webhook-based sources.
|
|
3
|
+
*
|
|
4
|
+
* Listens on localhost only. Routes POST /webhook/:sourceId to registered handlers.
|
|
5
|
+
* No auth, no CORS — just local event ingestion.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrgLoopEvent, WebhookHandler } from '@orgloop/sdk';
|
|
8
|
+
export declare const DEFAULT_HTTP_PORT = 4800;
|
|
9
|
+
export declare class WebhookServer {
|
|
10
|
+
private readonly handlers;
|
|
11
|
+
private readonly onEvent;
|
|
12
|
+
private server;
|
|
13
|
+
constructor(handlers: Map<string, WebhookHandler>, onEvent: (event: OrgLoopEvent) => Promise<void>);
|
|
14
|
+
start(port: number): Promise<void>;
|
|
15
|
+
stop(): Promise<void>;
|
|
16
|
+
private handleRequest;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEjE,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,MAAM,CAAgD;gBAG7D,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACrC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC;IAM1C,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAalC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAWb,aAAa;CAuC3B"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebhookServer — lightweight HTTP server for webhook-based sources.
|
|
3
|
+
*
|
|
4
|
+
* Listens on localhost only. Routes POST /webhook/:sourceId to registered handlers.
|
|
5
|
+
* No auth, no CORS — just local event ingestion.
|
|
6
|
+
*/
|
|
7
|
+
import { createServer } from 'node:http';
|
|
8
|
+
export const DEFAULT_HTTP_PORT = 4800;
|
|
9
|
+
export class WebhookServer {
|
|
10
|
+
handlers;
|
|
11
|
+
onEvent;
|
|
12
|
+
server = null;
|
|
13
|
+
constructor(handlers, onEvent) {
|
|
14
|
+
this.handlers = handlers;
|
|
15
|
+
this.onEvent = onEvent;
|
|
16
|
+
}
|
|
17
|
+
async start(port) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
this.server = createServer((req, res) => {
|
|
20
|
+
void this.handleRequest(req, res);
|
|
21
|
+
});
|
|
22
|
+
this.server.on('error', reject);
|
|
23
|
+
this.server.listen(port, '127.0.0.1', () => {
|
|
24
|
+
resolve();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async stop() {
|
|
29
|
+
const srv = this.server;
|
|
30
|
+
if (!srv)
|
|
31
|
+
return;
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
srv.close(() => {
|
|
34
|
+
this.server = null;
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async handleRequest(req, res) {
|
|
40
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
41
|
+
const parts = url.pathname.split('/').filter(Boolean);
|
|
42
|
+
// Route: POST /webhook/:sourceId
|
|
43
|
+
if (parts.length !== 2 || parts[0] !== 'webhook') {
|
|
44
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
45
|
+
res.end(JSON.stringify({ error: 'Not found' }));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const sourceId = parts[1];
|
|
49
|
+
if (req.method !== 'POST') {
|
|
50
|
+
res.writeHead(405, { 'Content-Type': 'application/json' });
|
|
51
|
+
res.end(JSON.stringify({ error: 'Method not allowed' }));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const handler = this.handlers.get(sourceId);
|
|
55
|
+
if (!handler) {
|
|
56
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
57
|
+
res.end(JSON.stringify({ error: `Unknown source: ${sourceId}` }));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const events = await handler(req, res);
|
|
62
|
+
for (const event of events) {
|
|
63
|
+
await this.onEvent(event);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
// If the handler hasn't written a response yet, send 500
|
|
68
|
+
if (!res.headersSent) {
|
|
69
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
70
|
+
res.end(JSON.stringify({ error: err instanceof Error ? err.message : 'Internal error' }));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA6C,YAAY,EAAE,MAAM,WAAW,CAAC;AAGpF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE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M,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,yDAAyD;YACzD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACtB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;gBAC3D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YAC3F,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @orgloop/core — OrgLoop Runtime Engine
|
|
3
|
+
*
|
|
4
|
+
* Public API exports for library mode.
|
|
5
|
+
*/
|
|
6
|
+
export { OrgLoop } from './engine.js';
|
|
7
|
+
export type { OrgLoopOptions, EngineStatus } from './engine.js';
|
|
8
|
+
export { loadConfig, buildConfig } from './schema.js';
|
|
9
|
+
export type { LoadConfigOptions } from './schema.js';
|
|
10
|
+
export { OrgLoopError, ConfigError, ConnectorError, TransformError, DeliveryError, SchemaError, } from './errors.js';
|
|
11
|
+
export { InMemoryBus, FileWalBus } from './bus.js';
|
|
12
|
+
export type { EventBus, BusHandler } from './bus.js';
|
|
13
|
+
export { FileCheckpointStore, FileEventStore, InMemoryCheckpointStore, InMemoryEventStore, } from './store.js';
|
|
14
|
+
export type { CheckpointStore, EventStore, WalEntry } from './store.js';
|
|
15
|
+
export { matchRoutes } from './router.js';
|
|
16
|
+
export type { MatchedRoute } from './router.js';
|
|
17
|
+
export { executeTransformPipeline } from './transform.js';
|
|
18
|
+
export type { TransformPipelineOptions, TransformPipelineResult } from './transform.js';
|
|
19
|
+
export { LoggerManager } from './logger.js';
|
|
20
|
+
export { Scheduler } from './scheduler.js';
|
|
21
|
+
export { WebhookServer, DEFAULT_HTTP_PORT } from './http.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EACN,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,WAAW,GACX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,EACN,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGxE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @orgloop/core — OrgLoop Runtime Engine
|
|
3
|
+
*
|
|
4
|
+
* Public API exports for library mode.
|
|
5
|
+
*/
|
|
6
|
+
// Main engine
|
|
7
|
+
export { OrgLoop } from './engine.js';
|
|
8
|
+
// Config loading
|
|
9
|
+
export { loadConfig, buildConfig } from './schema.js';
|
|
10
|
+
// Errors
|
|
11
|
+
export { OrgLoopError, ConfigError, ConnectorError, TransformError, DeliveryError, SchemaError, } from './errors.js';
|
|
12
|
+
// Event bus
|
|
13
|
+
export { InMemoryBus, FileWalBus } from './bus.js';
|
|
14
|
+
// Stores
|
|
15
|
+
export { FileCheckpointStore, FileEventStore, InMemoryCheckpointStore, InMemoryEventStore, } from './store.js';
|
|
16
|
+
// Router
|
|
17
|
+
export { matchRoutes } from './router.js';
|
|
18
|
+
// Transform pipeline
|
|
19
|
+
export { executeTransformPipeline } from './transform.js';
|
|
20
|
+
// Logger manager
|
|
21
|
+
export { LoggerManager } from './logger.js';
|
|
22
|
+
// Scheduler
|
|
23
|
+
export { Scheduler } from './scheduler.js';
|
|
24
|
+
// HTTP webhook server
|
|
25
|
+
export { WebhookServer, DEFAULT_HTTP_PORT } from './http.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc;AACd,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,iBAAiB;AACjB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGtD,SAAS;AACT,OAAO,EACN,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGnD,SAAS;AACT,OAAO,EACN,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,GAClB,MAAM,YAAY,CAAC;AAGpB,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,qBAAqB;AACrB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,sBAAsB;AACtB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger fan-out manager.
|
|
3
|
+
*
|
|
4
|
+
* Fans out LogEntry to all configured loggers.
|
|
5
|
+
* Non-blocking: errors in one logger don't affect others.
|
|
6
|
+
*/
|
|
7
|
+
import type { LogEntry } from '@orgloop/sdk';
|
|
8
|
+
import type { Logger } from '@orgloop/sdk';
|
|
9
|
+
export declare class LoggerManager {
|
|
10
|
+
private readonly loggers;
|
|
11
|
+
addLogger(logger: Logger): void;
|
|
12
|
+
/**
|
|
13
|
+
* Fan out a log entry to all loggers.
|
|
14
|
+
* Non-blocking: fires all loggers concurrently, catches individual errors.
|
|
15
|
+
*/
|
|
16
|
+
log(entry: LogEntry): Promise<void>;
|
|
17
|
+
/** Flush all loggers */
|
|
18
|
+
flush(): Promise<void>;
|
|
19
|
+
/** Shutdown all loggers */
|
|
20
|
+
shutdown(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IAExC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACG,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzC,wBAAwB;IAClB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B,2BAA2B;IACrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAW/B"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger fan-out manager.
|
|
3
|
+
*
|
|
4
|
+
* Fans out LogEntry to all configured loggers.
|
|
5
|
+
* Non-blocking: errors in one logger don't affect others.
|
|
6
|
+
*/
|
|
7
|
+
export class LoggerManager {
|
|
8
|
+
loggers = [];
|
|
9
|
+
addLogger(logger) {
|
|
10
|
+
this.loggers.push(logger);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fan out a log entry to all loggers.
|
|
14
|
+
* Non-blocking: fires all loggers concurrently, catches individual errors.
|
|
15
|
+
*/
|
|
16
|
+
async log(entry) {
|
|
17
|
+
await Promise.allSettled(this.loggers.map(async (logger) => {
|
|
18
|
+
try {
|
|
19
|
+
await logger.log(entry);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Swallow — one logger's failure must not affect others
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/** Flush all loggers */
|
|
27
|
+
async flush() {
|
|
28
|
+
await Promise.allSettled(this.loggers.map(async (logger) => {
|
|
29
|
+
try {
|
|
30
|
+
await logger.flush();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Swallow
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/** Shutdown all loggers */
|
|
38
|
+
async shutdown() {
|
|
39
|
+
await Promise.allSettled(this.loggers.map(async (logger) => {
|
|
40
|
+
try {
|
|
41
|
+
await logger.shutdown();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Swallow
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,OAAO,aAAa;IACR,OAAO,GAAa,EAAE,CAAC;IAExC,SAAS,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,KAAe;QACxB,MAAM,OAAO,CAAC,UAAU,CACvB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACjC,IAAI,CAAC;gBACJ,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;YAAC,MAAM,CAAC;gBACR,wDAAwD;YACzD,CAAC;QACF,CAAC,CAAC,CACF,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,KAAK;QACV,MAAM,OAAO,CAAC,UAAU,CACvB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACjC,IAAI,CAAC;gBACJ,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACR,UAAU;YACX,CAAC;QACF,CAAC,CAAC,CACF,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,KAAK,CAAC,QAAQ;QACb,MAAM,OAAO,CAAC,UAAU,CACvB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACjC,IAAI,CAAC;gBACJ,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC;YAAC,MAAM,CAAC;gBACR,UAAU;YACX,CAAC;QACF,CAAC,CAAC,CACF,CAAC;IACH,CAAC;CACD"}
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route matching + dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Matches events against routes using `when` criteria (source, events, filter).
|
|
5
|
+
* Supports multi-route matching: one event can match many routes.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrgLoopEvent, RouteDefinition } from '@orgloop/sdk';
|
|
8
|
+
export interface MatchedRoute {
|
|
9
|
+
route: RouteDefinition;
|
|
10
|
+
event: OrgLoopEvent;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Find all routes that match a given event.
|
|
14
|
+
* Returns all matched routes (multi-match supported).
|
|
15
|
+
*/
|
|
16
|
+
export declare function matchRoutes(event: OrgLoopEvent, routes: RouteDefinition[]): MatchedRoute[];
|
|
17
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA6ClE,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,CAQ1F"}
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route matching + dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Matches events against routes using `when` criteria (source, events, filter).
|
|
5
|
+
* Supports multi-route matching: one event can match many routes.
|
|
6
|
+
*/
|
|
7
|
+
// ─── Dot-path field access ────────────────────────────────────────────────────
|
|
8
|
+
function getNestedValue(obj, path) {
|
|
9
|
+
const parts = path.split('.');
|
|
10
|
+
let current = obj;
|
|
11
|
+
for (const part of parts) {
|
|
12
|
+
if (current === null || current === undefined || typeof current !== 'object') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
current = current[part];
|
|
16
|
+
}
|
|
17
|
+
return current;
|
|
18
|
+
}
|
|
19
|
+
// ─── Filter matching ──────────────────────────────────────────────────────────
|
|
20
|
+
function matchesFilter(event, filter) {
|
|
21
|
+
for (const [path, expected] of Object.entries(filter)) {
|
|
22
|
+
const actual = getNestedValue(event, path);
|
|
23
|
+
if (actual !== expected)
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// ─── Route matching ───────────────────────────────────────────────────────────
|
|
29
|
+
function matchesRoute(event, route) {
|
|
30
|
+
const { when } = route;
|
|
31
|
+
// Match source
|
|
32
|
+
if (when.source !== event.source)
|
|
33
|
+
return false;
|
|
34
|
+
// Match event type
|
|
35
|
+
if (!when.events.includes(event.type))
|
|
36
|
+
return false;
|
|
37
|
+
// Match filter (optional)
|
|
38
|
+
if (when.filter && !matchesFilter(event, when.filter))
|
|
39
|
+
return false;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Find all routes that match a given event.
|
|
44
|
+
* Returns all matched routes (multi-match supported).
|
|
45
|
+
*/
|
|
46
|
+
export function matchRoutes(event, routes) {
|
|
47
|
+
const matched = [];
|
|
48
|
+
for (const route of routes) {
|
|
49
|
+
if (matchesRoute(event, route)) {
|
|
50
|
+
matched.push({ route, event });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return matched;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,iFAAiF;AAEjF,SAAS,cAAc,CAAC,GAAY,EAAE,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAY,GAAG,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9E,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,iFAAiF;AAEjF,SAAS,aAAa,CAAC,KAAmB,EAAE,MAA+B;IAC1E,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,MAAM,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,iFAAiF;AAEjF,SAAS,YAAY,CAAC,KAAmB,EAAE,KAAsB;IAChE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEvB,eAAe;IACf,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAE/C,mBAAmB;IACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpD,0BAA0B;IAC1B,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpE,OAAO,IAAI,CAAC;AACb,CAAC;AASD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAmB,EAAE,MAAyB;IACzE,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,IAAI,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Poll scheduling.
|
|
3
|
+
*
|
|
4
|
+
* Schedules poll operations for sources based on their configured intervals.
|
|
5
|
+
* Graceful start/stop with interval cleanup.
|
|
6
|
+
*/
|
|
7
|
+
export type PollCallback = (sourceId: string) => Promise<void>;
|
|
8
|
+
export declare class Scheduler {
|
|
9
|
+
private readonly sources;
|
|
10
|
+
private running;
|
|
11
|
+
private pollCallback;
|
|
12
|
+
/**
|
|
13
|
+
* Register a source to be polled at the given interval.
|
|
14
|
+
*/
|
|
15
|
+
addSource(sourceId: string, interval: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Start polling all registered sources.
|
|
18
|
+
*/
|
|
19
|
+
start(callback: PollCallback): void;
|
|
20
|
+
private safePoll;
|
|
21
|
+
/**
|
|
22
|
+
* Stop all scheduled polls.
|
|
23
|
+
*/
|
|
24
|
+
stop(): void;
|
|
25
|
+
get isRunning(): boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAQ/D,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAA6B;IAEjD;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnD;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;YAerB,QAAQ;IAStB;;OAEG;IACH,IAAI,IAAI,IAAI;IAUZ,IAAI,SAAS,IAAI,OAAO,CAEvB;CACD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Poll scheduling.
|
|
3
|
+
*
|
|
4
|
+
* Schedules poll operations for sources based on their configured intervals.
|
|
5
|
+
* Graceful start/stop with interval cleanup.
|
|
6
|
+
*/
|
|
7
|
+
import { parseDuration } from '@orgloop/sdk';
|
|
8
|
+
export class Scheduler {
|
|
9
|
+
sources = [];
|
|
10
|
+
running = false;
|
|
11
|
+
pollCallback = null;
|
|
12
|
+
/**
|
|
13
|
+
* Register a source to be polled at the given interval.
|
|
14
|
+
*/
|
|
15
|
+
addSource(sourceId, interval) {
|
|
16
|
+
const intervalMs = parseDuration(interval);
|
|
17
|
+
this.sources.push({ sourceId, intervalMs, timer: null });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Start polling all registered sources.
|
|
21
|
+
*/
|
|
22
|
+
start(callback) {
|
|
23
|
+
if (this.running)
|
|
24
|
+
return;
|
|
25
|
+
this.running = true;
|
|
26
|
+
this.pollCallback = callback;
|
|
27
|
+
for (const source of this.sources) {
|
|
28
|
+
// Run first poll immediately
|
|
29
|
+
void this.safePoll(source.sourceId);
|
|
30
|
+
// Then schedule recurring polls
|
|
31
|
+
source.timer = setInterval(() => {
|
|
32
|
+
void this.safePoll(source.sourceId);
|
|
33
|
+
}, source.intervalMs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async safePoll(sourceId) {
|
|
37
|
+
if (!this.pollCallback)
|
|
38
|
+
return;
|
|
39
|
+
try {
|
|
40
|
+
await this.pollCallback(sourceId);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Errors handled upstream; scheduler keeps going
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Stop all scheduled polls.
|
|
48
|
+
*/
|
|
49
|
+
stop() {
|
|
50
|
+
this.running = false;
|
|
51
|
+
for (const source of this.sources) {
|
|
52
|
+
if (source.timer) {
|
|
53
|
+
clearInterval(source.timer);
|
|
54
|
+
source.timer = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
get isRunning() {
|
|
59
|
+
return this.running;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAU7C,MAAM,OAAO,SAAS;IACJ,OAAO,GAAsB,EAAE,CAAC;IACzC,OAAO,GAAG,KAAK,CAAC;IAChB,YAAY,GAAwB,IAAI,CAAC;IAEjD;;OAEG;IACH,SAAS,CAAC,QAAgB,EAAE,QAAgB;QAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ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
|
1
|
+
/**
|
|
2
|
+
* YAML config loading + JSON Schema validation.
|
|
3
|
+
*
|
|
4
|
+
* Loads orgloop.yaml and all referenced YAML files, resolves ${} env vars,
|
|
5
|
+
* validates against schema, and returns a fully resolved OrgLoopConfig.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrgLoopConfig } from '@orgloop/sdk';
|
|
8
|
+
export interface LoadConfigOptions {
|
|
9
|
+
/** Path to orgloop.yaml */
|
|
10
|
+
configPath: string;
|
|
11
|
+
/** Additional route YAML files */
|
|
12
|
+
routeFiles?: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load and validate an OrgLoop configuration from YAML.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadConfig(options: LoadConfigOptions): Promise<OrgLoopConfig>;
|
|
18
|
+
/**
|
|
19
|
+
* Build an OrgLoopConfig programmatically (for library/testing use).
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildConfig(partial: Partial<OrgLoopConfig> & {
|
|
22
|
+
project: OrgLoopConfig['project'];
|
|
23
|
+
}): OrgLoopConfig;
|
|
24
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAGX,aAAa,EAKb,MAAM,cAAc,CAAC;AA0KtB,MAAM,WAAW,iBAAiB;IACjC,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyCnF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;CAAE,GACrE,aAAa,CAWf"}
|