@amityco/ts-sdk 6.9.0 → 6.9.1-616d86a.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/core/events.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/index.cjs.js +33 -19
- package/dist/index.esm.js +33 -19
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/core/events.ts +6 -1
- package/src/core/query/filtering.ts +24 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AA+BA,cAAc;AACd,eAAO,MAAM,kBAAkB,4CAE9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,MAAM,MAAM,CAAC,SAAS,CAAC,SAM5F,CAAC;AAEF,eAAO,MAAM,eAAe,eACd,MAAM,MAAM,CAAC,MAAM,CAAC,WACvB,MAAM,MAAM,CAAC,SAAS,CAAC,SAajC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,8pEACxB,MAAM,MAAM,aACT,MAAM,oDAGhB,MAAM,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AA+BA,cAAc;AACd,eAAO,MAAM,kBAAkB,4CAE9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,MAAM,MAAM,CAAC,SAAS,CAAC,SAM5F,CAAC;AAEF,eAAO,MAAM,eAAe,eACd,MAAM,MAAM,CAAC,MAAM,CAAC,WACvB,MAAM,MAAM,CAAC,SAAS,CAAC,SAajC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,8pEACxB,MAAM,MAAM,aACT,MAAM,oDAGhB,MAAM,YAsBR,CAAC;AAEF,eAAO,MAAM,2BAA2B,8pEAC9B,MAAM,MAAM,aACT,MAAM,yBAEJ,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAC5C,MAAM,YAQR,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,isEAKrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAII,CAAC;AAEjB,eAAO,MAAM,8BAA8B,sEAGlC,GAAG,QASI,CAAC;AAEjB,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC;AAE/F,eAAO,MAAM,wBAAwB,6EAG3B,GAAG,EAAE,GAAG,SAAS,QAQ1B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,eACxB,MAAM,OAAO,EAAE,cACf,MAAM,qBAAqB,CAAC,YAAY,CAAC,UAC7C,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAC5C,MAAM,OAAO,EAyBf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,yDAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,QAgBjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,2DAE1B,MAAM,uBAAuB,CAAC,YAAY,CAAC,UAC/C,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QA0BhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,0DAErB,MAAM,kBAAkB,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAII,CAAC;AAEjB,eAAO,MAAM,8BAA8B,sEAGlC,GAAG,QASI,CAAC;AAEjB,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC;AAE/F,eAAO,MAAM,wBAAwB,6EAG3B,GAAG,EAAE,GAAG,SAAS,QAQ1B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,eACxB,MAAM,OAAO,EAAE,cACf,MAAM,qBAAqB,CAAC,YAAY,CAAC,UAC7C,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAC5C,MAAM,OAAO,EAyBf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,yDAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,QAgBjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,2DAE1B,MAAM,uBAAuB,CAAC,YAAY,CAAC,UAC/C,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QA0BhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,0DAErB,MAAM,kBAAkB,CAAC,WAAW,CAAC,QAgCjD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;YAAwB,MAAM,IAAI,CAAC,QAAQ,CAAC;;gCAE7D,MAAM,QAanB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1192,26 +1192,35 @@ const filterByCommunityMembership = (collection, membership, userId) => {
|
|
|
1192
1192
|
* @hidden
|
|
1193
1193
|
*/
|
|
1194
1194
|
const filterByPostDataTypes = (collection, dataTypes) => {
|
|
1195
|
-
const
|
|
1196
|
-
collection.
|
|
1195
|
+
const postIds = [];
|
|
1196
|
+
return collection.reduce((acc, post) => {
|
|
1197
1197
|
var _a;
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
if
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
filteredPosts.push(childPost);
|
|
1208
|
-
}
|
|
1209
|
-
return;
|
|
1198
|
+
// A text post with no children is just a text post
|
|
1199
|
+
if (post.dataType === 'text' && !post.children.length)
|
|
1200
|
+
return acc;
|
|
1201
|
+
// Skip if post is already in the collection
|
|
1202
|
+
if (postIds.includes(post.postId))
|
|
1203
|
+
return acc;
|
|
1204
|
+
// Check dataType for current post
|
|
1205
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(post.dataType)) {
|
|
1206
|
+
acc.push(post);
|
|
1210
1207
|
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1208
|
+
// Check dataType for child post. this function will return all child posts in a same level of parent post (flatten)
|
|
1209
|
+
if (!post.children.length)
|
|
1210
|
+
return acc;
|
|
1211
|
+
const childPost = (_a = pullFromCache(['post', 'get', post.children[0]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1212
|
+
if (!childPost)
|
|
1213
|
+
return acc;
|
|
1214
|
+
// Prevent to insert a duplicate record
|
|
1215
|
+
if (postIds.includes(childPost.postId))
|
|
1216
|
+
return acc;
|
|
1217
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(childPost === null || childPost === void 0 ? void 0 : childPost.dataType))
|
|
1218
|
+
return acc;
|
|
1219
|
+
postIds.push(childPost.postId);
|
|
1220
|
+
// @ts-ignore
|
|
1221
|
+
acc.push(childPost);
|
|
1222
|
+
return acc;
|
|
1223
|
+
}, []);
|
|
1215
1224
|
};
|
|
1216
1225
|
/**
|
|
1217
1226
|
* Filter a collection by search term
|
|
@@ -1385,7 +1394,12 @@ const createEventSubscriber = (client, namespace, event, fn) => {
|
|
|
1385
1394
|
log(`${namespace}(tmpid: ${timestamp}) > listen`);
|
|
1386
1395
|
const handler = (...payload) => {
|
|
1387
1396
|
log(`${namespace}(tmpid: ${timestamp}) > trigger`, payload);
|
|
1388
|
-
|
|
1397
|
+
try {
|
|
1398
|
+
fn(...payload);
|
|
1399
|
+
}
|
|
1400
|
+
catch (e) {
|
|
1401
|
+
log(`${namespace}(tmpid: ${timestamp}) > error`, e);
|
|
1402
|
+
}
|
|
1389
1403
|
};
|
|
1390
1404
|
emitter.on(event, handler);
|
|
1391
1405
|
return () => {
|
package/dist/index.esm.js
CHANGED
|
@@ -1178,26 +1178,35 @@ const filterByCommunityMembership = (collection, membership, userId) => {
|
|
|
1178
1178
|
* @hidden
|
|
1179
1179
|
*/
|
|
1180
1180
|
const filterByPostDataTypes = (collection, dataTypes) => {
|
|
1181
|
-
const
|
|
1182
|
-
collection.
|
|
1181
|
+
const postIds = [];
|
|
1182
|
+
return collection.reduce((acc, post) => {
|
|
1183
1183
|
var _a;
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
filteredPosts.push(childPost);
|
|
1194
|
-
}
|
|
1195
|
-
return;
|
|
1184
|
+
// A text post with no children is just a text post
|
|
1185
|
+
if (post.dataType === 'text' && !post.children.length)
|
|
1186
|
+
return acc;
|
|
1187
|
+
// Skip if post is already in the collection
|
|
1188
|
+
if (postIds.includes(post.postId))
|
|
1189
|
+
return acc;
|
|
1190
|
+
// Check dataType for current post
|
|
1191
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(post.dataType)) {
|
|
1192
|
+
acc.push(post);
|
|
1196
1193
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1194
|
+
// Check dataType for child post. this function will return all child posts in a same level of parent post (flatten)
|
|
1195
|
+
if (!post.children.length)
|
|
1196
|
+
return acc;
|
|
1197
|
+
const childPost = (_a = pullFromCache(['post', 'get', post.children[0]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1198
|
+
if (!childPost)
|
|
1199
|
+
return acc;
|
|
1200
|
+
// Prevent to insert a duplicate record
|
|
1201
|
+
if (postIds.includes(childPost.postId))
|
|
1202
|
+
return acc;
|
|
1203
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(childPost === null || childPost === void 0 ? void 0 : childPost.dataType))
|
|
1204
|
+
return acc;
|
|
1205
|
+
postIds.push(childPost.postId);
|
|
1206
|
+
// @ts-ignore
|
|
1207
|
+
acc.push(childPost);
|
|
1208
|
+
return acc;
|
|
1209
|
+
}, []);
|
|
1201
1210
|
};
|
|
1202
1211
|
/**
|
|
1203
1212
|
* Filter a collection by search term
|
|
@@ -1371,7 +1380,12 @@ const createEventSubscriber = (client, namespace, event, fn) => {
|
|
|
1371
1380
|
log(`${namespace}(tmpid: ${timestamp}) > listen`);
|
|
1372
1381
|
const handler = (...payload) => {
|
|
1373
1382
|
log(`${namespace}(tmpid: ${timestamp}) > trigger`, payload);
|
|
1374
|
-
|
|
1383
|
+
try {
|
|
1384
|
+
fn(...payload);
|
|
1385
|
+
}
|
|
1386
|
+
catch (e) {
|
|
1387
|
+
log(`${namespace}(tmpid: ${timestamp}) > error`, e);
|
|
1388
|
+
}
|
|
1375
1389
|
};
|
|
1376
1390
|
emitter.on(event, handler);
|
|
1377
1391
|
return () => {
|