@stigmer/sdk 3.4.0 → 3.4.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/__tests__/node.test.js +15 -0
- package/__tests__/node.test.js.map +1 -1
- package/node.d.ts +24 -1
- package/node.d.ts.map +1 -1
- package/node.js +14 -2
- package/node.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/node.test.ts +17 -0
- package/src/node.ts +35 -2
package/__tests__/node.test.js
CHANGED
|
@@ -21,6 +21,21 @@ describe("createNodeTransport", () => {
|
|
|
21
21
|
});
|
|
22
22
|
expect(transport).toBeDefined();
|
|
23
23
|
});
|
|
24
|
+
it("creates a native gRPC transport when protocol is grpc", () => {
|
|
25
|
+
const transport = createNodeTransport({
|
|
26
|
+
baseUrl: "https://api.stigmer.ai",
|
|
27
|
+
apiKey: "sk_test_123",
|
|
28
|
+
protocol: "grpc",
|
|
29
|
+
});
|
|
30
|
+
expect(transport).toBeDefined();
|
|
31
|
+
});
|
|
32
|
+
it("defaults to gRPC-web when protocol is omitted", () => {
|
|
33
|
+
const transport = createNodeTransport({
|
|
34
|
+
baseUrl: "https://api.stigmer.ai",
|
|
35
|
+
protocol: "grpc-web",
|
|
36
|
+
});
|
|
37
|
+
expect(transport).toBeDefined();
|
|
38
|
+
});
|
|
24
39
|
});
|
|
25
40
|
describe("createNodeClient", () => {
|
|
26
41
|
it("creates a Stigmer client with API key", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../../src/__tests__/node.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEhE,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;Q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AG,EAAE,CAAC,WAAW;SAClC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,MAAM,GAAG,gBAAgB,CAAC;YAC9B,OAAO,EAAE,wBAAwB;YACjC,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/node.d.ts
CHANGED
|
@@ -15,9 +15,28 @@ export interface NodeClientConfig {
|
|
|
15
15
|
readonly apiKey?: string;
|
|
16
16
|
/** Dynamic token provider for authentication. */
|
|
17
17
|
readonly getAccessToken?: TokenProvider;
|
|
18
|
+
/**
|
|
19
|
+
* gRPC wire protocol to speak to the backend. Defaults to `"grpc-web"`.
|
|
20
|
+
*
|
|
21
|
+
* - `"grpc-web"` (default) traverses HTTP/1.1 proxies and browser-grade
|
|
22
|
+
* edges, so it is the safe choice for the CLI and Ink apps that may
|
|
23
|
+
* sit behind arbitrary corporate proxies or an ingress that only
|
|
24
|
+
* understands gRPC-Web.
|
|
25
|
+
* - `"grpc"` is native gRPC over HTTP/2. Use it for in-cluster,
|
|
26
|
+
* server-to-server callers that dial a gRPC endpoint directly — a
|
|
27
|
+
* Java gRPC server (like stigmer-service on its internal address)
|
|
28
|
+
* rejects gRPC-Web content types with HTTP 415, and the OSS Go server
|
|
29
|
+
* serves native gRPC on the same listener, so `"grpc"` is correct
|
|
30
|
+
* against both. This mirrors the runner's own backend client
|
|
31
|
+
* (`backend/services/runner/src/client/stigmer-client.ts`), the other
|
|
32
|
+
* in-cluster Node caller.
|
|
33
|
+
*
|
|
34
|
+
* @default "grpc-web"
|
|
35
|
+
*/
|
|
36
|
+
readonly protocol?: "grpc" | "grpc-web";
|
|
18
37
|
}
|
|
19
38
|
/**
|
|
20
|
-
* Create a gRPC-web
|
|
39
|
+
* Create a Node.js transport (gRPC-web by default, native gRPC opt-in).
|
|
21
40
|
*
|
|
22
41
|
* The interceptor chain matches the browser transport for consistent
|
|
23
42
|
* behavior across runtimes:
|
|
@@ -28,6 +47,10 @@ export interface NodeClientConfig {
|
|
|
28
47
|
* The browser-specific auth-redirect interceptor (`onUnauthenticated`)
|
|
29
48
|
* is intentionally omitted — Node.js consumers handle auth failures
|
|
30
49
|
* through error handling, not UI redirects.
|
|
50
|
+
*
|
|
51
|
+
* The wire protocol is chosen by {@link NodeClientConfig.protocol}
|
|
52
|
+
* (default `"grpc-web"` over HTTP/2); pass `"grpc"` for native gRPC when
|
|
53
|
+
* dialing a gRPC endpoint directly.
|
|
31
54
|
*/
|
|
32
55
|
export declare function createNodeTransport(config: NodeClientConfig): Transport;
|
|
33
56
|
/**
|
package/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOzD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACzC;AAED
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAOzD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;IAExC;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAyBvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CASlE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyBrD"}
|
package/node.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createGrpcWebTransport } from "@connectrpc/connect-node";
|
|
1
|
+
import { createGrpcTransport, createGrpcWebTransport } from "@connectrpc/connect-node";
|
|
2
2
|
import { Stigmer } from "./index.js";
|
|
3
3
|
import { createAuthInterceptor, rpcMetadataInterceptor, errorStripInterceptor, } from "./internal/interceptors.js";
|
|
4
4
|
export { createPlatformClientAuth, PlatformClientAuth, } from "./platform-client-auth.js";
|
|
5
5
|
/**
|
|
6
|
-
* Create a gRPC-web
|
|
6
|
+
* Create a Node.js transport (gRPC-web by default, native gRPC opt-in).
|
|
7
7
|
*
|
|
8
8
|
* The interceptor chain matches the browser transport for consistent
|
|
9
9
|
* behavior across runtimes:
|
|
@@ -14,6 +14,10 @@ export { createPlatformClientAuth, PlatformClientAuth, } from "./platform-client
|
|
|
14
14
|
* The browser-specific auth-redirect interceptor (`onUnauthenticated`)
|
|
15
15
|
* is intentionally omitted — Node.js consumers handle auth failures
|
|
16
16
|
* through error handling, not UI redirects.
|
|
17
|
+
*
|
|
18
|
+
* The wire protocol is chosen by {@link NodeClientConfig.protocol}
|
|
19
|
+
* (default `"grpc-web"` over HTTP/2); pass `"grpc"` for native gRPC when
|
|
20
|
+
* dialing a gRPC endpoint directly.
|
|
17
21
|
*/
|
|
18
22
|
export function createNodeTransport(config) {
|
|
19
23
|
const tokenProvider = config.apiKey
|
|
@@ -24,6 +28,14 @@ export function createNodeTransport(config) {
|
|
|
24
28
|
rpcMetadataInterceptor,
|
|
25
29
|
errorStripInterceptor,
|
|
26
30
|
];
|
|
31
|
+
if (config.protocol === "grpc") {
|
|
32
|
+
// Native gRPC is HTTP/2-only; the transport does not take an
|
|
33
|
+
// httpVersion knob (unlike gRPC-web).
|
|
34
|
+
return createGrpcTransport({
|
|
35
|
+
baseUrl: config.baseUrl,
|
|
36
|
+
interceptors,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
27
39
|
return createGrpcWebTransport({
|
|
28
40
|
baseUrl: config.baseUrl,
|
|
29
41
|
httpVersion: "2",
|
package/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,OAAO,EAAsB,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GAInB,MAAM,2BAA2B,CAAC;AAwCnC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAwB;IAC1D,MAAM,aAAa,GAAkB,MAAM,CAAC,MAAM;QAChD,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAO;QACtB,CAAC,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAE1C,MAAM,YAAY,GAAkB;QAClC,qBAAqB,CAAC,aAAa,CAAC;QACpC,sBAAsB;QACtB,qBAAqB;KACtB,CAAC;IAEF,IAAI,MAAM,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QAC/B,6DAA6D;QAC7D,sCAAsC;QACtC,OAAO,mBAAmB,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,sBAAsB,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,GAAG;QAChB,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE9C,OAAO,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+
"version": "3.4.1",
|
|
4
4
|
"description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@bufbuild/protobuf": "^2.0.0",
|
|
47
47
|
"@connectrpc/connect-node": "^2.0.0",
|
|
48
|
-
"@stigmer/protos": "3.4.
|
|
48
|
+
"@stigmer/protos": "3.4.1"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -24,6 +24,23 @@ describe("createNodeTransport", () => {
|
|
|
24
24
|
});
|
|
25
25
|
expect(transport).toBeDefined();
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
it("creates a native gRPC transport when protocol is grpc", () => {
|
|
29
|
+
const transport = createNodeTransport({
|
|
30
|
+
baseUrl: "https://api.stigmer.ai",
|
|
31
|
+
apiKey: "sk_test_123",
|
|
32
|
+
protocol: "grpc",
|
|
33
|
+
});
|
|
34
|
+
expect(transport).toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("defaults to gRPC-web when protocol is omitted", () => {
|
|
38
|
+
const transport = createNodeTransport({
|
|
39
|
+
baseUrl: "https://api.stigmer.ai",
|
|
40
|
+
protocol: "grpc-web",
|
|
41
|
+
});
|
|
42
|
+
expect(transport).toBeDefined();
|
|
43
|
+
});
|
|
27
44
|
});
|
|
28
45
|
|
|
29
46
|
describe("createNodeClient", () => {
|
package/src/node.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createGrpcWebTransport } from "@connectrpc/connect-node";
|
|
1
|
+
import { createGrpcTransport, createGrpcWebTransport } from "@connectrpc/connect-node";
|
|
2
2
|
import type { Transport, Interceptor } from "@connectrpc/connect";
|
|
3
3
|
import { Stigmer, type TokenProvider } from "./index.js";
|
|
4
4
|
import {
|
|
@@ -31,10 +31,30 @@ export interface NodeClientConfig {
|
|
|
31
31
|
|
|
32
32
|
/** Dynamic token provider for authentication. */
|
|
33
33
|
readonly getAccessToken?: TokenProvider;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* gRPC wire protocol to speak to the backend. Defaults to `"grpc-web"`.
|
|
37
|
+
*
|
|
38
|
+
* - `"grpc-web"` (default) traverses HTTP/1.1 proxies and browser-grade
|
|
39
|
+
* edges, so it is the safe choice for the CLI and Ink apps that may
|
|
40
|
+
* sit behind arbitrary corporate proxies or an ingress that only
|
|
41
|
+
* understands gRPC-Web.
|
|
42
|
+
* - `"grpc"` is native gRPC over HTTP/2. Use it for in-cluster,
|
|
43
|
+
* server-to-server callers that dial a gRPC endpoint directly — a
|
|
44
|
+
* Java gRPC server (like stigmer-service on its internal address)
|
|
45
|
+
* rejects gRPC-Web content types with HTTP 415, and the OSS Go server
|
|
46
|
+
* serves native gRPC on the same listener, so `"grpc"` is correct
|
|
47
|
+
* against both. This mirrors the runner's own backend client
|
|
48
|
+
* (`backend/services/runner/src/client/stigmer-client.ts`), the other
|
|
49
|
+
* in-cluster Node caller.
|
|
50
|
+
*
|
|
51
|
+
* @default "grpc-web"
|
|
52
|
+
*/
|
|
53
|
+
readonly protocol?: "grpc" | "grpc-web";
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
/**
|
|
37
|
-
* Create a gRPC-web
|
|
57
|
+
* Create a Node.js transport (gRPC-web by default, native gRPC opt-in).
|
|
38
58
|
*
|
|
39
59
|
* The interceptor chain matches the browser transport for consistent
|
|
40
60
|
* behavior across runtimes:
|
|
@@ -45,6 +65,10 @@ export interface NodeClientConfig {
|
|
|
45
65
|
* The browser-specific auth-redirect interceptor (`onUnauthenticated`)
|
|
46
66
|
* is intentionally omitted — Node.js consumers handle auth failures
|
|
47
67
|
* through error handling, not UI redirects.
|
|
68
|
+
*
|
|
69
|
+
* The wire protocol is chosen by {@link NodeClientConfig.protocol}
|
|
70
|
+
* (default `"grpc-web"` over HTTP/2); pass `"grpc"` for native gRPC when
|
|
71
|
+
* dialing a gRPC endpoint directly.
|
|
48
72
|
*/
|
|
49
73
|
export function createNodeTransport(config: NodeClientConfig): Transport {
|
|
50
74
|
const tokenProvider: TokenProvider = config.apiKey
|
|
@@ -57,6 +81,15 @@ export function createNodeTransport(config: NodeClientConfig): Transport {
|
|
|
57
81
|
errorStripInterceptor,
|
|
58
82
|
];
|
|
59
83
|
|
|
84
|
+
if (config.protocol === "grpc") {
|
|
85
|
+
// Native gRPC is HTTP/2-only; the transport does not take an
|
|
86
|
+
// httpVersion knob (unlike gRPC-web).
|
|
87
|
+
return createGrpcTransport({
|
|
88
|
+
baseUrl: config.baseUrl,
|
|
89
|
+
interceptors,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
60
93
|
return createGrpcWebTransport({
|
|
61
94
|
baseUrl: config.baseUrl,
|
|
62
95
|
httpVersion: "2",
|