@fragno-dev/create 0.1.6 → 0.1.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragno-dev/create",
3
3
  "description": "A library for creating Fragno fragments",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "exports": {
6
6
  ".": {
7
7
  "development": "./src/index.ts",
@@ -14,10 +14,10 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "type": "module",
16
16
  "dependencies": {
17
- "zod": "^4.1.12"
17
+ "zod": "^4.3.5"
18
18
  },
19
19
  "devDependencies": {
20
- "@types/node": "^22",
20
+ "@types/node": "^22.19.7",
21
21
  "@vitest/coverage-istanbul": "^3.2.4",
22
22
  "vitest": "^3.2.4",
23
23
  "@fragno-private/typescript-config": "0.0.1",
@@ -1,18 +1,18 @@
1
1
  import type { BuildTools } from "./index";
2
2
 
3
- const fragnoCoreVersion = "0.1.11";
4
- const fragnoDbVersion = "0.2.2";
5
- const unpluginFragnoVersion = "0.0.7";
6
- const fragnoCliVersion = "0.1.23";
3
+ const fragnoCoreVersion = "0.2.0";
4
+ const fragnoDbVersion = "0.3.0";
5
+ const unpluginFragnoVersion = "0.0.8";
6
+ const fragnoCliVersion = "0.2.0";
7
7
 
8
8
  export const basePkg: Record<string, unknown> = {
9
9
  dependencies: {
10
10
  "@fragno-dev/core": fragnoCoreVersion,
11
- "@standard-schema/spec": "^1.0.0",
12
- zod: "^4.0.5",
11
+ "@standard-schema/spec": "^1.1.0",
12
+ zod: "^4.3.6",
13
13
  },
14
14
  devDependencies: {
15
- "@types/node": "^24",
15
+ "@types/node": "^25.2.2",
16
16
  "@fragno-dev/cli": fragnoCliVersion,
17
17
  "@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
18
18
  },
@@ -38,7 +38,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
38
38
  none: {},
39
39
  tsdown: {
40
40
  devDependencies: {
41
- tsdown: "^0.12.0",
41
+ tsdown: "^0.20.3",
42
42
  },
43
43
  scripts: {
44
44
  build: "tsdown",
@@ -46,7 +46,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
46
46
  },
47
47
  esbuild: {
48
48
  devDependencies: {
49
- esbuild: "^0.25.12",
49
+ esbuild: "^0.27.3",
50
50
  },
51
51
  scripts: {
52
52
  build: "./esbuild.config.js",
@@ -54,7 +54,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
54
54
  },
55
55
  vite: {
56
56
  devDependencies: {
57
- vite: "^6.3.5",
57
+ vite: "^7.3.1",
58
58
  },
59
59
  scripts: {
60
60
  build: "vite build",
@@ -62,10 +62,10 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
62
62
  },
63
63
  rollup: {
64
64
  devDependencies: {
65
- "@rollup/plugin-node-resolve": "^16.0.2",
66
- "@rollup/plugin-typescript": "^12.1.4",
65
+ "@rollup/plugin-node-resolve": "^16.0.3",
66
+ "@rollup/plugin-typescript": "^12.3.0",
67
67
  tslib: "^2.8.1",
68
- rollup: "^4.41.0",
68
+ rollup: "^4.57.1",
69
69
  },
70
70
  scripts: {
71
71
  build: "rollup -c",
@@ -73,9 +73,9 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
73
73
  },
74
74
  webpack: {
75
75
  devDependencies: {
76
- webpack: "^5.99.9",
76
+ webpack: "^5.105.0",
77
77
  "webpack-cli": "^6.0.1",
78
- "ts-loader": "^9.5.1",
78
+ "ts-loader": "^9.5.4",
79
79
  },
80
80
  scripts: {
81
81
  build: "webpack",
@@ -83,8 +83,8 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
83
83
  },
84
84
  rspack: {
85
85
  devDependencies: {
86
- "@rspack/core": "^1.6.1",
87
- "@rspack/cli": "^1.6.1",
86
+ "@rspack/core": "^1.7.5",
87
+ "@rspack/cli": "^1.7.5",
88
88
  },
89
89
  scripts: {
90
90
  build: "rspack build",
@@ -133,7 +133,7 @@ Database schemas are defined in a separate `schema.ts` file using the Fragno sch
133
133
  ```typescript
134
134
  import { column, idColumn, referenceColumn, schema } from "@fragno-dev/db/schema";
135
135
 
136
- export const noteSchema = schema((s) => {
136
+ export const noteSchema = schema("example-fragment", (s) => {
137
137
  return s
138
138
  .addTable("users", (t) => {
139
139
  return t.addColumn("id", idColumn()).addColumn("name", column("string"));
@@ -201,32 +201,43 @@ const fragmentDef = defineFragmentWithDatabase<Config>("my-fragment")
201
201
  - `orm.delete(table, id)` - Delete a row by ID
202
202
  - `.whereIndex(indexName, condition)` - Use indexes for efficient queries
203
203
 
204
- ### Transactions (Unit of Work)
204
+ ### Transactions (handlerTx + serviceTx)
205
205
 
206
- Two-phase pattern for atomic operations (optimistic concurrency control):
206
+ Two-phase pattern for atomic operations (optimistic concurrency control) using handler-owned
207
+ transactions:
207
208
 
208
209
  ```typescript
209
- // Phase 1: Retrieve with version tracking
210
- const uow = orm
211
- .createUnitOfWork()
212
- .find("users", (b) => b.whereIndex("primary", (eb) => eb("id", "=", userId)))
213
- .find("accounts", (b) => b.whereIndex("idx_user", (eb) => eb("userId", "=", userId)));
214
- const [users, accounts] = await uow.executeRetrieve();
215
-
216
- // Phase 2: Mutate atomically
217
- uow.update("users", users[0].id, (b) => b.set({ lastLogin: new Date() }).check());
218
- uow.update("accounts", accounts[0].id, (b) =>
219
- b.set({ balance: accounts[0].balance + 100 }).check(),
220
- );
221
-
222
- const { success } = await uow.executeMutations();
223
- if (!success) {
224
- /* Version conflict - retry */
210
+ // Route handler - owns the transaction boundary
211
+ const [result] = await this.handlerTx()
212
+ .withServiceCalls(() => [services.transferFunds({ userId, amount })])
213
+ .execute();
214
+
215
+ // Service - defines the unit of work
216
+ transferFunds: function ({ userId, amount }: { userId: string; amount: number }) {
217
+ return this.serviceTx(mySchema)
218
+ .retrieve((uow) =>
219
+ uow
220
+ .findFirst("users", (b) => b.whereIndex("primary", (eb) => eb("id", "=", userId)))
221
+ .findFirst("accounts", (b) => b.whereIndex("idx_user", (eb) => eb("userId", "=", userId))),
222
+ )
223
+ .mutate(({ uow, retrieveResult: [user, account] }) => {
224
+ if (!user || !account) {
225
+ return { ok: false as const };
226
+ }
227
+
228
+ uow.update("users", user.id, (b) => b.set({ lastLogin: new Date() }).check());
229
+ uow.update("accounts", account.id, (b) =>
230
+ b.set({ balance: account.balance + amount }).check(),
231
+ );
232
+
233
+ return { ok: true as const };
234
+ })
235
+ .build();
225
236
  }
226
237
  ```
227
238
 
228
- **Notes**: `.check()` enables optimistic concurrency control; requires `FragnoId` objects (not
229
- string IDs); use `uow.getCreatedIds()` for new record IDs
239
+ **Notes**: `.check()` enables optimistic concurrency control and requires `FragnoId` objects (not
240
+ string IDs).
230
241
 
231
242
  ## Strategies for Building Fragments
232
243
 
@@ -14,15 +14,18 @@ export default defineConfig([
14
14
  "./src/client/vue.ts",
15
15
  ],
16
16
  dts: true,
17
+ failOnWarn: true,
17
18
  platform: "browser",
18
19
  outDir: "./dist/browser",
19
20
  plugins: [unpluginFragno({ platform: "browser" })],
20
21
  noExternal: [/^@fragno-dev\/core\//],
22
+ inlineOnly: [/^@fragno-dev\/core/, /^nanostores$/, /^@nanostores\//, /^nanoevents$/],
21
23
  },
22
24
  {
23
25
  ignoreWatch: ["./dist"],
24
26
  entry: "./src/index.ts",
25
27
  dts: true,
28
+ failOnWarn: true,
26
29
  platform: "node",
27
30
  outDir: "./dist/node",
28
31
  plugins: [unpluginFragno({ platform: "node" })],
@@ -1,6 +1,6 @@
1
1
  import { column, idColumn, referenceColumn, schema } from "@fragno-dev/db/schema";
2
2
 
3
- export const noteSchema = schema((s) => {
3
+ export const noteSchema = schema("example-fragment", (s) => {
4
4
  return s
5
5
  .addTable("user", (t) => {
6
6
  return t