@memberjunction/server 2.1.2 → 2.1.3
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/apolloServer/TransactionPlugin.d.ts +4 -0
- package/dist/apolloServer/TransactionPlugin.d.ts.map +1 -0
- package/dist/apolloServer/TransactionPlugin.js +46 -0
- package/dist/apolloServer/TransactionPlugin.js.map +1 -0
- package/dist/apolloServer/index.d.ts +11 -0
- package/dist/apolloServer/index.d.ts.map +1 -0
- package/dist/apolloServer/index.js +25 -0
- package/dist/apolloServer/index.js.map +1 -0
- package/dist/auth/exampleNewUserSubClass.d.ts +6 -0
- package/dist/auth/exampleNewUserSubClass.d.ts.map +1 -0
- package/dist/auth/exampleNewUserSubClass.js +49 -0
- package/dist/auth/exampleNewUserSubClass.js.map +1 -0
- package/dist/auth/index.d.ts +30 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +121 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/newUsers.d.ts +5 -0
- package/dist/auth/newUsers.d.ts.map +1 -0
- package/{src/auth/newUsers.ts → dist/auth/newUsers.js} +20 -14
- package/dist/auth/newUsers.js.map +1 -0
- package/dist/auth/tokenExpiredError.d.ts +5 -0
- package/dist/auth/tokenExpiredError.d.ts.map +1 -0
- package/dist/auth/tokenExpiredError.js +12 -0
- package/dist/auth/tokenExpiredError.js.map +1 -0
- package/dist/cache.d.ts +3 -0
- package/dist/cache.d.ts.map +1 -0
- package/{src/cache.ts → dist/cache.js} +4 -6
- package/dist/cache.js.map +1 -0
- package/dist/config.d.ts +196 -0
- package/dist/config.d.ts.map +1 -0
- package/{src/config.ts → dist/config.js} +25 -49
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +17 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +84 -0
- package/dist/context.js.map +1 -0
- package/dist/directives/Public.d.ts +4 -0
- package/dist/directives/Public.d.ts.map +1 -0
- package/dist/directives/Public.js +30 -0
- package/dist/directives/Public.js.map +1 -0
- package/dist/directives/index.d.ts +2 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/directives/index.js +2 -0
- package/dist/directives/index.js.map +1 -0
- package/dist/entitySubclasses/DuplicateRunEntity.server.d.ts +6 -0
- package/dist/entitySubclasses/DuplicateRunEntity.server.d.ts.map +1 -0
- package/dist/entitySubclasses/DuplicateRunEntity.server.js +33 -0
- package/dist/entitySubclasses/DuplicateRunEntity.server.js.map +1 -0
- 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 +93 -0
- package/dist/entitySubclasses/entityPermissions.server.js.map +1 -0
- package/dist/entitySubclasses/userViewEntity.server.d.ts +13 -0
- package/dist/entitySubclasses/userViewEntity.server.d.ts.map +1 -0
- package/dist/entitySubclasses/userViewEntity.server.js +161 -0
- package/dist/entitySubclasses/userViewEntity.server.js.map +1 -0
- package/dist/generated/generated.d.ts +6679 -0
- package/dist/generated/generated.d.ts.map +1 -0
- package/dist/generated/generated.js +40786 -0
- package/dist/generated/generated.js.map +1 -0
- package/dist/generic/DeleteOptionsInput.d.ts +5 -0
- package/dist/generic/DeleteOptionsInput.d.ts.map +1 -0
- package/dist/generic/DeleteOptionsInput.js +27 -0
- package/dist/generic/DeleteOptionsInput.js.map +1 -0
- package/dist/generic/KeyInputOutputTypes.d.ts +16 -0
- package/dist/generic/KeyInputOutputTypes.d.ts.map +1 -0
- package/dist/generic/KeyInputOutputTypes.js +65 -0
- package/dist/generic/KeyInputOutputTypes.js.map +1 -0
- package/dist/generic/KeyValuePairInput.d.ts +5 -0
- package/dist/generic/KeyValuePairInput.d.ts.map +1 -0
- package/dist/generic/KeyValuePairInput.js +27 -0
- package/dist/generic/KeyValuePairInput.js.map +1 -0
- package/dist/generic/PushStatusResolver.d.ts +14 -0
- package/dist/generic/PushStatusResolver.d.ts.map +1 -0
- package/dist/generic/PushStatusResolver.js +58 -0
- package/dist/generic/PushStatusResolver.js.map +1 -0
- package/dist/generic/ResolverBase.d.ts +39 -0
- package/dist/generic/ResolverBase.d.ts.map +1 -0
- package/dist/generic/ResolverBase.js +573 -0
- package/dist/generic/ResolverBase.js.map +1 -0
- package/dist/generic/RunViewResolver.d.ts +123 -0
- package/dist/generic/RunViewResolver.d.ts.map +1 -0
- package/dist/generic/RunViewResolver.js +728 -0
- package/dist/generic/RunViewResolver.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/orm.d.ts +4 -0
- package/dist/orm.d.ts.map +1 -0
- package/dist/orm.js +32 -0
- package/dist/orm.js.map +1 -0
- package/dist/resolvers/AskSkipResolver.d.ts +54 -0
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -0
- package/dist/resolvers/AskSkipResolver.js +805 -0
- package/dist/resolvers/AskSkipResolver.js.map +1 -0
- package/dist/resolvers/ColorResolver.d.ts +23 -0
- package/dist/resolvers/ColorResolver.d.ts.map +1 -0
- package/dist/resolvers/ColorResolver.js +97 -0
- package/dist/resolvers/ColorResolver.js.map +1 -0
- package/dist/resolvers/DatasetResolver.d.ts +42 -0
- package/dist/resolvers/DatasetResolver.d.ts.map +1 -0
- package/dist/resolvers/DatasetResolver.js +179 -0
- package/dist/resolvers/DatasetResolver.js.map +1 -0
- package/dist/resolvers/EntityCommunicationsResolver.d.ts +50 -0
- package/dist/resolvers/EntityCommunicationsResolver.d.ts.map +1 -0
- package/dist/resolvers/EntityCommunicationsResolver.js +280 -0
- package/dist/resolvers/EntityCommunicationsResolver.js.map +1 -0
- package/dist/resolvers/EntityRecordNameResolver.d.ts +21 -0
- package/dist/resolvers/EntityRecordNameResolver.d.ts.map +1 -0
- package/dist/resolvers/EntityRecordNameResolver.js +117 -0
- package/dist/resolvers/EntityRecordNameResolver.js.map +1 -0
- package/dist/resolvers/EntityResolver.d.ts +6 -0
- package/dist/resolvers/EntityResolver.d.ts.map +1 -0
- package/dist/resolvers/EntityResolver.js +57 -0
- package/dist/resolvers/EntityResolver.js.map +1 -0
- package/dist/resolvers/FileCategoryResolver.d.ts +6 -0
- package/dist/resolvers/FileCategoryResolver.d.ts.map +1 -0
- package/dist/resolvers/FileCategoryResolver.js +61 -0
- package/dist/resolvers/FileCategoryResolver.js.map +1 -0
- package/dist/resolvers/FileResolver.d.ts +24 -0
- package/dist/resolvers/FileResolver.d.ts.map +1 -0
- package/dist/resolvers/FileResolver.js +166 -0
- package/dist/resolvers/FileResolver.js.map +1 -0
- package/dist/resolvers/MergeRecordsResolver.d.ts +59 -0
- package/dist/resolvers/MergeRecordsResolver.d.ts.map +1 -0
- package/dist/resolvers/MergeRecordsResolver.js +282 -0
- package/dist/resolvers/MergeRecordsResolver.js.map +1 -0
- package/dist/resolvers/PotentialDuplicateRecordResolver.d.ts +29 -0
- package/dist/resolvers/PotentialDuplicateRecordResolver.d.ts.map +1 -0
- package/dist/resolvers/PotentialDuplicateRecordResolver.js +125 -0
- package/dist/resolvers/PotentialDuplicateRecordResolver.js.map +1 -0
- package/dist/resolvers/QueryResolver.d.ts +13 -0
- package/dist/resolvers/QueryResolver.d.ts.map +1 -0
- package/dist/resolvers/QueryResolver.js +77 -0
- package/dist/resolvers/QueryResolver.js.map +1 -0
- package/dist/resolvers/ReportResolver.d.ts +20 -0
- package/dist/resolvers/ReportResolver.d.ts.map +1 -0
- package/dist/resolvers/ReportResolver.js +182 -0
- package/dist/resolvers/ReportResolver.js.map +1 -0
- package/dist/resolvers/UserFavoriteResolver.d.ts +42 -0
- package/dist/resolvers/UserFavoriteResolver.d.ts.map +1 -0
- package/dist/resolvers/UserFavoriteResolver.js +230 -0
- package/dist/resolvers/UserFavoriteResolver.js.map +1 -0
- package/dist/resolvers/UserResolver.d.ts +10 -0
- package/dist/resolvers/UserResolver.d.ts.map +1 -0
- package/dist/resolvers/UserResolver.js +71 -0
- package/dist/resolvers/UserResolver.js.map +1 -0
- package/dist/resolvers/UserViewResolver.d.ts +13 -0
- package/dist/resolvers/UserViewResolver.d.ts.map +1 -0
- package/dist/resolvers/UserViewResolver.js +99 -0
- package/dist/resolvers/UserViewResolver.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +4 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +85 -0
- package/dist/util.js.map +1 -0
- package/package.json +25 -21
- package/CHANGELOG.json +0 -3389
- package/CHANGELOG.md +0 -739
- package/src/apolloServer/TransactionPlugin.ts +0 -57
- package/src/apolloServer/index.ts +0 -33
- package/src/auth/exampleNewUserSubClass.ts +0 -74
- package/src/auth/index.ts +0 -151
- package/src/auth/tokenExpiredError.ts +0 -12
- package/src/context.ts +0 -111
- package/src/directives/Public.ts +0 -42
- package/src/directives/index.ts +0 -1
- package/src/entitySubclasses/DuplicateRunEntity.server.ts +0 -29
- package/src/entitySubclasses/entityPermissions.server.ts +0 -111
- package/src/entitySubclasses/userViewEntity.server.ts +0 -187
- package/src/generated/generated.ts +0 -25369
- package/src/generic/DeleteOptionsInput.ts +0 -13
- package/src/generic/KeyInputOutputTypes.ts +0 -35
- package/src/generic/KeyValuePairInput.ts +0 -14
- package/src/generic/PushStatusResolver.ts +0 -40
- package/src/generic/ResolverBase.ts +0 -767
- package/src/generic/RunViewResolver.ts +0 -582
- package/src/index.ts +0 -161
- package/src/orm.ts +0 -36
- package/src/resolvers/AskSkipResolver.ts +0 -926
- package/src/resolvers/ColorResolver.ts +0 -61
- package/src/resolvers/DatasetResolver.ts +0 -115
- package/src/resolvers/EntityCommunicationsResolver.ts +0 -216
- package/src/resolvers/EntityRecordNameResolver.ts +0 -78
- package/src/resolvers/EntityResolver.ts +0 -37
- package/src/resolvers/FileCategoryResolver.ts +0 -62
- package/src/resolvers/FileResolver.ts +0 -147
- package/src/resolvers/MergeRecordsResolver.ts +0 -182
- package/src/resolvers/PotentialDuplicateRecordResolver.ts +0 -91
- package/src/resolvers/QueryResolver.ts +0 -42
- package/src/resolvers/ReportResolver.ts +0 -147
- package/src/resolvers/UserFavoriteResolver.ts +0 -166
- package/src/resolvers/UserResolver.ts +0 -33
- package/src/resolvers/UserViewResolver.ts +0 -64
- package/src/types.ts +0 -40
- package/src/util.ts +0 -106
- package/tsconfig.json +0 -30
- package/typedoc.json +0 -4
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ApolloServerPlugin, GraphQLRequestContextDidEncounterErrors, GraphQLRequestListenerParsingDidEnd } from '@apollo/server';
|
|
2
|
-
import { DataSource } from 'typeorm';
|
|
3
|
-
import { AppContext } from '../types';
|
|
4
|
-
|
|
5
|
-
export const TransactionPlugin: ApolloServerPlugin<AppContext> = {
|
|
6
|
-
async requestDidStart(requestContext) {
|
|
7
|
-
const start = Date.now();
|
|
8
|
-
const query = requestContext.request.query || '';
|
|
9
|
-
const isMutation = /^\s*mutation\b/i.test(query);
|
|
10
|
-
|
|
11
|
-
if (!isMutation) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Start transaction, one or more mutations. If it is just one mutation, this trans wrapper isn't really needed
|
|
16
|
-
// but there's no good way to know if it's one or more mutations, so we just start a transaction anyway and it isn't terribly expensive
|
|
17
|
-
// to do so with SQL Server anyway.
|
|
18
|
-
const dataSource: DataSource = requestContext.contextValue.dataSource;
|
|
19
|
-
const queryRunner = dataSource.createQueryRunner();
|
|
20
|
-
|
|
21
|
-
requestContext.contextValue.queryRunner = queryRunner;
|
|
22
|
-
console.log('Starting transaction wrapper, time spent: ', Date.now() - start, 'ms ');
|
|
23
|
-
await queryRunner.startTransaction();
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
didEncounterErrors: async (requestContext) => {
|
|
27
|
-
console.log('Error in transaction wrapper: ' + requestContext.errors, 'time spent: ', Date.now() - start, 'ms');
|
|
28
|
-
},
|
|
29
|
-
executionDidStart: async () => {
|
|
30
|
-
return {
|
|
31
|
-
executionDidEnd: async (err) => {
|
|
32
|
-
try {
|
|
33
|
-
if (err) {
|
|
34
|
-
console.log(
|
|
35
|
-
'Error in transaction, rolling back, time spent: ',
|
|
36
|
-
Date.now() - start,
|
|
37
|
-
'ms '
|
|
38
|
-
);
|
|
39
|
-
console.error('Rolling back transaction', err);
|
|
40
|
-
await queryRunner.rollbackTransaction();
|
|
41
|
-
} else {
|
|
42
|
-
console.log('Committing transaction, time spent: ', Date.now() - start, 'ms ');
|
|
43
|
-
await queryRunner.commitTransaction();
|
|
44
|
-
}
|
|
45
|
-
} catch (execErr) {
|
|
46
|
-
console.log('Execution Error, time spent: ', Date.now() - start, 'ms ');
|
|
47
|
-
console.error(execErr);
|
|
48
|
-
} finally {
|
|
49
|
-
await queryRunner.release();
|
|
50
|
-
console.log('Transaction complete, time spent: ', Date.now() - start, 'ms ');
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ApolloServer, ApolloServerOptions } from '@apollo/server';
|
|
2
|
-
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
|
|
3
|
-
import { Disposable } from 'graphql-ws';
|
|
4
|
-
import { Server } from 'http';
|
|
5
|
-
import { enableIntrospection } from '../config';
|
|
6
|
-
import { AppContext } from '../types';
|
|
7
|
-
import { TransactionPlugin } from './TransactionPlugin';
|
|
8
|
-
|
|
9
|
-
const buildApolloServer = (
|
|
10
|
-
configOverride: ApolloServerOptions<AppContext>,
|
|
11
|
-
{ httpServer, serverCleanup }: { httpServer: Server; serverCleanup: Disposable }
|
|
12
|
-
) =>
|
|
13
|
-
new ApolloServer({
|
|
14
|
-
csrfPrevention: true,
|
|
15
|
-
cache: 'bounded',
|
|
16
|
-
plugins: [
|
|
17
|
-
ApolloServerPluginDrainHttpServer({ httpServer }),
|
|
18
|
-
TransactionPlugin,
|
|
19
|
-
{
|
|
20
|
-
async serverWillStart() {
|
|
21
|
-
return {
|
|
22
|
-
async drainServer() {
|
|
23
|
-
await serverCleanup.dispose();
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
introspection: enableIntrospection,
|
|
30
|
-
...configOverride,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export default buildApolloServer;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { RegisterClass } from "@memberjunction/global";
|
|
2
|
-
import { Metadata, RunView, LogError } from "@memberjunction/core";
|
|
3
|
-
import { NewUserBase } from "./newUsers";
|
|
4
|
-
import { UserCache } from "@memberjunction/sqlserver-dataprovider";
|
|
5
|
-
import { configInfo } from "../config";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This example class subclasses the @NewUserBase class and overrides the createNewUser method to create a new person record and then call the base class to create the user record. In this example there is an entity
|
|
9
|
-
* called "Persons" that is mapped to the User table in the core MemberJunction schema. You can sub-class the NewUserBase to do whatever behavior you want and pre-process, post-process or entirely override the base
|
|
10
|
-
* class behavior.
|
|
11
|
-
*/
|
|
12
|
-
// NOTE: This is commented out becuase it is turned off by default. To make this work, you'd have to do a real implementation below, and then uncomment this decorator
|
|
13
|
-
// so that your class is actually used.
|
|
14
|
-
//@RegisterClass(NewUserBase, undefined, 1) /*by putting 1 into the priority setting, MJGlobal ClassFactory will use this instead of the base class as that registration had no priority*/
|
|
15
|
-
export class ExampleNewUserSubClass extends NewUserBase {
|
|
16
|
-
public override async createNewUser(firstName: string, lastName: string, email: string) {
|
|
17
|
-
try {
|
|
18
|
-
const md = new Metadata();
|
|
19
|
-
const contextUser = UserCache.Instance.Users.find(u => u.Email.trim().toLowerCase() === configInfo?.userHandling?.contextUserForNewUserCreation?.trim().toLowerCase())
|
|
20
|
-
if(!contextUser) {
|
|
21
|
-
LogError(`Failed to load context user ${configInfo?.userHandling?.contextUserForNewUserCreation}, if you've not specified this on your config.json you must do so. This is the user that is contextually used for creating a new user record dynamically.`);
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const pEntity = md.Entities.find(e => e.Name === 'Persons'); // look up the entity info for the Persons entity
|
|
26
|
-
if (!pEntity) {
|
|
27
|
-
LogError('Failed to find Persons entity');
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let personId;
|
|
32
|
-
// this block of code only executes if we have an entity called Persons
|
|
33
|
-
const rv = new RunView();
|
|
34
|
-
const viewResults = await rv.RunView({
|
|
35
|
-
EntityName: 'Persons',
|
|
36
|
-
ExtraFilter: `Email = '${email}'`
|
|
37
|
-
}, contextUser)
|
|
38
|
-
|
|
39
|
-
if (viewResults && viewResults.Success && Array.isArray(viewResults.Results) && viewResults.Results.length > 0) {
|
|
40
|
-
// we have a match so use it
|
|
41
|
-
const row = (viewResults.Results as { ID: number }[])[0]; // we know the rows will have an ID number
|
|
42
|
-
personId = row['ID'];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!personId) {
|
|
46
|
-
// we don't have a match so create a new person record
|
|
47
|
-
const p = await md.GetEntityObject('Persons', contextUser);
|
|
48
|
-
p.NewRecord(); // assumes we have an entity called Persons that has FirstName/LastName/Email fields
|
|
49
|
-
// this code is commented out because we don't have a strongly typed sub-class generatd for this "Persons" entity as it is a demo/hypothetical example
|
|
50
|
-
//p.FirstName = firstName;
|
|
51
|
-
//p.LastName = lastName;
|
|
52
|
-
//p.Email = email;
|
|
53
|
-
//p.Status = 'active';
|
|
54
|
-
if (await p.Save()) {
|
|
55
|
-
personId = p.FirstPrimaryKey.Value; // if we had a strongly typed sub-class above, we could use this code p.ID;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
LogError(`Failed to create new person ${firstName} ${lastName} ${email}`)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// now call the base class to create the user, and pass in our LinkedRecordType and ID
|
|
63
|
-
return super.createNewUser(firstName, lastName, email, 'Other', pEntity?.ID, personId);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
LogError(`Error creating new user ${email} ${e}`);
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function LoadExampleNewUserSubClass() {
|
|
73
|
-
// do nothing, just having this forces the above class to get registered via its @RegisterClass decorator
|
|
74
|
-
}
|
package/src/auth/index.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { JwtHeader, SigningKeyCallback } from 'jsonwebtoken';
|
|
2
|
-
import jwksClient from 'jwks-rsa';
|
|
3
|
-
import { auth0Domain, auth0WebClientID, configInfo, tenantID, webClientID } from '../config';
|
|
4
|
-
import { UserCache } from '@memberjunction/sqlserver-dataprovider';
|
|
5
|
-
import { DataSource } from 'typeorm';
|
|
6
|
-
import { Metadata, UserInfo } from '@memberjunction/core';
|
|
7
|
-
import { NewUserBase } from './newUsers';
|
|
8
|
-
import { MJGlobal } from '@memberjunction/global';
|
|
9
|
-
|
|
10
|
-
export * from './tokenExpiredError';
|
|
11
|
-
|
|
12
|
-
const missingAzureConfig = !tenantID || !webClientID;
|
|
13
|
-
const missingAuth0Config = !auth0Domain || !auth0WebClientID;
|
|
14
|
-
|
|
15
|
-
class MissingAuthError extends Error {
|
|
16
|
-
constructor() {
|
|
17
|
-
super('Could not find authentication configuration for either MSAL or Auth0 in the server environment variables.');
|
|
18
|
-
this.name = 'MissingAuthError';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const issuers = {
|
|
23
|
-
azure: `https://login.microsoftonline.com/${tenantID}/v2.0`,
|
|
24
|
-
auth0: `https://${auth0Domain}/`,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const validationOptions = {
|
|
28
|
-
[issuers.auth0]: {
|
|
29
|
-
audience: auth0WebClientID,
|
|
30
|
-
jwksUri: `https://${auth0Domain}/.well-known/jwks.json`,
|
|
31
|
-
},
|
|
32
|
-
[issuers.azure]: {
|
|
33
|
-
audience: webClientID,
|
|
34
|
-
jwksUri: `https://login.microsoftonline.com/${tenantID}/discovery/v2.0/keys`,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export class UserPayload {
|
|
39
|
-
aio?: string;
|
|
40
|
-
aud?: string;
|
|
41
|
-
exp?: number;
|
|
42
|
-
iat?: number;
|
|
43
|
-
iss?: string;
|
|
44
|
-
name?: string;
|
|
45
|
-
nbf?: number;
|
|
46
|
-
nonce?: string;
|
|
47
|
-
oid?: string;
|
|
48
|
-
preferred_username?: string;
|
|
49
|
-
rh?: string;
|
|
50
|
-
sub?: string;
|
|
51
|
-
tid?: string;
|
|
52
|
-
uti?: string;
|
|
53
|
-
ver?: string;
|
|
54
|
-
// what about an array of roles???
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const getSigningKeys = (issuer: string) => (header: JwtHeader, cb: SigningKeyCallback) => {
|
|
58
|
-
if (!validationOptions[issuer]) {
|
|
59
|
-
throw new Error(`No validation options found for issuer ${issuer}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const jwksUri = validationOptions[issuer].jwksUri;
|
|
63
|
-
if (missingAuth0Config && missingAzureConfig) {
|
|
64
|
-
throw new MissingAuthError();
|
|
65
|
-
}
|
|
66
|
-
if (missingAuth0Config) {
|
|
67
|
-
console.warn('Auth0 configuration not found in environment variables');
|
|
68
|
-
}
|
|
69
|
-
if (missingAzureConfig) {
|
|
70
|
-
console.warn('MSAL configuration not found in environment variables');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
jwksClient({ jwksUri })
|
|
74
|
-
.getSigningKey(header.kid)
|
|
75
|
-
.then((key) => {
|
|
76
|
-
cb(null, 'publicKey' in key ? key.publicKey : key.rsaPublicKey);
|
|
77
|
-
})
|
|
78
|
-
.catch((err) => console.error(err));
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const verifyUserRecord = async (email?: string, firstName?: string, lastName?: string, requestDomain?: string, dataSource?: DataSource, attemptCacheUpdateIfNeeded: boolean = true): Promise<UserInfo | undefined> => {
|
|
82
|
-
if (!email) return undefined;
|
|
83
|
-
|
|
84
|
-
let user = UserCache.Instance.Users.find((u) => {
|
|
85
|
-
if (!u.Email || u.Email.trim() === '') {
|
|
86
|
-
// this condition should never occur. If it doesn throw a console error including the user id
|
|
87
|
-
// DB requires non-null but this is just an extra check and we could in theory have a blank string in the DB
|
|
88
|
-
console.error(`SYSTEM METADATA ISSUE: User ${u.ID} has no email address`);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
else
|
|
92
|
-
return u.Email.toLowerCase().trim() === email.toLowerCase().trim()
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
if (!user) {
|
|
96
|
-
if (configInfo.userHandling.autoCreateNewUsers && firstName && lastName && (requestDomain || configInfo.userHandling.newUserLimitedToAuthorizedDomains === false)) {
|
|
97
|
-
// check to see if the domain that we have a request coming in from matches one of the domains in the autoCreateNewUsersDomains setting
|
|
98
|
-
let passesDomainCheck: boolean = configInfo.userHandling.newUserLimitedToAuthorizedDomains === false /*in this first condition, we are set up to NOT care about domain */
|
|
99
|
-
if (!passesDomainCheck && requestDomain) {
|
|
100
|
-
/*in this second condition, we check the domain against authorized domains*/
|
|
101
|
-
passesDomainCheck = configInfo.userHandling.newUserAuthorizedDomains.some((pattern) => {
|
|
102
|
-
// Convert wildcard domain patterns to regular expressions
|
|
103
|
-
const regex = new RegExp('^' + pattern.toLowerCase().trim().replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
104
|
-
return regex.test(requestDomain?.toLowerCase().trim());
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (passesDomainCheck) {
|
|
109
|
-
// we have a domain from the request that matches one of the domains provided by the configuration, so we will create a new user
|
|
110
|
-
console.warn(`User ${email} not found in cache. Attempting to create a new user...`);
|
|
111
|
-
const newUserCreator: NewUserBase = <NewUserBase>MJGlobal.Instance.ClassFactory.CreateInstance(NewUserBase); // this will create the object that handles creating the new user for us
|
|
112
|
-
const newUser = await newUserCreator.createNewUser(firstName, lastName, email);
|
|
113
|
-
if (newUser) {
|
|
114
|
-
// new user worked! we already have the stuff we need for the cache, so no need to go to the DB now, just create a new UserInfo object and use the return value from the createNewUser method
|
|
115
|
-
// to init it, including passing in the role list for the user.
|
|
116
|
-
const initData: any = newUser.GetAll();
|
|
117
|
-
initData.UserRoles = configInfo.userHandling.newUserRoles.map((role) => { return { UserID: initData.ID, RoleName: role } });
|
|
118
|
-
user = new UserInfo(Metadata.Provider, initData);
|
|
119
|
-
UserCache.Instance.Users.push(user);
|
|
120
|
-
console.warn(` >>> New user ${email} created successfully!`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
console.warn(`User ${email} not found in cache. Request domain '${requestDomain}' does not match any of the domains in the newUserAuthorizedDomains setting. To ignore domain, make sure you set the newUserLimitedToAuthorizedDomains setting to false. In this case we are NOT creating a new user.`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if(!user && configInfo.userHandling.updateCacheWhenNotFound && dataSource && attemptCacheUpdateIfNeeded) {
|
|
128
|
-
// if we get here that means in the above, if we were attempting to create a new user, it did not work, or it wasn't attempted and we have a config that asks us to auto update the cache
|
|
129
|
-
console.warn(`User ${email} not found in cache. Updating cache in attempt to find the user...`);
|
|
130
|
-
|
|
131
|
-
const startTime: number = Date.now();
|
|
132
|
-
await UserCache.Instance.Refresh(dataSource);
|
|
133
|
-
const endTime: number = Date.now();
|
|
134
|
-
const elapsed: number = endTime - startTime;
|
|
135
|
-
|
|
136
|
-
// if elapsed time is less than the delay setting, wait for the additional time to achieve the full delay
|
|
137
|
-
// the below also makes sure we never go more than a 30 second total delay
|
|
138
|
-
const delay = configInfo.userHandling.updateCacheWhenNotFoundDelay ? (configInfo.userHandling.updateCacheWhenNotFoundDelay < 30000 ? configInfo.userHandling.updateCacheWhenNotFoundDelay : 30000) : 0;
|
|
139
|
-
if (elapsed < delay)
|
|
140
|
-
await new Promise(resolve => setTimeout(resolve, delay - elapsed));
|
|
141
|
-
|
|
142
|
-
const finalTime: number = Date.now();
|
|
143
|
-
const finalElapsed: number = finalTime - startTime;
|
|
144
|
-
|
|
145
|
-
console.log(` UserCache updated in ${elapsed}ms, total elapsed time of ${finalElapsed}ms including delay of ${delay}ms (if needed). Attempting to find the user again via recursive call to verifyUserRecord()`);
|
|
146
|
-
return verifyUserRecord(email, firstName, lastName, requestDomain, dataSource, false) // try one more time but do not update cache next time if not found
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return user;
|
|
151
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
2
|
-
|
|
3
|
-
export class TokenExpiredError extends GraphQLError {
|
|
4
|
-
constructor(expiryDate: Date, message = 'The provided token has expired. Please authenticate again.') {
|
|
5
|
-
super(message, {
|
|
6
|
-
extensions: {
|
|
7
|
-
code: 'JWT_EXPIRED',
|
|
8
|
-
expiryDate: expiryDate.toISOString(),
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
}
|
package/src/context.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from 'http';
|
|
2
|
-
import * as url from 'url';
|
|
3
|
-
import { default as jwt } from 'jsonwebtoken';
|
|
4
|
-
import 'reflect-metadata';
|
|
5
|
-
import { Subject, firstValueFrom } from 'rxjs';
|
|
6
|
-
import { AuthenticationError, AuthorizationError } from 'type-graphql';
|
|
7
|
-
import { DataSource } from 'typeorm';
|
|
8
|
-
import { getSigningKeys, validationOptions, verifyUserRecord } from './auth';
|
|
9
|
-
import { authCache } from './cache';
|
|
10
|
-
import { userEmailMap } from './config';
|
|
11
|
-
import { UserPayload } from './types';
|
|
12
|
-
import { TokenExpiredError } from './auth';
|
|
13
|
-
|
|
14
|
-
const verifyAsync = async (issuer: string, options: jwt.VerifyOptions, token: string): Promise<jwt.JwtPayload> =>
|
|
15
|
-
new Promise((resolve, reject) => {
|
|
16
|
-
jwt.verify(token, getSigningKeys(issuer), options, (err, jwt) => {
|
|
17
|
-
if (jwt && typeof jwt !== 'string' && !err) {
|
|
18
|
-
const payload = jwt.payload ?? jwt;
|
|
19
|
-
|
|
20
|
-
console.log(`Valid token: ${payload.name} (${payload.email ? payload.email : payload.preferred_username})`); // temporary fix to check preferred_username if email is not present
|
|
21
|
-
resolve(payload);
|
|
22
|
-
} else {
|
|
23
|
-
console.warn('Invalid token');
|
|
24
|
-
reject(err);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const getUserPayload = async (
|
|
30
|
-
bearerToken: string,
|
|
31
|
-
sessionId = 'default',
|
|
32
|
-
dataSource: DataSource,
|
|
33
|
-
requestDomain?: string
|
|
34
|
-
): Promise<UserPayload> => {
|
|
35
|
-
try {
|
|
36
|
-
const token = bearerToken.replace('Bearer ', '');
|
|
37
|
-
|
|
38
|
-
if (!token) {
|
|
39
|
-
console.warn('No token to validate');
|
|
40
|
-
throw new AuthenticationError('Missing token');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const payload = jwt.decode(token);
|
|
44
|
-
if (!payload || typeof payload === 'string') {
|
|
45
|
-
throw new AuthenticationError('Invalid token payload');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const expiryDate = new Date((payload.exp ?? 0) * 1000);
|
|
49
|
-
if (expiryDate.getTime() <= Date.now()) {
|
|
50
|
-
throw new TokenExpiredError(expiryDate);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!authCache.has(token)) {
|
|
54
|
-
const issuer = payload.iss;
|
|
55
|
-
if (!issuer) {
|
|
56
|
-
console.warn('No issuer claim on token');
|
|
57
|
-
throw new AuthenticationError('Missing issuer claim on token');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await verifyAsync(issuer, validationOptions[issuer], token);
|
|
61
|
-
authCache.set(token, true);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const email = payload?.email ? userEmailMap[payload?.email] ?? payload?.email : payload?.preferred_username; // temporary fix to check preferred_username if email is not present
|
|
65
|
-
const fullName = payload?.name;
|
|
66
|
-
const firstName = payload?.given_name || fullName?.split(' ')[0];
|
|
67
|
-
const lastName = payload?.family_name || fullName?.split(' ')[1] || fullName?.split(' ')[0];
|
|
68
|
-
const userRecord = await verifyUserRecord(email, firstName, lastName, requestDomain, dataSource);
|
|
69
|
-
|
|
70
|
-
if (!userRecord) {
|
|
71
|
-
console.error(`User ${email} not found`);
|
|
72
|
-
throw new AuthorizationError();
|
|
73
|
-
} else if (!userRecord.IsActive) {
|
|
74
|
-
console.error(`User ${email} found but inactive`);
|
|
75
|
-
throw new AuthorizationError();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return { userRecord, email, sessionId };
|
|
79
|
-
} catch (e) {
|
|
80
|
-
console.error(e);
|
|
81
|
-
if (e instanceof TokenExpiredError) {
|
|
82
|
-
throw e;
|
|
83
|
-
} else return {} as UserPayload;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const contextFunction =
|
|
88
|
-
({ setupComplete$, dataSource }: { setupComplete$: Subject<unknown>; dataSource: DataSource }) =>
|
|
89
|
-
async ({ req }: { req: IncomingMessage }) => {
|
|
90
|
-
await firstValueFrom(setupComplete$); // wait for setup to complete before processing the request
|
|
91
|
-
|
|
92
|
-
const sessionIdRaw = req.headers['x-session-id'];
|
|
93
|
-
const requestDomain = url.parse(req.headers.origin || '');
|
|
94
|
-
const sessionId = sessionIdRaw ? sessionIdRaw.toString() : '';
|
|
95
|
-
const bearerToken = req.headers.authorization ?? '';
|
|
96
|
-
|
|
97
|
-
const userPayload = await getUserPayload(
|
|
98
|
-
bearerToken,
|
|
99
|
-
sessionId,
|
|
100
|
-
dataSource,
|
|
101
|
-
requestDomain?.hostname ? requestDomain.hostname : undefined
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
-
const operationName: string | undefined = (req as any).body?.operationName;
|
|
106
|
-
if (operationName !== 'IntrospectionQuery') {
|
|
107
|
-
console.log({ operationName });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return { dataSource, userPayload };
|
|
111
|
-
};
|
package/src/directives/Public.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FieldMapper, MapperKind, getDirective, mapSchema } from '@graphql-tools/utils';
|
|
2
|
-
import { GraphQLFieldResolver, defaultFieldResolver } from 'graphql';
|
|
3
|
-
import { AuthorizationError, Directive } from 'type-graphql';
|
|
4
|
-
import { AppContext, DirectiveBuilder } from '../types';
|
|
5
|
-
|
|
6
|
-
const DIRECTIVE_NAME = 'Public';
|
|
7
|
-
|
|
8
|
-
export function Public(): PropertyDecorator & MethodDecorator & ClassDecorator;
|
|
9
|
-
export function Public(): PropertyDecorator | MethodDecorator | ClassDecorator {
|
|
10
|
-
return (targetOrPrototype, propertyKey, descriptor) =>
|
|
11
|
-
Directive(`@${DIRECTIVE_NAME}`)(targetOrPrototype, propertyKey, descriptor);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const publicDirective: DirectiveBuilder = {
|
|
15
|
-
typeDefs: `directive @${DIRECTIVE_NAME} on FIELD_DEFINITION`,
|
|
16
|
-
transformer: (schema) => {
|
|
17
|
-
const fieldMapper: FieldMapper = (fieldConfig) => {
|
|
18
|
-
const directive = getDirective(schema, fieldConfig, DIRECTIVE_NAME)?.[0];
|
|
19
|
-
if (directive) {
|
|
20
|
-
return fieldConfig;
|
|
21
|
-
} else {
|
|
22
|
-
// `@Public` directive not present, so will require auth
|
|
23
|
-
const { resolve = defaultFieldResolver } = fieldConfig;
|
|
24
|
-
const directiveResolver: GraphQLFieldResolver<unknown, AppContext> = async (
|
|
25
|
-
source,
|
|
26
|
-
args,
|
|
27
|
-
context,
|
|
28
|
-
info
|
|
29
|
-
) => {
|
|
30
|
-
// eslint-disable-next-line
|
|
31
|
-
if (!context?.userPayload?.userRecord?.IsActive) {
|
|
32
|
-
throw new AuthorizationError();
|
|
33
|
-
}
|
|
34
|
-
return await resolve(source, args, context, info);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return { ...fieldConfig, resolve: directiveResolver };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return mapSchema(schema, { [MapperKind.OBJECT_FIELD]: fieldMapper });
|
|
41
|
-
},
|
|
42
|
-
};
|
package/src/directives/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Public';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseEntity, PotentialDuplicateRequest } from "@memberjunction/core";
|
|
2
|
-
import { RegisterClass } from "@memberjunction/global";
|
|
3
|
-
import { DuplicateRunEntity } from "@memberjunction/core-entities";
|
|
4
|
-
import { DuplicateRecordDetector } from "@memberjunction/ai-vector-dupe";
|
|
5
|
-
|
|
6
|
-
@RegisterClass(BaseEntity, 'Duplicate Runs', 3)
|
|
7
|
-
export class DuplicateRunEntity_Server extends DuplicateRunEntity {
|
|
8
|
-
public async Save(): Promise<boolean> {
|
|
9
|
-
const saveResult: boolean = await super.Save();
|
|
10
|
-
if (saveResult && this.EndedAt === null) {
|
|
11
|
-
// do something
|
|
12
|
-
const duplicateRecordDetector: DuplicateRecordDetector = new DuplicateRecordDetector();
|
|
13
|
-
let request: PotentialDuplicateRequest = new PotentialDuplicateRequest();
|
|
14
|
-
request.EntityID = this.EntityID;
|
|
15
|
-
request.ListID = this.SourceListID;
|
|
16
|
-
request.Options = {
|
|
17
|
-
DuplicateRunID: this.ID,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const response = await duplicateRecordDetector.getDuplicateRecords(request, this.ContextCurrentUser);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return saveResult;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function LoadDuplicateRunEntityServerSubClass() {
|
|
28
|
-
|
|
29
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { RegisterClass } from "@memberjunction/global";
|
|
2
|
-
import { BaseEntity, EntitySaveOptions } from "@memberjunction/core";
|
|
3
|
-
import { EntityPermissionEntity } from '@memberjunction/core-entities'
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
import { ___codeGenAPIPort, ___codeGenAPISubmissionDelay, ___codeGenAPIURL } from "../config";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Server-side only class that extends the entity permissions object to watch for changes to entity permissions, build a queue of entities that have been changed, and then from time to time, submit
|
|
9
|
-
* them to an API server that will execute the underlying permission changes at the database level.
|
|
10
|
-
*/
|
|
11
|
-
@RegisterClass(BaseEntity, 'Entity Permissions', 3)
|
|
12
|
-
export class EntityPermissionsEntity_Server extends EntityPermissionEntity {
|
|
13
|
-
protected static _entityIDQueue: string[] = [];
|
|
14
|
-
protected static _lastModifiedTime: Date | null = null;
|
|
15
|
-
protected static _submissionTimer: NodeJS.Timeout | null = null;
|
|
16
|
-
protected static _submissionDelay: number = ___codeGenAPISubmissionDelay;
|
|
17
|
-
protected static _baseURL: string = ___codeGenAPIURL;
|
|
18
|
-
protected static _port: number = ___codeGenAPIPort;
|
|
19
|
-
protected static _apiEndpoint: string = '/api/entity-permissions';
|
|
20
|
-
|
|
21
|
-
// Method to construct the full URL dynamically
|
|
22
|
-
protected static getSubmissionURL(): string {
|
|
23
|
-
return `${this._baseURL}:${this._port}${this._apiEndpoint}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static get EntityIDQueue(): string[] {
|
|
27
|
-
return this._entityIDQueue;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public static ClearQueue(): void {
|
|
31
|
-
this._entityIDQueue = [];
|
|
32
|
-
this._submissionTimer = null;
|
|
33
|
-
}
|
|
34
|
-
public static AddToQueue(entityID: string): void {
|
|
35
|
-
if (this._entityIDQueue.indexOf(entityID) === -1)
|
|
36
|
-
this._entityIDQueue.push(entityID);
|
|
37
|
-
this._lastModifiedTime = new Date();
|
|
38
|
-
this.CheckStartSubmissionTimer();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
protected static CheckStartSubmissionTimer(): void {
|
|
42
|
-
if (this._submissionTimer === null) {
|
|
43
|
-
this.StartSubmissionTimer();
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// we need to cancel the existing timer and start a new one
|
|
47
|
-
clearTimeout(this._submissionTimer);
|
|
48
|
-
this.StartSubmissionTimer();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected static StartSubmissionTimer(): void {
|
|
53
|
-
this._submissionTimer = setTimeout(() => {
|
|
54
|
-
this.SubmitQueue();
|
|
55
|
-
}, this._submissionDelay);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected static async SubmitQueue(): Promise<void> {
|
|
59
|
-
this._lastModifiedTime = null;
|
|
60
|
-
|
|
61
|
-
// now, use Axios to submit the queue to the API server
|
|
62
|
-
// Check if there's anything to submit
|
|
63
|
-
if (this._entityIDQueue.length > 0) {
|
|
64
|
-
try {
|
|
65
|
-
// Use Axios to submit the queue to the API server
|
|
66
|
-
const response = await axios.post(this.getSubmissionURL(), {
|
|
67
|
-
entityIDArray: this._entityIDQueue
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Check the Axios response code implicitly and API response explicitly
|
|
71
|
-
if (response.status === 200 && response.data.status === 'ok') {
|
|
72
|
-
console.log('Queue submitted successfully.');
|
|
73
|
-
// now, clear the queue and timer
|
|
74
|
-
this.ClearQueue();
|
|
75
|
-
} else {
|
|
76
|
-
// Handle API indicating a failure
|
|
77
|
-
console.error('Failed to submit queue:', response.data.errorMessage || 'Unknown error');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
} catch (error) {
|
|
81
|
-
// Handle errors here
|
|
82
|
-
console.error('Failed to submit queue:', error);
|
|
83
|
-
// Consider re-trying or logging the error based on your requirements
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
console.log('No entities to submit.');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
override Save(options?: EntitySaveOptions): Promise<boolean> {
|
|
91
|
-
// simply queue up the entity ID
|
|
92
|
-
if (this.Dirty || options?.IgnoreDirtyState)
|
|
93
|
-
EntityPermissionsEntity_Server.AddToQueue(this.EntityID);
|
|
94
|
-
|
|
95
|
-
return super.Save(options);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
override async Delete(): Promise<boolean> {
|
|
99
|
-
const success = await super.Delete();
|
|
100
|
-
|
|
101
|
-
// simply queue up the entity ID if the delete worked
|
|
102
|
-
if (success)
|
|
103
|
-
EntityPermissionsEntity_Server.AddToQueue(this.EntityID);
|
|
104
|
-
|
|
105
|
-
return success;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function LoadEntityPermissionsServerSubClass() {
|
|
110
|
-
|
|
111
|
-
}
|