@joai/sdk 0.20.0 → 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/dist/index.d.mts +21 -4
- package/dist/index.mjs +52 -45
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2312,6 +2312,7 @@ type LoyaltyReward = {
|
|
|
2312
2312
|
pointsCost: number;
|
|
2313
2313
|
config: Record<string, JsonValue> | null;
|
|
2314
2314
|
sortOrder: number;
|
|
2315
|
+
createdAt: string;
|
|
2315
2316
|
};
|
|
2316
2317
|
type LoyaltyTier = {
|
|
2317
2318
|
id: string;
|
|
@@ -2392,10 +2393,21 @@ type Pass = {
|
|
|
2392
2393
|
team: Team;
|
|
2393
2394
|
points: number;
|
|
2394
2395
|
tier: string | null;
|
|
2395
|
-
|
|
2396
|
+
benefit: {
|
|
2397
|
+
pointName: string | null;
|
|
2398
|
+
earning: {
|
|
2399
|
+
type: 'per_visit' | 'per_spend' | 'per_item' | 'per_category';
|
|
2400
|
+
value: number;
|
|
2401
|
+
minimumSpendCents: number | null;
|
|
2402
|
+
currency: string | null;
|
|
2403
|
+
};
|
|
2404
|
+
reward: {
|
|
2405
|
+
name: string;
|
|
2406
|
+
pointsCost: number;
|
|
2407
|
+
};
|
|
2408
|
+
} | null;
|
|
2396
2409
|
};
|
|
2397
2410
|
type LoyaltyMember = {
|
|
2398
|
-
id: string;
|
|
2399
2411
|
contactId: string;
|
|
2400
2412
|
contactName: string;
|
|
2401
2413
|
points: number;
|
|
@@ -3244,7 +3256,9 @@ declare class LinksResource {
|
|
|
3244
3256
|
declare class LoyaltyResource {
|
|
3245
3257
|
private readonly http;
|
|
3246
3258
|
constructor(http: IHttpService);
|
|
3247
|
-
getProgram(
|
|
3259
|
+
getProgram(params?: {
|
|
3260
|
+
team?: string;
|
|
3261
|
+
}): Promise<IAppResponse<LoyaltyProgram>>;
|
|
3248
3262
|
updateProgram(data: {
|
|
3249
3263
|
name?: string;
|
|
3250
3264
|
settings?: ProgramSettings;
|
|
@@ -3317,7 +3331,7 @@ declare class LoyaltyResource {
|
|
|
3317
3331
|
redeem(contactId: string, rewardId: string): Promise<IAppResponse<RedeemResponse>>;
|
|
3318
3332
|
adjustPoints(contactId: string, points: number, reason: string): Promise<IAppResponse<LoyaltyAccount>>;
|
|
3319
3333
|
getTransactionHistory(contactId: string): Promise<IAppResponse<LoyaltyTransaction[]>>;
|
|
3320
|
-
listMembers(): Promise<IAppResponse<LoyaltyMember
|
|
3334
|
+
listMembers(): Promise<IAppResponse<PaginatedResponse<LoyaltyMember>>>;
|
|
3321
3335
|
getPass(contact: string): Promise<IAppResponse<Pass>>;
|
|
3322
3336
|
generatePass(contact: string, platform: 'apple' | 'google'): Promise<IAppResponse<{
|
|
3323
3337
|
url: string | null;
|
|
@@ -4177,6 +4191,7 @@ declare class CachedHttpService implements IHttpService {
|
|
|
4177
4191
|
private cache;
|
|
4178
4192
|
private ttlMap;
|
|
4179
4193
|
private defaultTtl;
|
|
4194
|
+
private cacheVersion;
|
|
4180
4195
|
onNetworkError: (error: Error) => void;
|
|
4181
4196
|
onUnauthorized: (response: IAppResponse<JsonValue>) => void;
|
|
4182
4197
|
onSuccessfulResponse: (response: IAppResponse<JsonValue>) => void;
|
|
@@ -4189,6 +4204,8 @@ declare class CachedHttpService implements IHttpService {
|
|
|
4189
4204
|
put<T>(url: string, data?: JsonValue | FormData, options?: IRequestOptions): Promise<IAppResponse<T>>;
|
|
4190
4205
|
patch<T>(url: string, data?: JsonValue | FormData, options?: IRequestOptions): Promise<IAppResponse<T>>;
|
|
4191
4206
|
delete<T>(url: string, options?: IRequestOptions): Promise<IAppResponse<T>>;
|
|
4207
|
+
private mutate;
|
|
4208
|
+
private bust;
|
|
4192
4209
|
}
|
|
4193
4210
|
//#endregion
|
|
4194
4211
|
//#region src/resources/distribution.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -130,7 +130,7 @@ var AgentsResource = class {
|
|
|
130
130
|
return this.http.post("agents", params);
|
|
131
131
|
}
|
|
132
132
|
update(uuid, name, description, avatar) {
|
|
133
|
-
return this.http.
|
|
133
|
+
return this.http.patch(`agents/${uuid}`, {
|
|
134
134
|
name,
|
|
135
135
|
description,
|
|
136
136
|
avatar
|
|
@@ -149,7 +149,7 @@ var AgentsResource = class {
|
|
|
149
149
|
return this.http.put(`agents/${uuid}/settings/${key}`, { value });
|
|
150
150
|
}
|
|
151
151
|
updateMeta(uuid, key, value) {
|
|
152
|
-
return this.http.put(`agents/${uuid}/
|
|
152
|
+
return this.http.put(`agents/${uuid}/settings/${key}`, { value });
|
|
153
153
|
}
|
|
154
154
|
publish(uuid) {
|
|
155
155
|
return this.http.post(`agents/${uuid}/publish`, {});
|
|
@@ -540,18 +540,18 @@ var BillingResource = class {
|
|
|
540
540
|
return this.http.get(`billing/plans?type=${type}`);
|
|
541
541
|
}
|
|
542
542
|
checkoutProduct(id) {
|
|
543
|
-
return this.http.get(`
|
|
543
|
+
return this.http.get(`products/${id}`);
|
|
544
544
|
}
|
|
545
545
|
orders(team, page = 1, contactId) {
|
|
546
|
-
let params = `
|
|
546
|
+
let params = `orders?page=${page}`;
|
|
547
547
|
if (contactId) params += `&contactId=${encodeURIComponent(contactId)}`;
|
|
548
548
|
return this.http.get(params);
|
|
549
549
|
}
|
|
550
550
|
payOrder(id, provider) {
|
|
551
|
-
return this.http.post(`
|
|
551
|
+
return this.http.post(`orders/${id}/pay`, { provider });
|
|
552
552
|
}
|
|
553
553
|
deleteOrder(id) {
|
|
554
|
-
return this.http.delete(`
|
|
554
|
+
return this.http.delete(`orders/${id}`);
|
|
555
555
|
}
|
|
556
556
|
paymentAccount(team, provider) {
|
|
557
557
|
return this.http.get(`payment-accounts/${provider}`, { headers: { "X-Team": team } });
|
|
@@ -619,8 +619,7 @@ var BlueprintsResource = class {
|
|
|
619
619
|
return this.http.post("blueprints", data);
|
|
620
620
|
}
|
|
621
621
|
assemble(blueprint, team, name) {
|
|
622
|
-
return this.http.post(
|
|
623
|
-
blueprint,
|
|
622
|
+
return this.http.post(`blueprints/${blueprint}/assemble`, {
|
|
624
623
|
team,
|
|
625
624
|
name
|
|
626
625
|
});
|
|
@@ -856,7 +855,7 @@ var DocumentsResource = class {
|
|
|
856
855
|
});
|
|
857
856
|
}
|
|
858
857
|
uploadFile(agentUuid, name, document) {
|
|
859
|
-
return this.http.post("documents", {
|
|
858
|
+
return this.http.post("documents/upload", {
|
|
860
859
|
agent: agentUuid,
|
|
861
860
|
name,
|
|
862
861
|
document
|
|
@@ -1115,8 +1114,9 @@ var LoyaltyResource = class {
|
|
|
1115
1114
|
constructor(http) {
|
|
1116
1115
|
this.http = http;
|
|
1117
1116
|
}
|
|
1118
|
-
getProgram() {
|
|
1119
|
-
|
|
1117
|
+
getProgram(params) {
|
|
1118
|
+
const query = params?.team ? `?team=${encodeURIComponent(params.team)}` : "";
|
|
1119
|
+
return this.http.get(`loyalty/program${query}`);
|
|
1120
1120
|
}
|
|
1121
1121
|
updateProgram(data) {
|
|
1122
1122
|
return this.http.patch("loyalty/program", data);
|
|
@@ -1202,7 +1202,7 @@ var StoreResource = class {
|
|
|
1202
1202
|
this.http = http;
|
|
1203
1203
|
}
|
|
1204
1204
|
async get(locale = "en") {
|
|
1205
|
-
const res = await this.http.get(`
|
|
1205
|
+
const res = await this.http.get(`billing/catalog?locale=${locale}`);
|
|
1206
1206
|
if (!res.ok || !res.data) return {
|
|
1207
1207
|
blueprints: [],
|
|
1208
1208
|
skills: [],
|
|
@@ -1248,10 +1248,10 @@ var StoreResource = class {
|
|
|
1248
1248
|
return this.http.get(`billing/commissions?team=${encodeURIComponent(teamSlug)}`);
|
|
1249
1249
|
}
|
|
1250
1250
|
priceTiers() {
|
|
1251
|
-
return this.http.get("
|
|
1251
|
+
return this.http.get("billing/price-tiers");
|
|
1252
1252
|
}
|
|
1253
1253
|
purchase(entityType, entityId, paymentMethod = "balance") {
|
|
1254
|
-
return this.http.post("
|
|
1254
|
+
return this.http.post("billing/purchase", {
|
|
1255
1255
|
entityType,
|
|
1256
1256
|
entityId,
|
|
1257
1257
|
paymentMethod
|
|
@@ -1355,7 +1355,7 @@ var MemoriesResource = class {
|
|
|
1355
1355
|
return this.http.get(`memories${qs ? "?" + qs : ""}`);
|
|
1356
1356
|
}
|
|
1357
1357
|
add(payload) {
|
|
1358
|
-
return this.http.post(
|
|
1358
|
+
return this.http.post(`agents/${payload.agentId}/memories`, payload);
|
|
1359
1359
|
}
|
|
1360
1360
|
update(id, data) {
|
|
1361
1361
|
return this.http.put(`memories/${id}`, data);
|
|
@@ -1516,41 +1516,41 @@ var ProductsResource = class {
|
|
|
1516
1516
|
this.http = http;
|
|
1517
1517
|
}
|
|
1518
1518
|
list() {
|
|
1519
|
-
return this.http.get("
|
|
1519
|
+
return this.http.get("products");
|
|
1520
1520
|
}
|
|
1521
1521
|
get(id) {
|
|
1522
|
-
return this.http.get(`
|
|
1522
|
+
return this.http.get(`products/${id}`);
|
|
1523
1523
|
}
|
|
1524
1524
|
create(data, teamSlug) {
|
|
1525
|
-
const url = teamSlug ? `
|
|
1525
|
+
const url = teamSlug ? `products?team=${teamSlug}` : "products";
|
|
1526
1526
|
return this.http.post(url, data);
|
|
1527
1527
|
}
|
|
1528
1528
|
update(id, data) {
|
|
1529
|
-
return this.http.put(`
|
|
1529
|
+
return this.http.put(`products/${id}`, data);
|
|
1530
1530
|
}
|
|
1531
1531
|
delete(id) {
|
|
1532
|
-
return this.http.delete(`
|
|
1532
|
+
return this.http.delete(`products/${id}`);
|
|
1533
1533
|
}
|
|
1534
1534
|
createVariation(productSlug, data) {
|
|
1535
|
-
return this.http.post(`
|
|
1535
|
+
return this.http.post(`products/${productSlug}/variations`, data);
|
|
1536
1536
|
}
|
|
1537
1537
|
updateVariation(variationId, data) {
|
|
1538
|
-
return this.http.put(`
|
|
1538
|
+
return this.http.put(`products/variations/${variationId}`, data);
|
|
1539
1539
|
}
|
|
1540
1540
|
sortVariations(ids) {
|
|
1541
|
-
return this.http.post("
|
|
1541
|
+
return this.http.post("products/variations/sort", { ids });
|
|
1542
1542
|
}
|
|
1543
1543
|
deleteVariation(variationId) {
|
|
1544
|
-
return this.http.delete(`
|
|
1544
|
+
return this.http.delete(`products/variations/${variationId}`);
|
|
1545
1545
|
}
|
|
1546
1546
|
createRelation(productSlug, data) {
|
|
1547
|
-
return this.http.post(`
|
|
1547
|
+
return this.http.post(`products/${productSlug}/relations`, data);
|
|
1548
1548
|
}
|
|
1549
1549
|
deleteRelation(productSlug, relatedProductId) {
|
|
1550
|
-
return this.http.delete(`
|
|
1550
|
+
return this.http.delete(`products/${productSlug}/relations?relatedProductId=${relatedProductId}`);
|
|
1551
1551
|
}
|
|
1552
1552
|
updateVolumePrices(productSlug, data) {
|
|
1553
|
-
return this.http.put(`
|
|
1553
|
+
return this.http.put(`products/${productSlug}/volume-prices`, { prices: data });
|
|
1554
1554
|
}
|
|
1555
1555
|
};
|
|
1556
1556
|
//#endregion
|
|
@@ -1603,7 +1603,7 @@ var RemindersResource = class {
|
|
|
1603
1603
|
return this.http.get("reminders");
|
|
1604
1604
|
}
|
|
1605
1605
|
add(payload) {
|
|
1606
|
-
return this.http.post(
|
|
1606
|
+
return this.http.post(`agents/${payload.agentId}/reminders`, payload);
|
|
1607
1607
|
}
|
|
1608
1608
|
delete(id) {
|
|
1609
1609
|
return this.http.delete(`reminders/${id}`);
|
|
@@ -1781,10 +1781,10 @@ var KvResource = class {
|
|
|
1781
1781
|
this.http = http;
|
|
1782
1782
|
}
|
|
1783
1783
|
list() {
|
|
1784
|
-
return this.http.get("
|
|
1784
|
+
return this.http.get("kv");
|
|
1785
1785
|
}
|
|
1786
1786
|
create(payload) {
|
|
1787
|
-
return this.http.post("
|
|
1787
|
+
return this.http.post("kv", payload);
|
|
1788
1788
|
}
|
|
1789
1789
|
entries(params) {
|
|
1790
1790
|
const query = new URLSearchParams();
|
|
@@ -2224,7 +2224,7 @@ var WarpsResource = class {
|
|
|
2224
2224
|
return this.http.post("warps", data);
|
|
2225
2225
|
}
|
|
2226
2226
|
update(identifier, data) {
|
|
2227
|
-
return this.http.
|
|
2227
|
+
return this.http.patch(`warps/${identifier}`, data);
|
|
2228
2228
|
}
|
|
2229
2229
|
destroy(identifier) {
|
|
2230
2230
|
return this.http.delete(`warps/${identifier}`);
|
|
@@ -2314,7 +2314,7 @@ var WebhooksResource = class {
|
|
|
2314
2314
|
});
|
|
2315
2315
|
}
|
|
2316
2316
|
update(agentId, webhookId, updates) {
|
|
2317
|
-
return this.http.
|
|
2317
|
+
return this.http.patch(`agents/${agentId}/webhooks/${webhookId}`, updates);
|
|
2318
2318
|
}
|
|
2319
2319
|
delete(agentId, webhookId) {
|
|
2320
2320
|
return this.http.delete(`agents/${agentId}/webhooks/${webhookId}`);
|
|
@@ -2394,6 +2394,7 @@ var CachedHttpService = class {
|
|
|
2394
2394
|
constructor(inner, overrides, defaultTtl) {
|
|
2395
2395
|
this.inner = inner;
|
|
2396
2396
|
this.cache = new MemoryCache();
|
|
2397
|
+
this.cacheVersion = 0;
|
|
2397
2398
|
this.onNetworkError = () => {};
|
|
2398
2399
|
this.onUnauthorized = () => {};
|
|
2399
2400
|
this.onSuccessfulResponse = () => {};
|
|
@@ -2408,34 +2409,40 @@ var CachedHttpService = class {
|
|
|
2408
2409
|
this.defaultTtl = defaultTtl ?? DEFAULT_TTL;
|
|
2409
2410
|
}
|
|
2410
2411
|
clearCache() {
|
|
2412
|
+
this.cacheVersion++;
|
|
2411
2413
|
this.cache.clear();
|
|
2412
2414
|
}
|
|
2413
2415
|
async get(url, options) {
|
|
2414
2416
|
const cached = this.cache.get(url);
|
|
2415
2417
|
if (cached !== void 0) return cached;
|
|
2418
|
+
const cacheVersion = this.cacheVersion;
|
|
2416
2419
|
const response = await this.inner.get(url, options);
|
|
2417
|
-
if (response.ok) this.cache.set(url, response, getTtl(url, this.ttlMap, this.defaultTtl));
|
|
2420
|
+
if (response.ok && cacheVersion === this.cacheVersion) this.cache.set(url, response, getTtl(url, this.ttlMap, this.defaultTtl));
|
|
2418
2421
|
return response;
|
|
2419
2422
|
}
|
|
2420
2423
|
async post(url, data, options) {
|
|
2421
|
-
|
|
2422
|
-
this.cache.bust(getUrlPrefix(url));
|
|
2423
|
-
return response;
|
|
2424
|
+
return this.mutate(getUrlPrefix(url), () => this.inner.post(url, data, options));
|
|
2424
2425
|
}
|
|
2425
2426
|
async put(url, data, options) {
|
|
2426
|
-
|
|
2427
|
-
this.cache.bust(getUrlPrefix(url));
|
|
2428
|
-
return response;
|
|
2427
|
+
return this.mutate(getUrlPrefix(url), () => this.inner.put(url, data, options));
|
|
2429
2428
|
}
|
|
2430
2429
|
async patch(url, data, options) {
|
|
2431
|
-
|
|
2432
|
-
this.cache.bust(getUrlPrefix(url));
|
|
2433
|
-
return response;
|
|
2430
|
+
return this.mutate(getUrlPrefix(url), () => this.inner.patch(url, data, options));
|
|
2434
2431
|
}
|
|
2435
2432
|
async delete(url, options) {
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2433
|
+
return this.mutate(getUrlPrefix(url), () => this.inner.delete(url, options));
|
|
2434
|
+
}
|
|
2435
|
+
async mutate(prefix, request) {
|
|
2436
|
+
this.bust(prefix);
|
|
2437
|
+
try {
|
|
2438
|
+
return await request();
|
|
2439
|
+
} finally {
|
|
2440
|
+
this.bust(prefix);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
bust(prefix) {
|
|
2444
|
+
this.cacheVersion++;
|
|
2445
|
+
this.cache.bust(prefix);
|
|
2439
2446
|
}
|
|
2440
2447
|
};
|
|
2441
2448
|
//#endregion
|