@substrat-run/control-plane-api 0.209.0 → 0.210.0
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/api.d.ts.map +1 -1
- package/dist/api.js +22 -0
- package/dist/api.js.map +1 -1
- package/dist/built-version.d.ts +31 -0
- package/dist/built-version.d.ts.map +1 -0
- package/dist/built-version.js +55 -0
- package/dist/built-version.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The version of a vertical already built from one source revision, if there is one.
|
|
3
|
+
*
|
|
4
|
+
* The studio's Run builds the project's saved revision into a version before it binds that
|
|
5
|
+
* version to a preview slot, and a build is minutes in a fresh container. When the revision is
|
|
6
|
+
* one the platform has already built (the commit prod was released from, or the one the last Run
|
|
7
|
+
* built), that build is redone for nothing. A source build stamps `manifest.build.revision` itself
|
|
8
|
+
* (D-66, the builder's agent), after the project's code ran and from the commit it checked out,
|
|
9
|
+
* so the stored manifest is the authority here. A version's `origin` is not: a snapshot push
|
|
10
|
+
* supplies its own.
|
|
11
|
+
*
|
|
12
|
+
* Bounded on purpose. A manifest is the largest thing the directory holds, so the search reads
|
|
13
|
+
* only the version prod points at, the one it serves, and the newest few. That covers the cases
|
|
14
|
+
* Run meets (an unchanged project, and a Run straight after a release), and a revision built
|
|
15
|
+
* long ago and since pushed past is built again, as it was before this existed.
|
|
16
|
+
*/
|
|
17
|
+
import { z, type PlatformActorId, type VerticalVersion } from '@substrat-run/contracts';
|
|
18
|
+
import type { HostAdmin } from '@substrat-run/kernel';
|
|
19
|
+
/** How many of the newest versions are searched, beside prod's. */
|
|
20
|
+
export declare const BUILT_VERSION_WINDOW = 10;
|
|
21
|
+
/** A git commit, as `manifest.build.revision` stores it. */
|
|
22
|
+
export declare const buildRevision: z.ZodString;
|
|
23
|
+
type Reader = Pick<HostAdmin, 'listChannels' | 'listVersions' | 'getVersion' | 'versionManifest'>;
|
|
24
|
+
/**
|
|
25
|
+
* The newest admissible version of `slug` built from `revision`, among prod's and the newest
|
|
26
|
+
* {@link BUILT_VERSION_WINDOW}; undefined when none is. A rejected version is passed over: it was
|
|
27
|
+
* refused, and a preview of it would show code the vertical's owner turned away.
|
|
28
|
+
*/
|
|
29
|
+
export declare function versionBuiltFrom(admin: Reader, actor: PlatformActorId, slug: string, revision: string, window?: number): Promise<VerticalVersion | undefined>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=built-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-version.d.ts","sourceRoot":"","sources":["../src/built-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,CAAC,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,4DAA4D;AAC5D,eAAO,MAAM,aAAa,aAAqC,CAAC;AAKhE,KAAK,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,GAAG,YAAY,GAAG,iBAAiB,CAAC,CAAC;AAElG;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAA6B,GACpC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAoBtC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The version of a vertical already built from one source revision, if there is one.
|
|
3
|
+
*
|
|
4
|
+
* The studio's Run builds the project's saved revision into a version before it binds that
|
|
5
|
+
* version to a preview slot, and a build is minutes in a fresh container. When the revision is
|
|
6
|
+
* one the platform has already built (the commit prod was released from, or the one the last Run
|
|
7
|
+
* built), that build is redone for nothing. A source build stamps `manifest.build.revision` itself
|
|
8
|
+
* (D-66, the builder's agent), after the project's code ran and from the commit it checked out,
|
|
9
|
+
* so the stored manifest is the authority here. A version's `origin` is not: a snapshot push
|
|
10
|
+
* supplies its own.
|
|
11
|
+
*
|
|
12
|
+
* Bounded on purpose. A manifest is the largest thing the directory holds, so the search reads
|
|
13
|
+
* only the version prod points at, the one it serves, and the newest few. That covers the cases
|
|
14
|
+
* Run meets (an unchanged project, and a Run straight after a release), and a revision built
|
|
15
|
+
* long ago and since pushed past is built again, as it was before this existed.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from '@substrat-run/contracts';
|
|
18
|
+
/** How many of the newest versions are searched, beside prod's. */
|
|
19
|
+
export const BUILT_VERSION_WINDOW = 10;
|
|
20
|
+
/** A git commit, as `manifest.build.revision` stores it. */
|
|
21
|
+
export const buildRevision = z.string().regex(/^[0-9a-f]{40}$/);
|
|
22
|
+
/** The one field the search reads; the rest of a stored manifest is not parsed. */
|
|
23
|
+
const stamped = z.object({ build: z.object({ revision: z.string() }).nullish() });
|
|
24
|
+
/**
|
|
25
|
+
* The newest admissible version of `slug` built from `revision`, among prod's and the newest
|
|
26
|
+
* {@link BUILT_VERSION_WINDOW}; undefined when none is. A rejected version is passed over: it was
|
|
27
|
+
* refused, and a preview of it would show code the vertical's owner turned away.
|
|
28
|
+
*/
|
|
29
|
+
export async function versionBuiltFrom(admin, actor, slug, revision, window = BUILT_VERSION_WINDOW) {
|
|
30
|
+
const prod = (await admin.listChannels(actor, slug)).find((ch) => ch.channel === 'prod');
|
|
31
|
+
const newest = await admin.listVersions(actor, slug, { limit: window, order: 'desc' });
|
|
32
|
+
const pinned = [prod?.servingVersionId, prod?.versionId].filter((id) => !!id);
|
|
33
|
+
// Prod's versions join the newest-first window when they have fallen out of it.
|
|
34
|
+
const candidates = [...newest];
|
|
35
|
+
for (const id of pinned) {
|
|
36
|
+
if (candidates.some((v) => v.id === id))
|
|
37
|
+
continue;
|
|
38
|
+
const found = await admin.getVersion(actor, id, slug);
|
|
39
|
+
if (found)
|
|
40
|
+
candidates.push(found);
|
|
41
|
+
}
|
|
42
|
+
for (const version of candidates) {
|
|
43
|
+
if (version.admission === 'rejected')
|
|
44
|
+
continue;
|
|
45
|
+
const json = await admin.versionManifest(actor, slug, version.id);
|
|
46
|
+
// A cheap refusal first: a manifest that does not hold the commit's text was not built from it.
|
|
47
|
+
if (!json || !json.includes(revision))
|
|
48
|
+
continue;
|
|
49
|
+
const parsed = stamped.safeParse(JSON.parse(json));
|
|
50
|
+
if (parsed.success && parsed.data.build?.revision === revision)
|
|
51
|
+
return version;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=built-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-version.js","sourceRoot":"","sources":["../src/built-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,CAAC,EAA8C,MAAM,yBAAyB,CAAC;AAGxF,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAEhE,mFAAmF;AACnF,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAIlF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,KAAsB,EACtB,IAAY,EACZ,QAAgB,EAChB,MAAM,GAAW,oBAAoB;IAErC,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC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AI,CAAC,CAAC,CAAC;QACnD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;IACjF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/control-plane-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.210.0",
|
|
4
4
|
"description": "HTTP surface over HostAdmin — the audited control-plane transport (control-plane.md §4.5)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"hono": "^4.13.13",
|
|
30
|
-
"@substrat-run/contracts": "^0.
|
|
31
|
-
"@substrat-run/
|
|
32
|
-
"@substrat-run/
|
|
30
|
+
"@substrat-run/contracts": "^0.210.0",
|
|
31
|
+
"@substrat-run/kernel": "^0.210.0",
|
|
32
|
+
"@substrat-run/control-plane-client": "^0.9.10",
|
|
33
33
|
"@substrat-run/psl": "^0.2.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"tsx": "^4.19.0",
|
|
44
44
|
"typescript": "^7.0.0",
|
|
45
45
|
"vitest": "^5.0.5",
|
|
46
|
-
"@substrat-run/
|
|
47
|
-
"@substrat-run/
|
|
48
|
-
"@substrat-run/connector-
|
|
49
|
-
"@substrat-run/
|
|
50
|
-
"@substrat-run/
|
|
46
|
+
"@substrat-run/connector-fortnox": "^0.9.2",
|
|
47
|
+
"@substrat-run/adapter-sqlite": "^0.210.0",
|
|
48
|
+
"@substrat-run/connector-woocommerce": "^0.0.16",
|
|
49
|
+
"@substrat-run/vertical-host": "^0.210.0",
|
|
50
|
+
"@substrat-run/connector-planima": "^0.2.107"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|