@nxtedition/types 1.0.0 → 1.2.0

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.
@@ -0,0 +1,255 @@
1
+ import __typia from "typia";
2
+ export const isRule = input => {
3
+ const $io0 = input => Array.isArray(input.locations) && input.locations.every(elem => "string" === typeof elem) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295)) && (Array.isArray(input.includes) && input.includes.every(elem => "string" === typeof elem)) && (Array.isArray(input.excludes) && input.excludes.every(elem => "string" === typeof elem));
4
+ return "object" === typeof input && null !== input && $io0(input);
5
+ };
6
+ export const assertRule = (input, errorFactory) => {
7
+ const __is = input => {
8
+ const $io0 = input => Array.isArray(input.locations) && input.locations.every(elem => "string" === typeof elem) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295)) && (Array.isArray(input.includes) && input.includes.every(elem => "string" === typeof elem)) && (Array.isArray(input.excludes) && input.excludes.every(elem => "string" === typeof elem));
9
+ return "object" === typeof input && null !== input && $io0(input);
10
+ };
11
+ if (false === __is(input))
12
+ ((input, _path, _exceptionable = true) => {
13
+ const $guard = __typia.createAssert.guard;
14
+ const $ao0 = (input, _path, _exceptionable = true) => ((Array.isArray(input.locations) || $guard(_exceptionable, {
15
+ path: _path + ".locations",
16
+ expected: "Array<string>",
17
+ value: input.locations
18
+ }, errorFactory)) && input.locations.every((elem, _index1) => "string" === typeof elem || $guard(_exceptionable, {
19
+ path: _path + ".locations[" + _index1 + "]",
20
+ expected: "string",
21
+ value: elem
22
+ }, errorFactory)) || $guard(_exceptionable, {
23
+ path: _path + ".locations",
24
+ expected: "Array<string>",
25
+ value: input.locations
26
+ }, errorFactory)) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295 || $guard(_exceptionable, {
27
+ path: _path + ".replicas",
28
+ expected: "number & Type<\"uint32\">",
29
+ value: input.replicas
30
+ }, errorFactory)) || $guard(_exceptionable, {
31
+ path: _path + ".replicas",
32
+ expected: "(number & Type<\"uint32\">)",
33
+ value: input.replicas
34
+ }, errorFactory)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295 || $guard(_exceptionable, {
35
+ path: _path + ".priority",
36
+ expected: "number & Type<\"uint32\">",
37
+ value: input.priority
38
+ }, errorFactory)) || $guard(_exceptionable, {
39
+ path: _path + ".priority",
40
+ expected: "(number & Type<\"uint32\">)",
41
+ value: input.priority
42
+ }, errorFactory)) && ((Array.isArray(input.includes) || $guard(_exceptionable, {
43
+ path: _path + ".includes",
44
+ expected: "Array<string>",
45
+ value: input.includes
46
+ }, errorFactory)) && input.includes.every((elem, _index2) => "string" === typeof elem || $guard(_exceptionable, {
47
+ path: _path + ".includes[" + _index2 + "]",
48
+ expected: "string",
49
+ value: elem
50
+ }, errorFactory)) || $guard(_exceptionable, {
51
+ path: _path + ".includes",
52
+ expected: "Array<string>",
53
+ value: input.includes
54
+ }, errorFactory)) && ((Array.isArray(input.excludes) || $guard(_exceptionable, {
55
+ path: _path + ".excludes",
56
+ expected: "Array<string>",
57
+ value: input.excludes
58
+ }, errorFactory)) && input.excludes.every((elem, _index3) => "string" === typeof elem || $guard(_exceptionable, {
59
+ path: _path + ".excludes[" + _index3 + "]",
60
+ expected: "string",
61
+ value: elem
62
+ }, errorFactory)) || $guard(_exceptionable, {
63
+ path: _path + ".excludes",
64
+ expected: "Array<string>",
65
+ value: input.excludes
66
+ }, errorFactory));
67
+ return ("object" === typeof input && null !== input || $guard(true, {
68
+ path: _path + "",
69
+ expected: "Rule",
70
+ value: input
71
+ }, errorFactory)) && $ao0(input, _path + "", true) || $guard(true, {
72
+ path: _path + "",
73
+ expected: "Rule",
74
+ value: input
75
+ }, errorFactory);
76
+ })(input, "$input", true);
77
+ return input;
78
+ };
79
+ export const randomRule = generator => {
80
+ const $generator = __typia.createRandom.generator;
81
+ const $ro0 = (_recursive = false, _depth = 0) => ({
82
+ locations: (generator?.array ?? $generator.array)(() => (generator?.customs ?? $generator.customs)?.string?.([]) ?? (generator?.string ?? $generator.string)()),
83
+ replicas: (generator?.customs ?? $generator.customs)?.number?.([
84
+ {
85
+ name: "Type<\"uint32\">",
86
+ kind: "type",
87
+ value: "uint32"
88
+ }
89
+ ]) ?? (generator?.integer ?? $generator.integer)(0, 10),
90
+ priority: (generator?.customs ?? $generator.customs)?.number?.([
91
+ {
92
+ name: "Type<\"uint32\">",
93
+ kind: "type",
94
+ value: "uint32"
95
+ }
96
+ ]) ?? (generator?.integer ?? $generator.integer)(0, 10),
97
+ includes: (generator?.array ?? $generator.array)(() => (generator?.customs ?? $generator.customs)?.string?.([]) ?? (generator?.string ?? $generator.string)()),
98
+ excludes: (generator?.array ?? $generator.array)(() => (generator?.customs ?? $generator.customs)?.string?.([]) ?? (generator?.string ?? $generator.string)())
99
+ });
100
+ return $ro0();
101
+ };
102
+ export const assertGuardRule = (input, errorFactory) => {
103
+ const __is = input => {
104
+ const $io0 = input => Array.isArray(input.locations) && input.locations.every(elem => "string" === typeof elem) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295)) && (Array.isArray(input.includes) && input.includes.every(elem => "string" === typeof elem)) && (Array.isArray(input.excludes) && input.excludes.every(elem => "string" === typeof elem));
105
+ return "object" === typeof input && null !== input && $io0(input);
106
+ };
107
+ if (false === __is(input))
108
+ ((input, _path, _exceptionable = true) => {
109
+ const $guard = __typia.createAssertGuard.guard;
110
+ const $ao0 = (input, _path, _exceptionable = true) => ((Array.isArray(input.locations) || $guard(_exceptionable, {
111
+ path: _path + ".locations",
112
+ expected: "Array<string>",
113
+ value: input.locations
114
+ }, errorFactory)) && input.locations.every((elem, _index1) => "string" === typeof elem || $guard(_exceptionable, {
115
+ path: _path + ".locations[" + _index1 + "]",
116
+ expected: "string",
117
+ value: elem
118
+ }, errorFactory)) || $guard(_exceptionable, {
119
+ path: _path + ".locations",
120
+ expected: "Array<string>",
121
+ value: input.locations
122
+ }, errorFactory)) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295 || $guard(_exceptionable, {
123
+ path: _path + ".replicas",
124
+ expected: "number & Type<\"uint32\">",
125
+ value: input.replicas
126
+ }, errorFactory)) || $guard(_exceptionable, {
127
+ path: _path + ".replicas",
128
+ expected: "(number & Type<\"uint32\">)",
129
+ value: input.replicas
130
+ }, errorFactory)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295 || $guard(_exceptionable, {
131
+ path: _path + ".priority",
132
+ expected: "number & Type<\"uint32\">",
133
+ value: input.priority
134
+ }, errorFactory)) || $guard(_exceptionable, {
135
+ path: _path + ".priority",
136
+ expected: "(number & Type<\"uint32\">)",
137
+ value: input.priority
138
+ }, errorFactory)) && ((Array.isArray(input.includes) || $guard(_exceptionable, {
139
+ path: _path + ".includes",
140
+ expected: "Array<string>",
141
+ value: input.includes
142
+ }, errorFactory)) && input.includes.every((elem, _index2) => "string" === typeof elem || $guard(_exceptionable, {
143
+ path: _path + ".includes[" + _index2 + "]",
144
+ expected: "string",
145
+ value: elem
146
+ }, errorFactory)) || $guard(_exceptionable, {
147
+ path: _path + ".includes",
148
+ expected: "Array<string>",
149
+ value: input.includes
150
+ }, errorFactory)) && ((Array.isArray(input.excludes) || $guard(_exceptionable, {
151
+ path: _path + ".excludes",
152
+ expected: "Array<string>",
153
+ value: input.excludes
154
+ }, errorFactory)) && input.excludes.every((elem, _index3) => "string" === typeof elem || $guard(_exceptionable, {
155
+ path: _path + ".excludes[" + _index3 + "]",
156
+ expected: "string",
157
+ value: elem
158
+ }, errorFactory)) || $guard(_exceptionable, {
159
+ path: _path + ".excludes",
160
+ expected: "Array<string>",
161
+ value: input.excludes
162
+ }, errorFactory));
163
+ return ("object" === typeof input && null !== input || $guard(true, {
164
+ path: _path + "",
165
+ expected: "Rule",
166
+ value: input
167
+ }, errorFactory)) && $ao0(input, _path + "", true) || $guard(true, {
168
+ path: _path + "",
169
+ expected: "Rule",
170
+ value: input
171
+ }, errorFactory);
172
+ })(input, "$input", true);
173
+ };
174
+ export const stringifyRule = input => {
175
+ const $string = __typia.json.createStringify.string;
176
+ const $so0 = input => `{"locations":${`[${input.locations.map(elem => $string(elem)).join(",")}]`},"replicas":${input.replicas},"priority":${input.priority},"includes":${`[${input.includes.map(elem => $string(elem)).join(",")}]`},"excludes":${`[${input.excludes.map(elem => $string(elem)).join(",")}]`}}`;
177
+ return $so0(input);
178
+ };
179
+ export const assertStringifyRule = (input, errorFactory) => { const assert = (input, errorFactory) => {
180
+ const __is = input => {
181
+ const $io0 = input => Array.isArray(input.locations) && input.locations.every(elem => "string" === typeof elem) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295)) && (Array.isArray(input.includes) && input.includes.every(elem => "string" === typeof elem)) && (Array.isArray(input.excludes) && input.excludes.every(elem => "string" === typeof elem));
182
+ return "object" === typeof input && null !== input && $io0(input);
183
+ };
184
+ if (false === __is(input))
185
+ ((input, _path, _exceptionable = true) => {
186
+ const $guard = __typia.json.createAssertStringify.guard;
187
+ const $ao0 = (input, _path, _exceptionable = true) => ((Array.isArray(input.locations) || $guard(_exceptionable, {
188
+ path: _path + ".locations",
189
+ expected: "Array<string>",
190
+ value: input.locations
191
+ }, errorFactory)) && input.locations.every((elem, _index1) => "string" === typeof elem || $guard(_exceptionable, {
192
+ path: _path + ".locations[" + _index1 + "]",
193
+ expected: "string",
194
+ value: elem
195
+ }, errorFactory)) || $guard(_exceptionable, {
196
+ path: _path + ".locations",
197
+ expected: "Array<string>",
198
+ value: input.locations
199
+ }, errorFactory)) && ("number" === typeof input.replicas && (Math.floor(input.replicas) === input.replicas && 0 <= input.replicas && input.replicas <= 4294967295 || $guard(_exceptionable, {
200
+ path: _path + ".replicas",
201
+ expected: "number & Type<\"uint32\">",
202
+ value: input.replicas
203
+ }, errorFactory)) || $guard(_exceptionable, {
204
+ path: _path + ".replicas",
205
+ expected: "(number & Type<\"uint32\">)",
206
+ value: input.replicas
207
+ }, errorFactory)) && ("number" === typeof input.priority && (Math.floor(input.priority) === input.priority && 0 <= input.priority && input.priority <= 4294967295 || $guard(_exceptionable, {
208
+ path: _path + ".priority",
209
+ expected: "number & Type<\"uint32\">",
210
+ value: input.priority
211
+ }, errorFactory)) || $guard(_exceptionable, {
212
+ path: _path + ".priority",
213
+ expected: "(number & Type<\"uint32\">)",
214
+ value: input.priority
215
+ }, errorFactory)) && ((Array.isArray(input.includes) || $guard(_exceptionable, {
216
+ path: _path + ".includes",
217
+ expected: "Array<string>",
218
+ value: input.includes
219
+ }, errorFactory)) && input.includes.every((elem, _index2) => "string" === typeof elem || $guard(_exceptionable, {
220
+ path: _path + ".includes[" + _index2 + "]",
221
+ expected: "string",
222
+ value: elem
223
+ }, errorFactory)) || $guard(_exceptionable, {
224
+ path: _path + ".includes",
225
+ expected: "Array<string>",
226
+ value: input.includes
227
+ }, errorFactory)) && ((Array.isArray(input.excludes) || $guard(_exceptionable, {
228
+ path: _path + ".excludes",
229
+ expected: "Array<string>",
230
+ value: input.excludes
231
+ }, errorFactory)) && input.excludes.every((elem, _index3) => "string" === typeof elem || $guard(_exceptionable, {
232
+ path: _path + ".excludes[" + _index3 + "]",
233
+ expected: "string",
234
+ value: elem
235
+ }, errorFactory)) || $guard(_exceptionable, {
236
+ path: _path + ".excludes",
237
+ expected: "Array<string>",
238
+ value: input.excludes
239
+ }, errorFactory));
240
+ return ("object" === typeof input && null !== input || $guard(true, {
241
+ path: _path + "",
242
+ expected: "Rule",
243
+ value: input
244
+ }, errorFactory)) && $ao0(input, _path + "", true) || $guard(true, {
245
+ path: _path + "",
246
+ expected: "Rule",
247
+ value: input
248
+ }, errorFactory);
249
+ })(input, "$input", true);
250
+ return input;
251
+ }; const stringify = input => {
252
+ const $string = __typia.json.createAssertStringify.string;
253
+ const $so0 = input => `{"locations":${`[${input.locations.map(elem => $string(elem)).join(",")}]`},"replicas":${input.replicas},"priority":${input.priority},"includes":${`[${input.includes.map(elem => $string(elem)).join(",")}]`},"excludes":${`[${input.excludes.map(elem => $string(elem)).join(",")}]`}}`;
254
+ return $so0(input);
255
+ }; return stringify(assert(input, errorFactory)); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/types",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "prepare": "ts-patch install && typia patch",
@@ -27,6 +27,7 @@
27
27
  "fast-json-stringify": "^5.16.0",
28
28
  "mitata": "^0.1.11",
29
29
  "rimraf": "^5.0.7",
30
+ "spark-md5": "^3.0.2",
30
31
  "ts-node": "^10.9.2",
31
32
  "ts-patch": "^3.1.2",
32
33
  "typescript": "^5.4.5"