samsar-js 0.48.31 → 0.48.32

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
@@ -330,14 +330,9 @@ await samsar.deleteEmbedding({
330
330
  source_id: '2',
331
331
  });
332
332
 
333
- // Remove branding/watermark
333
+ // Remove visible text
334
334
  const cleaned = await samsar.removeBrandingFromImage({ image_url: 'https://example.com/photo.png' });
335
335
 
336
- // Replace branding/watermark (original image, replacement logo/image)
337
- const replaced = await samsar.replaceBrandingFromImage({
338
- image_urls: ['https://example.com/photo.png', 'https://example.com/new-logo.png'],
339
- });
340
-
341
336
  // Extend image set
342
337
  const images = await samsar.extendImageList({
343
338
  image_urls: ['https://example.com/extra.jpg'],
@@ -578,10 +573,10 @@ console.log(externalLibrary.data.requests.map((request) => request.request_id));
578
573
  ```
579
574
 
580
575
  Video model support notes:
581
- - `createVideoFromText` image model keys include: `GPTIMAGE2`, `IMAGEN4`, `SEEDREAM`, `NANOBANANA2`, `CUSTOM_TEXT_TO_IMAGE`.
576
+ - `createVideoFromText` image model keys include: `GPTIMAGE2`, `IMAGEN4`, `SEEDREAM`, `NANOBANANA2`, `NANOBANANAPRO`, `CUSTOM_TEXT_TO_IMAGE`.
582
577
  - `createVideoFromText` supports these video models: `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `SEEDANCEI2V` (Seedance 1.5), `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V`.
583
578
  - `createVideoFromText` accepts either a provided outro (`outro_image_url`) or server-generated QR outro (`generate_outro_image: true` with `cta_url`). It can also render bottom CTA footer QR cards with `add_footer_animation` and `footer_metadata`; one footer item applies to every generated scene, while multiple items map by scene index.
584
- - `createVideoFromImageList` supports `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `SEEDANCEI2V`, `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V` via `video_model`; if omitted, it defaults to `RUNWAYML`. Use `aspect_ratio: '16:9'` or `'9:16'`; omitted or invalid values fall back to `16:9`.
579
+ - `createVideoFromImageList` supports `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `SEEDANCEI2V`, `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V` via `video_model`; if omitted, it defaults to `RUNWAYML`. It also accepts the same `image_model` keys as text-to-video. Use `aspect_ratio: '16:9'` or `'9:16'`; omitted or invalid values fall back to `16:9`.
585
580
  - `createVideoFromImageList` accepts either a provided outro (`outro_image_url`) or server-generated QR outro (`generate_outro_image: true` with `cta_url`). Do not combine the two modes in a single request.
586
581
  - `createVideoFromImageList` can render per-scene footer QR cards by setting `add_footer_animation: true` and providing one `footer_metadata` item per image scene.
587
582
  - `createVideoFromImageList` can also generate QR outro CTA text and each scene footer CTA from a single link by setting `express_cta_generation: true` with `cta_url`. CamelCase `expressCtaGeneration` and compatibility aliases `auto_generate_cta_text` / `generate_cta_texts` are normalized to the same API field.
package/dist/index.d.ts CHANGED
@@ -939,22 +939,6 @@ export interface RemoveBrandingFromImageResponse {
939
939
  remainingCredits?: number;
940
940
  [key: string]: unknown;
941
941
  }
942
- export interface ReplaceBrandingFromImageRequest {
943
- image_urls: string[];
944
- }
945
- export interface ReplaceBrandingFromImageResponse {
946
- status?: string;
947
- message?: string;
948
- request_id?: string;
949
- session_id?: string;
950
- global_status_id?: string;
951
- case_type?: string;
952
- image_urls: string[];
953
- userId?: string;
954
- creditsCharged?: number;
955
- remainingCredits?: number;
956
- [key: string]: unknown;
957
- }
958
942
  export interface EnhanceImageRequest {
959
943
  image_url: string;
960
944
  resolution?: '1k' | '2k' | '3k' | '4k';
@@ -1866,6 +1850,18 @@ export interface CreditsRechargeResponse {
1866
1850
  currency: string;
1867
1851
  [key: string]: unknown;
1868
1852
  }
1853
+ export interface V2CreditsRechargeRequest {
1854
+ credits?: number;
1855
+ credits_to_recharge?: number;
1856
+ creditsToRecharge?: number;
1857
+ [key: string]: unknown;
1858
+ }
1859
+ export interface V2CreditsGrantRequest {
1860
+ credits?: number;
1861
+ credits_to_grant?: number;
1862
+ creditsToGrant?: number;
1863
+ [key: string]: unknown;
1864
+ }
1869
1865
  export interface EnableAutoRechargeRequest {
1870
1866
  thresholdCredits?: number;
1871
1867
  amountUsd?: number;
@@ -1970,6 +1966,8 @@ export declare class SamsarClient {
1970
1966
  getV2<T = Record<string, unknown>>(path: string, options?: V2RequestOptions): Promise<SamsarResult<T>>;
1971
1967
  createV2Session(options?: V2RequestOptions): Promise<SamsarResult<V2SessionResponse>>;
1972
1968
  getV2Credits(options?: V2RequestOptions): Promise<SamsarResult<CreditsBalanceResponse | ExternalCreditsBalanceResponse>>;
1969
+ createV2CreditsRecharge(payload: number | V2CreditsRechargeRequest, options?: V2RequestOptions): Promise<SamsarResult<CreditsRechargeResponse | ExternalCreditsRechargeResponse>>;
1970
+ grantV2Credits(payload: number | V2CreditsGrantRequest, options?: V2RequestOptions): Promise<SamsarResult<ExternalCreditsGrantResponse>>;
1973
1971
  getV2UserCredits(options?: V2RequestOptions): Promise<SamsarResult<CreditsBalanceResponse>>;
1974
1972
  getV2UserUsageLogs(options?: V2RequestOptions & {
1975
1973
  page?: number;
@@ -1986,6 +1984,7 @@ export declare class SamsarClient {
1986
1984
  refreshV2UserAppKey(payload?: V2UserAppKeyRefreshRequest, options?: V2RequestOptions): Promise<SamsarResult<V2UserAppKeyResponse>>;
1987
1985
  revokeV2UserAppKey(options?: V2RequestOptions): Promise<SamsarResult<V2UserAppKeyResponse>>;
1988
1986
  getV2UserPaymentStatus(payload: PaymentStatusRequest, options?: V2RequestOptions): Promise<SamsarResult<PaymentStatusResponse>>;
1987
+ getV2PaymentStatus(payload: PaymentStatusRequest, options?: V2RequestOptions): Promise<SamsarResult<PaymentStatusResponse | ExternalPaymentStatusResponse>>;
1989
1988
  createV2LoginToken(options?: V2RequestOptions & {
1990
1989
  redirect?: string;
1991
1990
  }): Promise<SamsarResult<CreateLoginTokenResponse | ExternalCreateLoginTokenResponse>>;
@@ -2014,6 +2013,7 @@ export declare class SamsarClient {
2014
2013
  updateV2VideoOutroImage(input: UpdateVideoOutroImageInput, options?: V2RequestOptions): Promise<SamsarResult<UpdateVideoOutroImageResponse | ExternalRequestResponse>>;
2015
2014
  updateV2VideoFooterImage(input: UpdateVideoFooterImageInput, options?: V2RequestOptions): Promise<SamsarResult<UpdateVideoFooterImageResponse | ExternalRequestResponse>>;
2016
2015
  addV2VideoOutroImage(input: AddVideoOutroImageInput, options?: V2RequestOptions): Promise<SamsarResult<AddVideoOutroImageResponse | ExternalRequestResponse>>;
2016
+ joinV2Videos(input: JoinVideosInput, options?: V2RequestOptions): Promise<SamsarResult<JoinVideosResponse | ExternalRequestResponse>>;
2017
2017
  getV2Status(requestId: string, options?: V2RequestOptions & {
2018
2018
  queryParams?: QueryParams;
2019
2019
  }): Promise<SamsarResult<GlobalStatusResponse | ExternalStatusResponse>>;
@@ -2023,6 +2023,10 @@ export declare class SamsarClient {
2023
2023
  getV2DetailedStatus(requestId: string, options?: V2RequestOptions & {
2024
2024
  queryParams?: QueryParams;
2025
2025
  }): Promise<SamsarResult<GlobalStatusDetailedResponse | ExternalStatusDetailedResponse>>;
2026
+ /**
2027
+ * Cancel an in-progress v2 render for an existing video session.
2028
+ */
2029
+ cancelV2Render(input: CancelRenderInput, options?: V2RequestOptions): Promise<SamsarResult<CancelRenderResponse>>;
2026
2030
  /**
2027
2031
  * Create a new video generation job from text.
2028
2032
  */
@@ -2285,13 +2289,9 @@ export declare class SamsarClient {
2285
2289
  */
2286
2290
  getEmbeddingStatus(templateId: string, options?: SamsarRequestOptions): Promise<SamsarResult<EmbeddingStatusResponse>>;
2287
2291
  /**
2288
- * Remove branding/watermark from an image by URL.
2292
+ * Remove visible text from an image by URL.
2289
2293
  */
2290
2294
  removeBrandingFromImage(payload: RemoveBrandingFromImageRequest, options?: SamsarRequestOptions): Promise<SamsarResult<RemoveBrandingFromImageResponse>>;
2291
- /**
2292
- * Replace branding/watermark on an image by providing the original and replacement image URLs.
2293
- */
2294
- replaceBrandingFromImage(payload: ReplaceBrandingFromImageRequest, options?: SamsarRequestOptions): Promise<SamsarResult<ReplaceBrandingFromImageResponse>>;
2295
2295
  /**
2296
2296
  * Enhance an image by upscaling it with the specified resolution.
2297
2297
  */
package/dist/index.js CHANGED
@@ -557,6 +557,32 @@ export class SamsarClient {
557
557
  async getV2Credits(options) {
558
558
  return this.getV2('credits', options);
559
559
  }
560
+ async createV2CreditsRecharge(payload, options) {
561
+ const input = typeof payload === 'number' ? { credits: payload } : (payload ?? {});
562
+ const credits = Number(input.credits ?? input.credits_to_recharge ?? input.creditsToRecharge);
563
+ if (!Number.isFinite(credits) || credits <= 0 || !Number.isInteger(credits)) {
564
+ throw new Error('credits must be a positive integer');
565
+ }
566
+ return this.postV2('credits/recharge', {
567
+ input: {
568
+ ...input,
569
+ credits,
570
+ },
571
+ }, options);
572
+ }
573
+ async grantV2Credits(payload, options) {
574
+ const input = typeof payload === 'number' ? { credits: payload } : (payload ?? {});
575
+ const credits = Number(input.credits ?? input.credits_to_grant ?? input.creditsToGrant);
576
+ if (!Number.isFinite(credits) || credits <= 0 || !Number.isInteger(credits)) {
577
+ throw new Error('credits must be a positive integer');
578
+ }
579
+ return this.postV2('credits/grant', {
580
+ input: {
581
+ ...input,
582
+ credits,
583
+ },
584
+ }, options);
585
+ }
560
586
  async getV2UserCredits(options) {
561
587
  return this.getV2('user/credits', options);
562
588
  }
@@ -689,6 +715,24 @@ export class SamsarClient {
689
715
  query,
690
716
  });
691
717
  }
718
+ async getV2PaymentStatus(payload, options) {
719
+ const query = {
720
+ ...(options?.query ?? {}),
721
+ };
722
+ if (payload?.checkoutSessionId) {
723
+ query.checkoutSessionId = payload.checkoutSessionId;
724
+ }
725
+ if (payload?.paymentIntentId) {
726
+ query.paymentIntentId = payload.paymentIntentId;
727
+ }
728
+ if (payload?.setupIntentId) {
729
+ query.setupIntentId = payload.setupIntentId;
730
+ }
731
+ return this.getV2('payment_status', {
732
+ ...(options ?? {}),
733
+ query,
734
+ });
735
+ }
692
736
  async createV2LoginToken(options) {
693
737
  const body = options?.redirect ? { redirect: options.redirect } : {};
694
738
  return this.postV2('create_login_token', body, options);
@@ -828,6 +872,22 @@ export class SamsarClient {
828
872
  webhookUrl: options?.webhookUrl,
829
873
  }, options);
830
874
  }
875
+ async joinV2Videos(input, options) {
876
+ const rawIds = input.session_ids ?? input.sessionIds ?? input.video_session_ids ?? input.videoSessionIds;
877
+ const sessionIds = Array.isArray(rawIds)
878
+ ? rawIds.map((value) => (typeof value === 'string' ? value.trim() : '')).filter(Boolean)
879
+ : [];
880
+ if (sessionIds.length < 2) {
881
+ throw new Error('at least two session IDs are required for joinV2Videos');
882
+ }
883
+ return this.postV2('join_videos', {
884
+ input: {
885
+ ...input,
886
+ session_ids: sessionIds,
887
+ },
888
+ webhookUrl: options?.webhookUrl,
889
+ }, options);
890
+ }
831
891
  async getV2Status(requestId, options) {
832
892
  const queryParams = {
833
893
  ...(options?.externalUser
@@ -857,6 +917,48 @@ export class SamsarClient {
857
917
  async getV2DetailedStatus(requestId, options) {
858
918
  return this.getV2StatusDetailed(requestId, options);
859
919
  }
920
+ /**
921
+ * Cancel an in-progress v2 render for an existing video session.
922
+ */
923
+ async cancelV2Render(input, options) {
924
+ const raw = input;
925
+ const videoSessionId = raw.videoSessionId ??
926
+ raw.video_session_id ??
927
+ raw.videoSessionID ??
928
+ raw.session_id ??
929
+ raw.sessionId ??
930
+ raw.sessionID ??
931
+ raw.request_id ??
932
+ raw.requestId;
933
+ if (!videoSessionId) {
934
+ throw new Error('videoSessionId is required for cancelV2Render');
935
+ }
936
+ const response = await this.postV2('cancel_render', {
937
+ input: {
938
+ ...input,
939
+ videoSessionId: String(videoSessionId),
940
+ },
941
+ }, options);
942
+ const data = response.data;
943
+ if (data && typeof data === 'object') {
944
+ const sessionId = typeof data.sessionID === 'string'
945
+ ? data.sessionID
946
+ : typeof data.session_id === 'string'
947
+ ? data.session_id
948
+ : typeof data.request_id === 'string'
949
+ ? data.request_id
950
+ : undefined;
951
+ const normalizedSessionId = sessionId ? String(sessionId) : undefined;
952
+ const normalizedData = {
953
+ ...data,
954
+ sessionID: data.sessionID ?? normalizedSessionId ?? '',
955
+ session_id: data.session_id ?? normalizedSessionId,
956
+ request_id: data.request_id ?? normalizedSessionId,
957
+ };
958
+ return { ...response, data: normalizedData };
959
+ }
960
+ return response;
961
+ }
860
962
  /**
861
963
  * Create a new video generation job from text.
862
964
  */
@@ -1757,17 +1859,11 @@ export class SamsarClient {
1757
1859
  });
1758
1860
  }
1759
1861
  /**
1760
- * Remove branding/watermark from an image by URL.
1862
+ * Remove visible text from an image by URL.
1761
1863
  */
1762
1864
  async removeBrandingFromImage(payload, options) {
1763
1865
  return this.post('image/remove_branding', payload, options);
1764
1866
  }
1765
- /**
1766
- * Replace branding/watermark on an image by providing the original and replacement image URLs.
1767
- */
1768
- async replaceBrandingFromImage(payload, options) {
1769
- return this.post('image/replace_branding', payload, options);
1770
- }
1771
1867
  /**
1772
1868
  * Enhance an image by upscaling it with the specified resolution.
1773
1869
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samsar-js",
3
- "version": "0.48.31",
3
+ "version": "0.48.32",
4
4
  "description": "TypeScript client for the Samsar Processor API routes.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",