@shipfox/api-definitions 8.0.0 → 9.0.2
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +83 -0
- package/dist/core/entities/integration-context.d.ts +12 -1
- package/dist/core/entities/integration-context.d.ts.map +1 -1
- package/dist/core/entities/integration-context.js.map +1 -1
- package/dist/core/sync-definitions.d.ts +1 -0
- package/dist/core/sync-definitions.d.ts.map +1 -1
- package/dist/core/sync-definitions.js +3 -3
- package/dist/core/sync-definitions.js.map +1 -1
- package/dist/core/workflow-model/normalize-agent-integrations.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-agent-integrations.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +31 -24
- package/src/core/entities/integration-context.ts +13 -5
- package/src/core/sync-definitions.test.ts +3 -6
- package/src/core/sync-definitions.ts +3 -3
- package/src/core/workflow-model/normalize-agent-integrations.ts +7 -1
- package/src/index.ts +1 -1
- package/src/temporal/activities/sync-activities.test.ts +3 -6
- package/test/agent-validation-catalog.ts +3 -2
- package/test/published/workflow-source-bundle.mjs +17 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
$ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
|
|
2
|
-
Successfully compiled: 72 files with swc (
|
|
3
|
-
2026-07-
|
|
2
|
+
Successfully compiled: 72 files with swc (620.07ms)
|
|
3
|
+
2026-07-24T15:39:03.252Z [INFO] asset workflow-bundle-2e2f2f4d6c035dc8e198.js 3.18 MiB [emitted] [immutable] (name: main)
|
|
4
4
|
orphan modules 33.5 KiB [orphan] 21 modules
|
|
5
5
|
runtime modules 1.13 KiB 5 modules
|
|
6
6
|
modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
|
|
@@ -14,6 +14,6 @@ optional modules 30 bytes [optional]
|
|
|
14
14
|
__temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
15
15
|
__temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
16
16
|
../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
|
|
17
|
-
webpack 5.107.2 compiled successfully in
|
|
18
|
-
2026-07-
|
|
17
|
+
webpack 5.107.2 compiled successfully in 5834 ms
|
|
18
|
+
2026-07-24T15:39:03.269Z [INFO] Workflow bundle created { size: '3.18MB' }
|
|
19
19
|
/home/runner/work/shipfox/shipfox/libs/api/definitions/dist/temporal/workflows/index.js: 3332889 bytes
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @shipfox/api-definitions
|
|
2
2
|
|
|
3
|
+
## 9.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b85404: Adds versioned architecture identity to participating package artifacts during publication.
|
|
8
|
+
- Updated dependencies [4b85404]
|
|
9
|
+
- @shipfox/api-agent-dto@9.0.2
|
|
10
|
+
- @shipfox/api-auth-context@9.0.2
|
|
11
|
+
- @shipfox/api-definitions-dto@9.0.2
|
|
12
|
+
- @shipfox/api-integration-core-dto@9.0.2
|
|
13
|
+
- @shipfox/api-projects-dto@9.0.2
|
|
14
|
+
- @shipfox/api-secrets-dto@9.0.2
|
|
15
|
+
- @shipfox/config@1.2.4
|
|
16
|
+
- @shipfox/expression@1.1.5
|
|
17
|
+
- @shipfox/inter-module@0.2.2
|
|
18
|
+
- @shipfox/node-drizzle@0.3.4
|
|
19
|
+
- @shipfox/node-error-monitoring@0.2.2
|
|
20
|
+
- @shipfox/node-fastify@0.3.2
|
|
21
|
+
- @shipfox/node-module@1.0.1
|
|
22
|
+
- @shipfox/node-opentelemetry@0.6.2
|
|
23
|
+
- @shipfox/node-outbox@0.2.6
|
|
24
|
+
- @shipfox/node-postgres@0.4.4
|
|
25
|
+
- @shipfox/node-temporal@0.4.2
|
|
26
|
+
- @shipfox/runner-labels@0.1.3
|
|
27
|
+
- @shipfox/workflow-document@2.1.3
|
|
28
|
+
|
|
29
|
+
## 9.0.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 475ce59: Republishes all public packages after restoring release authorization.
|
|
34
|
+
- Updated dependencies [8436596]
|
|
35
|
+
- Updated dependencies [475ce59]
|
|
36
|
+
- Updated dependencies [154e03f]
|
|
37
|
+
- @shipfox/api-secrets-dto@9.0.1
|
|
38
|
+
- @shipfox/runner-labels@0.1.2
|
|
39
|
+
- @shipfox/expression@1.1.4
|
|
40
|
+
- @shipfox/workflow-document@2.1.2
|
|
41
|
+
- @shipfox/api-agent-dto@9.0.1
|
|
42
|
+
- @shipfox/api-auth-context@9.0.1
|
|
43
|
+
- @shipfox/api-definitions-dto@9.0.1
|
|
44
|
+
- @shipfox/api-integration-core-dto@9.0.1
|
|
45
|
+
- @shipfox/api-projects-dto@9.0.1
|
|
46
|
+
- @shipfox/config@1.2.3
|
|
47
|
+
- @shipfox/inter-module@0.2.1
|
|
48
|
+
- @shipfox/node-drizzle@0.3.3
|
|
49
|
+
- @shipfox/node-error-monitoring@0.2.1
|
|
50
|
+
- @shipfox/node-fastify@0.3.1
|
|
51
|
+
- @shipfox/node-module@1.0.0
|
|
52
|
+
- @shipfox/node-opentelemetry@0.6.1
|
|
53
|
+
- @shipfox/node-outbox@0.2.5
|
|
54
|
+
- @shipfox/node-postgres@0.4.3
|
|
55
|
+
- @shipfox/node-temporal@0.4.1
|
|
56
|
+
|
|
57
|
+
## 9.0.0
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- a9f9c57: Decouples Definitions and Workflows tests from peer implementation packages and databases.
|
|
62
|
+
- c279061: Improves release verification with owner-defined packed contracts, discovery-driven artifact checks, and an early publication preflight.
|
|
63
|
+
- Updated dependencies [46aa52f]
|
|
64
|
+
- Updated dependencies [02974d6]
|
|
65
|
+
- Updated dependencies [4a6d124]
|
|
66
|
+
- @shipfox/api-agent-dto@9.0.0
|
|
67
|
+
- @shipfox/api-integration-core-dto@9.0.0
|
|
68
|
+
- @shipfox/api-secrets-dto@9.0.0
|
|
69
|
+
- @shipfox/api-auth-context@9.0.0
|
|
70
|
+
- @shipfox/api-definitions-dto@6.0.0
|
|
71
|
+
- @shipfox/api-projects-dto@8.0.0
|
|
72
|
+
- @shipfox/config@1.2.2
|
|
73
|
+
- @shipfox/inter-module@0.2.0
|
|
74
|
+
- @shipfox/runner-labels@0.1.1
|
|
75
|
+
- @shipfox/expression@1.1.3
|
|
76
|
+
- @shipfox/node-drizzle@0.3.2
|
|
77
|
+
- @shipfox/node-error-monitoring@0.2.0
|
|
78
|
+
- @shipfox/node-fastify@0.3.0
|
|
79
|
+
- @shipfox/node-module@0.5.0
|
|
80
|
+
- @shipfox/node-opentelemetry@0.6.0
|
|
81
|
+
- @shipfox/node-outbox@0.2.4
|
|
82
|
+
- @shipfox/node-postgres@0.4.2
|
|
83
|
+
- @shipfox/node-temporal@0.4.0
|
|
84
|
+
- @shipfox/workflow-document@2.1.1
|
|
85
|
+
|
|
3
86
|
## 8.0.0
|
|
4
87
|
|
|
5
88
|
### Major Changes
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
type IntegrationProviderKind = string;
|
|
2
|
+
type IntegrationCapability = 'source_control' | 'agent_tools';
|
|
3
|
+
interface AgentToolSelectionCatalog {
|
|
4
|
+
readonly selectors: readonly AgentToolSelector[];
|
|
5
|
+
}
|
|
6
|
+
interface AgentToolSelector {
|
|
7
|
+
readonly token: string;
|
|
8
|
+
readonly kind: 'family' | 'family_wildcard' | 'method' | 'standalone';
|
|
9
|
+
readonly sensitivity: 'read' | 'write';
|
|
10
|
+
readonly sensitive: boolean;
|
|
11
|
+
}
|
|
2
12
|
export interface IntegrationValidationContext {
|
|
3
13
|
readonly agentToolSelectionCatalogs: ReadonlyMap<IntegrationProviderKind, AgentToolSelectionCatalog>;
|
|
4
14
|
readonly workspaceConnectionSnapshot: ReadonlyMap<string, {
|
|
@@ -8,4 +18,5 @@ export interface IntegrationValidationContext {
|
|
|
8
18
|
}>;
|
|
9
19
|
readonly defaultConnectionSlug?: string | undefined;
|
|
10
20
|
}
|
|
21
|
+
export {};
|
|
11
22
|
//# sourceMappingURL=integration-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-context.d.ts","sourceRoot":"","sources":["../../../src/core/entities/integration-context.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"integration-context.d.ts","sourceRoot":"","sources":["../../../src/core/entities/integration-context.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,GAAG,MAAM,CAAC;AACtC,KAAK,qBAAqB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAE9D,UAAU,yBAAyB;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAClD;AAED,UAAU,iBAAiB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,0BAA0B,EAAE,WAAW,CAC9C,uBAAuB,EACvB,yBAAyB,CAC1B,CAAC;IACF,QAAQ,CAAC,2BAA2B,EAAE,WAAW,CAC/C,MAAM,EACN;QACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;QAC3C,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;KACzD,CACF,CAAC;IACF,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/entities/integration-context.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/core/entities/integration-context.ts"],"sourcesContent":["type IntegrationProviderKind = string;\ntype IntegrationCapability = 'source_control' | 'agent_tools';\n\ninterface AgentToolSelectionCatalog {\n readonly selectors: readonly AgentToolSelector[];\n}\n\ninterface AgentToolSelector {\n readonly token: string;\n readonly kind: 'family' | 'family_wildcard' | 'method' | 'standalone';\n readonly sensitivity: 'read' | 'write';\n readonly sensitive: boolean;\n}\n\nexport interface IntegrationValidationContext {\n readonly agentToolSelectionCatalogs: ReadonlyMap<\n IntegrationProviderKind,\n AgentToolSelectionCatalog\n >;\n readonly workspaceConnectionSnapshot: ReadonlyMap<\n string,\n {\n readonly id: string;\n readonly provider: IntegrationProviderKind;\n readonly capabilities: readonly IntegrationCapability[];\n }\n >;\n readonly defaultConnectionSlug?: string | undefined;\n}\n"],"names":[],"mappings":"AAcA,WAcC"}
|
|
@@ -5,6 +5,7 @@ import type { WorkflowDefinitionPayload } from './entities/workflow-definition.j
|
|
|
5
5
|
import type { DefinitionsSourceControl } from './integrations.js';
|
|
6
6
|
export declare const WORKFLOW_PREFIX = ".shipfox/workflows/";
|
|
7
7
|
export declare const MAX_WORKFLOW_FILES = 100;
|
|
8
|
+
export declare const MAX_WORKFLOW_FILE_BYTES = 1000000;
|
|
8
9
|
export declare const FILE_FETCH_CONCURRENCY = 4;
|
|
9
10
|
export declare const UNRESOLVED_SYNC_REF = "__unresolved__";
|
|
10
11
|
export interface SyncSourceContext {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-definitions.d.ts","sourceRoot":"","sources":["../../src/core/sync-definitions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,sBAAsB,EA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C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,gCAAgC,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,4BAA4B,CAAC,CAAC,GAAG,SAAS,CAAC;CAC9F;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,cAAc,EAAE,CAAC,CAkD3B;AA6BD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CA+B7E"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { MAX_REPOSITORY_FILE_BYTES } from '@shipfox/api-integration-core-dto';
|
|
3
2
|
import { integrationsInterModuleContract } from '@shipfox/api-integration-core-dto/inter-module';
|
|
4
3
|
import { isInterModuleKnownError } from '@shipfox/inter-module';
|
|
5
4
|
import { boundedMap } from '@shipfox/node-module';
|
|
@@ -8,6 +7,7 @@ import { hasAgentStepIntegrations } from './has-agent-step-integrations.js';
|
|
|
8
7
|
import { parseDefinition } from './parse-definition.js';
|
|
9
8
|
export const WORKFLOW_PREFIX = '.shipfox/workflows/';
|
|
10
9
|
export const MAX_WORKFLOW_FILES = 100;
|
|
10
|
+
export const MAX_WORKFLOW_FILE_BYTES = 1_000_000;
|
|
11
11
|
export const FILE_FETCH_CONCURRENCY = 4;
|
|
12
12
|
export const UNRESOLVED_SYNC_REF = '__unresolved__';
|
|
13
13
|
export async function resolveSyncSource(params) {
|
|
@@ -50,8 +50,8 @@ export async function fetchAndParseWorkflows(params) {
|
|
|
50
50
|
ref: params.ref,
|
|
51
51
|
path
|
|
52
52
|
});
|
|
53
|
-
if (Buffer.byteLength(snapshot.content, 'utf8') >
|
|
54
|
-
throw new DefinitionSyncPermanentError('content-too-large', `Workflow file is larger than ${
|
|
53
|
+
if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_WORKFLOW_FILE_BYTES) {
|
|
54
|
+
throw new DefinitionSyncPermanentError('content-too-large', `Workflow file is larger than ${MAX_WORKFLOW_FILE_BYTES} bytes: ${snapshot.path}`);
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
...parseWorkflowSnapshot({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/sync-definitions.ts"],"sourcesContent":["import {createHash} from 'node:crypto';\nimport type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {MAX_REPOSITORY_FILE_BYTES} from '@shipfox/api-integration-core-dto';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto/inter-module';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {DefinitionSyncErrorCode} from './entities/sync-state.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nimport {hasAgentStepIntegrations} from './has-agent-step-integrations.js';\nimport type {DefinitionsSourceControl} from './integrations.js';\nimport {parseDefinition} from './parse-definition.js';\n\nexport const WORKFLOW_PREFIX = '.shipfox/workflows/';\nexport const MAX_WORKFLOW_FILES = 100;\nexport const FILE_FETCH_CONCURRENCY = 4;\nexport const UNRESOLVED_SYNC_REF = '__unresolved__';\n\nexport interface SyncSourceContext {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceControl: DefinitionsSourceControl;\n}\n\nexport interface ResolvedSyncSource {\n ref: string;\n}\n\nexport async function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource> {\n const source = await params.sourceControl.resolveRepository({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n });\n return {ref: source.repository.defaultBranch};\n}\n\nexport interface DiscoverWorkflowFilesParams extends SyncSourceContext {\n ref: string;\n}\n\nexport async function discoverWorkflowFiles(\n params: DiscoverWorkflowFilesParams,\n): Promise<{paths: string[]}> {\n const page = await params.sourceControl.listFiles({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n prefix: WORKFLOW_PREFIX,\n limit: MAX_WORKFLOW_FILES,\n });\n if (page.nextCursor) {\n throw new DefinitionSyncPermanentError(\n 'too-many-files',\n `More than ${MAX_WORKFLOW_FILES} workflow files were found`,\n );\n }\n\n const paths = page.files\n .filter((file) => file.path.endsWith('.yml') || file.path.endsWith('.yaml'))\n .map((file) => file.path);\n if (paths.length === 0) {\n throw new DefinitionSyncPermanentError(\n 'no-workflow-files',\n `No workflow files were found under ${WORKFLOW_PREFIX}`,\n );\n }\n\n return {paths};\n}\n\nexport interface ParsedWorkflow {\n path: string;\n name: string;\n definition: WorkflowDefinitionPayload;\n contentHash: string;\n}\n\nexport interface FetchAndParseWorkflowsParams extends SyncSourceContext {\n ref: string;\n paths: string[];\n onProgress?: ((path: string) => void) | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;\n}\n\nexport async function fetchAndParseWorkflows(\n params: FetchAndParseWorkflowsParams,\n): Promise<ParsedWorkflow[]> {\n const parsed = await boundedMap(\n params.paths,\n FILE_FETCH_CONCURRENCY,\n async (path) => {\n params.onProgress?.(path);\n\n const snapshot = await params.sourceControl.fetchFile({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n path,\n });\n\n if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_REPOSITORY_FILE_BYTES) {\n throw new DefinitionSyncPermanentError(\n 'content-too-large',\n `Workflow file is larger than ${MAX_REPOSITORY_FILE_BYTES} bytes: ${snapshot.path}`,\n );\n }\n\n return {\n ...parseWorkflowSnapshot({\n path: snapshot.path,\n content: snapshot.content,\n agentValidationCatalog: params.agentValidationCatalog,\n }),\n rawContent: snapshot.content,\n };\n },\n {stopOnError: true},\n );\n\n if (\n !params.loadIntegrationValidationContext ||\n !parsed.some((entry) => hasAgentStepIntegrations(entry.definition.document))\n ) {\n return parsed.map(({rawContent: _rawContent, ...entry}) => entry);\n }\n\n const integrationValidationContext = await params.loadIntegrationValidationContext();\n return parsed.map((entry) =>\n parseWorkflowSnapshot({\n path: entry.path,\n content: entry.rawContent,\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext,\n }),\n );\n}\n\nfunction parseWorkflowSnapshot(params: {\n path: string;\n content: string;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n}): ParsedWorkflow {\n try {\n const definition =\n params.integrationValidationContext === undefined\n ? parseDefinition(params.content, {agentValidationCatalog: params.agentValidationCatalog})\n : parseDefinition(params.content, {\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext: params.integrationValidationContext,\n });\n const contentHash = sha256Hex(params.content);\n return {path: params.path, name: definition.document.name, definition, contentHash};\n } catch (error) {\n if (error instanceof DefinitionParseError) {\n throw new DefinitionSyncPermanentError(\n 'invalid-definition',\n `Invalid workflow definition at ${params.path}: ${error.message}`,\n );\n }\n throw error;\n }\n}\n\nexport interface SyncFailureClassification {\n code: DefinitionSyncErrorCode;\n message: string;\n retryable: boolean;\n}\n\nexport function classifySyncFailure(error: unknown): SyncFailureClassification {\n if (error instanceof DefinitionSyncPermanentError) {\n return {code: error.code, message: error.message, retryable: false};\n }\n const methods = [\n integrationsInterModuleContract.methods.resolveSourceRepository,\n integrationsInterModuleContract.methods.listSourceFiles,\n integrationsInterModuleContract.methods.fetchSourceFile,\n ] as const;\n for (const method of methods) {\n if (!isInterModuleKnownError(method, error)) continue;\n if (\n error.code === 'connection-not-found' ||\n error.code === 'connection-inactive' ||\n error.code === 'connection-workspace-mismatch'\n ) {\n return {code: 'connection-unavailable', message: error.message, retryable: false};\n }\n if (error.code === 'provider-failure') {\n return {\n code: providerErrorCode(error.details.reason),\n message: error.message,\n retryable: isProviderReasonRetryable(error.details.reason),\n };\n }\n }\n return {\n code: 'unknown',\n message: error instanceof Error ? error.message : String(error),\n retryable: true,\n };\n}\n\nfunction isProviderReasonRetryable(reason: string): boolean {\n return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';\n}\n\nfunction providerErrorCode(reason: string): DefinitionSyncErrorCode {\n if (reason === 'repository-not-found') return 'provider-repository-not-found';\n if (reason === 'file-not-found') return 'provider-file-not-found';\n if (reason === 'access-denied') return 'provider-access-denied';\n if (reason === 'rate-limited') return 'provider-rate-limited';\n if (reason === 'timeout') return 'provider-timeout';\n if (reason === 'provider-unavailable') return 'provider-unavailable';\n if (reason === 'malformed-provider-response') return 'provider-malformed-response';\n if (reason === 'content-too-large') return 'content-too-large';\n if (reason === 'too-many-files') return 'too-many-files';\n return 'unknown';\n}\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n"],"names":["createHash","MAX_REPOSITORY_FILE_BYTES","integrationsInterModuleContract","isInterModuleKnownError","boundedMap","DefinitionParseError","DefinitionSyncPermanentError","hasAgentStepIntegrations","parseDefinition","WORKFLOW_PREFIX","MAX_WORKFLOW_FILES","FILE_FETCH_CONCURRENCY","UNRESOLVED_SYNC_REF","resolveSyncSource","params","source","sourceControl","resolveRepository","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","ref","repository","defaultBranch","discoverWorkflowFiles","page","listFiles","prefix","limit","nextCursor","paths","files","filter","file","path","endsWith","map","length","fetchAndParseWorkflows","parsed","onProgress","snapshot","fetchFile","Buffer","byteLength","content","parseWorkflowSnapshot","agentValidationCatalog","rawContent","stopOnError","loadIntegrationValidationContext","some","entry","definition","document","_rawContent","integrationValidationContext","undefined","contentHash","sha256Hex","name","error","message","classifySyncFailure","code","retryable","methods","resolveSourceRepository","listSourceFiles","fetchSourceFile","method","providerErrorCode","details","reason","isProviderReasonRetryable","Error","String","update","digest"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAc;AAEvC,SAAQC,yBAAyB,QAAO,oCAAoC;AAC5E,SAAQC,+BAA+B,QAAO,iDAAiD;AAC/F,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,UAAU,QAAO,uBAAuB;AAIhD,SAAQC,oBAAoB,EAAEC,4BAA4B,QAAO,cAAc;AAC/E,SAAQC,wBAAwB,QAAO,mCAAmC;AAE1E,SAAQC,eAAe,QAAO,wBAAwB;AAEtD,OAAO,MAAMC,kBAAkB,sBAAsB;AACrD,OAAO,MAAMC,qBAAqB,IAAI;AACtC,OAAO,MAAMC,yBAAyB,EAAE;AACxC,OAAO,MAAMC,sBAAsB,iBAAiB;AAapD,OAAO,eAAeC,kBAAkBC,MAAyB;IAC/D,MAAMC,SAAS,MAAMD,OAAOE,aAAa,CAACC,iBAAiB,CAAC;QAC1DC,aAAaJ,OAAOI,WAAW;QAC/BC,cAAcL,OAAOM,kBAAkB;QACvCC,sBAAsBP,OAAOQ,0BAA0B;IACzD;IACA,OAAO;QAACC,KAAKR,OAAOS,UAAU,CAACC,aAAa;IAAA;AAC9C;AAMA,OAAO,eAAeC,sBACpBZ,MAAmC;IAEnC,MAAMa,OAAO,MAAMb,OAAOE,aAAa,CAACY,SAAS,CAAC;QAChDV,aAAaJ,OAAOI,WAAW;QAC/BC,cAAcL,OAAOM,kBAAkB;QACvCC,sBAAsBP,OAAOQ,0BAA0B;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{createHash} from 'node:crypto';\nimport type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto/inter-module';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {DefinitionSyncErrorCode} from './entities/sync-state.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nimport {hasAgentStepIntegrations} from './has-agent-step-integrations.js';\nimport type {DefinitionsSourceControl} from './integrations.js';\nimport {parseDefinition} from './parse-definition.js';\n\nexport const WORKFLOW_PREFIX = '.shipfox/workflows/';\nexport const MAX_WORKFLOW_FILES = 100;\nexport const MAX_WORKFLOW_FILE_BYTES = 1_000_000;\nexport const FILE_FETCH_CONCURRENCY = 4;\nexport const UNRESOLVED_SYNC_REF = '__unresolved__';\n\nexport interface SyncSourceContext {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceControl: DefinitionsSourceControl;\n}\n\nexport interface ResolvedSyncSource {\n ref: string;\n}\n\nexport async function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource> {\n const source = await params.sourceControl.resolveRepository({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n });\n return {ref: source.repository.defaultBranch};\n}\n\nexport interface DiscoverWorkflowFilesParams extends SyncSourceContext {\n ref: string;\n}\n\nexport async function discoverWorkflowFiles(\n params: DiscoverWorkflowFilesParams,\n): Promise<{paths: string[]}> {\n const page = await params.sourceControl.listFiles({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n prefix: WORKFLOW_PREFIX,\n limit: MAX_WORKFLOW_FILES,\n });\n if (page.nextCursor) {\n throw new DefinitionSyncPermanentError(\n 'too-many-files',\n `More than ${MAX_WORKFLOW_FILES} workflow files were found`,\n );\n }\n\n const paths = page.files\n .filter((file) => file.path.endsWith('.yml') || file.path.endsWith('.yaml'))\n .map((file) => file.path);\n if (paths.length === 0) {\n throw new DefinitionSyncPermanentError(\n 'no-workflow-files',\n `No workflow files were found under ${WORKFLOW_PREFIX}`,\n );\n }\n\n return {paths};\n}\n\nexport interface ParsedWorkflow {\n path: string;\n name: string;\n definition: WorkflowDefinitionPayload;\n contentHash: string;\n}\n\nexport interface FetchAndParseWorkflowsParams extends SyncSourceContext {\n ref: string;\n paths: string[];\n onProgress?: ((path: string) => void) | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;\n}\n\nexport async function fetchAndParseWorkflows(\n params: FetchAndParseWorkflowsParams,\n): Promise<ParsedWorkflow[]> {\n const parsed = await boundedMap(\n params.paths,\n FILE_FETCH_CONCURRENCY,\n async (path) => {\n params.onProgress?.(path);\n\n const snapshot = await params.sourceControl.fetchFile({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n path,\n });\n\n if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_WORKFLOW_FILE_BYTES) {\n throw new DefinitionSyncPermanentError(\n 'content-too-large',\n `Workflow file is larger than ${MAX_WORKFLOW_FILE_BYTES} bytes: ${snapshot.path}`,\n );\n }\n\n return {\n ...parseWorkflowSnapshot({\n path: snapshot.path,\n content: snapshot.content,\n agentValidationCatalog: params.agentValidationCatalog,\n }),\n rawContent: snapshot.content,\n };\n },\n {stopOnError: true},\n );\n\n if (\n !params.loadIntegrationValidationContext ||\n !parsed.some((entry) => hasAgentStepIntegrations(entry.definition.document))\n ) {\n return parsed.map(({rawContent: _rawContent, ...entry}) => entry);\n }\n\n const integrationValidationContext = await params.loadIntegrationValidationContext();\n return parsed.map((entry) =>\n parseWorkflowSnapshot({\n path: entry.path,\n content: entry.rawContent,\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext,\n }),\n );\n}\n\nfunction parseWorkflowSnapshot(params: {\n path: string;\n content: string;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n}): ParsedWorkflow {\n try {\n const definition =\n params.integrationValidationContext === undefined\n ? parseDefinition(params.content, {agentValidationCatalog: params.agentValidationCatalog})\n : parseDefinition(params.content, {\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext: params.integrationValidationContext,\n });\n const contentHash = sha256Hex(params.content);\n return {path: params.path, name: definition.document.name, definition, contentHash};\n } catch (error) {\n if (error instanceof DefinitionParseError) {\n throw new DefinitionSyncPermanentError(\n 'invalid-definition',\n `Invalid workflow definition at ${params.path}: ${error.message}`,\n );\n }\n throw error;\n }\n}\n\nexport interface SyncFailureClassification {\n code: DefinitionSyncErrorCode;\n message: string;\n retryable: boolean;\n}\n\nexport function classifySyncFailure(error: unknown): SyncFailureClassification {\n if (error instanceof DefinitionSyncPermanentError) {\n return {code: error.code, message: error.message, retryable: false};\n }\n const methods = [\n integrationsInterModuleContract.methods.resolveSourceRepository,\n integrationsInterModuleContract.methods.listSourceFiles,\n integrationsInterModuleContract.methods.fetchSourceFile,\n ] as const;\n for (const method of methods) {\n if (!isInterModuleKnownError(method, error)) continue;\n if (\n error.code === 'connection-not-found' ||\n error.code === 'connection-inactive' ||\n error.code === 'connection-workspace-mismatch'\n ) {\n return {code: 'connection-unavailable', message: error.message, retryable: false};\n }\n if (error.code === 'provider-failure') {\n return {\n code: providerErrorCode(error.details.reason),\n message: error.message,\n retryable: isProviderReasonRetryable(error.details.reason),\n };\n }\n }\n return {\n code: 'unknown',\n message: error instanceof Error ? error.message : String(error),\n retryable: true,\n };\n}\n\nfunction isProviderReasonRetryable(reason: string): boolean {\n return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';\n}\n\nfunction providerErrorCode(reason: string): DefinitionSyncErrorCode {\n if (reason === 'repository-not-found') return 'provider-repository-not-found';\n if (reason === 'file-not-found') return 'provider-file-not-found';\n if (reason === 'access-denied') return 'provider-access-denied';\n if (reason === 'rate-limited') return 'provider-rate-limited';\n if (reason === 'timeout') return 'provider-timeout';\n if (reason === 'provider-unavailable') return 'provider-unavailable';\n if (reason === 'malformed-provider-response') return 'provider-malformed-response';\n if (reason === 'content-too-large') return 'content-too-large';\n if (reason === 'too-many-files') return 'too-many-files';\n return 'unknown';\n}\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n"],"names":["createHash","integrationsInterModuleContract","isInterModuleKnownError","boundedMap","DefinitionParseError","DefinitionSyncPermanentError","hasAgentStepIntegrations","parseDefinition","WORKFLOW_PREFIX","MAX_WORKFLOW_FILES","MAX_WORKFLOW_FILE_BYTES","FILE_FETCH_CONCURRENCY","UNRESOLVED_SYNC_REF","resolveSyncSource","params","source","sourceControl","resolveRepository","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","ref","repository","defaultBranch","discoverWorkflowFiles","page","listFiles","prefix","limit","nextCursor","paths","files","filter","file","path","endsWith","map","length","fetchAndParseWorkflows","parsed","onProgress","snapshot","fetchFile","Buffer","byteLength","content","parseWorkflowSnapshot","agentValidationCatalog","rawContent","stopOnError","loadIntegrationValidationContext","some","entry","definition","document","_rawContent","integrationValidationContext","undefined","contentHash","sha256Hex","name","error","message","classifySyncFailure","code","retryable","methods","resolveSourceRepository","listSourceFiles","fetchSourceFile","method","providerErrorCode","details","reason","isProviderReasonRetryable","Error","String","update","digest"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAc;AAEvC,SAAQC,+BAA+B,QAAO,iDAAiD;AAC/F,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,UAAU,QAAO,uBAAuB;AAIhD,SAAQC,oBAAoB,EAAEC,4BAA4B,QAAO,cAAc;AAC/E,SAAQC,wBAAwB,QAAO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ASD,iBAAiBc,QAAQd,MAAMC,OAAO,GAAGc,OAAOf;QACzDI,WAAW;IACb;AACF;AAEA,SAASS,0BAA0BD,MAAc;IAC/C,OAAOA,WAAW,kBAAkBA,WAAW,aAAaA,WAAW;AACzE;AAEA,SAASF,kBAAkBE,MAAc;IACvC,IAAIA,WAAW,wBAAwB,OAAO;IAC9C,IAAIA,WAAW,kBAAkB,OAAO;IACxC,IAAIA,WAAW,iBAAiB,OAAO;IACvC,IAAIA,WAAW,gBAAgB,OAAO;IACtC,IAAIA,WAAW,WAAW,OAAO;IACjC,IAAIA,WAAW,wBAAwB,OAAO;IAC9C,IAAIA,WAAW,+BAA+B,OAAO;IACrD,IAAIA,WAAW,qBAAqB,OAAO;IAC3C,IAAIA,WAAW,kBAAkB,OAAO;IACxC,OAAO;AACT;AAEA,SAASd,UAAUd,OAAe;IAChC,OAAO/C,WAAW,UAAU+E,MAAM,CAAChC,SAAS,QAAQiC,MAAM,CAAC;AAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-agent-integrations.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-agent-integrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-agent-integrations.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-agent-integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,4BAA4B,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAUpF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE;IACjD,YAAY,EAAE,SAAS,+BAA+B,EAAE,GAAG,SAAS,CAAC;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CACzE,GAAG,SAAS,4BAA4B,EAAE,GAAG,SAAS,CAQtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/workflow-model/normalize-agent-integrations.ts"],"sourcesContent":["import type {AgentToolSelector} from '@shipfox/api-integration-core-dto';\nimport type {WorkflowDocumentStepIntegration} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {WorkflowModelStepIntegration} from '../entities/workflow-model.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {issue} from './validation-issue.js';\n\nexport function normalizeAgentIntegrations(params: {\n integrations: readonly WorkflowDocumentStepIntegration[] | undefined;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): readonly WorkflowModelStepIntegration[] | undefined {\n if (params.integrations === undefined) return undefined;\n\n return params.integrations.map((integration, integrationIndex) => {\n const normalized = normalizeIntegration(integration);\n validateIntegration({...params, integration, normalized, integrationIndex});\n return normalized;\n });\n}\n\nfunction normalizeIntegration(\n integration: WorkflowDocumentStepIntegration,\n): WorkflowModelStepIntegration {\n return {\n ...(integration.connection === undefined ? {} : {connection: integration.connection}),\n include: dedupe(integration.include),\n ...(integration.exclude === undefined ? {} : {exclude: dedupe(integration.exclude)}),\n allowWrite: integration.allow_write ?? false,\n };\n}\n\nfunction validateIntegration(params: {\n integration: WorkflowDocumentStepIntegration;\n normalized: WorkflowModelStepIntegration;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): void {\n const context = params.integrationValidationContext;\n if (context === undefined) return;\n\n const connectionSlug = params.normalized.connection ?? context.defaultConnectionSlug;\n if (connectionSlug === undefined) {\n params.issues.push(\n issue({\n code: 'missing-connection-for-integration',\n message: 'Agent step integration requires a connection or a default source connection.',\n path: integrationPath(params),\n details: {integrationIndex: params.integrationIndex},\n }),\n );\n return;\n }\n\n const connection = context.workspaceConnectionSnapshot.get(connectionSlug);\n if (connection === undefined) {\n params.issues.push(\n issue({\n code: 'integration-connection-not-found',\n message: `Integration connection \"${connectionSlug}\" was not found in the workspace.`,\n path: integrationConnectionPath(params),\n details: {\n connection: connectionSlug,\n integrationIndex: params.integrationIndex,\n },\n }),\n );\n return;\n }\n\n const catalog = context.agentToolSelectionCatalogs.get(connection.provider);\n if (catalog === undefined || !connection.capabilities.includes('agent_tools')) {\n params.issues.push(\n issue({\n code: 'integration-connection-not-capable',\n message: `Integration connection \"${connectionSlug}\" does not support agent tools.`,\n path: integrationConnectionPath(params),\n details: {\n connection: connectionSlug,\n provider: connection.provider,\n capabilities: connection.capabilities,\n integrationIndex: params.integrationIndex,\n },\n }),\n );\n return;\n }\n\n const selectorsByToken = new Map(catalog.selectors.map((selector) => [selector.token, selector]));\n validateSelection({\n ...params,\n field: 'include',\n tokens: params.integration.include,\n selectorsByToken,\n });\n if (params.integration.exclude !== undefined) {\n validateSelection({\n ...params,\n field: 'exclude',\n tokens: params.integration.exclude,\n selectorsByToken,\n });\n }\n validateWriteSelection({...params, selectorsByToken});\n}\n\nfunction validateSelection(params: {\n field: 'include' | 'exclude';\n tokens: readonly string[];\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): void {\n params.tokens.forEach((token, tokenIndex) => {\n if (params.selectorsByToken.has(token)) return;\n\n const code = classifyUnknownSelection(token, params.selectorsByToken);\n params.issues.push(\n issue({\n code,\n message:\n code === 'unknown-integration-method'\n ? `Unknown integration tool method: ${token}.`\n : `Unknown integration tool: ${token}.`,\n path: [...integrationPath(params), params.field, tokenIndex],\n details: {token},\n }),\n );\n });\n}\n\nfunction validateWriteSelection(params: {\n integration: WorkflowDocumentStepIntegration;\n normalized: WorkflowModelStepIntegration;\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): void {\n if (params.normalized.allowWrite) return;\n\n const writeTokens = dedupe(\n params.integration.include.filter(\n (token) => params.selectorsByToken.get(token)?.sensitivity === 'write',\n ),\n );\n if (writeTokens.length === 0) return;\n\n params.issues.push(\n issue({\n code: 'integration-write-not-allowed',\n message: `Integration selection includes write-capable tools but allow_write is not true: ${writeTokens.join(', ')}.`,\n path: [...integrationPath(params), 'include'],\n details: {tokens: writeTokens},\n }),\n );\n}\n\nfunction classifyUnknownSelection(\n token: string,\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>,\n): 'unknown-integration-method' | 'unknown-integration-tool' {\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return 'unknown-integration-tool';\n\n const family = token.slice(0, dotIndex);\n return selectorsByToken.get(family)?.kind === 'family'\n ? 'unknown-integration-method'\n : 'unknown-integration-tool';\n}\n\nfunction integrationConnectionPath(params: {\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n integration: WorkflowDocumentStepIntegration;\n}): readonly (string | number)[] {\n const path = integrationPath(params);\n if (params.integration.connection === undefined) return path;\n return [...path, 'connection'];\n}\n\nfunction integrationPath(params: {\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n}): readonly (string | number)[] {\n return [\n 'jobs',\n params.sourceName,\n 'steps',\n params.stepIndex,\n 'integrations',\n params.integrationIndex,\n ];\n}\n\nfunction dedupe(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n"],"names":["issue","normalizeAgentIntegrations","params","integrations","undefined","map","integration","integrationIndex","normalized","normalizeIntegration","validateIntegration","connection","include","dedupe","exclude","allowWrite","allow_write","context","integrationValidationContext","connectionSlug","defaultConnectionSlug","issues","push","code","message","path","integrationPath","details","workspaceConnectionSnapshot","get","integrationConnectionPath","catalog","agentToolSelectionCatalogs","provider","capabilities","includes","selectorsByToken","Map","selectors","selector","token","validateSelection","field","tokens","validateWriteSelection","forEach","tokenIndex","has","classifyUnknownSelection","writeTokens","filter","sensitivity","length","join","dotIndex","indexOf","family","slice","kind","sourceName","stepIndex","values","Set"],"mappings":"AAKA,SAAQA,KAAK,QAAO,wBAAwB;AAE5C,OAAO,SAASC,2BAA2BC,MAM1C;IACC,IAAIA,OAAOC,YAAY,KAAKC,WAAW,OAAOA;IAE9C,OAAOF,OAAOC,YAAY,CAACE,GAAG,CAAC,CAACC,aAAaC;QAC3C,MAAMC,aAAaC,qBAAqBH;QACxCI,oBAAoB;YAAC,GAAGR,MAAM;YAAEI;YAAaE;YAAYD;QAAgB;QACzE,OAAOC;IACT;AACF;AAEA,SAASC,qBACPH,WAA4C;IAE5C,OAAO;QACL,GAAIA,YAAYK,UAAU,KAAKP,YAAY,CAAC,IAAI;YAACO,YAAYL,YAAYK,UAAU;QAAA,CAAC;QACpFC,SAASC,OAAOP,YAAYM,OAAO;QACnC,GAAIN,YAAYQ,OAAO,KAAKV,YAAY,CAAC,IAAI;YAACU,SAASD,OAAOP,YAAYQ,OAAO;QAAC,CAAC;QACnFC,YAAYT,YAAYU,WAAW,IAAI;IACzC;AACF;AAEA,SAASN,oBAAoBR,MAQ5B;IACC,MAAMe,UAAUf,OAAOgB,4BAA4B;IACnD,IAAID,YAAYb,WAAW;IAE3B,MAAMe,iBAAiBjB,OAAOM,UAAU,CAACG,UAAU,IAAIM,QAAQG,qBAAqB;IACpF,IAAID,mBAAmBf,WAAW;QAChCF,OAAOmB,MAAM,CAACC,IAAI,CAChBtB,MAAM;YACJuB,MAAM;YACNC,SAAS;YACTC,MAAMC,gBAAgBxB;YACtByB,SAAS;gBAACpB,kBAAkBL,OAAOK,gBAAgB;YAAA;QACrD;QAEF;IACF;IAEA,MAAMI,aAAaM,QAAQW,2BAA2B,CAACC,GAAG,CAACV;IAC3D,IAAIR,eAAeP,WAAW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KAAa;AAChC;AAEA,SAASC,gBAAgBxB,MAIxB;IACC,OAAO;QACL;QACAA,OAAOyD,UAAU;QACjB;QACAzD,OAAO0D,SAAS;QAChB;QACA1D,OAAOK,gBAAgB;KACxB;AACH;AAEA,SAASM,OAAOgD,MAAyB;IACvC,OAAO;WAAI,IAAIC,IAAID;KAAQ;AAC7B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-agent-integrations.ts"],"sourcesContent":["import type {WorkflowDocumentStepIntegration} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {WorkflowModelStepIntegration} from '../entities/workflow-model.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {issue} from './validation-issue.js';\n\ninterface AgentToolSelector {\n readonly token: string;\n readonly kind: 'family' | 'family_wildcard' | 'method' | 'standalone';\n readonly sensitivity: 'read' | 'write';\n readonly sensitive: boolean;\n}\n\nexport function normalizeAgentIntegrations(params: {\n integrations: readonly WorkflowDocumentStepIntegration[] | undefined;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): readonly WorkflowModelStepIntegration[] | undefined {\n if (params.integrations === undefined) return undefined;\n\n return params.integrations.map((integration, integrationIndex) => {\n const normalized = normalizeIntegration(integration);\n validateIntegration({...params, integration, normalized, integrationIndex});\n return normalized;\n });\n}\n\nfunction normalizeIntegration(\n integration: WorkflowDocumentStepIntegration,\n): WorkflowModelStepIntegration {\n return {\n ...(integration.connection === undefined ? {} : {connection: integration.connection}),\n include: dedupe(integration.include),\n ...(integration.exclude === undefined ? {} : {exclude: dedupe(integration.exclude)}),\n allowWrite: integration.allow_write ?? false,\n };\n}\n\nfunction validateIntegration(params: {\n integration: WorkflowDocumentStepIntegration;\n normalized: WorkflowModelStepIntegration;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): void {\n const context = params.integrationValidationContext;\n if (context === undefined) return;\n\n const connectionSlug = params.normalized.connection ?? context.defaultConnectionSlug;\n if (connectionSlug === undefined) {\n params.issues.push(\n issue({\n code: 'missing-connection-for-integration',\n message: 'Agent step integration requires a connection or a default source connection.',\n path: integrationPath(params),\n details: {integrationIndex: params.integrationIndex},\n }),\n );\n return;\n }\n\n const connection = context.workspaceConnectionSnapshot.get(connectionSlug);\n if (connection === undefined) {\n params.issues.push(\n issue({\n code: 'integration-connection-not-found',\n message: `Integration connection \"${connectionSlug}\" was not found in the workspace.`,\n path: integrationConnectionPath(params),\n details: {\n connection: connectionSlug,\n integrationIndex: params.integrationIndex,\n },\n }),\n );\n return;\n }\n\n const catalog = context.agentToolSelectionCatalogs.get(connection.provider);\n if (catalog === undefined || !connection.capabilities.includes('agent_tools')) {\n params.issues.push(\n issue({\n code: 'integration-connection-not-capable',\n message: `Integration connection \"${connectionSlug}\" does not support agent tools.`,\n path: integrationConnectionPath(params),\n details: {\n connection: connectionSlug,\n provider: connection.provider,\n capabilities: connection.capabilities,\n integrationIndex: params.integrationIndex,\n },\n }),\n );\n return;\n }\n\n const selectorsByToken = new Map(catalog.selectors.map((selector) => [selector.token, selector]));\n validateSelection({\n ...params,\n field: 'include',\n tokens: params.integration.include,\n selectorsByToken,\n });\n if (params.integration.exclude !== undefined) {\n validateSelection({\n ...params,\n field: 'exclude',\n tokens: params.integration.exclude,\n selectorsByToken,\n });\n }\n validateWriteSelection({...params, selectorsByToken});\n}\n\nfunction validateSelection(params: {\n field: 'include' | 'exclude';\n tokens: readonly string[];\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): void {\n params.tokens.forEach((token, tokenIndex) => {\n if (params.selectorsByToken.has(token)) return;\n\n const code = classifyUnknownSelection(token, params.selectorsByToken);\n params.issues.push(\n issue({\n code,\n message:\n code === 'unknown-integration-method'\n ? `Unknown integration tool method: ${token}.`\n : `Unknown integration tool: ${token}.`,\n path: [...integrationPath(params), params.field, tokenIndex],\n details: {token},\n }),\n );\n });\n}\n\nfunction validateWriteSelection(params: {\n integration: WorkflowDocumentStepIntegration;\n normalized: WorkflowModelStepIntegration;\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>;\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): void {\n if (params.normalized.allowWrite) return;\n\n const writeTokens = dedupe(\n params.integration.include.filter(\n (token) => params.selectorsByToken.get(token)?.sensitivity === 'write',\n ),\n );\n if (writeTokens.length === 0) return;\n\n params.issues.push(\n issue({\n code: 'integration-write-not-allowed',\n message: `Integration selection includes write-capable tools but allow_write is not true: ${writeTokens.join(', ')}.`,\n path: [...integrationPath(params), 'include'],\n details: {tokens: writeTokens},\n }),\n );\n}\n\nfunction classifyUnknownSelection(\n token: string,\n selectorsByToken: ReadonlyMap<string, AgentToolSelector>,\n): 'unknown-integration-method' | 'unknown-integration-tool' {\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return 'unknown-integration-tool';\n\n const family = token.slice(0, dotIndex);\n return selectorsByToken.get(family)?.kind === 'family'\n ? 'unknown-integration-method'\n : 'unknown-integration-tool';\n}\n\nfunction integrationConnectionPath(params: {\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n integration: WorkflowDocumentStepIntegration;\n}): readonly (string | number)[] {\n const path = integrationPath(params);\n if (params.integration.connection === undefined) return path;\n return [...path, 'connection'];\n}\n\nfunction integrationPath(params: {\n sourceName: string;\n stepIndex: number;\n integrationIndex: number;\n}): readonly (string | number)[] {\n return [\n 'jobs',\n params.sourceName,\n 'steps',\n params.stepIndex,\n 'integrations',\n params.integrationIndex,\n ];\n}\n\nfunction dedupe(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n"],"names":["issue","normalizeAgentIntegrations","params","integrations","undefined","map","integration","integrationIndex","normalized","normalizeIntegration","validateIntegration","connection","include","dedupe","exclude","allowWrite","allow_write","context","integrationValidationContext","connectionSlug","defaultConnectionSlug","issues","push","code","message","path","integrationPath","details","workspaceConnectionSnapshot","get","integrationConnectionPath","catalog","agentToolSelectionCatalogs","provider","capabilities","includes","selectorsByToken","Map","selectors","selector","token","validateSelection","field","tokens","validateWriteSelection","forEach","tokenIndex","has","classifyUnknownSelection","writeTokens","filter","sensitivity","length","join","dotIndex","indexOf","family","slice","kind","sourceName","stepIndex","values","Set"],"mappings":"AAIA,SAAQA,KAAK,QAAO,wBAAwB;AAS5C,OAAO,SAASC,2BAA2BC,MAM1C;IACC,IAAIA,OAAOC,YAAY,KAAKC,WAAW,OAAOA;IAE9C,OAAOF,OAAOC,YAAY,CAACE,GAAG,CAAC,CAACC,aAAaC;QAC3C,MAAMC,aAAaC,qBAAqBH;QACxCI,oBAAoB;YAAC,GAAGR,MAAM;YAAEI;YAAaE;YAAYD;QAAgB;QACzE,OAAOC;IACT;AACF;AAEA,SAASC,qBACPH,WAA4C;IAE5C,OAAO;QACL,GAAIA,YAAYK,UAAU,KAAKP,YAAY,CAAC,IAAI;YAACO,YAAYL,YAAYK,UAAU;QAAA,CAAC;QACpFC,SAASC,OAAOP,YAAYM,OAAO;QACnC,GAAIN,YAAYQ,OAAO,KAAKV,YAAY,CAAC,IAAI;YAACU,SAASD,OAAOP,YAAYQ,OAAO;QAAC,CAAC;QACnFC,YAAYT,YAAYU,WAAW,IAAI;IACzC;AACF;AAEA,SAASN,oBAAoBR,MAQ5B;IACC,MAAMe,UAAUf,OAAOgB,4BAA4B;IACnD,IAAID,YAAYb,WAAW;IAE3B,MAAMe,iBAAiBjB,OAAOM,UAAU,CAACG,UAAU,IAAIM,QAAQG,qBAAqB;IACpF,IAAID,mBAAmBf,WAAW;QAChCF,OAAOmB,MAAM,CAACC,IAAI,CAChBtB,MAAM;YACJuB,MAAM;YACNC,SAAS;YACTC,MAAMC,gBAAgBxB;YACtByB,SAAS;gBAACpB,kB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,MAKlC;IACC,MAAMuB,OAAOC,gBAAgBxB;IAC7B,IAAIA,OAAOI,WAAW,CAACK,UAAU,KAAKP,WAAW,OAAOqB;IACxD,OAAO;WAAIA;QAAM;KAAa;AAChC;AAEA,SAASC,gBAAgBxB,MAIxB;IACC,OAAO;QACL;QACAA,OAAOyD,UAAU;QACjB;QACAzD,OAAO0D,SAAS;QAChB;QACA1D,OAAOK,gBAAgB;KACxB;AACH;AAEA,SAASM,OAAOgD,MAAyB;IACvC,OAAO;WAAI,IAAIC,IAAID;KAAQ;AAC7B"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<DefinitionsEventMap & ProjectsEventMap>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () => createDefinitionSyncActivities(sourceControl, agent, integrations),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AAEtC,SACEC,oBAAoB,EACpBC,8BAA8B,QAEzB,4BAA4B;AAEnC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,8BAA8B,QAAO,wBAAwB;AACrE,SAAQC,EAAE,EAAEC,iBAAiB,EAAEC,cAAc,QAAO,eAAe;AACnE,SAAQC,sBAAsB,QAAO,yBAAyB;AAC9D,SAAQC,wCAAwC,QAAO,gCAAgC;AACvF,SACEC,oBAAoB,EACpBC,6BAA6B,QACxB,qCAAqC;AAC5C,SAAQC,8BAA8B,EAAEC,sBAAsB,QAAO,qBAAqB;AAW1F,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,sBAAsB,EACtBC,yBAAyB,QACpB,iBAAiB;AACxB,SAAQZ,EAAE,EAAEC,iBAAiB,EAAEY,iBAAiB,EAAEX,cAAc,QAAO,eAAe;AAEtF,MAAMY,cAAcvB,QAAQD,QAAQE,cAAc,YAAYuB,GAAG,IAAI;AACrE,MAAMC,gBAAgBzB,QAAQuB,aAAa;AAE3C,MAAMG,aAAapB;AAQnB,OAAO,SAASqB,wBAAwB,EACtCC,QAAQ,EACRC,KAAK,EACLC,YAAY,EACmB;IAC/B,MAAMC,gBAAgBvB,+BAA+BsB;IAErD,OAAO;QACLE,MAAM;QACNC,UAAU;YAACxB;YAAIE;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<DefinitionsEventMap & ProjectsEventMap>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath, databaseNamespace: 'definitions'},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () => createDefinitionSyncActivities(sourceControl, agent, integrations),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","databaseNamespace","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,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