@treeseed/sdk 0.4.3 → 0.4.5
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/operations/services/config-runtime.js +1 -1
- package/dist/operations/services/railway-deploy.js +1 -1
- package/dist/operations/services/runtime-tools.d.ts +1 -0
- package/dist/operations/services/runtime-tools.js +39 -3
- package/dist/platform/contracts.d.ts +31 -5
- package/dist/platform/deploy-config.js +30 -2
- package/dist/platform/plugin.d.ts +32 -3
- package/dist/platform/tenant-config.js +26 -1
- package/dist/scripts/aggregate-book.js +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.d.ts +3 -2
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.ts +4 -1
- package/package.json +1 -1
|
@@ -1064,7 +1064,7 @@ function syncTreeseedRailwayEnvironment({ tenantRoot, scope = "prod", dryRun = f
|
|
|
1064
1064
|
}
|
|
1065
1065
|
const environment = service.environments?.[scope];
|
|
1066
1066
|
const fallbackServiceName = serviceKey === "api" ? config.settings.services.railway.apiServiceName : serviceKey === "agents" ? config.settings.services.railway.agentsServiceName : "";
|
|
1067
|
-
const defaultRootDir = serviceKey === "api" ? "
|
|
1067
|
+
const defaultRootDir = serviceKey === "api" ? "." : "packages/agent";
|
|
1068
1068
|
return {
|
|
1069
1069
|
service: serviceKey,
|
|
1070
1070
|
projectName: service.railway?.projectName ?? config.settings.services.railway.projectName,
|
|
@@ -26,7 +26,7 @@ function configuredRailwayServices(tenantRoot, scope) {
|
|
|
26
26
|
if (!service || service.enabled === false || (service.provider ?? "railway") !== "railway") {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
const defaultRootDir = serviceKey === "api" ? "
|
|
29
|
+
const defaultRootDir = serviceKey === "api" ? "." : "packages/agent";
|
|
30
30
|
const serviceRoot = resolve(tenantRoot, service.railway?.rootDir ?? service.rootDir ?? defaultRootDir);
|
|
31
31
|
const railwayEnvironment = service.environments?.[normalizedScope]?.railwayEnvironment ?? normalizedScope;
|
|
32
32
|
const publicBaseUrl = service.environments?.[normalizedScope]?.baseUrl ?? service.publicBaseUrl ?? null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const packageRoot: string;
|
|
2
2
|
export declare const packageScriptRoot: string;
|
|
3
|
+
export declare const packageDistScriptRoot: string;
|
|
3
4
|
export declare const runtimeRoot: string;
|
|
4
5
|
export declare function treeseedWorkspacePackageCheckoutState(root?: string): {
|
|
5
6
|
mode: string;
|
|
@@ -6,7 +6,27 @@ import { createRequire } from "node:module";
|
|
|
6
6
|
import { parse as parseYaml } from "yaml";
|
|
7
7
|
const require2 = createRequire(import.meta.url);
|
|
8
8
|
const scriptRoot = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
9
|
+
function resolveSdkPackageRoot(startDir) {
|
|
10
|
+
let currentDir = startDir;
|
|
11
|
+
while (true) {
|
|
12
|
+
const packageJsonPath = resolve(currentDir, "package.json");
|
|
13
|
+
if (existsSync(packageJsonPath)) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
16
|
+
if (packageJson?.name === "@treeseed/sdk") {
|
|
17
|
+
return currentDir;
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const parentDir = dirname(currentDir);
|
|
23
|
+
if (parentDir === currentDir) {
|
|
24
|
+
return resolve(startDir, "..", "..", "..");
|
|
25
|
+
}
|
|
26
|
+
currentDir = parentDir;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const packageRootFromSource = resolveSdkPackageRoot(scriptRoot);
|
|
10
30
|
const treeseedRuntimeRoot = resolve(packageRootFromSource, "src", "treeseed");
|
|
11
31
|
const TREESEED_DEFAULT_PLUGIN_REFERENCES = [
|
|
12
32
|
{
|
|
@@ -31,7 +51,7 @@ const TREESEED_DEFAULT_PROVIDER_SELECTIONS = {
|
|
|
31
51
|
site: "default"
|
|
32
52
|
};
|
|
33
53
|
const TRESEED_MANAGED_SERVICE_KEYS = ["api", "agents", "gateway", "manager", "worker", "workdayStart", "workdayReport"];
|
|
34
|
-
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli", "agent"
|
|
54
|
+
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli", "agent"];
|
|
35
55
|
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
36
56
|
function parseServiceEnvironmentConfig(value) {
|
|
37
57
|
const record = optionalRecord(value, "service environment") ?? {};
|
|
@@ -87,6 +107,7 @@ function parseManagedServicesConfig(value) {
|
|
|
87
107
|
}
|
|
88
108
|
const packageRoot = packageRootFromSource;
|
|
89
109
|
const packageScriptRoot = resolve(packageRoot, "scripts");
|
|
110
|
+
const packageDistScriptRoot = resolve(packageRoot, "dist", "scripts");
|
|
90
111
|
const runtimeRoot = treeseedRuntimeRoot;
|
|
91
112
|
function resolvePackageBinary(packageName, binName = packageName) {
|
|
92
113
|
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
@@ -182,7 +203,15 @@ function createProductionBuildEnv(extraEnv = {}) {
|
|
|
182
203
|
}
|
|
183
204
|
function packageScriptPath(scriptName) {
|
|
184
205
|
if (extname(scriptName)) {
|
|
185
|
-
|
|
206
|
+
const directScriptPath = resolve(packageScriptRoot, scriptName);
|
|
207
|
+
if (existsSync(directScriptPath)) {
|
|
208
|
+
return directScriptPath;
|
|
209
|
+
}
|
|
210
|
+
const distScriptPath = resolve(packageDistScriptRoot, scriptName.replace(/\.(ts|mjs)$/u, ".js"));
|
|
211
|
+
if (existsSync(distScriptPath)) {
|
|
212
|
+
return distScriptPath;
|
|
213
|
+
}
|
|
214
|
+
return directScriptPath;
|
|
186
215
|
}
|
|
187
216
|
for (const extension of [".js", ".ts", ".mjs"]) {
|
|
188
217
|
const candidate = resolve(packageScriptRoot, `${scriptName}${extension}`);
|
|
@@ -190,6 +219,12 @@ function packageScriptPath(scriptName) {
|
|
|
190
219
|
return candidate;
|
|
191
220
|
}
|
|
192
221
|
}
|
|
222
|
+
for (const extension of [".js", ".mjs"]) {
|
|
223
|
+
const candidate = resolve(packageDistScriptRoot, `${scriptName}${extension}`);
|
|
224
|
+
if (existsSync(candidate)) {
|
|
225
|
+
return candidate;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
193
228
|
throw new Error(`Unable to resolve package script "${scriptName}".`);
|
|
194
229
|
}
|
|
195
230
|
function withProcessCwd(cwd, action) {
|
|
@@ -343,6 +378,7 @@ export {
|
|
|
343
378
|
isWorkspaceRoot,
|
|
344
379
|
loadCliDeployConfig,
|
|
345
380
|
loadPackageJson,
|
|
381
|
+
packageDistScriptRoot,
|
|
346
382
|
packageRoot,
|
|
347
383
|
packageScriptPath,
|
|
348
384
|
packageScriptRoot,
|
|
@@ -83,6 +83,28 @@ export interface TreeseedPluginReference {
|
|
|
83
83
|
enabled?: boolean;
|
|
84
84
|
config?: Record<string, unknown>;
|
|
85
85
|
}
|
|
86
|
+
export type TreeseedPlatformSurfaceName = 'web' | 'api' | 'gateway' | (string & {});
|
|
87
|
+
export type TreeseedPlatformResourceKind = 'pages' | 'styles' | 'components' | 'routes' | 'middleware' | 'handlers' | 'config';
|
|
88
|
+
export interface TreeseedPlatformLayerDefinition {
|
|
89
|
+
root: string;
|
|
90
|
+
kinds?: TreeseedPlatformResourceKind[];
|
|
91
|
+
}
|
|
92
|
+
export interface TreeseedTenantSurfaceOverride {
|
|
93
|
+
layers?: TreeseedPlatformLayerDefinition[];
|
|
94
|
+
}
|
|
95
|
+
export interface TreeseedTenantOverrides {
|
|
96
|
+
pagesRoot?: string;
|
|
97
|
+
stylesRoot?: string;
|
|
98
|
+
componentsRoot?: string;
|
|
99
|
+
surfaces?: Partial<Record<TreeseedPlatformSurfaceName, TreeseedTenantSurfaceOverride>>;
|
|
100
|
+
}
|
|
101
|
+
export interface TreeseedPlatformSurfaceConfig {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
provider?: string;
|
|
104
|
+
rootDir?: string;
|
|
105
|
+
publicBaseUrl?: string;
|
|
106
|
+
localBaseUrl?: string;
|
|
107
|
+
}
|
|
86
108
|
export interface TreeseedManagedServiceEnvironmentConfig {
|
|
87
109
|
baseUrl?: string;
|
|
88
110
|
domain?: string;
|
|
@@ -108,6 +130,13 @@ export interface TreeseedManagedServiceConfig {
|
|
|
108
130
|
export interface TreeseedManagedServicesConfig {
|
|
109
131
|
api?: TreeseedManagedServiceConfig;
|
|
110
132
|
agents?: TreeseedManagedServiceConfig;
|
|
133
|
+
[key: string]: TreeseedManagedServiceConfig | undefined;
|
|
134
|
+
}
|
|
135
|
+
export interface TreeseedPlatformSurfacesConfig {
|
|
136
|
+
web?: TreeseedPlatformSurfaceConfig;
|
|
137
|
+
api?: TreeseedPlatformSurfaceConfig;
|
|
138
|
+
gateway?: TreeseedPlatformSurfaceConfig;
|
|
139
|
+
[key: string]: TreeseedPlatformSurfaceConfig | undefined;
|
|
111
140
|
}
|
|
112
141
|
export interface TreeseedProviderSelections {
|
|
113
142
|
forms: string;
|
|
@@ -137,6 +166,7 @@ export interface TreeseedDeployConfig {
|
|
|
137
166
|
};
|
|
138
167
|
plugins: TreeseedPluginReference[];
|
|
139
168
|
providers: TreeseedProviderSelections;
|
|
169
|
+
surfaces?: TreeseedPlatformSurfacesConfig;
|
|
140
170
|
services?: TreeseedManagedServicesConfig;
|
|
141
171
|
smtp?: {
|
|
142
172
|
enabled?: boolean;
|
|
@@ -150,9 +180,5 @@ export interface TreeseedTenantConfig {
|
|
|
150
180
|
siteConfigPath: string;
|
|
151
181
|
content: TreeseedContentMap;
|
|
152
182
|
features: TreeseedFeatureModules;
|
|
153
|
-
overrides?:
|
|
154
|
-
pagesRoot?: string;
|
|
155
|
-
stylesRoot?: string;
|
|
156
|
-
componentsRoot?: string;
|
|
157
|
-
};
|
|
183
|
+
overrides?: TreeseedTenantOverrides;
|
|
158
184
|
}
|
|
@@ -153,11 +153,38 @@ function parseManagedServicesConfig(value) {
|
|
|
153
153
|
if (!record) {
|
|
154
154
|
return void 0;
|
|
155
155
|
}
|
|
156
|
+
return Object.fromEntries(
|
|
157
|
+
Object.entries(record).map(([serviceKey, serviceValue]) => [
|
|
158
|
+
serviceKey,
|
|
159
|
+
parseManagedServiceConfig(serviceValue, `services.${serviceKey}`)
|
|
160
|
+
])
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function parsePlatformSurfaceConfig(value, label) {
|
|
164
|
+
const record = optionalRecord(value, label);
|
|
165
|
+
if (!record) {
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
156
168
|
return {
|
|
157
|
-
|
|
158
|
-
|
|
169
|
+
enabled: record.enabled === void 0 ? void 0 : optionalBoolean(record.enabled, `${label}.enabled`),
|
|
170
|
+
provider: optionalString(record.provider),
|
|
171
|
+
rootDir: optionalString(record.rootDir),
|
|
172
|
+
publicBaseUrl: optionalString(record.publicBaseUrl),
|
|
173
|
+
localBaseUrl: optionalString(record.localBaseUrl)
|
|
159
174
|
};
|
|
160
175
|
}
|
|
176
|
+
function parsePlatformSurfacesConfig(value) {
|
|
177
|
+
const record = optionalRecord(value, "surfaces");
|
|
178
|
+
if (!record) {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
return Object.fromEntries(
|
|
182
|
+
Object.entries(record).map(([surfaceKey, surfaceValue]) => [
|
|
183
|
+
surfaceKey,
|
|
184
|
+
parsePlatformSurfaceConfig(surfaceValue, `surfaces.${surfaceKey}`)
|
|
185
|
+
])
|
|
186
|
+
);
|
|
187
|
+
}
|
|
161
188
|
function parseDeployConfig(raw) {
|
|
162
189
|
const parsed = normalizeAliasedRecord(
|
|
163
190
|
deployConfigFieldAliases,
|
|
@@ -181,6 +208,7 @@ function parseDeployConfig(raw) {
|
|
|
181
208
|
},
|
|
182
209
|
plugins: parsePluginReferences(parsed.plugins),
|
|
183
210
|
providers: parseProviderSelections(parsed.providers),
|
|
211
|
+
surfaces: parsePlatformSurfacesConfig(parsed.surfaces),
|
|
184
212
|
services: parseManagedServicesConfig(parsed.services),
|
|
185
213
|
smtp: {
|
|
186
214
|
enabled: optionalBoolean(smtp.enabled, "smtp.enabled")
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { TreeseedDeployConfig, TreeseedTenantConfig } from './contracts.ts';
|
|
1
|
+
import type { TreeseedDeployConfig, TreeseedPlatformLayerDefinition, TreeseedPlatformResourceKind, TreeseedPlatformSurfaceName, TreeseedTenantConfig } from './contracts.ts';
|
|
2
2
|
import type { TreeseedEnvironmentRegistryOverlay } from './environment.ts';
|
|
3
3
|
import type { SdkGraphRankingProvider } from '../sdk-types.ts';
|
|
4
|
-
export type TreeseedSiteLayerDefinition = {
|
|
5
|
-
root: string;
|
|
4
|
+
export type TreeseedSiteLayerDefinition = TreeseedPlatformLayerDefinition & {
|
|
6
5
|
kinds?: Array<'pages' | 'styles' | 'components'>;
|
|
7
6
|
};
|
|
8
7
|
export type TreeseedSiteRouteContribution = {
|
|
@@ -10,6 +9,12 @@ export type TreeseedSiteRouteContribution = {
|
|
|
10
9
|
entrypoint?: string;
|
|
11
10
|
resourcePath?: string;
|
|
12
11
|
};
|
|
12
|
+
export type TreeseedPlatformRouteContribution = {
|
|
13
|
+
pattern: string;
|
|
14
|
+
entrypoint?: string;
|
|
15
|
+
resourcePath?: string;
|
|
16
|
+
methods?: string[];
|
|
17
|
+
};
|
|
13
18
|
export type TreeseedSiteExtensionContribution = {
|
|
14
19
|
routes?: TreeseedSiteRouteContribution[];
|
|
15
20
|
starlightComponents?: Record<string, string>;
|
|
@@ -21,6 +26,20 @@ export type TreeseedSiteExtensionContribution = {
|
|
|
21
26
|
integrations?: unknown[];
|
|
22
27
|
routeMiddleware?: unknown[];
|
|
23
28
|
};
|
|
29
|
+
export type TreeseedPlatformExtensionContribution = {
|
|
30
|
+
routes?: TreeseedPlatformRouteContribution[];
|
|
31
|
+
middleware?: unknown[];
|
|
32
|
+
handlers?: Record<string, unknown>;
|
|
33
|
+
config?: Record<string, unknown>;
|
|
34
|
+
envSchema?: Record<string, unknown>;
|
|
35
|
+
vitePlugins?: unknown[];
|
|
36
|
+
integrations?: unknown[];
|
|
37
|
+
customCss?: string[];
|
|
38
|
+
remarkPlugins?: unknown[];
|
|
39
|
+
rehypePlugins?: unknown[];
|
|
40
|
+
routeMiddleware?: unknown[];
|
|
41
|
+
starlightComponents?: Record<string, string>;
|
|
42
|
+
};
|
|
24
43
|
export type TreeseedPluginSiteContext = {
|
|
25
44
|
projectRoot: string;
|
|
26
45
|
tenantConfig: TreeseedTenantConfig;
|
|
@@ -28,6 +47,13 @@ export type TreeseedPluginSiteContext = {
|
|
|
28
47
|
deployConfig?: TreeseedDeployConfig;
|
|
29
48
|
pluginConfig: Record<string, unknown>;
|
|
30
49
|
};
|
|
50
|
+
export type TreeseedPluginPlatformContext = TreeseedPluginSiteContext & {
|
|
51
|
+
surface: TreeseedPlatformSurfaceName;
|
|
52
|
+
};
|
|
53
|
+
export type TreeseedPlatformLayerContribution = TreeseedPlatformLayerDefinition & {
|
|
54
|
+
surface?: TreeseedPlatformSurfaceName;
|
|
55
|
+
kinds?: TreeseedPlatformResourceKind[];
|
|
56
|
+
};
|
|
31
57
|
export type TreeseedPluginEnvironmentContext = {
|
|
32
58
|
projectRoot: string;
|
|
33
59
|
tenantConfig?: TreeseedTenantConfig;
|
|
@@ -44,6 +70,9 @@ export interface TreeseedPlugin {
|
|
|
44
70
|
siteProviders?: Record<string, TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution)>;
|
|
45
71
|
siteHooks?: TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution);
|
|
46
72
|
siteLayers?: TreeseedSiteLayerDefinition[] | ((context: TreeseedPluginSiteContext) => TreeseedSiteLayerDefinition[] | undefined);
|
|
73
|
+
platformProviders?: Record<TreeseedPlatformSurfaceName, Record<string, TreeseedPlatformExtensionContribution | ((context: TreeseedPluginPlatformContext) => TreeseedPlatformExtensionContribution)>>;
|
|
74
|
+
platformHooks?: Partial<Record<TreeseedPlatformSurfaceName, TreeseedPlatformExtensionContribution>> | ((context: TreeseedPluginPlatformContext) => TreeseedPlatformExtensionContribution | undefined);
|
|
75
|
+
platformLayers?: TreeseedPlatformLayerContribution[] | ((context: TreeseedPluginPlatformContext) => TreeseedPlatformLayerContribution[] | undefined);
|
|
47
76
|
environmentRegistry?: TreeseedEnvironmentRegistryOverlay | ((context: TreeseedPluginEnvironmentContext) => TreeseedEnvironmentRegistryOverlay | undefined);
|
|
48
77
|
graphRankingProviders?: Record<string, TreeseedGraphRankingProviderContribution>;
|
|
49
78
|
[key: string]: unknown;
|
|
@@ -111,6 +111,22 @@ function loadTreeseedManifest(manifestPath = "./src/manifest.yaml") {
|
|
|
111
111
|
manifestOverrideFieldAliases,
|
|
112
112
|
parsed.overrides
|
|
113
113
|
) : void 0;
|
|
114
|
+
const normalizedSurfaceOverrides = Object.fromEntries(
|
|
115
|
+
Object.entries(overrides?.surfaces ?? {}).map(([surface, definition]) => [
|
|
116
|
+
surface,
|
|
117
|
+
{
|
|
118
|
+
layers: (definition?.layers ?? []).map((layer) => ({
|
|
119
|
+
root: resolve(tenantRoot, layer.root),
|
|
120
|
+
kinds: layer.kinds
|
|
121
|
+
}))
|
|
122
|
+
}
|
|
123
|
+
])
|
|
124
|
+
);
|
|
125
|
+
const legacyWebLayers = [
|
|
126
|
+
overrides?.pagesRoot ? { root: resolve(tenantRoot, overrides.pagesRoot), kinds: ["pages"] } : null,
|
|
127
|
+
overrides?.stylesRoot ? { root: resolve(tenantRoot, overrides.stylesRoot), kinds: ["styles"] } : null,
|
|
128
|
+
overrides?.componentsRoot ? { root: resolve(tenantRoot, overrides.componentsRoot), kinds: ["components"] } : null
|
|
129
|
+
].filter(Boolean);
|
|
114
130
|
const tenantConfig = defineTreeseedTenant({
|
|
115
131
|
...parsed,
|
|
116
132
|
siteConfigPath: resolve(tenantRoot, parsed.siteConfigPath),
|
|
@@ -123,7 +139,16 @@ function loadTreeseedManifest(manifestPath = "./src/manifest.yaml") {
|
|
|
123
139
|
overrides: overrides ? {
|
|
124
140
|
pagesRoot: overrides.pagesRoot ? resolve(tenantRoot, overrides.pagesRoot) : void 0,
|
|
125
141
|
stylesRoot: overrides.stylesRoot ? resolve(tenantRoot, overrides.stylesRoot) : void 0,
|
|
126
|
-
componentsRoot: overrides.componentsRoot ? resolve(tenantRoot, overrides.componentsRoot) : void 0
|
|
142
|
+
componentsRoot: overrides.componentsRoot ? resolve(tenantRoot, overrides.componentsRoot) : void 0,
|
|
143
|
+
surfaces: {
|
|
144
|
+
...normalizedSurfaceOverrides,
|
|
145
|
+
web: {
|
|
146
|
+
layers: [
|
|
147
|
+
...normalizedSurfaceOverrides.web?.layers ?? [],
|
|
148
|
+
...legacyWebLayers
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
127
152
|
} : void 0
|
|
128
153
|
});
|
|
129
154
|
Object.defineProperty(tenantConfig, "__tenantRoot", {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { buildTenantBookRuntime } from '../platform/
|
|
3
|
+
import { buildTenantBookRuntime } from '../platform/books-data.js';
|
|
4
4
|
import { loadTreeseedManifest } from '../platform/tenant-config.js';
|
|
5
5
|
const PROJECT_TENANT = loadTreeseedManifest();
|
|
6
6
|
const { BOOKS, TREESEED_LIBRARY_DOWNLOAD } = buildTenantBookRuntime(PROJECT_TENANT, {
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { AstroUserConfig } from 'astro/config';
|
|
2
|
+
declare const config: AstroUserConfig;
|
|
3
|
+
export default config;
|