@fabrika/cli 0.9.0-cloudflare.3 → 0.9.0-dev.10
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 +12 -12
- package/src/app-dev.ts +1 -1
- package/src/db.ts +8 -5
- package/src/job.ts +2 -2
- package/types/src/job.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/cli",
|
|
3
|
-
"version": "0.9.0-
|
|
3
|
+
"version": "0.9.0-dev.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"zod": "^3.25.76",
|
|
34
|
-
"@fabrika/app": "0.9.0-
|
|
35
|
-
"@fabrika/auth-core": "0.9.0-
|
|
36
|
-
"@fabrika/control-contract": "0.9.0-
|
|
37
|
-
"@fabrika/provider-contract": "0.9.0-
|
|
38
|
-
"@fabrika/db": "0.9.0-
|
|
39
|
-
"@fabrika/platform": "0.9.0-
|
|
40
|
-
"@fabrika/platform-node": "0.9.0-
|
|
41
|
-
"@fabrika/check": "0.9.0-
|
|
34
|
+
"@fabrika/app": "0.9.0-dev.10",
|
|
35
|
+
"@fabrika/auth-core": "0.9.0-dev.10",
|
|
36
|
+
"@fabrika/control-contract": "0.9.0-dev.10",
|
|
37
|
+
"@fabrika/provider-contract": "0.9.0-dev.10",
|
|
38
|
+
"@fabrika/db": "0.9.0-dev.10",
|
|
39
|
+
"@fabrika/platform": "0.9.0-dev.10",
|
|
40
|
+
"@fabrika/platform-node": "0.9.0-dev.10",
|
|
41
|
+
"@fabrika/check": "0.9.0-dev.10"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@fabrika/builder": "0.9.0-
|
|
45
|
-
"@fabrika/provider-cloudflare": "0.9.0-
|
|
46
|
-
"@fabrika/provider-zerops": "0.9.0-
|
|
44
|
+
"@fabrika/builder": "0.9.0-dev.10",
|
|
45
|
+
"@fabrika/provider-cloudflare": "0.9.0-dev.10",
|
|
46
|
+
"@fabrika/provider-zerops": "0.9.0-dev.10"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@fabrika/builder": {
|
package/src/app-dev.ts
CHANGED
|
@@ -240,7 +240,7 @@ async function runSeed(dev: DevKit<AnyContract>, outside: DevOutside, path: stri
|
|
|
240
240
|
return parseSeeded(dev, answer)
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
/** What a
|
|
243
|
+
/** What a request's 5xx or a job attempt threw, printed whole on the developer's terminal. */
|
|
244
244
|
const printHandlerError = (where: string, error: unknown): void => {
|
|
245
245
|
console.error(`fabrika app dev: ${where} threw\n${Bun.inspect(error)}`)
|
|
246
246
|
}
|
package/src/db.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
readApplicationTree,
|
|
13
13
|
scaffoldInputs,
|
|
14
14
|
} from '@fabrika/check'
|
|
15
|
-
import { CodegenError, generateSchema, SCHEMA_FILE } from '@fabrika/db/codegen'
|
|
15
|
+
import { CodegenError, type GeneratedModule, generateSchema, leftOutText, SCHEMA_FILE } from '@fabrika/db/codegen'
|
|
16
16
|
import { generateSqliteSchema } from '@fabrika/db/codegen-sqlite'
|
|
17
17
|
import { FRAMEWORK_MIGRATION_BUNDLE, FRAMEWORK_MIGRATIONS } from '@fabrika/db/migrations'
|
|
18
18
|
import { SQLITE_FRAMEWORK_MIGRATIONS } from '@fabrika/db/migrations-sqlite'
|
|
@@ -160,7 +160,7 @@ const migrate = async (argv: readonly string[], deps: DbCommandDependencies): Pr
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/** The schema module of the migrated application schema, read with the provisioning credential. */
|
|
163
|
-
const postgresSchema = async (deps: DbCommandDependencies): Promise<
|
|
163
|
+
const postgresSchema = async (deps: DbCommandDependencies): Promise<GeneratedModule> => {
|
|
164
164
|
const migrations = applicationMigrations(required(deps.source, 'FABRIKA_APP_ID'), deps.cwd)
|
|
165
165
|
const url = required(deps.source, 'FABRIKA_APP_DATABASE_URL')
|
|
166
166
|
try {
|
|
@@ -172,7 +172,7 @@ const postgresSchema = async (deps: DbCommandDependencies): Promise<string> => {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/** The schema module of the bundles the Durable Object applies, in its order, run in an in-memory database. */
|
|
175
|
-
const sqliteSchema = async (cwd: string): Promise<
|
|
175
|
+
const sqliteSchema = async (cwd: string): Promise<GeneratedModule> =>
|
|
176
176
|
generateSqliteSchema([
|
|
177
177
|
{ bundle: FRAMEWORK_MIGRATION_BUNDLE, migrations: SQLITE_FRAMEWORK_MIGRATIONS },
|
|
178
178
|
{ bundle: APPLICATION_MIGRATION_BUNDLE, migrations: await sqliteApplicationMigrations(cwd) },
|
|
@@ -181,8 +181,10 @@ const sqliteSchema = async (cwd: string): Promise<string> =>
|
|
|
181
181
|
const codegen = async (argv: readonly string[], deps: DbCommandDependencies): Promise<void> => {
|
|
182
182
|
const verify = argv.includes('--verify')
|
|
183
183
|
refuseArguments('codegen', argv.filter((arg) => arg !== '--verify'))
|
|
184
|
-
const source = (await dialectAt(deps.cwd)) === 'sqlite' ? await sqliteSchema(deps.cwd) : await postgresSchema(deps)
|
|
184
|
+
const { source, leftOut } = (await dialectAt(deps.cwd)) === 'sqlite' ? await sqliteSchema(deps.cwd) : await postgresSchema(deps)
|
|
185
185
|
const path = join(deps.cwd, SCHEMA_FILE)
|
|
186
|
+
// Named on every run, --verify's too, so a column the module leaves out is never silent.
|
|
187
|
+
for (const column of leftOut) deps.write(`${leftOutText(`${column.table}.${column.column}`, column.type)}\n`)
|
|
186
188
|
if (verify) {
|
|
187
189
|
const committed = await readFile(path, 'utf8').catch(() => undefined)
|
|
188
190
|
if (committed !== source) throw new Error(`${SCHEMA_FILE} is stale; run fabrika db codegen and commit the result`)
|
|
@@ -217,10 +219,11 @@ const testScaffold = async (argv: readonly string[], deps: DbCommandDependencies
|
|
|
217
219
|
deps.write(`removed ${path}\n`)
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
|
-
for (const [path, { text }] of tests) {
|
|
222
|
+
for (const [path, { text, notes }] of tests) {
|
|
221
223
|
await mkdir(dirname(join(deps.cwd, path)), { recursive: true })
|
|
222
224
|
await writeFile(join(deps.cwd, path), text)
|
|
223
225
|
deps.write(`${path}\n`)
|
|
226
|
+
for (const note of notes) deps.write(`not checked: ${note}\n`)
|
|
224
227
|
}
|
|
225
228
|
if (missing.length > 0) {
|
|
226
229
|
throw new Error(`db test-scaffold: the endpoint access tests are incomplete\n${missing.map(formatFinding).join('\n')}`)
|
package/src/job.ts
CHANGED
|
@@ -16,8 +16,8 @@ come from the environment only and leave the process before ${IMPLEMENTATION_FIL
|
|
|
16
16
|
process started again with the runtime role's credential in place of FABRIKA_APP_DATABASE_URL. A run takes the job's lease
|
|
17
17
|
or does not start. It exits 1 when the job failed, and 0 when it succeeded or a previous run still holds the lease.
|
|
18
18
|
A failure is named by a fixed code (timeout, lease_lost, handler_failed, query_refused, capability_refused,
|
|
19
|
-
driver_failed, crashed, unauthorized, iam_unavailable, boot_failed), never by the
|
|
20
|
-
its catalog reason (query_refused: undeclared_reach).
|
|
19
|
+
framework_fault, unavailable, driver_failed, crashed, unauthorized, iam_unavailable, boot_failed), never by the
|
|
20
|
+
application's error; a framework failure adds its catalog reason (query_refused: undeclared_reach).
|
|
21
21
|
`
|
|
22
22
|
|
|
23
23
|
export interface JobCommandDependencies {
|
package/types/src/job.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ImplementationLoader } from '@fabrika/app/bun';
|
|
2
2
|
import { type JobRunResult } from '@fabrika/app/implement';
|
|
3
|
-
export declare const JOB_USAGE = "fabrika job \u2014 an application's c.cron jobs\n\nUsage:\n fabrika job run <name> Run the job <name> of fabrika.contract.ts once: the command every crontab entry runs.\n The framework's own fabrika-file-scan scans the uploads of scan: true file collections,\n and fabrika-file-sweep deletes the objects of removed and orphaned files.\n\nRun from the application root. The job boots like the server: the framework variables (FABRIKA_APP_ID,\nFABRIKA_APP_DATABASE_URL, FABRIKA_IAM_*, FABRIKA_CONTRACT_DIGEST, FABRIKA_PROXY_SECRET, FABRIKA_OPERATIONS_DSN)\ncome from the environment only and leave the process before src/app.ts loads; the run itself happens in a\nprocess started again with the runtime role's credential in place of FABRIKA_APP_DATABASE_URL. A run takes the job's lease\nor does not start. It exits 1 when the job failed, and 0 when it succeeded or a previous run still holds the lease.\nA failure is named by a fixed code (timeout, lease_lost, handler_failed, query_refused, capability_refused,\
|
|
3
|
+
export declare const JOB_USAGE = "fabrika job \u2014 an application's c.cron jobs\n\nUsage:\n fabrika job run <name> Run the job <name> of fabrika.contract.ts once: the command every crontab entry runs.\n The framework's own fabrika-file-scan scans the uploads of scan: true file collections,\n and fabrika-file-sweep deletes the objects of removed and orphaned files.\n\nRun from the application root. The job boots like the server: the framework variables (FABRIKA_APP_ID,\nFABRIKA_APP_DATABASE_URL, FABRIKA_IAM_*, FABRIKA_CONTRACT_DIGEST, FABRIKA_PROXY_SECRET, FABRIKA_OPERATIONS_DSN)\ncome from the environment only and leave the process before src/app.ts loads; the run itself happens in a\nprocess started again with the runtime role's credential in place of FABRIKA_APP_DATABASE_URL. A run takes the job's lease\nor does not start. It exits 1 when the job failed, and 0 when it succeeded or a previous run still holds the lease.\nA failure is named by a fixed code (timeout, lease_lost, handler_failed, query_refused, capability_refused,\nframework_fault, unavailable, driver_failed, crashed, unauthorized, iam_unavailable, boot_failed), never by the\napplication's error; a framework failure adds its catalog reason (query_refused: undeclared_reach).\n";
|
|
4
4
|
export interface JobCommandDependencies {
|
|
5
5
|
/** The application root. */
|
|
6
6
|
readonly cwd: string;
|