hh-contracts 0.0.101 → 0.0.103

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.
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BooleanQueryParamSchema = void 0;
37
+ const z = __importStar(require("zod"));
38
+ // export const BooleanQueryParamSchema = z
39
+ // .union([z.boolean(), z.enum(['true', 'false', '1', '0', 'yes', 'no'])])
40
+ // .transform(value => {
41
+ // if (typeof value === 'boolean') return value;
42
+ // return value === 'true' || value === '1' || value === 'yes';
43
+ // });
44
+ exports.BooleanQueryParamSchema = z
45
+ .enum(['all', 'true', 'false', '1', '0', 'yes', 'no'])
46
+ .transform(value => {
47
+ if (value === 'all') {
48
+ return undefined;
49
+ }
50
+ return value === 'true' || value === '1' || value === 'yes';
51
+ });
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./boolean-query-param.schema"), exports);
17
18
  __exportStar(require("./common-query-params.schema"), exports);
18
19
  __exportStar(require("./icon-key.schema"), exports);
19
20
  __exportStar(require("./info.schema"), exports);
@@ -42,8 +42,8 @@ const BaseQuerySchema = role_models_1.RoleListItemSchema.pick({
42
42
  type: true,
43
43
  })
44
44
  .extend({
45
- isActive: z.coerce.boolean().optional(),
46
- permissionIds: z.array(z.uuid()).optional(),
45
+ isActive: common_1.BooleanQueryParamSchema.optional(),
46
+ permissionIds: common_1.UuidArraySchema.optional(),
47
47
  })
48
48
  .partial();
49
49
  const OrderBySchema = role_models_1.RoleListItemSchema.omit({
@@ -0,0 +1,17 @@
1
+ import * as z from 'zod';
2
+
3
+ // export const BooleanQueryParamSchema = z
4
+ // .union([z.boolean(), z.enum(['true', 'false', '1', '0', 'yes', 'no'])])
5
+ // .transform(value => {
6
+ // if (typeof value === 'boolean') return value;
7
+ // return value === 'true' || value === '1' || value === 'yes';
8
+ // });
9
+
10
+ export const BooleanQueryParamSchema = z
11
+ .enum(['all', 'true', 'false', '1', '0', 'yes', 'no'])
12
+ .transform(value => {
13
+ if (value === 'all') {
14
+ return undefined;
15
+ }
16
+ return value === 'true' || value === '1' || value === 'yes';
17
+ });
@@ -1,3 +1,4 @@
1
+ export * from './boolean-query-param.schema';
1
2
  export * from './common-query-params.schema';
2
3
  export * from './icon-key.schema';
3
4
  export * from './info.schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-contracts",
3
- "version": "0.0.101",
3
+ "version": "0.0.103",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,5 +1,11 @@
1
1
  import * as z from 'zod';
2
- import { HTTP_METHODS, CommonQueryParamsSchema, PaginationResponseSchema } from '../../common';
2
+ import {
3
+ HTTP_METHODS,
4
+ CommonQueryParamsSchema,
5
+ PaginationResponseSchema,
6
+ UuidArraySchema,
7
+ BooleanQueryParamSchema,
8
+ } from '../../common';
3
9
  import { RoleListItemSchema } from '../role.models';
4
10
  import { ROLES_API, ROLES_CONTROLLER } from '../roles.api';
5
11
 
@@ -7,8 +13,8 @@ const BaseQuerySchema = RoleListItemSchema.pick({
7
13
  type: true,
8
14
  })
9
15
  .extend({
10
- isActive: z.coerce.boolean().optional(),
11
- permissionIds: z.array(z.uuid()).optional(),
16
+ isActive: BooleanQueryParamSchema.optional(),
17
+ permissionIds: UuidArraySchema.optional(),
12
18
  })
13
19
  .partial();
14
20