@develit-io/backend-sdk 5.47.0 → 6.0.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.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +9 -4
- package/package.json +1 -2
package/dist/index.d.mts
CHANGED
|
@@ -5,8 +5,8 @@ import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
|
|
|
5
5
|
import { MiddlewareHandler } from 'hono/types';
|
|
6
6
|
import { z as z$1 } from 'zod';
|
|
7
7
|
import * as z from 'zod/v4/core';
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
8
|
+
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
9
|
+
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
10
10
|
import { Queue } from '@cloudflare/workers-types';
|
|
11
11
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
12
12
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
@@ -15,7 +15,7 @@ declare const uuidv4: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
|
15
15
|
|
|
16
16
|
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
17
17
|
|
|
18
|
-
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
18
|
+
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'cryptobyte-website' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
19
19
|
|
|
20
20
|
declare const base: {
|
|
21
21
|
id: drizzle_orm.IsPrimaryKey<drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"id", [string, ...string[]], number | undefined>>>;
|
|
@@ -478,18 +478,17 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
|
|
|
478
478
|
[k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
|
|
479
479
|
}>>, z.$ZodObjectConfig>;
|
|
480
480
|
|
|
481
|
-
type InternalErrorResponseStatus = Exclude<
|
|
481
|
+
type InternalErrorResponseStatus = Exclude<ContentfulStatusCode, SuccessStatusCode>;
|
|
482
482
|
interface InternalError {
|
|
483
483
|
status: InternalErrorResponseStatus;
|
|
484
484
|
code: string;
|
|
485
485
|
message: string;
|
|
486
486
|
}
|
|
487
487
|
interface IRPCResponse<T> {
|
|
488
|
-
status:
|
|
488
|
+
status: ContentfulStatusCode;
|
|
489
489
|
message: string;
|
|
490
490
|
data: T | null | undefined;
|
|
491
491
|
error: boolean;
|
|
492
|
-
phrase?: ReasonPhrases;
|
|
493
492
|
}
|
|
494
493
|
interface GatewayResponse<T> {
|
|
495
494
|
status?: number;
|
|
@@ -748,7 +747,7 @@ declare const RPCResponse: {
|
|
|
748
747
|
*/
|
|
749
748
|
ok<T>(message: string, detail?: {
|
|
750
749
|
data?: T;
|
|
751
|
-
status?:
|
|
750
|
+
status?: ContentfulStatusCode;
|
|
752
751
|
}): IRPCResponse<T>;
|
|
753
752
|
/**
|
|
754
753
|
* ❌ Constructs a generic service error response.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
|
|
|
5
5
|
import { MiddlewareHandler } from 'hono/types';
|
|
6
6
|
import { z as z$1 } from 'zod';
|
|
7
7
|
import * as z from 'zod/v4/core';
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
8
|
+
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
9
|
+
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
10
10
|
import { Queue } from '@cloudflare/workers-types';
|
|
11
11
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
12
12
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
@@ -15,7 +15,7 @@ declare const uuidv4: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
|
15
15
|
|
|
16
16
|
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
17
17
|
|
|
18
|
-
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
18
|
+
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'cryptobyte-website' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
19
19
|
|
|
20
20
|
declare const base: {
|
|
21
21
|
id: drizzle_orm.IsPrimaryKey<drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"id", [string, ...string[]], number | undefined>>>;
|
|
@@ -478,18 +478,17 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
|
|
|
478
478
|
[k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
|
|
479
479
|
}>>, z.$ZodObjectConfig>;
|
|
480
480
|
|
|
481
|
-
type InternalErrorResponseStatus = Exclude<
|
|
481
|
+
type InternalErrorResponseStatus = Exclude<ContentfulStatusCode, SuccessStatusCode>;
|
|
482
482
|
interface InternalError {
|
|
483
483
|
status: InternalErrorResponseStatus;
|
|
484
484
|
code: string;
|
|
485
485
|
message: string;
|
|
486
486
|
}
|
|
487
487
|
interface IRPCResponse<T> {
|
|
488
|
-
status:
|
|
488
|
+
status: ContentfulStatusCode;
|
|
489
489
|
message: string;
|
|
490
490
|
data: T | null | undefined;
|
|
491
491
|
error: boolean;
|
|
492
|
-
phrase?: ReasonPhrases;
|
|
493
492
|
}
|
|
494
493
|
interface GatewayResponse<T> {
|
|
495
494
|
status?: number;
|
|
@@ -748,7 +747,7 @@ declare const RPCResponse: {
|
|
|
748
747
|
*/
|
|
749
748
|
ok<T>(message: string, detail?: {
|
|
750
749
|
data?: T;
|
|
751
|
-
status?:
|
|
750
|
+
status?: ContentfulStatusCode;
|
|
752
751
|
}): IRPCResponse<T>;
|
|
753
752
|
/**
|
|
754
753
|
* ❌ Constructs a generic service error response.
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,6 @@ import crypto$1 from 'node:crypto';
|
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { parse } from 'comment-json';
|
|
13
13
|
import * as z from 'zod/v4/core';
|
|
14
|
-
import 'http-status-codes';
|
|
15
14
|
import superjson from 'superjson';
|
|
16
15
|
|
|
17
16
|
const uuidv4 = () => crypto.randomUUID();
|
|
@@ -134,6 +133,12 @@ const createInternalError = (error, details) => {
|
|
|
134
133
|
const isInternalError = (error) => {
|
|
135
134
|
return typeof error === "object" && error !== null && "message" in error && "code" in error;
|
|
136
135
|
};
|
|
136
|
+
const toErrorStatus = (status) => {
|
|
137
|
+
if (status >= 400 && status < 600) {
|
|
138
|
+
return status;
|
|
139
|
+
}
|
|
140
|
+
return 500;
|
|
141
|
+
};
|
|
137
142
|
|
|
138
143
|
const RPCResponse = {
|
|
139
144
|
/**
|
|
@@ -460,7 +465,7 @@ async function useFetch(url, { parseAs = "json", ...options } = {}) {
|
|
|
460
465
|
createInternalError(parseError, {
|
|
461
466
|
message: body?.message ?? response.statusText,
|
|
462
467
|
code: "HTTP_ERROR",
|
|
463
|
-
status: response.status
|
|
468
|
+
status: toErrorStatus(response.status)
|
|
464
469
|
})
|
|
465
470
|
];
|
|
466
471
|
}
|
|
@@ -469,7 +474,7 @@ async function useFetch(url, { parseAs = "json", ...options } = {}) {
|
|
|
469
474
|
null,
|
|
470
475
|
createInternalError(parseError, {
|
|
471
476
|
code: "PARSE_ERROR",
|
|
472
|
-
status: response.status
|
|
477
|
+
status: toErrorStatus(response.status)
|
|
473
478
|
})
|
|
474
479
|
];
|
|
475
480
|
}
|
|
@@ -939,7 +944,7 @@ function develitWorker(Worker) {
|
|
|
939
944
|
const parseResult = z.safeParse(schema, input);
|
|
940
945
|
if (!parseResult.success) {
|
|
941
946
|
const parseError = {
|
|
942
|
-
status: 400,
|
|
947
|
+
status: toErrorStatus(400),
|
|
943
948
|
code: "INVALID_ACTION_INPUT",
|
|
944
949
|
message: z.prettifyError(parseResult.error)
|
|
945
950
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develit-io/backend-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Develit Backend SDK",
|
|
5
5
|
"author": "Develit.io",
|
|
6
6
|
"license": "ISC",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"drizzle-kit": "^0.31.6",
|
|
34
34
|
"drizzle-orm": "^0.44.7",
|
|
35
35
|
"h3": "^1.15.4",
|
|
36
|
-
"http-status-codes": "2.3.0",
|
|
37
36
|
"superjson": "^2.2.5"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|