@amityco/ts-sdk 7.32.1-330f4a7d.0 → 7.32.1-6d2e2c1e.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/cache/api/queryCache.d.ts.map +1 -1
- package/dist/cache/api/tests/queryCache.test.d.ts +2 -0
- package/dist/cache/api/tests/queryCache.test.d.ts.map +1 -0
- package/dist/index.cjs.js +13 -4
- package/dist/index.esm.js +13 -4
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/dist/client/api/tests/setupBillableRequests.test.d.ts +0 -2
- package/dist/client/api/tests/setupBillableRequests.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EAatB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryCache.test.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/tests/queryCache.test.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1184,6 +1184,17 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1184
1184
|
return true;
|
|
1185
1185
|
};
|
|
1186
1186
|
|
|
1187
|
+
const isPrimitiveKey = (key) => Array.isArray(key) &&
|
|
1188
|
+
key.length > 0 &&
|
|
1189
|
+
key.every(segment => typeof segment === 'string' || typeof segment === 'number');
|
|
1190
|
+
const createMatcher = (key) => {
|
|
1191
|
+
if (isPrimitiveKey(key)) {
|
|
1192
|
+
const encoded = encodeKey(key);
|
|
1193
|
+
const prefix = `${encoded.slice(0, -1)},`;
|
|
1194
|
+
return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
|
|
1195
|
+
}
|
|
1196
|
+
return encodedKey => partialMatch(key, decodeKey(encodedKey));
|
|
1197
|
+
};
|
|
1187
1198
|
/**
|
|
1188
1199
|
* ```js
|
|
1189
1200
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1204,11 +1215,9 @@ const queryCache = (key) => {
|
|
|
1204
1215
|
if (!cache)
|
|
1205
1216
|
return;
|
|
1206
1217
|
log('cache/api/queryCache', { key });
|
|
1218
|
+
const matches = createMatcher(key);
|
|
1207
1219
|
return Object.keys(cache.data)
|
|
1208
|
-
.filter(
|
|
1209
|
-
const decodedKey = decodeKey(stringKey);
|
|
1210
|
-
return partialMatch(key, decodedKey);
|
|
1211
|
-
})
|
|
1220
|
+
.filter(matches)
|
|
1212
1221
|
.map(stringKey => cache.data[stringKey]);
|
|
1213
1222
|
};
|
|
1214
1223
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1168,6 +1168,17 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1168
1168
|
return true;
|
|
1169
1169
|
};
|
|
1170
1170
|
|
|
1171
|
+
const isPrimitiveKey = (key) => Array.isArray(key) &&
|
|
1172
|
+
key.length > 0 &&
|
|
1173
|
+
key.every(segment => typeof segment === 'string' || typeof segment === 'number');
|
|
1174
|
+
const createMatcher = (key) => {
|
|
1175
|
+
if (isPrimitiveKey(key)) {
|
|
1176
|
+
const encoded = encodeKey(key);
|
|
1177
|
+
const prefix = `${encoded.slice(0, -1)},`;
|
|
1178
|
+
return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
|
|
1179
|
+
}
|
|
1180
|
+
return encodedKey => partialMatch(key, decodeKey(encodedKey));
|
|
1181
|
+
};
|
|
1171
1182
|
/**
|
|
1172
1183
|
* ```js
|
|
1173
1184
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1188,11 +1199,9 @@ const queryCache = (key) => {
|
|
|
1188
1199
|
if (!cache)
|
|
1189
1200
|
return;
|
|
1190
1201
|
log('cache/api/queryCache', { key });
|
|
1202
|
+
const matches = createMatcher(key);
|
|
1191
1203
|
return Object.keys(cache.data)
|
|
1192
|
-
.filter(
|
|
1193
|
-
const decodedKey = decodeKey(stringKey);
|
|
1194
|
-
return partialMatch(key, decodedKey);
|
|
1195
|
-
})
|
|
1204
|
+
.filter(matches)
|
|
1196
1205
|
.map(stringKey => cache.data[stringKey]);
|
|
1197
1206
|
};
|
|
1198
1207
|
|