@syscli/oneclickdz 0.1.0
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/LICENSE +21 -0
- package/README.md +298 -0
- package/dist/index.cjs +934 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +730 -0
- package/dist/index.d.ts +730 -0
- package/dist/index.js +890 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/base.ts","../src/resources/core.ts","../src/resources/account.ts","../src/types.ts","../src/poll.ts","../src/ref.ts","../src/validate.ts","../src/resources/mobile.ts","../src/secret.ts","../src/resources/internet.ts","../src/resources/giftcards.ts","../src/resources/payments.ts","../src/client.ts","../src/pricing.ts","../src/index.ts"],"names":["validateSend","isTerminal"],"mappings":";;;AA0CO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA;AAAA,EAE9B,MAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,IAAA,EACA,OAAA,GAAgC,EAAC,EACjC;AACA,IAAA,KAAA;AAAA,MACE,OAAA;AAAA,MACA,QAAQ,KAAA,KAAU,MAAA,GAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,OAAM,GAAI;AAAA,KAC3D;AACA,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AACzB,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AAAA,EACtB;AACF;AAGO,IAAM,SAAA,GA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AA,CAAA,GAAO,IAAA,GAAO,MAAA,CAAO,IAAA;AAC1E,EAAA,OAAO,IAAA,CAAK,MAAM,GAAG,CAAA;AACvB;AAaO,SAAS,qBAAA,CACd,UACA,MAAA,EAC2B;AAC3B,EAAA,OAAO,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IAC1B,OAAO,CAAA,CAAE,KAAA;AAAA,IACT,KAAA,EAAO,SAAA,CAAU,CAAA,CAAE,IAAA,EAAM,MAAM,CAAA;AAAA,IAC/B,WAAW,CAAA,CAAE;AAAA,GACf,CAAE,CAAA;AACJ;AAcO,SAAS,cAAA,CACd,OACA,MAAA,EACoB;AACpB,EAAA,OAAO,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IACvB,IAAI,CAAA,CAAE,EAAA;AAAA,IACN,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,KAAA,EAAO,SAAA,CAAU,CAAA,CAAE,KAAA,EAAO,MAAM,CAAA;AAAA,IAChC,OAAA,EAAS,EAAE,QAAA,GAAW;AAAA,GACxB,CAAE,CAAA;AACJ;;;AC9DO,IAAM,OAAA,GAAU","file":"index.cjs","sourcesContent":["// The error hierarchy. Every failure the client raises is an instance of\n// OneClickError, so callers can catch one type and branch on `instanceof` or on\n// the stable `code` string the API returns. HTTP failures are mapped from the\n// envelope's `error.code` first and the status second; ValidationError is also\n// raised client-side, before any request leaves.\n\n/**\n * The machine-readable error codes. The API's own codes are kept verbatim so\n * `error.code` matches what the docs list. `network` is the one code the client\n * adds itself, for a request that never reached the server.\n */\nexport type OneClickErrorCode =\n | \"MISSING_ACCESS_TOKEN\"\n | \"INVALID_ACCESS_TOKEN\"\n | \"ERR_AUTH\"\n | \"NO_BALANCE\"\n | \"INSUFFICIENT_BALANCE\"\n | \"DUPLICATED_REF\"\n | \"IP_BLOCKED\"\n | \"IP_NOT_ALLOWED\"\n | \"ERR_VALIDATION\"\n | \"ERR_PHONE\"\n | \"ERR_STOCK\"\n | \"NOT_FOUND\"\n | \"RATE_LIMIT_EXCEEDED\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"INTERNAL_ERROR\"\n | \"ERR_SERVICE\"\n | \"network\"\n | (string & {});\n\nexport interface OneClickErrorOptions {\n status?: number;\n /** The `error.details` object the API attaches to some failures. */\n details?: unknown;\n /** The request id from the envelope, handy when opening a support ticket. */\n requestId?: string;\n /** The full parsed response body, kept so callers can read everything. */\n body?: unknown;\n cause?: unknown;\n}\n\nexport class OneClickError extends Error {\n /** HTTP status, or undefined for a client-side or network error. */\n readonly status?: number;\n readonly code: OneClickErrorCode;\n readonly details: unknown;\n readonly requestId?: string;\n readonly body: unknown;\n\n constructor(\n message: string,\n code: OneClickErrorCode,\n options: OneClickErrorOptions = {},\n ) {\n super(\n message,\n options.cause !== undefined ? { cause: options.cause } : undefined,\n );\n this.name = new.target.name;\n this.code = code;\n this.status = options.status;\n this.details = options.details;\n this.requestId = options.requestId;\n this.body = options.body;\n }\n}\n\n/** 401. The key is missing, malformed, or rejected. */\nexport class AuthError extends OneClickError {}\n\n/**\n * 403. The key is valid but the action is not allowed: a blocked or unlisted IP,\n * for instance. Balance and duplicate-ref cases have their own subclasses below\n * so they can be caught on their own.\n */\nexport class ForbiddenError extends OneClickError {}\n\n/** 403 with NO_BALANCE or INSUFFICIENT_BALANCE. Top up the account first. */\nexport class InsufficientBalanceError extends ForbiddenError {}\n\n/**\n * 403 with DUPLICATED_REF. The reference was already used, so the original order\n * stands and nothing was charged twice. Look the first one up by its ref rather\n * than sending again.\n */\nexport class DuplicateRefError extends ForbiddenError {}\n\nexport interface ValidationIssue {\n field: string;\n message: string;\n /** The order reference this issue belongs to, when checking a batch. */\n ref?: string;\n}\n\nexport interface ValidationErrorOptions extends OneClickErrorOptions {\n /** The API code for a server-side 400; defaults to ERR_VALIDATION. */\n code?: OneClickErrorCode;\n /** Filled when the client caught the problem before sending. */\n issues?: ValidationIssue[];\n}\n\n/**\n * A 400 from the API, or a client-side check. `issues` is filled when the client\n * caught the problem before sending; for a server 400 it is empty and the detail\n * sits in `code`, `message`, and `details`.\n */\nexport class ValidationError extends OneClickError {\n readonly issues: ValidationIssue[];\n\n constructor(message: string, options: ValidationErrorOptions = {}) {\n super(message, options.code ?? \"ERR_VALIDATION\", options);\n this.issues = options.issues ?? [];\n }\n}\n\n/** 404. No order, product, or payment matches the id or reference. */\nexport class NotFoundError extends OneClickError {}\n\nexport interface RateLimitErrorOptions extends OneClickErrorOptions {\n /** Seconds to wait before retrying, read from the Retry-After header. */\n retryAfter?: number;\n}\n\n/** 429. Too many requests inside the per-minute window. */\nexport class RateLimitError extends OneClickError {\n readonly retryAfter?: number;\n\n constructor(message: string, options: RateLimitErrorOptions = {}) {\n super(message, \"RATE_LIMIT_EXCEEDED\", options);\n this.retryAfter = options.retryAfter;\n }\n}\n\n/**\n * 500 or 503. The request may or may not have been processed. For a top-up this\n * matters: the docs say not to refund a server error for 24 hours, since the\n * recharge can still settle. The client never auto-retries a send on a 5xx for\n * the same reason.\n */\nexport class ServiceError extends OneClickError {}\n\n/** The request never reached the server: DNS, socket, or a timeout abort. */\nexport class NetworkError extends OneClickError {\n constructor(message: string, options: OneClickErrorOptions = {}) {\n super(message, \"network\", options);\n }\n}\n\n/** Any other 4xx the client does not model on its own. */\nexport class RequestError extends OneClickError {}\n\ninterface ApiErrorBody {\n code?: OneClickErrorCode;\n message?: string;\n details?: unknown;\n}\n\n/**\n * Build the right error from a failed envelope. The API's `error.code` decides\n * the class where we recognise it; otherwise the HTTP status does. The code is\n * passed through verbatim so `error.code` matches the documentation.\n */\nexport function errorFromResponse(\n status: number,\n body: unknown,\n retryAfter?: number,\n): OneClickError {\n const apiError = readApiError(body);\n const code = apiError.code;\n const message = apiError.message ?? `Request failed with status ${status}.`;\n const options: OneClickErrorOptions = {\n status,\n body,\n requestId: readRequestId(body),\n details: apiError.details,\n };\n\n switch (code) {\n case \"MISSING_ACCESS_TOKEN\":\n case \"INVALID_ACCESS_TOKEN\":\n case \"ERR_AUTH\":\n return new AuthError(message, code, options);\n case \"NO_BALANCE\":\n case \"INSUFFICIENT_BALANCE\":\n return new InsufficientBalanceError(message, code, options);\n case \"DUPLICATED_REF\":\n return new DuplicateRefError(message, code, options);\n case \"IP_BLOCKED\":\n case \"IP_NOT_ALLOWED\":\n return new ForbiddenError(message, code, options);\n case \"ERR_VALIDATION\":\n case \"ERR_PHONE\":\n case \"ERR_STOCK\":\n return new ValidationError(message, { ...options, code });\n case \"NOT_FOUND\":\n return new NotFoundError(message, code, options);\n case \"RATE_LIMIT_EXCEEDED\":\n return new RateLimitError(message, { ...options, retryAfter });\n case \"INTERNAL_SERVER_ERROR\":\n case \"INTERNAL_ERROR\":\n case \"ERR_SERVICE\":\n return new ServiceError(message, code, options);\n }\n\n // No code we recognise. Fall back to the status, keeping any code the API did\n // send so a new server-side code still reaches the caller through `error.code`.\n return errorFromStatus(status, message, options, code, retryAfter);\n}\n\nfunction errorFromStatus(\n status: number,\n message: string,\n options: OneClickErrorOptions,\n code: OneClickErrorCode | undefined,\n retryAfter?: number,\n): OneClickError {\n if (status === 401) return new AuthError(message, code ?? \"ERR_AUTH\", options);\n if (status === 403)\n return new ForbiddenError(message, code ?? \"ERR_AUTH\", options);\n if (status === 404)\n return new NotFoundError(message, code ?? \"NOT_FOUND\", options);\n if (status === 429)\n return new RateLimitError(message, { ...options, retryAfter });\n if (status >= 500)\n return new ServiceError(message, code ?? \"INTERNAL_SERVER_ERROR\", options);\n return new RequestError(message, code ?? \"ERR_VALIDATION\", options);\n}\n\nfunction readApiError(body: unknown): ApiErrorBody {\n if (body && typeof body === \"object\" && \"error\" in body) {\n const inner = (body as { error?: unknown }).error;\n if (inner && typeof inner === \"object\") {\n const e = inner as { code?: unknown; message?: unknown; details?: unknown };\n return {\n code: typeof e.code === \"string\" ? e.code : undefined,\n message: typeof e.message === \"string\" ? e.message : undefined,\n details: e.details,\n };\n }\n }\n return {};\n}\n\nfunction readRequestId(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"requestId\" in body) {\n const id = (body as { requestId?: unknown }).requestId;\n if (typeof id === \"string\") return id;\n }\n return undefined;\n}\n","// Low-level transport for the OneClickDZ client. Everything that touches the\n// network goes through here: the access-token header, query encoding, the\n// timeout, the retry, envelope unwrapping, and JSON parsing. Resources call\n// `request` and never build a URL or read the envelope themselves.\n\nimport {\n errorFromResponse,\n NetworkError,\n OneClickError,\n RateLimitError,\n ServiceError,\n} from \"./errors\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\n/** A fetch implementation compatible with the platform global. */\nexport type FetchLike = typeof globalThis.fetch;\n\nexport interface RetryConfig {\n /** Total attempts including the first. 1 disables retrying. */\n attempts: number;\n /** Wait the Retry-After header when the API sends one. */\n respectRetryAfter: boolean;\n}\n\n/** Page numbers and totals the API returns on list endpoints. */\nexport interface Pagination {\n page: number;\n pageSize: number;\n totalPages: number;\n totalResults: number;\n}\n\nexport interface ResponseMeta {\n timestamp?: string;\n pagination?: Pagination;\n [key: string]: unknown;\n}\n\n/**\n * The success envelope every endpoint returns. `data` is the endpoint payload;\n * a few endpoints (the gift-card catalog, for one) hang extra counts off the top\n * level, so unknown keys are preserved.\n */\nexport interface Envelope<T> {\n success: true;\n data: T;\n meta?: ResponseMeta;\n requestId?: string;\n [key: string]: unknown;\n}\n\nconst sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\nexport type QueryValue = string | number | boolean | null | undefined;\nexport type QueryParams = Record<string, QueryValue>;\n\nexport interface HttpClientConfig {\n /** The API access token, sent as the X-Access-Token header. */\n key: string;\n /** Trailing slash is optional; it is added if missing. */\n baseUrl: string;\n fetch: FetchLike;\n timeoutMs: number;\n retry: RetryConfig;\n}\n\nexport interface RequestOptions {\n query?: QueryParams;\n /** Serialized as JSON. Its presence is what adds the Content-Type header. */\n body?: unknown;\n /** Caller cancellation, merged with the per-request timeout. */\n signal?: AbortSignal;\n}\n\n/**\n * Turn a params object into a query string, including the leading `?`. Returns\n * an empty string when nothing survives filtering. `undefined` and `null` are\n * dropped; booleans go over the wire as `\"true\"` and `\"false\"`.\n */\nexport function encodeQuery(params: QueryParams | undefined): string {\n if (!params) return \"\";\n\n const parts: string[] = [];\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n parts.push(\n `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`,\n );\n }\n\n return parts.length ? `?${parts.join(\"&\")}` : \"\";\n}\n\n/** The headers every request carries, plus Content-Type when sending a body. */\nexport function buildHeaders(\n config: HttpClientConfig,\n hasBody: boolean,\n): Record<string, string> {\n const headers: Record<string, string> = {\n \"X-Access-Token\": config.key,\n Accept: \"application/json\",\n };\n if (hasBody) headers[\"Content-Type\"] = \"application/json\";\n return headers;\n}\n\n/**\n * Read a Retry-After header into seconds. The header is either a delta in\n * seconds or an HTTP date, so both are handled; anything else returns undefined.\n */\nexport function parseRetryAfter(value: string | null): number | undefined {\n if (!value) return undefined;\n\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.max(0, seconds);\n\n const at = Date.parse(value);\n if (Number.isNaN(at)) return undefined;\n return Math.max(0, Math.round((at - Date.now()) / 1000));\n}\n\nexport class HttpClient {\n private readonly config: HttpClientConfig;\n\n constructor(config: HttpClientConfig) {\n // new URL() treats a base without a trailing slash as a file and drops the\n // last path segment, which would silently delete the `/v3` prefix. Pin it.\n this.config = {\n ...config,\n baseUrl: config.baseUrl.endsWith(\"/\")\n ? config.baseUrl\n : `${config.baseUrl}/`,\n };\n }\n\n /**\n * Send a request and return the unwrapped envelope.\n *\n * Retry policy is deliberately narrow. A 429 is always safe to retry, since\n * the request was rejected before processing. A 5xx or a dropped connection is\n * retried only for GET: a send that timed out may still have gone through, and\n * a blind retry could charge the account twice. Use a `ref` for safe resends.\n */\n async request<T>(\n method: HttpMethod,\n path: string,\n options: RequestOptions = {},\n ): Promise<Envelope<T>> {\n const maxAttempts = Math.max(1, this.config.retry.attempts);\n const idempotent = method === \"GET\";\n\n for (let attempt = 1; ; attempt++) {\n try {\n return await this.send<T>(method, path, options);\n } catch (error) {\n if (attempt >= maxAttempts || !this.retryable(error, idempotent)) {\n throw error;\n }\n await sleep(this.backoffMs(error, attempt));\n }\n }\n }\n\n private retryable(error: unknown, idempotent: boolean): boolean {\n if (error instanceof RateLimitError) return true;\n if (error instanceof ServiceError) return idempotent;\n if (error instanceof NetworkError) return idempotent;\n return false;\n }\n\n /** Wait the API's Retry-After when offered, otherwise an exponential backoff. */\n private backoffMs(error: unknown, attempt: number): number {\n if (\n error instanceof RateLimitError &&\n this.config.retry.respectRetryAfter &&\n error.retryAfter !== undefined\n ) {\n return error.retryAfter * 1000;\n }\n return Math.min(2 ** (attempt - 1) * 500, 30_000);\n }\n\n private async send<T>(\n method: HttpMethod,\n path: string,\n options: RequestOptions,\n ): Promise<Envelope<T>> {\n const hasBody = options.body !== undefined;\n const url = new URL(path, this.config.baseUrl);\n const target = `${url.toString()}${encodeQuery(options.query)}`;\n const headers = buildHeaders(this.config, hasBody);\n\n const controller = new AbortController();\n const timer =\n this.config.timeoutMs > 0\n ? setTimeout(() => controller.abort(), this.config.timeoutMs)\n : undefined;\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else\n options.signal.addEventListener(\"abort\", () => controller.abort(), {\n once: true,\n });\n }\n\n let response: Response;\n try {\n response = await this.config.fetch(target, {\n method,\n headers,\n body: hasBody ? JSON.stringify(options.body) : undefined,\n signal: controller.signal,\n });\n } catch (cause) {\n // A caller abort should surface as itself; a timeout or transport failure\n // becomes a NetworkError so the retry and the catch sites stay uniform.\n if (options.signal?.aborted) throw cause;\n const reason = cause instanceof Error ? cause.message : \"request failed\";\n throw new NetworkError(`Could not reach the API: ${reason}.`, { cause });\n } finally {\n if (timer) clearTimeout(timer);\n }\n\n const text = await response.text();\n let body: unknown;\n try {\n body = text ? JSON.parse(text) : undefined;\n } catch {\n // Some gateway error pages are HTML, not JSON. Keep the raw text to report.\n body = text;\n }\n\n if (!response.ok) {\n const retryAfter = parseRetryAfter(response.headers.get(\"retry-after\"));\n throw errorFromResponse(response.status, body, retryAfter);\n }\n\n return this.toEnvelope<T>(body, response.status);\n }\n\n /** Confirm the body is a success envelope before handing it back. */\n private toEnvelope<T>(body: unknown, status: number): Envelope<T> {\n if (body && typeof body === \"object\" && \"success\" in body) {\n if ((body as { success?: unknown }).success === false) {\n // A 200 that still carries success:false. Treat it as the error it is.\n throw errorFromResponse(status, body);\n }\n return body as Envelope<T>;\n }\n throw new OneClickError(\n \"The API returned a response in an unexpected shape.\",\n \"ERR_SERVICE\",\n { status, body },\n );\n }\n}\n","// The shared base every resource extends. It holds the HttpClient and offers the\n// three things resources keep needing: read a single payload, send one, and walk\n// a paginated list. List endpoints differ in where they nest their items, so the\n// pagination helper takes an extractor and lets each resource map its own shape.\n\nimport type { HttpClient, QueryParams, Envelope } from \"../http\";\nimport type { Pagination } from \"../http\";\n\n/**\n * One page of a list, plus a `next()` that fetches the page after it. `next()`\n * resolves to undefined once there is nothing more, so a `while (page)` loop ends\n * cleanly.\n */\nexport interface Page<T> extends Pagination {\n items: T[];\n /** True while a further page exists. */\n hasMore: boolean;\n /** The next page, or undefined when this is the last one. */\n next(): Promise<Page<T> | undefined>;\n}\n\nexport abstract class Resource {\n constructor(protected readonly http: HttpClient) {}\n\n /** GET a path and return its `data` payload. */\n protected async getData<T>(\n path: string,\n query?: QueryParams,\n signal?: AbortSignal,\n ): Promise<T> {\n const env = await this.http.request<T>(\"GET\", path, { query, signal });\n return env.data;\n }\n\n /** POST a body and return the `data` payload. */\n protected async postData<T>(\n path: string,\n body: unknown,\n signal?: AbortSignal,\n ): Promise<T> {\n const env = await this.http.request<T>(\"POST\", path, { body, signal });\n return env.data;\n }\n\n /**\n * Fetch one page of a list. `extract` pulls the items and the pagination block\n * out of whatever shape the endpoint nests them in; it gets the whole envelope\n * because some endpoints keep pagination in `data` and others in `meta`.\n * `next()` reissues the same request with the page number bumped.\n */\n protected async fetchPage<T>(\n path: string,\n query: QueryParams,\n extract: (env: Envelope<unknown>) => { items: T[]; pagination: Pagination },\n ): Promise<Page<T>> {\n const env = await this.http.request<unknown>(\"GET\", path, { query });\n const { items, pagination } = extract(env);\n const hasMore = pagination.page < pagination.totalPages;\n return {\n items,\n ...pagination,\n hasMore,\n next: hasMore\n ? () =>\n this.fetchPage(\n path,\n { ...query, page: pagination.page + 1 },\n extract,\n )\n : async () => undefined,\n };\n }\n\n /** Walk every item across every page, starting from a first-page promise. */\n protected async *iterate<T>(first: Promise<Page<T>>): AsyncGenerator<T> {\n let page: Page<T> | undefined = await first;\n while (page) {\n for (const item of page.items) yield item;\n page = await page.next();\n }\n }\n}\n","// Service status and key validation. These two endpoints need no parameters and\n// are the quickest way to confirm a key works and which environment it belongs\n// to before any money moves.\n\nimport { Resource } from \"./base\";\nimport type { ServiceHealth, ValidateResult } from \"../types\";\n\nexport class Core extends Resource {\n /** Check the API and each operator's reachability. */\n ping(signal?: AbortSignal): Promise<ServiceHealth> {\n return this.getData<ServiceHealth>(\"ping\", undefined, signal);\n }\n\n /** Confirm the key and read its environment, scope, and IP allowlist. */\n validate(signal?: AbortSignal): Promise<ValidateResult> {\n return this.getData<ValidateResult>(\"validate\", undefined, signal);\n }\n}\n","// Account balance and the transaction ledger. Balance is a single number; the\n// ledger is paginated, so it comes back as a Page you can step through or as an\n// async iterator that walks the whole history.\n\nimport { Resource, type Page } from \"./base\";\nimport type { Envelope, Pagination } from \"../http\";\nimport type { Balance, Transaction, TransactionsParams } from \"../types\";\n\n/** The transactions endpoint nests its items and pagination inside `data`. */\nfunction extractTransactions(env: Envelope<unknown>): {\n items: Transaction[];\n pagination: Pagination;\n} {\n const d = (env.data ?? {}) as {\n items?: Transaction[];\n pagination?: Pagination;\n };\n return {\n items: d.items ?? [],\n pagination:\n d.pagination ?? { page: 1, pageSize: 0, totalPages: 1, totalResults: 0 },\n };\n}\n\nexport class Account extends Resource {\n /** The current balance in dinars. */\n balance(signal?: AbortSignal): Promise<Balance> {\n return this.getData<Balance>(\"account/balance\", undefined, signal);\n }\n\n /** One page of the transaction ledger, newest first. */\n transactions(params: TransactionsParams = {}): Promise<Page<Transaction>> {\n return this.fetchPage<Transaction>(\n \"account/transactions\",\n { ...params },\n extractTransactions,\n );\n }\n\n /** Every transaction across every page, as an async iterator. */\n paginateTransactions(\n params: TransactionsParams = {},\n ): AsyncGenerator<Transaction> {\n return this.iterate(this.transactions(params));\n }\n}\n","// Shared types: the response status unions every product polls against, and the\n// account-level entities. Product-specific entities (plans, products, gift-card\n// catalogs, payment links) live with their resources.\n\nimport type { Pagination } from \"./http\";\n\n/**\n * Where a mobile or internet top-up sits in its lifecycle. PENDING and HANDLING\n * are in-flight; the rest are final. QUEUED only appears for internet orders.\n * UNKNOWN_ERROR means the outcome is undecided and can still settle within 24h,\n * which is why a top-up should not be treated as failed the moment it shows up.\n */\nexport type TopupStatus =\n | \"PENDING\"\n | \"HANDLING\"\n | \"QUEUED\"\n | \"FULFILLED\"\n | \"REFUNDED\"\n | \"UNKNOWN_ERROR\";\n\n/** A gift-card order's lifecycle. PARTIALLY_FILLED means some cards came through. */\nexport type GiftOrderStatus =\n | \"HANDLING\"\n | \"FULFILLED\"\n | \"PARTIALLY_FILLED\"\n | \"REFUNDED\";\n\n/** A Navio payment link's lifecycle. */\nexport type PaymentStatus = \"PENDING\" | \"CONFIRMED\" | \"FAILED\";\n\n/** The top-up statuses at which polling stops. */\nexport const TOPUP_TERMINAL: readonly TopupStatus[] = [\n \"FULFILLED\",\n \"REFUNDED\",\n \"UNKNOWN_ERROR\",\n];\n\n/** The gift-card order statuses at which polling stops. */\nexport const GIFT_TERMINAL: readonly GiftOrderStatus[] = [\n \"FULFILLED\",\n \"PARTIALLY_FILLED\",\n \"REFUNDED\",\n];\n\n/** The payment statuses at which polling stops. */\nexport const PAYMENT_TERMINAL: readonly PaymentStatus[] = [\n \"CONFIRMED\",\n \"FAILED\",\n];\n\nexport type KeyType = \"SANDBOX\" | \"PRODUCTION\";\nexport type KeyScope = \"READ-WRITE\" | \"READ-ONLY\";\n\nexport interface ApiKeyInfo {\n key: string;\n isEnabled: boolean;\n type: KeyType;\n /** Allowed source IPs. An empty array means any IP is accepted. */\n allowedips: string[];\n scope: KeyScope;\n}\n\n/** What `validate()` returns: the account name and the key's own settings. */\nexport interface ValidateResult {\n username: string;\n apiKey: ApiKeyInfo;\n}\n\n/** What `ping()` returns: the API's own status and each operator's reachability. */\nexport interface ServiceHealth {\n api: string;\n operators: Record<string, string>;\n}\n\nexport interface Balance {\n /** Current account balance in dinars. */\n balance: number;\n}\n\nexport interface Transaction {\n _id: string;\n /** The kind of movement, such as a top-up or a deposit. */\n type: string;\n /** The direction of the movement: increment or decrement. */\n operation: string;\n amount: number;\n oldBalance: number;\n newBalance: number;\n /** The id of the related order, when there is one. */\n objid: string;\n note: string;\n time: string;\n}\n\nexport interface TransactionsParams {\n page?: number;\n pageSize?: number;\n /** ISO 8601 start of the date filter. Pass `to` alongside it. */\n from?: string;\n /** ISO 8601 end of the date filter. Pass `from` alongside it. */\n to?: string;\n}\n\n/** A paginated `{ items, pagination }` payload, the shape list endpoints return. */\nexport interface ItemsPage<T> {\n items: T[];\n pagination: Pagination;\n}\n","// The polling engine behind every `*AndWait` helper. The recharge endpoints are\n// asynchronous: you send an order, then check its status until it settles.\n// Webhooks are not available yet, so polling is the only way to learn the\n// outcome. This keeps the loop in one place so each resource just supplies a\n// fetcher and a \"done yet?\" predicate.\n\nimport { OneClickError } from \"./errors\";\n\nexport interface PollOptions {\n /** Milliseconds between checks. The docs recommend a fixed 5s. */\n intervalMs?: number;\n /** How many checks before giving up. */\n maxAttempts?: number;\n /** Cancel the wait early. The pending delay rejects at once when aborted. */\n signal?: AbortSignal;\n}\n\n/** Raised when a status never reaches a terminal state within the attempt budget. */\nexport class PollTimeoutError extends OneClickError {\n /** The most recent value seen before time ran out. */\n readonly last: unknown;\n\n constructor(message: string, last: unknown, attempts: number) {\n super(message, \"poll_timeout\", { details: { attempts } });\n this.last = last;\n }\n}\n\n/**\n * Call `fetchOnce` until `isDone` accepts the result, then return that result.\n * The first check happens immediately; the interval only applies between checks,\n * so a status that is already settled returns without an extra wait.\n */\nexport async function pollUntil<T>(\n fetchOnce: () => Promise<T>,\n isDone: (value: T) => boolean,\n options: PollOptions = {},\n): Promise<T> {\n const intervalMs = options.intervalMs ?? 5000;\n const maxAttempts = Math.max(1, options.maxAttempts ?? 60);\n\n let last: T | undefined;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n throwIfAborted(options.signal);\n last = await fetchOnce();\n if (isDone(last)) return last;\n if (attempt < maxAttempts) await delay(intervalMs, options.signal);\n }\n\n throw new PollTimeoutError(\n `Gave up after ${maxAttempts} checks without a final status.`,\n last,\n maxAttempts,\n );\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) throw abortReason(signal);\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n const reason = (signal as { reason?: unknown }).reason;\n if (reason !== undefined) return reason;\n const error = new Error(\"The wait was aborted.\");\n error.name = \"AbortError\";\n return error;\n}\n\n/** A sleep that rejects the moment its signal aborts, rather than after the full wait. */\nfunction delay(ms: number, signal: AbortSignal | undefined): Promise<void> {\n return new Promise((resolve, reject) => {\n const onAbort = () => {\n clearTimeout(timer);\n reject(abortReason(signal!));\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, ms);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n","// A small reference generator. Every send accepts a caller `ref`; when one is\n// not given the client makes its own, so a resend after a dropped connection\n// reuses the same reference and the API rejects the duplicate instead of\n// charging the account a second time. That is the whole point of having a ref.\n\n/** Build a unique-enough order reference with a readable prefix. */\nexport function generateRef(prefix = \"ocd\"): string {\n const uuid =\n typeof globalThis.crypto?.randomUUID === \"function\"\n ? globalThis.crypto.randomUUID()\n : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n return `${prefix}-${uuid}`;\n}\n","// Client-side checks that run before a request leaves, so a wrong phone number\n// or an out-of-range amount fails immediately instead of spending a request and\n// a slice of the rate limit. The patterns mirror what the API documents for each\n// service. Each resource composes these primitives with an Issues collector and\n// throws a ValidationError if anything is wrong.\n\nimport { ValidationError, type ValidationIssue } from \"./errors\";\n\n/** Mobile MSISDN: Mobilis, Djezzy, or Ooredoo, ten digits starting 05, 06, or 07. */\nexport const MOBILE_NUMBER = /^0[567]\\d{8}$/;\n/** ADSL line number: nine digits starting with 0. */\nexport const ADSL_NUMBER = /^0\\d{8}$/;\n/** 4G number: the 213 country code followed by nine digits. */\nexport const FOURG_NUMBER = /^213\\d{9}$/;\n\nexport function isMobileNumber(value: string): boolean {\n return MOBILE_NUMBER.test(value);\n}\n\nexport function isAdslNumber(value: string): boolean {\n return ADSL_NUMBER.test(value);\n}\n\nexport function isFourgNumber(value: string): boolean {\n return FOURG_NUMBER.test(value);\n}\n\n/** A whole number of dinars, at or above one. The API has no fractional amounts. */\nexport function isWholeAmount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1;\n}\n\n/**\n * Gathers field problems and turns them into one ValidationError. Using a\n * collector rather than throwing on the first issue means a caller sees every\n * problem with an input at once.\n */\nexport class Issues {\n private readonly list: ValidationIssue[] = [];\n\n /** Record a problem. The ref ties an issue to one order when checking a batch. */\n add(field: string, message: string, ref?: string): this {\n this.list.push(ref ? { field, message, ref } : { field, message });\n return this;\n }\n\n /** Record a problem only when the condition holds. */\n addIf(condition: boolean, field: string, message: string, ref?: string): this {\n if (condition) this.add(field, message, ref);\n return this;\n }\n\n get any(): boolean {\n return this.list.length > 0;\n }\n\n all(): ValidationIssue[] {\n return this.list;\n }\n\n /** Throw if anything was collected; otherwise do nothing. */\n throwIfAny(summary = \"The request did not pass validation.\"): void {\n if (this.list.length > 0) {\n throw new ValidationError(summary, { issues: this.list });\n }\n }\n}\n\n/** A required string field that must be present and non-empty. */\nexport function requireText(\n issues: Issues,\n value: unknown,\n field: string,\n ref?: string,\n): void {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n issues.add(field, \"is required\", ref);\n }\n}\n","// Mobile top-ups for Mobilis, Djezzy, and Ooredoo. Sending is asynchronous: you\n// post an order, get back an id and a reference, then poll until it settles.\n// `send` validates the number and amount client-side and fills in a reference\n// when you leave one out. `sendAndWait` does the whole round trip for you.\n\nimport { Resource, type Page } from \"./base\";\nimport type { Envelope, Pagination } from \"../http\";\nimport type { TopupStatus } from \"../types\";\nimport { TOPUP_TERMINAL } from \"../types\";\nimport { pollUntil, type PollOptions } from \"../poll\";\nimport { generateRef } from \"../ref\";\nimport { Issues, isMobileNumber, isWholeAmount, requireText } from \"../validate\";\n\ninterface MobilePlanBase {\n code: string;\n name: string;\n operator: string;\n /**\n * Your wholesale cost factor. Absent on the wholesale `GROS_*` plans. Do not\n * show it to end users; apply your own markup.\n */\n cost?: number;\n isEnabled: boolean;\n}\n\n/** A plan whose amount you choose, within a range. */\nexport interface DynamicMobilePlan extends MobilePlanBase {\n min_amount: number;\n max_amount: number;\n}\n\n/** A plan with a fixed amount, such as a data pack. */\nexport interface FixedMobilePlan extends MobilePlanBase {\n amount: number;\n}\n\nexport interface MobilePlans {\n dynamicPlans: DynamicMobilePlan[];\n fixedPlans: FixedMobilePlan[];\n}\n\nexport interface MobileSendInput {\n /** A plan code from `plans()`, such as `PREPAID_DJEZZY`. */\n plan_code: string;\n /** The recipient number: ten digits starting 05, 06, or 07. */\n MSSIDN: string;\n /** Required for dynamic plans, within the plan's min and max. */\n amount?: number;\n /** Your order reference. One is generated when omitted. */\n ref?: string;\n}\n\nexport interface MobileSendResult {\n topupId: string;\n topupRef: string;\n}\n\n/** A retry the API suggests after a refund. */\nexport interface SuggestedOffer {\n typename: string;\n plan_code: string;\n amount: number;\n}\n\nexport interface MobileTopup {\n _id: string;\n ref?: string;\n status: TopupStatus;\n plan_code: string;\n MSSIDN: string;\n topup_amount: number;\n balance_amount: number;\n created_at: string;\n /** Present on a REFUNDED order, explaining why it did not go through. */\n refund_message?: string;\n /** Alternative offers to try after a refund. */\n suggested_offers?: SuggestedOffer[];\n follow_orderid?: string;\n retry_orderid?: string;\n}\n\nexport interface MobileListParams {\n page?: number;\n pageSize?: number;\n from?: string;\n to?: string;\n}\n\nfunction extractTopups(env: Envelope<unknown>): {\n items: MobileTopup[];\n pagination: Pagination;\n} {\n const d = (env.data ?? {}) as {\n items?: MobileTopup[];\n pagination?: Pagination;\n };\n return {\n items: d.items ?? [],\n pagination:\n d.pagination ?? { page: 1, pageSize: 0, totalPages: 1, totalResults: 0 },\n };\n}\n\nfunction validateSend(input: MobileSendInput): void {\n const issues = new Issues();\n requireText(issues, input.plan_code, \"plan_code\");\n if (typeof input.MSSIDN !== \"string\" || !isMobileNumber(input.MSSIDN)) {\n issues.add(\"MSSIDN\", \"is not a valid mobile number\");\n }\n if (input.amount !== undefined && !isWholeAmount(input.amount)) {\n issues.add(\"amount\", \"must be a whole number of dinars\");\n }\n issues.throwIfAny(\"The top-up did not pass validation.\");\n}\n\nconst isTerminal = (t: MobileTopup): boolean =>\n TOPUP_TERMINAL.includes(t.status);\n\nexport class Mobile extends Resource {\n /** The plans available to your account, split into dynamic and fixed. */\n plans(signal?: AbortSignal): Promise<MobilePlans> {\n return this.getData<MobilePlans>(\"mobile/plans\", undefined, signal);\n }\n\n /**\n * Send a top-up. The number and amount are checked first, and a reference is\n * generated when you do not pass one, so the returned `topupRef` is always set.\n */\n async send(\n input: MobileSendInput,\n signal?: AbortSignal,\n ): Promise<MobileSendResult> {\n validateSend(input);\n const body = { ...input, ref: input.ref ?? generateRef() };\n return this.postData<MobileSendResult>(\"mobile/send\", body, signal);\n }\n\n /** Look a top-up up by your own reference. */\n checkByRef(ref: string, signal?: AbortSignal): Promise<MobileTopup> {\n return this.getData<MobileTopup>(\n `mobile/check-ref/${encodeURIComponent(ref)}`,\n undefined,\n signal,\n );\n }\n\n /** Look a top-up up by the id from `send`. */\n checkById(id: string, signal?: AbortSignal): Promise<MobileTopup> {\n return this.getData<MobileTopup>(\n `mobile/check-id/${encodeURIComponent(id)}`,\n undefined,\n signal,\n );\n }\n\n /**\n * Send a top-up and wait for it to settle, polling by reference. Resolves with\n * the final top-up once it is FULFILLED, REFUNDED, or UNKNOWN_ERROR. Defaults\n * to a check every 5 seconds for up to 5 minutes, which the docs recommend.\n */\n async sendAndWait(\n input: MobileSendInput,\n options: PollOptions = {},\n ): Promise<MobileTopup> {\n const ref = input.ref ?? generateRef();\n await this.send({ ...input, ref }, options.signal);\n return pollUntil(() => this.checkByRef(ref, options.signal), isTerminal, {\n intervalMs: 5000,\n maxAttempts: 60,\n ...options,\n });\n }\n\n /** One page of your past top-ups, newest first. */\n list(params: MobileListParams = {}): Promise<Page<MobileTopup>> {\n return this.fetchPage<MobileTopup>(\"mobile/list\", { ...params }, extractTopups);\n }\n\n /** Every past top-up across every page, as an async iterator. */\n paginate(params: MobileListParams = {}): AsyncGenerator<MobileTopup> {\n return this.iterate(this.list(params));\n }\n}\n","// A wrapper for values that must not end up in logs: gift-card codes, serials,\n// and internet recharge codes. The docs are explicit that card codes should\n// never be written out in plain text, so the SDK hands them back inside a Secret\n// that renders as a placeholder everywhere a value is normally stringified, and\n// only gives up the real value when you ask for it with `reveal()`.\n\nconst REDACTED = \"[redacted]\";\n\n// The symbol Node's console and util.inspect look for. Referencing it by name\n// rather than importing `util` keeps this file free of any Node-only import, so\n// it works the same on edge runtimes.\nconst INSPECT = Symbol.for(\"nodejs.util.inspect.custom\");\n\nexport class Secret<T = string> {\n // A private field is neither enumerable nor reachable by Object.keys or a\n // spread, so the value cannot leak through ordinary object handling.\n readonly #value: T;\n\n constructor(value: T) {\n this.#value = value;\n }\n\n /** The real value. Calling this is the deliberate, searchable moment a secret is read. */\n reveal(): T {\n return this.#value;\n }\n\n /** Used by JSON.stringify, so a secret nested in an object serializes redacted. */\n toJSON(): string {\n return REDACTED;\n }\n\n toString(): string {\n return REDACTED;\n }\n\n [INSPECT](): string {\n return `Secret(${REDACTED})`;\n }\n\n static of<T>(value: T): Secret<T> {\n return new Secret(value);\n }\n}\n\nexport function isSecret(value: unknown): value is Secret<unknown> {\n return value instanceof Secret;\n}\n\n/** Reveal a value whether or not it is wrapped, for code that handles both. */\nexport function reveal<T>(value: Secret<T> | T): T {\n return value instanceof Secret ? value.reveal() : value;\n}\n","// ADSL and 4G internet recharges. The flow matches mobile: validate the number,\n// send, then poll. The difference is the payload: a settled order carries a\n// `card_code`, the recharge code the customer keys in. That code comes back\n// wrapped in a Secret so it stays out of logs until you call `reveal()`.\n\nimport { Resource, type Page } from \"./base\";\nimport type { Envelope, Pagination } from \"../http\";\nimport type { TopupStatus } from \"../types\";\nimport { TOPUP_TERMINAL } from \"../types\";\nimport { pollUntil, type PollOptions } from \"../poll\";\nimport { generateRef } from \"../ref\";\nimport {\n Issues,\n isAdslNumber,\n isFourgNumber,\n isWholeAmount,\n} from \"../validate\";\nimport { Secret } from \"../secret\";\n\nexport type InternetType = \"ADSL\" | \"4G\";\n\nexport interface InternetProduct {\n /** Your wholesale cost. Strip this before showing products to end users. */\n cost: number;\n /** The card's face value in dinars. */\n value: number;\n available: boolean;\n}\n\nexport interface InternetProducts {\n products: InternetProduct[];\n type: string;\n}\n\nexport interface NumberCheck {\n /** The masked client identifier the API returns for a valid line. */\n ncli: string;\n type: string;\n /** The current offer, for ADSL lines. */\n offre?: string;\n}\n\nexport interface InternetSendInput {\n type: InternetType;\n /** ADSL: nine digits starting 0. 4G: 213 followed by nine digits. */\n number: string;\n /** A face value from `products()`. */\n value: number;\n /** Your order reference. One is generated when omitted. */\n ref?: string;\n}\n\nexport interface InternetSendResult {\n topupId: string;\n topupRef: string;\n}\n\nexport interface InternetTopup {\n _id: string;\n ref?: string;\n status: TopupStatus;\n type: string;\n number: string;\n topup_amount: number;\n /** The recharge code, present once FULFILLED. Call `.reveal()` to read it. */\n card_code?: Secret<string>;\n num_trans?: string;\n date_traitement?: string;\n created_at: string;\n}\n\nexport interface InternetListParams {\n page?: number;\n pageSize?: number;\n from?: string;\n to?: string;\n}\n\ninterface RawInternetTopup {\n _id: string;\n ref?: string;\n status: TopupStatus;\n type: string;\n number: string;\n topup_amount: number;\n card_code?: string;\n num_trans?: string;\n date_traitement?: string;\n created_at: string;\n}\n\n/** Wrap the recharge code so it cannot be logged by accident. */\nfunction toTopup(raw: RawInternetTopup): InternetTopup {\n const { card_code, ...rest } = raw;\n return card_code\n ? { ...rest, card_code: Secret.of(card_code) }\n : { ...rest };\n}\n\n/**\n * The internet list endpoint is the odd one out: items sit under `topups` and\n * pagination under `meta.pagination` with its own field names. Normalize both.\n */\nfunction extractInternetTopups(env: Envelope<unknown>): {\n items: InternetTopup[];\n pagination: Pagination;\n} {\n const data = (env.data ?? {}) as { topups?: RawInternetTopup[] };\n const page = (env.meta?.pagination ?? {}) as {\n currentPage?: number;\n page?: number;\n totalPages?: number;\n totalItems?: number;\n totalResults?: number;\n };\n const items = (data.topups ?? []).map(toTopup);\n return {\n items,\n pagination: {\n page: page.currentPage ?? page.page ?? 1,\n pageSize: items.length,\n totalPages: page.totalPages ?? 1,\n totalResults: page.totalItems ?? page.totalResults ?? items.length,\n },\n };\n}\n\nfunction validateSend(input: InternetSendInput): void {\n const issues = new Issues();\n if (input.type !== \"ADSL\" && input.type !== \"4G\") {\n issues.add(\"type\", \"must be ADSL or 4G\");\n } else if (input.type === \"ADSL\" && !isAdslNumber(input.number)) {\n issues.add(\"number\", \"is not a valid ADSL number\");\n } else if (input.type === \"4G\" && !isFourgNumber(input.number)) {\n issues.add(\"number\", \"is not a valid 4G number\");\n }\n if (!isWholeAmount(input.value)) {\n issues.add(\"value\", \"must be a whole number of dinars\");\n }\n issues.throwIfAny(\"The internet top-up did not pass validation.\");\n}\n\nconst isTerminal = (t: InternetTopup): boolean =>\n TOPUP_TERMINAL.includes(t.status);\n\nexport class Internet extends Resource {\n /** The cards on offer for a service type, with their cost and stock. */\n products(type: InternetType, signal?: AbortSignal): Promise<InternetProducts> {\n return this.getData<InternetProducts>(\"internet/products\", { type }, signal);\n }\n\n /** Confirm a number is valid and active before sending to it. */\n checkNumber(\n type: InternetType,\n number: string,\n signal?: AbortSignal,\n ): Promise<NumberCheck> {\n return this.getData<NumberCheck>(\n \"internet/check-number\",\n { type, number },\n signal,\n );\n }\n\n /** Send a recharge. The number and value are checked first; a ref is filled in. */\n async send(\n input: InternetSendInput,\n signal?: AbortSignal,\n ): Promise<InternetSendResult> {\n validateSend(input);\n const body = { ...input, ref: input.ref ?? generateRef() };\n return this.postData<InternetSendResult>(\"internet/send\", body, signal);\n }\n\n async checkByRef(ref: string, signal?: AbortSignal): Promise<InternetTopup> {\n const raw = await this.getData<RawInternetTopup>(\n `internet/check-ref/${encodeURIComponent(ref)}`,\n undefined,\n signal,\n );\n return toTopup(raw);\n }\n\n async checkById(id: string, signal?: AbortSignal): Promise<InternetTopup> {\n const raw = await this.getData<RawInternetTopup>(\n `internet/check-id/${encodeURIComponent(id)}`,\n undefined,\n signal,\n );\n return toTopup(raw);\n }\n\n /**\n * Send and wait for the recharge to settle. Resolves with the final order,\n * its `card_code` ready to reveal once FULFILLED. A QUEUED order can take up to\n * 48 hours, well past the default polling window, so expect a timeout there.\n */\n async sendAndWait(\n input: InternetSendInput,\n options: PollOptions = {},\n ): Promise<InternetTopup> {\n const ref = input.ref ?? generateRef();\n await this.send({ ...input, ref }, options.signal);\n return pollUntil(() => this.checkByRef(ref, options.signal), isTerminal, {\n intervalMs: 5000,\n maxAttempts: 60,\n ...options,\n });\n }\n\n list(params: InternetListParams = {}): Promise<Page<InternetTopup>> {\n return this.fetchPage<InternetTopup>(\n \"internet/list\",\n { ...params },\n extractInternetTopups,\n );\n }\n\n paginate(params: InternetListParams = {}): AsyncGenerator<InternetTopup> {\n return this.iterate(this.list(params));\n }\n}\n","// Gift cards: a catalog of products, each with one or more denominations, that\n// you order by quantity and then poll until the codes come through. An order can\n// settle as PARTIALLY_FILLED when only some of the cards were in stock. Every\n// card's code and serial come back wrapped in a Secret, since these are bearer\n// credentials that must not be logged.\n\nimport { Resource, type Page } from \"./base\";\nimport type { Envelope, Pagination } from \"../http\";\nimport type { GiftOrderStatus } from \"../types\";\nimport { GIFT_TERMINAL } from \"../types\";\nimport { pollUntil, type PollOptions } from \"../poll\";\nimport { Issues, requireText } from \"../validate\";\nimport { Secret } from \"../secret\";\n\nexport interface GiftProductSummary {\n id: string;\n title: string;\n enabled: boolean;\n /** The region the product is valid in, such as france or turkey. Absent on some products. */\n region?: string;\n}\n\nexport interface GiftCategory {\n title: string;\n products: GiftProductSummary[];\n}\n\nexport interface GiftCatalog {\n categories: GiftCategory[];\n totalCategories?: number;\n totalProducts?: number;\n}\n\nexport interface GiftProductType {\n id: string;\n /** The denomination label, such as \"PSN 500 DA\". */\n name: string;\n /** Your wholesale price. Do not show it to end users. */\n price: number;\n /** Stock on hand. Zero means out of stock. */\n quantity: number;\n}\n\nexport interface GiftProductDetails {\n productId: string;\n productTitle: string;\n types: GiftProductType[];\n}\n\nexport interface GiftOrderInput {\n /** A product id from the catalog. */\n productId: string;\n /** A type id from `checkProduct`. */\n typeId: string;\n /** How many cards to buy. At least one. */\n quantity: number;\n}\n\nexport interface GiftOrderResult {\n orderId: string;\n}\n\n/** A delivered card. Both fields are secrets; call `.reveal()` to read them. */\nexport interface GiftCard {\n value: Secret<string>;\n serial: Secret<string>;\n}\n\nexport interface GiftOrder {\n status: GiftOrderStatus;\n quantity: number;\n fulfilled_quantity: number;\n fulfilled_amount: number;\n price_per_card: number;\n /** Filled once the order is FULFILLED or PARTIALLY_FILLED. */\n cards: GiftCard[];\n /** Present in the order list; the single-order check omits these. */\n _id?: string;\n product?: string;\n type?: string;\n time?: string;\n}\n\nexport interface GiftOrdersParams {\n page?: number;\n pageSize?: number;\n from?: string;\n to?: string;\n}\n\ninterface RawCard {\n value?: string;\n serial?: string;\n}\n\ninterface RawGiftOrder {\n status: GiftOrderStatus;\n quantity: number;\n fulfilled_quantity: number;\n fulfilled_amount: number;\n price_per_card: number;\n cards?: RawCard[];\n _id?: string;\n product?: string;\n type?: string;\n time?: string;\n}\n\n/** Wrap each card's code and serial so neither can be logged by accident. */\nfunction toOrder(raw: RawGiftOrder): GiftOrder {\n const cards = (raw.cards ?? []).map((card) => ({\n value: Secret.of(card.value ?? \"\"),\n serial: Secret.of(card.serial ?? \"\"),\n }));\n return { ...raw, cards };\n}\n\nfunction extractOrders(env: Envelope<unknown>): {\n items: GiftOrder[];\n pagination: Pagination;\n} {\n const d = (env.data ?? {}) as {\n items?: RawGiftOrder[];\n pagination?: Pagination;\n };\n return {\n items: (d.items ?? []).map(toOrder),\n pagination:\n d.pagination ?? { page: 1, pageSize: 0, totalPages: 1, totalResults: 0 },\n };\n}\n\nfunction validateOrder(input: GiftOrderInput): void {\n const issues = new Issues();\n requireText(issues, input.productId, \"productId\");\n requireText(issues, input.typeId, \"typeId\");\n if (!Number.isInteger(input.quantity) || input.quantity < 1) {\n issues.add(\"quantity\", \"must be a whole number of one or more\");\n }\n issues.throwIfAny(\"The gift-card order did not pass validation.\");\n}\n\nconst isTerminal = (o: GiftOrder): boolean => GIFT_TERMINAL.includes(o.status);\n\nexport class GiftCards extends Resource {\n /** The full product catalog. Cache it; the docs say it changes rarely. */\n async catalog(signal?: AbortSignal): Promise<GiftCatalog> {\n const env = await this.http.request<{ categories?: GiftCategory[] }>(\n \"GET\",\n \"gift-cards/catalog\",\n { signal },\n );\n return {\n categories: env.data.categories ?? [],\n totalCategories: env.totalCategories as number | undefined,\n totalProducts: env.totalProducts as number | undefined,\n };\n }\n\n /** A product's denominations, with live pricing and stock. */\n checkProduct(\n productId: string,\n signal?: AbortSignal,\n ): Promise<GiftProductDetails> {\n return this.getData<GiftProductDetails>(\n `gift-cards/checkProduct/${encodeURIComponent(productId)}`,\n undefined,\n signal,\n );\n }\n\n /** Place an order. The product, type, and quantity are checked first. */\n async placeOrder(\n input: GiftOrderInput,\n signal?: AbortSignal,\n ): Promise<GiftOrderResult> {\n validateOrder(input);\n return this.postData<GiftOrderResult>(\n \"gift-cards/placeOrder\",\n input,\n signal,\n );\n }\n\n /** Read an order's status and, once settled, its cards. */\n async checkOrder(orderId: string, signal?: AbortSignal): Promise<GiftOrder> {\n const raw = await this.getData<RawGiftOrder>(\n `gift-cards/checkOrder/${encodeURIComponent(orderId)}`,\n undefined,\n signal,\n );\n return toOrder(raw);\n }\n\n /**\n * Place an order and wait for it to settle. Resolves once the order is\n * FULFILLED, PARTIALLY_FILLED, or REFUNDED. Gift cards can take longer than a\n * top-up, so this checks every 5 seconds for up to 10 minutes by default.\n */\n async placeOrderAndWait(\n input: GiftOrderInput,\n options: PollOptions = {},\n ): Promise<GiftOrder> {\n const { orderId } = await this.placeOrder(input, options.signal);\n return pollUntil(\n () => this.checkOrder(orderId, options.signal),\n isTerminal,\n { intervalMs: 5000, maxAttempts: 120, ...options },\n );\n }\n\n /** One page of past orders, newest first. */\n listOrders(params: GiftOrdersParams = {}): Promise<Page<GiftOrder>> {\n return this.fetchPage<GiftOrder>(\n \"gift-cards/list\",\n { ...params },\n extractOrders,\n );\n }\n\n /** Every past order across every page, as an async iterator. */\n paginateOrders(params: GiftOrdersParams = {}): AsyncGenerator<GiftOrder> {\n return this.iterate(this.listOrders(params));\n }\n}\n","// Navio, the hosted payment gateway (OCPay in the API path). You create a\n// payment link, send the customer to its URL, and poll the reference until the\n// payment is confirmed or fails. A link expires twenty minutes after creation if\n// no payment is started, which is also the default polling window here.\n\nimport { Resource } from \"./base\";\nimport type { PaymentStatus } from \"../types\";\nimport { PAYMENT_TERMINAL } from \"../types\";\nimport { pollUntil, type PollOptions } from \"../poll\";\nimport { Issues, isWholeAmount, requireText } from \"../validate\";\n\n/** Who pays the gateway fee. NO_FEE is the default. */\nexport type FeeMode = \"NO_FEE\" | \"SPLIT_FEE\" | \"CUSTOMER_FEE\";\n\nexport const MIN_PAYMENT_AMOUNT = 500;\nexport const MAX_PAYMENT_AMOUNT = 500_000;\n\nexport interface PaymentProductInfo {\n /** What the customer is paying for. One to two hundred characters. */\n title: string;\n /** Optional details, up to a thousand characters. Markdown is allowed. */\n description?: string;\n /** Amount in dinars: a whole number from 500 to 500000. */\n amount: number;\n}\n\nexport interface CreateLinkInput {\n productInfo: PaymentProductInfo;\n feeMode?: FeeMode;\n /** Shown to the customer after a successful payment, up to 500 characters. */\n successMessage?: string;\n /** Where to send the customer after payment. Must be http or https. */\n redirectUrl?: string;\n}\n\nexport interface PaymentLink {\n uid: string;\n ref: string;\n isSandbox: boolean;\n productInfo: PaymentProductInfo;\n feeMode: FeeMode;\n successMessage?: string;\n redirectUrl?: string;\n time: string;\n}\n\nexport interface CreateLinkResult {\n paymentLink: PaymentLink;\n /** The URL to send the customer to. */\n paymentUrl: string;\n /** The reference to poll with `checkPayment`. */\n paymentRef: string;\n}\n\nexport interface PaymentTransactionDetails {\n amount: number;\n currency: string;\n isSandbox: boolean;\n createdDate: string;\n}\n\nexport interface PaymentCheck {\n status: PaymentStatus;\n message: string;\n paymentRef: string;\n transactionDetails: PaymentTransactionDetails;\n}\n\nfunction validateCreateLink(input: CreateLinkInput): void {\n const issues = new Issues();\n const info = input.productInfo ?? ({} as PaymentProductInfo);\n\n requireText(issues, info.title, \"productInfo.title\");\n if (typeof info.title === \"string\" && info.title.length > 200) {\n issues.add(\"productInfo.title\", \"must be at most 200 characters\");\n }\n if (!isWholeAmount(info.amount)) {\n issues.add(\"productInfo.amount\", \"must be a whole number of dinars\");\n } else if (\n info.amount < MIN_PAYMENT_AMOUNT ||\n info.amount > MAX_PAYMENT_AMOUNT\n ) {\n issues.add(\n \"productInfo.amount\",\n `must be between ${MIN_PAYMENT_AMOUNT} and ${MAX_PAYMENT_AMOUNT}`,\n );\n }\n if (info.description !== undefined && info.description.length > 1000) {\n issues.add(\"productInfo.description\", \"must be at most 1000 characters\");\n }\n if (input.successMessage !== undefined && input.successMessage.length > 500) {\n issues.add(\"successMessage\", \"must be at most 500 characters\");\n }\n if (\n input.feeMode !== undefined &&\n input.feeMode !== \"NO_FEE\" &&\n input.feeMode !== \"SPLIT_FEE\" &&\n input.feeMode !== \"CUSTOMER_FEE\"\n ) {\n issues.add(\"feeMode\", \"must be NO_FEE, SPLIT_FEE, or CUSTOMER_FEE\");\n }\n if (input.redirectUrl !== undefined && !/^https?:\\/\\//.test(input.redirectUrl)) {\n issues.add(\"redirectUrl\", \"must start with http:// or https://\");\n }\n issues.throwIfAny(\"The payment link did not pass validation.\");\n}\n\nconst isTerminal = (p: PaymentCheck): boolean =>\n PAYMENT_TERMINAL.includes(p.status);\n\nexport class Payments extends Resource {\n /** Create a payment link. Returns the URL to send the customer to. */\n async createLink(\n input: CreateLinkInput,\n signal?: AbortSignal,\n ): Promise<CreateLinkResult> {\n validateCreateLink(input);\n return this.postData<CreateLinkResult>(\"ocpay/createLink\", input, signal);\n }\n\n /** Check a payment's status by its reference. */\n checkPayment(ref: string, signal?: AbortSignal): Promise<PaymentCheck> {\n return this.getData<PaymentCheck>(\n `ocpay/checkPayment/${encodeURIComponent(ref)}`,\n undefined,\n signal,\n );\n }\n\n /**\n * Poll a payment until it is CONFIRMED or FAILED. The default window is twenty\n * minutes, matching how long an unpaid link stays open; a payment that is\n * never started times out with a PollTimeoutError. Pass a signal to stop early.\n */\n waitForPayment(ref: string, options: PollOptions = {}): Promise<PaymentCheck> {\n return pollUntil(\n () => this.checkPayment(ref, options.signal),\n isTerminal,\n { intervalMs: 5000, maxAttempts: 240, ...options },\n );\n }\n}\n","// The client. One instance holds the key and the transport, and exposes a\n// resource per product. Construct it once and reuse it: the resources are thin\n// and share the same HttpClient, so there is nothing to pool or close.\n\nimport { HttpClient, type FetchLike, type RetryConfig } from \"./http\";\nimport { Core } from \"./resources/core\";\nimport { Account } from \"./resources/account\";\nimport { Mobile } from \"./resources/mobile\";\nimport { Internet } from \"./resources/internet\";\nimport { GiftCards } from \"./resources/giftcards\";\nimport { Payments } from \"./resources/payments\";\nimport type { ServiceHealth, ValidateResult } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://api.oneclickdz.com/v3\";\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_RETRY: RetryConfig = { attempts: 3, respectRetryAfter: true };\n\nexport interface OneClickDZOptions {\n /** Your access token, sandbox or production, from the dashboard. */\n key: string;\n /** Defaults to the production v3 endpoint. */\n baseUrl?: string;\n /** Per-request timeout in milliseconds. Defaults to 30000. */\n timeoutMs?: number;\n /** Override either retry field; the rest keep their defaults. */\n retry?: Partial<RetryConfig>;\n /** Supply a fetch for older runtimes or for tests. Defaults to the global. */\n fetch?: FetchLike;\n}\n\nexport class OneClickDZ {\n readonly core: Core;\n readonly account: Account;\n readonly mobile: Mobile;\n readonly internet: Internet;\n readonly giftCards: GiftCards;\n readonly payments: Payments;\n\n private readonly http: HttpClient;\n\n constructor(options: OneClickDZOptions) {\n if (!options.key) {\n throw new Error(\"OneClickDZ needs an access token in options.key.\");\n }\n\n const fetchImpl = options.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new Error(\n \"No fetch is available. Run on Node 18+ or pass one in options.fetch.\",\n );\n }\n\n this.http = new HttpClient({\n key: options.key,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n retry: { ...DEFAULT_RETRY, ...options.retry },\n fetch: fetchImpl,\n });\n\n this.core = new Core(this.http);\n this.account = new Account(this.http);\n this.mobile = new Mobile(this.http);\n this.internet = new Internet(this.http);\n this.giftCards = new GiftCards(this.http);\n this.payments = new Payments(this.http);\n }\n\n /** Shortcut for `core.ping()`: the API and operator status. */\n ping(signal?: AbortSignal): Promise<ServiceHealth> {\n return this.core.ping(signal);\n }\n\n /** Shortcut for `core.validate()`: confirm the key and read its environment. */\n validate(signal?: AbortSignal): Promise<ValidateResult> {\n return this.core.validate(signal);\n }\n}\n","// Resale pricing. The API returns your wholesale cost on internet products and\n// gift-card types, and the docs are blunt that you must strip it and add your own\n// markup before showing anything to a customer. Resellers are the whole audience\n// here, so that step lives in the SDK: pick a markup, get back a customer-safe\n// list with the cost gone and a sell price in its place.\n\nimport type { InternetProduct } from \"./resources/internet\";\nimport type { GiftProductType } from \"./resources/giftcards\";\n\n/** A markup as a percentage of cost, or a flat number of dinars added on top. */\nexport type Markup = { percent: number } | { flat: number };\n\n/** Apply a markup to a wholesale cost and round to a whole dinar. */\nexport function sellPrice(cost: number, markup: Markup): number {\n const raw =\n \"percent\" in markup ? cost * (1 + markup.percent / 100) : cost + markup.flat;\n return Math.round(raw);\n}\n\n/** An internet product as a customer should see it: face value, sell price, stock. */\nexport interface CustomerInternetProduct {\n value: number;\n price: number;\n available: boolean;\n}\n\n/**\n * Turn the raw internet products into a customer-facing list. The wholesale\n * `cost` is dropped and `price` is your sell price for the card's face value.\n */\nexport function priceInternetProducts(\n products: InternetProduct[],\n markup: Markup,\n): CustomerInternetProduct[] {\n return products.map((p) => ({\n value: p.value,\n price: sellPrice(p.cost, markup),\n available: p.available,\n }));\n}\n\n/** A gift-card denomination as a customer should see it, with cost removed. */\nexport interface CustomerGiftType {\n id: string;\n name: string;\n price: number;\n inStock: boolean;\n}\n\n/**\n * Turn a product's types into a customer-facing list. The wholesale `price` is\n * replaced by your sell price, and stock collapses to a single boolean.\n */\nexport function priceGiftTypes(\n types: GiftProductType[],\n markup: Markup,\n): CustomerGiftType[] {\n return types.map((t) => ({\n id: t.id,\n name: t.name,\n price: sellPrice(t.price, markup),\n inStock: t.quantity > 0,\n }));\n}\n","// Public entry point.\nexport const VERSION = \"0.1.0\";\n\nexport { OneClickDZ } from \"./client\";\nexport type { OneClickDZOptions } from \"./client\";\n\nexport { Core } from \"./resources/core\";\nexport { Account } from \"./resources/account\";\nexport { Mobile } from \"./resources/mobile\";\nexport { Internet } from \"./resources/internet\";\nexport { GiftCards } from \"./resources/giftcards\";\nexport { Payments } from \"./resources/payments\";\n\nexport {\n OneClickError,\n AuthError,\n ForbiddenError,\n InsufficientBalanceError,\n DuplicateRefError,\n ValidationError,\n NotFoundError,\n RateLimitError,\n ServiceError,\n NetworkError,\n RequestError,\n errorFromResponse,\n} from \"./errors\";\nexport type {\n OneClickErrorCode,\n OneClickErrorOptions,\n ValidationIssue,\n ValidationErrorOptions,\n RateLimitErrorOptions,\n} from \"./errors\";\n\nexport type {\n HttpMethod,\n FetchLike,\n RetryConfig,\n Pagination,\n ResponseMeta,\n Envelope,\n} from \"./http\";\n\nexport { Secret, isSecret, reveal } from \"./secret\";\n\nexport { pollUntil, PollTimeoutError } from \"./poll\";\nexport type { PollOptions } from \"./poll\";\n\nexport {\n Issues,\n requireText,\n isMobileNumber,\n isAdslNumber,\n isFourgNumber,\n isWholeAmount,\n MOBILE_NUMBER,\n ADSL_NUMBER,\n FOURG_NUMBER,\n} from \"./validate\";\n\nexport type { Page } from \"./resources/base\";\n\nexport { generateRef } from \"./ref\";\n\nexport {\n sellPrice,\n priceInternetProducts,\n priceGiftTypes,\n} from \"./pricing\";\nexport type {\n Markup,\n CustomerInternetProduct,\n CustomerGiftType,\n} from \"./pricing\";\n\nexport type {\n MobilePlans,\n DynamicMobilePlan,\n FixedMobilePlan,\n MobileSendInput,\n MobileSendResult,\n MobileTopup,\n SuggestedOffer,\n MobileListParams,\n} from \"./resources/mobile\";\n\nexport type {\n InternetType,\n InternetProduct,\n InternetProducts,\n NumberCheck,\n InternetSendInput,\n InternetSendResult,\n InternetTopup,\n InternetListParams,\n} from \"./resources/internet\";\n\nexport type {\n GiftProductSummary,\n GiftCategory,\n GiftCatalog,\n GiftProductType,\n GiftProductDetails,\n GiftOrderInput,\n GiftOrderResult,\n GiftCard,\n GiftOrder,\n GiftOrdersParams,\n} from \"./resources/giftcards\";\n\nexport {\n MIN_PAYMENT_AMOUNT,\n MAX_PAYMENT_AMOUNT,\n} from \"./resources/payments\";\nexport type {\n FeeMode,\n PaymentProductInfo,\n CreateLinkInput,\n PaymentLink,\n CreateLinkResult,\n PaymentTransactionDetails,\n PaymentCheck,\n} from \"./resources/payments\";\n\nexport {\n TOPUP_TERMINAL,\n GIFT_TERMINAL,\n PAYMENT_TERMINAL,\n} from \"./types\";\nexport type {\n TopupStatus,\n GiftOrderStatus,\n PaymentStatus,\n KeyType,\n KeyScope,\n ApiKeyInfo,\n ValidateResult,\n ServiceHealth,\n Balance,\n Transaction,\n TransactionsParams,\n ItemsPage,\n} from \"./types\";\n"]}
|