@skmtc/core 0.0.540 → 0.0.541

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,11 +1,12 @@
1
1
  import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  import { List } from './List.js';
4
- type CreateArgs = {
4
+ type FunctionParameterArgs = {
5
5
  name?: string;
6
6
  typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
7
7
  destructure?: boolean;
8
8
  required?: boolean;
9
+ skipEmpty?: boolean;
9
10
  };
10
11
  type ParameterProperties = VoidParameter | DestructuredParameter | RegularParameter;
11
12
  type VoidParameter = {
@@ -24,7 +25,8 @@ type RegularParameter = {
24
25
  };
25
26
  export declare class FunctionParameter {
26
27
  properties: ParameterProperties;
27
- constructor(args: CreateArgs);
28
+ skipEmpty?: boolean;
29
+ constructor(args: FunctionParameterArgs);
28
30
  hasProperty(name: string): boolean;
29
31
  toPropertyList(): List;
30
32
  toInbound(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,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;AA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I,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;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;gBAEP,IAAI,EAAE,qBAAqB;IA2BvC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAalC,cAAc,IAAI,IAAI;IAUtB,SAAS,IAAI,MAAM;IAUnB,QAAQ,IAAI,MAAM;CAuBnB"}
@@ -10,6 +10,13 @@ export class FunctionParameter {
10
10
  writable: true,
11
11
  value: void 0
12
12
  });
13
+ Object.defineProperty(this, "skipEmpty", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ this.skipEmpty = args.skipEmpty;
13
20
  if (args.typeDefinition.value.type === 'object') {
14
21
  this.properties = match(args)
15
22
  .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
@@ -68,6 +75,12 @@ export class FunctionParameter {
68
75
  return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
69
76
  })
70
77
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
78
+ if (this.skipEmpty) {
79
+ const isEmpty = Object.keys(typeDefinition.value.objectProperties?.properties ?? {}).length === 0;
80
+ if (isEmpty) {
81
+ return '';
82
+ }
83
+ }
71
84
  return List.toKeyValue(toDestructured(typeDefinition).toString(), typeDefinition.identifier).toString();
72
85
  })
73
86
  .exhaustive();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.540",
3
+ "version": "0.0.541",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1,11 +1,12 @@
1
1
  import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  import { List } from './List.js';
4
- type CreateArgs = {
4
+ type FunctionParameterArgs = {
5
5
  name?: string;
6
6
  typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
7
7
  destructure?: boolean;
8
8
  required?: boolean;
9
+ skipEmpty?: boolean;
9
10
  };
10
11
  type ParameterProperties = VoidParameter | DestructuredParameter | RegularParameter;
11
12
  type VoidParameter = {
@@ -24,7 +25,8 @@ type RegularParameter = {
24
25
  };
25
26
  export declare class FunctionParameter {
26
27
  properties: ParameterProperties;
27
- constructor(args: CreateArgs);
28
+ skipEmpty?: boolean;
29
+ constructor(args: FunctionParameterArgs);
28
30
  hasProperty(name: string): boolean;
29
31
  toPropertyList(): List;
30
32
  toInbound(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,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,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nF,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;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;gBAEP,IAAI,EAAE,qBAAqB;IA2BvC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAalC,cAAc,IAAI,IAAI;IAUtB,SAAS,IAAI,MAAM;IAUnB,QAAQ,IAAI,MAAM;CAuBnB"}
@@ -13,6 +13,13 @@ class FunctionParameter {
13
13
  writable: true,
14
14
  value: void 0
15
15
  });
16
+ Object.defineProperty(this, "skipEmpty", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ this.skipEmpty = args.skipEmpty;
16
23
  if (args.typeDefinition.value.type === 'object') {
17
24
  this.properties = (0, ts_pattern_1.match)(args)
18
25
  .with({ destructure: true, required: true }, ({ typeDefinition, required }) => ({
@@ -71,6 +78,12 @@ class FunctionParameter {
71
78
  return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
72
79
  })
73
80
  .with({ type: 'destructured' }, ({ typeDefinition }) => {
81
+ if (this.skipEmpty) {
82
+ const isEmpty = Object.keys(typeDefinition.value.objectProperties?.properties ?? {}).length === 0;
83
+ if (isEmpty) {
84
+ return '';
85
+ }
86
+ }
74
87
  return List_js_1.List.toKeyValue(toDestructured(typeDefinition).toString(), typeDefinition.identifier).toString();
75
88
  })
76
89
  .exhaustive();