@treeseed/sdk 0.4.2 → 0.4.4
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/d1-http.d.ts +38 -0
- package/dist/d1-http.js +95 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/operations/services/config-runtime.js +1 -1
- package/dist/operations/services/railway-deploy.js +1 -1
- package/dist/operations/services/runtime-tools.js +1 -1
- package/dist/platform/contracts.d.ts +31 -5
- package/dist/platform/deploy-config.js +30 -2
- package/dist/platform/environment.d.ts +1 -1
- package/dist/platform/environment.js +1 -0
- 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 +5 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { D1DatabaseLike, D1PreparedStatementLike } from './types/cloudflare.ts';
|
|
2
|
+
type D1QueryResult<T = Record<string, unknown>> = {
|
|
3
|
+
success?: boolean;
|
|
4
|
+
results?: T[];
|
|
5
|
+
meta?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export interface CloudflareHttpD1DatabaseOptions {
|
|
8
|
+
accountId: string;
|
|
9
|
+
databaseId: string;
|
|
10
|
+
apiToken: string;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
}
|
|
13
|
+
declare class CloudflareHttpD1PreparedStatement implements D1PreparedStatementLike {
|
|
14
|
+
private readonly endpoint;
|
|
15
|
+
private readonly apiToken;
|
|
16
|
+
private readonly fetchImpl;
|
|
17
|
+
private readonly query;
|
|
18
|
+
private bindings;
|
|
19
|
+
constructor(endpoint: string, apiToken: string, fetchImpl: typeof fetch, query: string);
|
|
20
|
+
bind(...values: unknown[]): this;
|
|
21
|
+
private execute;
|
|
22
|
+
run(): Promise<D1QueryResult<Record<string, unknown>>[]>;
|
|
23
|
+
all<T = Record<string, unknown>>(): Promise<{
|
|
24
|
+
results: T[];
|
|
25
|
+
}>;
|
|
26
|
+
first<T = Record<string, unknown>>(): Promise<NonNullable<T> | null>;
|
|
27
|
+
raw<T = unknown[]>(): Promise<T[]>;
|
|
28
|
+
}
|
|
29
|
+
export declare class CloudflareHttpD1Database implements D1DatabaseLike {
|
|
30
|
+
private readonly options;
|
|
31
|
+
private readonly endpoint;
|
|
32
|
+
private readonly fetchImpl;
|
|
33
|
+
constructor(options: CloudflareHttpD1DatabaseOptions);
|
|
34
|
+
prepare(query: string): CloudflareHttpD1PreparedStatement;
|
|
35
|
+
exec(query: string): Promise<D1QueryResult<Record<string, unknown>>[]>;
|
|
36
|
+
}
|
|
37
|
+
export declare function interpolateD1Query(query: string, bindings: unknown[]): string;
|
|
38
|
+
export {};
|
package/dist/d1-http.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function toSqlValue(value) {
|
|
2
|
+
if (value === null || value === void 0) {
|
|
3
|
+
return "NULL";
|
|
4
|
+
}
|
|
5
|
+
if (typeof value === "number") {
|
|
6
|
+
return String(value);
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === "boolean") {
|
|
9
|
+
return value ? "1" : "0";
|
|
10
|
+
}
|
|
11
|
+
return `'${String(value).replace(/'/g, "''")}'`;
|
|
12
|
+
}
|
|
13
|
+
function interpolateBindings(query, values) {
|
|
14
|
+
let result = query;
|
|
15
|
+
for (const value of values) {
|
|
16
|
+
result = result.replace(/\?/, toSqlValue(value));
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
class CloudflareHttpD1PreparedStatement {
|
|
21
|
+
constructor(endpoint, apiToken, fetchImpl, query) {
|
|
22
|
+
this.endpoint = endpoint;
|
|
23
|
+
this.apiToken = apiToken;
|
|
24
|
+
this.fetchImpl = fetchImpl;
|
|
25
|
+
this.query = query;
|
|
26
|
+
}
|
|
27
|
+
endpoint;
|
|
28
|
+
apiToken;
|
|
29
|
+
fetchImpl;
|
|
30
|
+
query;
|
|
31
|
+
bindings = [];
|
|
32
|
+
bind(...values) {
|
|
33
|
+
this.bindings = values;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
async execute() {
|
|
37
|
+
const response = await this.fetchImpl(this.endpoint, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
authorization: `Bearer ${this.apiToken}`,
|
|
41
|
+
"content-type": "application/json"
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
sql: this.query,
|
|
45
|
+
params: this.bindings
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
const payload = await response.json().catch(() => ({}));
|
|
49
|
+
if (!response.ok || payload.success === false || payload.errors?.length) {
|
|
50
|
+
const message = payload.errors?.[0]?.message || `Cloudflare D1 request failed with ${response.status}.`;
|
|
51
|
+
throw new Error(message);
|
|
52
|
+
}
|
|
53
|
+
return payload.result ?? [];
|
|
54
|
+
}
|
|
55
|
+
async run() {
|
|
56
|
+
return this.execute();
|
|
57
|
+
}
|
|
58
|
+
async all() {
|
|
59
|
+
const result = await this.execute();
|
|
60
|
+
return {
|
|
61
|
+
results: result.flatMap((entry) => entry.results ?? [])
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async first() {
|
|
65
|
+
const { results } = await this.all();
|
|
66
|
+
return results[0] ?? null;
|
|
67
|
+
}
|
|
68
|
+
async raw() {
|
|
69
|
+
const { results } = await this.all();
|
|
70
|
+
return results.map((entry) => Object.values(entry));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class CloudflareHttpD1Database {
|
|
74
|
+
constructor(options) {
|
|
75
|
+
this.options = options;
|
|
76
|
+
this.endpoint = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/d1/database/${options.databaseId}/query`;
|
|
77
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
78
|
+
}
|
|
79
|
+
options;
|
|
80
|
+
endpoint;
|
|
81
|
+
fetchImpl;
|
|
82
|
+
prepare(query) {
|
|
83
|
+
return new CloudflareHttpD1PreparedStatement(this.endpoint, this.options.apiToken, this.fetchImpl, query);
|
|
84
|
+
}
|
|
85
|
+
async exec(query) {
|
|
86
|
+
return this.prepare(query).run();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function interpolateD1Query(query, bindings) {
|
|
90
|
+
return interpolateBindings(query, bindings);
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
CloudflareHttpD1Database,
|
|
94
|
+
interpolateD1Query
|
|
95
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export type * from './operations-types.ts';
|
|
|
19
19
|
export type * from './workflow.ts';
|
|
20
20
|
export type { AgentDatabase } from './d1-store.ts';
|
|
21
21
|
export type { D1DatabaseLike, D1PreparedStatementLike } from './types/cloudflare.ts';
|
|
22
|
+
export { CloudflareHttpD1Database } from './d1-http.ts';
|
|
22
23
|
export type * from './remote.ts';
|
package/dist/index.js
CHANGED
|
@@ -47,9 +47,11 @@ import {
|
|
|
47
47
|
import { TreeseedOperationsSdk } from "./operations/runtime.js";
|
|
48
48
|
import { TreeseedWorkflowSdk } from "./workflow.js";
|
|
49
49
|
import { getTreeseedVerifyDriverStatus, runTreeseedVerifyDriver } from "./verification.js";
|
|
50
|
+
import { CloudflareHttpD1Database } from "./d1-http.js";
|
|
50
51
|
export {
|
|
51
52
|
AgentSdk,
|
|
52
53
|
BUILTIN_MODEL_REGISTRY,
|
|
54
|
+
CloudflareHttpD1Database,
|
|
53
55
|
CloudflareQueuePullClient,
|
|
54
56
|
ContentGraphRuntime,
|
|
55
57
|
DEFAULT_GRAPH_RANKING_PROVIDER,
|
|
@@ -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;
|
|
@@ -31,7 +31,7 @@ const TREESEED_DEFAULT_PROVIDER_SELECTIONS = {
|
|
|
31
31
|
site: "default"
|
|
32
32
|
};
|
|
33
33
|
const TRESEED_MANAGED_SERVICE_KEYS = ["api", "agents", "gateway", "manager", "worker", "workdayStart", "workdayReport"];
|
|
34
|
-
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli", "agent"
|
|
34
|
+
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli", "agent"];
|
|
35
35
|
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
36
36
|
function parseServiceEnvironmentConfig(value) {
|
|
37
37
|
const record = optionalRecord(value, "service environment") ?? {};
|
|
@@ -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")
|
|
@@ -2,7 +2,7 @@ import type { TreeseedDeployConfig, TreeseedTenantConfig } from './contracts.ts'
|
|
|
2
2
|
import { type LoadedTreeseedPluginEntry } from './plugins.ts';
|
|
3
3
|
export declare const TREESEED_ENVIRONMENT_SCOPES: readonly ["local", "staging", "prod"];
|
|
4
4
|
export declare const TREESEED_ENVIRONMENT_REQUIREMENTS: readonly ["required", "conditional", "optional"];
|
|
5
|
-
export declare const TREESEED_ENVIRONMENT_TARGETS: readonly ["local-file", "wrangler-dev-vars", "github-secret", "github-variable", "cloudflare-secret", "cloudflare-var", "railway-secret", "config-file"];
|
|
5
|
+
export declare const TREESEED_ENVIRONMENT_TARGETS: readonly ["local-file", "wrangler-dev-vars", "github-secret", "github-variable", "cloudflare-secret", "cloudflare-var", "railway-secret", "railway-var", "config-file"];
|
|
6
6
|
export declare const TREESEED_ENVIRONMENT_PURPOSES: readonly ["dev", "save", "deploy", "destroy", "config"];
|
|
7
7
|
export declare const TREESEED_ENVIRONMENT_SENSITIVITY: readonly ["secret", "plain", "derived"];
|
|
8
8
|
export type TreeseedEnvironmentScope = (typeof TREESEED_ENVIRONMENT_SCOPES)[number];
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -196,6 +196,10 @@
|
|
|
196
196
|
"types": "./dist/wrangler-d1.d.ts",
|
|
197
197
|
"default": "./dist/wrangler-d1.js"
|
|
198
198
|
},
|
|
199
|
+
"./d1-http": {
|
|
200
|
+
"types": "./dist/d1-http.d.ts",
|
|
201
|
+
"default": "./dist/d1-http.js"
|
|
202
|
+
},
|
|
199
203
|
"./stores/cursor-store": {
|
|
200
204
|
"types": "./dist/stores/cursor-store.d.ts",
|
|
201
205
|
"default": "./dist/stores/cursor-store.js"
|