ts-fortress 4.2.0 → 4.2.1

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.
@@ -58,6 +58,6 @@ export { createCastFn } from './utils/create-cast-fn.mjs';
58
58
  export { createIsFn } from './utils/create-is-fn.mjs';
59
59
  export { createPrimitiveType } from './utils/create-primitive-type.mjs';
60
60
  export { createType } from './utils/create-type.mjs';
61
- export { toIntersectionString, toUnionString } from './utils/to-union-string.mjs';
61
+ export { toIntersectionString, toUnionKeyString, toUnionString } from './utils/to-union-string.mjs';
62
62
  export { createPrimitiveValidationError, prependIndexToValidationErrors, prependPathToValidationErrors, validationErrorToMessage, validationErrorsToMessages } from './utils/validation-error.mjs';
63
63
  //# sourceMappingURL=entry-point.mjs.map
package/dist/index.mjs CHANGED
@@ -58,6 +58,6 @@ export { createCastFn } from './utils/create-cast-fn.mjs';
58
58
  export { createIsFn } from './utils/create-is-fn.mjs';
59
59
  export { createPrimitiveType } from './utils/create-primitive-type.mjs';
60
60
  export { createType } from './utils/create-type.mjs';
61
- export { toIntersectionString, toUnionString } from './utils/to-union-string.mjs';
61
+ export { toIntersectionString, toUnionKeyString, toUnionString } from './utils/to-union-string.mjs';
62
62
  export { createPrimitiveValidationError, prependIndexToValidationErrors, prependPathToValidationErrors, validationErrorToMessage, validationErrorsToMessages } from './utils/validation-error.mjs';
63
63
  //# sourceMappingURL=index.mjs.map
@@ -1,11 +1,11 @@
1
1
  import { Obj } from 'ts-data-forge';
2
- import { toUnionString } from '../utils/to-union-string.mjs';
2
+ import { toUnionKeyString } from '../utils/to-union-string.mjs';
3
3
  import { record } from './record.mjs';
4
4
 
5
5
  /** Creates a record type with keys omitted. */
6
6
  const omit = (recordType, keysToOmit, options) => record(Obj.omit(recordType.shape, keysToOmit), {
7
7
  typeName: options?.typeName ??
8
- `Omit<${recordType.typeName}, ${toUnionString(keysToOmit)}>`,
8
+ `Omit<${recordType.typeName}, ${toUnionKeyString(keysToOmit)}>`,
9
9
  allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
10
10
  });
11
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"omit.mjs","sources":["../../src/record/omit.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,aAAa,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AAC9D,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
1
+ {"version":3,"file":"omit.mjs","sources":["../../src/record/omit.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
@@ -1,5 +1,5 @@
1
1
  import 'ts-data-forge';
2
- import { toUnionString } from '../utils/to-union-string.mjs';
2
+ import { toUnionKeyString } from '../utils/to-union-string.mjs';
3
3
  import { optional } from './optional.mjs';
4
4
  import { record } from './record.mjs';
5
5
 
@@ -11,7 +11,7 @@ const partial = (recordType, options) => {
11
11
  const typeNameFilled = options?.typeName ??
12
12
  (options?.keysToBeOptional === undefined
13
13
  ? `Partial<${recordType.typeName}>`
14
- : `PartiallyPartial<${recordType.typeName}, ${toUnionString(options.keysToBeOptional)}>`);
14
+ : `PartiallyPartial<${recordType.typeName}, ${toUnionKeyString(options.keysToBeOptional)}>`);
15
15
  const keysToBeOptional = new Set(options?.keysToBeOptional ?? Object.keys(recordType.shape));
16
16
  const partialShape =
17
17
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
@@ -1 +1 @@
1
- {"version":3,"file":"partial.mjs","sources":["../../src/record/partial.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;;;AAGG;MACU,OAAO,GAAG,CAIrB,UAAyB,EACzB,OAME,KACkC;AACpC,IAAA,MAAM,cAAc,GAClB,OAAO,EAAE,QAAQ;AACjB,SAAC,OAAO,EAAE,gBAAgB,KAAK;AAC7B,cAAE,CAAA,QAAA,EAAW,UAAU,CAAC,QAAQ,CAAA,CAAA;AAChC,cAAE,CAAA,iBAAA,EAAoB,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA,CAAA,CAAG,CAAC;AAE7F,IAAA,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CACnD,OAAO,EAAE,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAC3D;AAED,IAAA,MAAM,YAAY;;IAEhB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAClC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAU,CACpE,CAIF;IAEH,OAAO,MAAM,CAAC,YAAY,EAAE;AAC1B,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,KAAA,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"partial.mjs","sources":["../../src/record/partial.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;;;AAGG;MACU,OAAO,GAAG,CAIrB,UAAyB,EACzB,OAME,KACkC;AACpC,IAAA,MAAM,cAAc,GAClB,OAAO,EAAE,QAAQ;AACjB,SAAC,OAAO,EAAE,gBAAgB,KAAK;AAC7B,cAAE,CAAA,QAAA,EAAW,UAAU,CAAC,QAAQ,CAAA,CAAA;AAChC,cAAE,CAAA,iBAAA,EAAoB,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA,CAAA,CAAG,CAAC;AAEhG,IAAA,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CACnD,OAAO,EAAE,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAC3D;AAED,IAAA,MAAM,YAAY;;IAEhB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAClC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAU,CACpE,CAIF;IAEH,OAAO,MAAM,CAAC,YAAY,EAAE;AAC1B,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,KAAA,CAAC;AACJ;;;;"}
@@ -1,11 +1,11 @@
1
1
  import { Obj } from 'ts-data-forge';
2
- import { toUnionString } from '../utils/to-union-string.mjs';
2
+ import { toUnionKeyString } from '../utils/to-union-string.mjs';
3
3
  import { record } from './record.mjs';
4
4
 
5
5
  /** Creates a record type with keys picked. */
6
6
  const pick = (recordType, keysToPick, options) => record(Obj.pick(recordType.shape, keysToPick), {
7
7
  typeName: options?.typeName ??
8
- `Pick<${recordType.typeName}, ${toUnionString(keysToPick)}>`,
8
+ `Pick<${recordType.typeName}, ${toUnionKeyString(keysToPick)}>`,
9
9
  allowExcessProperties: options?.allowExcessProperties ?? recordType.allowExcessProperties,
10
10
  });
11
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"pick.mjs","sources":["../../src/record/pick.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,aAAa,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AAC9D,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
1
+ {"version":3,"file":"pick.mjs","sources":["../../src/record/pick.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AACO,MAAM,IAAI,GAAG,CAIlB,UAAyB,EACzB,UAAsB,EACtB,OAKE,KAEF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;IAC7C,QAAQ,EACN,OAAO,EAAE,QAAQ;QACjB,CAAA,KAAA,EAAQ,UAAU,CAAC,QAAQ,CAAA,EAAA,EAAK,gBAAgB,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG;AACjE,IAAA,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,qBAAqB;AACrE,CAAA;;;;"}
@@ -3,6 +3,6 @@ export { createCastFn } from './create-cast-fn.mjs';
3
3
  export { createIsFn } from './create-is-fn.mjs';
4
4
  export { createPrimitiveType } from './create-primitive-type.mjs';
5
5
  export { createType } from './create-type.mjs';
6
- export { toIntersectionString, toUnionString } from './to-union-string.mjs';
6
+ export { toIntersectionString, toUnionKeyString, toUnionString } from './to-union-string.mjs';
7
7
  export { createPrimitiveValidationError, prependIndexToValidationErrors, prependPathToValidationErrors, validationErrorToMessage, validationErrorsToMessages } from './validation-error.mjs';
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,4 @@
1
+ export declare const toUnionKeyString: (members: readonly string[]) => string;
1
2
  export declare const toUnionString: (members: readonly string[]) => string;
2
3
  export declare const toIntersectionString: (members: readonly string[]) => string;
3
4
  //# sourceMappingURL=to-union-string.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-union-string.d.mts","sourceRoot":"","sources":["../../src/utils/to-union-string.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MACjB,CAAC;AAE3C,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MACxB,CAAC"}
1
+ {"version":3,"file":"to-union-string.d.mts","sourceRoot":"","sources":["../../src/utils/to-union-string.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MACpB,CAAC;AAE3C,eAAO,MAAM,aAAa,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MACtC,CAAC;AAEtB,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MAC7C,CAAC"}
@@ -1,5 +1,6 @@
1
- const toUnionString = (members) => members.map((k) => `"${k}"`).join(' | ');
2
- const toIntersectionString = (members) => members.map((k) => `"${k}"`).join(' & ');
1
+ const toUnionKeyString = (members) => members.map((k) => `"${k}"`).join(' | ');
2
+ const toUnionString = (members) => members.join(' | ');
3
+ const toIntersectionString = (members) => members.join(' & ');
3
4
 
4
- export { toIntersectionString, toUnionString };
5
+ export { toIntersectionString, toUnionKeyString, toUnionString };
5
6
  //# sourceMappingURL=to-union-string.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-union-string.mjs","sources":["../../src/utils/to-union-string.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,aAAa,GAAG,CAAC,OAA0B,KACtD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,CAAG,CAAC,CAAC,IAAI,CAAC,KAAK;AAElC,MAAM,oBAAoB,GAAG,CAAC,OAA0B,KAC7D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,CAAG,CAAC,CAAC,IAAI,CAAC,KAAK;;;;"}
1
+ {"version":3,"file":"to-union-string.mjs","sources":["../../src/utils/to-union-string.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,gBAAgB,GAAG,CAAC,OAA0B,KACzD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,CAAG,CAAC,CAAC,IAAI,CAAC,KAAK;AAElC,MAAM,aAAa,GAAG,CAAC,OAA0B,KACtD,OAAO,CAAC,IAAI,CAAC,KAAK;AAEb,MAAM,oBAAoB,GAAG,CAAC,OAA0B,KAC7D,OAAO,CAAC,IAAI,CAAC,KAAK;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-fortress",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -109,9 +109,8 @@ describe('intersection', () => {
109
109
  path: [],
110
110
  actualValue: { x: 0, y: 1 },
111
111
  expectedType:
112
- '("{ x: number, y: number }" & "{ z: number, w: number }")',
113
- typeName:
114
- '("{ x: number, y: number }" & "{ z: number, w: number }")',
112
+ '({ x: number, y: number } & { z: number, w: number })',
113
+ typeName: '({ x: number, y: number } & { z: number, w: number })',
115
114
  message:
116
115
  'The type of value is expected to match all types of { { x: number, y: number }, { z: number, w: number } }',
117
116
  },
@@ -221,10 +220,10 @@ describe('intersection', () => {
221
220
  {
222
221
  path: [],
223
222
  actualValue: 'aaa',
224
- expectedType: '("number" & "number")',
223
+ expectedType: '(number & number)',
225
224
  message:
226
225
  'The type of value is expected to match all types of { number, number }',
227
- typeName: '("number" & "number")',
226
+ typeName: '(number & number)',
228
227
  },
229
228
  {
230
229
  path: [],
@@ -236,10 +235,10 @@ describe('intersection', () => {
236
235
  {
237
236
  path: [],
238
237
  actualValue: 'aaa',
239
- expectedType: '("number" & "number")',
238
+ expectedType: '(number & number)',
240
239
  message:
241
240
  'The type of value is expected to match all types of { number, number }',
242
- typeName: '("number" & "number")',
241
+ typeName: '(number & number)',
243
242
  },
244
243
  {
245
244
  path: [],
@@ -356,10 +355,10 @@ describe('intersection', () => {
356
355
  {
357
356
  path: [],
358
357
  actualValue: 7,
359
- expectedType: '("uintRange(0, 5)" & "uintRange(1, 7)")',
358
+ expectedType: '(uintRange(0, 5) & uintRange(1, 7))',
360
359
  message:
361
360
  'The type of value is expected to match all types of { uintRange(0, 5), uintRange(1, 7) }',
362
- typeName: '("uintRange(0, 5)" & "uintRange(1, 7)")',
361
+ typeName: '(uintRange(0, 5) & uintRange(1, 7))',
363
362
  },
364
363
  {
365
364
  path: [],
@@ -371,10 +370,10 @@ describe('intersection', () => {
371
370
  {
372
371
  path: [],
373
372
  actualValue: 7,
374
- expectedType: '("uintRange(0, 5)" & "uintRange(1, 7)")',
373
+ expectedType: '(uintRange(0, 5) & uintRange(1, 7))',
375
374
  message:
376
375
  'The type of value is expected to match all types of { uintRange(0, 5), uintRange(1, 7) }',
377
- typeName: '("uintRange(0, 5)" & "uintRange(1, 7)")',
376
+ typeName: '(uintRange(0, 5) & uintRange(1, 7))',
378
377
  },
379
378
  {
380
379
  path: [],
@@ -101,9 +101,8 @@ describe('mergeRecords', () => {
101
101
  path: [],
102
102
  actualValue: { x: 0, y: 1 },
103
103
  expectedType:
104
- '("{ x: number, y: number }" & "{ z: number, w: number }")',
105
- typeName:
106
- '("{ x: number, y: number }" & "{ z: number, w: number }")',
104
+ '({ x: number, y: number } & { z: number, w: number })',
105
+ typeName: '({ x: number, y: number } & { z: number, w: number })',
107
106
  message:
108
107
  'The type of value is expected to match all types of { { x: number, y: number }, { z: number, w: number } }',
109
108
  },
@@ -91,9 +91,8 @@ describe('union', () => {
91
91
  path: [],
92
92
  actualValue: 5,
93
93
  expectedType:
94
- '("{ x: number, y: number }" | "literal(3)" | "literal("2")")',
95
- typeName:
96
- '("{ x: number, y: number }" | "literal(3)" | "literal("2")")',
94
+ '({ x: number, y: number } | literal(3) | literal("2"))',
95
+ typeName: '({ x: number, y: number } | literal(3) | literal("2"))',
97
96
  message:
98
97
  'The type of value is expected to be one of the elements contained in { { x: number, y: number }, literal(3), literal("2") }',
99
98
  });
@@ -1,6 +1,6 @@
1
1
  import { expectType, Obj } from 'ts-data-forge';
2
2
  import { type RecordType, type Type } from '../type.mjs';
3
- import { toUnionString } from '../utils/index.mjs';
3
+ import { toUnionKeyString } from '../utils/index.mjs';
4
4
  import { record } from './record.mjs';
5
5
 
6
6
  /** Creates a record type with keys omitted. */
@@ -20,7 +20,7 @@ export const omit = <
20
20
  record(Obj.omit(recordType.shape, keysToOmit), {
21
21
  typeName:
22
22
  options?.typeName ??
23
- `Omit<${recordType.typeName}, ${toUnionString(keysToOmit)}>`,
23
+ `Omit<${recordType.typeName}, ${toUnionKeyString(keysToOmit)}>`,
24
24
  allowExcessProperties:
25
25
  options?.allowExcessProperties ?? recordType.allowExcessProperties,
26
26
  });
@@ -1,6 +1,6 @@
1
1
  import { expectType } from 'ts-data-forge';
2
2
  import { type RecordType, type Type } from '../type.mjs';
3
- import { toUnionString } from '../utils/index.mjs';
3
+ import { toUnionKeyString } from '../utils/index.mjs';
4
4
  import { optional, type OptionalPropertyType } from './optional.mjs';
5
5
  import { record } from './record.mjs';
6
6
 
@@ -25,7 +25,7 @@ export const partial = <
25
25
  options?.typeName ??
26
26
  (options?.keysToBeOptional === undefined
27
27
  ? `Partial<${recordType.typeName}>`
28
- : `PartiallyPartial<${recordType.typeName}, ${toUnionString(options.keysToBeOptional)}>`);
28
+ : `PartiallyPartial<${recordType.typeName}, ${toUnionKeyString(options.keysToBeOptional)}>`);
29
29
 
30
30
  const keysToBeOptional: ReadonlySet<string> = new Set(
31
31
  options?.keysToBeOptional ?? Object.keys(recordType.shape),
@@ -1,6 +1,6 @@
1
1
  import { expectType, Obj } from 'ts-data-forge';
2
2
  import { type RecordType, type Type } from '../type.mjs';
3
- import { toUnionString } from '../utils/index.mjs';
3
+ import { toUnionKeyString } from '../utils/index.mjs';
4
4
  import { record } from './record.mjs';
5
5
 
6
6
  /** Creates a record type with keys picked. */
@@ -20,7 +20,7 @@ export const pick = <
20
20
  record(Obj.pick(recordType.shape, keysToPick), {
21
21
  typeName:
22
22
  options?.typeName ??
23
- `Pick<${recordType.typeName}, ${toUnionString(keysToPick)}>`,
23
+ `Pick<${recordType.typeName}, ${toUnionKeyString(keysToPick)}>`,
24
24
  allowExcessProperties:
25
25
  options?.allowExcessProperties ?? recordType.allowExcessProperties,
26
26
  });
@@ -1,5 +1,8 @@
1
- export const toUnionString = (members: readonly string[]): string =>
1
+ export const toUnionKeyString = (members: readonly string[]): string =>
2
2
  members.map((k) => `"${k}"`).join(' | ');
3
3
 
4
+ export const toUnionString = (members: readonly string[]): string =>
5
+ members.join(' | ');
6
+
4
7
  export const toIntersectionString = (members: readonly string[]): string =>
5
- members.map((k) => `"${k}"`).join(' & ');
8
+ members.join(' & ');