@ossy/platform 1.24.3 → 1.25.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/platform",
3
- "version": "1.24.3",
3
+ "version": "1.25.0",
4
4
  "description": "Ossy application server runtime",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@ossy/router": "^1.25.3",
27
- "@ossy/sdk": "^1.25.3",
26
+ "@ossy/router": "^1.26.0",
27
+ "@ossy/sdk": "^1.26.0",
28
28
  "cookie-parser": "^1.4.7",
29
29
  "dotenv": ">=16.0.0 <18.0.0",
30
30
  "express": ">=5.0.0 <6.0.0",
@@ -35,5 +35,5 @@
35
35
  "src",
36
36
  "Dockerfile"
37
37
  ],
38
- "gitHead": "88840c464266647e040f0b0d51c0bb95b18a056b"
38
+ "gitHead": "40e96d148d991ef4ad60fe9090f19b836ff8eb00"
39
39
  }
package/src/server.js CHANGED
@@ -6,6 +6,7 @@ import morgan from 'morgan'
6
6
  import { Router as OssyRouter } from '@ossy/router'
7
7
  import cookieParser from 'cookie-parser'
8
8
  import { ProxyInternal } from './proxy-internal.js'
9
+ import { SDK } from '@ossy/sdk'
9
10
  import { TaskService } from './tasks/task-service.js'
10
11
  import { ChangeStream } from './tasks/change-stream.js'
11
12
 
@@ -100,12 +101,12 @@ export async function startServer (options = {}) {
100
101
  }
101
102
  }
102
103
 
103
- // Register the SDK adapter so all tasks receive it as `sdk`.
104
- // Callers pass an adapter via `options.sdk`; for the ossy API server this is
105
- // the EventStoreAdapter created in api/src/index.js.
106
- if (options.sdk) {
107
- TaskService.setSdk(options.sdk)
108
- }
104
+ // Register the SDK so all tasks receive it as `sdk`.
105
+ // Priority: explicit options.sdk SDK.of() from env vars null (direct-DB fallback in tasks).
106
+ const botSdk = (process.env.API_URL && process.env.OSSY_API_KEY)
107
+ ? SDK.of({ apiUrl: process.env.API_URL, authorization: process.env.OSSY_API_KEY })
108
+ : null
109
+ TaskService.setSdk(options.sdk ?? botSdk)
109
110
 
110
111
  TaskService.startScheduler()
111
112
 
@@ -14,17 +14,17 @@ export class TaskService {
14
14
  static _schedulerInterval = null
15
15
 
16
16
  /**
17
- * Global SDK adapter injected at server startup. Tasks receive this as `sdk`
17
+ * Global SDK instance injected at server startup. Tasks receive this as `sdk`
18
18
  * unless a per-call override is supplied to `dispatch`.
19
- * Set via `TaskService.setSdk(adapter)`.
20
- * @type {import('./adapter.js').OssySdkAdapter | null}
19
+ * Set via `TaskService.setSdk(sdk)`.
20
+ * @type {import('@ossy/sdk').SDK | null}
21
21
  */
22
22
  static _sdk = null
23
23
 
24
24
  /**
25
- * Register the SDK adapter that every task will receive as `sdk`.
25
+ * Register the SDK instance that every task will receive as `sdk`.
26
26
  * Call this once during application startup before ChangeStream / scheduler begin.
27
- * @param {import('./adapter.js').OssySdkAdapter | null} sdk
27
+ * @param {import('@ossy/sdk').SDK | null} sdk
28
28
  */
29
29
  static setSdk(sdk) {
30
30
  TaskService._sdk = sdk