@revoengine/cli 1.0.11 → 1.0.12
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 +275 -479
- package/dist/src/cli.js +71 -5
- package/dist/src/client.d.ts +28 -12
- package/dist/src/client.js +234 -66
- package/dist/src/commands/component.d.ts +67 -0
- package/dist/src/commands/component.js +299 -27
- package/dist/src/commands/database-tables.d.ts +2 -0
- package/dist/src/commands/{database-schemas.js → database-tables.js} +21 -40
- package/dist/src/commands/database-views.js +21 -18
- package/dist/src/commands/endpoints.js +26 -16
- package/dist/src/commands/events.js +18 -20
- package/dist/src/commands/groups.js +13 -22
- package/dist/src/commands/index.d.ts +2 -1
- package/dist/src/commands/index.js +2 -1
- package/dist/src/commands/job-templates.js +21 -15
- package/dist/src/commands/metadata.js +58 -15
- package/dist/src/commands/migrate.d.ts +6 -0
- package/dist/src/commands/migrate.js +658 -0
- package/dist/src/commands/project.js +4 -4
- package/dist/src/commands/role-groups.js +14 -25
- package/dist/src/commands/schedules.js +19 -20
- package/dist/src/commands/terminal-browser.d.ts +16 -0
- package/dist/src/commands/terminal-browser.js +92 -0
- package/dist/src/commands/terminal-image.d.ts +7 -0
- package/dist/src/commands/terminal-image.js +40 -0
- package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
- package/dist/src/commands/terminal-patch-worker.js +24 -0
- package/dist/src/commands/terminal-patch.d.ts +2 -0
- package/dist/src/commands/terminal-patch.js +156 -0
- package/dist/src/commands/terminal-sandbox.d.ts +8 -0
- package/dist/src/commands/terminal-sandbox.js +87 -0
- package/dist/src/commands/terminal-service.js +2 -2
- package/dist/src/commands/terminal.d.ts +31 -4
- package/dist/src/commands/terminal.js +360 -45
- package/dist/src/component-lock.d.ts +12 -2
- package/dist/src/component-lock.js +60 -1
- package/dist/src/diff-details.d.ts +8 -0
- package/dist/src/diff-details.js +152 -0
- package/dist/src/env-sync.js +8 -6
- package/dist/src/http-trace.d.ts +94 -0
- package/dist/src/http-trace.js +226 -0
- package/dist/src/metadata-backfill.d.ts +5 -4
- package/dist/src/metadata-backfill.js +82 -158
- package/dist/src/migration.d.ts +141 -0
- package/dist/src/migration.js +1632 -0
- package/dist/src/resource-inventory.d.ts +28 -0
- package/dist/src/resource-inventory.js +85 -0
- package/dist/src/resource-syncs/{database-schema-sync.d.ts → database-table-sync.d.ts} +13 -3
- package/dist/src/resource-syncs/{database-schema-sync.js → database-table-sync.js} +147 -62
- package/dist/src/resource-syncs/database-view-sync.d.ts +24 -2
- package/dist/src/resource-syncs/database-view-sync.js +156 -68
- package/dist/src/resource-syncs/endpoint-sync.d.ts +27 -0
- package/dist/src/resource-syncs/endpoint-sync.js +362 -82
- package/dist/src/resource-syncs/event-sync.d.ts +27 -0
- package/dist/src/resource-syncs/event-sync.js +123 -26
- package/dist/src/resource-syncs/group-sync.d.ts +7 -0
- package/dist/src/resource-syncs/group-sync.js +60 -14
- package/dist/src/resource-syncs/job-template-sync.d.ts +21 -0
- package/dist/src/resource-syncs/job-template-sync.js +91 -30
- package/dist/src/resource-syncs/role-group-sync.d.ts +7 -0
- package/dist/src/resource-syncs/role-group-sync.js +47 -9
- package/dist/src/resource-syncs/schedule-sync.d.ts +30 -1
- package/dist/src/resource-syncs/schedule-sync.js +114 -20
- package/dist/src/resource-syncs/util.d.ts +3 -0
- package/dist/src/resource-syncs/util.js +8 -6
- package/dist/src/resource-target.d.ts +11 -0
- package/dist/src/resource-target.js +48 -0
- package/dist/src/sync-output.d.ts +29 -1
- package/dist/src/sync-output.js +139 -2
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +8 -6
- package/dist/src/types.d.ts +3 -0
- package/dist/src/ui.js +18 -9
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.js +17 -0
- package/dist/src/workspace-diff.d.ts +25 -0
- package/dist/src/workspace-diff.js +75 -0
- package/package.json +9 -6
- package/dist/src/commands/database-schemas.d.ts +0 -2
- /package/dist/src/{database-schema-artifacts.d.ts → database-table-artifacts.d.ts} +0 -0
- /package/dist/src/{database-schema-artifacts.js → database-table-artifacts.js} +0 -0
package/dist/src/client.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { setTimeout as waitForDelay } from 'node:timers/promises';
|
|
1
2
|
import { AUTH_VALIDATION_TTL_MS, buildAuthValidationKey, DEFAULT_BASE_URL, readAuthValidationState, resolveRuntimeConfig, saveAuthValidationState, } from "./config.js";
|
|
3
|
+
import { beginHttpTraceRequest, completeHttpTraceRequest, responseSize, } from "./http-trace.js";
|
|
2
4
|
import { isInteractiveTerminal, promptConfirm } from "./prompt.js";
|
|
3
5
|
import { createSpinner } from "./spinner.js";
|
|
6
|
+
import { mapWithConcurrency } from "./utils.js";
|
|
4
7
|
export class ApiError extends Error {
|
|
5
8
|
status;
|
|
6
9
|
data;
|
|
@@ -13,6 +16,16 @@ export class ApiError extends Error {
|
|
|
13
16
|
this.headers = headers;
|
|
14
17
|
}
|
|
15
18
|
}
|
|
19
|
+
export class RequestTimeoutError extends Error {
|
|
20
|
+
timeoutMs;
|
|
21
|
+
path;
|
|
22
|
+
constructor(timeoutMs, path) {
|
|
23
|
+
super(`Request timed out after ${timeoutMs} ms for ${path}.`);
|
|
24
|
+
this.name = 'RequestTimeoutError';
|
|
25
|
+
this.timeoutMs = timeoutMs;
|
|
26
|
+
this.path = path;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
export class AuthenticationError extends ApiError {
|
|
17
30
|
constructor(status, message, data, headers) {
|
|
18
31
|
super(status, message, data, headers);
|
|
@@ -284,8 +297,8 @@ function toErrorMessage(responseText, status) {
|
|
|
284
297
|
const trimmed = responseText.trim();
|
|
285
298
|
return trimmed ? `${status} ${trimmed}` : `HTTP ${status}`;
|
|
286
299
|
}
|
|
287
|
-
function delay(ms) {
|
|
288
|
-
return
|
|
300
|
+
function delay(ms, signal) {
|
|
301
|
+
return waitForDelay(ms, undefined, { signal });
|
|
289
302
|
}
|
|
290
303
|
async function readResponseData(response) {
|
|
291
304
|
const text = await response.text();
|
|
@@ -399,19 +412,25 @@ export class RevoClient {
|
|
|
399
412
|
instance;
|
|
400
413
|
token;
|
|
401
414
|
production;
|
|
415
|
+
environmentName;
|
|
402
416
|
fetchImpl;
|
|
403
417
|
productionWriteConfirmed = false;
|
|
404
418
|
confirmProductionWrite;
|
|
405
419
|
trustedServiceOrigins;
|
|
420
|
+
maxRetries;
|
|
421
|
+
retryDelayMs;
|
|
406
422
|
constructor(options = {}) {
|
|
407
423
|
const config = resolveRuntimeConfig(options);
|
|
408
424
|
this.baseUrl = config.baseUrl;
|
|
409
425
|
this.instance = config.instance || '';
|
|
410
426
|
this.token = config.token;
|
|
411
427
|
this.production = options.production === true || config.production === true;
|
|
428
|
+
this.environmentName = options.environmentName || options.envName || '';
|
|
412
429
|
this.fetchImpl = options.fetch || globalThis.fetch;
|
|
413
430
|
this.confirmProductionWrite = options.confirmProductionWrite || confirmProductionWriteInTerminal;
|
|
414
431
|
this.trustedServiceOrigins = resolveTrustedServiceOrigins(options.trustedServiceOrigins);
|
|
432
|
+
this.maxRetries = options.maxRetries ?? 0;
|
|
433
|
+
this.retryDelayMs = options.retryDelayMs ?? 100;
|
|
415
434
|
}
|
|
416
435
|
get authHeader() {
|
|
417
436
|
return normalizeToken(this.token);
|
|
@@ -510,45 +529,133 @@ export class RevoClient {
|
|
|
510
529
|
const timeout = abortController
|
|
511
530
|
? setTimeout(() => abortController.abort(), options.timeoutMs)
|
|
512
531
|
: undefined;
|
|
532
|
+
const traceRequest = beginHttpTraceRequest({
|
|
533
|
+
method,
|
|
534
|
+
url,
|
|
535
|
+
body: body,
|
|
536
|
+
context: this.environmentName ? { environment: this.environmentName } : undefined,
|
|
537
|
+
});
|
|
538
|
+
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
539
|
+
const baseRetryDelay = options.retryDelayMs ?? this.retryDelayMs;
|
|
540
|
+
const normalizedMethod = method.toUpperCase();
|
|
513
541
|
spinner.start();
|
|
514
542
|
try {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
543
|
+
let lastError;
|
|
544
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
545
|
+
if (attempt > 0) {
|
|
546
|
+
const backoff = baseRetryDelay * Math.pow(2, attempt - 1) + Math.floor(Math.random() * 25);
|
|
547
|
+
await delay(backoff, abortController?.signal);
|
|
548
|
+
}
|
|
549
|
+
await delay(REQUEST_DELAY_MS, abortController?.signal);
|
|
550
|
+
let response;
|
|
551
|
+
try {
|
|
552
|
+
response = await this.fetchImpl(url, {
|
|
553
|
+
method: normalizedMethod,
|
|
554
|
+
headers,
|
|
555
|
+
body: body,
|
|
556
|
+
redirect: 'manual',
|
|
557
|
+
...(abortController ? { signal: abortController.signal } : {}),
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
lastError = error;
|
|
562
|
+
if (attempt < maxRetries && !abortController?.signal.aborted) {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
completeHttpTraceRequest(traceRequest, { ok: false, error });
|
|
566
|
+
throw error;
|
|
567
|
+
}
|
|
568
|
+
try {
|
|
569
|
+
assertNoAuthenticatedRedirect(response);
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
completeHttpTraceRequest(traceRequest, {
|
|
573
|
+
status: response.status,
|
|
574
|
+
ok: false,
|
|
575
|
+
responseHeaders: response.headers,
|
|
576
|
+
error,
|
|
577
|
+
});
|
|
578
|
+
throw error;
|
|
579
|
+
}
|
|
580
|
+
let data;
|
|
581
|
+
try {
|
|
582
|
+
data = await readResponseData(response);
|
|
583
|
+
}
|
|
584
|
+
catch (error) {
|
|
585
|
+
lastError = error;
|
|
586
|
+
if (attempt < maxRetries && !abortController?.signal.aborted) {
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
completeHttpTraceRequest(traceRequest, {
|
|
590
|
+
status: response.status,
|
|
591
|
+
ok: false,
|
|
592
|
+
responseHeaders: response.headers,
|
|
593
|
+
error,
|
|
531
594
|
});
|
|
532
|
-
throw
|
|
595
|
+
throw error;
|
|
533
596
|
}
|
|
534
|
-
|
|
535
|
-
|
|
597
|
+
const isRetryableStatus = [429, 502, 503, 504].includes(response.status)
|
|
598
|
+
|| (response.status === 500 && ['GET', 'HEAD', 'OPTIONS'].includes(normalizedMethod));
|
|
599
|
+
if (!response.ok && response.status !== 304 && isRetryableStatus && attempt < maxRetries && !abortController?.signal.aborted) {
|
|
600
|
+
let retryAfterMs = 0;
|
|
601
|
+
const retryAfterHeader = response.headers.get('retry-after');
|
|
602
|
+
if (retryAfterHeader) {
|
|
603
|
+
const seconds = Number(retryAfterHeader);
|
|
604
|
+
if (!Number.isNaN(seconds) && seconds > 0) {
|
|
605
|
+
retryAfterMs = seconds * 1000;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (retryAfterMs > 0) {
|
|
609
|
+
await delay(Math.min(5000, retryAfterMs), abortController?.signal);
|
|
610
|
+
}
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
const accepted = response.ok || response.status === 304;
|
|
614
|
+
completeHttpTraceRequest(traceRequest, {
|
|
615
|
+
status: response.status,
|
|
616
|
+
ok: accepted,
|
|
617
|
+
responseHeaders: response.headers,
|
|
618
|
+
responseData: data,
|
|
619
|
+
responseBytes: responseSize(data, response.headers),
|
|
620
|
+
});
|
|
621
|
+
if (!response.ok && response.status !== 304) {
|
|
622
|
+
if (response.status === 401) {
|
|
623
|
+
saveAuthValidationState({
|
|
624
|
+
key: this.authValidationKey,
|
|
625
|
+
status: 'not_authenticated',
|
|
626
|
+
checkedAt: Date.now(),
|
|
627
|
+
});
|
|
628
|
+
throw new AuthenticationError(401, 'Not authenticated. Run `revo auth login`.', data, response.headers);
|
|
629
|
+
}
|
|
630
|
+
if (response.status === 403 && path !== '/api/v1/me') {
|
|
631
|
+
throw new PermissionDeniedError(path, `Access denied for ${path}.`, data, response.headers);
|
|
632
|
+
}
|
|
633
|
+
throw new ApiError(response.status, toErrorMessage(typeof data === 'string' ? data : JSON.stringify(data), response.status), data, response.headers);
|
|
536
634
|
}
|
|
537
|
-
|
|
635
|
+
const previous = readAuthValidationState(this.authValidationKey);
|
|
636
|
+
saveAuthValidationState({
|
|
637
|
+
key: this.authValidationKey,
|
|
638
|
+
status: 'authenticated',
|
|
639
|
+
checkedAt: Date.now(),
|
|
640
|
+
profile: previous && previous.key === this.authValidationKey ? previous.profile : undefined,
|
|
641
|
+
});
|
|
642
|
+
return {
|
|
643
|
+
status: response.status,
|
|
644
|
+
ok: response.ok,
|
|
645
|
+
data,
|
|
646
|
+
headers: response.headers,
|
|
647
|
+
};
|
|
538
648
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
data,
|
|
550
|
-
headers: response.headers,
|
|
551
|
-
};
|
|
649
|
+
if (lastError) {
|
|
650
|
+
throw lastError;
|
|
651
|
+
}
|
|
652
|
+
throw new Error(`Request failed after ${maxRetries} retries`);
|
|
653
|
+
}
|
|
654
|
+
catch (error) {
|
|
655
|
+
if (abortController?.signal.aborted && options.timeoutMs !== undefined) {
|
|
656
|
+
throw new RequestTimeoutError(options.timeoutMs, path);
|
|
657
|
+
}
|
|
658
|
+
throw error;
|
|
552
659
|
}
|
|
553
660
|
finally {
|
|
554
661
|
if (timeout) {
|
|
@@ -798,36 +905,70 @@ export class RevoClient {
|
|
|
798
905
|
}
|
|
799
906
|
}
|
|
800
907
|
}
|
|
801
|
-
async getDatabaseView(databaseViewId) {
|
|
802
|
-
return this.requestData('GET', `/api/v1/databases/views/${encodeURIComponent(databaseViewId)}
|
|
908
|
+
async getDatabaseView(databaseViewId, options = {}) {
|
|
909
|
+
return this.requestData('GET', `/api/v1/databases/views/${encodeURIComponent(databaseViewId)}`, options);
|
|
803
910
|
}
|
|
804
911
|
async listAllDatabaseViewsForSync() {
|
|
805
912
|
const summaries = await this.listAllDatabaseViews();
|
|
806
913
|
const activeSummaries = summaries.filter((view) => !view.deletedAt && !view.deletedBy);
|
|
807
914
|
const seenIds = new Set();
|
|
808
|
-
const
|
|
915
|
+
const uniqueSummaries = activeSummaries.filter((summary) => {
|
|
809
916
|
const databaseViewId = String(summary.databaseViewId || summary.id || '');
|
|
810
917
|
if (!databaseViewId || seenIds.has(databaseViewId)) {
|
|
811
|
-
return
|
|
918
|
+
return false;
|
|
812
919
|
}
|
|
813
920
|
seenIds.add(databaseViewId);
|
|
814
|
-
|
|
921
|
+
return true;
|
|
922
|
+
});
|
|
923
|
+
const records = await mapWithConcurrency(uniqueSummaries, async (summary) => {
|
|
924
|
+
const databaseViewId = String(summary.databaseViewId || summary.id || '');
|
|
925
|
+
const response = await this.getDatabaseView(databaseViewId, { maxRetries: 2 });
|
|
815
926
|
if (isRecord(response) && isRecord(response.data)) {
|
|
816
927
|
return response.data;
|
|
817
928
|
}
|
|
818
929
|
return response;
|
|
819
|
-
})
|
|
930
|
+
});
|
|
820
931
|
return records
|
|
821
932
|
.filter((record) => record !== undefined && !record.deletedAt && !record.deletedBy)
|
|
822
933
|
.sort((left, right) => String(left.databaseViewId || left.id || '').localeCompare(String(right.databaseViewId || right.id || '')));
|
|
823
934
|
}
|
|
824
935
|
async previewDatabaseView(body) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
936
|
+
try {
|
|
937
|
+
return await this.requestData('POST', '/api/v1/databases/views/preview', {
|
|
938
|
+
body,
|
|
939
|
+
productionWrite: false,
|
|
940
|
+
spinnerLabel: 'Previewing Database View',
|
|
941
|
+
timeoutMs: 30_000,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
catch (error) {
|
|
945
|
+
const status = error instanceof ApiError ? `HTTP ${error.status}` : 'no HTTP status';
|
|
946
|
+
const timeout = error instanceof RequestTimeoutError ? `timeout after ${error.timeoutMs} ms` : 'timeout: no';
|
|
947
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
948
|
+
if (error instanceof ApiError) {
|
|
949
|
+
message = error instanceof AuthenticationError || error instanceof PermissionDeniedError ? error.message : 'Request failed.';
|
|
950
|
+
const data = error.data;
|
|
951
|
+
const backendMessage = typeof data === 'string' ? data
|
|
952
|
+
: data && typeof data === 'object' && 'message' in data ? data.message : undefined;
|
|
953
|
+
if (typeof backendMessage === 'string') {
|
|
954
|
+
message = backendMessage;
|
|
955
|
+
}
|
|
956
|
+
else if (Array.isArray(backendMessage) && backendMessage.every((part) => typeof part === 'string')) {
|
|
957
|
+
message = backendMessage.join('; ');
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
// Only expose the explanatory message, not arbitrary response data or headers.
|
|
961
|
+
message = message.replace(/[\u0000-\u001f\u007f]/g, ' ').slice(0, 2000);
|
|
962
|
+
const rawSqlHint = body.definitionMode === 'RAW_SQL'
|
|
963
|
+
? ' Check whether RAW SQL Database Views are enabled for this instance.'
|
|
964
|
+
: '';
|
|
965
|
+
const detail = `${body.definitionMode}; ${status}; ${timeout}: ${message}${rawSqlHint}`;
|
|
966
|
+
if (error instanceof Error) {
|
|
967
|
+
error.message = detail;
|
|
968
|
+
throw error;
|
|
969
|
+
}
|
|
970
|
+
throw new Error(detail, { cause: error });
|
|
971
|
+
}
|
|
831
972
|
}
|
|
832
973
|
async createDatabaseView(body) {
|
|
833
974
|
return this.requestData('POST', '/api/v1/databases/views', {
|
|
@@ -881,8 +1022,8 @@ export class RevoClient {
|
|
|
881
1022
|
}
|
|
882
1023
|
return { endpoints, discoveredTotal };
|
|
883
1024
|
}
|
|
884
|
-
async getEndpoint(endpointId) {
|
|
885
|
-
return this.requestData('GET', `/api/v1/endpoints/${encodeURIComponent(endpointId)}
|
|
1025
|
+
async getEndpoint(endpointId, options = {}) {
|
|
1026
|
+
return this.requestData('GET', `/api/v1/endpoints/${encodeURIComponent(endpointId)}`, options);
|
|
886
1027
|
}
|
|
887
1028
|
async createEndpoint(body) {
|
|
888
1029
|
return this.requestData('POST', '/api/v1/endpoints', {
|
|
@@ -942,15 +1083,36 @@ export class RevoClient {
|
|
|
942
1083
|
headers.set('instance', this.instance);
|
|
943
1084
|
headers.set('x-api-instance', this.instance);
|
|
944
1085
|
}
|
|
945
|
-
const
|
|
1086
|
+
const serializedBody = JSON.stringify(body);
|
|
1087
|
+
const traceRequest = beginHttpTraceRequest({
|
|
946
1088
|
method: 'POST',
|
|
947
|
-
|
|
948
|
-
body:
|
|
949
|
-
|
|
1089
|
+
url,
|
|
1090
|
+
body: serializedBody,
|
|
1091
|
+
context: this.environmentName ? { environment: this.environmentName } : undefined,
|
|
950
1092
|
});
|
|
951
|
-
|
|
1093
|
+
let response;
|
|
1094
|
+
try {
|
|
1095
|
+
response = await this.fetchImpl(url, {
|
|
1096
|
+
method: 'POST',
|
|
1097
|
+
headers,
|
|
1098
|
+
body: serializedBody,
|
|
1099
|
+
redirect: 'manual',
|
|
1100
|
+
});
|
|
1101
|
+
assertNoAuthenticatedRedirect(response);
|
|
1102
|
+
}
|
|
1103
|
+
catch (error) {
|
|
1104
|
+
completeHttpTraceRequest(traceRequest, { ok: false, error });
|
|
1105
|
+
throw error;
|
|
1106
|
+
}
|
|
952
1107
|
if (!response.ok) {
|
|
953
1108
|
const data = await readResponseData(response);
|
|
1109
|
+
completeHttpTraceRequest(traceRequest, {
|
|
1110
|
+
status: response.status,
|
|
1111
|
+
ok: false,
|
|
1112
|
+
responseHeaders: response.headers,
|
|
1113
|
+
responseData: data,
|
|
1114
|
+
responseBytes: responseSize(data, response.headers),
|
|
1115
|
+
});
|
|
954
1116
|
if (response.status === 401) {
|
|
955
1117
|
saveAuthValidationState({
|
|
956
1118
|
key: this.authValidationKey,
|
|
@@ -964,6 +1126,12 @@ export class RevoClient {
|
|
|
964
1126
|
}
|
|
965
1127
|
throw new ApiError(response.status, toErrorMessage(typeof data === 'string' ? data : JSON.stringify(data), response.status), data, response.headers);
|
|
966
1128
|
}
|
|
1129
|
+
completeHttpTraceRequest(traceRequest, {
|
|
1130
|
+
status: response.status,
|
|
1131
|
+
ok: true,
|
|
1132
|
+
responseHeaders: response.headers,
|
|
1133
|
+
responseBytes: responseSize(undefined, response.headers),
|
|
1134
|
+
});
|
|
967
1135
|
for await (const event of readSseEvents(response)) {
|
|
968
1136
|
yield event;
|
|
969
1137
|
}
|
|
@@ -1019,8 +1187,8 @@ export class RevoClient {
|
|
|
1019
1187
|
}
|
|
1020
1188
|
return { components, discoveredTotal };
|
|
1021
1189
|
}
|
|
1022
|
-
async getComponent(componentId) {
|
|
1023
|
-
return this.requestData('GET', `/api/v1/component/${componentId}
|
|
1190
|
+
async getComponent(componentId, options = {}) {
|
|
1191
|
+
return this.requestData('GET', `/api/v1/component/${componentId}`, options);
|
|
1024
1192
|
}
|
|
1025
1193
|
async createComponent(body) {
|
|
1026
1194
|
return this.requestData('POST', '/api/v1/component', {
|
|
@@ -1082,8 +1250,8 @@ export class RevoClient {
|
|
|
1082
1250
|
}
|
|
1083
1251
|
return { roleGroups, discoveredTotal };
|
|
1084
1252
|
}
|
|
1085
|
-
async getRoleGroup(roleGroupId) {
|
|
1086
|
-
return this.requestData('GET', `/api/v1/role-groups/${roleGroupId}
|
|
1253
|
+
async getRoleGroup(roleGroupId, options = {}) {
|
|
1254
|
+
return this.requestData('GET', `/api/v1/role-groups/${roleGroupId}`, options);
|
|
1087
1255
|
}
|
|
1088
1256
|
async listGroups(options = {}) {
|
|
1089
1257
|
return this.requestData('GET', options.path || '/api/v1/groups', {
|
|
@@ -1128,8 +1296,8 @@ export class RevoClient {
|
|
|
1128
1296
|
}
|
|
1129
1297
|
return { groups, discoveredTotal };
|
|
1130
1298
|
}
|
|
1131
|
-
async getGroup(groupId) {
|
|
1132
|
-
return this.requestData('GET', `/api/v1/groups/${groupId}
|
|
1299
|
+
async getGroup(groupId, options = {}) {
|
|
1300
|
+
return this.requestData('GET', `/api/v1/groups/${groupId}`, options);
|
|
1133
1301
|
}
|
|
1134
1302
|
async listJobTemplates(options = {}) {
|
|
1135
1303
|
return this.requestData('GET', options.path || '/api/v1/automation/template', {
|
|
@@ -1172,8 +1340,8 @@ export class RevoClient {
|
|
|
1172
1340
|
}
|
|
1173
1341
|
return { jobTemplates, discoveredTotal };
|
|
1174
1342
|
}
|
|
1175
|
-
async getJobTemplate(jobTemplateId) {
|
|
1176
|
-
return this.requestData('GET', `/api/v1/automation/template/${jobTemplateId}
|
|
1343
|
+
async getJobTemplate(jobTemplateId, options = {}) {
|
|
1344
|
+
return this.requestData('GET', `/api/v1/automation/template/${jobTemplateId}`, options);
|
|
1177
1345
|
}
|
|
1178
1346
|
async createJobTemplate(body) {
|
|
1179
1347
|
return this.requestData('POST', '/api/v1/automation/template', {
|
|
@@ -1228,8 +1396,8 @@ export class RevoClient {
|
|
|
1228
1396
|
}
|
|
1229
1397
|
return { schedules, discoveredTotal };
|
|
1230
1398
|
}
|
|
1231
|
-
async getSchedule(scheduleId) {
|
|
1232
|
-
return this.requestData('GET', `/api/v1/automation/schedule/${scheduleId}
|
|
1399
|
+
async getSchedule(scheduleId, options = {}) {
|
|
1400
|
+
return this.requestData('GET', `/api/v1/automation/schedule/${scheduleId}`, options);
|
|
1233
1401
|
}
|
|
1234
1402
|
async createSchedule(body) {
|
|
1235
1403
|
return this.requestData('POST', '/api/v1/automation/schedule', {
|
|
@@ -1299,8 +1467,8 @@ export class RevoClient {
|
|
|
1299
1467
|
}
|
|
1300
1468
|
return { events, discoveredTotal };
|
|
1301
1469
|
}
|
|
1302
|
-
async getEvent(eventId) {
|
|
1303
|
-
return this.requestData('GET', `/api/v1/automation/event/${eventId}
|
|
1470
|
+
async getEvent(eventId, options = {}) {
|
|
1471
|
+
return this.requestData('GET', `/api/v1/automation/event/${eventId}`, options);
|
|
1304
1472
|
}
|
|
1305
1473
|
async createEvent(body) {
|
|
1306
1474
|
return this.requestData('POST', '/api/v1/automation/event', {
|
|
@@ -1,2 +1,69 @@
|
|
|
1
|
+
import { type FieldChange } from '../diff-details.ts';
|
|
2
|
+
import { type ComponentIdentityConfig } from '../resource-metadata.ts';
|
|
3
|
+
import { type WorkspaceSyncResult as SyncResult } from '../sync-output.ts';
|
|
1
4
|
import type { CommandContext } from '../types.ts';
|
|
5
|
+
export type ComponentPlanStatus = 'clean' | 'local-changed' | 'remote-changed' | 'safe-update' | 'conflict' | 'create' | 'delete' | 'missing-lock' | 'blocked';
|
|
6
|
+
export type ComponentPlanItem = {
|
|
7
|
+
componentId: string;
|
|
8
|
+
identityKey?: string;
|
|
9
|
+
stableKey?: string;
|
|
10
|
+
remoteComponentId?: string;
|
|
11
|
+
lockRemoteComponentId?: string;
|
|
12
|
+
componentName: string;
|
|
13
|
+
componentType: string;
|
|
14
|
+
category: string | null;
|
|
15
|
+
path: string;
|
|
16
|
+
status: ComponentPlanStatus;
|
|
17
|
+
localHash: string | null;
|
|
18
|
+
lockHash: string | null;
|
|
19
|
+
remoteHash: string | null;
|
|
20
|
+
remoteVersion: number | null;
|
|
21
|
+
reason: string;
|
|
22
|
+
changedFields?: string[];
|
|
23
|
+
fieldChanges?: FieldChange[];
|
|
24
|
+
codeDiffs?: Array<{
|
|
25
|
+
element: string;
|
|
26
|
+
lines: string[];
|
|
27
|
+
}>;
|
|
28
|
+
blocked?: boolean;
|
|
29
|
+
inScope?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type ComponentPlan = {
|
|
32
|
+
schemaVersion: 1;
|
|
33
|
+
generatedAt: string;
|
|
34
|
+
workspaceRoot: string;
|
|
35
|
+
componentIdentity: ComponentIdentityConfig;
|
|
36
|
+
unmanaged: {
|
|
37
|
+
local: number;
|
|
38
|
+
remote: number;
|
|
39
|
+
};
|
|
40
|
+
scope?: {
|
|
41
|
+
mode: 'changed';
|
|
42
|
+
base: string;
|
|
43
|
+
componentIds: string[];
|
|
44
|
+
};
|
|
45
|
+
counts: Record<ComponentPlanStatus, number>;
|
|
46
|
+
items: ComponentPlanItem[];
|
|
47
|
+
blockers: string[];
|
|
48
|
+
};
|
|
49
|
+
export type ComponentSyncResult = SyncResult;
|
|
50
|
+
type ChangedScope = {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
base: string;
|
|
53
|
+
componentIds: Set<string>;
|
|
54
|
+
};
|
|
55
|
+
export declare function pullAllComponents(context: CommandContext, options: {
|
|
56
|
+
force: boolean;
|
|
57
|
+
stale: boolean;
|
|
58
|
+
yes: boolean;
|
|
59
|
+
pruneOrphans?: boolean;
|
|
60
|
+
}): Promise<SyncResult[]>;
|
|
61
|
+
export declare function pushAllComponents(context: CommandContext, options: {
|
|
62
|
+
force: boolean;
|
|
63
|
+
yes: boolean;
|
|
64
|
+
prune?: boolean;
|
|
65
|
+
scope?: ChangedScope;
|
|
66
|
+
}): Promise<SyncResult[]>;
|
|
67
|
+
export declare function buildComponentPlan(context: CommandContext, scope?: ChangedScope, includeDiffDetails?: boolean, prune?: boolean): Promise<ComponentPlan>;
|
|
2
68
|
export declare function handleComponentCommand(context: CommandContext): Promise<void>;
|
|
69
|
+
export {};
|