@gencow/core 0.1.24 → 0.1.26
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/dist/crud.d.ts +2 -2
- package/dist/crud.js +225 -208
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/reactive.js +10 -3
- package/dist/retry.js +1 -1
- package/dist/rls-db.d.ts +2 -2
- package/dist/rls-db.js +1 -5
- package/dist/scheduler.d.ts +2 -0
- package/dist/scheduler.js +16 -6
- package/dist/server.d.ts +0 -1
- package/dist/server.js +0 -1
- package/dist/storage.js +29 -22
- package/dist/v.d.ts +2 -2
- package/dist/workflow.js +4 -11
- package/dist/workflows-api.js +5 -12
- package/package.json +45 -42
- package/src/__tests__/auth.test.ts +90 -86
- package/src/__tests__/crons.test.ts +69 -67
- package/src/__tests__/crud-codegen-integration.test.ts +164 -170
- package/src/__tests__/crud-owner-rls.test.ts +308 -301
- package/src/__tests__/crud.test.ts +694 -711
- package/src/__tests__/dist-exports.test.ts +120 -120
- package/src/__tests__/fixtures/basic/auth.ts +16 -16
- package/src/__tests__/fixtures/basic/drizzle.config.ts +1 -4
- package/src/__tests__/fixtures/basic/index.ts +1 -1
- package/src/__tests__/fixtures/basic/schema.ts +1 -1
- package/src/__tests__/fixtures/basic/tasks.ts +4 -4
- package/src/__tests__/fixtures/common/auth-schema.ts +38 -34
- package/src/__tests__/helpers/basic-rls-fixture.ts +80 -78
- package/src/__tests__/helpers/pglite-migrations.ts +2 -5
- package/src/__tests__/helpers/pglite-rls-session.ts +13 -16
- package/src/__tests__/helpers/seed-like-fill.ts +47 -41
- package/src/__tests__/helpers/test-gencow-ctx-rls.ts +4 -7
- package/src/__tests__/httpaction.test.ts +91 -91
- package/src/__tests__/image-optimization.test.ts +570 -574
- package/src/__tests__/load.test.ts +321 -308
- package/src/__tests__/network-sim.test.ts +238 -215
- package/src/__tests__/reactive.test.ts +380 -358
- package/src/__tests__/retry.test.ts +99 -84
- package/src/__tests__/rls-crud-basic.test.ts +172 -245
- package/src/__tests__/rls-crud-no-owner-rls-pglite.test.ts +81 -81
- package/src/__tests__/rls-custom-mutation-handlers.test.ts +47 -94
- package/src/__tests__/rls-custom-query-handlers.test.ts +92 -92
- package/src/__tests__/rls-db-leased-connection.test.ts +2 -6
- package/src/__tests__/rls-session-and-policies.test.ts +181 -199
- package/src/__tests__/scheduler-durable-v2.test.ts +199 -181
- package/src/__tests__/scheduler-durable.test.ts +117 -117
- package/src/__tests__/scheduler-exec.test.ts +258 -246
- package/src/__tests__/scheduler.test.ts +129 -111
- package/src/__tests__/storage.test.ts +282 -269
- package/src/__tests__/tsconfig.json +6 -6
- package/src/__tests__/validator.test.ts +236 -232
- package/src/__tests__/workflow.test.ts +309 -286
- package/src/__tests__/ws-integration.test.ts +223 -218
- package/src/__tests__/ws-scale.test.ts +168 -159
- package/src/auth-config.ts +18 -18
- package/src/auth.ts +106 -106
- package/src/crons.ts +77 -77
- package/src/crud.ts +523 -479
- package/src/index.ts +69 -5
- package/src/reactive.ts +357 -331
- package/src/retry.ts +51 -54
- package/src/rls-db.ts +195 -205
- package/src/rls.ts +33 -36
- package/src/scheduler.ts +237 -211
- package/src/server.ts +0 -1
- package/src/storage.ts +632 -593
- package/src/v.ts +119 -114
- package/src/workflow-types.ts +67 -70
- package/src/workflow.ts +99 -116
- package/src/workflows-api.ts +231 -241
- package/dist/db.d.ts +0 -13
- package/dist/db.js +0 -16
- package/src/db.ts +0 -18
|
@@ -1,81 +1,83 @@
|
|
|
1
1
|
import { describe, test, expect } from "bun:test";
|
|
2
|
-
import { cronJobs } from "../crons";
|
|
2
|
+
import { cronJobs } from "../crons.js";
|
|
3
3
|
|
|
4
4
|
describe("cronJobs 빌더", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
test("interval — minutes → cron 패턴 변환", () => {
|
|
6
|
+
const crons = cronJobs();
|
|
7
|
+
crons.interval("test", { minutes: 15 }, "test.action");
|
|
8
|
+
const jobs = crons.getJobs();
|
|
9
|
+
expect(jobs).toHaveLength(1);
|
|
10
|
+
expect(jobs[0].name).toBe("test");
|
|
11
|
+
expect(jobs[0].pattern).toBe("*/15 * * * *");
|
|
12
|
+
expect(jobs[0].action).toBe("test.action");
|
|
13
|
+
});
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
test("interval — hours → cron 패턴 변환", () => {
|
|
16
|
+
const crons = cronJobs();
|
|
17
|
+
crons.interval("hourly", { hours: 6 }, "cleanup");
|
|
18
|
+
expect(crons.getJobs()[0].pattern).toBe("0 */6 * * *");
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
test("interval — seconds → 6자리 cron 패턴", () => {
|
|
22
|
+
const crons = cronJobs();
|
|
23
|
+
crons.interval("fast", { seconds: 30 }, "tick");
|
|
24
|
+
expect(crons.getJobs()[0].pattern).toBe("*/30 * * * * *");
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
test("daily — 특정 시각", () => {
|
|
28
|
+
const crons = cronJobs();
|
|
29
|
+
crons.daily("report", { hour: 9, minute: 30 }, "reports.gen");
|
|
30
|
+
const job = crons.getJobs()[0];
|
|
31
|
+
expect(job.pattern).toBe("30 9 * * *");
|
|
32
|
+
});
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
test("daily — minute 기본값 0", () => {
|
|
35
|
+
const crons = cronJobs();
|
|
36
|
+
crons.daily("cleanup", { hour: 2 }, "admin.cleanup");
|
|
37
|
+
expect(crons.getJobs()[0].pattern).toBe("0 2 * * *");
|
|
38
|
+
});
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
test("weekly — 요일 + 시각", () => {
|
|
41
|
+
const crons = cronJobs();
|
|
42
|
+
crons.weekly("monday-report", { dayOfWeek: 1, hour: 9 }, "reports.weekly");
|
|
43
|
+
expect(crons.getJobs()[0].pattern).toBe("0 9 * * 1");
|
|
44
|
+
});
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
test("cron — 직접 패턴 지정", () => {
|
|
47
|
+
const crons = cronJobs();
|
|
48
|
+
crons.cron("custom", "0 */2 * * *", "custom.handler");
|
|
49
|
+
expect(crons.getJobs()[0].pattern).toBe("0 */2 * * *");
|
|
50
|
+
});
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
test("체이닝 지원", () => {
|
|
53
|
+
const crons = cronJobs();
|
|
54
|
+
crons
|
|
55
|
+
.interval("a", { minutes: 5 }, "a.action")
|
|
56
|
+
.daily("b", { hour: 3 }, "b.action")
|
|
57
|
+
.cron("c", "0 * * * *", "c.action");
|
|
58
|
+
expect(crons.getJobs()).toHaveLength(3);
|
|
59
|
+
});
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
61
|
+
test("인라인 핸들러 지원", () => {
|
|
62
|
+
const crons = cronJobs();
|
|
63
|
+
const fn = async () => {
|
|
64
|
+
/* noop */
|
|
65
|
+
};
|
|
66
|
+
crons.interval("inline", { minutes: 1 }, fn);
|
|
67
|
+
expect(typeof crons.getJobs()[0].action).toBe("function");
|
|
68
|
+
});
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
test("getJobs는 복사본 반환 (원본 보호)", () => {
|
|
71
|
+
const crons = cronJobs();
|
|
72
|
+
crons.interval("test", { minutes: 1 }, "test");
|
|
73
|
+
const jobs1 = crons.getJobs();
|
|
74
|
+
const jobs2 = crons.getJobs();
|
|
75
|
+
expect(jobs1).not.toBe(jobs2); // 서로 다른 참조
|
|
76
|
+
expect(jobs1).toEqual(jobs2); // 내용은 동일
|
|
77
|
+
});
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
test("interval — 옵션 없으면 에러", () => {
|
|
80
|
+
const crons = cronJobs();
|
|
81
|
+
expect(() => crons.interval("bad", {}, "bad")).toThrow("minutes, hours, 또는 seconds");
|
|
82
|
+
});
|
|
81
83
|
});
|
|
@@ -24,41 +24,35 @@
|
|
|
24
24
|
import { describe, it, expect, beforeAll } from "bun:test";
|
|
25
25
|
import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
|
|
26
26
|
|
|
27
|
-
import { crud } from "../crud";
|
|
28
|
-
import {
|
|
29
|
-
query,
|
|
30
|
-
mutation,
|
|
31
|
-
getRegisteredQueries,
|
|
32
|
-
getRegisteredMutations,
|
|
33
|
-
getQueryDef,
|
|
34
|
-
} from "../reactive";
|
|
27
|
+
import { crud } from "../crud.js";
|
|
28
|
+
import { query, mutation, getRegisteredQueries, getRegisteredMutations, getQueryDef } from "../reactive.js";
|
|
35
29
|
|
|
36
30
|
// ─── 테스트용 테이블 정의 ─────────────────────────────────────────────
|
|
37
31
|
|
|
38
32
|
const keywords = pgTable("cg_keywords", {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
id: serial("id").primaryKey(),
|
|
34
|
+
keyword: text("keyword").notNull(),
|
|
35
|
+
userId: text("user_id"),
|
|
36
|
+
createdAt: timestamp("created_at").defaultNow(),
|
|
43
37
|
});
|
|
44
38
|
|
|
45
39
|
const crawlLogs = pgTable("cg_crawl_logs", {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
id: serial("id").primaryKey(),
|
|
41
|
+
status: text("status"),
|
|
42
|
+
createdAt: timestamp("created_at").defaultNow(),
|
|
49
43
|
});
|
|
50
44
|
|
|
51
45
|
const digests = pgTable("cg_digests", {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
id: serial("id").primaryKey(),
|
|
47
|
+
title: text("title"),
|
|
48
|
+
content: text("content"),
|
|
49
|
+
createdAt: timestamp("created_at").defaultNow(),
|
|
56
50
|
});
|
|
57
51
|
|
|
58
52
|
const appSettings = pgTable("cg_app_settings", {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
id: serial("id").primaryKey(),
|
|
54
|
+
key: text("key"),
|
|
55
|
+
value: text("value"),
|
|
62
56
|
});
|
|
63
57
|
|
|
64
58
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -66,46 +60,46 @@ const appSettings = pgTable("cg_app_settings", {
|
|
|
66
60
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
67
61
|
|
|
68
62
|
describe("crud() → codegen 통합 — 다중 테이블", () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
63
|
+
beforeAll(() => {
|
|
64
|
+
// test032 패턴 재현: 4개 모듈이 각각 crud() 호출
|
|
65
|
+
crud(keywords, { public: true });
|
|
66
|
+
crud(crawlLogs, { public: true });
|
|
67
|
+
crud(digests, { public: true });
|
|
68
|
+
crud(appSettings, { public: true });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("4개 테이블의 list/get query가 모두 레지스트리에 등록된다", () => {
|
|
72
|
+
const queries = getRegisteredQueries();
|
|
73
|
+
|
|
74
|
+
// 각 테이블의 list + get = 8개
|
|
75
|
+
expect(queries).toContain("cg_keywords.list");
|
|
76
|
+
expect(queries).toContain("cg_keywords.get");
|
|
77
|
+
expect(queries).toContain("cg_crawl_logs.list");
|
|
78
|
+
expect(queries).toContain("cg_crawl_logs.get");
|
|
79
|
+
expect(queries).toContain("cg_digests.list");
|
|
80
|
+
expect(queries).toContain("cg_digests.get");
|
|
81
|
+
expect(queries).toContain("cg_app_settings.list");
|
|
82
|
+
expect(queries).toContain("cg_app_settings.get");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("4개 테이블의 create/update/remove mutation이 모두 레지스트리에 등록된다", () => {
|
|
86
|
+
const mutations = getRegisteredMutations();
|
|
87
|
+
const names = mutations.map((m) => m.name);
|
|
88
|
+
|
|
89
|
+
// 각 테이블의 create + update + remove = 12개
|
|
90
|
+
expect(names).toContain("cg_keywords.create");
|
|
91
|
+
expect(names).toContain("cg_keywords.update");
|
|
92
|
+
expect(names).toContain("cg_keywords.remove");
|
|
93
|
+
expect(names).toContain("cg_crawl_logs.create");
|
|
94
|
+
expect(names).toContain("cg_crawl_logs.update");
|
|
95
|
+
expect(names).toContain("cg_crawl_logs.remove");
|
|
96
|
+
expect(names).toContain("cg_digests.create");
|
|
97
|
+
expect(names).toContain("cg_digests.update");
|
|
98
|
+
expect(names).toContain("cg_digests.remove");
|
|
99
|
+
expect(names).toContain("cg_app_settings.create");
|
|
100
|
+
expect(names).toContain("cg_app_settings.update");
|
|
101
|
+
expect(names).toContain("cg_app_settings.remove");
|
|
102
|
+
});
|
|
109
103
|
});
|
|
110
104
|
|
|
111
105
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -113,54 +107,54 @@ describe("crud() → codegen 통합 — 다중 테이블", () => {
|
|
|
113
107
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
114
108
|
|
|
115
109
|
describe("crud() + 수동 query/mutation 혼용", () => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
mutation("cg_digests.generate", {
|
|
134
|
-
public: true,
|
|
135
|
-
handler: async (ctx) => {
|
|
136
|
-
return { success: true };
|
|
137
|
-
},
|
|
138
|
-
});
|
|
110
|
+
beforeAll(() => {
|
|
111
|
+
// crud로 자동 등록
|
|
112
|
+
const articlesTable = pgTable("cg_articles", {
|
|
113
|
+
id: serial("id").primaryKey(),
|
|
114
|
+
title: text("title"),
|
|
115
|
+
createdAt: timestamp("created_at").defaultNow(),
|
|
116
|
+
});
|
|
117
|
+
crud(articlesTable, { public: true });
|
|
118
|
+
|
|
119
|
+
// 수동으로 추가 등록 (test032의 digestsModule.generate 패턴)
|
|
120
|
+
query("cg_digests.latest", {
|
|
121
|
+
public: true,
|
|
122
|
+
handler: async (ctx) => {
|
|
123
|
+
return { id: 1, title: "latest" };
|
|
124
|
+
},
|
|
139
125
|
});
|
|
140
126
|
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
mutation("cg_digests.generate", {
|
|
128
|
+
public: true,
|
|
129
|
+
handler: async (ctx) => {
|
|
130
|
+
return { success: true };
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
});
|
|
143
134
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
expect(queries).toContain("cg_articles.get");
|
|
135
|
+
it("crud 등록 + 수동 등록이 모두 getRegisteredQueries()에 포함된다", () => {
|
|
136
|
+
const queries = getRegisteredQueries();
|
|
147
137
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
138
|
+
// crud 자동 등록
|
|
139
|
+
expect(queries).toContain("cg_articles.list");
|
|
140
|
+
expect(queries).toContain("cg_articles.get");
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
// 수동 등록
|
|
143
|
+
expect(queries).toContain("cg_digests.latest");
|
|
144
|
+
});
|
|
155
145
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(names).toContain("cg_articles.remove");
|
|
146
|
+
it("crud 등록 + 수동 등록이 모두 getRegisteredMutations()에 포함된다", () => {
|
|
147
|
+
const mutations = getRegisteredMutations();
|
|
148
|
+
const names = mutations.map((m) => m.name);
|
|
160
149
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
150
|
+
// crud 자동 등록
|
|
151
|
+
expect(names).toContain("cg_articles.create");
|
|
152
|
+
expect(names).toContain("cg_articles.update");
|
|
153
|
+
expect(names).toContain("cg_articles.remove");
|
|
154
|
+
|
|
155
|
+
// 수동 등록
|
|
156
|
+
expect(names).toContain("cg_digests.generate");
|
|
157
|
+
});
|
|
164
158
|
});
|
|
165
159
|
|
|
166
160
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -168,43 +162,43 @@ describe("crud() + 수동 query/mutation 혼용", () => {
|
|
|
168
162
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
169
163
|
|
|
170
164
|
describe("crud() isPublic 상태 — codegen auth 분기 정확성", () => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
crud(publicTable, { public: true });
|
|
182
|
-
crud(privateTable); // default: auth 필수
|
|
165
|
+
beforeAll(() => {
|
|
166
|
+
const publicTable = pgTable("cg_public_data", {
|
|
167
|
+
id: serial("id").primaryKey(),
|
|
168
|
+
name: text("name"),
|
|
169
|
+
});
|
|
170
|
+
const privateTable = pgTable("cg_private_data", {
|
|
171
|
+
id: serial("id").primaryKey(),
|
|
172
|
+
name: text("name"),
|
|
183
173
|
});
|
|
184
174
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
crud(publicTable, { public: true });
|
|
176
|
+
crud(privateTable); // default: auth 필수
|
|
177
|
+
});
|
|
188
178
|
|
|
189
|
-
|
|
190
|
-
|
|
179
|
+
it("public: true 테이블의 모든 엔드포인트가 isPublic === true", () => {
|
|
180
|
+
const listDef = getQueryDef("cg_public_data.list");
|
|
181
|
+
const getDef = getQueryDef("cg_public_data.get");
|
|
191
182
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
expect(createDef!.isPublic).toBe(true);
|
|
195
|
-
});
|
|
183
|
+
expect(listDef!.isPublic).toBe(true);
|
|
184
|
+
expect(getDef!.isPublic).toBe(true);
|
|
196
185
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
const mutations = getRegisteredMutations();
|
|
187
|
+
const createDef = mutations.find((m) => m.name === "cg_public_data.create");
|
|
188
|
+
expect(createDef!.isPublic).toBe(true);
|
|
189
|
+
});
|
|
200
190
|
|
|
201
|
-
|
|
202
|
-
|
|
191
|
+
it("기본(private) 테이블의 모든 엔드포인트가 isPublic === false", () => {
|
|
192
|
+
const listDef = getQueryDef("cg_private_data.list");
|
|
193
|
+
const getDef = getQueryDef("cg_private_data.get");
|
|
203
194
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
expect(listDef!.isPublic).toBe(false);
|
|
196
|
+
expect(getDef!.isPublic).toBe(false);
|
|
197
|
+
|
|
198
|
+
const mutations = getRegisteredMutations();
|
|
199
|
+
const createDef = mutations.find((m) => m.name === "cg_private_data.create");
|
|
200
|
+
expect(createDef!.isPublic).toBe(false);
|
|
201
|
+
});
|
|
208
202
|
});
|
|
209
203
|
|
|
210
204
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -212,41 +206,41 @@ describe("crud() isPublic 상태 — codegen auth 분기 정확성", () => {
|
|
|
212
206
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
213
207
|
|
|
214
208
|
describe("codegen 시뮬레이션 — api.ts 생성 가능 여부", () => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
209
|
+
it("getRegisteredQueries()로 모든 query key를 열거할 수 있다", () => {
|
|
210
|
+
const queries = getRegisteredQueries();
|
|
211
|
+
expect(queries.length).toBeGreaterThan(0);
|
|
212
|
+
|
|
213
|
+
// 모든 query key가 "namespace.action" 패턴이어야 함
|
|
214
|
+
for (const key of queries) {
|
|
215
|
+
expect(key).toMatch(/^[a-z_]+\.[a-z_]+$/i);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("getRegisteredMutations()로 모든 mutation을 열거할 수 있다", () => {
|
|
220
|
+
const mutations = getRegisteredMutations();
|
|
221
|
+
expect(mutations.length).toBeGreaterThan(0);
|
|
222
|
+
|
|
223
|
+
// 모든 mutation이 name + handler를 가져야 함
|
|
224
|
+
for (const mut of mutations) {
|
|
225
|
+
expect(mut.name).toBeTruthy();
|
|
226
|
+
expect(typeof mut.handler).toBe("function");
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("getQueryDef()로 개별 query의 argsSchema에 접근할 수 있다", () => {
|
|
231
|
+
const listDef = getQueryDef("cg_keywords.list");
|
|
232
|
+
expect(listDef).toBeDefined();
|
|
233
|
+
// list handler에는 argsSchema가 있음 (limit, offset, sort, filters)
|
|
234
|
+
expect(listDef!.handler).toBeDefined();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("codegen 대상 query/mutation 총 개수가 올바르다", () => {
|
|
238
|
+
const queries = getRegisteredQueries();
|
|
239
|
+
const mutations = getRegisteredMutations();
|
|
240
|
+
|
|
241
|
+
// 최소 8개 query (4테이블 × list+get) + 수동 1개 + 이전 테스트들
|
|
242
|
+
expect(queries.length).toBeGreaterThanOrEqual(8);
|
|
243
|
+
// 최소 12개 mutation (4테이블 × create+update+remove) + 수동 1개
|
|
244
|
+
expect(mutations.length).toBeGreaterThanOrEqual(12);
|
|
245
|
+
});
|
|
252
246
|
});
|