@restorecommerce/facade 0.5.7 → 1.0.0
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/CHANGELOG.md +22 -0
- package/dist/gql/index.d.ts +0 -3
- package/dist/gql/index.js +0 -3
- package/dist/gql/protos/graphql.d.ts +1 -0
- package/dist/gql/protos/graphql.js +9 -3
- package/dist/gql/protos/index.d.ts +0 -1
- package/dist/gql/protos/index.js +0 -1
- package/dist/gql/protos/types.d.ts +3 -1
- package/dist/modules/access-control/grpc/index.d.ts +11 -12
- package/dist/modules/access-control/grpc/index.js +6 -7
- package/dist/modules/access-control/index.js +4 -1
- package/dist/modules/catalog/grpc/index.d.ts +13 -14
- package/dist/modules/catalog/grpc/index.js +7 -8
- package/dist/modules/catalog/index.js +4 -1
- package/dist/modules/fulfillment/grpc/index.d.ts +7 -8
- package/dist/modules/fulfillment/grpc/index.js +4 -5
- package/dist/modules/fulfillment/index.js +4 -1
- package/dist/modules/identity/grpc/index.d.ts +13 -14
- package/dist/modules/identity/grpc/index.js +7 -8
- package/dist/modules/identity/index.js +4 -1
- package/dist/modules/identity/oauth/oauth.js +3 -3
- package/dist/modules/identity/oidc/adapter.d.ts +1 -1
- package/dist/modules/identity/oidc/interfaces.d.ts +2 -2
- package/dist/modules/identity/oidc/password-grant.js +1 -1
- package/dist/modules/identity/oidc/user.d.ts +1 -1
- package/dist/modules/identity/oidc/user.js +1 -1
- package/dist/modules/indexing/grpc/index.d.ts +5 -6
- package/dist/modules/indexing/grpc/index.js +3 -4
- package/dist/modules/indexing/index.js +4 -1
- package/dist/modules/invoicing/grpc/index.d.ts +5 -6
- package/dist/modules/invoicing/grpc/index.js +3 -4
- package/dist/modules/invoicing/index.js +4 -1
- package/dist/modules/notification/grpc/index.d.ts +5 -6
- package/dist/modules/notification/grpc/index.js +3 -4
- package/dist/modules/notification/index.js +4 -1
- package/dist/modules/ordering/grpc/index.d.ts +5 -6
- package/dist/modules/ordering/grpc/index.js +3 -4
- package/dist/modules/ordering/index.js +4 -1
- package/dist/modules/ostorage/grpc/index.d.ts +5 -6
- package/dist/modules/ostorage/grpc/index.js +3 -4
- package/dist/modules/ostorage/index.js +4 -1
- package/dist/modules/payment/grpc/index.d.ts +5 -6
- package/dist/modules/payment/grpc/index.js +3 -4
- package/dist/modules/payment/index.js +4 -1
- package/dist/modules/resource/grpc/index.d.ts +25 -27
- package/dist/modules/resource/grpc/index.js +13 -16
- package/dist/modules/resource/index.js +4 -1
- package/dist/modules/scheduling/grpc/index.d.ts +5 -6
- package/dist/modules/scheduling/grpc/index.js +3 -4
- package/dist/modules/scheduling/index.js +4 -1
- package/package.json +7 -7
- package/dist/gql/helpers/index.d.ts +0 -1
- package/dist/gql/helpers/index.js +0 -2
- package/dist/gql/helpers/resolver.d.ts +0 -122
- package/dist/gql/helpers/resolver.js +0 -290
- package/dist/gql/helpers/schema.d.ts +0 -56
- package/dist/gql/helpers/schema.js +0 -126
- package/dist/gql/protos/protos.d.ts +0 -6
- package/dist/gql/protos/protos.js +0 -55
@@ -1,290 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.resolveCRUDUpdateResources = exports.resolveCRUDDeleteResources = exports.resolveCRUDCreateResources = exports.convertReadResouecesInputToReadRequest = exports.resolveCRUDReadResources = exports.OperatorType = void 0;
|
4
|
-
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
5
|
-
// export enum FilterValueType {
|
6
|
-
// STRING = 0,
|
7
|
-
// NUMBER = 1,
|
8
|
-
// BOOLEAN = 2,
|
9
|
-
// DATE = 3,
|
10
|
-
// ARRAY = 4,
|
11
|
-
// };
|
12
|
-
var OperatorType;
|
13
|
-
(function (OperatorType) {
|
14
|
-
OperatorType[OperatorType["and"] = 0] = "and";
|
15
|
-
OperatorType[OperatorType["or"] = 1] = "or";
|
16
|
-
})(OperatorType = exports.OperatorType || (exports.OperatorType = {}));
|
17
|
-
;
|
18
|
-
async function resolveCRUDReadResources({ service, input, mapResponseItem }) {
|
19
|
-
try {
|
20
|
-
const readRequest = convertReadResouecesInputToReadRequest(input);
|
21
|
-
const result = await service.Read(readRequest);
|
22
|
-
const payload = mapResponseItem ?
|
23
|
-
result.items.map((_item) => mapResponseItem(_item.payload)) :
|
24
|
-
result.items;
|
25
|
-
return {
|
26
|
-
details: {
|
27
|
-
items: payload
|
28
|
-
},
|
29
|
-
operationStatus: {
|
30
|
-
code: 200,
|
31
|
-
message: 'success'
|
32
|
-
}
|
33
|
-
};
|
34
|
-
}
|
35
|
-
catch (error) {
|
36
|
-
return {
|
37
|
-
details: {
|
38
|
-
items: []
|
39
|
-
},
|
40
|
-
operationStatus: {
|
41
|
-
code: error.code,
|
42
|
-
message: error.message
|
43
|
-
}
|
44
|
-
};
|
45
|
-
}
|
46
|
-
}
|
47
|
-
exports.resolveCRUDReadResources = resolveCRUDReadResources;
|
48
|
-
function convertReadResouecesInputToReadRequest(input) {
|
49
|
-
const readRequest = rc_grpc_clients_1.ReadRequest.fromPartial({});
|
50
|
-
if (!input) {
|
51
|
-
return readRequest;
|
52
|
-
}
|
53
|
-
if (typeof input.limit === 'number') {
|
54
|
-
readRequest.limit = input.limit;
|
55
|
-
}
|
56
|
-
if (typeof input.offset === 'number') {
|
57
|
-
readRequest.offset = input.offset;
|
58
|
-
}
|
59
|
-
if (input.filters) {
|
60
|
-
const length = input.filters.length;
|
61
|
-
const buildFilter = ({ field, operation, value, type }) => {
|
62
|
-
let filterValue = value;
|
63
|
-
if (!!type && type !== 'string') {
|
64
|
-
if (type == 'date') {
|
65
|
-
filterValue = (new Date(value)).getTime();
|
66
|
-
}
|
67
|
-
else if (type === 'number' && isFinite(Number(value))) {
|
68
|
-
filterValue = Number(value);
|
69
|
-
}
|
70
|
-
else if (type === 'boolean') {
|
71
|
-
filterValue = (value === 'true');
|
72
|
-
}
|
73
|
-
// else if (type === FilterFieldValueEnumType.Array) {
|
74
|
-
// filterValue = JSON.parse(value);
|
75
|
-
// }
|
76
|
-
}
|
77
|
-
const operations = ['gt', 'lt', 'lte', 'gte', 'eq', 'isEmpty', 'in', 'iLike'];
|
78
|
-
if (operations.find((op) => {
|
79
|
-
return op === operation;
|
80
|
-
}) == null) {
|
81
|
-
throw new Error('Invalid operation ' + operation);
|
82
|
-
}
|
83
|
-
if (operation == 'isEmpty') {
|
84
|
-
filterValue = '';
|
85
|
-
}
|
86
|
-
return { [field]: { ['$' + operation]: filterValue } };
|
87
|
-
};
|
88
|
-
// if (length > 0) {
|
89
|
-
// if (length === 1) {
|
90
|
-
// readRequest.filters = buildFilter(input.filters[0].filter[0]) as any;
|
91
|
-
// } else {
|
92
|
-
// readRequest.filters = {
|
93
|
-
// $and: input.filters.reduce((convertedFilters, filter) => {
|
94
|
-
// return [
|
95
|
-
// ...convertedFilters,
|
96
|
-
// buildFilter(filter[0])
|
97
|
-
// ]
|
98
|
-
// }, [] as any[])
|
99
|
-
// } as any;
|
100
|
-
// }
|
101
|
-
// }
|
102
|
-
if (input.sort && (input.sort.field || input.sort.order)) {
|
103
|
-
const field = input.sort.field;
|
104
|
-
let order;
|
105
|
-
switch (input.sort.order) {
|
106
|
-
case 'asc': {
|
107
|
-
order = rc_grpc_clients_1.Sort_SortOrder.ASCENDING;
|
108
|
-
}
|
109
|
-
case 'desc': {
|
110
|
-
order = rc_grpc_clients_1.Sort_SortOrder.DESCENDING;
|
111
|
-
}
|
112
|
-
default: {
|
113
|
-
order = rc_grpc_clients_1.Sort_SortOrder.UNSORTED;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
const sort = {
|
117
|
-
field,
|
118
|
-
order
|
119
|
-
};
|
120
|
-
readRequest.sort = [sort];
|
121
|
-
}
|
122
|
-
}
|
123
|
-
return readRequest;
|
124
|
-
}
|
125
|
-
exports.convertReadResouecesInputToReadRequest = convertReadResouecesInputToReadRequest;
|
126
|
-
async function resolveCRUDCreateResources({ service, input, mapRequestItem, mapResponseItem }) {
|
127
|
-
try {
|
128
|
-
const items = mapRequestItem ?
|
129
|
-
input.items.map((_item) => mapRequestItem(_item)) :
|
130
|
-
input.items;
|
131
|
-
;
|
132
|
-
const result = await service.Create({
|
133
|
-
items,
|
134
|
-
totalCount: items.length
|
135
|
-
});
|
136
|
-
const payload = mapResponseItem ?
|
137
|
-
result.items.map((_item) => mapResponseItem(_item.payload)) :
|
138
|
-
result.items;
|
139
|
-
return {
|
140
|
-
details: {
|
141
|
-
items: payload
|
142
|
-
},
|
143
|
-
operationStatus: {
|
144
|
-
code: 200,
|
145
|
-
message: 'success'
|
146
|
-
}
|
147
|
-
};
|
148
|
-
}
|
149
|
-
catch (error) {
|
150
|
-
return {
|
151
|
-
details: {
|
152
|
-
items: []
|
153
|
-
},
|
154
|
-
operationStatus: {
|
155
|
-
code: error.code,
|
156
|
-
message: error.message
|
157
|
-
}
|
158
|
-
};
|
159
|
-
}
|
160
|
-
}
|
161
|
-
exports.resolveCRUDCreateResources = resolveCRUDCreateResources;
|
162
|
-
async function resolveCRUDDeleteResources({ service, input }) {
|
163
|
-
var _a;
|
164
|
-
try {
|
165
|
-
const deleteResponse = await service.Delete({
|
166
|
-
ids: input.ids,
|
167
|
-
collection: (_a = input.collection) !== null && _a !== void 0 ? _a : false
|
168
|
-
});
|
169
|
-
return deleteResponse;
|
170
|
-
}
|
171
|
-
catch (error) {
|
172
|
-
return {
|
173
|
-
status: [],
|
174
|
-
operationStatus: {
|
175
|
-
code: error.code,
|
176
|
-
message: error.message
|
177
|
-
}
|
178
|
-
};
|
179
|
-
}
|
180
|
-
}
|
181
|
-
exports.resolveCRUDDeleteResources = resolveCRUDDeleteResources;
|
182
|
-
async function resolveCRUDUpdateResources({ service, input, mapRequestItem, mapResponseItem }) {
|
183
|
-
try {
|
184
|
-
const items = mapRequestItem ?
|
185
|
-
input.items.map((_item) => mapRequestItem(_item)) :
|
186
|
-
input.items;
|
187
|
-
;
|
188
|
-
const result = await service.Update({
|
189
|
-
items,
|
190
|
-
totalCount: items.length
|
191
|
-
});
|
192
|
-
const payload = mapResponseItem ?
|
193
|
-
result.items.map((_item) => mapResponseItem(_item.payload)) :
|
194
|
-
result.items;
|
195
|
-
return {
|
196
|
-
details: {
|
197
|
-
items: payload
|
198
|
-
},
|
199
|
-
operationStatus: {
|
200
|
-
code: 200,
|
201
|
-
message: 'success'
|
202
|
-
}
|
203
|
-
};
|
204
|
-
}
|
205
|
-
catch (error) {
|
206
|
-
return {
|
207
|
-
details: {
|
208
|
-
items: []
|
209
|
-
},
|
210
|
-
operationStatus: {
|
211
|
-
code: error.code,
|
212
|
-
message: error.message
|
213
|
-
}
|
214
|
-
};
|
215
|
-
}
|
216
|
-
}
|
217
|
-
exports.resolveCRUDUpdateResources = resolveCRUDUpdateResources;
|
218
|
-
// export interface CreateTestArgs<TContext, TGrpcType, TGqlType, TCreateKey extends string> {
|
219
|
-
// resourceName: string;
|
220
|
-
// service: (ctx: TContext) => CRUDService<TGrpcType>
|
221
|
-
// create: {
|
222
|
-
// fn: TCreateKey;
|
223
|
-
// mapRequestItem?: (item: TGqlType) => TGrpcType;
|
224
|
-
// mapResponseItem?: (item: TGrpcType) => TGqlType;
|
225
|
-
// },
|
226
|
-
// read: {
|
227
|
-
// fn: string;
|
228
|
-
// mapResponseItem?: (item: TGrpcType) => TGqlType;
|
229
|
-
// },
|
230
|
-
// update: {
|
231
|
-
// mapRequestItem?: (item: TGqlType) => TGrpcType;
|
232
|
-
// mapResponseItem?: (item: TGrpcType) => TGqlType;
|
233
|
-
// fn: string;
|
234
|
-
// },
|
235
|
-
// delete: {
|
236
|
-
// fn: string;
|
237
|
-
// }
|
238
|
-
// }
|
239
|
-
// export interface CreateTestResult<TContext, TReadKey extends string> {
|
240
|
-
// Query: {
|
241
|
-
// [key: TReadKey]: (parent: any, {input}: {input: ResolveCRUDReadResourcesArgsInput}, ctx: TContext) => any;
|
242
|
-
// },
|
243
|
-
// // mutation: {
|
244
|
-
// // [key: TCreateKey]: (parent: any, {input}: {input: ResolveCRUDReadResourcesArgsInput}, ctx: TContext) => any;
|
245
|
-
// // [key: TCreateKey]: (parent: any, {input}: {input: ResolveCRUDReadResourcesArgsInput}, ctx: TContext) => any;
|
246
|
-
// // [key: TCreateKey]: (parent: any, {input}: {input: ResolveCRUDReadResourcesArgsInput}, ctx: TContext) => any;
|
247
|
-
// // }
|
248
|
-
// }
|
249
|
-
// export function createTest<
|
250
|
-
// TContext,
|
251
|
-
// TGqlType,
|
252
|
-
// TGrpcType,
|
253
|
-
// TCreateKey extends string
|
254
|
-
// >(args: CreateTestArgs<TContext, TGrpcType, TGqlType, TCreateKey>): CreateTestResult<TContext, ''> {
|
255
|
-
// return {
|
256
|
-
// Query: {
|
257
|
-
// [args.read.fn]: async (parent, {input}: {input: ResolveCRUDReadResourcesArgsInput}, ctx: TContext) => {
|
258
|
-
// return await resolveCRUDReadResources<TGqlType, TGrpcType>({
|
259
|
-
// service: args.service(ctx),
|
260
|
-
// input,
|
261
|
-
// mapResponseItem: args.read.mapResponseItem
|
262
|
-
// });
|
263
|
-
// },
|
264
|
-
// },
|
265
|
-
// // Mutation: {
|
266
|
-
// // [args.create.fn]: async (parent: any, {input}: {input: CreateResourcesInputType<TGqlType>}, ctx: TContext) => {
|
267
|
-
// // return await resolveCRUDCreateResources({
|
268
|
-
// // service: args.service(ctx),
|
269
|
-
// // input,
|
270
|
-
// // mapRequestItem: args.create.mapRequestItem,
|
271
|
-
// // mapResponseItem: args.create.mapResponseItem
|
272
|
-
// // });
|
273
|
-
// // },
|
274
|
-
// // [args.update.fn]: async (parent: any, {input}: {input: UpdateResourcesInputType<TGqlType>}, ctx: TContext) => {
|
275
|
-
// // return await resolveCRUDUpdateResources({
|
276
|
-
// // service: args.service(ctx),
|
277
|
-
// // input,
|
278
|
-
// // mapRequestItem: args.create.mapRequestItem,
|
279
|
-
// // mapResponseItem: args.update.mapResponseItem
|
280
|
-
// // });
|
281
|
-
// // },
|
282
|
-
// // [args.delete.fn]: async (parent: any, {input}: {input: DeleteResourcesInputType}, ctx: TContext) => {
|
283
|
-
// // return await resolveCRUDDeleteResources({
|
284
|
-
// // service: args.service(ctx),
|
285
|
-
// // input,
|
286
|
-
// // });
|
287
|
-
// // }
|
288
|
-
// // }
|
289
|
-
// }
|
290
|
-
// }
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import { GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType, GraphQLOutputType } from 'graphql';
|
2
|
-
export interface OutputWithStatusTypeArgs {
|
3
|
-
name: string;
|
4
|
-
description: string;
|
5
|
-
payloadType: GraphQLOutputType;
|
6
|
-
}
|
7
|
-
export declare function createSchemaOutputWithStatusType({ name, description, payloadType }: OutputWithStatusTypeArgs): GraphQLObjectType<any, any>;
|
8
|
-
export interface ReadResourcesFieldArgs {
|
9
|
-
resourceName: string;
|
10
|
-
outputType: GraphQLObjectType;
|
11
|
-
}
|
12
|
-
export declare function createSchemaReadResourcesField({ resourceName, outputType }: ReadResourcesFieldArgs): GraphQLFieldConfig<any, any>;
|
13
|
-
export interface CreateSchemaCreateResourcesFieldArgs {
|
14
|
-
resourceName: string;
|
15
|
-
inputType: GraphQLInputObjectType;
|
16
|
-
outputType: GraphQLObjectType;
|
17
|
-
}
|
18
|
-
export declare function createSchemaCreateResourcesField({ resourceName, inputType, outputType }: CreateSchemaCreateResourcesFieldArgs): GraphQLFieldConfig<any, any>;
|
19
|
-
export interface CreateSchemaDeleteResourcesFieldArgs {
|
20
|
-
resourceName: string;
|
21
|
-
}
|
22
|
-
export declare function createSchemaDeleteResourcesField({ resourceName }: CreateSchemaDeleteResourcesFieldArgs): GraphQLFieldConfig<any, any>;
|
23
|
-
export interface CreateSchemaUpdateResourcesFieldArgs {
|
24
|
-
resourceName: string;
|
25
|
-
inputType: GraphQLInputObjectType;
|
26
|
-
outputType: GraphQLObjectType;
|
27
|
-
}
|
28
|
-
export declare function createSchemaUpdateResourcesField({ resourceName, inputType, outputType }: CreateSchemaUpdateResourcesFieldArgs): GraphQLFieldConfig<any, any>;
|
29
|
-
export interface CreateSchemaCRUDFieldsArgs {
|
30
|
-
resourceName: string;
|
31
|
-
create: {
|
32
|
-
fn: string;
|
33
|
-
inputType: GraphQLInputObjectType;
|
34
|
-
outputType: GraphQLObjectType;
|
35
|
-
};
|
36
|
-
read: {
|
37
|
-
fn: string;
|
38
|
-
outputType: GraphQLObjectType;
|
39
|
-
};
|
40
|
-
update: {
|
41
|
-
fn: string;
|
42
|
-
inputType: GraphQLInputObjectType;
|
43
|
-
outputType: GraphQLObjectType;
|
44
|
-
};
|
45
|
-
delete: {
|
46
|
-
fn: string;
|
47
|
-
};
|
48
|
-
}
|
49
|
-
export declare function createSchemaCRUDFields(args: CreateSchemaCRUDFieldsArgs): {
|
50
|
-
queryFields: {
|
51
|
-
[x: string]: GraphQLFieldConfig<any, any, any>;
|
52
|
-
};
|
53
|
-
mutationFields: {
|
54
|
-
[x: string]: GraphQLFieldConfig<any, any, any>;
|
55
|
-
};
|
56
|
-
};
|
@@ -1,126 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createSchemaCRUDFields = exports.createSchemaUpdateResourcesField = exports.createSchemaDeleteResourcesField = exports.createSchemaCreateResourcesField = exports.createSchemaReadResourcesField = exports.createSchemaOutputWithStatusType = void 0;
|
4
|
-
const graphql_1 = require("graphql");
|
5
|
-
const index_1 = require("../types/index");
|
6
|
-
const capitalize = (s) => {
|
7
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
8
|
-
};
|
9
|
-
function createSchemaOutputWithStatusType({ name, description, payloadType }) {
|
10
|
-
return new graphql_1.GraphQLObjectType({
|
11
|
-
name,
|
12
|
-
description,
|
13
|
-
fields: () => ({
|
14
|
-
payload: {
|
15
|
-
type: payloadType,
|
16
|
-
},
|
17
|
-
operationStatus: {
|
18
|
-
type: new graphql_1.GraphQLNonNull(index_1.OperationStatusType),
|
19
|
-
},
|
20
|
-
}),
|
21
|
-
});
|
22
|
-
}
|
23
|
-
exports.createSchemaOutputWithStatusType = createSchemaOutputWithStatusType;
|
24
|
-
function createSchemaReadResourcesField({ resourceName, outputType }) {
|
25
|
-
return {
|
26
|
-
type: createSchemaOutputWithStatusType({
|
27
|
-
name: "Read" + capitalize(resourceName),
|
28
|
-
description: 'TODO',
|
29
|
-
payloadType: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(outputType))
|
30
|
-
}),
|
31
|
-
args: {
|
32
|
-
input: {
|
33
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLInputObjectType({
|
34
|
-
name: "ReadResources" + capitalize(resourceName) + 'Input',
|
35
|
-
fields: {
|
36
|
-
limit: { type: graphql_1.GraphQLInt },
|
37
|
-
offset: { type: graphql_1.GraphQLInt },
|
38
|
-
filter: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(index_1.FilterOptionsInputType)) },
|
39
|
-
sort: { type: index_1.SortInputType },
|
40
|
-
scope: { type: index_1.ScopeInputType }
|
41
|
-
}
|
42
|
-
})),
|
43
|
-
}
|
44
|
-
},
|
45
|
-
};
|
46
|
-
}
|
47
|
-
exports.createSchemaReadResourcesField = createSchemaReadResourcesField;
|
48
|
-
function createSchemaCreateResourcesField({ resourceName, inputType, outputType }) {
|
49
|
-
return {
|
50
|
-
type: createSchemaOutputWithStatusType({
|
51
|
-
name: "CreateResources" + capitalize(resourceName),
|
52
|
-
description: 'TODO',
|
53
|
-
payloadType: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(outputType))
|
54
|
-
}),
|
55
|
-
args: {
|
56
|
-
input: {
|
57
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLInputObjectType({
|
58
|
-
name: "CreateResources" + capitalize(resourceName) + 'Input',
|
59
|
-
fields: {
|
60
|
-
items: {
|
61
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(inputType)))
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}))
|
65
|
-
}
|
66
|
-
},
|
67
|
-
};
|
68
|
-
}
|
69
|
-
exports.createSchemaCreateResourcesField = createSchemaCreateResourcesField;
|
70
|
-
function createSchemaDeleteResourcesField({ resourceName }) {
|
71
|
-
return {
|
72
|
-
type: createSchemaOutputWithStatusType({
|
73
|
-
name: "DeleteResources" + capitalize(resourceName),
|
74
|
-
description: 'TODO',
|
75
|
-
payloadType: graphql_1.GraphQLBoolean
|
76
|
-
}),
|
77
|
-
args: {
|
78
|
-
input: {
|
79
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLInputObjectType({
|
80
|
-
name: 'DeleteResources' + capitalize(resourceName) + 'Input',
|
81
|
-
fields: {
|
82
|
-
ids: {
|
83
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)))
|
84
|
-
}
|
85
|
-
}
|
86
|
-
}))
|
87
|
-
}
|
88
|
-
},
|
89
|
-
};
|
90
|
-
}
|
91
|
-
exports.createSchemaDeleteResourcesField = createSchemaDeleteResourcesField;
|
92
|
-
function createSchemaUpdateResourcesField({ resourceName, inputType, outputType }) {
|
93
|
-
return {
|
94
|
-
type: createSchemaOutputWithStatusType({
|
95
|
-
name: "UpdateResources" + capitalize(resourceName),
|
96
|
-
description: 'TODO',
|
97
|
-
payloadType: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(outputType))
|
98
|
-
}),
|
99
|
-
args: {
|
100
|
-
input: {
|
101
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLInputObjectType({
|
102
|
-
name: "UpdateResources" + capitalize(resourceName) + 'Input',
|
103
|
-
fields: {
|
104
|
-
items: {
|
105
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(inputType)))
|
106
|
-
}
|
107
|
-
}
|
108
|
-
}))
|
109
|
-
}
|
110
|
-
},
|
111
|
-
};
|
112
|
-
}
|
113
|
-
exports.createSchemaUpdateResourcesField = createSchemaUpdateResourcesField;
|
114
|
-
function createSchemaCRUDFields(args) {
|
115
|
-
return {
|
116
|
-
queryFields: {
|
117
|
-
[args.read.fn]: createSchemaReadResourcesField({ resourceName: args.resourceName, outputType: args.read.outputType })
|
118
|
-
},
|
119
|
-
mutationFields: {
|
120
|
-
[args.create.fn]: createSchemaCreateResourcesField({ resourceName: args.resourceName, inputType: args.create.inputType, outputType: args.create.outputType }),
|
121
|
-
[args.update.fn]: createSchemaUpdateResourcesField({ resourceName: args.resourceName, inputType: args.create.inputType, outputType: args.create.outputType }),
|
122
|
-
[args.delete.fn]: createSchemaDeleteResourcesField({ resourceName: args.resourceName })
|
123
|
-
}
|
124
|
-
};
|
125
|
-
}
|
126
|
-
exports.createSchemaCRUDFields = createSchemaCRUDFields;
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { GrpcClientRpcMethodDefinition, GrpcService, GrpcServiceMethods } from "@restorecommerce/grpc-client";
|
2
|
-
import { RestoreCommerceGrpcClient } from "@restorecommerce/rc-grpc-clients";
|
3
|
-
import { ServiceDescriptorProto, MethodDescriptorProto } from "ts-proto-descriptors";
|
4
|
-
export declare const getProtoFunction: (method: MethodDescriptorProto) => GrpcClientRpcMethodDefinition<any, any>;
|
5
|
-
export declare const getProtoFunctions: <M extends GrpcService = any>(service: ServiceDescriptorProto) => GrpcServiceMethods<M>;
|
6
|
-
export declare const getGRPCService: <T extends Record<string, any>>(self: RestoreCommerceGrpcClient, packageName: string, service: ServiceDescriptorProto) => T;
|
@@ -1,55 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGRPCService = exports.getProtoFunctions = exports.getProtoFunction = void 0;
|
4
|
-
const registry_1 = require("./registry");
|
5
|
-
const getProtoFunction = (method) => {
|
6
|
-
const inputMessage = (0, registry_1.getTyping)(method.inputType);
|
7
|
-
const outputMessage = (0, registry_1.getTyping)(method.outputType);
|
8
|
-
if (!inputMessage) {
|
9
|
-
throw Error(`Method '${method.name}' could not find input type: ${method.inputType}`);
|
10
|
-
}
|
11
|
-
if (!outputMessage) {
|
12
|
-
throw Error(`Method '${method.name}' could not find output type: ${method.outputType}`);
|
13
|
-
}
|
14
|
-
if (!inputMessage.processor || !outputMessage.processor) {
|
15
|
-
throw Error("Method does not contain encodeRequest or decodeResponse metadata");
|
16
|
-
}
|
17
|
-
if (!('encode' in inputMessage.processor)) {
|
18
|
-
throw Error(`Method ${method.name} input type '${method.inputType}' does not contain 'encode' function`);
|
19
|
-
}
|
20
|
-
if (!('decode' in outputMessage.processor)) {
|
21
|
-
throw Error(`Method ${method.name} output type '${method.inputType}' does not contain 'decode' function`);
|
22
|
-
}
|
23
|
-
let type = 'unary';
|
24
|
-
if (method.clientStreaming && method.serverStreaming) {
|
25
|
-
type = 'bidiStream';
|
26
|
-
}
|
27
|
-
else if (method.clientStreaming) {
|
28
|
-
type = 'clientStream';
|
29
|
-
}
|
30
|
-
else if (method.serverStreaming) {
|
31
|
-
type = 'serverStream';
|
32
|
-
}
|
33
|
-
return {
|
34
|
-
type,
|
35
|
-
serialize: inputMessage.processor.encode,
|
36
|
-
deserialize: outputMessage.processor.decode
|
37
|
-
};
|
38
|
-
};
|
39
|
-
exports.getProtoFunction = getProtoFunction;
|
40
|
-
const getProtoFunctions = (service) => {
|
41
|
-
var _a;
|
42
|
-
return (_a = service.method) === null || _a === void 0 ? void 0 : _a.reduce((obj, method) => {
|
43
|
-
obj[method.name] = (0, exports.getProtoFunction)(method);
|
44
|
-
return obj;
|
45
|
-
}, {});
|
46
|
-
};
|
47
|
-
exports.getProtoFunctions = getProtoFunctions;
|
48
|
-
const getGRPCService = (self, packageName, service) => {
|
49
|
-
return self['createService']({
|
50
|
-
packageName,
|
51
|
-
serviceName: service.name,
|
52
|
-
methods: (0, exports.getProtoFunctions)(service)
|
53
|
-
});
|
54
|
-
};
|
55
|
-
exports.getGRPCService = getGRPCService;
|