alchemy 0.51.3 → 0.53.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.
Files changed (91) hide show
  1. package/lib/cloudflare/assets.d.ts +1 -1
  2. package/lib/cloudflare/assets.d.ts.map +1 -1
  3. package/lib/cloudflare/bindings.d.ts +12 -11
  4. package/lib/cloudflare/bindings.d.ts.map +1 -1
  5. package/lib/cloudflare/bindings.js.map +1 -1
  6. package/lib/cloudflare/bound.d.ts +11 -18
  7. package/lib/cloudflare/bound.d.ts.map +1 -1
  8. package/lib/cloudflare/bucket.d.ts +4 -5
  9. package/lib/cloudflare/bucket.d.ts.map +1 -1
  10. package/lib/cloudflare/bucket.js +1 -16
  11. package/lib/cloudflare/bucket.js.map +1 -1
  12. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  13. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  14. package/lib/cloudflare/d1-database.d.ts +85 -26
  15. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  16. package/lib/cloudflare/d1-database.js +66 -47
  17. package/lib/cloudflare/d1-database.js.map +1 -1
  18. package/lib/cloudflare/d1-local-migrations.d.ts +10 -0
  19. package/lib/cloudflare/d1-local-migrations.d.ts.map +1 -0
  20. package/lib/cloudflare/d1-local-migrations.js +39 -0
  21. package/lib/cloudflare/d1-local-migrations.js.map +1 -0
  22. package/lib/cloudflare/dispatch-namespace.d.ts +4 -6
  23. package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -1
  24. package/lib/cloudflare/dispatch-namespace.js +1 -11
  25. package/lib/cloudflare/dispatch-namespace.js.map +1 -1
  26. package/lib/cloudflare/event-source.d.ts +3 -3
  27. package/lib/cloudflare/event-source.d.ts.map +1 -1
  28. package/lib/cloudflare/hyperdrive.d.ts +3 -4
  29. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  30. package/lib/cloudflare/hyperdrive.js +1 -9
  31. package/lib/cloudflare/hyperdrive.js.map +1 -1
  32. package/lib/cloudflare/index.d.ts +1 -0
  33. package/lib/cloudflare/index.d.ts.map +1 -1
  34. package/lib/cloudflare/index.js +1 -0
  35. package/lib/cloudflare/index.js.map +1 -1
  36. package/lib/cloudflare/kv-namespace.d.ts +4 -5
  37. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  38. package/lib/cloudflare/kv-namespace.js +1 -14
  39. package/lib/cloudflare/kv-namespace.js.map +1 -1
  40. package/lib/cloudflare/pipeline.d.ts +4 -5
  41. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  42. package/lib/cloudflare/pipeline.js +1 -12
  43. package/lib/cloudflare/pipeline.js.map +1 -1
  44. package/lib/cloudflare/queue-consumer.d.ts +3 -3
  45. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  46. package/lib/cloudflare/queue.d.ts +3 -4
  47. package/lib/cloudflare/queue.d.ts.map +1 -1
  48. package/lib/cloudflare/queue.js +1 -11
  49. package/lib/cloudflare/queue.js.map +1 -1
  50. package/lib/cloudflare/vectorize-index.d.ts +4 -5
  51. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  52. package/lib/cloudflare/vectorize-index.js +1 -15
  53. package/lib/cloudflare/vectorize-index.js.map +1 -1
  54. package/lib/cloudflare/vectorize-metadata-index.d.ts +2 -2
  55. package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
  56. package/lib/cloudflare/worker-ref.d.ts +41 -0
  57. package/lib/cloudflare/worker-ref.d.ts.map +1 -0
  58. package/lib/cloudflare/worker-ref.js +27 -0
  59. package/lib/cloudflare/worker-ref.js.map +1 -0
  60. package/lib/cloudflare/worker.d.ts +6 -68
  61. package/lib/cloudflare/worker.d.ts.map +1 -1
  62. package/lib/cloudflare/worker.js +5 -198
  63. package/lib/cloudflare/worker.js.map +1 -1
  64. package/lib/cloudflare/wrangler.json.js +2 -2
  65. package/lib/cloudflare/wrangler.json.js.map +1 -1
  66. package/lib/esbuild/bundle.d.ts +2 -2
  67. package/lib/state/instrumented-state-store.d.ts +2 -0
  68. package/lib/state/instrumented-state-store.d.ts.map +1 -1
  69. package/lib/state/instrumented-state-store.js +2 -0
  70. package/lib/state/instrumented-state-store.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/cloudflare/bindings.ts +18 -17
  73. package/src/cloudflare/bound.ts +35 -18
  74. package/src/cloudflare/bucket.ts +5 -27
  75. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  76. package/src/cloudflare/d1-database.ts +107 -100
  77. package/src/cloudflare/d1-local-migrations.ts +52 -0
  78. package/src/cloudflare/dispatch-namespace.ts +6 -25
  79. package/src/cloudflare/event-source.ts +3 -3
  80. package/src/cloudflare/hyperdrive.ts +4 -19
  81. package/src/cloudflare/index.ts +1 -0
  82. package/src/cloudflare/kv-namespace.ts +5 -28
  83. package/src/cloudflare/pipeline.ts +8 -27
  84. package/src/cloudflare/queue-consumer.ts +3 -3
  85. package/src/cloudflare/queue.ts +4 -22
  86. package/src/cloudflare/vectorize-index.ts +5 -27
  87. package/src/cloudflare/vectorize-metadata-index.ts +2 -2
  88. package/src/cloudflare/worker-ref.ts +51 -0
  89. package/src/cloudflare/worker.ts +16 -332
  90. package/src/cloudflare/wrangler.json.ts +2 -2
  91. package/src/state/instrumented-state-store.ts +2 -0
@@ -1,6 +1,5 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource, ResourceKind } from "../resource.ts";
3
- import { bind } from "../runtime/bind.ts";
4
3
  import { logger } from "../util/logger.ts";
5
4
  import { CloudflareApiError, handleApiError } from "./api-error.ts";
6
5
  import {
@@ -37,14 +36,14 @@ export interface DispatchNamespaceProps extends CloudflareApiOptions {
37
36
 
38
37
  export function isDispatchNamespace(
39
38
  resource: Resource,
40
- ): resource is DispatchNamespaceResource {
39
+ ): resource is DispatchNamespace {
41
40
  return resource[ResourceKind] === "cloudflare::DispatchNamespace";
42
41
  }
43
42
 
44
43
  /**
45
44
  * Output returned after Dispatch Namespace creation/update
46
45
  */
47
- export interface DispatchNamespaceResource
46
+ export interface DispatchNamespace
48
47
  extends Resource<"cloudflare::DispatchNamespace">,
49
48
  Omit<DispatchNamespaceProps, "delete"> {
50
49
  type: "dispatch_namespace";
@@ -74,10 +73,6 @@ export interface DispatchNamespaceResource
74
73
  modifiedAt: number;
75
74
  }
76
75
 
77
- export type DispatchNamespace = DispatchNamespaceResource & {
78
- get(name: string): Fetcher;
79
- };
80
-
81
76
  /**
82
77
  * A Cloudflare Dispatch Namespace enables routing worker requests to different scripts based on patterns.
83
78
  *
@@ -107,27 +102,13 @@ export type DispatchNamespace = DispatchNamespaceResource & {
107
102
  * delete: false
108
103
  * });
109
104
  */
110
-
111
- export async function DispatchNamespace(
112
- name: string,
113
- props: DispatchNamespaceProps = {},
114
- ): Promise<DispatchNamespace> {
115
- const dispatchNamespace = await _DispatchNamespace(name, props);
116
- const binding = await bind(dispatchNamespace);
117
- return {
118
- ...dispatchNamespace,
119
- // Add runtime methods that dispatch namespaces have
120
- get: binding.get,
121
- };
122
- }
123
-
124
- const _DispatchNamespace = Resource(
105
+ export const DispatchNamespace = Resource(
125
106
  "cloudflare::DispatchNamespace",
126
107
  async function (
127
- this: Context<DispatchNamespaceResource>,
108
+ this: Context<DispatchNamespace>,
128
109
  id: string,
129
- props: DispatchNamespaceProps,
130
- ): Promise<DispatchNamespaceResource> {
110
+ props: DispatchNamespaceProps = {},
111
+ ): Promise<DispatchNamespace> {
131
112
  // Create Cloudflare API client with automatic account discovery
132
113
  const api = await createCloudflareApi(props);
133
114
 
@@ -1,10 +1,10 @@
1
1
  import type { QueueConsumerSettings } from "./queue-consumer.ts";
2
- import type { QueueResource } from "./queue.ts";
2
+ import type { Queue } from "./queue.ts";
3
3
 
4
4
  /**
5
5
  * Base interface for event sources that can be bound to a Worker
6
6
  */
7
- export type EventSource = QueueEventSource | QueueResource;
7
+ export type EventSource = QueueEventSource | Queue;
8
8
 
9
9
  /**
10
10
  * Configuration for a Queue as an event source for a Worker
@@ -13,7 +13,7 @@ export interface QueueEventSource {
13
13
  /**
14
14
  * The queue to consume messages from
15
15
  */
16
- readonly queue: QueueResource;
16
+ readonly queue: Queue;
17
17
 
18
18
  /**
19
19
  * Optional settings for configuring how the Worker consumes the queue
@@ -1,11 +1,9 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource } from "../resource.ts";
3
- import { tryGetBinding } from "../runtime/bind.ts";
4
3
  import type { Secret } from "../secret.ts";
5
4
  import { logger } from "../util/logger.ts";
6
5
  import { handleApiError } from "./api-error.ts";
7
6
  import { createCloudflareApi, type CloudflareApiOptions } from "./api.ts";
8
- import type { Bound } from "./bound.ts";
9
7
 
10
8
  /**
11
9
  * Origin configuration for a PostgreSQL or MySQL database connection
@@ -156,7 +154,7 @@ export interface HyperdriveProps extends CloudflareApiOptions {
156
154
  * Output returned after Cloudflare Hyperdrive creation/update.
157
155
  * IMPORTANT: The interface name MUST match the exported resource name.
158
156
  */
159
- export interface HyperdriveResource
157
+ export interface Hyperdrive
160
158
  extends Resource<"cloudflare::Hyperdrive">,
161
159
  Omit<HyperdriveProps, "origin"> {
162
160
  /**
@@ -181,8 +179,6 @@ export interface HyperdriveResource
181
179
  type: "hyperdrive";
182
180
  }
183
181
 
184
- export type Hyperdrive = HyperdriveResource & Bound<HyperdriveResource>;
185
-
186
182
  /**
187
183
  * Represents a Cloudflare Hyperdrive configuration.
188
184
  *
@@ -261,24 +257,13 @@ export type Hyperdrive = HyperdriveResource & Bound<HyperdriveResource>;
261
257
  * }
262
258
  * });
263
259
  */
264
- export async function Hyperdrive(
265
- name: string,
266
- props: HyperdriveProps,
267
- ): Promise<Hyperdrive> {
268
- const resource = await HyperdriveResource(name, props);
269
- return {
270
- ...resource,
271
- ...tryGetBinding(resource),
272
- } as Hyperdrive;
273
- }
274
-
275
- const HyperdriveResource = Resource(
260
+ export const Hyperdrive = Resource(
276
261
  "cloudflare::Hyperdrive",
277
262
  async function (
278
- this: Context<HyperdriveResource>,
263
+ this: Context<Hyperdrive>,
279
264
  id: string,
280
265
  props: HyperdriveProps,
281
- ): Promise<HyperdriveResource> {
266
+ ): Promise<Hyperdrive> {
282
267
  const api = await createCloudflareApi(props);
283
268
  const configsPath = `/accounts/${api.accountId}/hyperdrive/configs`;
284
269
 
@@ -55,6 +55,7 @@ export * from "./vectorize-metadata-index.ts";
55
55
  export * from "./version-metadata.ts";
56
56
  export * from "./vite.ts";
57
57
  export * from "./website.ts";
58
+ export * from "./worker-ref.ts";
58
59
  export * from "./worker-stub.ts";
59
60
  export * from "./worker-subdomain.ts";
60
61
  export * from "./worker.ts";
@@ -1,6 +1,5 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource, ResourceKind } from "../resource.ts";
3
- import { bind } from "../runtime/bind.ts";
4
3
  import { logger } from "../util/logger.ts";
5
4
  import { withExponentialBackoff } from "../util/retry.ts";
6
5
  import { handleApiError } from "./api-error.ts";
@@ -9,7 +8,6 @@ import {
9
8
  type CloudflareApi,
10
9
  type CloudflareApiOptions,
11
10
  } from "./api.ts";
12
- import type { Bound } from "./bound.ts";
13
11
 
14
12
  /**
15
13
  * Properties for creating or updating a KV Namespace
@@ -84,16 +82,14 @@ export interface KVPair {
84
82
  metadata?: any;
85
83
  }
86
84
 
87
- export function isKVNamespace(
88
- resource: Resource,
89
- ): resource is KVNamespaceResource {
85
+ export function isKVNamespace(resource: Resource): resource is KVNamespace {
90
86
  return resource[ResourceKind] === "cloudflare::KVNamespace";
91
87
  }
92
88
 
93
89
  /**
94
90
  * Output returned after KV Namespace creation/update
95
91
  */
96
- export interface KVNamespaceResource
92
+ export interface KVNamespace
97
93
  extends Resource<"cloudflare::KVNamespace">,
98
94
  Omit<KVNamespaceProps, "delete"> {
99
95
  type: "kv_namespace";
@@ -113,8 +109,6 @@ export interface KVNamespaceResource
113
109
  modifiedAt: number;
114
110
  }
115
111
 
116
- export type KVNamespace = KVNamespaceResource & Bound<KVNamespaceResource>;
117
-
118
112
  /**
119
113
  * A Cloudflare KV Namespace is a key-value store that can be used to store data for your application.
120
114
  *
@@ -169,30 +163,13 @@ export type KVNamespace = KVNamespaceResource & Bound<KVNamespaceResource>;
169
163
  * delete: false
170
164
  * });
171
165
  */
172
-
173
- export async function KVNamespace(
174
- name: string,
175
- props: KVNamespaceProps = {},
176
- ): Promise<KVNamespace> {
177
- const kv = await _KVNamespace(name, props);
178
- const binding = await bind(kv);
179
- return {
180
- ...kv,
181
- delete: binding.delete,
182
- get: binding.get,
183
- getWithMetadata: binding.getWithMetadata,
184
- list: binding.list,
185
- put: binding.put,
186
- };
187
- }
188
-
189
- const _KVNamespace = Resource(
166
+ export const KVNamespace = Resource(
190
167
  "cloudflare::KVNamespace",
191
168
  async function (
192
- this: Context<KVNamespaceResource>,
169
+ this: Context<KVNamespace>,
193
170
  id: string,
194
171
  props: KVNamespaceProps,
195
- ): Promise<KVNamespaceResource> {
172
+ ): Promise<KVNamespace> {
196
173
  // Create Cloudflare API client with automatic account discovery
197
174
  const api = await createCloudflareApi(props);
198
175
 
@@ -1,6 +1,5 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource, ResourceKind } from "../resource.ts";
3
- import { bind } from "../runtime/bind.ts";
4
3
  import type { Secret } from "../secret.ts";
5
4
  import { logger } from "../util/logger.ts";
6
5
  import { CloudflareApiError, handleApiError } from "./api-error.ts";
@@ -9,7 +8,6 @@ import {
9
8
  type CloudflareApi,
10
9
  type CloudflareApiOptions,
11
10
  } from "./api.ts";
12
- import type { Bound } from "./bound.ts";
13
11
 
14
12
  /**
15
13
  * Settings for compression of pipeline output
@@ -229,10 +227,14 @@ export interface PipelineRecord {
229
227
  [key: string]: any;
230
228
  }
231
229
 
230
+ export function isPipeline(resource: Resource): resource is Pipeline {
231
+ return resource[ResourceKind] === "cloudflare::Pipeline";
232
+ }
233
+
232
234
  /**
233
235
  * Output returned after Pipeline creation/update
234
236
  */
235
- export interface PipelineResource<_T extends PipelineRecord = PipelineRecord>
237
+ export interface Pipeline<_T extends PipelineRecord = PipelineRecord>
236
238
  extends Resource<"cloudflare::Pipeline">,
237
239
  PipelineProps {
238
240
  /**
@@ -261,13 +263,6 @@ export interface PipelineResource<_T extends PipelineRecord = PipelineRecord>
261
263
  version: number;
262
264
  }
263
265
 
264
- export function isPipeline(resource: Resource): resource is PipelineResource {
265
- return resource[ResourceKind] === "cloudflare::Pipeline";
266
- }
267
-
268
- export type Pipeline<T extends PipelineRecord = PipelineRecord> =
269
- PipelineResource<T> & Bound<PipelineResource<T>>;
270
-
271
266
  /**
272
267
  * Creates and manages Cloudflare Pipelines.
273
268
  *
@@ -334,24 +329,10 @@ export type Pipeline<T extends PipelineRecord = PipelineRecord> =
334
329
  *
335
330
  * @see https://developers.cloudflare.com/pipelines/
336
331
  */
337
- export async function Pipeline<T extends PipelineRecord = PipelineRecord>(
338
- name: string,
339
- props: PipelineProps,
340
- ): Promise<Pipeline<T>> {
341
- const pipeline = await PipelineResource(name, props);
342
- const binding = await bind(pipeline, {
343
- bindThis: false,
344
- });
345
- return {
346
- ...pipeline,
347
- send: binding.send,
348
- };
349
- }
350
-
351
- const PipelineResource = Resource("cloudflare::Pipeline", async function <
332
+ export const Pipeline = Resource("cloudflare::Pipeline", async function <
352
333
  T extends PipelineRecord = PipelineRecord,
353
- >(this: Context<PipelineResource<T>>, id: string, props: PipelineProps): Promise<
354
- PipelineResource<T>
334
+ >(this: Context<Pipeline<T>>, id: string, props: PipelineProps): Promise<
335
+ Pipeline<T>
355
336
  > {
356
337
  const api = await createCloudflareApi(props);
357
338
  const pipelineName = props.name ?? id;
@@ -7,7 +7,7 @@ import {
7
7
  type CloudflareApi,
8
8
  type CloudflareApiOptions,
9
9
  } from "./api.ts";
10
- import type { Queue, QueueResource } from "./queue.ts";
10
+ import type { Queue } from "./queue.ts";
11
11
 
12
12
  /**
13
13
  * Settings for configuring a Queue Consumer
@@ -55,9 +55,9 @@ export interface QueueConsumerSettings {
55
55
  */
56
56
  export interface QueueConsumerProps extends CloudflareApiOptions {
57
57
  /**
58
- * The {@link QueueResource} or Queue ID to consume
58
+ * The {@link Queue} or Queue ID to consume
59
59
  */
60
- queue: string | QueueResource;
60
+ queue: string | Queue;
61
61
 
62
62
  /**
63
63
  * Name of the worker script that will consume the queue
@@ -1,13 +1,11 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource, ResourceKind } from "../resource.ts";
3
- import { bind } from "../runtime/bind.ts";
4
3
  import { CloudflareApiError, handleApiError } from "./api-error.ts";
5
4
  import {
6
5
  createCloudflareApi,
7
6
  type CloudflareApi,
8
7
  type CloudflareApiOptions,
9
8
  } from "./api.ts";
10
- import type { Bound } from "./bound.ts";
11
9
 
12
10
  /**
13
11
  * Settings for a Cloudflare Queue
@@ -95,7 +93,7 @@ export function isQueue(eventSource: any): eventSource is Queue {
95
93
  /**
96
94
  * Output returned after Cloudflare Queue creation/update
97
95
  */
98
- export interface QueueResource<Body = unknown>
96
+ export interface Queue<Body = unknown>
99
97
  extends Resource<"cloudflare::Queue">,
100
98
  QueueProps {
101
99
  /**
@@ -131,9 +129,6 @@ export interface QueueResource<Body = unknown>
131
129
  Batch: MessageBatch<Body>;
132
130
  }
133
131
 
134
- export type Queue<Body = unknown> = QueueResource<Body> &
135
- Bound<QueueResource<Body>>;
136
-
137
132
  /**
138
133
  * Creates and manages Cloudflare Queues.
139
134
  *
@@ -213,23 +208,10 @@ export type Queue<Body = unknown> = QueueResource<Body> &
213
208
  *
214
209
  * @see https://developers.cloudflare.com/queues/
215
210
  */
216
- export async function Queue<Body = unknown>(
217
- name: string,
218
- props: QueueProps = {},
219
- ): Promise<Queue<Body>> {
220
- const queue = await QueueResource<Body>(name, props);
221
- const binding = await bind(queue);
222
- return {
223
- ...queue,
224
- send: binding.send,
225
- sendBatch: binding.sendBatch,
226
- } as Queue<Body>;
227
- }
228
-
229
- const QueueResource = Resource("cloudflare::Queue", async function <
211
+ export const Queue = Resource("cloudflare::Queue", async function <
230
212
  T = unknown,
231
- >(this: Context<QueueResource<T>>, id: string, props: QueueProps = {}): Promise<
232
- QueueResource<T>
213
+ >(this: Context<Queue<T>>, id: string, props: QueueProps = {}): Promise<
214
+ Queue<T>
233
215
  > {
234
216
  const api = await createCloudflareApi(props);
235
217
  const queueName = props.name ?? id;
@@ -1,6 +1,5 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource, ResourceKind } from "../resource.ts";
3
- import { bind } from "../runtime/bind.ts";
4
3
  import { logger } from "../util/logger.ts";
5
4
  import { CloudflareApiError, handleApiError } from "./api-error.ts";
6
5
  import {
@@ -8,7 +7,6 @@ import {
8
7
  type CloudflareApi,
9
8
  type CloudflareApiOptions,
10
9
  } from "./api.ts";
11
- import type { Bound } from "./bound.ts";
12
10
 
13
11
  /**
14
12
  * Properties for creating or updating a Vectorize Index
@@ -53,14 +51,14 @@ export interface VectorizeIndexProps extends CloudflareApiOptions {
53
51
 
54
52
  export function isVectorizeIndex(
55
53
  resource: Resource,
56
- ): resource is VectorizeIndexResource {
54
+ ): resource is VectorizeIndex {
57
55
  return resource[ResourceKind] === "cloudflare::VectorizeIndex";
58
56
  }
59
57
 
60
58
  /**
61
59
  * Output returned after Vectorize Index creation/update
62
60
  */
63
- export interface VectorizeIndexResource
61
+ export interface VectorizeIndex
64
62
  extends Resource<"cloudflare::VectorizeIndex">,
65
63
  VectorizeIndexProps {
66
64
  type: "vectorize";
@@ -76,9 +74,6 @@ export interface VectorizeIndexResource
76
74
  createdAt?: number;
77
75
  }
78
76
 
79
- export type VectorizeIndex = VectorizeIndexResource &
80
- Bound<VectorizeIndexResource>;
81
-
82
77
  /**
83
78
  * Creates and manages Cloudflare Vectorize Indexes.
84
79
  *
@@ -118,30 +113,13 @@ export type VectorizeIndex = VectorizeIndexResource &
118
113
  *
119
114
  * @see https://developers.cloudflare.com/vectorize/
120
115
  */
121
- export async function VectorizeIndex(
122
- name: string,
123
- props: VectorizeIndexProps,
124
- ): Promise<VectorizeIndex> {
125
- const index = await _VectorizeIndex(name, props);
126
- const binding = await bind(index);
127
- return {
128
- ...index,
129
- describe: binding.describe,
130
- query: binding.query,
131
- insert: binding.insert,
132
- upsert: binding.upsert,
133
- deleteByIds: binding.deleteByIds,
134
- getByIds: binding.getByIds,
135
- };
136
- }
137
-
138
- const _VectorizeIndex = Resource(
116
+ export const VectorizeIndex = Resource(
139
117
  "cloudflare::VectorizeIndex",
140
118
  async function (
141
- this: Context<VectorizeIndexResource>,
119
+ this: Context<VectorizeIndex>,
142
120
  id: string,
143
121
  props: VectorizeIndexProps,
144
- ): Promise<VectorizeIndexResource> {
122
+ ): Promise<VectorizeIndex> {
145
123
  const api = await createCloudflareApi(props);
146
124
  const indexName = props.name || id;
147
125
 
@@ -7,7 +7,7 @@ import {
7
7
  type CloudflareApi,
8
8
  type CloudflareApiOptions,
9
9
  } from "./api.ts";
10
- import type { VectorizeIndexResource } from "./vectorize-index.ts";
10
+ import type { VectorizeIndex } from "./vectorize-index.ts";
11
11
 
12
12
  /**
13
13
  * Properties for creating or deleting a Vectorize Metadata Index
@@ -16,7 +16,7 @@ export interface VectorizeMetadataIndexProps extends CloudflareApiOptions {
16
16
  /**
17
17
  * Parent Vectorize Index
18
18
  */
19
- index: VectorizeIndexResource;
19
+ index: VectorizeIndex;
20
20
 
21
21
  /**
22
22
  * Name of the property in the metadata to create an index for
@@ -0,0 +1,51 @@
1
+ import type { WorkerBindingService } from "./bindings.ts";
2
+
3
+ /**
4
+ * Represents a reference to a Cloudflare Worker service.
5
+ *
6
+ * @template RPC - The type of the worker's RPC entrypoint, defaults to Rpc.WorkerEntrypointBranded.
7
+ *
8
+ * This interface extends all properties of WorkerBindingService except for "name".
9
+ * It also includes an optional __rpc__ property for type branding.
10
+ */
11
+ export type WorkerRef<
12
+ RPC extends Rpc.WorkerEntrypointBranded = Rpc.WorkerEntrypointBranded,
13
+ > = Omit<WorkerBindingService, "name"> & {
14
+ /**
15
+ * Optional type branding for the worker's RPC entrypoint.
16
+ */
17
+ __rpc__?: RPC;
18
+ };
19
+
20
+ /**
21
+ * Creates a reference to a Cloudflare Worker service.
22
+ *
23
+ * @example
24
+ * // Create a reference to a Cloudflare Worker service:
25
+ * const ref = WorkerRef({
26
+ * service: "my-worker",
27
+ * environment: "production",
28
+ * namespace: "main"
29
+ * });
30
+ *
31
+ * // Optionally, you can specify only the service:
32
+ * const ref2 = WorkerRef({ service: "my-worker" });
33
+ *
34
+ * // You can also specify the RPC type for stronger typing:
35
+ * interface MyWorkerRPC extends Rpc.WorkerEntrypointBranded {
36
+ * myMethod(arg: string): Promise<number>;
37
+ * }
38
+ * const typedRef = WorkerRef<MyWorkerRPC>({ service: "my-worker" });
39
+ */
40
+ export function WorkerRef<
41
+ RPC extends Rpc.WorkerEntrypointBranded = Rpc.WorkerEntrypointBranded,
42
+ >(options?: {
43
+ service: string;
44
+ environment?: string;
45
+ namespace?: string;
46
+ }): WorkerRef<RPC> {
47
+ return {
48
+ ...options,
49
+ type: "service",
50
+ } as WorkerRef<RPC>;
51
+ }