perspectapi-ts-sdk 6.3.0 → 6.4.1
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -16
- package/dist/index.mjs +20 -16
- package/package.json +1 -1
- package/src/v2/client/collections-client.ts +8 -10
- package/src/v2/client/site-users-client.ts +4 -1
- package/src/v2/client/subscriptions-client.ts +7 -0
package/dist/index.d.mts
CHANGED
|
@@ -1967,7 +1967,7 @@ declare class SiteUsersV2Client extends BaseV2Client {
|
|
|
1967
1967
|
/** Update the authenticated user's own fields. */
|
|
1968
1968
|
updateMe(siteName: string, data: V2SiteUserMeUpdateParams): Promise<V2SiteUser>;
|
|
1969
1969
|
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
1970
|
-
getProfile(siteName: string): Promise<V2SiteUserProfile>;
|
|
1970
|
+
getProfile(siteName: string, cachePolicy?: CachePolicy): Promise<V2SiteUserProfile>;
|
|
1971
1971
|
/**
|
|
1972
1972
|
* Set a single profile key. The value is persisted verbatim — callers wanting
|
|
1973
1973
|
* structured data should JSON-stringify their value first.
|
|
@@ -2104,7 +2104,7 @@ declare class WebhooksV2Client extends BaseV2Client {
|
|
|
2104
2104
|
|
|
2105
2105
|
declare class SubscriptionsV2Client extends BaseV2Client {
|
|
2106
2106
|
/** List all subscriptions for the authenticated user. */
|
|
2107
|
-
listMySubscriptions(siteName: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
2107
|
+
listMySubscriptions(siteName: string, cachePolicy?: CachePolicy): Promise<V2List<V2SiteUserSubscription>>;
|
|
2108
2108
|
/** Pause a subscription. */
|
|
2109
2109
|
pauseSubscription(siteName: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
2110
2110
|
/** Resume a paused subscription. */
|
|
@@ -2114,7 +2114,7 @@ declare class SubscriptionsV2Client extends BaseV2Client {
|
|
|
2114
2114
|
/** Change the plan (price) of a subscription. */
|
|
2115
2115
|
changeSubscriptionPlan(siteName: string, subId: string, params: V2SubscriptionChangePlanParams): Promise<V2SiteUserSubscription>;
|
|
2116
2116
|
/** List subscriptions for a specific user (admin). */
|
|
2117
|
-
listUserSubscriptions(siteName: string, userId: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
2117
|
+
listUserSubscriptions(siteName: string, userId: string, cachePolicy?: CachePolicy): Promise<V2List<V2SiteUserSubscription>>;
|
|
2118
2118
|
/** Pause a user's subscription (admin). */
|
|
2119
2119
|
pauseUserSubscription(siteName: string, userId: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
2120
2120
|
/** Resume a user's paused subscription (admin). */
|
package/dist/index.d.ts
CHANGED
|
@@ -1967,7 +1967,7 @@ declare class SiteUsersV2Client extends BaseV2Client {
|
|
|
1967
1967
|
/** Update the authenticated user's own fields. */
|
|
1968
1968
|
updateMe(siteName: string, data: V2SiteUserMeUpdateParams): Promise<V2SiteUser>;
|
|
1969
1969
|
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
1970
|
-
getProfile(siteName: string): Promise<V2SiteUserProfile>;
|
|
1970
|
+
getProfile(siteName: string, cachePolicy?: CachePolicy): Promise<V2SiteUserProfile>;
|
|
1971
1971
|
/**
|
|
1972
1972
|
* Set a single profile key. The value is persisted verbatim — callers wanting
|
|
1973
1973
|
* structured data should JSON-stringify their value first.
|
|
@@ -2104,7 +2104,7 @@ declare class WebhooksV2Client extends BaseV2Client {
|
|
|
2104
2104
|
|
|
2105
2105
|
declare class SubscriptionsV2Client extends BaseV2Client {
|
|
2106
2106
|
/** List all subscriptions for the authenticated user. */
|
|
2107
|
-
listMySubscriptions(siteName: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
2107
|
+
listMySubscriptions(siteName: string, cachePolicy?: CachePolicy): Promise<V2List<V2SiteUserSubscription>>;
|
|
2108
2108
|
/** Pause a subscription. */
|
|
2109
2109
|
pauseSubscription(siteName: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
2110
2110
|
/** Resume a paused subscription. */
|
|
@@ -2114,7 +2114,7 @@ declare class SubscriptionsV2Client extends BaseV2Client {
|
|
|
2114
2114
|
/** Change the plan (price) of a subscription. */
|
|
2115
2115
|
changeSubscriptionPlan(siteName: string, subId: string, params: V2SubscriptionChangePlanParams): Promise<V2SiteUserSubscription>;
|
|
2116
2116
|
/** List subscriptions for a specific user (admin). */
|
|
2117
|
-
listUserSubscriptions(siteName: string, userId: string): Promise<V2List<V2SiteUserSubscription>>;
|
|
2117
|
+
listUserSubscriptions(siteName: string, userId: string, cachePolicy?: CachePolicy): Promise<V2List<V2SiteUserSubscription>>;
|
|
2118
2118
|
/** Pause a user's subscription (admin). */
|
|
2119
2119
|
pauseUserSubscription(siteName: string, userId: string, subId: string, params?: V2SubscriptionPauseParams): Promise<V2SiteUserSubscription>;
|
|
2120
2120
|
/** Resume a user's paused subscription (admin). */
|
package/dist/index.js
CHANGED
|
@@ -903,7 +903,9 @@ var CategoriesV2Client = class extends BaseV2Client {
|
|
|
903
903
|
// src/v2/client/collections-client.ts
|
|
904
904
|
var CollectionsV2Client = class extends BaseV2Client {
|
|
905
905
|
async list(siteName, params) {
|
|
906
|
-
return this.getList(this.sitePath(siteName, "collections"), params
|
|
906
|
+
return this.getList(this.sitePath(siteName, "collections"), params, {
|
|
907
|
+
tags: [`collections:${siteName}`]
|
|
908
|
+
});
|
|
907
909
|
}
|
|
908
910
|
async getCurrent(siteName) {
|
|
909
911
|
const result = await this.getOne(
|
|
@@ -916,26 +918,22 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
916
918
|
}
|
|
917
919
|
async create(siteName, data) {
|
|
918
920
|
const result = await this.post(this.sitePath(siteName, "collections"), data);
|
|
919
|
-
await this.invalidateCache({
|
|
921
|
+
await this.invalidateCache({ tags: [`collections:${siteName}`] });
|
|
920
922
|
return result;
|
|
921
923
|
}
|
|
922
924
|
async update(siteName, id, data) {
|
|
923
925
|
const result = await this.patchOne(this.sitePath(siteName, "collections", id), data);
|
|
924
926
|
await this.invalidateCache({
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
this.sitePath(siteName, "collections", id)
|
|
928
|
-
]
|
|
927
|
+
tags: [`collections:${siteName}`],
|
|
928
|
+
keys: [this.sitePath(siteName, "collections", id)]
|
|
929
929
|
});
|
|
930
930
|
return result;
|
|
931
931
|
}
|
|
932
932
|
async del(siteName, id) {
|
|
933
933
|
const result = await this.deleteOne(this.sitePath(siteName, "collections", id));
|
|
934
934
|
await this.invalidateCache({
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
this.sitePath(siteName, "collections", id)
|
|
938
|
-
]
|
|
935
|
+
tags: [`collections:${siteName}`],
|
|
936
|
+
keys: [this.sitePath(siteName, "collections", id)]
|
|
939
937
|
});
|
|
940
938
|
return result;
|
|
941
939
|
}
|
|
@@ -1040,9 +1038,11 @@ var SiteUsersV2Client = class extends BaseV2Client {
|
|
|
1040
1038
|
);
|
|
1041
1039
|
}
|
|
1042
1040
|
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
1043
|
-
async getProfile(siteName) {
|
|
1041
|
+
async getProfile(siteName, cachePolicy) {
|
|
1044
1042
|
return this.getOne(
|
|
1045
|
-
this.sitePath(siteName, "users", "me/profile")
|
|
1043
|
+
this.sitePath(siteName, "users", "me/profile"),
|
|
1044
|
+
void 0,
|
|
1045
|
+
cachePolicy
|
|
1046
1046
|
);
|
|
1047
1047
|
}
|
|
1048
1048
|
/**
|
|
@@ -1260,9 +1260,11 @@ var WebhooksV2Client = class extends BaseV2Client {
|
|
|
1260
1260
|
var SubscriptionsV2Client = class extends BaseV2Client {
|
|
1261
1261
|
// --- Authenticated "me" endpoints (site-user JWT) ---
|
|
1262
1262
|
/** List all subscriptions for the authenticated user. */
|
|
1263
|
-
async listMySubscriptions(siteName) {
|
|
1263
|
+
async listMySubscriptions(siteName, cachePolicy) {
|
|
1264
1264
|
return this.getList(
|
|
1265
|
-
this.sitePath(siteName, "users", "me/subscriptions")
|
|
1265
|
+
this.sitePath(siteName, "users", "me/subscriptions"),
|
|
1266
|
+
void 0,
|
|
1267
|
+
cachePolicy
|
|
1266
1268
|
);
|
|
1267
1269
|
}
|
|
1268
1270
|
/** Pause a subscription. */
|
|
@@ -1294,9 +1296,11 @@ var SubscriptionsV2Client = class extends BaseV2Client {
|
|
|
1294
1296
|
}
|
|
1295
1297
|
// --- Admin endpoints (API key) ---
|
|
1296
1298
|
/** List subscriptions for a specific user (admin). */
|
|
1297
|
-
async listUserSubscriptions(siteName, userId) {
|
|
1299
|
+
async listUserSubscriptions(siteName, userId, cachePolicy) {
|
|
1298
1300
|
return this.getList(
|
|
1299
|
-
this.sitePath(siteName, "users", `${userId}/subscriptions`)
|
|
1301
|
+
this.sitePath(siteName, "users", `${userId}/subscriptions`),
|
|
1302
|
+
void 0,
|
|
1303
|
+
cachePolicy
|
|
1300
1304
|
);
|
|
1301
1305
|
}
|
|
1302
1306
|
/** Pause a user's subscription (admin). */
|
package/dist/index.mjs
CHANGED
|
@@ -827,7 +827,9 @@ var CategoriesV2Client = class extends BaseV2Client {
|
|
|
827
827
|
// src/v2/client/collections-client.ts
|
|
828
828
|
var CollectionsV2Client = class extends BaseV2Client {
|
|
829
829
|
async list(siteName, params) {
|
|
830
|
-
return this.getList(this.sitePath(siteName, "collections"), params
|
|
830
|
+
return this.getList(this.sitePath(siteName, "collections"), params, {
|
|
831
|
+
tags: [`collections:${siteName}`]
|
|
832
|
+
});
|
|
831
833
|
}
|
|
832
834
|
async getCurrent(siteName) {
|
|
833
835
|
const result = await this.getOne(
|
|
@@ -840,26 +842,22 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
840
842
|
}
|
|
841
843
|
async create(siteName, data) {
|
|
842
844
|
const result = await this.post(this.sitePath(siteName, "collections"), data);
|
|
843
|
-
await this.invalidateCache({
|
|
845
|
+
await this.invalidateCache({ tags: [`collections:${siteName}`] });
|
|
844
846
|
return result;
|
|
845
847
|
}
|
|
846
848
|
async update(siteName, id, data) {
|
|
847
849
|
const result = await this.patchOne(this.sitePath(siteName, "collections", id), data);
|
|
848
850
|
await this.invalidateCache({
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
this.sitePath(siteName, "collections", id)
|
|
852
|
-
]
|
|
851
|
+
tags: [`collections:${siteName}`],
|
|
852
|
+
keys: [this.sitePath(siteName, "collections", id)]
|
|
853
853
|
});
|
|
854
854
|
return result;
|
|
855
855
|
}
|
|
856
856
|
async del(siteName, id) {
|
|
857
857
|
const result = await this.deleteOne(this.sitePath(siteName, "collections", id));
|
|
858
858
|
await this.invalidateCache({
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
this.sitePath(siteName, "collections", id)
|
|
862
|
-
]
|
|
859
|
+
tags: [`collections:${siteName}`],
|
|
860
|
+
keys: [this.sitePath(siteName, "collections", id)]
|
|
863
861
|
});
|
|
864
862
|
return result;
|
|
865
863
|
}
|
|
@@ -964,9 +962,11 @@ var SiteUsersV2Client = class extends BaseV2Client {
|
|
|
964
962
|
);
|
|
965
963
|
}
|
|
966
964
|
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
967
|
-
async getProfile(siteName) {
|
|
965
|
+
async getProfile(siteName, cachePolicy) {
|
|
968
966
|
return this.getOne(
|
|
969
|
-
this.sitePath(siteName, "users", "me/profile")
|
|
967
|
+
this.sitePath(siteName, "users", "me/profile"),
|
|
968
|
+
void 0,
|
|
969
|
+
cachePolicy
|
|
970
970
|
);
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
@@ -1184,9 +1184,11 @@ var WebhooksV2Client = class extends BaseV2Client {
|
|
|
1184
1184
|
var SubscriptionsV2Client = class extends BaseV2Client {
|
|
1185
1185
|
// --- Authenticated "me" endpoints (site-user JWT) ---
|
|
1186
1186
|
/** List all subscriptions for the authenticated user. */
|
|
1187
|
-
async listMySubscriptions(siteName) {
|
|
1187
|
+
async listMySubscriptions(siteName, cachePolicy) {
|
|
1188
1188
|
return this.getList(
|
|
1189
|
-
this.sitePath(siteName, "users", "me/subscriptions")
|
|
1189
|
+
this.sitePath(siteName, "users", "me/subscriptions"),
|
|
1190
|
+
void 0,
|
|
1191
|
+
cachePolicy
|
|
1190
1192
|
);
|
|
1191
1193
|
}
|
|
1192
1194
|
/** Pause a subscription. */
|
|
@@ -1218,9 +1220,11 @@ var SubscriptionsV2Client = class extends BaseV2Client {
|
|
|
1218
1220
|
}
|
|
1219
1221
|
// --- Admin endpoints (API key) ---
|
|
1220
1222
|
/** List subscriptions for a specific user (admin). */
|
|
1221
|
-
async listUserSubscriptions(siteName, userId) {
|
|
1223
|
+
async listUserSubscriptions(siteName, userId, cachePolicy) {
|
|
1222
1224
|
return this.getList(
|
|
1223
|
-
this.sitePath(siteName, "users", `${userId}/subscriptions`)
|
|
1225
|
+
this.sitePath(siteName, "users", `${userId}/subscriptions`),
|
|
1226
|
+
void 0,
|
|
1227
|
+
cachePolicy
|
|
1224
1228
|
);
|
|
1225
1229
|
}
|
|
1226
1230
|
/** Pause a user's subscription (admin). */
|
package/package.json
CHANGED
|
@@ -11,7 +11,9 @@ import type {
|
|
|
11
11
|
export class CollectionsV2Client extends BaseV2Client {
|
|
12
12
|
|
|
13
13
|
async list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Collection>> {
|
|
14
|
-
return this.getList<V2Collection>(this.sitePath(siteName, 'collections'), params
|
|
14
|
+
return this.getList<V2Collection>(this.sitePath(siteName, 'collections'), params, {
|
|
15
|
+
tags: [`collections:${siteName}`],
|
|
16
|
+
});
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
async getCurrent(siteName: string): Promise<V2Collection | null> {
|
|
@@ -27,17 +29,15 @@ export class CollectionsV2Client extends BaseV2Client {
|
|
|
27
29
|
|
|
28
30
|
async create(siteName: string, data: V2CollectionCreateParams): Promise<V2Collection> {
|
|
29
31
|
const result = await this.post<V2Collection>(this.sitePath(siteName, 'collections'), data);
|
|
30
|
-
await this.invalidateCache({
|
|
32
|
+
await this.invalidateCache({ tags: [`collections:${siteName}`] });
|
|
31
33
|
return result;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
async update(siteName: string, id: string, data: V2CollectionUpdateParams): Promise<V2Collection> {
|
|
35
37
|
const result = await this.patchOne<V2Collection>(this.sitePath(siteName, 'collections', id), data);
|
|
36
38
|
await this.invalidateCache({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.sitePath(siteName, 'collections', id),
|
|
40
|
-
],
|
|
39
|
+
tags: [`collections:${siteName}`],
|
|
40
|
+
keys: [this.sitePath(siteName, 'collections', id)],
|
|
41
41
|
});
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
@@ -45,10 +45,8 @@ export class CollectionsV2Client extends BaseV2Client {
|
|
|
45
45
|
async del(siteName: string, id: string): Promise<V2Deleted> {
|
|
46
46
|
const result = await this.deleteOne(this.sitePath(siteName, 'collections', id));
|
|
47
47
|
await this.invalidateCache({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.sitePath(siteName, 'collections', id),
|
|
51
|
-
],
|
|
48
|
+
tags: [`collections:${siteName}`],
|
|
49
|
+
keys: [this.sitePath(siteName, 'collections', id)],
|
|
52
50
|
});
|
|
53
51
|
return result;
|
|
54
52
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { BaseV2Client } from './base-v2-client';
|
|
12
|
+
import type { CachePolicy } from '../../cache/types';
|
|
12
13
|
import type {
|
|
13
14
|
V2SiteUser,
|
|
14
15
|
V2SiteUserUpdateParams,
|
|
@@ -91,9 +92,11 @@ export class SiteUsersV2Client extends BaseV2Client {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
/** Fetch the profile KV map as a dedicated `site_user_profile` envelope. */
|
|
94
|
-
async getProfile(siteName: string): Promise<V2SiteUserProfile> {
|
|
95
|
+
async getProfile(siteName: string, cachePolicy?: CachePolicy): Promise<V2SiteUserProfile> {
|
|
95
96
|
return this.getOne<V2SiteUserProfile>(
|
|
96
97
|
this.sitePath(siteName, 'users', 'me/profile'),
|
|
98
|
+
undefined,
|
|
99
|
+
cachePolicy,
|
|
97
100
|
);
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { BaseV2Client } from './base-v2-client';
|
|
10
|
+
import type { CachePolicy } from '../../cache/types';
|
|
10
11
|
import type {
|
|
11
12
|
V2SiteUserSubscription,
|
|
12
13
|
V2SubscriptionPauseParams,
|
|
@@ -23,9 +24,12 @@ export class SubscriptionsV2Client extends BaseV2Client {
|
|
|
23
24
|
/** List all subscriptions for the authenticated user. */
|
|
24
25
|
async listMySubscriptions(
|
|
25
26
|
siteName: string,
|
|
27
|
+
cachePolicy?: CachePolicy,
|
|
26
28
|
): Promise<V2List<V2SiteUserSubscription>> {
|
|
27
29
|
return this.getList<V2SiteUserSubscription>(
|
|
28
30
|
this.sitePath(siteName, 'users', 'me/subscriptions'),
|
|
31
|
+
undefined,
|
|
32
|
+
cachePolicy,
|
|
29
33
|
);
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -81,9 +85,12 @@ export class SubscriptionsV2Client extends BaseV2Client {
|
|
|
81
85
|
async listUserSubscriptions(
|
|
82
86
|
siteName: string,
|
|
83
87
|
userId: string,
|
|
88
|
+
cachePolicy?: CachePolicy,
|
|
84
89
|
): Promise<V2List<V2SiteUserSubscription>> {
|
|
85
90
|
return this.getList<V2SiteUserSubscription>(
|
|
86
91
|
this.sitePath(siteName, 'users', `${userId}/subscriptions`),
|
|
92
|
+
undefined,
|
|
93
|
+
cachePolicy,
|
|
87
94
|
);
|
|
88
95
|
}
|
|
89
96
|
|