wgc 0.15.1 → 0.17.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 +12 -0
- package/dist/commands/federated-graph/commands/changelog.js +4 -3
- package/dist/commands/federated-graph/commands/changelog.js.map +1 -1
- package/dist/commands/federated-graph/commands/fetch.js +23 -11
- package/dist/commands/federated-graph/commands/fetch.js.map +1 -1
- package/dist/commands/federated-graph/commands/list.js +43 -24
- package/dist/commands/federated-graph/commands/list.js.map +1 -1
- package/dist/commands/router/commands/compose.js +9 -3
- package/dist/commands/router/commands/compose.js.map +1 -1
- package/dist/commands/router/commands/fetch.js +10 -2
- package/dist/commands/router/commands/fetch.js.map +1 -1
- package/dist/commands/subgraph/commands/introspect.js +16 -10
- package/dist/commands/subgraph/commands/introspect.js.map +1 -1
- package/dist/commands/subgraph/commands/list.js +47 -24
- package/dist/commands/subgraph/commands/list.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/commands/federated-graph/commands/changelog.ts +19 -17
- package/src/commands/federated-graph/commands/fetch.ts +20 -10
- package/src/commands/federated-graph/commands/list.ts +57 -21
- package/src/commands/router/commands/compose.ts +8 -3
- package/src/commands/router/commands/fetch.ts +8 -1
- package/src/commands/subgraph/commands/introspect.ts +16 -9
- package/src/commands/subgraph/commands/list.ts +60 -21
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ Binaries are attached to the github release otherwise all images can be found [h
|
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
|
5
5
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
6
6
|
|
|
7
|
+
# [0.17.0](https://github.com/wundergraph/cosmo/compare/wgc@0.16.0...wgc@0.17.0) (2023-09-29)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* improve trail version banner and handle trial version expiry ([#138](https://github.com/wundergraph/cosmo/issues/138)) ([0ecb2d1](https://github.com/wundergraph/cosmo/commit/0ecb2d150d9f9906631168aa0f588d2ca64ab590)) (@JivusAyrus)
|
|
12
|
+
|
|
13
|
+
# [0.16.0](https://github.com/wundergraph/cosmo/compare/wgc@0.15.1...wgc@0.16.0) (2023-09-27)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* output file option for cli commands ([#121](https://github.com/wundergraph/cosmo/issues/121)) ([329023e](https://github.com/wundergraph/cosmo/commit/329023e1b3e518020dd2948220d64960783d3577)) (@thisisnithin)
|
|
18
|
+
|
|
7
19
|
## [0.15.1](https://github.com/wundergraph/cosmo/compare/wgc@0.15.0...wgc@0.15.1) (2023-09-26)
|
|
8
20
|
|
|
9
21
|
**Note:** Version bump only for package wgc
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
3
3
|
import { Command, program } from 'commander';
|
|
4
4
|
import { endOfDay, formatISO, startOfDay, subDays } from 'date-fns';
|
|
5
5
|
import pc from 'picocolors';
|
|
6
|
+
import { join } from 'pathe';
|
|
6
7
|
import { baseHeaders } from '../../../core/config.js';
|
|
7
8
|
export default (opts) => {
|
|
8
9
|
const command = new Command('changelog');
|
|
@@ -12,7 +13,7 @@ export default (opts) => {
|
|
|
12
13
|
command.option('-f, --offset [number]', 'Offset of entries. Defaults to 0', '0');
|
|
13
14
|
command.option('-s, --start [date]', 'Start date. Defaults to 3 days back');
|
|
14
15
|
command.option('-e, --end [date]', 'End date. Defaults to today');
|
|
15
|
-
command.option('-o, --out', 'Destination file for changelog. Defaults to changelog.json', 'changelog.json');
|
|
16
|
+
command.option('-o, --out [string]', 'Destination file for changelog. Defaults to changelog.json', 'changelog.json');
|
|
16
17
|
command.action(async (name, options) => {
|
|
17
18
|
var _a, _b, _c;
|
|
18
19
|
let startDate = subDays(new Date(), 3);
|
|
@@ -48,7 +49,7 @@ export default (opts) => {
|
|
|
48
49
|
createdAt: cl.createdAt,
|
|
49
50
|
})),
|
|
50
51
|
}));
|
|
51
|
-
|
|
52
|
+
await writeFile(join(process.cwd(), options.out), JSON.stringify(output));
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
55
|
let message = `Failed to fetch changelog for ${pc.bold(name)}.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../../../src/commands/federated-graph/commands/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../../../src/commands/federated-graph/commands/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAetD,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,4CAA4C,CAAC,CAAC;IACzE,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,kCAAkC,EAAE,IAAI,CAAC,CAAC;IACjF,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,kCAAkC,EAAE,GAAG,CAAC,CAAC;IACjF,OAAO,CAAC,MAAM,CAAC,oBA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AS;gBACvB,eAAe,EAAE,EAAE,CAAC,eAAe;gBACnC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;oBACrC,EAAE,EAAE,EAAE,CAAC,EAAE;oBACT,IAAI,EAAE,EAAE,CAAC,IAAI;oBACb,UAAU,EAAE,EAAE,CAAC,UAAU;oBACzB,aAAa,EAAE,EAAE,CAAC,aAAa;oBAC/B,SAAS,EAAE,EAAE,CAAC,SAAS;iBACxB,CAAC,CAAC;aACmB,CAAA,CAC3B,CAAC;YACF,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;SAC3E;aAAM;YACL,IAAI,OAAO,GAAG,iCAAiC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YAChE,IAAI,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,EAAE;gBAC1B,OAAO,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,CAAC,CAAC;aACpD;YACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACxB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,28 +1,40 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
1
3
|
import { Command } from 'commander';
|
|
4
|
+
import { join } from 'pathe';
|
|
2
5
|
import pc from 'picocolors';
|
|
3
|
-
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
4
6
|
import { baseHeaders } from '../../../core/config.js';
|
|
7
|
+
import program from '../../index.js';
|
|
5
8
|
export default (opts) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const command = new Command('fetch');
|
|
10
|
+
command.description('Fetches the latest valid SDL of a federated graph. The output can be piped to a file.');
|
|
11
|
+
command.argument('<name>', 'The name of the federated graph to fetch.');
|
|
12
|
+
command.option('-o, --out [string]', 'Destination file for the SDL.');
|
|
13
|
+
command.action(async (name, options) => {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
11
15
|
const resp = await opts.client.platform.getFederatedGraphSDLByName({
|
|
12
16
|
name,
|
|
13
17
|
}, {
|
|
14
18
|
headers: baseHeaders,
|
|
15
19
|
});
|
|
16
|
-
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) === EnumStatusCode.
|
|
20
|
+
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) === EnumStatusCode.ERR_FREE_TRIAL_EXPIRED) {
|
|
21
|
+
program.error(resp.response.details || 'Free trial has concluded. Please talk to sales to upgrade your plan.');
|
|
22
|
+
}
|
|
23
|
+
if (((_b = resp.response) === null || _b === void 0 ? void 0 : _b.code) === EnumStatusCode.ERR_NOT_FOUND) {
|
|
17
24
|
console.log(`${pc.red(`No valid composition could be fetched for federated graph ${pc.bold(name)}`)}`);
|
|
18
25
|
console.log('Please check the name and the composition status of the federated graph in the Studio.');
|
|
19
|
-
if ((
|
|
20
|
-
console.log(pc.red(pc.bold((
|
|
26
|
+
if ((_c = resp.response) === null || _c === void 0 ? void 0 : _c.details) {
|
|
27
|
+
console.log(pc.red(pc.bold((_d = resp.response) === null || _d === void 0 ? void 0 : _d.details)));
|
|
21
28
|
}
|
|
22
29
|
process.exit(1);
|
|
23
30
|
}
|
|
24
|
-
|
|
31
|
+
if (options.out) {
|
|
32
|
+
await writeFile(join(process.cwd(), options.out), (_e = resp.sdl) !== null && _e !== void 0 ? _e : '');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log(resp.sdl);
|
|
36
|
+
}
|
|
25
37
|
});
|
|
26
|
-
return
|
|
38
|
+
return command;
|
|
27
39
|
};
|
|
28
40
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/commands/federated-graph/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/commands/federated-graph/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,WAAW,CAAC,uFAAuF,CAAC,CAAC;IAC7G,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,2CAA2C,CAAC,CAAC;IACxE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,+BAA+B,CAAC,CAAC;IACtE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAChE;YACE,IAAI;SACL,EACD;YACE,OAAO,EAAE,WAAW;SACrB,CACF,CAAC;QAEF,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,MAAK,cAAc,CAAC,sBAAsB,EAAE;YACjE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,sEAAsE,CAAC,CAAC;SAChH;QAED,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,MAAK,cAAc,CAAC,aAAa,EAAE;YACxD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,6DAA6D,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACvG,OAAO,CAAC,GAAG,CAAC,wFAAwF,CAAC,CAAC;YACtG,IAAI,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,EAAE;gBAC1B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,CAAC,CAAC,CAAC;aACtD;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,IAAI,OAAO,CAAC,GAAG,EAAE;YACf,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,EAAE,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACvB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import pc from 'picocolors';
|
|
3
4
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
4
5
|
import Table from 'cli-table3';
|
|
5
6
|
import logSymbols from 'log-symbols';
|
|
7
|
+
import { join } from 'pathe';
|
|
6
8
|
import { baseHeaders } from '../../../core/config.js';
|
|
7
9
|
import program from '../../index.js';
|
|
8
10
|
export default (opts) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const command = new Command('list');
|
|
12
|
+
command.description('Lists federated graphs.');
|
|
13
|
+
command.option('-o, --out [string]', 'Destination file for the json output.');
|
|
14
|
+
command.option('-r, --raw', 'Prints to the console in json format instead of table');
|
|
15
|
+
command.action(async (options) => {
|
|
16
|
+
var _a, _b;
|
|
13
17
|
const resp = await opts.client.platform.getFederatedGraphs({
|
|
14
18
|
includeMetrics: false,
|
|
15
19
|
// limit 0 fetches all
|
|
@@ -18,37 +22,52 @@ export default (opts) => {
|
|
|
18
22
|
}, {
|
|
19
23
|
headers: baseHeaders,
|
|
20
24
|
});
|
|
25
|
+
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
|
|
26
|
+
console.log(pc.red((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details));
|
|
27
|
+
program.error(pc.red('Could not fetch the federated graphs.'));
|
|
28
|
+
}
|
|
29
|
+
if (resp.graphs.length === 0) {
|
|
30
|
+
console.log('No federated graphs found');
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
if (options.out) {
|
|
34
|
+
const output = resp.graphs.map((g) => ({
|
|
35
|
+
name: g.name,
|
|
36
|
+
labelMatchers: g.labelMatchers,
|
|
37
|
+
routingURL: g.routingURL,
|
|
38
|
+
isComposable: g.isComposable,
|
|
39
|
+
lastUpdatedAt: g.lastUpdatedAt,
|
|
40
|
+
}));
|
|
41
|
+
await writeFile(join(process.cwd(), options.out), JSON.stringify(output));
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
if (options.raw) {
|
|
45
|
+
console.log(resp.graphs);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
21
48
|
const graphsTable = new Table({
|
|
22
49
|
head: [
|
|
23
50
|
pc.bold(pc.white('NAME')),
|
|
24
51
|
pc.bold(pc.white('LABEL_MATCHERS')),
|
|
25
52
|
pc.bold(pc.white('ROUTING_URL')),
|
|
26
53
|
pc.bold(pc.white('IS_COMPOSABLE')),
|
|
54
|
+
pc.bold(pc.white('UPDATED_AT')),
|
|
27
55
|
],
|
|
28
56
|
colAligns: ['left', 'left', 'left', 'center'],
|
|
29
|
-
colWidths: [25, 40, 70, 15],
|
|
57
|
+
colWidths: [25, 40, 70, 15, 30],
|
|
30
58
|
wordWrap: true,
|
|
31
59
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
42
|
-
console.log(graphsTable.toString());
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
console.log('No federated graphs found');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
program.error(pc.red('Could not fetch the federated graphs.'));
|
|
60
|
+
for (const graph of resp.graphs) {
|
|
61
|
+
graphsTable.push([
|
|
62
|
+
graph.name,
|
|
63
|
+
graph.labelMatchers.join(','),
|
|
64
|
+
graph.routingURL,
|
|
65
|
+
graph.isComposable ? logSymbols.success : logSymbols.error,
|
|
66
|
+
graph.lastUpdatedAt,
|
|
67
|
+
]);
|
|
50
68
|
}
|
|
69
|
+
console.log(graphsTable.toString());
|
|
51
70
|
});
|
|
52
|
-
return
|
|
71
|
+
return command;
|
|
53
72
|
};
|
|
54
73
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/federated-graph/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAA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,gBAAgB,CAAC,CAAC;gBACnC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBAChC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAClC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;aAChC;YACD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;YAC7C,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;YAC/B,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,WAAW,CAAC,IAAI,CAAC;gBACf,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC7B,KAAK,CAAC,UAAU;gBAChB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK;gBAC1D,KAAK,CAAC,aAAa;aACpB,CAAC,CAAC;SACJ;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { buildRouterConfig, normalizeURL } from '@wundergraph/cosmo-shared';
|
|
4
4
|
import { Command, program } from 'commander';
|
|
5
5
|
import { parse, printSchema } from 'graphql';
|
|
6
6
|
import * as yaml from 'js-yaml';
|
|
7
|
-
import { resolve, dirname } from 'pathe';
|
|
7
|
+
import { resolve, dirname, join } from 'pathe';
|
|
8
8
|
import pc from 'picocolors';
|
|
9
9
|
import { composeSubgraphs, introspectSubgraph } from '../../../utils.js';
|
|
10
10
|
export default (opts) => {
|
|
11
11
|
const command = new Command('compose');
|
|
12
12
|
command.description('Generates a router config from a local composition file. This makes it easy to test your router without a control-plane connection. For production, please use the "router fetch" command');
|
|
13
13
|
command.requiredOption('-i, --input <path-to-input>', 'The yaml file with data about graph and subgraphs.');
|
|
14
|
+
command.option('-o, --out [string]', 'Destination file for the router config.');
|
|
14
15
|
command.action(async (options) => {
|
|
15
16
|
var _a, _b, _c, _d, _e, _f;
|
|
16
17
|
const inputFile = resolve(process.cwd(), options.input);
|
|
@@ -62,7 +63,12 @@ export default (opts) => {
|
|
|
62
63
|
sdl: sdls[index],
|
|
63
64
|
})),
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
+
if (options.out) {
|
|
67
|
+
await writeFile(join(process.cwd(), options.out), routerConfig.toJsonString());
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.log(routerConfig.toJsonString());
|
|
71
|
+
}
|
|
66
72
|
});
|
|
67
73
|
return command;
|
|
68
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,OA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';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import pc from 'picocolors';
|
|
3
4
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
5
|
+
import { join } from 'pathe';
|
|
4
6
|
import { baseHeaders } from '../../../core/config.js';
|
|
5
7
|
export default (opts) => {
|
|
6
8
|
const command = new Command('fetch');
|
|
7
9
|
command.description('Fetches the latest valid router config for a federated graph. The output can be piped to a file.');
|
|
8
10
|
command.argument('<name>', 'The name of the federated graph to fetch.');
|
|
11
|
+
command.option('-o, --out [string]', 'Destination file for the router config.');
|
|
9
12
|
command.action(async (name, options) => {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
14
|
const resp = await opts.client.platform.getLatestValidRouterConfig({
|
|
12
15
|
graphName: name,
|
|
13
16
|
}, {
|
|
@@ -20,7 +23,12 @@ export default (opts) => {
|
|
|
20
23
|
}
|
|
21
24
|
process.exit(1);
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
if (options.out) {
|
|
27
|
+
await writeFile(join(process.cwd(), options.out), (_e = (_d = resp.config) === null || _d === void 0 ? void 0 : _d.toJsonString()) !== null && _e !== void 0 ? _e : '');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log((_f = resp.config) === null || _f === void 0 ? void 0 : _f.toJsonString());
|
|
31
|
+
}
|
|
24
32
|
});
|
|
25
33
|
return command;
|
|
26
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,eAAe,CAAC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C,GAAG,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,EAAE,mCAAI,EAAE,CAAC,CAAC;SACtF;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,EAAE,CAAC,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
1
2
|
import { splitLabel } from '@wundergraph/cosmo-shared';
|
|
2
3
|
import { Command } from 'commander';
|
|
3
4
|
import pc from 'picocolors';
|
|
5
|
+
import { join } from 'pathe';
|
|
4
6
|
import { introspectSubgraph } from '../../../utils.js';
|
|
5
7
|
import program from '../../index.js';
|
|
6
8
|
export default (opts) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const command = new Command('introspect');
|
|
10
|
+
command.description('Introspects a subgraph.');
|
|
11
|
+
command.requiredOption('-r, --routing-url <url>', 'The routing url of your subgraph. This is the url that the subgraph will be accessible at.');
|
|
12
|
+
command.option('--header [headers...]', 'The headers to apply when the subgraph is introspected. This is used for authentication and authorization.The headers are passed in the format <key>=<value> <key>=<value>.Use quotes if there exists space in the key/value.');
|
|
13
|
+
command.option('-o, --out [string]', 'Destination file for the SDL.');
|
|
14
|
+
command.action(async (options) => {
|
|
15
|
+
var _a, _b;
|
|
13
16
|
const resp = await introspectSubgraph({
|
|
14
17
|
subgraphURL: options.routingUrl,
|
|
15
18
|
additionalHeaders: ((_a = options.header) === null || _a === void 0 ? void 0 : _a.map((label) => {
|
|
@@ -20,13 +23,16 @@ export default (opts) => {
|
|
|
20
23
|
};
|
|
21
24
|
})) || [],
|
|
22
25
|
});
|
|
23
|
-
if (resp.success
|
|
24
|
-
|
|
26
|
+
if (resp.success !== true) {
|
|
27
|
+
program.error(pc.red('Could not introspect the subgraph.'));
|
|
28
|
+
}
|
|
29
|
+
if (options.out) {
|
|
30
|
+
await writeFile(join(process.cwd(), options.out), (_b = resp.sdl) !== null && _b !== void 0 ? _b : '');
|
|
25
31
|
}
|
|
26
32
|
else {
|
|
27
|
-
|
|
33
|
+
console.log(resp.sdl);
|
|
28
34
|
}
|
|
29
35
|
});
|
|
30
|
-
return
|
|
36
|
+
return command;
|
|
31
37
|
};
|
|
32
38
|
//# sourceMappingURL=introspect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../../../../src/commands/subgraph/commands/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../../../../src/commands/subgraph/commands/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAC/C,OAAO,CAAC,cAAc,CACpB,yBAAyB,EACzB,4FAA4F,CAC7F,CAAC;IACF,OAAO,CAAC,MAAM,CACZ,uBAAuB,EACvB,+NAA+N,CAChO,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,+BAA+B,CAAC,CAAC;IACtE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;;QAC/B,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC;YACpC,WAAW,EAAE,OAAO,CAAC,UAAU;YAC/B,iBAAiB,EACf,CAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;gBACpC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO;oBACL,GAAG;oBACH,KAAK;iBACN,CAAC;YACJ,CAAC,CAAC,KAAI,EAAE;SACX,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;SAC7D;QAED,IAAI,OAAO,CAAC,GAAG,EAAE;YACf,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,EAAE,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACvB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
1
2
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
3
|
+
import { joinLabel } from '@wundergraph/cosmo-shared';
|
|
2
4
|
import Table from 'cli-table3';
|
|
3
5
|
import { Command } from 'commander';
|
|
4
6
|
import pc from 'picocolors';
|
|
7
|
+
import { join } from 'pathe';
|
|
5
8
|
import { baseHeaders } from '../../../core/config.js';
|
|
6
9
|
import program from '../../index.js';
|
|
7
10
|
export default (opts) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const command = new Command('list');
|
|
12
|
+
command.description('Lists subgraphs.');
|
|
13
|
+
command.option('-o, --out [string]', 'Destination file for the json output.');
|
|
14
|
+
command.option('-r, --raw', 'Prints to the console in json format instead of table');
|
|
15
|
+
command.action(async (options) => {
|
|
16
|
+
var _a, _b;
|
|
12
17
|
const resp = await opts.client.platform.getSubgraphs({
|
|
13
18
|
// limit 0 fetches all
|
|
14
19
|
limit: 0,
|
|
@@ -16,30 +21,48 @@ export default (opts) => {
|
|
|
16
21
|
}, {
|
|
17
22
|
headers: baseHeaders,
|
|
18
23
|
});
|
|
24
|
+
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
|
|
25
|
+
console.log(pc.red((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details));
|
|
26
|
+
program.error(pc.red('Could not fetch subgraphs.'));
|
|
27
|
+
}
|
|
28
|
+
if (resp.graphs.length === 0) {
|
|
29
|
+
console.log('No subgraphs found');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
if (options.out) {
|
|
33
|
+
const output = resp.graphs.map((g) => ({
|
|
34
|
+
name: g.name,
|
|
35
|
+
labels: g.labels.map((l) => joinLabel(l)),
|
|
36
|
+
routingURL: g.routingURL,
|
|
37
|
+
lastUpdatedAt: g.lastUpdatedAt,
|
|
38
|
+
}));
|
|
39
|
+
await writeFile(join(process.cwd(), options.out), JSON.stringify(output));
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
if (options.raw) {
|
|
43
|
+
console.log(resp.graphs);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
19
46
|
const graphsTable = new Table({
|
|
20
|
-
head: [
|
|
21
|
-
|
|
47
|
+
head: [
|
|
48
|
+
pc.bold(pc.white('NAME')),
|
|
49
|
+
pc.bold(pc.white('LABELS')),
|
|
50
|
+
pc.bold(pc.white('ROUTING_URL')),
|
|
51
|
+
pc.bold(pc.white('UPDATED_AT')),
|
|
52
|
+
],
|
|
53
|
+
colWidths: [15, 30, 60, 30],
|
|
22
54
|
wordWrap: true,
|
|
23
55
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
console.log(graphsTable.toString());
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
console.log('No subgraphs found');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
program.error(pc.red('Could not fetch the subgraphs.'));
|
|
56
|
+
for (const graph of resp.graphs) {
|
|
57
|
+
graphsTable.push([
|
|
58
|
+
graph.name,
|
|
59
|
+
graph.labels.map(({ key, value }) => `${key}=${value}`).join(', '),
|
|
60
|
+
graph.routingURL,
|
|
61
|
+
graph.lastUpdatedAt,
|
|
62
|
+
]);
|
|
41
63
|
}
|
|
64
|
+
console.log(graphsTable.toString());
|
|
42
65
|
});
|
|
43
|
-
return
|
|
66
|
+
return command;
|
|
44
67
|
};
|
|
45
68
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/subgraph/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,OAAO,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3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