alchemy 0.12.21 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai/client.d.ts.map +1 -1
- package/lib/ai/client.js +3 -5
- package/lib/ai/client.js.map +1 -1
- package/lib/alchemy.d.ts +2 -1
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +87 -92
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +6 -1
- package/lib/apply.js.map +1 -1
- package/lib/aws/bucket.d.ts.map +1 -1
- package/lib/aws/bucket.js +55 -57
- package/lib/aws/bucket.js.map +1 -1
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +250 -252
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/policy-attachment.d.ts.map +1 -1
- package/lib/aws/policy-attachment.js +4 -6
- package/lib/aws/policy-attachment.js.map +1 -1
- package/lib/aws/policy.d.ts.map +1 -1
- package/lib/aws/policy.js +63 -65
- package/lib/aws/policy.js.map +1 -1
- package/lib/aws/queue.js +88 -90
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/table.d.ts.map +1 -1
- package/lib/aws/table.js +95 -99
- package/lib/aws/table.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +0 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/ai.d.ts +1 -1
- package/lib/cloudflare/ai.d.ts.map +1 -1
- package/lib/cloudflare/ai.js.map +1 -1
- package/lib/cloudflare/api.d.ts +5 -5
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +52 -15
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/auth.d.ts +24 -55
- package/lib/cloudflare/auth.d.ts.map +1 -1
- package/lib/cloudflare/auth.js +15 -72
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bucket.d.ts +2 -2
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +22 -24
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/alias-plugin.d.ts +6 -0
- package/lib/cloudflare/bundle/alias-plugin.d.ts.map +1 -0
- package/lib/cloudflare/bundle/alias-plugin.js +36 -0
- package/lib/cloudflare/bundle/alias-plugin.js.map +1 -0
- package/lib/cloudflare/bundle/build-failures.d.ts +12 -0
- package/lib/cloudflare/bundle/build-failures.d.ts.map +1 -0
- package/lib/cloudflare/bundle/build-failures.js +45 -0
- package/lib/cloudflare/bundle/build-failures.js.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts +7 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.js +69 -0
- package/lib/cloudflare/bundle/bundle-worker.js.map +1 -0
- package/lib/cloudflare/bundle/external.d.ts +1 -0
- package/lib/cloudflare/bundle/external.d.ts.map +1 -1
- package/lib/cloudflare/bundle/external.js +8 -1
- package/lib/cloudflare/bundle/external.js.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js +6 -6
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +17 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js +27 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -0
- package/lib/cloudflare/bundle/{hybrid-nodejs-compat.d.ts → nodejs-compat.d.ts} +2 -2
- package/lib/cloudflare/bundle/nodejs-compat.d.ts.map +1 -0
- package/lib/cloudflare/bundle/{hybrid-nodejs-compat.js → nodejs-compat.js} +2 -2
- package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -0
- package/lib/cloudflare/custom-domain.d.ts.map +1 -1
- package/lib/cloudflare/custom-domain.js +3 -5
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +1 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +70 -72
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/d1-migrations.d.ts +1 -1
- package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
- package/lib/cloudflare/d1-migrations.js +2 -3
- package/lib/cloudflare/d1-migrations.js.map +1 -1
- package/lib/cloudflare/dns-records.d.ts.map +1 -1
- package/lib/cloudflare/dns-records.js +2 -4
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +1 -1
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +24 -27
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +1 -1
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +32 -34
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +1 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +27 -33
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +1 -1
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +36 -38
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/r2-rest-state-store.js +4 -8
- package/lib/cloudflare/r2-rest-state-store.js.map +1 -1
- package/lib/cloudflare/types.d.ts.map +1 -1
- package/lib/cloudflare/types.js +1 -3
- package/lib/cloudflare/types.js.map +1 -1
- package/lib/cloudflare/user.d.ts +51 -0
- package/lib/cloudflare/user.d.ts.map +1 -0
- package/lib/cloudflare/user.js +62 -0
- package/lib/cloudflare/user.js.map +1 -0
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +37 -39
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.js +10 -13
- package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +18 -3
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +11 -54
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/workflow.d.ts +1 -1
- package/lib/cloudflare/workflow.d.ts.map +1 -1
- package/lib/cloudflare/workflow.js.map +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +48 -50
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/dns/godaddy.js +1 -1
- package/lib/dns/import-dns.js +1 -1
- package/lib/dns/import-dns.js.map +1 -1
- package/lib/env.js +7 -9
- package/lib/env.js.map +1 -1
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +8 -11
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/copy-file.d.ts.map +1 -1
- package/lib/fs/copy-file.js +27 -29
- package/lib/fs/copy-file.js.map +1 -1
- package/lib/fs/file.d.ts +1 -1
- package/lib/fs/file.d.ts.map +1 -1
- package/lib/fs/file.js +1 -1
- package/lib/fs/file.js.map +1 -1
- package/lib/fs/folder.d.ts.map +1 -1
- package/lib/fs/folder.js +1 -3
- package/lib/fs/folder.js.map +1 -1
- package/lib/github/client.d.ts.map +1 -1
- package/lib/github/client.js +3 -5
- package/lib/github/client.js.map +1 -1
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +173 -176
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js +97 -99
- package/lib/github/secret.js.map +1 -1
- package/lib/internal/docs/providers.d.ts.map +1 -1
- package/lib/internal/docs/providers.js +5 -7
- package/lib/internal/docs/providers.js.map +1 -1
- package/lib/neon/api.js +1 -2
- package/lib/neon/api.js.map +1 -1
- package/lib/neon/project.js +2 -2
- package/lib/neon/project.js.map +1 -1
- package/lib/os/exec.d.ts +5 -0
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js +88 -56
- package/lib/os/exec.js.map +1 -1
- package/lib/scope.d.ts +3 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +10 -3
- package/lib/scope.js.map +1 -1
- package/lib/secret.d.ts.map +1 -1
- package/lib/secret.js +1 -3
- package/lib/secret.js.map +1 -1
- package/lib/serde.d.ts.map +1 -1
- package/lib/serde.js +13 -15
- package/lib/serde.js.map +1 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +69 -73
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +50 -52
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +51 -53
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +3 -8
- package/lib/test/bun.js.map +1 -1
- package/lib/test/prune.d.ts.map +1 -1
- package/lib/test/prune.js.map +1 -1
- package/lib/util/dedent.js +4 -4
- package/lib/util/dedent.js.map +1 -1
- package/lib/web/astro.js +1 -1
- package/lib/web/shadcn.js +4 -4
- package/lib/web/shadcn.js.map +1 -1
- package/lib/web/tailwind.d.ts.map +1 -1
- package/lib/web/tailwind.js +0 -1
- package/lib/web/tailwind.js.map +1 -1
- package/lib/web/vite.js +3 -3
- package/lib/web/vitepress/home-page.d.ts.map +1 -1
- package/lib/web/vitepress/home-page.js +6 -8
- package/lib/web/vitepress/home-page.js.map +1 -1
- package/lib/web/vitepress/process-front-matter-files.js +1 -1
- package/lib/web/vitepress/process-front-matter-files.js.map +1 -1
- package/lib/web/vitepress/vitepress.js +2 -2
- package/lib/web/vitepress/vitepress.js.map +1 -1
- package/package.json +4 -1
- package/src/ai/astro-file.ts +4 -4
- package/src/ai/client.ts +4 -5
- package/src/ai/css-file.ts +4 -4
- package/src/ai/document.ts +3 -3
- package/src/ai/html-file.ts +4 -4
- package/src/ai/json-file.ts +1 -1
- package/src/ai/typescript-file.ts +4 -4
- package/src/ai/vue-file.ts +4 -4
- package/src/ai/yaml-file.ts +1 -1
- package/src/alchemy.ts +111 -104
- package/src/apply.ts +13 -6
- package/src/aws/bucket.ts +72 -75
- package/src/aws/function.ts +296 -297
- package/src/aws/oidc/github-oidc-provider.ts +1 -1
- package/src/aws/oidc/oidc-provider.ts +15 -15
- package/src/aws/policy-attachment.ts +10 -11
- package/src/aws/policy.ts +91 -94
- package/src/aws/queue.ts +111 -111
- package/src/aws/role.ts +24 -24
- package/src/aws/ses.ts +17 -17
- package/src/aws/table.ts +114 -115
- package/src/cloudflare/account-api-token.ts +11 -11
- package/src/cloudflare/ai-gateway.ts +4 -4
- package/src/cloudflare/ai.ts +1 -1
- package/src/cloudflare/api-error.ts +1 -1
- package/src/cloudflare/api.ts +70 -25
- package/src/cloudflare/assets.ts +4 -4
- package/src/cloudflare/auth.ts +49 -164
- package/src/cloudflare/bucket.ts +62 -63
- package/src/cloudflare/bundle/alias-plugin.ts +48 -0
- package/src/cloudflare/bundle/build-failures.ts +55 -0
- package/src/cloudflare/bundle/bundle-worker.ts +89 -0
- package/src/cloudflare/bundle/external.ts +9 -1
- package/src/cloudflare/bundle/local-dev-cloudflare-shim.ts +7 -6
- package/src/cloudflare/bundle/nodejs-compat-mode.ts +49 -0
- package/src/cloudflare/bundle/{hybrid-nodejs-compat.ts → nodejs-compat.ts} +10 -10
- package/src/cloudflare/custom-domain.ts +27 -28
- package/src/cloudflare/d1-database.ts +101 -102
- package/src/cloudflare/d1-migrations.ts +10 -10
- package/src/cloudflare/dns-records.ts +23 -24
- package/src/cloudflare/durable-object-namespace.ts +1 -1
- package/src/cloudflare/event-source.ts +1 -1
- package/src/cloudflare/hyperdrive.ts +3 -3
- package/src/cloudflare/kv-namespace.ts +36 -37
- package/src/cloudflare/nuxt.ts +1 -1
- package/src/cloudflare/permission-groups.ts +7 -7
- package/src/cloudflare/pipeline.ts +55 -56
- package/src/cloudflare/queue-consumer.ts +46 -53
- package/src/cloudflare/queue.ts +56 -57
- package/src/cloudflare/r2-rest-state-store.ts +11 -11
- package/src/cloudflare/redwood.ts +1 -1
- package/src/cloudflare/tanstack-start.ts +1 -1
- package/src/cloudflare/types.ts +1 -2
- package/src/cloudflare/user.ts +142 -0
- package/src/cloudflare/vectorize-index.ts +60 -61
- package/src/cloudflare/vectorize-metadata-index.ts +25 -25
- package/src/cloudflare/vite.ts +1 -1
- package/src/cloudflare/website.ts +3 -3
- package/src/cloudflare/worker.ts +83 -108
- package/src/cloudflare/workflow.ts +4 -4
- package/src/cloudflare/wrangler.json.ts +4 -4
- package/src/cloudflare/zone.ts +69 -70
- package/src/destroy.ts +4 -4
- package/src/dns/godaddy.ts +1 -1
- package/src/dns/import-dns.ts +5 -5
- package/src/encrypt.ts +6 -6
- package/src/env.ts +10 -10
- package/src/esbuild/bundle.ts +14 -15
- package/src/fs/copy-file.ts +35 -36
- package/src/fs/file-system-state-store.ts +4 -4
- package/src/fs/file.ts +9 -8
- package/src/fs/folder.ts +6 -7
- package/src/github/client.ts +15 -14
- package/src/github/repository-environment.ts +206 -210
- package/src/github/secret.ts +111 -116
- package/src/internal/docs/providers.ts +16 -17
- package/src/neon/api-error.ts +1 -1
- package/src/neon/api.ts +6 -6
- package/src/neon/project.ts +18 -17
- package/src/os/exec.ts +107 -66
- package/src/resource.ts +3 -3
- package/src/scope.ts +14 -4
- package/src/secret.ts +2 -3
- package/src/serde.ts +30 -22
- package/src/stripe/price.ts +74 -77
- package/src/stripe/product.ts +55 -56
- package/src/stripe/webhook.ts +56 -57
- package/src/test/bun.ts +9 -13
- package/src/test/prune.ts +4 -4
- package/src/util/dedent.ts +4 -4
- package/src/web/astro.ts +10 -10
- package/src/web/shadcn-component.ts +4 -4
- package/src/web/shadcn.ts +10 -10
- package/src/web/tailwind.ts +2 -3
- package/src/web/vite.ts +11 -11
- package/src/web/vitepress/config.ts +2 -2
- package/src/web/vitepress/custom-theme.ts +7 -7
- package/src/web/vitepress/dependencies.ts +4 -4
- package/src/web/vitepress/home-page.ts +8 -9
- package/src/web/vitepress/process-front-matter-files.ts +5 -5
- package/src/web/vitepress/vitepress.ts +7 -7
- package/lib/cloudflare/account-id.d.ts +0 -6
- package/lib/cloudflare/account-id.d.ts.map +0 -1
- package/lib/cloudflare/account-id.js +0 -6
- package/lib/cloudflare/account-id.js.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +0 -1
- package/src/cloudflare/account-id.ts +0 -12
|
@@ -16,7 +16,7 @@ const REQUIRED_UNENV_ALIAS_NAMESPACE = "required-unenv-alias";
|
|
|
16
16
|
*
|
|
17
17
|
* @returns ESBuild plugin
|
|
18
18
|
*/
|
|
19
|
-
export async function
|
|
19
|
+
export async function nodeJsCompatPlugin(): Promise<Plugin> {
|
|
20
20
|
// `unenv` and `@cloudflare/unenv-preset` only publish esm
|
|
21
21
|
const { defineEnv } = await import("unenv");
|
|
22
22
|
const { cloudflare } = await import("@cloudflare/unenv-preset");
|
|
@@ -56,7 +56,7 @@ function errorOnServiceWorkerFormat(build: PluginBuild) {
|
|
|
56
56
|
const pathList = new Intl.ListFormat("en-US").format(
|
|
57
57
|
Array.from(paths.keys())
|
|
58
58
|
.map((p) => `"${p}"`)
|
|
59
|
-
.sort()
|
|
59
|
+
.sort(),
|
|
60
60
|
);
|
|
61
61
|
return {
|
|
62
62
|
errors: [
|
|
@@ -98,7 +98,7 @@ function handleRequireCallsToNodeJSBuiltins(build: PluginBuild) {
|
|
|
98
98
|
module.exports = libDefault;`,
|
|
99
99
|
loader: "js",
|
|
100
100
|
};
|
|
101
|
-
}
|
|
101
|
+
},
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -112,7 +112,7 @@ function handleRequireCallsToNodeJSBuiltins(build: PluginBuild) {
|
|
|
112
112
|
function handleUnenvAliasedPackages(
|
|
113
113
|
build: PluginBuild,
|
|
114
114
|
alias: Record<string, string>,
|
|
115
|
-
external: readonly string[]
|
|
115
|
+
external: readonly string[],
|
|
116
116
|
) {
|
|
117
117
|
// esbuild expects alias paths to be absolute
|
|
118
118
|
const aliasAbsolute: Record<string, string> = {};
|
|
@@ -125,7 +125,7 @@ function handleUnenvAliasedPackages(
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const UNENV_ALIAS_RE = new RegExp(
|
|
128
|
-
`^(${Object.keys(aliasAbsolute).join("|")})
|
|
128
|
+
`^(${Object.keys(aliasAbsolute).join("|")})$`,
|
|
129
129
|
);
|
|
130
130
|
|
|
131
131
|
build.onResolve({ filter: UNENV_ALIAS_RE }, (args) => {
|
|
@@ -164,7 +164,7 @@ function handleUnenvAliasedPackages(
|
|
|
164
164
|
);`,
|
|
165
165
|
loader: "js",
|
|
166
166
|
};
|
|
167
|
-
}
|
|
167
|
+
},
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -177,13 +177,13 @@ function handleUnenvAliasedPackages(
|
|
|
177
177
|
function handleNodeJSGlobals(
|
|
178
178
|
build: PluginBuild,
|
|
179
179
|
inject: Record<string, string | readonly string[]>,
|
|
180
|
-
polyfill: readonly string[]
|
|
180
|
+
polyfill: readonly string[],
|
|
181
181
|
) {
|
|
182
182
|
const UNENV_VIRTUAL_MODULE_RE = /_virtual_unenv_global_polyfill-(.+)$/;
|
|
183
183
|
const prefix = nodePath.resolve(
|
|
184
184
|
// getBasePath(),
|
|
185
185
|
import.meta.dirname,
|
|
186
|
-
"_virtual_unenv_global_polyfill-"
|
|
186
|
+
"_virtual_unenv_global_polyfill-",
|
|
187
187
|
);
|
|
188
188
|
|
|
189
189
|
/**
|
|
@@ -209,7 +209,7 @@ function handleNodeJSGlobals(
|
|
|
209
209
|
injectsByModule.set(module, []);
|
|
210
210
|
virtualModulePathToSpecifier.set(
|
|
211
211
|
prefix + module.replaceAll("/", "-"),
|
|
212
|
-
module
|
|
212
|
+
module,
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -235,7 +235,7 @@ function handleNodeJSGlobals(
|
|
|
235
235
|
assert(injects, `Expected ${module} to inject values`);
|
|
236
236
|
|
|
237
237
|
const imports = injects.map(({ exportName, importName }) =>
|
|
238
|
-
importName === exportName ? exportName : `${exportName} as ${importName}
|
|
238
|
+
importName === exportName ? exportName : `${exportName} as ${importName}`,
|
|
239
239
|
);
|
|
240
240
|
|
|
241
241
|
return {
|
|
@@ -2,7 +2,7 @@ import type { Context } from "../context.js";
|
|
|
2
2
|
import { Resource } from "../resource.js";
|
|
3
3
|
import { handleApiError } from "./api-error.js";
|
|
4
4
|
import {
|
|
5
|
-
CloudflareApi,
|
|
5
|
+
type CloudflareApi,
|
|
6
6
|
createCloudflareApi,
|
|
7
7
|
type CloudflareApiOptions,
|
|
8
8
|
} from "./api.js";
|
|
@@ -91,7 +91,7 @@ export const CustomDomain = Resource(
|
|
|
91
91
|
async function (
|
|
92
92
|
this: Context<CustomDomain>,
|
|
93
93
|
logicalId: string, // Changed param name from id to logicalId for clarity
|
|
94
|
-
props: CustomDomainProps
|
|
94
|
+
props: CustomDomainProps,
|
|
95
95
|
): Promise<CustomDomain> {
|
|
96
96
|
// Create Cloudflare API client with automatic account discovery
|
|
97
97
|
const api = await createCloudflareApi(props);
|
|
@@ -110,11 +110,10 @@ export const CustomDomain = Resource(
|
|
|
110
110
|
if (this.phase === "delete") {
|
|
111
111
|
await deleteCustomDomain(this, api, logicalId, props);
|
|
112
112
|
return this.destroy();
|
|
113
|
-
} else {
|
|
114
|
-
// Create or Update phase
|
|
115
|
-
return await ensureCustomDomain(this, api, logicalId, props);
|
|
116
113
|
}
|
|
117
|
-
|
|
114
|
+
// Create or Update phase
|
|
115
|
+
return await ensureCustomDomain(this, api, logicalId, props);
|
|
116
|
+
},
|
|
118
117
|
);
|
|
119
118
|
|
|
120
119
|
// Helper function to delete the custom domain binding
|
|
@@ -122,29 +121,29 @@ async function deleteCustomDomain(
|
|
|
122
121
|
context: Context<CustomDomain>,
|
|
123
122
|
api: CloudflareApi,
|
|
124
123
|
logicalId: string,
|
|
125
|
-
props: CustomDomainProps
|
|
124
|
+
props: CustomDomainProps,
|
|
126
125
|
): Promise<void> {
|
|
127
126
|
const domainHostname = props.name;
|
|
128
127
|
const domainIdToDelete = context.output?.id;
|
|
129
128
|
|
|
130
129
|
if (!domainIdToDelete) {
|
|
131
130
|
console.warn(
|
|
132
|
-
`Cannot delete CustomDomain ${logicalId} (${domainHostname}): Missing domain ID in state. Assuming already deleted
|
|
131
|
+
`Cannot delete CustomDomain ${logicalId} (${domainHostname}): Missing domain ID in state. Assuming already deleted.`,
|
|
133
132
|
);
|
|
134
133
|
return; // Exit early if no ID
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
console.log(
|
|
138
|
-
`Deleting CustomDomain binding ${domainIdToDelete} for ${domainHostname}
|
|
137
|
+
`Deleting CustomDomain binding ${domainIdToDelete} for ${domainHostname}`,
|
|
139
138
|
);
|
|
140
139
|
const response = await api.delete(
|
|
141
|
-
`/accounts/${api.accountId}/workers/domains/${domainIdToDelete}
|
|
140
|
+
`/accounts/${api.accountId}/workers/domains/${domainIdToDelete}`,
|
|
142
141
|
);
|
|
143
142
|
|
|
144
143
|
console.log(
|
|
145
144
|
`Delete result for ${domainIdToDelete} (${domainHostname}):`,
|
|
146
145
|
response.status,
|
|
147
|
-
response.statusText
|
|
146
|
+
response.statusText,
|
|
148
147
|
);
|
|
149
148
|
|
|
150
149
|
// 404 is acceptable during deletion for idempotency
|
|
@@ -153,11 +152,11 @@ async function deleteCustomDomain(
|
|
|
153
152
|
response,
|
|
154
153
|
"deleting",
|
|
155
154
|
"custom domain binding",
|
|
156
|
-
domainIdToDelete
|
|
155
|
+
domainIdToDelete,
|
|
157
156
|
);
|
|
158
157
|
// Throw after handling to ensure failure is reported
|
|
159
158
|
throw new Error(
|
|
160
|
-
`Failed to delete custom domain binding ${domainIdToDelete}: ${response.statusText}
|
|
159
|
+
`Failed to delete custom domain binding ${domainIdToDelete}: ${response.statusText}`,
|
|
161
160
|
);
|
|
162
161
|
}
|
|
163
162
|
}
|
|
@@ -167,7 +166,7 @@ async function ensureCustomDomain(
|
|
|
167
166
|
context: Context<CustomDomain>,
|
|
168
167
|
api: CloudflareApi,
|
|
169
168
|
logicalId: string,
|
|
170
|
-
props: CustomDomainProps
|
|
169
|
+
props: CustomDomainProps,
|
|
171
170
|
): Promise<CustomDomain> {
|
|
172
171
|
const environment = props.environment || "production";
|
|
173
172
|
const domainHostname = props.name;
|
|
@@ -175,7 +174,7 @@ async function ensureCustomDomain(
|
|
|
175
174
|
// Check if domain binding already exists for this account
|
|
176
175
|
console.log(`Checking existing domain bindings for account ${api.accountId}`);
|
|
177
176
|
const listResponse = await api.get(
|
|
178
|
-
`/accounts/${api.accountId}/workers/domains
|
|
177
|
+
`/accounts/${api.accountId}/workers/domains`,
|
|
179
178
|
);
|
|
180
179
|
|
|
181
180
|
if (!listResponse.ok) {
|
|
@@ -184,11 +183,11 @@ async function ensureCustomDomain(
|
|
|
184
183
|
listResponse,
|
|
185
184
|
"listing",
|
|
186
185
|
"worker domains",
|
|
187
|
-
`Account ${api.accountId}
|
|
186
|
+
`Account ${api.accountId}`,
|
|
188
187
|
);
|
|
189
188
|
// If listing fails, we cannot proceed reliably
|
|
190
189
|
throw new Error(
|
|
191
|
-
`Failed to list worker domains for account ${api.accountId}: ${listResponse.statusText}
|
|
190
|
+
`Failed to list worker domains for account ${api.accountId}: ${listResponse.statusText}`,
|
|
192
191
|
);
|
|
193
192
|
}
|
|
194
193
|
|
|
@@ -199,13 +198,13 @@ async function ensureCustomDomain(
|
|
|
199
198
|
|
|
200
199
|
if (!listData.success || !listData.result) {
|
|
201
200
|
throw new Error(
|
|
202
|
-
`Failed to parse list worker domains response: ${JSON.stringify(listData)}
|
|
201
|
+
`Failed to parse list worker domains response: ${JSON.stringify(listData)}`,
|
|
203
202
|
);
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
// Find the specific binding by hostname AND zoneId
|
|
207
206
|
const existingBinding = listData.result.find(
|
|
208
|
-
(b) => b.hostname === domainHostname && b.zone_id === props.zoneId
|
|
207
|
+
(b) => b.hostname === domainHostname && b.zone_id === props.zoneId,
|
|
209
208
|
);
|
|
210
209
|
|
|
211
210
|
let currentDomainId = existingBinding?.id;
|
|
@@ -215,7 +214,7 @@ async function ensureCustomDomain(
|
|
|
215
214
|
`Domain binding status for ${domainHostname} (Zone: ${props.zoneId}):`,
|
|
216
215
|
bindingExists
|
|
217
216
|
? `Found (ID: ${currentDomainId}, Worker: ${existingBinding.service}, Env: ${existingBinding.environment})`
|
|
218
|
-
: "Not found"
|
|
217
|
+
: "Not found",
|
|
219
218
|
);
|
|
220
219
|
|
|
221
220
|
// Determine if we need to update (binding exists but has different service or environment)
|
|
@@ -232,7 +231,7 @@ async function ensureCustomDomain(
|
|
|
232
231
|
if (!bindingExists || needsUpdate) {
|
|
233
232
|
operationPerformed = bindingExists ? "update" : "create";
|
|
234
233
|
console.log(
|
|
235
|
-
`${operationPerformed === "update" ? "Updating" : "Creating"} domain binding: ${domainHostname} (Zone: ${props.zoneId}) → ${props.workerName}:${environment}
|
|
234
|
+
`${operationPerformed === "update" ? "Updating" : "Creating"} domain binding: ${domainHostname} (Zone: ${props.zoneId}) → ${props.workerName}:${environment}`,
|
|
236
235
|
);
|
|
237
236
|
|
|
238
237
|
const putPayload = {
|
|
@@ -244,7 +243,7 @@ async function ensureCustomDomain(
|
|
|
244
243
|
|
|
245
244
|
const putResponse = await api.put(
|
|
246
245
|
`/accounts/${api.accountId}/workers/domains`,
|
|
247
|
-
putPayload
|
|
246
|
+
putPayload,
|
|
248
247
|
);
|
|
249
248
|
|
|
250
249
|
if (!putResponse.ok) {
|
|
@@ -252,11 +251,11 @@ async function ensureCustomDomain(
|
|
|
252
251
|
putResponse,
|
|
253
252
|
operationPerformed === "update" ? "updating" : "creating",
|
|
254
253
|
"custom domain binding",
|
|
255
|
-
domainHostname
|
|
254
|
+
domainHostname,
|
|
256
255
|
);
|
|
257
256
|
// Throw after handling to prevent inconsistent state
|
|
258
257
|
throw new Error(
|
|
259
|
-
`Failed to ${operationPerformed} custom domain binding: ${putResponse.statusText}
|
|
258
|
+
`Failed to ${operationPerformed} custom domain binding: ${putResponse.statusText}`,
|
|
260
259
|
);
|
|
261
260
|
}
|
|
262
261
|
|
|
@@ -267,18 +266,18 @@ async function ensureCustomDomain(
|
|
|
267
266
|
|
|
268
267
|
if (!putResult.success || !putResult.result) {
|
|
269
268
|
throw new Error(
|
|
270
|
-
`Failed to parse ${operationPerformed} domain binding response: ${JSON.stringify(putResult)}
|
|
269
|
+
`Failed to parse ${operationPerformed} domain binding response: ${JSON.stringify(putResult)}`,
|
|
271
270
|
);
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
resultantBinding = putResult.result;
|
|
275
274
|
currentDomainId = resultantBinding.id; // Update ID from the PUT response
|
|
276
275
|
console.log(
|
|
277
|
-
`Successfully ${operationPerformed}d binding, new ID: ${currentDomainId}
|
|
276
|
+
`Successfully ${operationPerformed}d binding, new ID: ${currentDomainId}`,
|
|
278
277
|
);
|
|
279
278
|
} else {
|
|
280
279
|
console.log(
|
|
281
|
-
`Domain binding already exists and is up to date: ${domainHostname} (ID: ${currentDomainId}) → ${props.workerName}:${environment}
|
|
280
|
+
`Domain binding already exists and is up to date: ${domainHostname} (ID: ${currentDomainId}) → ${props.workerName}:${environment}`,
|
|
282
281
|
);
|
|
283
282
|
}
|
|
284
283
|
|
|
@@ -291,7 +290,7 @@ async function ensureCustomDomain(
|
|
|
291
290
|
currentDomainId,
|
|
292
291
|
});
|
|
293
292
|
throw new Error(
|
|
294
|
-
`Failed to get final state for custom domain ${domainHostname}
|
|
293
|
+
`Failed to get final state for custom domain ${domainHostname}`,
|
|
295
294
|
);
|
|
296
295
|
}
|
|
297
296
|
|
|
@@ -2,7 +2,7 @@ import type { Context } from "../context.js";
|
|
|
2
2
|
import { Resource } from "../resource.js";
|
|
3
3
|
import { CloudflareApiError, handleApiError } from "./api-error.js";
|
|
4
4
|
import {
|
|
5
|
-
CloudflareApi,
|
|
5
|
+
type CloudflareApi,
|
|
6
6
|
createCloudflareApi,
|
|
7
7
|
type CloudflareApiOptions,
|
|
8
8
|
} from "./api.js";
|
|
@@ -125,7 +125,7 @@ export type D1Database = Resource<"cloudflare::D1Database"> &
|
|
|
125
125
|
|
|
126
126
|
export async function D1Database(
|
|
127
127
|
id: string,
|
|
128
|
-
props: Omit<D1DatabaseProps, "migrationsFiles"
|
|
128
|
+
props: Omit<D1DatabaseProps, "migrationsFiles">,
|
|
129
129
|
) {
|
|
130
130
|
const migrationsFiles = props.migrationsDir
|
|
131
131
|
? await listMigrationsFiles(props.migrationsDir)
|
|
@@ -180,7 +180,7 @@ export const D1DatabaseResource = Resource(
|
|
|
180
180
|
async function (
|
|
181
181
|
this: Context<D1Database>,
|
|
182
182
|
id: string,
|
|
183
|
-
props: D1DatabaseProps = {}
|
|
183
|
+
props: D1DatabaseProps = {},
|
|
184
184
|
): Promise<D1Database> {
|
|
185
185
|
const api = await createCloudflareApi(props);
|
|
186
186
|
const databaseName = props.name ?? id;
|
|
@@ -195,99 +195,98 @@ export const D1DatabaseResource = Resource(
|
|
|
195
195
|
|
|
196
196
|
// Return void (a deleted database has no content)
|
|
197
197
|
return this.destroy();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
// Re-throw the error if adopt is false or it's not a "database already exists" error
|
|
235
|
-
throw error;
|
|
198
|
+
}
|
|
199
|
+
let dbData: CloudflareD1Response;
|
|
200
|
+
|
|
201
|
+
if (this.phase === "create") {
|
|
202
|
+
console.log("Creating D1 database:", databaseName);
|
|
203
|
+
try {
|
|
204
|
+
dbData = await createDatabase(api, databaseName, props);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
// Check if this is a "database already exists" error and adopt is enabled
|
|
207
|
+
if (
|
|
208
|
+
props.adopt &&
|
|
209
|
+
error instanceof CloudflareApiError &&
|
|
210
|
+
error.message.includes("already exists")
|
|
211
|
+
) {
|
|
212
|
+
console.log(`Database ${databaseName} already exists, adopting it`);
|
|
213
|
+
// Find the existing database by name
|
|
214
|
+
const databases = await listDatabases(api, databaseName);
|
|
215
|
+
const existingDb = databases.find((db) => db.name === databaseName);
|
|
216
|
+
|
|
217
|
+
if (!existingDb) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Failed to find existing database '${databaseName}' for adoption`,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Get the database details using its ID
|
|
224
|
+
dbData = await getDatabase(api, existingDb.id);
|
|
225
|
+
|
|
226
|
+
// Update the database with the provided properties
|
|
227
|
+
if (props.readReplication) {
|
|
228
|
+
console.log(
|
|
229
|
+
`Updating adopted database ${databaseName} with new properties`,
|
|
230
|
+
);
|
|
231
|
+
dbData = await updateDatabase(api, existingDb.id, props);
|
|
236
232
|
}
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
// Update operation
|
|
240
|
-
if (this.output?.id) {
|
|
241
|
-
console.log("Updating D1 database:", databaseName);
|
|
242
|
-
// Update the database with new properties
|
|
243
|
-
dbData = await updateDatabase(api, this.output.id, props);
|
|
244
233
|
} else {
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
"No existing database ID found, creating new D1 database:",
|
|
248
|
-
databaseName
|
|
249
|
-
);
|
|
250
|
-
dbData = await createDatabase(api, databaseName, props);
|
|
234
|
+
// Re-throw the error if adopt is false or it's not a "database already exists" error
|
|
235
|
+
throw error;
|
|
251
236
|
}
|
|
252
237
|
}
|
|
238
|
+
} else {
|
|
239
|
+
// Update operation
|
|
240
|
+
if (this.output?.id) {
|
|
241
|
+
console.log("Updating D1 database:", databaseName);
|
|
242
|
+
// Update the database with new properties
|
|
243
|
+
dbData = await updateDatabase(api, this.output.id, props);
|
|
244
|
+
} else {
|
|
245
|
+
// If no ID exists, fall back to creating a new database
|
|
246
|
+
console.log(
|
|
247
|
+
"No existing database ID found, creating new D1 database:",
|
|
248
|
+
databaseName,
|
|
249
|
+
);
|
|
250
|
+
dbData = await createDatabase(api, databaseName, props);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (!databaseId) {
|
|
261
|
-
throw new Error("Database ID not found for migrations");
|
|
262
|
-
}
|
|
254
|
+
// Run migrations if provided
|
|
255
|
+
if (props.migrationsFiles && props.migrationsFiles.length > 0) {
|
|
256
|
+
try {
|
|
257
|
+
const migrationsTable = props.migrationsTable || "d1_migrations";
|
|
258
|
+
const databaseId = dbData.result.uuid || this.output?.id;
|
|
263
259
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
migrationsTable,
|
|
267
|
-
accountId: api.accountId,
|
|
268
|
-
databaseId,
|
|
269
|
-
api,
|
|
270
|
-
});
|
|
271
|
-
} catch (migrationErr) {
|
|
272
|
-
console.error("Failed to apply D1 migrations:", migrationErr);
|
|
273
|
-
throw migrationErr;
|
|
260
|
+
if (!databaseId) {
|
|
261
|
+
throw new Error("Database ID not found for migrations");
|
|
274
262
|
}
|
|
275
|
-
}
|
|
276
263
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
});
|
|
264
|
+
await applyMigrations({
|
|
265
|
+
migrationsFiles: props.migrationsFiles,
|
|
266
|
+
migrationsTable,
|
|
267
|
+
accountId: api.accountId,
|
|
268
|
+
databaseId,
|
|
269
|
+
api,
|
|
270
|
+
});
|
|
271
|
+
} catch (migrationErr) {
|
|
272
|
+
console.error("Failed to apply D1 migrations:", migrationErr);
|
|
273
|
+
throw migrationErr;
|
|
274
|
+
}
|
|
289
275
|
}
|
|
290
|
-
|
|
276
|
+
|
|
277
|
+
return this({
|
|
278
|
+
type: "d1",
|
|
279
|
+
id: dbData.result.uuid || "",
|
|
280
|
+
name: databaseName,
|
|
281
|
+
fileSize: dbData.result.file_size,
|
|
282
|
+
numTables: dbData.result.num_tables,
|
|
283
|
+
version: dbData.result.version,
|
|
284
|
+
readReplication: dbData.result.read_replication,
|
|
285
|
+
primaryLocationHint: props.primaryLocationHint,
|
|
286
|
+
accountId: api.accountId,
|
|
287
|
+
migrationsDir: props.migrationsDir,
|
|
288
|
+
});
|
|
289
|
+
},
|
|
291
290
|
);
|
|
292
291
|
|
|
293
292
|
interface CloudflareD1Response {
|
|
@@ -313,7 +312,7 @@ interface CloudflareD1Response {
|
|
|
313
312
|
export async function createDatabase(
|
|
314
313
|
api: CloudflareApi,
|
|
315
314
|
databaseName: string,
|
|
316
|
-
props: D1DatabaseProps
|
|
315
|
+
props: D1DatabaseProps,
|
|
317
316
|
): Promise<CloudflareD1Response> {
|
|
318
317
|
// Create new D1 database
|
|
319
318
|
const createPayload: any = {
|
|
@@ -326,7 +325,7 @@ export async function createDatabase(
|
|
|
326
325
|
|
|
327
326
|
const createResponse = await api.post(
|
|
328
327
|
`/accounts/${api.accountId}/d1/database`,
|
|
329
|
-
createPayload
|
|
328
|
+
createPayload,
|
|
330
329
|
);
|
|
331
330
|
|
|
332
331
|
if (!createResponse.ok) {
|
|
@@ -334,7 +333,7 @@ export async function createDatabase(
|
|
|
334
333
|
createResponse,
|
|
335
334
|
"creating",
|
|
336
335
|
"D1 database",
|
|
337
|
-
databaseName
|
|
336
|
+
databaseName,
|
|
338
337
|
);
|
|
339
338
|
}
|
|
340
339
|
|
|
@@ -346,14 +345,14 @@ export async function createDatabase(
|
|
|
346
345
|
*/
|
|
347
346
|
export async function getDatabase(
|
|
348
347
|
api: CloudflareApi,
|
|
349
|
-
databaseId?: string
|
|
348
|
+
databaseId?: string,
|
|
350
349
|
): Promise<CloudflareD1Response> {
|
|
351
350
|
if (!databaseId) {
|
|
352
351
|
throw new Error("Database ID is required");
|
|
353
352
|
}
|
|
354
353
|
|
|
355
354
|
const response = await api.get(
|
|
356
|
-
`/accounts/${api.accountId}/d1/database/${databaseId}
|
|
355
|
+
`/accounts/${api.accountId}/d1/database/${databaseId}`,
|
|
357
356
|
);
|
|
358
357
|
|
|
359
358
|
if (!response.ok) {
|
|
@@ -368,7 +367,7 @@ export async function getDatabase(
|
|
|
368
367
|
*/
|
|
369
368
|
export async function deleteDatabase(
|
|
370
369
|
api: CloudflareApi,
|
|
371
|
-
databaseId?: string
|
|
370
|
+
databaseId?: string,
|
|
372
371
|
): Promise<void> {
|
|
373
372
|
if (!databaseId) {
|
|
374
373
|
console.log("No database ID provided, skipping delete");
|
|
@@ -377,7 +376,7 @@ export async function deleteDatabase(
|
|
|
377
376
|
|
|
378
377
|
// Delete D1 database
|
|
379
378
|
const deleteResponse = await api.delete(
|
|
380
|
-
`/accounts/${api.accountId}/d1/database/${databaseId}
|
|
379
|
+
`/accounts/${api.accountId}/d1/database/${databaseId}`,
|
|
381
380
|
);
|
|
382
381
|
|
|
383
382
|
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
@@ -386,7 +385,7 @@ export async function deleteDatabase(
|
|
|
386
385
|
}));
|
|
387
386
|
throw new CloudflareApiError(
|
|
388
387
|
`Error deleting D1 database '${databaseId}': ${errorData.errors?.[0]?.message || deleteResponse.statusText}`,
|
|
389
|
-
deleteResponse
|
|
388
|
+
deleteResponse,
|
|
390
389
|
);
|
|
391
390
|
}
|
|
392
391
|
}
|
|
@@ -396,19 +395,19 @@ export async function deleteDatabase(
|
|
|
396
395
|
*/
|
|
397
396
|
export async function listDatabases(
|
|
398
397
|
api: CloudflareApi,
|
|
399
|
-
name?: string
|
|
398
|
+
name?: string,
|
|
400
399
|
): Promise<{ name: string; id: string }[]> {
|
|
401
400
|
// Construct query string if name is provided
|
|
402
401
|
const queryParams = name ? `?name=${encodeURIComponent(name)}` : "";
|
|
403
402
|
|
|
404
403
|
const response = await api.get(
|
|
405
|
-
`/accounts/${api.accountId}/d1/database${queryParams}
|
|
404
|
+
`/accounts/${api.accountId}/d1/database${queryParams}`,
|
|
406
405
|
);
|
|
407
406
|
|
|
408
407
|
if (!response.ok) {
|
|
409
408
|
throw new CloudflareApiError(
|
|
410
409
|
`Failed to list databases: ${response.statusText}`,
|
|
411
|
-
response
|
|
410
|
+
response,
|
|
412
411
|
);
|
|
413
412
|
}
|
|
414
413
|
|
|
@@ -441,7 +440,7 @@ export async function listDatabases(
|
|
|
441
440
|
export async function updateDatabase(
|
|
442
441
|
api: CloudflareApi,
|
|
443
442
|
databaseId: string,
|
|
444
|
-
props: D1DatabaseProps
|
|
443
|
+
props: D1DatabaseProps,
|
|
445
444
|
): Promise<CloudflareD1Response> {
|
|
446
445
|
// Get current database state to check for non-mutable changes
|
|
447
446
|
const currentDB = await getDatabase(api, databaseId);
|
|
@@ -452,7 +451,7 @@ export async function updateDatabase(
|
|
|
452
451
|
props.primaryLocationHint !== currentDB.result.primary_location_hint
|
|
453
452
|
) {
|
|
454
453
|
throw new Error(
|
|
455
|
-
"Cannot update primaryLocationHint after database creation. Only readReplication.mode can be modified."
|
|
454
|
+
"Cannot update primaryLocationHint after database creation. Only readReplication.mode can be modified.",
|
|
456
455
|
);
|
|
457
456
|
}
|
|
458
457
|
|
|
@@ -467,7 +466,7 @@ export async function updateDatabase(
|
|
|
467
466
|
|
|
468
467
|
const updateResponse = await api.patch(
|
|
469
468
|
`/accounts/${api.accountId}/d1/database/${databaseId}`,
|
|
470
|
-
updatePayload
|
|
469
|
+
updatePayload,
|
|
471
470
|
);
|
|
472
471
|
|
|
473
472
|
if (!updateResponse.ok) {
|
|
@@ -475,7 +474,7 @@ export async function updateDatabase(
|
|
|
475
474
|
updateResponse,
|
|
476
475
|
"updating",
|
|
477
476
|
"D1 database",
|
|
478
|
-
databaseId
|
|
477
|
+
databaseId,
|
|
479
478
|
);
|
|
480
479
|
}
|
|
481
480
|
|