@voiceflow/common 8.3.0 → 8.3.2
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/crypto/base64.js +4 -4
- package/build/cjs/crypto/synchronous.d.ts +1 -1
- package/build/cjs/crypto/synchronous.d.ts.map +1 -1
- package/build/cjs/crypto/synchronous.js +2 -2
- package/build/cjs/utils/intent.js +2 -2
- package/build/cjs/utils/number.js +2 -2
- package/build/cjs/utils/object/common.js +2 -2
- package/build/cjs/utils/object/diff.js +2 -2
- package/build/cjs/utils/slot.js +2 -2
- package/build/cjs/utils/time.js +14 -14
- package/build/cjs/utils/variables.js +2 -2
- package/build/esm/crypto/base64.js +2 -2
- package/build/esm/crypto/synchronous.d.ts +1 -1
- package/build/esm/crypto/synchronous.d.ts.map +1 -1
- package/build/esm/crypto/synchronous.js +1 -1
- package/build/esm/utils/intent.js +1 -1
- package/build/esm/utils/number.js +1 -1
- package/build/esm/utils/object/common.js +1 -1
- package/build/esm/utils/object/diff.js +1 -1
- package/build/esm/utils/slot.js +1 -1
- package/build/esm/utils/time.js +7 -7
- package/build/esm/utils/variables.js +2 -2
- package/package.json +2 -2
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const enc_base64_js_1 = __importDefault(require("crypto-js/enc-base64.js"));
|
|
7
|
+
const enc_utf8_js_1 = __importDefault(require("crypto-js/enc-utf8.js"));
|
|
8
8
|
class Base64 {
|
|
9
9
|
static encode(data) {
|
|
10
|
-
return
|
|
10
|
+
return enc_base64_js_1.default.stringify(enc_utf8_js_1.default.parse(data));
|
|
11
11
|
}
|
|
12
12
|
static encodeJSON(data) {
|
|
13
13
|
return Base64.encode(JSON.stringify(data));
|
|
14
14
|
}
|
|
15
15
|
static decode(data) {
|
|
16
|
-
return
|
|
16
|
+
return enc_utf8_js_1.default.stringify(enc_base64_js_1.default.parse(data));
|
|
17
17
|
}
|
|
18
18
|
static decodeJSON(data) {
|
|
19
19
|
return data ? JSON.parse(Base64.decode(data)) : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronous.d.ts","sourceRoot":"","sources":["../../../src/crypto/synchronous.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"synchronous.d.ts","sourceRoot":"","sources":["../../../src/crypto/synchronous.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAGjD,UAAU,kBAAkB;IAC1B,GAAG,EAAE,OAAO,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,cAAM,WAAW;;gBAKH,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,kBAAkB;IAK5C,SAAS,CAAC,MAAM,IAAI,MAAM;IAInB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAkB,GAAG,MAAM;IAItD,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;IAIlC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAY,GAAG,MAAM;IAI9C,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;CAGvC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
var _Synchronous_alg, _Synchronous_key;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const
|
|
18
|
+
const enc_utf8_js_1 = __importDefault(require("crypto-js/enc-utf8.js"));
|
|
19
19
|
class Synchronous {
|
|
20
20
|
constructor({ alg, key }) {
|
|
21
21
|
_Synchronous_alg.set(this, void 0);
|
|
@@ -33,7 +33,7 @@ class Synchronous {
|
|
|
33
33
|
return this.encrypt(JSON.stringify(data));
|
|
34
34
|
}
|
|
35
35
|
decrypt(data, key = __classPrivateFieldGet(this, _Synchronous_key, "f")) {
|
|
36
|
-
return __classPrivateFieldGet(this, _Synchronous_alg, "f").decrypt(data, key).toString(
|
|
36
|
+
return __classPrivateFieldGet(this, _Synchronous_alg, "f").decrypt(data, key).toString(enc_utf8_js_1.default);
|
|
37
37
|
}
|
|
38
38
|
decryptJSON(data) {
|
|
39
39
|
return JSON.parse(this.decrypt(data));
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.cleanVFIntentName = exports.injectUtteranceSpaces = exports.utteranceEntityPermutations = exports.VF_ENTITY_REGEXP = exports.getSlotType = exports.getUtterancesWithSlotNames = exports.formatIntentName = void 0;
|
|
7
|
-
const
|
|
7
|
+
const sample_js_1 = __importDefault(require("lodash/sample.js"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const slot_1 = require("./slot");
|
|
10
10
|
const formatIntentName = (name) => {
|
|
@@ -68,7 +68,7 @@ const utteranceEntityPermutations = ({ utterances, entitiesByID, limit = 22, rep
|
|
|
68
68
|
if (!entity)
|
|
69
69
|
return entityName;
|
|
70
70
|
const sample = (entityRef[entityID]?.samples.shift() ||
|
|
71
|
-
(0,
|
|
71
|
+
(0, sample_js_1.default)(getSamples(entity?.inputs)) ||
|
|
72
72
|
entityName).trim();
|
|
73
73
|
if (!entityRef[entityID]?.samples?.length)
|
|
74
74
|
delete entityRef[entityID];
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.clamp = exports.isInRange = exports.convertToWord = exports.NON_ALPHANUMERIC_REGEXP = void 0;
|
|
7
|
-
const
|
|
7
|
+
const index_js_1 = __importDefault(require("number-to-words/src/index.js"));
|
|
8
8
|
exports.NON_ALPHANUMERIC_REGEXP = /\W/g;
|
|
9
|
-
const convertToWord = (value) =>
|
|
9
|
+
const convertToWord = (value) => index_js_1.default.toWords(value).replace(exports.NON_ALPHANUMERIC_REGEXP, ' ');
|
|
10
10
|
exports.convertToWord = convertToWord;
|
|
11
11
|
const isInRange = (target, min, max) => target >= min && target <= max;
|
|
12
12
|
exports.isInRange = isInRange;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.shallowPartialEquals = exports.mapValue = exports.mapEntry = exports.filterEntries = exports.omitBy = exports.pickBy = exports.pick = exports.omit = exports.hasProperty = exports.isPlainObject = exports.isObject = exports.selectValue = exports.selectKey = exports.selectID = exports.selectField = exports.shallowEquals = void 0;
|
|
7
|
-
const
|
|
7
|
+
const isPlainObject_js_1 = __importDefault(require("lodash/isPlainObject.js"));
|
|
8
8
|
var shallowequal_1 = require("shallowequal");
|
|
9
9
|
Object.defineProperty(exports, "shallowEquals", { enumerable: true, get: function () { return __importDefault(shallowequal_1).default; } });
|
|
10
10
|
const selectField = (field) => (obj) => obj[field];
|
|
@@ -14,7 +14,7 @@ exports.selectKey = (0, exports.selectField)('key');
|
|
|
14
14
|
exports.selectValue = (0, exports.selectField)('value');
|
|
15
15
|
const isObject = (obj) => obj !== null && typeof obj === 'object';
|
|
16
16
|
exports.isObject = isObject;
|
|
17
|
-
const isPlainObject = (obj) => (0,
|
|
17
|
+
const isPlainObject = (obj) => (0, isPlainObject_js_1.default)(obj);
|
|
18
18
|
exports.isPlainObject = isPlainObject;
|
|
19
19
|
const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
20
20
|
exports.hasProperty = hasProperty;
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getTopLevelDiff = void 0;
|
|
7
|
-
const
|
|
7
|
+
const transform_js_1 = __importDefault(require("lodash/transform.js"));
|
|
8
8
|
const defaultCompare = (left, right) => left === right;
|
|
9
9
|
const getTopLevelDiff = (object, base, compare = defaultCompare) => {
|
|
10
|
-
const changes = (object, base) => (0,
|
|
10
|
+
const changes = (object, base) => (0, transform_js_1.default)(object, (result, value, key) => {
|
|
11
11
|
if (!compare(value, base[key])) {
|
|
12
12
|
// eslint-disable-next-line no-param-reassign
|
|
13
13
|
result[key] = value;
|
package/build/cjs/utils/slot.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.mapSlotAnnotations = exports.getValueWithSynonyms = exports.getAllSamples = exports.getUniqueSamples = exports.addPrebuiltEntities = void 0;
|
|
7
|
-
const
|
|
7
|
+
const uniqBy_js_1 = __importDefault(require("lodash/uniqBy.js"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const addPrebuiltEntities = (entities, prebuiltEntities) => entities.map((entity) => {
|
|
10
10
|
if (prebuiltEntities[entity.key]) {
|
|
@@ -16,7 +16,7 @@ const addPrebuiltEntities = (entities, prebuiltEntities) => entities.map((entity
|
|
|
16
16
|
return entity;
|
|
17
17
|
});
|
|
18
18
|
exports.addPrebuiltEntities = addPrebuiltEntities;
|
|
19
|
-
const getUniqueSamples = (input) => (0,
|
|
19
|
+
const getUniqueSamples = (input) => (0, uniqBy_js_1.default)(input.split(','), (sample) => sample.toLowerCase());
|
|
20
20
|
exports.getUniqueSamples = getUniqueSamples;
|
|
21
21
|
// spread all synonyms into string array ['car, automobile', 'plane, jet'] => ['car', 'automobile', 'plane', 'jet']
|
|
22
22
|
const getAllSamples = (inputs = []) => inputs.flatMap((input) => input.split(',')).filter((sample) => !!sample.trim());
|
package/build/cjs/utils/time.js
CHANGED
|
@@ -5,20 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAbbrevatedFormat = exports.getTimeDuration = exports.getCurrentTimestamp = void 0;
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
dayjs_1.default.extend(
|
|
16
|
-
dayjs_1.default.extend(
|
|
17
|
-
dayjs_1.default.extend(
|
|
18
|
-
dayjs_1.default.extend(
|
|
19
|
-
dayjs_1.default.extend(
|
|
20
|
-
dayjs_1.default.extend(
|
|
21
|
-
dayjs_1.default.extend(
|
|
8
|
+
const advancedFormat_js_1 = __importDefault(require("dayjs/plugin/advancedFormat.js"));
|
|
9
|
+
const customParseFormat_js_1 = __importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
10
|
+
const duration_js_1 = __importDefault(require("dayjs/plugin/duration.js"));
|
|
11
|
+
const minMax_js_1 = __importDefault(require("dayjs/plugin/minMax.js"));
|
|
12
|
+
const relativeTime_js_1 = __importDefault(require("dayjs/plugin/relativeTime.js"));
|
|
13
|
+
const updateLocale_js_1 = __importDefault(require("dayjs/plugin/updateLocale.js"));
|
|
14
|
+
const utc_js_1 = __importDefault(require("dayjs/plugin/utc.js"));
|
|
15
|
+
dayjs_1.default.extend(utc_js_1.default);
|
|
16
|
+
dayjs_1.default.extend(duration_js_1.default);
|
|
17
|
+
dayjs_1.default.extend(relativeTime_js_1.default);
|
|
18
|
+
dayjs_1.default.extend(customParseFormat_js_1.default);
|
|
19
|
+
dayjs_1.default.extend(minMax_js_1.default);
|
|
20
|
+
dayjs_1.default.extend(advancedFormat_js_1.default);
|
|
21
|
+
dayjs_1.default.extend(updateLocale_js_1.default);
|
|
22
22
|
// https://day.js.org/docs/en/customization/relative-time
|
|
23
23
|
dayjs_1.default.updateLocale('en', {
|
|
24
24
|
relativeTime: {
|
|
@@ -16,10 +16,10 @@ const replaceVariables = (phrase, variables, modifier = undefined, { trim = true
|
|
|
16
16
|
return phrase.replace(constants_1.READABLE_VARIABLE_REGEXP, (match, inner) => String((0, exports.variableReplacer)(match, inner, variables, modifier)));
|
|
17
17
|
};
|
|
18
18
|
exports.replaceVariables = replaceVariables;
|
|
19
|
-
// turn float variables to
|
|
19
|
+
// turn float variables to 4 decimal places
|
|
20
20
|
const sanitizeVariables = (variables) => Object.entries(variables).reduce((acc, [key, value]) => {
|
|
21
21
|
if (typeof value === 'number' && !Number.isInteger(value)) {
|
|
22
|
-
acc[key] = value.toFixed(
|
|
22
|
+
acc[key] = value.toFixed(4);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
acc[key] = value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CryptoBase64 from 'crypto-js/enc-base64';
|
|
2
|
-
import Utf8 from 'crypto-js/enc-utf8';
|
|
1
|
+
import CryptoBase64 from 'crypto-js/enc-base64.js';
|
|
2
|
+
import Utf8 from 'crypto-js/enc-utf8.js';
|
|
3
3
|
class Base64 {
|
|
4
4
|
static encode(data) {
|
|
5
5
|
return CryptoBase64.stringify(Utf8.parse(data));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronous.d.ts","sourceRoot":"","sources":["../../../src/crypto/synchronous.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"synchronous.d.ts","sourceRoot":"","sources":["../../../src/crypto/synchronous.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAGjD,UAAU,kBAAkB;IAC1B,GAAG,EAAE,OAAO,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,cAAM,WAAW;;gBAKH,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,kBAAkB;IAK5C,SAAS,CAAC,MAAM,IAAI,MAAM;IAInB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAkB,GAAG,MAAM;IAItD,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;IAIlC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAY,GAAG,MAAM;IAI9C,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;CAGvC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _Synchronous_alg, _Synchronous_key;
|
|
13
|
-
import Utf8 from 'crypto-js/enc-utf8';
|
|
13
|
+
import Utf8 from 'crypto-js/enc-utf8.js';
|
|
14
14
|
class Synchronous {
|
|
15
15
|
constructor({ alg, key }) {
|
|
16
16
|
_Synchronous_alg.set(this, void 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import numberToWords from 'number-to-words/src';
|
|
1
|
+
import numberToWords from 'number-to-words/src/index.js';
|
|
2
2
|
export const NON_ALPHANUMERIC_REGEXP = /\W/g;
|
|
3
3
|
export const convertToWord = (value) => numberToWords.toWords(value).replace(NON_ALPHANUMERIC_REGEXP, ' ');
|
|
4
4
|
export const isInRange = (target, min, max) => target >= min && target <= max;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _transform from 'lodash/transform';
|
|
1
|
+
import _transform from 'lodash/transform.js';
|
|
2
2
|
const defaultCompare = (left, right) => left === right;
|
|
3
3
|
export const getTopLevelDiff = (object, base, compare = defaultCompare) => {
|
|
4
4
|
const changes = (object, base) => _transform(object, (result, value, key) => {
|
package/build/esm/utils/slot.js
CHANGED
package/build/esm/utils/time.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
3
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
4
|
-
import duration from 'dayjs/plugin/duration';
|
|
5
|
-
import minMax from 'dayjs/plugin/minMax';
|
|
6
|
-
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
7
|
-
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
8
|
-
import utc from 'dayjs/plugin/utc';
|
|
2
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|
3
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
4
|
+
import duration from 'dayjs/plugin/duration.js';
|
|
5
|
+
import minMax from 'dayjs/plugin/minMax.js';
|
|
6
|
+
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
7
|
+
import updateLocale from 'dayjs/plugin/updateLocale.js';
|
|
8
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
9
9
|
dayjs.extend(utc);
|
|
10
10
|
dayjs.extend(duration);
|
|
11
11
|
dayjs.extend(relativeTime);
|
|
@@ -11,10 +11,10 @@ export const replaceVariables = (phrase, variables, modifier = undefined, { trim
|
|
|
11
11
|
}
|
|
12
12
|
return phrase.replace(READABLE_VARIABLE_REGEXP, (match, inner) => String(variableReplacer(match, inner, variables, modifier)));
|
|
13
13
|
};
|
|
14
|
-
// turn float variables to
|
|
14
|
+
// turn float variables to 4 decimal places
|
|
15
15
|
export const sanitizeVariables = (variables) => Object.entries(variables).reduce((acc, [key, value]) => {
|
|
16
16
|
if (typeof value === 'number' && !Number.isInteger(value)) {
|
|
17
|
-
acc[key] = value.toFixed(
|
|
17
|
+
acc[key] = value.toFixed(4);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
acc[key] = value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/common",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"description": "Junk drawer of utility functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voiceflow"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "eb8d92af87448d5f34d648d0e1e48992c42ec289"
|
|
64
64
|
}
|