@sequenceholdings/pipeline-spec 0.1.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.
Files changed (126) hide show
  1. package/README.md +114 -0
  2. package/dist/authoring/per-table-ingestion.d.ts +74 -0
  3. package/dist/authoring/per-table-ingestion.d.ts.map +1 -0
  4. package/dist/authoring/per-table-ingestion.js +122 -0
  5. package/dist/authoring/per-table-ingestion.js.map +1 -0
  6. package/dist/authoring/yaml.d.ts +6 -0
  7. package/dist/authoring/yaml.d.ts.map +1 -0
  8. package/dist/authoring/yaml.js +15 -0
  9. package/dist/authoring/yaml.js.map +1 -0
  10. package/dist/binding-gaps.d.ts +21 -0
  11. package/dist/binding-gaps.d.ts.map +1 -0
  12. package/dist/binding-gaps.js +74 -0
  13. package/dist/binding-gaps.js.map +1 -0
  14. package/dist/bodies/ingestion.d.ts +359 -0
  15. package/dist/bodies/ingestion.d.ts.map +1 -0
  16. package/dist/bodies/ingestion.js +446 -0
  17. package/dist/bodies/ingestion.js.map +1 -0
  18. package/dist/bodies/serving.d.ts +316 -0
  19. package/dist/bodies/serving.d.ts.map +1 -0
  20. package/dist/bodies/serving.js +290 -0
  21. package/dist/bodies/serving.js.map +1 -0
  22. package/dist/bodies/transformation.d.ts +397 -0
  23. package/dist/bodies/transformation.d.ts.map +1 -0
  24. package/dist/bodies/transformation.js +278 -0
  25. package/dist/bodies/transformation.js.map +1 -0
  26. package/dist/catalog-binding.d.ts +15 -0
  27. package/dist/catalog-binding.d.ts.map +1 -0
  28. package/dist/catalog-binding.js +15 -0
  29. package/dist/catalog-binding.js.map +1 -0
  30. package/dist/columns.d.ts +177 -0
  31. package/dist/columns.d.ts.map +1 -0
  32. package/dist/columns.js +89 -0
  33. package/dist/columns.js.map +1 -0
  34. package/dist/compatibility.d.ts +25 -0
  35. package/dist/compatibility.d.ts.map +1 -0
  36. package/dist/compatibility.js +108 -0
  37. package/dist/compatibility.js.map +1 -0
  38. package/dist/constants.d.ts +95 -0
  39. package/dist/constants.d.ts.map +1 -0
  40. package/dist/constants.js +105 -0
  41. package/dist/constants.js.map +1 -0
  42. package/dist/diff.d.ts +36 -0
  43. package/dist/diff.d.ts.map +1 -0
  44. package/dist/diff.js +300 -0
  45. package/dist/diff.js.map +1 -0
  46. package/dist/documentation.d.ts +22 -0
  47. package/dist/documentation.d.ts.map +1 -0
  48. package/dist/documentation.js +43 -0
  49. package/dist/documentation.js.map +1 -0
  50. package/dist/envelope.d.ts +1241 -0
  51. package/dist/envelope.d.ts.map +1 -0
  52. package/dist/envelope.js +163 -0
  53. package/dist/envelope.js.map +1 -0
  54. package/dist/errors.d.ts +30 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/errors.js +47 -0
  57. package/dist/errors.js.map +1 -0
  58. package/dist/graph-references.d.ts +34 -0
  59. package/dist/graph-references.d.ts.map +1 -0
  60. package/dist/graph-references.js +81 -0
  61. package/dist/graph-references.js.map +1 -0
  62. package/dist/graph.d.ts +112 -0
  63. package/dist/graph.d.ts.map +1 -0
  64. package/dist/graph.js +546 -0
  65. package/dist/graph.js.map +1 -0
  66. package/dist/hash.d.ts +28 -0
  67. package/dist/hash.d.ts.map +1 -0
  68. package/dist/hash.js +91 -0
  69. package/dist/hash.js.map +1 -0
  70. package/dist/index.d.ts +27 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +27 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/issues.d.ts +14 -0
  75. package/dist/issues.d.ts.map +1 -0
  76. package/dist/issues.js +27 -0
  77. package/dist/issues.js.map +1 -0
  78. package/dist/loader.d.ts +50 -0
  79. package/dist/loader.d.ts.map +1 -0
  80. package/dist/loader.js +241 -0
  81. package/dist/loader.js.map +1 -0
  82. package/dist/migrations/contracts.d.ts +38 -0
  83. package/dist/migrations/contracts.d.ts.map +1 -0
  84. package/dist/migrations/contracts.js +175 -0
  85. package/dist/migrations/contracts.js.map +1 -0
  86. package/dist/migrations/manifest.d.ts +137 -0
  87. package/dist/migrations/manifest.d.ts.map +1 -0
  88. package/dist/migrations/manifest.js +137 -0
  89. package/dist/migrations/manifest.js.map +1 -0
  90. package/dist/operations.d.ts +214 -0
  91. package/dist/operations.d.ts.map +1 -0
  92. package/dist/operations.js +275 -0
  93. package/dist/operations.js.map +1 -0
  94. package/dist/orm-satisfies.d.ts +132 -0
  95. package/dist/orm-satisfies.d.ts.map +1 -0
  96. package/dist/orm-satisfies.js +119 -0
  97. package/dist/orm-satisfies.js.map +1 -0
  98. package/dist/primitives.d.ts +11 -0
  99. package/dist/primitives.d.ts.map +1 -0
  100. package/dist/primitives.js +20 -0
  101. package/dist/primitives.js.map +1 -0
  102. package/dist/resolve.d.ts +124 -0
  103. package/dist/resolve.d.ts.map +1 -0
  104. package/dist/resolve.js +194 -0
  105. package/dist/resolve.js.map +1 -0
  106. package/dist/secret-scan.d.ts +34 -0
  107. package/dist/secret-scan.d.ts.map +1 -0
  108. package/dist/secret-scan.js +98 -0
  109. package/dist/secret-scan.js.map +1 -0
  110. package/dist/serving-compatibility.d.ts +14 -0
  111. package/dist/serving-compatibility.d.ts.map +1 -0
  112. package/dist/serving-compatibility.js +19 -0
  113. package/dist/serving-compatibility.js.map +1 -0
  114. package/dist/snapshot-transport.d.ts +83 -0
  115. package/dist/snapshot-transport.d.ts.map +1 -0
  116. package/dist/snapshot-transport.js +42 -0
  117. package/dist/snapshot-transport.js.map +1 -0
  118. package/dist/suggestions.d.ts +3 -0
  119. package/dist/suggestions.d.ts.map +1 -0
  120. package/dist/suggestions.js +26 -0
  121. package/dist/suggestions.js.map +1 -0
  122. package/dist/types.d.ts +72 -0
  123. package/dist/types.d.ts.map +1 -0
  124. package/dist/types.js +119 -0
  125. package/dist/types.js.map +1 -0
  126. package/package.json +52 -0
@@ -0,0 +1,214 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Operations are named, parameterized entry points on a stage — the successor
4
+ * to Data Sync's run operations, governed by "ad-hoc invocation, never ad-hoc
5
+ * code". The platform reserves `backfill`, `replay`, `sample`, and
6
+ * `live-source-run`; author-declared operations may not shadow them.
7
+ */
8
+ /** Scalar parameter types — the column scalar vocabulary minus contract-only shapes. */
9
+ export declare const OPERATION_SCALAR_TYPES: readonly ["string", "int", "long", "numeric", "double", "boolean", "timestamp", "date", "uuid"];
10
+ export type OperationScalarType = (typeof OPERATION_SCALAR_TYPES)[number];
11
+ /**
12
+ * A typed parameter declaration. Invocations are validated against this shape
13
+ * before enqueue (see `validateOperationParams`) — same posture as Data
14
+ * Sync's paramsSchema coercion: it is impossible to declare an operation that
15
+ * accepts arbitrary unvalidated input.
16
+ */
17
+ export declare const operationParamSchema: z.ZodUnion<readonly [z.ZodObject<{
18
+ type: z.ZodLiteral<"enum">;
19
+ description: z.ZodOptional<z.ZodString>;
20
+ values: z.ZodArray<z.ZodString>;
21
+ optional: z.ZodDefault<z.ZodBoolean>;
22
+ default: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ type: z.ZodLiteral<"array">;
25
+ description: z.ZodOptional<z.ZodString>;
26
+ items: z.ZodEnum<{
27
+ string: "string";
28
+ boolean: "boolean";
29
+ uuid: "uuid";
30
+ int: "int";
31
+ long: "long";
32
+ numeric: "numeric";
33
+ double: "double";
34
+ timestamp: "timestamp";
35
+ date: "date";
36
+ }>;
37
+ optional: z.ZodDefault<z.ZodBoolean>;
38
+ default: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
39
+ min_items: z.ZodOptional<z.ZodNumber>;
40
+ max_items: z.ZodOptional<z.ZodNumber>;
41
+ }, z.core.$strict>, z.ZodObject<{
42
+ type: z.ZodEnum<{
43
+ string: "string";
44
+ boolean: "boolean";
45
+ uuid: "uuid";
46
+ int: "int";
47
+ long: "long";
48
+ numeric: "numeric";
49
+ double: "double";
50
+ timestamp: "timestamp";
51
+ date: "date";
52
+ }>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ optional: z.ZodDefault<z.ZodBoolean>;
55
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
56
+ }, z.core.$strict>]>;
57
+ export type OperationParam = z.infer<typeof operationParamSchema>;
58
+ /**
59
+ * Concurrency / safety posture of an operation. Also reused verbatim by
60
+ * ingestion `schedule` blocks — the policy vocabulary lands in the SDK once.
61
+ *
62
+ * Enforcement lives with the run infrastructure (registry / enqueue route) —
63
+ * the spec only declares the policy.
64
+ */
65
+ export declare const operationPolicySchema: z.ZodObject<{
66
+ singleton: z.ZodOptional<z.ZodBoolean>;
67
+ exclusion_group: z.ZodOptional<z.ZodString>;
68
+ timeout_minutes: z.ZodOptional<z.ZodNumber>;
69
+ mutates: z.ZodOptional<z.ZodBoolean>;
70
+ cooldown_minutes: z.ZodOptional<z.ZodNumber>;
71
+ requires_approval: z.ZodOptional<z.ZodBoolean>;
72
+ }, z.core.$strict>;
73
+ export type OperationPolicy = z.infer<typeof operationPolicySchema>;
74
+ /** Operation names are kebab/snake slugs; reserved platform verbs are rejected. */
75
+ export declare const operationNameSchema: z.ZodString;
76
+ export declare const operationSchema: z.ZodObject<{
77
+ description: z.ZodString;
78
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
79
+ type: z.ZodLiteral<"enum">;
80
+ description: z.ZodOptional<z.ZodString>;
81
+ values: z.ZodArray<z.ZodString>;
82
+ optional: z.ZodDefault<z.ZodBoolean>;
83
+ default: z.ZodOptional<z.ZodString>;
84
+ }, z.core.$strict>, z.ZodObject<{
85
+ type: z.ZodLiteral<"array">;
86
+ description: z.ZodOptional<z.ZodString>;
87
+ items: z.ZodEnum<{
88
+ string: "string";
89
+ boolean: "boolean";
90
+ uuid: "uuid";
91
+ int: "int";
92
+ long: "long";
93
+ numeric: "numeric";
94
+ double: "double";
95
+ timestamp: "timestamp";
96
+ date: "date";
97
+ }>;
98
+ optional: z.ZodDefault<z.ZodBoolean>;
99
+ default: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
100
+ min_items: z.ZodOptional<z.ZodNumber>;
101
+ max_items: z.ZodOptional<z.ZodNumber>;
102
+ }, z.core.$strict>, z.ZodObject<{
103
+ type: z.ZodEnum<{
104
+ string: "string";
105
+ boolean: "boolean";
106
+ uuid: "uuid";
107
+ int: "int";
108
+ long: "long";
109
+ numeric: "numeric";
110
+ double: "double";
111
+ timestamp: "timestamp";
112
+ date: "date";
113
+ }>;
114
+ description: z.ZodOptional<z.ZodString>;
115
+ optional: z.ZodDefault<z.ZodBoolean>;
116
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
117
+ }, z.core.$strict>]>>>;
118
+ policy: z.ZodDefault<z.ZodObject<{
119
+ singleton: z.ZodOptional<z.ZodBoolean>;
120
+ exclusion_group: z.ZodOptional<z.ZodString>;
121
+ timeout_minutes: z.ZodOptional<z.ZodNumber>;
122
+ mutates: z.ZodOptional<z.ZodBoolean>;
123
+ cooldown_minutes: z.ZodOptional<z.ZodNumber>;
124
+ requires_approval: z.ZodOptional<z.ZodBoolean>;
125
+ }, z.core.$strict>>;
126
+ entrypoint: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strict>;
128
+ export type OperationSpec = z.infer<typeof operationSchema>;
129
+ /**
130
+ * The envelope `operations:` block. Reserved platform names are rejected here
131
+ * so the error lands on the offending key.
132
+ */
133
+ export declare const operationsBlockSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
134
+ description: z.ZodString;
135
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
136
+ type: z.ZodLiteral<"enum">;
137
+ description: z.ZodOptional<z.ZodString>;
138
+ values: z.ZodArray<z.ZodString>;
139
+ optional: z.ZodDefault<z.ZodBoolean>;
140
+ default: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ type: z.ZodLiteral<"array">;
143
+ description: z.ZodOptional<z.ZodString>;
144
+ items: z.ZodEnum<{
145
+ string: "string";
146
+ boolean: "boolean";
147
+ uuid: "uuid";
148
+ int: "int";
149
+ long: "long";
150
+ numeric: "numeric";
151
+ double: "double";
152
+ timestamp: "timestamp";
153
+ date: "date";
154
+ }>;
155
+ optional: z.ZodDefault<z.ZodBoolean>;
156
+ default: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
157
+ min_items: z.ZodOptional<z.ZodNumber>;
158
+ max_items: z.ZodOptional<z.ZodNumber>;
159
+ }, z.core.$strict>, z.ZodObject<{
160
+ type: z.ZodEnum<{
161
+ string: "string";
162
+ boolean: "boolean";
163
+ uuid: "uuid";
164
+ int: "int";
165
+ long: "long";
166
+ numeric: "numeric";
167
+ double: "double";
168
+ timestamp: "timestamp";
169
+ date: "date";
170
+ }>;
171
+ description: z.ZodOptional<z.ZodString>;
172
+ optional: z.ZodDefault<z.ZodBoolean>;
173
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
174
+ }, z.core.$strict>]>>>;
175
+ policy: z.ZodDefault<z.ZodObject<{
176
+ singleton: z.ZodOptional<z.ZodBoolean>;
177
+ exclusion_group: z.ZodOptional<z.ZodString>;
178
+ timeout_minutes: z.ZodOptional<z.ZodNumber>;
179
+ mutates: z.ZodOptional<z.ZodBoolean>;
180
+ cooldown_minutes: z.ZodOptional<z.ZodNumber>;
181
+ requires_approval: z.ZodOptional<z.ZodBoolean>;
182
+ }, z.core.$strict>>;
183
+ entrypoint: z.ZodOptional<z.ZodString>;
184
+ }, z.core.$strict>>;
185
+ export type OperationsBlock = z.infer<typeof operationsBlockSchema>;
186
+ /**
187
+ * The invocation model — the shape the registry run ledger stores for every
188
+ * operation run (storage lands with the registry milestone).
189
+ */
190
+ export declare const operationInvocationSchema: z.ZodObject<{
191
+ operation: z.ZodString;
192
+ params: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
193
+ triggered_by: z.ZodEnum<{
194
+ operator: "operator";
195
+ schedule: "schedule";
196
+ trigger: "trigger";
197
+ }>;
198
+ executing_version: z.ZodString;
199
+ }, z.core.$strict>;
200
+ export type OperationInvocation = z.infer<typeof operationInvocationSchema>;
201
+ export type ParamValidationResult = {
202
+ readonly ok: true;
203
+ readonly params: Record<string, string | number | boolean | Array<string | number | boolean>>;
204
+ } | {
205
+ readonly ok: false;
206
+ readonly errors: readonly string[];
207
+ };
208
+ /**
209
+ * Validate (with Data-Sync-style coercion) an invocation's params against an
210
+ * operation's declarations: apply defaults, coerce numeric/boolean strings,
211
+ * reject unknown params, missing required params, and out-of-domain values.
212
+ */
213
+ export declare function validateOperationParams(operation: OperationSpec, params: Record<string, unknown>): ParamValidationResult;
214
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB;;;;;GAKG;AAEH,wFAAwF;AACxF,eAAO,MAAM,sBAAsB,iGAUzB,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAgCzE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA8B7B,CAAA;AAEJ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;kBAahC,CAAA;AAEF,MAA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Schema } from './columns.js';
4
+ import { repoRelativePathSchema } from './primitives.js';
5
+ /**
6
+ * Operations are named, parameterized entry points on a stage — the successor
7
+ * to Data Sync's run operations, governed by "ad-hoc invocation, never ad-hoc
8
+ * code". The platform reserves `backfill`, `replay`, `sample`, and
9
+ * `live-source-run`; author-declared operations may not shadow them.
10
+ */
11
+ /** Scalar parameter types — the column scalar vocabulary minus contract-only shapes. */
12
+ export const OPERATION_SCALAR_TYPES = [
13
+ 'string',
14
+ 'int',
15
+ 'long',
16
+ 'numeric',
17
+ 'double',
18
+ 'boolean',
19
+ 'timestamp',
20
+ 'date',
21
+ 'uuid',
22
+ ];
23
+ const scalarValueSchema = z.union([z.string(), z.number(), z.boolean()]);
24
+ const scalarParamSchema = z.strictObject({
25
+ type: z.enum(OPERATION_SCALAR_TYPES),
26
+ description: z.string().optional(),
27
+ /** Omittable at invocation; the value is simply absent (no default applies). */
28
+ optional: z.boolean().default(false),
29
+ /** Applied when the invocation omits the param. Mutually exclusive with `optional`. */
30
+ default: scalarValueSchema.optional(),
31
+ });
32
+ const enumParamSchema = z.strictObject({
33
+ type: z.literal('enum'),
34
+ description: z.string().optional(),
35
+ values: z.array(z.string().min(1)).min(1),
36
+ optional: z.boolean().default(false),
37
+ default: z.string().optional(),
38
+ });
39
+ const arrayParamSchema = z.strictObject({
40
+ type: z.literal('array'),
41
+ description: z.string().optional(),
42
+ /** Element type of the array. */
43
+ items: z.enum(OPERATION_SCALAR_TYPES),
44
+ optional: z.boolean().default(false),
45
+ default: z.array(scalarValueSchema).optional(),
46
+ min_items: z.number().int().nonnegative().optional(),
47
+ max_items: z.number().int().positive().optional(),
48
+ });
49
+ /**
50
+ * A typed parameter declaration. Invocations are validated against this shape
51
+ * before enqueue (see `validateOperationParams`) — same posture as Data
52
+ * Sync's paramsSchema coercion: it is impossible to declare an operation that
53
+ * accepts arbitrary unvalidated input.
54
+ */
55
+ export const operationParamSchema = z
56
+ .union([enumParamSchema, arrayParamSchema, scalarParamSchema])
57
+ .superRefine((param, ctx) => {
58
+ if (param.optional && param.default !== undefined) {
59
+ // Contradictory: a default always wins, so `optional` could never mean
60
+ // "omitted". Pick one (mirrors the Data Sync manifest rule).
61
+ ctx.addIssue({
62
+ code: 'custom',
63
+ path: ['optional'],
64
+ message: 'a param cannot be both optional and carry a default',
65
+ });
66
+ }
67
+ if (param.type === 'array' &&
68
+ param.min_items !== undefined &&
69
+ param.max_items !== undefined &&
70
+ param.min_items > param.max_items) {
71
+ ctx.addIssue({ code: 'custom', path: ['max_items'], message: 'max_items must be >= min_items' });
72
+ }
73
+ // A default must survive the SAME validation path a supplied value takes
74
+ // (type/items coercion, enum membership, array bounds) — otherwise an
75
+ // omitted param would silently receive a value that could never be
76
+ // submitted at invocation.
77
+ if (param.default !== undefined) {
78
+ const result = validateOneParam('default', param, param.default);
79
+ if (result.error !== undefined) {
80
+ ctx.addIssue({ code: 'custom', path: ['default'], message: result.error });
81
+ }
82
+ }
83
+ });
84
+ /**
85
+ * Concurrency / safety posture of an operation. Also reused verbatim by
86
+ * ingestion `schedule` blocks — the policy vocabulary lands in the SDK once.
87
+ *
88
+ * Enforcement lives with the run infrastructure (registry / enqueue route) —
89
+ * the spec only declares the policy.
90
+ */
91
+ export const operationPolicySchema = z.strictObject({
92
+ /** Only one run of this operation may be in flight at a time. */
93
+ singleton: z.boolean().optional(),
94
+ /** Operations sharing a group must not run concurrently with each other. */
95
+ exclusion_group: identifierSchema.optional(),
96
+ /** Wall-clock budget after which a run is considered hung. */
97
+ timeout_minutes: z.number().int().positive().optional(),
98
+ /** True when the operation writes data (vs a read-only probe). */
99
+ mutates: z.boolean().optional(),
100
+ /** Minimum gap between consecutive runs. */
101
+ cooldown_minutes: z.number().int().positive().optional(),
102
+ /** Run requires an operator approval step before executing. */
103
+ requires_approval: z.boolean().optional(),
104
+ });
105
+ /** Operation names are kebab/snake slugs; reserved platform verbs are rejected. */
106
+ export const operationNameSchema = z
107
+ .string()
108
+ .regex(/^[a-z][a-z0-9_-]*$/, 'must be a lowercase slug (a-z, 0-9, -, _)');
109
+ export const operationSchema = z.strictObject({
110
+ description: z.string().min(1),
111
+ /** Typed parameter surface, keyed by param name. Empty/omitted = no parameters. */
112
+ params: z.record(identifierSchema, operationParamSchema).default({}),
113
+ policy: operationPolicySchema.default({}),
114
+ /** Repo-relative code path; omitted when the stage's own entrypoint handles the op. */
115
+ entrypoint: repoRelativePathSchema.optional(),
116
+ });
117
+ /**
118
+ * The envelope `operations:` block. Reserved platform names are rejected here
119
+ * so the error lands on the offending key.
120
+ */
121
+ export const operationsBlockSchema = z
122
+ .record(operationNameSchema, operationSchema)
123
+ .superRefine((operations, ctx) => {
124
+ for (const name of Object.keys(operations)) {
125
+ if (RESERVED_OPERATION_NAMES.has(name)) {
126
+ ctx.addIssue({
127
+ code: 'custom',
128
+ path: [name],
129
+ message: `'${name}' is a reserved platform operation name — author-declared operations may not shadow it`,
130
+ });
131
+ }
132
+ }
133
+ });
134
+ /**
135
+ * The invocation model — the shape the registry run ledger stores for every
136
+ * operation run (storage lands with the registry milestone).
137
+ */
138
+ export const operationInvocationSchema = z.strictObject({
139
+ operation: operationNameSchema,
140
+ params: z.record(z.string(), z.union([scalarValueSchema, z.array(scalarValueSchema)])),
141
+ triggered_by: z.enum(['operator', 'schedule', 'trigger']),
142
+ /** The resolved spec version (spec_hash) the run executed against. */
143
+ executing_version: z.string().min(1),
144
+ });
145
+ const INT_TYPES = new Set(['int', 'long']);
146
+ const FLOAT_TYPES = new Set(['numeric', 'double']);
147
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
148
+ const DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
149
+ const TIMESTAMP_PATTERN = /^(\d{4})-(\d{2})-(\d{2})T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)$/;
150
+ /**
151
+ * Calendar round-trip check — engines roll invalid dates over (Date.parse
152
+ * accepts 2026-02-30 as March 2), so shape-matching alone is not enough.
153
+ */
154
+ function isCalendarDate(match) {
155
+ const year = Number(match[1]);
156
+ const month = Number(match[2]);
157
+ const day = Number(match[3]);
158
+ const date = new Date(Date.UTC(year, month - 1, day));
159
+ return (date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day);
160
+ }
161
+ /**
162
+ * Coerce/validate one scalar against its declared type. This is the
163
+ * pre-enqueue gate the run ledger advertises, so string-carried formats are
164
+ * enforced HERE, not in the executor: `uuid` is canonical 8-4-4-4-12 hex,
165
+ * `date` is `YYYY-MM-DD`, `timestamp` is ISO-8601 with timezone — all
166
+ * calendar-checked, and shared by array items and declared defaults.
167
+ */
168
+ function coerceScalar(value, type) {
169
+ if (INT_TYPES.has(type)) {
170
+ if (typeof value === 'number' && Number.isSafeInteger(value))
171
+ return value;
172
+ if (typeof value === 'string' && /^-?\d+$/.test(value)) {
173
+ const parsed = Number(value);
174
+ return Number.isSafeInteger(parsed) ? parsed : null;
175
+ }
176
+ return null;
177
+ }
178
+ if (FLOAT_TYPES.has(type)) {
179
+ if (typeof value === 'number' && Number.isFinite(value))
180
+ return value;
181
+ if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))
182
+ return Number(value);
183
+ return null;
184
+ }
185
+ if (type === 'boolean') {
186
+ if (typeof value === 'boolean')
187
+ return value;
188
+ if (value === 'true')
189
+ return true;
190
+ if (value === 'false')
191
+ return false;
192
+ return null;
193
+ }
194
+ if (typeof value !== 'string')
195
+ return null;
196
+ return coerceStringFormat(value, type);
197
+ }
198
+ /** Format gate for the string-carried scalar types (`string` passes through). */
199
+ function coerceStringFormat(value, type) {
200
+ if (type === 'uuid')
201
+ return UUID_PATTERN.test(value) ? value : null;
202
+ if (type === 'date') {
203
+ const match = DATE_PATTERN.exec(value);
204
+ return match && isCalendarDate(match) ? value : null;
205
+ }
206
+ if (type === 'timestamp') {
207
+ const match = TIMESTAMP_PATTERN.exec(value);
208
+ return match && isCalendarDate(match) ? value : null;
209
+ }
210
+ return value;
211
+ }
212
+ function coerceArrayParam(name, declaration, provided) {
213
+ if (!Array.isArray(provided))
214
+ return { error: `param '${name}' must be an array of ${declaration.items}` };
215
+ if (declaration.min_items !== undefined && provided.length < declaration.min_items) {
216
+ return { error: `param '${name}' must have at least ${declaration.min_items} items` };
217
+ }
218
+ if (declaration.max_items !== undefined && provided.length > declaration.max_items) {
219
+ return { error: `param '${name}' must have at most ${declaration.max_items} items` };
220
+ }
221
+ const coerced = [];
222
+ for (const entry of provided) {
223
+ const value = coerceScalar(entry, declaration.items);
224
+ if (value === null)
225
+ return { error: `param '${name}' items must be ${declaration.items}` };
226
+ coerced.push(value);
227
+ }
228
+ return { value: coerced };
229
+ }
230
+ function validateOneParam(name, declaration, provided) {
231
+ if (declaration.type === 'enum') {
232
+ if (typeof provided === 'string' && declaration.values.includes(provided))
233
+ return { value: provided };
234
+ return { error: `param '${name}' must be one of: ${declaration.values.join(', ')}` };
235
+ }
236
+ if (declaration.type === 'array')
237
+ return coerceArrayParam(name, declaration, provided);
238
+ const value = coerceScalar(provided, declaration.type);
239
+ if (value === null)
240
+ return { error: `param '${name}' must be ${declaration.type}` };
241
+ return { value };
242
+ }
243
+ /**
244
+ * Validate (with Data-Sync-style coercion) an invocation's params against an
245
+ * operation's declarations: apply defaults, coerce numeric/boolean strings,
246
+ * reject unknown params, missing required params, and out-of-domain values.
247
+ */
248
+ export function validateOperationParams(operation, params) {
249
+ const errors = [];
250
+ const validated = {};
251
+ for (const name of Object.keys(params)) {
252
+ if (!(name in operation.params))
253
+ errors.push(`unknown param '${name}'`);
254
+ }
255
+ for (const [name, declaration] of Object.entries(operation.params)) {
256
+ // Defaults take the same validation/coercion path as supplied values, so
257
+ // e.g. a declared default '5' for an int param lands as the number 5.
258
+ // (Only absence triggers the default — an explicit null stays an error.)
259
+ const provided = params[name] !== undefined ? params[name] : declaration.default;
260
+ if (provided === undefined) {
261
+ if (!declaration.optional)
262
+ errors.push(`missing required param '${name}'`);
263
+ continue;
264
+ }
265
+ const result = validateOneParam(name, declaration, provided);
266
+ if (result.error !== undefined) {
267
+ errors.push(result.error);
268
+ }
269
+ else if (result.value !== undefined) {
270
+ validated[name] = result.value;
271
+ }
272
+ }
273
+ return errors.length > 0 ? { ok: false, errors } : { ok: true, params: validated };
274
+ }
275
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD;;;;;GAKG;AAEH,wFAAwF;AACxF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ;IACR,KAAK;IACL,MAAM;IACN,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;IACX,MAAM;IACN,MAAM;CACE,CAAA;AAIV,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;AAExE,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IACpC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,gFAAgF;IAChF,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACpC,uFAAuF;IACvF,OAAO,EAAE,iBAAiB,CAAC,QAAQ,EAAE;CACtC,CAA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C,CAAA;QAC5D,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;aAAM,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAA;QAChC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;AACpF,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Serving `satisfies:` enforcement against an ORM synced-table contract
3
+ * (SEQ-2499). Pure — callers (offline `validateSpecGraph`, provision plan)
4
+ * supply the active contract catalog; this module never fetches ORM state.
5
+ *
6
+ * Compatibility posture:
7
+ * - Projection is the **producer**; ORM contract columns are the **consumer
8
+ * requirement** (`checkCompatibility`).
9
+ * - Extra projection columns are allowed (additive pipeline supersets).
10
+ * - Primary keys must match exactly (same set + order).
11
+ * - `content_hash` on `satisfies` must equal the active contract hash.
12
+ */
13
+ import { z } from 'zod';
14
+ import { type ColumnMap } from './columns.js';
15
+ import type { SatisfiesBinding } from './bodies/serving.js';
16
+ export declare const ORM_SATISFIES_FINDING_CODES: readonly ["orm_contract_unavailable", "orm_contract_hash_mismatch", "orm_contract_pk_mismatch", "missing_column", "type_incompatible", "nullability_violation", "domain_violation", "domain_shrunk"];
17
+ export type OrmSatisfiesFindingCode = (typeof ORM_SATISFIES_FINDING_CODES)[number];
18
+ export interface OrmSatisfiesFinding {
19
+ readonly code: OrmSatisfiesFindingCode;
20
+ readonly severity: 'error' | 'warning';
21
+ readonly message: string;
22
+ readonly column?: string;
23
+ }
24
+ /**
25
+ * Active ORM synced-table contract as consumed by pipeline validation.
26
+ * Structurally matches `@sequenceholdings/orm`'s `OrmSyncedTableContract`
27
+ * (duplicated here so pipeline-spec stays free of an ORM runtime dependency).
28
+ */
29
+ export interface OrmSyncedContractRequirement {
30
+ readonly namespace: string;
31
+ readonly table: string;
32
+ readonly columns: ColumnMap;
33
+ readonly primary_key: readonly string[];
34
+ readonly content_hash: string;
35
+ }
36
+ /** Catalog keyed by `namespace.table`. */
37
+ export type OrmContractCatalog = Readonly<Record<string, OrmSyncedContractRequirement>>;
38
+ /** One ORM synced-table contract entry for offline `satisfies` validation. */
39
+ export declare const ormSyncedContractRequirementSchema: z.ZodObject<{
40
+ namespace: z.ZodString;
41
+ table: z.ZodString;
42
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
43
+ type: z.ZodUnion<readonly [z.ZodEnum<{
44
+ string: "string";
45
+ boolean: "boolean";
46
+ uuid: "uuid";
47
+ int: "int";
48
+ long: "long";
49
+ numeric: "numeric";
50
+ double: "double";
51
+ timestamp: "timestamp";
52
+ date: "date";
53
+ json: "json";
54
+ }>, z.ZodEnum<{
55
+ float: "float";
56
+ timestamp_ntz: "timestamp_ntz";
57
+ array: "array";
58
+ map: "map";
59
+ struct: "struct";
60
+ binary: "binary";
61
+ }>, z.ZodString]>;
62
+ nullable: z.ZodDefault<z.ZodBoolean>;
63
+ key: z.ZodDefault<z.ZodBoolean>;
64
+ domain: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
65
+ description: z.ZodOptional<z.ZodString>;
66
+ on_violation: z.ZodDefault<z.ZodEnum<{
67
+ fail: "fail";
68
+ quarantine: "quarantine";
69
+ warn: "warn";
70
+ }>>;
71
+ }, z.core.$strict>>;
72
+ primary_key: z.ZodArray<z.ZodString>;
73
+ content_hash: z.ZodString;
74
+ }, z.core.$strict>;
75
+ /**
76
+ * Offline ORM contract catalog for `seq-studio pipeline validate --orm-contracts`
77
+ * or `<pipeline-dir>/orm-contracts.json`. Keys must be `namespace.table`.
78
+ */
79
+ export declare const ormContractCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
80
+ namespace: z.ZodString;
81
+ table: z.ZodString;
82
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
83
+ type: z.ZodUnion<readonly [z.ZodEnum<{
84
+ string: "string";
85
+ boolean: "boolean";
86
+ uuid: "uuid";
87
+ int: "int";
88
+ long: "long";
89
+ numeric: "numeric";
90
+ double: "double";
91
+ timestamp: "timestamp";
92
+ date: "date";
93
+ json: "json";
94
+ }>, z.ZodEnum<{
95
+ float: "float";
96
+ timestamp_ntz: "timestamp_ntz";
97
+ array: "array";
98
+ map: "map";
99
+ struct: "struct";
100
+ binary: "binary";
101
+ }>, z.ZodString]>;
102
+ nullable: z.ZodDefault<z.ZodBoolean>;
103
+ key: z.ZodDefault<z.ZodBoolean>;
104
+ domain: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
105
+ description: z.ZodOptional<z.ZodString>;
106
+ on_violation: z.ZodDefault<z.ZodEnum<{
107
+ fail: "fail";
108
+ quarantine: "quarantine";
109
+ warn: "warn";
110
+ }>>;
111
+ }, z.core.$strict>>;
112
+ primary_key: z.ZodArray<z.ZodString>;
113
+ content_hash: z.ZodString;
114
+ }, z.core.$strict>>;
115
+ export declare function ormContractCatalogKey({ namespace, table, }: {
116
+ namespace: string;
117
+ table: string;
118
+ }): string;
119
+ /**
120
+ * Does this serving projection satisfy the declared ORM contract binding?
121
+ * Returns findings (empty = ok). Hash + PK mismatches are always errors;
122
+ * column findings reuse `checkCompatibility` severities.
123
+ */
124
+ export declare function checkServingSatisfiesOrmContract({ projection, satisfies, contract, }: {
125
+ projection: {
126
+ readonly columns: ColumnMap;
127
+ readonly primary_key: readonly string[];
128
+ };
129
+ satisfies: SatisfiesBinding;
130
+ contract: OrmSyncedContractRequirement | undefined;
131
+ }): OrmSatisfiesFinding[];
132
+ //# sourceMapping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