run402 4.165.0 → 4.167.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/lib/app-repo-tokens.mjs +1 -2
- package/lib/app-repos.mjs +2 -2
- package/lib/apps.mjs +1 -3
- package/lib/archives.mjs +0 -6
- package/lib/argparse.mjs +10 -53
- package/lib/assets.mjs +11 -42
- package/lib/auth.mjs +4 -48
- package/lib/billing.mjs +8 -8
- package/lib/branches.mjs +3 -5
- package/lib/buzz-notifications.mjs +2 -21
- package/lib/buzz.mjs +4 -5
- package/lib/cache.mjs +0 -20
- package/lib/cdn.mjs +0 -7
- package/lib/claims.mjs +2 -4
- package/lib/contacts.mjs +3 -9
- package/lib/contracts.mjs +0 -28
- package/lib/credentials.mjs +2 -5
- package/lib/deliveries.mjs +0 -1
- package/lib/deploy-v2.mjs +20 -102
- package/lib/domains.mjs +6 -73
- package/lib/email.mjs +73 -64
- package/lib/errors.mjs +6 -13
- package/lib/escalations.mjs +2 -4
- package/lib/events.mjs +1 -3
- package/lib/feedback.mjs +1 -34
- package/lib/functions.mjs +12 -26
- package/lib/grants.mjs +0 -7
- package/lib/identity.mjs +1 -7
- package/lib/image.mjs +1 -2
- package/lib/init.mjs +0 -3
- package/lib/jobs.mjs +2 -2
- package/lib/logs.mjs +2 -5
- package/lib/messages.mjs +3 -3
- package/lib/orgs.mjs +3 -3
- package/lib/projects.mjs +3 -50
- package/lib/remote-helper-session.mjs +1 -2
- package/lib/repos.mjs +7 -39
- package/lib/rooms.mjs +2 -3
- package/lib/snapshots.mjs +2 -7
- package/lib/stripe.mjs +9 -16
- package/lib/subscriptions.mjs +0 -3
- package/lib/transfer.mjs +16 -67
- package/lib/up.mjs +0 -16
- package/lib/webhooks.mjs +1 -13
- package/lib/whoami.mjs +0 -8
- package/package.json +1 -1
- package/sdk/dist/app-up.js +1 -0
- package/sdk/dist/app-up.js.map +1 -1
- package/sdk/dist/ci-credentials.d.ts.map +1 -1
- package/sdk/dist/ci-credentials.js +6 -0
- package/sdk/dist/ci-credentials.js.map +1 -1
- package/sdk/dist/control-plane-credentials.d.ts.map +1 -1
- package/sdk/dist/control-plane-credentials.js +2 -0
- package/sdk/dist/control-plane-credentials.js.map +1 -1
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +7 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/jcs.d.ts.map +1 -1
- package/sdk/dist/jcs.js +1 -0
- package/sdk/dist/jcs.js.map +1 -1
- package/sdk/dist/namespaces/admin.d.ts +1 -1
- package/sdk/dist/namespaces/admin.d.ts.map +1 -1
- package/sdk/dist/namespaces/admin.js +0 -5
- package/sdk/dist/namespaces/admin.js.map +1 -1
- package/sdk/dist/namespaces/agent.d.ts.map +1 -1
- package/sdk/dist/namespaces/agent.js +1 -0
- package/sdk/dist/namespaces/agent.js.map +1 -1
- package/sdk/dist/namespaces/ai.d.ts.map +1 -1
- package/sdk/dist/namespaces/ai.js +1 -0
- package/sdk/dist/namespaces/ai.js.map +1 -1
- package/sdk/dist/namespaces/app-repos.d.ts.map +1 -1
- package/sdk/dist/namespaces/app-repos.js +5 -4
- package/sdk/dist/namespaces/app-repos.js.map +1 -1
- package/sdk/dist/namespaces/archives.d.ts.map +1 -1
- package/sdk/dist/namespaces/archives.js +6 -3
- package/sdk/dist/namespaces/archives.js.map +1 -1
- package/sdk/dist/namespaces/assets-validation.d.ts +14 -19
- package/sdk/dist/namespaces/assets-validation.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets-validation.js +27 -50
- package/sdk/dist/namespaces/assets-validation.js.map +1 -1
- package/sdk/dist/namespaces/assets.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets.js +11 -28
- package/sdk/dist/namespaces/assets.js.map +1 -1
- package/sdk/dist/namespaces/assets.types.d.ts +0 -2
- package/sdk/dist/namespaces/assets.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets.types.js +0 -2
- package/sdk/dist/namespaces/assets.types.js.map +1 -1
- package/sdk/dist/namespaces/auth.d.ts.map +1 -1
- package/sdk/dist/namespaces/auth.js +30 -51
- package/sdk/dist/namespaces/auth.js.map +1 -1
- package/sdk/dist/namespaces/billing.d.ts.map +1 -1
- package/sdk/dist/namespaces/billing.js +12 -41
- package/sdk/dist/namespaces/billing.js.map +1 -1
- package/sdk/dist/namespaces/branches.js +1 -0
- package/sdk/dist/namespaces/branches.js.map +1 -1
- package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
- package/sdk/dist/namespaces/buzz.js +3 -6
- package/sdk/dist/namespaces/buzz.js.map +1 -1
- package/sdk/dist/namespaces/cache.d.ts.map +1 -1
- package/sdk/dist/namespaces/cache.js +0 -4
- package/sdk/dist/namespaces/cache.js.map +1 -1
- package/sdk/dist/namespaces/ci.d.ts.map +1 -1
- package/sdk/dist/namespaces/ci.js +24 -90
- package/sdk/dist/namespaces/ci.js.map +1 -1
- package/sdk/dist/namespaces/contracts.d.ts.map +1 -1
- package/sdk/dist/namespaces/contracts.js +10 -32
- package/sdk/dist/namespaces/contracts.js.map +1 -1
- package/sdk/dist/namespaces/credentials.d.ts.map +1 -1
- package/sdk/dist/namespaces/credentials.js +13 -8
- package/sdk/dist/namespaces/credentials.js.map +1 -1
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +156 -649
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/domains.d.ts.map +1 -1
- package/sdk/dist/namespaces/domains.js +1 -0
- package/sdk/dist/namespaces/domains.js.map +1 -1
- package/sdk/dist/namespaces/email.d.ts +22 -2
- package/sdk/dist/namespaces/email.d.ts.map +1 -1
- package/sdk/dist/namespaces/email.js +23 -78
- package/sdk/dist/namespaces/email.js.map +1 -1
- package/sdk/dist/namespaces/errors.d.ts.map +1 -1
- package/sdk/dist/namespaces/errors.js +9 -0
- package/sdk/dist/namespaces/errors.js.map +1 -1
- package/sdk/dist/namespaces/escalations.d.ts.map +1 -1
- package/sdk/dist/namespaces/escalations.js +15 -0
- package/sdk/dist/namespaces/escalations.js.map +1 -1
- package/sdk/dist/namespaces/events.d.ts.map +1 -1
- package/sdk/dist/namespaces/events.js +2 -0
- package/sdk/dist/namespaces/events.js.map +1 -1
- package/sdk/dist/namespaces/functions.d.ts +2 -2
- package/sdk/dist/namespaces/functions.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.js +39 -154
- package/sdk/dist/namespaces/functions.js.map +1 -1
- package/sdk/dist/namespaces/grants.d.ts.map +1 -1
- package/sdk/dist/namespaces/grants.js +12 -0
- package/sdk/dist/namespaces/grants.js.map +1 -1
- package/sdk/dist/namespaces/identity-links.d.ts.map +1 -1
- package/sdk/dist/namespaces/identity-links.js +7 -3
- package/sdk/dist/namespaces/identity-links.js.map +1 -1
- package/sdk/dist/namespaces/identity-links.protocol.d.ts.map +1 -1
- package/sdk/dist/namespaces/identity-links.protocol.js +1 -0
- package/sdk/dist/namespaces/identity-links.protocol.js.map +1 -1
- package/sdk/dist/namespaces/live.js +2 -0
- package/sdk/dist/namespaces/live.js.map +1 -1
- package/sdk/dist/namespaces/org.d.ts.map +1 -1
- package/sdk/dist/namespaces/org.js +22 -9
- package/sdk/dist/namespaces/org.js.map +1 -1
- package/sdk/dist/namespaces/projects.d.ts.map +1 -1
- package/sdk/dist/namespaces/projects.js +3 -0
- package/sdk/dist/namespaces/projects.js.map +1 -1
- package/sdk/dist/namespaces/push.d.ts.map +1 -1
- package/sdk/dist/namespaces/push.js +6 -0
- package/sdk/dist/namespaces/push.js.map +1 -1
- package/sdk/dist/namespaces/repos.d.ts +7 -37
- package/sdk/dist/namespaces/repos.d.ts.map +1 -1
- package/sdk/dist/namespaces/repos.js +61 -63
- package/sdk/dist/namespaces/repos.js.map +1 -1
- package/sdk/dist/namespaces/rooms.d.ts.map +1 -1
- package/sdk/dist/namespaces/rooms.js +4 -0
- package/sdk/dist/namespaces/rooms.js.map +1 -1
- package/sdk/dist/namespaces/secrets.d.ts.map +1 -1
- package/sdk/dist/namespaces/secrets.js +1 -12
- package/sdk/dist/namespaces/secrets.js.map +1 -1
- package/sdk/dist/namespaces/snapshots.d.ts.map +1 -1
- package/sdk/dist/namespaces/snapshots.js +5 -0
- package/sdk/dist/namespaces/snapshots.js.map +1 -1
- package/sdk/dist/namespaces/subdomains.d.ts.map +1 -1
- package/sdk/dist/namespaces/subdomains.js +1 -0
- package/sdk/dist/namespaces/subdomains.js.map +1 -1
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +17 -28
- package/sdk/dist/namespaces/transfers.js.map +1 -1
- package/sdk/dist/namespaces/vault.crypto.d.ts.map +1 -1
- package/sdk/dist/namespaces/vault.crypto.js +1 -0
- package/sdk/dist/namespaces/vault.crypto.js.map +1 -1
- package/sdk/dist/namespaces/wallets.d.ts.map +1 -1
- package/sdk/dist/namespaces/wallets.js +6 -0
- package/sdk/dist/namespaces/wallets.js.map +1 -1
- package/sdk/dist/node/actions-node.d.ts.map +1 -1
- package/sdk/dist/node/actions-node.js +16 -0
- package/sdk/dist/node/actions-node.js.map +1 -1
- package/sdk/dist/node/archives-node.d.ts.map +1 -1
- package/sdk/dist/node/archives-node.js +17 -0
- package/sdk/dist/node/archives-node.js.map +1 -1
- package/sdk/dist/node/assets-node.d.ts.map +1 -1
- package/sdk/dist/node/assets-node.js +5 -3
- package/sdk/dist/node/assets-node.js.map +1 -1
- package/sdk/dist/node/bearer-redeem-key.d.ts.map +1 -1
- package/sdk/dist/node/bearer-redeem-key.js +1 -0
- package/sdk/dist/node/bearer-redeem-key.js.map +1 -1
- package/sdk/dist/node/buzz-doctor.d.ts.map +1 -1
- package/sdk/dist/node/buzz-doctor.js +3 -0
- package/sdk/dist/node/buzz-doctor.js.map +1 -1
- package/sdk/dist/node/ci.d.ts.map +1 -1
- package/sdk/dist/node/ci.js +1 -0
- package/sdk/dist/node/ci.js.map +1 -1
- package/sdk/dist/node/credentials.d.ts.map +1 -1
- package/sdk/dist/node/credentials.js +1 -0
- package/sdk/dist/node/credentials.js.map +1 -1
- package/sdk/dist/node/deploy-manifest.d.ts.map +1 -1
- package/sdk/dist/node/deploy-manifest.js +90 -222
- package/sdk/dist/node/deploy-manifest.js.map +1 -1
- package/sdk/dist/node/dev-session.d.ts.map +1 -1
- package/sdk/dist/node/dev-session.js +4 -0
- package/sdk/dist/node/dev-session.js.map +1 -1
- package/sdk/dist/node/doctor.d.ts.map +1 -1
- package/sdk/dist/node/doctor.js +1 -0
- package/sdk/dist/node/doctor.js.map +1 -1
- package/sdk/dist/node/files.d.ts.map +1 -1
- package/sdk/dist/node/files.js +5 -0
- package/sdk/dist/node/files.js.map +1 -1
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +1 -0
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/init.d.ts.map +1 -1
- package/sdk/dist/node/init.js +2 -0
- package/sdk/dist/node/init.js.map +1 -1
- package/sdk/dist/node/lightning-wallet.d.ts.map +1 -1
- package/sdk/dist/node/lightning-wallet.js +1 -0
- package/sdk/dist/node/lightning-wallet.js.map +1 -1
- package/sdk/dist/node/manifest-export.d.ts.map +1 -1
- package/sdk/dist/node/manifest-export.js +1 -0
- package/sdk/dist/node/manifest-export.js.map +1 -1
- package/sdk/dist/node/mpp-pay-executor.d.ts.map +1 -1
- package/sdk/dist/node/mpp-pay-executor.js +1 -0
- package/sdk/dist/node/mpp-pay-executor.js.map +1 -1
- package/sdk/dist/node/org-adopt.d.ts.map +1 -1
- package/sdk/dist/node/org-adopt.js +4 -0
- package/sdk/dist/node/org-adopt.js.map +1 -1
- package/sdk/dist/node/org-context.d.ts.map +1 -1
- package/sdk/dist/node/org-context.js +5 -0
- package/sdk/dist/node/org-context.js.map +1 -1
- package/sdk/dist/node/paid-fetch.d.ts.map +1 -1
- package/sdk/dist/node/paid-fetch.js +2 -0
- package/sdk/dist/node/paid-fetch.js.map +1 -1
- package/sdk/dist/node/payment-attempts.d.ts.map +1 -1
- package/sdk/dist/node/payment-attempts.js +4 -0
- package/sdk/dist/node/payment-attempts.js.map +1 -1
- package/sdk/dist/node/signers/index.d.ts.map +1 -1
- package/sdk/dist/node/signers/index.js +2 -0
- package/sdk/dist/node/signers/index.js.map +1 -1
- package/sdk/dist/node/signers/kms.d.ts.map +1 -1
- package/sdk/dist/node/signers/kms.js +7 -0
- package/sdk/dist/node/signers/kms.js.map +1 -1
- package/sdk/dist/node/target-profile.d.ts.map +1 -1
- package/sdk/dist/node/target-profile.js +4 -0
- package/sdk/dist/node/target-profile.js.map +1 -1
- package/sdk/dist/node/vault-apply.d.ts.map +1 -1
- package/sdk/dist/node/vault-apply.js +6 -0
- package/sdk/dist/node/vault-apply.js.map +1 -1
- package/sdk/dist/node/vault-byo-config.d.ts.map +1 -1
- package/sdk/dist/node/vault-byo-config.js +1 -0
- package/sdk/dist/node/vault-byo-config.js.map +1 -1
- package/sdk/dist/node/vault-byo-probe.d.ts.map +1 -1
- package/sdk/dist/node/vault-byo-probe.js +1 -0
- package/sdk/dist/node/vault-byo-probe.js.map +1 -1
- package/sdk/dist/node/vault-creation-journal.d.ts.map +1 -1
- package/sdk/dist/node/vault-creation-journal.js +1 -0
- package/sdk/dist/node/vault-creation-journal.js.map +1 -1
- package/sdk/dist/node/vault-deploy.d.ts.map +1 -1
- package/sdk/dist/node/vault-deploy.js +7 -0
- package/sdk/dist/node/vault-deploy.js.map +1 -1
- package/sdk/dist/node/vault-handoff.d.ts.map +1 -1
- package/sdk/dist/node/vault-handoff.js +1 -0
- package/sdk/dist/node/vault-handoff.js.map +1 -1
- package/sdk/dist/node/vault-keystore.d.ts.map +1 -1
- package/sdk/dist/node/vault-keystore.js +2 -0
- package/sdk/dist/node/vault-keystore.js.map +1 -1
- package/sdk/dist/node/vault-member-bundle.d.ts.map +1 -1
- package/sdk/dist/node/vault-member-bundle.js +1 -0
- package/sdk/dist/node/vault-member-bundle.js.map +1 -1
- package/sdk/dist/node/vault-mirror-backend.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror-backend.js +1 -0
- package/sdk/dist/node/vault-mirror-backend.js.map +1 -1
- package/sdk/dist/node/vault-mirror-config.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror-config.js +1 -0
- package/sdk/dist/node/vault-mirror-config.js.map +1 -1
- package/sdk/dist/node/vault-mirror.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror.js +1 -0
- package/sdk/dist/node/vault-mirror.js.map +1 -1
- package/sdk/dist/node/vault-prune.d.ts.map +1 -1
- package/sdk/dist/node/vault-prune.js +1 -0
- package/sdk/dist/node/vault-prune.js.map +1 -1
- package/sdk/dist/node/vault-publication.d.ts +1 -2
- package/sdk/dist/node/vault-publication.d.ts.map +1 -1
- package/sdk/dist/node/vault-publication.js +2 -0
- package/sdk/dist/node/vault-publication.js.map +1 -1
- package/sdk/dist/node/vault-recover.d.ts.map +1 -1
- package/sdk/dist/node/vault-recover.js +1 -0
- package/sdk/dist/node/vault-recover.js.map +1 -1
- package/sdk/dist/node/vault-restore.d.ts.map +1 -1
- package/sdk/dist/node/vault-restore.js +3 -0
- package/sdk/dist/node/vault-restore.js.map +1 -1
- package/sdk/dist/node/vault-snapshot.d.ts.map +1 -1
- package/sdk/dist/node/vault-snapshot.js +6 -0
- package/sdk/dist/node/vault-snapshot.js.map +1 -1
- package/sdk/dist/node/vault-writer-state.d.ts.map +1 -1
- package/sdk/dist/node/vault-writer-state.js +1 -0
- package/sdk/dist/node/vault-writer-state.js.map +1 -1
- package/sdk/dist/node/wallets-send.d.ts.map +1 -1
- package/sdk/dist/node/wallets-send.js +4 -0
- package/sdk/dist/node/wallets-send.js.map +1 -1
- package/sdk/dist/node/wallets.d.ts.map +1 -1
- package/sdk/dist/node/wallets.js +17 -0
- package/sdk/dist/node/wallets.js.map +1 -1
- package/sdk/dist/project-id.d.ts.map +1 -1
- package/sdk/dist/project-id.js +1 -0
- package/sdk/dist/project-id.js.map +1 -1
- package/sdk/dist/validation.d.ts +0 -5
- package/sdk/dist/validation.d.ts.map +1 -1
- package/sdk/dist/validation.js +2 -40
- package/sdk/dist/validation.js.map +1 -1
- package/vault-surface.json +1 -1
|
@@ -23,11 +23,11 @@ import { isCiSessionCredentials } from "../ci-credentials.js";
|
|
|
23
23
|
import { isGrantKeyCredentials } from "../grant-key-credentials.js";
|
|
24
24
|
import { isKnownBinaryContent, isUtf8StringSource } from "../validation.js";
|
|
25
25
|
import { assertCiDeployableSpec } from "./ci.js";
|
|
26
|
-
import {
|
|
26
|
+
import { isModernPlanMigrationDiff, normalizeDeployResolveRequest, } from "./deploy.types.js";
|
|
27
27
|
import { ApiError, LocalError, PaymentRequired, Run402DeployError, Unauthorized, isNoResponseError, isRun402Error, isTransferFreezeError, } from "../errors.js";
|
|
28
28
|
import { assertAssetMetadata, assertExifPolicy, } from "./assets-validation.js";
|
|
29
29
|
import { withSiteRemovalSummaries } from "./site-removal-summary.js";
|
|
30
|
-
import {
|
|
30
|
+
import { installedFunctionToolLifter } from "../function-tools.js";
|
|
31
31
|
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
32
32
|
const PLAN_BODY_LIMIT_BYTES = 5 * 1024 * 1024;
|
|
33
33
|
const COMMIT_POLL_INITIAL_MS = 1_000;
|
|
@@ -51,7 +51,6 @@ const CONTENT_COMMIT_POLL_TIMEOUT_MS = 60 * 60 * 1000;
|
|
|
51
51
|
* of holding the request for as long as a large promote takes (RFC 7240). */
|
|
52
52
|
const CONTENT_COMMIT_PREFER = "respond-async, wait=20";
|
|
53
53
|
const URL_REFRESH_AT_MS = 50 * 60 * 1000;
|
|
54
|
-
const SECRET_KEY_RE = /^[A-Z_][A-Z0-9_]{0,127}$/;
|
|
55
54
|
const APPLY_SAFE_RETRY_CODES = new Set([
|
|
56
55
|
"BASE_RELEASE_CONFLICT",
|
|
57
56
|
]);
|
|
@@ -75,7 +74,6 @@ const APPLY_TRANSIENT_RETRY_MAX_DELAY_MS = 15_000;
|
|
|
75
74
|
/** A read or an idempotent request lost to a 502/503/504 or a dropped connection. */
|
|
76
75
|
const TRANSIENT_REQUEST_MAX_ATTEMPTS = 3;
|
|
77
76
|
const TRANSIENT_REQUEST_RETRY_BASE_DELAY_MS = 500;
|
|
78
|
-
const EMAIL_TRIGGER_EVENTS = new Set(["reply_received", "delivery", "bounced", "complained", "mailbox_suspended", "sender_suspended"]);
|
|
79
77
|
const STATIC_ACTIVATION_FAILURE_CODES = new Set([
|
|
80
78
|
"BAD_FIELD",
|
|
81
79
|
"INVALID_SPEC",
|
|
@@ -146,6 +144,7 @@ export class Deploy {
|
|
|
146
144
|
await sleep(delayMs);
|
|
147
145
|
}
|
|
148
146
|
}
|
|
147
|
+
// local-check: sdk_normalization — the SDK's own retry loop ended with no result
|
|
149
148
|
throw new Run402DeployError("Deploy retry loop ended without a result", {
|
|
150
149
|
code: "INTERNAL_ERROR",
|
|
151
150
|
phase: "apply",
|
|
@@ -196,6 +195,7 @@ export class Deploy {
|
|
|
196
195
|
}
|
|
197
196
|
async rehearse(planId, opts = {}) {
|
|
198
197
|
if (!planId || typeof planId !== "string") {
|
|
198
|
+
// local-check: argument — plan id builds the request URL
|
|
199
199
|
throw new Run402DeployError(`Invalid plan id: "${String(planId)}"`, {
|
|
200
200
|
code: "BAD_REQUEST",
|
|
201
201
|
phase: "rehearsal",
|
|
@@ -220,6 +220,7 @@ export class Deploy {
|
|
|
220
220
|
*/
|
|
221
221
|
async resume(operationId, opts = {}) {
|
|
222
222
|
if (!operationId || !operationId.startsWith("op_")) {
|
|
223
|
+
// local-check: argument — operation id builds the request URL
|
|
223
224
|
throw new Run402DeployError(`Invalid operation id: "${operationId}"`, {
|
|
224
225
|
code: "OPERATION_NOT_FOUND",
|
|
225
226
|
retryable: false,
|
|
@@ -266,6 +267,7 @@ export class Deploy {
|
|
|
266
267
|
*/
|
|
267
268
|
async promote(project, releaseId, opts = {}) {
|
|
268
269
|
if (!project || typeof project !== "string") {
|
|
270
|
+
// local-check: argument — project id picks the apikey headers
|
|
269
271
|
throw new Run402DeployError(`Invalid project id: "${String(project)}"`, {
|
|
270
272
|
code: "BAD_REQUEST",
|
|
271
273
|
retryable: false,
|
|
@@ -273,6 +275,7 @@ export class Deploy {
|
|
|
273
275
|
});
|
|
274
276
|
}
|
|
275
277
|
if (!releaseId || !releaseId.startsWith("rel_")) {
|
|
278
|
+
// local-check: argument — release id builds the request URL
|
|
276
279
|
throw new Run402DeployError(`Invalid release id: "${releaseId}"`, {
|
|
277
280
|
code: "BAD_REQUEST",
|
|
278
281
|
retryable: false,
|
|
@@ -310,6 +313,7 @@ export class Deploy {
|
|
|
310
313
|
*/
|
|
311
314
|
async status(operationId, opts = {}) {
|
|
312
315
|
if (!operationId || !operationId.startsWith("op_")) {
|
|
316
|
+
// local-check: argument — operation id builds the request URL
|
|
313
317
|
throw new Run402DeployError(`Invalid operation id: "${operationId}"`, {
|
|
314
318
|
code: "OPERATION_NOT_FOUND",
|
|
315
319
|
retryable: false,
|
|
@@ -336,6 +340,7 @@ export class Deploy {
|
|
|
336
340
|
const limit = typeof opts === "string" ? undefined : opts?.limit;
|
|
337
341
|
const cursor = typeof opts === "string" ? undefined : opts?.cursor;
|
|
338
342
|
if (!project) {
|
|
343
|
+
// local-check: argument — project id picks the apikey and URL
|
|
339
344
|
throw new LocalError("apply.list requires a project id (as a string or { project: 'prj_...' })", "listing deploy operations");
|
|
340
345
|
}
|
|
341
346
|
const normalizedLimit = normalizePositiveSafeIntegerQueryOption(limit, "apply.list limit", "listing deploy operations");
|
|
@@ -364,6 +369,7 @@ export class Deploy {
|
|
|
364
369
|
*/
|
|
365
370
|
async events(operationId, opts) {
|
|
366
371
|
if (!operationId || !operationId.startsWith("op_")) {
|
|
372
|
+
// local-check: argument — operation id builds the request URL
|
|
367
373
|
throw new Run402DeployError(`Invalid operation id: "${operationId}"`, {
|
|
368
374
|
code: "OPERATION_NOT_FOUND",
|
|
369
375
|
retryable: false,
|
|
@@ -385,6 +391,7 @@ export class Deploy {
|
|
|
385
391
|
*/
|
|
386
392
|
async edgeCoherence(operationId, opts) {
|
|
387
393
|
if (!operationId || !operationId.startsWith("op_")) {
|
|
394
|
+
// local-check: argument — operation id builds the request URL
|
|
388
395
|
throw new Run402DeployError(`Invalid operation id: "${operationId}"`, {
|
|
389
396
|
code: "OPERATION_NOT_FOUND",
|
|
390
397
|
retryable: false,
|
|
@@ -392,6 +399,7 @@ export class Deploy {
|
|
|
392
399
|
});
|
|
393
400
|
}
|
|
394
401
|
if (!opts?.project) {
|
|
402
|
+
// local-check: argument — project id picks the apikey headers
|
|
395
403
|
throw new LocalError("apply.edgeCoherence requires a project id ({ project: 'prj_...' })", "verifying deploy edge coherence");
|
|
396
404
|
}
|
|
397
405
|
const headers = await apikeyHeaders(this.client, opts.project);
|
|
@@ -411,6 +419,7 @@ export class Deploy {
|
|
|
411
419
|
const timeoutMs = normalizePositiveSafeIntegerQueryOption(opts?.timeoutMs ?? 60_000, "apply.waitEdgeCoherent timeoutMs", "waiting for deploy edge coherence") ?? 60_000;
|
|
412
420
|
const intervalMs = normalizePositiveSafeIntegerQueryOption(opts?.intervalMs ?? 1_000, "apply.waitEdgeCoherent intervalMs", "waiting for deploy edge coherence") ?? 1_000;
|
|
413
421
|
if (!opts?.project) {
|
|
422
|
+
// local-check: argument — project id picks the apikey headers
|
|
414
423
|
throw new LocalError("apply.waitEdgeCoherent requires a project id ({ project: 'prj_...' })", "waiting for deploy edge coherence");
|
|
415
424
|
}
|
|
416
425
|
const start = Date.now();
|
|
@@ -436,9 +445,11 @@ export class Deploy {
|
|
|
436
445
|
*/
|
|
437
446
|
async getRelease(opts) {
|
|
438
447
|
if (!opts?.project) {
|
|
448
|
+
// local-check: argument — project id picks the apikey headers
|
|
439
449
|
throw new LocalError("apply.getRelease requires a project id ({ project: 'prj_...', releaseId: 'rel_...' })", "fetching release inventory");
|
|
440
450
|
}
|
|
441
451
|
if (!opts.releaseId) {
|
|
452
|
+
// local-check: argument — release id builds the request URL
|
|
442
453
|
throw new LocalError("apply.getRelease requires a release id", "fetching release inventory");
|
|
443
454
|
}
|
|
444
455
|
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "apply.getRelease siteLimit", "fetching release inventory");
|
|
@@ -456,6 +467,7 @@ export class Deploy {
|
|
|
456
467
|
*/
|
|
457
468
|
async getActiveRelease(opts) {
|
|
458
469
|
if (!opts?.project) {
|
|
470
|
+
// local-check: argument — project id picks the apikey headers
|
|
459
471
|
throw new LocalError("apply.getActiveRelease requires a project id ({ project: 'prj_...' })", "fetching active release inventory");
|
|
460
472
|
}
|
|
461
473
|
const siteLimit = normalizePositiveSafeIntegerQueryOption(opts.siteLimit, "apply.getActiveRelease siteLimit", "fetching active release inventory");
|
|
@@ -471,6 +483,7 @@ export class Deploy {
|
|
|
471
483
|
*/
|
|
472
484
|
async diff(opts) {
|
|
473
485
|
if (!opts?.project) {
|
|
486
|
+
// local-check: argument — project id picks the apikey headers
|
|
474
487
|
throw new LocalError("apply.diff requires a project id ({ project: 'prj_...', from, to })", "diffing releases");
|
|
475
488
|
}
|
|
476
489
|
const from = requireNonEmptyStringQueryOption(opts.from, "apply.diff from", "diffing releases");
|
|
@@ -511,12 +524,14 @@ function normalizePositiveSafeIntegerQueryOption(value, label, context) {
|
|
|
511
524
|
if (value === undefined)
|
|
512
525
|
return undefined;
|
|
513
526
|
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
527
|
+
// local-check: argument — numeric option type, also the SDK's own poll timing
|
|
514
528
|
throw new LocalError(`${label} must be a positive safe integer`, context);
|
|
515
529
|
}
|
|
516
530
|
return value;
|
|
517
531
|
}
|
|
518
532
|
function requireNonEmptyStringQueryOption(value, label, context) {
|
|
519
533
|
if (typeof value !== "string" || value.length === 0) {
|
|
534
|
+
// local-check: argument — query option must be a string
|
|
520
535
|
throw new LocalError(`${label} must be a non-empty string`, context);
|
|
521
536
|
}
|
|
522
537
|
return value;
|
|
@@ -588,6 +603,7 @@ async function rehearseBeforeCommit(client, plan, planId, project, opts, emit) {
|
|
|
588
603
|
durationMs: report.duration_ms,
|
|
589
604
|
});
|
|
590
605
|
if (report.status !== "passed") {
|
|
606
|
+
// local-check: protects_local — the SDK's own rehearsal failed, so it does not commit
|
|
591
607
|
throw new Run402DeployError(`${report.branch_project_id ? "Rehearsal failed on a contained branch" : "Rehearsal failed"}; nothing was committed. ${describeRehearsalFailure(report)}`, {
|
|
592
608
|
code: "REHEARSAL_FAILED",
|
|
593
609
|
phase: "rehearsal",
|
|
@@ -675,6 +691,7 @@ async function pollRehearsal(client, planId, operationId, project, emit) {
|
|
|
675
691
|
throw translateGatewayError(snapshot.error, "rehearsal", planId, operationId);
|
|
676
692
|
}
|
|
677
693
|
if (Date.now() - start > REHEARSAL_POLL_TIMEOUT_MS) {
|
|
694
|
+
// local-check: sdk_normalization — the SDK's own rehearsal poll ran out of time
|
|
678
695
|
throw new Run402DeployError(`Timed out waiting for rehearsal operation ${operationId} to finish`, {
|
|
679
696
|
code: "INTERNAL_ERROR",
|
|
680
697
|
phase: "rehearsal",
|
|
@@ -723,6 +740,7 @@ async function applyOnce(client, spec, opts, emit) {
|
|
|
723
740
|
const allowWarningCodes = normalizeAllowWarningCodes(opts.allowWarningCodes);
|
|
724
741
|
const target = opts.target === "core" ? "core" : "cloud";
|
|
725
742
|
if (opts.vault && target === "core") {
|
|
743
|
+
// local-check: sdk_normalization — the vault gate is not available on the Core gateway this client talks to
|
|
726
744
|
// Refuse rather than drop the hooks: silently committing without the
|
|
727
745
|
// activation block would activate a `required` project unvaulted.
|
|
728
746
|
throw new Run402DeployError("vault-bound deploys are not supported against a self-hosted Core gateway; the vault gate is a Cloud control-plane capability.", { code: "VAULT_UNSUPPORTED_TARGET", phase: "validate", retryable: false, context: "applying deploy" });
|
|
@@ -893,6 +911,7 @@ function normalizeApplyMaxRetries(value) {
|
|
|
893
911
|
if (value === undefined)
|
|
894
912
|
return APPLY_RETRY_DEFAULT_MAX_RETRIES;
|
|
895
913
|
if (!Number.isInteger(value) || value < 0 || !Number.isFinite(value)) {
|
|
914
|
+
// local-check: argument — maxRetries drives the SDK's own retry loop
|
|
896
915
|
throw new Run402DeployError("ApplyOptions.maxRetries must be a non-negative integer", {
|
|
897
916
|
code: "INVALID_SPEC",
|
|
898
917
|
phase: "validate",
|
|
@@ -981,6 +1000,7 @@ function contentRefToCoreSpec(ref) {
|
|
|
981
1000
|
function requireContentRef(ref, resource) {
|
|
982
1001
|
if (ref)
|
|
983
1002
|
return ref;
|
|
1003
|
+
// local-check: sdk_normalization — internal: a normalized entry lost its content ref
|
|
984
1004
|
throw new Run402DeployError(`Missing content ref for ${resource}`, {
|
|
985
1005
|
code: "INTERNAL_ERROR",
|
|
986
1006
|
phase: "validate",
|
|
@@ -1129,26 +1149,30 @@ function functionsToWire(functions) {
|
|
|
1129
1149
|
: {}),
|
|
1130
1150
|
};
|
|
1131
1151
|
}
|
|
1152
|
+
function siteFileSlicesTo(site, toFiles) {
|
|
1153
|
+
// replace and patch are each carried when present; a site with both is the
|
|
1154
|
+
// gateway's to refuse (INVALID_SPEC), never silently narrowed here.
|
|
1155
|
+
const raw = site;
|
|
1156
|
+
return {
|
|
1157
|
+
...(raw.replace ? { replace: toFiles(raw.replace) } : {}),
|
|
1158
|
+
...(raw.patch
|
|
1159
|
+
? {
|
|
1160
|
+
patch: {
|
|
1161
|
+
...(raw.patch.put ? { put: toFiles(raw.patch.put) } : {}),
|
|
1162
|
+
...(raw.patch.delete !== undefined ? { delete: raw.patch.delete } : {}),
|
|
1163
|
+
},
|
|
1164
|
+
}
|
|
1165
|
+
: {}),
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1132
1168
|
function siteToCoreSpec(site) {
|
|
1133
|
-
if ("replace" in site && site.replace) {
|
|
1134
|
-
return {
|
|
1135
|
-
replace: fileSetToCoreSpec(site.replace),
|
|
1136
|
-
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
if ("patch" in site && site.patch) {
|
|
1140
|
-
return {
|
|
1141
|
-
patch: {
|
|
1142
|
-
...(site.patch.put ? { put: fileSetToCoreSpec(site.patch.put) } : {}),
|
|
1143
|
-
...(site.patch.delete ? { delete: site.patch.delete } : {}),
|
|
1144
|
-
},
|
|
1145
|
-
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
1169
|
// tenant-site-embedding, site.sign_in_path, and site.noindex never reach
|
|
1149
1170
|
// core: all three are gateway-owned and core validates site keys against
|
|
1150
1171
|
// its own list.
|
|
1151
|
-
return
|
|
1172
|
+
return {
|
|
1173
|
+
...siteFileSlicesTo(site, fileSetToCoreSpec),
|
|
1174
|
+
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1175
|
+
};
|
|
1152
1176
|
}
|
|
1153
1177
|
function siteToWire(site) {
|
|
1154
1178
|
// tenant-site-embedding: `null` is a meaningful value on the wire (clear), so
|
|
@@ -1158,28 +1182,8 @@ function siteToWire(site) {
|
|
|
1158
1182
|
const embedding = "embedding" in site && site.embedding !== undefined ? { embedding: site.embedding } : {};
|
|
1159
1183
|
const signInPath = "sign_in_path" in site && site.sign_in_path !== undefined ? { sign_in_path: site.sign_in_path } : {};
|
|
1160
1184
|
const noindex = "noindex" in site && site.noindex !== undefined ? { noindex: site.noindex } : {};
|
|
1161
|
-
if ("replace" in site && site.replace) {
|
|
1162
|
-
return {
|
|
1163
|
-
replace: fileSetToWire(site.replace),
|
|
1164
|
-
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1165
|
-
...embedding,
|
|
1166
|
-
...signInPath,
|
|
1167
|
-
...noindex,
|
|
1168
|
-
};
|
|
1169
|
-
}
|
|
1170
|
-
if ("patch" in site && site.patch) {
|
|
1171
|
-
return {
|
|
1172
|
-
patch: {
|
|
1173
|
-
...(site.patch.put ? { put: fileSetToWire(site.patch.put) } : {}),
|
|
1174
|
-
...(site.patch.delete ? { delete: site.patch.delete } : {}),
|
|
1175
|
-
},
|
|
1176
|
-
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1177
|
-
...embedding,
|
|
1178
|
-
...signInPath,
|
|
1179
|
-
...noindex,
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
1185
|
return {
|
|
1186
|
+
...siteFileSlicesTo(site, fileSetToWire),
|
|
1183
1187
|
...(site.public_paths ? { public_paths: site.public_paths } : {}),
|
|
1184
1188
|
...embedding,
|
|
1185
1189
|
...signInPath,
|
|
@@ -1261,6 +1265,7 @@ async function planInternal(client, spec, idempotencyKey, opts = {}) {
|
|
|
1261
1265
|
body = inlineBody;
|
|
1262
1266
|
}
|
|
1263
1267
|
else if (isCore) {
|
|
1268
|
+
// local-check: sdk_normalization — the SDK spilled the spec to manifest_ref, which Core cannot take
|
|
1264
1269
|
throw new Run402DeployError("Core deploy planning requires an inline spec under the gateway body cap; manifest_ref is not supported by Run402 Core yet.", {
|
|
1265
1270
|
code: "DRY_RUN_REQUIRES_INLINE_SPEC",
|
|
1266
1271
|
phase: "validate",
|
|
@@ -1271,6 +1276,7 @@ async function planInternal(client, spec, idempotencyKey, opts = {}) {
|
|
|
1271
1276
|
}
|
|
1272
1277
|
else {
|
|
1273
1278
|
if (dryRun || reviewedPlan || opts.requiredPlan) {
|
|
1279
|
+
// local-check: sdk_normalization — the SDK spilled the spec to manifest_ref, which this flow cannot take
|
|
1274
1280
|
throw new Run402DeployError("Check/plan/require-plan deploy planning requires an inline spec under the gateway body cap; the normalized deploy plan would require manifest_ref.", {
|
|
1275
1281
|
code: "PLAN_REQUIRES_INLINE_SPEC",
|
|
1276
1282
|
phase: "validate",
|
|
@@ -1280,6 +1286,7 @@ async function planInternal(client, spec, idempotencyKey, opts = {}) {
|
|
|
1280
1286
|
});
|
|
1281
1287
|
}
|
|
1282
1288
|
if (ciCredentials) {
|
|
1289
|
+
// local-check: sdk_normalization — the SDK spilled the spec to manifest_ref, which CI cannot take
|
|
1283
1290
|
throw new Run402DeployError("CI deploys must use inline specs under the gateway body cap; the normalized deploy plan would require manifest_ref.", {
|
|
1284
1291
|
code: "forbidden_spec_field",
|
|
1285
1292
|
phase: "validate",
|
|
@@ -1438,6 +1445,7 @@ async function uploadMissing(client, projectId, presence, byteReaders, emit) {
|
|
|
1438
1445
|
for (const session of planRes.missing) {
|
|
1439
1446
|
const reader = byteReaders.get(session.sha256);
|
|
1440
1447
|
if (!reader) {
|
|
1448
|
+
// local-check: sdk_normalization — internal: no local byte reader for a requested upload
|
|
1441
1449
|
throw new Run402DeployError(`internal: no local byte reader for sha ${session.sha256.slice(0, 12)}…`, {
|
|
1442
1450
|
code: "CONTENT_UPLOAD_FAILED",
|
|
1443
1451
|
phase: "upload",
|
|
@@ -1526,11 +1534,13 @@ async function commitContentPlan(client, planId, headers) {
|
|
|
1526
1534
|
for (;;) {
|
|
1527
1535
|
const status = state?.status;
|
|
1528
1536
|
if (state && status !== "committing" && status !== "pending") {
|
|
1537
|
+
// local-check: sdk_normalization — the content commit the SDK polls ended failed or expired
|
|
1529
1538
|
if (status === "failed" || status === "expired")
|
|
1530
1539
|
throw contentCommitStateError(planId, state);
|
|
1531
1540
|
return;
|
|
1532
1541
|
}
|
|
1533
1542
|
if (Date.now() >= deadline) {
|
|
1543
|
+
// local-check: sdk_normalization — the SDK's own content-commit poll ran out of time
|
|
1534
1544
|
throw new Run402DeployError(`Content commit for plan ${planId} was still running after ${CONTENT_COMMIT_POLL_TIMEOUT_MS / 60_000} minutes; read GET ${planPath} for its state`, { code: "CONTENT_UPLOAD_FAILED", phase: "upload", retryable: true, planId, context: "committing content upload" });
|
|
1535
1545
|
}
|
|
1536
1546
|
if (status === "pending") {
|
|
@@ -1592,6 +1602,7 @@ async function uploadOneWithRetry(fetchFn, session, bytes) {
|
|
|
1592
1602
|
async function uploadOne(fetchFn, entry, bytes) {
|
|
1593
1603
|
if (entry.mode === "single") {
|
|
1594
1604
|
if (entry.parts.length !== 1) {
|
|
1605
|
+
// local-check: sdk_normalization — unexpected upload session shape from the gateway
|
|
1595
1606
|
throw new Run402DeployError(`internal: single-mode upload for ${entry.sha256.slice(0, 12)}… returned ${entry.parts.length} parts`, {
|
|
1596
1607
|
code: "CONTENT_UPLOAD_FAILED",
|
|
1597
1608
|
phase: "upload",
|
|
@@ -1611,6 +1622,7 @@ async function uploadOne(fetchFn, entry, bytes) {
|
|
|
1611
1622
|
const checksum = await sha256Base64(slice);
|
|
1612
1623
|
const etag = await putToS3(fetchFn, part.url, slice, checksum, part.part_number);
|
|
1613
1624
|
if (!etag) {
|
|
1625
|
+
// local-check: sdk_normalization — S3 answered without an ETag
|
|
1614
1626
|
throw new Run402DeployError(`S3 PUT succeeded for multipart part ${part.part_number} but did not return an ETag`, {
|
|
1615
1627
|
code: "CONTENT_UPLOAD_FAILED",
|
|
1616
1628
|
phase: "upload",
|
|
@@ -1663,6 +1675,7 @@ async function putToS3(fetchFn, url, body, checksumBase64, partNumber) {
|
|
|
1663
1675
|
});
|
|
1664
1676
|
}
|
|
1665
1677
|
catch (err) {
|
|
1678
|
+
// local-check: sdk_normalization — the S3 PUT failed in transport
|
|
1666
1679
|
throw new Run402DeployError(`S3 PUT failed for part ${partNumber}: ${err.message}`, {
|
|
1667
1680
|
code: "CONTENT_UPLOAD_FAILED",
|
|
1668
1681
|
phase: "upload",
|
|
@@ -1672,6 +1685,7 @@ async function putToS3(fetchFn, url, body, checksumBase64, partNumber) {
|
|
|
1672
1685
|
}
|
|
1673
1686
|
if (!res.ok) {
|
|
1674
1687
|
const text = await res.text().catch(() => "");
|
|
1688
|
+
// local-check: sdk_normalization — S3 refused the PUT
|
|
1675
1689
|
throw new Run402DeployError(`S3 PUT failed for part ${partNumber} (HTTP ${res.status})${text ? ": " + text.slice(0, 200) : ""}`, {
|
|
1676
1690
|
code: "CONTENT_UPLOAD_FAILED",
|
|
1677
1691
|
phase: "upload",
|
|
@@ -1689,6 +1703,7 @@ async function pollUntilReady(client, commit, diff, warnings, emit, projectId, s
|
|
|
1689
1703
|
}
|
|
1690
1704
|
if (commit.status === "ready") {
|
|
1691
1705
|
if (!commit.release_id || !commit.urls) {
|
|
1706
|
+
// local-check: sdk_normalization — commit response is ready but carries no release
|
|
1692
1707
|
throw new Run402DeployError("Commit returned ready but no release_id/urls", {
|
|
1693
1708
|
code: "INTERNAL_ERROR",
|
|
1694
1709
|
phase: "ready",
|
|
@@ -1825,6 +1840,7 @@ async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, pro
|
|
|
1825
1840
|
}
|
|
1826
1841
|
if (snapshot.status === SUCCESS_STATUS) {
|
|
1827
1842
|
if (!snapshot.release_id || !snapshot.urls) {
|
|
1843
|
+
// local-check: sdk_normalization — operation is ready but carries no release
|
|
1828
1844
|
throw new Run402DeployError("Operation reached ready but no release_id/urls available", {
|
|
1829
1845
|
code: "INTERNAL_ERROR",
|
|
1830
1846
|
phase: "ready",
|
|
@@ -1868,6 +1884,7 @@ async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, pro
|
|
|
1868
1884
|
throw translateGatewayError(snapshot.error, "activate", snapshot.plan_id, snapshot.operation_id);
|
|
1869
1885
|
}
|
|
1870
1886
|
if (Date.now() - start > COMMIT_POLL_TIMEOUT_MS) {
|
|
1887
|
+
// local-check: sdk_normalization — the SDK's own operation poll ran out of time
|
|
1871
1888
|
throw new Run402DeployError(`Timed out waiting for operation ${snapshot.operation_id} to reach ready`, {
|
|
1872
1889
|
code: "INTERNAL_ERROR",
|
|
1873
1890
|
phase: snapshot.status,
|
|
@@ -2140,7 +2157,6 @@ const ROUTE_ENTRY_FIELDS = new Set(["pattern", "methods", "target", "pricing"]);
|
|
|
2140
2157
|
const FUNCTION_ROUTE_TARGET_FIELDS = new Set(["type", "name"]);
|
|
2141
2158
|
const STATIC_ROUTE_TARGET_FIELDS = new Set(["type", "file"]);
|
|
2142
2159
|
const REPO_ROUTE_TARGET_FIELDS = new Set(["type", "repo", "path", "requireAuth", "requireRole"]);
|
|
2143
|
-
const ROUTE_METHOD_SET = new Set(ROUTE_HTTP_METHODS);
|
|
2144
2160
|
const ROUTE_PRICING_FIELDS = new Set([
|
|
2145
2161
|
"mode",
|
|
2146
2162
|
"amount_usd_micros",
|
|
@@ -2150,15 +2166,11 @@ const ROUTE_PRICING_FIELDS = new Set([
|
|
|
2150
2166
|
"receipt",
|
|
2151
2167
|
"discovery",
|
|
2152
2168
|
]);
|
|
2153
|
-
const ROUTE_PRICING_NETWORK_SET = new Set(ROUTE_PRICING_NETWORKS);
|
|
2154
2169
|
const I18N_SPEC_FIELDS = new Set(["defaultLocale", "locales", "detect", "unknownLocalePolicy"]);
|
|
2155
|
-
const I18N_LOCALE_TAG_REGEX = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
2156
|
-
const I18N_COOKIE_NAME_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
2157
|
-
const I18N_MAX_LOCALES = 50;
|
|
2158
|
-
const I18N_MAX_DETECT_SOURCES = 10;
|
|
2159
2170
|
const MIGRATION_NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
2160
2171
|
function validateSpec(spec) {
|
|
2161
2172
|
if (!spec || typeof spec !== "object") {
|
|
2173
|
+
// local-check: argument — the spec argument must be an object
|
|
2162
2174
|
throw new Run402DeployError("ReleaseSpec must be an object", {
|
|
2163
2175
|
code: "INVALID_SPEC",
|
|
2164
2176
|
phase: "validate",
|
|
@@ -2173,6 +2185,7 @@ function validateSpec(spec) {
|
|
|
2173
2185
|
subdomain: "Use `subdomains: { set: [name] }`.",
|
|
2174
2186
|
});
|
|
2175
2187
|
if (!spec.project_id || typeof spec.project_id !== "string") {
|
|
2188
|
+
// local-check: argument — project id picks the apikey and URL
|
|
2176
2189
|
throw new Run402DeployError("ReleaseSpec.project_id is required", {
|
|
2177
2190
|
code: "INVALID_SPEC",
|
|
2178
2191
|
phase: "validate",
|
|
@@ -2188,22 +2201,10 @@ function validateSpec(spec) {
|
|
|
2188
2201
|
validateSiteSpec(raw.site);
|
|
2189
2202
|
validateSubdomainsSpec(raw.subdomains);
|
|
2190
2203
|
validateRoutesSpec(raw.routes);
|
|
2191
|
-
validateChecksSpec(raw.checks);
|
|
2192
2204
|
validateSecretsSpec(raw.secrets);
|
|
2193
2205
|
validateI18nSpec(raw.i18n);
|
|
2194
|
-
const subdomains = raw.subdomains;
|
|
2195
|
-
const set = subdomains?.set;
|
|
2196
|
-
if (set && set.length > 1) {
|
|
2197
|
-
throw new Run402DeployError("subdomains.set accepts at most one subdomain per project; multi-subdomain support is not yet available", {
|
|
2198
|
-
code: "SUBDOMAIN_MULTI_NOT_SUPPORTED",
|
|
2199
|
-
phase: "validate",
|
|
2200
|
-
resource: "subdomains.set",
|
|
2201
|
-
retryable: false,
|
|
2202
|
-
fix: { action: "set_field", path: "subdomains.set" },
|
|
2203
|
-
context: "validating spec",
|
|
2204
|
-
});
|
|
2205
|
-
}
|
|
2206
2206
|
if (!hasDeployableContent(raw)) {
|
|
2207
|
+
// local-check: protects_local — an empty spec is refused before hashing and uploading
|
|
2207
2208
|
throw new Run402DeployError(`ReleaseSpec contains no deployable sections. Expected at least one non-empty section: ${DEPLOYABLE_SPEC_FIELDS.join(", ")}`, {
|
|
2208
2209
|
code: "MANIFEST_EMPTY",
|
|
2209
2210
|
phase: "validate",
|
|
@@ -2220,9 +2221,6 @@ function validateBaseSpec(base) {
|
|
|
2220
2221
|
return;
|
|
2221
2222
|
const obj = requireObject(base, "base");
|
|
2222
2223
|
validateKnownFields(obj, "base", BASE_SPEC_FIELDS);
|
|
2223
|
-
if (hasOwn(obj, "release") && hasOwn(obj, "release_id")) {
|
|
2224
|
-
throw invalidSpec("ReleaseSpec.base must use either release or release_id, not both", "base");
|
|
2225
|
-
}
|
|
2226
2224
|
}
|
|
2227
2225
|
function validateDatabaseSpec(database) {
|
|
2228
2226
|
if (database === undefined)
|
|
@@ -2231,6 +2229,7 @@ function validateDatabaseSpec(database) {
|
|
|
2231
2229
|
validateKnownFields(obj, "database", DATABASE_SPEC_FIELDS);
|
|
2232
2230
|
if (obj.migrations !== undefined) {
|
|
2233
2231
|
if (!Array.isArray(obj.migrations)) {
|
|
2232
|
+
// local-check: sdk_normalization — the SDK walks migrations to hash their SQL
|
|
2234
2233
|
throw invalidSpec("ReleaseSpec.database.migrations must be an array", "database.migrations");
|
|
2235
2234
|
}
|
|
2236
2235
|
const seenNames = new Map();
|
|
@@ -2249,17 +2248,21 @@ function validateMigrationIdentity(migration, index, seenNames) {
|
|
|
2249
2248
|
const hasId = hasOwn(migration, "id") && migration.id !== undefined;
|
|
2250
2249
|
const hasName = hasOwn(migration, "name") && migration.name !== undefined;
|
|
2251
2250
|
if (hasId && hasName) {
|
|
2251
|
+
// local-check: sdk_normalization — migration name is SDK-only, lowered to an id
|
|
2252
2252
|
throw invalidSpec(`ReleaseSpec.${resource} declares both id and name; use exactly one`, resource);
|
|
2253
2253
|
}
|
|
2254
2254
|
if (!hasId && !hasName) {
|
|
2255
|
+
// local-check: sdk_normalization — migration name is SDK-only, lowered to an id
|
|
2255
2256
|
throw invalidSpec(`ReleaseSpec.${resource} must declare exactly one of id or name`, resource);
|
|
2256
2257
|
}
|
|
2257
2258
|
if (hasName) {
|
|
2258
2259
|
if (typeof migration.name !== "string" || !MIGRATION_NAME_RE.test(migration.name)) {
|
|
2260
|
+
// local-check: sdk_normalization — migration name is SDK-only, lowered to an id
|
|
2259
2261
|
throw invalidSpec(`ReleaseSpec.${resource}.name must match /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/`, `${resource}.name`);
|
|
2260
2262
|
}
|
|
2261
2263
|
const firstIndex = seenNames.get(migration.name);
|
|
2262
2264
|
if (firstIndex !== undefined) {
|
|
2265
|
+
// local-check: sdk_normalization — migration name is SDK-only, lowered to an id
|
|
2263
2266
|
throw invalidSpec(`ReleaseSpec.${resource}.name duplicates database.migrations.${firstIndex}.name ${JSON.stringify(migration.name)}`, `${resource}.name`);
|
|
2264
2267
|
}
|
|
2265
2268
|
seenNames.set(migration.name, index);
|
|
@@ -2278,8 +2281,6 @@ function validateFunctionsSpec(functions) {
|
|
|
2278
2281
|
validateKnownFields(patch, "functions.patch", FUNCTIONS_PATCH_FIELDS);
|
|
2279
2282
|
if (patch.set !== undefined)
|
|
2280
2283
|
validateFunctionMap(patch.set, "functions.patch.set");
|
|
2281
|
-
if (patch.delete !== undefined)
|
|
2282
|
-
validateStringArray(patch.delete, "functions.patch.delete");
|
|
2283
2284
|
}
|
|
2284
2285
|
}
|
|
2285
2286
|
function validateFunctionMap(value, resource) {
|
|
@@ -2290,139 +2291,45 @@ function validateFunctionMap(value, resource) {
|
|
|
2290
2291
|
if (entry.config !== undefined) {
|
|
2291
2292
|
const config = requireObject(entry.config, `${resource}.${name}.config`);
|
|
2292
2293
|
validateKnownFields(config, `${resource}.${name}.config`, FUNCTION_CONFIG_FIELDS);
|
|
2293
|
-
validateFunctionConfigInteger(config.timeoutSeconds, `${resource}.${name}.config.timeoutSeconds`);
|
|
2294
|
-
validateFunctionConfigInteger(config.memoryMb, `${resource}.${name}.config.memoryMb`);
|
|
2295
2294
|
}
|
|
2296
2295
|
if (entry.files !== undefined) {
|
|
2297
2296
|
requireObject(entry.files, `${resource}.${name}.files`);
|
|
2298
2297
|
}
|
|
2299
2298
|
validateFunctionTriggers(entry.triggers, `${resource}.${name}.triggers`);
|
|
2300
|
-
validateFunctionTools(entry.tools, `${resource}.${name}.tools
|
|
2299
|
+
validateFunctionTools(entry.tools, `${resource}.${name}.tools`);
|
|
2301
2300
|
}
|
|
2302
2301
|
}
|
|
2303
2302
|
/**
|
|
2304
|
-
* `tools` passed as data
|
|
2305
|
-
*
|
|
2303
|
+
* `tools` passed as data is sent as written; its entry rules are the
|
|
2304
|
+
* gateway's (MCP_TOOL_* at plan). The SDK copies each entry, so it needs an array.
|
|
2306
2305
|
*/
|
|
2307
|
-
function validateFunctionTools(value, resource
|
|
2306
|
+
function validateFunctionTools(value, resource) {
|
|
2308
2307
|
if (value === undefined)
|
|
2309
2308
|
return;
|
|
2309
|
+
// local-check: sdk_normalization — the SDK copies each tool entry
|
|
2310
2310
|
if (!Array.isArray(value))
|
|
2311
2311
|
throw invalidSpec(`ReleaseSpec.${resource} must be an array`, resource);
|
|
2312
|
-
for (const [index, entry] of value.entries()) {
|
|
2313
|
-
const fieldPath = `${resource}[${index}]`;
|
|
2314
|
-
const checked = checkFunctionToolEntry(entry, fieldPath);
|
|
2315
|
-
if (!checked.ok) {
|
|
2316
|
-
const name = isRecord(entry) && typeof entry.name === "string" ? entry.name : undefined;
|
|
2317
|
-
throw toolDeclarationError({ ...checked.problem, file: null, ...(name !== undefined ? { tool: name } : {}) }, { functionName });
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
2312
|
}
|
|
2321
2313
|
function validateFunctionTriggers(value, resource) {
|
|
2322
2314
|
if (value === undefined)
|
|
2323
2315
|
return;
|
|
2316
|
+
// local-check: sdk_normalization — the SDK walks the trigger list to normalize it
|
|
2324
2317
|
if (!Array.isArray(value))
|
|
2325
2318
|
throw invalidSpec(`ReleaseSpec.${resource} must be an array`, resource);
|
|
2326
|
-
|
|
2319
|
+
// Ids, types, cron, mailbox, events, repo, paths and run values are the
|
|
2320
|
+
// gateway's rules (INVALID_SPEC at plan); every field is carried as written.
|
|
2327
2321
|
for (const [index, trigger] of value.entries()) {
|
|
2328
2322
|
const path = `${resource}.${index}`;
|
|
2329
2323
|
const obj = requireObject(trigger, path);
|
|
2330
2324
|
validateKnownFields(obj, path, FUNCTION_TRIGGER_FIELDS, {
|
|
2331
2325
|
delivery: "Remove delivery; schedule triggers always start durable function runs.",
|
|
2332
2326
|
});
|
|
2333
|
-
|
|
2334
|
-
// cron and timezone) and its run (D-scheduled-functions-5).
|
|
2335
|
-
const isSchedule = obj.type === "schedule";
|
|
2336
|
-
if (!(isSchedule && obj.id === undefined)) {
|
|
2337
|
-
if (typeof obj.id !== "string" || obj.id.trim() === "") {
|
|
2338
|
-
throw invalidSpec(`ReleaseSpec.${path}.id is required for ${String(obj.type)} triggers`, `${path}.id`);
|
|
2339
|
-
}
|
|
2340
|
-
if (seen.has(obj.id))
|
|
2341
|
-
throw invalidSpec(`ReleaseSpec.${path}.id duplicates ${JSON.stringify(obj.id)}`, `${path}.id`);
|
|
2342
|
-
seen.add(obj.id);
|
|
2343
|
-
}
|
|
2344
|
-
if (obj.type !== "app_repo" && (obj.repo !== undefined || obj.paths !== undefined)) {
|
|
2345
|
-
throw invalidSpec(`ReleaseSpec.${path} ${String(obj.type)} triggers cannot include repo or paths`, path);
|
|
2346
|
-
}
|
|
2347
|
-
if (obj.type === "schedule") {
|
|
2348
|
-
if (obj.mailbox !== undefined || obj.events !== undefined) {
|
|
2349
|
-
throw invalidSpec(`ReleaseSpec.${path} schedule triggers cannot include mailbox or events`, path);
|
|
2350
|
-
}
|
|
2351
|
-
if (typeof obj.cron !== "string" || obj.cron.trim().split(/\s+/).length !== 5) {
|
|
2352
|
-
throw invalidSpec(`ReleaseSpec.${path}.cron must be a 5-field cron expression`, `${path}.cron`);
|
|
2353
|
-
}
|
|
2354
|
-
if (obj.timezone !== undefined && typeof obj.timezone !== "string") {
|
|
2355
|
-
throw invalidSpec(`ReleaseSpec.${path}.timezone must be a string`, `${path}.timezone`);
|
|
2356
|
-
}
|
|
2357
|
-
if (obj.misfire_policy !== undefined && obj.misfire_policy !== "skip") {
|
|
2358
|
-
throw invalidSpec(`ReleaseSpec.${path}.misfire_policy must be "skip"`, `${path}.misfire_policy`);
|
|
2359
|
-
}
|
|
2360
|
-
if (obj.overlap_policy !== undefined && obj.overlap_policy !== "allow") {
|
|
2361
|
-
throw invalidSpec(`ReleaseSpec.${path}.overlap_policy must be "allow"`, `${path}.overlap_policy`);
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
else if (obj.type === "email") {
|
|
2365
|
-
if (obj.cron !== undefined ||
|
|
2366
|
-
obj.timezone !== undefined ||
|
|
2367
|
-
obj.misfire_policy !== undefined ||
|
|
2368
|
-
obj.overlap_policy !== undefined) {
|
|
2369
|
-
throw invalidSpec(`ReleaseSpec.${path} email triggers cannot include schedule fields`, path);
|
|
2370
|
-
}
|
|
2371
|
-
if (typeof obj.mailbox !== "string" || obj.mailbox.trim() === "") {
|
|
2372
|
-
throw invalidSpec(`ReleaseSpec.${path}.mailbox is required`, `${path}.mailbox`);
|
|
2373
|
-
}
|
|
2374
|
-
if (!Array.isArray(obj.events) || obj.events.length === 0) {
|
|
2375
|
-
throw invalidSpec(`ReleaseSpec.${path}.events must be a non-empty array`, `${path}.events`);
|
|
2376
|
-
}
|
|
2377
|
-
for (const [eventIndex, event] of obj.events.entries()) {
|
|
2378
|
-
if (typeof event !== "string" || !EMAIL_TRIGGER_EVENTS.has(event)) {
|
|
2379
|
-
throw invalidSpec(`ReleaseSpec.${path}.events.${eventIndex} must be one of reply_received, delivery, bounced, complained, mailbox_suspended, sender_suspended`, `${path}.events.${eventIndex}`);
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
else if (obj.type === "app_repo") {
|
|
2384
|
-
if (obj.cron !== undefined ||
|
|
2385
|
-
obj.timezone !== undefined ||
|
|
2386
|
-
obj.misfire_policy !== undefined ||
|
|
2387
|
-
obj.overlap_policy !== undefined ||
|
|
2388
|
-
obj.mailbox !== undefined ||
|
|
2389
|
-
obj.events !== undefined) {
|
|
2390
|
-
throw invalidSpec(`ReleaseSpec.${path} app_repo triggers take only repo, paths and run`, path);
|
|
2391
|
-
}
|
|
2392
|
-
if (typeof obj.repo !== "string" || obj.repo.trim() === "") {
|
|
2393
|
-
throw invalidSpec(`ReleaseSpec.${path}.repo is required (an app repo name, e.g. "default", or "*" for every repo of the project)`, `${path}.repo`);
|
|
2394
|
-
}
|
|
2395
|
-
if (obj.paths !== undefined) {
|
|
2396
|
-
if (!Array.isArray(obj.paths) || obj.paths.length === 0) {
|
|
2397
|
-
throw invalidSpec(`ReleaseSpec.${path}.paths must be a non-empty array of path prefixes; omit it for every commit`, `${path}.paths`);
|
|
2398
|
-
}
|
|
2399
|
-
for (const [pathIndex, prefix] of obj.paths.entries()) {
|
|
2400
|
-
if (typeof prefix !== "string" || prefix === "") {
|
|
2401
|
-
throw invalidSpec(`ReleaseSpec.${path}.paths.${pathIndex} must be a non-empty string`, `${path}.paths.${pathIndex}`);
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
else {
|
|
2407
|
-
throw invalidSpec(`ReleaseSpec.${path}.type must be "schedule", "email" or "app_repo"`, `${path}.type`);
|
|
2408
|
-
}
|
|
2409
|
-
if (isSchedule && obj.run === undefined)
|
|
2327
|
+
if (obj.run === undefined)
|
|
2410
2328
|
continue;
|
|
2411
2329
|
const run = requireObject(obj.run, `${path}.run`);
|
|
2412
2330
|
validateKnownFields(run, `${path}.run`, FUNCTION_TRIGGER_RUN_FIELDS);
|
|
2413
|
-
if (!(isSchedule && run.event_type === undefined) && (typeof run.event_type !== "string" || run.event_type.trim() === "")) {
|
|
2414
|
-
throw invalidSpec(`ReleaseSpec.${path}.run.event_type is required`, `${path}.run.event_type`);
|
|
2415
|
-
}
|
|
2416
|
-
if (run.payload !== undefined)
|
|
2417
|
-
requireObject(run.payload, `${path}.run.payload`);
|
|
2418
2331
|
if (run.retry !== undefined)
|
|
2419
2332
|
requireObject(run.retry, `${path}.run.retry`);
|
|
2420
|
-
if (run.expires_after_seconds !== undefined &&
|
|
2421
|
-
(typeof run.expires_after_seconds !== "number" ||
|
|
2422
|
-
!Number.isSafeInteger(run.expires_after_seconds) ||
|
|
2423
|
-
run.expires_after_seconds <= 0)) {
|
|
2424
|
-
throw invalidSpec(`ReleaseSpec.${path}.run.expires_after_seconds must be a positive integer`, `${path}.run.expires_after_seconds`);
|
|
2425
|
-
}
|
|
2426
2333
|
}
|
|
2427
2334
|
}
|
|
2428
2335
|
/**
|
|
@@ -2471,6 +2378,7 @@ function assertNoAstroAdapterTreeInSite(paths, resource) {
|
|
|
2471
2378
|
}
|
|
2472
2379
|
if (offenders.length === 0)
|
|
2473
2380
|
return;
|
|
2381
|
+
// local-check: protects_local — a local build tree would be uploaded as static content
|
|
2474
2382
|
throw new Run402DeployError(`${resource} ships the @run402/astro adapter build tree (e.g. ${offenders
|
|
2475
2383
|
.map((p) => `\`${p}\``)
|
|
2476
2384
|
.join(", ")}) as static content. Only \`dist/run402/client/\` is deployable; ` +
|
|
@@ -2498,9 +2406,6 @@ function validateSiteSpec(site) {
|
|
|
2498
2406
|
file: "Use `site.replace` or `site.patch.put` with a path-keyed file map.",
|
|
2499
2407
|
files: "Use `site.replace` or `site.patch.put` with a path-keyed file map.",
|
|
2500
2408
|
});
|
|
2501
|
-
if (hasOwn(obj, "replace") && hasOwn(obj, "patch")) {
|
|
2502
|
-
throw invalidSpec("ReleaseSpec.site must use either replace or patch, not both", "site");
|
|
2503
|
-
}
|
|
2504
2409
|
if (obj.replace !== undefined) {
|
|
2505
2410
|
requireObject(obj.replace, "site.replace");
|
|
2506
2411
|
assertNoAstroAdapterTreeInSite(siteFileSetKeysForGuard(obj.replace), "site.replace");
|
|
@@ -2512,8 +2417,6 @@ function validateSiteSpec(site) {
|
|
|
2512
2417
|
requireObject(patch.put, "site.patch.put");
|
|
2513
2418
|
assertNoAstroAdapterTreeInSite(siteFileSetKeysForGuard(patch.put), "site.patch.put");
|
|
2514
2419
|
}
|
|
2515
|
-
if (patch.delete !== undefined)
|
|
2516
|
-
validateStringArray(patch.delete, "site.patch.delete");
|
|
2517
2420
|
}
|
|
2518
2421
|
if (obj.public_paths !== undefined) {
|
|
2519
2422
|
validateSitePublicPathsSpec(obj.public_paths, "site.public_paths");
|
|
@@ -2521,39 +2424,6 @@ function validateSiteSpec(site) {
|
|
|
2521
2424
|
if (obj.embedding !== undefined) {
|
|
2522
2425
|
validateSiteEmbeddingSpec(obj.embedding, "site.embedding");
|
|
2523
2426
|
}
|
|
2524
|
-
if (obj.sign_in_path !== undefined) {
|
|
2525
|
-
validateSiteSignInPath(obj.sign_in_path, "site.sign_in_path");
|
|
2526
|
-
}
|
|
2527
|
-
if (obj.noindex !== undefined) {
|
|
2528
|
-
validateSiteNoindex(obj.noindex, "site.noindex");
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
/** site.noindex. `true` = every response of the host carries
|
|
2532
|
-
* `X-Robots-Tag: noindex, nofollow, nosnippet`; `false` or `null` clears back
|
|
2533
|
-
* to indexable; omitted carries forward. */
|
|
2534
|
-
function validateSiteNoindex(value, resource) {
|
|
2535
|
-
if (value === null || typeof value === "boolean")
|
|
2536
|
-
return;
|
|
2537
|
-
throw invalidSpec(`ReleaseSpec.${resource} must be true, false, or null; send true to add X-Robots-Tag: noindex, nofollow, nosnippet to every response of the host, false or null to make it indexable again, or omit ${resource} to carry the previous value forward`, resource);
|
|
2538
|
-
}
|
|
2539
|
-
/** site.sign_in_path. Structural check only (the gateway is authoritative on
|
|
2540
|
-
* the reserved prefixes and the full rule set): a same-origin absolute path
|
|
2541
|
-
* like "/join", or `null` to clear back to the hosted sign-in page. Omitted
|
|
2542
|
-
* carries forward. */
|
|
2543
|
-
function validateSiteSignInPath(value, resource) {
|
|
2544
|
-
if (value === null)
|
|
2545
|
-
return;
|
|
2546
|
-
const hint = `omit ${resource} to carry the previous value forward or send null to use the hosted sign-in page`;
|
|
2547
|
-
if (typeof value !== "string") {
|
|
2548
|
-
throw invalidSpec(`ReleaseSpec.${resource} must be a same-origin path string (e.g. "/join") or null; ${hint}`, resource);
|
|
2549
|
-
}
|
|
2550
|
-
if (!value.startsWith("/") ||
|
|
2551
|
-
value.startsWith("//") ||
|
|
2552
|
-
value.length > 512 ||
|
|
2553
|
-
value.includes("://") ||
|
|
2554
|
-
/[?#\\\s\u0000-\u001f\u007f]/.test(value)) {
|
|
2555
|
-
throw invalidSpec(`ReleaseSpec.${resource} must be a same-origin path starting with a single "/" (e.g. "/join"), at most 512 characters, with no query, fragment, whitespace, backslash, or scheme; ${hint}`, resource);
|
|
2556
|
-
}
|
|
2557
2427
|
}
|
|
2558
2428
|
/** tenant-site-embedding. Structural check only: the catalog is the gateway's
|
|
2559
2429
|
* (it names the valid keys in INVALID_SPEC), so a new key never needs an SDK
|
|
@@ -2563,37 +2433,19 @@ function validateSiteEmbeddingSpec(value, resource) {
|
|
|
2563
2433
|
return;
|
|
2564
2434
|
const obj = requireObject(value, resource);
|
|
2565
2435
|
validateKnownFields(obj, resource, new Set(["frame_ancestors"]));
|
|
2566
|
-
if (!Array.isArray(obj.frame_ancestors) || obj.frame_ancestors.length === 0) {
|
|
2567
|
-
throw invalidSpec(`ReleaseSpec.${resource}.frame_ancestors must be a non-empty array of embedding catalog keys (e.g. ["localhost"]); omit ${resource} to carry the previous declaration forward or send null to deny`, `${resource}.frame_ancestors`);
|
|
2568
|
-
}
|
|
2569
|
-
validateStringArray(obj.frame_ancestors, `${resource}.frame_ancestors`);
|
|
2570
2436
|
}
|
|
2571
2437
|
function validateSitePublicPathsSpec(value, resource) {
|
|
2572
2438
|
const obj = requireObject(value, resource);
|
|
2573
2439
|
validateKnownFields(obj, resource, SITE_PUBLIC_PATHS_FIELDS);
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
if (obj.mode === "implicit") {
|
|
2578
|
-
if (hasOwn(obj, "replace")) {
|
|
2579
|
-
throw invalidSpec("ReleaseSpec.site.public_paths.replace is not allowed when mode is implicit", `${resource}.replace`);
|
|
2580
|
-
}
|
|
2440
|
+
// mode, and whether it takes a replace table, and each asset value are the
|
|
2441
|
+
// gateway's rules (INVALID_SPEC at plan); the table is carried as written.
|
|
2442
|
+
if (obj.replace === undefined)
|
|
2581
2443
|
return;
|
|
2582
|
-
}
|
|
2583
|
-
if (!hasOwn(obj, "replace")) {
|
|
2584
|
-
throw invalidSpec("ReleaseSpec.site.public_paths with mode explicit requires a complete public_paths.replace map", `${resource}.replace`);
|
|
2585
|
-
}
|
|
2586
2444
|
const replace = requireObject(obj.replace, `${resource}.replace`);
|
|
2587
2445
|
for (const [publicPath, entry] of Object.entries(replace)) {
|
|
2588
2446
|
const entryResource = `${resource}.replace.${publicPath}`;
|
|
2589
2447
|
const pathSpec = requireObject(entry, entryResource);
|
|
2590
2448
|
validateKnownFields(pathSpec, entryResource, PUBLIC_STATIC_PATH_FIELDS);
|
|
2591
|
-
if (typeof pathSpec.asset !== "string" || pathSpec.asset.length === 0) {
|
|
2592
|
-
throw invalidSpec(`ReleaseSpec.${entryResource}.asset must be a non-empty release static asset path`, `${entryResource}.asset`);
|
|
2593
|
-
}
|
|
2594
|
-
if (pathSpec.cache_class !== undefined && typeof pathSpec.cache_class !== "string") {
|
|
2595
|
-
throw invalidSpec(`ReleaseSpec.${entryResource}.cache_class must be a string`, `${entryResource}.cache_class`);
|
|
2596
|
-
}
|
|
2597
2449
|
}
|
|
2598
2450
|
}
|
|
2599
2451
|
function validateSubdomainsSpec(subdomains) {
|
|
@@ -2601,12 +2453,6 @@ function validateSubdomainsSpec(subdomains) {
|
|
|
2601
2453
|
return;
|
|
2602
2454
|
const obj = requireObject(subdomains, "subdomains");
|
|
2603
2455
|
validateKnownFields(obj, "subdomains", SUBDOMAINS_SPEC_FIELDS);
|
|
2604
|
-
if (obj.set !== undefined)
|
|
2605
|
-
validateStringArray(obj.set, "subdomains.set");
|
|
2606
|
-
if (obj.add !== undefined)
|
|
2607
|
-
validateStringArray(obj.add, "subdomains.add");
|
|
2608
|
-
if (obj.remove !== undefined)
|
|
2609
|
-
validateStringArray(obj.remove, "subdomains.remove");
|
|
2610
2456
|
}
|
|
2611
2457
|
function validateRoutesSpec(routes) {
|
|
2612
2458
|
if (routes === undefined)
|
|
@@ -2616,14 +2462,17 @@ function validateRoutesSpec(routes) {
|
|
|
2616
2462
|
const obj = requireObject(routes, "routes");
|
|
2617
2463
|
for (const key of Object.keys(obj)) {
|
|
2618
2464
|
if (key.startsWith("/")) {
|
|
2465
|
+
// local-check: sdk_normalization — path-keyed route maps are a shape the SDK cannot walk
|
|
2619
2466
|
throw invalidRouteSpec(`Unknown ReleaseSpec field: routes.${key}. ${routeShapeHints(obj)[key]}`, `routes.${key}`);
|
|
2620
2467
|
}
|
|
2621
2468
|
}
|
|
2622
2469
|
validateKnownFields(obj, "routes", ROUTES_SPEC_FIELDS, routeShapeHints(obj));
|
|
2623
2470
|
if (!hasOwn(obj, "replace")) {
|
|
2471
|
+
// local-check: sdk_normalization — the route lint walks routes.replace
|
|
2624
2472
|
throw invalidRouteSpec("ReleaseSpec.routes must be null or { replace: [{ pattern, target: { type: \"function\", name } | { type: \"static\", file } }] }. Path-keyed route maps are not supported.", "routes");
|
|
2625
2473
|
}
|
|
2626
2474
|
if (!Array.isArray(obj.replace)) {
|
|
2475
|
+
// local-check: sdk_normalization — the route lint walks routes.replace
|
|
2627
2476
|
throw invalidRouteSpec("ReleaseSpec.routes.replace must be an array of route entries", "routes.replace");
|
|
2628
2477
|
}
|
|
2629
2478
|
for (const [index, route] of obj.replace.entries()) {
|
|
@@ -2642,190 +2491,18 @@ function routeShapeHints(obj) {
|
|
|
2642
2491
|
function validateRouteEntry(route, resource) {
|
|
2643
2492
|
const entry = requireObject(route, resource);
|
|
2644
2493
|
validateKnownFields(entry, resource, ROUTE_ENTRY_FIELDS);
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
}
|
|
2648
|
-
if (
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
throw invalidRouteSpec(`Unsupported route method ${JSON.stringify(method)} at ReleaseSpec.${resource}.methods. Supported methods: ${ROUTE_HTTP_METHODS.join(", ")}`, `${resource}.methods`);
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
const seen = new Set();
|
|
2661
|
-
for (const method of entry.methods) {
|
|
2662
|
-
const methodString = method;
|
|
2663
|
-
if (seen.has(methodString)) {
|
|
2664
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.methods contains duplicate method ${JSON.stringify(method)}`, `${resource}.methods`);
|
|
2665
|
-
}
|
|
2666
|
-
seen.add(methodString);
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
const targetType = validateRouteTarget(entry.target, `${resource}.target`);
|
|
2670
|
-
validateRoutePricing(entry.pricing, resource, targetType);
|
|
2671
|
-
if (targetType === "static") {
|
|
2672
|
-
validateStaticRouteEntry(entry, resource);
|
|
2673
|
-
}
|
|
2674
|
-
if (targetType === "repo") {
|
|
2675
|
-
validateRepoRouteEntry(entry, resource);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
/** Shape only: the gateway checks that the repo exists and the path is valid. */
|
|
2679
|
-
function validateRepoRouteEntry(entry, resource) {
|
|
2680
|
-
if (entry.methods === undefined)
|
|
2681
|
-
return;
|
|
2682
|
-
const methodSet = new Set(entry.methods);
|
|
2683
|
-
const valid = methodSet.has("GET") && (methodSet.size === 1 || (methodSet.size === 2 && methodSet.has("HEAD")));
|
|
2684
|
-
if (!valid) {
|
|
2685
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.methods for repo route targets must be ["GET"] or ["GET", "HEAD"] (or omitted); a repo target serves GET and HEAD only`, `${resource}.methods`);
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
function validateRoutePricing(pricing, resource, targetType) {
|
|
2689
|
-
if (pricing === undefined)
|
|
2690
|
-
return;
|
|
2691
|
-
if (targetType !== "function") {
|
|
2692
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing is only supported on function route targets`, `${resource}.pricing`);
|
|
2693
|
-
}
|
|
2694
|
-
const obj = requireObject(pricing, `${resource}.pricing`);
|
|
2695
|
-
validateKnownFields(obj, `${resource}.pricing`, ROUTE_PRICING_FIELDS);
|
|
2696
|
-
if (obj.mode !== "always") {
|
|
2697
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.mode must be "always"`, `${resource}.pricing.mode`);
|
|
2698
|
-
}
|
|
2699
|
-
if (typeof obj.amount_usd_micros !== "number" || !Number.isSafeInteger(obj.amount_usd_micros) || obj.amount_usd_micros <= 0) {
|
|
2700
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.amount_usd_micros must be a positive safe JSON integer`, `${resource}.pricing.amount_usd_micros`);
|
|
2701
|
-
}
|
|
2702
|
-
if (obj.pay_to !== "org_default_payout") {
|
|
2703
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.pay_to must be "org_default_payout"`, `${resource}.pricing.pay_to`);
|
|
2704
|
-
}
|
|
2705
|
-
if (obj.receipt !== undefined &&
|
|
2706
|
-
obj.receipt !== "on_fulfillment") {
|
|
2707
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.receipt must be "on_fulfillment"`, `${resource}.pricing.receipt`);
|
|
2708
|
-
}
|
|
2709
|
-
if (obj.discovery !== undefined) {
|
|
2710
|
-
// Shape only: the gateway owns the Bazaar limits and names the exact field
|
|
2711
|
-
// it refuses (description length, tags, icon_url, schema refs, size).
|
|
2712
|
-
const discovery = requireObject(obj.discovery, `${resource}.pricing.discovery`);
|
|
2713
|
-
if (typeof discovery.description !== "string" || discovery.description.trim() === "") {
|
|
2714
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.discovery.description must be a non-empty string`, `${resource}.pricing.discovery.description`);
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
const networks = validateRoutePricingNetworks(obj.networks, resource);
|
|
2718
|
-
const hasLightning = networks.some((network) => network === "lightning" || network === "lightning-testnet");
|
|
2719
|
-
if (obj.amount_msat !== undefined) {
|
|
2720
|
-
if (typeof obj.amount_msat !== "number" || !Number.isSafeInteger(obj.amount_msat) || obj.amount_msat <= 0) {
|
|
2721
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.amount_msat must be a positive safe JSON integer`, `${resource}.pricing.amount_msat`);
|
|
2722
|
-
}
|
|
2723
|
-
if (!hasLightning) {
|
|
2724
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.amount_msat requires a Lightning network ("lightning" or "lightning-testnet") in pricing.networks`, `${resource}.pricing.amount_msat`);
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
if (obj.receipt === "on_fulfillment" && hasLightning) {
|
|
2728
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.receipt covers EVM entries only; merchant evidence is not issued for Lightning networks`, `${resource}.pricing.receipt`);
|
|
2729
|
-
}
|
|
2730
|
-
if (obj.receipt === "on_fulfillment" && networks.some((network) => network === "tempo" || network === "tempo-testnet")) {
|
|
2731
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.receipt covers x402 EVM entries only; merchant evidence is not issued for Tempo`, `${resource}.pricing.receipt`);
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
/** The declared pricing networks, validated; `["mainnet"]` when omitted. */
|
|
2735
|
-
function validateRoutePricingNetworks(networks, resource) {
|
|
2736
|
-
if (networks === undefined)
|
|
2737
|
-
return ["mainnet"];
|
|
2738
|
-
if (!Array.isArray(networks)) {
|
|
2739
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.networks must be an array`, `${resource}.pricing.networks`);
|
|
2740
|
-
}
|
|
2741
|
-
if (networks.length === 0) {
|
|
2742
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.networks must not be empty; omit networks for production mainnet only`, `${resource}.pricing.networks`);
|
|
2743
|
-
}
|
|
2744
|
-
const seen = new Set();
|
|
2745
|
-
for (const network of networks) {
|
|
2746
|
-
if (typeof network !== "string" || !ROUTE_PRICING_NETWORK_SET.has(network)) {
|
|
2747
|
-
throw invalidRouteSpec(`Unsupported route pricing network ${JSON.stringify(network)} at ReleaseSpec.${resource}.pricing.networks. Supported networks: ${ROUTE_PRICING_NETWORKS.join(", ")}`, `${resource}.pricing.networks`);
|
|
2748
|
-
}
|
|
2749
|
-
if (seen.has(network)) {
|
|
2750
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pricing.networks contains duplicate network ${JSON.stringify(network)}`, `${resource}.pricing.networks`);
|
|
2751
|
-
}
|
|
2752
|
-
seen.add(network);
|
|
2753
|
-
}
|
|
2754
|
-
return [...seen];
|
|
2755
|
-
}
|
|
2756
|
-
function validateRouteTarget(target, resource) {
|
|
2757
|
-
const obj = requireObject(target, resource);
|
|
2758
|
-
if ((hasOwn(obj, "function") || hasOwn(obj, "static")) && !hasOwn(obj, "type")) {
|
|
2759
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource} uses an unsupported target shorthand. Use { type: "function", name: "api" } or { type: "static", file: "events.html" }.`, resource);
|
|
2760
|
-
}
|
|
2761
|
-
if (obj.type === undefined) {
|
|
2762
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.type is required; use "function" or "static"`, `${resource}.type`);
|
|
2763
|
-
}
|
|
2764
|
-
if (obj.type === "function") {
|
|
2765
|
-
validateKnownFields(obj, resource, FUNCTION_ROUTE_TARGET_FIELDS);
|
|
2766
|
-
if (typeof obj.name !== "string" || obj.name.length === 0) {
|
|
2767
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.name is required for function route targets`, `${resource}.name`);
|
|
2768
|
-
}
|
|
2769
|
-
return "function";
|
|
2770
|
-
}
|
|
2771
|
-
if (obj.type === "static") {
|
|
2772
|
-
validateKnownFields(obj, resource, STATIC_ROUTE_TARGET_FIELDS);
|
|
2773
|
-
if (typeof obj.file !== "string" || obj.file.length === 0) {
|
|
2774
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.file is required for static route targets`, `${resource}.file`);
|
|
2775
|
-
}
|
|
2776
|
-
validateStaticTargetFile(obj.file, `${resource}.file`);
|
|
2777
|
-
return "static";
|
|
2778
|
-
}
|
|
2779
|
-
if (obj.type === "repo") {
|
|
2780
|
-
validateKnownFields(obj, resource, REPO_ROUTE_TARGET_FIELDS);
|
|
2781
|
-
if (typeof obj.repo !== "string" || obj.repo.length === 0) {
|
|
2782
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.repo is required for repo route targets (an app repo name, e.g. "default")`, `${resource}.repo`);
|
|
2783
|
-
}
|
|
2784
|
-
if (obj.path !== undefined && typeof obj.path !== "string") {
|
|
2785
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.path must be a string`, `${resource}.path`);
|
|
2786
|
-
}
|
|
2787
|
-
if (obj.requireAuth !== undefined && typeof obj.requireAuth !== "boolean") {
|
|
2788
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.requireAuth must be a boolean`, `${resource}.requireAuth`);
|
|
2789
|
-
}
|
|
2790
|
-
if (obj.requireRole !== undefined && obj.requireRole !== null) {
|
|
2791
|
-
requireObject(obj.requireRole, `${resource}.requireRole`);
|
|
2792
|
-
}
|
|
2793
|
-
return "repo";
|
|
2794
|
-
}
|
|
2795
|
-
throw invalidRouteSpec(`Unsupported route target type ${JSON.stringify(obj.type)} at ReleaseSpec.${resource}.type; route targets support "function", "static" and "repo"`, `${resource}.type`);
|
|
2796
|
-
}
|
|
2797
|
-
function validateStaticRouteEntry(entry, resource) {
|
|
2798
|
-
const pattern = entry.pattern;
|
|
2799
|
-
if (pattern.includes("*")) {
|
|
2800
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.pattern uses a static route target, so it must be an exact path pattern (wildcard patterns such as /docs/* are not supported for static targets)`, `${resource}.pattern`);
|
|
2801
|
-
}
|
|
2802
|
-
if (entry.methods === undefined) {
|
|
2803
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.methods is required for static route targets; use ["GET"] or ["GET", "HEAD"]`, `${resource}.methods`);
|
|
2804
|
-
}
|
|
2805
|
-
const methods = entry.methods;
|
|
2806
|
-
const methodSet = new Set(methods);
|
|
2807
|
-
const valid = methodSet.has("GET") &&
|
|
2808
|
-
(methodSet.size === 1 || (methodSet.size === 2 && methodSet.has("HEAD")));
|
|
2809
|
-
if (!valid) {
|
|
2810
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource}.methods for static route targets must be ["GET"] or ["GET", "HEAD"]; either form materializes effective GET plus HEAD`, `${resource}.methods`);
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
function validateStaticTargetFile(file, resource) {
|
|
2814
|
-
const invalid = file.startsWith("/") ||
|
|
2815
|
-
file.includes("?") ||
|
|
2816
|
-
file.includes("#") ||
|
|
2817
|
-
file.includes("\\") ||
|
|
2818
|
-
file.endsWith("/") ||
|
|
2819
|
-
file.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
|
|
2820
|
-
if (invalid) {
|
|
2821
|
-
throw invalidRouteSpec(`ReleaseSpec.${resource} must be a relative materialized static-site file path without leading slash, query, fragment, traversal, empty segments, backslashes, or directory shorthand`, resource);
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
function validateChecksSpec(checks) {
|
|
2825
|
-
if (checks === undefined)
|
|
2826
|
-
return;
|
|
2827
|
-
if (!Array.isArray(checks)) {
|
|
2828
|
-
throw invalidSpec("ReleaseSpec.checks must be an array", "checks");
|
|
2494
|
+
// pattern, methods, target values and pricing values are the gateway's
|
|
2495
|
+
// rules (INVALID_SPEC at plan); the route is carried as written.
|
|
2496
|
+
const target = requireObject(entry.target, `${resource}.target`);
|
|
2497
|
+
if (target.type === "function")
|
|
2498
|
+
validateKnownFields(target, `${resource}.target`, FUNCTION_ROUTE_TARGET_FIELDS);
|
|
2499
|
+
else if (target.type === "static")
|
|
2500
|
+
validateKnownFields(target, `${resource}.target`, STATIC_ROUTE_TARGET_FIELDS);
|
|
2501
|
+
else if (target.type === "repo")
|
|
2502
|
+
validateKnownFields(target, `${resource}.target`, REPO_ROUTE_TARGET_FIELDS);
|
|
2503
|
+
if (entry.pricing !== undefined) {
|
|
2504
|
+
const pricing = requireObject(entry.pricing, `${resource}.pricing`);
|
|
2505
|
+
validateKnownFields(pricing, `${resource}.pricing`, ROUTE_PRICING_FIELDS);
|
|
2829
2506
|
}
|
|
2830
2507
|
}
|
|
2831
2508
|
function validateI18nSpec(i18n) {
|
|
@@ -2839,67 +2516,8 @@ function validateI18nSpec(i18n) {
|
|
|
2839
2516
|
default: "Use `defaultLocale` in i18n.",
|
|
2840
2517
|
locale: "Use `locales` (plural array) in i18n.",
|
|
2841
2518
|
});
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
}
|
|
2845
|
-
if (!I18N_LOCALE_TAG_REGEX.test(obj.defaultLocale)) {
|
|
2846
|
-
throw invalidSpec(`ReleaseSpec.i18n.defaultLocale ${JSON.stringify(obj.defaultLocale)} must match /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/`, "i18n.defaultLocale");
|
|
2847
|
-
}
|
|
2848
|
-
if (!Array.isArray(obj.locales)) {
|
|
2849
|
-
throw invalidSpec("ReleaseSpec.i18n.locales is required and must be a non-empty array of locale tags", "i18n.locales");
|
|
2850
|
-
}
|
|
2851
|
-
if (obj.locales.length === 0) {
|
|
2852
|
-
throw invalidSpec("ReleaseSpec.i18n.locales must contain at least one entry", "i18n.locales");
|
|
2853
|
-
}
|
|
2854
|
-
if (obj.locales.length > I18N_MAX_LOCALES) {
|
|
2855
|
-
throw invalidSpec(`ReleaseSpec.i18n.locales accepts at most ${I18N_MAX_LOCALES} entries (got ${obj.locales.length})`, "i18n.locales");
|
|
2856
|
-
}
|
|
2857
|
-
const seenLocales = new Set();
|
|
2858
|
-
for (let i = 0; i < obj.locales.length; i++) {
|
|
2859
|
-
const tag = obj.locales[i];
|
|
2860
|
-
const path = `i18n.locales.${i}`;
|
|
2861
|
-
if (typeof tag !== "string" || tag.length === 0) {
|
|
2862
|
-
throw invalidSpec(`ReleaseSpec.${path} must be a non-empty string`, path);
|
|
2863
|
-
}
|
|
2864
|
-
if (!I18N_LOCALE_TAG_REGEX.test(tag)) {
|
|
2865
|
-
throw invalidSpec(`ReleaseSpec.${path} (${JSON.stringify(tag)}) must match /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/`, path);
|
|
2866
|
-
}
|
|
2867
|
-
if (seenLocales.has(tag)) {
|
|
2868
|
-
throw invalidSpec(`ReleaseSpec.i18n.locales contains duplicate entry ${JSON.stringify(tag)}`, path);
|
|
2869
|
-
}
|
|
2870
|
-
seenLocales.add(tag);
|
|
2871
|
-
}
|
|
2872
|
-
if (!seenLocales.has(obj.defaultLocale)) {
|
|
2873
|
-
throw invalidSpec(`ReleaseSpec.i18n.defaultLocale (${JSON.stringify(obj.defaultLocale)}) must be byte-identical to one entry in i18n.locales`, "i18n.defaultLocale");
|
|
2874
|
-
}
|
|
2875
|
-
if (obj.detect !== undefined) {
|
|
2876
|
-
if (!Array.isArray(obj.detect)) {
|
|
2877
|
-
throw invalidSpec("ReleaseSpec.i18n.detect must be an array of detect sources", "i18n.detect");
|
|
2878
|
-
}
|
|
2879
|
-
if (obj.detect.length > I18N_MAX_DETECT_SOURCES) {
|
|
2880
|
-
throw invalidSpec(`ReleaseSpec.i18n.detect accepts at most ${I18N_MAX_DETECT_SOURCES} entries (got ${obj.detect.length})`, "i18n.detect");
|
|
2881
|
-
}
|
|
2882
|
-
for (let i = 0; i < obj.detect.length; i++) {
|
|
2883
|
-
const source = obj.detect[i];
|
|
2884
|
-
const path = `i18n.detect.${i}`;
|
|
2885
|
-
if (typeof source !== "string" || source.length === 0) {
|
|
2886
|
-
throw invalidSpec(`ReleaseSpec.${path} must be a non-empty string ("accept-language" or "cookie:<name>")`, path);
|
|
2887
|
-
}
|
|
2888
|
-
if (source === "accept-language")
|
|
2889
|
-
continue;
|
|
2890
|
-
if (source.startsWith("cookie:")) {
|
|
2891
|
-
const cookieName = source.slice("cookie:".length);
|
|
2892
|
-
if (cookieName.length === 0) {
|
|
2893
|
-
throw invalidSpec(`ReleaseSpec.${path} cookie source is missing the cookie name (use "cookie:<name>")`, path);
|
|
2894
|
-
}
|
|
2895
|
-
if (!I18N_COOKIE_NAME_REGEX.test(cookieName)) {
|
|
2896
|
-
throw invalidSpec(`ReleaseSpec.${path} cookie name ${JSON.stringify(cookieName)} must match the RFC 6265 cookie-name grammar /^[!#$%&'*+\\-.^_\`|~0-9A-Za-z]+$/`, path);
|
|
2897
|
-
}
|
|
2898
|
-
continue;
|
|
2899
|
-
}
|
|
2900
|
-
throw invalidSpec(`ReleaseSpec.${path} must be "accept-language" or "cookie:<name>" (got ${JSON.stringify(source)})`, path);
|
|
2901
|
-
}
|
|
2902
|
-
}
|
|
2519
|
+
// defaultLocale, locales and detect values are the gateway's rules
|
|
2520
|
+
// (INVALID_SPEC at plan); the slice is carried as written.
|
|
2903
2521
|
}
|
|
2904
2522
|
function validateKnownFields(obj, resource, allowed, hints = {}) {
|
|
2905
2523
|
for (const key of Object.keys(obj)) {
|
|
@@ -2907,30 +2525,17 @@ function validateKnownFields(obj, resource, allowed, hints = {}) {
|
|
|
2907
2525
|
continue;
|
|
2908
2526
|
const field = resource === "spec" ? `spec.${key}` : `${resource}.${key}`;
|
|
2909
2527
|
const hint = hints[key] ? ` ${hints[key]}` : "";
|
|
2528
|
+
// local-check: sdk_normalization — normalization would silently drop unknown fields
|
|
2910
2529
|
throw invalidSpec(`Unknown ReleaseSpec field: ${field}.${hint}`, field);
|
|
2911
2530
|
}
|
|
2912
2531
|
}
|
|
2913
2532
|
function requireObject(value, resource) {
|
|
2914
2533
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2534
|
+
// local-check: sdk_normalization — the SDK walks this object while normalizing
|
|
2915
2535
|
throw invalidSpec(`ReleaseSpec.${resource} must be an object`, resource);
|
|
2916
2536
|
}
|
|
2917
2537
|
return value;
|
|
2918
2538
|
}
|
|
2919
|
-
function validateStringArray(value, resource) {
|
|
2920
|
-
if (!Array.isArray(value)) {
|
|
2921
|
-
throw invalidSpec(`ReleaseSpec.${resource} must be an array`, resource);
|
|
2922
|
-
}
|
|
2923
|
-
if (value.some((entry) => typeof entry !== "string")) {
|
|
2924
|
-
throw invalidSpec(`ReleaseSpec.${resource} entries must be strings`, resource);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
function validateFunctionConfigInteger(value, resource) {
|
|
2928
|
-
if (value === undefined)
|
|
2929
|
-
return;
|
|
2930
|
-
if (!Number.isSafeInteger(value) || value < 1) {
|
|
2931
|
-
throw invalidSpec(`ReleaseSpec.${resource} must be a positive safe JSON integer`, resource);
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
2539
|
function hasDeployableContent(spec) {
|
|
2935
2540
|
return (hasDatabaseContent(spec.database) ||
|
|
2936
2541
|
hasSiteContent(spec.site) ||
|
|
@@ -3100,6 +2705,7 @@ function requirePersistedPlan(plan, context) {
|
|
|
3100
2705
|
if (plan.plan_id && plan.operation_id) {
|
|
3101
2706
|
return { planId: plan.plan_id, operationId: plan.operation_id };
|
|
3102
2707
|
}
|
|
2708
|
+
// local-check: protects_local — a dry-run plan has no rows to upload or commit
|
|
3103
2709
|
throw new Run402DeployError("Dry-run plan responses cannot be uploaded or committed because they do not create plan or operation rows.", {
|
|
3104
2710
|
code: "DRY_RUN_PLAN_NOT_COMMITTABLE",
|
|
3105
2711
|
phase: "plan",
|
|
@@ -3111,6 +2717,7 @@ function requirePersistedPlan(plan, context) {
|
|
|
3111
2717
|
function requirePlanId(plan, context) {
|
|
3112
2718
|
if (plan.plan_id)
|
|
3113
2719
|
return plan.plan_id;
|
|
2720
|
+
// local-check: sdk_normalization — plan response carries no plan_id
|
|
3114
2721
|
throw new Run402DeployError("Plan response cannot be committed because it does not include plan_id.", {
|
|
3115
2722
|
code: "DRY_RUN_PLAN_NOT_COMMITTABLE",
|
|
3116
2723
|
phase: "plan",
|
|
@@ -3130,6 +2737,7 @@ function isCoreCommitResponse(commit) {
|
|
|
3130
2737
|
function requireCloudCommitResponse(commit, context) {
|
|
3131
2738
|
if (!isCoreCommitResponse(commit))
|
|
3132
2739
|
return commit;
|
|
2740
|
+
// local-check: sdk_normalization — Core commit response on the Cloud polling path
|
|
3133
2741
|
throw new Run402DeployError("Core commit response reached a Cloud operation-polling path.", {
|
|
3134
2742
|
code: "INTERNAL_ERROR",
|
|
3135
2743
|
phase: "commit",
|
|
@@ -3139,6 +2747,7 @@ function requireCloudCommitResponse(commit, context) {
|
|
|
3139
2747
|
}
|
|
3140
2748
|
async function coreDeployResult(client, commit, diff, warnings, emit, projectId, sliceKinds = []) {
|
|
3141
2749
|
if (commit.status === "deferred") {
|
|
2750
|
+
// local-check: sdk_normalization — Core commit response was deferred
|
|
3142
2751
|
throw new Run402DeployError(commit.deferred_reason ?? "Core deploy commit deferred.", {
|
|
3143
2752
|
code: "INTERNAL_ERROR",
|
|
3144
2753
|
phase: commit.deferred_phase ?? "commit",
|
|
@@ -3208,9 +2817,9 @@ function clientRoutePlanWarnings(spec) {
|
|
|
3208
2817
|
return [];
|
|
3209
2818
|
const affected = routes.replace
|
|
3210
2819
|
.filter((route) => {
|
|
3211
|
-
if (route.target
|
|
2820
|
+
if (route.target?.type !== "function")
|
|
3212
2821
|
return false;
|
|
3213
|
-
if (!isFinalWildcardRoutePattern(route.pattern))
|
|
2822
|
+
if (typeof route.pattern !== "string" || !isFinalWildcardRoutePattern(route.pattern))
|
|
3214
2823
|
return false;
|
|
3215
2824
|
if (!route.methods)
|
|
3216
2825
|
return false;
|
|
@@ -3247,6 +2856,7 @@ function normalizeAllowWarningCodes(value) {
|
|
|
3247
2856
|
if (value === undefined)
|
|
3248
2857
|
return new Set();
|
|
3249
2858
|
if (!Array.isArray(value)) {
|
|
2859
|
+
// local-check: argument — allowWarningCodes drives the SDK's own warning gate
|
|
3250
2860
|
throw new Run402DeployError("ApplyOptions.allowWarningCodes must be an array of warning-code strings", {
|
|
3251
2861
|
code: "INVALID_SPEC",
|
|
3252
2862
|
phase: "validate",
|
|
@@ -3258,6 +2868,7 @@ function normalizeAllowWarningCodes(value) {
|
|
|
3258
2868
|
const codes = new Set();
|
|
3259
2869
|
for (const code of value) {
|
|
3260
2870
|
if (typeof code !== "string" || code.length === 0) {
|
|
2871
|
+
// local-check: argument — allowWarningCodes drives the SDK's own warning gate
|
|
3261
2872
|
throw new Run402DeployError("ApplyOptions.allowWarningCodes entries must be non-empty strings", {
|
|
3262
2873
|
code: "INVALID_SPEC",
|
|
3263
2874
|
phase: "validate",
|
|
@@ -3282,6 +2893,7 @@ function abortOnConfirmationWarnings(plan, opts, allowWarningCodes) {
|
|
|
3282
2893
|
const missing = unacknowledged.find((w) => w.code === "MISSING_REQUIRED_SECRET");
|
|
3283
2894
|
const first = missing ?? unacknowledged[0];
|
|
3284
2895
|
const unacknowledgedCodes = Array.from(new Set(unacknowledged.map((w) => w.code))).sort();
|
|
2896
|
+
// local-check: protects_local — stops before upload and commit until the caller acknowledges
|
|
3285
2897
|
throw new Run402DeployError(`Deploy plan requires review of ${first.code}. Review the affected access or resources, then acknowledge only the reviewed warning codes.`, {
|
|
3286
2898
|
code: first.code || "DEPLOY_WARNING_REQUIRES_CONFIRMATION",
|
|
3287
2899
|
phase: "plan",
|
|
@@ -3302,44 +2914,21 @@ function validateSecretsSpec(secrets) {
|
|
|
3302
2914
|
if (secrets === undefined)
|
|
3303
2915
|
return;
|
|
3304
2916
|
if (!secrets || typeof secrets !== "object" || Array.isArray(secrets)) {
|
|
2917
|
+
// local-check: sdk_normalization — the SDK walks the secrets object
|
|
3305
2918
|
throw invalidSecretSpec("ReleaseSpec.secrets must be an object", "secrets");
|
|
3306
2919
|
}
|
|
3307
2920
|
const obj = secrets;
|
|
3308
2921
|
const allowed = new Set(["require", "delete"]);
|
|
3309
2922
|
for (const key of Object.keys(obj)) {
|
|
3310
2923
|
if (!allowed.has(key)) {
|
|
2924
|
+
// local-check: sdk_normalization — unknown secrets fields, with the retired set/replace_all hint
|
|
3311
2925
|
throw invalidSecretSpec(key === "set" || key === "replace_all"
|
|
3312
2926
|
? `ReleaseSpec.secrets.${key} is no longer supported; set values with the secrets API, then use secrets.require[] in the deploy spec.`
|
|
3313
2927
|
: `Unknown ReleaseSpec.secrets field: ${key}`, `secrets.${key}`);
|
|
3314
2928
|
}
|
|
3315
2929
|
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
const deleteSet = new Set(deleted);
|
|
3319
|
-
const conflict = required.find((key) => deleteSet.has(key));
|
|
3320
|
-
if (conflict) {
|
|
3321
|
-
throw invalidSecretSpec(`Secret key ${conflict} cannot appear in both secrets.require and secrets.delete`, "secrets");
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
function validateSecretKeyArray(value, resource) {
|
|
3325
|
-
if (value === undefined)
|
|
3326
|
-
return [];
|
|
3327
|
-
if (!Array.isArray(value)) {
|
|
3328
|
-
throw invalidSecretSpec(`${resource} must be an array of secret keys`, resource);
|
|
3329
|
-
}
|
|
3330
|
-
const seen = new Set();
|
|
3331
|
-
const out = [];
|
|
3332
|
-
for (const key of value) {
|
|
3333
|
-
if (typeof key !== "string" || !SECRET_KEY_RE.test(key)) {
|
|
3334
|
-
throw invalidSecretSpec(`${resource} entries must match ${SECRET_KEY_RE.source}`, resource);
|
|
3335
|
-
}
|
|
3336
|
-
if (seen.has(key)) {
|
|
3337
|
-
throw invalidSecretSpec(`${resource} contains duplicate key ${key}`, resource);
|
|
3338
|
-
}
|
|
3339
|
-
seen.add(key);
|
|
3340
|
-
out.push(key);
|
|
3341
|
-
}
|
|
3342
|
-
return out;
|
|
2930
|
+
// Key names, array shapes, a key listed twice, and a key in both require
|
|
2931
|
+
// and delete are the gateway's rules (INVALID_SPEC at plan).
|
|
3343
2932
|
}
|
|
3344
2933
|
function invalidSecretSpec(message, resource) {
|
|
3345
2934
|
return new Run402DeployError(message, {
|
|
@@ -3411,7 +3000,6 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
|
|
|
3411
3000
|
}
|
|
3412
3001
|
if (spec.database.migrations && spec.database.migrations.length > 0) {
|
|
3413
3002
|
db.migrations = await Promise.all(spec.database.migrations.map(async (m) => normalizeMigration(client, spec.project_id, m, rememberRelease, opts)));
|
|
3414
|
-
assertUniqueMigrationIds(db.migrations);
|
|
3415
3003
|
}
|
|
3416
3004
|
normalized.database = db;
|
|
3417
3005
|
}
|
|
@@ -3428,7 +3016,6 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
|
|
|
3428
3016
|
if (spec.functions.patch.delete)
|
|
3429
3017
|
fns.patch.delete = spec.functions.patch.delete;
|
|
3430
3018
|
}
|
|
3431
|
-
assertUniqueToolNames(fns);
|
|
3432
3019
|
normalized.functions = fns;
|
|
3433
3020
|
}
|
|
3434
3021
|
if (spec.site) {
|
|
@@ -3445,37 +3032,27 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
|
|
|
3445
3032
|
const noindex = "noindex" in spec.site && spec.site.noindex !== undefined
|
|
3446
3033
|
? { noindex: spec.site.noindex }
|
|
3447
3034
|
: {};
|
|
3448
|
-
|
|
3449
|
-
|
|
3035
|
+
const rawSite = spec.site;
|
|
3036
|
+
const files = {};
|
|
3037
|
+
if (rawSite.replace) {
|
|
3038
|
+
files.replace = await normalizeFileSet(rawSite.replace, rememberRelease);
|
|
3450
3039
|
// Re-check post-expansion so `dir("dist")` (a LocalDirRef whose keys are
|
|
3451
3040
|
// unknown at validateSpec time) is caught too, not just literal FileSets.
|
|
3452
|
-
assertNoAstroAdapterTreeInSite(Object.keys(
|
|
3453
|
-
normalized.site = {
|
|
3454
|
-
replace: map,
|
|
3455
|
-
...(publicPaths ? { public_paths: publicPaths } : {}),
|
|
3456
|
-
...embedding,
|
|
3457
|
-
...signInPath,
|
|
3458
|
-
...noindex,
|
|
3459
|
-
};
|
|
3041
|
+
assertNoAstroAdapterTreeInSite(Object.keys(files.replace), "site.replace");
|
|
3460
3042
|
}
|
|
3461
|
-
|
|
3043
|
+
if (rawSite.patch) {
|
|
3462
3044
|
const patch = {};
|
|
3463
|
-
if (
|
|
3464
|
-
patch.put = await normalizeFileSet(
|
|
3045
|
+
if (rawSite.patch.put) {
|
|
3046
|
+
patch.put = await normalizeFileSet(rawSite.patch.put, rememberRelease);
|
|
3465
3047
|
assertNoAstroAdapterTreeInSite(Object.keys(patch.put), "site.patch.put");
|
|
3466
3048
|
}
|
|
3467
|
-
if (
|
|
3468
|
-
patch.delete =
|
|
3469
|
-
|
|
3470
|
-
patch,
|
|
3471
|
-
...(publicPaths ? { public_paths: publicPaths } : {}),
|
|
3472
|
-
...embedding,
|
|
3473
|
-
...signInPath,
|
|
3474
|
-
...noindex,
|
|
3475
|
-
};
|
|
3049
|
+
if (rawSite.patch.delete !== undefined)
|
|
3050
|
+
patch.delete = rawSite.patch.delete;
|
|
3051
|
+
files.patch = patch;
|
|
3476
3052
|
}
|
|
3477
|
-
|
|
3053
|
+
if (files.replace || files.patch || publicPaths || "embedding" in embedding || "sign_in_path" in signInPath || "noindex" in noindex) {
|
|
3478
3054
|
normalized.site = {
|
|
3055
|
+
...files,
|
|
3479
3056
|
...(publicPaths ? { public_paths: publicPaths } : {}),
|
|
3480
3057
|
...embedding,
|
|
3481
3058
|
...signInPath,
|
|
@@ -3595,31 +3172,6 @@ function fsPathOf(source) {
|
|
|
3595
3172
|
* refused here, naming both functions; the gateway checks the functions the
|
|
3596
3173
|
* spec does not name.
|
|
3597
3174
|
*/
|
|
3598
|
-
function assertUniqueToolNames(fns) {
|
|
3599
|
-
const groups = [];
|
|
3600
|
-
const collect = (map) => {
|
|
3601
|
-
for (const [name, fn] of Object.entries(map ?? {})) {
|
|
3602
|
-
if (fn.tools && fn.tools.length > 0)
|
|
3603
|
-
groups.push({ owner: name, tools: fn.tools, defaultName: name });
|
|
3604
|
-
}
|
|
3605
|
-
};
|
|
3606
|
-
collect(fns.replace);
|
|
3607
|
-
collect(fns.patch?.set);
|
|
3608
|
-
const duplicate = findDuplicateToolName(groups);
|
|
3609
|
-
if (!duplicate)
|
|
3610
|
-
return;
|
|
3611
|
-
const [first, second] = duplicate.owners;
|
|
3612
|
-
const where = first === second
|
|
3613
|
-
? `function \`${first}\` declares it twice`
|
|
3614
|
-
: `functions \`${first}\` and \`${second}\` both declare it`;
|
|
3615
|
-
throw toolDeclarationError({
|
|
3616
|
-
code: "MCP_TOOL_NAME_DUPLICATE",
|
|
3617
|
-
message: `Two tools are named \`${duplicate.name}\`: ${where}. A tool name is unique in a release; rename one.`,
|
|
3618
|
-
file: null,
|
|
3619
|
-
field_path: `functions.${second}.tools`,
|
|
3620
|
-
tool: duplicate.name,
|
|
3621
|
-
}, { functionName: second, functions: [...new Set(duplicate.owners)] });
|
|
3622
|
-
}
|
|
3623
3175
|
function normalizeFunctionTriggers(triggers) {
|
|
3624
3176
|
const runOf = (run) => ({
|
|
3625
3177
|
...(run.event_type !== undefined ? { event_type: run.event_type } : {}),
|
|
@@ -3629,39 +3181,27 @@ function normalizeFunctionTriggers(triggers) {
|
|
|
3629
3181
|
? { expires_after_seconds: run.expires_after_seconds }
|
|
3630
3182
|
: {}),
|
|
3631
3183
|
});
|
|
3184
|
+
// Every field the caller set is carried (the gateway judges which fields a
|
|
3185
|
+
// trigger type takes); only the schedule defaults and the event order are
|
|
3186
|
+
// the SDK's.
|
|
3632
3187
|
return triggers
|
|
3633
3188
|
.map((trigger) => {
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
type: "app_repo",
|
|
3647
|
-
repo: trigger.repo,
|
|
3648
|
-
...(trigger.paths !== undefined ? { paths: [...trigger.paths] } : {}),
|
|
3649
|
-
run: runOf(trigger.run),
|
|
3650
|
-
};
|
|
3189
|
+
const raw = trigger;
|
|
3190
|
+
const out = { ...raw };
|
|
3191
|
+
if (raw.run !== undefined)
|
|
3192
|
+
out.run = runOf(raw.run);
|
|
3193
|
+
if (raw.type === "email" && Array.isArray(raw.events))
|
|
3194
|
+
out.events = [...raw.events].sort();
|
|
3195
|
+
if (raw.type === "app_repo" && Array.isArray(raw.paths))
|
|
3196
|
+
out.paths = [...raw.paths];
|
|
3197
|
+
if (raw.type === "schedule") {
|
|
3198
|
+
out.timezone = raw.timezone ?? "UTC";
|
|
3199
|
+
out.misfire_policy = raw.misfire_policy ?? "skip";
|
|
3200
|
+
out.overlap_policy = raw.overlap_policy ?? "allow";
|
|
3651
3201
|
}
|
|
3652
|
-
|
|
3653
|
-
// (D-scheduled-functions-5): an omitted one is sent omitted.
|
|
3654
|
-
return {
|
|
3655
|
-
...(trigger.id !== undefined ? { id: trigger.id } : {}),
|
|
3656
|
-
type: "schedule",
|
|
3657
|
-
cron: trigger.cron,
|
|
3658
|
-
timezone: trigger.timezone ?? "UTC",
|
|
3659
|
-
misfire_policy: trigger.misfire_policy ?? "skip",
|
|
3660
|
-
overlap_policy: trigger.overlap_policy ?? "allow",
|
|
3661
|
-
...(trigger.run !== undefined ? { run: runOf(trigger.run) } : {}),
|
|
3662
|
-
};
|
|
3202
|
+
return out;
|
|
3663
3203
|
})
|
|
3664
|
-
.sort((a, b) => (a.id ?? "").localeCompare(b.id ?? ""));
|
|
3204
|
+
.sort((a, b) => String(a.id ?? "").localeCompare(String(b.id ?? "")));
|
|
3665
3205
|
}
|
|
3666
3206
|
async function normalizeFileSet(set, remember) {
|
|
3667
3207
|
// `dir(path)` produces a LocalDirRef sentinel that is documented as a
|
|
@@ -3678,6 +3218,7 @@ async function normalizeFileSet(set, remember) {
|
|
|
3678
3218
|
resolved.ref.contentType = guessContentType(path);
|
|
3679
3219
|
}
|
|
3680
3220
|
if (isUtf8StringSource(source) && isKnownBinaryContent(path, resolved.ref.contentType)) {
|
|
3221
|
+
// local-check: protects_local — a string would hash and upload the wrong bytes for binary content
|
|
3681
3222
|
throw binaryContentRequiresBytes(path, resolved.ref.contentType);
|
|
3682
3223
|
}
|
|
3683
3224
|
out[path] = remember(resolved);
|
|
@@ -3699,6 +3240,7 @@ async function expandLocalDirRef(ref) {
|
|
|
3699
3240
|
walker = (await import("../node/files.js"));
|
|
3700
3241
|
}
|
|
3701
3242
|
catch {
|
|
3243
|
+
// local-check: local_state — a local directory source needs a Node runtime
|
|
3702
3244
|
throw new Run402DeployError("site dir() is only supported in Node runtimes (received a LocalDirRef in a non-Node environment)", {
|
|
3703
3245
|
code: "INVALID_SPEC",
|
|
3704
3246
|
resource: "site.replace",
|
|
@@ -3847,11 +3389,13 @@ function isAssetPutEntryInput(entry) {
|
|
|
3847
3389
|
async function normalizeAssetSlice(slice, remember) {
|
|
3848
3390
|
const out = {};
|
|
3849
3391
|
if (slice.put && slice.put.length > 0) {
|
|
3850
|
-
const seenKeys = new Set();
|
|
3851
3392
|
const put = [];
|
|
3852
3393
|
for (let idx = 0; idx < slice.put.length; idx++) {
|
|
3853
3394
|
const entry = slice.put[idx];
|
|
3854
|
-
|
|
3395
|
+
// A duplicate key, or a key both put and deleted, is the gateway's rule
|
|
3396
|
+
// (ASSET_DUPLICATE_KEY_IN_PUT / ASSET_KEY_IN_PUT_AND_DELETE at plan).
|
|
3397
|
+
if (isAssetPutEntryInput(entry) && (!entry.key || typeof entry.key !== "string")) {
|
|
3398
|
+
// local-check: sdk_normalization — the SDK guesses the upload's content type from the key
|
|
3855
3399
|
throw new Run402DeployError(`assets.put[${idx}] missing required \`key\``, {
|
|
3856
3400
|
code: "INVALID_SPEC",
|
|
3857
3401
|
phase: "validate",
|
|
@@ -3861,17 +3405,6 @@ async function normalizeAssetSlice(slice, remember) {
|
|
|
3861
3405
|
context: "validating spec",
|
|
3862
3406
|
});
|
|
3863
3407
|
}
|
|
3864
|
-
if (seenKeys.has(entry.key)) {
|
|
3865
|
-
throw new Run402DeployError(`assets.put contains duplicate key \`${entry.key}\``, {
|
|
3866
|
-
code: "ASSET_DUPLICATE_KEY_IN_PUT",
|
|
3867
|
-
phase: "validate",
|
|
3868
|
-
resource: `assets.put[${idx}]`,
|
|
3869
|
-
retryable: false,
|
|
3870
|
-
fix: { action: "set_field", path: `assets.put[${idx}].key` },
|
|
3871
|
-
context: "validating spec",
|
|
3872
|
-
});
|
|
3873
|
-
}
|
|
3874
|
-
seenKeys.add(entry.key);
|
|
3875
3408
|
// v1.50: validate caller-supplied metadata / EXIF policy on BOTH
|
|
3876
3409
|
// shapes BEFORE any HTTP traffic. Throws LocalError with the
|
|
3877
3410
|
// canonical gateway code (INVALID_ASSET_METADATA / INVALID_EXIF_
|
|
@@ -3893,6 +3426,7 @@ async function normalizeAssetSlice(slice, remember) {
|
|
|
3893
3426
|
const contentType = inputShape.content_type ?? resolved.ref.contentType ?? guessContentType(inputShape.key);
|
|
3894
3427
|
if (isUtf8StringSource(inputShape.source) &&
|
|
3895
3428
|
isKnownBinaryContent(inputShape.key, contentType)) {
|
|
3429
|
+
// local-check: protects_local — a string would hash and upload the wrong bytes for binary content
|
|
3896
3430
|
throw binaryContentRequiresBytes(inputShape.key, contentType, `assets.put[${idx}]`);
|
|
3897
3431
|
}
|
|
3898
3432
|
if (!resolved.ref.contentType) {
|
|
@@ -3933,24 +3467,9 @@ async function normalizeAssetSlice(slice, remember) {
|
|
|
3933
3467
|
}
|
|
3934
3468
|
out.put = put;
|
|
3935
3469
|
}
|
|
3936
|
-
if (slice.delete && slice.delete.length
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
// Cross-slice invariant: a key may not be both `put` and `delete`-d.
|
|
3940
|
-
if (out.put && out.delete) {
|
|
3941
|
-
const putKeys = new Set(out.put.map((e) => e.key));
|
|
3942
|
-
for (const k of out.delete) {
|
|
3943
|
-
if (putKeys.has(k)) {
|
|
3944
|
-
throw new Run402DeployError(`assets.put and assets.delete both reference key \`${k}\``, {
|
|
3945
|
-
code: "ASSET_KEY_IN_PUT_AND_DELETE",
|
|
3946
|
-
phase: "validate",
|
|
3947
|
-
resource: `assets`,
|
|
3948
|
-
retryable: false,
|
|
3949
|
-
fix: { action: "remove_field", path: `assets.delete[\`${k}\`]` },
|
|
3950
|
-
context: "validating spec",
|
|
3951
|
-
});
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3470
|
+
if (slice.delete !== undefined && !(Array.isArray(slice.delete) && slice.delete.length === 0)) {
|
|
3471
|
+
// Carried as written; its shape and keys are the gateway's to judge.
|
|
3472
|
+
out.delete = Array.isArray(slice.delete) ? [...slice.delete] : slice.delete;
|
|
3954
3473
|
}
|
|
3955
3474
|
if (slice.sync) {
|
|
3956
3475
|
out.sync = {
|
|
@@ -3977,6 +3496,7 @@ async function normalizeMigration(client, projectId, m, remember, opts = {}) {
|
|
|
3977
3496
|
const originalId = "id" in m ? m.id : undefined;
|
|
3978
3497
|
const name = "name" in m ? m.name : undefined;
|
|
3979
3498
|
if (!originalId && !name) {
|
|
3499
|
+
// local-check: sdk_normalization — the SDK derives the migration id from id or name
|
|
3980
3500
|
throw new Run402DeployError("MigrationSpec.id or MigrationSpec.name is required", {
|
|
3981
3501
|
code: "INVALID_SPEC",
|
|
3982
3502
|
phase: "validate",
|
|
@@ -4011,6 +3531,7 @@ async function normalizeMigration(client, projectId, m, remember, opts = {}) {
|
|
|
4011
3531
|
checksum = m.checksum ?? sha256;
|
|
4012
3532
|
}
|
|
4013
3533
|
else {
|
|
3534
|
+
// local-check: sdk_normalization — the SDK hashes the migration SQL for its checksum
|
|
4014
3535
|
throw new Run402DeployError(`MigrationSpec ${identityLabel} must include sql or sql_ref`, {
|
|
4015
3536
|
code: "INVALID_SPEC",
|
|
4016
3537
|
phase: "validate",
|
|
@@ -4036,23 +3557,6 @@ async function normalizeMigration(client, projectId, m, remember, opts = {}) {
|
|
|
4036
3557
|
void client;
|
|
4037
3558
|
void projectId;
|
|
4038
3559
|
}
|
|
4039
|
-
function assertUniqueMigrationIds(migrations) {
|
|
4040
|
-
const seen = new Map();
|
|
4041
|
-
for (const [index, migration] of migrations.entries()) {
|
|
4042
|
-
const firstIndex = seen.get(migration.id);
|
|
4043
|
-
if (firstIndex !== undefined) {
|
|
4044
|
-
throw new Run402DeployError(`ReleaseSpec.database.migrations.${index}.id duplicates database.migrations.${firstIndex}.id ${JSON.stringify(migration.id)}`, {
|
|
4045
|
-
code: "INVALID_SPEC",
|
|
4046
|
-
phase: "validate",
|
|
4047
|
-
resource: `database.migrations.${index}.id`,
|
|
4048
|
-
retryable: false,
|
|
4049
|
-
fix: { action: "set_field", path: `database.migrations.${index}.id` },
|
|
4050
|
-
context: "validating spec",
|
|
4051
|
-
});
|
|
4052
|
-
}
|
|
4053
|
-
seen.set(migration.id, index);
|
|
4054
|
-
}
|
|
4055
|
-
}
|
|
4056
3560
|
// ─── Content source resolution ───────────────────────────────────────────────
|
|
4057
3561
|
async function resolveContent(source, label) {
|
|
4058
3562
|
// Pre-resolved ContentRef — pass through, no reader needed (caller is
|
|
@@ -4101,6 +3605,7 @@ async function resolveContent(source, label) {
|
|
|
4101
3605
|
const bytes = await readStreamFully(source);
|
|
4102
3606
|
return makeMemResolved(bytes, undefined, label);
|
|
4103
3607
|
}
|
|
3608
|
+
// local-check: argument — byte source of an unsupported JS type
|
|
4104
3609
|
throw new Run402DeployError(`Unsupported byte source for ${label}`, {
|
|
4105
3610
|
code: "INVALID_SPEC",
|
|
4106
3611
|
resource: label,
|
|
@@ -4124,6 +3629,7 @@ async function resolveFsFile(source, label) {
|
|
|
4124
3629
|
fsMod = (await import("node:fs/promises"));
|
|
4125
3630
|
}
|
|
4126
3631
|
catch {
|
|
3632
|
+
// local-check: local_state — a filesystem source needs a Node runtime
|
|
4127
3633
|
throw new Run402DeployError("FsFileSource is only supported in Node runtimes (received in a non-Node environment)", {
|
|
4128
3634
|
code: "INVALID_SPEC",
|
|
4129
3635
|
resource: label,
|
|
@@ -4154,6 +3660,7 @@ function makeBytesReader(bytes, label, contentType) {
|
|
|
4154
3660
|
}
|
|
4155
3661
|
function makeUnreadableReader(sha256, label) {
|
|
4156
3662
|
const reader = async () => {
|
|
3663
|
+
// local-check: sdk_normalization — a pre-resolved ref the gateway lacks has no local bytes to upload
|
|
4157
3664
|
throw new Run402DeployError(`ContentRef ${sha256.slice(0, 12)}… was passed pre-resolved but the gateway reports it missing — provide bytes inline instead`, {
|
|
4158
3665
|
code: "CONTENT_UPLOAD_FAILED",
|
|
4159
3666
|
resource: label,
|