wgc 0.71.6 → 0.72.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/router/commands/cache/commands/push.d.ts +4 -0
- package/dist/commands/router/commands/cache/commands/push.js +56 -0
- package/dist/commands/router/commands/cache/commands/push.js.map +1 -0
- package/dist/commands/router/commands/cache/index.d.ts +4 -0
- package/dist/commands/router/commands/cache/index.js +9 -0
- package/dist/commands/router/commands/cache/index.js.map +1 -0
- package/dist/commands/router/index.js +4 -0
- package/dist/commands/router/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { Command, program } from 'commander';
|
|
4
|
+
import pc from 'picocolors';
|
|
5
|
+
import { resolve } from 'pathe';
|
|
6
|
+
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
7
|
+
import { getBaseHeaders } from '../../../../../core/config.js';
|
|
8
|
+
export default (opts) => {
|
|
9
|
+
const command = new Command('push');
|
|
10
|
+
command.description('Pushes new cache warmer operations to the registry');
|
|
11
|
+
command.argument('<graph_name>', 'The name of the federated graph or monograph on which the check operations are stored.');
|
|
12
|
+
command.option('-n, --namespace [string]', 'The namespace of the federated graph or monograph.');
|
|
13
|
+
command.option('-o, --operation-name <operation-name>', 'The name of the operation. Only needed when working with multi-operation document.');
|
|
14
|
+
command.option('-p, --persisted-operation-id <persisted-operation-id>', 'The id of the persisted operation to be pushed.');
|
|
15
|
+
command.option('-f, --file <file>', 'The file with the operation to push - supports .graphql, .gql. If both the file and the persisted operation id are provided, the persisted operation id will be used.');
|
|
16
|
+
command.action(async (name, options) => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if (!options.file && !options.persistedOperationId) {
|
|
19
|
+
command.error(pc.red('No operation file or the id of persisted operation provided'));
|
|
20
|
+
}
|
|
21
|
+
if (options.persistedOperationId && options.file) {
|
|
22
|
+
command.error(pc.red('Only the persisted operation id or the file can be specified'));
|
|
23
|
+
}
|
|
24
|
+
let operation;
|
|
25
|
+
if (options.file) {
|
|
26
|
+
const operationFile = resolve(options.file);
|
|
27
|
+
if (!existsSync(operationFile)) {
|
|
28
|
+
program.error(pc.red(pc.bold(`The operation file '${pc.bold(operationFile)}' does not exist. Please check the path and try again.`)));
|
|
29
|
+
}
|
|
30
|
+
const schemaBuffer = await readFile(operationFile);
|
|
31
|
+
operation = new TextDecoder().decode(schemaBuffer);
|
|
32
|
+
if (operation.trim().length === 0) {
|
|
33
|
+
program.error(pc.red(pc.bold(`The schema file '${pc.bold(operationFile)}' is empty. Please provide a valid operation.`)));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const result = await opts.client.platform.pushCacheWarmerOperation({
|
|
37
|
+
federatedGraphName: name,
|
|
38
|
+
operationContent: operation,
|
|
39
|
+
operationName: options.operationName,
|
|
40
|
+
operationPersistedId: options.persistedOperationId,
|
|
41
|
+
namespace: options.namespace,
|
|
42
|
+
}, { headers: getBaseHeaders() });
|
|
43
|
+
if (((_a = result.response) === null || _a === void 0 ? void 0 : _a.code) === EnumStatusCode.OK) {
|
|
44
|
+
console.log(pc.green(`The cache warmer operation was pushed successfully.`));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(pc.red(`Failed to push the cache warmer operation. Please try again.`));
|
|
48
|
+
if ((_b = result.response) === null || _b === void 0 ? void 0 : _b.details) {
|
|
49
|
+
console.error(pc.red(pc.bold((_c = result.response) === null || _c === void 0 ? void 0 : _c.details)));
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return command;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"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AAC,qDAAqD,CAAC,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC,CAAC;YACpF,IAAI,MAAA,MAAM,CAAC,QAAQ,0CAAE,OAAO,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAA,MAAM,CAAC,QAAQ,0CAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import PushCacheOperation from './commands/push.js';
|
|
3
|
+
export default (opts) => {
|
|
4
|
+
const schema = new Command('cache');
|
|
5
|
+
schema.description('Provides commands for pushing and maintaining router cache warmer operations of a federated graph');
|
|
6
|
+
schema.addCommand(PushCacheOperation(opts));
|
|
7
|
+
return schema;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/router/commands/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,kBAAkB,MAAM,oBAAoB,CAAC;AAEpD,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,CAAC,WAAW,CAChB,mGAAmG,CACpG,CAAC;IAEF,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -4,6 +4,7 @@ import ComposeRouterConfig from './commands/compose.js';
|
|
|
4
4
|
import FetchRouterConfig from './commands/fetch.js';
|
|
5
5
|
import RouterTokenCommands from './commands/token/index.js';
|
|
6
6
|
import DownloadRouterBinaryConfig from './commands/download-binary.js';
|
|
7
|
+
import RouterCacheCommands from './commands/cache/index.js';
|
|
7
8
|
export default (opts) => {
|
|
8
9
|
const cmd = new Command('router');
|
|
9
10
|
cmd.description('Provides commands for fetching and composing router configs');
|
|
@@ -13,6 +14,9 @@ export default (opts) => {
|
|
|
13
14
|
client: opts.client,
|
|
14
15
|
}));
|
|
15
16
|
cmd.addCommand(DownloadRouterBinaryConfig(opts));
|
|
17
|
+
cmd.addCommand(RouterCacheCommands({
|
|
18
|
+
client: opts.client,
|
|
19
|
+
}));
|
|
16
20
|
cmd.hook('preAction', async (thisCmd) => {
|
|
17
21
|
if (['compose', 'download-binary'].includes(thisCmd.args[0])) {
|
|
18
22
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAC5D,OAAO,0BAA0B,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC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