UNPKG

@signiant/media-shuttle-sdk

Version:

The SDK for supporting file transfer to and from Media Shuttle

224 lines 10.3 kB
import { RemoteFile, signiant_private } from '@signiant/media-shuttle-sdk-base'; import Credentials from '../../external/common/Credentials'; import { GetFolderContentRequest, Portal, PortalBasicRequest, PortalFile, PortalPermissions } from '../../external'; import { BasicRequestOptions } from '../../external/common/BasicRequestOptions'; import { FormDefinition, PortalMetadataForms } from '../../external/navigation/Explorer'; export interface GetTransferConfigOptions extends BasicRequestOptions { files: RemoteFile[]; destinationPath?: string; portalId: string; transferDirection?: string; appVersion?: string; clientId?: string; metadata?: Record<string, any>; } export interface PlatformServiceConstructorOptions { baseUrl: string; credentials: Credentials; } interface CreateTransferFileResponse { filePath: string; fileSize: number; fileId: string; fileName: string; } export interface CreateTransferResponse { portalId: string; packageId: string; transferId: string; transferConfig: signiant_private.TransferConfig; files: CreateTransferFileResponse[]; } export interface UpdateTransferBody { fileIds: string[]; portalId: string; status?: string; protocol?: string; userAgent?: string; bytesTransferred?: number; bytesRemaining?: number; etaMillis?: number; rateInBytesPerSecond?: number; } export interface UpdateTransferOptions extends BasicRequestOptions { body: UpdateTransferBody; transferId: string; } export interface GetPortalsRequestOptions extends BasicRequestOptions { cursor?: string; pageSize?: number; limitPortalsToMemberRole?: boolean; } export interface GetFormDefinitionRequestOptions { accountId: string; serviceId: string; formDefinitionId: string; } interface PlatformArrayResponse<T> { items: T[]; } interface Account { accountId: string; accountName: string; authenticationConfig: { mfaEnabled: boolean; }; } interface Service { serviceInfo: string; accountId: string; serviceId: string; serviceType: string; startsOn: string; effectiveContractDetails: { isExpired: boolean; startsOn: string; }; } interface Role { accountId: string; serviceId: string; role: string; msAccountId?: string; } interface ProfileResponse { accounts: PlatformArrayResponse<Account>; services: PlatformArrayResponse<Service>; roles: PlatformArrayResponse<Role>; } interface ListResponse<T> { items: T[]; nextCursor?: string; } /** * All messages to the platform API service should be filtered through the PlatformService. */ declare class PlatformService { private readonly _baseUrl; private readonly _credentials; constructor({ baseUrl, credentials }: PlatformServiceConstructorOptions); /** * This function creates a transfer in Media Shuttle * @param {GetTransferConfigOptions} - **files** - An array of file objects. Each file object must * have a **path** property and a **size** property. * @returns The response from the API call. */ createTransfer({ files, portalId, transferDirection, accountId, destinationPath, serviceId, appVersion, clientId, metadata, }: GetTransferConfigOptions): Promise<CreateTransferResponse>; /** * Fetches the profile information for a given user * @returns {Promise<ProfileResponse>} List of accounts and service basic information */ getProfile(): Promise<ProfileResponse>; /** * Fetch a list of portals. * * @param {GetPortalsRequestOptions} options - GetPortalsRequestOptions * @param {string} options.cursor - Opaque string used to fetch the next page of results * @returns {Promise<ListResponse<Portal>>} A promise that resolves to a ListResponse<Portal> object. */ getPortals({ serviceId, accountId, cursor, pageSize, limitPortalsToMemberRole, }: GetPortalsRequestOptions): Promise<ListResponse<Portal>>; /** * @ignore * It updates a transfer. * @param {UpdateTransferOptions} UpdateTransferOptions the required parameters to update a transfer * @param {string} UpdateTransferOptions.serviceId - **serviceId**: The ID of the Media Shuttle service. * @param {UpdateTransferOptions} UpdateTransferOptions.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {UpdateTransferOptions} UpdateTransferOptions.transferId - **transferId**: The ID of transfer. * @param {UpdateTransferOptions} UpdateTransferOptions.body - **body**: Update transfer REST request body. * @returns The update transfer response. */ updateTransfer({ serviceId, body, transferId, accountId, }: UpdateTransferOptions): Promise<UpdateTransferBody>; /** * @ignore * It gets the contents of a portal folder. * @param {GetFolderContentRequest} - Request Object | Includes all the required parameters in order to perform te getFolderContent request * @param {GetFolderContentRequest} GetFolderContentRequest.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {GetFolderContentRequest} GetFolderContentRequest.portalId - **portalId**: The ID of portal. * @param {GetFolderContentRequest} GetFolderContentRequest.serviceId - **serviceId**: The ID of the MS Service. * @param {GetFolderContentRequest} GetFolderContentRequest.folderId - **folderId**: Folder Identifier. * @param {GetFolderContentRequest} GetFolderContentRequest.browsePath - **browsePath**: path of the subfolder to look for relative to the provided folderId * @returns A list of files/folders in the folder. */ getFolderContent({ accountId, portalId, serviceId, folderId, browsePath, }: GetFolderContentRequest): Promise<ListResponse<PortalFile>>; /** * @ignore * It gets the permissions for a member of a portal. * @param {PortalBasicRequest} requestObject - Request Object | Includes all the required parameters in order to perform te getPortalMemberPermissions request * @param {string} requestObject.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {string} requestObject.serviceId - **serviceId**: The ID of the MS Service. * @param {string} requestObject.portalId - **portalId**: The ID of portal. * @returns The permissions for the portal member. */ getPortalMemberPermissions({ accountId, serviceId, portalId, }: PortalBasicRequest): Promise<PortalPermissions>; /** * Retrieves the metadata form definitions configured for a Media Shuttle portal. * * Calls the Platform API endpoint: * GET /v1/mediaShuttle/portals/{portalId}/metadataForms * using account- and service-scoped authentication headers. * * @param accountId - The unique identifier of the account that owns the portal. * @param serviceId - The identifier of the Media Shuttle service within the account. * @param portalId - The unique identifier of the portal whose metadata forms are requested. * * @returns A promise that resolves to the portal's metadata form definitions. * * @throws Error - If the request fails due to network errors, authorization issues, or a non-2xx API response. * * @example * const forms = await platformService.getPortalMetadataForms({ * accountId: 'acc-123', * serviceId: 'svc-456', * portalId: 'portal-789', * }); */ getPortalMetadataForms({ accountId, serviceId, portalId }: PortalBasicRequest): Promise<PortalMetadataForms>; /** * Retrieves a form definition by its unique identifier from the Platform API. * * Constructs an authenticated GET request to the `/v1/formDefinitions/{formDefinitionId}` endpoint * using account- and service-scoped headers generated for the provided identifiers. * * @param options - Options used to authorize and locate the form definition. * @param options.accountId - The account identifier used to scope and authorize the request. * @param options.serviceId - The service identifier used to scope and authorize the request. * @param options.formDefinitionId - The unique identifier of the form definition to retrieve. * * @returns A promise that resolves to the matching FormDefinition. * * @throws {Error} If the request fails due to authentication/authorization errors (e.g., 401/403), * not found (404), network issues, or any non-2xx HTTP response from the platform. * * @example * ```ts * const formDef = await platformService.getFormDefinitionById({ * accountId: 'acc_123', * serviceId: 'svc_456', * formDefinitionId: 'fd_789', * }); * console.log(formDef.name); * ``` */ getFormDefinitionById({ accountId, serviceId, formDefinitionId, }: GetFormDefinitionRequestOptions): Promise<FormDefinition>; /** * It takes an object with two properties, `accountId` and `serviceId`, and returns a promise that * resolves to an object with four properties, `Authorization`, `Date`, `Signiant-Account-Id`, and * `Signiant-Service-Id`, which are the required headers for most of the Platform requests * @param {Object} headerOptions * @param {string} headerOptions.accountId - `accountId` - The account ID of the account you want to use. * @param {string} headerOptions.serviceId - `serviceId` - The Media Shuttle service ID. * @param {string} headerOptions.appVersion - `appVersion` - Signiant application version * @param {string} headerOptions.clientId - `clientId` - Signiant App Machine identifier * @param {string} headerOptions.apiClientType - `apiClientType` - Indicates the initiator of the API Request * @returns {Promise<PlatformRequestHeaders} a PlatformRequestHeaders object. */ private generateHeaders; /** * Returns the basic required headers to make a Platform request * @param {string} token auth token used for the Authorization header * @returns {object} basic headers */ private getBasicHeaders; } export default PlatformService; //# sourceMappingURL=PlatformService.d.ts.map