@montytools/cli 0.2.7 → 0.2.8
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/package.json +1 -1
- package/template/AGENTS.md +13 -1
- package/template/package.json +1 -1
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -39,6 +39,9 @@ Folders are managed for you: this app lives in `~/Monty/<slug>`. `monty current`
|
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
// monty.config.ts
|
|
42
|
+
import { defineApp, montyFileSchema } from "@montytools/sdk";
|
|
43
|
+
import { z } from "zod";
|
|
44
|
+
|
|
42
45
|
export const app = defineApp({
|
|
43
46
|
slug: "expenses",
|
|
44
47
|
tables: {
|
|
@@ -47,13 +50,14 @@ export const app = defineApp({
|
|
|
47
50
|
amount: z.number().positive(),
|
|
48
51
|
status: z.enum(["draft", "submitted", "approved"]).default("draft"),
|
|
49
52
|
assigneeId: z.string().optional(), // userId from useMembers()
|
|
53
|
+
receipt: montyFileSchema.optional(),
|
|
50
54
|
}),
|
|
51
55
|
},
|
|
52
56
|
});
|
|
53
57
|
```
|
|
54
58
|
|
|
55
59
|
```tsx
|
|
56
|
-
import { useList, useRecord, useInsert, useUpdate, useRemove, useMembers } from "@montytools/sdk/react";
|
|
60
|
+
import { useList, useRecord, useInsert, useUpdate, useRemove, useMembers, useUploadFile, useFileUrl } from "@montytools/sdk/react";
|
|
57
61
|
import { app } from "../../monty.config";
|
|
58
62
|
|
|
59
63
|
const { data, status, loadMore } = useList(app, "expenses", {
|
|
@@ -81,6 +85,11 @@ await remove(row._id);
|
|
|
81
85
|
|
|
82
86
|
const one = useRecord(app, "expenses", idOrNull); // row | null(missing or no selection) | undefined(loading)
|
|
83
87
|
const members = useMembers(); // [{ userId, name, email, imageUrl, role }]
|
|
88
|
+
|
|
89
|
+
const uploadFile = useUploadFile(app); // File/Blob -> MontyFile descriptor
|
|
90
|
+
const receipt = await uploadFile(input.files[0]);
|
|
91
|
+
await update(row._id, { receipt }); // store descriptor, not bytes
|
|
92
|
+
const { url } = useFileUrl(app, row.receipt); // authenticated blob: URL for previews/downloads
|
|
84
93
|
```
|
|
85
94
|
|
|
86
95
|
## Errors are instructions
|
|
@@ -97,6 +106,7 @@ Every platform error is one line shaped like:
|
|
|
97
106
|
| `NOT_FOUND` | Stale, foreign, or WRONG-TABLE record id — ids come from `useList`/`useRecord` on the same table; never hard-code or mix them. |
|
|
98
107
|
| `INVALID_SCHEMA` | A table field uses a reserved name (`_*`, `updatedAt`, `createdBy`) — rename it. |
|
|
99
108
|
| `SCHEMA_DRIFT` (warning) | Stored rows predate your latest schema change; nothing crashes, but make changed fields `.optional()`/`.default(...)`. |
|
|
109
|
+
| `FILE_TOO_LARGE` | Platform file uploads are currently capped at 10 MiB per file. |
|
|
100
110
|
| `UNAUTHENTICATED` / `NO_ACTIVE_WORKSPACE` | App isn't running through the Monty host/dev shell. |
|
|
101
111
|
| `MISSING_ENV` / `NO_PROVIDER` | `.env.local` or the `<MontyProvider>` in `main.tsx` was removed. |
|
|
102
112
|
|
|
@@ -136,6 +146,8 @@ confirms it.
|
|
|
136
146
|
|
|
137
147
|
- Rows, not embedded arrays: a comments thread is a `comments` table with a
|
|
138
148
|
`parentId` field, not an array inside a record (records cap at 1 MiB).
|
|
149
|
+
- Files are `montyFileSchema` descriptors in records; bytes live in platform
|
|
150
|
+
storage and are previewed with `useFileUrl(app, file)`.
|
|
139
151
|
- People are `z.string()` userIds from `useMembers()`; render names/avatars
|
|
140
152
|
from the member list.
|
|
141
153
|
- Timestamps are `z.number()` epochs or `z.iso.datetime()` strings — never
|
package/template/package.json
CHANGED