@aerogel/plugin-local-first 0.0.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.
Files changed (38) hide show
  1. package/dist/InruptAuthenticator.lazy-BvpQLGoj-BvpQLGoj.js +9 -0
  2. package/dist/InruptAuthenticator.lazy-BvpQLGoj-BvpQLGoj.js.map +1 -0
  3. package/dist/LegacyAuthenticator.lazy-ChFFqP14-ChFFqP14.js +5 -0
  4. package/dist/LegacyAuthenticator.lazy-ChFFqP14-ChFFqP14.js.map +1 -0
  5. package/dist/aerogel-plugin-local-first.d.ts +269 -0
  6. package/dist/aerogel-plugin-local-first.js +1686 -0
  7. package/dist/aerogel-plugin-local-first.js.map +1 -0
  8. package/package.json +50 -0
  9. package/src/components/AGCloudStatus.vue +31 -0
  10. package/src/components/index.ts +3 -0
  11. package/src/index.ts +29 -0
  12. package/src/jobs/Backup.ts +98 -0
  13. package/src/jobs/Migrate.test.ts +217 -0
  14. package/src/jobs/Migrate.ts +179 -0
  15. package/src/jobs/Sync.test.ts +982 -0
  16. package/src/jobs/Sync.ts +590 -0
  17. package/src/jobs/mixins/LoadsChildren.ts +210 -0
  18. package/src/jobs/mixins/LoadsTypeIndex.ts +23 -0
  19. package/src/jobs/mixins/TracksLocalModels.ts +32 -0
  20. package/src/lib/SyncQueue.ts +94 -0
  21. package/src/lib/inference.ts +124 -0
  22. package/src/lib/mirroring.ts +327 -0
  23. package/src/lib/utils.ts +21 -0
  24. package/src/services/Cloud.state.ts +111 -0
  25. package/src/services/Cloud.ts +450 -0
  26. package/src/services/DocumentsCache.ts +35 -0
  27. package/src/testing/cloud.ts +193 -0
  28. package/src/testing/mocks/Solid.mock.ts +34 -0
  29. package/src/testing/setup.ts +32 -0
  30. package/src/testing/stubs/LegacyTask.schema.ts +15 -0
  31. package/src/testing/stubs/Movie.schema.ts +15 -0
  32. package/src/testing/stubs/Movie.ts +3 -0
  33. package/src/testing/stubs/MoviesContainer.ts +20 -0
  34. package/src/testing/stubs/Task.schema.ts +12 -0
  35. package/src/testing/stubs/Task.ts +3 -0
  36. package/src/testing/stubs/TasksList.ts +20 -0
  37. package/src/testing/stubs/Workspace.ts +15 -0
  38. package/src/types/shims.d.ts +7 -0
@@ -0,0 +1,34 @@
1
+ import { FakeServer, fakeContainerUrl, fakeDocumentUrl, mock } from '@noeldemartin/testing';
2
+ import { facade } from '@noeldemartin/utils';
3
+ import { SolidACLAuthorization, SolidDocument, SolidEngine, SolidTypeIndex } from 'soukai-solid';
4
+ import { SolidService } from '@aerogel/plugin-solid';
5
+ import type { AuthSession } from '@aerogel/plugin-solid';
6
+
7
+ export class SolidMockService extends SolidService {
8
+
9
+ constructor() {
10
+ super();
11
+
12
+ const engine = new SolidEngine(FakeServer.fetch);
13
+
14
+ this.setState('session', {
15
+ user: mock({
16
+ privateTypeIndexUrl: fakeDocumentUrl(),
17
+ storageUrls: [fakeContainerUrl()],
18
+ }),
19
+ authenticator: mock({
20
+ engine,
21
+ requireAuthenticatedFetch: () => FakeServer.fetch,
22
+ }),
23
+ } as unknown as AuthSession);
24
+
25
+ SolidACLAuthorization.setEngine(engine);
26
+ SolidTypeIndex.setEngine(engine);
27
+ SolidDocument.setEngine(engine);
28
+
29
+ this.booted.resolve();
30
+ }
31
+
32
+ }
33
+
34
+ export default facade(SolidMockService);
@@ -0,0 +1,32 @@
1
+ import 'fake-indexeddb/auto';
2
+
3
+ import { installVitestSolidMatchers } from '@noeldemartin/solid-utils/testing';
4
+ import { FakeLocalStorage, FakeServer, setupFacadeMocks } from '@noeldemartin/testing';
5
+ import { resetAsyncMemo } from '@noeldemartin/utils';
6
+ import { beforeEach, vi } from 'vitest';
7
+
8
+ setupFacadeMocks();
9
+ installVitestSolidMatchers();
10
+
11
+ beforeEach(async () => {
12
+ const { Solid } = await import('@aerogel/plugin-solid');
13
+ const { default: SolidMock } = await import('./mocks/Solid.mock');
14
+ const { resetPiniaStore } = await import('@aerogel/core');
15
+ const { resetTrackedModels } = await import('@aerogel/plugin-soukai');
16
+
17
+ FakeLocalStorage.requireInstance().clear();
18
+ Solid.setMockFacade(SolidMock);
19
+ FakeServer.reset();
20
+
21
+ resetAsyncMemo();
22
+ resetPiniaStore();
23
+ resetTrackedModels();
24
+ });
25
+
26
+ vi.mock('@aerogel/core', async () => {
27
+ const original = (await vi.importActual('@aerogel/core')) as object;
28
+
29
+ FakeLocalStorage.patchGlobal();
30
+
31
+ return original;
32
+ });
@@ -0,0 +1,15 @@
1
+ import { FieldType } from 'soukai';
2
+ import { defineSolidModelSchema } from 'soukai-solid';
3
+
4
+ export default defineSolidModelSchema({
5
+ rdfContext: 'http://www.w3.org/2002/12/cal/ical#',
6
+ rdfsClass: 'Vtodo',
7
+ history: true,
8
+ tombstone: false,
9
+ fields: {
10
+ name: {
11
+ type: FieldType.String,
12
+ rdfProperty: 'summary',
13
+ },
14
+ },
15
+ });
@@ -0,0 +1,15 @@
1
+ import { FieldType } from 'soukai';
2
+ import { defineSolidModelSchema } from 'soukai-solid';
3
+
4
+ export default defineSolidModelSchema({
5
+ rdfContext: 'https://schema.org/',
6
+ history: true,
7
+ tombstone: false,
8
+ fields: {
9
+ name: FieldType.String,
10
+ releaseDate: {
11
+ type: FieldType.Date,
12
+ rdfProperty: 'schema:datePublished',
13
+ },
14
+ },
15
+ });
@@ -0,0 +1,3 @@
1
+ import Model from './Movie.schema';
2
+
3
+ export default class Movie extends Model {}
@@ -0,0 +1,20 @@
1
+ import { SolidContainer } from 'soukai-solid';
2
+ import type { Relation } from 'soukai';
3
+ import type { SolidContainsRelation } from 'soukai-solid';
4
+
5
+ import Movie from './Movie';
6
+
7
+ export default class MoviesContainer extends SolidContainer {
8
+
9
+ public static override history = true;
10
+ public static override timestamps = true;
11
+ public static override tombstone = false;
12
+
13
+ declare public movies?: Movie[];
14
+ declare public relatedMovies: SolidContainsRelation<this, Movie, typeof Movie>;
15
+
16
+ public moviesRelationship(): Relation {
17
+ return this.contains(Movie);
18
+ }
19
+
20
+ }
@@ -0,0 +1,12 @@
1
+ import { FieldType } from 'soukai';
2
+ import { defineSolidModelSchema } from 'soukai-solid';
3
+
4
+ export default defineSolidModelSchema({
5
+ rdfContext: 'https://schema.org/',
6
+ rdfsClass: 'Action',
7
+ history: true,
8
+ tombstone: false,
9
+ fields: {
10
+ name: FieldType.String,
11
+ },
12
+ });
@@ -0,0 +1,3 @@
1
+ import Model from './Task.schema';
2
+
3
+ export default class Task extends Model {}
@@ -0,0 +1,20 @@
1
+ import { SolidContainer } from 'soukai-solid';
2
+ import type { Relation } from 'soukai';
3
+ import type { SolidContainsRelation } from 'soukai-solid';
4
+
5
+ import Task from './Task';
6
+
7
+ export default class TasksList extends SolidContainer {
8
+
9
+ public static override history = true;
10
+ public static override timestamps = true;
11
+ public static override tombstone = false;
12
+
13
+ declare public tasks?: Task[];
14
+ declare public relatedTasks: SolidContainsRelation<this, Task, typeof Task>;
15
+
16
+ public tasksRelationship(): Relation {
17
+ return this.contains(Task);
18
+ }
19
+
20
+ }
@@ -0,0 +1,15 @@
1
+ import type { Relation } from 'soukai';
2
+ import type { SolidContainsRelation } from 'soukai-solid';
3
+
4
+ import TasksList from './TasksList';
5
+
6
+ export default class Workspace extends TasksList {
7
+
8
+ declare public lists?: TasksList[];
9
+ declare public relatedLists: SolidContainsRelation<this, TasksList, typeof TasksList>;
10
+
11
+ public listsRelationship(): Relation {
12
+ return this.contains(TasksList);
13
+ }
14
+
15
+ }
@@ -0,0 +1,7 @@
1
+ declare module '*.vue' {
2
+ import type { ComponentOptions } from 'vue';
3
+
4
+ const component: ComponentOptions;
5
+
6
+ export default component;
7
+ }