agentref 1.0.4 → 1.0.5

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.5
4
+
5
+ - **Fix:** `merchant.updatePayoutInfo()` now sends `PATCH` instead of `PUT` to match the API contract.
6
+ - Added optional `include` parameter to `affiliates.get(id, { include: 'stats' })` for fetching aggregated stats.
7
+
3
8
  ## 1.0.4
4
9
 
5
10
  - Added `search`, `sortBy`, `sortOrder`, `status` parameters to `affiliates.list()`.
package/dist/index.cjs CHANGED
@@ -93,7 +93,7 @@ var SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
93
93
  var DEFAULT_BASE_URL = "https://www.agentref.dev/api/v1";
94
94
  var DEFAULT_TIMEOUT = 3e4;
95
95
  var DEFAULT_MAX_RETRIES = 2;
96
- var VERSION = true ? "1.0.4" : "0.0.0";
96
+ var VERSION = true ? "1.0.5" : "0.0.0";
97
97
  function hasUsableIdempotencyKey(idempotencyKey) {
98
98
  return typeof idempotencyKey === "string" && idempotencyKey.trim().length > 0;
99
99
  }
@@ -223,10 +223,11 @@ var AffiliatesResource = class {
223
223
  list(params) {
224
224
  return this.http.request({ method: "GET", path: "/affiliates", query: params });
225
225
  }
226
- async get(id) {
226
+ async get(id, options) {
227
227
  const envelope = await this.http.request({
228
228
  method: "GET",
229
- path: `/affiliates/${id}`
229
+ path: `/affiliates/${id}`,
230
+ query: options?.include ? { include: options.include } : void 0
230
231
  });
231
232
  return envelope.data;
232
233
  }
@@ -373,6 +374,36 @@ var MerchantResource = class {
373
374
  });
374
375
  return envelope.data;
375
376
  }
377
+ async getPayoutInfo() {
378
+ const envelope = await this.http.request({
379
+ method: "GET",
380
+ path: "/me/payout-info"
381
+ });
382
+ return envelope.data;
383
+ }
384
+ async updatePayoutInfo(data) {
385
+ const envelope = await this.http.request({
386
+ method: "PATCH",
387
+ path: "/me/payout-info",
388
+ body: data
389
+ });
390
+ return envelope.data;
391
+ }
392
+ async getNotifications() {
393
+ const envelope = await this.http.request({
394
+ method: "GET",
395
+ path: "/merchant/notifications"
396
+ });
397
+ return envelope.data;
398
+ }
399
+ async updateNotifications(data) {
400
+ const envelope = await this.http.request({
401
+ method: "PUT",
402
+ path: "/merchant/notifications",
403
+ body: data
404
+ });
405
+ return envelope.data;
406
+ }
376
407
  };
377
408
 
378
409
  // src/resources/payouts.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/affiliates.ts","../src/resources/billing.ts","../src/resources/conversions.ts","../src/resources/flags.ts","../src/resources/merchant.ts","../src/resources/payouts.ts","../src/resources/programs.ts","../src/client.ts"],"sourcesContent":["export { AgentRef } from './client.js'\nexport {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nexport type {\n AgentRefConfig,\n Affiliate,\n AffiliateStatus,\n BillingStatus,\n BillingTier,\n BillingTierId,\n CommissionType,\n CreatePayoutParams,\n Conversion,\n ConversionStats,\n ConversionStatus,\n Coupon,\n CreateCouponParams,\n CreateProgramParams,\n Flag,\n FlagStats,\n FlagStatus,\n FlagType,\n Invite,\n Merchant,\n MutationOptions,\n PaginatedResponse,\n PaginationMeta,\n PendingAffiliate,\n Payout,\n ProgramMarketplaceVisibility,\n PayoutStats,\n PayoutStatus,\n Program,\n ProgramStats,\n ProgramStatus,\n StripeConnectSession,\n MerchantDomainStatus,\n UpdateMerchantParams,\n UpdateProgramMarketplaceParams,\n ResolveFlagParams,\n UpdateProgramParams,\n} from './types/index.js'\n","export class AgentRefError extends Error {\n readonly code: string\n readonly status: number\n readonly requestId: string\n\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message)\n this.name = 'AgentRefError'\n this.code = code\n this.status = status\n this.requestId = requestId\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 401, requestId)\n this.name = 'AuthError'\n }\n}\n\nexport class ForbiddenError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 403, requestId)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class ValidationError extends AgentRefError {\n readonly details: unknown\n\n constructor(message: string, code: string, requestId: string, details?: unknown) {\n super(message, code, 400, requestId)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class NotFoundError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 404, requestId)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 409, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends AgentRefError {\n readonly retryAfter: number\n\n constructor(message: string, code: string, requestId: string, retryAfter: number) {\n super(message, code, 429, requestId)\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class ServerError extends AgentRefError {\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message, code, status, requestId)\n this.name = 'ServerError'\n }\n}\n","import {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nimport type { AgentRefConfig } from './types/index.js'\n\nexport type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE'\n\nconst SAFE_METHODS: ReadonlySet<HttpMethod> = new Set(['GET', 'HEAD'])\n\nexport interface RequestOptions {\n method: HttpMethod\n path: string\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n idempotencyKey?: string\n}\n\nconst DEFAULT_BASE_URL = 'https://www.agentref.dev/api/v1'\nconst DEFAULT_TIMEOUT = 30_000\nconst DEFAULT_MAX_RETRIES = 2\n\ndeclare const __SDK_VERSION__: string\nconst VERSION = typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : '0.0.0'\n\nfunction hasUsableIdempotencyKey(idempotencyKey: string | undefined): boolean {\n return typeof idempotencyKey === 'string' && idempotencyKey.trim().length > 0\n}\n\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n\n constructor(config: AgentRefConfig = {}) {\n if (typeof window !== 'undefined' && !config.dangerouslyAllowBrowser) {\n throw new Error(\n '[AgentRef] Refusing to initialize in browser context. API keys must not be exposed client-side. Use a server-side proxy to call the AgentRef API instead. To override: set dangerouslyAllowBrowser: true (understand the security implications first).'\n )\n }\n\n const apiKey = config.apiKey ?? process.env['AGENTREF_API_KEY']\n if (!apiKey) {\n throw new Error(\n '[AgentRef] API key is required. Pass it as apiKey or set the AGENTREF_API_KEY environment variable.'\n )\n }\n\n this.apiKey = apiKey\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query)\n const isSafe = SAFE_METHODS.has(options.method)\n const hasIdempotency = options.method === 'POST' && hasUsableIdempotencyKey(options.idempotencyKey)\n const canRetry = isSafe || hasIdempotency\n const maxAttempts = canRetry ? this.maxRetries + 1 : 1\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n let response: Response\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': `agentref-node/${VERSION}`,\n }\n\n if (hasIdempotency) {\n headers['Idempotency-Key'] = options.idempotencyKey!.trim()\n }\n\n response = await fetch(url, {\n method: options.method,\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: AbortSignal.timeout(this.timeout),\n })\n } catch (error) {\n if (canRetry && attempt < maxAttempts - 1) {\n await this.wait(this.backoff(attempt))\n continue\n }\n throw error\n }\n\n if (!response.ok) {\n const parsedError = await this.parseError(response)\n\n if (canRetry && this.isRetryable(response.status) && attempt < maxAttempts - 1) {\n const delay =\n response.status === 429\n ? this.retryAfterToMs(response.headers.get('Retry-After'))\n : this.backoff(attempt)\n await this.wait(delay)\n continue\n }\n\n throw parsedError\n }\n\n return response.json() as Promise<T>\n }\n\n throw new ServerError('Request failed after retries', 'REQUEST_RETRY_EXHAUSTED', 500, '')\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n const url = new URL(`${this.baseUrl}${normalizedPath}`)\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n return url.toString()\n }\n\n private async parseError(response: Response): Promise<AgentRefError> {\n const json = (await response.json().catch(() => ({}))) as {\n error?: { code?: string; message?: string; details?: unknown }\n meta?: { requestId?: string }\n }\n\n const code = json.error?.code ?? 'UNKNOWN_ERROR'\n const message = json.error?.message ?? response.statusText\n const requestId = json.meta?.requestId ?? ''\n const details = json.error?.details\n\n if (response.status === 400) return new ValidationError(message, code, requestId, details)\n if (response.status === 401) return new AuthError(message, code, requestId)\n if (response.status === 403) return new ForbiddenError(message, code, requestId)\n if (response.status === 404) return new NotFoundError(message, code, requestId)\n if (response.status === 409) return new ConflictError(message, code, requestId)\n if (response.status === 429) {\n return new RateLimitError(message, code, requestId, this.retryAfterToSeconds(response.headers.get('Retry-After')))\n }\n\n return new ServerError(message, code, response.status, requestId)\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500\n }\n\n private retryAfterToSeconds(headerValue: string | null): number {\n if (!headerValue) return 60\n\n const numericSeconds = Number(headerValue)\n if (!Number.isNaN(numericSeconds) && numericSeconds >= 0) {\n return Math.ceil(numericSeconds)\n }\n\n const asDate = Date.parse(headerValue)\n if (!Number.isNaN(asDate)) {\n const deltaMs = asDate - Date.now()\n return Math.max(0, Math.ceil(deltaMs / 1000))\n }\n\n return 60\n }\n\n private retryAfterToMs(headerValue: string | null): number {\n return this.retryAfterToSeconds(headerValue) * 1000\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms)\n })\n }\n\n private backoff(attempt: number): number {\n return 500 * Math.pow(2, attempt)\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Affiliate, MutationOptions, PaginatedResponse } from '../types/index.js'\n\nexport class AffiliatesResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n includeBlocked?: boolean\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({ method: 'GET', path: '/affiliates', query: params })\n }\n\n async get(id: string): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'GET',\n path: `/affiliates/${id}`,\n })\n return envelope.data\n }\n\n async approve(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/approve`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async block(id: string, data?: { reason?: string }, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/block`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async unblock(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/unblock`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { BillingStatus, BillingTier, MutationOptions } from '../types/index.js'\n\nexport class BillingResource {\n constructor(private readonly http: HttpClient) {}\n\n async current(): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'GET',\n path: '/billing',\n })\n return envelope.data\n }\n\n async tiers(): Promise<BillingTier[]> {\n const envelope = await this.http.request<{ data: BillingTier[]; meta: unknown }>({\n method: 'GET',\n path: '/billing/tiers',\n })\n return envelope.data\n }\n\n async subscribe(data: { tier: 'starter' | 'growth' | 'pro' | 'scale' }, options?: MutationOptions): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'POST',\n path: '/billing/subscribe',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Conversion, ConversionStats, PaginatedResponse } from '../types/index.js'\n\nexport class ConversionsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: string\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Conversion>> {\n return this.http.request({ method: 'GET', path: '/conversions', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<ConversionStats> {\n const envelope = await this.http.request<{ data: ConversionStats; meta: unknown }>({\n method: 'GET',\n path: '/conversions/stats',\n query: params,\n })\n return envelope.data\n }\n\n async recent(params?: { limit?: number }): Promise<Conversion[]> {\n const envelope = await this.http.request<{ data: Conversion[]; meta: unknown }>({\n method: 'GET',\n path: '/conversions/recent',\n query: params,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Flag, FlagStats, MutationOptions, PaginatedResponse, ResolveFlagParams } from '../types/index.js'\n\nexport class FlagsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n status?: string\n type?: string\n affiliateId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Flag>> {\n return this.http.request({ method: 'GET', path: '/flags', query: params })\n }\n\n async stats(): Promise<FlagStats> {\n const envelope = await this.http.request<{ data: FlagStats; meta: unknown }>({\n method: 'GET',\n path: '/flags/stats',\n })\n return envelope.data\n }\n\n async resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag> {\n const envelope = await this.http.request<{ data: Flag; meta: unknown }>({\n method: 'POST',\n path: `/flags/${id}/resolve`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Merchant, MerchantDomainStatus, StripeConnectSession, UpdateMerchantParams } from '../types/index.js'\n\nexport class MerchantResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'GET',\n path: '/merchant',\n })\n return envelope.data\n }\n\n async update(data: UpdateMerchantParams): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'PATCH',\n path: '/merchant',\n body: data,\n })\n return envelope.data\n }\n\n async connectStripe(): Promise<StripeConnectSession> {\n const envelope = await this.http.request<{ data: StripeConnectSession; meta: unknown }>({\n method: 'POST',\n path: '/merchant/connect-stripe',\n })\n return envelope.data\n }\n\n async domainStatus(): Promise<MerchantDomainStatus> {\n const envelope = await this.http.request<{ data: MerchantDomainStatus; meta: unknown }>({\n method: 'GET',\n path: '/merchant/domain-status',\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatePayoutParams, MutationOptions, PaginatedResponse, PendingAffiliate, Payout, PayoutStats, PayoutStatus } from '../types/index.js'\n\nexport class PayoutsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: PayoutStatus\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Payout>> {\n return this.http.request({ method: 'GET', path: '/payouts', query: params })\n }\n\n listPending(params?: {\n programId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<PendingAffiliate>> {\n return this.http.request({ method: 'GET', path: '/payouts/pending', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<PayoutStats> {\n const envelope = await this.http.request<{ data: PayoutStats; meta: unknown }>({\n method: 'GET',\n path: '/payouts/stats',\n query: params,\n })\n return envelope.data\n }\n\n async create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'POST',\n path: '/payouts',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Affiliate,\n Coupon,\n CreateCouponParams,\n CreateProgramParams,\n Invite,\n MutationOptions,\n PaginatedResponse,\n Program,\n ProgramStats,\n UpdateProgramMarketplaceParams,\n UpdateProgramParams,\n} from '../types/index.js'\n\nexport class ProgramsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n status?: string\n }): Promise<PaginatedResponse<Program>> {\n return this.http.request({ method: 'GET', path: '/programs', query: params })\n }\n\n async *listAll(params?: {\n pageSize?: number\n }): AsyncGenerator<Program> {\n let page = 1\n const pageSize = params?.pageSize ?? 100\n\n while (true) {\n const response = await this.list({ page, limit: pageSize })\n yield* response.data\n\n if (!response.meta.hasMore) {\n break\n }\n\n page += 1\n }\n }\n\n async get(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async create(data: CreateProgramParams, options?: MutationOptions): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'POST',\n path: '/programs',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async update(id: string, data: UpdateProgramParams): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}`,\n body: data,\n })\n return envelope.data\n }\n\n async delete(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'DELETE',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async stats(id: string, params?: { period?: string }): Promise<ProgramStats> {\n const envelope = await this.http.request<{ data: ProgramStats; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/stats`,\n query: params,\n })\n return envelope.data\n }\n\n listAffiliates(\n id: string,\n params?: { includeBlocked?: boolean; cursor?: string; limit?: number; page?: number; pageSize?: number; offset?: number }\n ): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({\n method: 'GET',\n path: `/programs/${id}/affiliates`,\n query: params,\n })\n }\n\n async listCoupons(id: string): Promise<Coupon[]> {\n const envelope = await this.http.request<{ data: Coupon[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/coupons`,\n })\n return envelope.data\n }\n\n async createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/coupons`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async createInvite(\n id: string,\n data: {\n email?: string\n name?: string\n isPublic?: boolean\n usageLimit?: number\n expiresInDays?: number\n },\n options?: MutationOptions\n ): Promise<Invite> {\n const envelope = await this.http.request<{ data: Invite; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/invites`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async listInvites(id: string): Promise<Invite[]> {\n const envelope = await this.http.request<{ data: Invite[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/invites`,\n })\n return envelope.data\n }\n\n async deleteCoupon(couponId: string): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'DELETE',\n path: `/coupons/${couponId}`,\n })\n return envelope.data\n }\n\n async updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}/marketplace`,\n body: data,\n })\n return envelope.data\n }\n}\n","import { HttpClient } from './http.js'\nimport type { AgentRefConfig } from './types/index.js'\nimport { AffiliatesResource } from './resources/affiliates.js'\nimport { BillingResource } from './resources/billing.js'\nimport { ConversionsResource } from './resources/conversions.js'\nimport { FlagsResource } from './resources/flags.js'\nimport { MerchantResource } from './resources/merchant.js'\nimport { PayoutsResource } from './resources/payouts.js'\nimport { ProgramsResource } from './resources/programs.js'\n\nexport class AgentRef {\n readonly programs: ProgramsResource\n readonly affiliates: AffiliatesResource\n readonly conversions: ConversionsResource\n readonly payouts: PayoutsResource\n readonly flags: FlagsResource\n readonly billing: BillingResource\n readonly merchant: MerchantResource\n\n constructor(config?: AgentRefConfig) {\n const http = new HttpClient(config)\n\n this.programs = new ProgramsResource(http)\n this.affiliates = new AffiliatesResource(http)\n this.conversions = new ConversionsResource(http)\n this.payouts = new PayoutsResource(http)\n this.flags = new FlagsResource(http)\n this.billing = new BillingResource(http)\n this.merchant = new MerchantResource(http)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAKvC,YAAY,SAAiB,MAAc,QAAgB,WAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAEO,IAAM,YAAN,cAAwB,cAAc;AAAA,EAC3C,Y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IACA,MAOA,SACiB;AACjB,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,MACN,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,YAAY,IAA+B;AAC/C,UAAM,WAAW,MAAM,KAAK,KAAK,QAA2C;AAAA,MAC1E,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,IACvB,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,UAAmC;AACpD,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,YAAY,QAAQ;AAAA,IAC5B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,IAAY,MAAwE;AAC1G,UAAM,WAAW,MAAM,KAAK,KAAK,QAA0D;AAAA,MACzF,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,IACR,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AACF;;;AC1JO,IAAM,WAAN,MAAe;AAAA,EASpB,YAAY,QAAyB;AACnC,UAAM,OAAO,IAAI,WAAW,MAAM;AAElC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,aAAa,IAAI,mBAAmB,IAAI;AAC7C,SAAK,cAAc,IAAI,oBAAoB,IAAI;AAC/C,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,QAAQ,IAAI,cAAc,IAAI;AACnC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AAAA,EAC3C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/affiliates.ts","../src/resources/billing.ts","../src/resources/conversions.ts","../src/resources/flags.ts","../src/resources/merchant.ts","../src/resources/payouts.ts","../src/resources/programs.ts","../src/client.ts"],"sourcesContent":["export { AgentRef } from './client.js'\nexport {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nexport type {\n AgentRefConfig,\n Affiliate,\n AffiliateSortBy,\n AffiliateStatus,\n BillingStatus,\n BillingTier,\n BillingTierId,\n CommissionType,\n CreateInviteParams,\n CreatePayoutParams,\n Conversion,\n ConversionStats,\n ConversionStatus,\n Coupon,\n CreateCouponParams,\n CreateProgramParams,\n Flag,\n FlagStats,\n FlagStatus,\n FlagType,\n Invite,\n Merchant,\n MutationOptions,\n NotificationPreferences,\n PaginatedResponse,\n PaginationMeta,\n PayoutInfo,\n PendingAffiliate,\n Payout,\n ProgramMarketplaceVisibility,\n PayoutStats,\n PayoutStatus,\n Program,\n ProgramStats,\n ProgramStatus,\n SortOrder,\n StripeConnectSession,\n MerchantDomainStatus,\n UpdateMerchantParams,\n UpdateNotificationPreferencesParams,\n UpdatePayoutInfoParams,\n UpdateProgramMarketplaceParams,\n ResolveFlagParams,\n UpdateProgramParams,\n} from './types/index.js'\n","export class AgentRefError extends Error {\n readonly code: string\n readonly status: number\n readonly requestId: string\n\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message)\n this.name = 'AgentRefError'\n this.code = code\n this.status = status\n this.requestId = requestId\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 401, requestId)\n this.name = 'AuthError'\n }\n}\n\nexport class ForbiddenError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 403, requestId)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class ValidationError extends AgentRefError {\n readonly details: unknown\n\n constructor(message: string, code: string, requestId: string, details?: unknown) {\n super(message, code, 400, requestId)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class NotFoundError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 404, requestId)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 409, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends AgentRefError {\n readonly retryAfter: number\n\n constructor(message: string, code: string, requestId: string, retryAfter: number) {\n super(message, code, 429, requestId)\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class ServerError extends AgentRefError {\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message, code, status, requestId)\n this.name = 'ServerError'\n }\n}\n","import {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nimport type { AgentRefConfig } from './types/index.js'\n\nexport type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nconst SAFE_METHODS: ReadonlySet<HttpMethod> = new Set(['GET', 'HEAD'])\n\nexport interface RequestOptions {\n method: HttpMethod\n path: string\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n idempotencyKey?: string\n}\n\nconst DEFAULT_BASE_URL = 'https://www.agentref.dev/api/v1'\nconst DEFAULT_TIMEOUT = 30_000\nconst DEFAULT_MAX_RETRIES = 2\n\ndeclare const __SDK_VERSION__: string\nconst VERSION = typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : '0.0.0'\n\nfunction hasUsableIdempotencyKey(idempotencyKey: string | undefined): boolean {\n return typeof idempotencyKey === 'string' && idempotencyKey.trim().length > 0\n}\n\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n\n constructor(config: AgentRefConfig = {}) {\n if (typeof window !== 'undefined' && !config.dangerouslyAllowBrowser) {\n throw new Error(\n '[AgentRef] Refusing to initialize in browser context. API keys must not be exposed client-side. Use a server-side proxy to call the AgentRef API instead. To override: set dangerouslyAllowBrowser: true (understand the security implications first).'\n )\n }\n\n const apiKey = config.apiKey ?? process.env['AGENTREF_API_KEY']\n if (!apiKey) {\n throw new Error(\n '[AgentRef] API key is required. Pass it as apiKey or set the AGENTREF_API_KEY environment variable.'\n )\n }\n\n this.apiKey = apiKey\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query)\n const isSafe = SAFE_METHODS.has(options.method)\n const hasIdempotency = options.method === 'POST' && hasUsableIdempotencyKey(options.idempotencyKey)\n const canRetry = isSafe || hasIdempotency\n const maxAttempts = canRetry ? this.maxRetries + 1 : 1\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n let response: Response\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': `agentref-node/${VERSION}`,\n }\n\n if (hasIdempotency) {\n headers['Idempotency-Key'] = options.idempotencyKey!.trim()\n }\n\n response = await fetch(url, {\n method: options.method,\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: AbortSignal.timeout(this.timeout),\n })\n } catch (error) {\n if (canRetry && attempt < maxAttempts - 1) {\n await this.wait(this.backoff(attempt))\n continue\n }\n throw error\n }\n\n if (!response.ok) {\n const parsedError = await this.parseError(response)\n\n if (canRetry && this.isRetryable(response.status) && attempt < maxAttempts - 1) {\n const delay =\n response.status === 429\n ? this.retryAfterToMs(response.headers.get('Retry-After'))\n : this.backoff(attempt)\n await this.wait(delay)\n continue\n }\n\n throw parsedError\n }\n\n return response.json() as Promise<T>\n }\n\n throw new ServerError('Request failed after retries', 'REQUEST_RETRY_EXHAUSTED', 500, '')\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n const url = new URL(`${this.baseUrl}${normalizedPath}`)\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n return url.toString()\n }\n\n private async parseError(response: Response): Promise<AgentRefError> {\n const json = (await response.json().catch(() => ({}))) as {\n error?: { code?: string; message?: string; details?: unknown }\n meta?: { requestId?: string }\n }\n\n const code = json.error?.code ?? 'UNKNOWN_ERROR'\n const message = json.error?.message ?? response.statusText\n const requestId = json.meta?.requestId ?? ''\n const details = json.error?.details\n\n if (response.status === 400) return new ValidationError(message, code, requestId, details)\n if (response.status === 401) return new AuthError(message, code, requestId)\n if (response.status === 403) return new ForbiddenError(message, code, requestId)\n if (response.status === 404) return new NotFoundError(message, code, requestId)\n if (response.status === 409) return new ConflictError(message, code, requestId)\n if (response.status === 429) {\n return new RateLimitError(message, code, requestId, this.retryAfterToSeconds(response.headers.get('Retry-After')))\n }\n\n return new ServerError(message, code, response.status, requestId)\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500\n }\n\n private retryAfterToSeconds(headerValue: string | null): number {\n if (!headerValue) return 60\n\n const numericSeconds = Number(headerValue)\n if (!Number.isNaN(numericSeconds) && numericSeconds >= 0) {\n return Math.ceil(numericSeconds)\n }\n\n const asDate = Date.parse(headerValue)\n if (!Number.isNaN(asDate)) {\n const deltaMs = asDate - Date.now()\n return Math.max(0, Math.ceil(deltaMs / 1000))\n }\n\n return 60\n }\n\n private retryAfterToMs(headerValue: string | null): number {\n return this.retryAfterToSeconds(headerValue) * 1000\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms)\n })\n }\n\n private backoff(attempt: number): number {\n return 500 * Math.pow(2, attempt)\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Affiliate, AffiliateSortBy, AffiliateStatus, MutationOptions, PaginatedResponse, SortOrder } from '../types/index.js'\n\nexport class AffiliatesResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n includeBlocked?: boolean\n search?: string\n sortBy?: AffiliateSortBy\n sortOrder?: SortOrder\n status?: AffiliateStatus\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({ method: 'GET', path: '/affiliates', query: params })\n }\n\n async get(id: string, options?: { include?: 'stats' }): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'GET',\n path: `/affiliates/${id}`,\n query: options?.include ? { include: options.include } : undefined,\n })\n return envelope.data\n }\n\n async approve(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/approve`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async block(id: string, data?: { reason?: string }, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/block`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async unblock(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/unblock`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { BillingStatus, BillingTier, MutationOptions } from '../types/index.js'\n\nexport class BillingResource {\n constructor(private readonly http: HttpClient) {}\n\n async current(): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'GET',\n path: '/billing',\n })\n return envelope.data\n }\n\n async tiers(): Promise<BillingTier[]> {\n const envelope = await this.http.request<{ data: BillingTier[]; meta: unknown }>({\n method: 'GET',\n path: '/billing/tiers',\n })\n return envelope.data\n }\n\n async subscribe(data: { tier: 'starter' | 'growth' | 'pro' | 'scale' }, options?: MutationOptions): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'POST',\n path: '/billing/subscribe',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Conversion, ConversionStats, PaginatedResponse } from '../types/index.js'\n\nexport class ConversionsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: string\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Conversion>> {\n return this.http.request({ method: 'GET', path: '/conversions', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<ConversionStats> {\n const envelope = await this.http.request<{ data: ConversionStats; meta: unknown }>({\n method: 'GET',\n path: '/conversions/stats',\n query: params,\n })\n return envelope.data\n }\n\n async recent(params?: { limit?: number }): Promise<Conversion[]> {\n const envelope = await this.http.request<{ data: Conversion[]; meta: unknown }>({\n method: 'GET',\n path: '/conversions/recent',\n query: params,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Flag, FlagStats, MutationOptions, PaginatedResponse, ResolveFlagParams } from '../types/index.js'\n\nexport class FlagsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n status?: string\n type?: string\n affiliateId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Flag>> {\n return this.http.request({ method: 'GET', path: '/flags', query: params })\n }\n\n async stats(): Promise<FlagStats> {\n const envelope = await this.http.request<{ data: FlagStats; meta: unknown }>({\n method: 'GET',\n path: '/flags/stats',\n })\n return envelope.data\n }\n\n async resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag> {\n const envelope = await this.http.request<{ data: Flag; meta: unknown }>({\n method: 'POST',\n path: `/flags/${id}/resolve`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Merchant,\n MerchantDomainStatus,\n NotificationPreferences,\n PayoutInfo,\n StripeConnectSession,\n UpdateMerchantParams,\n UpdateNotificationPreferencesParams,\n UpdatePayoutInfoParams,\n} from '../types/index.js'\n\nexport class MerchantResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'GET',\n path: '/merchant',\n })\n return envelope.data\n }\n\n async update(data: UpdateMerchantParams): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'PATCH',\n path: '/merchant',\n body: data,\n })\n return envelope.data\n }\n\n async connectStripe(): Promise<StripeConnectSession> {\n const envelope = await this.http.request<{ data: StripeConnectSession; meta: unknown }>({\n method: 'POST',\n path: '/merchant/connect-stripe',\n })\n return envelope.data\n }\n\n async domainStatus(): Promise<MerchantDomainStatus> {\n const envelope = await this.http.request<{ data: MerchantDomainStatus; meta: unknown }>({\n method: 'GET',\n path: '/merchant/domain-status',\n })\n return envelope.data\n }\n\n async getPayoutInfo(): Promise<PayoutInfo> {\n const envelope = await this.http.request<{ data: PayoutInfo; meta: unknown }>({\n method: 'GET',\n path: '/me/payout-info',\n })\n return envelope.data\n }\n\n async updatePayoutInfo(data: UpdatePayoutInfoParams): Promise<PayoutInfo> {\n const envelope = await this.http.request<{ data: PayoutInfo; meta: unknown }>({\n method: 'PATCH',\n path: '/me/payout-info',\n body: data,\n })\n return envelope.data\n }\n\n async getNotifications(): Promise<NotificationPreferences> {\n const envelope = await this.http.request<{ data: NotificationPreferences; meta: unknown }>({\n method: 'GET',\n path: '/merchant/notifications',\n })\n return envelope.data\n }\n\n async updateNotifications(data: UpdateNotificationPreferencesParams): Promise<NotificationPreferences> {\n const envelope = await this.http.request<{ data: NotificationPreferences; meta: unknown }>({\n method: 'PUT',\n path: '/merchant/notifications',\n body: data,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatePayoutParams, MutationOptions, PaginatedResponse, PendingAffiliate, Payout, PayoutStats, PayoutStatus } from '../types/index.js'\n\nexport class PayoutsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: PayoutStatus\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Payout>> {\n return this.http.request({ method: 'GET', path: '/payouts', query: params })\n }\n\n listPending(params?: {\n programId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<PendingAffiliate>> {\n return this.http.request({ method: 'GET', path: '/payouts/pending', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<PayoutStats> {\n const envelope = await this.http.request<{ data: PayoutStats; meta: unknown }>({\n method: 'GET',\n path: '/payouts/stats',\n query: params,\n })\n return envelope.data\n }\n\n async create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'POST',\n path: '/payouts',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Affiliate,\n Coupon,\n CreateCouponParams,\n CreateInviteParams,\n CreateProgramParams,\n Invite,\n MutationOptions,\n PaginatedResponse,\n Program,\n ProgramStats,\n UpdateProgramMarketplaceParams,\n UpdateProgramParams,\n} from '../types/index.js'\n\nexport class ProgramsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n status?: string\n }): Promise<PaginatedResponse<Program>> {\n return this.http.request({ method: 'GET', path: '/programs', query: params })\n }\n\n async *listAll(params?: {\n pageSize?: number\n }): AsyncGenerator<Program> {\n let page = 1\n const pageSize = params?.pageSize ?? 100\n\n while (true) {\n const response = await this.list({ page, limit: pageSize })\n yield* response.data\n\n if (!response.meta.hasMore) {\n break\n }\n\n page += 1\n }\n }\n\n async get(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async create(data: CreateProgramParams, options?: MutationOptions): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'POST',\n path: '/programs',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async update(id: string, data: UpdateProgramParams): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}`,\n body: data,\n })\n return envelope.data\n }\n\n async delete(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'DELETE',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async stats(id: string, params?: { period?: string }): Promise<ProgramStats> {\n const envelope = await this.http.request<{ data: ProgramStats; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/stats`,\n query: params,\n })\n return envelope.data\n }\n\n listAffiliates(\n id: string,\n params?: { includeBlocked?: boolean; cursor?: string; limit?: number; page?: number; pageSize?: number; offset?: number }\n ): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({\n method: 'GET',\n path: `/programs/${id}/affiliates`,\n query: params,\n })\n }\n\n async listCoupons(id: string): Promise<Coupon[]> {\n const envelope = await this.http.request<{ data: Coupon[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/coupons`,\n })\n return envelope.data\n }\n\n async createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/coupons`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async createInvite(\n id: string,\n data: CreateInviteParams,\n options?: MutationOptions\n ): Promise<Invite> {\n const envelope = await this.http.request<{ data: Invite; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/invites`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async listInvites(id: string): Promise<Invite[]> {\n const envelope = await this.http.request<{ data: Invite[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/invites`,\n })\n return envelope.data\n }\n\n async deleteCoupon(couponId: string): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'DELETE',\n path: `/coupons/${couponId}`,\n })\n return envelope.data\n }\n\n async updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}/marketplace`,\n body: data,\n })\n return envelope.data\n }\n}\n","import { HttpClient } from './http.js'\nimport type { AgentRefConfig } from './types/index.js'\nimport { AffiliatesResource } from './resources/affiliates.js'\nimport { BillingResource } from './resources/billing.js'\nimport { ConversionsResource } from './resources/conversions.js'\nimport { FlagsResource } from './resources/flags.js'\nimport { MerchantResource } from './resources/merchant.js'\nimport { PayoutsResource } from './resources/payouts.js'\nimport { ProgramsResource } from './resources/programs.js'\n\nexport class AgentRef {\n readonly programs: ProgramsResource\n readonly affiliates: AffiliatesResource\n readonly conversions: ConversionsResource\n readonly payouts: PayoutsResource\n readonly flags: FlagsResource\n readonly billing: BillingResource\n readonly merchant: MerchantResource\n\n constructor(config?: AgentRefConfig) {\n const http = new HttpClient(config)\n\n this.programs = new ProgramsResource(http)\n this.affiliates = new AffiliatesResource(http)\n this.conversions = new ConversionsResource(http)\n this.payouts = new PayoutsResource(http)\n this.flags = new FlagsResource(http)\n this.billing = new BillingResource(http)\n this.merch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,EAAE;AAAA,MACrB,MAAM;AAAA,MACN,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,YAAY,IAA+B;AAC/C,UAAM,WAAW,MAAM,KAAK,KAAK,QAA2C;AAAA,MAC1E,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,IACvB,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,UAAmC;AACpD,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,YAAY,QAAQ;AAAA,IAC5B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,IAAY,MAAwE;AAC1G,UAAM,WAAW,MAAM,KAAK,KAAK,QAA0D;AAAA,MACzF,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,IACR,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AACF;;;ACrJO,IAAM,WAAN,MAAe;AAAA,EASpB,YAAY,QAAyB;AACnC,UAAM,OAAO,IAAI,WAAW,MAAM;AAElC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,aAAa,IAAI,mBAAmB,IAAI;AAC7C,SAAK,cAAc,IAAI,oBAAoB,IAAI;AAC/C,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,QAAQ,IAAI,cAAc,IAAI;AACnC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AAAA,EAC3C;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -229,8 +229,59 @@ interface Invite {
229
229
  expiresAt: string;
230
230
  createdAt: string;
231
231
  }
232
+ type AffiliateSortBy = 'createdAt' | 'totalClicks' | 'totalRevenue' | 'name';
233
+ type SortOrder = 'asc' | 'desc';
234
+ interface CreateInviteParams {
235
+ email?: string;
236
+ name?: string;
237
+ isPublic?: boolean;
238
+ usageLimit?: number;
239
+ expiresInDays?: number;
240
+ trackingCode?: string;
241
+ skipOnboarding?: boolean;
242
+ }
243
+ interface PayoutInfo {
244
+ payoutMethod: 'paypal' | 'bank_transfer' | null;
245
+ paypalEmail: string | null;
246
+ bankIban: string | null;
247
+ firstName: string | null;
248
+ lastName: string | null;
249
+ addressLine1: string | null;
250
+ addressLine2: string | null;
251
+ city: string | null;
252
+ state: string | null;
253
+ postalCode: string | null;
254
+ vatId: string | null;
255
+ }
256
+ interface UpdatePayoutInfoParams {
257
+ payoutMethod?: 'paypal' | 'bank_transfer';
258
+ paypalEmail?: string;
259
+ bankIban?: string;
260
+ firstName?: string;
261
+ lastName?: string;
262
+ addressLine1?: string;
263
+ addressLine2?: string;
264
+ city?: string;
265
+ state?: string;
266
+ postalCode?: string;
267
+ vatId?: string;
268
+ }
269
+ interface NotificationPreferences {
270
+ newAffiliate: boolean;
271
+ newConversion: boolean;
272
+ commissionApproved: boolean;
273
+ payoutProcessed: boolean;
274
+ weeklyDigest: boolean;
275
+ }
276
+ interface UpdateNotificationPreferencesParams {
277
+ newAffiliate?: boolean;
278
+ newConversion?: boolean;
279
+ commissionApproved?: boolean;
280
+ payoutProcessed?: boolean;
281
+ weeklyDigest?: boolean;
282
+ }
232
283
 
233
- type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
284
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
234
285
  interface RequestOptions {
235
286
  method: HttpMethod;
236
287
  path: string;
@@ -260,13 +311,19 @@ declare class AffiliatesResource {
260
311
  list(params?: {
261
312
  programId?: string;
262
313
  includeBlocked?: boolean;
314
+ search?: string;
315
+ sortBy?: AffiliateSortBy;
316
+ sortOrder?: SortOrder;
317
+ status?: AffiliateStatus;
263
318
  cursor?: string;
264
319
  limit?: number;
265
320
  page?: number;
266
321
  pageSize?: number;
267
322
  offset?: number;
268
323
  }): Promise<PaginatedResponse<Affiliate>>;
269
- get(id: string): Promise<Affiliate>;
324
+ get(id: string, options?: {
325
+ include?: 'stats';
326
+ }): Promise<Affiliate>;
270
327
  approve(id: string, options?: MutationOptions): Promise<Affiliate>;
271
328
  block(id: string, data?: {
272
329
  reason?: string;
@@ -334,6 +391,10 @@ declare class MerchantResource {
334
391
  update(data: UpdateMerchantParams): Promise<Merchant>;
335
392
  connectStripe(): Promise<StripeConnectSession>;
336
393
  domainStatus(): Promise<MerchantDomainStatus>;
394
+ getPayoutInfo(): Promise<PayoutInfo>;
395
+ updatePayoutInfo(data: UpdatePayoutInfoParams): Promise<PayoutInfo>;
396
+ getNotifications(): Promise<NotificationPreferences>;
397
+ updateNotifications(data: UpdateNotificationPreferencesParams): Promise<NotificationPreferences>;
337
398
  }
338
399
 
339
400
  declare class PayoutsResource {
@@ -399,13 +460,7 @@ declare class ProgramsResource {
399
460
  }): Promise<PaginatedResponse<Affiliate>>;
400
461
  listCoupons(id: string): Promise<Coupon[]>;
401
462
  createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon>;
402
- createInvite(id: string, data: {
403
- email?: string;
404
- name?: string;
405
- isPublic?: boolean;
406
- usageLimit?: number;
407
- expiresInDays?: number;
408
- }, options?: MutationOptions): Promise<Invite>;
463
+ createInvite(id: string, data: CreateInviteParams, options?: MutationOptions): Promise<Invite>;
409
464
  listInvites(id: string): Promise<Invite[]>;
410
465
  deleteCoupon(couponId: string): Promise<Coupon>;
411
466
  updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>>;
@@ -452,4 +507,4 @@ declare class ServerError extends AgentRefError {
452
507
  constructor(message: string, code: string, status: number, requestId: string);
453
508
  }
454
509
 
455
- export { type Affiliate, type AffiliateStatus, AgentRef, type AgentRefConfig, AgentRefError, AuthError, type BillingStatus, type BillingTier, type BillingTierId, type CommissionType, ConflictError, type Conversion, type ConversionStats, type ConversionStatus, type Coupon, type CreateCouponParams, type CreatePayoutParams, type CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MerchantDomainStatus, type MutationOptions, NotFoundError, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramMarketplaceVisibility, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type StripeConnectSession, type UpdateMerchantParams, type UpdateProgramMarketplaceParams, type UpdateProgramParams, ValidationError };
510
+ export { type Affiliate, type AffiliateSortBy, type AffiliateStatus, AgentRef, type AgentRefConfig, AgentRefError, AuthError, type BillingStatus, type BillingTier, type BillingTierId, type CommissionType, ConflictError, type Conversion, type ConversionStats, type ConversionStatus, type Coupon, type CreateCouponParams, type CreateInviteParams, type CreatePayoutParams, type CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MerchantDomainStatus, type MutationOptions, NotFoundError, type NotificationPreferences, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutInfo, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramMarketplaceVisibility, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type SortOrder, type StripeConnectSession, type UpdateMerchantParams, type UpdateNotificationPreferencesParams, type UpdatePayoutInfoParams, type UpdateProgramMarketplaceParams, type UpdateProgramParams, ValidationError };
package/dist/index.d.ts CHANGED
@@ -229,8 +229,59 @@ interface Invite {
229
229
  expiresAt: string;
230
230
  createdAt: string;
231
231
  }
232
+ type AffiliateSortBy = 'createdAt' | 'totalClicks' | 'totalRevenue' | 'name';
233
+ type SortOrder = 'asc' | 'desc';
234
+ interface CreateInviteParams {
235
+ email?: string;
236
+ name?: string;
237
+ isPublic?: boolean;
238
+ usageLimit?: number;
239
+ expiresInDays?: number;
240
+ trackingCode?: string;
241
+ skipOnboarding?: boolean;
242
+ }
243
+ interface PayoutInfo {
244
+ payoutMethod: 'paypal' | 'bank_transfer' | null;
245
+ paypalEmail: string | null;
246
+ bankIban: string | null;
247
+ firstName: string | null;
248
+ lastName: string | null;
249
+ addressLine1: string | null;
250
+ addressLine2: string | null;
251
+ city: string | null;
252
+ state: string | null;
253
+ postalCode: string | null;
254
+ vatId: string | null;
255
+ }
256
+ interface UpdatePayoutInfoParams {
257
+ payoutMethod?: 'paypal' | 'bank_transfer';
258
+ paypalEmail?: string;
259
+ bankIban?: string;
260
+ firstName?: string;
261
+ lastName?: string;
262
+ addressLine1?: string;
263
+ addressLine2?: string;
264
+ city?: string;
265
+ state?: string;
266
+ postalCode?: string;
267
+ vatId?: string;
268
+ }
269
+ interface NotificationPreferences {
270
+ newAffiliate: boolean;
271
+ newConversion: boolean;
272
+ commissionApproved: boolean;
273
+ payoutProcessed: boolean;
274
+ weeklyDigest: boolean;
275
+ }
276
+ interface UpdateNotificationPreferencesParams {
277
+ newAffiliate?: boolean;
278
+ newConversion?: boolean;
279
+ commissionApproved?: boolean;
280
+ payoutProcessed?: boolean;
281
+ weeklyDigest?: boolean;
282
+ }
232
283
 
233
- type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
284
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
234
285
  interface RequestOptions {
235
286
  method: HttpMethod;
236
287
  path: string;
@@ -260,13 +311,19 @@ declare class AffiliatesResource {
260
311
  list(params?: {
261
312
  programId?: string;
262
313
  includeBlocked?: boolean;
314
+ search?: string;
315
+ sortBy?: AffiliateSortBy;
316
+ sortOrder?: SortOrder;
317
+ status?: AffiliateStatus;
263
318
  cursor?: string;
264
319
  limit?: number;
265
320
  page?: number;
266
321
  pageSize?: number;
267
322
  offset?: number;
268
323
  }): Promise<PaginatedResponse<Affiliate>>;
269
- get(id: string): Promise<Affiliate>;
324
+ get(id: string, options?: {
325
+ include?: 'stats';
326
+ }): Promise<Affiliate>;
270
327
  approve(id: string, options?: MutationOptions): Promise<Affiliate>;
271
328
  block(id: string, data?: {
272
329
  reason?: string;
@@ -334,6 +391,10 @@ declare class MerchantResource {
334
391
  update(data: UpdateMerchantParams): Promise<Merchant>;
335
392
  connectStripe(): Promise<StripeConnectSession>;
336
393
  domainStatus(): Promise<MerchantDomainStatus>;
394
+ getPayoutInfo(): Promise<PayoutInfo>;
395
+ updatePayoutInfo(data: UpdatePayoutInfoParams): Promise<PayoutInfo>;
396
+ getNotifications(): Promise<NotificationPreferences>;
397
+ updateNotifications(data: UpdateNotificationPreferencesParams): Promise<NotificationPreferences>;
337
398
  }
338
399
 
339
400
  declare class PayoutsResource {
@@ -399,13 +460,7 @@ declare class ProgramsResource {
399
460
  }): Promise<PaginatedResponse<Affiliate>>;
400
461
  listCoupons(id: string): Promise<Coupon[]>;
401
462
  createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon>;
402
- createInvite(id: string, data: {
403
- email?: string;
404
- name?: string;
405
- isPublic?: boolean;
406
- usageLimit?: number;
407
- expiresInDays?: number;
408
- }, options?: MutationOptions): Promise<Invite>;
463
+ createInvite(id: string, data: CreateInviteParams, options?: MutationOptions): Promise<Invite>;
409
464
  listInvites(id: string): Promise<Invite[]>;
410
465
  deleteCoupon(couponId: string): Promise<Coupon>;
411
466
  updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>>;
@@ -452,4 +507,4 @@ declare class ServerError extends AgentRefError {
452
507
  constructor(message: string, code: string, status: number, requestId: string);
453
508
  }
454
509
 
455
- export { type Affiliate, type AffiliateStatus, AgentRef, type AgentRefConfig, AgentRefError, AuthError, type BillingStatus, type BillingTier, type BillingTierId, type CommissionType, ConflictError, type Conversion, type ConversionStats, type ConversionStatus, type Coupon, type CreateCouponParams, type CreatePayoutParams, type CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MerchantDomainStatus, type MutationOptions, NotFoundError, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramMarketplaceVisibility, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type StripeConnectSession, type UpdateMerchantParams, type UpdateProgramMarketplaceParams, type UpdateProgramParams, ValidationError };
510
+ export { type Affiliate, type AffiliateSortBy, type AffiliateStatus, AgentRef, type AgentRefConfig, AgentRefError, AuthError, type BillingStatus, type BillingTier, type BillingTierId, type CommissionType, ConflictError, type Conversion, type ConversionStats, type ConversionStatus, type Coupon, type CreateCouponParams, type CreateInviteParams, type CreatePayoutParams, type CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MerchantDomainStatus, type MutationOptions, NotFoundError, type NotificationPreferences, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutInfo, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramMarketplaceVisibility, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type SortOrder, type StripeConnectSession, type UpdateMerchantParams, type UpdateNotificationPreferencesParams, type UpdatePayoutInfoParams, type UpdateProgramMarketplaceParams, type UpdateProgramParams, ValidationError };
package/dist/index.mjs CHANGED
@@ -59,7 +59,7 @@ var SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
59
59
  var DEFAULT_BASE_URL = "https://www.agentref.dev/api/v1";
60
60
  var DEFAULT_TIMEOUT = 3e4;
61
61
  var DEFAULT_MAX_RETRIES = 2;
62
- var VERSION = true ? "1.0.4" : "0.0.0";
62
+ var VERSION = true ? "1.0.5" : "0.0.0";
63
63
  function hasUsableIdempotencyKey(idempotencyKey) {
64
64
  return typeof idempotencyKey === "string" && idempotencyKey.trim().length > 0;
65
65
  }
@@ -189,10 +189,11 @@ var AffiliatesResource = class {
189
189
  list(params) {
190
190
  return this.http.request({ method: "GET", path: "/affiliates", query: params });
191
191
  }
192
- async get(id) {
192
+ async get(id, options) {
193
193
  const envelope = await this.http.request({
194
194
  method: "GET",
195
- path: `/affiliates/${id}`
195
+ path: `/affiliates/${id}`,
196
+ query: options?.include ? { include: options.include } : void 0
196
197
  });
197
198
  return envelope.data;
198
199
  }
@@ -339,6 +340,36 @@ var MerchantResource = class {
339
340
  });
340
341
  return envelope.data;
341
342
  }
343
+ async getPayoutInfo() {
344
+ const envelope = await this.http.request({
345
+ method: "GET",
346
+ path: "/me/payout-info"
347
+ });
348
+ return envelope.data;
349
+ }
350
+ async updatePayoutInfo(data) {
351
+ const envelope = await this.http.request({
352
+ method: "PATCH",
353
+ path: "/me/payout-info",
354
+ body: data
355
+ });
356
+ return envelope.data;
357
+ }
358
+ async getNotifications() {
359
+ const envelope = await this.http.request({
360
+ method: "GET",
361
+ path: "/merchant/notifications"
362
+ });
363
+ return envelope.data;
364
+ }
365
+ async updateNotifications(data) {
366
+ const envelope = await this.http.request({
367
+ method: "PUT",
368
+ path: "/merchant/notifications",
369
+ body: data
370
+ });
371
+ return envelope.data;
372
+ }
342
373
  };
343
374
 
344
375
  // src/resources/payouts.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/affiliates.ts","../src/resources/billing.ts","../src/resources/conversions.ts","../src/resources/flags.ts","../src/resources/merchant.ts","../src/resources/payouts.ts","../src/resources/programs.ts","../src/client.ts"],"sourcesContent":["export class AgentRefError extends Error {\n readonly code: string\n readonly status: number\n readonly requestId: string\n\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message)\n this.name = 'AgentRefError'\n this.code = code\n this.status = status\n this.requestId = requestId\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 401, requestId)\n this.name = 'AuthError'\n }\n}\n\nexport class ForbiddenError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 403, requestId)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class ValidationError extends AgentRefError {\n readonly details: unknown\n\n constructor(message: string, code: string, requestId: string, details?: unknown) {\n super(message, code, 400, requestId)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class NotFoundError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 404, requestId)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 409, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends AgentRefError {\n readonly retryAfter: number\n\n constructor(message: string, code: string, requestId: string, retryAfter: number) {\n super(message, code, 429, requestId)\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class ServerError extends AgentRefError {\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message, code, status, requestId)\n this.name = 'ServerError'\n }\n}\n","import {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nimport type { AgentRefConfig } from './types/index.js'\n\nexport type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE'\n\nconst SAFE_METHODS: ReadonlySet<HttpMethod> = new Set(['GET', 'HEAD'])\n\nexport interface RequestOptions {\n method: HttpMethod\n path: string\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n idempotencyKey?: string\n}\n\nconst DEFAULT_BASE_URL = 'https://www.agentref.dev/api/v1'\nconst DEFAULT_TIMEOUT = 30_000\nconst DEFAULT_MAX_RETRIES = 2\n\ndeclare const __SDK_VERSION__: string\nconst VERSION = typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : '0.0.0'\n\nfunction hasUsableIdempotencyKey(idempotencyKey: string | undefined): boolean {\n return typeof idempotencyKey === 'string' && idempotencyKey.trim().length > 0\n}\n\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n\n constructor(config: AgentRefConfig = {}) {\n if (typeof window !== 'undefined' && !config.dangerouslyAllowBrowser) {\n throw new Error(\n '[AgentRef] Refusing to initialize in browser context. API keys must not be exposed client-side. Use a server-side proxy to call the AgentRef API instead. To override: set dangerouslyAllowBrowser: true (understand the security implications first).'\n )\n }\n\n const apiKey = config.apiKey ?? process.env['AGENTREF_API_KEY']\n if (!apiKey) {\n throw new Error(\n '[AgentRef] API key is required. Pass it as apiKey or set the AGENTREF_API_KEY environment variable.'\n )\n }\n\n this.apiKey = apiKey\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query)\n const isSafe = SAFE_METHODS.has(options.method)\n const hasIdempotency = options.method === 'POST' && hasUsableIdempotencyKey(options.idempotencyKey)\n const canRetry = isSafe || hasIdempotency\n const maxAttempts = canRetry ? this.maxRetries + 1 : 1\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n let response: Response\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': `agentref-node/${VERSION}`,\n }\n\n if (hasIdempotency) {\n headers['Idempotency-Key'] = options.idempotencyKey!.trim()\n }\n\n response = await fetch(url, {\n method: options.method,\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: AbortSignal.timeout(this.timeout),\n })\n } catch (error) {\n if (canRetry && attempt < maxAttempts - 1) {\n await this.wait(this.backoff(attempt))\n continue\n }\n throw error\n }\n\n if (!response.ok) {\n const parsedError = await this.parseError(response)\n\n if (canRetry && this.isRetryable(response.status) && attempt < maxAttempts - 1) {\n const delay =\n response.status === 429\n ? this.retryAfterToMs(response.headers.get('Retry-After'))\n : this.backoff(attempt)\n await this.wait(delay)\n continue\n }\n\n throw parsedError\n }\n\n return response.json() as Promise<T>\n }\n\n throw new ServerError('Request failed after retries', 'REQUEST_RETRY_EXHAUSTED', 500, '')\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n const url = new URL(`${this.baseUrl}${normalizedPath}`)\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n return url.toString()\n }\n\n private async parseError(response: Response): Promise<AgentRefError> {\n const json = (await response.json().catch(() => ({}))) as {\n error?: { code?: string; message?: string; details?: unknown }\n meta?: { requestId?: string }\n }\n\n const code = json.error?.code ?? 'UNKNOWN_ERROR'\n const message = json.error?.message ?? response.statusText\n const requestId = json.meta?.requestId ?? ''\n const details = json.error?.details\n\n if (response.status === 400) return new ValidationError(message, code, requestId, details)\n if (response.status === 401) return new AuthError(message, code, requestId)\n if (response.status === 403) return new ForbiddenError(message, code, requestId)\n if (response.status === 404) return new NotFoundError(message, code, requestId)\n if (response.status === 409) return new ConflictError(message, code, requestId)\n if (response.status === 429) {\n return new RateLimitError(message, code, requestId, this.retryAfterToSeconds(response.headers.get('Retry-After')))\n }\n\n return new ServerError(message, code, response.status, requestId)\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500\n }\n\n private retryAfterToSeconds(headerValue: string | null): number {\n if (!headerValue) return 60\n\n const numericSeconds = Number(headerValue)\n if (!Number.isNaN(numericSeconds) && numericSeconds >= 0) {\n return Math.ceil(numericSeconds)\n }\n\n const asDate = Date.parse(headerValue)\n if (!Number.isNaN(asDate)) {\n const deltaMs = asDate - Date.now()\n return Math.max(0, Math.ceil(deltaMs / 1000))\n }\n\n return 60\n }\n\n private retryAfterToMs(headerValue: string | null): number {\n return this.retryAfterToSeconds(headerValue) * 1000\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms)\n })\n }\n\n private backoff(attempt: number): number {\n return 500 * Math.pow(2, attempt)\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Affiliate, MutationOptions, PaginatedResponse } from '../types/index.js'\n\nexport class AffiliatesResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n includeBlocked?: boolean\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({ method: 'GET', path: '/affiliates', query: params })\n }\n\n async get(id: string): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'GET',\n path: `/affiliates/${id}`,\n })\n return envelope.data\n }\n\n async approve(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/approve`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async block(id: string, data?: { reason?: string }, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/block`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async unblock(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/unblock`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { BillingStatus, BillingTier, MutationOptions } from '../types/index.js'\n\nexport class BillingResource {\n constructor(private readonly http: HttpClient) {}\n\n async current(): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'GET',\n path: '/billing',\n })\n return envelope.data\n }\n\n async tiers(): Promise<BillingTier[]> {\n const envelope = await this.http.request<{ data: BillingTier[]; meta: unknown }>({\n method: 'GET',\n path: '/billing/tiers',\n })\n return envelope.data\n }\n\n async subscribe(data: { tier: 'starter' | 'growth' | 'pro' | 'scale' }, options?: MutationOptions): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'POST',\n path: '/billing/subscribe',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Conversion, ConversionStats, PaginatedResponse } from '../types/index.js'\n\nexport class ConversionsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: string\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Conversion>> {\n return this.http.request({ method: 'GET', path: '/conversions', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<ConversionStats> {\n const envelope = await this.http.request<{ data: ConversionStats; meta: unknown }>({\n method: 'GET',\n path: '/conversions/stats',\n query: params,\n })\n return envelope.data\n }\n\n async recent(params?: { limit?: number }): Promise<Conversion[]> {\n const envelope = await this.http.request<{ data: Conversion[]; meta: unknown }>({\n method: 'GET',\n path: '/conversions/recent',\n query: params,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Flag, FlagStats, MutationOptions, PaginatedResponse, ResolveFlagParams } from '../types/index.js'\n\nexport class FlagsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n status?: string\n type?: string\n affiliateId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Flag>> {\n return this.http.request({ method: 'GET', path: '/flags', query: params })\n }\n\n async stats(): Promise<FlagStats> {\n const envelope = await this.http.request<{ data: FlagStats; meta: unknown }>({\n method: 'GET',\n path: '/flags/stats',\n })\n return envelope.data\n }\n\n async resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag> {\n const envelope = await this.http.request<{ data: Flag; meta: unknown }>({\n method: 'POST',\n path: `/flags/${id}/resolve`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Merchant, MerchantDomainStatus, StripeConnectSession, UpdateMerchantParams } from '../types/index.js'\n\nexport class MerchantResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'GET',\n path: '/merchant',\n })\n return envelope.data\n }\n\n async update(data: UpdateMerchantParams): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'PATCH',\n path: '/merchant',\n body: data,\n })\n return envelope.data\n }\n\n async connectStripe(): Promise<StripeConnectSession> {\n const envelope = await this.http.request<{ data: StripeConnectSession; meta: unknown }>({\n method: 'POST',\n path: '/merchant/connect-stripe',\n })\n return envelope.data\n }\n\n async domainStatus(): Promise<MerchantDomainStatus> {\n const envelope = await this.http.request<{ data: MerchantDomainStatus; meta: unknown }>({\n method: 'GET',\n path: '/merchant/domain-status',\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatePayoutParams, MutationOptions, PaginatedResponse, PendingAffiliate, Payout, PayoutStats, PayoutStatus } from '../types/index.js'\n\nexport class PayoutsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: PayoutStatus\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Payout>> {\n return this.http.request({ method: 'GET', path: '/payouts', query: params })\n }\n\n listPending(params?: {\n programId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<PendingAffiliate>> {\n return this.http.request({ method: 'GET', path: '/payouts/pending', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<PayoutStats> {\n const envelope = await this.http.request<{ data: PayoutStats; meta: unknown }>({\n method: 'GET',\n path: '/payouts/stats',\n query: params,\n })\n return envelope.data\n }\n\n async create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'POST',\n path: '/payouts',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Affiliate,\n Coupon,\n CreateCouponParams,\n CreateProgramParams,\n Invite,\n MutationOptions,\n PaginatedResponse,\n Program,\n ProgramStats,\n UpdateProgramMarketplaceParams,\n UpdateProgramParams,\n} from '../types/index.js'\n\nexport class ProgramsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n status?: string\n }): Promise<PaginatedResponse<Program>> {\n return this.http.request({ method: 'GET', path: '/programs', query: params })\n }\n\n async *listAll(params?: {\n pageSize?: number\n }): AsyncGenerator<Program> {\n let page = 1\n const pageSize = params?.pageSize ?? 100\n\n while (true) {\n const response = await this.list({ page, limit: pageSize })\n yield* response.data\n\n if (!response.meta.hasMore) {\n break\n }\n\n page += 1\n }\n }\n\n async get(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async create(data: CreateProgramParams, options?: MutationOptions): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'POST',\n path: '/programs',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async update(id: string, data: UpdateProgramParams): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}`,\n body: data,\n })\n return envelope.data\n }\n\n async delete(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'DELETE',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async stats(id: string, params?: { period?: string }): Promise<ProgramStats> {\n const envelope = await this.http.request<{ data: ProgramStats; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/stats`,\n query: params,\n })\n return envelope.data\n }\n\n listAffiliates(\n id: string,\n params?: { includeBlocked?: boolean; cursor?: string; limit?: number; page?: number; pageSize?: number; offset?: number }\n ): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({\n method: 'GET',\n path: `/programs/${id}/affiliates`,\n query: params,\n })\n }\n\n async listCoupons(id: string): Promise<Coupon[]> {\n const envelope = await this.http.request<{ data: Coupon[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/coupons`,\n })\n return envelope.data\n }\n\n async createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/coupons`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async createInvite(\n id: string,\n data: {\n email?: string\n name?: string\n isPublic?: boolean\n usageLimit?: number\n expiresInDays?: number\n },\n options?: MutationOptions\n ): Promise<Invite> {\n const envelope = await this.http.request<{ data: Invite; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/invites`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async listInvites(id: string): Promise<Invite[]> {\n const envelope = await this.http.request<{ data: Invite[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/invites`,\n })\n return envelope.data\n }\n\n async deleteCoupon(couponId: string): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'DELETE',\n path: `/coupons/${couponId}`,\n })\n return envelope.data\n }\n\n async updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}/marketplace`,\n body: data,\n })\n return envelope.data\n }\n}\n","import { HttpClient } from './http.js'\nimport type { AgentRefConfig } from './types/index.js'\nimport { AffiliatesResource } from './resources/affiliates.js'\nimport { BillingResource } from './resources/billing.js'\nimport { ConversionsResource } from './resources/conversions.js'\nimport { FlagsResource } from './resources/flags.js'\nimport { MerchantResource } from './resources/merchant.js'\nimport { PayoutsResource } from './resources/payouts.js'\nimport { ProgramsResource } from './resources/programs.js'\n\nexport class AgentRef {\n readonly programs: ProgramsResource\n readonly affiliates: AffiliatesResource\n readonly conversions: ConversionsResource\n readonly payouts: PayoutsResource\n readonly flags: FlagsResource\n readonly billing: BillingResource\n readonly merchant: MerchantResource\n\n constructor(config?: AgentRefConfig) {\n const http = new HttpClient(config)\n\n this.programs = new ProgramsResource(http)\n this.affiliates = new AffiliatesResource(http)\n this.conversions = new ConversionsResource(http)\n this.payouts = new PayoutsResource(http)\n this.flags = new FlagsResource(http)\n this.billing = new BillingResource(http)\n this.merchant = new MerchantResource(http)\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAKvC,YAAY,SAAiB,MAAc,QAAgB,WAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAEO,IAAM,YAAN,cAAwB,cAAc;AAAA,EAC3C,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,cAAc;AAAA,EAChD,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EAGjD,YAAY,SAAiB,MAAc,WAAmB,SAAmB;AAC/E,UAAM,SAAS,MAAM,KAAK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WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,UAAmC;AACpD,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,YAAY,QAAQ;AAAA,IAC5B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,IAAY,MAAwE;AAC1G,UAAM,WAAW,MAAM,KAAK,KAAK,QAA0D;AAAA,MACzF,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,IACR,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AACF;;;AC1JO,IAAM,WAAN,MAAe;AAAA,EASpB,YAAY,QAAyB;AACnC,UAAM,OAAO,IAAI,WAAW,MAAM;AAElC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,aAAa,IAAI,mBAAmB,IAAI;AAC7C,SAAK,cAAc,IAAI,oBAAoB,IAAI;AAC/C,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,QAAQ,IAAI,cAAc,IAAI;AACnC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AAAA,EAC3C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/affiliates.ts","../src/resources/billing.ts","../src/resources/conversions.ts","../src/resources/flags.ts","../src/resources/merchant.ts","../src/resources/payouts.ts","../src/resources/programs.ts","../src/client.ts"],"sourcesContent":["export class AgentRefError extends Error {\n readonly code: string\n readonly status: number\n readonly requestId: string\n\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message)\n this.name = 'AgentRefError'\n this.code = code\n this.status = status\n this.requestId = requestId\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 401, requestId)\n this.name = 'AuthError'\n }\n}\n\nexport class ForbiddenError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 403, requestId)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class ValidationError extends AgentRefError {\n readonly details: unknown\n\n constructor(message: string, code: string, requestId: string, details?: unknown) {\n super(message, code, 400, requestId)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class NotFoundError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 404, requestId)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends AgentRefError {\n constructor(message: string, code: string, requestId: string) {\n super(message, code, 409, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends AgentRefError {\n readonly retryAfter: number\n\n constructor(message: string, code: string, requestId: string, retryAfter: number) {\n super(message, code, 429, requestId)\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class ServerError extends AgentRefError {\n constructor(message: string, code: string, status: number, requestId: string) {\n super(message, code, status, requestId)\n this.name = 'ServerError'\n }\n}\n","import {\n AgentRefError,\n AuthError,\n ConflictError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from './errors.js'\nimport type { AgentRefConfig } from './types/index.js'\n\nexport type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nconst SAFE_METHODS: ReadonlySet<HttpMethod> = new Set(['GET', 'HEAD'])\n\nexport interface RequestOptions {\n method: HttpMethod\n path: string\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n idempotencyKey?: string\n}\n\nconst DEFAULT_BASE_URL = 'https://www.agentref.dev/api/v1'\nconst DEFAULT_TIMEOUT = 30_000\nconst DEFAULT_MAX_RETRIES = 2\n\ndeclare const __SDK_VERSION__: string\nconst VERSION = typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : '0.0.0'\n\nfunction hasUsableIdempotencyKey(idempotencyKey: string | undefined): boolean {\n return typeof idempotencyKey === 'string' && idempotencyKey.trim().length > 0\n}\n\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n\n constructor(config: AgentRefConfig = {}) {\n if (typeof window !== 'undefined' && !config.dangerouslyAllowBrowser) {\n throw new Error(\n '[AgentRef] Refusing to initialize in browser context. API keys must not be exposed client-side. Use a server-side proxy to call the AgentRef API instead. To override: set dangerouslyAllowBrowser: true (understand the security implications first).'\n )\n }\n\n const apiKey = config.apiKey ?? process.env['AGENTREF_API_KEY']\n if (!apiKey) {\n throw new Error(\n '[AgentRef] API key is required. Pass it as apiKey or set the AGENTREF_API_KEY environment variable.'\n )\n }\n\n this.apiKey = apiKey\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query)\n const isSafe = SAFE_METHODS.has(options.method)\n const hasIdempotency = options.method === 'POST' && hasUsableIdempotencyKey(options.idempotencyKey)\n const canRetry = isSafe || hasIdempotency\n const maxAttempts = canRetry ? this.maxRetries + 1 : 1\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n let response: Response\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': `agentref-node/${VERSION}`,\n }\n\n if (hasIdempotency) {\n headers['Idempotency-Key'] = options.idempotencyKey!.trim()\n }\n\n response = await fetch(url, {\n method: options.method,\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: AbortSignal.timeout(this.timeout),\n })\n } catch (error) {\n if (canRetry && attempt < maxAttempts - 1) {\n await this.wait(this.backoff(attempt))\n continue\n }\n throw error\n }\n\n if (!response.ok) {\n const parsedError = await this.parseError(response)\n\n if (canRetry && this.isRetryable(response.status) && attempt < maxAttempts - 1) {\n const delay =\n response.status === 429\n ? this.retryAfterToMs(response.headers.get('Retry-After'))\n : this.backoff(attempt)\n await this.wait(delay)\n continue\n }\n\n throw parsedError\n }\n\n return response.json() as Promise<T>\n }\n\n throw new ServerError('Request failed after retries', 'REQUEST_RETRY_EXHAUSTED', 500, '')\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {\n const normalizedPath = path.startsWith('/') ? path : `/${path}`\n const url = new URL(`${this.baseUrl}${normalizedPath}`)\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n return url.toString()\n }\n\n private async parseError(response: Response): Promise<AgentRefError> {\n const json = (await response.json().catch(() => ({}))) as {\n error?: { code?: string; message?: string; details?: unknown }\n meta?: { requestId?: string }\n }\n\n const code = json.error?.code ?? 'UNKNOWN_ERROR'\n const message = json.error?.message ?? response.statusText\n const requestId = json.meta?.requestId ?? ''\n const details = json.error?.details\n\n if (response.status === 400) return new ValidationError(message, code, requestId, details)\n if (response.status === 401) return new AuthError(message, code, requestId)\n if (response.status === 403) return new ForbiddenError(message, code, requestId)\n if (response.status === 404) return new NotFoundError(message, code, requestId)\n if (response.status === 409) return new ConflictError(message, code, requestId)\n if (response.status === 429) {\n return new RateLimitError(message, code, requestId, this.retryAfterToSeconds(response.headers.get('Retry-After')))\n }\n\n return new ServerError(message, code, response.status, requestId)\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500\n }\n\n private retryAfterToSeconds(headerValue: string | null): number {\n if (!headerValue) return 60\n\n const numericSeconds = Number(headerValue)\n if (!Number.isNaN(numericSeconds) && numericSeconds >= 0) {\n return Math.ceil(numericSeconds)\n }\n\n const asDate = Date.parse(headerValue)\n if (!Number.isNaN(asDate)) {\n const deltaMs = asDate - Date.now()\n return Math.max(0, Math.ceil(deltaMs / 1000))\n }\n\n return 60\n }\n\n private retryAfterToMs(headerValue: string | null): number {\n return this.retryAfterToSeconds(headerValue) * 1000\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms)\n })\n }\n\n private backoff(attempt: number): number {\n return 500 * Math.pow(2, attempt)\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Affiliate, AffiliateSortBy, AffiliateStatus, MutationOptions, PaginatedResponse, SortOrder } from '../types/index.js'\n\nexport class AffiliatesResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n includeBlocked?: boolean\n search?: string\n sortBy?: AffiliateSortBy\n sortOrder?: SortOrder\n status?: AffiliateStatus\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({ method: 'GET', path: '/affiliates', query: params })\n }\n\n async get(id: string, options?: { include?: 'stats' }): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'GET',\n path: `/affiliates/${id}`,\n query: options?.include ? { include: options.include } : undefined,\n })\n return envelope.data\n }\n\n async approve(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/approve`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async block(id: string, data?: { reason?: string }, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/block`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async unblock(id: string, options?: MutationOptions): Promise<Affiliate> {\n const envelope = await this.http.request<{ data: Affiliate; meta: unknown }>({\n method: 'POST',\n path: `/affiliates/${id}/unblock`,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { BillingStatus, BillingTier, MutationOptions } from '../types/index.js'\n\nexport class BillingResource {\n constructor(private readonly http: HttpClient) {}\n\n async current(): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'GET',\n path: '/billing',\n })\n return envelope.data\n }\n\n async tiers(): Promise<BillingTier[]> {\n const envelope = await this.http.request<{ data: BillingTier[]; meta: unknown }>({\n method: 'GET',\n path: '/billing/tiers',\n })\n return envelope.data\n }\n\n async subscribe(data: { tier: 'starter' | 'growth' | 'pro' | 'scale' }, options?: MutationOptions): Promise<BillingStatus> {\n const envelope = await this.http.request<{ data: BillingStatus; meta: unknown }>({\n method: 'POST',\n path: '/billing/subscribe',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Conversion, ConversionStats, PaginatedResponse } from '../types/index.js'\n\nexport class ConversionsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: string\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Conversion>> {\n return this.http.request({ method: 'GET', path: '/conversions', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<ConversionStats> {\n const envelope = await this.http.request<{ data: ConversionStats; meta: unknown }>({\n method: 'GET',\n path: '/conversions/stats',\n query: params,\n })\n return envelope.data\n }\n\n async recent(params?: { limit?: number }): Promise<Conversion[]> {\n const envelope = await this.http.request<{ data: Conversion[]; meta: unknown }>({\n method: 'GET',\n path: '/conversions/recent',\n query: params,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { Flag, FlagStats, MutationOptions, PaginatedResponse, ResolveFlagParams } from '../types/index.js'\n\nexport class FlagsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n status?: string\n type?: string\n affiliateId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Flag>> {\n return this.http.request({ method: 'GET', path: '/flags', query: params })\n }\n\n async stats(): Promise<FlagStats> {\n const envelope = await this.http.request<{ data: FlagStats; meta: unknown }>({\n method: 'GET',\n path: '/flags/stats',\n })\n return envelope.data\n }\n\n async resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag> {\n const envelope = await this.http.request<{ data: Flag; meta: unknown }>({\n method: 'POST',\n path: `/flags/${id}/resolve`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Merchant,\n MerchantDomainStatus,\n NotificationPreferences,\n PayoutInfo,\n StripeConnectSession,\n UpdateMerchantParams,\n UpdateNotificationPreferencesParams,\n UpdatePayoutInfoParams,\n} from '../types/index.js'\n\nexport class MerchantResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'GET',\n path: '/merchant',\n })\n return envelope.data\n }\n\n async update(data: UpdateMerchantParams): Promise<Merchant> {\n const envelope = await this.http.request<{ data: Merchant; meta: unknown }>({\n method: 'PATCH',\n path: '/merchant',\n body: data,\n })\n return envelope.data\n }\n\n async connectStripe(): Promise<StripeConnectSession> {\n const envelope = await this.http.request<{ data: StripeConnectSession; meta: unknown }>({\n method: 'POST',\n path: '/merchant/connect-stripe',\n })\n return envelope.data\n }\n\n async domainStatus(): Promise<MerchantDomainStatus> {\n const envelope = await this.http.request<{ data: MerchantDomainStatus; meta: unknown }>({\n method: 'GET',\n path: '/merchant/domain-status',\n })\n return envelope.data\n }\n\n async getPayoutInfo(): Promise<PayoutInfo> {\n const envelope = await this.http.request<{ data: PayoutInfo; meta: unknown }>({\n method: 'GET',\n path: '/me/payout-info',\n })\n return envelope.data\n }\n\n async updatePayoutInfo(data: UpdatePayoutInfoParams): Promise<PayoutInfo> {\n const envelope = await this.http.request<{ data: PayoutInfo; meta: unknown }>({\n method: 'PATCH',\n path: '/me/payout-info',\n body: data,\n })\n return envelope.data\n }\n\n async getNotifications(): Promise<NotificationPreferences> {\n const envelope = await this.http.request<{ data: NotificationPreferences; meta: unknown }>({\n method: 'GET',\n path: '/merchant/notifications',\n })\n return envelope.data\n }\n\n async updateNotifications(data: UpdateNotificationPreferencesParams): Promise<NotificationPreferences> {\n const envelope = await this.http.request<{ data: NotificationPreferences; meta: unknown }>({\n method: 'PUT',\n path: '/merchant/notifications',\n body: data,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatePayoutParams, MutationOptions, PaginatedResponse, PendingAffiliate, Payout, PayoutStats, PayoutStatus } from '../types/index.js'\n\nexport class PayoutsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n programId?: string\n affiliateId?: string\n status?: PayoutStatus\n startDate?: string\n endDate?: string\n from?: string\n to?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<Payout>> {\n return this.http.request({ method: 'GET', path: '/payouts', query: params })\n }\n\n listPending(params?: {\n programId?: string\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n }): Promise<PaginatedResponse<PendingAffiliate>> {\n return this.http.request({ method: 'GET', path: '/payouts/pending', query: params })\n }\n\n async stats(params?: { programId?: string; period?: '7d' | '30d' | '90d' | 'all' }): Promise<PayoutStats> {\n const envelope = await this.http.request<{ data: PayoutStats; meta: unknown }>({\n method: 'GET',\n path: '/payouts/stats',\n query: params,\n })\n return envelope.data\n }\n\n async create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'POST',\n path: '/payouts',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Affiliate,\n Coupon,\n CreateCouponParams,\n CreateInviteParams,\n CreateProgramParams,\n Invite,\n MutationOptions,\n PaginatedResponse,\n Program,\n ProgramStats,\n UpdateProgramMarketplaceParams,\n UpdateProgramParams,\n} from '../types/index.js'\n\nexport class ProgramsResource {\n constructor(private readonly http: HttpClient) {}\n\n list(params?: {\n cursor?: string\n limit?: number\n page?: number\n pageSize?: number\n offset?: number\n status?: string\n }): Promise<PaginatedResponse<Program>> {\n return this.http.request({ method: 'GET', path: '/programs', query: params })\n }\n\n async *listAll(params?: {\n pageSize?: number\n }): AsyncGenerator<Program> {\n let page = 1\n const pageSize = params?.pageSize ?? 100\n\n while (true) {\n const response = await this.list({ page, limit: pageSize })\n yield* response.data\n\n if (!response.meta.hasMore) {\n break\n }\n\n page += 1\n }\n }\n\n async get(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async create(data: CreateProgramParams, options?: MutationOptions): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'POST',\n path: '/programs',\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async update(id: string, data: UpdateProgramParams): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}`,\n body: data,\n })\n return envelope.data\n }\n\n async delete(id: string): Promise<Program> {\n const envelope = await this.http.request<{ data: Program; meta: unknown }>({\n method: 'DELETE',\n path: `/programs/${id}`,\n })\n return envelope.data\n }\n\n async stats(id: string, params?: { period?: string }): Promise<ProgramStats> {\n const envelope = await this.http.request<{ data: ProgramStats; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/stats`,\n query: params,\n })\n return envelope.data\n }\n\n listAffiliates(\n id: string,\n params?: { includeBlocked?: boolean; cursor?: string; limit?: number; page?: number; pageSize?: number; offset?: number }\n ): Promise<PaginatedResponse<Affiliate>> {\n return this.http.request({\n method: 'GET',\n path: `/programs/${id}/affiliates`,\n query: params,\n })\n }\n\n async listCoupons(id: string): Promise<Coupon[]> {\n const envelope = await this.http.request<{ data: Coupon[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/coupons`,\n })\n return envelope.data\n }\n\n async createCoupon(id: string, data: CreateCouponParams, options?: MutationOptions): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/coupons`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async createInvite(\n id: string,\n data: CreateInviteParams,\n options?: MutationOptions\n ): Promise<Invite> {\n const envelope = await this.http.request<{ data: Invite; meta: unknown }>({\n method: 'POST',\n path: `/programs/${id}/invites`,\n body: data,\n idempotencyKey: options?.idempotencyKey,\n })\n return envelope.data\n }\n\n async listInvites(id: string): Promise<Invite[]> {\n const envelope = await this.http.request<{ data: Invite[]; meta: unknown }>({\n method: 'GET',\n path: `/programs/${id}/invites`,\n })\n return envelope.data\n }\n\n async deleteCoupon(couponId: string): Promise<Coupon> {\n const envelope = await this.http.request<{ data: Coupon; meta: unknown }>({\n method: 'DELETE',\n path: `/coupons/${couponId}`,\n })\n return envelope.data\n }\n\n async updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>> {\n const envelope = await this.http.request<{ data: Record<string, unknown>; meta: unknown }>({\n method: 'PATCH',\n path: `/programs/${id}/marketplace`,\n body: data,\n })\n return envelope.data\n }\n}\n","import { HttpClient } from './http.js'\nimport type { AgentRefConfig } from './types/index.js'\nimport { AffiliatesResource } from './resources/affiliates.js'\nimport { BillingResource } from './resources/billing.js'\nimport { ConversionsResource } from './resources/conversions.js'\nimport { FlagsResource } from './resources/flags.js'\nimport { MerchantResource } from './resources/merchant.js'\nimport { PayoutsResource } from './resources/payouts.js'\nimport { ProgramsResource } from './resources/programs.js'\n\nexport class AgentRef {\n readonly programs: ProgramsResource\n readonly affiliates: AffiliatesResource\n readonly conversions: ConversionsResource\n readonly payouts: PayoutsResource\n readonly flags: FlagsResource\n readonly billing: BillingResource\n readonly merchant: MerchantResource\n\n constructor(config?: AgentRefConfig) {\n const http = new HttpClient(config)\n\n this.programs = new ProgramsResource(http)\n this.affiliates = new AffiliatesResource(http)\n this.conversions = new ConversionsResource(http)\n this.payouts = new PayoutsResource(http)\n this.flags = new FlagsResource(http)\n this.billing = new BillingResource(http)\n this.merchant = new MerchantResource(http)\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAKvC,YAAY,SAAiB,MAAc,QAAgB,WAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAEO,IAAM,YAAN,cAAwB,cAAc;AAAA,EAC3C,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,cAAc;AAAA,EAChD,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EAGjD,YAAY,SAAiB,MAAc,WAAmB,SAAmB;AAC/E,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,cAAc;AAAA,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MACA,SACiB;AACjB,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,MACN,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,YAAY,IAA+B;AAC/C,UAAM,WAAW,MAAM,KAAK,KAAK,QAA2C;AAAA,MAC1E,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,IACvB,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,UAAmC;AACpD,UAAM,WAAW,MAAM,KAAK,KAAK,QAAyC;AAAA,MACxE,QAAQ;AAAA,MACR,MAAM,YAAY,QAAQ;AAAA,IAC5B,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,IAAY,MAAwE;AAC1G,UAAM,WAAW,MAAM,KAAK,KAAK,QAA0D;AAAA,MACzF,QAAQ;AAAA,MACR,MAAM,aAAa,EAAE;AAAA,MACrB,MAAM;AAAA,IACR,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AACF;;;ACrJO,IAAM,WAAN,MAAe;AAAA,EASpB,YAAY,QAAyB;AACnC,UAAM,OAAO,IAAI,WAAW,MAAM;AAElC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,aAAa,IAAI,mBAAmB,IAAI;AAC7C,SAAK,cAAc,IAAI,oBAAoB,IAAI;AAC/C,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,QAAQ,IAAI,cAAc,IAAI;AACnC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AACvC,SAAK,WAAW,IAAI,iBAAiB,IAAI;AAAA,EAC3C;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentref",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Official TypeScript/JavaScript SDK for the AgentRef Affiliate API",
5
5
  "author": "AgentRef <hi@agentref.dev>",
6
6
  "license": "MIT",