@neon/config-runtime 1.7.3 → 1.7.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-config.d.ts","names":[],"sources":["../../src/lib/pull-config.ts"],"mappings":";;;UAkBiB,iBAAA;;EAAA,SAAA,EAAA,MAAA;EAmBA;EAAa,QAAA,EAAA,MAAA;EACU;EAA9B,MAAA,CAAA,EAAA,MAAA;EACE;EAOE,OAAA,CAAA,EAAA,MAAA;EAAkB;EAGf,GAAA,CAAA,EArBV,OAqBU;AAAkB;AA6B1B;AAME;AAAa;AAGxB;AAAgC;AACtB;AACC,UApDM,aAAA,CAoDN;EAAR,OAAA,EAnDO,KAmDP,CAAA;IAAO,IAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"pull-config.d.ts","names":[],"sources":["../../src/lib/pull-config.ts"],"mappings":";;;UAkBiB,iBAAA;;EAAA,SAAA,EAAA,MAAA;EAmBA;EAAa,QAAA,EAAA,MAAA;EACU;EAA9B,MAAA,CAAA,EAAA,MAAA;EACE;EAOE,OAAA,CAAA,EAAA,MAAA;EAAkB;EAGf,GAAA,CAAA,EArBV,OAqBU;AAAkB;AA6B1B;AAME;AAAa;AAGxB;AAAgC;AACtB;AACC,UApDM,aAAA,CAoDN;EAAR,OAAA,EAnDO,KAmDP,CAAA;IAAO,IAAA,EAAA,MAAA;IAoIM,MAAA,EAvLwB,iBAuLD;EAAA,CAAA,CAAA;EAC7B,SAAA,EAvLE,KAuLF,CAAA;IACD,IAAA,EAAA,MAAA;IACE,IAAA,EAAA,MAAA;EACA,CAAA,CAAA;EAEA;AACE;AACG;AAMb;AAAkB;;eA7LP;;UAGG,kBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BR;;;;;;YAME;;iBAGW,UAAA,UACZ,oBACP,QAAQ;iBAoIK,uBAAA,UACN,6BACD,8BACE,gCACA;WAEA;aACE;gBACG;;;;;IAMb"}
|
package/dist/lib/pull-config.js
CHANGED
|
@@ -3,18 +3,26 @@ import { ErrorCode, PlatformError, createNeonApiFromOptions } from "@neon/config
|
|
|
3
3
|
async function pullConfig(options) {
|
|
4
4
|
const api = options.api ?? createApiFromOptions(options);
|
|
5
5
|
const projectId = options.projectId;
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const branchId = options.branchId;
|
|
7
|
+
const projectRead = started(() => api.getProject(projectId));
|
|
8
|
+
const listsRead = started(() => Promise.all([started(() => api.listBranches(projectId)), started(() => api.listEndpoints(projectId))]));
|
|
9
|
+
const databasesRead = started(() => api.listBranchDatabases(projectId, branchId));
|
|
10
|
+
const previewRead = started(() => databasesRead.then((databases) => {
|
|
11
|
+
const probeDatabase = pickProbeDatabase(databases);
|
|
12
|
+
return Promise.all([
|
|
13
|
+
started(() => degradeUnavailable(() => api.listBranchBuckets(projectId, branchId), [])),
|
|
14
|
+
started(() => degradeUnavailable(() => api.listBranchFunctions(projectId, branchId), [])),
|
|
15
|
+
started(() => degradeUnavailable(() => api.listCredentials(projectId, branchId), [])),
|
|
16
|
+
started(() => api.getNeonAuth(projectId, branchId)),
|
|
17
|
+
started(() => probeDatabase ? api.getNeonDataApi(projectId, branchId, probeDatabase) : Promise.resolve(null))
|
|
18
|
+
]);
|
|
19
|
+
}));
|
|
20
|
+
const project = await projectRead;
|
|
21
|
+
const [branches, endpoints] = await listsRead;
|
|
22
|
+
const branch = resolveBranch(branchId, branches);
|
|
9
23
|
const endpoint = endpoints.find((ep) => ep.type === "read_write" && ep.branchId === branch.id);
|
|
10
|
-
|
|
11
|
-
const [buckets, functions, credentials, auth, dataApi] = await
|
|
12
|
-
degradeUnavailable(() => api.listBranchBuckets(projectId, branch.id), []),
|
|
13
|
-
degradeUnavailable(() => api.listBranchFunctions(projectId, branch.id), []),
|
|
14
|
-
degradeUnavailable(() => api.listCredentials(projectId, branch.id), []),
|
|
15
|
-
api.getNeonAuth(projectId, branch.id),
|
|
16
|
-
probeDatabase ? api.getNeonDataApi(projectId, branch.id, probeDatabase) : Promise.resolve(null)
|
|
17
|
-
]);
|
|
24
|
+
await databasesRead;
|
|
25
|
+
const [buckets, functions, credentials, auth, dataApi] = await previewRead;
|
|
18
26
|
return buildPulledBranchConfig(project, branch, branches, endpoint, {
|
|
19
27
|
buckets,
|
|
20
28
|
functions,
|
|
@@ -24,6 +32,16 @@ async function pullConfig(options) {
|
|
|
24
32
|
});
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
35
|
+
* Starts a read now and keeps an unread rejection from crashing the process; the caller
|
|
36
|
+
* awaits it (and sees the error) when its turn comes. Also turns a synchronous throw from
|
|
37
|
+
* a custom adapter into a rejection.
|
|
38
|
+
*/
|
|
39
|
+
function started(read) {
|
|
40
|
+
const promise = Promise.resolve().then(read);
|
|
41
|
+
promise.catch(() => void 0);
|
|
42
|
+
return promise;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
27
45
|
* Pick the database to probe for a Data API integration. Data API is enabled per
|
|
28
46
|
* branch + database; for read-back we only need to know whether *any* database has it
|
|
29
47
|
* on, so prefer the conventional default (`neondb`) and otherwise fall back to the first
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-config.js","names":[],"sources":["../../src/lib/pull-config.ts"],"sourcesContent":["import {\n\ttype BranchTuning,\n\ttype BucketAccessLevel,\n\ttype ComputeSettings,\n\ttype Config,\n\tcreateNeonApiFromOptions,\n\tErrorCode,\n\ttype NeonApi,\n\ttype NeonBranchSnapshot,\n\ttype NeonBucketSnapshot,\n\ttype NeonCredentialMeta,\n\ttype NeonDatabaseSnapshot,\n\ttype NeonEndpointSnapshot,\n\ttype NeonFunctionSnapshot,\n\ttype NeonProjectSnapshot,\n\tPlatformError,\n} from \"@neon/config\";\n\nexport interface PullConfigOptions {\n\t/** Neon project id (`<project>`). Required — the API addresses branches by project. */\n\tprojectId: string;\n\t/** Neon branch id (`br-…`). Required. Resolve names to ids before calling. */\n\tbranchId: string;\n\t/** Neon API key. Falls back to `NEON_API_KEY` / neonctl credentials. */\n\tapiKey?: string;\n\t/** Neon API base URL. Falls back to `NEON_API_HOST`, then production. */\n\tapiHost?: string;\n\t/** Inject a custom NeonApi adapter (primarily for tests). */\n\tapi?: NeonApi;\n}\n\n/**\n * Live Preview-feature state read back from a branch. Surfaced alongside `config` rather\n * than inside it because functions cannot round-trip: the remote only knows the deployed\n * bundle, not the local `source` path a {@link FunctionConfig} requires, so a pulled\n * function is reported as `{ slug, name }` (no `source`).\n */\nexport interface PulledPreview {\n\tbuckets: Array<{ name: string; access: BucketAccessLevel }>;\n\tfunctions: Array<{ slug: string; name: string }>;\n\t/**\n\t * Secret-free metadata for the credentials issued on the branch (Preview). Surfaced so\n\t * `config status` can show issued credentials (id, scopes, last used) without ever\n\t * exposing the one-time `api_token` / `s3_secret_access_key`. Empty when none / the\n\t * credentials endpoint is unavailable for the project.\n\t */\n\tcredentials: NeonCredentialMeta[];\n}\n\nexport interface PulledBranchConfig {\n\tproject: {\n\t\tid: string;\n\t\tname: string;\n\t\tregion: string;\n\t\tpgVersion: number;\n\t\torgId?: string;\n\t};\n\tbranch: {\n\t\tid: string;\n\t\tname: string;\n\t\tparent?: string;\n\t\tisDefault: boolean;\n\t\tprotected: boolean;\n\t\texpiresAt?: string;\n\t};\n\t/**\n\t * The branch's live state expressed as a {@link Config}: static `auth` / `dataApi`\n\t * toggles, any object-storage `preview.buckets`, plus a `branch` closure carrying the\n\t * branch's lifecycle/compute tuning. Buckets are included here (not just in\n\t * {@link PulledBranchConfig.preview}) because they round-trip cleanly — name + access\n\t * level is all a {@link Config} needs — so the no-policy env path (`neon dev` /\n\t * `neon env pull`) can resolve the branch's storage credentials without a local\n\t * `neon.ts`. Preview **functions** are reported only in\n\t * {@link PulledBranchConfig.preview}: they cannot round-trip (the remote has no local\n\t * `source` path). The AI Gateway is omitted from both — it has no branch-level \"enabled\"\n\t * state to read back (it is always available, credential-gated), so `pullConfig` cannot\n\t * tell whether a policy would enable it.\n\t */\n\tconfig: Config;\n\t/**\n\t * Live Preview-feature state, when the branch has any buckets/functions or issued\n\t * credentials. Omitted entirely when there is nothing to report. The AI Gateway is not\n\t * included: it is always available (credential-gated), not per-branch state.\n\t */\n\tpreview?: PulledPreview;\n}\n\nexport async function pullConfig(\n\toptions: PullConfigOptions,\n): Promise<PulledBranchConfig> {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\tconst project = await api.getProject(projectId);\n\tconst [branches, endpoints] = await Promise.all([\n\t\tapi.listBranches(projectId),\n\t\tapi.listEndpoints(projectId),\n\t]);\n\tconst branch = resolveBranch(options.branchId, branches);\n\tconst endpoint = endpoints.find(\n\t\t(ep) => ep.type === \"read_write\" && ep.branchId === branch.id,\n\t);\n\n\t// Data API is enabled per branch + database, so resolve a database to probe.\n\tconst databases = await api.listBranchDatabases(projectId, branch.id);\n\tconst probeDatabase = pickProbeDatabase(databases);\n\n\t// Preview reads degrade to \"none / disabled\" when the feature isn't available for the\n\t// project/region. `pullConfig` mirrors the branch for env resolution (`neon dev`,\n\t// `neon env pull`) and `inspect` — an unavailable Preview feature should not break those\n\t// (env comes from auth/dataApi/postgres). `pushConfig` is the place that fails on an\n\t// unavailable feature, and only when the policy declares it.\n\tconst [buckets, functions, credentials, auth, dataApi] = await Promise.all([\n\t\tdegradeUnavailable(\n\t\t\t() => api.listBranchBuckets(projectId, branch.id),\n\t\t\t[],\n\t\t),\n\t\tdegradeUnavailable(\n\t\t\t() => api.listBranchFunctions(projectId, branch.id),\n\t\t\t[],\n\t\t),\n\t\tdegradeUnavailable(() => api.listCredentials(projectId, branch.id), []),\n\t\tapi.getNeonAuth(projectId, branch.id),\n\t\tprobeDatabase\n\t\t\t? api.getNeonDataApi(projectId, branch.id, probeDatabase)\n\t\t\t: Promise.resolve(null),\n\t]);\n\n\treturn buildPulledBranchConfig(project, branch, branches, endpoint, {\n\t\tbuckets,\n\t\tfunctions,\n\t\tcredentials,\n\t\tauthEnabled: auth !== null,\n\t\tdataApiEnabled: dataApi !== null,\n\t});\n}\n\n/**\n * Pick the database to probe for a Data API integration. Data API is enabled per\n * branch + database; for read-back we only need to know whether *any* database has it\n * on, so prefer the conventional default (`neondb`) and otherwise fall back to the first\n * database. Returns `undefined` when the branch has no databases.\n */\nfunction pickProbeDatabase(\n\tdatabases: NeonDatabaseSnapshot[],\n): string | undefined {\n\tif (databases.length === 0) return undefined;\n\tconst byName = databases.find((d) => d.name === \"neondb\");\n\tif (byName) return byName.name;\n\treturn databases[0].name;\n}\n\n/**\n * Run a Preview-feature read, returning `fallback` if the feature is unavailable for the\n * project/region (a {@link ErrorCode.FeatureUnavailable} from the adapter). Other errors\n * propagate. Used by `pullConfig` so a branch without a Preview feature still mirrors\n * cleanly for env resolution / `inspect`, rather than aborting on an unrelated capability.\n */\nasync function degradeUnavailable<T>(\n\tread: () => Promise<T>,\n\tfallback: T,\n): Promise<T> {\n\ttry {\n\t\treturn await read();\n\t} catch (err) {\n\t\tif (\n\t\t\terr instanceof PlatformError &&\n\t\t\terr.code === ErrorCode.FeatureUnavailable\n\t\t) {\n\t\t\treturn fallback;\n\t\t}\n\t\tthrow err;\n\t}\n}\n\nfunction createApiFromOptions(options: PullConfigOptions): NeonApi {\n\treturn createNeonApiFromOptions(\"pullConfig\", {\n\t\t...(options.apiKey ? { apiKey: options.apiKey } : {}),\n\t\t...(options.apiHost ? { apiHost: options.apiHost } : {}),\n\t});\n}\n\nexport function buildPulledBranchConfig(\n\tproject: NeonProjectSnapshot,\n\tbranch: NeonBranchSnapshot,\n\tbranches: NeonBranchSnapshot[],\n\tendpoint: NeonEndpointSnapshot | undefined,\n\tpreviewState?: {\n\t\tbuckets: NeonBucketSnapshot[];\n\t\tfunctions: NeonFunctionSnapshot[];\n\t\tcredentials?: NeonCredentialMeta[];\n\t\t/** Whether a Neon Auth integration is enabled on the branch. */\n\t\tauthEnabled?: boolean;\n\t\t/** Whether a Neon Data API integration is enabled on the branch. */\n\t\tdataApiEnabled?: boolean;\n\t},\n): PulledBranchConfig {\n\tconst parent = branch.parentId\n\t\t? branches.find((b) => b.id === branch.parentId)\n\t\t: undefined;\n\t// Auth/Data API are static top-level toggles, so a config pulled from a branch with\n\t// them enabled round-trips through `resolveConfig` / `fetchEnv` and the matching\n\t// secrets get injected. Branch lifecycle/compute is per-branch tuning, so it goes in\n\t// the `branch` closure.\n\tconst tuning: BranchTuning = {};\n\tif (parent) tuning.parent = parent.name;\n\t// Deliberately NOT emitting `ttl` from `branch.expiresAt`: policy `ttl` is a\n\t// creation-time *duration*, while `expiresAt` is an absolute timestamp. Feeding the\n\t// timestamp through `parseDuration` (in `resolveConfig`) would throw, breaking\n\t// `fetchEnv` / `neon dev` / `neon env pull` for any branch that has a TTL. The expiry\n\t// is reported faithfully on `branch.expiresAt` above.\n\tif (branch.protected) tuning.protected = true;\n\tif (endpoint) {\n\t\tconst compute = endpointToComputeSettings(endpoint, project);\n\t\tif (compute) tuning.postgres = { computeSettings: compute };\n\t}\n\t// Buckets round-trip cleanly (name + access level), so they belong in the config the\n\t// env path resolves from — this is what lets `neon dev` / `neon env pull` inject the\n\t// branch's object-storage credentials (AWS_*) with no local neon.ts. Functions are\n\t// deliberately NOT emitted here (they can't round-trip: the remote has no `source`\n\t// path) and neither is the AI Gateway (no branch-level enabled state to detect, only a\n\t// credential) — both would otherwise turn a read-back into a bogus policy declaration.\n\tconst bucketDefs: Record<string, { access: BucketAccessLevel }> = {};\n\tfor (const b of previewState?.buckets ?? []) {\n\t\tbucketDefs[b.name] = { access: b.accessLevel };\n\t}\n\tconst config: Config = {\n\t\t...(previewState?.authEnabled ? { auth: true } : {}),\n\t\t...(previewState?.dataApiEnabled ? { dataApi: true } : {}),\n\t\t...(Object.keys(bucketDefs).length > 0\n\t\t\t? { preview: { buckets: bucketDefs } }\n\t\t\t: {}),\n\t\t...(Object.keys(tuning).length > 0 ? { branch: () => tuning } : {}),\n\t};\n\tconst result: PulledBranchConfig = {\n\t\tproject: {\n\t\t\tid: project.id,\n\t\t\tname: project.name,\n\t\t\tregion: project.regionId,\n\t\t\tpgVersion: project.pgVersion,\n\t\t\t...(project.orgId ? { orgId: project.orgId } : {}),\n\t\t},\n\t\tbranch: {\n\t\t\tid: branch.id,\n\t\t\tname: branch.name,\n\t\t\t...(parent ? { parent: parent.name } : {}),\n\t\t\tisDefault: branch.isDefault,\n\t\t\tprotected: branch.protected,\n\t\t\t...(branch.expiresAt ? { expiresAt: branch.expiresAt } : {}),\n\t\t},\n\t\tconfig,\n\t};\n\tconst preview = previewState ? buildPulledPreview(previewState) : undefined;\n\tif (preview) result.preview = preview;\n\treturn result;\n}\n\n/**\n * Reverse-engineer the {@link PulledPreview} from remote snapshots. Returns `undefined` when\n * the branch has no Preview features so the field can be omitted entirely.\n */\nfunction buildPulledPreview(state: {\n\tbuckets: NeonBucketSnapshot[];\n\tfunctions: NeonFunctionSnapshot[];\n\tcredentials?: NeonCredentialMeta[];\n}): PulledPreview | undefined {\n\tconst credentials = state.credentials ?? [];\n\tif (\n\t\tstate.buckets.length === 0 &&\n\t\tstate.functions.length === 0 &&\n\t\tcredentials.length === 0\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tbuckets: state.buckets.map((b) => ({\n\t\t\tname: b.name,\n\t\t\taccess: b.accessLevel,\n\t\t})),\n\t\tfunctions: state.functions.map((f) => ({\n\t\t\tslug: f.slug,\n\t\t\tname: f.name,\n\t\t})),\n\t\tcredentials,\n\t};\n}\n\nfunction resolveBranch(\n\tbranchId: string,\n\tbranches: NeonBranchSnapshot[],\n): NeonBranchSnapshot {\n\tconst match = branches.find((b) => b.id === branchId);\n\tif (match) return match;\n\tthrow new PlatformError(\n\t\tErrorCode.BranchNotFound,\n\t\t[\n\t\t\t`pullConfig: branch id ${JSON.stringify(branchId)} not found on project.`,\n\t\t\t`Available branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \") || \"(none)\"}.`,\n\t\t].join(\" \"),\n\t\t{\n\t\t\tdetails: {\n\t\t\t\tbranchId,\n\t\t\t\tavailable: branches.map((b) => b.id),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction endpointToComputeSettings(\n\tendpoint: NeonEndpointSnapshot,\n\tproject: NeonProjectSnapshot,\n): ComputeSettings | undefined {\n\tconst defaults = project.defaultEndpointSettings;\n\tconst out: ComputeSettings = {};\n\tif (\n\t\tendpoint.autoscalingLimitMinCu !== undefined &&\n\t\tendpoint.autoscalingLimitMinCu !== defaults?.autoscalingLimitMinCu\n\t) {\n\t\tout.autoscalingLimitMinCu = endpoint.autoscalingLimitMinCu;\n\t}\n\tif (\n\t\tendpoint.autoscalingLimitMaxCu !== undefined &&\n\t\tendpoint.autoscalingLimitMaxCu !== defaults?.autoscalingLimitMaxCu\n\t) {\n\t\tout.autoscalingLimitMaxCu = endpoint.autoscalingLimitMaxCu;\n\t}\n\tif (\n\t\tendpoint.suspendTimeout !== undefined &&\n\t\tendpoint.suspendTimeout !== defaults?.suspendTimeout\n\t) {\n\t\tout.suspendTimeout = endpoint.suspendTimeout;\n\t}\n\treturn Object.keys(out).length > 0 ? out : undefined;\n}\n"],"mappings":";;AAuFA,eAAsB,WACrB,SAC8B;CAC9B,MAAM,MAAM,QAAQ,OAAO,qBAAqB,OAAO;CACvD,MAAM,YAAY,QAAQ;CAC1B,MAAM,UAAU,MAAM,IAAI,WAAW,SAAS;CAC9C,MAAM,CAAC,UAAU,aAAa,MAAM,QAAQ,IAAI,CAC/C,IAAI,aAAa,SAAS,GAC1B,IAAI,cAAc,SAAS,CAC5B,CAAC;CACD,MAAM,SAAS,cAAc,QAAQ,UAAU,QAAQ;CACvD,MAAM,WAAW,UAAU,MACzB,OAAO,GAAG,SAAS,gBAAgB,GAAG,aAAa,OAAO,EAC5D;CAIA,MAAM,gBAAgB,kBAAkB,MADhB,IAAI,oBAAoB,WAAW,OAAO,EAAE,CACnB;CAOjD,MAAM,CAAC,SAAS,WAAW,aAAa,MAAM,WA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,KAAK,OAAO;GAClC,MAAM,EAAE;GACR,QAAQ,EAAE;EACX,EAAE;EACF,WAAW,MAAM,UAAU,KAAK,OAAO;GACtC,MAAM,EAAE;GACR,MAAM,EAAE;EACT,EAAE;EACF;CACD;AACD;AAEA,SAAS,cACR,UACA,UACqB;CACrB,MAAM,QAAQ,SAAS,MAAM,MAAM,EAAE,OAAO,QAAQ;CACpD,IAAI,OAAO,OAAO;CAClB,MAAM,IAAI,cACT,UAAU,gBACV,CACC,yBAAyB,KAAK,UAAU,QAAQ,EAAE,yBAClD,uBAAuB,SAAS,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,SAAS,EAC1F,CAAC,CAAC,KAAK,GAAG,GACV,EACC,SAAS;EACR;EACA,WAAW,SAAS,KAAK,MAAM,EAAE,EAAE;CACpC,EACD,CACD;AACD;AAEA,SAAS,0BACR,UACA,SAC8B;CAC9B,MAAM,WAAW,QAAQ;CACzB,MAAM,MAAuB,CAAC;CAC9B,IACC,SAAS,0BAA0B,KAAA,KACnC,SAAS,0BAA0B,UAAU,uBAE7C,IAAI,wBAAwB,SAAS;CAEtC,IACC,SAAS,0BAA0B,KAAA,KACnC,SAAS,0BAA0B,UAAU,uBAE7C,IAAI,wBAAwB,SAAS;CAEtC,IACC,SAAS,mBAAmB,KAAA,KAC5B,SAAS,mBAAmB,UAAU,gBAEtC,IAAI,iBAAiB,SAAS;CAE/B,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,KAAA;AAC5C"}
|
|
1
|
+
{"version":3,"file":"pull-config.js","names":[],"sources":["../../src/lib/pull-config.ts"],"sourcesContent":["import {\n\ttype BranchTuning,\n\ttype BucketAccessLevel,\n\ttype ComputeSettings,\n\ttype Config,\n\tcreateNeonApiFromOptions,\n\tErrorCode,\n\ttype NeonApi,\n\ttype NeonBranchSnapshot,\n\ttype NeonBucketSnapshot,\n\ttype NeonCredentialMeta,\n\ttype NeonDatabaseSnapshot,\n\ttype NeonEndpointSnapshot,\n\ttype NeonFunctionSnapshot,\n\ttype NeonProjectSnapshot,\n\tPlatformError,\n} from \"@neon/config\";\n\nexport interface PullConfigOptions {\n\t/** Neon project id (`<project>`). Required — the API addresses branches by project. */\n\tprojectId: string;\n\t/** Neon branch id (`br-…`). Required. Resolve names to ids before calling. */\n\tbranchId: string;\n\t/** Neon API key. Falls back to `NEON_API_KEY` / neonctl credentials. */\n\tapiKey?: string;\n\t/** Neon API base URL. Falls back to `NEON_API_HOST`, then production. */\n\tapiHost?: string;\n\t/** Inject a custom NeonApi adapter (primarily for tests). */\n\tapi?: NeonApi;\n}\n\n/**\n * Live Preview-feature state read back from a branch. Surfaced alongside `config` rather\n * than inside it because functions cannot round-trip: the remote only knows the deployed\n * bundle, not the local `source` path a {@link FunctionConfig} requires, so a pulled\n * function is reported as `{ slug, name }` (no `source`).\n */\nexport interface PulledPreview {\n\tbuckets: Array<{ name: string; access: BucketAccessLevel }>;\n\tfunctions: Array<{ slug: string; name: string }>;\n\t/**\n\t * Secret-free metadata for the credentials issued on the branch (Preview). Surfaced so\n\t * `config status` can show issued credentials (id, scopes, last used) without ever\n\t * exposing the one-time `api_token` / `s3_secret_access_key`. Empty when none / the\n\t * credentials endpoint is unavailable for the project.\n\t */\n\tcredentials: NeonCredentialMeta[];\n}\n\nexport interface PulledBranchConfig {\n\tproject: {\n\t\tid: string;\n\t\tname: string;\n\t\tregion: string;\n\t\tpgVersion: number;\n\t\torgId?: string;\n\t};\n\tbranch: {\n\t\tid: string;\n\t\tname: string;\n\t\tparent?: string;\n\t\tisDefault: boolean;\n\t\tprotected: boolean;\n\t\texpiresAt?: string;\n\t};\n\t/**\n\t * The branch's live state expressed as a {@link Config}: static `auth` / `dataApi`\n\t * toggles, any object-storage `preview.buckets`, plus a `branch` closure carrying the\n\t * branch's lifecycle/compute tuning. Buckets are included here (not just in\n\t * {@link PulledBranchConfig.preview}) because they round-trip cleanly — name + access\n\t * level is all a {@link Config} needs — so the no-policy env path (`neon dev` /\n\t * `neon env pull`) can resolve the branch's storage credentials without a local\n\t * `neon.ts`. Preview **functions** are reported only in\n\t * {@link PulledBranchConfig.preview}: they cannot round-trip (the remote has no local\n\t * `source` path). The AI Gateway is omitted from both — it has no branch-level \"enabled\"\n\t * state to read back (it is always available, credential-gated), so `pullConfig` cannot\n\t * tell whether a policy would enable it.\n\t */\n\tconfig: Config;\n\t/**\n\t * Live Preview-feature state, when the branch has any buckets/functions or issued\n\t * credentials. Omitted entirely when there is nothing to report. The AI Gateway is not\n\t * included: it is always available (credential-gated), not per-branch state.\n\t */\n\tpreview?: PulledPreview;\n}\n\nexport async function pullConfig(\n\toptions: PullConfigOptions,\n): Promise<PulledBranchConfig> {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\tconst branchId = options.branchId;\n\n\t// The first three stages need only the project and branch ids, so they start together.\n\t// They are awaited in the order they used to run, so the first error reported is the same\n\t// one as before (project, then branches/endpoints, then the branch lookup, then databases).\n\tconst projectRead = started(() => api.getProject(projectId));\n\tconst listsRead = started(() =>\n\t\tPromise.all([\n\t\t\tstarted(() => api.listBranches(projectId)),\n\t\t\tstarted(() => api.listEndpoints(projectId)),\n\t\t]),\n\t);\n\t// Data API is enabled per branch + database, so resolve a database to probe.\n\tconst databasesRead = started(() =>\n\t\tapi.listBranchDatabases(projectId, branchId),\n\t);\n\t// Preview reads degrade to \"none / disabled\" when the feature isn't available for the\n\t// project/region. `pullConfig` mirrors the branch for env resolution (`neon dev`,\n\t// `neon env pull`) and `inspect` — an unavailable Preview feature should not break those\n\t// (env comes from auth/dataApi/postgres). `pushConfig` is the place that fails on an\n\t// unavailable feature, and only when the policy declares it.\n\t// The group starts together once databases resolve (the Data API probe needs one), as\n\t// before, so which member's error comes first is unchanged.\n\tconst previewRead = started(() =>\n\t\tdatabasesRead.then((databases) => {\n\t\t\tconst probeDatabase = pickProbeDatabase(databases);\n\t\t\treturn Promise.all([\n\t\t\t\tstarted(() =>\n\t\t\t\t\tdegradeUnavailable(\n\t\t\t\t\t\t() => api.listBranchBuckets(projectId, branchId),\n\t\t\t\t\t\t[],\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tstarted(() =>\n\t\t\t\t\tdegradeUnavailable(\n\t\t\t\t\t\t() => api.listBranchFunctions(projectId, branchId),\n\t\t\t\t\t\t[],\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tstarted(() =>\n\t\t\t\t\tdegradeUnavailable(\n\t\t\t\t\t\t() => api.listCredentials(projectId, branchId),\n\t\t\t\t\t\t[],\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tstarted(() => api.getNeonAuth(projectId, branchId)),\n\t\t\t\tstarted(() =>\n\t\t\t\t\tprobeDatabase\n\t\t\t\t\t\t? api.getNeonDataApi(projectId, branchId, probeDatabase)\n\t\t\t\t\t\t: Promise.resolve(null),\n\t\t\t\t),\n\t\t\t]);\n\t\t}),\n\t);\n\n\tconst project = await projectRead;\n\tconst [branches, endpoints] = await listsRead;\n\tconst branch = resolveBranch(branchId, branches);\n\tconst endpoint = endpoints.find(\n\t\t(ep) => ep.type === \"read_write\" && ep.branchId === branch.id,\n\t);\n\tawait databasesRead;\n\tconst [buckets, functions, credentials, auth, dataApi] = await previewRead;\n\n\treturn buildPulledBranchConfig(project, branch, branches, endpoint, {\n\t\tbuckets,\n\t\tfunctions,\n\t\tcredentials,\n\t\tauthEnabled: auth !== null,\n\t\tdataApiEnabled: dataApi !== null,\n\t});\n}\n\n/**\n * Starts a read now and keeps an unread rejection from crashing the process; the caller\n * awaits it (and sees the error) when its turn comes. Also turns a synchronous throw from\n * a custom adapter into a rejection.\n */\nfunction started<T>(read: () => Promise<T>): Promise<T> {\n\tconst promise = Promise.resolve().then(read);\n\tpromise.catch(() => undefined);\n\treturn promise;\n}\n\n/**\n * Pick the database to probe for a Data API integration. Data API is enabled per\n * branch + database; for read-back we only need to know whether *any* database has it\n * on, so prefer the conventional default (`neondb`) and otherwise fall back to the first\n * database. Returns `undefined` when the branch has no databases.\n */\nfunction pickProbeDatabase(\n\tdatabases: NeonDatabaseSnapshot[],\n): string | undefined {\n\tif (databases.length === 0) return undefined;\n\tconst byName = databases.find((d) => d.name === \"neondb\");\n\tif (byName) return byName.name;\n\treturn databases[0].name;\n}\n\n/**\n * Run a Preview-feature read, returning `fallback` if the feature is unavailable for the\n * project/region (a {@link ErrorCode.FeatureUnavailable} from the adapter). Other errors\n * propagate. Used by `pullConfig` so a branch without a Preview feature still mirrors\n * cleanly for env resolution / `inspect`, rather than aborting on an unrelated capability.\n */\nasync function degradeUnavailable<T>(\n\tread: () => Promise<T>,\n\tfallback: T,\n): Promise<T> {\n\ttry {\n\t\treturn await read();\n\t} catch (err) {\n\t\tif (\n\t\t\terr instanceof PlatformError &&\n\t\t\terr.code === ErrorCode.FeatureUnavailable\n\t\t) {\n\t\t\treturn fallback;\n\t\t}\n\t\tthrow err;\n\t}\n}\n\nfunction createApiFromOptions(options: PullConfigOptions): NeonApi {\n\treturn createNeonApiFromOptions(\"pullConfig\", {\n\t\t...(options.apiKey ? { apiKey: options.apiKey } : {}),\n\t\t...(options.apiHost ? { apiHost: options.apiHost } : {}),\n\t});\n}\n\nexport function buildPulledBranchConfig(\n\tproject: NeonProjectSnapshot,\n\tbranch: NeonBranchSnapshot,\n\tbranches: NeonBranchSnapshot[],\n\tendpoint: NeonEndpointSnapshot | undefined,\n\tpreviewState?: {\n\t\tbuckets: NeonBucketSnapshot[];\n\t\tfunctions: NeonFunctionSnapshot[];\n\t\tcredentials?: NeonCredentialMeta[];\n\t\t/** Whether a Neon Auth integration is enabled on the branch. */\n\t\tauthEnabled?: boolean;\n\t\t/** Whether a Neon Data API integration is enabled on the branch. */\n\t\tdataApiEnabled?: boolean;\n\t},\n): PulledBranchConfig {\n\tconst parent = branch.parentId\n\t\t? branches.find((b) => b.id === branch.parentId)\n\t\t: undefined;\n\t// Auth/Data API are static top-level toggles, so a config pulled from a branch with\n\t// them enabled round-trips through `resolveConfig` / `fetchEnv` and the matching\n\t// secrets get injected. Branch lifecycle/compute is per-branch tuning, so it goes in\n\t// the `branch` closure.\n\tconst tuning: BranchTuning = {};\n\tif (parent) tuning.parent = parent.name;\n\t// Deliberately NOT emitting `ttl` from `branch.expiresAt`: policy `ttl` is a\n\t// creation-time *duration*, while `expiresAt` is an absolute timestamp. Feeding the\n\t// timestamp through `parseDuration` (in `resolveConfig`) would throw, breaking\n\t// `fetchEnv` / `neon dev` / `neon env pull` for any branch that has a TTL. The expiry\n\t// is reported faithfully on `branch.expiresAt` above.\n\tif (branch.protected) tuning.protected = true;\n\tif (endpoint) {\n\t\tconst compute = endpointToComputeSettings(endpoint, project);\n\t\tif (compute) tuning.postgres = { computeSettings: compute };\n\t}\n\t// Buckets round-trip cleanly (name + access level), so they belong in the config the\n\t// env path resolves from — this is what lets `neon dev` / `neon env pull` inject the\n\t// branch's object-storage credentials (AWS_*) with no local neon.ts. Functions are\n\t// deliberately NOT emitted here (they can't round-trip: the remote has no `source`\n\t// path) and neither is the AI Gateway (no branch-level enabled state to detect, only a\n\t// credential) — both would otherwise turn a read-back into a bogus policy declaration.\n\tconst bucketDefs: Record<string, { access: BucketAccessLevel }> = {};\n\tfor (const b of previewState?.buckets ?? []) {\n\t\tbucketDefs[b.name] = { access: b.accessLevel };\n\t}\n\tconst config: Config = {\n\t\t...(previewState?.authEnabled ? { auth: true } : {}),\n\t\t...(previewState?.dataApiEnabled ? { dataApi: true } : {}),\n\t\t...(Object.keys(bucketDefs).length > 0\n\t\t\t? { preview: { buckets: bucketDefs } }\n\t\t\t: {}),\n\t\t...(Object.keys(tuning).length > 0 ? { branch: () => tuning } : {}),\n\t};\n\tconst result: PulledBranchConfig = {\n\t\tproject: {\n\t\t\tid: project.id,\n\t\t\tname: project.name,\n\t\t\tregion: project.regionId,\n\t\t\tpgVersion: project.pgVersion,\n\t\t\t...(project.orgId ? { orgId: project.orgId } : {}),\n\t\t},\n\t\tbranch: {\n\t\t\tid: branch.id,\n\t\t\tname: branch.name,\n\t\t\t...(parent ? { parent: parent.name } : {}),\n\t\t\tisDefault: branch.isDefault,\n\t\t\tprotected: branch.protected,\n\t\t\t...(branch.expiresAt ? { expiresAt: branch.expiresAt } : {}),\n\t\t},\n\t\tconfig,\n\t};\n\tconst preview = previewState ? buildPulledPreview(previewState) : undefined;\n\tif (preview) result.preview = preview;\n\treturn result;\n}\n\n/**\n * Reverse-engineer the {@link PulledPreview} from remote snapshots. Returns `undefined` when\n * the branch has no Preview features so the field can be omitted entirely.\n */\nfunction buildPulledPreview(state: {\n\tbuckets: NeonBucketSnapshot[];\n\tfunctions: NeonFunctionSnapshot[];\n\tcredentials?: NeonCredentialMeta[];\n}): PulledPreview | undefined {\n\tconst credentials = state.credentials ?? [];\n\tif (\n\t\tstate.buckets.length === 0 &&\n\t\tstate.functions.length === 0 &&\n\t\tcredentials.length === 0\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tbuckets: state.buckets.map((b) => ({\n\t\t\tname: b.name,\n\t\t\taccess: b.accessLevel,\n\t\t})),\n\t\tfunctions: state.functions.map((f) => ({\n\t\t\tslug: f.slug,\n\t\t\tname: f.name,\n\t\t})),\n\t\tcredentials,\n\t};\n}\n\nfunction resolveBranch(\n\tbranchId: string,\n\tbranches: NeonBranchSnapshot[],\n): NeonBranchSnapshot {\n\tconst match = branches.find((b) => b.id === branchId);\n\tif (match) return match;\n\tthrow new PlatformError(\n\t\tErrorCode.BranchNotFound,\n\t\t[\n\t\t\t`pullConfig: branch id ${JSON.stringify(branchId)} not found on project.`,\n\t\t\t`Available branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \") || \"(none)\"}.`,\n\t\t].join(\" \"),\n\t\t{\n\t\t\tdetails: {\n\t\t\t\tbranchId,\n\t\t\t\tavailable: branches.map((b) => b.id),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction endpointToComputeSettings(\n\tendpoint: NeonEndpointSnapshot,\n\tproject: NeonProjectSnapshot,\n): ComputeSettings | undefined {\n\tconst defaults = project.defaultEndpointSettings;\n\tconst out: ComputeSettings = {};\n\tif (\n\t\tendpoint.autoscalingLimitMinCu !== undefined &&\n\t\tendpoint.autoscalingLimitMinCu !== defaults?.autoscalingLimitMinCu\n\t) {\n\t\tout.autoscalingLimitMinCu = endpoint.autoscalingLimitMinCu;\n\t}\n\tif (\n\t\tendpoint.autoscalingLimitMaxCu !== undefined &&\n\t\tendpoint.autoscalingLimitMaxCu !== defaults?.autoscalingLimitMaxCu\n\t) {\n\t\tout.autoscalingLimitMaxCu = endpoint.autoscalingLimitMaxCu;\n\t}\n\tif (\n\t\tendpoint.suspendTimeout !== undefined &&\n\t\tendpoint.suspendTimeout !== defaults?.suspendTimeout\n\t) {\n\t\tout.suspendTimeout = endpoint.suspendTimeout;\n\t}\n\treturn Object.keys(out).length > 0 ? out : undefined;\n}\n"],"mappings":";;AAuFA,eAAsB,WACrB,SAC8B;CAC9B,MAAM,MAAM,QAAQ,OAAO,qBAAqB,OAAO;CACvD,MAAM,YAAY,QAAQ;CAC1B,MAAM,WAAW,QAAQ;CAKzB,MAAM,cAAc,cAAc,IAAI,WAAW,SAAS,CAAC;CAC3D,MAAM,YAAY,cACjB,QAAQ,IAAI,CACX,cAAc,IAAI,aAAa,SAAS,CAAC,GACzC,cAAc,IAAI,cAAc,SAAS,CAAC,CAC3C,CAAC,CACF;CAEA,MAAM,gBAAgB,cACrB,IAAI,oBAAoB,WAAW,QAAQ,CAC5C;CAQA,MAAM,cAAc,cACnB,cAAc,MAAM,cAAc;EACjC,MAAM,gBAAgB,kBAAkB,SAAS;EACjD,OAAO,QAAQ,IAAI;GAClB,cACC,yBACO,IAAI,kBAAkB,WAAW,QAAQ,GAC/C,CAAC,CACF,CACD;GACA,cACC,yBACO,IAAI,oBAAoB,WAAW,QAAQ,GACjD,CAAC,CACF,CACD;GACA,cACC,yBACO,IAAI,gBAAgB,WAAW,QAAQ,GAC7C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
@@ -20,8 +20,10 @@ async function pushConfig(config, options) {
|
|
|
20
20
|
const dryRun = options.dryRun === true;
|
|
21
21
|
const updateExisting = options.updateExisting === true;
|
|
22
22
|
const allowProtectedBranch = options.allowProtectedBranch === true;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const projectRead = started(() => api.getProject(projectId));
|
|
24
|
+
const listsRead = started(() => Promise.all([handled(api.listBranches(projectId)), handled(api.listEndpoints(projectId))]));
|
|
25
|
+
const remoteProject = await projectRead;
|
|
26
|
+
const [branches, endpoints] = await listsRead;
|
|
25
27
|
const branch = resolveRemoteBranch(options.branchId, branches);
|
|
26
28
|
const resolved = resolveConfig(config, {
|
|
27
29
|
name: branch.name,
|
|
@@ -32,26 +34,29 @@ async function pushConfig(config, options) {
|
|
|
32
34
|
isProtected: branch.protected,
|
|
33
35
|
...branch.expiresAt ? { expiresAt: branch.expiresAt } : {}
|
|
34
36
|
});
|
|
35
|
-
const
|
|
37
|
+
const servicesRead = started(() => resolveServiceState({
|
|
36
38
|
api,
|
|
37
39
|
projectId: remoteProject.id,
|
|
38
40
|
branch,
|
|
39
41
|
wantsAuth: resolved.authEnabled,
|
|
40
42
|
wantsDataApi: resolved.dataApiEnabled || resolved.dataApiPolicy === "disabled"
|
|
41
|
-
});
|
|
43
|
+
}));
|
|
44
|
+
const desiredPreview = resolved.preview;
|
|
45
|
+
const previewRead = desiredPreview ? started(() => resolvePreviewState({
|
|
46
|
+
api,
|
|
47
|
+
projectId: remoteProject.id,
|
|
48
|
+
branchId: branch.id,
|
|
49
|
+
desired: desiredPreview,
|
|
50
|
+
wantsTriggers: (resolved.triggers?.length ?? 0) > 0
|
|
51
|
+
})) : void 0;
|
|
52
|
+
const services = await servicesRead;
|
|
42
53
|
const remote = {
|
|
43
54
|
projectId: remoteProject.id,
|
|
44
55
|
branch,
|
|
45
56
|
endpoint: endpoints.find((ep) => ep.type === "read_write" && ep.branchId === branch.id),
|
|
46
57
|
services
|
|
47
58
|
};
|
|
48
|
-
if (
|
|
49
|
-
api,
|
|
50
|
-
projectId: remoteProject.id,
|
|
51
|
-
branchId: branch.id,
|
|
52
|
-
desired: resolved.preview,
|
|
53
|
-
wantsTriggers: (resolved.triggers?.length ?? 0) > 0
|
|
54
|
-
});
|
|
59
|
+
if (previewRead) remote.preview = await previewRead;
|
|
55
60
|
const diff = diffConfig(resolved, remote, { updateExisting: true });
|
|
56
61
|
const needsOverrideConfirm = diff.plan.filter(isOverrideStep).length > 0 && !updateExisting;
|
|
57
62
|
const needsProtectedConfirm = branch.protected && !allowProtectedBranch;
|
|
@@ -256,6 +261,30 @@ function resolveRemoteBranch(branchId, branches) {
|
|
|
256
261
|
} });
|
|
257
262
|
}
|
|
258
263
|
/**
|
|
264
|
+
* Starts a read now and keeps an unread rejection from crashing the process; the caller
|
|
265
|
+
* awaits it (and sees the error) when its turn comes. The read is called synchronously and
|
|
266
|
+
* its own promise returned, so errors surface in the same order as a direct call; a
|
|
267
|
+
* synchronous throw becomes the returned rejection.
|
|
268
|
+
*/
|
|
269
|
+
function started(read) {
|
|
270
|
+
let promise;
|
|
271
|
+
try {
|
|
272
|
+
promise = read();
|
|
273
|
+
} catch (error) {
|
|
274
|
+
promise = Promise.reject(error);
|
|
275
|
+
}
|
|
276
|
+
promise.catch(() => void 0);
|
|
277
|
+
return promise;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Marks a `Promise.all` member's rejection as handled, so a later member's synchronous
|
|
281
|
+
* throw cannot leave it unobserved. `Promise.all` still reports it.
|
|
282
|
+
*/
|
|
283
|
+
function handled(promise) {
|
|
284
|
+
promise.catch(() => void 0);
|
|
285
|
+
return promise;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
259
288
|
* Pre-fetch the current state of branch-scoped integrations on the selected branch.
|
|
260
289
|
*/
|
|
261
290
|
async function resolveServiceState(args) {
|
|
@@ -266,7 +295,7 @@ async function resolveServiceState(args) {
|
|
|
266
295
|
dataApiEnabled: false
|
|
267
296
|
};
|
|
268
297
|
const databaseName = await pickServiceDatabaseName(api, projectId, branch.id);
|
|
269
|
-
const [auth, dataApi] = await Promise.all([wantsAuth ? api.getNeonAuth(projectId, branch.id) : Promise.resolve(null), wantsDataApi ? api.getNeonDataApi(projectId, branch.id, databaseName) : Promise.resolve(null)]);
|
|
298
|
+
const [auth, dataApi] = await Promise.all([wantsAuth ? handled(api.getNeonAuth(projectId, branch.id)) : Promise.resolve(null), wantsDataApi ? handled(api.getNeonDataApi(projectId, branch.id, databaseName)) : Promise.resolve(null)]);
|
|
270
299
|
const result = {
|
|
271
300
|
databaseName,
|
|
272
301
|
authEnabled: auth !== null,
|
|
@@ -288,10 +317,10 @@ async function resolvePreviewState(args) {
|
|
|
288
317
|
const wantsCustomDomains = desired.functions.some((fn) => (fn.customDomains?.length ?? 0) > 0);
|
|
289
318
|
const customDomainApi = wantsCustomDomains ? requireCustomDomainApi(api) : void 0;
|
|
290
319
|
const [buckets, functions, triggers, customDomains] = await Promise.all([
|
|
291
|
-
desired.buckets.length > 0 ? api.listBranchBuckets(projectId, branchId) : Promise.resolve([]),
|
|
292
|
-
desired.functions.length > 0 ? api.listBranchFunctions(projectId, branchId) : Promise.resolve([]),
|
|
293
|
-
wantsTriggers ? api.listBranchTriggers(projectId, branchId) : Promise.resolve([]),
|
|
294
|
-
customDomainApi ? customDomainApi.listBranchCustomDomains(projectId, branchId) : Promise.resolve([])
|
|
320
|
+
desired.buckets.length > 0 ? handled(api.listBranchBuckets(projectId, branchId)) : Promise.resolve([]),
|
|
321
|
+
desired.functions.length > 0 ? handled(api.listBranchFunctions(projectId, branchId)) : Promise.resolve([]),
|
|
322
|
+
wantsTriggers ? handled(api.listBranchTriggers(projectId, branchId)) : Promise.resolve([]),
|
|
323
|
+
customDomainApi ? handled(customDomainApi.listBranchCustomDomains(projectId, branchId)) : Promise.resolve([])
|
|
295
324
|
]);
|
|
296
325
|
const preview = {
|
|
297
326
|
buckets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-config.js","names":[],"sources":["../../src/lib/push-config.ts"],"sourcesContent":["import {\n\ttype AppliedChange,\n\ttype Config,\n\ttype CreateTriggerInput,\n\tcreateNeonApiFromOptions,\n\tdiffConfig,\n\tErrorCode,\n\ttype NeonApi,\n\ttype NeonBranchSnapshot,\n\ttype NeonCustomDomainSnapshot,\n\ttype PlanStep,\n\tPlatformError,\n\tPushAbortedError,\n\tPushConflictError,\n\ttype PushResult,\n\ttype RemotePreviewState,\n\ttype RemoteServiceState,\n\ttype RemoteState,\n\ttype ResolvedFunctionConfig,\n\ttype ResolvedFunctionTrigger,\n\ttype ResolvedPreviewConfig,\n\tresolveConfig,\n\ttype UpdateTriggerInput,\n} from \"@neon/config\";\nimport type { FunctionBundler } from \"./function-bundle.js\";\n\n// Eager loading would evaluate esbuild for callers that provide their own bundler.\nconst makeDefaultBundleFunction =\n\t(onWarning: (message: string) => void): FunctionBundler =>\n\tasync (fn: ResolvedFunctionConfig): Promise<Uint8Array> => {\n\t\tconst { buildFunctionBundle } = await import(\"./function-bundle.js\");\n\t\treturn buildFunctionBundle(fn, { onWarning });\n\t};\n\nexport interface PushConfigOptions {\n\t/**\n\t * Neon project id. **Required** — the management API addresses every branch through\n\t * its project, so there is no way to push without it. `pushConfig` never creates a\n\t * project; resolve the id yourself (e.g. via neonctl) and pass it in.\n\t */\n\tprojectId: string;\n\t/**\n\t * Neon branch id (`br-…`). **Required.** `pushConfig` never creates a branch — it must\n\t * already exist on the project. Resolve names to ids before calling.\n\t */\n\tbranchId: string;\n\t/** Neon API key. Falls back to `NEON_API_KEY` / neonctl credentials. Ignored when `api` is supplied. */\n\tapiKey?: string;\n\t/** Neon API base URL. Falls back to `NEON_API_HOST`, then production. */\n\tapiHost?: string;\n\t/**\n\t * Inject a custom NeonApi adapter. Primarily used by tests; production callers can rely\n\t * on the default real adapter built from `apiKey`.\n\t */\n\tapi?: NeonApi;\n\t/**\n\t * Whether to evaluate the policy as if the target branch **already exists** (the value of\n\t * `branch.exists` passed to the `defineConfig({ branch: (branch) => … })` closure). Defaults to `true`.\n\t *\n\t * Set to `false` to evaluate the policy as a **branch creation** — used by\n\t * {@link createBranch} right after it provisions a new branch, so creation-time tuning\n\t * gated on `!branch.exists` (TTL, compute settings, `parent`) actually resolves instead of\n\t * hitting the \"existing branch, leave as-is\" path. Only affects policy evaluation; the\n\t * branch must still physically exist on Neon (`pushConfig` never creates one).\n\t */\n\tbranchExists?: boolean;\n\t/**\n\t * Auto-confirm overriding existing remote settings.\n\t *\n\t * When `true`, mutable drift on the selected branch (TTL, `protected` flag, compute\n\t * settings) is applied as actual mutations and the override-confirm prompt is\n\t * skipped. When `false` (default) the behaviour depends on whether `confirm` is\n\t * supplied:\n\t * - With `confirm`: the callback is asked whether to apply the override.\n\t * - Without `confirm`: drift is reported as a `PushConflictError` (legacy\n\t * non-interactive default — preserved so programmatic SDK callers don't\n\t * silently start mutating remote state).\n\t */\n\tupdateExisting?: boolean;\n\t/**\n\t * Auto-confirm pushing to a protected branch.\n\t *\n\t * When `true`, no protected-branch confirmation is asked. When `false` (default):\n\t * - With `confirm`: the callback is asked.\n\t * - Without `confirm`: the push proceeds (legacy SDK default).\n\t */\n\tallowProtectedBranch?: boolean;\n\t/**\n\t * Optional confirmation callback. Invoked once with a single context object before\n\t * any mutations run when the push needs confirmation: pushing to a protected\n\t * branch (unless `allowProtectedBranch` is `true`) and/or applying mutable drift\n\t * (unless `updateExisting` is `true`).\n\t *\n\t * Both prompts collapse into a single callback invocation when both apply, so the\n\t * CLI can render one combined \"are you sure?\" prompt.\n\t *\n\t * Resolves to `true` to proceed, `false` to abort with {@link PushAbortedError}.\n\t *\n\t * Never invoked on `dryRun`.\n\t */\n\tconfirm?: (context: PushConfirmContext) => boolean | Promise<boolean>;\n\t/** Inject to deploy without this package loading esbuild. */\n\tbundleFunction?: FunctionBundler;\n\t/**\n\t * When `true`, compute the full plan against the live remote state but **do not\n\t * execute any mutations**. The resulting `PushResult.applied` array records every\n\t * change that *would* run on a real push (with the same action / identifier / details\n\t * shape, so the existing CLI summary formatter just works), and conflicts are\n\t * reported instead of thrown.\n\t *\n\t * Used by `plan(config, branchId)` and any caller that wants a \"would this push do\n\t * something dangerous?\" check before invoking `pushConfig` for real.\n\t */\n\tdryRun?: boolean;\n}\n\n/**\n * Context handed to a {@link PushConfigOptions.confirm} callback. Both flags can be\n * `true` simultaneously when the push targets a protected branch *and* would override\n * existing settings — render a single combined prompt covering both reasons.\n */\nexport interface PushConfirmContext {\n\t/** Name of the target branch on Neon. */\n\tbranchName: string;\n\t/**\n\t * `true` when the target branch has the `protected` flag on Neon and the caller\n\t * did not pass `allowProtectedBranch: true`.\n\t */\n\tprotectedBranch: boolean;\n\t/**\n\t * `true` when the plan would override existing remote settings (TTL, `protected`\n\t * flag, compute settings on an existing endpoint) and the caller did not pass\n\t * `updateExisting: true`. Additive operations (enabling Neon Auth / Data API for\n\t * the first time) are **not** counted here — those are unambiguous and never\n\t * prompt.\n\t */\n\toverrideUpdates: boolean;\n}\n\n/**\n * Push a Neon branch policy to a specific project + branch.\n *\n * Filesystem- and env-agnostic: the caller supplies an already-validated `Config` object\n * (from `defineConfig` / `loadConfigFromFile`) and explicit `projectId` + `branch` in\n * `options`. `pushConfig` performs no `.neon` lookups and reads no `NEON_*` env vars except the API credential/host resolution documented on `apiKey`/`apiHost`.\n *\n * It will **not** create a project or branch — both must already exist on Neon.\n */\nexport async function pushConfig(\n\tconfig: Config,\n\toptions: PushConfigOptions,\n): Promise<PushResult> {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\n\t// Collected from the built-in bundler and returned on the result. A caller that injects\n\t// its own `bundleFunction` reports for itself, so this stays empty for them.\n\tconst warnings: string[] = [];\n\n\tconst dryRun = options.dryRun === true;\n\tconst updateExisting = options.updateExisting === true;\n\tconst allowProtectedBranch = options.allowProtectedBranch === true;\n\n\tconst remoteProject = await api.getProject(projectId);\n\n\tconst [branches, endpoints] = await Promise.all([\n\t\tapi.listBranches(remoteProject.id),\n\t\tapi.listEndpoints(remoteProject.id),\n\t]);\n\tconst branch = resolveRemoteBranch(options.branchId, branches);\n\tconst resolved = resolveConfig(config, {\n\t\tname: branch.name,\n\t\tid: branch.id,\n\t\texists: options.branchExists !== false,\n\t\t...(branch.parentId ? { parentId: branch.parentId } : {}),\n\t\tisDefault: branch.isDefault,\n\t\tisProtected: branch.protected,\n\t\t...(branch.expiresAt ? { expiresAt: branch.expiresAt } : {}),\n\t});\n\tconst services = await resolveServiceState({\n\t\tapi,\n\t\tprojectId: remoteProject.id,\n\t\tbranch,\n\t\twantsAuth: resolved.authEnabled,\n\t\twantsDataApi:\n\t\t\tresolved.dataApiEnabled || resolved.dataApiPolicy === \"disabled\",\n\t});\n\tconst remote: RemoteState = {\n\t\tprojectId: remoteProject.id,\n\t\tbranch,\n\t\tendpoint: endpoints.find(\n\t\t\t(ep) => ep.type === \"read_write\" && ep.branchId === branch.id,\n\t\t),\n\t\tservices,\n\t};\n\t// Only fetch Preview state when the policy actually uses it — and within that, only the\n\t// specific features the policy declares. So a policy that uses functions never probes\n\t// the AI Gateway, and `apply`/`plan` only fail on a Preview feature being unavailable\n\t// (404/503) when the policy actually asks for it.\n\tif (resolved.preview) {\n\t\tremote.preview = await resolvePreviewState({\n\t\t\tapi,\n\t\t\tprojectId: remoteProject.id,\n\t\t\tbranchId: branch.id,\n\t\t\tdesired: resolved.preview,\n\t\t\twantsTriggers: (resolved.triggers?.length ?? 0) > 0,\n\t\t});\n\t}\n\n\t// Always compute the plan with `updateExisting: true` so we can see what *would* be\n\t// overridden. The decision of whether to apply / prompt / fail is gated below using\n\t// the recorded steps.\n\tconst diff = diffConfig(resolved, remote, { updateExisting: true });\n\tconst overrideSteps = diff.plan.filter(isOverrideStep);\n\tconst needsOverrideConfirm = overrideSteps.length > 0 && !updateExisting;\n\tconst needsProtectedConfirm = branch.protected && !allowProtectedBranch;\n\n\tif (!dryRun && diff.conflicts.length > 0) {\n\t\tthrow new PushConflictError(diff.conflicts);\n\t}\n\n\tif (!dryRun && (needsOverrideConfirm || needsProtectedConfirm)) {\n\t\tif (options.confirm) {\n\t\t\tconst ok = await options.confirm({\n\t\t\t\tbranchName: branch.name,\n\t\t\t\tprotectedBranch: needsProtectedConfirm,\n\t\t\t\toverrideUpdates: needsOverrideConfirm,\n\t\t\t});\n\t\t\tif (!ok) {\n\t\t\t\tconst reasons: (\"protected-branch\" | \"override-updates\")[] = [];\n\t\t\t\tif (needsProtectedConfirm) reasons.push(\"protected-branch\");\n\t\t\t\tif (needsOverrideConfirm) reasons.push(\"override-updates\");\n\t\t\t\tthrow new PushAbortedError(branch.name, reasons);\n\t\t\t}\n\t\t} else if (needsOverrideConfirm) {\n\t\t\t// Legacy non-interactive fallback: surface the would-be drift as a\n\t\t\t// `PushConflictError` so programmatic callers that skipped both\n\t\t\t// `updateExisting` and `confirm` see the previous fail-fast behavior.\n\t\t\tconst legacy = diffConfig(resolved, remote, {\n\t\t\t\tupdateExisting: false,\n\t\t\t});\n\t\t\tthrow new PushConflictError(legacy.conflicts);\n\t\t}\n\t\t// Protected branch + no confirm callback: legacy default proceeds without\n\t\t// any extra check (no programmatic regression).\n\t}\n\n\tconst applied: AppliedChange[] = [\n\t\t{ kind: \"branch\", action: \"noop\", identifier: branch.name },\n\t];\n\n\tconst branchById = new Map(branches.map((b) => [b.id, b] as const));\n\tconst branchByName = new Map(branches.map((b) => [b.name, b] as const));\n\tconst ctx: ApplyContext = {\n\t\tapi,\n\t\tremoteProjectId: remoteProject.id,\n\t\tbranchById,\n\t\tbranchByName,\n\t\tbundleFunction:\n\t\t\toptions.bundleFunction ??\n\t\t\tmakeDefaultBundleFunction((message) => {\n\t\t\t\twarnings.push(message);\n\t\t\t}),\n\t\tdeploymentIdBySlug: new Map(),\n\t};\n\n\tfor (const step of diff.plan) {\n\t\tconst change = dryRun\n\t\t\t? synthesizeAppliedChange(step)\n\t\t\t: await applyStep(step, ctx);\n\t\tapplied.push(change);\n\t}\n\n\t// Surface each deployed function's invocation URL on its applied change so callers\n\t// (e.g. neonctl) can show users where to call it right after a push.\n\tawait enrichFunctionInvocationUrls({\n\t\tapi,\n\t\tprojectId: remoteProject.id,\n\t\tbranchId: branch.id,\n\t\tplan: diff.plan,\n\t\tapplied,\n\t\tpreview: remote.preview,\n\t\tdryRun,\n\t});\n\n\tconst result: PushResult = {\n\t\tprojectId: remoteProject.id,\n\t\tbranchId: branch.id,\n\t\tbranchName: branch.name,\n\t\tdryRun,\n\t\tapplied,\n\t\tconflicts: diff.conflicts,\n\t\twarnings,\n\t};\n\tif (remoteProject.orgId) result.orgId = remoteProject.orgId;\n\tenrichDeclaredCustomDomains({\n\t\tresult,\n\t\tpreview: remote.preview,\n\t\tfunctions: resolved.preview?.functions ?? [],\n\t\tapplied,\n\t\twarnings,\n\t});\n\treturn result;\n}\n\nfunction isOverrideStep(step: PlanStep): boolean {\n\treturn (\n\t\tstep.kind === \"update-branch-ttl\" ||\n\t\tstep.kind === \"update-branch-protected\" ||\n\t\tstep.kind === \"update-endpoint\" ||\n\t\tstep.kind === \"update-data-api\" ||\n\t\tstep.kind === \"disable-data-api\" ||\n\t\tstep.kind === \"retarget-custom-domain\"\n\t);\n}\n\n/**\n * Build an {@link AppliedChange} from a {@link PlanStep} without calling the Neon API.\n * Used by dry-run mode so callers see the same record shape they would on a live push,\n * just with no side effects. Identifiers are the branch names from the plan; any\n * sub-resource ids (`branchId`, `endpointId`) flow through unchanged when known.\n */\nfunction synthesizeAppliedChange(step: PlanStep): AppliedChange {\n\tswitch (step.kind) {\n\t\tcase \"update-branch-ttl\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: { field: \"ttl\", expiresAt: step.expiresAt },\n\t\t\t};\n\t\tcase \"update-branch-protected\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: { field: \"protected\", protected: step.protected },\n\t\t\t};\n\t\tcase \"update-endpoint\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: {\n\t\t\t\t\tfield: \"computeSettings\",\n\t\t\t\t\tendpointId: step.endpointId,\n\t\t\t\t\tsettings: step.settings,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"enable-auth\":\n\t\t\t// Pure branch on/off toggle: the target branch is redundant (same on\n\t\t\t// every row) and the database is auto-derived, not policy-chosen — so\n\t\t\t// there is nothing meaningful to surface in the change summary.\n\t\t\treturn { kind: \"service\", action: \"create\", identifier: \"auth\" };\n\t\tcase \"enable-data-api\":\n\t\t\treturn { kind: \"service\", action: \"create\", identifier: \"dataApi\" };\n\t\tcase \"update-data-api\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t\tdetails: { field: \"settings\", settings: step.settings },\n\t\t\t};\n\t\tcase \"disable-data-api\":\n\t\t\treturn { kind: \"service\", action: \"delete\", identifier: \"dataApi\" };\n\t\tcase \"create-bucket\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `bucket:${step.bucketName}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tbucketName: step.bucketName,\n\t\t\t\t\taccessLevel: step.accessLevel,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"deploy-function\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\t// The first deployment creates the function; a later one updates it.\n\t\t\t\taction: step.functionExists ? \"update\" : \"create\",\n\t\t\t\tidentifier: `function:${step.fn.slug}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tslug: step.fn.slug,\n\t\t\t\t\tsource: step.fn.source,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"create-trigger\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\tcase \"update-trigger\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\tcase \"register-custom-domain\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: step.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"retarget-custom-domain\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: step.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tpreviousSlug: step.previousSlug,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction createApiFromOptions(options: PushConfigOptions): NeonApi {\n\treturn createNeonApiFromOptions(\"pushConfig\", {\n\t\t...(options.apiKey ? { apiKey: options.apiKey } : {}),\n\t\t...(options.apiHost ? { apiHost: options.apiHost } : {}),\n\t});\n}\n\nfunction resolveRemoteBranch(\n\tbranchId: string,\n\tbranches: NeonBranchSnapshot[],\n): NeonBranchSnapshot {\n\tconst found = branches.find((b) => b.id === branchId);\n\tif (found) return found;\n\tthrow new PlatformError(\n\t\tErrorCode.BranchNotFound,\n\t\t[\n\t\t\t`pushConfig: branch id ${JSON.stringify(branchId)} does not exist on the project.`,\n\t\t\t`Available branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \") || \"(none)\"}.`,\n\t\t\t\"Pass an existing branch id, or create the branch first with the neonctl CLI.\",\n\t\t].join(\" \"),\n\t\t{ details: { branchId, available: branches.map((b) => b.id) } },\n\t);\n}\n\n/**\n * Pre-fetch the current state of branch-scoped integrations on the selected branch.\n */\nasync function resolveServiceState(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranch: NeonBranchSnapshot;\n\twantsAuth: boolean;\n\twantsDataApi: boolean;\n}): Promise<RemoteServiceState> {\n\tconst { api, projectId, branch, wantsAuth, wantsDataApi } = args;\n\tif (!wantsAuth && !wantsDataApi) {\n\t\treturn {\n\t\t\tdatabaseName: \"neondb\",\n\t\t\tauthEnabled: false,\n\t\t\tdataApiEnabled: false,\n\t\t};\n\t}\n\n\tconst databaseName = await pickServiceDatabaseName(\n\t\tapi,\n\t\tprojectId,\n\t\tbranch.id,\n\t);\n\n\tconst [auth, dataApi] = await Promise.all([\n\t\twantsAuth\n\t\t\t? api.getNeonAuth(projectId, branch.id)\n\t\t\t: Promise.resolve(null),\n\t\twantsDataApi\n\t\t\t? api.getNeonDataApi(projectId, branch.id, databaseName)\n\t\t\t: Promise.resolve(null),\n\t]);\n\tconst result: RemoteServiceState = {\n\t\tdatabaseName,\n\t\tauthEnabled: auth !== null,\n\t\tdataApiEnabled: dataApi !== null,\n\t};\n\t// Carry the current Data API settings (when reported) so the diff can detect settings\n\t// drift and plan an update. `null` distinguishes \"enabled but not reported\" from \"absent\".\n\tif (dataApi) result.dataApiSettings = dataApi.settings ?? null;\n\treturn result;\n}\n\n/**\n * Pre-fetch the current state of branch-scoped Preview features (buckets, functions) so the\n * diff can be computed additively. Only called when the policy has a `preview` block.\n *\n * The AI Gateway is not probed: it is always available (credential-gated, not per-branch\n * provisioned), so `preview.aiGateway` produces no plan step — it only drives the branch\n * credential's `ai_gateway:invoke` scope and the gateway env vars (`@neon/env`).\n */\nasync function resolvePreviewState(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tdesired: ResolvedPreviewConfig;\n\twantsTriggers: boolean;\n}): Promise<RemotePreviewState> {\n\tconst { api, projectId, branchId, desired, wantsTriggers } = args;\n\t// Read only the Preview features the policy declares: undeclared features can never\n\t// produce a plan step (see diffConfig), so probing them is pure waste — and would make\n\t// `plan`/`apply` fail on a feature the user didn't ask for if it's unavailable in the\n\t// project/region. A declared-but-unavailable feature still throws (failing the push),\n\t// which is the intended signal to enable it first.\n\tconst wantsCustomDomains = desired.functions.some(\n\t\t(fn) => (fn.customDomains?.length ?? 0) > 0,\n\t);\n\tconst customDomainApi = wantsCustomDomains\n\t\t? requireCustomDomainApi(api)\n\t\t: undefined;\n\tconst [buckets, functions, triggers, customDomains] = await Promise.all([\n\t\tdesired.buckets.length > 0\n\t\t\t? api.listBranchBuckets(projectId, branchId)\n\t\t\t: Promise.resolve([]),\n\t\tdesired.functions.length > 0\n\t\t\t? api.listBranchFunctions(projectId, branchId)\n\t\t\t: Promise.resolve([]),\n\t\twantsTriggers\n\t\t\t? api.listBranchTriggers(projectId, branchId)\n\t\t\t: Promise.resolve([]),\n\t\tcustomDomainApi\n\t\t\t? customDomainApi.listBranchCustomDomains(projectId, branchId)\n\t\t\t: Promise.resolve([]),\n\t]);\n\tconst preview: RemotePreviewState = { buckets, functions, triggers };\n\tif (wantsCustomDomains) preview.customDomains = customDomains;\n\treturn preview;\n}\n\n/**\n * Resolve the database name for a Data API integration. Auto-pick when the branch has\n * exactly one database; otherwise fall back to Neon's default (`neondb`) so the call\n * stays useful even on branches with multiple databases — push doesn't have a way to\n * surface a \"pick one\" prompt the way `fetchEnv` does.\n */\nasync function pickServiceDatabaseName(\n\tapi: NeonApi,\n\tprojectId: string,\n\tbranchId: string,\n): Promise<string> {\n\tconst databases = await api.listBranchDatabases(projectId, branchId);\n\tif (databases.length === 1) return databases[0].name;\n\tconst neondb = databases.find((d) => d.name === \"neondb\");\n\tif (neondb) return neondb.name;\n\treturn databases[0]?.name ?? \"neondb\";\n}\n\ninterface ApplyContext {\n\tapi: NeonApi;\n\tremoteProjectId: string;\n\tbranchById: Map<string, NeonBranchSnapshot>;\n\tbranchByName: Map<string, NeonBranchSnapshot>;\n\tbundleFunction: FunctionBundler;\n\tdeploymentIdBySlug: Map<string, number>;\n}\n\nasync function applyStep(\n\tstep: PlanStep,\n\tctx: ApplyContext,\n): Promise<AppliedChange> {\n\tswitch (step.kind) {\n\t\tcase \"update-branch-ttl\": {\n\t\t\tconst updated = await ctx.api.updateBranch(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{\n\t\t\t\t\texpiresAt: step.expiresAt ?? null,\n\t\t\t\t},\n\t\t\t);\n\t\t\tctx.branchById.set(updated.id, updated);\n\t\t\tctx.branchByName.set(updated.name, updated);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: updated.name,\n\t\t\t\tdetails: { field: \"ttl\", expiresAt: step.expiresAt },\n\t\t\t};\n\t\t}\n\t\tcase \"update-branch-protected\": {\n\t\t\tconst updated = await ctx.api.updateBranch(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{ protected: step.protected },\n\t\t\t);\n\t\t\tctx.branchById.set(updated.id, updated);\n\t\t\tctx.branchByName.set(updated.name, updated);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: updated.name,\n\t\t\t\tdetails: { field: \"protected\", protected: step.protected },\n\t\t\t};\n\t\t}\n\t\tcase \"update-endpoint\": {\n\t\t\tconst updated = await ctx.api.updateEndpoint(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.endpointId,\n\t\t\t\tstep.settings,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: {\n\t\t\t\t\tfield: \"computeSettings\",\n\t\t\t\t\tendpointId: updated.id,\n\t\t\t\t\tsettings: step.settings,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"enable-auth\": {\n\t\t\tawait ctx.api.enableNeonAuth(ctx.remoteProjectId, step.branchId, {\n\t\t\t\t...(step.databaseName\n\t\t\t\t\t? { databaseName: step.databaseName }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: \"auth\",\n\t\t\t};\n\t\t}\n\t\tcase \"enable-data-api\": {\n\t\t\tawait ctx.api.enableProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t\tstep.input,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t};\n\t\t}\n\t\tcase \"update-data-api\": {\n\t\t\tawait ctx.api.updateProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t\tstep.settings,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t\tdetails: { field: \"settings\", settings: step.settings },\n\t\t\t};\n\t\t}\n\t\tcase \"disable-data-api\": {\n\t\t\tawait ctx.api.deleteProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"delete\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t};\n\t\t}\n\t\tcase \"create-bucket\": {\n\t\t\tawait ctx.api.createBranchBucket(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{ name: step.bucketName, accessLevel: step.accessLevel },\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `bucket:${step.bucketName}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tbucketName: step.bucketName,\n\t\t\t\t\taccessLevel: step.accessLevel,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"deploy-function\": {\n\t\t\tconst bundle = await ctx.bundleFunction(step.fn);\n\t\t\t// Neon creates the function on its first deployment — there is no separate\n\t\t\t// create call — so a single deploy both creates (when absent) and ships code.\n\t\t\tconst deployment = await ctx.api.deployBranchFunction(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.fn.slug,\n\t\t\t\t{\n\t\t\t\t\tbundle,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t\tenvironment: step.fn.env,\n\t\t\t\t},\n\t\t\t);\n\t\t\tctx.deploymentIdBySlug.set(step.fn.slug, deployment.id);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: step.functionExists ? \"update\" : \"create\",\n\t\t\t\tidentifier: `function:${step.fn.slug}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tslug: step.fn.slug,\n\t\t\t\t\tsource: step.fn.source,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t\tdeploymentId: deployment.id,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"create-trigger\": {\n\t\t\tawait ctx.api.createBranchTrigger(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tcreateTriggerInput(step.functionSlug, step.trigger),\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\t}\n\t\tcase \"update-trigger\": {\n\t\t\tawait ctx.api.updateBranchTrigger(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.triggerId,\n\t\t\t\tupdateTriggerInput(step.functionSlug, step.trigger),\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\t}\n\t\tcase \"register-custom-domain\": {\n\t\t\tconst methods = requireCustomDomainApi(ctx.api);\n\t\t\tlet snapshot: NeonCustomDomainSnapshot;\n\t\t\ttry {\n\t\t\t\tsnapshot = await methods.registerBranchCustomDomain(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t\t{ domain: step.domain, functionSlug: step.functionSlug },\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tthrow rewriteCustomDomainConflict(err, step.domain);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: snapshot.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tcnameTarget: snapshot.cnameTarget,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"retarget-custom-domain\": {\n\t\t\tconst methods = requireCustomDomainApi(ctx.api);\n\t\t\tconst deploymentId = ctx.deploymentIdBySlug.get(step.functionSlug);\n\t\t\tif (deploymentId === undefined) {\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.ServerError,\n\t\t\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(step.functionSlug)}: this apply did not deploy that function.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait waitForCompletedFunctionDeployment({\n\t\t\t\tapi: ctx.api,\n\t\t\t\tprojectId: ctx.remoteProjectId,\n\t\t\t\tbranchId: step.branchId,\n\t\t\t\tslug: step.functionSlug,\n\t\t\t\tdeploymentId,\n\t\t\t});\n\t\t\tconst observed = (\n\t\t\t\tawait methods.listBranchCustomDomains(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t)\n\t\t\t).find((item) => item.domain === step.domain);\n\t\t\tif (\n\t\t\t\tobserved === undefined ||\n\t\t\t\tobserved.entityType !== \"function\" ||\n\t\t\t\tobserved.entityId !== step.previousSlug\n\t\t\t) {\n\t\t\t\tconst seen =\n\t\t\t\t\tobserved === undefined\n\t\t\t\t\t\t? \"no registration\"\n\t\t\t\t\t\t: `${observed.entityType} ${JSON.stringify(observed.entityId)}`;\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.Conflict,\n\t\t\t\t\t`Cannot retarget ${JSON.stringify(step.domain)}: planned owner was function ${JSON.stringify(step.previousSlug)}; observed ${seen}. DELETE was not attempted.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait methods.deleteBranchCustomDomain(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.domain,\n\t\t\t);\n\t\t\tlet snapshot: NeonCustomDomainSnapshot;\n\t\t\ttry {\n\t\t\t\tsnapshot = await methods.registerBranchCustomDomain(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t\t{ domain: step.domain, functionSlug: step.functionSlug },\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tconst rewritten = rewriteCustomDomainConflict(err, step.domain);\n\t\t\t\tconst message =\n\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t? rewritten.message\n\t\t\t\t\t\t: rewritten instanceof Error\n\t\t\t\t\t\t\t? rewritten.message\n\t\t\t\t\t\t\t: String(rewritten);\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t? rewritten.code\n\t\t\t\t\t\t: ErrorCode.ServerError,\n\t\t\t\t\t`Deleted the previous registration of ${JSON.stringify(step.domain)} (function ${JSON.stringify(step.previousSlug)}) but failed to register it on ${JSON.stringify(step.functionSlug)}. Inspect current ownership with \\`neon function domains list\\` before recovering. ${message}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: rewritten instanceof Error ? rewritten : err,\n\t\t\t\t\t\tdetails:\n\t\t\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t\t\t? { ...rewritten.details }\n\t\t\t\t\t\t\t\t: {},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: snapshot.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tpreviousSlug: step.previousSlug,\n\t\t\t\t\tcnameTarget: snapshot.cnameTarget,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * Add each deployed function's invocation URL to its applied-change `details` so callers\n * (e.g. neonctl) can show users where to call the function right after a push.\n *\n * The URL is read from the preview snapshot already fetched for the diff, which lists every\n * existing function with its `invocationUrl`. A function created by its *first* deployment in\n * this push is not in that snapshot, so when one is present we re-list the branch's functions\n * once to learn its freshly-minted URL. Skipped on dry-run (nothing was created) and\n * best-effort otherwise: a failed re-list omits the URL rather than failing a push that has\n * already applied.\n */\nasync function enrichFunctionInvocationUrls(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tplan: PlanStep[];\n\tapplied: AppliedChange[];\n\tpreview: RemotePreviewState | undefined;\n\tdryRun: boolean;\n}): Promise<void> {\n\tconst { api, projectId, branchId, plan, applied, preview, dryRun } = args;\n\tconst deployedSlugs = plan.flatMap((step) =>\n\t\tstep.kind === \"deploy-function\" ? [step.fn.slug] : [],\n\t);\n\tif (deployedSlugs.length === 0) return;\n\n\tconst urlBySlug = new Map<string, string>(\n\t\t(preview?.functions ?? []).map(\n\t\t\t(fn) => [fn.slug, fn.invocationUrl] as const,\n\t\t),\n\t);\n\n\t// A first-time deploy creates the function, so its URL isn't in the pre-fetch; re-list\n\t// once when any deployed slug is still missing a URL.\n\tconst hasMissingUrl = deployedSlugs.some((slug) => !urlBySlug.has(slug));\n\tif (hasMissingUrl && !dryRun) {\n\t\ttry {\n\t\t\tfor (const fn of await api.listBranchFunctions(\n\t\t\t\tprojectId,\n\t\t\t\tbranchId,\n\t\t\t)) {\n\t\t\t\turlBySlug.set(fn.slug, fn.invocationUrl);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Push already succeeded; surface what we can rather than failing here.\n\t\t}\n\t}\n\n\tfor (const change of applied) {\n\t\tconst slug = functionSlugFromIdentifier(change.identifier);\n\t\tif (slug === undefined) continue;\n\t\tconst invocationUrl = urlBySlug.get(slug);\n\t\tif (invocationUrl === undefined) continue;\n\t\tchange.details = { ...change.details, invocationUrl };\n\t}\n}\n\n/** Pull the function slug out of a `function:<slug>` applied-change identifier. */\nfunction functionSlugFromIdentifier(identifier: string): string | undefined {\n\tconst prefix = \"function:\";\n\treturn identifier.startsWith(prefix)\n\t\t? identifier.slice(prefix.length)\n\t\t: undefined;\n}\n\nasync function waitForCompletedFunctionDeployment(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tslug: string;\n\tdeploymentId: number;\n}): Promise<void> {\n\tconst get = args.api.getBranchFunction;\n\tif (!get) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.FeatureUnavailable,\n\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(args.slug)}: this NeonApi adapter does not implement getBranchFunction, so apply cannot confirm the function finished deploying.`,\n\t\t);\n\t}\n\tconst intervalMs =\n\t\tNumber(process.env.NEON_FUNCTIONS_POLL_INTERVAL_MS) || 2000;\n\tconst timeoutMs =\n\t\tNumber(process.env.NEON_FUNCTIONS_POLL_TIMEOUT_MS) || 600_000;\n\tconst deadline = Date.now() + timeoutMs;\n\tfor (;;) {\n\t\tconst fn = await get.call(\n\t\t\targs.api,\n\t\t\targs.projectId,\n\t\t\targs.branchId,\n\t\t\targs.slug,\n\t\t);\n\t\tconst dep = fn.currentDeployment;\n\t\t// GET can still report the previous deployment after this apply's POST returns.\n\t\tif (dep !== undefined && dep.id > args.deploymentId) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.ServerError,\n\t\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(args.slug)}: current deployment is ${dep.id}, this apply submitted ${args.deploymentId}; left the previous custom-domain registration in place.`,\n\t\t\t);\n\t\t}\n\t\tif (dep !== undefined && dep.id === args.deploymentId) {\n\t\t\tif (dep.status === \"completed\") return;\n\t\t\tif (dep.status === \"failed\") {\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.ServerError,\n\t\t\t\t\t`Deployment of function ${JSON.stringify(args.slug)} failed; left the previous custom-domain registration in place.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.ServerError,\n\t\t\t\t`Timed out waiting for function ${JSON.stringify(args.slug)} to finish deploying; left the previous custom-domain registration in place.`,\n\t\t\t);\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, intervalMs));\n\t}\n}\n\nfunction requireCustomDomainApi(api: NeonApi): {\n\tlistBranchCustomDomains: NonNullable<NeonApi[\"listBranchCustomDomains\"]>;\n\tregisterBranchCustomDomain: NonNullable<\n\t\tNeonApi[\"registerBranchCustomDomain\"]\n\t>;\n\tdeleteBranchCustomDomain: NonNullable<NeonApi[\"deleteBranchCustomDomain\"]>;\n} {\n\tconst list = api.listBranchCustomDomains;\n\tconst register = api.registerBranchCustomDomain;\n\tconst remove = api.deleteBranchCustomDomain;\n\tif (!list || !register || !remove) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.FeatureUnavailable,\n\t\t\t\"This NeonApi adapter does not implement custom domains. Implement listBranchCustomDomains, registerBranchCustomDomain, and deleteBranchCustomDomain, or remove customDomains from neon.ts.\",\n\t\t);\n\t}\n\treturn {\n\t\tlistBranchCustomDomains: list.bind(api),\n\t\tregisterBranchCustomDomain: register.bind(api),\n\t\tdeleteBranchCustomDomain: remove.bind(api),\n\t};\n}\n\nfunction rewriteCustomDomainConflict(err: unknown, domain: string): unknown {\n\tif (!(err instanceof PlatformError) || err.code !== ErrorCode.Conflict) {\n\t\treturn err;\n\t}\n\tconst neonMessage =\n\t\ttypeof err.details.neonMessage === \"string\"\n\t\t\t? err.details.neonMessage\n\t\t\t: undefined;\n\tconst requestId =\n\t\ttypeof err.details.requestId === \"string\"\n\t\t\t? err.details.requestId\n\t\t\t: undefined;\n\tconst status =\n\t\ttypeof err.details.status === \"number\" ? err.details.status : undefined;\n\tconst apiParts = [\n\t\tstatus !== undefined ? `HTTP ${status}` : undefined,\n\t\tneonMessage ? `Neon API said: \"${neonMessage}\"` : undefined,\n\t\trequestId ? `request id ${requestId}` : undefined,\n\t].filter((part): part is string => part !== undefined);\n\treturn new PlatformError(\n\t\tErrorCode.Conflict,\n\t\t[\n\t\t\t`Hostname ${JSON.stringify(domain)} is already registered to another resource.`,\n\t\t\tapiParts.length > 0 ? `(${apiParts.join(\"; \")})` : undefined,\n\t\t\t\"Declare it only on the branch that owns it (use the branch closure), or delete it there first with `neon function domains delete`.\",\n\t\t]\n\t\t\t.filter((part): part is string => part !== undefined)\n\t\t\t.join(\" \"),\n\t\t{ cause: err, details: { ...err.details } },\n\t);\n}\n\nfunction enrichDeclaredCustomDomains(args: {\n\tresult: PushResult;\n\tpreview: RemotePreviewState | undefined;\n\tfunctions: ResolvedFunctionConfig[];\n\tapplied: AppliedChange[];\n\twarnings: string[];\n}): void {\n\tconst declared: Array<{ domain: string; slug: string }> = [];\n\tfor (const fn of args.functions) {\n\t\tfor (const domain of fn.customDomains ?? []) {\n\t\t\tdeclared.push({ domain, slug: fn.slug });\n\t\t}\n\t}\n\tif (declared.length === 0) return;\n\n\tconst blockedDomains = new Set(\n\t\targs.result.conflicts.flatMap((conflict) => {\n\t\t\tif (conflict.field !== \"customDomain\") return [];\n\t\t\tconst match = /^custom domain \"([^\"]+)\"/.exec(conflict.reason);\n\t\t\treturn match?.[1] !== undefined ? [match[1]] : [];\n\t\t}),\n\t);\n\n\tconst cnameByDomain = new Map<string, string>();\n\tfor (const remote of args.preview?.customDomains ?? []) {\n\t\tif (blockedDomains.has(remote.domain)) continue;\n\t\tcnameByDomain.set(remote.domain, remote.cnameTarget);\n\t}\n\tfor (const change of args.applied) {\n\t\tconst domain =\n\t\t\ttypeof change.details?.domain === \"string\"\n\t\t\t\t? change.details.domain\n\t\t\t\t: undefined;\n\t\tconst cnameTarget = change.details?.cnameTarget;\n\t\tif (domain !== undefined && typeof cnameTarget === \"string\") {\n\t\t\tcnameByDomain.set(domain, cnameTarget);\n\t\t}\n\t}\n\n\targs.result.customDomains = declared.map(({ domain, slug }) => {\n\t\tconst entry: { domain: string; slug: string; cnameTarget?: string } = {\n\t\t\tdomain,\n\t\t\tslug,\n\t\t};\n\t\tconst cnameTarget = cnameByDomain.get(domain);\n\t\tif (cnameTarget !== undefined) entry.cnameTarget = cnameTarget;\n\t\tif (cnameTarget === \"\") {\n\t\t\targs.warnings.push(\n\t\t\t\t`No CNAME target for ${domain}; this region has no custom-domains front door.`,\n\t\t\t);\n\t\t}\n\t\treturn entry;\n\t});\n}\n\nfunction triggerChangeDetails(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): Record<string, unknown> {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\tfunctionSlug,\n\t\t\ttype: trigger.type,\n\t\t\tcron: trigger.cron,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\tfunctionSlug,\n\t\ttype: trigger.type,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tenabled: trigger.enabled,\n\t};\n}\n\nfunction createTriggerInput(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): CreateTriggerInput {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\ttype: \"schedule\",\n\t\t\tname: trigger.name,\n\t\t\tfunctionSlug,\n\t\t\tcron: trigger.cron,\n\t\t\tfunctionPath: trigger.functionPath,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"storage_object_created\",\n\t\tname: trigger.name,\n\t\tfunctionSlug,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tfunctionPath: trigger.functionPath,\n\t\tenabled: trigger.enabled,\n\t};\n}\n\nfunction updateTriggerInput(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): UpdateTriggerInput {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\ttype: \"schedule\",\n\t\t\tname: trigger.name,\n\t\t\tfunctionSlug,\n\t\t\tcron: trigger.cron,\n\t\t\tfunctionPath: trigger.functionPath,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"storage_object_created\",\n\t\tname: trigger.name,\n\t\tfunctionSlug,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tfunctionPath: trigger.functionPath,\n\t\tenabled: trigger.enabled,\n\t};\n}\n"],"mappings":";;AA2BA,MAAM,6BACJ,cACD,OAAO,OAAoD;CAC1D,MAAM,EAAE,wBAAwB,MAAM,OAAO;CAC7C,OAAO,oBAAoB,IAAI,EAAE,UAAU,CAAC;AAC7C;;;;;;;;;;AAoHD,eAAsB,WACrB,QACA,SACsB;C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ACtB,SAAS,QAAQ;CAClB;AACD;AAEA,SAAS,mBACR,cACA,SACqB;CACrB,IAAI,QAAQ,SAAS,YACpB,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;CAED,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,YAAY,QAAQ;EACpB,GAAI,QAAQ,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACjE,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;AACD"}
|
|
1
|
+
{"version":3,"file":"push-config.js","names":[],"sources":["../../src/lib/push-config.ts"],"sourcesContent":["import {\n\ttype AppliedChange,\n\ttype Config,\n\ttype CreateTriggerInput,\n\tcreateNeonApiFromOptions,\n\tdiffConfig,\n\tErrorCode,\n\ttype NeonApi,\n\ttype NeonBranchSnapshot,\n\ttype NeonCustomDomainSnapshot,\n\ttype PlanStep,\n\tPlatformError,\n\tPushAbortedError,\n\tPushConflictError,\n\ttype PushResult,\n\ttype RemotePreviewState,\n\ttype RemoteServiceState,\n\ttype RemoteState,\n\ttype ResolvedFunctionConfig,\n\ttype ResolvedFunctionTrigger,\n\ttype ResolvedPreviewConfig,\n\tresolveConfig,\n\ttype UpdateTriggerInput,\n} from \"@neon/config\";\nimport type { FunctionBundler } from \"./function-bundle.js\";\n\n// Eager loading would evaluate esbuild for callers that provide their own bundler.\nconst makeDefaultBundleFunction =\n\t(onWarning: (message: string) => void): FunctionBundler =>\n\tasync (fn: ResolvedFunctionConfig): Promise<Uint8Array> => {\n\t\tconst { buildFunctionBundle } = await import(\"./function-bundle.js\");\n\t\treturn buildFunctionBundle(fn, { onWarning });\n\t};\n\nexport interface PushConfigOptions {\n\t/**\n\t * Neon project id. **Required** — the management API addresses every branch through\n\t * its project, so there is no way to push without it. `pushConfig` never creates a\n\t * project; resolve the id yourself (e.g. via neonctl) and pass it in.\n\t */\n\tprojectId: string;\n\t/**\n\t * Neon branch id (`br-…`). **Required.** `pushConfig` never creates a branch — it must\n\t * already exist on the project. Resolve names to ids before calling.\n\t */\n\tbranchId: string;\n\t/** Neon API key. Falls back to `NEON_API_KEY` / neonctl credentials. Ignored when `api` is supplied. */\n\tapiKey?: string;\n\t/** Neon API base URL. Falls back to `NEON_API_HOST`, then production. */\n\tapiHost?: string;\n\t/**\n\t * Inject a custom NeonApi adapter. Primarily used by tests; production callers can rely\n\t * on the default real adapter built from `apiKey`.\n\t */\n\tapi?: NeonApi;\n\t/**\n\t * Whether to evaluate the policy as if the target branch **already exists** (the value of\n\t * `branch.exists` passed to the `defineConfig({ branch: (branch) => … })` closure). Defaults to `true`.\n\t *\n\t * Set to `false` to evaluate the policy as a **branch creation** — used by\n\t * {@link createBranch} right after it provisions a new branch, so creation-time tuning\n\t * gated on `!branch.exists` (TTL, compute settings, `parent`) actually resolves instead of\n\t * hitting the \"existing branch, leave as-is\" path. Only affects policy evaluation; the\n\t * branch must still physically exist on Neon (`pushConfig` never creates one).\n\t */\n\tbranchExists?: boolean;\n\t/**\n\t * Auto-confirm overriding existing remote settings.\n\t *\n\t * When `true`, mutable drift on the selected branch (TTL, `protected` flag, compute\n\t * settings) is applied as actual mutations and the override-confirm prompt is\n\t * skipped. When `false` (default) the behaviour depends on whether `confirm` is\n\t * supplied:\n\t * - With `confirm`: the callback is asked whether to apply the override.\n\t * - Without `confirm`: drift is reported as a `PushConflictError` (legacy\n\t * non-interactive default — preserved so programmatic SDK callers don't\n\t * silently start mutating remote state).\n\t */\n\tupdateExisting?: boolean;\n\t/**\n\t * Auto-confirm pushing to a protected branch.\n\t *\n\t * When `true`, no protected-branch confirmation is asked. When `false` (default):\n\t * - With `confirm`: the callback is asked.\n\t * - Without `confirm`: the push proceeds (legacy SDK default).\n\t */\n\tallowProtectedBranch?: boolean;\n\t/**\n\t * Optional confirmation callback. Invoked once with a single context object before\n\t * any mutations run when the push needs confirmation: pushing to a protected\n\t * branch (unless `allowProtectedBranch` is `true`) and/or applying mutable drift\n\t * (unless `updateExisting` is `true`).\n\t *\n\t * Both prompts collapse into a single callback invocation when both apply, so the\n\t * CLI can render one combined \"are you sure?\" prompt.\n\t *\n\t * Resolves to `true` to proceed, `false` to abort with {@link PushAbortedError}.\n\t *\n\t * Never invoked on `dryRun`.\n\t */\n\tconfirm?: (context: PushConfirmContext) => boolean | Promise<boolean>;\n\t/** Inject to deploy without this package loading esbuild. */\n\tbundleFunction?: FunctionBundler;\n\t/**\n\t * When `true`, compute the full plan against the live remote state but **do not\n\t * execute any mutations**. The resulting `PushResult.applied` array records every\n\t * change that *would* run on a real push (with the same action / identifier / details\n\t * shape, so the existing CLI summary formatter just works), and conflicts are\n\t * reported instead of thrown.\n\t *\n\t * Used by `plan(config, branchId)` and any caller that wants a \"would this push do\n\t * something dangerous?\" check before invoking `pushConfig` for real.\n\t */\n\tdryRun?: boolean;\n}\n\n/**\n * Context handed to a {@link PushConfigOptions.confirm} callback. Both flags can be\n * `true` simultaneously when the push targets a protected branch *and* would override\n * existing settings — render a single combined prompt covering both reasons.\n */\nexport interface PushConfirmContext {\n\t/** Name of the target branch on Neon. */\n\tbranchName: string;\n\t/**\n\t * `true` when the target branch has the `protected` flag on Neon and the caller\n\t * did not pass `allowProtectedBranch: true`.\n\t */\n\tprotectedBranch: boolean;\n\t/**\n\t * `true` when the plan would override existing remote settings (TTL, `protected`\n\t * flag, compute settings on an existing endpoint) and the caller did not pass\n\t * `updateExisting: true`. Additive operations (enabling Neon Auth / Data API for\n\t * the first time) are **not** counted here — those are unambiguous and never\n\t * prompt.\n\t */\n\toverrideUpdates: boolean;\n}\n\n/**\n * Push a Neon branch policy to a specific project + branch.\n *\n * Filesystem- and env-agnostic: the caller supplies an already-validated `Config` object\n * (from `defineConfig` / `loadConfigFromFile`) and explicit `projectId` + `branch` in\n * `options`. `pushConfig` performs no `.neon` lookups and reads no `NEON_*` env vars except the API credential/host resolution documented on `apiKey`/`apiHost`.\n *\n * It will **not** create a project or branch — both must already exist on Neon.\n */\nexport async function pushConfig(\n\tconfig: Config,\n\toptions: PushConfigOptions,\n): Promise<PushResult> {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\n\t// Collected from the built-in bundler and returned on the result. A caller that injects\n\t// its own `bundleFunction` reports for itself, so this stays empty for them.\n\tconst warnings: string[] = [];\n\n\tconst dryRun = options.dryRun === true;\n\tconst updateExisting = options.updateExisting === true;\n\tconst allowProtectedBranch = options.allowProtectedBranch === true;\n\n\t// Same scheduling as `pullConfig`: independent reads start together and are awaited in\n\t// the order they used to run, so the first error reported is unchanged.\n\tconst projectRead = started(() => api.getProject(projectId));\n\tconst listsRead = started(() =>\n\t\tPromise.all([\n\t\t\thandled(api.listBranches(projectId)),\n\t\t\thandled(api.listEndpoints(projectId)),\n\t\t]),\n\t);\n\tconst remoteProject = await projectRead;\n\tconst [branches, endpoints] = await listsRead;\n\tconst branch = resolveRemoteBranch(options.branchId, branches);\n\tconst resolved = resolveConfig(config, {\n\t\tname: branch.name,\n\t\tid: branch.id,\n\t\texists: options.branchExists !== false,\n\t\t...(branch.parentId ? { parentId: branch.parentId } : {}),\n\t\tisDefault: branch.isDefault,\n\t\tisProtected: branch.protected,\n\t\t...(branch.expiresAt ? { expiresAt: branch.expiresAt } : {}),\n\t});\n\tconst servicesRead = started(() =>\n\t\tresolveServiceState({\n\t\t\tapi,\n\t\t\tprojectId: remoteProject.id,\n\t\t\tbranch,\n\t\t\twantsAuth: resolved.authEnabled,\n\t\t\twantsDataApi:\n\t\t\t\tresolved.dataApiEnabled ||\n\t\t\t\tresolved.dataApiPolicy === \"disabled\",\n\t\t}),\n\t);\n\t// Only fetch Preview state when the policy actually uses it — and within that, only the\n\t// specific features the policy declares. So a policy that uses functions never probes\n\t// the AI Gateway, and `apply`/`plan` only fail on a Preview feature being unavailable\n\t// (404/503) when the policy actually asks for it.\n\tconst desiredPreview = resolved.preview;\n\tconst previewRead = desiredPreview\n\t\t? started(() =>\n\t\t\t\tresolvePreviewState({\n\t\t\t\t\tapi,\n\t\t\t\t\tprojectId: remoteProject.id,\n\t\t\t\t\tbranchId: branch.id,\n\t\t\t\t\tdesired: desiredPreview,\n\t\t\t\t\twantsTriggers: (resolved.triggers?.length ?? 0) > 0,\n\t\t\t\t}),\n\t\t\t)\n\t\t: undefined;\n\tconst services = await servicesRead;\n\tconst remote: RemoteState = {\n\t\tprojectId: remoteProject.id,\n\t\tbranch,\n\t\tendpoint: endpoints.find(\n\t\t\t(ep) => ep.type === \"read_write\" && ep.branchId === branch.id,\n\t\t),\n\t\tservices,\n\t};\n\tif (previewRead) {\n\t\tremote.preview = await previewRead;\n\t}\n\n\t// Always compute the plan with `updateExisting: true` so we can see what *would* be\n\t// overridden. The decision of whether to apply / prompt / fail is gated below using\n\t// the recorded steps.\n\tconst diff = diffConfig(resolved, remote, { updateExisting: true });\n\tconst overrideSteps = diff.plan.filter(isOverrideStep);\n\tconst needsOverrideConfirm = overrideSteps.length > 0 && !updateExisting;\n\tconst needsProtectedConfirm = branch.protected && !allowProtectedBranch;\n\n\tif (!dryRun && diff.conflicts.length > 0) {\n\t\tthrow new PushConflictError(diff.conflicts);\n\t}\n\n\tif (!dryRun && (needsOverrideConfirm || needsProtectedConfirm)) {\n\t\tif (options.confirm) {\n\t\t\tconst ok = await options.confirm({\n\t\t\t\tbranchName: branch.name,\n\t\t\t\tprotectedBranch: needsProtectedConfirm,\n\t\t\t\toverrideUpdates: needsOverrideConfirm,\n\t\t\t});\n\t\t\tif (!ok) {\n\t\t\t\tconst reasons: (\"protected-branch\" | \"override-updates\")[] = [];\n\t\t\t\tif (needsProtectedConfirm) reasons.push(\"protected-branch\");\n\t\t\t\tif (needsOverrideConfirm) reasons.push(\"override-updates\");\n\t\t\t\tthrow new PushAbortedError(branch.name, reasons);\n\t\t\t}\n\t\t} else if (needsOverrideConfirm) {\n\t\t\t// Legacy non-interactive fallback: surface the would-be drift as a\n\t\t\t// `PushConflictError` so programmatic callers that skipped both\n\t\t\t// `updateExisting` and `confirm` see the previous fail-fast behavior.\n\t\t\tconst legacy = diffConfig(resolved, remote, {\n\t\t\t\tupdateExisting: false,\n\t\t\t});\n\t\t\tthrow new PushConflictError(legacy.conflicts);\n\t\t}\n\t\t// Protected branch + no confirm callback: legacy default proceeds without\n\t\t// any extra check (no programmatic regression).\n\t}\n\n\tconst applied: AppliedChange[] = [\n\t\t{ kind: \"branch\", action: \"noop\", identifier: branch.name },\n\t];\n\n\tconst branchById = new Map(branches.map((b) => [b.id, b] as const));\n\tconst branchByName = new Map(branches.map((b) => [b.name, b] as const));\n\tconst ctx: ApplyContext = {\n\t\tapi,\n\t\tremoteProjectId: remoteProject.id,\n\t\tbranchById,\n\t\tbranchByName,\n\t\tbundleFunction:\n\t\t\toptions.bundleFunction ??\n\t\t\tmakeDefaultBundleFunction((message) => {\n\t\t\t\twarnings.push(message);\n\t\t\t}),\n\t\tdeploymentIdBySlug: new Map(),\n\t};\n\n\tfor (const step of diff.plan) {\n\t\tconst change = dryRun\n\t\t\t? synthesizeAppliedChange(step)\n\t\t\t: await applyStep(step, ctx);\n\t\tapplied.push(change);\n\t}\n\n\t// Surface each deployed function's invocation URL on its applied change so callers\n\t// (e.g. neonctl) can show users where to call it right after a push.\n\tawait enrichFunctionInvocationUrls({\n\t\tapi,\n\t\tprojectId: remoteProject.id,\n\t\tbranchId: branch.id,\n\t\tplan: diff.plan,\n\t\tapplied,\n\t\tpreview: remote.preview,\n\t\tdryRun,\n\t});\n\n\tconst result: PushResult = {\n\t\tprojectId: remoteProject.id,\n\t\tbranchId: branch.id,\n\t\tbranchName: branch.name,\n\t\tdryRun,\n\t\tapplied,\n\t\tconflicts: diff.conflicts,\n\t\twarnings,\n\t};\n\tif (remoteProject.orgId) result.orgId = remoteProject.orgId;\n\tenrichDeclaredCustomDomains({\n\t\tresult,\n\t\tpreview: remote.preview,\n\t\tfunctions: resolved.preview?.functions ?? [],\n\t\tapplied,\n\t\twarnings,\n\t});\n\treturn result;\n}\n\nfunction isOverrideStep(step: PlanStep): boolean {\n\treturn (\n\t\tstep.kind === \"update-branch-ttl\" ||\n\t\tstep.kind === \"update-branch-protected\" ||\n\t\tstep.kind === \"update-endpoint\" ||\n\t\tstep.kind === \"update-data-api\" ||\n\t\tstep.kind === \"disable-data-api\" ||\n\t\tstep.kind === \"retarget-custom-domain\"\n\t);\n}\n\n/**\n * Build an {@link AppliedChange} from a {@link PlanStep} without calling the Neon API.\n * Used by dry-run mode so callers see the same record shape they would on a live push,\n * just with no side effects. Identifiers are the branch names from the plan; any\n * sub-resource ids (`branchId`, `endpointId`) flow through unchanged when known.\n */\nfunction synthesizeAppliedChange(step: PlanStep): AppliedChange {\n\tswitch (step.kind) {\n\t\tcase \"update-branch-ttl\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: { field: \"ttl\", expiresAt: step.expiresAt },\n\t\t\t};\n\t\tcase \"update-branch-protected\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: { field: \"protected\", protected: step.protected },\n\t\t\t};\n\t\tcase \"update-endpoint\":\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: {\n\t\t\t\t\tfield: \"computeSettings\",\n\t\t\t\t\tendpointId: step.endpointId,\n\t\t\t\t\tsettings: step.settings,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"enable-auth\":\n\t\t\t// Pure branch on/off toggle: the target branch is redundant (same on\n\t\t\t// every row) and the database is auto-derived, not policy-chosen — so\n\t\t\t// there is nothing meaningful to surface in the change summary.\n\t\t\treturn { kind: \"service\", action: \"create\", identifier: \"auth\" };\n\t\tcase \"enable-data-api\":\n\t\t\treturn { kind: \"service\", action: \"create\", identifier: \"dataApi\" };\n\t\tcase \"update-data-api\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t\tdetails: { field: \"settings\", settings: step.settings },\n\t\t\t};\n\t\tcase \"disable-data-api\":\n\t\t\treturn { kind: \"service\", action: \"delete\", identifier: \"dataApi\" };\n\t\tcase \"create-bucket\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `bucket:${step.bucketName}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tbucketName: step.bucketName,\n\t\t\t\t\taccessLevel: step.accessLevel,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"deploy-function\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\t// The first deployment creates the function; a later one updates it.\n\t\t\t\taction: step.functionExists ? \"update\" : \"create\",\n\t\t\t\tidentifier: `function:${step.fn.slug}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tslug: step.fn.slug,\n\t\t\t\t\tsource: step.fn.source,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"create-trigger\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\tcase \"update-trigger\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\tcase \"register-custom-domain\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: step.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t},\n\t\t\t};\n\t\tcase \"retarget-custom-domain\":\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: step.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tpreviousSlug: step.previousSlug,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction createApiFromOptions(options: PushConfigOptions): NeonApi {\n\treturn createNeonApiFromOptions(\"pushConfig\", {\n\t\t...(options.apiKey ? { apiKey: options.apiKey } : {}),\n\t\t...(options.apiHost ? { apiHost: options.apiHost } : {}),\n\t});\n}\n\nfunction resolveRemoteBranch(\n\tbranchId: string,\n\tbranches: NeonBranchSnapshot[],\n): NeonBranchSnapshot {\n\tconst found = branches.find((b) => b.id === branchId);\n\tif (found) return found;\n\tthrow new PlatformError(\n\t\tErrorCode.BranchNotFound,\n\t\t[\n\t\t\t`pushConfig: branch id ${JSON.stringify(branchId)} does not exist on the project.`,\n\t\t\t`Available branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \") || \"(none)\"}.`,\n\t\t\t\"Pass an existing branch id, or create the branch first with the neonctl CLI.\",\n\t\t].join(\" \"),\n\t\t{ details: { branchId, available: branches.map((b) => b.id) } },\n\t);\n}\n\n/**\n * Starts a read now and keeps an unread rejection from crashing the process; the caller\n * awaits it (and sees the error) when its turn comes. The read is called synchronously and\n * its own promise returned, so errors surface in the same order as a direct call; a\n * synchronous throw becomes the returned rejection.\n */\nfunction started<T>(read: () => Promise<T>): Promise<T> {\n\tlet promise: Promise<T>;\n\ttry {\n\t\tpromise = read();\n\t} catch (error) {\n\t\tpromise = Promise.reject(error);\n\t}\n\tpromise.catch(() => undefined);\n\treturn promise;\n}\n\n/**\n * Marks a `Promise.all` member's rejection as handled, so a later member's synchronous\n * throw cannot leave it unobserved. `Promise.all` still reports it.\n */\nfunction handled<T>(promise: Promise<T>): Promise<T> {\n\tpromise.catch(() => undefined);\n\treturn promise;\n}\n\n/**\n * Pre-fetch the current state of branch-scoped integrations on the selected branch.\n */\nasync function resolveServiceState(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranch: NeonBranchSnapshot;\n\twantsAuth: boolean;\n\twantsDataApi: boolean;\n}): Promise<RemoteServiceState> {\n\tconst { api, projectId, branch, wantsAuth, wantsDataApi } = args;\n\tif (!wantsAuth && !wantsDataApi) {\n\t\treturn {\n\t\t\tdatabaseName: \"neondb\",\n\t\t\tauthEnabled: false,\n\t\t\tdataApiEnabled: false,\n\t\t};\n\t}\n\n\tconst databaseName = await pickServiceDatabaseName(\n\t\tapi,\n\t\tprojectId,\n\t\tbranch.id,\n\t);\n\n\tconst [auth, dataApi] = await Promise.all([\n\t\twantsAuth\n\t\t\t? handled(api.getNeonAuth(projectId, branch.id))\n\t\t\t: Promise.resolve(null),\n\t\twantsDataApi\n\t\t\t? handled(api.getNeonDataApi(projectId, branch.id, databaseName))\n\t\t\t: Promise.resolve(null),\n\t]);\n\tconst result: RemoteServiceState = {\n\t\tdatabaseName,\n\t\tauthEnabled: auth !== null,\n\t\tdataApiEnabled: dataApi !== null,\n\t};\n\t// Carry the current Data API settings (when reported) so the diff can detect settings\n\t// drift and plan an update. `null` distinguishes \"enabled but not reported\" from \"absent\".\n\tif (dataApi) result.dataApiSettings = dataApi.settings ?? null;\n\treturn result;\n}\n\n/**\n * Pre-fetch the current state of branch-scoped Preview features (buckets, functions) so the\n * diff can be computed additively. Only called when the policy has a `preview` block.\n *\n * The AI Gateway is not probed: it is always available (credential-gated, not per-branch\n * provisioned), so `preview.aiGateway` produces no plan step — it only drives the branch\n * credential's `ai_gateway:invoke` scope and the gateway env vars (`@neon/env`).\n */\nasync function resolvePreviewState(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tdesired: ResolvedPreviewConfig;\n\twantsTriggers: boolean;\n}): Promise<RemotePreviewState> {\n\tconst { api, projectId, branchId, desired, wantsTriggers } = args;\n\t// Read only the Preview features the policy declares: undeclared features can never\n\t// produce a plan step (see diffConfig), so probing them is pure waste — and would make\n\t// `plan`/`apply` fail on a feature the user didn't ask for if it's unavailable in the\n\t// project/region. A declared-but-unavailable feature still throws (failing the push),\n\t// which is the intended signal to enable it first.\n\tconst wantsCustomDomains = desired.functions.some(\n\t\t(fn) => (fn.customDomains?.length ?? 0) > 0,\n\t);\n\tconst customDomainApi = wantsCustomDomains\n\t\t? requireCustomDomainApi(api)\n\t\t: undefined;\n\tconst [buckets, functions, triggers, customDomains] = await Promise.all([\n\t\tdesired.buckets.length > 0\n\t\t\t? handled(api.listBranchBuckets(projectId, branchId))\n\t\t\t: Promise.resolve([]),\n\t\tdesired.functions.length > 0\n\t\t\t? handled(api.listBranchFunctions(projectId, branchId))\n\t\t\t: Promise.resolve([]),\n\t\twantsTriggers\n\t\t\t? handled(api.listBranchTriggers(projectId, branchId))\n\t\t\t: Promise.resolve([]),\n\t\tcustomDomainApi\n\t\t\t? handled(\n\t\t\t\t\tcustomDomainApi.listBranchCustomDomains(\n\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\tbranchId,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: Promise.resolve([]),\n\t]);\n\tconst preview: RemotePreviewState = { buckets, functions, triggers };\n\tif (wantsCustomDomains) preview.customDomains = customDomains;\n\treturn preview;\n}\n\n/**\n * Resolve the database name for a Data API integration. Auto-pick when the branch has\n * exactly one database; otherwise fall back to Neon's default (`neondb`) so the call\n * stays useful even on branches with multiple databases — push doesn't have a way to\n * surface a \"pick one\" prompt the way `fetchEnv` does.\n */\nasync function pickServiceDatabaseName(\n\tapi: NeonApi,\n\tprojectId: string,\n\tbranchId: string,\n): Promise<string> {\n\tconst databases = await api.listBranchDatabases(projectId, branchId);\n\tif (databases.length === 1) return databases[0].name;\n\tconst neondb = databases.find((d) => d.name === \"neondb\");\n\tif (neondb) return neondb.name;\n\treturn databases[0]?.name ?? \"neondb\";\n}\n\ninterface ApplyContext {\n\tapi: NeonApi;\n\tremoteProjectId: string;\n\tbranchById: Map<string, NeonBranchSnapshot>;\n\tbranchByName: Map<string, NeonBranchSnapshot>;\n\tbundleFunction: FunctionBundler;\n\tdeploymentIdBySlug: Map<string, number>;\n}\n\nasync function applyStep(\n\tstep: PlanStep,\n\tctx: ApplyContext,\n): Promise<AppliedChange> {\n\tswitch (step.kind) {\n\t\tcase \"update-branch-ttl\": {\n\t\t\tconst updated = await ctx.api.updateBranch(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{\n\t\t\t\t\texpiresAt: step.expiresAt ?? null,\n\t\t\t\t},\n\t\t\t);\n\t\t\tctx.branchById.set(updated.id, updated);\n\t\t\tctx.branchByName.set(updated.name, updated);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: updated.name,\n\t\t\t\tdetails: { field: \"ttl\", expiresAt: step.expiresAt },\n\t\t\t};\n\t\t}\n\t\tcase \"update-branch-protected\": {\n\t\t\tconst updated = await ctx.api.updateBranch(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{ protected: step.protected },\n\t\t\t);\n\t\t\tctx.branchById.set(updated.id, updated);\n\t\t\tctx.branchByName.set(updated.name, updated);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: updated.name,\n\t\t\t\tdetails: { field: \"protected\", protected: step.protected },\n\t\t\t};\n\t\t}\n\t\tcase \"update-endpoint\": {\n\t\t\tconst updated = await ctx.api.updateEndpoint(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.endpointId,\n\t\t\t\tstep.settings,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"branch\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: step.branchName,\n\t\t\t\tdetails: {\n\t\t\t\t\tfield: \"computeSettings\",\n\t\t\t\t\tendpointId: updated.id,\n\t\t\t\t\tsettings: step.settings,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"enable-auth\": {\n\t\t\tawait ctx.api.enableNeonAuth(ctx.remoteProjectId, step.branchId, {\n\t\t\t\t...(step.databaseName\n\t\t\t\t\t? { databaseName: step.databaseName }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: \"auth\",\n\t\t\t};\n\t\t}\n\t\tcase \"enable-data-api\": {\n\t\t\tawait ctx.api.enableProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t\tstep.input,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t};\n\t\t}\n\t\tcase \"update-data-api\": {\n\t\t\tawait ctx.api.updateProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t\tstep.settings,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t\tdetails: { field: \"settings\", settings: step.settings },\n\t\t\t};\n\t\t}\n\t\tcase \"disable-data-api\": {\n\t\t\tawait ctx.api.deleteProjectBranchDataApi(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.databaseName,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"delete\",\n\t\t\t\tidentifier: \"dataApi\",\n\t\t\t};\n\t\t}\n\t\tcase \"create-bucket\": {\n\t\t\tawait ctx.api.createBranchBucket(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\t{ name: step.bucketName, accessLevel: step.accessLevel },\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `bucket:${step.bucketName}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tbucketName: step.bucketName,\n\t\t\t\t\taccessLevel: step.accessLevel,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"deploy-function\": {\n\t\t\tconst bundle = await ctx.bundleFunction(step.fn);\n\t\t\t// Neon creates the function on its first deployment — there is no separate\n\t\t\t// create call — so a single deploy both creates (when absent) and ships code.\n\t\t\tconst deployment = await ctx.api.deployBranchFunction(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.fn.slug,\n\t\t\t\t{\n\t\t\t\t\tbundle,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t\tenvironment: step.fn.env,\n\t\t\t\t},\n\t\t\t);\n\t\t\tctx.deploymentIdBySlug.set(step.fn.slug, deployment.id);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: step.functionExists ? \"update\" : \"create\",\n\t\t\t\tidentifier: `function:${step.fn.slug}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tslug: step.fn.slug,\n\t\t\t\t\tsource: step.fn.source,\n\t\t\t\t\truntime: step.fn.runtime,\n\t\t\t\t\tdeploymentId: deployment.id,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"create-trigger\": {\n\t\t\tawait ctx.api.createBranchTrigger(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tcreateTriggerInput(step.functionSlug, step.trigger),\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\t}\n\t\tcase \"update-trigger\": {\n\t\t\tawait ctx.api.updateBranchTrigger(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.triggerId,\n\t\t\t\tupdateTriggerInput(step.functionSlug, step.trigger),\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `trigger:${step.functionSlug}:${step.trigger.name}`,\n\t\t\t\tdetails: triggerChangeDetails(step.functionSlug, step.trigger),\n\t\t\t};\n\t\t}\n\t\tcase \"register-custom-domain\": {\n\t\t\tconst methods = requireCustomDomainApi(ctx.api);\n\t\t\tlet snapshot: NeonCustomDomainSnapshot;\n\t\t\ttry {\n\t\t\t\tsnapshot = await methods.registerBranchCustomDomain(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t\t{ domain: step.domain, functionSlug: step.functionSlug },\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tthrow rewriteCustomDomainConflict(err, step.domain);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"create\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: snapshot.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tcnameTarget: snapshot.cnameTarget,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase \"retarget-custom-domain\": {\n\t\t\tconst methods = requireCustomDomainApi(ctx.api);\n\t\t\tconst deploymentId = ctx.deploymentIdBySlug.get(step.functionSlug);\n\t\t\tif (deploymentId === undefined) {\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.ServerError,\n\t\t\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(step.functionSlug)}: this apply did not deploy that function.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait waitForCompletedFunctionDeployment({\n\t\t\t\tapi: ctx.api,\n\t\t\t\tprojectId: ctx.remoteProjectId,\n\t\t\t\tbranchId: step.branchId,\n\t\t\t\tslug: step.functionSlug,\n\t\t\t\tdeploymentId,\n\t\t\t});\n\t\t\tconst observed = (\n\t\t\t\tawait methods.listBranchCustomDomains(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t)\n\t\t\t).find((item) => item.domain === step.domain);\n\t\t\tif (\n\t\t\t\tobserved === undefined ||\n\t\t\t\tobserved.entityType !== \"function\" ||\n\t\t\t\tobserved.entityId !== step.previousSlug\n\t\t\t) {\n\t\t\t\tconst seen =\n\t\t\t\t\tobserved === undefined\n\t\t\t\t\t\t? \"no registration\"\n\t\t\t\t\t\t: `${observed.entityType} ${JSON.stringify(observed.entityId)}`;\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.Conflict,\n\t\t\t\t\t`Cannot retarget ${JSON.stringify(step.domain)}: planned owner was function ${JSON.stringify(step.previousSlug)}; observed ${seen}. DELETE was not attempted.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait methods.deleteBranchCustomDomain(\n\t\t\t\tctx.remoteProjectId,\n\t\t\t\tstep.branchId,\n\t\t\t\tstep.domain,\n\t\t\t);\n\t\t\tlet snapshot: NeonCustomDomainSnapshot;\n\t\t\ttry {\n\t\t\t\tsnapshot = await methods.registerBranchCustomDomain(\n\t\t\t\t\tctx.remoteProjectId,\n\t\t\t\t\tstep.branchId,\n\t\t\t\t\t{ domain: step.domain, functionSlug: step.functionSlug },\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tconst rewritten = rewriteCustomDomainConflict(err, step.domain);\n\t\t\t\tconst message =\n\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t? rewritten.message\n\t\t\t\t\t\t: rewritten instanceof Error\n\t\t\t\t\t\t\t? rewritten.message\n\t\t\t\t\t\t\t: String(rewritten);\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t? rewritten.code\n\t\t\t\t\t\t: ErrorCode.ServerError,\n\t\t\t\t\t`Deleted the previous registration of ${JSON.stringify(step.domain)} (function ${JSON.stringify(step.previousSlug)}) but failed to register it on ${JSON.stringify(step.functionSlug)}. Inspect current ownership with \\`neon function domains list\\` before recovering. ${message}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: rewritten instanceof Error ? rewritten : err,\n\t\t\t\t\t\tdetails:\n\t\t\t\t\t\t\trewritten instanceof PlatformError\n\t\t\t\t\t\t\t\t? { ...rewritten.details }\n\t\t\t\t\t\t\t\t: {},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"service\",\n\t\t\t\taction: \"update\",\n\t\t\t\tidentifier: `domain:${step.domain}`,\n\t\t\t\tdetails: {\n\t\t\t\t\tdomain: snapshot.domain,\n\t\t\t\t\tslug: step.functionSlug,\n\t\t\t\t\tpreviousSlug: step.previousSlug,\n\t\t\t\t\tcnameTarget: snapshot.cnameTarget,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * Add each deployed function's invocation URL to its applied-change `details` so callers\n * (e.g. neonctl) can show users where to call the function right after a push.\n *\n * The URL is read from the preview snapshot already fetched for the diff, which lists every\n * existing function with its `invocationUrl`. A function created by its *first* deployment in\n * this push is not in that snapshot, so when one is present we re-list the branch's functions\n * once to learn its freshly-minted URL. Skipped on dry-run (nothing was created) and\n * best-effort otherwise: a failed re-list omits the URL rather than failing a push that has\n * already applied.\n */\nasync function enrichFunctionInvocationUrls(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tplan: PlanStep[];\n\tapplied: AppliedChange[];\n\tpreview: RemotePreviewState | undefined;\n\tdryRun: boolean;\n}): Promise<void> {\n\tconst { api, projectId, branchId, plan, applied, preview, dryRun } = args;\n\tconst deployedSlugs = plan.flatMap((step) =>\n\t\tstep.kind === \"deploy-function\" ? [step.fn.slug] : [],\n\t);\n\tif (deployedSlugs.length === 0) return;\n\n\tconst urlBySlug = new Map<string, string>(\n\t\t(preview?.functions ?? []).map(\n\t\t\t(fn) => [fn.slug, fn.invocationUrl] as const,\n\t\t),\n\t);\n\n\t// A first-time deploy creates the function, so its URL isn't in the pre-fetch; re-list\n\t// once when any deployed slug is still missing a URL.\n\tconst hasMissingUrl = deployedSlugs.some((slug) => !urlBySlug.has(slug));\n\tif (hasMissingUrl && !dryRun) {\n\t\ttry {\n\t\t\tfor (const fn of await api.listBranchFunctions(\n\t\t\t\tprojectId,\n\t\t\t\tbranchId,\n\t\t\t)) {\n\t\t\t\turlBySlug.set(fn.slug, fn.invocationUrl);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Push already succeeded; surface what we can rather than failing here.\n\t\t}\n\t}\n\n\tfor (const change of applied) {\n\t\tconst slug = functionSlugFromIdentifier(change.identifier);\n\t\tif (slug === undefined) continue;\n\t\tconst invocationUrl = urlBySlug.get(slug);\n\t\tif (invocationUrl === undefined) continue;\n\t\tchange.details = { ...change.details, invocationUrl };\n\t}\n}\n\n/** Pull the function slug out of a `function:<slug>` applied-change identifier. */\nfunction functionSlugFromIdentifier(identifier: string): string | undefined {\n\tconst prefix = \"function:\";\n\treturn identifier.startsWith(prefix)\n\t\t? identifier.slice(prefix.length)\n\t\t: undefined;\n}\n\nasync function waitForCompletedFunctionDeployment(args: {\n\tapi: NeonApi;\n\tprojectId: string;\n\tbranchId: string;\n\tslug: string;\n\tdeploymentId: number;\n}): Promise<void> {\n\tconst get = args.api.getBranchFunction;\n\tif (!get) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.FeatureUnavailable,\n\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(args.slug)}: this NeonApi adapter does not implement getBranchFunction, so apply cannot confirm the function finished deploying.`,\n\t\t);\n\t}\n\tconst intervalMs =\n\t\tNumber(process.env.NEON_FUNCTIONS_POLL_INTERVAL_MS) || 2000;\n\tconst timeoutMs =\n\t\tNumber(process.env.NEON_FUNCTIONS_POLL_TIMEOUT_MS) || 600_000;\n\tconst deadline = Date.now() + timeoutMs;\n\tfor (;;) {\n\t\tconst fn = await get.call(\n\t\t\targs.api,\n\t\t\targs.projectId,\n\t\t\targs.branchId,\n\t\t\targs.slug,\n\t\t);\n\t\tconst dep = fn.currentDeployment;\n\t\t// GET can still report the previous deployment after this apply's POST returns.\n\t\tif (dep !== undefined && dep.id > args.deploymentId) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.ServerError,\n\t\t\t\t`Cannot retarget a custom domain onto ${JSON.stringify(args.slug)}: current deployment is ${dep.id}, this apply submitted ${args.deploymentId}; left the previous custom-domain registration in place.`,\n\t\t\t);\n\t\t}\n\t\tif (dep !== undefined && dep.id === args.deploymentId) {\n\t\t\tif (dep.status === \"completed\") return;\n\t\t\tif (dep.status === \"failed\") {\n\t\t\t\tthrow new PlatformError(\n\t\t\t\t\tErrorCode.ServerError,\n\t\t\t\t\t`Deployment of function ${JSON.stringify(args.slug)} failed; left the previous custom-domain registration in place.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.ServerError,\n\t\t\t\t`Timed out waiting for function ${JSON.stringify(args.slug)} to finish deploying; left the previous custom-domain registration in place.`,\n\t\t\t);\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, intervalMs));\n\t}\n}\n\nfunction requireCustomDomainApi(api: NeonApi): {\n\tlistBranchCustomDomains: NonNullable<NeonApi[\"listBranchCustomDomains\"]>;\n\tregisterBranchCustomDomain: NonNullable<\n\t\tNeonApi[\"registerBranchCustomDomain\"]\n\t>;\n\tdeleteBranchCustomDomain: NonNullable<NeonApi[\"deleteBranchCustomDomain\"]>;\n} {\n\tconst list = api.listBranchCustomDomains;\n\tconst register = api.registerBranchCustomDomain;\n\tconst remove = api.deleteBranchCustomDomain;\n\tif (!list || !register || !remove) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.FeatureUnavailable,\n\t\t\t\"This NeonApi adapter does not implement custom domains. Implement listBranchCustomDomains, registerBranchCustomDomain, and deleteBranchCustomDomain, or remove customDomains from neon.ts.\",\n\t\t);\n\t}\n\treturn {\n\t\tlistBranchCustomDomains: list.bind(api),\n\t\tregisterBranchCustomDomain: register.bind(api),\n\t\tdeleteBranchCustomDomain: remove.bind(api),\n\t};\n}\n\nfunction rewriteCustomDomainConflict(err: unknown, domain: string): unknown {\n\tif (!(err instanceof PlatformError) || err.code !== ErrorCode.Conflict) {\n\t\treturn err;\n\t}\n\tconst neonMessage =\n\t\ttypeof err.details.neonMessage === \"string\"\n\t\t\t? err.details.neonMessage\n\t\t\t: undefined;\n\tconst requestId =\n\t\ttypeof err.details.requestId === \"string\"\n\t\t\t? err.details.requestId\n\t\t\t: undefined;\n\tconst status =\n\t\ttypeof err.details.status === \"number\" ? err.details.status : undefined;\n\tconst apiParts = [\n\t\tstatus !== undefined ? `HTTP ${status}` : undefined,\n\t\tneonMessage ? `Neon API said: \"${neonMessage}\"` : undefined,\n\t\trequestId ? `request id ${requestId}` : undefined,\n\t].filter((part): part is string => part !== undefined);\n\treturn new PlatformError(\n\t\tErrorCode.Conflict,\n\t\t[\n\t\t\t`Hostname ${JSON.stringify(domain)} is already registered to another resource.`,\n\t\t\tapiParts.length > 0 ? `(${apiParts.join(\"; \")})` : undefined,\n\t\t\t\"Declare it only on the branch that owns it (use the branch closure), or delete it there first with `neon function domains delete`.\",\n\t\t]\n\t\t\t.filter((part): part is string => part !== undefined)\n\t\t\t.join(\" \"),\n\t\t{ cause: err, details: { ...err.details } },\n\t);\n}\n\nfunction enrichDeclaredCustomDomains(args: {\n\tresult: PushResult;\n\tpreview: RemotePreviewState | undefined;\n\tfunctions: ResolvedFunctionConfig[];\n\tapplied: AppliedChange[];\n\twarnings: string[];\n}): void {\n\tconst declared: Array<{ domain: string; slug: string }> = [];\n\tfor (const fn of args.functions) {\n\t\tfor (const domain of fn.customDomains ?? []) {\n\t\t\tdeclared.push({ domain, slug: fn.slug });\n\t\t}\n\t}\n\tif (declared.length === 0) return;\n\n\tconst blockedDomains = new Set(\n\t\targs.result.conflicts.flatMap((conflict) => {\n\t\t\tif (conflict.field !== \"customDomain\") return [];\n\t\t\tconst match = /^custom domain \"([^\"]+)\"/.exec(conflict.reason);\n\t\t\treturn match?.[1] !== undefined ? [match[1]] : [];\n\t\t}),\n\t);\n\n\tconst cnameByDomain = new Map<string, string>();\n\tfor (const remote of args.preview?.customDomains ?? []) {\n\t\tif (blockedDomains.has(remote.domain)) continue;\n\t\tcnameByDomain.set(remote.domain, remote.cnameTarget);\n\t}\n\tfor (const change of args.applied) {\n\t\tconst domain =\n\t\t\ttypeof change.details?.domain === \"string\"\n\t\t\t\t? change.details.domain\n\t\t\t\t: undefined;\n\t\tconst cnameTarget = change.details?.cnameTarget;\n\t\tif (domain !== undefined && typeof cnameTarget === \"string\") {\n\t\t\tcnameByDomain.set(domain, cnameTarget);\n\t\t}\n\t}\n\n\targs.result.customDomains = declared.map(({ domain, slug }) => {\n\t\tconst entry: { domain: string; slug: string; cnameTarget?: string } = {\n\t\t\tdomain,\n\t\t\tslug,\n\t\t};\n\t\tconst cnameTarget = cnameByDomain.get(domain);\n\t\tif (cnameTarget !== undefined) entry.cnameTarget = cnameTarget;\n\t\tif (cnameTarget === \"\") {\n\t\t\targs.warnings.push(\n\t\t\t\t`No CNAME target for ${domain}; this region has no custom-domains front door.`,\n\t\t\t);\n\t\t}\n\t\treturn entry;\n\t});\n}\n\nfunction triggerChangeDetails(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): Record<string, unknown> {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\tfunctionSlug,\n\t\t\ttype: trigger.type,\n\t\t\tcron: trigger.cron,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\tfunctionSlug,\n\t\ttype: trigger.type,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tenabled: trigger.enabled,\n\t};\n}\n\nfunction createTriggerInput(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): CreateTriggerInput {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\ttype: \"schedule\",\n\t\t\tname: trigger.name,\n\t\t\tfunctionSlug,\n\t\t\tcron: trigger.cron,\n\t\t\tfunctionPath: trigger.functionPath,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"storage_object_created\",\n\t\tname: trigger.name,\n\t\tfunctionSlug,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tfunctionPath: trigger.functionPath,\n\t\tenabled: trigger.enabled,\n\t};\n}\n\nfunction updateTriggerInput(\n\tfunctionSlug: string,\n\ttrigger: ResolvedFunctionTrigger,\n): UpdateTriggerInput {\n\tif (trigger.type === \"schedule\") {\n\t\treturn {\n\t\t\ttype: \"schedule\",\n\t\t\tname: trigger.name,\n\t\t\tfunctionSlug,\n\t\t\tcron: trigger.cron,\n\t\t\tfunctionPath: trigger.functionPath,\n\t\t\tenabled: trigger.enabled,\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"storage_object_created\",\n\t\tname: trigger.name,\n\t\tfunctionSlug,\n\t\tbucketName: trigger.bucketName,\n\t\t...(trigger.prefix !== undefined ? { prefix: trigger.prefix } : {}),\n\t\tfunctionPath: trigger.functionPath,\n\t\tenabled: trigger.enabled,\n\t};\n}\n"],"mappings":";;AA2BA,MAAM,6BACJ,cACD,OAAO,OAAoD;CAC1D,MAAM,EAAE,wBAAwB,MAAM,OAAO;CAC7C,OAAO,oBAAoB,IAAI,EAAE,UAAU,CAAC;AAC7C;;;;;;;;;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AM,QAAQ;EACd,SAAS,QAAQ;CAClB;CAED,OAAO;EACN;EACA,MAAM,QAAQ;EACd,YAAY,QAAQ;EACpB,GAAI,QAAQ,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACjE,SAAS,QAAQ;CAClB;AACD;AAEA,SAAS,mBACR,cACA,SACqB;CACrB,IAAI,QAAQ,SAAS,YACpB,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;CAED,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,YAAY,QAAQ;EACpB,GAAI,QAAQ,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACjE,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;AACD;AAEA,SAAS,mBACR,cACA,SACqB;CACrB,IAAI,QAAQ,SAAS,YACpB,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;CAED,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;EACd;EACA,YAAY,QAAQ;EACpB,GAAI,QAAQ,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACjE,cAAc,QAAQ;EACtB,SAAS,QAAQ;CAClB;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon/config-runtime",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Imperative runtime for @neon/config: inspect/plan/apply a neon.ts policy against the Neon API and bundle + deploy Neon Functions. Pulls in esbuild; import this from CLIs and CI, not from neon.ts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"tsdown": "^0.14.1",
|
|
48
48
|
"typescript": "^5.9.0",
|
|
49
49
|
"vitest": "^3.0.9",
|
|
50
|
-
"@neon/
|
|
51
|
-
"@neon/
|
|
50
|
+
"@neon/sdk": "7.0.0",
|
|
51
|
+
"@neon/e2e-harness": "0.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@vercel/nft": "^1.10.2",
|