deepline 0.3.293 → 0.3.295

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 (138) hide show
  1. package/dist/bundling-sources/sdk/src/compat.ts +35 -7
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +269 -267
  4. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +3 -4
  5. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +14 -1
  6. package/dist/cli/auth-EDTRERZP.mjs +31 -0
  7. package/dist/cli/auth-TDHKB277.js +31 -0
  8. package/dist/cli/billing-ELIDPILY.js +1749 -0
  9. package/dist/cli/billing-EXGXJVAU.mjs +1749 -0
  10. package/dist/cli/chunk-2S5Y3TZP.js +5688 -0
  11. package/dist/cli/chunk-3KC45UVF.js +150 -0
  12. package/dist/cli/chunk-3XX5TEA4.js +15 -0
  13. package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
  14. package/dist/cli/chunk-4NEFYBF7.js +2240 -0
  15. package/dist/cli/chunk-5JLQPVNX.js +3056 -0
  16. package/dist/cli/chunk-5KDKFHZI.js +1269 -0
  17. package/dist/cli/chunk-6A3TJUWC.js +76 -0
  18. package/dist/cli/chunk-6O5YZOVN.mjs +890 -0
  19. package/dist/cli/chunk-7P5AA3SN.js +344 -0
  20. package/dist/cli/chunk-AYHLUHE5.js +52 -0
  21. package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
  22. package/dist/cli/chunk-CFVVCN4A.js +735 -0
  23. package/dist/cli/chunk-COGTRVWW.js +30 -0
  24. package/dist/cli/chunk-D4AZUZO4.js +190 -0
  25. package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
  26. package/dist/cli/chunk-EACVZI6N.mjs +1995 -0
  27. package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
  28. package/dist/cli/chunk-EXMLR72R.mjs +0 -0
  29. package/dist/cli/chunk-F35VOIQL.js +890 -0
  30. package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
  31. package/dist/cli/chunk-GHRQQPW2.mjs +2240 -0
  32. package/dist/cli/chunk-GONRLVV3.js +3440 -0
  33. package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
  34. package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
  35. package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
  36. package/dist/cli/chunk-I5YZLGMG.js +1 -0
  37. package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
  38. package/dist/cli/chunk-J5NA2TTX.js +503 -0
  39. package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
  40. package/dist/cli/chunk-JNNOCMQY.js +47 -0
  41. package/dist/cli/chunk-KRD6H754.mjs +30 -0
  42. package/dist/cli/chunk-LA46MMTL.js +560 -0
  43. package/dist/cli/chunk-LDWT7RJK.mjs +190 -0
  44. package/dist/cli/chunk-M2V26OR5.js +499 -0
  45. package/dist/cli/chunk-MIMASXO4.mjs +389 -0
  46. package/dist/cli/chunk-MROPCKW2.mjs +190 -0
  47. package/dist/cli/chunk-NXDRDJ4K.js +389 -0
  48. package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
  49. package/dist/cli/chunk-OG64RBAC.js +6 -0
  50. package/dist/cli/chunk-OQYEC4GL.mjs +34 -0
  51. package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
  52. package/dist/cli/chunk-SDK3ZA2C.js +103 -0
  53. package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
  54. package/dist/cli/chunk-SVIIIYIQ.js +923 -0
  55. package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
  56. package/dist/cli/chunk-U3PI7HBM.js +34 -0
  57. package/dist/cli/chunk-UFS752TU.mjs +52 -0
  58. package/dist/cli/chunk-UI37DQE7.mjs +499 -0
  59. package/dist/cli/chunk-UNEMDKXN.js +1 -0
  60. package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
  61. package/dist/cli/chunk-WJYPBHTE.js +148 -0
  62. package/dist/cli/chunk-WOHBA5PV.js +354 -0
  63. package/dist/cli/chunk-WQICC2B3.js +190 -0
  64. package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
  65. package/dist/cli/chunk-XL2FO6CW.mjs +5688 -0
  66. package/dist/cli/chunk-XNYIZMNQ.js +28 -0
  67. package/dist/cli/chunk-XRK2TZT5.js +1995 -0
  68. package/dist/cli/chunk-YJYPL5OK.mjs +1269 -0
  69. package/dist/cli/chunk-YWNDYCXR.mjs +735 -0
  70. package/dist/cli/chunk-YWWAF7KZ.mjs +923 -0
  71. package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
  72. package/dist/cli/client-4JVOYVC5.js +20 -0
  73. package/dist/cli/client-EEN2IJN2.mjs +20 -0
  74. package/dist/cli/csv-BOHBEP2I.mjs +585 -0
  75. package/dist/cli/csv-S5NYRUEX.js +585 -0
  76. package/dist/cli/db-CLODWCOB.mjs +486 -0
  77. package/dist/cli/db-F6PKFOOV.js +486 -0
  78. package/dist/cli/executions-5TQAKLJU.js +28 -0
  79. package/dist/cli/executions-MAKW6QOY.mjs +28 -0
  80. package/dist/cli/feedback-GV4QJFEN.js +107 -0
  81. package/dist/cli/feedback-XY24TW7H.mjs +107 -0
  82. package/dist/cli/getting-started.js +18 -76
  83. package/dist/cli/getting-started.mjs +10 -37
  84. package/dist/cli/git-6S2C22T5.js +23 -0
  85. package/dist/cli/git-OZLBD5HH.mjs +23 -0
  86. package/dist/cli/index.js +291 -54294
  87. package/dist/cli/index.mjs +209 -54352
  88. package/dist/cli/legacy-noops-LLCGDPQE.js +157 -0
  89. package/dist/cli/legacy-noops-TYH3TW2D.mjs +157 -0
  90. package/dist/cli/monitors-CABMB4DW.js +3251 -0
  91. package/dist/cli/monitors-TTD55HMK.mjs +3251 -0
  92. package/dist/cli/org-MSF3RG76.js +849 -0
  93. package/dist/cli/org-SFJ77MWY.mjs +849 -0
  94. package/dist/cli/play-NXHJSCKL.mjs +18439 -0
  95. package/dist/cli/play-OKSFNNO4.js +18439 -0
  96. package/dist/cli/providers-QC2ERERL.js +95 -0
  97. package/dist/cli/providers-TIIAZEUA.mjs +95 -0
  98. package/dist/cli/proxy-env-EBANZHPV.js +161 -0
  99. package/dist/cli/proxy-env-M4ZHXHRL.mjs +161 -0
  100. package/dist/cli/quickstart-ICANHLMI.js +69 -0
  101. package/dist/cli/quickstart-KWUOP3FI.mjs +69 -0
  102. package/dist/cli/search-U5H2FDOO.mjs +18 -0
  103. package/dist/cli/search-XQRQOLWS.js +18 -0
  104. package/dist/cli/secrets-3J6YTWFA.mjs +400 -0
  105. package/dist/cli/secrets-YNMNZNOM.js +400 -0
  106. package/dist/cli/sessions-CLEES4L6.mjs +15 -0
  107. package/dist/cli/sessions-J6VR47FG.js +15 -0
  108. package/dist/cli/settings-EEKZMTY4.js +846 -0
  109. package/dist/cli/settings-UVLOQZRH.mjs +846 -0
  110. package/dist/cli/setup-DLMDXPGJ.mjs +1257 -0
  111. package/dist/cli/setup-HC4Q7QM4.js +1257 -0
  112. package/dist/cli/skills-33PHFBSB.mjs +28 -0
  113. package/dist/cli/skills-LFRY3KPX.js +28 -0
  114. package/dist/cli/tools-3COEPKML.mjs +2955 -0
  115. package/dist/cli/tools-QXEVCN45.js +2955 -0
  116. package/dist/cli/update-LSAC4FF5.mjs +28 -0
  117. package/dist/cli/update-NXHSPYXA.js +28 -0
  118. package/dist/cli/workflow-7S44OECF.mjs +1936 -0
  119. package/dist/cli/workflow-QPZWYSZE.js +1936 -0
  120. package/dist/helpers.js +6 -32
  121. package/dist/helpers.mjs +2 -0
  122. package/dist/index.js +1972 -12825
  123. package/dist/index.mjs +1910 -12672
  124. package/dist/install-integrity.json +110 -0
  125. package/dist/monitor-fleet-contract.js +31 -730
  126. package/dist/monitor-fleet-contract.mjs +18 -667
  127. package/dist/monitor-input-contract.js +10 -390
  128. package/dist/monitor-input-contract.mjs +7 -348
  129. package/dist/plays/bundle-play-file.mjs +13 -5178
  130. package/dist/plays/csv-data-input.js +5 -3132
  131. package/dist/plays/csv-data-input.mjs +5 -3105
  132. package/dist/plays/run-request.js +56 -664
  133. package/dist/plays/run-request.mjs +30 -588
  134. package/dist/release.d.mts +1 -1
  135. package/dist/release.d.ts +1 -1
  136. package/dist/release.js +5 -212
  137. package/dist/release.mjs +5 -185
  138. package/package.json +1 -1
@@ -1,664 +1,56 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/plays/run-request.ts
21
- var run_request_exports = {};
22
- __export(run_request_exports, {
23
- CSV_DATA_INPUT_KEY: () => CSV_DATA_INPUT_KEY,
24
- DeeplineError: () => DeeplineError,
25
- PLAY_FILES_STAGE_MINT_PATH: () => PLAY_FILES_STAGE_MINT_PATH,
26
- PLAY_FILES_STAGE_PATH: () => PLAY_FILES_STAGE_PATH,
27
- PLAY_RUN_START_PATH: () => PLAY_RUN_START_PATH,
28
- PLAY_RUN_START_STREAM_PATH: () => PLAY_RUN_START_STREAM_PATH,
29
- STAGE_LEGACY_MULTIPART_MAX_BYTES: () => STAGE_LEGACY_MULTIPART_MAX_BYTES,
30
- buildNamedPlayRunRequest: () => buildNamedPlayRunRequest,
31
- buildPlayRunStartBody: () => buildPlayRunStartBody,
32
- createSessionPlayRunHttp: () => createSessionPlayRunHttp,
33
- createStagedFileUpload: () => createStagedFileUpload,
34
- fileInputBindingsFromPlaySchema: () => fileInputBindingsFromPlaySchema,
35
- fileInputBindingsFromStaticPipeline: () => fileInputBindingsFromStaticPipeline,
36
- getDottedInputValue: () => getDottedInputValue,
37
- isPlayRunPackage: () => isPlayRunPackage,
38
- mintStagedPlayFileUploads: () => mintStagedPlayFileUploads,
39
- normalizePlayRunStart: () => normalizePlayRunStart,
40
- playRunFileInputBindings: () => playRunFileInputBindings,
41
- setDottedInputValue: () => setDottedInputValue,
42
- stageFileInputs: () => stageFileInputs,
43
- stagePlayFiles: () => stagePlayFiles,
44
- stagedFileContentType: () => stagedFileContentType,
45
- startPlayRun: () => startPlayRun,
46
- webStagedFileCodec: () => webStagedFileCodec
47
- });
48
- module.exports = __toCommonJS(run_request_exports);
49
-
50
- // ../plays/tool-execution-error.ts
51
- var DEEPLINE_ERROR_BRAND = Symbol.for("deepline.error.v1");
52
- var TOOL_EXECUTION_ERROR_BRAND = Symbol.for(
53
- "deepline.tool-execution-error.v1"
54
- );
55
- var PROVIDER_TRANSIENT_ERROR_BRAND = Symbol.for(
56
- "deepline.provider-transient-error.v1"
57
- );
58
- function nativeInstanceOf(constructor, value) {
59
- return Reflect.apply(Function.prototype[Symbol.hasInstance], constructor, [
60
- value
61
- ]);
62
- }
63
- function hasBrand(value, brand) {
64
- return typeof value === "object" && value !== null && value[brand] === true;
65
- }
66
- function applyBrand(value, brand) {
67
- if (hasBrand(value, brand)) return;
68
- Object.defineProperty(value, brand, {
69
- configurable: false,
70
- enumerable: false,
71
- writable: false,
72
- value: true
73
- });
74
- }
75
- var DeeplineError = class _DeeplineError extends Error {
76
- /** HTTP status when the failure crossed an HTTP boundary. */
77
- statusCode;
78
- /** Stable machine-readable error code when one exists. */
79
- code;
80
- /** Local diagnostic context; not a portable error contract. */
81
- details;
82
- /**
83
- * Construct a Deepline error.
84
- *
85
- * SDK and runtime code construct these errors. Application and Play code
86
- * normally catches the public subclasses instead.
87
- *
88
- * @param message Human-readable failure summary.
89
- * @param statusCode HTTP status when one exists.
90
- * @param code Stable machine-readable code when one exists.
91
- * @param details Local diagnostic context; never a portable error contract.
92
- */
93
- constructor(message, statusCode, code, details) {
94
- super(message);
95
- this.name = "DeeplineError";
96
- this.statusCode = statusCode;
97
- this.code = code;
98
- this.details = details;
99
- applyBrand(this, DEEPLINE_ERROR_BRAND);
100
- }
101
- static [Symbol.hasInstance](value) {
102
- if (this !== _DeeplineError) return nativeInstanceOf(this, value);
103
- return hasBrand(value, DEEPLINE_ERROR_BRAND);
104
- }
105
- };
106
-
107
- // ../play-runtime/run-lifecycle-policy.ts
108
- var TERMINAL_PLAY_RUN_STATUSES = /* @__PURE__ */ new Set([
109
- "completed",
110
- "failed",
111
- "cancelled",
112
- "terminated",
113
- "timed_out"
114
- ]);
115
- function normalizePlayRunLifecycleStatus(value) {
116
- const normalized = String(value ?? "").trim().toLowerCase();
117
- switch (normalized) {
118
- case "queued":
119
- case "pending":
120
- return "queued";
121
- case "running":
122
- case "started":
123
- return "running";
124
- case "waiting":
125
- return "waiting";
126
- case "completed":
127
- case "complete":
128
- case "succeeded":
129
- return "completed";
130
- case "failed":
131
- case "error":
132
- return "failed";
133
- case "cancelled":
134
- case "canceled":
135
- return "cancelled";
136
- case "terminated":
137
- return "terminated";
138
- case "timed_out":
139
- case "timeout":
140
- return "timed_out";
141
- default:
142
- return "unknown";
143
- }
144
- }
145
- function isTerminalPlayRunLifecycleStatus(status) {
146
- return TERMINAL_PLAY_RUN_STATUSES.has(
147
- normalizePlayRunLifecycleStatus(status)
148
- );
149
- }
150
-
151
- // src/api-error.ts
152
- function asRecord(value) {
153
- return typeof value === "object" && value !== null ? value : null;
154
- }
155
- function apiErrorCodeFromResponse(parsed) {
156
- const response = asRecord(parsed);
157
- const error = asRecord(response?.error);
158
- const code = error?.code ?? response?.code;
159
- return typeof code === "string" ? code : "API_ERROR";
160
- }
161
- function apiErrorMessage(parsed, status) {
162
- const errorValue = typeof parsed === "object" && parsed && "error" in parsed ? parsed.error : void 0;
163
- if (typeof errorValue === "string") {
164
- return errorValue;
165
- }
166
- if (errorValue && typeof errorValue === "object" && "message" in errorValue && typeof errorValue.message === "string") {
167
- return errorValue.message;
168
- }
169
- if (typeof parsed === "object" && parsed && "message" in parsed && typeof parsed.message === "string") {
170
- return parsed.message;
171
- }
172
- return `HTTP ${status}`;
173
- }
174
-
175
- // src/plays/run-request.ts
176
- var PLAY_RUN_START_PATH = "/api/v2/plays/run";
177
- var PLAY_RUN_START_STREAM_PATH = `${PLAY_RUN_START_PATH}?stream=true`;
178
- var PLAY_FILES_STAGE_PATH = "/api/v2/plays/files/stage";
179
- var PLAY_FILES_STAGE_MINT_PATH = `${PLAY_FILES_STAGE_PATH}/mint`;
180
- function buildPlayRunStartBody(request) {
181
- return {
182
- ...request.name ? { name: request.name } : {},
183
- ...request.revisionId ? { revisionId: request.revisionId } : {},
184
- ...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
185
- ...request.sourceCode ? { sourceCode: request.sourceCode } : {},
186
- ...request.sourceFiles ? { sourceFiles: request.sourceFiles } : {},
187
- ...request.description ? { description: request.description } : {},
188
- ..."staticPipeline" in request ? { staticPipeline: request.staticPipeline } : {},
189
- ...request.artifactHash ? { artifactHash: request.artifactHash } : {},
190
- ...request.graphHash ? { graphHash: request.graphHash } : {},
191
- ...request.runtimeArtifact ? { runtimeArtifact: request.runtimeArtifact } : {},
192
- ...request.compilerManifest ? { compilerManifest: request.compilerManifest } : {},
193
- ...request.inputFileUpload ? { inputFileUpload: request.inputFileUpload } : {},
194
- ...request.packagedFileUploads?.length ? { packagedFileUploads: request.packagedFileUploads } : {},
195
- ...request.input ? { input: request.input } : {},
196
- ...request.inputFile ? { inputFile: request.inputFile } : {},
197
- ...request.packagedFiles?.length ? { packagedFiles: request.packagedFiles } : {},
198
- ...request.force ? { force: true } : {},
199
- ...request.forceToolRefresh === true ? { forceToolRefresh: true } : {},
200
- ...typeof request.maxConcurrentExternalCalls === "number" ? { maxConcurrentExternalCalls: request.maxConcurrentExternalCalls } : {},
201
- ...typeof request.maxConcurrentRows === "number" ? { maxConcurrentRows: request.maxConcurrentRows } : {},
202
- ...typeof request.waitForCompletionMs === "number" ? { waitForCompletionMs: request.waitForCompletionMs } : {},
203
- // Profile selection is the API's job, not the caller's. The server
204
- // defaults to absurd; callers normally omit this field.
205
- ...request.profile ? { profile: request.profile } : {},
206
- ...request.integrationMode ? { integrationMode: request.integrationMode } : {},
207
- ...request.fixtureBehavior ? { fixtureBehavior: request.fixtureBehavior } : {},
208
- ...request.runtime ? { runtime: request.runtime } : {},
209
- ...request.testPolicyOverrides ? { testPolicyOverrides: request.testPolicyOverrides } : {}
210
- };
211
- }
212
- async function startPlayRun(http, request, headers) {
213
- const response = await http.post(
214
- PLAY_RUN_START_PATH,
215
- buildPlayRunStartBody(request),
216
- headers,
217
- { maxRetries: 0, exactUrlOnly: true }
218
- );
219
- return normalizePlayRunStart(response);
220
- }
221
- function isPlayRunPackage(value) {
222
- return Boolean(
223
- value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run?.id === "string"
224
- );
225
- }
226
- function normalizePlayRunStart(raw) {
227
- const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
228
- if (!runPackage) {
229
- const workflowId = typeof raw.workflowId === "string" && raw.workflowId ? raw.workflowId : typeof raw.runId === "string" ? raw.runId : "";
230
- return {
231
- ...raw,
232
- workflowId
233
- };
234
- }
235
- const status = typeof runPackage.run.status === "string" ? runPackage.run.status : "running";
236
- return {
237
- workflowId: runPackage.run.id,
238
- name: runPackage.run.playName,
239
- status,
240
- ...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
241
- ...isTerminalPlayRunLifecycleStatus(status) ? { finalStatus: runPackage } : {},
242
- package: runPackage
243
- };
244
- }
245
- function buildNamedPlayRunRequest(input) {
246
- return {
247
- name: input.name,
248
- ...input.revisionId ? { revisionId: input.revisionId } : {},
249
- ...Object.keys(input.runtimeInput).length > 0 ? { input: input.runtimeInput } : {},
250
- ...input.stagedFileInputs.inputFile ? { inputFile: input.stagedFileInputs.inputFile } : {},
251
- ...input.stagedFileInputs.packagedFiles.length ? { packagedFiles: input.stagedFileInputs.packagedFiles } : {},
252
- ...input.extra
253
- };
254
- }
255
- var CSV_DATA_INPUT_KEY = "csv";
256
- function schemaMetadata(schema, key) {
257
- if (!schema || typeof schema !== "object" || Array.isArray(schema))
258
- return null;
259
- const value = schema[key];
260
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
261
- }
262
- function stringMetadata(metadata, key) {
263
- const value = metadata?.[key];
264
- return typeof value === "string" && value.trim() ? value.trim() : null;
265
- }
266
- function inputFieldFromCsvArg(csvArg) {
267
- if (typeof csvArg !== "string") return null;
268
- const match = /^\(?\s*input\.([A-Za-z_$][\w$]*)\s*\)?(?:\s*\?\?[\s\S]+)?$/.exec(
269
- csvArg.trim()
270
- );
271
- return match?.[1] ?? null;
272
- }
273
- function fileInputBindingsFromPlaySchema(inputSchema) {
274
- const csvInput = schemaMetadata(inputSchema, "csvInput");
275
- if (!csvInput) return [];
276
- return [
277
- {
278
- inputPath: stringMetadata(csvInput, "inputField") ?? CSV_DATA_INPUT_KEY
279
- }
280
- ];
281
- }
282
- function fileInputBindingsFromStaticPipeline(staticPipeline) {
283
- if (!staticPipeline || typeof staticPipeline !== "object" || Array.isArray(staticPipeline)) {
284
- return [];
285
- }
286
- const inputField = inputFieldFromCsvArg(
287
- staticPipeline.csvArg
288
- );
289
- return inputField ? [{ inputPath: inputField }] : [];
290
- }
291
- function playRunFileInputBindings(play) {
292
- return [
293
- ...fileInputBindingsFromPlaySchema(play.inputSchema),
294
- ...fileInputBindingsFromStaticPipeline(play.staticPipeline)
295
- ];
296
- }
297
- function getDottedInputValue(input, path) {
298
- const parts = path.split(".").map((part) => part.trim()).filter(Boolean);
299
- let cursor = input;
300
- for (const part of parts) {
301
- if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
302
- return void 0;
303
- }
304
- cursor = cursor[part];
305
- }
306
- return cursor;
307
- }
308
- function setDottedInputValue(input, path, value) {
309
- const parts = path.split(".").map((part) => part.trim()).filter(Boolean);
310
- if (parts.length === 0) {
311
- throw new Error(`Invalid play input flag path: ${path}`);
312
- }
313
- let cursor = input;
314
- for (const part of parts.slice(0, -1)) {
315
- const existing = cursor[part];
316
- if (existing !== void 0 && (!existing || typeof existing !== "object" || Array.isArray(existing))) {
317
- throw new Error(
318
- `Cannot set --${path}; input.${part} is already a non-object value.`
319
- );
320
- }
321
- if (!existing) {
322
- cursor[part] = {};
323
- }
324
- cursor = cursor[part];
325
- }
326
- cursor[parts[parts.length - 1]] = value;
327
- }
328
- var webStagedFileCodec = {
329
- async sha256Hex(bytes) {
330
- const digest = await globalThis.crypto.subtle.digest(
331
- "SHA-256",
332
- bytes
333
- );
334
- return Array.from(
335
- new Uint8Array(digest),
336
- (byte) => byte.toString(16).padStart(2, "0")
337
- ).join("");
338
- },
339
- base64(bytes) {
340
- let binary = "";
341
- for (let offset = 0; offset < bytes.length; offset += 32768) {
342
- binary += String.fromCharCode(...bytes.subarray(offset, offset + 32768));
343
- }
344
- return btoa(binary);
345
- }
346
- };
347
- function stagedFileContentType(logicalPath) {
348
- const lower = logicalPath.toLowerCase();
349
- return lower.endsWith(".csv") ? "text/csv" : lower.endsWith(".json") ? "application/json" : "application/octet-stream";
350
- }
351
- async function createStagedFileUpload(logicalPath, bytes, codec = webStagedFileCodec) {
352
- return {
353
- logicalPath,
354
- contentBase64: codec.base64(bytes),
355
- contentHash: await codec.sha256Hex(bytes),
356
- contentType: stagedFileContentType(logicalPath),
357
- bytes: bytes.byteLength
358
- };
359
- }
360
- var STAGE_LEGACY_MULTIPART_MAX_BYTES = 4e6;
361
- var STAGE_DIRECT_UPLOAD_MAX_ATTEMPTS = 3;
362
- function sleep(ms) {
363
- return new Promise((resolve) => setTimeout(resolve, ms));
364
- }
365
- function stagedUploadIdentity(logicalPath, contentHash) {
366
- return `${contentHash}:${logicalPath}`;
367
- }
368
- function isStagedUploadMintUnsupported(error) {
369
- return error instanceof DeeplineError && error.statusCode === 404;
370
- }
371
- function isStagedUploadDirectEgressDenied(error) {
372
- return error instanceof DeeplineError && error.code === "STAGED_FILE_UPLOAD_EGRESS_DENIED";
373
- }
374
- function formatMegabytes(bytes) {
375
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
376
- }
377
- function decodeBase64Bytes(value) {
378
- const binary = atob(value);
379
- const bytes = new Uint8Array(binary.length);
380
- for (let index = 0; index < binary.length; index += 1) {
381
- bytes[index] = binary.charCodeAt(index);
382
- }
383
- return bytes;
384
- }
385
- async function uploadStagedFileToPresignedUrl(input) {
386
- const arrayBuffer = input.body.buffer.slice(
387
- input.body.byteOffset,
388
- input.body.byteOffset + input.body.byteLength
389
- );
390
- let lastError;
391
- for (let attempt = 1; attempt <= STAGE_DIRECT_UPLOAD_MAX_ATTEMPTS; attempt += 1) {
392
- try {
393
- const response = await fetch(input.url, {
394
- method: "PUT",
395
- headers: input.headers,
396
- body: new Blob([arrayBuffer])
397
- });
398
- if (response.ok) {
399
- return;
400
- }
401
- const text = await response.text().catch(() => "");
402
- const egressDenied = response.status === 403 && response.headers.get("x-deny-reason")?.trim().toLowerCase() === "host_not_allowed";
403
- lastError = new DeeplineError(
404
- `Direct storage upload of ${input.logicalPath} failed: ${response.status} ${text.slice(0, 200)}`,
405
- response.status,
406
- egressDenied ? "STAGED_FILE_UPLOAD_EGRESS_DENIED" : "STAGED_FILE_UPLOAD_FAILED",
407
- { logicalPath: input.logicalPath }
408
- );
409
- if (response.status < 500 && response.status !== 429) {
410
- break;
411
- }
412
- } catch (error) {
413
- lastError = error instanceof TypeError ? new DeeplineError(
414
- `Direct storage upload of ${input.logicalPath} could not reach the storage endpoint: ${error.message}`,
415
- void 0,
416
- "STAGED_FILE_UPLOAD_EGRESS_DENIED",
417
- { logicalPath: input.logicalPath }
418
- ) : error;
419
- }
420
- if (attempt < STAGE_DIRECT_UPLOAD_MAX_ATTEMPTS) {
421
- await sleep(250 * attempt);
422
- }
423
- }
424
- throw lastError instanceof Error ? lastError : new DeeplineError(
425
- `Direct storage upload of ${input.logicalPath} failed.`,
426
- void 0,
427
- "STAGED_FILE_UPLOAD_FAILED",
428
- { logicalPath: input.logicalPath }
429
- );
430
- }
431
- async function mintStagedPlayFileUploads(http, files) {
432
- const response = await http.post(PLAY_FILES_STAGE_MINT_PATH, { files });
433
- return response.uploads ?? [];
434
- }
435
- async function stagePlayFilesViaMultipart(http, files, reason = "mint-unsupported") {
436
- for (const file of files) {
437
- if (file.bytes > STAGE_LEGACY_MULTIPART_MAX_BYTES) {
438
- const reasonMessage = reason === "direct-egress-denied" ? "direct storage is blocked by this environment's network egress policy" : "the connected Deepline server does not support direct-to-storage uploads";
439
- throw new DeeplineError(
440
- `Cannot stage ${file.logicalPath} (${formatMegabytes(file.bytes)}): ${reasonMessage}, and this file exceeds the ~4.5MB request-body limit the legacy upload path is subject to.`,
441
- 413,
442
- "STAGED_FILE_TOO_LARGE_FOR_LEGACY_UPLOAD",
443
- {
444
- logicalPath: file.logicalPath,
445
- bytes: file.bytes,
446
- maxBytes: STAGE_LEGACY_MULTIPART_MAX_BYTES
447
- }
448
- );
449
- }
450
- }
451
- const buildFormData = () => {
452
- const formData = new FormData();
453
- formData.set(
454
- "metadata",
455
- JSON.stringify({
456
- files: files.map((file, index) => ({
457
- index,
458
- logicalPath: file.logicalPath,
459
- contentHash: file.contentHash,
460
- contentType: file.contentType,
461
- bytes: file.bytes
462
- }))
463
- })
464
- );
465
- for (const [index, file] of files.entries()) {
466
- const bytes = decodeBase64Bytes(file.contentBase64);
467
- const body = bytes.buffer.slice(
468
- bytes.byteOffset,
469
- bytes.byteOffset + bytes.byteLength
470
- );
471
- formData.set(
472
- `file:${index}`,
473
- new Blob([body], { type: file.contentType }),
474
- file.logicalPath
475
- );
476
- }
477
- return formData;
478
- };
479
- const response = await http.postFormData(PLAY_FILES_STAGE_PATH, buildFormData);
480
- return response.files;
481
- }
482
- async function stagePlayFiles(http, files) {
483
- let uploads;
484
- try {
485
- uploads = await mintStagedPlayFileUploads(
486
- http,
487
- files.map((file) => ({
488
- logicalPath: file.logicalPath,
489
- contentHash: file.contentHash,
490
- contentType: file.contentType,
491
- bytes: file.bytes
492
- }))
493
- );
494
- } catch (error) {
495
- if (isStagedUploadMintUnsupported(error)) {
496
- return stagePlayFilesViaMultipart(http, files);
497
- }
498
- throw error;
499
- }
500
- const uploadByIdentity = /* @__PURE__ */ new Map();
501
- for (const upload of uploads) {
502
- uploadByIdentity.set(
503
- stagedUploadIdentity(upload.logicalPath, upload.contentHash),
504
- upload
505
- );
506
- }
507
- const directResults = await Promise.all(
508
- files.map(async (file) => {
509
- const upload = uploadByIdentity.get(
510
- stagedUploadIdentity(file.logicalPath, file.contentHash)
511
- );
512
- if (!upload) {
513
- throw new DeeplineError(
514
- `The staging server did not return an upload target for ${file.logicalPath}.`,
515
- void 0,
516
- "STAGED_FILE_MINT_INCOMPLETE"
517
- );
518
- }
519
- if (upload.alreadyStaged || !upload.uploadUrl) {
520
- return { ref: upload.ref };
521
- }
522
- try {
523
- await uploadStagedFileToPresignedUrl({
524
- url: upload.uploadUrl,
525
- headers: upload.uploadHeaders ?? {
526
- "content-type": file.contentType
527
- },
528
- body: decodeBase64Bytes(file.contentBase64),
529
- logicalPath: file.logicalPath
530
- });
531
- return { ref: upload.ref };
532
- } catch (error) {
533
- if (isStagedUploadDirectEgressDenied(error)) {
534
- return { fallbackFile: file };
535
- }
536
- throw error;
537
- }
538
- })
539
- );
540
- return await Promise.all(
541
- directResults.map(async (result) => {
542
- if ("fallbackFile" in result) {
543
- const [ref] = await stagePlayFilesViaMultipart(
544
- http,
545
- [result.fallbackFile],
546
- "direct-egress-denied"
547
- );
548
- if (!ref) {
549
- throw new DeeplineError(
550
- `The staging server did not return an upload target for ${result.fallbackFile.logicalPath}.`,
551
- void 0,
552
- "STAGED_FILE_MINT_INCOMPLETE"
553
- );
554
- }
555
- return ref;
556
- }
557
- return result.ref;
558
- })
559
- );
560
- }
561
- async function stageFileInputs(input) {
562
- const uniqueBindings = [
563
- ...new Map(
564
- input.bindings.map((binding) => [binding.inputPath, binding])
565
- ).values()
566
- ];
567
- const localFiles = uniqueBindings.flatMap((binding) => {
568
- const file = input.resolveLocalFile(
569
- getDottedInputValue(input.runtimeInput, binding.inputPath),
570
- binding
571
- );
572
- return file ? [{ binding, file }] : [];
573
- });
574
- if (localFiles.length === 0) {
575
- return { inputFile: null, packagedFiles: [] };
576
- }
577
- input.onStaging?.(localFiles.length);
578
- const uploads = await Promise.all(
579
- localFiles.map(
580
- async ({ file }) => createStagedFileUpload(file.logicalPath, await file.read(), input.codec)
581
- )
582
- );
583
- const staged = await input.stage(uploads);
584
- for (const [index, { binding, file }] of localFiles.entries()) {
585
- setDottedInputValue(
586
- input.runtimeInput,
587
- binding.inputPath,
588
- file.logicalPath
589
- );
590
- const stagedFile = staged[index];
591
- if (stagedFile && stagedFile.logicalPath !== file.logicalPath) {
592
- setDottedInputValue(
593
- input.runtimeInput,
594
- binding.inputPath,
595
- stagedFile.logicalPath
596
- );
597
- }
598
- }
599
- return {
600
- inputFile: staged[0] ?? null,
601
- packagedFiles: staged.slice(1)
602
- };
603
- }
604
- function createSessionPlayRunHttp(fetchImpl = (...args) => fetch(...args)) {
605
- const send = async (path, init) => {
606
- const response = await fetchImpl(path, {
607
- ...init,
608
- credentials: "include"
609
- });
610
- const text = await response.text();
611
- let parsed = text;
612
- try {
613
- parsed = text ? JSON.parse(text) : null;
614
- } catch {
615
- }
616
- if (!response.ok) {
617
- throw new DeeplineError(
618
- apiErrorMessage(parsed, response.status),
619
- response.status,
620
- apiErrorCodeFromResponse(parsed),
621
- { response: parsed }
622
- );
623
- }
624
- return parsed;
625
- };
626
- return {
627
- post: (path, body, headers) => send(path, {
628
- method: "POST",
629
- headers: { "content-type": "application/json", ...headers },
630
- body: JSON.stringify(body)
631
- }),
632
- postFormData: (path, formData) => send(path, {
633
- method: "POST",
634
- body: typeof formData === "function" ? formData() : formData
635
- })
636
- };
637
- }
638
- // Annotate the CommonJS export names for ESM import in node:
639
- 0 && (module.exports = {
640
- CSV_DATA_INPUT_KEY,
641
- DeeplineError,
642
- PLAY_FILES_STAGE_MINT_PATH,
643
- PLAY_FILES_STAGE_PATH,
644
- PLAY_RUN_START_PATH,
645
- PLAY_RUN_START_STREAM_PATH,
646
- STAGE_LEGACY_MULTIPART_MAX_BYTES,
647
- buildNamedPlayRunRequest,
648
- buildPlayRunStartBody,
649
- createSessionPlayRunHttp,
650
- createStagedFileUpload,
651
- fileInputBindingsFromPlaySchema,
652
- fileInputBindingsFromStaticPipeline,
653
- getDottedInputValue,
654
- isPlayRunPackage,
655
- mintStagedPlayFileUploads,
656
- normalizePlayRunStart,
657
- playRunFileInputBindings,
658
- setDottedInputValue,
659
- stageFileInputs,
660
- stagePlayFiles,
661
- stagedFileContentType,
662
- startPlayRun,
663
- webStagedFileCodec
664
- });
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ var _chunkLA46MMTLjs = require('../cli/chunk-LA46MMTL.js');
26
+ require('../cli/chunk-XNYIZMNQ.js');
27
+
28
+
29
+ var _chunk7P5AA3SNjs = require('../cli/chunk-7P5AA3SN.js');
30
+ require('../cli/chunk-COGTRVWW.js');
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ exports.CSV_DATA_INPUT_KEY = _chunkLA46MMTLjs.CSV_DATA_INPUT_KEY; exports.DeeplineError = _chunk7P5AA3SNjs.DeeplineError; exports.PLAY_FILES_STAGE_MINT_PATH = _chunkLA46MMTLjs.PLAY_FILES_STAGE_MINT_PATH; exports.PLAY_FILES_STAGE_PATH = _chunkLA46MMTLjs.PLAY_FILES_STAGE_PATH; exports.PLAY_RUN_START_PATH = _chunkLA46MMTLjs.PLAY_RUN_START_PATH; exports.PLAY_RUN_START_STREAM_PATH = _chunkLA46MMTLjs.PLAY_RUN_START_STREAM_PATH; exports.STAGE_LEGACY_MULTIPART_MAX_BYTES = _chunkLA46MMTLjs.STAGE_LEGACY_MULTIPART_MAX_BYTES; exports.buildNamedPlayRunRequest = _chunkLA46MMTLjs.buildNamedPlayRunRequest; exports.buildPlayRunStartBody = _chunkLA46MMTLjs.buildPlayRunStartBody; exports.createSessionPlayRunHttp = _chunkLA46MMTLjs.createSessionPlayRunHttp; exports.createStagedFileUpload = _chunkLA46MMTLjs.createStagedFileUpload; exports.fileInputBindingsFromPlaySchema = _chunkLA46MMTLjs.fileInputBindingsFromPlaySchema; exports.fileInputBindingsFromStaticPipeline = _chunkLA46MMTLjs.fileInputBindingsFromStaticPipeline; exports.getDottedInputValue = _chunkLA46MMTLjs.getDottedInputValue; exports.isPlayRunPackage = _chunkLA46MMTLjs.isPlayRunPackage; exports.mintStagedPlayFileUploads = _chunkLA46MMTLjs.mintStagedPlayFileUploads; exports.normalizePlayRunStart = _chunkLA46MMTLjs.normalizePlayRunStart; exports.playRunFileInputBindings = _chunkLA46MMTLjs.playRunFileInputBindings; exports.setDottedInputValue = _chunkLA46MMTLjs.setDottedInputValue; exports.stageFileInputs = _chunkLA46MMTLjs.stageFileInputs; exports.stagePlayFiles = _chunkLA46MMTLjs.stagePlayFiles; exports.stagedFileContentType = _chunkLA46MMTLjs.stagedFileContentType; exports.startPlayRun = _chunkLA46MMTLjs.startPlayRun; exports.webStagedFileCodec = _chunkLA46MMTLjs.webStagedFileCodec;