export type LongMap = {[key: string]: number}; export type LicenseGateRules = {enabled?: Array | undefined, disabled?: Array | undefined}; export type LicenseGatePolicy = {productFeatures?: LicenseGateRules | undefined, commands?: LicenseGateRules | undefined}; export type IssueLicenseArgs = {requestId?: string | undefined, customerPartyId?: string | undefined, softwarePartyId?: string | undefined, installationId?: string | undefined, templateId?: string | undefined, profileId?: string | undefined, product: string, edition: string, features?: Array | undefined, quotas?: LongMap | undefined, gatePolicy?: LicenseGatePolicy | undefined, validFrom?: string | undefined, expiresAt?: string | undefined, installationBaseDomain?: string | undefined, platformDomainRoots?: Array | undefined, notes?: string | undefined}; export type CreateApiLicensesBundleArgs = {body: IssueLicenseArgs}; export type CreateApiLicensesBundleOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Issue a protected setup bundle * * POST /licenses/bundle */ export const createApiLicensesBundle = async (args: CreateApiLicensesBundleArgs, options?: CreateApiLicensesBundleOptions) => { const {baseUrl = "https://api.example.com/api/license-portal/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "multipart/mixed") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/licenses/bundle${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };