deepline 0.1.168 → 0.1.169

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 (30) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +317 -26
  2. package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +99 -6
  3. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +229 -75
  4. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +119 -33
  5. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +2 -0
  6. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-instance-create.ts +3 -0
  7. package/dist/bundling-sources/sdk/src/client.ts +29 -1
  8. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  9. package/dist/bundling-sources/sdk/src/types.ts +3 -0
  10. package/dist/bundling-sources/shared_libs/play-data-plane/column-names.ts +50 -8
  11. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +40 -1
  12. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +3 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +2 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +1 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +2 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +2 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +1 -0
  19. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +202 -45
  20. package/dist/cli/index.js +70 -113
  21. package/dist/cli/index.mjs +70 -113
  22. package/dist/{compiler-manifest-VhtM9n24.d.mts → compiler-manifest-OwORQ07f.d.mts} +1 -0
  23. package/dist/{compiler-manifest-VhtM9n24.d.ts → compiler-manifest-OwORQ07f.d.ts} +1 -0
  24. package/dist/index.d.mts +5 -1
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +26 -5
  27. package/dist/index.mjs +26 -5
  28. package/dist/plays/bundle-play-file.d.mts +2 -2
  29. package/dist/plays/bundle-play-file.d.ts +2 -2
  30. package/package.json +1 -1
@@ -178,6 +178,7 @@ export function ensureCompiledSheetContract(
178
178
  }
179
179
 
180
180
  const DEFAULT_MAX_EMBEDDED_PLAY_CALL_PIPELINE_DEPTH = 3;
181
+ const DEFAULT_MAX_STORED_SUBSTEP_DEPTH = 3;
181
182
 
182
183
  function cloneStorageSafeSourceRange(
183
184
  sourceRange: PlayStaticSourceRange | undefined,
@@ -195,22 +196,140 @@ function cloneStorageSafeSheetContract(
195
196
  };
196
197
  }
197
198
 
199
+ function omitUndefinedProperties<T extends Record<string, unknown>>(
200
+ value: T,
201
+ ): T {
202
+ const out: Record<string, unknown> = {};
203
+ for (const [key, entry] of Object.entries(value)) {
204
+ if (entry !== undefined) {
205
+ out[key] = entry;
206
+ }
207
+ }
208
+ return out as T;
209
+ }
210
+
211
+ function stripUndefinedDeep<T>(value: T): T {
212
+ if (Array.isArray(value)) {
213
+ return value.map((entry) => stripUndefinedDeep(entry)) as T;
214
+ }
215
+ if (value && typeof value === 'object') {
216
+ const out: Record<string, unknown> = {};
217
+ for (const [key, entry] of Object.entries(value)) {
218
+ if (entry !== undefined) {
219
+ out[key] = stripUndefinedDeep(entry);
220
+ }
221
+ }
222
+ return out as T;
223
+ }
224
+ return value;
225
+ }
226
+
227
+ function truncateStaticControlFlowBranchesForStorage(
228
+ branches: PlayStaticControlFlowBranch[] | undefined,
229
+ input: {
230
+ embeddedPlayCallPipelineDepth: number;
231
+ maxEmbeddedPlayCallPipelineDepth: number;
232
+ maxStoredSubstepDepth: number;
233
+ storedSubstepDepth: number;
234
+ },
235
+ ): PlayStaticControlFlowBranch[] | undefined {
236
+ if (!branches) return undefined;
237
+ return branches.map((branch) =>
238
+ omitUndefinedProperties({
239
+ label: branch.label,
240
+ condition: branch.condition,
241
+ steps: truncateStaticSubstepsForStorage(
242
+ branch.steps,
243
+ nextStoredSubstepInput(input),
244
+ ),
245
+ }),
246
+ );
247
+ }
248
+
249
+ function nextStoredSubstepInput(input: {
250
+ embeddedPlayCallPipelineDepth: number;
251
+ maxEmbeddedPlayCallPipelineDepth: number;
252
+ maxStoredSubstepDepth: number;
253
+ storedSubstepDepth: number;
254
+ }) {
255
+ return {
256
+ ...input,
257
+ storedSubstepDepth: input.storedSubstepDepth + 1,
258
+ };
259
+ }
260
+
261
+ function truncateStaticSubstepShallowForStorage(
262
+ substep: Record<string, unknown>,
263
+ ): PlayStaticSubstep {
264
+ const shallow: Record<string, unknown> = { ...substep };
265
+ delete shallow.branches;
266
+ delete shallow.pipeline;
267
+ delete shallow.steps;
268
+
269
+ if (
270
+ shallow.type === 'control_flow' ||
271
+ shallow.type === 'dataset' ||
272
+ shallow.type === 'step_suite'
273
+ ) {
274
+ shallow.steps = [];
275
+ }
276
+
277
+ return omitUndefinedProperties(shallow) as PlayStaticSubstep;
278
+ }
279
+
198
280
  function truncateStaticSubstepsForStorage(
199
281
  substeps: PlayStaticSubstep[] | undefined,
200
282
  input: {
201
283
  embeddedPlayCallPipelineDepth: number;
202
284
  maxEmbeddedPlayCallPipelineDepth: number;
285
+ maxStoredSubstepDepth: number;
286
+ storedSubstepDepth: number;
203
287
  },
204
288
  ): PlayStaticSubstep[] {
205
289
  return (substeps ?? []).map((substep) => {
206
- const base = {
207
- ...substep,
290
+ const {
291
+ paramsSource: _paramsSource,
292
+ returnSource: _returnSource,
293
+ sourceText: _sourceText,
294
+ ...substepWithoutSourceText
295
+ } = substep as PlayStaticSubstep & {
296
+ paramsSource?: string;
297
+ pipeline?: PlayStaticPipeline | null;
298
+ returnSource?: string;
299
+ sourceText?: string;
300
+ };
301
+ const base = omitUndefinedProperties({
302
+ ...substepWithoutSourceText,
208
303
  sourceRange: cloneStorageSafeSourceRange(substep.sourceRange),
209
304
  callPath: substep.callPath ? [...substep.callPath] : undefined,
210
- };
305
+ });
306
+
307
+ if (input.storedSubstepDepth >= input.maxStoredSubstepDepth) {
308
+ return truncateStaticSubstepShallowForStorage(base);
309
+ }
310
+
311
+ if (
312
+ base.type !== 'play_call' &&
313
+ 'pipeline' in substepWithoutSourceText
314
+ ) {
315
+ const nestedPipeline = substepWithoutSourceText.pipeline;
316
+ (base as { pipeline?: PlayStaticPipeline | null }).pipeline =
317
+ nestedPipeline
318
+ ? truncateStaticPipelineForStorage(nestedPipeline, {
319
+ maxEmbeddedPlayCallPipelineDepth:
320
+ input.maxEmbeddedPlayCallPipelineDepth,
321
+ embeddedPlayCallPipelineDepth:
322
+ input.embeddedPlayCallPipelineDepth + 1,
323
+ maxStoredSubstepDepth: input.maxStoredSubstepDepth,
324
+ storedSubstepDepth: input.storedSubstepDepth + 1,
325
+ })
326
+ : nestedPipeline;
327
+ }
328
+
329
+ const nestedInput = nextStoredSubstepInput(input);
211
330
 
212
331
  if (base.type === 'dataset') {
213
- return {
332
+ return omitUndefinedProperties({
214
333
  ...base,
215
334
  inputFields: base.inputFields ? [...base.inputFields] : undefined,
216
335
  rowKeyFields: base.rowKeyFields ? [...base.rowKeyFields] : undefined,
@@ -219,14 +338,14 @@ function truncateStaticSubstepsForStorage(
219
338
  ? base.columns.map((column) => ({
220
339
  ...column,
221
340
  producers: column.producers.map((producer) => ({
222
- ...producer,
341
+ ...omitUndefinedProperties({ ...producer }),
223
342
  dependsOnFields: producer.dependsOnFields
224
343
  ? [...producer.dependsOnFields]
225
344
  : undefined,
226
345
  sourceRange: cloneStorageSafeSourceRange(producer.sourceRange),
227
346
  steps: producer.steps
228
347
  ? producer.steps.map((stepProducer) => ({
229
- ...stepProducer,
348
+ ...omitUndefinedProperties({ ...stepProducer }),
230
349
  dependsOnFields: stepProducer.dependsOnFields
231
350
  ? [...stepProducer.dependsOnFields]
232
351
  : undefined,
@@ -239,26 +358,52 @@ function truncateStaticSubstepsForStorage(
239
358
  }))
240
359
  : undefined,
241
360
  waterfallIds: base.waterfallIds ? [...base.waterfallIds] : undefined,
242
- steps: truncateStaticSubstepsForStorage(base.steps, input),
361
+ steps: truncateStaticSubstepsForStorage(base.steps, nestedInput),
243
362
  sheetContract: cloneStorageSafeSheetContract(base.sheetContract),
244
- };
363
+ });
245
364
  }
246
365
 
247
366
  if (base.type === 'waterfall') {
248
- return {
367
+ return omitUndefinedProperties({
249
368
  ...base,
250
- steps: base.steps?.map((step) => ({ ...step })),
251
- };
369
+ steps: base.steps?.map((step) =>
370
+ omitUndefinedProperties({
371
+ id: step.id,
372
+ kind: step.kind,
373
+ toolId: step.toolId,
374
+ }),
375
+ ),
376
+ });
252
377
  }
253
378
 
254
379
  if (base.type === 'control_flow') {
255
- return {
380
+ return omitUndefinedProperties({
256
381
  ...base,
257
- steps: truncateStaticSubstepsForStorage(base.steps, input),
258
- };
382
+ steps: truncateStaticSubstepsForStorage(base.steps, nestedInput),
383
+ branches: truncateStaticControlFlowBranchesForStorage(
384
+ base.branches,
385
+ input,
386
+ ),
387
+ });
388
+ }
389
+
390
+ if (base.type === 'step_suite') {
391
+ return omitUndefinedProperties({
392
+ ...base,
393
+ steps: truncateStaticSubstepsForStorage(base.steps, nestedInput),
394
+ });
259
395
  }
260
396
 
261
397
  if (base.type !== 'play_call') {
398
+ if (Array.isArray((base as { steps?: unknown }).steps)) {
399
+ return omitUndefinedProperties({
400
+ ...base,
401
+ steps: truncateStaticSubstepsForStorage(
402
+ (base as { steps?: PlayStaticSubstep[] }).steps,
403
+ nestedInput,
404
+ ),
405
+ });
406
+ }
262
407
  return base;
263
408
  }
264
409
 
@@ -267,23 +412,25 @@ function truncateStaticSubstepsForStorage(
267
412
  input.embeddedPlayCallPipelineDepth >=
268
413
  input.maxEmbeddedPlayCallPipelineDepth
269
414
  ) {
270
- return {
415
+ return omitUndefinedProperties({
271
416
  ...base,
272
417
  pipeline: null,
273
418
  resolutionError:
274
419
  base.resolutionError ??
275
420
  `Stored static pipeline truncated at ${base.playId}`,
276
- };
421
+ });
277
422
  }
278
423
 
279
- return {
424
+ return omitUndefinedProperties({
280
425
  ...base,
281
426
  pipeline: truncateStaticPipelineForStorage(base.pipeline, {
282
427
  maxEmbeddedPlayCallPipelineDepth:
283
428
  input.maxEmbeddedPlayCallPipelineDepth,
284
429
  embeddedPlayCallPipelineDepth: input.embeddedPlayCallPipelineDepth + 1,
430
+ maxStoredSubstepDepth: input.maxStoredSubstepDepth,
431
+ storedSubstepDepth: input.storedSubstepDepth + 1,
285
432
  }),
286
- };
433
+ });
287
434
  });
288
435
  }
289
436
 
@@ -292,6 +439,8 @@ export function truncateStaticPipelineForStorage(
292
439
  options: {
293
440
  maxEmbeddedPlayCallPipelineDepth?: number;
294
441
  embeddedPlayCallPipelineDepth?: number;
442
+ maxStoredSubstepDepth?: number;
443
+ storedSubstepDepth?: number;
295
444
  } = {},
296
445
  ): PlayStaticPipeline | null | undefined {
297
446
  if (!pipeline) {
@@ -302,30 +451,39 @@ export function truncateStaticPipelineForStorage(
302
451
  DEFAULT_MAX_EMBEDDED_PLAY_CALL_PIPELINE_DEPTH;
303
452
  const embeddedPlayCallPipelineDepth =
304
453
  options.embeddedPlayCallPipelineDepth ?? 0;
305
-
306
- return {
307
- ...pipeline,
308
- inputFields: pipeline.inputFields ? [...pipeline.inputFields] : undefined,
309
- rowKeyFields: pipeline.rowKeyFields
310
- ? [...pipeline.rowKeyFields]
311
- : undefined,
312
- fields: [...(pipeline.fields ?? [])],
313
- returnFields: pipeline.returnFields
314
- ? pipeline.returnFields.map((field) => ({ ...field }))
315
- : undefined,
316
- stages: truncateStaticSubstepsForStorage(pipeline.stages, {
317
- embeddedPlayCallPipelineDepth,
318
- maxEmbeddedPlayCallPipelineDepth,
319
- }),
320
- substeps: truncateStaticSubstepsForStorage(pipeline.substeps, {
321
- embeddedPlayCallPipelineDepth,
322
- maxEmbeddedPlayCallPipelineDepth,
454
+ const maxStoredSubstepDepth =
455
+ options.maxStoredSubstepDepth ?? DEFAULT_MAX_STORED_SUBSTEP_DEPTH;
456
+ const storedSubstepDepth = options.storedSubstepDepth ?? 0;
457
+
458
+ return stripUndefinedDeep(
459
+ omitUndefinedProperties({
460
+ ...pipeline,
461
+ inputFields: pipeline.inputFields ? [...pipeline.inputFields] : undefined,
462
+ rowKeyFields: pipeline.rowKeyFields
463
+ ? [...pipeline.rowKeyFields]
464
+ : undefined,
465
+ fields: [...(pipeline.fields ?? [])],
466
+ returnFields: pipeline.returnFields
467
+ ? pipeline.returnFields.map((field) => ({ ...field }))
468
+ : undefined,
469
+ stages: truncateStaticSubstepsForStorage(pipeline.stages, {
470
+ embeddedPlayCallPipelineDepth,
471
+ maxEmbeddedPlayCallPipelineDepth,
472
+ maxStoredSubstepDepth,
473
+ storedSubstepDepth,
474
+ }),
475
+ substeps: truncateStaticSubstepsForStorage(pipeline.substeps, {
476
+ embeddedPlayCallPipelineDepth,
477
+ maxEmbeddedPlayCallPipelineDepth,
478
+ maxStoredSubstepDepth,
479
+ storedSubstepDepth,
480
+ }),
481
+ sheetContract: cloneStorageSafeSheetContract(pipeline.sheetContract),
482
+ sheetContractErrors: pipeline.sheetContractErrors
483
+ ? [...pipeline.sheetContractErrors]
484
+ : undefined,
323
485
  }),
324
- sheetContract: cloneStorageSafeSheetContract(pipeline.sheetContract),
325
- sheetContractErrors: pipeline.sheetContractErrors
326
- ? [...pipeline.sheetContractErrors]
327
- : undefined,
328
- };
486
+ );
329
487
  }
330
488
 
331
489
  export interface PlayStaticSourceRange {
@@ -338,6 +496,7 @@ export interface PlayStaticSourceRange {
338
496
 
339
497
  type PlayStaticSubstepMetadata = {
340
498
  conditional?: boolean;
499
+ disabled?: boolean;
341
500
  dependsOnFields?: string[];
342
501
  };
343
502
 
@@ -680,10 +839,7 @@ function compileDatasetColumns(
680
839
  sqlSafePlayColumnName(field),
681
840
  );
682
841
  if (!column) continue;
683
- const producer = columnProducerFromSubstep(
684
- substep,
685
- field,
686
- );
842
+ const producer = columnProducerFromSubstep(substep, field);
687
843
  column.producers.push(producer);
688
844
  }
689
845
 
@@ -735,6 +891,7 @@ function columnProducerFromSubstep(
735
891
  ? { dependsOnFields: [...substep.dependsOnFields] }
736
892
  : {}),
737
893
  ...(substep.conditional ? { conditional: true } : {}),
894
+ ...(substep.disabled ? { disabled: true } : {}),
738
895
  ...(substep.sourceRange ? { sourceRange: substep.sourceRange } : {}),
739
896
  ...(steps && steps.length > 0 ? { steps } : {}),
740
897
  substep,