@memberjunction/graphql-dataprovider 1.0.6 → 1.0.7

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.
@@ -83,12 +83,12 @@ class GraphQLDataProvider extends core_1.ProviderBase {
83
83
  // }
84
84
  // }
85
85
  // `
86
- this._innerCurrentUserQueryString = `CurrentUser {
87
- ${this.userInfoString()}
88
- UserRolesArray {
89
- ${this.userRoleInfoString()}
90
- }
91
- }
86
+ this._innerCurrentUserQueryString = `CurrentUser {
87
+ ${this.userInfoString()}
88
+ UserRolesArray {
89
+ ${this.userRoleInfoString()}
90
+ }
91
+ }
92
92
  `;
93
93
  // private _allApplicationsQuery = gql`
94
94
  // ${this._innerAllApplicationsQueryString}
@@ -131,8 +131,8 @@ class GraphQLDataProvider extends core_1.ProviderBase {
131
131
  // ${this._innerAllQueriesQueryString}
132
132
  // ${this._innerAllQueryCategoriesQueryString}
133
133
  // }`
134
- this._currentUserQuery = (0, graphql_request_1.gql) `query CurrentUserAndRoles {
135
- ${this._innerCurrentUserQueryString}
134
+ this._currentUserQuery = (0, graphql_request_1.gql) `query CurrentUserAndRoles {
135
+ ${this._innerCurrentUserQueryString}
136
136
  }`;
137
137
  this._wsClient = null;
138
138
  this._pushStatusRequests = [];
@@ -176,15 +176,15 @@ class GraphQLDataProvider extends core_1.ProviderBase {
176
176
  // START ---- IRunReportProvider
177
177
  /**************************************************************************/
178
178
  async RunReport(params, contextUser) {
179
- const query = (0, graphql_request_1.gql) `
180
- query GetReportDataQuery ($ReportID: Int!) {
181
- GetReportData(ReportID: $ReportID) {
182
- Success
183
- Results
184
- RowCount
185
- ExecutionTime
186
- ErrorMessage
187
- }
179
+ const query = (0, graphql_request_1.gql) `
180
+ query GetReportDataQuery ($ReportID: Int!) {
181
+ GetReportData(ReportID: $ReportID) {
182
+ Success
183
+ Results
184
+ RowCount
185
+ ExecutionTime
186
+ ErrorMessage
187
+ }
188
188
  }`;
189
189
  const result = await GraphQLDataProvider.ExecuteGQL(query, { ReportID: params.ReportID });
190
190
  if (result && result.GetReportData)
@@ -204,15 +204,15 @@ class GraphQLDataProvider extends core_1.ProviderBase {
204
204
  // START ---- IRunQueryProvider
205
205
  /**************************************************************************/
206
206
  async RunQuery(params, contextUser) {
207
- const query = (0, graphql_request_1.gql) `
208
- query GetQueryDataQuery ($QueryID: Int!) {
209
- GetQueryData(QueryID: $QueryID) {
210
- Success
211
- Results
212
- RowCount
213
- ExecutionTime
214
- ErrorMessage
215
- }
207
+ const query = (0, graphql_request_1.gql) `
208
+ query GetQueryDataQuery ($QueryID: Int!) {
209
+ GetQueryData(QueryID: $QueryID) {
210
+ Success
211
+ Results
212
+ RowCount
213
+ ExecutionTime
214
+ ErrorMessage
215
+ }
216
216
  }`;
217
217
  const queryId = typeof params.QueryID === 'string' ? parseInt(params.QueryID) : params.QueryID;
218
218
  const result = await GraphQLDataProvider.ExecuteGQL(query, { QueryID: queryId });
@@ -284,19 +284,19 @@ class GraphQLDataProvider extends core_1.ProviderBase {
284
284
  innerParams.SaveViewResults = params.SaveViewResults ? params.SaveViewResults : false;
285
285
  }
286
286
  const fieldList = this.getViewRunTimeFieldList(e, viewEntity, params, dynamicView);
287
- const query = (0, graphql_request_1.gql) `
288
- query RunViewQuery ($input: ${paramType}!) {
289
- ${qName}(input: $input) {
290
- Results {
291
- ${fieldList.join("\n ")}
292
- }
293
- UserViewRunID
294
- RowCount
295
- TotalRowCount
296
- ExecutionTime
297
- Success
298
- ErrorMessage
299
- }
287
+ const query = (0, graphql_request_1.gql) `
288
+ query RunViewQuery ($input: ${paramType}!) {
289
+ ${qName}(input: $input) {
290
+ Results {
291
+ ${fieldList.join("\n ")}
292
+ }
293
+ UserViewRunID
294
+ RowCount
295
+ TotalRowCount
296
+ ExecutionTime
297
+ Success
298
+ ErrorMessage
299
+ }
300
300
  }`;
301
301
  const viewData = await GraphQLDataProvider.ExecuteGQL(query, { input: innerParams });
302
302
  if (viewData && viewData[qName]) {
@@ -424,13 +424,13 @@ class GraphQLDataProvider extends core_1.ProviderBase {
424
424
  async GetRecordDependencies(entityName, primaryKeyValues) {
425
425
  try {
426
426
  // execute the gql query to get the dependencies
427
- const query = (0, graphql_request_1.gql) `query GetRecordDependenciesQuery ($entityName: String!, $primaryKeyValues: [PrimaryKeyValueInputType!]!) {
428
- GetRecordDependencies(entityName: $entityName, primaryKeyValues: $primaryKeyValues) {
429
- EntityName
430
- RelatedEntityName
431
- FieldName
432
- PrimaryKeyValue
433
- }
427
+ const query = (0, graphql_request_1.gql) `query GetRecordDependenciesQuery ($entityName: String!, $primaryKeyValues: [PrimaryKeyValueInputType!]!) {
428
+ GetRecordDependencies(entityName: $entityName, primaryKeyValues: $primaryKeyValues) {
429
+ EntityName
430
+ RelatedEntityName
431
+ FieldName
432
+ PrimaryKeyValue
433
+ }
434
434
  }`;
435
435
  // now we have our query built, execute it
436
436
  const vars = {
@@ -454,17 +454,17 @@ class GraphQLDataProvider extends core_1.ProviderBase {
454
454
  if (!params) {
455
455
  return null;
456
456
  }
457
- const query = (0, graphql_request_1.gql) `query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
458
- GetRecordDuplicates(params: $params) {
459
- EntityID
460
- Duplicates {
461
- ProbabilityScore
462
- PrimaryKeyValues {
463
- FieldName
464
- Value
465
- }
466
- }
467
- }
457
+ const query = (0, graphql_request_1.gql) `query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
458
+ GetRecordDuplicates(params: $params) {
459
+ EntityID
460
+ Duplicates {
461
+ ProbabilityScore
462
+ PrimaryKeyValues {
463
+ FieldName
464
+ Value
465
+ }
466
+ }
467
+ }
468
468
  }`;
469
469
  const data = await GraphQLDataProvider.ExecuteGQL(query, { params: {
470
470
  ...params,
@@ -483,21 +483,21 @@ class GraphQLDataProvider extends core_1.ProviderBase {
483
483
  async MergeRecords(request) {
484
484
  try {
485
485
  // execute the gql query to get the dependencies
486
- const mutation = (0, graphql_request_1.gql) `mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
487
- MergeRecords(request: $request) {
488
- Success
489
- OverallStatus
490
- RecordMergeLogID
491
- RecordStatus {
492
- PrimaryKeyValues {
493
- FieldName
494
- Value
495
- }
496
- Success
497
- RecordMergeDeletionLogID
498
- Message
499
- }
500
- }
486
+ const mutation = (0, graphql_request_1.gql) `mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
487
+ MergeRecords(request: $request) {
488
+ Success
489
+ OverallStatus
490
+ RecordMergeLogID
491
+ RecordStatus {
492
+ PrimaryKeyValues {
493
+ FieldName
494
+ Value
495
+ }
496
+ Success
497
+ RecordMergeDeletionLogID
498
+ Message
499
+ }
500
+ }
501
501
  }`;
502
502
  // create a new request that is compatible with the server's expectations where field maps and also the primary key values are all strings
503
503
  const newRequest = {
@@ -553,12 +553,12 @@ class GraphQLDataProvider extends core_1.ProviderBase {
553
553
  const mutationName = `${type}${entity.EntityInfo.ClassName}`;
554
554
  // only pass along writable fields, AND the PKEY value if this is an update
555
555
  const filteredFields = entity.Fields.filter(f => f.SQLType.trim().toLowerCase() !== 'uniqueidentifier' && (f.ReadOnly === false || (f.IsPrimaryKey && pKeyValue)));
556
- const inner = ` ${mutationName}(input: $input) {
557
- ${entity.Fields.map(f => f.CodeName).join("\n ")}
556
+ const inner = ` ${mutationName}(input: $input) {
557
+ ${entity.Fields.map(f => f.CodeName).join("\n ")}
558
558
  }`;
559
- const outer = (0, graphql_request_1.gql) `mutation ${type}${entity.EntityInfo.ClassName} ($input: ${mutationName}Input!) {
560
- ${inner}
561
- }
559
+ const outer = (0, graphql_request_1.gql) `mutation ${type}${entity.EntityInfo.ClassName} ($input: ${mutationName}Input!) {
560
+ ${inner}
561
+ }
562
562
  `;
563
563
  for (let i = 0; i < filteredFields.length; i++) {
564
564
  const f = filteredFields[i];
@@ -647,12 +647,12 @@ class GraphQLDataProvider extends core_1.ProviderBase {
647
647
  vars[field.CodeName] = val;
648
648
  }
649
649
  const rel = EntityRelationshipsToLoad && EntityRelationshipsToLoad.length > 0 ? this.getRelatedEntityString(entity.EntityInfo, EntityRelationshipsToLoad) : '';
650
- const query = (0, graphql_request_1.gql) `query Single${entity.EntityInfo.ClassName}${rel.length > 0 ? 'Full' : ''} (${pkeyOuterParamString}) {
651
- ${entity.EntityInfo.ClassName}(${pkeyInnerParamString}) {
652
- ${entity.Fields.filter(f => !f.EntityFieldInfo.IsBinaryFieldType).map(f => f.CodeName).join("\n ")}
653
- ${rel}
654
- }
655
- }
650
+ const query = (0, graphql_request_1.gql) `query Single${entity.EntityInfo.ClassName}${rel.length > 0 ? 'Full' : ''} (${pkeyOuterParamString}) {
651
+ ${entity.EntityInfo.ClassName}(${pkeyInnerParamString}) {
652
+ ${entity.Fields.filter(f => !f.EntityFieldInfo.IsBinaryFieldType).map(f => f.CodeName).join("\n ")}
653
+ ${rel}
654
+ }
655
+ }
656
656
  `;
657
657
  const d = await GraphQLDataProvider.ExecuteGQL(query, vars);
658
658
  if (d && d[entity.EntityInfo.ClassName]) {
@@ -672,10 +672,10 @@ class GraphQLDataProvider extends core_1.ProviderBase {
672
672
  if (EntityRelationshipsToLoad.indexOf(entityInfo.RelatedEntities[i].RelatedEntity) >= 0) {
673
673
  const r = entityInfo.RelatedEntities[i];
674
674
  const re = this.Entities.find(e => e.ID === r.RelatedEntityID);
675
- rel += `
676
- ${re.CodeName} {
677
- ${re.Fields.map(f => f.CodeName).join("\n ")}
678
- }
675
+ rel += `
676
+ ${re.CodeName} {
677
+ ${re.Fields.map(f => f.CodeName).join("\n ")}
678
+ }
679
679
  `;
680
680
  }
681
681
  }
@@ -702,13 +702,13 @@ class GraphQLDataProvider extends core_1.ProviderBase {
702
702
  returnValues += `${pk.CodeName}`;
703
703
  }
704
704
  const queryName = 'Delete' + entity.EntityInfo.ClassName;
705
- const inner = (0, graphql_request_1.gql) `${queryName}(${pkeyInnerParamString}) {
706
- ${returnValues}
707
- }
705
+ const inner = (0, graphql_request_1.gql) `${queryName}(${pkeyInnerParamString}) {
706
+ ${returnValues}
707
+ }
708
708
  `;
709
- const query = (0, graphql_request_1.gql) `mutation ${queryName} (${pkeyOuterParamString}) {
710
- ${inner}
711
- }
709
+ const query = (0, graphql_request_1.gql) `mutation ${queryName} (${pkeyOuterParamString}) {
710
+ ${inner}
711
+ }
712
712
  `;
713
713
  if (entity.TransactionGroup) {
714
714
  // we have a transaction group, need to play nice and be part of it
@@ -764,15 +764,15 @@ class GraphQLDataProvider extends core_1.ProviderBase {
764
764
  // START ---- IMetadataProvider
765
765
  /**************************************************************************/
766
766
  async GetDatasetByName(datasetName, itemFilters) {
767
- const query = (0, graphql_request_1.gql) `query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
768
- GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
769
- DatasetID
770
- DatasetName
771
- Success
772
- Status
773
- LatestUpdateDate
774
- Results
775
- }
767
+ const query = (0, graphql_request_1.gql) `query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
768
+ GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
769
+ DatasetID
770
+ DatasetName
771
+ Success
772
+ Status
773
+ LatestUpdateDate
774
+ Results
775
+ }
776
776
  }`;
777
777
  const data = await GraphQLDataProvider.ExecuteGQL(query, { DatasetName: datasetName, ItemFilters: itemFilters });
778
778
  if (data && data.GetDatasetByName && data.GetDatasetByName.Success) {
@@ -797,15 +797,15 @@ class GraphQLDataProvider extends core_1.ProviderBase {
797
797
  }
798
798
  }
799
799
  async GetDatasetStatusByName(datasetName, itemFilters) {
800
- const query = (0, graphql_request_1.gql) `query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
801
- GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
802
- DatasetID
803
- DatasetName
804
- Success
805
- Status
806
- LatestUpdateDate
807
- EntityUpdateDates
808
- }
800
+ const query = (0, graphql_request_1.gql) `query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
801
+ GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
802
+ DatasetID
803
+ DatasetName
804
+ Success
805
+ Status
806
+ LatestUpdateDate
807
+ EntityUpdateDates
808
+ }
809
809
  }`;
810
810
  const data = await GraphQLDataProvider.ExecuteGQL(query, { DatasetName: datasetName, ItemFilters: itemFilters });
811
811
  if (data && data.GetDatasetStatusByName && data.GetDatasetStatusByName.Success) {
@@ -836,11 +836,11 @@ class GraphQLDataProvider extends core_1.ProviderBase {
836
836
  const e = this.Entities.find(e => e.Name === entityName);
837
837
  if (!e)
838
838
  throw new Error(`Entity ${entityName} not found in metadata`);
839
- const query = (0, graphql_request_1.gql) `query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
840
- GetRecordFavoriteStatus(params: $params) {
841
- Success
842
- IsFavorite
843
- }
839
+ const query = (0, graphql_request_1.gql) `query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
840
+ GetRecordFavoriteStatus(params: $params) {
841
+ Success
842
+ IsFavorite
843
+ }
844
844
  }`;
845
845
  const data = await GraphQLDataProvider.ExecuteGQL(query, { params: {
846
846
  UserID: userId,
@@ -860,10 +860,10 @@ class GraphQLDataProvider extends core_1.ProviderBase {
860
860
  const e = this.Entities.find(e => e.Name === entityName);
861
861
  if (!e)
862
862
  throw new Error(`Entity ${entityName} not found in metadata`);
863
- const query = (0, graphql_request_1.gql) `mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
864
- SetRecordFavoriteStatus(params: $params){
865
- Success
866
- }
863
+ const query = (0, graphql_request_1.gql) `mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
864
+ SetRecordFavoriteStatus(params: $params){
865
+ Success
866
+ }
867
867
  }`;
868
868
  const data = await GraphQLDataProvider.ExecuteGQL(query, { params: {
869
869
  UserID: userId,
@@ -883,12 +883,12 @@ class GraphQLDataProvider extends core_1.ProviderBase {
883
883
  async GetEntityRecordName(entityName, primaryKeyValues) {
884
884
  if (!entityName || !primaryKeyValues)
885
885
  return null;
886
- const query = (0, graphql_request_1.gql) `query GetEntityRecordNameQuery ($EntityName: String!, $PrimaryKeyValues: [PrimaryKeyValueInputType!]!) {
887
- GetEntityRecordName(EntityName: $EntityName, PrimaryKeyValues: $PrimaryKeyValues) {
888
- Success
889
- Status
890
- RecordName
891
- }
886
+ const query = (0, graphql_request_1.gql) `query GetEntityRecordNameQuery ($EntityName: String!, $PrimaryKeyValues: [PrimaryKeyValueInputType!]!) {
887
+ GetEntityRecordName(EntityName: $EntityName, PrimaryKeyValues: $PrimaryKeyValues) {
888
+ Success
889
+ Status
890
+ RecordName
891
+ }
892
892
  }`;
893
893
  const data = await GraphQLDataProvider.ExecuteGQL(query, {
894
894
  EntityName: entityName,
@@ -906,17 +906,17 @@ class GraphQLDataProvider extends core_1.ProviderBase {
906
906
  async GetEntityRecordNames(info) {
907
907
  if (!info)
908
908
  return null;
909
- const query = (0, graphql_request_1.gql) `query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
910
- GetEntityRecordNames(info: $info) {
911
- Success
912
- Status
913
- PrimaryKeyValues {
914
- FieldName
915
- Value
916
- }
917
- EntityName
918
- RecordName
919
- }
909
+ const query = (0, graphql_request_1.gql) `query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
910
+ GetEntityRecordNames(info: $info) {
911
+ Success
912
+ Status
913
+ PrimaryKeyValues {
914
+ FieldName
915
+ Value
916
+ }
917
+ EntityName
918
+ RecordName
919
+ }
920
920
  }`;
921
921
  const data = await GraphQLDataProvider.ExecuteGQL(query, { info: info.map(i => {
922
922
  // map each info item so that each of its PrimaryKeyValues.Value is a string
@@ -1060,13 +1060,13 @@ class GraphQLDataProvider extends core_1.ProviderBase {
1060
1060
  const existingRequest = this._pushStatusRequests.find(r => r.sessionId === sessionId);
1061
1061
  if (existingRequest)
1062
1062
  return existingRequest.observable;
1063
- const SUBSCRIBE_TO_STATUS = (0, graphql_request_1.gql) `subscription StatusUpdates($sessionId: String!) {
1064
- statusUpdates(sessionId: $sessionId) {
1065
- date
1066
- message
1067
- sessionId
1068
- }
1069
- }
1063
+ const SUBSCRIBE_TO_STATUS = (0, graphql_request_1.gql) `subscription StatusUpdates($sessionId: String!) {
1064
+ statusUpdates(sessionId: $sessionId) {
1065
+ date
1066
+ message
1067
+ sessionId
1068
+ }
1069
+ }
1070
1070
  `;
1071
1071
  const newObservable = new rxjs_1.Observable((observer) => {
1072
1072
  const unsubscribe = this._wsClient.subscribe({ query: SUBSCRIBE_TO_STATUS, variables: { sessionId } }, {
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "@memberjunction/graphql-dataprovider",
3
- "version": "1.0.6",
4
- "description": "MemberJunction: GraphQL Client Data Provider",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "/dist"
9
- ],
10
- "scripts": {
11
- "start": "ts-node-dev src/index.ts",
12
- "test": "echo \"Error: no test specified\" && exit 1",
13
- "build:node": "tsc --project tsconfig.node.json",
14
- "build:browser": "tsc --project tsconfig.browser.json && webpack --config webpack.config.js",
15
- "build": "npm run build:node && npm run build:browser"
16
- },
17
- "author": "MemberJunction.com",
18
- "license": "ISC",
19
- "devDependencies": {
20
- "ts-loader": "^9.4.4",
21
- "ts-node-dev": "^2.0.0",
22
- "typescript": "^5.3.3",
23
- "webpack": "^5.88.2",
24
- "webpack-cli": "^5.1.4"
25
- },
26
- "dependencies": {
27
- "@memberjunction/core": "^1.0.6",
28
- "@memberjunction/core-entities": "^1.0.6",
29
- "@memberjunction/global": "^1.0.6",
30
- "graphql": "^16.6.0",
31
- "graphql-request": "^5.2.0",
32
- "graphql-ws": "^5.14.0",
33
- "idb": "^7.1.1",
34
- "rxjs": "^7.8.1"
35
- }
36
- }
1
+ {
2
+ "name": "@memberjunction/graphql-dataprovider",
3
+ "version": "1.0.7",
4
+ "description": "MemberJunction: GraphQL Client Data Provider",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "start": "ts-node-dev src/index.ts",
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "build:node": "tsc --project tsconfig.node.json",
14
+ "build:browser": "tsc --project tsconfig.browser.json && webpack --config webpack.config.js",
15
+ "build": "npm run build:node && npm run build:browser"
16
+ },
17
+ "author": "MemberJunction.com",
18
+ "license": "ISC",
19
+ "devDependencies": {
20
+ "ts-loader": "^9.4.4",
21
+ "ts-node-dev": "^2.0.0",
22
+ "typescript": "^5.3.3",
23
+ "webpack": "^5.88.2",
24
+ "webpack-cli": "^5.1.4"
25
+ },
26
+ "dependencies": {
27
+ "@memberjunction/core": "^1.0.7",
28
+ "@memberjunction/core-entities": "^1.0.7",
29
+ "@memberjunction/global": "^1.0.7",
30
+ "graphql": "^16.6.0",
31
+ "graphql-request": "^5.2.0",
32
+ "graphql-ws": "^5.14.0",
33
+ "idb": "^7.1.1",
34
+ "rxjs": "^7.8.1"
35
+ }
36
+ }