@fabrika/provider-contract 0.9.0-dev.1 → 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 +17 -5
- package/src/app-cli.ts +81 -0
- package/src/conformance.ts +221 -0
- package/src/control.ts +176 -22
- package/types/src/app-cli.d.ts +46 -0
- package/types/src/authoring.d.ts +27 -0
- package/types/src/conformance.d.ts +22 -0
- package/types/src/control.d.ts +628 -0
- package/types/src/index.d.ts +5 -0
- package/types/src/installation.d.ts +37 -0
- package/types/src/json.d.ts +17 -0
- package/types/src/schema.d.ts +17 -0
- package/types/src/steps.d.ts +23 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ProviderDeploymentNamespace, ProviderNamespacePlan } from './control';
|
|
2
|
+
/** The runtime a contract application's generated entry is written for (`@fabrika/app/build`'s `EntryRuntime`). */
|
|
3
|
+
export type AppEntryRuntime = 'bun' | 'cloudflare';
|
|
4
|
+
/** What a namespace command asks of Control. The `fabrika` command holds the Control origin, the credential and the transport. */
|
|
5
|
+
export interface NamespaceControl {
|
|
6
|
+
create(namespace: ProviderDeploymentNamespace): Promise<unknown>;
|
|
7
|
+
adopt(namespace: ProviderDeploymentNamespace): Promise<unknown>;
|
|
8
|
+
reconcile(namespaceId: string): Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
/** A plan, or the namespace Control answered with; the `fabrika` command validates and prints either. */
|
|
11
|
+
export type NamespaceCommandResult = {
|
|
12
|
+
readonly plan: ProviderNamespacePlan;
|
|
13
|
+
} | {
|
|
14
|
+
readonly namespace: unknown;
|
|
15
|
+
};
|
|
16
|
+
export interface NamespaceCommandContext {
|
|
17
|
+
readonly source: Readonly<Record<string, string | undefined>>;
|
|
18
|
+
/** Reads the Control origin and credential, and throws when either is missing: call it after every other input is checked. */
|
|
19
|
+
control(): NamespaceControl;
|
|
20
|
+
}
|
|
21
|
+
export interface NamespaceCli {
|
|
22
|
+
readonly usage: string;
|
|
23
|
+
/** `argv` is the command's own arguments, without the router's `--provider` and `--json`. */
|
|
24
|
+
run(subcommand: string, argv: readonly string[], context: NamespaceCommandContext): Promise<NamespaceCommandResult>;
|
|
25
|
+
}
|
|
26
|
+
export interface AppCli {
|
|
27
|
+
readonly provider: string;
|
|
28
|
+
readonly entryRuntime: AppEntryRuntime;
|
|
29
|
+
/** `fabrika app build`, after the command wrote a contract application's entry; `contract` says whether it did. */
|
|
30
|
+
build?(argv: readonly string[], context: {
|
|
31
|
+
readonly contract: boolean;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
deploy?(argv: readonly string[]): Promise<void>;
|
|
34
|
+
/** The text `fabrika app register` hands Control: the application's manifest for one environment. */
|
|
35
|
+
registrationManifest?(options: {
|
|
36
|
+
readonly config: string;
|
|
37
|
+
readonly env: string;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
readonly namespaces?: NamespaceCli;
|
|
40
|
+
}
|
|
41
|
+
export interface AppCliModule {
|
|
42
|
+
readonly appCli: AppCli;
|
|
43
|
+
}
|
|
44
|
+
export declare const isAppCli: (value: unknown) => value is AppCli;
|
|
45
|
+
/** `specifier` names the module in the error, so an operator knows which package to upgrade. */
|
|
46
|
+
export declare const appCliFromModule: (value: unknown, expectedProvider: string, specifier: string) => AppCli;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AppSchema } from '@fabrika/auth-core';
|
|
2
|
+
export declare const APP_PROVIDER: unique symbol;
|
|
3
|
+
export interface ProviderAuthoredApp<Provider extends string = string> {
|
|
4
|
+
readonly [APP_PROVIDER]: Provider;
|
|
5
|
+
}
|
|
6
|
+
export declare const authoredAppProvider: (value: unknown) => string | undefined;
|
|
7
|
+
export declare const isProviderAuthoredApp: <Provider extends string>(value: unknown, provider: Provider) => value is ProviderAuthoredApp<Provider>;
|
|
8
|
+
/** Provider-neutral build inputs and environment requirements declared by an app. */
|
|
9
|
+
export interface AppPipeline {
|
|
10
|
+
/** Source directory relative to the app config file. Defaults to `.`. */
|
|
11
|
+
workerDir?: string;
|
|
12
|
+
/** Shell command that builds the deployable artifact. */
|
|
13
|
+
build?: string;
|
|
14
|
+
/** Secret names that must resolve before deployment. */
|
|
15
|
+
secrets?: string[];
|
|
16
|
+
/** Non-secret variable names that must resolve before deployment. */
|
|
17
|
+
vars?: string[];
|
|
18
|
+
}
|
|
19
|
+
/** App metadata shared by every provider-specific authoring config. */
|
|
20
|
+
export interface AppConfigBase {
|
|
21
|
+
/** Stable app id, unique within one control plane. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** The app-owned authorization vocabulary reconciled into IAM. */
|
|
24
|
+
schema?: AppSchema;
|
|
25
|
+
/** Provider-neutral build and environment requirements. */
|
|
26
|
+
pipeline?: AppPipeline;
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ControlProvider, type ProviderDeployInput } from './control';
|
|
2
|
+
/** What the suite hands a fake cloud: `accepted` is called once the cloud has taken the deploy's operation. */
|
|
3
|
+
export interface ConformanceCloudHooks {
|
|
4
|
+
accepted(): void;
|
|
5
|
+
}
|
|
6
|
+
/** One provider over one fresh fake cloud. */
|
|
7
|
+
export interface ConformanceCloud {
|
|
8
|
+
readonly provider: ControlProvider;
|
|
9
|
+
/** A deploy the fake cloud accepts and lets succeed. Each case sets `dryRun`, `signal` and `events` itself. */
|
|
10
|
+
readonly input: Omit<ProviderDeployInput, 'dryRun' | 'signal' | 'events'>;
|
|
11
|
+
/** The credentials the provider holds itself (a cloud token, a signed URL); no event may carry one. */
|
|
12
|
+
readonly credentials: readonly string[];
|
|
13
|
+
/** Every request that changed the cloud: a write, a created resource, started work. A preview the cloud runs is none. */
|
|
14
|
+
mutations(): readonly string[];
|
|
15
|
+
/** Every request to stop or remove the deploy's work: a cancelled build or job, a deleted version. */
|
|
16
|
+
stops(): readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface ControlProviderConformanceHarness {
|
|
19
|
+
/** Called once per case, and once per event in the lease-loss sweep. */
|
|
20
|
+
create(hooks: ConformanceCloudHooks): ConformanceCloud;
|
|
21
|
+
}
|
|
22
|
+
export declare function describeControlProviderConformance(name: string, harness: ControlProviderConformanceHarness): void;
|