@boringos/workflow 0.1.1 → 0.1.3
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/handlers/connector-action.d.ts +2 -4
- package/dist/handlers/connector-action.d.ts.map +1 -1
- package/dist/handlers/connector-action.js +80 -13
- package/dist/handlers/connector-action.js.map +1 -1
- package/dist/handlers/create-inbox-item.d.ts +17 -0
- package/dist/handlers/create-inbox-item.d.ts.map +1 -0
- package/dist/handlers/create-inbox-item.js +78 -0
- package/dist/handlers/create-inbox-item.js.map +1 -0
- package/dist/handlers/emit-event.d.ts +15 -0
- package/dist/handlers/emit-event.d.ts.map +1 -0
- package/dist/handlers/emit-event.js +53 -0
- package/dist/handlers/emit-event.js.map +1 -0
- package/dist/handlers/for-each.d.ts +17 -0
- package/dist/handlers/for-each.d.ts.map +1 -0
- package/dist/handlers/for-each.js +41 -0
- package/dist/handlers/for-each.js.map +1 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +3 -0
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +6 -1
- package/dist/state.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import type { BlockHandler } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Connector-action block handler — calls a connector action from within a workflow.
|
|
4
|
+
* Auto-refreshes OAuth tokens on failure and retries once.
|
|
4
5
|
*
|
|
5
6
|
* Config:
|
|
6
7
|
* connectorKind: string (required) — e.g., "google", "slack"
|
|
7
8
|
* action: string (required) — e.g., "list_emails", "send_message"
|
|
8
9
|
* inputs?: Record<string, unknown> — action inputs
|
|
9
10
|
*
|
|
10
|
-
* Output:
|
|
11
|
-
* { success: boolean, data?: Record<string, unknown>, error?: string }
|
|
12
|
-
*
|
|
13
11
|
* Requires "actionRunner" and "db" in services.
|
|
14
|
-
*
|
|
12
|
+
* Optionally uses "connectorRegistry" for OAuth config to refresh tokens.
|
|
15
13
|
*/
|
|
16
14
|
export declare const connectorActionHandler: BlockHandler;
|
|
17
15
|
//# sourceMappingURL=connector-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-action.d.ts","sourceRoot":"","sources":["../../src/handlers/connector-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAEzF
|
|
1
|
+
{"version":3,"file":"connector-action.d.ts","sourceRoot":"","sources":["../../src/handlers/connector-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,YA8FpC,CAAC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Connector-action block handler — calls a connector action from within a workflow.
|
|
3
|
+
* Auto-refreshes OAuth tokens on failure and retries once.
|
|
3
4
|
*
|
|
4
5
|
* Config:
|
|
5
6
|
* connectorKind: string (required) — e.g., "google", "slack"
|
|
6
7
|
* action: string (required) — e.g., "list_emails", "send_message"
|
|
7
8
|
* inputs?: Record<string, unknown> — action inputs
|
|
8
9
|
*
|
|
9
|
-
* Output:
|
|
10
|
-
* { success: boolean, data?: Record<string, unknown>, error?: string }
|
|
11
|
-
*
|
|
12
10
|
* Requires "actionRunner" and "db" in services.
|
|
13
|
-
*
|
|
11
|
+
* Optionally uses "connectorRegistry" for OAuth config to refresh tokens.
|
|
14
12
|
*/
|
|
15
13
|
export const connectorActionHandler = {
|
|
16
14
|
types: ["connector-action"],
|
|
@@ -25,7 +23,6 @@ export const connectorActionHandler = {
|
|
|
25
23
|
if (!actionRunner) {
|
|
26
24
|
return { output: { success: false, error: "actionRunner not available in services" } };
|
|
27
25
|
}
|
|
28
|
-
// Fetch connector credentials from DB
|
|
29
26
|
const db = ctx.services.get("db");
|
|
30
27
|
if (!db) {
|
|
31
28
|
return { output: { success: false, error: "db not available in services" } };
|
|
@@ -43,19 +40,89 @@ export const connectorActionHandler = {
|
|
|
43
40
|
output: { success: false, error: `Connector ${connectorKind} not configured for tenant` },
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
const result = await actionRunner.execute({
|
|
43
|
+
const creds = connectorRow.credentials;
|
|
44
|
+
let accessToken = creds?.accessToken ?? "";
|
|
45
|
+
const refreshToken = creds?.refreshToken;
|
|
46
|
+
const request = {
|
|
52
47
|
connectorKind,
|
|
53
48
|
action,
|
|
54
49
|
tenantId: ctx.tenantId,
|
|
55
50
|
agentId: ctx.governingAgentId ?? "",
|
|
56
51
|
inputs: inputs ?? {},
|
|
57
|
-
}
|
|
58
|
-
|
|
52
|
+
};
|
|
53
|
+
// First attempt
|
|
54
|
+
let result = await actionRunner.execute(request, {
|
|
55
|
+
accessToken,
|
|
56
|
+
refreshToken,
|
|
57
|
+
config: connectorRow.config,
|
|
58
|
+
});
|
|
59
|
+
// If failed and we have a refresh token, try refreshing
|
|
60
|
+
if (!result.success && refreshToken && result.error?.includes("401")) {
|
|
61
|
+
const newToken = await tryRefreshToken(connectorKind, refreshToken, creds);
|
|
62
|
+
if (newToken) {
|
|
63
|
+
// Update stored credentials
|
|
64
|
+
await db.update(connectors).set({
|
|
65
|
+
credentials: { ...creds, accessToken: newToken.accessToken, expiresAt: newToken.expiresAt },
|
|
66
|
+
updatedAt: new Date(),
|
|
67
|
+
}).where(eq(connectors.id, connectorRow.id));
|
|
68
|
+
// Retry with new token
|
|
69
|
+
result = await actionRunner.execute(request, {
|
|
70
|
+
accessToken: newToken.accessToken,
|
|
71
|
+
refreshToken,
|
|
72
|
+
config: connectorRow.config,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Flatten: merge result.data into output so {{blockName.field}} works for data fields
|
|
77
|
+
const output = { success: result.success, error: result.error };
|
|
78
|
+
if (result.data) {
|
|
79
|
+
for (const [k, v] of Object.entries(result.data)) {
|
|
80
|
+
output[k] = v;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { output };
|
|
59
84
|
},
|
|
60
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Try to refresh an OAuth token using the standard token endpoint.
|
|
88
|
+
* Returns new access token or null on failure.
|
|
89
|
+
*/
|
|
90
|
+
async function tryRefreshToken(connectorKind, refreshToken, creds) {
|
|
91
|
+
// Known token endpoints
|
|
92
|
+
const tokenEndpoints = {
|
|
93
|
+
google: "https://oauth2.googleapis.com/token",
|
|
94
|
+
slack: "https://slack.com/api/oauth.v2.access",
|
|
95
|
+
};
|
|
96
|
+
const tokenUrl = tokenEndpoints[connectorKind];
|
|
97
|
+
if (!tokenUrl)
|
|
98
|
+
return null;
|
|
99
|
+
// Get client credentials from env (connector config doesn't store secrets)
|
|
100
|
+
const clientId = connectorKind === "google" ? process.env.GOOGLE_CLIENT_ID : "";
|
|
101
|
+
const clientSecret = connectorKind === "google" ? process.env.GOOGLE_CLIENT_SECRET : "";
|
|
102
|
+
if (!clientId || !clientSecret)
|
|
103
|
+
return null;
|
|
104
|
+
try {
|
|
105
|
+
const res = await fetch(tokenUrl, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
108
|
+
body: new URLSearchParams({
|
|
109
|
+
grant_type: "refresh_token",
|
|
110
|
+
refresh_token: refreshToken,
|
|
111
|
+
client_id: clientId,
|
|
112
|
+
client_secret: clientSecret,
|
|
113
|
+
}).toString(),
|
|
114
|
+
});
|
|
115
|
+
if (!res.ok)
|
|
116
|
+
return null;
|
|
117
|
+
const data = await res.json();
|
|
118
|
+
const expiresIn = data.expires_in;
|
|
119
|
+
return {
|
|
120
|
+
accessToken: data.access_token,
|
|
121
|
+
expiresAt: expiresIn ? new Date(Date.now() + expiresIn * 1000).toISOString() : undefined,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
61
128
|
//# sourceMappingURL=connector-action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-action.js","sourceRoot":"","sources":["../../src/handlers/connector-action.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"connector-action.js","sourceRoot":"","sources":["../../src/handlers/connector-action.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAiB;IAClD,KAAK,EAAE,CAAC,kBAAkB,CAAC;IAE3B,KAAK,CAAC,OAAO,CAAC,GAAwB;QACpC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAI7C,CAAC;QAEF,IAAI,CAAC,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,OAAO;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,uCAAuC,EAAE;aAC3E,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAKlC,cAAc,CAAC,CAAC;QAEnB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,wCAAwC,EAAE,EAAE,CAAC;QACzF,CAAC;QAED,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAM,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,8BA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CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;SACzF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BlockHandler } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* create-inbox-item block handler — stores data in the inbox.
|
|
4
|
+
* Used in sync workflows to persist fetched data before agent processing.
|
|
5
|
+
*
|
|
6
|
+
* Config:
|
|
7
|
+
* - source: string — where the item came from (e.g., "gmail", "slack")
|
|
8
|
+
* - subject: string — item subject/title (supports templates)
|
|
9
|
+
* - body: string — item body/content (supports templates)
|
|
10
|
+
* - from: string — sender (supports templates)
|
|
11
|
+
* - items: array — if provided, creates one inbox item per array element
|
|
12
|
+
* Each element should have { subject, body?, from? }
|
|
13
|
+
*
|
|
14
|
+
* Requires "db" service.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createInboxItemHandler: BlockHandler;
|
|
17
|
+
//# sourceMappingURL=create-inbox-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-inbox-item.d.ts","sourceRoot":"","sources":["../../src/handlers/create-inbox-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAgEpC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* create-inbox-item block handler — stores data in the inbox.
|
|
3
|
+
* Used in sync workflows to persist fetched data before agent processing.
|
|
4
|
+
*
|
|
5
|
+
* Config:
|
|
6
|
+
* - source: string — where the item came from (e.g., "gmail", "slack")
|
|
7
|
+
* - subject: string — item subject/title (supports templates)
|
|
8
|
+
* - body: string — item body/content (supports templates)
|
|
9
|
+
* - from: string — sender (supports templates)
|
|
10
|
+
* - items: array — if provided, creates one inbox item per array element
|
|
11
|
+
* Each element should have { subject, body?, from? }
|
|
12
|
+
*
|
|
13
|
+
* Requires "db" service.
|
|
14
|
+
*/
|
|
15
|
+
export const createInboxItemHandler = {
|
|
16
|
+
types: ["create-inbox-item"],
|
|
17
|
+
async execute(ctx) {
|
|
18
|
+
const db = ctx.services.get("db");
|
|
19
|
+
if (!db) {
|
|
20
|
+
return { output: { error: "db service not available", created: 0 } };
|
|
21
|
+
}
|
|
22
|
+
const { inboxItems } = await import("@boringos/db");
|
|
23
|
+
const { generateId } = await import("@boringos/shared");
|
|
24
|
+
const source = ctx.config.source ?? "workflow";
|
|
25
|
+
const tenantId = ctx.tenantId;
|
|
26
|
+
let created = 0;
|
|
27
|
+
// Batch mode — create from array (may arrive as JSON string from template resolution)
|
|
28
|
+
let items = ctx.config.items;
|
|
29
|
+
if (typeof items === "string") {
|
|
30
|
+
try {
|
|
31
|
+
items = JSON.parse(items);
|
|
32
|
+
}
|
|
33
|
+
catch { /* not JSON, treat as single */ }
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
36
|
+
const { eq, and } = await import("drizzle-orm");
|
|
37
|
+
for (const item of items) {
|
|
38
|
+
const entry = item;
|
|
39
|
+
const sourceId = entry.id ?? entry.messageId ?? null;
|
|
40
|
+
// Dedup: skip if sourceId already exists for this tenant+source
|
|
41
|
+
if (sourceId) {
|
|
42
|
+
const existing = await db.select({ id: inboxItems.id }).from(inboxItems)
|
|
43
|
+
.where(and(eq(inboxItems.tenantId, tenantId), eq(inboxItems.source, source), eq(inboxItems.sourceId, sourceId)))
|
|
44
|
+
.limit(1);
|
|
45
|
+
if (existing.length > 0)
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
await db.insert(inboxItems).values({
|
|
49
|
+
id: generateId(),
|
|
50
|
+
tenantId,
|
|
51
|
+
source,
|
|
52
|
+
subject: entry.subject ?? entry.summary ?? entry.title ?? "No subject",
|
|
53
|
+
body: entry.body ?? entry.snippet ?? entry.description ?? null,
|
|
54
|
+
from: entry.from ?? null,
|
|
55
|
+
sourceId,
|
|
56
|
+
metadata: entry,
|
|
57
|
+
});
|
|
58
|
+
created++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Single item mode
|
|
63
|
+
await db.insert(inboxItems).values({
|
|
64
|
+
id: generateId(),
|
|
65
|
+
tenantId,
|
|
66
|
+
source,
|
|
67
|
+
subject: ctx.config.subject ?? "No subject",
|
|
68
|
+
body: ctx.config.body ?? null,
|
|
69
|
+
from: ctx.config.from ?? null,
|
|
70
|
+
});
|
|
71
|
+
created = 1;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
output: { created, source },
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=create-inbox-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-inbox-item.js","sourceRoot":"","sources":["../../src/handlers/create-inbox-item.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAiB;IAClD,KAAK,EAAE,CAAC,mBAAmB,CAAC;IAE5B,KAAK,CAAC,OAAO,CAAC,GAAwB;QACpC,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAA0C,CAAC;QAC3E,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QACvE,CAAC;QAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;QACpD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAExD,MAAM,MAAM,GAAI,GAAG,CAAC,MAAM,CAAC,MAAiB,IAAI,UAAU,C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M,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;oBACjC,EAAE,EAAE,UAAU,EAAE;oBAChB,QAAQ;oBACR,MAAM;oBACN,OAAO,EAAG,KAAK,CAAC,OAAkB,IAAK,KAAK,CAAC,OAAkB,IAAK,KAAK,CAAC,KAAgB,IAAI,YAAY;oBAC1G,IAAI,EAAG,KAAK,CAAC,IAAe,IAAK,KAAK,CAAC,OAAkB,IAAK,KAAK,CAAC,WAAsB,IAAI,IAAI;oBAClG,IAAI,EAAG,KAAK,CAAC,IAAe,IAAI,IAAI;oBACpC,QAAQ;oBACR,QAAQ,EAAE,KAAK;iBAChB,CAAC,CAAC;gBACH,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,mBAAmB;YACnB,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;gBACjC,EAAE,EAAE,UAAU,EAAE;gBAChB,QAAQ;gBACR,MAAM;gBACN,OAAO,EAAG,GAAG,CAAC,MAAM,CAAC,OAAkB,IAAI,YAAY;gBACvD,IAAI,EAAG,GAAG,CAAC,MAAM,CAAC,IAAe,IAAI,IAAI;gBACzC,IAAI,EAAG,GAAG,CAAC,MAAM,CAAC,IAAe,IAAI,IAAI;aAC1C,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,CAAC;QACd,CAAC;QAED,OAAO;YACL,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BlockHandler } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* emit-event block handler — emits a connector event from within a workflow.
|
|
4
|
+
* This allows routeToInbox() and other event listeners to catch workflow-generated events.
|
|
5
|
+
*
|
|
6
|
+
* Config:
|
|
7
|
+
* - connectorKind: string — e.g., "google", "slack"
|
|
8
|
+
* - eventType: string — e.g., "email_received", "message_received"
|
|
9
|
+
* - data: object — event data (supports templates)
|
|
10
|
+
* - items: array — if provided, emits one event per item
|
|
11
|
+
*
|
|
12
|
+
* Requires "eventBus" service (from @boringos/connector EventBus).
|
|
13
|
+
*/
|
|
14
|
+
export declare const emitEventHandler: BlockHandler;
|
|
15
|
+
//# sourceMappingURL=emit-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-event.d.ts","sourceRoot":"","sources":["../../src/handlers/emit-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,YA0C9B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* emit-event block handler — emits a connector event from within a workflow.
|
|
3
|
+
* This allows routeToInbox() and other event listeners to catch workflow-generated events.
|
|
4
|
+
*
|
|
5
|
+
* Config:
|
|
6
|
+
* - connectorKind: string — e.g., "google", "slack"
|
|
7
|
+
* - eventType: string — e.g., "email_received", "message_received"
|
|
8
|
+
* - data: object — event data (supports templates)
|
|
9
|
+
* - items: array — if provided, emits one event per item
|
|
10
|
+
*
|
|
11
|
+
* Requires "eventBus" service (from @boringos/connector EventBus).
|
|
12
|
+
*/
|
|
13
|
+
export const emitEventHandler = {
|
|
14
|
+
types: ["emit-event"],
|
|
15
|
+
async execute(ctx) {
|
|
16
|
+
const eventBus = ctx.services.get("eventBus");
|
|
17
|
+
const connectorKind = ctx.config.connectorKind ?? "workflow";
|
|
18
|
+
const eventType = ctx.config.eventType ?? "item_processed";
|
|
19
|
+
const tenantId = ctx.tenantId;
|
|
20
|
+
let emitted = 0;
|
|
21
|
+
const items = ctx.config.items;
|
|
22
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
23
|
+
for (const item of items) {
|
|
24
|
+
if (eventBus) {
|
|
25
|
+
await eventBus.emit({
|
|
26
|
+
connectorKind,
|
|
27
|
+
type: eventType,
|
|
28
|
+
tenantId,
|
|
29
|
+
data: item,
|
|
30
|
+
timestamp: new Date(),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
emitted++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (eventBus) {
|
|
38
|
+
await eventBus.emit({
|
|
39
|
+
connectorKind,
|
|
40
|
+
type: eventType,
|
|
41
|
+
tenantId,
|
|
42
|
+
data: ctx.config.data ?? {},
|
|
43
|
+
timestamp: new Date(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
emitted = 1;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
output: { emitted, eventType },
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=emit-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-event.js","sourceRoot":"","sources":["../../src/handlers/emit-event.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,KAAK,EAAE,CAAC,YAAY,CAAC;IAErB,KAAK,CAAC,OAAO,CAAC,GAAwB;QACpC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAwD,CAAC;QAErG,MAAM,aAAa,GAAI,GAAG,CAAC,MAAM,CAAC,aAAwB,IAAI,UAAU,CAAC;QACzE,MAAM,SAAS,GAAI,GAAG,CAAC,MAAM,CAAC,SAAoB,IAAI,gBAAgB,CAAC;QACvE,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,QAAQ,EAAE,CAAC;oBACb,MAAM,QAAQ,CAAC,IAAI,CAAC;wBAClB,aAAa;wBACb,IAAI,EAAE,SAAS;wBACf,QAAQ;wBACR,IAAI,EAAE,IAA+B;wBACrC,SAAS,EAAE,IAAI,IAAI,EAAE;qBACtB,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,QAAQ,CAAC,IAAI,CAAC;oBAClB,aAAa;oBACb,IAAI,EAAE,SAAS;oBACf,QAAQ;oBACR,IAAI,EAAG,GAAG,CAAC,MAAM,CAAC,IAAgC,IAAI,EAAE;oBACxD,SAAS,EAAE,IAAI,IAAI,EAAE;iBACtB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,GAAG,CAAC,CAAC;QACd,CAAC;QAED,OAAO;YACL,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;SAC/B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BlockHandler } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* for-each block handler — iterates over an array from a previous block's output
|
|
4
|
+
* and collects results. Used for processing lists (emails, events, items).
|
|
5
|
+
*
|
|
6
|
+
* Config:
|
|
7
|
+
* - items: the array to iterate (usually a template like "{{fetch.messages}}")
|
|
8
|
+
* After template resolution, this should be a JSON string of an array or an actual array.
|
|
9
|
+
* - itemKey: key name for each item in output (default: "item")
|
|
10
|
+
*
|
|
11
|
+
* Output:
|
|
12
|
+
* - items: the original array
|
|
13
|
+
* - count: number of items
|
|
14
|
+
* - processed: true
|
|
15
|
+
*/
|
|
16
|
+
export declare const forEachHandler: BlockHandler;
|
|
17
|
+
//# sourceMappingURL=for-each.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for-each.d.ts","sourceRoot":"","sources":["../../src/handlers/for-each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,EAAE,YA0B5B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* for-each block handler — iterates over an array from a previous block's output
|
|
3
|
+
* and collects results. Used for processing lists (emails, events, items).
|
|
4
|
+
*
|
|
5
|
+
* Config:
|
|
6
|
+
* - items: the array to iterate (usually a template like "{{fetch.messages}}")
|
|
7
|
+
* After template resolution, this should be a JSON string of an array or an actual array.
|
|
8
|
+
* - itemKey: key name for each item in output (default: "item")
|
|
9
|
+
*
|
|
10
|
+
* Output:
|
|
11
|
+
* - items: the original array
|
|
12
|
+
* - count: number of items
|
|
13
|
+
* - processed: true
|
|
14
|
+
*/
|
|
15
|
+
export const forEachHandler = {
|
|
16
|
+
types: ["for-each"],
|
|
17
|
+
async execute(ctx) {
|
|
18
|
+
let items = [];
|
|
19
|
+
const rawItems = ctx.config.items;
|
|
20
|
+
if (typeof rawItems === "string") {
|
|
21
|
+
try {
|
|
22
|
+
items = JSON.parse(rawItems);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Might be a single value — wrap in array
|
|
26
|
+
items = rawItems ? [rawItems] : [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (Array.isArray(rawItems)) {
|
|
30
|
+
items = rawItems;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
output: {
|
|
34
|
+
items,
|
|
35
|
+
count: items.length,
|
|
36
|
+
processed: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=for-each.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for-each.js","sourceRoot":"","sources":["../../src/handlers/for-each.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,KAAK,EAAE,CAAC,UAAU,CAAC;IAEnB,KAAK,CAAC,OAAO,CAAC,GAAwB;QACpC,IAAI,KAAK,GAAc,EAAE,CAAC;QAE1B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,0CAA0C;gBAC1C,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,KAAK,GAAG,QAAQ,CAAC;QACnB,CAAC;QAED,OAAO;YACL,MAAM,EAAE;gBACN,KAAK;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM;gBACnB,SAAS,EAAE,IAAI;aAChB;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ export { delayHandler } from "./delay.js";
|
|
|
4
4
|
export { transformHandler } from "./transform.js";
|
|
5
5
|
export { wakeAgentHandler } from "./wake-agent.js";
|
|
6
6
|
export { connectorActionHandler } from "./connector-action.js";
|
|
7
|
+
export { forEachHandler } from "./for-each.js";
|
|
8
|
+
export { createInboxItemHandler } from "./create-inbox-item.js";
|
|
9
|
+
export { emitEventHandler } from "./emit-event.js";
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/handlers/index.js
CHANGED
|
@@ -4,4 +4,7 @@ export { delayHandler } from "./delay.js";
|
|
|
4
4
|
export { transformHandler } from "./transform.js";
|
|
5
5
|
export { wakeAgentHandler } from "./wake-agent.js";
|
|
6
6
|
export { connectorActionHandler } from "./connector-action.js";
|
|
7
|
+
export { forEachHandler } from "./for-each.js";
|
|
8
|
+
export { createInboxItemHandler } from "./create-inbox-item.js";
|
|
9
|
+
export { emitEventHandler } from "./emit-event.js";
|
|
7
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export type { HandlerRegistry } from "./handler-registry.js";
|
|
|
7
7
|
export { createWorkflowEngine } from "./engine.js";
|
|
8
8
|
export type { WorkflowEngineConfig } from "./engine.js";
|
|
9
9
|
export { createWorkflowStore } from "./store.js";
|
|
10
|
-
export { triggerHandler, conditionHandler, delayHandler, transformHandler, wakeAgentHandler, connectorActionHandler } from "./handlers/index.js";
|
|
10
|
+
export { triggerHandler, conditionHandler, delayHandler, transformHandler, wakeAgentHandler, connectorActionHandler, forEachHandler, createInboxItemHandler, emitEventHandler } from "./handlers/index.js";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,OAAO,EACP,GAAG,EACH,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,OAAO,EACP,GAAG,EACH,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { createExecutionState, resolveTemplate } from "./state.js";
|
|
|
4
4
|
export { createHandlerRegistry } from "./handler-registry.js";
|
|
5
5
|
export { createWorkflowEngine } from "./engine.js";
|
|
6
6
|
export { createWorkflowStore } from "./store.js";
|
|
7
|
-
export { triggerHandler, conditionHandler, delayHandler, transformHandler, wakeAgentHandler, connectorActionHandler } from "./handlers/index.js";
|
|
7
|
+
export { triggerHandler, conditionHandler, delayHandler, transformHandler, wakeAgentHandler, connectorActionHandler, forEachHandler, createInboxItemHandler, emitEventHandler } from "./handlers/index.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAE7D,wBAAgB,oBAAoB,IAAI,cAAc,CAgBrD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAE7D,wBAAgB,oBAAoB,IAAI,cAAc,CAgBrD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAcR"}
|
package/dist/state.js
CHANGED
|
@@ -25,7 +25,12 @@ export function resolveTemplate(template, state, nameToId) {
|
|
|
25
25
|
if (!blockState?.output)
|
|
26
26
|
return `{{${blockName}.${field}}}`;
|
|
27
27
|
const value = blockState.output[field];
|
|
28
|
-
|
|
28
|
+
if (value === undefined)
|
|
29
|
+
return `{{${blockName}.${field}}}`;
|
|
30
|
+
// Preserve arrays and objects as JSON strings so downstream handlers can parse them
|
|
31
|
+
if (typeof value === "object" && value !== null)
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
return String(value);
|
|
29
34
|
});
|
|
30
35
|
}
|
|
31
36
|
//# sourceMappingURL=state.js.map
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB;IAClC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE7C,OAAO;QACL,GAAG,C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