@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
|
@@ -43,6 +43,27 @@ function railwayManagedEnabled(context) {
|
|
|
43
43
|
(service) => service && service.enabled !== false && (service.provider ?? "railway") === "railway"
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
+
function resolveHostingKind(context) {
|
|
47
|
+
return context.deployConfig.hosting?.kind ?? "self_hosted_project";
|
|
48
|
+
}
|
|
49
|
+
function resolveHostingRegistration(context) {
|
|
50
|
+
return context.deployConfig.hosting?.registration ?? "none";
|
|
51
|
+
}
|
|
52
|
+
function marketControlPlaneEnabled(context) {
|
|
53
|
+
return resolveHostingKind(context) === "market_control_plane";
|
|
54
|
+
}
|
|
55
|
+
function hostedProjectEnabled(context) {
|
|
56
|
+
return resolveHostingKind(context) === "hosted_project";
|
|
57
|
+
}
|
|
58
|
+
function selfHostedProjectEnabled(context) {
|
|
59
|
+
return resolveHostingKind(context) === "self_hosted_project";
|
|
60
|
+
}
|
|
61
|
+
function projectRegistrationEnabled(context) {
|
|
62
|
+
if (hostedProjectEnabled(context)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return selfHostedProjectEnabled(context) && resolveHostingRegistration(context) === "optional";
|
|
66
|
+
}
|
|
46
67
|
function generatedSecret(bytes = 24) {
|
|
47
68
|
return randomBytes(bytes).toString("hex");
|
|
48
69
|
}
|
|
@@ -102,20 +123,54 @@ function resolveWebServiceId(_values = {}) {
|
|
|
102
123
|
function resolveApiWebServiceId(values = {}) {
|
|
103
124
|
return values.TREESEED_WEB_SERVICE_ID?.trim() || "web";
|
|
104
125
|
}
|
|
126
|
+
function resolvePagesProjectName(context) {
|
|
127
|
+
return context.deployConfig.cloudflare.pages?.projectName?.trim() || context.deployConfig.slug;
|
|
128
|
+
}
|
|
129
|
+
function resolvePagesPreviewProjectName(context) {
|
|
130
|
+
return context.deployConfig.cloudflare.pages?.previewProjectName?.trim() || `${context.deployConfig.cloudflare.pages?.projectName?.trim() || context.deployConfig.slug}-staging`;
|
|
131
|
+
}
|
|
132
|
+
function resolveContentBucketName(context) {
|
|
133
|
+
return context.deployConfig.cloudflare.r2?.bucketName?.trim() || `${context.deployConfig.slug}-content`;
|
|
134
|
+
}
|
|
135
|
+
function resolveContentBucketBinding(context) {
|
|
136
|
+
return context.deployConfig.cloudflare.r2?.binding?.trim() || "TREESEED_CONTENT_BUCKET";
|
|
137
|
+
}
|
|
138
|
+
function resolveMarketBaseUrl(context) {
|
|
139
|
+
return context.deployConfig.hosting?.marketBaseUrl?.trim() || context.deployConfig.services?.api?.environments?.prod?.baseUrl?.trim() || context.deployConfig.services?.api?.publicBaseUrl?.trim() || "https://api.treeseed.ai";
|
|
140
|
+
}
|
|
141
|
+
function resolveHostedTeamId(context) {
|
|
142
|
+
return context.deployConfig.hosting?.teamId?.trim() || context.deployConfig.slug;
|
|
143
|
+
}
|
|
144
|
+
function resolveHostedProjectId(context) {
|
|
145
|
+
return context.deployConfig.hosting?.projectId?.trim() || context.deployConfig.slug;
|
|
146
|
+
}
|
|
105
147
|
const VALUE_RESOLVERS = {
|
|
106
148
|
generatedSecret: () => generatedSecret(),
|
|
107
149
|
localFormsBypassDefault: () => "true",
|
|
108
150
|
projectDomainsDefault: (context) => primaryHostFromUrl(context.deployConfig.siteUrl),
|
|
109
151
|
apiBaseUrlDefault: (context, scope, values) => resolveConfiguredApiBaseUrl(context, scope, values),
|
|
110
152
|
webServiceIdDefault: (_context, _scope, values) => resolveWebServiceId(values),
|
|
111
|
-
apiWebServiceIdDefault: (_context, _scope, values) => resolveApiWebServiceId(values)
|
|
153
|
+
apiWebServiceIdDefault: (_context, _scope, values) => resolveApiWebServiceId(values),
|
|
154
|
+
pagesProjectNameDefault: (context) => resolvePagesProjectName(context),
|
|
155
|
+
pagesPreviewProjectNameDefault: (context) => resolvePagesPreviewProjectName(context),
|
|
156
|
+
contentBucketNameDefault: (context) => resolveContentBucketName(context),
|
|
157
|
+
contentBucketBindingDefault: (context) => resolveContentBucketBinding(context),
|
|
158
|
+
hostingKindDefault: (context) => resolveHostingKind(context),
|
|
159
|
+
hostingRegistrationDefault: (context) => resolveHostingRegistration(context),
|
|
160
|
+
marketBaseUrlDefault: (context) => resolveMarketBaseUrl(context),
|
|
161
|
+
hostingTeamIdDefault: (context) => resolveHostedTeamId(context),
|
|
162
|
+
hostingProjectIdDefault: (context) => resolveHostedProjectId(context)
|
|
112
163
|
};
|
|
113
164
|
const PREDICATES = {
|
|
114
165
|
turnstileEnabled: (context) => turnstileEnabled(context),
|
|
115
166
|
turnstileNonLocal: (context, scope) => turnstileEnabled(context) && scope !== "local",
|
|
116
167
|
smtpEnabled: (context) => smtpEnabled(context),
|
|
117
168
|
smtpNonLocal: (context, scope) => smtpEnabled(context) && scope !== "local",
|
|
118
|
-
railwayManagedEnabled: (context) => railwayManagedEnabled(context)
|
|
169
|
+
railwayManagedEnabled: (context) => railwayManagedEnabled(context),
|
|
170
|
+
marketControlPlaneEnabled: (context) => marketControlPlaneEnabled(context),
|
|
171
|
+
hostedProjectEnabled: (context) => hostedProjectEnabled(context),
|
|
172
|
+
selfHostedProjectEnabled: (context) => selfHostedProjectEnabled(context),
|
|
173
|
+
projectRegistrationEnabled: (context) => projectRegistrationEnabled(context)
|
|
119
174
|
};
|
|
120
175
|
function deepMerge(left, right) {
|
|
121
176
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
@@ -60,6 +60,9 @@ export type TreeseedPluginEnvironmentContext = {
|
|
|
60
60
|
deployConfig?: TreeseedDeployConfig;
|
|
61
61
|
pluginConfig: Record<string, unknown>;
|
|
62
62
|
};
|
|
63
|
+
export type TreeseedContentProviderContext = TreeseedPluginEnvironmentContext & {
|
|
64
|
+
tenantConfig: TreeseedTenantConfig;
|
|
65
|
+
};
|
|
63
66
|
export type TreeseedGraphRankingProviderContribution = SdkGraphRankingProvider | ((context: TreeseedPluginEnvironmentContext) => SdkGraphRankingProvider | undefined);
|
|
64
67
|
export interface TreeseedPlugin {
|
|
65
68
|
id?: string;
|
|
@@ -68,6 +71,11 @@ export interface TreeseedPlugin {
|
|
|
68
71
|
};
|
|
69
72
|
operationProviders?: Record<string, unknown>;
|
|
70
73
|
siteProviders?: Record<string, TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution)>;
|
|
74
|
+
contentProviders?: {
|
|
75
|
+
runtime?: Record<string, unknown>;
|
|
76
|
+
publish?: Record<string, unknown>;
|
|
77
|
+
docs?: Record<string, unknown>;
|
|
78
|
+
};
|
|
71
79
|
siteHooks?: TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution);
|
|
72
80
|
siteLayers?: TreeseedSiteLayerDefinition[] | ((context: TreeseedPluginSiteContext) => TreeseedSiteLayerDefinition[] | undefined);
|
|
73
81
|
platformProviders?: Record<TreeseedPlatformSurfaceName, Record<string, TreeseedPlatformExtensionContribution | ((context: TreeseedPluginPlatformContext) => TreeseedPlatformExtensionContribution)>>;
|
|
@@ -107,6 +107,8 @@ function collectProvidedIds(plugins) {
|
|
|
107
107
|
},
|
|
108
108
|
deploy: /* @__PURE__ */ new Set(),
|
|
109
109
|
content: {
|
|
110
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
111
|
+
publish: /* @__PURE__ */ new Set(),
|
|
110
112
|
docs: /* @__PURE__ */ new Set()
|
|
111
113
|
},
|
|
112
114
|
site: /* @__PURE__ */ new Set()
|
|
@@ -122,6 +124,8 @@ function collectProvidedIds(plugins) {
|
|
|
122
124
|
for (const id of plugin.provides?.agents?.research ?? []) provided.agents.research.add(id);
|
|
123
125
|
for (const id of plugin.provides?.agents?.handlers ?? []) provided.agents.handlers.add(id);
|
|
124
126
|
for (const id of plugin.provides?.deploy ?? []) provided.deploy.add(id);
|
|
127
|
+
for (const id of plugin.provides?.content?.runtime ?? []) provided.content.runtime.add(id);
|
|
128
|
+
for (const id of plugin.provides?.content?.publish ?? []) provided.content.publish.add(id);
|
|
125
129
|
for (const id of plugin.provides?.content?.docs ?? []) provided.content.docs.add(id);
|
|
126
130
|
for (const id of plugin.provides?.site ?? []) provided.site.add(id);
|
|
127
131
|
}
|
|
@@ -148,7 +152,11 @@ function loadTreeseedPluginRuntime(config = loadTreeseedDeployConfig()) {
|
|
|
148
152
|
assertSelectedProvider(provided.agents.notification, "agents.notification", providers.agents.notification);
|
|
149
153
|
assertSelectedProvider(provided.agents.research, "agents.research", providers.agents.research);
|
|
150
154
|
assertSelectedProvider(provided.deploy, "deploy", providers.deploy);
|
|
151
|
-
assertSelectedProvider(provided.content.
|
|
155
|
+
assertSelectedProvider(provided.content.runtime, "content.runtime", providers.content?.runtime);
|
|
156
|
+
assertSelectedProvider(provided.content.publish, "content.publish", providers.content?.publish);
|
|
157
|
+
if (providers.content?.docs) {
|
|
158
|
+
assertSelectedProvider(provided.content.docs, "content.docs", providers.content.docs);
|
|
159
|
+
}
|
|
152
160
|
assertSelectedProvider(provided.site, "site", providers.site);
|
|
153
161
|
return {
|
|
154
162
|
config,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { TREESEED_DEFAULT_PLUGIN_PACKAGE, TREESEED_DEFAULT_PLUGIN_REFERENCES, TREESEED_DEFAULT_PROVIDER_SELECTIONS, } from './plugins/constants.ts';
|
|
2
|
-
export { getTreeseedAgentProviderSelections, getTreeseedDeployConfig, getTreeseedDeployProvider, getTreeseedDocsProvider, getTreeseedFormsProvider, getTreeseedOperationsProvider, getTreeseedSiteProvider, isTreeseedSmtpEnabled, isTreeseedTurnstileEnabled, resetTreeseedDeployConfigForTests, } from './deploy-runtime.ts';
|
|
2
|
+
export { getTreeseedAgentProviderSelections, getTreeseedContentPublishProvider, getTreeseedContentRuntimeProvider, getTreeseedDeployConfig, getTreeseedDeployProvider, getTreeseedDocsProvider, getTreeseedFormsProvider, getTreeseedOperationsProvider, getTreeseedSiteProvider, isTreeseedSmtpEnabled, isTreeseedTurnstileEnabled, resetTreeseedDeployConfigForTests, } from './deploy-runtime.ts';
|
|
3
3
|
export { defineTreeseedPlugin } from './plugin.ts';
|
|
4
4
|
export type * from './plugin.ts';
|
|
5
5
|
export { loadTreeseedPluginRuntime, loadTreeseedPlugins, resolveTreeseedGraphRankingProvider } from './plugins/runtime.ts';
|
package/dist/platform/plugins.js
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
} from "./plugins/constants.js";
|
|
6
6
|
import {
|
|
7
7
|
getTreeseedAgentProviderSelections,
|
|
8
|
+
getTreeseedContentPublishProvider,
|
|
9
|
+
getTreeseedContentRuntimeProvider,
|
|
8
10
|
getTreeseedDeployConfig,
|
|
9
11
|
getTreeseedDeployProvider,
|
|
10
12
|
getTreeseedDocsProvider,
|
|
@@ -23,6 +25,8 @@ export {
|
|
|
23
25
|
TREESEED_DEFAULT_PROVIDER_SELECTIONS,
|
|
24
26
|
defineTreeseedPlugin,
|
|
25
27
|
getTreeseedAgentProviderSelections,
|
|
28
|
+
getTreeseedContentPublishProvider,
|
|
29
|
+
getTreeseedContentRuntimeProvider,
|
|
26
30
|
getTreeseedDeployConfig,
|
|
27
31
|
getTreeseedDeployProvider,
|
|
28
32
|
getTreeseedDocsProvider,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { TreeseedDeployConfig, TreeseedTenantConfig } from './contracts.ts';
|
|
2
|
+
import { type PublishContentObjectInput, type PublishedArtifactVersion, type PublishedCollectionIndex, type PublishedContentEntry, type PublishedContentManifest, type PublishedOverlayManifest, type PublishedRuntimePointers, type PublishedContentVisibility } from './published-content.ts';
|
|
3
|
+
import type { CatalogIndexEntry } from './published-content.ts';
|
|
4
|
+
export interface ContentSourceEntry {
|
|
5
|
+
model: string;
|
|
6
|
+
id: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
summary?: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
visibility?: PublishedContentVisibility;
|
|
12
|
+
frontmatter: Record<string, unknown>;
|
|
13
|
+
body: string;
|
|
14
|
+
relativePath: string;
|
|
15
|
+
filePath: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ContentSource {
|
|
19
|
+
listEntries(): Promise<ContentSourceEntry[]>;
|
|
20
|
+
}
|
|
21
|
+
export interface RenderedContentEntry {
|
|
22
|
+
entry: PublishedContentEntry;
|
|
23
|
+
objects: PublishContentObjectInput[];
|
|
24
|
+
searchText: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EntryRenderer {
|
|
27
|
+
render(entry: ContentSourceEntry, context: PublishedContentPipelineContext): Promise<RenderedContentEntry>;
|
|
28
|
+
}
|
|
29
|
+
export interface CollectionIndexBuilder {
|
|
30
|
+
build(model: string, entries: PublishedContentEntry[], context: PublishedContentPipelineContext): Promise<{
|
|
31
|
+
index: PublishedCollectionIndex;
|
|
32
|
+
object: PublishContentObjectInput;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export interface RuntimeBundleBuilderResult {
|
|
36
|
+
runtime: PublishedRuntimePointers;
|
|
37
|
+
objects: PublishContentObjectInput[];
|
|
38
|
+
}
|
|
39
|
+
export interface RuntimeBundleBuilder {
|
|
40
|
+
build(context: PublishedContentPipelineContext, entries: PublishedContentEntry[]): Promise<RuntimeBundleBuilderResult>;
|
|
41
|
+
}
|
|
42
|
+
export interface ArtifactBuilderResult {
|
|
43
|
+
artifacts: PublishedArtifactVersion[];
|
|
44
|
+
objects: PublishContentObjectInput[];
|
|
45
|
+
catalog?: CatalogIndexEntry[];
|
|
46
|
+
}
|
|
47
|
+
export interface ArtifactBuilder {
|
|
48
|
+
build(context: PublishedContentPipelineContext, entries: PublishedContentEntry[]): Promise<ArtifactBuilderResult>;
|
|
49
|
+
}
|
|
50
|
+
export interface PublishedContentPipelineContext {
|
|
51
|
+
projectRoot: string;
|
|
52
|
+
siteConfig: TreeseedDeployConfig;
|
|
53
|
+
tenantConfig: TreeseedTenantConfig;
|
|
54
|
+
teamId: string;
|
|
55
|
+
generatedAt: string;
|
|
56
|
+
sourceCommit?: string | null;
|
|
57
|
+
sourceRef?: string | null;
|
|
58
|
+
previewId?: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface PublishedContentPipeline {
|
|
61
|
+
buildProductionRevision(options?: {
|
|
62
|
+
previousManifest?: PublishedContentManifest | null;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
manifest: PublishedContentManifest;
|
|
65
|
+
objects: PublishContentObjectInput[];
|
|
66
|
+
catalog: CatalogIndexEntry[];
|
|
67
|
+
}>;
|
|
68
|
+
buildEditorialOverlay(options?: {
|
|
69
|
+
previousManifest?: PublishedContentManifest | null;
|
|
70
|
+
previewId: string;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
overlay: PublishedOverlayManifest;
|
|
73
|
+
objects: PublishContentObjectInput[];
|
|
74
|
+
catalog: CatalogIndexEntry[];
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
export declare function createFilesystemContentSource(tenantConfig: TreeseedTenantConfig): ContentSource;
|
|
78
|
+
export declare function createPublishedContentPipeline(context: PublishedContentPipelineContext, options?: {
|
|
79
|
+
contentSource?: ContentSource;
|
|
80
|
+
entryRenderer?: EntryRenderer;
|
|
81
|
+
collectionIndexBuilder?: CollectionIndexBuilder;
|
|
82
|
+
runtimeBundleBuilder?: RuntimeBundleBuilder;
|
|
83
|
+
artifactBuilder?: ArtifactBuilder;
|
|
84
|
+
}): PublishedContentPipeline;
|