ignotum 0.0.0 → 0.0.1

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 (57) hide show
  1. package/README.md +161 -0
  2. package/dist/cli/bin.d.mts +1 -0
  3. package/dist/cli/bin.mjs +1696 -0
  4. package/dist/cli/bin.mjs.map +1 -0
  5. package/dist/runtime/api-BXXIZc_Q.js +119 -0
  6. package/dist/runtime/api-BXXIZc_Q.js.map +1 -0
  7. package/dist/runtime/api-Cpx57mk3.d.ts +47 -0
  8. package/dist/runtime/client/jsx-dev-runtime.d.ts +2 -0
  9. package/dist/runtime/client/jsx-dev-runtime.js +2 -0
  10. package/dist/runtime/client/jsx-runtime.d.ts +2 -0
  11. package/dist/runtime/client/jsx-runtime.js +2 -0
  12. package/dist/runtime/client.d.ts +29 -0
  13. package/dist/runtime/client.js +364 -0
  14. package/dist/runtime/client.js.map +1 -0
  15. package/dist/runtime/index-BgWROoyk.d.ts +249 -0
  16. package/dist/runtime/internal/api.d.ts +2 -0
  17. package/dist/runtime/internal/api.js +2 -0
  18. package/dist/runtime/internal/server.d.ts +6 -0
  19. package/dist/runtime/internal/server.js +7 -0
  20. package/dist/runtime/internal/server.js.map +1 -0
  21. package/dist/runtime/internal/types.d.ts +2 -0
  22. package/dist/runtime/internal/types.js +2 -0
  23. package/dist/runtime/result-B2W-z2wG.js +136 -0
  24. package/dist/runtime/result-B2W-z2wG.js.map +1 -0
  25. package/dist/runtime/result-C1ZdsM6Y.d.ts +106 -0
  26. package/dist/runtime/schema-CNEVLF7D.js +116 -0
  27. package/dist/runtime/schema-CNEVLF7D.js.map +1 -0
  28. package/dist/runtime/server.d.ts +9 -0
  29. package/dist/runtime/server.js +9 -0
  30. package/dist/runtime/server.js.map +1 -0
  31. package/package.json +81 -1
  32. package/src/cli/agent-files.ts +35 -0
  33. package/src/cli/bin.ts +5 -0
  34. package/src/cli/client-plugin.ts +66 -0
  35. package/src/cli/codegen.ts +203 -0
  36. package/src/cli/command.ts +155 -0
  37. package/src/cli/dev.ts +206 -0
  38. package/src/cli/new-project.ts +377 -0
  39. package/src/cli/package-manager.ts +55 -0
  40. package/src/client/errors.ts +83 -0
  41. package/src/client/hooks.ts +141 -0
  42. package/src/client/index.ts +90 -0
  43. package/src/client/jsx-dev-runtime.ts +2 -0
  44. package/src/client/jsx-runtime.ts +2 -0
  45. package/src/client/query.ts +17 -0
  46. package/src/client/sync.ts +487 -0
  47. package/src/dev-runtime/database.ts +374 -0
  48. package/src/dev-runtime/dev-database.ts +199 -0
  49. package/src/dev-runtime/functions.ts +293 -0
  50. package/src/dev-runtime/id.ts +11 -0
  51. package/src/dev-runtime/sync.ts +473 -0
  52. package/src/internal/api.ts +141 -0
  53. package/src/internal/http-paths.ts +5 -0
  54. package/src/internal/server.ts +3 -0
  55. package/src/internal/types.ts +2 -0
  56. package/src/raw.d.ts +4 -0
  57. package/src/server/index.ts +8 -0
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # Ignotum
2
+
3
+ Ignotum is an opinionated TypeScript application cloud. Define a schema, queries, and mutations,
4
+ then call them from the client with end-to-end types and realtime updates.
5
+
6
+ The current release supports local development. Hosted infrastructure is not included yet.
7
+
8
+ ## Get started
9
+
10
+ Ignotum requires Node.js 22.18 or newer.
11
+
12
+ ```sh
13
+ npx ignotum new my-app
14
+ cd my-app
15
+ npx ignotum dev
16
+ ```
17
+
18
+ Open <http://127.0.0.1:3210>. The generated project contains a schema, a query, a mutation, and a
19
+ JSX client.
20
+
21
+ ## Follow the example app
22
+
23
+ ```text
24
+ client/
25
+ App.tsx
26
+ styles.css
27
+ server/
28
+ counter.ts
29
+ schema.ts
30
+ shared/
31
+ utils.ts
32
+ ```
33
+
34
+ Ignotum creates `_generated` beside them. Do not edit that directory by hand.
35
+
36
+ ### Define the data
37
+
38
+ `server/schema.ts` declares a `counters` table with one numeric field:
39
+
40
+ ```ts
41
+ import { defineSchema } from "ignotum/server";
42
+
43
+ export default defineSchema(({ table, values }) => ({
44
+ counters: table({
45
+ value: values.number(),
46
+ }),
47
+ }));
48
+ ```
49
+
50
+ The schema supplies both runtime validation and TypeScript types. Ignotum also adds `id`,
51
+ `createdAt`, and `updatedAt` to every stored document.
52
+
53
+ The `shared/utils.ts` keeps the increment in one place that both the client and server
54
+ can import:
55
+
56
+ ```ts
57
+ export const counterIncrement = 1;
58
+ ```
59
+
60
+ ### Read and write from the server
61
+
62
+ `server/counter.ts` defines the functions exposed to the client.
63
+
64
+ ```ts
65
+ import { mutation, query, values } from "@/_generated/server.js";
66
+ import { counterIncrement } from "@/shared/utils.js";
67
+
68
+ export const get = query({
69
+ returns: values.number(),
70
+
71
+ handler: function* (ctx) {
72
+ const counters = yield* ctx.db.query("counters").collect();
73
+ return counters[0]?.value ?? 0;
74
+ },
75
+ });
76
+
77
+ export const increment = mutation({
78
+ handler: function* (ctx) {
79
+ const counters = yield* ctx.db.query("counters").collect();
80
+ const counter = counters[0];
81
+ const value = (counter?.value ?? 0) + counterIncrement;
82
+
83
+ if (counter === undefined) {
84
+ yield* ctx.db.insert("counters", { value });
85
+ } else {
86
+ yield* ctx.db.patch("counters", counter.id, { value });
87
+ }
88
+ },
89
+ });
90
+ ```
91
+
92
+ Server handlers are generator functions. If `function*` and `yield*` look scary, read `function*`
93
+ as `async function` and `yield*` as `await`. That mental model is close enough when writing an
94
+ Ignotum handler. Use `yield*` for database operations, then return plain values from queries. Query
95
+ handlers can only read data. Mutation handlers can read and write, and Ignotum rolls back their
96
+ writes if they fail.
97
+
98
+ The file and export names form the generated API. The functions above become `api.counter.get`
99
+ and `api.counter.increment`.
100
+
101
+ ### Call the functions from the client
102
+
103
+ `client/App.tsx` uses the generated references to call the server functions.
104
+
105
+ ```tsx
106
+ import { Result, useMutation, useQuery } from "ignotum/client";
107
+
108
+ import { api } from "@/_generated/api.js";
109
+ import { counterIncrement } from "@/shared/utils.js";
110
+
111
+ export default function App() {
112
+ const count = useQuery(api.counter.get);
113
+ const increment = useMutation(api.counter.increment);
114
+
115
+ return (
116
+ <main class="mx-auto max-w-sm px-6 py-20 text-center">
117
+ <h1 class="text-2xl font-semibold">Counter</h1>
118
+ {Result.match(count, {
119
+ pending: () => <p class="mt-6">Loading...</p>,
120
+ value: (value) => (
121
+ <>
122
+ <p class="my-6 text-5xl tabular-nums">{value}</p>
123
+ <button
124
+ class="rounded bg-zinc-900 px-4 py-2 text-white"
125
+ type="button"
126
+ onClick={() => void increment()}
127
+ >
128
+ Increment by {counterIncrement}
129
+ </button>
130
+ </>
131
+ ),
132
+ })}
133
+ </main>
134
+ );
135
+ }
136
+ ```
137
+
138
+ `useQuery` starts with a pending result and subscribes to later values. `Result.match` makes the UI
139
+ handle each query state. `useMutation` returns a typed function whose arguments come from the
140
+ server definition.
141
+
142
+ Open the app in two browser tabs and increment the counter in either one. Both tabs update because
143
+ Ignotum refreshes active queries after a successful mutation.
144
+
145
+ ## Keep working
146
+
147
+ The dev server watches the schema and server modules, regenerates bindings, and reloads the app.
148
+ Run code generation separately before a typecheck when the dev server is not running:
149
+
150
+ ```sh
151
+ npx ignotum codegen
152
+ npx tsc --noEmit
153
+ ```
154
+
155
+ Local data survives dev-server restarts. Stop the server before resetting it:
156
+
157
+ ```sh
158
+ npx ignotum dev db reset
159
+ ```
160
+
161
+ The package exports server APIs from `ignotum/server` and client APIs from `ignotum/client`.
@@ -0,0 +1 @@
1
+ export {}