@arkyn/server 3.0.3 → 3.0.5
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/README.md +20 -20
- package/dist/http/badResponses/badGateway.d.ts +1 -1
- package/dist/http/badResponses/badRequest.d.ts +1 -1
- package/dist/http/badResponses/conflict.d.ts +1 -1
- package/dist/http/badResponses/forbidden.d.ts +1 -1
- package/dist/http/badResponses/notFound.d.ts +1 -1
- package/dist/http/badResponses/notImplemented.d.ts +1 -1
- package/dist/http/badResponses/serverError.d.ts +1 -1
- package/dist/http/badResponses/unauthorized.d.ts +1 -1
- package/dist/http/badResponses/unprocessableEntity.d.ts +1 -1
- package/dist/http/successResponses/created.d.ts +1 -1
- package/dist/http/successResponses/found.d.ts +1 -1
- package/dist/http/successResponses/noContent.d.ts +1 -1
- package/dist/http/successResponses/success.d.ts +1 -1
- package/dist/http/successResponses/updated.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/http/badResponses/badGateway.js.map +1 -1
- package/dist/modules/http/badResponses/badRequest.js.map +1 -1
- package/dist/modules/http/badResponses/conflict.js.map +1 -1
- package/dist/modules/http/badResponses/forbidden.js.map +1 -1
- package/dist/modules/http/badResponses/notFound.js.map +1 -1
- package/dist/modules/http/badResponses/notImplemented.js.map +1 -1
- package/dist/modules/http/badResponses/serverError.js.map +1 -1
- package/dist/modules/http/badResponses/unauthorized.js.map +1 -1
- package/dist/modules/http/badResponses/unprocessableEntity.js.map +1 -1
- package/dist/modules/http/successResponses/created.js.map +1 -1
- package/dist/modules/http/successResponses/found.js.map +1 -1
- package/dist/modules/http/successResponses/noContent.js.map +1 -1
- package/dist/modules/http/successResponses/success.js.map +1 -1
- package/dist/modules/http/successResponses/updated.js.map +1 -1
- package/dist/modules/services/debugService.js.map +1 -1
- package/dist/modules/utilities/formAsyncParse.js.map +1 -1
- package/dist/modules/utilities/schemaValidator.js.map +1 -1
- package/dist/services/debugService.d.ts +1 -1
- package/dist/utilities/formAsyncParse.d.ts +1 -1
- package/dist/utilities/schemaValidator.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict.js","names":[],"sources":["../../../../src/http/badResponses/conflict.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 409 Conflict
|
|
1
|
+
{"version":3,"file":"conflict.js","names":[],"sources":["../../../../src/http/badResponses/conflict.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 409 Conflict, the request conflicts with the current state of the server (e.g. duplicate record).\n *\n * @example\n * ```typescript\n * throw new Conflict(\"Email already in use\");\n * ```\n */\nclass Conflict extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Conflict\";\n\t\tthis.status = 409;\n\t\tthis.statusText = message;\n\t\tthis.debugColor = \"yellow\";\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { Conflict };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAuB,EAAY;CAMlC,YAAY,GAAiB,GAAa;EASzC,AARA,MAAM,GAEN,KAAK,OAAO,YACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,aAAa,UAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden.js","names":[],"sources":["../../../../src/http/badResponses/forbidden.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 403 Forbidden
|
|
1
|
+
{"version":3,"file":"forbidden.js","names":[],"sources":["../../../../src/http/badResponses/forbidden.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 403 Forbidden, authenticated but not authorized to access this resource.\n *\n * @example\n * ```typescript\n * throw new Forbidden(\"You don't have permission to delete this resource\");\n * ```\n */\nclass Forbidden extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Forbidden\";\n\t\tthis.status = 403;\n\t\tthis.statusText = message;\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { Forbidden };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAwB,EAAY;CAMnC,YAAY,GAAiB,GAAa;EAQzC,AAPA,MAAM,GAEN,KAAK,OAAO,aACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.js","names":[],"sources":["../../../../src/http/badResponses/notFound.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 404 Not Found
|
|
1
|
+
{"version":3,"file":"notFound.js","names":[],"sources":["../../../../src/http/badResponses/notFound.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 404 Not Found, the requested resource does not exist.\n *\n * @example\n * ```typescript\n * throw new NotFound(\"Product not found\");\n * ```\n */\nclass NotFound extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"NotFound\";\n\t\tthis.status = 404;\n\t\tthis.statusText = message;\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { NotFound };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAuB,EAAY;CAMlC,YAAY,GAAiB,GAAa;EAQzC,AAPA,MAAM,GAEN,KAAK,OAAO,YACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notImplemented.js","names":[],"sources":["../../../../src/http/badResponses/notImplemented.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 501 Not Implemented
|
|
1
|
+
{"version":3,"file":"notImplemented.js","names":[],"sources":["../../../../src/http/badResponses/notImplemented.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 501 Not Implemented, the server does not support the functionality required to fulfill the request.\n *\n * @example\n * ```typescript\n * throw new NotImplemented(\"Webhook delivery is not yet implemented\");\n * ```\n */\nclass NotImplemented extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"NotImplemented\";\n\t\tthis.status = 501;\n\t\tthis.statusText = message;\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { NotImplemented };\n"],"mappings":";;AAUA,IAAM,IAAN,cAA6B,EAAY;CAMxC,YAAY,GAAiB,GAAa;EAQzC,AAPA,MAAM,GAEN,KAAK,OAAO,kBACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverError.js","names":[],"sources":["../../../../src/http/badResponses/serverError.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 500 Internal Server Error
|
|
1
|
+
{"version":3,"file":"serverError.js","names":[],"sources":["../../../../src/http/badResponses/serverError.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 500 Internal Server Error, an unexpected condition prevented the server from fulfilling the request.\n *\n * @example\n * ```typescript\n * throw new ServerError(\"Failed to connect to the database\");\n * ```\n */\nclass ServerError extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"ServerError\";\n\t\tthis.status = 500;\n\t\tthis.statusText = message;\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { ServerError };\n"],"mappings":";;AAUA,IAAM,IAAN,cAA0B,EAAY;CAMrC,YAAY,GAAiB,GAAa;EAQzC,AAPA,MAAM,GAEN,KAAK,OAAO,eACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.js","names":[],"sources":["../../../../src/http/badResponses/unauthorized.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 401 Unauthorized
|
|
1
|
+
{"version":3,"file":"unauthorized.js","names":[],"sources":["../../../../src/http/badResponses/unauthorized.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 401 Unauthorized, the request lacks valid authentication credentials.\n *\n * @example\n * ```typescript\n * throw new Unauthorized(\"Invalid or expired token\");\n * ```\n */\nclass Unauthorized extends BadResponse {\n\t/**\n\t * @param message - Error description.\n\t * @param cause - Optional extra context (serialized to JSON).\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, cause?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Unauthorized\";\n\t\tthis.status = 401;\n\t\tthis.statusText = message;\n\t\tthis.debugColor = \"yellow\";\n\t\tthis.cause = cause ? JSON.stringify(cause) : undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { Unauthorized };\n"],"mappings":";;AAUA,IAAM,IAAN,cAA2B,EAAY;CAMtC,YAAY,GAAiB,GAAa;EASzC,AARA,MAAM,GAEN,KAAK,OAAO,gBACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,aAAa,UAClB,KAAK,QAAQ,IAAQ,KAAK,UAAU,CAAK,IAAI,KAAA,GAE7C,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unprocessableEntity.js","names":[],"sources":["../../../../src/http/badResponses/unprocessableEntity.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 422 Unprocessable Entity
|
|
1
|
+
{"version":3,"file":"unprocessableEntity.js","names":[],"sources":["../../../../src/http/badResponses/unprocessableEntity.ts"],"sourcesContent":["import { BadResponse } from \"./_badResponse\";\n\n/**\n * HTTP 422 Unprocessable Entity, the request is well-formed but contains semantic validation errors.\n * Typically used for form field validation failures.\n *\n * @example\n * ```typescript\n * throw new UnprocessableEntity({\n * message: \"Validation failed\",\n * fieldErrors: { email: \"Invalid email format\", age: \"Must be 18 or older\" },\n * fields: { email: \"not-an-email\", age: \"15\" },\n * });\n * ```\n */\nclass UnprocessableEntity extends BadResponse {\n\t/**\n\t * @param props.message - Human-readable description of the error.\n\t * @param props.fieldErrors - Per-field validation messages keyed by field name.\n\t * @param props.fields - Original submitted field values (useful for repopulating forms).\n\t * @param props.data - Any extra data to include in the response body.\n\t */\n\tconstructor(props: {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\t\tdata?: any;\n\t\tfieldErrors?: Record<string, string>;\n\t\tfields?: Record<string, string>;\n\t\tmessage?: string;\n\t}) {\n\t\tsuper();\n\n\t\tthis.name = \"UnprocessableEntity\";\n\t\tthis.status = 422;\n\t\tthis.statusText = props.message || \"Unprocessable entity\";\n\t\tthis.debugColor = \"yellow\";\n\t\tthis.cause = {\n\t\t\tdata: props.data,\n\t\t\tfieldErrors: props.fieldErrors,\n\t\t\tfields: props.fields,\n\t\t};\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.makeBody()), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.makeBody(), responseInit);\n\t}\n}\n\nexport { UnprocessableEntity };\n"],"mappings":";;AAeA,IAAM,IAAN,cAAkC,EAAY;CAO7C,YAAY,GAMT;EAaF,AAZA,MAAM,GAEN,KAAK,OAAO,uBACZ,KAAK,SAAS,KACd,KAAK,aAAa,EAAM,WAAW,wBACnC,KAAK,aAAa,UAClB,KAAK,QAAQ;GACZ,MAAM,EAAM;GACZ,aAAa,EAAM;GACnB,QAAQ,EAAM;EACf,GAEA,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,SAAS,CAAC,GAAG,CAAY;CAClE;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,CAAY;CACnD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created.js","names":[],"sources":["../../../../src/http/successResponses/created.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 201 Created
|
|
1
|
+
{"version":3,"file":"created.js","names":[],"sources":["../../../../src/http/successResponses/created.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 201 Created, the request succeeded and a new resource was created.\n *\n * @example\n * ```typescript\n * return new Created(\"User created successfully\", { id: user.id }).toJson();\n * ```\n */\nclass Created extends SuccessResponse {\n\t/**\n\t * @param message - Description included in the response status text.\n\t * @param body - Data to include in the response body.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, body?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Created\";\n\t\tthis.status = 201;\n\t\tthis.statusText = message;\n\t\tthis.body = body || undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.body), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.body, responseInit);\n\t}\n}\n\nexport { Created };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAsB,EAAgB;CAMrC,YAAY,GAAiB,GAAY;EAQxC,AAPA,MAAM,GAEN,KAAK,OAAO,WACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,OAAO,KAAQ,KAAA,GAEpB,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,IAAI,GAAG,CAAY;CAC5D;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,MAAM,CAAY;CAC7C;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"found.js","names":[],"sources":["../../../../src/http/successResponses/found.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 302 Found
|
|
1
|
+
{"version":3,"file":"found.js","names":[],"sources":["../../../../src/http/successResponses/found.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 302 Found, the resource was located and the response includes it in the body.\n *\n * @example\n * ```typescript\n * return new Found(\"Products retrieved\", { products }).toJson();\n * ```\n */\nclass Found extends SuccessResponse {\n\t/**\n\t * @param message - Description included in the response status text.\n\t * @param body - Data to include in the response body.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, body?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Found\";\n\t\tthis.status = 302;\n\t\tthis.statusText = message;\n\t\tthis.body = body || undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.body), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.body, responseInit);\n\t}\n}\n\nexport { Found };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAoB,EAAgB;CAMnC,YAAY,GAAiB,GAAY;EAQxC,AAPA,MAAM,GAEN,KAAK,OAAO,SACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,OAAO,KAAQ,KAAA,GAEpB,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,IAAI,GAAG,CAAY;CAC5D;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,MAAM,CAAY;CAC7C;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noContent.js","names":[],"sources":["../../../../src/http/successResponses/noContent.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 204 No Content
|
|
1
|
+
{"version":3,"file":"noContent.js","names":[],"sources":["../../../../src/http/successResponses/noContent.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 204 No Content, the request succeeded but there is no content to return.\n * Typically used for delete or update operations where a body is not needed.\n *\n * @example\n * ```typescript\n * return new NoContent(\"Record deleted\").toResponse();\n * ```\n */\nclass NoContent extends SuccessResponse {\n\t/**\n\t * @param message - Description included in the response status text.\n\t */\n\tconstructor(message: string) {\n\t\tsuper();\n\n\t\tthis.name = \"NoContent\";\n\t\tthis.status = 204;\n\t\tthis.statusText = message;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header and no body. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(null, responseInit);\n\t}\n}\n\nexport { NoContent };\n"],"mappings":";;AAWA,IAAM,IAAN,cAAwB,EAAgB;CAIvC,YAAY,GAAiB;EAO5B,AANA,MAAM,GAEN,KAAK,OAAO,aACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAElB,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,MAAM,CAAY;CACvC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"success.js","names":[],"sources":["../../../../src/http/successResponses/success.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 200 OK
|
|
1
|
+
{"version":3,"file":"success.js","names":[],"sources":["../../../../src/http/successResponses/success.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 200 OK, the request succeeded and the response body contains the result.\n *\n * @example\n * ```typescript\n * return new Success(\"Order fetched\", { order }).toJson();\n * ```\n */\nclass Success extends SuccessResponse {\n\t/**\n\t * @param message - Description included in the response status text.\n\t * @param body - Data to include in the response body.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, body?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Success\";\n\t\tthis.status = 200;\n\t\tthis.statusText = message;\n\t\tthis.body = body || undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.body), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.body, responseInit);\n\t}\n}\n\nexport { Success };\n"],"mappings":";;AAUA,IAAM,IAAN,cAAsB,EAAgB;CAMrC,YAAY,GAAiB,GAAY;EAQxC,AAPA,MAAM,GAEN,KAAK,OAAO,WACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,OAAO,KAAQ,KAAA,GAEpB,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,IAAI,GAAG,CAAY;CAC5D;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,MAAM,CAAY;CAC7C;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updated.js","names":[],"sources":["../../../../src/http/successResponses/updated.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 200 OK
|
|
1
|
+
{"version":3,"file":"updated.js","names":[],"sources":["../../../../src/http/successResponses/updated.ts"],"sourcesContent":["import { SuccessResponse } from \"./_successResponse\";\n\n/**\n * HTTP 200 OK, the request succeeded and the resource was updated.\n * Semantically equivalent to `Success` but signals an update operation to consumers.\n *\n * @example\n * ```typescript\n * return new Updated(\"Profile updated\", { user }).toJson();\n * ```\n */\nclass Updated extends SuccessResponse {\n\t/**\n\t * @param message - Description included in the response status text.\n\t * @param body - Data to include in the response body.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tconstructor(message: string, body?: any) {\n\t\tsuper();\n\n\t\tthis.name = \"Updated\";\n\t\tthis.status = 200;\n\t\tthis.statusText = message;\n\t\tthis.body = body || undefined;\n\n\t\tthis.onDebug();\n\t}\n\n\t/** Converts to a `Response` with `Content-Type: application/json` header. */\n\ttoResponse(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn new Response(JSON.stringify(this.body), responseInit);\n\t}\n\n\t/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */\n\ttoJson(): Response {\n\t\tconst responseInit: ResponseInit = {\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t};\n\n\t\treturn Response.json(this.body, responseInit);\n\t}\n}\n\nexport { Updated };\n"],"mappings":";;AAWA,IAAM,IAAN,cAAsB,EAAgB;CAMrC,YAAY,GAAiB,GAAY;EAQxC,AAPA,MAAM,GAEN,KAAK,OAAO,WACZ,KAAK,SAAS,KACd,KAAK,aAAa,GAClB,KAAK,OAAO,KAAQ,KAAA,GAEpB,KAAK,QAAQ;CACd;CAGA,aAAuB;EACtB,IAAM,IAA6B;GAClC,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,IAAI,SAAS,KAAK,UAAU,KAAK,IAAI,GAAG,CAAY;CAC5D;CAGA,SAAmB;EAClB,IAAM,IAA6B;GAClC,QAAQ,KAAK;GACb,YAAY,KAAK;EAClB;EAEA,OAAO,SAAS,KAAK,KAAK,MAAM,CAAY;CAC7C;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugService.js","names":[],"sources":["../../../src/services/debugService.ts"],"sourcesContent":["import path from \"node:path\";\n\n/**\n * Manages stack-trace configuration for debug output, allowing specific adapter/wrapper files\n * to be skipped so logs show the actual business-logic caller.\n *\n * @example\n * ```typescript\n * // Skip httpAdapter.ts so debug output shows the calling route instead\n * DebugService.setIgnoreFile(\"httpAdapter.ts\");\n * ```\n */\n\nclass DebugService {\n\t/**\n\t * The name of the file to ignore when analyzing the stack trace.\n\t * When set, the `getCaller` function will skip stack frames containing this file name.\n\t */\n\tstatic ignoreFiles: string[] = [];\n\n\t/**\n\t * Adds a file name to the ignore list so it is skipped when resolving the caller in stack traces.\n\t *\n\t * @param file - File name to ignore (e.g. `\"httpAdapter.ts\"`).\n\t */\n\tstatic setIgnoreFile(file: string): void {\n\t\tDebugService.ignoreFiles.push(file);\n\t}\n\n\t/** Resets the ignore list, restoring full stack trace analysis. */\n\tstatic clearIgnoreFiles(): void {\n\t\tDebugService.ignoreFiles = [];\n\t}\n\n\t/**\n\t * Resolves the file path and function name of the code that triggered the current debug call,\n\t * skipping internal node modules and any files registered with `setIgnoreFile`.\n\t *\n\t * @returns `{ functionName, callerInfo }
|
|
1
|
+
{"version":3,"file":"debugService.js","names":[],"sources":["../../../src/services/debugService.ts"],"sourcesContent":["import path from \"node:path\";\n\n/**\n * Manages stack-trace configuration for debug output, allowing specific adapter/wrapper files\n * to be skipped so logs show the actual business-logic caller.\n *\n * @example\n * ```typescript\n * // Skip httpAdapter.ts so debug output shows the calling route instead\n * DebugService.setIgnoreFile(\"httpAdapter.ts\");\n * ```\n */\n\nclass DebugService {\n\t/**\n\t * The name of the file to ignore when analyzing the stack trace.\n\t * When set, the `getCaller` function will skip stack frames containing this file name.\n\t */\n\tstatic ignoreFiles: string[] = [];\n\n\t/**\n\t * Adds a file name to the ignore list so it is skipped when resolving the caller in stack traces.\n\t *\n\t * @param file - File name to ignore (e.g. `\"httpAdapter.ts\"`).\n\t */\n\tstatic setIgnoreFile(file: string): void {\n\t\tDebugService.ignoreFiles.push(file);\n\t}\n\n\t/** Resets the ignore list, restoring full stack trace analysis. */\n\tstatic clearIgnoreFiles(): void {\n\t\tDebugService.ignoreFiles = [];\n\t}\n\n\t/**\n\t * Resolves the file path and function name of the code that triggered the current debug call,\n\t * skipping internal node modules and any files registered with `setIgnoreFile`.\n\t *\n\t * @returns `{ functionName, callerInfo }`, caller function name and file path relative to `process.cwd()`.\n\t */\n\tstatic getCaller() {\n\t\tconst projectRoot = process.cwd();\n\n\t\tconst err = new Error();\n\t\tconst stack = err.stack || \"\";\n\t\tconst stackLines = stack.split(\"\\n\").map((line) => line.trim());\n\n\t\tlet callerIndex = 2;\n\n\t\twhile (\n\t\t\tcallerIndex < stackLines.length &&\n\t\t\t(stackLines[callerIndex].includes(\"node:internal\") ||\n\t\t\t\tstackLines[callerIndex].includes(\"/node_modules/\"))\n\t\t) {\n\t\t\tcallerIndex++;\n\t\t}\n\n\t\tif (DebugService.ignoreFiles.length > 0) {\n\t\t\twhile (\n\t\t\t\tcallerIndex < stackLines.length &&\n\t\t\t\tDebugService.ignoreFiles.some((ignoreFile) =>\n\t\t\t\t\tstackLines[callerIndex].includes(ignoreFile),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tcallerIndex++;\n\t\t\t}\n\t\t}\n\n\t\tconst callerLine = stackLines[callerIndex] || \"\";\n\n\t\tlet functionName = \"Unknown function\";\n\t\tlet callerInfo = \"Unknown caller\";\n\n\t\tconst namedFunctionMatch = callerLine.match(/at\\s+([^(\\s]+)\\s+\\(([^)]+)\\)/);\n\t\tif (namedFunctionMatch) {\n\t\t\tfunctionName = namedFunctionMatch[1];\n\t\t\tcallerInfo = namedFunctionMatch[2];\n\t\t} else {\n\t\t\tconst anonymousFunctionMatch = callerLine.match(/at\\s+(.+)/);\n\t\t\tif (anonymousFunctionMatch) {\n\t\t\t\tcallerInfo = anonymousFunctionMatch[1];\n\n\t\t\t\tconst objectMethodMatch = callerInfo.match(/at\\s+([^(\\s]+)\\s+/);\n\t\t\t\tif (objectMethodMatch && objectMethodMatch[1] !== \"new\") {\n\t\t\t\t\tfunctionName = objectMethodMatch[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (callerInfo.includes(\"(\")) {\n\t\t\tcallerInfo = callerInfo.substring(\n\t\t\t\tcallerInfo.indexOf(\"(\") + 1,\n\t\t\t\tcallerInfo.lastIndexOf(\")\"),\n\t\t\t);\n\t\t}\n\n\t\tcallerInfo = callerInfo.split(\":\").slice(0, -2).join(\":\");\n\n\t\ttry {\n\t\t\tcallerInfo = path.relative(projectRoot, callerInfo);\n\t\t} catch (_e) {}\n\n\t\treturn { functionName, callerInfo };\n\t}\n}\n\nexport { DebugService };\n"],"mappings":";;AAaA,IAAM,IAAN,MAAM,EAAa;CAKlB,OAAO,cAAwB,CAAC;CAOhC,OAAO,cAAc,GAAoB;EACxC,EAAa,YAAY,KAAK,CAAI;CACnC;CAGA,OAAO,mBAAyB;EAC/B,EAAa,cAAc,CAAC;CAC7B;CAQA,OAAO,YAAY;EAClB,IAAM,IAAc,QAAQ,IAAI,GAI1B,MADQ,gBADE,MACF,EAAA,CAAI,SAAS,GAAA,CACF,MAAM,IAAI,CAAC,CAAC,KAAK,MAAS,EAAK,KAAK,CAAC,GAE1D,IAAc;EAElB,OACC,IAAc,EAAW,WACxB,EAAW,EAAY,CAAC,SAAS,eAAe,KAChD,EAAW,EAAY,CAAC,SAAS,gBAAgB,KAElD;EAGD,IAAI,EAAa,YAAY,SAAS,GACrC,OACC,IAAc,EAAW,UACzB,EAAa,YAAY,MAAM,MAC9B,EAAW,EAAY,CAAC,SAAS,CAAU,CAC5C,IAEA;EAIF,IAAM,IAAa,EAAW,MAAgB,IAE1C,IAAe,oBACf,IAAa,kBAEX,IAAqB,EAAW,MAAM,8BAA8B;EAC1E,IAAI,GAEH,AADA,IAAe,EAAmB,IAClC,IAAa,EAAmB;OAC1B;GACN,IAAM,IAAyB,EAAW,MAAM,WAAW;GAC3D,IAAI,GAAwB;IAC3B,IAAa,EAAuB;IAEpC,IAAM,IAAoB,EAAW,MAAM,mBAAmB;IAC9D,AAAI,KAAqB,EAAkB,OAAO,UACjD,IAAe,EAAkB;GAEnC;EACD;EASA,AAPI,EAAW,SAAS,GAAG,MAC1B,IAAa,EAAW,UACvB,EAAW,QAAQ,GAAG,IAAI,GAC1B,EAAW,YAAY,GAAG,CAC3B,IAGD,IAAa,EAAW,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG;EAExD,IAAI;GACH,IAAa,EAAK,SAAS,GAAa,CAAU;EACnD,QAAa,CAAC;EAEd,OAAO;GAAE;GAAc;EAAW;CACnC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formAsyncParse.js","names":[],"sources":["../../../src/utilities/formAsyncParse.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\n\ntype SuccessResponse<T extends FormParseProps> = {\n\tsuccess: true;\n\tdata: T[1] extends ZodType<infer U> ? U : never;\n};\n\ntype ErrorResponse = {\n\tsuccess: false;\n\tfields: { [x: string]: string };\n\tfieldErrors: { [x: string]: string };\n};\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\ntype FormParseProps = [formData: { [k: string]: any }, schema: ZodType];\n\ntype FormParseReturnType<T extends FormParseProps> =\n\t| SuccessResponse<T>\n\t| ErrorResponse;\n\n/**\n * Async variant of `formParse
|
|
1
|
+
{"version":3,"file":"formAsyncParse.js","names":[],"sources":["../../../src/utilities/formAsyncParse.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\n\ntype SuccessResponse<T extends FormParseProps> = {\n\tsuccess: true;\n\tdata: T[1] extends ZodType<infer U> ? U : never;\n};\n\ntype ErrorResponse = {\n\tsuccess: false;\n\tfields: { [x: string]: string };\n\tfieldErrors: { [x: string]: string };\n};\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\ntype FormParseProps = [formData: { [k: string]: any }, schema: ZodType];\n\ntype FormParseReturnType<T extends FormParseProps> =\n\t| SuccessResponse<T>\n\t| ErrorResponse;\n\n/**\n * Async variant of `formParse`, uses `safeParseAsync` to support Zod schemas with async refinements.\n * Returns `{ success: true, data }` on success or `{ success: false, fieldErrors, fields }` on failure.\n *\n * @param formData - The raw form data object to validate.\n * @param schema - The Zod schema to validate against.\n *\n * @example\n * ```typescript\n * const schema = z.object({ email: z.string().email() });\n * const result = await formAsyncParse([{ email: \"bad\" }, schema]);\n *\n * if (!result.success) {\n * console.log(result.fieldErrors); // { email: \"Invalid email\" }\n * }\n * ```\n */\n\nasync function formAsyncParse<T extends FormParseProps>([\n\tformData,\n\tschema,\n]: T): Promise<FormParseReturnType<T>> {\n\tconst zodResponse = await schema.safeParseAsync(formData);\n\n\tif (zodResponse.success === false) {\n\t\tconst errorsObject = Object.fromEntries(\n\t\t\tzodResponse.error.issues.map((item) => {\n\t\t\t\treturn [item.path.join(\".\"), item.message];\n\t\t\t}),\n\t\t);\n\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tfieldErrors: errorsObject,\n\t\t\tfields: formData,\n\t\t};\n\t} else {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: zodResponse.data as T[1] extends ZodType<infer U> ? U : never,\n\t\t};\n\t}\n}\n\nexport { formAsyncParse };\n"],"mappings":";AAsCA,eAAe,EAAyC,CACvD,GACA,IACsC;CACtC,IAAM,IAAc,MAAM,EAAO,eAAe,CAAQ;CAevD,OAbG,EAAY,YAAY,KAOpB;EACN,SAAS;EACT,aARoB,OAAO,YAC3B,EAAY,MAAM,OAAO,KAAK,MACtB,CAAC,EAAK,KAAK,KAAK,GAAG,GAAG,EAAK,OAAO,CACzC,CAKY;EACb,QAAQ;CACT,IAEO;EACN,SAAS;EACT,MAAM,EAAY;CACnB;AAEF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaValidator.js","names":[],"sources":["../../../src/utilities/schemaValidator.ts"],"sourcesContent":["import type { ZodType, z } from \"zod\";\n\nimport { ServerError } from \"../http/badResponses/serverError\";\nimport { UnprocessableEntity } from \"../http/badResponses/unprocessableEntity\";\nimport { formAsyncParse } from \"./formAsyncParse\";\nimport { formParse } from \"./formParse\";\n\nfunction formatErrorMessage(error: z.ZodError) {\n\tconst title = \"Error validating:\";\n\tconst lines = error.issues.map(\n\t\t({ path, message }) => `-> ${path.join(\".\")}: ${message}`,\n\t);\n\n\treturn [title, ...lines].join(\"\\n\");\n}\n\n/**\n * Wraps a Zod schema with convenience validation methods suited for server-side use:\n * - `isValid
|
|
1
|
+
{"version":3,"file":"schemaValidator.js","names":[],"sources":["../../../src/utilities/schemaValidator.ts"],"sourcesContent":["import type { ZodType, z } from \"zod\";\n\nimport { ServerError } from \"../http/badResponses/serverError\";\nimport { UnprocessableEntity } from \"../http/badResponses/unprocessableEntity\";\nimport { formAsyncParse } from \"./formAsyncParse\";\nimport { formParse } from \"./formParse\";\n\nfunction formatErrorMessage(error: z.ZodError) {\n\tconst title = \"Error validating:\";\n\tconst lines = error.issues.map(\n\t\t({ path, message }) => `-> ${path.join(\".\")}: ${message}`,\n\t);\n\n\treturn [title, ...lines].join(\"\\n\");\n}\n\n/**\n * Wraps a Zod schema with convenience validation methods suited for server-side use:\n * - `isValid`, boolean check, no throws\n * - `safeValidate`, raw Zod result, no throws\n * - `validate`, throws `ServerError` on failure (for trusted/internal data)\n * - `formValidate` / `formAsyncValidate`, throws `UnprocessableEntity` on failure (for user-submitted forms)\n *\n * @example\n * ```typescript\n * const validator = new SchemaValidator(z.object({ email: z.string().email() }));\n *\n * // Inside a Remix action:\n * const body = validator.formValidate(await decodeRequestBody(request));\n * ```\n */\nclass SchemaValidator<T extends ZodType> {\n\t/**\n\t * @param schema - The Zod schema used for all validation methods on this instance.\n\t */\n\tconstructor(readonly schema: T) {}\n\n\t/**\n\t * Returns `true` if the data satisfies the schema, `false` otherwise. Never throws.\n\t *\n\t * @param data - The value to check.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tisValid(data: any): boolean {\n\t\treturn this.schema.safeParse(data).success;\n\t}\n\n\t/**\n\t * Validates data and returns the raw Zod `safeParseResult` without throwing.\n\t * Useful when you need access to the full error details.\n\t *\n\t * @param data - The value to validate.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tsafeValidate(data: any): z.ZodSafeParseResult<z.infer<T>> {\n\t\treturn this.schema.safeParse(data);\n\t}\n\n\t/**\n\t * Validates data and returns the typed result, throwing `ServerError` on failure.\n\t * Use for validating internal/trusted data (e.g. env vars, config objects).\n\t *\n\t * @param data - The value to validate.\n\t * @throws `ServerError` with a formatted field-by-field error message.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tvalidate(data: any): z.infer<T> {\n\t\ttry {\n\t\t\treturn this.schema.parse(data);\n\t\t} catch (error) {\n\t\t\tthrow new ServerError(formatErrorMessage(error as z.ZodError));\n\t\t}\n\t}\n\n\t/**\n\t * Validates form data and returns the typed result, throwing `UnprocessableEntity` on failure.\n\t * The error includes `fieldErrors`, `fields`, and `data.scrollTo` (first failing field name).\n\t *\n\t * @param data - The raw form data to validate.\n\t * @param message - Optional human-readable error message for the 422 response.\n\t * @throws `UnprocessableEntity` with structured field errors for client-side form handling.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validator = new SchemaValidator(registerSchema);\n\t * const body = validator.formValidate(await decodeRequestBody(request));\n\t * ```\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tformValidate(data: any, message?: string): z.infer<T> {\n\t\tconst formParsed = formParse([data, this.schema]);\n\n\t\tif (\"fieldErrors\" in formParsed) {\n\t\t\tconst firstErrorKey = Object.keys(formParsed.fieldErrors)[0];\n\n\t\t\tthrow new UnprocessableEntity({\n\t\t\t\tfields: formParsed.fields,\n\t\t\t\tfieldErrors: formParsed.fieldErrors,\n\t\t\t\tdata: { scrollTo: firstErrorKey },\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\n\t\treturn formParsed.data as z.infer<T>;\n\t}\n\n\t/**\n\t * Async version of `formValidate` for schemas with async refinements (e.g. uniqueness checks).\n\t *\n\t * @param data - The raw form data to validate.\n\t * @param message - Optional human-readable error message for the 422 response.\n\t * @throws `UnprocessableEntity` with structured field errors for client-side form handling.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validator = new SchemaValidator(registerSchema);\n\t * const body = await validator.formAsyncValidate(await decodeRequestBody(request));\n\t * ```\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tasync formAsyncValidate(data: any, message?: string): Promise<z.infer<T>> {\n\t\tconst formParsed = await formAsyncParse([data, this.schema]);\n\n\t\tif (\"fieldErrors\" in formParsed) {\n\t\t\tconst firstErrorKey = Object.keys(formParsed.fieldErrors)[0];\n\n\t\t\tthrow new UnprocessableEntity({\n\t\t\t\tfields: formParsed.fields,\n\t\t\t\tfieldErrors: formParsed.fieldErrors,\n\t\t\t\tdata: { scrollTo: firstErrorKey },\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\n\t\treturn formParsed.data as z.infer<T>;\n\t}\n}\n\nexport { SchemaValidator };\n"],"mappings":";;;;;AAOA,SAAS,EAAmB,GAAmB;CAM9C,OAAO,CAAC,qBAAO,GAJD,EAAM,OAAO,KACzB,EAAE,SAAM,iBAAc,MAAM,EAAK,KAAK,GAAG,EAAE,IAAI,GAG/B,CAAK,CAAC,CAAC,KAAK,IAAI;AACnC;AAiBA,IAAM,IAAN,MAAyC;CAInB;CAArB,YAAY,GAAoB;EAAX,KAAA,SAAA;CAAY;CAQjC,QAAQ,GAAoB;EAC3B,OAAO,KAAK,OAAO,UAAU,CAAI,CAAC,CAAC;CACpC;CASA,aAAa,GAA6C;EACzD,OAAO,KAAK,OAAO,UAAU,CAAI;CAClC;CAUA,SAAS,GAAuB;EAC/B,IAAI;GACH,OAAO,KAAK,OAAO,MAAM,CAAI;EAC9B,SAAS,GAAO;GACf,MAAM,IAAI,EAAY,EAAmB,CAAmB,CAAC;EAC9D;CACD;CAiBA,aAAa,GAAW,GAA8B;EACrD,IAAM,IAAa,EAAU,CAAC,GAAM,KAAK,MAAM,CAAC;EAEhD,IAAI,iBAAiB,GAAY;GAChC,IAAM,IAAgB,OAAO,KAAK,EAAW,WAAW,CAAC,CAAC;GAE1D,MAAM,IAAI,EAAoB;IAC7B,QAAQ,EAAW;IACnB,aAAa,EAAW;IACxB,MAAM,EAAE,UAAU,EAAc;IAChC;GACD,CAAC;EACF;EAEA,OAAO,EAAW;CACnB;CAgBA,MAAM,kBAAkB,GAAW,GAAuC;EACzE,IAAM,IAAa,MAAM,EAAe,CAAC,GAAM,KAAK,MAAM,CAAC;EAE3D,IAAI,iBAAiB,GAAY;GAChC,IAAM,IAAgB,OAAO,KAAK,EAAW,WAAW,CAAC,CAAC;GAE1D,MAAM,IAAI,EAAoB;IAC7B,QAAQ,EAAW;IACnB,aAAa,EAAW;IACxB,MAAM,EAAE,UAAU,EAAc;IAChC;GACD,CAAC;EACF;EAEA,OAAO,EAAW;CACnB;AACD"}
|
|
@@ -26,7 +26,7 @@ declare class DebugService {
|
|
|
26
26
|
* Resolves the file path and function name of the code that triggered the current debug call,
|
|
27
27
|
* skipping internal node modules and any files registered with `setIgnoreFile`.
|
|
28
28
|
*
|
|
29
|
-
* @returns `{ functionName, callerInfo }
|
|
29
|
+
* @returns `{ functionName, callerInfo }`, caller function name and file path relative to `process.cwd()`.
|
|
30
30
|
*/
|
|
31
31
|
static getCaller(): {
|
|
32
32
|
functionName: string;
|
|
@@ -17,7 +17,7 @@ type FormParseProps = [formData: {
|
|
|
17
17
|
}, schema: ZodType];
|
|
18
18
|
type FormParseReturnType<T extends FormParseProps> = SuccessResponse<T> | ErrorResponse;
|
|
19
19
|
/**
|
|
20
|
-
* Async variant of `formParse
|
|
20
|
+
* Async variant of `formParse`, uses `safeParseAsync` to support Zod schemas with async refinements.
|
|
21
21
|
* Returns `{ success: true, data }` on success or `{ success: false, fieldErrors, fields }` on failure.
|
|
22
22
|
*
|
|
23
23
|
* @param formData - The raw form data object to validate.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ZodType, z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Wraps a Zod schema with convenience validation methods suited for server-side use:
|
|
4
|
-
* - `isValid
|
|
5
|
-
* - `safeValidate
|
|
6
|
-
* - `validate
|
|
7
|
-
* - `formValidate` / `formAsyncValidate
|
|
4
|
+
* - `isValid`, boolean check, no throws
|
|
5
|
+
* - `safeValidate`, raw Zod result, no throws
|
|
6
|
+
* - `validate`, throws `ServerError` on failure (for trusted/internal data)
|
|
7
|
+
* - `formValidate` / `formAsyncValidate`, throws `UnprocessableEntity` on failure (for user-submitted forms)
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|