@objectstack/sveltekit 3.2.8 → 3.3.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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +12 -0
- package/package.json +3 -3
- package/src/sveltekit.test.ts +21 -17
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/sveltekit@3.
|
|
2
|
+
> @objectstack/sveltekit@3.3.0 build /home/runner/work/spec/spec/packages/adapters/sveltekit
|
|
3
3
|
> tsup --config ../../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[32mESM[39m [1mdist/index.mjs [22m[32m4.50 KB[39m
|
|
14
14
|
[32mESM[39m [1mdist/index.mjs.map [22m[32m10.35 KB[39m
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 73ms
|
|
16
16
|
[32mCJS[39m [1mdist/index.js [22m[32m5.56 KB[39m
|
|
17
17
|
[32mCJS[39m [1mdist/index.js.map [22m[32m10.39 KB[39m
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 79ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 13264ms
|
|
21
21
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.65 KB[39m
|
|
22
22
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.65 KB[39m
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/sveltekit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@sveltejs/kit": "^2.55.0",
|
|
16
|
-
"@objectstack/runtime": "^3.
|
|
16
|
+
"@objectstack/runtime": "^3.3.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@sveltejs/kit": "^2.55.0",
|
|
20
20
|
"typescript": "^5.0.0",
|
|
21
21
|
"vitest": "^4.1.0",
|
|
22
|
-
"@objectstack/runtime": "3.
|
|
22
|
+
"@objectstack/runtime": "3.3.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsup --config ../../../tsup.config.ts",
|
package/src/sveltekit.test.ts
CHANGED
|
@@ -7,9 +7,8 @@ const mockDispatcher = {
|
|
|
7
7
|
getDiscoveryInfo: vi.fn().mockReturnValue({ version: '1.0', endpoints: [] }),
|
|
8
8
|
handleAuth: vi.fn().mockResolvedValue({ handled: true, response: { body: { ok: true }, status: 200 } }),
|
|
9
9
|
handleGraphQL: vi.fn().mockResolvedValue({ data: {} }),
|
|
10
|
-
handleMetadata: vi.fn().mockResolvedValue({ handled: true, response: { body: { objects: [] }, status: 200 } }),
|
|
11
|
-
handleData: vi.fn().mockResolvedValue({ handled: true, response: { body: { records: [] }, status: 200 } }),
|
|
12
10
|
handleStorage: vi.fn().mockResolvedValue({ handled: true, response: { body: {}, status: 200 } }),
|
|
11
|
+
dispatch: vi.fn().mockResolvedValue({ handled: true, response: { body: { success: true }, status: 200 } }),
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
vi.mock('@objectstack/runtime', () => {
|
|
@@ -167,27 +166,29 @@ describe('createRequestHandler', () => {
|
|
|
167
166
|
});
|
|
168
167
|
|
|
169
168
|
describe('Metadata', () => {
|
|
170
|
-
it('GET /api/meta/objects
|
|
169
|
+
it('GET /api/meta/objects delegates to dispatch()', async () => {
|
|
171
170
|
const event = makeEvent('http://localhost/api/meta/objects');
|
|
172
171
|
const res = await handler(event);
|
|
173
172
|
expect(res.status).toBe(200);
|
|
174
|
-
expect(mockDispatcher.
|
|
175
|
-
'
|
|
173
|
+
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
|
|
174
|
+
'GET',
|
|
175
|
+
'/meta/objects',
|
|
176
|
+
undefined,
|
|
177
|
+
expect.any(Object),
|
|
176
178
|
expect.objectContaining({ request: expect.anything() }),
|
|
177
|
-
'GET', undefined,
|
|
178
179
|
);
|
|
179
180
|
});
|
|
180
181
|
});
|
|
181
182
|
|
|
182
183
|
describe('Data', () => {
|
|
183
|
-
it('GET /api/data/account
|
|
184
|
+
it('GET /api/data/account delegates to dispatch()', async () => {
|
|
184
185
|
const event = makeEvent('http://localhost/api/data/account');
|
|
185
186
|
const res = await handler(event);
|
|
186
187
|
expect(res.status).toBe(200);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
|
|
189
|
+
'GET',
|
|
190
|
+
'/data/account',
|
|
191
|
+
undefined,
|
|
191
192
|
expect.any(Object),
|
|
192
193
|
expect.objectContaining({ request: expect.anything() }),
|
|
193
194
|
);
|
|
@@ -198,15 +199,17 @@ describe('createRequestHandler', () => {
|
|
|
198
199
|
const event = makeEvent('http://localhost/api/data/account', 'POST', body);
|
|
199
200
|
const res = await handler(event);
|
|
200
201
|
expect(res.status).toBe(200);
|
|
201
|
-
expect(mockDispatcher.
|
|
202
|
-
'
|
|
202
|
+
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
|
|
203
|
+
'POST',
|
|
204
|
+
'/data/account',
|
|
205
|
+
body,
|
|
203
206
|
expect.any(Object),
|
|
204
207
|
expect.objectContaining({ request: expect.anything() }),
|
|
205
208
|
);
|
|
206
209
|
});
|
|
207
210
|
|
|
208
211
|
it('returns 404 when not handled', async () => {
|
|
209
|
-
mockDispatcher.
|
|
212
|
+
mockDispatcher.dispatch.mockResolvedValueOnce({ handled: false });
|
|
210
213
|
const event = makeEvent('http://localhost/api/data/missing');
|
|
211
214
|
const res = await handler(event);
|
|
212
215
|
expect(res.status).toBe(404);
|
|
@@ -227,13 +230,14 @@ describe('createRequestHandler', () => {
|
|
|
227
230
|
|
|
228
231
|
describe('Error handling', () => {
|
|
229
232
|
it('returns 404 for unknown routes', async () => {
|
|
233
|
+
mockDispatcher.dispatch.mockResolvedValueOnce({ handled: false });
|
|
230
234
|
const event = makeEvent('http://localhost/api/unknown');
|
|
231
235
|
const res = await handler(event);
|
|
232
236
|
expect(res.status).toBe(404);
|
|
233
237
|
});
|
|
234
238
|
|
|
235
239
|
it('returns 500 on generic error', async () => {
|
|
236
|
-
mockDispatcher.
|
|
240
|
+
mockDispatcher.dispatch.mockRejectedValueOnce(new Error());
|
|
237
241
|
const event = makeEvent('http://localhost/api/data/account');
|
|
238
242
|
const res = await handler(event);
|
|
239
243
|
expect(res.status).toBe(500);
|
|
@@ -242,7 +246,7 @@ describe('createRequestHandler', () => {
|
|
|
242
246
|
|
|
243
247
|
describe('toResponse', () => {
|
|
244
248
|
it('handles redirect result', async () => {
|
|
245
|
-
mockDispatcher.
|
|
249
|
+
mockDispatcher.dispatch.mockResolvedValueOnce({
|
|
246
250
|
handled: true,
|
|
247
251
|
result: { type: 'redirect', url: 'https://example.com' },
|
|
248
252
|
});
|
|
@@ -253,7 +257,7 @@ describe('createRequestHandler', () => {
|
|
|
253
257
|
});
|
|
254
258
|
|
|
255
259
|
it('handles generic result objects', async () => {
|
|
256
|
-
mockDispatcher.
|
|
260
|
+
mockDispatcher.dispatch.mockResolvedValueOnce({
|
|
257
261
|
handled: true,
|
|
258
262
|
result: { foo: 'bar' },
|
|
259
263
|
});
|