alchemy 0.12.21 → 0.13.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 -0
- 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.js +1 -5
- package/lib/cloudflare/api.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/hybrid-nodejs-compat.d.ts +0 -3
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +1 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.js +3 -4
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +1 -1
- 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 +31 -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/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.js +6 -12
- 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.js +8 -10
- 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 +1 -0
- 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 +1 -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 -5
- 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/account-id.ts +1 -1
- 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 +7 -11
- package/src/cloudflare/assets.ts +4 -4
- package/src/cloudflare/auth.ts +13 -13
- package/src/cloudflare/bucket.ts +62 -63
- package/src/cloudflare/bundle/hybrid-nodejs-compat.ts +13 -14
- 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 +53 -54
- 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/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 +61 -61
- 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 -14
- 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 +7 -6
- 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
|
@@ -45,7 +45,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
45
45
|
*/
|
|
46
46
|
constructor(
|
|
47
47
|
public readonly scope: Scope,
|
|
48
|
-
private readonly options: CloudflareR2StateStoreOptions = {}
|
|
48
|
+
private readonly options: CloudflareR2StateStoreOptions = {},
|
|
49
49
|
) {
|
|
50
50
|
// Use the scope's chain to build the prefix, similar to how FileSystemStateStore builds its directory
|
|
51
51
|
const scopePath = scope.chain.join("/");
|
|
@@ -74,7 +74,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
74
74
|
() => getBucket(this.api, this.bucketName),
|
|
75
75
|
isRetryableError,
|
|
76
76
|
5,
|
|
77
|
-
1000
|
|
77
|
+
1000,
|
|
78
78
|
);
|
|
79
79
|
} catch (error) {
|
|
80
80
|
// If not, create the alchemy state bucket
|
|
@@ -83,7 +83,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
83
83
|
() => createBucket(this.api, this.bucketName),
|
|
84
84
|
isRetryableError,
|
|
85
85
|
5,
|
|
86
|
-
1000
|
|
86
|
+
1000,
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -133,7 +133,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
133
133
|
// Retry on transient errors
|
|
134
134
|
isRetryableError,
|
|
135
135
|
5, // 5 retry attempts
|
|
136
|
-
1000 // Start with 1 second delay
|
|
136
|
+
1000, // Start with 1 second delay
|
|
137
137
|
);
|
|
138
138
|
|
|
139
139
|
const data = (await response.json()) as any;
|
|
@@ -147,7 +147,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
147
147
|
objects.map((obj: any) => {
|
|
148
148
|
const keyName = obj.key || obj.name;
|
|
149
149
|
return this.convertKeyFromStorage(keyName.slice(this.prefix.length));
|
|
150
|
-
})
|
|
150
|
+
}),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
// Update cursor for next page if available
|
|
@@ -181,7 +181,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
181
181
|
const response = await withExponentialBackoff(
|
|
182
182
|
async () => {
|
|
183
183
|
const response = await this.api.get(
|
|
184
|
-
`/accounts/${this.api.accountId}/r2/buckets/${this.bucketName}/objects/${this.getObjectKey(key)}
|
|
184
|
+
`/accounts/${this.api.accountId}/r2/buckets/${this.bucketName}/objects/${this.getObjectKey(key)}`,
|
|
185
185
|
);
|
|
186
186
|
|
|
187
187
|
if (!response.ok && response.status !== 404) {
|
|
@@ -193,7 +193,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
193
193
|
// Retry on transient errors
|
|
194
194
|
isRetryableError,
|
|
195
195
|
5, // 5 retry attempts
|
|
196
|
-
1000 // Start with 1 second delay
|
|
196
|
+
1000, // Start with 1 second delay
|
|
197
197
|
);
|
|
198
198
|
|
|
199
199
|
if (response.status === 404) {
|
|
@@ -275,7 +275,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
275
275
|
headers: {
|
|
276
276
|
"Content-Type": "application/json",
|
|
277
277
|
},
|
|
278
|
-
}
|
|
278
|
+
},
|
|
279
279
|
);
|
|
280
280
|
|
|
281
281
|
if (!response.ok) {
|
|
@@ -286,7 +286,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
286
286
|
// Retry on transient errors
|
|
287
287
|
isRetryableError,
|
|
288
288
|
5, // 5 retry attempts
|
|
289
|
-
1000 // Start with 1 second delay
|
|
289
|
+
1000, // Start with 1 second delay
|
|
290
290
|
);
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -301,7 +301,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
301
301
|
await withExponentialBackoff(
|
|
302
302
|
async () => {
|
|
303
303
|
const response = await this.api.delete(
|
|
304
|
-
`/accounts/${this.api.accountId}/r2/buckets/${this.bucketName}/objects/${this.getObjectKey(key)}
|
|
304
|
+
`/accounts/${this.api.accountId}/r2/buckets/${this.bucketName}/objects/${this.getObjectKey(key)}`,
|
|
305
305
|
);
|
|
306
306
|
|
|
307
307
|
if (!response.ok && response.status !== 404) {
|
|
@@ -312,7 +312,7 @@ export class R2RestStateStore implements StateStore {
|
|
|
312
312
|
},
|
|
313
313
|
isRetryableError,
|
|
314
314
|
5, // 5 retry attempts
|
|
315
|
-
1000 // Start with 1 second delay
|
|
315
|
+
1000, // Start with 1 second delay
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
318
|
|
|
@@ -39,7 +39,7 @@ export type Redwood<B extends Bindings> = B extends { ASSETS: any }
|
|
|
39
39
|
*/
|
|
40
40
|
export async function Redwood<B extends Bindings>(
|
|
41
41
|
id: string,
|
|
42
|
-
props?: Partial<RedwoodProps<B
|
|
42
|
+
props?: Partial<RedwoodProps<B>>,
|
|
43
43
|
): Promise<Redwood<B>> {
|
|
44
44
|
return Website(id, {
|
|
45
45
|
...props,
|
|
@@ -13,7 +13,7 @@ export type TanStackStart<B extends Bindings> = B extends { ASSETS: any }
|
|
|
13
13
|
|
|
14
14
|
export async function TanStackStart<B extends Bindings>(
|
|
15
15
|
id: string,
|
|
16
|
-
props?: Partial<TanStackStartProps<B
|
|
16
|
+
props?: Partial<TanStackStartProps<B>>,
|
|
17
17
|
): Promise<TanStackStart<B>> {
|
|
18
18
|
return Website(id, {
|
|
19
19
|
...props,
|
package/src/cloudflare/types.ts
CHANGED
|
@@ -62,9 +62,8 @@ export async function extractCloudflareError(
|
|
|
62
62
|
const data = (await response.json()) as CloudflareApiResponse<any>;
|
|
63
63
|
if (data.errors && data.errors.length > 0) {
|
|
64
64
|
return data.errors.map((e) => `Error ${e.code}: ${e.message}`).join(", ");
|
|
65
|
-
} else {
|
|
66
|
-
return `HTTP ${response.status}: ${response.statusText}`;
|
|
67
65
|
}
|
|
66
|
+
return `HTTP ${response.status}: ${response.statusText}`;
|
|
68
67
|
} catch (e) {
|
|
69
68
|
return `HTTP ${response.status}: ${response.statusText}`;
|
|
70
69
|
}
|
|
@@ -111,7 +111,7 @@ export const VectorizeIndex = Resource(
|
|
|
111
111
|
async function (
|
|
112
112
|
this: Context<VectorizeIndex>,
|
|
113
113
|
id: string,
|
|
114
|
-
props: VectorizeIndexProps
|
|
114
|
+
props: VectorizeIndexProps,
|
|
115
115
|
): Promise<VectorizeIndex> {
|
|
116
116
|
const api = await createCloudflareApi(props);
|
|
117
117
|
const indexName = props.name || id;
|
|
@@ -125,56 +125,55 @@ export const VectorizeIndex = Resource(
|
|
|
125
125
|
|
|
126
126
|
// Return void (a deleted index has no content)
|
|
127
127
|
return this.destroy();
|
|
128
|
-
}
|
|
129
|
-
|
|
128
|
+
}
|
|
129
|
+
let indexData: CloudflareVectorizeResponse;
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
131
|
+
if (this.phase === "create") {
|
|
132
|
+
console.log("Creating Vectorize index:", indexName);
|
|
133
|
+
try {
|
|
134
|
+
indexData = await createIndex(api, indexName, {
|
|
135
|
+
...props,
|
|
136
|
+
name: indexName,
|
|
137
|
+
});
|
|
138
|
+
} catch (error) {
|
|
139
|
+
// Check if this is a "index already exists" error and adopt is enabled
|
|
140
|
+
if (
|
|
141
|
+
props.adopt &&
|
|
142
|
+
error instanceof CloudflareApiError &&
|
|
143
|
+
error.message.includes("already exists")
|
|
144
|
+
) {
|
|
145
|
+
console.log(`Index ${indexName} already exists, adopting it`);
|
|
146
|
+
// Find the existing index
|
|
147
|
+
indexData = await getIndex(api, indexName);
|
|
148
|
+
} else {
|
|
149
|
+
// Re-throw the error if adopt is false or it's not a "index already exists" error
|
|
150
|
+
throw error;
|
|
152
151
|
}
|
|
153
|
-
} else {
|
|
154
|
-
// Update operation is not supported by Vectorize API
|
|
155
|
-
throw new Error(
|
|
156
|
-
"Updating Vectorize indexes is not supported by the Cloudflare API. " +
|
|
157
|
-
"To change an index, delete it and create a new one with the desired configuration."
|
|
158
|
-
);
|
|
159
152
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
dimensions: indexData.result.config.dimensions,
|
|
167
|
-
metric: indexData.result.config.metric as
|
|
168
|
-
| "cosine"
|
|
169
|
-
| "euclidean"
|
|
170
|
-
| "dot_product",
|
|
171
|
-
accountId: api.accountId,
|
|
172
|
-
createdAt: indexData.result.created_on
|
|
173
|
-
? new Date(indexData.result.created_on).getTime()
|
|
174
|
-
: undefined,
|
|
175
|
-
});
|
|
153
|
+
} else {
|
|
154
|
+
// Update operation is not supported by Vectorize API
|
|
155
|
+
throw new Error(
|
|
156
|
+
"Updating Vectorize indexes is not supported by the Cloudflare API. " +
|
|
157
|
+
"To change an index, delete it and create a new one with the desired configuration.",
|
|
158
|
+
);
|
|
176
159
|
}
|
|
177
|
-
|
|
160
|
+
|
|
161
|
+
return this({
|
|
162
|
+
type: "vectorize",
|
|
163
|
+
id: indexName,
|
|
164
|
+
name: indexName,
|
|
165
|
+
description: props.description,
|
|
166
|
+
dimensions: indexData.result.config.dimensions,
|
|
167
|
+
metric: indexData.result.config.metric as
|
|
168
|
+
| "cosine"
|
|
169
|
+
| "euclidean"
|
|
170
|
+
| "dot_product",
|
|
171
|
+
accountId: api.accountId,
|
|
172
|
+
createdAt: indexData.result.created_on
|
|
173
|
+
? new Date(indexData.result.created_on).getTime()
|
|
174
|
+
: undefined,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
178
177
|
);
|
|
179
178
|
|
|
180
179
|
interface CloudflareVectorizeResponse {
|
|
@@ -198,7 +197,7 @@ interface CloudflareVectorizeResponse {
|
|
|
198
197
|
export async function createIndex(
|
|
199
198
|
api: CloudflareApi,
|
|
200
199
|
indexName: string,
|
|
201
|
-
props: VectorizeIndexProps
|
|
200
|
+
props: VectorizeIndexProps,
|
|
202
201
|
): Promise<CloudflareVectorizeResponse> {
|
|
203
202
|
// Create new Vectorize index
|
|
204
203
|
const createPayload: any = {
|
|
@@ -215,7 +214,7 @@ export async function createIndex(
|
|
|
215
214
|
|
|
216
215
|
const createResponse = await api.post(
|
|
217
216
|
`/accounts/${api.accountId}/vectorize/v2/indexes`,
|
|
218
|
-
createPayload
|
|
217
|
+
createPayload,
|
|
219
218
|
);
|
|
220
219
|
|
|
221
220
|
if (!createResponse.ok) {
|
|
@@ -223,7 +222,7 @@ export async function createIndex(
|
|
|
223
222
|
createResponse,
|
|
224
223
|
"creating",
|
|
225
224
|
"Vectorize index",
|
|
226
|
-
indexName
|
|
225
|
+
indexName,
|
|
227
226
|
);
|
|
228
227
|
}
|
|
229
228
|
|
|
@@ -235,10 +234,10 @@ export async function createIndex(
|
|
|
235
234
|
*/
|
|
236
235
|
export async function getIndex(
|
|
237
236
|
api: CloudflareApi,
|
|
238
|
-
indexName: string
|
|
237
|
+
indexName: string,
|
|
239
238
|
): Promise<CloudflareVectorizeResponse> {
|
|
240
239
|
const response = await api.get(
|
|
241
|
-
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}
|
|
240
|
+
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}`,
|
|
242
241
|
);
|
|
243
242
|
|
|
244
243
|
if (!response.ok) {
|
|
@@ -246,7 +245,7 @@ export async function getIndex(
|
|
|
246
245
|
response,
|
|
247
246
|
"getting",
|
|
248
247
|
"Vectorize index",
|
|
249
|
-
indexName
|
|
248
|
+
indexName,
|
|
250
249
|
);
|
|
251
250
|
}
|
|
252
251
|
|
|
@@ -258,11 +257,11 @@ export async function getIndex(
|
|
|
258
257
|
*/
|
|
259
258
|
export async function deleteIndex(
|
|
260
259
|
api: CloudflareApi,
|
|
261
|
-
indexName: string
|
|
260
|
+
indexName: string,
|
|
262
261
|
): Promise<void> {
|
|
263
262
|
// Delete Vectorize index
|
|
264
263
|
const deleteResponse = await api.delete(
|
|
265
|
-
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}
|
|
264
|
+
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}`,
|
|
266
265
|
);
|
|
267
266
|
|
|
268
267
|
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
@@ -271,7 +270,7 @@ export async function deleteIndex(
|
|
|
271
270
|
}));
|
|
272
271
|
throw new CloudflareApiError(
|
|
273
272
|
`Error deleting Vectorize index '${indexName}': ${errorData.errors?.[0]?.message || deleteResponse.statusText}`,
|
|
274
|
-
deleteResponse
|
|
273
|
+
deleteResponse,
|
|
275
274
|
);
|
|
276
275
|
}
|
|
277
276
|
}
|
|
@@ -280,16 +279,16 @@ export async function deleteIndex(
|
|
|
280
279
|
* List all Vectorize indexes in an account
|
|
281
280
|
*/
|
|
282
281
|
export async function listIndexes(
|
|
283
|
-
api: CloudflareApi
|
|
282
|
+
api: CloudflareApi,
|
|
284
283
|
): Promise<{ name: string; description?: string }[]> {
|
|
285
284
|
const response = await api.get(
|
|
286
|
-
`/accounts/${api.accountId}/vectorize/v2/indexes
|
|
285
|
+
`/accounts/${api.accountId}/vectorize/v2/indexes`,
|
|
287
286
|
);
|
|
288
287
|
|
|
289
288
|
if (!response.ok) {
|
|
290
289
|
throw new CloudflareApiError(
|
|
291
290
|
`Failed to list indexes: ${response.statusText}`,
|
|
292
|
-
response
|
|
291
|
+
response,
|
|
293
292
|
);
|
|
294
293
|
}
|
|
295
294
|
|
|
@@ -323,9 +322,9 @@ export async function listIndexes(
|
|
|
323
322
|
export async function updateIndex(
|
|
324
323
|
api: CloudflareApi,
|
|
325
324
|
indexName: string,
|
|
326
|
-
props: VectorizeIndexProps
|
|
325
|
+
props: VectorizeIndexProps,
|
|
327
326
|
): Promise<CloudflareVectorizeResponse> {
|
|
328
327
|
throw new Error(
|
|
329
|
-
"Updating Vectorize indexes is not supported by the Cloudflare API. To change an index, delete it and create a new one."
|
|
328
|
+
"Updating Vectorize indexes is not supported by the Cloudflare API. To change an index, delete it and create a new one.",
|
|
330
329
|
);
|
|
331
330
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type CloudflareApi,
|
|
7
7
|
type CloudflareApiOptions,
|
|
8
8
|
} from "./api.js";
|
|
9
|
-
import { VectorizeIndex } from "./vectorize-index.js";
|
|
9
|
+
import type { VectorizeIndex } from "./vectorize-index.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Properties for creating or deleting a Vectorize Metadata Index
|
|
@@ -83,7 +83,7 @@ export const VectorizeMetadataIndex = Resource(
|
|
|
83
83
|
async function (
|
|
84
84
|
this: Context<VectorizeMetadataIndex>,
|
|
85
85
|
id: string,
|
|
86
|
-
props: VectorizeMetadataIndexProps
|
|
86
|
+
props: VectorizeMetadataIndexProps,
|
|
87
87
|
): Promise<VectorizeMetadataIndex> {
|
|
88
88
|
const api = await createCloudflareApi(props);
|
|
89
89
|
const indexName = props.index.name;
|
|
@@ -105,25 +105,25 @@ export const VectorizeMetadataIndex = Resource(
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
return this.destroy();
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
|
+
if (this.phase === "update") {
|
|
109
110
|
// Update operation is not supported
|
|
110
111
|
throw new Error(
|
|
111
112
|
"Updating Vectorize metadata indexes is not supported by the Cloudflare API. " +
|
|
112
|
-
"To change a metadata index, delete it and create a new one with the desired configuration."
|
|
113
|
+
"To change a metadata index, delete it and create a new one with the desired configuration.",
|
|
113
114
|
);
|
|
114
|
-
} else {
|
|
115
|
-
const indexData = await createMetadataIndex(api, indexName, props);
|
|
116
|
-
|
|
117
|
-
return this({
|
|
118
|
-
id: propertyName, // Use propertyName as ID
|
|
119
|
-
index: props.index,
|
|
120
|
-
propertyName: props.propertyName,
|
|
121
|
-
indexType: props.indexType,
|
|
122
|
-
accountId: api.accountId,
|
|
123
|
-
mutationId: indexData.result.mutationId,
|
|
124
|
-
});
|
|
125
115
|
}
|
|
126
|
-
|
|
116
|
+
const indexData = await createMetadataIndex(api, indexName, props);
|
|
117
|
+
|
|
118
|
+
return this({
|
|
119
|
+
id: propertyName, // Use propertyName as ID
|
|
120
|
+
index: props.index,
|
|
121
|
+
propertyName: props.propertyName,
|
|
122
|
+
indexType: props.indexType,
|
|
123
|
+
accountId: api.accountId,
|
|
124
|
+
mutationId: indexData.result.mutationId,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
interface CloudflareMetadataIndexResponse {
|
|
@@ -153,7 +153,7 @@ interface CloudflareMetadataIndexListResponse {
|
|
|
153
153
|
export async function createMetadataIndex(
|
|
154
154
|
api: CloudflareApi,
|
|
155
155
|
indexName: string,
|
|
156
|
-
props: VectorizeMetadataIndexProps
|
|
156
|
+
props: VectorizeMetadataIndexProps,
|
|
157
157
|
): Promise<CloudflareMetadataIndexResponse> {
|
|
158
158
|
// Create new metadata index
|
|
159
159
|
const createPayload = {
|
|
@@ -163,7 +163,7 @@ export async function createMetadataIndex(
|
|
|
163
163
|
|
|
164
164
|
const createResponse = await api.post(
|
|
165
165
|
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}/metadata_index/create`,
|
|
166
|
-
createPayload
|
|
166
|
+
createPayload,
|
|
167
167
|
);
|
|
168
168
|
|
|
169
169
|
if (!createResponse.ok) {
|
|
@@ -171,7 +171,7 @@ export async function createMetadataIndex(
|
|
|
171
171
|
createResponse,
|
|
172
172
|
"creating",
|
|
173
173
|
"Vectorize metadata index",
|
|
174
|
-
props.propertyName
|
|
174
|
+
props.propertyName,
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -184,13 +184,13 @@ export async function createMetadataIndex(
|
|
|
184
184
|
export async function deleteMetadataIndex(
|
|
185
185
|
api: CloudflareApi,
|
|
186
186
|
indexName: string,
|
|
187
|
-
propertyName: string
|
|
187
|
+
propertyName: string,
|
|
188
188
|
): Promise<void> {
|
|
189
189
|
const deleteResponse = await api.post(
|
|
190
190
|
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}/metadata_index/delete`,
|
|
191
191
|
{
|
|
192
192
|
propertyName,
|
|
193
|
-
}
|
|
193
|
+
},
|
|
194
194
|
);
|
|
195
195
|
|
|
196
196
|
if (!deleteResponse.ok) {
|
|
@@ -198,7 +198,7 @@ export async function deleteMetadataIndex(
|
|
|
198
198
|
deleteResponse,
|
|
199
199
|
"deleting",
|
|
200
200
|
"Vectorize metadata index",
|
|
201
|
-
propertyName
|
|
201
|
+
propertyName,
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -208,12 +208,12 @@ export async function deleteMetadataIndex(
|
|
|
208
208
|
*/
|
|
209
209
|
export async function listMetadataIndexes(
|
|
210
210
|
api: CloudflareApi,
|
|
211
|
-
indexName: string
|
|
211
|
+
indexName: string,
|
|
212
212
|
): Promise<
|
|
213
213
|
{ propertyName: string; indexType: "string" | "number" | "boolean" }[]
|
|
214
214
|
> {
|
|
215
215
|
const response = await api.get(
|
|
216
|
-
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}/metadata_index/list
|
|
216
|
+
`/accounts/${api.accountId}/vectorize/v2/indexes/${indexName}/metadata_index/list`,
|
|
217
217
|
);
|
|
218
218
|
|
|
219
219
|
if (response.status === 410) {
|
|
@@ -224,7 +224,7 @@ export async function listMetadataIndexes(
|
|
|
224
224
|
if (!response.ok) {
|
|
225
225
|
throw new CloudflareApiError(
|
|
226
226
|
`Failed to list metadata indexes: ${response.statusText}`,
|
|
227
|
-
response
|
|
227
|
+
response,
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
230
|
|
package/src/cloudflare/vite.ts
CHANGED
|
@@ -61,7 +61,7 @@ export type Website<B extends Bindings> = B extends { ASSETS: any }
|
|
|
61
61
|
|
|
62
62
|
export async function Website<B extends Bindings>(
|
|
63
63
|
id: string,
|
|
64
|
-
props: WebsiteProps<B
|
|
64
|
+
props: WebsiteProps<B>,
|
|
65
65
|
): Promise<Website<B>> {
|
|
66
66
|
if (props.bindings?.ASSETS) {
|
|
67
67
|
throw new Error("ASSETS binding is reserved for internal use");
|
|
@@ -98,8 +98,8 @@ export async function Website<B extends Bindings>(
|
|
|
98
98
|
compatibility_date: new Date().toISOString().split("T")[0],
|
|
99
99
|
},
|
|
100
100
|
null,
|
|
101
|
-
2
|
|
102
|
-
)
|
|
101
|
+
2,
|
|
102
|
+
),
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
}
|