@skmtc/core 0.0.333 → 0.0.335

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.
Files changed (45) hide show
  1. package/esm/context/GenerateContext.d.ts +12 -4
  2. package/esm/context/GenerateContext.d.ts.map +1 -1
  3. package/esm/context/GenerateContext.js +57 -31
  4. package/esm/dsl/ModelDriver.d.ts +1 -2
  5. package/esm/dsl/ModelDriver.d.ts.map +1 -1
  6. package/esm/dsl/ModelDriver.js +2 -19
  7. package/esm/dsl/OperationDriver.d.ts +1 -2
  8. package/esm/dsl/OperationDriver.d.ts.map +1 -1
  9. package/esm/dsl/OperationDriver.js +2 -20
  10. package/esm/dsl/ValueBase.d.ts +2 -2
  11. package/esm/dsl/ValueBase.d.ts.map +1 -1
  12. package/esm/dsl/ValueBase.js +2 -3
  13. package/esm/dsl/withConfig.d.ts +2 -2
  14. package/esm/types/CustomValue.d.ts +1 -1
  15. package/esm/types/CustomValue.d.ts.map +1 -1
  16. package/esm/types/GeneratedValue.d.ts +1 -1
  17. package/esm/types/GeneratedValue.d.ts.map +1 -1
  18. package/esm/types/TypeSystem.d.ts +1 -1
  19. package/esm/types/TypeSystem.d.ts.map +1 -1
  20. package/esm/typescript/List.d.ts +70 -3
  21. package/esm/typescript/List.d.ts.map +1 -1
  22. package/esm/typescript/List.js +94 -6
  23. package/package.json +1 -1
  24. package/script/context/GenerateContext.d.ts +12 -4
  25. package/script/context/GenerateContext.d.ts.map +1 -1
  26. package/script/context/GenerateContext.js +57 -31
  27. package/script/dsl/ModelDriver.d.ts +1 -2
  28. package/script/dsl/ModelDriver.d.ts.map +1 -1
  29. package/script/dsl/ModelDriver.js +2 -19
  30. package/script/dsl/OperationDriver.d.ts +1 -2
  31. package/script/dsl/OperationDriver.d.ts.map +1 -1
  32. package/script/dsl/OperationDriver.js +2 -20
  33. package/script/dsl/ValueBase.d.ts +2 -2
  34. package/script/dsl/ValueBase.d.ts.map +1 -1
  35. package/script/dsl/ValueBase.js +2 -3
  36. package/script/dsl/withConfig.d.ts +2 -2
  37. package/script/types/CustomValue.d.ts +1 -1
  38. package/script/types/CustomValue.d.ts.map +1 -1
  39. package/script/types/GeneratedValue.d.ts +1 -1
  40. package/script/types/GeneratedValue.d.ts.map +1 -1
  41. package/script/types/TypeSystem.d.ts +1 -1
  42. package/script/types/TypeSystem.d.ts.map +1 -1
  43. package/script/typescript/List.d.ts +70 -3
  44. package/script/typescript/List.d.ts.map +1 -1
  45. package/script/typescript/List.js +94 -6
@@ -1,23 +1,90 @@
1
1
  import type { Stringable } from '../dsl/Stringable.js';
2
2
  type ConstructorOptions = {
3
3
  separator?: string;
4
- bookends?: 'square' | 'curly' | 'round' | 'none';
4
+ bookends?: 'square' | 'curly' | 'round' | 'angle' | 'none';
5
5
  };
6
6
  export declare class List {
7
7
  values: Stringable[];
8
8
  separator: string;
9
- bookends: 'square' | 'curly' | 'round' | 'none';
9
+ bookends: 'square' | 'curly' | 'round' | 'angle' | 'none';
10
10
  constructor(values: (Stringable | undefined)[], { separator, bookends }?: ConstructorOptions);
11
11
  toString(): string;
12
+ /**
13
+ * Create an empty List that will render as an empty string ''
14
+ * @returns List
15
+ */
12
16
  static toEmpty: () => List;
17
+ /**
18
+ * Create a List with a single value that will render as `value`
19
+ * @param value
20
+ * @returns List
21
+ */
13
22
  static toSingle: (value: Stringable) => List;
14
- static toOptional: (value: Stringable, condition: boolean) => List;
23
+ /**
24
+ * If condition is true, return a List with a single value that will render as `value`.
25
+ * Otherwise, return an empty List that will render as an empty string ''.
26
+ *
27
+ * Useful for conditional rendering. For example, rendering a function arg object when
28
+ * it has at least one property.
29
+ * @param value
30
+ * @param condition
31
+ * @returns List
32
+ */
33
+ static toConditional: (value: Stringable, condition: boolean) => List;
34
+ /**
35
+ * Create a record with Stringable values. KeyValue pairs will be joined with `: ` as separator
36
+ * and the resulting List will be wrapped with `{}`
37
+ * @param record
38
+ * @returns `record` with `Stringable` values
39
+ */
40
+ static toRecord: (record: Record<string, Stringable | Stringable[] | List>) => List;
41
+ /**
42
+ * Create a record with `undefined` or empty array or List values filtered out.
43
+ * @param record
44
+ * @returns `record` with `undefined` values filtered out
45
+ */
15
46
  static toFilteredRecord: (record: Record<string, undefined | Stringable | Stringable[] | List>) => List;
47
+ /**
48
+ * Join `key` and `value` using `: ` as separator
49
+ * @param key
50
+ * @param value
51
+ * @returns `key` and `value` joined with `: ` as separator
52
+ */
16
53
  static toKeyValue: (key: string, value: Stringable) => List;
54
+ /**
55
+ * Join `key` and `value` using `.` as separator
56
+ * @param key
57
+ * @param value
58
+ * @returns `key` and `value` joined with `.` as separator
59
+ */
17
60
  static toObjectKey: (key: string, value: Stringable) => List;
61
+ /**
62
+ * Join `values` using `, ` as separator and wrap in `{` and `}`
63
+ * @param values
64
+ * @returns `values` joined with `, ` as separator and wrapped in `{` and `}`
65
+ */
18
66
  static toObject: (values: (Stringable | undefined)[]) => List;
67
+ /**
68
+ * Create a List using the keys of a record
69
+ * @param record
70
+ * @returns List of record keys
71
+ */
19
72
  static fromRecord: (record: Record<string, Stringable> | undefined) => List;
73
+ /**
74
+ * Create a keyValue pair if `value` is not undefined and is not an empty array or List.
75
+ * Return `undefined` otherwise.
76
+ *
77
+ * Useful for filtering out `undefined values from a record.
78
+ * @param key
79
+ * @param value
80
+ * @returns `key` and `value` joined with `: ` as separator if `value` is not undefined and is not an empty array or List. `undefined` otherwise.
81
+ */
20
82
  static toFilteredKeyValue: (key: string, value: undefined | Stringable | Stringable[] | List) => List | undefined;
83
+ /**
84
+ * Check if `value` is not undefined and is not an empty array or List.
85
+ * @param value
86
+ * @returns `true` if `value` is not undefined and is not an empty array or List. `false` otherwise.
87
+ */
21
88
  static hasValue: (value: undefined | Stringable | Stringable[] | List) => value is Stringable | Stringable[] | List;
22
89
  }
23
90
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../src/typescript/List.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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,EAAE,UAEpD;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAU,WAAY,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,UAElE;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,QAClB,MAAM,SACJ,SAAS,GAAG,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,sBAGpD;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,UACN,SAAS,GAAG,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,KAClD,KAAK,IAAI,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,CAc3C;CACF"}
@@ -32,29 +32,75 @@ class List {
32
32
  .with('square', () => `[${joined}]`)
33
33
  .with('curly', () => `{${joined}}`)
34
34
  .with('round', () => `(${joined})`)
35
+ .with('angle', () => `<${joined}>`)
35
36
  .with('none', () => joined)
36
37
  .exhaustive();
37
38
  }
38
39
  }
39
40
  exports.List = List;
41
+ /**
42
+ * Create an empty List that will render as an empty string ''
43
+ * @returns List
44
+ */
40
45
  Object.defineProperty(List, "toEmpty", {
41
46
  enumerable: true,
42
47
  configurable: true,
43
48
  writable: true,
44
49
  value: () => new List([], { bookends: 'none' })
45
50
  });
51
+ /**
52
+ * Create a List with a single value that will render as `value`
53
+ * @param value
54
+ * @returns List
55
+ */
46
56
  Object.defineProperty(List, "toSingle", {
47
57
  enumerable: true,
48
58
  configurable: true,
49
59
  writable: true,
50
- value: (value) => new List([value], { bookends: 'none' })
60
+ value: (value) => {
61
+ return new List([value], { bookends: 'none' });
62
+ }
51
63
  });
52
- Object.defineProperty(List, "toOptional", {
64
+ /**
65
+ * If condition is true, return a List with a single value that will render as `value`.
66
+ * Otherwise, return an empty List that will render as an empty string ''.
67
+ *
68
+ * Useful for conditional rendering. For example, rendering a function arg object when
69
+ * it has at least one property.
70
+ * @param value
71
+ * @param condition
72
+ * @returns List
73
+ */
74
+ Object.defineProperty(List, "toConditional", {
53
75
  enumerable: true,
54
76
  configurable: true,
55
77
  writable: true,
56
- value: (value, condition) => new List([condition ? value : undefined])
78
+ value: (value, condition) => {
79
+ return new List([condition ? value : undefined], { bookends: 'none' });
80
+ }
57
81
  });
82
+ /**
83
+ * Create a record with Stringable values. KeyValue pairs will be joined with `: ` as separator
84
+ * and the resulting List will be wrapped with `{}`
85
+ * @param record
86
+ * @returns `record` with `Stringable` values
87
+ */
88
+ Object.defineProperty(List, "toRecord", {
89
+ enumerable: true,
90
+ configurable: true,
91
+ writable: true,
92
+ value: (record) => {
93
+ const entries = Object.entries(record).map(([key, value]) => {
94
+ return List.toKeyValue(key, value);
95
+ });
96
+ return List.toObject(entries);
97
+ }
98
+ });
99
+ /**
100
+ * Create a record with `undefined` or empty array or List values filtered out.
101
+ * @param record
102
+ * @returns `record` with `undefined` values filtered out
103
+ */
58
104
  Object.defineProperty(List, "toFilteredRecord", {
59
105
  enumerable: true,
60
106
  configurable: true,
@@ -66,24 +112,52 @@ Object.defineProperty(List, "toFilteredRecord", {
66
112
  return List.toObject(entries);
67
113
  }
68
114
  });
115
+ /**
116
+ * Join `key` and `value` using `: ` as separator
117
+ * @param key
118
+ * @param value
119
+ * @returns `key` and `value` joined with `: ` as separator
120
+ */
69
121
  Object.defineProperty(List, "toKeyValue", {
70
122
  enumerable: true,
71
123
  configurable: true,
72
124
  writable: true,
73
- value: (key, value) => new List([key, value], { separator: ': ' })
125
+ value: (key, value) => {
126
+ return new List([key, value], { separator: ': ' });
127
+ }
74
128
  });
129
+ /**
130
+ * Join `key` and `value` using `.` as separator
131
+ * @param key
132
+ * @param value
133
+ * @returns `key` and `value` joined with `.` as separator
134
+ */
75
135
  Object.defineProperty(List, "toObjectKey", {
76
136
  enumerable: true,
77
137
  configurable: true,
78
138
  writable: true,
79
- value: (key, value) => new List([key, value], { separator: '.' })
139
+ value: (key, value) => {
140
+ return new List([key, value], { separator: '.' });
141
+ }
80
142
  });
143
+ /**
144
+ * Join `values` using `, ` as separator and wrap in `{` and `}`
145
+ * @param values
146
+ * @returns `values` joined with `, ` as separator and wrapped in `{` and `}`
147
+ */
81
148
  Object.defineProperty(List, "toObject", {
82
149
  enumerable: true,
83
150
  configurable: true,
84
151
  writable: true,
85
- value: (values) => new List(values, { bookends: 'curly' })
152
+ value: (values) => {
153
+ return new List(values, { bookends: 'curly' });
154
+ }
86
155
  });
156
+ /**
157
+ * Create a List using the keys of a record
158
+ * @param record
159
+ * @returns List of record keys
160
+ */
87
161
  Object.defineProperty(List, "fromRecord", {
88
162
  enumerable: true,
89
163
  configurable: true,
@@ -92,6 +166,15 @@ Object.defineProperty(List, "fromRecord", {
92
166
  return new List(Object.keys(record ?? {}));
93
167
  }
94
168
  });
169
+ /**
170
+ * Create a keyValue pair if `value` is not undefined and is not an empty array or List.
171
+ * Return `undefined` otherwise.
172
+ *
173
+ * Useful for filtering out `undefined values from a record.
174
+ * @param key
175
+ * @param value
176
+ * @returns `key` and `value` joined with `: ` as separator if `value` is not undefined and is not an empty array or List. `undefined` otherwise.
177
+ */
95
178
  Object.defineProperty(List, "toFilteredKeyValue", {
96
179
  enumerable: true,
97
180
  configurable: true,
@@ -100,6 +183,11 @@ Object.defineProperty(List, "toFilteredKeyValue", {
100
183
  return List.hasValue(value) ? List.toKeyValue(key, value) : undefined;
101
184
  }
102
185
  });
186
+ /**
187
+ * Check if `value` is not undefined and is not an empty array or List.
188
+ * @param value
189
+ * @returns `true` if `value` is not undefined and is not an empty array or List. `false` otherwise.
190
+ */
103
191
  Object.defineProperty(List, "hasValue", {
104
192
  enumerable: true,
105
193
  configurable: true,