@treeseed/sdk 0.4.9 → 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/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/index.d.ts +11 -1
- package/dist/index.js +69 -1
- package/dist/operations/services/config-runtime.d.ts +10 -0
- package/dist/operations/services/config-runtime.js +60 -2
- package/dist/operations/services/deploy.d.ts +95 -0
- package/dist/operations/services/deploy.js +350 -9
- 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 +355 -6
- package/dist/operations/services/runtime-tools.d.ts +25 -0
- package/dist/operations/services/runtime-tools.js +65 -3
- 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 +55 -2
- 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/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-types.d.ts +442 -3
- package/dist/sdk-types.js +37 -1
- package/dist/sdk.d.ts +11 -1
- package/dist/sdk.js +40 -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/package.json +7 -2
- package/templates/github/deploy.workflow.yml +442 -0
- package/templates/github/hosted-project.workflow.yml +77 -0
|
@@ -166,6 +166,108 @@ function parseTheme(value, path) {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
function parseAccessRoles(value, path) {
|
|
170
|
+
const record = optionalRecord(value, path);
|
|
171
|
+
if (!record) {
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return Object.fromEntries(
|
|
176
|
+
Object.entries(record).map(([roleId, rawRole]) => {
|
|
177
|
+
const parsedRole = expectRecord(rawRole, `${path}.${roleId}`);
|
|
178
|
+
return [
|
|
179
|
+
roleId,
|
|
180
|
+
{
|
|
181
|
+
grants: stringArray(parsedRole.grants, `${path}.${roleId}.grants`),
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function parseAccessPolicies(value, path) {
|
|
189
|
+
const record = optionalRecord(value, path);
|
|
190
|
+
if (!record) {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return Object.fromEntries(
|
|
195
|
+
Object.entries(record).map(([policyId, rawPolicy]) => {
|
|
196
|
+
const parsedPolicy = expectRecord(rawPolicy, `${path}.${policyId}`);
|
|
197
|
+
return [
|
|
198
|
+
policyId,
|
|
199
|
+
{
|
|
200
|
+
audience: optionalString(parsedPolicy.audience, `${path}.${policyId}.audience`),
|
|
201
|
+
entitlement: optionalString(parsedPolicy.entitlement, `${path}.${policyId}.entitlement`),
|
|
202
|
+
offer: optionalString(parsedPolicy.offer, `${path}.${policyId}.offer`),
|
|
203
|
+
visibility: optionalString(parsedPolicy.visibility, `${path}.${policyId}.visibility`),
|
|
204
|
+
},
|
|
205
|
+
];
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function parseAccessDefaults(value, path) {
|
|
211
|
+
const record = optionalRecord(value, path);
|
|
212
|
+
if (!record) {
|
|
213
|
+
return { models: {} };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const models = optionalRecord(record.models, `${path}.models`) ?? {};
|
|
217
|
+
return {
|
|
218
|
+
models: Object.fromEntries(
|
|
219
|
+
Object.entries(models).map(([modelId, rawSurfaces]) => {
|
|
220
|
+
const parsedSurfaces = expectRecord(rawSurfaces, `${path}.models.${modelId}`);
|
|
221
|
+
return [
|
|
222
|
+
modelId,
|
|
223
|
+
Object.fromEntries(
|
|
224
|
+
Object.entries(parsedSurfaces).map(([surfaceId, rawPolicy]) => [
|
|
225
|
+
surfaceId,
|
|
226
|
+
expectString(rawPolicy, `${path}.models.${modelId}.${surfaceId}`),
|
|
227
|
+
]),
|
|
228
|
+
),
|
|
229
|
+
];
|
|
230
|
+
}),
|
|
231
|
+
),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function parseAccessBootstrap(value, path) {
|
|
236
|
+
const record = optionalRecord(value, path);
|
|
237
|
+
if (!record) {
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const owners = optionalRecord(record.owners, `${path}.owners`);
|
|
242
|
+
return {
|
|
243
|
+
owners: owners
|
|
244
|
+
? {
|
|
245
|
+
emails: stringArray(owners.emails, `${path}.owners.emails`),
|
|
246
|
+
roles: stringArray(owners.roles, `${path}.owners.roles`),
|
|
247
|
+
}
|
|
248
|
+
: undefined,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function parseAccess(value, path) {
|
|
253
|
+
const record = optionalRecord(value, path);
|
|
254
|
+
if (!record) {
|
|
255
|
+
return {
|
|
256
|
+
roles: {},
|
|
257
|
+
policies: {},
|
|
258
|
+
defaults: { models: {} },
|
|
259
|
+
bootstrap: {},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
roles: parseAccessRoles(record.roles, `${path}.roles`),
|
|
265
|
+
policies: parseAccessPolicies(record.policies, `${path}.policies`),
|
|
266
|
+
defaults: parseAccessDefaults(record.defaults, `${path}.defaults`),
|
|
267
|
+
bootstrap: parseAccessBootstrap(record.bootstrap, `${path}.bootstrap`),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
169
271
|
/** @type {TreeseedFieldAliasRegistry} */
|
|
170
272
|
const siteFieldAliases = {
|
|
171
273
|
siteUrl: { key: 'siteUrl', aliases: ['site_url'] },
|
|
@@ -228,6 +330,7 @@ export function parseSiteConfig(source) {
|
|
|
228
330
|
emailNotificationFieldAliases,
|
|
229
331
|
expectRecord(site.emailNotifications, 'site.emailNotifications'),
|
|
230
332
|
);
|
|
333
|
+
const access = parseAccess(parsed.access, 'access');
|
|
231
334
|
|
|
232
335
|
return {
|
|
233
336
|
site: {
|
|
@@ -317,5 +420,6 @@ export function parseSiteConfig(source) {
|
|
|
317
420
|
},
|
|
318
421
|
},
|
|
319
422
|
},
|
|
423
|
+
access,
|
|
320
424
|
};
|
|
321
425
|
}
|
package/dist/plugin-default.d.ts
CHANGED
package/dist/plugin-default.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const allowlisted = [];
|
|
8
|
+
const files = [];
|
|
9
|
+
|
|
10
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
11
|
+
const arg = args[index];
|
|
12
|
+
if (arg === '--allow') {
|
|
13
|
+
const pattern = args[index + 1];
|
|
14
|
+
if (!pattern) {
|
|
15
|
+
throw new Error('Missing value for --allow.');
|
|
16
|
+
}
|
|
17
|
+
allowlisted.push(new RegExp(pattern));
|
|
18
|
+
index += 1;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
files.push(arg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (files.length === 0) {
|
|
25
|
+
throw new Error('Usage: node check-build-warnings.mjs <log-file> [<log-file> ...] [--allow <regex>]');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const warningLines = [];
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
const contents = readFileSync(resolve(process.cwd(), file), 'utf8');
|
|
31
|
+
for (const line of contents.split(/\r?\n/u)) {
|
|
32
|
+
if (!line.includes('[WARN]')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (allowlisted.some((pattern) => pattern.test(line))) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
warningLines.push(line);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (warningLines.length > 0) {
|
|
43
|
+
console.error('Unexpected build warnings detected:');
|
|
44
|
+
for (const line of warningLines) {
|
|
45
|
+
console.error(`- ${line}`);
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('No unexpected build warnings detected.');
|
|
@@ -74,6 +74,13 @@ try {
|
|
|
74
74
|
console.log(`Machine key: ${keyPath}`);
|
|
75
75
|
console.log(`Updated values: ${applyResult.updated.length}`);
|
|
76
76
|
console.log(`Initialized environments: ${result.initialized.length}`);
|
|
77
|
+
for (const scope of scopes) {
|
|
78
|
+
const readiness = result.readinessByScope?.[scope];
|
|
79
|
+
if (!readiness)
|
|
80
|
+
continue;
|
|
81
|
+
const status = readiness.deployable ? 'deployable' : readiness.provisioned ? 'provisioned' : readiness.configured ? 'configured' : 'pending';
|
|
82
|
+
console.log(`Readiness (${scope}): ${status}`);
|
|
83
|
+
}
|
|
77
84
|
if (result.synced.github) {
|
|
78
85
|
console.log(`GitHub sync: ${result.synced.github.secrets.length} secrets, ${result.synced.github.variables.length} variables (${result.synced.github.repository})`);
|
|
79
86
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolveScope, runProjectPlatformAction, } from '../operations/services/project-platform.js';
|
|
3
|
+
const tenantRoot = process.cwd();
|
|
4
|
+
function parseArgs(argv) {
|
|
5
|
+
const parsed = {
|
|
6
|
+
action: 'deploy_code',
|
|
7
|
+
environment: null,
|
|
8
|
+
projectId: null,
|
|
9
|
+
previewId: null,
|
|
10
|
+
dryRun: false,
|
|
11
|
+
};
|
|
12
|
+
const rest = [...argv];
|
|
13
|
+
while (rest.length) {
|
|
14
|
+
const current = rest.shift();
|
|
15
|
+
if (!current)
|
|
16
|
+
continue;
|
|
17
|
+
if (current === '--action') {
|
|
18
|
+
parsed.action = (rest.shift() ?? parsed.action);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (current.startsWith('--action=')) {
|
|
22
|
+
parsed.action = (current.split('=', 2)[1] ?? parsed.action);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (current === '--environment') {
|
|
26
|
+
parsed.environment = rest.shift() ?? null;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (current.startsWith('--environment=')) {
|
|
30
|
+
parsed.environment = current.split('=', 2)[1] ?? null;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (current === '--project-id') {
|
|
34
|
+
parsed.projectId = rest.shift() ?? null;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (current.startsWith('--project-id=')) {
|
|
38
|
+
parsed.projectId = current.split('=', 2)[1] ?? null;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (current === '--preview-id') {
|
|
42
|
+
parsed.previewId = rest.shift() ?? null;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (current.startsWith('--preview-id=')) {
|
|
46
|
+
parsed.previewId = current.split('=', 2)[1] ?? null;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (current === '--dry-run') {
|
|
50
|
+
parsed.dryRun = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Unknown workflow action argument: ${current}`);
|
|
54
|
+
}
|
|
55
|
+
return parsed;
|
|
56
|
+
}
|
|
57
|
+
async function main() {
|
|
58
|
+
const options = parseArgs(process.argv.slice(2));
|
|
59
|
+
const scope = resolveScope(options.environment);
|
|
60
|
+
const result = await runProjectPlatformAction(options.action, {
|
|
61
|
+
tenantRoot,
|
|
62
|
+
scope,
|
|
63
|
+
projectId: options.projectId ?? process.env.TREESEED_PROJECT_ID ?? null,
|
|
64
|
+
previewId: options.previewId,
|
|
65
|
+
dryRun: options.dryRun,
|
|
66
|
+
});
|
|
67
|
+
if (result !== undefined) {
|
|
68
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await main();
|