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