@skmtc/core 0.0.258 → 0.0.259

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.
@@ -1,12 +1,15 @@
1
- import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
1
+ import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefinition: Definition<TypeSystemObject>;
5
+ typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
6
6
  destructure?: boolean;
7
7
  required?: boolean;
8
8
  };
9
- type ParameterProperties = DestructuredParameter | RegularParameter;
9
+ type ParameterProperties = VoidParameter | DestructuredParameter | RegularParameter;
10
+ type VoidParameter = {
11
+ type: 'void';
12
+ };
10
13
  type DestructuredParameter = {
11
14
  type: 'destructured';
12
15
  typeDefinition: Definition<TypeSystemObject>;
@@ -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;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GAAG,qBAAqB,GAAG,gBAAgB,CAAA;AAEnE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;A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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;IAyB5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAelC,cAAc,IAAI,MAAM,EAAE;IAY1B,SAAS,IAAI,MAAM;IAUnB,QAAQ,IAAI,MAAM;CAanB"}
@@ -8,24 +8,30 @@ export class FunctionParameter {
8
8
  writable: true,
9
9
  value: void 0
10
10
  });
11
- this.properties = match(args)
12
- .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
13
- type: 'destructured',
14
- typeDefinition,
15
- required
16
- }))
17
- .with({ name: P.string }, ({ typeDefinition, name, required }) => ({
18
- type: 'regular',
19
- name,
20
- typeDefinition,
21
- required: required ?? false
22
- }))
23
- .otherwise(() => {
24
- throw new Error('Invalid FunctionParameter');
25
- });
11
+ if (args.typeDefinition.value.type === 'object') {
12
+ this.properties = match(args)
13
+ .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
14
+ type: 'destructured',
15
+ typeDefinition: typeDefinition,
16
+ required
17
+ }))
18
+ .with({ name: P.string }, ({ typeDefinition, name, required }) => ({
19
+ type: 'regular',
20
+ name,
21
+ typeDefinition: typeDefinition,
22
+ required: required ?? false
23
+ }))
24
+ .otherwise(() => {
25
+ throw new Error('Invalid FunctionParameter');
26
+ });
27
+ }
28
+ else {
29
+ this.properties = { type: 'void' };
30
+ }
26
31
  }
27
32
  hasProperty(name) {
28
33
  return match(this.properties)
34
+ .with({ type: 'void' }, () => false)
29
35
  .with({ type: 'regular' }, ({ typeDefinition }) => {
30
36
  const { value } = typeDefinition;
31
37
  return Boolean(value.type === 'object' && value.objectProperties?.properties[name]);
@@ -37,6 +43,7 @@ export class FunctionParameter {
37
43
  }
38
44
  toPropertyList() {
39
45
  return match(this.properties)
46
+ .with({ type: 'void' }, () => [])
40
47
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
41
48
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
42
49
  return new DestructuredObject(typeDefinition.value).properties.map(item => (typeof item === 'string' ? item : item.name));
@@ -45,6 +52,7 @@ export class FunctionParameter {
45
52
  }
46
53
  toInbound() {
47
54
  return match(this.properties)
55
+ .with({ type: 'void' }, () => '')
48
56
  .with({ type: 'regular' }, ({ name }) => `${name}`)
49
57
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
50
58
  return new DestructuredObject(typeDefinition.value).toString();
@@ -53,6 +61,7 @@ export class FunctionParameter {
53
61
  }
54
62
  toString() {
55
63
  return match(this.properties)
64
+ .with({ type: 'void' }, () => '')
56
65
  .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
57
66
  return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
58
67
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.258",
3
+ "version": "0.0.259",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1,12 +1,15 @@
1
- import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
1
+ import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefinition: Definition<TypeSystemObject>;
5
+ typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
6
6
  destructure?: boolean;
7
7
  required?: boolean;
8
8
  };
9
- type ParameterProperties = DestructuredParameter | RegularParameter;
9
+ type ParameterProperties = VoidParameter | DestructuredParameter | RegularParameter;
10
+ type VoidParameter = {
11
+ type: 'void';
12
+ };
10
13
  type DestructuredParameter = {
11
14
  type: 'destructured';
12
15
  typeDefinition: Definition<TypeSystemObject>;
@@ -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;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GAAG,qBAAqB,GAAG,gBAAgB,CAAA;AAEnE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AAED,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;IAqB5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAclC,cAAc,IAAI,MAAM,EAAE;IAW1B,SAAS,IAAI,MAAM;IASnB,QAAQ,IAAI,MAAM;CAYnB"}
1
+ {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,gBAAgB,GAAG,cAAc,CAAC,CAAA;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,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,cAAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AAED,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;IAyB5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAelC,cAAc,IAAI,MAAM,EAAE;IAY1B,SAAS,IAAI,MAAM;IAUnB,QAAQ,IAAI,MAAM;CAanB"}
@@ -11,24 +11,30 @@ class FunctionParameter {
11
11
  writable: true,
12
12
  value: void 0
13
13
  });
14
- this.properties = (0, ts_pattern_1.match)(args)
15
- .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
16
- type: 'destructured',
17
- typeDefinition,
18
- required
19
- }))
20
- .with({ name: ts_pattern_1.P.string }, ({ typeDefinition, name, required }) => ({
21
- type: 'regular',
22
- name,
23
- typeDefinition,
24
- required: required ?? false
25
- }))
26
- .otherwise(() => {
27
- throw new Error('Invalid FunctionParameter');
28
- });
14
+ if (args.typeDefinition.value.type === 'object') {
15
+ this.properties = (0, ts_pattern_1.match)(args)
16
+ .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
17
+ type: 'destructured',
18
+ typeDefinition: typeDefinition,
19
+ required
20
+ }))
21
+ .with({ name: ts_pattern_1.P.string }, ({ typeDefinition, name, required }) => ({
22
+ type: 'regular',
23
+ name,
24
+ typeDefinition: typeDefinition,
25
+ required: required ?? false
26
+ }))
27
+ .otherwise(() => {
28
+ throw new Error('Invalid FunctionParameter');
29
+ });
30
+ }
31
+ else {
32
+ this.properties = { type: 'void' };
33
+ }
29
34
  }
30
35
  hasProperty(name) {
31
36
  return (0, ts_pattern_1.match)(this.properties)
37
+ .with({ type: 'void' }, () => false)
32
38
  .with({ type: 'regular' }, ({ typeDefinition }) => {
33
39
  const { value } = typeDefinition;
34
40
  return Boolean(value.type === 'object' && value.objectProperties?.properties[name]);
@@ -40,6 +46,7 @@ class FunctionParameter {
40
46
  }
41
47
  toPropertyList() {
42
48
  return (0, ts_pattern_1.match)(this.properties)
49
+ .with({ type: 'void' }, () => [])
43
50
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
44
51
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
45
52
  return new DestructuredObject_js_1.DestructuredObject(typeDefinition.value).properties.map(item => (typeof item === 'string' ? item : item.name));
@@ -48,6 +55,7 @@ class FunctionParameter {
48
55
  }
49
56
  toInbound() {
50
57
  return (0, ts_pattern_1.match)(this.properties)
58
+ .with({ type: 'void' }, () => '')
51
59
  .with({ type: 'regular' }, ({ name }) => `${name}`)
52
60
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
53
61
  return new DestructuredObject_js_1.DestructuredObject(typeDefinition.value).toString();
@@ -56,6 +64,7 @@ class FunctionParameter {
56
64
  }
57
65
  toString() {
58
66
  return (0, ts_pattern_1.match)(this.properties)
67
+ .with({ type: 'void' }, () => '')
59
68
  .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
60
69
  return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
61
70
  })