@treeseed/sdk 0.4.8 → 0.4.10
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 +1 -1
- package/dist/control-plane-client.d.ts +45 -0
- package/dist/control-plane-client.js +229 -0
- package/dist/control-plane.d.ts +94 -0
- package/dist/control-plane.js +125 -0
- package/dist/d1-store.d.ts +56 -1
- package/dist/d1-store.js +132 -0
- package/dist/dispatch.d.ts +4 -0
- package/dist/dispatch.js +180 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +94 -4
- package/dist/operations/services/config-runtime.d.ts +10 -0
- package/dist/operations/services/config-runtime.js +62 -4
- package/dist/operations/services/deploy.d.ts +95 -3
- package/dist/operations/services/deploy.js +351 -10
- package/dist/operations/services/github-automation.d.ts +37 -1
- package/dist/operations/services/github-automation.js +71 -14
- package/dist/operations/services/project-platform.d.ts +835 -0
- package/dist/operations/services/project-platform.js +782 -0
- package/dist/operations/services/railway-deploy.d.ts +113 -18
- package/dist/operations/services/railway-deploy.js +357 -8
- package/dist/operations/services/runtime-tools.d.ts +25 -1
- package/dist/operations/services/runtime-tools.js +66 -5
- package/dist/operations/services/template-registry.d.ts +1 -1
- package/dist/operations/services/template-registry.js +17 -3
- package/dist/platform/books-data.d.ts +3 -4
- package/dist/platform/books-data.js +30 -4
- package/dist/platform/contracts.d.ts +56 -4
- package/dist/platform/deploy-config.js +109 -4
- package/dist/platform/deploy-runtime.d.ts +2 -0
- package/dist/platform/deploy-runtime.js +9 -1
- package/dist/platform/env.yaml +677 -0
- package/dist/platform/environment.js +57 -2
- package/dist/platform/plugin.d.ts +8 -0
- package/dist/platform/plugins/constants.d.ts +2 -0
- package/dist/platform/plugins/constants.js +2 -0
- package/dist/platform/plugins/runtime.d.ts +2 -0
- package/dist/platform/plugins/runtime.js +9 -1
- package/dist/platform/plugins.d.ts +1 -1
- package/dist/platform/plugins.js +4 -0
- package/dist/platform/published-content-pipeline.d.ts +84 -0
- package/dist/platform/published-content-pipeline.js +543 -0
- package/dist/platform/published-content.d.ts +223 -0
- package/dist/platform/published-content.js +588 -0
- package/dist/platform/tenant/runtime-config.d.ts +1 -1
- package/dist/platform/tenant/runtime-config.js +34 -1
- package/dist/platform/tenant-config.d.ts +2 -1
- package/dist/platform/tenant-config.js +17 -1
- package/dist/platform/utils/site-config-schema.js +104 -0
- package/dist/plugin-default.d.ts +2 -0
- package/dist/plugin-default.js +2 -0
- package/dist/remote.d.ts +65 -9
- package/dist/remote.js +104 -28
- package/dist/scripts/check-build-warnings.js +50 -0
- package/dist/scripts/config-treeseed.js +7 -0
- package/dist/scripts/tenant-workflow-action.js +71 -0
- package/dist/sdk-dispatch.d.ts +12 -0
- package/dist/sdk-dispatch.js +142 -0
- package/dist/sdk-types.d.ts +579 -7
- package/dist/sdk-types.js +53 -1
- package/dist/sdk.d.ts +17 -1
- package/dist/sdk.js +109 -0
- package/dist/stores/operational-store.d.ts +22 -2
- package/dist/stores/operational-store.js +235 -0
- package/dist/template-catalog.js +8 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +20 -0
- package/dist/types/cloudflare.d.ts +23 -0
- package/dist/workflow/operations.d.ts +12 -3
- package/dist/workflow/policy.d.ts +1 -1
- package/dist/workflow-state.js +2 -1
- package/package.json +7 -2
- package/templates/github/deploy.workflow.yml +442 -0
- package/templates/github/hosted-project.workflow.yml +77 -0
|
@@ -19,9 +19,11 @@ import {
|
|
|
19
19
|
markManagedServicesInitialized,
|
|
20
20
|
markDeploymentInitialized,
|
|
21
21
|
provisionCloudflareResources,
|
|
22
|
-
syncCloudflareSecrets
|
|
22
|
+
syncCloudflareSecrets,
|
|
23
|
+
verifyProvisionedCloudflareResources
|
|
23
24
|
} from "./deploy.js";
|
|
24
25
|
import { maybeResolveGitHubRepositorySlug } from "./github-automation.js";
|
|
26
|
+
import { validateRailwayDeployPrerequisites } from "./railway-deploy.js";
|
|
25
27
|
import { loadCliDeployConfig, resolveWranglerBin, withProcessCwd } from "./runtime-tools.js";
|
|
26
28
|
const MACHINE_CONFIG_RELATIVE_PATH = ".treeseed/config/machine.yaml";
|
|
27
29
|
const MACHINE_KEY_HOME_RELATIVE_PATH = ".treeseed/config/machine.key";
|
|
@@ -1181,14 +1183,15 @@ function syncTreeseedRailwayEnvironment({ tenantRoot, scope = "prod", dryRun = f
|
|
|
1181
1183
|
const values = resolveTreeseedMachineEnvironmentValues(tenantRoot, scope);
|
|
1182
1184
|
const registry = collectTreeseedEnvironmentContext(tenantRoot);
|
|
1183
1185
|
const railwaySecretNames = registry.entries.filter((entry) => entry.scopes.includes(scope) && entry.targets.includes("railway-secret")).map((entry) => entry.id).filter((key) => typeof values[key] === "string" && values[key].length > 0);
|
|
1184
|
-
const
|
|
1186
|
+
const railwayVariableNames = registry.entries.filter((entry) => entry.scopes.includes(scope) && entry.targets.includes("railway-var")).map((entry) => entry.id).filter((key) => typeof values[key] === "string" && values[key].length > 0);
|
|
1187
|
+
const services = ["api", "agents", "manager", "worker", "runner", "workdayStart", "workdayReport"].map((serviceKey) => {
|
|
1185
1188
|
const service = deployConfig.services?.[serviceKey];
|
|
1186
1189
|
if (!service || service.enabled === false || (service.provider ?? "railway") !== "railway") {
|
|
1187
1190
|
return null;
|
|
1188
1191
|
}
|
|
1189
1192
|
const environment = service.environments?.[scope];
|
|
1190
1193
|
const fallbackServiceName = serviceKey === "api" ? config.settings.services.railway.apiServiceName : serviceKey === "agents" ? config.settings.services.railway.agentsServiceName : "";
|
|
1191
|
-
const defaultRootDir = ["api", "manager", "worker", "workdayStart", "workdayReport"].includes(serviceKey) ? "." : "packages/core";
|
|
1194
|
+
const defaultRootDir = ["api", "manager", "worker", "runner", "workdayStart", "workdayReport"].includes(serviceKey) ? "." : "packages/core";
|
|
1192
1195
|
return {
|
|
1193
1196
|
service: serviceKey,
|
|
1194
1197
|
projectName: service.railway?.projectName ?? config.settings.services.railway.projectName,
|
|
@@ -1198,6 +1201,7 @@ function syncTreeseedRailwayEnvironment({ tenantRoot, scope = "prod", dryRun = f
|
|
|
1198
1201
|
baseUrl: environment?.baseUrl ?? service.publicBaseUrl ?? "(unset)",
|
|
1199
1202
|
environmentName: environment?.railwayEnvironment ?? scope,
|
|
1200
1203
|
secrets: railwaySecretNames,
|
|
1204
|
+
variables: railwayVariableNames,
|
|
1201
1205
|
dryRun
|
|
1202
1206
|
};
|
|
1203
1207
|
}).filter(Boolean);
|
|
@@ -1208,6 +1212,12 @@ function syncTreeseedRailwayEnvironment({ tenantRoot, scope = "prod", dryRun = f
|
|
|
1208
1212
|
{ cwd: service.rootDir, dryRun, input: values[key] }
|
|
1209
1213
|
);
|
|
1210
1214
|
}
|
|
1215
|
+
for (const key of service.variables) {
|
|
1216
|
+
runRailway(
|
|
1217
|
+
["variable", "set", "--service", service.serviceName || service.serviceId, "--environment", service.environmentName, "--stdin", "--skip-deploys", key],
|
|
1218
|
+
{ cwd: service.rootDir, dryRun, input: values[key] }
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1211
1221
|
}
|
|
1212
1222
|
return {
|
|
1213
1223
|
scope,
|
|
@@ -1230,6 +1240,40 @@ function initializeTreeseedPersistentEnvironment({ tenantRoot, scope = "prod", d
|
|
|
1230
1240
|
secrets: syncedSecrets
|
|
1231
1241
|
};
|
|
1232
1242
|
}
|
|
1243
|
+
function summarizePersistentReadiness(tenantRoot, scope, validation, connectionChecks) {
|
|
1244
|
+
if (scope === "local") {
|
|
1245
|
+
return {
|
|
1246
|
+
configured: validation.ok,
|
|
1247
|
+
provisioned: true,
|
|
1248
|
+
deployable: validation.ok,
|
|
1249
|
+
checks: {
|
|
1250
|
+
validation: validation.ok,
|
|
1251
|
+
connections: connectionChecks.every((check) => check.ready || check.skipped)
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
const cloudflare = verifyProvisionedCloudflareResources(tenantRoot, { scope });
|
|
1256
|
+
let railwayReady = true;
|
|
1257
|
+
try {
|
|
1258
|
+
validateRailwayDeployPrerequisites(tenantRoot, scope);
|
|
1259
|
+
} catch {
|
|
1260
|
+
railwayReady = false;
|
|
1261
|
+
}
|
|
1262
|
+
const configured = validation.ok;
|
|
1263
|
+
const provisioned = cloudflare.ok && railwayReady;
|
|
1264
|
+
const deployable = configured && provisioned && connectionChecks.every((check) => check.ready || check.skipped);
|
|
1265
|
+
return {
|
|
1266
|
+
configured,
|
|
1267
|
+
provisioned,
|
|
1268
|
+
deployable,
|
|
1269
|
+
checks: {
|
|
1270
|
+
validation: validation.ok,
|
|
1271
|
+
connections: connectionChecks.every((check) => check.ready || check.skipped),
|
|
1272
|
+
cloudflare: cloudflare.checks,
|
|
1273
|
+
railway: railwayReady
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1233
1277
|
function colorize(value, code) {
|
|
1234
1278
|
return `\x1B[${code}m${value}\x1B[0m`;
|
|
1235
1279
|
}
|
|
@@ -1413,7 +1457,8 @@ function finalizeTreeseedConfig({
|
|
|
1413
1457
|
synced: {},
|
|
1414
1458
|
initialized: [],
|
|
1415
1459
|
connectionChecks: [],
|
|
1416
|
-
validationByScope: {}
|
|
1460
|
+
validationByScope: {},
|
|
1461
|
+
readinessByScope: {}
|
|
1417
1462
|
};
|
|
1418
1463
|
for (const scope of scopes) {
|
|
1419
1464
|
const validation = validateTreeseedEnvironmentValues({
|
|
@@ -1460,6 +1505,19 @@ ${details}`);
|
|
|
1460
1505
|
if (sync === "railway" || sync === "all") {
|
|
1461
1506
|
summary.synced.railway = syncTreeseedRailwayEnvironment({ tenantRoot, scope: scopes.at(-1) ?? "prod" });
|
|
1462
1507
|
}
|
|
1508
|
+
for (const scope of scopes) {
|
|
1509
|
+
summary.readinessByScope[scope] = summarizePersistentReadiness(
|
|
1510
|
+
tenantRoot,
|
|
1511
|
+
scope,
|
|
1512
|
+
summary.validationByScope[scope],
|
|
1513
|
+
summary.connectionChecks.find((report) => report.scope === scope)?.checks ?? []
|
|
1514
|
+
);
|
|
1515
|
+
if (scope !== "local" && summary.readinessByScope[scope].deployable !== true) {
|
|
1516
|
+
throw new Error(
|
|
1517
|
+
`Treeseed config readiness failed for ${scope}: configuration is not deployable.`
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1463
1521
|
return summary;
|
|
1464
1522
|
}
|
|
1465
1523
|
function collectTreeseedPrintEnvReport({
|
|
@@ -20,14 +20,35 @@ export declare function ensureGeneratedWranglerConfig(tenantRoot: any, options?:
|
|
|
20
20
|
slug: string;
|
|
21
21
|
siteUrl: string;
|
|
22
22
|
contactEmail: string;
|
|
23
|
+
hosting: {
|
|
24
|
+
kind: string;
|
|
25
|
+
registration: string;
|
|
26
|
+
marketBaseUrl: string | undefined;
|
|
27
|
+
teamId: string | undefined;
|
|
28
|
+
projectId: string | undefined;
|
|
29
|
+
} | undefined;
|
|
23
30
|
cloudflare: {
|
|
24
31
|
accountId: string;
|
|
25
32
|
workerName: string | undefined;
|
|
26
|
-
gatewayWorkerName: string | undefined;
|
|
27
33
|
queueName: string | undefined;
|
|
28
34
|
dlqName: string | undefined;
|
|
29
35
|
d1Binding: string | undefined;
|
|
30
36
|
queueBinding: string | undefined;
|
|
37
|
+
pages: {
|
|
38
|
+
projectName: string | undefined;
|
|
39
|
+
previewProjectName: string | undefined;
|
|
40
|
+
productionBranch: string;
|
|
41
|
+
stagingBranch: string;
|
|
42
|
+
buildOutputDir: string | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
r2: {
|
|
45
|
+
binding: string | undefined;
|
|
46
|
+
bucketName: string | undefined;
|
|
47
|
+
publicBaseUrl: string | undefined;
|
|
48
|
+
manifestKeyTemplate: string;
|
|
49
|
+
previewRootTemplate: string;
|
|
50
|
+
previewTtlHours: number;
|
|
51
|
+
} | undefined;
|
|
31
52
|
};
|
|
32
53
|
plugins: {
|
|
33
54
|
package: string;
|
|
@@ -49,6 +70,8 @@ export declare function ensureGeneratedWranglerConfig(tenantRoot: any, options?:
|
|
|
49
70
|
};
|
|
50
71
|
deploy: string;
|
|
51
72
|
content: {
|
|
73
|
+
runtime: string;
|
|
74
|
+
publish: string;
|
|
52
75
|
docs: string;
|
|
53
76
|
};
|
|
54
77
|
site: string;
|
|
@@ -70,6 +93,7 @@ export declare function ensureGeneratedWranglerConfig(tenantRoot: any, options?:
|
|
|
70
93
|
rootDir: string | undefined;
|
|
71
94
|
buildCommand: string | undefined;
|
|
72
95
|
startCommand: string | undefined;
|
|
96
|
+
schedule: any;
|
|
73
97
|
};
|
|
74
98
|
environments: {
|
|
75
99
|
local: {
|
|
@@ -123,14 +147,35 @@ export declare function validateDeployPrerequisites(tenantRoot: any, { requireRe
|
|
|
123
147
|
slug: string;
|
|
124
148
|
siteUrl: string;
|
|
125
149
|
contactEmail: string;
|
|
150
|
+
hosting: {
|
|
151
|
+
kind: string;
|
|
152
|
+
registration: string;
|
|
153
|
+
marketBaseUrl: string | undefined;
|
|
154
|
+
teamId: string | undefined;
|
|
155
|
+
projectId: string | undefined;
|
|
156
|
+
} | undefined;
|
|
126
157
|
cloudflare: {
|
|
127
158
|
accountId: string;
|
|
128
159
|
workerName: string | undefined;
|
|
129
|
-
gatewayWorkerName: string | undefined;
|
|
130
160
|
queueName: string | undefined;
|
|
131
161
|
dlqName: string | undefined;
|
|
132
162
|
d1Binding: string | undefined;
|
|
133
163
|
queueBinding: string | undefined;
|
|
164
|
+
pages: {
|
|
165
|
+
projectName: string | undefined;
|
|
166
|
+
previewProjectName: string | undefined;
|
|
167
|
+
productionBranch: string;
|
|
168
|
+
stagingBranch: string;
|
|
169
|
+
buildOutputDir: string | undefined;
|
|
170
|
+
} | undefined;
|
|
171
|
+
r2: {
|
|
172
|
+
binding: string | undefined;
|
|
173
|
+
bucketName: string | undefined;
|
|
174
|
+
publicBaseUrl: string | undefined;
|
|
175
|
+
manifestKeyTemplate: string;
|
|
176
|
+
previewRootTemplate: string;
|
|
177
|
+
previewTtlHours: number;
|
|
178
|
+
} | undefined;
|
|
134
179
|
};
|
|
135
180
|
plugins: {
|
|
136
181
|
package: string;
|
|
@@ -152,6 +197,8 @@ export declare function validateDeployPrerequisites(tenantRoot: any, { requireRe
|
|
|
152
197
|
};
|
|
153
198
|
deploy: string;
|
|
154
199
|
content: {
|
|
200
|
+
runtime: string;
|
|
201
|
+
publish: string;
|
|
155
202
|
docs: string;
|
|
156
203
|
};
|
|
157
204
|
site: string;
|
|
@@ -173,6 +220,7 @@ export declare function validateDeployPrerequisites(tenantRoot: any, { requireRe
|
|
|
173
220
|
rootDir: string | undefined;
|
|
174
221
|
buildCommand: string | undefined;
|
|
175
222
|
startCommand: string | undefined;
|
|
223
|
+
schedule: any;
|
|
176
224
|
};
|
|
177
225
|
environments: {
|
|
178
226
|
local: {
|
|
@@ -207,14 +255,35 @@ export declare function validateDestroyPrerequisites(tenantRoot: any, { requireR
|
|
|
207
255
|
slug: string;
|
|
208
256
|
siteUrl: string;
|
|
209
257
|
contactEmail: string;
|
|
258
|
+
hosting: {
|
|
259
|
+
kind: string;
|
|
260
|
+
registration: string;
|
|
261
|
+
marketBaseUrl: string | undefined;
|
|
262
|
+
teamId: string | undefined;
|
|
263
|
+
projectId: string | undefined;
|
|
264
|
+
} | undefined;
|
|
210
265
|
cloudflare: {
|
|
211
266
|
accountId: string;
|
|
212
267
|
workerName: string | undefined;
|
|
213
|
-
gatewayWorkerName: string | undefined;
|
|
214
268
|
queueName: string | undefined;
|
|
215
269
|
dlqName: string | undefined;
|
|
216
270
|
d1Binding: string | undefined;
|
|
217
271
|
queueBinding: string | undefined;
|
|
272
|
+
pages: {
|
|
273
|
+
projectName: string | undefined;
|
|
274
|
+
previewProjectName: string | undefined;
|
|
275
|
+
productionBranch: string;
|
|
276
|
+
stagingBranch: string;
|
|
277
|
+
buildOutputDir: string | undefined;
|
|
278
|
+
} | undefined;
|
|
279
|
+
r2: {
|
|
280
|
+
binding: string | undefined;
|
|
281
|
+
bucketName: string | undefined;
|
|
282
|
+
publicBaseUrl: string | undefined;
|
|
283
|
+
manifestKeyTemplate: string;
|
|
284
|
+
previewRootTemplate: string;
|
|
285
|
+
previewTtlHours: number;
|
|
286
|
+
} | undefined;
|
|
218
287
|
};
|
|
219
288
|
plugins: {
|
|
220
289
|
package: string;
|
|
@@ -236,6 +305,8 @@ export declare function validateDestroyPrerequisites(tenantRoot: any, { requireR
|
|
|
236
305
|
};
|
|
237
306
|
deploy: string;
|
|
238
307
|
content: {
|
|
308
|
+
runtime: string;
|
|
309
|
+
publish: string;
|
|
239
310
|
docs: string;
|
|
240
311
|
};
|
|
241
312
|
site: string;
|
|
@@ -257,6 +328,7 @@ export declare function validateDestroyPrerequisites(tenantRoot: any, { requireR
|
|
|
257
328
|
rootDir: string | undefined;
|
|
258
329
|
buildCommand: string | undefined;
|
|
259
330
|
startCommand: string | undefined;
|
|
331
|
+
schedule: any;
|
|
260
332
|
};
|
|
261
333
|
environments: {
|
|
262
334
|
local: {
|
|
@@ -297,9 +369,12 @@ export declare function destroyCloudflareResources(tenantRoot: any, options?: {}
|
|
|
297
369
|
workerName: any;
|
|
298
370
|
siteUrl: any;
|
|
299
371
|
accountId: any;
|
|
372
|
+
pages: any;
|
|
300
373
|
formGuardKv: any;
|
|
301
374
|
sessionKv: any;
|
|
302
375
|
siteDataDb: any;
|
|
376
|
+
queue: any;
|
|
377
|
+
content: any;
|
|
303
378
|
};
|
|
304
379
|
operations: {
|
|
305
380
|
worker: {
|
|
@@ -354,11 +429,28 @@ export declare function provisionCloudflareResources(tenantRoot: any, options?:
|
|
|
354
429
|
workerName: any;
|
|
355
430
|
siteUrl: any;
|
|
356
431
|
accountId: any;
|
|
432
|
+
pages: any;
|
|
357
433
|
formGuardKv: any;
|
|
358
434
|
sessionKv: any;
|
|
359
435
|
siteDataDb: any;
|
|
436
|
+
queue: any;
|
|
437
|
+
content: any;
|
|
360
438
|
};
|
|
361
439
|
export declare function syncCloudflareSecrets(tenantRoot: any, options?: {}): string[];
|
|
440
|
+
export declare function verifyProvisionedCloudflareResources(tenantRoot: any, options?: {}): {
|
|
441
|
+
ok: boolean;
|
|
442
|
+
target: any;
|
|
443
|
+
checks: {
|
|
444
|
+
pages: boolean;
|
|
445
|
+
formGuardKv: boolean;
|
|
446
|
+
sessionKv: boolean;
|
|
447
|
+
d1: boolean;
|
|
448
|
+
queue: boolean;
|
|
449
|
+
dlq: boolean;
|
|
450
|
+
r2: boolean;
|
|
451
|
+
};
|
|
452
|
+
state: any;
|
|
453
|
+
};
|
|
362
454
|
export declare function runRemoteD1Migrations(tenantRoot: any, options?: {}): {
|
|
363
455
|
databaseName: any;
|
|
364
456
|
dryRun: boolean;
|