@aerogel/plugin-local-first 0.1.1 → 0.1.2-next.823beb2779ebc4c5272f5e4e094cecc32cffa527
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/aerogel-plugin-local-first.d.ts +32 -21
- package/dist/aerogel-plugin-local-first.js +935 -788
- package/dist/aerogel-plugin-local-first.js.map +1 -1
- package/package.json +15 -9
- package/src/components/AccountModal.vue +6 -10
- package/src/index.ts +12 -6
- package/src/jobs/Backup.ts +41 -6
- package/src/jobs/Sync.test.ts +126 -37
- package/src/jobs/Sync.ts +236 -58
- package/src/jobs/mixins/LoadsChildren.ts +141 -75
- package/src/jobs/mixins/TracksLocalModels.ts +2 -4
- package/src/lib/inference.ts +39 -0
- package/src/lib/mirroring.ts +78 -57
- package/src/services/Cloud.state.ts +5 -0
- package/src/services/Cloud.ts +49 -21
- package/src/testing/cloud.ts +8 -2
- package/src/testing/mocks/Solid.mock.ts +2 -4
- package/src/testing/mocks/documents-cache.ts +59 -0
- package/src/testing/setup.ts +15 -0
- package/src/services/DocumentsCache.ts +0 -39
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { AcceptRefs } from '@aerogel/core';
|
|
2
1
|
import { Authenticator } from '@aerogel/plugin-solid';
|
|
3
2
|
import { ComponentOptionsMixin } from 'vue';
|
|
4
3
|
import { ComponentProvideOptions } from 'vue';
|
|
5
4
|
import { Cr } from '@noeldemartin/utils';
|
|
6
5
|
import { DefineComponent } from 'vue';
|
|
6
|
+
import { DocumentsCache } from 'soukai-solid';
|
|
7
7
|
import { Engine } from 'soukai';
|
|
8
|
+
import { EngineDocument } from 'soukai';
|
|
8
9
|
import { ErrorSource } from '@aerogel/core';
|
|
9
10
|
import { Facade } from '@noeldemartin/utils';
|
|
10
11
|
import { Job } from '@aerogel/core';
|
|
11
12
|
import { JobListener } from '@aerogel/core';
|
|
12
13
|
import { JobStatus } from '@aerogel/core';
|
|
13
|
-
import { ModalExpose } from '@aerogel/core';
|
|
14
14
|
import { Nullable } from '@noeldemartin/utils';
|
|
15
15
|
import { ObjectsMap } from '@noeldemartin/utils';
|
|
16
16
|
import { Plugin as Plugin_2 } from '@aerogel/core';
|
|
@@ -18,7 +18,6 @@ import { PublicProps } from 'vue';
|
|
|
18
18
|
import { Replace } from '@aerogel/core';
|
|
19
19
|
import { Semaphore } from '@noeldemartin/utils';
|
|
20
20
|
import { ServiceWithState } from '@aerogel/core';
|
|
21
|
-
import { ShallowUnwrapRef } from 'vue';
|
|
22
21
|
import { SolidContainer } from 'soukai-solid';
|
|
23
22
|
import { SolidDocument } from 'soukai-solid';
|
|
24
23
|
import { SolidModel } from 'soukai-solid';
|
|
@@ -35,18 +34,19 @@ export declare const AccountLoggedOut: DefineComponent< {}, {}, {}, {}, {}, C
|
|
|
35
34
|
|
|
36
35
|
export declare const AccountLoginModal: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
37
36
|
|
|
38
|
-
export declare const AccountModal: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
39
|
-
$modalRef: ShallowUnwrapRef<AcceptRefs<ModalExpose<void>>> | null;
|
|
40
|
-
}, any>;
|
|
37
|
+
export declare const AccountModal: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
41
38
|
|
|
42
39
|
export declare const Cloud: Facade<CloudService>;
|
|
43
40
|
|
|
44
41
|
export declare class CloudService extends _default {
|
|
45
42
|
protected asyncLock: Semaphore;
|
|
46
43
|
protected engine: Engine | null;
|
|
47
|
-
protected pollingInterval:
|
|
44
|
+
protected pollingInterval: ReturnType<typeof setInterval> | null;
|
|
45
|
+
protected documentsCache: DocumentsCache | null;
|
|
48
46
|
whenReady<T>(callback: () => T): Promise<T>;
|
|
49
47
|
setup(modelUrlMappings?: WeakMap<SolidModelConstructor, Record<string, string>>): Promise<void>;
|
|
48
|
+
getEngine(): Engine | null;
|
|
49
|
+
requireEngine(): Engine;
|
|
50
50
|
dismissSetup(): void;
|
|
51
51
|
dismissMigration(): void;
|
|
52
52
|
postponeMigration(): void;
|
|
@@ -61,16 +61,16 @@ export declare class CloudService extends _default {
|
|
|
61
61
|
register(modelClass: SolidModelConstructor, options?: RegisterOptions): Promise<void>;
|
|
62
62
|
registerSchemaMigration(modelClass: SolidModelConstructor, schema: SolidModelConstructor | SolidSchemaDefinition): void;
|
|
63
63
|
requireRemoteCollection(modelClass: SolidModelConstructor): string;
|
|
64
|
+
getDocumentsCache(): DocumentsCache;
|
|
64
65
|
protected boot(): Promise<void>;
|
|
65
66
|
protected getDirtyLocalModels(): SolidModel[];
|
|
66
67
|
protected getModelsIn(urls: string[], model: SolidModel): SolidModel[];
|
|
67
|
-
protected requireEngine(): Engine;
|
|
68
68
|
protected setReady(ready: boolean): Promise<void>;
|
|
69
69
|
protected backup(modelUrlMappings?: WeakMap<SolidModelConstructor, Record<string, string>>): Promise<void>;
|
|
70
70
|
protected onApplicationReady(): Promise<void>;
|
|
71
71
|
protected onApplicationMounted(): Promise<void>;
|
|
72
72
|
protected login(authenticator: Authenticator): void;
|
|
73
|
-
protected logout(): void
|
|
73
|
+
protected logout(): Promise<void>;
|
|
74
74
|
private watchNetworkStatus;
|
|
75
75
|
private syncOnStartup;
|
|
76
76
|
private bustDocumentsCache;
|
|
@@ -92,9 +92,11 @@ migrationDismissed: boolean;
|
|
|
92
92
|
migrationJob: Nullable<Migrate>;
|
|
93
93
|
migrationPostponed: boolean;
|
|
94
94
|
modelCollections: Record<string, string[]>;
|
|
95
|
+
rootModelCollections: Record<string, string>;
|
|
95
96
|
pollingEnabled: boolean;
|
|
96
97
|
pollingMinutes: number;
|
|
97
98
|
ready: boolean;
|
|
99
|
+
manualSetup: boolean;
|
|
98
100
|
registeredModels: ModelRegistration[];
|
|
99
101
|
schemaMigrations: Map<SolidModelConstructor, SolidModelConstructor | SolidSchemaDefinition>;
|
|
100
102
|
setupDismissed: boolean;
|
|
@@ -120,9 +122,11 @@ migrationDismissed: boolean;
|
|
|
120
122
|
migrationJob: Nullable<Migrate>;
|
|
121
123
|
migrationPostponed: boolean;
|
|
122
124
|
modelCollections: Record<string, string[]>;
|
|
125
|
+
rootModelCollections: Record<string, string>;
|
|
123
126
|
pollingEnabled: boolean;
|
|
124
127
|
pollingMinutes: number;
|
|
125
128
|
ready: boolean;
|
|
129
|
+
manualSetup: boolean;
|
|
126
130
|
registeredModels: ModelRegistration[];
|
|
127
131
|
schemaMigrations: Map<SolidModelConstructor, SolidModelConstructor | SolidSchemaDefinition>;
|
|
128
132
|
setupDismissed: boolean;
|
|
@@ -137,22 +141,24 @@ migrationJob: MigrateJobStatus | undefined;
|
|
|
137
141
|
|
|
138
142
|
declare class LoadsChildren {
|
|
139
143
|
protected localModels?: ObjectsMap<SolidModel>;
|
|
140
|
-
protected loadContainedModels(
|
|
144
|
+
protected loadContainedModels(container: SolidContainer, options?: {
|
|
141
145
|
ignoreTombstones?: boolean;
|
|
142
146
|
status?: ResourceJobStatus;
|
|
147
|
+
updateProgress?: (update?: () => unknown) => Promise<void>;
|
|
143
148
|
onDocumentLoaded?: () => unknown;
|
|
144
149
|
onDocumentError?: (error: unknown) => unknown;
|
|
145
150
|
onDocumentRead?: (document: SolidDocument) => unknown;
|
|
151
|
+
onDocumentIgnored?: (document: SolidDocument) => unknown;
|
|
146
152
|
}): Promise<SolidModel[]>;
|
|
147
|
-
protected
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
protected loadContainedDocuments(container: SolidContainer, options?: {
|
|
154
|
+
status?: ResourceJobStatus;
|
|
155
|
+
updateProgress?: (update?: () => unknown) => Promise<void>;
|
|
156
|
+
onDocumentLoaded?: () => unknown;
|
|
157
|
+
onDocumentError?: (error: unknown) => unknown;
|
|
158
|
+
onDocumentRead?: (document: SolidDocument) => unknown;
|
|
159
|
+
}): Promise<Record<string, EngineDocument>>;
|
|
160
|
+
private loadDocumentChildren;
|
|
161
|
+
private loadDocumentChildrenFromRemote;
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
declare class LoadsTypeIndex {
|
|
@@ -166,7 +172,7 @@ declare class LoadsTypeIndex {
|
|
|
166
172
|
}): Promise<SolidTypeIndex>;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
|
-
declare function localFirst(): Plugin_2;
|
|
175
|
+
declare function localFirst(options?: Options): Plugin_2;
|
|
170
176
|
export default localFirst;
|
|
171
177
|
|
|
172
178
|
export declare type LocalFirstServices = typeof services;
|
|
@@ -199,6 +205,10 @@ declare interface ModelRegistration {
|
|
|
199
205
|
path?: string;
|
|
200
206
|
}
|
|
201
207
|
|
|
208
|
+
export declare interface Options {
|
|
209
|
+
manualSetup?: boolean;
|
|
210
|
+
}
|
|
211
|
+
|
|
202
212
|
export declare interface RegisterOptions {
|
|
203
213
|
path?: string;
|
|
204
214
|
}
|
|
@@ -233,12 +243,13 @@ declare class Sync extends Sync_base {
|
|
|
233
243
|
private pullChanges;
|
|
234
244
|
private pushChanges;
|
|
235
245
|
private fetchRemoteModels;
|
|
246
|
+
private fetchRemoteModelsFromContainer;
|
|
236
247
|
private fetchRemoteModelsForLocal;
|
|
237
248
|
private getTypeRegistrations;
|
|
238
249
|
private updateTypeRegistrations;
|
|
239
250
|
private loadChildren;
|
|
240
251
|
private deleteChild;
|
|
241
|
-
private
|
|
252
|
+
private saveModelAndRelated;
|
|
242
253
|
private synchronizeModels;
|
|
243
254
|
private reconcileInconsistencies;
|
|
244
255
|
private synchronizeContainerDocuments;
|