@tellescope/sdk 0.0.4 → 0.0.8
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/lib/cjs/enduser.d.ts +346 -13
- package/lib/cjs/enduser.d.ts.map +1 -1
- package/lib/cjs/enduser.js +135 -14
- package/lib/cjs/enduser.js.map +1 -1
- package/lib/cjs/sdk.d.ts +106 -19
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +116 -32
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/session.d.ts +36 -175
- package/lib/cjs/session.d.ts.map +1 -1
- package/lib/cjs/session.js +131 -34
- package/lib/cjs/session.js.map +1 -1
- package/lib/cjs/tests/public_endpoint_tests.js +3 -3
- package/lib/cjs/tests/public_endpoint_tests.js.map +1 -1
- package/lib/cjs/tests/socket_tests.js +42 -31
- package/lib/cjs/tests/socket_tests.js.map +1 -1
- package/lib/cjs/tests/tests.js +196 -62
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +346 -13
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/enduser.js +132 -12
- package/lib/esm/enduser.js.map +1 -1
- package/lib/esm/sdk.d.ts +106 -19
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +116 -32
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/session.d.ts +36 -175
- package/lib/esm/session.d.ts.map +1 -1
- package/lib/esm/session.js +130 -32
- package/lib/esm/session.js.map +1 -1
- package/lib/esm/tests/public_endpoint_tests.js +3 -3
- package/lib/esm/tests/public_endpoint_tests.js.map +1 -1
- package/lib/esm/tests/socket_tests.js +41 -30
- package/lib/esm/tests/socket_tests.js.map +1 -1
- package/lib/esm/tests/tests.js +192 -63
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -9
- package/src/enduser.ts +93 -20
- package/src/sdk.ts +70 -42
- package/src/session.ts +121 -33
- package/src/tests/public_endpoint_tests.ts +6 -4
- package/src/tests/socket_tests.ts +37 -16
- package/src/tests/tests.ts +117 -24
- package/tsconfig.json +0 -1
package/lib/cjs/tests/tests.js
CHANGED
|
@@ -48,19 +48,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
require('source-map-support').install();
|
|
51
|
-
// import v from 'validator'
|
|
52
51
|
var validation_1 = require("@tellescope/validation");
|
|
53
52
|
var sdk_1 = require("../sdk");
|
|
54
|
-
var utilities_1 = require("@tellescope/utilities");
|
|
55
53
|
var constants_1 = require("@tellescope/constants");
|
|
56
54
|
var schema_1 = require("@tellescope/schema");
|
|
57
55
|
var testing_1 = require("@tellescope/testing");
|
|
56
|
+
var utilities_1 = require("@tellescope/utilities");
|
|
58
57
|
var host = process.env.TEST_URL || 'http://localhost:8080';
|
|
59
58
|
var _a = [process.env.TEST_EMAIL, process.env.TEST_PASSWORD], email = _a[0], password = _a[1];
|
|
60
59
|
var _b = [process.env.TEST_EMAIL_2, process.env.TEST_PASSWORD_2], email2 = _b[0], password2 = _b[1];
|
|
61
60
|
var userId = '60398b0231a295e64f084fd9';
|
|
61
|
+
// const example_SDK_usage = async () => {
|
|
62
|
+
// // initialize SDK and authenticate a user
|
|
63
|
+
// const sdk = new Session()
|
|
64
|
+
// await sdk.authenticate("user-email", 'user-password')
|
|
65
|
+
// // create a record, using Enduser model as example
|
|
66
|
+
// const enduser = await sdk.api.endusers.createOne({ email: "enduser1@tellescope.com" })
|
|
67
|
+
// // update an existing record
|
|
68
|
+
// await sdk.api.endusers.updateOne(enduser.id, { phone: "+15555555555" })
|
|
69
|
+
// // fetch a record by id, or a list of recent records
|
|
70
|
+
// const existingEnduser: Enduser = await sdk.api.endusers.getOne(enduser.id)
|
|
71
|
+
// const existingEndusers: Enduser[] = await sdk.api.endusers.getSome({ limit: 5, lastId: enduser.id })
|
|
72
|
+
// // delete an individual record
|
|
73
|
+
// await sdk.api.endusers.deleteOne(enduser.id)
|
|
74
|
+
// }
|
|
62
75
|
var sdk = new sdk_1.Session();
|
|
63
76
|
var sdkOther = new sdk_1.Session({ host: host, apiKey: "ba745e25162bb95a795c5fa1af70df188d93c4d3aac9c48b34a5c8c9dd7b80f7" });
|
|
77
|
+
var enduserSDK = new sdk_1.EnduserSession({ host: host });
|
|
64
78
|
// const sdkOtherEmail = "sebass@tellescope.com"
|
|
65
79
|
if (!(email && password && email2 && password2)) {
|
|
66
80
|
console.error("Set TEST_EMAIL and TEST_PASSWORD");
|
|
@@ -343,7 +357,7 @@ var run_generated_tests = function (_a) {
|
|
|
343
357
|
if (!(d === null || d === void 0 ? void 0 : d.id))
|
|
344
358
|
return false;
|
|
345
359
|
for (var k in instance) {
|
|
346
|
-
if (!(0,
|
|
360
|
+
if (!(0, utilities_1.objects_equivalent)(instance[k], d[k]))
|
|
347
361
|
return false;
|
|
348
362
|
}
|
|
349
363
|
return true;
|
|
@@ -351,13 +365,13 @@ var run_generated_tests = function (_a) {
|
|
|
351
365
|
})];
|
|
352
366
|
case 9:
|
|
353
367
|
_c.sent();
|
|
354
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-" + safeName, function () { return queries.getSome({
|
|
368
|
+
return [4 /*yield*/, (0, testing_1.async_test)("get-" + safeName, function () { return queries.getSome({ filter: filter }); }, { onResult: function (_a) {
|
|
355
369
|
var d = _a[0];
|
|
356
370
|
// if (others.length !== 0) return false // some collections are not reset during testing, like API keys
|
|
357
371
|
if (!(d === null || d === void 0 ? void 0 : d.id))
|
|
358
372
|
return false;
|
|
359
373
|
for (var k in instance) {
|
|
360
|
-
if (!(0,
|
|
374
|
+
if (!(0, utilities_1.objects_equivalent)(instance[k], d[k]))
|
|
361
375
|
return false;
|
|
362
376
|
}
|
|
363
377
|
return true;
|
|
@@ -421,7 +435,7 @@ var enduser_tests = function (queries) {
|
|
|
421
435
|
return [4 /*yield*/, (0, testing_1.async_test)("update-enduser test replaceObjectFields true unset", function () { var _a; return queries.updateOne((_a = e1.id) !== null && _a !== void 0 ? _a : '', { fields: {} }, { replaceObjectFields: true }); }, passOnVoid)];
|
|
422
436
|
case 13:
|
|
423
437
|
_a.sent();
|
|
424
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-enduser test replaceObjectFields verify true unset", function () { var _a; return queries.getOne((_a = e1.id) !== null && _a !== void 0 ? _a : ''); }, { onResult: function (e) { return (0,
|
|
438
|
+
return [4 /*yield*/, (0, testing_1.async_test)("get-enduser test replaceObjectFields verify true unset", function () { var _a; return queries.getOne((_a = e1.id) !== null && _a !== void 0 ? _a : ''); }, { onResult: function (e) { return (0, utilities_1.objects_equivalent)(e.fields, {}); } })];
|
|
425
439
|
case 14:
|
|
426
440
|
_a.sent();
|
|
427
441
|
eToDup1 = { email: 'dup1@tellescope.com' };
|
|
@@ -560,10 +574,10 @@ var journey_tests = function (queries) {
|
|
|
560
574
|
return [4 /*yield*/, queries.updateOne(journey.id, { states: [{ name: 'First', priority: "N/A" }, { name: 'Added', priority: "N/A" }] }, { replaceObjectFields: true })];
|
|
561
575
|
case 23:
|
|
562
576
|
_g.sent();
|
|
563
|
-
return [4 /*yield*/, (0, testing_1.async_test)("journey-update - insert new state at front", function () { return queries.getOne(journey.id); }, { onResult: function (j) { return (0,
|
|
577
|
+
return [4 /*yield*/, (0, testing_1.async_test)("journey-update - insert new state at front", function () { return queries.getOne(journey.id); }, { onResult: function (j) { return (0, utilities_1.objects_equivalent)(j.states, [{ name: 'First', priority: "N/A" }, { name: 'Added', priority: "N/A" }]); } })];
|
|
564
578
|
case 24:
|
|
565
579
|
_g.sent();
|
|
566
|
-
return [4 /*yield*/, (0, testing_1.async_test)("journey-updateState", function () { return queries.updateState(journey.id, 'Added', { name: 'Updated', priority: 'N/A' }); }, passOnVoid)];
|
|
580
|
+
return [4 /*yield*/, (0, testing_1.async_test)("journey-updateState", function () { return queries.updateState({ id: journey.id, name: 'Added', updates: { name: 'Updated', priority: 'N/A' } }); }, passOnVoid)];
|
|
567
581
|
case 25:
|
|
568
582
|
_g.sent();
|
|
569
583
|
return [4 /*yield*/, (0, testing_1.wait)(undefined, 25)]; // wait for side effects to update endusers
|
|
@@ -571,13 +585,13 @@ var journey_tests = function (queries) {
|
|
|
571
585
|
_g.sent(); // wait for side effects to update endusers
|
|
572
586
|
return [4 /*yield*/, (0, testing_1.async_test)("journey-updateState verify propagation to enduser 1", function () { return sdk.api.endusers.getOne(e1.id); }, { onResult: function (e) {
|
|
573
587
|
var _a;
|
|
574
|
-
return (0,
|
|
588
|
+
return (0, utilities_1.objects_equivalent)(e.journeys, (_a = {}, _a[journey.id] = 'Updated', _a));
|
|
575
589
|
} })];
|
|
576
590
|
case 27:
|
|
577
591
|
_g.sent();
|
|
578
592
|
return [4 /*yield*/, (0, testing_1.async_test)("journey-updateState verify propagation to enduser 2", function () { return sdk.api.endusers.getOne(e2.id); }, { onResult: function (e) {
|
|
579
593
|
var _a;
|
|
580
|
-
return (0,
|
|
594
|
+
return (0, utilities_1.objects_equivalent)(e.journeys, (_a = {}, _a[journey.id] = 'Updated', _a[journey2.id] = 'New', _a));
|
|
581
595
|
} })];
|
|
582
596
|
case 28:
|
|
583
597
|
_g.sent();
|
|
@@ -587,12 +601,12 @@ var journey_tests = function (queries) {
|
|
|
587
601
|
return [4 /*yield*/, (0, testing_1.wait)(undefined, 25)]; // wait for side effects to update endusers
|
|
588
602
|
case 30:
|
|
589
603
|
_g.sent(); // wait for side effects to update endusers
|
|
590
|
-
return [4 /*yield*/, (0, testing_1.async_test)("journey-delete - corresponding enduser journeys are unset 1", function () { return sdk.api.endusers.getOne(e1.id); }, { onResult: function (e) { return (0,
|
|
604
|
+
return [4 /*yield*/, (0, testing_1.async_test)("journey-delete - corresponding enduser journeys are unset 1", function () { return sdk.api.endusers.getOne(e1.id); }, { onResult: function (e) { return (0, utilities_1.objects_equivalent)(e.journeys, {}); } })];
|
|
591
605
|
case 31:
|
|
592
606
|
_g.sent();
|
|
593
607
|
return [4 /*yield*/, (0, testing_1.async_test)("journey-delete - corresponding enduser journeys are unset, others left", function () { return sdk.api.endusers.getOne(e2.id); }, { onResult: function (e) {
|
|
594
608
|
var _a;
|
|
595
|
-
return (0,
|
|
609
|
+
return (0, utilities_1.objects_equivalent)(e.journeys, (_a = {}, _a[journey2.id] = 'New', _a));
|
|
596
610
|
} })];
|
|
597
611
|
case 32:
|
|
598
612
|
_g.sent();
|
|
@@ -782,79 +796,195 @@ var chat_tests = function () { return __awaiter(void 0, void 0, void 0, function
|
|
|
782
796
|
return [4 /*yield*/, (0, testing_1.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; } })];
|
|
783
797
|
case 7:
|
|
784
798
|
_a.sent();
|
|
785
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-chats (with filter)", function () { return sdk.api.chats.getSome({
|
|
799
|
+
return [4 /*yield*/, (0, testing_1.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; } })];
|
|
786
800
|
case 8:
|
|
787
801
|
_a.sent();
|
|
788
802
|
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
789
803
|
case 9:
|
|
790
804
|
_a.sent();
|
|
791
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-chats not allowed", function () { return sdk2.api.chats.getSome({
|
|
805
|
+
return [4 /*yield*/, (0, testing_1.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'; } })
|
|
806
|
+
// currently disabled endpoint altogether
|
|
807
|
+
// await async_test(
|
|
808
|
+
// `update-chat not allowed`,
|
|
809
|
+
// () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
|
|
810
|
+
// { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
|
|
811
|
+
// )
|
|
812
|
+
];
|
|
792
813
|
case 10:
|
|
793
814
|
_a.sent();
|
|
794
|
-
|
|
815
|
+
// currently disabled endpoint altogether
|
|
816
|
+
// await async_test(
|
|
817
|
+
// `update-chat not allowed`,
|
|
818
|
+
// () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
|
|
819
|
+
// { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
|
|
820
|
+
// )
|
|
821
|
+
return [4 /*yield*/, (0, testing_1.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'; } })
|
|
822
|
+
// currently disabled endpoint altogether
|
|
823
|
+
// await async_test(
|
|
824
|
+
// `update-chat can't update roomId`,
|
|
825
|
+
// () => 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
|
|
826
|
+
// { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
|
|
827
|
+
// )
|
|
828
|
+
];
|
|
795
829
|
case 11:
|
|
830
|
+
// currently disabled endpoint altogether
|
|
831
|
+
// await async_test(
|
|
832
|
+
// `update-chat not allowed`,
|
|
833
|
+
// () => sdk2.api.chats.updateOne(chat.id, { message: 'Hi' }),
|
|
834
|
+
// { shouldError: true, onError: e => e.message === 'You do not have permission to access this resource' }
|
|
835
|
+
// )
|
|
796
836
|
_a.sent();
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
_a.sent();
|
|
837
|
+
// currently disabled endpoint altogether
|
|
838
|
+
// await async_test(
|
|
839
|
+
// `update-chat can't update roomId`,
|
|
840
|
+
// () => 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
|
|
841
|
+
// { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
|
|
842
|
+
// )
|
|
804
843
|
return [4 /*yield*/, sdk.api.chat_rooms.deleteOne(room.id)];
|
|
805
|
-
case
|
|
844
|
+
case 12:
|
|
845
|
+
// currently disabled endpoint altogether
|
|
846
|
+
// await async_test(
|
|
847
|
+
// `update-chat can't update roomId`,
|
|
848
|
+
// () => 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
|
|
849
|
+
// { shouldError: true, onError: e => e.message === 'Error parsing field updates: roomId is not valid for updates' }
|
|
850
|
+
// )
|
|
806
851
|
_a.sent();
|
|
807
852
|
return [4 /*yield*/, (0, testing_1.wait)(undefined, 25)];
|
|
808
|
-
case
|
|
853
|
+
case 13:
|
|
809
854
|
_a.sent();
|
|
810
855
|
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
811
|
-
case
|
|
856
|
+
case 14:
|
|
812
857
|
_a.sent();
|
|
813
858
|
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
814
|
-
case
|
|
859
|
+
case 15:
|
|
815
860
|
_a.sent();
|
|
816
861
|
return [4 /*yield*/, sdk.api.chat_rooms.createOne({ type: 'internal', userIds: [userId, sdk2.userInfo.id] })];
|
|
817
|
-
case
|
|
862
|
+
case 16:
|
|
818
863
|
sharedRoom = _a.sent();
|
|
819
864
|
return [4 /*yield*/, sdk.api.chats.createOne({ roomId: sharedRoom.id, message: "Hello!", })];
|
|
820
|
-
case
|
|
865
|
+
case 17:
|
|
821
866
|
sharedChat = _a.sent();
|
|
822
867
|
return [4 /*yield*/, sdk2.api.chats.createOne({ roomId: sharedRoom.id, message: "Hello there!", })];
|
|
823
|
-
case
|
|
868
|
+
case 18:
|
|
824
869
|
sharedChat2 = _a.sent();
|
|
825
870
|
return [4 /*yield*/, (0, testing_1.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; } })];
|
|
826
|
-
case
|
|
871
|
+
case 19:
|
|
827
872
|
_a.sent();
|
|
828
873
|
return [4 /*yield*/, (0, testing_1.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; } })];
|
|
829
|
-
case
|
|
874
|
+
case 20:
|
|
830
875
|
_a.sent();
|
|
831
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-chats (shared, user1)", function () { return sdk.api.chats.getSome({
|
|
832
|
-
case
|
|
876
|
+
return [4 /*yield*/, (0, testing_1.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; }); } })];
|
|
877
|
+
case 21:
|
|
833
878
|
_a.sent();
|
|
834
|
-
return [4 /*yield*/, (0, testing_1.async_test)("get-chats (shared, user2)", function () { return sdk2.api.chats.getSome({
|
|
879
|
+
return [4 /*yield*/, (0, testing_1.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; }); } })
|
|
835
880
|
// test setNull dependency
|
|
836
881
|
];
|
|
837
|
-
case
|
|
882
|
+
case 22:
|
|
838
883
|
_a.sent();
|
|
839
884
|
return [4 /*yield*/, sdk.api.chat_rooms.createOne({ type: 'internal', userIds: [userId] })];
|
|
840
|
-
case
|
|
885
|
+
case 23:
|
|
841
886
|
roomNull = _a.sent();
|
|
842
887
|
return [4 /*yield*/, sdk.api.chats.createOne({ roomId: roomNull.id, message: "Hello!" })];
|
|
843
|
-
case
|
|
888
|
+
case 24:
|
|
844
889
|
chatNull = _a.sent();
|
|
845
890
|
return [4 /*yield*/, sdk.api.chats.createOne({ roomId: roomNull.id, message: "Hello...", replyId: chatNull.id })];
|
|
846
|
-
case
|
|
891
|
+
case 25:
|
|
847
892
|
chat2Null = _a.sent();
|
|
848
893
|
return [4 /*yield*/, sdk.api.chats.deleteOne(chatNull.id)];
|
|
849
|
-
case
|
|
894
|
+
case 26:
|
|
850
895
|
_a.sent();
|
|
851
896
|
return [4 /*yield*/, (0, testing_1.async_test)("get-chat (setNull working)", function () { return sdk.api.chats.getOne(chat2Null.id, { roomId: roomNull.id }); }, { onResult: function (c) { return c.replyId === null; } })];
|
|
852
|
-
case
|
|
897
|
+
case 27:
|
|
853
898
|
_a.sent();
|
|
854
899
|
return [2 /*return*/];
|
|
855
900
|
}
|
|
856
901
|
});
|
|
857
902
|
}); };
|
|
903
|
+
var enduserAccessTests = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
904
|
+
var email, password, enduser, _loop_1, _a, _b, _i, n;
|
|
905
|
+
var _c, _d, _e, _f, _g, _h;
|
|
906
|
+
return __generator(this, function (_j) {
|
|
907
|
+
switch (_j.label) {
|
|
908
|
+
case 0:
|
|
909
|
+
email = 'enduser@tellescope.com';
|
|
910
|
+
password = 'testpassword';
|
|
911
|
+
return [4 /*yield*/, sdk.api.endusers.createOne({ email: email })];
|
|
912
|
+
case 1:
|
|
913
|
+
enduser = _j.sent();
|
|
914
|
+
return [4 /*yield*/, sdk.api.endusers.setPassword({ id: enduser.id, password: password }).catch(console.error)];
|
|
915
|
+
case 2:
|
|
916
|
+
_j.sent();
|
|
917
|
+
return [4 /*yield*/, enduserSDK.authenticate(email, password).catch(console.error)];
|
|
918
|
+
case 3:
|
|
919
|
+
_j.sent();
|
|
920
|
+
_loop_1 = function (n) {
|
|
921
|
+
var endpoint, model;
|
|
922
|
+
return __generator(this, function (_k) {
|
|
923
|
+
switch (_k.label) {
|
|
924
|
+
case 0:
|
|
925
|
+
endpoint = (0, utilities_1.url_safe_path)(n);
|
|
926
|
+
model = schema_1.schema[n];
|
|
927
|
+
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];
|
|
928
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
929
|
+
case 1:
|
|
930
|
+
_k.sent();
|
|
931
|
+
_k.label = 2;
|
|
932
|
+
case 2:
|
|
933
|
+
if (!(!((_d = model.enduserActions) === null || _d === void 0 ? void 0 : _d.readMany) && (model.defaultActions.readMany || model.customActions.readMany))) return [3 /*break*/, 4];
|
|
934
|
+
return [4 /*yield*/, (0, testing_1.async_test)("no-enduser-access getSome (" + endpoint + ")", function () { return enduserSDK.GET("/v1/" + endpoint); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
|
|
935
|
+
case 3:
|
|
936
|
+
_k.sent();
|
|
937
|
+
_k.label = 4;
|
|
938
|
+
case 4:
|
|
939
|
+
if (!(!((_e = model.enduserActions) === null || _e === void 0 ? void 0 : _e.create) && (model.defaultActions.create || model.customActions.create))) return [3 /*break*/, 6];
|
|
940
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
941
|
+
case 5:
|
|
942
|
+
_k.sent();
|
|
943
|
+
_k.label = 6;
|
|
944
|
+
case 6:
|
|
945
|
+
if (!(!((_f = model.enduserActions) === null || _f === void 0 ? void 0 : _f.createMany) && (model.defaultActions.createMany || model.customActions.createMany))) return [3 /*break*/, 8];
|
|
946
|
+
return [4 /*yield*/, (0, testing_1.async_test)("no-enduser-access createMany (" + endpoint + ")", function () { return enduserSDK.POST("/v1/" + endpoint); }, { shouldError: true, onError: function (e) { return e === 'Unauthenticated'; } })];
|
|
947
|
+
case 7:
|
|
948
|
+
_k.sent();
|
|
949
|
+
_k.label = 8;
|
|
950
|
+
case 8:
|
|
951
|
+
if (!(!((_g = model.enduserActions) === null || _g === void 0 ? void 0 : _g.update) && (model.defaultActions.update || model.customActions.update))) return [3 /*break*/, 10];
|
|
952
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
953
|
+
case 9:
|
|
954
|
+
_k.sent();
|
|
955
|
+
_k.label = 10;
|
|
956
|
+
case 10:
|
|
957
|
+
if (!(!((_h = model.enduserActions) === null || _h === void 0 ? void 0 : _h.delete) && (model.defaultActions.delete || model.customActions.delete))) return [3 /*break*/, 12];
|
|
958
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
959
|
+
case 11:
|
|
960
|
+
_k.sent();
|
|
961
|
+
_k.label = 12;
|
|
962
|
+
case 12: return [2 /*return*/];
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
};
|
|
966
|
+
_a = [];
|
|
967
|
+
for (_b in schema_1.schema)
|
|
968
|
+
_a.push(_b);
|
|
969
|
+
_i = 0;
|
|
970
|
+
_j.label = 4;
|
|
971
|
+
case 4:
|
|
972
|
+
if (!(_i < _a.length)) return [3 /*break*/, 7];
|
|
973
|
+
n = _a[_i];
|
|
974
|
+
return [5 /*yield**/, _loop_1(n)];
|
|
975
|
+
case 5:
|
|
976
|
+
_j.sent();
|
|
977
|
+
_j.label = 6;
|
|
978
|
+
case 6:
|
|
979
|
+
_i++;
|
|
980
|
+
return [3 /*break*/, 4];
|
|
981
|
+
case 7: return [4 /*yield*/, sdk.api.endusers.deleteOne(enduser.id)];
|
|
982
|
+
case 8:
|
|
983
|
+
_j.sent();
|
|
984
|
+
return [2 /*return*/];
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
}); };
|
|
858
988
|
var tests = {
|
|
859
989
|
chats: chat_tests,
|
|
860
990
|
endusers: enduser_tests,
|
|
@@ -867,6 +997,7 @@ var tests = {
|
|
|
867
997
|
chat_rooms: chat_room_tests,
|
|
868
998
|
users: function () { },
|
|
869
999
|
templates: function () { },
|
|
1000
|
+
files: function () { },
|
|
870
1001
|
};
|
|
871
1002
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
872
1003
|
var n, _a, _b, _i, returnValidation, t, _c, _d, _e, err_1;
|
|
@@ -880,19 +1011,22 @@ var tests = {
|
|
|
880
1011
|
return [4 /*yield*/, setup_tests()];
|
|
881
1012
|
case 2:
|
|
882
1013
|
_h.sent();
|
|
883
|
-
return [4 /*yield*/,
|
|
1014
|
+
return [4 /*yield*/, enduserAccessTests()];
|
|
884
1015
|
case 3:
|
|
1016
|
+
_h.sent();
|
|
1017
|
+
return [4 /*yield*/, multi_tenant_tests()]; // should come right after setup tests
|
|
1018
|
+
case 4:
|
|
885
1019
|
_h.sent(); // should come right after setup tests
|
|
886
1020
|
return [4 /*yield*/, threadKeyTests()];
|
|
887
|
-
case
|
|
1021
|
+
case 5:
|
|
888
1022
|
_h.sent();
|
|
889
1023
|
_a = [];
|
|
890
1024
|
for (_b in schema_1.schema)
|
|
891
1025
|
_a.push(_b);
|
|
892
1026
|
_i = 0;
|
|
893
|
-
_h.label =
|
|
894
|
-
case
|
|
895
|
-
if (!(_i < _a.length)) return [3 /*break*/,
|
|
1027
|
+
_h.label = 6;
|
|
1028
|
+
case 6:
|
|
1029
|
+
if (!(_i < _a.length)) return [3 /*break*/, 9];
|
|
896
1030
|
n = _a[_i];
|
|
897
1031
|
returnValidation = (_g = (_f = schema_1.schema[n].customActions) === null || _f === void 0 ? void 0 : _f.create) === null || _g === void 0 ? void 0 : _g.returns;
|
|
898
1032
|
return [4 /*yield*/, run_generated_tests({
|
|
@@ -903,37 +1037,37 @@ var tests = {
|
|
|
903
1037
|
create: returnValidation,
|
|
904
1038
|
}
|
|
905
1039
|
})];
|
|
906
|
-
case 6:
|
|
907
|
-
_h.sent();
|
|
908
|
-
_h.label = 7;
|
|
909
1040
|
case 7:
|
|
910
|
-
|
|
911
|
-
|
|
1041
|
+
_h.sent();
|
|
1042
|
+
_h.label = 8;
|
|
912
1043
|
case 8:
|
|
1044
|
+
_i++;
|
|
1045
|
+
return [3 /*break*/, 6];
|
|
1046
|
+
case 9:
|
|
913
1047
|
_c = [];
|
|
914
1048
|
for (_d in tests)
|
|
915
1049
|
_c.push(_d);
|
|
916
1050
|
_e = 0;
|
|
917
|
-
_h.label = 9;
|
|
918
|
-
case 9:
|
|
919
|
-
if (!(_e < _c.length)) return [3 /*break*/, 14];
|
|
920
|
-
t = _c[_e];
|
|
921
1051
|
_h.label = 10;
|
|
922
1052
|
case 10:
|
|
923
|
-
|
|
924
|
-
|
|
1053
|
+
if (!(_e < _c.length)) return [3 /*break*/, 15];
|
|
1054
|
+
t = _c[_e];
|
|
1055
|
+
_h.label = 11;
|
|
925
1056
|
case 11:
|
|
926
|
-
_h.
|
|
927
|
-
return [
|
|
1057
|
+
_h.trys.push([11, 13, , 14]);
|
|
1058
|
+
return [4 /*yield*/, tests[t]()];
|
|
928
1059
|
case 12:
|
|
1060
|
+
_h.sent();
|
|
1061
|
+
return [3 /*break*/, 14];
|
|
1062
|
+
case 13:
|
|
929
1063
|
err_1 = _h.sent();
|
|
930
1064
|
console.error("Error running test:");
|
|
931
1065
|
console.error(err_1);
|
|
932
|
-
return [3 /*break*/,
|
|
933
|
-
case 13:
|
|
934
|
-
_e++;
|
|
935
|
-
return [3 /*break*/, 9];
|
|
1066
|
+
return [3 /*break*/, 14];
|
|
936
1067
|
case 14:
|
|
1068
|
+
_e++;
|
|
1069
|
+
return [3 /*break*/, 10];
|
|
1070
|
+
case 15:
|
|
937
1071
|
process.exit();
|
|
938
1072
|
return [2 /*return*/];
|
|
939
1073
|
}
|