@run402/sdk 2.44.0 → 2.46.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.
- package/README.md +11 -12
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/namespaces/assets.d.ts.map +1 -1
- package/dist/namespaces/assets.js +26 -2
- package/dist/namespaces/assets.js.map +1 -1
- package/dist/namespaces/billing.d.ts +22 -12
- package/dist/namespaces/billing.d.ts.map +1 -1
- package/dist/namespaces/billing.js +38 -48
- package/dist/namespaces/billing.js.map +1 -1
- package/dist/namespaces/deploy.d.ts +1 -1
- package/dist/namespaces/deploy.d.ts.map +1 -1
- package/dist/namespaces/deploy.js +145 -18
- package/dist/namespaces/deploy.js.map +1 -1
- package/dist/namespaces/deploy.types.d.ts +19 -10
- package/dist/namespaces/deploy.types.d.ts.map +1 -1
- package/dist/namespaces/deploy.types.js +3 -3
- package/dist/namespaces/deploy.types.js.map +1 -1
- package/dist/namespaces/jobs.d.ts +15 -4
- package/dist/namespaces/jobs.d.ts.map +1 -1
- package/dist/namespaces/jobs.js +19 -1
- package/dist/namespaces/jobs.js.map +1 -1
- package/dist/namespaces/projects.d.ts +1 -1
- package/dist/namespaces/projects.d.ts.map +1 -1
- package/dist/namespaces/projects.js +40 -6
- package/dist/namespaces/projects.js.map +1 -1
- package/dist/node/deploy-manifest.d.ts +9 -8
- package/dist/node/deploy-manifest.d.ts.map +1 -1
- package/dist/node/deploy-manifest.js +82 -33
- package/dist/node/deploy-manifest.js.map +1 -1
- package/dist/node/files.d.ts +2 -2
- package/dist/node/files.js +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/sites-node.d.ts +3 -3
- package/dist/node/sites-node.js +3 -3
- package/dist/retry.d.ts +1 -1
- package/dist/retry.js +1 -1
- package/dist/scoped.d.ts +10 -21
- package/dist/scoped.d.ts.map +1 -1
- package/dist/scoped.js +40 -78
- package/dist/scoped.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* accept any of the three identifier forms and resolve internally. Organization
|
|
8
8
|
* reads require SIWX from a wallet linked to the organization (or matching the
|
|
9
9
|
* looked-up `?wallet`), or an admin key; email lookups are admin-only.
|
|
10
|
-
* Mutations such as link-wallet
|
|
11
|
-
*
|
|
10
|
+
* Mutations such as link-wallet, checkout creation, and auto-recharge require
|
|
11
|
+
* an org credential (or admin).
|
|
12
12
|
*/
|
|
13
13
|
import { LocalError } from "../errors.js";
|
|
14
14
|
import { assertEmailAddress, assertEvmAddress, assertNonEmptyString, assertPositiveSafeInteger, assertStringInSet, } from "../validation.js";
|
|
@@ -64,24 +64,36 @@ function assertUsdMicrosAmount(value, name, context) {
|
|
|
64
64
|
throw new LocalError(`${name} must be a safe integer USD-micros amount of at least 500000 and whole-cent aligned.`, context);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
if (!
|
|
69
|
-
throw new LocalError("
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
function checkoutRequestBody(request, context) {
|
|
68
|
+
if (!request || typeof request !== "object" || Array.isArray(request)) {
|
|
69
|
+
throw new LocalError("checkout must be an object with a product.", context);
|
|
70
|
+
}
|
|
71
|
+
if (request.product === "balance_topup") {
|
|
72
|
+
assertUsdMicrosAmount(request.amountUsdMicros, "amountUsdMicros", context);
|
|
73
|
+
return {
|
|
74
|
+
product: "balance_topup",
|
|
75
|
+
amount_usd_micros: request.amountUsdMicros,
|
|
76
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
77
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
78
|
+
};
|
|
75
79
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
return {
|
|
80
|
+
if (request.product === "tier") {
|
|
81
|
+
assertStringInSet(request.tier, BILLING_TIERS, "tier", context);
|
|
82
|
+
return {
|
|
83
|
+
product: "tier",
|
|
84
|
+
tier: request.tier,
|
|
85
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
86
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
87
|
+
};
|
|
79
88
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
if (request.product === "email_pack") {
|
|
90
|
+
return {
|
|
91
|
+
product: "email_pack",
|
|
92
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
93
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
94
|
+
};
|
|
83
95
|
}
|
|
84
|
-
throw new LocalError("
|
|
96
|
+
throw new LocalError("product must be one of: balance_topup, tier, email_pack.", context);
|
|
85
97
|
}
|
|
86
98
|
export class Billing {
|
|
87
99
|
client;
|
|
@@ -145,15 +157,14 @@ export class Billing {
|
|
|
145
157
|
context: "fetching billing history",
|
|
146
158
|
});
|
|
147
159
|
}
|
|
148
|
-
/** Create a Stripe checkout URL
|
|
149
|
-
async createCheckout(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.client.request(
|
|
160
|
+
/** Create a Stripe checkout URL for an organization. */
|
|
161
|
+
async createCheckout(organizationId, checkout) {
|
|
162
|
+
assertNonEmptyString(organizationId, "organizationId", "creating checkout");
|
|
163
|
+
const body = checkoutRequestBody(checkout, "creating checkout");
|
|
164
|
+
return this.client.request(`/orgs/v1/${encodeURIComponent(organizationId)}/checkouts`, {
|
|
153
165
|
method: "POST",
|
|
154
|
-
body
|
|
166
|
+
body,
|
|
155
167
|
context: "creating checkout",
|
|
156
|
-
withAuth: false,
|
|
157
168
|
});
|
|
158
169
|
}
|
|
159
170
|
/** Create an email-only (no-wallet) organization. Sends a verification email. */
|
|
@@ -185,39 +196,18 @@ export class Billing {
|
|
|
185
196
|
context: "linking wallet",
|
|
186
197
|
});
|
|
187
198
|
}
|
|
188
|
-
/** Create a Stripe checkout for a tier subscription/renewal/upgrade. */
|
|
189
|
-
async tierCheckout(tier, identifier) {
|
|
190
|
-
assertStringInSet(tier, BILLING_TIERS, "tier", "creating tier checkout");
|
|
191
|
-
const body = checkoutIdentifierBody(identifier, "creating tier checkout");
|
|
192
|
-
return this.client.request(`/billing/v1/tiers/${encodeURIComponent(tier)}/checkout`, {
|
|
193
|
-
method: "POST",
|
|
194
|
-
body,
|
|
195
|
-
context: "creating tier checkout",
|
|
196
|
-
withAuth: false,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
/** Buy a $5 email pack (10,000 emails). */
|
|
200
|
-
async buyEmailPack(identifier) {
|
|
201
|
-
const body = checkoutIdentifierBody(identifier, "creating email pack checkout");
|
|
202
|
-
return this.client.request("/billing/v1/email-packs/checkout", {
|
|
203
|
-
method: "POST",
|
|
204
|
-
body,
|
|
205
|
-
context: "creating email pack checkout",
|
|
206
|
-
withAuth: false,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
199
|
/** Enable/disable email-pack auto-recharge. */
|
|
210
200
|
async setAutoRecharge(opts) {
|
|
201
|
+
assertNonEmptyString(opts.organizationId, "organizationId", "setting auto-recharge");
|
|
211
202
|
const body = {
|
|
212
|
-
organization_id: opts.organizationId,
|
|
213
203
|
enabled: opts.enabled,
|
|
214
204
|
};
|
|
215
205
|
if (opts.threshold !== undefined) {
|
|
216
206
|
assertNonNegativeSafeInteger(opts.threshold, "threshold", "setting auto-recharge");
|
|
217
207
|
body.threshold = opts.threshold;
|
|
218
208
|
}
|
|
219
|
-
await this.client.request(
|
|
220
|
-
method: "
|
|
209
|
+
await this.client.request(`/orgs/v1/${encodeURIComponent(opts.organizationId)}/billing/auto-recharge`, {
|
|
210
|
+
method: "PATCH",
|
|
221
211
|
body,
|
|
222
212
|
context: "setting auto-recharge",
|
|
223
213
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAuG1B,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAE9D,MAAM,OAAO,GACX,iEAAiE,CAAC;AASpE;;;;GAIG;AACH,SAAS,yBAAyB,CAChC,UAAmB,EACnB,OAAe;IAEf,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,gBAAgB,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;IAC7D,CAAC;IACD,kBAAkB,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,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AyB;QAC7C,oBAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;QACrF,MAAM,IAAI,GAA4B;YACpC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;QACF,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,4BAA4B,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;YACnF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAClC,CAAC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,YAAY,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,wBAAwB,EAAE;YAC9G,MAAM,EAAE,OAAO;YACf,IAAI;YACJ,OAAO,EAAE,uBAAuB;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -58,7 +58,7 @@ export declare class Deploy {
|
|
|
58
58
|
onEvent?: (event: DeployEvent) => void;
|
|
59
59
|
}): Promise<void>;
|
|
60
60
|
/**
|
|
61
|
-
* Low-level commit: `POST /apply/v1/plans/:
|
|
61
|
+
* Low-level commit: `POST /apply/v1/plans/:plan_id/commit`, then poll
|
|
62
62
|
* `/operations/:id` until terminal. Pass the project id whose anon_key
|
|
63
63
|
* should authenticate the polling — the operations endpoint requires
|
|
64
64
|
* apikey auth even though the plan/commit endpoints accept SIWX.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/namespaces/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAkB3C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAQtB,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,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AkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA+BnE;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAW1E;AAoiDD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;iEAG6D;IAC7D,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;CACvC"}
|
|
@@ -159,7 +159,7 @@ export class Deploy {
|
|
|
159
159
|
await uploadMissing(this.client, opts.project, plan.missing_content, opts.byteReaders, emit);
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* Low-level commit: `POST /apply/v1/plans/:
|
|
162
|
+
* Low-level commit: `POST /apply/v1/plans/:plan_id/commit`, then poll
|
|
163
163
|
* `/operations/:id` until terminal. Pass the project id whose anon_key
|
|
164
164
|
* should authenticate the polling — the operations endpoint requires
|
|
165
165
|
* apikey auth even though the plan/commit endpoints accept SIWX.
|
|
@@ -297,9 +297,9 @@ export class Deploy {
|
|
|
297
297
|
const limit = typeof opts === "string" ? undefined : opts?.limit;
|
|
298
298
|
const cursor = typeof opts === "string" ? undefined : opts?.cursor;
|
|
299
299
|
if (!project) {
|
|
300
|
-
throw new LocalError("
|
|
300
|
+
throw new LocalError("apply.list requires a project id (as a string or { project: 'prj_...' })", "listing deploy operations");
|
|
301
301
|
}
|
|
302
|
-
const normalizedLimit = normalizePositiveSafeIntegerQueryOption(limit, "
|
|
302
|
+
const normalizedLimit = normalizePositiveSafeIntegerQueryOption(limit, "apply.list limit", "listing deploy operations");
|
|
303
303
|
const headers = await apikeyHeaders(this.client, project);
|
|
304
304
|
const qs = new URLSearchParams();
|
|
305
305
|
if (normalizedLimit !== undefined)
|
|
@@ -346,12 +346,12 @@ export class Deploy {
|
|
|
346
346
|
*/
|
|
347
347
|
async getRelease(opts) {
|
|
348
348
|
if (!opts?.project) {
|
|
349
|
-
throw new LocalError("
|
|
349
|
+
throw new LocalError("apply.getRelease requires a project id ({ project: 'prj_...', releaseId: 'rel_...' })", "fetching release inventory");
|
|
350
350
|
}
|
|
351
351
|
if (!opts.releaseId) {
|
|
352
|
-
throw new LocalError("
|
|
352
|
+
throw new LocalError("apply.getRelease requires a release id", "fetching release inventory");
|
|
353
353
|
}
|
|
354
|
-
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "
|
|
354
|
+
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "apply.getRelease siteLimit", "fetching release inventory");
|
|
355
355
|
const headers = await apikeyHeaders(this.client, opts.project);
|
|
356
356
|
return this.client.request(appendQuery(`/apply/v1/releases/${encodeURIComponent(opts.releaseId)}`, {
|
|
357
357
|
site_limit: siteLimit,
|
|
@@ -364,9 +364,9 @@ export class Deploy {
|
|
|
364
364
|
*/
|
|
365
365
|
async getActiveRelease(opts) {
|
|
366
366
|
if (!opts?.project) {
|
|
367
|
-
throw new LocalError("
|
|
367
|
+
throw new LocalError("apply.getActiveRelease requires a project id ({ project: 'prj_...' })", "fetching active release inventory");
|
|
368
368
|
}
|
|
369
|
-
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "
|
|
369
|
+
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "apply.getActiveRelease siteLimit", "fetching active release inventory");
|
|
370
370
|
const headers = await apikeyHeaders(this.client, opts.project);
|
|
371
371
|
return this.client.request(appendQuery("/apply/v1/releases/active", {
|
|
372
372
|
site_limit: siteLimit,
|
|
@@ -379,11 +379,11 @@ export class Deploy {
|
|
|
379
379
|
*/
|
|
380
380
|
async diff(opts) {
|
|
381
381
|
if (!opts?.project) {
|
|
382
|
-
throw new LocalError("
|
|
382
|
+
throw new LocalError("apply.diff requires a project id ({ project: 'prj_...', from, to })", "diffing releases");
|
|
383
383
|
}
|
|
384
|
-
const from = requireNonEmptyStringQueryOption(opts.from, "
|
|
385
|
-
const to = requireNonEmptyStringQueryOption(opts.to, "
|
|
386
|
-
const limit = normalizePositiveSafeIntegerQueryOption(opts.limit, "
|
|
384
|
+
const from = requireNonEmptyStringQueryOption(opts.from, "apply.diff from", "diffing releases");
|
|
385
|
+
const to = requireNonEmptyStringQueryOption(opts.to, "apply.diff to", "diffing releases");
|
|
386
|
+
const limit = normalizePositiveSafeIntegerQueryOption(opts.limit, "apply.diff limit", "diffing releases");
|
|
387
387
|
const headers = await apikeyHeaders(this.client, opts.project);
|
|
388
388
|
const qs = new URLSearchParams({ from, to });
|
|
389
389
|
if (limit !== undefined)
|
|
@@ -631,6 +631,132 @@ function enrichDeployRetryBody(body, attempts, maxRetries, lastRetryCode) {
|
|
|
631
631
|
}
|
|
632
632
|
return retryFields;
|
|
633
633
|
}
|
|
634
|
+
function contentRefToWire(ref) {
|
|
635
|
+
const maybeWire = ref;
|
|
636
|
+
return {
|
|
637
|
+
sha256: ref.sha256,
|
|
638
|
+
size: ref.size,
|
|
639
|
+
...(ref.contentType ?? maybeWire.content_type
|
|
640
|
+
? { content_type: ref.contentType ?? maybeWire.content_type }
|
|
641
|
+
: {}),
|
|
642
|
+
...(ref.integrity ? { integrity: ref.integrity } : {}),
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function fileSetToWire(map) {
|
|
646
|
+
const out = {};
|
|
647
|
+
for (const [path, ref] of Object.entries(map))
|
|
648
|
+
out[path] = contentRefToWire(ref);
|
|
649
|
+
return out;
|
|
650
|
+
}
|
|
651
|
+
function requireRoleToWire(gate) {
|
|
652
|
+
return {
|
|
653
|
+
table: gate.table,
|
|
654
|
+
id_column: gate.idColumn,
|
|
655
|
+
role_column: gate.roleColumn,
|
|
656
|
+
allowed: gate.allowed,
|
|
657
|
+
...(gate.cacheTtl !== undefined ? { cache_ttl: gate.cacheTtl } : {}),
|
|
658
|
+
...(gate.onDeny !== undefined ? { on_deny: gate.onDeny } : {}),
|
|
659
|
+
...(gate.signInPath !== undefined ? { sign_in_path: gate.signInPath } : {}),
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
function functionToWire(fn) {
|
|
663
|
+
return {
|
|
664
|
+
...(fn.runtime !== undefined ? { runtime: fn.runtime } : {}),
|
|
665
|
+
...(fn.source !== undefined ? { source: contentRefToWire(fn.source) } : {}),
|
|
666
|
+
...(fn.files !== undefined ? { files: fileSetToWire(fn.files) } : {}),
|
|
667
|
+
...(fn.entrypoint !== undefined ? { entrypoint: fn.entrypoint } : {}),
|
|
668
|
+
...(fn.config !== undefined
|
|
669
|
+
? {
|
|
670
|
+
config: {
|
|
671
|
+
...(fn.config.timeoutSeconds !== undefined ? { timeout_seconds: fn.config.timeoutSeconds } : {}),
|
|
672
|
+
...(fn.config.memoryMb !== undefined ? { memory_mb: fn.config.memoryMb } : {}),
|
|
673
|
+
},
|
|
674
|
+
}
|
|
675
|
+
: {}),
|
|
676
|
+
...(fn.schedule !== undefined ? { schedule: fn.schedule } : {}),
|
|
677
|
+
...(fn.requireAuth !== undefined ? { require_auth: fn.requireAuth } : {}),
|
|
678
|
+
...(fn.requireRole !== undefined
|
|
679
|
+
? { require_role: fn.requireRole === null ? null : requireRoleToWire(fn.requireRole) }
|
|
680
|
+
: {}),
|
|
681
|
+
...(fn.class !== undefined ? { class: fn.class } : {}),
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function functionMapToWire(map) {
|
|
685
|
+
const out = {};
|
|
686
|
+
for (const [name, fn] of Object.entries(map))
|
|
687
|
+
out[name] = functionToWire(fn);
|
|
688
|
+
return out;
|
|
689
|
+
}
|
|
690
|
+
function databaseToWire(database) {
|
|
691
|
+
return {
|
|
692
|
+
...(database.expose !== undefined ? { expose: database.expose } : {}),
|
|
693
|
+
...(database.zero_downtime !== undefined ? { zero_downtime: database.zero_downtime } : {}),
|
|
694
|
+
...(database.migrations !== undefined
|
|
695
|
+
? {
|
|
696
|
+
migrations: database.migrations.map((m) => ({
|
|
697
|
+
id: m.id,
|
|
698
|
+
checksum: m.checksum,
|
|
699
|
+
sql_ref: contentRefToWire(m.sql_ref),
|
|
700
|
+
...(m.transaction !== undefined ? { transaction: m.transaction } : {}),
|
|
701
|
+
})),
|
|
702
|
+
}
|
|
703
|
+
: {}),
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function functionsToWire(functions) {
|
|
707
|
+
return {
|
|
708
|
+
...(functions.replace !== undefined ? { replace: functionMapToWire(functions.replace) } : {}),
|
|
709
|
+
...(functions.patch !== undefined
|
|
710
|
+
? {
|
|
711
|
+
patch: {
|
|
712
|
+
...(functions.patch.set !== undefined ? { set: functionMapToWire(functions.patch.set) } : {}),
|
|
713
|
+
...(functions.patch.delete !== undefined ? { delete: functions.patch.delete } : {}),
|
|
714
|
+
},
|
|
715
|
+
}
|
|
716
|
+
: {}),
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function siteToWire(site) {
|
|
720
|
+
if ("replace" in site && site.replace) {
|
|
721
|
+
return {
|
|
722
|
+
replace: fileSetToWire(site.replace),
|
|
723
|
+
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
if ("patch" in site && site.patch) {
|
|
727
|
+
return {
|
|
728
|
+
patch: {
|
|
729
|
+
...(site.patch.put ? { put: fileSetToWire(site.patch.put) } : {}),
|
|
730
|
+
...(site.patch.delete ? { delete: site.patch.delete } : {}),
|
|
731
|
+
},
|
|
732
|
+
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
return { public_paths: site.public_paths };
|
|
736
|
+
}
|
|
737
|
+
function i18nToWire(i18n) {
|
|
738
|
+
return {
|
|
739
|
+
default_locale: i18n.defaultLocale,
|
|
740
|
+
locales: i18n.locales,
|
|
741
|
+
...(i18n.detect !== undefined ? { detect: i18n.detect } : {}),
|
|
742
|
+
...(i18n.unknownLocalePolicy !== undefined ? { unknown_locale_policy: i18n.unknownLocalePolicy } : {}),
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function releaseSpecToWire(spec) {
|
|
746
|
+
return {
|
|
747
|
+
project_id: spec.project,
|
|
748
|
+
...(spec.base !== undefined ? { base: spec.base } : {}),
|
|
749
|
+
...(spec.database !== undefined ? { database: databaseToWire(spec.database) } : {}),
|
|
750
|
+
...(spec.secrets !== undefined ? { secrets: spec.secrets } : {}),
|
|
751
|
+
...(spec.functions !== undefined ? { functions: functionsToWire(spec.functions) } : {}),
|
|
752
|
+
...(spec.site !== undefined ? { site: siteToWire(spec.site) } : {}),
|
|
753
|
+
...(spec.subdomains !== undefined ? { subdomains: spec.subdomains } : {}),
|
|
754
|
+
...(spec.routes !== undefined ? { routes: spec.routes } : {}),
|
|
755
|
+
...(spec.checks !== undefined ? { checks: spec.checks } : {}),
|
|
756
|
+
...(spec.assets !== undefined ? { assets: spec.assets } : {}),
|
|
757
|
+
...(spec.i18n !== undefined ? { i18n: spec.i18n === null ? null : i18nToWire(spec.i18n) } : {}),
|
|
758
|
+
};
|
|
759
|
+
}
|
|
634
760
|
async function planInternal(client, spec, idempotencyKey, dryRun = false) {
|
|
635
761
|
const ciCredentials = isCiClient(client);
|
|
636
762
|
validateSpec(spec);
|
|
@@ -638,12 +764,13 @@ async function planInternal(client, spec, idempotencyKey, dryRun = false) {
|
|
|
638
764
|
assertCiDeployableSpec(spec);
|
|
639
765
|
const { normalized, byteReaders } = await normalizeReleaseSpec(client, spec);
|
|
640
766
|
await preflightTierFunctionLimits(client, normalized, ciCredentials);
|
|
767
|
+
const wireSpec = releaseSpecToWire(normalized);
|
|
641
768
|
// The gateway expects { spec, manifest_ref?, idempotency_key? } with
|
|
642
|
-
// ReleaseSpec
|
|
769
|
+
// snake_case ReleaseSpec wire JSON. For oversized specs the SDK uploads
|
|
643
770
|
// the manifest JSON to CAS first and references it; the gateway still
|
|
644
771
|
// needs `spec` in the body (with at least the project), so we keep a
|
|
645
772
|
// minimal stub there.
|
|
646
|
-
const inlineBody = { spec:
|
|
773
|
+
const inlineBody = { spec: wireSpec };
|
|
647
774
|
if (idempotencyKey && !dryRun)
|
|
648
775
|
inlineBody.idempotency_key = idempotencyKey;
|
|
649
776
|
const inlineBytes = new TextEncoder().encode(JSON.stringify(inlineBody)).byteLength;
|
|
@@ -673,9 +800,9 @@ async function planInternal(client, spec, idempotencyKey, dryRun = false) {
|
|
|
673
800
|
// Upload the normalized manifest itself as a CAS object so the gateway
|
|
674
801
|
// can pick it up via `manifest_ref`. The body still carries a minimal
|
|
675
802
|
// `spec` so the gateway has the project for auth + plan persistence.
|
|
676
|
-
const manifestBytes = new TextEncoder().encode(JSON.stringify(
|
|
803
|
+
const manifestBytes = new TextEncoder().encode(JSON.stringify(wireSpec));
|
|
677
804
|
const ref = await uploadInlineCas(client, spec.project, manifestBytes, MANIFEST_CONTENT_TYPE);
|
|
678
|
-
body = { spec: {
|
|
805
|
+
body = { spec: { project_id: spec.project }, manifest_ref: contentRefToWire(ref) };
|
|
679
806
|
if (idempotencyKey)
|
|
680
807
|
body.idempotency_key = idempotencyKey;
|
|
681
808
|
}
|
|
@@ -1564,7 +1691,7 @@ const ROUTE_ENTRY_FIELDS = new Set(["pattern", "methods", "target", "acknowledge
|
|
|
1564
1691
|
const FUNCTION_ROUTE_TARGET_FIELDS = new Set(["type", "name"]);
|
|
1565
1692
|
const STATIC_ROUTE_TARGET_FIELDS = new Set(["type", "file"]);
|
|
1566
1693
|
const ROUTE_METHOD_SET = new Set(ROUTE_HTTP_METHODS);
|
|
1567
|
-
const I18N_SPEC_FIELDS = new Set(["defaultLocale", "locales", "detect"]);
|
|
1694
|
+
const I18N_SPEC_FIELDS = new Set(["defaultLocale", "locales", "detect", "unknownLocalePolicy"]);
|
|
1568
1695
|
const I18N_LOCALE_TAG_REGEX = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
1569
1696
|
const I18N_COOKIE_NAME_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
1570
1697
|
const I18N_MAX_LOCALES = 50;
|
|
@@ -3004,7 +3131,7 @@ async function uploadInlineCas(client, projectId, bytes, contentType) {
|
|
|
3004
3131
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
3005
3132
|
/**
|
|
3006
3133
|
* Build the apikey header set for a project. The v1.34 gateway's
|
|
3007
|
-
* `/apply/v1/operations/:
|
|
3134
|
+
* `/apply/v1/operations/:operation_id*` and `/content/v1/plans*` routes require
|
|
3008
3135
|
* `apikey: <project.anon_key>` (apikeyAuth middleware). Plan + commit on
|
|
3009
3136
|
* `/apply/v1/plans*` use SIWX, which the kernel's getAuth provides
|
|
3010
3137
|
* automatically — only the apikey-gated paths need this helper.
|