@based/schema 1.1.15 → 1.3.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.
Files changed (40) hide show
  1. package/dist/set/fields/string.d.ts.map +1 -1
  2. package/dist/set/fields/string.js +182 -28
  3. package/dist/set/fields/string.js.map +1 -1
  4. package/dist/types.d.ts +2 -0
  5. package/dist/types.d.ts.map +1 -1
  6. package/dist/walker/args.d.ts +1 -0
  7. package/dist/walker/args.d.ts.map +1 -1
  8. package/dist/walker/args.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/set/fields/string.ts +163 -11
  11. package/src/types.ts +71 -67
  12. package/src/walker/args.ts +2 -0
  13. package/test/text.ts +133 -19
  14. package/dist/schema.d.ts +0 -1
  15. package/dist/schema.js +0 -3
  16. package/dist/schema.js.map +0 -1
  17. package/dist/set/collections.d.ts +0 -5
  18. package/dist/set/collections.js +0 -211
  19. package/dist/set/collections.js.map +0 -1
  20. package/dist/set/error.d.ts +0 -14
  21. package/dist/set/error.js +0 -23
  22. package/dist/set/error.js.map +0 -1
  23. package/dist/set/number.d.ts +0 -4
  24. package/dist/set/number.js +0 -110
  25. package/dist/set/number.js.map +0 -1
  26. package/dist/set/parseDefaultAndValue.d.ts +0 -3
  27. package/dist/set/parseDefaultAndValue.js +0 -33
  28. package/dist/set/parseDefaultAndValue.js.map +0 -1
  29. package/dist/set/parsers.d.ts +0 -3
  30. package/dist/set/parsers.js +0 -42
  31. package/dist/set/parsers.js.map +0 -1
  32. package/dist/set/references.d.ts +0 -3
  33. package/dist/set/references.js +0 -77
  34. package/dist/set/references.js.map +0 -1
  35. package/dist/set/rest.d.ts +0 -5
  36. package/dist/set/rest.js +0 -76
  37. package/dist/set/rest.js.map +0 -1
  38. package/dist/set/string.d.ts +0 -3
  39. package/dist/set/string.js +0 -169
  40. package/dist/set/string.js.map +0 -1
@@ -1,14 +0,0 @@
1
- export declare enum ParseError {
2
- 'incorrectFieldType' = 0,
3
- 'incorrectNodeType' = 1,
4
- 'exceedsMaximum' = 2,
5
- 'subceedsMinimum' = 3,
6
- 'fieldDoesNotExist' = 4,
7
- 'incorrectFormat' = 5,
8
- 'referenceIsIncorrectType' = 6,
9
- 'valueAndDefault' = 7,
10
- 'defaultNotSupported' = 8,
11
- 'multipleOperationsNotAllowed' = 9,
12
- 'requiredFieldNotDefined' = 10
13
- }
14
- export declare const error: (path: (number | string)[], error: ParseError, type?: string) => never;
package/dist/set/error.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.error = exports.ParseError = void 0;
4
- var ParseError;
5
- (function (ParseError) {
6
- ParseError[ParseError["incorrectFieldType"] = 0] = "incorrectFieldType";
7
- ParseError[ParseError["incorrectNodeType"] = 1] = "incorrectNodeType";
8
- ParseError[ParseError["exceedsMaximum"] = 2] = "exceedsMaximum";
9
- ParseError[ParseError["subceedsMinimum"] = 3] = "subceedsMinimum";
10
- ParseError[ParseError["fieldDoesNotExist"] = 4] = "fieldDoesNotExist";
11
- ParseError[ParseError["incorrectFormat"] = 5] = "incorrectFormat";
12
- ParseError[ParseError["referenceIsIncorrectType"] = 6] = "referenceIsIncorrectType";
13
- ParseError[ParseError["valueAndDefault"] = 7] = "valueAndDefault";
14
- ParseError[ParseError["defaultNotSupported"] = 8] = "defaultNotSupported";
15
- ParseError[ParseError["multipleOperationsNotAllowed"] = 9] = "multipleOperationsNotAllowed";
16
- ParseError[ParseError["requiredFieldNotDefined"] = 10] = "requiredFieldNotDefined";
17
- })(ParseError = exports.ParseError || (exports.ParseError = {}));
18
- const error = (path, error, type // nice to give as option
19
- ) => {
20
- throw new Error(`Field: "${path.join('.')}" ${ParseError[error]}`);
21
- };
22
- exports.error = error;
23
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/set/error.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,uEAAoB,CAAA;IACpB,qEAAmB,CAAA;IACnB,+DAAgB,CAAA;IAChB,iEAAiB,CAAA;IACjB,qEAAmB,CAAA;IACnB,iEAAiB,CAAA;IACjB,mFAA0B,CAAA;IAC1B,iEAAiB,CAAA;IACjB,yEAAqB,CAAA;IACrB,2FAA8B,CAAA;IAC9B,kFAAyB,CAAA;AAC3B,CAAC,EAZW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAYrB;AAEM,MAAM,KAAK,GAAG,CACnB,IAAyB,EACzB,KAAiB,EACjB,IAAa,CAAC,yBAAyB;EACvC,EAAE;IACF,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC,CAAA;AANY,QAAA,KAAK,SAMjB"}
@@ -1,4 +0,0 @@
1
- import { Parser } from './types';
2
- export declare const timestamp: Parser<'timestamp'>;
3
- export declare const number: Parser<'number'>;
4
- export declare const integer: Parser<'integer'>;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.integer = exports.number = exports.timestamp = void 0;
4
- const error_1 = require("./error");
5
- const validate = (path, value, fieldSchema) => {
6
- if (typeof value !== 'number') {
7
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
8
- }
9
- if (fieldSchema.type === 'integer' && value - Math.floor(value) !== 0) {
10
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
11
- }
12
- if (fieldSchema.multipleOf &&
13
- value / fieldSchema.multipleOf -
14
- Math.floor(value / fieldSchema.multipleOf) !==
15
- 0) {
16
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
17
- }
18
- if (fieldSchema.maximum) {
19
- if (fieldSchema.exclusiveMaximum && value > value) {
20
- (0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
21
- }
22
- else if (value >= value) {
23
- (0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
24
- }
25
- }
26
- if (fieldSchema.minimum) {
27
- if (fieldSchema.exclusiveMinimum && value < value) {
28
- (0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
29
- }
30
- else if (value <= value) {
31
- (0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
32
- }
33
- }
34
- return value;
35
- };
36
- const shared = (path, value, fieldSchema) => {
37
- if (typeof value === 'object') {
38
- if (value.$increment) {
39
- validate([...path, '$increment'], value.$increment, fieldSchema);
40
- }
41
- if (value.$decrement) {
42
- validate([...path, '$decrement'], value.$decrement, fieldSchema);
43
- }
44
- if (value.$value !== undefined) {
45
- validate(path, value.$value, fieldSchema);
46
- }
47
- if (value.$default !== undefined) {
48
- if (value.$value !== undefined) {
49
- (0, error_1.error)(path, error_1.ParseError.valueAndDefault);
50
- }
51
- validate(path, value.$default, fieldSchema);
52
- }
53
- }
54
- else {
55
- validate(path, value, fieldSchema);
56
- }
57
- return value;
58
- };
59
- const timestamp = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
60
- if (typeof value === 'string') {
61
- if (value === 'now') {
62
- value = Date.now();
63
- }
64
- else {
65
- const d = new Date(value);
66
- value = d.valueOf();
67
- if (isNaN(value)) {
68
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
69
- }
70
- }
71
- }
72
- const parsedValue = shared(path, value, fieldSchema);
73
- if (!noCollect) {
74
- handlers.collect({
75
- path,
76
- value: parsedValue,
77
- typeSchema,
78
- fieldSchema,
79
- target,
80
- });
81
- }
82
- };
83
- exports.timestamp = timestamp;
84
- const number = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
85
- const parsedValue = shared(path, value, fieldSchema);
86
- if (!noCollect) {
87
- handlers.collect({
88
- path,
89
- value: parsedValue,
90
- typeSchema,
91
- fieldSchema,
92
- target,
93
- });
94
- }
95
- };
96
- exports.number = number;
97
- const integer = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
98
- const parsedValue = shared(path, value, fieldSchema);
99
- if (!noCollect) {
100
- handlers.collect({
101
- path,
102
- value: parsedValue,
103
- typeSchema,
104
- fieldSchema,
105
- target,
106
- });
107
- }
108
- };
109
- exports.integer = integer;
110
- //# sourceMappingURL=number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/set/number.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAO3C,MAAM,QAAQ,GAAG,CACf,IAAyB,EACzB,KAAU,EACV,WAG6B,EACrB,EAAE;IACV,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACrE,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,IACE,WAAW,CAAC,UAAU;QACtB,KAAK,GAAG,WAAW,CAAC,UAAU;YAC5B,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC;YAC1C,CAAC,EACH;QACA,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,IAAI,WAAW,CAAC,OAAO,EAAE;QACvB,IAAI,WAAW,CAAC,gBAAgB,IAAI,KAAK,GAAG,KAAK,EAAE;YACjD,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,cAAc,CAAC,CAAA;SACvC;aAAM,IAAI,KAAK,IAAI,KAAK,EAAE;YACzB,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,cAAc,CAAC,CAAA;SACvC;KACF;IACD,IAAI,WAAW,CAAC,OAAO,EAAE;QACvB,IAAI,WAAW,CAAC,gBAAgB,IAAI,KAAK,GAAG,KAAK,EAAE;YACjD,I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,WAAW,CAAC,CAAA;IACpD,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC;YACf,IAAI;YACJ,KAAK,EAAE,WAAW;YAClB,UAAU;YACV,WAAW;YACX,MAAM;SACP,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AAnBY,QAAA,OAAO,WAmBnB"}
@@ -1,3 +0,0 @@
1
- import { BasedSchemaFields } from '../types';
2
- import { Parser } from './types';
3
- export declare const parseValueAndDefault: Parser<keyof BasedSchemaFields>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseValueAndDefault = void 0;
7
- const error_1 = require("./error");
8
- const parsers_1 = __importDefault(require("./parsers"));
9
- const parseValueAndDefault = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
10
- let handled = false;
11
- if (typeof value === 'object') {
12
- const typeDef = fieldSchema.type ?? ('enum' in fieldSchema ? 'enum' : '');
13
- const parse = parsers_1.default[typeDef];
14
- if (value.$value !== undefined) {
15
- // TODO: for errors handle path a bit smarter...
16
- parse(path, value.$value, fieldSchema, typeSchema, target, handlers, true);
17
- handled = true;
18
- }
19
- if (value.$default !== undefined) {
20
- if (value.$value !== undefined) {
21
- (0, error_1.error)(path, error_1.ParseError.valueAndDefault);
22
- }
23
- parse(path, value.$default, fieldSchema, typeSchema, target, handlers, true);
24
- handled = true;
25
- }
26
- }
27
- if (handled && !noCollect) {
28
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
29
- }
30
- return handled;
31
- };
32
- exports.parseValueAndDefault = parseValueAndDefault;
33
- //# sourceMappingURL=parseDefaultAndValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseDefaultAndValue.js","sourceRoot":"","sources":["../../src/set/parseDefaultAndValue.ts"],"names":[],"mappings":";;;;;;AAEA,mCAA2C;AAC3C,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
3
- export default parsers;
@@ -1,42 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const references = __importStar(require("./references"));
27
- const collections = __importStar(require("./collections"));
28
- const number = __importStar(require("./number"));
29
- const string = __importStar(require("./string"));
30
- const rest_1 = require("./rest");
31
- const parsers = {
32
- ...string,
33
- ...references,
34
- ...collections,
35
- ...number,
36
- enum: rest_1.enumParser,
37
- boolean: rest_1.boolean,
38
- cardinality: rest_1.cardinality,
39
- json: rest_1.json,
40
- };
41
- exports.default = parsers;
42
- //# sourceMappingURL=parsers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../src/set/parsers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA0C;AAC1C,2DAA4C;AAC5C,iDAAkC;AAClC,iDAAkC;AAElC,iCAA+D;AAE/D,MAAM,OAAO,GAAY;IACvB,GAAG,MAAM;IACT,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,MAAM;IACT,IAAI,EAAE,iBAAU;IAChB,OAAO,EAAP,cAAO;IACP,WAAW,EAAX,kBAAW;IACX,IAAI,EAAJ,WAAI;CACL,CAAA;AAED,kBAAe,OAAO,CAAA"}
@@ -1,3 +0,0 @@
1
- import { Parser } from './types';
2
- export declare const reference: Parser<'reference'>;
3
- export declare const references: Parser<'references'>;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.references = exports.reference = void 0;
4
- const error_1 = require("./error");
5
- const reference = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
6
- // $no root
7
- // prob pass these as options
8
- // value .default
9
- // $value
10
- if (typeof value !== 'string') {
11
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
12
- }
13
- if ('allowedTypes' in fieldSchema) {
14
- const prefix = value.slice(0, 2);
15
- const targetType = target.schema.prefixToTypeMapping[prefix];
16
- if (!targetType) {
17
- (0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
18
- }
19
- let typeMatches = false;
20
- for (const t of fieldSchema.allowedTypes) {
21
- if (typeof t === 'string') {
22
- if (t === targetType) {
23
- typeMatches = true;
24
- break;
25
- }
26
- }
27
- else {
28
- if (t.type && t.type === targetType) {
29
- typeMatches = true;
30
- if (t.$filter) {
31
- if (!(await handlers.referenceFilterCondition(value, t.$filter))) {
32
- (0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
33
- }
34
- }
35
- }
36
- else if (!t.type && t.$filter) {
37
- if (!(await handlers.referenceFilterCondition(value, t.$filter))) {
38
- (0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
39
- }
40
- }
41
- }
42
- }
43
- if (typeMatches === false) {
44
- (0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
45
- }
46
- }
47
- if (!noCollect) {
48
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
49
- }
50
- };
51
- exports.reference = reference;
52
- const references = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
53
- // default
54
- // $no root
55
- if (Array.isArray(value)) {
56
- await Promise.all(value.map((v, i) => {
57
- return (0, exports.reference)([...path, i], v,
58
- // not nice slow
59
- { ...fieldSchema, type: 'reference' }, typeSchema, target, handlers, true);
60
- }));
61
- value = { $value: value };
62
- }
63
- else if (typeof value === 'object') {
64
- if (value.$add) {
65
- await Promise.all(value.$add.map((v, i) => {
66
- return (0, exports.reference)([...path, '$add', i], v,
67
- // not nice slow
68
- { ...fieldSchema, type: 'reference' }, typeSchema, target, handlers, true);
69
- }));
70
- }
71
- }
72
- if (!noCollect) {
73
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
74
- }
75
- };
76
- exports.references = references;
77
- //# sourceMappingURL=references.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/set/references.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAEpC,MAAM,SAAS,GAAwB,KAAK,EACjD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,WAAW;IACX,6BAA6B;IAC7B,iBAAiB;IACjB,SAAS;IAET,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IAED,IAAI,cAAc,IAAI,WAAW,EAAE;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC5D,IAAI,CAAC,UAAU,EAAE;YACf,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,wBAAwB,CAAC,CAAA;SACjD;QACD,IAAI,WAAW,GAAG,KAAK,CAAA;QACvB,KAAK,MAAM,CAAC,IAAI,WAAW,C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C,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjB,OAAO,IAAA,iBAAS,EACd,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,EACZ,CAAC;YACD,gBAAgB;YAChB,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EACrC,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAA;QACH,CAAC,CAAC,CACH,CAAA;QACD,KAAK,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAC1B;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACtB,OAAO,IAAA,iBAAS,EACd,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EACpB,CAAC;gBACD,gBAAgB;gBAChB,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EACrC,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAA;YACH,CAAC,CAAC,CACH,CAAA;SACF;KACF;IACD,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;KACnE;AACH,CAAC,CAAA;AAhDY,QAAA,UAAU,cAgDtB"}
@@ -1,5 +0,0 @@
1
- import { Parser } from './types';
2
- export declare const cardinality: Parser<'cardinality'>;
3
- export declare const boolean: Parser<'boolean'>;
4
- export declare const enumParser: Parser<'enum'>;
5
- export declare const json: Parser<'json'>;
package/dist/set/rest.js DELETED
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.json = exports.enumParser = exports.boolean = exports.cardinality = void 0;
4
- const utils_1 = require("@saulx/utils");
5
- const hash_1 = require("@saulx/hash");
6
- const error_1 = require("./error");
7
- const parseDefaultAndValue_1 = require("./parseDefaultAndValue");
8
- const cardinality = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
9
- if (value && typeof value === 'object') {
10
- if (value.$default !== undefined) {
11
- (0, error_1.error)(path, error_1.ParseError.defaultNotSupported);
12
- }
13
- if (value.$value !== undefined) {
14
- value = (0, hash_1.hashObjectIgnoreKeyOrder)(value.$value).toString(16);
15
- }
16
- else {
17
- value = (0, hash_1.hashObjectIgnoreKeyOrder)(value).toString(16);
18
- }
19
- }
20
- else {
21
- value = (0, hash_1.hash)(value).toString(16);
22
- }
23
- if (!noCollect) {
24
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
25
- }
26
- };
27
- exports.cardinality = cardinality;
28
- const boolean = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
29
- if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
30
- return;
31
- }
32
- if (typeof value !== 'boolean') {
33
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
34
- }
35
- if (!noCollect) {
36
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
37
- }
38
- };
39
- exports.boolean = boolean;
40
- const enumParser = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
41
- const enumValues = fieldSchema.enum;
42
- if (!(await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect))) {
43
- for (let i = 0; i < enumValues.length; i++) {
44
- if ((0, utils_1.deepEqual)(enumValues[i], value)) {
45
- if (!noCollect) {
46
- handlers.collect({ path, value: i, typeSchema, fieldSchema, target });
47
- }
48
- return;
49
- }
50
- }
51
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
52
- }
53
- };
54
- exports.enumParser = enumParser;
55
- const json = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
56
- if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
57
- return;
58
- }
59
- try {
60
- const parsedValue = JSON.stringify(value);
61
- if (!noCollect) {
62
- handlers.collect({
63
- path,
64
- value: parsedValue,
65
- typeSchema,
66
- fieldSchema,
67
- target,
68
- });
69
- }
70
- }
71
- catch (err) {
72
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
73
- }
74
- };
75
- exports.json = json;
76
- //# sourceMappingURL=rest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/set/rest.ts"],"names":[],"mappings":";;;AACA,wCAAwC;AACxC,sCAA4D;AAC5D,mCAA2C;AAC3C,iEAA6D;AAEtD,MAAM,WAAW,GAA0B,KAAK,EACrD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACtC,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,mBAAmB,CAAC,CAAA;SAC5C;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9B,KAAK,GAAG,IAAA,+BAAwB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SAC5D;aAAM;YACL,KAAK,GAAG,IAAA,+BAAwB,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SACrD;KACF;SAAM;QACL,KAAK,GAAG,IAAA,WAAI,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KACjC;IACD,IAAI,CAAC,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AC,SAAS,EAAE;oBACd,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;iBACtE;gBACD,OAAM;aACP;SACF;QACD,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;AACH,CAAC,CAAA;AA/BY,QAAA,UAAU,cA+BtB;AAEM,MAAM,IAAI,GAAmB,KAAK,EACvC,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IACE,MAAM,IAAA,2CAAoB,EACxB,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,CACV,EACD;QACA,OAAM;KACP;IAED,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACzC,IAAI,CAAC,SAAS,EAAE;YACd,QAAQ,CAAC,OAAO,CAAC;gBACf,IAAI;gBACJ,KAAK,EAAE,WAAW;gBAClB,UAAU;gBACV,WAAW;gBACX,MAAM;aACP,CAAC,CAAA;SACH;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;AACH,CAAC,CAAA;AArCY,QAAA,IAAI,QAqChB"}
@@ -1,3 +0,0 @@
1
- import { Parser } from './types';
2
- export declare const string: Parser<'string'>;
3
- export declare const text: Parser<'text'>;
@@ -1,169 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.text = exports.string = void 0;
7
- const error_1 = require("./error");
8
- const validator_1 = __importDefault(require("validator"));
9
- const parseDefaultAndValue_1 = require("./parseDefaultAndValue");
10
- const formatPatterns = {
11
- email: validator_1.default.isEmail,
12
- URL: validator_1.default.isURL,
13
- MACAddress: validator_1.default.isMACAddress,
14
- IP: validator_1.default.isIP,
15
- IPRange: validator_1.default.isIPRange,
16
- FQDN: validator_1.default.isFQDN,
17
- IBAN: validator_1.default.isIBAN,
18
- BIC: validator_1.default.isBIC,
19
- alpha: validator_1.default.isAlpha,
20
- alphaLocales: validator_1.default.isAlphaLocales,
21
- alphanumeric: validator_1.default.isAlphanumeric,
22
- alphanumericLocales: validator_1.default.isAlphanumericLocales,
23
- passportNumber: validator_1.default.isPassportNumber,
24
- port: validator_1.default.isPort,
25
- lowercase: validator_1.default.isLowercase,
26
- uppercase: validator_1.default.isUppercase,
27
- ascii: validator_1.default.isAscii,
28
- semVer: validator_1.default.isSemVer,
29
- surrogatePair: validator_1.default.isSurrogatePair,
30
- IMEI: validator_1.default.isIMEI,
31
- hexadecimal: validator_1.default.isHexadecimal,
32
- octal: validator_1.default.isOctal,
33
- hexColor: validator_1.default.isHexColor,
34
- rgbColor: validator_1.default.isRgbColor,
35
- HSL: validator_1.default.isHSL,
36
- ISRC: validator_1.default.isISRC,
37
- MD5: validator_1.default.isMD5,
38
- JWT: validator_1.default.isJWT,
39
- UUID: validator_1.default.isUUID,
40
- luhnNumber: validator_1.default.isLuhnNumber,
41
- creditCard: validator_1.default.isCreditCard,
42
- identityCard: validator_1.default.isIdentityCard,
43
- EAN: validator_1.default.isEAN,
44
- ISIN: validator_1.default.isISIN,
45
- ISBN: validator_1.default.isISBN,
46
- ISSN: validator_1.default.isISSN,
47
- mobilePhone: validator_1.default.isMobilePhone,
48
- mobilePhoneLocales: validator_1.default.isMobilePhoneLocales,
49
- postalCode: validator_1.default.isPostalCode,
50
- postalCodeLocales: validator_1.default.isPostalCodeLocales,
51
- ethereumAddress: validator_1.default.isEthereumAddress,
52
- currency: validator_1.default.isCurrency,
53
- btcAddress: validator_1.default.isBtcAddress,
54
- ISO6391: validator_1.default.isISO6391,
55
- ISO8601: validator_1.default.isISO8601,
56
- RFC3339: validator_1.default.isRFC3339,
57
- ISO31661Alpha2: validator_1.default.isISO31661Alpha2,
58
- ISO31661Alpha3: validator_1.default.isISO31661Alpha3,
59
- ISO4217: validator_1.default.isISO4217,
60
- base32: validator_1.default.isBase32,
61
- base58: validator_1.default.isBase58,
62
- base64: validator_1.default.isBase64,
63
- dataURI: validator_1.default.isDataURI,
64
- magnetURI: validator_1.default.isMagnetURI,
65
- mimeType: validator_1.default.isMimeType,
66
- latLong: validator_1.default.isLatLong,
67
- slug: validator_1.default.isSlug,
68
- strongPassword: validator_1.default.isStrongPassword,
69
- taxID: validator_1.default.isTaxID,
70
- licensePlate: validator_1.default.isLicensePlate,
71
- VAT: validator_1.default.isVAT,
72
- };
73
- const validate = (path, value, fieldSchema) => {
74
- if (typeof value !== 'string') {
75
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
76
- }
77
- if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
78
- (0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
79
- }
80
- if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
81
- (0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
82
- }
83
- if (fieldSchema.pattern) {
84
- const re = new RegExp(fieldSchema.pattern);
85
- if (!re.test(value)) {
86
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
87
- }
88
- }
89
- if (fieldSchema.format && !formatPatterns[fieldSchema.format](value)) {
90
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
91
- }
92
- };
93
- const string = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
94
- if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
95
- return;
96
- }
97
- validate(path, value, fieldSchema);
98
- if (!noCollect) {
99
- handlers.collect({ path, value, typeSchema, fieldSchema, target });
100
- }
101
- };
102
- exports.string = string;
103
- const text = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
104
- const valueType = typeof value;
105
- if (target.$language && valueType === 'string') {
106
- validate(path, value, fieldSchema);
107
- if (!noCollect) {
108
- handlers.collect({
109
- path,
110
- value: { [target.$language]: value },
111
- typeSchema,
112
- fieldSchema,
113
- target,
114
- });
115
- }
116
- return;
117
- }
118
- if (valueType !== 'object') {
119
- (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
120
- }
121
- if (target.$language &&
122
- (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect))) {
123
- return;
124
- }
125
- else if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, true)) {
126
- if (!noCollect) {
127
- handlers.collect({
128
- path,
129
- value,
130
- typeSchema,
131
- fieldSchema,
132
- target,
133
- });
134
- }
135
- return;
136
- }
137
- for (const key in value) {
138
- const newPath = [...path, key];
139
- if (typeof value[key] === 'object') {
140
- if (value[key].$value) {
141
- (0, exports.text)([...path, key, '$value'], value[key].$value, fieldSchema, typeSchema, target, handlers, true);
142
- }
143
- if (!noCollect) {
144
- handlers.collect({
145
- path: newPath,
146
- value: null,
147
- typeSchema,
148
- fieldSchema,
149
- target,
150
- });
151
- }
152
- continue;
153
- }
154
- if (!(await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, { $language: key, [key]: value[key] }, fieldSchema, typeSchema, target, handlers, true))) {
155
- validate(newPath, value[key], fieldSchema);
156
- }
157
- if (!noCollect) {
158
- handlers.collect({
159
- path: newPath,
160
- value: value[key],
161
- typeSchema,
162
- fieldSchema,
163
- target,
164
- });
165
- }
166
- }
167
- };
168
- exports.text = text;
169
- //# sourceMappingURL=string.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/set/string.ts"],"names":[],"mappings":";;;;;;AACA,mCAA2C;AAE3C,0DAAkC;AAClC,iEAA6D;AAE7D,MAAM,cAAc,GAGhB;IACF,KAAK,EAA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