@shipfox/expression 1.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 (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/evaluator/errors.d.ts +8 -0
  4. package/dist/evaluator/errors.d.ts.map +1 -0
  5. package/dist/evaluator/errors.js +13 -0
  6. package/dist/evaluator/errors.js.map +1 -0
  7. package/dist/evaluator/evaluate-workflow-expression.d.ts +11 -0
  8. package/dist/evaluator/evaluate-workflow-expression.d.ts.map +1 -0
  9. package/dist/evaluator/evaluate-workflow-expression.js +30 -0
  10. package/dist/evaluator/evaluate-workflow-expression.js.map +1 -0
  11. package/dist/evaluator/index.d.ts +3 -0
  12. package/dist/evaluator/index.d.ts.map +1 -0
  13. package/dist/evaluator/index.js +4 -0
  14. package/dist/evaluator/index.js.map +1 -0
  15. package/dist/expression/create-workflow-expression.d.ts +7 -0
  16. package/dist/expression/create-workflow-expression.d.ts.map +1 -0
  17. package/dist/expression/create-workflow-expression.js +156 -0
  18. package/dist/expression/create-workflow-expression.js.map +1 -0
  19. package/dist/expression/errors.d.ts +12 -0
  20. package/dist/expression/errors.d.ts.map +1 -0
  21. package/dist/expression/errors.js +13 -0
  22. package/dist/expression/errors.js.map +1 -0
  23. package/dist/expression/index.d.ts +4 -0
  24. package/dist/expression/index.d.ts.map +1 -0
  25. package/dist/expression/index.js +4 -0
  26. package/dist/expression/index.js.map +1 -0
  27. package/dist/expression/workflow-expression.d.ts +33 -0
  28. package/dist/expression/workflow-expression.d.ts.map +1 -0
  29. package/dist/expression/workflow-expression.js +3 -0
  30. package/dist/expression/workflow-expression.js.map +1 -0
  31. package/dist/index.d.ts +27 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +25 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/outputs/index.d.ts +2 -0
  36. package/dist/outputs/index.d.ts.map +1 -0
  37. package/dist/outputs/index.js +3 -0
  38. package/dist/outputs/index.js.map +1 -0
  39. package/dist/outputs/output-declarations.d.ts +39 -0
  40. package/dist/outputs/output-declarations.d.ts.map +1 -0
  41. package/dist/outputs/output-declarations.js +295 -0
  42. package/dist/outputs/output-declarations.js.map +1 -0
  43. package/dist/plan/bare-reference.d.ts +2 -0
  44. package/dist/plan/bare-reference.d.ts.map +1 -0
  45. package/dist/plan/bare-reference.js +23 -0
  46. package/dist/plan/bare-reference.js.map +1 -0
  47. package/dist/plan/context-key-access.d.ts +25 -0
  48. package/dist/plan/context-key-access.d.ts.map +1 -0
  49. package/dist/plan/context-key-access.js +249 -0
  50. package/dist/plan/context-key-access.js.map +1 -0
  51. package/dist/plan/evaluate-planned-predicate.d.ts +14 -0
  52. package/dist/plan/evaluate-planned-predicate.d.ts.map +1 -0
  53. package/dist/plan/evaluate-planned-predicate.js +31 -0
  54. package/dist/plan/evaluate-planned-predicate.js.map +1 -0
  55. package/dist/plan/evaluation-trace.d.ts +44 -0
  56. package/dist/plan/evaluation-trace.d.ts.map +1 -0
  57. package/dist/plan/evaluation-trace.js +95 -0
  58. package/dist/plan/evaluation-trace.js.map +1 -0
  59. package/dist/plan/extract-exact-context-roots.d.ts +2 -0
  60. package/dist/plan/extract-exact-context-roots.d.ts.map +1 -0
  61. package/dist/plan/extract-exact-context-roots.js +114 -0
  62. package/dist/plan/extract-exact-context-roots.js.map +1 -0
  63. package/dist/plan/fill.d.ts +3 -0
  64. package/dist/plan/fill.d.ts.map +1 -0
  65. package/dist/plan/fill.js +8 -0
  66. package/dist/plan/fill.js.map +1 -0
  67. package/dist/plan/freeze-run-command.d.ts +17 -0
  68. package/dist/plan/freeze-run-command.d.ts.map +1 -0
  69. package/dist/plan/freeze-run-command.js +33 -0
  70. package/dist/plan/freeze-run-command.js.map +1 -0
  71. package/dist/plan/freeze.d.ts +48 -0
  72. package/dist/plan/freeze.d.ts.map +1 -0
  73. package/dist/plan/freeze.js +148 -0
  74. package/dist/plan/freeze.js.map +1 -0
  75. package/dist/plan/plan-field.d.ts +26 -0
  76. package/dist/plan/plan-field.d.ts.map +1 -0
  77. package/dist/plan/plan-field.js +63 -0
  78. package/dist/plan/plan-field.js.map +1 -0
  79. package/dist/plan/predicate-shape.d.ts +2 -0
  80. package/dist/plan/predicate-shape.d.ts.map +1 -0
  81. package/dist/plan/predicate-shape.js +45 -0
  82. package/dist/plan/predicate-shape.js.map +1 -0
  83. package/dist/plan/resolved-field.d.ts +17 -0
  84. package/dist/plan/resolved-field.d.ts.map +1 -0
  85. package/dist/plan/resolved-field.js +3 -0
  86. package/dist/plan/resolved-field.js.map +1 -0
  87. package/dist/plan/route-expression.d.ts +9 -0
  88. package/dist/plan/route-expression.d.ts.map +1 -0
  89. package/dist/plan/route-expression.js +46 -0
  90. package/dist/plan/route-expression.js.map +1 -0
  91. package/dist/plan/validate-server-evaluable.d.ts +14 -0
  92. package/dist/plan/validate-server-evaluable.d.ts.map +1 -0
  93. package/dist/plan/validate-server-evaluable.js +20 -0
  94. package/dist/plan/validate-server-evaluable.js.map +1 -0
  95. package/dist/resolver/coerce-workflow-value-to-string.d.ts +2 -0
  96. package/dist/resolver/coerce-workflow-value-to-string.d.ts.map +1 -0
  97. package/dist/resolver/coerce-workflow-value-to-string.js +16 -0
  98. package/dist/resolver/coerce-workflow-value-to-string.js.map +1 -0
  99. package/dist/resolver/errors.d.ts +10 -0
  100. package/dist/resolver/errors.d.ts.map +1 -0
  101. package/dist/resolver/errors.js +12 -0
  102. package/dist/resolver/errors.js.map +1 -0
  103. package/dist/run/hoist-run-command.d.ts +33 -0
  104. package/dist/run/hoist-run-command.d.ts.map +1 -0
  105. package/dist/run/hoist-run-command.js +79 -0
  106. package/dist/run/hoist-run-command.js.map +1 -0
  107. package/dist/run/shell-quoting.d.ts +24 -0
  108. package/dist/run/shell-quoting.d.ts.map +1 -0
  109. package/dist/run/shell-quoting.js +364 -0
  110. package/dist/run/shell-quoting.js.map +1 -0
  111. package/dist/template/errors.d.ts +14 -0
  112. package/dist/template/errors.d.ts.map +1 -0
  113. package/dist/template/errors.js +14 -0
  114. package/dist/template/errors.js.map +1 -0
  115. package/dist/template/extract-cel-context-roots.d.ts +2 -0
  116. package/dist/template/extract-cel-context-roots.d.ts.map +1 -0
  117. package/dist/template/extract-cel-context-roots.js +110 -0
  118. package/dist/template/extract-cel-context-roots.js.map +1 -0
  119. package/dist/template/extract-cel-untrusted-path-accesses.d.ts +5 -0
  120. package/dist/template/extract-cel-untrusted-path-accesses.d.ts.map +1 -0
  121. package/dist/template/extract-cel-untrusted-path-accesses.js +140 -0
  122. package/dist/template/extract-cel-untrusted-path-accesses.js.map +1 -0
  123. package/dist/template/parse-workflow-template.d.ts +3 -0
  124. package/dist/template/parse-workflow-template.d.ts.map +1 -0
  125. package/dist/template/parse-workflow-template.js +111 -0
  126. package/dist/template/parse-workflow-template.js.map +1 -0
  127. package/dist/template/scan-cel-token.d.ts +3 -0
  128. package/dist/template/scan-cel-token.d.ts.map +1 -0
  129. package/dist/template/scan-cel-token.js +55 -0
  130. package/dist/template/scan-cel-token.js.map +1 -0
  131. package/dist/template/template-segment.d.ts +12 -0
  132. package/dist/template/template-segment.d.ts.map +1 -0
  133. package/dist/template/template-segment.js +3 -0
  134. package/dist/template/template-segment.js.map +1 -0
  135. package/dist/tsconfig.test.tsbuildinfo +1 -0
  136. package/dist/workflow-context/workflow-context.d.ts +458 -0
  137. package/dist/workflow-context/workflow-context.d.ts.map +1 -0
  138. package/dist/workflow-context/workflow-context.js +664 -0
  139. package/dist/workflow-context/workflow-context.js.map +1 -0
  140. package/package.json +49 -0
@@ -0,0 +1,664 @@
1
+ import { outputDeclarationsToExpressionFields } from '../outputs/output-declarations.js';
2
+ export const workflowContextNames = [
3
+ 'run',
4
+ 'trigger',
5
+ 'event',
6
+ 'inputs',
7
+ 'job',
8
+ 'executions',
9
+ 'execution',
10
+ 'jobs',
11
+ 'needs',
12
+ 'steps',
13
+ 'step',
14
+ 'vars',
15
+ 'secrets'
16
+ ];
17
+ export const availabilitySites = [
18
+ // Server receives an external trigger or manual request before a run row exists.
19
+ 'ingest',
20
+ // Server creates the workflow run and its run-scoped context.
21
+ 'run-creation',
22
+ // Server creates a concrete job execution and its execution-scoped context.
23
+ 'execution-creation',
24
+ // Server activates a queued job after dependencies, matrix expansion, and runner demand are known.
25
+ 'job-activation',
26
+ // Server dispatches a job step to a runner with all server-filled context resolved.
27
+ 'step-dispatch',
28
+ // Server receives a step report and makes step result context available.
29
+ 'step-report',
30
+ // Server resolves one job execution after its steps have settled.
31
+ 'execution-resolution',
32
+ // Server resolves the job after all of its executions are known.
33
+ 'job-resolution'
34
+ ];
35
+ export const runnerFillTarget = 'runner-fill';
36
+ export const workflowContextSensitivities = [
37
+ 'persistable',
38
+ 'ephemeral'
39
+ ];
40
+ export const workflowContextHosts = [
41
+ 'server',
42
+ 'runner'
43
+ ];
44
+ export const workflowContextReservedRoots = {
45
+ matrix: {
46
+ host: 'server',
47
+ availability: 'job-activation'
48
+ },
49
+ runner: {
50
+ host: 'runner'
51
+ }
52
+ };
53
+ export const workflowContextTrustTiers = [
54
+ 'trusted',
55
+ 'untrusted'
56
+ ];
57
+ const runTypeEnvironment = {
58
+ run: {
59
+ kind: 'object',
60
+ fields: {
61
+ id: 'string',
62
+ name: 'string',
63
+ definition_id: 'string',
64
+ project_id: 'string',
65
+ workspace_id: 'string',
66
+ created_at: 'timestamp'
67
+ }
68
+ }
69
+ };
70
+ const triggerTypeEnvironment = {
71
+ trigger: {
72
+ kind: 'object',
73
+ fields: {
74
+ source: 'string',
75
+ event: 'string'
76
+ }
77
+ }
78
+ };
79
+ const jobTypeEnvironment = {
80
+ job: {
81
+ kind: 'object',
82
+ fields: {
83
+ key: 'string'
84
+ }
85
+ }
86
+ };
87
+ const executionEventType = {
88
+ kind: 'object',
89
+ fields: {
90
+ source: 'string',
91
+ event: 'string',
92
+ delivery_id: 'string',
93
+ received_at: 'timestamp',
94
+ data: {
95
+ kind: 'object',
96
+ fields: {}
97
+ }
98
+ }
99
+ };
100
+ const executionType = {
101
+ kind: 'object',
102
+ fields: {
103
+ index: 'int',
104
+ name: 'string',
105
+ status: 'string',
106
+ failed: 'bool',
107
+ started_at: 'timestamp',
108
+ finished_at: 'timestamp',
109
+ events: {
110
+ kind: 'list',
111
+ element: executionEventType
112
+ },
113
+ outputs: {
114
+ kind: 'map'
115
+ }
116
+ }
117
+ };
118
+ const executionsTypeEnvironment = {
119
+ executions: {
120
+ kind: 'list',
121
+ element: executionType
122
+ }
123
+ };
124
+ const executionTypeEnvironment = {
125
+ execution: executionType
126
+ };
127
+ const stepGateType = {
128
+ kind: 'object',
129
+ fields: {
130
+ passed: 'bool',
131
+ source: 'string',
132
+ reason: 'string',
133
+ exit_code: 'int'
134
+ }
135
+ };
136
+ const stepAttemptType = {
137
+ kind: 'object',
138
+ fields: {
139
+ status: 'string',
140
+ exit_code: 'int',
141
+ outputs: {
142
+ kind: 'map'
143
+ },
144
+ response: 'string',
145
+ gate: stepGateType
146
+ }
147
+ };
148
+ const stepEntityType = {
149
+ kind: 'object',
150
+ fields: {
151
+ ...stepAttemptType.fields,
152
+ attempts: {
153
+ kind: 'list',
154
+ element: stepAttemptType
155
+ }
156
+ }
157
+ };
158
+ const stepTypeEnvironment = {
159
+ step: {
160
+ kind: 'object',
161
+ fields: {
162
+ attempt: 'int',
163
+ is_retry: 'bool',
164
+ restart: {
165
+ kind: 'object',
166
+ fields: {
167
+ from: stepEntityType,
168
+ feedback: 'string'
169
+ }
170
+ },
171
+ exit_code: 'int',
172
+ status: 'string',
173
+ outputs: {
174
+ kind: 'map'
175
+ }
176
+ }
177
+ }
178
+ };
179
+ export function buildTypedRootsEnvironment(params) {
180
+ return {
181
+ ...params.steps === undefined ? {} : {
182
+ steps: stepsRootType(params.steps)
183
+ },
184
+ ...params.currentStep === undefined ? {} : {
185
+ step: selfStepType(params.currentStep)
186
+ },
187
+ ...params.jobs === undefined ? {} : {
188
+ jobs: jobsRootType(params.jobs)
189
+ },
190
+ ...params.needs === undefined ? {} : {
191
+ needs: needsRootType()
192
+ }
193
+ };
194
+ }
195
+ export const workflowContextDefinitions = {
196
+ run: {
197
+ availability: 'run-creation',
198
+ trustTier: 'trusted',
199
+ sensitivity: 'persistable',
200
+ host: 'server',
201
+ shape: 'known',
202
+ checkMode: 'typed',
203
+ typeEnvironment: runTypeEnvironment
204
+ },
205
+ trigger: {
206
+ availability: 'ingest',
207
+ trustTier: 'trusted',
208
+ sensitivity: 'persistable',
209
+ host: 'server',
210
+ shape: 'known',
211
+ checkMode: 'typed',
212
+ typeEnvironment: triggerTypeEnvironment
213
+ },
214
+ event: {
215
+ availability: 'ingest',
216
+ trustTier: 'untrusted',
217
+ sensitivity: 'persistable',
218
+ host: 'server',
219
+ shape: 'open',
220
+ checkMode: 'syntax'
221
+ },
222
+ inputs: {
223
+ availability: 'run-creation',
224
+ trustTier: 'untrusted',
225
+ sensitivity: 'persistable',
226
+ host: 'server',
227
+ shape: 'open',
228
+ checkMode: 'syntax'
229
+ },
230
+ job: {
231
+ availability: 'run-creation',
232
+ trustTier: 'trusted',
233
+ sensitivity: 'persistable',
234
+ host: 'server',
235
+ shape: 'known',
236
+ checkMode: 'typed',
237
+ typeEnvironment: jobTypeEnvironment
238
+ },
239
+ executions: {
240
+ availability: 'execution-creation',
241
+ trustTier: 'trusted',
242
+ sensitivity: 'persistable',
243
+ host: 'server',
244
+ shape: 'known',
245
+ checkMode: 'typed',
246
+ typeEnvironment: executionsTypeEnvironment,
247
+ untrustedPaths: [
248
+ 'events'
249
+ ]
250
+ },
251
+ execution: {
252
+ availability: 'execution-creation',
253
+ trustTier: 'trusted',
254
+ sensitivity: 'persistable',
255
+ host: 'server',
256
+ shape: 'known',
257
+ checkMode: 'typed',
258
+ typeEnvironment: executionTypeEnvironment,
259
+ untrustedPaths: [
260
+ 'events'
261
+ ]
262
+ },
263
+ jobs: {
264
+ availability: 'job-activation',
265
+ trustTier: 'untrusted',
266
+ sensitivity: 'persistable',
267
+ host: 'server',
268
+ shape: 'open',
269
+ checkMode: 'syntax'
270
+ },
271
+ needs: {
272
+ availability: 'job-activation',
273
+ trustTier: 'untrusted',
274
+ sensitivity: 'persistable',
275
+ host: 'server',
276
+ shape: 'known',
277
+ checkMode: 'typed',
278
+ typeEnvironment: {
279
+ needs: {
280
+ kind: 'list',
281
+ element: jobEntityType({
282
+ key: '$need'
283
+ })
284
+ }
285
+ }
286
+ },
287
+ steps: {
288
+ availability: 'step-dispatch',
289
+ trustTier: 'trusted',
290
+ sensitivity: 'persistable',
291
+ host: 'server',
292
+ shape: 'open',
293
+ checkMode: 'syntax'
294
+ },
295
+ step: {
296
+ availability: 'step-dispatch',
297
+ trustTier: 'trusted',
298
+ sensitivity: 'persistable',
299
+ host: 'server',
300
+ shape: 'known',
301
+ checkMode: 'typed',
302
+ typeEnvironment: stepTypeEnvironment,
303
+ untrustedPaths: [
304
+ 'outputs'
305
+ ]
306
+ },
307
+ vars: {
308
+ availability: 'run-creation',
309
+ trustTier: 'trusted',
310
+ sensitivity: 'persistable',
311
+ host: 'server',
312
+ shape: 'open',
313
+ checkMode: 'syntax',
314
+ literalKeyOnly: true
315
+ },
316
+ secrets: {
317
+ trustTier: 'trusted',
318
+ sensitivity: 'ephemeral',
319
+ host: 'runner',
320
+ shape: 'open',
321
+ checkMode: 'syntax',
322
+ literalKeyOnly: true
323
+ }
324
+ };
325
+ export const workflowFieldFailurePolicies = [
326
+ 'fail',
327
+ 'degrade',
328
+ 'fail-closed'
329
+ ];
330
+ const trustedOnlyTrustTiers = [
331
+ 'trusted'
332
+ ];
333
+ const anyTrustTier = [
334
+ 'trusted',
335
+ 'untrusted'
336
+ ];
337
+ const serverOnlyHosts = [
338
+ 'server'
339
+ ];
340
+ const anyHost = [
341
+ 'server',
342
+ 'runner'
343
+ ];
344
+ export const workflowInterpolationFieldPolicies = {
345
+ run: {
346
+ acceptedTrustTiers: trustedOnlyTrustTiers,
347
+ acceptedHosts: anyHost,
348
+ failurePolicy: 'fail',
349
+ renderSanitize: false
350
+ },
351
+ 'env.value': {
352
+ acceptedTrustTiers: anyTrustTier,
353
+ acceptedHosts: anyHost,
354
+ failurePolicy: 'fail',
355
+ renderSanitize: false
356
+ },
357
+ 'agent.prompt': {
358
+ acceptedTrustTiers: anyTrustTier,
359
+ acceptedHosts: serverOnlyHosts,
360
+ failurePolicy: 'fail',
361
+ renderSanitize: false
362
+ },
363
+ 'agent.model': {
364
+ acceptedTrustTiers: trustedOnlyTrustTiers,
365
+ acceptedHosts: serverOnlyHosts,
366
+ failurePolicy: 'fail',
367
+ renderSanitize: false
368
+ },
369
+ 'agent.provider': {
370
+ acceptedTrustTiers: trustedOnlyTrustTiers,
371
+ acceptedHosts: serverOnlyHosts,
372
+ failurePolicy: 'fail',
373
+ renderSanitize: false
374
+ },
375
+ 'agent.thinking': {
376
+ acceptedTrustTiers: trustedOnlyTrustTiers,
377
+ acceptedHosts: serverOnlyHosts,
378
+ failurePolicy: 'fail',
379
+ renderSanitize: false
380
+ },
381
+ 'job.runner': {
382
+ acceptedTrustTiers: anyTrustTier,
383
+ acceptedHosts: serverOnlyHosts,
384
+ failurePolicy: 'fail',
385
+ renderSanitize: false
386
+ },
387
+ 'job.outputs': {
388
+ acceptedTrustTiers: anyTrustTier,
389
+ acceptedHosts: serverOnlyHosts,
390
+ failurePolicy: 'fail',
391
+ renderSanitize: false,
392
+ minimumFillTarget: 'execution-resolution'
393
+ },
394
+ 'job.name': {
395
+ acceptedTrustTiers: anyTrustTier,
396
+ acceptedHosts: serverOnlyHosts,
397
+ failurePolicy: 'degrade',
398
+ renderSanitize: true
399
+ },
400
+ 'step.name': {
401
+ acceptedTrustTiers: anyTrustTier,
402
+ acceptedHosts: serverOnlyHosts,
403
+ failurePolicy: 'degrade',
404
+ renderSanitize: true
405
+ },
406
+ 'step.feedback': {
407
+ acceptedTrustTiers: anyTrustTier,
408
+ acceptedHosts: serverOnlyHosts,
409
+ failurePolicy: 'fail',
410
+ renderSanitize: false
411
+ }
412
+ };
413
+ export const workflowInterpolationFields = Object.keys(workflowInterpolationFieldPolicies);
414
+ export const workflowPredicateFields = [
415
+ 'step.success',
416
+ 'job.success',
417
+ 'trigger.filter',
418
+ 'listener.on',
419
+ 'listener.until',
420
+ 'job.if',
421
+ 'step.if'
422
+ ];
423
+ export const workflowPredicateFieldFailurePolicy = 'fail-closed';
424
+ const workflowPredicateFieldMinimumFillTargets = {
425
+ 'step.success': 'step-report',
426
+ 'job.success': 'job-resolution',
427
+ 'trigger.filter': 'ingest',
428
+ 'listener.on': 'job-activation',
429
+ 'listener.until': 'job-activation',
430
+ 'job.if': 'job-activation',
431
+ 'step.if': 'step-dispatch'
432
+ };
433
+ export function getWorkflowContextDefinition(name) {
434
+ return workflowContextDefinitions[name];
435
+ }
436
+ export function getWorkflowContextAvailability(name) {
437
+ const definition = workflowContextDefinitions[name];
438
+ return definition.host === 'server' ? definition.availability : undefined;
439
+ }
440
+ export function getWorkflowContextHost(name) {
441
+ return workflowContextDefinitions[name].host;
442
+ }
443
+ export function resolveContextRootHost(root) {
444
+ if (isWorkflowContextName(root)) return workflowContextDefinitions[root].host;
445
+ if (isWorkflowContextReservedRoot(root)) return workflowContextReservedRoots[root].host;
446
+ return undefined;
447
+ }
448
+ export function resolveContextRootAvailability(root) {
449
+ if (isWorkflowContextName(root)) {
450
+ const definition = workflowContextDefinitions[root];
451
+ return definition.host === 'server' ? definition.availability : undefined;
452
+ }
453
+ if (!isWorkflowContextReservedRoot(root)) return undefined;
454
+ const reservedRoot = workflowContextReservedRoots[root];
455
+ return reservedRoot.host === 'server' ? reservedRoot.availability : undefined;
456
+ }
457
+ export function getWorkflowContextSensitivity(name) {
458
+ return workflowContextDefinitions[name].sensitivity;
459
+ }
460
+ export function rootsAvailableAt(site) {
461
+ const targetSiteIndex = availabilitySites.indexOf(site);
462
+ return workflowContextNames.filter((name)=>{
463
+ const definition = workflowContextDefinitions[name];
464
+ return definition.host === 'server' && availabilitySites.indexOf(definition.availability) <= targetSiteIndex;
465
+ });
466
+ }
467
+ export function unavailableRootsAt(roots, site) {
468
+ const availableRoots = new Set(rootsAvailableAt(site));
469
+ return roots.filter((root)=>!availableRoots.has(root));
470
+ }
471
+ export function getWorkflowContextTypeEnvironment(name) {
472
+ const context = getWorkflowContextDefinition(name);
473
+ return context.shape === 'known' ? context.typeEnvironment : undefined;
474
+ }
475
+ export function getWorkflowContextUntrustedPaths(name) {
476
+ const context = getWorkflowContextDefinition(name);
477
+ return context.shape === 'known' ? context.untrustedPaths : undefined;
478
+ }
479
+ export function workflowInterpolationFieldAcceptsTrustTier(field, trustTier) {
480
+ return workflowInterpolationFieldPolicies[field].acceptedTrustTiers.includes(trustTier);
481
+ }
482
+ export function workflowInterpolationFieldAcceptsHost(field, host) {
483
+ return workflowInterpolationFieldPolicies[field].acceptedHosts.includes(host);
484
+ }
485
+ export function workflowInterpolationFieldAcceptsContext(field, context) {
486
+ return workflowInterpolationFieldAcceptsTrustTier(field, workflowContextDefinitions[context].trustTier);
487
+ }
488
+ export function workflowContextRootRequiresLiteralKey(root) {
489
+ if (!isWorkflowContextName(root)) return false;
490
+ const definition = workflowContextDefinitions[root];
491
+ return 'literalKeyOnly' in definition && definition.literalKeyOnly === true;
492
+ }
493
+ export function getWorkflowInterpolationFieldFailurePolicy(field) {
494
+ return workflowInterpolationFieldPolicies[field].failurePolicy;
495
+ }
496
+ export function getWorkflowInterpolationFieldMinimumFillTarget(field) {
497
+ const policy = workflowInterpolationFieldPolicies[field];
498
+ return 'minimumFillTarget' in policy ? policy.minimumFillTarget : undefined;
499
+ }
500
+ export function getWorkflowPredicateFieldMinimumFillTarget(field) {
501
+ return workflowPredicateFieldMinimumFillTargets[field];
502
+ }
503
+ export function workflowContextAvailabilityReference() {
504
+ return [
505
+ ...workflowContextNames.map((root)=>{
506
+ const definition = workflowContextDefinitions[root];
507
+ if (definition.host === 'runner') return noServerAvailabilityReferenceEntry(root, false);
508
+ return availabilityReferenceEntry(root, definition.availability, false);
509
+ }),
510
+ ...Object.entries(workflowContextReservedRoots).map(([root, definition])=>{
511
+ if (definition.host === 'runner') {
512
+ return noServerAvailabilityReferenceEntry(root, true);
513
+ }
514
+ return availabilityReferenceEntry(root, definition.availability, true);
515
+ })
516
+ ];
517
+ }
518
+ function availabilityReferenceEntry(root, availability, reserved) {
519
+ const availabilityIndex = availabilitySites.indexOf(availability);
520
+ const availableAt = Object.fromEntries(availabilitySites.map((site)=>[
521
+ site,
522
+ availabilitySites.indexOf(site) >= availabilityIndex
523
+ ]));
524
+ return {
525
+ root,
526
+ availability,
527
+ reserved,
528
+ availableAt
529
+ };
530
+ }
531
+ function noServerAvailabilityReferenceEntry(root, reserved) {
532
+ const availableAt = Object.fromEntries(availabilitySites.map((site)=>[
533
+ site,
534
+ false
535
+ ]));
536
+ return {
537
+ root,
538
+ reserved,
539
+ availableAt
540
+ };
541
+ }
542
+ function stepsRootType(steps) {
543
+ return {
544
+ kind: 'object',
545
+ fields: Object.fromEntries(steps.map((step)=>[
546
+ step.key,
547
+ stepEntityTypeForStep(step)
548
+ ]))
549
+ };
550
+ }
551
+ function stepEntityTypeForStep(step) {
552
+ const attemptType = stepAttemptTypeForOutputs(outputsTypeForStep(step));
553
+ return {
554
+ kind: 'object',
555
+ fields: {
556
+ ...attemptType.fields,
557
+ attempts: {
558
+ kind: 'list',
559
+ element: attemptType
560
+ }
561
+ }
562
+ };
563
+ }
564
+ function selfStepType(step) {
565
+ return {
566
+ kind: 'object',
567
+ fields: {
568
+ ...stepTypeEnvironment.step.fields,
569
+ outputs: outputsTypeForStep(step)
570
+ }
571
+ };
572
+ }
573
+ function stepAttemptTypeForOutputs(outputs) {
574
+ return {
575
+ kind: 'object',
576
+ fields: {
577
+ ...stepAttemptType.fields,
578
+ outputs
579
+ }
580
+ };
581
+ }
582
+ function outputsTypeForStep(step) {
583
+ if (step.outputs === undefined) return {
584
+ kind: 'map'
585
+ };
586
+ return {
587
+ kind: 'object',
588
+ fields: outputDeclarationsToExpressionFields(step.outputs)
589
+ };
590
+ }
591
+ function jobsRootType(jobs) {
592
+ return {
593
+ kind: 'object',
594
+ fields: Object.fromEntries(jobs.map((job)=>[
595
+ job.key,
596
+ jobEntityType(job)
597
+ ]))
598
+ };
599
+ }
600
+ function needsRootType() {
601
+ return {
602
+ kind: 'list',
603
+ element: jobEntityTypeForNeeds()
604
+ };
605
+ }
606
+ function jobEntityTypeForNeeds() {
607
+ return {
608
+ kind: 'object',
609
+ fields: {
610
+ key: 'string',
611
+ status: 'string',
612
+ outputs: {
613
+ kind: 'map'
614
+ },
615
+ executions: {
616
+ kind: 'list',
617
+ element: executionTypeWithOutputs({
618
+ kind: 'map'
619
+ })
620
+ }
621
+ }
622
+ };
623
+ }
624
+ function jobEntityType(job) {
625
+ const outputs = jobOutputsType(job);
626
+ const execution = executionTypeWithOutputs(outputs);
627
+ return {
628
+ kind: 'object',
629
+ fields: {
630
+ key: 'string',
631
+ status: 'string',
632
+ outputs,
633
+ executions: {
634
+ kind: 'list',
635
+ element: execution
636
+ }
637
+ }
638
+ };
639
+ }
640
+ function jobOutputsType(job) {
641
+ return job.outputs === undefined ? {
642
+ kind: 'map'
643
+ } : {
644
+ kind: 'object',
645
+ fields: job.outputs
646
+ };
647
+ }
648
+ function executionTypeWithOutputs(outputs) {
649
+ return {
650
+ kind: 'object',
651
+ fields: {
652
+ ...executionType.fields,
653
+ outputs
654
+ }
655
+ };
656
+ }
657
+ function isWorkflowContextName(root) {
658
+ return Object.hasOwn(workflowContextDefinitions, root);
659
+ }
660
+ function isWorkflowContextReservedRoot(root) {
661
+ return Object.hasOwn(workflowContextReservedRoots, root);
662
+ }
663
+
664
+ //# sourceMappingURL=workflow-context.js.map