@ossy/sdk 1.40.1 → 1.40.3

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 CHANGED
@@ -41,8 +41,8 @@ const resource = await sdk.resources.get({ id: 'resource-id' })
41
41
  - `sdk.workspaces.list()` — List workspaces
42
42
  - `sdk.workspaces.get({ workspaceId })` — Get workspace by ID
43
43
  - `sdk.workspaces.create(payload)` — Create workspace
44
- - `sdk.workspaces.importResourceTemplates(...)` — Import resource templates
45
- - `sdk.workspaces.getResourceTemplates(...)` — Get resource templates
44
+ - `sdk.workspaces.importSchemas(...)` — Import schemas
45
+ - `sdk.workspaces.getSchemas(...)` — Get schemas
46
46
 
47
47
  ### Resources
48
48
 
@@ -87,6 +87,26 @@ export const App = () => (
87
87
  )
88
88
  ```
89
89
 
90
+ ## Agents (MCP)
91
+
92
+ MCP is embedded in the app server — same actions as `sdk.invoke`, exposed as tools from `build/capabilities.json`.
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "ossy-local": {
98
+ "url": "http://localhost:3006/mcp",
99
+ "headers": {
100
+ "Authorization": "Bearer your-jwt-token",
101
+ "workspaceId": "your-workspace-id"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ See [TODO-AGENT-MCP.md](../../docs/TODO-AGENT-MCP.md).
109
+
90
110
  ## Invoking platform actions
91
111
 
92
112
  **Writes and commands** use `sdk.invoke(action, payload)` with a platform action POJO or id string:
@@ -98,8 +118,8 @@ import { BookingCreate } from '@ossy/booking'
98
118
  const sdk = SDK.of({ workspaceId: 'your-workspace-id' })
99
119
 
100
120
  // POJO (preferred) — importable on client and server
101
- await sdk.invoke(BookingCreate, { consultantId, startAt, duration })
102
- // HTTP: POST /actions with { action: 'booking/create', payload: { … } }
121
+ await sdk.invoke(BookingCreate, { providerId, startAt, duration })
122
+ // HTTP: POST /actions with { action: '@ossy/booking/actions/create', payload: { … } }
103
123
  ```
104
124
 
105
125
  **Reads** use location paths — not invoke:
@@ -107,3 +127,32 @@ await sdk.invoke(BookingCreate, { consultantId, startAt, duration })
107
127
  ```js
108
128
  await sdk.resources.list({ location: '/@ossy/booking/services/' })
109
129
  ```
130
+
131
+ ## Push invalidation (ADR 0008)
132
+
133
+ Subscribe to workspace SSE events at `GET /events` to invalidate client read caches when server state changes.
134
+
135
+ ```js
136
+ import { SDK } from '@ossy/sdk'
137
+
138
+ const sdk = SDK.of({ workspaceId: 'your-workspace-id' })
139
+
140
+ const unsubscribe = sdk.subscribePush({
141
+ onMessage: (message) => {
142
+ // message.invalidate — cache keys to drop (when present)
143
+ console.log(message.kind, message.invalidate)
144
+ },
145
+ onError: (error) => {
146
+ console.error('SSE error', error)
147
+ },
148
+ })
149
+
150
+ // later
151
+ unsubscribe()
152
+ ```
153
+
154
+ `PushMessage` fields include `kind`, `type`, `resourceId`, `event`, `version`, `eventId`, `scope.workspaceId`, and `invalidate` (string array of cache keys).
155
+
156
+ Requires `workspaceId` on the SDK config, or a workspace cookie on the same origin. Returns a no-op unsubscribe when `EventSource` is unavailable (SSR/tests).
157
+
158
+ With React, `WorkspaceProvider` from `@ossy/sdk-react` wires this automatically via `usePushInvalidation`.
@@ -1,15 +1,29 @@
1
- import { Action, SDKConfig, ActionAccess } from '@ossy/types';
1
+ import { Action, ActionRoute, SDKConfig, ActionAccess } from '@ossy/types';
2
2
  export * from '@ossy/types';
3
- export { ActionAccess, TaskStatus, Tasks } from '@ossy/types';
3
+ export { ActionAccess, ActionRoute } from '@ossy/types';
4
4
 
5
5
  type ActionRef = Action | string;
6
- /** Normalize dot aliases to slash ids (`resources.list` → `resources/list`). */
6
+ /** Normalize dot aliases to slash ids (`@ossy.booking.actions.create` → `@ossy/booking/actions/create`). */
7
7
  declare function resolveActionId(action: ActionRef): string;
8
+ /**
9
+ * Resolve POST /actions URL from an SDK `apiUrl`.
10
+ * Actions are served at the app server root, not under `/api/v0` or the `/@ossy` proxy prefix.
11
+ */
12
+ declare function resolveActionsUrl(apiUrl: string): string;
13
+ /** Resolve GET /events SSE URL from an SDK `apiUrl`. */
14
+ declare function resolveEventsUrl(apiUrl: string): string;
15
+
16
+ /**
17
+ * Resolve a manifest HTTP action route to a fetch URL.
18
+ * Supports same-origin `/@ossy` proxy and absolute `/api/v0` bases.
19
+ */
20
+ declare function resolveHttpActionUrl(apiUrl: string, route: ActionRoute, payload?: Record<string, unknown>): string;
8
21
 
9
22
  declare class SDK {
10
23
  workspaceId?: string;
11
24
  authorization?: string;
12
25
  baseUrl: string;
26
+ actionRoutes: Record<string, ActionRoute>;
13
27
  static of(config: SDKConfig): SDK;
14
28
  constructor(config: SDKConfig);
15
29
  updateConfig(intendedConfig: SDKConfig): void;
@@ -38,7 +52,28 @@ declare class SDK {
38
52
  };
39
53
  invoke: <TPayload extends Record<string, unknown> = Record<string, unknown>, TResult = unknown>(action: ActionRef, payload?: TPayload) => Promise<TResult>;
40
54
  invokePlatformAction: (actionId: string, payload?: Record<string, unknown>) => Promise<any>;
55
+ invokeHttpRoute: (route: ActionRoute, payload?: Record<string, unknown>) => Promise<any>;
41
56
  handleResponse: (response: Response) => Response | Promise<any>;
57
+ /**
58
+ * Subscribe to workspace push invalidation (ADR 0008 §9 SSE).
59
+ * Requires `workspaceId` on the SDK config (or workspace cookie on same origin).
60
+ */
61
+ subscribePush: (handlers: {
62
+ onMessage: (message: PushMessage) => void;
63
+ onError?: (error: Event) => void;
64
+ }) => (() => void);
65
+ }
66
+ interface PushMessage {
67
+ kind: string;
68
+ type?: string;
69
+ resourceId?: string;
70
+ event?: string;
71
+ version?: number;
72
+ eventId?: string;
73
+ scope?: {
74
+ workspaceId?: string;
75
+ };
76
+ invalidate?: string[];
42
77
  }
43
78
 
44
79
  /** Platform action POJO for CLI discovery and `sdk.invoke` action refs. */
@@ -65,10 +100,10 @@ declare const WorkspacesGet: PlatformAction<{
65
100
  declare const WorkspacesCreate: PlatformAction<{
66
101
  name: string;
67
102
  }>;
68
- declare const WorkspacesImportResourceTemplates: PlatformAction<{
69
- templates: unknown[];
103
+ declare const WorkspacesImportSchemas: PlatformAction<{
104
+ schemas: unknown[];
70
105
  }>;
71
- declare const WorkspacesGetResourceTemplates: PlatformAction;
106
+ declare const WorkspacesGetSchemas: PlatformAction;
72
107
  declare const WorkspacesCreateApiToken: PlatformAction<{
73
108
  description: string;
74
109
  }>;
@@ -173,5 +208,5 @@ declare const AuthSignOff: PlatformAction;
173
208
  /** @deprecated Use `PlatformAction`. */
174
209
  type RestAction<TPayload = Record<string, unknown>> = PlatformAction<TPayload>;
175
210
 
176
- export { ApiTokenCreate, ApiTokenGetAll, ApiTokenInvalidate, AuthGetAuthenticatedUser, AuthGetAuthenticatedUserHistory, AuthGetUser, AuthSignIn, AuthSignOff, AuthSignUp, AuthVerifyInvitation, AuthVerifySignIn, ResourceUpdateAccess, ResourcesCreate, ResourcesCreateDirectory, ResourcesGet, ResourcesList, ResourcesMove, ResourcesRemove, ResourcesRename, ResourcesSearch, ResourcesUpdateContent, ResourcesUpload, ResourcesUploadNamedVersion, SDK, UserCurrentGet, UserCurrentGetHistory, UserCurrentUpdate, WorkspacesAddMember, WorkspacesCreate, WorkspacesCreateApiToken, WorkspacesDisableService, WorkspacesEnableService, WorkspacesGet, WorkspacesGetApiTokens, WorkspacesGetCurrent, WorkspacesGetResourceTemplates, WorkspacesGetUsers, WorkspacesImportResourceTemplates, WorkspacesInviteUser, WorkspacesList, WorkspacesRemoveMember, resolveActionId };
177
- export type { ActionRef, PlatformAction, RestAction };
211
+ export { ApiTokenCreate, ApiTokenGetAll, ApiTokenInvalidate, AuthGetAuthenticatedUser, AuthGetAuthenticatedUserHistory, AuthGetUser, AuthSignIn, AuthSignOff, AuthSignUp, AuthVerifyInvitation, AuthVerifySignIn, ResourceUpdateAccess, ResourcesCreate, ResourcesCreateDirectory, ResourcesGet, ResourcesList, ResourcesMove, ResourcesRemove, ResourcesRename, ResourcesSearch, ResourcesUpdateContent, ResourcesUpload, ResourcesUploadNamedVersion, SDK, UserCurrentGet, UserCurrentGetHistory, UserCurrentUpdate, WorkspacesAddMember, WorkspacesCreate, WorkspacesCreateApiToken, WorkspacesDisableService, WorkspacesEnableService, WorkspacesGet, WorkspacesGetApiTokens, WorkspacesGetCurrent, WorkspacesGetSchemas, WorkspacesGetUsers, WorkspacesImportSchemas, WorkspacesInviteUser, WorkspacesList, WorkspacesRemoveMember, resolveActionId, resolveActionsUrl, resolveEventsUrl, resolveHttpActionUrl };
212
+ export type { ActionRef, PlatformAction, PushMessage, RestAction };
@@ -1 +1 @@
1
- const e={VisualContentDescriptors:"@ossy/tasks/visual-content-descriptors",ResizeCommonWeb:"@ossy/tasks/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"},t={id:"users/get-api-tokens"},i={id:"users/create-api-token"},r={id:"users/invalidate-api-token"},o={id:"workspaces/list"},a={id:"workspaces/get"},n={id:"workspaces/get"},c={id:"workspaces/create"},d={id:"workspaces/import-resource-templates"},u={id:"workspaces/get-resource-templates"},p={id:"workspaces/create-api-token"},h={id:"workspaces/get-api-tokens"},l={id:"workspaces/invite-user"},k={id:"workspaces/enable-service"},g={id:"workspaces/disable-service"},m={id:"workspaces/get-users"},w={id:"users/join-workspace"},y={id:"workspaces/remove-member"},b={id:"authentication/get-current-user"},v={id:"users/get-current-user-history"},f={id:"users/update-details"},j={id:"resources/create",payload:{type:"directory"}},z={id:"resources/create"},U={id:"resources/create"},P={id:"resources/upload-named-version"},I={id:"resources/get"},O={id:"resources/list"},T={id:"resources/search"},C={id:"resources/update-access"},S={id:"resources/delete"},R={id:"resources/update-content"},A={id:"resources/update-location"},q={id:"resources/update-name"},N={id:"authentication/sign-up"},V={id:"authentication/request-sign-in"},$={id:"authentication/verify-sign-in"},x={id:"workspaces/accept-invitation"},D={id:"authentication/get-current-user"},F={id:"users/get-current-user-history"},J={id:"authentication/get-current-user"},L={id:"authentication/sign-out"};function Q(e){const s="string"==typeof e?e:e.id;return s.includes(".")?s.replace(/\./g,"/"):s}class W{static of(e){return new W(e)}constructor(e){this.baseUrl="https://api.ossy.se/api/v0",this.invoke=(e,s)=>this.invokePlatformAction(Q(e),s),this.invokePlatformAction=(e,s)=>{const t={method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,payload:null!=s?s:{}})};this.workspaceId&&(t.headers=Object.assign(Object.assign({},t.headers),{workspaceId:this.workspaceId})),this.authorization&&(t.headers=Object.assign(Object.assign({},t.headers),{Authorization:this.authorization}));const i=this.baseUrl.replace(/\/api\/v0\/?$/,"");return fetch(i?`${i}/actions`:"/actions",t).then(this.handleResponse)},this.handleResponse=e=>{const s=e.headers.get("Content-Type")||"",t=e.status;return 400===t?e.json().then(e=>Promise.reject(e.error)):[200,204].includes(t)?s.includes("application/json")?e.json():e:Promise.reject(e)},this.updateConfig(e)}updateConfig(e){this.baseUrl=e.apiUrl||this.baseUrl,this.workspaceId=e.workspaceId||this.workspaceId,this.authorization=e.authorization||this.authorization}get resources(){return{upload:({location:e="/",file:s})=>{const t={type:s.type,location:e,name:s.name,size:s.size};return this.invoke(U,t).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},list:e=>{const s=new URLSearchParams(Object.assign({},e)).toString();return this.invoke(O,{search:s})},uploadNamedVersion:({id:e,name:s,file:t})=>{const i={id:e,name:s,size:t.size};return this.invoke(P,i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:t}).then(()=>e))}}}}export{i as ApiTokenCreate,t as ApiTokenGetAll,r as ApiTokenInvalidate,D as AuthGetAuthenticatedUser,F as AuthGetAuthenticatedUserHistory,J as AuthGetUser,V as AuthSignIn,L as AuthSignOff,N as AuthSignUp,x as AuthVerifyInvitation,$ as AuthVerifySignIn,C as ResourceUpdateAccess,z as ResourcesCreate,j as ResourcesCreateDirectory,I as ResourcesGet,O as ResourcesList,A as ResourcesMove,S as ResourcesRemove,q as ResourcesRename,T as ResourcesSearch,R as ResourcesUpdateContent,U as ResourcesUpload,P as ResourcesUploadNamedVersion,W as SDK,s as TaskStatus,e as Tasks,b as UserCurrentGet,v as UserCurrentGetHistory,f as UserCurrentUpdate,w as WorkspacesAddMember,c as WorkspacesCreate,p as WorkspacesCreateApiToken,g as WorkspacesDisableService,k as WorkspacesEnableService,n as WorkspacesGet,h as WorkspacesGetApiTokens,a as WorkspacesGetCurrent,u as WorkspacesGetResourceTemplates,m as WorkspacesGetUsers,d as WorkspacesImportResourceTemplates,l as WorkspacesInviteUser,o as WorkspacesList,y as WorkspacesRemoveMember,Q as resolveActionId};
1
+ const s={VisualContentDescriptors:"@ossy/tasks/visual-content-descriptors",ResizeCommonWeb:"@ossy/tasks/resize-common-web"},e={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"},t={id:"@ossy/users/actions/get-api-tokens"},o={id:"@ossy/users/actions/create-api-token"},i={id:"@ossy/users/actions/invalidate-api-token"},n={id:"@ossy/workspaces/actions/list"},a={id:"@ossy/workspaces/actions/get"},r={id:"@ossy/workspaces/actions/get"},c={id:"@ossy/workspaces/actions/create"},u={id:"@ossy/workspaces/actions/import-schemas"},d={id:"@ossy/workspaces/actions/get-schemas"},h={id:"@ossy/workspaces/actions/create-api-token"},p={id:"@ossy/workspaces/actions/get-api-tokens"},l={id:"@ossy/workspaces/actions/invite-user"},y={id:"@ossy/workspaces/actions/enable-service"},g={id:"@ossy/workspaces/actions/disable-service"},k={id:"@ossy/workspaces/actions/get-users"},v={id:"@ossy/users/actions/join-workspace"},m={id:"@ossy/workspaces/actions/remove-member"},w={id:"@ossy/authentication/actions/get-current-user"},f={id:"@ossy/users/actions/get-current-user-history"},b={id:"@ossy/users/actions/update-details"},j={id:"@ossy/resources/actions/create",payload:{type:"directory"}},$={id:"@ossy/resources/actions/create"},z={id:"@ossy/resources/actions/create"},O={id:"@ossy/resources/actions/upload-named-version"},R={id:"@ossy/resources/actions/get"},S={id:"@ossy/resources/actions/list"},U={id:"@ossy/resources/actions/search"},T={id:"@ossy/resources/actions/update-access"},P={id:"@ossy/resources/actions/delete"},I={id:"@ossy/resources/actions/update-content"},E={id:"@ossy/resources/actions/update-location"},C={id:"@ossy/resources/actions/update-name"},A={id:"@ossy/authentication/actions/sign-up"},W={id:"@ossy/authentication/actions/request-sign-in"},G={id:"@ossy/authentication/actions/verify-sign-in"},H={id:"@ossy/workspaces/actions/accept-invitation"},N={id:"@ossy/authentication/actions/get-current-user"},q={id:"@ossy/users/actions/get-current-user-history"},D={id:"@ossy/authentication/actions/get-current-user"},J={id:"@ossy/authentication/actions/sign-out"};function L(s){const e="string"==typeof s?s:s.id;return e.includes(".")?e.replace(/\./g,"/"):e}function V(s){const e=(null!=s?s:"").replace(/\/$/,"");if(!e||"/@ossy"===e||e.endsWith("/@ossy"))return"/actions";const t=e.replace(/\/api\/v0\/?$/,"").replace(/\/$/,"");return t?`${t}/actions`:"/actions"}function x(s){const e=(null!=s?s:"").replace(/\/$/,"");if(!e||"/@ossy"===e||e.endsWith("/@ossy"))return"/events";const t=e.replace(/\/api\/v0\/?$/,"").replace(/\/$/,"");return t?`${t}/events`:"/events"}function F(s,e,t){var o,i;const n=e.path.startsWith("/")?e.path:`/${e.path}`,a=(null!=s?s:"").replace(/\/$/,"");let r;r=!a||"/@ossy"===a||a.endsWith("/@ossy")?`/@ossy${n.replace(/^\/api\/v0/,"")}`:a.includes("/api/v0")?`${a.replace(/\/api\/v0\/?$/,"")}${n}`:`${a}${n}`;const c=null!==(o=e.method)&&void 0!==o?o:"GET";if("GET"===c||"HEAD"===c){const s=new URLSearchParams;for(const o of null!==(i=e.query)&&void 0!==i?i:[]){const e=null==t?void 0:t[o];null!=e&&""!==e&&s.set(o,String(e))}const o=s.toString();o&&(r+=`${r.includes("?")?"&":"?"}${o}`)}return r}class M{static of(s){return new M(s)}constructor(s){this.baseUrl="https://api.ossy.se/api/v0",this.actionRoutes={},this.invoke=(s,e)=>this.invokePlatformAction(L(s),e),this.invokePlatformAction=(s,e)=>{const t=this.actionRoutes[s];if(t)return this.invokeHttpRoute(t,e);const o={method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:s,payload:null!=e?e:{}})};this.workspaceId&&(o.headers=Object.assign(Object.assign({},o.headers),{workspaceId:this.workspaceId})),this.authorization&&(o.headers=Object.assign(Object.assign({},o.headers),{Authorization:this.authorization}));const i=V(this.baseUrl);return fetch(i,o).then(this.handleResponse)},this.invokeHttpRoute=(s,e)=>{var t;const o=null!==(t=s.method)&&void 0!==t?t:"GET",i=F(this.baseUrl,s,e),n={method:o,credentials:"include",headers:{}};return this.workspaceId&&(n.headers=Object.assign(Object.assign({},n.headers),{workspaceId:this.workspaceId})),this.authorization&&(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:this.authorization})),"GET"!==o&&"HEAD"!==o&&(n.headers=Object.assign(Object.assign({},n.headers),{"Content-Type":"application/json"}),n.body=JSON.stringify(null!=e?e:{})),fetch(i,n).then(this.handleResponse)},this.handleResponse=s=>{const e=s.headers.get("Content-Type")||"",t=s.status;return 400===t?s.json().then(s=>Promise.reject(s.error)):[200,204].includes(t)?e.includes("application/json")?s.json():s:Promise.reject(s)},this.subscribePush=s=>{if("undefined"==typeof EventSource)return()=>{};const e=x(this.baseUrl),t=new EventSource(e,{withCredentials:!0});return t.onmessage=e=>{try{const t=JSON.parse(e.data);s.onMessage(t)}catch(s){}},t.onerror=e=>{var t;null===(t=s.onError)||void 0===t||t.call(s,e)},()=>{t.close()}},this.updateConfig(s)}updateConfig(s){var e;this.baseUrl=s.apiUrl||this.baseUrl,this.workspaceId=s.workspaceId||this.workspaceId,this.authorization=s.authorization||this.authorization,this.actionRoutes=null!==(e=s.actionRoutes)&&void 0!==e?e:this.actionRoutes}get resources(){return{upload:({location:s="/",file:e})=>{const t={type:e.type,location:s,name:e.name,size:e.size};return this.invoke(z,t).then(s=>fetch(s.content.uploadUrl,{method:"PUT",body:e}).then(()=>s))},list:s=>{const e=new URLSearchParams(Object.assign({},s)).toString();return this.invoke(S,{search:e})},uploadNamedVersion:({id:s,name:e,file:t})=>{const o={id:s,name:e,size:t.size};return this.invoke(O,o).then(s=>fetch(s.content.uploadUrl,{method:"PUT",body:t}).then(()=>s))}}}}export{o as ApiTokenCreate,t as ApiTokenGetAll,i as ApiTokenInvalidate,N as AuthGetAuthenticatedUser,q as AuthGetAuthenticatedUserHistory,D as AuthGetUser,W as AuthSignIn,J as AuthSignOff,A as AuthSignUp,H as AuthVerifyInvitation,G as AuthVerifySignIn,T as ResourceUpdateAccess,$ as ResourcesCreate,j as ResourcesCreateDirectory,R as ResourcesGet,S as ResourcesList,E as ResourcesMove,P as ResourcesRemove,C as ResourcesRename,U as ResourcesSearch,I as ResourcesUpdateContent,z as ResourcesUpload,O as ResourcesUploadNamedVersion,M as SDK,e as TaskStatus,s as Tasks,w as UserCurrentGet,f as UserCurrentGetHistory,b as UserCurrentUpdate,v as WorkspacesAddMember,c as WorkspacesCreate,h as WorkspacesCreateApiToken,g as WorkspacesDisableService,y as WorkspacesEnableService,r as WorkspacesGet,p as WorkspacesGetApiTokens,a as WorkspacesGetCurrent,d as WorkspacesGetSchemas,k as WorkspacesGetUsers,u as WorkspacesImportSchemas,l as WorkspacesInviteUser,n as WorkspacesList,m as WorkspacesRemoveMember,L as resolveActionId,V as resolveActionsUrl,x as resolveEventsUrl,F as resolveHttpActionUrl};
@@ -23,10 +23,10 @@ export declare const WorkspacesGet: PlatformAction<{
23
23
  export declare const WorkspacesCreate: PlatformAction<{
24
24
  name: string;
25
25
  }>;
26
- export declare const WorkspacesImportResourceTemplates: PlatformAction<{
27
- templates: unknown[];
26
+ export declare const WorkspacesImportSchemas: PlatformAction<{
27
+ schemas: unknown[];
28
28
  }>;
29
- export declare const WorkspacesGetResourceTemplates: PlatformAction;
29
+ export declare const WorkspacesGetSchemas: PlatformAction;
30
30
  export declare const WorkspacesCreateApiToken: PlatformAction<{
31
31
  description: string;
32
32
  }>;
@@ -1,2 +1,2 @@
1
1
  export * from "./sdk.js";
2
- export { Tasks, TaskStatus } from "./tasks-client.js";
2
+ export { Tasks, TaskStatus } from "@ossy/types";
@@ -1,5 +1,12 @@
1
1
  import type { Action } from '@ossy/types';
2
2
  export type ActionRef = Action | string;
3
3
  export declare function isActionRef(value: unknown): value is ActionRef;
4
- /** Normalize dot aliases to slash ids (`resources.list` → `resources/list`). */
4
+ /** Normalize dot aliases to slash ids (`@ossy.booking.actions.create` → `@ossy/booking/actions/create`). */
5
5
  export declare function resolveActionId(action: ActionRef): string;
6
+ /**
7
+ * Resolve POST /actions URL from an SDK `apiUrl`.
8
+ * Actions are served at the app server root, not under `/api/v0` or the `/@ossy` proxy prefix.
9
+ */
10
+ export declare function resolveActionsUrl(apiUrl: string): string;
11
+ /** Resolve GET /events SSE URL from an SDK `apiUrl`. */
12
+ export declare function resolveEventsUrl(apiUrl: string): string;
@@ -1,4 +1,3 @@
1
- export { Tasks, TaskStatus } from './tasks-client.js';
2
1
  export * from '@ossy/types';
3
2
  export * from './sdk';
4
3
  export * from './Actions';
@@ -0,0 +1,6 @@
1
+ import type { ActionRoute } from '@ossy/types';
2
+ /**
3
+ * Resolve a manifest HTTP action route to a fetch URL.
4
+ * Supports same-origin `/@ossy` proxy and absolute `/api/v0` bases.
5
+ */
6
+ export declare function resolveHttpActionUrl(apiUrl: string, route: ActionRoute, payload?: Record<string, unknown>): string;
@@ -1,10 +1,14 @@
1
1
  import { SDKConfig } from './config';
2
- import { resolveActionId, type ActionRef } from './platform-action';
3
- export { resolveActionId, type ActionRef };
2
+ import { resolveActionId, resolveActionsUrl, resolveEventsUrl, type ActionRef } from './platform-action';
3
+ import { resolveHttpActionUrl } from './resolve-http-action-url';
4
+ import type { ActionRoute } from '@ossy/types';
5
+ export { resolveActionId, resolveActionsUrl, resolveEventsUrl, resolveHttpActionUrl, type ActionRef };
6
+ export type { ActionRoute };
4
7
  export declare class SDK {
5
8
  workspaceId?: string;
6
9
  authorization?: string;
7
10
  baseUrl: string;
11
+ actionRoutes: Record<string, ActionRoute>;
8
12
  static of(config: SDKConfig): SDK;
9
13
  constructor(config: SDKConfig);
10
14
  updateConfig(intendedConfig: SDKConfig): void;
@@ -33,5 +37,26 @@ export declare class SDK {
33
37
  };
34
38
  invoke: <TPayload extends Record<string, unknown> = Record<string, unknown>, TResult = unknown>(action: ActionRef, payload?: TPayload) => Promise<TResult>;
35
39
  invokePlatformAction: (actionId: string, payload?: Record<string, unknown>) => Promise<any>;
40
+ invokeHttpRoute: (route: ActionRoute, payload?: Record<string, unknown>) => Promise<any>;
36
41
  handleResponse: (response: Response) => Response | Promise<any>;
42
+ /**
43
+ * Subscribe to workspace push invalidation (ADR 0008 §9 SSE).
44
+ * Requires `workspaceId` on the SDK config (or workspace cookie on same origin).
45
+ */
46
+ subscribePush: (handlers: {
47
+ onMessage: (message: PushMessage) => void;
48
+ onError?: (error: Event) => void;
49
+ }) => (() => void);
50
+ }
51
+ export interface PushMessage {
52
+ kind: string;
53
+ type?: string;
54
+ resourceId?: string;
55
+ event?: string;
56
+ version?: number;
57
+ eventId?: string;
58
+ scope?: {
59
+ workspaceId?: string;
60
+ };
61
+ invalidate?: string[];
37
62
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/sdk",
3
3
  "description": "Software Development Kit for interacting with our services",
4
- "version": "1.40.1",
4
+ "version": "1.40.3",
5
5
  "url": "git://github.com/ossy-se/packages/sdk",
6
6
  "source": "src/public.index.ts",
7
7
  "main": "build/public.index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@ossy/types": "^1.40.1"
24
+ "@ossy/types": "^1.40.3"
25
25
  },
26
26
  "scripts": {
27
27
  "start": "",
@@ -36,5 +36,5 @@
36
36
  "/build",
37
37
  "README.md"
38
38
  ],
39
- "gitHead": "c0ba5d90749690634e4dc2705178ff8d89dd3070"
39
+ "gitHead": "a0d89185a17f8de8ce328c3a648c108ff1d61d8f"
40
40
  }
@@ -1,32 +0,0 @@
1
- import { Tasks, TaskStatus, TaskType, Resource, Task } from '@ossy/types';
2
- export { Tasks, TaskStatus };
3
- interface ResourcesClient {
4
- search: (payload: Record<string, unknown>) => Promise<Resource<Task>[]>;
5
- create: (data: {
6
- type: string;
7
- location: string;
8
- name: string;
9
- content: {
10
- resourceId: string;
11
- status: string;
12
- result: undefined;
13
- };
14
- }) => Promise<Resource<Task>>;
15
- }
16
- interface TasksClientConfig {
17
- http?: unknown;
18
- resources: ResourcesClient;
19
- }
20
- export declare class TasksClient {
21
- static location: string;
22
- private http?;
23
- private resources;
24
- static of(config: TasksClientConfig): TasksClient;
25
- constructor(config: TasksClientConfig);
26
- get(_query?: string | Record<string, unknown>): Promise<Resource<Task>[]>;
27
- getUnprocessed(): Promise<Resource<Task>[]>;
28
- create({ type, resourceId }: {
29
- type: TaskType;
30
- resourceId: string;
31
- }): Promise<Resource<Task>>;
32
- }