@tellescope/sdk 0.0.5 → 0.0.9

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.
Files changed (45) hide show
  1. package/lib/cjs/enduser.d.ts +346 -13
  2. package/lib/cjs/enduser.d.ts.map +1 -1
  3. package/lib/cjs/enduser.js +135 -14
  4. package/lib/cjs/enduser.js.map +1 -1
  5. package/lib/cjs/sdk.d.ts +107 -20
  6. package/lib/cjs/sdk.d.ts.map +1 -1
  7. package/lib/cjs/sdk.js +116 -32
  8. package/lib/cjs/sdk.js.map +1 -1
  9. package/lib/cjs/session.d.ts +37 -176
  10. package/lib/cjs/session.d.ts.map +1 -1
  11. package/lib/cjs/session.js +131 -34
  12. package/lib/cjs/session.js.map +1 -1
  13. package/lib/cjs/tests/public_endpoint_tests.js +3 -3
  14. package/lib/cjs/tests/public_endpoint_tests.js.map +1 -1
  15. package/lib/cjs/tests/socket_tests.js +42 -31
  16. package/lib/cjs/tests/socket_tests.js.map +1 -1
  17. package/lib/cjs/tests/tests.js +232 -63
  18. package/lib/cjs/tests/tests.js.map +1 -1
  19. package/lib/esm/enduser.d.ts +346 -13
  20. package/lib/esm/enduser.d.ts.map +1 -1
  21. package/lib/esm/enduser.js +132 -12
  22. package/lib/esm/enduser.js.map +1 -1
  23. package/lib/esm/sdk.d.ts +107 -20
  24. package/lib/esm/sdk.d.ts.map +1 -1
  25. package/lib/esm/sdk.js +116 -32
  26. package/lib/esm/sdk.js.map +1 -1
  27. package/lib/esm/session.d.ts +37 -176
  28. package/lib/esm/session.d.ts.map +1 -1
  29. package/lib/esm/session.js +130 -32
  30. package/lib/esm/session.js.map +1 -1
  31. package/lib/esm/tests/public_endpoint_tests.js +3 -3
  32. package/lib/esm/tests/public_endpoint_tests.js.map +1 -1
  33. package/lib/esm/tests/socket_tests.js +41 -30
  34. package/lib/esm/tests/socket_tests.js.map +1 -1
  35. package/lib/esm/tests/tests.js +228 -64
  36. package/lib/esm/tests/tests.js.map +1 -1
  37. package/lib/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +11 -9
  39. package/src/enduser.ts +93 -20
  40. package/src/sdk.ts +71 -43
  41. package/src/session.ts +122 -34
  42. package/src/tests/public_endpoint_tests.ts +6 -4
  43. package/src/tests/socket_tests.ts +37 -16
  44. package/src/tests/tests.ts +147 -25
  45. package/tsconfig.json +0 -1
@@ -46,24 +46,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  }
47
47
  };
48
48
  require('source-map-support').install();
49
- // import v from 'validator'
50
- import { fieldsToValidation, mongoIdValidator,
51
- // InputValidation,
52
- } from "@tellescope/validation";
53
- import { Session } from "../sdk";
54
- import { url_safe_path } from "@tellescope/utilities";
49
+ import { fieldsToValidation, mongoIdValidator, } from "@tellescope/validation";
50
+ import { Session, EnduserSession } from "../sdk";
55
51
  import { DEFAULT_OPERATIONS } from "@tellescope/constants";
56
- import { schema,
57
- // Model,
58
- // ModelFields
59
- } from "@tellescope/schema";
60
- import { assert, async_test, log_header, objects_equivalent, wait, } from "@tellescope/testing";
52
+ import { schema, } from "@tellescope/schema";
53
+ import { assert, async_test, log_header, wait, } from "@tellescope/testing";
54
+ import { objects_equivalent, url_safe_path, } from "@tellescope/utilities";
61
55
  var host = process.env.TEST_URL || 'http://localhost:8080';
62
56
  var _a = [process.env.TEST_EMAIL, process.env.TEST_PASSWORD], email = _a[0], password = _a[1];
63
57
  var _b = [process.env.TEST_EMAIL_2, process.env.TEST_PASSWORD_2], email2 = _b[0], password2 = _b[1];
64
58
  var userId = '60398b0231a295e64f084fd9';
59
+ // const example_SDK_usage = async () => {
60
+ // // initialize SDK and authenticate a user
61
+ // const sdk = new Session()
62
+ // await sdk.authenticate("user-email", 'user-password')
63
+ // // create a record, using Enduser model as example
64
+ // const enduser = await sdk.api.endusers.createOne({ email: "enduser1@tellescope.com" })
65
+ // // update an existing record
66
+ // await sdk.api.endusers.updateOne(enduser.id, { phone: "+15555555555" })
67
+ // // fetch a record by id, or a list of recent records
68
+ // const existingEnduser: Enduser = await sdk.api.endusers.getOne(enduser.id)
69
+ // const existingEndusers: Enduser[] = await sdk.api.endusers.getSome({ limit: 5, lastId: enduser.id })
70
+ // // delete an individual record
71
+ // await sdk.api.endusers.deleteOne(enduser.id)
72
+ // }
65
73
  var sdk = new Session();
66
74
  var sdkOther = new Session({ host: host, apiKey: "ba745e25162bb95a795c5fa1af70df188d93c4d3aac9c48b34a5c8c9dd7b80f7" });
75
+ var enduserSDK = new EnduserSession({ host: host });
67
76
  // const sdkOtherEmail = "sebass@tellescope.com"
68
77
  if (!(email && password && email2 && password2)) {
69
78
  console.error("Set TEST_EMAIL and TEST_PASSWORD");
@@ -224,6 +233,38 @@ var threadKeyTests = function () { return __awaiter(void 0, void 0, void 0, func
224
233
  }
225
234
  });
226
235
  }); };
236
+ var filterTests = function () { return __awaiter(void 0, void 0, void 0, function () {
237
+ var enduser, otherEnduser;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0: return [4 /*yield*/, sdk.api.endusers.createOne({ email: 'filtertests@tellescope.com', fname: 'test' })];
241
+ case 1:
242
+ enduser = _a.sent();
243
+ return [4 /*yield*/, sdk.api.endusers.createOne({ email: 'other@tellescope.com' })];
244
+ case 2:
245
+ otherEnduser = _a.sent();
246
+ return [4 /*yield*/, async_test("find enduser by filter", function () { return sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com' } }); }, { onResult: function (es) { return es.length === 1 && es[0].id === enduser.id; } })];
247
+ case 3:
248
+ _a.sent();
249
+ return [4 /*yield*/, async_test("find enduser by compound filter", function () { return sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com', fname: 'test' } }); }, { onResult: function (es) { return es.length === 1 && es[0].id === enduser.id; } })];
250
+ case 4:
251
+ _a.sent();
252
+ return [4 /*yield*/, async_test("nothing found by invalid compound filter", function () { return sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com', fname: 'nottest' } }); }, { onResult: function (es) { return es.length === 0; } })];
253
+ case 5:
254
+ _a.sent();
255
+ return [4 /*yield*/, async_test("nothing found for invalid filter", function () { return sdk.api.endusers.getSome({ filter: { email: 'doesnotexist@tellescope.com' } }); }, { onResult: function (es) { return es.length === 0; } })];
256
+ case 6:
257
+ _a.sent();
258
+ return [4 /*yield*/, sdk.api.endusers.deleteOne(enduser.id)];
259
+ case 7:
260
+ _a.sent();
261
+ return [4 /*yield*/, sdk.api.endusers.deleteOne(otherEnduser.id)];
262
+ case 8:
263
+ _a.sent();
264
+ return [2 /*return*/];
265
+ }
266
+ });
267
+ }); };
227
268
  var instanceForModel = function (model, i) {
228
269
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
229
270
  if (i === void 0) { i = 0; }
@@ -338,7 +379,7 @@ var run_generated_tests = function (_a) {
338
379
  case 6:
339
380
  _c.sent();
340
381
  if (!model.defaultActions.update) return [3 /*break*/, 8];
341
- return [4 /*yield*/, async_test("update-" + singularName, function () { return queries.updateOne(_id, updates, { replaceObjectFields: true }); }, passOnVoid)];
382
+ return [4 /*yield*/, async_test("update-" + singularName, function () { return queries.updateOne(_id, updates, { replaceObjectFields: true }); }, { onResult: function (u) { return typeof u === 'object' && u.id === _id; } })];
342
383
  case 7:
343
384
  _c.sent();
344
385
  _c.label = 8;
@@ -354,7 +395,7 @@ var run_generated_tests = function (_a) {
354
395
  })];
355
396
  case 9:
356
397
  _c.sent();
357
- return [4 /*yield*/, async_test("get-" + safeName, function () { return queries.getSome({}, filter); }, { onResult: function (_a) {
398
+ return [4 /*yield*/, async_test("get-" + safeName, function () { return queries.getSome({ filter: filter }); }, { onResult: function (_a) {
358
399
  var d = _a[0];
359
400
  // if (others.length !== 0) return false // some collections are not reset during testing, like API keys
360
401
  if (!(d === null || d === void 0 ? void 0 : d.id))
@@ -566,7 +607,7 @@ var journey_tests = function (queries) {
566
607
  return [4 /*yield*/, async_test("journey-update - insert new state at front", function () { return queries.getOne(journey.id); }, { onResult: function (j) { return objects_equivalent(j.states, [{ name: 'First', priority: "N/A" }, { name: 'Added', priority: "N/A" }]); } })];
567
608
  case 24:
568
609
  _g.sent();
569
- return [4 /*yield*/, async_test("journey-updateState", function () { return queries.updateState(journey.id, 'Added', { name: 'Updated', priority: 'N/A' }); }, passOnVoid)];
610
+ return [4 /*yield*/, async_test("journey-updateState", function () { return queries.updateState({ id: journey.id, name: 'Added', updates: { name: 'Updated', priority: 'N/A' } }); }, passOnVoid)];
570
611
  case 25:
571
612
  _g.sent();
572
613
  return [4 /*yield*/, wait(undefined, 25)]; // wait for side effects to update endusers
@@ -785,79 +826,195 @@ var chat_tests = function () { return __awaiter(void 0, void 0, void 0, function
785
826
  return [4 /*yield*/, async_test("get-chat (with filter)", function () { return sdk.api.chats.getOne(chat.id, { roomId: room.id }); }, { onResult: function (c) { return (c === null || c === void 0 ? void 0 : c.id) === chat.id; } })];
786
827
  case 7:
787
828
  _a.sent();
788
- return [4 /*yield*/, async_test("get-chats (with filter)", function () { return sdk.api.chats.getSome({}, { roomId: room.id }); }, { onResult: function (c) { return (c === null || c === void 0 ? void 0 : c.length) === 2; } })];
829
+ return [4 /*yield*/, async_test("get-chats (with filter)", function () { return sdk.api.chats.getSome({ filter: { roomId: room.id } }); }, { onResult: function (c) { return (c === null || c === void 0 ? void 0 : c.length) === 2; } })];
789
830
  case 8:
790
831
  _a.sent();
791
832
  return [4 /*yield*/, async_test("get-chat not allowed", function () { return sdk2.api.chats.getOne(chat.id, { roomId: room.id }); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })];
792
833
  case 9:
793
834
  _a.sent();
794
- return [4 /*yield*/, async_test("get-chats not allowed", function () { return sdk2.api.chats.getSome({}, { roomId: room.id }); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })];
835
+ return [4 /*yield*/, async_test("get-chats not allowed", function () { return sdk2.api.chats.getSome({ filter: { roomId: room.id } }); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })
836
+ // currently disabled endpoint altogether
837
+ // await async_test(
838
+ // `update-chat not allowed`,
839
+ // () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
840
+ // { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
841
+ // )
842
+ ];
795
843
  case 10:
796
844
  _a.sent();
797
- return [4 /*yield*/, async_test("update-chat not allowed", function () { return sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })];
845
+ // currently disabled endpoint altogether
846
+ // await async_test(
847
+ // `update-chat not allowed`,
848
+ // () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
849
+ // { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
850
+ // )
851
+ return [4 /*yield*/, async_test("delete-chat not allowed", function () { return sdk2.api.chats.deleteOne(chat.id); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })
852
+ // currently disabled endpoint altogether
853
+ // await async_test(
854
+ // `update-chat can't update roomId`,
855
+ // () => sdk.api.chats.updateOne(chat.id, { roomId: room.id } as any), // cast to any to allow calling with bad argument, but typing should catch this too
856
+ // { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
857
+ // )
858
+ ];
798
859
  case 11:
860
+ // currently disabled endpoint altogether
861
+ // await async_test(
862
+ // `update-chat not allowed`,
863
+ // () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
864
+ // { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
865
+ // )
799
866
  _a.sent();
800
- return [4 /*yield*/, async_test("delete-chat not allowed", function () { return sdk2.api.chats.deleteOne(chat.id); }, { shouldError: true, onError: function (e) { return e.message === 'You do not have permission to access this resource'; } })];
801
- case 12:
802
- _a.sent();
803
- return [4 /*yield*/, async_test("update-chat can't update roomId", function () { return sdk.api.chats.updateOne(chat.id, { roomId: room.id }); }, // cast to any to allow calling with bad argument, but typing should catch this too
804
- { shouldError: true, onError: function (e) { return e.message === 'Error parsing field updates: roomId is not valid for updates'; } })];
805
- case 13:
806
- _a.sent();
867
+ // currently disabled endpoint altogether
868
+ // await async_test(
869
+ // `update-chat can't update roomId`,
870
+ // () => sdk.api.chats.updateOne(chat.id, { roomId: room.id } as any), // cast to any to allow calling with bad argument, but typing should catch this too
871
+ // { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
872
+ // )
807
873
  return [4 /*yield*/, sdk.api.chat_rooms.deleteOne(room.id)];
808
- case 14:
874
+ case 12:
875
+ // currently disabled endpoint altogether
876
+ // await async_test(
877
+ // `update-chat can't update roomId`,
878
+ // () => sdk.api.chats.updateOne(chat.id, { roomId: room.id } as any), // cast to any to allow calling with bad argument, but typing should catch this too
879
+ // { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
880
+ // )
809
881
  _a.sent();
810
882
  return [4 /*yield*/, wait(undefined, 25)];
811
- case 15:
883
+ case 13:
812
884
  _a.sent();
813
885
  return [4 /*yield*/, async_test("get-chat (deleted as dependency of room 1)", function () { return sdk.api.chats.getOne(chat.id, { roomId: room.id }); }, { shouldError: true, onError: function (e) { return e.message === 'Could not find a record for the given id'; } })];
814
- case 16:
886
+ case 14:
815
887
  _a.sent();
816
888
  return [4 /*yield*/, async_test("get-chat (deleted as dependency of room 2)", function () { return sdk.api.chats.getOne(chat2.id, { roomId: room.id }); }, { shouldError: true, onError: function (e) { return e.message === 'Could not find a record for the given id'; } })];
817
- case 17:
889
+ case 15:
818
890
  _a.sent();
819
891
  return [4 /*yield*/, sdk.api.chat_rooms.createOne({ type: 'internal', userIds: [userId, sdk2.userInfo.id] })];
820
- case 18:
892
+ case 16:
821
893
  sharedRoom = _a.sent();
822
894
  return [4 /*yield*/, sdk.api.chats.createOne({ roomId: sharedRoom.id, message: "Hello!", })];
823
- case 19:
895
+ case 17:
824
896
  sharedChat = _a.sent();
825
897
  return [4 /*yield*/, sdk2.api.chats.createOne({ roomId: sharedRoom.id, message: "Hello there!", })];
826
- case 20:
898
+ case 18:
827
899
  sharedChat2 = _a.sent();
828
900
  return [4 /*yield*/, async_test("get-chat (shared, user1)", function () { return sdk.api.chats.getOne(sharedChat.id, { roomId: sharedRoom.id }); }, { onResult: function (r) { return r.id === sharedChat.id; } })];
829
- case 21:
901
+ case 19:
830
902
  _a.sent();
831
903
  return [4 /*yield*/, async_test("get-chat (shared, user2)", function () { return sdk2.api.chats.getOne(sharedChat.id, { roomId: sharedRoom.id }); }, { onResult: function (r) { return r.id === sharedChat.id; } })];
832
- case 22:
904
+ case 20:
833
905
  _a.sent();
834
- return [4 /*yield*/, async_test("get-chats (shared, user1)", function () { return sdk.api.chats.getSome({}, { roomId: sharedRoom.id }); }, { onResult: function (cs) { return cs.length === 2 && !!cs.find(function (c) { return c.id === sharedChat.id; }) && !!cs.find(function (c) { return c.id === sharedChat2.id; }); } })];
835
- case 23:
906
+ return [4 /*yield*/, async_test("get-chats (shared, user1)", function () { return sdk.api.chats.getSome({ filter: { roomId: sharedRoom.id } }); }, { onResult: function (cs) { return cs.length === 2 && !!cs.find(function (c) { return c.id === sharedChat.id; }) && !!cs.find(function (c) { return c.id === sharedChat2.id; }); } })];
907
+ case 21:
836
908
  _a.sent();
837
- return [4 /*yield*/, async_test("get-chats (shared, user2)", function () { return sdk2.api.chats.getSome({}, { roomId: sharedRoom.id }); }, { onResult: function (cs) { return cs.length === 2 && !!cs.find(function (c) { return c.id === sharedChat.id; }) && !!cs.find(function (c) { return c.id === sharedChat2.id; }); } })
909
+ return [4 /*yield*/, async_test("get-chats (shared, user2)", function () { return sdk2.api.chats.getSome({ filter: { roomId: sharedRoom.id } }); }, { onResult: function (cs) { return cs.length === 2 && !!cs.find(function (c) { return c.id === sharedChat.id; }) && !!cs.find(function (c) { return c.id === sharedChat2.id; }); } })
838
910
  // test setNull dependency
839
911
  ];
840
- case 24:
912
+ case 22:
841
913
  _a.sent();
842
914
  return [4 /*yield*/, sdk.api.chat_rooms.createOne({ type: 'internal', userIds: [userId] })];
843
- case 25:
915
+ case 23:
844
916
  roomNull = _a.sent();
845
917
  return [4 /*yield*/, sdk.api.chats.createOne({ roomId: roomNull.id, message: "Hello!" })];
846
- case 26:
918
+ case 24:
847
919
  chatNull = _a.sent();
848
920
  return [4 /*yield*/, sdk.api.chats.createOne({ roomId: roomNull.id, message: "Hello...", replyId: chatNull.id })];
849
- case 27:
921
+ case 25:
850
922
  chat2Null = _a.sent();
851
923
  return [4 /*yield*/, sdk.api.chats.deleteOne(chatNull.id)];
852
- case 28:
924
+ case 26:
853
925
  _a.sent();
854
926
  return [4 /*yield*/, async_test("get-chat (setNull working)", function () { return sdk.api.chats.getOne(chat2Null.id, { roomId: roomNull.id }); }, { onResult: function (c) { return c.replyId === null; } })];
855
- case 29:
927
+ case 27:
856
928
  _a.sent();
857
929
  return [2 /*return*/];
858
930
  }
859
931
  });
860
932
  }); };
933
+ var enduserAccessTests = function () { return __awaiter(void 0, void 0, void 0, function () {
934
+ var email, password, enduser, _loop_1, _a, _b, _i, n;
935
+ var _c, _d, _e, _f, _g, _h;
936
+ return __generator(this, function (_j) {
937
+ switch (_j.label) {
938
+ case 0:
939
+ email = 'enduser@tellescope.com';
940
+ password = 'testpassword';
941
+ return [4 /*yield*/, sdk.api.endusers.createOne({ email: email })];
942
+ case 1:
943
+ enduser = _j.sent();
944
+ return [4 /*yield*/, sdk.api.endusers.setPassword({ id: enduser.id, password: password }).catch(console.error)];
945
+ case 2:
946
+ _j.sent();
947
+ return [4 /*yield*/, enduserSDK.authenticate(email, password).catch(console.error)];
948
+ case 3:
949
+ _j.sent();
950
+ _loop_1 = function (n) {
951
+ var endpoint, model;
952
+ return __generator(this, function (_k) {
953
+ switch (_k.label) {
954
+ case 0:
955
+ endpoint = url_safe_path(n);
956
+ model = schema[n];
957
+ if (!(!((_c = model === null || model === void 0 ? void 0 : model.enduserActions) === null || _c === void 0 ? void 0 : _c.read) && (model.defaultActions.read || model.customActions.read))) return [3 /*break*/, 2];
958
+ return [4 /*yield*/, async_test("no-enduser-access getOne (" + endpoint + ")", function () { return enduserSDK.GET("/v1/" + endpoint.substring(0, endpoint.length - 1) + "/:id"); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
959
+ case 1:
960
+ _k.sent();
961
+ _k.label = 2;
962
+ case 2:
963
+ if (!(!((_d = model.enduserActions) === null || _d === void 0 ? void 0 : _d.readMany) && (model.defaultActions.readMany || model.customActions.readMany))) return [3 /*break*/, 4];
964
+ return [4 /*yield*/, async_test("no-enduser-access getSome (" + endpoint + ")", function () { return enduserSDK.GET("/v1/" + endpoint); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
965
+ case 3:
966
+ _k.sent();
967
+ _k.label = 4;
968
+ case 4:
969
+ if (!(!((_e = model.enduserActions) === null || _e === void 0 ? void 0 : _e.create) && (model.defaultActions.create || model.customActions.create))) return [3 /*break*/, 6];
970
+ return [4 /*yield*/, async_test("no-enduser-access createOne (" + endpoint + ")", function () { return enduserSDK.POST("/v1/" + endpoint.substring(0, endpoint.length - 1)); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
971
+ case 5:
972
+ _k.sent();
973
+ _k.label = 6;
974
+ case 6:
975
+ if (!(!((_f = model.enduserActions) === null || _f === void 0 ? void 0 : _f.createMany) && (model.defaultActions.createMany || model.customActions.createMany))) return [3 /*break*/, 8];
976
+ return [4 /*yield*/, async_test("no-enduser-access createMany (" + endpoint + ")", function () { return enduserSDK.POST("/v1/" + endpoint); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
977
+ case 7:
978
+ _k.sent();
979
+ _k.label = 8;
980
+ case 8:
981
+ if (!(!((_g = model.enduserActions) === null || _g === void 0 ? void 0 : _g.update) && (model.defaultActions.update || model.customActions.update))) return [3 /*break*/, 10];
982
+ return [4 /*yield*/, async_test("no-enduser-access update (" + endpoint + ")", function () { return enduserSDK.PATCH("/v1/" + endpoint.substring(0, endpoint.length - 1) + "/:id"); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
983
+ case 9:
984
+ _k.sent();
985
+ _k.label = 10;
986
+ case 10:
987
+ if (!(!((_h = model.enduserActions) === null || _h === void 0 ? void 0 : _h.delete) && (model.defaultActions.delete || model.customActions.delete))) return [3 /*break*/, 12];
988
+ return [4 /*yield*/, async_test("no-enduser-access delete (" + endpoint + ")", function () { return enduserSDK.DELETE("/v1/" + endpoint.substring(0, endpoint.length - 1) + "/:id"); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
989
+ case 11:
990
+ _k.sent();
991
+ _k.label = 12;
992
+ case 12: return [2 /*return*/];
993
+ }
994
+ });
995
+ };
996
+ _a = [];
997
+ for (_b in schema)
998
+ _a.push(_b);
999
+ _i = 0;
1000
+ _j.label = 4;
1001
+ case 4:
1002
+ if (!(_i < _a.length)) return [3 /*break*/, 7];
1003
+ n = _a[_i];
1004
+ return [5 /*yield**/, _loop_1(n)];
1005
+ case 5:
1006
+ _j.sent();
1007
+ _j.label = 6;
1008
+ case 6:
1009
+ _i++;
1010
+ return [3 /*break*/, 4];
1011
+ case 7: return [4 /*yield*/, sdk.api.endusers.deleteOne(enduser.id)];
1012
+ case 8:
1013
+ _j.sent();
1014
+ return [2 /*return*/];
1015
+ }
1016
+ });
1017
+ }); };
861
1018
  var tests = {
862
1019
  chats: chat_tests,
863
1020
  endusers: enduser_tests,
@@ -870,6 +1027,7 @@ var tests = {
870
1027
  chat_rooms: chat_room_tests,
871
1028
  users: function () { },
872
1029
  templates: function () { },
1030
+ files: function () { },
873
1031
  };
874
1032
  (function () { return __awaiter(void 0, void 0, void 0, function () {
875
1033
  var n, _a, _b, _i, returnValidation, t, _c, _d, _e, err_1;
@@ -886,16 +1044,22 @@ var tests = {
886
1044
  return [4 /*yield*/, multi_tenant_tests()]; // should come right after setup tests
887
1045
  case 3:
888
1046
  _h.sent(); // should come right after setup tests
889
- return [4 /*yield*/, threadKeyTests()];
1047
+ return [4 /*yield*/, filterTests()];
890
1048
  case 4:
1049
+ _h.sent();
1050
+ return [4 /*yield*/, threadKeyTests()];
1051
+ case 5:
1052
+ _h.sent();
1053
+ return [4 /*yield*/, enduserAccessTests()];
1054
+ case 6:
891
1055
  _h.sent();
892
1056
  _a = [];
893
1057
  for (_b in schema)
894
1058
  _a.push(_b);
895
1059
  _i = 0;
896
- _h.label = 5;
897
- case 5:
898
- if (!(_i < _a.length)) return [3 /*break*/, 8];
1060
+ _h.label = 7;
1061
+ case 7:
1062
+ if (!(_i < _a.length)) return [3 /*break*/, 10];
899
1063
  n = _a[_i];
900
1064
  returnValidation = (_g = (_f = schema[n].customActions) === null || _f === void 0 ? void 0 : _f.create) === null || _g === void 0 ? void 0 : _g.returns;
901
1065
  return [4 /*yield*/, run_generated_tests({
@@ -906,37 +1070,37 @@ var tests = {
906
1070
  create: returnValidation,
907
1071
  }
908
1072
  })];
909
- case 6:
1073
+ case 8:
910
1074
  _h.sent();
911
- _h.label = 7;
912
- case 7:
1075
+ _h.label = 9;
1076
+ case 9:
913
1077
  _i++;
914
- return [3 /*break*/, 5];
915
- case 8:
1078
+ return [3 /*break*/, 7];
1079
+ case 10:
916
1080
  _c = [];
917
1081
  for (_d in tests)
918
1082
  _c.push(_d);
919
1083
  _e = 0;
920
- _h.label = 9;
921
- case 9:
922
- if (!(_e < _c.length)) return [3 /*break*/, 14];
1084
+ _h.label = 11;
1085
+ case 11:
1086
+ if (!(_e < _c.length)) return [3 /*break*/, 16];
923
1087
  t = _c[_e];
924
- _h.label = 10;
925
- case 10:
926
- _h.trys.push([10, 12, , 13]);
1088
+ _h.label = 12;
1089
+ case 12:
1090
+ _h.trys.push([12, 14, , 15]);
927
1091
  return [4 /*yield*/, tests[t]()];
928
- case 11:
1092
+ case 13:
929
1093
  _h.sent();
930
- return [3 /*break*/, 13];
931
- case 12:
1094
+ return [3 /*break*/, 15];
1095
+ case 14:
932
1096
  err_1 = _h.sent();
933
1097
  console.error("Error running test:");
934
1098
  console.error(err_1);
935
- return [3 /*break*/, 13];
936
- case 13:
1099
+ return [3 /*break*/, 15];
1100
+ case 15:
937
1101
  _e++;
938
- return [3 /*break*/, 9];
939
- case 14:
1102
+ return [3 /*break*/, 11];
1103
+ case 16:
940
1104
  process.exit();
941
1105
  return [2 /*return*/];
942
1106
  }