@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,4 +1,4 @@
1
- import { D as D1_LOCATION_HINT, Q as QUEUE_MESSAGE_RETENTION_PERIOD, a as QUEUE_DELIVERY_DELAY, R as R2_STORAGE_CLASS, b as R2_LOCATION_HINT, d as R2_JURISDICTION, l as loadWorkerConfig, f as QUEUE_MAX_BATCH_TIMEOUT, g as QUEUE_MAX_BATCH_SIZE, c as composeWorkerArguments, e as extractWorkerCrons, C as COMPATIBILITY_FLAGS, h as COMPATIBILITY_DATE } from '../shared/backend-sdk.Cyo7INro.mjs';
1
+ import { D as D1_LOCATION_HINT, Q as QUEUE_MESSAGE_RETENTION_PERIOD, b as QUEUE_DELIVERY_DELAY, R as R2_LOCATION_HINT, d as R2_JURISDICTION, f as R2_STORAGE_CLASS, l as loadWorkerConfig, g as QUEUE_MAX_BATCH_TIMEOUT, h as QUEUE_MAX_BATCH_SIZE, c as composeWorkerArguments, a as extractWorkerVars, e as extractWorkerCrons, C as COMPATIBILITY_FLAGS, i as COMPATIBILITY_DATE } from '../shared/backend-sdk.c1cEUEGX.mjs';
2
2
  import { toKebabCase } from '@std/text';
3
3
  import { KVNamespace, D1Database, Queue, R2Bucket, DurableObjectNamespace, Worker, Nuxt } from 'alchemy/cloudflare';
4
4
  import { A as ALCHEMY_STATE_STORE } from '../shared/backend-sdk.BIVnu5aA.mjs';
@@ -16,6 +16,20 @@ const composeD1Arguments = ({
16
16
  };
17
17
  };
18
18
 
19
+ const composeDlqArguments = ({
20
+ resourceName,
21
+ deliveryDelay = QUEUE_DELIVERY_DELAY,
22
+ messageRetentionPeriod = QUEUE_MESSAGE_RETENTION_PERIOD
23
+ }) => {
24
+ return {
25
+ name: resourceName,
26
+ settings: {
27
+ deliveryDelay,
28
+ messageRetentionPeriod
29
+ }
30
+ };
31
+ };
32
+
19
33
  const composeKvArguments = ({
20
34
  resourceName
21
35
  }) => {
@@ -26,17 +40,17 @@ const composeKvArguments = ({
26
40
 
27
41
  const composeQueueArguments = ({
28
42
  resourceName,
43
+ dlq,
29
44
  deliveryDelay = QUEUE_DELIVERY_DELAY,
30
- messageRetentionPeriod = QUEUE_MESSAGE_RETENTION_PERIOD,
31
- dlq
45
+ messageRetentionPeriod = QUEUE_MESSAGE_RETENTION_PERIOD
32
46
  }) => {
33
47
  return {
34
48
  name: resourceName,
49
+ dlq,
35
50
  settings: {
36
51
  deliveryDelay,
37
52
  messageRetentionPeriod
38
- },
39
- dlq
53
+ }
40
54
  };
41
55
  };
42
56
 
@@ -46,9 +60,9 @@ const composeR2Arguments = ({
46
60
  }) => {
47
61
  return {
48
62
  name: resourceName,
63
+ storageClass,
49
64
  jurisdiction: R2_JURISDICTION,
50
- locationHint: R2_LOCATION_HINT,
51
- storageClass
65
+ locationHint: R2_LOCATION_HINT
52
66
  };
53
67
  };
54
68
 
@@ -66,23 +80,10 @@ const composeResourceName = ({
66
80
  return `${project}-${toKebabCase(resourceName).toLowerCase()}-${environment}`;
67
81
  };
68
82
 
69
- const composeDlqArguments = ({
70
- resourceName,
71
- deliveryDelay = QUEUE_DELIVERY_DELAY,
72
- messageRetentionPeriod = QUEUE_MESSAGE_RETENTION_PERIOD
73
- }) => {
74
- return {
75
- name: resourceName,
76
- settings: {
77
- deliveryDelay,
78
- messageRetentionPeriod
79
- }
80
- };
81
- };
82
-
83
83
  class Deployment {
84
84
  project;
85
85
  environment;
86
+ // TODO: Check if the type is most correct
86
87
  alchemy;
87
88
  constructor({ project }) {
88
89
  this.project = project;
@@ -93,6 +94,7 @@ class Deployment {
93
94
  scriptName: ALCHEMY_STATE_STORE
94
95
  });
95
96
  },
97
+ // TODO: Convert to a util
96
98
  stage: Bun.env.ENVIRONMENT || "unknown"
97
99
  });
98
100
  }
@@ -135,11 +137,11 @@ class Deployment {
135
137
  );
136
138
  }
137
139
  /**
138
- * Creates an instance of Cloudflare Queue.
140
+ * Creates an instance of Cloudflare Queue. A DLQ is created automatically.
139
141
  */
140
142
  async queue(options) {
141
143
  const { resourceName, deliveryDelay, messageRetentionPeriod } = options;
142
- const dlq = await this.dlq({
144
+ const deadLetterQueue = await this.dlq({
143
145
  resourceName
144
146
  });
145
147
  return await Queue(
@@ -150,9 +152,9 @@ class Deployment {
150
152
  environment: this.environment,
151
153
  resourceName
152
154
  }),
155
+ dlq: deadLetterQueue,
153
156
  deliveryDelay,
154
- messageRetentionPeriod,
155
- dlq
157
+ messageRetentionPeriod
156
158
  })
157
159
  );
158
160
  }
@@ -202,6 +204,7 @@ class Deployment {
202
204
  resourceName: className,
203
205
  resource: "durable-object"
204
206
  }),
207
+ // TODO: Create util
205
208
  {
206
209
  // TODO: Create util
207
210
  className: `${className}DurableObject`,
@@ -221,12 +224,11 @@ class Deployment {
221
224
  assets,
222
225
  crons,
223
226
  bindings,
224
- variables,
225
- secrets,
226
227
  eventSources
227
228
  } = options;
228
229
  const identifierName = composeIdentifierName({
229
230
  resourceName,
231
+ // TODO: Convert to a util
230
232
  resource: resource || "worker"
231
233
  });
232
234
  const workerConfig = await loadWorkerConfig({ path });
@@ -237,10 +239,12 @@ class Deployment {
237
239
  deadLetterQueue: queue.dlq,
238
240
  batchSize: QUEUE_MAX_BATCH_SIZE,
239
241
  maxWaitTimeMs: QUEUE_MAX_BATCH_TIMEOUT
242
+ // TODO: Watch out for the type
240
243
  }
241
244
  };
242
245
  });
243
246
  return await Worker(
247
+ // TODO: Make it to use composeIdentifierName similary to other resources
244
248
  identifierName,
245
249
  composeWorkerArguments({
246
250
  resourceName: composeResourceName({
@@ -252,14 +256,17 @@ class Deployment {
252
256
  entrypoint: `${path}/src/index.ts`,
253
257
  domains,
254
258
  assets,
259
+ // TODO: Convert to a util
255
260
  crons: crons || extractWorkerCrons({
256
261
  workerConfig,
257
262
  environment: this.environment
258
263
  }),
259
264
  bindings: {
260
265
  ...bindings,
261
- ...variables,
262
- ...secrets
266
+ ...extractWorkerVars({
267
+ workerConfig,
268
+ environment: this.environment
269
+ })
263
270
  },
264
271
  eventSources: consumers
265
272
  })
@@ -269,15 +276,13 @@ class Deployment {
269
276
  * Creates an instance of Cloudflare Worker as a service.
270
277
  */
271
278
  async service(options) {
272
- const { resourceName, bindings, variables, secrets, eventSources } = options;
279
+ const { resourceName, bindings, eventSources } = options;
273
280
  return await this.worker({
274
281
  resourceName,
275
282
  resource: "service",
276
283
  // TODO: Convert to util
277
284
  path: `./services/${resourceName}`,
278
285
  bindings,
279
- variables,
280
- secrets,
281
286
  eventSources
282
287
  });
283
288
  }
@@ -285,14 +290,7 @@ class Deployment {
285
290
  * Creates an instance of Cloudflare Worker as an orchestrator.
286
291
  */
287
292
  async orchestrator(options) {
288
- const {
289
- resourceName,
290
- domains,
291
- bindings,
292
- variables,
293
- secrets,
294
- eventSources
295
- } = options;
293
+ const { resourceName, domains, bindings, eventSources } = options;
296
294
  return await this.worker({
297
295
  resourceName,
298
296
  resource: "orchestrator",
@@ -300,8 +298,6 @@ class Deployment {
300
298
  path: `./apps/${resourceName}`,
301
299
  domains,
302
300
  bindings,
303
- variables,
304
- secrets,
305
301
  eventSources
306
302
  });
307
303
  }
@@ -309,7 +305,7 @@ class Deployment {
309
305
  * Creates an instance of Cloudflare Worker as a client.
310
306
  */
311
307
  async client(options) {
312
- const { resourceName, domains, bindings, variables, secrets } = options;
308
+ const { resourceName, domains, bindings, variables } = options;
313
309
  return await Nuxt(
314
310
  composeIdentifierName({
315
311
  resourceName,
@@ -330,8 +326,7 @@ class Deployment {
330
326
  domains,
331
327
  bindings: {
332
328
  ...bindings,
333
- ...variables,
334
- ...secrets
329
+ ...variables
335
330
  },
336
331
  // TODO: Convert to util
337
332
  cwd: `./apps/${resourceName}`
@@ -340,4 +335,4 @@ class Deployment {
340
335
  }
341
336
  }
342
337
 
343
- export { Deployment, composeD1Arguments, composeIdentifierName, composeKvArguments, composeQueueArguments, composeR2Arguments, composeResourceName, composeWorkerArguments, extractWorkerCrons, loadWorkerConfig };
338
+ export { Deployment, composeD1Arguments, composeDlqArguments, composeIdentifierName, composeKvArguments, composeQueueArguments, composeR2Arguments, composeResourceName, composeWorkerArguments, extractWorkerCrons, extractWorkerVars, loadWorkerConfig };
@@ -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
  require('../shared/backend-sdk.ClVQ4AzB.cjs');
5
5
  require('@std/path');
6
6
  require('comment-json');
@@ -9,4 +9,5 @@ require('comment-json');
9
9
 
10
10
  exports.composeWorkerArguments = worker.composeWorkerArguments;
11
11
  exports.extractWorkerCrons = worker.extractWorkerCrons;
12
+ exports.extractWorkerVars = worker.extractWorkerVars;
12
13
  exports.loadWorkerConfig = worker.loadWorkerConfig;
@@ -1,3 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.D8N5si7y.cjs';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, a as extractWorkerVars, l as loadWorkerConfig } from '../shared/backend-sdk.CdngrAa0.cjs';
2
2
  import 'alchemy/cloudflare';
3
3
  import '../shared/backend-sdk.CYcpgphg.cjs';
@@ -1,3 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.OvCBQJUw.mjs';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, a as extractWorkerVars, l as loadWorkerConfig } from '../shared/backend-sdk.C-0xIdM4.mjs';
2
2
  import 'alchemy/cloudflare';
3
3
  import '../shared/backend-sdk.CYcpgphg.mjs';
@@ -1,3 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.DSK5flKM.js';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, a as extractWorkerVars, l as loadWorkerConfig } from '../shared/backend-sdk.qPzlx18G.js';
2
2
  import 'alchemy/cloudflare';
3
3
  import '../shared/backend-sdk.CYcpgphg.js';
@@ -1,4 +1,4 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.Cyo7INro.mjs';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, a as extractWorkerVars, l as loadWorkerConfig } from '../shared/backend-sdk.c1cEUEGX.mjs';
2
2
  import '../shared/backend-sdk.BIVnu5aA.mjs';
3
3
  import '@std/path';
4
4
  import 'comment-json';
@@ -4,11 +4,17 @@ import { E as Environment } from './backend-sdk.CYcpgphg.mjs';
4
4
  type Resource = 'kv' | 'd1' | 'queue' | 'dlq' | 'r2' | 'durable-object' | 'worker' | 'service' | 'orchestrator' | 'client';
5
5
  type WorkerType = 'service' | 'orchestrator' | 'client';
6
6
  interface WorkerConfig {
7
+ vars: {
8
+ [key: string]: string;
9
+ };
7
10
  triggers: {
8
11
  crons: string[];
9
12
  };
10
13
  env: {
11
14
  [key: string]: {
15
+ vars: {
16
+ [key: string]: string;
17
+ };
12
18
  triggers: {
13
19
  crons: string[];
14
20
  };
@@ -23,6 +29,12 @@ declare const extractWorkerCrons: ({ workerConfig, environment, }: {
23
29
  workerConfig: WorkerConfig;
24
30
  environment: Environment;
25
31
  }) => string[];
32
+ declare const extractWorkerVars: ({ workerConfig, environment, }: {
33
+ workerConfig: WorkerConfig;
34
+ environment: Environment;
35
+ }) => {
36
+ [key: string]: string;
37
+ };
26
38
  declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domains, crons, bindings, eventSources, }: {
27
39
  resourceName: string;
28
40
  entrypoint: string;
@@ -53,5 +65,5 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domai
53
65
  bindings: Bindings | undefined;
54
66
  };
55
67
 
56
- export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
68
+ export { extractWorkerVars as a, composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
57
69
  export type { Resource as R, WorkerType as W };
@@ -4,11 +4,17 @@ import { E as Environment } from './backend-sdk.CYcpgphg.cjs';
4
4
  type Resource = 'kv' | 'd1' | 'queue' | 'dlq' | 'r2' | 'durable-object' | 'worker' | 'service' | 'orchestrator' | 'client';
5
5
  type WorkerType = 'service' | 'orchestrator' | 'client';
6
6
  interface WorkerConfig {
7
+ vars: {
8
+ [key: string]: string;
9
+ };
7
10
  triggers: {
8
11
  crons: string[];
9
12
  };
10
13
  env: {
11
14
  [key: string]: {
15
+ vars: {
16
+ [key: string]: string;
17
+ };
12
18
  triggers: {
13
19
  crons: string[];
14
20
  };
@@ -23,6 +29,12 @@ declare const extractWorkerCrons: ({ workerConfig, environment, }: {
23
29
  workerConfig: WorkerConfig;
24
30
  environment: Environment;
25
31
  }) => string[];
32
+ declare const extractWorkerVars: ({ workerConfig, environment, }: {
33
+ workerConfig: WorkerConfig;
34
+ environment: Environment;
35
+ }) => {
36
+ [key: string]: string;
37
+ };
26
38
  declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domains, crons, bindings, eventSources, }: {
27
39
  resourceName: string;
28
40
  entrypoint: string;
@@ -53,5 +65,5 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domai
53
65
  bindings: Bindings | undefined;
54
66
  };
55
67
 
56
- export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
68
+ export { extractWorkerVars as a, composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
57
69
  export type { Resource as R, WorkerType as W };
@@ -33,6 +33,15 @@ const extractWorkerCrons = ({
33
33
  }
34
34
  return workerConfig.env[environment]?.triggers?.crons || [];
35
35
  };
36
+ const extractWorkerVars = ({
37
+ workerConfig,
38
+ environment
39
+ }) => {
40
+ if (!environment_consts.ENVIRONMENT.includes(String(environment))) {
41
+ return workerConfig.vars || [];
42
+ }
43
+ return workerConfig.env[environment]?.vars || [];
44
+ };
36
45
  const composeWorkerArguments = ({
37
46
  resourceName,
38
47
  entrypoint,
@@ -71,4 +80,5 @@ exports.R2_LOCATION_HINT = R2_LOCATION_HINT;
71
80
  exports.R2_STORAGE_CLASS = R2_STORAGE_CLASS;
72
81
  exports.composeWorkerArguments = composeWorkerArguments;
73
82
  exports.extractWorkerCrons = extractWorkerCrons;
83
+ exports.extractWorkerVars = extractWorkerVars;
74
84
  exports.loadWorkerConfig = loadWorkerConfig;
@@ -31,6 +31,15 @@ const extractWorkerCrons = ({
31
31
  }
32
32
  return workerConfig.env[environment]?.triggers?.crons || [];
33
33
  };
34
+ const extractWorkerVars = ({
35
+ workerConfig,
36
+ environment
37
+ }) => {
38
+ if (!ENVIRONMENT.includes(String(environment))) {
39
+ return workerConfig.vars || [];
40
+ }
41
+ return workerConfig.env[environment]?.vars || [];
42
+ };
34
43
  const composeWorkerArguments = ({
35
44
  resourceName,
36
45
  entrypoint,
@@ -57,4 +66,4 @@ const composeWorkerArguments = ({
57
66
  };
58
67
  };
59
68
 
60
- export { COMPATIBILITY_FLAGS as C, D1_LOCATION_HINT as D, QUEUE_MESSAGE_RETENTION_PERIOD as Q, R2_STORAGE_CLASS as R, QUEUE_DELIVERY_DELAY as a, R2_LOCATION_HINT as b, composeWorkerArguments as c, R2_JURISDICTION as d, extractWorkerCrons as e, QUEUE_MAX_BATCH_TIMEOUT as f, QUEUE_MAX_BATCH_SIZE as g, COMPATIBILITY_DATE as h, loadWorkerConfig as l };
69
+ export { COMPATIBILITY_FLAGS as C, D1_LOCATION_HINT as D, QUEUE_MESSAGE_RETENTION_PERIOD as Q, R2_LOCATION_HINT as R, extractWorkerVars as a, QUEUE_DELIVERY_DELAY as b, composeWorkerArguments as c, R2_JURISDICTION as d, extractWorkerCrons as e, R2_STORAGE_CLASS as f, QUEUE_MAX_BATCH_TIMEOUT as g, QUEUE_MAX_BATCH_SIZE as h, COMPATIBILITY_DATE as i, loadWorkerConfig as l };
@@ -4,11 +4,17 @@ import { E as Environment } from './backend-sdk.CYcpgphg.js';
4
4
  type Resource = 'kv' | 'd1' | 'queue' | 'dlq' | 'r2' | 'durable-object' | 'worker' | 'service' | 'orchestrator' | 'client';
5
5
  type WorkerType = 'service' | 'orchestrator' | 'client';
6
6
  interface WorkerConfig {
7
+ vars: {
8
+ [key: string]: string;
9
+ };
7
10
  triggers: {
8
11
  crons: string[];
9
12
  };
10
13
  env: {
11
14
  [key: string]: {
15
+ vars: {
16
+ [key: string]: string;
17
+ };
12
18
  triggers: {
13
19
  crons: string[];
14
20
  };
@@ -23,6 +29,12 @@ declare const extractWorkerCrons: ({ workerConfig, environment, }: {
23
29
  workerConfig: WorkerConfig;
24
30
  environment: Environment;
25
31
  }) => string[];
32
+ declare const extractWorkerVars: ({ workerConfig, environment, }: {
33
+ workerConfig: WorkerConfig;
34
+ environment: Environment;
35
+ }) => {
36
+ [key: string]: string;
37
+ };
26
38
  declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domains, crons, bindings, eventSources, }: {
27
39
  resourceName: string;
28
40
  entrypoint: string;
@@ -53,5 +65,5 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, domai
53
65
  bindings: Bindings | undefined;
54
66
  };
55
67
 
56
- export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
68
+ export { extractWorkerVars as a, composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
57
69
  export type { Resource as R, WorkerType as W };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "5.29.1",
3
+ "version": "5.30.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -38,19 +38,19 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@cloudflare/workers-types": "4.20250923.0",
41
+ "@cloudflare/workers-types": "4.20251001.0",
42
42
  "@std/path": "npm:@jsr/std__path",
43
43
  "@std/text": "npm:@jsr/std__text",
44
- "comment-json": "^4.2.5",
45
- "drizzle-kit": "^0.31.4",
44
+ "comment-json": "^4.3.0",
45
+ "drizzle-kit": "^0.31.5",
46
46
  "drizzle-orm": "^0.44.5",
47
47
  "h3": "^1.15.4",
48
48
  "http-status-codes": "2.3.0",
49
49
  "superjson": "^2.2.2"
50
50
  },
51
51
  "peerDependencies": {
52
- "@develit-io/general-codes": "^1.12.1",
53
- "alchemy": "^0.69.0",
52
+ "@develit-io/general-codes": "^1.14.0",
53
+ "alchemy": "^0.69.1",
54
54
  "zod": "^4.1.8"
55
55
  }
56
56
  }