@graphql-mesh/odata 1.0.0-alpha-20230523155104-df277a22b → 1.0.0-alpha-20230523160518-5443a1139
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/cjs/index.js +61 -48
- package/esm/index.js +61 -48
- package/package.json +7 -10
package/cjs/index.js
CHANGED
|
@@ -123,7 +123,7 @@ class ODataHandler {
|
|
|
123
123
|
const contextDataloaderName = Symbol(`${this.name}DataLoader`);
|
|
124
124
|
function getNamespaceFromTypeRef(typeRef) {
|
|
125
125
|
let namespace = '';
|
|
126
|
-
namespaces
|
|
126
|
+
namespaces === null || namespaces === void 0 ? void 0 : namespaces.forEach(el => {
|
|
127
127
|
if (typeRef.startsWith(el) &&
|
|
128
128
|
el.length > namespace.length && // It can be deeper namespace
|
|
129
129
|
!typeRef.replace(el + '.', '').includes('.') // Typename cannot have `.`
|
|
@@ -196,7 +196,7 @@ class ODataHandler {
|
|
|
196
196
|
}
|
|
197
197
|
const returnList = responseJson.value;
|
|
198
198
|
return returnList.map(element => {
|
|
199
|
-
if (!entityTypeExtensions
|
|
199
|
+
if (!(entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo)) {
|
|
200
200
|
return element;
|
|
201
201
|
}
|
|
202
202
|
const urlOfElement = new URL(urlStringWithoutSearchParams);
|
|
@@ -235,13 +235,13 @@ class ODataHandler {
|
|
|
235
235
|
else {
|
|
236
236
|
const actualReturnType = info.returnType;
|
|
237
237
|
const entityTypeExtensions = actualReturnType.extensions;
|
|
238
|
-
if (!entityTypeExtensions
|
|
238
|
+
if (!(entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo)) {
|
|
239
239
|
return responseJson;
|
|
240
240
|
}
|
|
241
241
|
const identifierUrl = responseJson['@odata.id'] || urlStringWithoutSearchParams;
|
|
242
242
|
const fieldMap = actualReturnType.getFields();
|
|
243
243
|
for (const fieldName in responseJson) {
|
|
244
|
-
if (entityTypeExtensions
|
|
244
|
+
if (entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo.navigationFields.includes(fieldName)) {
|
|
245
245
|
const field = responseJson[fieldName];
|
|
246
246
|
let fieldType = fieldMap[fieldName].type;
|
|
247
247
|
if ('ofType' in fieldType) {
|
|
@@ -306,7 +306,7 @@ class ODataHandler {
|
|
|
306
306
|
try {
|
|
307
307
|
return schemaComposer.getAnyTC(typeName);
|
|
308
308
|
}
|
|
309
|
-
catch { }
|
|
309
|
+
catch (_a) { }
|
|
310
310
|
}
|
|
311
311
|
return null;
|
|
312
312
|
}
|
|
@@ -351,6 +351,7 @@ class ODataHandler {
|
|
|
351
351
|
}
|
|
352
352
|
const DATALOADER_FACTORIES = {
|
|
353
353
|
multipart: (context) => new dataloader_1.default(async (requests) => {
|
|
354
|
+
var _a;
|
|
354
355
|
let requestBody = '';
|
|
355
356
|
const requestBoundary = 'batch_' + Date.now();
|
|
356
357
|
for (const requestIndex in requests) {
|
|
@@ -360,7 +361,7 @@ class ODataHandler {
|
|
|
360
361
|
requestBody += `Content-Transfer-Encoding:binary\n`;
|
|
361
362
|
requestBody += `Content-ID: ${requestIndex}\n\n`;
|
|
362
363
|
requestBody += `${request.method} ${request.url} HTTP/1.1\n`;
|
|
363
|
-
request.headers
|
|
364
|
+
(_a = request.headers) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
|
|
364
365
|
requestBody += `${key}: ${value}\n`;
|
|
365
366
|
});
|
|
366
367
|
if (request.body) {
|
|
@@ -411,11 +412,12 @@ class ODataHandler {
|
|
|
411
412
|
method: 'POST',
|
|
412
413
|
body: JSON.stringify({
|
|
413
414
|
requests: await Promise.all(requests.map(async (request, index) => {
|
|
415
|
+
var _a;
|
|
414
416
|
const id = index.toString();
|
|
415
417
|
const url = request.url.replace(endpoint, '');
|
|
416
418
|
const method = request.method;
|
|
417
419
|
const headers = {};
|
|
418
|
-
request.headers
|
|
420
|
+
(_a = request.headers) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
|
|
419
421
|
headers[key] = value;
|
|
420
422
|
});
|
|
421
423
|
return {
|
|
@@ -446,7 +448,7 @@ class ODataHandler {
|
|
|
446
448
|
const ref = alias + '.' + name;
|
|
447
449
|
return multipleSchemas ? (0, pascal_case_1.pascalCase)(ref.split('.').join('_')) : name;
|
|
448
450
|
}
|
|
449
|
-
schemas
|
|
451
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
450
452
|
const schemaNamespace = schemaObj.attributes.Namespace;
|
|
451
453
|
namespaces.add(schemaNamespace);
|
|
452
454
|
const schemaAlias = schemaObj.attributes.Alias;
|
|
@@ -454,11 +456,13 @@ class ODataHandler {
|
|
|
454
456
|
aliasNamespaceMap.set(schemaNamespace, schemaAlias);
|
|
455
457
|
}
|
|
456
458
|
});
|
|
457
|
-
schemas
|
|
459
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
460
|
+
var _a, _b, _c;
|
|
458
461
|
const schemaNamespace = schemaObj.attributes.Namespace;
|
|
459
|
-
schemaObj.EnumType
|
|
462
|
+
(_a = schemaObj.EnumType) === null || _a === void 0 ? void 0 : _a.forEach((enumObj) => {
|
|
463
|
+
var _a;
|
|
460
464
|
const values = {};
|
|
461
|
-
enumObj.Member
|
|
465
|
+
(_a = enumObj.Member) === null || _a === void 0 ? void 0 : _a.forEach((memberObj) => {
|
|
462
466
|
const key = memberObj.attributes.Name;
|
|
463
467
|
// This doesn't work.
|
|
464
468
|
// const value = memberElement.getAttribute('Value')!;
|
|
@@ -476,7 +480,8 @@ class ODataHandler {
|
|
|
476
480
|
});
|
|
477
481
|
const allTypes = (schemaObj.EntityType || []).concat(schemaObj.ComplexType || []);
|
|
478
482
|
const typesWithBaseType = allTypes.filter((typeObj) => typeObj.attributes.BaseType);
|
|
479
|
-
allTypes
|
|
483
|
+
allTypes === null || allTypes === void 0 ? void 0 : allTypes.forEach((typeObj) => {
|
|
484
|
+
var _a, _b, _c;
|
|
480
485
|
const entityTypeName = buildName({ schemaNamespace, name: typeObj.attributes.Name });
|
|
481
486
|
const isOpenType = typeObj.attributes.OpenType === 'true';
|
|
482
487
|
const isAbstract = typeObj.attributes.Abstract === 'true';
|
|
@@ -504,7 +509,8 @@ class ODataHandler {
|
|
|
504
509
|
name: isAbstract ? entityTypeName : `I${entityTypeName}`,
|
|
505
510
|
extensions,
|
|
506
511
|
resolveType: (root) => {
|
|
507
|
-
|
|
512
|
+
var _a;
|
|
513
|
+
const typeRef = (_a = root['@odata.type']) === null || _a === void 0 ? void 0 : _a.replace('#', '');
|
|
508
514
|
if (typeRef) {
|
|
509
515
|
const typeName = getTypeNameFromRef({
|
|
510
516
|
typeRef: root['@odata.type'].replace('#', ''),
|
|
@@ -522,13 +528,13 @@ class ODataHandler {
|
|
|
522
528
|
extensions,
|
|
523
529
|
interfaces: abstractType ? [abstractType] : [],
|
|
524
530
|
});
|
|
525
|
-
abstractType
|
|
531
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.setInputTypeComposer(inputType);
|
|
526
532
|
outputType.setInputTypeComposer(inputType);
|
|
527
533
|
const propertyRefObj = typeObj.Key && typeObj.Key[0].PropertyRef[0];
|
|
528
534
|
if (propertyRefObj) {
|
|
529
535
|
extensions.entityInfo.identifierFieldName = propertyRefObj.attributes.Name;
|
|
530
536
|
}
|
|
531
|
-
typeObj.Property
|
|
537
|
+
(_a = typeObj.Property) === null || _a === void 0 ? void 0 : _a.forEach((propertyObj) => {
|
|
532
538
|
const propertyName = propertyObj.attributes.Name;
|
|
533
539
|
extensions.entityInfo.actualFields.push(propertyName);
|
|
534
540
|
const propertyTypeRef = propertyObj.attributes.Type;
|
|
@@ -554,14 +560,14 @@ class ODataHandler {
|
|
|
554
560
|
}),
|
|
555
561
|
extensions: { propertyObj },
|
|
556
562
|
};
|
|
557
|
-
abstractType
|
|
563
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
558
564
|
[propertyName]: field,
|
|
559
565
|
});
|
|
560
566
|
outputType.addFields({
|
|
561
567
|
[propertyName]: field,
|
|
562
568
|
});
|
|
563
569
|
});
|
|
564
|
-
typeObj.NavigationProperty
|
|
570
|
+
(_b = typeObj.NavigationProperty) === null || _b === void 0 ? void 0 : _b.forEach((navigationPropertyObj) => {
|
|
565
571
|
const navigationPropertyName = navigationPropertyObj.attributes.Name;
|
|
566
572
|
extensions.entityInfo.navigationFields.push(navigationPropertyName);
|
|
567
573
|
const navigationPropertyTypeRef = navigationPropertyObj.attributes.Type;
|
|
@@ -594,7 +600,7 @@ class ODataHandler {
|
|
|
594
600
|
addIdentifierToUrl(url, entityInfo.identifierFieldName, entityInfo.identifierFieldTypeRef, args);
|
|
595
601
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
596
602
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
597
|
-
searchParams
|
|
603
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
598
604
|
url.searchParams.set(key, value);
|
|
599
605
|
});
|
|
600
606
|
const urlString = getUrlString(url);
|
|
@@ -633,7 +639,7 @@ class ODataHandler {
|
|
|
633
639
|
url.href = (0, url_join_1.default)(url.href, '/' + navigationPropertyName);
|
|
634
640
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
635
641
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
636
|
-
searchParams
|
|
642
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
637
643
|
url.searchParams.set(key, value);
|
|
638
644
|
});
|
|
639
645
|
const urlString = getUrlString(url);
|
|
@@ -653,7 +659,7 @@ class ODataHandler {
|
|
|
653
659
|
return handleResponseText(responseText, urlString, info);
|
|
654
660
|
},
|
|
655
661
|
};
|
|
656
|
-
abstractType
|
|
662
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
657
663
|
[navigationPropertyName]: pluralField,
|
|
658
664
|
[`${navigationPropertyName}ById`]: singularField,
|
|
659
665
|
});
|
|
@@ -681,7 +687,7 @@ class ODataHandler {
|
|
|
681
687
|
url.href = (0, url_join_1.default)(url.href, '/' + navigationPropertyName);
|
|
682
688
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
683
689
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
684
|
-
searchParams
|
|
690
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
685
691
|
url.searchParams.set(key, value);
|
|
686
692
|
});
|
|
687
693
|
const urlString = getUrlString(url);
|
|
@@ -701,7 +707,7 @@ class ODataHandler {
|
|
|
701
707
|
return handleResponseText(responseText, urlString, info);
|
|
702
708
|
},
|
|
703
709
|
};
|
|
704
|
-
abstractType
|
|
710
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
705
711
|
[navigationPropertyName]: field,
|
|
706
712
|
});
|
|
707
713
|
outputType.addFields({
|
|
@@ -716,7 +722,7 @@ class ODataHandler {
|
|
|
716
722
|
type: 'JSON',
|
|
717
723
|
},
|
|
718
724
|
});
|
|
719
|
-
abstractType
|
|
725
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
720
726
|
rest: {
|
|
721
727
|
type: 'JSON',
|
|
722
728
|
resolve: (root) => root,
|
|
@@ -730,13 +736,13 @@ class ODataHandler {
|
|
|
730
736
|
});
|
|
731
737
|
}
|
|
732
738
|
const updateInputType = inputType.clone(`${entityTypeName}UpdateInput`);
|
|
733
|
-
updateInputType
|
|
734
|
-
.getFieldNames()
|
|
735
|
-
?.forEach(fieldName => updateInputType.makeOptional(fieldName));
|
|
739
|
+
(_c = updateInputType
|
|
740
|
+
.getFieldNames()) === null || _c === void 0 ? void 0 : _c.forEach(fieldName => updateInputType.makeOptional(fieldName));
|
|
736
741
|
// Types might be considered as unused implementations of interfaces so we must prevent that
|
|
737
742
|
schemaComposer.addSchemaMustHaveType(outputType);
|
|
738
743
|
});
|
|
739
744
|
const handleUnboundFunctionObj = (unboundFunctionObj) => {
|
|
745
|
+
var _a;
|
|
740
746
|
const functionName = unboundFunctionObj.attributes.Name;
|
|
741
747
|
const returnTypeRef = unboundFunctionObj.ReturnType[0].attributes.Type;
|
|
742
748
|
const returnType = getTypeNameFromRef({
|
|
@@ -759,7 +765,7 @@ class ODataHandler {
|
|
|
759
765
|
.join(', ')})`;
|
|
760
766
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
761
767
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
762
|
-
searchParams
|
|
768
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
763
769
|
url.searchParams.set(key, value);
|
|
764
770
|
});
|
|
765
771
|
const urlString = getUrlString(url);
|
|
@@ -780,7 +786,7 @@ class ODataHandler {
|
|
|
780
786
|
},
|
|
781
787
|
},
|
|
782
788
|
});
|
|
783
|
-
unboundFunctionObj.Parameter
|
|
789
|
+
(_a = unboundFunctionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
784
790
|
const parameterName = parameterObj.attributes.Name;
|
|
785
791
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
786
792
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -797,6 +803,7 @@ class ODataHandler {
|
|
|
797
803
|
});
|
|
798
804
|
};
|
|
799
805
|
const handleBoundFunctionObj = (boundFunctionObj) => {
|
|
806
|
+
var _a, _b;
|
|
800
807
|
const functionName = boundFunctionObj.attributes.Name;
|
|
801
808
|
const functionRef = schemaNamespace + '.' + functionName;
|
|
802
809
|
const returnTypeRef = boundFunctionObj.ReturnType[0].attributes.Type;
|
|
@@ -809,10 +816,10 @@ class ODataHandler {
|
|
|
809
816
|
...commonArgs,
|
|
810
817
|
};
|
|
811
818
|
// eslint-disable-next-line prefer-const
|
|
812
|
-
let entitySetPath = boundFunctionObj.attributes.EntitySetPath
|
|
819
|
+
let entitySetPath = (_a = boundFunctionObj.attributes.EntitySetPath) === null || _a === void 0 ? void 0 : _a.split('/')[0];
|
|
813
820
|
let field;
|
|
814
821
|
let boundEntityTypeName;
|
|
815
|
-
boundFunctionObj.Parameter
|
|
822
|
+
(_b = boundFunctionObj.Parameter) === null || _b === void 0 ? void 0 : _b.forEach((parameterObj) => {
|
|
816
823
|
const parameterName = parameterObj.attributes.Name;
|
|
817
824
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
818
825
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -852,7 +859,7 @@ class ODataHandler {
|
|
|
852
859
|
}
|
|
853
860
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
854
861
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
855
|
-
searchParams
|
|
862
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
856
863
|
url.searchParams.set(key, value);
|
|
857
864
|
});
|
|
858
865
|
const urlString = getUrlString(url);
|
|
@@ -882,12 +889,13 @@ class ODataHandler {
|
|
|
882
889
|
boundEntityType.addFields({
|
|
883
890
|
[functionName]: field,
|
|
884
891
|
});
|
|
885
|
-
boundEntityOtherType
|
|
892
|
+
boundEntityOtherType === null || boundEntityOtherType === void 0 ? void 0 : boundEntityOtherType.addFields({
|
|
886
893
|
[functionName]: field,
|
|
887
894
|
});
|
|
888
895
|
};
|
|
889
|
-
schemaObj.Function
|
|
890
|
-
|
|
896
|
+
(_b = schemaObj.Function) === null || _b === void 0 ? void 0 : _b.forEach((functionObj) => {
|
|
897
|
+
var _a;
|
|
898
|
+
if (((_a = functionObj.attributes) === null || _a === void 0 ? void 0 : _a.IsBound) === 'true') {
|
|
891
899
|
handleBoundFunctionObj(functionObj);
|
|
892
900
|
}
|
|
893
901
|
else {
|
|
@@ -895,6 +903,7 @@ class ODataHandler {
|
|
|
895
903
|
}
|
|
896
904
|
});
|
|
897
905
|
const handleUnboundActionObj = (unboundActionObj) => {
|
|
906
|
+
var _a;
|
|
898
907
|
const actionName = unboundActionObj.attributes.Name;
|
|
899
908
|
schemaComposer.Mutation.addFields({
|
|
900
909
|
[actionName]: {
|
|
@@ -924,7 +933,7 @@ class ODataHandler {
|
|
|
924
933
|
},
|
|
925
934
|
},
|
|
926
935
|
});
|
|
927
|
-
unboundActionObj.Parameter
|
|
936
|
+
(_a = unboundActionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
928
937
|
const parameterName = parameterObj.attributes.Name;
|
|
929
938
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
930
939
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -941,6 +950,7 @@ class ODataHandler {
|
|
|
941
950
|
});
|
|
942
951
|
};
|
|
943
952
|
const handleBoundActionObj = (boundActionObj) => {
|
|
953
|
+
var _a;
|
|
944
954
|
const actionName = boundActionObj.attributes.Name;
|
|
945
955
|
const actionRef = schemaNamespace + '.' + actionName;
|
|
946
956
|
const args = {
|
|
@@ -949,7 +959,7 @@ class ODataHandler {
|
|
|
949
959
|
let entitySetPath = boundActionObj.attributes.EntitySetPath;
|
|
950
960
|
let boundField;
|
|
951
961
|
let boundEntityTypeName;
|
|
952
|
-
boundActionObj.Parameter
|
|
962
|
+
(_a = boundActionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
953
963
|
const parameterName = parameterObj.attributes.Name;
|
|
954
964
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
955
965
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -1002,12 +1012,13 @@ class ODataHandler {
|
|
|
1002
1012
|
[actionName]: boundField,
|
|
1003
1013
|
});
|
|
1004
1014
|
const otherType = getTCByTypeNames(`I${boundEntityTypeName}`, `T${boundEntityTypeName}`);
|
|
1005
|
-
otherType
|
|
1015
|
+
otherType === null || otherType === void 0 ? void 0 : otherType.addFields({
|
|
1006
1016
|
[actionName]: boundField,
|
|
1007
1017
|
});
|
|
1008
1018
|
};
|
|
1009
|
-
schemaObj.Action
|
|
1010
|
-
|
|
1019
|
+
(_c = schemaObj.Action) === null || _c === void 0 ? void 0 : _c.forEach((actionObj) => {
|
|
1020
|
+
var _a;
|
|
1021
|
+
if (((_a = actionObj.attributes) === null || _a === void 0 ? void 0 : _a.IsBound) === 'true') {
|
|
1011
1022
|
handleBoundActionObj(actionObj);
|
|
1012
1023
|
}
|
|
1013
1024
|
else {
|
|
@@ -1015,7 +1026,7 @@ class ODataHandler {
|
|
|
1015
1026
|
}
|
|
1016
1027
|
});
|
|
1017
1028
|
// Rearrange fields for base types and implementations
|
|
1018
|
-
typesWithBaseType
|
|
1029
|
+
typesWithBaseType === null || typesWithBaseType === void 0 ? void 0 : typesWithBaseType.forEach((typeObj) => {
|
|
1019
1030
|
const typeName = buildName({
|
|
1020
1031
|
schemaNamespace,
|
|
1021
1032
|
name: typeObj.attributes.Name,
|
|
@@ -1041,7 +1052,7 @@ class ODataHandler {
|
|
|
1041
1052
|
entityInfo.identifierFieldTypeRef =
|
|
1042
1053
|
baseEntityInfo.identifierFieldTypeRef || entityInfo.identifierFieldTypeRef;
|
|
1043
1054
|
entityInfo.actualFields.unshift(...baseEntityInfo.actualFields);
|
|
1044
|
-
abstractType
|
|
1055
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields(baseAbstractType === null || baseAbstractType === void 0 ? void 0 : baseAbstractType.getFields());
|
|
1045
1056
|
outputType.addFields(baseOutputType.getFields());
|
|
1046
1057
|
if (baseAbstractType instanceof graphql_compose_1.InterfaceTypeComposer) {
|
|
1047
1058
|
// abstractType.addInterface(baseAbstractType.getTypeName());
|
|
@@ -1053,9 +1064,11 @@ class ODataHandler {
|
|
|
1053
1064
|
baseEventEmitterListener();
|
|
1054
1065
|
});
|
|
1055
1066
|
});
|
|
1056
|
-
schemas
|
|
1057
|
-
|
|
1058
|
-
|
|
1067
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
1068
|
+
var _a;
|
|
1069
|
+
(_a = schemaObj.EntityContainer) === null || _a === void 0 ? void 0 : _a.forEach((entityContainerObj) => {
|
|
1070
|
+
var _a, _b;
|
|
1071
|
+
(_a = entityContainerObj.Singleton) === null || _a === void 0 ? void 0 : _a.forEach((singletonObj) => {
|
|
1059
1072
|
const singletonName = singletonObj.attributes.Name;
|
|
1060
1073
|
const singletonTypeRef = singletonObj.attributes.Type;
|
|
1061
1074
|
const singletonTypeName = getTypeNameFromRef({
|
|
@@ -1074,7 +1087,7 @@ class ODataHandler {
|
|
|
1074
1087
|
url.href = (0, url_join_1.default)(url.href, '/' + singletonName);
|
|
1075
1088
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
1076
1089
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1077
|
-
searchParams
|
|
1090
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1078
1091
|
url.searchParams.set(key, value);
|
|
1079
1092
|
});
|
|
1080
1093
|
const urlString = getUrlString(url);
|
|
@@ -1096,7 +1109,7 @@ class ODataHandler {
|
|
|
1096
1109
|
},
|
|
1097
1110
|
});
|
|
1098
1111
|
});
|
|
1099
|
-
entityContainerObj
|
|
1112
|
+
(_b = entityContainerObj === null || entityContainerObj === void 0 ? void 0 : entityContainerObj.EntitySet) === null || _b === void 0 ? void 0 : _b.forEach((entitySetObj) => {
|
|
1100
1113
|
const entitySetName = entitySetObj.attributes.Name;
|
|
1101
1114
|
const entitySetTypeRef = entitySetObj.attributes.EntityType;
|
|
1102
1115
|
const entityTypeName = getTypeNameFromRef({
|
|
@@ -1122,7 +1135,7 @@ class ODataHandler {
|
|
|
1122
1135
|
url.href = (0, url_join_1.default)(url.href, '/' + entitySetName);
|
|
1123
1136
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
1124
1137
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1125
|
-
searchParams
|
|
1138
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1126
1139
|
url.searchParams.set(key, value);
|
|
1127
1140
|
});
|
|
1128
1141
|
const urlString = getUrlString(url);
|
|
@@ -1156,7 +1169,7 @@ class ODataHandler {
|
|
|
1156
1169
|
addIdentifierToUrl(url, identifierFieldName, identifierFieldTypeRef, args);
|
|
1157
1170
|
const parsedInfoFragment = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
1158
1171
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1159
|
-
searchParams
|
|
1172
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1160
1173
|
url.searchParams.set(key, value);
|
|
1161
1174
|
});
|
|
1162
1175
|
const urlString = getUrlString(url);
|
package/esm/index.js
CHANGED
|
@@ -120,7 +120,7 @@ export default class ODataHandler {
|
|
|
120
120
|
const contextDataloaderName = Symbol(`${this.name}DataLoader`);
|
|
121
121
|
function getNamespaceFromTypeRef(typeRef) {
|
|
122
122
|
let namespace = '';
|
|
123
|
-
namespaces
|
|
123
|
+
namespaces === null || namespaces === void 0 ? void 0 : namespaces.forEach(el => {
|
|
124
124
|
if (typeRef.startsWith(el) &&
|
|
125
125
|
el.length > namespace.length && // It can be deeper namespace
|
|
126
126
|
!typeRef.replace(el + '.', '').includes('.') // Typename cannot have `.`
|
|
@@ -193,7 +193,7 @@ export default class ODataHandler {
|
|
|
193
193
|
}
|
|
194
194
|
const returnList = responseJson.value;
|
|
195
195
|
return returnList.map(element => {
|
|
196
|
-
if (!entityTypeExtensions
|
|
196
|
+
if (!(entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo)) {
|
|
197
197
|
return element;
|
|
198
198
|
}
|
|
199
199
|
const urlOfElement = new URL(urlStringWithoutSearchParams);
|
|
@@ -232,13 +232,13 @@ export default class ODataHandler {
|
|
|
232
232
|
else {
|
|
233
233
|
const actualReturnType = info.returnType;
|
|
234
234
|
const entityTypeExtensions = actualReturnType.extensions;
|
|
235
|
-
if (!entityTypeExtensions
|
|
235
|
+
if (!(entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo)) {
|
|
236
236
|
return responseJson;
|
|
237
237
|
}
|
|
238
238
|
const identifierUrl = responseJson['@odata.id'] || urlStringWithoutSearchParams;
|
|
239
239
|
const fieldMap = actualReturnType.getFields();
|
|
240
240
|
for (const fieldName in responseJson) {
|
|
241
|
-
if (entityTypeExtensions
|
|
241
|
+
if (entityTypeExtensions === null || entityTypeExtensions === void 0 ? void 0 : entityTypeExtensions.entityInfo.navigationFields.includes(fieldName)) {
|
|
242
242
|
const field = responseJson[fieldName];
|
|
243
243
|
let fieldType = fieldMap[fieldName].type;
|
|
244
244
|
if ('ofType' in fieldType) {
|
|
@@ -303,7 +303,7 @@ export default class ODataHandler {
|
|
|
303
303
|
try {
|
|
304
304
|
return schemaComposer.getAnyTC(typeName);
|
|
305
305
|
}
|
|
306
|
-
catch { }
|
|
306
|
+
catch (_a) { }
|
|
307
307
|
}
|
|
308
308
|
return null;
|
|
309
309
|
}
|
|
@@ -348,6 +348,7 @@ export default class ODataHandler {
|
|
|
348
348
|
}
|
|
349
349
|
const DATALOADER_FACTORIES = {
|
|
350
350
|
multipart: (context) => new DataLoader(async (requests) => {
|
|
351
|
+
var _a;
|
|
351
352
|
let requestBody = '';
|
|
352
353
|
const requestBoundary = 'batch_' + Date.now();
|
|
353
354
|
for (const requestIndex in requests) {
|
|
@@ -357,7 +358,7 @@ export default class ODataHandler {
|
|
|
357
358
|
requestBody += `Content-Transfer-Encoding:binary\n`;
|
|
358
359
|
requestBody += `Content-ID: ${requestIndex}\n\n`;
|
|
359
360
|
requestBody += `${request.method} ${request.url} HTTP/1.1\n`;
|
|
360
|
-
request.headers
|
|
361
|
+
(_a = request.headers) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
|
|
361
362
|
requestBody += `${key}: ${value}\n`;
|
|
362
363
|
});
|
|
363
364
|
if (request.body) {
|
|
@@ -408,11 +409,12 @@ export default class ODataHandler {
|
|
|
408
409
|
method: 'POST',
|
|
409
410
|
body: JSON.stringify({
|
|
410
411
|
requests: await Promise.all(requests.map(async (request, index) => {
|
|
412
|
+
var _a;
|
|
411
413
|
const id = index.toString();
|
|
412
414
|
const url = request.url.replace(endpoint, '');
|
|
413
415
|
const method = request.method;
|
|
414
416
|
const headers = {};
|
|
415
|
-
request.headers
|
|
417
|
+
(_a = request.headers) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
|
|
416
418
|
headers[key] = value;
|
|
417
419
|
});
|
|
418
420
|
return {
|
|
@@ -443,7 +445,7 @@ export default class ODataHandler {
|
|
|
443
445
|
const ref = alias + '.' + name;
|
|
444
446
|
return multipleSchemas ? pascalCase(ref.split('.').join('_')) : name;
|
|
445
447
|
}
|
|
446
|
-
schemas
|
|
448
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
447
449
|
const schemaNamespace = schemaObj.attributes.Namespace;
|
|
448
450
|
namespaces.add(schemaNamespace);
|
|
449
451
|
const schemaAlias = schemaObj.attributes.Alias;
|
|
@@ -451,11 +453,13 @@ export default class ODataHandler {
|
|
|
451
453
|
aliasNamespaceMap.set(schemaNamespace, schemaAlias);
|
|
452
454
|
}
|
|
453
455
|
});
|
|
454
|
-
schemas
|
|
456
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
457
|
+
var _a, _b, _c;
|
|
455
458
|
const schemaNamespace = schemaObj.attributes.Namespace;
|
|
456
|
-
schemaObj.EnumType
|
|
459
|
+
(_a = schemaObj.EnumType) === null || _a === void 0 ? void 0 : _a.forEach((enumObj) => {
|
|
460
|
+
var _a;
|
|
457
461
|
const values = {};
|
|
458
|
-
enumObj.Member
|
|
462
|
+
(_a = enumObj.Member) === null || _a === void 0 ? void 0 : _a.forEach((memberObj) => {
|
|
459
463
|
const key = memberObj.attributes.Name;
|
|
460
464
|
// This doesn't work.
|
|
461
465
|
// const value = memberElement.getAttribute('Value')!;
|
|
@@ -473,7 +477,8 @@ export default class ODataHandler {
|
|
|
473
477
|
});
|
|
474
478
|
const allTypes = (schemaObj.EntityType || []).concat(schemaObj.ComplexType || []);
|
|
475
479
|
const typesWithBaseType = allTypes.filter((typeObj) => typeObj.attributes.BaseType);
|
|
476
|
-
allTypes
|
|
480
|
+
allTypes === null || allTypes === void 0 ? void 0 : allTypes.forEach((typeObj) => {
|
|
481
|
+
var _a, _b, _c;
|
|
477
482
|
const entityTypeName = buildName({ schemaNamespace, name: typeObj.attributes.Name });
|
|
478
483
|
const isOpenType = typeObj.attributes.OpenType === 'true';
|
|
479
484
|
const isAbstract = typeObj.attributes.Abstract === 'true';
|
|
@@ -501,7 +506,8 @@ export default class ODataHandler {
|
|
|
501
506
|
name: isAbstract ? entityTypeName : `I${entityTypeName}`,
|
|
502
507
|
extensions,
|
|
503
508
|
resolveType: (root) => {
|
|
504
|
-
|
|
509
|
+
var _a;
|
|
510
|
+
const typeRef = (_a = root['@odata.type']) === null || _a === void 0 ? void 0 : _a.replace('#', '');
|
|
505
511
|
if (typeRef) {
|
|
506
512
|
const typeName = getTypeNameFromRef({
|
|
507
513
|
typeRef: root['@odata.type'].replace('#', ''),
|
|
@@ -519,13 +525,13 @@ export default class ODataHandler {
|
|
|
519
525
|
extensions,
|
|
520
526
|
interfaces: abstractType ? [abstractType] : [],
|
|
521
527
|
});
|
|
522
|
-
abstractType
|
|
528
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.setInputTypeComposer(inputType);
|
|
523
529
|
outputType.setInputTypeComposer(inputType);
|
|
524
530
|
const propertyRefObj = typeObj.Key && typeObj.Key[0].PropertyRef[0];
|
|
525
531
|
if (propertyRefObj) {
|
|
526
532
|
extensions.entityInfo.identifierFieldName = propertyRefObj.attributes.Name;
|
|
527
533
|
}
|
|
528
|
-
typeObj.Property
|
|
534
|
+
(_a = typeObj.Property) === null || _a === void 0 ? void 0 : _a.forEach((propertyObj) => {
|
|
529
535
|
const propertyName = propertyObj.attributes.Name;
|
|
530
536
|
extensions.entityInfo.actualFields.push(propertyName);
|
|
531
537
|
const propertyTypeRef = propertyObj.attributes.Type;
|
|
@@ -551,14 +557,14 @@ export default class ODataHandler {
|
|
|
551
557
|
}),
|
|
552
558
|
extensions: { propertyObj },
|
|
553
559
|
};
|
|
554
|
-
abstractType
|
|
560
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
555
561
|
[propertyName]: field,
|
|
556
562
|
});
|
|
557
563
|
outputType.addFields({
|
|
558
564
|
[propertyName]: field,
|
|
559
565
|
});
|
|
560
566
|
});
|
|
561
|
-
typeObj.NavigationProperty
|
|
567
|
+
(_b = typeObj.NavigationProperty) === null || _b === void 0 ? void 0 : _b.forEach((navigationPropertyObj) => {
|
|
562
568
|
const navigationPropertyName = navigationPropertyObj.attributes.Name;
|
|
563
569
|
extensions.entityInfo.navigationFields.push(navigationPropertyName);
|
|
564
570
|
const navigationPropertyTypeRef = navigationPropertyObj.attributes.Type;
|
|
@@ -591,7 +597,7 @@ export default class ODataHandler {
|
|
|
591
597
|
addIdentifierToUrl(url, entityInfo.identifierFieldName, entityInfo.identifierFieldTypeRef, args);
|
|
592
598
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
593
599
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
594
|
-
searchParams
|
|
600
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
595
601
|
url.searchParams.set(key, value);
|
|
596
602
|
});
|
|
597
603
|
const urlString = getUrlString(url);
|
|
@@ -630,7 +636,7 @@ export default class ODataHandler {
|
|
|
630
636
|
url.href = urljoin(url.href, '/' + navigationPropertyName);
|
|
631
637
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
632
638
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
633
|
-
searchParams
|
|
639
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
634
640
|
url.searchParams.set(key, value);
|
|
635
641
|
});
|
|
636
642
|
const urlString = getUrlString(url);
|
|
@@ -650,7 +656,7 @@ export default class ODataHandler {
|
|
|
650
656
|
return handleResponseText(responseText, urlString, info);
|
|
651
657
|
},
|
|
652
658
|
};
|
|
653
|
-
abstractType
|
|
659
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
654
660
|
[navigationPropertyName]: pluralField,
|
|
655
661
|
[`${navigationPropertyName}ById`]: singularField,
|
|
656
662
|
});
|
|
@@ -678,7 +684,7 @@ export default class ODataHandler {
|
|
|
678
684
|
url.href = urljoin(url.href, '/' + navigationPropertyName);
|
|
679
685
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
680
686
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
681
|
-
searchParams
|
|
687
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
682
688
|
url.searchParams.set(key, value);
|
|
683
689
|
});
|
|
684
690
|
const urlString = getUrlString(url);
|
|
@@ -698,7 +704,7 @@ export default class ODataHandler {
|
|
|
698
704
|
return handleResponseText(responseText, urlString, info);
|
|
699
705
|
},
|
|
700
706
|
};
|
|
701
|
-
abstractType
|
|
707
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
702
708
|
[navigationPropertyName]: field,
|
|
703
709
|
});
|
|
704
710
|
outputType.addFields({
|
|
@@ -713,7 +719,7 @@ export default class ODataHandler {
|
|
|
713
719
|
type: 'JSON',
|
|
714
720
|
},
|
|
715
721
|
});
|
|
716
|
-
abstractType
|
|
722
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields({
|
|
717
723
|
rest: {
|
|
718
724
|
type: 'JSON',
|
|
719
725
|
resolve: (root) => root,
|
|
@@ -727,13 +733,13 @@ export default class ODataHandler {
|
|
|
727
733
|
});
|
|
728
734
|
}
|
|
729
735
|
const updateInputType = inputType.clone(`${entityTypeName}UpdateInput`);
|
|
730
|
-
updateInputType
|
|
731
|
-
.getFieldNames()
|
|
732
|
-
?.forEach(fieldName => updateInputType.makeOptional(fieldName));
|
|
736
|
+
(_c = updateInputType
|
|
737
|
+
.getFieldNames()) === null || _c === void 0 ? void 0 : _c.forEach(fieldName => updateInputType.makeOptional(fieldName));
|
|
733
738
|
// Types might be considered as unused implementations of interfaces so we must prevent that
|
|
734
739
|
schemaComposer.addSchemaMustHaveType(outputType);
|
|
735
740
|
});
|
|
736
741
|
const handleUnboundFunctionObj = (unboundFunctionObj) => {
|
|
742
|
+
var _a;
|
|
737
743
|
const functionName = unboundFunctionObj.attributes.Name;
|
|
738
744
|
const returnTypeRef = unboundFunctionObj.ReturnType[0].attributes.Type;
|
|
739
745
|
const returnType = getTypeNameFromRef({
|
|
@@ -756,7 +762,7 @@ export default class ODataHandler {
|
|
|
756
762
|
.join(', ')})`;
|
|
757
763
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
758
764
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
759
|
-
searchParams
|
|
765
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
760
766
|
url.searchParams.set(key, value);
|
|
761
767
|
});
|
|
762
768
|
const urlString = getUrlString(url);
|
|
@@ -777,7 +783,7 @@ export default class ODataHandler {
|
|
|
777
783
|
},
|
|
778
784
|
},
|
|
779
785
|
});
|
|
780
|
-
unboundFunctionObj.Parameter
|
|
786
|
+
(_a = unboundFunctionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
781
787
|
const parameterName = parameterObj.attributes.Name;
|
|
782
788
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
783
789
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -794,6 +800,7 @@ export default class ODataHandler {
|
|
|
794
800
|
});
|
|
795
801
|
};
|
|
796
802
|
const handleBoundFunctionObj = (boundFunctionObj) => {
|
|
803
|
+
var _a, _b;
|
|
797
804
|
const functionName = boundFunctionObj.attributes.Name;
|
|
798
805
|
const functionRef = schemaNamespace + '.' + functionName;
|
|
799
806
|
const returnTypeRef = boundFunctionObj.ReturnType[0].attributes.Type;
|
|
@@ -806,10 +813,10 @@ export default class ODataHandler {
|
|
|
806
813
|
...commonArgs,
|
|
807
814
|
};
|
|
808
815
|
// eslint-disable-next-line prefer-const
|
|
809
|
-
let entitySetPath = boundFunctionObj.attributes.EntitySetPath
|
|
816
|
+
let entitySetPath = (_a = boundFunctionObj.attributes.EntitySetPath) === null || _a === void 0 ? void 0 : _a.split('/')[0];
|
|
810
817
|
let field;
|
|
811
818
|
let boundEntityTypeName;
|
|
812
|
-
boundFunctionObj.Parameter
|
|
819
|
+
(_b = boundFunctionObj.Parameter) === null || _b === void 0 ? void 0 : _b.forEach((parameterObj) => {
|
|
813
820
|
const parameterName = parameterObj.attributes.Name;
|
|
814
821
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
815
822
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -849,7 +856,7 @@ export default class ODataHandler {
|
|
|
849
856
|
}
|
|
850
857
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
851
858
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
852
|
-
searchParams
|
|
859
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
853
860
|
url.searchParams.set(key, value);
|
|
854
861
|
});
|
|
855
862
|
const urlString = getUrlString(url);
|
|
@@ -879,12 +886,13 @@ export default class ODataHandler {
|
|
|
879
886
|
boundEntityType.addFields({
|
|
880
887
|
[functionName]: field,
|
|
881
888
|
});
|
|
882
|
-
boundEntityOtherType
|
|
889
|
+
boundEntityOtherType === null || boundEntityOtherType === void 0 ? void 0 : boundEntityOtherType.addFields({
|
|
883
890
|
[functionName]: field,
|
|
884
891
|
});
|
|
885
892
|
};
|
|
886
|
-
schemaObj.Function
|
|
887
|
-
|
|
893
|
+
(_b = schemaObj.Function) === null || _b === void 0 ? void 0 : _b.forEach((functionObj) => {
|
|
894
|
+
var _a;
|
|
895
|
+
if (((_a = functionObj.attributes) === null || _a === void 0 ? void 0 : _a.IsBound) === 'true') {
|
|
888
896
|
handleBoundFunctionObj(functionObj);
|
|
889
897
|
}
|
|
890
898
|
else {
|
|
@@ -892,6 +900,7 @@ export default class ODataHandler {
|
|
|
892
900
|
}
|
|
893
901
|
});
|
|
894
902
|
const handleUnboundActionObj = (unboundActionObj) => {
|
|
903
|
+
var _a;
|
|
895
904
|
const actionName = unboundActionObj.attributes.Name;
|
|
896
905
|
schemaComposer.Mutation.addFields({
|
|
897
906
|
[actionName]: {
|
|
@@ -921,7 +930,7 @@ export default class ODataHandler {
|
|
|
921
930
|
},
|
|
922
931
|
},
|
|
923
932
|
});
|
|
924
|
-
unboundActionObj.Parameter
|
|
933
|
+
(_a = unboundActionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
925
934
|
const parameterName = parameterObj.attributes.Name;
|
|
926
935
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
927
936
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -938,6 +947,7 @@ export default class ODataHandler {
|
|
|
938
947
|
});
|
|
939
948
|
};
|
|
940
949
|
const handleBoundActionObj = (boundActionObj) => {
|
|
950
|
+
var _a;
|
|
941
951
|
const actionName = boundActionObj.attributes.Name;
|
|
942
952
|
const actionRef = schemaNamespace + '.' + actionName;
|
|
943
953
|
const args = {
|
|
@@ -946,7 +956,7 @@ export default class ODataHandler {
|
|
|
946
956
|
let entitySetPath = boundActionObj.attributes.EntitySetPath;
|
|
947
957
|
let boundField;
|
|
948
958
|
let boundEntityTypeName;
|
|
949
|
-
boundActionObj.Parameter
|
|
959
|
+
(_a = boundActionObj.Parameter) === null || _a === void 0 ? void 0 : _a.forEach((parameterObj) => {
|
|
950
960
|
const parameterName = parameterObj.attributes.Name;
|
|
951
961
|
const parameterTypeRef = parameterObj.attributes.Type;
|
|
952
962
|
const isRequired = parameterObj.attributes.Nullable === 'false';
|
|
@@ -999,12 +1009,13 @@ export default class ODataHandler {
|
|
|
999
1009
|
[actionName]: boundField,
|
|
1000
1010
|
});
|
|
1001
1011
|
const otherType = getTCByTypeNames(`I${boundEntityTypeName}`, `T${boundEntityTypeName}`);
|
|
1002
|
-
otherType
|
|
1012
|
+
otherType === null || otherType === void 0 ? void 0 : otherType.addFields({
|
|
1003
1013
|
[actionName]: boundField,
|
|
1004
1014
|
});
|
|
1005
1015
|
};
|
|
1006
|
-
schemaObj.Action
|
|
1007
|
-
|
|
1016
|
+
(_c = schemaObj.Action) === null || _c === void 0 ? void 0 : _c.forEach((actionObj) => {
|
|
1017
|
+
var _a;
|
|
1018
|
+
if (((_a = actionObj.attributes) === null || _a === void 0 ? void 0 : _a.IsBound) === 'true') {
|
|
1008
1019
|
handleBoundActionObj(actionObj);
|
|
1009
1020
|
}
|
|
1010
1021
|
else {
|
|
@@ -1012,7 +1023,7 @@ export default class ODataHandler {
|
|
|
1012
1023
|
}
|
|
1013
1024
|
});
|
|
1014
1025
|
// Rearrange fields for base types and implementations
|
|
1015
|
-
typesWithBaseType
|
|
1026
|
+
typesWithBaseType === null || typesWithBaseType === void 0 ? void 0 : typesWithBaseType.forEach((typeObj) => {
|
|
1016
1027
|
const typeName = buildName({
|
|
1017
1028
|
schemaNamespace,
|
|
1018
1029
|
name: typeObj.attributes.Name,
|
|
@@ -1038,7 +1049,7 @@ export default class ODataHandler {
|
|
|
1038
1049
|
entityInfo.identifierFieldTypeRef =
|
|
1039
1050
|
baseEntityInfo.identifierFieldTypeRef || entityInfo.identifierFieldTypeRef;
|
|
1040
1051
|
entityInfo.actualFields.unshift(...baseEntityInfo.actualFields);
|
|
1041
|
-
abstractType
|
|
1052
|
+
abstractType === null || abstractType === void 0 ? void 0 : abstractType.addFields(baseAbstractType === null || baseAbstractType === void 0 ? void 0 : baseAbstractType.getFields());
|
|
1042
1053
|
outputType.addFields(baseOutputType.getFields());
|
|
1043
1054
|
if (baseAbstractType instanceof InterfaceTypeComposer) {
|
|
1044
1055
|
// abstractType.addInterface(baseAbstractType.getTypeName());
|
|
@@ -1050,9 +1061,11 @@ export default class ODataHandler {
|
|
|
1050
1061
|
baseEventEmitterListener();
|
|
1051
1062
|
});
|
|
1052
1063
|
});
|
|
1053
|
-
schemas
|
|
1054
|
-
|
|
1055
|
-
|
|
1064
|
+
schemas === null || schemas === void 0 ? void 0 : schemas.forEach((schemaObj) => {
|
|
1065
|
+
var _a;
|
|
1066
|
+
(_a = schemaObj.EntityContainer) === null || _a === void 0 ? void 0 : _a.forEach((entityContainerObj) => {
|
|
1067
|
+
var _a, _b;
|
|
1068
|
+
(_a = entityContainerObj.Singleton) === null || _a === void 0 ? void 0 : _a.forEach((singletonObj) => {
|
|
1056
1069
|
const singletonName = singletonObj.attributes.Name;
|
|
1057
1070
|
const singletonTypeRef = singletonObj.attributes.Type;
|
|
1058
1071
|
const singletonTypeName = getTypeNameFromRef({
|
|
@@ -1071,7 +1084,7 @@ export default class ODataHandler {
|
|
|
1071
1084
|
url.href = urljoin(url.href, '/' + singletonName);
|
|
1072
1085
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
1073
1086
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1074
|
-
searchParams
|
|
1087
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1075
1088
|
url.searchParams.set(key, value);
|
|
1076
1089
|
});
|
|
1077
1090
|
const urlString = getUrlString(url);
|
|
@@ -1093,7 +1106,7 @@ export default class ODataHandler {
|
|
|
1093
1106
|
},
|
|
1094
1107
|
});
|
|
1095
1108
|
});
|
|
1096
|
-
entityContainerObj
|
|
1109
|
+
(_b = entityContainerObj === null || entityContainerObj === void 0 ? void 0 : entityContainerObj.EntitySet) === null || _b === void 0 ? void 0 : _b.forEach((entitySetObj) => {
|
|
1097
1110
|
const entitySetName = entitySetObj.attributes.Name;
|
|
1098
1111
|
const entitySetTypeRef = entitySetObj.attributes.EntityType;
|
|
1099
1112
|
const entityTypeName = getTypeNameFromRef({
|
|
@@ -1119,7 +1132,7 @@ export default class ODataHandler {
|
|
|
1119
1132
|
url.href = urljoin(url.href, '/' + entitySetName);
|
|
1120
1133
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
1121
1134
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1122
|
-
searchParams
|
|
1135
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1123
1136
|
url.searchParams.set(key, value);
|
|
1124
1137
|
});
|
|
1125
1138
|
const urlString = getUrlString(url);
|
|
@@ -1153,7 +1166,7 @@ export default class ODataHandler {
|
|
|
1153
1166
|
addIdentifierToUrl(url, identifierFieldName, identifierFieldTypeRef, args);
|
|
1154
1167
|
const parsedInfoFragment = parseResolveInfo(info);
|
|
1155
1168
|
const searchParams = this.prepareSearchParams(parsedInfoFragment, info.schema);
|
|
1156
|
-
searchParams
|
|
1169
|
+
searchParams === null || searchParams === void 0 ? void 0 : searchParams.forEach((value, key) => {
|
|
1157
1170
|
url.searchParams.set(key, value);
|
|
1158
1171
|
});
|
|
1159
1172
|
const urlString = getUrlString(url);
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/odata",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230523160518-5443a1139",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/cross-helpers": "0.4.0-alpha-
|
|
7
|
-
"@graphql-mesh/store": "1.0.0-alpha-
|
|
8
|
-
"@graphql-mesh/types": "1.0.0-alpha-
|
|
9
|
-
"@graphql-mesh/utils": "1.0.0-alpha-
|
|
6
|
+
"@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523160518-5443a1139",
|
|
7
|
+
"@graphql-mesh/store": "1.0.0-alpha-20230523160518-5443a1139",
|
|
8
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230523160518-5443a1139",
|
|
9
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230523160518-5443a1139",
|
|
10
10
|
"@graphql-tools/utils": "^9.2.1",
|
|
11
11
|
"graphql": "*",
|
|
12
12
|
"tslib": "^2.4.0"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@graphql-mesh/string-interpolation": "0.5.0-alpha-
|
|
15
|
+
"@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523160518-5443a1139",
|
|
16
16
|
"@graphql-tools/delegate": "^9.0.32",
|
|
17
|
-
"@whatwg-node/fetch": "^0.
|
|
17
|
+
"@whatwg-node/fetch": "^0.8.3",
|
|
18
18
|
"dataloader": "^2.2.2",
|
|
19
19
|
"fast-xml-parser": "^4.2.1",
|
|
20
20
|
"graphql-compose": "^9.0.10",
|
|
@@ -30,9 +30,6 @@
|
|
|
30
30
|
"directory": "packages/handlers/odata"
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=16.0.0"
|
|
35
|
-
},
|
|
36
33
|
"main": "cjs/index.js",
|
|
37
34
|
"module": "esm/index.js",
|
|
38
35
|
"typings": "typings/index.d.ts",
|