agentmall 0.1.20 → 0.1.21
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/dist/cli.js +21 -9
- package/dist/index.cjs +21 -9
- package/dist/index.d.cts +27 -15
- package/dist/index.d.ts +27 -15
- package/dist/index.js +21 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -73,6 +73,7 @@ var AgentMall = class {
|
|
|
73
73
|
purchases;
|
|
74
74
|
payments;
|
|
75
75
|
refunds;
|
|
76
|
+
storeAccounts;
|
|
76
77
|
managedAccounts;
|
|
77
78
|
constructor(config = {}) {
|
|
78
79
|
this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
|
|
@@ -82,7 +83,8 @@ var AgentMall = class {
|
|
|
82
83
|
this.purchases = new AgentMallPurchases(this);
|
|
83
84
|
this.payments = new AgentMallPayments(this);
|
|
84
85
|
this.refunds = new AgentMallRefunds(this);
|
|
85
|
-
this.
|
|
86
|
+
this.storeAccounts = new AgentMallStoreAccounts(this);
|
|
87
|
+
this.managedAccounts = this.storeAccounts;
|
|
86
88
|
}
|
|
87
89
|
/** @internal */
|
|
88
90
|
hasApiSecret() {
|
|
@@ -161,9 +163,11 @@ var AgentMallPurchases = class {
|
|
|
161
163
|
*/
|
|
162
164
|
async create(body) {
|
|
163
165
|
const idempotencyKey = body.idempotency_key ?? createIdempotencyKey();
|
|
166
|
+
const storeAccountId = body.store_account_id ?? body.retailer_credentials_id;
|
|
164
167
|
return this.client.request("POST", "/api/purchases", {
|
|
165
168
|
body: {
|
|
166
169
|
...body,
|
|
170
|
+
...storeAccountId ? { retailer_credentials_id: storeAccountId } : {},
|
|
167
171
|
idempotency_key: idempotencyKey
|
|
168
172
|
},
|
|
169
173
|
headers: {
|
|
@@ -174,20 +178,22 @@ var AgentMallPurchases = class {
|
|
|
174
178
|
/** Get a single purchase by ID using either operator auth or a buyer token. */
|
|
175
179
|
async get(id, options) {
|
|
176
180
|
if (options?.buyerToken) {
|
|
177
|
-
|
|
181
|
+
const purchase2 = await this.client.request("POST", "/api/purchases/status", {
|
|
178
182
|
body: {
|
|
179
183
|
id,
|
|
180
184
|
buyer_token: options.buyerToken
|
|
181
185
|
}
|
|
182
186
|
});
|
|
187
|
+
return normalizePurchase(purchase2);
|
|
183
188
|
}
|
|
184
189
|
if (!this.client.hasApiSecret()) {
|
|
185
190
|
throw new Error("buyerToken or apiSecret is required for this endpoint");
|
|
186
191
|
}
|
|
187
|
-
|
|
192
|
+
const purchase = await this.client.request("GET", "/api/purchases", {
|
|
188
193
|
auth: true,
|
|
189
194
|
params: { id }
|
|
190
195
|
});
|
|
196
|
+
return normalizePurchase(purchase);
|
|
191
197
|
}
|
|
192
198
|
/** List purchases. Requires apiSecret. */
|
|
193
199
|
async list(filters) {
|
|
@@ -196,7 +202,7 @@ var AgentMallPurchases = class {
|
|
|
196
202
|
"/api/purchases",
|
|
197
203
|
{ auth: true, params: filters }
|
|
198
204
|
);
|
|
199
|
-
return result.purchases;
|
|
205
|
+
return result.purchases.map(normalizePurchase);
|
|
200
206
|
}
|
|
201
207
|
};
|
|
202
208
|
var AgentMallPayments = class {
|
|
@@ -268,7 +274,13 @@ var AgentMallRefunds = class {
|
|
|
268
274
|
return result.refunds;
|
|
269
275
|
}
|
|
270
276
|
};
|
|
271
|
-
|
|
277
|
+
function normalizePurchase(purchase) {
|
|
278
|
+
return {
|
|
279
|
+
...purchase,
|
|
280
|
+
...purchase.storeAccountId ? {} : purchase.retailerCredentialsId ? { storeAccountId: purchase.retailerCredentialsId } : {}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
var AgentMallStoreAccounts = class {
|
|
272
284
|
constructor(client) {
|
|
273
285
|
this.client = client;
|
|
274
286
|
}
|
|
@@ -291,28 +303,28 @@ var AgentMallManagedAccounts = class {
|
|
|
291
303
|
"X-AgentMall-Auth-Signature": signature
|
|
292
304
|
};
|
|
293
305
|
}
|
|
294
|
-
/** List
|
|
306
|
+
/** List your store accounts. Requires either apiSecret or a wallet signer. */
|
|
295
307
|
async list(options) {
|
|
296
308
|
const result = await this.client.request("GET", "/api/managed-accounts", {
|
|
297
309
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
|
|
298
310
|
});
|
|
299
311
|
return result.credentials;
|
|
300
312
|
}
|
|
301
|
-
/** Create a
|
|
313
|
+
/** Create a store account. Requires either apiSecret or a wallet signer. */
|
|
302
314
|
async create(body, options) {
|
|
303
315
|
return this.client.request("POST", "/api/managed-accounts", {
|
|
304
316
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
305
317
|
body
|
|
306
318
|
});
|
|
307
319
|
}
|
|
308
|
-
/** Update a
|
|
320
|
+
/** Update a store account. Requires either apiSecret or a wallet signer. */
|
|
309
321
|
async update(body, options) {
|
|
310
322
|
return this.client.request("PUT", "/api/managed-accounts", {
|
|
311
323
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
312
324
|
body
|
|
313
325
|
});
|
|
314
326
|
}
|
|
315
|
-
/** Delete a
|
|
327
|
+
/** Delete a store account. Requires either apiSecret or a wallet signer. */
|
|
316
328
|
async delete(shortId, options) {
|
|
317
329
|
await this.client.request("DELETE", "/api/managed-accounts", {
|
|
318
330
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
package/dist/index.cjs
CHANGED
|
@@ -113,6 +113,7 @@ var AgentMall = class {
|
|
|
113
113
|
purchases;
|
|
114
114
|
payments;
|
|
115
115
|
refunds;
|
|
116
|
+
storeAccounts;
|
|
116
117
|
managedAccounts;
|
|
117
118
|
constructor(config = {}) {
|
|
118
119
|
this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
|
|
@@ -122,7 +123,8 @@ var AgentMall = class {
|
|
|
122
123
|
this.purchases = new AgentMallPurchases(this);
|
|
123
124
|
this.payments = new AgentMallPayments(this);
|
|
124
125
|
this.refunds = new AgentMallRefunds(this);
|
|
125
|
-
this.
|
|
126
|
+
this.storeAccounts = new AgentMallStoreAccounts(this);
|
|
127
|
+
this.managedAccounts = this.storeAccounts;
|
|
126
128
|
}
|
|
127
129
|
/** @internal */
|
|
128
130
|
hasApiSecret() {
|
|
@@ -201,9 +203,11 @@ var AgentMallPurchases = class {
|
|
|
201
203
|
*/
|
|
202
204
|
async create(body) {
|
|
203
205
|
const idempotencyKey = body.idempotency_key ?? createIdempotencyKey();
|
|
206
|
+
const storeAccountId = body.store_account_id ?? body.retailer_credentials_id;
|
|
204
207
|
return this.client.request("POST", "/api/purchases", {
|
|
205
208
|
body: {
|
|
206
209
|
...body,
|
|
210
|
+
...storeAccountId ? { retailer_credentials_id: storeAccountId } : {},
|
|
207
211
|
idempotency_key: idempotencyKey
|
|
208
212
|
},
|
|
209
213
|
headers: {
|
|
@@ -214,20 +218,22 @@ var AgentMallPurchases = class {
|
|
|
214
218
|
/** Get a single purchase by ID using either operator auth or a buyer token. */
|
|
215
219
|
async get(id, options) {
|
|
216
220
|
if (options?.buyerToken) {
|
|
217
|
-
|
|
221
|
+
const purchase3 = await this.client.request("POST", "/api/purchases/status", {
|
|
218
222
|
body: {
|
|
219
223
|
id,
|
|
220
224
|
buyer_token: options.buyerToken
|
|
221
225
|
}
|
|
222
226
|
});
|
|
227
|
+
return normalizePurchase(purchase3);
|
|
223
228
|
}
|
|
224
229
|
if (!this.client.hasApiSecret()) {
|
|
225
230
|
throw new Error("buyerToken or apiSecret is required for this endpoint");
|
|
226
231
|
}
|
|
227
|
-
|
|
232
|
+
const purchase2 = await this.client.request("GET", "/api/purchases", {
|
|
228
233
|
auth: true,
|
|
229
234
|
params: { id }
|
|
230
235
|
});
|
|
236
|
+
return normalizePurchase(purchase2);
|
|
231
237
|
}
|
|
232
238
|
/** List purchases. Requires apiSecret. */
|
|
233
239
|
async list(filters) {
|
|
@@ -236,7 +242,7 @@ var AgentMallPurchases = class {
|
|
|
236
242
|
"/api/purchases",
|
|
237
243
|
{ auth: true, params: filters }
|
|
238
244
|
);
|
|
239
|
-
return result.purchases;
|
|
245
|
+
return result.purchases.map(normalizePurchase);
|
|
240
246
|
}
|
|
241
247
|
};
|
|
242
248
|
var AgentMallPayments = class {
|
|
@@ -308,7 +314,13 @@ var AgentMallRefunds = class {
|
|
|
308
314
|
return result.refunds;
|
|
309
315
|
}
|
|
310
316
|
};
|
|
311
|
-
|
|
317
|
+
function normalizePurchase(purchase2) {
|
|
318
|
+
return {
|
|
319
|
+
...purchase2,
|
|
320
|
+
...purchase2.storeAccountId ? {} : purchase2.retailerCredentialsId ? { storeAccountId: purchase2.retailerCredentialsId } : {}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
var AgentMallStoreAccounts = class {
|
|
312
324
|
constructor(client) {
|
|
313
325
|
this.client = client;
|
|
314
326
|
}
|
|
@@ -331,28 +343,28 @@ var AgentMallManagedAccounts = class {
|
|
|
331
343
|
"X-AgentMall-Auth-Signature": signature
|
|
332
344
|
};
|
|
333
345
|
}
|
|
334
|
-
/** List
|
|
346
|
+
/** List your store accounts. Requires either apiSecret or a wallet signer. */
|
|
335
347
|
async list(options) {
|
|
336
348
|
const result = await this.client.request("GET", "/api/managed-accounts", {
|
|
337
349
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
|
|
338
350
|
});
|
|
339
351
|
return result.credentials;
|
|
340
352
|
}
|
|
341
|
-
/** Create a
|
|
353
|
+
/** Create a store account. Requires either apiSecret or a wallet signer. */
|
|
342
354
|
async create(body, options) {
|
|
343
355
|
return this.client.request("POST", "/api/managed-accounts", {
|
|
344
356
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
345
357
|
body
|
|
346
358
|
});
|
|
347
359
|
}
|
|
348
|
-
/** Update a
|
|
360
|
+
/** Update a store account. Requires either apiSecret or a wallet signer. */
|
|
349
361
|
async update(body, options) {
|
|
350
362
|
return this.client.request("PUT", "/api/managed-accounts", {
|
|
351
363
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
352
364
|
body
|
|
353
365
|
});
|
|
354
366
|
}
|
|
355
|
-
/** Delete a
|
|
367
|
+
/** Delete a store account. Requires either apiSecret or a wallet signer. */
|
|
356
368
|
async delete(shortId, options) {
|
|
357
369
|
await this.client.request("DELETE", "/api/managed-accounts", {
|
|
358
370
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,7 @@ type CreatePurchaseRequest = {
|
|
|
62
62
|
delivery_address: DeliveryAddress;
|
|
63
63
|
max_budget: number;
|
|
64
64
|
buyer_email: string;
|
|
65
|
+
store_account_id?: string;
|
|
65
66
|
retailer_credentials_id?: string;
|
|
66
67
|
idempotency_key?: string;
|
|
67
68
|
metadata?: unknown;
|
|
@@ -92,6 +93,7 @@ type Purchase = {
|
|
|
92
93
|
items: PurchaseItem[];
|
|
93
94
|
deliveryMethod?: string;
|
|
94
95
|
tracking?: unknown;
|
|
96
|
+
storeAccountId?: string;
|
|
95
97
|
retailerCredentialsId?: string;
|
|
96
98
|
maxBudget: number;
|
|
97
99
|
finalTotal?: number;
|
|
@@ -143,7 +145,7 @@ type RefundFilters = {
|
|
|
143
145
|
purchase_id?: string;
|
|
144
146
|
status?: string;
|
|
145
147
|
};
|
|
146
|
-
type
|
|
148
|
+
type StoreAccount = {
|
|
147
149
|
id: string;
|
|
148
150
|
short_id: string;
|
|
149
151
|
email: string;
|
|
@@ -155,19 +157,25 @@ type ManagedAccount = {
|
|
|
155
157
|
created_at: string;
|
|
156
158
|
updated_at: string;
|
|
157
159
|
};
|
|
158
|
-
type
|
|
160
|
+
type RetailerAccount = StoreAccount;
|
|
161
|
+
type ManagedAccount = StoreAccount;
|
|
162
|
+
type StoreAccountAuthChallenge = {
|
|
159
163
|
challenge: string;
|
|
160
164
|
message: string;
|
|
161
165
|
expiresAt: number;
|
|
162
166
|
};
|
|
163
|
-
type
|
|
167
|
+
type RetailerAccountAuthChallenge = StoreAccountAuthChallenge;
|
|
168
|
+
type ManagedAccountAuthChallenge = StoreAccountAuthChallenge;
|
|
169
|
+
type CreateStoreAccountRequest = {
|
|
164
170
|
email: string;
|
|
165
171
|
password?: string | null;
|
|
166
172
|
retailer?: string | null;
|
|
167
173
|
totp_secret?: string | null;
|
|
168
174
|
retailer_config?: Record<string, unknown> | null;
|
|
169
175
|
};
|
|
170
|
-
type
|
|
176
|
+
type CreateRetailerAccountRequest = CreateStoreAccountRequest;
|
|
177
|
+
type CreateManagedAccountRequest = CreateStoreAccountRequest;
|
|
178
|
+
type UpdateStoreAccountRequest = {
|
|
171
179
|
short_id: string;
|
|
172
180
|
email?: string | null;
|
|
173
181
|
password?: string | null;
|
|
@@ -175,6 +183,8 @@ type UpdateManagedAccountRequest = {
|
|
|
175
183
|
totp_secret?: string | null;
|
|
176
184
|
retailer_config?: Record<string, unknown> | null;
|
|
177
185
|
};
|
|
186
|
+
type UpdateRetailerAccountRequest = UpdateStoreAccountRequest;
|
|
187
|
+
type UpdateManagedAccountRequest = UpdateStoreAccountRequest;
|
|
178
188
|
|
|
179
189
|
declare class AgentMall {
|
|
180
190
|
private baseUrl;
|
|
@@ -184,6 +194,7 @@ declare class AgentMall {
|
|
|
184
194
|
purchases: AgentMallPurchases;
|
|
185
195
|
payments: AgentMallPayments;
|
|
186
196
|
refunds: AgentMallRefunds;
|
|
197
|
+
storeAccounts: AgentMallStoreAccounts;
|
|
187
198
|
managedAccounts: AgentMallManagedAccounts;
|
|
188
199
|
constructor(config?: AgentMallConfig);
|
|
189
200
|
/** @internal */
|
|
@@ -237,27 +248,28 @@ declare class AgentMallRefunds {
|
|
|
237
248
|
/** List refunds. Requires apiSecret. */
|
|
238
249
|
list(filters?: RefundFilters): Promise<Refund[]>;
|
|
239
250
|
}
|
|
240
|
-
declare class
|
|
251
|
+
declare class AgentMallStoreAccounts {
|
|
241
252
|
private client;
|
|
242
253
|
constructor(client: AgentMall);
|
|
243
254
|
private walletHeaders;
|
|
244
|
-
/** List
|
|
255
|
+
/** List your store accounts. Requires either apiSecret or a wallet signer. */
|
|
245
256
|
list(options?: {
|
|
246
257
|
account?: WalletAccount;
|
|
247
|
-
}): Promise<
|
|
248
|
-
/** Create a
|
|
249
|
-
create(body:
|
|
258
|
+
}): Promise<StoreAccount[]>;
|
|
259
|
+
/** Create a store account. Requires either apiSecret or a wallet signer. */
|
|
260
|
+
create(body: CreateStoreAccountRequest, options?: {
|
|
250
261
|
account?: WalletAccount;
|
|
251
|
-
}): Promise<
|
|
252
|
-
/** Update a
|
|
253
|
-
update(body:
|
|
262
|
+
}): Promise<StoreAccount>;
|
|
263
|
+
/** Update a store account. Requires either apiSecret or a wallet signer. */
|
|
264
|
+
update(body: UpdateStoreAccountRequest, options?: {
|
|
254
265
|
account?: WalletAccount;
|
|
255
|
-
}): Promise<
|
|
256
|
-
/** Delete a
|
|
266
|
+
}): Promise<StoreAccount>;
|
|
267
|
+
/** Delete a store account. Requires either apiSecret or a wallet signer. */
|
|
257
268
|
delete(shortId: string, options?: {
|
|
258
269
|
account?: WalletAccount;
|
|
259
270
|
}): Promise<void>;
|
|
260
271
|
}
|
|
272
|
+
type AgentMallManagedAccounts = AgentMallStoreAccounts;
|
|
261
273
|
|
|
262
274
|
type PurchaseConfig = CreatePurchaseRequest & {
|
|
263
275
|
/** viem Account for MPP payment (from privateKeyToAccount or mppx resolveAccount). */
|
|
@@ -308,4 +320,4 @@ declare const BASE_URL = "https://api.agentmall.sh";
|
|
|
308
320
|
declare const SERVICE_FEE_CENTS = 150;
|
|
309
321
|
declare const SUPPORTED_RETAILERS: readonly ["amazon.com", "walmart.com", "target.com", "bestbuy.com", "homedepot.com", "ebay.com", "lowes.com", "wayfair.com", "acehardware.com", "1800flowers.com", "pokemoncenter.com"];
|
|
310
322
|
|
|
311
|
-
export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type UpdateManagedAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
|
|
323
|
+
export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type CreateRetailerAccountRequest, type CreateStoreAccountRequest, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, type RetailerAccount, type RetailerAccountAuthChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type StoreAccount, type StoreAccountAuthChallenge, type UpdateManagedAccountRequest, type UpdateRetailerAccountRequest, type UpdateStoreAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ type CreatePurchaseRequest = {
|
|
|
62
62
|
delivery_address: DeliveryAddress;
|
|
63
63
|
max_budget: number;
|
|
64
64
|
buyer_email: string;
|
|
65
|
+
store_account_id?: string;
|
|
65
66
|
retailer_credentials_id?: string;
|
|
66
67
|
idempotency_key?: string;
|
|
67
68
|
metadata?: unknown;
|
|
@@ -92,6 +93,7 @@ type Purchase = {
|
|
|
92
93
|
items: PurchaseItem[];
|
|
93
94
|
deliveryMethod?: string;
|
|
94
95
|
tracking?: unknown;
|
|
96
|
+
storeAccountId?: string;
|
|
95
97
|
retailerCredentialsId?: string;
|
|
96
98
|
maxBudget: number;
|
|
97
99
|
finalTotal?: number;
|
|
@@ -143,7 +145,7 @@ type RefundFilters = {
|
|
|
143
145
|
purchase_id?: string;
|
|
144
146
|
status?: string;
|
|
145
147
|
};
|
|
146
|
-
type
|
|
148
|
+
type StoreAccount = {
|
|
147
149
|
id: string;
|
|
148
150
|
short_id: string;
|
|
149
151
|
email: string;
|
|
@@ -155,19 +157,25 @@ type ManagedAccount = {
|
|
|
155
157
|
created_at: string;
|
|
156
158
|
updated_at: string;
|
|
157
159
|
};
|
|
158
|
-
type
|
|
160
|
+
type RetailerAccount = StoreAccount;
|
|
161
|
+
type ManagedAccount = StoreAccount;
|
|
162
|
+
type StoreAccountAuthChallenge = {
|
|
159
163
|
challenge: string;
|
|
160
164
|
message: string;
|
|
161
165
|
expiresAt: number;
|
|
162
166
|
};
|
|
163
|
-
type
|
|
167
|
+
type RetailerAccountAuthChallenge = StoreAccountAuthChallenge;
|
|
168
|
+
type ManagedAccountAuthChallenge = StoreAccountAuthChallenge;
|
|
169
|
+
type CreateStoreAccountRequest = {
|
|
164
170
|
email: string;
|
|
165
171
|
password?: string | null;
|
|
166
172
|
retailer?: string | null;
|
|
167
173
|
totp_secret?: string | null;
|
|
168
174
|
retailer_config?: Record<string, unknown> | null;
|
|
169
175
|
};
|
|
170
|
-
type
|
|
176
|
+
type CreateRetailerAccountRequest = CreateStoreAccountRequest;
|
|
177
|
+
type CreateManagedAccountRequest = CreateStoreAccountRequest;
|
|
178
|
+
type UpdateStoreAccountRequest = {
|
|
171
179
|
short_id: string;
|
|
172
180
|
email?: string | null;
|
|
173
181
|
password?: string | null;
|
|
@@ -175,6 +183,8 @@ type UpdateManagedAccountRequest = {
|
|
|
175
183
|
totp_secret?: string | null;
|
|
176
184
|
retailer_config?: Record<string, unknown> | null;
|
|
177
185
|
};
|
|
186
|
+
type UpdateRetailerAccountRequest = UpdateStoreAccountRequest;
|
|
187
|
+
type UpdateManagedAccountRequest = UpdateStoreAccountRequest;
|
|
178
188
|
|
|
179
189
|
declare class AgentMall {
|
|
180
190
|
private baseUrl;
|
|
@@ -184,6 +194,7 @@ declare class AgentMall {
|
|
|
184
194
|
purchases: AgentMallPurchases;
|
|
185
195
|
payments: AgentMallPayments;
|
|
186
196
|
refunds: AgentMallRefunds;
|
|
197
|
+
storeAccounts: AgentMallStoreAccounts;
|
|
187
198
|
managedAccounts: AgentMallManagedAccounts;
|
|
188
199
|
constructor(config?: AgentMallConfig);
|
|
189
200
|
/** @internal */
|
|
@@ -237,27 +248,28 @@ declare class AgentMallRefunds {
|
|
|
237
248
|
/** List refunds. Requires apiSecret. */
|
|
238
249
|
list(filters?: RefundFilters): Promise<Refund[]>;
|
|
239
250
|
}
|
|
240
|
-
declare class
|
|
251
|
+
declare class AgentMallStoreAccounts {
|
|
241
252
|
private client;
|
|
242
253
|
constructor(client: AgentMall);
|
|
243
254
|
private walletHeaders;
|
|
244
|
-
/** List
|
|
255
|
+
/** List your store accounts. Requires either apiSecret or a wallet signer. */
|
|
245
256
|
list(options?: {
|
|
246
257
|
account?: WalletAccount;
|
|
247
|
-
}): Promise<
|
|
248
|
-
/** Create a
|
|
249
|
-
create(body:
|
|
258
|
+
}): Promise<StoreAccount[]>;
|
|
259
|
+
/** Create a store account. Requires either apiSecret or a wallet signer. */
|
|
260
|
+
create(body: CreateStoreAccountRequest, options?: {
|
|
250
261
|
account?: WalletAccount;
|
|
251
|
-
}): Promise<
|
|
252
|
-
/** Update a
|
|
253
|
-
update(body:
|
|
262
|
+
}): Promise<StoreAccount>;
|
|
263
|
+
/** Update a store account. Requires either apiSecret or a wallet signer. */
|
|
264
|
+
update(body: UpdateStoreAccountRequest, options?: {
|
|
254
265
|
account?: WalletAccount;
|
|
255
|
-
}): Promise<
|
|
256
|
-
/** Delete a
|
|
266
|
+
}): Promise<StoreAccount>;
|
|
267
|
+
/** Delete a store account. Requires either apiSecret or a wallet signer. */
|
|
257
268
|
delete(shortId: string, options?: {
|
|
258
269
|
account?: WalletAccount;
|
|
259
270
|
}): Promise<void>;
|
|
260
271
|
}
|
|
272
|
+
type AgentMallManagedAccounts = AgentMallStoreAccounts;
|
|
261
273
|
|
|
262
274
|
type PurchaseConfig = CreatePurchaseRequest & {
|
|
263
275
|
/** viem Account for MPP payment (from privateKeyToAccount or mppx resolveAccount). */
|
|
@@ -308,4 +320,4 @@ declare const BASE_URL = "https://api.agentmall.sh";
|
|
|
308
320
|
declare const SERVICE_FEE_CENTS = 150;
|
|
309
321
|
declare const SUPPORTED_RETAILERS: readonly ["amazon.com", "walmart.com", "target.com", "bestbuy.com", "homedepot.com", "ebay.com", "lowes.com", "wayfair.com", "acehardware.com", "1800flowers.com", "pokemoncenter.com"];
|
|
310
322
|
|
|
311
|
-
export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type UpdateManagedAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
|
|
323
|
+
export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type CreateRetailerAccountRequest, type CreateStoreAccountRequest, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, type RetailerAccount, type RetailerAccountAuthChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type StoreAccount, type StoreAccountAuthChallenge, type UpdateManagedAccountRequest, type UpdateRetailerAccountRequest, type UpdateStoreAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var AgentMall = class {
|
|
|
68
68
|
purchases;
|
|
69
69
|
payments;
|
|
70
70
|
refunds;
|
|
71
|
+
storeAccounts;
|
|
71
72
|
managedAccounts;
|
|
72
73
|
constructor(config = {}) {
|
|
73
74
|
this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
|
|
@@ -77,7 +78,8 @@ var AgentMall = class {
|
|
|
77
78
|
this.purchases = new AgentMallPurchases(this);
|
|
78
79
|
this.payments = new AgentMallPayments(this);
|
|
79
80
|
this.refunds = new AgentMallRefunds(this);
|
|
80
|
-
this.
|
|
81
|
+
this.storeAccounts = new AgentMallStoreAccounts(this);
|
|
82
|
+
this.managedAccounts = this.storeAccounts;
|
|
81
83
|
}
|
|
82
84
|
/** @internal */
|
|
83
85
|
hasApiSecret() {
|
|
@@ -156,9 +158,11 @@ var AgentMallPurchases = class {
|
|
|
156
158
|
*/
|
|
157
159
|
async create(body) {
|
|
158
160
|
const idempotencyKey = body.idempotency_key ?? createIdempotencyKey();
|
|
161
|
+
const storeAccountId = body.store_account_id ?? body.retailer_credentials_id;
|
|
159
162
|
return this.client.request("POST", "/api/purchases", {
|
|
160
163
|
body: {
|
|
161
164
|
...body,
|
|
165
|
+
...storeAccountId ? { retailer_credentials_id: storeAccountId } : {},
|
|
162
166
|
idempotency_key: idempotencyKey
|
|
163
167
|
},
|
|
164
168
|
headers: {
|
|
@@ -169,20 +173,22 @@ var AgentMallPurchases = class {
|
|
|
169
173
|
/** Get a single purchase by ID using either operator auth or a buyer token. */
|
|
170
174
|
async get(id, options) {
|
|
171
175
|
if (options?.buyerToken) {
|
|
172
|
-
|
|
176
|
+
const purchase3 = await this.client.request("POST", "/api/purchases/status", {
|
|
173
177
|
body: {
|
|
174
178
|
id,
|
|
175
179
|
buyer_token: options.buyerToken
|
|
176
180
|
}
|
|
177
181
|
});
|
|
182
|
+
return normalizePurchase(purchase3);
|
|
178
183
|
}
|
|
179
184
|
if (!this.client.hasApiSecret()) {
|
|
180
185
|
throw new Error("buyerToken or apiSecret is required for this endpoint");
|
|
181
186
|
}
|
|
182
|
-
|
|
187
|
+
const purchase2 = await this.client.request("GET", "/api/purchases", {
|
|
183
188
|
auth: true,
|
|
184
189
|
params: { id }
|
|
185
190
|
});
|
|
191
|
+
return normalizePurchase(purchase2);
|
|
186
192
|
}
|
|
187
193
|
/** List purchases. Requires apiSecret. */
|
|
188
194
|
async list(filters) {
|
|
@@ -191,7 +197,7 @@ var AgentMallPurchases = class {
|
|
|
191
197
|
"/api/purchases",
|
|
192
198
|
{ auth: true, params: filters }
|
|
193
199
|
);
|
|
194
|
-
return result.purchases;
|
|
200
|
+
return result.purchases.map(normalizePurchase);
|
|
195
201
|
}
|
|
196
202
|
};
|
|
197
203
|
var AgentMallPayments = class {
|
|
@@ -263,7 +269,13 @@ var AgentMallRefunds = class {
|
|
|
263
269
|
return result.refunds;
|
|
264
270
|
}
|
|
265
271
|
};
|
|
266
|
-
|
|
272
|
+
function normalizePurchase(purchase2) {
|
|
273
|
+
return {
|
|
274
|
+
...purchase2,
|
|
275
|
+
...purchase2.storeAccountId ? {} : purchase2.retailerCredentialsId ? { storeAccountId: purchase2.retailerCredentialsId } : {}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
var AgentMallStoreAccounts = class {
|
|
267
279
|
constructor(client) {
|
|
268
280
|
this.client = client;
|
|
269
281
|
}
|
|
@@ -286,28 +298,28 @@ var AgentMallManagedAccounts = class {
|
|
|
286
298
|
"X-AgentMall-Auth-Signature": signature
|
|
287
299
|
};
|
|
288
300
|
}
|
|
289
|
-
/** List
|
|
301
|
+
/** List your store accounts. Requires either apiSecret or a wallet signer. */
|
|
290
302
|
async list(options) {
|
|
291
303
|
const result = await this.client.request("GET", "/api/managed-accounts", {
|
|
292
304
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
|
|
293
305
|
});
|
|
294
306
|
return result.credentials;
|
|
295
307
|
}
|
|
296
|
-
/** Create a
|
|
308
|
+
/** Create a store account. Requires either apiSecret or a wallet signer. */
|
|
297
309
|
async create(body, options) {
|
|
298
310
|
return this.client.request("POST", "/api/managed-accounts", {
|
|
299
311
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
300
312
|
body
|
|
301
313
|
});
|
|
302
314
|
}
|
|
303
|
-
/** Update a
|
|
315
|
+
/** Update a store account. Requires either apiSecret or a wallet signer. */
|
|
304
316
|
async update(body, options) {
|
|
305
317
|
return this.client.request("PUT", "/api/managed-accounts", {
|
|
306
318
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|
|
307
319
|
body
|
|
308
320
|
});
|
|
309
321
|
}
|
|
310
|
-
/** Delete a
|
|
322
|
+
/** Delete a store account. Requires either apiSecret or a wallet signer. */
|
|
311
323
|
async delete(shortId, options) {
|
|
312
324
|
await this.client.request("DELETE", "/api/managed-accounts", {
|
|
313
325
|
...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
|