alchemy 0.12.6 → 0.12.8
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/cloudflare/ai-gateway.d.ts.map +1 -1
- package/lib/cloudflare/ai-gateway.js +1 -2
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +2 -1
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bound.d.ts +2 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +8 -2
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +1 -1
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +8 -2
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +2 -2
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/event-source.d.ts +26 -0
- package/lib/cloudflare/event-source.d.ts.map +1 -0
- package/lib/cloudflare/event-source.js +9 -0
- package/lib/cloudflare/event-source.js.map +1 -0
- package/lib/cloudflare/hyperdrive.d.ts +216 -0
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -0
- package/lib/cloudflare/hyperdrive.js +184 -0
- package/lib/cloudflare/hyperdrive.js.map +1 -0
- package/lib/cloudflare/index.d.ts +2 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +2 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +162 -0
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -0
- package/lib/cloudflare/queue-consumer.js +197 -0
- package/lib/cloudflare/queue-consumer.js.map +1 -0
- package/lib/cloudflare/queue.d.ts +15 -3
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +8 -2
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +8 -10
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +13 -2
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +75 -3
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +13 -3
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +27 -5
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/neon/api-error.d.ts +31 -0
- package/lib/neon/api-error.d.ts.map +1 -0
- package/lib/neon/api-error.js +73 -0
- package/lib/neon/api-error.js.map +1 -0
- package/lib/neon/api.d.ts +70 -0
- package/lib/neon/api.d.ts.map +1 -0
- package/lib/neon/api.js +128 -0
- package/lib/neon/api.js.map +1 -0
- package/lib/neon/index.d.ts +4 -0
- package/lib/neon/index.d.ts.map +1 -0
- package/lib/neon/index.js +4 -0
- package/lib/neon/index.js.map +1 -0
- package/lib/neon/project.d.ts +345 -0
- package/lib/neon/project.d.ts.map +1 -0
- package/lib/neon/project.js +305 -0
- package/lib/neon/project.js.map +1 -0
- package/package.json +2 -1
- package/src/cloudflare/ai-gateway.ts +0 -1
- package/src/cloudflare/bindings.ts +4 -2
- package/src/cloudflare/bound.ts +20 -17
- package/src/cloudflare/bucket.ts +9 -2
- package/src/cloudflare/d1-database.ts +10 -3
- package/src/cloudflare/event-source.ts +33 -0
- package/src/cloudflare/hyperdrive.ts +375 -0
- package/src/cloudflare/index.ts +2 -0
- package/src/cloudflare/queue-consumer.ts +433 -0
- package/src/cloudflare/queue.ts +83 -63
- package/src/cloudflare/website.ts +9 -13
- package/src/cloudflare/worker.ts +109 -5
- package/src/cloudflare/wrangler.json.ts +52 -8
- package/src/neon/api-error.ts +81 -0
- package/src/neon/api.ts +178 -0
- package/src/neon/index.ts +3 -0
- package/src/neon/project.ts +870 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { handleApiError } from "./api-error.js";
|
|
3
|
+
import { createCloudflareApi } from "./api.js";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Cloudflare Hyperdrive configuration.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Create a basic Hyperdrive connection to a PostgreSQL database
|
|
9
|
+
* const basicHyperdrive = await Hyperdrive("my-postgres-db", {
|
|
10
|
+
* name: "my-postgres-db",
|
|
11
|
+
* origin: {
|
|
12
|
+
* database: "postgres",
|
|
13
|
+
* host: "database.example.com",
|
|
14
|
+
* password: alchemy.secret("your-password"),
|
|
15
|
+
* port: 5432,
|
|
16
|
+
* user: "postgres"
|
|
17
|
+
* }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Create a Hyperdrive with caching disabled
|
|
22
|
+
* const noCacheHyperdrive = await Hyperdrive("no-cache-db", {
|
|
23
|
+
* name: "no-cache-db",
|
|
24
|
+
* origin: {
|
|
25
|
+
* database: "postgres",
|
|
26
|
+
* host: "database.example.com",
|
|
27
|
+
* password: alchemy.secret(process.env.DB_PASSWORD),
|
|
28
|
+
* port: 5432,
|
|
29
|
+
* user: "postgres"
|
|
30
|
+
* },
|
|
31
|
+
* caching: {
|
|
32
|
+
* disabled: true
|
|
33
|
+
* }
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Create a Hyperdrive with mTLS configuration
|
|
38
|
+
* const mtlsHyperdrive = await Hyperdrive("secure-db", {
|
|
39
|
+
* name: "secure-db",
|
|
40
|
+
* origin: {
|
|
41
|
+
* database: "postgres",
|
|
42
|
+
* host: "database.example.com",
|
|
43
|
+
* password: alchemy.secret(process.env.DB_PASSWORD),
|
|
44
|
+
* port: 5432,
|
|
45
|
+
* user: "postgres"
|
|
46
|
+
* },
|
|
47
|
+
* mtls: {
|
|
48
|
+
* ca_certificate_id: "00000000-0000-0000-0000-0000000000",
|
|
49
|
+
* mtls_certificate_id: "00000000-0000-0000-0000-0000000000",
|
|
50
|
+
* sslmode: "verify-full"
|
|
51
|
+
* }
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Create a Hyperdrive with access client credentials
|
|
56
|
+
* const accessHyperdrive = await Hyperdrive("access-db", {
|
|
57
|
+
* name: "access-db",
|
|
58
|
+
* origin: {
|
|
59
|
+
* database: "postgres",
|
|
60
|
+
* host: "database.example.com",
|
|
61
|
+
* access_client_id: "client-id",
|
|
62
|
+
* access_client_secret: alchemy.secret(process.env.ACCESS_CLIENT_SECRET),
|
|
63
|
+
* port: 5432,
|
|
64
|
+
* user: "postgres"
|
|
65
|
+
* }
|
|
66
|
+
* });
|
|
67
|
+
*/
|
|
68
|
+
export const Hyperdrive = Resource("cloudflare::Hyperdrive", async function (id, props) {
|
|
69
|
+
const api = await createCloudflareApi(props);
|
|
70
|
+
const configsPath = `/accounts/${api.accountId}/hyperdrive/configs`;
|
|
71
|
+
// For create operations, we don't have a hyperdriveId yet
|
|
72
|
+
// For update/delete operations, we need to use the hyperdriveId from props or output
|
|
73
|
+
const hyperdriveId = props.hyperdriveId || this.output?.hyperdriveId;
|
|
74
|
+
const configPath = hyperdriveId
|
|
75
|
+
? `${configsPath}/${hyperdriveId}`
|
|
76
|
+
: `${configsPath}`;
|
|
77
|
+
if (this.phase === "delete") {
|
|
78
|
+
if (!hyperdriveId) {
|
|
79
|
+
console.warn(`No hyperdriveId found for ${id}, skipping delete`);
|
|
80
|
+
return this.destroy();
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const deleteResponse = await api.delete(configPath);
|
|
84
|
+
// Only swallow 404 Not Found errors, all other errors should be handled
|
|
85
|
+
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
86
|
+
await handleApiError(deleteResponse, "delete", "hyperdrive", id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error(`Error deleting Hyperdrive ${id}:`, error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
return this.destroy();
|
|
94
|
+
}
|
|
95
|
+
let response;
|
|
96
|
+
let apiResource;
|
|
97
|
+
// Prepare request body with unwrapped secrets
|
|
98
|
+
const requestBody = prepareRequestBody(props);
|
|
99
|
+
try {
|
|
100
|
+
if (this.phase === "update" && hyperdriveId) {
|
|
101
|
+
// Update existing hyperdrive
|
|
102
|
+
response = await api.put(configPath, requestBody);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Create new hyperdrive
|
|
106
|
+
if (hyperdriveId) {
|
|
107
|
+
// If we have a hyperdriveId but we're in create phase, it could be because
|
|
108
|
+
// the resource exists but wasn't in state. Do a GET to check.
|
|
109
|
+
const getResponse = await api.get(configPath);
|
|
110
|
+
if (getResponse.status === 200) {
|
|
111
|
+
// Hyperdrive exists, update it
|
|
112
|
+
console.log(`Hyperdrive '${id}' already exists. Updating existing resource.`);
|
|
113
|
+
response = await api.put(configPath, requestBody);
|
|
114
|
+
}
|
|
115
|
+
else if (getResponse.status === 404) {
|
|
116
|
+
// Hyperdrive doesn't exist, create new
|
|
117
|
+
response = await api.post(configsPath, {
|
|
118
|
+
...requestBody,
|
|
119
|
+
// Ensure name is set correctly if not already set
|
|
120
|
+
name: props.name || id,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Unexpected error during GET check
|
|
125
|
+
await handleApiError(getResponse, "get", "hyperdrive", id);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// No hyperdriveId, create new
|
|
130
|
+
response = await api.post(configsPath, {
|
|
131
|
+
...requestBody,
|
|
132
|
+
// Ensure name is set correctly if not already set
|
|
133
|
+
name: props.name || id,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!response?.ok) {
|
|
138
|
+
const action = this.phase === "update" ? "update" : "create";
|
|
139
|
+
await handleApiError(response, action, "hyperdrive", id);
|
|
140
|
+
}
|
|
141
|
+
const data = await response.json();
|
|
142
|
+
apiResource = data.result;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error(`Error ${this.phase} Hyperdrive '${id}':`, error);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
// Construct the output object from API response and props
|
|
149
|
+
return this({
|
|
150
|
+
id,
|
|
151
|
+
hyperdriveId: apiResource.id, // Store the Cloudflare-assigned UUID
|
|
152
|
+
name: apiResource.name,
|
|
153
|
+
origin: props.origin, // Keep the original origin with secrets
|
|
154
|
+
caching: apiResource.caching,
|
|
155
|
+
mtls: apiResource.mtls,
|
|
156
|
+
type: "hyperdrive",
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* Prepare the request body by unwrapping secret values
|
|
161
|
+
*/
|
|
162
|
+
function prepareRequestBody(props) {
|
|
163
|
+
const requestBody = { ...props };
|
|
164
|
+
// Remove internal props
|
|
165
|
+
delete requestBody.hyperdriveId;
|
|
166
|
+
// Deep clone and unwrap secrets in the origin object
|
|
167
|
+
if ("password" in props.origin) {
|
|
168
|
+
// Regular origin with password
|
|
169
|
+
requestBody.origin = {
|
|
170
|
+
...props.origin,
|
|
171
|
+
password: props.origin.password.unencrypted,
|
|
172
|
+
scheme: props.origin.scheme ?? "postgres",
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
else if ("access_client_secret" in props.origin) {
|
|
176
|
+
// Origin with access client secret
|
|
177
|
+
requestBody.origin = {
|
|
178
|
+
...props.origin,
|
|
179
|
+
access_client_secret: props.origin.access_client_secret.unencrypted,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return requestBody;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=hyperdrive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperdrive.js","sourceRoot":"","sources":["../../src/cloudflare/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ACxB,OAAO,WAAW,CAAC,YAAY,CAAC;IAEhC,qDAAqD;IACrD,IAAI,UAAU,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC/B,+BAA+B;QAC/B,WAAW,CAAC,MAAM,GAAG;YACnB,GAAG,KAAK,CAAC,MAAM;YACf,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW;YAC3C,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,UAAU;SAC1C,CAAC;IACJ,CAAC;SAAM,IAAI,sBAAsB,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAClD,mCAAmC;QACnC,WAAW,CAAC,MAAM,GAAG;YACnB,GAAG,KAAK,CAAC,MAAM;YACf,oBAAoB,EAAE,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,WAAW;SACpE,CAAC;IACJ,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -9,11 +9,13 @@ export * from "./custom-domain.js";
|
|
|
9
9
|
export * from "./d1-database.js";
|
|
10
10
|
export * from "./dns-records.js";
|
|
11
11
|
export * from "./durable-object-namespace.js";
|
|
12
|
+
export * from "./hyperdrive.js";
|
|
12
13
|
export * from "./kv-namespace.js";
|
|
13
14
|
export * from "./local-dev-cloudflare-shim.js";
|
|
14
15
|
export * from "./nuxt.js";
|
|
15
16
|
export * from "./permission-groups.js";
|
|
16
17
|
export * from "./pipeline.js";
|
|
18
|
+
export * from "./queue-consumer.js";
|
|
17
19
|
export * from "./queue.js";
|
|
18
20
|
export * from "./r2-rest-state-store.js";
|
|
19
21
|
export * from "./redwood.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAA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AA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
package/lib/cloudflare/index.js
CHANGED
|
@@ -9,11 +9,13 @@ export * from "./custom-domain.js";
|
|
|
9
9
|
export * from "./d1-database.js";
|
|
10
10
|
export * from "./dns-records.js";
|
|
11
11
|
export * from "./durable-object-namespace.js";
|
|
12
|
+
export * from "./hyperdrive.js";
|
|
12
13
|
export * from "./kv-namespace.js";
|
|
13
14
|
export * from "./local-dev-cloudflare-shim.js";
|
|
14
15
|
export * from "./nuxt.js";
|
|
15
16
|
export * from "./permission-groups.js";
|
|
16
17
|
export * from "./pipeline.js";
|
|
18
|
+
export * from "./queue-consumer.js";
|
|
17
19
|
export * from "./queue.js";
|
|
18
20
|
export * from "./r2-rest-state-store.js";
|
|
19
21
|
export * from "./redwood.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,WAAW,CAAC;AAC1B,cAAc,wBA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nC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { Context } from "../context.js";
|
|
2
|
+
import { Resource } from "../resource.js";
|
|
3
|
+
import { CloudflareApi, type CloudflareApiOptions } from "./api.js";
|
|
4
|
+
import type { Queue } from "./queue.js";
|
|
5
|
+
/**
|
|
6
|
+
* Settings for configuring a Queue Consumer
|
|
7
|
+
*/
|
|
8
|
+
export interface QueueConsumerSettings {
|
|
9
|
+
/**
|
|
10
|
+
* Number of messages to deliver in a batch
|
|
11
|
+
* @default 10
|
|
12
|
+
*/
|
|
13
|
+
batchSize?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of concurrent consumer worker invocations
|
|
16
|
+
* @default 2
|
|
17
|
+
*/
|
|
18
|
+
maxConcurrency?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of retries for each message
|
|
21
|
+
* @default 3
|
|
22
|
+
*/
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum time in milliseconds to wait for batch to fill
|
|
26
|
+
* @default 500
|
|
27
|
+
*/
|
|
28
|
+
maxWaitTimeMs?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Time in seconds to delay retry after a failure
|
|
31
|
+
* @default 30
|
|
32
|
+
*/
|
|
33
|
+
retryDelay?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Properties for creating or updating a Queue Consumer
|
|
37
|
+
*/
|
|
38
|
+
export interface QueueConsumerProps extends CloudflareApiOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The queue to consume
|
|
41
|
+
* Either queue or queueId must be provided
|
|
42
|
+
*/
|
|
43
|
+
queue?: Queue;
|
|
44
|
+
/**
|
|
45
|
+
* The queue ID to consume (alternative to providing a queue)
|
|
46
|
+
* Either queue or queueId must be provided
|
|
47
|
+
*/
|
|
48
|
+
queueId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Name of the worker script that will consume the queue
|
|
51
|
+
*/
|
|
52
|
+
scriptName: string;
|
|
53
|
+
/**
|
|
54
|
+
* Settings for the consumer
|
|
55
|
+
*/
|
|
56
|
+
settings?: QueueConsumerSettings;
|
|
57
|
+
/**
|
|
58
|
+
* Whether to delete the consumer.
|
|
59
|
+
* If set to false, the consumer will remain but the resource will be removed from state
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
delete?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Output returned after Queue Consumer creation/update
|
|
66
|
+
*/
|
|
67
|
+
export interface QueueConsumer extends Resource<"cloudflare::QueueConsumer">, QueueConsumerProps {
|
|
68
|
+
/**
|
|
69
|
+
* Unique ID for the consumer
|
|
70
|
+
*/
|
|
71
|
+
id: string;
|
|
72
|
+
/**
|
|
73
|
+
* Type identifier for Cloudflare Queue Consumer
|
|
74
|
+
*/
|
|
75
|
+
type: "worker";
|
|
76
|
+
/**
|
|
77
|
+
* ID of the queue being consumed
|
|
78
|
+
*/
|
|
79
|
+
queueId: string;
|
|
80
|
+
/**
|
|
81
|
+
* Time when the consumer was created
|
|
82
|
+
*/
|
|
83
|
+
createdOn?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates a consumer for a Cloudflare Queue that processes messages using a Worker.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Create a queue consumer with default settings
|
|
90
|
+
* const queue = await Queue("notifications", {
|
|
91
|
+
* name: "notifications"
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* const consumer = await QueueConsumer("notification-processor", {
|
|
95
|
+
* queue,
|
|
96
|
+
* scriptName: "notification-worker"
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Create a consumer with custom settings
|
|
101
|
+
* const batchConsumer = await QueueConsumer("batch-processor", {
|
|
102
|
+
* queue,
|
|
103
|
+
* scriptName: "batch-worker",
|
|
104
|
+
* settings: {
|
|
105
|
+
* batchSize: 50, // Process 50 messages at once
|
|
106
|
+
* maxConcurrency: 10, // Allow 10 concurrent invocations
|
|
107
|
+
* maxRetries: 5, // Retry failed messages up to 5 times
|
|
108
|
+
* maxWaitTimeMs: 2000, // Wait up to 2 seconds to fill a batch
|
|
109
|
+
* retryDelay: 60 // Wait 60 seconds before retrying failed messages
|
|
110
|
+
* }
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* @see https://developers.cloudflare.com/queues/platform/consumers/
|
|
114
|
+
*/
|
|
115
|
+
export declare const QueueConsumer: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<QueueConsumer>, id: string, props: QueueConsumerProps) => Promise<QueueConsumer>);
|
|
116
|
+
/**
|
|
117
|
+
* Response from Cloudflare API for Queue Consumer operations
|
|
118
|
+
*/
|
|
119
|
+
interface CloudflareQueueConsumerResponse {
|
|
120
|
+
result: {
|
|
121
|
+
consumer_id: string;
|
|
122
|
+
script_name: string;
|
|
123
|
+
settings?: {
|
|
124
|
+
batch_size?: number;
|
|
125
|
+
max_concurrency?: number;
|
|
126
|
+
max_retries?: number;
|
|
127
|
+
max_wait_time_ms?: number;
|
|
128
|
+
retry_delay?: number;
|
|
129
|
+
};
|
|
130
|
+
type: "worker";
|
|
131
|
+
queue_id?: string;
|
|
132
|
+
created_on?: string;
|
|
133
|
+
};
|
|
134
|
+
success: boolean;
|
|
135
|
+
errors: Array<{
|
|
136
|
+
code: number;
|
|
137
|
+
message: string;
|
|
138
|
+
}>;
|
|
139
|
+
messages: string[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new Queue Consumer
|
|
143
|
+
*/
|
|
144
|
+
export declare function createQueueConsumer(api: CloudflareApi, queueId: string, props: QueueConsumerProps): Promise<CloudflareQueueConsumerResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Delete a Queue Consumer
|
|
147
|
+
*/
|
|
148
|
+
export declare function deleteQueueConsumer(api: CloudflareApi, queueId: string, consumerId: string): Promise<void>;
|
|
149
|
+
export interface ListQueueConsumersResponse {
|
|
150
|
+
id: string;
|
|
151
|
+
scriptName: string;
|
|
152
|
+
queueId: string;
|
|
153
|
+
queueName: string;
|
|
154
|
+
createdOn: string;
|
|
155
|
+
settings?: QueueConsumerSettings;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* List all consumers for a queue
|
|
159
|
+
*/
|
|
160
|
+
export declare function listQueueConsumers(api: CloudflareApi, queueId: string): Promise<ListQueueConsumersResponse[]>;
|
|
161
|
+
export {};
|
|
162
|
+
//# sourceMappingURL=queue-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-consumer.d.ts","sourceRoot":"","sources":["../../src/cloudflare/queue-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,aAAa,EAEb,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;I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,MAAM,EACf,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,+BAA+B,CAAC,CA+C1C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAcf;AA4DD,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AACD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAqDvC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { CloudflareApiError, handleApiError } from "./api-error.js";
|
|
3
|
+
import { CloudflareApi, createCloudflareApi, } from "./api.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a consumer for a Cloudflare Queue that processes messages using a Worker.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Create a queue consumer with default settings
|
|
9
|
+
* const queue = await Queue("notifications", {
|
|
10
|
+
* name: "notifications"
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* const consumer = await QueueConsumer("notification-processor", {
|
|
14
|
+
* queue,
|
|
15
|
+
* scriptName: "notification-worker"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a consumer with custom settings
|
|
20
|
+
* const batchConsumer = await QueueConsumer("batch-processor", {
|
|
21
|
+
* queue,
|
|
22
|
+
* scriptName: "batch-worker",
|
|
23
|
+
* settings: {
|
|
24
|
+
* batchSize: 50, // Process 50 messages at once
|
|
25
|
+
* maxConcurrency: 10, // Allow 10 concurrent invocations
|
|
26
|
+
* maxRetries: 5, // Retry failed messages up to 5 times
|
|
27
|
+
* maxWaitTimeMs: 2000, // Wait up to 2 seconds to fill a batch
|
|
28
|
+
* retryDelay: 60 // Wait 60 seconds before retrying failed messages
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* @see https://developers.cloudflare.com/queues/platform/consumers/
|
|
33
|
+
*/
|
|
34
|
+
export const QueueConsumer = Resource("cloudflare::QueueConsumer", async function (id, props) {
|
|
35
|
+
const api = await createCloudflareApi(props);
|
|
36
|
+
// Get queueId from either props.queue or props.queueId
|
|
37
|
+
const queueId = props.queue?.id || props.queueId;
|
|
38
|
+
if (!queueId) {
|
|
39
|
+
throw new Error("Either queue or queueId must be provided");
|
|
40
|
+
}
|
|
41
|
+
if (this.phase === "delete") {
|
|
42
|
+
console.log(`Deleting Queue Consumer for queue ${queueId}`);
|
|
43
|
+
if (props.delete !== false && this.output?.id) {
|
|
44
|
+
// Delete the consumer
|
|
45
|
+
await deleteQueueConsumer(api, queueId, this.output.id);
|
|
46
|
+
}
|
|
47
|
+
// Return void (a deleted consumer has no content)
|
|
48
|
+
return this.destroy();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
let consumerData;
|
|
52
|
+
if (this.phase === "create") {
|
|
53
|
+
console.log(`Creating Queue Consumer for queue ${queueId}`);
|
|
54
|
+
consumerData = await createQueueConsumer(api, queueId, props);
|
|
55
|
+
}
|
|
56
|
+
else if (this.output?.id) {
|
|
57
|
+
console.log(`Updating Queue Consumer ${this.output.id}`);
|
|
58
|
+
consumerData = await updateQueueConsumer(api, queueId, this.output.id, props);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// If no ID exists, fall back to creating a new consumer
|
|
62
|
+
console.log(`No existing Consumer ID found, creating new Queue Consumer for queue ${queueId}`);
|
|
63
|
+
consumerData = await createQueueConsumer(api, queueId, props);
|
|
64
|
+
}
|
|
65
|
+
return this({
|
|
66
|
+
id: consumerData.result.consumer_id,
|
|
67
|
+
queueId,
|
|
68
|
+
queue: props.queue,
|
|
69
|
+
type: "worker",
|
|
70
|
+
scriptName: props.scriptName,
|
|
71
|
+
settings: consumerData.result.settings
|
|
72
|
+
? {
|
|
73
|
+
batchSize: consumerData.result.settings.batch_size,
|
|
74
|
+
maxConcurrency: consumerData.result.settings.max_concurrency,
|
|
75
|
+
maxRetries: consumerData.result.settings.max_retries,
|
|
76
|
+
maxWaitTimeMs: consumerData.result.settings.max_wait_time_ms,
|
|
77
|
+
retryDelay: consumerData.result.settings.retry_delay,
|
|
78
|
+
}
|
|
79
|
+
: undefined,
|
|
80
|
+
createdOn: consumerData.result.created_on,
|
|
81
|
+
accountId: api.accountId,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Create a new Queue Consumer
|
|
87
|
+
*/
|
|
88
|
+
export async function createQueueConsumer(api, queueId, props) {
|
|
89
|
+
// Prepare the create payload
|
|
90
|
+
const createPayload = {
|
|
91
|
+
script_name: props.scriptName,
|
|
92
|
+
type: "worker",
|
|
93
|
+
};
|
|
94
|
+
// Add settings if provided
|
|
95
|
+
if (props.settings) {
|
|
96
|
+
createPayload.settings = {};
|
|
97
|
+
if (props.settings.batchSize !== undefined) {
|
|
98
|
+
createPayload.settings.batch_size = props.settings.batchSize;
|
|
99
|
+
}
|
|
100
|
+
if (props.settings.maxConcurrency !== undefined) {
|
|
101
|
+
createPayload.settings.max_concurrency = props.settings.maxConcurrency;
|
|
102
|
+
}
|
|
103
|
+
if (props.settings.maxRetries !== undefined) {
|
|
104
|
+
createPayload.settings.max_retries = props.settings.maxRetries;
|
|
105
|
+
}
|
|
106
|
+
if (props.settings.maxWaitTimeMs !== undefined) {
|
|
107
|
+
createPayload.settings.max_wait_time_ms = props.settings.maxWaitTimeMs;
|
|
108
|
+
}
|
|
109
|
+
if (props.settings.retryDelay !== undefined) {
|
|
110
|
+
createPayload.settings.retry_delay = props.settings.retryDelay;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const createResponse = await api.post(`/accounts/${api.accountId}/queues/${queueId}/consumers`, createPayload);
|
|
114
|
+
if (!createResponse.ok) {
|
|
115
|
+
return await handleApiError(createResponse, "creating", "Queue Consumer", `for queue ${queueId}`);
|
|
116
|
+
}
|
|
117
|
+
return (await createResponse.json());
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Delete a Queue Consumer
|
|
121
|
+
*/
|
|
122
|
+
export async function deleteQueueConsumer(api, queueId, consumerId) {
|
|
123
|
+
const deleteResponse = await api.delete(`/accounts/${api.accountId}/queues/${queueId}/consumers/${consumerId}`);
|
|
124
|
+
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
125
|
+
const errorData = await deleteResponse.json().catch(() => ({
|
|
126
|
+
errors: [{ message: deleteResponse.statusText }],
|
|
127
|
+
}));
|
|
128
|
+
throw new CloudflareApiError(`Error deleting Queue Consumer '${consumerId}': ${errorData.errors?.[0]?.message || deleteResponse.statusText}`, deleteResponse);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Update a Queue Consumer
|
|
133
|
+
*/
|
|
134
|
+
async function updateQueueConsumer(api, queueId, consumerId, props) {
|
|
135
|
+
// Prepare the update payload
|
|
136
|
+
const updatePayload = {
|
|
137
|
+
script_name: props.scriptName,
|
|
138
|
+
type: "worker",
|
|
139
|
+
};
|
|
140
|
+
// Add settings if provided
|
|
141
|
+
if (props.settings) {
|
|
142
|
+
updatePayload.settings = {};
|
|
143
|
+
if (props.settings.batchSize !== undefined) {
|
|
144
|
+
updatePayload.settings.batch_size = props.settings.batchSize;
|
|
145
|
+
}
|
|
146
|
+
if (props.settings.maxConcurrency !== undefined) {
|
|
147
|
+
updatePayload.settings.max_concurrency = props.settings.maxConcurrency;
|
|
148
|
+
}
|
|
149
|
+
if (props.settings.maxRetries !== undefined) {
|
|
150
|
+
updatePayload.settings.max_retries = props.settings.maxRetries;
|
|
151
|
+
}
|
|
152
|
+
if (props.settings.maxWaitTimeMs !== undefined) {
|
|
153
|
+
updatePayload.settings.max_wait_time_ms = props.settings.maxWaitTimeMs;
|
|
154
|
+
}
|
|
155
|
+
if (props.settings.retryDelay !== undefined) {
|
|
156
|
+
updatePayload.settings.retry_delay = props.settings.retryDelay;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Use PUT to update the consumer
|
|
160
|
+
const updateResponse = await api.put(`/accounts/${api.accountId}/queues/${queueId}/consumers/${consumerId}`, updatePayload);
|
|
161
|
+
if (!updateResponse.ok) {
|
|
162
|
+
return await handleApiError(updateResponse, "updating", "Queue Consumer", consumerId);
|
|
163
|
+
}
|
|
164
|
+
return (await updateResponse.json());
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* List all consumers for a queue
|
|
168
|
+
*/
|
|
169
|
+
export async function listQueueConsumers(api, queueId) {
|
|
170
|
+
const response = await api.get(`/accounts/${api.accountId}/queues/${queueId}/consumers`);
|
|
171
|
+
if (!response.ok) {
|
|
172
|
+
throw new CloudflareApiError(`Failed to list queue consumers: ${response.statusText}`, response);
|
|
173
|
+
}
|
|
174
|
+
const data = (await response.json());
|
|
175
|
+
if (!data.success) {
|
|
176
|
+
const errorMessage = data.errors?.[0]?.message || "Unknown error";
|
|
177
|
+
throw new Error(`Failed to list queue consumers: ${errorMessage}`);
|
|
178
|
+
}
|
|
179
|
+
// Transform API response
|
|
180
|
+
return (data.result || []).map((consumer) => ({
|
|
181
|
+
id: consumer.consumer_id,
|
|
182
|
+
scriptName: consumer.script,
|
|
183
|
+
queueId: consumer.queue_id,
|
|
184
|
+
queueName: consumer.queue_name,
|
|
185
|
+
createdOn: consumer.created_on,
|
|
186
|
+
settings: consumer.settings
|
|
187
|
+
? {
|
|
188
|
+
batchSize: consumer.settings.batch_size,
|
|
189
|
+
maxConcurrency: consumer.settings.max_concurrency,
|
|
190
|
+
maxRetries: consumer.settings.max_retries,
|
|
191
|
+
maxWaitTimeMs: consumer.settings.max_wait_time_ms,
|
|
192
|
+
retryDelay: consumer.settings.retry_delay,
|
|
193
|
+
}
|
|
194
|
+
: undefined,
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=queue-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-consumer.js","sourceRoot":"","sources":["../../src/cloudflare/queue-consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EACL,aAAa,EACb,mBAAmB,GAEpB,MAAM,UAAU,CAAC;AAmGlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CACnC,2BAA2B,EAC3B,KAAK,WAEH,EAAU,EACV,KAAyB;IAEzB,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAE7C,uDAAuD;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC;IAEjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,qCAAqC,OAAO,EAAE,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;YAC9C,sBAAsB;YACtB,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,C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Q,CAAC,QAAQ,CAAC,UAAU;gBACvC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe;gBACjD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW;gBACzC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,gBAAgB;gBACjD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW;aAC1C;YACH,CAAC,CAAC,SAAS;KACd,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -29,8 +29,10 @@ export interface QueueProps extends CloudflareApiOptions {
|
|
|
29
29
|
* Name of the queue
|
|
30
30
|
* Required during creation
|
|
31
31
|
* Cannot be changed after creation
|
|
32
|
+
*
|
|
33
|
+
* @default id
|
|
32
34
|
*/
|
|
33
|
-
name
|
|
35
|
+
name?: string;
|
|
34
36
|
/**
|
|
35
37
|
* Settings for the queue
|
|
36
38
|
* These can be updated after queue creation
|
|
@@ -44,10 +46,11 @@ export interface QueueProps extends CloudflareApiOptions {
|
|
|
44
46
|
*/
|
|
45
47
|
delete?: boolean;
|
|
46
48
|
}
|
|
49
|
+
export declare function isQueue(eventSource: any): eventSource is Queue;
|
|
47
50
|
/**
|
|
48
51
|
* Output returned after Cloudflare Queue creation/update
|
|
49
52
|
*/
|
|
50
|
-
export interface Queue extends Resource<"cloudflare::Queue">, QueueProps {
|
|
53
|
+
export interface Queue<Body = unknown> extends Resource<"cloudflare::Queue">, QueueProps {
|
|
51
54
|
/**
|
|
52
55
|
* Type identifier for Cloudflare Queue
|
|
53
56
|
*/
|
|
@@ -56,6 +59,10 @@ export interface Queue extends Resource<"cloudflare::Queue">, QueueProps {
|
|
|
56
59
|
* The unique ID of the queue
|
|
57
60
|
*/
|
|
58
61
|
id: string;
|
|
62
|
+
/**
|
|
63
|
+
* The name of the queue
|
|
64
|
+
*/
|
|
65
|
+
name: string;
|
|
59
66
|
/**
|
|
60
67
|
* Time when the queue was created
|
|
61
68
|
*/
|
|
@@ -64,6 +71,11 @@ export interface Queue extends Resource<"cloudflare::Queue">, QueueProps {
|
|
|
64
71
|
* Modified timestamp
|
|
65
72
|
*/
|
|
66
73
|
modifiedOn: string;
|
|
74
|
+
/**
|
|
75
|
+
* Phantom property to allow type inference
|
|
76
|
+
*/
|
|
77
|
+
Body: Body;
|
|
78
|
+
Batch: MessageBatch<Body>;
|
|
67
79
|
}
|
|
68
80
|
interface CloudflareQueueResponse {
|
|
69
81
|
result: {
|
|
@@ -117,7 +129,7 @@ interface CloudflareQueueResponse {
|
|
|
117
129
|
*
|
|
118
130
|
* @see https://developers.cloudflare.com/queues/
|
|
119
131
|
*/
|
|
120
|
-
export declare const Queue: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Queue
|
|
132
|
+
export declare const Queue: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | (<T = unknown>(this: Context<Queue<T>>, id: string, props?: QueueProps) => Promise<Queue<T>>);
|
|
121
133
|
/**
|
|
122
134
|
* Create a new Cloudflare Queue
|
|
123
135
|
*/
|