@principal-ai/subsystems-core 0.53.0 → 0.53.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/infra/index.d.ts +5 -1
- package/dist/infra/index.d.ts.map +1 -1
- package/dist/infra/index.js +10 -2
- package/dist/infra/index.js.map +1 -1
- package/dist/infra/observe.d.ts +102 -0
- package/dist/infra/observe.d.ts.map +1 -0
- package/dist/infra/observe.js +347 -0
- package/dist/infra/observe.js.map +1 -0
- package/dist/infra/types.d.ts +4 -4
- package/dist/infra/types.js +4 -4
- package/package.json +1 -1
- package/src/index.ts +3 -2
- package/src/infra/index.ts +16 -1
- package/src/infra/observe.test.ts +202 -0
- package/src/infra/observe.ts +451 -0
- package/src/infra/types.ts +4 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAKxH,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI/D,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,8 +33,9 @@ Object.defineProperty(exports, "formatTopicReferenceLink", { enumerable: true, g
|
|
|
33
33
|
Object.defineProperty(exports, "parseTopicReferenceLink", { enumerable: true, get: function () { return topic_reference_links_1.parseTopicReferenceLink; } });
|
|
34
34
|
var topic_share_1 = require("./storage/topic-share");
|
|
35
35
|
Object.defineProperty(exports, "toSharedTopic", { enumerable: true, get: function () { return topic_share_1.toSharedTopic; } });
|
|
36
|
-
// Infrastructure-as-code read side: what wrangler / terraform declare,
|
|
37
|
-
// shape a live-deployment observation takes
|
|
36
|
+
// Infrastructure-as-code read side: what wrangler / terraform declare, the
|
|
37
|
+
// shape a live-deployment observation takes, and the checks that produce one
|
|
38
|
+
// from a credential the caller supplies. Browser-safe — no Node built-ins.
|
|
38
39
|
__exportStar(require("./infra"), exports);
|
|
39
40
|
// Cross-field validation (the rules the JSON Schema can't express). Structural
|
|
40
41
|
// (schema) validation is enforced per surface against
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AASxB,yEAAoG;AAA3F,iIAAA,wBAAwB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAC1D,qDAAsD;AAA7C,4GAAA,aAAa,OAAA;AAGtB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AASxB,yEAAoG;AAA3F,iIAAA,wBAAwB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAC1D,qDAAsD;AAA7C,4GAAA,aAAa,OAAA;AAGtB,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,0CAAwB;AAExB,+EAA+E;AAC/E,sDAAsD;AACtD,yCAAyC;AACzC,2CAAgE;AAAvD,8HAAA,gCAAgC,OAAA;AAGzC,gFAAgF;AAChF,uEAAuE;AACvE,+CAA6B"}
|
package/dist/infra/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Infrastructure-as-code read side.
|
|
2
|
+
* Infrastructure-as-code read side. Browser-safe. Everything is pure except
|
|
3
|
+
* `./observe`, which asks a provider's API what is running, with a credential
|
|
4
|
+
* the caller supplies.
|
|
3
5
|
*/
|
|
4
6
|
export { infraResourceKey, mergeInfraManifests } from './types';
|
|
5
7
|
export type { InfraBinding, InfraDeploymentObservation, InfraDeploymentStatus, InfraManifest, InfraResource, InfraResourceSource, InfraTool, } from './types';
|
|
@@ -10,4 +12,6 @@ export { extractTerraformManifest, terraformStateObservations } from './terrafor
|
|
|
10
12
|
export type { ExtractTerraformOptions } from './terraform';
|
|
11
13
|
export { infraContainerId, infraDeploymentRef, infraToC4 } from './c4';
|
|
12
14
|
export type { InfraC4Container, InfraC4Deployment, InfraC4Edge } from './c4';
|
|
15
|
+
export { CLOUDFLARE_OBSERVED_TYPES, observeCloudflare, parseWranglerAuthToken, resolveCloudflareAccount, withoutUnknownOverwrites, } from './observe';
|
|
16
|
+
export type { CloudflareAccess, CloudflareAccountResult, InfraObserveDeps, InfraObserveResult, } from './observe';
|
|
13
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EACV,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACnF,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC7E,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,WAAW,CAAC"}
|
package/dist/infra/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Infrastructure-as-code read side.
|
|
3
|
+
* Infrastructure-as-code read side. Browser-safe. Everything is pure except
|
|
4
|
+
* `./observe`, which asks a provider's API what is running, with a credential
|
|
5
|
+
* the caller supplies.
|
|
4
6
|
*/
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.infraToC4 = exports.infraDeploymentRef = exports.infraContainerId = exports.terraformStateObservations = exports.extractTerraformManifest = exports.extractWranglerManifest = exports.stripJsonc = exports.parseJsonc = exports.mergeInfraManifests = exports.infraResourceKey = void 0;
|
|
8
|
+
exports.withoutUnknownOverwrites = exports.resolveCloudflareAccount = exports.parseWranglerAuthToken = exports.observeCloudflare = exports.CLOUDFLARE_OBSERVED_TYPES = exports.infraToC4 = exports.infraDeploymentRef = exports.infraContainerId = exports.terraformStateObservations = exports.extractTerraformManifest = exports.extractWranglerManifest = exports.stripJsonc = exports.parseJsonc = exports.mergeInfraManifests = exports.infraResourceKey = void 0;
|
|
7
9
|
var types_1 = require("./types");
|
|
8
10
|
Object.defineProperty(exports, "infraResourceKey", { enumerable: true, get: function () { return types_1.infraResourceKey; } });
|
|
9
11
|
Object.defineProperty(exports, "mergeInfraManifests", { enumerable: true, get: function () { return types_1.mergeInfraManifests; } });
|
|
@@ -19,4 +21,10 @@ var c4_1 = require("./c4");
|
|
|
19
21
|
Object.defineProperty(exports, "infraContainerId", { enumerable: true, get: function () { return c4_1.infraContainerId; } });
|
|
20
22
|
Object.defineProperty(exports, "infraDeploymentRef", { enumerable: true, get: function () { return c4_1.infraDeploymentRef; } });
|
|
21
23
|
Object.defineProperty(exports, "infraToC4", { enumerable: true, get: function () { return c4_1.infraToC4; } });
|
|
24
|
+
var observe_1 = require("./observe");
|
|
25
|
+
Object.defineProperty(exports, "CLOUDFLARE_OBSERVED_TYPES", { enumerable: true, get: function () { return observe_1.CLOUDFLARE_OBSERVED_TYPES; } });
|
|
26
|
+
Object.defineProperty(exports, "observeCloudflare", { enumerable: true, get: function () { return observe_1.observeCloudflare; } });
|
|
27
|
+
Object.defineProperty(exports, "parseWranglerAuthToken", { enumerable: true, get: function () { return observe_1.parseWranglerAuthToken; } });
|
|
28
|
+
Object.defineProperty(exports, "resolveCloudflareAccount", { enumerable: true, get: function () { return observe_1.resolveCloudflareAccount; } });
|
|
29
|
+
Object.defineProperty(exports, "withoutUnknownOverwrites", { enumerable: true, get: function () { return observe_1.withoutUnknownOverwrites; } });
|
|
22
30
|
//# sourceMappingURL=index.js.map
|
package/dist/infra/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iCAAgE;AAAvD,yGAAA,gBAAgB,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAU9C,iCAAiD;AAAxC,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA;AAC/B,uCAAqD;AAA5C,mHAAA,uBAAuB,OAAA;AAEhC,yCAAmF;AAA1E,qHAAA,wBAAwB,OAAA;AAAE,uHAAA,0BAA0B,OAAA;AAE7D,2BAAuE;AAA9D,sGAAA,gBAAgB,OAAA;AAAE,wGAAA,kBAAkB,OAAA;AAAE,+FAAA,SAAS,OAAA;AAExD,qCAMmB;AALjB,oHAAA,yBAAyB,OAAA;AACzB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,mHAAA,wBAAwB,OAAA;AACxB,mHAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Looking at a live account — the checks that turn declared resource keys into
|
|
3
|
+
* {@link InfraDeploymentObservation}s.
|
|
4
|
+
*
|
|
5
|
+
* This is the one place that knows how to ask a provider whether a declared
|
|
6
|
+
* resource exists. It is given a credential and returns observations; it does
|
|
7
|
+
* not know where the credential came from (a pasted token, a CLI login, a
|
|
8
|
+
* server-held token) and it stores nothing. Hosts own both ends: Studio and
|
|
9
|
+
* the desktop app run it in their main process, a hosted service can run it in
|
|
10
|
+
* a Worker.
|
|
11
|
+
*
|
|
12
|
+
* Fetch-only and browser-safe. The token travels only in the Authorization
|
|
13
|
+
* header of requests to the provider's API, and never appears in a result.
|
|
14
|
+
*
|
|
15
|
+
* Cloudflare only: Workers, R2, D1, KV, Queues and Containers. A resource type
|
|
16
|
+
* with no lookup is reported as skipped rather than guessed at.
|
|
17
|
+
*/
|
|
18
|
+
import type { InfraDeploymentObservation } from './types';
|
|
19
|
+
/** What a check needs to run, besides the credential. */
|
|
20
|
+
export interface InfraObserveDeps {
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
now?: () => Date;
|
|
23
|
+
}
|
|
24
|
+
/** A credential for one Cloudflare account. */
|
|
25
|
+
export interface CloudflareAccess {
|
|
26
|
+
/** An API token or an OAuth access token; sent as a Bearer token. */
|
|
27
|
+
token: string;
|
|
28
|
+
accountId: string;
|
|
29
|
+
}
|
|
30
|
+
export type CloudflareAccountResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
accountId: string;
|
|
33
|
+
account?: string;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
error: string;
|
|
37
|
+
/** Set when the token sees several accounts and one must be chosen. */
|
|
38
|
+
accounts?: Array<{
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Work out which account a Cloudflare token is for, and prove it can do the
|
|
45
|
+
* job: it must resolve to one account and be able to read that account's
|
|
46
|
+
* Workers. A token that cannot is refused with the reason, so a person finds
|
|
47
|
+
* out when connecting rather than from cards that never light up.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveCloudflareAccount(input: {
|
|
50
|
+
token: string;
|
|
51
|
+
accountId?: string;
|
|
52
|
+
}, deps?: InfraObserveDeps): Promise<CloudflareAccountResult>;
|
|
53
|
+
/** Cloudflare resource types a check can look at. */
|
|
54
|
+
export declare const CLOUDFLARE_OBSERVED_TYPES: readonly string[];
|
|
55
|
+
/** What one run of checks learned. Nothing here has been stored. */
|
|
56
|
+
export interface InfraObserveResult {
|
|
57
|
+
/**
|
|
58
|
+
* One observation per resource that was looked at, `unknown` ones included.
|
|
59
|
+
* A host that already holds an observation for a key should pass these
|
|
60
|
+
* through {@link withoutUnknownOverwrites} before storing them.
|
|
61
|
+
*/
|
|
62
|
+
observations: InfraDeploymentObservation[];
|
|
63
|
+
/** Keys that were not looked at, with the reason. */
|
|
64
|
+
skipped: Array<{
|
|
65
|
+
resourceKey: string;
|
|
66
|
+
reason: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Why some lookups could not be made, when any could not. */
|
|
69
|
+
failure?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Look at the named Cloudflare resources and say what was seen.
|
|
73
|
+
*
|
|
74
|
+
* Three outcomes per resource, kept apart on purpose:
|
|
75
|
+
* - it is there → `deployed`, with whatever address and dashboard page it has;
|
|
76
|
+
* - Cloudflare says it does not exist → `not-found`;
|
|
77
|
+
* - the question could not be asked (auth, network) → `unknown`.
|
|
78
|
+
*
|
|
79
|
+
* Failures are per resource: a token that cannot read R2 still gets the
|
|
80
|
+
* Workers checked, and the R2 failure is reported in `failure`. Keys for other
|
|
81
|
+
* providers are ignored.
|
|
82
|
+
*/
|
|
83
|
+
export declare function observeCloudflare(resourceKeys: readonly string[], access: CloudflareAccess, deps?: InfraObserveDeps): Promise<InfraObserveResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Drop `unknown` observations for resources something is already known about.
|
|
86
|
+
* A failed check must not erase what was known: `unknown` is only worth
|
|
87
|
+
* keeping when it is the first thing said about a resource.
|
|
88
|
+
*/
|
|
89
|
+
export declare function withoutUnknownOverwrites(observations: readonly InfraDeploymentObservation[], alreadyKnown: ReadonlySet<string>): InfraDeploymentObservation[];
|
|
90
|
+
/**
|
|
91
|
+
* Read the answer of `wrangler auth token --json` — the credential of whoever
|
|
92
|
+
* is logged in to wrangler on this machine, refreshed by wrangler itself.
|
|
93
|
+
*
|
|
94
|
+
* Only a Bearer credential is usable here: an OAuth login or an API token. A
|
|
95
|
+
* global API key (key + email) is not, and reads as null, as does anything
|
|
96
|
+
* that is not wrangler's JSON.
|
|
97
|
+
*/
|
|
98
|
+
export declare function parseWranglerAuthToken(stdout: string): {
|
|
99
|
+
token: string;
|
|
100
|
+
type: 'oauth' | 'api_token';
|
|
101
|
+
} | null;
|
|
102
|
+
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/infra/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAM1D,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAyDD,MAAM,MAAM,uBAAuB,GAC/B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CAAC;AAEN;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5C,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CAuDlC;AA2JD,qDAAqD;AACrD,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAAwB,CAAC;AAEhF,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,YAAY,EAAE,0BAA0B,EAAE,CAAC;IAC3C,qDAAqD;IACrD,OAAO,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,MAAM,EAAE,gBAAgB,EACxB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CA0D7B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,SAAS,0BAA0B,EAAE,EACnD,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAChC,0BAA0B,EAAE,CAI9B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAA;CAAE,GAAG,IAAI,CAavD"}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Looking at a live account — the checks that turn declared resource keys into
|
|
4
|
+
* {@link InfraDeploymentObservation}s.
|
|
5
|
+
*
|
|
6
|
+
* This is the one place that knows how to ask a provider whether a declared
|
|
7
|
+
* resource exists. It is given a credential and returns observations; it does
|
|
8
|
+
* not know where the credential came from (a pasted token, a CLI login, a
|
|
9
|
+
* server-held token) and it stores nothing. Hosts own both ends: Studio and
|
|
10
|
+
* the desktop app run it in their main process, a hosted service can run it in
|
|
11
|
+
* a Worker.
|
|
12
|
+
*
|
|
13
|
+
* Fetch-only and browser-safe. The token travels only in the Authorization
|
|
14
|
+
* header of requests to the provider's API, and never appears in a result.
|
|
15
|
+
*
|
|
16
|
+
* Cloudflare only: Workers, R2, D1, KV, Queues and Containers. A resource type
|
|
17
|
+
* with no lookup is reported as skipped rather than guessed at.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.parseWranglerAuthToken = exports.withoutUnknownOverwrites = exports.observeCloudflare = exports.CLOUDFLARE_OBSERVED_TYPES = exports.resolveCloudflareAccount = void 0;
|
|
21
|
+
const CLOUDFLARE_API = 'https://api.cloudflare.com/client/v4';
|
|
22
|
+
const REQUEST_TIMEOUT_MS = 15000;
|
|
23
|
+
const ACCOUNT_ID_SHAPE = /^[a-f0-9]{32}$/;
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One read against the Cloudflare API. Failures come back as values: the
|
|
29
|
+
* caller decides whether "not there" and "could not ask" mean different
|
|
30
|
+
* things.
|
|
31
|
+
*/
|
|
32
|
+
async function cloudflareGet(path, token, doFetch) {
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
response = await doFetch(`${CLOUDFLARE_API}${path}`, {
|
|
36
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
37
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { ok: false, status: 0, message: 'could not reach the Cloudflare API' };
|
|
42
|
+
}
|
|
43
|
+
let body;
|
|
44
|
+
try {
|
|
45
|
+
body = await response.json();
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return { ok: false, status: response.status, message: `Cloudflare answered ${response.status}` };
|
|
49
|
+
}
|
|
50
|
+
if (response.ok && isRecord(body) && body['success'] === true) {
|
|
51
|
+
return { ok: true, result: body['result'] };
|
|
52
|
+
}
|
|
53
|
+
// The containers API answers with the bare value, not the usual envelope.
|
|
54
|
+
if (response.ok && (Array.isArray(body) || (isRecord(body) && !('success' in body)))) {
|
|
55
|
+
return { ok: true, result: body };
|
|
56
|
+
}
|
|
57
|
+
const first = isRecord(body) && Array.isArray(body['errors']) && isRecord(body['errors'][0])
|
|
58
|
+
? body['errors'][0]
|
|
59
|
+
: undefined;
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
status: response.status,
|
|
63
|
+
...(typeof first?.['code'] === 'number' ? { code: first['code'] } : {}),
|
|
64
|
+
message: typeof first?.['message'] === 'string'
|
|
65
|
+
? first['message']
|
|
66
|
+
: `Cloudflare answered ${response.status}`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Work out which account a Cloudflare token is for, and prove it can do the
|
|
71
|
+
* job: it must resolve to one account and be able to read that account's
|
|
72
|
+
* Workers. A token that cannot is refused with the reason, so a person finds
|
|
73
|
+
* out when connecting rather than from cards that never light up.
|
|
74
|
+
*/
|
|
75
|
+
async function resolveCloudflareAccount(input, deps = {}) {
|
|
76
|
+
const doFetch = deps.fetch ?? fetch;
|
|
77
|
+
const { token } = input;
|
|
78
|
+
let accountId = input.accountId?.trim() ?? '';
|
|
79
|
+
if (accountId && !ACCOUNT_ID_SHAPE.test(accountId)) {
|
|
80
|
+
return { ok: false, error: 'The account id should be 32 hexadecimal characters.' };
|
|
81
|
+
}
|
|
82
|
+
let account;
|
|
83
|
+
const listed = await cloudflareGet('/accounts?per_page=50', token, doFetch);
|
|
84
|
+
if (!listed.ok && (listed.status === 401 || listed.status === 403) && !accountId) {
|
|
85
|
+
return { ok: false, error: `Cloudflare rejected the token: ${listed.message}` };
|
|
86
|
+
}
|
|
87
|
+
if (!listed.ok && listed.status === 0)
|
|
88
|
+
return { ok: false, error: listed.message };
|
|
89
|
+
const accounts = (listed.ok && Array.isArray(listed.result) ? listed.result : [])
|
|
90
|
+
.filter((a) => typeof a?.id === 'string')
|
|
91
|
+
.map((a) => ({ id: a.id, name: a.name ?? a.id }));
|
|
92
|
+
if (accountId) {
|
|
93
|
+
account = accounts.find((a) => a.id === accountId)?.name;
|
|
94
|
+
}
|
|
95
|
+
else if (accounts.length === 1) {
|
|
96
|
+
accountId = accounts[0].id;
|
|
97
|
+
account = accounts[0].name;
|
|
98
|
+
}
|
|
99
|
+
else if (accounts.length > 1) {
|
|
100
|
+
return { ok: false, error: 'This token can see several accounts. Choose one.', accounts };
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
error: 'This token cannot list its account. Enter the account id as well.',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// The permission the checks need. Also proves the account id is right.
|
|
109
|
+
const probe = await cloudflareGet(`/accounts/${accountId}/workers/subdomain`, token, doFetch);
|
|
110
|
+
if (!probe.ok) {
|
|
111
|
+
// 10007: no workers.dev subdomain registered — the token still works.
|
|
112
|
+
const usable = probe.status === 404 || probe.code === 10007;
|
|
113
|
+
if (!usable) {
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
error: probe.status === 0
|
|
117
|
+
? probe.message
|
|
118
|
+
: `The token cannot read Workers on that account: ${probe.message}`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { ok: true, accountId, ...(account ? { account } : {}) };
|
|
123
|
+
}
|
|
124
|
+
exports.resolveCloudflareAccount = resolveCloudflareAccount;
|
|
125
|
+
/** `cloudflare:worker:name` → `name`. Names may not contain a colon. */
|
|
126
|
+
function parseKey(key) {
|
|
127
|
+
const [provider, resourceType, ...rest] = key.split(':');
|
|
128
|
+
const identifier = rest.join(':');
|
|
129
|
+
return provider && resourceType && identifier ? { provider, resourceType, identifier } : null;
|
|
130
|
+
}
|
|
131
|
+
function missing(result) {
|
|
132
|
+
return result.status === 404 || result.code === 10007;
|
|
133
|
+
}
|
|
134
|
+
function isoOrUndefined(value) {
|
|
135
|
+
return typeof value === 'string' && !Number.isNaN(Date.parse(value))
|
|
136
|
+
? new Date(value).toISOString()
|
|
137
|
+
: undefined;
|
|
138
|
+
}
|
|
139
|
+
const dash = (accountId, path) => `https://dash.cloudflare.com/${accountId}/${path}`;
|
|
140
|
+
/**
|
|
141
|
+
* One lookup per resource type. Each asks for exactly the declared thing — by
|
|
142
|
+
* the same name or id the config uses — and never lists more of the account
|
|
143
|
+
* than it needs to find it. Every call is a read.
|
|
144
|
+
*/
|
|
145
|
+
const CHECKS = {
|
|
146
|
+
worker: async (name, ctx) => {
|
|
147
|
+
const script = encodeURIComponent(name);
|
|
148
|
+
const base = `/accounts/${ctx.accountId}/workers/scripts/${script}`;
|
|
149
|
+
const state = await ctx.get(`${base}/subdomain`);
|
|
150
|
+
if (!state.ok)
|
|
151
|
+
return missing(state) ? { state: 'not-found' } : { state: 'unknown', reason: state.message };
|
|
152
|
+
// Everything below is best effort: the Worker is already known to exist.
|
|
153
|
+
const liveUrls = [];
|
|
154
|
+
const domains = await ctx.get(`/accounts/${ctx.accountId}/workers/domains/records?service=${script}`);
|
|
155
|
+
if (domains.ok && Array.isArray(domains.result)) {
|
|
156
|
+
for (const domain of domains.result) {
|
|
157
|
+
if (typeof domain?.hostname === 'string' && domain.hostname) {
|
|
158
|
+
liveUrls.push(`https://${domain.hostname}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (state.result?.enabled) {
|
|
163
|
+
const subdomain = await ctx.workersSubdomain();
|
|
164
|
+
if (subdomain)
|
|
165
|
+
liveUrls.push(`https://${name}.${subdomain}.workers.dev`);
|
|
166
|
+
}
|
|
167
|
+
const deployments = await ctx.get(`${base}/deployments`);
|
|
168
|
+
const latest = deployments.ok ? deployments.result?.deployments?.[0] : undefined;
|
|
169
|
+
const version = latest?.versions?.[0]?.version_id;
|
|
170
|
+
const deployedAt = isoOrUndefined(latest?.created_on);
|
|
171
|
+
return {
|
|
172
|
+
state: 'deployed',
|
|
173
|
+
// A custom domain, when there is one, is the address people use.
|
|
174
|
+
...(liveUrls.length > 0 ? { liveUrls } : {}),
|
|
175
|
+
consoleUrl: dash(ctx.accountId, `workers/services/view/${script}/production`),
|
|
176
|
+
...(typeof version === 'string' ? { version } : {}),
|
|
177
|
+
...(deployedAt ? { deployedAt } : {}),
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
r2_bucket: async (name, ctx) => {
|
|
181
|
+
const bucket = encodeURIComponent(name);
|
|
182
|
+
const found = await ctx.get(`/accounts/${ctx.accountId}/r2/buckets/${bucket}`);
|
|
183
|
+
if (!found.ok)
|
|
184
|
+
return missing(found) ? { state: 'not-found' } : { state: 'unknown', reason: found.message };
|
|
185
|
+
return {
|
|
186
|
+
state: 'deployed',
|
|
187
|
+
consoleUrl: dash(ctx.accountId, `r2/default/buckets/${bucket}`),
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
d1_database: async (name, ctx) => {
|
|
191
|
+
// The endpoint accepts a database name as well as its id.
|
|
192
|
+
const found = await ctx.get(`/accounts/${ctx.accountId}/d1/database/${encodeURIComponent(name)}`);
|
|
193
|
+
if (!found.ok)
|
|
194
|
+
return missing(found) ? { state: 'not-found' } : { state: 'unknown', reason: found.message };
|
|
195
|
+
const uuid = typeof found.result?.uuid === 'string' ? found.result.uuid : undefined;
|
|
196
|
+
return {
|
|
197
|
+
state: 'deployed',
|
|
198
|
+
...(uuid ? { resourceId: uuid, consoleUrl: dash(ctx.accountId, `workers/d1/databases/${uuid}`) } : {}),
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
kv_namespace: async (id, ctx) => {
|
|
202
|
+
const found = await ctx.get(`/accounts/${ctx.accountId}/storage/kv/namespaces/${encodeURIComponent(id)}`);
|
|
203
|
+
if (!found.ok)
|
|
204
|
+
return missing(found) ? { state: 'not-found' } : { state: 'unknown', reason: found.message };
|
|
205
|
+
return {
|
|
206
|
+
state: 'deployed',
|
|
207
|
+
resourceId: id,
|
|
208
|
+
consoleUrl: dash(ctx.accountId, `workers/kv/namespaces/${encodeURIComponent(id)}`),
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
queue: async (name, ctx) => {
|
|
212
|
+
const listed = await ctx.get(`/accounts/${ctx.accountId}/queues?name=${encodeURIComponent(name)}`);
|
|
213
|
+
if (!listed.ok)
|
|
214
|
+
return { state: 'unknown', reason: listed.message };
|
|
215
|
+
if (!Array.isArray(listed.result))
|
|
216
|
+
return { state: 'unknown', reason: 'unexpected answer for queues' };
|
|
217
|
+
// The filter may be a prefix match; only an exact name counts.
|
|
218
|
+
const queue = listed.result.find((q) => q?.queue_name === name);
|
|
219
|
+
if (!queue)
|
|
220
|
+
return { state: 'not-found' };
|
|
221
|
+
return {
|
|
222
|
+
state: 'deployed',
|
|
223
|
+
...(typeof queue.queue_id === 'string' ? { resourceId: queue.queue_id } : {}),
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
container: async (name, ctx) => {
|
|
227
|
+
const listed = await ctx.get(`/accounts/${ctx.accountId}/containers/applications?name=${encodeURIComponent(name)}`);
|
|
228
|
+
if (!listed.ok)
|
|
229
|
+
return { state: 'unknown', reason: listed.message };
|
|
230
|
+
if (!Array.isArray(listed.result)) {
|
|
231
|
+
return { state: 'unknown', reason: 'unexpected answer for container applications' };
|
|
232
|
+
}
|
|
233
|
+
const app = listed.result.find((a) => a?.name === name);
|
|
234
|
+
if (!app)
|
|
235
|
+
return { state: 'not-found' };
|
|
236
|
+
return {
|
|
237
|
+
state: 'deployed',
|
|
238
|
+
...(typeof app.id === 'string' ? { resourceId: app.id } : {}),
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
/** Cloudflare resource types a check can look at. */
|
|
243
|
+
exports.CLOUDFLARE_OBSERVED_TYPES = Object.keys(CHECKS);
|
|
244
|
+
/**
|
|
245
|
+
* Look at the named Cloudflare resources and say what was seen.
|
|
246
|
+
*
|
|
247
|
+
* Three outcomes per resource, kept apart on purpose:
|
|
248
|
+
* - it is there → `deployed`, with whatever address and dashboard page it has;
|
|
249
|
+
* - Cloudflare says it does not exist → `not-found`;
|
|
250
|
+
* - the question could not be asked (auth, network) → `unknown`.
|
|
251
|
+
*
|
|
252
|
+
* Failures are per resource: a token that cannot read R2 still gets the
|
|
253
|
+
* Workers checked, and the R2 failure is reported in `failure`. Keys for other
|
|
254
|
+
* providers are ignored.
|
|
255
|
+
*/
|
|
256
|
+
async function observeCloudflare(resourceKeys, access, deps = {}) {
|
|
257
|
+
const doFetch = deps.fetch ?? fetch;
|
|
258
|
+
const now = deps.now ?? (() => new Date());
|
|
259
|
+
const { token, accountId } = access;
|
|
260
|
+
const skipped = [];
|
|
261
|
+
const targets = [];
|
|
262
|
+
for (const key of new Set(resourceKeys)) {
|
|
263
|
+
const parsed = parseKey(key);
|
|
264
|
+
if (!parsed || parsed.provider !== 'cloudflare')
|
|
265
|
+
continue;
|
|
266
|
+
if (CHECKS[parsed.resourceType])
|
|
267
|
+
targets.push({ key, ...parsed });
|
|
268
|
+
else
|
|
269
|
+
skipped.push({ resourceKey: key, reason: `${parsed.resourceType} is not checked yet` });
|
|
270
|
+
}
|
|
271
|
+
const observedAt = now().toISOString();
|
|
272
|
+
const source = 'cloudflare-api';
|
|
273
|
+
let subdomain;
|
|
274
|
+
const ctx = {
|
|
275
|
+
accountId,
|
|
276
|
+
get: (path) => cloudflareGet(path, token, doFetch),
|
|
277
|
+
workersSubdomain: () => {
|
|
278
|
+
subdomain ?? (subdomain = cloudflareGet(`/accounts/${accountId}/workers/subdomain`, token, doFetch).then((sub) => sub.ok && typeof sub.result?.subdomain === 'string' ? sub.result.subdomain : undefined));
|
|
279
|
+
return subdomain;
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
const observations = [];
|
|
283
|
+
const failures = new Set();
|
|
284
|
+
for (const { key, resourceType, identifier } of targets) {
|
|
285
|
+
let seen;
|
|
286
|
+
try {
|
|
287
|
+
seen = await CHECKS[resourceType](identifier, ctx);
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
seen = { state: 'unknown', reason: `could not check ${resourceType}` };
|
|
291
|
+
}
|
|
292
|
+
if (seen.state === 'unknown') {
|
|
293
|
+
failures.add(`${resourceType.replace(/_/g, ' ')}: ${seen.reason}`);
|
|
294
|
+
observations.push({ resourceKey: key, status: 'unknown', observedAt, source });
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (seen.state === 'not-found') {
|
|
298
|
+
observations.push({ resourceKey: key, status: 'not-found', observedAt, source });
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const { state: _state, ...facts } = seen;
|
|
302
|
+
observations.push({ resourceKey: key, status: 'deployed', ...facts, observedAt, source });
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
observations,
|
|
306
|
+
skipped,
|
|
307
|
+
...(failures.size > 0 ? { failure: [...failures].join('; ') } : {}),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
exports.observeCloudflare = observeCloudflare;
|
|
311
|
+
/**
|
|
312
|
+
* Drop `unknown` observations for resources something is already known about.
|
|
313
|
+
* A failed check must not erase what was known: `unknown` is only worth
|
|
314
|
+
* keeping when it is the first thing said about a resource.
|
|
315
|
+
*/
|
|
316
|
+
function withoutUnknownOverwrites(observations, alreadyKnown) {
|
|
317
|
+
return observations.filter((observation) => observation.status !== 'unknown' || !alreadyKnown.has(observation.resourceKey));
|
|
318
|
+
}
|
|
319
|
+
exports.withoutUnknownOverwrites = withoutUnknownOverwrites;
|
|
320
|
+
/**
|
|
321
|
+
* Read the answer of `wrangler auth token --json` — the credential of whoever
|
|
322
|
+
* is logged in to wrangler on this machine, refreshed by wrangler itself.
|
|
323
|
+
*
|
|
324
|
+
* Only a Bearer credential is usable here: an OAuth login or an API token. A
|
|
325
|
+
* global API key (key + email) is not, and reads as null, as does anything
|
|
326
|
+
* that is not wrangler's JSON.
|
|
327
|
+
*/
|
|
328
|
+
function parseWranglerAuthToken(stdout) {
|
|
329
|
+
let parsed;
|
|
330
|
+
try {
|
|
331
|
+
parsed = JSON.parse(stdout);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
if (!isRecord(parsed))
|
|
337
|
+
return null;
|
|
338
|
+
const { type, token } = parsed;
|
|
339
|
+
if (type !== 'oauth' && type !== 'api_token')
|
|
340
|
+
return null;
|
|
341
|
+
// A header value: refuse anything that could not have been a token.
|
|
342
|
+
if (typeof token !== 'string' || !/^[\x21-\x7e]{20,4096}$/.test(token))
|
|
343
|
+
return null;
|
|
344
|
+
return { token, type };
|
|
345
|
+
}
|
|
346
|
+
exports.parseWranglerAuthToken = parseWranglerAuthToken;
|
|
347
|
+
//# sourceMappingURL=observe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/infra/observe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAIH,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAC9D,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAe1C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAMD;;;;GAIG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAY,EACZ,KAAa,EACb,OAAqB;IAErB,IAAI,QAAkB,CAAC;IACvB,IAAI;QACF,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,cAAc,GAAG,IAAI,EAAE,EAAE;YACnD,OAAO,EAAE,EAAE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
* commit. No credentials, always available, verifiable like source.
|
|
9
9
|
* - **Deployed** ({@link InfraDeploymentObservation}) is an observation of
|
|
10
10
|
* the live account. It needs credentials, carries a timestamp, and goes
|
|
11
|
-
* stale.
|
|
12
|
-
* only has to produce this shape.
|
|
11
|
+
* stale. `./observe` produces them from a credential its caller supplies;
|
|
12
|
+
* any other tooling only has to produce this shape.
|
|
13
13
|
*
|
|
14
|
-
* Everything in this folder is
|
|
15
|
-
*
|
|
14
|
+
* Everything in this folder is browser-safe: extractors take text or parsed
|
|
15
|
+
* JSON, never a path, and the checks reach the network only through `fetch`.
|
|
16
16
|
*/
|
|
17
17
|
/** The tool whose file declared a resource. */
|
|
18
18
|
export type InfraTool = 'wrangler' | 'terraform';
|
package/dist/infra/types.js
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* commit. No credentials, always available, verifiable like source.
|
|
10
10
|
* - **Deployed** ({@link InfraDeploymentObservation}) is an observation of
|
|
11
11
|
* the live account. It needs credentials, carries a timestamp, and goes
|
|
12
|
-
* stale.
|
|
13
|
-
* only has to produce this shape.
|
|
12
|
+
* stale. `./observe` produces them from a credential its caller supplies;
|
|
13
|
+
* any other tooling only has to produce this shape.
|
|
14
14
|
*
|
|
15
|
-
* Everything in this folder is
|
|
16
|
-
*
|
|
15
|
+
* Everything in this folder is browser-safe: extractors take text or parsed
|
|
16
|
+
* JSON, never a path, and the checks reach the network only through `fetch`.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.mergeInfraManifests = exports.infraResourceKey = void 0;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,8 +24,9 @@ export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/top
|
|
|
24
24
|
export { toSharedTopic } from './storage/topic-share';
|
|
25
25
|
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
|
|
26
26
|
|
|
27
|
-
// Infrastructure-as-code read side: what wrangler / terraform declare,
|
|
28
|
-
// shape a live-deployment observation takes
|
|
27
|
+
// Infrastructure-as-code read side: what wrangler / terraform declare, the
|
|
28
|
+
// shape a live-deployment observation takes, and the checks that produce one
|
|
29
|
+
// from a credential the caller supplies. Browser-safe — no Node built-ins.
|
|
29
30
|
export * from './infra';
|
|
30
31
|
|
|
31
32
|
// Cross-field validation (the rules the JSON Schema can't express). Structural
|
package/src/infra/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Infrastructure-as-code read side.
|
|
2
|
+
* Infrastructure-as-code read side. Browser-safe. Everything is pure except
|
|
3
|
+
* `./observe`, which asks a provider's API what is running, with a credential
|
|
4
|
+
* the caller supplies.
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
export { infraResourceKey, mergeInfraManifests } from './types';
|
|
@@ -19,3 +21,16 @@ export { extractTerraformManifest, terraformStateObservations } from './terrafor
|
|
|
19
21
|
export type { ExtractTerraformOptions } from './terraform';
|
|
20
22
|
export { infraContainerId, infraDeploymentRef, infraToC4 } from './c4';
|
|
21
23
|
export type { InfraC4Container, InfraC4Deployment, InfraC4Edge } from './c4';
|
|
24
|
+
export {
|
|
25
|
+
CLOUDFLARE_OBSERVED_TYPES,
|
|
26
|
+
observeCloudflare,
|
|
27
|
+
parseWranglerAuthToken,
|
|
28
|
+
resolveCloudflareAccount,
|
|
29
|
+
withoutUnknownOverwrites,
|
|
30
|
+
} from './observe';
|
|
31
|
+
export type {
|
|
32
|
+
CloudflareAccess,
|
|
33
|
+
CloudflareAccountResult,
|
|
34
|
+
InfraObserveDeps,
|
|
35
|
+
InfraObserveResult,
|
|
36
|
+
} from './observe';
|