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.
- package/README.md +89 -101
- package/dist/cli/bin.mjs +1119 -195
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-DtX8qPrq.js → api-DzcR7spt.js} +36 -13
- package/dist/runtime/api-DzcR7spt.js.map +1 -0
- package/dist/runtime/{api-Dp4J-xt-.d.ts → api-jCl8Hzry.d.ts} +7 -9
- package/dist/runtime/client.d.ts +12 -5
- package/dist/runtime/client.js +285 -60
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-t6BOEGw9-C1rwYIlx.js → descriptor-C5VA9qRl-BKbdenuU.js} +38 -7
- package/dist/runtime/descriptor-C5VA9qRl-BKbdenuU.js.map +1 -0
- package/dist/runtime/file-C1abuMgd.js +173 -0
- package/dist/runtime/file-C1abuMgd.js.map +1 -0
- package/dist/runtime/{id-Btwac71X-DhnKYsjY.d.ts → id-Cs82tq9Q-Caqfx54f.d.ts} +51 -5
- package/dist/runtime/{index-B5KSOjGN.d.ts → index-D6VLTbDB.d.ts} +40 -21
- package/dist/runtime/internal/api.d.ts +2 -2
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +8 -7
- package/dist/runtime/internal/host.js +21 -10
- package/dist/runtime/internal/host.js.map +1 -1
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +1 -1
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/{pagination-B1BzNkh8-BUSTbeSg.d.ts → pagination-Bt3l7QaC-D_zI5zsu.d.ts} +8 -4
- package/dist/runtime/pagination-DcIkTOFs.d.ts +1 -0
- package/dist/runtime/{schema-D9RmboaS.js → schema-B6PK_ZwV.js} +17 -3
- package/dist/runtime/schema-B6PK_ZwV.js.map +1 -0
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/sync-bMQq9tXx.d.ts +8 -0
- package/package.json +7 -5
- package/src/cli/agent-files.ts +52 -13
- package/src/cli/app-configuration.ts +4 -1
- package/src/cli/auth-client.ts +286 -0
- package/src/cli/build/server.ts +83 -6
- package/src/cli/command.ts +65 -2
- package/src/cli/control-client.ts +19 -6
- package/src/cli/new-app.ts +16 -0
- package/src/client/errors.ts +7 -10
- package/src/client/files.ts +153 -0
- package/src/client/hooks.ts +2 -15
- package/src/client/index.ts +7 -0
- package/src/client/sync.ts +158 -30
- package/src/dev-runtime/database.ts +69 -57
- package/src/dev-runtime/files.ts +337 -0
- package/src/dev-runtime/functions.ts +14 -6
- package/src/dev-runtime/migrations.ts +14 -0
- package/src/dev-runtime/sync.ts +134 -22
- package/src/internal/api.ts +16 -1
- package/src/server/index.ts +8 -1
- package/dist/runtime/api-DtX8qPrq.js.map +0 -1
- package/dist/runtime/descriptor-t6BOEGw9-C1rwYIlx.js.map +0 -1
- package/dist/runtime/id-D570vudg.js +0 -26
- package/dist/runtime/id-D570vudg.js.map +0 -1
- package/dist/runtime/pagination-BKPko9Hm.d.ts +0 -1
- 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
|
|
4
|
-
|
|
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
|
|
7
|
+
The package requires Node.js 22.18 or newer.
|
|
7
8
|
|
|
8
|
-
##
|
|
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
|
|
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
|
|
30
|
+
Ignotum writes generated bindings to `_generated`. Read those files when investigating a type, but
|
|
31
|
+
do not edit them.
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
## Define the schema
|
|
37
34
|
|
|
38
|
-
`server/schema.ts`
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
todos: table({
|
|
42
|
+
text: values.string(),
|
|
43
|
+
completed: values.boolean(),
|
|
44
|
+
}).index("by_completed", ["completed"]),
|
|
47
45
|
}));
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
57
|
-
export const counterIncrement = 1;
|
|
58
|
-
```
|
|
51
|
+
## Define functions
|
|
59
52
|
|
|
60
|
-
|
|
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
|
-
|
|
73
|
-
return counters[0]?.value ?? 0;
|
|
62
|
+
return yield* ctx.db.query("todos").collect();
|
|
74
63
|
},
|
|
75
64
|
});
|
|
76
65
|
|
|
77
|
-
export const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
handler: function* (ctx) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
103
|
-
and `api.counter.increment`.
|
|
83
|
+
## Build the client
|
|
104
84
|
|
|
105
|
-
|
|
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
|
|
118
|
-
const
|
|
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-
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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: "
|
|
118
|
+
title: "Todos",
|
|
144
119
|
component: App,
|
|
145
120
|
});
|
|
146
121
|
```
|
|
147
122
|
|
|
148
|
-
`useQuery`
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
153
|
-
|
|
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
|
-
|
|
156
|
-
any filename when imported from app code.
|
|
131
|
+
## Commands
|
|
157
132
|
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
162
|
-
|
|
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
|
-
##
|
|
149
|
+
## Package entry points
|
|
165
150
|
|
|
166
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
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
|
-
|
|
177
|
-
|
|
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
|
-
|
|
167
|
+
See the [Ignotum documentation](https://docs.ignotum.cloud) for validators, indexes, pagination,
|
|
168
|
+
errors, consistency guarantees, hosted limits, and deployment behavior.
|