@restorecommerce/facade 1.2.0 → 1.3.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.
- package/.eslintignore +3 -0
- package/.eslintrc.cjs +13 -0
- package/CHANGELOG.md +22 -0
- package/codegen/index.d.ts +1 -1
- package/codegen/index.js +18 -44
- package/debug-run.ts +7 -6
- package/dist/gql/index.d.ts +1 -1
- package/dist/gql/index.js +1 -17
- package/dist/gql/protos/federation.d.ts +3 -3
- package/dist/gql/protos/federation.js +16 -24
- package/dist/gql/protos/graphql.d.ts +4 -4
- package/dist/gql/protos/graphql.js +64 -42
- package/dist/gql/protos/index.d.ts +6 -6
- package/dist/gql/protos/index.js +6 -22
- package/dist/gql/protos/registry.d.ts +6 -6
- package/dist/gql/protos/registry.js +157 -176
- package/dist/gql/protos/resolvers.d.ts +3 -3
- package/dist/gql/protos/resolvers.js +78 -104
- package/dist/gql/protos/schema.d.ts +4 -4
- package/dist/gql/protos/schema.js +40 -53
- package/dist/gql/protos/types.d.ts +3 -3
- package/dist/gql/protos/types.js +1 -4
- package/dist/gql/protos/utils.d.ts +3 -3
- package/dist/gql/protos/utils.js +23 -62
- package/dist/gql/types/AccessControlTypes.js +13 -16
- package/dist/gql/types/DateType.js +4 -7
- package/dist/gql/types/FilterType.js +7 -10
- package/dist/gql/types/MetaType.js +8 -11
- package/dist/gql/types/ScopeType.js +4 -7
- package/dist/gql/types/SortType.js +5 -8
- package/dist/gql/types/StatusType.js +4 -7
- package/dist/gql/types/index.d.ts +7 -7
- package/dist/gql/types/index.js +7 -23
- package/dist/index.d.ts +14 -14
- package/dist/index.js +195 -207
- package/dist/interfaces.d.ts +8 -8
- package/dist/interfaces.js +1 -2
- package/dist/middlewares/index.d.ts +1 -1
- package/dist/middlewares/index.js +1 -17
- package/dist/middlewares/req-res-logger/index.d.ts +2 -2
- package/dist/middlewares/req-res-logger/index.js +33 -31
- package/dist/modules/access-control/gql/federation.d.ts +1 -1
- package/dist/modules/access-control/gql/federation.js +10 -17
- package/dist/modules/access-control/gql/schema.d.ts +1 -1
- package/dist/modules/access-control/gql/schema.generated.d.ts +136 -110
- package/dist/modules/access-control/gql/schema.generated.js +22 -25
- package/dist/modules/access-control/gql/schema.js +5 -9
- package/dist/modules/access-control/gql/types.d.ts +2 -2
- package/dist/modules/access-control/gql/types.js +13 -17
- package/dist/modules/access-control/grpc/index.d.ts +5 -5
- package/dist/modules/access-control/grpc/index.js +10 -14
- package/dist/modules/access-control/index.d.ts +2 -2
- package/dist/modules/access-control/index.js +20 -17
- package/dist/modules/access-control/interfaces.d.ts +3 -3
- package/dist/modules/access-control/interfaces.js +1 -4
- package/dist/modules/catalog/gql/federation.d.ts +1 -1
- package/dist/modules/catalog/gql/federation.js +10 -17
- package/dist/modules/catalog/gql/schema.d.ts +1 -1
- package/dist/modules/catalog/gql/schema.generated.d.ts +252 -226
- package/dist/modules/catalog/gql/schema.generated.js +20 -23
- package/dist/modules/catalog/gql/schema.js +5 -9
- package/dist/modules/catalog/gql/types.d.ts +2 -2
- package/dist/modules/catalog/gql/types.js +15 -19
- package/dist/modules/catalog/grpc/index.d.ts +6 -6
- package/dist/modules/catalog/grpc/index.js +12 -16
- package/dist/modules/catalog/index.d.ts +2 -2
- package/dist/modules/catalog/index.js +20 -17
- package/dist/modules/catalog/interfaces.d.ts +3 -3
- package/dist/modules/catalog/interfaces.js +1 -4
- package/dist/modules/facade-status/gql/index.js +8 -14
- package/dist/modules/facade-status/gql/resolvers.d.ts +1 -1
- package/dist/modules/facade-status/gql/resolvers.js +14 -8
- package/dist/modules/facade-status/gql/schema.d.ts +1 -1
- package/dist/modules/facade-status/gql/schema.generated.d.ts +34 -11
- package/dist/modules/facade-status/gql/schema.generated.js +1 -2
- package/dist/modules/facade-status/gql/schema.js +6 -9
- package/dist/modules/facade-status/gql/types.js +3 -6
- package/dist/modules/facade-status/index.d.ts +1 -1
- package/dist/modules/facade-status/index.js +4 -7
- package/dist/modules/facade-status/interfaces.d.ts +1 -1
- package/dist/modules/facade-status/interfaces.js +1 -2
- package/dist/modules/fulfillment/gql/federation.d.ts +1 -1
- package/dist/modules/fulfillment/gql/federation.js +10 -17
- package/dist/modules/fulfillment/gql/schema.d.ts +1 -1
- package/dist/modules/fulfillment/gql/schema.generated.d.ts +249 -223
- package/dist/modules/fulfillment/gql/schema.generated.js +20 -23
- package/dist/modules/fulfillment/gql/schema.js +5 -9
- package/dist/modules/fulfillment/gql/types.d.ts +2 -2
- package/dist/modules/fulfillment/gql/types.js +11 -15
- package/dist/modules/fulfillment/grpc/index.d.ts +3 -3
- package/dist/modules/fulfillment/grpc/index.js +6 -10
- package/dist/modules/fulfillment/index.d.ts +2 -2
- package/dist/modules/fulfillment/index.js +20 -17
- package/dist/modules/fulfillment/interfaces.d.ts +3 -3
- package/dist/modules/fulfillment/interfaces.js +1 -4
- package/dist/modules/identity/api-key/api-key.d.ts +2 -2
- package/dist/modules/identity/api-key/api-key.js +45 -65
- package/dist/modules/identity/gql/federation.d.ts +2 -2
- package/dist/modules/identity/gql/federation.js +5 -9
- package/dist/modules/identity/gql/schema.d.ts +1 -1
- package/dist/modules/identity/gql/schema.generated.d.ts +284 -255
- package/dist/modules/identity/gql/schema.generated.js +20 -23
- package/dist/modules/identity/gql/schema.js +5 -9
- package/dist/modules/identity/gql/types.d.ts +2 -2
- package/dist/modules/identity/gql/types.js +17 -21
- package/dist/modules/identity/grpc/index.d.ts +6 -6
- package/dist/modules/identity/grpc/index.js +12 -16
- package/dist/modules/identity/index.d.ts +4 -4
- package/dist/modules/identity/index.js +24 -21
- package/dist/modules/identity/interfaces.d.ts +5 -5
- package/dist/modules/identity/interfaces.js +1 -4
- package/dist/modules/identity/oauth/oauth.d.ts +4 -4
- package/dist/modules/identity/oauth/oauth.js +109 -135
- package/dist/modules/identity/oidc/adapter.d.ts +3 -3
- package/dist/modules/identity/oidc/adapter.js +111 -92
- package/dist/modules/identity/oidc/in-memory-adapter.d.ts +1 -1
- package/dist/modules/identity/oidc/in-memory-adapter.js +64 -50
- package/dist/modules/identity/oidc/index.d.ts +6 -6
- package/dist/modules/identity/oidc/index.js +29 -30
- package/dist/modules/identity/oidc/interfaces.d.ts +6 -6
- package/dist/modules/identity/oidc/interfaces.js +2 -6
- package/dist/modules/identity/oidc/password-grant.d.ts +1 -1
- package/dist/modules/identity/oidc/password-grant.js +43 -66
- package/dist/modules/identity/oidc/router.d.ts +6 -6
- package/dist/modules/identity/oidc/router.js +31 -26
- package/dist/modules/identity/oidc/templates.d.ts +1 -1
- package/dist/modules/identity/oidc/templates.js +45 -41
- package/dist/modules/identity/oidc/user.d.ts +4 -4
- package/dist/modules/identity/oidc/user.js +31 -29
- package/dist/modules/identity/oidc/utils.d.ts +2 -2
- package/dist/modules/identity/oidc/utils.js +6 -13
- package/dist/modules/index.d.ts +13 -13
- package/dist/modules/index.js +13 -29
- package/dist/modules/indexing/gql/federation.d.ts +1 -1
- package/dist/modules/indexing/gql/federation.js +10 -17
- package/dist/modules/indexing/gql/schema.d.ts +1 -1
- package/dist/modules/indexing/gql/schema.generated.d.ts +45 -19
- package/dist/modules/indexing/gql/schema.generated.js +2 -5
- package/dist/modules/indexing/gql/schema.js +5 -9
- package/dist/modules/indexing/gql/types.d.ts +2 -2
- package/dist/modules/indexing/gql/types.js +7 -11
- package/dist/modules/indexing/grpc/index.d.ts +2 -2
- package/dist/modules/indexing/grpc/index.js +4 -8
- package/dist/modules/indexing/index.d.ts +2 -2
- package/dist/modules/indexing/index.js +20 -17
- package/dist/modules/indexing/interfaces.d.ts +3 -3
- package/dist/modules/indexing/interfaces.js +1 -4
- package/dist/modules/invoicing/gql/federation.d.ts +1 -1
- package/dist/modules/invoicing/gql/federation.js +10 -17
- package/dist/modules/invoicing/gql/schema.d.ts +1 -1
- package/dist/modules/invoicing/gql/schema.generated.d.ts +209 -183
- package/dist/modules/invoicing/gql/schema.generated.js +20 -23
- package/dist/modules/invoicing/gql/schema.js +5 -9
- package/dist/modules/invoicing/gql/types.d.ts +2 -2
- package/dist/modules/invoicing/gql/types.js +7 -11
- package/dist/modules/invoicing/grpc/index.d.ts +2 -2
- package/dist/modules/invoicing/grpc/index.js +4 -8
- package/dist/modules/invoicing/index.d.ts +2 -2
- package/dist/modules/invoicing/index.js +20 -17
- package/dist/modules/invoicing/interfaces.d.ts +3 -3
- package/dist/modules/invoicing/interfaces.js +1 -4
- package/dist/modules/notification/gql/federation.d.ts +1 -1
- package/dist/modules/notification/gql/federation.js +10 -17
- package/dist/modules/notification/gql/schema.d.ts +1 -1
- package/dist/modules/notification/gql/schema.generated.d.ts +100 -74
- package/dist/modules/notification/gql/schema.generated.js +18 -21
- package/dist/modules/notification/gql/schema.js +5 -9
- package/dist/modules/notification/gql/types.d.ts +2 -2
- package/dist/modules/notification/gql/types.js +7 -11
- package/dist/modules/notification/grpc/index.d.ts +2 -2
- package/dist/modules/notification/grpc/index.js +4 -8
- package/dist/modules/notification/index.d.ts +2 -2
- package/dist/modules/notification/index.js +20 -17
- package/dist/modules/notification/interfaces.d.ts +3 -3
- package/dist/modules/notification/interfaces.js +1 -4
- package/dist/modules/ordering/gql/federation.d.ts +1 -1
- package/dist/modules/ordering/gql/federation.js +10 -17
- package/dist/modules/ordering/gql/schema.d.ts +1 -1
- package/dist/modules/ordering/gql/schema.generated.d.ts +221 -195
- package/dist/modules/ordering/gql/schema.generated.js +22 -25
- package/dist/modules/ordering/gql/schema.js +5 -9
- package/dist/modules/ordering/gql/types.d.ts +2 -2
- package/dist/modules/ordering/gql/types.js +7 -11
- package/dist/modules/ordering/grpc/index.d.ts +2 -2
- package/dist/modules/ordering/grpc/index.js +4 -8
- package/dist/modules/ordering/index.d.ts +2 -2
- package/dist/modules/ordering/index.js +20 -17
- package/dist/modules/ordering/interfaces.d.ts +3 -3
- package/dist/modules/ordering/interfaces.js +1 -4
- package/dist/modules/ostorage/gql/federation.d.ts +1 -1
- package/dist/modules/ostorage/gql/federation.js +10 -17
- package/dist/modules/ostorage/gql/schema.d.ts +1 -1
- package/dist/modules/ostorage/gql/schema.generated.d.ts +126 -94
- package/dist/modules/ostorage/gql/schema.generated.js +8 -11
- package/dist/modules/ostorage/gql/schema.js +5 -9
- package/dist/modules/ostorage/gql/types.d.ts +2 -2
- package/dist/modules/ostorage/gql/types.js +7 -11
- package/dist/modules/ostorage/grpc/index.d.ts +2 -2
- package/dist/modules/ostorage/grpc/index.js +4 -8
- package/dist/modules/ostorage/index.d.ts +2 -2
- package/dist/modules/ostorage/index.js +20 -17
- package/dist/modules/ostorage/interfaces.d.ts +3 -3
- package/dist/modules/ostorage/interfaces.js +1 -4
- package/dist/modules/payment/gql/federation.d.ts +1 -1
- package/dist/modules/payment/gql/federation.js +10 -17
- package/dist/modules/payment/gql/schema.d.ts +1 -1
- package/dist/modules/payment/gql/schema.generated.d.ts +67 -44
- package/dist/modules/payment/gql/schema.generated.js +4 -7
- package/dist/modules/payment/gql/schema.js +5 -9
- package/dist/modules/payment/gql/types.d.ts +2 -2
- package/dist/modules/payment/gql/types.js +7 -11
- package/dist/modules/payment/grpc/index.d.ts +2 -2
- package/dist/modules/payment/grpc/index.js +4 -8
- package/dist/modules/payment/index.d.ts +2 -2
- package/dist/modules/payment/index.js +20 -17
- package/dist/modules/payment/interfaces.d.ts +3 -3
- package/dist/modules/payment/interfaces.js +1 -4
- package/dist/modules/resource/gql/federation.d.ts +1 -1
- package/dist/modules/resource/gql/federation.js +10 -17
- package/dist/modules/resource/gql/schema.d.ts +1 -1
- package/dist/modules/resource/gql/schema.generated.d.ts +348 -322
- package/dist/modules/resource/gql/schema.generated.js +28 -31
- package/dist/modules/resource/gql/schema.js +5 -9
- package/dist/modules/resource/gql/types.d.ts +2 -2
- package/dist/modules/resource/gql/types.js +31 -35
- package/dist/modules/resource/grpc/index.d.ts +13 -13
- package/dist/modules/resource/grpc/index.js +28 -32
- package/dist/modules/resource/index.d.ts +2 -2
- package/dist/modules/resource/index.js +20 -17
- package/dist/modules/resource/interfaces.d.ts +3 -3
- package/dist/modules/resource/interfaces.js +1 -4
- package/dist/modules/scheduling/gql/federation.d.ts +1 -1
- package/dist/modules/scheduling/gql/federation.js +10 -17
- package/dist/modules/scheduling/gql/schema.d.ts +1 -1
- package/dist/modules/scheduling/gql/schema.generated.d.ts +109 -83
- package/dist/modules/scheduling/gql/schema.generated.js +10 -13
- package/dist/modules/scheduling/gql/schema.js +5 -9
- package/dist/modules/scheduling/gql/types.d.ts +2 -2
- package/dist/modules/scheduling/gql/types.js +7 -11
- package/dist/modules/scheduling/grpc/index.d.ts +2 -2
- package/dist/modules/scheduling/grpc/index.js +4 -8
- package/dist/modules/scheduling/index.d.ts +2 -2
- package/dist/modules/scheduling/index.js +20 -17
- package/dist/modules/scheduling/interfaces.d.ts +3 -3
- package/dist/modules/scheduling/interfaces.js +1 -4
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +4 -9
- package/generate.ts +42 -42
- package/jest.config.cjs +23 -0
- package/package.json +18 -13
- package/tsconfig-base.json +8 -0
- package/tsconfig.debug.json +5 -1
- package/tsconfig.test.json +17 -2
- package/jest.config.js +0 -14
@@ -1,46 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const ts_proto_descriptors_1 = require("ts-proto-descriptors");
|
10
|
-
exports.registeredTypings = new Map();
|
11
|
-
exports.scalarTypes = ['Boolean', 'Int', 'Float', 'String', 'ID', 'Upload'];
|
1
|
+
import { GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString, } from 'graphql';
|
2
|
+
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType } from 'graphql/type/definition.js';
|
3
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
4
|
+
import { capitalizeProtoName } from './utils.js';
|
5
|
+
import { authSubjectType } from './types.js';
|
6
|
+
import { FieldDescriptorProto_Label, FieldDescriptorProto_Type } from 'ts-proto-descriptors';
|
7
|
+
export const registeredTypings = new Map();
|
8
|
+
export const scalarTypes = ['Boolean', 'Int', 'Float', 'String', 'ID', 'Upload'];
|
12
9
|
const typeNameAndNameSpaceMapping = new Map();
|
13
10
|
const registeredEnumTypes = [];
|
14
|
-
const MapScalar = new
|
11
|
+
const MapScalar = new GraphQLScalarType({
|
15
12
|
name: 'MapScalar',
|
16
13
|
});
|
17
|
-
const GoogleProtobufAnyValue = new
|
14
|
+
const GoogleProtobufAnyValue = new GraphQLScalarType({
|
18
15
|
name: 'GoogleProtobufAnyValue'
|
19
16
|
});
|
20
17
|
const protobufAnyFields = {
|
21
18
|
typeUrl: {
|
22
|
-
type:
|
19
|
+
type: GraphQLString
|
23
20
|
},
|
24
21
|
value: {
|
25
22
|
type: GoogleProtobufAnyValue
|
26
23
|
}
|
27
24
|
};
|
28
|
-
const GoogleProtobufAny = new
|
25
|
+
const GoogleProtobufAny = new GraphQLObjectType({
|
29
26
|
name: 'GoogleProtobufAny',
|
30
27
|
fields: protobufAnyFields
|
31
28
|
});
|
32
|
-
|
29
|
+
export const IGoogleProtobufAny = new GraphQLInputObjectType({
|
33
30
|
name: 'IGoogleProtobufAny',
|
34
31
|
fields: protobufAnyFields
|
35
32
|
});
|
36
|
-
const DateTime = new
|
33
|
+
const DateTime = new GraphQLScalarType({
|
37
34
|
name: 'DateTime',
|
38
35
|
description: `A date-time string at UTC, such as 2007-12-03T10:15:30Z,
|
39
36
|
compliant with the date-time format outlined in section 5.6 of
|
40
37
|
the RFC 3339 profile of the ISO 8601 standard for representation
|
41
38
|
of dates and times using the Gregorian calendar.`,
|
42
39
|
});
|
43
|
-
const IDateTime = new
|
40
|
+
const IDateTime = new GraphQLScalarType({
|
44
41
|
name: 'IDateTime',
|
45
42
|
description: `A date-time string at UTC, such as 2007-12-03T10:15:30Z,
|
46
43
|
compliant with the date-time format outlined in section 5.6 of
|
@@ -51,50 +48,36 @@ const googleProtobufAnyName = '.google.protobuf.Any';
|
|
51
48
|
const googleProtobufTimestampName = '.google.protobuf.Timestamp';
|
52
49
|
const Mutate = ['Create', 'Update', 'Upsert'];
|
53
50
|
const CRUD_TRAVERSAL_OP_NAMES = ['Cretae', 'Update', 'Upsert', 'Delete', 'Read', 'Traversal'];
|
54
|
-
const TodoScalar = new
|
51
|
+
const TodoScalar = new GraphQLScalarType({
|
55
52
|
name: 'TodoScalar',
|
56
53
|
serialize: () => {
|
57
|
-
throw Error(
|
54
|
+
throw Error('Not Implemented!');
|
58
55
|
},
|
59
56
|
parseValue: () => {
|
60
|
-
throw Error(
|
57
|
+
throw Error('Not Implemented!');
|
61
58
|
}
|
62
59
|
});
|
63
|
-
const clearRegistry = () => {
|
64
|
-
|
60
|
+
export const clearRegistry = () => {
|
61
|
+
registeredTypings.clear();
|
65
62
|
};
|
66
|
-
|
67
|
-
const registerPackagesRecursive = (...protoMetadata) => {
|
68
|
-
protoMetadata.forEach(meta => {
|
69
|
-
var _a, _b;
|
70
|
-
meta.dependencies && (0, exports.registerPackagesRecursive)(...meta.dependencies);
|
71
|
-
meta.fileDescriptor.messageType && registerMessageTypesRecursive(meta.fileDescriptor.package, (_a = meta.fileDescriptor.service[0]) === null || _a === void 0 ? void 0 : _a.method, meta.options, ...meta.fileDescriptor.messageType);
|
72
|
-
(_b = meta.fileDescriptor.enumType) === null || _b === void 0 ? void 0 : _b.forEach((m) => {
|
73
|
-
(0, exports.registerEnumTyping)(meta.fileDescriptor.package, m);
|
74
|
-
});
|
75
|
-
Object.keys(meta.references).forEach(key => {
|
76
|
-
exports.registeredTypings.get(key).processor = meta.references[key];
|
77
|
-
});
|
78
|
-
});
|
79
|
-
};
|
80
|
-
exports.registerPackagesRecursive = registerPackagesRecursive;
|
81
|
-
const getRegisteredEnumTypings = () => {
|
63
|
+
export const getRegisteredEnumTypings = () => {
|
82
64
|
return registeredEnumTypes;
|
83
65
|
};
|
84
|
-
|
85
|
-
const getNameSpaceTypeName = (typeName) => {
|
66
|
+
export const getNameSpaceTypeName = (typeName) => {
|
86
67
|
return typeNameAndNameSpaceMapping.get(typeName);
|
87
68
|
};
|
88
|
-
|
69
|
+
export const getTyping = (type) => {
|
70
|
+
return registeredTypings.get(type);
|
71
|
+
};
|
89
72
|
// Iterate through the object and collect list of all enum types with their keys / paths
|
90
|
-
const recursiveEnumCheck = (typeName, enumMap, prevFieldName, traversedFields) => {
|
91
|
-
if (
|
73
|
+
export const recursiveEnumCheck = (typeName, enumMap, prevFieldName, traversedFields) => {
|
74
|
+
if (scalarTypes.indexOf(typeName) <= -1) {
|
92
75
|
if (typeName && typeName.startsWith('[') && typeName.endsWith('!]')) {
|
93
76
|
typeName = typeName.substring(1, typeName.length - 2);
|
94
77
|
}
|
95
|
-
const objectNameSpace =
|
78
|
+
const objectNameSpace = getNameSpaceTypeName(typeName);
|
96
79
|
if (objectNameSpace) {
|
97
|
-
const objectType =
|
80
|
+
const objectType = getTyping(objectNameSpace);
|
98
81
|
if ((objectType === null || objectType === void 0 ? void 0 : objectType.input) && (registeredEnumTypes.indexOf(objectType.input.toString()) > -1)) {
|
99
82
|
enumMap.set(objectType === null || objectType === void 0 ? void 0 : objectType.input.toString(), prevFieldName);
|
100
83
|
prevFieldName = '';
|
@@ -107,7 +90,7 @@ const recursiveEnumCheck = (typeName, enumMap, prevFieldName, traversedFields) =
|
|
107
90
|
for (let fieldName of fieldNames) {
|
108
91
|
let fieldType = gqlFields[fieldName].type.toString();
|
109
92
|
// if fieldType is not basic type, get the object and make recursive check till no more objects are found
|
110
|
-
if (
|
93
|
+
if (scalarTypes.indexOf(fieldType) <= -1) {
|
111
94
|
// check if fieldName already exists in the traversedFields (to avoid circular reference for infinite loop)
|
112
95
|
if (traversedFields.indexOf(fieldName) <= -1) {
|
113
96
|
traversedFields.push(fieldName);
|
@@ -116,7 +99,7 @@ const recursiveEnumCheck = (typeName, enumMap, prevFieldName, traversedFields) =
|
|
116
99
|
// skip loop as this GQL type is already traversed
|
117
100
|
continue;
|
118
101
|
}
|
119
|
-
|
102
|
+
recursiveEnumCheck(fieldType, enumMap, fieldName, traversedFields);
|
120
103
|
}
|
121
104
|
}
|
122
105
|
}
|
@@ -125,21 +108,93 @@ const recursiveEnumCheck = (typeName, enumMap, prevFieldName, traversedFields) =
|
|
125
108
|
}
|
126
109
|
return enumMap;
|
127
110
|
};
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
111
|
+
const resolveMeta = (key, field, rootObjType, objName, input) => {
|
112
|
+
var _a;
|
113
|
+
let result;
|
114
|
+
switch (field.type) {
|
115
|
+
case FieldDescriptorProto_Type.TYPE_BOOL:
|
116
|
+
result = GraphQLBoolean;
|
117
|
+
break;
|
118
|
+
case FieldDescriptorProto_Type.TYPE_STRING:
|
119
|
+
result = GraphQLString;
|
120
|
+
break;
|
121
|
+
case FieldDescriptorProto_Type.TYPE_ENUM:
|
122
|
+
case FieldDescriptorProto_Type.TYPE_MESSAGE:
|
123
|
+
const objType = field.typeName;
|
124
|
+
if (objType === googleProtobufAnyName) {
|
125
|
+
if (input) {
|
126
|
+
result = IGoogleProtobufAny;
|
127
|
+
break;
|
128
|
+
}
|
129
|
+
result = GoogleProtobufAny;
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
if (objType === googleProtobufTimestampName) {
|
133
|
+
if (input) {
|
134
|
+
result = IDateTime;
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
result = DateTime;
|
138
|
+
break;
|
139
|
+
}
|
140
|
+
if (!registeredTypings.has(objType)) {
|
141
|
+
throw new Error('Typing \'' + objType + '\' not registered for key \'' + key + '\' in object: ' + objName);
|
142
|
+
}
|
143
|
+
let typingData = registeredTypings.get(objType);
|
144
|
+
let mapEntry = false;
|
145
|
+
if (typingData.meta.options) {
|
146
|
+
mapEntry = !!((_a = typingData.meta.options) === null || _a === void 0 ? void 0 : _a.mapEntry);
|
147
|
+
}
|
148
|
+
// TODO Actually unroll maps into entries
|
149
|
+
if (mapEntry) {
|
150
|
+
return MapScalar;
|
151
|
+
}
|
152
|
+
if (!input) {
|
153
|
+
result = typingData.output;
|
154
|
+
break;
|
155
|
+
}
|
156
|
+
if (objType === authSubjectType) {
|
157
|
+
return null;
|
158
|
+
}
|
159
|
+
result = typingData.input;
|
160
|
+
break;
|
161
|
+
case FieldDescriptorProto_Type.TYPE_BYTES:
|
162
|
+
if (input) {
|
163
|
+
// TODO Why can't it be nullable?
|
164
|
+
result = GraphQLUpload;
|
165
|
+
break;
|
166
|
+
}
|
167
|
+
// TODO Output Buffer
|
168
|
+
result = TodoScalar;
|
169
|
+
break;
|
170
|
+
case FieldDescriptorProto_Type.TYPE_INT32:
|
171
|
+
case FieldDescriptorProto_Type.TYPE_UINT32:
|
172
|
+
case FieldDescriptorProto_Type.TYPE_INT64:
|
173
|
+
case FieldDescriptorProto_Type.TYPE_UINT64:
|
174
|
+
case FieldDescriptorProto_Type.TYPE_SINT32:
|
175
|
+
case FieldDescriptorProto_Type.TYPE_SINT64:
|
176
|
+
result = GraphQLInt;
|
177
|
+
break;
|
178
|
+
case FieldDescriptorProto_Type.TYPE_DOUBLE:
|
179
|
+
case FieldDescriptorProto_Type.TYPE_FLOAT:
|
180
|
+
case FieldDescriptorProto_Type.TYPE_FIXED64:
|
181
|
+
case FieldDescriptorProto_Type.TYPE_FIXED32:
|
182
|
+
case FieldDescriptorProto_Type.TYPE_SFIXED32:
|
183
|
+
case FieldDescriptorProto_Type.TYPE_SFIXED64:
|
184
|
+
result = GraphQLFloat;
|
185
|
+
break;
|
186
|
+
default:
|
187
|
+
throw new Error('unknown typing type \'' + field.type + '\' for key \'' + key + '\' in: ' + objName);
|
188
|
+
}
|
189
|
+
if (field.label === FieldDescriptorProto_Label.LABEL_REPEATED) {
|
190
|
+
result = new GraphQLList(new GraphQLNonNull(result));
|
191
|
+
}
|
192
|
+
if (field.label === FieldDescriptorProto_Label.LABEL_REQUIRED) {
|
193
|
+
result = new GraphQLNonNull(result);
|
194
|
+
}
|
195
|
+
return result;
|
141
196
|
};
|
142
|
-
const ModeType = new
|
197
|
+
const ModeType = new GraphQLEnumType({
|
143
198
|
name: 'ModeType',
|
144
199
|
values: {
|
145
200
|
CREATE: {
|
@@ -153,7 +208,7 @@ const ModeType = new definition_1.GraphQLEnumType({
|
|
153
208
|
},
|
154
209
|
}
|
155
210
|
});
|
156
|
-
const registerTyping = (protoPackage, message, methodDef, opts, inputOpts, messageOptions) => {
|
211
|
+
export const registerTyping = (protoPackage, message, methodDef, opts, inputOpts, messageOptions) => {
|
157
212
|
let insertMode = false;
|
158
213
|
let crudOperation = false;
|
159
214
|
const type = (protoPackage.startsWith('.') ? '' : '.') + protoPackage + '.' + message.name;
|
@@ -173,25 +228,25 @@ const registerTyping = (protoPackage, message, methodDef, opts, inputOpts, messa
|
|
173
228
|
if (type === googleProtobufAnyName) {
|
174
229
|
// Do not register any type
|
175
230
|
typeNameAndNameSpaceMapping.set(GoogleProtobufAny.name, type);
|
176
|
-
|
231
|
+
registeredTypings.set(type, {
|
177
232
|
output: GoogleProtobufAny,
|
178
|
-
input:
|
233
|
+
input: IGoogleProtobufAny,
|
179
234
|
meta: message
|
180
235
|
});
|
181
236
|
}
|
182
237
|
if (type === googleProtobufTimestampName) {
|
183
238
|
typeNameAndNameSpaceMapping.set(DateTime.name, type);
|
184
|
-
|
239
|
+
registeredTypings.set(type, {
|
185
240
|
output: DateTime,
|
186
241
|
input: IDateTime,
|
187
242
|
meta: message
|
188
243
|
});
|
189
244
|
}
|
190
|
-
if (
|
245
|
+
if (registeredTypings.has(type)) {
|
191
246
|
// TODO Log debug "Typings for object are already registered"
|
192
247
|
return;
|
193
248
|
}
|
194
|
-
const name = (opts === null || opts === void 0 ? void 0 : opts.name) ||
|
249
|
+
const name = (opts === null || opts === void 0 ? void 0 : opts.name) || capitalizeProtoName(type);
|
195
250
|
const inputName = (inputOpts === null || inputOpts === void 0 ? void 0 : inputOpts.name) || 'I' + name;
|
196
251
|
const fields = () => {
|
197
252
|
var _a;
|
@@ -208,7 +263,7 @@ const registerTyping = (protoPackage, message, methodDef, opts, inputOpts, messa
|
|
208
263
|
if (field.name in messageOptions.fields) {
|
209
264
|
const data = messageOptions.fields[field.name].resolver;
|
210
265
|
const resolved = resolveMeta(data.fieldName, {
|
211
|
-
type:
|
266
|
+
type: FieldDescriptorProto_Type.TYPE_MESSAGE,
|
212
267
|
label: field.label,
|
213
268
|
typeName: data.targetType
|
214
269
|
}, type, name, false);
|
@@ -244,32 +299,25 @@ const registerTyping = (protoPackage, message, methodDef, opts, inputOpts, messa
|
|
244
299
|
if (!result.scope) {
|
245
300
|
result['scope'] = {
|
246
301
|
description: 'target scope',
|
247
|
-
type:
|
302
|
+
type: GraphQLString
|
248
303
|
};
|
249
304
|
}
|
250
305
|
}
|
251
306
|
return result;
|
252
307
|
};
|
253
|
-
const resultObj = new
|
254
|
-
|
255
|
-
fields,
|
256
|
-
});
|
257
|
-
const resultInputObj = new definition_1.GraphQLInputObjectType({
|
258
|
-
...(inputOpts || { name: inputName }),
|
259
|
-
fields: inputFields,
|
260
|
-
});
|
308
|
+
const resultObj = new GraphQLObjectType(Object.assign(Object.assign({}, (opts || { name })), { fields }));
|
309
|
+
const resultInputObj = new GraphQLInputObjectType(Object.assign(Object.assign({}, (inputOpts || { name: inputName })), { fields: inputFields }));
|
261
310
|
typeNameAndNameSpaceMapping.set(resultInputObj.name, type);
|
262
|
-
|
311
|
+
registeredTypings.set(type, {
|
263
312
|
output: resultObj,
|
264
313
|
input: resultInputObj,
|
265
314
|
meta: message
|
266
315
|
});
|
267
316
|
};
|
268
|
-
|
269
|
-
const registerEnumTyping = (protoPackage, message, opts) => {
|
317
|
+
export const registerEnumTyping = (protoPackage, message, opts) => {
|
270
318
|
var _a;
|
271
319
|
const type = (protoPackage.startsWith('.') ? '' : '.') + protoPackage + '.' + message.name;
|
272
|
-
if (
|
320
|
+
if (registeredTypings.has(type)) {
|
273
321
|
// TODO Log debug "Typings for enum are already registered"
|
274
322
|
return;
|
275
323
|
}
|
@@ -279,106 +327,39 @@ const registerEnumTyping = (protoPackage, message, opts) => {
|
|
279
327
|
value: entry.number
|
280
328
|
};
|
281
329
|
});
|
282
|
-
const name = (opts === null || opts === void 0 ? void 0 : opts.name) ||
|
283
|
-
const result = new
|
284
|
-
...(opts || { name }),
|
285
|
-
values
|
286
|
-
});
|
330
|
+
const name = (opts === null || opts === void 0 ? void 0 : opts.name) || capitalizeProtoName(type);
|
331
|
+
const result = new GraphQLEnumType(Object.assign(Object.assign({}, (opts || { name })), { values }));
|
287
332
|
registeredEnumTypes.push(name);
|
288
333
|
typeNameAndNameSpaceMapping.set(name, type);
|
289
|
-
|
334
|
+
registeredTypings.set(type, {
|
290
335
|
output: result,
|
291
336
|
input: result,
|
292
337
|
meta: message
|
293
338
|
});
|
294
339
|
};
|
295
|
-
|
296
|
-
|
297
|
-
|
340
|
+
const registerMessageTypesRecursive = (packageName, methodDef, options, ...types) => {
|
341
|
+
types.forEach(m => {
|
342
|
+
registerTyping(packageName, m, methodDef, undefined, undefined, options && options.messages && options.messages[m.name]);
|
343
|
+
if (m.enumType) {
|
344
|
+
m.enumType.forEach((enumType) => {
|
345
|
+
registerEnumTyping(packageName + '.' + m.name, enumType);
|
346
|
+
});
|
347
|
+
}
|
348
|
+
if (m.nestedType) {
|
349
|
+
registerMessageTypesRecursive(packageName + '.' + m.name, methodDef, options, ...m.nestedType);
|
350
|
+
}
|
351
|
+
});
|
298
352
|
};
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE:
|
312
|
-
const objType = field.typeName;
|
313
|
-
if (objType === googleProtobufAnyName) {
|
314
|
-
if (input) {
|
315
|
-
result = exports.IGoogleProtobufAny;
|
316
|
-
break;
|
317
|
-
}
|
318
|
-
result = GoogleProtobufAny;
|
319
|
-
break;
|
320
|
-
}
|
321
|
-
if (objType === googleProtobufTimestampName) {
|
322
|
-
if (input) {
|
323
|
-
result = IDateTime;
|
324
|
-
break;
|
325
|
-
}
|
326
|
-
result = DateTime;
|
327
|
-
break;
|
328
|
-
}
|
329
|
-
if (!exports.registeredTypings.has(objType)) {
|
330
|
-
throw new Error("Typing '" + objType + "' not registered for key '" + key + "' in object: " + objName);
|
331
|
-
}
|
332
|
-
let typingData = exports.registeredTypings.get(objType);
|
333
|
-
let mapEntry = false;
|
334
|
-
if (typingData.meta.options) {
|
335
|
-
mapEntry = !!((_a = typingData.meta.options) === null || _a === void 0 ? void 0 : _a.mapEntry);
|
336
|
-
}
|
337
|
-
// TODO Actually unroll maps into entries
|
338
|
-
if (mapEntry) {
|
339
|
-
return MapScalar;
|
340
|
-
}
|
341
|
-
if (!input) {
|
342
|
-
result = typingData.output;
|
343
|
-
break;
|
344
|
-
}
|
345
|
-
if (objType === types_1.authSubjectType) {
|
346
|
-
return null;
|
347
|
-
}
|
348
|
-
result = typingData.input;
|
349
|
-
break;
|
350
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_BYTES:
|
351
|
-
if (input) {
|
352
|
-
result = GraphQLUpload;
|
353
|
-
break;
|
354
|
-
}
|
355
|
-
// TODO Output Buffer
|
356
|
-
result = TodoScalar;
|
357
|
-
break;
|
358
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_INT32:
|
359
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_UINT32:
|
360
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_INT64:
|
361
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_UINT64:
|
362
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_SINT32:
|
363
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_SINT64:
|
364
|
-
result = graphql_1.GraphQLInt;
|
365
|
-
break;
|
366
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_DOUBLE:
|
367
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_FLOAT:
|
368
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_FIXED64:
|
369
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_FIXED32:
|
370
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_SFIXED32:
|
371
|
-
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_SFIXED64:
|
372
|
-
result = graphql_1.GraphQLFloat;
|
373
|
-
break;
|
374
|
-
default:
|
375
|
-
throw new Error("unknown typing type '" + field.type + "' for key '" + key + "' in: " + objName);
|
376
|
-
}
|
377
|
-
if (field.label === ts_proto_descriptors_1.FieldDescriptorProto_Label.LABEL_REPEATED) {
|
378
|
-
result = new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(result));
|
379
|
-
}
|
380
|
-
if (field.label === ts_proto_descriptors_1.FieldDescriptorProto_Label.LABEL_REQUIRED) {
|
381
|
-
result = new graphql_1.GraphQLNonNull(result);
|
382
|
-
}
|
383
|
-
return result;
|
353
|
+
export const registerPackagesRecursive = (...protoMetadata) => {
|
354
|
+
protoMetadata.forEach(meta => {
|
355
|
+
var _a, _b;
|
356
|
+
meta.dependencies && registerPackagesRecursive(...meta.dependencies);
|
357
|
+
meta.fileDescriptor.messageType && registerMessageTypesRecursive(meta.fileDescriptor.package, (_a = meta.fileDescriptor.service[0]) === null || _a === void 0 ? void 0 : _a.method, meta.options, ...meta.fileDescriptor.messageType);
|
358
|
+
(_b = meta.fileDescriptor.enumType) === null || _b === void 0 ? void 0 : _b.forEach((m) => {
|
359
|
+
registerEnumTyping(meta.fileDescriptor.package, m);
|
360
|
+
});
|
361
|
+
Object.keys(meta.references).forEach(key => {
|
362
|
+
registeredTypings.get(key).processor = meta.references[key];
|
363
|
+
});
|
364
|
+
});
|
384
365
|
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ProtoMetadata, ServiceClient, ServiceConfig, SubSpaceServiceConfig } from './types';
|
2
|
-
import { ServiceDescriptorProto } from 'ts-proto-descriptors';
|
3
|
-
import { GraphQLResolveInfo } from 'graphql';
|
1
|
+
import { type ProtoMetadata, type ServiceClient, type ServiceConfig, type SubSpaceServiceConfig } from './types.js';
|
2
|
+
import { type ServiceDescriptorProto } from 'ts-proto-descriptors';
|
3
|
+
import { type GraphQLResolveInfo } from 'graphql';
|
4
4
|
export type ResolverFn<TResult, TParent, TContext, TArgs> = (parent: TParent, args: TArgs, context: TContext, info: GraphQLResolveInfo) => Promise<TResult> | TResult;
|
5
5
|
export type SubscribeResolverFn<TResult, TParent, TContext, TArgs> = (parent: TParent, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncGenerator<TResult>;
|
6
6
|
export declare const getGQLResolverFunctions: <T extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, T>, SRV = any, R = ResolverFn<any, any, ServiceClient<CTX, keyof CTX, T>, any>, B extends keyof T = any, NS extends keyof CTX = any>(service: ServiceDescriptorProto, key: NS, serviceKey: B, cfg: ServiceConfig) => { [key in keyof SRV]: R; };
|