@treeseed/core 0.4.9 → 0.4.11
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 -2
- package/dist/agent.d.ts +0 -1
- package/dist/agent.js +0 -2
- package/dist/agents/spec-types.d.ts +10 -10
- package/dist/api/agent-routes.d.ts +2 -2
- package/dist/api/agent-routes.js +51 -125
- package/dist/api/app.js +56 -4
- package/dist/api/auth/d1-store.d.ts +1 -0
- package/dist/api/auth/d1-store.js +21 -1
- package/dist/api/auth/rbac.d.ts +2 -2
- package/dist/api/auth/rbac.js +2 -1
- package/dist/api/config.js +4 -0
- package/dist/api/http.d.ts +4 -0
- package/dist/api/http.js +7 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/operations-routes.d.ts +1 -0
- package/dist/api/operations-routes.js +6 -1
- package/dist/api/railway.d.ts +4 -0
- package/dist/api/sdk-dispatch.d.ts +2 -11
- package/dist/api/sdk-dispatch.js +1 -133
- package/dist/api/sdk-routes.d.ts +1 -0
- package/dist/api/sdk-routes.js +5 -1
- package/dist/api/types.d.ts +32 -16
- package/dist/components/site/RouteNotFound.astro +25 -0
- package/dist/content-config.d.ts +1 -0
- package/dist/content.d.ts +1 -0
- package/dist/content.js +177 -1
- package/dist/dev.d.ts +7 -2
- package/dist/dev.js +83 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -3
- package/dist/middleware/editorial-preview.d.ts +26 -0
- package/dist/middleware/editorial-preview.js +37 -0
- package/dist/middleware/starlightRouteData.js +15 -4
- package/dist/pages/[slug].astro +12 -10
- package/dist/pages/agents/[slug].astro +28 -21
- package/dist/pages/books/[slug].astro +19 -12
- package/dist/pages/feed.xml.js +6 -4
- package/dist/pages/index.astro +43 -14
- package/dist/pages/notes/[slug].astro +19 -12
- package/dist/pages/objectives/[slug].astro +30 -23
- package/dist/pages/people/[slug].astro +28 -21
- package/dist/pages/questions/[slug].astro +30 -23
- package/dist/scripts/build-dist.js +6 -1
- package/dist/scripts/dev-platform.js +9 -1
- package/dist/scripts/test-smoke.js +0 -1
- package/dist/services/agents.d.ts +22 -0
- package/dist/services/agents.js +29 -0
- package/dist/services/common.d.ts +37 -4
- package/dist/services/common.js +135 -17
- package/dist/services/index.d.ts +4 -1
- package/dist/services/index.js +14 -2
- package/dist/services/manager.d.ts +246 -3
- package/dist/services/manager.js +1101 -171
- package/dist/services/remote-runner.d.ts +30 -0
- package/dist/services/remote-runner.js +111 -0
- package/dist/services/workday-content.d.ts +53 -0
- package/dist/services/workday-content.js +190 -0
- package/dist/services/workday-report.d.ts +160 -2
- package/dist/services/workday-report.js +4 -31
- package/dist/services/workday-start.d.ts +174 -1
- package/dist/services/workday-start.js +3 -13
- package/dist/services/worker-pool-scaler.d.ts +27 -0
- package/dist/services/worker-pool-scaler.js +109 -0
- package/dist/services/worker.d.ts +7 -0
- package/dist/services/worker.js +41 -57
- package/dist/site.js +43 -27
- package/dist/templates.d.ts +98 -0
- package/dist/templates.js +170 -0
- package/dist/tenant/runtime-config.d.ts +4 -0
- package/dist/tenant/runtime-config.js +34 -1
- package/dist/utils/hub-content.js +35 -0
- package/dist/utils/published-content.js +60 -0
- package/dist/utils/site-models.d.ts +6 -0
- package/dist/utils/site-models.js +16 -0
- package/dist/utils/starlight-nav.js +50 -0
- package/package.json +23 -9
- package/templates/github/deploy.workflow.yml +404 -9
- package/templates/github/hosted-project.workflow.yml +77 -0
- package/dist/api/gateway.d.ts +0 -5
- package/dist/api/gateway.js +0 -35
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CatalogItem, CatalogItemOfferMode } from '@treeseed/sdk/types';
|
|
2
|
+
export interface TemplateContentEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
data: {
|
|
5
|
+
slug: string;
|
|
6
|
+
title: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
description: string;
|
|
9
|
+
status: string;
|
|
10
|
+
category: string;
|
|
11
|
+
featured?: boolean;
|
|
12
|
+
publisher: {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
templateVersion: string;
|
|
16
|
+
templateApiVersion: number;
|
|
17
|
+
minCliVersion: string;
|
|
18
|
+
minCoreVersion: string;
|
|
19
|
+
offer?: {
|
|
20
|
+
priceModel?: CatalogItemOfferMode | string;
|
|
21
|
+
};
|
|
22
|
+
fulfillment: {
|
|
23
|
+
mode?: string;
|
|
24
|
+
source: {
|
|
25
|
+
kind: 'git';
|
|
26
|
+
repoUrl: string;
|
|
27
|
+
directory: string;
|
|
28
|
+
ref: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'r2';
|
|
31
|
+
objectKey: string;
|
|
32
|
+
version: string;
|
|
33
|
+
publicUrl?: string;
|
|
34
|
+
};
|
|
35
|
+
hooksPolicy?: string;
|
|
36
|
+
supportsReconcile?: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface TemplateCatalogProviderContext {
|
|
42
|
+
locals?: object | null | undefined;
|
|
43
|
+
}
|
|
44
|
+
export interface TemplateCatalogProvider {
|
|
45
|
+
listItems?(context: TemplateCatalogProviderContext): Promise<CatalogItem[]>;
|
|
46
|
+
getItemBySlug?(slug: string, context: TemplateCatalogProviderContext): Promise<CatalogItem | null>;
|
|
47
|
+
}
|
|
48
|
+
export interface TemplateSiteCard {
|
|
49
|
+
slug: string;
|
|
50
|
+
title: string;
|
|
51
|
+
summary: string;
|
|
52
|
+
category: string;
|
|
53
|
+
featured: boolean;
|
|
54
|
+
publisherName: string;
|
|
55
|
+
templateVersion?: string;
|
|
56
|
+
priceModel?: CatalogItemOfferMode | string;
|
|
57
|
+
source: 'catalog' | 'content';
|
|
58
|
+
}
|
|
59
|
+
export interface TemplateSiteDetail extends TemplateSiteCard {
|
|
60
|
+
description: string;
|
|
61
|
+
compatibility: {
|
|
62
|
+
templateVersion?: string;
|
|
63
|
+
templateApiVersion?: number | string;
|
|
64
|
+
minCliVersion?: string;
|
|
65
|
+
minCoreVersion?: string;
|
|
66
|
+
};
|
|
67
|
+
fulfillment: {
|
|
68
|
+
mode: string;
|
|
69
|
+
sourceLabel: string;
|
|
70
|
+
artifactKey?: string | null;
|
|
71
|
+
manifestKey?: string | null;
|
|
72
|
+
repoUrl?: string;
|
|
73
|
+
directory?: string;
|
|
74
|
+
ref?: string;
|
|
75
|
+
objectKey?: string;
|
|
76
|
+
version?: string;
|
|
77
|
+
publicUrl?: string;
|
|
78
|
+
hooksPolicy?: string | null;
|
|
79
|
+
supportsReconcile?: boolean | null;
|
|
80
|
+
};
|
|
81
|
+
contentEntry: TemplateContentEntry | null;
|
|
82
|
+
catalogItem: CatalogItem | null;
|
|
83
|
+
}
|
|
84
|
+
type TemplateSourceOptions = TemplateCatalogProviderContext & {
|
|
85
|
+
catalogProvider?: TemplateCatalogProvider | null;
|
|
86
|
+
listLocalEntries?: (() => Promise<TemplateContentEntry[]>) | null;
|
|
87
|
+
};
|
|
88
|
+
export interface TemplateSiteListingResult {
|
|
89
|
+
rendered: boolean;
|
|
90
|
+
items: TemplateSiteCard[];
|
|
91
|
+
}
|
|
92
|
+
export interface ResolvedSiteTemplateResult {
|
|
93
|
+
rendered: boolean;
|
|
94
|
+
item: TemplateSiteDetail | null;
|
|
95
|
+
}
|
|
96
|
+
export declare function listSiteTemplates(context?: TemplateSourceOptions): Promise<TemplateSiteListingResult>;
|
|
97
|
+
export declare function resolveSiteTemplate(slug: string, context?: TemplateSourceOptions): Promise<ResolvedSiteTemplateResult>;
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { getCollection } from "astro:content";
|
|
2
|
+
import { RUNTIME_TENANT } from "./tenant/runtime-config.js";
|
|
3
|
+
import { siteModelRendered } from "./utils/site-models.js";
|
|
4
|
+
function sortTemplateCards(entries) {
|
|
5
|
+
return [...entries].sort((left, right) => {
|
|
6
|
+
const featuredDelta = Number(Boolean(right.featured)) - Number(Boolean(left.featured));
|
|
7
|
+
if (featuredDelta !== 0) {
|
|
8
|
+
return featuredDelta;
|
|
9
|
+
}
|
|
10
|
+
return String(left.title ?? "").localeCompare(String(right.title ?? ""), void 0, { sensitivity: "base" });
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async function listLocalTemplateEntries(listLocalEntries) {
|
|
14
|
+
if (typeof listLocalEntries === "function") {
|
|
15
|
+
return listLocalEntries();
|
|
16
|
+
}
|
|
17
|
+
if (!RUNTIME_TENANT.content.templates) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return getCollection("templates");
|
|
21
|
+
}
|
|
22
|
+
function catalogString(metadata, key) {
|
|
23
|
+
const value = metadata?.[key];
|
|
24
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function catalogNumber(metadata, key) {
|
|
27
|
+
const value = metadata?.[key];
|
|
28
|
+
return typeof value === "number" ? value : void 0;
|
|
29
|
+
}
|
|
30
|
+
function contentCardFromEntry(entry) {
|
|
31
|
+
if (entry.data.status !== "live") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
slug: entry.data.slug,
|
|
36
|
+
title: entry.data.title,
|
|
37
|
+
summary: entry.data.summary,
|
|
38
|
+
category: entry.data.category,
|
|
39
|
+
featured: entry.data.featured === true,
|
|
40
|
+
publisherName: entry.data.publisher.name,
|
|
41
|
+
templateVersion: entry.data.templateVersion,
|
|
42
|
+
priceModel: entry.data.offer?.priceModel,
|
|
43
|
+
source: "content"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function detailFromContentEntry(entry) {
|
|
47
|
+
const source = entry.data.fulfillment.source;
|
|
48
|
+
return {
|
|
49
|
+
...contentCardFromEntry(entry),
|
|
50
|
+
description: entry.data.description,
|
|
51
|
+
compatibility: {
|
|
52
|
+
templateVersion: entry.data.templateVersion,
|
|
53
|
+
templateApiVersion: entry.data.templateApiVersion,
|
|
54
|
+
minCliVersion: entry.data.minCliVersion,
|
|
55
|
+
minCoreVersion: entry.data.minCoreVersion
|
|
56
|
+
},
|
|
57
|
+
fulfillment: source.kind === "r2" ? {
|
|
58
|
+
mode: entry.data.fulfillment.mode ?? "r2",
|
|
59
|
+
sourceLabel: "R2 artifact",
|
|
60
|
+
objectKey: source.objectKey,
|
|
61
|
+
version: source.version,
|
|
62
|
+
publicUrl: source.publicUrl,
|
|
63
|
+
hooksPolicy: entry.data.fulfillment.hooksPolicy,
|
|
64
|
+
supportsReconcile: entry.data.fulfillment.supportsReconcile
|
|
65
|
+
} : {
|
|
66
|
+
mode: entry.data.fulfillment.mode ?? "git",
|
|
67
|
+
sourceLabel: "Git",
|
|
68
|
+
repoUrl: source.repoUrl,
|
|
69
|
+
directory: source.directory,
|
|
70
|
+
ref: source.ref,
|
|
71
|
+
hooksPolicy: entry.data.fulfillment.hooksPolicy,
|
|
72
|
+
supportsReconcile: entry.data.fulfillment.supportsReconcile
|
|
73
|
+
},
|
|
74
|
+
contentEntry: entry,
|
|
75
|
+
catalogItem: null
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function cardFromCatalogItem(item) {
|
|
79
|
+
return {
|
|
80
|
+
slug: item.slug,
|
|
81
|
+
title: item.title,
|
|
82
|
+
summary: item.summary ?? "",
|
|
83
|
+
category: catalogString(item.metadata, "category") ?? "Template",
|
|
84
|
+
featured: item.metadata?.featured === true,
|
|
85
|
+
publisherName: catalogString(item.metadata, "publisherName") ?? item.teamId,
|
|
86
|
+
templateVersion: catalogString(item.metadata, "templateVersion"),
|
|
87
|
+
priceModel: item.offerMode,
|
|
88
|
+
source: "catalog"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function detailFromCatalogItem(item) {
|
|
92
|
+
return {
|
|
93
|
+
...cardFromCatalogItem(item),
|
|
94
|
+
description: item.summary ?? "This template is managed through the central market catalog.",
|
|
95
|
+
compatibility: {
|
|
96
|
+
templateVersion: catalogString(item.metadata, "templateVersion"),
|
|
97
|
+
templateApiVersion: catalogNumber(item.metadata, "templateApiVersion"),
|
|
98
|
+
minCliVersion: catalogString(item.metadata, "minCliVersion"),
|
|
99
|
+
minCoreVersion: catalogString(item.metadata, "minCoreVersion")
|
|
100
|
+
},
|
|
101
|
+
fulfillment: {
|
|
102
|
+
mode: catalogString(item.metadata, "fulfillmentMode") ?? "r2",
|
|
103
|
+
sourceLabel: item.artifactKey ? "R2 artifact" : "Catalog metadata",
|
|
104
|
+
artifactKey: item.artifactKey,
|
|
105
|
+
manifestKey: item.manifestKey
|
|
106
|
+
},
|
|
107
|
+
contentEntry: null,
|
|
108
|
+
catalogItem: item
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function selectCatalogItemBySlug(slug, context) {
|
|
112
|
+
if (!context.catalogProvider) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (typeof context.catalogProvider.getItemBySlug === "function") {
|
|
116
|
+
return context.catalogProvider.getItemBySlug(slug, { locals: context.locals });
|
|
117
|
+
}
|
|
118
|
+
if (typeof context.catalogProvider.listItems === "function") {
|
|
119
|
+
const items = await context.catalogProvider.listItems({ locals: context.locals });
|
|
120
|
+
return items.find((item) => item.slug === slug) ?? null;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
async function listSiteTemplates(context = {}) {
|
|
125
|
+
if (!siteModelRendered("templates")) {
|
|
126
|
+
return {
|
|
127
|
+
rendered: false,
|
|
128
|
+
items: []
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const catalogItems = context.catalogProvider && typeof context.catalogProvider.listItems === "function" ? await context.catalogProvider.listItems({ locals: context.locals }) : [];
|
|
132
|
+
if (catalogItems.length > 0) {
|
|
133
|
+
return {
|
|
134
|
+
rendered: true,
|
|
135
|
+
items: sortTemplateCards(catalogItems.map(cardFromCatalogItem))
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const entries = await listLocalTemplateEntries(context.listLocalEntries);
|
|
139
|
+
return {
|
|
140
|
+
rendered: true,
|
|
141
|
+
items: sortTemplateCards(
|
|
142
|
+
entries.map(contentCardFromEntry).filter((entry) => Boolean(entry))
|
|
143
|
+
)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function resolveSiteTemplate(slug, context = {}) {
|
|
147
|
+
if (!siteModelRendered("templates")) {
|
|
148
|
+
return {
|
|
149
|
+
rendered: false,
|
|
150
|
+
item: null
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const catalogItem = await selectCatalogItemBySlug(slug, context);
|
|
154
|
+
if (catalogItem) {
|
|
155
|
+
return {
|
|
156
|
+
rendered: true,
|
|
157
|
+
item: detailFromCatalogItem(catalogItem)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const entries = await listLocalTemplateEntries(context.listLocalEntries);
|
|
161
|
+
const entry = entries.find((candidate) => candidate.data.slug === slug && candidate.data.status === "live") ?? null;
|
|
162
|
+
return {
|
|
163
|
+
rendered: true,
|
|
164
|
+
item: entry ? detailFromContentEntry(entry) : null
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
listSiteTemplates,
|
|
169
|
+
resolveSiteTemplate
|
|
170
|
+
};
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
2
3
|
import { loadTreeseedManifest } from "@treeseed/sdk/platform/tenant-config";
|
|
3
4
|
import { parseSiteConfig } from "../utils/site-config-schema.js";
|
|
4
5
|
const injectedTenantConfig = typeof __TREESEED_TENANT_CONFIG__ !== "undefined" ? __TREESEED_TENANT_CONFIG__ : null;
|
|
5
6
|
const injectedProjectRoot = typeof __TREESEED_PROJECT_ROOT__ !== "undefined" ? __TREESEED_PROJECT_ROOT__ : null;
|
|
6
7
|
const injectedSiteConfig = typeof __TREESEED_SITE_CONFIG__ !== "undefined" ? __TREESEED_SITE_CONFIG__ : null;
|
|
7
|
-
const RUNTIME_TENANT = injectedTenantConfig ?? loadTreeseedManifest();
|
|
8
8
|
const RUNTIME_PROJECT_ROOT = injectedProjectRoot ?? process.cwd();
|
|
9
|
+
function fallbackTenantConfig(projectRoot) {
|
|
10
|
+
return {
|
|
11
|
+
id: "treeseed-runtime",
|
|
12
|
+
siteConfigPath: resolve(projectRoot, "treeseed.site.yaml"),
|
|
13
|
+
content: {
|
|
14
|
+
pages: resolve(projectRoot, "src/content/pages"),
|
|
15
|
+
notes: resolve(projectRoot, "src/content/notes"),
|
|
16
|
+
questions: resolve(projectRoot, "src/content/questions"),
|
|
17
|
+
objectives: resolve(projectRoot, "src/content/objectives"),
|
|
18
|
+
people: resolve(projectRoot, "src/content/people"),
|
|
19
|
+
agents: resolve(projectRoot, "src/content/agents"),
|
|
20
|
+
books: resolve(projectRoot, "src/content/books"),
|
|
21
|
+
docs: resolve(projectRoot, "src/content/knowledge"),
|
|
22
|
+
templates: resolve(projectRoot, "src/content/templates"),
|
|
23
|
+
knowledge_packs: resolve(projectRoot, "src/content/knowledge-packs"),
|
|
24
|
+
workdays: resolve(projectRoot, "src/content/workdays")
|
|
25
|
+
},
|
|
26
|
+
features: {
|
|
27
|
+
docs: true,
|
|
28
|
+
books: true
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const RUNTIME_TENANT = (() => {
|
|
33
|
+
if (injectedTenantConfig) {
|
|
34
|
+
return injectedTenantConfig;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return loadTreeseedManifest();
|
|
38
|
+
} catch {
|
|
39
|
+
return fallbackTenantConfig(RUNTIME_PROJECT_ROOT);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
9
42
|
const RUNTIME_SITE_CONFIG = injectedSiteConfig ?? (() => {
|
|
10
43
|
try {
|
|
11
44
|
return parseSiteConfig(readFileSync(RUNTIME_TENANT.siteConfigPath, "utf8"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getCollection, getEntries, getEntry } from "astro:content";
|
|
2
|
+
import { siteModelRendered } from "./site-models.js";
|
|
2
3
|
function sortEntriesByDateDescending(entries) {
|
|
3
4
|
return [...entries].sort((left, right) => right.data.date.valueOf() - left.data.date.valueOf());
|
|
4
5
|
}
|
|
@@ -13,13 +14,47 @@ async function resolveReferences(references) {
|
|
|
13
14
|
return getEntries(references);
|
|
14
15
|
}
|
|
15
16
|
async function getPublishedQuestions() {
|
|
17
|
+
if (!siteModelRendered("questions")) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
16
20
|
return sortEntriesByDateDescending(await getCollection("questions", ({ data }) => !data.draft));
|
|
17
21
|
}
|
|
18
22
|
async function getPublishedObjectives() {
|
|
23
|
+
if (!siteModelRendered("objectives")) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
19
26
|
return sortEntriesByDateDescending(await getCollection("objectives", ({ data }) => !data.draft));
|
|
20
27
|
}
|
|
28
|
+
async function getPublishedNotes() {
|
|
29
|
+
if (!siteModelRendered("notes")) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
return sortEntriesByDateDescending(await getCollection("notes", ({ data }) => !data.draft));
|
|
33
|
+
}
|
|
34
|
+
async function getPublishedPeople() {
|
|
35
|
+
if (!siteModelRendered("people")) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
return getCollection("people");
|
|
39
|
+
}
|
|
40
|
+
async function getPublishedAgents() {
|
|
41
|
+
if (!siteModelRendered("agents")) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return getCollection("agents");
|
|
45
|
+
}
|
|
46
|
+
async function getPublishedBooks() {
|
|
47
|
+
if (!siteModelRendered("books")) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return (await getCollection("books")).sort((a, b) => a.data.order - b.data.order);
|
|
51
|
+
}
|
|
21
52
|
export {
|
|
53
|
+
getPublishedAgents,
|
|
54
|
+
getPublishedBooks,
|
|
55
|
+
getPublishedNotes,
|
|
22
56
|
getPublishedObjectives,
|
|
57
|
+
getPublishedPeople,
|
|
23
58
|
getPublishedQuestions,
|
|
24
59
|
resolveContributor,
|
|
25
60
|
resolveContributorsForEntries,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getTreeseedDeployConfig } from "@treeseed/sdk/platform/plugins";
|
|
2
|
+
import {
|
|
3
|
+
createTeamScopedR2OverlayContentRuntimeProvider,
|
|
4
|
+
isTeamScopedR2ContentEnabled,
|
|
5
|
+
resolveCloudflareR2Bucket,
|
|
6
|
+
resolvePublishedContentBucketBinding,
|
|
7
|
+
resolveTeamScopedContentLocator
|
|
8
|
+
} from "@treeseed/sdk/platform/published-content";
|
|
9
|
+
function runtimeFromLocals(locals) {
|
|
10
|
+
return locals?.runtime ?? null;
|
|
11
|
+
}
|
|
12
|
+
function previewFromLocals(locals) {
|
|
13
|
+
return locals?.contentPreview ?? null;
|
|
14
|
+
}
|
|
15
|
+
function defaultTeamIdForRuntime(locals) {
|
|
16
|
+
const runtime = runtimeFromLocals(locals);
|
|
17
|
+
const configured = typeof runtime?.env?.TREESEED_CONTENT_DEFAULT_TEAM_ID === "string" ? runtime.env.TREESEED_CONTENT_DEFAULT_TEAM_ID.trim() : "";
|
|
18
|
+
if (configured) {
|
|
19
|
+
return configured;
|
|
20
|
+
}
|
|
21
|
+
return getTreeseedDeployConfig().slug;
|
|
22
|
+
}
|
|
23
|
+
function resolveHostedContentRuntimeProvider(locals) {
|
|
24
|
+
const deployConfig = getTreeseedDeployConfig();
|
|
25
|
+
if (!isTeamScopedR2ContentEnabled(deployConfig)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const runtime = runtimeFromLocals(locals);
|
|
29
|
+
const bucket = resolveCloudflareR2Bucket(runtime, resolvePublishedContentBucketBinding(deployConfig));
|
|
30
|
+
if (!bucket) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const defaultTeamId = defaultTeamIdForRuntime(locals);
|
|
34
|
+
const preview = previewFromLocals(locals);
|
|
35
|
+
const locator = resolveTeamScopedContentLocator(
|
|
36
|
+
deployConfig,
|
|
37
|
+
defaultTeamId,
|
|
38
|
+
preview?.teamId === defaultTeamId ? preview.previewId : void 0
|
|
39
|
+
);
|
|
40
|
+
return createTeamScopedR2OverlayContentRuntimeProvider({
|
|
41
|
+
bucket,
|
|
42
|
+
locator
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async function loadHostedBookRuntime(locals) {
|
|
46
|
+
const provider = resolveHostedContentRuntimeProvider(locals);
|
|
47
|
+
if (!provider) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const manifest = await provider.getManifest();
|
|
51
|
+
const pointer = manifest.runtime?.booksRuntime;
|
|
52
|
+
if (!pointer) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return provider.getObject(pointer);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
loadHostedBookRuntime,
|
|
59
|
+
resolveHostedContentRuntimeProvider
|
|
60
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TreeseedContentCollection, TreeseedTenantConfig } from '@treeseed/sdk/platform/contracts';
|
|
2
|
+
export declare function isSiteRenderedModel(tenantConfig: Pick<TreeseedTenantConfig, 'features' | 'site'>, modelName: TreeseedContentCollection): boolean;
|
|
3
|
+
export declare function filterSiteRenderedModels<T extends {
|
|
4
|
+
model: TreeseedContentCollection;
|
|
5
|
+
}>(tenantConfig: Pick<TreeseedTenantConfig, 'features' | 'site'>, entries: T[]): T[];
|
|
6
|
+
export declare function siteModelRendered(modelName: TreeseedContentCollection): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tenantModelRendered } from "@treeseed/sdk/platform/tenant-config";
|
|
2
|
+
import { RUNTIME_TENANT } from "../tenant/runtime-config.js";
|
|
3
|
+
function isSiteRenderedModel(tenantConfig, modelName) {
|
|
4
|
+
return tenantModelRendered(tenantConfig, modelName);
|
|
5
|
+
}
|
|
6
|
+
function filterSiteRenderedModels(tenantConfig, entries) {
|
|
7
|
+
return entries.filter((entry) => isSiteRenderedModel(tenantConfig, entry.model));
|
|
8
|
+
}
|
|
9
|
+
function siteModelRendered(modelName) {
|
|
10
|
+
return isSiteRenderedModel(RUNTIME_TENANT, modelName);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
filterSiteRenderedModels,
|
|
14
|
+
isSiteRenderedModel,
|
|
15
|
+
siteModelRendered
|
|
16
|
+
};
|
|
@@ -5,6 +5,39 @@ import {
|
|
|
5
5
|
TREESEED_LINKS
|
|
6
6
|
} from "@treeseed/sdk/platform/books-data";
|
|
7
7
|
const normalizeHref = (href) => href.endsWith("/") ? href : `${href}/`;
|
|
8
|
+
function buildSidebarLink(href, label, currentPath) {
|
|
9
|
+
return {
|
|
10
|
+
type: "link",
|
|
11
|
+
label,
|
|
12
|
+
href,
|
|
13
|
+
isCurrent: normalizeHref(href) === normalizeHref(currentPath),
|
|
14
|
+
badge: void 0,
|
|
15
|
+
attrs: {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function buildSidebarEntries(items, currentPath) {
|
|
19
|
+
return items.map((item) => {
|
|
20
|
+
if (item.items?.length) {
|
|
21
|
+
return {
|
|
22
|
+
type: "group",
|
|
23
|
+
label: item.label,
|
|
24
|
+
entries: buildSidebarEntries(item.items, currentPath),
|
|
25
|
+
collapsed: false,
|
|
26
|
+
badge: void 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (item.link) {
|
|
30
|
+
return buildSidebarLink(item.link, item.label, currentPath);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
type: "group",
|
|
34
|
+
label: item.label,
|
|
35
|
+
entries: [],
|
|
36
|
+
collapsed: false,
|
|
37
|
+
badge: void 0
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
8
41
|
function buildBookSidebarFromRuntime(runtime2, bookSlug) {
|
|
9
42
|
const book = runtime2.BOOKS.find((candidate) => candidate.slug === bookSlug);
|
|
10
43
|
if (!book) {
|
|
@@ -18,6 +51,18 @@ function buildBookSidebarFromRuntime(runtime2, bookSlug) {
|
|
|
18
51
|
function getStarlightSidebarConfigFromRuntime(runtime2) {
|
|
19
52
|
return [runtime2.BOOKS_LINK, ...runtime2.BOOKS.map((book) => buildBookSidebarFromRuntime(runtime2, book.slug))];
|
|
20
53
|
}
|
|
54
|
+
function buildStarlightSidebarEntriesFromRuntime(runtime2, currentPath = runtime2.TREESEED_LINKS.home) {
|
|
55
|
+
return [
|
|
56
|
+
buildSidebarLink(String(runtime2.BOOKS_LINK.link ?? runtime2.TREESEED_LINKS.home), String(runtime2.BOOKS_LINK.label ?? "Books"), currentPath),
|
|
57
|
+
...runtime2.BOOKS.map((book) => ({
|
|
58
|
+
type: "group",
|
|
59
|
+
label: book.sectionLabel,
|
|
60
|
+
entries: buildSidebarEntries(book.sidebarItems, currentPath),
|
|
61
|
+
collapsed: false,
|
|
62
|
+
badge: void 0
|
|
63
|
+
}))
|
|
64
|
+
];
|
|
65
|
+
}
|
|
21
66
|
function getBookForPathFromRuntime(runtime2, pathname) {
|
|
22
67
|
const normalizedPath = normalizeHref(pathname);
|
|
23
68
|
return runtime2.BOOKS.find((book) => normalizedPath.startsWith(normalizeHref(book.basePath)));
|
|
@@ -44,6 +89,9 @@ function buildBookSidebar(bookSlug) {
|
|
|
44
89
|
function getStarlightSidebarConfig() {
|
|
45
90
|
return getStarlightSidebarConfigFromRuntime(runtime);
|
|
46
91
|
}
|
|
92
|
+
function getStarlightSidebarEntries(currentPath) {
|
|
93
|
+
return buildStarlightSidebarEntriesFromRuntime(runtime, currentPath);
|
|
94
|
+
}
|
|
47
95
|
function getBookForPath(pathname) {
|
|
48
96
|
return getBookForPathFromRuntime(runtime, pathname);
|
|
49
97
|
}
|
|
@@ -57,11 +105,13 @@ export {
|
|
|
57
105
|
TREESEED_LINKS,
|
|
58
106
|
buildBookSidebar,
|
|
59
107
|
buildBookSidebarFromRuntime,
|
|
108
|
+
buildStarlightSidebarEntriesFromRuntime,
|
|
60
109
|
getBookForPath,
|
|
61
110
|
getBookForPathFromRuntime,
|
|
62
111
|
getDocsDownloadForPath,
|
|
63
112
|
getDocsDownloadForPathFromRuntime,
|
|
64
113
|
getStarlightSidebarConfig,
|
|
65
114
|
getStarlightSidebarConfigFromRuntime,
|
|
115
|
+
getStarlightSidebarEntries,
|
|
66
116
|
normalizeHref
|
|
67
117
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "Treeseed integrated platform starter for Astro/Starlight web runtimes and Hono API runtimes.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"dev:api": "node ./scripts/run-ts.mjs ./scripts/dev-platform.ts --surface api",
|
|
43
43
|
"dev:manager": "node ./scripts/run-ts.mjs ./src/services/manager.ts",
|
|
44
44
|
"dev:worker": "node ./scripts/run-ts.mjs ./src/services/worker.ts",
|
|
45
|
+
"dev:agents": "node ./scripts/run-ts.mjs ./src/services/agents.ts",
|
|
46
|
+
"dev:remote-runner": "node ./scripts/run-ts.mjs ./src/services/remote-runner.ts",
|
|
45
47
|
"dev:workday-start": "node ./scripts/run-ts.mjs ./src/services/workday-start.ts",
|
|
46
48
|
"dev:workday-report": "node ./scripts/run-ts.mjs ./src/services/workday-report.ts",
|
|
47
49
|
"dev:watch": "node ./scripts/run-ts.mjs ./scripts/dev-platform.ts --watch",
|
|
@@ -67,7 +69,7 @@
|
|
|
67
69
|
"release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
|
|
68
70
|
},
|
|
69
71
|
"dependencies": {
|
|
70
|
-
"@treeseed/sdk": "^0.4.
|
|
72
|
+
"@treeseed/sdk": "^0.4.11",
|
|
71
73
|
"@astrojs/check": "^0.9.8",
|
|
72
74
|
"@astrojs/cloudflare": "^12.6.13",
|
|
73
75
|
"@astrojs/sitemap": "3.7.0",
|
|
@@ -156,16 +158,32 @@
|
|
|
156
158
|
"types": "./dist/content-config.d.ts",
|
|
157
159
|
"default": "./dist/content-config.js"
|
|
158
160
|
},
|
|
161
|
+
"./templates": {
|
|
162
|
+
"types": "./dist/templates.d.ts",
|
|
163
|
+
"default": "./dist/templates.js"
|
|
164
|
+
},
|
|
165
|
+
"./middleware/editorial-preview": {
|
|
166
|
+
"types": "./dist/middleware/editorial-preview.d.ts",
|
|
167
|
+
"default": "./dist/middleware/editorial-preview.js"
|
|
168
|
+
},
|
|
159
169
|
"./tenant": "./dist/tenant/bridge.js",
|
|
160
170
|
"./scripts/dev-platform": "./dist/scripts/dev-platform.js",
|
|
161
171
|
"./scripts/workspace-bootstrap": "./dist/scripts/workspace-bootstrap.js",
|
|
172
|
+
"./services/worker": {
|
|
173
|
+
"types": "./dist/services/worker.d.ts",
|
|
174
|
+
"default": "./dist/services/worker.js"
|
|
175
|
+
},
|
|
162
176
|
"./services/manager": {
|
|
163
177
|
"types": "./dist/services/manager.d.ts",
|
|
164
178
|
"default": "./dist/services/manager.js"
|
|
165
179
|
},
|
|
166
|
-
"./services/
|
|
167
|
-
"types": "./dist/services/
|
|
168
|
-
"default": "./dist/services/
|
|
180
|
+
"./services/agents": {
|
|
181
|
+
"types": "./dist/services/agents.d.ts",
|
|
182
|
+
"default": "./dist/services/agents.js"
|
|
183
|
+
},
|
|
184
|
+
"./services/remote-runner": {
|
|
185
|
+
"types": "./dist/services/remote-runner.d.ts",
|
|
186
|
+
"default": "./dist/services/remote-runner.js"
|
|
169
187
|
},
|
|
170
188
|
"./services/workday-start": {
|
|
171
189
|
"types": "./dist/services/workday-start.d.ts",
|
|
@@ -179,10 +197,6 @@
|
|
|
179
197
|
"types": "./dist/api/app.d.ts",
|
|
180
198
|
"default": "./dist/api/app.js"
|
|
181
199
|
},
|
|
182
|
-
"./api/gateway": {
|
|
183
|
-
"types": "./dist/api/gateway.d.ts",
|
|
184
|
-
"default": "./dist/api/gateway.js"
|
|
185
|
-
},
|
|
186
200
|
"./site-resources": {
|
|
187
201
|
"types": "./dist/site-resources.d.ts",
|
|
188
202
|
"default": "./dist/site-resources.js"
|