@fabrika/app 0.9.0-dev.4 → 0.9.0-dev.6

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 (113) hide show
  1. package/package.json +9 -9
  2. package/skill/SKILL.md +41 -14
  3. package/skill/references/app-setup.md +43 -12
  4. package/skill/references/dev.md +2 -1
  5. package/skill/references/endpoint.md +30 -24
  6. package/skill/references/errors.md +40 -35
  7. package/skill/references/files.md +4 -2
  8. package/skill/references/jobs.md +21 -4
  9. package/skill/references/table-and-migration.md +19 -2
  10. package/skill/references/tests.md +40 -1
  11. package/skill/references/webhooks-links-connectors.md +1 -1
  12. package/src/build-recipe.ts +198 -0
  13. package/src/build.ts +60 -4
  14. package/src/bun.ts +181 -13
  15. package/src/cloudflare/application.ts +822 -0
  16. package/src/cloudflare/bindings.ts +159 -0
  17. package/src/cloudflare/export.ts +621 -0
  18. package/src/cloudflare/import.ts +1013 -0
  19. package/src/cloudflare/maintenance.ts +518 -0
  20. package/src/cloudflare/names.ts +16 -0
  21. package/src/cloudflare/ops.ts +375 -0
  22. package/src/cloudflare/r2-files.ts +172 -0
  23. package/src/cloudflare/restore.ts +167 -0
  24. package/src/cloudflare/tracker.ts +192 -0
  25. package/src/cloudflare.ts +100 -146
  26. package/src/contract/app-id.ts +5 -0
  27. package/src/contract/artifact-schema.ts +9 -1
  28. package/src/contract/build.ts +40 -2
  29. package/src/contract/compile.ts +1 -0
  30. package/src/contract/context.ts +35 -9
  31. package/src/contract/declaration.ts +2 -0
  32. package/src/contract/defaults.ts +22 -2
  33. package/src/contract/define.ts +29 -3
  34. package/src/contract/kit.ts +4 -1
  35. package/src/contract/platform.ts +3 -2
  36. package/src/contract/vocabulary.ts +26 -8
  37. package/src/dev/launcher.ts +50 -4
  38. package/src/disk-assets.ts +8 -3
  39. package/src/files/archive.ts +2 -2
  40. package/src/files/job-names.ts +12 -0
  41. package/src/files/kinds.ts +73 -31
  42. package/src/files/scan.ts +3 -4
  43. package/src/files/streams.ts +3 -1
  44. package/src/implement/anonymous.ts +12 -11
  45. package/src/implement/boot.ts +75 -6
  46. package/src/implement/bounded.ts +21 -2
  47. package/src/implement/capability.ts +15 -3
  48. package/src/implement/dispatch.ts +419 -177
  49. package/src/implement/failures.ts +17 -1
  50. package/src/implement/faults.ts +1 -0
  51. package/src/implement/index.ts +1 -0
  52. package/src/implement/invocation.ts +58 -10
  53. package/src/implement/principal.ts +25 -2
  54. package/src/implement/terminals.ts +93 -0
  55. package/src/implement/workload.ts +42 -16
  56. package/src/jobs/mail.ts +8 -0
  57. package/src/jobs/report.ts +5 -1
  58. package/src/jobs/runner.ts +672 -113
  59. package/src/jobs/schedule.ts +7 -1
  60. package/src/jobs/scrub.ts +14 -1
  61. package/src/jobs/types.ts +6 -0
  62. package/src/spa-fallback.ts +12 -0
  63. package/src/testing/endpoint-access.ts +307 -152
  64. package/src/testing/isolation.ts +8 -1
  65. package/src/testing/kit.ts +80 -2
  66. package/src/testing/proxy.ts +15 -10
  67. package/types/src/build-recipe.d.ts +70 -0
  68. package/types/src/build.d.ts +19 -1
  69. package/types/src/bun.d.ts +34 -1
  70. package/types/src/cloudflare/application.d.ts +73 -0
  71. package/types/src/cloudflare/bindings.d.ts +33 -0
  72. package/types/src/cloudflare/export.d.ts +16 -0
  73. package/types/src/cloudflare/import.d.ts +51 -0
  74. package/types/src/cloudflare/maintenance.d.ts +117 -0
  75. package/types/src/cloudflare/names.d.ts +11 -0
  76. package/types/src/cloudflare/ops.d.ts +81 -0
  77. package/types/src/cloudflare/r2-files.d.ts +9 -0
  78. package/types/src/cloudflare/restore.d.ts +9 -0
  79. package/types/src/cloudflare/tracker.d.ts +29 -0
  80. package/types/src/cloudflare.d.ts +12 -18
  81. package/types/src/contract/app-id.d.ts +2 -0
  82. package/types/src/contract/artifact-schema.d.ts +2 -0
  83. package/types/src/contract/context.d.ts +35 -11
  84. package/types/src/contract/declaration.d.ts +4 -0
  85. package/types/src/contract/defaults.d.ts +19 -1
  86. package/types/src/contract/define.d.ts +20 -3
  87. package/types/src/contract/kit.d.ts +2 -1
  88. package/types/src/contract/platform.d.ts +2 -2
  89. package/types/src/contract/vocabulary.d.ts +9 -7
  90. package/types/src/disk-assets.d.ts +4 -1
  91. package/types/src/files/job-names.d.ts +9 -0
  92. package/types/src/files/kinds.d.ts +21 -14
  93. package/types/src/files/scan.d.ts +1 -3
  94. package/types/src/implement/anonymous.d.ts +2 -4
  95. package/types/src/implement/boot.d.ts +17 -1
  96. package/types/src/implement/bounded.d.ts +11 -1
  97. package/types/src/implement/capability.d.ts +4 -2
  98. package/types/src/implement/dispatch.d.ts +34 -1
  99. package/types/src/implement/failures.d.ts +5 -0
  100. package/types/src/implement/faults.d.ts +1 -0
  101. package/types/src/implement/index.d.ts +1 -0
  102. package/types/src/implement/invocation.d.ts +22 -7
  103. package/types/src/implement/principal.d.ts +6 -1
  104. package/types/src/implement/terminals.d.ts +33 -0
  105. package/types/src/implement/workload.d.ts +5 -0
  106. package/types/src/jobs/runner.d.ts +66 -2
  107. package/types/src/jobs/schedule.d.ts +2 -0
  108. package/types/src/jobs/types.d.ts +6 -0
  109. package/types/src/spa-fallback.d.ts +2 -0
  110. package/types/src/testing/endpoint-access.d.ts +37 -5
  111. package/types/src/testing/isolation.d.ts +1 -1
  112. package/types/src/testing/kit.d.ts +22 -1
  113. package/types/src/testing/proxy.d.ts +4 -4
@@ -1,4 +1,4 @@
1
- import { type ContractArtifact, type IamMembershipRpc } from '@fabrika/auth-core';
1
+ import { type ContractArtifact, type IamMembershipRpc, type IamTerminalRpc } from '@fabrika/auth-core';
2
2
  import type { Database } from '@fabrika/db';
3
3
  import { MemoryEmailSender } from '@fabrika/email/memory';
4
4
  import type { FileObjectStore } from '@fabrika/platform';
@@ -48,6 +48,11 @@ export interface TestKitOptions {
48
48
  * kit's proxy obtains each delegation grant from it. Without it the kit's IAM answers them under IAM's rules.
49
49
  */
50
50
  readonly membership?: IamMembershipRpc;
51
+ /**
52
+ * IAM's identifications at a terminal (ADR-0067), for a contract that declares one. Without it the kit's IAM knows no
53
+ * open identification: `inspect` answers null and `assert` `not_found`.
54
+ */
55
+ readonly terminals?: IamTerminalRpc;
51
56
  /**
52
57
  * Each import's owner, by the import's name: its origin and edge key, which the platform writes as the import's
53
58
  * framework variables, and how a request reaches it — usually the owner kit's `fetch`.
@@ -121,6 +126,17 @@ export interface TestKit<C extends AnyContract> {
121
126
  runJob(name: JobName<C> | typeof FILE_SCAN_JOB | typeof FILE_SWEEP_JOB, options?: JobRunOptions): Promise<JobRunResult>;
122
127
  /** Waits for the work requests left running: the runs a site's `ctx.kick` sent, a failure's report. */
123
128
  drain(): Promise<void>;
129
+ /**
130
+ * Runs every job with a wake due now or within `within` ms (0 by default) once, as the Cloudflare object's alarm
131
+ * runs it: the startup repair first (each job's cron wake at its next fire), then each wake ahead moved to now, then
132
+ * each due job under its lease, a failed run's retry moved to its backoff. It first waits for the runs a site's
133
+ * `ctx.kick` sent. Nothing else fires on its own. Handlers keep real time: only the wakes move, never the clock, so
134
+ * a run again schedules its cron fire from now, and a later call skips a cron fire this kit already ran early. Needs
135
+ * the application's data layer.
136
+ */
137
+ runDueJobs(options?: {
138
+ readonly within?: number;
139
+ }): Promise<readonly DueJobRun[]>;
124
140
  /**
125
141
  * The stand-in for every job's transport: what reached it (`accepted`, `handoffs`) and its faults (`refuse`,
126
142
  * `unavailable`, `unreachable`, `loseAnswers`, `during`, `heal`). Each message carries the transport key,
@@ -143,6 +159,11 @@ export interface TestKit<C extends AnyContract> {
143
159
  */
144
160
  solveChallenge(procedure: object): Promise<string>;
145
161
  }
162
+ /** A job `runDueJobs` ran, and its run's result. */
163
+ export interface DueJobRun {
164
+ readonly job: string;
165
+ readonly result: JobRunResult;
166
+ }
146
167
  /** The names of the contract's cron jobs. */
147
168
  export type JobName<C> = C extends {
148
169
  readonly surface: {
@@ -3,12 +3,12 @@ import { type DelegationIssuer, type IamGateway, type TokenCache } from '@fabrik
3
3
  /** What the proxy did with a request: answered it itself, or forwarded it with what only the proxy may set. */
4
4
  export type ProxyOutcome = {
5
5
  readonly outcome: 'forward';
6
- /** Every header only the proxy may assert, with the value the decision gave it. */
7
- readonly asserted: ReadonlyMap<string, string>;
8
6
  /**
9
- * Whether the request's own `Authorization` reaches the application: not on an anonymous endpoint, except a webhook
10
- * row the decision marked to pass it on.
7
+ * Every header only the proxy may assert, with the value the decision gave it. A credentialed request that carried
8
+ * `Authorization` has it replaced by the minted token, so the caller's `px_` key never reaches the application.
11
9
  */
10
+ readonly asserted: ReadonlyMap<string, string>;
11
+ /** Whether the request's own `Authorization` reaches the application: only on a webhook row the decision marked to pass it on. */
12
12
  readonly keepsAuthorization: boolean;
13
13
  /** What the application's answer is given for an admitted cross-origin request, over its own headers. */
14
14
  readonly decorate: (headers: Headers) => void;