From 5a6686324a85eb359236d6243306bd017f78d0bf Mon Sep 17 00:00:00 2001 From: larryrider Date: Mon, 9 Feb 2026 13:27:27 +0100 Subject: [PATCH 1/2] feat(send): implement Send class and related types for link management --- src/send/index.ts | 1 + src/send/send.ts | 49 +++++++++++++++++++++++++++++++ src/send/types/index.ts | 64 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 src/send/index.ts create mode 100644 src/send/send.ts create mode 100644 src/send/types/index.ts diff --git a/src/send/index.ts b/src/send/index.ts new file mode 100644 index 0000000..d1ab99c --- /dev/null +++ b/src/send/index.ts @@ -0,0 +1 @@ +export * from './send'; diff --git a/src/send/send.ts b/src/send/send.ts new file mode 100644 index 0000000..431c3bd --- /dev/null +++ b/src/send/send.ts @@ -0,0 +1,49 @@ +import { ApiUrl, AppDetails } from '../shared'; +import { basicHeaders } from '../shared/headers'; +import { HttpClient } from '../shared/http/client'; +import { CreateSendLinksPayload, CreateSendLinksResponse, GetSendLinkResponse } from './types'; + +export class Send { + private readonly client: HttpClient; + private readonly appDetails: AppDetails; + + public static client(apiUrl: ApiUrl, appDetails: AppDetails) { + return new Send(apiUrl, appDetails); + } + + private constructor(apiUrl: ApiUrl, appDetails: AppDetails) { + this.client = HttpClient.create(apiUrl); + this.appDetails = appDetails; + } + + /** + * Gets a send link by its id + * @param linkId id of the send link + * @returns a promise with the send link data + */ + public getSendLink(linkId: string): Promise { + return this.client.get('/links/' + linkId, this.headers()); + } + + /** + * Creates a new send link + * @param payload contains the data to create a new send link + * @returns a promise with the newly created send link data + */ + public createSendLink(payload: CreateSendLinksPayload): Promise { + // Spread payload into a plain object literal so it matches the `Parameters`/Record expected by HttpClient.post + return this.client.post('/links/', { ...payload }, this.headers()); + } + + /** + * Returns the basic needed headers for the module requests + * @private + */ + private headers() { + return basicHeaders({ + clientName: this.appDetails.clientName, + clientVersion: this.appDetails.clientVersion, + customHeaders: this.appDetails.customHeaders, + }); + } +} diff --git a/src/send/types/index.ts b/src/send/types/index.ts new file mode 100644 index 0000000..9f8d985 --- /dev/null +++ b/src/send/types/index.ts @@ -0,0 +1,64 @@ +export interface SendItemBasic { + id: string; + name: string; + size: number; + type: 'file' | 'folder'; + parent_folder: string | null; +} + +export interface SendItem extends SendItemBasic { + linkId: string; + networkId: string; + encryptionKey: string; + createdAt: Date; + updatedAt: Date; + version: number; + path?: string; + countFiles?: number; + childrenFiles?: SendItem[]; + childrenFolders?: SendItem[]; +} + +export interface GetSendLinkResponse { + id: string; + title: string; + subject: string; + code: string; + views: number; + userId: number | null; + items: SendItem[]; + createdAt: string; + updatedAt: string; + expirationAt: string; + size: number; +} + +export interface SendLink extends SendItemBasic { + networkId: string; + encryptionKey: string; +} + +export interface CreateSendLinksPayload { + sender?: string; + receivers?: string[]; + code: string; + title?: string; + subject?: string; + items: SendLink[]; + mnemonic: string; +} + +export interface CreateSendLinksResponse { + id: string; + title: string; + subject: string; + code: string; + sender: string; + receivers: string[]; + views: number; + userId: number; + items: SendLink[]; + createdAt: string; + updatedAt: string; + expirationAt: string; +} From cb994db9c852ddc64987467a4337acf96628e630 Mon Sep 17 00:00:00 2001 From: larryrider Date: Mon, 9 Feb 2026 13:29:20 +0100 Subject: [PATCH 2/2] chore: bump sdk version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b72b3f..49032e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.12.4", + "version": "1.12.5", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git",