@protobase/cli 0.49.0 → 0.49.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.
- package/dist/cli/package.js +1 -1
- package/dist/config/build-project.js +6 -3
- package/dist/config/config-defaults.js +3 -0
- package/package.json +7 -7
- package/skills/protobase/SKILL.md +7 -1
- package/skills/protobase/references/features/sign-in-and-accounts.md +2 -0
- package/skills/protobase/references/features/start-a-project.md +6 -0
- package/skills/protobase/references/getting-started.md +13 -13
- package/skills/protobase/references/guides/deploy.md +2 -2
- package/skills/protobase/references/guides/export-a-list.md +1 -1
- package/skills/protobase/references/guides/field-type.md +1 -1
- package/skills/protobase/references/guides/first-composed-page.md +1 -1
- package/skills/protobase/references/guides/first-plugin.md +1 -1
- package/skills/protobase/references/guides/import-records.md +1 -1
- package/skills/protobase/references/guides/personal-setting.md +1 -1
- package/skills/protobase/references/guides/push-notifications.md +1 -1
- package/skills/protobase/references/guides/record-card.md +1 -1
- package/skills/protobase/references/guides/remote-resources.md +1 -1
- package/skills/protobase/references/guides/theme-an-app.md +1 -1
- package/skills/protobase/references/reference/api.md +1 -1
- package/skills/protobase/references/reference/architecture.md +4 -4
- package/skills/protobase/references/reference/auth.md +29 -2
- package/skills/protobase/references/reference/blocks.md +1 -1
- package/skills/protobase/references/reference/bottom-bar.md +1 -1
- package/skills/protobase/references/reference/cli.md +9 -9
- package/skills/protobase/references/reference/client.md +2 -2
- package/skills/protobase/references/reference/config/admin-app.md +62 -0
- package/skills/protobase/references/reference/config/api.md +164 -0
- package/skills/protobase/references/reference/config/app.md +112 -0
- package/skills/protobase/references/reference/config/files.md +99 -0
- package/skills/protobase/references/reference/config/jobs-and-events.md +267 -0
- package/skills/protobase/references/reference/config/sign-in.md +396 -0
- package/skills/protobase/references/reference/config.md +88 -70
- package/skills/protobase/references/reference/custom-components.md +2 -2
- package/skills/protobase/references/reference/data-config.md +2 -2
- package/skills/protobase/references/reference/email.md +1 -1
- package/skills/protobase/references/reference/sidebar.md +2 -2
- package/skills/protobase/references/reference/ui-config.md +5 -5
- package/skills/protobase/references/reference/user-menu.md +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config.md: run `bun run docs:skill`, do not edit. -->
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Configuring Protobase
|
|
4
4
|
|
|
5
|
-
The project's config as one object of data,
|
|
5
|
+
The project's config file, protobase.config.ts or protobase.config.json, as one object of data; defineConfig and its function form, $env values, where the project's code is found and how extensions merge.
|
|
6
6
|
|
|
7
|
-
`protobase.config.ts`,
|
|
7
|
+
Protobase reads its config from one file in the project's root: `protobase.config.ts`, or `protobase.config.json` for the same object as JSON. The file describes the whole app as one flat object of data: its address and secret, sign-in, the jobs, the file providers and the API's settings. Every key is optional; Protobase has a default for each, and a project without a config file is a config of defaults.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
// protobase.config.ts
|
|
@@ -20,72 +20,80 @@ export default defineConfig({
|
|
|
20
20
|
})
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
The config names things; it never holds or imports their code. Protobase finds the code by its path, so the job above runs `jobs/send-invoice.ts` and the write hook is `hooks/queue-sent-invoice.ts`.
|
|
23
|
+
The config names things; it never holds or imports their code. Protobase finds the code by its path, so the job above runs `jobs/send-invoice.ts` and the write hook is `hooks/queue-sent-invoice.ts`.
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Each file below is loaded only when the app needs it, never while the config is read.
|
|
25
|
+
Each key is described with its type and default in the option pages:
|
|
28
26
|
|
|
29
|
-
|
|
|
30
|
-
| --- | --- | --- |
|
|
31
|
-
| `config/index.ts`, `config/<dir>/ui.ts` | the resources, views and pages, as exports | [Data config](data-config.md) |
|
|
32
|
-
| `config/roles.ts` | the `roles` export, made with `defineRoles` | [Access](access.md) |
|
|
33
|
-
| `functions/<name>.ts` | an API function, as its default export | [API functions](../guides/api-functions.md) |
|
|
34
|
-
| `jobs/<name>.ts` | what the job `<name>` of `jobs` does, as its default export (`JobRun`) | [Jobs](jobs.md) |
|
|
35
|
-
| `hooks/<name>.ts` | a write hook named in `writeHooks`, as its default export | [Jobs](jobs.md#enqueueing) |
|
|
36
|
-
| `hooks/error.ts` | called with every error the API answers `500` for, and the request (`onUnhandledError`) | [REST API](api.md#errors) |
|
|
37
|
-
| `auth/hooks.ts` | sign-in's hooks, as named exports: `generateUserId`, `onUserCreated`, the organization hooks | [Login](auth.md#hooks) |
|
|
38
|
-
| `auth/mailer.ts` | a mailer of the app's own for sign-in mail, as its default export | [Email](email.md) |
|
|
39
|
-
| `auth/authenticate.ts` | an `Authenticator` of the app's own, such as `jwtAuthenticator(...)`, in place of `authenticate` | [Tokens and roles](auth.md#tokens-and-roles) |
|
|
40
|
-
| `assistant/tools.ts` | the assistant's own tools, an array of `defineTool(...)` | [Assistant](assistant.md) |
|
|
41
|
-
| `audit/queue.ts` | the `AuditQueue` reveals of sensitive fields publish to | [REST API](api.md#sensitive-fields-and-audit) |
|
|
42
|
-
| `files/<name>.ts` | the file provider `<name>`, declared `{ kind: 'custom' }` in `files.providers` | [Files](files.md) |
|
|
43
|
-
| `webhooks/owner-roles.ts` | the roles a webhook subscription's owner holds, when the app signs people in another way | [Webhooks](webhooks.md) |
|
|
44
|
-
| `notifications/store.ts`, `notifications/history-store.ts`, `notifications/senders.ts` | a device store, a history store and push senders in place of the built-in ones | [Notifications](notifications.md) |
|
|
45
|
-
| `emails/` | the templates of sign-in's mail | [Email](email.md#templates) |
|
|
46
|
-
|
|
47
|
-
Hooks of the project's own get the app's database, `{ db }` (Kysely, as jobs get it), as their last argument. A job named in the config without its `jobs/<name>.ts`, or a write hook without its `hooks/<name>.ts`, stops the app at start with an error that names the file.
|
|
48
|
-
|
|
49
|
-
## Defaults
|
|
50
|
-
|
|
51
|
-
| Key | Default |
|
|
27
|
+
| Page | Keys |
|
|
52
28
|
| --- | --- |
|
|
53
|
-
|
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
29
|
+
| [App options](config/app.md) | `name`, `url`, `secret`, `previousSecrets`, `locale`, `timezone`, `themeColor`, `backgroundColor`, `mobile` |
|
|
30
|
+
| [Sign-in options](config/sign-in.md) | `auth`, `authenticate`, `signingKeyDays`, `signingKeyGraceDays` |
|
|
31
|
+
| [API options](config/api.md) | `apiPath`, `apiKeys`, `cors`, `defaultAccess`, `rowPermissions`, `statementTimeoutMs`, `scanGuard`, `errorReporting`, `writeHooks`, `mcpEndpoint`, `remoteResources`, `runtimeUpdates` |
|
|
32
|
+
| [Admin app options](config/admin-app.md) | `assistant`, `maps`, `plugins` |
|
|
33
|
+
| [Jobs and events options](config/jobs-and-events.md) | `jobs`, `events`, `history`, `webhooks`, `notifications` |
|
|
34
|
+
| [Files options](config/files.md) | `files` |
|
|
35
|
+
|
|
36
|
+
## Config types
|
|
37
|
+
|
|
38
|
+
`defineConfig` from `@protobase/config` types every key and returns its argument as it is, so the editor completes and checks the config without anything running. The package exports the types too: `ProtobaseConfig` is the object, and `AuthConfig` and `FilesConfig` are its `auth` and `files`.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import type { ProtobaseConfig } from '@protobase/config'
|
|
42
|
+
|
|
43
|
+
const config: ProtobaseConfig = { timezone: 'Europe/Amsterdam' }
|
|
44
|
+
export default config
|
|
45
|
+
```
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
## Conditional config
|
|
62
48
|
|
|
63
|
-
|
|
49
|
+
`defineConfig` also takes a function, which gets the command that reads the config, the environment and the project's folder, and returns a config:
|
|
64
50
|
|
|
65
|
-
|
|
51
|
+
```ts
|
|
52
|
+
export default defineConfig(({ command, env }) => ({
|
|
53
|
+
auth: { trustedOrigins: env.TUNNEL_URL ? [env.TUNNEL_URL] : undefined },
|
|
54
|
+
errorReporting: command === 'dev' ? false : undefined,
|
|
55
|
+
}))
|
|
56
|
+
```
|
|
66
57
|
|
|
67
58
|
| | |
|
|
68
59
|
| --- | --- |
|
|
69
|
-
| `command` | `dev`, `build`, `serve` (also `protobase worker` and the serve runtime's `migrate` and `create-admin`), or `tool`, any other command over the project, such as `migration`, `users` or `
|
|
60
|
+
| `command` | `dev`, `build`, `serve` (also `protobase worker` and the serve runtime's `migrate` and `create-admin`), or `tool`, any other command over the project, such as `migration`, `users` or `doctor` |
|
|
70
61
|
| `env` | `process.env`, with the project's `.env` loaded |
|
|
71
62
|
| `root` | the project's folder |
|
|
72
63
|
|
|
64
|
+
`protobase serve` reads a bundle's config again where it runs, with that environment, so a bundle built once serves with each host's own variables. The types are `ConfigEnv`, `ConfigCommand` and `ConfigFunction`.
|
|
65
|
+
|
|
66
|
+
## Async config
|
|
67
|
+
|
|
68
|
+
The function may be async, and return its config as a promise:
|
|
69
|
+
|
|
73
70
|
```ts
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
import { readFile } from 'node:fs/promises'
|
|
72
|
+
|
|
73
|
+
export default defineConfig(async ({ root }) => ({
|
|
74
|
+
maps: JSON.parse(await readFile(`${root}/maps.json`, 'utf8')),
|
|
77
75
|
}))
|
|
78
76
|
```
|
|
79
77
|
|
|
80
|
-
A config may
|
|
78
|
+
A config may read files of its own with Node's `fs`, and import values from other files, such as a list of map layers, as any module can.
|
|
81
79
|
|
|
82
|
-
##
|
|
80
|
+
## Environment variables
|
|
81
|
+
|
|
82
|
+
Secrets are values like any other, read from the environment. Several keys fall back to a variable of their own when the config leaves them out, such as `url` to `PROTOBASE_URL`; each option names its variable. A TypeScript config reads any other variable from `env` (or `process.env`, which holds the same):
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
export default defineConfig(({ env }) => ({
|
|
86
|
+
auth: { trustedOrigins: env.TUNNEL_URLS?.split(',') },
|
|
87
|
+
}))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A JSON config reads one with an `$env` value: `{ "$env": "NAME" }`, with `"default"` for when the variable is unset or empty, and `"split": ","` for a list of its non-empty parts, each trimmed. A value whose variable is unset and has no default is left out, as if the key were not written. A TypeScript config may write `$env` values too, but its types do not know them; `env` is the typed way.
|
|
83
91
|
|
|
84
|
-
|
|
92
|
+
The app's database is `DATABASE_URL`'s, with the pool size of `PROTOBASE_DB_CONNECTIONS`; neither is a key of the config.
|
|
85
93
|
|
|
86
94
|
## The same config as JSON
|
|
87
95
|
|
|
88
|
-
`protobase.config.json` holds the same object as JSON
|
|
96
|
+
`protobase.config.json` holds the same object as JSON, with [`$env` values](#environment-variables) for what the environment gives:
|
|
89
97
|
|
|
90
98
|
```json
|
|
91
99
|
{
|
|
@@ -97,35 +105,45 @@ Every command reads the config, in a few milliseconds: reading it runs the confi
|
|
|
97
105
|
}
|
|
98
106
|
```
|
|
99
107
|
|
|
100
|
-
A TypeScript config may use `$env` values too. A project has one config file: one with both `protobase.config.ts` and `protobase.config.json` stops every command with an error that names both.
|
|
101
|
-
|
|
102
108
|
JSON cannot branch on the command or compute a value; a config that needs to is written in TypeScript. There is no JSON Schema for the file yet, so a JSON config is checked when the app starts rather than in the editor.
|
|
103
109
|
|
|
104
|
-
##
|
|
110
|
+
## One config per project
|
|
111
|
+
|
|
112
|
+
A project has one config file: one with both `protobase.config.ts` and `protobase.config.json` stops every command with an error that names both. A config cannot extend another itself; [extensions](#extensions) merge folders instead.
|
|
113
|
+
|
|
114
|
+
## Reading it
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
Every command reads the config, in a few milliseconds: reading it runs the config's file and what that file imports, and none of the project's code. A config may not load part of itself later: an `import()` in `protobase.config.ts` stops every command with an error that names it. Code belongs in the files below.
|
|
117
|
+
|
|
118
|
+
## Where the code is
|
|
119
|
+
|
|
120
|
+
Protobase loads each file below only when the app needs it, never while the config is read. Hooks of the project's own get the app's database, `{ db }` (Kysely, as jobs get it), as their last argument. A job named in the config without its `jobs/<name>.ts`, or a write hook without its `hooks/<name>.ts`, stops the app at start with an error that names the file.
|
|
121
|
+
|
|
122
|
+
The resources and roles have no key of their own:
|
|
123
|
+
|
|
124
|
+
| File | What it holds | See |
|
|
107
125
|
| --- | --- | --- |
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
126
|
+
| `config/index.ts`, `config/<dir>/ui.ts` | the resources, views and pages, as exports | [Data config](data-config.md) |
|
|
127
|
+
| `config/roles.ts` | the `roles` export, made with `defineRoles` | [Access](access.md) |
|
|
128
|
+
| `functions/<name>.ts` | an API function, as its default export | [API functions](../guides/api-functions.md) |
|
|
129
|
+
|
|
130
|
+
The other files belong to an option, and are described with it:
|
|
131
|
+
|
|
132
|
+
| File | Option |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `auth/hooks.ts`, `auth/mailer.ts`, `emails/` | [`auth`](config/sign-in.md#auth) |
|
|
135
|
+
| `auth/authenticate.ts` | [`authenticate`](config/sign-in.md#authenticate) |
|
|
136
|
+
| `hooks/<name>.ts` | [`writeHooks`](config/api.md#writehooks) |
|
|
137
|
+
| `hooks/error.ts`, `audit/queue.ts` | [Code of the API](config/api.md#code-of-the-api) |
|
|
138
|
+
| `assistant/tools.ts` | [`assistant`](config/admin-app.md#assistant) |
|
|
139
|
+
| `jobs/<name>.ts` | [`jobs`](config/jobs-and-events.md#jobs) |
|
|
140
|
+
| `webhooks/owner-roles.ts` | [`webhooks`](config/jobs-and-events.md#webhooks) |
|
|
141
|
+
| `notifications/store.ts`, `notifications/history-store.ts`, `notifications/senders.ts` | [`notifications`](config/jobs-and-events.md#notifications) |
|
|
142
|
+
| `files/<name>.ts` | [`files.providers`](config/files.md#filesproviders) |
|
|
125
143
|
|
|
126
144
|
## Extensions
|
|
127
145
|
|
|
128
|
-
`protobase dev --extend <dir>` and `protobase build --extend <dir>` merge an extension's folder into the app, before the project. The extension's folder has a config and code of its own, found by the same paths in that folder.
|
|
146
|
+
`protobase dev --extend <dir>` and `protobase build --extend <dir>` merge an extension's folder into the app, before the project. The extension's folder has a config and code of its own, found by the same paths in that folder.
|
|
129
147
|
|
|
130
148
|
```tsx
|
|
131
149
|
// protobase.ui.tsx
|
|
@@ -6,7 +6,7 @@ React components and action handlers of your own in protobase.ui.tsx, used by na
|
|
|
6
6
|
|
|
7
7
|
Layouts are data; a project's React code lives in one module: `protobase.ui.tsx` at the project root, beside `protobase.config.ts`. It exports each custom component under the name its layouts declare, each from a file of its own, and default-exports `defineUi({ actions })` from `@protobase/ui` for the rest, so the project depends on `@protobase/ui`, and on `react` for its JSX. This is the ERP example's:
|
|
8
8
|
|
|
9
|
-
```tsx title="
|
|
9
|
+
```tsx title="tests/apps/erp/protobase.ui.tsx"
|
|
10
10
|
import { defineUi, type ActionContext } from '@protobase/ui'
|
|
11
11
|
|
|
12
12
|
// The custom components, each in a file of its own, exported by the name their layouts declare.
|
|
@@ -23,7 +23,7 @@ const send = async ({ record, recordKey, etag, client }: ActionContext) => {
|
|
|
23
23
|
export default defineUi({ actions: { send } })
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
```tsx title="
|
|
26
|
+
```tsx title="tests/apps/erp/components/orders-per-day.tsx"
|
|
27
27
|
import { useSeries } from '@protobase/ui'
|
|
28
28
|
|
|
29
29
|
/** Bars for orders per day; the custom component behind `<OrdersPerDay>` in config/overview/page.tsx. */
|
|
@@ -117,7 +117,7 @@ Every option returns a new [field](https://docs.protobase.net/api/schema/interfa
|
|
|
117
117
|
|
|
118
118
|
The ERP's products show most of them, together with soft delete and a tenant:
|
|
119
119
|
|
|
120
|
-
```ts title="
|
|
120
|
+
```ts title="tests/apps/erp/config/products/data.ts"
|
|
121
121
|
import { f, resource } from '@protobase/schema'
|
|
122
122
|
import { erpAccess } from '../roles'
|
|
123
123
|
|
|
@@ -398,7 +398,7 @@ export const workOrders = resource('work_orders')
|
|
|
398
398
|
|
|
399
399
|
Export the roles as `roles` from `config/roles.ts`, where the server finds them, and every operation without a rule needs its capability (`<resource>.<action>`). The ERP's orders use `.owner` and `.search` with the ERP's roles:
|
|
400
400
|
|
|
401
|
-
```ts title="
|
|
401
|
+
```ts title="tests/apps/erp/config/orders/data.ts"
|
|
402
402
|
import { f, resource } from '@protobase/schema'
|
|
403
403
|
import { erpAccess } from '../roles'
|
|
404
404
|
|
|
@@ -12,7 +12,7 @@ An app sends mail through one SMTP server: Protobase's own mail ([password reset
|
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `PROTOBASE_SMTP_URL` | The SMTP server, credential included: `smtp://user:password@host:587` (STARTTLS when the server offers it) or `smtps://user:password@host:465` (TLS from the start). |
|
|
14
14
|
| `PROTOBASE_MAIL_FROM` | The sender, a plain address such as `noreply@shop.example.com`. The client greets the server with its domain; a `?name=` on the URL overrides that. |
|
|
15
|
-
| `PROTOBASE_APP_NAME` | Optional: the app's name, such as `Shop`, which mail clients show as the sender's name (`Shop <noreply@shop.example.com>`). It overrides the config's [`name`](config.md#
|
|
15
|
+
| `PROTOBASE_APP_NAME` | Optional: the app's name, such as `Shop`, which mail clients show as the sender's name (`Shop <noreply@shop.example.com>`). It overrides the config's [`name`](config/app.md#name). Without either the sender has no name. |
|
|
16
16
|
|
|
17
17
|
Set both or neither. One without the other, a URL that is not `smtp://` or `smtps://`, or a sender that is not a plain address stops the app at startup. Without them mail is off: password reset and emailed codes are not offered, a job's `mail` is `undefined`, and sending an app's email rejects.
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ view<typeof apps>('apps')
|
|
|
24
24
|
An entry can list a few of its records under it, each with a status dot, so the ones that need attention are one click away:
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
//
|
|
27
|
+
// tests/apps/erp/config/orders/ui.ts
|
|
28
28
|
export const ordersView = view<typeof orders>('orders')
|
|
29
29
|
.nav({
|
|
30
30
|
recent: {
|
|
@@ -61,4 +61,4 @@ The records come from the list API with the caller's token, so they follow the s
|
|
|
61
61
|
|
|
62
62
|
`/meta` drops the group, and keeps the rest of `nav`, for a caller who cannot read a field it uses (its status, or a field in its filter or order), so it never names a hidden field.
|
|
63
63
|
|
|
64
|
-
`EMAIL=... PASSWORD=... bun scripts/e2e-shell.mjs` checks the groups and the user menu in a browser against a running `bun run --cwd
|
|
64
|
+
`EMAIL=... PASSWORD=... bun scripts/e2e-shell.mjs` checks the groups and the user menu in a browser against a running `bun run --cwd tests/apps/erp dev` (`BASE` for another address), comparing them with what the API gives that user.
|
|
@@ -505,7 +505,7 @@ view<typeof savedSearches>('saved_searches').searchesOf((r) => ({
|
|
|
505
505
|
|
|
506
506
|
The view checks its own fields when the config loads: `filter` and `name` are text fields, `seenAt` a timestamp and each control an enum or boolean. The server checks the rest when it starts: `resource` has an [owner](data-config.md#access), the fields a save or a control writes are writable, `unseen.field` is a filterable timestamp or date of the searched resource, and a view of the resource a list saves to has `searchesOf` for that list. In `/api/meta`, a user who cannot list the searched resource or read `filter` gets the view without `searchesOf`, and its controls and `unseen` narrow to what they can write. A search's filter is checked like any list's when its records load; checking it on a write, against the searched resource, is the data config's: a `.validate` rule with `parseFilter` and `checkFilter`.
|
|
507
507
|
|
|
508
|
-
To tell users of new records, a job matches each new record against the saved filters with `evaluateFilter`, given the searched resource as `search` so that a search text in the filter looks in its search fields too, and sends an [email](email.md). The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/
|
|
508
|
+
To tell users of new records, a job matches each new record against the saved filters with `evaluateFilter`, given the searched resource as `search` so that a search text in the filter looks in its search fields too, and sends an [email](email.md). The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/tests/apps/property-portal#alerts) mails at once or in a daily digest.
|
|
509
509
|
|
|
510
510
|
### Exports
|
|
511
511
|
|
|
@@ -763,7 +763,7 @@ d.map(
|
|
|
763
763
|
|
|
764
764
|
`radius`, `area` and `defaultRadius` need `approximate` or `exact`, and the server refuses to start when a field is of another type. A user who may not read the field that marks the positions sees them as exact.
|
|
765
765
|
|
|
766
|
-
<gap>A map does not edit the position.</gap> List the fields in a section as well when users should change them. The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/
|
|
766
|
+
<gap>A map does not edit the position.</gap> List the fields in a section as well when users should change them. The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/tests/apps/property-portal) shows a listing on a map, and its listings on one.
|
|
767
767
|
|
|
768
768
|
#### Map layers
|
|
769
769
|
|
|
@@ -796,7 +796,7 @@ export default defineConfig({
|
|
|
796
796
|
| `bounds` | Optional `[west, south, east, north]` in degrees, where the tiles are. The layer is offered everywhere; outside its bounds no tiles are asked for and the style's map shows through. |
|
|
797
797
|
| `maxzoom` | Optional deepest zoom of the tiles, from 0 to 24 (default 22); closer in, the map enlarges them. |
|
|
798
798
|
|
|
799
|
-
The browser fetches the tiles, so their host must answer the app's origins with CORS. Layers need a style: without one there is no map to switch. A layer that is not as above stops the server at startup. Use only tiles whose terms allow it: open aerial photos are published per country, such as the Netherlands' [PDOK Luchtfoto](https://www.pdok.nl/-/open-data-hr-luchtfoto) and Spain's [PNOA](https://pnoa.ign.es/) from the IGN, both CC BY 4.0, free and without a key; the [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/
|
|
799
|
+
The browser fetches the tiles, so their host must answer the app's origins with CORS. Layers need a style: without one there is no map to switch. A layer that is not as above stops the server at startup. Use only tiles whose terms allow it: open aerial photos are published per country, such as the Netherlands' [PDOK Luchtfoto](https://www.pdok.nl/-/open-data-hr-luchtfoto) and Spain's [PNOA](https://pnoa.ign.es/) from the IGN, both CC BY 4.0, free and without a key; the [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/tests/apps/property-portal) offers both.
|
|
800
800
|
|
|
801
801
|
### Related records
|
|
802
802
|
|
|
@@ -822,7 +822,7 @@ Without any configuration, the record page's rail has a **Related records** card
|
|
|
822
822
|
|
|
823
823
|
The real estate example lists who a unit is let to (the primary tenant and co-signers of the lease that runs today) and that lease:
|
|
824
824
|
|
|
825
|
-
```ts title="
|
|
825
|
+
```ts title="tests/apps/real-estate/config/units/ui.ts"
|
|
826
826
|
import { l, view } from '@protobase/schema'
|
|
827
827
|
import type { units } from './data'
|
|
828
828
|
|
|
@@ -942,7 +942,7 @@ export const workshopRepairsView = laidOut
|
|
|
942
942
|
|
|
943
943
|
The ERP's orders view uses most of this page at once, with a recent-record group in the sidebar:
|
|
944
944
|
|
|
945
|
-
```ts title="
|
|
945
|
+
```ts title="tests/apps/erp/config/orders/ui.ts"
|
|
946
946
|
import { view } from '@protobase/schema'
|
|
947
947
|
import type { orders } from './data'
|
|
948
948
|
|
|
@@ -9,7 +9,7 @@ The signed-in user sits at the bottom of the sidebar. Clicking them opens a menu
|
|
|
9
9
|
Export one [`userMenu(...)`](https://docs.protobase.net/api/schema/functions/usermenu/) from the config module:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
//
|
|
12
|
+
// tests/apps/erp/config/user-menu.ts, re-exported from config/index.ts
|
|
13
13
|
import { userMenu } from '@protobase/schema'
|
|
14
14
|
|
|
15
15
|
export const accountMenu = userMenu((m) => [
|