@fabrika/app 0.4.7 → 0.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/app",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -93,13 +93,13 @@
93
93
  "test": "bun test --path-ignore-patterns='src/react/**' && bun test --isolate src/react"
94
94
  },
95
95
  "dependencies": {
96
- "@fabrika/auth": "0.4.7",
97
- "@fabrika/auth-core": "0.4.7",
98
- "@fabrika/db": "0.4.7",
99
- "@fabrika/jwks": "0.4.7",
100
- "@fabrika/platform": "0.4.7",
101
- "@fabrika/platform-node": "0.4.7",
102
- "@fabrika/proxy-core": "0.4.7",
96
+ "@fabrika/auth": "0.4.8",
97
+ "@fabrika/auth-core": "0.4.8",
98
+ "@fabrika/db": "0.4.8",
99
+ "@fabrika/jwks": "0.4.8",
100
+ "@fabrika/platform": "0.4.8",
101
+ "@fabrika/platform-node": "0.4.8",
102
+ "@fabrika/proxy-core": "0.4.8",
103
103
  "jose": "^5.9.0"
104
104
  },
105
105
  "peerDependencies": {
package/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: fabrika-app
3
- version: 0.4.7
3
+ version: 0.4.8
4
4
  description: >
5
5
  How to write and change a Fabrika application: src/vocabulary.ts, db/migrations/, src/db/tables.ts, the
6
6
  slices' endpoints.ts with their handlers, fabrika.contract.ts, jobs, files, webhooks, share links, connectors
@@ -19,20 +19,20 @@ the SPA is added with it.
19
19
  "test": "bun test --isolate"
20
20
  },
21
21
  "dependencies": {
22
- "@fabrika/app": "0.4.7",
23
- "@fabrika/db": "0.4.7",
24
- "@fabrika/provider-zerops": "0.4.7",
25
- "@fabrika/proxy-core": "0.4.7",
26
- "@fabrika/ui": "0.4.7",
22
+ "@fabrika/app": "0.4.8",
23
+ "@fabrika/db": "0.4.8",
24
+ "@fabrika/provider-zerops": "0.4.8",
25
+ "@fabrika/proxy-core": "0.4.8",
26
+ "@fabrika/ui": "0.4.8",
27
27
  "kysely": "0.29.6",
28
28
  "react": "^19.0.0",
29
29
  "react-dom": "^19.0.0",
30
30
  "zod": "^3.25.76"
31
31
  },
32
32
  "devDependencies": {
33
- "@fabrika/check": "0.4.7",
34
- "@fabrika/cli": "0.4.7",
35
- "@fabrika/platform": "0.4.7",
33
+ "@fabrika/check": "0.4.8",
34
+ "@fabrika/cli": "0.4.8",
35
+ "@fabrika/platform": "0.4.8",
36
36
  "@happy-dom/global-registrator": "^20.11.2",
37
37
  "@types/bun": "latest",
38
38
  "@types/react": "^19.0.0",
package/src/bun.ts CHANGED
@@ -130,14 +130,28 @@ const PROVISIONING_DATABASE_URL = 'FABRIKA_APP_DATABASE_URL'
130
130
  /** The runtime role's credential, which the launcher derives and hands the application's process in its place. */
131
131
  const RUNTIME_DATABASE_URL = 'FABRIKA_APP_RUNTIME_DATABASE_URL'
132
132
 
133
+ /** The most connections one process opens, as the platform sized it from the database's limit (ADR-0043). */
134
+ const DATABASE_CONNECTIONS = 'FABRIKA_APP_DATABASE_CONNECTIONS'
135
+ /** Without one (a deploy by an older platform, the local stack): the size every process had before the platform sized it. */
136
+ const DEFAULT_DATABASE_CONNECTIONS = 10
137
+ const MAX_DATABASE_CONNECTIONS = 100
138
+
139
+ /** The pool size the platform wrote, the default without one, or null for a value that is no count in range. */
140
+ function databaseConnections(value: string | undefined): number | null {
141
+ if (value === undefined) return DEFAULT_DATABASE_CONNECTIONS
142
+ const count = /^[1-9][0-9]*$/.test(value) ? Number(value) : Number.NaN
143
+ return count <= MAX_DATABASE_CONNECTIONS ? count : null
144
+ }
145
+
133
146
  /**
134
147
  * The application's connection: its runtime role `run_<FABRIKA_APP_ID>`, whose URL the launcher derived from the
135
- * provisioning credential, on the schema `app_<FABRIKA_APP_ID>` its migrations created. A URL is a credential, so no
136
- * message quotes it.
148
+ * provisioning credential, on the schema `app_<FABRIKA_APP_ID>` its migrations created, with at most
149
+ * `FABRIKA_APP_DATABASE_CONNECTIONS` connections. A URL is a credential, so no message quotes it.
137
150
  */
138
151
  function openApplicationDatabase(data: DataLayerOpeners, framework: Readonly<Record<string, string>>): Database {
139
152
  const url = framework[RUNTIME_DATABASE_URL] ?? ''
140
153
  const appId = framework['FABRIKA_APP_ID'] ?? ''
154
+ const connections = framework[DATABASE_CONNECTIONS]
141
155
  const problems: string[] = []
142
156
  if (url.trim() === '') {
143
157
  problems.push('FABRIKA_APP_DATABASE_URL is not set; the platform writes it for an application with a database')
@@ -148,10 +162,14 @@ function openApplicationDatabase(data: DataLayerOpeners, framework: Readonly<Rec
148
162
  } catch {
149
163
  problems.push(`FABRIKA_APP_ID '${appId}' is not an application id (allowed: lowercase letters, digits and -, at most 59)`)
150
164
  }
151
- if (problems.length > 0) {
165
+ const max = databaseConnections(connections)
166
+ if (max === null) {
167
+ problems.push(`${DATABASE_CONNECTIONS} '${connections ?? ''}' is not a number of connections (allowed: 1 to ${MAX_DATABASE_CONNECTIONS})`)
168
+ }
169
+ if (problems.length > 0 || max === null) {
152
170
  throw new BootError(problems)
153
171
  }
154
- return data.postgres({ url, schema })
172
+ return data.postgres({ url, schema, max })
155
173
  }
156
174
 
157
175
  /**
package/src/jobs/scrub.ts CHANGED
@@ -15,6 +15,7 @@ const PUBLIC_FRAMEWORK_VARIABLES: ReadonlySet<string> = new Set([
15
15
  'FABRIKA_APP_ID',
16
16
  'FABRIKA_ENVIRONMENT',
17
17
  'FABRIKA_IAM_RPC_URL',
18
+ 'FABRIKA_APP_DATABASE_CONNECTIONS',
18
19
  FABRIKA_CONTRACT_DIGEST,
19
20
  FABRIKA_IAM_APP_ID,
20
21
  FABRIKA_IAM_ISSUER,