@btst/plugin-affiliate 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -0
- package/dist/api/getters.cjs +182 -0
- package/dist/api/getters.mjs +166 -0
- package/dist/api/index.cjs +49 -0
- package/dist/api/index.d.cts +975 -0
- package/dist/api/index.d.mts +975 -0
- package/dist/api/index.d.ts +975 -0
- package/dist/api/index.mjs +7 -0
- package/dist/api/mutations.cjs +362 -0
- package/dist/api/mutations.mjs +352 -0
- package/dist/api/operations.cjs +328 -0
- package/dist/api/operations.mjs +326 -0
- package/dist/api/plugin.cjs +146 -0
- package/dist/api/plugin.mjs +144 -0
- package/dist/attribution.cjs +92 -0
- package/dist/attribution.d.cts +20 -0
- package/dist/attribution.d.mts +20 -0
- package/dist/attribution.d.ts +20 -0
- package/dist/attribution.mjs +82 -0
- package/dist/client/components/index.cjs +12 -0
- package/dist/client/components/index.d.cts +13 -0
- package/dist/client/components/index.d.mts +13 -0
- package/dist/client/components/index.d.ts +13 -0
- package/dist/client/components/index.mjs +1 -0
- package/dist/client/components/pages/affiliate-apply-page.internal.cjs +59 -0
- package/dist/client/components/pages/affiliate-apply-page.internal.mjs +57 -0
- package/dist/client/components/pages/affiliate-detail-page.internal.cjs +112 -0
- package/dist/client/components/pages/affiliate-detail-page.internal.mjs +110 -0
- package/dist/client/components/pages/affiliate-portal-page.internal.cjs +252 -0
- package/dist/client/components/pages/affiliate-portal-page.internal.mjs +250 -0
- package/dist/client/components/pages/affiliates-page.internal.cjs +160 -0
- package/dist/client/components/pages/affiliates-page.internal.mjs +158 -0
- package/dist/client/components/pages/commissions-page.internal.cjs +151 -0
- package/dist/client/components/pages/commissions-page.internal.mjs +149 -0
- package/dist/client/components/pages/payouts-page.internal.cjs +230 -0
- package/dist/client/components/pages/payouts-page.internal.mjs +228 -0
- package/dist/client/components/pages.cjs +145 -0
- package/dist/client/components/pages.mjs +138 -0
- package/dist/client/components/shared.cjs +331 -0
- package/dist/client/components/shared.mjs +316 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/index.cjs +77 -0
- package/dist/client/hooks/index.d.cts +39 -0
- package/dist/client/hooks/index.d.mts +39 -0
- package/dist/client/hooks/index.d.ts +39 -0
- package/dist/client/hooks/index.mjs +61 -0
- package/dist/client/index.cjs +7 -0
- package/dist/client/index.d.cts +110 -0
- package/dist/client/index.d.mts +110 -0
- package/dist/client/index.d.ts +110 -0
- package/dist/client/index.mjs +1 -0
- package/dist/client/plugin.cjs +77 -0
- package/dist/client/plugin.mjs +75 -0
- package/dist/client.css +311 -0
- package/dist/commission.cjs +24 -0
- package/dist/commission.mjs +22 -0
- package/dist/db.cjs +74 -0
- package/dist/db.mjs +72 -0
- package/dist/permissions.cjs +53 -0
- package/dist/permissions.d.cts +78 -0
- package/dist/permissions.d.mts +78 -0
- package/dist/permissions.d.ts +78 -0
- package/dist/permissions.mjs +51 -0
- package/dist/query-keys.cjs +152 -0
- package/dist/query-keys.d.cts +394 -0
- package/dist/query-keys.d.mts +394 -0
- package/dist/query-keys.d.ts +394 -0
- package/dist/query-keys.mjs +149 -0
- package/dist/schemas.cjs +95 -0
- package/dist/schemas.mjs +77 -0
- package/dist/style.css +313 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +176 -0
- package/dist/types.d.mts +176 -0
- package/dist/types.d.ts +176 -0
- package/dist/types.mjs +1 -0
- package/package.json +159 -3
- package/README.md +0 -3
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
+
import { DeepReadonly } from '@btst/stack/plugins/api';
|
|
3
|
+
import * as _btst_stack_authorization from '@btst/stack/authorization';
|
|
4
|
+
import * as better_call from 'better-call';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { AffiliateOptions, Affiliate, Conversion, Commission, CreatePayoutInput, Payout, AffiliateStatus, CommissionType, CommissionStatus, PayoutStatus, ListParams, AffiliateStats, MarketingAsset, AffiliatePortal, ReferralClick, ListResult, CreateAffiliateInput, CreateConversionInput, TrackClickInput, UpdateAffiliateInput } from '../types.js';
|
|
7
|
+
import * as _btst_db from '@btst/db';
|
|
8
|
+
import { DBAdapter } from '@btst/db';
|
|
9
|
+
export { affiliatePermissions } from '../permissions.js';
|
|
10
|
+
export { AFFILIATE_COOKIE_NAME, attributionFromRequest, createReferralLink, createTrackingLink, getReferralRedirect, isClickWithinWindow, referralCodeFromURL, safeLandingPath, selectAttributionClick } from '../attribution.js';
|
|
11
|
+
|
|
12
|
+
/** Authorized request context shared by affiliate lifecycle callbacks. */
|
|
13
|
+
interface AffiliateHookContext {
|
|
14
|
+
readonly request?: Request;
|
|
15
|
+
readonly identity: {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
/** Lifecycle callbacks run after the operation permission is authorized. */
|
|
20
|
+
interface AffiliatePluginHooks {
|
|
21
|
+
onBeforeApproveAffiliate?: (affiliate: DeepReadonly<Affiliate>, context: AffiliateHookContext) => Promise<void> | void;
|
|
22
|
+
onAfterConversion?: (conversion: DeepReadonly<Conversion>, commission: DeepReadonly<Commission>, context: AffiliateHookContext) => Promise<void> | void;
|
|
23
|
+
onBeforePayout?: (batch: DeepReadonly<CreatePayoutInput>, context: AffiliateHookContext) => Promise<void> | void;
|
|
24
|
+
onAfterPayout?: (payout: DeepReadonly<Payout>, context: AffiliateHookContext) => Promise<void> | void;
|
|
25
|
+
}
|
|
26
|
+
/** Affiliate attribution, commission rules, marketing assets, and lifecycle callbacks. */
|
|
27
|
+
interface AffiliateBackendOptions extends AffiliateOptions {
|
|
28
|
+
hooks?: AffiliatePluginHooks;
|
|
29
|
+
}
|
|
30
|
+
/** Processor-independent affiliate operations and identity-scoped portal API. */
|
|
31
|
+
declare const affiliateBackendPlugin: (options?: AffiliateBackendOptions) => _btst_stack_plugins_api.BackendPlugin<{
|
|
32
|
+
listAffiliates: better_call.StrictEndpoint<"/affiliate/affiliates", {
|
|
33
|
+
requireRequest: true;
|
|
34
|
+
} & {
|
|
35
|
+
method: "GET";
|
|
36
|
+
} & {
|
|
37
|
+
query: better_call.StandardSchemaV1<{
|
|
38
|
+
limit?: unknown;
|
|
39
|
+
offset?: unknown;
|
|
40
|
+
status?: "pending" | "approved" | "suspended" | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
limit?: unknown;
|
|
43
|
+
offset?: unknown;
|
|
44
|
+
status?: "pending" | "approved" | "suspended" | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
}, {
|
|
47
|
+
readonly items: readonly {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly userId: string;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly email: string;
|
|
52
|
+
readonly code: string;
|
|
53
|
+
readonly status: AffiliateStatus;
|
|
54
|
+
readonly payoutDetails?: string | null | undefined;
|
|
55
|
+
readonly notes?: string | null | undefined;
|
|
56
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
57
|
+
readonly commissionValue?: number | null | undefined;
|
|
58
|
+
readonly createdAt: string;
|
|
59
|
+
readonly updatedAt: string;
|
|
60
|
+
}[];
|
|
61
|
+
readonly total: number;
|
|
62
|
+
readonly limit: number;
|
|
63
|
+
readonly offset: number;
|
|
64
|
+
}>;
|
|
65
|
+
getAffiliate: better_call.StrictEndpoint<"/affiliate/affiliates/:id", {
|
|
66
|
+
requireRequest: true;
|
|
67
|
+
} & {
|
|
68
|
+
method: "GET";
|
|
69
|
+
}, {
|
|
70
|
+
readonly affiliate: {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly userId: string;
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly email: string;
|
|
75
|
+
readonly code: string;
|
|
76
|
+
readonly status: AffiliateStatus;
|
|
77
|
+
readonly payoutDetails?: string | null | undefined;
|
|
78
|
+
readonly notes?: string | null | undefined;
|
|
79
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
80
|
+
readonly commissionValue?: number | null | undefined;
|
|
81
|
+
readonly createdAt: string;
|
|
82
|
+
readonly updatedAt: string;
|
|
83
|
+
};
|
|
84
|
+
readonly stats: {
|
|
85
|
+
readonly clicks: number;
|
|
86
|
+
readonly conversions: number;
|
|
87
|
+
readonly totals: readonly {
|
|
88
|
+
readonly currency: string;
|
|
89
|
+
readonly pending: number;
|
|
90
|
+
readonly approved: number;
|
|
91
|
+
readonly paid: number;
|
|
92
|
+
readonly voided: number;
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
}>;
|
|
96
|
+
createAffiliate: better_call.StrictEndpoint<"/affiliate/affiliates", {
|
|
97
|
+
requireRequest: true;
|
|
98
|
+
} & {
|
|
99
|
+
method: "POST";
|
|
100
|
+
body: better_call.StandardSchemaV1<{
|
|
101
|
+
name: string;
|
|
102
|
+
email: string;
|
|
103
|
+
userId: string;
|
|
104
|
+
code?: string | undefined;
|
|
105
|
+
payoutDetails?: string | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
name: string;
|
|
108
|
+
email: string;
|
|
109
|
+
userId: string;
|
|
110
|
+
code?: string | undefined;
|
|
111
|
+
payoutDetails?: string | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
}, {
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly userId: string;
|
|
116
|
+
readonly name: string;
|
|
117
|
+
readonly email: string;
|
|
118
|
+
readonly code: string;
|
|
119
|
+
readonly status: AffiliateStatus;
|
|
120
|
+
readonly payoutDetails?: string | null | undefined;
|
|
121
|
+
readonly notes?: string | null | undefined;
|
|
122
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
123
|
+
readonly commissionValue?: number | null | undefined;
|
|
124
|
+
readonly createdAt: string;
|
|
125
|
+
readonly updatedAt: string;
|
|
126
|
+
}>;
|
|
127
|
+
updateAffiliate: better_call.StrictEndpoint<"/affiliate/affiliates/:id", {
|
|
128
|
+
requireRequest: true;
|
|
129
|
+
} & {
|
|
130
|
+
method: "PUT";
|
|
131
|
+
body: better_call.StandardSchemaV1<{
|
|
132
|
+
name?: string | undefined;
|
|
133
|
+
email?: string | undefined;
|
|
134
|
+
code?: string | undefined;
|
|
135
|
+
payoutDetails?: string | null | undefined;
|
|
136
|
+
status?: "pending" | "approved" | "suspended" | undefined;
|
|
137
|
+
notes?: string | null | undefined;
|
|
138
|
+
commissionType?: "flat" | "percent" | null | undefined;
|
|
139
|
+
commissionValue?: number | null | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
name?: string | undefined;
|
|
142
|
+
email?: string | undefined;
|
|
143
|
+
code?: string | undefined;
|
|
144
|
+
payoutDetails?: string | null | undefined;
|
|
145
|
+
status?: "pending" | "approved" | "suspended" | undefined;
|
|
146
|
+
notes?: string | null | undefined;
|
|
147
|
+
commissionType?: "flat" | "percent" | null | undefined;
|
|
148
|
+
commissionValue?: number | null | undefined;
|
|
149
|
+
}>;
|
|
150
|
+
}, {
|
|
151
|
+
readonly id: string;
|
|
152
|
+
readonly userId: string;
|
|
153
|
+
readonly name: string;
|
|
154
|
+
readonly email: string;
|
|
155
|
+
readonly code: string;
|
|
156
|
+
readonly status: AffiliateStatus;
|
|
157
|
+
readonly payoutDetails?: string | null | undefined;
|
|
158
|
+
readonly notes?: string | null | undefined;
|
|
159
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
160
|
+
readonly commissionValue?: number | null | undefined;
|
|
161
|
+
readonly createdAt: string;
|
|
162
|
+
readonly updatedAt: string;
|
|
163
|
+
}>;
|
|
164
|
+
deleteAffiliate: better_call.StrictEndpoint<"/affiliate/affiliates/:id", {
|
|
165
|
+
requireRequest: true;
|
|
166
|
+
} & {
|
|
167
|
+
method: "DELETE";
|
|
168
|
+
body: better_call.StandardSchemaV1<unknown, unknown>;
|
|
169
|
+
}, {
|
|
170
|
+
readonly success: true;
|
|
171
|
+
}>;
|
|
172
|
+
apply: better_call.StrictEndpoint<"/affiliate/apply", {
|
|
173
|
+
requireRequest: true;
|
|
174
|
+
} & {
|
|
175
|
+
method: "POST";
|
|
176
|
+
body: better_call.StandardSchemaV1<{
|
|
177
|
+
name: string;
|
|
178
|
+
email: string;
|
|
179
|
+
code?: string | undefined;
|
|
180
|
+
payoutDetails?: string | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
name: string;
|
|
183
|
+
email: string;
|
|
184
|
+
code?: string | undefined;
|
|
185
|
+
payoutDetails?: string | undefined;
|
|
186
|
+
}>;
|
|
187
|
+
}, {
|
|
188
|
+
readonly id: string;
|
|
189
|
+
readonly userId: string;
|
|
190
|
+
readonly name: string;
|
|
191
|
+
readonly email: string;
|
|
192
|
+
readonly code: string;
|
|
193
|
+
readonly status: AffiliateStatus;
|
|
194
|
+
readonly payoutDetails?: string | null | undefined;
|
|
195
|
+
readonly notes?: string | null | undefined;
|
|
196
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
197
|
+
readonly commissionValue?: number | null | undefined;
|
|
198
|
+
readonly createdAt: string;
|
|
199
|
+
readonly updatedAt: string;
|
|
200
|
+
}>;
|
|
201
|
+
getPortal: better_call.StrictEndpoint<"/affiliate/portal", {
|
|
202
|
+
requireRequest: true;
|
|
203
|
+
} & {
|
|
204
|
+
method: "GET";
|
|
205
|
+
}, {
|
|
206
|
+
readonly affiliate: {
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly userId: string;
|
|
209
|
+
readonly name: string;
|
|
210
|
+
readonly email: string;
|
|
211
|
+
readonly code: string;
|
|
212
|
+
readonly status: AffiliateStatus;
|
|
213
|
+
readonly payoutDetails?: string | null | undefined;
|
|
214
|
+
readonly notes?: string | null | undefined;
|
|
215
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
216
|
+
readonly commissionValue?: number | null | undefined;
|
|
217
|
+
readonly createdAt: string;
|
|
218
|
+
readonly updatedAt: string;
|
|
219
|
+
} | null;
|
|
220
|
+
readonly stats: {
|
|
221
|
+
readonly clicks: number;
|
|
222
|
+
readonly conversions: number;
|
|
223
|
+
readonly totals: readonly {
|
|
224
|
+
readonly currency: string;
|
|
225
|
+
readonly pending: number;
|
|
226
|
+
readonly approved: number;
|
|
227
|
+
readonly paid: number;
|
|
228
|
+
readonly voided: number;
|
|
229
|
+
}[];
|
|
230
|
+
};
|
|
231
|
+
readonly commissions: readonly {
|
|
232
|
+
readonly id: string;
|
|
233
|
+
readonly affiliateId: string;
|
|
234
|
+
readonly conversionId: string;
|
|
235
|
+
readonly payoutId?: string | null | undefined;
|
|
236
|
+
readonly amount: number;
|
|
237
|
+
readonly currency: string;
|
|
238
|
+
readonly status: CommissionStatus;
|
|
239
|
+
readonly createdAt: string;
|
|
240
|
+
readonly updatedAt: string;
|
|
241
|
+
}[];
|
|
242
|
+
readonly payouts: readonly {
|
|
243
|
+
readonly id: string;
|
|
244
|
+
readonly affiliateId: string;
|
|
245
|
+
readonly amount: number;
|
|
246
|
+
readonly currency: string;
|
|
247
|
+
readonly status: PayoutStatus;
|
|
248
|
+
readonly reference?: string | null | undefined;
|
|
249
|
+
readonly paidAt?: string | null | undefined;
|
|
250
|
+
readonly createdAt: string;
|
|
251
|
+
}[];
|
|
252
|
+
readonly assets: readonly {
|
|
253
|
+
readonly name: string;
|
|
254
|
+
readonly url: string;
|
|
255
|
+
readonly description?: string | undefined;
|
|
256
|
+
readonly bannerUrl?: string | undefined;
|
|
257
|
+
}[];
|
|
258
|
+
}>;
|
|
259
|
+
updatePortal: better_call.StrictEndpoint<"/affiliate/portal", {
|
|
260
|
+
requireRequest: true;
|
|
261
|
+
} & {
|
|
262
|
+
method: "PUT";
|
|
263
|
+
body: better_call.StandardSchemaV1<{
|
|
264
|
+
name?: string | undefined;
|
|
265
|
+
email?: string | undefined;
|
|
266
|
+
code?: string | undefined;
|
|
267
|
+
payoutDetails?: string | null | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
name?: string | undefined;
|
|
270
|
+
email?: string | undefined;
|
|
271
|
+
code?: string | undefined;
|
|
272
|
+
payoutDetails?: string | null | undefined;
|
|
273
|
+
}>;
|
|
274
|
+
}, {
|
|
275
|
+
readonly id: string;
|
|
276
|
+
readonly userId: string;
|
|
277
|
+
readonly name: string;
|
|
278
|
+
readonly email: string;
|
|
279
|
+
readonly code: string;
|
|
280
|
+
readonly status: AffiliateStatus;
|
|
281
|
+
readonly payoutDetails?: string | null | undefined;
|
|
282
|
+
readonly commissionType?: (CommissionType | null) | undefined;
|
|
283
|
+
readonly commissionValue?: number | null | undefined;
|
|
284
|
+
readonly createdAt: string;
|
|
285
|
+
readonly updatedAt: string;
|
|
286
|
+
}>;
|
|
287
|
+
trackClick: better_call.StrictEndpoint<"/affiliate/track/:code", {
|
|
288
|
+
requireRequest: true;
|
|
289
|
+
} & {
|
|
290
|
+
method: "GET";
|
|
291
|
+
} & {
|
|
292
|
+
query: better_call.StandardSchemaV1<{
|
|
293
|
+
to?: string | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
to?: string | undefined;
|
|
296
|
+
}>;
|
|
297
|
+
}, Response>;
|
|
298
|
+
createConversion: better_call.StrictEndpoint<"/affiliate/conversions", {
|
|
299
|
+
requireRequest: true;
|
|
300
|
+
} & {
|
|
301
|
+
method: "POST";
|
|
302
|
+
body: better_call.StandardSchemaV1<{
|
|
303
|
+
amount: number;
|
|
304
|
+
externalRef?: string | undefined;
|
|
305
|
+
currency?: string | undefined;
|
|
306
|
+
attribution?: {
|
|
307
|
+
code?: string | undefined;
|
|
308
|
+
clickId?: string | undefined;
|
|
309
|
+
} | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
amount: number;
|
|
312
|
+
externalRef?: string | undefined;
|
|
313
|
+
currency?: string | undefined;
|
|
314
|
+
attribution?: {
|
|
315
|
+
code?: string | undefined;
|
|
316
|
+
clickId?: string | undefined;
|
|
317
|
+
} | undefined;
|
|
318
|
+
}>;
|
|
319
|
+
}, {
|
|
320
|
+
readonly conversion: {
|
|
321
|
+
readonly id: string;
|
|
322
|
+
readonly affiliateId: string;
|
|
323
|
+
readonly clickId?: string | null | undefined;
|
|
324
|
+
readonly externalRef?: string | null | undefined;
|
|
325
|
+
readonly amount: number;
|
|
326
|
+
readonly currency: string;
|
|
327
|
+
readonly status: "pending" | "approved" | "rejected";
|
|
328
|
+
readonly createdAt: string;
|
|
329
|
+
};
|
|
330
|
+
readonly commission: {
|
|
331
|
+
readonly id: string;
|
|
332
|
+
readonly affiliateId: string;
|
|
333
|
+
readonly conversionId: string;
|
|
334
|
+
readonly payoutId?: string | null | undefined;
|
|
335
|
+
readonly amount: number;
|
|
336
|
+
readonly currency: string;
|
|
337
|
+
readonly status: CommissionStatus;
|
|
338
|
+
readonly createdAt: string;
|
|
339
|
+
readonly updatedAt: string;
|
|
340
|
+
};
|
|
341
|
+
} | null>;
|
|
342
|
+
listCommissions: better_call.StrictEndpoint<"/affiliate/commissions", {
|
|
343
|
+
requireRequest: true;
|
|
344
|
+
} & {
|
|
345
|
+
method: "GET";
|
|
346
|
+
} & {
|
|
347
|
+
query: better_call.StandardSchemaV1<{
|
|
348
|
+
limit?: unknown;
|
|
349
|
+
offset?: unknown;
|
|
350
|
+
affiliateId?: string | undefined;
|
|
351
|
+
status?: string | undefined;
|
|
352
|
+
currency?: string | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
limit?: unknown;
|
|
355
|
+
offset?: unknown;
|
|
356
|
+
affiliateId?: string | undefined;
|
|
357
|
+
status?: string | undefined;
|
|
358
|
+
currency?: string | undefined;
|
|
359
|
+
}>;
|
|
360
|
+
}, {
|
|
361
|
+
readonly items: readonly {
|
|
362
|
+
readonly id: string;
|
|
363
|
+
readonly affiliateId: string;
|
|
364
|
+
readonly conversionId: string;
|
|
365
|
+
readonly payoutId?: string | null | undefined;
|
|
366
|
+
readonly amount: number;
|
|
367
|
+
readonly currency: string;
|
|
368
|
+
readonly status: CommissionStatus;
|
|
369
|
+
readonly createdAt: string;
|
|
370
|
+
readonly updatedAt: string;
|
|
371
|
+
}[];
|
|
372
|
+
readonly total: number;
|
|
373
|
+
readonly limit: number;
|
|
374
|
+
readonly offset: number;
|
|
375
|
+
}>;
|
|
376
|
+
updateCommission: better_call.StrictEndpoint<"/affiliate/commissions/:id", {
|
|
377
|
+
requireRequest: true;
|
|
378
|
+
} & {
|
|
379
|
+
method: "PUT";
|
|
380
|
+
body: better_call.StandardSchemaV1<{
|
|
381
|
+
status: "approved" | "voided";
|
|
382
|
+
}, {
|
|
383
|
+
status: "approved" | "voided";
|
|
384
|
+
}>;
|
|
385
|
+
}, {
|
|
386
|
+
readonly id: string;
|
|
387
|
+
readonly affiliateId: string;
|
|
388
|
+
readonly conversionId: string;
|
|
389
|
+
readonly payoutId?: string | null | undefined;
|
|
390
|
+
readonly amount: number;
|
|
391
|
+
readonly currency: string;
|
|
392
|
+
readonly status: CommissionStatus;
|
|
393
|
+
readonly createdAt: string;
|
|
394
|
+
readonly updatedAt: string;
|
|
395
|
+
}>;
|
|
396
|
+
listPayouts: better_call.StrictEndpoint<"/affiliate/payouts", {
|
|
397
|
+
requireRequest: true;
|
|
398
|
+
} & {
|
|
399
|
+
method: "GET";
|
|
400
|
+
} & {
|
|
401
|
+
query: better_call.StandardSchemaV1<{
|
|
402
|
+
limit?: unknown;
|
|
403
|
+
offset?: unknown;
|
|
404
|
+
affiliateId?: string | undefined;
|
|
405
|
+
status?: string | undefined;
|
|
406
|
+
currency?: string | undefined;
|
|
407
|
+
}, {
|
|
408
|
+
limit?: unknown;
|
|
409
|
+
offset?: unknown;
|
|
410
|
+
affiliateId?: string | undefined;
|
|
411
|
+
status?: string | undefined;
|
|
412
|
+
currency?: string | undefined;
|
|
413
|
+
}>;
|
|
414
|
+
}, {
|
|
415
|
+
readonly items: readonly {
|
|
416
|
+
readonly id: string;
|
|
417
|
+
readonly affiliateId: string;
|
|
418
|
+
readonly amount: number;
|
|
419
|
+
readonly currency: string;
|
|
420
|
+
readonly status: PayoutStatus;
|
|
421
|
+
readonly reference?: string | null | undefined;
|
|
422
|
+
readonly paidAt?: string | null | undefined;
|
|
423
|
+
readonly createdAt: string;
|
|
424
|
+
}[];
|
|
425
|
+
readonly total: number;
|
|
426
|
+
readonly limit: number;
|
|
427
|
+
readonly offset: number;
|
|
428
|
+
}>;
|
|
429
|
+
createPayout: better_call.StrictEndpoint<"/affiliate/payouts", {
|
|
430
|
+
requireRequest: true;
|
|
431
|
+
} & {
|
|
432
|
+
method: "POST";
|
|
433
|
+
body: better_call.StandardSchemaV1<{
|
|
434
|
+
affiliateId: string;
|
|
435
|
+
currency: string;
|
|
436
|
+
commissionIds?: string[] | undefined;
|
|
437
|
+
}, {
|
|
438
|
+
affiliateId: string;
|
|
439
|
+
currency: string;
|
|
440
|
+
commissionIds?: string[] | undefined;
|
|
441
|
+
}>;
|
|
442
|
+
}, {
|
|
443
|
+
readonly id: string;
|
|
444
|
+
readonly affiliateId: string;
|
|
445
|
+
readonly amount: number;
|
|
446
|
+
readonly currency: string;
|
|
447
|
+
readonly status: PayoutStatus;
|
|
448
|
+
readonly reference?: string | null | undefined;
|
|
449
|
+
readonly paidAt?: string | null | undefined;
|
|
450
|
+
readonly createdAt: string;
|
|
451
|
+
}>;
|
|
452
|
+
updatePayout: better_call.StrictEndpoint<"/affiliate/payouts/:id", {
|
|
453
|
+
requireRequest: true;
|
|
454
|
+
} & {
|
|
455
|
+
method: "PUT";
|
|
456
|
+
body: better_call.StandardSchemaV1<{
|
|
457
|
+
status: "sent" | "failed";
|
|
458
|
+
reference?: string | undefined;
|
|
459
|
+
}, {
|
|
460
|
+
status: "sent" | "failed";
|
|
461
|
+
reference?: string | undefined;
|
|
462
|
+
}>;
|
|
463
|
+
}, {
|
|
464
|
+
readonly id: string;
|
|
465
|
+
readonly affiliateId: string;
|
|
466
|
+
readonly amount: number;
|
|
467
|
+
readonly currency: string;
|
|
468
|
+
readonly status: PayoutStatus;
|
|
469
|
+
readonly reference?: string | null | undefined;
|
|
470
|
+
readonly paidAt?: string | null | undefined;
|
|
471
|
+
readonly createdAt: string;
|
|
472
|
+
}>;
|
|
473
|
+
exportPayouts: better_call.StrictEndpoint<"/affiliate/payouts/export", {
|
|
474
|
+
requireRequest: true;
|
|
475
|
+
} & {
|
|
476
|
+
method: "GET";
|
|
477
|
+
} & {
|
|
478
|
+
query: better_call.StandardSchemaV1<{
|
|
479
|
+
limit?: unknown;
|
|
480
|
+
offset?: unknown;
|
|
481
|
+
affiliateId?: string | undefined;
|
|
482
|
+
status?: string | undefined;
|
|
483
|
+
currency?: string | undefined;
|
|
484
|
+
}, {
|
|
485
|
+
limit?: unknown;
|
|
486
|
+
offset?: unknown;
|
|
487
|
+
affiliateId?: string | undefined;
|
|
488
|
+
status?: string | undefined;
|
|
489
|
+
currency?: string | undefined;
|
|
490
|
+
}>;
|
|
491
|
+
}, {
|
|
492
|
+
readonly csv: string;
|
|
493
|
+
}>;
|
|
494
|
+
}, never, {
|
|
495
|
+
listAffiliates: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
496
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
497
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
498
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
499
|
+
pending: "pending";
|
|
500
|
+
approved: "approved";
|
|
501
|
+
suspended: "suspended";
|
|
502
|
+
}>>;
|
|
503
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:affiliate.read", z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
504
|
+
scope: z.ZodLiteral<"collection">;
|
|
505
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
506
|
+
scope: z.ZodLiteral<"record">;
|
|
507
|
+
affiliateId: z.ZodString;
|
|
508
|
+
}, z.core.$strip>], "scope">>, {
|
|
509
|
+
items: {
|
|
510
|
+
id: string;
|
|
511
|
+
userId: string;
|
|
512
|
+
name: string;
|
|
513
|
+
email: string;
|
|
514
|
+
code: string;
|
|
515
|
+
status: AffiliateStatus;
|
|
516
|
+
payoutDetails?: string | null;
|
|
517
|
+
notes?: string | null;
|
|
518
|
+
commissionType?: CommissionType | null;
|
|
519
|
+
commissionValue?: number | null;
|
|
520
|
+
createdAt: string;
|
|
521
|
+
updatedAt: string;
|
|
522
|
+
}[];
|
|
523
|
+
total: number;
|
|
524
|
+
limit: number;
|
|
525
|
+
offset: number;
|
|
526
|
+
}, false>;
|
|
527
|
+
getAffiliate: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
528
|
+
id: z.ZodString;
|
|
529
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:affiliate.read", z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
530
|
+
scope: z.ZodLiteral<"collection">;
|
|
531
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
532
|
+
scope: z.ZodLiteral<"record">;
|
|
533
|
+
affiliateId: z.ZodString;
|
|
534
|
+
}, z.core.$strip>], "scope">>, {
|
|
535
|
+
affiliate: {
|
|
536
|
+
id: string;
|
|
537
|
+
userId: string;
|
|
538
|
+
name: string;
|
|
539
|
+
email: string;
|
|
540
|
+
code: string;
|
|
541
|
+
status: AffiliateStatus;
|
|
542
|
+
payoutDetails?: string | null;
|
|
543
|
+
notes?: string | null;
|
|
544
|
+
commissionType?: CommissionType | null;
|
|
545
|
+
commissionValue?: number | null;
|
|
546
|
+
createdAt: string;
|
|
547
|
+
updatedAt: string;
|
|
548
|
+
};
|
|
549
|
+
stats: {
|
|
550
|
+
clicks: number;
|
|
551
|
+
conversions: number;
|
|
552
|
+
totals: {
|
|
553
|
+
currency: string;
|
|
554
|
+
pending: number;
|
|
555
|
+
approved: number;
|
|
556
|
+
paid: number;
|
|
557
|
+
voided: number;
|
|
558
|
+
}[];
|
|
559
|
+
};
|
|
560
|
+
}, false>;
|
|
561
|
+
createAffiliate: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
562
|
+
name: z.ZodString;
|
|
563
|
+
email: z.ZodEmail;
|
|
564
|
+
code: z.ZodOptional<z.ZodString>;
|
|
565
|
+
payoutDetails: z.ZodOptional<z.ZodString>;
|
|
566
|
+
userId: z.ZodString;
|
|
567
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:affiliate.create", undefined>, {
|
|
568
|
+
id: string;
|
|
569
|
+
userId: string;
|
|
570
|
+
name: string;
|
|
571
|
+
email: string;
|
|
572
|
+
code: string;
|
|
573
|
+
status: AffiliateStatus;
|
|
574
|
+
payoutDetails?: string | null;
|
|
575
|
+
notes?: string | null;
|
|
576
|
+
commissionType?: CommissionType | null;
|
|
577
|
+
commissionValue?: number | null;
|
|
578
|
+
createdAt: string;
|
|
579
|
+
updatedAt: string;
|
|
580
|
+
}, false>;
|
|
581
|
+
updateAffiliate: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
582
|
+
id: z.ZodString;
|
|
583
|
+
data: z.ZodObject<{
|
|
584
|
+
name: z.ZodOptional<z.ZodString>;
|
|
585
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
586
|
+
code: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
587
|
+
payoutDetails: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
588
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
589
|
+
pending: "pending";
|
|
590
|
+
approved: "approved";
|
|
591
|
+
suspended: "suspended";
|
|
592
|
+
}>>;
|
|
593
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
594
|
+
commissionType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
595
|
+
flat: "flat";
|
|
596
|
+
percent: "percent";
|
|
597
|
+
}>>>;
|
|
598
|
+
commissionValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
599
|
+
}, z.core.$strip>;
|
|
600
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:affiliate.update", z.ZodObject<{
|
|
601
|
+
affiliateId: z.ZodString;
|
|
602
|
+
userId: z.ZodString;
|
|
603
|
+
status: z.ZodEnum<{
|
|
604
|
+
pending: "pending";
|
|
605
|
+
approved: "approved";
|
|
606
|
+
suspended: "suspended";
|
|
607
|
+
}>;
|
|
608
|
+
}, z.core.$strip>>, {
|
|
609
|
+
id: string;
|
|
610
|
+
userId: string;
|
|
611
|
+
name: string;
|
|
612
|
+
email: string;
|
|
613
|
+
code: string;
|
|
614
|
+
status: AffiliateStatus;
|
|
615
|
+
payoutDetails?: string | null;
|
|
616
|
+
notes?: string | null;
|
|
617
|
+
commissionType?: CommissionType | null;
|
|
618
|
+
commissionValue?: number | null;
|
|
619
|
+
createdAt: string;
|
|
620
|
+
updatedAt: string;
|
|
621
|
+
}, false>;
|
|
622
|
+
deleteAffiliate: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
623
|
+
id: z.ZodString;
|
|
624
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:affiliate.delete", z.ZodObject<{
|
|
625
|
+
affiliateId: z.ZodString;
|
|
626
|
+
userId: z.ZodString;
|
|
627
|
+
status: z.ZodEnum<{
|
|
628
|
+
pending: "pending";
|
|
629
|
+
approved: "approved";
|
|
630
|
+
suspended: "suspended";
|
|
631
|
+
}>;
|
|
632
|
+
}, z.core.$strip>>, {
|
|
633
|
+
success: true;
|
|
634
|
+
}, false>;
|
|
635
|
+
apply: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
636
|
+
name: z.ZodString;
|
|
637
|
+
email: z.ZodEmail;
|
|
638
|
+
code: z.ZodOptional<z.ZodString>;
|
|
639
|
+
payoutDetails: z.ZodOptional<z.ZodString>;
|
|
640
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:application.create", undefined>, {
|
|
641
|
+
id: string;
|
|
642
|
+
userId: string;
|
|
643
|
+
name: string;
|
|
644
|
+
email: string;
|
|
645
|
+
code: string;
|
|
646
|
+
status: AffiliateStatus;
|
|
647
|
+
payoutDetails?: string | null;
|
|
648
|
+
notes?: string | null;
|
|
649
|
+
commissionType?: CommissionType | null;
|
|
650
|
+
commissionValue?: number | null;
|
|
651
|
+
createdAt: string;
|
|
652
|
+
updatedAt: string;
|
|
653
|
+
}, false>;
|
|
654
|
+
getPortal: _btst_stack_plugins_api.Operation<z.ZodObject<{}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:portal.read", undefined>, {
|
|
655
|
+
affiliate: {
|
|
656
|
+
id: string;
|
|
657
|
+
userId: string;
|
|
658
|
+
name: string;
|
|
659
|
+
email: string;
|
|
660
|
+
code: string;
|
|
661
|
+
status: AffiliateStatus;
|
|
662
|
+
payoutDetails?: string | null;
|
|
663
|
+
notes?: string | null;
|
|
664
|
+
commissionType?: CommissionType | null;
|
|
665
|
+
commissionValue?: number | null;
|
|
666
|
+
createdAt: string;
|
|
667
|
+
updatedAt: string;
|
|
668
|
+
} | null;
|
|
669
|
+
stats: {
|
|
670
|
+
clicks: number;
|
|
671
|
+
conversions: number;
|
|
672
|
+
totals: {
|
|
673
|
+
currency: string;
|
|
674
|
+
pending: number;
|
|
675
|
+
approved: number;
|
|
676
|
+
paid: number;
|
|
677
|
+
voided: number;
|
|
678
|
+
}[];
|
|
679
|
+
};
|
|
680
|
+
commissions: {
|
|
681
|
+
id: string;
|
|
682
|
+
affiliateId: string;
|
|
683
|
+
conversionId: string;
|
|
684
|
+
payoutId?: string | null;
|
|
685
|
+
amount: number;
|
|
686
|
+
currency: string;
|
|
687
|
+
status: CommissionStatus;
|
|
688
|
+
createdAt: string;
|
|
689
|
+
updatedAt: string;
|
|
690
|
+
}[];
|
|
691
|
+
payouts: {
|
|
692
|
+
id: string;
|
|
693
|
+
affiliateId: string;
|
|
694
|
+
amount: number;
|
|
695
|
+
currency: string;
|
|
696
|
+
status: PayoutStatus;
|
|
697
|
+
reference?: string | null;
|
|
698
|
+
paidAt?: string | null;
|
|
699
|
+
createdAt: string;
|
|
700
|
+
}[];
|
|
701
|
+
assets: {
|
|
702
|
+
name: string;
|
|
703
|
+
url: string;
|
|
704
|
+
description?: string;
|
|
705
|
+
bannerUrl?: string;
|
|
706
|
+
}[];
|
|
707
|
+
}, false>;
|
|
708
|
+
updatePortal: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
709
|
+
name: z.ZodOptional<z.ZodString>;
|
|
710
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
711
|
+
code: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
712
|
+
payoutDetails: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
713
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:portal.update", undefined>, {
|
|
714
|
+
id: string;
|
|
715
|
+
userId: string;
|
|
716
|
+
name: string;
|
|
717
|
+
email: string;
|
|
718
|
+
code: string;
|
|
719
|
+
status: AffiliateStatus;
|
|
720
|
+
payoutDetails?: string | null;
|
|
721
|
+
commissionType?: CommissionType | null;
|
|
722
|
+
commissionValue?: number | null;
|
|
723
|
+
createdAt: string;
|
|
724
|
+
updatedAt: string;
|
|
725
|
+
}, false>;
|
|
726
|
+
trackClick: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
727
|
+
code: z.ZodString;
|
|
728
|
+
landingPath: z.ZodOptional<z.ZodString>;
|
|
729
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
730
|
+
ipHash: z.ZodOptional<z.ZodString>;
|
|
731
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
732
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:tracking.track", undefined>, Response, true>;
|
|
733
|
+
createConversion: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
734
|
+
externalRef: z.ZodOptional<z.ZodString>;
|
|
735
|
+
amount: z.ZodNumber;
|
|
736
|
+
currency: z.ZodDefault<z.ZodString>;
|
|
737
|
+
attribution: z.ZodOptional<z.ZodObject<{
|
|
738
|
+
code: z.ZodOptional<z.ZodString>;
|
|
739
|
+
clickId: z.ZodOptional<z.ZodString>;
|
|
740
|
+
}, z.core.$strip>>;
|
|
741
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:conversion.create", undefined>, {
|
|
742
|
+
conversion: {
|
|
743
|
+
id: string;
|
|
744
|
+
affiliateId: string;
|
|
745
|
+
clickId?: string | null;
|
|
746
|
+
externalRef?: string | null;
|
|
747
|
+
amount: number;
|
|
748
|
+
currency: string;
|
|
749
|
+
status: "pending" | "approved" | "rejected";
|
|
750
|
+
createdAt: string;
|
|
751
|
+
};
|
|
752
|
+
commission: {
|
|
753
|
+
id: string;
|
|
754
|
+
affiliateId: string;
|
|
755
|
+
conversionId: string;
|
|
756
|
+
payoutId?: string | null;
|
|
757
|
+
amount: number;
|
|
758
|
+
currency: string;
|
|
759
|
+
status: CommissionStatus;
|
|
760
|
+
createdAt: string;
|
|
761
|
+
updatedAt: string;
|
|
762
|
+
};
|
|
763
|
+
} | null, false>;
|
|
764
|
+
listCommissions: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
765
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
766
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
767
|
+
affiliateId: z.ZodOptional<z.ZodString>;
|
|
768
|
+
status: z.ZodOptional<z.ZodString>;
|
|
769
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
770
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:commission.read", undefined>, {
|
|
771
|
+
items: {
|
|
772
|
+
id: string;
|
|
773
|
+
affiliateId: string;
|
|
774
|
+
conversionId: string;
|
|
775
|
+
payoutId?: string | null;
|
|
776
|
+
amount: number;
|
|
777
|
+
currency: string;
|
|
778
|
+
status: CommissionStatus;
|
|
779
|
+
createdAt: string;
|
|
780
|
+
updatedAt: string;
|
|
781
|
+
}[];
|
|
782
|
+
total: number;
|
|
783
|
+
limit: number;
|
|
784
|
+
offset: number;
|
|
785
|
+
}, false>;
|
|
786
|
+
updateCommission: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
787
|
+
id: z.ZodString;
|
|
788
|
+
data: z.ZodObject<{
|
|
789
|
+
status: z.ZodEnum<{
|
|
790
|
+
approved: "approved";
|
|
791
|
+
voided: "voided";
|
|
792
|
+
}>;
|
|
793
|
+
}, z.core.$strip>;
|
|
794
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:commission.update", z.ZodObject<{
|
|
795
|
+
commissionId: z.ZodString;
|
|
796
|
+
affiliateId: z.ZodString;
|
|
797
|
+
status: z.ZodEnum<{
|
|
798
|
+
pending: "pending";
|
|
799
|
+
approved: "approved";
|
|
800
|
+
paid: "paid";
|
|
801
|
+
voided: "voided";
|
|
802
|
+
}>;
|
|
803
|
+
}, z.core.$strip>>, {
|
|
804
|
+
id: string;
|
|
805
|
+
affiliateId: string;
|
|
806
|
+
conversionId: string;
|
|
807
|
+
payoutId?: string | null;
|
|
808
|
+
amount: number;
|
|
809
|
+
currency: string;
|
|
810
|
+
status: CommissionStatus;
|
|
811
|
+
createdAt: string;
|
|
812
|
+
updatedAt: string;
|
|
813
|
+
}, false>;
|
|
814
|
+
listPayouts: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
815
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
816
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
817
|
+
affiliateId: z.ZodOptional<z.ZodString>;
|
|
818
|
+
status: z.ZodOptional<z.ZodString>;
|
|
819
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
820
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:payout.read", undefined>, {
|
|
821
|
+
items: {
|
|
822
|
+
id: string;
|
|
823
|
+
affiliateId: string;
|
|
824
|
+
amount: number;
|
|
825
|
+
currency: string;
|
|
826
|
+
status: PayoutStatus;
|
|
827
|
+
reference?: string | null;
|
|
828
|
+
paidAt?: string | null;
|
|
829
|
+
createdAt: string;
|
|
830
|
+
}[];
|
|
831
|
+
total: number;
|
|
832
|
+
limit: number;
|
|
833
|
+
offset: number;
|
|
834
|
+
}, false>;
|
|
835
|
+
createPayout: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
836
|
+
affiliateId: z.ZodString;
|
|
837
|
+
currency: z.ZodString;
|
|
838
|
+
commissionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
839
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:payout.create", z.ZodObject<{
|
|
840
|
+
affiliateId: z.ZodString;
|
|
841
|
+
currency: z.ZodString;
|
|
842
|
+
}, z.core.$strip>>, {
|
|
843
|
+
id: string;
|
|
844
|
+
affiliateId: string;
|
|
845
|
+
amount: number;
|
|
846
|
+
currency: string;
|
|
847
|
+
status: PayoutStatus;
|
|
848
|
+
reference?: string | null;
|
|
849
|
+
paidAt?: string | null;
|
|
850
|
+
createdAt: string;
|
|
851
|
+
}, false>;
|
|
852
|
+
updatePayout: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
853
|
+
id: z.ZodString;
|
|
854
|
+
data: z.ZodObject<{
|
|
855
|
+
status: z.ZodEnum<{
|
|
856
|
+
sent: "sent";
|
|
857
|
+
failed: "failed";
|
|
858
|
+
}>;
|
|
859
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
860
|
+
}, z.core.$strip>;
|
|
861
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:payout.update", z.ZodObject<{
|
|
862
|
+
payoutId: z.ZodString;
|
|
863
|
+
affiliateId: z.ZodString;
|
|
864
|
+
status: z.ZodEnum<{
|
|
865
|
+
pending: "pending";
|
|
866
|
+
sent: "sent";
|
|
867
|
+
failed: "failed";
|
|
868
|
+
}>;
|
|
869
|
+
}, z.core.$strip>>, {
|
|
870
|
+
id: string;
|
|
871
|
+
affiliateId: string;
|
|
872
|
+
amount: number;
|
|
873
|
+
currency: string;
|
|
874
|
+
status: PayoutStatus;
|
|
875
|
+
reference?: string | null;
|
|
876
|
+
paidAt?: string | null;
|
|
877
|
+
createdAt: string;
|
|
878
|
+
}, false>;
|
|
879
|
+
exportPayouts: _btst_stack_plugins_api.Operation<z.ZodObject<{
|
|
880
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
881
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
882
|
+
affiliateId: z.ZodOptional<z.ZodString>;
|
|
883
|
+
status: z.ZodOptional<z.ZodString>;
|
|
884
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
885
|
+
}, z.core.$strip>, _btst_stack_authorization.PermissionDescriptor<"affiliate:payout.export", undefined>, {
|
|
886
|
+
csv: string;
|
|
887
|
+
}, false>;
|
|
888
|
+
}, "affiliate">;
|
|
889
|
+
type AffiliateApiRouter = ReturnType<ReturnType<typeof affiliateBackendPlugin>["routes"]>;
|
|
890
|
+
|
|
891
|
+
declare const affiliateSchema: _btst_db.DbPlugin;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Lower-level reads do not authorize callers or run operation lifecycle hooks.
|
|
895
|
+
* Callers own input validation and access control; use stack operations for requests.
|
|
896
|
+
*/
|
|
897
|
+
|
|
898
|
+
/** Adapter reads shared by ordinary callers and an existing transaction. */
|
|
899
|
+
type AffiliateDataAdapter = Omit<DBAdapter, "transaction">;
|
|
900
|
+
type Where = {
|
|
901
|
+
field: string;
|
|
902
|
+
value: string;
|
|
903
|
+
operator: "eq";
|
|
904
|
+
}[];
|
|
905
|
+
/** Normalize adapter Date values for JSON and hydrated query caches. */
|
|
906
|
+
declare function serializeAffiliateRecord<T>(record: unknown): T;
|
|
907
|
+
/** Read an affiliate profile, including administrative notes, by its record ID. */
|
|
908
|
+
declare const getAffiliate: (adapter: AffiliateDataAdapter, id: string) => Promise<Affiliate | null>;
|
|
909
|
+
/** Find the profile owned by an authenticated account ID. */
|
|
910
|
+
declare const getAffiliateByUserId: (adapter: AffiliateDataAdapter, userId: string) => Promise<Affiliate | null>;
|
|
911
|
+
/** Resolve a public referral code without filtering the affiliate's status. */
|
|
912
|
+
declare const getAffiliateByCode: (adapter: AffiliateDataAdapter, code: string) => Promise<Affiliate | null>;
|
|
913
|
+
/** Resolve an opaque click ID; callers must still check its attribution window. */
|
|
914
|
+
declare const getReferralClick: (adapter: AffiliateDataAdapter, id: string) => Promise<ReferralClick | null>;
|
|
915
|
+
/** Read a commission and its payout reservation, if any. */
|
|
916
|
+
declare const getCommission: (adapter: AffiliateDataAdapter, id: string) => Promise<Commission | null>;
|
|
917
|
+
/** Read a manual payout batch by ID. */
|
|
918
|
+
declare const getPayout: (adapter: AffiliateDataAdapter, id: string) => Promise<Payout | null>;
|
|
919
|
+
/** Find an existing order/event conversion for retry deduplication. */
|
|
920
|
+
declare const getConversionByExternalRef: (adapter: AffiliateDataAdapter, externalRef: string) => Promise<Conversion | null>;
|
|
921
|
+
/** Page affiliate profiles, including administrative notes, newest first. */
|
|
922
|
+
declare const listAffiliates: (adapter: AffiliateDataAdapter, params?: ListParams) => Promise<ListResult<Affiliate>>;
|
|
923
|
+
/** Page commissions, optionally filtering affiliate, status, and currency. */
|
|
924
|
+
declare const listCommissions: (adapter: AffiliateDataAdapter, params?: ListParams) => Promise<ListResult<Commission>>;
|
|
925
|
+
/** Page payout batches, optionally filtering affiliate, status, and currency. */
|
|
926
|
+
declare const listPayouts: (adapter: AffiliateDataAdapter, params?: ListParams) => Promise<ListResult<Payout>>;
|
|
927
|
+
/** Read every matching record in stable ID order, beyond adapter page limits. */
|
|
928
|
+
declare function allRows<T>(adapter: AffiliateDataAdapter, model: string, where?: Where): Promise<T[]>;
|
|
929
|
+
/** Count referral activity and total commission minor units separately per currency. */
|
|
930
|
+
declare function getAffiliateStats(adapter: AffiliateDataAdapter, affiliateId: string): Promise<AffiliateStats>;
|
|
931
|
+
/** Read one account's portal, excluding notes and limiting each history to 100 records. */
|
|
932
|
+
declare function getPortal(adapter: AffiliateDataAdapter, userId: string, assets?: MarketingAsset[]): Promise<AffiliatePortal>;
|
|
933
|
+
/** Export all matching batches with quoted cells and escaped spreadsheet formulas. */
|
|
934
|
+
declare function exportPayouts(adapter: AffiliateDataAdapter, params?: ListParams): Promise<string>;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Lower-level writes validate domain inputs but do not authorize callers or run
|
|
938
|
+
* operation lifecycle hooks. Callers own those concerns; use stack operations for requests.
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
type AffiliateSnapshot = Pick<Affiliate, "id" | "userId" | "status">;
|
|
942
|
+
/** Serialize ledger changes with a transactional affiliate row lock and a memory-adapter queue. */
|
|
943
|
+
declare function withAffiliateTransaction<T>(adapter: DBAdapter, affiliateId: string | null, run: (tx: AffiliateDataAdapter) => Promise<T>): Promise<T>;
|
|
944
|
+
/** Create a pending profile with unique account, email, and referral code. */
|
|
945
|
+
declare function createAffiliate(adapter: DBAdapter, input: CreateAffiliateInput): Promise<Affiliate>;
|
|
946
|
+
/** Update a profile while enforcing unique fields, status transitions, and commission rules. */
|
|
947
|
+
declare function updateAffiliate(adapter: DBAdapter, id: string, input: UpdateAffiliateInput, expected?: AffiliateSnapshot): Promise<Affiliate>;
|
|
948
|
+
/** Delete a profile and its clicks only when no financial history exists. */
|
|
949
|
+
declare function deleteAffiliate(adapter: DBAdapter, id: string, expected?: AffiliateSnapshot): Promise<{
|
|
950
|
+
success: true;
|
|
951
|
+
}>;
|
|
952
|
+
/** Record a local landing-page visit for an approved affiliate. */
|
|
953
|
+
declare function trackClick(adapter: DBAdapter, input: TrackClickInput): Promise<ReferralClick>;
|
|
954
|
+
/** Atomically create an attributed conversion and commission, deduplicating stable external references. */
|
|
955
|
+
declare function createConversion(adapter: DBAdapter, input: CreateConversionInput, options?: AffiliateOptions): Promise<{
|
|
956
|
+
conversion: Conversion;
|
|
957
|
+
commission: Commission;
|
|
958
|
+
} | null>;
|
|
959
|
+
/** Approve or void an unsettled commission that has no payout reservation. */
|
|
960
|
+
declare function updateCommission(adapter: DBAdapter, id: string, input: {
|
|
961
|
+
status: "approved" | "voided";
|
|
962
|
+
}, expected?: Pick<Commission, "id" | "affiliateId" | "status">): Promise<Commission>;
|
|
963
|
+
/** Reserve approved commissions in one currency for a manual payout batch. */
|
|
964
|
+
declare function createPayout(adapter: DBAdapter, input: CreatePayoutInput): Promise<Payout>;
|
|
965
|
+
/** Mark a pending batch sent and its commissions paid, or failed and release its reservations. */
|
|
966
|
+
declare function updatePayout(adapter: DBAdapter, id: string, input: {
|
|
967
|
+
status: "sent" | "failed";
|
|
968
|
+
reference?: string;
|
|
969
|
+
}, expected?: Pick<Payout, "id" | "affiliateId" | "status">): Promise<Payout>;
|
|
970
|
+
|
|
971
|
+
/** Amounts are integer minor units; percentage values may have up to two decimals. */
|
|
972
|
+
declare function calculateCommission(amount: number, type: CommissionType, value: number): number;
|
|
973
|
+
|
|
974
|
+
export { Affiliate, AffiliateOptions, AffiliatePortal, AffiliateStats, AffiliateStatus, Commission, CommissionStatus, CommissionType, Conversion, CreateAffiliateInput, CreateConversionInput, CreatePayoutInput, ListParams, ListResult, MarketingAsset, Payout, PayoutStatus, ReferralClick, TrackClickInput, UpdateAffiliateInput, affiliateBackendPlugin, affiliateSchema, allRows, calculateCommission, createAffiliate, createConversion, createPayout, deleteAffiliate, exportPayouts, getAffiliate, getAffiliateByCode, getAffiliateByUserId, getAffiliateStats, getCommission, getConversionByExternalRef, getPayout, getPortal, getReferralClick, listAffiliates, listCommissions, listPayouts, serializeAffiliateRecord, trackClick, updateAffiliate, updateCommission, updatePayout, withAffiliateTransaction };
|
|
975
|
+
export type { AffiliateApiRouter, AffiliateBackendOptions, AffiliateDataAdapter, AffiliateHookContext, AffiliatePluginHooks };
|