@milkio/astra 1.0.0-alpha.1 → 1.0.0-alpha.100
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/.publish/publish.json +0 -0
- package/README.md +0 -0
- package/index.ts +31 -23
- package/package.json +6 -9
- package/tsconfig.json +9 -8
- package/utils/cookbook-dto-checks.ts +255 -128
- package/utils/cookbook-dto-types.ts +30 -15
package/.publish/publish.json
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { format } from "date-fns";
|
|
|
9
9
|
import type { CookbookOptions } from "./utils/cookbook-dto-types";
|
|
10
10
|
|
|
11
11
|
export type AstraOptionsInit = {
|
|
12
|
-
stargate: { $types: any; execute: any; ping: any;
|
|
12
|
+
stargate: { $types: any; execute: any; ping: any; __cookbook: any };
|
|
13
13
|
bootstrap: () => Promise<Record<string, any>>;
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -41,9 +41,9 @@ type Log = [string /* executeId */, "[DEBUG]" | "[INFO]" | "[WARN]" | "[ERROR]"
|
|
|
41
41
|
|
|
42
42
|
type Reject = (description: string, ...params: Array<unknown>) => Error;
|
|
43
43
|
|
|
44
|
-
export
|
|
44
|
+
export async function createAstra<AstraOptions extends AstraOptionsInit, Generated extends AstraOptions["stargate"]["$types"]["generated"]>(astraOptions: AstraOptions) {
|
|
45
45
|
if (!existsSync(join(cwd(), "cookbook.toml"))) throw new Error(`The "cookbook.toml" file does not exist in the current directory. If you are running the test with the VS Code extension, make sure it exists in the root directory of the folder you are opening with VS Code.`);
|
|
46
|
-
|
|
46
|
+
const cookbookOptions = load((await readFile(join(cwd(), "cookbook.toml"))).toString()) as CookbookOptions;
|
|
47
47
|
// wait for all milkio projects to start and can be accessed
|
|
48
48
|
// the reason why stargate's ping method is not used directly is that even if only one project is tested, it is necessary to wait for all milkio projects to start
|
|
49
49
|
await Promise.all([
|
|
@@ -53,7 +53,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
53
53
|
const project = cookbookOptions.projects[projectName];
|
|
54
54
|
if (project.type !== "milkio") continue;
|
|
55
55
|
projectStatus.set(projectName, withResolvers());
|
|
56
|
-
let counter =
|
|
56
|
+
let counter = 65;
|
|
57
57
|
let timer: Timer | null = setInterval(async () => {
|
|
58
58
|
if (--counter <= 0) {
|
|
59
59
|
clearInterval(timer!);
|
|
@@ -63,6 +63,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
try {
|
|
66
|
+
console.log("\n[ASTRA]", `connecting.. ${counter >= 64 ? "" : `(${counter})`}`);
|
|
66
67
|
const response = await fetchWithTimeout(`http://localhost:${project.port}/generate_204`, { method: "HEAD", timeout: 1024 });
|
|
67
68
|
if (response.status === 204) {
|
|
68
69
|
if (timer) clearTimeout(timer);
|
|
@@ -70,30 +71,30 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
70
71
|
return projectStatus.get(projectName)!.resolve(undefined);
|
|
71
72
|
}
|
|
72
73
|
} catch (error) {}
|
|
73
|
-
},
|
|
74
|
+
}, 100);
|
|
74
75
|
}
|
|
75
76
|
return Array.from(projectStatus.values()).map((v) => v.promise);
|
|
76
77
|
})(),
|
|
77
78
|
]);
|
|
78
79
|
|
|
79
|
-
type Execute = <Path extends keyof Generated["routeSchema"]
|
|
80
|
+
type Execute = <Path extends keyof Generated["routeSchema"]>(
|
|
80
81
|
path: Path,
|
|
81
82
|
options?: Mixin<
|
|
82
83
|
ExecuteOptions,
|
|
83
84
|
| {
|
|
84
|
-
params?: Generated["routeSchema"]["
|
|
85
|
+
params?: Generated["routeSchema"][Path]["types"]["params"];
|
|
85
86
|
}
|
|
86
87
|
| {
|
|
87
|
-
params?: Partial<Generated["routeSchema"]["
|
|
88
|
+
params?: Partial<Generated["routeSchema"][Path]["types"]["params"]>;
|
|
88
89
|
generateParams: true;
|
|
89
90
|
}
|
|
90
91
|
>,
|
|
91
92
|
) => Promise<
|
|
92
|
-
Generated["routeSchema"]["
|
|
93
|
+
Generated["routeSchema"][Path]["types"]["🐣"] extends boolean
|
|
93
94
|
? // action
|
|
94
|
-
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["routeSchema"]["
|
|
95
|
+
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["routeSchema"][Path]["types"]["result"], ExecuteResultsOption]
|
|
95
96
|
: // stream
|
|
96
|
-
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, AsyncGenerator<[Partial<Generated["rejectCode"]>, null] | [null, GeneratorGeneric<Generated["routeSchema"]["
|
|
97
|
+
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, AsyncGenerator<[Partial<Generated["rejectCode"]>, null] | [null, GeneratorGeneric<Generated["routeSchema"][Path]["types"]["result"]>], ExecuteResultsOption>]
|
|
97
98
|
>;
|
|
98
99
|
|
|
99
100
|
type MirrorWorld = Mixin<
|
|
@@ -110,7 +111,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
110
111
|
const thisFilePath = join(fileURLToPath(importMetaUrl));
|
|
111
112
|
const thisFileDirPath = join(dirname(thisFilePath)).replaceAll("\\", "/");
|
|
112
113
|
const thisFileDirPathArr = thisFileDirPath.split("/");
|
|
113
|
-
let projectName
|
|
114
|
+
let projectName = "";
|
|
114
115
|
|
|
115
116
|
await (async () => {
|
|
116
117
|
let isProjectsDirectory = false;
|
|
@@ -137,17 +138,17 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
137
138
|
const paths = {
|
|
138
139
|
cwd: join(cwd(), "projects", projectName),
|
|
139
140
|
milkio: join(cwd(), "projects", projectName, ".milkio"),
|
|
140
|
-
generated: join(cwd(), "projects", projectName, ".milkio"
|
|
141
|
+
generated: join(cwd(), "projects", projectName, ".milkio"),
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
const execute = async (path: Parameters<MirrorWorld["execute"]>[0], optionsInit?: Parameters<MirrorWorld["execute"]>[1]) => {
|
|
144
|
-
|
|
145
|
+
const options = (optionsInit as any) ?? {};
|
|
145
146
|
if (options?.generateParams === true) {
|
|
146
147
|
if (!options?.params) options.params = {};
|
|
147
148
|
options.params.$milkioGenerateParams = "enable";
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
const results = await this.options.stargate.
|
|
151
|
+
const results = await this.options.stargate.__cookbook.subscribe(`http://localhost:${cookbookOptions.general.cookbookPort}`);
|
|
151
152
|
void (async () => {
|
|
152
153
|
for await (const result of results) {
|
|
153
154
|
if (result.type !== "milkio@logger") continue;
|
|
@@ -165,6 +166,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
165
166
|
|
|
166
167
|
const getNow = () => format(new Date(), "(yyyy-MM-dd hh:mm:ss)");
|
|
167
168
|
const onLoggerInserting = (log: Log) => {
|
|
169
|
+
// biome-ignore lint/style/noParameterAssign: <explanation>
|
|
168
170
|
log = [...log];
|
|
169
171
|
log[0] = `\n${log[0]}` as any;
|
|
170
172
|
console.log(...log);
|
|
@@ -208,15 +210,21 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
208
210
|
} as any;
|
|
209
211
|
|
|
210
212
|
const reject = (...params: Array<unknown>): Error => {
|
|
211
|
-
const output: Array<any> = [
|
|
213
|
+
const output: Array<any> = [
|
|
214
|
+
"[REJECT]",
|
|
215
|
+
...params.map((param) => {
|
|
216
|
+
try {
|
|
217
|
+
const result = TSON.stringify(param);
|
|
218
|
+
return result;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return error?.toString?.() ?? typeof error;
|
|
221
|
+
}
|
|
222
|
+
}),
|
|
223
|
+
];
|
|
212
224
|
console.log(...output);
|
|
213
225
|
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
|
-
}
|
|
226
|
+
if (typeof output[index] === "object") {
|
|
227
|
+
output[index] = output[index].toString();
|
|
220
228
|
}
|
|
221
229
|
}
|
|
222
230
|
const message = output.join(" ");
|
|
@@ -226,7 +234,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
226
234
|
return [context, reject, world];
|
|
227
235
|
},
|
|
228
236
|
};
|
|
229
|
-
}
|
|
237
|
+
}
|
|
230
238
|
|
|
231
239
|
export async function fetchWithTimeout(url: string, options: FetchRequestInit & { timeout?: number } = {}) {
|
|
232
240
|
const { timeout = 8000 } = options;
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkio/astra",
|
|
3
|
-
"module": "index.ts",
|
|
4
|
-
"version": "1.0.0-alpha.1",
|
|
5
3
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"typescript": "5.6.0"
|
|
11
|
-
},
|
|
4
|
+
"version": "1.0.0-alpha.100",
|
|
5
|
+
"module": "index.ts",
|
|
12
6
|
"dependencies": {
|
|
13
|
-
"@southern-aurora/tson": "
|
|
7
|
+
"@southern-aurora/tson": "*",
|
|
14
8
|
"date-fns": "^4.1.0",
|
|
15
9
|
"js-toml": "^1.0.0"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bun": "latest"
|
|
16
13
|
}
|
|
17
14
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"jsx": "react-jsx",
|
|
5
|
+
"erasableSyntaxOnly":true,
|
|
3
6
|
// Enable latest features
|
|
4
7
|
"lib": ["ESNext", "DOM"],
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"module": "ESNext",
|
|
7
8
|
"moduleDetection": "force",
|
|
8
|
-
"
|
|
9
|
-
"allowJs": true,
|
|
9
|
+
"module": "ESNext",
|
|
10
10
|
|
|
11
11
|
// Bundler mode
|
|
12
12
|
"moduleResolution": "bundler",
|
|
13
13
|
"allowImportingTsExtensions": true,
|
|
14
|
-
"
|
|
15
|
-
"noEmit": true,
|
|
14
|
+
"allowJs": true,
|
|
16
15
|
|
|
17
16
|
// Best practices
|
|
18
17
|
"strict": true,
|
|
19
|
-
"skipLibCheck": true,
|
|
20
18
|
"noFallthroughCasesInSwitch": true,
|
|
21
19
|
|
|
20
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
22
21
|
// Some stricter flags (disabled by default)
|
|
23
22
|
"noUnusedLocals": false,
|
|
24
23
|
"noUnusedParameters": false,
|
|
25
|
-
"
|
|
24
|
+
"noEmit": true,
|
|
25
|
+
"verbatimModuleSyntax": true,
|
|
26
|
+
"skipLibCheck": true
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The content of this file is automatically generated by Typia.
|
|
3
|
-
* It can be edited in the /packages/cookbook-dto/src/* file, and each time you run bun run dev, the generated file will be synced to another location based on the content of the /develop.ts.
|
|
4
|
-
*/
|
|
2
|
+
* The content of this file is automatically generated by Typia.
|
|
3
|
+
* It can be edited in the /packages/cookbook-dto/src/* file, and each time you run bun run dev, the generated file will be synced to another location based on the content of the /develop.ts.
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
6
|
+
import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
|
|
7
|
+
import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js";
|
|
8
|
+
import * as __typia_transform__throwTypeGuardError from "typia/lib/internal/_throwTypeGuardError.js";
|
|
9
|
+
import typia from 'typia';
|
|
10
|
+
import type { CookbookActionParams, CookbookOptions, CookbookSubscribeEmits } from './cookbook-dto-types';
|
|
11
|
+
export async function checkCookbookOptions(cookbookTomlParsed: any): Promise<[
|
|
9
12
|
Record<any, any> & {
|
|
10
13
|
message: string;
|
|
11
14
|
stack: string;
|
|
@@ -14,46 +17,47 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
14
17
|
] | [
|
|
15
18
|
null,
|
|
16
19
|
CookbookOptions
|
|
17
|
-
]>
|
|
18
|
-
const
|
|
20
|
+
]> {
|
|
21
|
+
const cookbookToml = { ...cookbookTomlParsed };
|
|
22
|
+
const checkResult = (() => { 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
23
|
if (["projects", "general"].some((prop: any) => key === prop))
|
|
20
24
|
return true;
|
|
21
25
|
const value = input[key];
|
|
22
26
|
if (undefined === value)
|
|
23
27
|
return true;
|
|
24
28
|
return false;
|
|
25
|
-
})); const
|
|
29
|
+
})); const _io1 = (input: any, _exceptionable: boolean = true): boolean => Object.keys(input).every((key: any) => {
|
|
26
30
|
const value = input[key];
|
|
27
31
|
if (undefined === value)
|
|
28
32
|
return true;
|
|
29
|
-
return "object" === typeof value && null !== value &&
|
|
30
|
-
}); const
|
|
31
|
-
if (["type", "port", "start", "build", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
33
|
+
return "object" === typeof value && null !== value && _io2(value, true && _exceptionable);
|
|
34
|
+
}); const _io2 = (input: any, _exceptionable: boolean = true): boolean => ("milkio" === input.type || "custom" === 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) => {
|
|
35
|
+
if (["type", "port", "start", "build", "watch", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
32
36
|
return true;
|
|
33
37
|
const value = input[key];
|
|
34
38
|
if (undefined === value)
|
|
35
39
|
return true;
|
|
36
40
|
return false;
|
|
37
|
-
})); const
|
|
38
|
-
if (["cookbookPort"].some((prop: any) => key === prop))
|
|
41
|
+
})); 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) => {
|
|
42
|
+
if (["start", "cookbookPort"].some((prop: any) => key === prop))
|
|
39
43
|
return true;
|
|
40
44
|
const value = input[key];
|
|
41
45
|
if (undefined === value)
|
|
42
46
|
return true;
|
|
43
47
|
return false;
|
|
44
|
-
})); const
|
|
48
|
+
})); const _vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => [("object" === typeof input.projects && null !== input.projects && false === Array.isArray(input.projects) || _report(_exceptionable, {
|
|
45
49
|
path: _path + ".projects",
|
|
46
50
|
expected: "Record<string, __type>",
|
|
47
51
|
value: input.projects
|
|
48
|
-
})) &&
|
|
52
|
+
})) && _vo1(input.projects, _path + ".projects", true && _exceptionable) || _report(_exceptionable, {
|
|
49
53
|
path: _path + ".projects",
|
|
50
54
|
expected: "Record<string, __type>",
|
|
51
55
|
value: input.projects
|
|
52
|
-
}), ("object" === typeof input.general && null !== input.general ||
|
|
56
|
+
}), ("object" === typeof input.general && null !== input.general || _report(_exceptionable, {
|
|
53
57
|
path: _path + ".general",
|
|
54
58
|
expected: "__type.o1",
|
|
55
59
|
value: input.general
|
|
56
|
-
})) &&
|
|
60
|
+
})) && _vo3(input.general, _path + ".general", true && _exceptionable) || _report(_exceptionable, {
|
|
57
61
|
path: _path + ".general",
|
|
58
62
|
expected: "__type.o1",
|
|
59
63
|
value: input.general
|
|
@@ -63,150 +67,160 @@ export const checkCookbookOptions = async (cookbookTomlParsed: any): Promise<[
|
|
|
63
67
|
const value = input[key];
|
|
64
68
|
if (undefined === value)
|
|
65
69
|
return true;
|
|
66
|
-
return
|
|
67
|
-
path: _path +
|
|
70
|
+
return _report(_exceptionable, {
|
|
71
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
68
72
|
expected: "undefined",
|
|
69
73
|
value: value
|
|
70
74
|
});
|
|
71
|
-
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const
|
|
75
|
+
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const _vo1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => [false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
72
76
|
const value = input[key];
|
|
73
77
|
if (undefined === value)
|
|
74
78
|
return true;
|
|
75
|
-
return ("object" === typeof value && null !== value ||
|
|
76
|
-
path: _path +
|
|
79
|
+
return ("object" === typeof value && null !== value || _report(_exceptionable, {
|
|
80
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
77
81
|
expected: "__type",
|
|
78
82
|
value: value
|
|
79
|
-
})) &&
|
|
80
|
-
path: _path +
|
|
83
|
+
})) && _vo2(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || _report(_exceptionable, {
|
|
84
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
81
85
|
expected: "__type",
|
|
82
86
|
value: value
|
|
83
87
|
});
|
|
84
|
-
}).every((flag: boolean) => flag)].every((flag: boolean) => flag); const
|
|
88
|
+
}).every((flag: boolean) => flag)].every((flag: boolean) => flag); const _vo2 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio" === input.type || "custom" === input.type || _report(_exceptionable, {
|
|
85
89
|
path: _path + ".type",
|
|
86
|
-
expected: "(\"milkio\" | \"
|
|
90
|
+
expected: "(\"milkio\" | \"custom\")",
|
|
87
91
|
value: input.type
|
|
88
|
-
}), "number" === typeof input.port ||
|
|
92
|
+
}), "number" === typeof input.port || _report(_exceptionable, {
|
|
89
93
|
path: _path + ".port",
|
|
90
94
|
expected: "number",
|
|
91
95
|
value: input.port
|
|
92
|
-
}), (Array.isArray(input.start) ||
|
|
96
|
+
}), (Array.isArray(input.start) || _report(_exceptionable, {
|
|
93
97
|
path: _path + ".start",
|
|
94
98
|
expected: "Array<string>",
|
|
95
99
|
value: input.start
|
|
96
|
-
})) && input.start.map((elem: any, _index5: number) => "string" === typeof elem ||
|
|
100
|
+
})) && input.start.map((elem: any, _index5: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
97
101
|
path: _path + ".start[" + _index5 + "]",
|
|
98
102
|
expected: "string",
|
|
99
103
|
value: elem
|
|
100
|
-
})).every((flag: boolean) => flag) ||
|
|
104
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
101
105
|
path: _path + ".start",
|
|
102
106
|
expected: "Array<string>",
|
|
103
107
|
value: input.start
|
|
104
|
-
}), (Array.isArray(input.build) ||
|
|
108
|
+
}), (Array.isArray(input.build) || _report(_exceptionable, {
|
|
105
109
|
path: _path + ".build",
|
|
106
110
|
expected: "Array<string>",
|
|
107
111
|
value: input.build
|
|
108
|
-
})) && input.build.map((elem: any, _index6: number) => "string" === typeof elem ||
|
|
112
|
+
})) && input.build.map((elem: any, _index6: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
109
113
|
path: _path + ".build[" + _index6 + "]",
|
|
110
114
|
expected: "string",
|
|
111
115
|
value: elem
|
|
112
|
-
})).every((flag: boolean) => flag) ||
|
|
116
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
113
117
|
path: _path + ".build",
|
|
114
118
|
expected: "Array<string>",
|
|
115
119
|
value: input.build
|
|
116
|
-
}), undefined === input.
|
|
120
|
+
}), undefined === input.watch || "boolean" === typeof input.watch || _report(_exceptionable, {
|
|
121
|
+
path: _path + ".watch",
|
|
122
|
+
expected: "(boolean | undefined)",
|
|
123
|
+
value: input.watch
|
|
124
|
+
}), undefined === input.lazyRoutes || "boolean" === typeof input.lazyRoutes || _report(_exceptionable, {
|
|
117
125
|
path: _path + ".lazyRoutes",
|
|
118
126
|
expected: "(boolean | undefined)",
|
|
119
127
|
value: input.lazyRoutes
|
|
120
|
-
}), undefined === input.typiaMode || "generation" === input.typiaMode || "bundler" === input.typiaMode ||
|
|
128
|
+
}), undefined === input.typiaMode || "generation" === input.typiaMode || "bundler" === input.typiaMode || _report(_exceptionable, {
|
|
121
129
|
path: _path + ".typiaMode",
|
|
122
130
|
expected: "(\"bundler\" | \"generation\" | undefined)",
|
|
123
131
|
value: input.typiaMode
|
|
124
|
-
}), undefined === input.significant || (Array.isArray(input.significant) ||
|
|
132
|
+
}), undefined === input.significant || (Array.isArray(input.significant) || _report(_exceptionable, {
|
|
125
133
|
path: _path + ".significant",
|
|
126
134
|
expected: "(Array<string> | undefined)",
|
|
127
135
|
value: input.significant
|
|
128
|
-
})) && input.significant.map((elem: any, _index7: number) => "string" === typeof elem ||
|
|
136
|
+
})) && input.significant.map((elem: any, _index7: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
129
137
|
path: _path + ".significant[" + _index7 + "]",
|
|
130
138
|
expected: "string",
|
|
131
139
|
value: elem
|
|
132
|
-
})).every((flag: boolean) => flag) ||
|
|
140
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
133
141
|
path: _path + ".significant",
|
|
134
142
|
expected: "(Array<string> | undefined)",
|
|
135
143
|
value: input.significant
|
|
136
|
-
}), undefined === input.insignificant || (Array.isArray(input.insignificant) ||
|
|
144
|
+
}), undefined === input.insignificant || (Array.isArray(input.insignificant) || _report(_exceptionable, {
|
|
137
145
|
path: _path + ".insignificant",
|
|
138
146
|
expected: "(Array<string> | undefined)",
|
|
139
147
|
value: input.insignificant
|
|
140
|
-
})) && input.insignificant.map((elem: any, _index8: number) => "string" === typeof elem ||
|
|
148
|
+
})) && input.insignificant.map((elem: any, _index8: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
141
149
|
path: _path + ".insignificant[" + _index8 + "]",
|
|
142
150
|
expected: "string",
|
|
143
151
|
value: elem
|
|
144
|
-
})).every((flag: boolean) => flag) ||
|
|
152
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
145
153
|
path: _path + ".insignificant",
|
|
146
154
|
expected: "(Array<string> | undefined)",
|
|
147
155
|
value: input.insignificant
|
|
148
156
|
}), 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))
|
|
157
|
+
if (["type", "port", "start", "build", "watch", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
150
158
|
return true;
|
|
151
159
|
const value = input[key];
|
|
152
160
|
if (undefined === value)
|
|
153
161
|
return true;
|
|
154
|
-
return
|
|
155
|
-
path: _path +
|
|
162
|
+
return _report(_exceptionable, {
|
|
163
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
156
164
|
expected: "undefined",
|
|
157
165
|
value: value
|
|
158
166
|
});
|
|
159
|
-
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const
|
|
167
|
+
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const _vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["string" === typeof input.start || _report(_exceptionable, {
|
|
168
|
+
path: _path + ".start",
|
|
169
|
+
expected: "string",
|
|
170
|
+
value: input.start
|
|
171
|
+
}), "number" === typeof input.cookbookPort || _report(_exceptionable, {
|
|
160
172
|
path: _path + ".cookbookPort",
|
|
161
173
|
expected: "number",
|
|
162
174
|
value: input.cookbookPort
|
|
163
|
-
}),
|
|
164
|
-
if (["cookbookPort"].some((prop: any) => key === prop))
|
|
175
|
+
}), 2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
176
|
+
if (["start", "cookbookPort"].some((prop: any) => key === prop))
|
|
165
177
|
return true;
|
|
166
178
|
const value = input[key];
|
|
167
179
|
if (undefined === value)
|
|
168
180
|
return true;
|
|
169
|
-
return
|
|
170
|
-
path: _path +
|
|
181
|
+
return _report(_exceptionable, {
|
|
182
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
171
183
|
expected: "undefined",
|
|
172
184
|
value: value
|
|
173
185
|
});
|
|
174
|
-
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const __is = (input: any, _exceptionable: boolean = true): input is CookbookOptions => "object" === typeof input && null !== input &&
|
|
186
|
+
}).every((flag: boolean) => flag))].every((flag: boolean) => flag); const __is = (input: any, _exceptionable: boolean = true): input is CookbookOptions => "object" === typeof input && null !== input && _io0(input, true); let errors: any; let _report: any; return (input: any): import("typia").IValidation<CookbookOptions> => {
|
|
175
187
|
if (false === __is(input)) {
|
|
176
188
|
errors = [];
|
|
177
|
-
|
|
178
|
-
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input ||
|
|
189
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
190
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
179
191
|
path: _path + "",
|
|
180
192
|
expected: "CookbookOptions",
|
|
181
193
|
value: input
|
|
182
|
-
})) &&
|
|
194
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
183
195
|
path: _path + "",
|
|
184
196
|
expected: "CookbookOptions",
|
|
185
197
|
value: input
|
|
186
198
|
}))(input, "$input", true);
|
|
187
199
|
const success = 0 === errors.length;
|
|
188
|
-
return {
|
|
200
|
+
return success ? {
|
|
201
|
+
success,
|
|
202
|
+
data: input
|
|
203
|
+
} : {
|
|
189
204
|
success,
|
|
190
205
|
errors,
|
|
191
|
-
data:
|
|
206
|
+
data: input
|
|
192
207
|
} as any;
|
|
193
208
|
}
|
|
194
209
|
return {
|
|
195
210
|
success: true,
|
|
196
|
-
errors: [],
|
|
197
211
|
data: input
|
|
198
212
|
} as any;
|
|
199
213
|
}; })()(cookbookTomlParsed);
|
|
200
|
-
|
|
214
|
+
const error = null;
|
|
201
215
|
if (!checkResult.success) {
|
|
202
216
|
const error: any = checkResult.errors.at(0)!;
|
|
203
217
|
error.message = `The "cookbook.toml" format is incorrect, [${error.path.slice(7)}] should be ${error.expected}, but it is actually ${error.value}. You may be missing some properties in the configuration item, or adding some properties that will not be used. If you have extra properties, these properties are likely due to a misspelling.`;
|
|
204
218
|
Error.captureStackTrace(error);
|
|
205
219
|
cookbookTomlParsed = null;
|
|
206
220
|
}
|
|
207
|
-
return [error,
|
|
208
|
-
}
|
|
209
|
-
export
|
|
221
|
+
return [error, cookbookToml];
|
|
222
|
+
}
|
|
223
|
+
export async function checkCookbookActionParams(resultsRaw: any): Promise<[
|
|
210
224
|
Record<any, any> & {
|
|
211
225
|
message: string;
|
|
212
226
|
stack: string;
|
|
@@ -215,58 +229,168 @@ export const checkCookbookActionParams = async (results: any): Promise<[
|
|
|
215
229
|
] | [
|
|
216
230
|
null,
|
|
217
231
|
CookbookActionParams
|
|
218
|
-
]>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
232
|
+
]> {
|
|
233
|
+
let results = { ...resultsRaw };
|
|
234
|
+
if (typeof Bun === 'undefined')
|
|
235
|
+
throw new Error('Bun is not defined');
|
|
236
|
+
const checkResult = (() => { const _io0 = (input: any): boolean => "milkio@ping" === input.type; const _io1 = (input: any): boolean => "milkio@logger" === input.type && Array.isArray(input.log); const _io2 = (input: any): boolean => "milkio@template" === input.type && "string" === typeof input.name && "string" === typeof input.fsPath && "string" === typeof input.template; const _io3 = (input: any): boolean => "workers@list" === input.type; const _io4 = (input: any): boolean => "workers@get" === input.type && "string" === typeof input.key && "number" === typeof input.index; const _iu0 = (input: any): any => (() => {
|
|
237
|
+
if ("milkio@ping" === input.type)
|
|
238
|
+
return _io0(input);
|
|
239
|
+
else if ("milkio@logger" === input.type)
|
|
240
|
+
return _io1(input);
|
|
241
|
+
else if ("milkio@template" === input.type)
|
|
242
|
+
return _io2(input);
|
|
243
|
+
else if ("workers@list" === input.type)
|
|
244
|
+
return _io3(input);
|
|
245
|
+
else if ("workers@get" === input.type)
|
|
246
|
+
return _io4(input);
|
|
247
|
+
else
|
|
248
|
+
return false;
|
|
249
|
+
})(); const _vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@ping" === input.type || _report(_exceptionable, {
|
|
250
|
+
path: _path + ".type",
|
|
251
|
+
expected: "\"milkio@ping\"",
|
|
252
|
+
value: input.type
|
|
253
|
+
})].every((flag: boolean) => flag); const _vo1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@logger" === input.type || _report(_exceptionable, {
|
|
222
254
|
path: _path + ".type",
|
|
223
255
|
expected: "\"milkio@logger\"",
|
|
224
256
|
value: input.type
|
|
225
|
-
}), Array.isArray(input.log) ||
|
|
257
|
+
}), Array.isArray(input.log) || _report(_exceptionable, {
|
|
226
258
|
path: _path + ".log",
|
|
227
259
|
expected: "Array<any>",
|
|
228
260
|
value: input.log
|
|
229
|
-
})].every((flag: boolean) => flag); const
|
|
261
|
+
})].every((flag: boolean) => flag); const _vo2 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@template" === input.type || _report(_exceptionable, {
|
|
262
|
+
path: _path + ".type",
|
|
263
|
+
expected: "\"milkio@template\"",
|
|
264
|
+
value: input.type
|
|
265
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
266
|
+
path: _path + ".name",
|
|
267
|
+
expected: "string",
|
|
268
|
+
value: input.name
|
|
269
|
+
}), "string" === typeof input.fsPath || _report(_exceptionable, {
|
|
270
|
+
path: _path + ".fsPath",
|
|
271
|
+
expected: "string",
|
|
272
|
+
value: input.fsPath
|
|
273
|
+
}), "string" === typeof input.template || _report(_exceptionable, {
|
|
274
|
+
path: _path + ".template",
|
|
275
|
+
expected: "string",
|
|
276
|
+
value: input.template
|
|
277
|
+
})].every((flag: boolean) => flag); const _vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@list" === input.type || _report(_exceptionable, {
|
|
278
|
+
path: _path + ".type",
|
|
279
|
+
expected: "\"workers@list\"",
|
|
280
|
+
value: input.type
|
|
281
|
+
})].every((flag: boolean) => flag); const _vo4 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@get" === input.type || _report(_exceptionable, {
|
|
282
|
+
path: _path + ".type",
|
|
283
|
+
expected: "\"workers@get\"",
|
|
284
|
+
value: input.type
|
|
285
|
+
}), "string" === typeof input.key || _report(_exceptionable, {
|
|
286
|
+
path: _path + ".key",
|
|
287
|
+
expected: "string",
|
|
288
|
+
value: input.key
|
|
289
|
+
}), "number" === typeof input.index || _report(_exceptionable, {
|
|
290
|
+
path: _path + ".index",
|
|
291
|
+
expected: "number",
|
|
292
|
+
value: input.index
|
|
293
|
+
})].every((flag: boolean) => flag); const _vu0 = (input: any, _path: string, _exceptionable: boolean = true): any => (() => {
|
|
294
|
+
if ("milkio@ping" === input.type)
|
|
295
|
+
return _vo0(input, _path, true && _exceptionable);
|
|
296
|
+
else if ("milkio@logger" === input.type)
|
|
297
|
+
return _vo1(input, _path, true && _exceptionable);
|
|
298
|
+
else if ("milkio@template" === input.type)
|
|
299
|
+
return _vo2(input, _path, true && _exceptionable);
|
|
300
|
+
else if ("workers@list" === input.type)
|
|
301
|
+
return _vo3(input, _path, true && _exceptionable);
|
|
302
|
+
else if ("workers@get" === input.type)
|
|
303
|
+
return _vo4(input, _path, true && _exceptionable);
|
|
304
|
+
else
|
|
305
|
+
return _report(_exceptionable, {
|
|
306
|
+
path: _path,
|
|
307
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
308
|
+
value: input
|
|
309
|
+
});
|
|
310
|
+
})(); const _po0 = (input: any): any => {
|
|
311
|
+
for (const key of Object.keys(input)) {
|
|
312
|
+
if ("type" === key)
|
|
313
|
+
continue;
|
|
314
|
+
delete input[key];
|
|
315
|
+
}
|
|
316
|
+
}; const _po1 = (input: any): any => {
|
|
230
317
|
for (const key of Object.keys(input)) {
|
|
231
318
|
if ("type" === key || "log" === key)
|
|
232
319
|
continue;
|
|
233
320
|
delete input[key];
|
|
234
321
|
}
|
|
235
|
-
}; const
|
|
322
|
+
}; const _po2 = (input: any): any => {
|
|
323
|
+
for (const key of Object.keys(input)) {
|
|
324
|
+
if ("type" === key || "name" === key || "fsPath" === key || "template" === key)
|
|
325
|
+
continue;
|
|
326
|
+
delete input[key];
|
|
327
|
+
}
|
|
328
|
+
}; const _po3 = (input: any): any => {
|
|
329
|
+
for (const key of Object.keys(input)) {
|
|
330
|
+
if ("type" === key)
|
|
331
|
+
continue;
|
|
332
|
+
delete input[key];
|
|
333
|
+
}
|
|
334
|
+
}; const _po4 = (input: any): any => {
|
|
335
|
+
for (const key of Object.keys(input)) {
|
|
336
|
+
if ("type" === key || "key" === key || "index" === key)
|
|
337
|
+
continue;
|
|
338
|
+
delete input[key];
|
|
339
|
+
}
|
|
340
|
+
}; const _pu0 = (input: any): any => (() => {
|
|
341
|
+
if ("milkio@ping" === input.type)
|
|
342
|
+
return _po0(input);
|
|
343
|
+
else if ("milkio@logger" === input.type)
|
|
344
|
+
return _po1(input);
|
|
345
|
+
else if ("milkio@template" === input.type)
|
|
346
|
+
return _po2(input);
|
|
347
|
+
else if ("workers@list" === input.type)
|
|
348
|
+
return _po3(input);
|
|
349
|
+
else if ("workers@get" === input.type)
|
|
350
|
+
return _po4(input);
|
|
351
|
+
else
|
|
352
|
+
__typia_transform__throwTypeGuardError._throwTypeGuardError({
|
|
353
|
+
method: "typia.misc.validatePrune",
|
|
354
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
355
|
+
value: input
|
|
356
|
+
});
|
|
357
|
+
})(); const __is = (input: any): input is CookbookActionParams => "object" === typeof input && null !== input && _iu0(input); let errors: any; let _report: any; const __validate = (input: any): import("typia").IValidation<CookbookActionParams> => {
|
|
236
358
|
if (false === __is(input)) {
|
|
237
359
|
errors = [];
|
|
238
|
-
|
|
239
|
-
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input ||
|
|
360
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
361
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
240
362
|
path: _path + "",
|
|
241
|
-
expected: "
|
|
363
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
242
364
|
value: input
|
|
243
|
-
})) &&
|
|
365
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
244
366
|
path: _path + "",
|
|
245
|
-
expected: "
|
|
367
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
246
368
|
value: input
|
|
247
369
|
}))(input, "$input", true);
|
|
248
370
|
const success = 0 === errors.length;
|
|
249
|
-
return {
|
|
371
|
+
return success ? {
|
|
372
|
+
success,
|
|
373
|
+
data: input
|
|
374
|
+
} : {
|
|
250
375
|
success,
|
|
251
376
|
errors,
|
|
252
|
-
data:
|
|
377
|
+
data: input
|
|
253
378
|
} as any;
|
|
254
379
|
}
|
|
255
380
|
return {
|
|
256
381
|
success: true,
|
|
257
|
-
errors: [],
|
|
258
382
|
data: input
|
|
259
383
|
} as any;
|
|
260
384
|
}; const __prune = (input: CookbookActionParams): void => {
|
|
261
385
|
if ("object" === typeof input && null !== input)
|
|
262
|
-
|
|
263
|
-
}; return (input: any): typia.IValidation<CookbookActionParams> => {
|
|
386
|
+
_pu0(input);
|
|
387
|
+
}; return (input: any): import("typia").IValidation<CookbookActionParams> => {
|
|
264
388
|
const result = __validate(input);
|
|
265
389
|
if (result.success)
|
|
266
390
|
__prune(input);
|
|
267
391
|
return result;
|
|
268
|
-
}; })()(
|
|
269
|
-
|
|
392
|
+
}; })()(resultsRaw);
|
|
393
|
+
const error = null;
|
|
270
394
|
if (!checkResult.success) {
|
|
271
395
|
const error: any = checkResult.errors.at(0)!;
|
|
272
396
|
error.message = `The "cookbook.toml" format is incorrect, [${error.path.slice(7)}] should be ${error.expected}, but it is actually ${error.value}. You may be missing some properties in the configuration item, or adding some properties that will not be used. If you have extra properties, these properties are likely due to a misspelling.`;
|
|
@@ -274,8 +398,8 @@ export const checkCookbookActionParams = async (results: any): Promise<[
|
|
|
274
398
|
results = null;
|
|
275
399
|
}
|
|
276
400
|
return [error, results];
|
|
277
|
-
}
|
|
278
|
-
export
|
|
401
|
+
}
|
|
402
|
+
export async function checkCookbookSubscribeEmits(results: any): Promise<[
|
|
279
403
|
Record<any, any> & {
|
|
280
404
|
message: string;
|
|
281
405
|
stack: string;
|
|
@@ -284,155 +408,158 @@ export const checkCookbookSubscribeEmits = async (results: any): Promise<[
|
|
|
284
408
|
] | [
|
|
285
409
|
null,
|
|
286
410
|
CookbookSubscribeEmits
|
|
287
|
-
]>
|
|
288
|
-
const typia = await import(
|
|
289
|
-
const checkResult = (() => { const
|
|
411
|
+
]> {
|
|
412
|
+
const typia = await import('typia');
|
|
413
|
+
const checkResult = (() => { const _io0 = (input: any): boolean => "workers@stdout" === input.type && "string" === typeof input.key && "string" === typeof input.chunk; const _io1 = (input: any): boolean => "workers@state" === input.type && "string" === typeof input.key && ("running" === input.state || "stopped" === input.state) && (null === input.code || "running" === input.code || "kill" === input.code || "number" === typeof input.code); const _io2 = (input: any): boolean => "watcher@change" === input.type && ("rename" === input.event || "change" === input.event) && "string" === typeof input.path; const _io3 = (input: any): boolean => "milkio@logger" === input.type && Array.isArray(input.log); const _iu0 = (input: any): any => (() => {
|
|
290
414
|
if ("workers@stdout" === input.type)
|
|
291
|
-
return
|
|
415
|
+
return _io0(input);
|
|
292
416
|
else if ("workers@state" === input.type)
|
|
293
|
-
return
|
|
417
|
+
return _io1(input);
|
|
294
418
|
else if ("watcher@change" === input.type)
|
|
295
|
-
return
|
|
419
|
+
return _io2(input);
|
|
296
420
|
else if ("milkio@logger" === input.type)
|
|
297
|
-
return
|
|
421
|
+
return _io3(input);
|
|
298
422
|
else
|
|
299
423
|
return false;
|
|
300
|
-
})(); const
|
|
424
|
+
})(); const _vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@stdout" === input.type || _report(_exceptionable, {
|
|
301
425
|
path: _path + ".type",
|
|
302
426
|
expected: "\"workers@stdout\"",
|
|
303
427
|
value: input.type
|
|
304
|
-
}), "string" === typeof input.key ||
|
|
428
|
+
}), "string" === typeof input.key || _report(_exceptionable, {
|
|
305
429
|
path: _path + ".key",
|
|
306
430
|
expected: "string",
|
|
307
431
|
value: input.key
|
|
308
|
-
}), "string" === typeof input.chunk ||
|
|
432
|
+
}), "string" === typeof input.chunk || _report(_exceptionable, {
|
|
309
433
|
path: _path + ".chunk",
|
|
310
434
|
expected: "string",
|
|
311
435
|
value: input.chunk
|
|
312
|
-
})].every((flag: boolean) => flag); const
|
|
436
|
+
})].every((flag: boolean) => flag); const _vo1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@state" === input.type || _report(_exceptionable, {
|
|
313
437
|
path: _path + ".type",
|
|
314
438
|
expected: "\"workers@state\"",
|
|
315
439
|
value: input.type
|
|
316
|
-
}), "string" === typeof input.key ||
|
|
440
|
+
}), "string" === typeof input.key || _report(_exceptionable, {
|
|
317
441
|
path: _path + ".key",
|
|
318
442
|
expected: "string",
|
|
319
443
|
value: input.key
|
|
320
|
-
}), "running" === input.state || "stopped" === input.state ||
|
|
444
|
+
}), "running" === input.state || "stopped" === input.state || _report(_exceptionable, {
|
|
321
445
|
path: _path + ".state",
|
|
322
446
|
expected: "(\"running\" | \"stopped\")",
|
|
323
447
|
value: input.state
|
|
324
|
-
}), null === input.code || "running" === input.code || "kill" === input.code || "number" === typeof input.code ||
|
|
448
|
+
}), null === input.code || "running" === input.code || "kill" === input.code || "number" === typeof input.code || _report(_exceptionable, {
|
|
325
449
|
path: _path + ".code",
|
|
326
450
|
expected: "(\"kill\" | \"running\" | null | number)",
|
|
327
451
|
value: input.code
|
|
328
|
-
})].every((flag: boolean) => flag); const
|
|
452
|
+
})].every((flag: boolean) => flag); const _vo2 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["watcher@change" === input.type || _report(_exceptionable, {
|
|
329
453
|
path: _path + ".type",
|
|
330
454
|
expected: "\"watcher@change\"",
|
|
331
455
|
value: input.type
|
|
332
|
-
}), "rename" === input.event || "change" === input.event ||
|
|
456
|
+
}), "rename" === input.event || "change" === input.event || _report(_exceptionable, {
|
|
333
457
|
path: _path + ".event",
|
|
334
458
|
expected: "(\"change\" | \"rename\")",
|
|
335
459
|
value: input.event
|
|
336
|
-
}), "string" === typeof input.path ||
|
|
460
|
+
}), "string" === typeof input.path || _report(_exceptionable, {
|
|
337
461
|
path: _path + ".path",
|
|
338
462
|
expected: "string",
|
|
339
463
|
value: input.path
|
|
340
|
-
})].every((flag: boolean) => flag); const
|
|
464
|
+
})].every((flag: boolean) => flag); const _vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@logger" === input.type || _report(_exceptionable, {
|
|
341
465
|
path: _path + ".type",
|
|
342
466
|
expected: "\"milkio@logger\"",
|
|
343
467
|
value: input.type
|
|
344
|
-
}), Array.isArray(input.log) ||
|
|
468
|
+
}), Array.isArray(input.log) || _report(_exceptionable, {
|
|
345
469
|
path: _path + ".log",
|
|
346
470
|
expected: "Array<any>",
|
|
347
471
|
value: input.log
|
|
348
|
-
})].every((flag: boolean) => flag); const
|
|
472
|
+
})].every((flag: boolean) => flag); const _vu0 = (input: any, _path: string, _exceptionable: boolean = true): any => (() => {
|
|
349
473
|
if ("workers@stdout" === input.type)
|
|
350
|
-
return
|
|
474
|
+
return _vo0(input, _path, true && _exceptionable);
|
|
351
475
|
else if ("workers@state" === input.type)
|
|
352
|
-
return
|
|
476
|
+
return _vo1(input, _path, true && _exceptionable);
|
|
353
477
|
else if ("watcher@change" === input.type)
|
|
354
|
-
return
|
|
478
|
+
return _vo2(input, _path, true && _exceptionable);
|
|
355
479
|
else if ("milkio@logger" === input.type)
|
|
356
|
-
return
|
|
480
|
+
return _vo3(input, _path, true && _exceptionable);
|
|
357
481
|
else
|
|
358
|
-
return
|
|
482
|
+
return _report(_exceptionable, {
|
|
359
483
|
path: _path,
|
|
360
484
|
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
361
485
|
value: input
|
|
362
486
|
});
|
|
363
|
-
})(); const
|
|
487
|
+
})(); const _po0 = (input: any): any => {
|
|
364
488
|
for (const key of Object.keys(input)) {
|
|
365
489
|
if ("type" === key || "key" === key || "chunk" === key)
|
|
366
490
|
continue;
|
|
367
491
|
delete input[key];
|
|
368
492
|
}
|
|
369
|
-
}; const
|
|
493
|
+
}; const _po1 = (input: any): any => {
|
|
370
494
|
for (const key of Object.keys(input)) {
|
|
371
495
|
if ("type" === key || "key" === key || "state" === key || "code" === key)
|
|
372
496
|
continue;
|
|
373
497
|
delete input[key];
|
|
374
498
|
}
|
|
375
|
-
}; const
|
|
499
|
+
}; const _po2 = (input: any): any => {
|
|
376
500
|
for (const key of Object.keys(input)) {
|
|
377
501
|
if ("type" === key || "event" === key || "path" === key)
|
|
378
502
|
continue;
|
|
379
503
|
delete input[key];
|
|
380
504
|
}
|
|
381
|
-
}; const
|
|
505
|
+
}; const _po3 = (input: any): any => {
|
|
382
506
|
for (const key of Object.keys(input)) {
|
|
383
507
|
if ("type" === key || "log" === key)
|
|
384
508
|
continue;
|
|
385
509
|
delete input[key];
|
|
386
510
|
}
|
|
387
|
-
}; const
|
|
511
|
+
}; const _pu0 = (input: any): any => (() => {
|
|
388
512
|
if ("workers@stdout" === input.type)
|
|
389
|
-
return
|
|
513
|
+
return _po0(input);
|
|
390
514
|
else if ("workers@state" === input.type)
|
|
391
|
-
return
|
|
515
|
+
return _po1(input);
|
|
392
516
|
else if ("watcher@change" === input.type)
|
|
393
|
-
return
|
|
517
|
+
return _po2(input);
|
|
394
518
|
else if ("milkio@logger" === input.type)
|
|
395
|
-
return
|
|
519
|
+
return _po3(input);
|
|
396
520
|
else
|
|
397
|
-
|
|
521
|
+
__typia_transform__throwTypeGuardError._throwTypeGuardError({
|
|
522
|
+
method: "typia.misc.validatePrune",
|
|
398
523
|
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
399
524
|
value: input
|
|
400
525
|
});
|
|
401
|
-
})(); const __is = (input: any): input is CookbookSubscribeEmits => "object" === typeof input && null !== input &&
|
|
526
|
+
})(); const __is = (input: any): input is CookbookSubscribeEmits => "object" === typeof input && null !== input && _iu0(input); let errors: any; let _report: any; const __validate = (input: any): import("typia").IValidation<CookbookSubscribeEmits> => {
|
|
402
527
|
if (false === __is(input)) {
|
|
403
528
|
errors = [];
|
|
404
|
-
|
|
405
|
-
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input ||
|
|
529
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
530
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
406
531
|
path: _path + "",
|
|
407
532
|
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
408
533
|
value: input
|
|
409
|
-
})) &&
|
|
534
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
410
535
|
path: _path + "",
|
|
411
536
|
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
412
537
|
value: input
|
|
413
538
|
}))(input, "$input", true);
|
|
414
539
|
const success = 0 === errors.length;
|
|
415
|
-
return {
|
|
540
|
+
return success ? {
|
|
541
|
+
success,
|
|
542
|
+
data: input
|
|
543
|
+
} : {
|
|
416
544
|
success,
|
|
417
545
|
errors,
|
|
418
|
-
data:
|
|
546
|
+
data: input
|
|
419
547
|
} as any;
|
|
420
548
|
}
|
|
421
549
|
return {
|
|
422
550
|
success: true,
|
|
423
|
-
errors: [],
|
|
424
551
|
data: input
|
|
425
552
|
} as any;
|
|
426
553
|
}; const __prune = (input: CookbookSubscribeEmits): void => {
|
|
427
554
|
if ("object" === typeof input && null !== input)
|
|
428
|
-
|
|
429
|
-
}; return (input: any): typia.IValidation<CookbookSubscribeEmits> => {
|
|
555
|
+
_pu0(input);
|
|
556
|
+
}; return (input: any): import("typia").IValidation<CookbookSubscribeEmits> => {
|
|
430
557
|
const result = __validate(input);
|
|
431
558
|
if (result.success)
|
|
432
559
|
__prune(input);
|
|
433
560
|
return result;
|
|
434
561
|
}; })()(results);
|
|
435
|
-
|
|
562
|
+
const error = null;
|
|
436
563
|
if (!checkResult.success) {
|
|
437
564
|
const error: any = checkResult.errors.at(0)!;
|
|
438
565
|
error.message = `The "cookbook.toml" format is incorrect, [${error.path.slice(7)}] should be ${error.expected}, but it is actually ${error.value}. You may be missing some properties in the configuration item, or adding some properties that will not be used. If you have extra properties, these properties are likely due to a misspelling.`;
|
|
@@ -440,4 +567,4 @@ export const checkCookbookSubscribeEmits = async (results: any): Promise<[
|
|
|
440
567
|
results = null;
|
|
441
568
|
}
|
|
442
569
|
return [error, results];
|
|
443
|
-
}
|
|
570
|
+
}
|
|
@@ -1,41 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The content of this file is automatically generated by Typia.
|
|
3
|
-
* It can be edited in the /packages/cookbook-dto/src/* file, and each time you run bun run dev, the generated file will be synced to another location based on the content of the /develop.ts.
|
|
4
|
-
*/
|
|
2
|
+
* The content of this file is automatically generated by Typia.
|
|
3
|
+
* It can be edited in the /packages/cookbook-dto/src/* file, and each time you run bun run dev, the generated file will be synced to another location based on the content of the /develop.ts.
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface CookbookOptions {
|
|
7
7
|
projects: Record<string, {
|
|
8
|
-
type:
|
|
8
|
+
type: 'milkio' | 'custom';
|
|
9
9
|
port: number;
|
|
10
10
|
start: Array<string>;
|
|
11
11
|
build: Array<string>;
|
|
12
|
+
watch?: boolean;
|
|
12
13
|
lazyRoutes?: boolean;
|
|
13
|
-
typiaMode?:
|
|
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
|
-
type:
|
|
24
|
+
type: 'milkio@ping';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'milkio@logger';
|
|
23
27
|
log: Array<any>;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'milkio@template';
|
|
30
|
+
name: string;
|
|
31
|
+
fsPath: string;
|
|
32
|
+
template: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'workers@list';
|
|
35
|
+
} | {
|
|
36
|
+
type: 'workers@get';
|
|
37
|
+
key: string;
|
|
38
|
+
index: number;
|
|
24
39
|
};
|
|
25
40
|
export type CookbookSubscribeEmits = {
|
|
26
|
-
type:
|
|
41
|
+
type: 'workers@stdout';
|
|
27
42
|
key: string;
|
|
28
43
|
chunk: string;
|
|
29
44
|
} | {
|
|
30
|
-
type:
|
|
45
|
+
type: 'workers@state';
|
|
31
46
|
key: string;
|
|
32
|
-
state:
|
|
33
|
-
code: number | null |
|
|
47
|
+
state: 'running' | 'stopped';
|
|
48
|
+
code: number | null | 'kill' | 'running';
|
|
34
49
|
} | {
|
|
35
|
-
type:
|
|
36
|
-
event:
|
|
50
|
+
type: 'watcher@change';
|
|
51
|
+
event: 'rename' | 'change';
|
|
37
52
|
path: string;
|
|
38
53
|
} | {
|
|
39
|
-
type:
|
|
54
|
+
type: 'milkio@logger';
|
|
40
55
|
log: Array<any>;
|
|
41
56
|
};
|