@develit-io/backend-sdk 5.21.0 → 5.21.2

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/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ const pgCore = require('drizzle-orm/pg-core');
5
5
  const sqliteCore = require('drizzle-orm/sqlite-core');
6
6
  const generalCodes = require('@develit-io/general-codes');
7
7
  const text = require('@std/text');
8
+ const cloudflare = require('alchemy/cloudflare');
8
9
  const z = require('zod/v4/core');
9
10
  require('http-status-codes');
10
11
  const h3 = require('h3');
@@ -81,12 +82,9 @@ const composeD1Arguments = ({
81
82
  resourceName
82
83
  }) => {
83
84
  return {
84
- transform: {
85
- database: {
86
- name: resourceName,
87
- primaryLocationHint: "weur"
88
- }
89
- }
85
+ name: resourceName,
86
+ primaryLocationHint: "weur"
87
+ // TODO: It's possible that it will take care of migrations as well
90
88
  };
91
89
  };
92
90
 
@@ -94,11 +92,7 @@ const composeKvArguments = ({
94
92
  resourceName
95
93
  }) => {
96
94
  return {
97
- transform: {
98
- namespace: {
99
- title: resourceName
100
- }
101
- }
95
+ title: resourceName
102
96
  };
103
97
  };
104
98
 
@@ -108,14 +102,10 @@ const composeQueueArguments = ({
108
102
  messageRetentionPeriod = 259200
109
103
  }) => {
110
104
  return {
111
- transform: {
112
- queue: {
113
- queueName: resourceName,
114
- settings: {
115
- deliveryDelay,
116
- messageRetentionPeriod
117
- }
118
- }
105
+ name: resourceName,
106
+ settings: {
107
+ deliveryDelay,
108
+ messageRetentionPeriod
119
109
  }
120
110
  };
121
111
  };
@@ -125,14 +115,10 @@ const composeR2Arguments = ({
125
115
  storageClass = "Standard"
126
116
  }) => {
127
117
  return {
128
- transform: {
129
- bucket: {
130
- name: resourceName,
131
- jurisdiction: "eu",
132
- location: "weur",
133
- storageClass
134
- }
135
- }
118
+ name: resourceName,
119
+ jurisdiction: "eu",
120
+ locationHint: "weur",
121
+ storageClass
136
122
  };
137
123
  };
138
124
 
@@ -144,6 +130,12 @@ const composeBindingName = ({
144
130
  const convertedBindingName = bindingName ? text.toSnakeCase(bindingName) : `${text.toSnakeCase(resourceName)}_${resource}`;
145
131
  return convertedBindingName.toUpperCase();
146
132
  };
133
+ const composeIdentifierName = ({
134
+ resource,
135
+ resourceName
136
+ }) => {
137
+ return `${resourceName}-${resource}`;
138
+ };
147
139
  const composeResourceName = ({
148
140
  project,
149
141
  environment,
@@ -155,23 +147,20 @@ const composeResourceName = ({
155
147
  class Infrastructure {
156
148
  project;
157
149
  environment;
158
- sst;
159
150
  constructor({
160
151
  project,
161
- environment,
162
- sst
152
+ environment
163
153
  }) {
164
154
  this.project = project;
165
155
  this.environment = environment;
166
- this.sst = sst;
167
156
  }
168
157
  /**
169
158
  * Creates an instance of Cloudflare KV.
170
159
  */
171
- kv(options) {
172
- const { resourceName, bindingName } = options;
173
- return new this.sst.cloudflare.Kv(
174
- `${composeBindingName({ resource: "kv", resourceName, bindingName })}`,
160
+ async kv(options) {
161
+ const { resourceName } = options;
162
+ return await cloudflare.KVNamespace(
163
+ composeIdentifierName({ resourceName, resource: "kv" }),
175
164
  composeKvArguments({
176
165
  resourceName: composeResourceName({
177
166
  project: this.project,
@@ -184,10 +173,10 @@ class Infrastructure {
184
173
  /**
185
174
  * Creates an instance of Cloudflare D1.
186
175
  */
187
- d1(options) {
188
- const { resourceName, bindingName } = options;
189
- return new this.sst.cloudflare.D1(
190
- `${composeBindingName({ resource: "d1", resourceName, bindingName })}`,
176
+ async d1(options) {
177
+ const { resourceName } = options;
178
+ return await cloudflare.D1Database(
179
+ composeIdentifierName({ resourceName, resource: "d1" }),
191
180
  composeD1Arguments({
192
181
  resourceName: composeResourceName({
193
182
  project: this.project,
@@ -200,10 +189,10 @@ class Infrastructure {
200
189
  /**
201
190
  * Creates an instance of Cloudflare Queue.
202
191
  */
203
- queue(options) {
204
- const { resourceName, bindingName, deliveryDelay, messageRetentionPeriod } = options;
205
- return new this.sst.cloudflare.Queue(
206
- `${composeBindingName({ resource: "queue", resourceName, bindingName })}`,
192
+ async queue(options) {
193
+ const { resourceName, deliveryDelay, messageRetentionPeriod } = options;
194
+ return await cloudflare.Queue(
195
+ composeIdentifierName({ resourceName, resource: "queue" }),
207
196
  composeQueueArguments({
208
197
  resourceName: composeResourceName({
209
198
  project: this.project,
@@ -218,10 +207,10 @@ class Infrastructure {
218
207
  /**
219
208
  * Creates an instance of Cloudflare R2.
220
209
  */
221
- r2(options) {
222
- const { resourceName, bindingName, storageClass } = options;
223
- return new this.sst.cloudflare.Bucket(
224
- `${composeBindingName({ resource: "r2", resourceName, bindingName })}`,
210
+ async r2(options) {
211
+ const { resourceName, storageClass } = options;
212
+ return await cloudflare.R2Bucket(
213
+ composeIdentifierName({ resourceName, resource: "r2" }),
225
214
  composeR2Arguments({
226
215
  resourceName: composeResourceName({
227
216
  project: this.project,
package/dist/index.d.cts CHANGED
@@ -4,10 +4,11 @@ import * as drizzle_orm from 'drizzle-orm';
4
4
  import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult } from 'drizzle-orm';
5
5
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
6
6
  import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
7
+ import { KVNamespace, D1Database, Queue, R2Bucket } from 'alchemy/cloudflare';
7
8
  import * as z from 'zod/v4/core';
8
9
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
10
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
- import { Queue } from '@cloudflare/workers-types';
11
+ import { Queue as Queue$1 } from '@cloudflare/workers-types';
11
12
  import { BatchItem } from 'drizzle-orm/batch';
12
13
  import { DrizzleD1Database } from 'drizzle-orm/d1';
13
14
 
@@ -50,19 +51,12 @@ type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
50
51
 
51
52
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
52
53
 
53
- interface SstInstance {
54
- cloudflare: {
55
- [key: string]: any;
56
- };
57
- }
58
54
  declare class Infrastructure {
59
55
  private project;
60
56
  private environment;
61
- private sst;
62
- constructor({ project, environment, sst, }: {
57
+ constructor({ project, environment, }: {
63
58
  project: Project;
64
59
  environment: Environment;
65
- sst: SstInstance;
66
60
  });
67
61
  /**
68
62
  * Creates an instance of Cloudflare KV.
@@ -72,11 +66,7 @@ declare class Infrastructure {
72
66
  * Name of the KV. Do not include the 'kv' prefix.
73
67
  */
74
68
  resourceName: string;
75
- /**
76
- * Name of the KV's binding. If not set, it is generated automatically based on the provided name.
77
- */
78
- bindingName?: string;
79
- }): any;
69
+ }): Promise<KVNamespace>;
80
70
  /**
81
71
  * Creates an instance of Cloudflare D1.
82
72
  */
@@ -85,11 +75,7 @@ declare class Infrastructure {
85
75
  * Name of the D1. Do not include the 'd1' prefix.
86
76
  */
87
77
  resourceName: string;
88
- /**
89
- * Name of the D1's binding. If not set, it is generated automatically based on the provided name.
90
- */
91
- bindingName?: string;
92
- }): any;
78
+ }): Promise<D1Database>;
93
79
  /**
94
80
  * Creates an instance of Cloudflare Queue.
95
81
  */
@@ -98,10 +84,6 @@ declare class Infrastructure {
98
84
  * Name of the Queue. Do not include the 'queue' prefix.
99
85
  */
100
86
  resourceName: string;
101
- /**
102
- * Name of the Queue's binding. If not set, it is generated automatically based on the provided name.
103
- */
104
- bindingName?: string;
105
87
  /**
106
88
  * The number of seconds to delay delivery of messages to the queue.
107
89
  */
@@ -110,7 +92,7 @@ declare class Infrastructure {
110
92
  * The number of seconds a message will remain in the queue before being deleted.
111
93
  */
112
94
  messageRetentionPeriod?: number;
113
- }): any;
95
+ }): Promise<Queue<unknown>>;
114
96
  /**
115
97
  * Creates an instance of Cloudflare R2.
116
98
  */
@@ -119,15 +101,11 @@ declare class Infrastructure {
119
101
  * Name of the R2. Do not include the 'r2' prefix.
120
102
  */
121
103
  resourceName: string;
122
- /**
123
- * Name of the R2's binding. If not set, it is generated automatically based on the provided name.
124
- */
125
- bindingName?: string;
126
104
  /**
127
105
  * The storage class for the R2 bucket.
128
106
  */
129
107
  storageClass?: 'Standard' | 'InfrequentAccess';
130
- }): any;
108
+ }): Promise<R2Bucket>;
131
109
  }
132
110
 
133
111
  interface AuditLogPayload<T> {
@@ -244,8 +222,8 @@ interface DevelitWorkerMethods {
244
222
  logInput(data: object): void;
245
223
  logOutput(data: object): void;
246
224
  logError(error: object): void;
247
- pushToQueue<T>(queue: Queue, message: T | T[]): Promise<void>;
248
- recordAuditLogMessage<T>(queue: Queue, message: T | T[]): Promise<void>;
225
+ pushToQueue<T>(queue: Queue$1, message: T | T[]): Promise<void>;
226
+ recordAuditLogMessage<T>(queue: Queue$1, message: T | T[]): Promise<void>;
249
227
  handleInput<T extends z.$ZodType>(args: {
250
228
  input: z.infer<T>;
251
229
  schema: T;
@@ -329,7 +307,7 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
329
307
  */
330
308
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
331
309
 
332
- declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
310
+ declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): any;
333
311
  declare const getD1DatabaseIdFromWrangler: () => string | undefined;
334
312
  declare const getD1Credentials: () => {
335
313
  driver?: undefined;
@@ -337,14 +315,14 @@ declare const getD1Credentials: () => {
337
315
  } | {
338
316
  driver: string;
339
317
  dbCredentials: {
340
- accountId: string | undefined;
318
+ accountId: any;
341
319
  databaseId: string;
342
- token: string | undefined;
320
+ token: any;
343
321
  url?: undefined;
344
322
  };
345
323
  } | {
346
324
  dbCredentials: {
347
- url: string | undefined;
325
+ url: any;
348
326
  accountId?: undefined;
349
327
  databaseId?: undefined;
350
328
  token?: undefined;
@@ -360,9 +338,9 @@ declare const getDrizzleD1Config: () => {
360
338
  } | {
361
339
  driver: string;
362
340
  dbCredentials: {
363
- accountId: string | undefined;
341
+ accountId: any;
364
342
  databaseId: string;
365
- token: string | undefined;
343
+ token: any;
366
344
  url?: undefined;
367
345
  };
368
346
  schema: string;
@@ -370,7 +348,7 @@ declare const getDrizzleD1Config: () => {
370
348
  dialect: "sqlite";
371
349
  } | {
372
350
  dbCredentials: {
373
- url: string | undefined;
351
+ url: any;
374
352
  accountId?: undefined;
375
353
  databaseId?: undefined;
376
354
  token?: undefined;
@@ -428,7 +406,7 @@ declare const getPgLocalConnectionString: (id: string) => string;
428
406
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
429
407
  declare const getPgCredentials: (serviceName?: string) => {
430
408
  dbCredentials: {
431
- url: string;
409
+ url: any;
432
410
  };
433
411
  };
434
412
  declare const getDrizzlePgConfig: () => {
@@ -437,7 +415,7 @@ declare const getDrizzlePgConfig: () => {
437
415
  schema: string;
438
416
  };
439
417
  dbCredentials: {
440
- url: string;
418
+ url: any;
441
419
  };
442
420
  schema: string;
443
421
  out: string;
package/dist/index.d.mts CHANGED
@@ -4,10 +4,11 @@ import * as drizzle_orm from 'drizzle-orm';
4
4
  import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult } from 'drizzle-orm';
5
5
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
6
6
  import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
7
+ import { KVNamespace, D1Database, Queue, R2Bucket } from 'alchemy/cloudflare';
7
8
  import * as z from 'zod/v4/core';
8
9
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
10
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
- import { Queue } from '@cloudflare/workers-types';
11
+ import { Queue as Queue$1 } from '@cloudflare/workers-types';
11
12
  import { BatchItem } from 'drizzle-orm/batch';
12
13
  import { DrizzleD1Database } from 'drizzle-orm/d1';
13
14
 
@@ -50,19 +51,12 @@ type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
50
51
 
51
52
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
52
53
 
53
- interface SstInstance {
54
- cloudflare: {
55
- [key: string]: any;
56
- };
57
- }
58
54
  declare class Infrastructure {
59
55
  private project;
60
56
  private environment;
61
- private sst;
62
- constructor({ project, environment, sst, }: {
57
+ constructor({ project, environment, }: {
63
58
  project: Project;
64
59
  environment: Environment;
65
- sst: SstInstance;
66
60
  });
67
61
  /**
68
62
  * Creates an instance of Cloudflare KV.
@@ -72,11 +66,7 @@ declare class Infrastructure {
72
66
  * Name of the KV. Do not include the 'kv' prefix.
73
67
  */
74
68
  resourceName: string;
75
- /**
76
- * Name of the KV's binding. If not set, it is generated automatically based on the provided name.
77
- */
78
- bindingName?: string;
79
- }): any;
69
+ }): Promise<KVNamespace>;
80
70
  /**
81
71
  * Creates an instance of Cloudflare D1.
82
72
  */
@@ -85,11 +75,7 @@ declare class Infrastructure {
85
75
  * Name of the D1. Do not include the 'd1' prefix.
86
76
  */
87
77
  resourceName: string;
88
- /**
89
- * Name of the D1's binding. If not set, it is generated automatically based on the provided name.
90
- */
91
- bindingName?: string;
92
- }): any;
78
+ }): Promise<D1Database>;
93
79
  /**
94
80
  * Creates an instance of Cloudflare Queue.
95
81
  */
@@ -98,10 +84,6 @@ declare class Infrastructure {
98
84
  * Name of the Queue. Do not include the 'queue' prefix.
99
85
  */
100
86
  resourceName: string;
101
- /**
102
- * Name of the Queue's binding. If not set, it is generated automatically based on the provided name.
103
- */
104
- bindingName?: string;
105
87
  /**
106
88
  * The number of seconds to delay delivery of messages to the queue.
107
89
  */
@@ -110,7 +92,7 @@ declare class Infrastructure {
110
92
  * The number of seconds a message will remain in the queue before being deleted.
111
93
  */
112
94
  messageRetentionPeriod?: number;
113
- }): any;
95
+ }): Promise<Queue<unknown>>;
114
96
  /**
115
97
  * Creates an instance of Cloudflare R2.
116
98
  */
@@ -119,15 +101,11 @@ declare class Infrastructure {
119
101
  * Name of the R2. Do not include the 'r2' prefix.
120
102
  */
121
103
  resourceName: string;
122
- /**
123
- * Name of the R2's binding. If not set, it is generated automatically based on the provided name.
124
- */
125
- bindingName?: string;
126
104
  /**
127
105
  * The storage class for the R2 bucket.
128
106
  */
129
107
  storageClass?: 'Standard' | 'InfrequentAccess';
130
- }): any;
108
+ }): Promise<R2Bucket>;
131
109
  }
132
110
 
133
111
  interface AuditLogPayload<T> {
@@ -244,8 +222,8 @@ interface DevelitWorkerMethods {
244
222
  logInput(data: object): void;
245
223
  logOutput(data: object): void;
246
224
  logError(error: object): void;
247
- pushToQueue<T>(queue: Queue, message: T | T[]): Promise<void>;
248
- recordAuditLogMessage<T>(queue: Queue, message: T | T[]): Promise<void>;
225
+ pushToQueue<T>(queue: Queue$1, message: T | T[]): Promise<void>;
226
+ recordAuditLogMessage<T>(queue: Queue$1, message: T | T[]): Promise<void>;
249
227
  handleInput<T extends z.$ZodType>(args: {
250
228
  input: z.infer<T>;
251
229
  schema: T;
@@ -329,7 +307,7 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
329
307
  */
330
308
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
331
309
 
332
- declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
310
+ declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): any;
333
311
  declare const getD1DatabaseIdFromWrangler: () => string | undefined;
334
312
  declare const getD1Credentials: () => {
335
313
  driver?: undefined;
@@ -337,14 +315,14 @@ declare const getD1Credentials: () => {
337
315
  } | {
338
316
  driver: string;
339
317
  dbCredentials: {
340
- accountId: string | undefined;
318
+ accountId: any;
341
319
  databaseId: string;
342
- token: string | undefined;
320
+ token: any;
343
321
  url?: undefined;
344
322
  };
345
323
  } | {
346
324
  dbCredentials: {
347
- url: string | undefined;
325
+ url: any;
348
326
  accountId?: undefined;
349
327
  databaseId?: undefined;
350
328
  token?: undefined;
@@ -360,9 +338,9 @@ declare const getDrizzleD1Config: () => {
360
338
  } | {
361
339
  driver: string;
362
340
  dbCredentials: {
363
- accountId: string | undefined;
341
+ accountId: any;
364
342
  databaseId: string;
365
- token: string | undefined;
343
+ token: any;
366
344
  url?: undefined;
367
345
  };
368
346
  schema: string;
@@ -370,7 +348,7 @@ declare const getDrizzleD1Config: () => {
370
348
  dialect: "sqlite";
371
349
  } | {
372
350
  dbCredentials: {
373
- url: string | undefined;
351
+ url: any;
374
352
  accountId?: undefined;
375
353
  databaseId?: undefined;
376
354
  token?: undefined;
@@ -428,7 +406,7 @@ declare const getPgLocalConnectionString: (id: string) => string;
428
406
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
429
407
  declare const getPgCredentials: (serviceName?: string) => {
430
408
  dbCredentials: {
431
- url: string;
409
+ url: any;
432
410
  };
433
411
  };
434
412
  declare const getDrizzlePgConfig: () => {
@@ -437,7 +415,7 @@ declare const getDrizzlePgConfig: () => {
437
415
  schema: string;
438
416
  };
439
417
  dbCredentials: {
440
- url: string;
418
+ url: any;
441
419
  };
442
420
  schema: string;
443
421
  out: string;
package/dist/index.d.ts CHANGED
@@ -4,10 +4,11 @@ import * as drizzle_orm from 'drizzle-orm';
4
4
  import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult } from 'drizzle-orm';
5
5
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
6
6
  import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
7
+ import { KVNamespace, D1Database, Queue, R2Bucket } from 'alchemy/cloudflare';
7
8
  import * as z from 'zod/v4/core';
8
9
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
10
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
- import { Queue } from '@cloudflare/workers-types';
11
+ import { Queue as Queue$1 } from '@cloudflare/workers-types';
11
12
  import { BatchItem } from 'drizzle-orm/batch';
12
13
  import { DrizzleD1Database } from 'drizzle-orm/d1';
13
14
 
@@ -50,19 +51,12 @@ type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
50
51
 
51
52
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
52
53
 
53
- interface SstInstance {
54
- cloudflare: {
55
- [key: string]: any;
56
- };
57
- }
58
54
  declare class Infrastructure {
59
55
  private project;
60
56
  private environment;
61
- private sst;
62
- constructor({ project, environment, sst, }: {
57
+ constructor({ project, environment, }: {
63
58
  project: Project;
64
59
  environment: Environment;
65
- sst: SstInstance;
66
60
  });
67
61
  /**
68
62
  * Creates an instance of Cloudflare KV.
@@ -72,11 +66,7 @@ declare class Infrastructure {
72
66
  * Name of the KV. Do not include the 'kv' prefix.
73
67
  */
74
68
  resourceName: string;
75
- /**
76
- * Name of the KV's binding. If not set, it is generated automatically based on the provided name.
77
- */
78
- bindingName?: string;
79
- }): any;
69
+ }): Promise<KVNamespace>;
80
70
  /**
81
71
  * Creates an instance of Cloudflare D1.
82
72
  */
@@ -85,11 +75,7 @@ declare class Infrastructure {
85
75
  * Name of the D1. Do not include the 'd1' prefix.
86
76
  */
87
77
  resourceName: string;
88
- /**
89
- * Name of the D1's binding. If not set, it is generated automatically based on the provided name.
90
- */
91
- bindingName?: string;
92
- }): any;
78
+ }): Promise<D1Database>;
93
79
  /**
94
80
  * Creates an instance of Cloudflare Queue.
95
81
  */
@@ -98,10 +84,6 @@ declare class Infrastructure {
98
84
  * Name of the Queue. Do not include the 'queue' prefix.
99
85
  */
100
86
  resourceName: string;
101
- /**
102
- * Name of the Queue's binding. If not set, it is generated automatically based on the provided name.
103
- */
104
- bindingName?: string;
105
87
  /**
106
88
  * The number of seconds to delay delivery of messages to the queue.
107
89
  */
@@ -110,7 +92,7 @@ declare class Infrastructure {
110
92
  * The number of seconds a message will remain in the queue before being deleted.
111
93
  */
112
94
  messageRetentionPeriod?: number;
113
- }): any;
95
+ }): Promise<Queue<unknown>>;
114
96
  /**
115
97
  * Creates an instance of Cloudflare R2.
116
98
  */
@@ -119,15 +101,11 @@ declare class Infrastructure {
119
101
  * Name of the R2. Do not include the 'r2' prefix.
120
102
  */
121
103
  resourceName: string;
122
- /**
123
- * Name of the R2's binding. If not set, it is generated automatically based on the provided name.
124
- */
125
- bindingName?: string;
126
104
  /**
127
105
  * The storage class for the R2 bucket.
128
106
  */
129
107
  storageClass?: 'Standard' | 'InfrequentAccess';
130
- }): any;
108
+ }): Promise<R2Bucket>;
131
109
  }
132
110
 
133
111
  interface AuditLogPayload<T> {
@@ -244,8 +222,8 @@ interface DevelitWorkerMethods {
244
222
  logInput(data: object): void;
245
223
  logOutput(data: object): void;
246
224
  logError(error: object): void;
247
- pushToQueue<T>(queue: Queue, message: T | T[]): Promise<void>;
248
- recordAuditLogMessage<T>(queue: Queue, message: T | T[]): Promise<void>;
225
+ pushToQueue<T>(queue: Queue$1, message: T | T[]): Promise<void>;
226
+ recordAuditLogMessage<T>(queue: Queue$1, message: T | T[]): Promise<void>;
249
227
  handleInput<T extends z.$ZodType>(args: {
250
228
  input: z.infer<T>;
251
229
  schema: T;
@@ -329,7 +307,7 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
329
307
  */
330
308
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
331
309
 
332
- declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
310
+ declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): any;
333
311
  declare const getD1DatabaseIdFromWrangler: () => string | undefined;
334
312
  declare const getD1Credentials: () => {
335
313
  driver?: undefined;
@@ -337,14 +315,14 @@ declare const getD1Credentials: () => {
337
315
  } | {
338
316
  driver: string;
339
317
  dbCredentials: {
340
- accountId: string | undefined;
318
+ accountId: any;
341
319
  databaseId: string;
342
- token: string | undefined;
320
+ token: any;
343
321
  url?: undefined;
344
322
  };
345
323
  } | {
346
324
  dbCredentials: {
347
- url: string | undefined;
325
+ url: any;
348
326
  accountId?: undefined;
349
327
  databaseId?: undefined;
350
328
  token?: undefined;
@@ -360,9 +338,9 @@ declare const getDrizzleD1Config: () => {
360
338
  } | {
361
339
  driver: string;
362
340
  dbCredentials: {
363
- accountId: string | undefined;
341
+ accountId: any;
364
342
  databaseId: string;
365
- token: string | undefined;
343
+ token: any;
366
344
  url?: undefined;
367
345
  };
368
346
  schema: string;
@@ -370,7 +348,7 @@ declare const getDrizzleD1Config: () => {
370
348
  dialect: "sqlite";
371
349
  } | {
372
350
  dbCredentials: {
373
- url: string | undefined;
351
+ url: any;
374
352
  accountId?: undefined;
375
353
  databaseId?: undefined;
376
354
  token?: undefined;
@@ -428,7 +406,7 @@ declare const getPgLocalConnectionString: (id: string) => string;
428
406
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
429
407
  declare const getPgCredentials: (serviceName?: string) => {
430
408
  dbCredentials: {
431
- url: string;
409
+ url: any;
432
410
  };
433
411
  };
434
412
  declare const getDrizzlePgConfig: () => {
@@ -437,7 +415,7 @@ declare const getDrizzlePgConfig: () => {
437
415
  schema: string;
438
416
  };
439
417
  dbCredentials: {
440
- url: string;
418
+ url: any;
441
419
  };
442
420
  schema: string;
443
421
  out: string;
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { timestamp, uuid, pgEnum, text as text$1 } from 'drizzle-orm/pg-core';
3
3
  import { integer, text } from 'drizzle-orm/sqlite-core';
4
4
  import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
5
5
  import { toSnakeCase } from '@std/text';
6
+ import { KVNamespace, D1Database, Queue, R2Bucket } from 'alchemy/cloudflare';
6
7
  import * as z from 'zod/v4/core';
7
8
  import 'http-status-codes';
8
9
  import { createError } from 'h3';
@@ -59,12 +60,9 @@ const composeD1Arguments = ({
59
60
  resourceName
60
61
  }) => {
61
62
  return {
62
- transform: {
63
- database: {
64
- name: resourceName,
65
- primaryLocationHint: "weur"
66
- }
67
- }
63
+ name: resourceName,
64
+ primaryLocationHint: "weur"
65
+ // TODO: It's possible that it will take care of migrations as well
68
66
  };
69
67
  };
70
68
 
@@ -72,11 +70,7 @@ const composeKvArguments = ({
72
70
  resourceName
73
71
  }) => {
74
72
  return {
75
- transform: {
76
- namespace: {
77
- title: resourceName
78
- }
79
- }
73
+ title: resourceName
80
74
  };
81
75
  };
82
76
 
@@ -86,14 +80,10 @@ const composeQueueArguments = ({
86
80
  messageRetentionPeriod = 259200
87
81
  }) => {
88
82
  return {
89
- transform: {
90
- queue: {
91
- queueName: resourceName,
92
- settings: {
93
- deliveryDelay,
94
- messageRetentionPeriod
95
- }
96
- }
83
+ name: resourceName,
84
+ settings: {
85
+ deliveryDelay,
86
+ messageRetentionPeriod
97
87
  }
98
88
  };
99
89
  };
@@ -103,14 +93,10 @@ const composeR2Arguments = ({
103
93
  storageClass = "Standard"
104
94
  }) => {
105
95
  return {
106
- transform: {
107
- bucket: {
108
- name: resourceName,
109
- jurisdiction: "eu",
110
- location: "weur",
111
- storageClass
112
- }
113
- }
96
+ name: resourceName,
97
+ jurisdiction: "eu",
98
+ locationHint: "weur",
99
+ storageClass
114
100
  };
115
101
  };
116
102
 
@@ -122,6 +108,12 @@ const composeBindingName = ({
122
108
  const convertedBindingName = bindingName ? toSnakeCase(bindingName) : `${toSnakeCase(resourceName)}_${resource}`;
123
109
  return convertedBindingName.toUpperCase();
124
110
  };
111
+ const composeIdentifierName = ({
112
+ resource,
113
+ resourceName
114
+ }) => {
115
+ return `${resourceName}-${resource}`;
116
+ };
125
117
  const composeResourceName = ({
126
118
  project,
127
119
  environment,
@@ -133,23 +125,20 @@ const composeResourceName = ({
133
125
  class Infrastructure {
134
126
  project;
135
127
  environment;
136
- sst;
137
128
  constructor({
138
129
  project,
139
- environment,
140
- sst
130
+ environment
141
131
  }) {
142
132
  this.project = project;
143
133
  this.environment = environment;
144
- this.sst = sst;
145
134
  }
146
135
  /**
147
136
  * Creates an instance of Cloudflare KV.
148
137
  */
149
- kv(options) {
150
- const { resourceName, bindingName } = options;
151
- return new this.sst.cloudflare.Kv(
152
- `${composeBindingName({ resource: "kv", resourceName, bindingName })}`,
138
+ async kv(options) {
139
+ const { resourceName } = options;
140
+ return await KVNamespace(
141
+ composeIdentifierName({ resourceName, resource: "kv" }),
153
142
  composeKvArguments({
154
143
  resourceName: composeResourceName({
155
144
  project: this.project,
@@ -162,10 +151,10 @@ class Infrastructure {
162
151
  /**
163
152
  * Creates an instance of Cloudflare D1.
164
153
  */
165
- d1(options) {
166
- const { resourceName, bindingName } = options;
167
- return new this.sst.cloudflare.D1(
168
- `${composeBindingName({ resource: "d1", resourceName, bindingName })}`,
154
+ async d1(options) {
155
+ const { resourceName } = options;
156
+ return await D1Database(
157
+ composeIdentifierName({ resourceName, resource: "d1" }),
169
158
  composeD1Arguments({
170
159
  resourceName: composeResourceName({
171
160
  project: this.project,
@@ -178,10 +167,10 @@ class Infrastructure {
178
167
  /**
179
168
  * Creates an instance of Cloudflare Queue.
180
169
  */
181
- queue(options) {
182
- const { resourceName, bindingName, deliveryDelay, messageRetentionPeriod } = options;
183
- return new this.sst.cloudflare.Queue(
184
- `${composeBindingName({ resource: "queue", resourceName, bindingName })}`,
170
+ async queue(options) {
171
+ const { resourceName, deliveryDelay, messageRetentionPeriod } = options;
172
+ return await Queue(
173
+ composeIdentifierName({ resourceName, resource: "queue" }),
185
174
  composeQueueArguments({
186
175
  resourceName: composeResourceName({
187
176
  project: this.project,
@@ -196,10 +185,10 @@ class Infrastructure {
196
185
  /**
197
186
  * Creates an instance of Cloudflare R2.
198
187
  */
199
- r2(options) {
200
- const { resourceName, bindingName, storageClass } = options;
201
- return new this.sst.cloudflare.Bucket(
202
- `${composeBindingName({ resource: "r2", resourceName, bindingName })}`,
188
+ async r2(options) {
189
+ const { resourceName, storageClass } = options;
190
+ return await R2Bucket(
191
+ composeIdentifierName({ resourceName, resource: "r2" }),
203
192
  composeR2Arguments({
204
193
  resourceName: composeResourceName({
205
194
  project: this.project,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "5.21.0",
3
+ "version": "5.21.2",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@cloudflare/workers-types": "4.20250923.0",
37
- "@pulumi/cloudflare": "^6.9.1",
38
37
  "@std/path": "npm:@jsr/std__path",
39
38
  "@std/text": "npm:@jsr/std__text",
39
+ "alchemy": "^0.69.0",
40
40
  "comment-json": "^4.2.5",
41
41
  "drizzle-kit": "^0.31.4",
42
42
  "drizzle-orm": "^0.44.5",