@nodaro/sdk 1.10.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 CHANGED
@@ -2118,10 +2118,17 @@ var CommunityResource = class {
2118
2118
  };
2119
2119
 
2120
2120
  // src/client.ts
2121
+ var SDK_VERSION = "1.12.0" ;
2122
+ var CLIENT_HEADER = "X-Nodaro-Client";
2123
+ var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
2121
2124
  var NodaroClient = class {
2122
2125
  baseUrl;
2123
2126
  auth;
2124
2127
  timeoutMs;
2128
+ /** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */
2129
+ clientLabel;
2130
+ /** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */
2131
+ sendClientHeader;
2125
2132
  fetchOverride;
2126
2133
  /**
2127
2134
  * Resolved lazily so consumers can swap `globalThis.fetch` after the
@@ -2162,6 +2169,8 @@ var NodaroClient = class {
2162
2169
  this.auth = opts.auth;
2163
2170
  this.fetchOverride = opts.fetch;
2164
2171
  this.timeoutMs = opts.timeoutMs ?? 6e4;
2172
+ this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`;
2173
+ this.sendClientHeader = opts.clientLabel !== void 0 || !isBrowser();
2165
2174
  this.workflows = new WorkflowsResource(this);
2166
2175
  this.projects = new ProjectsResource(this);
2167
2176
  this.jobs = new JobsResource(this);
@@ -2194,6 +2203,7 @@ var NodaroClient = class {
2194
2203
  const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
2195
2204
  const headers = {
2196
2205
  ...isFormData ? {} : { "Content-Type": "application/json" },
2206
+ ...this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {},
2197
2207
  ...options.headers ?? {}
2198
2208
  };
2199
2209
  if (token) headers["Authorization"] = `Bearer ${token}`;