@nodaro/sdk 1.25.0 → 1.26.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
@@ -331,6 +331,14 @@ var JobsResource = class {
331
331
  get(id) {
332
332
  return this.client.request("GET", `/v1/jobs/${encodeURIComponent(id)}`);
333
333
  }
334
+ /**
335
+ * Your jobs, newest first (`GET /v1/jobs`), cursor-paginated. `type` and
336
+ * `origin` filter on the job's own `input_data`, which every job carries —
337
+ * a client app lists its runs with `{ type: "llm-structured", origin: "studio" }`.
338
+ */
339
+ list(params = {}) {
340
+ return this.client.request("GET", "/v1/jobs", { query: { ...params } });
341
+ }
334
342
  /**
335
343
  * Get the lean status of a single job (poll-loop friendly).
336
344
  * Hits `GET /v1/jobs/:id/status` — returns only id/status/progress/
@@ -1793,6 +1801,36 @@ var VoicesResource = class {
1793
1801
  }
1794
1802
  };
1795
1803
 
1804
+ // src/resources/llm.ts
1805
+ var LlmResource = class {
1806
+ constructor(client) {
1807
+ this.client = client;
1808
+ }
1809
+ client;
1810
+ /**
1811
+ * Synchronous forced-schema completion (`POST /v1/llm/structured`). A call
1812
+ * can run several minutes — longer than the client's default 60 s
1813
+ * `timeoutMs`; construct the client with a larger `timeoutMs` for this
1814
+ * call, or use {@link LlmResource.structuredJob}.
1815
+ */
1816
+ structured(input) {
1817
+ return this.client.request("POST", "/v1/llm/structured", { body: input });
1818
+ }
1819
+ /**
1820
+ * The same call as a job (`POST /v1/llm/structured/jobs`): answers `{ jobId }`
1821
+ * at once. Poll `jobs.getStatus(jobId)` — `output_data` is an
1822
+ * {@link LlmStructuredJobOutput}; `error_message` says why a run failed.
1823
+ * `jobs.list({ type: "llm-structured", origin })` finds every run later.
1824
+ * Throws `NotFoundError` on a platform that predates the route. An instance
1825
+ * that proxies its LLM calls to nodaro.ai answers `503 provider_unavailable`
1826
+ * permanently — the SDK surfaces that as a generic `NodaroError` with the
1827
+ * same code; treat it as unavailable here, not as transient.
1828
+ */
1829
+ structuredJob(input) {
1830
+ return this.client.request("POST", "/v1/llm/structured/jobs", { body: input });
1831
+ }
1832
+ };
1833
+
1796
1834
  // src/resources/media.ts
1797
1835
  var MediaResource = class {
1798
1836
  constructor(client) {
@@ -1942,6 +1980,16 @@ var MediaResource = class {
1942
1980
  videoMetadata(input) {
1943
1981
  return this.client.request("POST", "/v1/video-metadata", { body: input });
1944
1982
  }
1983
+ /**
1984
+ * Cut or crop a stored file (`POST /v1/media/process`) — synchronous and
1985
+ * free, the source-preparation sibling of the priced `trimVideo` node.
1986
+ * `trim` is `[startTime, endTime]` in seconds; `deleteSource: true` removes
1987
+ * the source object afterwards when it is yours and nothing else references
1988
+ * it ("the cut replaces the original"). Answers the stored file.
1989
+ */
1990
+ process(input) {
1991
+ return this.client.request("POST", "/v1/media/process", { body: input });
1992
+ }
1945
1993
  };
1946
1994
 
1947
1995
  // src/resources/audio.ts
@@ -2543,6 +2591,23 @@ var OrganizationsResource = class {
2543
2591
  audit(orgId, opts = {}) {
2544
2592
  return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/audit`, { query: { ...opts } });
2545
2593
  }
2594
+ // -- usage ----------------------------------------------------------------
2595
+ /**
2596
+ * Credits by workspace, member, model or day. Owner and org admins only.
2597
+ * Inclusive dates (`from`/`to`), IANA `tz` (default UTC), ≤ 366 days
2598
+ * (default last 30).
2599
+ */
2600
+ usage(orgId, opts = {}) {
2601
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/usage`, { query: { ...opts } });
2602
+ }
2603
+ /** The individual runs behind a report, newest first, cursor-paged. */
2604
+ usageRows(orgId, opts = {}) {
2605
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/usage`, { query: { ...opts, groupBy: "none" } });
2606
+ }
2607
+ /** The same report (or the rows, with `groupBy: "none"`) as CSV text. */
2608
+ usageCsv(orgId, opts = {}) {
2609
+ return this.client.requestText("GET", `/v1/orgs/${encodeURIComponent(orgId)}/usage`, { query: { ...opts, format: "csv" } });
2610
+ }
2546
2611
  };
2547
2612
 
2548
2613
  // src/resources/workspaces.ts
@@ -2634,8 +2699,26 @@ var WorkspacesResource = class {
2634
2699
  join(code) {
2635
2700
  return this.client.request("POST", "/v1/workspaces/join", { body: { code } });
2636
2701
  }
2702
+ // -- usage ----------------------------------------------------------------
2703
+ /**
2704
+ * Credits by member, model or day for this workspace. A plain member sees
2705
+ * their OWN runs (the report is self-narrowed and `groupBy: "member"` is
2706
+ * refused); a workspace admin sees everyone and may filter `userId`.
2707
+ * Inclusive dates, IANA `tz` (default UTC), ≤ 366 days (default last 30).
2708
+ */
2709
+ usage(id, opts = {}) {
2710
+ return this.client.request("GET", `/v1/workspaces/${encodeURIComponent(id)}/usage`, { query: { ...opts } });
2711
+ }
2712
+ /** The individual runs behind a report, newest first, cursor-paged. */
2713
+ usageRows(id, opts = {}) {
2714
+ return this.client.request("GET", `/v1/workspaces/${encodeURIComponent(id)}/usage`, { query: { ...opts, groupBy: "none" } });
2715
+ }
2716
+ /** The same report (or the rows, with `groupBy: "none"`) as CSV text. */
2717
+ usageCsv(id, opts = {}) {
2718
+ return this.client.requestText("GET", `/v1/workspaces/${encodeURIComponent(id)}/usage`, { query: { ...opts, format: "csv" } });
2719
+ }
2637
2720
  };
2638
- var SDK_VERSION = "1.25.0" ;
2721
+ var SDK_VERSION = "1.26.0" ;
2639
2722
  var CLIENT_HEADER = "X-Nodaro-Client";
2640
2723
  var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
2641
2724
  var NodaroClient = class _NodaroClient {
@@ -2673,6 +2756,7 @@ var NodaroClient = class _NodaroClient {
2673
2756
  reduce;
2674
2757
  promptHelper;
2675
2758
  voices;
2759
+ llm;
2676
2760
  media;
2677
2761
  audio;
2678
2762
  credits;
@@ -2716,6 +2800,7 @@ var NodaroClient = class _NodaroClient {
2716
2800
  this.reduce = new ReduceResource(this);
2717
2801
  this.promptHelper = new PromptHelperResource(this);
2718
2802
  this.voices = new VoicesResource(this);
2803
+ this.llm = new LlmResource(this);
2719
2804
  this.media = new MediaResource(this);
2720
2805
  this.audio = new AudioResource(this);
2721
2806
  this.credits = new CreditsResource(this);
@@ -2754,7 +2839,14 @@ var NodaroClient = class _NodaroClient {
2754
2839
  ...workspaceId ? { workspaceId } : {}
2755
2840
  });
2756
2841
  }
2757
- async request(method, path, options = {}) {
2842
+ /**
2843
+ * The transport: build the request, send it, throw the typed error on a
2844
+ * non-2xx via {@link throwFromResponse}, then read the body via `read` — all
2845
+ * inside the abort timer, so `timeoutMs` bounds the body download too (a
2846
+ * stalled CSV stream aborts, it does not hang forever). Both the JSON path
2847
+ * ({@link request}) and the text path ({@link requestText}) go through here.
2848
+ */
2849
+ async send(method, path, options, read) {
2758
2850
  const url = this.buildUrl(path, options.query);
2759
2851
  const token = await this.auth.getToken();
2760
2852
  const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
@@ -2787,12 +2879,30 @@ var NodaroClient = class _NodaroClient {
2787
2879
  }
2788
2880
  throwFromResponse(res.status, errBody);
2789
2881
  }
2790
- if (res.status === 204) return void 0;
2791
- return await res.json();
2882
+ return await read(res);
2792
2883
  } finally {
2793
2884
  clearTimeout(timeoutId);
2794
2885
  }
2795
2886
  }
2887
+ async request(method, path, options = {}) {
2888
+ return this.send(
2889
+ method,
2890
+ path,
2891
+ options,
2892
+ async (res) => (
2893
+ // 204 No Content
2894
+ res.status === 204 ? void 0 : await res.json()
2895
+ )
2896
+ );
2897
+ }
2898
+ /**
2899
+ * Like {@link request}, for endpoints that answer text (CSV exports). Errors
2900
+ * are still the JSON envelope and throw the same typed errors, and the read is
2901
+ * bounded by the same timeout as the request.
2902
+ */
2903
+ async requestText(method, path, options = {}) {
2904
+ return this.send(method, path, options, (res) => res.text());
2905
+ }
2796
2906
  /**
2797
2907
  * `GET /v1/me` → the authenticated user's identity (see {@link UserIdentity}).
2798
2908
  * Unwraps the `{ data }` envelope. Throws `UnauthorizedError` (401) when the
@@ -2932,6 +3042,10 @@ Object.defineProperty(exports, "SURROUND_DIRECTIONS", {
2932
3042
  enumerable: true,
2933
3043
  get: function () { return shared.SURROUND_DIRECTIONS; }
2934
3044
  });
3045
+ Object.defineProperty(exports, "USAGE_GROUP_BYS", {
3046
+ enumerable: true,
3047
+ get: function () { return shared.USAGE_GROUP_BYS; }
3048
+ });
2935
3049
  Object.defineProperty(exports, "WORKSPACE_HEADER", {
2936
3050
  enumerable: true,
2937
3051
  get: function () { return shared.WORKSPACE_HEADER; }
@@ -2954,6 +3068,7 @@ exports.JobFailedError = JobFailedError;
2954
3068
  exports.JobTimeoutError = JobTimeoutError;
2955
3069
  exports.JobsResource = JobsResource;
2956
3070
  exports.LibraryResource = LibraryResource;
3071
+ exports.LlmResource = LlmResource;
2957
3072
  exports.LocationsResource = LocationsResource;
2958
3073
  exports.MediaResource = MediaResource;
2959
3074
  exports.ModelsResource = ModelsResource;