great 1.0.2 → 1.2.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/README.md +141 -43
- package/dist/accounts/create.d.ts +1 -1
- package/dist/accounts/create.js +2 -4
- package/dist/accounts/create.js.map +1 -1
- package/dist/accounts/index.d.ts +1 -1
- package/dist/accounts/index.js +2 -4
- package/dist/accounts/index.js.map +1 -1
- package/dist/clone/index.d.ts +4 -2
- package/dist/clone/index.js +19 -43
- package/dist/clone/index.js.map +1 -1
- package/dist/config/index.js +4 -30
- package/dist/config/index.js.map +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.js +55 -15
- package/dist/deploy/index.js.map +1 -1
- package/dist/env/index.d.ts +12 -0
- package/dist/env/index.js +131 -0
- package/dist/env/index.js.map +1 -0
- package/dist/explode/transform.d.ts +1 -1
- package/dist/explode/transform.js +6 -2
- package/dist/explode/transform.js.map +1 -1
- package/dist/explode/unescapeMongo.js +9 -1
- package/dist/explode/unescapeMongo.js.map +1 -1
- package/dist/generated/operations.d.ts +617 -0
- package/dist/generated/operations.js +2 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/generated/schema.d.ts +965 -0
- package/dist/generated/{graphql.js → schema.js} +20 -2
- package/dist/generated/schema.js.map +1 -0
- package/dist/implode/escapeMongo.d.ts +1 -0
- package/dist/implode/escapeMongo.js +23 -0
- package/dist/implode/escapeMongo.js.map +1 -0
- package/dist/implode/index.d.ts +6 -0
- package/dist/implode/index.js +132 -0
- package/dist/implode/index.js.map +1 -0
- package/dist/implode/transform.d.ts +45 -0
- package/dist/implode/transform.js +73 -0
- package/dist/implode/transform.js.map +1 -0
- package/dist/import/index.d.ts +8 -0
- package/dist/import/index.js +43 -0
- package/dist/import/index.js.map +1 -0
- package/dist/include/index.d.ts +10 -0
- package/dist/include/index.js +41 -0
- package/dist/include/index.js.map +1 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/init/index.js +8 -16
- package/dist/init/index.js.map +1 -1
- package/dist/integrations/create.d.ts +1 -1
- package/dist/integrations/create.js +3 -5
- package/dist/integrations/create.js.map +1 -1
- package/dist/integrations/list.d.ts +1 -1
- package/dist/integrations/list.js +3 -5
- package/dist/integrations/list.js.map +1 -1
- package/dist/migrate/index.d.ts +5 -0
- package/dist/migrate/index.js +101 -0
- package/dist/migrate/index.js.map +1 -0
- package/dist/pull/index.d.ts +4 -2
- package/dist/pull/index.js +25 -44
- package/dist/pull/index.js.map +1 -1
- package/dist/push/index.d.ts +1 -1
- package/dist/push/index.js +364 -93
- package/dist/push/index.js.map +1 -1
- package/dist/rename/index.d.ts +8 -0
- package/dist/rename/index.js +109 -0
- package/dist/rename/index.js.map +1 -0
- package/dist/repl/dispatch.d.ts +8 -2
- package/dist/repl/dispatch.js +43 -29
- package/dist/repl/dispatch.js.map +1 -1
- package/dist/repl/dispatchAndLoad.d.ts +7 -0
- package/dist/repl/dispatchAndLoad.js +35 -0
- package/dist/repl/dispatchAndLoad.js.map +1 -0
- package/dist/repl/help.js +13 -2
- package/dist/repl/help.js.map +1 -1
- package/dist/repl/index.d.ts +1 -1
- package/dist/repl/index.js +31 -10
- package/dist/repl/index.js.map +1 -1
- package/dist/repl/load.d.ts +8 -0
- package/dist/repl/load.js +53 -0
- package/dist/repl/load.js.map +1 -0
- package/dist/run/index.d.ts +7 -5
- package/dist/run/index.js +5 -7
- package/dist/run/index.js.map +1 -1
- package/dist/status/index.d.ts +1 -1
- package/dist/status/index.js +6 -8
- package/dist/status/index.js.map +1 -1
- package/dist/utils/config.d.ts +9 -2
- package/dist/utils/config.js +39 -6
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/createIntegrationFromFile.d.ts +3 -1
- package/dist/utils/createIntegrationFromFile.js +14 -30
- package/dist/utils/createIntegrationFromFile.js.map +1 -1
- package/dist/utils/detectPullConflicts.d.ts +8 -0
- package/dist/utils/detectPullConflicts.js +65 -0
- package/dist/utils/detectPullConflicts.js.map +1 -0
- package/dist/utils/dispatch.d.ts +2 -2
- package/dist/utils/dispatch.js +5 -4
- package/dist/utils/dispatch.js.map +1 -1
- package/dist/utils/elementFiles.d.ts +13 -0
- package/dist/utils/elementFiles.js +76 -0
- package/dist/utils/elementFiles.js.map +1 -0
- package/dist/utils/fetchIntegrationDefinition.d.ts +8 -0
- package/dist/utils/fetchIntegrationDefinition.js +58 -0
- package/dist/utils/fetchIntegrationDefinition.js.map +1 -0
- package/dist/utils/fetchLocal.d.ts +3 -1
- package/dist/utils/fetchLocal.js +11 -9
- package/dist/utils/fetchLocal.js.map +1 -1
- package/dist/utils/fetchSession.d.ts +1 -1
- package/dist/utils/fetchSession.js +2 -1
- package/dist/utils/fetchSession.js.map +1 -1
- package/dist/utils/graphqlClient.d.ts +3 -0
- package/dist/utils/graphqlClient.js +3 -0
- package/dist/utils/graphqlClient.js.map +1 -1
- package/dist/utils/graphqlError.d.ts +2 -1
- package/dist/utils/graphqlError.js +17 -3
- package/dist/utils/graphqlError.js.map +1 -1
- package/dist/utils/greatFile.d.ts +40 -0
- package/dist/utils/greatFile.js +66 -0
- package/dist/utils/greatFile.js.map +1 -0
- package/dist/utils/hashContent.js +1 -1
- package/dist/utils/hashContent.js.map +1 -1
- package/dist/utils/integrationType.d.ts +3 -0
- package/dist/utils/integrationType.js +15 -0
- package/dist/utils/integrationType.js.map +1 -0
- package/dist/utils/parseJson.d.ts +1 -0
- package/dist/utils/parseJson.js +5 -0
- package/dist/utils/parseJson.js.map +1 -0
- package/dist/utils/resolveAccount.d.ts +5 -4
- package/dist/utils/resolveAccount.js +17 -9
- package/dist/utils/resolveAccount.js.map +1 -1
- package/dist/utils/resolveElement.d.ts +1 -1
- package/dist/utils/resolveElementInclude.d.ts +3 -0
- package/dist/utils/resolveElementInclude.js +28 -0
- package/dist/utils/resolveElementInclude.js.map +1 -0
- package/dist/utils/resolveIntegration.d.ts +4 -2
- package/dist/utils/resolveIntegration.js +7 -3
- package/dist/utils/resolveIntegration.js.map +1 -1
- package/dist/utils/resolveTemplateImport.d.ts +3 -0
- package/dist/utils/resolveTemplateImport.js +31 -0
- package/dist/utils/resolveTemplateImport.js.map +1 -0
- package/dist/utils/response.d.ts +3 -0
- package/dist/utils/response.js +24 -0
- package/dist/utils/response.js.map +1 -0
- package/dist/utils/saveIntegration.d.ts +8 -4
- package/dist/utils/saveIntegration.js +76 -34
- package/dist/utils/saveIntegration.js.map +1 -1
- package/dist/utils/token.js +1 -1
- package/dist/utils/token.js.map +1 -1
- package/dist/utils/url.d.ts +1 -0
- package/dist/utils/url.js +10 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/writeShadowElement.d.ts +26 -0
- package/dist/utils/writeShadowElement.js +119 -0
- package/dist/utils/writeShadowElement.js.map +1 -0
- package/dist/{value → values}/get.d.ts +1 -1
- package/dist/{value → values}/get.js +7 -8
- package/dist/values/get.js.map +1 -0
- package/dist/{value → values}/index.js +13 -1
- package/dist/values/index.js.map +1 -0
- package/dist/{value → values}/list.js +10 -9
- package/dist/values/list.js.map +1 -0
- package/dist/{value → values}/set.d.ts +1 -1
- package/dist/{value → values}/set.js +9 -9
- package/dist/values/set.js.map +1 -0
- package/dist/values/unset.d.ts +8 -0
- package/dist/values/unset.js +61 -0
- package/dist/values/unset.js.map +1 -0
- package/dist/whoami/fetchSession.d.ts +3 -3
- package/dist/whoami/fetchSession.js +2 -4
- package/dist/whoami/fetchSession.js.map +1 -1
- package/dist/whoami/index.d.ts +1 -1
- package/package.json +20 -19
- package/dist/generated/graphql.d.ts +0 -1784
- package/dist/generated/graphql.js.map +0 -1
- package/dist/value/get.js.map +0 -1
- package/dist/value/index.js.map +0 -1
- package/dist/value/list.js.map +0 -1
- package/dist/value/set.js.map +0 -1
- /package/dist/{value → values}/index.d.ts +0 -0
- /package/dist/{value → values}/list.d.ts +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import parseJson from './parseJson.js';
|
|
3
|
+
import { ElementType } from '../generated/schema.js';
|
|
4
|
+
export const elementTypeToFolder = {
|
|
5
|
+
[ElementType.Schema]: 'schemas',
|
|
6
|
+
[ElementType.Service]: 'services',
|
|
7
|
+
[ElementType.Auth]: 'auths',
|
|
8
|
+
[ElementType.Mutation]: 'mutations',
|
|
9
|
+
[ElementType.Dictionary]: 'dictionaries',
|
|
10
|
+
[ElementType.Job]: 'jobs',
|
|
11
|
+
[ElementType.Value]: 'values',
|
|
12
|
+
[ElementType.Flow]: 'flows',
|
|
13
|
+
[ElementType.RetryRule]: 'retryRules',
|
|
14
|
+
[ElementType.Config]: undefined,
|
|
15
|
+
};
|
|
16
|
+
export const folderToElementType = {
|
|
17
|
+
schemas: ElementType.Schema,
|
|
18
|
+
services: ElementType.Service,
|
|
19
|
+
auths: ElementType.Auth,
|
|
20
|
+
mutations: ElementType.Mutation,
|
|
21
|
+
dictionaries: ElementType.Dictionary,
|
|
22
|
+
jobs: ElementType.Job,
|
|
23
|
+
values: ElementType.Value,
|
|
24
|
+
flows: ElementType.Flow,
|
|
25
|
+
retryRules: ElementType.RetryRule,
|
|
26
|
+
};
|
|
27
|
+
export const ELEMENT_FOLDERS = [
|
|
28
|
+
'schemas',
|
|
29
|
+
'services',
|
|
30
|
+
'auths',
|
|
31
|
+
'mutations',
|
|
32
|
+
'dictionaries',
|
|
33
|
+
'jobs',
|
|
34
|
+
'values',
|
|
35
|
+
'flows',
|
|
36
|
+
'retryRules',
|
|
37
|
+
];
|
|
38
|
+
export const JSON_EXTENSIONS = ['.jsonc', '.json'];
|
|
39
|
+
export function elementKeyFromFileName(fileName) {
|
|
40
|
+
const ext = JSON_EXTENSIONS.find((e) => fileName.endsWith(e));
|
|
41
|
+
return ext ? fileName.slice(0, -ext.length) : undefined;
|
|
42
|
+
}
|
|
43
|
+
export function readElementFolder(folder, root, fsImpl) {
|
|
44
|
+
const folderPath = root ? path.join(root, folder) : folder;
|
|
45
|
+
if (!fsImpl.existsSync(folderPath)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const seenKeys = new Map();
|
|
49
|
+
const elements = [];
|
|
50
|
+
for (const file of fsImpl.readdirSync(folderPath)) {
|
|
51
|
+
const fileName = String(file);
|
|
52
|
+
const key = elementKeyFromFileName(fileName);
|
|
53
|
+
if (!key) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const existingFile = seenKeys.get(key);
|
|
57
|
+
if (existingFile) {
|
|
58
|
+
throw new Error(`Duplicate element key "${key}" in ${folder}/: found both ${existingFile} and ${fileName}`);
|
|
59
|
+
}
|
|
60
|
+
seenKeys.set(key, fileName);
|
|
61
|
+
const filePath = path.join(folderPath, fileName);
|
|
62
|
+
try {
|
|
63
|
+
const content = fsImpl.readFileSync(filePath, 'utf8');
|
|
64
|
+
elements.push({
|
|
65
|
+
key,
|
|
66
|
+
filePath,
|
|
67
|
+
data: parseJson(content),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new Error(`Failed to read or parse ${filePath}: ${error}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return elements;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=elementFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementFiles.js","sourceRoot":"","sources":["../../src/utils/elementFiles.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAMpD,MAAM,CAAC,MAAM,mBAAmB,GAA4C;IAC1E,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,SAAS;IAC/B,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU;IACjC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO;IAC3B,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW;IACnC,C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CAAC;YACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphQLRequestClient } from './graphqlClient.js';
|
|
2
|
+
import type { IntegrationDefinitionQuery } from '../generated/operations.js';
|
|
3
|
+
type Integration = NonNullable<IntegrationDefinitionQuery['integration']>;
|
|
4
|
+
type IntegrationWithLatest = Integration & {
|
|
5
|
+
latest: NonNullable<Integration['latest']>;
|
|
6
|
+
};
|
|
7
|
+
export declare function fetchIntegrationDefinition(graphqlClient: GraphQLRequestClient, id: string, log: (message: string) => void): Promise<IntegrationWithLatest | undefined>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { gql } from 'graphql-tag';
|
|
3
|
+
import { handleGraphQLError } from './graphqlError.js';
|
|
4
|
+
const IntegrationDefinitionQueryDocument = gql `
|
|
5
|
+
query IntegrationDefinition($id: ID!) {
|
|
6
|
+
integration(id: $id) {
|
|
7
|
+
id
|
|
8
|
+
key
|
|
9
|
+
name
|
|
10
|
+
description
|
|
11
|
+
status
|
|
12
|
+
type
|
|
13
|
+
account {
|
|
14
|
+
id
|
|
15
|
+
key
|
|
16
|
+
name
|
|
17
|
+
}
|
|
18
|
+
templateImports {
|
|
19
|
+
id
|
|
20
|
+
timestamp
|
|
21
|
+
template {
|
|
22
|
+
id
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
latest {
|
|
26
|
+
timestamp
|
|
27
|
+
elements {
|
|
28
|
+
id
|
|
29
|
+
key
|
|
30
|
+
name
|
|
31
|
+
description
|
|
32
|
+
__typename
|
|
33
|
+
content {
|
|
34
|
+
createdAt
|
|
35
|
+
data
|
|
36
|
+
sourceId
|
|
37
|
+
sourceTimestamp
|
|
38
|
+
provenance
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export async function fetchIntegrationDefinition(graphqlClient, id, log) {
|
|
46
|
+
const result = await graphqlClient.request(IntegrationDefinitionQueryDocument, { id });
|
|
47
|
+
if (result.error) {
|
|
48
|
+
handleGraphQLError(result.error, log);
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const integration = result.data?.integration;
|
|
52
|
+
if (!integration?.latest) {
|
|
53
|
+
log(chalk.red('Integration has no latest version'));
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return { ...integration, latest: integration.latest };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=fetchIntegrationDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchIntegrationDefinition.js","sourceRoot":"","sources":["../../src/utils/fetchIntegrationDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAStD,MAAM,kCAAkC,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwC7C,CAAA;AAKD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,aAAmC,EACnC,EAAU,EACV,GAA8B;IAE9B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CACxC,kCAAkC,EAClC,EAAE,EAAE,EAAE,CACP,CAAA;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACrC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,WAAW,CAAA;IAC5C,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QACzB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC,CAAA;QACnD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAA;AACvD,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function currentIntegrationKey(): string;
|
|
3
|
+
export declare function fetchIntegrationId(fsImpl?: typeof fs): string | undefined;
|
|
4
|
+
export declare function fetchAccountFromFolder(fsImpl?: typeof fs): string | undefined;
|
|
3
5
|
export declare function fetchIntegrationFromFile(fsImpl?: typeof fs): Record<string, unknown> | undefined;
|
package/dist/utils/fetchLocal.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readGreatFile, getIntegrationId } from './greatFile.js';
|
|
4
|
+
export function currentIntegrationKey() {
|
|
5
|
+
return path.basename(process.cwd());
|
|
6
|
+
}
|
|
7
|
+
export function fetchIntegrationId(fsImpl = fs) {
|
|
8
|
+
return getIntegrationId(readGreatFile(undefined, fsImpl));
|
|
9
|
+
}
|
|
10
|
+
export function fetchAccountFromFolder(fsImpl = fs) {
|
|
11
|
+
const { account } = readGreatFile(undefined, fsImpl);
|
|
12
|
+
return account?.id ?? account?.key;
|
|
11
13
|
}
|
|
12
14
|
export function fetchIntegrationFromFile(fsImpl = fs) {
|
|
13
15
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchLocal.js","sourceRoot":"","sources":["../../src/utils/fetchLocal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchLocal.js","sourceRoot":"","sources":["../../src/utils/fetchLocal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAIhE,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AACrC,CAAC;AAKD,MAAM,UAAU,kBAAkB,CAAC,MAAM,GAAG,EAAE;IAC5C,OAAO,gBAAgB,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;AAC3D,CAAC;AAKD,MAAM,UAAU,sBAAsB,CAAC,MAAM,GAAG,EAAE;IAChD,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACpD,OAAO,OAAO,EAAE,EAAE,IAAI,OAAO,EAAE,GAAG,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,MAAM,GAAG,EAAE;IAEX,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GraphQLRequestClient } from './graphqlClient.js';
|
|
2
|
-
export declare const SessionQueryDocument: import("graphql
|
|
2
|
+
export declare const SessionQueryDocument: import("graphql").DocumentNode;
|
|
3
3
|
export interface SessionResult {
|
|
4
4
|
userName?: string;
|
|
5
5
|
error?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { gql } from 'graphql-tag';
|
|
2
2
|
import { createGraphQLClient, } from './graphqlClient.js';
|
|
3
|
+
import { getGraphQLErrorMessage } from './graphqlError.js';
|
|
3
4
|
export const SessionQueryDocument = gql `
|
|
4
5
|
query Session {
|
|
5
6
|
session {
|
|
@@ -15,7 +16,7 @@ export async function fetchSession(apiToken, client, baseUrl) {
|
|
|
15
16
|
try {
|
|
16
17
|
const sessionResult = await graphqlClient.request(SessionQueryDocument, {});
|
|
17
18
|
if (sessionResult.error) {
|
|
18
|
-
const errorMessage =
|
|
19
|
+
const errorMessage = getGraphQLErrorMessage(sessionResult.error);
|
|
19
20
|
return {
|
|
20
21
|
error: errorMessage,
|
|
21
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSession.js","sourceRoot":"","sources":["../../src/utils/fetchSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchSession.js","sourceRoot":"","sources":["../../src/utils/fetchSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;;;;;;;;;CAStC,CAAA;AAOD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAiB,EACjB,MAA6B,EAC7B,OAAgB;IAEhB,MAAM,aAAa,GAAG,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEtE,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,OAAO,CAC/C,oBAAoB,EACpB,EAAE,CACH,CAAA;QAGD,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,YAAY,GAAG,sBAAsB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YAChE,OAAO;gBACL,KAAK,EAAE,YAAY;aACpB,CAAA;QACH,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;SAClD,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3E,OAAO;YACL,KAAK,EAAE,4BAA4B,YAAY,EAAE;SAClD,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type Conf from 'conf';
|
|
2
|
+
import type { ConfigSchema } from './config.js';
|
|
1
3
|
import type { RequestDocument, Variables } from 'graphql-request';
|
|
2
4
|
interface RequestResult<T> {
|
|
3
5
|
data?: T;
|
|
@@ -6,5 +8,6 @@ interface RequestResult<T> {
|
|
|
6
8
|
export interface GraphQLRequestClient {
|
|
7
9
|
request: <T, V extends Variables = Variables>(document: RequestDocument, variables: V) => Promise<RequestResult<T>>;
|
|
8
10
|
}
|
|
11
|
+
export declare function getClient(apiToken: string | undefined, client: GraphQLRequestClient | undefined, config?: Conf<ConfigSchema>): GraphQLRequestClient;
|
|
9
12
|
export declare function createGraphQLClient(token?: string, baseUrl?: string): GraphQLRequestClient;
|
|
10
13
|
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { GraphQLClient, ClientError } from 'graphql-request';
|
|
2
2
|
import { getApiBaseUrl } from './config.js';
|
|
3
|
+
export function getClient(apiToken, client, config) {
|
|
4
|
+
return client ?? createGraphQLClient(apiToken, getApiBaseUrl(config));
|
|
5
|
+
}
|
|
3
6
|
export function createGraphQLClient(token, baseUrl) {
|
|
4
7
|
const apiUrl = baseUrl ?? getApiBaseUrl();
|
|
5
8
|
const graphQLUrl = `${apiUrl}/graphql`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlClient.js","sourceRoot":"","sources":["../../src/utils/graphqlClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"graphqlClient.js","sourceRoot":"","sources":["../../src/utils/graphqlClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAoB3C,MAAM,UAAU,SAAS,CACvB,QAA4B,EAC5B,MAAwC,EACxC,MAA2B;IAE3B,OAAO,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,KAAc,EACd,OAAgB;IAEhB,MAAM,MAAM,GAAG,OAAO,IAAI,aAAa,EAAE,CAAA;IACzC,MAAM,UAAU,GAAG,GAAG,MAAM,UAAU,CAAA;IAEtC,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,UAAU,EAAE;QAC3C,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;KAC3D,CAAC,CAAA;IAEF,OAAO;QACL,OAAO,EAAE,KAAK,EACZ,QAAyB,EACzB,SAAY,EACe,EAAE;YAC7B,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAI,QAAQ,EAAE,SAAS,CAAC,CAAA;gBACzD,OAAO,EAAE,IAAI,EAAE,CAAA;YACjB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;oBAEjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAS,EAAE,CAAA;gBACzD,CAAC;gBACD,OAAO,EAAE,KAAK,EAAE,KAAc,EAAE,CAAA;YAClC,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function isNotFoundError(error: Error): boolean;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getGraphQLErrorMessage(error: Error | string): string;
|
|
3
|
+
export declare function handleGraphQLError(error: Error | string | undefined, log: (message: string) => void): void;
|
|
@@ -6,15 +6,29 @@ export function isNotFoundError(error) {
|
|
|
6
6
|
}
|
|
7
7
|
return error?.message?.includes('NOT_FOUND');
|
|
8
8
|
}
|
|
9
|
+
export function getGraphQLErrorMessage(error) {
|
|
10
|
+
if (typeof error === 'string')
|
|
11
|
+
return error;
|
|
12
|
+
const errors = error.response?.errors;
|
|
13
|
+
const messages = errors
|
|
14
|
+
?.map((err) => err.message)
|
|
15
|
+
.filter((message) => Boolean(message));
|
|
16
|
+
if (messages?.length) {
|
|
17
|
+
return messages.join('\n');
|
|
18
|
+
}
|
|
19
|
+
return error.message;
|
|
20
|
+
}
|
|
9
21
|
export function handleGraphQLError(error, log) {
|
|
10
22
|
if (!error)
|
|
11
23
|
return;
|
|
12
|
-
const
|
|
13
|
-
|
|
24
|
+
const message = getGraphQLErrorMessage(error);
|
|
25
|
+
const isAuthError = message.includes('Authentication required') ||
|
|
26
|
+
message.includes('Not authenticated') ||
|
|
27
|
+
message.includes('Unauthorized');
|
|
14
28
|
if (isAuthError) {
|
|
15
29
|
log(chalk.red(`Not logged in. Run ${chalk.bold('great login')}.`));
|
|
16
30
|
return;
|
|
17
31
|
}
|
|
18
|
-
log(chalk.red(
|
|
32
|
+
log(chalk.red(message));
|
|
19
33
|
}
|
|
20
34
|
//# sourceMappingURL=graphqlError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlError.js","sourceRoot":"","sources":["../../src/utils/graphqlError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"graphqlError.js","sourceRoot":"","sources":["../../src/utils/graphqlError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAezB,MAAM,UAAU,eAAe,CAAC,KAAY;IAE1C,MAAM,iBAAiB,GAAG,KAAkC,CAAA;IAE5D,IAAI,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACvC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAC3C,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,KAAK,WAAW,CAC9C,CAAA;IACH,CAAC;IAGD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9C,CAAC;AAUD,MAAM,UAAU,sBAAsB,CAAC,KAAqB;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAE3C,MAAM,MAAM,GAAI,KAAmC,CAAC,QAAQ,EAAE,MAAM,CAAA;IACpE,MAAM,QAAQ,GAAG,MAAM;QACrB,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;SAC1B,MAAM,CAAC,CAAC,OAAO,EAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3D,IAAI,QAAQ,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAA;AACtB,CAAC;AAKD,MAAM,UAAU,kBAAkB,CAChC,KAAiC,EACjC,GAA8B;IAE9B,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;IAC7C,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QAC3C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;IAClC,IAAI,WAAW,EAAE,CAAC;QAChB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;QAClE,OAAM;IACR,CAAC;IAGD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
export interface GreatElementSource {
|
|
3
|
+
id: string;
|
|
4
|
+
timestamp?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GreatElementRecord {
|
|
7
|
+
id?: string;
|
|
8
|
+
timestamp?: string;
|
|
9
|
+
hash?: string;
|
|
10
|
+
source?: GreatElementSource;
|
|
11
|
+
provenance?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface GreatImportRecord {
|
|
14
|
+
templateId: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
id?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GreatFile {
|
|
19
|
+
id?: string;
|
|
20
|
+
timestamp?: string;
|
|
21
|
+
account?: {
|
|
22
|
+
id?: string;
|
|
23
|
+
key?: string;
|
|
24
|
+
};
|
|
25
|
+
imports?: GreatImportRecord[];
|
|
26
|
+
elements: Record<string, GreatElementRecord>;
|
|
27
|
+
}
|
|
28
|
+
export declare const emptyGreatFile: () => GreatFile;
|
|
29
|
+
export declare function readGreatFile(root?: string, fsImpl?: typeof fs): GreatFile;
|
|
30
|
+
export declare function writeGreatFile(great: GreatFile, root?: string, fsImpl?: typeof fs): void;
|
|
31
|
+
export declare const getIntegrationId: (great: GreatFile) => string | undefined;
|
|
32
|
+
export declare function getElementRecord(great: GreatFile, folder: string, key: string): GreatElementRecord | undefined;
|
|
33
|
+
export declare function setElementRecord(great: GreatFile, folder: string, key: string, record: GreatElementRecord): void;
|
|
34
|
+
export declare function removeElementRecord(great: GreatFile, folder: string, key: string): void;
|
|
35
|
+
export declare function removeElementRecordById(great: GreatFile, id: string): void;
|
|
36
|
+
export declare function renameElementRecord(great: GreatFile, folder: string, oldKey: string, newKey: string): void;
|
|
37
|
+
export declare function getImportRecord(great: GreatFile, templateId: string): GreatImportRecord | undefined;
|
|
38
|
+
export declare function upsertImportRecord(great: GreatFile, templateId: string, timestamp: string): void;
|
|
39
|
+
export declare function addProvenance(record: GreatElementRecord, templates: readonly string[]): void;
|
|
40
|
+
export declare function sameProvenance(a: readonly string[] | undefined, b: readonly string[] | undefined): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
const FILENAME = '.great.json';
|
|
3
|
+
const filePath = (root) => (root ? `${root}/${FILENAME}` : FILENAME);
|
|
4
|
+
const recordKey = (folder, key) => `${folder}/${key}`;
|
|
5
|
+
export const emptyGreatFile = () => ({ elements: {} });
|
|
6
|
+
export function readGreatFile(root, fsImpl = fs) {
|
|
7
|
+
try {
|
|
8
|
+
const content = fsImpl.readFileSync(filePath(root), 'utf8');
|
|
9
|
+
const parsed = JSON.parse(content);
|
|
10
|
+
return { elements: {}, ...parsed };
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return emptyGreatFile();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function writeGreatFile(great, root, fsImpl = fs) {
|
|
17
|
+
fsImpl.writeFileSync(filePath(root), JSON.stringify(great, undefined, 2));
|
|
18
|
+
}
|
|
19
|
+
export const getIntegrationId = (great) => great.id;
|
|
20
|
+
export function getElementRecord(great, folder, key) {
|
|
21
|
+
return great.elements[recordKey(folder, key)];
|
|
22
|
+
}
|
|
23
|
+
export function setElementRecord(great, folder, key, record) {
|
|
24
|
+
great.elements[recordKey(folder, key)] = record;
|
|
25
|
+
}
|
|
26
|
+
export function removeElementRecord(great, folder, key) {
|
|
27
|
+
Reflect.deleteProperty(great.elements, recordKey(folder, key));
|
|
28
|
+
}
|
|
29
|
+
export function removeElementRecordById(great, id) {
|
|
30
|
+
for (const [key, record] of Object.entries(great.elements)) {
|
|
31
|
+
if (record.id === id) {
|
|
32
|
+
Reflect.deleteProperty(great.elements, key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function renameElementRecord(great, folder, oldKey, newKey) {
|
|
37
|
+
const record = getElementRecord(great, folder, oldKey);
|
|
38
|
+
if (record) {
|
|
39
|
+
removeElementRecord(great, folder, oldKey);
|
|
40
|
+
setElementRecord(great, folder, newKey, record);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function getImportRecord(great, templateId) {
|
|
44
|
+
return great.imports?.find((record) => record.templateId === templateId);
|
|
45
|
+
}
|
|
46
|
+
export function upsertImportRecord(great, templateId, timestamp) {
|
|
47
|
+
const existing = getImportRecord(great, templateId);
|
|
48
|
+
if (existing) {
|
|
49
|
+
existing.timestamp = timestamp;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
great.imports = [...(great.imports ?? []), { templateId, timestamp }];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function addProvenance(record, templates) {
|
|
56
|
+
const merged = new Set([...(record.provenance ?? []), ...templates]);
|
|
57
|
+
if (merged.size > 0) {
|
|
58
|
+
record.provenance = [...merged].sort();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function sameProvenance(a, b) {
|
|
62
|
+
const setA = new Set(a ?? []);
|
|
63
|
+
const setB = new Set(b ?? []);
|
|
64
|
+
return setA.size === setB.size && [...setA].every((id) => setB.has(id));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=greatFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greatFile.js","sourceRoot":"","sources":["../../src/utils/greatFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AA6DxB,MAAM,QAAQ,GAAG,aAAa,CAAA;AAE9B,MAAM,QAAQ,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AAE7E,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAA;AAErE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAc,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;AAEjE,MAAM,UAAU,aAAa,CAAC,IAAa,EAAE,MAAM,GAAG,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;QAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAuB,CAAA;QACxD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,cAAc,EAAE,CAAA;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,KAAgB,EAChB,IAAa,EACb,MAAM,GAAG,EAAE;IAEX,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAA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IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
export default function hashContent(data) {
|
|
3
|
-
const {
|
|
3
|
+
const { name, description, value, ...content } = data;
|
|
4
4
|
const jsonString = JSON.stringify(content);
|
|
5
5
|
return crypto.createHash('sha256').update(jsonString).digest('hex');
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashContent.js","sourceRoot":"","sources":["../../src/utils/hashContent.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"hashContent.js","sourceRoot":"","sources":["../../src/utils/hashContent.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAahC,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAA6B;IAK/D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAA;IAGrD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAG1C,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { IntegrationType } from '../generated/schema.js';
|
|
3
|
+
export const DEFAULT_INTEGRATION_TYPE = IntegrationType.Integration;
|
|
4
|
+
const validTypes = Object.values(IntegrationType);
|
|
5
|
+
export default function resolveIntegrationType(value, log) {
|
|
6
|
+
if (value === undefined || value === null || value === '') {
|
|
7
|
+
return DEFAULT_INTEGRATION_TYPE;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === 'string' && validTypes.includes(value)) {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
log?.(chalk.yellow(`Unknown integration type "${String(value)}", defaulting to "${DEFAULT_INTEGRATION_TYPE}". Valid types are: ${validTypes.join(', ')}.`));
|
|
13
|
+
return DEFAULT_INTEGRATION_TYPE;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=integrationType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationType.js","sourceRoot":"","sources":["../../src/utils/integrationType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC,WAAW,CAAA;AAEnE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAa,CAAA;AAK7D,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,KAAc,EACd,GAA+B;IAE/B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,wBAAwB,CAAA;IACjC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAwB,CAAA;IACjC,CAAC;IAED,GAAG,EAAE,CACH,KAAK,CAAC,MAAM,CACV,6BAA6B,MAAM,CAAC,KAAK,CAAC,qBAAqB,wBAAwB,uBAAuB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACvI,CACF,CAAA;IACD,OAAO,wBAAwB,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function parseJson(text: string): unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJson.js","sourceRoot":"","sources":["../../src/utils/parseJson.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AAMnD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACtE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import Conf from 'conf';
|
|
2
3
|
import { type ConfigSchema } from './config.js';
|
|
3
4
|
import { type GraphQLRequestClient } from './graphqlClient.js';
|
|
@@ -7,13 +8,13 @@ export interface AccountResult {
|
|
|
7
8
|
name: string;
|
|
8
9
|
key: string;
|
|
9
10
|
};
|
|
10
|
-
error?: string;
|
|
11
|
+
error?: Error | string;
|
|
11
12
|
}
|
|
12
13
|
export interface ResolveAccountResult {
|
|
13
14
|
accountId?: string;
|
|
14
|
-
error?: string;
|
|
15
|
-
source?: 'flag' | 'config';
|
|
15
|
+
error?: Error | string;
|
|
16
|
+
source?: 'flag' | 'folder' | 'config';
|
|
16
17
|
}
|
|
17
18
|
export declare function resolveAccountId(options: {
|
|
18
19
|
account?: string;
|
|
19
|
-
}, apiToken: string, client: GraphQLRequestClient, config?: Conf<ConfigSchema
|
|
20
|
+
}, apiToken: string, client: GraphQLRequestClient, config?: Conf<ConfigSchema>, fsImpl?: typeof fs): Promise<ResolveAccountResult>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import { gql } from 'graphql-tag';
|
|
2
3
|
import { getConfigValue } from './config.js';
|
|
4
|
+
import { fetchAccountFromFolder } from './fetchLocal.js';
|
|
3
5
|
import { createGraphQLClient, } from './graphqlClient.js';
|
|
4
6
|
import { isNotFoundError } from './graphqlError.js';
|
|
5
7
|
const AccountByIdQueryDocument = gql `
|
|
@@ -25,18 +27,14 @@ async function fetchAccount(accountId, apiToken, client, baseUrl) {
|
|
|
25
27
|
try {
|
|
26
28
|
const idResult = await graphqlClient.request(AccountByIdQueryDocument, { id: accountId });
|
|
27
29
|
if (idResult.error && !isNotFoundError(idResult.error)) {
|
|
28
|
-
return {
|
|
29
|
-
error: `Could not fetch account: ${idResult.error.message}`,
|
|
30
|
-
};
|
|
30
|
+
return { error: idResult.error };
|
|
31
31
|
}
|
|
32
32
|
if (idResult.data?.account) {
|
|
33
33
|
return { account: idResult.data.account };
|
|
34
34
|
}
|
|
35
35
|
const keyResult = await graphqlClient.request(AccountByKeyQueryDocument, { key: accountId });
|
|
36
36
|
if (keyResult.error && !isNotFoundError(keyResult.error)) {
|
|
37
|
-
return {
|
|
38
|
-
error: `Could not fetch account: ${keyResult.error.message}`,
|
|
39
|
-
};
|
|
37
|
+
return { error: keyResult.error };
|
|
40
38
|
}
|
|
41
39
|
if (keyResult.data?.accountByKey) {
|
|
42
40
|
return { account: keyResult.data.accountByKey };
|
|
@@ -46,13 +44,12 @@ async function fetchAccount(accountId, apiToken, client, baseUrl) {
|
|
|
46
44
|
};
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
50
47
|
return {
|
|
51
|
-
error:
|
|
48
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
52
49
|
};
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
export async function resolveAccountId(options, apiToken, client, config) {
|
|
52
|
+
export async function resolveAccountId(options, apiToken, client, config, fsImpl = fs) {
|
|
56
53
|
if (options?.account) {
|
|
57
54
|
const result = await fetchAccount(options.account, apiToken, client);
|
|
58
55
|
if (result.error) {
|
|
@@ -60,10 +57,21 @@ export async function resolveAccountId(options, apiToken, client, config) {
|
|
|
60
57
|
}
|
|
61
58
|
return { accountId: result.account?.id, source: 'flag' };
|
|
62
59
|
}
|
|
60
|
+
const folderAccount = fetchAccountFromFolder(fsImpl);
|
|
61
|
+
if (folderAccount) {
|
|
62
|
+
const result = await fetchAccount(folderAccount, apiToken, client);
|
|
63
|
+
if (result.error) {
|
|
64
|
+
return { error: result.error };
|
|
65
|
+
}
|
|
66
|
+
return { accountId: result.account?.id, source: 'folder' };
|
|
67
|
+
}
|
|
63
68
|
const defaultAccount = getConfigValue('account', config);
|
|
64
69
|
if (defaultAccount) {
|
|
65
70
|
const result = await fetchAccount(defaultAccount, apiToken, client);
|
|
66
71
|
if (result.error) {
|
|
72
|
+
if (result.error instanceof Error) {
|
|
73
|
+
return { error: result.error };
|
|
74
|
+
}
|
|
67
75
|
return {
|
|
68
76
|
error: `Default account '${defaultAccount}' not found. Update with: great config set account <id>, or unset with: great config unset account`,
|
|
69
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAccount.js","sourceRoot":"","sources":["../../src/utils/resolveAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveAccount.js","sourceRoot":"","sources":["../../src/utils/resolveAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAMnD,MAAM,wBAAwB,GAAG,GAAG,CAAA;;;;;;;;CAQnC,CAAA;AAED,MAAM,yBAAyB,GAAG,GAAG,CAAA;;;;;;;;CAQpC,CAAA;AAWD,KAAK,UAAU,YAAY,CACzB,SAAiB,EACjB,QAAiB,EACjB,MAA6B,EAC7B,OAAgB;IAEhB,MAAM,aAAa,GAAG,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,O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S,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;IAC5D,CAAC;IAGD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GraphQLRequestClient } from './graphqlClient.js';
|
|
2
|
+
import type { ResolveElementIncludeQuery } from '../generated/operations.js';
|
|
3
|
+
export declare function resolveElementInclude(graphqlClient: GraphQLRequestClient, elementId: string, sourceTimestamp: string | undefined, log: (message: string) => void): Promise<ResolveElementIncludeQuery['resolveElementInclude'] | undefined>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { handleGraphQLError } from './graphqlError.js';
|
|
3
|
+
const ResolveElementIncludeQueryDocument = gql `
|
|
4
|
+
query ResolveElementInclude($elementId: ID!, $sourceTimestamp: DateTime) {
|
|
5
|
+
resolveElementInclude(elementId: $elementId, sourceTimestamp: $sourceTimestamp) {
|
|
6
|
+
key
|
|
7
|
+
name
|
|
8
|
+
description
|
|
9
|
+
type
|
|
10
|
+
content {
|
|
11
|
+
sourceId
|
|
12
|
+
sourceTimestamp
|
|
13
|
+
createdAt
|
|
14
|
+
provenance
|
|
15
|
+
data
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
export async function resolveElementInclude(graphqlClient, elementId, sourceTimestamp, log) {
|
|
21
|
+
const result = await graphqlClient.request(ResolveElementIncludeQueryDocument, { elementId, sourceTimestamp });
|
|
22
|
+
if (result.error) {
|
|
23
|
+
handleGraphQLError(result.error, log);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return result.data?.resolveElementInclude;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=resolveElementInclude.js.map
|