@kalutskii/foundation 0.4.0 → 0.4.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.d.ts +2 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,8 +45,7 @@ declare function failure({ status, error }: {
|
|
|
45
45
|
declare function fetchSafely<TResult extends APIContractResult<unknown>>(fetcher: () => Promise<TResult>): Promise<FetchResult<APIContractData<TResult>>>;
|
|
46
46
|
/** Resolves an APIContractResult fetcher, throwing an error if the result is an APIError. */
|
|
47
47
|
declare function fetchAndThrow<TResult extends APIContractResult<unknown>>(fetcher: () => Promise<TResult>): Promise<APIContractData<TResult>>;
|
|
48
|
-
|
|
49
|
-
declare function isErrorResponse<TResponse>(response: TResponse): response is TResponse & APIError;
|
|
48
|
+
declare function isAPIResponse<TResponse>(response: TResponse): response is TResponse & APIContractResult<unknown>;
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
51
|
* Global error handler for Hono framework. Catches all exceptions thrown in route handlers and middlewares.
|
|
@@ -214,4 +213,4 @@ declare class ZodJWTService<TPayloadOrSchema> {
|
|
|
214
213
|
verifyOrThrow(token: string, secret: string): Promise<Payload<TPayloadOrSchema>>;
|
|
215
214
|
}
|
|
216
215
|
|
|
217
|
-
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type SerializeDates, type SuccessStatusCode, type XOR, ZodJWTService, asQueryBoolean, asQueryNumber, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler,
|
|
216
|
+
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type SerializeDates, type SuccessStatusCode, type XOR, ZodJWTService, asQueryBoolean, asQueryNumber, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, isAPIResponse, log, onHandlerError, respond, safeExecute, success };
|
package/dist/index.js
CHANGED
|
@@ -23,13 +23,13 @@ async function fetchAndThrow(fetcher) {
|
|
|
23
23
|
throw new Error(response.error);
|
|
24
24
|
return response.data;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function isAPIResponse(response) {
|
|
27
27
|
if (typeof response !== "object" || response === null)
|
|
28
28
|
return false;
|
|
29
29
|
if (!("kind" in response) || !("status" in response))
|
|
30
30
|
return false;
|
|
31
31
|
const { kind, status } = response;
|
|
32
|
-
return kind === "error" && (typeof status === "number" || typeof status === "string");
|
|
32
|
+
return (kind === "data" || kind === "error") && (typeof status === "number" || typeof status === "string");
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// src/hono/hono.execution.ts
|
|
@@ -231,7 +231,7 @@ export {
|
|
|
231
231
|
getUTCOffset,
|
|
232
232
|
getZonedTime,
|
|
233
233
|
honoLoggingHandler,
|
|
234
|
-
|
|
234
|
+
isAPIResponse,
|
|
235
235
|
log,
|
|
236
236
|
onHandlerError,
|
|
237
237
|
respond,
|