great 1.2.2 → 1.4.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 +122 -50
- package/dist/clone/index.d.ts +2 -2
- package/dist/clone/index.js.map +1 -1
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/index.js.map +1 -1
- package/dist/explode/index.d.ts +2 -2
- package/dist/explode/index.js.map +1 -1
- package/dist/generated/operations.d.ts +30 -8
- package/dist/generated/schema.d.ts +138 -2
- package/dist/generated/schema.js +15 -0
- package/dist/generated/schema.js.map +1 -1
- package/dist/implode/index.d.ts +2 -2
- package/dist/implode/index.js +1 -0
- package/dist/implode/index.js.map +1 -1
- package/dist/implode/transform.d.ts +1 -0
- package/dist/implode/transform.js +16 -2
- package/dist/implode/transform.js.map +1 -1
- package/dist/import/index.d.ts +4 -2
- package/dist/import/index.js +27 -6
- package/dist/import/index.js.map +1 -1
- package/dist/include/index.d.ts +4 -2
- package/dist/include/index.js +129 -11
- package/dist/include/index.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +2 -2
- package/dist/init/index.js +3 -3
- package/dist/init/index.js.map +1 -1
- package/dist/integrations/create.js +1 -1
- package/dist/integrations/create.js.map +1 -1
- package/dist/integrations/index.js +6 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/list.d.ts +2 -0
- package/dist/integrations/list.js +30 -16
- package/dist/integrations/list.js.map +1 -1
- package/dist/migrate/index.d.ts +5 -2
- package/dist/migrate/index.js +102 -4
- package/dist/migrate/index.js.map +1 -1
- package/dist/pull/index.d.ts +2 -2
- package/dist/pull/index.js.map +1 -1
- package/dist/push/index.d.ts +3 -2
- package/dist/push/index.js +168 -73
- package/dist/push/index.js.map +1 -1
- package/dist/remove/index.d.ts +5 -0
- package/dist/remove/index.js +71 -0
- package/dist/remove/index.js.map +1 -0
- package/dist/rename/index.d.ts +2 -2
- package/dist/rename/index.js +54 -23
- package/dist/rename/index.js.map +1 -1
- package/dist/run/index.d.ts +29 -2
- package/dist/run/index.js.map +1 -1
- package/dist/status/index.d.ts +2 -2
- package/dist/status/index.js +1 -1
- package/dist/status/index.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/utils/createIntegrationFromFile.d.ts +2 -2
- package/dist/utils/createIntegrationFromFile.js.map +1 -1
- package/dist/utils/detectPullConflicts.d.ts +2 -2
- package/dist/utils/detectPullConflicts.js +9 -14
- package/dist/utils/detectPullConflicts.js.map +1 -1
- package/dist/utils/elementFiles.d.ts +24 -5
- package/dist/utils/elementFiles.js +147 -8
- package/dist/utils/elementFiles.js.map +1 -1
- package/dist/utils/fetchLocal.d.ts +4 -4
- package/dist/utils/fetchLocal.js.map +1 -1
- package/dist/utils/graphqlError.js +16 -2
- package/dist/utils/graphqlError.js.map +1 -1
- package/dist/utils/greatFile.d.ts +3 -3
- package/dist/utils/greatFile.js.map +1 -1
- package/dist/utils/mergeEndpointLists.d.ts +7 -0
- package/dist/utils/mergeEndpointLists.js +32 -0
- package/dist/utils/mergeEndpointLists.js.map +1 -0
- package/dist/utils/promptForDetach.d.ts +6 -0
- package/dist/utils/promptForDetach.js +15 -0
- package/dist/utils/promptForDetach.js.map +1 -0
- package/dist/utils/promptForEndpoints.d.ts +5 -0
- package/dist/utils/promptForEndpoints.js +37 -0
- package/dist/utils/promptForEndpoints.js.map +1 -0
- package/dist/utils/promptForReplaceLocal.d.ts +5 -0
- package/dist/utils/promptForReplaceLocal.js +18 -0
- package/dist/utils/promptForReplaceLocal.js.map +1 -0
- package/dist/utils/promptForValue.d.ts +1 -0
- package/dist/utils/promptForValue.js +5 -3
- package/dist/utils/promptForValue.js.map +1 -1
- package/dist/utils/resolveAccount.d.ts +2 -2
- package/dist/utils/resolveAccount.js.map +1 -1
- package/dist/utils/resolveElement.d.ts +2 -0
- package/dist/utils/resolveElement.js +8 -0
- package/dist/utils/resolveElement.js.map +1 -1
- package/dist/utils/resolveElementIncludes.d.ts +6 -0
- package/dist/utils/resolveElementIncludes.js +113 -0
- package/dist/utils/resolveElementIncludes.js.map +1 -0
- package/dist/utils/saveIntegration.d.ts +2 -2
- package/dist/utils/saveIntegration.js +54 -30
- package/dist/utils/saveIntegration.js.map +1 -1
- package/dist/utils/serviceFile.d.ts +34 -0
- package/dist/utils/serviceFile.js +95 -0
- package/dist/utils/serviceFile.js.map +1 -0
- package/dist/utils/shadowMarker.d.ts +5 -0
- package/dist/utils/shadowMarker.js +16 -0
- package/dist/utils/shadowMarker.js.map +1 -0
- package/dist/utils/writeShadowElement.d.ts +12 -10
- package/dist/utils/writeShadowElement.js +98 -58
- package/dist/utils/writeShadowElement.js.map +1 -1
- package/dist/values/get.d.ts +2 -2
- package/dist/values/get.js.map +1 -1
- package/dist/values/list.d.ts +2 -2
- package/dist/values/list.js.map +1 -1
- package/dist/values/set.d.ts +2 -2
- package/dist/values/set.js.map +1 -1
- package/dist/values/unset.d.ts +2 -2
- package/dist/values/unset.js.map +1 -1
- package/package.json +16 -17
- package/quality.toml +4 -0
- package/dist/utils/resolveElementInclude.d.ts +0 -3
- package/dist/utils/resolveElementInclude.js +0 -27
- package/dist/utils/resolveElementInclude.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAA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AC,CAAA;QAC3C,GAAG,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAA;QAC9C,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,uCAAuC,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAA;IACtD,CAAC;AACH,CAAC,CAAA;AAEH,eAAe,CAAC,OAAgB,EAAE,EAAE,CAClC,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CACV,gHAAgH,CACjH;KACA,MAAM,CACL,aAAa,EACb,4DAA4D,CAC7D;KACA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
package/dist/pull/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import Conf from 'conf';
|
|
3
2
|
import { type GraphQLRequestClient } from '../utils/graphqlClient.js';
|
|
4
3
|
import type { ConfigSchema } from '../utils/config.js';
|
|
5
4
|
import type { Command } from 'commander';
|
|
6
|
-
|
|
5
|
+
import type { GreatFs } from '../types.js';
|
|
6
|
+
export declare const action: (log: (message: string) => void, apiToken?: string, client?: GraphQLRequestClient, fsImpl?: GreatFs, config?: Conf<ConfigSchema>) => (options?: {
|
|
7
7
|
force?: boolean;
|
|
8
8
|
}) => Promise<void>;
|
|
9
9
|
declare const _default: (program: Command, apiToken?: string) => Command;
|
package/dist/pull/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pull/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pull/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAA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,WAAW,GAAG,MAAM,0BAA0B,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAC5E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAM;IACR,CAAC;IAID,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QACnD,MAAM,SAAS,GAAG,mBAAmB,CACnC,WAAW,CAAC,MAAM,EAClB,UAAU,EACV,SAAS,EACT,MAAM,CACP,CAAA;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;YAC/B,OAAM;QACR,CAAC;IACH,CAAC;IAED,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;AACrE,CAAC,CAAA;AAEH,eAAe,CAAC,OAAgB,EAAE,QAAiB,EAAE,EAAE,CACrD,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,uDAAuD,CAAC;KACpE,MAAM,CAAC,aAAa,EAAE,gDAAgD,CAAC;KACvE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA"}
|
package/dist/push/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import Conf from 'conf';
|
|
2
|
+
import { promptForDetach } from '../utils/promptForDetach.js';
|
|
3
3
|
import { type GraphQLRequestClient } from '../utils/graphqlClient.js';
|
|
4
4
|
import type { ConfigSchema } from '../utils/config.js';
|
|
5
5
|
import { promptForValueSetting } from '../utils/promptForValue.js';
|
|
6
6
|
import type { Command } from 'commander';
|
|
7
|
-
|
|
7
|
+
import type { GreatFs } from '../types.js';
|
|
8
|
+
export declare const action: (log: (message: string) => void, apiToken?: string, client?: GraphQLRequestClient, fsImpl?: GreatFs, config?: Conf<ConfigSchema>, promptForValueSettingFn?: typeof promptForValueSetting, promptForDetachFn?: typeof promptForDetach) => (options?: {
|
|
8
9
|
account?: string;
|
|
9
10
|
}) => Promise<void>;
|
|
10
11
|
declare const _default: (program: Command, apiToken?: string) => Command;
|
package/dist/push/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import parseJson from '../utils/parseJson.js';
|
|
4
3
|
import { sentenceCase } from 'change-case';
|
|
5
4
|
import { fetchIntegrationFromFile } from '../utils/fetchLocal.js';
|
|
6
5
|
import { readGreatFile, writeGreatFile, getElementRecord, setElementRecord, removeElementRecordById, sameProvenance, } from '../utils/greatFile.js';
|
|
7
|
-
import {
|
|
6
|
+
import { readWorkspaceElements, writeElementFile, folderToElementType, } from '../utils/elementFiles.js';
|
|
7
|
+
import { ENDPOINT_LISTS_FOLDER, validateEndpointReferences, } from '../utils/serviceFile.js';
|
|
8
|
+
import { promptForDetach } from '../utils/promptForDetach.js';
|
|
9
|
+
import { fetchElementById } from '../utils/resolveElement.js';
|
|
8
10
|
import createIntegrationFromFile from '../utils/createIntegrationFromFile.js';
|
|
9
11
|
import { typeToFolder } from '../utils/saveIntegration.js';
|
|
10
12
|
import { getClient } from '../utils/graphqlClient.js';
|
|
11
|
-
import { getGraphQLErrorMessage, handleGraphQLError, } from '../utils/graphqlError.js';
|
|
13
|
+
import { getGraphQLErrorMessage, handleGraphQLError, isNotFoundError, } from '../utils/graphqlError.js';
|
|
12
14
|
import hashContent from '../utils/hashContent.js';
|
|
13
15
|
import { VALID_VALUE_TYPES, isValidValueElementType, } from '../utils/valueTypes.js';
|
|
14
16
|
import { setValueForElement } from '../values/set.js';
|
|
15
17
|
import { promptForValueSetting } from '../utils/promptForValue.js';
|
|
16
|
-
import { SHADOW_MARKER } from '../utils/writeShadowElement.js';
|
|
17
18
|
import resolveIntegrationType from '../utils/integrationType.js';
|
|
18
19
|
import { ElementType } from '../generated/schema.js';
|
|
19
20
|
import { gql } from 'graphql-tag';
|
|
@@ -43,6 +44,7 @@ const IntegrationForPushQueryDocument = gql `
|
|
|
43
44
|
content {
|
|
44
45
|
checksum
|
|
45
46
|
createdAt
|
|
47
|
+
sourceId
|
|
46
48
|
sourceTimestamp
|
|
47
49
|
provenance
|
|
48
50
|
}
|
|
@@ -135,8 +137,8 @@ const UpdateElementMutationDocument = gql `
|
|
|
135
137
|
}
|
|
136
138
|
`;
|
|
137
139
|
const SetElementContentMutationDocument = gql `
|
|
138
|
-
mutation SetElementContent($id: ID!, $content: JSON) {
|
|
139
|
-
setElementContent(id: $id, content: $content) {
|
|
140
|
+
mutation SetElementContent($id: ID!, $content: JSON, $provenance: [ID!]) {
|
|
141
|
+
setElementContent(id: $id, content: $content, provenance: $provenance) {
|
|
140
142
|
id
|
|
141
143
|
content {
|
|
142
144
|
createdAt
|
|
@@ -158,14 +160,47 @@ const SetSecretRefMutationDocument = gql `
|
|
|
158
160
|
setSecretRef(id: $id, secretRef: $secretRef)
|
|
159
161
|
}
|
|
160
162
|
`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
const readLocalElements = (fsImpl) => readWorkspaceElements(undefined, fsImpl);
|
|
164
|
+
const isEndpointList = (element) => element.folder === ENDPOINT_LISTS_FOLDER;
|
|
165
|
+
const hasShadowContentChanged = (local) => local.hash !== undefined && hashContent(local.data) !== local.hash;
|
|
166
|
+
function compareShadow(local, remote, source) {
|
|
167
|
+
const localName = local.data.name || '';
|
|
168
|
+
const localDesc = local.data.description || '';
|
|
169
|
+
const isList = isEndpointList(local);
|
|
170
|
+
const hasNameChanged = !isList && localName !== (remote.name || '');
|
|
171
|
+
const hasDescriptionChanged = !isList && localDesc !== (remote.description || '');
|
|
172
|
+
const hasSourceChanged = source.id !== remote.sourceId;
|
|
173
|
+
const hasPinChanged = (source.timestamp ?? null) !== (remote.sourceTimestamp ?? null);
|
|
174
|
+
const hasProvenanceChanged = !sameProvenance(local.provenance, remote.provenance);
|
|
175
|
+
const hasRemoteMoved = local.timestamp !== remote.contentCreatedAt;
|
|
176
|
+
if (hasShadowContentChanged(local)) {
|
|
177
|
+
return hasRemoteMoved
|
|
178
|
+
? {
|
|
179
|
+
category: 'conflict',
|
|
180
|
+
reason: ' Shadow content changed locally and shadow changed remotely',
|
|
181
|
+
}
|
|
182
|
+
: { category: 'detach' };
|
|
183
|
+
}
|
|
184
|
+
if (!hasNameChanged &&
|
|
185
|
+
!hasDescriptionChanged &&
|
|
186
|
+
!hasSourceChanged &&
|
|
187
|
+
!hasPinChanged &&
|
|
188
|
+
!hasProvenanceChanged) {
|
|
189
|
+
return { category: 'unchanged' };
|
|
190
|
+
}
|
|
191
|
+
if (hasSourceChanged && hasRemoteMoved) {
|
|
192
|
+
return {
|
|
193
|
+
category: 'conflict',
|
|
194
|
+
reason: ' Shadow source changed both local and remote',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
else if (hasPinChanged && hasRemoteMoved) {
|
|
198
|
+
return {
|
|
199
|
+
category: 'conflict',
|
|
200
|
+
reason: ' Shadow pin changed both local and remote',
|
|
201
|
+
};
|
|
167
202
|
}
|
|
168
|
-
return
|
|
203
|
+
return { category: 'update' };
|
|
169
204
|
}
|
|
170
205
|
function compareLocalAndRemote(local, remote) {
|
|
171
206
|
if (!remote) {
|
|
@@ -174,27 +209,12 @@ function compareLocalAndRemote(local, remote) {
|
|
|
174
209
|
reason: 'Element exists locally with an id but not found in Integreat',
|
|
175
210
|
};
|
|
176
211
|
}
|
|
177
|
-
const localName = local.data.name || '';
|
|
178
|
-
const localDesc = local.data.description || '';
|
|
179
212
|
if (local.source) {
|
|
180
|
-
|
|
181
|
-
const hasDescriptionChanged = localDesc !== (remote.description || '');
|
|
182
|
-
const hasPinChanged = (local.source.timestamp ?? null) !== (remote.sourceTimestamp ?? null);
|
|
183
|
-
const hasProvenanceChanged = !sameProvenance(local.provenance, remote.provenance);
|
|
184
|
-
if (!hasNameChanged &&
|
|
185
|
-
!hasDescriptionChanged &&
|
|
186
|
-
!hasPinChanged &&
|
|
187
|
-
!hasProvenanceChanged) {
|
|
188
|
-
return { category: 'unchanged' };
|
|
189
|
-
}
|
|
190
|
-
if (hasPinChanged && local.timestamp !== remote.contentCreatedAt) {
|
|
191
|
-
return {
|
|
192
|
-
category: 'conflict',
|
|
193
|
-
reason: ' Shadow pin changed both local and remote',
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return { category: 'update' };
|
|
213
|
+
return compareShadow(local, remote, local.source);
|
|
197
214
|
}
|
|
215
|
+
const localName = local.data.name || '';
|
|
216
|
+
const localDesc = local.data.description || '';
|
|
217
|
+
const isList = isEndpointList(local);
|
|
198
218
|
const localChecksum = hashContent(local.data);
|
|
199
219
|
const localTimestamp = local.timestamp ? new Date(local.timestamp) : undefined;
|
|
200
220
|
const remoteChecksum = remote.checksum || '';
|
|
@@ -203,9 +223,11 @@ function compareLocalAndRemote(local, remote) {
|
|
|
203
223
|
const remoteCreatedAt = remote.createdAt
|
|
204
224
|
? new Date(remote.createdAt)
|
|
205
225
|
: undefined;
|
|
206
|
-
const hasContentChanged = localChecksum !== remoteChecksum
|
|
207
|
-
|
|
208
|
-
|
|
226
|
+
const hasContentChanged = localChecksum !== remoteChecksum ||
|
|
227
|
+
Boolean(remote.sourceId) ||
|
|
228
|
+
!sameProvenance(local.provenance, remote.provenance);
|
|
229
|
+
const hasNameChanged = !isList && localName !== remoteName;
|
|
230
|
+
const hasDescriptionChanged = !isList && localDesc !== remoteDesc;
|
|
209
231
|
if (!hasContentChanged && !hasNameChanged && !hasDescriptionChanged) {
|
|
210
232
|
return { category: 'unchanged' };
|
|
211
233
|
}
|
|
@@ -234,6 +256,7 @@ function categorizeElements(localElements, remoteElementsMap) {
|
|
|
234
256
|
const toCreate = [];
|
|
235
257
|
const toInclude = [];
|
|
236
258
|
const toUpdate = [];
|
|
259
|
+
const toDetach = [];
|
|
237
260
|
const toDelete = [];
|
|
238
261
|
const conflicts = [];
|
|
239
262
|
const localElementIds = new Set();
|
|
@@ -256,13 +279,18 @@ function categorizeElements(localElements, remoteElementsMap) {
|
|
|
256
279
|
else if (result.category === 'update') {
|
|
257
280
|
toUpdate.push({ ...local, remoteId: remote?.id });
|
|
258
281
|
}
|
|
282
|
+
else if (result.category === 'detach') {
|
|
283
|
+
toDetach.push({ ...local, remoteId: remote?.id });
|
|
284
|
+
}
|
|
259
285
|
}
|
|
260
286
|
for (const [id, remoteLement] of remoteElementsMap) {
|
|
261
287
|
if (!localElementIds.has(id)) {
|
|
262
288
|
toDelete.push(remoteLement);
|
|
263
289
|
}
|
|
264
290
|
}
|
|
265
|
-
|
|
291
|
+
toDelete.sort((a, b) => Number(b.folder === ENDPOINT_LISTS_FOLDER) -
|
|
292
|
+
Number(a.folder === ENDPOINT_LISTS_FOLDER));
|
|
293
|
+
return { toCreate, toInclude, toUpdate, toDetach, toDelete, conflicts };
|
|
266
294
|
}
|
|
267
295
|
const prepareContentForApi = ({ name, description, ...content }, elementType) => {
|
|
268
296
|
if (elementType === ElementType.Value) {
|
|
@@ -283,7 +311,9 @@ const prepareContentForApi = ({ name, description, ...content }, elementType) =>
|
|
|
283
311
|
};
|
|
284
312
|
async function createElementOnApi(client, integrationId, element) {
|
|
285
313
|
const elementType = folderToElementType[element.folder];
|
|
286
|
-
const name = element.data.name ||
|
|
314
|
+
const name = element.data.name ||
|
|
315
|
+
element.defaultName ||
|
|
316
|
+
sentenceCase(element.key);
|
|
287
317
|
const description = element.data.description;
|
|
288
318
|
const result = await client.request(CreateElementMutationDocument, {
|
|
289
319
|
integrationId,
|
|
@@ -301,28 +331,30 @@ async function createElementOnApi(client, integrationId, element) {
|
|
|
301
331
|
}
|
|
302
332
|
return { id, name };
|
|
303
333
|
}
|
|
334
|
+
function buildShadowData(element, name, description, data) {
|
|
335
|
+
if (isEndpointList(element)) {
|
|
336
|
+
return { ...data };
|
|
337
|
+
}
|
|
338
|
+
const finalName = element.data.name || name;
|
|
339
|
+
const finalDescription = element.data.description || description || undefined;
|
|
340
|
+
return {
|
|
341
|
+
...(finalName ? { name: finalName } : {}),
|
|
342
|
+
...(finalDescription ? { description: finalDescription } : {}),
|
|
343
|
+
...data,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
304
346
|
function writeShadowFileAndRecord(fsImpl, element, great, source, included) {
|
|
305
|
-
const name = element.data.name || included.name;
|
|
306
|
-
const description = element.data.description ||
|
|
307
|
-
included.description ||
|
|
308
|
-
undefined;
|
|
309
347
|
const content = included.content;
|
|
310
|
-
const fileData = {
|
|
311
|
-
[SHADOW_MARKER]: true,
|
|
312
|
-
...(name ? { name } : {}),
|
|
313
|
-
...(description ? { description } : {}),
|
|
314
|
-
...content?.data,
|
|
315
|
-
};
|
|
316
|
-
fsImpl.writeFileSync(element.filePath, JSON.stringify(fileData, null, 2));
|
|
317
348
|
setElementRecord(great, element.folder, element.key, {
|
|
318
349
|
id: included.id,
|
|
319
350
|
...(content?.createdAt ? { timestamp: content.createdAt } : {}),
|
|
320
|
-
|
|
351
|
+
hash: hashContent({ ...content?.data }),
|
|
321
352
|
source,
|
|
322
353
|
...(element.provenance && element.provenance.length > 0
|
|
323
354
|
? { provenance: element.provenance }
|
|
324
355
|
: {}),
|
|
325
356
|
});
|
|
357
|
+
writeElementFile(undefined, element.folder, element.key, buildShadowData(element, included.name, included.description, content?.data), great, fsImpl, element.filePath);
|
|
326
358
|
}
|
|
327
359
|
async function includeShadowElement(element, graphqlClient, integrationId, fsImpl, log, great) {
|
|
328
360
|
const source = element.source;
|
|
@@ -347,7 +379,7 @@ async function includeShadowElement(element, graphqlClient, integrationId, fsImp
|
|
|
347
379
|
const localDesc = element.data.description || '';
|
|
348
380
|
const nameDiffers = localName !== (included.name || '');
|
|
349
381
|
const descDiffers = localDesc !== (included.description || '');
|
|
350
|
-
if (nameDiffers || descDiffers) {
|
|
382
|
+
if (!isEndpointList(element) && (nameDiffers || descDiffers)) {
|
|
351
383
|
const updateResult = await graphqlClient.request(UpdateElementMutationDocument, {
|
|
352
384
|
id: included.id,
|
|
353
385
|
name: nameDiffers ? localName : undefined,
|
|
@@ -360,24 +392,32 @@ async function includeShadowElement(element, graphqlClient, integrationId, fsImp
|
|
|
360
392
|
writeShadowFileAndRecord(fsImpl, element, great, source, included);
|
|
361
393
|
return true;
|
|
362
394
|
}
|
|
363
|
-
async function updateElementContent(client, elementId, content) {
|
|
395
|
+
async function updateElementContent(client, elementId, content, provenance) {
|
|
364
396
|
const result = await client.request(SetElementContentMutationDocument, {
|
|
365
397
|
id: elementId,
|
|
366
398
|
content,
|
|
399
|
+
...(provenance && provenance.length > 0 ? { provenance } : {}),
|
|
367
400
|
});
|
|
368
401
|
if (result.error) {
|
|
369
402
|
return undefined;
|
|
370
403
|
}
|
|
371
404
|
return result.data?.setElementContent?.content?.createdAt;
|
|
372
405
|
}
|
|
406
|
+
async function setSecretRefForElement(client, elementId, element, log) {
|
|
407
|
+
const result = await client.request(SetSecretRefMutationDocument, { id: elementId, secretRef: String(element.data.ref) });
|
|
408
|
+
if (result.error) {
|
|
409
|
+
log(chalk.red(`Failed to set secret ref for ${element.key}: ${getGraphQLErrorMessage(result.error)}`));
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
log(chalk.green(`✓ Secret ref set for element "${element.key}"`));
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
373
415
|
function updateLocalFile(fsImpl, element, great, updatedId, updatedTimestamp, generatedName, keepValue = false) {
|
|
374
|
-
const
|
|
375
|
-
const parsed = parseJson(content);
|
|
376
|
-
const { name, description, value, ref, ...data } = parsed;
|
|
416
|
+
const { name, description, value, ref, ...data } = element.data;
|
|
377
417
|
const existing = getElementRecord(great, element.folder, element.key);
|
|
378
418
|
const id = updatedId ?? existing?.id;
|
|
379
419
|
const timestamp = updatedTimestamp ?? existing?.timestamp;
|
|
380
|
-
const finalName = generatedName || name;
|
|
420
|
+
const finalName = isEndpointList(element) ? undefined : generatedName || name;
|
|
381
421
|
const orderedData = {
|
|
382
422
|
...(finalName ? { name: finalName } : {}),
|
|
383
423
|
...(description ? { description } : {}),
|
|
@@ -385,12 +425,27 @@ function updateLocalFile(fsImpl, element, great, updatedId, updatedTimestamp, ge
|
|
|
385
425
|
...(keepValue && value !== undefined ? { value } : {}),
|
|
386
426
|
...(keepValue && ref !== undefined ? { ref } : {}),
|
|
387
427
|
};
|
|
388
|
-
fsImpl.writeFileSync(element.filePath, JSON.stringify(orderedData, null, 2));
|
|
389
428
|
setElementRecord(great, element.folder, element.key, {
|
|
390
429
|
...(id ? { id } : {}),
|
|
391
430
|
...(timestamp ? { timestamp } : {}),
|
|
392
431
|
hash: hashContent(orderedData),
|
|
432
|
+
...(element.provenance && element.provenance.length > 0
|
|
433
|
+
? { provenance: element.provenance }
|
|
434
|
+
: {}),
|
|
393
435
|
});
|
|
436
|
+
writeElementFile(undefined, element.folder, element.key, orderedData, great, fsImpl, element.filePath);
|
|
437
|
+
}
|
|
438
|
+
async function restoreShadowFile(element, graphqlClient, fsImpl, great, log) {
|
|
439
|
+
const remote = element.id
|
|
440
|
+
? await fetchElementById(graphqlClient, element.id, log)
|
|
441
|
+
: undefined;
|
|
442
|
+
if (!remote) {
|
|
443
|
+
log(chalk.red(`Could not restore ${element.folder}/${element.key} from its source — the local changes are kept but not pushed`));
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const data = (remote.content?.data ?? {});
|
|
447
|
+
writeElementFile(undefined, element.folder, element.key, buildShadowData(element, undefined, undefined, data), great, fsImpl, element.filePath);
|
|
448
|
+
log(chalk.yellow(`Restored ${element.folder}/${element.key} from its source — the local changes were discarded`));
|
|
394
449
|
}
|
|
395
450
|
function recordElementProgress(great, element, fields) {
|
|
396
451
|
const existing = getElementRecord(great, element.folder, element.key);
|
|
@@ -402,15 +457,20 @@ function recordElementProgress(great, element, fields) {
|
|
|
402
457
|
function buildRemoteElementsMap(elements) {
|
|
403
458
|
const remoteElements = new Map();
|
|
404
459
|
for (const element of elements) {
|
|
460
|
+
const folder = typeToFolder[element.__typename];
|
|
461
|
+
if (!folder) {
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
405
464
|
remoteElements.set(element.id, {
|
|
406
465
|
id: element.id,
|
|
407
466
|
key: element.key,
|
|
408
|
-
folder
|
|
467
|
+
folder,
|
|
409
468
|
checksum: element.content?.checksum,
|
|
410
469
|
contentCreatedAt: element.content?.createdAt,
|
|
411
470
|
name: element.name,
|
|
412
471
|
description: element.description,
|
|
413
472
|
createdAt: element.createdAt,
|
|
473
|
+
sourceId: element.content?.sourceId,
|
|
414
474
|
sourceTimestamp: element.content?.sourceTimestamp,
|
|
415
475
|
provenance: element.content?.provenance,
|
|
416
476
|
});
|
|
@@ -440,7 +500,7 @@ async function createOrUpdateElement(element, graphqlClient, integrationId, fsIm
|
|
|
440
500
|
}
|
|
441
501
|
else {
|
|
442
502
|
const apiElement = apiElementsMap.get(id);
|
|
443
|
-
if (apiElement) {
|
|
503
|
+
if (apiElement && !isEndpointList(element)) {
|
|
444
504
|
const localName = element.data.name || '';
|
|
445
505
|
const localDesc = element.data.description;
|
|
446
506
|
const apiName = apiElement.name || '';
|
|
@@ -459,11 +519,12 @@ async function createOrUpdateElement(element, graphqlClient, integrationId, fsIm
|
|
|
459
519
|
}
|
|
460
520
|
}
|
|
461
521
|
}
|
|
462
|
-
if (element.source) {
|
|
522
|
+
if (element.source && !element.detach) {
|
|
463
523
|
const remote = apiElementsMap.get(id);
|
|
524
|
+
const sourceChanged = element.source.id !== remote?.sourceId;
|
|
464
525
|
const pinChanged = (element.source.timestamp ?? null) !== (remote?.sourceTimestamp ?? null);
|
|
465
526
|
const provenanceChanged = !sameProvenance(element.provenance, remote?.provenance);
|
|
466
|
-
if (pinChanged || provenanceChanged) {
|
|
527
|
+
if (sourceChanged || pinChanged || provenanceChanged) {
|
|
467
528
|
return includeShadowElement(element, graphqlClient, integrationId, fsImpl, log, great);
|
|
468
529
|
}
|
|
469
530
|
return true;
|
|
@@ -477,7 +538,7 @@ async function createOrUpdateElement(element, graphqlClient, integrationId, fsIm
|
|
|
477
538
|
log(chalk.red(`Failed to prepare content for ${element.key} in ${element.folder}: ${error instanceof Error ? error.message : String(error)}`));
|
|
478
539
|
return false;
|
|
479
540
|
}
|
|
480
|
-
const timestamp = await updateElementContent(graphqlClient, id, content);
|
|
541
|
+
const timestamp = await updateElementContent(graphqlClient, id, content, element.provenance);
|
|
481
542
|
if (!timestamp) {
|
|
482
543
|
log(chalk.red(`Failed to ${element.remoteId ? 'update' : 'set'} content for ${element.key} in ${element.folder}`));
|
|
483
544
|
return false;
|
|
@@ -488,13 +549,10 @@ async function createOrUpdateElement(element, graphqlClient, integrationId, fsIm
|
|
|
488
549
|
const isSecret = content.type === 'secret';
|
|
489
550
|
if (elementType === ElementType.Value && shouldSetValue) {
|
|
490
551
|
if (isSecret && hasRef && !hasValue) {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
if (result.error) {
|
|
494
|
-
log(chalk.red(`Failed to set secret ref for ${element.key}: ${getGraphQLErrorMessage(result.error)}`));
|
|
552
|
+
const success = await setSecretRefForElement(graphqlClient, id, element, log);
|
|
553
|
+
if (!success) {
|
|
495
554
|
return false;
|
|
496
555
|
}
|
|
497
|
-
log(chalk.green(`✓ Secret ref set for element "${element.key}"`));
|
|
498
556
|
}
|
|
499
557
|
else if (hasValue) {
|
|
500
558
|
const valueStr = String(element.data.value);
|
|
@@ -506,19 +564,38 @@ async function createOrUpdateElement(element, graphqlClient, integrationId, fsIm
|
|
|
506
564
|
log(chalk.green(`✓ Value set for element "${element.key}" (${content.type})`));
|
|
507
565
|
}
|
|
508
566
|
}
|
|
509
|
-
updateLocalFile(fsImpl, element, great, element.remoteId ? undefined : id, timestamp, generatedName, !shouldSetValue && hasValue);
|
|
567
|
+
updateLocalFile(fsImpl, element, great, element.remoteId ? undefined : id, timestamp, generatedName, !shouldSetValue && (hasValue || hasRef));
|
|
510
568
|
return true;
|
|
511
569
|
}
|
|
512
570
|
async function deleteElement(element, graphqlClient, log) {
|
|
513
571
|
const result = await graphqlClient.request(DeleteElementMutationDocument, {
|
|
514
572
|
id: element.id,
|
|
515
573
|
});
|
|
516
|
-
if (result.error) {
|
|
574
|
+
if (result.error && !isNotFoundError(result.error)) {
|
|
517
575
|
log(chalk.red(`Failed to delete element ${element.id}`));
|
|
518
576
|
return false;
|
|
519
577
|
}
|
|
520
578
|
return true;
|
|
521
579
|
}
|
|
580
|
+
async function resolveDetaches(toDetach, promptForDetachFn, graphqlClient, fsImpl, great, log) {
|
|
581
|
+
const detached = [];
|
|
582
|
+
for (const element of toDetach) {
|
|
583
|
+
let shouldDetach;
|
|
584
|
+
try {
|
|
585
|
+
shouldDetach = await promptForDetachFn(element, log);
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
590
|
+
if (shouldDetach) {
|
|
591
|
+
detached.push({ ...element, detach: true, provenance: undefined });
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
await restoreShadowFile(element, graphqlClient, fsImpl, great, log);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return detached;
|
|
598
|
+
}
|
|
522
599
|
function buildRemoteImportsMap(templateImports) {
|
|
523
600
|
const map = new Map();
|
|
524
601
|
for (const templateImport of templateImports) {
|
|
@@ -597,12 +674,12 @@ function logSummary(createdCount, includedCount, updatedCount, deletedCount, reg
|
|
|
597
674
|
log(`\n${chalk.green('✓')} ${parts.join(', ')}`);
|
|
598
675
|
}
|
|
599
676
|
}
|
|
600
|
-
export const action = (log, apiToken, client, fsImpl = fs, config, promptForValueSettingFn = promptForValueSetting) => async function pushIntegration(options) {
|
|
677
|
+
export const action = (log, apiToken, client, fsImpl = fs, config, promptForValueSettingFn = promptForValueSetting, promptForDetachFn = promptForDetach) => async function pushIntegration(options) {
|
|
601
678
|
const great = readGreatFile(undefined, fsImpl);
|
|
602
679
|
let integrationId = great.id;
|
|
603
680
|
if (!integrationId) {
|
|
604
681
|
log(chalk.yellow('No integration ID found'));
|
|
605
|
-
log('Creating integration
|
|
682
|
+
log('Creating integration in Integreat...\n');
|
|
606
683
|
const graphqlClient = getClient(apiToken, client, config);
|
|
607
684
|
const result = await createIntegrationFromFile(graphqlClient, apiToken ?? '', options ?? {}, config, fsImpl);
|
|
608
685
|
if (!result.success || !result.integration) {
|
|
@@ -640,7 +717,7 @@ export const action = (log, apiToken, client, fsImpl = fs, config, promptForValu
|
|
|
640
717
|
};
|
|
641
718
|
writeGreatFile(great, undefined, fsImpl);
|
|
642
719
|
integrationId = integration.id;
|
|
643
|
-
log(chalk.green('✓ Updated integration.json with
|
|
720
|
+
log(chalk.green('✓ Updated integration.json with the details from Integreat\n'));
|
|
644
721
|
}
|
|
645
722
|
const graphqlClient = getClient(apiToken, client, config);
|
|
646
723
|
const result = await graphqlClient.request(IntegrationForPushQueryDocument, { id: integrationId });
|
|
@@ -668,14 +745,32 @@ export const action = (log, apiToken, client, fsImpl = fs, config, promptForValu
|
|
|
668
745
|
const record = getElementRecord(great, local.folder, local.key);
|
|
669
746
|
local.id = record?.id;
|
|
670
747
|
local.timestamp = record?.timestamp;
|
|
748
|
+
local.hash = record?.hash;
|
|
671
749
|
local.source = record?.source;
|
|
672
750
|
local.provenance = record?.provenance;
|
|
673
751
|
}
|
|
674
|
-
const
|
|
752
|
+
const serviceNames = new Map(localElements
|
|
753
|
+
.filter((el) => el.folder === 'services' && el.data.name)
|
|
754
|
+
.map((el) => [el.key, String(el.data.name)]));
|
|
755
|
+
for (const local of localElements) {
|
|
756
|
+
if (isEndpointList(local)) {
|
|
757
|
+
local.defaultName = serviceNames.get(local.key);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
for (const warning of validateEndpointReferences(localElements, great)) {
|
|
761
|
+
log(chalk.yellow(`Warning: ${warning}`));
|
|
762
|
+
}
|
|
763
|
+
const { toCreate, toInclude, toUpdate, toDetach, toDelete, conflicts } = categorizeElements(localElements, apiElementsMap);
|
|
675
764
|
if (conflicts.length > 0) {
|
|
676
765
|
handleConflicts(conflicts, log);
|
|
677
766
|
return;
|
|
678
767
|
}
|
|
768
|
+
const detached = await resolveDetaches(toDetach, promptForDetachFn, graphqlClient, fsImpl, great, log);
|
|
769
|
+
if (!detached) {
|
|
770
|
+
log(chalk.yellow('\nPush cancelled'));
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
toUpdate.push(...detached);
|
|
679
774
|
const remoteImportsMap = buildRemoteImportsMap(integration.templateImports ?? []);
|
|
680
775
|
const importsToRegister = findImportsToRegister(great, remoteImportsMap);
|
|
681
776
|
if (toCreate.length +
|
|
@@ -687,7 +782,7 @@ export const action = (log, apiToken, client, fsImpl = fs, config, promptForValu
|
|
|
687
782
|
log(chalk.green('No changes to push'));
|
|
688
783
|
return;
|
|
689
784
|
}
|
|
690
|
-
let shouldSetValue
|
|
785
|
+
let shouldSetValue;
|
|
691
786
|
try {
|
|
692
787
|
shouldSetValue = await promptForValueSettingFn([...toCreate, ...toUpdate], log);
|
|
693
788
|
}
|