@teable/create-app 1.0.4 → 1.0.6
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/dist/template/AGENTS.md +33 -1
- package/package.json +1 -1
package/dist/template/AGENTS.md
CHANGED
|
@@ -102,7 +102,8 @@ Also:
|
|
|
102
102
|
Renaming one or changing its input breaks its callers.
|
|
103
103
|
- Table names starting with `_teable_` are reserved.
|
|
104
104
|
- One app is one Durable Object: up to 10 GB, one thread, 128 MB of memory.
|
|
105
|
-
Keep each call small, and page through long lists (`limit
|
|
105
|
+
Keep each call small, and page through long lists (`cursor` and `limit`,
|
|
106
|
+
as in "Add a read or a write").
|
|
106
107
|
- Teable has no secrets store for apps yet. Never put keys or tokens in code
|
|
107
108
|
or git; ask the user.
|
|
108
109
|
- Pages are for the members of the app's space unless the app says
|
|
@@ -142,6 +143,26 @@ export const markPaid = app.write({
|
|
|
142
143
|
fail("NOT_FOUND", `No invoice ${input.id}`),
|
|
143
144
|
});
|
|
144
145
|
|
|
146
|
+
export const listInvoices = app.read({
|
|
147
|
+
description: "Invoices, oldest first",
|
|
148
|
+
input: z.object({
|
|
149
|
+
cursor: z.number().int().optional(), // the nextCursor of the page before; none for the first
|
|
150
|
+
limit: z.number().int().min(1).max(200).default(50),
|
|
151
|
+
}),
|
|
152
|
+
output: z.object({ invoices: z.array(schemaOf(invoices)), nextCursor: z.number().nullable() }),
|
|
153
|
+
handler: ({ db, input }) => {
|
|
154
|
+
const rows = db
|
|
155
|
+
.select()
|
|
156
|
+
.from(invoices)
|
|
157
|
+
.where(gt(invoices.id, input.cursor ?? 0))
|
|
158
|
+
.orderBy(invoices.id)
|
|
159
|
+
.limit(input.limit)
|
|
160
|
+
.all();
|
|
161
|
+
const full = rows.length === input.limit; // a shorter page is the last
|
|
162
|
+
return { invoices: rows, nextCursor: full ? (rows.at(-1)?.id ?? null) : null };
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
145
166
|
export const App = app.define({ listInvoices, markPaid });
|
|
146
167
|
```
|
|
147
168
|
|
|
@@ -152,6 +173,10 @@ export const App = app.define({ listInvoices, markPaid });
|
|
|
152
173
|
it from the tables: `schemaOf(table)` for a row (`.pick`, `.omit`,
|
|
153
174
|
`.extend`), `schemaOf(table.column)` for one value. They carry the column's
|
|
154
175
|
kind, so callers tell money (and its currency) from a number.
|
|
176
|
+
- A read of a long list returns it a page at a time, as `listInvoices` does:
|
|
177
|
+
it takes an optional `cursor` (and `limit`) and returns its rows in one
|
|
178
|
+
array beside `nextCursor`, the next page's `cursor` (null after the last).
|
|
179
|
+
The builder, and pages with `useInfiniteQuery`, read on from it.
|
|
155
180
|
- Return plain data: end Drizzle queries with `.all()`, `.get()` or `.run()`.
|
|
156
181
|
- `fail(code, message)` refuses the call with `BAD_INPUT`, `FORBIDDEN`,
|
|
157
182
|
`NOT_FOUND` or `CONFLICT`; nothing the write did is kept.
|
|
@@ -354,6 +379,13 @@ methods through the API (`/api/v4/apps/<appId>/methods/<name>`, described at
|
|
|
354
379
|
Teable previews the pages. A version is the server code and the pages
|
|
355
380
|
together: a rollback brings back both.
|
|
356
381
|
|
|
382
|
+
Tell the user once, when the publish has finished: run the check, the build
|
|
383
|
+
and the publish in the foreground and wait for them, not as background
|
|
384
|
+
tasks. When a background task you started ends after you told them (a
|
|
385
|
+
server you ran to see the pages, say), say in a line what it changes, if
|
|
386
|
+
anything; do not repeat what you told them. Stop such a server before you
|
|
387
|
+
finish.
|
|
388
|
+
|
|
357
389
|
A project nobody named has no name: `teable-next publish` prints its
|
|
358
390
|
`projectName` as null (so do `init` and `clone`), and Teable lists it as
|
|
359
391
|
untitled. Once you know what the app is, name it after the app, in the
|
package/package.json
CHANGED