@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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config/admin-app.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Admin app options
|
|
4
|
+
|
|
5
|
+
The config keys of what the admin app draws besides the resources, the assistant, the maps and the plugins, with their types, defaults and environment variables, and the file of the assistant's own tools.
|
|
6
|
+
|
|
7
|
+
The keys of what the admin app draws besides the resources, at the top level of [`protobase.config.ts`](../config.md). The app's language is [`locale`](app.md#locale).
|
|
8
|
+
|
|
9
|
+
## assistant
|
|
10
|
+
|
|
11
|
+
- **Type:** `{ url?: string; apiKey?: string; model?: string; baseUrl?: string; chats?: string } | false`
|
|
12
|
+
- **Default:** the backend of `PROTOBASE_ASSISTANT_URL`; otherwise the built-in one, when `PROTOBASE_ASSISTANT_API_KEY` is set; otherwise none
|
|
13
|
+
- **Environment variables:** `PROTOBASE_ASSISTANT_URL`, `PROTOBASE_ASSISTANT_API_KEY`, `PROTOBASE_ASSISTANT_MODEL`, `PROTOBASE_ASSISTANT_BASE_URL`, `PROTOBASE_ASSISTANT_CHATS`
|
|
14
|
+
|
|
15
|
+
The assistant in the admin app's dock, which admins and the `ai` role see. Each key falls back to its variable:
|
|
16
|
+
|
|
17
|
+
- `url`: an assistant backend elsewhere, which the dock talks to instead of the built-in one.
|
|
18
|
+
- `apiKey`: turns on the built-in assistant, which answers with a chat model.
|
|
19
|
+
- `baseUrl`: the model's OpenAI-compatible endpoint; default OpenRouter's, `https://openrouter.ai/api/v1`.
|
|
20
|
+
- `model`: the model; default `openrouter/auto` with OpenRouter, and required with any other endpoint.
|
|
21
|
+
- `chats`: the folder the built-in assistant keeps conversations in, one file each; default `.protobase/chats`.
|
|
22
|
+
|
|
23
|
+
`false` turns the assistant off. A value that cannot work stops the app at start. See [Assistant](../assistant.md#which-backend).
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
export default defineConfig(({ env }) => ({
|
|
27
|
+
assistant: { apiKey: env.OPENROUTER_API_KEY, model: 'anthropic/claude-sonnet-5.5' },
|
|
28
|
+
}))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The built-in assistant's own tools are the default export of `assistant/tools.ts`, an array of `defineTool(...)`, offered after its own; with [extensions](../config.md#extensions), the extensions' come first. See [The app's own tools](../assistant.md#the-apps-own-tools).
|
|
32
|
+
|
|
33
|
+
## maps
|
|
34
|
+
|
|
35
|
+
- **Type:** `{ style?: string; layers?: { id: string; label: string; tiles: string; attribution: string; bounds?: [number, number, number, number]; maxzoom?: number }[] } | false`
|
|
36
|
+
- **Default:** the style of `PROTOBASE_MAP_STYLE_URL`, when set
|
|
37
|
+
- **Environment variable:** `PROTOBASE_MAP_STYLE_URL`
|
|
38
|
+
|
|
39
|
+
The map style the app's maps (`l.map`, `d.map`) are drawn with, and the layers they may switch to. `style` is the URL of a MapLibre style, such as one of self-hosted PMTiles. Each of `layers` is another map of raster tiles, such as aerial photos: `tiles` is its tile URL with `{z}`, `{x}` and `{y}`, `attribution` the credit its licence asks for, `bounds` where its tiles are (`[west, south, east, north]`), and `maxzoom` the deepest zoom they go to (default 22). Without a style, or with `false`, the app draws no maps. See [Map layers](../ui-config.md#map-layers).
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
maps: {
|
|
44
|
+
style: 'https://tiles.example.com/style.json',
|
|
45
|
+
layers: [{ id: 'aerial', label: 'Aerial', tiles: 'https://tiles.example.com/aerial/{z}/{x}/{y}.jpg', attribution: '© Example' }],
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## plugins
|
|
51
|
+
|
|
52
|
+
- **Type:** `{ url: string; settings?: Record<string, JsonValue>; roles?: string[]; beforeSignIn?: boolean }[] | false`
|
|
53
|
+
- **Default:** none, and those the environment variables list
|
|
54
|
+
- **Environment variables:** `PROTOBASE_PLUGINS` and `PROTOBASE_PLUGINS_BEFORE_SIGN_IN`, plugin.json URLs separated by commas, loaded after the config's
|
|
55
|
+
|
|
56
|
+
The plugins the admin app loads at runtime. `url` names a plugin's `plugin.json`, on another origin or this one (`/plugins/...`); the plugin reads `settings` with `usePlugin()`; with `roles`, only callers holding one of them load it; with `beforeSignIn`, the app loads it before anyone signs in, which cannot go with `roles`. `false` turns off all but the plugins the app's own bundle carries. See [Loading](../plugins.md#loading).
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: [{ url: 'https://plugins.example.com/maps/plugin.json', settings: { zoom: 12 }, roles: ['admin'] }],
|
|
61
|
+
})
|
|
62
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config/api.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# API options
|
|
4
|
+
|
|
5
|
+
The config keys of the REST API, its path, keys, CORS, access defaults, query limits, error reporting, write hooks, MCP tools, remote resources and runtime updates, and the files of the API's own hooks.
|
|
6
|
+
|
|
7
|
+
The keys of the API, at the top level of [`protobase.config.ts`](../config.md). The API itself is described in [REST API](../api.md).
|
|
8
|
+
|
|
9
|
+
## apiPath
|
|
10
|
+
|
|
11
|
+
- **Type:** `string`
|
|
12
|
+
- **Default:** `/api/v1`
|
|
13
|
+
|
|
14
|
+
The path of the REST API on the app's origin.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
export default defineConfig({ apiPath: '/api/v2' })
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## apiKeys
|
|
21
|
+
|
|
22
|
+
- **Type:** `{ publishable_key?: string; secret_key?: string } | false`
|
|
23
|
+
- **Default:** `PROTOBASE_PUBLISHABLE_KEY` and `PROTOBASE_SECRET_KEY`
|
|
24
|
+
- **Environment variables:** `PROTOBASE_PUBLISHABLE_KEY`, `PROTOBASE_SECRET_KEY`
|
|
25
|
+
|
|
26
|
+
The app's two keys, for clients that call it the way they call Supabase: with one, the app serves the PostgREST-compatible `/api/sb/rest/v1`, the Realtime-compatible `/api/sb/realtime/v1` and the Storage-compatible `/api/sb/storage/v1`. The publishable key is safe in a browser and makes a request anonymous or its signed-in user's; the secret key stays on servers and makes a request the app's own. A publishable key that looks like a secret one, the other way round, or both the same stop the app at start. Without either, or with `false`, the app serves none of them. See [Supabase client API](../supabase-rest.md).
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
export default defineConfig(({ env }) => ({
|
|
30
|
+
apiKeys: { publishable_key: env.PUBLISHABLE_KEY, secret_key: env.SECRET_KEY },
|
|
31
|
+
}))
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## cors
|
|
35
|
+
|
|
36
|
+
- **Type:** `'*' | string[]`
|
|
37
|
+
- **Default:** `PROTOBASE_CORS_ORIGINS`, `*` or comma separated, when set
|
|
38
|
+
- **Environment variable:** `PROTOBASE_CORS_ORIGINS`
|
|
39
|
+
|
|
40
|
+
The websites whose browser code may call the API (`/api/*` but `/api/auth/*`) besides the app's own origins: a list of origins, or `*` for any. A [`mobile`](app.md#mobile) section adds the app's Capacitor origins. With none, the API sends no CORS headers for other websites. See [CORS](../api.md#cors).
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
export default defineConfig({ cors: ['https://shop.example.com'] })
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## defaultAccess
|
|
47
|
+
|
|
48
|
+
- **Type:** `'allow' | 'deny'`
|
|
49
|
+
- **Default:** without roles, `allow`; with roles, the capability check
|
|
50
|
+
|
|
51
|
+
What an operation without an access rule does, over the capability check of the roles in `config/roles.ts`. `allow` together with roles opens such operations to every user, and the app warns about it at start. See [Access](../access.md).
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
export default defineConfig({ defaultAccess: 'deny' })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## rowPermissions
|
|
58
|
+
|
|
59
|
+
- **Type:** `boolean | { except: string[] }`
|
|
60
|
+
- **Default:** `true`
|
|
61
|
+
|
|
62
|
+
Whether list items carry their `permissions` (update, delete), or `{ except: [...] }` for the resources that leave them out. See [Record permissions](../api.md#record-permissions).
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
export default defineConfig({ rowPermissions: { except: ['events'] } })
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## statementTimeoutMs
|
|
69
|
+
|
|
70
|
+
- **Type:** `number`
|
|
71
|
+
- **Default:** `1000`
|
|
72
|
+
|
|
73
|
+
How long a query of an API request may run, in milliseconds; a query that runs longer answers `504` and names the request. A query that needs longer wants an index or a simpler filter, or belongs in a function or a job with `longQueries`. See [Safety](../api.md#safety).
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
export default defineConfig({ statementTimeoutMs: 3000 })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## scanGuard
|
|
80
|
+
|
|
81
|
+
- **Type:** `{ mode?: 'reject' | 'warn' | 'off' }`
|
|
82
|
+
- **Default:** `{ mode: 'reject' }`
|
|
83
|
+
|
|
84
|
+
What the API does with reads that filter, sort or count by a column no index serves: refuse them, let them through with a warning, or let them through. See [Safety](../api.md#safety).
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
export default defineConfig({ scanGuard: { mode: 'warn' } })
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## errorReporting
|
|
91
|
+
|
|
92
|
+
- **Type:** `{ dsn?: string; environment?: string } | false`
|
|
93
|
+
- **Default:** the DSN in `PROTOBASE_SENTRY_DSN`, when set
|
|
94
|
+
- **Environment variable:** `PROTOBASE_SENTRY_DSN`
|
|
95
|
+
|
|
96
|
+
Where the app's errors go: the server's `500`s, stopped queries and crashes, and the admin app's errors in the browser. `dsn` is a project's DSN in Sentry or a tracker that speaks its protocol, such as Bugsink or GlitchTip; `environment` names the deployment there. `false` turns it off. A DSN without a public key or a project id stops the app at start. See [Error reporting](../api.md#error-reporting).
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
export default defineConfig(({ command }) => ({
|
|
100
|
+
errorReporting: command === 'dev' ? false : { environment: 'staging' },
|
|
101
|
+
}))
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## writeHooks
|
|
105
|
+
|
|
106
|
+
- **Type:** `string[]`
|
|
107
|
+
- **Default:** none
|
|
108
|
+
|
|
109
|
+
The write hooks by name, run in this order inside each create's, update's and delete's transaction, with that transaction. Each is the default export of `hooks/<name>.ts`, loaded on the first write; a name without its file stops the app at start with an error that names the file. A hook does database work only: while it waits on anything else, such as an HTTP call, the row stays locked, so it enqueues a job for such work. [Enqueueing](../jobs.md#enqueueing) shows a hook that does.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
export default defineConfig({ writeHooks: ['queue-sent-invoice'] })
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## mcpEndpoint
|
|
116
|
+
|
|
117
|
+
- **Type:** `{ sql?: boolean; writes?: boolean | { resources?: string[]; rolesWithoutApproval?: string[] } } | false`
|
|
118
|
+
- **Default:** the read tools only: `list_resources`, `list_records` and `get_record`
|
|
119
|
+
|
|
120
|
+
The MCP endpoint's tools; [`auth.mcp`](sign-in.md#authmcp) turns the endpoint on. `sql: true` also offers admins and the `ai` role `run_read_only_query`, which reads the whole database outside the access rules. `writes: true` offers `create_record` and `update_record` through the REST API's rules, each approved by the person in their client; `writes.resources` limits them to the resources named, and `writes.rolesWithoutApproval` lets holders of those roles, such as a service account, write without the approval. `false` is for a host that serves its own MCP endpoint at `auth.mcp.path`, in front of this app. See [MCP](../mcp.md#the-tools).
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
export default defineConfig({ auth: { mcp: true }, mcpEndpoint: { writes: { resources: ['tasks'] } } })
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## remoteResources
|
|
127
|
+
|
|
128
|
+
- **Type:** `{ url: string; label: string; resources: string[]; roles?: string[] }[] | false`
|
|
129
|
+
- **Default:** those `PROTOBASE_SOURCES` lists
|
|
130
|
+
- **Environment variable:** `PROTOBASE_SOURCES`, a JSON list of the same objects, added after the config's
|
|
131
|
+
|
|
132
|
+
Other Protobase APIs whose resources the admin app draws as its own. `url` is the other API's resources API, such as `https://other.example.com/api/v1`; `label` names it to people when it cannot be reached; `resources` are the ones drawn from it; with `roles`, only callers holding one of them see it. `false` turns off both the config's and the variable's. See [Remote resources](../remote-resources.md#declaring-a-source).
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
export default defineConfig({
|
|
136
|
+
remoteResources: [{ url: 'https://crm.example.com/api/v1', label: 'CRM', resources: ['contacts'] }],
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## runtimeUpdates
|
|
141
|
+
|
|
142
|
+
- **Type:** `{ url?: string } | false`
|
|
143
|
+
- **Default:** `PROTOBASE_RUNTIME_URL`, when set
|
|
144
|
+
- **Environment variable:** `PROTOBASE_RUNTIME_URL`
|
|
145
|
+
|
|
146
|
+
The endpoint that reports the app's runtime version and updates it, such as a hosting platform's; the top bar shows an update button to admins from what it answers. `false` turns it off. See [Runtime updates](../versioning.md#runtime-updates).
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
export default defineConfig({ runtimeUpdates: false })
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Code of the API
|
|
153
|
+
|
|
154
|
+
Two files of the project's own change what the API does, each its default export, with no key in the config:
|
|
155
|
+
|
|
156
|
+
- `hooks/error.ts`: called with every error the API answers `500` for, every query stopped at its statement timeout and every request that found all database connections busy, and the request it failed, so the app can report it. See [Errors](../api.md#errors).
|
|
157
|
+
- `audit/queue.ts`: the `AuditQueue` that receives an event for every reveal of a sensitive field; without it, each is printed to the console and nothing is kept. See [Sensitive fields and audit](../api.md#sensitive-fields-and-audit).
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
// hooks/error.ts
|
|
161
|
+
export default (error: unknown, request?: Request) => {
|
|
162
|
+
console.error(request?.url, error)
|
|
163
|
+
}
|
|
164
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config/app.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# App options
|
|
4
|
+
|
|
5
|
+
The config keys of the app itself, its name, public URL, secret, language, time zone, install colours and mobile build, with their types, defaults and environment variables.
|
|
6
|
+
|
|
7
|
+
The keys of the app itself, at the top level of [`protobase.config.ts`](../config.md).
|
|
8
|
+
|
|
9
|
+
## name
|
|
10
|
+
|
|
11
|
+
- **Type:** `string`
|
|
12
|
+
- **Default:** `Protobase`
|
|
13
|
+
- **Environment variable:** `PROTOBASE_APP_NAME`, which overrides it
|
|
14
|
+
|
|
15
|
+
The app's name: sign-in prompts and passkeys show it, the mail it sends names the app with it and is sent as it, and the sidebar, the browser tabs and the [installed app](../installable-app.md) are called by it. A deployment renames the app with `PROTOBASE_APP_NAME`, which wins over the config. See [App identity](../app-identity.md#the-name).
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
export default defineConfig({ name: 'Property Finder' })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## url
|
|
22
|
+
|
|
23
|
+
- **Type:** `string`
|
|
24
|
+
- **Default:** `PROTOBASE_URL`; in `protobase dev`, the dev server's own address
|
|
25
|
+
- **Environment variable:** `PROTOBASE_URL`
|
|
26
|
+
|
|
27
|
+
The app's public URL: the issuer and audience of its tokens, and where its emails link to. Sign-in needs it: with `auth` on, `protobase dev`, `serve` and the commands that sign people in stop with a clear message when it is missing. Other origins the app is served on are [`auth.origins`](sign-in.md#authorigins).
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
export default defineConfig({ url: 'https://admin.example.com' })
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## secret
|
|
34
|
+
|
|
35
|
+
- **Type:** `string`
|
|
36
|
+
- **Default:** `PROTOBASE_SECRET`
|
|
37
|
+
- **Environment variable:** `PROTOBASE_SECRET`
|
|
38
|
+
|
|
39
|
+
The app's secret, made with `openssl rand -base64 32`: it signs session cookies, upload tickets, download links and public forms' bot checks, and encrypts the token signing keys. Sign-in needs it, and file fields too unless [`files.secret`](files.md#filessecret) names another. Keep it out of the config's source and read it from the environment, which the default does.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
export default defineConfig(({ env }) => ({ secret: env.ADMIN_SECRET }))
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## previousSecrets
|
|
46
|
+
|
|
47
|
+
- **Type:** `string[]`
|
|
48
|
+
- **Default:** `PROTOBASE_PREVIOUS_SECRETS`, comma separated; none
|
|
49
|
+
- **Environment variable:** `PROTOBASE_PREVIOUS_SECRETS`
|
|
50
|
+
|
|
51
|
+
The app's secrets before `secret`, newest first. The app encrypts with `secret` and still decrypts what these encrypted, so after the secret changes the token signing keys keep signing and the tokens in flight keep verifying. Keep an old secret listed until the keys it encrypted have rotated out ([`signingKeyDays`](sign-in.md#signingkeydays)), and while authenticator apps set up before the change are in use. See [Changing the secret](../auth.md#changing-the-secret).
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
export default defineConfig(({ env }) => ({ secret: env.ADMIN_SECRET, previousSecrets: [env.OLD_ADMIN_SECRET] }))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## locale
|
|
58
|
+
|
|
59
|
+
- **Type:** `'en' | 'nl'`
|
|
60
|
+
- **Default:** each user's browser's language, when the screens come in it; English otherwise
|
|
61
|
+
|
|
62
|
+
The language of the admin app's built-in screens and of its numbers and dates, for every user. Any other value stops the app at start. See [Languages](../languages.md).
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
export default defineConfig({ locale: 'nl' })
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## timezone
|
|
69
|
+
|
|
70
|
+
- **Type:** `string`
|
|
71
|
+
- **Default:** `UTC`
|
|
72
|
+
|
|
73
|
+
The time zone the jobs' schedules are read in, such as `Europe/Amsterdam`, unless a job names its own [`timezone`](jobs-and-events.md#jobs). See [Recurring jobs](../jobs.md#recurring-jobs).
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
export default defineConfig({ timezone: 'Europe/Amsterdam' })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## themeColor
|
|
80
|
+
|
|
81
|
+
- **Type:** `string`, any CSS colour
|
|
82
|
+
|
|
83
|
+
The colour of the installed app's title bar and of the browser's toolbar around it, the web manifest's `theme_color`. See [App identity](../app-identity.md#the-colours).
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
export default defineConfig({ themeColor: '#0d9488' })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## backgroundColor
|
|
90
|
+
|
|
91
|
+
- **Type:** `string`, any CSS colour
|
|
92
|
+
|
|
93
|
+
The colour of the screen the installed app shows while it starts, the web manifest's `background_color`.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
export default defineConfig({ backgroundColor: '#ffffff' })
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## mobile
|
|
100
|
+
|
|
101
|
+
- **Type:** `{ appId: string; plugins?: Record<string, string> }`
|
|
102
|
+
|
|
103
|
+
The app's iOS and Android build: with it, `protobase mobile` builds the app with Capacitor, and the API also allows the app's Capacitor origins (`capacitor://localhost`, `https://localhost`) for [CORS](api.md#cors). See [A mobile app](../../guides/mobile-app.md).
|
|
104
|
+
|
|
105
|
+
- `appId`: the app's id on both iOS and Android, such as `com.example.shop`: two or more dot-separated parts, each a letter then letters and digits.
|
|
106
|
+
- `plugins`: extra native Capacitor plugins, by npm name and version range. A range fetched over plain `http:` or `git:` is refused.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
mobile: { appId: 'com.example.shop', plugins: { '@capacitor/camera': '^8.0.0' } },
|
|
111
|
+
})
|
|
112
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config/files.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Files options
|
|
4
|
+
|
|
5
|
+
The config key files, where file fields keep their bytes, with each provider kind, retention, signing, trusted hosts, the Storage API and the image library, their types, defaults and environment variables.
|
|
6
|
+
|
|
7
|
+
The `files` key of [`protobase.config.ts`](../config.md): where [file fields](../files.md) keep their bytes, and how. Every key is optional; without `files`, the providers a field names default to folders under `data/files`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
files: {
|
|
12
|
+
providers: {
|
|
13
|
+
private: { kind: 'local', dir: 'data/files/private' },
|
|
14
|
+
public: { kind: 's3', bucket: 'shop-media', endpoint: 'https://<account>.eu.r2.cloudflarestorage.com', region: 'auto', public: true, publicUrl: 'https://media.shop.com' },
|
|
15
|
+
},
|
|
16
|
+
retention: '7 days',
|
|
17
|
+
images: 'sharp',
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## files.providers
|
|
23
|
+
|
|
24
|
+
- **Type:** `Record<string, LocalProvider | S3Provider | { kind: 'custom' }>`
|
|
25
|
+
- **Default:** `private` and `public`, the folders `data/files/private` and `data/files/public`, when a field names them
|
|
26
|
+
- **Environment variable:** `PROTOBASE_FILES_<NAME>`, which replaces the provider of that name, or adds one
|
|
27
|
+
|
|
28
|
+
The providers by name. A name is part of every stored value, so name the role (`archive`), not the vendor. A field that names a provider the app does not have stops it at start. See [Providers](../files.md#providers).
|
|
29
|
+
|
|
30
|
+
- `{ kind: 'local', dir, public?, publicUrl?, retention?, maxBytes?, maxFiles? }`: a folder on local disk, relative to the working directory and created when missing.
|
|
31
|
+
- `{ kind: 's3', bucket, prefix?, endpoint?, region?, accessKeyId?, secretAccessKey?, public?, publicUrl?, retention?, maxBytes?, maxFiles? }`: an S3-compatible bucket. `endpoint` defaults to AWS; the credentials default to `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY`, then `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. See [S3-compatible buckets](../files.md#s3-compatible-buckets).
|
|
32
|
+
- `{ kind: 'custom' }`: a `FileProvider` of the project's own, the default export of `files/<name>.ts`; a custom provider without its file stops the app at start.
|
|
33
|
+
|
|
34
|
+
For each of the first two, `public` serves files to anyone with the link, without a signature, `publicUrl` is where public files are linked from instead of the app's own `/api/files/<provider>`, such as a CDN, `retention` overrides [`files.retention`](#filesretention), and `maxBytes` (such as `'1 GB'`) and `maxFiles` cap what the provider holds. See [Limits](../files.md#limits).
|
|
35
|
+
|
|
36
|
+
`PROTOBASE_FILES_<NAME>` describes a provider as a URL, such as `PROTOBASE_FILES_ARCHIVE=s3://bucket/prefix?endpoint=…®ion=auto` or `file:///data/files/private?public=1`, with its credentials in `PROTOBASE_FILES_<NAME>_ACCESS_KEY_ID` and `PROTOBASE_FILES_<NAME>_SECRET_ACCESS_KEY`. `RETENTION`, `SECRET` and `CLEANUP_MINUTES` are settings, never provider names.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
files: { providers: { archive: { kind: 's3', bucket: 'archive', prefix: 'invoices' }, scans: { kind: 'custom' } } },
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## files.retention
|
|
45
|
+
|
|
46
|
+
- **Type:** `number | string`
|
|
47
|
+
- **Default:** `1 day`; `0` for a public provider
|
|
48
|
+
- **Environment variable:** `PROTOBASE_FILES_RETENTION`, which overrides it
|
|
49
|
+
|
|
50
|
+
How long bytes outlive their last reference, so a restore of the database to an earlier moment still finds its files: milliseconds, or text such as `14 days`. A provider's own `retention` wins over it. See [Deleting files](../files.md#deleting-files).
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
export default defineConfig({ files: { retention: '14 days' } })
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## files.secret
|
|
57
|
+
|
|
58
|
+
- **Type:** `string`
|
|
59
|
+
- **Default:** `PROTOBASE_FILES_SECRET`, else the app's [`secret`](app.md#secret)
|
|
60
|
+
- **Environment variable:** `PROTOBASE_FILES_SECRET`
|
|
61
|
+
|
|
62
|
+
Signs upload tickets and download links. The app does not start with file fields and no secret.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
export default defineConfig(({ env }) => ({ files: { secret: env.FILES_SECRET } }))
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## files.trustedHosts
|
|
69
|
+
|
|
70
|
+
- **Type:** `string[]`
|
|
71
|
+
- **Default:** none
|
|
72
|
+
|
|
73
|
+
Hosts whose images the admin app draws with the page's referrer, besides the app's own and those its providers link public files from. Images from any other host load with `referrerPolicy="no-referrer"`. See [Image referrers](../files.md#image-referrers).
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
export default defineConfig({ files: { trustedHosts: ['images.example.com'] } })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## files.storage
|
|
80
|
+
|
|
81
|
+
- **Type:** `{ provider?: string; maxFileSize?: number | string } | false`
|
|
82
|
+
- **Default:** `{ provider: 'private', maxFileSize: '50 MB' }`
|
|
83
|
+
|
|
84
|
+
Where `supabase.storage` keeps the bytes of its objects, which the app serves at `/api/sb/storage/v1` when it has an [API key](api.md#apikeys): `provider` names one of the providers, and `maxFileSize` caps every upload, as text or a number of bytes; a bucket's own limit can only be lower. `false` serves no `/api/sb/storage/v1`. See [Supabase Storage API](../supabase-storage.md).
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
export default defineConfig({ files: { storage: { provider: 'uploads', maxFileSize: '10 MB' } } })
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## files.images
|
|
91
|
+
|
|
92
|
+
- **Type:** `'sharp'`
|
|
93
|
+
- **Default:** none
|
|
94
|
+
|
|
95
|
+
The image library that makes the variants and placeholders of image fields, by its package name, loaded from the project's dependencies when the app serves. Fields with `.variants()` or `.placeholder()` need it. See [Image variants and placeholders](../files.md#image-variants-and-placeholders).
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
export default defineConfig({ files: { images: 'sharp' } })
|
|
99
|
+
```
|