ignotum 0.0.7 → 0.0.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.
Files changed (58) hide show
  1. package/README.md +89 -101
  2. package/dist/cli/bin.mjs +1119 -195
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/runtime/{api-DtX8qPrq.js → api-DzcR7spt.js} +36 -13
  5. package/dist/runtime/api-DzcR7spt.js.map +1 -0
  6. package/dist/runtime/{api-Dp4J-xt-.d.ts → api-jCl8Hzry.d.ts} +7 -9
  7. package/dist/runtime/client.d.ts +12 -5
  8. package/dist/runtime/client.js +285 -60
  9. package/dist/runtime/client.js.map +1 -1
  10. package/dist/runtime/{descriptor-t6BOEGw9-C1rwYIlx.js → descriptor-C5VA9qRl-BKbdenuU.js} +38 -7
  11. package/dist/runtime/descriptor-C5VA9qRl-BKbdenuU.js.map +1 -0
  12. package/dist/runtime/file-C1abuMgd.js +173 -0
  13. package/dist/runtime/file-C1abuMgd.js.map +1 -0
  14. package/dist/runtime/{id-Btwac71X-DhnKYsjY.d.ts → id-Cs82tq9Q-Caqfx54f.d.ts} +51 -5
  15. package/dist/runtime/{index-B5KSOjGN.d.ts → index-D6VLTbDB.d.ts} +40 -21
  16. package/dist/runtime/internal/api.d.ts +2 -2
  17. package/dist/runtime/internal/api.js +1 -1
  18. package/dist/runtime/internal/host.d.ts +8 -7
  19. package/dist/runtime/internal/host.js +21 -10
  20. package/dist/runtime/internal/host.js.map +1 -1
  21. package/dist/runtime/internal/server.d.ts +1 -1
  22. package/dist/runtime/internal/server.js +1 -1
  23. package/dist/runtime/internal/types.d.ts +1 -1
  24. package/dist/runtime/internal/types.js +1 -1
  25. package/dist/runtime/{pagination-B1BzNkh8-BUSTbeSg.d.ts → pagination-Bt3l7QaC-D_zI5zsu.d.ts} +8 -4
  26. package/dist/runtime/pagination-DcIkTOFs.d.ts +1 -0
  27. package/dist/runtime/{schema-D9RmboaS.js → schema-B6PK_ZwV.js} +17 -3
  28. package/dist/runtime/schema-B6PK_ZwV.js.map +1 -0
  29. package/dist/runtime/server.d.ts +3 -3
  30. package/dist/runtime/server.js +2 -2
  31. package/dist/runtime/server.js.map +1 -1
  32. package/dist/runtime/sync-bMQq9tXx.d.ts +8 -0
  33. package/package.json +7 -5
  34. package/src/cli/agent-files.ts +52 -13
  35. package/src/cli/app-configuration.ts +4 -1
  36. package/src/cli/auth-client.ts +286 -0
  37. package/src/cli/build/server.ts +83 -6
  38. package/src/cli/command.ts +65 -2
  39. package/src/cli/control-client.ts +19 -6
  40. package/src/cli/new-app.ts +16 -0
  41. package/src/client/errors.ts +7 -10
  42. package/src/client/files.ts +153 -0
  43. package/src/client/hooks.ts +2 -15
  44. package/src/client/index.ts +7 -0
  45. package/src/client/sync.ts +158 -30
  46. package/src/dev-runtime/database.ts +69 -57
  47. package/src/dev-runtime/files.ts +337 -0
  48. package/src/dev-runtime/functions.ts +14 -6
  49. package/src/dev-runtime/migrations.ts +14 -0
  50. package/src/dev-runtime/sync.ts +134 -22
  51. package/src/internal/api.ts +16 -1
  52. package/src/server/index.ts +8 -1
  53. package/dist/runtime/api-DtX8qPrq.js.map +0 -1
  54. package/dist/runtime/descriptor-t6BOEGw9-C1rwYIlx.js.map +0 -1
  55. package/dist/runtime/id-D570vudg.js +0 -26
  56. package/dist/runtime/id-D570vudg.js.map +0 -1
  57. package/dist/runtime/pagination-BKPko9Hm.d.ts +0 -1
  58. package/dist/runtime/schema-D9RmboaS.js.map +0 -1
package/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  # Ignotum
2
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.
3
+ Ignotum is an opinionated TypeScript application cloud built around a schema, server queries and mutations,
4
+ and a browser client. Generated references carry function argument, result, and error types from
5
+ the server to the client.
5
6
 
6
- The current release supports local development and hosted deployment.
7
+ The package requires Node.js 22.18 or newer.
7
8
 
8
- ## Get started
9
-
10
- Ignotum requires Node.js 22.18 or newer.
9
+ ## Create an app
11
10
 
12
11
  ```sh
13
12
  npx ignotum new my-app
@@ -15,10 +14,7 @@ cd my-app
15
14
  npx ignotum dev
16
15
  ```
17
16
 
18
- Open <http://127.0.0.1:3210>. The generated app contains a schema, a query, a mutation, and a
19
- JSX client.
20
-
21
- ## Follow the example app
17
+ Open `http://127.0.0.1:3210`. The generated counter app has this source layout:
22
18
 
23
19
  ```text
24
20
  client/
@@ -31,108 +27,87 @@ shared/
31
27
  utils.ts
32
28
  ```
33
29
 
34
- Ignotum creates `_generated` beside them. Do not edit that directory by hand.
30
+ Ignotum writes generated bindings to `_generated`. Read those files when investigating a type, but
31
+ do not edit them.
35
32
 
36
- ### Define the data
33
+ ## Define the schema
37
34
 
38
- `server/schema.ts` declares a `counters` table with one numeric field:
35
+ `server/schema.ts` names the tables and validates their stored fields:
39
36
 
40
37
  ```ts
41
38
  import { defineSchema } from "ignotum/server";
42
39
 
43
40
  export default defineSchema(({ table, values }) => ({
44
- counters: table({
45
- value: values.number(),
46
- }),
41
+ todos: table({
42
+ text: values.string(),
43
+ completed: values.boolean(),
44
+ }).index("by_completed", ["completed"]),
47
45
  }));
48
46
  ```
49
47
 
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:
48
+ Every document also has an `id`, `createdAt`, and `updatedAt`. IDs are typed by table, so an ID for
49
+ one table cannot be passed where another table's ID is required.
55
50
 
56
- ```ts
57
- export const counterIncrement = 1;
58
- ```
51
+ ## Define functions
59
52
 
60
- ### Read and write from the server
61
-
62
- `server/counter.ts` defines the functions exposed to the client.
53
+ Put function modules directly inside `server`. The file and export names form the generated client
54
+ address. This example exports `api.todos.list` and `api.todos.create`:
63
55
 
64
56
  ```ts
65
57
  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
58
 
59
+ export const list = query({
60
+ returns: values.array(values.doc("todos")),
71
61
  handler: function* (ctx) {
72
- const counters = yield* ctx.db.query("counters").collect();
73
- return counters[0]?.value ?? 0;
62
+ return yield* ctx.db.query("todos").collect();
74
63
  },
75
64
  });
76
65
 
77
- export const increment = mutation({
78
- returns: values.number(),
79
-
80
- handler: function* (ctx) {
81
- const counters = yield* ctx.db.query("counters").collect();
82
- const counter = counters[0];
83
- const value = (counter?.value ?? 0) + counterIncrement;
84
-
85
- if (counter === undefined) {
86
- yield* ctx.db.insert("counters", { value });
87
- } else {
88
- yield* ctx.db.patch("counters", counter.id, { value });
89
- }
90
-
91
- return value;
66
+ export const create = mutation({
67
+ args: { text: values.string() },
68
+ returns: values.id("todos"),
69
+ handler: function* (ctx, args) {
70
+ return yield* ctx.db.insert("todos", {
71
+ text: args.text,
72
+ completed: false,
73
+ });
92
74
  },
93
75
  });
94
76
  ```
95
77
 
96
- Server handlers are generator functions. If `function*` and `yield*` look scary, read `function*`
97
- as `async function` and `yield*` as `await`. That mental model is close enough when writing an
98
- Ignotum handler. Use `yield*` for database operations, then return plain values from queries. Query
99
- handlers can only read data. Mutation handlers can read and write, and Ignotum rolls back their
100
- writes if they fail.
78
+ Handlers are generator functions. Use `yield*` for database operations and `return` for the public
79
+ result. Queries can read. Mutations can read and write, and their writes commit together only when
80
+ the function succeeds. Arguments, returned values, and declared application errors are checked at
81
+ runtime as well as in TypeScript.
101
82
 
102
- The file and export names form the generated API. The functions above become `api.counter.get`
103
- and `api.counter.increment`.
83
+ ## Build the client
104
84
 
105
- ### Call the functions from the client
106
-
107
- `client/index.tsx` defines the app title and uses the generated references to call the server
108
- functions.
85
+ `client/index.tsx` default-exports one `app` definition. Use generated references with the query and
86
+ mutation hooks:
109
87
 
110
88
  ```tsx
111
89
  import { app, Result, useMutation, useQuery } from "ignotum/client";
112
90
 
113
91
  import { api } from "@/_generated/api.js";
114
- import { counterIncrement } from "@/shared/utils.js";
115
92
 
116
93
  function App() {
117
- const count = useQuery(api.counter.get);
118
- const increment = useMutation(api.counter.increment);
94
+ const todos = useQuery(api.todos.list);
95
+ const create = useMutation(api.todos.create);
119
96
 
120
97
  return (
121
- <main class="mx-auto max-w-sm px-6 py-20 text-center">
122
- <h1 class="text-2xl font-semibold">Counter</h1>
123
- {Result.match(count, {
124
- pending: () => <p class="mt-6">Loading...</p>,
125
- value: (value) => (
126
- <>
127
- <p class="my-6 text-5xl tabular-nums">{value}</p>
128
- <button
129
- class="rounded bg-zinc-900 px-4 py-2 text-white"
130
- type="button"
131
- onClick={() => void increment()}
132
- >
133
- Increment by {counterIncrement}
134
- </button>
135
- </>
98
+ <main class="mx-auto max-w-xl p-8">
99
+ <button type="button" onClick={() => void create({ text: "New todo" })}>
100
+ Add todo
101
+ </button>
102
+
103
+ {Result.match(todos, {
104
+ pending: () => <p>Loading...</p>,
105
+ value: (items) => (
106
+ <ul>
107
+ {items.map((todo) => (
108
+ <li key={todo.id}>{todo.text}</li>
109
+ ))}
110
+ </ul>
136
111
  ),
137
112
  })}
138
113
  </main>
@@ -140,41 +115,54 @@ function App() {
140
115
  }
141
116
 
142
117
  export default app({
143
- title: "Counter",
118
+ title: "Todos",
144
119
  component: App,
145
120
  });
146
121
  ```
147
122
 
148
- `useQuery` starts with a pending result and subscribes to later values. `Result.match` makes the UI
149
- handle each query state. `useMutation` returns a typed function whose arguments come from the
150
- server definition.
123
+ `useQuery` subscribes while the component uses the result. It starts as `Pending` and then contains
124
+ a value or declared application error. `useMutation` returns a stable typed function. Its promise
125
+ settles after the mutation result arrives; affected queries may refresh afterward.
151
126
 
152
- Open the app in two browser tabs and increment the counter in either one. Both tabs update because
153
- Ignotum refreshes active queries after a successful mutation.
127
+ Import UI components, hooks, and types from `ignotum/client`. Tailwind classes work without an app
128
+ configuration file. Import any custom CSS from client code. An optional `client/icon.svg` becomes
129
+ the favicon. Supported files in a top-level `public` directory retain their URL paths.
154
130
 
155
- Ignotum loads Tailwind CSS automatically. Custom CSS files are ordinary client modules and can use
156
- any filename when imported from app code.
131
+ ## Commands
157
132
 
158
- The optional `client/icon.svg` file becomes the favicon automatically. If it is absent, Ignotum
159
- does not add a favicon link.
133
+ | Command | Purpose |
134
+ | --------------------------------- | ------------------------------------------------------------------ |
135
+ | `npx ignotum new <directory>` | Create an app, optionally initialize Git, and install dependencies |
136
+ | `npx ignotum install` | Install with pnpm when available, otherwise npm |
137
+ | `npx ignotum codegen` | Regenerate `_generated` without starting the dev server |
138
+ | `npx ignotum dev` | Run the local app and watch client, schema, and function changes |
139
+ | `npx ignotum dev db reset` | Delete local app data while the dev server is stopped |
140
+ | `npx ignotum auth login` | Sign in to Ignotum with GitHub |
141
+ | `npx ignotum auth logout` | Revoke and remove the saved login |
142
+ | `npx ignotum auth status` | Show the current account and team |
143
+ | `npx ignotum deploy --app <slug>` | Link the app on its first deployment, then build and activate it |
160
144
 
161
- Optional files in a top-level `public` directory keep their relative paths as public URLs. Ignotum
162
- accepts AVIF, GIF, ICO, JPEG, PNG, WebP, and PDF files there; `client/public` is not supported.
145
+ Run `npx ignotum auth login` before the first deployment. The CLI stores the login outside the app
146
+ directory. After the first deployment, it records the app link in `.ignotum/app.json`; later
147
+ deployments do not need `--app`.
163
148
 
164
- ## Keep working
149
+ ## Package entry points
165
150
 
166
- The dev server watches the schema and server modules, regenerates bindings, and reloads the app.
167
- Run code generation separately before a typecheck when the dev server is not running:
151
+ Application code uses two entry points:
168
152
 
169
- ```sh
170
- npx ignotum codegen
171
- npx tsc --noEmit
172
- ```
153
+ - `ignotum/server` exports `defineSchema`, the server form of `Result`, and schema authoring types.
154
+ - `ignotum/client` exports `app`, query and mutation hooks, `Query.skip`, client-side result
155
+ matching, application file URLs, and the supported UI APIs and types.
173
156
 
174
- Local data survives dev-server restarts. Stop the server before resetting it:
157
+ Generated files provide schema-bound server builders and function references. Imports from
158
+ `@/_generated/server.js` belong in server code. Imports from `@/_generated/api.js` belong in client
159
+ code. Shared modules may be imported through `@/shared`.
175
160
 
176
- ```sh
177
- npx ignotum dev db reset
178
- ```
161
+ ## Current scope
162
+
163
+ Ignotum currently supports schema-defined data, queries, mutations, live query results, application
164
+ image files, local development, and hosted deployment. It does not provide authentication, custom
165
+ HTTP endpoints, actions, scheduled jobs, or workflows.
179
166
 
180
- The package exports server APIs from `ignotum/server` and client APIs from `ignotum/client`.
167
+ See the [Ignotum documentation](https://docs.ignotum.cloud) for validators, indexes, pagination,
168
+ errors, consistency guarantees, hosted limits, and deployment behavior.