@nodaro/sdk 1.11.0 → 1.12.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/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -4438,6 +4438,14 @@ interface ClientOptions {
|
|
|
4438
4438
|
fetch?: typeof fetch;
|
|
4439
4439
|
/** Default request timeout in ms. Default 60s. */
|
|
4440
4440
|
timeoutMs?: number;
|
|
4441
|
+
/**
|
|
4442
|
+
* Overrides the `X-Nodaro-Client` label. Defaults to `sdk/<version>`.
|
|
4443
|
+
*
|
|
4444
|
+
* Exists for `@nodaro/cli`, which is a wrapper AROUND this SDK: without an
|
|
4445
|
+
* override every CLI invocation would be recorded as an SDK call and the two
|
|
4446
|
+
* surfaces could never be told apart.
|
|
4447
|
+
*/
|
|
4448
|
+
clientLabel?: string;
|
|
4441
4449
|
}
|
|
4442
4450
|
interface RequestOptions {
|
|
4443
4451
|
body?: unknown;
|
|
@@ -4466,6 +4474,10 @@ declare class NodaroClient {
|
|
|
4466
4474
|
readonly baseUrl: string;
|
|
4467
4475
|
readonly auth: Auth;
|
|
4468
4476
|
readonly timeoutMs: number;
|
|
4477
|
+
/** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */
|
|
4478
|
+
readonly clientLabel: string;
|
|
4479
|
+
/** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */
|
|
4480
|
+
private readonly sendClientHeader;
|
|
4469
4481
|
private readonly fetchOverride;
|
|
4470
4482
|
/**
|
|
4471
4483
|
* Resolved lazily so consumers can swap `globalThis.fetch` after the
|
package/dist/index.d.ts
CHANGED
|
@@ -4438,6 +4438,14 @@ interface ClientOptions {
|
|
|
4438
4438
|
fetch?: typeof fetch;
|
|
4439
4439
|
/** Default request timeout in ms. Default 60s. */
|
|
4440
4440
|
timeoutMs?: number;
|
|
4441
|
+
/**
|
|
4442
|
+
* Overrides the `X-Nodaro-Client` label. Defaults to `sdk/<version>`.
|
|
4443
|
+
*
|
|
4444
|
+
* Exists for `@nodaro/cli`, which is a wrapper AROUND this SDK: without an
|
|
4445
|
+
* override every CLI invocation would be recorded as an SDK call and the two
|
|
4446
|
+
* surfaces could never be told apart.
|
|
4447
|
+
*/
|
|
4448
|
+
clientLabel?: string;
|
|
4441
4449
|
}
|
|
4442
4450
|
interface RequestOptions {
|
|
4443
4451
|
body?: unknown;
|
|
@@ -4466,6 +4474,10 @@ declare class NodaroClient {
|
|
|
4466
4474
|
readonly baseUrl: string;
|
|
4467
4475
|
readonly auth: Auth;
|
|
4468
4476
|
readonly timeoutMs: number;
|
|
4477
|
+
/** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */
|
|
4478
|
+
readonly clientLabel: string;
|
|
4479
|
+
/** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */
|
|
4480
|
+
private readonly sendClientHeader;
|
|
4469
4481
|
private readonly fetchOverride;
|
|
4470
4482
|
/**
|
|
4471
4483
|
* Resolved lazily so consumers can swap `globalThis.fetch` after the
|
package/dist/index.js
CHANGED
|
@@ -2117,10 +2117,17 @@ var CommunityResource = class {
|
|
|
2117
2117
|
};
|
|
2118
2118
|
|
|
2119
2119
|
// src/client.ts
|
|
2120
|
+
var SDK_VERSION = "1.12.0" ;
|
|
2121
|
+
var CLIENT_HEADER = "X-Nodaro-Client";
|
|
2122
|
+
var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2120
2123
|
var NodaroClient = class {
|
|
2121
2124
|
baseUrl;
|
|
2122
2125
|
auth;
|
|
2123
2126
|
timeoutMs;
|
|
2127
|
+
/** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */
|
|
2128
|
+
clientLabel;
|
|
2129
|
+
/** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */
|
|
2130
|
+
sendClientHeader;
|
|
2124
2131
|
fetchOverride;
|
|
2125
2132
|
/**
|
|
2126
2133
|
* Resolved lazily so consumers can swap `globalThis.fetch` after the
|
|
@@ -2161,6 +2168,8 @@ var NodaroClient = class {
|
|
|
2161
2168
|
this.auth = opts.auth;
|
|
2162
2169
|
this.fetchOverride = opts.fetch;
|
|
2163
2170
|
this.timeoutMs = opts.timeoutMs ?? 6e4;
|
|
2171
|
+
this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`;
|
|
2172
|
+
this.sendClientHeader = opts.clientLabel !== void 0 || !isBrowser();
|
|
2164
2173
|
this.workflows = new WorkflowsResource(this);
|
|
2165
2174
|
this.projects = new ProjectsResource(this);
|
|
2166
2175
|
this.jobs = new JobsResource(this);
|
|
@@ -2193,6 +2202,7 @@ var NodaroClient = class {
|
|
|
2193
2202
|
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
2194
2203
|
const headers = {
|
|
2195
2204
|
...isFormData ? {} : { "Content-Type": "application/json" },
|
|
2205
|
+
...this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {},
|
|
2196
2206
|
...options.headers ?? {}
|
|
2197
2207
|
};
|
|
2198
2208
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|