hh-contracts 0.0.104 → 0.0.106

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,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ARRAY_SPLITTER = void 0;
4
+ exports.ARRAY_SPLITTER = ',';
@@ -8,6 +8,7 @@ exports.ICON_KEYS = {
8
8
  chevronRight: 'chevronRight',
9
9
  arrowDown: 'arrowDown',
10
10
  arrowUp: 'arrowUp',
11
+ arrowLeft: 'arrowLeft',
11
12
  ellipsis: 'ellipsis',
12
13
  plus: 'plus',
13
14
  moon: 'moon',
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./app-ability.constant"), exports);
18
+ __exportStar(require("./array-splitter.constant"), exports);
18
19
  __exportStar(require("./app-errors.constant"), exports);
19
20
  __exportStar(require("./app-statuses.constant"), exports);
20
21
  __exportStar(require("./default-pagination-config.constant"), exports);
@@ -35,17 +35,12 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.BooleanQueryParamSchema = void 0;
37
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 === 'true' || value === '1' || value === 'yes')
38
+ exports.BooleanQueryParamSchema = z.union([z.boolean(), z.string()]).transform(value => {
39
+ if (typeof value === 'boolean')
40
+ return value;
41
+ const v = value.trim().toLowerCase();
42
+ if (v === 'true' || v === '1' || v === 'yes')
48
43
  return true;
49
- if (value === 'false' || value === '0' || value === 'no')
44
+ if (v === 'false' || v === '0' || v === 'no')
50
45
  return false;
51
46
  });
@@ -33,7 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.UuidArraySchema = exports.UuidSchema = void 0;
36
+ exports.UuidArrayQueryParamSchema = exports.UuidArraySchema = exports.UuidSchema = void 0;
37
37
  const z = __importStar(require("zod"));
38
+ const constants_1 = require("../constants");
38
39
  exports.UuidSchema = z.uuid();
39
40
  exports.UuidArraySchema = z.array(exports.UuidSchema);
41
+ exports.UuidArrayQueryParamSchema = z
42
+ .union([z.string().transform(val => (val ? val.split(constants_1.ARRAY_SPLITTER) : [])), z.array(z.string())])
43
+ .pipe(exports.UuidArraySchema);
@@ -43,7 +43,7 @@ const BaseQuerySchema = role_models_1.RoleListItemSchema.pick({
43
43
  })
44
44
  .extend({
45
45
  isActive: common_1.BooleanQueryParamSchema.optional(),
46
- permissionIds: common_1.UuidArraySchema.optional(),
46
+ permissionIds: common_1.UuidArrayQueryParamSchema.optional(),
47
47
  })
48
48
  .partial();
49
49
  const OrderBySchema = role_models_1.RoleListItemSchema.omit({
@@ -0,0 +1 @@
1
+ export const ARRAY_SPLITTER = ',';
@@ -5,6 +5,7 @@ export const ICON_KEYS = {
5
5
  chevronRight: 'chevronRight',
6
6
  arrowDown: 'arrowDown',
7
7
  arrowUp: 'arrowUp',
8
+ arrowLeft: 'arrowLeft',
8
9
  ellipsis: 'ellipsis',
9
10
  plus: 'plus',
10
11
  moon: 'moon',
@@ -1,4 +1,5 @@
1
1
  export * from './app-ability.constant';
2
+ export * from './array-splitter.constant';
2
3
  export * from './app-errors.constant';
3
4
  export * from './app-statuses.constant';
4
5
  export * from './default-pagination-config.constant';
@@ -1,15 +1,8 @@
1
1
  import * as z from 'zod';
2
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 === 'true' || value === '1' || value === 'yes') return true;
14
- if (value === 'false' || value === '0' || value === 'no') return false;
15
- });
3
+ export const BooleanQueryParamSchema = z.union([z.boolean(), z.string()]).transform(value => {
4
+ if (typeof value === 'boolean') return value;
5
+ const v = value.trim().toLowerCase();
6
+ if (v === 'true' || v === '1' || v === 'yes') return true;
7
+ if (v === 'false' || v === '0' || v === 'no') return false;
8
+ });
@@ -1,4 +1,9 @@
1
1
  import * as z from 'zod';
2
+ import { ARRAY_SPLITTER } from '../constants';
2
3
 
3
4
  export const UuidSchema = z.uuid();
4
5
  export const UuidArraySchema = z.array(UuidSchema);
6
+
7
+ export const UuidArrayQueryParamSchema = z
8
+ .union([z.string().transform(val => (val ? val.split(ARRAY_SPLITTER) : [])), z.array(z.string())])
9
+ .pipe(UuidArraySchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-contracts",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -5,6 +5,7 @@ import {
5
5
  PaginationResponseSchema,
6
6
  UuidArraySchema,
7
7
  BooleanQueryParamSchema,
8
+ UuidArrayQueryParamSchema,
8
9
  } from '../../common';
9
10
  import { RoleListItemSchema } from '../role.models';
10
11
  import { ROLES_API, ROLES_CONTROLLER } from '../roles.api';
@@ -14,7 +15,7 @@ const BaseQuerySchema = RoleListItemSchema.pick({
14
15
  })
15
16
  .extend({
16
17
  isActive: BooleanQueryParamSchema.optional(),
17
- permissionIds: UuidArraySchema.optional(),
18
+ permissionIds: UuidArrayQueryParamSchema.optional(),
18
19
  })
19
20
  .partial();
20
21
 
@@ -41,7 +42,7 @@ export namespace FindManyRolesContract {
41
42
  export const httpMethod = HTTP_METHODS.get;
42
43
 
43
44
  export const BaseFilterSchema = BaseQuerySchema;
44
- export type TBaseFilter = z.infer<typeof BaseFilterSchema>;
45
+ export type TBaseFilter = z.input<typeof BaseFilterSchema>;
45
46
 
46
47
  export const SORTING_KEYS = OrderBySchema.options;
47
48
  export type TSortingKey = z.infer<typeof OrderBySchema>;