@treeseed/sdk 0.13.0-rc.100 → 0.13.0-rc.101

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-08T18:31:30.621Z"}
1
+ {"completedAt":"2026-09-09T04:49:43.782Z"}
@@ -703,9 +703,6 @@ export declare const capabilityDemandSchema: z.ZodObject<{
703
703
  demandDigest: z.ZodString;
704
704
  }, "strict", z.ZodTypeAny, {
705
705
  schemaVersion: "treeseed.capability-demand/v1";
706
- permissionClasses: string[];
707
- contextModes: string[];
708
- ontologyGeneration: number;
709
706
  requirements: {
710
707
  configuration: Record<string, {
711
708
  requirement: "required" | "preferred";
@@ -717,6 +714,9 @@ export declare const capabilityDemandSchema: z.ZodObject<{
717
714
  alternativeGroup: string | null;
718
715
  requiredFeatures: string[];
719
716
  }[];
717
+ permissionClasses: string[];
718
+ contextModes: string[];
719
+ ontologyGeneration: number;
720
720
  resolved: {
721
721
  id: string;
722
722
  version: string;
@@ -737,9 +737,6 @@ export declare const capabilityDemandSchema: z.ZodObject<{
737
737
  demandDigest: string;
738
738
  }, {
739
739
  schemaVersion: "treeseed.capability-demand/v1";
740
- permissionClasses: string[];
741
- contextModes: string[];
742
- ontologyGeneration: number;
743
740
  requirements: {
744
741
  requirement: "required" | "preferred";
745
742
  capabilityId: string;
@@ -751,6 +748,9 @@ export declare const capabilityDemandSchema: z.ZodObject<{
751
748
  alternativeGroup?: string | null | undefined;
752
749
  requiredFeatures?: string[] | undefined;
753
750
  }[];
751
+ permissionClasses: string[];
752
+ contextModes: string[];
753
+ ontologyGeneration: number;
754
754
  resolved: {
755
755
  id: string;
756
756
  version: string;
@@ -1,4 +1,5 @@
1
1
  export * from './schemas.js';
2
+ export * from './postgres/contracts.js';
2
3
  export * from './canonical.js';
3
4
  export * from './catalog.js';
4
5
  export * from './topology.js';
@@ -1,4 +1,5 @@
1
1
  export * from "./schemas.js";
2
+ export * from "./postgres/contracts.js";
2
3
  export * from "./canonical.js";
3
4
  export * from "./catalog.js";
4
5
  export * from "./topology.js";
@@ -0,0 +1,399 @@
1
+ import { z } from 'zod';
2
+ /** Package-owned requirements, not an instruction to start another server. */
3
+ export declare const postgresRequirementSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ componentId: z.ZodString;
6
+ enabled: z.ZodBoolean;
7
+ supportedMajors: z.ZodEffects<z.ZodArray<z.ZodNumber, "atleastone">, [number, ...number[]], [number, ...number[]]>;
8
+ extensions: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
9
+ runtimeConnectionLimit: z.ZodNumber;
10
+ }, "strict", z.ZodTypeAny, {
11
+ id: string;
12
+ componentId: string;
13
+ enabled: boolean;
14
+ supportedMajors: [number, ...number[]];
15
+ extensions: string[];
16
+ runtimeConnectionLimit: number;
17
+ }, {
18
+ id: string;
19
+ componentId: string;
20
+ enabled: boolean;
21
+ supportedMajors: [number, ...number[]];
22
+ extensions: string[];
23
+ runtimeConnectionLimit: number;
24
+ }>;
25
+ /** Deployment owns the selected server and its bootstrap authority. No credentials here. */
26
+ export declare const postgresServerSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ installationId: z.ZodString;
29
+ environment: z.ZodEnum<["staging", "production"]>;
30
+ mode: z.ZodEnum<["shared", "dedicated", "external"]>;
31
+ hostname: z.ZodString;
32
+ port: z.ZodNumber;
33
+ major: z.ZodNumber;
34
+ extensions: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
35
+ tls: z.ZodObject<{
36
+ mode: z.ZodLiteral<"verify-full">;
37
+ trustReference: z.ZodString;
38
+ }, "strict", z.ZodTypeAny, {
39
+ mode: "verify-full";
40
+ trustReference: string;
41
+ }, {
42
+ mode: "verify-full";
43
+ trustReference: string;
44
+ }>;
45
+ }, "strict", z.ZodTypeAny, {
46
+ id: string;
47
+ mode: "external" | "shared" | "dedicated";
48
+ environment: "production" | "staging";
49
+ port: number;
50
+ major: number;
51
+ tls: {
52
+ mode: "verify-full";
53
+ trustReference: string;
54
+ };
55
+ extensions: string[];
56
+ installationId: string;
57
+ hostname: string;
58
+ }, {
59
+ id: string;
60
+ mode: "external" | "shared" | "dedicated";
61
+ environment: "production" | "staging";
62
+ port: number;
63
+ major: number;
64
+ tls: {
65
+ mode: "verify-full";
66
+ trustReference: string;
67
+ };
68
+ extensions: string[];
69
+ installationId: string;
70
+ hostname: string;
71
+ }>;
72
+ export declare const postgresAllocationSchema: z.ZodEffects<z.ZodObject<{
73
+ requirementId: z.ZodString;
74
+ serverId: z.ZodString;
75
+ database: z.ZodEffects<z.ZodString, string, string>;
76
+ ownerRole: z.ZodEffects<z.ZodString, string, string>;
77
+ migrationRole: z.ZodEffects<z.ZodString, string, string>;
78
+ runtimeRole: z.ZodEffects<z.ZodString, string, string>;
79
+ migrationCredentialReference: z.ZodString;
80
+ runtimeCredentialReference: z.ZodString;
81
+ onDisable: z.ZodLiteral<"preserve">;
82
+ }, "strict", z.ZodTypeAny, {
83
+ requirementId: string;
84
+ serverId: string;
85
+ database: string;
86
+ ownerRole: string;
87
+ migrationRole: string;
88
+ runtimeRole: string;
89
+ migrationCredentialReference: string;
90
+ runtimeCredentialReference: string;
91
+ onDisable: "preserve";
92
+ }, {
93
+ requirementId: string;
94
+ serverId: string;
95
+ database: string;
96
+ ownerRole: string;
97
+ migrationRole: string;
98
+ runtimeRole: string;
99
+ migrationCredentialReference: string;
100
+ runtimeCredentialReference: string;
101
+ onDisable: "preserve";
102
+ }>, {
103
+ requirementId: string;
104
+ serverId: string;
105
+ database: string;
106
+ ownerRole: string;
107
+ migrationRole: string;
108
+ runtimeRole: string;
109
+ migrationCredentialReference: string;
110
+ runtimeCredentialReference: string;
111
+ onDisable: "preserve";
112
+ }, {
113
+ requirementId: string;
114
+ serverId: string;
115
+ database: string;
116
+ ownerRole: string;
117
+ migrationRole: string;
118
+ runtimeRole: string;
119
+ migrationCredentialReference: string;
120
+ runtimeCredentialReference: string;
121
+ onDisable: "preserve";
122
+ }>;
123
+ /** One installation/environment. Explicit allocations may select dedicated servers. */
124
+ export declare const postgresTopologySchema: z.ZodEffects<z.ZodObject<{
125
+ schemaVersion: z.ZodLiteral<"treeseed.postgres-topology/v1">;
126
+ installationId: z.ZodString;
127
+ environment: z.ZodEnum<["staging", "production"]>;
128
+ servers: z.ZodArray<z.ZodObject<{
129
+ id: z.ZodString;
130
+ installationId: z.ZodString;
131
+ environment: z.ZodEnum<["staging", "production"]>;
132
+ mode: z.ZodEnum<["shared", "dedicated", "external"]>;
133
+ hostname: z.ZodString;
134
+ port: z.ZodNumber;
135
+ major: z.ZodNumber;
136
+ extensions: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
137
+ tls: z.ZodObject<{
138
+ mode: z.ZodLiteral<"verify-full">;
139
+ trustReference: z.ZodString;
140
+ }, "strict", z.ZodTypeAny, {
141
+ mode: "verify-full";
142
+ trustReference: string;
143
+ }, {
144
+ mode: "verify-full";
145
+ trustReference: string;
146
+ }>;
147
+ }, "strict", z.ZodTypeAny, {
148
+ id: string;
149
+ mode: "external" | "shared" | "dedicated";
150
+ environment: "production" | "staging";
151
+ port: number;
152
+ major: number;
153
+ tls: {
154
+ mode: "verify-full";
155
+ trustReference: string;
156
+ };
157
+ extensions: string[];
158
+ installationId: string;
159
+ hostname: string;
160
+ }, {
161
+ id: string;
162
+ mode: "external" | "shared" | "dedicated";
163
+ environment: "production" | "staging";
164
+ port: number;
165
+ major: number;
166
+ tls: {
167
+ mode: "verify-full";
168
+ trustReference: string;
169
+ };
170
+ extensions: string[];
171
+ installationId: string;
172
+ hostname: string;
173
+ }>, "many">;
174
+ requirements: z.ZodArray<z.ZodObject<{
175
+ id: z.ZodString;
176
+ componentId: z.ZodString;
177
+ enabled: z.ZodBoolean;
178
+ supportedMajors: z.ZodEffects<z.ZodArray<z.ZodNumber, "atleastone">, [number, ...number[]], [number, ...number[]]>;
179
+ extensions: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, string[], string[]>;
180
+ runtimeConnectionLimit: z.ZodNumber;
181
+ }, "strict", z.ZodTypeAny, {
182
+ id: string;
183
+ componentId: string;
184
+ enabled: boolean;
185
+ supportedMajors: [number, ...number[]];
186
+ extensions: string[];
187
+ runtimeConnectionLimit: number;
188
+ }, {
189
+ id: string;
190
+ componentId: string;
191
+ enabled: boolean;
192
+ supportedMajors: [number, ...number[]];
193
+ extensions: string[];
194
+ runtimeConnectionLimit: number;
195
+ }>, "many">;
196
+ allocations: z.ZodArray<z.ZodEffects<z.ZodObject<{
197
+ requirementId: z.ZodString;
198
+ serverId: z.ZodString;
199
+ database: z.ZodEffects<z.ZodString, string, string>;
200
+ ownerRole: z.ZodEffects<z.ZodString, string, string>;
201
+ migrationRole: z.ZodEffects<z.ZodString, string, string>;
202
+ runtimeRole: z.ZodEffects<z.ZodString, string, string>;
203
+ migrationCredentialReference: z.ZodString;
204
+ runtimeCredentialReference: z.ZodString;
205
+ onDisable: z.ZodLiteral<"preserve">;
206
+ }, "strict", z.ZodTypeAny, {
207
+ requirementId: string;
208
+ serverId: string;
209
+ database: string;
210
+ ownerRole: string;
211
+ migrationRole: string;
212
+ runtimeRole: string;
213
+ migrationCredentialReference: string;
214
+ runtimeCredentialReference: string;
215
+ onDisable: "preserve";
216
+ }, {
217
+ requirementId: string;
218
+ serverId: string;
219
+ database: string;
220
+ ownerRole: string;
221
+ migrationRole: string;
222
+ runtimeRole: string;
223
+ migrationCredentialReference: string;
224
+ runtimeCredentialReference: string;
225
+ onDisable: "preserve";
226
+ }>, {
227
+ requirementId: string;
228
+ serverId: string;
229
+ database: string;
230
+ ownerRole: string;
231
+ migrationRole: string;
232
+ runtimeRole: string;
233
+ migrationCredentialReference: string;
234
+ runtimeCredentialReference: string;
235
+ onDisable: "preserve";
236
+ }, {
237
+ requirementId: string;
238
+ serverId: string;
239
+ database: string;
240
+ ownerRole: string;
241
+ migrationRole: string;
242
+ runtimeRole: string;
243
+ migrationCredentialReference: string;
244
+ runtimeCredentialReference: string;
245
+ onDisable: "preserve";
246
+ }>, "many">;
247
+ }, "strict", z.ZodTypeAny, {
248
+ schemaVersion: "treeseed.postgres-topology/v1";
249
+ environment: "production" | "staging";
250
+ installationId: string;
251
+ servers: {
252
+ id: string;
253
+ mode: "external" | "shared" | "dedicated";
254
+ environment: "production" | "staging";
255
+ port: number;
256
+ major: number;
257
+ tls: {
258
+ mode: "verify-full";
259
+ trustReference: string;
260
+ };
261
+ extensions: string[];
262
+ installationId: string;
263
+ hostname: string;
264
+ }[];
265
+ requirements: {
266
+ id: string;
267
+ componentId: string;
268
+ enabled: boolean;
269
+ supportedMajors: [number, ...number[]];
270
+ extensions: string[];
271
+ runtimeConnectionLimit: number;
272
+ }[];
273
+ allocations: {
274
+ requirementId: string;
275
+ serverId: string;
276
+ database: string;
277
+ ownerRole: string;
278
+ migrationRole: string;
279
+ runtimeRole: string;
280
+ migrationCredentialReference: string;
281
+ runtimeCredentialReference: string;
282
+ onDisable: "preserve";
283
+ }[];
284
+ }, {
285
+ schemaVersion: "treeseed.postgres-topology/v1";
286
+ environment: "production" | "staging";
287
+ installationId: string;
288
+ servers: {
289
+ id: string;
290
+ mode: "external" | "shared" | "dedicated";
291
+ environment: "production" | "staging";
292
+ port: number;
293
+ major: number;
294
+ tls: {
295
+ mode: "verify-full";
296
+ trustReference: string;
297
+ };
298
+ extensions: string[];
299
+ installationId: string;
300
+ hostname: string;
301
+ }[];
302
+ requirements: {
303
+ id: string;
304
+ componentId: string;
305
+ enabled: boolean;
306
+ supportedMajors: [number, ...number[]];
307
+ extensions: string[];
308
+ runtimeConnectionLimit: number;
309
+ }[];
310
+ allocations: {
311
+ requirementId: string;
312
+ serverId: string;
313
+ database: string;
314
+ ownerRole: string;
315
+ migrationRole: string;
316
+ runtimeRole: string;
317
+ migrationCredentialReference: string;
318
+ runtimeCredentialReference: string;
319
+ onDisable: "preserve";
320
+ }[];
321
+ }>, {
322
+ schemaVersion: "treeseed.postgres-topology/v1";
323
+ environment: "production" | "staging";
324
+ installationId: string;
325
+ servers: {
326
+ id: string;
327
+ mode: "external" | "shared" | "dedicated";
328
+ environment: "production" | "staging";
329
+ port: number;
330
+ major: number;
331
+ tls: {
332
+ mode: "verify-full";
333
+ trustReference: string;
334
+ };
335
+ extensions: string[];
336
+ installationId: string;
337
+ hostname: string;
338
+ }[];
339
+ requirements: {
340
+ id: string;
341
+ componentId: string;
342
+ enabled: boolean;
343
+ supportedMajors: [number, ...number[]];
344
+ extensions: string[];
345
+ runtimeConnectionLimit: number;
346
+ }[];
347
+ allocations: {
348
+ requirementId: string;
349
+ serverId: string;
350
+ database: string;
351
+ ownerRole: string;
352
+ migrationRole: string;
353
+ runtimeRole: string;
354
+ migrationCredentialReference: string;
355
+ runtimeCredentialReference: string;
356
+ onDisable: "preserve";
357
+ }[];
358
+ }, {
359
+ schemaVersion: "treeseed.postgres-topology/v1";
360
+ environment: "production" | "staging";
361
+ installationId: string;
362
+ servers: {
363
+ id: string;
364
+ mode: "external" | "shared" | "dedicated";
365
+ environment: "production" | "staging";
366
+ port: number;
367
+ major: number;
368
+ tls: {
369
+ mode: "verify-full";
370
+ trustReference: string;
371
+ };
372
+ extensions: string[];
373
+ installationId: string;
374
+ hostname: string;
375
+ }[];
376
+ requirements: {
377
+ id: string;
378
+ componentId: string;
379
+ enabled: boolean;
380
+ supportedMajors: [number, ...number[]];
381
+ extensions: string[];
382
+ runtimeConnectionLimit: number;
383
+ }[];
384
+ allocations: {
385
+ requirementId: string;
386
+ serverId: string;
387
+ database: string;
388
+ ownerRole: string;
389
+ migrationRole: string;
390
+ runtimeRole: string;
391
+ migrationCredentialReference: string;
392
+ runtimeCredentialReference: string;
393
+ onDisable: "preserve";
394
+ }[];
395
+ }>;
396
+ export type PostgresRequirement = z.infer<typeof postgresRequirementSchema>;
397
+ export type PostgresServer = z.infer<typeof postgresServerSchema>;
398
+ export type PostgresAllocation = z.infer<typeof postgresAllocationSchema>;
399
+ export type PostgresTopology = z.infer<typeof postgresTopologySchema>;
@@ -0,0 +1,77 @@
1
+ import { z } from "zod";
2
+ const id = z.string().regex(/^[a-z][a-z0-9-]{0,62}$/u);
3
+ const sqlName = z.string().regex(/^[a-z][a-z0-9_]{0,62}$/u).refine((value) => value !== "postgres" && !value.startsWith("pg_"), "Application identifiers must not use PostgreSQL administrative names.");
4
+ const unique = (values) => new Set(values).size === values.length;
5
+ const postgresRequirementSchema = z.object({
6
+ id,
7
+ componentId: id,
8
+ enabled: z.boolean(),
9
+ supportedMajors: z.array(z.number().int().min(14).max(99)).nonempty().refine(unique),
10
+ extensions: z.array(sqlName).refine(unique),
11
+ runtimeConnectionLimit: z.number().int().min(1).max(1e3)
12
+ }).strict();
13
+ const postgresServerSchema = z.object({
14
+ id,
15
+ installationId: id,
16
+ environment: z.enum(["staging", "production"]),
17
+ mode: z.enum(["shared", "dedicated", "external"]),
18
+ hostname: z.string().max(253).regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/u),
19
+ port: z.number().int().min(1).max(65535),
20
+ major: z.number().int().min(14).max(99),
21
+ extensions: z.array(sqlName).refine(unique),
22
+ tls: z.object({ mode: z.literal("verify-full"), trustReference: id }).strict()
23
+ }).strict();
24
+ const postgresAllocationSchema = z.object({
25
+ requirementId: id,
26
+ serverId: id,
27
+ database: sqlName,
28
+ ownerRole: sqlName,
29
+ migrationRole: sqlName,
30
+ runtimeRole: sqlName,
31
+ migrationCredentialReference: id,
32
+ runtimeCredentialReference: id,
33
+ onDisable: z.literal("preserve")
34
+ }).strict().superRefine((value, context) => {
35
+ if (!unique([value.ownerRole, value.migrationRole, value.runtimeRole])) context.addIssue({ code: z.ZodIssueCode.custom, message: "Owner, migration and runtime roles must be distinct." });
36
+ if (value.migrationCredentialReference === value.runtimeCredentialReference) context.addIssue({ code: z.ZodIssueCode.custom, message: "Migration and runtime credentials must be distinct." });
37
+ });
38
+ const postgresTopologySchema = z.object({
39
+ schemaVersion: z.literal("treeseed.postgres-topology/v1"),
40
+ installationId: id,
41
+ environment: z.enum(["staging", "production"]),
42
+ servers: z.array(postgresServerSchema),
43
+ requirements: z.array(postgresRequirementSchema),
44
+ allocations: z.array(postgresAllocationSchema)
45
+ }).strict().superRefine((value, context) => {
46
+ const fail = (message) => context.addIssue({ code: z.ZodIssueCode.custom, message });
47
+ 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.");
48
+ if (value.servers.filter((server) => server.mode === "shared").length > 1) fail("An environment has at most one default shared server.");
49
+ if (value.servers.some((server) => server.installationId !== value.installationId || server.environment !== value.environment)) fail("Servers must belong to this installation and environment.");
50
+ const databases = /* @__PURE__ */ new Set(), roles = /* @__PURE__ */ new Set();
51
+ for (const allocation of value.allocations) {
52
+ const server = value.servers.find((entry) => entry.id === allocation.serverId);
53
+ const requirement = value.requirements.find((entry) => entry.id === allocation.requirementId);
54
+ if (!server || !requirement) {
55
+ fail("Allocation references an unknown server or requirement.");
56
+ continue;
57
+ }
58
+ if (!requirement.supportedMajors.includes(server.major) || requirement.extensions.some((extension) => !server.extensions.includes(extension))) fail("Server does not satisfy package version/extension requirements.");
59
+ const databaseKey = `${server.id}:${allocation.database}`;
60
+ if (databases.has(databaseKey)) fail("Applications must not share an allocated database.");
61
+ databases.add(databaseKey);
62
+ for (const role of [allocation.ownerRole, allocation.migrationRole, allocation.runtimeRole]) {
63
+ const key = `${server.id}:${role}`;
64
+ if (roles.has(key)) fail("Applications must not share database roles.");
65
+ roles.add(key);
66
+ }
67
+ }
68
+ for (const requirement of value.requirements) {
69
+ if (requirement.enabled && !value.allocations.some((allocation) => allocation.requirementId === requirement.id)) fail("Enabled database requirements need explicit allocations.");
70
+ }
71
+ });
72
+ export {
73
+ postgresAllocationSchema,
74
+ postgresRequirementSchema,
75
+ postgresServerSchema,
76
+ postgresTopologySchema
77
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.13.0-rc.100",
3
+ "version": "0.13.0-rc.101",
4
4
  "description": "Portable TreeSeed contracts, standards, and typed remote control-plane clients.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {