@vocollege/app 0.0.134 → 0.0.136
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/global.d.ts +7 -7
- package/dist/interceptor.js +1 -1
- package/dist/modules/Services/Vapor/Vapor.js +4 -4
- package/dist/modules/VoApi/GraphClient.d.ts +1 -0
- package/dist/modules/VoApi/GraphClient.js +59 -3
- package/dist/modules/VoApi/VoApi.d.ts +1 -1
- package/dist/modules/VoApi/VoApi.js +1 -1
- package/dist/modules/VoAuth.js +2 -1
- package/dist/modules/VoConfig.d.ts +1 -1
- package/dist/modules/VoConfig.js +1 -0
- package/dist/modules/VoDocs/VoDocs.d.ts +1 -1
- package/dist/modules/VoDocs/VoDocs.js +4 -4
- package/dist/modules/VoHelpers.d.ts +4 -4
- package/dist/modules/VoHelpers.js +2 -2
- package/dist/modules/VoRouter.d.ts +1 -1
- package/dist/modules/VoUtils_REMOVE.d.ts +2 -2
- package/package.json +2 -2
- package/src/modules/VoApi/GraphClient.ts +72 -3
- package/src/modules/VoAuth.ts +1 -0
- package/src/modules/VoConfig.ts +1 -0
package/dist/global.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AuthStorageConfigType = {
|
|
2
2
|
STATE: string;
|
|
3
3
|
VERIFIER: string;
|
|
4
4
|
REFRESH_TOKEN: string;
|
|
5
5
|
ACCESS_TOKEN: string;
|
|
6
6
|
TOKEN_TYPE: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type AuthConfigType = {
|
|
9
9
|
BASE_URL: string;
|
|
10
10
|
CLIENT_ID?: string;
|
|
11
11
|
LOGIN?: string;
|
|
12
12
|
ENDPOINT?: string;
|
|
13
13
|
STORAGE?: AuthStorageConfigType;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type ApiConfigType = {
|
|
16
16
|
BASE_URL: string;
|
|
17
17
|
ENDPOINT?: string;
|
|
18
18
|
GRAPHQL?: string;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type AppConfigType = {
|
|
21
21
|
BASE_URL: string;
|
|
22
22
|
AUTH?: string;
|
|
23
23
|
HOME?: string;
|
|
24
24
|
LOGIN?: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type VoAppType = {
|
|
27
27
|
configure: Function;
|
|
28
28
|
config?: Function;
|
|
29
29
|
auth: any;
|
|
30
30
|
api: any;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type VoTokenType = {
|
|
33
33
|
access_token: string;
|
|
34
34
|
refresh_token: string;
|
|
35
35
|
};
|
|
36
36
|
export interface GeneralObject {
|
|
37
37
|
[key: string]: any;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type TypeNullObject = null | GeneralObject;
|
package/dist/interceptor.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -28,7 +28,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
28
28
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
29
|
function step(op) {
|
|
30
30
|
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
32
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
33
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
34
|
switch (op[0]) {
|
|
@@ -69,10 +69,10 @@ var Vapor = /** @class */ (function () {
|
|
|
69
69
|
/**
|
|
70
70
|
* Store a file in S3 and return its UUID, key, and other information.
|
|
71
71
|
*/
|
|
72
|
-
Vapor.prototype.store = function (
|
|
73
|
-
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
Vapor.prototype.store = function (file_1) {
|
|
73
|
+
return __awaiter(this, arguments, void 0, function (file, options) {
|
|
75
74
|
var response, instance, headers, cancelToken;
|
|
75
|
+
if (options === void 0) { options = {}; }
|
|
76
76
|
return __generator(this, function (_a) {
|
|
77
77
|
switch (_a.label) {
|
|
78
78
|
case 0: return [4 /*yield*/, axios_1.default.post(
|
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -137,12 +137,28 @@ var GraphClient = /** @class */ (function () {
|
|
|
137
137
|
// "field",
|
|
138
138
|
// ],
|
|
139
139
|
// },
|
|
140
|
+
ValidigGeneralSurveyRow: {
|
|
141
|
+
fields: {
|
|
142
|
+
options: {
|
|
143
|
+
read: function (existing) {
|
|
144
|
+
return existing ? JSON.parse(existing) : existing;
|
|
145
|
+
},
|
|
146
|
+
// merge(existing = "", incoming: "") {
|
|
147
|
+
// console.log("existing", existing);
|
|
148
|
+
// console.log("incoming", incoming);
|
|
149
|
+
// // return [...existing, ...incoming];
|
|
150
|
+
// return incoming;
|
|
151
|
+
// },
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
140
155
|
},
|
|
141
156
|
}),
|
|
142
157
|
link: (0, client_1.from)([
|
|
143
158
|
links.errorLink,
|
|
144
159
|
links.authLink,
|
|
145
160
|
links.omitTypenameLink,
|
|
161
|
+
links.transformVariablesLink,
|
|
146
162
|
httpLink,
|
|
147
163
|
]),
|
|
148
164
|
});
|
|
@@ -206,10 +222,14 @@ var GraphClient = /** @class */ (function () {
|
|
|
206
222
|
if (masquerade) {
|
|
207
223
|
masquerade = JSON.parse(masquerade);
|
|
208
224
|
}
|
|
209
|
-
|
|
225
|
+
var userLicensee = VoHelpers_1.localStorage.get(VoConfig_1.default.get.USER_LICENSEE);
|
|
226
|
+
if (userLicensee) {
|
|
227
|
+
userLicensee = JSON.parse(userLicensee);
|
|
228
|
+
}
|
|
229
|
+
operation.setContext(function () { return (__assign(__assign({}, currentHeaders), { headers: __assign(__assign({ Authorization: token
|
|
210
230
|
? // ? `${token.token_type} ${token.access_token}`
|
|
211
231
|
"Bearer ".concat(token.access_token)
|
|
212
|
-
: "", VoGroup: groupId }, (masquerade && { VoMasquerade: masquerade === null || masquerade === void 0 ? void 0 : masquerade.id })) })); });
|
|
232
|
+
: "", VoGroup: groupId }, (masquerade && { VoMasquerade: masquerade === null || masquerade === void 0 ? void 0 : masquerade.id })), (userLicensee && { VoLicensee: userLicensee })) })); });
|
|
213
233
|
return forward(operation);
|
|
214
234
|
});
|
|
215
235
|
var omitTypenameLink = new client_1.ApolloLink(function (operation, forward) {
|
|
@@ -218,10 +238,46 @@ var GraphClient = /** @class */ (function () {
|
|
|
218
238
|
}
|
|
219
239
|
return forward(operation);
|
|
220
240
|
});
|
|
241
|
+
var transformVariablesLink = new client_1.ApolloLink(function (operation, forward) {
|
|
242
|
+
var operationName = operation.operationName, variables = operation.variables;
|
|
243
|
+
switch (operationName) {
|
|
244
|
+
// Manipulate fields on GeneralSurvey.
|
|
245
|
+
case "CreateGeneralSurvey":
|
|
246
|
+
case "UpdateGeneralSurvey":
|
|
247
|
+
Object.keys(variables.input)
|
|
248
|
+
.filter(function (key) { return Array.isArray(variables.input[key]); })
|
|
249
|
+
.map(function (key) {
|
|
250
|
+
// JSON stringify GeneralSurveyRow.options.
|
|
251
|
+
variables.input[key]
|
|
252
|
+
.filter(function (v) { return v === null || v === void 0 ? void 0 : v.options; })
|
|
253
|
+
.map(function (v) {
|
|
254
|
+
if (v.options) {
|
|
255
|
+
v.options = JSON.stringify(v.options);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
// Traverse the variables and convert objects to JSON strings as needed
|
|
262
|
+
// const transformVariables = (vars) => {
|
|
263
|
+
// if (!vars || typeof vars !== 'object') return vars;
|
|
264
|
+
// return Object.keys(vars).reduce((acc, key) => {
|
|
265
|
+
// const value = vars[key];
|
|
266
|
+
// // Check if the value is an object that needs conversion
|
|
267
|
+
// acc[key] = value && typeof value === 'object' && !(value instanceof Array)
|
|
268
|
+
// ? JSON.stringify(value)
|
|
269
|
+
// : value;
|
|
270
|
+
// return acc;
|
|
271
|
+
// }, {});
|
|
272
|
+
// };
|
|
273
|
+
// operation.variables = transformVariables(variables);
|
|
274
|
+
return forward(operation);
|
|
275
|
+
});
|
|
221
276
|
return {
|
|
222
277
|
errorLink: errorLink,
|
|
223
278
|
authLink: authLink,
|
|
224
279
|
omitTypenameLink: omitTypenameLink,
|
|
280
|
+
transformVariablesLink: transformVariablesLink,
|
|
225
281
|
};
|
|
226
282
|
};
|
|
227
283
|
return GraphClient;
|
|
@@ -6,7 +6,7 @@ declare class VoApi extends VoBase {
|
|
|
6
6
|
init(params?: GeneralObject): void;
|
|
7
7
|
get getGraphqlUrl(): string;
|
|
8
8
|
get getGraphqlSubscriptionUrl(): string;
|
|
9
|
-
getUser(): Promise<import("axios").AxiosResponse<any>>;
|
|
9
|
+
getUser(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
10
|
logout(): Promise<boolean>;
|
|
11
11
|
}
|
|
12
12
|
declare const _default: VoApi;
|
|
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
29
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
30
|
function step(op) {
|
|
31
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
35
|
switch (op[0]) {
|
package/dist/modules/VoAuth.js
CHANGED
|
@@ -52,7 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
53
|
function step(op) {
|
|
54
54
|
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
55
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
56
56
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
57
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
58
|
switch (op[0]) {
|
|
@@ -238,6 +238,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
238
238
|
});
|
|
239
239
|
Helpers.localStorage.remove(VoConfig_1.default.get.CURRENT_GROUP || "");
|
|
240
240
|
Helpers.localStorage.remove(VoConfig_1.default.get.MASQUERADE_USER || "");
|
|
241
|
+
Helpers.localStorage.remove(VoConfig_1.default.get.USER_LICENSEE || "");
|
|
241
242
|
delete axios_1.default.defaults.headers.common["Authorization"];
|
|
242
243
|
};
|
|
243
244
|
VoAuth.prototype.refreshToken = function () {
|
package/dist/modules/VoConfig.js
CHANGED
|
@@ -3,7 +3,7 @@ declare class VoDocs extends VoBase {
|
|
|
3
3
|
graphqlClient: any;
|
|
4
4
|
init(): void;
|
|
5
5
|
get getGraphqlUrl(): string;
|
|
6
|
-
getTemporaryFileUrl(id: string, publicDownload?: boolean): Promise<import("axios").AxiosResponse<any>>;
|
|
6
|
+
getTemporaryFileUrl(id: string, publicDownload?: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: VoDocs;
|
|
9
9
|
export default _default;
|
|
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
29
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
30
|
function step(op) {
|
|
31
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
35
|
switch (op[0]) {
|
|
@@ -77,10 +77,10 @@ var VoDocs = /** @class */ (function (_super) {
|
|
|
77
77
|
enumerable: false,
|
|
78
78
|
configurable: true
|
|
79
79
|
});
|
|
80
|
-
VoDocs.prototype.getTemporaryFileUrl = function (
|
|
81
|
-
|
|
82
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
VoDocs.prototype.getTemporaryFileUrl = function (id_1) {
|
|
81
|
+
return __awaiter(this, arguments, void 0, function (id, publicDownload) {
|
|
83
82
|
var currentGroup, endpoint, url;
|
|
83
|
+
if (publicDownload === void 0) { publicDownload = false; }
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
try {
|
|
86
86
|
currentGroup = VoGroups_1.default.getCurrent(true);
|
|
@@ -7,7 +7,7 @@ export declare const localStorage: {
|
|
|
7
7
|
get: (key: string) => string | false | null;
|
|
8
8
|
remove: (key: string) => true | undefined;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type encodeQueryDataType = {
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
export declare const encodeQueryData: (data: encodeQueryDataType) => string;
|
|
@@ -20,7 +20,7 @@ export declare const regexPatterns: {
|
|
|
20
20
|
personalNumber: RegExp;
|
|
21
21
|
orgnr: RegExp;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
type errorObjectType = {
|
|
24
24
|
message: string;
|
|
25
25
|
fields?: {
|
|
26
26
|
[key: string]: any;
|
|
@@ -33,8 +33,8 @@ export declare const wrapPromise: (promise: any) => {
|
|
|
33
33
|
read: () => any;
|
|
34
34
|
};
|
|
35
35
|
export declare const downloadFile: (url: string) => void;
|
|
36
|
-
export declare const orderByPosition: (a: any, b: any) =>
|
|
37
|
-
export declare const orderByField: (a: any, b: any, field: string) =>
|
|
36
|
+
export declare const orderByPosition: (a: any, b: any) => 0 | 1 | -1;
|
|
37
|
+
export declare const orderByField: (a: any, b: any, field: string) => 0 | 1 | -1;
|
|
38
38
|
export declare const shortenText: (str: string, limit?: number, stripHtml?: boolean, addEllipsis?: boolean) => string;
|
|
39
39
|
export declare const getImageContact: (item: any, width?: number, height?: number) => string;
|
|
40
40
|
export declare const getImage: (item: any, width: number, height: number, field?: string) => string;
|
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -121,7 +121,7 @@ exports.regexPatterns = {
|
|
|
121
121
|
username: /(^[a-z]{3,})([\.]|[\_]|[\-]|[a-z]|[0-9]?)+$/,
|
|
122
122
|
email: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
123
123
|
stringNonDigit: /^[^0-9]+$/,
|
|
124
|
-
password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/,
|
|
124
|
+
password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/, // At least 8 characters, 1 uppercase, 1 lowercase and 1 digit.
|
|
125
125
|
cleanName: /(^[a-z]{1,})(\w|-?)+$/,
|
|
126
126
|
personalNumber: /^(\d{8})[-]\d{4}$/,
|
|
127
127
|
orgnr: /^(\d{6})[-]\d{4}$/,
|
|
@@ -6,7 +6,7 @@ declare const localStorage: {
|
|
|
6
6
|
get: (key: string) => string | false | null;
|
|
7
7
|
remove: (key: string) => true | undefined;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type encodeQueryDataType = {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
declare const encodeQueryData: (data: encodeQueryDataType) => string;
|
|
@@ -16,7 +16,7 @@ declare const regexPatterns: {
|
|
|
16
16
|
stringNonDigit: RegExp;
|
|
17
17
|
password: RegExp;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type errorObjectType = {
|
|
20
20
|
message: string;
|
|
21
21
|
fields?: {
|
|
22
22
|
[key: string]: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocollege/app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.136",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"graphql": "^14.0.0 || ^15.0.0",
|
|
40
40
|
"he": "^1.2.0",
|
|
41
41
|
"js-cookie": "^3.0.1",
|
|
42
|
-
"react": "^18.1
|
|
42
|
+
"react": "^18.3.1",
|
|
43
43
|
"react-toastify": "^8.0.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -26,7 +26,7 @@ class GraphClient {
|
|
|
26
26
|
static createGraphClient(
|
|
27
27
|
url: string,
|
|
28
28
|
uploadLink = false,
|
|
29
|
-
params: GeneralObject = {}
|
|
29
|
+
params: GeneralObject = {},
|
|
30
30
|
) {
|
|
31
31
|
let httpLink;
|
|
32
32
|
|
|
@@ -91,12 +91,30 @@ class GraphClient {
|
|
|
91
91
|
// "field",
|
|
92
92
|
// ],
|
|
93
93
|
// },
|
|
94
|
+
|
|
95
|
+
ValidigGeneralSurveyRow: {
|
|
96
|
+
fields: {
|
|
97
|
+
options: {
|
|
98
|
+
read(existing) {
|
|
99
|
+
return existing ? JSON.parse(existing) : existing;
|
|
100
|
+
},
|
|
101
|
+
// merge(existing = "", incoming: "") {
|
|
102
|
+
// console.log("existing", existing);
|
|
103
|
+
// console.log("incoming", incoming);
|
|
104
|
+
|
|
105
|
+
// // return [...existing, ...incoming];
|
|
106
|
+
// return incoming;
|
|
107
|
+
// },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
94
111
|
},
|
|
95
112
|
}),
|
|
96
113
|
link: from([
|
|
97
114
|
links.errorLink,
|
|
98
115
|
links.authLink,
|
|
99
116
|
links.omitTypenameLink,
|
|
117
|
+
links.transformVariablesLink,
|
|
100
118
|
httpLink,
|
|
101
119
|
]),
|
|
102
120
|
});
|
|
@@ -146,7 +164,7 @@ class GraphClient {
|
|
|
146
164
|
// redirect();
|
|
147
165
|
// }
|
|
148
166
|
}
|
|
149
|
-
}
|
|
167
|
+
},
|
|
150
168
|
);
|
|
151
169
|
|
|
152
170
|
// Create authLink that ensures that all calls include
|
|
@@ -168,6 +186,12 @@ class GraphClient {
|
|
|
168
186
|
masquerade = JSON.parse(masquerade);
|
|
169
187
|
}
|
|
170
188
|
|
|
189
|
+
let userLicensee: any = localStorage.get(VoConfig.get.USER_LICENSEE);
|
|
190
|
+
|
|
191
|
+
if (userLicensee) {
|
|
192
|
+
userLicensee = JSON.parse(userLicensee);
|
|
193
|
+
}
|
|
194
|
+
|
|
171
195
|
operation.setContext(() => ({
|
|
172
196
|
...currentHeaders,
|
|
173
197
|
headers: {
|
|
@@ -177,6 +201,7 @@ class GraphClient {
|
|
|
177
201
|
: "",
|
|
178
202
|
VoGroup: groupId,
|
|
179
203
|
...(masquerade && { VoMasquerade: masquerade?.id }),
|
|
204
|
+
...(userLicensee && { VoLicensee: userLicensee }),
|
|
180
205
|
},
|
|
181
206
|
}));
|
|
182
207
|
return forward(operation);
|
|
@@ -186,16 +211,60 @@ class GraphClient {
|
|
|
186
211
|
if (operation.variables) {
|
|
187
212
|
operation.variables = JSON.parse(
|
|
188
213
|
JSON.stringify(operation.variables),
|
|
189
|
-
(key, value) => (key === "__typename" ? undefined : value)
|
|
214
|
+
(key, value) => (key === "__typename" ? undefined : value),
|
|
190
215
|
);
|
|
191
216
|
}
|
|
192
217
|
return forward(operation);
|
|
193
218
|
});
|
|
194
219
|
|
|
220
|
+
const transformVariablesLink = new ApolloLink((operation, forward) => {
|
|
221
|
+
const { operationName, variables } = operation;
|
|
222
|
+
|
|
223
|
+
switch (operationName) {
|
|
224
|
+
// Manipulate fields on GeneralSurvey.
|
|
225
|
+
case "CreateGeneralSurvey":
|
|
226
|
+
case "UpdateGeneralSurvey":
|
|
227
|
+
Object.keys(variables.input)
|
|
228
|
+
.filter((key: string) => Array.isArray(variables.input[key]))
|
|
229
|
+
.map((key: string) => {
|
|
230
|
+
// JSON stringify GeneralSurveyRow.options.
|
|
231
|
+
variables.input[key]
|
|
232
|
+
.filter((v: GeneralObject) => v?.options)
|
|
233
|
+
.map((v: GeneralObject) => {
|
|
234
|
+
if (v.options) {
|
|
235
|
+
v.options = JSON.stringify(v.options);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Traverse the variables and convert objects to JSON strings as needed
|
|
243
|
+
// const transformVariables = (vars) => {
|
|
244
|
+
// if (!vars || typeof vars !== 'object') return vars;
|
|
245
|
+
|
|
246
|
+
// return Object.keys(vars).reduce((acc, key) => {
|
|
247
|
+
// const value = vars[key];
|
|
248
|
+
|
|
249
|
+
// // Check if the value is an object that needs conversion
|
|
250
|
+
// acc[key] = value && typeof value === 'object' && !(value instanceof Array)
|
|
251
|
+
// ? JSON.stringify(value)
|
|
252
|
+
// : value;
|
|
253
|
+
|
|
254
|
+
// return acc;
|
|
255
|
+
// }, {});
|
|
256
|
+
// };
|
|
257
|
+
|
|
258
|
+
// operation.variables = transformVariables(variables);
|
|
259
|
+
|
|
260
|
+
return forward(operation);
|
|
261
|
+
});
|
|
262
|
+
|
|
195
263
|
return {
|
|
196
264
|
errorLink,
|
|
197
265
|
authLink,
|
|
198
266
|
omitTypenameLink,
|
|
267
|
+
transformVariablesLink,
|
|
199
268
|
};
|
|
200
269
|
}
|
|
201
270
|
|
package/src/modules/VoAuth.ts
CHANGED
|
@@ -144,6 +144,7 @@ class VoAuth extends VoBase {
|
|
|
144
144
|
|
|
145
145
|
Helpers.localStorage.remove(VoConfig.get.CURRENT_GROUP || "");
|
|
146
146
|
Helpers.localStorage.remove(VoConfig.get.MASQUERADE_USER || "");
|
|
147
|
+
Helpers.localStorage.remove(VoConfig.get.USER_LICENSEE || "");
|
|
147
148
|
|
|
148
149
|
delete axios.defaults.headers.common["Authorization"];
|
|
149
150
|
}
|