@fabrika/provider-zerops 0.9.0-dev.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 (93) hide show
  1. package/package.json +15 -14
  2. package/src/execution.ts +45 -8
  3. package/types/src/api/client.d.ts +5 -0
  4. package/types/src/api/errors.d.ts +24 -0
  5. package/types/src/api/polling.d.ts +41 -0
  6. package/types/src/api/readers.d.ts +977 -0
  7. package/types/src/api/service-env-limit.d.ts +17 -0
  8. package/types/src/api/service-env-response.d.ts +23 -0
  9. package/types/src/api/types.d.ts +638 -0
  10. package/types/src/api.d.ts +6 -0
  11. package/types/src/authoring.d.ts +9 -0
  12. package/types/src/cli-args.d.ts +19 -0
  13. package/types/src/cli.d.ts +10 -0
  14. package/types/src/collaborators.d.ts +18 -0
  15. package/types/src/compile.d.ts +91 -0
  16. package/types/src/control.d.ts +41 -0
  17. package/types/src/database-budget.d.ts +38 -0
  18. package/types/src/descriptor.d.ts +28 -0
  19. package/types/src/execution.d.ts +137 -0
  20. package/types/src/exposure.d.ts +47 -0
  21. package/types/src/index.d.ts +31 -0
  22. package/types/src/installation/admin-options.d.ts +24 -0
  23. package/types/src/installation/admin.d.ts +35 -0
  24. package/types/src/installation/checker-release.d.ts +12 -0
  25. package/types/src/installation/deploy-options.d.ts +37 -0
  26. package/types/src/installation/deploy.d.ts +96 -0
  27. package/types/src/installation/generated/platform-console-schema.d.ts +2 -0
  28. package/types/src/installation/generated/platform-proxy-manifest.d.ts +2 -0
  29. package/types/src/installation/hosts.d.ts +38 -0
  30. package/types/src/installation/index.d.ts +9 -0
  31. package/types/src/installation/init-options.d.ts +38 -0
  32. package/types/src/installation/init.d.ts +60 -0
  33. package/types/src/installation/install-collaborators.d.ts +24 -0
  34. package/types/src/installation/install-environment.d.ts +70 -0
  35. package/types/src/installation/install-options.d.ts +49 -0
  36. package/types/src/installation/install-project.d.ts +13 -0
  37. package/types/src/installation/install-provisioning.d.ts +58 -0
  38. package/types/src/installation/install-secrets.d.ts +30 -0
  39. package/types/src/installation/install-token.d.ts +10 -0
  40. package/types/src/installation/install.d.ts +23 -0
  41. package/types/src/installation/installation-source.d.ts +8 -0
  42. package/types/src/installation/log.d.ts +44 -0
  43. package/types/src/installation/machine-key.d.ts +19 -0
  44. package/types/src/installation/mcp.d.ts +18 -0
  45. package/types/src/installation/placement-options.d.ts +11 -0
  46. package/types/src/installation/platform-archive.d.ts +7 -0
  47. package/types/src/installation/platform-source.d.ts +8 -0
  48. package/types/src/installation/platform-upload.d.ts +3 -0
  49. package/types/src/installation/proxy-manifest.d.ts +105 -0
  50. package/types/src/installation/secrets.d.ts +17 -0
  51. package/types/src/installation/sidecar.d.ts +51 -0
  52. package/types/src/installation/source-options.d.ts +1 -0
  53. package/types/src/installation/topology/artifacts.d.ts +8 -0
  54. package/types/src/installation/topology/index.d.ts +5 -0
  55. package/types/src/installation/topology/installation-schemas.d.ts +2242 -0
  56. package/types/src/installation/topology/invariants.d.ts +23 -0
  57. package/types/src/installation/topology/setups.d.ts +58 -0
  58. package/types/src/installation/topology/topology.d.ts +148 -0
  59. package/types/src/installation/topology/validate.d.ts +11 -0
  60. package/types/src/installation/upgrade-options.d.ts +26 -0
  61. package/types/src/installation/upgrade-output.d.ts +6 -0
  62. package/types/src/installation/upgrade.d.ts +88 -0
  63. package/types/src/managed-env.d.ts +57 -0
  64. package/types/src/manifest.d.ts +206 -0
  65. package/types/src/namespace/claims.d.ts +3 -0
  66. package/types/src/namespace/codec.d.ts +334 -0
  67. package/types/src/namespace/constants.d.ts +25 -0
  68. package/types/src/namespace/errors.d.ts +15 -0
  69. package/types/src/namespace/manifest.d.ts +4 -0
  70. package/types/src/namespace/operator.d.ts +12 -0
  71. package/types/src/namespace/provisioning.d.ts +4 -0
  72. package/types/src/namespace/proxy-attempt.d.ts +36 -0
  73. package/types/src/namespace/proxy-reads.d.ts +33 -0
  74. package/types/src/namespace/proxy-secrets.d.ts +8 -0
  75. package/types/src/namespace/proxy-source.d.ts +74 -0
  76. package/types/src/namespace/topology.d.ts +9 -0
  77. package/types/src/namespace/types.d.ts +99 -0
  78. package/types/src/namespace/update.d.ts +6 -0
  79. package/types/src/namespace/validation.d.ts +12 -0
  80. package/types/src/namespace.d.ts +9 -0
  81. package/types/src/plan.d.ts +12 -0
  82. package/types/src/provider.d.ts +65 -0
  83. package/types/src/proxy-manifest-carrier.d.ts +16 -0
  84. package/types/src/schema.generated.d.ts +376 -0
  85. package/types/src/service-names.d.ts +4 -0
  86. package/types/src/service-references.d.ts +13 -0
  87. package/types/src/source/constants.d.ts +6 -0
  88. package/types/src/source/port.d.ts +60 -0
  89. package/types/src/source/types.d.ts +4 -0
  90. package/types/src/source/validation.d.ts +19 -0
  91. package/types/src/source.d.ts +2 -0
  92. package/types/src/types.d.ts +121 -0
  93. package/types/src/version-attempt.d.ts +8 -0
@@ -0,0 +1,19 @@
1
+ export interface ZeropsCliArgs {
2
+ command: string | undefined;
3
+ subcommand: string | undefined;
4
+ env: string | undefined;
5
+ config: string;
6
+ output: string;
7
+ namespaceId: string | undefined;
8
+ preset: string | undefined;
9
+ exclusiveAppId: string | undefined;
10
+ projectId: string | undefined;
11
+ projectName: string | undefined;
12
+ corePackage: string | undefined;
13
+ publicAccess: string | undefined;
14
+ postgresType: string | undefined;
15
+ postgresProfile: string | undefined;
16
+ controlUrl: string | undefined;
17
+ help: boolean;
18
+ }
19
+ export declare const parseZeropsCliArgs: (argv: readonly string[]) => ZeropsCliArgs;
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bun
2
+ export declare const readZeropsSourceDescriptor: (root?: string) => Promise<import("./manifest").ZeropsArtifactSourceDescriptor>;
3
+ export interface ZeropsManifestBuildOptions {
4
+ /** App config path, resolved against the working directory like `--config`. */
5
+ readonly config: string;
6
+ readonly env: string;
7
+ }
8
+ /** The exact text `build` writes to `fabrika.manifest.json`, produced in memory and written nowhere. */
9
+ export declare const buildZeropsManifestText: (options: ZeropsManifestBuildOptions) => Promise<string>;
10
+ export declare const runZeropsCli: (argv: readonly string[]) => Promise<void>;
@@ -0,0 +1,18 @@
1
+ import type { SchemaReconciler } from '@fabrika/provider-contract';
2
+ import { type ZeropsApi } from './api';
3
+ import { type ExposureAlerter } from './exposure';
4
+ import type { ZeropsSourcePort } from './source/port';
5
+ import type { ZeropsRuntimeTarget } from './types';
6
+ export type Sleeper = (ms: number, signal: AbortSignal) => Promise<void>;
7
+ export declare const defaultSleep: Sleeper;
8
+ export interface ZeropsCollaborators {
9
+ api: ZeropsApi;
10
+ /** Injected by the Zerops control composition; dry runs do not require it. */
11
+ source?: ZeropsSourcePort;
12
+ reconcileSchema: SchemaReconciler;
13
+ /** Raises the Operations alert for a refused activation; best-effort. */
14
+ alertExposure: ExposureAlerter;
15
+ sleep: Sleeper;
16
+ }
17
+ export type ZeropsCollaboratorFactory = (target: ZeropsRuntimeTarget) => ZeropsCollaborators;
18
+ export declare const defaultZeropsCollaborators: ZeropsCollaboratorFactory;
@@ -0,0 +1,91 @@
1
+ import type { JsonValue } from '@fabrika/provider-contract';
2
+ import type { ZeropsImportProject, ZeropsImportService } from './schema.generated';
3
+ import type { ZeropsResourceContext, ZeropsSourceTarget } from './types';
4
+ /** The ONLY value fabrika ever writes for `envIsolation`, at either level. Not a default — an assertion. */
5
+ export declare const ENV_ISOLATION: 'service';
6
+ /**
7
+ * The ONLY value fabrika ever writes for `override`, on EVERY service class including managed ones.
8
+ * Live-verified: without it a re-apply is `400 serviceStackNameUnavailable` — see `compileService`.
9
+ */
10
+ export declare const OVERRIDE: true;
11
+ /** A compiled import document: exactly the two top-level keys the platform's schema defines. */
12
+ export interface ZeropsImportDocument {
13
+ /** Present only when fabrika is creating/reconciling the project itself. */
14
+ project?: ZeropsImportProject;
15
+ services: ZeropsImportService[];
16
+ }
17
+ /**
18
+ * The same document once it has been through JSON — a manifest's stored `importDocument`, or one whose
19
+ * values were substituted. Structurally identical, leaves typed as JSON, so `assertZeropsInvariants`
20
+ * checks it too rather than trusting whoever produced it.
21
+ */
22
+ export interface ZeropsJsonImportDocument {
23
+ readonly project?: {
24
+ readonly [key: string]: JsonValue;
25
+ };
26
+ readonly services: ReadonlyArray<{
27
+ readonly [key: string]: JsonValue;
28
+ }>;
29
+ }
30
+ /** What the compiler needs beyond the app's declaration. */
31
+ export interface CompileInput {
32
+ target: ZeropsSourceTarget;
33
+ ctx: ZeropsResourceContext;
34
+ /**
35
+ * Provision every service WITHOUT code — the answer to ADR-0004's "no secret can be set before the
36
+ * service exists" gap. Import the services, write their secrets through the env API, deploy later.
37
+ * Applied on top of whatever a service declared, because it is a property of THIS import, not of the app.
38
+ */
39
+ startWithoutCode?: boolean;
40
+ }
41
+ /**
42
+ * The last gate before serialization: re-check ADR-0004's invariants on the FINISHED document. The types
43
+ * make a violation unauthorable and the construction makes it unemittable; this catches everything else —
44
+ * a config deserialized from JSON, a document assembled by hand, a future edit to this file.
45
+ *
46
+ * Deliberately checks the emitted document rather than the input: it is the document that reaches Zerops.
47
+ */
48
+ export declare const assertZeropsInvariants: (document: ZeropsImportDocument | ZeropsJsonImportDocument) => void;
49
+ /** Compile an app's Zerops declaration into the import document, invariants already checked. */
50
+ export declare const compileImport: (input: CompileInput) => ZeropsImportDocument;
51
+ /**
52
+ * Render an arbitrary Zerops document (a `zerops.yaml`, a fragment) with the SAME emitter the import
53
+ * document uses. Exported so nothing outside this file has to grow a second YAML writer: two emitters
54
+ * disagreeing about quoting or block scalars is a class of bug worth spending one export to avoid.
55
+ *
56
+ * Deliberately does NOT assert the import invariants — it does not know it is looking at an import
57
+ * document. `renderImportYaml` is the entry point that does, and it is the one the driver calls.
58
+ */
59
+ export declare const renderYaml: (value: unknown) => string;
60
+ /**
61
+ * Render a compiled document as the `zerops-import.yaml` text the API takes. Re-asserts the invariants:
62
+ * this is the last place the document is still inspectable, and the only place it becomes a string.
63
+ */
64
+ export declare const renderImportYaml: (document: ZeropsImportDocument) => string;
65
+ /** Compile + render in one step — what the driver's `apply-import` step actually calls. */
66
+ export declare const compileImportYaml: (input: CompileInput) => {
67
+ document: ZeropsImportDocument;
68
+ yaml: string;
69
+ };
70
+ /**
71
+ * Compile the PROVISIONING import: the same document with every service forced `startWithoutCode: true`.
72
+ *
73
+ * This is ADR-0004's recorded gap closed. The ADR accepted a cost — "no secret can be set before the
74
+ * Zerops service exists, so registration must provision" — and `startWithoutCode` makes that provisioning
75
+ * cheap and code-free. The order becomes: register the app → import its services with no code → write
76
+ * their secrets through the SERVICE-level env API → deploy later. No local secret buffer, no secret in
77
+ * this document, and no secret held anywhere fabrika could leak it.
78
+ *
79
+ * Called by the control plane at EDIT time, not by the driver: on Zerops, pushing secrets is not a deploy
80
+ * step at all.
81
+ *
82
+ * **This document is the one that is NOT safe to re-apply, and `override` does not make it safe.**
83
+ * Verified live: re-applying it at a service that already carries code starts a `stack.deploy` and
84
+ * activates a new, EMPTY app version — the running code becomes a `BACKUP`. The steady-state document
85
+ * (no `startWithoutCode`) is a complete no-op on the same services. So this form belongs to first
86
+ * bring-up only; anything that reconciles an existing project applies `compileImportYaml`.
87
+ */
88
+ export declare const compileProvisioningYaml: (input: Omit<CompileInput, "startWithoutCode">) => {
89
+ document: ZeropsImportDocument;
90
+ yaml: string;
91
+ };
@@ -0,0 +1,41 @@
1
+ import type { ControlProvider, ProviderCodec, SchemaReconciler } from '@fabrika/provider-contract';
2
+ import { type ZeropsApi } from './api';
3
+ import { type Sleeper } from './collaborators';
4
+ import { type ExposureAlerter } from './exposure';
5
+ import { type ZeropsNamespaceProxySource } from './namespace';
6
+ import { type OlderProxyReaders } from './namespace/proxy-reads';
7
+ import type { ZeropsSourcePort } from './source/port';
8
+ import type { ZeropsRunState } from './types';
9
+ /** Provider coordinates that are safe to persist. Credentials are composed only for a live run. */
10
+ export interface ZeropsStoredTarget {
11
+ serviceId: string;
12
+ /**
13
+ * The object-storage service ids the first registration's collision-refusing import created: the creation evidence
14
+ * the first deploy writes into the provenance marker (ADR-0043). Absent when that import created no bucket.
15
+ */
16
+ createdBuckets?: string[];
17
+ }
18
+ export declare const zeropsStoredTargetCodec: ProviderCodec<ZeropsStoredTarget>;
19
+ export interface ZeropsControlProviderOptions {
20
+ readonly accessToken: string;
21
+ readonly apiBaseUrl?: string;
22
+ readonly propustkaUrl?: string;
23
+ readonly adminKey?: string;
24
+ readonly api?: ZeropsApi;
25
+ readonly source: ZeropsSourcePort;
26
+ readonly reconcileSchema?: SchemaReconciler;
27
+ readonly alertExposure?: ExposureAlerter;
28
+ readonly sleep?: Sleeper;
29
+ readonly namespaces?: {
30
+ readonly clientId: string;
31
+ readonly proxySource: ZeropsNamespaceProxySource;
32
+ readonly iamUrl: string;
33
+ readonly iamKey: string;
34
+ /** The manifest parsers of the older releases' proxies, which a namespace pinned to an older source may run. */
35
+ readonly olderProxies: OlderProxyReaders;
36
+ };
37
+ }
38
+ /** The run checkpoint (ADR-0044), or null for anything else — an older shape included. */
39
+ export declare const parseZeropsCheckpoint: (value: unknown) => ZeropsRunState | null;
40
+ /** Build the complete Zerops lifecycle bundle without importing control-plane persistence. */
41
+ export declare const createZeropsControlProvider: (options: ZeropsControlProviderOptions) => ControlProvider;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The RAM steps of a Zerops PostgreSQL service in GB; its `max_connections` follows the step its RAM is in, and a
3
+ * service between two steps has the lower one's (`docs/reference/zerops-platform.md`, "Connection limits"). Above 8 GB
4
+ * the steps are multiples of 8 GB; 16 GB is the first with the highest limit.
5
+ */
6
+ export declare const ZEROPS_POSTGRES_RAM_STEPS_GB: readonly number[];
7
+ /** The lowest step, and the smallest RAM a PostgreSQL service is given (`oltp-hobby`'s floor). */
8
+ export declare const ZEROPS_POSTGRES_MIN_RAM_GB = 0.25;
9
+ /** Of a service's `max_connections`, what no application role can take: 3 kept for superusers, up to 4 Zerops' own. */
10
+ export declare const ZEROPS_POSTGRES_UNAVAILABLE_CONNECTIONS = 7;
11
+ /**
12
+ * The most connections one container's init commands hold at once: `fabrika db test-isolation` peaks at 4 since the
13
+ * test kit opens a file's connections together, and at 5 with a `@fabrika/db` before that (measured locally,
14
+ * 2026-10-16, with the Notes and CRM examples). Migrating and reading the schema take fewer, one after the other.
15
+ */
16
+ export declare const ZEROPS_START_CONNECTIONS = 5;
17
+ /** The fewest connections a process may have: a job's fenced write and its cancellation each need one at once. */
18
+ export declare const MIN_PROCESS_CONNECTIONS = 2;
19
+ /** The most a process gets, however large the database: the pool every process had before the platform sized it. */
20
+ export declare const MAX_PROCESS_CONNECTIONS = 10;
21
+ /** Zerops' own maximum, which a runtime whose horizontal autoscaling reads nothing may scale to. */
22
+ export declare const ZEROPS_MAX_CONTAINERS = 10;
23
+ /** What opens connections to the application's database at once. */
24
+ export interface ZeropsDatabaseDemand {
25
+ /** The deploy service's maximum container count. */
26
+ readonly maxContainers: number;
27
+ /** The crontab lines that run `fabrika job run`, each its own process on one container. */
28
+ readonly jobs: number;
29
+ }
30
+ /** `max_connections` of a Zerops PostgreSQL service with `ramGB` of RAM and this autoscaling profile. */
31
+ export declare function zeropsPostgresMaxConnections(ramGB: number, profile: string | undefined): number;
32
+ /**
33
+ * The connections each process may open so that all of them, with one container's init commands, stay within what the
34
+ * application's roles can take; `null` when that is below `MIN_PROCESS_CONNECTIONS`.
35
+ */
36
+ export declare function zeropsProcessConnections(maxConnections: number, demand: ZeropsDatabaseDemand): number | null;
37
+ /** The smallest RAM step at which each process gets at least `MIN_PROCESS_CONNECTIONS`, or null when none does. */
38
+ export declare function zeropsDatabaseMinRam(demand: ZeropsDatabaseDemand, profile: string | undefined): number | null;
@@ -0,0 +1,28 @@
1
+ import type { JsonValue } from '@fabrika/provider-contract';
2
+ export interface ZeropsDescriptor {
3
+ document: {
4
+ readonly [key: string]: JsonValue;
5
+ };
6
+ setups: readonly string[];
7
+ }
8
+ export interface PreparedZeropsDescriptor {
9
+ contents: string;
10
+ setup: string;
11
+ }
12
+ export declare const parseZeropsDescriptor: (contents: string) => ZeropsDescriptor;
13
+ export declare const selectZeropsDescriptorSetup: (parsed: ZeropsDescriptor, setup?: string) => string;
14
+ /**
15
+ * The setup entries a deploy of `selected` applies: the selected one and, transitively, every setup it
16
+ * `extends`. Only these reach the running service; the other setups in the file never do.
17
+ */
18
+ export declare const appliedZeropsSetups: (parsed: ZeropsDescriptor, selected: string) => JsonValue[];
19
+ /**
20
+ * Refuse a selected setup that `extends` another without its own `run`: Zerops merges `extends` per
21
+ * whole section, and the deploy writes `FABRIKA_RELEASE` into `run`, which would replace the inherited one.
22
+ */
23
+ export declare const assertOwnRunWhenExtending: (parsed: ZeropsDescriptor, selected: string) => void;
24
+ /** The document Zerops executes: the selected setup and what it extends, which is exactly what the ownership check read. */
25
+ export declare const executionZeropsDocument: (parsed: ZeropsDescriptor, selected: string) => {
26
+ readonly [key: string]: JsonValue;
27
+ };
28
+ export declare const prepareZeropsDescriptor: (contents: string, setup?: string) => PreparedZeropsDescriptor;
@@ -0,0 +1,137 @@
1
+ import { type ContractArtifact, type DevLauncherConfig } from '@fabrika/auth-core';
2
+ import type { OperationsAssetRoot, OperationsSourceMapBuildUpload } from '@fabrika/operations-contract/releases';
3
+ import { type JsonValue } from '@fabrika/provider-contract';
4
+ import { type PreparedZeropsDescriptor } from './descriptor';
5
+ /** The port the generated entrypoint listens on (`PORT`), and the one the proxy dials. */
6
+ export declare const ZEROPS_APPLICATION_PORT = 3000;
7
+ /** The runtime every contract application runs on: the generated entrypoint is a Bun program. */
8
+ export declare const ZEROPS_APPLICATION_RUNTIME = "alpine/bun@1.3";
9
+ /**
10
+ * This package's own version. Control runs the git checkout of its release tag, so this reads the source version,
11
+ * which `release:validate` holds equal to the tag; the public packages are released together, so it is the checker
12
+ * release of the installation. A build checks with the application's own release instead (`checkRelease`).
13
+ */
14
+ export declare const FABRIKA_CHECK_VERSION: string;
15
+ /** The compiler the platform type-checks with. It is fetched by version, never taken from the application's lockfile. */
16
+ export declare const PLATFORM_TYPESCRIPT_VERSION = "5.9.3";
17
+ /** System packages an application may add to its runtime image, installed by the generated `run.prepareCommands`. */
18
+ export declare const ZEROPS_RUNTIME_PACKAGES: readonly ["ffmpeg", "ghostscript", "imagemagick", "poppler-utils", "vips"];
19
+ export type ZeropsRuntimePackage = (typeof ZEROPS_RUNTIME_PACKAGES)[number];
20
+ export interface ZeropsContractJob {
21
+ readonly name: string;
22
+ readonly schedule: string;
23
+ }
24
+ /** The framework's file scan job (`@fabrika/app`'s `FILE_SCAN_JOB`), run every minute when a collection scans. */
25
+ export declare const ZEROPS_FILE_SCAN_JOB = "fabrika-file-scan";
26
+ /** The framework's file sweep job (`@fabrika/app`'s `FILE_SWEEP_JOB` and its schedule), run when the contract has files. */
27
+ export declare const ZEROPS_FILE_SWEEP_JOB = "fabrika-file-sweep";
28
+ /**
29
+ * The RAM in GB a container of a scanning application starts with: one `clamscan` over a batch peaks at about 1 GB
30
+ * resident while it loads its signatures (measured with ClamAV 1.4), beside the application's own process.
31
+ */
32
+ export declare const ZEROPS_SCAN_MIN_RAM_GB = 2;
33
+ /**
34
+ * The RAM in GB a container of an application with a database starts with. Its init commands run `fabrika db
35
+ * test-isolation`, whose CLI and `bun test` child together peak at 161 MiB of anonymous memory for the Notes example
36
+ * and 225 MiB for the CRM example (measured locally, 2026-10-15), beside Bun's own mapped binary. Zerops' 0.125 GB
37
+ * floor kills that within a second, faster than vertical autoscaling reacts.
38
+ */
39
+ export declare const ZEROPS_START_MIN_RAM_GB = 0.5;
40
+ /** The minimum RAM in GB the deploy service's containers need to start, or null when Zerops' floor suffices. */
41
+ export declare function zeropsStartMinRam(execution: ZeropsLockedExecution): number | null;
42
+ /** What the generated run section needs from a contract; derived from the artifact by `zeropsContractRun`. */
43
+ export interface ZeropsContractRun {
44
+ /** The contract digest the application compares at startup (`FABRIKA_CONTRACT_DIGEST`). */
45
+ readonly digest: string;
46
+ /** The path of the contract's health endpoint, which the readiness and health checks request. */
47
+ readonly readinessPath: string;
48
+ readonly jobs: readonly ZeropsContractJob[];
49
+ /** Present when the contract declares a file collection: the crontab runs the sweep of removed files. */
50
+ readonly files?: true;
51
+ /** Present when a file collection scans its uploads: the build installs ClamAV and the crontab runs the scan. */
52
+ readonly scan?: true;
53
+ }
54
+ /** Everything one locked execution descriptor is rendered from. */
55
+ export interface ZeropsLockedExecution {
56
+ readonly appId: string;
57
+ readonly contract: ZeropsContractRun;
58
+ /**
59
+ * The release of the reader that read the application (`ProviderApprovedAccess.checker`), the newest patch of the
60
+ * framework minor it pins: the build runs `fabrika-check` and `fabrika-source-maps` of `@fabrika/check` at it.
61
+ */
62
+ readonly checkRelease: string;
63
+ /** A `${host_…}` reference to the application's PostgreSQL service, or null when it has none. */
64
+ readonly databaseUrl: string | null;
65
+ /**
66
+ * The most connections each process of the application opens (`FABRIKA_APP_DATABASE_CONNECTIONS`), as the deploy's
67
+ * `size-database` step sized it from the database's limit; null until then, and without a database.
68
+ */
69
+ readonly databaseConnections: number | null;
70
+ /** The hostname of the application's one object-storage service, or null when it has none. */
71
+ readonly storageHostname: string | null;
72
+ readonly runtimePackages: readonly ZeropsRuntimePackage[];
73
+ /** Where the build uploads its source maps, without the bearer; null when Control minted no upload for the run. */
74
+ readonly sourceMaps: OperationsSourceMapBuildUpload | null;
75
+ /**
76
+ * Present for an environment of kind `dev` (ADR-0049): `run.start` runs the dev launcher instead of the serving
77
+ * entry. The environment's kind selects it; an application never authors it.
78
+ */
79
+ readonly dev?: ZeropsDevExecution;
80
+ }
81
+ export interface ZeropsDevExecution {
82
+ /** The commit the bootstrap run builds: what a new container holds before the launcher's first sync. */
83
+ readonly head: string;
84
+ }
85
+ /** The application ids the generated scripts may name: the contract's own id rule, so a script needs no quoting. */
86
+ export declare const LOCKED_APP_ID_PATTERN: RegExp;
87
+ export declare const CONTRACT_DIGEST_PATTERN: RegExp;
88
+ /** A literal path of unreserved characters: it is written into the generated probes unquoted by any shell. */
89
+ export declare const READINESS_PATH_PATTERN: RegExp;
90
+ /**
91
+ * The run facts of a contract, with the digest the application's own release computes for it. A contract without a
92
+ * health endpoint has nothing a readiness check can request.
93
+ */
94
+ export declare function zeropsContractRun(artifact: ContractArtifact, digest: string): ZeropsContractRun;
95
+ /**
96
+ * A scanning application's deploy service must start its containers with `ZEROPS_SCAN_MIN_RAM_GB`: below it the
97
+ * scanner is killed for memory, and every upload stays quarantined. Zerops ignores a changed `verticalAutoscaling` of
98
+ * an existing service on a re-import, so the deploy's `raise-start-memory` step raises an existing service.
99
+ */
100
+ export declare function assertScanMemory(services: readonly {
101
+ readonly [key: string]: JsonValue;
102
+ }[], deployService: string, run: ZeropsContractRun): void;
103
+ /** The directories a contract serves its pages from: each SPA mount's and each share link's SPA, by URL prefix. */
104
+ export declare function zeropsAssetRoots(artifact: ContractArtifact): OperationsAssetRoot[];
105
+ interface AuthoredBuild {
106
+ readonly base: string | string[] | null;
107
+ readonly os: string | null;
108
+ readonly commands: string[];
109
+ }
110
+ /** Refuse every key of a contract application's setup the platform owns, and return what it keeps. */
111
+ export declare function lockedAuthoredBuild(entry: {
112
+ readonly [key: string]: JsonValue;
113
+ }, setup: string): AuthoredBuild;
114
+ /** What the dev launcher reads (`DEV_LAUNCHER_CONFIG_FILE`): the platform's, written after the checks. */
115
+ export declare function devLauncherConfig(execution: ZeropsLockedExecution, authoredSpa: readonly string[]): DevLauncherConfig;
116
+ /**
117
+ * The generated build commands, in order; the authored SPA commands run before all of them. The application's tests
118
+ * run first: they are authored code, so everything after them is reinstalled, regenerated or checked again. They run
119
+ * `--isolate`, as the application skill runs them: a test file's DOM globals otherwise leak into the next file. `tsc`
120
+ * runs before the checker, as in the skill's loop: the usual quick fix of a type error is a cast or an `any`, which only
121
+ * the checker refuses, so the checker is the last word on the code.
122
+ */
123
+ export declare function generatedBuildCommands(execution: ZeropsLockedExecution, authoredSpa?: readonly string[]): readonly string[];
124
+ /** How many job processes the crontab may run at once, each opening the application's database. */
125
+ export declare const zeropsJobProcesses: (contract: ZeropsContractRun) => number;
126
+ /** The commands every container runs before `run.start`, in order; any failure stops the activation. */
127
+ export declare function generatedInitCommands(execution: ZeropsLockedExecution): string[];
128
+ /** The generated selected setup: the authored build kept, everything else the platform's. */
129
+ export declare function renderLockedSetup(setup: string, authored: AuthoredBuild, release: string | null, execution: ZeropsLockedExecution): {
130
+ readonly [key: string]: JsonValue;
131
+ };
132
+ /**
133
+ * The execution descriptor of a contract application: only the selected setup, generated. The source descriptor's
134
+ * bytes and digest stay the artifact's identity; this document is what the build request carries.
135
+ */
136
+ export declare function renderLockedExecutionDescriptor(contents: string, setup: string | undefined, release: string | null, execution: ZeropsLockedExecution): PreparedZeropsDescriptor;
137
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { ZeropsImportResult } from './api';
2
+ /**
3
+ * The provenance marker: a service variable on the deploy service listing the object-storage service ids the platform
4
+ * created, each from an import that carried `objectStoragePolicy: private`. A bucket adopted by hostname has none.
5
+ * The import's answer is the only evidence of creation, so `apply-import` records it here before any other step runs.
6
+ */
7
+ export declare const STORAGE_PROVENANCE_KEY = "FABRIKA_STORAGE_PROVENANCE";
8
+ export declare const isObjectStorageType: (type: string) => boolean;
9
+ export declare const parseStorageProvenance: (value: string | undefined) => ReadonlySet<string>;
10
+ export declare const formatStorageProvenance: (ids: Iterable<string>) => string;
11
+ /** Hostname → service id of every service this import result reports creating. */
12
+ export declare const createdServices: (result: ZeropsImportResult) => ReadonlyMap<string, string>;
13
+ /** How the deploy service holds the marker: a release up to v0.4.2 wrote it sensitive, which reads back without its value. */
14
+ export type StorageProvenanceMarker = 'absent' | 'readable' | 'sensitive';
15
+ /** The refusal of a bucket no evidence names, with the two remedies an operator has without sudo. */
16
+ export declare const unprovenBucketReason: (input: {
17
+ bucketId: string;
18
+ deployService: string;
19
+ marker: StorageProvenanceMarker;
20
+ }) => string;
21
+ export interface ExposureFinding {
22
+ readonly hostname: string;
23
+ readonly reason: string;
24
+ }
25
+ export declare const formatExposureFindings: (findings: readonly ExposureFinding[]) => string;
26
+ export interface ExposureAlert {
27
+ readonly appId: string;
28
+ readonly env: string;
29
+ readonly release: string | null;
30
+ readonly findings: readonly ExposureFinding[];
31
+ }
32
+ /**
33
+ * The Operations ingest request that raises the alert: an error event in the application's own Operations project,
34
+ * which its `new_issue` alert rules deliver. Null for a DSN of any other form. The public key is not a secret, but it
35
+ * travels only in this request.
36
+ */
37
+ export declare function exposureAlertRequest(dsn: string, alert: ExposureAlert, eventId: string): {
38
+ url: string;
39
+ body: string;
40
+ } | null;
41
+ export type ExposureAlerter = (input: {
42
+ readonly dsn: string;
43
+ readonly alert: ExposureAlert;
44
+ readonly signal: AbortSignal;
45
+ }) => Promise<void>;
46
+ /** Send the alert. The caller treats a failure as non-fatal: the refusal stands either way. */
47
+ export declare const sendExposureAlert: ExposureAlerter;
@@ -0,0 +1,31 @@
1
+ export { createZeropsApi, enableSubdomainAccessWhenHttp, readableContent, waitForProcess, ZEROPS_ACTIVE, ZEROPS_API_BASE, ZEROPS_PROCESS_FINISHED, ZEROPS_PROCESS_TERMINAL, ZEROPS_SERVICE_NOT_HTTP, ZEROPS_TERMINAL, ZeropsApiError, } from './api';
2
+ export type { FetchLike, ZeropsApi, ZeropsApiOptions, ZeropsAppVersion, ZeropsAppVersionStatus, ZeropsAppVersionUpload, ZeropsImportedService, ZeropsImportResult, ZeropsIntegrationToken, ZeropsLogAccess, ZeropsLogLine, ZeropsProcess, ZeropsProject, ZeropsProjectMode, ZeropsProjectStatus, ZeropsRoleCode, ZeropsService, ZeropsServiceAutoscaling, ZeropsServiceEnv, ZeropsServiceEnvWrite, ZeropsServiceStatus, ZeropsTokenProjectGrant, ZeropsUserInfo, } from './api';
3
+ export { defineApp, isZeropsAppConfig, useSharedPostgres, zeropsSharedServiceHostname, zeropsSharedServicePrefix } from './authoring';
4
+ export type { ZeropsAuthoredAppConfig } from './authoring';
5
+ export { parseZeropsCliArgs } from './cli-args';
6
+ export type { ZeropsCliArgs } from './cli-args';
7
+ export { defaultSleep, defaultZeropsCollaborators } from './collaborators';
8
+ export type { Sleeper, ZeropsCollaboratorFactory, ZeropsCollaborators } from './collaborators';
9
+ export { assertZeropsInvariants, compileImport, compileImportYaml, compileProvisioningYaml, ENV_ISOLATION, OVERRIDE, renderImportYaml, renderYaml, } from './compile';
10
+ export type { CompileInput, ZeropsImportDocument, ZeropsJsonImportDocument } from './compile';
11
+ export { createZeropsControlProvider, parseZeropsCheckpoint, zeropsStoredTargetCodec } from './control';
12
+ export type { ZeropsControlProviderOptions, ZeropsStoredTarget } from './control';
13
+ export { type PreparedZeropsDescriptor, prepareZeropsDescriptor } from './descriptor';
14
+ export { assertFabrikaManifestCoordinates, compileFabrikaManifest, createZeropsArtifactSourceDescriptor, FABRIKA_MANIFEST_VERSION, manifestServiceHostnames, parseFabrikaManifest, renderFabrikaImportYaml, verifyZeropsArtifactSourceDescriptor, ZEROPS_SERVICE_HOSTNAME_PATTERN, ZEROPS_SOURCE_DESCRIPTOR_MAX_BYTES, zeropsArtifactCodec, } from './manifest';
15
+ export type { FabrikaImportDocument, FabrikaManifest, ManifestExpectation, ZeropsArtifactSourceDescriptor } from './manifest';
16
+ export { compileZeropsNamespaceTopology, createZeropsNamespaceCapabilities, createZeropsNamespaceOperator, decodeZeropsNamespaceProxySource, republishProxy, verifyZeropsNamespaceProxySource, ZEROPS_NAMESPACE_IAM_ISSUER_VARIABLE, ZEROPS_NAMESPACE_IAM_KEY_VARIABLE, ZEROPS_NAMESPACE_POSTGRES_HOSTNAME, ZEROPS_NAMESPACE_PROXY_HOSTNAME, ZEROPS_SHARED_POSTGRES_CONNECTION_STRING, zeropsNamespacePreset, zeropsNamespaceTargetCodec, } from './namespace';
17
+ export type { ZeropsNamespaceOperatorOptions, ZeropsNamespaceOptions, ZeropsNamespacePlanOptions, ZeropsNamespacePostgres, ZeropsNamespacePresetInput, ZeropsNamespaceProxyBuild, ZeropsNamespaceProxyDeployment, ZeropsNamespaceProxySource, ZeropsNamespacePublicAccess, ZeropsNamespaceTarget, ZeropsNamespaceTopology, ZeropsProxyApi, ZeropsProxyRepublishInput, } from './namespace';
18
+ export { postgresSchema as zeropsNamespacePostgresSchema } from './namespace/codec';
19
+ export { entriesNeedingCurrentProxy } from './namespace/proxy-reads';
20
+ export type { OlderProxyReader, OlderProxyReaders } from './namespace/proxy-reads';
21
+ export { buildZeropsPlan, resolveDeployHostname } from './plan';
22
+ export type { ZeropsStep, ZeropsStepKind } from './plan';
23
+ export { CANCELLED, createZeropsDeployer, interpolateManifest } from './provider';
24
+ export type { ZeropsDeployResult, ZeropsDeployRun } from './provider';
25
+ export { ZEROPS_PROXY_MANIFEST_PATH, type ZeropsProxyManifestCarrier, zeropsProxyManifestCarrier } from './proxy-manifest-carrier';
26
+ export type * from './schema.generated';
27
+ export { isZeropsUploadDestination, normalizeZeropsSourceRepository } from './source';
28
+ export type { ZeropsSourceRepository } from './source';
29
+ export { ZeropsSourceRateLimitedError } from './source/port';
30
+ export type { ZeropsSourceArchive, ZeropsSourcePort, ZeropsSourcePrivateBinding, ZeropsSourceResolution, ZeropsSourceResolveInput, ZeropsSourceUploadInput, ZeropsSourceUploadResult, } from './source/port';
31
+ export type { ZeropsAppConfig, ZeropsCompilerOwnedProjectField, ZeropsCompilerOwnedServiceField, ZeropsDuration, ZeropsHealthCheckSpec, ZeropsNamespaceResourceRequirement, ZeropsProjectSpec, ZeropsProxySpec, ZeropsReadinessCheckSpec, ZeropsResourceContext, ZeropsRunState, ZeropsRuntimeSource, ZeropsRuntimeTarget, ZeropsServiceSpec, ZeropsSharedPostgresBinding, ZeropsSourceTarget, ZeropsYamlDeploySpec, ZeropsYamlRunSpec, ZeropsYamlSetupSpec, ZeropsYamlSpec, } from './types';
@@ -0,0 +1,24 @@
1
+ /** Every input `runPlatformAdmin` takes from the operator. */
2
+ export interface PlatformAdminInput {
3
+ /** The mailbox that identifies the first administrator. */
4
+ readonly email: string;
5
+ /** IAM's public hostname — the address the proxy fronts, as `platform deploy` names it. */
6
+ readonly iamHost: string;
7
+ /** The scheme a browser speaks to this installation. With `iamHost` it composes IAM's public origin. */
8
+ readonly scheme: 'http' | 'https';
9
+ /** The `px_` provisioning key `platform install` wrote to its secrets file. Environment only. */
10
+ readonly provisioningKey: string;
11
+ /** Replace an outstanding enrollment instead of reporting it. */
12
+ readonly reissue: boolean;
13
+ }
14
+ /**
15
+ * The one way a second enrollment URL is ever issued.
16
+ *
17
+ * Printing the URL once is the property a re-run has to keep, so an outstanding enrollment is
18
+ * REPORTED rather than replaced. An enrollment that expired unopened would otherwise be a dead end —
19
+ * the only other way to issue one is a console nobody can sign in to yet — so the way out is a flag,
20
+ * which makes replacing the outstanding one an explicit choice.
21
+ */
22
+ export declare const REISSUE_FLAG = "--reissue";
23
+ /** Parse the command's arguments and environment into the one input `runPlatformAdmin` takes. */
24
+ export declare const parsePlatformAdminArgs: (argv: readonly string[], env: Record<string, string | undefined>) => PlatformAdminInput;
@@ -0,0 +1,35 @@
1
+ import { type FirstAdministratorApi } from '@fabrika/installation-init';
2
+ import type { PlatformAdminInput } from './admin-options';
3
+ /**
4
+ * Where this command's progress goes.
5
+ *
6
+ * The same rule the rest of this package's logging states: no helper here takes a secret value. The
7
+ * enrollment URL is a credential in transit and never travels through the log — it goes to `print`,
8
+ * which is stdout and nothing else.
9
+ */
10
+ export interface AdminLog {
11
+ step(title: string): void;
12
+ info(message: string): void;
13
+ warn(message: string): void;
14
+ ok(message: string): void;
15
+ }
16
+ /** `AdminLog` plus the boxed hand-off the closing block uses — composed in below, not asked of the caller. */
17
+ export interface AdminReportLog extends AdminLog {
18
+ action(title: string, lines: readonly string[]): void;
19
+ }
20
+ export interface PlatformAdminCollaborators {
21
+ readonly client: FirstAdministratorApi;
22
+ readonly log: AdminReportLog;
23
+ /** stdout, for the command's one piece of DATA: the enrollment URL, on a line of its own. */
24
+ readonly print: (line: string) => void;
25
+ }
26
+ /** The real collaborators: the typed admin client for this installation's public IAM, and the console. */
27
+ export declare const consoleAdminCollaborators: (input: PlatformAdminInput, log: AdminLog) => PlatformAdminCollaborators;
28
+ /**
29
+ * Admit the first administrator, and report exactly what was found rather than what was assumed.
30
+ *
31
+ * Nothing is printed before the whole sequence has succeeded except its progress: a failure — an
32
+ * unreachable IAM, a refused key, a 4xx — throws, and the CLI exits non-zero with that one message.
33
+ * No partial result and, above all, no URL.
34
+ */
35
+ export declare const runPlatformAdmin: (input: PlatformAdminInput, collaborators: PlatformAdminCollaborators) => Promise<void>;
@@ -0,0 +1,12 @@
1
+ /** The package every contract application build fetches by this checkout's version. */
2
+ export declare const FABRIKA_CHECK_PACKAGE = "@fabrika/check";
3
+ /** Whether npm has `@fabrika/check` at `version`. Throws when it cannot tell. */
4
+ export type CheckerPublication = (version: string, signal: AbortSignal) => Promise<boolean>;
5
+ export type RegistryFetch = (url: string, init: RequestInit) => Promise<Response>;
6
+ export declare const npmCheckerPublication: (fetchImpl?: RegistryFetch) => CheckerPublication;
7
+ /**
8
+ * Refuse a checkout whose checker npm does not have. Every contract application build of the installation fetches
9
+ * `@fabrika/check` at this checkout's version, so without it no application could deploy. Between a release's bump
10
+ * commit and its publish, `main` is such a checkout.
11
+ */
12
+ export declare const assertCheckerPublished: (published: CheckerPublication, signal: AbortSignal, version?: string) => Promise<void>;
@@ -0,0 +1,37 @@
1
+ import { type McpClient } from './mcp';
2
+ /** How the project this installation lives in is named. */
3
+ export type ZeropsProjectSelector = {
4
+ readonly kind: 'id';
5
+ readonly projectId: string;
6
+ } | {
7
+ readonly kind: 'name';
8
+ readonly clientId: string;
9
+ readonly name: string;
10
+ };
11
+ /** Every input `deployPlatform` takes from the operator. */
12
+ export interface PlatformDeployInput {
13
+ readonly project: ZeropsProjectSelector;
14
+ /** Zerops personal or integration access token. Environment only. */
15
+ readonly accessToken: string;
16
+ /** Region API base, when the installation is not on the default one. */
17
+ readonly apiBaseUrl?: string;
18
+ /** The name this installation calls itself — written to every platform service as `ENVIRONMENT`. */
19
+ readonly environment: string;
20
+ /** All three or none: none derives them from the proxy's Zerops subdomains. */
21
+ readonly hosts?: {
22
+ readonly iam: string;
23
+ readonly control: string;
24
+ readonly operations: string;
25
+ };
26
+ /** The scheme a browser speaks to this installation. `https` unless a local composition says otherwise. */
27
+ readonly scheme: 'http' | 'https';
28
+ readonly sourceDir: string;
29
+ /** The MCP clients this installation trusts. Absent leaves MCP authoring off (ADR-0049). */
30
+ readonly mcpClients?: readonly McpClient[];
31
+ /** IAM-issued `px_` admin key, used only to reconcile the console's schema. Environment only. */
32
+ readonly iamAdminKey: string;
33
+ /** Read everything, write nothing, trigger nothing. */
34
+ readonly dryRun: boolean;
35
+ }
36
+ /** Parse the command's arguments and environment into the one input `deployPlatform` takes. */
37
+ export declare const parsePlatformDeployArgs: (argv: readonly string[], env: Record<string, string | undefined>) => PlatformDeployInput;