samsar-js 0.48.25 → 0.48.26

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/README.md CHANGED
@@ -160,6 +160,14 @@ const translated = await samsar.translateVideo(
160
160
  { webhookUrl: 'https://example.com/webhook' },
161
161
  );
162
162
 
163
+ // Deep-clone an existing completed session and render a new final video URL
164
+ const cloned = await samsar.cloneVideo(
165
+ {
166
+ videoSessionId: videoFromImages.data.session_id ?? videoFromImages.data.request_id!,
167
+ },
168
+ { webhookUrl: 'https://example.com/webhook' },
169
+ );
170
+
163
171
  // Join multiple completed sessions into a single appended video
164
172
  const joined = await samsar.joinVideos(
165
173
  {
@@ -544,6 +552,7 @@ Video model support notes:
544
552
  - `createVideoFromImageList` can render per-scene footer QR cards by setting `add_footer_animation: true` and providing one `footer_metadata` item per image scene.
545
553
  - `updateVideoOutroImage` accepts either a replacement outro image URL (`outro_image_url`, `outroImageUrl`, `new_outro_image_url`) or a generated QR CTA outro (`generate_outro_image: true` with `cta_url`, or just `cta_url` when no outro image URL is supplied). Generated outro updates reuse the existing session image layers for tiling and only queue frame/video regeneration.
546
554
  - `updateVideoFooterImage` updates the footer CTA on a cloned session with `cta_text`, `cta_logo`, and/or `cta_url`, or removes all scene footers with `remove_footer: true`. Footer updates queue only frame/video regeneration.
555
+ - `cloneVideo` creates a deep copy of a completed session and queues only the final video render so the clone receives a new rendered video path and URL. It does not charge credits.
547
556
  - Main video methods and external-user methods accept the same generated outro and footer parameters. The API can resolve either internal session ids or external `extreq_...` ids on repeated video routes, so client code can keep using `translateVideo`, `joinVideos`, `addSubtitles`, `removeSubtitles`, `addVideoOutroImage`, `updateVideoOutroImage`, and `updateVideoFooterImage`; the explicit external variants are available when you want to call `/external_users/*` directly. Do not strip the `extreq_` prefix.
548
557
  - Completed video status, latest-version, and completed-session list responses expose `has_subtitles` and `result_language` when the session metadata is available.
549
558
  - `publishPublication`, `editPublication`, and `revokePublication` manage public feed publications for completed sessions through free `/publications/*` endpoints. They work with account API keys, customer sub-account API keys, and client auth tokens when the session belongs to the authenticated actor.
@@ -551,7 +560,7 @@ Video model support notes:
551
560
 
552
561
  Upcoming `/v2` omni route adapters:
553
562
  - `/v2` is additive; `/v1` is not deprecated.
554
- - `createV2VideoFromText`, `createV2VideoFromImageList`, `translateV2Video`, `updateV2VideoOutroImage`, `updateV2VideoFooterImage`, `addV2VideoOutroImage`, `getV2Status`, `getV2Credits`, `listV2Requests`, and `createV2Session` call the new omni route surface.
563
+ - `createV2VideoFromText`, `createV2VideoFromImageList`, `translateV2Video`, `cloneV2Video`, `updateV2VideoOutroImage`, `updateV2VideoFooterImage`, `addV2VideoOutroImage`, `getV2Status`, `getV2Credits`, `listV2Requests`, and `createV2Session` call the new omni route surface.
555
564
  - Programmatic user billing helpers include `createV2UserRechargeCredits`, `refreshV2UserToken`, `createV2UserAppKey`, `refreshV2UserAppKey`, `getV2UserCredits`, `getV2UserUsageLogs`, and `getV2UserPaymentStatus`.
556
565
  - Omit `externalUser` for internal account billing, pass `externalUser` to scope an external user with the account API key, or authenticate the client directly with an external-user auth token/API key.
557
566
 
@@ -580,6 +589,10 @@ const v2Translated = await platform.translateV2Video({
580
589
  translate_footer: true,
581
590
  });
582
591
 
592
+ const v2Clone = await platform.cloneV2Video({
593
+ videoSessionId: v2Video.data.request_id!,
594
+ });
595
+
583
596
  const v2Status = await platform.getV2Status(v2Video.data.request_id!);
584
597
  console.log(v2Status.data.status);
585
598
  ```
package/dist/index.d.ts CHANGED
@@ -237,6 +237,26 @@ export interface TranslateVideoResponse {
237
237
  remainingCredits?: number | null;
238
238
  [key: string]: unknown;
239
239
  }
240
+ export interface CloneVideoInput {
241
+ videoSessionId?: string;
242
+ video_session_id?: string;
243
+ videoSessionID?: string;
244
+ session_id?: string;
245
+ sessionId?: string;
246
+ sessionID?: string;
247
+ request_id?: string;
248
+ requestId?: string;
249
+ source_session_id?: string;
250
+ sourceSessionId?: string;
251
+ source_request_id?: string;
252
+ sourceRequestId?: string;
253
+ [key: string]: unknown;
254
+ }
255
+ export interface CloneVideoResponse extends GlobalStatusResponse {
256
+ sessionID?: string;
257
+ creditsCharged?: number;
258
+ remainingCredits?: number | null;
259
+ }
240
260
  export interface UpdateVideoOutroImageInput {
241
261
  videoSessionId?: string;
242
262
  video_session_id?: string;
@@ -1722,6 +1742,7 @@ export declare class SamsarClient {
1722
1742
  createV2VideoFromText(input: CreateVideoFromTextInput, options?: V2RequestOptions): Promise<SamsarResult<CreateVideoResponse | ExternalRequestResponse>>;
1723
1743
  createV2VideoFromImageList(input: CreateVideoFromImageListInput, options?: V2RequestOptions): Promise<SamsarResult<CreateVideoFromImageListResponse | ExternalRequestResponse>>;
1724
1744
  translateV2Video(input: TranslateVideoInput, options?: V2RequestOptions): Promise<SamsarResult<TranslateVideoResponse | ExternalRequestResponse>>;
1745
+ cloneV2Video(input: CloneVideoInput, options?: V2RequestOptions): Promise<SamsarResult<CloneVideoResponse>>;
1725
1746
  uploadV2ImageData(imageData: string[], options?: V2RequestOptions): Promise<SamsarResult<{
1726
1747
  image_urls: string[];
1727
1748
  }>>;
@@ -1807,6 +1828,13 @@ export declare class SamsarClient {
1807
1828
  translateVideo(input: TranslateVideoInput, options?: {
1808
1829
  webhookUrl?: string;
1809
1830
  } & SamsarRequestOptions): Promise<SamsarResult<TranslateVideoResponse>>;
1831
+ /**
1832
+ * Deep-clone a completed video session and queue one final render for the new session.
1833
+ * The clone copies session assets, then regenerates only the final rendered video URL.
1834
+ */
1835
+ cloneVideo(input: CloneVideoInput, options?: {
1836
+ webhookUrl?: string;
1837
+ } & SamsarRequestOptions): Promise<SamsarResult<CloneVideoResponse>>;
1810
1838
  /**
1811
1839
  * Join multiple existing video sessions into a single session by appending their timelines.
1812
1840
  * Creates a new session_id and queues transcription + frame + video generation.
package/dist/index.js CHANGED
@@ -170,6 +170,28 @@ function normalizeTranslateVideoInput(input, context = 'translateVideo') {
170
170
  translate_footer: translateFooter,
171
171
  };
172
172
  }
173
+ function normalizeCloneVideoInput(input, context = 'cloneVideo') {
174
+ const raw = input;
175
+ const videoSessionId = raw.videoSessionId ??
176
+ raw.video_session_id ??
177
+ raw.videoSessionID ??
178
+ raw.session_id ??
179
+ raw.sessionId ??
180
+ raw.sessionID ??
181
+ raw.request_id ??
182
+ raw.requestId ??
183
+ raw.source_session_id ??
184
+ raw.sourceSessionId ??
185
+ raw.source_request_id ??
186
+ raw.sourceRequestId;
187
+ if (!videoSessionId) {
188
+ throw new Error(`videoSessionId is required for ${context}`);
189
+ }
190
+ return {
191
+ ...input,
192
+ videoSessionId: String(videoSessionId),
193
+ };
194
+ }
173
195
  function normalizeUpdateVideoOutroImageInput(input, context = 'updateVideoOutroImage') {
174
196
  const raw = input;
175
197
  const videoSessionId = raw.videoSessionId ??
@@ -541,6 +563,13 @@ export class SamsarClient {
541
563
  webhookUrl: options?.webhookUrl,
542
564
  }, options);
543
565
  }
566
+ async cloneV2Video(input, options) {
567
+ const normalizedInput = normalizeCloneVideoInput(input, 'cloneV2Video');
568
+ return this.postV2('video/clone', {
569
+ input: normalizedInput,
570
+ webhookUrl: options?.webhookUrl,
571
+ }, options);
572
+ }
544
573
  async uploadV2ImageData(imageData, options) {
545
574
  if (!Array.isArray(imageData) || imageData.length === 0) {
546
575
  throw new Error('imageData must be a non-empty array of data URLs');
@@ -782,6 +811,39 @@ export class SamsarClient {
782
811
  }
783
812
  return response;
784
813
  }
814
+ /**
815
+ * Deep-clone a completed video session and queue one final render for the new session.
816
+ * The clone copies session assets, then regenerates only the final rendered video URL.
817
+ */
818
+ async cloneVideo(input, options) {
819
+ const normalizedInput = normalizeCloneVideoInput(input, 'cloneVideo');
820
+ const body = {
821
+ input: {
822
+ ...normalizedInput,
823
+ },
824
+ webhookUrl: options?.webhookUrl,
825
+ };
826
+ const response = await this.post('video/clone', body, options);
827
+ const data = response.data;
828
+ if (data && typeof data === 'object') {
829
+ const sessionId = typeof data.sessionID === 'string'
830
+ ? data.sessionID
831
+ : typeof data.session_id === 'string'
832
+ ? data.session_id
833
+ : typeof data.request_id === 'string'
834
+ ? data.request_id
835
+ : undefined;
836
+ const normalizedSessionId = sessionId ? String(sessionId) : undefined;
837
+ const normalizedData = {
838
+ ...data,
839
+ sessionID: data.sessionID ?? normalizedSessionId ?? '',
840
+ session_id: data.session_id ?? normalizedSessionId ?? null,
841
+ request_id: data.request_id ?? normalizedSessionId ?? null,
842
+ };
843
+ return { ...response, data: normalizedData };
844
+ }
845
+ return response;
846
+ }
785
847
  /**
786
848
  * Join multiple existing video sessions into a single session by appending their timelines.
787
849
  * Creates a new session_id and queues transcription + frame + video generation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samsar-js",
3
- "version": "0.48.25",
3
+ "version": "0.48.26",
4
4
  "description": "TypeScript client for the Samsar Processor API routes.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",