@warp-drive-mirror/experiments 0.0.1-beta.1 → 0.0.1-beta.3

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/package.json +13 -24
  2. package/unstable-preview-types/data-worker/cache-handler.d.ts +0 -11
  3. package/unstable-preview-types/data-worker/cache-handler.d.ts.map +0 -1
  4. package/unstable-preview-types/data-worker/fetch.d.ts +0 -37
  5. package/unstable-preview-types/data-worker/fetch.d.ts.map +0 -1
  6. package/unstable-preview-types/data-worker/types.d.ts +0 -34
  7. package/unstable-preview-types/data-worker/types.d.ts.map +0 -1
  8. package/unstable-preview-types/data-worker/utils.d.ts +0 -23
  9. package/unstable-preview-types/data-worker/utils.d.ts.map +0 -1
  10. package/unstable-preview-types/data-worker/worker.d.ts +0 -26
  11. package/unstable-preview-types/data-worker/worker.d.ts.map +0 -1
  12. package/unstable-preview-types/data-worker.d.ts +0 -5
  13. package/unstable-preview-types/data-worker.d.ts.map +0 -1
  14. package/unstable-preview-types/document-storage/index.d.ts +0 -93
  15. package/unstable-preview-types/document-storage/index.d.ts.map +0 -1
  16. package/unstable-preview-types/document-storage.d.ts +0 -4
  17. package/unstable-preview-types/document-storage.d.ts.map +0 -1
  18. package/unstable-preview-types/image-fetch.d.ts +0 -4
  19. package/unstable-preview-types/image-fetch.d.ts.map +0 -1
  20. package/unstable-preview-types/image-worker/fetch.d.ts +0 -21
  21. package/unstable-preview-types/image-worker/fetch.d.ts.map +0 -1
  22. package/unstable-preview-types/image-worker/types.d.ts +0 -24
  23. package/unstable-preview-types/image-worker/types.d.ts.map +0 -1
  24. package/unstable-preview-types/image-worker/worker.d.ts +0 -20
  25. package/unstable-preview-types/image-worker/worker.d.ts.map +0 -1
  26. package/unstable-preview-types/image-worker.d.ts +0 -4
  27. package/unstable-preview-types/image-worker.d.ts.map +0 -1
  28. package/unstable-preview-types/index.d.ts +0 -18
  29. package/unstable-preview-types/persisted-cache/cache.d.ts +0 -433
  30. package/unstable-preview-types/persisted-cache/cache.d.ts.map +0 -1
  31. package/unstable-preview-types/persisted-cache/db.d.ts +0 -25
  32. package/unstable-preview-types/persisted-cache/db.d.ts.map +0 -1
  33. package/unstable-preview-types/persisted-cache/fetch.d.ts +0 -11
  34. package/unstable-preview-types/persisted-cache/fetch.d.ts.map +0 -1
  35. package/unstable-preview-types/persisted-cache.d.ts +0 -4
  36. package/unstable-preview-types/persisted-cache.d.ts.map +0 -1
  37. package/unstable-preview-types/worker-fetch.d.ts +0 -4
  38. package/unstable-preview-types/worker-fetch.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive-mirror/experiments",
3
3
  "description": "Experimental features for EmberData/WarpDrive",
4
- "version": "0.0.1-beta.1",
4
+ "version": "0.0.1-beta.3",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -29,14 +29,10 @@
29
29
  },
30
30
  "./image-fetch": {
31
31
  "default": "./dist/image-fetch.js"
32
- },
33
- "./unstable-preview-types": {
34
- "types": "./unstable-preview-types/index.d.ts"
35
32
  }
36
33
  },
37
34
  "files": [
38
35
  "dist",
39
- "unstable-preview-types",
40
36
  "CHANGELOG.md",
41
37
  "README.md",
42
38
  "LICENSE.md",
@@ -45,10 +41,10 @@
45
41
  ],
46
42
  "peerDependencies": {
47
43
  "@sqlite.org/sqlite-wasm": "3.46.0-build2",
48
- "@ember-data-mirror/request": "5.4.0-beta.13",
49
- "@ember-data-mirror/request-utils": "5.4.0-beta.13",
50
- "@ember-data-mirror/store": "5.4.0-beta.13",
51
- "@warp-drive-mirror/core-types": "0.0.0-beta.13"
44
+ "@ember-data-mirror/request": "5.4.0-beta.15",
45
+ "@ember-data-mirror/request-utils": "5.4.0-beta.15",
46
+ "@ember-data-mirror/store": "5.4.0-beta.15",
47
+ "@warp-drive-mirror/core-types": "0.0.0-beta.15"
52
48
  },
53
49
  "peerDependenciesMeta": {
54
50
  "@sqlite.org/sqlite-wasm": {
@@ -56,21 +52,21 @@
56
52
  }
57
53
  },
58
54
  "dependencies": {
59
- "@embroider/macros": "^1.16.6",
60
- "@warp-drive-mirror/build-config": "0.0.0-beta.8"
55
+ "@embroider/macros": "^1.16.10",
56
+ "@warp-drive-mirror/build-config": "0.0.0-beta.10"
61
57
  },
62
58
  "devDependencies": {
63
59
  "@babel/core": "^7.24.5",
64
60
  "@babel/plugin-transform-typescript": "^7.24.5",
65
61
  "@babel/preset-env": "^7.24.5",
66
62
  "@babel/preset-typescript": "^7.24.1",
67
- "@ember-data-mirror/request": "5.4.0-beta.13",
68
- "@ember-data-mirror/request-utils": "5.4.0-beta.13",
69
- "@ember-data-mirror/store": "5.4.0-beta.13",
70
- "@ember-data-mirror/tracking": "5.4.0-beta.13",
63
+ "@ember-data-mirror/request": "5.4.0-beta.15",
64
+ "@ember-data-mirror/request-utils": "5.4.0-beta.15",
65
+ "@ember-data-mirror/store": "5.4.0-beta.15",
66
+ "@ember-data-mirror/tracking": "5.4.0-beta.15",
71
67
  "@glimmer/component": "^1.1.2",
72
- "@warp-drive-mirror/core-types": "0.0.0-beta.13",
73
- "@warp-drive/internal-config": "5.4.0-beta.13",
68
+ "@warp-drive-mirror/core-types": "0.0.0-beta.15",
69
+ "@warp-drive/internal-config": "5.4.0-beta.15",
74
70
  "ember-source": "~5.12.0",
75
71
  "pnpm-sync-dependencies-meta-injected": "0.0.14",
76
72
  "@sqlite.org/sqlite-wasm": "3.46.0-build2",
@@ -83,13 +79,6 @@
83
79
  "volta": {
84
80
  "extends": "../../../../../../package.json"
85
81
  },
86
- "typesVersions": {
87
- "*": {
88
- "unstable-preview-types": [
89
- "./unstable-preview-types"
90
- ]
91
- }
92
- },
93
82
  "scripts": {
94
83
  "lint": "eslint . --quiet --cache --cache-strategy=content",
95
84
  "build:pkg": "vite build;",
@@ -1,11 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker/cache-handler' {
2
- import type { CacheHandler as CacheHandlerType } from '@ember-data-mirror/request';
3
- /**
4
- * A simplified CacheHandler that hydrates ResourceDataDocuments from the cache
5
- * with their referenced resources.
6
- *
7
- * @typedoc
8
- */
9
- export const CacheHandler: CacheHandlerType;
10
- }
11
- //# sourceMappingURL=cache-handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-handler.d.ts","sourceRoot":"","sources":["../../src/data-worker/cache-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAuB5F;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,gBAmC1B,CAAC"}
@@ -1,37 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker/fetch' {
2
- import type { Context } from '@ember-data-mirror/request/-private/context';
3
- import type { Deferred, Future, NextFn } from '@ember-data-mirror/request/-private/types';
4
- import type { AbortEventData, RequestEventData } from '@warp-drive-mirror/experiments/data-worker/types';
5
- export interface FastBoot {
6
- require(moduleName: string): unknown;
7
- isFastBoot: boolean;
8
- request: Request;
9
- }
10
- global {
11
- const FastBoot: undefined | FastBoot;
12
- }
13
- export class WorkerFetch {
14
- worker: Worker | SharedWorker;
15
- threadId: string;
16
- pending: Map<number, {
17
- context: Context;
18
- signal: AbortSignal | null;
19
- abortFn: () => void;
20
- deferred: Deferred<unknown>;
21
- stack: string;
22
- }>;
23
- channel: MessageChannel;
24
- constructor(worker: Worker | SharedWorker | null);
25
- cleanupRequest(id: number): {
26
- context: Context;
27
- signal: AbortSignal | null;
28
- abortFn: () => void;
29
- deferred: Deferred<unknown>;
30
- stack: string;
31
- } | undefined;
32
- send(event: RequestEventData | AbortEventData): void;
33
- request<T>(context: Context, next: NextFn<T>): Promise<T> | Future<T>;
34
- }
35
- export function enhanceReason(reason?: string): DOMException;
36
- }
37
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"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C,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;CAwCtE;AAED,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,gBAE5C"}
@@ -1,34 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker/types' {
2
- import type { RequestInfo, StructuredDataDocument, StructuredErrorDocument } from '@ember-data-mirror/request';
3
- export type SuccessResponseEventData<T> = {
4
- type: 'success-response';
5
- thread: string;
6
- id: number;
7
- data: StructuredDataDocument<T>;
8
- };
9
- export type ErrorResponseEventData<T> = {
10
- type: 'error-response';
11
- thread: string;
12
- id: number;
13
- data: StructuredErrorDocument<T>;
14
- };
15
- export type RequestEventData = {
16
- type: 'request';
17
- thread: string;
18
- id: number;
19
- data: RequestInfo;
20
- };
21
- export type AbortEventData = {
22
- type: 'abort';
23
- thread: string;
24
- id: number;
25
- data: string;
26
- };
27
- export type ThreadInitEventData = {
28
- type: 'connect';
29
- thread: string;
30
- };
31
- export type MainThreadEvent<T> = MessageEvent<SuccessResponseEventData<T> | ErrorResponseEventData<T>>;
32
- export type WorkerThreadEvent = MessageEvent<RequestEventData> | MessageEvent<ThreadInitEventData> | MessageEvent<AbortEventData>;
33
- }
34
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/data-worker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAExG,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI;IACxC,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;CACjC,CAAC;AACF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AACvG,MAAM,MAAM,iBAAiB,GACzB,YAAY,CAAC,gBAAgB,CAAC,GAC9B,YAAY,CAAC,mBAAmB,CAAC,GACjC,YAAY,CAAC,cAAc,CAAC,CAAC"}
@@ -1,23 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker/utils' {
2
- import type Store from '@ember-data-mirror/store';
3
- import type { StableDocumentIdentifier } from '@warp-drive-mirror/core-types/identifier';
4
- import type { ImmutableCreateRequestOptions, ImmutableDeleteRequestOptions, ImmutableRequestInfo, ImmutableUpdateRequestOptions, StructuredDataDocument } from '@warp-drive-mirror/core-types/request';
5
- import type { ApiError } from '@warp-drive-mirror/core-types/spec/error';
6
- export const MUTATION_OPS: Set<string>;
7
- /**
8
- * In a Worker, any time we are asked to make a request, data needs to be returned.
9
- * background requests are ergo no different than foreground requests.
10
- * @internal
11
- */
12
- export function calcShouldFetch(store: Store, request: ImmutableRequestInfo, hasCachedValue: boolean, identifier: StableDocumentIdentifier | null): boolean;
13
- export function isMutation(request: Partial<ImmutableRequestInfo>): request is ImmutableUpdateRequestOptions | ImmutableCreateRequestOptions | ImmutableDeleteRequestOptions;
14
- export function isCacheAffecting<T>(document: StructuredDataDocument<T>): boolean;
15
- type RobustError = Error & {
16
- error: string | object;
17
- errors?: ApiError[];
18
- content?: unknown;
19
- };
20
- export function cloneError(error: RobustError): RobustError;
21
- export {};
22
- }
23
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/data-worker/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EACV,6BAA6B,EAC7B,6BAA6B,EAC7B,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAElE,eAAO,MAAM,YAAY,aAA4D,CAAC;AAEtF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,oBAAoB,EAC7B,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,wBAAwB,GAAG,IAAI,GAC1C,OAAO,CAWT;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACrC,OAAO,IAAI,6BAA6B,GAAG,6BAA6B,GAAG,6BAA6B,CAE1G;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,OAAO,CAahF;AAMD,KAAK,WAAW,GAAG,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAG9F,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,eAa5C"}
@@ -1,26 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker/worker' {
2
- import type { Future } from '@ember-data-mirror/request';
3
- import type Store from '@ember-data-mirror/store';
4
- import { DocumentStorage } from '@warp-drive-mirror/experiments/document-storage';
5
- import type { AbortEventData, RequestEventData } from '@warp-drive-mirror/experiments/data-worker/types';
6
- export class DataWorker {
7
- store: Store;
8
- threads: Map<string, MessagePort>;
9
- pending: Map<string, Map<number, Future<unknown>>>;
10
- isSharedWorker: boolean;
11
- options: {
12
- persisted: boolean;
13
- scope?: string;
14
- };
15
- storage: DocumentStorage;
16
- constructor(UserStore: typeof Store, options?: {
17
- persisted: boolean;
18
- scope?: string;
19
- });
20
- initialize(): void;
21
- setupThread(thread: string, port: MessagePort): void;
22
- abortRequest(event: AbortEventData): void;
23
- request(event: RequestEventData): Promise<void>;
24
- }
25
- }
26
- //# sourceMappingURL=worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/data-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAwC,MAAM,qBAAqB,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAA0C,MAAM,SAAS,CAAC;AAIxG,qBAAa,UAAU;IACb,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnD,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,OAAO,EAAE,eAAe,CAAC;gBAErB,SAAS,EAAE,OAAO,KAAK,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAarF,UAAU;IAkCV,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;IAqB7C,YAAY,CAAC,KAAK,EAAE,cAAc;IAU5B,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAkBtC"}
@@ -1,5 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/data-worker' {
2
- export { DataWorker } from '@warp-drive-mirror/experiments/data-worker/worker';
3
- export { CacheHandler } from '@warp-drive-mirror/experiments/data-worker/cache-handler';
4
- }
5
- //# sourceMappingURL=data-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-worker.d.ts","sourceRoot":"","sources":["../src/data-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,93 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/document-storage' {
2
- import type { StructuredDocument } from '@ember-data-mirror/request';
3
- import type { ExistingRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';
4
- import type { ResourceDataDocument, ResourceDocument } from '@warp-drive-mirror/core-types/spec/document';
5
- import type { ExistingResourceObject } from '@warp-drive-mirror/core-types/spec/json-api-raw';
6
- export const WARP_DRIVE_STORAGE_FILE_NAME = "warp-drive_document-storage";
7
- export const WARP_DRIVE_STORAGE_VERSION = 1;
8
- export type DocumentStorageOptions = {
9
- /**
10
- * The scope of the storage. This is used to enable multiple distinct
11
- * storage areas within the same origin.
12
- *
13
- * One use case for this is to have a separate storage area for each
14
- * user credential. So for instance, in applications that allow a single
15
- * user to have multiple accounts, each account can have its own storage!
16
- */
17
- scope: string;
18
- /**
19
- * When set to true, if other instances of the storage are created with
20
- * the same scope, they will not share the same in-memory cache and BroadcastChannel.
21
- *
22
- * This is mostly useful for testing purposes to replicate the behavior of
23
- * multiple tabs or workers.
24
- */
25
- isolated: boolean;
26
- };
27
- /**
28
- * DocumentStorage is specifically designed around WarpDrive Cache and Request concepts.
29
- *
30
- * CacheFileDocument is a StructuredDocument (request response) whose `content` is
31
- * the ResourceDocument returned by inserting the request into a Store's Cache.
32
- */
33
- type CacheFileDocument = StructuredDocument<ResourceDocument<ExistingRecordIdentifier>>;
34
- /**
35
- * A CacheDocument is a reconstructed request response that rehydrates ResourceDocument
36
- * with the associated resources based on their identifiers.
37
- */
38
- type CacheDocument = StructuredDocument<ResourceDocument<ExistingResourceObject>>;
39
- type DocumentIdentifier = {
40
- lid: string;
41
- };
42
- type MemCache = {
43
- documents: Map<string, CacheFileDocument>;
44
- resources: Map<string, ExistingResourceObject>;
45
- };
46
- class InternalDocumentStorage {
47
- readonly options: DocumentStorageOptions;
48
- _fileHandle: Promise<FileSystemFileHandle>;
49
- _channel: BroadcastChannel;
50
- _invalidated: boolean;
51
- _lastModified: number;
52
- _cache: MemCache | null;
53
- _filePromise: Promise<MemCache> | null;
54
- constructor(options: DocumentStorageOptions);
55
- _onMessage(_event: MessageEvent): void;
56
- _open(scope: string): Promise<FileSystemFileHandle>;
57
- _read(): Promise<MemCache>;
58
- _patch(documentKey: string, document: CacheFileDocument, updatedResources: Map<string, ExistingResourceObject>): Promise<void>;
59
- getDocument(key: DocumentIdentifier): Promise<CacheDocument | null>;
60
- putDocument(document: CacheFileDocument, resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject): Promise<void>;
61
- _getResources(document: ResourceDataDocument<ExistingRecordIdentifier>, resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject, resources?: Map<string, ExistingResourceObject>): Map<string, ExistingResourceObject>;
62
- putResources(document: ResourceDataDocument<ExistingRecordIdentifier>, resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject): Promise<void>;
63
- clear(reset?: boolean): Promise<void>;
64
- }
65
- /**
66
- * DocumentStorage is a wrapper around the StorageManager API that provides
67
- * a simple interface for reading and updating documents and requests.
68
- *
69
- * Some goals for this experiment:
70
- *
71
- * - optimize for storing requests/documents
72
- * - optimize for storing resources
73
- * - optimize for looking up resources associated to a document
74
- * - optimize for notifying cross-tab when data is updated
75
- *
76
- * optional features:
77
- *
78
- * - support for offline mode
79
- * - ?? support for relationship based cache traversal
80
- * - a way to index records by type + another field (e.g updatedAt/createAt/name)
81
- * such that simple queries can be done without having to scan all records
82
- */
83
- export class DocumentStorage {
84
- readonly _storage: InternalDocumentStorage;
85
- constructor(options?: Partial<DocumentStorageOptions>);
86
- getDocument(key: DocumentIdentifier): Promise<CacheDocument | null>;
87
- putDocument(document: CacheFileDocument, resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject): Promise<void>;
88
- putResources(document: ResourceDataDocument<ExistingRecordIdentifier>, resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject): Promise<void>;
89
- clear(reset?: boolean): Promise<void>;
90
- }
91
- export {};
92
- }
93
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAEvF,eAAO,MAAM,4BAA4B,gCAAgC,CAAC;AA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,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqDnE,WAAW,CACf,QAAQ,EAAE,iBAAiB,EAC3B,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,KAAK,sBAAsB,GAC1F,OAAO,CAAC,IAAI,CAAC;IAkBhB,aAAa,CACX,QAAQ,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,EACxD,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,KAAK,sBAAsB,EAC3F,SAAS,GAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAA6C;IAsBtF,YAAY,CAChB,QAAQ,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,EACxD,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,KAAK,sBAAsB;IAyBvF,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;CAqB5B;AAgGD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAe;IAC1B,SAAiB,QAAQ,EAAE,uBAAuB,CAAC;gBAEvC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAoBzD,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAInE,WAAW,CACT,QAAQ,EAAE,iBAAiB,EAC3B,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,KAAK,sBAAsB,GAC1F,OAAO,CAAC,IAAI,CAAC;IAIhB,YAAY,CACV,QAAQ,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,EACxD,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,KAAK,sBAAsB,GAC1F,OAAO,CAAC,IAAI,CAAC;IAIhB,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;CAGtB"}
@@ -1,4 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/document-storage' {
2
- export { DocumentStorage } from '@warp-drive-mirror/experiments/document-storage/index';
3
- }
4
- //# sourceMappingURL=document-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"document-storage.d.ts","sourceRoot":"","sources":["../src/document-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,4 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/image-fetch' {
2
- export { ImageFetch } from '@warp-drive-mirror/experiments/image-worker/fetch';
3
- }
4
- //# sourceMappingURL=image-fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-fetch.d.ts","sourceRoot":"","sources":["../src/image-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,21 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/image-worker/fetch' {
2
- import type { Deferred } from '@ember-data-mirror/request/-private/types';
3
- import type { RequestEventData } from '@warp-drive-mirror/experiments/image-worker/types';
4
- export interface FastBoot {
5
- require(moduleName: string): unknown;
6
- isFastBoot: boolean;
7
- request: Request;
8
- }
9
- export class ImageFetch {
10
- worker: Worker | SharedWorker;
11
- threadId: string;
12
- pending: Map<string, Deferred<string>>;
13
- channel: MessageChannel;
14
- cache: Map<string, string>;
15
- constructor(worker: Worker | SharedWorker | null);
16
- cleanupRequest(url: string): Deferred<string> | undefined;
17
- _send(event: RequestEventData): void;
18
- load(url: string): Promise<string>;
19
- }
20
- }
21
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/image-worker/fetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAInE,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,qBAAa,UAAU;IACb,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEvB,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAwChD,cAAc,CAAC,GAAG,EAAE,MAAM;IAO1B,KAAK,CAAC,KAAK,EAAE,gBAAgB;IAK7B,IAAI,CAAC,GAAG,EAAE,MAAM;CAejB"}
@@ -1,24 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/image-worker/types' {
2
- export type SuccessResponseEventData = {
3
- type: 'success-response';
4
- thread: string;
5
- url: string;
6
- };
7
- export type ErrorResponseEventData = {
8
- type: 'error-response';
9
- thread: string;
10
- url: string;
11
- };
12
- export type RequestEventData = {
13
- type: 'load';
14
- thread: string;
15
- url: string;
16
- };
17
- export type ThreadInitEventData = {
18
- type: 'connect';
19
- thread: string;
20
- };
21
- export type MainThreadEvent = MessageEvent<SuccessResponseEventData | ErrorResponseEventData>;
22
- export type WorkerThreadEvent = MessageEvent<RequestEventData> | MessageEvent<ThreadInitEventData>;
23
- }
24
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/image-worker/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,wBAAwB,GAAG,sBAAsB,CAAC,CAAC;AAC9F,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,gBAAgB,CAAC,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/image-worker/worker' {
2
- import type { RequestEventData } from '@warp-drive-mirror/experiments/image-worker/types';
3
- export class ImageWorker {
4
- threads: Map<string, MessagePort>;
5
- pendingImages: Map<string, Promise<string>>;
6
- options: {
7
- persisted: boolean;
8
- };
9
- isSharedWorker: boolean;
10
- cache: Map<string, string>;
11
- constructor(options?: {
12
- persisted: boolean;
13
- });
14
- fetch(url: string): Promise<string>;
15
- initialize(): void;
16
- setupThread(thread: string, port: MessagePort): void;
17
- request(event: RequestEventData): Promise<void>;
18
- }
19
- }
20
- //# sourceMappingURL=worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/image-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0C,MAAM,SAAS,CAAC;AAUxF,qBAAa,WAAW;IACd,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEvB,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE;IAa5C,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmBnC,UAAU;IA4BV,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;IAiBvC,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAOtC"}
@@ -1,4 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/image-worker' {
2
- export { ImageWorker } from '@warp-drive-mirror/experiments/image-worker/worker';
3
- }
4
- //# sourceMappingURL=image-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-worker.d.ts","sourceRoot":"","sources":["../src/image-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,18 +0,0 @@
1
- /// <reference path="./image-fetch.d.ts" />
2
- /// <reference path="./data-worker.d.ts" />
3
- /// <reference path="./image-worker.d.ts" />
4
- /// <reference path="./worker-fetch.d.ts" />
5
- /// <reference path="./document-storage.d.ts" />
6
- /// <reference path="./persisted-cache.d.ts" />
7
- /// <reference path="./persisted-cache/db.d.ts" />
8
- /// <reference path="./persisted-cache/cache.d.ts" />
9
- /// <reference path="./persisted-cache/fetch.d.ts" />
10
- /// <reference path="./document-storage/index.d.ts" />
11
- /// <reference path="./data-worker/worker.d.ts" />
12
- /// <reference path="./data-worker/cache-handler.d.ts" />
13
- /// <reference path="./data-worker/utils.d.ts" />
14
- /// <reference path="./data-worker/types.d.ts" />
15
- /// <reference path="./data-worker/fetch.d.ts" />
16
- /// <reference path="./image-worker/worker.d.ts" />
17
- /// <reference path="./image-worker/types.d.ts" />
18
- /// <reference path="./image-worker/fetch.d.ts" />
@@ -1,433 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/persisted-cache/cache' {
2
- import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
3
- import type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive-mirror/core-types/cache';
4
- import type { ResourceBlob } from '@warp-drive-mirror/core-types/cache/aliases';
5
- import type { Change } from '@warp-drive-mirror/core-types/cache/change';
6
- import type { Mutation } from '@warp-drive-mirror/core-types/cache/mutations';
7
- import type { Operation } from '@warp-drive-mirror/core-types/cache/operations';
8
- import type { CollectionRelationship, ResourceRelationship } from '@warp-drive-mirror/core-types/cache/relationship';
9
- import type { StableDocumentIdentifier } from '@warp-drive-mirror/core-types/identifier';
10
- import type { Value } from '@warp-drive-mirror/core-types/json/raw';
11
- import type { TypeFromInstanceOrString } from '@warp-drive-mirror/core-types/record';
12
- import type { RequestContext, StructuredDataDocument, StructuredDocument } from '@warp-drive-mirror/core-types/request';
13
- import type { ResourceDocument, SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';
14
- import type { ApiError } from '@warp-drive-mirror/core-types/spec/error';
15
- /**
16
- * The PersistedCache wraps a Cache to enhance it with
17
- * Persisted Storage capabilities.
18
- *
19
- * @class PersistedCache
20
- * @internal
21
- */
22
- export class PersistedCache implements Cache {
23
- _cache: Cache;
24
- _db: IDBDatabase;
25
- version: '2';
26
- constructor(cache: Cache, db: IDBDatabase);
27
- /**
28
- * Cache the response to a request
29
- *
30
- * Unlike `store.push` which has UPSERT
31
- * semantics, `put` has `replace` semantics similar to
32
- * the `http` method `PUT`
33
- *
34
- * the individually cacheabl
35
- * e resource data it may contain
36
- * should upsert, but the document data surrounding it should
37
- * fully replace any existing information
38
- *
39
- * Note that in order to support inserting arbitrary data
40
- * to the cache that did not originate from a request `put`
41
- * should expect to sometimes encounter a document with only
42
- * a `content` member and therefor must not assume the existence
43
- * of `request` and `response` on the document.
44
- *
45
- * @method put
46
- * @param {StructuredDocument} doc
47
- * @return {ResourceDocument}
48
- * @internal
49
- */
50
- put<T>(doc: StructuredDocument<T> | {
51
- content: T;
52
- }): ResourceDocument;
53
- /**
54
- * Perform an operation on the cache to update the remote state.
55
- *
56
- * Note: currently the only valid operation is a MergeOperation
57
- * which occurs when a collision of identifiers is detected.
58
- *
59
- * @method patch
60
- * @internal
61
- * @param op the operation to perform
62
- * @return {void}
63
- */
64
- patch(op: Operation): void;
65
- /**
66
- * Update resource data with a local mutation. Currently supports operations
67
- * on relationships only.
68
- *
69
- * @method mutate
70
- * @internal
71
- * @param mutation
72
- */
73
- mutate(mutation: Mutation): void;
74
- /**
75
- * Peek resource data from the Cache.
76
- *
77
- * In development, if the return value
78
- * is JSON the return value
79
- * will be deep-cloned and deep-frozen
80
- * to prevent mutation thereby enforcing cache
81
- * Immutability.
82
- *
83
- * This form of peek is useful for implementations
84
- * that want to feed raw-data from cache to the UI
85
- * or which want to interact with a blob of data
86
- * directly from the presentation cache.
87
- *
88
- * An implementation might want to do this because
89
- * de-referencing records which read from their own
90
- * blob is generally safer because the record does
91
- * not require retainining connections to the Store
92
- * and Cache to present data on a per-field basis.
93
- *
94
- * This generally takes the place of `getAttr` as
95
- * an API and may even take the place of `getRelationship`
96
- * depending on implementation specifics, though this
97
- * latter usage is less recommended due to the advantages
98
- * of the Graph handling necessary entanglements and
99
- * notifications for relational data.
100
- *
101
- * @method peek
102
- * @internal
103
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
104
- * @return {ResourceDocument | ResourceBlob | null} the known resource data
105
- */
106
- peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
107
- peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
108
- /**
109
- * Peek the Cache for the existing request data associated with
110
- * a cacheable request
111
- *
112
- * @method peekRequest
113
- * @param {StableDocumentIdentifier}
114
- * @return {StableDocumentIdentifier | null}
115
- * @internal
116
- */
117
- peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
118
- /**
119
- * Push resource data from a remote source into the cache for this identifier
120
- *
121
- * @method upsert
122
- * @internal
123
- * @param identifier
124
- * @param data
125
- * @param hasRecord
126
- * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
127
- */
128
- upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[];
129
- /**
130
- * Create a fork of the cache from the current state.
131
- *
132
- * Applications should typically not call this method themselves,
133
- * preferring instead to fork at the Store level, which will
134
- * utilize this method to fork the cache.
135
- *
136
- * @method fork
137
- * @internal
138
- * @return Promise<Cache>
139
- */
140
- fork(): Promise<Cache>;
141
- /**
142
- * Merge a fork back into a parent Cache.
143
- *
144
- * Applications should typically not call this method themselves,
145
- * preferring instead to merge at the Store level, which will
146
- * utilize this method to merge the caches.
147
- *
148
- * @method merge
149
- * @param {Cache} cache
150
- * @internal
151
- * @return Promise<void>
152
- */
153
- merge(cache: Cache): Promise<void>;
154
- /**
155
- * Generate the list of changes applied to all
156
- * record in the store.
157
- *
158
- * Each individual resource or document that has
159
- * been mutated should be described as an individual
160
- * `Change` entry in the returned array.
161
- *
162
- * A `Change` is described by an object containing up to
163
- * three properties: (1) the `identifier` of the entity that
164
- * changed; (2) the `op` code of that change being one of
165
- * `upsert` or `remove`, and if the op is `upsert` a `patch`
166
- * containing the data to merge into the cache for the given
167
- * entity.
168
- *
169
- * This `patch` is opaque to the Store but should be understood
170
- * by the Cache and may expect to be utilized by an Adapter
171
- * when generating data during a `save` operation.
172
- *
173
- * It is generally recommended that the `patch` contain only
174
- * the updated state, ignoring fields that are unchanged
175
- *
176
- * ```ts
177
- * interface Change {
178
- * identifier: StableRecordIdentifier | StableDocumentIdentifier;
179
- * op: 'upsert' | 'remove';
180
- * patch?: unknown;
181
- * }
182
- * ```
183
- *
184
- * @method diff
185
- * @internal
186
- */
187
- diff(): Promise<Change[]>;
188
- /**
189
- * Serialize the entire contents of the Cache into a Stream
190
- * which may be fed back into a new instance of the same Cache
191
- * via `cache.hydrate`.
192
- *
193
- * @method dump
194
- * @return {Promise<ReadableStream>}
195
- * @internal
196
- */
197
- dump(): Promise<ReadableStream<unknown>>;
198
- /**
199
- * hydrate a Cache from a Stream with content previously serialized
200
- * from another instance of the same Cache, resolving when hydration
201
- * is complete.
202
- *
203
- * This method should expect to be called both in the context of restoring
204
- * the Cache during application rehydration after SSR **AND** at unknown
205
- * times during the lifetime of an already booted application when it is
206
- * desired to bulk-load additional information into the cache. This latter
207
- * behavior supports optimizing pre/fetching of data for route transitions
208
- * via data-only SSR modes.
209
- *
210
- * @method hydrate
211
- * @param {ReadableStream} stream
212
- * @return {Promise<void>}
213
- * @internal
214
- */
215
- hydrate(stream: ReadableStream<unknown>): Promise<void>;
216
- /**
217
- * [LIFECYLCE] Signal to the cache that a new record has been instantiated on the client
218
- *
219
- * It returns properties from options that should be set on the record during the create
220
- * process. This return value behavior is deprecated.
221
- *
222
- * @method clientDidCreate
223
- * @internal
224
- * @param identifier
225
- * @param options
226
- */
227
- clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown>;
228
- /**
229
- * [LIFECYCLE] Signals to the cache that a resource
230
- * will be part of a save transaction.
231
- *
232
- * @method willCommit
233
- * @internal
234
- * @param identifier
235
- */
236
- willCommit(identifier: StableRecordIdentifier, context: RequestContext): void;
237
- /**
238
- * [LIFECYCLE] Signals to the cache that a resource
239
- * was successfully updated as part of a save transaction.
240
- *
241
- * @method didCommit
242
- * @internal
243
- * @param identifier
244
- * @param data
245
- */
246
- didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
247
- /**
248
- * [LIFECYCLE] Signals to the cache that a resource
249
- * was update via a save transaction failed.
250
- *
251
- * @method commitWasRejected
252
- * @internal
253
- * @param identifier
254
- * @param errors
255
- */
256
- commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
257
- /**
258
- * [LIFECYCLE] Signals to the cache that all data for a resource
259
- * should be cleared.
260
- *
261
- * @method unloadRecord
262
- * @internal
263
- * @param identifier
264
- */
265
- unloadRecord(identifier: StableRecordIdentifier): void;
266
- /**
267
- * Retrieve the data for an attribute from the cache
268
- *
269
- * @method getAttr
270
- * @internal
271
- * @param identifier
272
- * @param propertyName
273
- * @return {unknown}
274
- */
275
- getAttr(identifier: StableRecordIdentifier, field: string): Value | undefined;
276
- /**
277
- * Mutate the data for an attribute in the cache
278
- *
279
- * @method setAttr
280
- * @internal
281
- * @param identifier
282
- * @param propertyName
283
- * @param value
284
- */
285
- setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void;
286
- /**
287
- * Query the cache for the changed attributes of a resource.
288
- *
289
- * @method changedAttrs
290
- * @internal
291
- * @param identifier
292
- * @return
293
- */
294
- changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
295
- /**
296
- * Query the cache for whether any mutated attributes exist
297
- *
298
- * @method hasChangedAttrs
299
- * @internal
300
- * @param identifier
301
- * @return {boolean}
302
- */
303
- hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
304
- /**
305
- * Tell the cache to discard any uncommitted mutations to attributes
306
- *
307
- * @method rollbackAttrs
308
- * @internal
309
- * @param identifier
310
- * @return the names of attributes that were restored
311
- */
312
- rollbackAttrs(identifier: StableRecordIdentifier): string[];
313
- /**
314
- * Query the cache for the changes to relationships of a resource.
315
- *
316
- * Returns a map of relationship names to RelationshipDiff objects.
317
- *
318
- * ```ts
319
- * type RelationshipDiff =
320
- | {
321
- kind: 'collection';
322
- remoteState: StableRecordIdentifier[];
323
- additions: Set<StableRecordIdentifier>;
324
- removals: Set<StableRecordIdentifier>;
325
- localState: StableRecordIdentifier[];
326
- reordered: boolean;
327
- }
328
- | {
329
- kind: 'resource';
330
- remoteState: StableRecordIdentifier | null;
331
- localState: StableRecordIdentifier | null;
332
- };
333
- ```
334
- *
335
- * @method changedRelationships
336
- * @public
337
- * @param {StableRecordIdentifier} identifier
338
- * @return {Map<string, RelationshipDiff>}
339
- */
340
- changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
341
- /**
342
- * Query the cache for whether any mutated attributes exist
343
- *
344
- * @method hasChangedRelationships
345
- * @public
346
- * @param {StableRecordIdentifier} identifier
347
- * @return {boolean}
348
- */
349
- hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
350
- /**
351
- * Tell the cache to discard any uncommitted mutations to relationships.
352
- *
353
- * This will also discard the change on any appropriate inverses.
354
- *
355
- * This method is a candidate to become a mutation
356
- *
357
- * @method rollbackRelationships
358
- * @public
359
- * @param {StableRecordIdentifier} identifier
360
- * @return {string[]} the names of relationships that were restored
361
- */
362
- rollbackRelationships(identifier: StableRecordIdentifier): string[];
363
- /**
364
- * Query the cache for the current state of a relationship property
365
- *
366
- * @method getRelationship
367
- * @internal
368
- * @param identifier
369
- * @param propertyName
370
- * @return resource relationship object
371
- */
372
- getRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
373
- /**
374
- * Update the cache state for the given resource to be marked as locally deleted,
375
- * or remove such a mark.
376
- *
377
- * @method setIsDeleted
378
- * @internal
379
- * @param identifier
380
- * @param isDeleted
381
- */
382
- setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
383
- /**
384
- * Query the cache for any validation errors applicable to the given resource.
385
- *
386
- * @method getErrors
387
- * @internal
388
- * @param identifier
389
- * @return
390
- */
391
- getErrors(identifier: StableRecordIdentifier): ApiError[];
392
- /**
393
- * Query the cache for whether a given resource has any available data
394
- *
395
- * @method isEmpty
396
- * @internal
397
- * @param identifier
398
- * @return {boolean}
399
- */
400
- isEmpty(identifier: StableRecordIdentifier): boolean;
401
- /**
402
- * Query the cache for whether a given resource was created locally and not
403
- * yet persisted.
404
- *
405
- * @method isNew
406
- * @internal
407
- * @param identifier
408
- * @return {boolean}
409
- */
410
- isNew(identifier: StableRecordIdentifier): boolean;
411
- /**
412
- * Query the cache for whether a given resource is marked as deleted (but not
413
- * necessarily persisted yet).
414
- *
415
- * @method isDeleted
416
- * @internal
417
- * @param identifier
418
- * @return {boolean}
419
- */
420
- isDeleted(identifier: StableRecordIdentifier): boolean;
421
- /**
422
- * Query the cache for whether a given resource has been deleted and that deletion
423
- * has also been persisted.
424
- *
425
- * @method isDeletionCommitted
426
- * @internal
427
- * @param identifier
428
- * @return {boolean}
429
- */
430
- isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
431
- }
432
- }
433
- //# sourceMappingURL=cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/persisted-cache/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAC9G,OAAO,KAAK,EAAE,wBAAwB,EAAkC,MAAM,mCAAmC,CAAC;AAClH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACjH,OAAO,KAAK,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,KAAK;IAClC,MAAM,EAAE,KAAK,CAAC;I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,CAAC;IAIvF;;;;;;;OAOG;IACH,uBAAuB,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAIpE;;;;;;;;;;;OAWG;IACH,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,GAAG,MAAM,EAAE;IAOnE;;;;;;;;OAQG;IACH,eAAe,CACb,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,OAAO,GACrB,oBAAoB,GAAG,sBAAsB;IAOhD;;;;;;;;OAQG;IACH,YAAY,CAAC,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAI1E;;;;;;;OAOG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,QAAQ,EAAE;IAIzD;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAIpD;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAIlD;;;;;;;;OAQG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAItD;;;;;;;;OAQG;IACH,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;CAGjE"}
@@ -1,25 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/persisted-cache/db' {
2
- import type { StructuredDocument } from '@ember-data-mirror/request';
3
- import type { ExistingRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';
4
- import type { ResourceDocument } from '@warp-drive-mirror/core-types/spec/document';
5
- import type { ExistingResourceObject } from '@warp-drive-mirror/core-types/spec/json-api-raw';
6
- /**
7
- * Retrieve the configured IndexedDB database instance
8
- *
9
- * @typedoc
10
- */
11
- export function getCache(): Promise<IDBDatabase>;
12
- /**
13
- * Retrieve a previously cached request from the IndexedDB database
14
- * if one exists.
15
- *
16
- * If the request is found, the associated resources will also be
17
- * loaded from the cache and added to the response.
18
- *
19
- * If any resource is not found in the cache, the result will be null.
20
- *
21
- * @typedoc
22
- */
23
- export function getCachedRequest(db: IDBDatabase, lid: string): Promise<StructuredDocument<ResourceDocument<ExistingResourceObject & ExistingRecordIdentifier>> | null>;
24
- }
25
- //# sourceMappingURL=db.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/persisted-cache/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AASvF;;;;GAIG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAgBrD;AA4ED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,WAAW,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,sBAAsB,GAAG,wBAAwB,CAAC,CAAC,GAAG,IAAI,CAAC,CAiEzG"}
@@ -1,11 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/persisted-cache/fetch' {
2
- import type { Future, Handler, NextFn, StructuredDataDocument } from '@ember-data-mirror/request';
3
- import type { StoreRequestContext } from '@ember-data-mirror/store';
4
- /**
5
- * A Handler that resolves requests from the persisted cache.
6
- */
7
- export class PersistedFetch implements Handler {
8
- request<T>(context: StoreRequestContext, next: NextFn<T>): Future<T> | Promise<StructuredDataDocument<T>>;
9
- }
10
- }
11
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/persisted-cache/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EAEP,MAAM,EACN,sBAAsB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D;;GAEG;AACH,qBAAa,cAAe,YAAW,OAAO;IAC5C,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;CAsE1G"}
@@ -1,4 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/persisted-cache' {
2
- export { PersistedCache } from '@warp-drive-mirror/experiments/persisted-cache/cache';
3
- }
4
- //# sourceMappingURL=persisted-cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persisted-cache.d.ts","sourceRoot":"","sources":["../src/persisted-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,4 +0,0 @@
1
- declare module '@warp-drive-mirror/experiments/worker-fetch' {
2
- export { WorkerFetch } from '@warp-drive-mirror/experiments/data-worker/fetch';
3
- }
4
- //# sourceMappingURL=worker-fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-fetch.d.ts","sourceRoot":"","sources":["../src/worker-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}