@shipfox/api-definitions 11.0.0 → 12.2.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 +106 -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 +5 -1
- 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/errors.d.ts +2 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/integrations.d.ts +1 -1
- 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 +315 -74
- 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/core/workflow-yaml/invalid-workflow-yaml-error.d.ts.map +1 -1
- package/dist/db/db.d.ts +48 -10
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/schema/definitions.d.ts +1 -1
- package/dist/db/schema/outbox.d.ts +1 -1
- package/dist/db/schema/sync-states.d.ts +22 -3
- 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/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.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/presentation/subscribers/index.d.ts +1 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -1
- package/dist/presentation/subscribers/index.js +1 -0
- package/dist/presentation/subscribers/index.js.map +1 -1
- package/dist/presentation/subscribers/on-integration-connection-available.d.ts +5 -0
- package/dist/presentation/subscribers/on-integration-connection-available.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-integration-connection-available.js +32 -0
- package/dist/presentation/subscribers/on-integration-connection-available.js.map +1 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts +1 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts.map +1 -1
- package/dist/presentation/subscribers/start-definition-sync.js +30 -17
- package/dist/presentation/subscribers/start-definition-sync.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 +17 -17
- 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 -3
- 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 +335 -90
- 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 +876 -202
- 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/index.ts +12 -1
- 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/presentation/subscribers/index.ts +1 -0
- package/src/presentation/subscribers/on-integration-connection-available.test.ts +132 -0
- package/src/presentation/subscribers/on-integration-connection-available.ts +44 -0
- package/src/presentation/subscribers/start-definition-sync.ts +35 -19
- 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,EAC9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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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} 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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-workflow-yaml-error.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/invalid-workflow-yaml-error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAK/C,QAAQ,CAAC,MAAM,EAAE,yBAAyB;IAJ5C,QAAQ,CAAC,IAAI,2BAAgC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"invalid-workflow-yaml-error.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/invalid-workflow-yaml-error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAK/C,QAAQ,CAAC,MAAM,EAAE,yBAAyB;IAJ5C,QAAQ,CAAC,IAAI,2BAAgC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAEpD,YACW,MAAM,EAAE,yBAAyB,EAC1C,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAA;KAAM,EAK7E;CACF"}
|
package/dist/db/db.d.ts
CHANGED
|
@@ -228,7 +228,7 @@ export declare const schema: {
|
|
|
228
228
|
generated: undefined;
|
|
229
229
|
}, {}, {}>;
|
|
230
230
|
};
|
|
231
|
-
dialect:
|
|
231
|
+
dialect: 'pg';
|
|
232
232
|
}>;
|
|
233
233
|
definitionsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
234
234
|
name: "outbox";
|
|
@@ -422,7 +422,7 @@ export declare const schema: {
|
|
|
422
422
|
generated: undefined;
|
|
423
423
|
}, {}, {}>;
|
|
424
424
|
};
|
|
425
|
-
dialect:
|
|
425
|
+
dialect: 'pg';
|
|
426
426
|
}>;
|
|
427
427
|
definitionSyncStates: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
428
428
|
name: "sync_states";
|
|
@@ -518,7 +518,7 @@ export declare const schema: {
|
|
|
518
518
|
tableName: "sync_states";
|
|
519
519
|
dataType: "string";
|
|
520
520
|
columnType: "PgEnumColumn";
|
|
521
|
-
data: "
|
|
521
|
+
data: "failed" | "pending" | "succeeded" | "syncing";
|
|
522
522
|
driverParam: string;
|
|
523
523
|
notNull: true;
|
|
524
524
|
hasDefault: true;
|
|
@@ -535,7 +535,7 @@ export declare const schema: {
|
|
|
535
535
|
tableName: "sync_states";
|
|
536
536
|
dataType: "string";
|
|
537
537
|
columnType: "PgEnumColumn";
|
|
538
|
-
data: "
|
|
538
|
+
data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
|
|
539
539
|
driverParam: string;
|
|
540
540
|
notNull: false;
|
|
541
541
|
hasDefault: false;
|
|
@@ -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";
|
|
@@ -633,7 +652,7 @@ export declare const schema: {
|
|
|
633
652
|
generated: undefined;
|
|
634
653
|
}, {}, {}>;
|
|
635
654
|
};
|
|
636
|
-
dialect:
|
|
655
|
+
dialect: 'pg';
|
|
637
656
|
}>;
|
|
638
657
|
};
|
|
639
658
|
export declare function db(): NodePgDatabase<{
|
|
@@ -865,7 +884,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
865
884
|
generated: undefined;
|
|
866
885
|
}, {}, {}>;
|
|
867
886
|
};
|
|
868
|
-
dialect:
|
|
887
|
+
dialect: 'pg';
|
|
869
888
|
}>;
|
|
870
889
|
definitionsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
871
890
|
name: "outbox";
|
|
@@ -1059,7 +1078,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
1059
1078
|
generated: undefined;
|
|
1060
1079
|
}, {}, {}>;
|
|
1061
1080
|
};
|
|
1062
|
-
dialect:
|
|
1081
|
+
dialect: 'pg';
|
|
1063
1082
|
}>;
|
|
1064
1083
|
definitionSyncStates: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
1065
1084
|
name: "sync_states";
|
|
@@ -1155,7 +1174,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
1155
1174
|
tableName: "sync_states";
|
|
1156
1175
|
dataType: "string";
|
|
1157
1176
|
columnType: "PgEnumColumn";
|
|
1158
|
-
data: "
|
|
1177
|
+
data: "failed" | "pending" | "succeeded" | "syncing";
|
|
1159
1178
|
driverParam: string;
|
|
1160
1179
|
notNull: true;
|
|
1161
1180
|
hasDefault: true;
|
|
@@ -1172,7 +1191,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
1172
1191
|
tableName: "sync_states";
|
|
1173
1192
|
dataType: "string";
|
|
1174
1193
|
columnType: "PgEnumColumn";
|
|
1175
|
-
data: "
|
|
1194
|
+
data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
|
|
1176
1195
|
driverParam: string;
|
|
1177
1196
|
notNull: false;
|
|
1178
1197
|
hasDefault: false;
|
|
@@ -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";
|
|
@@ -1270,7 +1308,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
1270
1308
|
generated: undefined;
|
|
1271
1309
|
}, {}, {}>;
|
|
1272
1310
|
};
|
|
1273
|
-
dialect:
|
|
1311
|
+
dialect: 'pg';
|
|
1274
1312
|
}>;
|
|
1275
1313
|
}>;
|
|
1276
1314
|
export declare function closeDb(): void;
|
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,uBAAuB,CAAC;AAMnE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGjB;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B"}
|
|
@@ -228,7 +228,7 @@ export declare const workflowDefinitions: import("drizzle-orm/pg-core").PgTableW
|
|
|
228
228
|
generated: undefined;
|
|
229
229
|
}, {}, {}>;
|
|
230
230
|
};
|
|
231
|
-
dialect:
|
|
231
|
+
dialect: 'pg';
|
|
232
232
|
}>;
|
|
233
233
|
export type DefinitionDb = typeof workflowDefinitions.$inferSelect;
|
|
234
234
|
export type DefinitionCreateDb = typeof workflowDefinitions.$inferInsert;
|
|
@@ -95,7 +95,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
|
|
|
95
95
|
tableName: "sync_states";
|
|
96
96
|
dataType: "string";
|
|
97
97
|
columnType: "PgEnumColumn";
|
|
98
|
-
data: "
|
|
98
|
+
data: "failed" | "pending" | "succeeded" | "syncing";
|
|
99
99
|
driverParam: string;
|
|
100
100
|
notNull: true;
|
|
101
101
|
hasDefault: true;
|
|
@@ -112,7 +112,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
|
|
|
112
112
|
tableName: "sync_states";
|
|
113
113
|
dataType: "string";
|
|
114
114
|
columnType: "PgEnumColumn";
|
|
115
|
-
data: "
|
|
115
|
+
data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
|
|
116
116
|
driverParam: string;
|
|
117
117
|
notNull: false;
|
|
118
118
|
hasDefault: false;
|
|
@@ -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";
|
|
@@ -210,7 +229,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
|
|
|
210
229
|
generated: undefined;
|
|
211
230
|
}, {}, {}>;
|
|
212
231
|
};
|
|
213
|
-
dialect:
|
|
232
|
+
dialect: 'pg';
|
|
214
233
|
}>;
|
|
215
234
|
export type DefinitionSyncStateDb = typeof definitionSyncStates.$inferSelect;
|
|
216
235
|
export type DefinitionSyncStateCreateDb = typeof definitionSyncStates.$inferInsert;
|
|
@@ -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;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMQ,uBAAuBH,QAClC,eACA;IACEI,IAAIb;IACJc,WAAWN,KAAK,cAAcO,OAAO;IACrCC,oBAAoBR,KAAK,wBAAwBO,OAAO;IACxD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ANGED
|
@@ -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;YACNrB,qBAAqBU,SAAS;YAC9BV,qBAAqBW,kBAAkB;YACvCX,qBAAqBY,0BAA0B;YAC/CZ,qBAAqBa,GAAG;SACzB;QACDS,KAAK;YACHR,QAAQX,OAAOW,MAAM;YACrBC,eAAeZ,OAAOY,aAAa,IAAI;YACvCC,kBAAkBb,OAAOa,gBAAgB,IAAI;YAC7CV;YACA,GAAIH,OAAOc,SAAS,KAAKM,YAAY;gBAACN,WAAWd,OAAOc,SAAS;YAAA,IAAI,CAAC,CAAC;YACvE,GAAId,OAAOe,UAAU,KAAKK,YAAY;gBAACL,YAAYf,OAAOe,UAAU;YAAA,IAAI,CAAC,CAAC;YAC1EC,WAAWf;QACb;IACF,GACCoB,SAAS;IAEZ,IAAI,CAACjB,KAAK,MAAM,IAAIkB,MAAM;IAC1B,OAAOxB,sBAAsBM;AAC/B;AAEA,OAAO,eAAemB,6BAA6BvB,MAIlD;IACC,MAAMwB,OAAO,MAAM5B,KAChB6B,MAAM,GACNC,IAAI,CAAC7B,sBACL8B,KAAK,CACJnC,IACEE,GAAGG,qBAAqBU,SAAS,EAAEP,OAAOO,SAAS,GACnDb,GAAGG,qBAAqBW,kBAAkB,EAAER,OAAOQ,kBAAkB,GACrEd,GAAGG,qBAAqBY,0BAA0B,EAAET,OAAOS,0BAA0B,IAGxFmB,OAAO,CAACnC,KAAKI,qBAAqBmB,SAAS,GAC3Ca,KAAK,CAAC;IAET,MAAMzB,MAAMoB,IAAI,CAAC,EAAE;IACnB,IAAI,CAACpB,KAAK,OAAOgB;IACjB,OAAOtB,sBAAsBM;AAC/B"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAUhF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAM7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAC,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAc3E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAStF,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,KAAK,EACL,YAAY,GACb,EAAE,8BAA8B,GAAG,aAAa,CAmChD"}
|