@gencow/core 0.1.24 → 0.1.25

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.
Files changed (73) hide show
  1. package/dist/crud.d.ts +2 -2
  2. package/dist/crud.js +225 -208
  3. package/dist/index.d.ts +5 -5
  4. package/dist/index.js +2 -2
  5. package/dist/reactive.js +10 -3
  6. package/dist/retry.js +1 -1
  7. package/dist/rls-db.d.ts +2 -2
  8. package/dist/rls-db.js +1 -5
  9. package/dist/scheduler.d.ts +2 -0
  10. package/dist/scheduler.js +16 -6
  11. package/dist/server.d.ts +0 -1
  12. package/dist/server.js +0 -1
  13. package/dist/storage.js +29 -22
  14. package/dist/v.d.ts +2 -2
  15. package/dist/workflow.js +4 -11
  16. package/dist/workflows-api.js +5 -12
  17. package/package.json +46 -42
  18. package/src/__tests__/auth.test.ts +90 -86
  19. package/src/__tests__/crons.test.ts +69 -67
  20. package/src/__tests__/crud-codegen-integration.test.ts +164 -170
  21. package/src/__tests__/crud-owner-rls.test.ts +308 -301
  22. package/src/__tests__/crud.test.ts +694 -711
  23. package/src/__tests__/dist-exports.test.ts +120 -120
  24. package/src/__tests__/fixtures/basic/auth.ts +16 -16
  25. package/src/__tests__/fixtures/basic/drizzle.config.ts +1 -4
  26. package/src/__tests__/fixtures/basic/index.ts +1 -1
  27. package/src/__tests__/fixtures/basic/schema.ts +1 -1
  28. package/src/__tests__/fixtures/basic/tasks.ts +4 -4
  29. package/src/__tests__/fixtures/common/auth-schema.ts +38 -34
  30. package/src/__tests__/helpers/basic-rls-fixture.ts +80 -78
  31. package/src/__tests__/helpers/pglite-migrations.ts +2 -5
  32. package/src/__tests__/helpers/pglite-rls-session.ts +13 -16
  33. package/src/__tests__/helpers/seed-like-fill.ts +50 -44
  34. package/src/__tests__/helpers/test-gencow-ctx-rls.ts +4 -7
  35. package/src/__tests__/httpaction.test.ts +91 -91
  36. package/src/__tests__/image-optimization.test.ts +570 -574
  37. package/src/__tests__/load.test.ts +321 -308
  38. package/src/__tests__/network-sim.test.ts +238 -215
  39. package/src/__tests__/reactive.test.ts +380 -358
  40. package/src/__tests__/retry.test.ts +99 -84
  41. package/src/__tests__/rls-crud-basic.test.ts +172 -245
  42. package/src/__tests__/rls-crud-no-owner-rls-pglite.test.ts +81 -81
  43. package/src/__tests__/rls-custom-mutation-handlers.test.ts +47 -94
  44. package/src/__tests__/rls-custom-query-handlers.test.ts +92 -92
  45. package/src/__tests__/rls-db-leased-connection.test.ts +2 -6
  46. package/src/__tests__/rls-session-and-policies.test.ts +181 -199
  47. package/src/__tests__/scheduler-durable-v2.test.ts +199 -181
  48. package/src/__tests__/scheduler-durable.test.ts +117 -117
  49. package/src/__tests__/scheduler-exec.test.ts +258 -246
  50. package/src/__tests__/scheduler.test.ts +129 -111
  51. package/src/__tests__/storage.test.ts +282 -269
  52. package/src/__tests__/tsconfig.json +6 -6
  53. package/src/__tests__/validator.test.ts +236 -232
  54. package/src/__tests__/workflow.test.ts +309 -286
  55. package/src/__tests__/ws-integration.test.ts +223 -218
  56. package/src/__tests__/ws-scale.test.ts +168 -159
  57. package/src/auth-config.ts +18 -18
  58. package/src/auth.ts +106 -106
  59. package/src/crons.ts +77 -77
  60. package/src/crud.ts +523 -479
  61. package/src/index.ts +69 -5
  62. package/src/reactive.ts +357 -331
  63. package/src/retry.ts +51 -54
  64. package/src/rls-db.ts +195 -205
  65. package/src/rls.ts +33 -36
  66. package/src/scheduler.ts +237 -211
  67. package/src/server.ts +0 -1
  68. package/src/storage.ts +632 -593
  69. package/src/v.ts +119 -114
  70. package/src/workflow-types.ts +67 -70
  71. package/src/workflow.ts +99 -116
  72. package/src/workflows-api.ts +231 -241
  73. package/src/db.ts +0 -18
@@ -1,98 +1,113 @@
1
1
  import { describe, test, expect, mock } from "bun:test";
2
- import { withRetry } from "../retry";
2
+ import { withRetry } from "../retry.js";
3
3
 
4
4
  describe("withRetry", () => {
5
- test("성공 시 즉시 반환", async () => {
6
- const result = await withRetry(async () => "success");
7
- expect(result).toBe("success");
8
- });
5
+ test("성공 시 즉시 반환", async () => {
6
+ const result = await withRetry(async () => "success");
7
+ expect(result).toBe("success");
8
+ });
9
9
 
10
- test("첫 시도 실패 후 재시도 성공", async () => {
11
- let attempt = 0;
12
- const result = await withRetry(async () => {
13
- attempt++;
14
- if (attempt < 2) throw new Error("fail");
15
- return "recovered";
16
- }, { initialBackoffMs: 10 });
10
+ test("첫 시도 실패 후 재시도 성공", async () => {
11
+ let attempt = 0;
12
+ const result = await withRetry(
13
+ async () => {
14
+ attempt++;
15
+ if (attempt < 2) throw new Error("fail");
16
+ return "recovered";
17
+ },
18
+ { initialBackoffMs: 10 },
19
+ );
17
20
 
18
- expect(result).toBe("recovered");
19
- expect(attempt).toBe(2);
20
- });
21
+ expect(result).toBe("recovered");
22
+ expect(attempt).toBe(2);
23
+ });
21
24
 
22
- test("maxAttempts 초과 시 마지막 에러 throw", async () => {
23
- let attempt = 0;
24
- try {
25
- await withRetry(async () => {
26
- attempt++;
27
- throw new Error(`fail-${attempt}`);
28
- }, { maxAttempts: 3, initialBackoffMs: 10 });
29
- expect(true).toBe(false); // 여기에 도달하면 안됨
30
- } catch (err: unknown) {
31
- expect((err as Error).message).toBe("fail-3");
32
- expect(attempt).toBe(3);
33
- }
34
- });
25
+ test("maxAttempts 초과 시 마지막 에러 throw", async () => {
26
+ let attempt = 0;
27
+ try {
28
+ await withRetry(
29
+ async () => {
30
+ attempt++;
31
+ throw new Error(`fail-${attempt}`);
32
+ },
33
+ { maxAttempts: 3, initialBackoffMs: 10 },
34
+ );
35
+ expect(true).toBe(false); // 여기에 도달하면 안됨
36
+ } catch (err: unknown) {
37
+ expect((err as Error).message).toBe("fail-3");
38
+ expect(attempt).toBe(3);
39
+ }
40
+ });
35
41
 
36
- test("shouldRetry가 false 반환 시 즉시 throw", async () => {
37
- let attempt = 0;
38
- try {
39
- await withRetry(async () => {
40
- attempt++;
41
- throw new Error("non-retryable");
42
- }, {
43
- maxAttempts: 5,
44
- initialBackoffMs: 10,
45
- shouldRetry: (err) => (err as Error).message !== "non-retryable",
46
- });
47
- } catch (err: unknown) {
48
- expect((err as Error).message).toBe("non-retryable");
49
- expect(attempt).toBe(1); // 재시도 없이 즉시 실패
50
- }
51
- });
42
+ test("shouldRetry가 false 반환 시 즉시 throw", async () => {
43
+ let attempt = 0;
44
+ try {
45
+ await withRetry(
46
+ async () => {
47
+ attempt++;
48
+ throw new Error("non-retryable");
49
+ },
50
+ {
51
+ maxAttempts: 5,
52
+ initialBackoffMs: 10,
53
+ shouldRetry: (err) => (err as Error).message !== "non-retryable",
54
+ },
55
+ );
56
+ } catch (err: unknown) {
57
+ expect((err as Error).message).toBe("non-retryable");
58
+ expect(attempt).toBe(1); // 재시도 없이 즉시 실패
59
+ }
60
+ });
52
61
 
53
- test("onRetry 콜백 호출", async () => {
54
- let attempt = 0;
55
- const retries: number[] = [];
62
+ test("onRetry 콜백 호출", async () => {
63
+ let attempt = 0;
64
+ const retries: number[] = [];
56
65
 
57
- await withRetry(async () => {
58
- attempt++;
59
- if (attempt < 3) throw new Error("fail");
60
- return "ok";
61
- }, {
62
- initialBackoffMs: 10,
63
- onRetry: (_err, attemptNum, _delay) => {
64
- retries.push(attemptNum);
65
- },
66
- });
66
+ await withRetry(
67
+ async () => {
68
+ attempt++;
69
+ if (attempt < 3) throw new Error("fail");
70
+ return "ok";
71
+ },
72
+ {
73
+ initialBackoffMs: 10,
74
+ onRetry: (_err, attemptNum, _delay) => {
75
+ retries.push(attemptNum);
76
+ },
77
+ },
78
+ );
67
79
 
68
- expect(retries).toEqual([1, 2]);
69
- });
80
+ expect(retries).toEqual([1, 2]);
81
+ });
70
82
 
71
- test("maxAttempts < 1이면 에러", async () => {
72
- try {
73
- await withRetry(async () => "ok", { maxAttempts: 0 });
74
- expect(true).toBe(false);
75
- } catch (err: unknown) {
76
- expect((err as Error).message).toContain("maxAttempts must be >= 1");
77
- }
78
- });
83
+ test("maxAttempts < 1이면 에러", async () => {
84
+ try {
85
+ await withRetry(async () => "ok", { maxAttempts: 0 });
86
+ expect(true).toBe(false);
87
+ } catch (err: unknown) {
88
+ expect((err as Error).message).toContain("maxAttempts must be >= 1");
89
+ }
90
+ });
79
91
 
80
- test("maxAttempts = 1이면 재시도 없이 즉시 throw", async () => {
81
- let attempt = 0;
82
- try {
83
- await withRetry(async () => {
84
- attempt++;
85
- throw new Error("once");
86
- }, { maxAttempts: 1 });
87
- } catch (err: unknown) {
88
- expect((err as Error).message).toBe("once");
89
- expect(attempt).toBe(1);
90
- }
91
- });
92
+ test("maxAttempts = 1이면 재시도 없이 즉시 throw", async () => {
93
+ let attempt = 0;
94
+ try {
95
+ await withRetry(
96
+ async () => {
97
+ attempt++;
98
+ throw new Error("once");
99
+ },
100
+ { maxAttempts: 1 },
101
+ );
102
+ } catch (err: unknown) {
103
+ expect((err as Error).message).toBe("once");
104
+ expect(attempt).toBe(1);
105
+ }
106
+ });
92
107
 
93
- test("비동기 함수 결과 타입 보존", async () => {
94
- const result = await withRetry(async () => ({ id: 1, name: "test" }));
95
- expect(result.id).toBe(1);
96
- expect(result.name).toBe("test");
97
- });
108
+ test("비동기 함수 결과 타입 보존", async () => {
109
+ const result = await withRetry(async () => ({ id: 1, name: "test" }));
110
+ expect(result.id).toBe(1);
111
+ expect(result.name).toBe("test");
112
+ });
98
113
  });