@zdrops/ai-assistants-sdk 1.4.0 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.5.1](https://github.com/ZDrops/ai-assistants-sdk/compare/ai-assistants-sdk-v1.5.0...ai-assistants-sdk-v1.5.1) (2026-06-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * trigger reelase please ([6495fbb](https://github.com/ZDrops/ai-assistants-sdk/commit/6495fbbcdc189afb1245ce455b7e11d1f03d87a8))
9
+
10
+ ## [1.5.0](https://github.com/ZDrops/ai-assistants-sdk/compare/ai-assistants-sdk-v1.4.0...ai-assistants-sdk-v1.5.0) (2026-06-20)
11
+
12
+
13
+ ### Features
14
+
15
+ * **api-types:** enhance PaginatedResponse schema and add ReceiptItemDto definition ([e9908df](https://github.com/ZDrops/ai-assistants-sdk/commit/e9908dfaa4fa22bf242dd5cf6ebce6a2eb731ddf))
16
+ * **client:** add ping() method to verify client configuration ([66a85ac](https://github.com/ZDrops/ai-assistants-sdk/commit/66a85ac2c63746c288b58310d042db9e5fb097b1))
17
+
3
18
  ## [1.4.0](https://github.com/ZDrops/ai-assistants-sdk/compare/ai-assistants-sdk-v1.3.0...ai-assistants-sdk-v1.4.0) (2026-05-11)
4
19
 
5
20
 
package/dist/index.cjs CHANGED
@@ -420,6 +420,9 @@ function createClient(options) {
420
420
  payments: new PaymentsResource(http),
421
421
  tenants: new TenantsResource(http),
422
422
  receipts: new ReceiptsResource(http),
423
+ ping() {
424
+ return http.get("/api/v1/ping", { authenticated: false });
425
+ },
423
426
  setAccessToken(token) {
424
427
  accessToken = token;
425
428
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/auth.ts","../src/resources/plans.ts","../src/resources/credits.ts","../src/resources/billing.ts","../src/resources/preferences.ts","../src/resources/conversations.ts","../src/resources/generation.ts","../src/resources/images.ts","../src/resources/payments.ts","../src/resources/tenants.ts","../src/resources/receipts.ts","../src/client.ts"],"sourcesContent":["export { createClient } from \"./client\";\nexport type { ClientOptions, AiAssistantsClient } from \"./client\";\n\nexport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n PurchaseCreditsDto,\n UpsertBillingDto,\n UpdatePreferencesDto,\n CreateConversationDto,\n AddMessageDto,\n GenerateDto,\n TriggerImageDto,\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n PlanResponseDto,\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n PurchaseCreditsResponseDto,\n CreditBalanceEntityResponseDto,\n BillingResponseDto,\n PreferenceResponseDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n ImageStatusResponseDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n TenantPublicInfoDto,\n StartAuthResponseDto,\n PaginatedResponse,\n\n OtpType,\n UserRole,\n PlanType,\n CreditTransactionType,\n ConversationStatus,\n MessageRole,\n ImageGenerationStatus,\n} from \"./types\";\n\nexport type { SseStreamOptions, GenerationDoneData } from \"./resources/generation\";\n\nexport { ApiError } from \"./errors\";\n","export class ApiError extends Error {\n constructor(\n public readonly statusCode: number,\n public readonly code: string,\n message: string | string[],\n public readonly requestId?: string,\n ) {\n super(Array.isArray(message) ? message.join(\", \") : message);\n this.name = \"ApiError\";\n }\n}\n","import { ApiError } from \"./errors\";\nimport type { TokensResponseDto } from \"./types\";\n\nexport interface HttpClientConfig {\n baseUrl: string;\n tenantKey: string;\n getAccessToken: () => string | null;\n getRefreshToken: () => string | null;\n onTokenRefreshed: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\ntype HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ninterface RequestOptions {\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined | null>;\n authenticated?: boolean;\n}\n\ninterface InternalRequestOptions extends RequestOptions {\n isRetry?: boolean;\n}\n\nexport class HttpClient {\n private refreshPromise: Promise<boolean> | null = null;\n private readonly baseUrl: URL;\n private readonly fetchFn: typeof globalThis.fetch;\n\n constructor(private config: HttpClientConfig) {\n this.baseUrl = new URL(config.baseUrl);\n this.fetchFn = config.fetch ?? globalThis.fetch;\n }\n\n private buildAndFetch(\n method: HttpMethod,\n path: string,\n options: RequestOptions = {},\n ): Promise<Response> {\n const { body, query, authenticated = true } = options;\n\n const url = new URL(path, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Tenant-Key\": this.config.tenantKey,\n };\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n if (authenticated) {\n const token = this.config.getAccessToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n }\n\n return this.fetchFn(url.toString(), {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n private async throwIfError(response: Response): Promise<void> {\n if (!response.ok) {\n const errorBody = await response.json().catch(() => null);\n throw new ApiError(\n response.status,\n errorBody?.error?.code ?? \"UNKNOWN_ERROR\",\n errorBody?.error?.message ?? response.statusText,\n errorBody?.meta?.requestId,\n );\n }\n }\n\n private async request<T>(\n method: HttpMethod,\n path: string,\n options: InternalRequestOptions = {},\n ): Promise<T> {\n const { isRetry = false, authenticated = true } = options;\n\n const response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && !isRetry && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n return this.request<T>(method, path, { ...options, isRetry: true });\n }\n }\n\n await this.throwIfError(response);\n\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return undefined as T;\n }\n\n const json = await response.json();\n return (json && \"data\" in json && \"meta\" in json ? json.data : json) as T;\n }\n\n private attemptTokenRefresh(): Promise<boolean> {\n if (this.refreshPromise) return this.refreshPromise;\n this.refreshPromise = this.doRefresh().finally(() => {\n this.refreshPromise = null;\n });\n return this.refreshPromise;\n }\n\n private async doRefresh(): Promise<boolean> {\n const refreshToken = this.config.getRefreshToken();\n if (!refreshToken) return false;\n\n try {\n const tokens = await this.request<TokensResponseDto>(\n \"POST\",\n \"/api/v1/auth/refresh\",\n {\n body: { refreshToken },\n authenticated: false,\n isRetry: true,\n },\n );\n await this.config.onTokenRefreshed(tokens);\n return true;\n } catch {\n return false;\n }\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"POST\", path, { ...options, body });\n }\n\n patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PATCH\", path, { ...options, body });\n }\n\n put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PUT\", path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"DELETE\", path, options);\n }\n\n async rawRequest(method: HttpMethod, path: string, options: RequestOptions = {}): Promise<Response> {\n const { authenticated = true } = options;\n\n let response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n response = await this.buildAndFetch(method, path, options);\n }\n }\n\n await this.throwIfError(response);\n\n return response;\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n StartAuthResponseDto,\n} from \"../types\";\n\nexport class AuthResource {\n constructor(private http: HttpClient) {}\n\n register(data: RegisterDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/register\", data, { authenticated: false });\n }\n\n login(data: LoginDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/login\", data, { authenticated: false });\n }\n\n startAuth(data: LoginDto): Promise<StartAuthResponseDto> {\n return this.http.post(\"/api/v1/auth/start\", data, { authenticated: false });\n }\n\n verifyOtp(data: VerifyOtpDto): Promise<AuthResponseDto> {\n return this.http.post(\"/api/v1/auth/verify-otp\", data, { authenticated: false });\n }\n\n refresh(data: RefreshTokenDto): Promise<TokensResponseDto> {\n return this.http.post(\"/api/v1/auth/refresh\", data, { authenticated: false });\n }\n\n logout(): Promise<void> {\n return this.http.post(\"/api/v1/auth/logout\");\n }\n\n getProfile(): Promise<UserResponseDto> {\n return this.http.get(\"/api/v1/auth/me\");\n }\n\n updateProfile(data: UpdateProfileDto): Promise<UserResponseDto> {\n return this.http.patch(\"/api/v1/auth/me\", data);\n }\n\n deleteAccount(): Promise<void> {\n return this.http.delete(\"/api/v1/auth/me\");\n }\n\n requestEmailChange(data: RequestEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/request-email-change\", data);\n }\n\n confirmEmailChange(data: ConfirmEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/confirm-email-change\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PlanResponseDto } from \"../types\";\n\nexport class PlansResource {\n constructor(private http: HttpClient) {}\n\n list(): Promise<PlanResponseDto[]> {\n return this.http.get(\"/api/v1/public/plans\", { authenticated: false });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n CreditTransactionType,\n PurchaseCreditsDto,\n PurchaseCreditsResponseDto,\n} from \"../types\";\n\nexport class CreditsResource {\n constructor(private http: HttpClient) {}\n\n getBalance(): Promise<CreditBalanceResponseDto> {\n return this.http.get(\"/api/v1/credits/balance\");\n }\n\n getTransactions(query?: {\n cursor?: string;\n limit?: number;\n type?: CreditTransactionType;\n }): Promise<CreditTransactionResponseDto[]> {\n return this.http.get(\"/api/v1/credits/transactions\", { query });\n }\n\n purchase(data: PurchaseCreditsDto): Promise<PurchaseCreditsResponseDto> {\n return this.http.post(\"/api/v1/credits/purchase\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { BillingResponseDto, UpsertBillingDto } from \"../types\";\n\nexport class BillingResource {\n constructor(private http: HttpClient) {}\n\n get(): Promise<BillingResponseDto> {\n return this.http.get(\"/api/v1/billing\");\n }\n\n upsert(data: UpsertBillingDto): Promise<BillingResponseDto> {\n return this.http.put(\"/api/v1/billing\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n PreferenceResponseDto,\n UpdatePreferencesDto,\n} from \"../types\";\n\nexport class PreferencesResource {\n constructor(private http: HttpClient) {}\n\n getAll(): Promise<PreferenceResponseDto[]> {\n return this.http.get(\"/api/v1/preferences\");\n }\n\n getByAppKey(appKey: string): Promise<PreferenceResponseDto> {\n return this.http.get(`/api/v1/preferences/${appKey}`);\n }\n\n upsert(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.put(`/api/v1/preferences/${appKey}`, data);\n }\n\n remove(appKey: string): Promise<void> {\n return this.http.delete(`/api/v1/preferences/${appKey}`);\n }\n\n merge(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.patch(`/api/v1/preferences/${appKey}`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateConversationDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n AddMessageDto,\n ConversationStatus,\n} from \"../types\";\n\nexport class ConversationsResource {\n constructor(private http: HttpClient) {}\n\n create(data: CreateConversationDto): Promise<ConversationResponseDto> {\n return this.http.post(\"/api/v1/conversations\", data);\n }\n\n list(query?: {\n cursor?: string;\n limit?: number;\n status?: ConversationStatus;\n appKey?: string;\n }): Promise<ConversationResponseDto[]> {\n return this.http.get(\"/api/v1/conversations\", { query });\n }\n\n get(id: string): Promise<ConversationResponseDto> {\n return this.http.get(`/api/v1/conversations/${id}`);\n }\n\n archive(id: string): Promise<ConversationResponseDto> {\n return this.http.patch(`/api/v1/conversations/${id}/archive`);\n }\n\n listMessages(conversationId: string, query?: {\n cursor?: string;\n limit?: number;\n }): Promise<ConversationMessageResponseDto[]> {\n return this.http.get(`/api/v1/conversations/${conversationId}/messages`, { query });\n }\n\n addMessage(conversationId: string, data: AddMessageDto): Promise<ConversationMessageResponseDto> {\n return this.http.post(`/api/v1/conversations/${conversationId}/messages`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { GenerateDto } from \"../types\";\n\nexport interface GenerationDoneData {\n messageId: string;\n usage?: { inputTokens: number; outputTokens: number };\n structuredOutput?: Record<string, unknown>;\n}\n\nexport interface SseStreamOptions {\n onTextDelta?: (text: string) => void;\n onDone?: (data: GenerationDoneData) => void;\n onError?: (error: string) => void;\n signal?: AbortSignal;\n}\n\ntype SseEvent =\n | { type: \"text_delta\"; text: string }\n | { type: \"done\"; messageId: string; usage?: { inputTokens: number; outputTokens: number }; structuredOutput?: Record<string, unknown> }\n | { type: \"error\"; error: string };\n\nexport class GenerationResource {\n constructor(private http: HttpClient) {}\n\n async generate(conversationId: string, data: GenerateDto, options?: SseStreamOptions): Promise<string> {\n const response = await this.http.rawRequest(\"POST\", `/api/v1/conversations/${conversationId}/generate`, {\n body: data,\n });\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"No response body\");\n\n const decoder = new TextDecoder();\n const parts: string[] = [];\n let buffer = \"\";\n\n try {\n while (true) {\n if (options?.signal?.aborted) {\n reader.cancel();\n break;\n }\n\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const jsonStr = line.slice(6).trim();\n if (!jsonStr) continue;\n\n let event: SseEvent;\n try {\n event = JSON.parse(jsonStr);\n } catch {\n continue;\n }\n\n if (event.type === \"text_delta\") {\n parts.push(event.text);\n options?.onTextDelta?.(event.text);\n } else if (event.type === \"done\") {\n options?.onDone?.(event);\n } else if (event.type === \"error\") {\n options?.onError?.(event.error);\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n\n return parts.join(\"\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n TriggerImageDto,\n ImageStatusResponseDto,\n} from \"../types\";\n\nexport class ImagesResource {\n constructor(private http: HttpClient) {}\n\n trigger(messageId: string, data: TriggerImageDto): Promise<ImageStatusResponseDto> {\n return this.http.post(`/api/v1/messages/${messageId}/images`, data);\n }\n\n getAll(messageId: string): Promise<ImageStatusResponseDto[]> {\n return this.http.get(`/api/v1/messages/${messageId}/images`);\n }\n\n getBySlot(messageId: string, slot: string): Promise<ImageStatusResponseDto> {\n return this.http.get(`/api/v1/messages/${messageId}/images/${slot}`);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n} from \"../types\";\n\nexport class PaymentsResource {\n constructor(private http: HttpClient) {}\n\n checkout(data: CreateCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout\", data);\n }\n\n checkoutCustom(data: CreateCustomCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout/custom\", data);\n }\n\n creditPricing(): Promise<CreditPricingResponseDto> {\n return this.http.get(\"/api/v1/payments/credit-pricing\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { TenantPublicInfoDto } from \"../types\";\n\nexport class TenantsResource {\n constructor(private http: HttpClient) {}\n\n getPublicInfo(tenantId: string): Promise<TenantPublicInfoDto> {\n return this.http.get(\"/api/v1/tenants/public-info\", {\n authenticated: false,\n query: { tenantId },\n });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PaginatedResponse } from \"../types\";\n\nexport class ReceiptsResource {\n constructor(private http: HttpClient) {}\n\n list(query?: { cursor?: string; limit?: number }): Promise<PaginatedResponse> {\n return this.http.get(\"/api/v1/receipts\", { query });\n }\n\n async download(id: string): Promise<Blob> {\n const response = await this.http.rawRequest(\"GET\", `/api/v1/receipts/${id}/download`);\n return response.blob();\n }\n}\n","import { HttpClient } from \"./http\";\nimport type { TokensResponseDto } from \"./types\";\nimport { AuthResource } from \"./resources/auth\";\nimport { PlansResource } from \"./resources/plans\";\nimport { CreditsResource } from \"./resources/credits\";\nimport { BillingResource } from \"./resources/billing\";\nimport { PreferencesResource } from \"./resources/preferences\";\nimport { ConversationsResource } from \"./resources/conversations\";\nimport { GenerationResource } from \"./resources/generation\";\nimport { ImagesResource } from \"./resources/images\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { TenantsResource } from \"./resources/tenants\";\nimport { ReceiptsResource } from \"./resources/receipts\";\n\nexport interface ClientOptions {\n baseUrl: string;\n tenantKey: string;\n accessToken?: string;\n refreshToken?: string;\n onTokenRefreshed?: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AiAssistantsClient {\n auth: AuthResource;\n plans: PlansResource;\n credits: CreditsResource;\n billing: BillingResource;\n preferences: PreferencesResource;\n conversations: ConversationsResource;\n generation: GenerationResource;\n images: ImagesResource;\n payments: PaymentsResource;\n tenants: TenantsResource;\n receipts: ReceiptsResource;\n setAccessToken(token: string): void;\n setRefreshToken(token: string): void;\n}\n\nexport function createClient(options: ClientOptions): AiAssistantsClient {\n let accessToken = options.accessToken ?? null;\n let refreshToken = options.refreshToken ?? null;\n\n const http = new HttpClient({\n baseUrl: options.baseUrl,\n tenantKey: options.tenantKey,\n fetch: options.fetch,\n getAccessToken: () => accessToken,\n getRefreshToken: () => refreshToken,\n onTokenRefreshed: async (tokens) => {\n accessToken = tokens.accessToken;\n refreshToken = tokens.refreshToken;\n await options.onTokenRefreshed?.(tokens);\n },\n });\n\n return {\n auth: new AuthResource(http),\n plans: new PlansResource(http),\n credits: new CreditsResource(http),\n billing: new BillingResource(http),\n preferences: new PreferencesResource(http),\n conversations: new ConversationsResource(http),\n generation: new GenerationResource(http),\n images: new ImagesResource(http),\n payments: new PaymentsResource(http),\n tenants: new TenantsResource(http),\n receipts: new ReceiptsResource(http),\n setAccessToken(token: string) {\n accessToken = token;\n },\n setRefreshToken(token: string) {\n refreshToken = token;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACkB,YACA,MAChB,SACgB,WAChB;AACA,UAAM,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO;AAL3C;AACA;AAEA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACcO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAoB,QAA0B;AAA1B;AAJpB,SAAQ,iBAA0C;AAKhD,SAAK,UAAU,IAAI,IAAI,OAAO,OAAO;AACrC,SAAK,UAAU,OAAO,SAAS,WAAW;AAAA,EAC5C;AAAA,EAEQ,cACN,QACA,MACA,UAA0B,CAAC,GACR;AACnB,UAAM,EAAE,MAAM,OAAO,gBAAgB,KAAK,IAAI;AAE9C,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO;AACtC,QAAI,OAAO;AACT,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,UAAU,UAAa,UAAU,MAAM;AACzC,cAAI,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,UAAM,UAA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AAM;AAAA,IACzC;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,MAAM,IAAI,aAAa,IAAI;AAAA,IAC3B,OAAO,IAAI,cAAc,IAAI;AAAA,IAC7B,SAAS,IAAI,gBAAgB,IAAI;AAAA,IACjC,SAAS,IAAI,gBAAgB,IAAI;AAAA,IACjC,aAAa,IAAI,oBAAoB,IAAI;AAAA,IACzC,eAAe,IAAI,sBAAsB,IAAI;AAAA,IAC7C,YAAY,IAAI,mBAAmB,IAAI;AAAA,IACvC,QAAQ,IAAI,eAAe,IAAI;AAAA,IAC/B,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,SAAS,IAAI,gBAAgB,IAAI;AAAA,IACjC,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,eAAe,OAAe;AAC5B,oBAAc;AAAA,IAChB;AAAA,IACA,gBAAgB,OAAe;AAC7B,qBAAe;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/auth.ts","../src/resources/plans.ts","../src/resources/credits.ts","../src/resources/billing.ts","../src/resources/preferences.ts","../src/resources/conversations.ts","../src/resources/generation.ts","../src/resources/images.ts","../src/resources/payments.ts","../src/resources/tenants.ts","../src/resources/receipts.ts","../src/client.ts"],"sourcesContent":["export { createClient } from \"./client\";\nexport type { ClientOptions, AiAssistantsClient } from \"./client\";\n\nexport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n PurchaseCreditsDto,\n UpsertBillingDto,\n UpdatePreferencesDto,\n CreateConversationDto,\n AddMessageDto,\n GenerateDto,\n TriggerImageDto,\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n PlanResponseDto,\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n PurchaseCreditsResponseDto,\n CreditBalanceEntityResponseDto,\n BillingResponseDto,\n PreferenceResponseDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n ImageStatusResponseDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n TenantPublicInfoDto,\n PingResponseDto,\n StartAuthResponseDto,\n PaginatedResponse,\n\n OtpType,\n UserRole,\n PlanType,\n CreditTransactionType,\n ConversationStatus,\n MessageRole,\n ImageGenerationStatus,\n} from \"./types\";\n\nexport type { SseStreamOptions, GenerationDoneData } from \"./resources/generation\";\n\nexport { ApiError } from \"./errors\";\n","export class ApiError extends Error {\n constructor(\n public readonly statusCode: number,\n public readonly code: string,\n message: string | string[],\n public readonly requestId?: string,\n ) {\n super(Array.isArray(message) ? message.join(\", \") : message);\n this.name = \"ApiError\";\n }\n}\n","import { ApiError } from \"./errors\";\nimport type { TokensResponseDto } from \"./types\";\n\nexport interface HttpClientConfig {\n baseUrl: string;\n tenantKey: string;\n getAccessToken: () => string | null;\n getRefreshToken: () => string | null;\n onTokenRefreshed: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\ntype HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ninterface RequestOptions {\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined | null>;\n authenticated?: boolean;\n}\n\ninterface InternalRequestOptions extends RequestOptions {\n isRetry?: boolean;\n}\n\nexport class HttpClient {\n private refreshPromise: Promise<boolean> | null = null;\n private readonly baseUrl: URL;\n private readonly fetchFn: typeof globalThis.fetch;\n\n constructor(private config: HttpClientConfig) {\n this.baseUrl = new URL(config.baseUrl);\n this.fetchFn = config.fetch ?? globalThis.fetch;\n }\n\n private buildAndFetch(\n method: HttpMethod,\n path: string,\n options: RequestOptions = {},\n ): Promise<Response> {\n const { body, query, authenticated = true } = options;\n\n const url = new URL(path, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Tenant-Key\": this.config.tenantKey,\n };\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n if (authenticated) {\n const token = this.config.getAccessToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n }\n\n return this.fetchFn(url.toString(), {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n private async throwIfError(response: Response): Promise<void> {\n if (!response.ok) {\n const errorBody = await response.json().catch(() => null);\n throw new ApiError(\n response.status,\n errorBody?.error?.code ?? \"UNKNOWN_ERROR\",\n errorBody?.error?.message ?? response.statusText,\n errorBody?.meta?.requestId,\n );\n }\n }\n\n private async request<T>(\n method: HttpMethod,\n path: string,\n options: InternalRequestOptions = {},\n ): Promise<T> {\n const { isRetry = false, authenticated = true } = options;\n\n const response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && !isRetry && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n return this.request<T>(method, path, { ...options, isRetry: true });\n }\n }\n\n await this.throwIfError(response);\n\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return undefined as T;\n }\n\n const json = await response.json();\n return (json && \"data\" in json && \"meta\" in json ? json.data : json) as T;\n }\n\n private attemptTokenRefresh(): Promise<boolean> {\n if (this.refreshPromise) return this.refreshPromise;\n this.refreshPromise = this.doRefresh().finally(() => {\n this.refreshPromise = null;\n });\n return this.refreshPromise;\n }\n\n private async doRefresh(): Promise<boolean> {\n const refreshToken = this.config.getRefreshToken();\n if (!refreshToken) return false;\n\n try {\n const tokens = await this.request<TokensResponseDto>(\n \"POST\",\n \"/api/v1/auth/refresh\",\n {\n body: { refreshToken },\n authenticated: false,\n isRetry: true,\n },\n );\n await this.config.onTokenRefreshed(tokens);\n return true;\n } catch {\n return false;\n }\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"POST\", path, { ...options, body });\n }\n\n patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PATCH\", path, { ...options, body });\n }\n\n put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PUT\", path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"DELETE\", path, options);\n }\n\n async rawRequest(method: HttpMethod, path: string, options: RequestOptions = {}): Promise<Response> {\n const { authenticated = true } = options;\n\n let response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n response = await this.buildAndFetch(method, path, options);\n }\n }\n\n await this.throwIfError(response);\n\n return response;\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n StartAuthResponseDto,\n} from \"../types\";\n\nexport class AuthResource {\n constructor(private http: HttpClient) {}\n\n register(data: RegisterDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/register\", data, { authenticated: false });\n }\n\n login(data: LoginDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/login\", data, { authenticated: false });\n }\n\n startAuth(data: LoginDto): Promise<StartAuthResponseDto> {\n return this.http.post(\"/api/v1/auth/start\", data, { authenticated: false });\n }\n\n verifyOtp(data: VerifyOtpDto): Promise<AuthResponseDto> {\n return this.http.post(\"/api/v1/auth/verify-otp\", data, { authenticated: false });\n }\n\n refresh(data: RefreshTokenDto): Promise<TokensResponseDto> {\n return this.http.post(\"/api/v1/auth/refresh\", data, { authenticated: false });\n }\n\n logout(): Promise<void> {\n return this.http.post(\"/api/v1/auth/logout\");\n }\n\n getProfile(): Promise<UserResponseDto> {\n return this.http.get(\"/api/v1/auth/me\");\n }\n\n updateProfile(data: UpdateProfileDto): Promise<UserResponseDto> {\n return this.http.patch(\"/api/v1/auth/me\", data);\n }\n\n deleteAccount(): Promise<void> {\n return this.http.delete(\"/api/v1/auth/me\");\n }\n\n requestEmailChange(data: RequestEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/request-email-change\", data);\n }\n\n confirmEmailChange(data: ConfirmEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/confirm-email-change\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PlanResponseDto } from \"../types\";\n\nexport class PlansResource {\n constructor(private http: HttpClient) {}\n\n list(): Promise<PlanResponseDto[]> {\n return this.http.get(\"/api/v1/public/plans\", { authenticated: false });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n CreditTransactionType,\n PurchaseCreditsDto,\n PurchaseCreditsResponseDto,\n} from \"../types\";\n\nexport class CreditsResource {\n constructor(private http: HttpClient) {}\n\n getBalance(): Promise<CreditBalanceResponseDto> {\n return this.http.get(\"/api/v1/credits/balance\");\n }\n\n getTransactions(query?: {\n cursor?: string;\n limit?: number;\n type?: CreditTransactionType;\n }): Promise<CreditTransactionResponseDto[]> {\n return this.http.get(\"/api/v1/credits/transactions\", { query });\n }\n\n purchase(data: PurchaseCreditsDto): Promise<PurchaseCreditsResponseDto> {\n return this.http.post(\"/api/v1/credits/purchase\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { BillingResponseDto, UpsertBillingDto } from \"../types\";\n\nexport class BillingResource {\n constructor(private http: HttpClient) {}\n\n get(): Promise<BillingResponseDto> {\n return this.http.get(\"/api/v1/billing\");\n }\n\n upsert(data: UpsertBillingDto): Promise<BillingResponseDto> {\n return this.http.put(\"/api/v1/billing\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n PreferenceResponseDto,\n UpdatePreferencesDto,\n} from \"../types\";\n\nexport class PreferencesResource {\n constructor(private http: HttpClient) {}\n\n getAll(): Promise<PreferenceResponseDto[]> {\n return this.http.get(\"/api/v1/preferences\");\n }\n\n getByAppKey(appKey: string): Promise<PreferenceResponseDto> {\n return this.http.get(`/api/v1/preferences/${appKey}`);\n }\n\n upsert(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.put(`/api/v1/preferences/${appKey}`, data);\n }\n\n remove(appKey: string): Promise<void> {\n return this.http.delete(`/api/v1/preferences/${appKey}`);\n }\n\n merge(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.patch(`/api/v1/preferences/${appKey}`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateConversationDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n AddMessageDto,\n ConversationStatus,\n} from \"../types\";\n\nexport class ConversationsResource {\n constructor(private http: HttpClient) {}\n\n create(data: CreateConversationDto): Promise<ConversationResponseDto> {\n return this.http.post(\"/api/v1/conversations\", data);\n }\n\n list(query?: {\n cursor?: string;\n limit?: number;\n status?: ConversationStatus;\n appKey?: string;\n }): Promise<ConversationResponseDto[]> {\n return this.http.get(\"/api/v1/conversations\", { query });\n }\n\n get(id: string): Promise<ConversationResponseDto> {\n return this.http.get(`/api/v1/conversations/${id}`);\n }\n\n archive(id: string): Promise<ConversationResponseDto> {\n return this.http.patch(`/api/v1/conversations/${id}/archive`);\n }\n\n listMessages(conversationId: string, query?: {\n cursor?: string;\n limit?: number;\n }): Promise<ConversationMessageResponseDto[]> {\n return this.http.get(`/api/v1/conversations/${conversationId}/messages`, { query });\n }\n\n addMessage(conversationId: string, data: AddMessageDto): Promise<ConversationMessageResponseDto> {\n return this.http.post(`/api/v1/conversations/${conversationId}/messages`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { GenerateDto } from \"../types\";\n\nexport interface GenerationDoneData {\n messageId: string;\n usage?: { inputTokens: number; outputTokens: number };\n structuredOutput?: Record<string, unknown>;\n}\n\nexport interface SseStreamOptions {\n onTextDelta?: (text: string) => void;\n onDone?: (data: GenerationDoneData) => void;\n onError?: (error: string) => void;\n signal?: AbortSignal;\n}\n\ntype SseEvent =\n | { type: \"text_delta\"; text: string }\n | { type: \"done\"; messageId: string; usage?: { inputTokens: number; outputTokens: number }; structuredOutput?: Record<string, unknown> }\n | { type: \"error\"; error: string };\n\nexport class GenerationResource {\n constructor(private http: HttpClient) {}\n\n async generate(conversationId: string, data: GenerateDto, options?: SseStreamOptions): Promise<string> {\n const response = await this.http.rawRequest(\"POST\", `/api/v1/conversations/${conversationId}/generate`, {\n body: data,\n });\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"No response body\");\n\n const decoder = new TextDecoder();\n const parts: string[] = [];\n let buffer = \"\";\n\n try {\n while (true) {\n if (options?.signal?.aborted) {\n reader.cancel();\n break;\n }\n\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const jsonStr = line.slice(6).trim();\n if (!jsonStr) continue;\n\n let event: SseEvent;\n try {\n event = JSON.parse(jsonStr);\n } catch {\n continue;\n }\n\n if (event.type === \"text_delta\") {\n parts.push(event.text);\n options?.onTextDelta?.(event.text);\n } else if (event.type === \"done\") {\n options?.onDone?.(event);\n } else if (event.type === \"error\") {\n options?.onError?.(event.error);\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n\n return parts.join(\"\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n TriggerImageDto,\n ImageStatusResponseDto,\n} from \"../types\";\n\nexport class ImagesResource {\n constructor(private http: HttpClient) {}\n\n trigger(messageId: string, data: TriggerImageDto): Promise<ImageStatusResponseDto> {\n return this.http.post(`/api/v1/messages/${messageId}/images`, data);\n }\n\n getAll(messageId: string): Promise<ImageStatusResponseDto[]> {\n return this.http.get(`/api/v1/messages/${messageId}/images`);\n }\n\n getBySlot(messageId: string, slot: string): Promise<ImageStatusResponseDto> {\n return this.http.get(`/api/v1/messages/${messageId}/images/${slot}`);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n} from \"../types\";\n\nexport class PaymentsResource {\n constructor(private http: HttpClient) {}\n\n checkout(data: CreateCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout\", data);\n }\n\n checkoutCustom(data: CreateCustomCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout/custom\", data);\n }\n\n creditPricing(): Promise<CreditPricingResponseDto> {\n return this.http.get(\"/api/v1/payments/credit-pricing\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { TenantPublicInfoDto } from \"../types\";\n\nexport class TenantsResource {\n constructor(private http: HttpClient) {}\n\n getPublicInfo(tenantId: string): Promise<TenantPublicInfoDto> {\n return this.http.get(\"/api/v1/tenants/public-info\", {\n authenticated: false,\n query: { tenantId },\n });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PaginatedResponse } from \"../types\";\n\nexport class ReceiptsResource {\n constructor(private http: HttpClient) {}\n\n list(query?: { cursor?: string; limit?: number }): Promise<PaginatedResponse> {\n return this.http.get(\"/api/v1/receipts\", { query });\n }\n\n async download(id: string): Promise<Blob> {\n const response = await this.http.rawRequest(\"GET\", `/api/v1/receipts/${id}/download`);\n return response.blob();\n }\n}\n","import { HttpClient } from \"./http\";\nimport type { TokensResponseDto, PingResponseDto } from \"./types\";\nimport { AuthResource } from \"./resources/auth\";\nimport { PlansResource } from \"./resources/plans\";\nimport { CreditsResource } from \"./resources/credits\";\nimport { BillingResource } from \"./resources/billing\";\nimport { PreferencesResource } from \"./resources/preferences\";\nimport { ConversationsResource } from \"./resources/conversations\";\nimport { GenerationResource } from \"./resources/generation\";\nimport { ImagesResource } from \"./resources/images\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { TenantsResource } from \"./resources/tenants\";\nimport { ReceiptsResource } from \"./resources/receipts\";\n\nexport interface ClientOptions {\n baseUrl: string;\n tenantKey: string;\n accessToken?: string;\n refreshToken?: string;\n onTokenRefreshed?: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AiAssistantsClient {\n auth: AuthResource;\n plans: PlansResource;\n credits: CreditsResource;\n billing: BillingResource;\n preferences: PreferencesResource;\n conversations: ConversationsResource;\n generation: GenerationResource;\n images: ImagesResource;\n payments: PaymentsResource;\n tenants: TenantsResource;\n receipts: ReceiptsResource;\n /**\n * Verify the client is configured correctly: confirms the base URL is\n * reachable and the tenant key is valid. Resolves with the tenant identity\n * when the SDK is ready to use, and rejects with an {@link ApiError} otherwise.\n */\n ping(): Promise<PingResponseDto>;\n setAccessToken(token: string): void;\n setRefreshToken(token: string): void;\n}\n\nexport function createClient(options: ClientOptions): AiAssistantsClient {\n let accessToken = options.accessToken ?? null;\n let refreshToken = options.refreshToken ?? null;\n\n const http = new HttpClient({\n baseUrl: options.baseUrl,\n tenantKey: options.tenantKey,\n fetch: options.fetch,\n getAccessToken: () => accessToken,\n getRefreshToken: () => refreshToken,\n onTokenRefreshed: async (tokens) => {\n accessToken = tokens.accessToken;\n refreshToken = tokens.refreshToken;\n await options.onTokenRefreshed?.(tokens);\n },\n });\n\n return {\n auth: new AuthResource(http),\n plans: new PlansResource(http),\n credits: new CreditsResource(http),\n billing: new BillingResource(http),\n preferences: new PreferencesResource(http),\n conversations: new ConversationsResource(http),\n generation: new GenerationResource(http),\n images: new ImagesResource(http),\n payments: new PaymentsResource(http),\n tenants: new TenantsResource(http),\n receipts: new ReceiptsResource(http),\n ping() {\n return http.get<PingResponseDto>(\"/api/v1/ping\", { authenticated: false });\n },\n setAccessToken(token: string) {\n accessToken = token;\n },\n setRefreshToken(token: string) {\n refreshToken = token;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACkB,YACA,MAChB,SACgB,WAChB;AACA,UAAM,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO;AAL3C;AACA;AAEA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACcO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAoB,QAA0B;AAA1B;AAJpB,SAAQ,iBAA0C;AAKhD,SAAK,UAAU,IAAI,IAAI,OAAO,OAAO;AACrC,SAAK,UAAU,OAAO,SAAS,WAAW;AAAA,EAC5C;AAAA,EAEQ,cACN,QACA,MACA,UAA0B,CAAC,GACR;AACnB,UAAM,EAAE,MAAM,OAAO,gBAAgB,KAAK,IAAI;AAE9C,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO;AACtC,QAAI,OAAO;AACT,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,UAAU,UAAa,UAAU,MAAM;AACzC,cAAI,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,UAAM,UAAkC;AAAA,MACtC,gBAAgB,KAAK,OAAO;AAAA,IAC9B;AACA,QAAI,SAAS,QAAW;AACtB,cAAQ,cAAc,IAAI;AAAA,IAC5B;AACA,QAAI,eAAe;AACjB,YAAM,QAAQ,KAAK,OAAO,eAAe;AACzC,UAAI,OAAO;AACT,gBAAQ,eAAe,IAAI,UAAU,KAAK;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO,KAAK,QAAQ,IAAI,SAAS,GAAG;AAAA,MAClC;AAAA,MACA;AA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AAA,IACvC,QAAQ,IAAI,eAAe,IAAI;AAAA,IAC/B,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,SAAS,IAAI,gBAAgB,IAAI;AAAA,IACjC,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,OAAO;AACL,aAAO,KAAK,IAAqB,gBAAgB,EAAE,eAAe,MAAM,CAAC;AAAA,IAC3E;AAAA,IACA,eAAe,OAAe;AAC5B,oBAAc;AAAA,IAChB;AAAA,IACA,gBAAgB,OAAe;AAC7B,qBAAe;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
package/dist/index.d.cts CHANGED
@@ -7,6 +7,19 @@ interface components {
7
7
  publicApiKey: string;
8
8
  frontendUrl: string;
9
9
  };
10
+ PingResponseDto: {
11
+ /**
12
+ * @description Always "ok" when credentials are valid
13
+ * @example ok
14
+ */
15
+ status: string;
16
+ /** @description Resolved tenant ID for the provided API key */
17
+ tenantId: string;
18
+ /** @description Resolved tenant name for the provided API key */
19
+ tenantName: string;
20
+ /** @description Server timestamp (ISO 8601) */
21
+ timestamp: string;
22
+ };
10
23
  RegisterDto: {
11
24
  /** @example user@example.com */
12
25
  email: string;
@@ -288,6 +301,11 @@ interface components {
288
301
  metadata: Record<string, never>;
289
302
  tokenCount?: Record<string, never> | null;
290
303
  };
304
+ PaginatedResponse: {
305
+ hasMore: boolean;
306
+ nextCursor: string | null;
307
+ total?: number;
308
+ };
291
309
  GenerateDto: {
292
310
  content: string;
293
311
  /** @default false */
@@ -361,11 +379,17 @@ interface components {
361
379
  /** @example https://app.example.com/payment/cancel */
362
380
  cancelUrl: string;
363
381
  };
364
- PaginatedResponse: {
365
- data: unknown[][];
366
- hasMore: boolean;
367
- nextCursor: string | null;
368
- total?: number;
382
+ ReceiptItemDto: {
383
+ id: string;
384
+ receiptNumber: string;
385
+ paymentId: string;
386
+ amountCents: number;
387
+ currency: string;
388
+ credits: number;
389
+ /** Format: date-time */
390
+ issuedAt: string;
391
+ /** Format: date-time */
392
+ createdAt: string;
369
393
  };
370
394
  };
371
395
  responses: never;
@@ -414,6 +438,7 @@ type ImageStatusResponseDto = components["schemas"]["ImageStatusResponseDto"];
414
438
  type CheckoutResponseDto = components["schemas"]["CheckoutResponseDto"];
415
439
  type CreditPricingResponseDto = components["schemas"]["CreditPricingResponseDto"];
416
440
  type TenantPublicInfoDto = components["schemas"]["TenantPublicInfoDto"];
441
+ type PingResponseDto = components["schemas"]["PingResponseDto"];
417
442
  type PaginatedResponse = components["schemas"]["PaginatedResponse"];
418
443
  type OtpType = components["schemas"]["OtpType"];
419
444
  type UserRole = components["schemas"]["UserRole"];
@@ -598,6 +623,12 @@ interface AiAssistantsClient {
598
623
  payments: PaymentsResource;
599
624
  tenants: TenantsResource;
600
625
  receipts: ReceiptsResource;
626
+ /**
627
+ * Verify the client is configured correctly: confirms the base URL is
628
+ * reachable and the tenant key is valid. Resolves with the tenant identity
629
+ * when the SDK is ready to use, and rejects with an {@link ApiError} otherwise.
630
+ */
631
+ ping(): Promise<PingResponseDto>;
601
632
  setAccessToken(token: string): void;
602
633
  setRefreshToken(token: string): void;
603
634
  }
@@ -610,4 +641,4 @@ declare class ApiError extends Error {
610
641
  constructor(statusCode: number, code: string, message: string | string[], requestId?: string | undefined);
611
642
  }
612
643
 
613
- export { type AddMessageDto, type AiAssistantsClient, ApiError, type AuthResponseDto, type BillingResponseDto, type CheckoutResponseDto, type ClientOptions, type ConfirmEmailChangeDto, type ConversationMessageResponseDto, type ConversationResponseDto, type ConversationStatus, type CreateCheckoutDto, type CreateConversationDto, type CreateCustomCheckoutDto, type CreditBalanceEntityResponseDto, type CreditBalanceResponseDto, type CreditPricingResponseDto, type CreditTransactionResponseDto, type CreditTransactionType, type GenerateDto, type GenerationDoneData, type ImageGenerationStatus, type ImageStatusResponseDto, type LoginDto, type MessageResponseDto, type MessageRole, type OtpType, type PaginatedResponse, type PlanResponseDto, type PlanType, type PreferenceResponseDto, type PurchaseCreditsDto, type PurchaseCreditsResponseDto, type RefreshTokenDto, type RegisterDto, type RequestEmailChangeDto, type SseStreamOptions, type StartAuthResponseDto, type TenantPublicInfoDto, type TokensResponseDto, type TriggerImageDto, type UpdatePreferencesDto, type UpdateProfileDto, type UpsertBillingDto, type UserResponseDto, type UserRole, type VerifyOtpDto, createClient };
644
+ export { type AddMessageDto, type AiAssistantsClient, ApiError, type AuthResponseDto, type BillingResponseDto, type CheckoutResponseDto, type ClientOptions, type ConfirmEmailChangeDto, type ConversationMessageResponseDto, type ConversationResponseDto, type ConversationStatus, type CreateCheckoutDto, type CreateConversationDto, type CreateCustomCheckoutDto, type CreditBalanceEntityResponseDto, type CreditBalanceResponseDto, type CreditPricingResponseDto, type CreditTransactionResponseDto, type CreditTransactionType, type GenerateDto, type GenerationDoneData, type ImageGenerationStatus, type ImageStatusResponseDto, type LoginDto, type MessageResponseDto, type MessageRole, type OtpType, type PaginatedResponse, type PingResponseDto, type PlanResponseDto, type PlanType, type PreferenceResponseDto, type PurchaseCreditsDto, type PurchaseCreditsResponseDto, type RefreshTokenDto, type RegisterDto, type RequestEmailChangeDto, type SseStreamOptions, type StartAuthResponseDto, type TenantPublicInfoDto, type TokensResponseDto, type TriggerImageDto, type UpdatePreferencesDto, type UpdateProfileDto, type UpsertBillingDto, type UserResponseDto, type UserRole, type VerifyOtpDto, createClient };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,19 @@ interface components {
7
7
  publicApiKey: string;
8
8
  frontendUrl: string;
9
9
  };
10
+ PingResponseDto: {
11
+ /**
12
+ * @description Always "ok" when credentials are valid
13
+ * @example ok
14
+ */
15
+ status: string;
16
+ /** @description Resolved tenant ID for the provided API key */
17
+ tenantId: string;
18
+ /** @description Resolved tenant name for the provided API key */
19
+ tenantName: string;
20
+ /** @description Server timestamp (ISO 8601) */
21
+ timestamp: string;
22
+ };
10
23
  RegisterDto: {
11
24
  /** @example user@example.com */
12
25
  email: string;
@@ -288,6 +301,11 @@ interface components {
288
301
  metadata: Record<string, never>;
289
302
  tokenCount?: Record<string, never> | null;
290
303
  };
304
+ PaginatedResponse: {
305
+ hasMore: boolean;
306
+ nextCursor: string | null;
307
+ total?: number;
308
+ };
291
309
  GenerateDto: {
292
310
  content: string;
293
311
  /** @default false */
@@ -361,11 +379,17 @@ interface components {
361
379
  /** @example https://app.example.com/payment/cancel */
362
380
  cancelUrl: string;
363
381
  };
364
- PaginatedResponse: {
365
- data: unknown[][];
366
- hasMore: boolean;
367
- nextCursor: string | null;
368
- total?: number;
382
+ ReceiptItemDto: {
383
+ id: string;
384
+ receiptNumber: string;
385
+ paymentId: string;
386
+ amountCents: number;
387
+ currency: string;
388
+ credits: number;
389
+ /** Format: date-time */
390
+ issuedAt: string;
391
+ /** Format: date-time */
392
+ createdAt: string;
369
393
  };
370
394
  };
371
395
  responses: never;
@@ -414,6 +438,7 @@ type ImageStatusResponseDto = components["schemas"]["ImageStatusResponseDto"];
414
438
  type CheckoutResponseDto = components["schemas"]["CheckoutResponseDto"];
415
439
  type CreditPricingResponseDto = components["schemas"]["CreditPricingResponseDto"];
416
440
  type TenantPublicInfoDto = components["schemas"]["TenantPublicInfoDto"];
441
+ type PingResponseDto = components["schemas"]["PingResponseDto"];
417
442
  type PaginatedResponse = components["schemas"]["PaginatedResponse"];
418
443
  type OtpType = components["schemas"]["OtpType"];
419
444
  type UserRole = components["schemas"]["UserRole"];
@@ -598,6 +623,12 @@ interface AiAssistantsClient {
598
623
  payments: PaymentsResource;
599
624
  tenants: TenantsResource;
600
625
  receipts: ReceiptsResource;
626
+ /**
627
+ * Verify the client is configured correctly: confirms the base URL is
628
+ * reachable and the tenant key is valid. Resolves with the tenant identity
629
+ * when the SDK is ready to use, and rejects with an {@link ApiError} otherwise.
630
+ */
631
+ ping(): Promise<PingResponseDto>;
601
632
  setAccessToken(token: string): void;
602
633
  setRefreshToken(token: string): void;
603
634
  }
@@ -610,4 +641,4 @@ declare class ApiError extends Error {
610
641
  constructor(statusCode: number, code: string, message: string | string[], requestId?: string | undefined);
611
642
  }
612
643
 
613
- export { type AddMessageDto, type AiAssistantsClient, ApiError, type AuthResponseDto, type BillingResponseDto, type CheckoutResponseDto, type ClientOptions, type ConfirmEmailChangeDto, type ConversationMessageResponseDto, type ConversationResponseDto, type ConversationStatus, type CreateCheckoutDto, type CreateConversationDto, type CreateCustomCheckoutDto, type CreditBalanceEntityResponseDto, type CreditBalanceResponseDto, type CreditPricingResponseDto, type CreditTransactionResponseDto, type CreditTransactionType, type GenerateDto, type GenerationDoneData, type ImageGenerationStatus, type ImageStatusResponseDto, type LoginDto, type MessageResponseDto, type MessageRole, type OtpType, type PaginatedResponse, type PlanResponseDto, type PlanType, type PreferenceResponseDto, type PurchaseCreditsDto, type PurchaseCreditsResponseDto, type RefreshTokenDto, type RegisterDto, type RequestEmailChangeDto, type SseStreamOptions, type StartAuthResponseDto, type TenantPublicInfoDto, type TokensResponseDto, type TriggerImageDto, type UpdatePreferencesDto, type UpdateProfileDto, type UpsertBillingDto, type UserResponseDto, type UserRole, type VerifyOtpDto, createClient };
644
+ export { type AddMessageDto, type AiAssistantsClient, ApiError, type AuthResponseDto, type BillingResponseDto, type CheckoutResponseDto, type ClientOptions, type ConfirmEmailChangeDto, type ConversationMessageResponseDto, type ConversationResponseDto, type ConversationStatus, type CreateCheckoutDto, type CreateConversationDto, type CreateCustomCheckoutDto, type CreditBalanceEntityResponseDto, type CreditBalanceResponseDto, type CreditPricingResponseDto, type CreditTransactionResponseDto, type CreditTransactionType, type GenerateDto, type GenerationDoneData, type ImageGenerationStatus, type ImageStatusResponseDto, type LoginDto, type MessageResponseDto, type MessageRole, type OtpType, type PaginatedResponse, type PingResponseDto, type PlanResponseDto, type PlanType, type PreferenceResponseDto, type PurchaseCreditsDto, type PurchaseCreditsResponseDto, type RefreshTokenDto, type RegisterDto, type RequestEmailChangeDto, type SseStreamOptions, type StartAuthResponseDto, type TenantPublicInfoDto, type TokensResponseDto, type TriggerImageDto, type UpdatePreferencesDto, type UpdateProfileDto, type UpsertBillingDto, type UserResponseDto, type UserRole, type VerifyOtpDto, createClient };
package/dist/index.js CHANGED
@@ -393,6 +393,9 @@ function createClient(options) {
393
393
  payments: new PaymentsResource(http),
394
394
  tenants: new TenantsResource(http),
395
395
  receipts: new ReceiptsResource(http),
396
+ ping() {
397
+ return http.get("/api/v1/ping", { authenticated: false });
398
+ },
396
399
  setAccessToken(token) {
397
400
  accessToken = token;
398
401
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/auth.ts","../src/resources/plans.ts","../src/resources/credits.ts","../src/resources/billing.ts","../src/resources/preferences.ts","../src/resources/conversations.ts","../src/resources/generation.ts","../src/resources/images.ts","../src/resources/payments.ts","../src/resources/tenants.ts","../src/resources/receipts.ts","../src/client.ts"],"sourcesContent":["export class ApiError extends Error {\n constructor(\n public readonly statusCode: number,\n public readonly code: string,\n message: string | string[],\n public readonly requestId?: string,\n ) {\n super(Array.isArray(message) ? message.join(\", \") : message);\n this.name = \"ApiError\";\n }\n}\n","import { ApiError } from \"./errors\";\nimport type { TokensResponseDto } from \"./types\";\n\nexport interface HttpClientConfig {\n baseUrl: string;\n tenantKey: string;\n getAccessToken: () => string | null;\n getRefreshToken: () => string | null;\n onTokenRefreshed: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\ntype HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ninterface RequestOptions {\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined | null>;\n authenticated?: boolean;\n}\n\ninterface InternalRequestOptions extends RequestOptions {\n isRetry?: boolean;\n}\n\nexport class HttpClient {\n private refreshPromise: Promise<boolean> | null = null;\n private readonly baseUrl: URL;\n private readonly fetchFn: typeof globalThis.fetch;\n\n constructor(private config: HttpClientConfig) {\n this.baseUrl = new URL(config.baseUrl);\n this.fetchFn = config.fetch ?? globalThis.fetch;\n }\n\n private buildAndFetch(\n method: HttpMethod,\n path: string,\n options: RequestOptions = {},\n ): Promise<Response> {\n const { body, query, authenticated = true } = options;\n\n const url = new URL(path, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Tenant-Key\": this.config.tenantKey,\n };\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n if (authenticated) {\n const token = this.config.getAccessToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n }\n\n return this.fetchFn(url.toString(), {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n private async throwIfError(response: Response): Promise<void> {\n if (!response.ok) {\n const errorBody = await response.json().catch(() => null);\n throw new ApiError(\n response.status,\n errorBody?.error?.code ?? \"UNKNOWN_ERROR\",\n errorBody?.error?.message ?? response.statusText,\n errorBody?.meta?.requestId,\n );\n }\n }\n\n private async request<T>(\n method: HttpMethod,\n path: string,\n options: InternalRequestOptions = {},\n ): Promise<T> {\n const { isRetry = false, authenticated = true } = options;\n\n const response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && !isRetry && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n return this.request<T>(method, path, { ...options, isRetry: true });\n }\n }\n\n await this.throwIfError(response);\n\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return undefined as T;\n }\n\n const json = await response.json();\n return (json && \"data\" in json && \"meta\" in json ? json.data : json) as T;\n }\n\n private attemptTokenRefresh(): Promise<boolean> {\n if (this.refreshPromise) return this.refreshPromise;\n this.refreshPromise = this.doRefresh().finally(() => {\n this.refreshPromise = null;\n });\n return this.refreshPromise;\n }\n\n private async doRefresh(): Promise<boolean> {\n const refreshToken = this.config.getRefreshToken();\n if (!refreshToken) return false;\n\n try {\n const tokens = await this.request<TokensResponseDto>(\n \"POST\",\n \"/api/v1/auth/refresh\",\n {\n body: { refreshToken },\n authenticated: false,\n isRetry: true,\n },\n );\n await this.config.onTokenRefreshed(tokens);\n return true;\n } catch {\n return false;\n }\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"POST\", path, { ...options, body });\n }\n\n patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PATCH\", path, { ...options, body });\n }\n\n put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PUT\", path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"DELETE\", path, options);\n }\n\n async rawRequest(method: HttpMethod, path: string, options: RequestOptions = {}): Promise<Response> {\n const { authenticated = true } = options;\n\n let response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n response = await this.buildAndFetch(method, path, options);\n }\n }\n\n await this.throwIfError(response);\n\n return response;\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n StartAuthResponseDto,\n} from \"../types\";\n\nexport class AuthResource {\n constructor(private http: HttpClient) {}\n\n register(data: RegisterDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/register\", data, { authenticated: false });\n }\n\n login(data: LoginDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/login\", data, { authenticated: false });\n }\n\n startAuth(data: LoginDto): Promise<StartAuthResponseDto> {\n return this.http.post(\"/api/v1/auth/start\", data, { authenticated: false });\n }\n\n verifyOtp(data: VerifyOtpDto): Promise<AuthResponseDto> {\n return this.http.post(\"/api/v1/auth/verify-otp\", data, { authenticated: false });\n }\n\n refresh(data: RefreshTokenDto): Promise<TokensResponseDto> {\n return this.http.post(\"/api/v1/auth/refresh\", data, { authenticated: false });\n }\n\n logout(): Promise<void> {\n return this.http.post(\"/api/v1/auth/logout\");\n }\n\n getProfile(): Promise<UserResponseDto> {\n return this.http.get(\"/api/v1/auth/me\");\n }\n\n updateProfile(data: UpdateProfileDto): Promise<UserResponseDto> {\n return this.http.patch(\"/api/v1/auth/me\", data);\n }\n\n deleteAccount(): Promise<void> {\n return this.http.delete(\"/api/v1/auth/me\");\n }\n\n requestEmailChange(data: RequestEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/request-email-change\", data);\n }\n\n confirmEmailChange(data: ConfirmEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/confirm-email-change\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PlanResponseDto } from \"../types\";\n\nexport class PlansResource {\n constructor(private http: HttpClient) {}\n\n list(): Promise<PlanResponseDto[]> {\n return this.http.get(\"/api/v1/public/plans\", { authenticated: false });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n CreditTransactionType,\n PurchaseCreditsDto,\n PurchaseCreditsResponseDto,\n} from \"../types\";\n\nexport class CreditsResource {\n constructor(private http: HttpClient) {}\n\n getBalance(): Promise<CreditBalanceResponseDto> {\n return this.http.get(\"/api/v1/credits/balance\");\n }\n\n getTransactions(query?: {\n cursor?: string;\n limit?: number;\n type?: CreditTransactionType;\n }): Promise<CreditTransactionResponseDto[]> {\n return this.http.get(\"/api/v1/credits/transactions\", { query });\n }\n\n purchase(data: PurchaseCreditsDto): Promise<PurchaseCreditsResponseDto> {\n return this.http.post(\"/api/v1/credits/purchase\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { BillingResponseDto, UpsertBillingDto } from \"../types\";\n\nexport class BillingResource {\n constructor(private http: HttpClient) {}\n\n get(): Promise<BillingResponseDto> {\n return this.http.get(\"/api/v1/billing\");\n }\n\n upsert(data: UpsertBillingDto): Promise<BillingResponseDto> {\n return this.http.put(\"/api/v1/billing\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n PreferenceResponseDto,\n UpdatePreferencesDto,\n} from \"../types\";\n\nexport class PreferencesResource {\n constructor(private http: HttpClient) {}\n\n getAll(): Promise<PreferenceResponseDto[]> {\n return this.http.get(\"/api/v1/preferences\");\n }\n\n getByAppKey(appKey: string): Promise<PreferenceResponseDto> {\n return this.http.get(`/api/v1/preferences/${appKey}`);\n }\n\n upsert(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.put(`/api/v1/preferences/${appKey}`, data);\n }\n\n remove(appKey: string): Promise<void> {\n return this.http.delete(`/api/v1/preferences/${appKey}`);\n }\n\n merge(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.patch(`/api/v1/preferences/${appKey}`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateConversationDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n AddMessageDto,\n ConversationStatus,\n} from \"../types\";\n\nexport class ConversationsResource {\n constructor(private http: HttpClient) {}\n\n create(data: CreateConversationDto): Promise<ConversationResponseDto> {\n return this.http.post(\"/api/v1/conversations\", data);\n }\n\n list(query?: {\n cursor?: string;\n limit?: number;\n status?: ConversationStatus;\n appKey?: string;\n }): Promise<ConversationResponseDto[]> {\n return this.http.get(\"/api/v1/conversations\", { query });\n }\n\n get(id: string): Promise<ConversationResponseDto> {\n return this.http.get(`/api/v1/conversations/${id}`);\n }\n\n archive(id: string): Promise<ConversationResponseDto> {\n return this.http.patch(`/api/v1/conversations/${id}/archive`);\n }\n\n listMessages(conversationId: string, query?: {\n cursor?: string;\n limit?: number;\n }): Promise<ConversationMessageResponseDto[]> {\n return this.http.get(`/api/v1/conversations/${conversationId}/messages`, { query });\n }\n\n addMessage(conversationId: string, data: AddMessageDto): Promise<ConversationMessageResponseDto> {\n return this.http.post(`/api/v1/conversations/${conversationId}/messages`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { GenerateDto } from \"../types\";\n\nexport interface GenerationDoneData {\n messageId: string;\n usage?: { inputTokens: number; outputTokens: number };\n structuredOutput?: Record<string, unknown>;\n}\n\nexport interface SseStreamOptions {\n onTextDelta?: (text: string) => void;\n onDone?: (data: GenerationDoneData) => void;\n onError?: (error: string) => void;\n signal?: AbortSignal;\n}\n\ntype SseEvent =\n | { type: \"text_delta\"; text: string }\n | { type: \"done\"; messageId: string; usage?: { inputTokens: number; outputTokens: number }; structuredOutput?: Record<string, unknown> }\n | { type: \"error\"; error: string };\n\nexport class GenerationResource {\n constructor(private http: HttpClient) {}\n\n async generate(conversationId: string, data: GenerateDto, options?: SseStreamOptions): Promise<string> {\n const response = await this.http.rawRequest(\"POST\", `/api/v1/conversations/${conversationId}/generate`, {\n body: data,\n });\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"No response body\");\n\n const decoder = new TextDecoder();\n const parts: string[] = [];\n let buffer = \"\";\n\n try {\n while (true) {\n if (options?.signal?.aborted) {\n reader.cancel();\n break;\n }\n\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const jsonStr = line.slice(6).trim();\n if (!jsonStr) continue;\n\n let event: SseEvent;\n try {\n event = JSON.parse(jsonStr);\n } catch {\n continue;\n }\n\n if (event.type === \"text_delta\") {\n parts.push(event.text);\n options?.onTextDelta?.(event.text);\n } else if (event.type === \"done\") {\n options?.onDone?.(event);\n } else if (event.type === \"error\") {\n options?.onError?.(event.error);\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n\n return parts.join(\"\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n TriggerImageDto,\n ImageStatusResponseDto,\n} from \"../types\";\n\nexport class ImagesResource {\n constructor(private http: HttpClient) {}\n\n trigger(messageId: string, data: TriggerImageDto): Promise<ImageStatusResponseDto> {\n return this.http.post(`/api/v1/messages/${messageId}/images`, data);\n }\n\n getAll(messageId: string): Promise<ImageStatusResponseDto[]> {\n return this.http.get(`/api/v1/messages/${messageId}/images`);\n }\n\n getBySlot(messageId: string, slot: string): Promise<ImageStatusResponseDto> {\n return this.http.get(`/api/v1/messages/${messageId}/images/${slot}`);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n} from \"../types\";\n\nexport class PaymentsResource {\n constructor(private http: HttpClient) {}\n\n checkout(data: CreateCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout\", data);\n }\n\n checkoutCustom(data: CreateCustomCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout/custom\", data);\n }\n\n creditPricing(): Promise<CreditPricingResponseDto> {\n return this.http.get(\"/api/v1/payments/credit-pricing\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { TenantPublicInfoDto } from \"../types\";\n\nexport class TenantsResource {\n constructor(private http: HttpClient) {}\n\n getPublicInfo(tenantId: string): Promise<TenantPublicInfoDto> {\n return this.http.get(\"/api/v1/tenants/public-info\", {\n authenticated: false,\n query: { tenantId },\n });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PaginatedResponse } from \"../types\";\n\nexport class ReceiptsResource {\n constructor(private http: HttpClient) {}\n\n list(query?: { cursor?: string; limit?: number }): Promise<PaginatedResponse> {\n return this.http.get(\"/api/v1/receipts\", { query });\n }\n\n async download(id: string): Promise<Blob> {\n const response = await this.http.rawRequest(\"GET\", `/api/v1/receipts/${id}/download`);\n return response.blob();\n }\n}\n","import { HttpClient } from \"./http\";\nimport type { TokensResponseDto } from \"./types\";\nimport { AuthResource } from \"./resources/auth\";\nimport { PlansResource } from \"./resources/plans\";\nimport { CreditsResource } from \"./resources/credits\";\nimport { BillingResource } from \"./resources/billing\";\nimport { PreferencesResource } from \"./resources/preferences\";\nimport { ConversationsResource } from \"./resources/conversations\";\nimport { GenerationResource } from \"./resources/generation\";\nimport { ImagesResource } from \"./resources/images\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { TenantsResource } from \"./resources/tenants\";\nimport { ReceiptsResource } from \"./resources/receipts\";\n\nexport interface ClientOptions {\n baseUrl: string;\n tenantKey: string;\n accessToken?: string;\n refreshToken?: string;\n onTokenRefreshed?: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AiAssistantsClient {\n auth: AuthResource;\n plans: PlansResource;\n credits: CreditsResource;\n billing: BillingResource;\n preferences: PreferencesResource;\n conversations: ConversationsResource;\n generation: GenerationResource;\n images: ImagesResource;\n payments: PaymentsResource;\n tenants: TenantsResource;\n receipts: ReceiptsResource;\n setAccessToken(token: string): void;\n setRefreshToken(token: string): void;\n}\n\nexport function createClient(options: ClientOptions): AiAssistantsClient {\n let accessToken = options.accessToken ?? null;\n let refreshToken = options.refreshToken ?? null;\n\n const http = new HttpClient({\n baseUrl: options.baseUrl,\n tenantKey: options.tenantKey,\n fetch: options.fetch,\n getAccessToken: () => accessToken,\n getRefreshToken: () => refreshToken,\n onTokenRefreshed: async (tokens) => {\n accessToken = tokens.accessToken;\n refreshToken = tokens.refreshToken;\n await options.onTokenRefreshed?.(tokens);\n },\n });\n\n return {\n auth: new AuthResource(http),\n plans: new PlansResource(http),\n credits: new CreditsResource(http),\n billing: new BillingResource(http),\n preferences: new PreferencesResource(http),\n conversations: new ConversationsResource(http),\n generation: new GenerationResource(http),\n images: new ImagesResource(http),\n payments: new PaymentsResource(http),\n tenants: new TenantsResource(http),\n receipts: new ReceiptsResource(http),\n setAccessToken(token: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,IACjC,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,eAAe,OAAe;AAC5B,oBAAc;AAAA,IAChB;AAAA,IACA,gBAAgB,OAAe;AAC7B,qBAAe;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/auth.ts","../src/resources/plans.ts","../src/resources/credits.ts","../src/resources/billing.ts","../src/resources/preferences.ts","../src/resources/conversations.ts","../src/resources/generation.ts","../src/resources/images.ts","../src/resources/payments.ts","../src/resources/tenants.ts","../src/resources/receipts.ts","../src/client.ts"],"sourcesContent":["export class ApiError extends Error {\n constructor(\n public readonly statusCode: number,\n public readonly code: string,\n message: string | string[],\n public readonly requestId?: string,\n ) {\n super(Array.isArray(message) ? message.join(\", \") : message);\n this.name = \"ApiError\";\n }\n}\n","import { ApiError } from \"./errors\";\nimport type { TokensResponseDto } from \"./types\";\n\nexport interface HttpClientConfig {\n baseUrl: string;\n tenantKey: string;\n getAccessToken: () => string | null;\n getRefreshToken: () => string | null;\n onTokenRefreshed: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\ntype HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ninterface RequestOptions {\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined | null>;\n authenticated?: boolean;\n}\n\ninterface InternalRequestOptions extends RequestOptions {\n isRetry?: boolean;\n}\n\nexport class HttpClient {\n private refreshPromise: Promise<boolean> | null = null;\n private readonly baseUrl: URL;\n private readonly fetchFn: typeof globalThis.fetch;\n\n constructor(private config: HttpClientConfig) {\n this.baseUrl = new URL(config.baseUrl);\n this.fetchFn = config.fetch ?? globalThis.fetch;\n }\n\n private buildAndFetch(\n method: HttpMethod,\n path: string,\n options: RequestOptions = {},\n ): Promise<Response> {\n const { body, query, authenticated = true } = options;\n\n const url = new URL(path, this.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Tenant-Key\": this.config.tenantKey,\n };\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n if (authenticated) {\n const token = this.config.getAccessToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n }\n\n return this.fetchFn(url.toString(), {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n private async throwIfError(response: Response): Promise<void> {\n if (!response.ok) {\n const errorBody = await response.json().catch(() => null);\n throw new ApiError(\n response.status,\n errorBody?.error?.code ?? \"UNKNOWN_ERROR\",\n errorBody?.error?.message ?? response.statusText,\n errorBody?.meta?.requestId,\n );\n }\n }\n\n private async request<T>(\n method: HttpMethod,\n path: string,\n options: InternalRequestOptions = {},\n ): Promise<T> {\n const { isRetry = false, authenticated = true } = options;\n\n const response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && !isRetry && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n return this.request<T>(method, path, { ...options, isRetry: true });\n }\n }\n\n await this.throwIfError(response);\n\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return undefined as T;\n }\n\n const json = await response.json();\n return (json && \"data\" in json && \"meta\" in json ? json.data : json) as T;\n }\n\n private attemptTokenRefresh(): Promise<boolean> {\n if (this.refreshPromise) return this.refreshPromise;\n this.refreshPromise = this.doRefresh().finally(() => {\n this.refreshPromise = null;\n });\n return this.refreshPromise;\n }\n\n private async doRefresh(): Promise<boolean> {\n const refreshToken = this.config.getRefreshToken();\n if (!refreshToken) return false;\n\n try {\n const tokens = await this.request<TokensResponseDto>(\n \"POST\",\n \"/api/v1/auth/refresh\",\n {\n body: { refreshToken },\n authenticated: false,\n isRetry: true,\n },\n );\n await this.config.onTokenRefreshed(tokens);\n return true;\n } catch {\n return false;\n }\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"POST\", path, { ...options, body });\n }\n\n patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PATCH\", path, { ...options, body });\n }\n\n put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, \"body\">): Promise<T> {\n return this.request<T>(\"PUT\", path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>(\"DELETE\", path, options);\n }\n\n async rawRequest(method: HttpMethod, path: string, options: RequestOptions = {}): Promise<Response> {\n const { authenticated = true } = options;\n\n let response = await this.buildAndFetch(method, path, options);\n\n if (response.status === 401 && authenticated) {\n const refreshed = await this.attemptTokenRefresh();\n if (refreshed) {\n response = await this.buildAndFetch(method, path, options);\n }\n }\n\n await this.throwIfError(response);\n\n return response;\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n RegisterDto,\n LoginDto,\n VerifyOtpDto,\n RefreshTokenDto,\n UpdateProfileDto,\n RequestEmailChangeDto,\n ConfirmEmailChangeDto,\n MessageResponseDto,\n AuthResponseDto,\n TokensResponseDto,\n UserResponseDto,\n StartAuthResponseDto,\n} from \"../types\";\n\nexport class AuthResource {\n constructor(private http: HttpClient) {}\n\n register(data: RegisterDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/register\", data, { authenticated: false });\n }\n\n login(data: LoginDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/login\", data, { authenticated: false });\n }\n\n startAuth(data: LoginDto): Promise<StartAuthResponseDto> {\n return this.http.post(\"/api/v1/auth/start\", data, { authenticated: false });\n }\n\n verifyOtp(data: VerifyOtpDto): Promise<AuthResponseDto> {\n return this.http.post(\"/api/v1/auth/verify-otp\", data, { authenticated: false });\n }\n\n refresh(data: RefreshTokenDto): Promise<TokensResponseDto> {\n return this.http.post(\"/api/v1/auth/refresh\", data, { authenticated: false });\n }\n\n logout(): Promise<void> {\n return this.http.post(\"/api/v1/auth/logout\");\n }\n\n getProfile(): Promise<UserResponseDto> {\n return this.http.get(\"/api/v1/auth/me\");\n }\n\n updateProfile(data: UpdateProfileDto): Promise<UserResponseDto> {\n return this.http.patch(\"/api/v1/auth/me\", data);\n }\n\n deleteAccount(): Promise<void> {\n return this.http.delete(\"/api/v1/auth/me\");\n }\n\n requestEmailChange(data: RequestEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/request-email-change\", data);\n }\n\n confirmEmailChange(data: ConfirmEmailChangeDto): Promise<MessageResponseDto> {\n return this.http.post(\"/api/v1/auth/confirm-email-change\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PlanResponseDto } from \"../types\";\n\nexport class PlansResource {\n constructor(private http: HttpClient) {}\n\n list(): Promise<PlanResponseDto[]> {\n return this.http.get(\"/api/v1/public/plans\", { authenticated: false });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreditBalanceResponseDto,\n CreditTransactionResponseDto,\n CreditTransactionType,\n PurchaseCreditsDto,\n PurchaseCreditsResponseDto,\n} from \"../types\";\n\nexport class CreditsResource {\n constructor(private http: HttpClient) {}\n\n getBalance(): Promise<CreditBalanceResponseDto> {\n return this.http.get(\"/api/v1/credits/balance\");\n }\n\n getTransactions(query?: {\n cursor?: string;\n limit?: number;\n type?: CreditTransactionType;\n }): Promise<CreditTransactionResponseDto[]> {\n return this.http.get(\"/api/v1/credits/transactions\", { query });\n }\n\n purchase(data: PurchaseCreditsDto): Promise<PurchaseCreditsResponseDto> {\n return this.http.post(\"/api/v1/credits/purchase\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { BillingResponseDto, UpsertBillingDto } from \"../types\";\n\nexport class BillingResource {\n constructor(private http: HttpClient) {}\n\n get(): Promise<BillingResponseDto> {\n return this.http.get(\"/api/v1/billing\");\n }\n\n upsert(data: UpsertBillingDto): Promise<BillingResponseDto> {\n return this.http.put(\"/api/v1/billing\", data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n PreferenceResponseDto,\n UpdatePreferencesDto,\n} from \"../types\";\n\nexport class PreferencesResource {\n constructor(private http: HttpClient) {}\n\n getAll(): Promise<PreferenceResponseDto[]> {\n return this.http.get(\"/api/v1/preferences\");\n }\n\n getByAppKey(appKey: string): Promise<PreferenceResponseDto> {\n return this.http.get(`/api/v1/preferences/${appKey}`);\n }\n\n upsert(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.put(`/api/v1/preferences/${appKey}`, data);\n }\n\n remove(appKey: string): Promise<void> {\n return this.http.delete(`/api/v1/preferences/${appKey}`);\n }\n\n merge(appKey: string, data: UpdatePreferencesDto): Promise<PreferenceResponseDto> {\n return this.http.patch(`/api/v1/preferences/${appKey}`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateConversationDto,\n ConversationResponseDto,\n ConversationMessageResponseDto,\n AddMessageDto,\n ConversationStatus,\n} from \"../types\";\n\nexport class ConversationsResource {\n constructor(private http: HttpClient) {}\n\n create(data: CreateConversationDto): Promise<ConversationResponseDto> {\n return this.http.post(\"/api/v1/conversations\", data);\n }\n\n list(query?: {\n cursor?: string;\n limit?: number;\n status?: ConversationStatus;\n appKey?: string;\n }): Promise<ConversationResponseDto[]> {\n return this.http.get(\"/api/v1/conversations\", { query });\n }\n\n get(id: string): Promise<ConversationResponseDto> {\n return this.http.get(`/api/v1/conversations/${id}`);\n }\n\n archive(id: string): Promise<ConversationResponseDto> {\n return this.http.patch(`/api/v1/conversations/${id}/archive`);\n }\n\n listMessages(conversationId: string, query?: {\n cursor?: string;\n limit?: number;\n }): Promise<ConversationMessageResponseDto[]> {\n return this.http.get(`/api/v1/conversations/${conversationId}/messages`, { query });\n }\n\n addMessage(conversationId: string, data: AddMessageDto): Promise<ConversationMessageResponseDto> {\n return this.http.post(`/api/v1/conversations/${conversationId}/messages`, data);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { GenerateDto } from \"../types\";\n\nexport interface GenerationDoneData {\n messageId: string;\n usage?: { inputTokens: number; outputTokens: number };\n structuredOutput?: Record<string, unknown>;\n}\n\nexport interface SseStreamOptions {\n onTextDelta?: (text: string) => void;\n onDone?: (data: GenerationDoneData) => void;\n onError?: (error: string) => void;\n signal?: AbortSignal;\n}\n\ntype SseEvent =\n | { type: \"text_delta\"; text: string }\n | { type: \"done\"; messageId: string; usage?: { inputTokens: number; outputTokens: number }; structuredOutput?: Record<string, unknown> }\n | { type: \"error\"; error: string };\n\nexport class GenerationResource {\n constructor(private http: HttpClient) {}\n\n async generate(conversationId: string, data: GenerateDto, options?: SseStreamOptions): Promise<string> {\n const response = await this.http.rawRequest(\"POST\", `/api/v1/conversations/${conversationId}/generate`, {\n body: data,\n });\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"No response body\");\n\n const decoder = new TextDecoder();\n const parts: string[] = [];\n let buffer = \"\";\n\n try {\n while (true) {\n if (options?.signal?.aborted) {\n reader.cancel();\n break;\n }\n\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const jsonStr = line.slice(6).trim();\n if (!jsonStr) continue;\n\n let event: SseEvent;\n try {\n event = JSON.parse(jsonStr);\n } catch {\n continue;\n }\n\n if (event.type === \"text_delta\") {\n parts.push(event.text);\n options?.onTextDelta?.(event.text);\n } else if (event.type === \"done\") {\n options?.onDone?.(event);\n } else if (event.type === \"error\") {\n options?.onError?.(event.error);\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n\n return parts.join(\"\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n TriggerImageDto,\n ImageStatusResponseDto,\n} from \"../types\";\n\nexport class ImagesResource {\n constructor(private http: HttpClient) {}\n\n trigger(messageId: string, data: TriggerImageDto): Promise<ImageStatusResponseDto> {\n return this.http.post(`/api/v1/messages/${messageId}/images`, data);\n }\n\n getAll(messageId: string): Promise<ImageStatusResponseDto[]> {\n return this.http.get(`/api/v1/messages/${messageId}/images`);\n }\n\n getBySlot(messageId: string, slot: string): Promise<ImageStatusResponseDto> {\n return this.http.get(`/api/v1/messages/${messageId}/images/${slot}`);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateCheckoutDto,\n CreateCustomCheckoutDto,\n CheckoutResponseDto,\n CreditPricingResponseDto,\n} from \"../types\";\n\nexport class PaymentsResource {\n constructor(private http: HttpClient) {}\n\n checkout(data: CreateCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout\", data);\n }\n\n checkoutCustom(data: CreateCustomCheckoutDto): Promise<CheckoutResponseDto> {\n return this.http.post(\"/api/v1/payments/checkout/custom\", data);\n }\n\n creditPricing(): Promise<CreditPricingResponseDto> {\n return this.http.get(\"/api/v1/payments/credit-pricing\");\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { TenantPublicInfoDto } from \"../types\";\n\nexport class TenantsResource {\n constructor(private http: HttpClient) {}\n\n getPublicInfo(tenantId: string): Promise<TenantPublicInfoDto> {\n return this.http.get(\"/api/v1/tenants/public-info\", {\n authenticated: false,\n query: { tenantId },\n });\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { PaginatedResponse } from \"../types\";\n\nexport class ReceiptsResource {\n constructor(private http: HttpClient) {}\n\n list(query?: { cursor?: string; limit?: number }): Promise<PaginatedResponse> {\n return this.http.get(\"/api/v1/receipts\", { query });\n }\n\n async download(id: string): Promise<Blob> {\n const response = await this.http.rawRequest(\"GET\", `/api/v1/receipts/${id}/download`);\n return response.blob();\n }\n}\n","import { HttpClient } from \"./http\";\nimport type { TokensResponseDto, PingResponseDto } from \"./types\";\nimport { AuthResource } from \"./resources/auth\";\nimport { PlansResource } from \"./resources/plans\";\nimport { CreditsResource } from \"./resources/credits\";\nimport { BillingResource } from \"./resources/billing\";\nimport { PreferencesResource } from \"./resources/preferences\";\nimport { ConversationsResource } from \"./resources/conversations\";\nimport { GenerationResource } from \"./resources/generation\";\nimport { ImagesResource } from \"./resources/images\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { TenantsResource } from \"./resources/tenants\";\nimport { ReceiptsResource } from \"./resources/receipts\";\n\nexport interface ClientOptions {\n baseUrl: string;\n tenantKey: string;\n accessToken?: string;\n refreshToken?: string;\n onTokenRefreshed?: (tokens: TokensResponseDto) => void | Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AiAssistantsClient {\n auth: AuthResource;\n plans: PlansResource;\n credits: CreditsResource;\n billing: BillingResource;\n preferences: PreferencesResource;\n conversations: ConversationsResource;\n generation: GenerationResource;\n images: ImagesResource;\n payments: PaymentsResource;\n tenants: TenantsResource;\n receipts: ReceiptsResource;\n /**\n * Verify the client is configured correctly: confirms the base URL is\n * reachable and the tenant key is valid. Resolves with the tenant identity\n * when the SDK is ready to use, and rejects with an {@link ApiError} otherwise.\n */\n ping(): Promise<PingResponseDto>;\n setAccessToken(token: string): void;\n setRefreshToken(token: string): void;\n}\n\nexport function createClient(options: ClientOptions): AiAssistantsClient {\n let accessToken = options.accessToken ?? null;\n let refreshToken = options.refreshToken ?? null;\n\n const http = new HttpClient({\n baseUrl: options.baseUrl,\n tenantKey: options.tenantKey,\n fetch: options.fetch,\n getAccessToken: () => accessToken,\n getRefreshToken: () => refreshToken,\n onTokenRefreshed: async (tokens) => {\n accessToken = tokens.accessToken;\n refreshToken = tokens.refreshToken;\n await options.onTokenRefreshed?.(tokens);\n },\n });\n\n return {\n auth: new AuthResource(http),\n plans: new PlansResource(http),\n credits: new CreditsResource(http),\n billing: new BillingResource(http),\n preferences: new PreferencesResource(http),\n conversations: new ConversationsResource(http),\n generation: new GenerationResource(http),\n images: new ImagesResource(http),\n payments: new PaymentsResource(http),\n tenants: new TenantsResource(http),\n receipts: new ReceiptsResource(http),\n ping() {\n return http.get<PingResponseDto>(\"/api/v1/ping\", { authenticated: false });\n },\n setAccessToken(token: string) {\n accessToken = token;\n },\n setRefreshToken(token: string) {\n refreshToken = token;\n },\n };\n}\n"],"mappings":";AAAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACkB,YACA,MAChB,SACgB,WAChB;AACA,UAAM,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO;AAL3C;AACA;AAEA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACcO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAoB,QAA0B;AAA1B;AAJpB,SAAQ,iBAA0C;AAKhD,SAAK,UAAU,IAAI,IAAI,OAAO,OAAO;AACrC,SAAK,UAAU,OAAO,SAAS,WAAW;AAAA,EAC5C;AAAA,EAEQ,cACN,QACA,MACA,UAA0B,CAAC,GACR;AACnB,UAAM,EAAE,MAAM,OAAO,gBAAgB,KAAK,IAAI;AAE9C,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO;AACtC,QAAI,OAAO;AACT,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,UAAU,UAAa,UAAU,MAAM;AACzC,cAAI,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,UAAM,UAAkC;AAAA,MACtC,gBAAgB,KAAK,OAAO;AAAA,IAC9B;AACA,QAAI,SAAS,QAAW;AACtB,cAAQ,cAAc,IAAI;AAAA,IAC5B;AACA,QAAI,eAAe;AACjB,YAAM,QAAQ,KAAK,OAAO,eAAe;AACzC,UAAI,OAAO;AACT,gBAAQ,eAAe,IAAI,UAAU,KAAK;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO,KAAK,QAAQ,IAAI,SAAS,GAAG;AAAA,MAClC;AAAA,MACA;AAAA,MACA,MAAM,SAAS,SAAY,KAAK,UAAU,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AA,IAC/B,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,SAAS,IAAI,gBAAgB,IAAI;AAAA,IACjC,UAAU,IAAI,iBAAiB,IAAI;AAAA,IACnC,OAAO;AACL,aAAO,KAAK,IAAqB,gBAAgB,EAAE,eAAe,MAAM,CAAC;AAAA,IAC3E;AAAA,IACA,eAAe,OAAe;AAC5B,oBAAc;AAAA,IAChB;AAAA,IACA,gBAAgB,OAAe;AAC7B,qBAAe;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zdrops/ai-assistants-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "TypeScript SDK for the AI Assistants API",
5
5
  "license": "MIT",
6
6
  "type": "module",