inanis 0.0.7-beta.3 → 0.0.7-beta.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.
@@ -32,7 +32,6 @@ export declare class APIManager extends Event<Channels> {
32
32
  routers: Router[];
33
33
  constructor(params: Params);
34
34
  _injectInanis(inanis: Inanis): void;
35
- loadAll(routers?: Router<any, any, string, Record<string, any>, Record<string, any>>[]): Promise<void>;
36
35
  createRoute<Path extends string, Fails extends FailData, BeforeData, Headers extends string>(params: RouterParams<Path, Fails, Record<any, any>, BeforeData, Headers>): Router<Path, Fails, Headers, Record<any, any>, BeforeData>;
37
36
  eachMethods(cb: (_route: Router, _method: keyof Methods) => void): void;
38
37
  getRouter(path: string): Router<any, any, string, Record<string, any>, Record<string, any>>;
@@ -43,12 +42,12 @@ export declare class APIManager extends Event<Channels> {
43
42
  json: string;
44
43
  yaml: string;
45
44
  }>>;
46
- expressHandlers: () => Promise<{
45
+ expressHandlers: () => {
47
46
  path: string;
48
47
  method: string;
49
48
  handler: (..._args: any[]) => void;
50
- }[]>;
51
- lambdaHandler: () => Promise<Record<string, APIGatewayProxyHandler>>;
49
+ }[];
50
+ lambdaHandler: () => Record<string, APIGatewayProxyHandler>;
52
51
  serverlessFunctionsConfig: () => Promise<{
53
52
  json: string;
54
53
  yaml: string;
package/dist/api/index.js CHANGED
@@ -54,19 +54,6 @@ class APIManager extends power_helper_1.Event {
54
54
  inanis
55
55
  });
56
56
  }
57
- async loadAll(routers = this.routers) {
58
- let loadedFlag = false;
59
- while (!loadedFlag) {
60
- loadedFlag = true;
61
- for (let router of routers) {
62
- if (!router.loaded) {
63
- await router.load();
64
- await this.loadAll(router.children);
65
- loadedFlag = false;
66
- }
67
- }
68
- }
69
- }
70
57
  createRoute(params) {
71
58
  const route = new router_js_1.Router(this, params);
72
59
  this.routers.push(route);
@@ -122,7 +109,6 @@ class APIManager extends power_helper_1.Event {
122
109
  get outputs() {
123
110
  return {
124
111
  toTypes: async () => {
125
- await this.loadAll();
126
112
  const outputs = [];
127
113
  const openApi = await this.outputs.openApiDocument({ servers: [] });
128
114
  for (let doc in openApi) {
@@ -131,15 +117,13 @@ class APIManager extends power_helper_1.Event {
131
117
  return outputs.join('\n\n');
132
118
  },
133
119
  openApiDocument: async (params) => {
134
- await this.loadAll();
135
120
  const outputs = {};
136
121
  for (let router of this.routers) {
137
122
  outputs[router.name] = await (0, export_open_api_js_1.exportOpenApi)(router, params);
138
123
  }
139
124
  return outputs;
140
125
  },
141
- expressHandlers: async () => {
142
- await this.loadAll();
126
+ expressHandlers: () => {
143
127
  const output = [];
144
128
  this.eachMethods((route, method) => {
145
129
  let path = route.path.replace('{', ':').replace('}', '');
@@ -153,8 +137,8 @@ class APIManager extends power_helper_1.Event {
153
137
  });
154
138
  return output;
155
139
  },
156
- lambdaHandler: async () => {
157
- await this.loadAll();
140
+ // 不支援非同步
141
+ lambdaHandler: () => {
158
142
  const outputs = {};
159
143
  this.eachMethods((router, method) => {
160
144
  const group = getLambdaGroup(this, method, router.path);
@@ -177,7 +161,6 @@ class APIManager extends power_helper_1.Event {
177
161
  return outputs;
178
162
  },
179
163
  serverlessFunctionsConfig: async () => {
180
- await this.loadAll();
181
164
  const outputs = {};
182
165
  this.eachMethods((router, method) => {
183
166
  let group = getLambdaGroup(this, method, router.path);
@@ -1,40 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.Method = void 0;
37
- const Yup = __importStar(require("yup"));
4
+ const zod_1 = require("zod");
38
5
  const power_helper_1 = require("power-helper");
39
6
  const json_schema_js_1 = require("../utils/json-schema.js");
40
7
  const context_js_1 = require("./context.js");
@@ -339,18 +306,19 @@ class Method {
339
306
  });
340
307
  }
341
308
  if (this.verify.query) {
342
- const attrs = this.verify.query(Yup);
309
+ const attrs = this.verify.query(zod_1.z);
343
310
  for (let key in attrs) {
344
311
  const doc = docs.query?.[key] || {};
345
- const { spec, type } = attrs[key];
312
+ const schema = attrs[key];
313
+ const isOptional = schema.isOptional();
346
314
  output.parameters.push({
347
315
  in: 'query',
348
316
  name: key,
349
317
  description: doc.desc,
350
318
  example: doc.example,
351
- required: !spec.nullable,
319
+ required: !isOptional,
352
320
  schema: {
353
- type: type
321
+ type: 'string'
354
322
  }
355
323
  });
356
324
  }
@@ -374,7 +342,7 @@ class Method {
374
342
  }
375
343
  else {
376
344
  const doc = docs.body;
377
- const schema = bodySchemaBindDoc((0, json_schema_js_1.yupToJsonSchema)(this.verify.body), doc);
345
+ const schema = bodySchemaBindDoc((0, json_schema_js_1.zodToJsonSchema)(this.verify.body), doc);
378
346
  output.requestBody = {
379
347
  content: {
380
348
  [this.contentType]: {
@@ -424,11 +392,12 @@ class Method {
424
392
  }
425
393
  if (this.verify.response) {
426
394
  const doc = docs.response;
427
- const schema = bodySchemaBindDoc((0, json_schema_js_1.yupToJsonSchema)(yup => {
395
+ const jsonSchema = (0, json_schema_js_1.zodToJsonSchema)(z => {
428
396
  return {
429
- data: yup.object(this.verify.response(yup)).required()
397
+ data: z.object(this.verify.response(z)).required()
430
398
  };
431
- }), doc);
399
+ });
400
+ const schema = bodySchemaBindDoc(jsonSchema, doc);
432
401
  output.responses[200] = {
433
402
  description: 'Success',
434
403
  content: {
@@ -24,8 +24,6 @@ export type RouterParams<Path extends string, Fails extends FailData, ParentData
24
24
  };
25
25
  export declare class Router<Path extends string = any, Fails extends FailData = any, Headers extends string = string, ParentData = Record<string, any>, BeforeData = Record<string, any>> {
26
26
  tags: string[];
27
- loaded: boolean;
28
- loadCallback: (() => Promise<void>) | null;
29
27
  path: Path;
30
28
  manager: APIManager;
31
29
  before: (_data: any, _context: any) => Promise<BeforeData>;
@@ -41,8 +39,6 @@ export declare class Router<Path extends string = any, Fails extends FailData =
41
39
  get schema(): typeof definedValidateSchema;
42
40
  get nowAuthorizerExpression(): AuthorizerExpression | null;
43
41
  child<ChildPath extends `${Path}/${string}`, ChildBeforeData, ChildFails extends FailData, ChildHeaders extends string>(params: RouterParams<ChildPath, ChildFails, BeforeData, ChildBeforeData, ChildHeaders>): Router<ChildPath, ChildFails, ChildHeaders, BeforeData, ChildBeforeData>;
44
- onLoad(cb: (() => Promise<void>)): void;
45
- load(): Promise<void>;
46
42
  export(): Record<string, Router<any, any, string, Record<string, any>, Record<string, any>>>;
47
43
  deepEachChildren(callback: (_route: Router) => void | '_break'): any;
48
44
  getParents(): Router<any, any, string, Record<string, any>, Record<string, any>>[];
@@ -7,8 +7,6 @@ const validate_js_1 = require("../utils/validate.js");
7
7
  const string_js_1 = require("../utils/string.js");
8
8
  class Router {
9
9
  tags;
10
- loaded = false;
11
- loadCallback = null;
12
10
  path;
13
11
  manager;
14
12
  before;
@@ -56,15 +54,6 @@ class Router {
56
54
  router.parent = this;
57
55
  return router;
58
56
  }
59
- onLoad(cb) {
60
- this.loadCallback = cb;
61
- }
62
- async load() {
63
- this.loaded = true;
64
- if (this.loadCallback) {
65
- await this.loadCallback();
66
- }
67
- }
68
57
  export() {
69
58
  const output = {};
70
59
  const parse = (route) => {
@@ -1,4 +1,4 @@
1
- import * as Yup from 'yup';
1
+ import { z } from 'zod';
2
2
  import { Hook } from 'power-helper';
3
3
  import { TableManager, TableParams, Index } from './table.js';
4
4
  import type { MongoClient, Db } from 'mongodb';
@@ -30,9 +30,9 @@ export declare class DocumentDbManager<M extends Modes> extends Hook<Channels> {
30
30
  mongoClientDB?: Db;
31
31
  dynamoDbOptions: DynamoDbConfig | null;
32
32
  constructor(params: Params<M>);
33
- static defineSchema<T extends Yup.AnyObjectSchema>(schema: (_yup: typeof Yup) => T): () => T;
33
+ static defineSchema<T extends z.ZodObject<any>>(schema: (_z: typeof z) => T): () => T;
34
34
  _install(): Promise<void>;
35
- defineTable<T extends Yup.AnyObjectSchema, P extends T['__outputType'], EP extends P & {
35
+ defineTable<T extends z.ZodObject<any>, P extends z.infer<T>, EP extends P & {
36
36
  createdAt: number;
37
37
  updatedAt: number;
38
38
  expiredAt: number;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DocumentDbManager = void 0;
37
- const Yup = __importStar(require("yup"));
37
+ const zod_1 = require("zod");
38
38
  const change_case_1 = require("change-case");
39
39
  const power_helper_1 = require("power-helper");
40
40
  const output_js_1 = require("../utils/output.js");
@@ -53,7 +53,7 @@ class DocumentDbManager extends power_helper_1.Hook {
53
53
  this.params = params;
54
54
  }
55
55
  static defineSchema(schema) {
56
- return () => schema(Yup);
56
+ return () => schema(zod_1.z);
57
57
  }
58
58
  async _install() {
59
59
  const { mode, config } = await this.params.install();
@@ -126,10 +126,11 @@ class DocumentDbManager extends power_helper_1.Hook {
126
126
  continue;
127
127
  }
128
128
  const keys = [table.params.primaryKey];
129
- const schema = table.yupSchema;
129
+ const schema = table.zodSchema;
130
130
  const getKeyType = (key) => {
131
- if (schema.fields[key]) {
132
- return schema.fields[key].type === 'string' ? 'S' : 'N';
131
+ const field = schema.shape[key];
132
+ if (field) {
133
+ return field._def.typeName === 'ZodString' ? 'S' : 'N';
133
134
  }
134
135
  else {
135
136
  throw exception.create(`key ${key} not found in schema.`);
@@ -1,4 +1,4 @@
1
- import * as Yup from 'yup';
1
+ import { z } from 'zod';
2
2
  import { DynamoDbTable } from './table-dynamo.js';
3
3
  import { MongoCollection } from './table-mongo.js';
4
4
  import { TPick } from 'power-helper';
@@ -23,9 +23,9 @@ export type TableParams<T = any, ID = any, PK = any, SK = any> = {
23
23
  tableName: string;
24
24
  primaryKey: PK;
25
25
  secondaryKey: SK;
26
- schema: (_yup: typeof Yup) => T;
26
+ schema: (_z: typeof z) => T;
27
27
  };
28
- export declare class TableManager<T extends Yup.AnyObjectSchema, OP extends T['__outputType'], OEP extends P & {
28
+ export declare class TableManager<T extends z.ZodObject<any>, OP extends z.infer<T>, OEP extends OP & {
29
29
  createdAt: number;
30
30
  updatedAt: number;
31
31
  expiredAt: number;
@@ -38,7 +38,7 @@ export declare class TableManager<T extends Yup.AnyObjectSchema, OP extends T['_
38
38
  constructor(manager: DocumentDbManager<'dynamo' | 'mongo'>, params: TableParams<T, ID, PK, SK>);
39
39
  get _type(): EP;
40
40
  get _putType(): P;
41
- get yupSchema(): T;
41
+ get zodSchema(): T;
42
42
  _connect(): void;
43
43
  get(primary: Key, secondary: Key): Promise<EP>;
44
44
  scan(options: Omit<ListOptions, 'forward'>): Promise<{
@@ -1,40 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.TableManager = void 0;
37
- const Yup = __importStar(require("yup"));
4
+ const zod_1 = require("zod");
38
5
  const exception_js_1 = require("../exception.js");
39
6
  const table_dynamo_js_1 = require("./table-dynamo.js");
40
7
  const table_mongo_js_1 = require("./table-mongo.js");
@@ -47,7 +14,7 @@ class TableManager {
47
14
  mongoDbCollection;
48
15
  constructor(manager, params) {
49
16
  this.params = params;
50
- this.schema = params.schema(Yup);
17
+ this.schema = params.schema(zod_1.z);
51
18
  this.manager = manager;
52
19
  }
53
20
  get _type() {
@@ -56,8 +23,8 @@ class TableManager {
56
23
  get _putType() {
57
24
  return null;
58
25
  }
59
- get yupSchema() {
60
- return this.params.schema(Yup);
26
+ get zodSchema() {
27
+ return this.params.schema(zod_1.z);
61
28
  }
62
29
  _connect() {
63
30
  if (this.manager.mode === 'mongo') {
@@ -127,7 +94,8 @@ class TableManager {
127
94
  }
128
95
  async update(primary, secondary, data) {
129
96
  for (let key in data) {
130
- this.schema.validateSyncAt(key, data);
97
+ const partialSchema = this.schema.pick({ [key]: true });
98
+ partialSchema.parse({ [key]: data[key] });
131
99
  }
132
100
  if (this.manager.mode === 'mongo') {
133
101
  await this.mongoDbCollection.update(primary, secondary, data);
@@ -137,8 +105,7 @@ class TableManager {
137
105
  }
138
106
  }
139
107
  async replace(primary, secondary, data) {
140
- let cast = this.schema.cast(data);
141
- this.schema.validateSync(cast);
108
+ let cast = this.schema.parse(data);
142
109
  if (this.manager.mode === 'mongo') {
143
110
  let result = await this.mongoDbCollection.replace(primary, secondary, cast);
144
111
  return result;
@@ -149,8 +116,7 @@ class TableManager {
149
116
  }
150
117
  }
151
118
  async put(data) {
152
- let cast = this.schema.cast(data);
153
- this.schema.validateSync(cast);
119
+ let cast = this.schema.parse(data);
154
120
  if (this.manager.mode === 'mongo') {
155
121
  let result = await this.mongoDbCollection.put(cast);
156
122
  return result;
@@ -161,8 +127,7 @@ class TableManager {
161
127
  }
162
128
  }
163
129
  async putForce(data) {
164
- let cast = this.schema.cast(data);
165
- this.schema.validateSync(cast);
130
+ let cast = this.schema.parse(data);
166
131
  if (this.manager.mode === 'mongo') {
167
132
  await this.mongoDbCollection.putForce(cast);
168
133
  }
@@ -3,6 +3,7 @@ export declare class DataModelConfig<T extends TableManager<any, any, any, any,
3
3
  table: T;
4
4
  defData: DefData;
5
5
  publicKeys: PublicKey[];
6
+ publicKeyMaps: Record<PublicKey, true>;
6
7
  _initData: Omit<T['_putType'], keyof ReturnType<DefData>> & Partial<T['_putType']>;
7
8
  constructor(params: {
8
9
  table: T;
@@ -6,11 +6,13 @@ class DataModelConfig {
6
6
  table;
7
7
  defData;
8
8
  publicKeys;
9
+ publicKeyMaps = {};
9
10
  _initData = null;
10
11
  constructor(params) {
11
12
  this.table = params.table;
12
13
  this.defData = params.defData;
13
14
  this.publicKeys = params.publicKeys;
15
+ this.publicKeyMaps = Object.fromEntries(this.publicKeys.map(k => [k, true]));
14
16
  }
15
17
  newData(data) {
16
18
  return {
@@ -1,4 +1,4 @@
1
- import { convertSchema } from '@sodaru/yup-to-json-schema';
1
+ import { z } from 'zod';
2
2
  import { ValidateCallback } from './validate.js';
3
- export type JsonSchema = ReturnType<typeof convertSchema>;
4
- export declare const yupToJsonSchema: (cb: ValidateCallback<any>) => import("json-schema").JSONSchema7;
3
+ export declare const zodToJsonSchema: (cb: ValidateCallback<any>) => z.core.JSONSchema.JSONSchema;
4
+ export type JsonSchema = ReturnType<typeof zodToJsonSchema>;
@@ -1,42 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.yupToJsonSchema = void 0;
37
- const Yup = __importStar(require("yup"));
38
- const yup_to_json_schema_1 = require("@sodaru/yup-to-json-schema");
39
- const yupToJsonSchema = (cb) => {
40
- return (0, yup_to_json_schema_1.convertSchema)(Yup.object(cb(Yup)));
3
+ exports.zodToJsonSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const zodToJsonSchema = (cb) => {
6
+ return (0, zod_1.toJSONSchema)(zod_1.z.object(cb(zod_1.z)));
41
7
  };
42
- exports.yupToJsonSchema = yupToJsonSchema;
8
+ exports.zodToJsonSchema = zodToJsonSchema;
@@ -1,11 +1,11 @@
1
- import * as Yup from 'yup';
1
+ import { z } from 'zod';
2
2
  import { DeepRequired } from '../types.js';
3
- import type { Schema, InferType } from 'yup';
4
- export type ValidateCallback<T extends Record<string, Schema>> = (_yup: typeof Yup) => {
3
+ import type { ZodType } from 'zod';
4
+ export type ValidateCallback<T extends Record<string, ZodType>> = (_z: typeof z) => {
5
5
  [K in keyof T]: T[K];
6
6
  };
7
7
  export type ValidateCallbackOutputs<T extends ValidateCallback<any>, R = ReturnType<T>> = {
8
- [K in keyof R]: R[K] extends Schema ? DeepRequired<InferType<R[K]>> : unknown;
8
+ [K in keyof R]: R[K] extends ZodType ? DeepRequired<z.infer<R[K]>> : unknown;
9
9
  };
10
10
  export declare function definedValidateSchema<T extends ValidateCallback<any>>(cb: T): T;
11
- export declare function validate<T extends ValidateCallback<any>, R = ReturnType<T>>(target: any, schemaCallback: T): { [K in keyof R]: R[K] extends Schema ? DeepRequired<InferType<R[K]>> : unknown; };
11
+ export declare function validate<T extends ValidateCallback<any>, R = ReturnType<T>>(target: any, schemaCallback: T): { [K in keyof R]: R[K] extends ZodType ? DeepRequired<z.infer<R[K]>> : unknown; };
@@ -1,44 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.definedValidateSchema = definedValidateSchema;
37
4
  exports.validate = validate;
38
- const Yup = __importStar(require("yup"));
5
+ const zod_1 = require("zod");
39
6
  function definedValidateSchema(cb) {
40
7
  return cb;
41
8
  }
42
9
  function validate(target, schemaCallback) {
43
- return Yup.object(schemaCallback(Yup)).required().validateSync(target || {});
10
+ return zod_1.z.object(schemaCallback(zod_1.z)).required().parse(target || {});
44
11
  }
@@ -31,7 +31,7 @@ export declare class WebsocketManager<M extends Modes> {
31
31
  mode: Modes;
32
32
  params: Params<M>;
33
33
  inanis: Inanis | null;
34
- emiters: Emitter<any, any>[];
34
+ emitters: Emitter<any, any>[];
35
35
  nodeWebsocket: WebSocketServer | null;
36
36
  nodeWebsocketClientPool: Map<string, WebSocketServerRequest>;
37
37
  constructor(params: Params<M>);
@@ -43,7 +43,7 @@ class WebsocketManager {
43
43
  mode;
44
44
  params;
45
45
  inanis = null;
46
- emiters = [];
46
+ emitters = [];
47
47
  nodeWebsocket = null;
48
48
  nodeWebsocketClientPool = new Map();
49
49
  constructor(params) {
@@ -116,9 +116,9 @@ class WebsocketManager {
116
116
  }
117
117
  }
118
118
  createEmitter(name, params) {
119
- const emiter = new emitter_js_1.Emitter(this, name, params);
120
- this.emiters.push(emiter);
121
- return emiter;
119
+ const emitter = new emitter_js_1.Emitter(this, name, params);
120
+ this.emitters.push(emitter);
121
+ return emitter;
122
122
  }
123
123
  // =================
124
124
  //
@@ -132,11 +132,11 @@ class WebsocketManager {
132
132
  required: [],
133
133
  properties: {}
134
134
  };
135
- for (let emiter of this.emiters) {
135
+ for (let emitter of this.emitters) {
136
136
  if (Array.isArray(tsData.required)) {
137
- tsData.required.push(emiter.name);
137
+ tsData.required.push(emitter.name);
138
138
  }
139
- tsData.properties[emiter.name] = (0, json_schema_js_1.yupToJsonSchema)(emiter.params.sendSchema);
139
+ tsData.properties[emitter.name] = (0, json_schema_js_1.zodToJsonSchema)(emitter.params.sendSchema);
140
140
  }
141
141
  try {
142
142
  const { js: jsBeautify } = await Promise.resolve().then(() => __importStar(require('js-beautify')));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inanis",
3
- "version": "0.0.7-beta.3",
3
+ "version": "0.0.7-beta.5",
4
4
  "description": "Micro Service Best Tools.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -53,7 +53,6 @@
53
53
  "@aws-sdk/credential-provider-node": "^3.848.0",
54
54
  "@aws-sdk/lib-dynamodb": "^3.850.0",
55
55
  "@aws-sdk/s3-request-presigner": "^3.850.0",
56
- "@sodaru/yup-to-json-schema": "^2.0.1",
57
56
  "amqplib": "^0.10.8",
58
57
  "axios": "^1.11.0",
59
58
  "change-case": "^5.4.4",
@@ -74,7 +73,7 @@
74
73
  "redis": "^5.6.1",
75
74
  "websocket": "^1.0.35",
76
75
  "yaml": "^2.8.0",
77
- "yup": "^1.6.1"
76
+ "zod": "^4.1.12"
78
77
  },
79
78
  "packageManager": "yarn@4.1.1"
80
79
  }