@nodaro/sdk 2.45.1 → 2.46.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.
Files changed (95) hide show
  1. package/dist/{chunk-3Y5TV37H.js → chunk-5Q4SUZPL.js} +3 -3
  2. package/dist/{chunk-3Y5TV37H.js.map → chunk-5Q4SUZPL.js.map} +1 -1
  3. package/dist/{chunk-55ZX6TE3.cjs → chunk-66M54BUO.cjs} +6 -6
  4. package/dist/chunk-66M54BUO.cjs.map +1 -0
  5. package/dist/chunk-6NTKEXT5.js +3 -0
  6. package/dist/chunk-6NTKEXT5.js.map +1 -0
  7. package/dist/{chunk-34JMD6ZO.cjs → chunk-7LTVS75S.cjs} +36 -12
  8. package/dist/chunk-7LTVS75S.cjs.map +1 -0
  9. package/dist/{chunk-HKDIIFG2.js → chunk-C3C7IL25.js} +6 -6
  10. package/dist/chunk-C3C7IL25.js.map +1 -0
  11. package/dist/{chunk-J6FHBQ4Z.cjs → chunk-DIF7A5OH.cjs} +2 -2
  12. package/dist/chunk-DIF7A5OH.cjs.map +1 -0
  13. package/dist/{chunk-JB4GVP4Q.js → chunk-GW76IRQD.js} +2 -2
  14. package/dist/{chunk-JB4GVP4Q.js.map → chunk-GW76IRQD.js.map} +1 -1
  15. package/dist/chunk-KBHDUHKM.js +21 -0
  16. package/dist/chunk-KBHDUHKM.js.map +1 -0
  17. package/dist/{chunk-A7HOOWKS.cjs → chunk-POKNFGGD.cjs} +19 -15
  18. package/dist/chunk-POKNFGGD.cjs.map +1 -0
  19. package/dist/{chunk-6MQ2LTJZ.js → chunk-PQHZUWSL.js} +36 -12
  20. package/dist/chunk-PQHZUWSL.js.map +1 -0
  21. package/dist/{chunk-5IXZLQNT.cjs → chunk-TK2CEVSK.cjs} +2 -2
  22. package/dist/{chunk-5IXZLQNT.cjs.map → chunk-TK2CEVSK.cjs.map} +1 -1
  23. package/dist/chunk-UANHMQ3A.cjs +4 -0
  24. package/dist/chunk-UANHMQ3A.cjs.map +1 -0
  25. package/dist/{chunk-RQY2WJD3.js → chunk-WFAFFAGV.js} +13 -9
  26. package/dist/chunk-WFAFFAGV.js.map +1 -0
  27. package/dist/{chunk-PEMLIAPZ.cjs → chunk-WMT7HEBZ.cjs} +40 -7
  28. package/dist/chunk-WMT7HEBZ.cjs.map +1 -0
  29. package/dist/{chunk-Y6VDCZPB.js → chunk-WS4ZQ4AA.js} +40 -7
  30. package/dist/chunk-WS4ZQ4AA.js.map +1 -0
  31. package/dist/{chunk-CKHCSZCV.js → chunk-XILR6TFO.js} +2 -2
  32. package/dist/chunk-XILR6TFO.js.map +1 -0
  33. package/dist/chunk-XKDVEQVD.cjs +23 -0
  34. package/dist/chunk-XKDVEQVD.cjs.map +1 -0
  35. package/dist/{chunk-WFWZBYBS.cjs → chunk-ZJCHIJND.cjs} +3 -3
  36. package/dist/{chunk-WFWZBYBS.cjs.map → chunk-ZJCHIJND.cjs.map} +1 -1
  37. package/dist/entries/cast-swap.cjs +2 -2
  38. package/dist/entries/cast-swap.d.cts +117 -143
  39. package/dist/entries/cast-swap.d.ts +117 -143
  40. package/dist/entries/cast-swap.js +1 -1
  41. package/dist/entries/characters.d.cts +1 -1
  42. package/dist/entries/characters.d.ts +1 -1
  43. package/dist/entries/client.cjs +14 -13
  44. package/dist/entries/client.d.cts +4 -1
  45. package/dist/entries/client.d.ts +4 -1
  46. package/dist/entries/client.js +9 -8
  47. package/dist/entries/core.cjs +5 -5
  48. package/dist/entries/core.js +1 -1
  49. package/dist/entries/creatures.d.cts +1 -1
  50. package/dist/entries/creatures.d.ts +1 -1
  51. package/dist/entries/jobs.cjs +2 -2
  52. package/dist/entries/jobs.d.cts +57 -8
  53. package/dist/entries/jobs.d.ts +57 -8
  54. package/dist/entries/jobs.js +1 -1
  55. package/dist/entries/locations.d.cts +1 -1
  56. package/dist/entries/locations.d.ts +1 -1
  57. package/dist/entries/nodes.cjs +2 -2
  58. package/dist/entries/nodes.d.cts +1 -1
  59. package/dist/entries/nodes.d.ts +1 -1
  60. package/dist/entries/nodes.js +1 -1
  61. package/dist/entries/objects.d.cts +1 -1
  62. package/dist/entries/objects.d.ts +1 -1
  63. package/dist/entries/scene3d.d.cts +2 -2
  64. package/dist/entries/scene3d.d.ts +2 -2
  65. package/dist/entries/sessions.cjs +2 -2
  66. package/dist/entries/sessions.d.cts +58 -8
  67. package/dist/entries/sessions.d.ts +58 -8
  68. package/dist/entries/sessions.js +1 -1
  69. package/dist/entries/trash.cjs +13 -0
  70. package/dist/entries/trash.cjs.map +1 -0
  71. package/dist/entries/trash.d.cts +71 -0
  72. package/dist/entries/trash.d.ts +71 -0
  73. package/dist/entries/trash.js +4 -0
  74. package/dist/entries/trash.js.map +1 -0
  75. package/dist/entries/trends.cjs +2 -2
  76. package/dist/entries/trends.d.cts +30 -21
  77. package/dist/entries/trends.d.ts +30 -21
  78. package/dist/entries/trends.js +1 -1
  79. package/dist/index.cjs +30 -24
  80. package/dist/index.d.cts +5 -4
  81. package/dist/index.d.ts +5 -4
  82. package/dist/index.js +11 -9
  83. package/dist/{nodes-MThDit8l.d.ts → nodes-C9j0PFto.d.ts} +11 -1
  84. package/dist/{nodes-Szl6HrZ_.d.cts → nodes-DGIefTze.d.cts} +11 -1
  85. package/package.json +7 -2
  86. package/dist/chunk-34JMD6ZO.cjs.map +0 -1
  87. package/dist/chunk-55ZX6TE3.cjs.map +0 -1
  88. package/dist/chunk-6MQ2LTJZ.js.map +0 -1
  89. package/dist/chunk-A7HOOWKS.cjs.map +0 -1
  90. package/dist/chunk-CKHCSZCV.js.map +0 -1
  91. package/dist/chunk-HKDIIFG2.js.map +0 -1
  92. package/dist/chunk-J6FHBQ4Z.cjs.map +0 -1
  93. package/dist/chunk-PEMLIAPZ.cjs.map +0 -1
  94. package/dist/chunk-RQY2WJD3.js.map +0 -1
  95. package/dist/chunk-Y6VDCZPB.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/sessions.ts"],"names":[],"m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O,OAAA;AAAA,MACjB,QAAA;AAAA,MACA,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,EAAU,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAAA,MACzE,OAAA,CAAQ,UAAU,EAAE,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAO,EAAE,GAAI;AAAC,KACtD;AAAA,EACF;AAAA;AAAA,EAGA,WAAA,CAAY,IAAY,KAAA,EAA2C;AACjE,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA;AAAA,MACjB,MAAA;AAAA,MACA,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,EAAU,kBAAA,CAAmB,KAAK,CAAC,CAAA,QAAA;AAAA,KAC3E;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,SAAA,CAAU,UAAkB,KAAA,EAAoE;AAC9F,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,MAAA,EAAQ,CAAA,aAAA,EAAgB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,WAAA,CAAA,EAAe,EAAE,IAAA,EAAM,KAAA,EAAO,CAAA;AAAA,EAC/G;AACF","file":"chunk-WMT7HEBZ.cjs","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\nimport type { Job } from \"./jobs.js\"\n\n/**\n * A generation session: one run of work in a creation tool (Create Image,\n * Video, Music), optionally inside a project. Its project is fixed at\n * creation — to get an item into another project, move it into a session\n * there ({@link SessionsResource.moveItems}) or import a copy of the link.\n */\nexport interface GenerationSession {\n id: string\n /** Null when the session has no project, or its project was deleted. */\n projectId: string | null\n /** Null = untitled; a UI may fall back to the first prompt. */\n title: string | null\n /** The creation tool that owns the session, e.g. `\"create-image\"`. */\n tool: string\n createdAt: string\n /** The latest activity: an item added, or an edit. */\n updatedAt: string\n archivedAt: string | null\n /** The item picked as the session's cover (`update(id, { coverJobId })`); `null` = automatic. */\n coverJobId: string | null\n /** Live items: not removed, and their job not deleted. */\n itemCount: number\n /** Items removed from the session — its part of the Trash\n * (`items(id, { removed: true })`, `client.trash.list()`). Absent from an\n * older server. */\n removedCount?: number\n /** Up to four image links: the cover's image first when one is set, then the\n * newest completed items. */\n previewUrls: string[]\n}\n\nexport interface CreateSessionInput {\n /** One of your projects (on the side of the workspace line you are on). */\n projectId?: string\n title?: string\n /** Lowercase letters, digits and dashes, at most 40 — e.g. `\"create-image\"`. */\n tool: string\n}\n\nexport interface UpdateSessionInput {\n /** `null` makes the session untitled again. */\n title?: string | null\n archived?: boolean\n /** One of the session's items to lead its previews (404 if it is not an\n * item of this session); `null` goes back to automatic. */\n coverJobId?: string | null\n}\n\nexport interface ListSessionsParams {\n /** A project's id, or `\"none\"` for the sessions with no project. */\n projectId?: string | \"none\"\n tool?: string\n /** Archived sessions are left out unless this is true. */\n includeArchived?: boolean\n /** Page size, 1–100 (server default 50). */\n limit?: number\n /** The previous page's `next`. */\n cursor?: string\n}\n\n/** One item of a session's feed: a link to one of your jobs. */\nexport interface SessionItem {\n jobId: string\n addedAt: string\n /** When the item was removed from the session (it is in the Trash); `null`\n * for a live item. Absent from an older server. */\n removedAt?: string | null\n /** True when imported from elsewhere rather than born in this session. */\n imported: boolean\n importedFrom: { sessionId: string; title: string | null } | null\n job: Job\n}\n\nexport interface ListSessionItemsParams {\n /** `true`: the items removed from the session (its Trash), newest removal first. */\n removed?: boolean\n limit?: number\n cursor?: string\n}\n\n/** {@link SessionsResource.moveItems}' body. */\nexport interface MoveSessionItemsInput {\n /** Items of `fromSessionId` to move, up to 100. */\n jobIds: string[]\n /** The session they are in now. It keeps them as removed items, so the move can be undone from its Trash. */\n fromSessionId: string\n}\n\nexport interface SessionPage<T> {\n data: T[]\n /** Pass back as `cursor` for the next page; `null` on the last one. */\n next: string | null\n}\n\nexport class SessionsResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * Create a session. Send its `id` as `sessionId` on a generation request\n * (`nodes.run(\"generate-image\", { sessionId, … })`, video, speech, music) and\n * the job is born in it.\n */\n create(input: CreateSessionInput): Promise<{ data: GenerationSession }> {\n return this.client.request(\"POST\", \"/v1/sessions\", { body: input })\n }\n\n /** Your sessions, newest first. */\n list(params: ListSessionsParams = {}): Promise<SessionPage<GenerationSession>> {\n const query: Record<string, string> = {}\n if (params.projectId) query.projectId = params.projectId\n if (params.tool) query.tool = params.tool\n if (params.includeArchived) query.includeArchived = \"true\"\n if (params.limit !== undefined) query.limit = String(params.limit)\n if (params.cursor) query.cursor = params.cursor\n return this.client.request(\"GET\", \"/v1/sessions\", { query })\n }\n\n get(id: string): Promise<{ data: GenerationSession }> {\n return this.client.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}`)\n }\n\n /** Rename or archive a session, or pick its cover. Its project cannot change. */\n update(id: string, input: UpdateSessionInput): Promise<{ data: GenerationSession }> {\n return this.client.request(\"PATCH\", `/v1/sessions/${encodeURIComponent(id)}`, { body: input })\n }\n\n /** Delete a session and its links. Its jobs are kept, and stay in every other session holding them. */\n delete(id: string): Promise<{ success: true }> {\n return this.client.request(\"DELETE\", `/v1/sessions/${encodeURIComponent(id)}`)\n }\n\n /**\n * The session's live items, born-in and imported, newest first — or, with\n * `{ removed: true }`, the items removed from it (its part of the Trash),\n * newest removal first. An item whose job was deleted is in neither: it is in\n * `client.trash.list()` as the deleted job.\n */\n items(id: string, params: ListSessionItemsParams = {}): Promise<SessionPage<SessionItem>> {\n const query: Record<string, string> = {}\n if (params.removed) query.removed = \"true\"\n if (params.limit !== undefined) query.limit = String(params.limit)\n if (params.cursor) query.cursor = params.cursor\n return this.client.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}/items`, { query })\n }\n\n /**\n * Import some of your own jobs into a session — a link, not a copy (up to 100\n * a call). All-or-nothing: if any id is not one of your jobs, nothing is\n * imported and the call fails with 404. Items already there are left as they\n * are; an item removed from the session comes back where it was.\n */\n importItems(id: string, input: { jobIds: string[] }): Promise<{ data: { imported: number; requested: number } }> {\n return this.client.request(\"POST\", `/v1/sessions/${encodeURIComponent(id)}/items`, { body: input })\n }\n\n /**\n * Remove one item from a session: it goes to the session's Trash until\n * {@link restoreItem} brings it back or `{ forever: true }` deletes it for good\n * — no automatic cleanup. Only the link moves: the job, and every other\n * session holding it, stay; an item in no session shows in General\n * (`client.jobs.list({ inSession: false })`). `forever` on an item that is\n * not removed fails with a 409 `NodaroError` whose `code` is `\"not_in_trash\"`.\n */\n removeItem(id: string, jobId: string, options: { forever?: boolean } = {}): Promise<{ success: true }> {\n return this.client.request(\n \"DELETE\",\n `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}`,\n options.forever ? { query: { forever: \"true\" } } : {},\n )\n }\n\n /** Bring a removed item back into the session, where it was. An item that is not removed succeeds too. */\n restoreItem(id: string, jobId: string): Promise<{ success: true }> {\n return this.client.request(\n \"POST\",\n `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}/restore`,\n )\n }\n\n /**\n * Move items of another of your sessions into `targetId`, in one\n * transaction: the target gets them (born-in stays born-in, else imported\n * from the source), the source keeps them as removed items — so the move is\n * undone with `restoreItem(fromSessionId, jobId)`. A session in another\n * project is how an item moves to another project. All-or-nothing: if any id\n * is not a live item of `fromSessionId`, nothing moves (404).\n */\n moveItems(targetId: string, input: MoveSessionItemsInput): Promise<{ data: { moved: number } }> {\n return this.client.request(\"POST\", `/v1/sessions/${encodeURIComponent(targetId)}/items/move`, { body: input })\n }\n}\n"]}
@@ -33,9 +33,15 @@ var SessionsResource = class {
33
33
  delete(id) {
34
34
  return this.client.request("DELETE", `/v1/sessions/${encodeURIComponent(id)}`);
35
35
  }
36
- /** The session's items, born-in and imported, newest first. */
36
+ /**
37
+ * The session's live items, born-in and imported, newest first — or, with
38
+ * `{ removed: true }`, the items removed from it (its part of the Trash),
39
+ * newest removal first. An item whose job was deleted is in neither: it is in
40
+ * `client.trash.list()` as the deleted job.
41
+ */
37
42
  items(id, params = {}) {
38
43
  const query = {};
44
+ if (params.removed) query.removed = "true";
39
45
  if (params.limit !== void 0) query.limit = String(params.limit);
40
46
  if (params.cursor) query.cursor = params.cursor;
41
47
  return this.client.request("GET", `/v1/sessions/${encodeURIComponent(id)}/items`, { query });
@@ -43,20 +49,47 @@ var SessionsResource = class {
43
49
  /**
44
50
  * Import some of your own jobs into a session — a link, not a copy (up to 100
45
51
  * a call). All-or-nothing: if any id is not one of your jobs, nothing is
46
- * imported and the call fails with 404. Items already there are left as they are.
52
+ * imported and the call fails with 404. Items already there are left as they
53
+ * are; an item removed from the session comes back where it was.
47
54
  */
48
55
  importItems(id, input) {
49
56
  return this.client.request("POST", `/v1/sessions/${encodeURIComponent(id)}/items`, { body: input });
50
57
  }
51
- /** Remove one item from a session. Only the link goes: the job, and every other session holding it, stay. */
52
- removeItem(id, jobId) {
58
+ /**
59
+ * Remove one item from a session: it goes to the session's Trash until
60
+ * {@link restoreItem} brings it back or `{ forever: true }` deletes it for good
61
+ * — no automatic cleanup. Only the link moves: the job, and every other
62
+ * session holding it, stay; an item in no session shows in General
63
+ * (`client.jobs.list({ inSession: false })`). `forever` on an item that is
64
+ * not removed fails with a 409 `NodaroError` whose `code` is `"not_in_trash"`.
65
+ */
66
+ removeItem(id, jobId, options = {}) {
53
67
  return this.client.request(
54
68
  "DELETE",
55
- `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}`
69
+ `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}`,
70
+ options.forever ? { query: { forever: "true" } } : {}
71
+ );
72
+ }
73
+ /** Bring a removed item back into the session, where it was. An item that is not removed succeeds too. */
74
+ restoreItem(id, jobId) {
75
+ return this.client.request(
76
+ "POST",
77
+ `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}/restore`
56
78
  );
57
79
  }
80
+ /**
81
+ * Move items of another of your sessions into `targetId`, in one
82
+ * transaction: the target gets them (born-in stays born-in, else imported
83
+ * from the source), the source keeps them as removed items — so the move is
84
+ * undone with `restoreItem(fromSessionId, jobId)`. A session in another
85
+ * project is how an item moves to another project. All-or-nothing: if any id
86
+ * is not a live item of `fromSessionId`, nothing moves (404).
87
+ */
88
+ moveItems(targetId, input) {
89
+ return this.client.request("POST", `/v1/sessions/${encodeURIComponent(targetId)}/items/move`, { body: input });
90
+ }
58
91
  };
59
92
 
60
93
  export { SessionsResource };
61
- //# sourceMappingURL=chunk-Y6VDCZPB.js.map
62
- //# sourceMappingURL=chunk-Y6VDCZPB.js.map
94
+ //# sourceMappingURL=chunk-WS4ZQ4AA.js.map
95
+ //# sourceMappingURL=chunk-WS4ZQ4AA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/sessions.ts"],"names":[],"mappings":";AAiGO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB,OAAO,KAAA,EAAiE;AACtE,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAQ,MAAA,EAAQ,gBAAgB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EACpE;AAAA;AAAA,EAGA,IAAA,CAAK,MAAA,GAA6B,EAAC,EAA4C;AAC7E,IAAA,MAAM,QAAgC,EAAC;AACvC,IAAA,IAAI,MAAA,CAAO,SAAA,EAAW,KAAA,CAAM,SAAA,GAAY,MAAA,CAAO,SAAA;AAC/C,IAAA,IAAI,MAAA,CAAO,IAAA,EAAM,KAAA,CAAM,IAAA,GAAO,MAAA,CAAO,IAAA;AACrC,IAAA,IAAI,MAAA,CAAO,eAAA,EAAiB,KAAA,CAAM,eAAA,GAAkB,MAAA;AACpD,IAAA,IAAI,OAAO,KAAA,KAAU,MAAA,QAAiB,KAAA,GAAQ,MAAA,CAAO,OAAO,KAAK,CAAA;AACjE,IAAA,IAAI,MAA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":"chunk-WS4ZQ4AA.js","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\nimport type { Job } from \"./jobs.js\"\n\n/**\n * A generation session: one run of work in a creation tool (Create Image,\n * Video, Music), optionally inside a project. Its project is fixed at\n * creation — to get an item into another project, move it into a session\n * there ({@link SessionsResource.moveItems}) or import a copy of the link.\n */\nexport interface GenerationSession {\n id: string\n /** Null when the session has no project, or its project was deleted. */\n projectId: string | null\n /** Null = untitled; a UI may fall back to the first prompt. */\n title: string | null\n /** The creation tool that owns the session, e.g. `\"create-image\"`. */\n tool: string\n createdAt: string\n /** The latest activity: an item added, or an edit. */\n updatedAt: string\n archivedAt: string | null\n /** The item picked as the session's cover (`update(id, { coverJobId })`); `null` = automatic. */\n coverJobId: string | null\n /** Live items: not removed, and their job not deleted. */\n itemCount: number\n /** Items removed from the session — its part of the Trash\n * (`items(id, { removed: true })`, `client.trash.list()`). Absent from an\n * older server. */\n removedCount?: number\n /** Up to four image links: the cover's image first when one is set, then the\n * newest completed items. */\n previewUrls: string[]\n}\n\nexport interface CreateSessionInput {\n /** One of your projects (on the side of the workspace line you are on). */\n projectId?: string\n title?: string\n /** Lowercase letters, digits and dashes, at most 40 — e.g. `\"create-image\"`. */\n tool: string\n}\n\nexport interface UpdateSessionInput {\n /** `null` makes the session untitled again. */\n title?: string | null\n archived?: boolean\n /** One of the session's items to lead its previews (404 if it is not an\n * item of this session); `null` goes back to automatic. */\n coverJobId?: string | null\n}\n\nexport interface ListSessionsParams {\n /** A project's id, or `\"none\"` for the sessions with no project. */\n projectId?: string | \"none\"\n tool?: string\n /** Archived sessions are left out unless this is true. */\n includeArchived?: boolean\n /** Page size, 1–100 (server default 50). */\n limit?: number\n /** The previous page's `next`. */\n cursor?: string\n}\n\n/** One item of a session's feed: a link to one of your jobs. */\nexport interface SessionItem {\n jobId: string\n addedAt: string\n /** When the item was removed from the session (it is in the Trash); `null`\n * for a live item. Absent from an older server. */\n removedAt?: string | null\n /** True when imported from elsewhere rather than born in this session. */\n imported: boolean\n importedFrom: { sessionId: string; title: string | null } | null\n job: Job\n}\n\nexport interface ListSessionItemsParams {\n /** `true`: the items removed from the session (its Trash), newest removal first. */\n removed?: boolean\n limit?: number\n cursor?: string\n}\n\n/** {@link SessionsResource.moveItems}' body. */\nexport interface MoveSessionItemsInput {\n /** Items of `fromSessionId` to move, up to 100. */\n jobIds: string[]\n /** The session they are in now. It keeps them as removed items, so the move can be undone from its Trash. */\n fromSessionId: string\n}\n\nexport interface SessionPage<T> {\n data: T[]\n /** Pass back as `cursor` for the next page; `null` on the last one. */\n next: string | null\n}\n\nexport class SessionsResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * Create a session. Send its `id` as `sessionId` on a generation request\n * (`nodes.run(\"generate-image\", { sessionId, … })`, video, speech, music) and\n * the job is born in it.\n */\n create(input: CreateSessionInput): Promise<{ data: GenerationSession }> {\n return this.client.request(\"POST\", \"/v1/sessions\", { body: input })\n }\n\n /** Your sessions, newest first. */\n list(params: ListSessionsParams = {}): Promise<SessionPage<GenerationSession>> {\n const query: Record<string, string> = {}\n if (params.projectId) query.projectId = params.projectId\n if (params.tool) query.tool = params.tool\n if (params.includeArchived) query.includeArchived = \"true\"\n if (params.limit !== undefined) query.limit = String(params.limit)\n if (params.cursor) query.cursor = params.cursor\n return this.client.request(\"GET\", \"/v1/sessions\", { query })\n }\n\n get(id: string): Promise<{ data: GenerationSession }> {\n return this.client.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}`)\n }\n\n /** Rename or archive a session, or pick its cover. Its project cannot change. */\n update(id: string, input: UpdateSessionInput): Promise<{ data: GenerationSession }> {\n return this.client.request(\"PATCH\", `/v1/sessions/${encodeURIComponent(id)}`, { body: input })\n }\n\n /** Delete a session and its links. Its jobs are kept, and stay in every other session holding them. */\n delete(id: string): Promise<{ success: true }> {\n return this.client.request(\"DELETE\", `/v1/sessions/${encodeURIComponent(id)}`)\n }\n\n /**\n * The session's live items, born-in and imported, newest first — or, with\n * `{ removed: true }`, the items removed from it (its part of the Trash),\n * newest removal first. An item whose job was deleted is in neither: it is in\n * `client.trash.list()` as the deleted job.\n */\n items(id: string, params: ListSessionItemsParams = {}): Promise<SessionPage<SessionItem>> {\n const query: Record<string, string> = {}\n if (params.removed) query.removed = \"true\"\n if (params.limit !== undefined) query.limit = String(params.limit)\n if (params.cursor) query.cursor = params.cursor\n return this.client.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}/items`, { query })\n }\n\n /**\n * Import some of your own jobs into a session — a link, not a copy (up to 100\n * a call). All-or-nothing: if any id is not one of your jobs, nothing is\n * imported and the call fails with 404. Items already there are left as they\n * are; an item removed from the session comes back where it was.\n */\n importItems(id: string, input: { jobIds: string[] }): Promise<{ data: { imported: number; requested: number } }> {\n return this.client.request(\"POST\", `/v1/sessions/${encodeURIComponent(id)}/items`, { body: input })\n }\n\n /**\n * Remove one item from a session: it goes to the session's Trash until\n * {@link restoreItem} brings it back or `{ forever: true }` deletes it for good\n * — no automatic cleanup. Only the link moves: the job, and every other\n * session holding it, stay; an item in no session shows in General\n * (`client.jobs.list({ inSession: false })`). `forever` on an item that is\n * not removed fails with a 409 `NodaroError` whose `code` is `\"not_in_trash\"`.\n */\n removeItem(id: string, jobId: string, options: { forever?: boolean } = {}): Promise<{ success: true }> {\n return this.client.request(\n \"DELETE\",\n `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}`,\n options.forever ? { query: { forever: \"true\" } } : {},\n )\n }\n\n /** Bring a removed item back into the session, where it was. An item that is not removed succeeds too. */\n restoreItem(id: string, jobId: string): Promise<{ success: true }> {\n return this.client.request(\n \"POST\",\n `/v1/sessions/${encodeURIComponent(id)}/items/${encodeURIComponent(jobId)}/restore`,\n )\n }\n\n /**\n * Move items of another of your sessions into `targetId`, in one\n * transaction: the target gets them (born-in stays born-in, else imported\n * from the source), the source keeps them as removed items — so the move is\n * undone with `restoreItem(fromSessionId, jobId)`. A session in another\n * project is how an item moves to another project. All-or-nothing: if any id\n * is not a live item of `fromSessionId`, nothing moves (404).\n */\n moveItems(targetId: string, input: MoveSessionItemsInput): Promise<{ data: { moved: number } }> {\n return this.client.request(\"POST\", `/v1/sessions/${encodeURIComponent(targetId)}/items/move`, { body: input })\n }\n}\n"]}
@@ -98,5 +98,5 @@ var TrendsResource = class {
98
98
  };
99
99
 
100
100
  export { TrendsResource };
101
- //# sourceMappingURL=chunk-CKHCSZCV.js.map
102
- //# sourceMappingURL=chunk-CKHCSZCV.js.map
101
+ //# sourceMappingURL=chunk-XILR6TFO.js.map
102
+ //# sourceMappingURL=chunk-XILR6TFO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/trends.ts"],"names":[],"mappings":";AA4DA,IAAM,cAAA,GAAmD;AAAA,EACvD,IAAA,EAAM,0BAAA;AAAA,EACN,IAAA,EAAM;AACR,CAAA;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,GAAO,EAAA,EAAY;AAClD,EAAA,IAAI,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB,IAAI,CAAA,EAAG;AACvC,IAAA,MAAM,IAAI,UAAU,CAAA,CAAA,EAAI,IAAI,6CAA6C,cAAA,CAAe,IAAI,CAAC,CAAA,CAAA,CAAG,CAAA;AAAA,EAClG;AACA,EAAA,OAAO,CAAA,WAAA,EAAc,kBAAA,CAAmB,IAAI,CAAC,GAAG,IAAI,CAAA,CAAA;AACtD;AAyVO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA,EAGpB,IAAA,CAAK,MAAA,GAA2B,EAAC,EAAkC;AACjE,IAAA,MAAM,QAAgC,EAAC;AACvC,IAAA,IAAI,MAAA,CAAO,CAAA,EAAG,KAAA,CAAM,CAAA,GAAI,MAAA,CAAO,CAAA;AAC/B,IAAA,IAAI,MAAA,CAAO,GAAA,EAAK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AAQ,KAAA,CAAM,MAAA,GAAS,MAAA,CAAO,MAAA;AACzC,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,CAAO,QAA8B,KAAA,EAAO,iBAAA,EAAmB,EAAE,KAAA,EAAO,CAAA;AAC/F,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA;AAAA,EAGA,MAAM,SAAS,IAAA,EAA6B;AAC1C,IAAA,MAAM,KAAK,MAAA,CAAO,OAAA,CAAc,OAAO,SAAA,CAAU,IAAA,EAAM,WAAW,CAAC,CAAA;AAAA,EACrE;AAAA;AAAA,EAGA,MAAM,WAAW,IAAA,EAA6B;AAC5C,IAAA,MAAM,KAAK,MAAA,CAAO,OAAA,CAAc,UAAU,SAAA,CAAU,IAAA,EAAM,WAAW,CAAC,CAAA;AAAA,EACxE;AACF","file":"chunk-XILR6TFO.js","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\nimport type { CastSwapEngine } from \"./cast-swap.js\"\n\n/**\n * Trends — ready-made Nodaro Motion recipes. A trend is a short clip with slots\n * (the people, pets, products and place you can replace); fill its slots with\n * your own pictures and run it to get the clip back with them in it.\n *\n * Cloud edition only: `/v1/trends` 404s on self-hosted installs. Only\n * published trends exist here: a draft, unpublished or unknown slug is a 404\n * on every route. `\"runs\"` and `\"tags\"` are never slugs (`/v1/trends/runs` is\n * the run list, `/v1/trends/tags` the tag list): the slug methods throw a\n * `TypeError` for them before any request. `run()` answers 202 with a job id; follow it with\n * `client.jobs.get(jobId)` / `client.jobs.getStatus(jobId)` like any other\n * job, or read it back as a trend run with `getRun(jobId)` / `runs()`.\n *\n * Repeats: pass `{ idempotencyKey }` to `run()` and it is sent as the\n * `Idempotency-Key` header. A repeat with the same key answers with the first\n * run's `jobId`; nothing new is started or charged.\n *\n * Refusals (thrown as a `NodaroError` subclass; body `{ error: { code, message } }`):\n * - 400 `validation_error` (the body, a query, or a bad `cursor`);\n * `estimate()` / `run()` only, before anything is charged:\n * `missing_slot` (a required slot without pictures, or an optional one\n * left empty that the chosen example has no pictures for), `unknown_slot`,\n * `invalid_choice` (a chip the slot's kind does not take),\n * `chip_not_offered` (a chip of the kind that the slot's\n * {@link TrendDetailSlot.chips} does not list: the trend fixes it),\n * `example_out_of_range` (`example` names no example of the trend, or is\n * sent at all on a trend with none), `preview_unavailable` (the trend offers no\n * preview), `invalid_slot_mention` (a `{slot:<key>}` in `details` naming no\n * slot), `prompt_too_long` (shorten `details`), `draft_unsupported`\n * (`draft: true` on a trend whose `engine` has no draft: Nodaro Motion Lite),\n * `resolution_unsupported` (a `resolution` not in the trend's\n * `resolutions`), `too_many_images` (a Nodaro Motion Lite trend's run would send more\n * than 10 pictures: send fewer per slot). The slot errors carry the\n * slot's key as `slot` (in `NodaroError.details`), and `chip_not_offered`\n * the chip as `chip` too.\n * - 401 `unauthorized`.\n * - 404 `not_found`: the trend is not published (every method), or `run()`'s\n * `sessionId` is not a session you may use.\n * - 502 `engine_error` (`estimate()` / `run()`).\n * - 503 `engine_unsupported` (this platform version cannot run trends yet),\n * `trend_unavailable` (`estimate()` / `run()`), `not_available` (this\n * server has no trend catalog yet).\n * - `estimate()` / `run()` answer the video engine's refusals with the trend\n * routes' OWN codes and fixed messages — never the engine's text or\n * `issues`: 400 `trend_run_rejected` (the inputs could not run), or\n * `clip_out_of_range` / `preview_out_of_range` / `video_unreadable` (this\n * trend's clip), `unsafe_url` (a picture is not a public http(s) address),\n * `raw_reference_token` (`details` holds `{image:` / `{video:` /\n * `{audio:`); 402 `insufficient_credits` (or a workspace cap) as given;\n * 413 `storage_limit_exceeded`; 422 `job_blocked` (the job policy\n * blocked it); 429 `rate_limited`; 503 `engine_unsupported`,\n * `estimate_unavailable`; 502 `engine_error` for anything else. `run()`\n * also answers 400 `validation_error` for an `idempotencyKey` outside\n * 8–200 characters.\n */\n\n/** `/v1/trends/runs` is the run list and `/v1/trends/tags` the tag list, so neither can be a trend's slug. */\nconst RESERVED_SLUGS: Readonly<Record<string, string>> = {\n runs: \"the run list; use runs()\",\n tags: \"the tag list; use tags()\",\n}\n\nfunction trendPath(slug: string, rest = \"\"): string {\n if (Object.hasOwn(RESERVED_SLUGS, slug)) {\n throw new TypeError(`\"${slug}\" is not a trend slug (it is reserved for ${RESERVED_SLUGS[slug]})`)\n }\n return `/v1/trends/${encodeURIComponent(slug)}${rest}`\n}\n\n/** What a slot holds. */\nexport type TrendSlotKind = \"person\" | \"location\" | \"product\" | \"pet\"\n\n/** A chip: make this trait anew from your pictures (`\"new\"`), or keep the clip's (`\"original\"`). */\nexport type TrendChoice = \"new\" | \"original\"\n\n/**\n * The chips a slot can take, by its kind: a person `body` / `outfit` / `hair`,\n * a pet `body` / `coat`, a product `shape` / `finish`, a location none.\n */\nexport interface TrendChips {\n body?: TrendChoice\n outfit?: TrendChoice\n hair?: TrendChoice\n coat?: TrendChoice\n shape?: TrendChoice\n finish?: TrendChoice\n}\n\n/** A chip's name: `body`, `outfit`, `hair`, `coat`, `shape` or `finish`. */\nexport type TrendChipKey = keyof TrendChips\n\nexport type TrendResolution = \"480p\" | \"720p\" | \"1080p\"\n\n/**\n * The engine a trend runs on, by its public id ({@link CastSwapEngine}):\n * `\"motion-pro\"` (Nodaro Motion Pro) or `\"motion-lite\"` (Nodaro Motion Lite).\n * The trend chooses it, never the person running it.\n */\nexport type TrendEngine = CastSwapEngine\n\n/** A trend in the catalog (`list()`). Text is in the resolved locale. */\nexport interface TrendCard {\n id: string\n slug: string\n name: string\n description?: string\n tags: string[]\n /** e.g. `\"trending\"`, `\"new\"`. */\n badges: string[]\n /**\n * The trend's first example, else (a trend with no example) its original's\n * display copy, as {@link TrendDetail.original}.\n */\n cover: { videoUrl: string; posterUrl?: string; width: number; height: number }\n /** How many slots of each kind the trend has. */\n needs: Record<TrendSlotKind, number>\n /** The length of a full run, in seconds. */\n durationSec: number\n isFavorite: boolean\n}\n\n/** One slot of a trend: what it asks you for. */\nexport interface TrendDetailSlot {\n /** The key to fill in {@link TrendRunRequest.slots}, and to mention in `details` as `{slot:<key>}`. */\n key: string\n label: string\n kind: TrendSlotKind\n /**\n * A required slot needs pictures; an optional one left empty takes the\n * chosen example's, or, on a trend with no example, stays as in the original.\n */\n required: boolean\n hint?: string\n /**\n * A picture showing who or what this slot is in the original (e.g. a frame\n * of that actor), when the trend has one. Show it on an empty slot; a run\n * never sends it.\n */\n hintImageUrl?: string\n /**\n * The chips you may set on this slot, in its kind's order; `[]` = none (show\n * no chips row). A chip of the kind that is not listed is fixed by the\n * trend: sending it is refused with `400 chip_not_offered`.\n */\n chips: TrendChipKey[]\n /** The starting value of the chips in {@link chips} (only those). */\n defaults?: TrendChips\n}\n\n/** A finished run shown on a trend's page, with the pictures it used per slot. */\nexport interface TrendExample {\n videoUrl: string\n posterUrl?: string\n width: number\n height: number\n /** Slot key → the pictures this example used for it. */\n slots: Record<string, string[]>\n}\n\n/**\n * The clip a trend recasts, as you may show it: a browser-safe copy (H.264\n * MP4) of the clip every run starts from. Its fields parallel\n * {@link TrendExample}'s.\n */\nexport interface TrendOriginal {\n videoUrl: string\n posterUrl?: string\n width: number\n height: number\n /** The copy's length, in seconds. */\n durationSec: number\n /**\n * Where the 4-second preview starts in the clip, in seconds (`0` included),\n * when the trend offers one ({@link TrendDetail.previewSec} is `4`); absent\n * otherwise.\n */\n previewStartSec?: number\n}\n\n/** A trend's page (`get()`). */\nexport interface TrendDetail extends TrendCard {\n /** The published version this page shows. */\n version: number\n /** `4` when the trend offers a 4-second preview run, else `null`. */\n previewSec: 4 | null\n /**\n * The original clip every run starts from, to show beside the examples.\n * Absent only on a version without a display copy (and from an older server).\n */\n original?: TrendOriginal\n /** The engine every run of this trend uses. Absent (an older server) = `\"motion-pro\"`. */\n engine?: TrendEngine\n /** Its name to show: \"Nodaro Motion Pro\" or \"Nodaro Motion Lite\". Absent from an older server. */\n engineName?: string\n /**\n * The resolutions a run may ask for, the default first. Nodaro Motion Pro:\n * `[\"480p\", \"720p\", \"1080p\"]`, where 480p is a draft (show it as one);\n * Nodaro Motion Lite: `[\"720p\", \"1080p\"]`, no draft. Offer exactly these.\n */\n resolutions: TrendResolution[]\n slots: TrendDetailSlot[]\n /** Finished runs to show beside the original; may be empty (a trend with only its original). */\n examples: TrendExample[]\n}\n\n/** What you put in one slot of a run: 1–3 pictures, and the chips the slot offers ({@link TrendDetailSlot.chips}). */\nexport interface TrendRunSlot extends TrendChips {\n images?: string[]\n}\n\n/** The body of `estimate()` and `run()`. */\nexport interface TrendRunRequest {\n /**\n * Slot key → what you put in it. Every required slot needs pictures; an\n * optional slot left out takes the chosen example's, or, on a trend with no\n * example, stays as in the original. 1–3 pictures per slot.\n */\n slots: Record<string, TrendRunSlot>\n /**\n * 1-based example whose pictures fill the optional slots you leave empty.\n * Default 1. Leave it out on a trend with no examples: sending one there\n * answers 400 `example_out_of_range` (and `0` is a `validation_error`).\n */\n example?: number\n /** Your own words, at most 1,000 characters. Mention a slot as `{slot:<key>}`. */\n details?: string\n /** `true` runs a 4-second preview (only when the trend's `previewSec` is `4`). */\n preview?: boolean\n /**\n * One of the trend's {@link TrendDetail.resolutions}; default its first\n * (`\"480p\"` on Nodaro Motion Pro, `\"720p\"` on Nodaro Motion Lite). Another answers 400\n * `resolution_unsupported`.\n */\n resolution?: TrendResolution\n /**\n * A draft run, only at 480p on a Nodaro Motion Pro trend. Default `true` at\n * 480p. `true` on a Nodaro Motion Lite trend answers 400 `draft_unsupported`.\n */\n draft?: boolean\n /**\n * A generation session of yours. Accepted (and checked: one you may not use\n * is a 404), but not yet applied: trend runs are not filed into sessions yet.\n */\n sessionId?: string\n /** Accepted, but not used by the run today. */\n projectId?: string\n /**\n * A full run's own preview: the `jobId` of a completed preview run of this\n * trend that you started. When that preview needed the trend's retry (the\n * clip refused at first), the full run is made that way from the start (the\n * quote includes it). Any other job is ignored, without an error. Must be a uuid\n * (else 400 `validation_error`).\n */\n previewJobId?: string\n /**\n * `run()`: your client app's slug (e.g. `\"tools\"`: lowercase letters,\n * digits and `-`, 1–40 characters, starting with a letter or digit), as on\n * any job: the run's job carries it as `input_data.origin`, so\n * `client.jobs.list({ origin })` finds it. Not a slug is a 400\n * `validation_error`; without it the run has no origin. `estimate()`\n * ignores it.\n */\n origin?: string\n}\n\n/** What a run would cost, in credits (`estimate()`). */\nexport interface TrendEstimate {\n /** The charge the run is expected to come to. */\n expectedCredits: number\n /** What is reserved when the run starts; the run is charged what it actually costs. */\n holdCredits: number\n /**\n * The parts of the quote, by name, for display only: some are alternatives\n * or sit outside the totals (`privacy`, the retry's, beside\n * `privacyCredits`), so read `expectedCredits` and `holdCredits`, never\n * their sum.\n */\n breakdown: Record<string, number>\n /**\n * Only on a trend that retries a clip the video model refuses: the extra\n * credits charged if that retry runs. Not included in `expectedCredits` or\n * `holdCredits`. 0 (or absent) when there is nothing extra to charge.\n */\n privacyCredits?: number\n /** @deprecated read {@link privacyCredits} (an older server answered this name). */\n maskingCredits?: number\n}\n\n/** Per-call options for {@link TrendsResource.run}. */\nexport interface TrendRunOptions {\n /**\n * Sent as the `Idempotency-Key` header, unchanged (an empty string sends no\n * header). The server takes 8–200 characters and answers 400 for any other\n * length. Reuse it when retrying the same run.\n */\n idempotencyKey?: string\n}\n\n/** One slot of a past run, as it was run. Labels are English. */\nexport interface TrendRunDisplaySlot extends TrendChips {\n key: string\n label: string\n kind: TrendSlotKind\n images: string[]\n /**\n * `true` when the slot was left empty and the example's pictures filled it.\n * `false` with no `images`: left empty on a trend with no example, so it\n * stayed as in the original.\n */\n fromExample: boolean\n}\n\n/**\n * One of your trend runs (`runs()`, `getRun()`). Stays readable after the\n * trend moves on or is unpublished.\n *\n * A Full Quality version of a draft is a run of its own, with its own status,\n * result and charge: `fullQualityOf` names the draft it was made from, and it\n * stays listed after that draft is deleted.\n */\nexport interface TrendRun {\n jobId: string\n status: string\n progress: number | null\n /**\n * Why a failed or cancelled run did not finish; `null` otherwise. `code` is\n * `safety-block` or `policy-block` when the job was blocked, `credits` when\n * it ran out of credits partway (it was refunded: ask the person to top up,\n * then run it again), else `cancelled` or `failed`. `message` is the same\n * fixed sentence for every code — branch on `code`, not on the text.\n */\n error: { code?: string; message: string } | null\n createdAt: string\n completedAt: string | null\n /** The trend and version it ran (name in English). */\n trend: { id: string; slug: string; version: number; name: string }\n /**\n * The 1-based example used for empty optional slots; `0` = the trend had no\n * example (none was used: never show it as \"Example 0\").\n */\n example: number\n slots: TrendRunDisplaySlot[]\n details?: string\n preview: boolean\n resolution: string\n draft: boolean\n /** The engine the run was made on. Absent (an older server) = `\"motion-pro\"`. */\n engine?: TrendEngine\n /** Its name to show: \"Nodaro Motion Pro\" or \"Nodaro Motion Lite\". Absent from an older server. */\n engineName?: string\n /** The result, once completed. */\n videoUrl: string | null\n posterUrl: string | null\n creditsCharged: number | null\n /** A Full Quality version: the job id of the run (a draft, or a Nodaro Motion Lite 720p run) it was made from. `null` for any other run. */\n fullQualityOf: string | null\n /**\n * A draft's (or Nodaro Motion Lite 720p run's) newest Full Quality try, if one was started: a pointer only,\n * to know an upgrade exists and how it is going. Its video and charge are on\n * that run, listed on its own (its `fullQualityOf` is this run's `jobId`) —\n * read it there (`getRun(fullQuality.jobId)`). Older tries of the draft (a\n * failed or cancelled one tried again) are not listed by `runs()`;\n * `getRun()` still reads one by its id.\n */\n fullQuality: { jobId: string; status: string } | null\n /**\n * Until when a completed run can be redone in Full Quality — a Nodaro Motion\n * Pro draft (the same take at 1080p) or a Nodaro Motion Lite run at 720p (a new take at\n * 1080p); `null` otherwise.\n */\n fullQualityUntil: string | null\n}\n\nexport interface ListTrendsParams {\n /** Search text. */\n q?: string\n tag?: string\n /** `true` lists only your favorites. */\n favorites?: boolean\n /** A platform language for names and descriptions; default your profile's, then English. */\n locale?: string\n /** The previous page's `next`. */\n cursor?: string\n /** Page size, 1–60 (server default 30). */\n limit?: number\n}\n\nexport interface ListTrendRunsParams {\n /** Only runs of this trend (its slug). */\n trend?: string\n /** The previous page's `next`. */\n cursor?: string\n /** Page size, 1–60 (server default 30). */\n limit?: number\n}\n\n/** A tag in use on the published catalog (`tags()`). */\nexport interface TrendTag {\n /** The tag itself: pass it as `list({ tag })`. */\n tag: string\n /** The tag's label in the resolved locale; the tag itself when it has none. */\n label: string\n /** How many published trends carry it. */\n count: number\n}\n\nexport interface TrendPage<T> {\n data: T[]\n /** Pass back as `cursor` for the next page; `null` on the last one. */\n next: string | null\n}\n\nexport class TrendsResource {\n constructor(private client: NodaroClientCore) {}\n\n /** The published catalog in its curated order (`GET /v1/trends`), a page at a time. */\n list(params: ListTrendsParams = {}): Promise<TrendPage<TrendCard>> {\n const query: Record<string, string> = {}\n if (params.q) query.q = params.q\n if (params.tag) query.tag = params.tag\n if (params.favorites) query.favorites = \"1\"\n if (params.locale) query.locale = params.locale\n if (params.cursor) query.cursor = params.cursor\n if (params.limit !== undefined) query.limit = String(params.limit)\n return this.client.request(\"GET\", \"/v1/trends\", { query })\n }\n\n /** A published trend's page (`GET /v1/trends/:slug`). */\n async get(slug: string, params: { locale?: string } = {}): Promise<TrendDetail> {\n const query: Record<string, string> = {}\n if (params.locale) query.locale = params.locale\n const res = await this.client.request<{ data: TrendDetail }>(\"GET\", trendPath(slug), { query })\n return res.data\n }\n\n /** Quote a run before starting it (`POST /v1/trends/:slug/estimate`); spends nothing. */\n async estimate(slug: string, request: TrendRunRequest): Promise<TrendEstimate> {\n const res = await this.client.request<{ data: TrendEstimate }>(\n \"POST\",\n trendPath(slug, \"/estimate\"),\n { body: request },\n )\n return res.data\n }\n\n /**\n * Start a run (`POST /v1/trends/:slug/runs`, 202). Returns the job to follow.\n * With `options.idempotencyKey` (sent as the `Idempotency-Key` header) a\n * repeat with the same key answers with the first run's `jobId`.\n */\n async run(slug: string, request: TrendRunRequest, options?: TrendRunOptions): Promise<{ jobId: string }> {\n const res = await this.client.request<{ data: { jobId: string } }>(\n \"POST\",\n trendPath(slug, \"/runs\"),\n {\n body: request,\n ...(options?.idempotencyKey ? { headers: { \"Idempotency-Key\": options.idempotencyKey } } : {}),\n },\n )\n return res.data\n }\n\n /**\n * Your trend runs, newest first (`GET /v1/trends/runs`). A Full Quality\n * version of a draft is listed as its own run (`fullQualityOf`).\n */\n runs(params: ListTrendRunsParams = {}): Promise<TrendPage<TrendRun>> {\n const query: Record<string, string> = {}\n if (params.trend) query.trend = params.trend\n if (params.cursor) query.cursor = params.cursor\n if (params.limit !== undefined) query.limit = String(params.limit)\n return this.client.request(\"GET\", \"/v1/trends/runs\", { query })\n }\n\n /**\n * One of your trend runs by its job id (`GET /v1/trends/runs/:jobId`), in\n * the same shape as `runs()`. A job that is not your own trend run is a\n * `NotFoundError`.\n */\n async getRun(jobId: string): Promise<TrendRun> {\n const res = await this.client.request<{ data: TrendRun }>(\"GET\", `/v1/trends/runs/${encodeURIComponent(jobId)}`)\n return res.data\n }\n\n /**\n * The tags in use on the published catalog, each with its label in the\n * resolved locale (`GET /v1/trends/tags`), most used first.\n */\n async tags(params: { locale?: string } = {}): Promise<TrendTag[]> {\n const query: Record<string, string> = {}\n if (params.locale) query.locale = params.locale\n const res = await this.client.request<{ data: TrendTag[] }>(\"GET\", \"/v1/trends/tags\", { query })\n return res.data\n }\n\n /** Add a trend to your favorites (`PUT /v1/trends/:slug/favorite`). */\n async favorite(slug: string): Promise<void> {\n await this.client.request<void>(\"PUT\", trendPath(slug, \"/favorite\"))\n }\n\n /** Remove a trend from your favorites (`DELETE /v1/trends/:slug/favorite`). */\n async unfavorite(slug: string): Promise<void> {\n await this.client.request<void>(\"DELETE\", trendPath(slug, \"/favorite\"))\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ // src/resources/trash.ts
4
+ var TrashResource = class {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ client;
9
+ /** One newest-first page of the Trash, on your side of the workspace line. */
10
+ list(params = {}) {
11
+ const query = {};
12
+ if (params.projectId) query.projectId = params.projectId;
13
+ if (params.tool) query.tool = params.tool;
14
+ if (params.type !== void 0) query.type = typeof params.type === "string" ? params.type : params.type.join(",");
15
+ if (params.limit !== void 0) query.limit = String(params.limit);
16
+ if (params.cursor) query.cursor = params.cursor;
17
+ return this.client.request("GET", "/v1/trash", { query });
18
+ }
19
+ };
20
+
21
+ exports.TrashResource = TrashResource;
22
+ //# sourceMappingURL=chunk-XKDVEQVD.cjs.map
23
+ //# sourceMappingURL=chunk-XKDVEQVD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/trash.ts"],"names":[],"mappings":";;;AAyDO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA,EAGpB,IAAA,CAAK,MAAA,GAA0B,EAAC,EAAuB;AACrD,IAAA,MAAM,QAAgC,EAAC;AACvC,IAAA,IAAI,MAAA,CAAO,SAAA,EAAW,KAAA,CAAM,SAAA,GAAY,MAAA,CAAO,SAAA;AAC/C,IAAA,IAAI,MAAA,CAAO,IAAA,EAAM,KAAA,CAAM,IAAA,GAAO,MAAA,CAAO,IAAA;AACrC,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAO,MAAA,CAAO,IAAA,KAAS,QAAA,GAAW,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,KAAK,GAAG,CAAA;AAChH,IAAA,IAAI,OAAO,KAAA,KAAU,MAAA,QAAiB,KAAA,GAAQ,MAAA,CAAO,OAAO,KAAK,CAAA;AACjE,IAAA,IAAI,MAAA,CAAO,MAAA,EAAQ,KAAA,CAAM,MAAA,GAAS,MAAA,CAAO,MAAA;AACzC,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,WAAA,EAAa,EAAE,OAAO,CAAA;AAAA,EAC1D;AACF","file":"chunk-XKDVEQVD.cjs","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\nimport type { Job } from \"./jobs.js\"\n\n/** The session a removed item was removed from. */\nexport interface TrashSession {\n id: string\n title: string | null\n projectId: string | null\n}\n\n/**\n * One entry of the Trash: an item removed from a session, or a deleted job.\n * Narrow on `kind`.\n *\n * - `removed`: kept until restored (`client.sessions.restoreItem(session.id, job.id)`)\n * or deleted for good (`client.sessions.removeItem(session.id, job.id, { forever: true })`).\n * - `deleted`: kept until `purgeAt` (30 days after `deletedAt`), then deleted for\n * good (a copy saved to the Library stays); restore with `client.jobs.restore(job.id)`, or delete\n * now with `client.jobs.delete(job.id, { forever: true })`.\n *\n * A removed item whose job was also deleted is listed once, as the deleted job.\n */\nexport type TrashEntry =\n | { kind: \"removed\"; removedAt: string; session: TrashSession; job: Job }\n | { kind: \"deleted\"; deletedAt: string; purgeAt: string; job: Job }\n\nexport interface ListTrashParams {\n /**\n * A project's id: its sessions' removed items, and deleted jobs a session of\n * it held. `\"none\"`: the sessions with no project, and General.\n */\n projectId?: string | \"none\"\n /**\n * A creation tool (e.g. `\"create-image\"`): what a session of that tool holds\n * or held. A job no session ever held has no tool and is left out — filter by\n * `type` alone to include it.\n */\n tool?: string\n /**\n * The job's `input_data.type` (`\"generate-image\"`, …), like `client.jobs.list`.\n * One value or several (up to 20). Every filter combines with AND.\n */\n type?: string | readonly string[]\n /** Page size, 1–100 (server default 50). */\n limit?: number\n /** The previous page's `next`. */\n cursor?: string\n}\n\nexport interface TrashPage {\n /** A page may hold fewer than `limit` entries and still carry a `next`; page on `next`. */\n data: TrashEntry[]\n /** Pass back as `cursor` for the next page; `null` on the last one. */\n next: string | null\n}\n\n/** Your Trash (`GET /v1/trash`): one entry beside General in a creation tool's sessions list. */\nexport class TrashResource {\n constructor(private client: NodaroClientCore) {}\n\n /** One newest-first page of the Trash, on your side of the workspace line. */\n list(params: ListTrashParams = {}): Promise<TrashPage> {\n const query: Record<string, string> = {}\n if (params.projectId) query.projectId = params.projectId\n if (params.tool) query.tool = params.tool\n if (params.type !== undefined) query.type = typeof params.type === \"string\" ? params.type : params.type.join(\",\")\n if (params.limit !== undefined) query.limit = String(params.limit)\n if (params.cursor) query.cursor = params.cursor\n return this.client.request(\"GET\", \"/v1/trash\", { query })\n }\n}\n"]}
@@ -36,7 +36,7 @@ async function readBinaryResponse(response, maxBytes) {
36
36
  }
37
37
  return bytes.buffer;
38
38
  }
39
- var SDK_VERSION = "2.45.1" ;
39
+ var SDK_VERSION = "2.46.0" ;
40
40
  var CLIENT_HEADER = "X-Nodaro-Client";
41
41
  var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
42
42
  var NodaroClientCore = class {
@@ -229,5 +229,5 @@ exports.CallbackAuth = CallbackAuth;
229
229
  exports.NodaroClientCore = NodaroClientCore;
230
230
  exports.StaticTokenAuth = StaticTokenAuth;
231
231
  exports.supabaseAuth = supabaseAuth;
232
- //# sourceMappingURL=chunk-WFWZBYBS.cjs.map
233
- //# sourceMappingURL=chunk-WFWZBYBS.cjs.map
232
+ //# sourceMappingURL=chunk-ZJCHIJND.cjs.map
233
+ //# sourceMappingURL=chunk-ZJCHIJND.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/binary-response.ts","../src/core.ts","../src/auth.ts"],"names":["WORKSPACE_HEADER","throwFromResponse"],"mappings":";;;;;;AACA,eAAsB,kBAAA,CAAmB,UAAoB,QAAA,EAAwC;AACnG,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA;AACxD,EAAA,IAAI,UAAA,KAAe,IAAA,KAAS,CAAC,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA,IAAK,MAAA,CAAO,UAAU,CAAA,GAAI,QAAA,CAAA,EAAW;AACvF,IAAA,MAAM,QAAA,CAAS,MAAM,MAAA,EAAO;AAC5B,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,CAAC,QAAA,CAAS,IAAA,EAAM,OAAO,IAAI,YAAY,CAAC,CAAA;AAC5C,EAAA,MAAM,MA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E,YAAA,CAAa,IAAI,CAAA,EAAG,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,MACtD;AACA,MAAA,OAAO,KAAK,OAAA,GAAU,CAAA,CAAE,UAAS,GAAI,CAAA,CAAE,WAAW,CAAA,CAAE,MAAA;AAAA,IACtD;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;ACjUO,IAAM,kBAAN,MAAsC;AAAA,EAC3C,YAAoB,KAAA,EAAe;AAAf,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAA,EAAgB;AAAA,EAAhB,KAAA;AAAA,EACpB,MAAM,QAAA,GAAW;AACf,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AACF;AAEO,IAAM,eAAN,MAAmC;AAAA,EACxC,YAAoB,EAAA,EAAkD;AAAlD,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AAAA,EAAmD;AAAA,EAAnD,EAAA;AAAA,EACpB,MAAM,QAAA,GAAW;AACf,IAAA,OAAO,KAAK,EAAA,EAAG;AAAA,EACjB;AACF;AASO,SAAS,aAAa,QAAA,EAAoC;AAC/D,EAAA,OAAO;AAAA,IACL,MAAM,QAAA,GAAW;AACf,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,QAAA,CAAS,KAAK,UAAA,EAAW;AAChD,MAAA,OAAO,IAAA,CAAK,SAAS,YAAA,IAAgB,IAAA;AAAA,IACvC;AAAA,GACF;AACF","file":"chunk-WFWZBYBS.cjs","sourcesContent":["/** Bound decoded response bytes even when Content-Length is absent or compressed. */\nexport async function readBinaryResponse(response: Response, maxBytes: number): Promise<ArrayBuffer> {\n const advertised = response.headers.get(\"content-length\")\n if (advertised !== null && (!/^\\d+$/.test(advertised) || Number(advertised) > maxBytes)) {\n await response.body?.cancel()\n throw new Error(\"Binary response exceeds its declared size limit\")\n }\n if (!response.body) return new ArrayBuffer(0)\n const reader = response.body.getReader()\n const chunks: Uint8Array[] = []\n let length = 0\n try {\n while (true) {\n const next = await reader.read()\n if (next.done) break\n length += next.value.byteLength\n if (length > maxBytes) {\n await reader.cancel()\n throw new Error(\"Binary response exceeds its declared size limit\")\n }\n chunks.push(next.value)\n }\n } finally { reader.releaseLock() }\n const bytes = new Uint8Array(length)\n let offset = 0\n for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.byteLength }\n return bytes.buffer\n}\n","/**\n * The client core: configuration, auth, the request transport and the\n * account-identity calls — everything a resource needs, and none of the\n * resources themselves.\n *\n * {@link NodaroClient} (`createClient`) extends it with every resource. An app\n * that uses only a few resources can extend it with just those, so it loads\n * (and its tests depend on) only the resource modules it actually uses:\n *\n * class AppClient extends NodaroClientCore {\n * readonly jobs = new JobsResource(this)\n * readonly nodes = new NodesResource(this) // needs `jobs` on the same client\n * }\n *\n * A resource that calls another one through the client says so in its\n * constructor type (`NodesResource` takes a core that also has `jobs`), so a\n * client missing it fails to compile rather than at run time.\n */\nimport { readBinaryResponse } from \"./binary-response.js\"\nimport { throwFromResponse } from \"./errors.js\"\nimport type { Auth } from \"./auth.js\"\nimport type { DeveloperAppKind, DeveloperAppScope } from \"./resources/developer-apps.js\"\nimport { WORKSPACE_HEADER, type MeOrganizations } from \"@nodaro/shared/organizations\"\n\n/** Replaced at build time by tsup `define` from package.json. The fallback\n * keeps `tsx`/vitest runs of the source working, where no define applies. */\ndeclare const __SDK_VERSION__: string | undefined\nconst SDK_VERSION = typeof __SDK_VERSION__ === \"string\" ? __SDK_VERSION__ : \"0.0.0-dev\"\n\n/**\n * Identifies the calling package to the backend, which records it as the job's\n * provenance (`jobs.source` / `source_detail`) so an operator can tell a CLI\n * run from an SDK integration from a browser session.\n *\n * Only `sdk/…` and `cli/…` are honoured server-side; anything else is ignored\n * rather than trusted, since this is an unauthenticated header.\n */\nexport const CLIENT_HEADER = \"X-Nodaro-Client\"\n\n/**\n * In a browser the header is redundant AND a liability, so it is not sent.\n *\n * Redundant: the browser already sends `Origin`, which names the actual product\n * (`studio.nodaro.ai`) rather than merely the library it used — and the backend\n * deliberately prefers Origin over this header, so a browser-sent value is\n * discarded on arrival.\n *\n * A liability: `X-Nodaro-Client` is not a CORS-safelisted request header, so a\n * browser sending it requires an exact match in the server's\n * `Access-Control-Allow-Headers`. Any deployment whose backend predates that\n * allowlist entry would fail the PREFLIGHT — breaking every API call from the\n * app, not just its provenance. Self-hosted and lagging deployments make that a\n * real risk, and nothing in a browser app would reveal the cause.\n *\n * An EXPLICIT `clientLabel` is always sent regardless: a caller that names\n * itself has opted in deliberately, and that intent outranks this default.\n */\nconst isBrowser = (): boolean => typeof window !== \"undefined\" && typeof window.document !== \"undefined\"\n\nexport interface ClientOptions {\n /** Backend base URL, e.g. \"https://nodaro.example.com\" or empty string for same-origin. */\n baseUrl: string\n /** Auth provider. Use StaticTokenAuth, supabaseAuth, or CallbackAuth. */\n auth: Auth\n /** Optional fetch override (for tests or custom transports). */\n fetch?: typeof fetch\n /** Default request timeout in ms. Default 60s. */\n timeoutMs?: number\n /**\n * Overrides the `X-Nodaro-Client` label. Defaults to `sdk/<version>`.\n *\n * Exists for `@nodaro/cli`, which is a wrapper AROUND this SDK: without an\n * override every CLI invocation would be recorded as an SDK call and the two\n * surfaces could never be told apart.\n */\n clientLabel?: string\n /**\n * The workspace every request acts in — sent as `X-Nodaro-Workspace`.\n *\n * It selects which workspace a LIST reads from and where a CREATE lands.\n * It never authorizes: reading, updating, deleting or running an\n * identified object is decided by that object's own workspace, so a\n * forgotten header cannot hide work and a forged one cannot reach anyone\n * else's. Omit it to work in the caller's personal space.\n *\n * Prefer {@link NodaroClient.withWorkspace} for anything short-lived — one\n * client per workspace, no shared mutable selection to get wrong.\n */\n workspaceId?: string\n}\n\ninterface RequestOptions {\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n headers?: Record<string, string>\n signal?: AbortSignal\n}\n\n/**\n * The authenticated user's canonical identity (`GET /v1/me`). A token-\n * introspection primitive: any valid bearer token (first-party Supabase JWT or\n * a developer-app OAuth token) resolves to its owner's identity. Mirrors the\n * `profiles` identity columns server-side — the route is the source of truth.\n */\nexport interface UserIdentity {\n /** Nodaro user id (= the Supabase auth user id). */\n readonly id: string\n readonly email: string\n /** Human-readable display name (from `profiles.full_name`); `null` if unset. */\n readonly displayName: string | null\n /** Avatar URL; `null` if unset. */\n readonly avatarUrl: string | null\n /** Subscription tier (e.g. \"free\", \"pro\"). */\n readonly tier: string\n /**\n * Whether the user holds an admin role. DESCRIPTIVE only — use it to decide\n * whether to render admin surfaces without capability-probing an admin\n * endpoint; every admin API stays enforced server-side regardless.\n */\n readonly isAdmin: boolean\n}\n\n/**\n * An app the user let into their account through OAuth (`GET\n * /v1/me/connected-apps`): a developer app, an AI assistant's MCP connector, or\n * a self-hosted install. One entry per grant still in force.\n */\nexport interface ConnectedApp {\n /** The grant's id — what {@link NodaroClient.revokeConnectedApp} takes. */\n readonly authorizationId: string\n /** The app's name; `null` if it has none. A `dynamic_mcp` client chose its own. */\n readonly name: string | null\n /**\n * How the app came to exist: `user` (a developer app someone registered),\n * `first_party_mcp`, `dynamic_mcp` (an MCP client that registered itself) or\n * `community_instance` (a self-hosted install).\n */\n readonly kind: DeveloperAppKind | (string & {})\n readonly homepageUrl: string | null\n /** The scopes this grant holds. */\n readonly scopes: readonly DeveloperAppScope[]\n /** When the user granted access (ISO 8601). */\n readonly connectedAt: string\n /** The latest use of any token issued under the grant; `null` if never used. */\n readonly lastUsedAt: string | null\n}\n\nexport class NodaroClientCore {\n readonly baseUrl: string\n readonly auth: Auth\n readonly timeoutMs: number\n /** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */\n readonly clientLabel: string\n /** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */\n private readonly sendClientHeader: boolean\n private readonly fetchOverride: typeof fetch | undefined\n\n /**\n * Resolved lazily so consumers can swap `globalThis.fetch` after the\n * client has been constructed (e.g. test mocks). Always rebound to the\n * global object — native fetch throws \"Illegal invocation\" when its\n * `this` is anything else.\n */\n get fetch(): typeof fetch {\n return this.fetchOverride ?? globalThis.fetch.bind(globalThis)\n }\n\n /** The workspace this client acts in; undefined = the personal space. */\n readonly workspaceId: string | undefined\n\n constructor(opts: ClientOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/$/, \"\") // strip trailing slash\n this.auth = opts.auth\n this.fetchOverride = opts.fetch\n this.timeoutMs = opts.timeoutMs ?? 60_000\n this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`\n this.workspaceId = opts.workspaceId\n // Explicit label = deliberate opt-in, always sent. The default is suppressed\n // in browsers — see the note on CLIENT_HEADER.\n this.sendClientHeader = opts.clientLabel !== undefined || !isBrowser()\n }\n\n /**\n * The transport: build the request, send it, throw the typed error on a\n * non-2xx via {@link throwFromResponse}, then read the body via `read` — all\n * inside the abort timer, so `timeoutMs` bounds the body download too (a\n * stalled CSV stream aborts, it does not hang forever). Both the JSON path\n * ({@link request}) and the text path ({@link requestText}) go through here.\n */\n private async send<T>(\n method: string,\n path: string,\n options: RequestOptions,\n read: (res: Response) => Promise<T>,\n ): Promise<T> {\n const url = this.buildUrl(path, options.query)\n\n const token = await this.auth.getToken()\n // A `FormData` body is a multipart upload: let the runtime set\n // `Content-Type: multipart/form-data; boundary=…` itself (a manual JSON\n // content-type corrupts the boundary), and send the body as-is rather than\n // JSON-stringifying it. Every other body stays JSON, exactly as before.\n const isFormData =\n typeof FormData !== \"undefined\" && options.body instanceof FormData\n const headers: Record<string, string> = {\n ...(isFormData ? {} : { \"Content-Type\": \"application/json\" }),\n ...(this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {}),\n // Before per-request headers: a resource that needs to reach outside\n // this client's workspace says so explicitly and wins.\n ...(this.workspaceId ? { [WORKSPACE_HEADER]: this.workspaceId } : {}),\n ...(options.headers ?? {}),\n }\n if (token) headers[\"Authorization\"] = `Bearer ${token}`\n\n const ac = new AbortController()\n const timeoutId = setTimeout(() => ac.abort(), this.timeoutMs)\n const abort = () => ac.abort(options.signal?.reason)\n options.signal?.addEventListener(\"abort\", abort, { once: true })\n if (options.signal?.aborted) abort()\n\n try {\n ac.signal.throwIfAborted()\n const res = await this.fetch(url, {\n method,\n headers,\n body:\n options.body === undefined\n ? undefined\n : isFormData\n ? (options.body as FormData)\n : JSON.stringify(options.body),\n signal: ac.signal,\n })\n\n if (!res.ok) {\n let errBody: Record<string, unknown> = {}\n try {\n errBody = await res.json() as Record<string, unknown>\n } catch {\n // Empty/non-JSON body — fall through with empty errBody\n }\n throwFromResponse(res.status, errBody)\n }\n\n return await read(res)\n } finally {\n clearTimeout(timeoutId)\n options.signal?.removeEventListener(\"abort\", abort)\n }\n }\n\n /** Authenticated, bounded binary reads through the normal timeout/error transport. */\n async requestBytes(method: string, path: string, options: RequestOptions & { maxBytes: number }): Promise<ArrayBuffer> {\n if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1) throw new Error(\"maxBytes must be a positive integer\")\n return this.send(method, path, options, (response) => readBinaryResponse(response, options.maxBytes))\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n return this.send(method, path, options, async (res) =>\n // 204 No Content\n res.status === 204 ? (undefined as T) : ((await res.json()) as T),\n )\n }\n\n /**\n * Like {@link request}, for endpoints that answer text (CSV exports). Errors\n * are still the JSON envelope and throw the same typed errors, and the read is\n * bounded by the same timeout as the request.\n */\n async requestText(method: string, path: string, options: RequestOptions = {}): Promise<string> {\n return this.send(method, path, options, (res) => res.text())\n }\n\n /**\n * `GET /v1/me` → the authenticated user's identity (see {@link UserIdentity}).\n * Unwraps the `{ data }` envelope. Throws `UnauthorizedError` (401) when the\n * token is missing/invalid, and the SDK's other typed errors as usual.\n *\n * On an instance with organizations it also carries what the caller belongs\n * to. THREE states, and collapsing them is wrong in a way users feel: the\n * organization fields ABSENT means this instance has no organizations at\n * all; present and empty means the account belongs to none; and\n * `organizationsUnavailable` means the lookup failed — keep whatever\n * selection you already had rather than concluding the person was removed\n * from everything.\n */\n async me(): Promise<UserIdentity & MeOrganizations> {\n const res = await this.request<{ data: UserIdentity & MeOrganizations }>(\"GET\", \"/v1/me\")\n return res.data\n }\n\n /**\n * `GET /v1/me/connected-apps` → every app with access to the signed-in\n * user's account (see {@link ConnectedApp}), newest grant first.\n *\n * **A signed-in browser session only.** The route answers a Supabase\n * session token (`supabaseAuth(…)`, `createSharedSupabaseClient`, or a\n * `StaticTokenAuth` holding one) and refuses every other credential with\n * `UnauthorizedError` (\"Sign in required\"): an app token or an API key must\n * not list the grants it lives under. Build your \"Connected apps\" settings\n * screen on this; a server-side integration cannot call it.\n */\n async connectedApps(): Promise<ConnectedApp[]> {\n const res = await this.request<{ apps: ConnectedApp[] }>(\"GET\", \"/v1/me/connected-apps\")\n return res.apps\n }\n\n /**\n * `POST /v1/me/connected-apps/:authorizationId/revoke` — ends an app's\n * access: the grant and every token issued under it, at once (the app's next\n * call is a 401). Resolves when done.\n *\n * A signed-in browser session only, like {@link connectedApps}. Throws\n * `NotFoundError` when the grant is not the user's or is already revoked.\n */\n async revokeConnectedApp(authorizationId: string): Promise<void> {\n await this.request(\"POST\", `/v1/me/connected-apps/${encodeURIComponent(authorizationId)}/revoke`)\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const base = this.baseUrl || (typeof window !== \"undefined\" ? window.location.origin : \"http://placeholder\")\n const url = new URL(path, base)\n // If baseUrl was empty, strip the placeholder origin\n const fullUrl = this.baseUrl ? url.toString() : url.pathname + url.search\n if (query) {\n const u = new URL(this.baseUrl ? fullUrl : fullUrl, base)\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) u.searchParams.set(k, String(v))\n }\n return this.baseUrl ? u.toString() : u.pathname + u.search\n }\n return fullUrl\n }\n}\n","/**\n * Auth provides the token used for `Authorization: Bearer <token>` on each request.\n * Implementations:\n * - StaticTokenAuth — fixed string (server-side, OAuth access token, API token)\n * - CallbackAuth — caller-supplied async function (BYO logic)\n * - supabaseAuth — pulls JWT from a Supabase client live (browser frontends)\n */\nexport interface Auth {\n /** Returns the current Bearer token, or null if not authenticated. */\n getToken(): Promise<string | null>\n}\n\nexport class StaticTokenAuth implements Auth {\n constructor(private token: string) {}\n async getToken() {\n return this.token\n }\n}\n\nexport class CallbackAuth implements Auth {\n constructor(private fn: () => string | null | Promise<string | null>) {}\n async getToken() {\n return this.fn()\n }\n}\n\ninterface SupabaseLikeClient {\n auth: {\n getSession(): Promise<{ data: { session: { access_token: string } | null } }>\n }\n}\n\n/** Pulls a JWT from a Supabase v2 client. Caller supplies their own supabase. */\nexport function supabaseAuth(supabase: SupabaseLikeClient): Auth {\n return {\n async getToken() {\n const { data } = await supabase.auth.getSession()\n return data.session?.access_token ?? null\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/binary-response.ts","../src/core.ts","../src/auth.ts"],"names":["WORKSPACE_HEADER","throwFromResponse"],"mappings":";;;;;;AACA,eAAsB,kBAAA,CAAmB,UAAoB,QAAA,EAAwC;AACnG,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA;AACxD,EAAA,IAAI,UAAA,KAAe,IAAA,KAAS,CAAC,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA,IAAK,MAAA,CAAO,UAAU,CAAA,GAAI,QAAA,CAAA,EAAW;AACvF,IAAA,MAAM,QAAA,CAAS,MAAM,MAAA,EAAO;AAC5B,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,CAAC,QAAA,CAAS,IAAA,EAAM,OAAO,IAAI,YAAY,CAAC,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAA,CAAK,SAAA,EAAU;AACvC,EAAA,MAAM,SAAuB,EAAC;AAC9B,EAAA,IAAI,MAAA,GAAS,CAAA;AACb,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,EAAM;AACX,MAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,IAAA,EAAK;AAC/B,MAAA,IAAI,KAAK,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AAsC;AAAA,EAC3C,YAAoB,KAAA,EAAe;AAAf,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAA,EAAgB;AAAA,EAAhB,KAAA;AAAA,EACpB,MAAM,QAAA,GAAW;AACf,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AACF;AAEO,IAAM,eAAN,MAAmC;AAAA,EACxC,YAAoB,EAAA,EAAkD;AAAlD,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AAAA,EAAmD;AAAA,EAAnD,EAAA;AAAA,EACpB,MAAM,QAAA,GAAW;AACf,IAAA,OAAO,KAAK,EAAA,EAAG;AAAA,EACjB;AACF;AASO,SAAS,aAAa,QAAA,EAAoC;AAC/D,EAAA,OAAO;AAAA,IACL,MAAM,QAAA,GAAW;AACf,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,QAAA,CAAS,KAAK,UAAA,EAAW;AAChD,MAAA,OAAO,IAAA,CAAK,SAAS,YAAA,IAAgB,IAAA;AAAA,IACvC;AAAA,GACF;AACF","file":"chunk-ZJCHIJND.cjs","sourcesContent":["/** Bound decoded response bytes even when Content-Length is absent or compressed. */\nexport async function readBinaryResponse(response: Response, maxBytes: number): Promise<ArrayBuffer> {\n const advertised = response.headers.get(\"content-length\")\n if (advertised !== null && (!/^\\d+$/.test(advertised) || Number(advertised) > maxBytes)) {\n await response.body?.cancel()\n throw new Error(\"Binary response exceeds its declared size limit\")\n }\n if (!response.body) return new ArrayBuffer(0)\n const reader = response.body.getReader()\n const chunks: Uint8Array[] = []\n let length = 0\n try {\n while (true) {\n const next = await reader.read()\n if (next.done) break\n length += next.value.byteLength\n if (length > maxBytes) {\n await reader.cancel()\n throw new Error(\"Binary response exceeds its declared size limit\")\n }\n chunks.push(next.value)\n }\n } finally { reader.releaseLock() }\n const bytes = new Uint8Array(length)\n let offset = 0\n for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.byteLength }\n return bytes.buffer\n}\n","/**\n * The client core: configuration, auth, the request transport and the\n * account-identity calls — everything a resource needs, and none of the\n * resources themselves.\n *\n * {@link NodaroClient} (`createClient`) extends it with every resource. An app\n * that uses only a few resources can extend it with just those, so it loads\n * (and its tests depend on) only the resource modules it actually uses:\n *\n * class AppClient extends NodaroClientCore {\n * readonly jobs = new JobsResource(this)\n * readonly nodes = new NodesResource(this) // needs `jobs` on the same client\n * }\n *\n * A resource that calls another one through the client says so in its\n * constructor type (`NodesResource` takes a core that also has `jobs`), so a\n * client missing it fails to compile rather than at run time.\n */\nimport { readBinaryResponse } from \"./binary-response.js\"\nimport { throwFromResponse } from \"./errors.js\"\nimport type { Auth } from \"./auth.js\"\nimport type { DeveloperAppKind, DeveloperAppScope } from \"./resources/developer-apps.js\"\nimport { WORKSPACE_HEADER, type MeOrganizations } from \"@nodaro/shared/organizations\"\n\n/** Replaced at build time by tsup `define` from package.json. The fallback\n * keeps `tsx`/vitest runs of the source working, where no define applies. */\ndeclare const __SDK_VERSION__: string | undefined\nconst SDK_VERSION = typeof __SDK_VERSION__ === \"string\" ? __SDK_VERSION__ : \"0.0.0-dev\"\n\n/**\n * Identifies the calling package to the backend, which records it as the job's\n * provenance (`jobs.source` / `source_detail`) so an operator can tell a CLI\n * run from an SDK integration from a browser session.\n *\n * Only `sdk/…` and `cli/…` are honoured server-side; anything else is ignored\n * rather than trusted, since this is an unauthenticated header.\n */\nexport const CLIENT_HEADER = \"X-Nodaro-Client\"\n\n/**\n * In a browser the header is redundant AND a liability, so it is not sent.\n *\n * Redundant: the browser already sends `Origin`, which names the actual product\n * (`studio.nodaro.ai`) rather than merely the library it used — and the backend\n * deliberately prefers Origin over this header, so a browser-sent value is\n * discarded on arrival.\n *\n * A liability: `X-Nodaro-Client` is not a CORS-safelisted request header, so a\n * browser sending it requires an exact match in the server's\n * `Access-Control-Allow-Headers`. Any deployment whose backend predates that\n * allowlist entry would fail the PREFLIGHT — breaking every API call from the\n * app, not just its provenance. Self-hosted and lagging deployments make that a\n * real risk, and nothing in a browser app would reveal the cause.\n *\n * An EXPLICIT `clientLabel` is always sent regardless: a caller that names\n * itself has opted in deliberately, and that intent outranks this default.\n */\nconst isBrowser = (): boolean => typeof window !== \"undefined\" && typeof window.document !== \"undefined\"\n\nexport interface ClientOptions {\n /** Backend base URL, e.g. \"https://nodaro.example.com\" or empty string for same-origin. */\n baseUrl: string\n /** Auth provider. Use StaticTokenAuth, supabaseAuth, or CallbackAuth. */\n auth: Auth\n /** Optional fetch override (for tests or custom transports). */\n fetch?: typeof fetch\n /** Default request timeout in ms. Default 60s. */\n timeoutMs?: number\n /**\n * Overrides the `X-Nodaro-Client` label. Defaults to `sdk/<version>`.\n *\n * Exists for `@nodaro/cli`, which is a wrapper AROUND this SDK: without an\n * override every CLI invocation would be recorded as an SDK call and the two\n * surfaces could never be told apart.\n */\n clientLabel?: string\n /**\n * The workspace every request acts in — sent as `X-Nodaro-Workspace`.\n *\n * It selects which workspace a LIST reads from and where a CREATE lands.\n * It never authorizes: reading, updating, deleting or running an\n * identified object is decided by that object's own workspace, so a\n * forgotten header cannot hide work and a forged one cannot reach anyone\n * else's. Omit it to work in the caller's personal space.\n *\n * Prefer {@link NodaroClient.withWorkspace} for anything short-lived — one\n * client per workspace, no shared mutable selection to get wrong.\n */\n workspaceId?: string\n}\n\ninterface RequestOptions {\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n headers?: Record<string, string>\n signal?: AbortSignal\n}\n\n/**\n * The authenticated user's canonical identity (`GET /v1/me`). A token-\n * introspection primitive: any valid bearer token (first-party Supabase JWT or\n * a developer-app OAuth token) resolves to its owner's identity. Mirrors the\n * `profiles` identity columns server-side — the route is the source of truth.\n */\nexport interface UserIdentity {\n /** Nodaro user id (= the Supabase auth user id). */\n readonly id: string\n readonly email: string\n /** Human-readable display name (from `profiles.full_name`); `null` if unset. */\n readonly displayName: string | null\n /** Avatar URL; `null` if unset. */\n readonly avatarUrl: string | null\n /** Subscription tier (e.g. \"free\", \"pro\"). */\n readonly tier: string\n /**\n * Whether the user holds an admin role. DESCRIPTIVE only — use it to decide\n * whether to render admin surfaces without capability-probing an admin\n * endpoint; every admin API stays enforced server-side regardless.\n */\n readonly isAdmin: boolean\n}\n\n/**\n * An app the user let into their account through OAuth (`GET\n * /v1/me/connected-apps`): a developer app, an AI assistant's MCP connector, or\n * a self-hosted install. One entry per grant still in force.\n */\nexport interface ConnectedApp {\n /** The grant's id — what {@link NodaroClient.revokeConnectedApp} takes. */\n readonly authorizationId: string\n /** The app's name; `null` if it has none. A `dynamic_mcp` client chose its own. */\n readonly name: string | null\n /**\n * How the app came to exist: `user` (a developer app someone registered),\n * `first_party_mcp`, `dynamic_mcp` (an MCP client that registered itself) or\n * `community_instance` (a self-hosted install).\n */\n readonly kind: DeveloperAppKind | (string & {})\n readonly homepageUrl: string | null\n /** The scopes this grant holds. */\n readonly scopes: readonly DeveloperAppScope[]\n /** When the user granted access (ISO 8601). */\n readonly connectedAt: string\n /** The latest use of any token issued under the grant; `null` if never used. */\n readonly lastUsedAt: string | null\n}\n\nexport class NodaroClientCore {\n readonly baseUrl: string\n readonly auth: Auth\n readonly timeoutMs: number\n /** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */\n readonly clientLabel: string\n /** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */\n private readonly sendClientHeader: boolean\n private readonly fetchOverride: typeof fetch | undefined\n\n /**\n * Resolved lazily so consumers can swap `globalThis.fetch` after the\n * client has been constructed (e.g. test mocks). Always rebound to the\n * global object — native fetch throws \"Illegal invocation\" when its\n * `this` is anything else.\n */\n get fetch(): typeof fetch {\n return this.fetchOverride ?? globalThis.fetch.bind(globalThis)\n }\n\n /** The workspace this client acts in; undefined = the personal space. */\n readonly workspaceId: string | undefined\n\n constructor(opts: ClientOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/$/, \"\") // strip trailing slash\n this.auth = opts.auth\n this.fetchOverride = opts.fetch\n this.timeoutMs = opts.timeoutMs ?? 60_000\n this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`\n this.workspaceId = opts.workspaceId\n // Explicit label = deliberate opt-in, always sent. The default is suppressed\n // in browsers — see the note on CLIENT_HEADER.\n this.sendClientHeader = opts.clientLabel !== undefined || !isBrowser()\n }\n\n /**\n * The transport: build the request, send it, throw the typed error on a\n * non-2xx via {@link throwFromResponse}, then read the body via `read` — all\n * inside the abort timer, so `timeoutMs` bounds the body download too (a\n * stalled CSV stream aborts, it does not hang forever). Both the JSON path\n * ({@link request}) and the text path ({@link requestText}) go through here.\n */\n private async send<T>(\n method: string,\n path: string,\n options: RequestOptions,\n read: (res: Response) => Promise<T>,\n ): Promise<T> {\n const url = this.buildUrl(path, options.query)\n\n const token = await this.auth.getToken()\n // A `FormData` body is a multipart upload: let the runtime set\n // `Content-Type: multipart/form-data; boundary=…` itself (a manual JSON\n // content-type corrupts the boundary), and send the body as-is rather than\n // JSON-stringifying it. Every other body stays JSON, exactly as before.\n const isFormData =\n typeof FormData !== \"undefined\" && options.body instanceof FormData\n const headers: Record<string, string> = {\n ...(isFormData ? {} : { \"Content-Type\": \"application/json\" }),\n ...(this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {}),\n // Before per-request headers: a resource that needs to reach outside\n // this client's workspace says so explicitly and wins.\n ...(this.workspaceId ? { [WORKSPACE_HEADER]: this.workspaceId } : {}),\n ...(options.headers ?? {}),\n }\n if (token) headers[\"Authorization\"] = `Bearer ${token}`\n\n const ac = new AbortController()\n const timeoutId = setTimeout(() => ac.abort(), this.timeoutMs)\n const abort = () => ac.abort(options.signal?.reason)\n options.signal?.addEventListener(\"abort\", abort, { once: true })\n if (options.signal?.aborted) abort()\n\n try {\n ac.signal.throwIfAborted()\n const res = await this.fetch(url, {\n method,\n headers,\n body:\n options.body === undefined\n ? undefined\n : isFormData\n ? (options.body as FormData)\n : JSON.stringify(options.body),\n signal: ac.signal,\n })\n\n if (!res.ok) {\n let errBody: Record<string, unknown> = {}\n try {\n errBody = await res.json() as Record<string, unknown>\n } catch {\n // Empty/non-JSON body — fall through with empty errBody\n }\n throwFromResponse(res.status, errBody)\n }\n\n return await read(res)\n } finally {\n clearTimeout(timeoutId)\n options.signal?.removeEventListener(\"abort\", abort)\n }\n }\n\n /** Authenticated, bounded binary reads through the normal timeout/error transport. */\n async requestBytes(method: string, path: string, options: RequestOptions & { maxBytes: number }): Promise<ArrayBuffer> {\n if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1) throw new Error(\"maxBytes must be a positive integer\")\n return this.send(method, path, options, (response) => readBinaryResponse(response, options.maxBytes))\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n return this.send(method, path, options, async (res) =>\n // 204 No Content\n res.status === 204 ? (undefined as T) : ((await res.json()) as T),\n )\n }\n\n /**\n * Like {@link request}, for endpoints that answer text (CSV exports). Errors\n * are still the JSON envelope and throw the same typed errors, and the read is\n * bounded by the same timeout as the request.\n */\n async requestText(method: string, path: string, options: RequestOptions = {}): Promise<string> {\n return this.send(method, path, options, (res) => res.text())\n }\n\n /**\n * `GET /v1/me` → the authenticated user's identity (see {@link UserIdentity}).\n * Unwraps the `{ data }` envelope. Throws `UnauthorizedError` (401) when the\n * token is missing/invalid, and the SDK's other typed errors as usual.\n *\n * On an instance with organizations it also carries what the caller belongs\n * to. THREE states, and collapsing them is wrong in a way users feel: the\n * organization fields ABSENT means this instance has no organizations at\n * all; present and empty means the account belongs to none; and\n * `organizationsUnavailable` means the lookup failed — keep whatever\n * selection you already had rather than concluding the person was removed\n * from everything.\n */\n async me(): Promise<UserIdentity & MeOrganizations> {\n const res = await this.request<{ data: UserIdentity & MeOrganizations }>(\"GET\", \"/v1/me\")\n return res.data\n }\n\n /**\n * `GET /v1/me/connected-apps` → every app with access to the signed-in\n * user's account (see {@link ConnectedApp}), newest grant first.\n *\n * **A signed-in browser session only.** The route answers a Supabase\n * session token (`supabaseAuth(…)`, `createSharedSupabaseClient`, or a\n * `StaticTokenAuth` holding one) and refuses every other credential with\n * `UnauthorizedError` (\"Sign in required\"): an app token or an API key must\n * not list the grants it lives under. Build your \"Connected apps\" settings\n * screen on this; a server-side integration cannot call it.\n */\n async connectedApps(): Promise<ConnectedApp[]> {\n const res = await this.request<{ apps: ConnectedApp[] }>(\"GET\", \"/v1/me/connected-apps\")\n return res.apps\n }\n\n /**\n * `POST /v1/me/connected-apps/:authorizationId/revoke` — ends an app's\n * access: the grant and every token issued under it, at once (the app's next\n * call is a 401). Resolves when done.\n *\n * A signed-in browser session only, like {@link connectedApps}. Throws\n * `NotFoundError` when the grant is not the user's or is already revoked.\n */\n async revokeConnectedApp(authorizationId: string): Promise<void> {\n await this.request(\"POST\", `/v1/me/connected-apps/${encodeURIComponent(authorizationId)}/revoke`)\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const base = this.baseUrl || (typeof window !== \"undefined\" ? window.location.origin : \"http://placeholder\")\n const url = new URL(path, base)\n // If baseUrl was empty, strip the placeholder origin\n const fullUrl = this.baseUrl ? url.toString() : url.pathname + url.search\n if (query) {\n const u = new URL(this.baseUrl ? fullUrl : fullUrl, base)\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) u.searchParams.set(k, String(v))\n }\n return this.baseUrl ? u.toString() : u.pathname + u.search\n }\n return fullUrl\n }\n}\n","/**\n * Auth provides the token used for `Authorization: Bearer <token>` on each request.\n * Implementations:\n * - StaticTokenAuth — fixed string (server-side, OAuth access token, API token)\n * - CallbackAuth — caller-supplied async function (BYO logic)\n * - supabaseAuth — pulls JWT from a Supabase client live (browser frontends)\n */\nexport interface Auth {\n /** Returns the current Bearer token, or null if not authenticated. */\n getToken(): Promise<string | null>\n}\n\nexport class StaticTokenAuth implements Auth {\n constructor(private token: string) {}\n async getToken() {\n return this.token\n }\n}\n\nexport class CallbackAuth implements Auth {\n constructor(private fn: () => string | null | Promise<string | null>) {}\n async getToken() {\n return this.fn()\n }\n}\n\ninterface SupabaseLikeClient {\n auth: {\n getSession(): Promise<{ data: { session: { access_token: string } | null } }>\n }\n}\n\n/** Pulls a JWT from a Supabase v2 client. Caller supplies their own supabase. */\nexport function supabaseAuth(supabase: SupabaseLikeClient): Auth {\n return {\n async getToken() {\n const { data } = await supabase.auth.getSession()\n return data.session?.access_token ?? null\n },\n }\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-RQSGS7ZK.cjs');
4
- var chunk55ZX6TE3_cjs = require('../chunk-55ZX6TE3.cjs');
4
+ var chunk66M54BUO_cjs = require('../chunk-66M54BUO.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "CastSwapResource", {
9
9
  enumerable: true,
10
- get: function () { return chunk55ZX6TE3_cjs.CastSwapResource; }
10
+ get: function () { return chunk66M54BUO_cjs.CastSwapResource; }
11
11
  });
12
12
  //# sourceMappingURL=cast-swap.cjs.map
13
13
  //# sourceMappingURL=cast-swap.cjs.map