milkio 0.0.5 → 0.0.7

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.
@@ -38,13 +38,14 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
38
38
  const csStartedAt = new Date().getTime();
39
39
  const clear = setTimeout(() => {
40
40
  console.error(`------`);
41
- console.error(`❌ TIMEOUT -- More than ${cs.timeout ?? 6000}ms`);
41
+ console.error(`❌ TIMEOUT -- More than ${cs.timeout ?? 8192}ms`);
42
42
  console.error(` ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i}`);
43
43
  console.error(`------`);
44
44
  exit(1);
45
- }, cs.timeout ?? 6000);
45
+ }, cs.timeout ?? 8192);
46
46
  await cs.handler({
47
47
  execute: async (params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
48
+ executeOther: async (path: any, params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
48
49
  reject: (message?: string) => {
49
50
  console.error(`------`);
50
51
  console.error(`❌ REJECT -- ${message ?? "Test not satisfied"}`);
@@ -52,7 +53,7 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
52
53
  console.error(`------`);
53
54
  exit(1);
54
55
  }
55
- });
56
+ } as any);
56
57
  clearTimeout(clear);
57
58
  console.log(`✅ DIRECT -- ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i} | Time: ${new Date().getTime() - csStartedAt}ms`);
58
59
  }
@@ -1,4 +1,5 @@
1
1
  import { type Api, type ExecuteResult, type ExecuteOptions } from "..";
2
+ import type schema from "../../../generate/api-schema";
2
3
 
3
4
  export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTestCases<ApiT>>) {
4
5
  return {
@@ -8,7 +9,14 @@ export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTest
8
9
  }
9
10
 
10
11
  export type ApiTestCases<ApiT extends Api> = {
11
- handler: (test: { execute: (params: Parameters<ApiT["action"]>[0], headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Awaited<ReturnType<ApiT["action"]>>>>; reject: (message?: string) => void }) => Promise<void> | void;
12
+ handler: (test: {
13
+ // execute
14
+ execute: (params: Parameters<ApiT["action"]>[0], headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Awaited<ReturnType<ApiT["action"]>>>>;
15
+ // execute other
16
+ executeOther: <Path extends keyof (typeof schema)["apiMethodsTypeSchema"], Result extends Awaited<ReturnType<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>>>(path: Path, params: Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>[0] | string, headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Result>>;
17
+ // reject
18
+ reject: (message?: string) => void;
19
+ }) => Promise<void> | void;
12
20
  name: string;
13
21
  timeout?: number;
14
22
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.0.5",
5
+ "version": "0.0.7",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
@@ -10,7 +10,6 @@
10
10
  "@poech/camel-hump-under": "^1.1.0",
11
11
  "@southern-aurora/tson": "2.0.2",
12
12
  "ulidx": "^2.3.0",
13
- "walk-sync": "^3.0.0",
14
13
  "typia": "5.5.5",
15
14
  "ejs": "^3.1.9"
16
15
  },
@@ -2,12 +2,12 @@
2
2
 
3
3
  import ejs from "ejs";
4
4
  import { join } from "node:path";
5
- import walkSync from "walk-sync";
6
5
  import { existsSync, mkdirSync } from "node:fs";
7
6
  import { cwd, exit } from "node:process";
8
7
  import { unlink, writeFile } from "node:fs/promises";
9
8
  import { exec as nodeExec } from "node:child_process";
10
9
  import { camel, hyphen } from "@poech/camel-hump-under";
10
+ import { Glob } from "bun";
11
11
 
12
12
  const utils = {
13
13
  camel: (str: string) => camel(str).replaceAll("-", "").replaceAll("_", ""),
@@ -41,9 +41,8 @@ export async function generateApp() {
41
41
  apiTestPaths: [] as Array<string>
42
42
  };
43
43
 
44
- const appFiles = walkSync(join(cwd(), "src", "apps"), {
45
- directories: false
46
- });
44
+ const glob = new Glob("**/*.ts");
45
+ const appFiles = await Array.fromAsync(glob.scan({ cwd: join(cwd(), "src", "apps") }));
47
46
 
48
47
  for (const path of appFiles) {
49
48
  if (!path.endsWith(".ts")) continue;
@@ -2,10 +2,10 @@
2
2
 
3
3
  import ejs from "ejs";
4
4
  import { join } from "node:path";
5
- import walkSync from "walk-sync";
6
5
  import { existsSync } from "node:fs";
7
6
  import { cwd } from "node:process";
8
7
  import { writeFile } from "node:fs/promises";
8
+ import { Glob } from "bun";
9
9
 
10
10
  export async function generateDatabase() {
11
11
  if (existsSync(join(cwd(), "src", "databases"))) {
@@ -13,9 +13,8 @@ export async function generateDatabase() {
13
13
  await writeFile(join("generate", "database-schema.ts"), ``);
14
14
  }
15
15
  const filePath = join(cwd(), "generate", "database-schema.ts");
16
- const databaseFiles = walkSync(join(cwd(), "src", "databases"), {
17
- directories: false
18
- }).filter((file) => file.endsWith(".ts"));
16
+ const glob = new Glob("**/*.ts");
17
+ const databaseFiles = await Array.fromAsync(glob.scan({ cwd: join(cwd(), "src", "databases") }));
19
18
  const template = `<% for (const path of ${"databaseFiles"}) { %>export * from '${"../src/databases"}/<%= path.slice(0, -3) %>'
20
19
  <% } %>`;
21
20
  await writeFile(filePath, ejs.render(template, { databaseFiles }));