@alevnyacow/nzmt 0.0.4 → 0.0.6
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 +1 -23
- package/dist/index.cjs +15 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -2
- package/dist/rslib-runtime.js +37 -0
- package/dist/zod-controller.utils.d.ts +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Setup
|
|
4
|
-
|
|
5
|
-
Install the dependencies:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Get started
|
|
12
|
-
|
|
13
|
-
Build the library:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm run build
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Build the library in watch mode:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm run dev
|
|
23
|
-
```
|
|
1
|
+
# NZMT - Next Zod Modules Toolkit
|
package/dist/index.cjs
CHANGED
|
@@ -33,11 +33,17 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
Controller: ()=>zod_controller_utils_namespaceObject,
|
|
36
37
|
zodStoreMethodFactory: ()=>zodStoreMethodFactory,
|
|
37
|
-
zodAPIEndpointFactory: ()=>zodAPIEndpointFactory,
|
|
38
38
|
zodModuleMethodFactory: ()=>zodModuleMethodFactory,
|
|
39
39
|
RAMStore: ()=>store_ram_utils_RAMStore
|
|
40
40
|
});
|
|
41
|
+
var zod_controller_utils_namespaceObject = {};
|
|
42
|
+
__webpack_require__.r(zod_controller_utils_namespaceObject);
|
|
43
|
+
__webpack_require__.d(zod_controller_utils_namespaceObject, {
|
|
44
|
+
DefaultErrorCodes: ()=>zod_controller_utils_DefaultErrorCodes,
|
|
45
|
+
endpoints: ()=>endpoints
|
|
46
|
+
});
|
|
41
47
|
const external_uuid_namespaceObject = require("uuid");
|
|
42
48
|
const external_zod_namespaceObject = require("zod");
|
|
43
49
|
var external_zod_default = /*#__PURE__*/ __webpack_require__.n(external_zod_namespaceObject);
|
|
@@ -325,7 +331,12 @@ const store_ram_utils_RAMStore = (schemas, options)=>{
|
|
|
325
331
|
return RAMStore;
|
|
326
332
|
};
|
|
327
333
|
const server_namespaceObject = require("next/server");
|
|
328
|
-
|
|
334
|
+
var zod_controller_utils_DefaultErrorCodes = /*#__PURE__*/ function(DefaultErrorCodes) {
|
|
335
|
+
DefaultErrorCodes["REQUEST_PARSING"] = "ZOD-CONTROLLER___REQUEST-PARSING";
|
|
336
|
+
DefaultErrorCodes["RESPONSE_PARSING"] = "ZOD-CONTROLLER___RESPONSE-PARSING";
|
|
337
|
+
return DefaultErrorCodes;
|
|
338
|
+
}({});
|
|
339
|
+
const endpoints = (metadata, sharedConfig = {})=>{
|
|
329
340
|
const endpointLogic = (method, handler, configuration = {})=>async (request)=>{
|
|
330
341
|
let requestPayload = {};
|
|
331
342
|
const errorFactory = ErrorFactory.forController(metadata.name).inMethod(method);
|
|
@@ -485,13 +496,13 @@ const zodAPIEndpointFactory = (metadata, sharedConfig = {})=>{
|
|
|
485
496
|
};
|
|
486
497
|
return endpointLogic;
|
|
487
498
|
};
|
|
499
|
+
exports.Controller = __webpack_exports__.Controller;
|
|
488
500
|
exports.RAMStore = __webpack_exports__.RAMStore;
|
|
489
|
-
exports.zodAPIEndpointFactory = __webpack_exports__.zodAPIEndpointFactory;
|
|
490
501
|
exports.zodModuleMethodFactory = __webpack_exports__.zodModuleMethodFactory;
|
|
491
502
|
exports.zodStoreMethodFactory = __webpack_exports__.zodStoreMethodFactory;
|
|
492
503
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
504
|
+
"Controller",
|
|
493
505
|
"RAMStore",
|
|
494
|
-
"zodAPIEndpointFactory",
|
|
495
506
|
"zodModuleMethodFactory",
|
|
496
507
|
"zodStoreMethodFactory"
|
|
497
508
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { RAMStore } from './store/store.ram.utils';
|
|
2
2
|
export { zodStoreMethodFactory, type ZodStore, type ZodStoreMetadata } from './store/store.zod.utils';
|
|
3
|
-
export { zodAPIEndpointFactory, type ZodControllerMetadata, type ZodControllerAPI } from './zod-controller.utils';
|
|
4
3
|
export { zodModuleMethodFactory } from './zod-module.utils';
|
|
4
|
+
export * as Controller from './zod-controller.utils';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
2
|
import { v4 } from "uuid";
|
|
2
3
|
import zod from "zod";
|
|
3
4
|
import { NextResponse } from "next/server";
|
|
5
|
+
var zod_controller_utils_namespaceObject = {};
|
|
6
|
+
__webpack_require__.r(zod_controller_utils_namespaceObject);
|
|
7
|
+
__webpack_require__.d(zod_controller_utils_namespaceObject, {
|
|
8
|
+
DefaultErrorCodes: ()=>zod_controller_utils_DefaultErrorCodes,
|
|
9
|
+
endpoints: ()=>endpoints
|
|
10
|
+
});
|
|
4
11
|
class Pagination {
|
|
5
12
|
data;
|
|
6
13
|
static schema = zod.object({
|
|
@@ -284,7 +291,12 @@ const store_ram_utils_RAMStore = (schemas, options)=>{
|
|
|
284
291
|
}
|
|
285
292
|
return RAMStore;
|
|
286
293
|
};
|
|
287
|
-
|
|
294
|
+
var zod_controller_utils_DefaultErrorCodes = /*#__PURE__*/ function(DefaultErrorCodes) {
|
|
295
|
+
DefaultErrorCodes["REQUEST_PARSING"] = "ZOD-CONTROLLER___REQUEST-PARSING";
|
|
296
|
+
DefaultErrorCodes["RESPONSE_PARSING"] = "ZOD-CONTROLLER___RESPONSE-PARSING";
|
|
297
|
+
return DefaultErrorCodes;
|
|
298
|
+
}({});
|
|
299
|
+
const endpoints = (metadata, sharedConfig = {})=>{
|
|
288
300
|
const endpointLogic = (method, handler, configuration = {})=>async (request)=>{
|
|
289
301
|
let requestPayload = {};
|
|
290
302
|
const errorFactory = ErrorFactory.forController(metadata.name).inMethod(method);
|
|
@@ -444,4 +456,4 @@ const zodAPIEndpointFactory = (metadata, sharedConfig = {})=>{
|
|
|
444
456
|
};
|
|
445
457
|
return endpointLogic;
|
|
446
458
|
};
|
|
447
|
-
export { store_ram_utils_RAMStore as RAMStore,
|
|
459
|
+
export { store_ram_utils_RAMStore as RAMStore, zodModuleMethodFactory, zodStoreMethodFactory, zod_controller_utils_namespaceObject as Controller };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __webpack_module_cache__ = {};
|
|
2
|
+
function __webpack_require__(moduleId) {
|
|
3
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
4
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
5
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
6
|
+
exports: {}
|
|
7
|
+
};
|
|
8
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
9
|
+
return module.exports;
|
|
10
|
+
}
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
13
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: definition[key]
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
(()=>{
|
|
20
|
+
__webpack_require__.add = function(modules) {
|
|
21
|
+
Object.assign(__webpack_require__.m, modules);
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
export { __webpack_require__ };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import z, { type ZodObject } from 'zod';
|
|
3
3
|
import { type ControllerErrorModel, type ErrorBaseCreatingPayload } from './errors.utils';
|
|
4
|
-
export declare enum
|
|
4
|
+
export declare enum DefaultErrorCodes {
|
|
5
5
|
REQUEST_PARSING = "ZOD-CONTROLLER___REQUEST-PARSING",
|
|
6
6
|
RESPONSE_PARSING = "ZOD-CONTROLLER___RESPONSE-PARSING"
|
|
7
7
|
}
|
|
@@ -56,11 +56,11 @@ export type SharedConfig = Partial<{
|
|
|
56
56
|
guards: Guard[];
|
|
57
57
|
onErrorHandlers?: Array<OnErrorHandler>;
|
|
58
58
|
}>;
|
|
59
|
-
export declare const
|
|
59
|
+
export declare const endpoints: <T extends Schemas>(metadata: {
|
|
60
60
|
schemas: T;
|
|
61
61
|
name: string;
|
|
62
62
|
}, sharedConfig?: SharedConfig) => <Method extends keyof T>(method: Method, handler: EndpointLogic<T[Method]>["handler"], configuration?: Omit<EndpointLogic<T[Method]>, "handler">) => (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
63
|
-
type
|
|
63
|
+
type Schemas = Record<string, ZodAPISchemas>;
|
|
64
64
|
type Flatten<T extends Record<string, object>> = {
|
|
65
65
|
[K in keyof T]: T[K];
|
|
66
66
|
}[keyof T];
|
|
@@ -70,7 +70,7 @@ type SchemaShape = {
|
|
|
70
70
|
query?: unknown;
|
|
71
71
|
response?: unknown;
|
|
72
72
|
};
|
|
73
|
-
export type
|
|
73
|
+
export type Metadata<T = Schemas> = {
|
|
74
74
|
name: string;
|
|
75
75
|
schemas: T;
|
|
76
76
|
};
|
|
@@ -105,7 +105,7 @@ type ZodAPIMethod<Schemas extends {
|
|
|
105
105
|
response: SuccessResponse<Schemas['response']>;
|
|
106
106
|
error: ErrorResponse;
|
|
107
107
|
};
|
|
108
|
-
export type
|
|
108
|
+
export type API<Metadata extends {
|
|
109
109
|
schemas: Record<string, SchemaShape>;
|
|
110
110
|
}, CustomModels extends Record<string, unknown> | undefined = undefined> = {
|
|
111
111
|
endpoints: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Next Zod Modules Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "^5.9.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"next": "
|
|
36
|
+
"next": ">=13 <17"
|
|
37
37
|
},
|
|
38
38
|
"private": false,
|
|
39
39
|
"dependencies": {
|