@skmtc/core 0.0.231 → 0.0.232

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.
@@ -2,7 +2,7 @@ import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefiniton: Definition<TypeSystemValue>;
5
+ typeDefinition: Definition<TypeSystemValue>;
6
6
  destructure: boolean;
7
7
  required?: boolean;
8
8
  };
@@ -12,12 +12,12 @@ type VoidParameter = {
12
12
  };
13
13
  type DestructuredParameter = {
14
14
  type: 'destructured';
15
- typeDefiniton: Definition<TypeSystemObject>;
15
+ typeDefinition: Definition<TypeSystemObject>;
16
16
  };
17
17
  type RegularParameter = {
18
18
  type: 'regular';
19
19
  name: string;
20
- typeDefiniton: Definition<TypeSystemValue>;
20
+ typeDefinition: Definition<TypeSystemValue>;
21
21
  required: boolean;
22
22
  };
23
23
  export declare class FunctionParameter {
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GACpB,aAAa,GACb,qBAAqB,GACrB,gBAAgB,CAAA;AAEpB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cA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AC,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB,CAAA;gBAEnB,IAAI,EAAE,UAAU;IA6B5B,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE;IAc1B,SAAS,IAAI,MAAM;IAkBnB,QAAQ,IAAI,MAAM;CAiBnB"}
@@ -10,21 +10,21 @@ export class FunctionParameter {
10
10
  });
11
11
  // @TODO It might be possible to simplify this by adding entityType
12
12
  // to Definition as one its generic parameter types
13
- if (args.typeDefiniton.identifier.entityType.type === 'value') {
13
+ if (args.typeDefinition.identifier.entityType.type === 'value') {
14
14
  throw new Error('Value identifiers cannot be used in type definitions');
15
15
  }
16
16
  this.properties = match(args)
17
- .with({ typeDefiniton: { value: { type: 'void' } } }, () => ({
17
+ .with({ typeDefinition: { value: { type: 'void' } } }, () => ({
18
18
  type: 'void'
19
19
  }))
20
- .with({ typeDefiniton: { value: { type: 'object' }, destructure: true } }, ({ typeDefiniton }) => ({
20
+ .with({ typeDefinition: { value: { type: 'object' } }, destructure: true }, ({ typeDefinition }) => ({
21
21
  type: 'destructured',
22
- typeDefiniton
22
+ typeDefinition
23
23
  }))
24
- .with({ name: P.string }, ({ typeDefiniton, name, required }) => ({
24
+ .with({ name: P.string }, ({ typeDefinition, name, required }) => ({
25
25
  type: 'regular',
26
26
  name,
27
- typeDefiniton,
27
+ typeDefinition,
28
28
  required: required ?? false
29
29
  }))
30
30
  .otherwise(() => {
@@ -35,9 +35,9 @@ export class FunctionParameter {
35
35
  if (this.properties.type === 'void') {
36
36
  return this;
37
37
  }
38
- invariant(this.properties.typeDefiniton.value.type === 'object', 'Only object types can be destructured');
38
+ invariant(this.properties.typeDefinition.value.type === 'object', 'Only object types can be destructured');
39
39
  return new FunctionParameter({
40
- typeDefiniton: this.properties.typeDefiniton,
40
+ typeDefinition: this.properties.typeDefinition,
41
41
  destructure: true
42
42
  });
43
43
  }
@@ -45,8 +45,8 @@ export class FunctionParameter {
45
45
  return match(this.properties)
46
46
  .with({ type: 'void' }, () => [])
47
47
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
48
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
49
- return toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
48
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
49
+ return toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
50
50
  })
51
51
  .otherwise(() => {
52
52
  throw new Error('Invalid parameter');
@@ -58,8 +58,8 @@ export class FunctionParameter {
58
58
  .with({ type: 'regular' }, ({ name }) => {
59
59
  return `${name}`;
60
60
  })
61
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
62
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
61
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
62
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
63
63
  return `{${propertyNames.join(', ')}}`;
64
64
  })
65
65
  .otherwise(() => {
@@ -69,12 +69,12 @@ export class FunctionParameter {
69
69
  toString() {
70
70
  return match(this.properties)
71
71
  .with({ type: 'void' }, () => '')
72
- .with({ type: 'regular' }, ({ name, typeDefiniton, required }) => {
73
- return `${name}${required ? '' : '?'}: ${typeDefiniton.identifier}`;
72
+ .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
73
+ return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
74
74
  })
75
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
76
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
77
- return `{${propertyNames.join(', ')}}: ${typeDefiniton.identifier}`;
75
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
76
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
77
+ return `{${propertyNames.join(', ')}}: ${typeDefinition.identifier}`;
78
78
  })
79
79
  .otherwise(() => {
80
80
  throw new Error('Invalid parameter');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.231",
3
+ "version": "0.0.232",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -2,7 +2,7 @@ import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefiniton: Definition<TypeSystemValue>;
5
+ typeDefinition: Definition<TypeSystemValue>;
6
6
  destructure: boolean;
7
7
  required?: boolean;
8
8
  };
@@ -12,12 +12,12 @@ type VoidParameter = {
12
12
  };
13
13
  type DestructuredParameter = {
14
14
  type: 'destructured';
15
- typeDefiniton: Definition<TypeSystemObject>;
15
+ typeDefinition: Definition<TypeSystemObject>;
16
16
  };
17
17
  type RegularParameter = {
18
18
  type: 'regular';
19
19
  name: string;
20
- typeDefiniton: Definition<TypeSystemValue>;
20
+ typeDefinition: Definition<TypeSystemValue>;
21
21
  required: boolean;
22
22
  };
23
23
  export declare class FunctionParameter {
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO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AAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;CAC7C,CAAA;AACD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB,CAAA;gBAEnB,IAAI,EAAE,UAAU;IA6B5B,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE;IAc1B,SAAS,IAAI,MAAM;IAkBnB,QAAQ,IAAI,MAAM;CAiBnB"}
@@ -16,21 +16,21 @@ class FunctionParameter {
16
16
  });
17
17
  // @TODO It might be possible to simplify this by adding entityType
18
18
  // to Definition as one its generic parameter types
19
- if (args.typeDefiniton.identifier.entityType.type === 'value') {
19
+ if (args.typeDefinition.identifier.entityType.type === 'value') {
20
20
  throw new Error('Value identifiers cannot be used in type definitions');
21
21
  }
22
22
  this.properties = (0, ts_pattern_1.match)(args)
23
- .with({ typeDefiniton: { value: { type: 'void' } } }, () => ({
23
+ .with({ typeDefinition: { value: { type: 'void' } } }, () => ({
24
24
  type: 'void'
25
25
  }))
26
- .with({ typeDefiniton: { value: { type: 'object' }, destructure: true } }, ({ typeDefiniton }) => ({
26
+ .with({ typeDefinition: { value: { type: 'object' } }, destructure: true }, ({ typeDefinition }) => ({
27
27
  type: 'destructured',
28
- typeDefiniton
28
+ typeDefinition
29
29
  }))
30
- .with({ name: ts_pattern_1.P.string }, ({ typeDefiniton, name, required }) => ({
30
+ .with({ name: ts_pattern_1.P.string }, ({ typeDefinition, name, required }) => ({
31
31
  type: 'regular',
32
32
  name,
33
- typeDefiniton,
33
+ typeDefinition,
34
34
  required: required ?? false
35
35
  }))
36
36
  .otherwise(() => {
@@ -41,9 +41,9 @@ class FunctionParameter {
41
41
  if (this.properties.type === 'void') {
42
42
  return this;
43
43
  }
44
- (0, tiny_invariant_1.default)(this.properties.typeDefiniton.value.type === 'object', 'Only object types can be destructured');
44
+ (0, tiny_invariant_1.default)(this.properties.typeDefinition.value.type === 'object', 'Only object types can be destructured');
45
45
  return new FunctionParameter({
46
- typeDefiniton: this.properties.typeDefiniton,
46
+ typeDefinition: this.properties.typeDefinition,
47
47
  destructure: true
48
48
  });
49
49
  }
@@ -51,8 +51,8 @@ class FunctionParameter {
51
51
  return (0, ts_pattern_1.match)(this.properties)
52
52
  .with({ type: 'void' }, () => [])
53
53
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
54
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
55
- return toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
54
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
55
+ return toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
56
56
  })
57
57
  .otherwise(() => {
58
58
  throw new Error('Invalid parameter');
@@ -64,8 +64,8 @@ class FunctionParameter {
64
64
  .with({ type: 'regular' }, ({ name }) => {
65
65
  return `${name}`;
66
66
  })
67
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
68
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
67
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
68
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
69
69
  return `{${propertyNames.join(', ')}}`;
70
70
  })
71
71
  .otherwise(() => {
@@ -75,12 +75,12 @@ class FunctionParameter {
75
75
  toString() {
76
76
  return (0, ts_pattern_1.match)(this.properties)
77
77
  .with({ type: 'void' }, () => '')
78
- .with({ type: 'regular' }, ({ name, typeDefiniton, required }) => {
79
- return `${name}${required ? '' : '?'}: ${typeDefiniton.identifier}`;
78
+ .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
79
+ return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
80
80
  })
81
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
82
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
83
- return `{${propertyNames.join(', ')}}: ${typeDefiniton.identifier}`;
81
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
82
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
83
+ return `{${propertyNames.join(', ')}}: ${typeDefinition.identifier}`;
84
84
  })
85
85
  .otherwise(() => {
86
86
  throw new Error('Invalid parameter');