@voiceflow/common 8.5.0 → 8.7.0
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/build/cjs/dtos/json.dto.d.ts +13 -0
- package/build/cjs/dtos/json.dto.d.ts.map +1 -0
- package/build/cjs/dtos/json.dto.js +17 -0
- package/build/cjs/dtos/main.d.ts +2 -0
- package/build/cjs/dtos/main.d.ts.map +1 -0
- package/build/cjs/dtos/main.js +17 -0
- package/build/cjs/utils/variables.d.ts +3 -1
- package/build/cjs/utils/variables.d.ts.map +1 -1
- package/build/cjs/utils/variables.js +3 -3
- package/build/esm/dtos/json.dto.d.ts +13 -0
- package/build/esm/dtos/json.dto.d.ts.map +1 -0
- package/build/esm/dtos/json.dto.js +13 -0
- package/build/esm/dtos/main.d.ts +2 -0
- package/build/esm/dtos/main.d.ts.map +1 -0
- package/build/esm/dtos/main.js +1 -0
- package/build/esm/utils/variables.d.ts +3 -1
- package/build/esm/utils/variables.d.ts.map +1 -1
- package/build/esm/utils/variables.js +3 -3
- package/package.json +31 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copied from the implementation found in `@nest-zod/z` since it recommended to migrate to bare `zod`
|
|
3
|
+
* https://github.com/BenLorantfy/nestjs-zod/blob/main/packages/z/src/z/generic-types/json.ts
|
|
4
|
+
*/
|
|
5
|
+
import type { ZodSchema } from 'zod';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
type Literal = boolean | number | string;
|
|
8
|
+
export type JSON = Literal | {
|
|
9
|
+
[key: string]: JSON;
|
|
10
|
+
} | JSON[];
|
|
11
|
+
export declare const zJSON: (message?: string) => ZodSchema<JSON, z.ZodTypeDef, JSON>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=json.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.dto.d.ts","sourceRoot":"","sources":["../../../src/dtos/json.dto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,EAAE,CAAC;AAM9D,eAAO,MAAM,KAAK,aAAa,MAAM,wCAQpC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copied from the implementation found in `@nest-zod/z` since it recommended to migrate to bare `zod`
|
|
4
|
+
* https://github.com/BenLorantfy/nestjs-zod/blob/main/packages/z/src/z/generic-types/json.ts
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.zJSON = void 0;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const literal = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean()]);
|
|
10
|
+
const DEFAULT_MESSAGE = 'Expected value to be a JSON-serializable';
|
|
11
|
+
const zJSON = (message = DEFAULT_MESSAGE) => {
|
|
12
|
+
const schema = zod_1.z.lazy(() => zod_1.z.union([literal, zod_1.z.array(schema), zod_1.z.record(schema)], {
|
|
13
|
+
invalid_type_error: message,
|
|
14
|
+
}));
|
|
15
|
+
return schema;
|
|
16
|
+
};
|
|
17
|
+
exports.zJSON = zJSON;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/dtos/main.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./json.dto"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const variableReplacer: (match: string, inner: string, variables: Record<string, unknown>, modifier?: (variable: unknown) => unknown) => unknown;
|
|
2
|
-
export declare const splitVariableName: (inner: string
|
|
2
|
+
export declare const splitVariableName: (inner: string, options?: {
|
|
3
|
+
pathWithDotPrefix: boolean;
|
|
4
|
+
}) => {
|
|
3
5
|
id: string;
|
|
4
6
|
path: string;
|
|
5
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/utils/variables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,UACpB,MAAM,SACN,MAAM,aACF,OAAO,MAAM,EAAE,OAAO,CAAC,aACvB,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,KACxC,OAmBF,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/utils/variables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,UACpB,MAAM,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exports.variableReplacer = variableReplacer;
|
|
29
|
-
const splitVariableName = (inner) => {
|
|
29
|
+
const splitVariableName = (inner, options = { pathWithDotPrefix: false }) => {
|
|
30
30
|
const firstDotIndex = inner.indexOf('.');
|
|
31
31
|
const firstSquareBracketIndex = inner.indexOf('[');
|
|
32
32
|
if (firstDotIndex === -1 && firstSquareBracketIndex === -1) {
|
|
@@ -35,7 +35,7 @@ const splitVariableName = (inner) => {
|
|
|
35
35
|
if (firstDotIndex !== -1 && firstSquareBracketIndex === -1) {
|
|
36
36
|
return {
|
|
37
37
|
id: inner.slice(0, firstDotIndex),
|
|
38
|
-
path: inner.slice(firstDotIndex + 1),
|
|
38
|
+
path: options.pathWithDotPrefix ? inner.slice(firstDotIndex) : inner.slice(firstDotIndex + 1),
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
if (firstDotIndex === -1 && firstSquareBracketIndex !== -1) {
|
|
@@ -47,7 +47,7 @@ const splitVariableName = (inner) => {
|
|
|
47
47
|
if (firstDotIndex < firstSquareBracketIndex) {
|
|
48
48
|
return {
|
|
49
49
|
id: inner.slice(0, firstDotIndex),
|
|
50
|
-
path: inner.slice(firstDotIndex + 1),
|
|
50
|
+
path: options.pathWithDotPrefix ? inner.slice(firstDotIndex) : inner.slice(firstDotIndex + 1),
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copied from the implementation found in `@nest-zod/z` since it recommended to migrate to bare `zod`
|
|
3
|
+
* https://github.com/BenLorantfy/nestjs-zod/blob/main/packages/z/src/z/generic-types/json.ts
|
|
4
|
+
*/
|
|
5
|
+
import type { ZodSchema } from 'zod';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
type Literal = boolean | number | string;
|
|
8
|
+
export type JSON = Literal | {
|
|
9
|
+
[key: string]: JSON;
|
|
10
|
+
} | JSON[];
|
|
11
|
+
export declare const zJSON: (message?: string) => ZodSchema<JSON, z.ZodTypeDef, JSON>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=json.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.dto.d.ts","sourceRoot":"","sources":["../../../src/dtos/json.dto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,EAAE,CAAC;AAM9D,eAAO,MAAM,KAAK,aAAa,MAAM,wCAQpC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copied from the implementation found in `@nest-zod/z` since it recommended to migrate to bare `zod`
|
|
3
|
+
* https://github.com/BenLorantfy/nestjs-zod/blob/main/packages/z/src/z/generic-types/json.ts
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const literal = z.union([z.string(), z.number(), z.boolean()]);
|
|
7
|
+
const DEFAULT_MESSAGE = 'Expected value to be a JSON-serializable';
|
|
8
|
+
export const zJSON = (message = DEFAULT_MESSAGE) => {
|
|
9
|
+
const schema = z.lazy(() => z.union([literal, z.array(schema), z.record(schema)], {
|
|
10
|
+
invalid_type_error: message,
|
|
11
|
+
}));
|
|
12
|
+
return schema;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/dtos/main.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './json.dto.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const variableReplacer: (match: string, inner: string, variables: Record<string, unknown>, modifier?: (variable: unknown) => unknown) => unknown;
|
|
2
|
-
export declare const splitVariableName: (inner: string
|
|
2
|
+
export declare const splitVariableName: (inner: string, options?: {
|
|
3
|
+
pathWithDotPrefix: boolean;
|
|
4
|
+
}) => {
|
|
3
5
|
id: string;
|
|
4
6
|
path: string;
|
|
5
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/utils/variables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,UACpB,MAAM,SACN,MAAM,aACF,OAAO,MAAM,EAAE,OAAO,CAAC,aACvB,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,KACxC,OAmBF,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/utils/variables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,UACpB,MAAM,SACN,MAAM,aACF,OAAO,MAAM,EAAE,OAAO,CAAC,aACvB,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,KACxC,OAmBF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UACrB,MAAM,YACJ;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAE;;;CAiCxC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,EACzC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,sBAAsB,CAAC,EAAE,KAAK,CAAA;CAAE,GAC3D,MAAM,CAAC;AACV,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,EACzC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,sBAAsB,EAAE,IAAI,CAAA;CAAE,GACzD,OAAO,CAAC;AAuBX,eAAO,MAAM,iBAAiB,cAAe,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,MAAM,EAAE,OAAO,CASrF,CAAC;AAET,eAAO,MAAM,+BAA+B,QAAS,MAAM,GAAG,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,MAAM,GAAG,IAY/F,CAAC;AAEF,eAAO,MAAM,wBAAwB,gBAAiB,CAAC,eAAe,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,CA2B/F,CAAC"}
|
|
@@ -19,7 +19,7 @@ export const variableReplacer = (match, inner, variables, modifier) => {
|
|
|
19
19
|
throw err;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
export const splitVariableName = (inner) => {
|
|
22
|
+
export const splitVariableName = (inner, options = { pathWithDotPrefix: false }) => {
|
|
23
23
|
const firstDotIndex = inner.indexOf('.');
|
|
24
24
|
const firstSquareBracketIndex = inner.indexOf('[');
|
|
25
25
|
if (firstDotIndex === -1 && firstSquareBracketIndex === -1) {
|
|
@@ -28,7 +28,7 @@ export const splitVariableName = (inner) => {
|
|
|
28
28
|
if (firstDotIndex !== -1 && firstSquareBracketIndex === -1) {
|
|
29
29
|
return {
|
|
30
30
|
id: inner.slice(0, firstDotIndex),
|
|
31
|
-
path: inner.slice(firstDotIndex + 1),
|
|
31
|
+
path: options.pathWithDotPrefix ? inner.slice(firstDotIndex) : inner.slice(firstDotIndex + 1),
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
if (firstDotIndex === -1 && firstSquareBracketIndex !== -1) {
|
|
@@ -40,7 +40,7 @@ export const splitVariableName = (inner) => {
|
|
|
40
40
|
if (firstDotIndex < firstSquareBracketIndex) {
|
|
41
41
|
return {
|
|
42
42
|
id: inner.slice(0, firstDotIndex),
|
|
43
|
-
path: inner.slice(firstDotIndex + 1),
|
|
43
|
+
path: options.pathWithDotPrefix ? inner.slice(firstDotIndex) : inner.slice(firstDotIndex + 1),
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/common",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.7.0",
|
|
4
4
|
"description": "Junk drawer of utility functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voiceflow"
|
|
@@ -15,9 +15,28 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"author": "Voiceflow",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./build/cjs/index.d.ts",
|
|
21
|
+
"main": "./build/cjs/index.js",
|
|
22
|
+
"module": "./build/esm/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./dtos": {
|
|
25
|
+
"types": "./build/cjs/dtos/main.d.ts",
|
|
26
|
+
"main": "./build/cjs/dtos/main.js",
|
|
27
|
+
"module": "./build/esm/dtos/main.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
18
30
|
"main": "build/cjs/index.js",
|
|
19
31
|
"module": "build/esm/index.js",
|
|
20
32
|
"types": "build/cjs/index.d.ts",
|
|
33
|
+
"typesVersions": {
|
|
34
|
+
"*": {
|
|
35
|
+
"dtos": [
|
|
36
|
+
"./build/cjs/dtos/main.d.ts"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
21
40
|
"files": [
|
|
22
41
|
"build"
|
|
23
42
|
],
|
|
@@ -52,7 +71,16 @@
|
|
|
52
71
|
},
|
|
53
72
|
"devDependencies": {
|
|
54
73
|
"@types/lodash": "4.14.178",
|
|
55
|
-
"@types/number-to-words": "1.2.0"
|
|
74
|
+
"@types/number-to-words": "1.2.0",
|
|
75
|
+
"zod": "3.24.1"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"zod": "^3"
|
|
79
|
+
},
|
|
80
|
+
"peerDependenciesMeta": {
|
|
81
|
+
"zod": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
56
84
|
},
|
|
57
85
|
"volta": {
|
|
58
86
|
"extends": "../../package.json"
|
|
@@ -60,5 +88,5 @@
|
|
|
60
88
|
"publishConfig": {
|
|
61
89
|
"access": "public"
|
|
62
90
|
},
|
|
63
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "78aee0cb0651458fc243fcbade1bf6fce87a3c7d"
|
|
64
92
|
}
|