@openstrap/plugin-contract 0.1.2 → 0.2.1

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/Provider.d.ts CHANGED
@@ -89,25 +89,6 @@ export type MachineResources = {
89
89
  diskBytes: number;
90
90
  };
91
91
 
92
- /** Declarative cloud-config passed to cloud-init; executable modules are rejected by OpenStrap. */
93
- export type CloudInitOptions = {
94
- [key: string]: unknown;
95
- /** Compatibility alias for cloud-init's package_update. */
96
- packageUpdate?: boolean;
97
- /** Compatibility alias for cloud-init's package_upgrade. */
98
- packageUpgrade?: boolean;
99
- packages?: readonly (string | readonly [name: string, version: string] | {
100
- name: string;
101
- version?: string;
102
- /** Official HTTPS repository setup script, run as root before APT installs this package. */
103
- setup: string;
104
- })[];
105
- /** Native APT configuration, interpreted by cloud-init. */
106
- apt?: Readonly<Record<string, unknown>>;
107
- /** Maximum time to wait for guest initialization; defaults to fifteen minutes. */
108
- timeoutMs?: number;
109
- };
110
-
111
92
  export type MachineNetwork = {
112
93
  hostAccess?: boolean;
113
94
  /** A provider-managed private network, in addition to outbound NAT. */
@@ -134,7 +115,13 @@ export type MachineRequest = {
134
115
  machineType?: string;
135
116
  /** Whether a guest may reach services on the provider's host through its network gateway. */
136
117
  network?: MachineNetwork;
137
- cloudInit?: CloudInitOptions;
118
+ /**
119
+ * The project's cloud-init user data for the first boot, as its file is written, with the values
120
+ * the blueprint declares filled in: any format cloud-init reads (`#cloud-config`, a script, …).
121
+ * The provider sends it beside its own part (the managed user and its key) as a MIME multipart
122
+ * archive, so neither replaces the other. Present only where the blueprint names a file.
123
+ */
124
+ userData?: string;
138
125
  /** Whether the machine needs a screen. Absent is no screen, which is what a server wants. */
139
126
  display?: boolean;
140
127
  /**
@@ -239,4 +226,14 @@ export type Provider = {
239
226
  * runs says so in the outcome.
240
227
  */
241
228
  publish?(machine: MachineHandle, ports: readonly number[], options?: MachineStartOptions): Promise<PublishedPorts>;
229
+ /** Every machine this provider holds on this host, made by openstrap or not. */
230
+ discover?(): Promise<Array<{ name: string; resourceId: string; status: "running" | "stopped" | "suspended" | "unknown" }>>;
231
+ /**
232
+ * Where a machine's disk came from, read from the provider's own records: a clone names its source
233
+ * machine (and snapshot); a machine that is not a clone answers null.
234
+ *
235
+ * `reference` is the image reference a blueprint would write for that source — the same form
236
+ * `resolveSource` produces for it.
237
+ */
238
+ diskOrigin?(machine: MachineHandle): Promise<{ source: MachineSource; reference: string; detail: string } | null>;
242
239
  };
package/Transport.d.ts CHANGED
@@ -76,6 +76,20 @@ export type OpenSshAccess = {
76
76
  options?: Readonly<Record<string, string>>;
77
77
  };
78
78
 
79
+ export type SshConfigTarget = { machine: string; host: string; port: number };
80
+
81
+ export type SshConfigEntry = {
82
+ alias: string;
83
+ user: string;
84
+ hostName: string;
85
+ port: number;
86
+ /** Paths on the transport host. Key material is never returned. */
87
+ identityFiles: string[];
88
+ };
89
+
90
+ export type SshConfigReport = { file: string; entries: SshConfigEntry[] };
91
+ export type TransportAuthenticationFailure = "connector" | "provided";
92
+
79
93
  /**
80
94
  * Opens a transport to a target.
81
95
  *
@@ -104,10 +118,16 @@ export type TransportConnector = {
104
118
  * key it was given rather than one of the connector's own. Nothing is kept.
105
119
  */
106
120
  publicKeyOf?(privateKey: string): Promise<string>;
121
+ /** Loads a caller-declared key path on the transport host. The connector resolves the path. */
122
+ readIdentityFile?(target: string, path: string): Promise<string>;
107
123
  /**
108
124
  * How an OpenSSH client reaches the machine the way this transport does. Optional: a transport
109
125
  * that is not SSH underneath has nothing to say to OpenSSH.
110
126
  */
111
127
  openSshAccess?(request: TransportConnectionRequest): Promise<OpenSshAccess>;
128
+ /** Resolves existing OpenSSH client settings for a target, when supported. */
129
+ sshConfigFor?(target: SshConfigTarget): Promise<SshConfigReport>;
130
+ /** Identifies a rejected login and whether the connector or caller supplied the identity. */
131
+ authenticationFailure?(error: unknown): TransportAuthenticationFailure | undefined;
112
132
  connect(request: TransportConnectionRequest): Promise<TransportConnection>;
113
133
  };
package/index.d.ts CHANGED
@@ -11,7 +11,6 @@ export type {
11
11
  export type {
12
12
  MachineAccess,
13
13
  MachineNetwork,
14
- CloudInitOptions,
15
14
  MachineHandle,
16
15
  MachineRequest,
17
16
  MachineResources,
@@ -33,6 +32,10 @@ export type {
33
32
  } from "./Secret.js";
34
33
  export type {
35
34
  OpenSshAccess,
35
+ SshConfigEntry,
36
+ SshConfigReport,
37
+ SshConfigTarget,
38
+ TransportAuthenticationFailure,
36
39
  TransportConnection,
37
40
  TransportConnectionRequest,
38
41
  TransportConnector,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openstrap/plugin-contract",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "The shape an OpenStrap plugin has. Types only: no runtime code, so a plugin depends on the contract and never on OpenStrap.",
5
5
  "type": "module",
6
6
  "exports": {