great 0.3.2 → 1.0.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/README.md +119 -13
- package/dist/accounts/create.d.ts +4 -0
- package/dist/accounts/create.js +42 -0
- package/dist/accounts/create.js.map +1 -0
- package/dist/accounts/index.d.ts +5 -2
- package/dist/accounts/index.js +48 -9
- package/dist/accounts/index.js.map +1 -1
- package/dist/clone/index.d.ts +8 -0
- package/dist/clone/index.js +61 -0
- package/dist/clone/index.js.map +1 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +111 -0
- package/dist/config/index.js.map +1 -0
- package/dist/create/index.d.ts +3 -0
- package/dist/create/index.js +7 -0
- package/dist/create/index.js.map +1 -0
- package/dist/deploy/index.d.ts +11 -0
- package/dist/deploy/index.js +132 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/explode/index.d.ts +5 -0
- package/dist/explode/index.js +32 -0
- package/dist/explode/index.js.map +1 -0
- package/dist/explode/transform.d.ts +30 -0
- package/dist/explode/transform.js +100 -0
- package/dist/explode/transform.js.map +1 -0
- package/dist/explode/unescapeMongo.d.ts +1 -0
- package/dist/explode/unescapeMongo.js +15 -0
- package/dist/explode/unescapeMongo.js.map +1 -0
- package/dist/generated/graphql.d.ts +1784 -0
- package/dist/generated/graphql.js +73 -0
- package/dist/generated/graphql.js.map +1 -0
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +5 -0
- package/dist/init/index.js +46 -0
- package/dist/init/index.js.map +1 -0
- package/dist/integrations/create.d.ts +6 -0
- package/dist/integrations/create.js +70 -0
- package/dist/integrations/create.js.map +1 -0
- package/dist/{projects/describe.d.ts → integrations/index.d.ts} +0 -1
- package/dist/integrations/index.js +23 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/list.d.ts +7 -0
- package/dist/integrations/list.js +103 -0
- package/dist/integrations/list.js.map +1 -0
- package/dist/login/index.d.ts +6 -0
- package/dist/login/index.js +25 -0
- package/dist/login/index.js.map +1 -0
- package/dist/logout/index.d.ts +6 -0
- package/dist/logout/index.js +11 -0
- package/dist/logout/index.js.map +1 -0
- package/dist/now/index.d.ts +3 -1
- package/dist/now/index.js +11 -2
- package/dist/now/index.js.map +1 -1
- package/dist/pull/index.d.ts +5 -1
- package/dist/pull/index.js +50 -19
- package/dist/pull/index.js.map +1 -1
- package/dist/push/index.d.ts +11 -0
- package/dist/push/index.js +481 -0
- package/dist/push/index.js.map +1 -0
- package/dist/repl/dispatch.d.ts +8 -0
- package/dist/repl/dispatch.js +75 -0
- package/dist/repl/dispatch.js.map +1 -0
- package/dist/repl/help.d.ts +2 -0
- package/dist/repl/help.js +14 -0
- package/dist/repl/help.js.map +1 -0
- package/dist/repl/index.d.ts +10 -0
- package/dist/repl/index.js +92 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/run/index.d.ts +33 -1
- package/dist/run/index.js +109 -40
- package/dist/run/index.js.map +1 -1
- package/dist/status/index.d.ts +10 -0
- package/dist/status/index.js +122 -0
- package/dist/status/index.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/authServer.d.ts +4 -0
- package/dist/utils/authServer.js +49 -0
- package/dist/utils/authServer.js.map +1 -0
- package/dist/utils/config.d.ts +15 -0
- package/dist/utils/config.js +41 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/createIntegrationFromFile.d.ts +22 -0
- package/dist/utils/createIntegrationFromFile.js +116 -0
- package/dist/utils/createIntegrationFromFile.js.map +1 -0
- package/dist/utils/determineNameAndKey.d.ts +4 -0
- package/dist/utils/determineNameAndKey.js +8 -0
- package/dist/utils/determineNameAndKey.js.map +1 -0
- package/dist/utils/dispatch.d.ts +3 -0
- package/dist/utils/dispatch.js +37 -0
- package/dist/utils/dispatch.js.map +1 -0
- package/dist/utils/fetchLocal.d.ts +3 -0
- package/dist/utils/fetchLocal.js +21 -0
- package/dist/utils/fetchLocal.js.map +1 -0
- package/dist/utils/fetchSession.d.ts +7 -0
- package/dist/utils/fetchSession.js +34 -0
- package/dist/utils/fetchSession.js.map +1 -0
- package/dist/utils/graphqlClient.d.ts +10 -0
- package/dist/utils/graphqlClient.js +24 -0
- package/dist/utils/graphqlClient.js.map +1 -0
- package/dist/utils/graphqlError.d.ts +2 -0
- package/dist/utils/graphqlError.js +20 -0
- package/dist/utils/graphqlError.js.map +1 -0
- package/dist/utils/hashContent.d.ts +1 -0
- package/dist/utils/hashContent.js +7 -0
- package/dist/utils/hashContent.js.map +1 -0
- package/dist/utils/jwt.d.ts +6 -0
- package/dist/utils/jwt.js +24 -0
- package/dist/utils/jwt.js.map +1 -0
- package/dist/utils/promptForValue.d.ts +9 -0
- package/dist/utils/promptForValue.js +24 -0
- package/dist/utils/promptForValue.js.map +1 -0
- package/dist/utils/resolveAccount.d.ts +19 -0
- package/dist/utils/resolveAccount.js +75 -0
- package/dist/utils/resolveAccount.js.map +1 -0
- package/dist/utils/resolveElement.d.ts +20 -0
- package/dist/utils/resolveElement.js +67 -0
- package/dist/utils/resolveElement.js.map +1 -0
- package/dist/utils/resolveIntegration.d.ts +9 -0
- package/dist/utils/resolveIntegration.js +71 -0
- package/dist/utils/resolveIntegration.js.map +1 -0
- package/dist/utils/saveIntegration.d.ts +16 -0
- package/dist/utils/saveIntegration.js +117 -0
- package/dist/utils/saveIntegration.js.map +1 -0
- package/dist/utils/token.d.ts +6 -0
- package/dist/utils/token.js +31 -0
- package/dist/utils/token.js.map +1 -0
- package/dist/utils/valueTypes.d.ts +4 -0
- package/dist/utils/valueTypes.js +43 -0
- package/dist/utils/valueTypes.js.map +1 -0
- package/dist/value/get.d.ts +8 -0
- package/dist/value/get.js +50 -0
- package/dist/value/get.js.map +1 -0
- package/dist/{projects → value}/index.d.ts +1 -2
- package/dist/value/index.js +26 -0
- package/dist/value/index.js.map +1 -0
- package/dist/value/list.d.ts +8 -0
- package/dist/value/list.js +122 -0
- package/dist/value/list.js.map +1 -0
- package/dist/value/set.d.ts +12 -0
- package/dist/value/set.js +103 -0
- package/dist/value/set.js.map +1 -0
- package/dist/whoami/fetchSession.d.ts +9 -0
- package/dist/whoami/fetchSession.js +19 -0
- package/dist/whoami/fetchSession.js.map +1 -0
- package/dist/whoami/index.d.ts +9 -1
- package/dist/whoami/index.js +18 -10
- package/dist/whoami/index.js.map +1 -1
- package/package.json +29 -13
- package/.codeclimate.yml +0 -7
- package/.editorconfig +0 -11
- package/.nvmrc +0 -1
- package/.prettierrc.json +0 -6
- package/dist/now/index.test.d.ts +0 -1
- package/dist/now/index.test.js +0 -18
- package/dist/now/index.test.js.map +0 -1
- package/dist/projects/describe.js +0 -44
- package/dist/projects/describe.js.map +0 -1
- package/dist/projects/index.js +0 -39
- package/dist/projects/index.js.map +0 -1
- package/dist/utils/callApi.d.ts +0 -5
- package/dist/utils/callApi.js +0 -20
- package/dist/utils/callApi.js.map +0 -1
- package/dist/utils/fetchLocalProject.d.ts +0 -1
- package/dist/utils/fetchLocalProject.js +0 -12
- package/dist/utils/fetchLocalProject.js.map +0 -1
- package/dist/utils/saveProject.d.ts +0 -2
- package/dist/utils/saveProject.js +0 -68
- package/dist/utils/saveProject.js.map +0 -1
- package/eslint.config.js +0 -27
- package/src/accounts/index.ts +0 -41
- package/src/index.ts +0 -22
- package/src/now/index.test.ts +0 -31
- package/src/now/index.ts +0 -15
- package/src/projects/describe.ts +0 -80
- package/src/projects/index.ts +0 -61
- package/src/pull/index.ts +0 -45
- package/src/run/index.ts +0 -81
- package/src/utils/callApi.ts +0 -29
- package/src/utils/fetchLocalProject.ts +0 -12
- package/src/utils/saveProject.ts +0 -106
- package/src/whoami/index.ts +0 -32
- package/tsconfig.json +0 -28
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import repl from 'node:repl';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { fetchIdFromFile } from '../utils/fetchLocal.js';
|
|
5
|
+
import { fetchSession } from '../utils/fetchSession.js';
|
|
6
|
+
import { resolveIntegration } from '../utils/resolveIntegration.js';
|
|
7
|
+
import { createDispatch } from './dispatch.js';
|
|
8
|
+
import { createHelp } from './help.js';
|
|
9
|
+
import { resolveAccountId } from '../utils/resolveAccount.js';
|
|
10
|
+
import { createGraphQLClient } from '../utils/graphqlClient.js';
|
|
11
|
+
import { getApiBaseUrl } from '../utils/config.js';
|
|
12
|
+
function validateReplArguments(integrationArg, accountId, log) {
|
|
13
|
+
const hasAccountFlag = !!accountId;
|
|
14
|
+
const hasIntegrationArg = !!integrationArg;
|
|
15
|
+
if (hasAccountFlag && !hasIntegrationArg) {
|
|
16
|
+
log(chalk.red('Account flag (-a) requires an integration key argument'));
|
|
17
|
+
log(`\nUsage: ${chalk.bold('great repl <integration-key> -a <account-id>')}`);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const identifier = integrationArg ?? fetchIdFromFile();
|
|
21
|
+
if (!identifier) {
|
|
22
|
+
log(chalk.red('No integration argument and no local integration project'));
|
|
23
|
+
log(`\nRun ${chalk.bold('great init')} to create a local integration project,`);
|
|
24
|
+
log(`or use ${chalk.bold('great repl <integration-id>')}`);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function printSessionInformation(log, userName, integrationId, integrationName) {
|
|
30
|
+
if (userName) {
|
|
31
|
+
log(chalk.cyan(`Ohai, ${userName}!`));
|
|
32
|
+
}
|
|
33
|
+
if (integrationName) {
|
|
34
|
+
log(chalk.white(`Working with integration ${chalk.yellow.bold(integrationName)} ${chalk.dim(`(${integrationId})`)}.`));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
log(chalk.white(`Working with integration ${chalk.bold(integrationId)}.`));
|
|
38
|
+
}
|
|
39
|
+
log(`Type ${chalk.bold('help()')} to see what you can do.`);
|
|
40
|
+
}
|
|
41
|
+
export const action = (log, apiToken, client, config) => async function startRepl(integrationKeyOrId, options) {
|
|
42
|
+
const identifier = integrationKeyOrId ?? fetchIdFromFile();
|
|
43
|
+
const isValid = validateReplArguments(identifier, options?.account, log);
|
|
44
|
+
if (!isValid) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!apiToken) {
|
|
48
|
+
log(chalk.red('Not logged in. Run `great login`'));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const apiBaseUrl = getApiBaseUrl(config);
|
|
52
|
+
const graphqlClient = client ?? createGraphQLClient(apiToken, apiBaseUrl);
|
|
53
|
+
const { accountId, error } = await resolveAccountId(options ?? {}, apiToken, graphqlClient, config);
|
|
54
|
+
if (error) {
|
|
55
|
+
log(chalk.red(error));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const integrationResult = await resolveIntegration(identifier, accountId, apiToken, client);
|
|
59
|
+
if (integrationResult.error) {
|
|
60
|
+
log(chalk.red(integrationResult.error));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!integrationResult.id) {
|
|
64
|
+
log(chalk.red('Failed to resolve integration'));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const sessionResult = await fetchSession(apiToken, client);
|
|
68
|
+
if (sessionResult.error) {
|
|
69
|
+
log(chalk.red(sessionResult.error));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
printSessionInformation(log, sessionResult.userName, integrationResult.id, integrationResult.name);
|
|
73
|
+
const prompt = chalk.cyan(os.platform() === 'win32' ? 'i> ' : '𝒊> ');
|
|
74
|
+
const replServer = repl.start({
|
|
75
|
+
prompt,
|
|
76
|
+
ignoreUndefined: true,
|
|
77
|
+
});
|
|
78
|
+
replServer.context.$ = undefined;
|
|
79
|
+
replServer.context.$$ = undefined;
|
|
80
|
+
replServer.context.dispatch = createDispatch(integrationResult.id, log, apiToken, client, replServer.context);
|
|
81
|
+
replServer.context.help = createHelp(log);
|
|
82
|
+
await new Promise((resolve) => {
|
|
83
|
+
replServer.on('exit', () => resolve());
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export default (program, apiToken) => program
|
|
87
|
+
.command('repl')
|
|
88
|
+
.description('start a Node.js REPL session')
|
|
89
|
+
.argument('[integration]', 'id or key of the integration to run repl for, will override any id in the local index file')
|
|
90
|
+
.option('-a, --account <id>', 'account id or key (required with integration key, or set default)')
|
|
91
|
+
.action(action(console.log, apiToken));
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repl/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAItC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA;AAErE,SAAS,qBAAqB,CAC5B,cAAkC,EAClC,SAA6B,EAC7B,GAAW;IAEX,MAAM,cAAc,GAAG,CAAC,CAAC,SAAS,CAAA;IAClC,MAAM,iBAAiB,GAAG,CAAC,CAAC,cAAc,CAAA;IAG1C,IAAI,cAAc,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC,CAAA;QACxE,GAAG,CACD,YAAY,KAAK,CAAC,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AC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA"}
|
package/dist/run/index.d.ts
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { type Spinner } from 'nanospinner';
|
|
3
|
+
import Conf from 'conf';
|
|
4
|
+
import { type GraphQLRequestClient } from '../utils/graphqlClient.js';
|
|
5
|
+
import { type ConfigSchema } from '../utils/config.js';
|
|
1
6
|
import type { Command } from 'commander';
|
|
2
|
-
export declare const action: (log: (message: string) => void, apiToken?: string
|
|
7
|
+
export declare const action: (log: (message: string) => void, apiToken?: string, client?: GraphQLRequestClient, fsImpl?: typeof fs, config?: Conf<ConfigSchema>, selectFn?: <Value>(config: {
|
|
8
|
+
message: string;
|
|
9
|
+
choices: readonly (import("@inquirer/prompts").Separator | Value | {
|
|
10
|
+
value: Value;
|
|
11
|
+
name?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
short?: string;
|
|
14
|
+
disabled?: boolean | string;
|
|
15
|
+
type?: never;
|
|
16
|
+
})[];
|
|
17
|
+
pageSize?: number | undefined;
|
|
18
|
+
loop?: boolean | undefined;
|
|
19
|
+
default?: NoInfer<Value> | undefined;
|
|
20
|
+
theme?: import("@inquirer/type/dist/utils.js").PartialDeep<import("@inquirer/core/dist/index.js").Theme<{
|
|
21
|
+
icon: {
|
|
22
|
+
cursor: string;
|
|
23
|
+
};
|
|
24
|
+
style: {
|
|
25
|
+
disabled: (text: string) => string;
|
|
26
|
+
description: (text: string) => string;
|
|
27
|
+
keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
|
|
28
|
+
};
|
|
29
|
+
indexMode: "hidden" | "number";
|
|
30
|
+
keybindings: ReadonlyArray<import("@inquirer/core/dist/index.js").Keybinding>;
|
|
31
|
+
}>> | undefined;
|
|
32
|
+
}, context?: import("@inquirer/type/dist/inquirer.js").Context) => Promise<Value>, createSpinnerFn?: () => Spinner) => (integrationIdOrKey?: string, options?: {
|
|
33
|
+
account?: string;
|
|
34
|
+
}) => Promise<void>;
|
|
3
35
|
declare const _default: (program: Command, apiToken?: string) => Command;
|
|
4
36
|
export default _default;
|
package/dist/run/index.js
CHANGED
|
@@ -1,55 +1,124 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
3
|
-
import { setTimeout } from 'timers/promises';
|
|
3
|
+
import { createSpinner } from 'nanospinner';
|
|
4
4
|
import { select } from '@inquirer/prompts';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import { gql } from 'graphql-tag';
|
|
6
|
+
import { fetchIntegrationFromFile } from '../utils/fetchLocal.js';
|
|
7
|
+
import { resolveIntegration } from '../utils/resolveIntegration.js';
|
|
8
|
+
import { createGraphQLClient, } from '../utils/graphqlClient.js';
|
|
9
|
+
import { handleGraphQLError } from '../utils/graphqlError.js';
|
|
10
|
+
import { resolveAccountId } from '../utils/resolveAccount.js';
|
|
11
|
+
import { getApiBaseUrl } from '../utils/config.js';
|
|
12
|
+
import { dispatchAction } from '../utils/dispatch.js';
|
|
13
|
+
const IntegrationElementsQueryDocument = gql `
|
|
14
|
+
query IntegrationElements($id: ID!) {
|
|
15
|
+
integration(id: $id) {
|
|
16
|
+
active {
|
|
17
|
+
elements(type: [job, flow]) {
|
|
18
|
+
__typename
|
|
19
|
+
id
|
|
20
|
+
key
|
|
21
|
+
name
|
|
22
|
+
description
|
|
23
|
+
... on Job {
|
|
24
|
+
sort
|
|
25
|
+
isSubJob
|
|
26
|
+
}
|
|
27
|
+
... on Flow {
|
|
28
|
+
sort
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const SUCCESS_STATUSES = ['ok', 'noaction', 'queued'];
|
|
36
|
+
export const action = (log, apiToken, client, fsImpl = fs, config, selectFn = select, createSpinnerFn = createSpinner) => async function run(integrationIdOrKey, options) {
|
|
37
|
+
let identifier = integrationIdOrKey;
|
|
38
|
+
if (!identifier) {
|
|
39
|
+
const localIntegration = fetchIntegrationFromFile(fsImpl);
|
|
40
|
+
if (!localIntegration) {
|
|
41
|
+
log(`You are not in an integration folder. Provide an integration id as an argument or see ${chalk.bold('great run --help')}.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
identifier = localIntegration.__id;
|
|
45
|
+
if (!identifier) {
|
|
46
|
+
log(chalk.red(`Integration has not been pushed yet. Run ${chalk.bold('great push')} first.`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const apiBaseUrl = getApiBaseUrl(config);
|
|
51
|
+
const graphqlClient = client ?? createGraphQLClient(apiToken, apiBaseUrl);
|
|
52
|
+
const { accountId, error: accountError } = await resolveAccountId(options ?? {}, apiToken ?? '', graphqlClient, config);
|
|
53
|
+
if (accountError) {
|
|
54
|
+
log(chalk.red(accountError));
|
|
11
55
|
return;
|
|
12
56
|
}
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
log(chalk.red(response.error));
|
|
57
|
+
const integration = await resolveIntegration(identifier, accountId, apiToken, client);
|
|
58
|
+
if (integration.error) {
|
|
59
|
+
handleGraphQLError(new Error(integration.error), log);
|
|
17
60
|
return;
|
|
18
61
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
const integrationId = integration.id;
|
|
63
|
+
const result = await graphqlClient.request(IntegrationElementsQueryDocument, { id: integrationId });
|
|
64
|
+
if (result.error) {
|
|
65
|
+
handleGraphQLError(result.error, log);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const active = result.data?.integration?.active;
|
|
69
|
+
if (!active) {
|
|
70
|
+
log(`No active version. Deploy with ${chalk.bold('great deploy')} first.`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const elements = active.elements;
|
|
74
|
+
const runnableElements = elements
|
|
75
|
+
.filter((el) => el.__typename !== 'Job' || !el.isSubJob)
|
|
76
|
+
.sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0));
|
|
77
|
+
if (runnableElements.length === 0) {
|
|
78
|
+
log(chalk.white('No runnable jobs or flows for this integration.'));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let selectedId;
|
|
82
|
+
try {
|
|
83
|
+
selectedId = await selectFn({
|
|
84
|
+
message: 'Select a job or flow to run',
|
|
85
|
+
choices: runnableElements.map((el) => ({
|
|
86
|
+
name: `${el.name} (${el.__typename.toLowerCase()})`,
|
|
87
|
+
value: el.id,
|
|
88
|
+
description: el.description ?? undefined,
|
|
89
|
+
})),
|
|
90
|
+
pageSize: 20,
|
|
91
|
+
loop: false,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const selectedElement = runnableElements.find((el) => el.id === selectedId);
|
|
98
|
+
if (!selectedElement)
|
|
99
|
+
return;
|
|
100
|
+
const payload = selectedElement.__typename === 'Job'
|
|
101
|
+
? { jobId: selectedElement.key }
|
|
102
|
+
: { flowId: selectedElement.key };
|
|
103
|
+
const spinner = createSpinnerFn().start();
|
|
104
|
+
try {
|
|
105
|
+
const response = await dispatchAction(integrationId, 'RUN', payload, apiToken, client);
|
|
106
|
+
if (SUCCESS_STATUSES.includes(response.status)) {
|
|
107
|
+
spinner.success(chalk.green(`${selectedElement.name} completed successfully.`));
|
|
38
108
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
await setTimeout(1000);
|
|
42
|
-
spinner.stop();
|
|
43
|
-
log('Job would have run if we had implemented the run command ...');
|
|
109
|
+
else {
|
|
110
|
+
spinner.error(chalk.red(response.error || response.warning || 'Run failed.'));
|
|
44
111
|
}
|
|
45
112
|
}
|
|
46
|
-
|
|
47
|
-
|
|
113
|
+
catch (error) {
|
|
114
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
115
|
+
spinner.error(chalk.red(`Could not run: ${errorMessage}`));
|
|
48
116
|
}
|
|
49
117
|
};
|
|
50
118
|
export default (program, apiToken) => program
|
|
51
119
|
.command('run')
|
|
52
|
-
.description('run a job in the current
|
|
53
|
-
.argument('[
|
|
120
|
+
.description('run a job or flow in the current integration or the integration with the provided id')
|
|
121
|
+
.argument('[integration]', 'id or key of the integration to run jobs/flows for')
|
|
122
|
+
.option('-a, --account <id>', 'account id or key (uses default from config if not provided)')
|
|
54
123
|
.action(action(console.log, apiToken));
|
|
55
124
|
//# sourceMappingURL=index.js.map
|
package/dist/run/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/run/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/run/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EACL,mBAAmB,GAEpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,kBAAkB,EAAE,MA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K,EACL,OAAO,EACP,QAAQ,EACR,MAAM,CACP,CAAA;QAED,IAAI,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/C,OAAO,CAAC,OAAO,CACb,KAAK,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,IAAI,0BAA0B,CAAC,CAC/D,CAAA;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,aAAa,CAAC,CAC/D,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACxD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,YAAY,EAAE,CAAC,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC,CAAA;AAEH,eAAe,CAAC,OAAgB,EAAE,QAAiB,EAAE,EAAE,CACrD,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CACV,sFAAsF,CACvF;KACA,QAAQ,CACP,eAAe,EACf,oDAAoD,CACrD;KACA,MAAM,CACL,oBAAoB,EACpB,8DAA8D,CAC/D;KACA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import Conf from 'conf';
|
|
3
|
+
import { type GraphQLRequestClient } from '../utils/graphqlClient.js';
|
|
4
|
+
import { type ConfigSchema } from '../utils/config.js';
|
|
5
|
+
import type { Command } from 'commander';
|
|
6
|
+
export declare const action: (log: (message: string) => void, apiToken?: string, client?: GraphQLRequestClient, fsImpl?: typeof fs, config?: Conf<ConfigSchema>) => (integrationIdOrKey?: string, options?: {
|
|
7
|
+
account?: string;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
declare const _default: (program: Command, apiToken?: string) => Command;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { sentenceCase } from 'change-case';
|
|
4
|
+
import { fetchIntegrationFromFile } from '../utils/fetchLocal.js';
|
|
5
|
+
import { resolveIntegration } from '../utils/resolveIntegration.js';
|
|
6
|
+
import { createGraphQLClient, } from '../utils/graphqlClient.js';
|
|
7
|
+
import { handleGraphQLError } from '../utils/graphqlError.js';
|
|
8
|
+
import { resolveAccountId } from '../utils/resolveAccount.js';
|
|
9
|
+
import { getApiBaseUrl } from '../utils/config.js';
|
|
10
|
+
import { gql } from 'graphql-tag';
|
|
11
|
+
const IntegrationStatusQueryDocument = gql `
|
|
12
|
+
query IntegrationStatus($id: ID!) {
|
|
13
|
+
integration(id: $id) {
|
|
14
|
+
id
|
|
15
|
+
key
|
|
16
|
+
name
|
|
17
|
+
status
|
|
18
|
+
active {
|
|
19
|
+
id
|
|
20
|
+
name
|
|
21
|
+
timestamp
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
async function resolveIntegrationForStatus(identifier, accountId, apiToken, client, log) {
|
|
27
|
+
const result = await resolveIntegration(identifier, accountId, apiToken, client);
|
|
28
|
+
if (result.error) {
|
|
29
|
+
handleGraphQLError(new Error(result.error), log);
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (!result.id) {
|
|
33
|
+
log(chalk.red('Failed to resolve integration'));
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
integrationId: result.id,
|
|
38
|
+
integrationName: result.name,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function fetchIntegrationStatus(graphqlClient, integrationId, log) {
|
|
42
|
+
const result = await graphqlClient.request(IntegrationStatusQueryDocument, { id: integrationId });
|
|
43
|
+
if (result.error) {
|
|
44
|
+
handleGraphQLError(result.error, log);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const integration = result.data?.integration;
|
|
48
|
+
if (!integration) {
|
|
49
|
+
log(chalk.red('Integration not found'));
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return integration;
|
|
53
|
+
}
|
|
54
|
+
function displayStatus(integration, version, status, log) {
|
|
55
|
+
const isLocal = status === 'local';
|
|
56
|
+
const idDisplay = isLocal ? '(local)' : integration.id;
|
|
57
|
+
log(`Integration: ${chalk.cyan(integration.name || '<No name>')} ${chalk.gray(idDisplay)}`);
|
|
58
|
+
if (integration.key) {
|
|
59
|
+
log(`Key: ${integration.key}`);
|
|
60
|
+
}
|
|
61
|
+
if (!version) {
|
|
62
|
+
log(`Version: ${chalk.dim('none')}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (version.name) {
|
|
66
|
+
log(`Version: ${version.name} (${version.timestamp}) ${chalk.gray(version.id)}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
log(`Version: ${version.timestamp} ${chalk.gray(version.id)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const statusColor = status === 'active' ? chalk.green : chalk.yellow;
|
|
73
|
+
const statusText = isLocal ? 'Not pushed (local only)' : sentenceCase(status);
|
|
74
|
+
log(`Status: ${statusColor(statusText)}`);
|
|
75
|
+
if (isLocal) {
|
|
76
|
+
log('');
|
|
77
|
+
log(`Run ${chalk.bold('great push')} to create this integration on the server.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export const action = (log, apiToken, client, fsImpl = fs, config) => async function status(integrationIdOrKey, options) {
|
|
81
|
+
let identifier = integrationIdOrKey;
|
|
82
|
+
if (!identifier) {
|
|
83
|
+
const localIntegration = fetchIntegrationFromFile(fsImpl);
|
|
84
|
+
if (!localIntegration) {
|
|
85
|
+
log(`You are not in an integration folder. Provide an integration id as an argument or see ${chalk.bold('great status --help')}.`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
identifier = localIntegration.__id;
|
|
89
|
+
if (!identifier) {
|
|
90
|
+
displayStatus({
|
|
91
|
+
name: localIntegration.name,
|
|
92
|
+
key: localIntegration.__key,
|
|
93
|
+
}, undefined, 'local', log);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const apiBaseUrl = getApiBaseUrl(config);
|
|
98
|
+
const graphqlClient = client ?? createGraphQLClient(apiToken, apiBaseUrl);
|
|
99
|
+
const { accountId, error } = await resolveAccountId(options ?? {}, apiToken ?? '', graphqlClient, config);
|
|
100
|
+
if (error) {
|
|
101
|
+
log(chalk.red(error));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const integration = await resolveIntegrationForStatus(identifier, accountId, apiToken, client, log);
|
|
105
|
+
if (!integration)
|
|
106
|
+
return;
|
|
107
|
+
const statusData = await fetchIntegrationStatus(graphqlClient, integration.integrationId, log);
|
|
108
|
+
if (!statusData)
|
|
109
|
+
return;
|
|
110
|
+
displayStatus({
|
|
111
|
+
id: statusData.id,
|
|
112
|
+
name: integration.integrationName || statusData.name,
|
|
113
|
+
key: statusData.key,
|
|
114
|
+
}, statusData.active, statusData.status, log);
|
|
115
|
+
};
|
|
116
|
+
export default (program, apiToken) => program
|
|
117
|
+
.command('status')
|
|
118
|
+
.description('show integration status')
|
|
119
|
+
.argument('[integration]', 'integration id or key')
|
|
120
|
+
.option('-a, --account <id>', 'account id or key (uses default from config if not provided)')
|
|
121
|
+
.action(action(console.log, apiToken));
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/status/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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uB,CAAC;KAClD,MAAM,CACL,oBAAoB,EACpB,8DAA8D,CAC/D;KACA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Logger = (message: string) => void;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { URL } from 'node:url';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
export async function startAuthFlow(authUrl, appBaseUrl) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const server = http.createServer((req, res) => {
|
|
7
|
+
const url = new URL(req.url || '/', `http://localhost`);
|
|
8
|
+
if (url.pathname === '/callback') {
|
|
9
|
+
const token = url.searchParams.get('token');
|
|
10
|
+
res.writeHead(302, {
|
|
11
|
+
Location: `${appBaseUrl}/signin/success`,
|
|
12
|
+
Connection: 'close',
|
|
13
|
+
});
|
|
14
|
+
res.end();
|
|
15
|
+
req.socket.destroy();
|
|
16
|
+
server.close();
|
|
17
|
+
if (token) {
|
|
18
|
+
resolve({ token });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
reject(new Error('No token received from authentication'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
server.listen(0, async () => {
|
|
26
|
+
const port = server.address().port;
|
|
27
|
+
const callbackUrl = `http://localhost:${port}/callback`;
|
|
28
|
+
const finalAuthUrl = authUrl.replace('{callback}', encodeURIComponent(callbackUrl));
|
|
29
|
+
try {
|
|
30
|
+
await open(finalAuthUrl);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
console.log(`\nPlease open this URL in your browser:\n${finalAuthUrl}\n`);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const timeout = setTimeout(() => {
|
|
37
|
+
server.close();
|
|
38
|
+
reject(new Error('Authentication timeout (2 minutes). Please try again.'));
|
|
39
|
+
}, 120000);
|
|
40
|
+
server.on('close', () => {
|
|
41
|
+
clearTimeout(timeout);
|
|
42
|
+
});
|
|
43
|
+
server.on('error', (error) => {
|
|
44
|
+
clearTimeout(timeout);
|
|
45
|
+
reject(error);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=authServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authServer.js","sourceRoot":"","sources":["../../src/utils/authServer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AAMvB,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,UAAkB;IAElB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,kBAAkB,CAAC,CAAA;YAEvD,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBACjC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;gBAG3C,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;oBACjB,QAAQ,EAAE,GAAG,UAAU,iBAAiB;oBACxC,UAAU,EAAE,OAAO;iBACpB,CAAC,CAAA;gBACF,GAAG,CAAC,GAAG,EAAE,CAAA;gBAGT,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA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0,0 +1,15 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
export interface ConfigSchema {
|
|
3
|
+
token?: string;
|
|
4
|
+
expiresAt?: number;
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
appUrl?: string;
|
|
7
|
+
account?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function getConfig(): Conf<ConfigSchema>;
|
|
10
|
+
export declare function getConfigValue<K extends keyof ConfigSchema>(key: K, config?: Conf<ConfigSchema>): ConfigSchema[K] | undefined;
|
|
11
|
+
export declare function setConfigValue<K extends keyof ConfigSchema>(key: K, value: ConfigSchema[K], config?: Conf<ConfigSchema>): void;
|
|
12
|
+
export declare function deleteConfigValue<K extends keyof ConfigSchema>(key: K, config?: Conf<ConfigSchema>): void;
|
|
13
|
+
export declare function getApiBaseUrl(config?: Conf<ConfigSchema>): string;
|
|
14
|
+
export declare function getAppBaseUrl(config?: Conf<ConfigSchema>): string;
|
|
15
|
+
export declare function getAllConfig(config?: Conf<ConfigSchema>): ConfigSchema;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
let configInstance;
|
|
3
|
+
export function getConfig() {
|
|
4
|
+
if (!configInstance) {
|
|
5
|
+
configInstance = new Conf({
|
|
6
|
+
projectName: 'great',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return configInstance;
|
|
10
|
+
}
|
|
11
|
+
export function getConfigValue(key, config) {
|
|
12
|
+
const conf = config ?? getConfig();
|
|
13
|
+
return conf.get(key);
|
|
14
|
+
}
|
|
15
|
+
export function setConfigValue(key, value, config) {
|
|
16
|
+
const conf = config ?? getConfig();
|
|
17
|
+
conf.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
export function deleteConfigValue(key, config) {
|
|
20
|
+
const conf = config ?? getConfig();
|
|
21
|
+
conf.delete(key);
|
|
22
|
+
}
|
|
23
|
+
export function getApiBaseUrl(config) {
|
|
24
|
+
const configUrl = getConfigValue('apiUrl', config);
|
|
25
|
+
return (configUrl || process.env.INTEGREAT_API_URL || 'https://api.integreat.io');
|
|
26
|
+
}
|
|
27
|
+
export function getAppBaseUrl(config) {
|
|
28
|
+
const configUrl = getConfigValue('appUrl', config);
|
|
29
|
+
return (configUrl || process.env.INTEGREAT_APP_URL || 'https://app.integreat.io');
|
|
30
|
+
}
|
|
31
|
+
export function getAllConfig(config) {
|
|
32
|
+
const conf = config ?? getConfig();
|
|
33
|
+
return {
|
|
34
|
+
token: conf.get('token'),
|
|
35
|
+
expiresAt: conf.get('expiresAt'),
|
|
36
|
+
apiUrl: conf.get('apiUrl'),
|
|
37
|
+
appUrl: conf.get('appUrl'),
|
|
38
|
+
account: conf.get('account'),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAmBvB,IAAI,cAA8C,CAAA;AAQlD,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,IAAI,CAAe;YACtC,WAAW,EAAE,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AAOD,MAAM,UAAU,cAAc,CAC5B,GAAM,EACN,MAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,IAAI,SAAS,EAAE,CAAA;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,GAAM,EACN,KAAsB,EACtB,MAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,IAAI,SAAS,EAAE,CAAA;IAClC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,GAAM,EACN,MAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,IAAI,SAAS,EAAE,CAAA;IAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC;AAWD,MAAM,UAAU,aAAa,CAAC,MAA2B;IACvD,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAClD,OAAO,CACL,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,0BAA0B,CACzE,CAAA;AACH,CAAC;AAWD,MAAM,UAAU,aAAa,CAAC,MAA2B;IACvD,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAClD,OAAO,CACL,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,0BAA0B,CACzE,CAAA;AACH,CAAC;AAQD,MAAM,UAAU,YAAY,CAAC,MAA2B;IACtD,MAAM,IAAI,GAAG,MAAM,IAAI,SAAS,EAAE,CAAA;IAClC,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QACxB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;QAChC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC1B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;KAC7B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import Conf from 'conf';
|
|
3
|
+
import type { GraphQLRequestClient } from './graphqlClient.js';
|
|
4
|
+
import type { ConfigSchema } from './config.js';
|
|
5
|
+
export interface CreateIntegrationResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
integration?: {
|
|
9
|
+
id: string;
|
|
10
|
+
key: string;
|
|
11
|
+
name: string;
|
|
12
|
+
status: string;
|
|
13
|
+
account: {
|
|
14
|
+
id: string;
|
|
15
|
+
key: string;
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default function createIntegrationFromFile(graphqlClient: GraphQLRequestClient, apiToken: string, options: {
|
|
21
|
+
account?: string;
|
|
22
|
+
}, config?: Conf<ConfigSchema>, fsImpl?: typeof fs): Promise<CreateIntegrationResult>;
|