@quark-fw/entity 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +40 -0
  2. package/package.json +10 -6
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @quark-fw/entity
2
+
3
+ Entity CRUD layer for the Quark framework: describe a model once and get a tRPC router (list, get, create, update, delete, custom methods) backed by Prisma, plus React form helpers on the client.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @quark-fw/entity
9
+ ```
10
+
11
+ Peers: `@quark-fw/core`, `react`. Server side expects the Prisma plugin to have populated `quark.db`.
12
+
13
+ ## Server
14
+
15
+ ```ts
16
+ import { createEntity } from "@quark-fw/entity";
17
+
18
+ export const taskEntity = createEntity({
19
+ model: "task", // key of your EntityModels augmentation
20
+ defaultSort: { field: "createdAt", dir: "desc" },
21
+ methods: {
22
+ // custom method: plain function or { input: zodSchema, handler }
23
+ complete: { input: z.object({ id: z.string() }), handler: ({ id }) => /* ... */ },
24
+ },
25
+ });
26
+ // taskEntity.createRouter() builds a tRPC router — merge it into your appRouter
27
+ ```
28
+
29
+ Model types are declared by your app through declaration merging of the `EntityModels` interface (see `EntityRow`, `EntityField`, `EntityModelName` types).
30
+
31
+ ## Client
32
+
33
+ ```tsx
34
+ import { useEntityForm } from "@quark-fw/entity/src/useEntityForm.js";
35
+ import { createEntityContext } from "@quark-fw/entity/src/client.js";
36
+ ```
37
+
38
+ `useEntityForm` gives zod-validated create/update forms wired to the entity router; `createEntityContext` builds typed React contexts for entity lists and single rows on top of [`@quark-fw/store`](https://www.npmjs.com/package/@quark-fw/store).
39
+
40
+ Part of the [Quark framework](https://www.npmjs.com/package/@quark-fw/core).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quark-fw/entity",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Entity CRUD layer over tRPC and Prisma for the Quark framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,25 +14,29 @@
14
14
  "./src/*": "./dist/*",
15
15
  "./*": "./dist/*"
16
16
  },
17
- "files": ["dist"],
17
+ "files": [
18
+ "dist"
19
+ ],
18
20
  "scripts": {
19
21
  "dev": "tsx watch src/index.ts",
20
22
  "build": "tsc -p tsconfig.build.json && node ../../scripts/postbuild.mjs"
21
23
  },
22
- "keywords": ["quark"],
24
+ "keywords": [
25
+ "quark"
26
+ ],
23
27
  "author": "",
24
28
  "license": "ISC",
25
29
  "publishConfig": {
26
30
  "access": "public"
27
31
  },
28
32
  "dependencies": {
29
- "@quark-fw/plugin-trpc": "0.0.1",
30
- "@quark-fw/store": "0.0.1",
33
+ "@quark-fw/plugin-trpc": "0.0.2",
34
+ "@quark-fw/store": "0.0.2",
31
35
  "@trpc/server": "^11.0.0",
32
36
  "zod": "^4.0.0"
33
37
  },
34
38
  "peerDependencies": {
35
- "@quark-fw/core": "0.0.1",
39
+ "@quark-fw/core": "0.0.2",
36
40
  "react": "^19.2.4"
37
41
  },
38
42
  "devDependencies": {