@jini-ai/devops 0.3.2 → 0.3.3
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/README.md +7 -0
- package/dist/deploy/host-kit.d.ts +116 -0
- package/dist/deploy/host-kit.js +2 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +1 -0
- package/dist/deploy/types.d.ts +8 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,6 +19,13 @@ import {
|
|
|
19
19
|
} from '@jini-ai/devops/deploy';
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
A host can also keep its own target code outside this package: it writes each
|
|
23
|
+
target as a `DeployTargetModule` and hands it a `DeployHostKit` (the outbound
|
|
24
|
+
`fetch`, timeouts, and this package's naming, reachability and redirect-guard
|
|
25
|
+
helpers), so the module needs no imports of its own. `create()` returns a plain
|
|
26
|
+
`DeployTarget`. `DeployPublishInput.responseHeaders` carries the headers every
|
|
27
|
+
published page should be served with; each target renders them its own way.
|
|
28
|
+
|
|
22
29
|
Deployment stays independent from CI/CD: a pipeline may invoke a deployment,
|
|
23
30
|
but the two have different credentials, approval policies, lifecycle, and audit
|
|
24
31
|
requirements.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The injection contract for host-supplied deploy targets.
|
|
3
|
+
*
|
|
4
|
+
* A host (an app, a plugin loader) may keep its own deploy-target code outside
|
|
5
|
+
* this package and still produce a plain {@link DeployTarget}. It writes each
|
|
6
|
+
* target as a {@link DeployTargetModule}, and hands every module a
|
|
7
|
+
* {@link DeployHostKit}: the outbound `fetch`, timeouts, and this package's
|
|
8
|
+
* generic helpers. A module then needs no imports of its own, so it can ship
|
|
9
|
+
* as a standalone file (for example inside a plugin copied verbatim to disk,
|
|
10
|
+
* where no npm dependency could resolve). The resulting targets bind like any
|
|
11
|
+
* other (`bindMany(DeployTargetToken, ...)` or passed straight to
|
|
12
|
+
* `publishDeploy`). Nothing here names a hosting provider.
|
|
13
|
+
*/
|
|
14
|
+
import type { assertNotRedirected, redirectGuardInit } from './redirect-guard.js';
|
|
15
|
+
import type { safeDnsLabel, safeProjectLabel } from './naming.js';
|
|
16
|
+
import type { checkDeploymentUrl, normalizeDeploymentUrl, waitForReachableDeploymentUrl } from './reachability.js';
|
|
17
|
+
import type { DeployError, DeployTarget, JsonObject } from './types.js';
|
|
18
|
+
/**
|
|
19
|
+
* The resolved saved credential a module builds its target from: always a
|
|
20
|
+
* `token`, plus whatever extra fields that host's credential carries (an
|
|
21
|
+
* account id, bucket coordinates, ...).
|
|
22
|
+
*/
|
|
23
|
+
export type DeployTargetCredential = {
|
|
24
|
+
readonly token: string;
|
|
25
|
+
} & Readonly<Record<string, string | undefined>>;
|
|
26
|
+
/**
|
|
27
|
+
* The per-call timeout classes the kit's `fetch` is used with. Same names as
|
|
28
|
+
* `@jini-ai/platform`'s `FETCH_TIMEOUT_MS`, so a host can pass that object.
|
|
29
|
+
*/
|
|
30
|
+
export interface DeployFetchTimeouts {
|
|
31
|
+
readonly QUICK: number;
|
|
32
|
+
readonly DEPLOY: number;
|
|
33
|
+
readonly UPLOAD: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What {@link DeployHostKit.createSigV4Client} takes: an access-key pair
|
|
37
|
+
* scoped to one service and region, the shape every SigV4-signed API uses.
|
|
38
|
+
*/
|
|
39
|
+
export interface SigV4ClientOptions {
|
|
40
|
+
readonly accessKeyId: string;
|
|
41
|
+
readonly secretAccessKey: string;
|
|
42
|
+
readonly service: string;
|
|
43
|
+
readonly region: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A client whose `fetch` signs each request with AWS Signature Version 4
|
|
47
|
+
* before sending it, retrying a 5xx/429 with backoff.
|
|
48
|
+
*/
|
|
49
|
+
export interface SigV4Client {
|
|
50
|
+
fetch(input: string, init?: RequestInit): Promise<Response>;
|
|
51
|
+
/** Signs a request without sending it, so the caller can send it through `DeployHostKit.fetch`. */
|
|
52
|
+
sign(input: string, init?: RequestInit): Promise<Request>;
|
|
53
|
+
}
|
|
54
|
+
/** Everything a module may call that is not a runtime builtin. The host builds it and passes it in. */
|
|
55
|
+
export interface DeployHostKit {
|
|
56
|
+
/** `fetch`, aborted after `options.timeoutMs`. */
|
|
57
|
+
fetch(url: string, init: RequestInit, options: {
|
|
58
|
+
readonly timeoutMs: number;
|
|
59
|
+
}): Promise<Response>;
|
|
60
|
+
readonly timeouts: DeployFetchTimeouts;
|
|
61
|
+
/** Delay between poll attempts. Injected so a test never waits in real time. */
|
|
62
|
+
sleep(ms: number): Promise<void>;
|
|
63
|
+
readonly checkDeploymentUrl: typeof checkDeploymentUrl;
|
|
64
|
+
readonly waitForReachableDeploymentUrl: typeof waitForReachableDeploymentUrl;
|
|
65
|
+
readonly normalizeDeploymentUrl: typeof normalizeDeploymentUrl;
|
|
66
|
+
readonly safeDnsLabel: typeof safeDnsLabel;
|
|
67
|
+
readonly safeProjectLabel: typeof safeProjectLabel;
|
|
68
|
+
/** A request built with `redirectGuardInit` never follows a redirect, and
|
|
69
|
+
* `assertNotRedirected` fails a 3xx instead of sending the token on to another host. */
|
|
70
|
+
readonly redirectGuardInit: typeof redirectGuardInit;
|
|
71
|
+
readonly assertNotRedirected: typeof assertNotRedirected;
|
|
72
|
+
/** A SigV4-signing client (a protocol, not a provider: many object stores speak it). */
|
|
73
|
+
createSigV4Client(options: SigV4ClientOptions): SigV4Client;
|
|
74
|
+
readonly DeployError: typeof DeployError;
|
|
75
|
+
}
|
|
76
|
+
export interface DeployTargetCreateContext {
|
|
77
|
+
readonly credential: DeployTargetCredential;
|
|
78
|
+
readonly config: JsonObject;
|
|
79
|
+
readonly kit: DeployHostKit;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* One credential check's raw outcome. `rejected`: the host answered and
|
|
83
|
+
* refused the credential (it must be replaced). `unreachable`: a transport
|
|
84
|
+
* failure, timeout or unexpected status that says nothing about the
|
|
85
|
+
* credential itself. `accountLabel` is the account's public handle only
|
|
86
|
+
* (never an email, plan or org).
|
|
87
|
+
*/
|
|
88
|
+
export type DeployCredentialCheck = {
|
|
89
|
+
readonly ok: true;
|
|
90
|
+
readonly accountLabel?: string;
|
|
91
|
+
} | {
|
|
92
|
+
readonly ok: false;
|
|
93
|
+
readonly reason: 'rejected' | 'unreachable';
|
|
94
|
+
readonly statusCode?: number;
|
|
95
|
+
};
|
|
96
|
+
export interface DeployCredentialCheckContext {
|
|
97
|
+
readonly credential: DeployTargetCredential;
|
|
98
|
+
readonly kit: DeployHostKit;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A deploy-target module's default export. Only `create` is required; the
|
|
102
|
+
* host supplies defaults for the rest (no config errors, no base path, no
|
|
103
|
+
* credential check).
|
|
104
|
+
*/
|
|
105
|
+
export interface DeployTargetModule {
|
|
106
|
+
create(context: DeployTargetCreateContext): DeployTarget;
|
|
107
|
+
/** A human-readable config error, or `null` when `config` is usable. */
|
|
108
|
+
validateConfig?(config: JsonObject): string | null;
|
|
109
|
+
/** The path prefix the host serves the site from, when it is not the root. */
|
|
110
|
+
basePath?(config: JsonObject): string | undefined;
|
|
111
|
+
/** One bounded, read-only authenticated request against the host's own API.
|
|
112
|
+
* May throw: the caller folds any throw into `unreachable`. Never returns
|
|
113
|
+
* the credential or a response body. */
|
|
114
|
+
verifyCredential?(context: DeployCredentialCheckContext): Promise<DeployCredentialCheck>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=host-kit.d.ts.map
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './types.js';
|
|
|
2
2
|
export * from './naming.js';
|
|
3
3
|
export * from './reachability.js';
|
|
4
4
|
export * from './redirect-guard.js';
|
|
5
|
+
export * from './host-kit.js';
|
|
5
6
|
export * from './vercel.js';
|
|
6
7
|
export * from './cloudflare-pages.js';
|
|
7
8
|
export * from './netlify.js';
|
package/dist/deploy/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './types.js';
|
|
|
2
2
|
export * from './naming.js';
|
|
3
3
|
export * from './reachability.js';
|
|
4
4
|
export * from './redirect-guard.js';
|
|
5
|
+
export * from './host-kit.js';
|
|
5
6
|
export * from './vercel.js';
|
|
6
7
|
export * from './cloudflare-pages.js';
|
|
7
8
|
export * from './netlify.js';
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -42,12 +42,20 @@ export interface DeploymentUrlCheck {
|
|
|
42
42
|
* options (e.g. Cloudflare custom-domain selection) that do not belong in
|
|
43
43
|
* the shared shape — each target documents the metadata keys it reads and
|
|
44
44
|
* ignores everything else.
|
|
45
|
+
*
|
|
46
|
+
* `responseHeaders` is the header set the caller wants every published page
|
|
47
|
+
* served with (e.g. security headers). Each target renders it into its own
|
|
48
|
+
* host format (a `_headers` file, a host config file, ...) or ignores it
|
|
49
|
+
* where the host offers no way to set headers.
|
|
45
50
|
*/
|
|
46
51
|
export interface DeployPublishInput {
|
|
47
52
|
files: DeployFile[];
|
|
48
53
|
projectName: string;
|
|
49
54
|
metadata?: JsonObject;
|
|
55
|
+
responseHeaders?: ResponseHeaderSet;
|
|
50
56
|
}
|
|
57
|
+
/** HTTP response headers by name, as a caller asks a target to serve them. */
|
|
58
|
+
export type ResponseHeaderSet = Readonly<Record<string, string>>;
|
|
51
59
|
/** Result of a successful (or partially successful) publish call. */
|
|
52
60
|
export interface DeployPublishResult {
|
|
53
61
|
targetId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/devops",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@vitest/coverage-v8": "^2.1.9",
|
|
56
|
-
"@jini-ai/daemon": "0.3.
|
|
56
|
+
"@jini-ai/daemon": "0.3.8"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsc -p tsconfig.json",
|