@pellux/goodvibes-operator-sdk 0.18.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 +26 -0
- package/dist/client-core.d.ts +104 -0
- package/dist/client-core.d.ts.map +1 -0
- package/dist/client-core.js +184 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @pellux/goodvibes-operator-sdk
|
|
2
|
+
|
|
3
|
+
Contract-driven HTTP client for the GoodVibes operator and control-plane APIs.
|
|
4
|
+
|
|
5
|
+
Install:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pellux/goodvibes-operator-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createOperatorSdk } from '@pellux/goodvibes-operator-sdk';
|
|
13
|
+
|
|
14
|
+
const operator = createOperatorSdk({
|
|
15
|
+
baseUrl: 'http://127.0.0.1:3210',
|
|
16
|
+
authToken: process.env.GOODVIBES_TOKEN,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const snapshot = await operator.control.snapshot();
|
|
20
|
+
const login = await operator.invoke('control.auth.login', {
|
|
21
|
+
username: 'alice',
|
|
22
|
+
password: 'secret',
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use this package when you want only the operator/control-plane surface and do not need the umbrella SDK composition layer.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { OperatorContractManifest, OperatorMethodContract } from '@pellux/goodvibes-contracts';
|
|
2
|
+
import type { OperatorMethodInput, OperatorMethodOutput, OperatorStreamMethodId, OperatorTypedMethodId } from '@pellux/goodvibes-contracts';
|
|
3
|
+
import type { HttpTransport } from '@pellux/goodvibes-transport-http';
|
|
4
|
+
import { type ContractInvokeOptions, type ContractStreamOptions } from '@pellux/goodvibes-transport-http';
|
|
5
|
+
export interface OperatorRemoteClientInvokeOptions extends ContractInvokeOptions {
|
|
6
|
+
}
|
|
7
|
+
export interface OperatorRemoteClientStreamOptions extends ContractStreamOptions {
|
|
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;
|
|
18
|
+
type KnownMethodArgs<TMethodId extends OperatorTypedMethodId> = MethodArgs<OperatorMethodInput<TMethodId>, OperatorRemoteClientInvokeOptions>;
|
|
19
|
+
type KnownPathMethodArgs<TMethodId extends OperatorTypedMethodId, TKeys extends PropertyKey> = MethodArgs<WithoutKeys<OperatorMethodInput<TMethodId>, TKeys>, OperatorRemoteClientInvokeOptions>;
|
|
20
|
+
type KnownStreamArgs<TMethodId extends OperatorStreamMethodId> = MethodArgs<OperatorMethodInput<TMethodId>, OperatorRemoteClientStreamOptions>;
|
|
21
|
+
export interface OperatorRemoteClient {
|
|
22
|
+
readonly transport: HttpTransport;
|
|
23
|
+
readonly contract: OperatorContractManifest;
|
|
24
|
+
listMethods(): readonly OperatorMethodContract[];
|
|
25
|
+
getMethod(methodId: string): OperatorMethodContract;
|
|
26
|
+
invoke<TMethodId extends OperatorTypedMethodId>(methodId: TMethodId, ...args: KnownMethodArgs<TMethodId>): Promise<OperatorMethodOutput<TMethodId>>;
|
|
27
|
+
invoke<T = unknown>(methodId: string, input?: Record<string, unknown>, options?: OperatorRemoteClientInvokeOptions): Promise<T>;
|
|
28
|
+
stream<TMethodId extends OperatorStreamMethodId>(methodId: TMethodId, ...args: KnownStreamArgs<TMethodId>): Promise<() => void>;
|
|
29
|
+
readonly sessions: {
|
|
30
|
+
create(...args: KnownMethodArgs<'sessions.create'>): Promise<OperatorMethodOutput<'sessions.create'>>;
|
|
31
|
+
get(sessionId: string, ...args: KnownPathMethodArgs<'sessions.get', 'sessionId'>): Promise<OperatorMethodOutput<'sessions.get'>>;
|
|
32
|
+
list(...args: KnownMethodArgs<'sessions.list'>): Promise<OperatorMethodOutput<'sessions.list'>>;
|
|
33
|
+
messages: {
|
|
34
|
+
create(sessionId: string, ...args: KnownPathMethodArgs<'sessions.messages.create', 'sessionId'>): Promise<OperatorMethodOutput<'sessions.messages.create'>>;
|
|
35
|
+
list(sessionId: string, ...args: KnownPathMethodArgs<'sessions.messages.list', 'sessionId'>): Promise<OperatorMethodOutput<'sessions.messages.list'>>;
|
|
36
|
+
};
|
|
37
|
+
inputs: {
|
|
38
|
+
cancel(sessionId: string, inputId: string, ...args: KnownPathMethodArgs<'sessions.inputs.cancel', 'sessionId' | 'inputId'>): Promise<OperatorMethodOutput<'sessions.inputs.cancel'>>;
|
|
39
|
+
};
|
|
40
|
+
followUp(...args: KnownMethodArgs<'sessions.followUp'>): Promise<OperatorMethodOutput<'sessions.followUp'>>;
|
|
41
|
+
steer(...args: KnownMethodArgs<'sessions.steer'>): Promise<OperatorMethodOutput<'sessions.steer'>>;
|
|
42
|
+
close(sessionId: string, ...args: KnownPathMethodArgs<'sessions.close', 'sessionId'>): Promise<OperatorMethodOutput<'sessions.close'>>;
|
|
43
|
+
reopen(sessionId: string, ...args: KnownPathMethodArgs<'sessions.reopen', 'sessionId'>): Promise<OperatorMethodOutput<'sessions.reopen'>>;
|
|
44
|
+
};
|
|
45
|
+
readonly tasks: {
|
|
46
|
+
create(...args: KnownMethodArgs<'tasks.create'>): Promise<OperatorMethodOutput<'tasks.create'>>;
|
|
47
|
+
get(taskId: string, ...args: KnownPathMethodArgs<'tasks.get', 'taskId'>): Promise<OperatorMethodOutput<'tasks.get'>>;
|
|
48
|
+
list(...args: KnownMethodArgs<'tasks.list'>): Promise<OperatorMethodOutput<'tasks.list'>>;
|
|
49
|
+
status(...args: KnownMethodArgs<'tasks.status'>): Promise<OperatorMethodOutput<'tasks.status'>>;
|
|
50
|
+
cancel(taskId: string, ...args: KnownPathMethodArgs<'tasks.cancel', 'taskId'>): Promise<OperatorMethodOutput<'tasks.cancel'>>;
|
|
51
|
+
retry(taskId: string, ...args: KnownPathMethodArgs<'tasks.retry', 'taskId'>): Promise<OperatorMethodOutput<'tasks.retry'>>;
|
|
52
|
+
};
|
|
53
|
+
readonly approvals: {
|
|
54
|
+
list(...args: KnownMethodArgs<'approvals.list'>): Promise<OperatorMethodOutput<'approvals.list'>>;
|
|
55
|
+
claim(approvalId: string, ...args: KnownPathMethodArgs<'approvals.claim', 'approvalId'>): Promise<OperatorMethodOutput<'approvals.claim'>>;
|
|
56
|
+
approve(approvalId: string, ...args: KnownPathMethodArgs<'approvals.approve', 'approvalId'>): Promise<OperatorMethodOutput<'approvals.approve'>>;
|
|
57
|
+
deny(approvalId: string, ...args: KnownPathMethodArgs<'approvals.deny', 'approvalId'>): Promise<OperatorMethodOutput<'approvals.deny'>>;
|
|
58
|
+
cancel(approvalId: string, ...args: KnownPathMethodArgs<'approvals.cancel', 'approvalId'>): Promise<OperatorMethodOutput<'approvals.cancel'>>;
|
|
59
|
+
};
|
|
60
|
+
readonly providers: {
|
|
61
|
+
list(...args: KnownMethodArgs<'providers.list'>): Promise<OperatorMethodOutput<'providers.list'>>;
|
|
62
|
+
get(providerId: string, ...args: KnownPathMethodArgs<'providers.get', 'providerId'>): Promise<OperatorMethodOutput<'providers.get'>>;
|
|
63
|
+
usage(providerId: string, ...args: KnownPathMethodArgs<'providers.usage.get', 'providerId'>): Promise<OperatorMethodOutput<'providers.usage.get'>>;
|
|
64
|
+
};
|
|
65
|
+
readonly accounts: {
|
|
66
|
+
snapshot(...args: KnownMethodArgs<'accounts.snapshot'>): Promise<OperatorMethodOutput<'accounts.snapshot'>>;
|
|
67
|
+
};
|
|
68
|
+
readonly localAuth: {
|
|
69
|
+
status(...args: KnownMethodArgs<'local_auth.status'>): Promise<OperatorMethodOutput<'local_auth.status'>>;
|
|
70
|
+
};
|
|
71
|
+
readonly control: {
|
|
72
|
+
snapshot(...args: KnownMethodArgs<'control.snapshot'>): Promise<OperatorMethodOutput<'control.snapshot'>>;
|
|
73
|
+
status(...args: KnownMethodArgs<'control.status'>): Promise<OperatorMethodOutput<'control.status'>>;
|
|
74
|
+
contract(...args: KnownMethodArgs<'control.contract'>): Promise<OperatorMethodOutput<'control.contract'>>;
|
|
75
|
+
methods: {
|
|
76
|
+
list(...args: KnownMethodArgs<'control.methods.list'>): Promise<OperatorMethodOutput<'control.methods.list'>>;
|
|
77
|
+
get(methodId: string, ...args: KnownPathMethodArgs<'control.methods.get', 'methodId'>): Promise<OperatorMethodOutput<'control.methods.get'>>;
|
|
78
|
+
};
|
|
79
|
+
auth: {
|
|
80
|
+
current(...args: KnownMethodArgs<'control.auth.current'>): Promise<OperatorMethodOutput<'control.auth.current'>>;
|
|
81
|
+
login(...args: KnownMethodArgs<'control.auth.login'>): Promise<OperatorMethodOutput<'control.auth.login'>>;
|
|
82
|
+
};
|
|
83
|
+
events: {
|
|
84
|
+
catalog(...args: KnownMethodArgs<'control.events.catalog'>): Promise<OperatorMethodOutput<'control.events.catalog'>>;
|
|
85
|
+
stream(...args: KnownStreamArgs<'control.events.stream'>): Promise<() => void>;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly telemetry: {
|
|
89
|
+
snapshot(...args: KnownMethodArgs<'telemetry.snapshot'>): Promise<OperatorMethodOutput<'telemetry.snapshot'>>;
|
|
90
|
+
events(...args: KnownMethodArgs<'telemetry.events.list'>): Promise<OperatorMethodOutput<'telemetry.events.list'>>;
|
|
91
|
+
errors(...args: KnownMethodArgs<'telemetry.errors.list'>): Promise<OperatorMethodOutput<'telemetry.errors.list'>>;
|
|
92
|
+
traces(...args: KnownMethodArgs<'telemetry.traces.list'>): Promise<OperatorMethodOutput<'telemetry.traces.list'>>;
|
|
93
|
+
metrics(...args: KnownMethodArgs<'telemetry.metrics.get'>): Promise<OperatorMethodOutput<'telemetry.metrics.get'>>;
|
|
94
|
+
otlp: {
|
|
95
|
+
traces(...args: KnownMethodArgs<'telemetry.otlp.traces'>): Promise<OperatorMethodOutput<'telemetry.otlp.traces'>>;
|
|
96
|
+
logs(...args: KnownMethodArgs<'telemetry.otlp.logs'>): Promise<OperatorMethodOutput<'telemetry.otlp.logs'>>;
|
|
97
|
+
metrics(...args: KnownMethodArgs<'telemetry.otlp.metrics'>): Promise<OperatorMethodOutput<'telemetry.otlp.metrics'>>;
|
|
98
|
+
};
|
|
99
|
+
stream(...args: KnownStreamArgs<'telemetry.stream'>): Promise<() => void>;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export declare function createOperatorRemoteClient(transport: HttpTransport, contract: OperatorContractManifest): OperatorRemoteClient;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=client-core.d.ts.map
|
|
@@ -0,0 +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,C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;CACH;AAoBD,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,wBAAwB,GACjC,oBAAoB,CAiMtB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { buildContractInput, invokeContractRoute, openContractRouteStream, requireContractRoute, } from '@pellux/goodvibes-transport-http';
|
|
2
|
+
function splitArgs(args) {
|
|
3
|
+
return args;
|
|
4
|
+
}
|
|
5
|
+
function requireMethod(contract, methodId) {
|
|
6
|
+
return requireContractRoute(contract.operator.methods, methodId, 'operator method');
|
|
7
|
+
}
|
|
8
|
+
function requireMethodRoute(contract, methodId) {
|
|
9
|
+
const method = requireMethod(contract, methodId);
|
|
10
|
+
if (!method.http) {
|
|
11
|
+
throw new Error(`Operator method "${methodId}" does not expose an HTTP binding`);
|
|
12
|
+
}
|
|
13
|
+
return method.http;
|
|
14
|
+
}
|
|
15
|
+
export function createOperatorRemoteClient(transport, contract) {
|
|
16
|
+
function invokeTyped(methodId, input, options = {}) {
|
|
17
|
+
return invokeContractRoute(transport, requireMethodRoute(contract, methodId), input, options);
|
|
18
|
+
}
|
|
19
|
+
function streamTyped(methodId, ...args) {
|
|
20
|
+
const [input, options] = splitArgs(args);
|
|
21
|
+
return openContractRouteStream(transport, requireMethodRoute(contract, methodId), input, options ?? { handlers: {} });
|
|
22
|
+
}
|
|
23
|
+
const client = {
|
|
24
|
+
transport,
|
|
25
|
+
contract,
|
|
26
|
+
listMethods() {
|
|
27
|
+
return contract.operator.methods;
|
|
28
|
+
},
|
|
29
|
+
getMethod(methodId) {
|
|
30
|
+
return requireMethod(contract, methodId);
|
|
31
|
+
},
|
|
32
|
+
invoke: invokeTyped,
|
|
33
|
+
stream: streamTyped,
|
|
34
|
+
sessions: {
|
|
35
|
+
create: (...args) => invokeTyped('sessions.create', ...args),
|
|
36
|
+
get: (sessionId, ...args) => {
|
|
37
|
+
const [input, options] = splitArgs(args);
|
|
38
|
+
return invokeTyped('sessions.get', buildContractInput('sessionId', sessionId, input), options);
|
|
39
|
+
},
|
|
40
|
+
list: (...args) => invokeTyped('sessions.list', ...args),
|
|
41
|
+
messages: {
|
|
42
|
+
create: (sessionId, ...args) => {
|
|
43
|
+
const [input, options] = splitArgs(args);
|
|
44
|
+
return invokeTyped('sessions.messages.create', buildContractInput('sessionId', sessionId, input), options);
|
|
45
|
+
},
|
|
46
|
+
list: (sessionId, ...args) => {
|
|
47
|
+
const [input, options] = splitArgs(args);
|
|
48
|
+
return invokeTyped('sessions.messages.list', buildContractInput('sessionId', sessionId, input), options);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
inputs: {
|
|
52
|
+
cancel: (sessionId, inputId, ...args) => {
|
|
53
|
+
const [input, options] = splitArgs(args);
|
|
54
|
+
return invokeTyped('sessions.inputs.cancel', {
|
|
55
|
+
sessionId,
|
|
56
|
+
inputId,
|
|
57
|
+
...(input ?? {}),
|
|
58
|
+
}, options);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
followUp: (...args) => invokeTyped('sessions.followUp', ...args),
|
|
62
|
+
steer: (...args) => invokeTyped('sessions.steer', ...args),
|
|
63
|
+
close: (sessionId, ...args) => {
|
|
64
|
+
const [input, options] = splitArgs(args);
|
|
65
|
+
return invokeTyped('sessions.close', {
|
|
66
|
+
sessionId,
|
|
67
|
+
...(input ?? {}),
|
|
68
|
+
}, options);
|
|
69
|
+
},
|
|
70
|
+
reopen: (sessionId, ...args) => {
|
|
71
|
+
const [input, options] = splitArgs(args);
|
|
72
|
+
return invokeTyped('sessions.reopen', {
|
|
73
|
+
sessionId,
|
|
74
|
+
...(input ?? {}),
|
|
75
|
+
}, options);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
tasks: {
|
|
79
|
+
create: (...args) => invokeTyped('tasks.create', ...args),
|
|
80
|
+
get: (taskId, ...args) => {
|
|
81
|
+
const [input, options] = splitArgs(args);
|
|
82
|
+
return invokeTyped('tasks.get', {
|
|
83
|
+
taskId,
|
|
84
|
+
...(input ?? {}),
|
|
85
|
+
}, options);
|
|
86
|
+
},
|
|
87
|
+
list: (...args) => invokeTyped('tasks.list', ...args),
|
|
88
|
+
status: (...args) => invokeTyped('tasks.status', ...args),
|
|
89
|
+
cancel: (taskId, ...args) => {
|
|
90
|
+
const [input, options] = splitArgs(args);
|
|
91
|
+
return invokeTyped('tasks.cancel', {
|
|
92
|
+
taskId,
|
|
93
|
+
...(input ?? {}),
|
|
94
|
+
}, options);
|
|
95
|
+
},
|
|
96
|
+
retry: (taskId, ...args) => {
|
|
97
|
+
const [input, options] = splitArgs(args);
|
|
98
|
+
return invokeTyped('tasks.retry', {
|
|
99
|
+
taskId,
|
|
100
|
+
...(input ?? {}),
|
|
101
|
+
}, options);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
approvals: {
|
|
105
|
+
list: (...args) => invokeTyped('approvals.list', ...args),
|
|
106
|
+
claim: (approvalId, ...args) => {
|
|
107
|
+
const [input, options] = splitArgs(args);
|
|
108
|
+
return invokeTyped('approvals.claim', buildContractInput('approvalId', approvalId, input), options);
|
|
109
|
+
},
|
|
110
|
+
approve: (approvalId, ...args) => {
|
|
111
|
+
const [input, options] = splitArgs(args);
|
|
112
|
+
return invokeTyped('approvals.approve', buildContractInput('approvalId', approvalId, input), options);
|
|
113
|
+
},
|
|
114
|
+
deny: (approvalId, ...args) => {
|
|
115
|
+
const [input, options] = splitArgs(args);
|
|
116
|
+
return invokeTyped('approvals.deny', buildContractInput('approvalId', approvalId, input), options);
|
|
117
|
+
},
|
|
118
|
+
cancel: (approvalId, ...args) => {
|
|
119
|
+
const [input, options] = splitArgs(args);
|
|
120
|
+
return invokeTyped('approvals.cancel', buildContractInput('approvalId', approvalId, input), options);
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
providers: {
|
|
124
|
+
list: (...args) => invokeTyped('providers.list', ...args),
|
|
125
|
+
get: (providerId, ...args) => {
|
|
126
|
+
const [input, options] = splitArgs(args);
|
|
127
|
+
return invokeTyped('providers.get', {
|
|
128
|
+
providerId,
|
|
129
|
+
...(input ?? {}),
|
|
130
|
+
}, options);
|
|
131
|
+
},
|
|
132
|
+
usage: (providerId, ...args) => {
|
|
133
|
+
const [input, options] = splitArgs(args);
|
|
134
|
+
return invokeTyped('providers.usage.get', {
|
|
135
|
+
providerId,
|
|
136
|
+
...(input ?? {}),
|
|
137
|
+
}, options);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
accounts: {
|
|
141
|
+
snapshot: (...args) => invokeTyped('accounts.snapshot', ...args),
|
|
142
|
+
},
|
|
143
|
+
localAuth: {
|
|
144
|
+
status: (...args) => invokeTyped('local_auth.status', ...args),
|
|
145
|
+
},
|
|
146
|
+
control: {
|
|
147
|
+
snapshot: (...args) => invokeTyped('control.snapshot', ...args),
|
|
148
|
+
status: (...args) => invokeTyped('control.status', ...args),
|
|
149
|
+
contract: (...args) => invokeTyped('control.contract', ...args),
|
|
150
|
+
methods: {
|
|
151
|
+
list: (...args) => invokeTyped('control.methods.list', ...args),
|
|
152
|
+
get: (methodId, ...args) => {
|
|
153
|
+
const [input, options] = splitArgs(args);
|
|
154
|
+
return invokeTyped('control.methods.get', {
|
|
155
|
+
methodId,
|
|
156
|
+
...(input ?? {}),
|
|
157
|
+
}, options);
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
auth: {
|
|
161
|
+
current: (...args) => invokeTyped('control.auth.current', ...args),
|
|
162
|
+
login: (...args) => invokeTyped('control.auth.login', ...args),
|
|
163
|
+
},
|
|
164
|
+
events: {
|
|
165
|
+
catalog: (...args) => invokeTyped('control.events.catalog', ...args),
|
|
166
|
+
stream: (...args) => streamTyped('control.events.stream', ...args),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
telemetry: {
|
|
170
|
+
snapshot: (...args) => invokeTyped('telemetry.snapshot', ...args),
|
|
171
|
+
events: (...args) => invokeTyped('telemetry.events.list', ...args),
|
|
172
|
+
errors: (...args) => invokeTyped('telemetry.errors.list', ...args),
|
|
173
|
+
traces: (...args) => invokeTyped('telemetry.traces.list', ...args),
|
|
174
|
+
metrics: (...args) => invokeTyped('telemetry.metrics.get', ...args),
|
|
175
|
+
otlp: {
|
|
176
|
+
traces: (...args) => invokeTyped('telemetry.otlp.traces', ...args),
|
|
177
|
+
logs: (...args) => invokeTyped('telemetry.otlp.logs', ...args),
|
|
178
|
+
metrics: (...args) => invokeTyped('telemetry.otlp.metrics', ...args),
|
|
179
|
+
},
|
|
180
|
+
stream: (...args) => streamTyped('telemetry.stream', ...args),
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
return client;
|
|
184
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OperatorMethodContract, OperatorMethodId } from '@pellux/goodvibes-contracts';
|
|
2
|
+
import { type HttpTransport, type HttpTransportOptions, type ServerSentEventHandlers } from '@pellux/goodvibes-transport-http';
|
|
3
|
+
import { type OperatorRemoteClient, type OperatorRemoteClientInvokeOptions, type OperatorRemoteClientStreamOptions } from './client-core.js';
|
|
4
|
+
export interface OperatorSdkOptions extends HttpTransportOptions {
|
|
5
|
+
}
|
|
6
|
+
export interface OperatorInvokeOptions extends OperatorRemoteClientInvokeOptions {
|
|
7
|
+
}
|
|
8
|
+
export interface OperatorStreamOptions extends OperatorRemoteClientStreamOptions {
|
|
9
|
+
readonly handlers: ServerSentEventHandlers;
|
|
10
|
+
}
|
|
11
|
+
export type OperatorSdk = Omit<OperatorRemoteClient, 'getMethod'> & {
|
|
12
|
+
readonly transport: HttpTransport;
|
|
13
|
+
getMethod(methodId: OperatorMethodId): OperatorMethodContract;
|
|
14
|
+
};
|
|
15
|
+
export declare function createOperatorSdk(options: OperatorSdkOptions): OperatorSdk;
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getOperatorContract } from '@pellux/goodvibes-contracts';
|
|
2
|
+
import { createHttpTransport, } from '@pellux/goodvibes-transport-http';
|
|
3
|
+
import { createOperatorRemoteClient, } from './client-core.js';
|
|
4
|
+
export function createOperatorSdk(options) {
|
|
5
|
+
const transport = createHttpTransport(options);
|
|
6
|
+
return createOperatorRemoteClient(transport, getOperatorContract());
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createOperatorSdk } from './client.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pellux/goodvibes-operator-sdk",
|
|
3
|
+
"version": "0.18.3",
|
|
4
|
+
"description": "Contract-driven HTTP client for the GoodVibes operator and control-plane APIs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/mgd34msu/goodvibes-sdk.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/mgd34msu/goodvibes-sdk/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/mgd34msu/goodvibes-sdk",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"goodvibes",
|
|
30
|
+
"sdk",
|
|
31
|
+
"operator",
|
|
32
|
+
"control-plane",
|
|
33
|
+
"client"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"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
|
+
}
|
|
43
|
+
}
|