@uniformdev/cli 18.19.0 → 18.20.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.
@@ -1,118 +0,0 @@
1
- import { Change } from 'diff';
2
- import { Argv } from 'yargs';
3
-
4
- type SyncEngineLogOptions = {
5
- id: string;
6
- providerId: string;
7
- displayName: string;
8
- action: 'create' | 'update' | 'delete';
9
- whatIf: boolean;
10
- diff: Change[];
11
- };
12
- type SyncEngineObject<TObject> = {
13
- /** Unique ID that is identical across all providers */
14
- id: string;
15
- /** Provider specific ID. Value is provided to deleteObject() function (always the provider ID from the same provider that issued it). */
16
- providerId: string;
17
- /** Optional display name of the object for log messages. The providerId will be used if this is not set. */
18
- displayName?: string;
19
- /** The object being synced. */
20
- object: TObject;
21
- };
22
- type SyncEngineDataSource<TObject> = {
23
- /** The objects to sync. */
24
- objects: AsyncIterable<SyncEngineObject<TObject>>;
25
- /**
26
- * Called when the sync engine detects a need to update a synced object.
27
- * Only called if this source is the target of a sync operation.
28
- * @param obj The object to write to the data source
29
- * @param existingObj The existing object that matches this one in the data source (if any)
30
- */
31
- writeObject: (obj: SyncEngineObject<TObject>, existingObj?: SyncEngineObject<TObject>) => Promise<void>;
32
- /**
33
- * Called when the sync engine detects a need to delete an object in this data source.
34
- * Only called if this source is the target of a sync operation.
35
- */
36
- deleteObject: (providerId: string, obj: SyncEngineObject<TObject>) => Promise<void>;
37
- /**
38
- * Called when the sync engine finishes synchronization.
39
- */
40
- onSyncComplete?: (isTarget: boolean) => Promise<void>;
41
- };
42
- type SyncEngineOptions<TObject> = {
43
- source: SyncEngineDataSource<TObject>;
44
- target: SyncEngineDataSource<TObject>;
45
- compareContents?: (source: SyncEngineObject<TObject>, target: SyncEngineObject<TObject>) => boolean;
46
- mode: 'mirror' | 'createOrUpdate' | 'create';
47
- /** Compare sources, but do not execute actions */
48
- whatIf?: boolean;
49
- /** An exception will normally br thrown if the sync source has nothing in it; this option allows the sync to continue (potentially deleting everything in the target) */
50
- allowEmptySource?: boolean;
51
- log?: (options: SyncEngineLogOptions) => void;
52
- };
53
- declare function syncEngine<TObject>({ source, target, compareContents, mode, allowEmptySource, whatIf, log, }: SyncEngineOptions<TObject>): Promise<void>;
54
- declare class SyncEngineError<TObject> extends Error {
55
- constructor(innerError: unknown, sourceObject: SyncEngineObject<TObject>);
56
- }
57
-
58
- type CreateArraySyncEngineDataSourceOptions<TObject> = {
59
- objects: Array<TObject>;
60
- selectIdentifier: (object: TObject) => string;
61
- selectDisplayName?: (object: TObject) => string;
62
- onSyncComplete?: (isTarget: boolean, result: Array<TObject>) => Promise<void>;
63
- };
64
- declare function createArraySyncEngineDataSource<TObject>({ objects, selectIdentifier, selectDisplayName, onSyncComplete, }: CreateArraySyncEngineDataSourceOptions<TObject>): Promise<SyncEngineDataSource<TObject> & {
65
- extractCurrent: () => Array<TObject>;
66
- }>;
67
-
68
- type CreateFileSyncEngineDataSourceOptions<TObject> = {
69
- directory: string;
70
- selectIdentifier: (object: TObject) => string;
71
- selectDisplayName?: (object: TObject) => string;
72
- selectFilename?: (object: TObject) => string;
73
- format?: 'json' | 'yaml';
74
- };
75
- declare function createFileSyncEngineDataSource<TObject>({ directory, format, selectIdentifier, selectDisplayName, selectFilename, }: CreateFileSyncEngineDataSourceOptions<TObject>): Promise<SyncEngineDataSource<TObject>>;
76
-
77
- type UniformPackage = {
78
- [key: string]: unknown;
79
- };
80
- declare function readUniformPackage(filename: string, assertExists: boolean): UniformPackage;
81
- declare function writeUniformPackage(filename: string, packageContents: UniformPackage): void;
82
-
83
- type DiffMode = 'off' | 'on' | 'update';
84
- declare function createSyncEngineConsoleLogger(options?: {
85
- diffMode?: DiffMode;
86
- indent?: string;
87
- prefix?: string;
88
- }): ({ action, displayName, whatIf, diff }: SyncEngineLogOptions) => void;
89
-
90
- type ApiArgs = {
91
- apiKey: string;
92
- apiHost: string;
93
- edgeApiHost: string;
94
- proxy?: string;
95
- };
96
- declare function withApiOptions<T>(yargs: Argv<T>): Argv<T>;
97
- declare function nodeFetchProxy(proxy: string | undefined): typeof fetch;
98
- type ProjectArgs = {
99
- project: string;
100
- };
101
- declare function withProjectOptions<T>(yargs: Argv<T>): Argv<T>;
102
- type FormatArgs = {
103
- format: 'json' | 'yaml';
104
- filename?: string;
105
- };
106
- declare function withFormatOptions<T>(yargs: Argv<T>): Argv<T>;
107
- type DiffArgs = {
108
- diff: DiffMode;
109
- };
110
- declare function withDiffOptions<T>(yargs: Argv<T>): Argv<T>;
111
- declare function isPathAPackageFile(path: string): boolean;
112
- declare function emitWithFormat(object: any, format?: string, filename?: string): void;
113
- declare function readFileToObject<T = unknown>(filename: string): T;
114
- declare function paginateAsync<TResult>(fetchPage: (offset: number, limit: number) => Promise<TResult[]>, options: {
115
- pageSize: number;
116
- }): AsyncIterableIterator<TResult>;
117
-
118
- export { ApiArgs, CreateArraySyncEngineDataSourceOptions, CreateFileSyncEngineDataSourceOptions, DiffArgs, DiffMode, FormatArgs, ProjectArgs, SyncEngineDataSource, SyncEngineError, SyncEngineLogOptions, SyncEngineObject, SyncEngineOptions, UniformPackage, createArraySyncEngineDataSource, createFileSyncEngineDataSource, createSyncEngineConsoleLogger, emitWithFormat, isPathAPackageFile, nodeFetchProxy, paginateAsync, readFileToObject, readUniformPackage, syncEngine, withApiOptions, withDiffOptions, withFormatOptions, withProjectOptions, writeUniformPackage };