@nodaro/sdk 1.17.0 → 1.19.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.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { buildPersonHints } from '@nodaro/prompts';
2
2
  export { PEOPLE, PERSON_DIMENSION_LABELS, PERSON_DIMENSION_ORDER, buildPersonHints } from '@nodaro/prompts';
3
- export { CHARACTER_ASPECT_DEFAULTS, CHARACTER_ASPECT_OPTIONS, CHARACTER_STYLES, OBJECT_ASPECT_DEFAULTS as CREATURE_ASPECT_DEFAULTS, OBJECT_ASPECT_OPTIONS as CREATURE_ASPECT_OPTIONS, CREATURE_ATTACH_COLUMNS, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASPECT_DEFAULTS, OBJECT_ASPECT_OPTIONS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS, SURROUND_DIRECTIONS } from '@nodaro/shared';
3
+ import { WORKSPACE_HEADER } from '@nodaro/shared';
4
+ export { CHARACTER_ASPECT_DEFAULTS, CHARACTER_ASPECT_OPTIONS, CHARACTER_STYLES, OBJECT_ASPECT_DEFAULTS as CREATURE_ASPECT_DEFAULTS, OBJECT_ASPECT_OPTIONS as CREATURE_ASPECT_OPTIONS, CREATURE_ATTACH_COLUMNS, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASPECT_DEFAULTS, OBJECT_ASPECT_OPTIONS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS, SURROUND_DIRECTIONS, WORKSPACE_HEADER } from '@nodaro/shared';
4
5
 
5
6
  // src/errors.ts
6
7
  var NodaroError = class extends Error {
@@ -199,6 +200,9 @@ var WorkflowsResource = class {
199
200
  /**
200
201
  * Import a `WorkflowExport` bundle into the specified project.
201
202
  * Re-creates any bundled assets (characters, objects, locations) under your account.
203
+ * Media the bundle references on other hosts is copied onto this instance's
204
+ * storage where reachable; `importReport` says what was copied, what could
205
+ * not be reached, and what was skipped (and why).
202
206
  */
203
207
  import(input) {
204
208
  const { projectId, ...workflowJson } = input;
@@ -1803,6 +1807,30 @@ var MediaResource = class {
1803
1807
  trimAudio(input) {
1804
1808
  return this.client.request("POST", "/v1/trim-audio", { body: input });
1805
1809
  }
1810
+ /**
1811
+ * Turn one still image + one audio track into an MP4
1812
+ * (`POST /v1/still-to-video`) — locally rendered (FFmpeg), no AI model,
1813
+ * zero credits. The output duration IS the audio's duration; there is no
1814
+ * duration field. Optional `motion` animates the still (zoom / pan /
1815
+ * ken-burns) at `intensity` 1–10. `fit: "contain"` letterboxes with
1816
+ * `padColor` instead of cropping. Poll `jobs.get(jobId)`.
1817
+ */
1818
+ stillToVideo(input) {
1819
+ return this.client.request("POST", "/v1/still-to-video", { body: input });
1820
+ }
1821
+ /**
1822
+ * Turn 2–100 images + one optional audio track into an MP4 slideshow
1823
+ * (`POST /v1/slideshow`) — locally rendered (FFmpeg), zero credits. With
1824
+ * audio, the output duration IS the audio's duration (equal split unless
1825
+ * `imageDurations` pins rows — null entries = auto; mismatched pinned sums
1826
+ * scale proportionally and the factor is disclosed in the job output).
1827
+ * Without audio: N × `perImageDuration`, silent output. Transitions
1828
+ * consume the outgoing slide, so totals stay exact. For a single image use
1829
+ * `stillToVideo`. Poll `jobs.get(jobId)`.
1830
+ */
1831
+ slideshow(input) {
1832
+ return this.client.request("POST", "/v1/slideshow", { body: input });
1833
+ }
1806
1834
  /**
1807
1835
  * Probe a social video's metadata (`POST /v1/video-metadata`) — duration,
1808
1836
  * dimensions, title, live status — WITHOUT downloading it. A direct read, not a
@@ -2114,6 +2142,22 @@ var RecastResource = class {
2114
2142
  get(recastId) {
2115
2143
  return this.client.request("GET", `/v1/recast/${encodeURIComponent(recastId)}`);
2116
2144
  }
2145
+ /** Quote a revisioned Music replacement and/or complete desired mix. Free. */
2146
+ estimateRescore(recastId, input) {
2147
+ return this.client.request(
2148
+ "POST",
2149
+ `/v1/recast/${encodeURIComponent(recastId)}/estimate-rescore`,
2150
+ { body: input }
2151
+ );
2152
+ }
2153
+ /** Apply a quoted audio operation. Reuse its request id only for a transport retry. */
2154
+ rescore(recastId, input) {
2155
+ return this.client.request(
2156
+ "POST",
2157
+ `/v1/recast/${encodeURIComponent(recastId)}/rescore`,
2158
+ { body: input }
2159
+ );
2160
+ }
2117
2161
  /** Start rendering a `planned` run. Idempotent server-side. */
2118
2162
  start(recastId, opts = {}) {
2119
2163
  return this.client.request("POST", `/v1/recast/${encodeURIComponent(recastId)}/start`, {
@@ -2280,11 +2324,204 @@ var TutorialsResource = class {
2280
2324
  }
2281
2325
  };
2282
2326
 
2283
- // src/client.ts
2284
- var SDK_VERSION = "1.17.0" ;
2327
+ // src/resources/organizations.ts
2328
+ var OrganizationsResource = class {
2329
+ constructor(client) {
2330
+ this.client = client;
2331
+ }
2332
+ client;
2333
+ /** The organizations this account belongs to. */
2334
+ list() {
2335
+ return this.client.request("GET", "/v1/orgs");
2336
+ }
2337
+ get(id) {
2338
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(id)}`);
2339
+ }
2340
+ /**
2341
+ * Create an organization. On instances that require it, `acceptTerms` must
2342
+ * be true or the server answers `terms_required` — the SDK does not decide
2343
+ * whether terms apply, because only the instance knows.
2344
+ *
2345
+ * A new organization may come back `pending`: some instances hold new
2346
+ * organizations for a platform admin to approve, and a pending one grants
2347
+ * nothing until it is active.
2348
+ */
2349
+ create(input) {
2350
+ return this.client.request("POST", "/v1/orgs", { body: input });
2351
+ }
2352
+ update(id, input) {
2353
+ return this.client.request("PATCH", `/v1/orgs/${encodeURIComponent(id)}`, { body: input });
2354
+ }
2355
+ /** Soft-delete. The organization stops granting context; nothing is destroyed. */
2356
+ delete(id) {
2357
+ return this.client.request("DELETE", `/v1/orgs/${encodeURIComponent(id)}`);
2358
+ }
2359
+ /** Hand the organization to another member. The caller becomes an admin. */
2360
+ transferOwnership(id, userId) {
2361
+ return this.client.request("POST", `/v1/orgs/${encodeURIComponent(id)}/transfer-ownership`, {
2362
+ body: { userId }
2363
+ });
2364
+ }
2365
+ /** Leave. An owner cannot — transfer ownership first (`owner_cannot_leave`). */
2366
+ leave(id) {
2367
+ return this.client.request("POST", `/v1/orgs/${encodeURIComponent(id)}/leave`);
2368
+ }
2369
+ // -- members --------------------------------------------------------------
2370
+ listMembers(orgId, opts = {}) {
2371
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/members`, { query: { ...opts } });
2372
+ }
2373
+ updateMember(orgId, userId, input) {
2374
+ return this.client.request(
2375
+ "PATCH",
2376
+ `/v1/orgs/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`,
2377
+ { body: input }
2378
+ );
2379
+ }
2380
+ removeMember(orgId, userId) {
2381
+ return this.client.request(
2382
+ "DELETE",
2383
+ `/v1/orgs/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`
2384
+ );
2385
+ }
2386
+ // -- invitations ----------------------------------------------------------
2387
+ /**
2388
+ * Invite by email. Returns ONE ROW PER ADDRESS, and a row whose `status` is
2389
+ * not `sent` carries a `link` instead.
2390
+ *
2391
+ * Surface that link. An install with no mail provider — every fresh
2392
+ * self-host — delivers nothing, and an integration that reports "invited"
2393
+ * without showing the link creates invitations nobody can ever reach.
2394
+ */
2395
+ invite(orgId, input) {
2396
+ return this.client.request("POST", `/v1/orgs/${encodeURIComponent(orgId)}/invitations`, { body: input });
2397
+ }
2398
+ listInvitations(orgId, opts = {}) {
2399
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/invitations`, {
2400
+ query: { ...opts }
2401
+ });
2402
+ }
2403
+ revokeInvitation(id) {
2404
+ return this.client.request("DELETE", `/v1/invitations/${encodeURIComponent(id)}`);
2405
+ }
2406
+ resendInvitation(id) {
2407
+ return this.client.request("POST", `/v1/invitations/${encodeURIComponent(id)}/resend`);
2408
+ }
2409
+ /**
2410
+ * What an invitee sees before signing in — the one organization read that
2411
+ * needs no token, so it works while the recipient is still signed out.
2412
+ */
2413
+ previewInvitation(token) {
2414
+ return this.client.request("GET", `/v1/invitations/by-token/${encodeURIComponent(token)}`);
2415
+ }
2416
+ /** Accept. Requires an authenticated caller whose email matches the invite. */
2417
+ acceptInvitation(token) {
2418
+ return this.client.request("POST", `/v1/invitations/${encodeURIComponent(token)}/accept`);
2419
+ }
2420
+ // -- audit ----------------------------------------------------------------
2421
+ /**
2422
+ * The organization's audit log, newest first. Owner and admins only, and
2423
+ * readable while the organization is suspended — the record of what
2424
+ * happened is exactly what someone needs when things have gone wrong.
2425
+ */
2426
+ audit(orgId, opts = {}) {
2427
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/audit`, { query: { ...opts } });
2428
+ }
2429
+ };
2430
+
2431
+ // src/resources/workspaces.ts
2432
+ var WorkspacesResource = class {
2433
+ constructor(client) {
2434
+ this.client = client;
2435
+ }
2436
+ client;
2437
+ /**
2438
+ * Every workspace this account belongs to, across all its organizations.
2439
+ *
2440
+ * An identity read: a stale workspace binding cannot lock a caller out of
2441
+ * it, which is what makes it safe to call when a selection has gone bad.
2442
+ *
2443
+ * Byte-for-byte the list `GET /v1/me` carries, so a client reconciles
2444
+ * against one truth rather than two. That is why these are SUMMARIES —
2445
+ * enough to render a switcher, not the full view; use {@link get} for that.
2446
+ */
2447
+ list() {
2448
+ return this.client.request("GET", "/v1/workspaces");
2449
+ }
2450
+ listForOrg(orgId, opts = {}) {
2451
+ return this.client.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/workspaces`, {
2452
+ query: { includeArchived: opts.includeArchived }
2453
+ });
2454
+ }
2455
+ get(id) {
2456
+ return this.client.request("GET", `/v1/workspaces/${encodeURIComponent(id)}`);
2457
+ }
2458
+ create(orgId, input) {
2459
+ return this.client.request("POST", `/v1/orgs/${encodeURIComponent(orgId)}/workspaces`, { body: input });
2460
+ }
2461
+ update(id, input) {
2462
+ return this.client.request("PATCH", `/v1/workspaces/${encodeURIComponent(id)}`, { body: input });
2463
+ }
2464
+ /**
2465
+ * Archive or restore. Archiving is REVERSIBLE and destroys nothing: the
2466
+ * workspace stops accepting new work and stays fully readable, which is
2467
+ * what a finished class term needs and a delete would not survive.
2468
+ */
2469
+ setArchived(id, archived) {
2470
+ return this.client.request(
2471
+ "POST",
2472
+ `/v1/workspaces/${encodeURIComponent(id)}/${archived ? "archive" : "unarchive"}`
2473
+ );
2474
+ }
2475
+ // -- members --------------------------------------------------------------
2476
+ listMembers(id, opts = {}) {
2477
+ return this.client.request("GET", `/v1/workspaces/${encodeURIComponent(id)}/members`, {
2478
+ query: { ...opts }
2479
+ });
2480
+ }
2481
+ /** Add someone who is ALREADY in the organization. To bring in a new person, invite them. */
2482
+ addMember(id, input) {
2483
+ return this.client.request("POST", `/v1/workspaces/${encodeURIComponent(id)}/members`, { body: input });
2484
+ }
2485
+ updateMember(id, userId, input) {
2486
+ return this.client.request(
2487
+ "PATCH",
2488
+ `/v1/workspaces/${encodeURIComponent(id)}/members/${encodeURIComponent(userId)}`,
2489
+ { body: input }
2490
+ );
2491
+ }
2492
+ removeMember(id, userId) {
2493
+ return this.client.request(
2494
+ "DELETE",
2495
+ `/v1/workspaces/${encodeURIComponent(id)}/members/${encodeURIComponent(userId)}`
2496
+ );
2497
+ }
2498
+ // -- join codes -----------------------------------------------------------
2499
+ /** The workspace's join code, or `null` if none has been created. Admins only. */
2500
+ getJoinCode(id) {
2501
+ return this.client.request("GET", `/v1/workspaces/${encodeURIComponent(id)}/join-code`);
2502
+ }
2503
+ /**
2504
+ * Rotate, enable or disable the code. Rotating invalidates the old one
2505
+ * immediately — that is the point of it, and anyone still holding a link
2506
+ * with the old code will be refused.
2507
+ */
2508
+ actOnJoinCode(id, action) {
2509
+ return this.client.request("POST", `/v1/workspaces/${encodeURIComponent(id)}/join-code`, {
2510
+ body: { action }
2511
+ });
2512
+ }
2513
+ /**
2514
+ * Join by code. Another way IN, so a stale workspace binding must not block
2515
+ * it — the server treats this as an identity route for that reason.
2516
+ */
2517
+ join(code) {
2518
+ return this.client.request("POST", "/v1/workspaces/join", { body: { code } });
2519
+ }
2520
+ };
2521
+ var SDK_VERSION = "1.19.0" ;
2285
2522
  var CLIENT_HEADER = "X-Nodaro-Client";
2286
2523
  var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
2287
- var NodaroClient = class {
2524
+ var NodaroClient = class _NodaroClient {
2288
2525
  baseUrl;
2289
2526
  auth;
2290
2527
  timeoutMs;
@@ -2332,12 +2569,17 @@ var NodaroClient = class {
2332
2569
  community;
2333
2570
  templates;
2334
2571
  tutorials;
2572
+ organizations;
2573
+ workspaces;
2574
+ /** The workspace this client acts in; undefined = the personal space. */
2575
+ workspaceId;
2335
2576
  constructor(opts) {
2336
2577
  this.baseUrl = opts.baseUrl.replace(/\/$/, "");
2337
2578
  this.auth = opts.auth;
2338
2579
  this.fetchOverride = opts.fetch;
2339
2580
  this.timeoutMs = opts.timeoutMs ?? 6e4;
2340
2581
  this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`;
2582
+ this.workspaceId = opts.workspaceId;
2341
2583
  this.sendClientHeader = opts.clientLabel !== void 0 || !isBrowser();
2342
2584
  this.workflows = new WorkflowsResource(this);
2343
2585
  this.projects = new ProjectsResource(this);
@@ -2369,6 +2611,29 @@ var NodaroClient = class {
2369
2611
  this.community = new CommunityResource(this);
2370
2612
  this.templates = new TemplatesResource(this);
2371
2613
  this.tutorials = new TutorialsResource(this);
2614
+ this.organizations = new OrganizationsResource(this);
2615
+ this.workspaces = new WorkspacesResource(this);
2616
+ }
2617
+ /**
2618
+ * A client that acts in `workspaceId`, sharing this one's auth and config.
2619
+ *
2620
+ * A NEW client rather than a setter, deliberately. A mutable selection is
2621
+ * the bug this whole axis exists to prevent: two concurrent operations
2622
+ * against one client would race over which workspace they were in, and the
2623
+ * loser would create work in the wrong place with nothing failing. A
2624
+ * per-workspace client cannot be raced.
2625
+ *
2626
+ * Pass `null` for the personal space.
2627
+ */
2628
+ withWorkspace(workspaceId) {
2629
+ return new _NodaroClient({
2630
+ baseUrl: this.baseUrl,
2631
+ auth: this.auth,
2632
+ timeoutMs: this.timeoutMs,
2633
+ ...this.fetchOverride ? { fetch: this.fetchOverride } : {},
2634
+ ...this.sendClientHeader ? { clientLabel: this.clientLabel } : {},
2635
+ ...workspaceId ? { workspaceId } : {}
2636
+ });
2372
2637
  }
2373
2638
  async request(method, path, options = {}) {
2374
2639
  const url = this.buildUrl(path, options.query);
@@ -2377,6 +2642,9 @@ var NodaroClient = class {
2377
2642
  const headers = {
2378
2643
  ...isFormData ? {} : { "Content-Type": "application/json" },
2379
2644
  ...this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {},
2645
+ // Before per-request headers: a resource that needs to reach outside
2646
+ // this client's workspace says so explicitly and wins.
2647
+ ...this.workspaceId ? { [WORKSPACE_HEADER]: this.workspaceId } : {},
2380
2648
  ...options.headers ?? {}
2381
2649
  };
2382
2650
  if (token) headers["Authorization"] = `Bearer ${token}`;
@@ -2410,6 +2678,14 @@ var NodaroClient = class {
2410
2678
  * `GET /v1/me` → the authenticated user's identity (see {@link UserIdentity}).
2411
2679
  * Unwraps the `{ data }` envelope. Throws `UnauthorizedError` (401) when the
2412
2680
  * token is missing/invalid, and the SDK's other typed errors as usual.
2681
+ *
2682
+ * On an instance with organizations it also carries what the caller belongs
2683
+ * to. THREE states, and collapsing them is wrong in a way users feel: the
2684
+ * organization fields ABSENT means this instance has no organizations at
2685
+ * all; present and empty means the account belongs to none; and
2686
+ * `organizationsUnavailable` means the lookup failed — keep whatever
2687
+ * selection you already had rather than concluding the person was removed
2688
+ * from everything.
2413
2689
  */
2414
2690
  async me() {
2415
2691
  const res = await this.request("GET", "/v1/me");
@@ -2461,6 +2737,6 @@ function supabaseAuth(supabase) {
2461
2737
  };
2462
2738
  }
2463
2739
 
2464
- export { AppsResource, AudioResource, CREATURE_ASSET_TYPES, CallbackAuth, CharactersResource, CommunityResource, CreaturesResource, CreditsResource, DeveloperAppsResource, ExecutionsResource, ForbiddenError, InsufficientCreditsError, JobAbortedError, JobFailedError, JobTimeoutError, JobsResource, LibraryResource, LocationsResource, MediaResource, ModelsResource, NodaroClient, NodaroError, NodesResource, NotFoundError, OAuthResource, ObjectsResource, PickerCatalogsResource, PipelinesResource, PresetsResource, ProjectsResource, PromptHelperResource, RateLimitedError, RecastResource, ReduceResource, ShotsResource, StaticTokenAuth, StorageExceededError, TemplatesResource, TutorialsResource, UnauthorizedError, UploadsResource, VideoProResource, VoicesResource, WorkflowConflictError, WorkflowsResource, buildPersonSeedPrompt, createClient, supabaseAuth, throwFromResponse };
2740
+ export { AppsResource, AudioResource, CREATURE_ASSET_TYPES, CallbackAuth, CharactersResource, CommunityResource, CreaturesResource, CreditsResource, DeveloperAppsResource, ExecutionsResource, ForbiddenError, InsufficientCreditsError, JobAbortedError, JobFailedError, JobTimeoutError, JobsResource, LibraryResource, LocationsResource, MediaResource, ModelsResource, NodaroClient, NodaroError, NodesResource, NotFoundError, OAuthResource, ObjectsResource, OrganizationsResource, PickerCatalogsResource, PipelinesResource, PresetsResource, ProjectsResource, PromptHelperResource, RateLimitedError, RecastResource, ReduceResource, ShotsResource, StaticTokenAuth, StorageExceededError, TemplatesResource, TutorialsResource, UnauthorizedError, UploadsResource, VideoProResource, VoicesResource, WorkflowConflictError, WorkflowsResource, WorkspacesResource, buildPersonSeedPrompt, createClient, supabaseAuth, throwFromResponse };
2465
2741
  //# sourceMappingURL=index.js.map
2466
2742
  //# sourceMappingURL=index.js.map