@restorecommerce/facade 1.2.0 → 1.3.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/.eslintignore +3 -0
- package/.eslintrc.cjs +13 -0
- package/CHANGELOG.md +11 -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 +17 -12
- package/tsconfig-base.json +8 -0
- package/tsconfig.debug.json +5 -1
- package/tsconfig.test.json +17 -2
- package/jest.config.js +0 -14
package/.eslintignore
ADDED
package/.eslintrc.cjs
ADDED
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.3.0](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.2.0...@restorecommerce/facade@1.3.0) (2023-06-12)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **facade:** move tests to esm ([a580de7](https://github.com/restorecommerce/libs/commit/a580de7b9e3e29c2856d3f4811e47c3fddcc5856))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
6
17
|
# [1.2.0](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.1.6...@restorecommerce/facade@1.2.0) (2023-06-02)
|
7
18
|
|
8
19
|
|
package/codegen/index.d.ts
CHANGED
@@ -9,4 +9,4 @@ export interface GenerateSchemaTypingsArgs {
|
|
9
9
|
[key: string]: any;
|
10
10
|
};
|
11
11
|
}
|
12
|
-
export declare
|
12
|
+
export declare const generateSchemaTypings: ({ schema, outputFile, typescript, typescriptResolvers }: GenerateSchemaTypingsArgs) => Promise<void>;
|
package/codegen/index.js
CHANGED
@@ -1,34 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
24
9
|
};
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
const
|
30
|
-
const core_1 = require("@graphql-codegen/core");
|
31
|
-
async function generateSchemaTypings({ schema, outputFile, typescript, typescriptResolvers }) {
|
10
|
+
import * as fs from 'node:fs';
|
11
|
+
import * as typescriptPlugin from '@graphql-codegen/typescript';
|
12
|
+
import * as typescriptResolversPlugin from '@graphql-codegen/typescript-resolvers';
|
13
|
+
import { codegen } from '@graphql-codegen/core';
|
14
|
+
export const generateSchemaTypings = ({ schema, outputFile, typescript, typescriptResolvers }) => __awaiter(void 0, void 0, void 0, function* () {
|
32
15
|
try {
|
33
16
|
const codegenConfig /* typings wrong? */ = {
|
34
17
|
// used by a plugin internally, although the 'typescript' plugin currently
|
@@ -38,32 +21,23 @@ async function generateSchemaTypings({ schema, outputFile, typescript, typescrip
|
|
38
21
|
documents: [],
|
39
22
|
plugins: [
|
40
23
|
{
|
41
|
-
typescript: {
|
42
|
-
maybeValue: 'T | null | undefined',
|
43
|
-
inputMaybeValue: 'T | null | undefined',
|
44
|
-
...(typescript !== null && typescript !== void 0 ? typescript : {})
|
45
|
-
},
|
24
|
+
typescript: Object.assign({ maybeValue: 'T | null | undefined', inputMaybeValue: 'T | null | undefined' }, (typescript !== null && typescript !== void 0 ? typescript : {})),
|
46
25
|
},
|
47
26
|
{
|
48
|
-
typescriptResolvers: {
|
49
|
-
noSchemaStitching: true,
|
50
|
-
useIndexSignature: true,
|
51
|
-
federation: true,
|
52
|
-
...(typescriptResolvers !== null && typescriptResolvers !== void 0 ? typescriptResolvers : {})
|
53
|
-
},
|
27
|
+
typescriptResolvers: Object.assign({ noSchemaStitching: true, useIndexSignature: true, federation: true }, (typescriptResolvers !== null && typescriptResolvers !== void 0 ? typescriptResolvers : {})),
|
54
28
|
},
|
55
29
|
],
|
56
30
|
pluginMap: {
|
57
31
|
typescript: typescriptPlugin,
|
58
32
|
typescriptResolvers: typescriptResolversPlugin,
|
59
33
|
},
|
34
|
+
emitLegacyCommonJSImports: false
|
60
35
|
};
|
61
|
-
const output =
|
36
|
+
const output = yield codegen(codegenConfig);
|
62
37
|
fs.writeFileSync(outputFile, output);
|
63
38
|
console.log('Schema typings generated in' + outputFile);
|
64
39
|
}
|
65
40
|
catch (ex) {
|
66
41
|
console.error(ex);
|
67
42
|
}
|
68
|
-
}
|
69
|
-
exports.generateSchemaTypings = generateSchemaTypings;
|
43
|
+
});
|
package/debug-run.ts
CHANGED
@@ -15,13 +15,14 @@ import {
|
|
15
15
|
ostorageModule,
|
16
16
|
paymentModule,
|
17
17
|
schedulingModule
|
18
|
-
} from './src';
|
19
|
-
import { join } from 'path';
|
18
|
+
} from './src/index.js';
|
19
|
+
import { join, dirname } from 'node:path';
|
20
|
+
import * as url from 'node:url';
|
20
21
|
|
21
|
-
const CONFIG_PATH =
|
22
|
-
|
22
|
+
const CONFIG_PATH = dirname(url.fileURLToPath(import.meta.url));
|
23
|
+
import jwks from './tests/jwks.json' assert { type: 'json' };
|
23
24
|
|
24
|
-
|
25
|
+
const createTestFacade = () => {
|
25
26
|
const serviceConfig = createServiceConfig(join(CONFIG_PATH, 'tests'));
|
26
27
|
|
27
28
|
const logger = createLogger(serviceConfig.get('logger'));
|
@@ -66,7 +67,7 @@ function createTestFacade() {
|
|
66
67
|
.useModule(paymentModule({config: serviceConfig.get('payment')}))
|
67
68
|
.useModule(schedulingModule({config: serviceConfig.get('scheduling')}))
|
68
69
|
.useMiddleware(reqResLogger({logger}));
|
69
|
-
}
|
70
|
+
};
|
70
71
|
|
71
72
|
const facade = createTestFacade();
|
72
73
|
|
package/dist/gql/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from './types/index';
|
1
|
+
export * from './types/index.js';
|
package/dist/gql/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./types/index"), exports);
|
1
|
+
export * from './types/index.js';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { FederatedSchemaWithResolvers, GraphQLResolverMap, ProtoMetadata, ServiceClient, SubSpaceServiceConfig } from './types';
|
2
|
-
import { GraphQLSchema } from 'graphql/index';
|
1
|
+
import { type FederatedSchemaWithResolvers, type GraphQLResolverMap, type ProtoMetadata, type ServiceClient, type SubSpaceServiceConfig } from './types.js';
|
2
|
+
import { type GraphQLSchema } from 'graphql/index.js';
|
3
3
|
import { GraphQLObjectType } from 'graphql';
|
4
|
-
import { GraphQLList } from 'graphql/type/definition';
|
4
|
+
import { GraphQLList } from 'graphql/type/definition.js';
|
5
5
|
export declare const buildFederatedSubscriptionSchema: <T, M extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, M>>(subServices: ProtoMetadata[], config: SubSpaceServiceConfig, namespace: string, schema: GraphQLSchema) => FederatedSchemaWithResolvers;
|
6
6
|
export declare const mergeSubscribeIntoSchema: (schema: GraphQLObjectType | GraphQLList<any> | null | undefined, resolvers: GraphQLResolverMap<any>[string]) => void;
|
@@ -1,21 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const index_1 = require("graphql/index");
|
10
|
-
const graphql_1 = require("graphql");
|
11
|
-
const definition_1 = require("graphql/type/definition");
|
12
|
-
const resolvers_1 = require("./resolvers");
|
13
|
-
const buildFederatedSubscriptionSchema = (subServices, config, namespace, schema) => {
|
14
|
-
const resolvers = (0, resolvers_1.generateSubServiceResolvers)(subServices, config, namespace);
|
1
|
+
import { buildSubgraphSchema } from '@apollo/federation';
|
2
|
+
import { gql } from 'graphql-tag';
|
3
|
+
import { printSchema } from 'graphql/index.js';
|
4
|
+
import { GraphQLObjectType } from 'graphql';
|
5
|
+
import { GraphQLList, GraphQLScalarType } from 'graphql/type/definition.js';
|
6
|
+
import { generateSubServiceResolvers } from './resolvers.js';
|
7
|
+
export const buildFederatedSubscriptionSchema = (subServices, config, namespace, schema) => {
|
8
|
+
const resolvers = generateSubServiceResolvers(subServices, config, namespace);
|
15
9
|
// TODO There is currently no way of building a federated schema from GraphQLSchema Object
|
16
10
|
// See https://github.com/apollographql/apollo-server/pull/4310
|
17
|
-
const federatedSchema =
|
18
|
-
typeDefs: (
|
11
|
+
const federatedSchema = buildSubgraphSchema({
|
12
|
+
typeDefs: gql(printSchema(schema)),
|
19
13
|
resolvers
|
20
14
|
});
|
21
15
|
return {
|
@@ -23,14 +17,13 @@ const buildFederatedSubscriptionSchema = (subServices, config, namespace, schema
|
|
23
17
|
resolvers
|
24
18
|
};
|
25
19
|
};
|
26
|
-
|
27
|
-
const mergeSubscribeIntoSchema = (schema, resolvers) => {
|
20
|
+
export const mergeSubscribeIntoSchema = (schema, resolvers) => {
|
28
21
|
if (!schema || !resolvers) {
|
29
22
|
return;
|
30
23
|
}
|
31
24
|
Object.entries(resolvers).forEach(([key, val]) => {
|
32
|
-
if (schema instanceof
|
33
|
-
|
25
|
+
if (schema instanceof GraphQLList) {
|
26
|
+
mergeSubscribeIntoSchema(schema.ofType, val);
|
34
27
|
return;
|
35
28
|
}
|
36
29
|
const field = schema.getFields()[key];
|
@@ -43,12 +36,11 @@ const mergeSubscribeIntoSchema = (schema, resolvers) => {
|
|
43
36
|
return;
|
44
37
|
}
|
45
38
|
const fieldType = field.type;
|
46
|
-
if (fieldType instanceof
|
39
|
+
if (fieldType instanceof GraphQLScalarType) {
|
47
40
|
field.subscribe = val['subscribe'];
|
48
41
|
}
|
49
|
-
else if (fieldType instanceof
|
50
|
-
|
42
|
+
else if (fieldType instanceof GraphQLObjectType) {
|
43
|
+
mergeSubscribeIntoSchema(fieldType, val);
|
51
44
|
}
|
52
45
|
});
|
53
46
|
};
|
54
|
-
exports.mergeSubscribeIntoSchema = mergeSubscribeIntoSchema;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { GraphQLInputField, GraphQLOutputType } from 'graphql';
|
2
|
-
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInputType } from 'graphql/type/definition';
|
3
|
-
import { ProtoMetadata, ServiceConfig } from './types';
|
4
|
-
import { ServiceDescriptorProto } from 'ts-proto-descriptors';
|
1
|
+
import { type GraphQLInputField, type GraphQLOutputType } from 'graphql';
|
2
|
+
import { GraphQLEnumType, GraphQLInputObjectType, type GraphQLInputType } from 'graphql/type/definition.js';
|
3
|
+
import { type ProtoMetadata, type ServiceConfig } from './types.js';
|
4
|
+
import { type ServiceDescriptorProto } from 'ts-proto-descriptors';
|
5
5
|
export declare const Mutate: string[];
|
6
6
|
export declare const preprocessGQLInput: (data: any, model: GraphQLInputObjectType | GraphQLEnumType | GraphQLInputField | GraphQLInputType) => Promise<any>;
|
7
7
|
export declare const postProcessGQLValue: (data: any, model: GraphQLOutputType) => any;
|
@@ -1,14 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
11
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
12
|
+
var m = o[Symbol.asyncIterator], i;
|
13
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
14
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
15
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
16
|
+
};
|
17
|
+
import { GraphQLList, GraphQLNonNull, GraphQLObjectType, } from 'graphql';
|
18
|
+
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, } from 'graphql/type/definition.js';
|
19
|
+
export const Mutate = ['Create', 'Update', 'Upsert'];
|
20
|
+
export const preprocessGQLInput = (data, model) => __awaiter(void 0, void 0, void 0, function* () {
|
21
|
+
var _a, e_1, _b, _c;
|
22
|
+
if (model instanceof GraphQLEnumType) {
|
9
23
|
return data;
|
10
24
|
}
|
11
|
-
if (model instanceof
|
25
|
+
if (model instanceof GraphQLInputObjectType) {
|
12
26
|
if (model.name === 'IGoogleProtobufAny') {
|
13
27
|
// TODO Use encoded once resource base supports it
|
14
28
|
// const typing = getTyping(data.typeUrl);
|
@@ -18,86 +32,95 @@ const preprocessGQLInput = async (data, model) => {
|
|
18
32
|
//
|
19
33
|
// const encoded = typing.processor.encode(typing.processor.fromPartial(data.value)).finish();
|
20
34
|
const encoded = Buffer.from(JSON.stringify(data.value));
|
21
|
-
return {
|
22
|
-
...data,
|
23
|
-
value: encoded
|
24
|
-
};
|
35
|
+
return Object.assign(Object.assign({}, data), { value: encoded });
|
25
36
|
}
|
26
37
|
else {
|
27
38
|
const fields = model.getFields();
|
28
39
|
for (let key of Object.keys(fields)) {
|
29
40
|
if (data && key in data) {
|
30
|
-
data[key] =
|
41
|
+
data[key] = yield preprocessGQLInput(data[key], fields[key].type);
|
31
42
|
}
|
32
43
|
}
|
33
44
|
}
|
34
45
|
}
|
35
|
-
if (model instanceof
|
46
|
+
if (model instanceof GraphQLScalarType) {
|
36
47
|
if (model.name === 'IDateTime') {
|
37
48
|
return new Date(data);
|
38
49
|
}
|
39
50
|
}
|
40
|
-
if (model instanceof
|
41
|
-
return
|
51
|
+
if (model instanceof GraphQLNonNull) {
|
52
|
+
return yield preprocessGQLInput(data, model.ofType);
|
42
53
|
}
|
43
|
-
if (model instanceof
|
54
|
+
if (model instanceof GraphQLList) {
|
44
55
|
for (let i = 0; i < data.length; i++) {
|
45
|
-
data[i] =
|
56
|
+
data[i] = yield preprocessGQLInput(data[i], model.ofType);
|
46
57
|
}
|
47
58
|
}
|
48
|
-
if (model instanceof
|
59
|
+
if (model instanceof GraphQLScalarType) {
|
49
60
|
switch (model.name) {
|
50
61
|
case 'Upload':
|
51
62
|
if (typeof data !== 'object') {
|
52
63
|
return Buffer.from(data.toString(), 'utf8');
|
53
64
|
}
|
54
|
-
let fileData =
|
55
|
-
const upload =
|
65
|
+
let fileData = yield data;
|
66
|
+
const upload = yield fileData.promise;
|
56
67
|
const stream = upload.createReadStream();
|
57
68
|
const chunks = [];
|
58
|
-
|
59
|
-
|
69
|
+
try {
|
70
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _a = stream_1_1.done, !_a;) {
|
71
|
+
_c = stream_1_1.value;
|
72
|
+
_d = false;
|
73
|
+
try {
|
74
|
+
let chunk = _c;
|
75
|
+
chunks.push(chunk);
|
76
|
+
}
|
77
|
+
finally {
|
78
|
+
_d = true;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
83
|
+
finally {
|
84
|
+
try {
|
85
|
+
if (!_d && !_a && (_b = stream_1.return)) yield _b.call(stream_1);
|
86
|
+
}
|
87
|
+
finally { if (e_1) throw e_1.error; }
|
60
88
|
}
|
61
89
|
return Buffer.concat(chunks);
|
62
90
|
}
|
63
91
|
}
|
64
92
|
return data;
|
65
|
-
};
|
66
|
-
|
67
|
-
|
68
|
-
if (model instanceof definition_1.GraphQLEnumType) {
|
93
|
+
});
|
94
|
+
export const postProcessGQLValue = (data, model) => {
|
95
|
+
if (model instanceof GraphQLEnumType) {
|
69
96
|
return data;
|
70
97
|
}
|
71
|
-
if (model instanceof
|
98
|
+
if (model instanceof GraphQLObjectType) {
|
72
99
|
if (model.name === 'GoogleProtobufAny' && (data === null || data === void 0 ? void 0 : data.value)) {
|
73
100
|
// TODO Use encoded once resource base supports it
|
74
101
|
const decoded = JSON.parse(data.value.toString());
|
75
|
-
return {
|
76
|
-
...data,
|
77
|
-
value: decoded
|
78
|
-
};
|
102
|
+
return Object.assign(Object.assign({}, data), { value: decoded });
|
79
103
|
}
|
80
104
|
else {
|
81
105
|
const fields = model.getFields();
|
82
106
|
for (let key of Object.keys(fields)) {
|
83
107
|
if (data && key in data) {
|
84
|
-
data[key] =
|
108
|
+
data[key] = postProcessGQLValue(data[key], fields[key].type);
|
85
109
|
}
|
86
110
|
}
|
87
111
|
}
|
88
112
|
}
|
89
|
-
if (model instanceof
|
90
|
-
return
|
113
|
+
if (model instanceof GraphQLNonNull) {
|
114
|
+
return postProcessGQLValue(data, model.ofType);
|
91
115
|
}
|
92
|
-
if (model instanceof
|
116
|
+
if (model instanceof GraphQLList) {
|
93
117
|
for (let i = 0; i < data.length; i++) {
|
94
|
-
data[i] =
|
118
|
+
data[i] = postProcessGQLValue(data[i], model.ofType);
|
95
119
|
}
|
96
120
|
}
|
97
121
|
return data;
|
98
122
|
};
|
99
|
-
|
100
|
-
const getWhitelistBlacklistConfig = (metaService, config, meta, entity) => {
|
123
|
+
export const getWhitelistBlacklistConfig = (metaService, config, meta, entity) => {
|
101
124
|
var _a, _b, _c, _d;
|
102
125
|
const queryList = [];
|
103
126
|
if (meta.options && meta.options.services && meta.options.services[metaService.name] && meta.options.services[metaService.name].methods) {
|
@@ -154,7 +177,7 @@ const getWhitelistBlacklistConfig = (metaService, config, meta, entity) => {
|
|
154
177
|
}
|
155
178
|
}
|
156
179
|
}
|
157
|
-
if (
|
180
|
+
if (Mutate.findIndex(val => mut.has(val)) > -1) {
|
158
181
|
mut.add('Mutate');
|
159
182
|
}
|
160
183
|
return {
|
@@ -162,4 +185,3 @@ const getWhitelistBlacklistConfig = (metaService, config, meta, entity) => {
|
|
162
185
|
queries: que
|
163
186
|
};
|
164
187
|
};
|
165
|
-
exports.getWhitelistBlacklistConfig = getWhitelistBlacklistConfig;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from './types';
|
2
|
-
export * from './registry';
|
3
|
-
export * from './graphql';
|
4
|
-
export * from './federation';
|
5
|
-
export * from './resolvers';
|
6
|
-
export * from './schema';
|
1
|
+
export * from './types.js';
|
2
|
+
export * from './registry.js';
|
3
|
+
export * from './graphql.js';
|
4
|
+
export * from './federation.js';
|
5
|
+
export * from './resolvers.js';
|
6
|
+
export * from './schema.js';
|
package/dist/gql/protos/index.js
CHANGED
@@ -1,22 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./types"), exports);
|
18
|
-
__exportStar(require("./registry"), exports);
|
19
|
-
__exportStar(require("./graphql"), exports);
|
20
|
-
__exportStar(require("./federation"), exports);
|
21
|
-
__exportStar(require("./resolvers"), exports);
|
22
|
-
__exportStar(require("./schema"), exports);
|
1
|
+
export * from './types.js';
|
2
|
+
export * from './registry.js';
|
3
|
+
export * from './graphql.js';
|
4
|
+
export * from './federation.js';
|
5
|
+
export * from './resolvers.js';
|
6
|
+
export * from './schema.js';
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { GraphQLEnumTypeConfig, GraphQLInputObjectTypeConfig, GraphQLObjectType, GraphQLObjectTypeConfig } from
|
2
|
-
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType } from
|
3
|
-
import { ProtoMetadata, ProtoMetaMessageOptions } from './types';
|
4
|
-
import { DescriptorProto, EnumDescriptorProto, MethodDescriptorProto } from
|
1
|
+
import { type GraphQLEnumTypeConfig, type GraphQLInputObjectTypeConfig, GraphQLObjectType, type GraphQLObjectTypeConfig } from 'graphql';
|
2
|
+
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType } from 'graphql/type/definition.js';
|
3
|
+
import { type ProtoMetadata, type ProtoMetaMessageOptions } from './types.js';
|
4
|
+
import { type DescriptorProto, type EnumDescriptorProto, type MethodDescriptorProto } from 'ts-proto-descriptors';
|
5
5
|
export interface TypingData {
|
6
6
|
output: GraphQLObjectType | GraphQLEnumType | GraphQLScalarType;
|
7
7
|
input: GraphQLInputObjectType | GraphQLEnumType | GraphQLScalarType;
|
@@ -12,12 +12,12 @@ export declare const registeredTypings: Map<string, TypingData>;
|
|
12
12
|
export declare const scalarTypes: string[];
|
13
13
|
export declare const IGoogleProtobufAny: GraphQLInputObjectType;
|
14
14
|
export declare const clearRegistry: () => void;
|
15
|
-
export declare const registerPackagesRecursive: (...protoMetadata: ProtoMetadata[]) => void;
|
16
15
|
export declare const getRegisteredEnumTypings: () => string[];
|
17
16
|
export declare const getNameSpaceTypeName: (typeName: string) => string | undefined;
|
17
|
+
export declare const getTyping: (type: string) => TypingData | undefined;
|
18
18
|
export declare const recursiveEnumCheck: (typeName: string, enumMap: Map<string, string>, prevFieldName: string, traversedFields: string[]) => Map<string, string>;
|
19
19
|
export declare const registerTyping: (protoPackage: string, message: DescriptorProto, methodDef: MethodDescriptorProto[], opts?: Omit<Readonly<GraphQLObjectTypeConfig<any, any>>, 'fields'>, inputOpts?: Omit<Readonly<GraphQLInputObjectTypeConfig>, 'fields'>, messageOptions?: ProtoMetaMessageOptions) => void;
|
20
20
|
export declare const registerEnumTyping: <T = {
|
21
21
|
[key: string]: any;
|
22
22
|
}>(protoPackage: string, message: EnumDescriptorProto, opts?: Omit<Readonly<GraphQLEnumTypeConfig>, 'values'>) => void;
|
23
|
-
export declare const
|
23
|
+
export declare const registerPackagesRecursive: (...protoMetadata: ProtoMetadata[]) => void;
|