@geekmidas/cli 0.9.0 → 0.12.0
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 +525 -0
- package/dist/bundler-DRXCw_YR.mjs +70 -0
- package/dist/bundler-DRXCw_YR.mjs.map +1 -0
- package/dist/bundler-WsEvH_b2.cjs +71 -0
- package/dist/bundler-WsEvH_b2.cjs.map +1 -0
- package/dist/{config-CFls09Ey.cjs → config-AmInkU7k.cjs} +10 -8
- package/dist/config-AmInkU7k.cjs.map +1 -0
- package/dist/{config-Bq72aj8e.mjs → config-DYULeEv8.mjs} +6 -4
- package/dist/config-DYULeEv8.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +2 -1
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +1 -1
- package/dist/encryption-C8H-38Yy.mjs +42 -0
- package/dist/encryption-C8H-38Yy.mjs.map +1 -0
- package/dist/encryption-Dyf_r1h-.cjs +44 -0
- package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
- package/dist/index.cjs +2125 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2143 -197
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi--vOy9mo4.mjs → openapi-BfFlOBCG.mjs} +812 -49
- package/dist/openapi-BfFlOBCG.mjs.map +1 -0
- package/dist/{openapi-CHhTPief.cjs → openapi-Bt_1FDpT.cjs} +805 -42
- package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
- package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
- package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
- package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
- package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.d.cts.map +1 -0
- package/dist/openapi-react-query.d.mts.map +1 -0
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.d.mts.map +1 -0
- package/dist/openapi.mjs +2 -2
- package/dist/storage-BUYQJgz7.cjs +4 -0
- package/dist/storage-BXoJvmv2.cjs +149 -0
- package/dist/storage-BXoJvmv2.cjs.map +1 -0
- package/dist/storage-C9PU_30f.mjs +101 -0
- package/dist/storage-C9PU_30f.mjs.map +1 -0
- package/dist/storage-DLJAYxzJ.mjs +3 -0
- package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
- package/dist/types-BR0M2v_c.d.mts.map +1 -0
- package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
- package/dist/types-BhkZc-vm.d.cts.map +1 -0
- package/examples/cron-example.ts +27 -27
- package/examples/env.ts +27 -27
- package/examples/function-example.ts +31 -31
- package/examples/gkm.config.json +20 -20
- package/examples/gkm.config.ts +8 -8
- package/examples/gkm.minimal.config.json +5 -5
- package/examples/gkm.production.config.json +25 -25
- package/examples/logger.ts +2 -2
- package/package.json +6 -6
- package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
- package/src/__tests__/config.spec.ts +55 -55
- package/src/__tests__/loadEnvFiles.spec.ts +93 -93
- package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
- package/src/__tests__/openapi-react-query.spec.ts +497 -497
- package/src/__tests__/openapi.spec.ts +428 -428
- package/src/__tests__/test-helpers.ts +77 -76
- package/src/auth/__tests__/credentials.spec.ts +204 -0
- package/src/auth/__tests__/index.spec.ts +168 -0
- package/src/auth/credentials.ts +187 -0
- package/src/auth/index.ts +226 -0
- package/src/build/__tests__/index-new.spec.ts +474 -474
- package/src/build/__tests__/manifests.spec.ts +333 -333
- package/src/build/bundler.ts +141 -0
- package/src/build/endpoint-analyzer.ts +236 -0
- package/src/build/handler-templates.ts +1253 -0
- package/src/build/index.ts +250 -179
- package/src/build/manifests.ts +52 -52
- package/src/build/providerResolver.ts +145 -145
- package/src/build/types.ts +64 -43
- package/src/config.ts +39 -37
- package/src/deploy/__tests__/docker.spec.ts +111 -0
- package/src/deploy/__tests__/dokploy.spec.ts +245 -0
- package/src/deploy/__tests__/init.spec.ts +662 -0
- package/src/deploy/docker.ts +128 -0
- package/src/deploy/dokploy.ts +204 -0
- package/src/deploy/index.ts +136 -0
- package/src/deploy/init.ts +484 -0
- package/src/deploy/types.ts +48 -0
- package/src/dev/__tests__/index.spec.ts +266 -266
- package/src/dev/index.ts +647 -593
- package/src/docker/__tests__/compose.spec.ts +531 -0
- package/src/docker/__tests__/templates.spec.ts +280 -0
- package/src/docker/compose.ts +273 -0
- package/src/docker/index.ts +230 -0
- package/src/docker/templates.ts +446 -0
- package/src/generators/CronGenerator.ts +72 -72
- package/src/generators/EndpointGenerator.ts +699 -398
- package/src/generators/FunctionGenerator.ts +84 -84
- package/src/generators/Generator.ts +72 -72
- package/src/generators/OpenApiTsGenerator.ts +589 -589
- package/src/generators/SubscriberGenerator.ts +124 -124
- package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
- package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
- package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
- package/src/generators/index.ts +4 -4
- package/src/index.ts +628 -206
- package/src/init/__tests__/generators.spec.ts +334 -334
- package/src/init/__tests__/init.spec.ts +332 -332
- package/src/init/__tests__/utils.spec.ts +89 -89
- package/src/init/generators/config.ts +175 -175
- package/src/init/generators/docker.ts +41 -41
- package/src/init/generators/env.ts +72 -72
- package/src/init/generators/index.ts +1 -1
- package/src/init/generators/models.ts +64 -64
- package/src/init/generators/monorepo.ts +161 -161
- package/src/init/generators/package.ts +71 -71
- package/src/init/generators/source.ts +6 -6
- package/src/init/index.ts +203 -208
- package/src/init/templates/api.ts +115 -115
- package/src/init/templates/index.ts +75 -75
- package/src/init/templates/minimal.ts +98 -98
- package/src/init/templates/serverless.ts +89 -89
- package/src/init/templates/worker.ts +98 -98
- package/src/init/utils.ts +54 -56
- package/src/openapi-react-query.ts +194 -194
- package/src/openapi.ts +63 -63
- package/src/secrets/__tests__/encryption.spec.ts +226 -0
- package/src/secrets/__tests__/generator.spec.ts +319 -0
- package/src/secrets/__tests__/index.spec.ts +91 -0
- package/src/secrets/__tests__/storage.spec.ts +403 -0
- package/src/secrets/encryption.ts +91 -0
- package/src/secrets/generator.ts +164 -0
- package/src/secrets/index.ts +383 -0
- package/src/secrets/storage.ts +134 -0
- package/src/secrets/types.ts +53 -0
- package/src/types.ts +295 -176
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +11 -8
- package/dist/config-Bq72aj8e.mjs.map +0 -1
- package/dist/config-CFls09Ey.cjs.map +0 -1
- package/dist/openapi--vOy9mo4.mjs.map +0 -1
- package/dist/openapi-CHhTPief.cjs.map +0 -1
- package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
- package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
|
@@ -3,344 +3,344 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { itWithDir } from '@geekmidas/testkit/os';
|
|
4
4
|
import { describe, expect, vi } from 'vitest';
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
CronInfo,
|
|
7
|
+
FunctionInfo,
|
|
8
|
+
RouteInfo,
|
|
9
|
+
SubscriberInfo,
|
|
10
10
|
} from '../../types';
|
|
11
11
|
import { generateAwsManifest, generateServerManifest } from '../manifests';
|
|
12
12
|
|
|
13
13
|
describe('generateAwsManifest', () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
14
|
+
itWithDir('should generate AWS manifest with routes', async ({ dir }) => {
|
|
15
|
+
const routes: RouteInfo[] = [
|
|
16
|
+
{
|
|
17
|
+
path: '/users',
|
|
18
|
+
method: 'GET',
|
|
19
|
+
handler: '.gkm/aws/getUsers.handler',
|
|
20
|
+
authorizer: 'jwt',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: '/users',
|
|
24
|
+
method: 'POST',
|
|
25
|
+
handler: '.gkm/aws/createUser.handler',
|
|
26
|
+
authorizer: 'jwt',
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
await generateAwsManifest(dir, routes, [], [], []);
|
|
31
|
+
|
|
32
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
33
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
34
|
+
|
|
35
|
+
expect(content).toContain('export const manifest = {');
|
|
36
|
+
expect(content).toContain('} as const;');
|
|
37
|
+
expect(content).toContain('/users');
|
|
38
|
+
expect(content).toContain('GET');
|
|
39
|
+
expect(content).toContain('POST');
|
|
40
|
+
expect(content).toContain('jwt');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
itWithDir(
|
|
44
|
+
'should filter out ALL method routes from AWS manifest',
|
|
45
|
+
async ({ dir }) => {
|
|
46
|
+
const routes: RouteInfo[] = [
|
|
47
|
+
{
|
|
48
|
+
path: '/users',
|
|
49
|
+
method: 'GET',
|
|
50
|
+
handler: '.gkm/aws/getUsers.handler',
|
|
51
|
+
authorizer: 'jwt',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
path: '*',
|
|
55
|
+
method: 'ALL',
|
|
56
|
+
handler: '.gkm/server/app.ts',
|
|
57
|
+
authorizer: 'none',
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
await generateAwsManifest(dir, routes, [], [], []);
|
|
62
|
+
|
|
63
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
64
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
65
|
+
|
|
66
|
+
expect(content).toContain('/users');
|
|
67
|
+
expect(content).toContain('GET');
|
|
68
|
+
expect(content).not.toContain('"ALL"');
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
itWithDir('should generate AWS manifest with functions', async ({ dir }) => {
|
|
73
|
+
const functions: FunctionInfo[] = [
|
|
74
|
+
{
|
|
75
|
+
name: 'processData',
|
|
76
|
+
handler: '.gkm/aws/processData.handler',
|
|
77
|
+
timeout: 300,
|
|
78
|
+
memorySize: 512,
|
|
79
|
+
environment: ['DATABASE_URL'],
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
await generateAwsManifest(dir, [], functions, [], []);
|
|
84
|
+
|
|
85
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
86
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
87
|
+
|
|
88
|
+
expect(content).toContain('processData');
|
|
89
|
+
expect(content).toContain('300');
|
|
90
|
+
expect(content).toContain('512');
|
|
91
|
+
expect(content).toContain('DATABASE_URL');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
itWithDir('should generate AWS manifest with crons', async ({ dir }) => {
|
|
95
|
+
const crons: CronInfo[] = [
|
|
96
|
+
{
|
|
97
|
+
name: 'dailyCleanup',
|
|
98
|
+
handler: '.gkm/aws/dailyCleanup.handler',
|
|
99
|
+
schedule: 'rate(1 day)',
|
|
100
|
+
timeout: 300,
|
|
101
|
+
memorySize: 256,
|
|
102
|
+
environment: [],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
await generateAwsManifest(dir, [], [], crons, []);
|
|
107
|
+
|
|
108
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
109
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
110
|
+
|
|
111
|
+
expect(content).toContain('dailyCleanup');
|
|
112
|
+
expect(content).toContain('rate(1 day)');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
itWithDir(
|
|
116
|
+
'should generate AWS manifest with subscribers',
|
|
117
|
+
async ({ dir }) => {
|
|
118
|
+
const subscribers: SubscriberInfo[] = [
|
|
119
|
+
{
|
|
120
|
+
name: 'orderHandler',
|
|
121
|
+
handler: '.gkm/aws/orderHandler.handler',
|
|
122
|
+
subscribedEvents: ['order.created', 'order.updated'],
|
|
123
|
+
timeout: 30,
|
|
124
|
+
memorySize: 256,
|
|
125
|
+
environment: [],
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
await generateAwsManifest(dir, [], [], [], subscribers);
|
|
130
|
+
|
|
131
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
132
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
133
|
+
|
|
134
|
+
expect(content).toContain('orderHandler');
|
|
135
|
+
expect(content).toContain('order.created');
|
|
136
|
+
expect(content).toContain('order.updated');
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
itWithDir('should export derived types', async ({ dir }) => {
|
|
141
|
+
await generateAwsManifest(dir, [], [], [], []);
|
|
142
|
+
|
|
143
|
+
const manifestPath = join(dir, 'manifest', 'aws.ts');
|
|
144
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
145
|
+
|
|
146
|
+
expect(content).toContain('export type Route =');
|
|
147
|
+
expect(content).toContain('export type Function =');
|
|
148
|
+
expect(content).toContain('export type Cron =');
|
|
149
|
+
expect(content).toContain('export type Subscriber =');
|
|
150
|
+
expect(content).toContain('export type Authorizer =');
|
|
151
|
+
expect(content).toContain('export type HttpMethod =');
|
|
152
|
+
expect(content).toContain('export type RoutePath =');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
itWithDir('should log manifest generation info', async ({ dir }) => {
|
|
156
|
+
const logSpy = vi.spyOn(console, 'log');
|
|
157
|
+
|
|
158
|
+
const routes: RouteInfo[] = [
|
|
159
|
+
{
|
|
160
|
+
path: '/users',
|
|
161
|
+
method: 'GET',
|
|
162
|
+
handler: '.gkm/aws/getUsers.handler',
|
|
163
|
+
authorizer: 'jwt',
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
await generateAwsManifest(dir, routes, [], [], []);
|
|
168
|
+
|
|
169
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
170
|
+
'Generated AWS manifest with 1 routes, 0 functions, 0 crons, 0 subscribers',
|
|
171
|
+
);
|
|
172
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Manifest:'));
|
|
173
|
+
|
|
174
|
+
logSpy.mockRestore();
|
|
175
|
+
});
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
describe('generateServerManifest', () => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
179
|
+
itWithDir(
|
|
180
|
+
'should generate server manifest with app info',
|
|
181
|
+
async ({ dir }) => {
|
|
182
|
+
const appInfo = {
|
|
183
|
+
handler: '.gkm/server/app.ts',
|
|
184
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
await generateServerManifest(dir, appInfo, [], []);
|
|
188
|
+
|
|
189
|
+
const manifestPath = join(dir, 'manifest', 'server.ts');
|
|
190
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
191
|
+
|
|
192
|
+
expect(content).toContain('export const manifest = {');
|
|
193
|
+
expect(content).toContain('} as const;');
|
|
194
|
+
expect(content).toContain('app:');
|
|
195
|
+
expect(content).toContain('.gkm/server/app.ts');
|
|
196
|
+
expect(content).toContain('.gkm/server/endpoints.ts');
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
itWithDir(
|
|
201
|
+
'should generate server manifest with route metadata',
|
|
202
|
+
async ({ dir }) => {
|
|
203
|
+
const appInfo = {
|
|
204
|
+
handler: '.gkm/server/app.ts',
|
|
205
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const routes: RouteInfo[] = [
|
|
209
|
+
{
|
|
210
|
+
path: '/users',
|
|
211
|
+
method: 'GET',
|
|
212
|
+
handler: '', // Not used for server
|
|
213
|
+
authorizer: 'jwt',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
path: '/posts',
|
|
217
|
+
method: 'POST',
|
|
218
|
+
handler: '',
|
|
219
|
+
authorizer: 'apiKey',
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
await generateServerManifest(dir, appInfo, routes, []);
|
|
224
|
+
|
|
225
|
+
const manifestPath = join(dir, 'manifest', 'server.ts');
|
|
226
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
227
|
+
|
|
228
|
+
expect(content).toContain('/users');
|
|
229
|
+
expect(content).toContain('/posts');
|
|
230
|
+
expect(content).toContain('GET');
|
|
231
|
+
expect(content).toContain('POST');
|
|
232
|
+
expect(content).toContain('jwt');
|
|
233
|
+
expect(content).toContain('apiKey');
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
itWithDir(
|
|
238
|
+
'should filter out ALL method routes from server manifest',
|
|
239
|
+
async ({ dir }) => {
|
|
240
|
+
const appInfo = {
|
|
241
|
+
handler: '.gkm/server/app.ts',
|
|
242
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const routes: RouteInfo[] = [
|
|
246
|
+
{
|
|
247
|
+
path: '/users',
|
|
248
|
+
method: 'GET',
|
|
249
|
+
handler: '',
|
|
250
|
+
authorizer: 'jwt',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
path: '*',
|
|
254
|
+
method: 'ALL',
|
|
255
|
+
handler: '',
|
|
256
|
+
authorizer: 'none',
|
|
257
|
+
},
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
await generateServerManifest(dir, appInfo, routes, []);
|
|
261
|
+
|
|
262
|
+
const manifestPath = join(dir, 'manifest', 'server.ts');
|
|
263
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
264
|
+
|
|
265
|
+
expect(content).toContain('/users');
|
|
266
|
+
expect(content).not.toContain('"ALL"');
|
|
267
|
+
},
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
itWithDir(
|
|
271
|
+
'should generate server manifest with subscribers',
|
|
272
|
+
async ({ dir }) => {
|
|
273
|
+
const appInfo = {
|
|
274
|
+
handler: '.gkm/server/app.ts',
|
|
275
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const subscribers: SubscriberInfo[] = [
|
|
279
|
+
{
|
|
280
|
+
name: 'orderHandler',
|
|
281
|
+
handler: '.gkm/server/orderHandler.ts',
|
|
282
|
+
subscribedEvents: ['order.created'],
|
|
283
|
+
timeout: 30,
|
|
284
|
+
memorySize: 256,
|
|
285
|
+
environment: [],
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
|
|
289
|
+
await generateServerManifest(dir, appInfo, [], subscribers);
|
|
290
|
+
|
|
291
|
+
const manifestPath = join(dir, 'manifest', 'server.ts');
|
|
292
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
293
|
+
|
|
294
|
+
// Server manifest only includes name and events for subscribers
|
|
295
|
+
expect(content).toContain('orderHandler');
|
|
296
|
+
expect(content).toContain('order.created');
|
|
297
|
+
// Should not include handler path in server manifest subscribers
|
|
298
|
+
expect(content).not.toContain('.gkm/server/orderHandler.ts');
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
itWithDir('should export derived types for server', async ({ dir }) => {
|
|
303
|
+
const appInfo = {
|
|
304
|
+
handler: '.gkm/server/app.ts',
|
|
305
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
await generateServerManifest(dir, appInfo, [], []);
|
|
309
|
+
|
|
310
|
+
const manifestPath = join(dir, 'manifest', 'server.ts');
|
|
311
|
+
const content = await readFile(manifestPath, 'utf-8');
|
|
312
|
+
|
|
313
|
+
expect(content).toContain('export type Route =');
|
|
314
|
+
expect(content).toContain('export type Subscriber =');
|
|
315
|
+
expect(content).toContain('export type Authorizer =');
|
|
316
|
+
expect(content).toContain('export type HttpMethod =');
|
|
317
|
+
expect(content).toContain('export type RoutePath =');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
itWithDir('should log manifest generation info', async ({ dir }) => {
|
|
321
|
+
const logSpy = vi.spyOn(console, 'log');
|
|
322
|
+
|
|
323
|
+
const appInfo = {
|
|
324
|
+
handler: '.gkm/server/app.ts',
|
|
325
|
+
endpoints: '.gkm/server/endpoints.ts',
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const routes: RouteInfo[] = [
|
|
329
|
+
{
|
|
330
|
+
path: '/users',
|
|
331
|
+
method: 'GET',
|
|
332
|
+
handler: '',
|
|
333
|
+
authorizer: 'jwt',
|
|
334
|
+
},
|
|
335
|
+
];
|
|
336
|
+
|
|
337
|
+
await generateServerManifest(dir, appInfo, routes, []);
|
|
338
|
+
|
|
339
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
340
|
+
'Generated server manifest with 1 routes, 0 subscribers',
|
|
341
|
+
);
|
|
342
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Manifest:'));
|
|
343
|
+
|
|
344
|
+
logSpy.mockRestore();
|
|
345
|
+
});
|
|
346
346
|
});
|