@develit-io/backend-sdk 5.15.2 → 5.16.1

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
@@ -3,17 +3,14 @@
3
3
  const drizzleOrm = require('drizzle-orm');
4
4
  const pgCore = require('drizzle-orm/pg-core');
5
5
  const sqliteCore = require('drizzle-orm/sqlite-core');
6
- const commentJson = require('comment-json');
7
- const node_fs = require('node:fs');
8
- const path = require('@std/path');
9
6
  const text = require('@std/text');
10
7
  require('http-status-codes');
11
8
  const z = require('zod/v4/core');
12
9
  const h3 = require('h3');
13
- const consola = require('consola');
14
10
  const fs = require('fs');
15
11
  const crypto$1 = require('node:crypto');
16
- const path$1 = require('path');
12
+ const path = require('path');
13
+ const commentJson = require('comment-json');
17
14
  const superjson = require('superjson');
18
15
 
19
16
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -33,7 +30,7 @@ function _interopNamespaceCompat(e) {
33
30
  const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
34
31
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
35
32
  const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto$1);
36
- const path__default = /*#__PURE__*/_interopDefaultCompat(path$1);
33
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
37
34
  const superjson__default = /*#__PURE__*/_interopDefaultCompat(superjson);
38
35
 
39
36
  const base = {
@@ -54,84 +51,23 @@ const basePostgres = {
54
51
  }).default(drizzleOrm.sql`null`)
55
52
  };
56
53
 
57
- const composeD1Arguments = ({
58
- resourceName
59
- }) => {
60
- return {
61
- transform: {
62
- database: {
63
- name: resourceName,
64
- primaryLocationHint: "weur"
65
- }
66
- }
67
- };
68
- };
69
-
70
- const composeKvArguments = ({
71
- resourceName
72
- }) => {
73
- return {
74
- transform: {
75
- namespace: {
76
- title: resourceName
77
- }
78
- }
79
- };
80
- };
81
-
82
- const composeQueueArguments = ({
83
- resourceName,
84
- deliveryDelay = 5,
85
- messageRetentionPeriod = 259200
86
- }) => {
87
- return {
88
- transform: {
89
- queue: {
90
- queueName: resourceName,
91
- settings: {
92
- deliveryDelay,
93
- messageRetentionPeriod
94
- }
95
- }
96
- }
97
- };
98
- };
99
-
100
- const composeR2Arguments = ({
101
- resourceName,
102
- storageClass = "Standard"
103
- }) => {
104
- return {
105
- transform: {
106
- bucket: {
107
- name: resourceName,
108
- jurisdiction: "eu",
109
- location: "weur",
110
- storageClass
111
- }
112
- }
113
- };
114
- };
115
-
116
- async function loadWorkerConfig({ path: path$1 }) {
117
- const workerConfigFile = node_fs.readFileSync(path.join(path$1, "./wrangler.jsonc"), "utf-8");
118
- return commentJson.parse(workerConfigFile);
119
- }
120
-
121
- const composeBindingName = ({
122
- resource,
123
- resourceName,
124
- bindingName
125
- }) => {
126
- const convertedBindingName = bindingName ? text.toSnakeCase(bindingName) : `${text.toSnakeCase(resourceName)}_${resource}`;
127
- return convertedBindingName.toUpperCase();
54
+ const bankAccount = {
55
+ holderName: sqliteCore.text("holder_name").notNull(),
56
+ number: sqliteCore.text("number").notNull(),
57
+ bankCode: sqliteCore.text("bank_code").$type().notNull(),
58
+ iban: sqliteCore.text("iban").notNull(),
59
+ bic: sqliteCore.text("bic").notNull(),
60
+ currency: sqliteCore.text("currency").$type(),
61
+ countryCode: sqliteCore.text("country_code").notNull()
128
62
  };
129
- const composeResourceName = ({
130
- project,
131
- environment,
132
- resourceName
133
- }) => {
134
- return `${project}-${resourceName}-${environment}`;
63
+ const bankAccountPostgres = {
64
+ holderName: pgCore.text("holder_name").notNull(),
65
+ number: pgCore.text("number").notNull(),
66
+ bankCode: pgCore.text("bank_code").$type().notNull(),
67
+ iban: pgCore.text("iban").notNull(),
68
+ bic: pgCore.text("bic").notNull(),
69
+ currency: pgCore.text("currency").$type(),
70
+ countryCode: pgCore.text("country_code").notNull()
135
71
  };
136
72
 
137
73
  class Infrastructure {
@@ -147,19 +83,158 @@ class Infrastructure {
147
83
  this.environment = environment;
148
84
  this.sst = sst;
149
85
  }
86
+ // TODO(Pookensivee): Make tests for this util
87
+ composeBindingName({
88
+ resource,
89
+ resourceName,
90
+ bindingName
91
+ }) {
92
+ const convertedBindingName = bindingName ? text.toSnakeCase(bindingName) : `${text.toSnakeCase(resourceName)}_${resource}`;
93
+ return convertedBindingName.toUpperCase();
94
+ }
95
+ // TODO(Pookensivee): Make tests for this util
96
+ composeResourceName({ resourceName }) {
97
+ return `${this.project}-${resourceName}-${this.environment}`;
98
+ }
99
+ // TODO(Pookensivee): Make tests for this util
100
+ composeKvArguments({ resourceName }) {
101
+ return {
102
+ transform: {
103
+ namespace: {
104
+ title: resourceName
105
+ }
106
+ }
107
+ };
108
+ }
109
+ // TODO(Pookensivee): Make tests for this util
110
+ composeD1Arguments({ resourceName }) {
111
+ return {
112
+ transform: {
113
+ database: {
114
+ name: resourceName,
115
+ primaryLocationHint: "weur"
116
+ }
117
+ }
118
+ };
119
+ }
120
+ // TODO(Pookensivee): Make tests for this util
121
+ composeQueueArguments({
122
+ resourceName,
123
+ deliveryDelay = 5,
124
+ messageRetentionPeriod = 259200
125
+ }) {
126
+ return {
127
+ transform: {
128
+ queue: {
129
+ queueName: resourceName,
130
+ settings: {
131
+ deliveryDelay,
132
+ messageRetentionPeriod
133
+ }
134
+ }
135
+ }
136
+ };
137
+ }
138
+ // TODO(Pookensivee): Make tests for this util
139
+ composeR2Arguments({
140
+ resourceName,
141
+ storageClass = "Standard"
142
+ }) {
143
+ return {
144
+ transform: {
145
+ bucket: {
146
+ name: resourceName,
147
+ jurisdiction: "eu",
148
+ location: "weur",
149
+ storageClass
150
+ }
151
+ }
152
+ };
153
+ }
154
+ // TODO: Solve the circular dependency on post infrastructure deploy script
155
+ // TODO: Cannot assign a queue as a producer, work around: https://developers.cloudflare.com/workers/wrangler/commands/#queues-consumer-add-script-name
156
+ // async composeWorkerArguments({
157
+ // resourceName,
158
+ // path,
159
+ // bindings = [],
160
+ // }: {
161
+ // resourceName: string
162
+ // path: string
163
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
164
+ // }) {
165
+ // const workerConfig = this.loadWorkerConfig({ path })
166
+ // const environmentVariables = this.extractEnvironmentVariables({ workerConfigEnv:
167
+ // workerConfig.env as WorkerConfigEnv
168
+ // })
169
+ // // TODO: Fix this
170
+ // if (
171
+ // 'SERVICE_CONFIG' in environmentVariables &&
172
+ // typeof environmentVariables.SERVICE_CONFIG === 'object'
173
+ // ) {
174
+ // environmentVariables.SERVICE_CONFIG = JSON.stringify(environmentVariables.SERVICE_CONFIG)
175
+ // }
176
+ // // TODO: Fix this
177
+ // if (
178
+ // 'EMAIL_SENDER' in environmentVariables &&
179
+ // typeof environmentVariables.EMAIL_SENDER === 'object'
180
+ // ) {
181
+ // environmentVariables.EMAIL_SENDER = JSON.stringify(environmentVariables.EMAIL_SENDER)
182
+ // }
183
+ // return {
184
+ // handler: join(path, './src/index.ts'),
185
+ // environment: Object.entries(environmentVariables).reduce((acc, [key, value]) => ({
186
+ // ...acc,
187
+ // [key]: String(value)
188
+ // }), {} as Record<string, string>),
189
+ // link: bindings,
190
+ // transform: {
191
+ // worker: {
192
+ // scriptName: this.composeResourceName({ resourceName }),
193
+ // compatibilityDate: '2025-06-04',
194
+ // compatibilityFlags: ['nodejs_compat'],
195
+ // observability: {
196
+ // enabled: true,
197
+ // headSamplingRate: 1,
198
+ // logs: {
199
+ // // Check whether this disables logs completely or just invocation ones
200
+ // enabled: false,
201
+ // invocationLogs: false,
202
+ // },
203
+ // },
204
+ // },
205
+ // }
206
+ // } satisfies Partial<WorkerArgs>
207
+ // }
208
+ // loadWorkerConfig({ path }: { path: string }) {
209
+ // const workerConfigFile = readFileSync(
210
+ // join(path, './wrangler.jsonc'),
211
+ // 'utf-8',
212
+ // )
213
+ // TODO: Use parse from comment-json
214
+ // const jsonString = workerConfigFile
215
+ // .replace(/\/\*[\s\S]*?\*\//g, '')
216
+ // .replace(/\/\/.*$/gm, '')
217
+ // return JSON.parse(jsonString)
218
+ // }
219
+ // extractEnvironmentVariables({
220
+ // workerConfigEnv,
221
+ // }: {
222
+ // workerConfigEnv: WorkerConfigEnv
223
+ // }) {
224
+ // if (typeof this.environment === 'number') {
225
+ // return { ...workerConfigEnv.dev.vars, ENVIRONMENT: this.environment }
226
+ // }
227
+ // return { ...workerConfigEnv[this.environment].vars }
228
+ // }
150
229
  /**
151
230
  * Creates an instance of Cloudflare KV.
152
231
  */
153
232
  kv(options) {
154
233
  const { resourceName, bindingName } = options;
155
234
  return new this.sst.cloudflare.Kv(
156
- `${composeBindingName({ resource: "kv", resourceName, bindingName })}`,
157
- composeKvArguments({
158
- resourceName: composeResourceName({
159
- project: this.project,
160
- environment: this.environment,
161
- resourceName
162
- })
235
+ `${this.composeBindingName({ resource: "kv", resourceName, bindingName })}`,
236
+ this.composeKvArguments({
237
+ resourceName: this.composeResourceName({ resourceName })
163
238
  })
164
239
  );
165
240
  }
@@ -169,13 +244,9 @@ class Infrastructure {
169
244
  d1(options) {
170
245
  const { resourceName, bindingName } = options;
171
246
  return new this.sst.cloudflare.D1(
172
- `${composeBindingName({ resource: "d1", resourceName, bindingName })}`,
173
- composeD1Arguments({
174
- resourceName: composeResourceName({
175
- project: this.project,
176
- environment: this.environment,
177
- resourceName
178
- })
247
+ `${this.composeBindingName({ resource: "d1", resourceName, bindingName })}`,
248
+ this.composeD1Arguments({
249
+ resourceName: this.composeResourceName({ resourceName })
179
250
  })
180
251
  );
181
252
  }
@@ -185,13 +256,9 @@ class Infrastructure {
185
256
  queue(options) {
186
257
  const { resourceName, bindingName, deliveryDelay, messageRetentionPeriod } = options;
187
258
  return new this.sst.cloudflare.Queue(
188
- `${composeBindingName({ resource: "queue", resourceName, bindingName })}`,
189
- composeQueueArguments({
190
- resourceName: composeResourceName({
191
- project: this.project,
192
- environment: this.environment,
193
- resourceName
194
- }),
259
+ `${this.composeBindingName({ resource: "queue", resourceName, bindingName })}`,
260
+ this.composeQueueArguments({
261
+ resourceName: this.composeResourceName({ resourceName }),
195
262
  deliveryDelay,
196
263
  messageRetentionPeriod
197
264
  })
@@ -203,28 +270,77 @@ class Infrastructure {
203
270
  r2(options) {
204
271
  const { resourceName, bindingName, storageClass } = options;
205
272
  return new this.sst.cloudflare.Bucket(
206
- `${composeBindingName({ resource: "r2", resourceName, bindingName })}`,
207
- composeR2Arguments({
208
- resourceName: composeResourceName({
209
- project: this.project,
210
- environment: this.environment,
211
- resourceName
212
- }),
273
+ `${this.composeBindingName({ resource: "r2", resourceName, bindingName })}`,
274
+ this.composeR2Arguments({
275
+ resourceName: this.composeResourceName({ resourceName }),
213
276
  storageClass
214
277
  })
215
278
  );
216
279
  }
280
+ // TODO: Solve the circular dependency on post infrastructure deploy script
281
+ // async worker({
282
+ // resourceName,
283
+ // bindingName,
284
+ // path,
285
+ // bindings = [],
286
+ // }: {
287
+ // resourceName: string
288
+ // bindingName: string
289
+ // path: string
290
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
291
+ // }) {
292
+ // return new sst.cloudflare.Worker(
293
+ // this.composeBindingName({
294
+ // resource: 'worker',
295
+ // bindingName,
296
+ // resourceName,
297
+ // }),
298
+ // await this.composeWorkerArguments({
299
+ // resourceName: this.composeResourceName({ resourceName }),
300
+ // path,
301
+ // bindings,
302
+ // }),
303
+ // )
304
+ // }
305
+ // async service({
306
+ // resourceName,
307
+ // bindingName,
308
+ // path,
309
+ // bindings = [],
310
+ // }: {
311
+ // resourceName: string
312
+ // bindingName?: string
313
+ // path?: string
314
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
315
+ // }) {
316
+ // return this.worker({
317
+ // resourceName: `${this.project}-${resourceName}-service-${this.environment}`,
318
+ // bindingName: this.composeBindingName({
319
+ // resource: 'service',
320
+ // bindingName,
321
+ // resourceName,
322
+ // }),
323
+ // path: `${path ?? `./services/${resourceName}`}`,
324
+ // bindings,
325
+ // })
326
+ // }
327
+ // // TODO: Add name
328
+ // async orchestrator({
329
+ // path,
330
+ // bindings = [],
331
+ // }: {
332
+ // path?: string
333
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
334
+ // }) {
335
+ // return this.worker({
336
+ // resourceName: `${this.project}-gateway-${this.environment}`,
337
+ // bindingName: 'GATEWAY',
338
+ // path: `${path ?? `./apps/gateway`}`,
339
+ // bindings,
340
+ // })
341
+ // }
217
342
  }
218
343
 
219
- const ENVIRONMENT = ["dev", "test", "staging", "production"];
220
-
221
- const validateEnvironment = (environment) => {
222
- if (ENVIRONMENT.includes(environment)) {
223
- return environment;
224
- }
225
- return Number(environment);
226
- };
227
-
228
344
  const ibanZodSchema = new z__namespace.$ZodString({
229
345
  type: "string",
230
346
  checks: [
@@ -398,7 +514,7 @@ const RPCResponse = {
398
514
  * @returns An `IRPCResponse<T>` with `null` data and the provided error.
399
515
  */
400
516
  serviceError(error) {
401
- consola.consola.error(error.message);
517
+ console.error(error.message);
402
518
  return {
403
519
  status: error.status,
404
520
  message: error.message,
@@ -853,15 +969,15 @@ function develitWorker(Worker) {
853
969
  }
854
970
 
855
971
  exports.DatabaseTransaction = DatabaseTransaction;
856
- exports.ENVIRONMENT = ENVIRONMENT;
857
972
  exports.Infrastructure = Infrastructure;
858
973
  exports.RPCResponse = RPCResponse;
859
974
  exports.action = action;
975
+ exports.bankAccount = bankAccount;
976
+ exports.bankAccountPostgres = bankAccountPostgres;
860
977
  exports.base = base;
861
978
  exports.basePostgres = basePostgres;
862
979
  exports.calculateExponentialBackoff = calculateExponentialBackoff;
863
980
  exports.cloudflareQueue = cloudflareQueue;
864
- exports.composeBindingName = composeBindingName;
865
981
  exports.createAuditLogWriter = createAuditLogWriter;
866
982
  exports.createInternalError = createInternalError;
867
983
  exports.defineCommand = defineCommand;
@@ -881,7 +997,6 @@ exports.handleAction = handleAction;
881
997
  exports.handleActionResponse = handleActionResponse;
882
998
  exports.ibanZodSchema = ibanZodSchema;
883
999
  exports.isInternalError = isInternalError;
884
- exports.loadWorkerConfig = loadWorkerConfig;
885
1000
  exports.paginationQuerySchema = paginationQuerySchema;
886
1001
  exports.paginationSchema = paginationSchema;
887
1002
  exports.service = service;
@@ -889,4 +1004,3 @@ exports.swiftZodSchema = swiftZodSchema;
889
1004
  exports.useResult = useResult;
890
1005
  exports.useResultSync = useResultSync;
891
1006
  exports.uuidv4 = uuidv4;
892
- exports.validateEnvironment = validateEnvironment;
package/dist/index.d.cts CHANGED
@@ -4,7 +4,6 @@ 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 * as comment_json from 'comment-json';
8
7
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
8
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
9
  import * as z from 'zod/v4/core';
@@ -25,8 +24,29 @@ declare const basePostgres: {
25
24
  deletedAt: drizzle_orm.HasDefault<drizzle_orm_pg_core.PgTimestampBuilderInitial<"deleted_at">>;
26
25
  };
27
26
 
27
+ declare const bankAccount: {
28
+ holderName: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"holder_name", [string, ...string[]], number | undefined>>;
29
+ number: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"number", [string, ...string[]], number | undefined>>;
30
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bank_code", [string, ...string[]], number | undefined>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
31
+ iban: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"iban", [string, ...string[]], number | undefined>>;
32
+ bic: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic", [string, ...string[]], number | undefined>>;
33
+ currency: drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", [string, ...string[]], number | undefined>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
34
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", [string, ...string[]], number | undefined>>;
35
+ };
36
+ declare const bankAccountPostgres: {
37
+ holderName: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"holder_name", [string, ...string[]]>>;
38
+ number: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"number", [string, ...string[]]>>;
39
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"bank_code", [string, ...string[]]>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
40
+ iban: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"iban", [string, ...string[]]>>;
41
+ bic: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"bic", [string, ...string[]]>>;
42
+ currency: drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"currency", [string, ...string[]]>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
43
+ countryCode: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"country_code", [string, ...string[]]>>;
44
+ };
45
+
28
46
  type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
29
47
 
48
+ type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
49
+
30
50
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
31
51
 
32
52
  interface SstInstance {
@@ -43,6 +63,61 @@ declare class Infrastructure {
43
63
  environment: Environment;
44
64
  sst: SstInstance;
45
65
  });
66
+ composeBindingName({ resource, resourceName, bindingName, }: {
67
+ resource: Resource;
68
+ resourceName: string;
69
+ bindingName?: string;
70
+ }): string;
71
+ composeResourceName({ resourceName }: {
72
+ resourceName: string;
73
+ }): string;
74
+ composeKvArguments({ resourceName }: {
75
+ resourceName: string;
76
+ }): {
77
+ transform: {
78
+ namespace: {
79
+ title: string;
80
+ };
81
+ };
82
+ };
83
+ composeD1Arguments({ resourceName }: {
84
+ resourceName: string;
85
+ }): {
86
+ transform: {
87
+ database: {
88
+ name: string;
89
+ primaryLocationHint: string;
90
+ };
91
+ };
92
+ };
93
+ composeQueueArguments({ resourceName, deliveryDelay, messageRetentionPeriod, }: {
94
+ resourceName: string;
95
+ deliveryDelay?: number;
96
+ messageRetentionPeriod?: number;
97
+ }): {
98
+ transform: {
99
+ queue: {
100
+ queueName: string;
101
+ settings: {
102
+ deliveryDelay: number;
103
+ messageRetentionPeriod: number;
104
+ };
105
+ };
106
+ };
107
+ };
108
+ composeR2Arguments({ resourceName, storageClass, }: {
109
+ resourceName: string;
110
+ storageClass?: 'Standard' | 'InfrequentAccess';
111
+ }): {
112
+ transform: {
113
+ bucket: {
114
+ name: string;
115
+ jurisdiction: string;
116
+ location: string;
117
+ storageClass: "Standard" | "InfrequentAccess";
118
+ };
119
+ };
120
+ };
46
121
  /**
47
122
  * Creates an instance of Cloudflare KV.
48
123
  */
@@ -109,12 +184,6 @@ declare class Infrastructure {
109
184
  }): any;
110
185
  }
111
186
 
112
- declare function loadWorkerConfig({ path }: {
113
- path: string;
114
- }): Promise<comment_json.CommentJSONValue>;
115
-
116
- type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
117
-
118
187
  type InternalErrorResponseStatus = Exclude<StatusCodes, 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207>;
119
188
  interface InternalError {
120
189
  status: InternalErrorResponseStatus;
@@ -177,16 +246,6 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
177
246
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
178
247
  }>>, z.$ZodObjectConfig>;
179
248
 
180
- declare const composeBindingName: ({ resource, resourceName, bindingName, }: {
181
- resource: Resource;
182
- resourceName: string;
183
- bindingName?: string;
184
- }) => string;
185
-
186
- declare const validateEnvironment: (environment: string) => Environment;
187
-
188
- declare const ENVIRONMENT: string[];
189
-
190
249
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
191
250
  error: boolean;
192
251
  status: number;
@@ -507,5 +566,5 @@ interface WithRetryCounterOptions {
507
566
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
508
567
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
509
568
 
510
- export { DatabaseTransaction, ENVIRONMENT, Infrastructure, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, composeBindingName, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, loadWorkerConfig, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4, validateEnvironment };
569
+ export { DatabaseTransaction, Infrastructure, RPCResponse, action, bankAccount, bankAccountPostgres, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
511
570
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, ValidatedInput };
package/dist/index.d.mts CHANGED
@@ -4,7 +4,6 @@ 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 * as comment_json from 'comment-json';
8
7
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
8
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
9
  import * as z from 'zod/v4/core';
@@ -25,8 +24,29 @@ declare const basePostgres: {
25
24
  deletedAt: drizzle_orm.HasDefault<drizzle_orm_pg_core.PgTimestampBuilderInitial<"deleted_at">>;
26
25
  };
27
26
 
27
+ declare const bankAccount: {
28
+ holderName: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"holder_name", [string, ...string[]], number | undefined>>;
29
+ number: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"number", [string, ...string[]], number | undefined>>;
30
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bank_code", [string, ...string[]], number | undefined>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
31
+ iban: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"iban", [string, ...string[]], number | undefined>>;
32
+ bic: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic", [string, ...string[]], number | undefined>>;
33
+ currency: drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", [string, ...string[]], number | undefined>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
34
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", [string, ...string[]], number | undefined>>;
35
+ };
36
+ declare const bankAccountPostgres: {
37
+ holderName: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"holder_name", [string, ...string[]]>>;
38
+ number: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"number", [string, ...string[]]>>;
39
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"bank_code", [string, ...string[]]>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
40
+ iban: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"iban", [string, ...string[]]>>;
41
+ bic: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"bic", [string, ...string[]]>>;
42
+ currency: drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"currency", [string, ...string[]]>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
43
+ countryCode: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"country_code", [string, ...string[]]>>;
44
+ };
45
+
28
46
  type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
29
47
 
48
+ type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
49
+
30
50
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
31
51
 
32
52
  interface SstInstance {
@@ -43,6 +63,61 @@ declare class Infrastructure {
43
63
  environment: Environment;
44
64
  sst: SstInstance;
45
65
  });
66
+ composeBindingName({ resource, resourceName, bindingName, }: {
67
+ resource: Resource;
68
+ resourceName: string;
69
+ bindingName?: string;
70
+ }): string;
71
+ composeResourceName({ resourceName }: {
72
+ resourceName: string;
73
+ }): string;
74
+ composeKvArguments({ resourceName }: {
75
+ resourceName: string;
76
+ }): {
77
+ transform: {
78
+ namespace: {
79
+ title: string;
80
+ };
81
+ };
82
+ };
83
+ composeD1Arguments({ resourceName }: {
84
+ resourceName: string;
85
+ }): {
86
+ transform: {
87
+ database: {
88
+ name: string;
89
+ primaryLocationHint: string;
90
+ };
91
+ };
92
+ };
93
+ composeQueueArguments({ resourceName, deliveryDelay, messageRetentionPeriod, }: {
94
+ resourceName: string;
95
+ deliveryDelay?: number;
96
+ messageRetentionPeriod?: number;
97
+ }): {
98
+ transform: {
99
+ queue: {
100
+ queueName: string;
101
+ settings: {
102
+ deliveryDelay: number;
103
+ messageRetentionPeriod: number;
104
+ };
105
+ };
106
+ };
107
+ };
108
+ composeR2Arguments({ resourceName, storageClass, }: {
109
+ resourceName: string;
110
+ storageClass?: 'Standard' | 'InfrequentAccess';
111
+ }): {
112
+ transform: {
113
+ bucket: {
114
+ name: string;
115
+ jurisdiction: string;
116
+ location: string;
117
+ storageClass: "Standard" | "InfrequentAccess";
118
+ };
119
+ };
120
+ };
46
121
  /**
47
122
  * Creates an instance of Cloudflare KV.
48
123
  */
@@ -109,12 +184,6 @@ declare class Infrastructure {
109
184
  }): any;
110
185
  }
111
186
 
112
- declare function loadWorkerConfig({ path }: {
113
- path: string;
114
- }): Promise<comment_json.CommentJSONValue>;
115
-
116
- type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
117
-
118
187
  type InternalErrorResponseStatus = Exclude<StatusCodes, 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207>;
119
188
  interface InternalError {
120
189
  status: InternalErrorResponseStatus;
@@ -177,16 +246,6 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
177
246
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
178
247
  }>>, z.$ZodObjectConfig>;
179
248
 
180
- declare const composeBindingName: ({ resource, resourceName, bindingName, }: {
181
- resource: Resource;
182
- resourceName: string;
183
- bindingName?: string;
184
- }) => string;
185
-
186
- declare const validateEnvironment: (environment: string) => Environment;
187
-
188
- declare const ENVIRONMENT: string[];
189
-
190
249
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
191
250
  error: boolean;
192
251
  status: number;
@@ -507,5 +566,5 @@ interface WithRetryCounterOptions {
507
566
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
508
567
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
509
568
 
510
- export { DatabaseTransaction, ENVIRONMENT, Infrastructure, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, composeBindingName, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, loadWorkerConfig, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4, validateEnvironment };
569
+ export { DatabaseTransaction, Infrastructure, RPCResponse, action, bankAccount, bankAccountPostgres, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
511
570
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, ValidatedInput };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ 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 * as comment_json from 'comment-json';
8
7
  import { StatusCodes, ReasonPhrases } from 'http-status-codes';
9
8
  export { ReasonPhrases as InternalResponsePhrase, StatusCodes as InternalResponseStatus } from 'http-status-codes';
10
9
  import * as z from 'zod/v4/core';
@@ -25,8 +24,29 @@ declare const basePostgres: {
25
24
  deletedAt: drizzle_orm.HasDefault<drizzle_orm_pg_core.PgTimestampBuilderInitial<"deleted_at">>;
26
25
  };
27
26
 
27
+ declare const bankAccount: {
28
+ holderName: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"holder_name", [string, ...string[]], number | undefined>>;
29
+ number: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"number", [string, ...string[]], number | undefined>>;
30
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bank_code", [string, ...string[]], number | undefined>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
31
+ iban: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"iban", [string, ...string[]], number | undefined>>;
32
+ bic: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic", [string, ...string[]], number | undefined>>;
33
+ currency: drizzle_orm.$Type<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", [string, ...string[]], number | undefined>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
34
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", [string, ...string[]], number | undefined>>;
35
+ };
36
+ declare const bankAccountPostgres: {
37
+ holderName: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"holder_name", [string, ...string[]]>>;
38
+ number: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"number", [string, ...string[]]>>;
39
+ bankCode: drizzle_orm.NotNull<drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"bank_code", [string, ...string[]]>, "0100" | "0300" | "0600" | "0710" | "0800" | "2010" | "2060" | "2070" | "2100" | "2200" | "2220" | "2250" | "2260" | "2600" | "2700" | "3030" | "3060" | "3500" | "4300" | "5500" | "5800" | "6000" | "6200" | "6210" | "6300" | "6363" | "6700" | "6800" | "7910" | "7950" | "7960" | "7970" | "7990" | "8030" | "8040" | "8060" | "8090" | "8150" | "8190" | "8198" | "8220" | "8250" | "8255" | "8265" | "8500">>;
40
+ iban: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"iban", [string, ...string[]]>>;
41
+ bic: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"bic", [string, ...string[]]>>;
42
+ currency: drizzle_orm.$Type<drizzle_orm_pg_core.PgTextBuilderInitial<"currency", [string, ...string[]]>, "CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX">;
43
+ countryCode: drizzle_orm.NotNull<drizzle_orm_pg_core.PgTextBuilderInitial<"country_code", [string, ...string[]]>>;
44
+ };
45
+
28
46
  type Project = 'creditio' | 'fp' | 'mdm' | 'moneio' | 'txs';
29
47
 
48
+ type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
49
+
30
50
  type Environment = number | 'dev' | 'test' | 'staging' | 'production';
31
51
 
32
52
  interface SstInstance {
@@ -43,6 +63,61 @@ declare class Infrastructure {
43
63
  environment: Environment;
44
64
  sst: SstInstance;
45
65
  });
66
+ composeBindingName({ resource, resourceName, bindingName, }: {
67
+ resource: Resource;
68
+ resourceName: string;
69
+ bindingName?: string;
70
+ }): string;
71
+ composeResourceName({ resourceName }: {
72
+ resourceName: string;
73
+ }): string;
74
+ composeKvArguments({ resourceName }: {
75
+ resourceName: string;
76
+ }): {
77
+ transform: {
78
+ namespace: {
79
+ title: string;
80
+ };
81
+ };
82
+ };
83
+ composeD1Arguments({ resourceName }: {
84
+ resourceName: string;
85
+ }): {
86
+ transform: {
87
+ database: {
88
+ name: string;
89
+ primaryLocationHint: string;
90
+ };
91
+ };
92
+ };
93
+ composeQueueArguments({ resourceName, deliveryDelay, messageRetentionPeriod, }: {
94
+ resourceName: string;
95
+ deliveryDelay?: number;
96
+ messageRetentionPeriod?: number;
97
+ }): {
98
+ transform: {
99
+ queue: {
100
+ queueName: string;
101
+ settings: {
102
+ deliveryDelay: number;
103
+ messageRetentionPeriod: number;
104
+ };
105
+ };
106
+ };
107
+ };
108
+ composeR2Arguments({ resourceName, storageClass, }: {
109
+ resourceName: string;
110
+ storageClass?: 'Standard' | 'InfrequentAccess';
111
+ }): {
112
+ transform: {
113
+ bucket: {
114
+ name: string;
115
+ jurisdiction: string;
116
+ location: string;
117
+ storageClass: "Standard" | "InfrequentAccess";
118
+ };
119
+ };
120
+ };
46
121
  /**
47
122
  * Creates an instance of Cloudflare KV.
48
123
  */
@@ -109,12 +184,6 @@ declare class Infrastructure {
109
184
  }): any;
110
185
  }
111
186
 
112
- declare function loadWorkerConfig({ path }: {
113
- path: string;
114
- }): Promise<comment_json.CommentJSONValue>;
115
-
116
- type Resource = 'kv' | 'd1' | 'queue' | 'r2' | 'worker' | 'service' | 'orchestrator';
117
-
118
187
  type InternalErrorResponseStatus = Exclude<StatusCodes, 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207>;
119
188
  interface InternalError {
120
189
  status: InternalErrorResponseStatus;
@@ -177,16 +246,6 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
177
246
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
178
247
  }>>, z.$ZodObjectConfig>;
179
248
 
180
- declare const composeBindingName: ({ resource, resourceName, bindingName, }: {
181
- resource: Resource;
182
- resourceName: string;
183
- bindingName?: string;
184
- }) => string;
185
-
186
- declare const validateEnvironment: (environment: string) => Environment;
187
-
188
- declare const ENVIRONMENT: string[];
189
-
190
249
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
191
250
  error: boolean;
192
251
  status: number;
@@ -507,5 +566,5 @@ interface WithRetryCounterOptions {
507
566
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
508
567
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
509
568
 
510
- export { DatabaseTransaction, ENVIRONMENT, Infrastructure, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, composeBindingName, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, loadWorkerConfig, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4, validateEnvironment };
569
+ export { DatabaseTransaction, Infrastructure, RPCResponse, action, bankAccount, bankAccountPostgres, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
511
570
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, ValidatedInput };
package/dist/index.mjs CHANGED
@@ -1,17 +1,14 @@
1
1
  import { sql } from 'drizzle-orm';
2
- import { timestamp, uuid } from 'drizzle-orm/pg-core';
2
+ import { timestamp, uuid, text as text$1 } from 'drizzle-orm/pg-core';
3
3
  import { integer, text } from 'drizzle-orm/sqlite-core';
4
- import { parse } from 'comment-json';
5
- import { readFileSync } from 'node:fs';
6
- import { join } from '@std/path';
7
4
  import { toSnakeCase } from '@std/text';
8
5
  import 'http-status-codes';
9
6
  import * as z from 'zod/v4/core';
10
7
  import { createError } from 'h3';
11
- import { consola } from 'consola';
12
8
  import fs from 'fs';
13
9
  import crypto$1 from 'node:crypto';
14
10
  import path from 'path';
11
+ import { parse } from 'comment-json';
15
12
  import superjson from 'superjson';
16
13
 
17
14
  const base = {
@@ -32,84 +29,23 @@ const basePostgres = {
32
29
  }).default(sql`null`)
33
30
  };
34
31
 
35
- const composeD1Arguments = ({
36
- resourceName
37
- }) => {
38
- return {
39
- transform: {
40
- database: {
41
- name: resourceName,
42
- primaryLocationHint: "weur"
43
- }
44
- }
45
- };
46
- };
47
-
48
- const composeKvArguments = ({
49
- resourceName
50
- }) => {
51
- return {
52
- transform: {
53
- namespace: {
54
- title: resourceName
55
- }
56
- }
57
- };
58
- };
59
-
60
- const composeQueueArguments = ({
61
- resourceName,
62
- deliveryDelay = 5,
63
- messageRetentionPeriod = 259200
64
- }) => {
65
- return {
66
- transform: {
67
- queue: {
68
- queueName: resourceName,
69
- settings: {
70
- deliveryDelay,
71
- messageRetentionPeriod
72
- }
73
- }
74
- }
75
- };
76
- };
77
-
78
- const composeR2Arguments = ({
79
- resourceName,
80
- storageClass = "Standard"
81
- }) => {
82
- return {
83
- transform: {
84
- bucket: {
85
- name: resourceName,
86
- jurisdiction: "eu",
87
- location: "weur",
88
- storageClass
89
- }
90
- }
91
- };
92
- };
93
-
94
- async function loadWorkerConfig({ path }) {
95
- const workerConfigFile = readFileSync(join(path, "./wrangler.jsonc"), "utf-8");
96
- return parse(workerConfigFile);
97
- }
98
-
99
- const composeBindingName = ({
100
- resource,
101
- resourceName,
102
- bindingName
103
- }) => {
104
- const convertedBindingName = bindingName ? toSnakeCase(bindingName) : `${toSnakeCase(resourceName)}_${resource}`;
105
- return convertedBindingName.toUpperCase();
32
+ const bankAccount = {
33
+ holderName: text("holder_name").notNull(),
34
+ number: text("number").notNull(),
35
+ bankCode: text("bank_code").$type().notNull(),
36
+ iban: text("iban").notNull(),
37
+ bic: text("bic").notNull(),
38
+ currency: text("currency").$type(),
39
+ countryCode: text("country_code").notNull()
106
40
  };
107
- const composeResourceName = ({
108
- project,
109
- environment,
110
- resourceName
111
- }) => {
112
- return `${project}-${resourceName}-${environment}`;
41
+ const bankAccountPostgres = {
42
+ holderName: text$1("holder_name").notNull(),
43
+ number: text$1("number").notNull(),
44
+ bankCode: text$1("bank_code").$type().notNull(),
45
+ iban: text$1("iban").notNull(),
46
+ bic: text$1("bic").notNull(),
47
+ currency: text$1("currency").$type(),
48
+ countryCode: text$1("country_code").notNull()
113
49
  };
114
50
 
115
51
  class Infrastructure {
@@ -125,19 +61,158 @@ class Infrastructure {
125
61
  this.environment = environment;
126
62
  this.sst = sst;
127
63
  }
64
+ // TODO(Pookensivee): Make tests for this util
65
+ composeBindingName({
66
+ resource,
67
+ resourceName,
68
+ bindingName
69
+ }) {
70
+ const convertedBindingName = bindingName ? toSnakeCase(bindingName) : `${toSnakeCase(resourceName)}_${resource}`;
71
+ return convertedBindingName.toUpperCase();
72
+ }
73
+ // TODO(Pookensivee): Make tests for this util
74
+ composeResourceName({ resourceName }) {
75
+ return `${this.project}-${resourceName}-${this.environment}`;
76
+ }
77
+ // TODO(Pookensivee): Make tests for this util
78
+ composeKvArguments({ resourceName }) {
79
+ return {
80
+ transform: {
81
+ namespace: {
82
+ title: resourceName
83
+ }
84
+ }
85
+ };
86
+ }
87
+ // TODO(Pookensivee): Make tests for this util
88
+ composeD1Arguments({ resourceName }) {
89
+ return {
90
+ transform: {
91
+ database: {
92
+ name: resourceName,
93
+ primaryLocationHint: "weur"
94
+ }
95
+ }
96
+ };
97
+ }
98
+ // TODO(Pookensivee): Make tests for this util
99
+ composeQueueArguments({
100
+ resourceName,
101
+ deliveryDelay = 5,
102
+ messageRetentionPeriod = 259200
103
+ }) {
104
+ return {
105
+ transform: {
106
+ queue: {
107
+ queueName: resourceName,
108
+ settings: {
109
+ deliveryDelay,
110
+ messageRetentionPeriod
111
+ }
112
+ }
113
+ }
114
+ };
115
+ }
116
+ // TODO(Pookensivee): Make tests for this util
117
+ composeR2Arguments({
118
+ resourceName,
119
+ storageClass = "Standard"
120
+ }) {
121
+ return {
122
+ transform: {
123
+ bucket: {
124
+ name: resourceName,
125
+ jurisdiction: "eu",
126
+ location: "weur",
127
+ storageClass
128
+ }
129
+ }
130
+ };
131
+ }
132
+ // TODO: Solve the circular dependency on post infrastructure deploy script
133
+ // TODO: Cannot assign a queue as a producer, work around: https://developers.cloudflare.com/workers/wrangler/commands/#queues-consumer-add-script-name
134
+ // async composeWorkerArguments({
135
+ // resourceName,
136
+ // path,
137
+ // bindings = [],
138
+ // }: {
139
+ // resourceName: string
140
+ // path: string
141
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
142
+ // }) {
143
+ // const workerConfig = this.loadWorkerConfig({ path })
144
+ // const environmentVariables = this.extractEnvironmentVariables({ workerConfigEnv:
145
+ // workerConfig.env as WorkerConfigEnv
146
+ // })
147
+ // // TODO: Fix this
148
+ // if (
149
+ // 'SERVICE_CONFIG' in environmentVariables &&
150
+ // typeof environmentVariables.SERVICE_CONFIG === 'object'
151
+ // ) {
152
+ // environmentVariables.SERVICE_CONFIG = JSON.stringify(environmentVariables.SERVICE_CONFIG)
153
+ // }
154
+ // // TODO: Fix this
155
+ // if (
156
+ // 'EMAIL_SENDER' in environmentVariables &&
157
+ // typeof environmentVariables.EMAIL_SENDER === 'object'
158
+ // ) {
159
+ // environmentVariables.EMAIL_SENDER = JSON.stringify(environmentVariables.EMAIL_SENDER)
160
+ // }
161
+ // return {
162
+ // handler: join(path, './src/index.ts'),
163
+ // environment: Object.entries(environmentVariables).reduce((acc, [key, value]) => ({
164
+ // ...acc,
165
+ // [key]: String(value)
166
+ // }), {} as Record<string, string>),
167
+ // link: bindings,
168
+ // transform: {
169
+ // worker: {
170
+ // scriptName: this.composeResourceName({ resourceName }),
171
+ // compatibilityDate: '2025-06-04',
172
+ // compatibilityFlags: ['nodejs_compat'],
173
+ // observability: {
174
+ // enabled: true,
175
+ // headSamplingRate: 1,
176
+ // logs: {
177
+ // // Check whether this disables logs completely or just invocation ones
178
+ // enabled: false,
179
+ // invocationLogs: false,
180
+ // },
181
+ // },
182
+ // },
183
+ // }
184
+ // } satisfies Partial<WorkerArgs>
185
+ // }
186
+ // loadWorkerConfig({ path }: { path: string }) {
187
+ // const workerConfigFile = readFileSync(
188
+ // join(path, './wrangler.jsonc'),
189
+ // 'utf-8',
190
+ // )
191
+ // TODO: Use parse from comment-json
192
+ // const jsonString = workerConfigFile
193
+ // .replace(/\/\*[\s\S]*?\*\//g, '')
194
+ // .replace(/\/\/.*$/gm, '')
195
+ // return JSON.parse(jsonString)
196
+ // }
197
+ // extractEnvironmentVariables({
198
+ // workerConfigEnv,
199
+ // }: {
200
+ // workerConfigEnv: WorkerConfigEnv
201
+ // }) {
202
+ // if (typeof this.environment === 'number') {
203
+ // return { ...workerConfigEnv.dev.vars, ENVIRONMENT: this.environment }
204
+ // }
205
+ // return { ...workerConfigEnv[this.environment].vars }
206
+ // }
128
207
  /**
129
208
  * Creates an instance of Cloudflare KV.
130
209
  */
131
210
  kv(options) {
132
211
  const { resourceName, bindingName } = options;
133
212
  return new this.sst.cloudflare.Kv(
134
- `${composeBindingName({ resource: "kv", resourceName, bindingName })}`,
135
- composeKvArguments({
136
- resourceName: composeResourceName({
137
- project: this.project,
138
- environment: this.environment,
139
- resourceName
140
- })
213
+ `${this.composeBindingName({ resource: "kv", resourceName, bindingName })}`,
214
+ this.composeKvArguments({
215
+ resourceName: this.composeResourceName({ resourceName })
141
216
  })
142
217
  );
143
218
  }
@@ -147,13 +222,9 @@ class Infrastructure {
147
222
  d1(options) {
148
223
  const { resourceName, bindingName } = options;
149
224
  return new this.sst.cloudflare.D1(
150
- `${composeBindingName({ resource: "d1", resourceName, bindingName })}`,
151
- composeD1Arguments({
152
- resourceName: composeResourceName({
153
- project: this.project,
154
- environment: this.environment,
155
- resourceName
156
- })
225
+ `${this.composeBindingName({ resource: "d1", resourceName, bindingName })}`,
226
+ this.composeD1Arguments({
227
+ resourceName: this.composeResourceName({ resourceName })
157
228
  })
158
229
  );
159
230
  }
@@ -163,13 +234,9 @@ class Infrastructure {
163
234
  queue(options) {
164
235
  const { resourceName, bindingName, deliveryDelay, messageRetentionPeriod } = options;
165
236
  return new this.sst.cloudflare.Queue(
166
- `${composeBindingName({ resource: "queue", resourceName, bindingName })}`,
167
- composeQueueArguments({
168
- resourceName: composeResourceName({
169
- project: this.project,
170
- environment: this.environment,
171
- resourceName
172
- }),
237
+ `${this.composeBindingName({ resource: "queue", resourceName, bindingName })}`,
238
+ this.composeQueueArguments({
239
+ resourceName: this.composeResourceName({ resourceName }),
173
240
  deliveryDelay,
174
241
  messageRetentionPeriod
175
242
  })
@@ -181,28 +248,77 @@ class Infrastructure {
181
248
  r2(options) {
182
249
  const { resourceName, bindingName, storageClass } = options;
183
250
  return new this.sst.cloudflare.Bucket(
184
- `${composeBindingName({ resource: "r2", resourceName, bindingName })}`,
185
- composeR2Arguments({
186
- resourceName: composeResourceName({
187
- project: this.project,
188
- environment: this.environment,
189
- resourceName
190
- }),
251
+ `${this.composeBindingName({ resource: "r2", resourceName, bindingName })}`,
252
+ this.composeR2Arguments({
253
+ resourceName: this.composeResourceName({ resourceName }),
191
254
  storageClass
192
255
  })
193
256
  );
194
257
  }
258
+ // TODO: Solve the circular dependency on post infrastructure deploy script
259
+ // async worker({
260
+ // resourceName,
261
+ // bindingName,
262
+ // path,
263
+ // bindings = [],
264
+ // }: {
265
+ // resourceName: string
266
+ // bindingName: string
267
+ // path: string
268
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
269
+ // }) {
270
+ // return new sst.cloudflare.Worker(
271
+ // this.composeBindingName({
272
+ // resource: 'worker',
273
+ // bindingName,
274
+ // resourceName,
275
+ // }),
276
+ // await this.composeWorkerArguments({
277
+ // resourceName: this.composeResourceName({ resourceName }),
278
+ // path,
279
+ // bindings,
280
+ // }),
281
+ // )
282
+ // }
283
+ // async service({
284
+ // resourceName,
285
+ // bindingName,
286
+ // path,
287
+ // bindings = [],
288
+ // }: {
289
+ // resourceName: string
290
+ // bindingName?: string
291
+ // path?: string
292
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
293
+ // }) {
294
+ // return this.worker({
295
+ // resourceName: `${this.project}-${resourceName}-service-${this.environment}`,
296
+ // bindingName: this.composeBindingName({
297
+ // resource: 'service',
298
+ // bindingName,
299
+ // resourceName,
300
+ // }),
301
+ // path: `${path ?? `./services/${resourceName}`}`,
302
+ // bindings,
303
+ // })
304
+ // }
305
+ // // TODO: Add name
306
+ // async orchestrator({
307
+ // path,
308
+ // bindings = [],
309
+ // }: {
310
+ // path?: string
311
+ // bindings?: Input<Kv | D1 | Queue | Worker | Bucket>[]
312
+ // }) {
313
+ // return this.worker({
314
+ // resourceName: `${this.project}-gateway-${this.environment}`,
315
+ // bindingName: 'GATEWAY',
316
+ // path: `${path ?? `./apps/gateway`}`,
317
+ // bindings,
318
+ // })
319
+ // }
195
320
  }
196
321
 
197
- const ENVIRONMENT = ["dev", "test", "staging", "production"];
198
-
199
- const validateEnvironment = (environment) => {
200
- if (ENVIRONMENT.includes(environment)) {
201
- return environment;
202
- }
203
- return Number(environment);
204
- };
205
-
206
322
  const ibanZodSchema = new z.$ZodString({
207
323
  type: "string",
208
324
  checks: [
@@ -376,7 +492,7 @@ const RPCResponse = {
376
492
  * @returns An `IRPCResponse<T>` with `null` data and the provided error.
377
493
  */
378
494
  serviceError(error) {
379
- consola.error(error.message);
495
+ console.error(error.message);
380
496
  return {
381
497
  status: error.status,
382
498
  message: error.message,
@@ -830,4 +946,4 @@ function develitWorker(Worker) {
830
946
  return DevelitWorker;
831
947
  }
832
948
 
833
- export { DatabaseTransaction, ENVIRONMENT, Infrastructure, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, composeBindingName, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, loadWorkerConfig, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4, validateEnvironment };
949
+ export { DatabaseTransaction, Infrastructure, RPCResponse, action, bankAccount, bankAccountPostgres, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, paginationQuerySchema, paginationSchema, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "5.15.2",
3
+ "version": "5.16.1",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -35,7 +35,6 @@
35
35
  "@std/path": "npm:@jsr/std__path",
36
36
  "@std/text": "npm:@jsr/std__text",
37
37
  "comment-json": "^4.2.5",
38
- "consola": "^3.4.2",
39
38
  "drizzle-kit": "^0.31.4",
40
39
  "drizzle-orm": "^0.44.5",
41
40
  "h3": "^1.15.4",