@ossy/platform 1.27.1 → 1.29.0

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 (2) hide show
  1. package/package.json +4 -4
  2. package/src/server.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/platform",
3
- "version": "1.27.1",
3
+ "version": "1.29.0",
4
4
  "description": "Ossy application server runtime",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,8 +24,8 @@
24
24
  "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@ossy/router": "^1.28.1",
28
- "@ossy/sdk": "^1.28.1",
27
+ "@ossy/router": "^1.30.0",
28
+ "@ossy/sdk": "^1.30.0",
29
29
  "cookie-parser": "^1.4.7",
30
30
  "dotenv": ">=16.0.0 <18.0.0",
31
31
  "express": ">=5.0.0 <6.0.0",
@@ -36,5 +36,5 @@
36
36
  "src",
37
37
  "Dockerfile"
38
38
  ],
39
- "gitHead": "df6c1ca73bc04210e7f284df680536b8501be770"
39
+ "gitHead": "ada54e62aeb87c197fa18891e995fbf22e23cc94"
40
40
  }
package/src/server.js CHANGED
@@ -48,6 +48,7 @@ export function loadManifest (buildDir) {
48
48
  const tasks = entries.filter((e) => e.type === 'task')
49
49
  const components = Array.isArray(manifest.components) ? manifest.components : []
50
50
  const resourceTemplates = Array.isArray(manifest.resourceTemplates) ? manifest.resourceTemplates : []
51
+ const aggregates = Array.isArray(manifest.aggregates) ? manifest.aggregates : []
51
52
  for (const e of entries) {
52
53
  if ((e.type === 'page' || e.type === 'api') && !validRoutable(e)) {
53
54
  console.warn(`[@ossy/platform][server] Skipping ${e.type} "${e.id}" — manifest entry has no path.`)
@@ -60,6 +61,7 @@ export function loadManifest (buildDir) {
60
61
  tasks,
61
62
  components,
62
63
  resourceTemplates,
64
+ aggregates,
63
65
  config: manifest.config || {},
64
66
  }
65
67
  }
@@ -106,6 +108,30 @@ export async function startServer (options = {}) {
106
108
  registerResourceTemplate(template)
107
109
  }
108
110
 
111
+ // Aggregate registration — mirrors task and resource-template registration above.
112
+ // AggregateRebuild lives in the co-located api package. The relative path resolves
113
+ // correctly both in the monorepo layout (ossy/packages/platform/src/ → api/) and
114
+ // when the published package is installed inside api/node_modules/@ossy/platform/src/.
115
+ // A try/catch ensures the server starts cleanly even when the api source is absent.
116
+ let AggregateRebuild = null
117
+ try {
118
+ const rebuildMod = await import(new URL('../../../../api/src/aggregate/aggregate.rebuild.js', import.meta.url).href)
119
+ AggregateRebuild = rebuildMod.AggregateRebuild
120
+ } catch {
121
+ // AggregateRebuild not reachable from this installation — aggregate registration skipped.
122
+ }
123
+
124
+ if (AggregateRebuild) {
125
+ for (const agg of manifest.aggregates ?? []) {
126
+ try {
127
+ const mod = await import(resolveEntryUrl(agg.entry, buildDir))
128
+ AggregateRebuild.registerAggregate(mod)
129
+ } catch (err) {
130
+ console.error(`[@ossy/platform][server] Failed to load aggregate "${agg.id}":`, err.message)
131
+ }
132
+ }
133
+ }
134
+
109
135
  // Register the SDK so all tasks receive it as `sdk`.
110
136
  // Priority: explicit options.sdk → SDK.of() from env vars → null (direct-DB fallback in tasks).
111
137
  const botSdk = (process.env.API_URL && process.env.OSSY_API_KEY)