@xemahq/dsl 0.1.1
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/LICENSE +201 -0
- package/dist/deliverable-spec/index.d.ts +3 -0
- package/dist/deliverable-spec/index.d.ts.map +1 -0
- package/dist/deliverable-spec/index.js +19 -0
- package/dist/deliverable-spec/index.js.map +1 -0
- package/dist/deliverable-spec/lib/schema.d.ts +151 -0
- package/dist/deliverable-spec/lib/schema.d.ts.map +1 -0
- package/dist/deliverable-spec/lib/schema.js +139 -0
- package/dist/deliverable-spec/lib/schema.js.map +1 -0
- package/dist/deliverable-spec/lib/types.d.ts +8 -0
- package/dist/deliverable-spec/lib/types.d.ts.map +1 -0
- package/dist/deliverable-spec/lib/types.js +3 -0
- package/dist/deliverable-spec/lib/types.js.map +1 -0
- package/dist/payload-codec/index.d.ts +8 -0
- package/dist/payload-codec/index.d.ts.map +1 -0
- package/dist/payload-codec/index.js +27 -0
- package/dist/payload-codec/index.js.map +1 -0
- package/dist/payload-codec/lib/blob-store.d.ts +37 -0
- package/dist/payload-codec/lib/blob-store.d.ts.map +1 -0
- package/dist/payload-codec/lib/blob-store.js +0 -0
- package/dist/payload-codec/lib/blob-store.js.map +1 -0
- package/dist/payload-codec/lib/codec-context.d.ts +6 -0
- package/dist/payload-codec/lib/codec-context.d.ts.map +1 -0
- package/dist/payload-codec/lib/codec-context.js +16 -0
- package/dist/payload-codec/lib/codec-context.js.map +1 -0
- package/dist/payload-codec/lib/codec.d.ts +51 -0
- package/dist/payload-codec/lib/codec.d.ts.map +1 -0
- package/dist/payload-codec/lib/codec.js +330 -0
- package/dist/payload-codec/lib/codec.js.map +1 -0
- package/dist/payload-codec/lib/enums.d.ts +18 -0
- package/dist/payload-codec/lib/enums.d.ts.map +1 -0
- package/dist/payload-codec/lib/enums.js +23 -0
- package/dist/payload-codec/lib/enums.js.map +1 -0
- package/dist/payload-codec/lib/errors.d.ts +18 -0
- package/dist/payload-codec/lib/errors.d.ts.map +1 -0
- package/dist/payload-codec/lib/errors.js +39 -0
- package/dist/payload-codec/lib/errors.js.map +1 -0
- package/dist/payload-codec/lib/http-blob-store.d.ts +21 -0
- package/dist/payload-codec/lib/http-blob-store.d.ts.map +1 -0
- package/dist/payload-codec/lib/http-blob-store.js +139 -0
- package/dist/payload-codec/lib/http-blob-store.js.map +1 -0
- package/dist/payload-codec/lib/lru-cache.d.ts +12 -0
- package/dist/payload-codec/lib/lru-cache.d.ts.map +1 -0
- package/dist/payload-codec/lib/lru-cache.js +59 -0
- package/dist/payload-codec/lib/lru-cache.js.map +1 -0
- package/dist/schema/action.schema.json +181 -0
- package/dist/schema/reusable-workflow.schema.json +46 -0
- package/dist/schema/workflow.schema.json +373 -0
- package/dist/workflow/index.d.ts +14 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +49 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/lib/action-input-validator.d.ts +10 -0
- package/dist/workflow/lib/action-input-validator.d.ts.map +1 -0
- package/dist/workflow/lib/action-input-validator.js +69 -0
- package/dist/workflow/lib/action-input-validator.js.map +1 -0
- package/dist/workflow/lib/compiler/action-shape.d.ts +5 -0
- package/dist/workflow/lib/compiler/action-shape.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/action-shape.js +43 -0
- package/dist/workflow/lib/compiler/action-shape.js.map +1 -0
- package/dist/workflow/lib/compiler/canonical-json.d.ts +3 -0
- package/dist/workflow/lib/compiler/canonical-json.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/canonical-json.js +45 -0
- package/dist/workflow/lib/compiler/canonical-json.js.map +1 -0
- package/dist/workflow/lib/compiler/compile.d.ts +4 -0
- package/dist/workflow/lib/compiler/compile.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/compile.js +794 -0
- package/dist/workflow/lib/compiler/compile.js.map +1 -0
- package/dist/workflow/lib/compiler/concurrency.d.ts +5 -0
- package/dist/workflow/lib/compiler/concurrency.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/concurrency.js +104 -0
- package/dist/workflow/lib/compiler/concurrency.js.map +1 -0
- package/dist/workflow/lib/compiler/dag.d.ts +10 -0
- package/dist/workflow/lib/compiler/dag.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/dag.js +74 -0
- package/dist/workflow/lib/compiler/dag.js.map +1 -0
- package/dist/workflow/lib/compiler/index.d.ts +6 -0
- package/dist/workflow/lib/compiler/index.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/index.js +14 -0
- package/dist/workflow/lib/compiler/index.js.map +1 -0
- package/dist/workflow/lib/compiler/inputs.d.ts +4 -0
- package/dist/workflow/lib/compiler/inputs.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/inputs.js +108 -0
- package/dist/workflow/lib/compiler/inputs.js.map +1 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.d.ts +9 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.js +76 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.js.map +1 -0
- package/dist/workflow/lib/compiler/manifest-source.d.ts +4 -0
- package/dist/workflow/lib/compiler/manifest-source.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/manifest-source.js +100 -0
- package/dist/workflow/lib/compiler/manifest-source.js.map +1 -0
- package/dist/workflow/lib/compiler/matrix.d.ts +4 -0
- package/dist/workflow/lib/compiler/matrix.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/matrix.js +76 -0
- package/dist/workflow/lib/compiler/matrix.js.map +1 -0
- package/dist/workflow/lib/compiler/mount-plan.d.ts +4 -0
- package/dist/workflow/lib/compiler/mount-plan.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/mount-plan.js +96 -0
- package/dist/workflow/lib/compiler/mount-plan.js.map +1 -0
- package/dist/workflow/lib/compiler/payload-reach-in.d.ts +14 -0
- package/dist/workflow/lib/compiler/payload-reach-in.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/payload-reach-in.js +273 -0
- package/dist/workflow/lib/compiler/payload-reach-in.js.map +1 -0
- package/dist/workflow/lib/compiler/permissions.d.ts +6 -0
- package/dist/workflow/lib/compiler/permissions.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/permissions.js +43 -0
- package/dist/workflow/lib/compiler/permissions.js.map +1 -0
- package/dist/workflow/lib/compiler/retry-timeout.d.ts +6 -0
- package/dist/workflow/lib/compiler/retry-timeout.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/retry-timeout.js +64 -0
- package/dist/workflow/lib/compiler/retry-timeout.js.map +1 -0
- package/dist/workflow/lib/compiler/review-step.d.ts +18 -0
- package/dist/workflow/lib/compiler/review-step.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/review-step.js +247 -0
- package/dist/workflow/lib/compiler/review-step.js.map +1 -0
- package/dist/workflow/lib/compiler/types.d.ts +42 -0
- package/dist/workflow/lib/compiler/types.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/types.js +3 -0
- package/dist/workflow/lib/compiler/types.js.map +1 -0
- package/dist/workflow/lib/compiler/variable-requirements.d.ts +5 -0
- package/dist/workflow/lib/compiler/variable-requirements.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/variable-requirements.js +119 -0
- package/dist/workflow/lib/compiler/variable-requirements.js.map +1 -0
- package/dist/workflow/lib/deliverable-spec-keys.d.ts +3 -0
- package/dist/workflow/lib/deliverable-spec-keys.d.ts.map +1 -0
- package/dist/workflow/lib/deliverable-spec-keys.js +90 -0
- package/dist/workflow/lib/deliverable-spec-keys.js.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/index.d.ts +23 -0
- package/dist/workflow/lib/dispatch-inputs/index.d.ts.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/index.js +106 -0
- package/dist/workflow/lib/dispatch-inputs/index.js.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts +3 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.js +43 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.js.map +1 -0
- package/dist/workflow/lib/duration.d.ts +2 -0
- package/dist/workflow/lib/duration.d.ts.map +1 -0
- package/dist/workflow/lib/duration.js +26 -0
- package/dist/workflow/lib/duration.js.map +1 -0
- package/dist/workflow/lib/errors.d.ts +9 -0
- package/dist/workflow/lib/errors.d.ts.map +1 -0
- package/dist/workflow/lib/errors.js +28 -0
- package/dist/workflow/lib/errors.js.map +1 -0
- package/dist/workflow/lib/expression/ast.d.ts +61 -0
- package/dist/workflow/lib/expression/ast.d.ts.map +1 -0
- package/dist/workflow/lib/expression/ast.js +34 -0
- package/dist/workflow/lib/expression/ast.js.map +1 -0
- package/dist/workflow/lib/expression/context.d.ts +63 -0
- package/dist/workflow/lib/expression/context.d.ts.map +1 -0
- package/dist/workflow/lib/expression/context.js +32 -0
- package/dist/workflow/lib/expression/context.js.map +1 -0
- package/dist/workflow/lib/expression/evaluator.d.ts +5 -0
- package/dist/workflow/lib/expression/evaluator.d.ts.map +1 -0
- package/dist/workflow/lib/expression/evaluator.js +291 -0
- package/dist/workflow/lib/expression/evaluator.js.map +1 -0
- package/dist/workflow/lib/expression/index.d.ts +9 -0
- package/dist/workflow/lib/expression/index.d.ts.map +1 -0
- package/dist/workflow/lib/expression/index.js +26 -0
- package/dist/workflow/lib/expression/index.js.map +1 -0
- package/dist/workflow/lib/expression/interpolation.d.ts +9 -0
- package/dist/workflow/lib/expression/interpolation.d.ts.map +1 -0
- package/dist/workflow/lib/expression/interpolation.js +51 -0
- package/dist/workflow/lib/expression/interpolation.js.map +1 -0
- package/dist/workflow/lib/expression/parser.d.ts +4 -0
- package/dist/workflow/lib/expression/parser.d.ts.map +1 -0
- package/dist/workflow/lib/expression/parser.js +203 -0
- package/dist/workflow/lib/expression/parser.js.map +1 -0
- package/dist/workflow/lib/expression/template.d.ts +18 -0
- package/dist/workflow/lib/expression/template.d.ts.map +1 -0
- package/dist/workflow/lib/expression/template.js +63 -0
- package/dist/workflow/lib/expression/template.js.map +1 -0
- package/dist/workflow/lib/expression/tokenizer.d.ts +3 -0
- package/dist/workflow/lib/expression/tokenizer.d.ts.map +1 -0
- package/dist/workflow/lib/expression/tokenizer.js +153 -0
- package/dist/workflow/lib/expression/tokenizer.js.map +1 -0
- package/dist/workflow/lib/expression/tokens.d.ts +25 -0
- package/dist/workflow/lib/expression/tokens.d.ts.map +1 -0
- package/dist/workflow/lib/expression/tokens.js +24 -0
- package/dist/workflow/lib/expression/tokens.js.map +1 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.d.ts +5 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.d.ts.map +1 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.js +138 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.js.map +1 -0
- package/dist/workflow/lib/installation-resource-kind.d.ts +14 -0
- package/dist/workflow/lib/installation-resource-kind.d.ts.map +1 -0
- package/dist/workflow/lib/installation-resource-kind.js +59 -0
- package/dist/workflow/lib/installation-resource-kind.js.map +1 -0
- package/dist/workflow/lib/schemas-loader.d.ts +4 -0
- package/dist/workflow/lib/schemas-loader.d.ts.map +1 -0
- package/dist/workflow/lib/schemas-loader.js +36 -0
- package/dist/workflow/lib/schemas-loader.js.map +1 -0
- package/dist/workflow/lib/serializer.d.ts +3 -0
- package/dist/workflow/lib/serializer.d.ts.map +1 -0
- package/dist/workflow/lib/serializer.js +15 -0
- package/dist/workflow/lib/serializer.js.map +1 -0
- package/dist/workflow/lib/types.d.ts +179 -0
- package/dist/workflow/lib/types.d.ts.map +1 -0
- package/dist/workflow/lib/types.js +3 -0
- package/dist/workflow/lib/types.js.map +1 -0
- package/dist/workflow/lib/validate.d.ts +8 -0
- package/dist/workflow/lib/validate.d.ts.map +1 -0
- package/dist/workflow/lib/validate.js +119 -0
- package/dist/workflow/lib/validate.js.map +1 -0
- package/dist/workspace-manifest/index.d.ts +6 -0
- package/dist/workspace-manifest/index.d.ts.map +1 -0
- package/dist/workspace-manifest/index.js +22 -0
- package/dist/workspace-manifest/index.js.map +1 -0
- package/dist/workspace-manifest/lib/compile.d.ts +8 -0
- package/dist/workspace-manifest/lib/compile.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/compile.js +439 -0
- package/dist/workspace-manifest/lib/compile.js.map +1 -0
- package/dist/workspace-manifest/lib/interpolate.d.ts +12 -0
- package/dist/workspace-manifest/lib/interpolate.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/interpolate.js +81 -0
- package/dist/workspace-manifest/lib/interpolate.js.map +1 -0
- package/dist/workspace-manifest/lib/resolve-extends.d.ts +10 -0
- package/dist/workspace-manifest/lib/resolve-extends.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/resolve-extends.js +108 -0
- package/dist/workspace-manifest/lib/resolve-extends.js.map +1 -0
- package/dist/workspace-manifest/lib/schema.d.ts +710 -0
- package/dist/workspace-manifest/lib/schema.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/schema.js +355 -0
- package/dist/workspace-manifest/lib/schema.js.map +1 -0
- package/dist/workspace-manifest/lib/types.d.ts +153 -0
- package/dist/workspace-manifest/lib/types.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/types.js +10 -0
- package/dist/workspace-manifest/lib/types.js.map +1 -0
- package/package.json +79 -0
- package/schema/action.schema.json +181 -0
- package/schema/reusable-workflow.schema.json +46 -0
- package/schema/workflow.schema.json +373 -0
- package/src/deliverable-spec/index.ts +19 -0
- package/src/deliverable-spec/lib/schema.ts +248 -0
- package/src/deliverable-spec/lib/types.ts +26 -0
- package/src/payload-codec/index.ts +40 -0
- package/src/payload-codec/lib/blob-store.ts +0 -0
- package/src/payload-codec/lib/codec-context.ts +38 -0
- package/src/payload-codec/lib/codec.ts +593 -0
- package/src/payload-codec/lib/enums.ts +58 -0
- package/src/payload-codec/lib/errors.ts +54 -0
- package/src/payload-codec/lib/http-blob-store.ts +257 -0
- package/src/payload-codec/lib/lru-cache.ts +81 -0
- package/src/workflow/index.ts +98 -0
- package/src/workflow/lib/action-input-validator.ts +160 -0
- package/src/workflow/lib/compiler/action-shape.ts +71 -0
- package/src/workflow/lib/compiler/canonical-json.ts +53 -0
- package/src/workflow/lib/compiler/compile.ts +1518 -0
- package/src/workflow/lib/compiler/concurrency.ts +223 -0
- package/src/workflow/lib/compiler/dag.ts +108 -0
- package/src/workflow/lib/compiler/index.ts +10 -0
- package/src/workflow/lib/compiler/inputs.ts +199 -0
- package/src/workflow/lib/compiler/installation-resource-validator.ts +114 -0
- package/src/workflow/lib/compiler/manifest-source.ts +176 -0
- package/src/workflow/lib/compiler/matrix.ts +135 -0
- package/src/workflow/lib/compiler/mount-plan.ts +202 -0
- package/src/workflow/lib/compiler/payload-reach-in.ts +497 -0
- package/src/workflow/lib/compiler/permissions.ts +64 -0
- package/src/workflow/lib/compiler/retry-timeout.ts +105 -0
- package/src/workflow/lib/compiler/review-step.ts +517 -0
- package/src/workflow/lib/compiler/types.ts +170 -0
- package/src/workflow/lib/compiler/variable-requirements.ts +208 -0
- package/src/workflow/lib/deliverable-spec-keys.ts +109 -0
- package/src/workflow/lib/dispatch-inputs/index.ts +160 -0
- package/src/workflow/lib/dispatch-inputs/to-json-schema.ts +60 -0
- package/src/workflow/lib/duration.ts +48 -0
- package/src/workflow/lib/errors.ts +37 -0
- package/src/workflow/lib/expression/ast.ts +108 -0
- package/src/workflow/lib/expression/context.ts +148 -0
- package/src/workflow/lib/expression/evaluator.ts +492 -0
- package/src/workflow/lib/expression/index.ts +28 -0
- package/src/workflow/lib/expression/interpolation.ts +84 -0
- package/src/workflow/lib/expression/parser.ts +264 -0
- package/src/workflow/lib/expression/template.ts +117 -0
- package/src/workflow/lib/expression/tokenizer.ts +200 -0
- package/src/workflow/lib/expression/tokens.ts +30 -0
- package/src/workflow/lib/expression/walk-artifact-refs.ts +232 -0
- package/src/workflow/lib/installation-resource-kind.ts +107 -0
- package/src/workflow/lib/schemas-loader.ts +64 -0
- package/src/workflow/lib/serializer.ts +30 -0
- package/src/workflow/lib/types.ts +361 -0
- package/src/workflow/lib/validate.ts +199 -0
- package/src/workspace-manifest/index.ts +27 -0
- package/src/workspace-manifest/lib/compile.ts +608 -0
- package/src/workspace-manifest/lib/interpolate.ts +140 -0
- package/src/workspace-manifest/lib/resolve-extends.ts +260 -0
- package/src/workspace-manifest/lib/schema.ts +612 -0
- package/src/workspace-manifest/lib/types.ts +392 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
4
|
+
// ── Zod schemas for `manifest.yaml` (deliverable-spec) ──
|
|
5
|
+
//
|
|
6
|
+
// Single source of truth: the deliverable-specs-api seeder validates each
|
|
7
|
+
// biome-shipped manifest with `DeliverableSpecManifestSchema.parse(…)`,
|
|
8
|
+
// and the schemas controller serves `z.toJSONSchema(…)` at
|
|
9
|
+
// `https://xema.dev/schemas/deliverable/v1/DeliverableSpec.json`. Authors
|
|
10
|
+
// point Monaco / IDE YAML extensions at the served URL via
|
|
11
|
+
// `# yaml-language-server: $schema=…`.
|
|
12
|
+
//
|
|
13
|
+
// Envelope shape mirrors workflow.yaml + workspace-manifest.yaml:
|
|
14
|
+
// apiVersion: xema.dev/deliverable/v1
|
|
15
|
+
// kind: DeliverableSpec | DeliverableSpecOverlay
|
|
16
|
+
// metadata: { slug, version, title, description? } (overlay: slug, title)
|
|
17
|
+
// spec: { kind, category, …, content?, pages?, … }
|
|
18
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
|
+
|
|
20
|
+
// Kebab-case slug, optionally namespaced (`foo-bar` or `family/leaf`).
|
|
21
|
+
const SlugRegex = /^[a-z][a-z0-9-]*(?:\/[a-z][a-z0-9-]*)?$/;
|
|
22
|
+
const VersionRegex = /^\d+\.\d+\.\d+$/;
|
|
23
|
+
const KebabRegex = /^[a-z][a-z0-9-]*$/;
|
|
24
|
+
// Overlay slugs are composed keys joining a stack/concern token to one
|
|
25
|
+
// or more spec categories with `+` (e.g.
|
|
26
|
+
// `react-architecture+api-design`). Lowercase alphanumerics, `-`, `+`.
|
|
27
|
+
const OverlaySlugRegex = /^[a-z][a-z0-9-]*(?:\+[a-z][a-z0-9-]*)*$/;
|
|
28
|
+
// Tag values are lowercase alphanumerics with `-`, `_`, `.` allowed
|
|
29
|
+
// (e.g. `tensorflow`, `python-3.12`).
|
|
30
|
+
const TagSlugRegex = /^[a-z0-9][a-z0-9-_.]*$/;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Closed set of deliverable kinds (the inner kind enum on `spec.kind` —
|
|
34
|
+
* NOT to be confused with the envelope `kind: DeliverableSpec`). Mirrors
|
|
35
|
+
* `DeliverableSpecKind` in
|
|
36
|
+
* `biomes/workflow-runtime/api/deliverable-specs-api/src/deliverable-specs/dto/deliverable-spec-enums.ts`
|
|
37
|
+
* — the wire values must stay byte-identical because they're persisted
|
|
38
|
+
* verbatim to `DeliverableSpec.kind`.
|
|
39
|
+
*/
|
|
40
|
+
export const DELIVERABLE_SPEC_KINDS = [
|
|
41
|
+
'DOCUMENT_TEMPLATE',
|
|
42
|
+
'ZOD_SCHEMA',
|
|
43
|
+
'JSON_SCHEMA',
|
|
44
|
+
'ENDPOINT_FETCH',
|
|
45
|
+
'STRUCTURED_JSON',
|
|
46
|
+
'CUSTOM',
|
|
47
|
+
'RESPONSE_ONLY',
|
|
48
|
+
] as const;
|
|
49
|
+
|
|
50
|
+
export type DeliverableSpecKindLiteral = (typeof DELIVERABLE_SPEC_KINDS)[number];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Closed set of artifact-versioning modes accepted by the harvester.
|
|
54
|
+
* Mirrors `ArtifactVersioningMode` in `@xemahq/platform-common` — kept as
|
|
55
|
+
* a string-literal trio here to keep this package free of platform deps.
|
|
56
|
+
*/
|
|
57
|
+
export const VERSIONING_MODES = ['append', 'new', 'replace'] as const;
|
|
58
|
+
|
|
59
|
+
export type VersioningModeLiteral = (typeof VERSIONING_MODES)[number];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Inline page entry — body is generated by the agent at run time from
|
|
63
|
+
* `slug`/`title` alone. Stored as `{slug, title, parentSlug, content: null}`
|
|
64
|
+
* in `DeliverableSpec.pages`.
|
|
65
|
+
*/
|
|
66
|
+
export const InlinePageSourceSchema = z.object({
|
|
67
|
+
slug: z.string().regex(KebabRegex, 'page slug must be kebab-case'),
|
|
68
|
+
title: z.string().min(1).max(200),
|
|
69
|
+
parentSlug: z
|
|
70
|
+
.string()
|
|
71
|
+
.regex(KebabRegex)
|
|
72
|
+
.nullable()
|
|
73
|
+
.optional(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* File-backed page entry — the seeder reads `<file>` relative to the
|
|
78
|
+
* manifest, parses YAML frontmatter for `slug`/`title`/`parentSlug`, and
|
|
79
|
+
* stores the remaining markdown body as `content`.
|
|
80
|
+
*/
|
|
81
|
+
export const FilePageSourceSchema = z.object({
|
|
82
|
+
file: z.string().min(1),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const PageSourceSchema = z.union([
|
|
86
|
+
InlinePageSourceSchema,
|
|
87
|
+
FilePageSourceSchema,
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
const TargetSlotRegex = /^(?:deliverables\/|repos\/[a-z0-9][a-z0-9-_]*\/)$/;
|
|
91
|
+
|
|
92
|
+
// ─── Envelope: DeliverableSpec ──────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
export const DeliverableSpecMetadataSchema = z.object({
|
|
95
|
+
slug: z
|
|
96
|
+
.string()
|
|
97
|
+
.min(1)
|
|
98
|
+
.max(150)
|
|
99
|
+
.regex(
|
|
100
|
+
SlugRegex,
|
|
101
|
+
'slug must be kebab-case (`foo-bar`) or kebab/kebab (`family/leaf`)',
|
|
102
|
+
),
|
|
103
|
+
version: z
|
|
104
|
+
.string()
|
|
105
|
+
.regex(VersionRegex, 'version must be strict semver (MAJOR.MINOR.PATCH)'),
|
|
106
|
+
title: z.string().min(1).max(200),
|
|
107
|
+
description: z.string().max(4000).optional(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const DeliverableSpecSpecSchema = z
|
|
111
|
+
.object({
|
|
112
|
+
kind: z.enum(DELIVERABLE_SPEC_KINDS),
|
|
113
|
+
category: z.string().regex(KebabRegex, 'category must be kebab-case').max(80),
|
|
114
|
+
complexity: z
|
|
115
|
+
.string()
|
|
116
|
+
.regex(KebabRegex, 'complexity must be kebab-case')
|
|
117
|
+
.optional(),
|
|
118
|
+
tags: z.array(z.string()).max(20).optional(),
|
|
119
|
+
phases: z.array(z.string()).max(20).optional(),
|
|
120
|
+
workTypes: z.array(z.string()).max(20).optional(),
|
|
121
|
+
|
|
122
|
+
// Authoritative body for DOCUMENT_TEMPLATE / JSON_SCHEMA /
|
|
123
|
+
// STRUCTURED_JSON / CUSTOM / RESPONSE_ONLY. Mutually exclusive with
|
|
124
|
+
// `contentFile` (the seeder reads the file relative to manifest.yaml
|
|
125
|
+
// when `contentFile` is set).
|
|
126
|
+
content: z.string().max(1_000_000).optional(),
|
|
127
|
+
contentFile: z.string().min(1).optional(),
|
|
128
|
+
|
|
129
|
+
multiPage: z.boolean().optional(),
|
|
130
|
+
pages: z.array(PageSourceSchema).max(64).optional(),
|
|
131
|
+
|
|
132
|
+
pageAllocationHints: z.record(z.string(), z.unknown()).optional(),
|
|
133
|
+
topologySchema: z.record(z.string(), z.unknown()).optional(),
|
|
134
|
+
sectionGuidance: z.record(z.string(), z.unknown()).optional(),
|
|
135
|
+
scope: z.record(z.string(), z.unknown()).optional(),
|
|
136
|
+
reviewDimensions: z.array(z.unknown()).optional(),
|
|
137
|
+
standards: z.array(z.unknown()).optional(),
|
|
138
|
+
|
|
139
|
+
// ZOD_SCHEMA-specific. Mutually exclusive with `zodSchemaSourceFile`.
|
|
140
|
+
zodSchemaSource: z.string().max(200_000).optional(),
|
|
141
|
+
zodSchemaSourceFile: z.string().min(1).optional(),
|
|
142
|
+
|
|
143
|
+
// ENDPOINT_FETCH-specific. Shape matches `EndpointFetchSpec` in
|
|
144
|
+
// `@xemahq/kernel-contracts/agent-workspace` — kept as an open record here
|
|
145
|
+
// to avoid a cross-package dependency; the activity validates the
|
|
146
|
+
// detailed shape at run time.
|
|
147
|
+
fetchSpec: z.record(z.string(), z.unknown()).optional(),
|
|
148
|
+
|
|
149
|
+
assets: z.array(z.unknown()).optional(),
|
|
150
|
+
rules: z.record(z.string(), z.unknown()).optional(),
|
|
151
|
+
|
|
152
|
+
targetSlot: z
|
|
153
|
+
.string()
|
|
154
|
+
.regex(
|
|
155
|
+
TargetSlotRegex,
|
|
156
|
+
"targetSlot must be 'deliverables/' or 'repos/<slug>/'",
|
|
157
|
+
)
|
|
158
|
+
.optional(),
|
|
159
|
+
|
|
160
|
+
versioningMode: z.enum(VERSIONING_MODES).optional(),
|
|
161
|
+
})
|
|
162
|
+
.refine(
|
|
163
|
+
(s) => !(s.content !== undefined && s.contentFile !== undefined),
|
|
164
|
+
{ message: 'spec cannot declare both `content` and `contentFile`' },
|
|
165
|
+
)
|
|
166
|
+
.refine(
|
|
167
|
+
(s) =>
|
|
168
|
+
!(s.zodSchemaSource !== undefined && s.zodSchemaSourceFile !== undefined),
|
|
169
|
+
{
|
|
170
|
+
message:
|
|
171
|
+
'spec cannot declare both `zodSchemaSource` and `zodSchemaSourceFile`',
|
|
172
|
+
},
|
|
173
|
+
)
|
|
174
|
+
.refine(
|
|
175
|
+
(s) =>
|
|
176
|
+
!(s.multiPage === true && (s.pages === undefined || s.pages.length === 0)),
|
|
177
|
+
{ message: 'multiPage=true requires non-empty `pages[]`' },
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
export const DeliverableSpecManifestSchema = z
|
|
181
|
+
.object({
|
|
182
|
+
apiVersion: z.literal('xema.dev/deliverable/v1'),
|
|
183
|
+
kind: z.literal('DeliverableSpec'),
|
|
184
|
+
metadata: DeliverableSpecMetadataSchema,
|
|
185
|
+
spec: DeliverableSpecSpecSchema,
|
|
186
|
+
})
|
|
187
|
+
.meta({
|
|
188
|
+
id: 'https://xema.dev/schemas/deliverable/v1/DeliverableSpec.json',
|
|
189
|
+
title: 'Xema DeliverableSpec',
|
|
190
|
+
description:
|
|
191
|
+
'Biome-shipped catalog row defining a deliverable kind, content body, page layout, and validator parameters.',
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ─── Envelope: DeliverableSpecOverlay ───────────────────────────────────
|
|
195
|
+
|
|
196
|
+
export const DeliverableSpecOverlayMetadataSchema = z.object({
|
|
197
|
+
slug: z
|
|
198
|
+
.string()
|
|
199
|
+
.min(1)
|
|
200
|
+
.max(150)
|
|
201
|
+
.regex(
|
|
202
|
+
OverlaySlugRegex,
|
|
203
|
+
'overlay slug must be kebab tokens joined with `+` (e.g. `react-architecture+api-design`)',
|
|
204
|
+
),
|
|
205
|
+
title: z.string().min(1).max(200),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export const DeliverableSpecOverlaySpecSchema = z
|
|
209
|
+
.object({
|
|
210
|
+
tagCategory: z
|
|
211
|
+
.string()
|
|
212
|
+
.min(1)
|
|
213
|
+
.max(80)
|
|
214
|
+
.regex(KebabRegex, 'tagCategory must be kebab-case'),
|
|
215
|
+
tagValue: z
|
|
216
|
+
.string()
|
|
217
|
+
.min(1)
|
|
218
|
+
.max(200)
|
|
219
|
+
.regex(
|
|
220
|
+
TagSlugRegex,
|
|
221
|
+
'tagValue must be a slug (lowercase alphanumerics, `+ . - _` allowed)',
|
|
222
|
+
),
|
|
223
|
+
specCategories: z.array(z.string()).max(40).optional(),
|
|
224
|
+
content: z.string().max(1_000_000).optional(),
|
|
225
|
+
contentFile: z.string().min(1).optional(),
|
|
226
|
+
priority: z.number().int().min(0).max(1000).optional(),
|
|
227
|
+
})
|
|
228
|
+
.refine((s) => s.content !== undefined || s.contentFile !== undefined, {
|
|
229
|
+
message: 'spec must declare either `content` or `contentFile`',
|
|
230
|
+
})
|
|
231
|
+
.refine(
|
|
232
|
+
(s) => !(s.content !== undefined && s.contentFile !== undefined),
|
|
233
|
+
{ message: 'spec cannot declare both `content` and `contentFile`' },
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
export const DeliverableSpecOverlayManifestSchema = z
|
|
237
|
+
.object({
|
|
238
|
+
apiVersion: z.literal('xema.dev/deliverable/v1'),
|
|
239
|
+
kind: z.literal('DeliverableSpecOverlay'),
|
|
240
|
+
metadata: DeliverableSpecOverlayMetadataSchema,
|
|
241
|
+
spec: DeliverableSpecOverlaySpecSchema,
|
|
242
|
+
})
|
|
243
|
+
.meta({
|
|
244
|
+
id: 'https://xema.dev/schemas/deliverable/v1/DeliverableSpecOverlay.json',
|
|
245
|
+
title: 'Xema DeliverableSpecOverlay',
|
|
246
|
+
description:
|
|
247
|
+
'Tag-driven overlay that appends to a base spec\'s content when the render context\'s tags[] includes tagValue.',
|
|
248
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DeliverableSpecManifestSchema,
|
|
5
|
+
DeliverableSpecOverlayManifestSchema,
|
|
6
|
+
FilePageSourceSchema,
|
|
7
|
+
InlinePageSourceSchema,
|
|
8
|
+
PageSourceSchema,
|
|
9
|
+
} from './schema';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TypeScript types inferred from the Zod schemas. Consumers prefer these
|
|
13
|
+
* over the schemas themselves at compile time so refactors of the shape
|
|
14
|
+
* surface as type errors at every call site.
|
|
15
|
+
*/
|
|
16
|
+
export type DeliverableSpecManifest = z.infer<
|
|
17
|
+
typeof DeliverableSpecManifestSchema
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type DeliverableSpecOverlayManifest = z.infer<
|
|
21
|
+
typeof DeliverableSpecOverlayManifestSchema
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type InlinePageSource = z.infer<typeof InlinePageSourceSchema>;
|
|
25
|
+
export type FilePageSource = z.infer<typeof FilePageSourceSchema>;
|
|
26
|
+
export type PageSource = z.infer<typeof PageSourceSchema>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// workflow-payload-codec — Temporal PayloadCodec that transparently spills
|
|
3
|
+
// large payloads to a content-addressed BlobStore (artifact-store-api in
|
|
4
|
+
// prod; in-memory in tests). Register this codec on the Client AND on the
|
|
5
|
+
// Worker — both sides must decode the envelope symmetrically.
|
|
6
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
BlobStoreKind,
|
|
10
|
+
DEFAULT_CACHE_CAPACITY_BYTES,
|
|
11
|
+
DEFAULT_SPILL_THRESHOLD_BYTES,
|
|
12
|
+
SPILL_ENCODING_V1,
|
|
13
|
+
SPILL_ENVELOPE_VERSION,
|
|
14
|
+
SpillMetadataKey,
|
|
15
|
+
} from './lib/enums';
|
|
16
|
+
export {
|
|
17
|
+
PayloadCodecError,
|
|
18
|
+
PayloadCodecErrorCode,
|
|
19
|
+
isPayloadCodecError,
|
|
20
|
+
} from './lib/errors';
|
|
21
|
+
export {
|
|
22
|
+
InMemoryBlobStore,
|
|
23
|
+
sha256Hex,
|
|
24
|
+
type BlobRef,
|
|
25
|
+
type BlobStore,
|
|
26
|
+
type StoredBlob,
|
|
27
|
+
} from './lib/blob-store';
|
|
28
|
+
export { HttpBlobStore, type HttpBlobStoreOptions } from './lib/http-blob-store';
|
|
29
|
+
export { BytesLruCache } from './lib/lru-cache';
|
|
30
|
+
export {
|
|
31
|
+
SpillPayloadCodec,
|
|
32
|
+
type SpillPayloadCodecOptions,
|
|
33
|
+
type CodecLifecycleEvent,
|
|
34
|
+
type CodecObserver,
|
|
35
|
+
} from './lib/codec';
|
|
36
|
+
export {
|
|
37
|
+
getCodecOrgId,
|
|
38
|
+
runWithCodecOrgId,
|
|
39
|
+
type CodecContext,
|
|
40
|
+
} from './lib/codec-context';
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Per-call codec context. Wrapping a Temporal client invocation in
|
|
5
|
+
* {@link runWithCodecOrgId} lets the {@link SpillPayloadCodec}'s
|
|
6
|
+
* `orgIdProvider` resolve the right tenant for blob writes:
|
|
7
|
+
*
|
|
8
|
+
* await runWithCodecOrgId(run.orgId, () =>
|
|
9
|
+
* client.workflow.start('rootRunWorkflow', { args, ... }),
|
|
10
|
+
* );
|
|
11
|
+
*
|
|
12
|
+
* The engine establishes this around every `client.workflow.*` call so the
|
|
13
|
+
* codec can stamp `X-Org-Id` on its blob-store traffic. The decode side
|
|
14
|
+
* does NOT depend on this context — orgId rides inside the spill envelope.
|
|
15
|
+
*
|
|
16
|
+
* Workers don't typically use this ALS for codec calls (the worker reads
|
|
17
|
+
* orgId from the active activity-auth-context or a fallback env var) but
|
|
18
|
+
* the helpers are exported for symmetry.
|
|
19
|
+
*/
|
|
20
|
+
export interface CodecContext {
|
|
21
|
+
readonly orgId: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const storage = new AsyncLocalStorage<CodecContext>();
|
|
25
|
+
|
|
26
|
+
export function getCodecOrgId(): string | undefined {
|
|
27
|
+
return storage.getStore()?.orgId;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function runWithCodecOrgId<T>(
|
|
31
|
+
orgId: string,
|
|
32
|
+
fn: () => Promise<T>,
|
|
33
|
+
): Promise<T> {
|
|
34
|
+
if (typeof orgId !== 'string' || orgId.length === 0) {
|
|
35
|
+
throw new Error('runWithCodecOrgId: orgId must be a non-empty string.');
|
|
36
|
+
}
|
|
37
|
+
return storage.run({ orgId }, fn);
|
|
38
|
+
}
|