@memberjunction/server 1.0.6 → 1.0.7-next.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/.eslintignore +4 -4
- package/.eslintrc +24 -24
- package/CHANGELOG.json +92 -0
- package/CHANGELOG.md +25 -0
- package/README.md +141 -141
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/entitySubclasses/entityPermissions.server.d.ts +23 -0
- package/dist/entitySubclasses/entityPermissions.server.d.ts.map +1 -0
- package/dist/entitySubclasses/entityPermissions.server.js +99 -0
- package/dist/entitySubclasses/entityPermissions.server.js.map +1 -0
- package/dist/entitySubclasses/userViewEntity.server.js +17 -17
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +10 -10
- package/dist/resolvers/FileCategoryResolver.js +2 -2
- package/dist/resolvers/ReportResolver.js +4 -4
- package/package.json +80 -80
- package/src/apolloServer/TransactionPlugin.ts +57 -57
- package/src/apolloServer/index.ts +33 -33
- package/src/auth/exampleNewUserSubClass.ts +73 -73
- package/src/auth/index.ts +151 -151
- package/src/auth/newUsers.ts +56 -56
- package/src/auth/tokenExpiredError.ts +12 -12
- package/src/cache.ts +10 -10
- package/src/config.ts +89 -84
- package/src/context.ts +119 -119
- package/src/directives/Public.ts +42 -42
- package/src/directives/index.ts +1 -1
- package/src/entitySubclasses/entityPermissions.server.ts +111 -0
- package/src/entitySubclasses/userViewEntity.server.ts +187 -187
- package/src/generated/generated.ts +2573 -2573
- package/src/generic/PushStatusResolver.ts +40 -40
- package/src/generic/ResolverBase.ts +331 -331
- package/src/generic/RunViewResolver.ts +350 -350
- package/src/index.ts +133 -137
- package/src/orm.ts +36 -36
- package/src/resolvers/AskSkipResolver.ts +782 -782
- package/src/resolvers/ColorResolver.ts +72 -72
- package/src/resolvers/DatasetResolver.ts +115 -115
- package/src/resolvers/EntityRecordNameResolver.ts +77 -77
- package/src/resolvers/EntityResolver.ts +37 -37
- package/src/resolvers/FileCategoryResolver.ts +38 -38
- package/src/resolvers/FileResolver.ts +110 -110
- package/src/resolvers/MergeRecordsResolver.ts +198 -198
- package/src/resolvers/PotentialDuplicateRecordResolver.ts +59 -59
- package/src/resolvers/QueryResolver.ts +42 -42
- package/src/resolvers/ReportResolver.ts +131 -131
- package/src/resolvers/UserFavoriteResolver.ts +102 -102
- package/src/resolvers/UserResolver.ts +29 -29
- package/src/resolvers/UserViewResolver.ts +64 -64
- package/src/types.ts +19 -19
- package/src/util.ts +106 -106
- package/tsconfig.json +31 -31
- package/typedoc.json +4 -4
- package/build.log.json +0 -47
package/src/types.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { DataSource, QueryRunner } from 'typeorm';
|
|
3
|
-
|
|
4
|
-
export type UserPayload = {
|
|
5
|
-
email: string;
|
|
6
|
-
userRecord: any;
|
|
7
|
-
sessionId: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type AppContext = {
|
|
11
|
-
dataSource: DataSource;
|
|
12
|
-
userPayload: UserPayload;
|
|
13
|
-
queryRunner?: QueryRunner;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type DirectiveBuilder = {
|
|
17
|
-
typeDefs: string;
|
|
18
|
-
transformer: (schema: GraphQLSchema) => GraphQLSchema;
|
|
19
|
-
};
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { DataSource, QueryRunner } from 'typeorm';
|
|
3
|
+
|
|
4
|
+
export type UserPayload = {
|
|
5
|
+
email: string;
|
|
6
|
+
userRecord: any;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AppContext = {
|
|
11
|
+
dataSource: DataSource;
|
|
12
|
+
userPayload: UserPayload;
|
|
13
|
+
queryRunner?: QueryRunner;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type DirectiveBuilder = {
|
|
17
|
+
typeDefs: string;
|
|
18
|
+
transformer: (schema: GraphQLSchema) => GraphQLSchema;
|
|
19
|
+
};
|
package/src/util.ts
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { request as httpRequest } from 'http';
|
|
2
|
-
import { request as httpsRequest } from 'https';
|
|
3
|
-
import { gzip as gzipCallback, createGunzip } from 'zlib';
|
|
4
|
-
import { promisify } from 'util';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
|
|
7
|
-
const gzip = promisify(gzipCallback);
|
|
8
|
-
|
|
9
|
-
type StreamCallback = (jsonObject: any) => void;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Utility function to handle HTTP/HTTPS requests with optional compression, custom headers, and streaming response callback for JSON objects.
|
|
13
|
-
* This function accumulates data chunks and parses complete JSON objects, assuming newline-delimited JSON in the stream.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} url - The URL to which the request is sent.
|
|
16
|
-
* @param {any} payload - The payload to be sent with the request.
|
|
17
|
-
* @param {boolean} useCompression - Flag to determine if payload compression should be used.
|
|
18
|
-
* @param {Record<string, string> | null} headers - Custom headers for the request. Can be null.
|
|
19
|
-
* @param {StreamCallback} [streamCallback] - Optional callback for handling streaming JSON objects.
|
|
20
|
-
* @returns {Promise<any[]>} - A promise that resolves to an array of all JSON objects received during the streaming process.
|
|
21
|
-
*/
|
|
22
|
-
export async function sendPostRequest(url: string, payload: any, useCompression: boolean, headers: Record<string, string> | null, streamCallback?: StreamCallback): Promise<any[]> {
|
|
23
|
-
return new Promise(async (resolve, reject) => {
|
|
24
|
-
try {
|
|
25
|
-
const { protocol, hostname, port, pathname } = new URL(url);
|
|
26
|
-
let data;
|
|
27
|
-
if (useCompression) {
|
|
28
|
-
try {
|
|
29
|
-
data = await gzip(Buffer.from(JSON.stringify(payload)));
|
|
30
|
-
headers = headers || {}; // Ensure headers is an object
|
|
31
|
-
headers['Content-Encoding'] = 'gzip';
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error(`Error in sendPostRequest while compressing data: ${error && error.message ? error.message : error}`);
|
|
34
|
-
return reject(error);
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
data = Buffer.from(JSON.stringify(payload));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const options = {
|
|
41
|
-
hostname,
|
|
42
|
-
port: port || (protocol === 'https:' ? 443 : 80),
|
|
43
|
-
path: pathname,
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
...headers
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const request = protocol === 'https:' ? httpsRequest : httpRequest;
|
|
52
|
-
const jsonObjects: any[] = [];
|
|
53
|
-
let buffer = '';
|
|
54
|
-
|
|
55
|
-
const req = request(options, (res) => {
|
|
56
|
-
const gunzip = createGunzip();
|
|
57
|
-
const stream = res.headers['content-encoding'] === 'gzip' ? res.pipe(gunzip) : res;
|
|
58
|
-
|
|
59
|
-
stream.on('data', (chunk) => {
|
|
60
|
-
buffer += chunk;
|
|
61
|
-
let boundary;
|
|
62
|
-
while ((boundary = buffer.indexOf('\n')) !== -1) {
|
|
63
|
-
const jsonString = buffer.substring(0, boundary);
|
|
64
|
-
buffer = buffer.substring(boundary + 1);
|
|
65
|
-
try {
|
|
66
|
-
const jsonObject = JSON.parse(jsonString);
|
|
67
|
-
jsonObjects.push(jsonObject);
|
|
68
|
-
streamCallback?.(jsonObject);
|
|
69
|
-
} catch (e) {
|
|
70
|
-
// Handle JSON parse error for cases of malformed JSON objects
|
|
71
|
-
console.warn(`Error in postRequest().stream(data) while parsing JSON object: ${e && e.message ? e.message : e}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
stream.on('end', () => {
|
|
77
|
-
// Attempt to parse any remaining data in buffer in case it's a complete JSON object
|
|
78
|
-
if (buffer.trim()) {
|
|
79
|
-
try {
|
|
80
|
-
const jsonObject = JSON.parse(buffer.trim());
|
|
81
|
-
jsonObjects.push(jsonObject);
|
|
82
|
-
streamCallback?.(jsonObject);
|
|
83
|
-
} catch (e) {
|
|
84
|
-
// Handle JSON parse error for the last chunk
|
|
85
|
-
console.warn(`Error in postRequest().stream(end) while parsing JSON object: ${e && e.message ? e.message : e}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
resolve(jsonObjects);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
req.on('error', (e) => {
|
|
93
|
-
console.error(`Error in sendPostRequest().req.on(error): ${e && e.message ? e.message : e}`)
|
|
94
|
-
reject(e);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
req.write(data);
|
|
98
|
-
req.end();
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
console.error(`Error in sendPostRequest: ${e && e.message ? e.message : e}`)
|
|
102
|
-
reject(e);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
}
|
|
1
|
+
import { request as httpRequest } from 'http';
|
|
2
|
+
import { request as httpsRequest } from 'https';
|
|
3
|
+
import { gzip as gzipCallback, createGunzip } from 'zlib';
|
|
4
|
+
import { promisify } from 'util';
|
|
5
|
+
import { URL } from 'url';
|
|
6
|
+
|
|
7
|
+
const gzip = promisify(gzipCallback);
|
|
8
|
+
|
|
9
|
+
type StreamCallback = (jsonObject: any) => void;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utility function to handle HTTP/HTTPS requests with optional compression, custom headers, and streaming response callback for JSON objects.
|
|
13
|
+
* This function accumulates data chunks and parses complete JSON objects, assuming newline-delimited JSON in the stream.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} url - The URL to which the request is sent.
|
|
16
|
+
* @param {any} payload - The payload to be sent with the request.
|
|
17
|
+
* @param {boolean} useCompression - Flag to determine if payload compression should be used.
|
|
18
|
+
* @param {Record<string, string> | null} headers - Custom headers for the request. Can be null.
|
|
19
|
+
* @param {StreamCallback} [streamCallback] - Optional callback for handling streaming JSON objects.
|
|
20
|
+
* @returns {Promise<any[]>} - A promise that resolves to an array of all JSON objects received during the streaming process.
|
|
21
|
+
*/
|
|
22
|
+
export async function sendPostRequest(url: string, payload: any, useCompression: boolean, headers: Record<string, string> | null, streamCallback?: StreamCallback): Promise<any[]> {
|
|
23
|
+
return new Promise(async (resolve, reject) => {
|
|
24
|
+
try {
|
|
25
|
+
const { protocol, hostname, port, pathname } = new URL(url);
|
|
26
|
+
let data;
|
|
27
|
+
if (useCompression) {
|
|
28
|
+
try {
|
|
29
|
+
data = await gzip(Buffer.from(JSON.stringify(payload)));
|
|
30
|
+
headers = headers || {}; // Ensure headers is an object
|
|
31
|
+
headers['Content-Encoding'] = 'gzip';
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`Error in sendPostRequest while compressing data: ${error && error.message ? error.message : error}`);
|
|
34
|
+
return reject(error);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
data = Buffer.from(JSON.stringify(payload));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const options = {
|
|
41
|
+
hostname,
|
|
42
|
+
port: port || (protocol === 'https:' ? 443 : 80),
|
|
43
|
+
path: pathname,
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
...headers
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const request = protocol === 'https:' ? httpsRequest : httpRequest;
|
|
52
|
+
const jsonObjects: any[] = [];
|
|
53
|
+
let buffer = '';
|
|
54
|
+
|
|
55
|
+
const req = request(options, (res) => {
|
|
56
|
+
const gunzip = createGunzip();
|
|
57
|
+
const stream = res.headers['content-encoding'] === 'gzip' ? res.pipe(gunzip) : res;
|
|
58
|
+
|
|
59
|
+
stream.on('data', (chunk) => {
|
|
60
|
+
buffer += chunk;
|
|
61
|
+
let boundary;
|
|
62
|
+
while ((boundary = buffer.indexOf('\n')) !== -1) {
|
|
63
|
+
const jsonString = buffer.substring(0, boundary);
|
|
64
|
+
buffer = buffer.substring(boundary + 1);
|
|
65
|
+
try {
|
|
66
|
+
const jsonObject = JSON.parse(jsonString);
|
|
67
|
+
jsonObjects.push(jsonObject);
|
|
68
|
+
streamCallback?.(jsonObject);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// Handle JSON parse error for cases of malformed JSON objects
|
|
71
|
+
console.warn(`Error in postRequest().stream(data) while parsing JSON object: ${e && e.message ? e.message : e}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
stream.on('end', () => {
|
|
77
|
+
// Attempt to parse any remaining data in buffer in case it's a complete JSON object
|
|
78
|
+
if (buffer.trim()) {
|
|
79
|
+
try {
|
|
80
|
+
const jsonObject = JSON.parse(buffer.trim());
|
|
81
|
+
jsonObjects.push(jsonObject);
|
|
82
|
+
streamCallback?.(jsonObject);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
// Handle JSON parse error for the last chunk
|
|
85
|
+
console.warn(`Error in postRequest().stream(end) while parsing JSON object: ${e && e.message ? e.message : e}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
resolve(jsonObjects);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
req.on('error', (e) => {
|
|
93
|
+
console.error(`Error in sendPostRequest().req.on(error): ${e && e.message ? e.message : e}`)
|
|
94
|
+
reject(e);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
req.write(data);
|
|
98
|
+
req.end();
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(`Error in sendPostRequest: ${e && e.message ? e.message : e}`)
|
|
102
|
+
reject(e);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"target": "es2020",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"composite": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"lib": ["es2020", "esnext.asynciterable"],
|
|
14
|
-
"moduleResolution": "node",
|
|
15
|
-
"removeComments": true,
|
|
16
|
-
"noImplicitAny": false,
|
|
17
|
-
"strictNullChecks": false,
|
|
18
|
-
"strictFunctionTypes": true,
|
|
19
|
-
"noImplicitThis": true,
|
|
20
|
-
"noUnusedLocals": false,
|
|
21
|
-
"noUnusedParameters": false,
|
|
22
|
-
"noImplicitReturns": true,
|
|
23
|
-
"noFallthroughCasesInSwitch": true,
|
|
24
|
-
"allowSyntheticDefaultImports": true,
|
|
25
|
-
"emitDecoratorMetadata": true,
|
|
26
|
-
"skipLibCheck": true,
|
|
27
|
-
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
|
28
|
-
},
|
|
29
|
-
"exclude": ["node_modules"],
|
|
30
|
-
"include": ["./src/**/*.ts"]
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "es2020",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"composite": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"lib": ["es2020", "esnext.asynciterable"],
|
|
14
|
+
"moduleResolution": "node",
|
|
15
|
+
"removeComments": true,
|
|
16
|
+
"noImplicitAny": false,
|
|
17
|
+
"strictNullChecks": false,
|
|
18
|
+
"strictFunctionTypes": true,
|
|
19
|
+
"noImplicitThis": true,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"noUnusedParameters": false,
|
|
22
|
+
"noImplicitReturns": true,
|
|
23
|
+
"noFallthroughCasesInSwitch": true,
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"emitDecoratorMetadata": true,
|
|
26
|
+
"skipLibCheck": true,
|
|
27
|
+
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
|
28
|
+
},
|
|
29
|
+
"exclude": ["node_modules"],
|
|
30
|
+
"include": ["./src/**/*.ts"]
|
|
31
|
+
}
|
package/typedoc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["../../typedoc.base.json"],
|
|
3
|
-
"entryPoints": ["src/index.ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../typedoc.base.json"],
|
|
3
|
+
"entryPoints": ["src/index.ts"]
|
|
4
|
+
}
|
package/build.log.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"buildTime": "2024-03-31T11:10:27.76538-05:00"
|
|
4
|
-
},
|
|
5
|
-
{
|
|
6
|
-
"buildTime": "2024-03-31T16:29:21.3000942-05:00"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"buildTime": "2024-03-31T16:47:35.1241895-05:00"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"buildTime": "2024-03-31T19:42:48.6285938-05:00"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"buildTime": "2024-04-01T20:21:20.3243467-05:00"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"buildTime": "2024-04-02T21:12:24.8458623-05:00"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"buildTime": "2024-04-03T16:39:10.9996496-05:00"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"buildTime": "2024-04-03T17:36:01.6321538-05:00"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"buildTime": "2024-04-03T18:47:41.8215356-05:00"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"buildTime": "2024-04-03T21:04:36.4408346-05:00"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"buildTime": "2024-04-03T21:18:18.1700679-05:00"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"buildTime": "2024-04-07T09:42:50.8731603-05:00"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"buildTime": "2024-04-07T10:02:26.0819429-05:00"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"buildTime": "2024-04-08T17:20:24.6852763-05:00"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"buildTime": "2024-04-08T19:32:52.0831924-05:00"
|
|
46
|
-
}
|
|
47
|
-
]
|