agentref 1.0.2 → 1.0.4
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 +15 -0
- package/README.md +4 -4
- package/dist/index.cjs +54 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +129 -95
- package/dist/index.d.ts +129 -95
- package/dist/index.mjs +54 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
- Added `search`, `sortBy`, `sortOrder`, `status` parameters to `affiliates.list()`.
|
|
6
|
+
- Added `trackingCode`, `skipOnboarding` parameters to `programs.createInvite()`.
|
|
7
|
+
- Added `merchant.getPayoutInfo()` and `merchant.updatePayoutInfo()` methods.
|
|
8
|
+
- Added `merchant.getNotifications()` and `merchant.updateNotifications()` methods.
|
|
9
|
+
- Added `PUT` to `HttpMethod` union type.
|
|
10
|
+
- Added new types: `AffiliateSortBy`, `SortOrder`, `CreateInviteParams`, `PayoutInfo`, `UpdatePayoutInfoParams`, `NotificationPreferences`, `UpdateNotificationPreferencesParams`.
|
|
11
|
+
|
|
12
|
+
## 1.0.3
|
|
13
|
+
|
|
14
|
+
- Hardened idempotency retry gate: POST retries now require a non-empty idempotency key.
|
|
15
|
+
- Added missing merchant API methods: merchant update/connectStripe, payouts create, programs marketplace/invites/coupon delete.
|
|
16
|
+
- Tightened contract types for core models and request/response shapes.
|
|
17
|
+
|
|
3
18
|
## 1.0.0
|
|
4
19
|
|
|
5
20
|
- Initial release.
|
package/README.md
CHANGED
|
@@ -28,19 +28,19 @@ console.log(programs.meta.requestId)
|
|
|
28
28
|
## Resources
|
|
29
29
|
|
|
30
30
|
- `client.programs`
|
|
31
|
-
- `list`, `listAll`, `get`, `create`, `update`, `delete`, `stats`, `listAffiliates`, `listCoupons`, `createCoupon`, `createInvite`
|
|
31
|
+
- `list`, `listAll`, `get`, `create`, `update`, `delete`, `stats`, `listAffiliates`, `listCoupons`, `createCoupon`, `deleteCoupon`, `listInvites`, `createInvite`, `updateMarketplace`
|
|
32
32
|
- `client.affiliates`
|
|
33
33
|
- `list`, `get`, `approve`, `block`, `unblock`
|
|
34
34
|
- `client.conversions`
|
|
35
35
|
- `list`, `stats`, `recent`
|
|
36
36
|
- `client.payouts`
|
|
37
|
-
- `list`, `listPending`, `stats`
|
|
37
|
+
- `list`, `listPending`, `stats`, `create`
|
|
38
38
|
- `client.flags`
|
|
39
39
|
- `list`, `stats`, `resolve`
|
|
40
40
|
- `client.billing`
|
|
41
41
|
- `current`, `tiers`, `subscribe`
|
|
42
42
|
- `client.merchant`
|
|
43
|
-
- `get`, `domainStatus`
|
|
43
|
+
- `get`, `update`, `connectStripe`, `domainStatus`
|
|
44
44
|
|
|
45
45
|
## Pagination
|
|
46
46
|
|
|
@@ -64,7 +64,7 @@ For auto-pagination use `listAll()`. Stop condition is `meta.hasMore === false`.
|
|
|
64
64
|
|
|
65
65
|
## Idempotency
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
POST methods with server idempotency support accept `options?: { idempotencyKey?: string }`.
|
|
68
68
|
|
|
69
69
|
- If set, `Idempotency-Key` is sent.
|
|
70
70
|
- Retries for mutating requests are only enabled for POST + `idempotencyKey`.
|
package/dist/index.cjs
CHANGED
|
@@ -93,7 +93,10 @@ 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.
|
|
96
|
+
var VERSION = true ? "1.0.4" : "0.0.0";
|
|
97
|
+
function hasUsableIdempotencyKey(idempotencyKey) {
|
|
98
|
+
return typeof idempotencyKey === "string" && idempotencyKey.trim().length > 0;
|
|
99
|
+
}
|
|
97
100
|
var HttpClient = class {
|
|
98
101
|
constructor(config = {}) {
|
|
99
102
|
if (typeof window !== "undefined" && !config.dangerouslyAllowBrowser) {
|
|
@@ -115,7 +118,8 @@ var HttpClient = class {
|
|
|
115
118
|
async request(options) {
|
|
116
119
|
const url = this.buildUrl(options.path, options.query);
|
|
117
120
|
const isSafe = SAFE_METHODS.has(options.method);
|
|
118
|
-
const
|
|
121
|
+
const hasIdempotency = options.method === "POST" && hasUsableIdempotencyKey(options.idempotencyKey);
|
|
122
|
+
const canRetry = isSafe || hasIdempotency;
|
|
119
123
|
const maxAttempts = canRetry ? this.maxRetries + 1 : 1;
|
|
120
124
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
121
125
|
let response;
|
|
@@ -125,8 +129,8 @@ var HttpClient = class {
|
|
|
125
129
|
"Content-Type": "application/json",
|
|
126
130
|
"User-Agent": `agentref-node/${VERSION}`
|
|
127
131
|
};
|
|
128
|
-
if (
|
|
129
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
132
|
+
if (hasIdempotency) {
|
|
133
|
+
headers["Idempotency-Key"] = options.idempotencyKey.trim();
|
|
130
134
|
}
|
|
131
135
|
response = await fetch(url, {
|
|
132
136
|
method: options.method,
|
|
@@ -347,6 +351,21 @@ var MerchantResource = class {
|
|
|
347
351
|
});
|
|
348
352
|
return envelope.data;
|
|
349
353
|
}
|
|
354
|
+
async update(data) {
|
|
355
|
+
const envelope = await this.http.request({
|
|
356
|
+
method: "PATCH",
|
|
357
|
+
path: "/merchant",
|
|
358
|
+
body: data
|
|
359
|
+
});
|
|
360
|
+
return envelope.data;
|
|
361
|
+
}
|
|
362
|
+
async connectStripe() {
|
|
363
|
+
const envelope = await this.http.request({
|
|
364
|
+
method: "POST",
|
|
365
|
+
path: "/merchant/connect-stripe"
|
|
366
|
+
});
|
|
367
|
+
return envelope.data;
|
|
368
|
+
}
|
|
350
369
|
async domainStatus() {
|
|
351
370
|
const envelope = await this.http.request({
|
|
352
371
|
method: "GET",
|
|
@@ -375,6 +394,15 @@ var PayoutsResource = class {
|
|
|
375
394
|
});
|
|
376
395
|
return envelope.data;
|
|
377
396
|
}
|
|
397
|
+
async create(data, options) {
|
|
398
|
+
const envelope = await this.http.request({
|
|
399
|
+
method: "POST",
|
|
400
|
+
path: "/payouts",
|
|
401
|
+
body: data,
|
|
402
|
+
idempotencyKey: options?.idempotencyKey
|
|
403
|
+
});
|
|
404
|
+
return envelope.data;
|
|
405
|
+
}
|
|
378
406
|
};
|
|
379
407
|
|
|
380
408
|
// src/resources/programs.ts
|
|
@@ -468,6 +496,28 @@ var ProgramsResource = class {
|
|
|
468
496
|
});
|
|
469
497
|
return envelope.data;
|
|
470
498
|
}
|
|
499
|
+
async listInvites(id) {
|
|
500
|
+
const envelope = await this.http.request({
|
|
501
|
+
method: "GET",
|
|
502
|
+
path: `/programs/${id}/invites`
|
|
503
|
+
});
|
|
504
|
+
return envelope.data;
|
|
505
|
+
}
|
|
506
|
+
async deleteCoupon(couponId) {
|
|
507
|
+
const envelope = await this.http.request({
|
|
508
|
+
method: "DELETE",
|
|
509
|
+
path: `/coupons/${couponId}`
|
|
510
|
+
});
|
|
511
|
+
return envelope.data;
|
|
512
|
+
}
|
|
513
|
+
async updateMarketplace(id, data) {
|
|
514
|
+
const envelope = await this.http.request({
|
|
515
|
+
method: "PATCH",
|
|
516
|
+
path: `/programs/${id}/marketplace`,
|
|
517
|
+
body: data
|
|
518
|
+
});
|
|
519
|
+
return envelope.data;
|
|
520
|
+
}
|
|
471
521
|
};
|
|
472
522
|
|
|
473
523
|
// src/client.ts
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 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 PayoutStats,\n PayoutStatus,\n Program,\n ProgramStats,\n ProgramStatus,\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\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 canRetry = isSafe || (options.method === 'POST' && options.idempotencyKey !== undefined)\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 (options.method === 'POST' && options.idempotencyKey) {\n headers['Idempotency-Key'] = options.idempotencyKey\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 } from '../types/index.js'\n\nexport interface DomainStatus {\n domain: string | null\n verified: boolean\n txtRecord?: string | null\n [key: string]: unknown\n}\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 domainStatus(): Promise<DomainStatus> {\n const envelope = await this.http.request<{ data: DomainStatus; 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 { 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","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 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 }): 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","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,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,SA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D,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,IAAY,MAA0B,SAA4C;AACnG,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,aACJ,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;AACF;;;AC/HO,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 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,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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AAA,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":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -23,33 +23,54 @@ interface MutationOptions {
|
|
|
23
23
|
interface Merchant {
|
|
24
24
|
id: string;
|
|
25
25
|
email: string;
|
|
26
|
-
companyName
|
|
27
|
-
domain
|
|
28
|
-
domainVerified
|
|
29
|
-
trustLevel
|
|
30
|
-
stripeConnected
|
|
31
|
-
createdAt
|
|
32
|
-
|
|
26
|
+
companyName: string | null;
|
|
27
|
+
domain: string | null;
|
|
28
|
+
domainVerified: boolean;
|
|
29
|
+
trustLevel: string;
|
|
30
|
+
stripeConnected: boolean;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
}
|
|
33
|
+
interface UpdateMerchantParams {
|
|
34
|
+
companyName?: string;
|
|
35
|
+
website?: string;
|
|
36
|
+
logoUrl?: string;
|
|
37
|
+
timezone?: string;
|
|
38
|
+
defaultCookieDuration?: number;
|
|
39
|
+
defaultPayoutThreshold?: number;
|
|
40
|
+
}
|
|
41
|
+
interface MerchantDomainStatus {
|
|
42
|
+
domain: string | null;
|
|
43
|
+
verified: boolean;
|
|
44
|
+
txtRecord: string | null;
|
|
45
|
+
}
|
|
46
|
+
interface StripeConnectSession {
|
|
47
|
+
url: string;
|
|
33
48
|
}
|
|
34
49
|
type CommissionType = 'one_time' | 'recurring' | 'recurring_limited';
|
|
35
50
|
type ProgramStatus = 'active' | 'paused' | 'archived';
|
|
51
|
+
type ProgramMarketplaceVisibility = 'private' | 'public';
|
|
36
52
|
interface Program {
|
|
37
53
|
id: string;
|
|
38
54
|
name: string;
|
|
39
|
-
description
|
|
40
|
-
landingPageUrl
|
|
55
|
+
description: string | null;
|
|
56
|
+
landingPageUrl: string | null;
|
|
41
57
|
commissionType: CommissionType;
|
|
42
58
|
commissionPercent: number;
|
|
43
|
-
commissionLimitMonths
|
|
59
|
+
commissionLimitMonths: number | null;
|
|
44
60
|
cookieDuration: number;
|
|
45
61
|
payoutThreshold: number;
|
|
46
62
|
autoApproveAffiliates: boolean;
|
|
47
63
|
status: ProgramStatus;
|
|
48
|
-
isPublic
|
|
49
|
-
merchantId
|
|
50
|
-
createdAt
|
|
51
|
-
updatedAt
|
|
52
|
-
|
|
64
|
+
isPublic: boolean;
|
|
65
|
+
merchantId: string;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
}
|
|
69
|
+
interface UpdateProgramMarketplaceParams {
|
|
70
|
+
status?: ProgramMarketplaceVisibility;
|
|
71
|
+
category?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
logoUrl?: string;
|
|
53
74
|
}
|
|
54
75
|
interface CreateProgramParams {
|
|
55
76
|
name: string;
|
|
@@ -72,6 +93,7 @@ interface UpdateProgramParams {
|
|
|
72
93
|
description?: string;
|
|
73
94
|
landingPageUrl?: string;
|
|
74
95
|
status?: ProgramStatus;
|
|
96
|
+
isPublic?: boolean;
|
|
75
97
|
}
|
|
76
98
|
interface CreateCouponParams {
|
|
77
99
|
affiliateId: string;
|
|
@@ -79,84 +101,99 @@ interface CreateCouponParams {
|
|
|
79
101
|
expiresAt?: string;
|
|
80
102
|
}
|
|
81
103
|
interface ProgramStats {
|
|
82
|
-
|
|
104
|
+
clicks: number;
|
|
105
|
+
conversions: number;
|
|
106
|
+
revenue: number;
|
|
107
|
+
commissions: number;
|
|
108
|
+
period: string;
|
|
83
109
|
}
|
|
84
110
|
type AffiliateStatus = 'pending' | 'approved' | 'blocked';
|
|
85
111
|
interface Affiliate {
|
|
86
112
|
id: string;
|
|
87
|
-
userId
|
|
88
|
-
programId
|
|
89
|
-
code
|
|
90
|
-
status
|
|
91
|
-
totalClicks
|
|
92
|
-
totalConversions
|
|
93
|
-
totalEarnings
|
|
94
|
-
createdAt
|
|
95
|
-
[key: string]: unknown;
|
|
113
|
+
userId: string;
|
|
114
|
+
programId: string;
|
|
115
|
+
code: string;
|
|
116
|
+
status: AffiliateStatus;
|
|
117
|
+
totalClicks: number;
|
|
118
|
+
totalConversions: number;
|
|
119
|
+
totalEarnings: number;
|
|
120
|
+
createdAt: string;
|
|
96
121
|
}
|
|
97
122
|
type ConversionStatus = 'pending' | 'approved' | 'rejected' | 'refunded';
|
|
98
123
|
interface Conversion {
|
|
99
124
|
id: string;
|
|
100
|
-
affiliateId
|
|
101
|
-
programId
|
|
102
|
-
amount
|
|
103
|
-
commission
|
|
104
|
-
status
|
|
105
|
-
method
|
|
106
|
-
stripeSessionId
|
|
107
|
-
createdAt
|
|
108
|
-
[key: string]: unknown;
|
|
125
|
+
affiliateId: string;
|
|
126
|
+
programId: string;
|
|
127
|
+
amount: number;
|
|
128
|
+
commission: number;
|
|
129
|
+
status: ConversionStatus;
|
|
130
|
+
method: 'cookie' | 'coupon' | 'metadata';
|
|
131
|
+
stripeSessionId: string | null;
|
|
132
|
+
createdAt: string;
|
|
109
133
|
}
|
|
110
134
|
interface ConversionStats {
|
|
111
|
-
|
|
135
|
+
total: number;
|
|
136
|
+
pending: number;
|
|
137
|
+
approved: number;
|
|
138
|
+
totalRevenue: number;
|
|
139
|
+
totalCommissions: number;
|
|
112
140
|
}
|
|
113
141
|
type PayoutStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
114
142
|
interface Payout {
|
|
115
143
|
id: string;
|
|
116
|
-
affiliateId
|
|
117
|
-
amount
|
|
118
|
-
status
|
|
119
|
-
method
|
|
120
|
-
createdAt
|
|
121
|
-
completedAt
|
|
122
|
-
|
|
144
|
+
affiliateId: string;
|
|
145
|
+
amount: number;
|
|
146
|
+
status: PayoutStatus;
|
|
147
|
+
method: string | null;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
completedAt: string | null;
|
|
150
|
+
}
|
|
151
|
+
interface CreatePayoutParams {
|
|
152
|
+
affiliateId: string;
|
|
153
|
+
programId: string;
|
|
154
|
+
method: 'paypal' | 'bank_transfer';
|
|
155
|
+
notes?: string;
|
|
123
156
|
}
|
|
124
157
|
interface PendingAffiliate {
|
|
125
|
-
affiliateId
|
|
126
|
-
email
|
|
127
|
-
name
|
|
128
|
-
code
|
|
129
|
-
programId
|
|
130
|
-
programName
|
|
131
|
-
payoutMethod
|
|
132
|
-
paypalEmail
|
|
133
|
-
bankIban
|
|
134
|
-
pendingAmount
|
|
135
|
-
currency
|
|
136
|
-
threshold
|
|
137
|
-
meetsThreshold
|
|
138
|
-
commissionCount
|
|
139
|
-
hasPayoutMethod
|
|
140
|
-
[key: string]: unknown;
|
|
158
|
+
affiliateId: string;
|
|
159
|
+
email: string;
|
|
160
|
+
name: string | null;
|
|
161
|
+
code: string;
|
|
162
|
+
programId: string;
|
|
163
|
+
programName: string;
|
|
164
|
+
payoutMethod: 'paypal' | 'bank_transfer' | null;
|
|
165
|
+
paypalEmail: string | null;
|
|
166
|
+
bankIban: string | null;
|
|
167
|
+
pendingAmount: number;
|
|
168
|
+
currency: string;
|
|
169
|
+
threshold: number;
|
|
170
|
+
meetsThreshold: boolean;
|
|
171
|
+
commissionCount: number;
|
|
172
|
+
hasPayoutMethod: boolean;
|
|
141
173
|
}
|
|
142
174
|
interface PayoutStats {
|
|
143
|
-
|
|
175
|
+
totalPaid: number;
|
|
176
|
+
totalPending: number;
|
|
177
|
+
count: number;
|
|
144
178
|
}
|
|
145
179
|
type FlagStatus = 'open' | 'reviewed' | 'dismissed' | 'confirmed';
|
|
146
180
|
type FlagType = 'suspicious_activity' | 'self_referral' | 'high_click_frequency' | 'conversion_anomaly' | 'manual_review';
|
|
147
181
|
interface Flag {
|
|
148
182
|
id: string;
|
|
149
|
-
affiliateId
|
|
150
|
-
type
|
|
151
|
-
status
|
|
152
|
-
details
|
|
153
|
-
note
|
|
154
|
-
createdAt
|
|
155
|
-
resolvedAt
|
|
156
|
-
[key: string]: unknown;
|
|
183
|
+
affiliateId: string;
|
|
184
|
+
type: FlagType;
|
|
185
|
+
status: FlagStatus;
|
|
186
|
+
details: Record<string, unknown> | null;
|
|
187
|
+
note: string | null;
|
|
188
|
+
createdAt: string;
|
|
189
|
+
resolvedAt: string | null;
|
|
157
190
|
}
|
|
158
191
|
interface FlagStats {
|
|
159
|
-
|
|
192
|
+
open: number;
|
|
193
|
+
reviewed: number;
|
|
194
|
+
dismissed: number;
|
|
195
|
+
confirmed: number;
|
|
196
|
+
total: number;
|
|
160
197
|
}
|
|
161
198
|
interface ResolveFlagParams {
|
|
162
199
|
status: 'reviewed' | 'dismissed' | 'confirmed';
|
|
@@ -168,33 +205,29 @@ interface BillingTier {
|
|
|
168
205
|
id: BillingTierId;
|
|
169
206
|
name: string;
|
|
170
207
|
price: number;
|
|
171
|
-
maxRevenue
|
|
172
|
-
features
|
|
173
|
-
bookable
|
|
174
|
-
[key: string]: unknown;
|
|
208
|
+
maxRevenue: number;
|
|
209
|
+
features: string[];
|
|
210
|
+
bookable: boolean;
|
|
175
211
|
}
|
|
176
212
|
interface BillingStatus {
|
|
177
|
-
tier
|
|
178
|
-
monthlyRevenue
|
|
179
|
-
nextTier
|
|
180
|
-
stripeSubscriptionId
|
|
181
|
-
[key: string]: unknown;
|
|
213
|
+
tier: BillingTierId;
|
|
214
|
+
monthlyRevenue: number;
|
|
215
|
+
nextTier: BillingTierId | null;
|
|
216
|
+
stripeSubscriptionId: string | null;
|
|
182
217
|
}
|
|
183
218
|
interface Coupon {
|
|
184
219
|
id: string;
|
|
185
220
|
code: string;
|
|
186
|
-
affiliateId
|
|
187
|
-
programId
|
|
188
|
-
createdAt
|
|
189
|
-
[key: string]: unknown;
|
|
221
|
+
affiliateId: string;
|
|
222
|
+
programId: string;
|
|
223
|
+
createdAt: string;
|
|
190
224
|
}
|
|
191
225
|
interface Invite {
|
|
192
|
-
token
|
|
193
|
-
email
|
|
194
|
-
programId
|
|
195
|
-
expiresAt
|
|
196
|
-
createdAt
|
|
197
|
-
[key: string]: unknown;
|
|
226
|
+
token: string;
|
|
227
|
+
email: string;
|
|
228
|
+
programId: string;
|
|
229
|
+
expiresAt: string;
|
|
230
|
+
createdAt: string;
|
|
198
231
|
}
|
|
199
232
|
|
|
200
233
|
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
|
|
@@ -294,17 +327,13 @@ declare class FlagsResource {
|
|
|
294
327
|
resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag>;
|
|
295
328
|
}
|
|
296
329
|
|
|
297
|
-
interface DomainStatus {
|
|
298
|
-
domain: string | null;
|
|
299
|
-
verified: boolean;
|
|
300
|
-
txtRecord?: string | null;
|
|
301
|
-
[key: string]: unknown;
|
|
302
|
-
}
|
|
303
330
|
declare class MerchantResource {
|
|
304
331
|
private readonly http;
|
|
305
332
|
constructor(http: HttpClient);
|
|
306
333
|
get(): Promise<Merchant>;
|
|
307
|
-
|
|
334
|
+
update(data: UpdateMerchantParams): Promise<Merchant>;
|
|
335
|
+
connectStripe(): Promise<StripeConnectSession>;
|
|
336
|
+
domainStatus(): Promise<MerchantDomainStatus>;
|
|
308
337
|
}
|
|
309
338
|
|
|
310
339
|
declare class PayoutsResource {
|
|
@@ -336,6 +365,7 @@ declare class PayoutsResource {
|
|
|
336
365
|
programId?: string;
|
|
337
366
|
period?: '7d' | '30d' | '90d' | 'all';
|
|
338
367
|
}): Promise<PayoutStats>;
|
|
368
|
+
create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>>;
|
|
339
369
|
}
|
|
340
370
|
|
|
341
371
|
declare class ProgramsResource {
|
|
@@ -347,6 +377,7 @@ declare class ProgramsResource {
|
|
|
347
377
|
page?: number;
|
|
348
378
|
pageSize?: number;
|
|
349
379
|
offset?: number;
|
|
380
|
+
status?: string;
|
|
350
381
|
}): Promise<PaginatedResponse<Program>>;
|
|
351
382
|
listAll(params?: {
|
|
352
383
|
pageSize?: number;
|
|
@@ -375,6 +406,9 @@ declare class ProgramsResource {
|
|
|
375
406
|
usageLimit?: number;
|
|
376
407
|
expiresInDays?: number;
|
|
377
408
|
}, options?: MutationOptions): Promise<Invite>;
|
|
409
|
+
listInvites(id: string): Promise<Invite[]>;
|
|
410
|
+
deleteCoupon(couponId: string): Promise<Coupon>;
|
|
411
|
+
updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>>;
|
|
378
412
|
}
|
|
379
413
|
|
|
380
414
|
declare class AgentRef {
|
|
@@ -418,4 +452,4 @@ declare class ServerError extends AgentRefError {
|
|
|
418
452
|
constructor(message: string, code: string, status: number, requestId: string);
|
|
419
453
|
}
|
|
420
454
|
|
|
421
|
-
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 CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MutationOptions, NotFoundError, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type UpdateProgramParams, ValidationError };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,33 +23,54 @@ interface MutationOptions {
|
|
|
23
23
|
interface Merchant {
|
|
24
24
|
id: string;
|
|
25
25
|
email: string;
|
|
26
|
-
companyName
|
|
27
|
-
domain
|
|
28
|
-
domainVerified
|
|
29
|
-
trustLevel
|
|
30
|
-
stripeConnected
|
|
31
|
-
createdAt
|
|
32
|
-
|
|
26
|
+
companyName: string | null;
|
|
27
|
+
domain: string | null;
|
|
28
|
+
domainVerified: boolean;
|
|
29
|
+
trustLevel: string;
|
|
30
|
+
stripeConnected: boolean;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
}
|
|
33
|
+
interface UpdateMerchantParams {
|
|
34
|
+
companyName?: string;
|
|
35
|
+
website?: string;
|
|
36
|
+
logoUrl?: string;
|
|
37
|
+
timezone?: string;
|
|
38
|
+
defaultCookieDuration?: number;
|
|
39
|
+
defaultPayoutThreshold?: number;
|
|
40
|
+
}
|
|
41
|
+
interface MerchantDomainStatus {
|
|
42
|
+
domain: string | null;
|
|
43
|
+
verified: boolean;
|
|
44
|
+
txtRecord: string | null;
|
|
45
|
+
}
|
|
46
|
+
interface StripeConnectSession {
|
|
47
|
+
url: string;
|
|
33
48
|
}
|
|
34
49
|
type CommissionType = 'one_time' | 'recurring' | 'recurring_limited';
|
|
35
50
|
type ProgramStatus = 'active' | 'paused' | 'archived';
|
|
51
|
+
type ProgramMarketplaceVisibility = 'private' | 'public';
|
|
36
52
|
interface Program {
|
|
37
53
|
id: string;
|
|
38
54
|
name: string;
|
|
39
|
-
description
|
|
40
|
-
landingPageUrl
|
|
55
|
+
description: string | null;
|
|
56
|
+
landingPageUrl: string | null;
|
|
41
57
|
commissionType: CommissionType;
|
|
42
58
|
commissionPercent: number;
|
|
43
|
-
commissionLimitMonths
|
|
59
|
+
commissionLimitMonths: number | null;
|
|
44
60
|
cookieDuration: number;
|
|
45
61
|
payoutThreshold: number;
|
|
46
62
|
autoApproveAffiliates: boolean;
|
|
47
63
|
status: ProgramStatus;
|
|
48
|
-
isPublic
|
|
49
|
-
merchantId
|
|
50
|
-
createdAt
|
|
51
|
-
updatedAt
|
|
52
|
-
|
|
64
|
+
isPublic: boolean;
|
|
65
|
+
merchantId: string;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
}
|
|
69
|
+
interface UpdateProgramMarketplaceParams {
|
|
70
|
+
status?: ProgramMarketplaceVisibility;
|
|
71
|
+
category?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
logoUrl?: string;
|
|
53
74
|
}
|
|
54
75
|
interface CreateProgramParams {
|
|
55
76
|
name: string;
|
|
@@ -72,6 +93,7 @@ interface UpdateProgramParams {
|
|
|
72
93
|
description?: string;
|
|
73
94
|
landingPageUrl?: string;
|
|
74
95
|
status?: ProgramStatus;
|
|
96
|
+
isPublic?: boolean;
|
|
75
97
|
}
|
|
76
98
|
interface CreateCouponParams {
|
|
77
99
|
affiliateId: string;
|
|
@@ -79,84 +101,99 @@ interface CreateCouponParams {
|
|
|
79
101
|
expiresAt?: string;
|
|
80
102
|
}
|
|
81
103
|
interface ProgramStats {
|
|
82
|
-
|
|
104
|
+
clicks: number;
|
|
105
|
+
conversions: number;
|
|
106
|
+
revenue: number;
|
|
107
|
+
commissions: number;
|
|
108
|
+
period: string;
|
|
83
109
|
}
|
|
84
110
|
type AffiliateStatus = 'pending' | 'approved' | 'blocked';
|
|
85
111
|
interface Affiliate {
|
|
86
112
|
id: string;
|
|
87
|
-
userId
|
|
88
|
-
programId
|
|
89
|
-
code
|
|
90
|
-
status
|
|
91
|
-
totalClicks
|
|
92
|
-
totalConversions
|
|
93
|
-
totalEarnings
|
|
94
|
-
createdAt
|
|
95
|
-
[key: string]: unknown;
|
|
113
|
+
userId: string;
|
|
114
|
+
programId: string;
|
|
115
|
+
code: string;
|
|
116
|
+
status: AffiliateStatus;
|
|
117
|
+
totalClicks: number;
|
|
118
|
+
totalConversions: number;
|
|
119
|
+
totalEarnings: number;
|
|
120
|
+
createdAt: string;
|
|
96
121
|
}
|
|
97
122
|
type ConversionStatus = 'pending' | 'approved' | 'rejected' | 'refunded';
|
|
98
123
|
interface Conversion {
|
|
99
124
|
id: string;
|
|
100
|
-
affiliateId
|
|
101
|
-
programId
|
|
102
|
-
amount
|
|
103
|
-
commission
|
|
104
|
-
status
|
|
105
|
-
method
|
|
106
|
-
stripeSessionId
|
|
107
|
-
createdAt
|
|
108
|
-
[key: string]: unknown;
|
|
125
|
+
affiliateId: string;
|
|
126
|
+
programId: string;
|
|
127
|
+
amount: number;
|
|
128
|
+
commission: number;
|
|
129
|
+
status: ConversionStatus;
|
|
130
|
+
method: 'cookie' | 'coupon' | 'metadata';
|
|
131
|
+
stripeSessionId: string | null;
|
|
132
|
+
createdAt: string;
|
|
109
133
|
}
|
|
110
134
|
interface ConversionStats {
|
|
111
|
-
|
|
135
|
+
total: number;
|
|
136
|
+
pending: number;
|
|
137
|
+
approved: number;
|
|
138
|
+
totalRevenue: number;
|
|
139
|
+
totalCommissions: number;
|
|
112
140
|
}
|
|
113
141
|
type PayoutStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
114
142
|
interface Payout {
|
|
115
143
|
id: string;
|
|
116
|
-
affiliateId
|
|
117
|
-
amount
|
|
118
|
-
status
|
|
119
|
-
method
|
|
120
|
-
createdAt
|
|
121
|
-
completedAt
|
|
122
|
-
|
|
144
|
+
affiliateId: string;
|
|
145
|
+
amount: number;
|
|
146
|
+
status: PayoutStatus;
|
|
147
|
+
method: string | null;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
completedAt: string | null;
|
|
150
|
+
}
|
|
151
|
+
interface CreatePayoutParams {
|
|
152
|
+
affiliateId: string;
|
|
153
|
+
programId: string;
|
|
154
|
+
method: 'paypal' | 'bank_transfer';
|
|
155
|
+
notes?: string;
|
|
123
156
|
}
|
|
124
157
|
interface PendingAffiliate {
|
|
125
|
-
affiliateId
|
|
126
|
-
email
|
|
127
|
-
name
|
|
128
|
-
code
|
|
129
|
-
programId
|
|
130
|
-
programName
|
|
131
|
-
payoutMethod
|
|
132
|
-
paypalEmail
|
|
133
|
-
bankIban
|
|
134
|
-
pendingAmount
|
|
135
|
-
currency
|
|
136
|
-
threshold
|
|
137
|
-
meetsThreshold
|
|
138
|
-
commissionCount
|
|
139
|
-
hasPayoutMethod
|
|
140
|
-
[key: string]: unknown;
|
|
158
|
+
affiliateId: string;
|
|
159
|
+
email: string;
|
|
160
|
+
name: string | null;
|
|
161
|
+
code: string;
|
|
162
|
+
programId: string;
|
|
163
|
+
programName: string;
|
|
164
|
+
payoutMethod: 'paypal' | 'bank_transfer' | null;
|
|
165
|
+
paypalEmail: string | null;
|
|
166
|
+
bankIban: string | null;
|
|
167
|
+
pendingAmount: number;
|
|
168
|
+
currency: string;
|
|
169
|
+
threshold: number;
|
|
170
|
+
meetsThreshold: boolean;
|
|
171
|
+
commissionCount: number;
|
|
172
|
+
hasPayoutMethod: boolean;
|
|
141
173
|
}
|
|
142
174
|
interface PayoutStats {
|
|
143
|
-
|
|
175
|
+
totalPaid: number;
|
|
176
|
+
totalPending: number;
|
|
177
|
+
count: number;
|
|
144
178
|
}
|
|
145
179
|
type FlagStatus = 'open' | 'reviewed' | 'dismissed' | 'confirmed';
|
|
146
180
|
type FlagType = 'suspicious_activity' | 'self_referral' | 'high_click_frequency' | 'conversion_anomaly' | 'manual_review';
|
|
147
181
|
interface Flag {
|
|
148
182
|
id: string;
|
|
149
|
-
affiliateId
|
|
150
|
-
type
|
|
151
|
-
status
|
|
152
|
-
details
|
|
153
|
-
note
|
|
154
|
-
createdAt
|
|
155
|
-
resolvedAt
|
|
156
|
-
[key: string]: unknown;
|
|
183
|
+
affiliateId: string;
|
|
184
|
+
type: FlagType;
|
|
185
|
+
status: FlagStatus;
|
|
186
|
+
details: Record<string, unknown> | null;
|
|
187
|
+
note: string | null;
|
|
188
|
+
createdAt: string;
|
|
189
|
+
resolvedAt: string | null;
|
|
157
190
|
}
|
|
158
191
|
interface FlagStats {
|
|
159
|
-
|
|
192
|
+
open: number;
|
|
193
|
+
reviewed: number;
|
|
194
|
+
dismissed: number;
|
|
195
|
+
confirmed: number;
|
|
196
|
+
total: number;
|
|
160
197
|
}
|
|
161
198
|
interface ResolveFlagParams {
|
|
162
199
|
status: 'reviewed' | 'dismissed' | 'confirmed';
|
|
@@ -168,33 +205,29 @@ interface BillingTier {
|
|
|
168
205
|
id: BillingTierId;
|
|
169
206
|
name: string;
|
|
170
207
|
price: number;
|
|
171
|
-
maxRevenue
|
|
172
|
-
features
|
|
173
|
-
bookable
|
|
174
|
-
[key: string]: unknown;
|
|
208
|
+
maxRevenue: number;
|
|
209
|
+
features: string[];
|
|
210
|
+
bookable: boolean;
|
|
175
211
|
}
|
|
176
212
|
interface BillingStatus {
|
|
177
|
-
tier
|
|
178
|
-
monthlyRevenue
|
|
179
|
-
nextTier
|
|
180
|
-
stripeSubscriptionId
|
|
181
|
-
[key: string]: unknown;
|
|
213
|
+
tier: BillingTierId;
|
|
214
|
+
monthlyRevenue: number;
|
|
215
|
+
nextTier: BillingTierId | null;
|
|
216
|
+
stripeSubscriptionId: string | null;
|
|
182
217
|
}
|
|
183
218
|
interface Coupon {
|
|
184
219
|
id: string;
|
|
185
220
|
code: string;
|
|
186
|
-
affiliateId
|
|
187
|
-
programId
|
|
188
|
-
createdAt
|
|
189
|
-
[key: string]: unknown;
|
|
221
|
+
affiliateId: string;
|
|
222
|
+
programId: string;
|
|
223
|
+
createdAt: string;
|
|
190
224
|
}
|
|
191
225
|
interface Invite {
|
|
192
|
-
token
|
|
193
|
-
email
|
|
194
|
-
programId
|
|
195
|
-
expiresAt
|
|
196
|
-
createdAt
|
|
197
|
-
[key: string]: unknown;
|
|
226
|
+
token: string;
|
|
227
|
+
email: string;
|
|
228
|
+
programId: string;
|
|
229
|
+
expiresAt: string;
|
|
230
|
+
createdAt: string;
|
|
198
231
|
}
|
|
199
232
|
|
|
200
233
|
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
|
|
@@ -294,17 +327,13 @@ declare class FlagsResource {
|
|
|
294
327
|
resolve(id: string, data: ResolveFlagParams, options?: MutationOptions): Promise<Flag>;
|
|
295
328
|
}
|
|
296
329
|
|
|
297
|
-
interface DomainStatus {
|
|
298
|
-
domain: string | null;
|
|
299
|
-
verified: boolean;
|
|
300
|
-
txtRecord?: string | null;
|
|
301
|
-
[key: string]: unknown;
|
|
302
|
-
}
|
|
303
330
|
declare class MerchantResource {
|
|
304
331
|
private readonly http;
|
|
305
332
|
constructor(http: HttpClient);
|
|
306
333
|
get(): Promise<Merchant>;
|
|
307
|
-
|
|
334
|
+
update(data: UpdateMerchantParams): Promise<Merchant>;
|
|
335
|
+
connectStripe(): Promise<StripeConnectSession>;
|
|
336
|
+
domainStatus(): Promise<MerchantDomainStatus>;
|
|
308
337
|
}
|
|
309
338
|
|
|
310
339
|
declare class PayoutsResource {
|
|
@@ -336,6 +365,7 @@ declare class PayoutsResource {
|
|
|
336
365
|
programId?: string;
|
|
337
366
|
period?: '7d' | '30d' | '90d' | 'all';
|
|
338
367
|
}): Promise<PayoutStats>;
|
|
368
|
+
create(data: CreatePayoutParams, options?: MutationOptions): Promise<Record<string, unknown>>;
|
|
339
369
|
}
|
|
340
370
|
|
|
341
371
|
declare class ProgramsResource {
|
|
@@ -347,6 +377,7 @@ declare class ProgramsResource {
|
|
|
347
377
|
page?: number;
|
|
348
378
|
pageSize?: number;
|
|
349
379
|
offset?: number;
|
|
380
|
+
status?: string;
|
|
350
381
|
}): Promise<PaginatedResponse<Program>>;
|
|
351
382
|
listAll(params?: {
|
|
352
383
|
pageSize?: number;
|
|
@@ -375,6 +406,9 @@ declare class ProgramsResource {
|
|
|
375
406
|
usageLimit?: number;
|
|
376
407
|
expiresInDays?: number;
|
|
377
408
|
}, options?: MutationOptions): Promise<Invite>;
|
|
409
|
+
listInvites(id: string): Promise<Invite[]>;
|
|
410
|
+
deleteCoupon(couponId: string): Promise<Coupon>;
|
|
411
|
+
updateMarketplace(id: string, data: UpdateProgramMarketplaceParams): Promise<Record<string, unknown>>;
|
|
378
412
|
}
|
|
379
413
|
|
|
380
414
|
declare class AgentRef {
|
|
@@ -418,4 +452,4 @@ declare class ServerError extends AgentRefError {
|
|
|
418
452
|
constructor(message: string, code: string, status: number, requestId: string);
|
|
419
453
|
}
|
|
420
454
|
|
|
421
|
-
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 CreateProgramParams, type Flag, type FlagStats, type FlagStatus, type FlagType, ForbiddenError, type Invite, type Merchant, type MutationOptions, NotFoundError, type PaginatedResponse, type PaginationMeta, type Payout, type PayoutStats, type PayoutStatus, type PendingAffiliate, type Program, type ProgramStats, type ProgramStatus, RateLimitError, type ResolveFlagParams, ServerError, type UpdateProgramParams, ValidationError };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -59,7 +59,10 @@ 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.
|
|
62
|
+
var VERSION = true ? "1.0.4" : "0.0.0";
|
|
63
|
+
function hasUsableIdempotencyKey(idempotencyKey) {
|
|
64
|
+
return typeof idempotencyKey === "string" && idempotencyKey.trim().length > 0;
|
|
65
|
+
}
|
|
63
66
|
var HttpClient = class {
|
|
64
67
|
constructor(config = {}) {
|
|
65
68
|
if (typeof window !== "undefined" && !config.dangerouslyAllowBrowser) {
|
|
@@ -81,7 +84,8 @@ var HttpClient = class {
|
|
|
81
84
|
async request(options) {
|
|
82
85
|
const url = this.buildUrl(options.path, options.query);
|
|
83
86
|
const isSafe = SAFE_METHODS.has(options.method);
|
|
84
|
-
const
|
|
87
|
+
const hasIdempotency = options.method === "POST" && hasUsableIdempotencyKey(options.idempotencyKey);
|
|
88
|
+
const canRetry = isSafe || hasIdempotency;
|
|
85
89
|
const maxAttempts = canRetry ? this.maxRetries + 1 : 1;
|
|
86
90
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
87
91
|
let response;
|
|
@@ -91,8 +95,8 @@ var HttpClient = class {
|
|
|
91
95
|
"Content-Type": "application/json",
|
|
92
96
|
"User-Agent": `agentref-node/${VERSION}`
|
|
93
97
|
};
|
|
94
|
-
if (
|
|
95
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
98
|
+
if (hasIdempotency) {
|
|
99
|
+
headers["Idempotency-Key"] = options.idempotencyKey.trim();
|
|
96
100
|
}
|
|
97
101
|
response = await fetch(url, {
|
|
98
102
|
method: options.method,
|
|
@@ -313,6 +317,21 @@ var MerchantResource = class {
|
|
|
313
317
|
});
|
|
314
318
|
return envelope.data;
|
|
315
319
|
}
|
|
320
|
+
async update(data) {
|
|
321
|
+
const envelope = await this.http.request({
|
|
322
|
+
method: "PATCH",
|
|
323
|
+
path: "/merchant",
|
|
324
|
+
body: data
|
|
325
|
+
});
|
|
326
|
+
return envelope.data;
|
|
327
|
+
}
|
|
328
|
+
async connectStripe() {
|
|
329
|
+
const envelope = await this.http.request({
|
|
330
|
+
method: "POST",
|
|
331
|
+
path: "/merchant/connect-stripe"
|
|
332
|
+
});
|
|
333
|
+
return envelope.data;
|
|
334
|
+
}
|
|
316
335
|
async domainStatus() {
|
|
317
336
|
const envelope = await this.http.request({
|
|
318
337
|
method: "GET",
|
|
@@ -341,6 +360,15 @@ var PayoutsResource = class {
|
|
|
341
360
|
});
|
|
342
361
|
return envelope.data;
|
|
343
362
|
}
|
|
363
|
+
async create(data, options) {
|
|
364
|
+
const envelope = await this.http.request({
|
|
365
|
+
method: "POST",
|
|
366
|
+
path: "/payouts",
|
|
367
|
+
body: data,
|
|
368
|
+
idempotencyKey: options?.idempotencyKey
|
|
369
|
+
});
|
|
370
|
+
return envelope.data;
|
|
371
|
+
}
|
|
344
372
|
};
|
|
345
373
|
|
|
346
374
|
// src/resources/programs.ts
|
|
@@ -434,6 +462,28 @@ var ProgramsResource = class {
|
|
|
434
462
|
});
|
|
435
463
|
return envelope.data;
|
|
436
464
|
}
|
|
465
|
+
async listInvites(id) {
|
|
466
|
+
const envelope = await this.http.request({
|
|
467
|
+
method: "GET",
|
|
468
|
+
path: `/programs/${id}/invites`
|
|
469
|
+
});
|
|
470
|
+
return envelope.data;
|
|
471
|
+
}
|
|
472
|
+
async deleteCoupon(couponId) {
|
|
473
|
+
const envelope = await this.http.request({
|
|
474
|
+
method: "DELETE",
|
|
475
|
+
path: `/coupons/${couponId}`
|
|
476
|
+
});
|
|
477
|
+
return envelope.data;
|
|
478
|
+
}
|
|
479
|
+
async updateMarketplace(id, data) {
|
|
480
|
+
const envelope = await this.http.request({
|
|
481
|
+
method: "PATCH",
|
|
482
|
+
path: `/programs/${id}/marketplace`,
|
|
483
|
+
body: data
|
|
484
|
+
});
|
|
485
|
+
return envelope.data;
|
|
486
|
+
}
|
|
437
487
|
};
|
|
438
488
|
|
|
439
489
|
// src/client.ts
|
package/dist/index.mjs.map
CHANGED
|
@@ -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\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 canRetry = isSafe || (options.method === 'POST' && options.idempotencyKey !== undefined)\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 (options.method === 'POST' && options.idempotencyKey) {\n headers['Idempotency-Key'] = options.idempotencyKey\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 } from '../types/index.js'\n\nexport interface DomainStatus {\n domain: string | null\n verified: boolean\n txtRecord?: string | null\n [key: string]: unknown\n}\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 domainStatus(): Promise<DomainStatus> {\n const envelope = await this.http.request<{ data: DomainStatus; 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 { 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","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 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 }): 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","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,UAA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,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,aACJ,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;AACF;;;AC/HO,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' | '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;AAC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