@fabrika/app 0.8.1 → 0.9.0-dev.2

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.
Files changed (135) hide show
  1. package/package.json +35 -24
  2. package/skill/SKILL.md +1 -1
  3. package/skill/references/app-setup.md +8 -8
  4. package/src/dev/changes.ts +35 -0
  5. package/src/dev/contract-digest.ts +17 -0
  6. package/src/dev/index.ts +11 -0
  7. package/src/dev/launcher.ts +604 -0
  8. package/src/dev/output.ts +62 -0
  9. package/src/dev/wire.ts +127 -0
  10. package/types/src/agent-skill.d.ts +29 -0
  11. package/types/src/build.d.ts +11 -0
  12. package/types/src/bun.d.ts +66 -0
  13. package/types/src/client/caller.d.ts +19 -0
  14. package/types/src/client/contract.d.ts +131 -0
  15. package/types/src/client/error-reporting.d.ts +66 -0
  16. package/types/src/client/index.d.ts +4 -0
  17. package/types/src/client/rpc.d.ts +14 -0
  18. package/types/src/client/share.d.ts +2 -0
  19. package/types/src/client/transport.d.ts +42 -0
  20. package/types/src/cloudflare.d.ts +49 -0
  21. package/types/src/contract/artifact-schema.d.ts +8 -0
  22. package/types/src/contract/attachment.d.ts +41 -0
  23. package/types/src/contract/build.d.ts +12 -0
  24. package/types/src/contract/compile.d.ts +11 -0
  25. package/types/src/contract/connect.d.ts +51 -0
  26. package/types/src/contract/context.d.ts +501 -0
  27. package/types/src/contract/declaration.d.ts +303 -0
  28. package/types/src/contract/defaults.d.ts +208 -0
  29. package/types/src/contract/define.d.ts +359 -0
  30. package/types/src/contract/file.d.ts +44 -0
  31. package/types/src/contract/group.d.ts +274 -0
  32. package/types/src/contract/handled.d.ts +18 -0
  33. package/types/src/contract/index.d.ts +19 -0
  34. package/types/src/contract/kit.d.ts +210 -0
  35. package/types/src/contract/platform.d.ts +9 -0
  36. package/types/src/contract/problems.d.ts +14 -0
  37. package/types/src/contract/redirect.d.ts +25 -0
  38. package/types/src/contract/schema-from-shape.d.ts +10 -0
  39. package/types/src/contract/schema-shape.d.ts +5 -0
  40. package/types/src/contract/snapshot-source.d.ts +15 -0
  41. package/types/src/contract/token.d.ts +58 -0
  42. package/types/src/contract/vocabulary.d.ts +30 -0
  43. package/types/src/contract/webhook-binding.d.ts +24 -0
  44. package/types/src/contract/webhook-scheme.d.ts +23 -0
  45. package/types/src/dev/changes.d.ts +7 -0
  46. package/types/src/dev/contract-digest.d.ts +1 -0
  47. package/types/src/dev/index.d.ts +2 -0
  48. package/types/src/dev/launcher.d.ts +32 -0
  49. package/types/src/dev/output.d.ts +22 -0
  50. package/types/src/dev/wire.d.ts +122 -0
  51. package/types/src/disk-assets.d.ts +3 -0
  52. package/types/src/errors.d.ts +46 -0
  53. package/types/src/fetch.d.ts +7 -0
  54. package/types/src/files/archive.d.ts +26 -0
  55. package/types/src/files/clamscan.d.ts +32 -0
  56. package/types/src/files/handle.d.ts +106 -0
  57. package/types/src/files/kinds.d.ts +105 -0
  58. package/types/src/files/scan.d.ts +80 -0
  59. package/types/src/files/sniff.d.ts +7 -0
  60. package/types/src/files/streams.d.ts +17 -0
  61. package/types/src/files/treatment.d.ts +18 -0
  62. package/types/src/from-row.d.ts +20 -0
  63. package/types/src/honeypot.d.ts +2 -0
  64. package/types/src/implement/anonymous.d.ts +26 -0
  65. package/types/src/implement/attachment.d.ts +14 -0
  66. package/types/src/implement/boot.d.ts +109 -0
  67. package/types/src/implement/bounded.d.ts +22 -0
  68. package/types/src/implement/browser-config.d.ts +19 -0
  69. package/types/src/implement/capability.d.ts +140 -0
  70. package/types/src/implement/challenge.d.ts +75 -0
  71. package/types/src/implement/client-address.d.ts +11 -0
  72. package/types/src/implement/connect.d.ts +67 -0
  73. package/types/src/implement/crashes.d.ts +31 -0
  74. package/types/src/implement/dispatch.d.ts +218 -0
  75. package/types/src/implement/egress.d.ts +14 -0
  76. package/types/src/implement/environment.d.ts +14 -0
  77. package/types/src/implement/failures.d.ts +34 -0
  78. package/types/src/implement/faults.d.ts +44 -0
  79. package/types/src/implement/headers.d.ts +7 -0
  80. package/types/src/implement/implement.d.ts +58 -0
  81. package/types/src/implement/index.d.ts +24 -0
  82. package/types/src/implement/invocation.d.ts +120 -0
  83. package/types/src/implement/membership.d.ts +201 -0
  84. package/types/src/implement/multipart.d.ts +36 -0
  85. package/types/src/implement/params.d.ts +7 -0
  86. package/types/src/implement/principal.d.ts +52 -0
  87. package/types/src/implement/project.d.ts +11 -0
  88. package/types/src/implement/public.d.ts +61 -0
  89. package/types/src/implement/serve.d.ts +25 -0
  90. package/types/src/implement/tokens.d.ts +49 -0
  91. package/types/src/implement/types.d.ts +243 -0
  92. package/types/src/implement/urls.d.ts +15 -0
  93. package/types/src/implement/verifiers.d.ts +19 -0
  94. package/types/src/implement/webhook.d.ts +55 -0
  95. package/types/src/implement/workload.d.ts +56 -0
  96. package/types/src/implement/xlsx.d.ts +6 -0
  97. package/types/src/index.d.ts +12 -0
  98. package/types/src/jobs/exception.d.ts +40 -0
  99. package/types/src/jobs/mail.d.ts +67 -0
  100. package/types/src/jobs/report.d.ts +56 -0
  101. package/types/src/jobs/runner.d.ts +145 -0
  102. package/types/src/jobs/schedule.d.ts +15 -0
  103. package/types/src/jobs/scrub.d.ts +12 -0
  104. package/types/src/jobs/types.d.ts +92 -0
  105. package/types/src/react/caller.d.ts +30 -0
  106. package/types/src/react/errors.d.ts +40 -0
  107. package/types/src/react/hooks.d.ts +110 -0
  108. package/types/src/react/index.d.ts +5 -0
  109. package/types/src/react/provider.d.ts +58 -0
  110. package/types/src/react/store.d.ts +68 -0
  111. package/types/src/react/testing.d.ts +28 -0
  112. package/types/src/react/types.d.ts +33 -0
  113. package/types/src/rpc/builder.d.ts +52 -0
  114. package/types/src/rpc/contract.d.ts +23 -0
  115. package/types/src/rpc/dispatcher.d.ts +11 -0
  116. package/types/src/rpc/types.d.ts +62 -0
  117. package/types/src/service/define.d.ts +42 -0
  118. package/types/src/service/index.d.ts +3 -0
  119. package/types/src/service/serve.d.ts +28 -0
  120. package/types/src/standard-schema.d.ts +55 -0
  121. package/types/src/testing/caller.d.ts +95 -0
  122. package/types/src/testing/challenge.d.ts +11 -0
  123. package/types/src/testing/dev.d.ts +97 -0
  124. package/types/src/testing/endpoint-access.d.ts +99 -0
  125. package/types/src/testing/index.d.ts +12 -0
  126. package/types/src/testing/isolation.d.ts +3 -0
  127. package/types/src/testing/kit.d.ts +182 -0
  128. package/types/src/testing/membership.d.ts +132 -0
  129. package/types/src/testing/policy-isolation.d.ts +113 -0
  130. package/types/src/testing/preload.d.ts +1 -0
  131. package/types/src/testing/proxy.d.ts +40 -0
  132. package/types/src/testing/runner.d.ts +8 -0
  133. package/types/src/testing/sample-file.d.ts +5 -0
  134. package/types/src/testing/status.d.ts +4 -0
  135. package/types/src/undumpable.d.ts +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/app",
3
- "version": "0.8.1",
3
+ "version": "0.9.0-dev.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,77 +14,88 @@
14
14
  "files": [
15
15
  "src",
16
16
  "skill",
17
- "!src/**/__tests__/**"
17
+ "!src/**/__tests__/**",
18
+ "types"
18
19
  ],
19
20
  "exports": {
20
21
  ".": {
21
22
  "bun": "./src/index.ts",
22
- "types": "./src/index.ts",
23
+ "types": "./types/src/index.d.ts",
23
24
  "default": "./src/index.ts"
24
25
  },
25
26
  "./bun": {
26
27
  "bun": "./src/bun.ts",
27
- "types": "./src/bun.ts",
28
+ "types": "./types/src/bun.d.ts",
28
29
  "default": "./src/bun.ts"
29
30
  },
30
31
  "./cloudflare": {
31
32
  "bun": "./src/cloudflare.ts",
32
- "types": "./src/cloudflare.ts",
33
+ "types": "./types/src/cloudflare.d.ts",
33
34
  "default": "./src/cloudflare.ts"
34
35
  },
35
36
  "./contract": {
36
37
  "bun": "./src/contract/index.ts",
37
- "types": "./src/contract/index.ts",
38
+ "types": "./types/src/contract/index.d.ts",
38
39
  "default": "./src/contract/index.ts"
39
40
  },
40
41
  "./client": {
41
42
  "bun": "./src/client/index.ts",
42
- "types": "./src/client/index.ts",
43
+ "types": "./types/src/client/index.d.ts",
43
44
  "default": "./src/client/index.ts"
44
45
  },
45
46
  "./react": {
46
47
  "bun": "./src/react/index.ts",
47
- "types": "./src/react/index.ts",
48
+ "types": "./types/src/react/index.d.ts",
48
49
  "default": "./src/react/index.ts"
49
50
  },
50
51
  "./react/testing": {
51
52
  "bun": "./src/react/testing.ts",
52
- "types": "./src/react/testing.ts",
53
+ "types": "./types/src/react/testing.d.ts",
53
54
  "default": "./src/react/testing.ts"
54
55
  },
55
56
  "./implement": {
56
57
  "bun": "./src/implement/index.ts",
57
- "types": "./src/implement/index.ts",
58
+ "types": "./types/src/implement/index.d.ts",
58
59
  "default": "./src/implement/index.ts"
59
60
  },
60
61
  "./service": {
61
62
  "bun": "./src/service/index.ts",
62
- "types": "./src/service/index.ts",
63
+ "types": "./types/src/service/index.d.ts",
63
64
  "default": "./src/service/index.ts"
64
65
  },
65
66
  "./build": {
66
67
  "bun": "./src/build.ts",
67
- "types": "./src/build.ts",
68
+ "types": "./types/src/build.d.ts",
68
69
  "default": "./src/build.ts"
69
70
  },
70
71
  "./testing": {
71
72
  "bun": "./src/testing/index.ts",
72
- "types": "./src/testing/index.ts",
73
+ "types": "./types/src/testing/index.d.ts",
73
74
  "default": "./src/testing/index.ts"
74
75
  },
75
76
  "./testing/isolation": {
76
77
  "bun": "./src/testing/isolation.ts",
77
- "types": "./src/testing/isolation.ts",
78
+ "types": "./types/src/testing/isolation.d.ts",
78
79
  "default": "./src/testing/isolation.ts"
79
80
  },
80
81
  "./testing/preload": {
81
82
  "bun": "./src/testing/preload.ts",
82
- "types": "./src/testing/preload.ts",
83
+ "types": "./types/src/testing/preload.d.ts",
83
84
  "default": "./src/testing/preload.ts"
84
85
  },
86
+ "./dev": {
87
+ "bun": "./src/dev/index.ts",
88
+ "types": "./types/src/dev/index.d.ts",
89
+ "default": "./src/dev/index.ts"
90
+ },
91
+ "./dev/wire": {
92
+ "bun": "./src/dev/wire.ts",
93
+ "types": "./types/src/dev/wire.d.ts",
94
+ "default": "./src/dev/wire.ts"
95
+ },
85
96
  "./agent-skill": {
86
97
  "bun": "./src/agent-skill.ts",
87
- "types": "./src/agent-skill.ts",
98
+ "types": "./types/src/agent-skill.d.ts",
88
99
  "default": "./src/agent-skill.ts"
89
100
  }
90
101
  },
@@ -93,14 +104,14 @@
93
104
  "test": "bun test --path-ignore-patterns='src/react/**' && bun test --isolate src/react"
94
105
  },
95
106
  "dependencies": {
96
- "@fabrika/auth": "0.8.1",
97
- "@fabrika/auth-core": "0.8.1",
98
- "@fabrika/db": "0.8.1",
99
- "@fabrika/email": "0.8.1",
100
- "@fabrika/jwks": "0.8.1",
101
- "@fabrika/platform": "0.8.1",
102
- "@fabrika/platform-node": "0.8.1",
103
- "@fabrika/proxy-core": "0.8.1",
107
+ "@fabrika/auth": "0.9.0-dev.2",
108
+ "@fabrika/auth-core": "0.9.0-dev.2",
109
+ "@fabrika/db": "0.9.0-dev.2",
110
+ "@fabrika/email": "0.9.0-dev.2",
111
+ "@fabrika/jwks": "0.9.0-dev.2",
112
+ "@fabrika/platform": "0.9.0-dev.2",
113
+ "@fabrika/platform-node": "0.9.0-dev.2",
114
+ "@fabrika/proxy-core": "0.9.0-dev.2",
104
115
  "altcha-lib": "2.6.0",
105
116
  "jose": "^5.9.0"
106
117
  },
package/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: fabrika-app
3
- version: 0.8.1
3
+ version: 0.9.0-dev.2
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.8.1",
23
- "@fabrika/db": "0.8.1",
24
- "@fabrika/provider-zerops": "0.8.1",
25
- "@fabrika/proxy-core": "0.8.1",
26
- "@fabrika/ui": "0.8.1",
22
+ "@fabrika/app": "0.9.0-dev.2",
23
+ "@fabrika/db": "0.9.0-dev.2",
24
+ "@fabrika/provider-zerops": "0.9.0-dev.2",
25
+ "@fabrika/proxy-core": "0.9.0-dev.2",
26
+ "@fabrika/ui": "0.9.0-dev.2",
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.8.1",
34
- "@fabrika/cli": "0.8.1",
35
- "@fabrika/platform": "0.8.1",
33
+ "@fabrika/check": "0.9.0-dev.2",
34
+ "@fabrika/cli": "0.9.0-dev.2",
35
+ "@fabrika/platform": "0.9.0-dev.2",
36
36
  "@happy-dom/global-registrator": "^20.11.2",
37
37
  "@types/bun": "latest",
38
38
  "@types/react": "^19.0.0",
@@ -0,0 +1,35 @@
1
+ // What a sync changes, read off its paths: whether the build owns one (then the commit needs a bootstrap run), whether
2
+ // the migrations changed, and whether a web source did. Whether the contract changed is the digest's to say, not a path's.
3
+
4
+ import { CONTRACT_FILE } from '../build.js'
5
+
6
+ /** The application's migrations, as `fabrika db migrate` reads them. */
7
+ export const MIGRATIONS_DIRECTORY = 'db/migrations/'
8
+
9
+ /** Files whose change the build turns into something else: an install, or the generated run and build descriptors. */
10
+ const BUILD_OWNED_FILES: ReadonlySet<string> = new Set(['package.json', 'bun.lock', 'bun.lockb', 'bunfig.toml', 'zerops.yaml', 'zerops.yml'])
11
+ const BUILD_OWNED_DIRECTORIES = ['fabrika/', 'node_modules/'] as const
12
+
13
+ /** Server code and the database: a change only there leaves the SPA as it is. */
14
+ const SERVER_DIRECTORIES = ['src/', 'db/'] as const
15
+
16
+ /** Why the change needs a bootstrap run, in one line, or null when the launcher may apply it. */
17
+ export function bootstrapReason(paths: readonly string[]): string | null {
18
+ for (const path of paths) {
19
+ const why = BUILD_OWNED_FILES.has(path)
20
+ ? 'the dependencies, the lockfile or the build descriptor'
21
+ : BUILD_OWNED_DIRECTORIES.some((directory) => path.startsWith(directory))
22
+ ? 'the generated files or the installed packages'
23
+ : path !== CONTRACT_FILE && path.startsWith('fabrika.') && !path.includes('/')
24
+ ? 'a fabrika.* file'
25
+ : null
26
+ if (why !== null) return `${path} changed, which is ${why}; that needs a bootstrap run: call bind_dev again`
27
+ }
28
+ return null
29
+ }
30
+
31
+ export const migrationsChanged = (paths: readonly string[]): boolean => paths.some((path) => path.startsWith(MIGRATIONS_DIRECTORY))
32
+
33
+ /** A change outside the server code and the database may reach the SPA, so its build runs again. */
34
+ export const webSourceChanged = (paths: readonly string[]): boolean =>
35
+ paths.some((path) => !SERVER_DIRECTORIES.some((directory) => path.startsWith(directory)))
@@ -0,0 +1,17 @@
1
+ // The launcher's child that answers whether a commit changed the contract (ADR-0049). It runs in the application root
2
+ // with no credential in its environment, loads the application module the launcher itself never loads, and prints the
3
+ // digest the application's boot compares with `FABRIKA_CONTRACT_DIGEST`.
4
+
5
+ import { contractDigest } from '@fabrika/auth-core'
6
+ import { join } from 'node:path'
7
+ import { IMPLEMENTATION_FILE } from '../build.js'
8
+ import { compileContract } from '../contract/compile.js'
9
+ import { isContractImplementation } from '../implement/implement.js'
10
+
11
+ const module: unknown = await import(join(process.cwd(), IMPLEMENTATION_FILE))
12
+ const app = typeof module === 'object' && module !== null ? Reflect.get(module, 'default') : undefined
13
+ if (!isContractImplementation(app)) {
14
+ console.error(`${IMPLEMENTATION_FILE} does not default-export serve(contract, { … })`)
15
+ process.exit(1)
16
+ }
17
+ console.log(contractDigest(compileContract(app.contract, app.database?.tables ?? {})))
@@ -0,0 +1,11 @@
1
+ // @fabrika/app/dev — the launcher of a `dev` environment, which the generated dev entrypoint runs (Bun only).
2
+
3
+ export { bootstrapReason, migrationsChanged, webSourceChanged } from './changes.js'
4
+ export {
5
+ type DevLauncher,
6
+ type DevLauncherOptions,
7
+ type DevSourceTransport,
8
+ readDevLauncherConfig,
9
+ runDevLauncher,
10
+ startDevLauncher,
11
+ } from './launcher.js'