@develit-io/backend-sdk 5.11.1 → 5.12.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.
package/dist/index.cjs CHANGED
@@ -80,6 +80,111 @@ const swiftZodSchema = new z__namespace.$ZodString({
80
80
  ]
81
81
  });
82
82
 
83
+ const paginationQuerySchema = new z__namespace.$ZodObject({
84
+ type: "object",
85
+ shape: {
86
+ page: new z__namespace.$ZodDefault({
87
+ type: "default",
88
+ innerType: new z__namespace.$ZodNumber({
89
+ type: "number",
90
+ coerce: true
91
+ }),
92
+ defaultValue: () => 1
93
+ }),
94
+ limit: new z__namespace.$ZodDefault({
95
+ type: "default",
96
+ innerType: new z__namespace.$ZodNumber({
97
+ type: "number",
98
+ coerce: true
99
+ }),
100
+ defaultValue: () => 20
101
+ }),
102
+ sort: new z__namespace.$ZodDefault({
103
+ type: "default",
104
+ innerType: new z__namespace.$ZodObject({
105
+ type: "object",
106
+ shape: {
107
+ column: new z__namespace.$ZodDefault({
108
+ type: "default",
109
+ innerType: new z__namespace.$ZodEnum({
110
+ type: "enum",
111
+ entries: {
112
+ createdAt: "createdAt",
113
+ modifiedAt: "modifiedAt",
114
+ deletedAt: "deletedAt"
115
+ }
116
+ }),
117
+ defaultValue: () => "modifiedAt"
118
+ }),
119
+ direction: new z__namespace.$ZodDefault({
120
+ type: "default",
121
+ innerType: new z__namespace.$ZodEnum({
122
+ type: "enum",
123
+ entries: {
124
+ asc: "asc",
125
+ desc: "desc"
126
+ }
127
+ }),
128
+ defaultValue: () => "desc"
129
+ })
130
+ }
131
+ }),
132
+ defaultValue: () => ({ column: "modifiedAt", direction: "desc" })
133
+ })
134
+ }
135
+ });
136
+ const paginationSchema = new z__namespace.$ZodObject({
137
+ type: "object",
138
+ shape: {
139
+ page: new z__namespace.$ZodDefault({
140
+ type: "default",
141
+ innerType: new z__namespace.$ZodNumber({
142
+ type: "number"
143
+ }),
144
+ defaultValue: () => 1
145
+ }),
146
+ limit: new z__namespace.$ZodDefault({
147
+ type: "default",
148
+ innerType: new z__namespace.$ZodNumber({
149
+ type: "number"
150
+ }),
151
+ defaultValue: () => 20
152
+ }),
153
+ sort: new z__namespace.$ZodDefault({
154
+ type: "default",
155
+ innerType: new z__namespace.$ZodObject({
156
+ type: "object",
157
+ shape: {
158
+ column: new z__namespace.$ZodDefault({
159
+ type: "default",
160
+ innerType: new z__namespace.$ZodEnum({
161
+ type: "enum",
162
+ entries: {
163
+ createdAt: "createdAt",
164
+ modifiedAt: "modifiedAt",
165
+ deletedAt: "deletedAt"
166
+ }
167
+ }),
168
+ defaultValue: () => "modifiedAt"
169
+ }),
170
+ direction: new z__namespace.$ZodDefault({
171
+ type: "default",
172
+ innerType: new z__namespace.$ZodEnum({
173
+ type: "enum",
174
+ entries: {
175
+ asc: "asc",
176
+ desc: "desc"
177
+ }
178
+ }),
179
+ defaultValue: () => "desc"
180
+ })
181
+ }
182
+ }),
183
+ defaultValue: () => ({ column: "modifiedAt", direction: "desc" })
184
+ })
185
+ }
186
+ });
187
+
83
188
  const handleActionResponse = ({
84
189
  error,
85
190
  status,
@@ -426,8 +531,7 @@ const getPgDatabaseIdFromWrangler = () => {
426
531
  );
427
532
  }
428
533
  };
429
- const getPgCredentials = () => {
430
- const databaseId = getPgDatabaseIdFromWrangler() ?? "";
534
+ const getPgCredentials = (serviceName) => {
431
535
  if (isRemoteEnvironment()) {
432
536
  return {
433
537
  dbCredentials: {
@@ -435,6 +539,7 @@ const getPgCredentials = () => {
435
539
  }
436
540
  };
437
541
  } else {
542
+ const databaseId = serviceName ? `${serviceName}-db` : getPgDatabaseIdFromWrangler() ?? "";
438
543
  return {
439
544
  dbCredentials: {
440
545
  url: getPgLocalConnectionString(databaseId)
@@ -619,6 +724,8 @@ exports.handleAction = handleAction;
619
724
  exports.handleActionResponse = handleActionResponse;
620
725
  exports.ibanZodSchema = ibanZodSchema;
621
726
  exports.isInternalError = isInternalError;
727
+ exports.paginationQuerySchema = paginationQuerySchema;
728
+ exports.paginationSchema = paginationSchema;
622
729
  exports.service = service;
623
730
  exports.swiftZodSchema = swiftZodSchema;
624
731
  exports.useResult = useResult;
package/dist/index.d.cts CHANGED
@@ -79,6 +79,13 @@ interface CommandItem<TAuditAction = string> {
79
79
  id: string;
80
80
  }
81
81
 
82
+ declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
83
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
84
+ }>>, z.$ZodObjectConfig>;
85
+ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
86
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
87
+ }>>, z.$ZodObjectConfig>;
88
+
82
89
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
83
90
  error: boolean;
84
91
  status: number;
@@ -282,7 +289,7 @@ declare const isInternalError: (error: unknown) => error is InternalError;
282
289
 
283
290
  declare const getPgLocalConnectionString: (id: string) => string;
284
291
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
285
- declare const getPgCredentials: () => {
292
+ declare const getPgCredentials: (serviceName?: string) => {
286
293
  dbCredentials: {
287
294
  url: string;
288
295
  };
@@ -399,5 +406,5 @@ interface WithRetryCounterOptions {
399
406
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
400
407
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
401
408
 
402
- export { DatabaseTransaction, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
409
+ export { DatabaseTransaction, RPCResponse, action, 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 };
403
410
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, ValidatedInput };
package/dist/index.d.mts CHANGED
@@ -79,6 +79,13 @@ interface CommandItem<TAuditAction = string> {
79
79
  id: string;
80
80
  }
81
81
 
82
+ declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
83
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
84
+ }>>, z.$ZodObjectConfig>;
85
+ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
86
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
87
+ }>>, z.$ZodObjectConfig>;
88
+
82
89
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
83
90
  error: boolean;
84
91
  status: number;
@@ -282,7 +289,7 @@ declare const isInternalError: (error: unknown) => error is InternalError;
282
289
 
283
290
  declare const getPgLocalConnectionString: (id: string) => string;
284
291
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
285
- declare const getPgCredentials: () => {
292
+ declare const getPgCredentials: (serviceName?: string) => {
286
293
  dbCredentials: {
287
294
  url: string;
288
295
  };
@@ -399,5 +406,5 @@ interface WithRetryCounterOptions {
399
406
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
400
407
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
401
408
 
402
- export { DatabaseTransaction, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
409
+ export { DatabaseTransaction, RPCResponse, action, 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 };
403
410
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, ValidatedInput };
package/dist/index.d.ts CHANGED
@@ -79,6 +79,13 @@ interface CommandItem<TAuditAction = string> {
79
79
  id: string;
80
80
  }
81
81
 
82
+ declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
83
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
84
+ }>>, z.$ZodObjectConfig>;
85
+ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
86
+ [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
87
+ }>>, z.$ZodObjectConfig>;
88
+
82
89
  declare const handleActionResponse: <T>({ error, status, message, data, }: {
83
90
  error: boolean;
84
91
  status: number;
@@ -282,7 +289,7 @@ declare const isInternalError: (error: unknown) => error is InternalError;
282
289
 
283
290
  declare const getPgLocalConnectionString: (id: string) => string;
284
291
  declare const getPgDatabaseIdFromWrangler: () => string | undefined;
285
- declare const getPgCredentials: () => {
292
+ declare const getPgCredentials: (serviceName?: string) => {
286
293
  dbCredentials: {
287
294
  url: string;
288
295
  };
@@ -399,5 +406,5 @@ interface WithRetryCounterOptions {
399
406
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
400
407
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
401
408
 
402
- export { DatabaseTransaction, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
409
+ export { DatabaseTransaction, RPCResponse, action, 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 };
403
410
  export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, Command, CommandLogPayload, DevelitWorkerMethods, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, ValidatedInput };
package/dist/index.mjs CHANGED
@@ -58,6 +58,111 @@ const swiftZodSchema = new z.$ZodString({
58
58
  ]
59
59
  });
60
60
 
61
+ const paginationQuerySchema = new z.$ZodObject({
62
+ type: "object",
63
+ shape: {
64
+ page: new z.$ZodDefault({
65
+ type: "default",
66
+ innerType: new z.$ZodNumber({
67
+ type: "number",
68
+ coerce: true
69
+ }),
70
+ defaultValue: () => 1
71
+ }),
72
+ limit: new z.$ZodDefault({
73
+ type: "default",
74
+ innerType: new z.$ZodNumber({
75
+ type: "number",
76
+ coerce: true
77
+ }),
78
+ defaultValue: () => 20
79
+ }),
80
+ sort: new z.$ZodDefault({
81
+ type: "default",
82
+ innerType: new z.$ZodObject({
83
+ type: "object",
84
+ shape: {
85
+ column: new z.$ZodDefault({
86
+ type: "default",
87
+ innerType: new z.$ZodEnum({
88
+ type: "enum",
89
+ entries: {
90
+ createdAt: "createdAt",
91
+ modifiedAt: "modifiedAt",
92
+ deletedAt: "deletedAt"
93
+ }
94
+ }),
95
+ defaultValue: () => "modifiedAt"
96
+ }),
97
+ direction: new z.$ZodDefault({
98
+ type: "default",
99
+ innerType: new z.$ZodEnum({
100
+ type: "enum",
101
+ entries: {
102
+ asc: "asc",
103
+ desc: "desc"
104
+ }
105
+ }),
106
+ defaultValue: () => "desc"
107
+ })
108
+ }
109
+ }),
110
+ defaultValue: () => ({ column: "modifiedAt", direction: "desc" })
111
+ })
112
+ }
113
+ });
114
+ const paginationSchema = new z.$ZodObject({
115
+ type: "object",
116
+ shape: {
117
+ page: new z.$ZodDefault({
118
+ type: "default",
119
+ innerType: new z.$ZodNumber({
120
+ type: "number"
121
+ }),
122
+ defaultValue: () => 1
123
+ }),
124
+ limit: new z.$ZodDefault({
125
+ type: "default",
126
+ innerType: new z.$ZodNumber({
127
+ type: "number"
128
+ }),
129
+ defaultValue: () => 20
130
+ }),
131
+ sort: new z.$ZodDefault({
132
+ type: "default",
133
+ innerType: new z.$ZodObject({
134
+ type: "object",
135
+ shape: {
136
+ column: new z.$ZodDefault({
137
+ type: "default",
138
+ innerType: new z.$ZodEnum({
139
+ type: "enum",
140
+ entries: {
141
+ createdAt: "createdAt",
142
+ modifiedAt: "modifiedAt",
143
+ deletedAt: "deletedAt"
144
+ }
145
+ }),
146
+ defaultValue: () => "modifiedAt"
147
+ }),
148
+ direction: new z.$ZodDefault({
149
+ type: "default",
150
+ innerType: new z.$ZodEnum({
151
+ type: "enum",
152
+ entries: {
153
+ asc: "asc",
154
+ desc: "desc"
155
+ }
156
+ }),
157
+ defaultValue: () => "desc"
158
+ })
159
+ }
160
+ }),
161
+ defaultValue: () => ({ column: "modifiedAt", direction: "desc" })
162
+ })
163
+ }
164
+ });
165
+
61
166
  const handleActionResponse = ({
62
167
  error,
63
168
  status,
@@ -404,8 +509,7 @@ const getPgDatabaseIdFromWrangler = () => {
404
509
  );
405
510
  }
406
511
  };
407
- const getPgCredentials = () => {
408
- const databaseId = getPgDatabaseIdFromWrangler() ?? "";
512
+ const getPgCredentials = (serviceName) => {
409
513
  if (isRemoteEnvironment()) {
410
514
  return {
411
515
  dbCredentials: {
@@ -413,6 +517,7 @@ const getPgCredentials = () => {
413
517
  }
414
518
  };
415
519
  } else {
520
+ const databaseId = serviceName ? `${serviceName}-db` : getPgDatabaseIdFromWrangler() ?? "";
416
521
  return {
417
522
  dbCredentials: {
418
523
  url: getPgLocalConnectionString(databaseId)
@@ -571,4 +676,4 @@ function develitWorker(Worker) {
571
676
  return DevelitWorker;
572
677
  }
573
678
 
574
- export { DatabaseTransaction, RPCResponse, action, base, basePostgres, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanZodSchema, isInternalError, service, swiftZodSchema, useResult, useResultSync, uuidv4 };
679
+ export { DatabaseTransaction, RPCResponse, action, 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.11.1",
3
+ "version": "5.12.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -28,7 +28,7 @@
28
28
  "types": "./dist/index.d.ts",
29
29
  "files": ["dist"],
30
30
  "dependencies": {
31
- "@cloudflare/workers-types": "^4.20250816.0",
31
+ "@cloudflare/workers-types": "^4.20250823.0",
32
32
  "comment-json": "^4.2.5",
33
33
  "consola": "^3.4.2",
34
34
  "drizzle-kit": "^0.31.4",
@@ -38,6 +38,6 @@
38
38
  "superjson": "^2.2.2"
39
39
  },
40
40
  "peerDependencies": {
41
- "zod": "^4.0.17"
41
+ "zod": "^4.1.1"
42
42
  }
43
43
  }