@milkio/astra 1.0.0-alpha.1 → 1.0.0-alpha.3
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/index.ts +13 -7
- package/package.json +2 -5
- package/utils/cookbook-dto-checks.ts +78 -18
- package/utils/cookbook-dto-types.ts +7 -0
package/index.ts
CHANGED
|
@@ -208,15 +208,21 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
208
208
|
} as any;
|
|
209
209
|
|
|
210
210
|
const reject = (...params: Array<unknown>): Error => {
|
|
211
|
-
const output: Array<any> = [
|
|
211
|
+
const output: Array<any> = [
|
|
212
|
+
"[REJECT]",
|
|
213
|
+
...params.map((param) => {
|
|
214
|
+
try {
|
|
215
|
+
const result = TSON.stringify(param);
|
|
216
|
+
return result;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return error?.toString?.() ?? typeof error;
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
];
|
|
212
222
|
console.log(...output);
|
|
213
223
|
for (let index = 1; index < output.length; index++) {
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
output[index] = output[index].toString();
|
|
217
|
-
} else {
|
|
218
|
-
output[index] = TSON.stringify(output[index]);
|
|
219
|
-
}
|
|
224
|
+
if (typeof output[index] === "object") {
|
|
225
|
+
output[index] = output[index].toString();
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
const message = output.join(" ");
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkio/astra",
|
|
3
3
|
"module": "index.ts",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@types/bun": "latest"
|
|
8
8
|
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"typescript": "5.6.0"
|
|
11
|
-
},
|
|
12
9
|
"dependencies": {
|
|
13
|
-
"@southern-aurora/tson": "
|
|
10
|
+
"@southern-aurora/tson": "*",
|
|
14
11
|
"date-fns": "^4.1.0",
|
|
15
12
|
"js-toml": "^1.0.0"
|
|
16
13
|
}
|
|
@@ -15,6 +15,7 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
15
15
|
null,
|
|
16
16
|
CookbookOptions
|
|
17
17
|
]> => {
|
|
18
|
+
let cookbookToml = { ...cookbookTomlParsed };
|
|
18
19
|
const checkResult = (() => { const $join = (typia.validateEquals as any).join; const $io0 = (input: any, _exceptionable: boolean = true): boolean => "object" === typeof input.projects && null !== input.projects && false === Array.isArray(input.projects) && $io1(input.projects, true && _exceptionable) && ("object" === typeof input.general && null !== input.general && $io3(input.general, true && _exceptionable)) && (2 === Object.keys(input).length || Object.keys(input).every((key: any) => {
|
|
19
20
|
if (["projects", "general"].some((prop: any) => key === prop))
|
|
20
21
|
return true;
|
|
@@ -27,15 +28,15 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
27
28
|
if (undefined === value)
|
|
28
29
|
return true;
|
|
29
30
|
return "object" === typeof value && null !== value && $io2(value, true && _exceptionable);
|
|
30
|
-
}); const $io2 = (input: any, _exceptionable: boolean = true): boolean => ("milkio" === input.type || "other" === input.type) && "number" === typeof input.port && (Array.isArray(input.start) && input.start.every((elem: any, _index1: number) => "string" === typeof elem)) && (Array.isArray(input.build) && input.build.every((elem: any, _index2: number) => "string" === typeof elem)) && (undefined === input.lazyRoutes || "boolean" === typeof input.lazyRoutes) && (undefined === input.typiaMode || "generation" === input.typiaMode || "bundler" === input.typiaMode) && (undefined === input.significant || Array.isArray(input.significant) && input.significant.every((elem: any, _index3: number) => "string" === typeof elem)) && (undefined === input.insignificant || Array.isArray(input.insignificant) && input.insignificant.every((elem: any, _index4: number) => "string" === typeof elem)) && (4 === Object.keys(input).length || Object.keys(input).every((key: any) => {
|
|
31
|
-
if (["type", "port", "start", "build", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
31
|
+
}); const $io2 = (input: any, _exceptionable: boolean = true): boolean => ("milkio" === input.type || "other" === input.type) && "number" === typeof input.port && (Array.isArray(input.start) && input.start.every((elem: any, _index1: number) => "string" === typeof elem)) && (Array.isArray(input.build) && input.build.every((elem: any, _index2: number) => "string" === typeof elem)) && (undefined === input.watch || "boolean" === typeof input.watch) && (undefined === input.lazyRoutes || "boolean" === typeof input.lazyRoutes) && (undefined === input.typiaMode || "generation" === input.typiaMode || "bundler" === input.typiaMode) && (undefined === input.significant || Array.isArray(input.significant) && input.significant.every((elem: any, _index3: number) => "string" === typeof elem)) && (undefined === input.insignificant || Array.isArray(input.insignificant) && input.insignificant.every((elem: any, _index4: number) => "string" === typeof elem)) && (4 === Object.keys(input).length || Object.keys(input).every((key: any) => {
|
|
32
|
+
if (["type", "port", "start", "build", "watch", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
32
33
|
return true;
|
|
33
34
|
const value = input[key];
|
|
34
35
|
if (undefined === value)
|
|
35
36
|
return true;
|
|
36
37
|
return false;
|
|
37
|
-
})); const $io3 = (input: any, _exceptionable: boolean = true): boolean => "number" === typeof input.cookbookPort && (
|
|
38
|
-
if (["cookbookPort"].some((prop: any) => key === prop))
|
|
38
|
+
})); const $io3 = (input: any, _exceptionable: boolean = true): boolean => "string" === typeof input.start && "number" === typeof input.cookbookPort && (2 === Object.keys(input).length || Object.keys(input).every((key: any) => {
|
|
39
|
+
if (["start", "cookbookPort"].some((prop: any) => key === prop))
|
|
39
40
|
return true;
|
|
40
41
|
const value = input[key];
|
|
41
42
|
if (undefined === value)
|
|
@@ -113,6 +114,10 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
113
114
|
path: _path + ".build",
|
|
114
115
|
expected: "Array<string>",
|
|
115
116
|
value: input.build
|
|
117
|
+
}), undefined === input.watch || "boolean" === typeof input.watch || $report(_exceptionable, {
|
|
118
|
+
path: _path + ".watch",
|
|
119
|
+
expected: "(boolean | undefined)",
|
|
120
|
+
value: input.watch
|
|
116
121
|
}), undefined === input.lazyRoutes || "boolean" === typeof input.lazyRoutes || $report(_exceptionable, {
|
|
117
122
|
path: _path + ".lazyRoutes",
|
|
118
123
|
expected: "(boolean | undefined)",
|
|
@@ -146,7 +151,7 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
146
151
|
expected: "(Array<string> | undefined)",
|
|
147
152
|
value: input.insignificant
|
|
148
153
|
}), 4 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
149
|
-
if (["type", "port", "start", "build", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
154
|
+
if (["type", "port", "start", "build", "watch", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
150
155
|
return true;
|
|
151
156
|
const value = input[key];
|
|
152
157
|
if (undefined === value)
|
|
@@ -156,12 +161,16 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
156
161
|
expected: "undefined",
|
|
157
162
|
value: value
|
|
158
163
|
});
|
|
159
|
-
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const $vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["
|
|
164
|
+
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const $vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["string" === typeof input.start || $report(_exceptionable, {
|
|
165
|
+
path: _path + ".start",
|
|
166
|
+
expected: "string",
|
|
167
|
+
value: input.start
|
|
168
|
+
}), "number" === typeof input.cookbookPort || $report(_exceptionable, {
|
|
160
169
|
path: _path + ".cookbookPort",
|
|
161
170
|
expected: "number",
|
|
162
171
|
value: input.cookbookPort
|
|
163
|
-
}),
|
|
164
|
-
if (["cookbookPort"].some((prop: any) => key === prop))
|
|
172
|
+
}), 2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
173
|
+
if (["start", "cookbookPort"].some((prop: any) => key === prop))
|
|
165
174
|
return true;
|
|
166
175
|
const value = input[key];
|
|
167
176
|
if (undefined === value)
|
|
@@ -204,9 +213,9 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
204
213
|
Error.captureStackTrace(error);
|
|
205
214
|
cookbookTomlParsed = null;
|
|
206
215
|
}
|
|
207
|
-
return [error,
|
|
216
|
+
return [error, cookbookToml];
|
|
208
217
|
};
|
|
209
|
-
export const checkCookbookActionParams = async (
|
|
218
|
+
export const checkCookbookActionParams = async (resultsRaw: any): Promise<[
|
|
210
219
|
Record<any, any> & {
|
|
211
220
|
message: string;
|
|
212
221
|
stack: string;
|
|
@@ -216,9 +225,17 @@ export const checkCookbookActionParams = async (results: any): Promise<[
|
|
|
216
225
|
null,
|
|
217
226
|
CookbookActionParams
|
|
218
227
|
]> => {
|
|
228
|
+
let results = { ...resultsRaw };
|
|
219
229
|
if (typeof Bun === "undefined")
|
|
220
230
|
throw new Error("Bun is not defined");
|
|
221
|
-
const checkResult = (() => { const $io0 = (input: any): boolean => "milkio@logger" === input.type && Array.isArray(input.log); const $
|
|
231
|
+
const checkResult = (() => { const $throws = (typia.misc.validatePrune as any).throws; const $io0 = (input: any): boolean => "milkio@logger" === input.type && Array.isArray(input.log); const $io1 = (input: any): boolean => "milkio@template" === input.type && "string" === typeof input.name && "string" === typeof input.fsPath && "string" === typeof input.template; const $iu0 = (input: any): any => (() => {
|
|
232
|
+
if ("milkio@logger" === input.type)
|
|
233
|
+
return $io0(input);
|
|
234
|
+
else if ("milkio@template" === input.type)
|
|
235
|
+
return $io1(input);
|
|
236
|
+
else
|
|
237
|
+
return false;
|
|
238
|
+
})(); const $vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@logger" === input.type || $report(_exceptionable, {
|
|
222
239
|
path: _path + ".type",
|
|
223
240
|
expected: "\"milkio@logger\"",
|
|
224
241
|
value: input.type
|
|
@@ -226,23 +243,66 @@ export const checkCookbookActionParams = async (results: any): Promise<[
|
|
|
226
243
|
path: _path + ".log",
|
|
227
244
|
expected: "Array<any>",
|
|
228
245
|
value: input.log
|
|
229
|
-
})].every((flag: boolean) => flag); const $
|
|
246
|
+
})].every((flag: boolean) => flag); const $vo1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@template" === input.type || $report(_exceptionable, {
|
|
247
|
+
path: _path + ".type",
|
|
248
|
+
expected: "\"milkio@template\"",
|
|
249
|
+
value: input.type
|
|
250
|
+
}), "string" === typeof input.name || $report(_exceptionable, {
|
|
251
|
+
path: _path + ".name",
|
|
252
|
+
expected: "string",
|
|
253
|
+
value: input.name
|
|
254
|
+
}), "string" === typeof input.fsPath || $report(_exceptionable, {
|
|
255
|
+
path: _path + ".fsPath",
|
|
256
|
+
expected: "string",
|
|
257
|
+
value: input.fsPath
|
|
258
|
+
}), "string" === typeof input.template || $report(_exceptionable, {
|
|
259
|
+
path: _path + ".template",
|
|
260
|
+
expected: "string",
|
|
261
|
+
value: input.template
|
|
262
|
+
})].every((flag: boolean) => flag); const $vu0 = (input: any, _path: string, _exceptionable: boolean = true): any => (() => {
|
|
263
|
+
if ("milkio@logger" === input.type)
|
|
264
|
+
return $vo0(input, _path, true && _exceptionable);
|
|
265
|
+
else if ("milkio@template" === input.type)
|
|
266
|
+
return $vo1(input, _path, true && _exceptionable);
|
|
267
|
+
else
|
|
268
|
+
return $report(_exceptionable, {
|
|
269
|
+
path: _path,
|
|
270
|
+
expected: "(__type | __type.o1)",
|
|
271
|
+
value: input
|
|
272
|
+
});
|
|
273
|
+
})(); const $po0 = (input: any): any => {
|
|
230
274
|
for (const key of Object.keys(input)) {
|
|
231
275
|
if ("type" === key || "log" === key)
|
|
232
276
|
continue;
|
|
233
277
|
delete input[key];
|
|
234
278
|
}
|
|
235
|
-
}; const
|
|
279
|
+
}; const $po1 = (input: any): any => {
|
|
280
|
+
for (const key of Object.keys(input)) {
|
|
281
|
+
if ("type" === key || "name" === key || "fsPath" === key || "template" === key)
|
|
282
|
+
continue;
|
|
283
|
+
delete input[key];
|
|
284
|
+
}
|
|
285
|
+
}; const $pu0 = (input: any): any => (() => {
|
|
286
|
+
if ("milkio@logger" === input.type)
|
|
287
|
+
return $po0(input);
|
|
288
|
+
else if ("milkio@template" === input.type)
|
|
289
|
+
return $po1(input);
|
|
290
|
+
else
|
|
291
|
+
$throws({
|
|
292
|
+
expected: "(__type | __type.o1)",
|
|
293
|
+
value: input
|
|
294
|
+
});
|
|
295
|
+
})(); const __is = (input: any): input is CookbookActionParams => "object" === typeof input && null !== input && $iu0(input); let errors: any; let $report: any; const __validate = (input: any): typia.IValidation<CookbookActionParams> => {
|
|
236
296
|
if (false === __is(input)) {
|
|
237
297
|
errors = [];
|
|
238
298
|
$report = (typia.misc.validatePrune as any).report(errors);
|
|
239
299
|
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || $report(true, {
|
|
240
300
|
path: _path + "",
|
|
241
|
-
expected: "
|
|
301
|
+
expected: "(__type | __type.o1)",
|
|
242
302
|
value: input
|
|
243
|
-
})) && $
|
|
303
|
+
})) && $vu0(input, _path + "", true) || $report(true, {
|
|
244
304
|
path: _path + "",
|
|
245
|
-
expected: "
|
|
305
|
+
expected: "(__type | __type.o1)",
|
|
246
306
|
value: input
|
|
247
307
|
}))(input, "$input", true);
|
|
248
308
|
const success = 0 === errors.length;
|
|
@@ -259,13 +319,13 @@ export const checkCookbookActionParams = async (results: any): Promise<[
|
|
|
259
319
|
} as any;
|
|
260
320
|
}; const __prune = (input: CookbookActionParams): void => {
|
|
261
321
|
if ("object" === typeof input && null !== input)
|
|
262
|
-
$
|
|
322
|
+
$pu0(input);
|
|
263
323
|
}; return (input: any): typia.IValidation<CookbookActionParams> => {
|
|
264
324
|
const result = __validate(input);
|
|
265
325
|
if (result.success)
|
|
266
326
|
__prune(input);
|
|
267
327
|
return result;
|
|
268
|
-
}; })()(
|
|
328
|
+
}; })()(resultsRaw);
|
|
269
329
|
let error = null;
|
|
270
330
|
if (!checkResult.success) {
|
|
271
331
|
const error: any = checkResult.errors.at(0)!;
|
|
@@ -9,18 +9,25 @@ export type CookbookOptions = {
|
|
|
9
9
|
port: number;
|
|
10
10
|
start: Array<string>;
|
|
11
11
|
build: Array<string>;
|
|
12
|
+
watch?: boolean;
|
|
12
13
|
lazyRoutes?: boolean;
|
|
13
14
|
typiaMode?: "generation" | "bundler";
|
|
14
15
|
significant?: Array<string>;
|
|
15
16
|
insignificant?: Array<string>;
|
|
16
17
|
}>;
|
|
17
18
|
general: {
|
|
19
|
+
start: string;
|
|
18
20
|
cookbookPort: number;
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
23
|
export type CookbookActionParams = {
|
|
22
24
|
type: "milkio@logger";
|
|
23
25
|
log: Array<any>;
|
|
26
|
+
} | {
|
|
27
|
+
type: "milkio@template";
|
|
28
|
+
name: string;
|
|
29
|
+
fsPath: string;
|
|
30
|
+
template: string;
|
|
24
31
|
};
|
|
25
32
|
export type CookbookSubscribeEmits = {
|
|
26
33
|
type: "workers@stdout";
|