@pellux/goodvibes-operator-sdk 0.18.3 → 0.30.1

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
@@ -1,15 +1,11 @@
1
1
  # @pellux/goodvibes-operator-sdk
2
2
 
3
- Contract-driven HTTP client for the GoodVibes operator and control-plane APIs.
3
+ Internal workspace package backing `@pellux/goodvibes-sdk/operator`.
4
4
 
5
- Install:
6
-
7
- ```bash
8
- npm install @pellux/goodvibes-operator-sdk
9
- ```
5
+ Consumers should install `@pellux/goodvibes-sdk` and import this surface from the umbrella package.
10
6
 
11
7
  ```ts
12
- import { createOperatorSdk } from '@pellux/goodvibes-operator-sdk';
8
+ import { createOperatorSdk } from '@pellux/goodvibes-sdk/operator';
13
9
 
14
10
  const operator = createOperatorSdk({
15
11
  baseUrl: 'http://127.0.0.1:3210',
@@ -23,4 +19,20 @@ const login = await operator.invoke('control.auth.login', {
23
19
  });
24
20
  ```
25
21
 
26
- Use this package when you want only the operator/control-plane surface and do not need the umbrella SDK composition layer.
22
+ Use this surface when you want only the operator/control-plane surface and do not need the umbrella SDK composition layer.
23
+
24
+ Advanced consumers can also build directly from a preconfigured transport and contract:
25
+
26
+ ```ts
27
+ import { getOperatorContract } from '@pellux/goodvibes-sdk/contracts';
28
+ import { createOperatorRemoteClient } from '@pellux/goodvibes-sdk/operator';
29
+ import { createHttpTransport } from '@pellux/goodvibes-sdk/transport-http';
30
+
31
+ const transport = createHttpTransport({
32
+ baseUrl: 'http://127.0.0.1:3210',
33
+ authToken: process.env.GOODVIBES_TOKEN,
34
+ });
35
+
36
+ const operator = createOperatorRemoteClient(transport, getOperatorContract());
37
+ const status = await operator.control.status();
38
+ ```
@@ -1,28 +1,23 @@
1
1
  import type { OperatorContractManifest, OperatorMethodContract } from '@pellux/goodvibes-contracts';
2
2
  import type { OperatorMethodInput, OperatorMethodOutput, OperatorStreamMethodId, OperatorTypedMethodId } from '@pellux/goodvibes-contracts';
3
3
  import type { HttpTransport } from '@pellux/goodvibes-transport-http';
4
- import { type ContractInvokeOptions, type ContractStreamOptions } from '@pellux/goodvibes-transport-http';
4
+ import { type ContractInvokeOptions, type ContractStreamOptions, type MethodArgs, type WithoutKeys } from '@pellux/goodvibes-transport-http';
5
5
  export interface OperatorRemoteClientInvokeOptions extends ContractInvokeOptions {
6
6
  }
7
7
  export interface OperatorRemoteClientStreamOptions extends ContractStreamOptions {
8
8
  }
9
- type RequiredKeys<T extends object> = {
10
- [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
11
- }[keyof T];
12
- type MethodArgs<TInput, TOptions> = [
13
- TInput
14
- ] extends [undefined] ? [input?: undefined, options?: TOptions] : TInput extends object ? [RequiredKeys<TInput>] extends [never] ? [input?: TInput, options?: TOptions] : [input: TInput, options?: TOptions] : [input: TInput, options?: TOptions];
15
- type WithoutKeys<TInput, TKeys extends PropertyKey> = [
16
- TInput
17
- ] extends [undefined] ? undefined : TInput extends object ? Omit<TInput, Extract<keyof TInput, TKeys>> : TInput;
9
+ export interface OperatorRemoteClientOptions {
10
+ readonly getResponseSchema?: (methodId: string) => ContractInvokeOptions['responseSchema'];
11
+ readonly validateResponses?: boolean;
12
+ }
18
13
  type KnownMethodArgs<TMethodId extends OperatorTypedMethodId> = MethodArgs<OperatorMethodInput<TMethodId>, OperatorRemoteClientInvokeOptions>;
19
14
  type KnownPathMethodArgs<TMethodId extends OperatorTypedMethodId, TKeys extends PropertyKey> = MethodArgs<WithoutKeys<OperatorMethodInput<TMethodId>, TKeys>, OperatorRemoteClientInvokeOptions>;
20
15
  type KnownStreamArgs<TMethodId extends OperatorStreamMethodId> = MethodArgs<OperatorMethodInput<TMethodId>, OperatorRemoteClientStreamOptions>;
21
16
  export interface OperatorRemoteClient {
22
17
  readonly transport: HttpTransport;
23
18
  readonly contract: OperatorContractManifest;
24
- listMethods(): readonly OperatorMethodContract[];
25
- getMethod(methodId: string): OperatorMethodContract;
19
+ listOperations(): readonly OperatorMethodContract[];
20
+ getOperation(methodId: string): OperatorMethodContract;
26
21
  invoke<TMethodId extends OperatorTypedMethodId>(methodId: TMethodId, ...args: KnownMethodArgs<TMethodId>): Promise<OperatorMethodOutput<TMethodId>>;
27
22
  invoke<T = unknown>(methodId: string, input?: Record<string, unknown>, options?: OperatorRemoteClientInvokeOptions): Promise<T>;
28
23
  stream<TMethodId extends OperatorStreamMethodId>(methodId: TMethodId, ...args: KnownStreamArgs<TMethodId>): Promise<() => void>;
@@ -99,6 +94,6 @@ export interface OperatorRemoteClient {
99
94
  stream(...args: KnownStreamArgs<'telemetry.stream'>): Promise<() => void>;
100
95
  };
101
96
  }
102
- export declare function createOperatorRemoteClient(transport: HttpTransport, contract: OperatorContractManifest): OperatorRemoteClient;
97
+ export declare function createOperatorRemoteClient(transport: HttpTransport, contract: OperatorContractManifest, clientOptions?: OperatorRemoteClientOptions): OperatorRemoteClient;
103
98
  export {};
104
99
  //# sourceMappingURL=client-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-core.d.ts","sourceRoot":"","sources":["../src/client-core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACpG,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,iCAAkC,SAAQ,qBAAqB;CAAG;AAEnF,MAAM,WAAW,iCAAkC,SAAQ,qBAAqB;CAAG;AAEnF,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI;KACnC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,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BAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAClH,MAAM,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAClH,OAAO,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC;QACnH,IAAI,EAAE;YACJ,MAAM,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAClH,IAAI,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC;YAC5G,OAAO,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,CAAC;SACtH,CAAC;QACF,MAAM,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;KAC3E,CAAC;CACH;AA4BD,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,wBAAwB,EAClC,aAAa,GAAE,2BAAgC,GAC9C,oBAAoB,CAmLtB"}
@@ -1,32 +1,44 @@
1
- import { buildContractInput, invokeContractRoute, openContractRouteStream, requireContractRoute, } from '@pellux/goodvibes-transport-http';
2
- function splitArgs(args) {
3
- return args;
4
- }
1
+ import { ContractError, GoodVibesSdkError } from '@pellux/goodvibes-errors';
2
+ import { invokeContractRoute, firstJsonSchemaFailure, openContractRouteStream, requireContractRoute, clientInputRecord, mergeClientInput, splitClientArgs, } from '@pellux/goodvibes-transport-http';
5
3
  function requireMethod(contract, methodId) {
6
4
  return requireContractRoute(contract.operator.methods, methodId, 'operator method');
7
5
  }
8
6
  function requireMethodRoute(contract, methodId) {
9
7
  const method = requireMethod(contract, methodId);
8
+ return methodHttpRoute(method);
9
+ }
10
+ function methodHttpRoute(method) {
10
11
  if (!method.http) {
11
- throw new Error(`Operator method "${methodId}" does not expose an HTTP binding`);
12
+ throw new GoodVibesSdkError(`Operator method "${method.id}" does not expose an HTTP binding. This method may be internal-only or require a different transport. Check the contract manifest for available HTTP methods.`, { category: 'contract', source: 'contract', recoverable: false });
12
13
  }
13
- return method.http;
14
+ return {
15
+ ...method.http,
16
+ id: method.id,
17
+ idempotent: method.idempotent,
18
+ };
14
19
  }
15
- export function createOperatorRemoteClient(transport, contract) {
20
+ export function createOperatorRemoteClient(transport, contract, clientOptions = {}) {
16
21
  function invokeTyped(methodId, input, options = {}) {
17
- return invokeContractRoute(transport, requireMethodRoute(contract, methodId), input, options);
22
+ const schema = options.responseSchema ?? clientOptions.getResponseSchema?.(methodId);
23
+ const method = requireMethod(contract, methodId);
24
+ const route = methodHttpRoute(method);
25
+ return invokeContractRoute(transport, route, input, schema ? { ...options, responseSchema: schema } : options).then((body) => {
26
+ if (!schema && clientOptions.validateResponses !== false)
27
+ validateJsonSchemaResponse(method, body);
28
+ return body;
29
+ });
18
30
  }
19
31
  function streamTyped(methodId, ...args) {
20
- const [input, options] = splitArgs(args);
21
- return openContractRouteStream(transport, requireMethodRoute(contract, methodId), input, options ?? { handlers: {} });
32
+ const [input, options] = splitClientArgs(args);
33
+ return openContractRouteStream(transport, requireMethodRoute(contract, methodId), clientInputRecord(input), options ?? { handlers: {} });
22
34
  }
23
35
  const client = {
24
36
  transport,
25
37
  contract,
26
- listMethods() {
38
+ listOperations() {
27
39
  return contract.operator.methods;
28
40
  },
29
- getMethod(methodId) {
41
+ getOperation(methodId) {
30
42
  return requireMethod(contract, methodId);
31
43
  },
32
44
  invoke: invokeTyped,
@@ -34,107 +46,85 @@ export function createOperatorRemoteClient(transport, contract) {
34
46
  sessions: {
35
47
  create: (...args) => invokeTyped('sessions.create', ...args),
36
48
  get: (sessionId, ...args) => {
37
- const [input, options] = splitArgs(args);
38
- return invokeTyped('sessions.get', buildContractInput('sessionId', sessionId, input), options);
49
+ const [input, options] = splitClientArgs(args);
50
+ return invokeTyped('sessions.get', mergeClientInput({ sessionId }, input), options);
39
51
  },
40
52
  list: (...args) => invokeTyped('sessions.list', ...args),
41
53
  messages: {
42
54
  create: (sessionId, ...args) => {
43
- const [input, options] = splitArgs(args);
44
- return invokeTyped('sessions.messages.create', buildContractInput('sessionId', sessionId, input), options);
55
+ const [input, options] = splitClientArgs(args);
56
+ return invokeTyped('sessions.messages.create', mergeClientInput({ sessionId }, input), options);
45
57
  },
46
58
  list: (sessionId, ...args) => {
47
- const [input, options] = splitArgs(args);
48
- return invokeTyped('sessions.messages.list', buildContractInput('sessionId', sessionId, input), options);
59
+ const [input, options] = splitClientArgs(args);
60
+ return invokeTyped('sessions.messages.list', mergeClientInput({ sessionId }, input), options);
49
61
  },
50
62
  },
51
63
  inputs: {
52
64
  cancel: (sessionId, inputId, ...args) => {
53
- const [input, options] = splitArgs(args);
54
- return invokeTyped('sessions.inputs.cancel', {
65
+ const [input, options] = splitClientArgs(args);
66
+ return invokeTyped('sessions.inputs.cancel', mergeClientInput({
55
67
  sessionId,
56
68
  inputId,
57
- ...(input ?? {}),
58
- }, options);
69
+ }, input), options);
59
70
  },
60
71
  },
61
72
  followUp: (...args) => invokeTyped('sessions.followUp', ...args),
62
73
  steer: (...args) => invokeTyped('sessions.steer', ...args),
63
74
  close: (sessionId, ...args) => {
64
- const [input, options] = splitArgs(args);
65
- return invokeTyped('sessions.close', {
66
- sessionId,
67
- ...(input ?? {}),
68
- }, options);
75
+ const [input, options] = splitClientArgs(args);
76
+ return invokeTyped('sessions.close', mergeClientInput({ sessionId }, input), options);
69
77
  },
70
78
  reopen: (sessionId, ...args) => {
71
- const [input, options] = splitArgs(args);
72
- return invokeTyped('sessions.reopen', {
73
- sessionId,
74
- ...(input ?? {}),
75
- }, options);
79
+ const [input, options] = splitClientArgs(args);
80
+ return invokeTyped('sessions.reopen', mergeClientInput({ sessionId }, input), options);
76
81
  },
77
82
  },
78
83
  tasks: {
79
84
  create: (...args) => invokeTyped('tasks.create', ...args),
80
85
  get: (taskId, ...args) => {
81
- const [input, options] = splitArgs(args);
82
- return invokeTyped('tasks.get', {
83
- taskId,
84
- ...(input ?? {}),
85
- }, options);
86
+ const [input, options] = splitClientArgs(args);
87
+ return invokeTyped('tasks.get', mergeClientInput({ taskId }, input), options);
86
88
  },
87
89
  list: (...args) => invokeTyped('tasks.list', ...args),
88
90
  status: (...args) => invokeTyped('tasks.status', ...args),
89
91
  cancel: (taskId, ...args) => {
90
- const [input, options] = splitArgs(args);
91
- return invokeTyped('tasks.cancel', {
92
- taskId,
93
- ...(input ?? {}),
94
- }, options);
92
+ const [input, options] = splitClientArgs(args);
93
+ return invokeTyped('tasks.cancel', mergeClientInput({ taskId }, input), options);
95
94
  },
96
95
  retry: (taskId, ...args) => {
97
- const [input, options] = splitArgs(args);
98
- return invokeTyped('tasks.retry', {
99
- taskId,
100
- ...(input ?? {}),
101
- }, options);
96
+ const [input, options] = splitClientArgs(args);
97
+ return invokeTyped('tasks.retry', mergeClientInput({ taskId }, input), options);
102
98
  },
103
99
  },
104
100
  approvals: {
105
101
  list: (...args) => invokeTyped('approvals.list', ...args),
106
102
  claim: (approvalId, ...args) => {
107
- const [input, options] = splitArgs(args);
108
- return invokeTyped('approvals.claim', buildContractInput('approvalId', approvalId, input), options);
103
+ const [input, options] = splitClientArgs(args);
104
+ return invokeTyped('approvals.claim', mergeClientInput({ approvalId }, input), options);
109
105
  },
110
106
  approve: (approvalId, ...args) => {
111
- const [input, options] = splitArgs(args);
112
- return invokeTyped('approvals.approve', buildContractInput('approvalId', approvalId, input), options);
107
+ const [input, options] = splitClientArgs(args);
108
+ return invokeTyped('approvals.approve', mergeClientInput({ approvalId }, input), options);
113
109
  },
114
110
  deny: (approvalId, ...args) => {
115
- const [input, options] = splitArgs(args);
116
- return invokeTyped('approvals.deny', buildContractInput('approvalId', approvalId, input), options);
111
+ const [input, options] = splitClientArgs(args);
112
+ return invokeTyped('approvals.deny', mergeClientInput({ approvalId }, input), options);
117
113
  },
118
114
  cancel: (approvalId, ...args) => {
119
- const [input, options] = splitArgs(args);
120
- return invokeTyped('approvals.cancel', buildContractInput('approvalId', approvalId, input), options);
115
+ const [input, options] = splitClientArgs(args);
116
+ return invokeTyped('approvals.cancel', mergeClientInput({ approvalId }, input), options);
121
117
  },
122
118
  },
123
119
  providers: {
124
120
  list: (...args) => invokeTyped('providers.list', ...args),
125
121
  get: (providerId, ...args) => {
126
- const [input, options] = splitArgs(args);
127
- return invokeTyped('providers.get', {
128
- providerId,
129
- ...(input ?? {}),
130
- }, options);
122
+ const [input, options] = splitClientArgs(args);
123
+ return invokeTyped('providers.get', mergeClientInput({ providerId }, input), options);
131
124
  },
132
125
  usage: (providerId, ...args) => {
133
- const [input, options] = splitArgs(args);
134
- return invokeTyped('providers.usage.get', {
135
- providerId,
136
- ...(input ?? {}),
137
- }, options);
126
+ const [input, options] = splitClientArgs(args);
127
+ return invokeTyped('providers.usage.get', mergeClientInput({ providerId }, input), options);
138
128
  },
139
129
  },
140
130
  accounts: {
@@ -150,11 +140,8 @@ export function createOperatorRemoteClient(transport, contract) {
150
140
  methods: {
151
141
  list: (...args) => invokeTyped('control.methods.list', ...args),
152
142
  get: (methodId, ...args) => {
153
- const [input, options] = splitArgs(args);
154
- return invokeTyped('control.methods.get', {
155
- methodId,
156
- ...(input ?? {}),
157
- }, options);
143
+ const [input, options] = splitClientArgs(args);
144
+ return invokeTyped('control.methods.get', mergeClientInput({ methodId }, input), options);
158
145
  },
159
146
  },
160
147
  auth: {
@@ -182,3 +169,12 @@ export function createOperatorRemoteClient(transport, contract) {
182
169
  };
183
170
  return client;
184
171
  }
172
+ function validateJsonSchemaResponse(method, body) {
173
+ const schema = method.outputSchema;
174
+ if (!schema || typeof schema !== 'object')
175
+ return;
176
+ const failure = firstJsonSchemaFailure(schema, body);
177
+ if (!failure)
178
+ return;
179
+ throw new ContractError(`Response validation failed for operator method "${method.id}": field "${failure.path}" expected ${failure.expected} but received ${failure.received}. Ensure the daemon is running the matching GoodVibes contract version.`, { source: 'contract' });
180
+ }
package/dist/client.d.ts CHANGED
@@ -1,16 +1,26 @@
1
1
  import type { OperatorMethodContract, OperatorMethodId } from '@pellux/goodvibes-contracts';
2
- import { type HttpTransport, type HttpTransportOptions, type ServerSentEventHandlers } from '@pellux/goodvibes-transport-http';
2
+ import { type HttpTransport, type HttpTransportOptions } from '@pellux/goodvibes-transport-http';
3
3
  import { type OperatorRemoteClient, type OperatorRemoteClientInvokeOptions, type OperatorRemoteClientStreamOptions } from './client-core.js';
4
4
  export interface OperatorSdkOptions extends HttpTransportOptions {
5
+ /**
6
+ * When `true` (default), response bodies for typed operator methods are
7
+ * validated against their Zod contract schemas. Set to `false` to opt out.
8
+ * This is useful when a caller wants raw response bodies for contract
9
+ * debugging or benchmarking.
10
+ */
11
+ readonly validateResponses?: boolean;
5
12
  }
6
13
  export interface OperatorInvokeOptions extends OperatorRemoteClientInvokeOptions {
7
14
  }
8
15
  export interface OperatorStreamOptions extends OperatorRemoteClientStreamOptions {
9
- readonly handlers: ServerSentEventHandlers;
10
16
  }
11
- export type OperatorSdk = Omit<OperatorRemoteClient, 'getMethod'> & {
17
+ export type OperatorSdk = Omit<OperatorRemoteClient, 'getOperation'> & {
12
18
  readonly transport: HttpTransport;
13
- getMethod(methodId: OperatorMethodId): OperatorMethodContract;
19
+ getOperation(methodId: OperatorMethodId): OperatorMethodContract;
20
+ dispose(): void;
21
+ asyncDispose(): Promise<void>;
22
+ [Symbol.dispose](): void;
23
+ [Symbol.asyncDispose](): Promise<void>;
14
24
  };
15
25
  export declare function createOperatorSdk(options: OperatorSdkOptions): OperatorSdk;
16
26
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACvC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;CAAG;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,iCAAiC;CAAG;AAEnF,MAAM,WAAW,qBAAsB,SAAQ,iCAAiC;IAC9E,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;CAC5C;AAED,MAAM,MAAM,WAAW,GACnB,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,GACvC;IACA,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,sBAAsB,CAAC;CAC/D,CAAC;AAEJ,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAG1E"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACvC,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,qBAAsB,SAAQ,iCAAiC;CAAG;AAEnF,MAAM,WAAW,qBAAsB,SAAQ,iCAAiC;CAAG;AAEnF,MAAM,MAAM,WAAW,GACnB,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,GAC1C;IACA,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,YAAY,CAAC,QAAQ,EAAE,gBAAgB,GAAG,sBAAsB,CAAC;IACjE,OAAO,IAAI,IAAI,CAAC;IAChB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACzB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC,CAAC;AAuCJ,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgC1E"}
package/dist/client.js CHANGED
@@ -1,7 +1,70 @@
1
1
  import { getOperatorContract } from '@pellux/goodvibes-contracts';
2
+ import * as ContractZodSchemas from '@pellux/goodvibes-contracts';
2
3
  import { createHttpTransport, } from '@pellux/goodvibes-transport-http';
3
4
  import { createOperatorRemoteClient, } from './client-core.js';
5
+ function isZodSchema(value) {
6
+ return Boolean(value && typeof value === 'object' && 'safeParse' in value && typeof value.safeParse === 'function');
7
+ }
8
+ function pascalCaseContractPart(part) {
9
+ return part
10
+ .split(/[_-]+/)
11
+ .filter(Boolean)
12
+ .map((token) => token.charAt(0).toUpperCase() + token.slice(1))
13
+ .join('');
14
+ }
15
+ function responseSchemaExportCandidates(methodId) {
16
+ const parts = methodId.split('.').filter(Boolean).map(pascalCaseContractPart);
17
+ if (parts.length === 0)
18
+ return [];
19
+ const fullName = `${parts.join('')}ResponseSchema`;
20
+ const verbFirst = parts.length > 1
21
+ ? `${parts[parts.length - 1]}${parts.slice(0, -1).join('')}ResponseSchema`
22
+ : fullName;
23
+ return fullName === verbFirst ? [fullName] : [fullName, verbFirst];
24
+ }
25
+ function buildSchemaRegistry(methodIds, schemas) {
26
+ const registry = {};
27
+ for (const methodId of methodIds) {
28
+ for (const exportName of responseSchemaExportCandidates(methodId)) {
29
+ const schema = schemas[exportName];
30
+ if (!isZodSchema(schema))
31
+ continue;
32
+ registry[methodId] = schema;
33
+ break;
34
+ }
35
+ }
36
+ return registry;
37
+ }
4
38
  export function createOperatorSdk(options) {
39
+ const validateResponses = options.validateResponses !== false;
5
40
  const transport = createHttpTransport(options);
6
- return createOperatorRemoteClient(transport, getOperatorContract());
41
+ const contract = getOperatorContract();
42
+ const schemaRegistry = validateResponses
43
+ ? buildSchemaRegistry(contract.operator.methods.map((method) => method.id), ContractZodSchemas)
44
+ : {};
45
+ const remote = createOperatorRemoteClient(transport, contract, {
46
+ validateResponses,
47
+ getResponseSchema: validateResponses
48
+ ? (methodId) => schemaRegistry[methodId]
49
+ : undefined,
50
+ });
51
+ return {
52
+ ...remote,
53
+ getOperation(methodId) {
54
+ return remote.getOperation(methodId);
55
+ },
56
+ dispose() {
57
+ // HTTP transports do not hold sockets today, but exposing disposal on the
58
+ // SDK object gives callers a stable lifecycle hook as transports evolve.
59
+ },
60
+ async asyncDispose() {
61
+ this.dispose();
62
+ },
63
+ [Symbol.dispose]() {
64
+ this.dispose();
65
+ },
66
+ async [Symbol.asyncDispose]() {
67
+ this.dispose();
68
+ },
69
+ };
7
70
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export type { OperatorInvokeOptions, OperatorSdk, OperatorSdkOptions, OperatorStreamOptions, } from './client.js';
2
2
  export { createOperatorSdk } from './client.js';
3
+ export { createOperatorRemoteClient, } from './client-core.js';
4
+ export type { OperatorRemoteClient, OperatorRemoteClientInvokeOptions, OperatorRemoteClientStreamOptions, } from './client-core.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,oBAAoB,EACpB,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { createOperatorSdk } from './client.js';
2
+ export { createOperatorRemoteClient, } from './client-core.js';
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-operator-sdk",
3
- "version": "0.18.3",
3
+ "version": "0.30.1",
4
+ "engines": {
5
+ "node": ">=20.0.0"
6
+ },
4
7
  "description": "Contract-driven HTTP client for the GoodVibes operator and control-plane APIs.",
5
8
  "type": "module",
6
9
  "main": "./dist/index.js",
@@ -10,6 +13,14 @@
10
13
  "types": "./dist/index.d.ts",
11
14
  "import": "./dist/index.js"
12
15
  },
16
+ "./client-core": {
17
+ "types": "./dist/client-core.d.ts",
18
+ "import": "./dist/client-core.js"
19
+ },
20
+ "./client": {
21
+ "types": "./dist/client.d.ts",
22
+ "import": "./dist/client.js"
23
+ },
13
24
  "./package.json": "./package.json"
14
25
  },
15
26
  "files": [
@@ -32,12 +43,13 @@
32
43
  "control-plane",
33
44
  "client"
34
45
  ],
46
+ "dependencies": {
47
+ "@pellux/goodvibes-contracts": "0.30.1",
48
+ "@pellux/goodvibes-errors": "0.30.1",
49
+ "@pellux/goodvibes-transport-http": "0.30.1",
50
+ "zod": "^4.3.6"
51
+ },
35
52
  "publishConfig": {
36
53
  "access": "public"
37
- },
38
- "dependencies": {
39
- "@pellux/goodvibes-contracts": "0.18.3",
40
- "@pellux/goodvibes-errors": "0.18.3",
41
- "@pellux/goodvibes-transport-http": "0.18.3"
42
54
  }
43
55
  }