@skmtc/core 0.0.254 → 0.0.256
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.
- package/esm/typescript/FunctionParameter.d.ts +3 -0
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/FunctionParameter.js +21 -0
- package/package.json +1 -1
- package/script/typescript/FunctionParameter.d.ts +3 -0
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/FunctionParameter.js +21 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
|
|
2
2
|
import type { Definition } from '../dsl/Definition.js';
|
|
3
|
+
import { ObjectProperty } from './DestructuredObject.js';
|
|
3
4
|
import type { Stringable } from '../dsl/Stringable.js';
|
|
4
5
|
type CreateArgs = {
|
|
5
6
|
name?: string;
|
|
@@ -24,7 +25,9 @@ type RegularParameter = {
|
|
|
24
25
|
export declare class FunctionParameter {
|
|
25
26
|
properties: ParameterProperties;
|
|
26
27
|
constructor(args: CreateArgs);
|
|
28
|
+
hasProperty(name: string): boolean;
|
|
27
29
|
toDestructured(): FunctionParameter;
|
|
30
|
+
toPropertyList(): string[] | ObjectProperty[];
|
|
28
31
|
toInbound(): Stringable;
|
|
29
32
|
toString(): string;
|
|
30
33
|
}
|
|
@@ -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;
|
|
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;AACtD,OAAO,EAAsB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,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,cAAc,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;IAuB5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAelC,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE,GAAG,cAAc,EAAE;IAU7C,SAAS,IAAI,UAAU;IAUvB,QAAQ,IAAI,MAAM;CAWnB"}
|
|
@@ -27,6 +27,18 @@ export class FunctionParameter {
|
|
|
27
27
|
throw new Error('Invalid parameter');
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
hasProperty(name) {
|
|
31
|
+
return match(this.properties)
|
|
32
|
+
.with({ type: 'void' }, () => false)
|
|
33
|
+
.with({ type: 'regular' }, ({ typeDefinition }) => {
|
|
34
|
+
const { value } = typeDefinition;
|
|
35
|
+
return Boolean(value.type === 'object' && value.objectProperties?.properties[name]);
|
|
36
|
+
})
|
|
37
|
+
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
38
|
+
return Boolean(typeDefinition.value.objectProperties?.properties[name]);
|
|
39
|
+
})
|
|
40
|
+
.exhaustive();
|
|
41
|
+
}
|
|
30
42
|
toDestructured() {
|
|
31
43
|
if (this.properties.type === 'void') {
|
|
32
44
|
return this;
|
|
@@ -37,6 +49,15 @@ export class FunctionParameter {
|
|
|
37
49
|
destructure: true
|
|
38
50
|
});
|
|
39
51
|
}
|
|
52
|
+
toPropertyList() {
|
|
53
|
+
return match(this.properties)
|
|
54
|
+
.with({ type: 'void' }, () => [])
|
|
55
|
+
.with({ type: 'regular' }, ({ name }) => [`${name}`])
|
|
56
|
+
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
57
|
+
return new DestructuredObject(typeDefinition.value).properties;
|
|
58
|
+
})
|
|
59
|
+
.exhaustive();
|
|
60
|
+
}
|
|
40
61
|
toInbound() {
|
|
41
62
|
return match(this.properties)
|
|
42
63
|
.with({ type: 'void' }, () => '')
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
|
|
2
2
|
import type { Definition } from '../dsl/Definition.js';
|
|
3
|
+
import { ObjectProperty } from './DestructuredObject.js';
|
|
3
4
|
import type { Stringable } from '../dsl/Stringable.js';
|
|
4
5
|
type CreateArgs = {
|
|
5
6
|
name?: string;
|
|
@@ -24,7 +25,9 @@ type RegularParameter = {
|
|
|
24
25
|
export declare class FunctionParameter {
|
|
25
26
|
properties: ParameterProperties;
|
|
26
27
|
constructor(args: CreateArgs);
|
|
28
|
+
hasProperty(name: string): boolean;
|
|
27
29
|
toDestructured(): FunctionParameter;
|
|
30
|
+
toPropertyList(): string[] | ObjectProperty[];
|
|
28
31
|
toInbound(): Stringable;
|
|
29
32
|
toString(): string;
|
|
30
33
|
}
|
|
@@ -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;
|
|
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;AACtD,OAAO,EAAsB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,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,cAAc,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;IAuB5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAelC,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE,GAAG,cAAc,EAAE;IAU7C,SAAS,IAAI,UAAU;IAUvB,QAAQ,IAAI,MAAM;CAWnB"}
|
|
@@ -33,6 +33,18 @@ class FunctionParameter {
|
|
|
33
33
|
throw new Error('Invalid parameter');
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
hasProperty(name) {
|
|
37
|
+
return (0, ts_pattern_1.match)(this.properties)
|
|
38
|
+
.with({ type: 'void' }, () => false)
|
|
39
|
+
.with({ type: 'regular' }, ({ typeDefinition }) => {
|
|
40
|
+
const { value } = typeDefinition;
|
|
41
|
+
return Boolean(value.type === 'object' && value.objectProperties?.properties[name]);
|
|
42
|
+
})
|
|
43
|
+
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
44
|
+
return Boolean(typeDefinition.value.objectProperties?.properties[name]);
|
|
45
|
+
})
|
|
46
|
+
.exhaustive();
|
|
47
|
+
}
|
|
36
48
|
toDestructured() {
|
|
37
49
|
if (this.properties.type === 'void') {
|
|
38
50
|
return this;
|
|
@@ -43,6 +55,15 @@ class FunctionParameter {
|
|
|
43
55
|
destructure: true
|
|
44
56
|
});
|
|
45
57
|
}
|
|
58
|
+
toPropertyList() {
|
|
59
|
+
return (0, ts_pattern_1.match)(this.properties)
|
|
60
|
+
.with({ type: 'void' }, () => [])
|
|
61
|
+
.with({ type: 'regular' }, ({ name }) => [`${name}`])
|
|
62
|
+
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
63
|
+
return new DestructuredObject_js_1.DestructuredObject(typeDefinition.value).properties;
|
|
64
|
+
})
|
|
65
|
+
.exhaustive();
|
|
66
|
+
}
|
|
46
67
|
toInbound() {
|
|
47
68
|
return (0, ts_pattern_1.match)(this.properties)
|
|
48
69
|
.with({ type: 'void' }, () => '')
|