@bluelibs/runner-dev 6.2.0 → 6.4.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/README.md +131 -12
- package/dist/cli/generators/initUtils.js +1 -1
- package/dist/cli/generators/initUtils.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/README.md.js +17 -4
- package/dist/cli/generators/scaffold/templates/README.md.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/index.d.ts +2 -1
- package/dist/cli/generators/scaffold/templates/index.js +5 -3
- package/dist/cli/generators/scaffold/templates/index.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/package.json.d.ts +7 -2
- package/dist/cli/generators/scaffold/templates/package.json.js +7 -2
- package/dist/cli/generators/scaffold/templates/package.json.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/src/app.test.ts.d.ts +1 -0
- package/dist/cli/generators/scaffold/templates/src/app.test.ts.js +29 -0
- package/dist/cli/generators/scaffold/templates/src/app.test.ts.js.map +1 -0
- package/dist/cli/generators/scaffold/templates/src/app.ts.d.ts +1 -0
- package/dist/cli/generators/scaffold/templates/src/app.ts.js +15 -0
- package/dist/cli/generators/scaffold/templates/src/app.ts.js.map +1 -0
- package/dist/cli/generators/scaffold/templates/src/main.ts.js +3 -10
- package/dist/cli/generators/scaffold/templates/src/main.ts.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/tsconfig.json.d.ts +4 -2
- package/dist/cli/generators/scaffold/templates/tsconfig.json.js +4 -2
- package/dist/cli/generators/scaffold/templates/tsconfig.json.js.map +1 -1
- package/dist/cli/generators/scaffold.js +2 -1
- package/dist/cli/generators/scaffold.js.map +1 -1
- package/dist/cli.js +0 -0
- package/dist/docs/packageDocs.d.ts +16 -0
- package/dist/docs/packageDocs.js +107 -0
- package/dist/docs/packageDocs.js.map +1 -0
- package/dist/exportDocs.d.ts +10 -0
- package/dist/exportDocs.js +98 -0
- package/dist/exportDocs.js.map +1 -0
- package/dist/generated/resolvers-types.d.ts +126 -178
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/env.d.ts +5 -0
- package/dist/mcp/env.js +30 -1
- package/dist/mcp/env.js.map +1 -1
- package/dist/mcp/help.d.ts +8 -1
- package/dist/mcp/help.js +30 -4
- package/dist/mcp/help.js.map +1 -1
- package/dist/mcp/http.js +10 -0
- package/dist/mcp/http.js.map +1 -1
- package/dist/mcp/projectOverview.js +13 -4
- package/dist/mcp/projectOverview.js.map +1 -1
- package/dist/mcp/snapshot.d.ts +22 -0
- package/dist/mcp/snapshot.js +344 -0
- package/dist/mcp/snapshot.js.map +1 -0
- package/dist/mcp/tools/graphql.mutation.js +4 -1
- package/dist/mcp/tools/graphql.mutation.js.map +1 -1
- package/dist/mcp/tools/graphql.ping.js +1 -1
- package/dist/mcp/tools/graphql.ping.js.map +1 -1
- package/dist/mcp/tools/graphql.query.js +1 -1
- package/dist/mcp/tools/graphql.query.js.map +1 -1
- package/dist/mcp/tools/help.read.js +7 -5
- package/dist/mcp/tools/help.read.js.map +1 -1
- package/dist/mcp/tools/help.runner.js +3 -1
- package/dist/mcp/tools/help.runner.js.map +1 -1
- package/dist/mcp/tools/help.runnerDev.js +4 -4
- package/dist/mcp/tools/help.runnerDev.js.map +1 -1
- package/dist/mcp.js +4 -9
- package/dist/mcp.js.map +1 -1
- package/dist/resources/docsPayload.d.ts +33 -0
- package/dist/resources/docsPayload.js +174 -0
- package/dist/resources/docsPayload.js.map +1 -0
- package/dist/resources/docsUiAssets.d.ts +27 -0
- package/dist/resources/docsUiAssets.js +150 -0
- package/dist/resources/docsUiAssets.js.map +1 -0
- package/dist/resources/graphql-accumulator.resource.d.ts +1 -0
- package/dist/resources/graphql-accumulator.resource.js +30 -26
- package/dist/resources/graphql-accumulator.resource.js.map +1 -1
- package/dist/resources/live.resource.d.ts +0 -2
- package/dist/resources/live.resource.js +1 -5
- package/dist/resources/live.resource.js.map +1 -1
- package/dist/resources/models/Introspector.d.ts +17 -0
- package/dist/resources/models/Introspector.js +61 -28
- package/dist/resources/models/Introspector.js.map +1 -1
- package/dist/resources/models/durable.runtime.d.ts +1 -5
- package/dist/resources/models/durable.runtime.js +0 -33
- package/dist/resources/models/durable.runtime.js.map +1 -1
- package/dist/resources/models/durable.tools.d.ts +10 -0
- package/dist/resources/models/durable.tools.js +21 -0
- package/dist/resources/models/durable.tools.js.map +1 -1
- package/dist/resources/models/initializeFromStore.js +5 -5
- package/dist/resources/models/initializeFromStore.js.map +1 -1
- package/dist/resources/models/initializeFromStore.utils.d.ts +2 -2
- package/dist/resources/models/initializeFromStore.utils.js +399 -68
- package/dist/resources/models/initializeFromStore.utils.js.map +1 -1
- package/dist/resources/models/introspector.tools.js +88 -4
- package/dist/resources/models/introspector.tools.js.map +1 -1
- package/dist/resources/routeHandlers/createDocsServeHandler.js +13 -37
- package/dist/resources/routeHandlers/createDocsServeHandler.js.map +1 -1
- package/dist/resources/routeHandlers/getDocsData.d.ts +1 -6
- package/dist/resources/routeHandlers/getDocsData.js +10 -168
- package/dist/resources/routeHandlers/getDocsData.js.map +1 -1
- package/dist/resources/server.resource.js +0 -1
- package/dist/resources/server.resource.js.map +1 -1
- package/dist/resources/ui.static.js +4 -9
- package/dist/resources/ui.static.js.map +1 -1
- package/dist/schema/model.d.ts +21 -13
- package/dist/schema/model.js +14 -0
- package/dist/schema/model.js.map +1 -1
- package/dist/schema/query.js +3 -3
- package/dist/schema/query.js.map +1 -1
- package/dist/schema/types/AllType.js +2 -21
- package/dist/schema/types/AllType.js.map +1 -1
- package/dist/schema/types/DurableFlowTypes.d.ts +2 -0
- package/dist/schema/types/DurableFlowTypes.js +51 -1
- package/dist/schema/types/DurableFlowTypes.js.map +1 -1
- package/dist/schema/types/ErrorType.js +1 -3
- package/dist/schema/types/ErrorType.js.map +1 -1
- package/dist/schema/types/EventType.js +6 -19
- package/dist/schema/types/EventType.js.map +1 -1
- package/dist/schema/types/HookType.js +4 -16
- package/dist/schema/types/HookType.js.map +1 -1
- package/dist/schema/types/ResourceType.js +60 -23
- package/dist/schema/types/ResourceType.js.map +1 -1
- package/dist/schema/types/TaskLikeCommon.js +2 -2
- package/dist/schema/types/TaskLikeCommon.js.map +1 -1
- package/dist/schema/types/TaskType.js +12 -31
- package/dist/schema/types/TaskType.js.map +1 -1
- package/dist/schema/types/index.d.ts +0 -1
- package/dist/schema/types/index.js +1 -10
- package/dist/schema/types/index.js.map +1 -1
- package/dist/schema/types/middleware/UsageTypes.d.ts +1 -0
- package/dist/schema/types/middleware/UsageTypes.js +16 -5
- package/dist/schema/types/middleware/UsageTypes.js.map +1 -1
- package/dist/schema/types/middleware/common.js +2 -2
- package/dist/schema/types/middleware/common.js.map +1 -1
- package/dist/ui/.vite/manifest.json +2 -2
- package/dist/ui/assets/docs-DaF8dCiE.css +1 -0
- package/dist/ui/assets/docs-DgcoUGlF.js +261 -0
- package/dist/ui/assets/docs-DgcoUGlF.js.map +1 -0
- package/dist/ui/docs/favicon.ico +0 -0
- package/dist/utils/lane-resources.d.ts +69 -0
- package/dist/utils/lane-resources.js +145 -0
- package/dist/utils/lane-resources.js.map +1 -1
- package/dist/utils/runner-namespace.d.ts +1 -0
- package/dist/utils/runner-namespace.js +9 -0
- package/dist/utils/runner-namespace.js.map +1 -0
- package/dist/utils/schemaFormat.d.ts +6 -0
- package/dist/utils/schemaFormat.js +244 -0
- package/dist/utils/schemaFormat.js.map +1 -0
- package/dist/utils/system-namespace.d.ts +1 -0
- package/dist/utils/system-namespace.js +9 -0
- package/dist/utils/system-namespace.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -4
- package/readmes/API_REFERENCE.md +352 -0
- package/readmes/COMPACT_GUIDE.md +254 -0
- package/skills/core/SKILL.md +27 -0
- package/skills/core/references/readmes/API_REFERENCE.md +352 -0
- package/skills/core/references/readmes/COMPACT_GUIDE.md +254 -0
- package/AI.md +0 -630
- package/dist/ui/assets/docs-CWJO6emS.css +0 -1
- package/dist/ui/assets/docs-Zej7hPlV.js +0 -302
- package/dist/ui/assets/docs-Zej7hPlV.js.map +0 -1
- package/readmes/runner-AI.md +0 -917
- package/readmes/runner-durable-workflows.md +0 -2247
- package/readmes/runner-full-guide.md +0 -6010
- package/readmes/runner-remote-lanes.md +0 -910
|
@@ -25,7 +25,7 @@ exports.extractTaskIdsFromDependencies = extractTaskIdsFromDependencies;
|
|
|
25
25
|
exports.extractErrorIdsFromDependencies = extractErrorIdsFromDependencies;
|
|
26
26
|
const runner_1 = require("@bluelibs/runner");
|
|
27
27
|
const lane_resources_1 = require("../../utils/lane-resources");
|
|
28
|
-
const
|
|
28
|
+
const schemaFormat_1 = require("../../utils/schemaFormat");
|
|
29
29
|
const path_1 = require("../../utils/path");
|
|
30
30
|
const introspector_tools_1 = require("./introspector.tools");
|
|
31
31
|
function normalizeTags(tags) {
|
|
@@ -66,22 +66,169 @@ function findById(collection, id) {
|
|
|
66
66
|
Object.values(collection).find((x) => (0, introspector_tools_1.readId)(x) === id));
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
|
+
const taskMiddlewareScopeMarker = ".middleware.task.";
|
|
70
|
+
const resourceMiddlewareScopeMarker = ".middleware.resource.";
|
|
71
|
+
function getMiddlewareDuplicateKey(id) {
|
|
72
|
+
const taskScopeIndex = id.lastIndexOf(taskMiddlewareScopeMarker);
|
|
73
|
+
if (taskScopeIndex >= 0) {
|
|
74
|
+
return id.slice(taskScopeIndex + taskMiddlewareScopeMarker.length);
|
|
75
|
+
}
|
|
76
|
+
const resourceScopeIndex = id.lastIndexOf(resourceMiddlewareScopeMarker);
|
|
77
|
+
if (resourceScopeIndex >= 0) {
|
|
78
|
+
return id.slice(resourceScopeIndex + resourceMiddlewareScopeMarker.length);
|
|
79
|
+
}
|
|
80
|
+
return id;
|
|
81
|
+
}
|
|
82
|
+
function getTaskOwnerResourceChain(store, taskId) {
|
|
83
|
+
const chain = [];
|
|
84
|
+
const visited = new Set();
|
|
85
|
+
let currentOwnerId = store.getOwnerResourceId(taskId);
|
|
86
|
+
while (currentOwnerId && !visited.has(currentOwnerId)) {
|
|
87
|
+
visited.add(currentOwnerId);
|
|
88
|
+
chain.push(currentOwnerId);
|
|
89
|
+
currentOwnerId = store.getOwnerResourceId(currentOwnerId);
|
|
90
|
+
}
|
|
91
|
+
return chain;
|
|
92
|
+
}
|
|
93
|
+
function normalizeIdentityRequirementSummary(value) {
|
|
94
|
+
if (!value || typeof value !== "object")
|
|
95
|
+
return null;
|
|
96
|
+
const config = value;
|
|
97
|
+
return {
|
|
98
|
+
tenant: config.tenant ?? true,
|
|
99
|
+
user: config.user === true,
|
|
100
|
+
roles: Array.isArray(config.roles)
|
|
101
|
+
? config.roles.map((role) => String(role))
|
|
102
|
+
: [],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function normalizeIdentityRequirementSummaries(value) {
|
|
106
|
+
const entries = Array.isArray(value)
|
|
107
|
+
? value
|
|
108
|
+
: value && typeof value === "object"
|
|
109
|
+
? [value]
|
|
110
|
+
: [];
|
|
111
|
+
return entries
|
|
112
|
+
.map((entry) => normalizeIdentityRequirementSummary(entry))
|
|
113
|
+
.filter((entry) => Boolean(entry));
|
|
114
|
+
}
|
|
115
|
+
function normalizeIdentityScopeSummary(value) {
|
|
116
|
+
if (!value || typeof value !== "object")
|
|
117
|
+
return null;
|
|
118
|
+
const config = value;
|
|
119
|
+
return {
|
|
120
|
+
tenant: config.tenant ?? true,
|
|
121
|
+
user: config.user === true,
|
|
122
|
+
required: config.required ?? true,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function getSubtreePolicies(resource) {
|
|
126
|
+
const rawSubtree = resource?.subtree;
|
|
127
|
+
if (!rawSubtree || typeof rawSubtree !== "object")
|
|
128
|
+
return [];
|
|
129
|
+
return Array.isArray(rawSubtree)
|
|
130
|
+
? rawSubtree.filter((policy) => Boolean(policy) && typeof policy === "object")
|
|
131
|
+
: [rawSubtree];
|
|
132
|
+
}
|
|
133
|
+
function readSubtreeMiddlewareEntryId(entry) {
|
|
134
|
+
if (typeof entry === "string")
|
|
135
|
+
return entry;
|
|
136
|
+
if (!entry || typeof entry !== "object")
|
|
137
|
+
return null;
|
|
138
|
+
if ("use" in entry) {
|
|
139
|
+
return readSubtreeMiddlewareEntryId(entry.use ?? null);
|
|
140
|
+
}
|
|
141
|
+
const id = (0, introspector_tools_1.readId)(entry);
|
|
142
|
+
return id ? id : null;
|
|
143
|
+
}
|
|
144
|
+
function resolveTaskSubtreeMiddlewareEntry(entry, task) {
|
|
145
|
+
if (typeof entry === "string") {
|
|
146
|
+
return entry;
|
|
147
|
+
}
|
|
148
|
+
if (!entry || typeof entry !== "object") {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if ("use" in entry) {
|
|
152
|
+
const conditionalEntry = entry;
|
|
153
|
+
if (typeof conditionalEntry.when === "function") {
|
|
154
|
+
try {
|
|
155
|
+
if (!conditionalEntry.when(task)) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return readSubtreeMiddlewareEntryId(conditionalEntry.use ?? null);
|
|
164
|
+
}
|
|
165
|
+
return readSubtreeMiddlewareEntryId(entry);
|
|
166
|
+
}
|
|
167
|
+
function collectSubtreeTaskMiddlewareOwnerIds(store, task) {
|
|
168
|
+
const ownerIds = new Map();
|
|
169
|
+
const chainRootToNearest = [
|
|
170
|
+
...getTaskOwnerResourceChain(store, task.id),
|
|
171
|
+
].reverse();
|
|
172
|
+
for (const ownerResourceId of chainRootToNearest) {
|
|
173
|
+
const ownerResource = store.resources.get(ownerResourceId)?.resource;
|
|
174
|
+
if (!ownerResource)
|
|
175
|
+
continue;
|
|
176
|
+
for (const policy of getSubtreePolicies(ownerResource)) {
|
|
177
|
+
const taskMiddlewares = Array.isArray(policy.tasks?.middleware)
|
|
178
|
+
? policy.tasks.middleware
|
|
179
|
+
: [];
|
|
180
|
+
for (const entry of taskMiddlewares) {
|
|
181
|
+
const middlewareId = resolveTaskSubtreeMiddlewareEntry(entry, task);
|
|
182
|
+
if (!middlewareId)
|
|
183
|
+
continue;
|
|
184
|
+
const duplicateKey = getMiddlewareDuplicateKey(middlewareId);
|
|
185
|
+
if (!ownerIds.has(duplicateKey)) {
|
|
186
|
+
ownerIds.set(duplicateKey, ownerResourceId);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return ownerIds;
|
|
192
|
+
}
|
|
193
|
+
function hasMiddlewareConfig(middleware) {
|
|
194
|
+
return (Boolean(middleware?.[runner_1.definitions.symbolMiddlewareConfigured]) ||
|
|
195
|
+
middleware?.config !== undefined);
|
|
196
|
+
}
|
|
197
|
+
function buildEffectiveTaskMiddlewareUsages(store, task) {
|
|
198
|
+
const resolver = store.getMiddlewareManager()?.middlewareResolver;
|
|
199
|
+
const effectiveMiddlewares = resolver
|
|
200
|
+
? resolver.getApplicableTaskMiddlewares(task)
|
|
201
|
+
: task.middleware;
|
|
202
|
+
const subtreeOwnersByKey = collectSubtreeTaskMiddlewareOwnerIds(store, task);
|
|
203
|
+
return effectiveMiddlewares.map((middleware) => {
|
|
204
|
+
const duplicateKey = getMiddlewareDuplicateKey(String(middleware.id));
|
|
205
|
+
const subtreeOwnerId = subtreeOwnersByKey.get(duplicateKey) ?? null;
|
|
206
|
+
return {
|
|
207
|
+
id: String(middleware.id),
|
|
208
|
+
config: hasMiddlewareConfig(middleware)
|
|
209
|
+
? (0, introspector_tools_1.stringifyIfObject)(middleware.config)
|
|
210
|
+
: null,
|
|
211
|
+
origin: subtreeOwnerId ? "subtree" : "local",
|
|
212
|
+
subtreeOwnerId,
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
}
|
|
69
216
|
// Mapping helpers
|
|
70
|
-
function mapStoreTaskToTaskModel(task, taskStoreElement) {
|
|
217
|
+
function mapStoreTaskToTaskModel(task, store, taskStoreElement) {
|
|
71
218
|
const depsObj = normalizeDependencies(task?.dependencies);
|
|
72
219
|
const eventIdsFromDeps = extractEventIdsFromDependencies(depsObj);
|
|
73
220
|
const resourceIdsFromDeps = extractResourceIdsFromDependencies(depsObj);
|
|
74
221
|
const taskIdsFromDeps = extractTaskIdsFromDependencies(depsObj);
|
|
75
222
|
const errorIdsFromDeps = extractErrorIdsFromDependencies(depsObj);
|
|
76
223
|
const tagIdsFromDeps = extractTagIdsFromDependencies(depsObj);
|
|
77
|
-
const middlewareDetailed =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
m
|
|
82
|
-
|
|
83
|
-
: null,
|
|
84
|
-
|
|
224
|
+
const middlewareDetailed = store
|
|
225
|
+
? buildEffectiveTaskMiddlewareUsages(store, task)
|
|
226
|
+
: (task.middleware || []).map((m) => ({
|
|
227
|
+
id: String(m.id),
|
|
228
|
+
config: hasMiddlewareConfig(m) ? (0, introspector_tools_1.stringifyIfObject)(m.config) : null,
|
|
229
|
+
origin: "local",
|
|
230
|
+
subtreeOwnerId: null,
|
|
231
|
+
}));
|
|
85
232
|
const { ids: tagIds, detailed: tagsDetailed } = normalizeTags(task?.tags);
|
|
86
233
|
const interceptorOwnerIds = Array.from(new Set(taskStoreElement?.interceptors
|
|
87
234
|
?.map((record) => record.ownerResourceId)
|
|
@@ -101,7 +248,7 @@ function mapStoreTaskToTaskModel(task, taskStoreElement) {
|
|
|
101
248
|
...errorIdsFromDeps,
|
|
102
249
|
...tagIdsFromDeps,
|
|
103
250
|
],
|
|
104
|
-
middleware:
|
|
251
|
+
middleware: middlewareDetailed.map((m) => m.id),
|
|
105
252
|
middlewareDetailed,
|
|
106
253
|
registeredBy: null,
|
|
107
254
|
kind: "TASK",
|
|
@@ -109,8 +256,8 @@ function mapStoreTaskToTaskModel(task, taskStoreElement) {
|
|
|
109
256
|
visibilityReason: null,
|
|
110
257
|
// Emits any events present in its dependencies
|
|
111
258
|
emits: eventIdsFromDeps,
|
|
112
|
-
inputSchema: (0,
|
|
113
|
-
resultSchema: (0,
|
|
259
|
+
inputSchema: (0, schemaFormat_1.formatSchemaIfZod)(task.inputSchema),
|
|
260
|
+
resultSchema: (0, schemaFormat_1.formatSchemaIfZod)(task.resultSchema),
|
|
114
261
|
rpcLane: extractRpcLaneSummary(tagsDetailed),
|
|
115
262
|
interceptorCount: taskStoreElement?.interceptors?.length ?? 0,
|
|
116
263
|
hasInterceptors: (taskStoreElement?.interceptors?.length ?? 0) > 0,
|
|
@@ -120,7 +267,7 @@ function mapStoreTaskToTaskModel(task, taskStoreElement) {
|
|
|
120
267
|
function mapStoreTaskToHookModel(_task) {
|
|
121
268
|
throw new Error("deprecated");
|
|
122
269
|
}
|
|
123
|
-
function mapStoreHookToHookModel(hkStoreElement) {
|
|
270
|
+
function mapStoreHookToHookModel(hkStoreElement, store) {
|
|
124
271
|
const hk = hkStoreElement.hook;
|
|
125
272
|
const depsObj = normalizeDependencies(hk?.dependencies);
|
|
126
273
|
const eventIdsFromDeps = extractEventIdsFromDependencies(depsObj);
|
|
@@ -129,9 +276,7 @@ function mapStoreHookToHookModel(hkStoreElement) {
|
|
|
129
276
|
const errorIdsFromDeps = extractErrorIdsFromDependencies(depsObj);
|
|
130
277
|
const tagIdsFromDeps = extractTagIdsFromDependencies(depsObj);
|
|
131
278
|
const { ids: tagIds, detailed: tagsDetailed } = normalizeTags(hk.tags);
|
|
132
|
-
const eventIds =
|
|
133
|
-
? hk.on.map((e) => String(e.id))
|
|
134
|
-
: [String(hk.on?.id ?? "*")];
|
|
279
|
+
const eventIds = resolveHookEventIds(hk, store);
|
|
135
280
|
return (0, introspector_tools_1.stampElementKind)({
|
|
136
281
|
id: String(hk?.id),
|
|
137
282
|
meta: buildMetaWithNormalizedTags(hk?.meta, hk),
|
|
@@ -188,6 +333,8 @@ function mapStoreResourceToResourceModel(resource, resourceConfig) {
|
|
|
188
333
|
const { ids: tagIds, detailed: tagsDetailed } = normalizeTags(resource?.tags);
|
|
189
334
|
const isolation = normalizeIsolation(resource);
|
|
190
335
|
const subtree = normalizeSubtreePolicy(resource);
|
|
336
|
+
const hasInit = typeof resource?.init === "function";
|
|
337
|
+
const hasDispose = typeof resource?.dispose === "function";
|
|
191
338
|
const hasCooldown = typeof resource?.cooldown === "function";
|
|
192
339
|
const hasReady = typeof resource?.ready === "function";
|
|
193
340
|
const hasHealthCheck = typeof resource?.health === "function";
|
|
@@ -215,12 +362,14 @@ function mapStoreResourceToResourceModel(resource, resourceConfig) {
|
|
|
215
362
|
registers: register.map((r) => r.id.toString()),
|
|
216
363
|
isolation,
|
|
217
364
|
subtree,
|
|
365
|
+
hasInit,
|
|
366
|
+
hasDispose,
|
|
218
367
|
hasCooldown,
|
|
219
368
|
hasReady,
|
|
220
369
|
hasHealthCheck,
|
|
221
370
|
context: (0, introspector_tools_1.stringifyIfObject)(resource.context),
|
|
222
371
|
registeredBy: null,
|
|
223
|
-
configSchema: (0,
|
|
372
|
+
configSchema: (0, schemaFormat_1.formatSchemaIfZod)(resource.configSchema),
|
|
224
373
|
isPrivate: false,
|
|
225
374
|
visibilityReason: null,
|
|
226
375
|
}, "RESOURCE");
|
|
@@ -238,25 +387,22 @@ function normalizeResourceConfig(config) {
|
|
|
238
387
|
function buildEvents(store) {
|
|
239
388
|
const eventsCollection = Array.from(store.events.values()).map((e) => e.event);
|
|
240
389
|
const allEventIds = eventsCollection.map((e) => e.id.toString());
|
|
241
|
-
const
|
|
390
|
+
const hookEntries = Array.from(store.hooks.values());
|
|
391
|
+
const hookTargetEventIdsByHookId = new Map();
|
|
392
|
+
const eventLaneByEventId = buildEventLaneSummaryByEventId(store);
|
|
393
|
+
for (const hookEntry of hookEntries) {
|
|
394
|
+
hookTargetEventIdsByHookId.set(hookEntry.hook.id, resolveHookEventIds(hookEntry.hook, store));
|
|
395
|
+
}
|
|
242
396
|
return allEventIds.map((eventId) => {
|
|
243
397
|
const e = findById(eventsCollection, eventId);
|
|
244
398
|
const { ids: tagIds, detailed: tagsDetailed } = normalizeTags(e.tags);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.
|
|
248
|
-
const on = h?.on;
|
|
249
|
-
if (on === "*")
|
|
399
|
+
const hooksListeningToEvent = hookEntries
|
|
400
|
+
.filter(({ hook }) => {
|
|
401
|
+
if (hook.on === "*")
|
|
250
402
|
return true;
|
|
251
|
-
|
|
252
|
-
return on === eventId;
|
|
253
|
-
if (on && typeof on === "object" && !Array.isArray(on))
|
|
254
|
-
return String(on.id) === eventId;
|
|
255
|
-
if (Array.isArray(on))
|
|
256
|
-
return on.some((v) => typeof v === "string" ? v === eventId : String(v?.id) === eventId);
|
|
257
|
-
return false;
|
|
403
|
+
return (hookTargetEventIdsByHookId.get(hook.id)?.includes(eventId) ?? false);
|
|
258
404
|
})
|
|
259
|
-
.map((
|
|
405
|
+
.map(({ hook }) => hook.id);
|
|
260
406
|
return (0, introspector_tools_1.stampElementKind)({
|
|
261
407
|
id: eventId,
|
|
262
408
|
meta: buildMetaWithNormalizedTags(e?.meta ?? null, e),
|
|
@@ -264,17 +410,175 @@ function buildEvents(store) {
|
|
|
264
410
|
tagsDetailed,
|
|
265
411
|
transactional: Boolean(e?.transactional),
|
|
266
412
|
parallel: Boolean(e?.parallel),
|
|
267
|
-
eventLane:
|
|
413
|
+
eventLane: eventLaneByEventId.get(eventId) ?? null,
|
|
268
414
|
rpcLane: extractRpcLaneSummary(tagsDetailed),
|
|
269
415
|
filePath: (0, path_1.sanitizePath)((e && e[runner_1.definitions.symbolFilePath]) ?? e?.filePath ?? null),
|
|
270
416
|
listenedToBy: hooksListeningToEvent,
|
|
271
417
|
registeredBy: null,
|
|
272
|
-
payloadSchema: (0,
|
|
418
|
+
payloadSchema: (0, schemaFormat_1.formatSchemaIfZod)(e.payloadSchema),
|
|
273
419
|
isPrivate: false,
|
|
274
420
|
visibilityReason: null,
|
|
275
421
|
}, "EVENT");
|
|
276
422
|
});
|
|
277
423
|
}
|
|
424
|
+
function resolveHookEventIds(hook, store) {
|
|
425
|
+
if (hook.on === "*") {
|
|
426
|
+
return ["*"];
|
|
427
|
+
}
|
|
428
|
+
if (store && hook.on) {
|
|
429
|
+
return store.resolveHookTargets(hook).map((entry) => entry.event.id);
|
|
430
|
+
}
|
|
431
|
+
if (Array.isArray(hook.on)) {
|
|
432
|
+
return hook.on.map((entry) => typeof entry === "string" ? entry : String(entry?.id));
|
|
433
|
+
}
|
|
434
|
+
return [String(hook.on?.id ?? "*")];
|
|
435
|
+
}
|
|
436
|
+
function buildEventLaneSummaryByEventId(store) {
|
|
437
|
+
const laneByEventId = new Map();
|
|
438
|
+
const buildLaneApplyTargetKey = (target) => {
|
|
439
|
+
if (typeof target === "string") {
|
|
440
|
+
return `id:${target}`;
|
|
441
|
+
}
|
|
442
|
+
const targetId = (0, lane_resources_1.extractLaneId)(target);
|
|
443
|
+
if (targetId) {
|
|
444
|
+
return `id:${targetId}`;
|
|
445
|
+
}
|
|
446
|
+
const serializedTarget = (0, introspector_tools_1.stringifyIfObject)(target);
|
|
447
|
+
if (serializedTarget) {
|
|
448
|
+
return `json:${serializedTarget}`;
|
|
449
|
+
}
|
|
450
|
+
return `raw:${String(target)}`;
|
|
451
|
+
};
|
|
452
|
+
const mergeLaneApplyTo = (existingApplyTo, incomingApplyTo) => {
|
|
453
|
+
if (incomingApplyTo === undefined) {
|
|
454
|
+
return existingApplyTo;
|
|
455
|
+
}
|
|
456
|
+
if (existingApplyTo === undefined) {
|
|
457
|
+
return incomingApplyTo;
|
|
458
|
+
}
|
|
459
|
+
if (Array.isArray(existingApplyTo) && Array.isArray(incomingApplyTo)) {
|
|
460
|
+
const mergedTargets = new Map();
|
|
461
|
+
for (const target of [...existingApplyTo, ...incomingApplyTo]) {
|
|
462
|
+
mergedTargets.set(buildLaneApplyTargetKey(target), target);
|
|
463
|
+
}
|
|
464
|
+
return Array.from(mergedTargets.values());
|
|
465
|
+
}
|
|
466
|
+
return incomingApplyTo;
|
|
467
|
+
};
|
|
468
|
+
const mergeTopologyLaneEntry = (existingEntry, incomingEntry) => {
|
|
469
|
+
if (!existingEntry) {
|
|
470
|
+
return incomingEntry;
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
id: incomingEntry.id,
|
|
474
|
+
applyTo: mergeLaneApplyTo(existingEntry.applyTo, incomingEntry.applyTo),
|
|
475
|
+
orderingKey: incomingEntry.orderingKey ?? existingEntry.orderingKey,
|
|
476
|
+
metadata: incomingEntry.metadata ?? existingEntry.metadata,
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
const upsertTopologyLaneEntry = (entry) => {
|
|
480
|
+
topologyLanesById.set(entry.id, mergeTopologyLaneEntry(topologyLanesById.get(entry.id), entry));
|
|
481
|
+
};
|
|
482
|
+
const topologyLanesById = new Map();
|
|
483
|
+
for (const resourceEntry of store.resources.values()) {
|
|
484
|
+
const resource = resourceEntry.resource;
|
|
485
|
+
const normalizedTags = normalizeTags(resource?.tags).ids;
|
|
486
|
+
if (!(0, lane_resources_1.isEventLanesResource)({
|
|
487
|
+
id: String(resource.id),
|
|
488
|
+
tags: normalizedTags,
|
|
489
|
+
})) {
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const topology = resourceEntry
|
|
493
|
+
.config?.topology;
|
|
494
|
+
if (Array.isArray(topology?.bindings)) {
|
|
495
|
+
for (const binding of topology.bindings) {
|
|
496
|
+
const laneId = (0, lane_resources_1.extractLaneId)(binding?.lane);
|
|
497
|
+
if (!laneId || !binding?.lane)
|
|
498
|
+
continue;
|
|
499
|
+
upsertTopologyLaneEntry({
|
|
500
|
+
id: laneId,
|
|
501
|
+
applyTo: normalizeEventLaneApplyTo(binding.lane.applyTo),
|
|
502
|
+
orderingKey: typeof binding.lane.orderingKey === "string"
|
|
503
|
+
? binding.lane.orderingKey
|
|
504
|
+
: null,
|
|
505
|
+
metadata: (0, introspector_tools_1.stringifyIfObject)(binding.lane.metadata),
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (topology?.profiles && typeof topology.profiles === "object") {
|
|
510
|
+
for (const profile of Object.values(topology.profiles)) {
|
|
511
|
+
if (!Array.isArray(profile?.consume))
|
|
512
|
+
continue;
|
|
513
|
+
for (const entry of profile.consume) {
|
|
514
|
+
const laneId = (0, lane_resources_1.extractLaneId)(entry?.lane);
|
|
515
|
+
if (!laneId || !entry?.lane)
|
|
516
|
+
continue;
|
|
517
|
+
upsertTopologyLaneEntry({
|
|
518
|
+
id: laneId,
|
|
519
|
+
applyTo: normalizeEventLaneApplyTo(entry.lane.applyTo),
|
|
520
|
+
orderingKey: typeof entry.lane.orderingKey === "string"
|
|
521
|
+
? entry.lane.orderingKey
|
|
522
|
+
: null,
|
|
523
|
+
metadata: (0, introspector_tools_1.stringifyIfObject)(entry.lane.metadata),
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const registeredEvents = Array.from(store.events.values()).map((eventEntry) => eventEntry.event);
|
|
530
|
+
for (const lane of topologyLanesById.values()) {
|
|
531
|
+
if (typeof lane.applyTo === "function") {
|
|
532
|
+
for (const event of registeredEvents) {
|
|
533
|
+
if (laneByEventId.has(event.id))
|
|
534
|
+
continue;
|
|
535
|
+
let matchesEvent = false;
|
|
536
|
+
try {
|
|
537
|
+
matchesEvent = lane.applyTo(event);
|
|
538
|
+
}
|
|
539
|
+
catch {
|
|
540
|
+
matchesEvent = false;
|
|
541
|
+
}
|
|
542
|
+
if (!matchesEvent)
|
|
543
|
+
continue;
|
|
544
|
+
laneByEventId.set(event.id, {
|
|
545
|
+
laneId: lane.id,
|
|
546
|
+
orderingKey: lane.orderingKey,
|
|
547
|
+
metadata: lane.metadata,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (!Array.isArray(lane.applyTo)) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
for (const target of lane.applyTo) {
|
|
556
|
+
const targetId = typeof target === "string"
|
|
557
|
+
? target
|
|
558
|
+
: store.findIdByDefinition(target) ?? (0, lane_resources_1.extractLaneId)(target);
|
|
559
|
+
if (!targetId)
|
|
560
|
+
continue;
|
|
561
|
+
const event = store.events.get(targetId)?.event;
|
|
562
|
+
if (!event || laneByEventId.has(event.id))
|
|
563
|
+
continue;
|
|
564
|
+
laneByEventId.set(event.id, {
|
|
565
|
+
laneId: lane.id,
|
|
566
|
+
orderingKey: lane.orderingKey,
|
|
567
|
+
metadata: lane.metadata,
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return laneByEventId;
|
|
572
|
+
}
|
|
573
|
+
function normalizeEventLaneApplyTo(applyTo) {
|
|
574
|
+
if (Array.isArray(applyTo)) {
|
|
575
|
+
return applyTo;
|
|
576
|
+
}
|
|
577
|
+
if (typeof applyTo === "function") {
|
|
578
|
+
return applyTo;
|
|
579
|
+
}
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
278
582
|
function buildMiddlewaresGeneric(middlewaresCollection, tasks, resources, kind) {
|
|
279
583
|
const matchesMiddlewareId = (candidateIds, middlewareId) => (candidateIds ?? []).some((candidateId) => candidateId === middlewareId ||
|
|
280
584
|
candidateId.endsWith(`.${middlewareId}`) ||
|
|
@@ -318,7 +622,7 @@ function buildMiddlewaresGeneric(middlewaresCollection, tasks, resources, kind)
|
|
|
318
622
|
usedByResources,
|
|
319
623
|
overriddenBy: mw?.overriddenBy ?? null,
|
|
320
624
|
registeredBy: null,
|
|
321
|
-
configSchema: (0,
|
|
625
|
+
configSchema: (0, schemaFormat_1.formatSchemaIfZod)(mw.configSchema),
|
|
322
626
|
type: kind,
|
|
323
627
|
isPrivate: false,
|
|
324
628
|
visibilityReason: null,
|
|
@@ -332,6 +636,20 @@ function buildResourceMiddlewares(middlewaresCollection, tasks, resources) {
|
|
|
332
636
|
return buildMiddlewaresGeneric(middlewaresCollection, tasks, resources, "resource");
|
|
333
637
|
}
|
|
334
638
|
function attachRegisteredBy(resources, tasks, hooks, middlewares, events) {
|
|
639
|
+
const matchesRegisteredElement = (candidateId, referenceId) => candidateId === referenceId ||
|
|
640
|
+
candidateId.endsWith(`.${referenceId}`) ||
|
|
641
|
+
referenceId.endsWith(`.${candidateId}`);
|
|
642
|
+
const resolveRegisteredElement = (map, referenceId) => {
|
|
643
|
+
const direct = map.get(referenceId);
|
|
644
|
+
if (direct)
|
|
645
|
+
return direct;
|
|
646
|
+
for (const element of map.values()) {
|
|
647
|
+
if (matchesRegisteredElement(element.id, referenceId)) {
|
|
648
|
+
return element;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return null;
|
|
652
|
+
};
|
|
335
653
|
const taskMap = (0, introspector_tools_1.buildIdMap)(tasks);
|
|
336
654
|
const hookMap = (0, introspector_tools_1.buildIdMap)(hooks);
|
|
337
655
|
const resourceMap = (0, introspector_tools_1.buildIdMap)(resources);
|
|
@@ -339,16 +657,30 @@ function attachRegisteredBy(resources, tasks, hooks, middlewares, events) {
|
|
|
339
657
|
const eventMap = (0, introspector_tools_1.buildIdMap)(events);
|
|
340
658
|
for (const r of resources) {
|
|
341
659
|
for (const id of r.registers ?? []) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
660
|
+
const task = resolveRegisteredElement(taskMap, id);
|
|
661
|
+
if (task) {
|
|
662
|
+
task.registeredBy = r.id;
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
const hook = resolveRegisteredElement(hookMap, id);
|
|
666
|
+
if (hook) {
|
|
667
|
+
hook.registeredBy = r.id;
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
const resource = resolveRegisteredElement(resourceMap, id);
|
|
671
|
+
if (resource) {
|
|
672
|
+
resource.registeredBy = r.id;
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const middleware = resolveRegisteredElement(middlewareMap, id);
|
|
676
|
+
if (middleware) {
|
|
677
|
+
middleware.registeredBy = r.id;
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
const event = resolveRegisteredElement(eventMap, id);
|
|
681
|
+
if (event) {
|
|
682
|
+
event.registeredBy = r.id;
|
|
683
|
+
}
|
|
352
684
|
}
|
|
353
685
|
}
|
|
354
686
|
}
|
|
@@ -592,8 +924,8 @@ function toSubtreeMiddlewareIds(entries) {
|
|
|
592
924
|
if (!Array.isArray(entries))
|
|
593
925
|
return [];
|
|
594
926
|
const ids = entries
|
|
595
|
-
.map((entry) =>
|
|
596
|
-
.filter(Boolean);
|
|
927
|
+
.map((entry) => typeof entry === "string" ? entry : readSubtreeMiddlewareEntryId(entry))
|
|
928
|
+
.filter((id) => Boolean(id));
|
|
597
929
|
return Array.from(new Set(ids));
|
|
598
930
|
}
|
|
599
931
|
function appendSubtreeMiddlewareIds(target, entries) {
|
|
@@ -602,16 +934,12 @@ function appendSubtreeMiddlewareIds(target, entries) {
|
|
|
602
934
|
}
|
|
603
935
|
}
|
|
604
936
|
function normalizeSubtreePolicy(resource) {
|
|
605
|
-
const
|
|
606
|
-
if (!rawSubtree || typeof rawSubtree !== "object")
|
|
607
|
-
return null;
|
|
608
|
-
const subtreePolicies = Array.isArray(rawSubtree)
|
|
609
|
-
? rawSubtree.filter((policy) => Boolean(policy) && typeof policy === "object")
|
|
610
|
-
: [rawSubtree];
|
|
937
|
+
const subtreePolicies = getSubtreePolicies(resource);
|
|
611
938
|
if (subtreePolicies.length === 0)
|
|
612
939
|
return null;
|
|
613
940
|
const taskMiddlewareIds = new Set();
|
|
614
941
|
const resourceMiddlewareIds = new Set();
|
|
942
|
+
const taskIdentityRequirements = [];
|
|
615
943
|
let tasksValidatorCount = 0;
|
|
616
944
|
let resourcesValidatorCount = 0;
|
|
617
945
|
let hooksValidatorCount = 0;
|
|
@@ -619,11 +947,16 @@ function normalizeSubtreePolicy(resource) {
|
|
|
619
947
|
let resourceMiddlewareValidatorCount = 0;
|
|
620
948
|
let eventsValidatorCount = 0;
|
|
621
949
|
let tagsValidatorCount = 0;
|
|
950
|
+
let subtreeMiddlewareIdentityScope = null;
|
|
622
951
|
for (const subtree of subtreePolicies) {
|
|
623
952
|
if (subtree.tasks) {
|
|
624
953
|
appendSubtreeMiddlewareIds(taskMiddlewareIds, subtree.tasks.middleware);
|
|
954
|
+
taskIdentityRequirements.push(...normalizeIdentityRequirementSummaries(subtree.tasks.identity));
|
|
625
955
|
tasksValidatorCount += normalizeSubtreeValidatorCount(subtree.tasks.validate);
|
|
626
956
|
}
|
|
957
|
+
if (subtree.middleware && "identityScope" in subtree.middleware) {
|
|
958
|
+
subtreeMiddlewareIdentityScope = normalizeIdentityScopeSummary(subtree.middleware.identityScope);
|
|
959
|
+
}
|
|
627
960
|
if (subtree.resources) {
|
|
628
961
|
appendSubtreeMiddlewareIds(resourceMiddlewareIds, subtree.resources.middleware);
|
|
629
962
|
resourcesValidatorCount += normalizeSubtreeValidatorCount(subtree.resources.validate);
|
|
@@ -644,10 +977,20 @@ function normalizeSubtreePolicy(resource) {
|
|
|
644
977
|
tagsValidatorCount += normalizeSubtreeValidatorCount(subtree.tags.validate);
|
|
645
978
|
}
|
|
646
979
|
}
|
|
647
|
-
const tasks = taskMiddlewareIds.size > 0 ||
|
|
980
|
+
const tasks = taskMiddlewareIds.size > 0 ||
|
|
981
|
+
tasksValidatorCount > 0 ||
|
|
982
|
+
taskIdentityRequirements.length > 0
|
|
648
983
|
? {
|
|
649
984
|
middleware: Array.from(taskMiddlewareIds),
|
|
650
985
|
validatorCount: tasksValidatorCount,
|
|
986
|
+
...(taskIdentityRequirements.length > 0
|
|
987
|
+
? { identity: taskIdentityRequirements }
|
|
988
|
+
: {}),
|
|
989
|
+
}
|
|
990
|
+
: null;
|
|
991
|
+
const middleware = subtreeMiddlewareIdentityScope !== null
|
|
992
|
+
? {
|
|
993
|
+
identityScope: subtreeMiddlewareIdentityScope,
|
|
651
994
|
}
|
|
652
995
|
: null;
|
|
653
996
|
const resources = resourceMiddlewareIds.size > 0 || resourcesValidatorCount > 0
|
|
@@ -682,6 +1025,7 @@ function normalizeSubtreePolicy(resource) {
|
|
|
682
1025
|
}
|
|
683
1026
|
: null;
|
|
684
1027
|
if (!tasks &&
|
|
1028
|
+
!middleware &&
|
|
685
1029
|
!resources &&
|
|
686
1030
|
!hooks &&
|
|
687
1031
|
!taskMiddleware &&
|
|
@@ -692,6 +1036,7 @@ function normalizeSubtreePolicy(resource) {
|
|
|
692
1036
|
}
|
|
693
1037
|
return {
|
|
694
1038
|
tasks,
|
|
1039
|
+
middleware,
|
|
695
1040
|
resources,
|
|
696
1041
|
hooks,
|
|
697
1042
|
taskMiddleware,
|
|
@@ -710,20 +1055,6 @@ function parseTagConfigJson(config) {
|
|
|
710
1055
|
return null;
|
|
711
1056
|
}
|
|
712
1057
|
}
|
|
713
|
-
function extractEventLaneSummary(tagsDetailed) {
|
|
714
|
-
const laneTag = tagsDetailed.find((tag) => matchesTagId(tag.id, lane_resources_1.EVENT_LANE_TAG_ID));
|
|
715
|
-
if (!laneTag)
|
|
716
|
-
return null;
|
|
717
|
-
const parsed = parseTagConfigJson(laneTag.config);
|
|
718
|
-
const laneId = (0, lane_resources_1.extractLaneId)(parsed?.lane);
|
|
719
|
-
if (!laneId)
|
|
720
|
-
return null;
|
|
721
|
-
return {
|
|
722
|
-
laneId,
|
|
723
|
-
orderingKey: parsed?.orderingKey != null ? String(parsed.orderingKey) : null,
|
|
724
|
-
metadata: parsed?.metadata != null ? (0, introspector_tools_1.stringifyIfObject)(parsed.metadata) : null,
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
1058
|
function extractRpcLaneSummary(tagsDetailed) {
|
|
728
1059
|
const laneTag = tagsDetailed.find((tag) => matchesTagId(tag.id, lane_resources_1.RPC_LANE_TAG_ID));
|
|
729
1060
|
if (!laneTag)
|