@syntero/orca-cli 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant.d.ts +17 -3
- package/dist/assistant.d.ts.map +1 -1
- package/dist/assistant.js +217 -22
- package/dist/assistant.js.map +1 -1
- package/dist/auth.d.ts +97 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +437 -0
- package/dist/auth.js.map +1 -0
- package/dist/autocomplete.d.ts +24 -0
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete.js +43 -0
- package/dist/autocomplete.js.map +1 -0
- package/dist/components/ChatApp.d.ts +32 -0
- package/dist/components/ChatApp.d.ts.map +1 -0
- package/dist/components/ChatApp.js +470 -0
- package/dist/components/ChatApp.js.map +1 -0
- package/dist/components/CommandPalette.d.ts +15 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +22 -0
- package/dist/components/CommandPalette.js.map +1 -0
- package/dist/components/ConfigWizard.d.ts +25 -0
- package/dist/components/ConfigWizard.d.ts.map +1 -0
- package/dist/components/ConfigWizard.js +401 -0
- package/dist/components/ConfigWizard.js.map +1 -0
- package/dist/components/InputFooter.d.ts +33 -0
- package/dist/components/InputFooter.d.ts.map +1 -0
- package/dist/components/InputFooter.js +618 -0
- package/dist/components/InputFooter.js.map +1 -0
- package/dist/components/InputModal.d.ts +25 -0
- package/dist/components/InputModal.d.ts.map +1 -0
- package/dist/components/InputModal.js +529 -0
- package/dist/components/InputModal.js.map +1 -0
- package/dist/components/ModelMenu.d.ts +24 -0
- package/dist/components/ModelMenu.d.ts.map +1 -0
- package/dist/components/ModelMenu.js +175 -0
- package/dist/components/ModelMenu.js.map +1 -0
- package/dist/components/ProviderMenu.d.ts +20 -0
- package/dist/components/ProviderMenu.d.ts.map +1 -0
- package/dist/components/ProviderMenu.js +31 -0
- package/dist/components/ProviderMenu.js.map +1 -0
- package/dist/components/SyncMenu.d.ts +23 -0
- package/dist/components/SyncMenu.d.ts.map +1 -0
- package/dist/components/SyncMenu.js +135 -0
- package/dist/components/SyncMenu.js.map +1 -0
- package/dist/components/TokenInput.d.ts +15 -0
- package/dist/components/TokenInput.d.ts.map +1 -0
- package/dist/components/TokenInput.js +103 -0
- package/dist/components/TokenInput.js.map +1 -0
- package/dist/index.js +323 -173
- package/dist/index.js.map +1 -1
- package/dist/ink-input.d.ts +14 -0
- package/dist/ink-input.d.ts.map +1 -0
- package/dist/ink-input.js +92 -0
- package/dist/ink-input.js.map +1 -0
- package/dist/models.d.ts +115 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +221 -0
- package/dist/models.js.map +1 -0
- package/dist/providers.d.ts +19 -4
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +80 -112
- package/dist/providers.js.map +1 -1
- package/dist/settings.d.ts +15 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +56 -21
- package/dist/settings.js.map +1 -1
- package/dist/sync/docker.d.ts +68 -0
- package/dist/sync/docker.d.ts.map +1 -0
- package/dist/sync/docker.js +234 -0
- package/dist/sync/docker.js.map +1 -0
- package/dist/sync/download.d.ts +87 -0
- package/dist/sync/download.d.ts.map +1 -0
- package/dist/sync/download.js +291 -0
- package/dist/sync/download.js.map +1 -0
- package/dist/sync/hash.d.ts +60 -0
- package/dist/sync/hash.d.ts.map +1 -0
- package/dist/sync/hash.js +92 -0
- package/dist/sync/hash.js.map +1 -0
- package/dist/sync/index.d.ts +15 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +21 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/manifest.d.ts +132 -0
- package/dist/sync/manifest.d.ts.map +1 -0
- package/dist/sync/manifest.js +260 -0
- package/dist/sync/manifest.js.map +1 -0
- package/dist/sync/progress.d.ts +164 -0
- package/dist/sync/progress.d.ts.map +1 -0
- package/dist/sync/progress.js +233 -0
- package/dist/sync/progress.js.map +1 -0
- package/dist/sync/services.d.ts +70 -0
- package/dist/sync/services.d.ts.map +1 -0
- package/dist/sync/services.js +134 -0
- package/dist/sync/services.js.map +1 -0
- package/dist/sync/sync-engine.d.ts +69 -0
- package/dist/sync/sync-engine.d.ts.map +1 -0
- package/dist/sync/sync-engine.js +533 -0
- package/dist/sync/sync-engine.js.map +1 -0
- package/dist/tokens.d.ts +70 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +198 -0
- package/dist/tokens.js.map +1 -0
- package/dist/tools.d.ts +60 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +34 -0
- package/dist/tools.js.map +1 -1
- package/dist/types/sync.d.ts +284 -0
- package/dist/types/sync.d.ts.map +1 -0
- package/dist/types/sync.js +5 -0
- package/dist/types/sync.js.map +1 -0
- package/package.json +10 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash utilities for library sync.
|
|
3
|
+
* Provides functions for SHA-256 hashing of files and content.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Compute SHA-256 hash of file content.
|
|
7
|
+
* Uses streaming for memory efficiency with large files.
|
|
8
|
+
*
|
|
9
|
+
* @param filePath Path to file on host filesystem
|
|
10
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
11
|
+
*/
|
|
12
|
+
export declare function hashFile(filePath: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Compute SHA-256 hash of Buffer content.
|
|
15
|
+
*
|
|
16
|
+
* @param content Buffer to hash
|
|
17
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
18
|
+
*/
|
|
19
|
+
export declare function hashBuffer(content: Buffer): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compute SHA-256 hash of string content.
|
|
22
|
+
*
|
|
23
|
+
* @param content String to hash
|
|
24
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
25
|
+
*/
|
|
26
|
+
export declare function hashString(content: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Compute combined solution hash from file hashes.
|
|
29
|
+
* Deterministic: sorted by path, concatenated, then hashed.
|
|
30
|
+
*
|
|
31
|
+
* @param files Array of objects with path and hash properties
|
|
32
|
+
* @returns Combined SHA-256 hash prefixed with 'sha256:'
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeSolutionHash(files: {
|
|
35
|
+
path: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
}[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Verify that content matches expected hash.
|
|
40
|
+
*
|
|
41
|
+
* @param content Buffer to verify
|
|
42
|
+
* @param expectedHash Expected hash (prefixed with 'sha256:')
|
|
43
|
+
* @returns True if hash matches
|
|
44
|
+
*/
|
|
45
|
+
export declare function verifyHash(content: Buffer, expectedHash: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Strip the hash prefix (sha256:) from a hash string.
|
|
48
|
+
*
|
|
49
|
+
* @param hash Hash string with or without prefix
|
|
50
|
+
* @returns Hash string without prefix
|
|
51
|
+
*/
|
|
52
|
+
export declare function stripHashPrefix(hash: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Add the hash prefix (sha256:) to a hash string if not present.
|
|
55
|
+
*
|
|
56
|
+
* @param hash Hash string with or without prefix
|
|
57
|
+
* @returns Hash string with prefix
|
|
58
|
+
*/
|
|
59
|
+
export declare function ensureHashPrefix(hash: string): string;
|
|
60
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/sync/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAShE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,MAAM,CAInF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAGzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash utilities for library sync.
|
|
3
|
+
* Provides functions for SHA-256 hashing of files and content.
|
|
4
|
+
*/
|
|
5
|
+
import * as crypto from 'crypto';
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
/**
|
|
8
|
+
* Compute SHA-256 hash of file content.
|
|
9
|
+
* Uses streaming for memory efficiency with large files.
|
|
10
|
+
*
|
|
11
|
+
* @param filePath Path to file on host filesystem
|
|
12
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
13
|
+
*/
|
|
14
|
+
export async function hashFile(filePath) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const hash = crypto.createHash('sha256');
|
|
17
|
+
const stream = fs.createReadStream(filePath);
|
|
18
|
+
stream.on('data', (chunk) => hash.update(chunk));
|
|
19
|
+
stream.on('end', () => resolve(`sha256:${hash.digest('hex')}`));
|
|
20
|
+
stream.on('error', reject);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Compute SHA-256 hash of Buffer content.
|
|
25
|
+
*
|
|
26
|
+
* @param content Buffer to hash
|
|
27
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
28
|
+
*/
|
|
29
|
+
export function hashBuffer(content) {
|
|
30
|
+
const hash = crypto.createHash('sha256');
|
|
31
|
+
hash.update(content);
|
|
32
|
+
return `sha256:${hash.digest('hex')}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compute SHA-256 hash of string content.
|
|
36
|
+
*
|
|
37
|
+
* @param content String to hash
|
|
38
|
+
* @returns SHA-256 hash prefixed with 'sha256:'
|
|
39
|
+
*/
|
|
40
|
+
export function hashString(content) {
|
|
41
|
+
const hash = crypto.createHash('sha256');
|
|
42
|
+
hash.update(content, 'utf8');
|
|
43
|
+
return `sha256:${hash.digest('hex')}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compute combined solution hash from file hashes.
|
|
47
|
+
* Deterministic: sorted by path, concatenated, then hashed.
|
|
48
|
+
*
|
|
49
|
+
* @param files Array of objects with path and hash properties
|
|
50
|
+
* @returns Combined SHA-256 hash prefixed with 'sha256:'
|
|
51
|
+
*/
|
|
52
|
+
export function computeSolutionHash(files) {
|
|
53
|
+
const sorted = [...files].sort((a, b) => a.path.localeCompare(b.path));
|
|
54
|
+
const combined = sorted.map(f => `${f.path}:${f.hash}`).join('\n');
|
|
55
|
+
return hashString(combined);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Verify that content matches expected hash.
|
|
59
|
+
*
|
|
60
|
+
* @param content Buffer to verify
|
|
61
|
+
* @param expectedHash Expected hash (prefixed with 'sha256:')
|
|
62
|
+
* @returns True if hash matches
|
|
63
|
+
*/
|
|
64
|
+
export function verifyHash(content, expectedHash) {
|
|
65
|
+
const actualHash = hashBuffer(content);
|
|
66
|
+
return actualHash === expectedHash;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Strip the hash prefix (sha256:) from a hash string.
|
|
70
|
+
*
|
|
71
|
+
* @param hash Hash string with or without prefix
|
|
72
|
+
* @returns Hash string without prefix
|
|
73
|
+
*/
|
|
74
|
+
export function stripHashPrefix(hash) {
|
|
75
|
+
if (hash.startsWith('sha256:')) {
|
|
76
|
+
return hash.slice(7);
|
|
77
|
+
}
|
|
78
|
+
return hash;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add the hash prefix (sha256:) to a hash string if not present.
|
|
82
|
+
*
|
|
83
|
+
* @param hash Hash string with or without prefix
|
|
84
|
+
* @returns Hash string with prefix
|
|
85
|
+
*/
|
|
86
|
+
export function ensureHashPrefix(hash) {
|
|
87
|
+
if (hash.startsWith('sha256:')) {
|
|
88
|
+
return hash;
|
|
89
|
+
}
|
|
90
|
+
return `sha256:${hash}`;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/sync/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAgB;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE7C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAChE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7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,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,UAAU,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync module - Library sync from cloud to local CLI
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality to sync the organization's solution
|
|
5
|
+
* library from the cloud backend to the local Docker container.
|
|
6
|
+
*/
|
|
7
|
+
export type { FileEntry, SolutionEntry, ServiceEntry, ServicesRegistry, RemoteLibraryManifest, LocalSyncManifest, LocalSolutionEntry, SyncState, SyncStatus, SyncOptions, SyncResult, SyncPlan, PreflightResult, LocalModification } from '../types/sync.js';
|
|
8
|
+
export { SyncEngine, runSync, resumeSync, showSyncStatus } from './sync-engine.js';
|
|
9
|
+
export { isDockerAvailable, findSandboxContainer, isSandboxRunning, runPreflightChecks, writeFileToSandbox, readFileFromSandbox, deleteFromSandbox, extractArchiveToSandbox, getLibraryPath, getServicesRegistryPath } from './docker.js';
|
|
10
|
+
export { hashFile, hashBuffer, hashString, computeSolutionHash, verifyHash } from './hash.js';
|
|
11
|
+
export { mergeServicesRegistry, getServicesToRemove, getServicesToAdd, getServicesToUpdate, getServicesMergeSummary } from './services.js';
|
|
12
|
+
export { loadLocalManifest, saveLocalManifest, loadSyncState, saveSyncState, updateSyncState, isFirstSync, hasResumableSync, getSyncStatusSummary } from './manifest.js';
|
|
13
|
+
export { downloadWithRetry, splitIntoBatches } from './download.js';
|
|
14
|
+
export { displayProgress, displayPhase, displayHeader, displaySuccess, displayWarning, displayError, displaySyncPlan, displaySyncComplete, displaySyncStatus, formatBytes, formatDuration } from './progress.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,eAAe,EACf,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGnF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync module - Library sync from cloud to local CLI
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality to sync the organization's solution
|
|
5
|
+
* library from the cloud backend to the local Docker container.
|
|
6
|
+
*/
|
|
7
|
+
// Sync engine
|
|
8
|
+
export { SyncEngine, runSync, resumeSync, showSyncStatus } from './sync-engine.js';
|
|
9
|
+
// Docker utilities
|
|
10
|
+
export { isDockerAvailable, findSandboxContainer, isSandboxRunning, runPreflightChecks, writeFileToSandbox, readFileFromSandbox, deleteFromSandbox, extractArchiveToSandbox, getLibraryPath, getServicesRegistryPath } from './docker.js';
|
|
11
|
+
// Hash utilities
|
|
12
|
+
export { hashFile, hashBuffer, hashString, computeSolutionHash, verifyHash } from './hash.js';
|
|
13
|
+
// Services registry
|
|
14
|
+
export { mergeServicesRegistry, getServicesToRemove, getServicesToAdd, getServicesToUpdate, getServicesMergeSummary } from './services.js';
|
|
15
|
+
// Manifest management
|
|
16
|
+
export { loadLocalManifest, saveLocalManifest, loadSyncState, saveSyncState, updateSyncState, isFirstSync, hasResumableSync, getSyncStatusSummary } from './manifest.js';
|
|
17
|
+
// Download utilities
|
|
18
|
+
export { downloadWithRetry, splitIntoBatches } from './download.js';
|
|
19
|
+
// Progress display
|
|
20
|
+
export { displayProgress, displayPhase, displayHeader, displaySuccess, displayWarning, displayError, displaySyncPlan, displaySyncComplete, displaySyncStatus, formatBytes, formatDuration } from './progress.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnF,mBAAmB;AACnB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB,iBAAiB;AACjB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB,oBAAoB;AACpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AAEvB,sBAAsB;AACtB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,qBAAqB;AACrB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest management for library sync.
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and saving local sync manifest and state.
|
|
5
|
+
*/
|
|
6
|
+
import { LocalSyncManifest, SyncState, SyncStatus, LocalSolutionEntry, PendingQueue, LastError, SyncStats } from '../types/sync.js';
|
|
7
|
+
/**
|
|
8
|
+
* Ensure the sync directory exists.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureSyncDir(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the sync directory.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSyncDir(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get the path to the local manifest file.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getManifestPath(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the path to the sync state file.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getStatePath(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Check if this is the first sync (no local manifest exists).
|
|
25
|
+
*/
|
|
26
|
+
export declare function isFirstSync(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Load the local sync manifest.
|
|
29
|
+
*
|
|
30
|
+
* @returns Local manifest or null if not found
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadLocalManifest(): LocalSyncManifest | null;
|
|
33
|
+
/**
|
|
34
|
+
* Save the local sync manifest.
|
|
35
|
+
*
|
|
36
|
+
* @param manifest Manifest to save
|
|
37
|
+
*/
|
|
38
|
+
export declare function saveLocalManifest(manifest: LocalSyncManifest): void;
|
|
39
|
+
/**
|
|
40
|
+
* Load the sync state.
|
|
41
|
+
*
|
|
42
|
+
* @returns Sync state or default idle state if not found
|
|
43
|
+
*/
|
|
44
|
+
export declare function loadSyncState(): SyncState;
|
|
45
|
+
/**
|
|
46
|
+
* Save the sync state.
|
|
47
|
+
*
|
|
48
|
+
* @param state State to save
|
|
49
|
+
*/
|
|
50
|
+
export declare function saveSyncState(state: SyncState): void;
|
|
51
|
+
/**
|
|
52
|
+
* Update specific fields in the sync state.
|
|
53
|
+
*
|
|
54
|
+
* @param updates Partial state updates to apply
|
|
55
|
+
*/
|
|
56
|
+
export declare function updateSyncState(updates: Partial<SyncState>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Set sync state to in-progress with start time.
|
|
59
|
+
*/
|
|
60
|
+
export declare function startSync(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Set sync state to completed with statistics.
|
|
63
|
+
*
|
|
64
|
+
* @param stats Sync statistics
|
|
65
|
+
*/
|
|
66
|
+
export declare function completeSync(stats: SyncStats): void;
|
|
67
|
+
/**
|
|
68
|
+
* Set sync state to interrupted with pending queue.
|
|
69
|
+
*
|
|
70
|
+
* @param pendingQueue Remaining work to be done
|
|
71
|
+
*/
|
|
72
|
+
export declare function interruptSync(pendingQueue: PendingQueue): void;
|
|
73
|
+
/**
|
|
74
|
+
* Set sync state to error with error details.
|
|
75
|
+
*
|
|
76
|
+
* @param error Error information
|
|
77
|
+
*/
|
|
78
|
+
export declare function failSync(error: LastError): void;
|
|
79
|
+
/**
|
|
80
|
+
* Update current operation being performed.
|
|
81
|
+
*
|
|
82
|
+
* @param operation Current operation details
|
|
83
|
+
*/
|
|
84
|
+
export declare function updateCurrentOperation(operation: {
|
|
85
|
+
type: 'manifest' | 'solution' | 'file';
|
|
86
|
+
solution_id?: string;
|
|
87
|
+
file_path?: string;
|
|
88
|
+
progress: number;
|
|
89
|
+
}): void;
|
|
90
|
+
/**
|
|
91
|
+
* Check if there's an interrupted sync that can be resumed.
|
|
92
|
+
*/
|
|
93
|
+
export declare function hasResumableSync(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Get the pending queue for resuming an interrupted sync.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getPendingQueue(): PendingQueue | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Clear the sync state (reset to idle).
|
|
100
|
+
*/
|
|
101
|
+
export declare function clearSyncState(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Build local solution entries from a completed sync.
|
|
104
|
+
*
|
|
105
|
+
* @param solutions Remote solution entries that were synced
|
|
106
|
+
* @returns Local solution entries with sync metadata
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildLocalSolutionEntries(solutions: Array<{
|
|
109
|
+
library_id: string;
|
|
110
|
+
solution_hash: string;
|
|
111
|
+
files: Array<{
|
|
112
|
+
path: string;
|
|
113
|
+
hash: string;
|
|
114
|
+
size: number;
|
|
115
|
+
}>;
|
|
116
|
+
}>): LocalSolutionEntry[];
|
|
117
|
+
/**
|
|
118
|
+
* Get sync status summary for display.
|
|
119
|
+
*/
|
|
120
|
+
export declare function getSyncStatusSummary(): {
|
|
121
|
+
status: SyncStatus;
|
|
122
|
+
lastSyncTime?: string;
|
|
123
|
+
lastSyncRelative?: string;
|
|
124
|
+
solutionCount: number;
|
|
125
|
+
fileCount: number;
|
|
126
|
+
totalSize: number;
|
|
127
|
+
orgId?: string;
|
|
128
|
+
endpoint?: string;
|
|
129
|
+
lastError?: LastError;
|
|
130
|
+
pendingFiles?: number;
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/sync/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,kBAAkB,EAElB,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,kBAAkB,CAAC;AAQ1B;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,GAAG,IAAI,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAWzC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAIjE;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAQhC;AAED;;;;GAIG;AACH,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AS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAkDA"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest management for library sync.
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and saving local sync manifest and state.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
// Sync data directory
|
|
9
|
+
const ORCA_DIR = path.join(process.env.HOME || process.env.USERPROFILE || '', '.orca');
|
|
10
|
+
const SYNC_DIR = path.join(ORCA_DIR, 'sync');
|
|
11
|
+
const MANIFEST_PATH = path.join(SYNC_DIR, 'manifest.json');
|
|
12
|
+
const STATE_PATH = path.join(SYNC_DIR, 'state.json');
|
|
13
|
+
/**
|
|
14
|
+
* Ensure the sync directory exists.
|
|
15
|
+
*/
|
|
16
|
+
export function ensureSyncDir() {
|
|
17
|
+
if (!fs.existsSync(SYNC_DIR)) {
|
|
18
|
+
fs.mkdirSync(SYNC_DIR, { recursive: true, mode: 0o700 });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the path to the sync directory.
|
|
23
|
+
*/
|
|
24
|
+
export function getSyncDir() {
|
|
25
|
+
return SYNC_DIR;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the path to the local manifest file.
|
|
29
|
+
*/
|
|
30
|
+
export function getManifestPath() {
|
|
31
|
+
return MANIFEST_PATH;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the path to the sync state file.
|
|
35
|
+
*/
|
|
36
|
+
export function getStatePath() {
|
|
37
|
+
return STATE_PATH;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if this is the first sync (no local manifest exists).
|
|
41
|
+
*/
|
|
42
|
+
export function isFirstSync() {
|
|
43
|
+
return !fs.existsSync(MANIFEST_PATH);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load the local sync manifest.
|
|
47
|
+
*
|
|
48
|
+
* @returns Local manifest or null if not found
|
|
49
|
+
*/
|
|
50
|
+
export function loadLocalManifest() {
|
|
51
|
+
if (!fs.existsSync(MANIFEST_PATH)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const data = fs.readFileSync(MANIFEST_PATH, 'utf-8');
|
|
56
|
+
return JSON.parse(data);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Save the local sync manifest.
|
|
64
|
+
*
|
|
65
|
+
* @param manifest Manifest to save
|
|
66
|
+
*/
|
|
67
|
+
export function saveLocalManifest(manifest) {
|
|
68
|
+
ensureSyncDir();
|
|
69
|
+
fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2), { mode: 0o600 });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Load the sync state.
|
|
73
|
+
*
|
|
74
|
+
* @returns Sync state or default idle state if not found
|
|
75
|
+
*/
|
|
76
|
+
export function loadSyncState() {
|
|
77
|
+
if (!fs.existsSync(STATE_PATH)) {
|
|
78
|
+
return { status: 'idle' };
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const data = fs.readFileSync(STATE_PATH, 'utf-8');
|
|
82
|
+
return JSON.parse(data);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return { status: 'idle' };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Save the sync state.
|
|
90
|
+
*
|
|
91
|
+
* @param state State to save
|
|
92
|
+
*/
|
|
93
|
+
export function saveSyncState(state) {
|
|
94
|
+
ensureSyncDir();
|
|
95
|
+
fs.writeFileSync(STATE_PATH, JSON.stringify(state, null, 2), { mode: 0o600 });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Update specific fields in the sync state.
|
|
99
|
+
*
|
|
100
|
+
* @param updates Partial state updates to apply
|
|
101
|
+
*/
|
|
102
|
+
export function updateSyncState(updates) {
|
|
103
|
+
const current = loadSyncState();
|
|
104
|
+
const updated = { ...current, ...updates };
|
|
105
|
+
saveSyncState(updated);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Set sync state to in-progress with start time.
|
|
109
|
+
*/
|
|
110
|
+
export function startSync() {
|
|
111
|
+
updateSyncState({
|
|
112
|
+
status: 'in_progress',
|
|
113
|
+
started_at: new Date().toISOString(),
|
|
114
|
+
completed_at: undefined,
|
|
115
|
+
last_error: undefined,
|
|
116
|
+
pending_queue: undefined
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set sync state to completed with statistics.
|
|
121
|
+
*
|
|
122
|
+
* @param stats Sync statistics
|
|
123
|
+
*/
|
|
124
|
+
export function completeSync(stats) {
|
|
125
|
+
updateSyncState({
|
|
126
|
+
status: 'idle',
|
|
127
|
+
completed_at: new Date().toISOString(),
|
|
128
|
+
stats,
|
|
129
|
+
current_operation: undefined,
|
|
130
|
+
pending_queue: undefined
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Set sync state to interrupted with pending queue.
|
|
135
|
+
*
|
|
136
|
+
* @param pendingQueue Remaining work to be done
|
|
137
|
+
*/
|
|
138
|
+
export function interruptSync(pendingQueue) {
|
|
139
|
+
updateSyncState({
|
|
140
|
+
status: 'interrupted',
|
|
141
|
+
pending_queue: pendingQueue
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Set sync state to error with error details.
|
|
146
|
+
*
|
|
147
|
+
* @param error Error information
|
|
148
|
+
*/
|
|
149
|
+
export function failSync(error) {
|
|
150
|
+
updateSyncState({
|
|
151
|
+
status: 'error',
|
|
152
|
+
last_error: error
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Update current operation being performed.
|
|
157
|
+
*
|
|
158
|
+
* @param operation Current operation details
|
|
159
|
+
*/
|
|
160
|
+
export function updateCurrentOperation(operation) {
|
|
161
|
+
const current = loadSyncState();
|
|
162
|
+
current.current_operation = operation;
|
|
163
|
+
saveSyncState(current);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if there's an interrupted sync that can be resumed.
|
|
167
|
+
*/
|
|
168
|
+
export function hasResumableSync() {
|
|
169
|
+
const state = loadSyncState();
|
|
170
|
+
return state.status === 'interrupted' && !!state.pending_queue;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the pending queue for resuming an interrupted sync.
|
|
174
|
+
*/
|
|
175
|
+
export function getPendingQueue() {
|
|
176
|
+
const state = loadSyncState();
|
|
177
|
+
if (state.status === 'interrupted') {
|
|
178
|
+
return state.pending_queue;
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Clear the sync state (reset to idle).
|
|
184
|
+
*/
|
|
185
|
+
export function clearSyncState() {
|
|
186
|
+
saveSyncState({ status: 'idle' });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Build local solution entries from a completed sync.
|
|
190
|
+
*
|
|
191
|
+
* @param solutions Remote solution entries that were synced
|
|
192
|
+
* @returns Local solution entries with sync metadata
|
|
193
|
+
*/
|
|
194
|
+
export function buildLocalSolutionEntries(solutions) {
|
|
195
|
+
const now = new Date().toISOString();
|
|
196
|
+
return solutions.map(s => ({
|
|
197
|
+
library_id: s.library_id,
|
|
198
|
+
solution_hash: s.solution_hash,
|
|
199
|
+
synced_at: now,
|
|
200
|
+
files: s.files.map(f => ({
|
|
201
|
+
path: f.path,
|
|
202
|
+
hash: f.hash,
|
|
203
|
+
size: f.size
|
|
204
|
+
})),
|
|
205
|
+
status: 'complete'
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get sync status summary for display.
|
|
210
|
+
*/
|
|
211
|
+
export function getSyncStatusSummary() {
|
|
212
|
+
const state = loadSyncState();
|
|
213
|
+
const manifest = loadLocalManifest();
|
|
214
|
+
let solutionCount = 0;
|
|
215
|
+
let fileCount = 0;
|
|
216
|
+
let totalSize = 0;
|
|
217
|
+
if (manifest) {
|
|
218
|
+
solutionCount = manifest.solutions.length;
|
|
219
|
+
for (const solution of manifest.solutions) {
|
|
220
|
+
fileCount += solution.files.length;
|
|
221
|
+
for (const file of solution.files) {
|
|
222
|
+
totalSize += file.size;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Calculate relative time for last sync
|
|
227
|
+
let lastSyncRelative;
|
|
228
|
+
const lastSyncTime = state.completed_at || manifest?.updated_at;
|
|
229
|
+
if (lastSyncTime) {
|
|
230
|
+
const diff = Date.now() - new Date(lastSyncTime).getTime();
|
|
231
|
+
const minutes = Math.floor(diff / 60000);
|
|
232
|
+
const hours = Math.floor(minutes / 60);
|
|
233
|
+
const days = Math.floor(hours / 24);
|
|
234
|
+
if (days > 0) {
|
|
235
|
+
lastSyncRelative = `${days} day${days > 1 ? 's' : ''} ago`;
|
|
236
|
+
}
|
|
237
|
+
else if (hours > 0) {
|
|
238
|
+
lastSyncRelative = `${hours} hour${hours > 1 ? 's' : ''} ago`;
|
|
239
|
+
}
|
|
240
|
+
else if (minutes > 0) {
|
|
241
|
+
lastSyncRelative = `${minutes} minute${minutes > 1 ? 's' : ''} ago`;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
lastSyncRelative = 'just now';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
status: state.status,
|
|
249
|
+
lastSyncTime,
|
|
250
|
+
lastSyncRelative,
|
|
251
|
+
solutionCount,
|
|
252
|
+
fileCount,
|
|
253
|
+
totalSize,
|
|
254
|
+
orgId: manifest?.org_id,
|
|
255
|
+
endpoint: manifest?.endpoint,
|
|
256
|
+
lastError: state.last_error,
|
|
257
|
+
pendingFiles: state.pending_queue?.files_to_download?.length
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/sync/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAY7B,sBAAsB;AACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;AACvF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,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