@memberjunction/graphql-dataprovider 1.5.3 → 1.6.1

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.
@@ -0,0 +1,2 @@
1
+ import { GraphQLDataProvider, GraphQLProviderConfigData } from "./graphQLDataProvider";
2
+ export declare function setupGraphQLClient(config: GraphQLProviderConfigData): Promise<GraphQLDataProvider>;
@@ -0,0 +1,18 @@
1
+ import { RunReport, BaseEntity, Metadata, RunView, RunQuery } from "@memberjunction/core";
2
+ import { GraphQLDataProvider } from "./graphQLDataProvider";
3
+ import { MJGlobal, MJEventType } from "@memberjunction/global";
4
+ export async function setupGraphQLClient(config) {
5
+ // Set the provider for all entities to be GraphQL in this project, can use a different provider in other situations....
6
+ const provider = new GraphQLDataProvider();
7
+ // BaseEntity + Metadata share the same GraphQLDataProvider instance
8
+ BaseEntity.Provider = provider;
9
+ Metadata.Provider = provider;
10
+ RunView.Provider = provider;
11
+ RunReport.Provider = provider;
12
+ RunQuery.Provider = provider;
13
+ await provider.Config(config);
14
+ // fire off the logged in event if we get here
15
+ MJGlobal.Instance.RaiseEvent({ event: MJEventType.LoggedIn, eventCode: null, component: this, args: null });
16
+ return provider;
17
+ }
18
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAA6B,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAiC;IACtE,wHAAwH;IACxH,MAAM,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAA;IAE1C,oEAAoE;IACpE,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC9B,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC3B,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC7B,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE5B,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5G,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,122 @@
1
+ /**************************************************************************************************************
2
+ * The graphQLDataProvider provides a data provider for the entities framework that uses GraphQL to communicate
3
+ * with the server.
4
+ * In practice - this FILE will NOT exist in the entities library, we need to move to its own separate project
5
+ * so it is only included by the consumer of the entities library if they want to use it.
6
+ **************************************************************************************************************/
7
+ import { BaseEntity, IEntityDataProvider, IMetadataProvider, IRunViewProvider, ProviderConfigDataBase, RunViewResult, EntityInfo, RunViewParams, ProviderBase, ProviderType, UserInfo, RecordChange, ILocalStorageProvider, EntitySaveOptions, TransactionGroupBase, DatasetItemFilterType, DatasetResultType, DatasetStatusResultType, EntityRecordNameInput, EntityRecordNameResult, IRunReportProvider, RunReportResult, RunReportParams, RecordDependency, RecordMergeRequest, RecordMergeResult, IRunQueryProvider, RunQueryResult, PotentialDuplicateRequest, PotentialDuplicateResponse, CompositeKey, EntityDeleteOptions, RunQueryParams, KeyValuePair } from "@memberjunction/core";
8
+ import { UserViewEntityExtended } from '@memberjunction/core-entities';
9
+ import { GraphQLClient } from 'graphql-request';
10
+ import { Observable } from 'rxjs';
11
+ export type RefreshTokenFunction = () => Promise<string>;
12
+ export declare class GraphQLProviderConfigData extends ProviderConfigDataBase {
13
+ /**
14
+ * Token is the JWT token that is used to authenticate the user with the server
15
+ */
16
+ get Token(): string;
17
+ set Token(token: string);
18
+ /**
19
+ * URL is the URL to the GraphQL endpoint
20
+ */
21
+ get URL(): string;
22
+ /**
23
+ * WSURL is the URL to the GraphQL websocket endpoint. This is used for subscriptions, if you are not using subscriptions, you can pass in a blank string for this
24
+ */
25
+ get WSURL(): string;
26
+ /**
27
+ * RefreshTokenFunction is a function that can be called by the GraphQLDataProvider whenever it receives an exception that the JWT it has already is expired
28
+ */
29
+ get RefreshTokenFunction(): RefreshTokenFunction;
30
+ /**
31
+ *
32
+ * @param token Token is the JWT token that is used to authenticate the user with the server
33
+ * @param url the URL to the GraphQL endpoint
34
+ * @param wsurl the URL to the GraphQL websocket endpoint. This is used for subscriptions, if you are not using subscriptions, you can pass in a blank string for this
35
+ * @param refreshTokenFunction is a function that can be called by the GraphQLDataProvider whenever it receives an exception that the JWT it has already is expired
36
+ * @param MJCoreSchemaName the name of the MJ Core schema, if it is not the default name of __mj
37
+ * @param includeSchemas optional, an array of schema names to include in the metadata. If not passed, all schemas are included
38
+ * @param excludeSchemas optional, an array of schema names to exclude from the metadata. If not passed, no schemas are excluded
39
+ */
40
+ constructor(token: string, url: string, wsurl: string, refreshTokenFunction: RefreshTokenFunction, MJCoreSchemaName?: string, includeSchemas?: string[], excludeSchemas?: string[]);
41
+ }
42
+ export declare class GraphQLDataProvider extends ProviderBase implements IEntityDataProvider, IMetadataProvider, IRunViewProvider, IRunReportProvider, IRunQueryProvider {
43
+ private static _client;
44
+ private static _configData;
45
+ private static _sessionId;
46
+ get ConfigData(): GraphQLProviderConfigData;
47
+ GenerateUUID(): string;
48
+ Config(configData: GraphQLProviderConfigData): Promise<boolean>;
49
+ get sessionId(): string;
50
+ protected get AllowRefresh(): boolean;
51
+ protected GetCurrentUser(): Promise<UserInfo>;
52
+ /**************************************************************************/
53
+ /**************************************************************************/
54
+ RunReport(params: RunReportParams, contextUser?: UserInfo): Promise<RunReportResult>;
55
+ /**************************************************************************/
56
+ /**************************************************************************/
57
+ /**************************************************************************/
58
+ /**************************************************************************/
59
+ RunQuery(params: RunQueryParams, contextUser?: UserInfo): Promise<RunQueryResult>;
60
+ /**************************************************************************/
61
+ /**************************************************************************/
62
+ /**************************************************************************/
63
+ /**************************************************************************/
64
+ RunView<T = any>(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult<T>>;
65
+ protected getEntityNameAndUserView(params: RunViewParams, contextUser?: UserInfo): Promise<{
66
+ entityName: string;
67
+ v: UserViewEntityExtended;
68
+ }>;
69
+ protected getViewRunTimeFieldList(e: EntityInfo, v: UserViewEntityExtended, params: RunViewParams, dynamicView: boolean): string[];
70
+ /**************************************************************************/
71
+ /**************************************************************************/
72
+ /**************************************************************************/
73
+ /**************************************************************************/
74
+ get ProviderType(): ProviderType;
75
+ GetRecordChanges(entityName: string, primaryKey: CompositeKey): Promise<RecordChange[]>;
76
+ /**
77
+ * Returns a list of dependencies - records that are linked to the specified Entity/KeyValuePairs combination. A dependency is as defined by the relationships in the database. The MemberJunction metadata that is used
78
+ * for this simply reflects the foreign key relationships that exist in the database. The CodeGen tool is what detects all of the relationships and generates the metadata that is used by MemberJunction. The metadata in question
79
+ * is within the EntityField table and specifically the RelatedEntity and RelatedEntityField columns. In turn, this method uses that metadata and queries the database to determine the dependencies. To get the list of entity dependencies
80
+ * you can use the utility method GetEntityDependencies(), which doesn't check for dependencies on a specific record, but rather gets the metadata in one shot that can be used for dependency checking.
81
+ * @param entityName the name of the entity to check
82
+ * @param KeyValuePairs the KeyValuePairs of the record to check
83
+ */
84
+ GetRecordDependencies(entityName: string, primaryKey: CompositeKey): Promise<RecordDependency[]>;
85
+ protected ensureKeyValuePairValueIsString(kvps: KeyValuePair[]): {
86
+ FieldName: string;
87
+ Value: string;
88
+ }[];
89
+ GetRecordDuplicates(params: PotentialDuplicateRequest, contextUser?: UserInfo): Promise<PotentialDuplicateResponse>;
90
+ MergeRecords(request: RecordMergeRequest): Promise<RecordMergeResult>;
91
+ Save(entity: BaseEntity, user: UserInfo, options: EntitySaveOptions): Promise<{}>;
92
+ Load(entity: BaseEntity, primaryKey: CompositeKey, EntityRelationshipsToLoad: string[], user: UserInfo): Promise<{}>;
93
+ protected getRelatedEntityString(entityInfo: EntityInfo, EntityRelationshipsToLoad: string[]): string;
94
+ Delete(entity: BaseEntity, options: EntityDeleteOptions, user: UserInfo): Promise<boolean>;
95
+ /**************************************************************************/
96
+ /**************************************************************************/
97
+ /**************************************************************************/
98
+ /**************************************************************************/
99
+ GetDatasetByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetResultType>;
100
+ GetDatasetStatusByName(datasetName: string, itemFilters?: DatasetItemFilterType[]): Promise<DatasetStatusResultType>;
101
+ CreateTransactionGroup(): Promise<TransactionGroupBase>;
102
+ GetRecordFavoriteStatus(userId: number, entityName: string, primaryKey: CompositeKey): Promise<boolean>;
103
+ SetRecordFavoriteStatus(userId: number, entityName: string, primaryKey: CompositeKey, isFavorite: boolean, contextUser: UserInfo): Promise<void>;
104
+ GetEntityRecordName(entityName: string, primaryKey: CompositeKey): Promise<string>;
105
+ GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
106
+ static ExecuteGQL(query: string, variables: any, refreshTokenIfNeeded?: boolean): Promise<any>;
107
+ static RefreshToken(): Promise<void>;
108
+ protected static CreateNewGraphQLClient(url: string, token: string, sessionId: string): GraphQLClient;
109
+ private _innerCurrentUserQueryString;
110
+ private _currentUserQuery;
111
+ private userInfoString;
112
+ private userRoleInfoString;
113
+ private infoString;
114
+ private _localStorageProvider;
115
+ get LocalStorageProvider(): ILocalStorageProvider;
116
+ /**************************************************************************/
117
+ /**************************************************************************/
118
+ protected get Metadata(): IMetadataProvider;
119
+ private _wsClient;
120
+ private _pushStatusRequests;
121
+ PushStatusUpdates(sessionId?: string): Observable<string>;
122
+ }