@treeseed/sdk 0.13.0-rc.102 → 0.13.0-rc.104

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.
@@ -1 +1 @@
1
- {"completedAt":"2026-09-09T05:56:47.945Z"}
1
+ {"completedAt":"2026-09-09T07:10:39.587Z"}
@@ -1,5 +1,6 @@
1
1
  export * from './schemas.js';
2
2
  export * from './postgres/contracts.js';
3
+ export * from './postgres/requirements.js';
3
4
  export * from './canonical.js';
4
5
  export * from './catalog.js';
5
6
  export * from './topology.js';
@@ -1,5 +1,6 @@
1
1
  export * from "./schemas.js";
2
2
  export * from "./postgres/contracts.js";
3
+ export * from "./postgres/requirements.js";
3
4
  export * from "./canonical.js";
4
5
  export * from "./catalog.js";
5
6
  export * from "./topology.js";
@@ -48,7 +48,7 @@ const postgresTopologySchema = z.object({
48
48
  if (!unique(value.servers.map((server) => server.id)) || !unique(value.requirements.map((requirement) => requirement.id)) || !unique(value.allocations.map((allocation) => allocation.requirementId))) fail("Server, requirement and allocation identities must be unique.");
49
49
  if (value.servers.filter((server) => server.mode === "shared").length > 1) fail("An environment has at most one default shared server.");
50
50
  if (value.servers.some((server) => server.installationId !== value.installationId || server.environment !== value.environment)) fail("Servers must belong to this installation and environment.");
51
- const databases = /* @__PURE__ */ new Set(), roles = /* @__PURE__ */ new Set();
51
+ const databases = /* @__PURE__ */ new Set(), roles = /* @__PURE__ */ new Set(), credentials = /* @__PURE__ */ new Set();
52
52
  for (const allocation of value.allocations) {
53
53
  const server = value.servers.find((entry) => entry.id === allocation.serverId);
54
54
  const requirement = value.requirements.find((entry) => entry.id === allocation.requirementId);
@@ -60,6 +60,10 @@ const postgresTopologySchema = z.object({
60
60
  const databaseKey = `${server.id}:${allocation.database}`;
61
61
  if (databases.has(databaseKey)) fail("Applications must not share an allocated database.");
62
62
  databases.add(databaseKey);
63
+ for (const reference of [allocation.migrationCredentialReference, allocation.runtimeCredentialReference]) {
64
+ if (credentials.has(reference)) fail("Applications must not share database credential references.");
65
+ credentials.add(reference);
66
+ }
63
67
  for (const role of [allocation.ownerRole, allocation.migrationRole, allocation.runtimeRole]) {
64
68
  const key = `${server.id}:${role}`;
65
69
  if (roles.has(key)) fail("Applications must not share database roles.");
@@ -0,0 +1,14 @@
1
+ /** Call after artifact authenticity verification, with the complete selected
2
+ * component inventory. Host configuration cannot weaken a package requirement.
3
+ */
4
+ export declare function verifyHostPostgresRequirements(hostInput: unknown, releaseInputs: unknown[]): {
5
+ verified: true;
6
+ requirements: {
7
+ id: string;
8
+ componentId: string;
9
+ enabled: boolean;
10
+ supportedMajors: [number, ...number[]];
11
+ extensions: string[];
12
+ runtimeConnectionLimit: number;
13
+ }[];
14
+ };
@@ -0,0 +1,30 @@
1
+ import { componentReleaseSchema, hostConfigurationSchema } from "../schemas.js";
2
+ import { canonicalDeploymentJson, deploymentDigest } from "../canonical.js";
3
+ function verifyHostPostgresRequirements(hostInput, releaseInputs) {
4
+ const host = hostConfigurationSchema.parse(hostInput);
5
+ const releases = releaseInputs.map((input) => componentReleaseSchema.parse(input));
6
+ if (new Set(releases.map((item) => item.componentId)).size !== releases.length) throw new Error("Duplicate component release inventory");
7
+ if (Object.entries(host.components).some(([id, selection]) => selection.enabled && !releases.some((release) => release.componentId === id))) throw new Error("Selected component release inventory is incomplete");
8
+ const requirements = [];
9
+ for (const release of releases) {
10
+ const selection = host.components[release.componentId];
11
+ if (!selection) continue;
12
+ if (deploymentDigest(release.runtime) !== release.runtimeDigest) throw new Error("Component runtime digest mismatch");
13
+ for (const requirement of release.runtime.postgresRequirements ?? []) requirements.push({
14
+ ...requirement,
15
+ componentId: release.componentId,
16
+ enabled: selection.enabled
17
+ });
18
+ }
19
+ if (new Set(requirements.map((item) => item.id)).size !== requirements.length) throw new Error("Component database requirement identities collide");
20
+ const normalize = (items) => items.map((item) => ({
21
+ ...item,
22
+ supportedMajors: [...item.supportedMajors].sort((a, b) => a - b),
23
+ extensions: [...item.extensions].sort()
24
+ })).sort((a, b) => a.id.localeCompare(b.id));
25
+ if (canonicalDeploymentJson(normalize(requirements)) !== canonicalDeploymentJson(normalize(host.postgres?.requirements ?? []))) throw new Error("Host database requirements differ from selected immutable components");
26
+ return { verified: true, requirements };
27
+ }
28
+ export {
29
+ verifyHostPostgresRequirements
30
+ };