@milkio/astra 1.0.0-alpha.0 → 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/README.md +1 -1
- package/index.ts +94 -38
- package/package.json +6 -9
- package/tsconfig.json +9 -8
- package/utils/cookbook-dto-checks.ts +570 -0
- package/utils/cookbook-dto-types.ts +56 -0
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import { join, dirname } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
3
|
import { existsSync } from "node:fs";
|
|
5
4
|
import { readFile } from "node:fs/promises";
|
|
6
5
|
import { cwd } from "node:process";
|
|
7
6
|
import { load } from "js-toml";
|
|
8
|
-
import typia from "typia";
|
|
9
7
|
import { TSON } from "@southern-aurora/tson";
|
|
8
|
+
import { format } from "date-fns";
|
|
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
|
|
|
16
|
-
|
|
16
|
+
type GeneratorGeneric<T> = T extends AsyncGenerator<infer I> ? I : never;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type Mixin<T, U> = U & Omit<T, keyof U>;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
type ExecuteOptions = {
|
|
21
21
|
headers?: Record<string, string>;
|
|
22
22
|
timeout?: number;
|
|
23
23
|
type?: "action" | "stream";
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
type ExecuteResultsOption = { executeId: string };
|
|
27
|
+
|
|
28
|
+
type Context = {
|
|
29
|
+
logger: Logger;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type Logger = {
|
|
33
|
+
debug: (description: string, ...params: Array<unknown>) => Log;
|
|
34
|
+
info: (description: string, ...params: Array<unknown>) => Log;
|
|
35
|
+
warn: (description: string, ...params: Array<unknown>) => Log;
|
|
36
|
+
error: (description: string, ...params: Array<unknown>) => Log;
|
|
37
|
+
response: (description: string, ...params: Array<unknown>) => Log;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type Log = [string /* executeId */, "[DEBUG]" | "[INFO]" | "[WARN]" | "[ERROR]" | "[RESPONSE]", string, string, ...Array<unknown>];
|
|
27
41
|
|
|
28
|
-
|
|
42
|
+
type Reject = (description: string, ...params: Array<unknown>) => Error;
|
|
29
43
|
|
|
30
|
-
export
|
|
31
|
-
let cookbookOptions: any = undefined;
|
|
44
|
+
export async function createAstra<AstraOptions extends AstraOptionsInit, Generated extends AstraOptions["stargate"]["$types"]["generated"]>(astraOptions: AstraOptions) {
|
|
32
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.`);
|
|
33
|
-
cookbookOptions = load((await readFile(join(cwd(), "cookbook.toml"))).toString());
|
|
46
|
+
const cookbookOptions = load((await readFile(join(cwd(), "cookbook.toml"))).toString()) as CookbookOptions;
|
|
34
47
|
// wait for all milkio projects to start and can be accessed
|
|
35
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
|
|
36
49
|
await Promise.all([
|
|
@@ -40,7 +53,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
40
53
|
const project = cookbookOptions.projects[projectName];
|
|
41
54
|
if (project.type !== "milkio") continue;
|
|
42
55
|
projectStatus.set(projectName, withResolvers());
|
|
43
|
-
let counter =
|
|
56
|
+
let counter = 65;
|
|
44
57
|
let timer: Timer | null = setInterval(async () => {
|
|
45
58
|
if (--counter <= 0) {
|
|
46
59
|
clearInterval(timer!);
|
|
@@ -50,6 +63,7 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
50
63
|
return;
|
|
51
64
|
}
|
|
52
65
|
try {
|
|
66
|
+
console.log("\n[ASTRA]", `connecting.. ${counter >= 64 ? "" : `(${counter})`}`);
|
|
53
67
|
const response = await fetchWithTimeout(`http://localhost:${project.port}/generate_204`, { method: "HEAD", timeout: 1024 });
|
|
54
68
|
if (response.status === 204) {
|
|
55
69
|
if (timer) clearTimeout(timer);
|
|
@@ -57,30 +71,30 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
57
71
|
return projectStatus.get(projectName)!.resolve(undefined);
|
|
58
72
|
}
|
|
59
73
|
} catch (error) {}
|
|
60
|
-
},
|
|
74
|
+
}, 100);
|
|
61
75
|
}
|
|
62
76
|
return Array.from(projectStatus.values()).map((v) => v.promise);
|
|
63
77
|
})(),
|
|
64
78
|
]);
|
|
65
79
|
|
|
66
|
-
type Execute = <Path extends keyof Generated["routeSchema"]
|
|
80
|
+
type Execute = <Path extends keyof Generated["routeSchema"]>(
|
|
67
81
|
path: Path,
|
|
68
82
|
options?: Mixin<
|
|
69
83
|
ExecuteOptions,
|
|
70
84
|
| {
|
|
71
|
-
params?: Generated["routeSchema"]["
|
|
85
|
+
params?: Generated["routeSchema"][Path]["types"]["params"];
|
|
72
86
|
}
|
|
73
87
|
| {
|
|
74
|
-
params?: Partial<Generated["routeSchema"]["
|
|
88
|
+
params?: Partial<Generated["routeSchema"][Path]["types"]["params"]>;
|
|
75
89
|
generateParams: true;
|
|
76
90
|
}
|
|
77
91
|
>,
|
|
78
92
|
) => Promise<
|
|
79
|
-
Generated["routeSchema"]["
|
|
93
|
+
Generated["routeSchema"][Path]["types"]["🐣"] extends boolean
|
|
80
94
|
? // action
|
|
81
|
-
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["routeSchema"]["
|
|
95
|
+
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["routeSchema"][Path]["types"]["result"], ExecuteResultsOption]
|
|
82
96
|
: // stream
|
|
83
|
-
[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>]
|
|
84
98
|
>;
|
|
85
99
|
|
|
86
100
|
type MirrorWorld = Mixin<
|
|
@@ -93,11 +107,11 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
93
107
|
|
|
94
108
|
return {
|
|
95
109
|
options: astraOptions,
|
|
96
|
-
async createMirrorWorld(importMetaUrl: string): Promise<[
|
|
110
|
+
async createMirrorWorld(importMetaUrl: string): Promise<[Context, Reject, MirrorWorld]> {
|
|
97
111
|
const thisFilePath = join(fileURLToPath(importMetaUrl));
|
|
98
112
|
const thisFileDirPath = join(dirname(thisFilePath)).replaceAll("\\", "/");
|
|
99
113
|
const thisFileDirPathArr = thisFileDirPath.split("/");
|
|
100
|
-
let projectName
|
|
114
|
+
let projectName = "";
|
|
101
115
|
|
|
102
116
|
await (async () => {
|
|
103
117
|
let isProjectsDirectory = false;
|
|
@@ -124,35 +138,71 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
124
138
|
const paths = {
|
|
125
139
|
cwd: join(cwd(), "projects", projectName),
|
|
126
140
|
milkio: join(cwd(), "projects", projectName, ".milkio"),
|
|
127
|
-
generated: join(cwd(), "projects", projectName, ".milkio"
|
|
141
|
+
generated: join(cwd(), "projects", projectName, ".milkio"),
|
|
128
142
|
};
|
|
129
143
|
|
|
130
144
|
const execute = async (path: Parameters<MirrorWorld["execute"]>[0], optionsInit?: Parameters<MirrorWorld["execute"]>[1]) => {
|
|
131
|
-
|
|
145
|
+
const options = (optionsInit as any) ?? {};
|
|
132
146
|
if (options?.generateParams === true) {
|
|
133
147
|
if (!options?.params) options.params = {};
|
|
134
148
|
options.params.$milkioGenerateParams = "enable";
|
|
135
149
|
}
|
|
136
150
|
|
|
137
|
-
const results = await this.options.stargate.
|
|
138
|
-
console.log("[MILKIO]", "--- server logs start ---");
|
|
151
|
+
const results = await this.options.stargate.__cookbook.subscribe(`http://localhost:${cookbookOptions.general.cookbookPort}`);
|
|
139
152
|
void (async () => {
|
|
140
153
|
for await (const result of results) {
|
|
141
154
|
if (result.type !== "milkio@logger") continue;
|
|
142
|
-
console.log("[MILKIO]", ...(result.log ?? []));
|
|
155
|
+
console.log("\n[MILKIO]", ...(result.log ?? []));
|
|
143
156
|
}
|
|
144
157
|
})();
|
|
145
158
|
|
|
146
159
|
const response = await this.options.stargate.execute(path, options);
|
|
147
160
|
|
|
148
161
|
await new Promise((resolve) => setTimeout(resolve, 40));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
console.log("[MILKIO]", "--- server logs end ---");
|
|
162
|
+
context.logger.response(path as string, `\nerror - ${TSON.stringify(response[0])}`, `\nresult - ${typeof response[1]?.next === "function" ? "AsyncGenerator" : TSON.stringify(response[1])}`);
|
|
152
163
|
|
|
153
164
|
return response;
|
|
154
165
|
};
|
|
155
166
|
|
|
167
|
+
const getNow = () => format(new Date(), "(yyyy-MM-dd hh:mm:ss)");
|
|
168
|
+
const onLoggerInserting = (log: Log) => {
|
|
169
|
+
// biome-ignore lint/style/noParameterAssign: <explanation>
|
|
170
|
+
log = [...log];
|
|
171
|
+
log[0] = `\n${log[0]}` as any;
|
|
172
|
+
console.log(...log);
|
|
173
|
+
return true;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const context = {
|
|
177
|
+
logger: {
|
|
178
|
+
debug: (description: string, ...params: Array<unknown>): Log => {
|
|
179
|
+
const log: Log = ["[TEST]", "[DEBUG]", description, getNow(), ...params];
|
|
180
|
+
onLoggerInserting(log);
|
|
181
|
+
return log;
|
|
182
|
+
},
|
|
183
|
+
info: (description: string, ...params: Array<unknown>): Log => {
|
|
184
|
+
const log: Log = ["[TEST]", "[INFO]", description, getNow(), ...params];
|
|
185
|
+
onLoggerInserting(log);
|
|
186
|
+
return log;
|
|
187
|
+
},
|
|
188
|
+
warn: (description: string, ...params: Array<unknown>): Log => {
|
|
189
|
+
const log: Log = ["[TEST]", "[WARN]", description, getNow(), ...params];
|
|
190
|
+
onLoggerInserting(log);
|
|
191
|
+
return log;
|
|
192
|
+
},
|
|
193
|
+
error: (description: string, ...params: Array<unknown>): Log => {
|
|
194
|
+
const log: Log = ["[TEST]", "[ERROR]", description, getNow(), ...params];
|
|
195
|
+
onLoggerInserting(log);
|
|
196
|
+
return log;
|
|
197
|
+
},
|
|
198
|
+
response: (path: string, ...params: Array<unknown>): Log => {
|
|
199
|
+
const log: Log = ["[TEST]", "[RESPONSE]", path, getNow(), ...params];
|
|
200
|
+
onLoggerInserting(log);
|
|
201
|
+
return log;
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
} as Context;
|
|
205
|
+
|
|
156
206
|
const world = {
|
|
157
207
|
...(await astraOptions.bootstrap()),
|
|
158
208
|
paths,
|
|
@@ -160,25 +210,31 @@ export const createAstra = async <AstraOptions extends AstraOptionsInit, Generat
|
|
|
160
210
|
} as any;
|
|
161
211
|
|
|
162
212
|
const reject = (...params: Array<unknown>): Error => {
|
|
163
|
-
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
|
+
];
|
|
164
224
|
console.log(...output);
|
|
165
225
|
for (let index = 1; index < output.length; index++) {
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
output[index] = output[index].toString();
|
|
169
|
-
} else {
|
|
170
|
-
output[index] = TSON.stringify(output[index]);
|
|
171
|
-
}
|
|
226
|
+
if (typeof output[index] === "object") {
|
|
227
|
+
output[index] = output[index].toString();
|
|
172
228
|
}
|
|
173
229
|
}
|
|
174
230
|
const message = output.join(" ");
|
|
175
231
|
return new Error(message);
|
|
176
232
|
};
|
|
177
233
|
|
|
178
|
-
return [
|
|
234
|
+
return [context, reject, world];
|
|
179
235
|
},
|
|
180
236
|
};
|
|
181
|
-
}
|
|
237
|
+
}
|
|
182
238
|
|
|
183
239
|
export async function fetchWithTimeout(url: string, options: FetchRequestInit & { timeout?: number } = {}) {
|
|
184
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.0",
|
|
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
|
}
|
|
@@ -0,0 +1,570 @@
|
|
|
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
|
+
*/
|
|
5
|
+
|
|
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<[
|
|
12
|
+
Record<any, any> & {
|
|
13
|
+
message: string;
|
|
14
|
+
stack: string;
|
|
15
|
+
},
|
|
16
|
+
null
|
|
17
|
+
] | [
|
|
18
|
+
null,
|
|
19
|
+
CookbookOptions
|
|
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) => {
|
|
23
|
+
if (["projects", "general"].some((prop: any) => key === prop))
|
|
24
|
+
return true;
|
|
25
|
+
const value = input[key];
|
|
26
|
+
if (undefined === value)
|
|
27
|
+
return true;
|
|
28
|
+
return false;
|
|
29
|
+
})); const _io1 = (input: any, _exceptionable: boolean = true): boolean => Object.keys(input).every((key: any) => {
|
|
30
|
+
const value = input[key];
|
|
31
|
+
if (undefined === value)
|
|
32
|
+
return true;
|
|
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))
|
|
36
|
+
return true;
|
|
37
|
+
const value = input[key];
|
|
38
|
+
if (undefined === value)
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
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))
|
|
43
|
+
return true;
|
|
44
|
+
const value = input[key];
|
|
45
|
+
if (undefined === value)
|
|
46
|
+
return true;
|
|
47
|
+
return false;
|
|
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, {
|
|
49
|
+
path: _path + ".projects",
|
|
50
|
+
expected: "Record<string, __type>",
|
|
51
|
+
value: input.projects
|
|
52
|
+
})) && _vo1(input.projects, _path + ".projects", true && _exceptionable) || _report(_exceptionable, {
|
|
53
|
+
path: _path + ".projects",
|
|
54
|
+
expected: "Record<string, __type>",
|
|
55
|
+
value: input.projects
|
|
56
|
+
}), ("object" === typeof input.general && null !== input.general || _report(_exceptionable, {
|
|
57
|
+
path: _path + ".general",
|
|
58
|
+
expected: "__type.o1",
|
|
59
|
+
value: input.general
|
|
60
|
+
})) && _vo3(input.general, _path + ".general", true && _exceptionable) || _report(_exceptionable, {
|
|
61
|
+
path: _path + ".general",
|
|
62
|
+
expected: "__type.o1",
|
|
63
|
+
value: input.general
|
|
64
|
+
}), 2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
65
|
+
if (["projects", "general"].some((prop: any) => key === prop))
|
|
66
|
+
return true;
|
|
67
|
+
const value = input[key];
|
|
68
|
+
if (undefined === value)
|
|
69
|
+
return true;
|
|
70
|
+
return _report(_exceptionable, {
|
|
71
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
72
|
+
expected: "undefined",
|
|
73
|
+
value: value
|
|
74
|
+
});
|
|
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) => {
|
|
76
|
+
const value = input[key];
|
|
77
|
+
if (undefined === value)
|
|
78
|
+
return true;
|
|
79
|
+
return ("object" === typeof value && null !== value || _report(_exceptionable, {
|
|
80
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
81
|
+
expected: "__type",
|
|
82
|
+
value: value
|
|
83
|
+
})) && _vo2(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || _report(_exceptionable, {
|
|
84
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
85
|
+
expected: "__type",
|
|
86
|
+
value: value
|
|
87
|
+
});
|
|
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, {
|
|
89
|
+
path: _path + ".type",
|
|
90
|
+
expected: "(\"milkio\" | \"custom\")",
|
|
91
|
+
value: input.type
|
|
92
|
+
}), "number" === typeof input.port || _report(_exceptionable, {
|
|
93
|
+
path: _path + ".port",
|
|
94
|
+
expected: "number",
|
|
95
|
+
value: input.port
|
|
96
|
+
}), (Array.isArray(input.start) || _report(_exceptionable, {
|
|
97
|
+
path: _path + ".start",
|
|
98
|
+
expected: "Array<string>",
|
|
99
|
+
value: input.start
|
|
100
|
+
})) && input.start.map((elem: any, _index5: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
101
|
+
path: _path + ".start[" + _index5 + "]",
|
|
102
|
+
expected: "string",
|
|
103
|
+
value: elem
|
|
104
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
105
|
+
path: _path + ".start",
|
|
106
|
+
expected: "Array<string>",
|
|
107
|
+
value: input.start
|
|
108
|
+
}), (Array.isArray(input.build) || _report(_exceptionable, {
|
|
109
|
+
path: _path + ".build",
|
|
110
|
+
expected: "Array<string>",
|
|
111
|
+
value: input.build
|
|
112
|
+
})) && input.build.map((elem: any, _index6: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
113
|
+
path: _path + ".build[" + _index6 + "]",
|
|
114
|
+
expected: "string",
|
|
115
|
+
value: elem
|
|
116
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
117
|
+
path: _path + ".build",
|
|
118
|
+
expected: "Array<string>",
|
|
119
|
+
value: input.build
|
|
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, {
|
|
125
|
+
path: _path + ".lazyRoutes",
|
|
126
|
+
expected: "(boolean | undefined)",
|
|
127
|
+
value: input.lazyRoutes
|
|
128
|
+
}), undefined === input.typiaMode || "generation" === input.typiaMode || "bundler" === input.typiaMode || _report(_exceptionable, {
|
|
129
|
+
path: _path + ".typiaMode",
|
|
130
|
+
expected: "(\"bundler\" | \"generation\" | undefined)",
|
|
131
|
+
value: input.typiaMode
|
|
132
|
+
}), undefined === input.significant || (Array.isArray(input.significant) || _report(_exceptionable, {
|
|
133
|
+
path: _path + ".significant",
|
|
134
|
+
expected: "(Array<string> | undefined)",
|
|
135
|
+
value: input.significant
|
|
136
|
+
})) && input.significant.map((elem: any, _index7: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
137
|
+
path: _path + ".significant[" + _index7 + "]",
|
|
138
|
+
expected: "string",
|
|
139
|
+
value: elem
|
|
140
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
141
|
+
path: _path + ".significant",
|
|
142
|
+
expected: "(Array<string> | undefined)",
|
|
143
|
+
value: input.significant
|
|
144
|
+
}), undefined === input.insignificant || (Array.isArray(input.insignificant) || _report(_exceptionable, {
|
|
145
|
+
path: _path + ".insignificant",
|
|
146
|
+
expected: "(Array<string> | undefined)",
|
|
147
|
+
value: input.insignificant
|
|
148
|
+
})) && input.insignificant.map((elem: any, _index8: number) => "string" === typeof elem || _report(_exceptionable, {
|
|
149
|
+
path: _path + ".insignificant[" + _index8 + "]",
|
|
150
|
+
expected: "string",
|
|
151
|
+
value: elem
|
|
152
|
+
})).every((flag: boolean) => flag) || _report(_exceptionable, {
|
|
153
|
+
path: _path + ".insignificant",
|
|
154
|
+
expected: "(Array<string> | undefined)",
|
|
155
|
+
value: input.insignificant
|
|
156
|
+
}), 4 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
157
|
+
if (["type", "port", "start", "build", "watch", "lazyRoutes", "typiaMode", "significant", "insignificant"].some((prop: any) => key === prop))
|
|
158
|
+
return true;
|
|
159
|
+
const value = input[key];
|
|
160
|
+
if (undefined === value)
|
|
161
|
+
return true;
|
|
162
|
+
return _report(_exceptionable, {
|
|
163
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
164
|
+
expected: "undefined",
|
|
165
|
+
value: value
|
|
166
|
+
});
|
|
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, {
|
|
172
|
+
path: _path + ".cookbookPort",
|
|
173
|
+
expected: "number",
|
|
174
|
+
value: input.cookbookPort
|
|
175
|
+
}), 2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map((key: any) => {
|
|
176
|
+
if (["start", "cookbookPort"].some((prop: any) => key === prop))
|
|
177
|
+
return true;
|
|
178
|
+
const value = input[key];
|
|
179
|
+
if (undefined === value)
|
|
180
|
+
return true;
|
|
181
|
+
return _report(_exceptionable, {
|
|
182
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
183
|
+
expected: "undefined",
|
|
184
|
+
value: value
|
|
185
|
+
});
|
|
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> => {
|
|
187
|
+
if (false === __is(input)) {
|
|
188
|
+
errors = [];
|
|
189
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
190
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
191
|
+
path: _path + "",
|
|
192
|
+
expected: "CookbookOptions",
|
|
193
|
+
value: input
|
|
194
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
195
|
+
path: _path + "",
|
|
196
|
+
expected: "CookbookOptions",
|
|
197
|
+
value: input
|
|
198
|
+
}))(input, "$input", true);
|
|
199
|
+
const success = 0 === errors.length;
|
|
200
|
+
return success ? {
|
|
201
|
+
success,
|
|
202
|
+
data: input
|
|
203
|
+
} : {
|
|
204
|
+
success,
|
|
205
|
+
errors,
|
|
206
|
+
data: input
|
|
207
|
+
} as any;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
data: input
|
|
212
|
+
} as any;
|
|
213
|
+
}; })()(cookbookTomlParsed);
|
|
214
|
+
const error = null;
|
|
215
|
+
if (!checkResult.success) {
|
|
216
|
+
const error: any = checkResult.errors.at(0)!;
|
|
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.`;
|
|
218
|
+
Error.captureStackTrace(error);
|
|
219
|
+
cookbookTomlParsed = null;
|
|
220
|
+
}
|
|
221
|
+
return [error, cookbookToml];
|
|
222
|
+
}
|
|
223
|
+
export async function checkCookbookActionParams(resultsRaw: any): Promise<[
|
|
224
|
+
Record<any, any> & {
|
|
225
|
+
message: string;
|
|
226
|
+
stack: string;
|
|
227
|
+
},
|
|
228
|
+
null
|
|
229
|
+
] | [
|
|
230
|
+
null,
|
|
231
|
+
CookbookActionParams
|
|
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, {
|
|
254
|
+
path: _path + ".type",
|
|
255
|
+
expected: "\"milkio@logger\"",
|
|
256
|
+
value: input.type
|
|
257
|
+
}), Array.isArray(input.log) || _report(_exceptionable, {
|
|
258
|
+
path: _path + ".log",
|
|
259
|
+
expected: "Array<any>",
|
|
260
|
+
value: input.log
|
|
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 => {
|
|
317
|
+
for (const key of Object.keys(input)) {
|
|
318
|
+
if ("type" === key || "log" === key)
|
|
319
|
+
continue;
|
|
320
|
+
delete input[key];
|
|
321
|
+
}
|
|
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> => {
|
|
358
|
+
if (false === __is(input)) {
|
|
359
|
+
errors = [];
|
|
360
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
361
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
362
|
+
path: _path + "",
|
|
363
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
364
|
+
value: input
|
|
365
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
366
|
+
path: _path + "",
|
|
367
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3 | __type.o4)",
|
|
368
|
+
value: input
|
|
369
|
+
}))(input, "$input", true);
|
|
370
|
+
const success = 0 === errors.length;
|
|
371
|
+
return success ? {
|
|
372
|
+
success,
|
|
373
|
+
data: input
|
|
374
|
+
} : {
|
|
375
|
+
success,
|
|
376
|
+
errors,
|
|
377
|
+
data: input
|
|
378
|
+
} as any;
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
success: true,
|
|
382
|
+
data: input
|
|
383
|
+
} as any;
|
|
384
|
+
}; const __prune = (input: CookbookActionParams): void => {
|
|
385
|
+
if ("object" === typeof input && null !== input)
|
|
386
|
+
_pu0(input);
|
|
387
|
+
}; return (input: any): import("typia").IValidation<CookbookActionParams> => {
|
|
388
|
+
const result = __validate(input);
|
|
389
|
+
if (result.success)
|
|
390
|
+
__prune(input);
|
|
391
|
+
return result;
|
|
392
|
+
}; })()(resultsRaw);
|
|
393
|
+
const error = null;
|
|
394
|
+
if (!checkResult.success) {
|
|
395
|
+
const error: any = checkResult.errors.at(0)!;
|
|
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.`;
|
|
397
|
+
Error.captureStackTrace(error);
|
|
398
|
+
results = null;
|
|
399
|
+
}
|
|
400
|
+
return [error, results];
|
|
401
|
+
}
|
|
402
|
+
export async function checkCookbookSubscribeEmits(results: any): Promise<[
|
|
403
|
+
Record<any, any> & {
|
|
404
|
+
message: string;
|
|
405
|
+
stack: string;
|
|
406
|
+
},
|
|
407
|
+
null
|
|
408
|
+
] | [
|
|
409
|
+
null,
|
|
410
|
+
CookbookSubscribeEmits
|
|
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 => (() => {
|
|
414
|
+
if ("workers@stdout" === input.type)
|
|
415
|
+
return _io0(input);
|
|
416
|
+
else if ("workers@state" === input.type)
|
|
417
|
+
return _io1(input);
|
|
418
|
+
else if ("watcher@change" === input.type)
|
|
419
|
+
return _io2(input);
|
|
420
|
+
else if ("milkio@logger" === input.type)
|
|
421
|
+
return _io3(input);
|
|
422
|
+
else
|
|
423
|
+
return false;
|
|
424
|
+
})(); const _vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@stdout" === input.type || _report(_exceptionable, {
|
|
425
|
+
path: _path + ".type",
|
|
426
|
+
expected: "\"workers@stdout\"",
|
|
427
|
+
value: input.type
|
|
428
|
+
}), "string" === typeof input.key || _report(_exceptionable, {
|
|
429
|
+
path: _path + ".key",
|
|
430
|
+
expected: "string",
|
|
431
|
+
value: input.key
|
|
432
|
+
}), "string" === typeof input.chunk || _report(_exceptionable, {
|
|
433
|
+
path: _path + ".chunk",
|
|
434
|
+
expected: "string",
|
|
435
|
+
value: input.chunk
|
|
436
|
+
})].every((flag: boolean) => flag); const _vo1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["workers@state" === input.type || _report(_exceptionable, {
|
|
437
|
+
path: _path + ".type",
|
|
438
|
+
expected: "\"workers@state\"",
|
|
439
|
+
value: input.type
|
|
440
|
+
}), "string" === typeof input.key || _report(_exceptionable, {
|
|
441
|
+
path: _path + ".key",
|
|
442
|
+
expected: "string",
|
|
443
|
+
value: input.key
|
|
444
|
+
}), "running" === input.state || "stopped" === input.state || _report(_exceptionable, {
|
|
445
|
+
path: _path + ".state",
|
|
446
|
+
expected: "(\"running\" | \"stopped\")",
|
|
447
|
+
value: input.state
|
|
448
|
+
}), null === input.code || "running" === input.code || "kill" === input.code || "number" === typeof input.code || _report(_exceptionable, {
|
|
449
|
+
path: _path + ".code",
|
|
450
|
+
expected: "(\"kill\" | \"running\" | null | number)",
|
|
451
|
+
value: input.code
|
|
452
|
+
})].every((flag: boolean) => flag); const _vo2 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["watcher@change" === input.type || _report(_exceptionable, {
|
|
453
|
+
path: _path + ".type",
|
|
454
|
+
expected: "\"watcher@change\"",
|
|
455
|
+
value: input.type
|
|
456
|
+
}), "rename" === input.event || "change" === input.event || _report(_exceptionable, {
|
|
457
|
+
path: _path + ".event",
|
|
458
|
+
expected: "(\"change\" | \"rename\")",
|
|
459
|
+
value: input.event
|
|
460
|
+
}), "string" === typeof input.path || _report(_exceptionable, {
|
|
461
|
+
path: _path + ".path",
|
|
462
|
+
expected: "string",
|
|
463
|
+
value: input.path
|
|
464
|
+
})].every((flag: boolean) => flag); const _vo3 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["milkio@logger" === input.type || _report(_exceptionable, {
|
|
465
|
+
path: _path + ".type",
|
|
466
|
+
expected: "\"milkio@logger\"",
|
|
467
|
+
value: input.type
|
|
468
|
+
}), Array.isArray(input.log) || _report(_exceptionable, {
|
|
469
|
+
path: _path + ".log",
|
|
470
|
+
expected: "Array<any>",
|
|
471
|
+
value: input.log
|
|
472
|
+
})].every((flag: boolean) => flag); const _vu0 = (input: any, _path: string, _exceptionable: boolean = true): any => (() => {
|
|
473
|
+
if ("workers@stdout" === input.type)
|
|
474
|
+
return _vo0(input, _path, true && _exceptionable);
|
|
475
|
+
else if ("workers@state" === input.type)
|
|
476
|
+
return _vo1(input, _path, true && _exceptionable);
|
|
477
|
+
else if ("watcher@change" === input.type)
|
|
478
|
+
return _vo2(input, _path, true && _exceptionable);
|
|
479
|
+
else if ("milkio@logger" === input.type)
|
|
480
|
+
return _vo3(input, _path, true && _exceptionable);
|
|
481
|
+
else
|
|
482
|
+
return _report(_exceptionable, {
|
|
483
|
+
path: _path,
|
|
484
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
485
|
+
value: input
|
|
486
|
+
});
|
|
487
|
+
})(); const _po0 = (input: any): any => {
|
|
488
|
+
for (const key of Object.keys(input)) {
|
|
489
|
+
if ("type" === key || "key" === key || "chunk" === key)
|
|
490
|
+
continue;
|
|
491
|
+
delete input[key];
|
|
492
|
+
}
|
|
493
|
+
}; const _po1 = (input: any): any => {
|
|
494
|
+
for (const key of Object.keys(input)) {
|
|
495
|
+
if ("type" === key || "key" === key || "state" === key || "code" === key)
|
|
496
|
+
continue;
|
|
497
|
+
delete input[key];
|
|
498
|
+
}
|
|
499
|
+
}; const _po2 = (input: any): any => {
|
|
500
|
+
for (const key of Object.keys(input)) {
|
|
501
|
+
if ("type" === key || "event" === key || "path" === key)
|
|
502
|
+
continue;
|
|
503
|
+
delete input[key];
|
|
504
|
+
}
|
|
505
|
+
}; const _po3 = (input: any): any => {
|
|
506
|
+
for (const key of Object.keys(input)) {
|
|
507
|
+
if ("type" === key || "log" === key)
|
|
508
|
+
continue;
|
|
509
|
+
delete input[key];
|
|
510
|
+
}
|
|
511
|
+
}; const _pu0 = (input: any): any => (() => {
|
|
512
|
+
if ("workers@stdout" === input.type)
|
|
513
|
+
return _po0(input);
|
|
514
|
+
else if ("workers@state" === input.type)
|
|
515
|
+
return _po1(input);
|
|
516
|
+
else if ("watcher@change" === input.type)
|
|
517
|
+
return _po2(input);
|
|
518
|
+
else if ("milkio@logger" === input.type)
|
|
519
|
+
return _po3(input);
|
|
520
|
+
else
|
|
521
|
+
__typia_transform__throwTypeGuardError._throwTypeGuardError({
|
|
522
|
+
method: "typia.misc.validatePrune",
|
|
523
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
524
|
+
value: input
|
|
525
|
+
});
|
|
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> => {
|
|
527
|
+
if (false === __is(input)) {
|
|
528
|
+
errors = [];
|
|
529
|
+
_report = (__typia_transform__validateReport._validateReport as any)(errors);
|
|
530
|
+
((input: any, _path: string, _exceptionable: boolean = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
531
|
+
path: _path + "",
|
|
532
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
533
|
+
value: input
|
|
534
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
535
|
+
path: _path + "",
|
|
536
|
+
expected: "(__type | __type.o1 | __type.o2 | __type.o3)",
|
|
537
|
+
value: input
|
|
538
|
+
}))(input, "$input", true);
|
|
539
|
+
const success = 0 === errors.length;
|
|
540
|
+
return success ? {
|
|
541
|
+
success,
|
|
542
|
+
data: input
|
|
543
|
+
} : {
|
|
544
|
+
success,
|
|
545
|
+
errors,
|
|
546
|
+
data: input
|
|
547
|
+
} as any;
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
success: true,
|
|
551
|
+
data: input
|
|
552
|
+
} as any;
|
|
553
|
+
}; const __prune = (input: CookbookSubscribeEmits): void => {
|
|
554
|
+
if ("object" === typeof input && null !== input)
|
|
555
|
+
_pu0(input);
|
|
556
|
+
}; return (input: any): import("typia").IValidation<CookbookSubscribeEmits> => {
|
|
557
|
+
const result = __validate(input);
|
|
558
|
+
if (result.success)
|
|
559
|
+
__prune(input);
|
|
560
|
+
return result;
|
|
561
|
+
}; })()(results);
|
|
562
|
+
const error = null;
|
|
563
|
+
if (!checkResult.success) {
|
|
564
|
+
const error: any = checkResult.errors.at(0)!;
|
|
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.`;
|
|
566
|
+
Error.captureStackTrace(error);
|
|
567
|
+
results = null;
|
|
568
|
+
}
|
|
569
|
+
return [error, results];
|
|
570
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface CookbookOptions {
|
|
7
|
+
projects: Record<string, {
|
|
8
|
+
type: 'milkio' | 'custom';
|
|
9
|
+
port: number;
|
|
10
|
+
start: Array<string>;
|
|
11
|
+
build: Array<string>;
|
|
12
|
+
watch?: boolean;
|
|
13
|
+
lazyRoutes?: boolean;
|
|
14
|
+
typiaMode?: 'generation' | 'bundler';
|
|
15
|
+
significant?: Array<string>;
|
|
16
|
+
insignificant?: Array<string>;
|
|
17
|
+
}>;
|
|
18
|
+
general: {
|
|
19
|
+
start: string;
|
|
20
|
+
cookbookPort: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type CookbookActionParams = {
|
|
24
|
+
type: 'milkio@ping';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'milkio@logger';
|
|
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;
|
|
39
|
+
};
|
|
40
|
+
export type CookbookSubscribeEmits = {
|
|
41
|
+
type: 'workers@stdout';
|
|
42
|
+
key: string;
|
|
43
|
+
chunk: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'workers@state';
|
|
46
|
+
key: string;
|
|
47
|
+
state: 'running' | 'stopped';
|
|
48
|
+
code: number | null | 'kill' | 'running';
|
|
49
|
+
} | {
|
|
50
|
+
type: 'watcher@change';
|
|
51
|
+
event: 'rename' | 'change';
|
|
52
|
+
path: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'milkio@logger';
|
|
55
|
+
log: Array<any>;
|
|
56
|
+
};
|