@treeseed/core 0.4.10 → 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.
Files changed (55) hide show
  1. package/dist/api/auth/rbac.d.ts +2 -2
  2. package/dist/api/auth/rbac.js +2 -1
  3. package/dist/components/site/RouteNotFound.astro +25 -0
  4. package/dist/content-config.d.ts +1 -0
  5. package/dist/content.d.ts +1 -0
  6. package/dist/content.js +177 -1
  7. package/dist/dev.d.ts +7 -2
  8. package/dist/dev.js +59 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +9 -1
  11. package/dist/middleware/editorial-preview.d.ts +26 -0
  12. package/dist/middleware/editorial-preview.js +37 -0
  13. package/dist/middleware/starlightRouteData.js +15 -4
  14. package/dist/pages/[slug].astro +12 -10
  15. package/dist/pages/agents/[slug].astro +28 -21
  16. package/dist/pages/books/[slug].astro +19 -12
  17. package/dist/pages/feed.xml.js +6 -4
  18. package/dist/pages/index.astro +43 -14
  19. package/dist/pages/notes/[slug].astro +19 -12
  20. package/dist/pages/objectives/[slug].astro +30 -23
  21. package/dist/pages/people/[slug].astro +28 -21
  22. package/dist/pages/questions/[slug].astro +30 -23
  23. package/dist/scripts/build-dist.js +6 -1
  24. package/dist/scripts/dev-platform.js +9 -1
  25. package/dist/services/agents.d.ts +22 -0
  26. package/dist/services/agents.js +29 -0
  27. package/dist/services/index.d.ts +3 -0
  28. package/dist/services/index.js +11 -0
  29. package/dist/services/manager.d.ts +247 -0
  30. package/dist/services/manager.js +1129 -0
  31. package/dist/services/remote-runner.d.ts +7 -0
  32. package/dist/services/remote-runner.js +6 -0
  33. package/dist/services/workday-content.d.ts +53 -0
  34. package/dist/services/workday-content.js +190 -0
  35. package/dist/services/workday-report.d.ts +160 -2
  36. package/dist/services/workday-report.js +3 -26
  37. package/dist/services/workday-start.d.ts +170 -1
  38. package/dist/services/workday-start.js +3 -7
  39. package/dist/services/worker-pool-scaler.d.ts +27 -0
  40. package/dist/services/worker-pool-scaler.js +109 -0
  41. package/dist/services/worker.d.ts +7 -0
  42. package/dist/services/worker.js +3 -0
  43. package/dist/site.js +43 -27
  44. package/dist/templates.d.ts +98 -0
  45. package/dist/templates.js +170 -0
  46. package/dist/tenant/runtime-config.d.ts +4 -0
  47. package/dist/tenant/runtime-config.js +34 -1
  48. package/dist/utils/hub-content.js +35 -0
  49. package/dist/utils/published-content.js +60 -0
  50. package/dist/utils/site-models.d.ts +6 -0
  51. package/dist/utils/site-models.js +16 -0
  52. package/dist/utils/starlight-nav.js +50 -0
  53. package/package.json +20 -2
  54. package/templates/github/deploy.workflow.yml +404 -9
  55. package/templates/github/hosted-project.workflow.yml +77 -0
@@ -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.10",
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": {
@@ -40,7 +40,9 @@
40
40
  "dev": "node ./scripts/run-ts.mjs ./scripts/dev-platform.ts",
41
41
  "dev:web": "node ./scripts/run-ts.mjs ./scripts/dev-platform.ts --surface web",
42
42
  "dev:api": "node ./scripts/run-ts.mjs ./scripts/dev-platform.ts --surface api",
43
+ "dev:manager": "node ./scripts/run-ts.mjs ./src/services/manager.ts",
43
44
  "dev:worker": "node ./scripts/run-ts.mjs ./src/services/worker.ts",
45
+ "dev:agents": "node ./scripts/run-ts.mjs ./src/services/agents.ts",
44
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",
@@ -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.9",
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,6 +158,14 @@
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",
@@ -163,6 +173,14 @@
163
173
  "types": "./dist/services/worker.d.ts",
164
174
  "default": "./dist/services/worker.js"
165
175
  },
176
+ "./services/manager": {
177
+ "types": "./dist/services/manager.d.ts",
178
+ "default": "./dist/services/manager.js"
179
+ },
180
+ "./services/agents": {
181
+ "types": "./dist/services/agents.d.ts",
182
+ "default": "./dist/services/agents.js"
183
+ },
166
184
  "./services/remote-runner": {
167
185
  "types": "./dist/services/remote-runner.d.ts",
168
186
  "default": "./dist/services/remote-runner.js"