@floristcloud/api-lib 1.0.48 → 1.0.49

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,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./date.helper"), exports);
18
+ __exportStar(require("./zod.helper"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyStringToNull = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.emptyStringToNull = zod_1.z
6
+ .string()
7
+ .transform(val => (val === '' ? null : val))
8
+ .nullable();
package/build/index.js CHANGED
@@ -19,3 +19,4 @@ __exportStar(require("./schemas"), exports);
19
19
  __exportStar(require("./constant"), exports);
20
20
  __exportStar(require("./enum"), exports);
21
21
  __exportStar(require("./types"), exports);
22
+ __exportStar(require("./helpers"), exports);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpdateProductConfigurationRequestSchema = exports.CreateProductConfigurationRequestSchema = exports.ProductConfigurationSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const enum_1 = require("../../enum");
6
+ const helpers_1 = require("../../helpers");
6
7
  exports.ProductConfigurationSchema = zod_1.z.object({
7
8
  uuid: zod_1.z.uuid(),
8
9
  categoryUUID: zod_1.z.uuid(),
@@ -13,20 +14,22 @@ exports.ProductConfigurationSchema = zod_1.z.object({
13
14
  multiplicity: zod_1.z.coerce.number(),
14
15
  multiplicityDescription: zod_1.z.string().nullable(),
15
16
  });
16
- exports.CreateProductConfigurationRequestSchema = exports.ProductConfigurationSchema.pick({
17
- categoryUUID: true,
18
- country: true,
19
- grower: true,
20
- size: true,
21
- isOptional: true,
22
- multiplicity: true,
23
- multiplicityDescription: true,
17
+ exports.CreateProductConfigurationRequestSchema = zod_1.z.object({
18
+ categoryUUID: zod_1.z.uuid(),
19
+ country: helpers_1.emptyStringToNull,
20
+ grower: helpers_1.emptyStringToNull,
21
+ size: zod_1.z.coerce.number().nullable(),
22
+ isOptional: zod_1.z.coerce.boolean(),
23
+ multiplicity: zod_1.z.coerce.number(),
24
+ multiplicityDescription: helpers_1.emptyStringToNull,
24
25
  });
25
- exports.UpdateProductConfigurationRequestSchema = exports.ProductConfigurationSchema.pick({
26
- country: true,
27
- grower: true,
28
- size: true,
29
- isOptional: true,
30
- multiplicity: true,
31
- multiplicityDescription: true,
32
- }).partial();
26
+ exports.UpdateProductConfigurationRequestSchema = zod_1.z
27
+ .object({
28
+ country: helpers_1.emptyStringToNull,
29
+ grower: helpers_1.emptyStringToNull,
30
+ size: zod_1.z.coerce.number().nullable(),
31
+ isOptional: zod_1.z.coerce.boolean(),
32
+ multiplicity: zod_1.z.coerce.number(),
33
+ multiplicityDescription: helpers_1.emptyStringToNull,
34
+ })
35
+ .partial();
@@ -0,0 +1,2 @@
1
+ export * from './date.helper';
2
+ export * from './zod.helper';
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ export const emptyStringToNull = z
4
+ .string()
5
+ .transform(val => (val === '' ? null : val))
6
+ .nullable();
package/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './schemas';
3
3
  export * from './constant';
4
4
  export * from './enum';
5
5
  export * from './types';
6
+ export * from './helpers';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floristcloud/api-lib",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { CountryCodeEnum } from '../../enum';
3
+ import { emptyStringToNull } from '../../helpers';
3
4
 
4
5
  export const ProductConfigurationSchema = z.object({
5
6
  uuid: z.uuid(),
@@ -12,21 +13,23 @@ export const ProductConfigurationSchema = z.object({
12
13
  multiplicityDescription: z.string().nullable(),
13
14
  });
14
15
 
15
- export const CreateProductConfigurationRequestSchema = ProductConfigurationSchema.pick({
16
- categoryUUID: true,
17
- country: true,
18
- grower: true,
19
- size: true,
20
- isOptional: true,
21
- multiplicity: true,
22
- multiplicityDescription: true,
16
+ export const CreateProductConfigurationRequestSchema = z.object({
17
+ categoryUUID: z.uuid(),
18
+ country: emptyStringToNull,
19
+ grower: emptyStringToNull,
20
+ size: z.coerce.number().nullable(),
21
+ isOptional: z.coerce.boolean(),
22
+ multiplicity: z.coerce.number(),
23
+ multiplicityDescription: emptyStringToNull,
23
24
  });
24
25
 
25
- export const UpdateProductConfigurationRequestSchema = ProductConfigurationSchema.pick({
26
- country: true,
27
- grower: true,
28
- size: true,
29
- isOptional: true,
30
- multiplicity: true,
31
- multiplicityDescription: true,
32
- }).partial();
26
+ export const UpdateProductConfigurationRequestSchema = z
27
+ .object({
28
+ country: emptyStringToNull,
29
+ grower: emptyStringToNull,
30
+ size: z.coerce.number().nullable(),
31
+ isOptional: z.coerce.boolean(),
32
+ multiplicity: z.coerce.number(),
33
+ multiplicityDescription: emptyStringToNull,
34
+ })
35
+ .partial();