@run402/sdk 1.70.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +47 -34
  2. package/dist/index.d.ts +11 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +12 -5
  5. package/dist/index.js.map +1 -1
  6. package/dist/namespaces/{blobs.d.ts → assets.d.ts} +3 -3
  7. package/dist/namespaces/assets.d.ts.map +1 -0
  8. package/dist/namespaces/{blobs.js → assets.js} +2 -2
  9. package/dist/namespaces/assets.js.map +1 -0
  10. package/dist/namespaces/{blobs.types.d.ts → assets.types.d.ts} +1 -1
  11. package/dist/namespaces/assets.types.d.ts.map +1 -0
  12. package/dist/namespaces/{blobs.types.js → assets.types.js} +1 -1
  13. package/dist/namespaces/assets.types.js.map +1 -0
  14. package/dist/namespaces/deploy.d.ts +3 -3
  15. package/dist/namespaces/deploy.d.ts.map +1 -1
  16. package/dist/namespaces/deploy.js +28 -42
  17. package/dist/namespaces/deploy.js.map +1 -1
  18. package/dist/namespaces/deploy.types.d.ts +130 -4
  19. package/dist/namespaces/deploy.types.d.ts.map +1 -1
  20. package/dist/namespaces/deploy.types.js +1 -1
  21. package/dist/namespaces/deploy.types.js.map +1 -1
  22. package/dist/node/assets-node.d.ts +205 -0
  23. package/dist/node/assets-node.d.ts.map +1 -0
  24. package/dist/node/assets-node.js +368 -0
  25. package/dist/node/assets-node.js.map +1 -0
  26. package/dist/node/canonicalize.d.ts +1 -1
  27. package/dist/node/canonicalize.js +1 -1
  28. package/dist/node/index.d.ts +9 -2
  29. package/dist/node/index.d.ts.map +1 -1
  30. package/dist/node/index.js +9 -0
  31. package/dist/node/index.js.map +1 -1
  32. package/dist/scoped.d.ts +38 -12
  33. package/dist/scoped.d.ts.map +1 -1
  34. package/dist/scoped.js +52 -35
  35. package/dist/scoped.js.map +1 -1
  36. package/package.json +1 -1
  37. package/dist/namespaces/blobs.d.ts.map +0 -1
  38. package/dist/namespaces/blobs.js.map +0 -1
  39. package/dist/namespaces/blobs.types.d.ts.map +0 -1
  40. package/dist/namespaces/blobs.types.js.map +0 -1
@@ -7,7 +7,7 @@
7
7
  * - `plan` / `upload` / `commit` — low-level steps for CLI and tests.
8
8
  *
9
9
  * All bytes ride through the CAS content service via presigned PUTs to S3.
10
- * The wire body to `POST /deploy/v2/plans` carries `ContentRef` objects only —
10
+ * The wire body to `POST /apply/v1/plans` carries `ContentRef` objects only —
11
11
  * never inline file bytes. When the normalized spec exceeds 5 MB JSON, the
12
12
  * SDK uploads the manifest itself as a CAS object and references it.
13
13
  *
@@ -141,7 +141,7 @@ export class Deploy {
141
141
  }
142
142
  /**
143
143
  * Low-level plan: normalize the spec, upload the manifest as CAS if over
144
- * the inline limit, and call `POST /deploy/v2/plans`. Returns the plan
144
+ * the inline limit, and call `POST /apply/v1/plans`. Returns the plan
145
145
  * response and a byte-reader map keyed by sha256 (used by `upload`).
146
146
  */
147
147
  async plan(spec, opts = {}) {
@@ -158,7 +158,7 @@ export class Deploy {
158
158
  await uploadMissing(this.client, opts.project, plan.missing_content, opts.byteReaders, emit);
159
159
  }
160
160
  /**
161
- * Low-level commit: `POST /deploy/v2/plans/:id/commit`, then poll
161
+ * Low-level commit: `POST /apply/v1/plans/:id/commit`, then poll
162
162
  * `/operations/:id` until terminal. Pass the project id whose anon_key
163
163
  * should authenticate the polling — the operations endpoint requires
164
164
  * apikey auth even though the plan/commit endpoints accept SIWX.
@@ -189,7 +189,7 @@ export class Deploy {
189
189
  const emit = makeEmitter(opts.onEvent);
190
190
  let snapshot;
191
191
  try {
192
- snapshot = await this.client.request(`/deploy/v2/operations/${encodeURIComponent(operationId)}/resume`, { method: "POST", context: "resuming deploy operation" });
192
+ snapshot = await this.client.request(`/apply/v1/operations/${encodeURIComponent(operationId)}/resume`, { method: "POST", context: "resuming deploy operation" });
193
193
  }
194
194
  catch (err) {
195
195
  throw translateDeployError(err, "resume", null, operationId);
@@ -211,7 +211,7 @@ export class Deploy {
211
211
  }
212
212
  const headers = opts.project ? await apikeyHeaders(this.client, opts.project) : {};
213
213
  try {
214
- return await this.client.request(`/deploy/v2/operations/${encodeURIComponent(operationId)}`, { headers, context: "fetching deploy operation" });
214
+ return await this.client.request(`/apply/v1/operations/${encodeURIComponent(operationId)}`, { headers, context: "fetching deploy operation" });
215
215
  }
216
216
  catch (err) {
217
217
  throw translateDeployError(err, "status", null, operationId);
@@ -239,8 +239,8 @@ export class Deploy {
239
239
  if (cursor !== undefined)
240
240
  qs.set("cursor", cursor);
241
241
  const path = qs.toString().length > 0
242
- ? `/deploy/v2/operations?${qs.toString()}`
243
- : `/deploy/v2/operations`;
242
+ ? `/apply/v1/operations?${qs.toString()}`
243
+ : `/apply/v1/operations`;
244
244
  return this.client.request(path, {
245
245
  headers,
246
246
  context: "listing deploy operations",
@@ -265,7 +265,7 @@ export class Deploy {
265
265
  }
266
266
  const headers = await apikeyHeaders(this.client, opts.project);
267
267
  try {
268
- return await this.client.request(`/deploy/v2/operations/${encodeURIComponent(operationId)}/events`, { headers, context: "fetching deploy events" });
268
+ return await this.client.request(`/apply/v1/operations/${encodeURIComponent(operationId)}/events`, { headers, context: "fetching deploy events" });
269
269
  }
270
270
  catch (err) {
271
271
  throw translateDeployError(err, "events", null, operationId);
@@ -285,7 +285,7 @@ export class Deploy {
285
285
  }
286
286
  const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "r.deploy.getRelease siteLimit", "fetching release inventory");
287
287
  const headers = await apikeyHeaders(this.client, opts.project);
288
- return this.client.request(appendQuery(`/deploy/v2/releases/${encodeURIComponent(opts.releaseId)}`, {
288
+ return this.client.request(appendQuery(`/apply/v1/releases/${encodeURIComponent(opts.releaseId)}`, {
289
289
  site_limit: siteLimit,
290
290
  }), { headers, context: "fetching release inventory" });
291
291
  }
@@ -300,7 +300,7 @@ export class Deploy {
300
300
  }
301
301
  const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "r.deploy.getActiveRelease siteLimit", "fetching active release inventory");
302
302
  const headers = await apikeyHeaders(this.client, opts.project);
303
- return this.client.request(appendQuery("/deploy/v2/releases/active", {
303
+ return this.client.request(appendQuery("/apply/v1/releases/active", {
304
304
  site_limit: siteLimit,
305
305
  }), { headers, context: "fetching active release inventory" });
306
306
  }
@@ -320,7 +320,7 @@ export class Deploy {
320
320
  const qs = new URLSearchParams({ from, to });
321
321
  if (limit !== undefined)
322
322
  qs.set("limit", String(limit));
323
- return this.client.request(`/deploy/v2/releases/diff?${qs.toString()}`, { headers, context: "diffing releases" });
323
+ return this.client.request(`/apply/v1/releases/diff?${qs.toString()}`, { headers, context: "diffing releases" });
324
324
  }
325
325
  /**
326
326
  * Diagnose how a stable public URL or host/path would resolve against the
@@ -335,7 +335,7 @@ export class Deploy {
335
335
  qs.set("path", request.path);
336
336
  if (request.method)
337
337
  qs.set("method", request.method);
338
- return this.client.request(`/deploy/v2/resolve?${qs.toString()}`, { headers, context: "resolving deploy public URL" });
338
+ return this.client.request(`/apply/v1/resolve?${qs.toString()}`, { headers, context: "resolving deploy public URL" });
339
339
  }
340
340
  }
341
341
  function appendQuery(path, params) {
@@ -497,7 +497,7 @@ async function planInternal(client, spec, idempotencyKey, dryRun = false) {
497
497
  }
498
498
  let plan;
499
499
  try {
500
- plan = withClientPlanWarnings(normalized, normalizePlanResponse(await client.request(dryRun ? "/deploy/v2/plans?dry_run=true" : "/deploy/v2/plans", {
500
+ plan = withClientPlanWarnings(normalized, normalizePlanResponse(await client.request(dryRun ? "/apply/v1/plans?dry_run=true" : "/apply/v1/plans", {
501
501
  method: "POST",
502
502
  body,
503
503
  context: "planning deploy",
@@ -715,7 +715,7 @@ function applyScheduledFunctionPatch(scheduled, patch) {
715
715
  async function readActiveScheduledFunctionNames(client, projectId) {
716
716
  let inventory;
717
717
  try {
718
- inventory = await client.request(appendQuery("/deploy/v2/releases/active", { site_limit: 1 }), {
718
+ inventory = await client.request(appendQuery("/apply/v1/releases/active", { site_limit: 1 }), {
719
719
  headers: await apikeyHeaders(client, projectId),
720
720
  context: "fetching active release inventory for deploy preflight",
721
721
  });
@@ -842,7 +842,7 @@ function expandCronNumberPart(part, min, max) {
842
842
  }
843
843
  async function commitInternal(client, planId, idempotencyKey) {
844
844
  try {
845
- return await client.request(`/deploy/v2/plans/${encodeURIComponent(planId)}/commit`, {
845
+ return await client.request(`/apply/v1/plans/${encodeURIComponent(planId)}/commit`, {
846
846
  method: "POST",
847
847
  body: idempotencyKey ? { idempotency_key: idempotencyKey } : {},
848
848
  context: "committing deploy",
@@ -905,20 +905,11 @@ async function uploadMissing(client, projectId, presence, byteReaders, emit) {
905
905
  });
906
906
  }
907
907
  const bytes = await reader();
908
- const uploadedParts = await uploadOneWithRetry(client.fetch, session, bytes);
909
- if (!ciCredentials) {
910
- // Per-session completion legacy non-CI promotion path via
911
- // /storage/v1/uploads/:id/complete. CI sessions skip this route because
912
- // the gateway contract only allows /content/v1/plans*; under CI the
913
- // plan-level content commit performs the CAS promotion.
914
- const completeBody = uploadCompleteBody(session, uploadedParts);
915
- await client.request(`/storage/v1/uploads/${encodeURIComponent(session.upload_id)}/complete`, {
916
- method: "POST",
917
- headers,
918
- body: completeBody,
919
- context: "completing content upload session",
920
- });
921
- }
908
+ await uploadOneWithRetry(client.fetch, session, bytes);
909
+ // v1.48 unified-apply: per-session completion via /storage/v1/uploads/:id/
910
+ // complete was removed (the route is now 404). All sessions are CAS-style
911
+ // staged-then-promote; the plan-level POST /content/v1/plans/:id/commit
912
+ // call below promotes every session for the plan in one shot.
922
913
  done += 1;
923
914
  emit({
924
915
  type: "content.upload.progress",
@@ -1065,7 +1056,7 @@ async function pollUntilReady(client, commit, diff, warnings, emit, projectId) {
1065
1056
  };
1066
1057
  }
1067
1058
  const opHeaders = projectId ? await apikeyHeaders(client, projectId) : {};
1068
- const initialSnapshot = await client.request(`/deploy/v2/operations/${encodeURIComponent(commit.operation_id)}`, { headers: opHeaders, context: "fetching deploy operation" });
1059
+ const initialSnapshot = await client.request(`/apply/v1/operations/${encodeURIComponent(commit.operation_id)}`, { headers: opHeaders, context: "fetching deploy operation" });
1069
1060
  return await pollSnapshotUntilReady(client, initialSnapshot, diff, warnings, emit, projectId);
1070
1061
  }
1071
1062
  async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, projectId) {
@@ -1166,7 +1157,7 @@ async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, pro
1166
1157
  if (Date.now() - start > COMMIT_POLL_BACKOFF_AFTER_MS) {
1167
1158
  interval = Math.min(Math.floor(interval * 1.5), COMMIT_POLL_MAX_MS);
1168
1159
  }
1169
- snapshot = await client.request(`/deploy/v2/operations/${encodeURIComponent(snapshot.operation_id)}`, { headers: opHeaders, context: "polling deploy operation" });
1160
+ snapshot = await client.request(`/apply/v1/operations/${encodeURIComponent(snapshot.operation_id)}`, { headers: opHeaders, context: "polling deploy operation" });
1170
1161
  }
1171
1162
  }
1172
1163
  function isTerminalStaticActivationError(error) {
@@ -1232,7 +1223,7 @@ async function startInternal(client, spec, opts) {
1232
1223
  const fetchSnapshot = async () => {
1233
1224
  if (snapshot && TERMINAL_STATUSES.includes(snapshot.status))
1234
1225
  return snapshot;
1235
- snapshot = await client.request(`/deploy/v2/operations/${encodeURIComponent(operationId)}`, { headers: startHeaders, context: "fetching deploy operation" });
1226
+ snapshot = await client.request(`/apply/v1/operations/${encodeURIComponent(operationId)}`, { headers: startHeaders, context: "fetching deploy operation" });
1236
1227
  return snapshot;
1237
1228
  };
1238
1229
  return {
@@ -2317,14 +2308,9 @@ async function uploadInlineCas(client, projectId, bytes, contentType) {
2317
2308
  });
2318
2309
  if (planRes.missing.length > 0) {
2319
2310
  const session = planRes.missing[0];
2320
- const uploadedParts = await uploadOne(client.fetch, session, bytes);
2321
- // Per-session promotion to CAS (see uploadMissing for the rationale).
2322
- await client.request(`/storage/v1/uploads/${encodeURIComponent(session.upload_id)}/complete`, {
2323
- method: "POST",
2324
- headers,
2325
- body: uploadCompleteBody(session, uploadedParts),
2326
- context: "completing content upload session",
2327
- });
2311
+ await uploadOne(client.fetch, session, bytes);
2312
+ // v1.48 unified-apply: per-session /storage/v1/uploads/:id/complete is
2313
+ // gone (404). The plan-level commit below promotes the session to CAS.
2328
2314
  await client.request(`/content/v1/plans/${encodeURIComponent(planRes.plan_id)}/commit`, { method: "POST", headers, body: {}, context: "committing content upload" });
2329
2315
  }
2330
2316
  return { sha256, size: bytes.byteLength, contentType };
@@ -2332,9 +2318,9 @@ async function uploadInlineCas(client, projectId, bytes, contentType) {
2332
2318
  // ─── Helpers ─────────────────────────────────────────────────────────────────
2333
2319
  /**
2334
2320
  * Build the apikey header set for a project. The v1.34 gateway's
2335
- * `/deploy/v2/operations/:id*` and `/content/v1/plans*` routes require
2321
+ * `/apply/v1/operations/:id*` and `/content/v1/plans*` routes require
2336
2322
  * `apikey: <project.anon_key>` (apikeyAuth middleware). Plan + commit on
2337
- * `/deploy/v2/plans*` use SIWX, which the kernel's getAuth provides
2323
+ * `/apply/v1/plans*` use SIWX, which the kernel's getAuth provides
2338
2324
  * automatically — only the apikey-gated paths need this helper.
2339
2325
  *
2340
2326
  * Returns an empty object when the credentials provider doesn't know the