@fragno-dev/core 0.1.7 → 0.1.9
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 +131 -64
- package/CHANGELOG.md +19 -0
- package/dist/api/api.d.ts +38 -2
- package/dist/api/api.d.ts.map +1 -0
- package/dist/api/api.js +9 -2
- package/dist/api/api.js.map +1 -0
- package/dist/api/bind-services.d.ts +6 -0
- package/dist/api/bind-services.d.ts.map +1 -0
- package/dist/api/bind-services.js +20 -0
- package/dist/api/bind-services.js.map +1 -0
- package/dist/api/error.d.ts +26 -0
- package/dist/api/error.d.ts.map +1 -0
- package/dist/{api-DngJDcmO.js → api/error.js} +2 -8
- package/dist/api/error.js.map +1 -0
- package/dist/api/fragment-definition-builder.d.ts +313 -0
- package/dist/api/fragment-definition-builder.d.ts.map +1 -0
- package/dist/api/fragment-definition-builder.js +326 -0
- package/dist/api/fragment-definition-builder.js.map +1 -0
- package/dist/api/fragment-instantiator.d.ts +216 -0
- package/dist/api/fragment-instantiator.d.ts.map +1 -0
- package/dist/api/fragment-instantiator.js +487 -0
- package/dist/api/fragment-instantiator.js.map +1 -0
- package/dist/api/fragno-response.d.ts +30 -0
- package/dist/api/fragno-response.d.ts.map +1 -0
- package/dist/api/fragno-response.js +73 -0
- package/dist/api/fragno-response.js.map +1 -0
- package/dist/api/internal/path.d.ts +50 -0
- package/dist/api/internal/path.d.ts.map +1 -0
- package/dist/api/internal/path.js +76 -0
- package/dist/api/internal/path.js.map +1 -0
- package/dist/api/internal/response-stream.d.ts +43 -0
- package/dist/api/internal/response-stream.d.ts.map +1 -0
- package/dist/api/internal/response-stream.js +81 -0
- package/dist/api/internal/response-stream.js.map +1 -0
- package/dist/api/internal/route.js +10 -0
- package/dist/api/internal/route.js.map +1 -0
- package/dist/api/mutable-request-state.d.ts +82 -0
- package/dist/api/mutable-request-state.d.ts.map +1 -0
- package/dist/api/mutable-request-state.js +97 -0
- package/dist/api/mutable-request-state.js.map +1 -0
- package/dist/api/request-context-storage.d.ts +42 -0
- package/dist/api/request-context-storage.d.ts.map +1 -0
- package/dist/api/request-context-storage.js +43 -0
- package/dist/api/request-context-storage.js.map +1 -0
- package/dist/api/request-input-context.d.ts +89 -0
- package/dist/api/request-input-context.d.ts.map +1 -0
- package/dist/api/request-input-context.js +118 -0
- package/dist/api/request-input-context.js.map +1 -0
- package/dist/api/request-middleware.d.ts +50 -0
- package/dist/api/request-middleware.d.ts.map +1 -0
- package/dist/api/request-middleware.js +83 -0
- package/dist/api/request-middleware.js.map +1 -0
- package/dist/api/request-output-context.d.ts +41 -0
- package/dist/api/request-output-context.d.ts.map +1 -0
- package/dist/api/request-output-context.js +119 -0
- package/dist/api/request-output-context.js.map +1 -0
- package/dist/api/route-handler-input-options.d.ts +21 -0
- package/dist/api/route-handler-input-options.d.ts.map +1 -0
- package/dist/api/route.d.ts +54 -3
- package/dist/api/route.d.ts.map +1 -0
- package/dist/api/route.js +29 -2
- package/dist/api/route.js.map +1 -0
- package/dist/api/shared-types.d.ts +47 -0
- package/dist/api/shared-types.d.ts.map +1 -0
- package/dist/api/shared-types.js +1 -0
- package/dist/client/client-error.d.ts +60 -0
- package/dist/client/client-error.d.ts.map +1 -0
- package/dist/client/client-error.js +92 -0
- package/dist/client/client-error.js.map +1 -0
- package/dist/client/client.d.ts +210 -4
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +397 -6
- package/dist/client/client.js.map +1 -0
- package/dist/client/client.svelte.d.ts +5 -3
- package/dist/client/client.svelte.d.ts.map +1 -1
- package/dist/client/client.svelte.js +1 -5
- package/dist/client/client.svelte.js.map +1 -1
- package/dist/client/internal/fetcher-merge.js +36 -0
- package/dist/client/internal/fetcher-merge.js.map +1 -0
- package/dist/client/internal/ndjson-streaming.js +139 -0
- package/dist/client/internal/ndjson-streaming.js.map +1 -0
- package/dist/client/react.d.ts +5 -3
- package/dist/client/react.d.ts.map +1 -1
- package/dist/client/react.js +3 -5
- package/dist/client/react.js.map +1 -1
- package/dist/client/solid.d.ts +5 -3
- package/dist/client/solid.d.ts.map +1 -1
- package/dist/client/solid.js +2 -5
- package/dist/client/solid.js.map +1 -1
- package/dist/client/vanilla.d.ts +5 -3
- package/dist/client/vanilla.d.ts.map +1 -1
- package/dist/client/vanilla.js +2 -43
- package/dist/client/vanilla.js.map +1 -1
- package/dist/client/vue.d.ts +5 -3
- package/dist/client/vue.d.ts.map +1 -1
- package/dist/client/vue.js +1 -5
- package/dist/client/vue.js.map +1 -1
- package/dist/http/http-status.d.ts +26 -0
- package/dist/http/http-status.d.ts.map +1 -0
- package/dist/integrations/react-ssr.js +1 -1
- package/dist/internal/symbols.d.ts +9 -0
- package/dist/internal/symbols.d.ts.map +1 -0
- package/dist/internal/symbols.js +10 -0
- package/dist/internal/symbols.js.map +1 -0
- package/dist/mod-client.d.ts +36 -0
- package/dist/mod-client.d.ts.map +1 -0
- package/dist/mod-client.js +21 -0
- package/dist/mod-client.js.map +1 -0
- package/dist/mod.d.ts +7 -4
- package/dist/mod.js +4 -6
- package/dist/request/request.d.ts +4 -0
- package/dist/request/request.js +5 -0
- package/dist/test/test.d.ts +62 -35
- package/dist/test/test.d.ts.map +1 -1
- package/dist/test/test.js +75 -40
- package/dist/test/test.js.map +1 -1
- package/dist/util/async.js +40 -0
- package/dist/util/async.js.map +1 -0
- package/dist/util/content-type.js +49 -0
- package/dist/util/content-type.js.map +1 -0
- package/dist/util/nanostores.js +31 -0
- package/dist/util/nanostores.js.map +1 -0
- package/dist/{ssr-BByDVfFD.js → util/ssr.js} +2 -2
- package/dist/util/ssr.js.map +1 -0
- package/dist/util/types-util.d.ts +8 -0
- package/dist/util/types-util.d.ts.map +1 -0
- package/package.json +19 -12
- package/src/api/api.ts +41 -6
- package/src/api/bind-services.ts +42 -0
- package/src/api/fragment-definition-builder.extend.test.ts +810 -0
- package/src/api/fragment-definition-builder.test.ts +499 -0
- package/src/api/fragment-definition-builder.ts +1088 -0
- package/src/api/fragment-instantiator.test.ts +1488 -0
- package/src/api/fragment-instantiator.ts +1053 -0
- package/src/api/fragment-services.test.ts +727 -0
- package/src/api/request-context-storage.ts +64 -0
- package/src/api/request-middleware.test.ts +301 -225
- package/src/api/route.test.ts +87 -1
- package/src/api/route.ts +345 -24
- package/src/api/shared-types.ts +43 -0
- package/src/client/client-builder.test.ts +23 -23
- package/src/client/client.ssr.test.ts +3 -3
- package/src/client/client.svelte.test.ts +15 -15
- package/src/client/client.test.ts +22 -22
- package/src/client/client.ts +72 -12
- package/src/client/internal/fetcher-merge.ts +1 -1
- package/src/client/react.test.ts +2 -2
- package/src/client/solid.test.ts +2 -2
- package/src/client/vanilla.test.ts +2 -2
- package/src/client/vue.test.ts +2 -2
- package/src/internal/symbols.ts +5 -0
- package/src/mod-client.ts +59 -0
- package/src/mod.ts +26 -9
- package/src/request/request.ts +8 -0
- package/src/test/test.test.ts +200 -381
- package/src/test/test.ts +190 -117
- package/tsdown.config.ts +8 -5
- package/dist/api/fragment-builder.d.ts +0 -4
- package/dist/api/fragment-builder.js +0 -3
- package/dist/api/fragment-instantiation.d.ts +0 -4
- package/dist/api/fragment-instantiation.js +0 -6
- package/dist/api-BWN97TOr.d.ts +0 -377
- package/dist/api-BWN97TOr.d.ts.map +0 -1
- package/dist/api-DngJDcmO.js.map +0 -1
- package/dist/client-C5LsYHEI.js +0 -782
- package/dist/client-C5LsYHEI.js.map +0 -1
- package/dist/fragment-builder-DOnCVBqc.js +0 -47
- package/dist/fragment-builder-DOnCVBqc.js.map +0 -1
- package/dist/fragment-builder-MGr68GNb.d.ts +0 -409
- package/dist/fragment-builder-MGr68GNb.d.ts.map +0 -1
- package/dist/fragment-instantiation-C4wvwl6V.js +0 -446
- package/dist/fragment-instantiation-C4wvwl6V.js.map +0 -1
- package/dist/request-output-context-CdIjwmEN.js +0 -320
- package/dist/request-output-context-CdIjwmEN.js.map +0 -1
- package/dist/route-Bl9Zr1Yv.d.ts +0 -26
- package/dist/route-Bl9Zr1Yv.d.ts.map +0 -1
- package/dist/route-C5Uryylh.js +0 -21
- package/dist/route-C5Uryylh.js.map +0 -1
- package/dist/ssr-BByDVfFD.js.map +0 -1
- package/src/api/fragment-builder.ts +0 -80
- package/src/api/fragment-instantiation.test.ts +0 -460
- package/src/api/fragment-instantiation.ts +0 -499
- package/src/api/fragment.test.ts +0 -537
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { test, expect, expectTypeOf, describe } from "vitest";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createClientBuilder } from "./client";
|
|
4
|
-
import {
|
|
5
|
-
import { defineFragment } from "../api/fragment-builder";
|
|
6
|
-
import type { FragnoPublicClientConfig } from "../api/
|
|
4
|
+
import { defineRoute } from "../api/route";
|
|
5
|
+
import { defineFragment } from "../api/fragment-definition-builder";
|
|
6
|
+
import type { FragnoPublicClientConfig } from "../api/shared-types";
|
|
7
7
|
|
|
8
8
|
// Test route configurations
|
|
9
|
-
const testFragment = defineFragment("test-fragment");
|
|
9
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
10
10
|
const testRoutes = [
|
|
11
11
|
// GET routes
|
|
12
|
-
|
|
12
|
+
defineRoute({
|
|
13
13
|
method: "GET",
|
|
14
14
|
path: "/home",
|
|
15
15
|
outputSchema: z.string(),
|
|
16
16
|
handler: async (_ctx, { json }) => json("ok"),
|
|
17
17
|
}),
|
|
18
|
-
|
|
18
|
+
defineRoute({
|
|
19
19
|
method: "GET",
|
|
20
20
|
path: "/users",
|
|
21
21
|
outputSchema: z.array(z.object({ id: z.number(), name: z.string() })),
|
|
22
22
|
handler: async (_ctx, { json }) => json([{ id: 1, name: "" }]),
|
|
23
23
|
}),
|
|
24
|
-
|
|
24
|
+
defineRoute({
|
|
25
25
|
method: "GET",
|
|
26
26
|
path: "/users/:id" as const,
|
|
27
27
|
outputSchema: z.object({ id: z.number(), name: z.string() }),
|
|
28
28
|
handler: async ({ pathParams }, { json }) => json({ id: Number(pathParams.id), name: "" }),
|
|
29
29
|
}),
|
|
30
|
-
|
|
30
|
+
defineRoute({
|
|
31
31
|
method: "GET",
|
|
32
32
|
path: "/ai-config",
|
|
33
33
|
outputSchema: z.object({
|
|
@@ -43,14 +43,14 @@ const testRoutes = [
|
|
|
43
43
|
}),
|
|
44
44
|
}),
|
|
45
45
|
// Non-GET routes (should not be available for hooks)
|
|
46
|
-
|
|
46
|
+
defineRoute({
|
|
47
47
|
method: "POST",
|
|
48
48
|
path: "/users",
|
|
49
49
|
inputSchema: z.object({ name: z.string() }),
|
|
50
50
|
outputSchema: z.object({ id: z.number(), name: z.string() }),
|
|
51
51
|
handler: async (_ctx, { json }) => json({ id: 1, name: "" }),
|
|
52
52
|
}),
|
|
53
|
-
|
|
53
|
+
defineRoute({
|
|
54
54
|
method: "PUT",
|
|
55
55
|
path: "/users/:id",
|
|
56
56
|
inputSchema: z.object({ name: z.string() }),
|
|
@@ -58,7 +58,7 @@ const testRoutes = [
|
|
|
58
58
|
return empty();
|
|
59
59
|
},
|
|
60
60
|
}),
|
|
61
|
-
|
|
61
|
+
defineRoute({
|
|
62
62
|
method: "DELETE",
|
|
63
63
|
path: "/users/:id",
|
|
64
64
|
handler: async (_ctx, { empty }) => {
|
|
@@ -73,18 +73,18 @@ const testPublicConfig: FragnoPublicClientConfig = {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
// Empty fragment config for edge case testing
|
|
76
|
-
const _emptyFragment = defineFragment("empty-fragment");
|
|
76
|
+
const _emptyFragment = defineFragment("empty-fragment").build();
|
|
77
77
|
const _emptyRoutes = [] as const;
|
|
78
78
|
|
|
79
79
|
// Fragment config with no GET routes
|
|
80
|
-
const noGetFragment = defineFragment("no-get-fragment");
|
|
80
|
+
const noGetFragment = defineFragment("no-get-fragment").build();
|
|
81
81
|
const noGetRoutes = [
|
|
82
|
-
|
|
82
|
+
defineRoute({
|
|
83
83
|
method: "POST",
|
|
84
84
|
path: "/create",
|
|
85
85
|
handler: async (_ctx, { json }) => json({}),
|
|
86
86
|
}),
|
|
87
|
-
|
|
87
|
+
defineRoute({
|
|
88
88
|
method: "DELETE",
|
|
89
89
|
path: "/delete/:id",
|
|
90
90
|
handler: async (_ctx, { empty }) => {
|
|
@@ -141,15 +141,15 @@ describe("Hook builder (createHookBuilder) and createFragmentHook", () => {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
test("should handle complex route paths", () => {
|
|
144
|
-
const complexFragment = defineFragment("complex-fragment");
|
|
144
|
+
const complexFragment = defineFragment("complex-fragment").build();
|
|
145
145
|
const complexRoutes = [
|
|
146
|
-
|
|
146
|
+
defineRoute({
|
|
147
147
|
method: "GET",
|
|
148
148
|
path: "/api/v1/users/:userId/posts/:postId/comments/:commentId",
|
|
149
149
|
outputSchema: z.object({ id: z.number(), content: z.string() }),
|
|
150
150
|
handler: async (_ctx, { json }) => json({ id: 1, content: "" }),
|
|
151
151
|
}),
|
|
152
|
-
|
|
152
|
+
defineRoute({
|
|
153
153
|
method: "GET",
|
|
154
154
|
path: "/files/**:filepath",
|
|
155
155
|
outputSchema: z.string(),
|
|
@@ -194,30 +194,30 @@ describe("type safety tests", () => {
|
|
|
194
194
|
|
|
195
195
|
describe("real-world usage scenarios", () => {
|
|
196
196
|
test("should work with Chatno-like configuration", () => {
|
|
197
|
-
const chatnoFragment = defineFragment("chatno");
|
|
197
|
+
const chatnoFragment = defineFragment("chatno").build();
|
|
198
198
|
const chatnoRoutes = [
|
|
199
|
-
|
|
199
|
+
defineRoute({
|
|
200
200
|
method: "GET",
|
|
201
201
|
path: "/home",
|
|
202
202
|
handler: async (_ctx, { empty }) => {
|
|
203
203
|
return empty();
|
|
204
204
|
},
|
|
205
205
|
}),
|
|
206
|
-
|
|
206
|
+
defineRoute({
|
|
207
207
|
method: "GET",
|
|
208
208
|
path: "/thing/**:path",
|
|
209
209
|
handler: async (_ctx, { empty }) => {
|
|
210
210
|
return empty();
|
|
211
211
|
},
|
|
212
212
|
}),
|
|
213
|
-
|
|
213
|
+
defineRoute({
|
|
214
214
|
method: "POST",
|
|
215
215
|
path: "/echo",
|
|
216
216
|
inputSchema: z.object({ number: z.number() }),
|
|
217
217
|
outputSchema: z.string(),
|
|
218
218
|
handler: async (_ctx, { json }) => json(""),
|
|
219
219
|
}),
|
|
220
|
-
|
|
220
|
+
defineRoute({
|
|
221
221
|
method: "GET",
|
|
222
222
|
path: "/ai-config",
|
|
223
223
|
outputSchema: z.object({
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { type FragnoPublicClientConfig } from "
|
|
10
|
+
import { type FragnoPublicClientConfig } from "./client";
|
|
11
11
|
import { createClientBuilder } from "./client";
|
|
12
12
|
import { defineRoute } from "../api/route";
|
|
13
|
-
import { defineFragment } from "../api/fragment-builder";
|
|
13
|
+
import { defineFragment } from "../api/fragment-definition-builder";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
import { createAsyncIteratorFromCallback, waitForAsyncIterator } from "../util/async";
|
|
16
16
|
|
|
17
17
|
describe("server side rendering", () => {
|
|
18
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
18
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
19
19
|
const testRoutes = [
|
|
20
20
|
defineRoute({
|
|
21
21
|
method: "GET",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { test, expect, describe, vi, beforeEach, afterEach, assert } from "vitest";
|
|
2
|
-
import { type FragnoPublicClientConfig } from "
|
|
2
|
+
import { type FragnoPublicClientConfig } from "./client";
|
|
3
3
|
import { createClientBuilder } from "./client";
|
|
4
4
|
import { render } from "@testing-library/svelte";
|
|
5
5
|
import { defineRoute } from "../api/route";
|
|
6
|
-
import { defineFragment } from "../api/fragment-builder";
|
|
6
|
+
import { defineFragment } from "../api/fragment-definition-builder";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { readableToAtom, useFragno } from "./client.svelte";
|
|
9
9
|
import { writable, readable, get, derived } from "svelte/store";
|
|
@@ -89,7 +89,7 @@ describe("createSvelteHook", () => {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
test("Hook should function", async () => {
|
|
92
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
92
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
93
93
|
const testRoutes = [
|
|
94
94
|
defineRoute({
|
|
95
95
|
method: "GET",
|
|
@@ -124,7 +124,7 @@ describe("createSvelteHook", () => {
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
test("Should support path parameters and update reactively when Svelte store changes", async () => {
|
|
127
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
127
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
128
128
|
type TestData = {
|
|
129
129
|
id: number;
|
|
130
130
|
name: string;
|
|
@@ -183,7 +183,7 @@ describe("createSvelteHook", () => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
test("Should support path parameters and update reactively when Nanostores Atom changes", async () => {
|
|
186
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
186
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
187
187
|
type TestData = { id: number; name: string };
|
|
188
188
|
const testRoutes = [
|
|
189
189
|
defineRoute({
|
|
@@ -239,7 +239,7 @@ describe("createSvelteHook", () => {
|
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
test("Should handle errors gracefully", async () => {
|
|
242
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
242
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
243
243
|
const testRoutes = [
|
|
244
244
|
defineRoute({
|
|
245
245
|
method: "GET",
|
|
@@ -277,7 +277,7 @@ describe("createSvelteHook", () => {
|
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
test("Should track loading states correctly", async () => {
|
|
280
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
280
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
281
281
|
const testRoutes = [
|
|
282
282
|
defineRoute({
|
|
283
283
|
method: "GET",
|
|
@@ -322,7 +322,7 @@ describe("createSvelteHook", () => {
|
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
test("Should handle query parameters", async () => {
|
|
325
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
325
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
326
326
|
const testRoutes = [
|
|
327
327
|
defineRoute({
|
|
328
328
|
method: "GET",
|
|
@@ -376,7 +376,7 @@ describe("createSvelteHook", () => {
|
|
|
376
376
|
});
|
|
377
377
|
|
|
378
378
|
test("Should handle multiple hooks together", async () => {
|
|
379
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
379
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
380
380
|
const testRoutes = [
|
|
381
381
|
defineRoute({
|
|
382
382
|
method: "GET",
|
|
@@ -432,7 +432,7 @@ describe("createSvelteHook", () => {
|
|
|
432
432
|
});
|
|
433
433
|
|
|
434
434
|
test("Should handle mixed reactive parameters - writable path param, atom and writable query params, with reactive updates", async () => {
|
|
435
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
435
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
436
436
|
const testRoutes = [
|
|
437
437
|
defineRoute({
|
|
438
438
|
method: "GET",
|
|
@@ -561,7 +561,7 @@ describe("createSvelteMutator", () => {
|
|
|
561
561
|
});
|
|
562
562
|
|
|
563
563
|
test("Should handle mutator hooks", async () => {
|
|
564
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
564
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
565
565
|
const testRoutes = [
|
|
566
566
|
defineRoute({
|
|
567
567
|
method: "POST",
|
|
@@ -605,7 +605,7 @@ describe("createSvelteMutator", () => {
|
|
|
605
605
|
});
|
|
606
606
|
|
|
607
607
|
test("Should handle mutator with path parameters", async () => {
|
|
608
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
608
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
609
609
|
const testRoutes = [
|
|
610
610
|
defineRoute({
|
|
611
611
|
method: "PUT",
|
|
@@ -663,7 +663,7 @@ describe("useFragno", () => {
|
|
|
663
663
|
baseUrl: "http://localhost:3000",
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
666
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
667
667
|
const testRoutes = [
|
|
668
668
|
defineRoute({
|
|
669
669
|
method: "GET",
|
|
@@ -711,7 +711,7 @@ describe("useFragno", () => {
|
|
|
711
711
|
});
|
|
712
712
|
|
|
713
713
|
test("Should support path parameters and update reactively when using Svelte runes", async () => {
|
|
714
|
-
const testFragmentDefinition = defineFragment("test-fragment");
|
|
714
|
+
const testFragmentDefinition = defineFragment("test-fragment").build();
|
|
715
715
|
type TestData = {
|
|
716
716
|
id: number;
|
|
717
717
|
name: string;
|
|
@@ -785,7 +785,7 @@ describe("createSvelteStore", () => {
|
|
|
785
785
|
});
|
|
786
786
|
|
|
787
787
|
test("streaming routes", async () => {
|
|
788
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
788
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
789
789
|
const streamRoutes = [
|
|
790
790
|
defineRoute({
|
|
791
791
|
method: "GET",
|
|
@@ -4,9 +4,9 @@ import { defineRoute } from "../api/route";
|
|
|
4
4
|
import { buildUrl, createClientBuilder, getCacheKey, isGetHook, isMutatorHook } from "./client";
|
|
5
5
|
import { useFragno } from "./vanilla";
|
|
6
6
|
import { createAsyncIteratorFromCallback, waitForAsyncIterator } from "../util/async";
|
|
7
|
-
import type { FragnoPublicClientConfig } from "
|
|
7
|
+
import type { FragnoPublicClientConfig } from "./client";
|
|
8
8
|
import { atom, computed, effect } from "nanostores";
|
|
9
|
-
import { defineFragment } from "../api/fragment-builder";
|
|
9
|
+
import { defineFragment } from "../api/fragment-definition-builder";
|
|
10
10
|
import { RequestOutputContext } from "../api/request-output-context";
|
|
11
11
|
import { FragnoClientUnknownApiError } from "./client-error";
|
|
12
12
|
|
|
@@ -112,7 +112,7 @@ describe("getCacheKey", () => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
describe("invalidation", () => {
|
|
115
|
-
const testFragment = defineFragment("test-fragment");
|
|
115
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
116
116
|
const testRoutes = [
|
|
117
117
|
defineRoute({
|
|
118
118
|
method: "GET",
|
|
@@ -269,7 +269,7 @@ describe("hook parameter reactivity", () => {
|
|
|
269
269
|
});
|
|
270
270
|
|
|
271
271
|
test("should react to path parameters", async () => {
|
|
272
|
-
const testFragment = defineFragment("test-fragment");
|
|
272
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
273
273
|
const testRoutes = [
|
|
274
274
|
defineRoute({
|
|
275
275
|
method: "GET",
|
|
@@ -343,7 +343,7 @@ describe("hook parameter reactivity", () => {
|
|
|
343
343
|
});
|
|
344
344
|
|
|
345
345
|
test("should react to query parameters", async () => {
|
|
346
|
-
const testFragment = defineFragment("test-fragment");
|
|
346
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
347
347
|
const testRoutes = [
|
|
348
348
|
defineRoute({
|
|
349
349
|
method: "GET",
|
|
@@ -446,7 +446,7 @@ describe("hook parameter reactivity", () => {
|
|
|
446
446
|
});
|
|
447
447
|
|
|
448
448
|
test("should react to optional query parameters", async () => {
|
|
449
|
-
const testFragment = defineFragment("test-fragment");
|
|
449
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
450
450
|
const testRoutes = [
|
|
451
451
|
defineRoute({
|
|
452
452
|
method: "GET",
|
|
@@ -523,7 +523,7 @@ describe("hook parameter reactivity", () => {
|
|
|
523
523
|
});
|
|
524
524
|
|
|
525
525
|
test("should react to combined path and query parameters", async () => {
|
|
526
|
-
const testFragment = defineFragment("test-fragment");
|
|
526
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
527
527
|
const testRoutes = [
|
|
528
528
|
defineRoute({
|
|
529
529
|
method: "GET",
|
|
@@ -632,7 +632,7 @@ describe("hook parameter reactivity", () => {
|
|
|
632
632
|
});
|
|
633
633
|
|
|
634
634
|
test("should handle mixed atoms and non-atoms in parameters", async () => {
|
|
635
|
-
const testFragment = defineFragment("test-fragment");
|
|
635
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
636
636
|
const testRoutes = [
|
|
637
637
|
defineRoute({
|
|
638
638
|
method: "GET",
|
|
@@ -752,7 +752,7 @@ describe("hook parameter reactivity", () => {
|
|
|
752
752
|
});
|
|
753
753
|
|
|
754
754
|
test("should not refetch when non-atom parameters remain unchanged", async () => {
|
|
755
|
-
const testFragment = defineFragment("test-fragment");
|
|
755
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
756
756
|
const testRoutes = [
|
|
757
757
|
defineRoute({
|
|
758
758
|
method: "GET",
|
|
@@ -859,7 +859,7 @@ describe("hook parameter reactivity", () => {
|
|
|
859
859
|
});
|
|
860
860
|
|
|
861
861
|
test("should handle multiple reactive query parameters independently", async () => {
|
|
862
|
-
const testFragment = defineFragment("test-fragment");
|
|
862
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
863
863
|
const testRoutes = [
|
|
864
864
|
defineRoute({
|
|
865
865
|
method: "GET",
|
|
@@ -1039,7 +1039,7 @@ describe("createHook - streaming", () => {
|
|
|
1039
1039
|
});
|
|
1040
1040
|
|
|
1041
1041
|
test("Should be able to stream data and receive updates in store (store.listen)", async () => {
|
|
1042
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
1042
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
1043
1043
|
const streamRoutes = [
|
|
1044
1044
|
defineRoute({
|
|
1045
1045
|
method: "GET",
|
|
@@ -1112,7 +1112,7 @@ describe("createHook - streaming", () => {
|
|
|
1112
1112
|
});
|
|
1113
1113
|
|
|
1114
1114
|
test("throws FragnoClientUnknownApiError when the stream is not valid JSON", async () => {
|
|
1115
|
-
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment");
|
|
1115
|
+
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment").build();
|
|
1116
1116
|
const streamErrorRoutes = [
|
|
1117
1117
|
defineRoute({
|
|
1118
1118
|
method: "GET",
|
|
@@ -1152,7 +1152,7 @@ describe("createHook - streaming", () => {
|
|
|
1152
1152
|
});
|
|
1153
1153
|
|
|
1154
1154
|
test("throws FragnoClientUnknownApiError when the stream is new lines only", async () => {
|
|
1155
|
-
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment");
|
|
1155
|
+
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment").build();
|
|
1156
1156
|
const streamErrorRoutes = [
|
|
1157
1157
|
defineRoute({
|
|
1158
1158
|
method: "GET",
|
|
@@ -1192,7 +1192,7 @@ describe("createHook - streaming", () => {
|
|
|
1192
1192
|
});
|
|
1193
1193
|
|
|
1194
1194
|
test("throws FragnoClientUnknownApiError with cause SyntaxError when the stream is not valid JSON (multiple empty lines)", async () => {
|
|
1195
|
-
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment");
|
|
1195
|
+
const streamErrorFragmentDefinition = defineFragment("stream-error-fragment").build();
|
|
1196
1196
|
const streamErrorRoutes = [
|
|
1197
1197
|
defineRoute({
|
|
1198
1198
|
method: "GET",
|
|
@@ -1249,7 +1249,7 @@ describe("createMutator", () => {
|
|
|
1249
1249
|
});
|
|
1250
1250
|
|
|
1251
1251
|
test("body is optional when no inputSchema in route", async () => {
|
|
1252
|
-
const testFragment = defineFragment("test-fragment");
|
|
1252
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
1253
1253
|
const testRoutes = [
|
|
1254
1254
|
defineRoute({
|
|
1255
1255
|
method: "DELETE",
|
|
@@ -1288,7 +1288,7 @@ describe("createMutator - streaming", () => {
|
|
|
1288
1288
|
});
|
|
1289
1289
|
|
|
1290
1290
|
test("should support streaming responses for mutations", async () => {
|
|
1291
|
-
const mutationStreamFragmentDefinition = defineFragment("mutation-stream-fragment");
|
|
1291
|
+
const mutationStreamFragmentDefinition = defineFragment("mutation-stream-fragment").build();
|
|
1292
1292
|
const mutationStreamRoutes = [
|
|
1293
1293
|
defineRoute({
|
|
1294
1294
|
method: "POST",
|
|
@@ -1354,7 +1354,7 @@ describe("createMutator - streaming", () => {
|
|
|
1354
1354
|
});
|
|
1355
1355
|
|
|
1356
1356
|
test("Should be able to mutate data and receive updates in store (store.subscribe)", async () => {
|
|
1357
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
1357
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
1358
1358
|
const streamRoutes = [
|
|
1359
1359
|
defineRoute({
|
|
1360
1360
|
method: "POST",
|
|
@@ -1459,7 +1459,7 @@ describe("createMutator - streaming", () => {
|
|
|
1459
1459
|
});
|
|
1460
1460
|
|
|
1461
1461
|
test("Should be able to mutate data and receive updates in store (store.listen)", async () => {
|
|
1462
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
1462
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
1463
1463
|
const streamRoutes = [
|
|
1464
1464
|
defineRoute({
|
|
1465
1465
|
method: "POST",
|
|
@@ -1570,7 +1570,7 @@ describe("computed", () => {
|
|
|
1570
1570
|
});
|
|
1571
1571
|
|
|
1572
1572
|
test("Derived from streaming route", async () => {
|
|
1573
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
1573
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
1574
1574
|
const streamRoutes = [
|
|
1575
1575
|
defineRoute({
|
|
1576
1576
|
method: "GET",
|
|
@@ -1617,7 +1617,7 @@ describe("computed", () => {
|
|
|
1617
1617
|
});
|
|
1618
1618
|
|
|
1619
1619
|
test("Derived from streaming route with atom usage", async () => {
|
|
1620
|
-
const streamFragmentDefinition = defineFragment("stream-fragment");
|
|
1620
|
+
const streamFragmentDefinition = defineFragment("stream-fragment").build();
|
|
1621
1621
|
const streamRoutes = [
|
|
1622
1622
|
defineRoute({
|
|
1623
1623
|
method: "GET",
|
|
@@ -1694,7 +1694,7 @@ describe("computed", () => {
|
|
|
1694
1694
|
});
|
|
1695
1695
|
|
|
1696
1696
|
describe("type guards", () => {
|
|
1697
|
-
const testFragment = defineFragment("test-fragment");
|
|
1697
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
1698
1698
|
const testRoutes = [
|
|
1699
1699
|
defineRoute({
|
|
1700
1700
|
method: "GET",
|
|
@@ -1767,7 +1767,7 @@ describe("type guards", () => {
|
|
|
1767
1767
|
});
|
|
1768
1768
|
|
|
1769
1769
|
describe("Custom Fetcher Configuration", () => {
|
|
1770
|
-
const testFragment = defineFragment("test-fragment");
|
|
1770
|
+
const testFragment = defineFragment("test-fragment").build();
|
|
1771
1771
|
const testRoutes = [
|
|
1772
1772
|
defineRoute({
|
|
1773
1773
|
method: "GET",
|