@develit-io/backend-sdk 5.29.1 → 5.30.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const worker = require('../shared/backend-sdk.n8SfX_xu.cjs');
3
+ const worker = require('../shared/backend-sdk.DEE4fXCZ.cjs');
4
4
  const text = require('@std/text');
5
5
  const cloudflare = require('alchemy/cloudflare');
6
6
  const environment_consts = require('../shared/backend-sdk.ClVQ4AzB.cjs');
@@ -22,6 +22,20 @@ const composeD1Arguments = ({
22
22
  };
23
23
  };
24
24
 
25
+ const composeDlqArguments = ({
26
+ resourceName,
27
+ deliveryDelay = worker.QUEUE_DELIVERY_DELAY,
28
+ messageRetentionPeriod = worker.QUEUE_MESSAGE_RETENTION_PERIOD
29
+ }) => {
30
+ return {
31
+ name: resourceName,
32
+ settings: {
33
+ deliveryDelay,
34
+ messageRetentionPeriod
35
+ }
36
+ };
37
+ };
38
+
25
39
  const composeKvArguments = ({
26
40
  resourceName
27
41
  }) => {
@@ -32,17 +46,17 @@ const composeKvArguments = ({
32
46
 
33
47
  const composeQueueArguments = ({
34
48
  resourceName,
49
+ dlq,
35
50
  deliveryDelay = worker.QUEUE_DELIVERY_DELAY,
36
- messageRetentionPeriod = worker.QUEUE_MESSAGE_RETENTION_PERIOD,
37
- dlq
51
+ messageRetentionPeriod = worker.QUEUE_MESSAGE_RETENTION_PERIOD
38
52
  }) => {
39
53
  return {
40
54
  name: resourceName,
55
+ dlq,
41
56
  settings: {
42
57
  deliveryDelay,
43
58
  messageRetentionPeriod
44
- },
45
- dlq
59
+ }
46
60
  };
47
61
  };
48
62
 
@@ -52,9 +66,9 @@ const composeR2Arguments = ({
52
66
  }) => {
53
67
  return {
54
68
  name: resourceName,
69
+ storageClass,
55
70
  jurisdiction: worker.R2_JURISDICTION,
56
- locationHint: worker.R2_LOCATION_HINT,
57
- storageClass
71
+ locationHint: worker.R2_LOCATION_HINT
58
72
  };
59
73
  };
60
74
 
@@ -72,23 +86,10 @@ const composeResourceName = ({
72
86
  return `${project}-${text.toKebabCase(resourceName).toLowerCase()}-${environment}`;
73
87
  };
74
88
 
75
- const composeDlqArguments = ({
76
- resourceName,
77
- deliveryDelay = worker.QUEUE_DELIVERY_DELAY,
78
- messageRetentionPeriod = worker.QUEUE_MESSAGE_RETENTION_PERIOD
79
- }) => {
80
- return {
81
- name: resourceName,
82
- settings: {
83
- deliveryDelay,
84
- messageRetentionPeriod
85
- }
86
- };
87
- };
88
-
89
89
  class Deployment {
90
90
  project;
91
91
  environment;
92
+ // TODO: Check if the type is most correct
92
93
  alchemy;
93
94
  constructor({ project }) {
94
95
  this.project = project;
@@ -99,6 +100,7 @@ class Deployment {
99
100
  scriptName: environment_consts.ALCHEMY_STATE_STORE
100
101
  });
101
102
  },
103
+ // TODO: Convert to a util
102
104
  stage: Bun.env.ENVIRONMENT || "unknown"
103
105
  });
104
106
  }
@@ -141,11 +143,11 @@ class Deployment {
141
143
  );
142
144
  }
143
145
  /**
144
- * Creates an instance of Cloudflare Queue.
146
+ * Creates an instance of Cloudflare Queue. A DLQ is created automatically.
145
147
  */
146
148
  async queue(options) {
147
149
  const { resourceName, deliveryDelay, messageRetentionPeriod } = options;
148
- const dlq = await this.dlq({
150
+ const deadLetterQueue = await this.dlq({
149
151
  resourceName
150
152
  });
151
153
  return await cloudflare.Queue(
@@ -156,9 +158,9 @@ class Deployment {
156
158
  environment: this.environment,
157
159
  resourceName
158
160
  }),
161
+ dlq: deadLetterQueue,
159
162
  deliveryDelay,
160
- messageRetentionPeriod,
161
- dlq
163
+ messageRetentionPeriod
162
164
  })
163
165
  );
164
166
  }
@@ -208,6 +210,7 @@ class Deployment {
208
210
  resourceName: className,
209
211
  resource: "durable-object"
210
212
  }),
213
+ // TODO: Create util
211
214
  {
212
215
  // TODO: Create util
213
216
  className: `${className}DurableObject`,
@@ -227,12 +230,11 @@ class Deployment {
227
230
  assets,
228
231
  crons,
229
232
  bindings,
230
- variables,
231
- secrets,
232
233
  eventSources
233
234
  } = options;
234
235
  const identifierName = composeIdentifierName({
235
236
  resourceName,
237
+ // TODO: Convert to a util
236
238
  resource: resource || "worker"
237
239
  });
238
240
  const workerConfig = await worker.loadWorkerConfig({ path });
@@ -243,10 +245,12 @@ class Deployment {
243
245
  deadLetterQueue: queue.dlq,
244
246
  batchSize: worker.QUEUE_MAX_BATCH_SIZE,
245
247
  maxWaitTimeMs: worker.QUEUE_MAX_BATCH_TIMEOUT
248
+ // TODO: Watch out for the type
246
249
  }
247
250
  };
248
251
  });
249
252
  return await cloudflare.Worker(
253
+ // TODO: Make it to use composeIdentifierName similary to other resources
250
254
  identifierName,
251
255
  worker.composeWorkerArguments({
252
256
  resourceName: composeResourceName({
@@ -258,14 +262,17 @@ class Deployment {
258
262
  entrypoint: `${path}/src/index.ts`,
259
263
  domains,
260
264
  assets,
265
+ // TODO: Convert to a util
261
266
  crons: crons || worker.extractWorkerCrons({
262
267
  workerConfig,
263
268
  environment: this.environment
264
269
  }),
265
270
  bindings: {
266
271
  ...bindings,
267
- ...variables,
268
- ...secrets
272
+ ...worker.extractWorkerVars({
273
+ workerConfig,
274
+ environment: this.environment
275
+ })
269
276
  },
270
277
  eventSources: consumers
271
278
  })
@@ -275,15 +282,13 @@ class Deployment {
275
282
  * Creates an instance of Cloudflare Worker as a service.
276
283
  */
277
284
  async service(options) {
278
- const { resourceName, bindings, variables, secrets, eventSources } = options;
285
+ const { resourceName, bindings, eventSources } = options;
279
286
  return await this.worker({
280
287
  resourceName,
281
288
  resource: "service",
282
289
  // TODO: Convert to util
283
290
  path: `./services/${resourceName}`,
284
291
  bindings,
285
- variables,
286
- secrets,
287
292
  eventSources
288
293
  });
289
294
  }
@@ -291,14 +296,7 @@ class Deployment {
291
296
  * Creates an instance of Cloudflare Worker as an orchestrator.
292
297
  */
293
298
  async orchestrator(options) {
294
- const {
295
- resourceName,
296
- domains,
297
- bindings,
298
- variables,
299
- secrets,
300
- eventSources
301
- } = options;
299
+ const { resourceName, domains, bindings, eventSources } = options;
302
300
  return await this.worker({
303
301
  resourceName,
304
302
  resource: "orchestrator",
@@ -306,8 +304,6 @@ class Deployment {
306
304
  path: `./apps/${resourceName}`,
307
305
  domains,
308
306
  bindings,
309
- variables,
310
- secrets,
311
307
  eventSources
312
308
  });
313
309
  }
@@ -315,7 +311,7 @@ class Deployment {
315
311
  * Creates an instance of Cloudflare Worker as a client.
316
312
  */
317
313
  async client(options) {
318
- const { resourceName, domains, bindings, variables, secrets } = options;
314
+ const { resourceName, domains, bindings, variables } = options;
319
315
  return await cloudflare.Nuxt(
320
316
  composeIdentifierName({
321
317
  resourceName,
@@ -336,8 +332,7 @@ class Deployment {
336
332
  domains,
337
333
  bindings: {
338
334
  ...bindings,
339
- ...variables,
340
- ...secrets
335
+ ...variables
341
336
  },
342
337
  // TODO: Convert to util
343
338
  cwd: `./apps/${resourceName}`
@@ -348,9 +343,11 @@ class Deployment {
348
343
 
349
344
  exports.composeWorkerArguments = worker.composeWorkerArguments;
350
345
  exports.extractWorkerCrons = worker.extractWorkerCrons;
346
+ exports.extractWorkerVars = worker.extractWorkerVars;
351
347
  exports.loadWorkerConfig = worker.loadWorkerConfig;
352
348
  exports.Deployment = Deployment;
353
349
  exports.composeD1Arguments = composeD1Arguments;
350
+ exports.composeDlqArguments = composeDlqArguments;
354
351
  exports.composeIdentifierName = composeIdentifierName;
355
352
  exports.composeKvArguments = composeKvArguments;
356
353
  exports.composeQueueArguments = composeQueueArguments;
@@ -2,8 +2,8 @@ import * as alchemy_cloudflare from 'alchemy/cloudflare';
2
2
  import { KVNamespace, D1Database, Queue, R2Bucket, DurableObjectNamespace, Bindings, Worker } from 'alchemy/cloudflare';
3
3
  import { P as Project } from '../shared/backend-sdk.CP78x0gl.cjs';
4
4
  import { E as Environment } from '../shared/backend-sdk.CYcpgphg.cjs';
5
- import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.D8N5si7y.cjs';
6
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.D8N5si7y.cjs';
5
+ import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.CdngrAa0.cjs';
6
+ export { c as composeWorkerArguments, e as extractWorkerCrons, a as extractWorkerVars, l as loadWorkerConfig } from '../shared/backend-sdk.CdngrAa0.cjs';
7
7
  import alchemy from 'alchemy';
8
8
 
9
9
  declare class Deployment {
@@ -22,7 +22,7 @@ declare class Deployment {
22
22
  */
23
23
  kv(options: {
24
24
  /**
25
- * Name of the KV. Do not include the 'kv' prefix.
25
+ * Name of the instance. Do not include a 'kv' prefix.
26
26
  */
27
27
  resourceName: string;
28
28
  }): Promise<KVNamespace>;
@@ -31,24 +31,24 @@ declare class Deployment {
31
31
  */
32
32
  d1(options: {
33
33
  /**
34
- * Name of the D1. Do not include the 'd1' prefix.
34
+ * Name of the instance. Do not include a 'd1' prefix.
35
35
  */
36
36
  resourceName: string;
37
37
  }): Promise<D1Database>;
38
38
  /**
39
- * Creates an instance of Cloudflare Queue.
39
+ * Creates an instance of Cloudflare Queue. A DLQ is created automatically.
40
40
  */
41
41
  queue(options: {
42
42
  /**
43
- * Name of the Queue. Do not include the 'queue' prefix.
43
+ * Name of the instance. Do not include a 'queue' prefix.
44
44
  */
45
45
  resourceName: string;
46
46
  /**
47
- * The number of seconds to delay delivery of messages to the queue.
47
+ * The number of seconds to delay delivery of messages to the instance.
48
48
  */
49
49
  deliveryDelay?: number;
50
50
  /**
51
- * The number of seconds a message will remain in the queue before being deleted.
51
+ * The number of seconds a message will remain in the instance before being deleted.
52
52
  */
53
53
  messageRetentionPeriod?: number;
54
54
  }): Promise<Queue<unknown>>;
@@ -57,15 +57,15 @@ declare class Deployment {
57
57
  */
58
58
  dlq(options: {
59
59
  /**
60
- * Name of the DLQ. Do not include the 'dlq' or 'queue' prefix.
60
+ * Name of the instance. Do not include a 'dlq' or 'queue' prefix.
61
61
  */
62
62
  resourceName: string;
63
63
  /**
64
- * The number of seconds to delay delivery of messages to the queue.
64
+ * The number of seconds to delay delivery of messages to the instance.
65
65
  */
66
66
  deliveryDelay?: number;
67
67
  /**
68
- * The number of seconds a message will remain in the queue before being deleted.
68
+ * The number of seconds a message will remain in the instance before being deleted.
69
69
  */
70
70
  messageRetentionPeriod?: number;
71
71
  }): Promise<Queue<unknown>>;
@@ -74,11 +74,11 @@ declare class Deployment {
74
74
  */
75
75
  r2(options: {
76
76
  /**
77
- * Name of the R2. Do not include the 'r2' prefix.
77
+ * Name of the instance. Do not include an 'r2' prefix.
78
78
  */
79
79
  resourceName: string;
80
80
  /**
81
- * The storage class for the R2 bucket.
81
+ * The storage class that the instance should take on.
82
82
  */
83
83
  storageClass?: 'Standard' | 'InfrequentAccess';
84
84
  }): Promise<R2Bucket>;
@@ -87,7 +87,7 @@ declare class Deployment {
87
87
  */
88
88
  durableObject(options: {
89
89
  /**
90
- * Name of the Durable Object class. Do not include the 'durable-object' or 'do' prefix.
90
+ * Name of the instance class. Do not include a 'durable-object' or 'do' prefix.
91
91
  */
92
92
  className: string;
93
93
  }): Promise<DurableObjectNamespace<any>>;
@@ -96,43 +96,35 @@ declare class Deployment {
96
96
  */
97
97
  worker(options: {
98
98
  /**
99
- * Name of the Worker. Do not include the 'worker' prefix.
99
+ * Name of the instance. Do not include the 'worker' prefix.
100
100
  */
101
101
  resourceName: string;
102
102
  /**
103
- * Type of the Worker.
103
+ * Type of the instance.
104
104
  */
105
105
  resource?: WorkerType$1;
106
106
  /**
107
- * Path to the root of the Worker.
107
+ * Path to the root of the instance.
108
108
  */
109
109
  path: string;
110
110
  /**
111
- * Custom domains to bind to the Worker.
111
+ * Custom domains to bind to the instance.
112
112
  */
113
113
  domains?: string[];
114
114
  /**
115
- * Static assets of the Worker.
115
+ * Static assets for the instance.
116
116
  */
117
117
  assets?: Bindings;
118
118
  /**
119
- * Cron expressions for the trigger of the Worker.
119
+ * Cron expressions for the triggers of the instange.
120
120
  */
121
121
  crons?: string[];
122
122
  /**
123
- * Bindings of the Worker.
123
+ * Bindings of the instance.
124
124
  */
125
125
  bindings?: Bindings;
126
126
  /**
127
- * Environment variables of the Worker.
128
- */
129
- variables?: Bindings;
130
- /**
131
- * Secrets of the Worker.
132
- */
133
- secrets?: Bindings;
134
- /**
135
- * Event sources for the service to consume.
127
+ * Event sources for the instance to consume.
136
128
  */
137
129
  eventSources?: Queue[];
138
130
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
@@ -141,23 +133,15 @@ declare class Deployment {
141
133
  */
142
134
  service(options: {
143
135
  /**
144
- * Name of the service. Do not include the 'service' prefix.
136
+ * Name of the instance. Do not include a 'service' prefix.
145
137
  */
146
138
  resourceName: string;
147
139
  /**
148
- * Bindings of the Worker.
140
+ * Bindings of the instance.
149
141
  */
150
142
  bindings?: Bindings;
151
143
  /**
152
- * Environment variables of the Worker.
153
- */
154
- variables?: Bindings;
155
- /**
156
- * Secrets of the Worker.
157
- */
158
- secrets?: Bindings;
159
- /**
160
- * Event sources for the service to consume.
144
+ * Event sources for the instance to consume.
161
145
  */
162
146
  eventSources?: Queue[];
163
147
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
@@ -166,27 +150,19 @@ declare class Deployment {
166
150
  */
167
151
  orchestrator(options: {
168
152
  /**
169
- * Name of the orchestrator. Do not include the 'orchestrator' prefix.
153
+ * Name of the instance. Do not include an 'orchestrator' prefix.
170
154
  */
171
155
  resourceName: string;
172
156
  /**
173
- * Custom domains to bind to the Worker.
157
+ * Custom domains to bind to the instance.
174
158
  */
175
159
  domains?: string[];
176
160
  /**
177
- * Bindings of the Worker.
161
+ * Bindings of the instance.
178
162
  */
179
163
  bindings?: Bindings;
180
164
  /**
181
- * Environment variables of the Worker.
182
- */
183
- variables?: Bindings;
184
- /**
185
- * Secrets of the Worker.
186
- */
187
- secrets?: Bindings;
188
- /**
189
- * Event sources for the orchestrator to consume.
165
+ * Event sources for the instance to consume.
190
166
  */
191
167
  eventSources?: Queue[];
192
168
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
@@ -195,25 +171,21 @@ declare class Deployment {
195
171
  */
196
172
  client(options: {
197
173
  /**
198
- * Name of the client. Do not include the 'client' prefix.
174
+ * Name of the instance. Do not include a 'client' prefix.
199
175
  */
200
176
  resourceName: string;
201
177
  /**
202
- * Custom domains to bind to the Worker.
178
+ * Custom domains to bind to the instance.
203
179
  */
204
180
  domains?: string[];
205
181
  /**
206
- * Bindings of the Worker.
182
+ * Bindings of the instance.
207
183
  */
208
184
  bindings?: Bindings;
209
185
  /**
210
- * Environment variables of the Worker.
186
+ * Environment variables of the instance.
211
187
  */
212
188
  variables?: Bindings;
213
- /**
214
- * Secrets of the Worker.
215
- */
216
- secrets?: Bindings;
217
189
  }): Promise<Worker<{
218
190
  [x: string]: alchemy_cloudflare.Binding;
219
191
  } & {
@@ -228,24 +200,36 @@ declare const composeD1Arguments: ({ resourceName, }: {
228
200
  primaryLocationHint: "weur";
229
201
  };
230
202
 
203
+ declare const composeDlqArguments: ({ resourceName, deliveryDelay, messageRetentionPeriod, }: {
204
+ resourceName: string;
205
+ deliveryDelay?: number;
206
+ messageRetentionPeriod?: number;
207
+ }) => {
208
+ name: string;
209
+ settings: {
210
+ deliveryDelay: number;
211
+ messageRetentionPeriod: number;
212
+ };
213
+ };
214
+
231
215
  declare const composeKvArguments: ({ resourceName, }: {
232
216
  resourceName: string;
233
217
  }) => {
234
218
  title: string;
235
219
  };
236
220
 
237
- declare const composeQueueArguments: ({ resourceName, deliveryDelay, messageRetentionPeriod, dlq, }: {
221
+ declare const composeQueueArguments: ({ resourceName, dlq, deliveryDelay, messageRetentionPeriod, }: {
238
222
  resourceName: string;
223
+ dlq: Queue;
239
224
  deliveryDelay?: number;
240
225
  messageRetentionPeriod?: number;
241
- dlq: Queue;
242
226
  }) => {
243
227
  name: string;
228
+ dlq: Queue;
244
229
  settings: {
245
230
  deliveryDelay: number;
246
231
  messageRetentionPeriod: number;
247
232
  };
248
- dlq: Queue;
249
233
  };
250
234
 
251
235
  declare const composeR2Arguments: ({ resourceName, storageClass, }: {
@@ -253,9 +237,9 @@ declare const composeR2Arguments: ({ resourceName, storageClass, }: {
253
237
  storageClass?: "Standard" | "InfrequentAccess";
254
238
  }) => {
255
239
  name: string;
240
+ storageClass: "Standard" | "InfrequentAccess";
256
241
  jurisdiction: "eu";
257
242
  locationHint: string;
258
- storageClass: "Standard" | "InfrequentAccess";
259
243
  };
260
244
 
261
245
  declare const composeIdentifierName: ({ resource, resourceName, }: {
@@ -268,4 +252,4 @@ declare const composeResourceName: ({ project, environment, resourceName, }: {
268
252
  resourceName: string;
269
253
  }) => string;
270
254
 
271
- export { Deployment, composeD1Arguments, composeIdentifierName, composeKvArguments, composeQueueArguments, composeR2Arguments, composeResourceName };
255
+ export { Deployment, composeD1Arguments, composeDlqArguments, composeIdentifierName, composeKvArguments, composeQueueArguments, composeR2Arguments, composeResourceName };