@fragno-dev/create 0.1.1 → 0.1.4
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 +9 -6
- package/CHANGELOG.md +19 -0
- package/LICENSE.md +16 -0
- package/dist/index.js +19 -26
- package/dist/index.js.map +1 -1
- package/package.json +19 -14
- package/src/integration.test.ts +8 -5
- package/src/package-json.ts +19 -20
- package/templates/fragment/src/client/react.ts +1 -1
- package/templates/fragment/src/client/solid.ts +1 -1
- package/templates/fragment/src/client/svelte.ts +1 -1
- package/templates/fragment/src/client/vanilla.ts +1 -1
- package/templates/fragment/src/client/vue.ts +1 -1
- package/templates/fragment/src/index.ts +23 -28
- package/templates/optional/agent/AGENTS.md +29 -14
- package/templates/optional/builder/esbuild.config.js +3 -3
- package/templates/optional/builder/rollup.config.js +3 -2
- package/templates/optional/builder/rspack.config.js +3 -2
- package/templates/optional/builder/vite.config.ts +5 -1
- package/templates/optional/builder/webpack.config.js +3 -2
- package/templates/optional/database/index.ts +52 -70
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -11,6 +11,7 @@ export default [
|
|
|
11
11
|
"client/svelte": "./src/client/svelte.ts",
|
|
12
12
|
"client/vanilla": "./src/client/vanilla.ts",
|
|
13
13
|
"client/vue": "./src/client/vue.ts",
|
|
14
|
+
"client/solid": "./src/client/solid.ts",
|
|
14
15
|
},
|
|
15
16
|
output: {
|
|
16
17
|
dir: "./dist/browser",
|
|
@@ -18,11 +19,12 @@ export default [
|
|
|
18
19
|
sourcemap: true,
|
|
19
20
|
},
|
|
20
21
|
// https://rollupjs.org/tools/#peer-dependencies
|
|
21
|
-
external: ["zod", "react", "svelte", "vue"],
|
|
22
|
+
external: ["zod", "react", "svelte", "vue", "solid-js", /^@fragno-dev\/db/],
|
|
22
23
|
plugins: [
|
|
23
24
|
resolve({
|
|
24
25
|
moduleDirectories: ["node_modules"],
|
|
25
26
|
browser: true,
|
|
27
|
+
conditions: ["browser"],
|
|
26
28
|
}),
|
|
27
29
|
typescript({
|
|
28
30
|
tsconfig: "./tsconfig.json",
|
|
@@ -41,7 +43,6 @@ export default [
|
|
|
41
43
|
format: "es",
|
|
42
44
|
sourcemap: true,
|
|
43
45
|
},
|
|
44
|
-
external: ["zod"],
|
|
45
46
|
plugins: [
|
|
46
47
|
resolve({
|
|
47
48
|
moduleDirectories: ["node_modules"],
|
|
@@ -16,6 +16,7 @@ export default [
|
|
|
16
16
|
"client/svelte": "./src/client/svelte.ts",
|
|
17
17
|
"client/vanilla": "./src/client/vanilla.ts",
|
|
18
18
|
"client/vue": "./src/client/vue.ts",
|
|
19
|
+
"client/solid": "./src/client/solid.ts",
|
|
19
20
|
},
|
|
20
21
|
output: {
|
|
21
22
|
path: path.resolve(__dirname, "dist/browser"),
|
|
@@ -48,7 +49,7 @@ export default [
|
|
|
48
49
|
},
|
|
49
50
|
plugins: [unpluginFragno({ platform: "browser" })],
|
|
50
51
|
devtool: "source-map",
|
|
51
|
-
externals: ["zod", "react", "vue", "svelte"],
|
|
52
|
+
externals: ["zod", "react", "vue", "svelte", "solid-js", /^@fragno-dev\/db/],
|
|
52
53
|
},
|
|
53
54
|
// Node build
|
|
54
55
|
{
|
|
@@ -88,6 +89,6 @@ export default [
|
|
|
88
89
|
},
|
|
89
90
|
plugins: [unpluginFragno({ platform: "node" })],
|
|
90
91
|
devtool: "source-map",
|
|
91
|
-
externals: ["zod"],
|
|
92
|
+
externals: ["zod", /^@fragno-dev\/core/, /^@fragno-dev\/db/],
|
|
92
93
|
},
|
|
93
94
|
];
|
|
@@ -3,6 +3,9 @@ import unpluginFragno from "@fragno-dev/unplugin-fragno/vite";
|
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
plugins: [unpluginFragno({ platform: "browser" })],
|
|
6
|
+
resolve: {
|
|
7
|
+
conditions: ["browser"],
|
|
8
|
+
},
|
|
6
9
|
// https://vite.dev/guide/build.html#library-mode
|
|
7
10
|
build: {
|
|
8
11
|
lib: {
|
|
@@ -12,11 +15,12 @@ export default defineConfig({
|
|
|
12
15
|
"client/svelte": "./src/client/svelte.ts",
|
|
13
16
|
"client/vanilla": "./src/client/vanilla.ts",
|
|
14
17
|
"client/vue": "./src/client/vue.ts",
|
|
18
|
+
"client/solid": "./src/client/solid.ts",
|
|
15
19
|
},
|
|
16
20
|
formats: ["es"],
|
|
17
21
|
},
|
|
18
22
|
rollupOptions: {
|
|
19
|
-
external: ["react", "vue", "svelte", "zod"],
|
|
23
|
+
external: ["react", "vue", "svelte", "solid-js", "zod", /^@fragno-dev\/db/],
|
|
20
24
|
},
|
|
21
25
|
outDir: "./dist/browser",
|
|
22
26
|
sourcemap: true,
|
|
@@ -16,6 +16,7 @@ export default [
|
|
|
16
16
|
"client/svelte": "./src/client/svelte.ts",
|
|
17
17
|
"client/vanilla": "./src/client/vanilla.ts",
|
|
18
18
|
"client/vue": "./src/client/vue.ts",
|
|
19
|
+
"client/solid": "./src/client/solid.ts",
|
|
19
20
|
},
|
|
20
21
|
output: {
|
|
21
22
|
path: path.resolve(__dirname, "dist/browser"),
|
|
@@ -41,7 +42,7 @@ export default [
|
|
|
41
42
|
},
|
|
42
43
|
plugins: [unpluginFragno({ platform: "browser" })],
|
|
43
44
|
devtool: "source-map",
|
|
44
|
-
externals: ["react", "vue", "svelte", "zod"],
|
|
45
|
+
externals: ["react", "vue", "svelte", "solid-js", "zod", /^@fragno-dev\/db/],
|
|
45
46
|
},
|
|
46
47
|
// Node build
|
|
47
48
|
{
|
|
@@ -74,6 +75,6 @@ export default [
|
|
|
74
75
|
},
|
|
75
76
|
plugins: [unpluginFragno({ platform: "node" })],
|
|
76
77
|
devtool: "source-map",
|
|
77
|
-
externals: ["zod"],
|
|
78
|
+
externals: ["zod", /^@fragno-dev\/core/, /^@fragno-dev\/db/],
|
|
78
79
|
},
|
|
79
80
|
];
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type FragnoPublicClientConfig,
|
|
6
|
-
} from "@fragno-dev/core";
|
|
7
|
-
import { createClientBuilder } from "@fragno-dev/core/client";
|
|
8
|
-
import {
|
|
9
|
-
defineFragmentWithDatabase,
|
|
10
|
-
type FragnoPublicConfigWithDatabase,
|
|
11
|
-
} from "@fragno-dev/db/fragment";
|
|
12
|
-
import type { AbstractQuery, TableToInsertValues } from "@fragno-dev/db/query";
|
|
1
|
+
import { defineFragment, defineRoutes, instantiate } from "@fragno-dev/core";
|
|
2
|
+
import { createClientBuilder, type FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
3
|
+
import { withDatabase, type FragnoPublicConfigWithDatabase } from "@fragno-dev/db";
|
|
4
|
+
import type { TableToInsertValues } from "@fragno-dev/db/query";
|
|
13
5
|
import { noteSchema } from "./schema";
|
|
14
6
|
|
|
15
7
|
// NOTE: We use zod here for defining schemas, but any StandardSchema library can be used!
|
|
@@ -21,37 +13,32 @@ export interface ExampleConfig {
|
|
|
21
13
|
// Add any server-side configuration here if needed
|
|
22
14
|
}
|
|
23
15
|
|
|
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
|
-
type ExampleDeps = {
|
|
50
|
-
orm: AbstractQuery<typeof noteSchema>;
|
|
51
|
-
};
|
|
16
|
+
const exampleFragmentDefinition = defineFragment<ExampleConfig>("example-fragment")
|
|
17
|
+
.extend(withDatabase(noteSchema))
|
|
18
|
+
.providesBaseService(({ deps }) => {
|
|
19
|
+
return {
|
|
20
|
+
createNote: async (note: TableToInsertValues<typeof noteSchema.tables.note>) => {
|
|
21
|
+
const id = await deps.db.create("note", note);
|
|
22
|
+
return {
|
|
23
|
+
...note,
|
|
24
|
+
id: id.valueOf(),
|
|
25
|
+
createdAt: note.createdAt ?? new Date(),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
getNotes: () => {
|
|
29
|
+
return deps.db.find("note", (b) => b);
|
|
30
|
+
},
|
|
31
|
+
getNotesByUser: (userId: string) => {
|
|
32
|
+
return deps.db.find("note", (b) =>
|
|
33
|
+
b.whereIndex("idx_note_user", (eb) => eb("userId", "=", userId)),
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
.build();
|
|
52
39
|
|
|
53
|
-
const exampleRoutesFactory = defineRoutes
|
|
54
|
-
({ services }) => {
|
|
40
|
+
const exampleRoutesFactory = defineRoutes(exampleFragmentDefinition).create(
|
|
41
|
+
({ services, defineRoute }) => {
|
|
55
42
|
return [
|
|
56
43
|
defineRoute({
|
|
57
44
|
method: "GET",
|
|
@@ -70,11 +57,25 @@ const exampleRoutesFactory = defineRoutes<ExampleConfig, ExampleDeps, ExampleSer
|
|
|
70
57
|
|
|
71
58
|
if (userId) {
|
|
72
59
|
const notes = await services.getNotesByUser(userId);
|
|
73
|
-
return json(
|
|
60
|
+
return json(
|
|
61
|
+
notes.map((note) => ({
|
|
62
|
+
id: note.id.valueOf(),
|
|
63
|
+
content: note.content,
|
|
64
|
+
userId: note.userId,
|
|
65
|
+
createdAt: note.createdAt,
|
|
66
|
+
})),
|
|
67
|
+
);
|
|
74
68
|
}
|
|
75
69
|
|
|
76
70
|
const notes = await services.getNotes();
|
|
77
|
-
return json(
|
|
71
|
+
return json(
|
|
72
|
+
notes.map((note) => ({
|
|
73
|
+
id: note.id.valueOf(),
|
|
74
|
+
content: note.content,
|
|
75
|
+
userId: note.userId,
|
|
76
|
+
createdAt: note.createdAt,
|
|
77
|
+
})),
|
|
78
|
+
);
|
|
78
79
|
},
|
|
79
80
|
}),
|
|
80
81
|
|
|
@@ -100,34 +101,15 @@ const exampleRoutesFactory = defineRoutes<ExampleConfig, ExampleDeps, ExampleSer
|
|
|
100
101
|
},
|
|
101
102
|
);
|
|
102
103
|
|
|
103
|
-
const exampleFragmentDefinition = defineFragmentWithDatabase<ExampleConfig>("example-fragment")
|
|
104
|
-
.withDatabase(noteSchema)
|
|
105
|
-
.withServices(({ orm }) => {
|
|
106
|
-
return {
|
|
107
|
-
createNote: async (note: TableToInsertValues<typeof noteSchema.tables.note>) => {
|
|
108
|
-
const id = await orm.create("note", note);
|
|
109
|
-
return {
|
|
110
|
-
...note,
|
|
111
|
-
id: id.toJSON(),
|
|
112
|
-
createdAt: note.createdAt ?? new Date(),
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
getNotes: () => {
|
|
116
|
-
return orm.find("note", (b) => b);
|
|
117
|
-
},
|
|
118
|
-
getNotesByUser: (userId: string) => {
|
|
119
|
-
return orm.find("note", (b) =>
|
|
120
|
-
b.whereIndex("idx_note_user", (eb) => eb("userId", "=", userId)),
|
|
121
|
-
);
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
|
|
126
104
|
export function createExampleFragment(
|
|
127
105
|
config: ExampleConfig = {},
|
|
128
|
-
|
|
106
|
+
options: FragnoPublicConfigWithDatabase,
|
|
129
107
|
) {
|
|
130
|
-
return
|
|
108
|
+
return instantiate(exampleFragmentDefinition)
|
|
109
|
+
.withConfig(config)
|
|
110
|
+
.withRoutes([exampleRoutesFactory])
|
|
111
|
+
.withOptions(options)
|
|
112
|
+
.build();
|
|
131
113
|
}
|
|
132
114
|
|
|
133
115
|
export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientConfig) {
|
|
@@ -138,4 +120,4 @@ export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientCon
|
|
|
138
120
|
useCreateNote: b.createMutator("POST", "/notes"),
|
|
139
121
|
};
|
|
140
122
|
}
|
|
141
|
-
export type { FragnoRouteConfig } from "@fragno-dev/core
|
|
123
|
+
export type { FragnoRouteConfig } from "@fragno-dev/core";
|