@skmtc/core 0.0.272 → 0.0.273
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/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/typescript/FunctionParameter.d.ts +2 -1
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/FunctionParameter.js +15 -6
- package/esm/typescript/List.d.ts +39 -0
- package/esm/typescript/List.d.ts.map +1 -0
- package/esm/typescript/List.js +93 -0
- package/package.json +1 -1
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -1
- package/script/typescript/FunctionParameter.d.ts +2 -1
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/FunctionParameter.js +15 -6
- package/script/typescript/List.d.ts +39 -0
- package/script/typescript/List.d.ts.map +1 -0
- package/script/typescript/List.js +98 -0
- package/esm/typescript/DestructuredObject.d.ts +0 -15
- package/esm/typescript/DestructuredObject.d.ts.map +0 -1
- package/esm/typescript/DestructuredObject.js +0 -54
- package/script/typescript/DestructuredObject.d.ts +0 -15
- package/script/typescript/DestructuredObject.d.ts.map +0 -1
- package/script/typescript/DestructuredObject.js +0 -59
package/esm/mod.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export * from './types/RefName.js';
|
|
|
49
49
|
export * from './types/Settings.js';
|
|
50
50
|
export * from './types/Settings.js';
|
|
51
51
|
export * from './types/TypeSystem.js';
|
|
52
|
-
export * from './typescript/
|
|
52
|
+
export * from './typescript/List.js';
|
|
53
53
|
export * from './typescript/FunctionParameter.js';
|
|
54
54
|
export * from './typescript/identifiers.js';
|
|
55
55
|
export * from './typescript/keyValues.js';
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,q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,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mCAAmC,CAAA;AACjD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA;AACrD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
|
package/esm/mod.js
CHANGED
|
@@ -49,7 +49,7 @@ export * from './types/RefName.js';
|
|
|
49
49
|
export * from './types/Settings.js';
|
|
50
50
|
export * from './types/Settings.js';
|
|
51
51
|
export * from './types/TypeSystem.js';
|
|
52
|
-
export * from './typescript/
|
|
52
|
+
export * from './typescript/List.js';
|
|
53
53
|
export * from './typescript/FunctionParameter.js';
|
|
54
54
|
export * from './typescript/identifiers.js';
|
|
55
55
|
export * from './typescript/keyValues.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
|
|
2
2
|
import type { Definition } from '../dsl/Definition.js';
|
|
3
|
+
import { List } from './List.js';
|
|
3
4
|
type CreateArgs = {
|
|
4
5
|
name?: string;
|
|
5
6
|
typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
|
|
@@ -25,7 +26,7 @@ export declare class FunctionParameter {
|
|
|
25
26
|
properties: ParameterProperties;
|
|
26
27
|
constructor(args: CreateArgs);
|
|
27
28
|
hasProperty(name: string): boolean;
|
|
28
|
-
toPropertyList(): string
|
|
29
|
+
toPropertyList(): List<string>;
|
|
29
30
|
toInbound(): string;
|
|
30
31
|
toString(): string;
|
|
31
32
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AACtD,OAAO,EAAE,IAAI,EAAkB,MAAM,WAAW,CAAA;AAEhD,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,IAAI,CAAC,MAAM,CAAC;IAgB9B,SAAS,IAAI,MAAM;IAenB,QAAQ,IAAI,MAAM;CAgBnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { match, P } from 'ts-pattern';
|
|
2
|
-
import {
|
|
2
|
+
import { List, ObjectProperty } from './List.js';
|
|
3
3
|
export class FunctionParameter {
|
|
4
4
|
constructor(args) {
|
|
5
5
|
Object.defineProperty(this, "properties", {
|
|
@@ -43,10 +43,12 @@ export class FunctionParameter {
|
|
|
43
43
|
}
|
|
44
44
|
toPropertyList() {
|
|
45
45
|
return match(this.properties)
|
|
46
|
-
.with({ type: 'void' }, () => [])
|
|
47
|
-
.with({ type: 'regular' }, ({ name }) => [`${name}`])
|
|
46
|
+
.with({ type: 'void' }, () => List.toObject({ items: [], renderWhenEmpty: false }))
|
|
47
|
+
.with({ type: 'regular' }, ({ name }) => List.toObject({ items: [`${name}`] }))
|
|
48
48
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
49
|
-
return
|
|
49
|
+
return List.keysToObject({
|
|
50
|
+
record: typeDefinition.value.objectProperties?.properties
|
|
51
|
+
});
|
|
50
52
|
})
|
|
51
53
|
.exhaustive();
|
|
52
54
|
}
|
|
@@ -55,7 +57,11 @@ export class FunctionParameter {
|
|
|
55
57
|
.with({ type: 'void' }, () => '')
|
|
56
58
|
.with({ type: 'regular' }, ({ name }) => `${name}`)
|
|
57
59
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
58
|
-
|
|
60
|
+
const list = List.keysToObject({
|
|
61
|
+
record: typeDefinition.value.objectProperties?.properties,
|
|
62
|
+
map: key => new ObjectProperty(key)
|
|
63
|
+
});
|
|
64
|
+
return `${list}`;
|
|
59
65
|
})
|
|
60
66
|
.exhaustive();
|
|
61
67
|
}
|
|
@@ -66,7 +72,10 @@ export class FunctionParameter {
|
|
|
66
72
|
return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
|
|
67
73
|
})
|
|
68
74
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
69
|
-
const destructured =
|
|
75
|
+
const destructured = List.keysToObject({
|
|
76
|
+
record: typeDefinition.value.objectProperties?.properties,
|
|
77
|
+
map: key => new ObjectProperty(key)
|
|
78
|
+
});
|
|
70
79
|
return `${destructured}: ${typeDefinition.identifier}`;
|
|
71
80
|
})
|
|
72
81
|
.exhaustive();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type ListArgs<V> = {
|
|
2
|
+
items: V[];
|
|
3
|
+
bookends: 'square' | 'curly' | 'round' | 'none';
|
|
4
|
+
separator: string;
|
|
5
|
+
renderWhenEmpty?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ToArrayArgs<V> = {
|
|
8
|
+
items: V[];
|
|
9
|
+
renderWhenEmpty?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type ToObjectArgs<V> = {
|
|
12
|
+
items: V[];
|
|
13
|
+
renderWhenEmpty?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type KeysToObjectArgs<V> = {
|
|
16
|
+
record?: Record<string, unknown>;
|
|
17
|
+
map?: (value: string) => V;
|
|
18
|
+
renderWhenEmpty?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class List<V> {
|
|
21
|
+
bookends: 'square' | 'curly' | 'round' | 'none';
|
|
22
|
+
separator: string;
|
|
23
|
+
renderWhenEmpty: boolean;
|
|
24
|
+
items: V[];
|
|
25
|
+
constructor({ items, bookends, separator, renderWhenEmpty }: ListArgs<V>);
|
|
26
|
+
static toArray<V>(args: ToArrayArgs<V>): List<V>;
|
|
27
|
+
static toObject<V>(args: ToObjectArgs<V>): List<V>;
|
|
28
|
+
static keysToObject<V>({ record, map, renderWhenEmpty }: KeysToObjectArgs<V>): List<string | V>;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
export declare class ObjectProperty {
|
|
32
|
+
name: string;
|
|
33
|
+
isValid: boolean;
|
|
34
|
+
canonicalName: string;
|
|
35
|
+
constructor(name: string);
|
|
36
|
+
toString(): string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=List.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../src/typescript/List.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,YAAY,CAAC,CAAC,IAAI;IACrB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,qBAAa,IAAI,CAAC,CAAC;IACjB,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,CAAC,EAAE,CAAK;gBACH,EACV,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAsB,EACvB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAOd,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAItC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAIxC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,EACrB,MAAM,EACN,GAAG,EACH,eAAe,EAChB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAWtB,QAAQ;CAcT;AAED,qBAAa,cAAc;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;gBACT,IAAI,EAAE,MAAM;IAYxB,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isIdentifierName } from '@babel/helper-validator-identifier';
|
|
2
|
+
import { camelCase } from 'lodash-es';
|
|
3
|
+
import { match } from 'ts-pattern';
|
|
4
|
+
export class List {
|
|
5
|
+
constructor({ items, bookends, separator, renderWhenEmpty = true }) {
|
|
6
|
+
Object.defineProperty(this, "bookends", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "separator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "renderWhenEmpty", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "items", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: []
|
|
29
|
+
});
|
|
30
|
+
this.items = items;
|
|
31
|
+
this.bookends = bookends;
|
|
32
|
+
this.separator = separator;
|
|
33
|
+
this.renderWhenEmpty = renderWhenEmpty;
|
|
34
|
+
}
|
|
35
|
+
static toArray(args) {
|
|
36
|
+
return new List({ ...args, bookends: 'square', separator: ',' });
|
|
37
|
+
}
|
|
38
|
+
static toObject(args) {
|
|
39
|
+
return new List({ ...args, bookends: 'curly', separator: ',' });
|
|
40
|
+
}
|
|
41
|
+
static keysToObject({ record, map, renderWhenEmpty }) {
|
|
42
|
+
const items = Object.keys(record ?? {}).map(key => (map ? map(key) : key));
|
|
43
|
+
return new List({
|
|
44
|
+
items,
|
|
45
|
+
bookends: 'curly',
|
|
46
|
+
separator: ',',
|
|
47
|
+
renderWhenEmpty
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
toString() {
|
|
51
|
+
if (this.items.length === 0 && !this.renderWhenEmpty) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
const items = this.items.map(item => `${item}`).join(this.separator);
|
|
55
|
+
return match(this.bookends)
|
|
56
|
+
.with('square', () => `[${items}]`)
|
|
57
|
+
.with('curly', () => `{${items}}`)
|
|
58
|
+
.with('round', () => `(${items})`)
|
|
59
|
+
.with('none', () => items)
|
|
60
|
+
.exhaustive();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export class ObjectProperty {
|
|
64
|
+
constructor(name) {
|
|
65
|
+
Object.defineProperty(this, "name", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "isValid", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(this, "canonicalName", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
83
|
+
this.name = name;
|
|
84
|
+
this.isValid = isIdentifierName(name);
|
|
85
|
+
this.canonicalName = this.isValid ? name : camelCase(name);
|
|
86
|
+
if (!isIdentifierName(this.canonicalName)) {
|
|
87
|
+
throw new Error(`Property name '${name}' is not a valid identifier and cannot be converted to a canonical name`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
toString() {
|
|
91
|
+
return this.isValid ? this.name : `${this.name}: ${this.canonicalName}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/package.json
CHANGED
package/script/mod.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export * from './types/RefName.js';
|
|
|
49
49
|
export * from './types/Settings.js';
|
|
50
50
|
export * from './types/Settings.js';
|
|
51
51
|
export * from './types/TypeSystem.js';
|
|
52
|
-
export * from './typescript/
|
|
52
|
+
export * from './typescript/List.js';
|
|
53
53
|
export * from './typescript/FunctionParameter.js';
|
|
54
54
|
export * from './typescript/identifiers.js';
|
|
55
55
|
export * from './typescript/keyValues.js';
|
package/script/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,c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AAsB,CAAA;AACpC,cAAc,mCAAmC,CAAA;AACjD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA;AACrD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
|
package/script/mod.js
CHANGED
|
@@ -65,7 +65,7 @@ __exportStar(require("./types/RefName.js"), exports);
|
|
|
65
65
|
__exportStar(require("./types/Settings.js"), exports);
|
|
66
66
|
__exportStar(require("./types/Settings.js"), exports);
|
|
67
67
|
__exportStar(require("./types/TypeSystem.js"), exports);
|
|
68
|
-
__exportStar(require("./typescript/
|
|
68
|
+
__exportStar(require("./typescript/List.js"), exports);
|
|
69
69
|
__exportStar(require("./typescript/FunctionParameter.js"), exports);
|
|
70
70
|
__exportStar(require("./typescript/identifiers.js"), exports);
|
|
71
71
|
__exportStar(require("./typescript/keyValues.js"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TypeSystemObject, TypeSystemValue, TypeSystemVoid } from '../types/TypeSystem.js';
|
|
2
2
|
import type { Definition } from '../dsl/Definition.js';
|
|
3
|
+
import { List } from './List.js';
|
|
3
4
|
type CreateArgs = {
|
|
4
5
|
name?: string;
|
|
5
6
|
typeDefinition: Definition<TypeSystemObject | TypeSystemVoid>;
|
|
@@ -25,7 +26,7 @@ export declare class FunctionParameter {
|
|
|
25
26
|
properties: ParameterProperties;
|
|
26
27
|
constructor(args: CreateArgs);
|
|
27
28
|
hasProperty(name: string): boolean;
|
|
28
|
-
toPropertyList(): string
|
|
29
|
+
toPropertyList(): List<string>;
|
|
29
30
|
toInbound(): string;
|
|
30
31
|
toString(): string;
|
|
31
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,eA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IAAI,MAAM;IAenB,QAAQ,IAAI,MAAM;CAgBnB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FunctionParameter = void 0;
|
|
4
4
|
const ts_pattern_1 = require("ts-pattern");
|
|
5
|
-
const
|
|
5
|
+
const List_js_1 = require("./List.js");
|
|
6
6
|
class FunctionParameter {
|
|
7
7
|
constructor(args) {
|
|
8
8
|
Object.defineProperty(this, "properties", {
|
|
@@ -46,10 +46,12 @@ class FunctionParameter {
|
|
|
46
46
|
}
|
|
47
47
|
toPropertyList() {
|
|
48
48
|
return (0, ts_pattern_1.match)(this.properties)
|
|
49
|
-
.with({ type: 'void' }, () => [])
|
|
50
|
-
.with({ type: 'regular' }, ({ name }) => [`${name}`])
|
|
49
|
+
.with({ type: 'void' }, () => List_js_1.List.toObject({ items: [], renderWhenEmpty: false }))
|
|
50
|
+
.with({ type: 'regular' }, ({ name }) => List_js_1.List.toObject({ items: [`${name}`] }))
|
|
51
51
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
52
|
-
return
|
|
52
|
+
return List_js_1.List.keysToObject({
|
|
53
|
+
record: typeDefinition.value.objectProperties?.properties
|
|
54
|
+
});
|
|
53
55
|
})
|
|
54
56
|
.exhaustive();
|
|
55
57
|
}
|
|
@@ -58,7 +60,11 @@ class FunctionParameter {
|
|
|
58
60
|
.with({ type: 'void' }, () => '')
|
|
59
61
|
.with({ type: 'regular' }, ({ name }) => `${name}`)
|
|
60
62
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
61
|
-
|
|
63
|
+
const list = List_js_1.List.keysToObject({
|
|
64
|
+
record: typeDefinition.value.objectProperties?.properties,
|
|
65
|
+
map: key => new List_js_1.ObjectProperty(key)
|
|
66
|
+
});
|
|
67
|
+
return `${list}`;
|
|
62
68
|
})
|
|
63
69
|
.exhaustive();
|
|
64
70
|
}
|
|
@@ -69,7 +75,10 @@ class FunctionParameter {
|
|
|
69
75
|
return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
|
|
70
76
|
})
|
|
71
77
|
.with({ type: 'destructured' }, ({ typeDefinition }) => {
|
|
72
|
-
const destructured =
|
|
78
|
+
const destructured = List_js_1.List.keysToObject({
|
|
79
|
+
record: typeDefinition.value.objectProperties?.properties,
|
|
80
|
+
map: key => new List_js_1.ObjectProperty(key)
|
|
81
|
+
});
|
|
73
82
|
return `${destructured}: ${typeDefinition.identifier}`;
|
|
74
83
|
})
|
|
75
84
|
.exhaustive();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type ListArgs<V> = {
|
|
2
|
+
items: V[];
|
|
3
|
+
bookends: 'square' | 'curly' | 'round' | 'none';
|
|
4
|
+
separator: string;
|
|
5
|
+
renderWhenEmpty?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ToArrayArgs<V> = {
|
|
8
|
+
items: V[];
|
|
9
|
+
renderWhenEmpty?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type ToObjectArgs<V> = {
|
|
12
|
+
items: V[];
|
|
13
|
+
renderWhenEmpty?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type KeysToObjectArgs<V> = {
|
|
16
|
+
record?: Record<string, unknown>;
|
|
17
|
+
map?: (value: string) => V;
|
|
18
|
+
renderWhenEmpty?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class List<V> {
|
|
21
|
+
bookends: 'square' | 'curly' | 'round' | 'none';
|
|
22
|
+
separator: string;
|
|
23
|
+
renderWhenEmpty: boolean;
|
|
24
|
+
items: V[];
|
|
25
|
+
constructor({ items, bookends, separator, renderWhenEmpty }: ListArgs<V>);
|
|
26
|
+
static toArray<V>(args: ToArrayArgs<V>): List<V>;
|
|
27
|
+
static toObject<V>(args: ToObjectArgs<V>): List<V>;
|
|
28
|
+
static keysToObject<V>({ record, map, renderWhenEmpty }: KeysToObjectArgs<V>): List<string | V>;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
export declare class ObjectProperty {
|
|
32
|
+
name: string;
|
|
33
|
+
isValid: boolean;
|
|
34
|
+
canonicalName: string;
|
|
35
|
+
constructor(name: string);
|
|
36
|
+
toString(): string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=List.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../src/typescript/List.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,YAAY,CAAC,CAAC,IAAI;IACrB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,qBAAa,IAAI,CAAC,CAAC;IACjB,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,CAAC,EAAE,CAAK;gBACH,EACV,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAsB,EACvB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAOd,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAItC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAIxC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,EACrB,MAAM,EACN,GAAG,EACH,eAAe,EAChB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAWtB,QAAQ;CAcT;AAED,qBAAa,cAAc;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;gBACT,IAAI,EAAE,MAAM;IAYxB,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectProperty = exports.List = void 0;
|
|
4
|
+
const helper_validator_identifier_1 = require("@babel/helper-validator-identifier");
|
|
5
|
+
const lodash_es_1 = require("lodash-es");
|
|
6
|
+
const ts_pattern_1 = require("ts-pattern");
|
|
7
|
+
class List {
|
|
8
|
+
constructor({ items, bookends, separator, renderWhenEmpty = true }) {
|
|
9
|
+
Object.defineProperty(this, "bookends", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: void 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "separator", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: void 0
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "renderWhenEmpty", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "items", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: []
|
|
32
|
+
});
|
|
33
|
+
this.items = items;
|
|
34
|
+
this.bookends = bookends;
|
|
35
|
+
this.separator = separator;
|
|
36
|
+
this.renderWhenEmpty = renderWhenEmpty;
|
|
37
|
+
}
|
|
38
|
+
static toArray(args) {
|
|
39
|
+
return new List({ ...args, bookends: 'square', separator: ',' });
|
|
40
|
+
}
|
|
41
|
+
static toObject(args) {
|
|
42
|
+
return new List({ ...args, bookends: 'curly', separator: ',' });
|
|
43
|
+
}
|
|
44
|
+
static keysToObject({ record, map, renderWhenEmpty }) {
|
|
45
|
+
const items = Object.keys(record ?? {}).map(key => (map ? map(key) : key));
|
|
46
|
+
return new List({
|
|
47
|
+
items,
|
|
48
|
+
bookends: 'curly',
|
|
49
|
+
separator: ',',
|
|
50
|
+
renderWhenEmpty
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
toString() {
|
|
54
|
+
if (this.items.length === 0 && !this.renderWhenEmpty) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
const items = this.items.map(item => `${item}`).join(this.separator);
|
|
58
|
+
return (0, ts_pattern_1.match)(this.bookends)
|
|
59
|
+
.with('square', () => `[${items}]`)
|
|
60
|
+
.with('curly', () => `{${items}}`)
|
|
61
|
+
.with('round', () => `(${items})`)
|
|
62
|
+
.with('none', () => items)
|
|
63
|
+
.exhaustive();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.List = List;
|
|
67
|
+
class ObjectProperty {
|
|
68
|
+
constructor(name) {
|
|
69
|
+
Object.defineProperty(this, "name", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: void 0
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(this, "isValid", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: void 0
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(this, "canonicalName", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: void 0
|
|
86
|
+
});
|
|
87
|
+
this.name = name;
|
|
88
|
+
this.isValid = (0, helper_validator_identifier_1.isIdentifierName)(name);
|
|
89
|
+
this.canonicalName = this.isValid ? name : (0, lodash_es_1.camelCase)(name);
|
|
90
|
+
if (!(0, helper_validator_identifier_1.isIdentifierName)(this.canonicalName)) {
|
|
91
|
+
throw new Error(`Property name '${name}' is not a valid identifier and cannot be converted to a canonical name`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
toString() {
|
|
95
|
+
return this.isValid ? this.name : `${this.name}: ${this.canonicalName}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ObjectProperty = ObjectProperty;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { TypeSystemObject } from '../types/TypeSystem.js';
|
|
2
|
-
export declare class DestructuredObject {
|
|
3
|
-
typeSystemObject: TypeSystemObject;
|
|
4
|
-
properties: ObjectProperty[];
|
|
5
|
-
constructor(typeSystemObject: TypeSystemObject);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
export declare class ObjectProperty {
|
|
9
|
-
name: string;
|
|
10
|
-
isValid: boolean;
|
|
11
|
-
canonicalName: string;
|
|
12
|
-
constructor(name: string);
|
|
13
|
-
toString(): string;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=DestructuredObject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DestructuredObject.d.ts","sourceRoot":"","sources":["../../src/typescript/DestructuredObject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,qBAAa,kBAAkB;IAC7B,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,UAAU,EAAE,cAAc,EAAE,CAAA;gBAChB,gBAAgB,EAAE,gBAAgB;IAQ9C,QAAQ,IAAI,MAAM;CAGnB;AAED,qBAAa,cAAc;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;gBACT,IAAI,EAAE,MAAM;IAYxB,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { isIdentifierName } from '@babel/helper-validator-identifier';
|
|
2
|
-
import { camelCase } from 'lodash-es';
|
|
3
|
-
export class DestructuredObject {
|
|
4
|
-
constructor(typeSystemObject) {
|
|
5
|
-
Object.defineProperty(this, "typeSystemObject", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(this, "properties", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: void 0
|
|
16
|
-
});
|
|
17
|
-
this.typeSystemObject = typeSystemObject;
|
|
18
|
-
this.properties = Object.keys(typeSystemObject.objectProperties?.properties ?? {}).map(name => new ObjectProperty(name));
|
|
19
|
-
}
|
|
20
|
-
toString() {
|
|
21
|
-
return `{${this.properties.map(property => `${property}`).join(',\n')}}`;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class ObjectProperty {
|
|
25
|
-
constructor(name) {
|
|
26
|
-
Object.defineProperty(this, "name", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: void 0
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(this, "isValid", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: void 0
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, "canonicalName", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
|
-
this.name = name;
|
|
45
|
-
this.isValid = isIdentifierName(name);
|
|
46
|
-
this.canonicalName = this.isValid ? name : camelCase(name);
|
|
47
|
-
if (!isIdentifierName(this.canonicalName)) {
|
|
48
|
-
throw new Error(`Property name '${name}' is not a valid identifier and cannot be converted to a canonical name`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
toString() {
|
|
52
|
-
return this.isValid ? this.name : `${this.name}: ${this.canonicalName}`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { TypeSystemObject } from '../types/TypeSystem.js';
|
|
2
|
-
export declare class DestructuredObject {
|
|
3
|
-
typeSystemObject: TypeSystemObject;
|
|
4
|
-
properties: ObjectProperty[];
|
|
5
|
-
constructor(typeSystemObject: TypeSystemObject);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
export declare class ObjectProperty {
|
|
9
|
-
name: string;
|
|
10
|
-
isValid: boolean;
|
|
11
|
-
canonicalName: string;
|
|
12
|
-
constructor(name: string);
|
|
13
|
-
toString(): string;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=DestructuredObject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DestructuredObject.d.ts","sourceRoot":"","sources":["../../src/typescript/DestructuredObject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,qBAAa,kBAAkB;IAC7B,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,UAAU,EAAE,cAAc,EAAE,CAAA;gBAChB,gBAAgB,EAAE,gBAAgB;IAQ9C,QAAQ,IAAI,MAAM;CAGnB;AAED,qBAAa,cAAc;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;gBACT,IAAI,EAAE,MAAM;IAYxB,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectProperty = exports.DestructuredObject = void 0;
|
|
4
|
-
const helper_validator_identifier_1 = require("@babel/helper-validator-identifier");
|
|
5
|
-
const lodash_es_1 = require("lodash-es");
|
|
6
|
-
class DestructuredObject {
|
|
7
|
-
constructor(typeSystemObject) {
|
|
8
|
-
Object.defineProperty(this, "typeSystemObject", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "properties", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
this.typeSystemObject = typeSystemObject;
|
|
21
|
-
this.properties = Object.keys(typeSystemObject.objectProperties?.properties ?? {}).map(name => new ObjectProperty(name));
|
|
22
|
-
}
|
|
23
|
-
toString() {
|
|
24
|
-
return `{${this.properties.map(property => `${property}`).join(',\n')}}`;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.DestructuredObject = DestructuredObject;
|
|
28
|
-
class ObjectProperty {
|
|
29
|
-
constructor(name) {
|
|
30
|
-
Object.defineProperty(this, "name", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: void 0
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(this, "isValid", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(this, "canonicalName", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
this.name = name;
|
|
49
|
-
this.isValid = (0, helper_validator_identifier_1.isIdentifierName)(name);
|
|
50
|
-
this.canonicalName = this.isValid ? name : (0, lodash_es_1.camelCase)(name);
|
|
51
|
-
if (!(0, helper_validator_identifier_1.isIdentifierName)(this.canonicalName)) {
|
|
52
|
-
throw new Error(`Property name '${name}' is not a valid identifier and cannot be converted to a canonical name`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
toString() {
|
|
56
|
-
return this.isValid ? this.name : `${this.name}: ${this.canonicalName}`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.ObjectProperty = ObjectProperty;
|