@shipfox/api-definitions 11.0.0 → 12.0.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/.turbo/turbo-build.log +13 -12
- package/CHANGELOG.md +81 -0
- package/dist/core/entities/index.d.ts +1 -0
- package/dist/core/entities/index.d.ts.map +1 -1
- package/dist/core/entities/index.js +1 -0
- package/dist/core/entities/index.js.map +1 -1
- package/dist/core/entities/sync-state.d.ts +4 -0
- package/dist/core/entities/sync-state.d.ts.map +1 -1
- package/dist/core/entities/sync-state.js +10 -0
- package/dist/core/entities/sync-state.js.map +1 -1
- package/dist/core/entities/validation-warning.d.ts +6 -0
- package/dist/core/entities/validation-warning.d.ts.map +1 -0
- package/dist/core/entities/validation-warning.js +3 -0
- package/dist/core/entities/validation-warning.js.map +1 -0
- package/dist/core/parse-definition.d.ts +9 -7
- package/dist/core/parse-definition.d.ts.map +1 -1
- package/dist/core/parse-definition.js +14 -2
- package/dist/core/parse-definition.js.map +1 -1
- package/dist/core/sync-definitions.d.ts +2 -0
- package/dist/core/sync-definitions.d.ts.map +1 -1
- package/dist/core/sync-definitions.js +6 -5
- package/dist/core/sync-definitions.js.map +1 -1
- package/dist/core/validate-definition.d.ts +9 -5
- package/dist/core/validate-definition.d.ts.map +1 -1
- package/dist/core/validate-definition.js +23 -2
- package/dist/core/validate-definition.js.map +1 -1
- package/dist/core/workflow-model/index.d.ts +1 -1
- package/dist/core/workflow-model/index.d.ts.map +1 -1
- package/dist/core/workflow-model/index.js.map +1 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts +3 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts.map +1 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.js.map +1 -1
- package/dist/core/workflow-model/normalize-if-condition.d.ts +0 -1
- package/dist/core/workflow-model/normalize-if-condition.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-if-condition.js +0 -1
- package/dist/core/workflow-model/normalize-if-condition.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.d.ts +15 -3
- package/dist/core/workflow-model/normalize-job-checkout.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.js +83 -4
- package/dist/core/workflow-model/normalize-job-checkout.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-listening.js +0 -1
- package/dist/core/workflow-model/normalize-job-listening.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.js +0 -1
- package/dist/core/workflow-model/normalize-job-success.js.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.js +310 -45
- package/dist/core/workflow-model/normalize-jobs.js.map +1 -1
- package/dist/core/workflow-model/normalize-step-gate.js +0 -1
- package/dist/core/workflow-model/normalize-step-gate.js.map +1 -1
- package/dist/core/workflow-model/normalize-triggers.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-triggers.js +0 -1
- package/dist/core/workflow-model/normalize-triggers.js.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.d.ts +3 -0
- package/dist/core/workflow-model/normalize-workflow-document.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.js +34 -4
- package/dist/core/workflow-model/normalize-workflow-document.js.map +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.d.ts +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.d.ts.map +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.js +27 -57
- package/dist/core/workflow-model/parse-interpolation-field.js.map +1 -1
- package/dist/core/workflow-model/validate-literal-name.d.ts +12 -0
- package/dist/core/workflow-model/validate-literal-name.d.ts.map +1 -0
- package/dist/core/workflow-model/validate-literal-name.js +36 -0
- package/dist/core/workflow-model/validate-literal-name.js.map +1 -0
- package/dist/core/workflow-model/validate-predicate-expression.d.ts +1 -2
- package/dist/core/workflow-model/validate-predicate-expression.d.ts.map +1 -1
- package/dist/core/workflow-model/validate-predicate-expression.js +31 -90
- package/dist/core/workflow-model/validate-predicate-expression.js.map +1 -1
- package/dist/core/workflow-model/validation-issue.d.ts +2 -1
- package/dist/core/workflow-model/validation-issue.d.ts.map +1 -1
- package/dist/core/workflow-model/validation-issue.js +8 -2
- package/dist/core/workflow-model/validation-issue.js.map +1 -1
- package/dist/core/workflow-model/workflow-field-label.d.ts.map +1 -1
- package/dist/core/workflow-model/workflow-field-label.js +16 -2
- package/dist/core/workflow-model/workflow-field-label.js.map +1 -1
- package/dist/db/db.d.ts +38 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/schema/sync-states.d.ts +19 -0
- package/dist/db/schema/sync-states.d.ts.map +1 -1
- package/dist/db/schema/sync-states.js +3 -1
- package/dist/db/schema/sync-states.js.map +1 -1
- package/dist/db/sync-states.d.ts +2 -1
- package/dist/db/sync-states.d.ts.map +1 -1
- package/dist/db/sync-states.js +4 -0
- package/dist/db/sync-states.js.map +1 -1
- package/dist/presentation/dto/definition.d.ts.map +1 -1
- package/dist/presentation/dto/definition.js +2 -1
- package/dist/presentation/dto/definition.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/presentation/routes/validate-definition.d.ts.map +1 -1
- package/dist/presentation/routes/validate-definition.js +5 -3
- package/dist/presentation/routes/validate-definition.js.map +1 -1
- package/dist/temporal/activities/sync-activities.d.ts +6 -2
- package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
- package/dist/temporal/activities/sync-activities.js +8 -1
- package/dist/temporal/activities/sync-activities.js.map +1 -1
- package/dist/temporal/workflows/definition-sync.js +4 -1
- package/dist/temporal/workflows/definition-sync.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +9029 -3
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0002_lumpy_ben_parker.sql +1 -0
- package/drizzle/meta/0002_snapshot.json +534 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +14 -14
- package/src/core/entities/index.ts +1 -0
- package/src/core/entities/sync-state.ts +23 -0
- package/src/core/entities/validation-warning.ts +5 -0
- package/src/core/parse-definition-warnings.test.ts +33 -0
- package/src/core/parse-definition.test.ts +7 -1
- package/src/core/parse-definition.ts +28 -10
- package/src/core/sync-definitions.test.ts +39 -0
- package/src/core/sync-definitions.ts +14 -4
- package/src/core/validate-definition.test.ts +128 -0
- package/src/core/validate-definition.ts +39 -8
- package/src/core/workflow-model/README.md +2 -2
- package/src/core/workflow-model/index.ts +1 -0
- package/src/core/workflow-model/invalid-workflow-model-error.ts +8 -2
- package/src/core/workflow-model/normalize-if-condition.ts +0 -2
- package/src/core/workflow-model/normalize-job-checkout.ts +105 -8
- package/src/core/workflow-model/normalize-job-listening.ts +0 -1
- package/src/core/workflow-model/normalize-job-success.ts +0 -1
- package/src/core/workflow-model/normalize-jobs.ts +330 -49
- package/src/core/workflow-model/normalize-step-gate.ts +0 -1
- package/src/core/workflow-model/normalize-triggers.ts +0 -1
- package/src/core/workflow-model/normalize-workflow-document.test.ts +732 -185
- package/src/core/workflow-model/normalize-workflow-document.ts +29 -4
- package/src/core/workflow-model/parse-interpolation-field.ts +50 -79
- package/src/core/workflow-model/validate-literal-name.ts +64 -0
- package/src/core/workflow-model/validate-predicate-expression.test.ts +153 -15
- package/src/core/workflow-model/validate-predicate-expression.ts +52 -120
- package/src/core/workflow-model/validation-issue.ts +4 -0
- package/src/core/workflow-model/workflow-field-label.ts +16 -2
- package/src/core/workflow-yaml/README.md +2 -2
- package/src/db/schema/sync-states.ts +4 -1
- package/src/db/sync-states.test.ts +57 -0
- package/src/db/sync-states.ts +6 -0
- package/src/presentation/dto/definition.ts +1 -0
- package/src/presentation/routes/list-definitions.test.ts +1 -0
- package/src/presentation/routes/validate-definition.test.ts +1 -0
- package/src/presentation/routes/validate-definition.ts +7 -1
- package/src/temporal/activities/sync-activities.test.ts +16 -0
- package/src/temporal/activities/sync-activities.ts +18 -3
- package/src/temporal/workflows/definition-sync.ts +1 -1
- package/test/agent-validation-catalog.ts +17 -0
- package/test/fixtures/valid-listening-job.yml +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"sourcesContent":["import {\n type AvailabilitySite,\n analyzeContextRootKeyAccess,\n availabilitySites,\n createWorkflowExpression,\n type ExpressionTypeEnvironment,\n extractExactContextRoots,\n getWorkflowContextDefinition,\n getWorkflowContextTypeEnvironment,\n InvalidWorkflowExpressionError,\n predicateSourceIsBooleanShaped,\n resolveContextRootAvailability,\n resolveContextRootHost,\n routeExpression,\n validateServerEvaluable,\n type WorkflowContextName,\n type WorkflowExpression,\n type WorkflowPredicateField,\n workflowContextNames,\n} from '@shipfox/expression';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\nimport {workflowFieldLabel} from './workflow-field-label.js';\n\nexport function validatePredicateExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowExpression | undefined {\n const syntaxExpression = createSyntaxExpression(params);\n if (syntaxExpression === undefined) return undefined;\n\n const contextRoots = extractExactContextRoots(syntaxExpression.source);\n const knownRoots = contextRoots.filter((root) => resolveContextRootHost(root) !== undefined);\n const unknownRoots = contextRoots.filter((root) => resolveContextRootHost(root) === undefined);\n\n if (unknownRoots.length > 0) {\n params.issues.push(invalidPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const serverEvaluability = validateServerEvaluable(syntaxExpression);\n if (!serverEvaluability.ok) {\n params.issues.push(\n ...serverEvaluability.violations.map((violation) =>\n runnerContextInServerPredicateIssue({\n ...params,\n contextRoots,\n runnerRoots: violation.runnerRoots,\n }),\n ),\n );\n return undefined;\n }\n\n const varsRoots = knownRoots.filter((root) => root === 'vars');\n if (varsRoots.length > 0) {\n params.issues.push(varsContextInServerPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const unavailableRoots = knownRoots.filter((root) => !isRootAvailableAt(root, params.site));\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailablePredicateContextIssue({...params, contextRoots, unavailableRoots}),\n );\n return undefined;\n }\n\n const route = routeExpression(syntaxExpression);\n if (route.fillTarget !== 'runner-fill' && !isSiteAtOrAfter(params.site, route.fillTarget)) {\n const unavailableRoots = unavailableRouteReferences(syntaxExpression);\n params.issues.push(\n unavailableRoots.length > 0\n ? unavailablePredicateContextIssue({\n ...params,\n contextRoots,\n unavailableRoots,\n })\n : routeUnavailablePredicateContextIssue({\n ...params,\n contextRoots,\n fillTarget: route.fillTarget,\n }),\n );\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: syntaxExpression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (params.typeOverlay === undefined && knownRoots.some((root) => hasSyntaxOnlyCheckMode(root))) {\n if (\n isWorkflowFilterPredicateField(params.field) &&\n !predicateSourceIsBooleanShaped(syntaxExpression.source)\n ) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason: 'Predicate source must be boolean-shaped.',\n }),\n );\n return undefined;\n }\n\n return syntaxExpression;\n }\n\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(knownRoots, params.typeOverlay),\n expectedResultType: 'bool',\n },\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction createSyntaxExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n}): WorkflowExpression | undefined {\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {mode: 'syntax'},\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots: [],\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction invalidPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n contextRoots: readonly string[];\n reason?: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: params.invalidCode,\n message: params.invalidMessage,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n reason: params.reason ?? 'Expression source did not parse or type-check.',\n },\n });\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction runnerContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n runnerRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(\n params.runnerRoots,\n )} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n runnerRoots: params.runnerRoots,\n site: params.site,\n },\n });\n}\n\nfunction varsContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'vars-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference vars because predicate evaluation does not include workflow variables.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n rejectedRoots: ['vars'],\n site: params.site,\n },\n });\n}\n\nfunction unavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n unavailableRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not available at ${describeAvailabilitySite(params.site)}. ${params.unavailableRoots\n .map(unavailableRootAvailabilityMessage)\n .join(' ')}`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n site: params.site,\n },\n });\n}\n\nfunction routeUnavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n fillTarget: AvailabilitySite;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} requires context filled at ${describeAvailabilitySite(\n params.fillTarget,\n )}, but it is evaluated at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n fillTarget: params.fillTarget,\n site: params.site,\n },\n });\n}\n\nfunction isRootAvailableAt(root: string, site: AvailabilitySite): boolean {\n const availability = resolveContextRootAvailability(root);\n if (availability === undefined) return false;\n\n return availabilitySites.indexOf(availability) <= availabilitySites.indexOf(site);\n}\n\nfunction unavailableRootAvailabilityMessage(root: string): string {\n if (root === 'execution.failed') {\n return '\"execution.failed\" becomes available at step dispatch.';\n }\n\n const availability = resolveContextRootAvailability(root);\n if (availability === undefined) return `\"${root}\" is not available at any server site.`;\n return `\"${root}\" becomes available at ${describeAvailabilitySite(availability)}.`;\n}\n\nfunction unavailableRouteReferences(expression: WorkflowExpression): readonly string[] {\n const access = analyzeContextRootKeyAccess(expression, ['execution']);\n return access.references.some((reference) => reference.key === 'failed')\n ? ['execution.failed']\n : [];\n}\n\nfunction hasSyntaxOnlyCheckMode(root: string): boolean {\n if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';\n return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n roots: readonly string[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (overlayType !== undefined) {\n typeEnvironment[root] = overlayType;\n continue;\n }\n\n if (!isWorkflowContextName(root)) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowContextTypeEnvironment(root);\n if (contextTypeEnvironment === undefined) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n Object.assign(typeEnvironment, contextTypeEnvironment);\n }\n\n return typeEnvironment;\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction isWorkflowFilterPredicateField(field: WorkflowPredicateField): boolean {\n return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';\n}\n\nfunction fieldLabel(field: WorkflowPredicateField): string {\n return workflowFieldLabel(field);\n}\n\nfunction contextNoun(roots: readonly string[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly string[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction isSiteAtOrAfter(site: AvailabilitySite, fillTarget: AvailabilitySite): boolean {\n return availabilitySites.indexOf(site) >= availabilitySites.indexOf(fillTarget);\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n"],"names":["analyzeContextRootKeyAccess","availabilitySites","createWorkflowExpression","extractExactContextRoots","getWorkflowContextDefinition","getWorkflowContextTypeEnvironment","InvalidWorkflowExpressionError","predicateSourceIsBooleanShaped","resolveContextRootAvailability","resolveContextRootHost","routeExpression","validateServerEvaluable","workflowContextNames","validateDirectJobReferences","issue","workflowFieldLabel","validatePredicateExpression","params","syntaxExpression","createSyntaxExpression","undefined","contextRoots","source","knownRoots","filter","root","unknownRoots","length","issues","push","invalidPredicateIssue","serverEvaluability","ok","violations","map","violation","runnerContextInServerPredicateIssue","runnerRoots","varsRoots","varsContextInServerPredicateIssue","unavailableRoots","isRootAvailableAt","site","unavailablePredicateContextIssue","route","fillTarget","isSiteAtOrAfter","unavailableRouteReferences","routeUnavailablePredicateContextIssue","invalidJobReferenceIssue","allowedJobReferences","expression","field","path","typeOverlay","some","hasSyntaxOnlyCheckMode","isWorkflowFilterPredicateField","reason","check","mode","typeEnvironment","mergeTypeEnvironments","expectedResultType","error","code","invalidCode","message","invalidMessage","details","availabilitySiteLabels","ingest","fieldLabel","formatList","describeAvailabilitySite","rejectedRoots","contextNoun","availabilityVerb","unavailableRootAvailabilityMessage","join","availability","indexOf","access","references","reference","key","isWorkflowContextName","checkMode","roots","overlayType","kind","contextTypeEnvironment","Object","assign","includes","values","value"],"mappings":"AAAA,SAEEA,2BAA2B,EAC3BC,iBAAiB,EACjBC,wBAAwB,EAExBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,iCAAiC,EACjCC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,eAAe,EACfC,uBAAuB,EAIvBC,oBAAoB,QACf,sBAAsB;AAM7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAC5C,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,OAAO,SAASC,4BAA4BC,MAU3C;IACC,MAAMC,mBAAmBC,uBAAuBF;IAChD,IAAIC,qBAAqBE,WAAW,OAAOA;IAE3C,MAAMC,eAAelB,yBAAyBe,iBAAiBI,MAAM;IACrE,MAAMC,aAAaF,aAAaG,MAAM,CAAC,CAACC,OAAShB,uBAAuBgB,UAAUL;IAClF,MAAMM,eAAeL,aAAaG,MAAM,CAAC,CAACC,OAAShB,uBAAuBgB,UAAUL;IAEpF,IAAIM,aAAaC,MAAM,GAAG,GAAG;QAC3BV,OAAOW,MAAM,CAACC,IAAI,CAACC,sBAAsB;YAAC,GAAGb,MAAM;YAAEI;QAAY;QACjE,OAAOD;IACT;IAEA,MAAMW,qBAAqBpB,wBAAwBO;IACnD,IAAI,CAACa,mBAAmBC,EAAE,EAAE;QAC1Bf,OAAOW,MAAM,CAACC,IAAI,IACbE,mBAAmBE,UAAU,CAACC,GAAG,CAAC,CAACC,YACpCC,oCAAoC;gBAClC,GAAGnB,MAAM;gBACTI;gBACAgB,aAAaF,UAAUE,WAAW;YACpC;QAGJ,OAAOjB;IACT;IA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;AACrC;AAEA,SAAS+C,yBAAyBhC,IAAsB;IACtD,OAAO4B,sBAAsB,CAAC5B,KAAK;AACrC;AAEA,SAASI,gBAAgBJ,IAAsB,EAAEG,UAA4B;IAC3E,OAAO5C,kBAAkBgF,OAAO,CAACvC,SAASzC,kBAAkBgF,OAAO,CAACpC;AACtE;AAEA,SAAS4B,WAAWsB,MAAyB;IAC3C,OAAOA,OAAO7D,GAAG,CAAC,CAAC8D,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEjB,IAAI,CAAC;AAClD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"sourcesContent":["import {\n type AvailabilitySite,\n createWorkflowExpression,\n type ExpressionType,\n type ExpressionTypeEnvironment,\n extractExactContextRoots,\n getWorkflowContextDefinition,\n getWorkflowPredicateContextRoots,\n getWorkflowPredicateFieldMinimumFillTarget,\n getWorkflowPredicateFieldTypeEnvironment,\n InvalidWorkflowExpressionError,\n predicateSourceIsBooleanShaped,\n resolveContextRootHost,\n validateServerEvaluable,\n type WorkflowContextName,\n type WorkflowExpression,\n type WorkflowPredicateField,\n workflowContextNames,\n} from '@shipfox/expression';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\nimport {workflowFieldLabel} from './workflow-field-label.js';\n\nexport function validatePredicateExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowExpression | undefined {\n const site = getWorkflowPredicateFieldMinimumFillTarget(params.field);\n const syntaxExpression = createSyntaxExpression(params);\n if (syntaxExpression === undefined) return undefined;\n\n const contextRoots = extractExactContextRoots(syntaxExpression.source);\n const knownRoots = contextRoots.filter((root) => resolveContextRootHost(root) !== undefined);\n const unknownRoots = contextRoots.filter((root) => resolveContextRootHost(root) === undefined);\n\n if (unknownRoots.length > 0) {\n params.issues.push(invalidPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const serverEvaluability = validateServerEvaluable(syntaxExpression);\n if (!serverEvaluability.ok) {\n params.issues.push(\n ...serverEvaluability.violations.map((violation) =>\n runnerContextInServerPredicateIssue({\n ...params,\n site,\n contextRoots,\n runnerRoots: violation.runnerRoots,\n }),\n ),\n );\n return undefined;\n }\n\n const predicateContextRoots = getWorkflowPredicateContextRoots(params.field);\n const unavailableRoots = knownRoots.filter(\n (root) => !predicateContextRoots.includes(root as (typeof predicateContextRoots)[number]),\n );\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailablePredicateContextIssue({\n ...params,\n site,\n contextRoots,\n unavailableRoots,\n }),\n );\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: syntaxExpression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (\n params.typeOverlay === undefined &&\n knownRoots.length > 0 &&\n knownRoots.every((root) => hasSyntaxOnlyCheckMode(root))\n ) {\n if (\n isWorkflowFilterPredicateField(params.field) &&\n !predicateSourceIsBooleanShaped(syntaxExpression.source)\n ) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason: 'Predicate source must be boolean-shaped.',\n }),\n );\n return undefined;\n }\n\n return syntaxExpression;\n }\n\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(params.field, knownRoots, params.typeOverlay),\n expectedResultType: 'bool',\n },\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction createSyntaxExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n}): WorkflowExpression | undefined {\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {mode: 'syntax'},\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots: [],\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction invalidPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n contextRoots: readonly string[];\n reason?: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: params.invalidCode,\n message: params.invalidMessage,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n reason: params.reason ?? 'Expression source did not parse or type-check.',\n },\n });\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction runnerContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n runnerRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(\n params.runnerRoots,\n )} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n runnerRoots: params.runnerRoots,\n site: params.site,\n },\n });\n}\n\nfunction unavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n unavailableRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not supplied when ${fieldLabel(params.field)} is evaluated at ${describeAvailabilitySite(\n params.site,\n )}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n site: params.site,\n },\n });\n}\n\nfunction hasSyntaxOnlyCheckMode(root: string): boolean {\n if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';\n return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n field: WorkflowPredicateField,\n roots: readonly string[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (!isWorkflowContextName(root)) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowPredicateFieldTypeEnvironment(field, root);\n if (contextTypeEnvironment === undefined) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextType = contextTypeEnvironment[root];\n if (contextType === undefined) continue;\n typeEnvironment[root] =\n overlayType === undefined ? contextType : overlayKnownFields(contextType, overlayType);\n }\n\n return typeEnvironment;\n}\n\nfunction overlayKnownFields(base: ExpressionType, overlay: ExpressionType): ExpressionType {\n if (typeof base === 'string' || typeof overlay === 'string') return overlay;\n if (base.kind !== 'object' || overlay.kind !== 'object') return overlay;\n\n // Preserve output specialization without reintroducing properties absent from this field's\n // runtime shape.\n return {\n kind: 'object',\n fields: Object.fromEntries(\n Object.entries(base.fields).map(([key, fieldType]) => [\n key,\n overlay.fields[key] ?? fieldType,\n ]),\n ),\n };\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction isWorkflowFilterPredicateField(field: WorkflowPredicateField): boolean {\n return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';\n}\n\nfunction fieldLabel(field: WorkflowPredicateField): string {\n return workflowFieldLabel(field);\n}\n\nfunction contextNoun(roots: readonly string[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly string[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n"],"names":["createWorkflowExpression","extractExactContextRoots","getWorkflowContextDefinition","getWorkflowPredicateContextRoots","getWorkflowPredicateFieldMinimumFillTarget","getWorkflowPredicateFieldTypeEnvironment","InvalidWorkflowExpressionError","predicateSourceIsBooleanShaped","resolveContextRootHost","validateServerEvaluable","workflowContextNames","validateDirectJobReferences","issue","workflowFieldLabel","validatePredicateExpression","params","site","field","syntaxExpression","createSyntaxExpression","undefined","contextRoots","source","knownRoots","filter","root","unknownRoots","length","issues","push","invalidPredicateIssue","serverEvaluability","ok","violations","map","violation","runnerContextInServerPredicateIssue","runnerRoots","predicateContextRoots","unavailableRoots","includes","unavailablePredicateContextIssue","invalidJobReferenceIssue","allowedJobReferences","expression","path","typeOverlay","every","hasSyntaxOnlyCheckMode","isWorkflowFilterPredicateField","reason","check","mode","typeEnvironment","mergeTypeEnvironments","expectedResultType","error","code","invalidCode","message","invalidMessage","details","availabilitySiteLabels","ingest","fieldLabel","formatList","describeAvailabilitySite","contextNoun","availabilityVerb","isWorkflowContextName","checkMode","roots","overlayType","kind","contextTypeEnvironment","contextType","overlayKnownFields","base","overlay","fields","Object","fromEntries","entries","key","fieldType","values","value","join"],"mappings":"AAAA,SAEEA,wBAAwB,EAGxBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,gCAAgC,EAChCC,0CAA0C,EAC1CC,wCAAwC,EACxCC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,uBAAuB,EAIvBC,oBAAoB,QACf,sBAAsB;AAM7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAC5C,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,OAAO,SAASC,4BAA4BC,MAS3C;IACC,MAAMC,OAAOZ,2CAA2CW,OAAOE,KAAK;IACpE,MAAMC,mBAAmBC,uBAAuBJ;IAChD,IAAIG,qBAAqBE,WAAW,OAAOA;IAE3C,MAAMC,eAAepB,yBAAyBiB,iBAAiBI,MAAM;IACrE,MAAMC,aAAaF,aAAaG,MAAM,CAAC,CAACC,OAASjB,uBAAuBiB,UAAUL;IAClF,MAAMM,eAAeL,aAAaG,MAAM,CAAC,CAACC,OAASjB,uBAAuBiB,UAAUL;IAEpF,IAAIM,aAAaC,MAAM,GAAG,GAAG;QAC3BZ,OAAOa,MAAM,CAACC,IAAI,CAACC,sBAAsB;YAAC,GAAGf,MAAM;YAAEM;QAAY;QACjE,OAAOD;IACT;IAEA,MAAMW,qBAAqBtB,wBAAwBS;IACnD,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AChD,OAAOA,MAAM5C,MAAM,KAAK,IAAI,OAAO;AACrC;AAEA,SAASuC,yBAAyBlD,IAAsB;IACtD,OAAO8C,sBAAsB,CAAC9C,KAAK;AACrC;AAEA,SAASiD,WAAWoB,MAAyB;IAC3C,OAAOA,OAAOnD,GAAG,CAAC,CAACoD,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEC,IAAI,CAAC;AAClD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment } from './invalid-workflow-model-error.js';
|
|
1
|
+
import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment, WorkflowModelValidationIssueSeverity } from './invalid-workflow-model-error.js';
|
|
2
2
|
export declare function issue(params: {
|
|
3
3
|
code: WorkflowModelValidationIssueCode;
|
|
4
4
|
message: string;
|
|
5
5
|
path: readonly WorkflowModelValidationIssuePathSegment[];
|
|
6
6
|
details?: Readonly<Record<string, unknown>>;
|
|
7
|
+
severity?: WorkflowModelValidationIssueSeverity;
|
|
7
8
|
}): WorkflowModelValidationIssue;
|
|
8
9
|
//# sourceMappingURL=validation-issue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-issue.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validation-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,
|
|
1
|
+
{"version":3,"file":"validation-issue.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validation-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,oCAAoC,EACrC,MAAM,mCAAmC,CAAC;AAE3C,wBAAgB,KAAK,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,oCAAoC,CAAC;CACjD,GAAG,4BAA4B,CAiB/B"}
|
|
@@ -3,14 +3,20 @@ export function issue(params) {
|
|
|
3
3
|
return {
|
|
4
4
|
code: params.code,
|
|
5
5
|
message: params.message,
|
|
6
|
-
path: params.path
|
|
6
|
+
path: params.path,
|
|
7
|
+
...params.severity === undefined ? {} : {
|
|
8
|
+
severity: params.severity
|
|
9
|
+
}
|
|
7
10
|
};
|
|
8
11
|
}
|
|
9
12
|
return {
|
|
10
13
|
code: params.code,
|
|
11
14
|
message: params.message,
|
|
12
15
|
path: params.path,
|
|
13
|
-
details: params.details
|
|
16
|
+
details: params.details,
|
|
17
|
+
...params.severity === undefined ? {} : {
|
|
18
|
+
severity: params.severity
|
|
19
|
+
}
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/workflow-model/validation-issue.ts"],"sourcesContent":["import type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\n\nexport function issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n}): WorkflowModelValidationIssue {\n if (params.details === undefined) {\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n };\n }\n\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n details: params.details,\n };\n}\n"],"names":["issue","params","details","undefined","code","message","path"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/validation-issue.ts"],"sourcesContent":["import type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n WorkflowModelValidationIssueSeverity,\n} from './invalid-workflow-model-error.js';\n\nexport function issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n severity?: WorkflowModelValidationIssueSeverity;\n}): WorkflowModelValidationIssue {\n if (params.details === undefined) {\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n ...(params.severity === undefined ? {} : {severity: params.severity}),\n };\n }\n\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n details: params.details,\n ...(params.severity === undefined ? {} : {severity: params.severity}),\n };\n}\n"],"names":["issue","params","details","undefined","code","message","path","severity"],"mappings":"AAOA,OAAO,SAASA,MAAMC,MAMrB;IACC,IAAIA,OAAOC,OAAO,KAAKC,WAAW;QAChC,OAAO;YACLC,MAAMH,OAAOG,IAAI;YACjBC,SAASJ,OAAOI,OAAO;YACvBC,MAAML,OAAOK,IAAI;YACjB,GAAIL,OAAOM,QAAQ,KAAKJ,YAAY,CAAC,IAAI;gBAACI,UAAUN,OAAOM,QAAQ;YAAA,CAAC;QACtE;IACF;IAEA,OAAO;QACLH,MAAMH,OAAOG,IAAI;QACjBC,SAASJ,OAAOI,OAAO;QACvBC,MAAML,OAAOK,IAAI;QACjBJ,SAASD,OAAOC,OAAO;QACvB,GAAID,OAAOM,QAAQ,KAAKJ,YAAY,CAAC,IAAI;YAACI,UAAUN,OAAOM,QAAQ;QAAA,CAAC;IACtE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-field-label.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,0BAA0B,EAAE,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAE5F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,0BAA0B,GAAG,sBAAsB,GACzD,MAAM,
|
|
1
|
+
{"version":3,"file":"workflow-field-label.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,0BAA0B,EAAE,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAE5F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,0BAA0B,GAAG,sBAAsB,GACzD,MAAM,CAuDR"}
|
|
@@ -16,10 +16,24 @@ export function workflowFieldLabel(field) {
|
|
|
16
16
|
return 'Job runner interpolation';
|
|
17
17
|
case 'job.outputs':
|
|
18
18
|
return 'Job outputs mapping';
|
|
19
|
-
case '
|
|
20
|
-
return '
|
|
19
|
+
case 'workflow.run_name':
|
|
20
|
+
return 'Workflow run name interpolation';
|
|
21
|
+
case 'job.execution_name':
|
|
22
|
+
return 'Job execution name interpolation';
|
|
21
23
|
case 'step.name':
|
|
22
24
|
return 'Step name interpolation';
|
|
25
|
+
case 'step.working_directory':
|
|
26
|
+
return 'Step working directory interpolation';
|
|
27
|
+
case 'checkout.project':
|
|
28
|
+
return 'Checkout project interpolation';
|
|
29
|
+
case 'checkout.connection':
|
|
30
|
+
return 'Checkout connection interpolation';
|
|
31
|
+
case 'checkout.repository':
|
|
32
|
+
return 'Checkout repository interpolation';
|
|
33
|
+
case 'checkout.ref':
|
|
34
|
+
return 'Checkout ref interpolation';
|
|
35
|
+
case 'checkout.path':
|
|
36
|
+
return 'Checkout path interpolation';
|
|
23
37
|
case 'step.success':
|
|
24
38
|
return 'Step gate success';
|
|
25
39
|
case 'step.feedback':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"sourcesContent":["import type {WorkflowInterpolationField, WorkflowPredicateField} from '@shipfox/expression';\n\nexport function workflowFieldLabel(\n field: WorkflowInterpolationField | WorkflowPredicateField,\n): string {\n switch (field) {\n case 'run':\n return 'Run command interpolation';\n case 'env.value':\n return 'Env value interpolation';\n case 'agent.prompt':\n return 'Agent prompt interpolation';\n case 'agent.model':\n return 'Agent model interpolation';\n case 'agent.provider':\n return 'Agent provider interpolation';\n case 'agent.thinking':\n return 'Agent thinking';\n case 'job.runner':\n return 'Job runner interpolation';\n case 'job.outputs':\n return 'Job outputs mapping';\n case '
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"sourcesContent":["import type {WorkflowInterpolationField, WorkflowPredicateField} from '@shipfox/expression';\n\nexport function workflowFieldLabel(\n field: WorkflowInterpolationField | WorkflowPredicateField,\n): string {\n switch (field) {\n case 'run':\n return 'Run command interpolation';\n case 'env.value':\n return 'Env value interpolation';\n case 'agent.prompt':\n return 'Agent prompt interpolation';\n case 'agent.model':\n return 'Agent model interpolation';\n case 'agent.provider':\n return 'Agent provider interpolation';\n case 'agent.thinking':\n return 'Agent thinking';\n case 'job.runner':\n return 'Job runner interpolation';\n case 'job.outputs':\n return 'Job outputs mapping';\n case 'workflow.run_name':\n return 'Workflow run name interpolation';\n case 'job.execution_name':\n return 'Job execution name interpolation';\n case 'step.name':\n return 'Step name interpolation';\n case 'step.working_directory':\n return 'Step working directory interpolation';\n case 'checkout.project':\n return 'Checkout project interpolation';\n case 'checkout.connection':\n return 'Checkout connection interpolation';\n case 'checkout.repository':\n return 'Checkout repository interpolation';\n case 'checkout.ref':\n return 'Checkout ref interpolation';\n case 'checkout.path':\n return 'Checkout path interpolation';\n case 'step.success':\n return 'Step gate success';\n case 'step.feedback':\n return 'Step feedback';\n case 'job.success':\n return 'Job success';\n case 'trigger.filter':\n return 'Trigger filter';\n case 'listener.on':\n return 'Listener on filter';\n case 'listener.until':\n return 'Listener until filter';\n case 'job.if':\n return 'Job if';\n case 'step.if':\n return 'Step if';\n default:\n return assertNever(field);\n }\n}\n\nfunction assertNever(value: never): never {\n throw new Error(`Unhandled workflow field: ${value}`);\n}\n"],"names":["workflowFieldLabel","field","assertNever","value","Error"],"mappings":"AAEA,OAAO,SAASA,mBACdC,KAA0D;IAE1D,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAOC,YAAYD;IACvB;AACF;AAEA,SAASC,YAAYC,KAAY;IAC/B,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAED,OAAO;AACtD"}
|
package/dist/db/db.d.ts
CHANGED
|
@@ -564,6 +564,25 @@ export declare const schema: {
|
|
|
564
564
|
identity: undefined;
|
|
565
565
|
generated: undefined;
|
|
566
566
|
}, {}, {}>;
|
|
567
|
+
warnings: import("drizzle-orm/pg-core").PgColumn<{
|
|
568
|
+
name: "warnings";
|
|
569
|
+
tableName: "sync_states";
|
|
570
|
+
dataType: "json";
|
|
571
|
+
columnType: "PgJsonb";
|
|
572
|
+
data: import("../core/validate-definition.js").ValidationWarning[];
|
|
573
|
+
driverParam: unknown;
|
|
574
|
+
notNull: true;
|
|
575
|
+
hasDefault: true;
|
|
576
|
+
isPrimaryKey: false;
|
|
577
|
+
isAutoincrement: false;
|
|
578
|
+
hasRuntimeDefault: false;
|
|
579
|
+
enumValues: undefined;
|
|
580
|
+
baseColumn: never;
|
|
581
|
+
identity: undefined;
|
|
582
|
+
generated: undefined;
|
|
583
|
+
}, {}, {
|
|
584
|
+
$type: import("../core/validate-definition.js").ValidationWarning[];
|
|
585
|
+
}>;
|
|
567
586
|
startedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
568
587
|
name: "started_at";
|
|
569
588
|
tableName: "sync_states";
|
|
@@ -1201,6 +1220,25 @@ export declare function db(): NodePgDatabase<{
|
|
|
1201
1220
|
identity: undefined;
|
|
1202
1221
|
generated: undefined;
|
|
1203
1222
|
}, {}, {}>;
|
|
1223
|
+
warnings: import("drizzle-orm/pg-core").PgColumn<{
|
|
1224
|
+
name: "warnings";
|
|
1225
|
+
tableName: "sync_states";
|
|
1226
|
+
dataType: "json";
|
|
1227
|
+
columnType: "PgJsonb";
|
|
1228
|
+
data: import("../core/validate-definition.js").ValidationWarning[];
|
|
1229
|
+
driverParam: unknown;
|
|
1230
|
+
notNull: true;
|
|
1231
|
+
hasDefault: true;
|
|
1232
|
+
isPrimaryKey: false;
|
|
1233
|
+
isAutoincrement: false;
|
|
1234
|
+
hasRuntimeDefault: false;
|
|
1235
|
+
enumValues: undefined;
|
|
1236
|
+
baseColumn: never;
|
|
1237
|
+
identity: undefined;
|
|
1238
|
+
generated: undefined;
|
|
1239
|
+
}, {}, {
|
|
1240
|
+
$type: import("../core/validate-definition.js").ValidationWarning[];
|
|
1241
|
+
}>;
|
|
1204
1242
|
startedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1205
1243
|
name: "started_at";
|
|
1206
1244
|
tableName: "sync_states";
|
package/dist/db/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAMnE,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGjB;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B"}
|
|
@@ -141,6 +141,25 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
|
|
|
141
141
|
identity: undefined;
|
|
142
142
|
generated: undefined;
|
|
143
143
|
}, {}, {}>;
|
|
144
|
+
warnings: import("drizzle-orm/pg-core").PgColumn<{
|
|
145
|
+
name: "warnings";
|
|
146
|
+
tableName: "sync_states";
|
|
147
|
+
dataType: "json";
|
|
148
|
+
columnType: "PgJsonb";
|
|
149
|
+
data: import("../../core/validate-definition.js").ValidationWarning[];
|
|
150
|
+
driverParam: unknown;
|
|
151
|
+
notNull: true;
|
|
152
|
+
hasDefault: true;
|
|
153
|
+
isPrimaryKey: false;
|
|
154
|
+
isAutoincrement: false;
|
|
155
|
+
hasRuntimeDefault: false;
|
|
156
|
+
enumValues: undefined;
|
|
157
|
+
baseColumn: never;
|
|
158
|
+
identity: undefined;
|
|
159
|
+
generated: undefined;
|
|
160
|
+
}, {}, {
|
|
161
|
+
$type: import("../../core/validate-definition.js").ValidationWarning[];
|
|
162
|
+
}>;
|
|
144
163
|
startedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
145
164
|
name: "started_at";
|
|
146
165
|
tableName: "sync_states";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-states.d.ts","sourceRoot":"","sources":["../../../src/db/schema/sync-states.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sync-states.d.ts","sourceRoot":"","sources":["../../../src/db/schema/sync-states.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,mBAAmB,EAGpB,MAAM,8BAA8B,CAAC;AAGtC,eAAO,MAAM,wBAAwB,qFAKnC,CAAC;AAEH,eAAO,MAAM,2BAA2B,yVActC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BhC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAC;AAC7E,MAAM,MAAM,2BAA2B,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAC;AAEnF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,mBAAmB,CAgBrF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
2
|
import { sql } from 'drizzle-orm';
|
|
3
|
-
import { index, pgEnum, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { index, jsonb, pgEnum, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
4
4
|
import { pgTable } from './common.js';
|
|
5
5
|
export const definitionSyncStatusEnum = pgEnum('definitions_sync_status', [
|
|
6
6
|
'pending',
|
|
@@ -32,6 +32,7 @@ export const definitionSyncStates = pgTable('sync_states', {
|
|
|
32
32
|
status: definitionSyncStatusEnum('status').notNull().default('pending'),
|
|
33
33
|
lastErrorCode: definitionSyncErrorCodeEnum('last_error_code'),
|
|
34
34
|
lastErrorMessage: text('last_error_message'),
|
|
35
|
+
warnings: jsonb('warnings').notNull().default([]).$type(),
|
|
35
36
|
startedAt: timestamp('started_at', {
|
|
36
37
|
withTimezone: true
|
|
37
38
|
}),
|
|
@@ -58,6 +59,7 @@ export function toDefinitionSyncState(row) {
|
|
|
58
59
|
status: row.status,
|
|
59
60
|
lastErrorCode: row.lastErrorCode,
|
|
60
61
|
lastErrorMessage: row.lastErrorMessage,
|
|
62
|
+
warnings: row.warnings ?? [],
|
|
61
63
|
startedAt: row.startedAt,
|
|
62
64
|
finishedAt: row.finishedAt,
|
|
63
65
|
createdAt: row.createdAt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/schema/sync-states.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {index, pgEnum, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {\n DefinitionSyncErrorCode,\n DefinitionSyncState,\n DefinitionSyncStatus,\n} from '#core/entities/sync-state.js';\nimport {pgTable} from './common.js';\n\nexport const definitionSyncStatusEnum = pgEnum('definitions_sync_status', [\n 'pending',\n 'syncing',\n 'succeeded',\n 'failed',\n]);\n\nexport const definitionSyncErrorCodeEnum = pgEnum('definitions_sync_error_code', [\n 'no-workflow-files',\n 'invalid-definition',\n 'provider-repository-not-found',\n 'provider-file-not-found',\n 'provider-access-denied',\n 'provider-rate-limited',\n 'provider-timeout',\n 'provider-unavailable',\n 'provider-malformed-response',\n 'content-too-large',\n 'too-many-files',\n 'connection-unavailable',\n 'unknown',\n]);\n\nexport const definitionSyncStates = pgTable(\n 'sync_states',\n {\n id: uuidv7PrimaryKey(),\n projectId: uuid('project_id').notNull(),\n sourceConnectionId: uuid('source_connection_id').notNull(),\n sourceExternalRepositoryId: text('source_external_repository_id').notNull(),\n ref: text('ref').notNull(),\n status: definitionSyncStatusEnum('status').notNull().default('pending'),\n lastErrorCode: definitionSyncErrorCodeEnum('last_error_code'),\n lastErrorMessage: text('last_error_message'),\n startedAt: timestamp('started_at', {withTimezone: true}),\n finishedAt: timestamp('finished_at', {withTimezone: true}),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('definitions_sync_states_source_unique').on(\n table.projectId,\n table.sourceConnectionId,\n table.sourceExternalRepositoryId,\n table.ref,\n ),\n index('definitions_sync_states_failed_idx').on(table.updatedAt).where(sql`\"status\" = 'failed'`),\n ],\n);\n\nexport type DefinitionSyncStateDb = typeof definitionSyncStates.$inferSelect;\nexport type DefinitionSyncStateCreateDb = typeof definitionSyncStates.$inferInsert;\n\nexport function toDefinitionSyncState(row: DefinitionSyncStateDb): DefinitionSyncState {\n return {\n id: row.id,\n projectId: row.projectId,\n sourceConnectionId: row.sourceConnectionId,\n sourceExternalRepositoryId: row.sourceExternalRepositoryId,\n ref: row.ref,\n status: row.status as DefinitionSyncStatus,\n lastErrorCode: row.lastErrorCode as DefinitionSyncErrorCode | null,\n lastErrorMessage: row.lastErrorMessage,\n startedAt: row.startedAt,\n finishedAt: row.finishedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","sql","index","pgEnum","text","timestamp","uniqueIndex","uuid","pgTable","definitionSyncStatusEnum","definitionSyncErrorCodeEnum","definitionSyncStates","id","projectId","notNull","sourceConnectionId","sourceExternalRepositoryId","ref","status","default","lastErrorCode","lastErrorMessage","startedAt","withTimezone","finishedAt","createdAt","defaultNow","updatedAt","table","on","where","toDefinitionSyncState","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SAAQC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAO,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/sync-states.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {index, jsonb, pgEnum, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {\n DefinitionSyncErrorCode,\n DefinitionSyncState,\n DefinitionSyncStatus,\n DefinitionSyncWarning,\n} from '#core/entities/sync-state.js';\nimport {pgTable} from './common.js';\n\nexport const definitionSyncStatusEnum = pgEnum('definitions_sync_status', [\n 'pending',\n 'syncing',\n 'succeeded',\n 'failed',\n]);\n\nexport const definitionSyncErrorCodeEnum = pgEnum('definitions_sync_error_code', [\n 'no-workflow-files',\n 'invalid-definition',\n 'provider-repository-not-found',\n 'provider-file-not-found',\n 'provider-access-denied',\n 'provider-rate-limited',\n 'provider-timeout',\n 'provider-unavailable',\n 'provider-malformed-response',\n 'content-too-large',\n 'too-many-files',\n 'connection-unavailable',\n 'unknown',\n]);\n\nexport const definitionSyncStates = pgTable(\n 'sync_states',\n {\n id: uuidv7PrimaryKey(),\n projectId: uuid('project_id').notNull(),\n sourceConnectionId: uuid('source_connection_id').notNull(),\n sourceExternalRepositoryId: text('source_external_repository_id').notNull(),\n ref: text('ref').notNull(),\n status: definitionSyncStatusEnum('status').notNull().default('pending'),\n lastErrorCode: definitionSyncErrorCodeEnum('last_error_code'),\n lastErrorMessage: text('last_error_message'),\n warnings: jsonb('warnings').notNull().default([]).$type<DefinitionSyncWarning[]>(),\n startedAt: timestamp('started_at', {withTimezone: true}),\n finishedAt: timestamp('finished_at', {withTimezone: true}),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('definitions_sync_states_source_unique').on(\n table.projectId,\n table.sourceConnectionId,\n table.sourceExternalRepositoryId,\n table.ref,\n ),\n index('definitions_sync_states_failed_idx').on(table.updatedAt).where(sql`\"status\" = 'failed'`),\n ],\n);\n\nexport type DefinitionSyncStateDb = typeof definitionSyncStates.$inferSelect;\nexport type DefinitionSyncStateCreateDb = typeof definitionSyncStates.$inferInsert;\n\nexport function toDefinitionSyncState(row: DefinitionSyncStateDb): DefinitionSyncState {\n return {\n id: row.id,\n projectId: row.projectId,\n sourceConnectionId: row.sourceConnectionId,\n sourceExternalRepositoryId: row.sourceExternalRepositoryId,\n ref: row.ref,\n status: row.status as DefinitionSyncStatus,\n lastErrorCode: row.lastErrorCode as DefinitionSyncErrorCode | null,\n lastErrorMessage: row.lastErrorMessage,\n warnings: row.warnings ?? [],\n startedAt: row.startedAt,\n finishedAt: row.finishedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","sql","index","jsonb","pgEnum","text","timestamp","uniqueIndex","uuid","pgTable","definitionSyncStatusEnum","definitionSyncErrorCodeEnum","definitionSyncStates","id","projectId","notNull","sourceConnectionId","sourceExternalRepositoryId","ref","status","default","lastErrorCode","lastErrorMessage","warnings","$type","startedAt","withTimezone","finishedAt","createdAt","defaultNow","updatedAt","table","on","where","toDefinitionSyncState","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SAAQC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAO,sBAAsB;AAO7F,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,2BAA2BN,OAAO,2BAA2B;IACxE;IACA;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMO,8BAA8BP,OAAO,+BAA+B;IAC/E;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAC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I,EAAE;QAC5BE,WAAWU,IAAIV,SAAS;QACxBE,YAAYQ,IAAIR,UAAU;QAC1BC,WAAWO,IAAIP,SAAS;QACxBE,WAAWK,IAAIL,SAAS;IAC1B;AACF"}
|
package/dist/db/sync-states.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefinitionSyncErrorCode, DefinitionSyncState, DefinitionSyncStatus } from '#core/entities/sync-state.js';
|
|
1
|
+
import type { DefinitionSyncErrorCode, DefinitionSyncState, DefinitionSyncStatus, DefinitionSyncWarning } from '#core/entities/sync-state.js';
|
|
2
2
|
export interface DefinitionSyncStateKey {
|
|
3
3
|
projectId: string;
|
|
4
4
|
sourceConnectionId: string;
|
|
@@ -9,6 +9,7 @@ export interface MarkDefinitionSyncParams extends DefinitionSyncStateKey {
|
|
|
9
9
|
status: DefinitionSyncStatus;
|
|
10
10
|
lastErrorCode?: DefinitionSyncErrorCode | null | undefined;
|
|
11
11
|
lastErrorMessage?: string | null | undefined;
|
|
12
|
+
warnings?: readonly DefinitionSyncWarning[] | null | undefined;
|
|
12
13
|
startedAt?: Date | null | undefined;
|
|
13
14
|
finishedAt?: Date | null | undefined;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-states.d.ts","sourceRoot":"","sources":["../../src/db/sync-states.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"sync-states.d.ts","sourceRoot":"","sources":["../../src/db/sync-states.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,wBAAyB,SAAQ,sBAAsB;IACtE,MAAM,EAAE,oBAAoB,CAAC;IAC7B,aAAa,CAAC,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/D,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;CACtC;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CAuC9B;AAED,wBAAsB,4BAA4B,CAAC,MAAM,EAAE;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAiB3C"}
|
package/dist/db/sync-states.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { and, desc, eq } from 'drizzle-orm';
|
|
2
|
+
import { limitDefinitionSyncWarnings } from '#core/entities/sync-state.js';
|
|
2
3
|
import { db } from './db.js';
|
|
3
4
|
import { definitionSyncStates, toDefinitionSyncState } from './schema/sync-states.js';
|
|
4
5
|
export async function markDefinitionSyncState(params) {
|
|
5
6
|
const now = new Date();
|
|
7
|
+
const warnings = limitDefinitionSyncWarnings(params.warnings ?? []);
|
|
6
8
|
const [row] = await db().insert(definitionSyncStates).values({
|
|
7
9
|
projectId: params.projectId,
|
|
8
10
|
sourceConnectionId: params.sourceConnectionId,
|
|
@@ -11,6 +13,7 @@ export async function markDefinitionSyncState(params) {
|
|
|
11
13
|
status: params.status,
|
|
12
14
|
lastErrorCode: params.lastErrorCode ?? null,
|
|
13
15
|
lastErrorMessage: params.lastErrorMessage ?? null,
|
|
16
|
+
warnings,
|
|
14
17
|
startedAt: params.startedAt ?? null,
|
|
15
18
|
finishedAt: params.finishedAt ?? null,
|
|
16
19
|
updatedAt: now
|
|
@@ -25,6 +28,7 @@ export async function markDefinitionSyncState(params) {
|
|
|
25
28
|
status: params.status,
|
|
26
29
|
lastErrorCode: params.lastErrorCode ?? null,
|
|
27
30
|
lastErrorMessage: params.lastErrorMessage ?? null,
|
|
31
|
+
warnings,
|
|
28
32
|
...params.startedAt !== undefined ? {
|
|
29
33
|
startedAt: params.startedAt
|
|
30
34
|
} : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/sync-states.ts"],"sourcesContent":["import {and, desc, eq} from 'drizzle-orm';\nimport type {\n DefinitionSyncErrorCode,\n DefinitionSyncState,\n DefinitionSyncStatus,\n} from '#core/entities/sync-state.js';\nimport {db} from './db.js';\nimport {definitionSyncStates, toDefinitionSyncState} from './schema/sync-states.js';\n\nexport interface DefinitionSyncStateKey {\n projectId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n ref: string;\n}\n\nexport interface MarkDefinitionSyncParams extends DefinitionSyncStateKey {\n status: DefinitionSyncStatus;\n lastErrorCode?: DefinitionSyncErrorCode | null | undefined;\n lastErrorMessage?: string | null | undefined;\n startedAt?: Date | null | undefined;\n finishedAt?: Date | null | undefined;\n}\n\nexport async function markDefinitionSyncState(\n params: MarkDefinitionSyncParams,\n): Promise<DefinitionSyncState> {\n const now = new Date();\n const [row] = await db()\n .insert(definitionSyncStates)\n .values({\n projectId: params.projectId,\n sourceConnectionId: params.sourceConnectionId,\n sourceExternalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n status: params.status,\n lastErrorCode: params.lastErrorCode ?? null,\n lastErrorMessage: params.lastErrorMessage ?? null,\n startedAt: params.startedAt ?? null,\n finishedAt: params.finishedAt ?? null,\n updatedAt: now,\n })\n .onConflictDoUpdate({\n target: [\n definitionSyncStates.projectId,\n definitionSyncStates.sourceConnectionId,\n definitionSyncStates.sourceExternalRepositoryId,\n definitionSyncStates.ref,\n ],\n set: {\n status: params.status,\n lastErrorCode: params.lastErrorCode ?? null,\n lastErrorMessage: params.lastErrorMessage ?? null,\n ...(params.startedAt !== undefined ? {startedAt: params.startedAt} : {}),\n ...(params.finishedAt !== undefined ? {finishedAt: params.finishedAt} : {}),\n updatedAt: now,\n },\n })\n .returning();\n\n if (!row) throw new Error('Definition sync state upsert returned no rows');\n return toDefinitionSyncState(row);\n}\n\nexport async function getLatestDefinitionSyncState(params: {\n projectId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n}): Promise<DefinitionSyncState | undefined> {\n const rows = await db()\n .select()\n .from(definitionSyncStates)\n .where(\n and(\n eq(definitionSyncStates.projectId, params.projectId),\n eq(definitionSyncStates.sourceConnectionId, params.sourceConnectionId),\n eq(definitionSyncStates.sourceExternalRepositoryId, params.sourceExternalRepositoryId),\n ),\n )\n .orderBy(desc(definitionSyncStates.updatedAt))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toDefinitionSyncState(row);\n}\n"],"names":["and","desc","eq","db","definitionSyncStates","toDefinitionSyncState","markDefinitionSyncState","params","now","Date","row","insert","values","projectId","sourceConnectionId","sourceExternalRepositoryId","ref","status","lastErrorCode","lastErrorMessage","startedAt","finishedAt","updatedAt","onConflictDoUpdate","target","set","undefined","returning","Error","getLatestDefinitionSyncState","rows","select","from","where","orderBy","limit"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,IAAI,EAAEC,EAAE,QAAO,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/db/sync-states.ts"],"sourcesContent":["import {and, desc, eq} from 'drizzle-orm';\nimport type {\n DefinitionSyncErrorCode,\n DefinitionSyncState,\n DefinitionSyncStatus,\n DefinitionSyncWarning,\n} from '#core/entities/sync-state.js';\nimport {limitDefinitionSyncWarnings} from '#core/entities/sync-state.js';\nimport {db} from './db.js';\nimport {definitionSyncStates, toDefinitionSyncState} from './schema/sync-states.js';\n\nexport interface DefinitionSyncStateKey {\n projectId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n ref: string;\n}\n\nexport interface MarkDefinitionSyncParams extends DefinitionSyncStateKey {\n status: DefinitionSyncStatus;\n lastErrorCode?: DefinitionSyncErrorCode | null | undefined;\n lastErrorMessage?: string | null | undefined;\n warnings?: readonly DefinitionSyncWarning[] | null | undefined;\n startedAt?: Date | null | undefined;\n finishedAt?: Date | null | undefined;\n}\n\nexport async function markDefinitionSyncState(\n params: MarkDefinitionSyncParams,\n): Promise<DefinitionSyncState> {\n const now = new Date();\n const warnings = limitDefinitionSyncWarnings(params.warnings ?? []);\n const [row] = await db()\n .insert(definitionSyncStates)\n .values({\n projectId: params.projectId,\n sourceConnectionId: params.sourceConnectionId,\n sourceExternalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n status: params.status,\n lastErrorCode: params.lastErrorCode ?? null,\n lastErrorMessage: params.lastErrorMessage ?? null,\n warnings,\n startedAt: params.startedAt ?? null,\n finishedAt: params.finishedAt ?? null,\n updatedAt: now,\n })\n .onConflictDoUpdate({\n target: [\n definitionSyncStates.projectId,\n definitionSyncStates.sourceConnectionId,\n definitionSyncStates.sourceExternalRepositoryId,\n definitionSyncStates.ref,\n ],\n set: {\n status: params.status,\n lastErrorCode: params.lastErrorCode ?? null,\n lastErrorMessage: params.lastErrorMessage ?? null,\n warnings,\n ...(params.startedAt !== undefined ? {startedAt: params.startedAt} : {}),\n ...(params.finishedAt !== undefined ? {finishedAt: params.finishedAt} : {}),\n updatedAt: now,\n },\n })\n .returning();\n\n if (!row) throw new Error('Definition sync state upsert returned no rows');\n return toDefinitionSyncState(row);\n}\n\nexport async function getLatestDefinitionSyncState(params: {\n projectId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n}): Promise<DefinitionSyncState | undefined> {\n const rows = await db()\n .select()\n .from(definitionSyncStates)\n .where(\n and(\n eq(definitionSyncStates.projectId, params.projectId),\n eq(definitionSyncStates.sourceConnectionId, params.sourceConnectionId),\n eq(definitionSyncStates.sourceExternalRepositoryId, params.sourceExternalRepositoryId),\n ),\n )\n .orderBy(desc(definitionSyncStates.updatedAt))\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toDefinitionSyncState(row);\n}\n"],"names":["and","desc","eq","limitDefinitionSyncWarnings","db","definitionSyncStates","toDefinitionSyncState","markDefinitionSyncState","params","now","Date","warnings","row","insert","values","projectId","sourceConnectionId","sourceExternalRepositoryId","ref","status","lastErrorCode","lastErrorMessage","startedAt","finishedAt","updatedAt","onConflictDoUpdate","target","set","undefined","returning","Error","getLatestDefinitionSyncState","rows","select","from","where","orderBy","limit"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,IAAI,EAAEC,EAAE,QAAO,cAAc;AAO1C,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,oBAAoB,EAAEC,qBAAqB,QAAO,0BAA0B;AAkBpF,OAAO,eAAeC,wBACpBC,MAAgC;IAEhC,MAAMC,MAAM,IAAIC;IAChB,MAAMC,WAAWR,4BAA4BK,OAAOG,QAAQ,IAAI,EAAE;IAClE,MAAM,CAACC,IAAI,GAAG,MAAMR,KACjBS,MAAM,CAACR,sBACPS,MAAM,CAAC;QACNC,WAAWP,OAAOO,SAAS;QAC3BC,oBAAoBR,OAAOQ,kBAAkB;QAC7CC,4BAA4BT,OAAOS,0BAA0B;QAC7DC,KAAKV,OAAOU,GAAG;QACfC,QAAQX,OAAOW,MAAM;QACrBC,eAAeZ,OAAOY,aAAa,IAAI;QACvCC,kBAAkBb,OAAOa,gBAAgB,IAAI;QAC7CV;QACAW,WAAWd,OAAOc,SAAS,IAAI;QAC/BC,YAAYf,OAAOe,UAAU,IAAI;QACjCC,WAAWf;IACb,GACCgB,kBAAkB,CAAC;QAClBC,QAAQ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,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,CAajC"}
|
|
@@ -28,7 +28,8 @@ export function toDefinitionSyncSummaryDto(syncState) {
|
|
|
28
28
|
started_at: syncState.startedAt?.toISOString() ?? null,
|
|
29
29
|
finished_at: syncState.finishedAt?.toISOString() ?? null,
|
|
30
30
|
last_error_code: syncState.lastErrorCode,
|
|
31
|
-
last_error_message: syncState.lastErrorMessage
|
|
31
|
+
last_error_message: syncState.lastErrorMessage,
|
|
32
|
+
warnings: syncState.warnings
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n const manualEntry = Object.entries(definition.document.triggers ?? {}).find(\n ([, trigger]) => trigger.source === 'manual',\n );\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualEntry ? {name: manualEntry[0]} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualEntry","Object","entries","document","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","workflow_model","model","manual_trigger","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,MAAMC,cAAcC,OAAOC,OAAO,CAACH,WAAWI,QAAQ,CAACC,QAAQ,IAAI,CAAC,GAAGC,IAAI,CACzE,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAK;IAEtC,OAAO;QACLC,IAAIT,WAAWS,EAAE;QACjBC,YAAYV,WAAWW,SAAS;QAChCC,aAAaZ,WAAWa,UAAU;QAClCL,QAAQR,WAAWQ,MAAM;QACzBM,KAAKd,WAAWc,GAAG;QACnBC,KAAKf,WAAWe,GAAG;QACnBC,MAAMhB,WAAWgB,IAAI;QACrBC,mBAAmBjB,WAAWI,QAAQ;QACtCc,gBAAgBlB,WAAWmB,KAAK;QAChCC,gBAAgBnB,cAAc;YAACe,MAAMf,WAAW,CAAC,EAAE;QAAA,IAAI;QACvDoB,YAAYrB,WAAWsB,SAAS,CAACC,WAAW;QAC5CC,YAAYxB,WAAWyB,SAAS,CAACF,WAAW;QAC5CG,YAAY1B,WAAW2B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLd,KAAKc,UAAUd,GAAG,KAAKjB,sBAAsB,OAAO+B,UAAUd,GAAG;QACjEe,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n const manualEntry = Object.entries(definition.document.triggers ?? {}).find(\n ([, trigger]) => trigger.source === 'manual',\n );\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualEntry ? {name: manualEntry[0]} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n warnings: syncState.warnings,\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualEntry","Object","entries","document","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","workflow_model","model","manual_trigger","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage","warnings"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,MAAMC,cAAcC,OAAOC,OAAO,CAACH,WAAWI,QAAQ,CAACC,QAAQ,IAAI,CAAC,GAAGC,IAAI,CACzE,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAK;IAEtC,OAAO;QACLC,IAAIT,WAAWS,EAAE;QACjBC,YAAYV,WAAWW,SAAS;QAChCC,aAAaZ,WAAWa,UAAU;QAClCL,QAAQR,WAAWQ,MAAM;QACzBM,KAAKd,WAAWc,GAAG;QACnBC,KAAKf,WAAWe,GAAG;QACnBC,MAAMhB,WAAWgB,IAAI;QACrBC,mBAAmBjB,WAAWI,QAAQ;QACtCc,gBAAgBlB,WAAWmB,KAAK;QAChCC,gBAAgBnB,cAAc;YAACe,MAAMf,WAAW,CAAC,EAAE;QAAA,IAAI;QACvDoB,YAAYrB,WAAWsB,SAAS,CAACC,WAAW;QAC5CC,YAAYxB,WAAWyB,SAAS,CAACF,WAAW;QAC5CG,YAAY1B,WAAW2B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLd,KAAKc,UAAUd,GAAG,KAAKjB,sBAAsB,OAAO+B,UAAUd,GAAG;QACjEe,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;QAC9CC,UAAUX,UAAUW,QAAQ;IAC9B;AACF"}
|
|
@@ -6,5 +6,6 @@ export declare function requireProjectAccess(request: FastifyRequest, projectId:
|
|
|
6
6
|
sourceConnectionId: string;
|
|
7
7
|
sourceExternalRepositoryId: string;
|
|
8
8
|
name: string;
|
|
9
|
+
sourceRepositoryOwner?: string | null | undefined;
|
|
9
10
|
}>;
|
|
10
11
|
//# sourceMappingURL=project-access.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB
|
|
1
|
+
{"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB;;;;;;;GAO/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AA2BhF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,mDA6BzE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definitionDtoSchema, definitionValidationErrorSchema } from '@shipfox/api-definitions-dto';
|
|
1
|
+
import { definitionDtoSchema, definitionValidationErrorSchema, definitionValidationWarningSchema } from '@shipfox/api-definitions-dto';
|
|
2
2
|
import { defineRoute } from '@shipfox/node-fastify';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { validateDefinition } from '#core/validate-definition.js';
|
|
@@ -9,7 +9,8 @@ const validationResultSchema = z.union([
|
|
|
9
9
|
z.object({
|
|
10
10
|
valid: z.literal(true),
|
|
11
11
|
workflow_document: definitionDtoSchema.shape.workflow_document,
|
|
12
|
-
workflow_model: definitionDtoSchema.shape.workflow_model
|
|
12
|
+
workflow_model: definitionDtoSchema.shape.workflow_model,
|
|
13
|
+
warnings: z.array(definitionValidationWarningSchema)
|
|
13
14
|
}),
|
|
14
15
|
z.object({
|
|
15
16
|
valid: z.literal(false),
|
|
@@ -36,7 +37,8 @@ export function buildValidateDefinitionRoute(agent) {
|
|
|
36
37
|
return {
|
|
37
38
|
valid: true,
|
|
38
39
|
workflow_document: result.definition.document,
|
|
39
|
-
workflow_model: result.definition.model
|
|
40
|
+
workflow_model: result.definition.model,
|
|
41
|
+
warnings: result.warnings
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {definitionDtoSchema
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n definitionDtoSchema,\n definitionValidationErrorSchema,\n definitionValidationWarningSchema,\n} from '@shipfox/api-definitions-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {validateDefinition} from '#core/validate-definition.js';\n\nconst validateBodySchema = z.object({\n yaml: z.string().min(1).max(1_000_000),\n});\n\nconst validationResultSchema = z.union([\n z.object({\n valid: z.literal(true),\n workflow_document: definitionDtoSchema.shape.workflow_document,\n workflow_model: definitionDtoSchema.shape.workflow_model,\n warnings: z.array(definitionValidationWarningSchema),\n }),\n z.object({\n valid: z.literal(false),\n errors: z.array(definitionValidationErrorSchema),\n }),\n]);\n\nexport function buildValidateDefinitionRoute(agent: AgentInterModuleClient) {\n return defineRoute({\n method: 'POST',\n path: '/validate',\n description: 'Validate a workflow definition without persisting',\n schema: {\n body: validateBodySchema,\n response: {\n 200: validationResultSchema,\n },\n },\n handler: async (request) => {\n const {yaml} = request.body;\n const result = validateDefinition(yaml, {\n agentValidationCatalog: await agent.getValidationCatalog({}),\n });\n\n if (result.valid) {\n return {\n valid: true as const,\n workflow_document: result.definition.document,\n workflow_model: result.definition.model,\n warnings: result.warnings,\n };\n }\n\n return result;\n },\n });\n}\n"],"names":["definitionDtoSchema","definitionValidationErrorSchema","definitionValidationWarningSchema","defineRoute","z","validateDefinition","validateBodySchema","object","yaml","string","min","max","validationResultSchema","union","valid","literal","workflow_document","shape","workflow_model","warnings","array","errors","buildValidateDefinitionRoute","agent","method","path","description","schema","body","response","handler","request","result","agentValidationCatalog","getValidationCatalog","definition","document","model"],"mappings":"AACA,SACEA,mBAAmB,EACnBC,+BAA+B,EAC/BC,iCAAiC,QAC5B,+BAA+B;AACtC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,+BAA+B;AAEhE,MAAMC,qBAAqBF,EAAEG,MAAM,CAAC;IAClCC,MAAMJ,EAAEK,MAAM,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC;AAC9B;AAEA,MAAMC,yBAAyBR,EAAES,KAAK,CAAC;IACrCT,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBC,mBAAmBhB,oBAAoBiB,KAAK,CAACD,iBAAiB;QAC9DE,gBAAgBlB,oBAAoBiB,KAAK,CAACC,cAAc;QACxDC,UAAUf,EAAEgB,KAAK,CAAClB;IACpB;IACAE,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBM,QAAQjB,EAAEgB,KAAK,CAACnB;IAClB;CACD;AAED,OAAO,SAASqB,6BAA6BC,KAA6B;IACxE,OAAOpB,YAAY;QACjBqB,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMtB;YACNuB,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACvB,IAAI,EAAC,GAAGuB,QAAQH,IAAI;YAC3B,MAAMI,SAAS3B,mBAAmBG,MAAM;gBACtCyB,wBAAwB,MAAMV,MAAMW,oBAAoB,CAAC,CAAC;YAC5D;YAEA,IAAIF,OAAOlB,KAAK,EAAE;gBAChB,OAAO;oBACLA,OAAO;oBACPE,mBAAmBgB,OAAOG,UAAU,CAACC,QAAQ;oBAC7ClB,gBAAgBc,OAAOG,UAAU,CAACE,KAAK;oBACvClB,UAAUa,OAAOb,QAAQ;gBAC3B;YACF;YAEA,OAAOa;QACT;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
|
|
2
2
|
import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
|
|
3
|
-
import type { DefinitionSyncErrorCode } from '#core/entities/sync-state.js';
|
|
3
|
+
import type { DefinitionSyncErrorCode, DefinitionSyncWarning } from '#core/entities/sync-state.js';
|
|
4
4
|
import type { DefinitionsSourceControl } from '#core/integrations.js';
|
|
5
5
|
export interface SyncWorkflowInput {
|
|
6
6
|
projectId: string;
|
|
@@ -31,6 +31,10 @@ export interface DiscoverWorkflowsActivityResult {
|
|
|
31
31
|
export interface FetchAndApplyActivityResult {
|
|
32
32
|
appliedCount: number;
|
|
33
33
|
deletedCount: number;
|
|
34
|
+
warnings: DefinitionSyncWarning[];
|
|
35
|
+
}
|
|
36
|
+
export interface MarkSyncSucceededActivityInput extends SyncRefScopedInput {
|
|
37
|
+
warnings?: readonly DefinitionSyncWarning[] | undefined;
|
|
34
38
|
}
|
|
35
39
|
export interface DefinitionSyncActivityOptions {
|
|
36
40
|
workflowPath: string;
|
|
@@ -39,7 +43,7 @@ export declare function createDefinitionSyncActivities(sourceControl: Definition
|
|
|
39
43
|
prepareDefinitionSync: (input: SyncWorkflowInput) => Promise<PrepareSyncResult>;
|
|
40
44
|
discoverDefinitionWorkflows: (input: SyncRefScopedInput) => Promise<DiscoverWorkflowsActivityResult>;
|
|
41
45
|
fetchAndApplyDefinitionWorkflows: (input: FetchAndApplyActivityInput) => Promise<FetchAndApplyActivityResult>;
|
|
42
|
-
markDefinitionSyncSucceeded: (input:
|
|
46
|
+
markDefinitionSyncSucceeded: (input: MarkSyncSucceededActivityInput) => Promise<void>;
|
|
43
47
|
markDefinitionSyncFailed: (input: MarkSyncFailedActivityInput) => Promise<void>;
|
|
44
48
|
};
|
|
45
49
|
//# sourceMappingURL=sync-activities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAI7F,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAI7F,OAAO,KAAK,EAAC,uBAAuB,EAAE,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAQjG,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AAIpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;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