@bwi-mentorspaces/application-utils-npm 0.0.12 → 0.0.15

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.
@@ -1,6 +1,19 @@
1
1
  import { User, StreamChat, PartialUserUpdate, UserFilters } from "stream-chat";
2
2
  import { IUserResponse } from "./models";
3
3
  import { StreamBase } from "./stream.base";
4
+ /**
5
+ * Necessary user information on a getStream user
6
+ */
7
+ interface IUserInfo {
8
+ email: string;
9
+ firstName: string;
10
+ lastName: string;
11
+ avatar: string;
12
+ name: string;
13
+ headline: string;
14
+ pronouns: string;
15
+ companyHeadline: string;
16
+ }
4
17
  /**
5
18
  * Channel Api declarations
6
19
  */
@@ -38,6 +51,23 @@ export declare class StreamUser extends StreamBase implements IStreamUser {
38
51
  * @returns {Promise<boolean>} promise of the type boolean
39
52
  */
40
53
  partialUpdateUsers(usersUpdate: PartialUserUpdate[]): Promise<boolean>;
54
+ /**
55
+ * Create GetStream user
56
+ *
57
+ * @param {userRef} userRef the MS userRef
58
+ * @param {info} userInfo user info object
59
+ * @returns {Promise<boolean>} promise of the type boolean
60
+ */
61
+ createUser(userRef: string, userInfo: IUserInfo): Promise<boolean>;
62
+ /**
63
+ * Delete stream user
64
+ * https://getstream.io/chat/docs/node/update_users/?language=javascript#delete-a-user
65
+ *
66
+ * @param {User} user user id (uuid) to be deleted
67
+ * @param {boolean} isHard Boolean to make operator a hard delete or not
68
+ * @returns {Promise<boolean>} promise of the type boolean
69
+ */
70
+ deleteUser(user: User, isHard?: boolean): Promise<boolean>;
41
71
  /**
42
72
  * Query stream users.
43
73
  *
@@ -70,6 +70,58 @@ class StreamUser extends stream_base_1.StreamBase {
70
70
  }
71
71
  });
72
72
  }
73
+ /**
74
+ * Create GetStream user
75
+ *
76
+ * @param {userRef} userRef the MS userRef
77
+ * @param {info} userInfo user info object
78
+ * @returns {Promise<boolean>} promise of the type boolean
79
+ */
80
+ createUser(userRef, userInfo) {
81
+ const _super = Object.create(null, {
82
+ server: { get: () => super.server }
83
+ });
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const payload = Object.create(userInfo);
86
+ payload.id = userRef;
87
+ payload.role = "user";
88
+ const r = yield _super.server.upsertUser(payload);
89
+ //check the result
90
+ if (r) {
91
+ return true;
92
+ }
93
+ else {
94
+ return false;
95
+ }
96
+ });
97
+ }
98
+ /**
99
+ * Delete stream user
100
+ * https://getstream.io/chat/docs/node/update_users/?language=javascript#delete-a-user
101
+ *
102
+ * @param {User} user user id (uuid) to be deleted
103
+ * @param {boolean} isHard Boolean to make operator a hard delete or not
104
+ * @returns {Promise<boolean>} promise of the type boolean
105
+ */
106
+ deleteUser(user, isHard) {
107
+ const _super = Object.create(null, {
108
+ server: { get: () => super.server }
109
+ });
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ //Execute the sync
112
+ const r = yield _super.server.deleteUser(user.id, {
113
+ hard_delete: isHard,
114
+ delete_conversation_channels: true
115
+ });
116
+ //check the result
117
+ if (r) {
118
+ return true;
119
+ }
120
+ else {
121
+ return false;
122
+ }
123
+ });
124
+ }
73
125
  /**
74
126
  * Query stream users.
75
127
  *
@@ -1 +1 @@
1
- {"version":3,"file":"stream.user.js","sourceRoot":"","sources":["../../../chat/stream/stream.user.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,+CAA2C;AAiB3C;;GAEG;AACH,MAAa,UAAW,SAAQ,wBAAU;IACtC,aAAa;IAEb;;;;OAIG;IACH,YAAY,MAAkB;QAC1B,KAAK,EAAE,CAAC;QACR,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,UAAU;IAEV;;;;;OAKG;IACG,QAAQ,CAAC,KAAa;;;;;YACxB,kBAAkB;YAClB,MAAM,CAAC,GAAG,MAAM,OAAM,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAChD,kBAAkB;YAClB,IAAI,CAAC,EAAE;gBACH,OAAO,IAAI,CAAC;aACf;iBAAM;gB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AClB,IAAI,CAAC,EAAE;gBACH,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC;KAAA;IAED;;;;;;OAMG;IACG,UAAU,CAAC,OAAe,EAAE,QAAmB;;;;;YACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACvC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAA;YACpB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;YACrB,MAAM,CAAC,GAAG,MAAM,OAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACjD,kBAAkB;YAClB,IAAI,CAAC,EAAE;gBACH,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC;KAAA;IAGD;;;;;;;OAOG;IACG,UAAU,CAAC,IAAU,EAAE,MAAgB;;;;;YACzC,kBAAkB;YAClB,MAAM,CAAC,GAAG,MAAM,OAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE;gBAC7C,WAAW,EAAE,MAAM;gBACnB,4BAA4B,EAAE,IAAI;aACrC,CAAC,CAAC;YACH,kBAAkB;YAClB,IAAI,CAAC,EAAE;gBACH,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC;KAAA;IAED;;;;;OAKG;IACG,UAAU,CAAC,IAAiB;;;;;YAC9B,wBAAwB;YACxB,MAAM,CAAC,GAAG,MAAM,OAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAE9C,OAAO,CAAC,CAAC,KAAK,CAAC;QACnB,CAAC;KAAA;CACJ;AAxGD,gCAwGC"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="express-serve-static-core" />
1
2
  /**
2
3
  * Serverless handler declarations
3
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bwi-mentorspaces/application-utils-npm",
3
- "version": "0.0.12",
3
+ "version": "0.0.15",
4
4
  "description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
5
5
  "author": {
6
6
  "name": "Mentor Spaces",
@@ -13,7 +13,7 @@
13
13
  "compile": "tsc --build",
14
14
  "test": "jest",
15
15
  "build:local": "npm-run-all clean lint compile",
16
- "build": "npm-run-all clean lint patch compile",
16
+ "build": "npm-run-all clean patch compile",
17
17
  "deploy": "npm publish .dist --access public"
18
18
  },
19
19
  "devDependencies": {