@keepkit/core 0.28.19 → 0.28.21
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/README.md +14 -3
- package/dist/{chunk-HTTOCLOC.js → chunk-IBODMDW3.js} +21 -2
- package/dist/chunk-IBODMDW3.js.map +1 -0
- package/dist/{chunk-OLGYOC3D.js → chunk-OHKVHU5I.js} +2 -2
- package/dist/chunk-OHKVHU5I.js.map +1 -0
- package/dist/chunk-R5BTN27K.js +62 -0
- package/dist/chunk-R5BTN27K.js.map +1 -0
- package/dist/core.d.ts +3 -3
- package/dist/core.js +5 -3
- package/dist/core.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +31 -18
- package/dist/react.js.map +1 -1
- package/dist/schema.d.ts +2 -1
- package/dist/schema.js +3 -1
- package/dist/storage.js +2 -2
- package/dist/{store-3LwroO9A.d.ts → store-Brz6nTKv.d.ts} +4 -2
- package/package.json +1 -1
- package/dist/chunk-5W4QSJHV.js +0 -41
- package/dist/chunk-5W4QSJHV.js.map +0 -1
- package/dist/chunk-HTTOCLOC.js.map +0 -1
- package/dist/chunk-OLGYOC3D.js.map +0 -1
package/dist/schema.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ declare class KeepSchemaValidationError extends Error {
|
|
|
8
8
|
itemId?: string;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
+
declare function stripUndefinedMeta<T>(value: T): T;
|
|
11
12
|
/** Parse metadata with a Zod-like, safeParse-like, or Standard Schema parser. */
|
|
12
13
|
declare function parseKeepMeta<T>(schema: KeepSchema<T>, value: unknown): Promise<T>;
|
|
13
14
|
declare function validateKeepItem<TMeta>(item: KeepItem<unknown>, schema: KeepSchema<TMeta>): Promise<KeepItem<TMeta>>;
|
|
14
15
|
|
|
15
|
-
export { KeepSchemaValidationError, parseKeepMeta, validateKeepItem };
|
|
16
|
+
export { KeepSchemaValidationError, parseKeepMeta, stripUndefinedMeta, validateKeepItem };
|
package/dist/schema.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
KeepSchemaValidationError,
|
|
3
3
|
parseKeepMeta,
|
|
4
|
+
stripUndefinedMeta,
|
|
4
5
|
validateKeepItem
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R5BTN27K.js";
|
|
6
7
|
export {
|
|
7
8
|
KeepSchemaValidationError,
|
|
8
9
|
parseKeepMeta,
|
|
10
|
+
stripUndefinedMeta,
|
|
9
11
|
validateKeepItem
|
|
10
12
|
};
|
|
11
13
|
//# sourceMappingURL=schema.js.map
|
package/dist/storage.js
CHANGED
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
createBrowserStorageAdapter,
|
|
19
19
|
createScopedStorageAdapter,
|
|
20
20
|
createStorageAdapter
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-IBODMDW3.js";
|
|
22
|
+
import "./chunk-R5BTN27K.js";
|
|
23
23
|
export {
|
|
24
24
|
DEFAULT_INDEXEDDB_DATABASE,
|
|
25
25
|
DEFAULT_INDEXEDDB_STORE,
|
|
@@ -88,6 +88,7 @@ type KeepItemRevalidationResult<TMeta = Record<string, unknown>> = {
|
|
|
88
88
|
reason?: string;
|
|
89
89
|
};
|
|
90
90
|
type KeepItemRevalidator<TMeta = Record<string, unknown>> = (item: KeepItem<TMeta>) => KeepItemRevalidationResult<TMeta> | KeepItemRevalidationResult<TMeta>["status"] | Promise<KeepItemRevalidationResult<TMeta> | KeepItemRevalidationResult<TMeta>["status"]>;
|
|
91
|
+
type KeepItemsRevalidator<TMeta = Record<string, unknown>> = (items: KeepItem<TMeta>[]) => Promise<Record<string, KeepItemRevalidationResult<TMeta> | KeepItemStatus>>;
|
|
91
92
|
type KeepItemResolver<TMeta = Record<string, unknown>> = (item: KeepItem<TMeta>, result: KeepItemRevalidationResult<TMeta>) => KeepItem<TMeta> | undefined | Promise<KeepItem<TMeta> | undefined>;
|
|
92
93
|
type KeepItemMetadataRefresher<TMeta = Record<string, unknown>> = (item: KeepItem<TMeta>) => TMeta | Promise<TMeta>;
|
|
93
94
|
/** Return whether source metadata should be fetched again based on its age. */
|
|
@@ -113,6 +114,7 @@ type KeepAutoRevalidationOptions<TMeta = Record<string, unknown>> = {
|
|
|
113
114
|
intervalMs?: number;
|
|
114
115
|
removeStatuses?: Array<Exclude<KeepItemStatus, "available">>;
|
|
115
116
|
revalidator?: KeepItemRevalidator<TMeta>;
|
|
117
|
+
revalidateMany?: KeepItemsRevalidator<TMeta>;
|
|
116
118
|
};
|
|
117
119
|
type KeepItemRevalidationSummary<TMeta = Record<string, unknown>> = {
|
|
118
120
|
items: KeepItem<TMeta>[];
|
|
@@ -206,7 +208,7 @@ type KeepStoreActions<TMeta = Record<string, unknown>> = {
|
|
|
206
208
|
clear: () => Promise<void>;
|
|
207
209
|
refresh: () => Promise<void>;
|
|
208
210
|
refreshItemMetadata: (id: string, refresh: KeepItemMetadataRefresher<TMeta>) => Promise<void>;
|
|
209
|
-
revalidateItems: (revalidator
|
|
211
|
+
revalidateItems: (revalidator?: KeepItemRevalidator<TMeta>, options?: RevalidateKeepItemsOptions<TMeta>) => Promise<KeepItemRevalidationSummary<TMeta>>;
|
|
210
212
|
reorderItems: (orderedIds: string[]) => Promise<void>;
|
|
211
213
|
moveItem: (id: string, targetIndex: number) => Promise<void>;
|
|
212
214
|
};
|
|
@@ -219,4 +221,4 @@ declare class KeepStore<TMeta = Record<string, unknown>> {
|
|
|
219
221
|
setState(next: Partial<KeepStoreState<TMeta>>): void;
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
export {
|
|
224
|
+
export { moveKeepItem as A, orderKeepItems as B, queryKeepItems as C, DEFAULT_KEEP_URL_PARAMS as D, reconcileKeepItems as E, reorderKeepItems as F, revalidateKeepItems as G, serializeKeepListQuery as H, type KeepListQuery as K, type QueryKeepItemsResult as Q, type RevalidateKeepItemsOptions as R, type KeepAutoRevalidationOptions as a, type KeepCollectionMeta as b, type KeepItemMetadataRefresher as c, type KeepItemResolver as d, type KeepItemRevalidationRecord as e, type KeepItemRevalidationResult as f, type KeepItemRevalidationSummary as g, type KeepItemRevalidator as h, type KeepItemsRevalidator as i, type KeepNavigationState as j, type KeepRediscoveryOptions as k, type KeepRediscoveryStrategy as l, KeepStore as m, type KeepStoreActions as n, type KeepStoreState as o, type KeepUrlParamNames as p, type KeepUrlState as q, type KeepUrlSyncOptions as r, createInboxQuery as s, createRediscoveryQuery as t, decodeKeepListQuery as u, encodeKeepListQuery as v, getKeepNavigationState as w, getTagCounts as x, isKeepItemMetadataStale as y, mergeKeepListQueryFromUrl as z };
|
package/package.json
CHANGED
package/dist/chunk-5W4QSJHV.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/features/persistence/schema.ts
|
|
2
|
-
var KeepSchemaValidationError = class extends Error {
|
|
3
|
-
constructor(message, options = {}) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = "KeepSchemaValidationError";
|
|
6
|
-
this.cause = options.cause;
|
|
7
|
-
this.itemId = options.itemId;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
async function parseKeepMeta(schema, value) {
|
|
11
|
-
try {
|
|
12
|
-
if ("parse" in schema) return await schema.parse(value);
|
|
13
|
-
if ("safeParse" in schema) {
|
|
14
|
-
const result2 = await schema.safeParse(value);
|
|
15
|
-
if (result2.success) return result2.data;
|
|
16
|
-
throw new KeepSchemaValidationError("KeepKit metadata did not match the configured schema.", {
|
|
17
|
-
cause: result2.error
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
const result = await schema["~standard"].validate(value);
|
|
21
|
-
if (!result.issues && "value" in result) return result.value;
|
|
22
|
-
throw new KeepSchemaValidationError("KeepKit metadata did not match the configured schema.", {
|
|
23
|
-
cause: result.issues
|
|
24
|
-
});
|
|
25
|
-
} catch (cause) {
|
|
26
|
-
if (cause instanceof KeepSchemaValidationError) throw cause;
|
|
27
|
-
throw new KeepSchemaValidationError("KeepKit metadata did not match the configured schema.", {
|
|
28
|
-
cause
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async function validateKeepItem(item, schema) {
|
|
33
|
-
return { ...item, meta: await parseKeepMeta(schema, item.meta) };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
KeepSchemaValidationError,
|
|
38
|
-
parseKeepMeta,
|
|
39
|
-
validateKeepItem
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=chunk-5W4QSJHV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/features/persistence/schema.ts"],"sourcesContent":["import type { KeepItem, KeepSchema } from \"../items/types\";\n\nexport class KeepSchemaValidationError extends Error {\n readonly cause?: unknown;\n readonly itemId?: string;\n\n constructor(message: string, options: { cause?: unknown; itemId?: string } = {}) {\n super(message);\n this.name = \"KeepSchemaValidationError\";\n this.cause = options.cause;\n this.itemId = options.itemId;\n }\n}\n\n/** Parse metadata with a Zod-like, safeParse-like, or Standard Schema parser. */\nexport async function parseKeepMeta<T>(schema: KeepSchema<T>, value: unknown): Promise<T> {\n try {\n if (\"parse\" in schema) return await schema.parse(value);\n\n if (\"safeParse\" in schema) {\n const result = await schema.safeParse(value);\n if (result.success) return result.data;\n throw new KeepSchemaValidationError(\"KeepKit metadata did not match the configured schema.\", {\n cause: result.error,\n });\n }\n\n const result = await schema[\"~standard\"].validate(value);\n if (!result.issues && \"value\" in result) return result.value as T;\n throw new KeepSchemaValidationError(\"KeepKit metadata did not match the configured schema.\", {\n cause: result.issues,\n });\n } catch (cause) {\n if (cause instanceof KeepSchemaValidationError) throw cause;\n throw new KeepSchemaValidationError(\"KeepKit metadata did not match the configured schema.\", {\n cause,\n });\n }\n}\n\nexport async function validateKeepItem<TMeta>(\n item: KeepItem<unknown>,\n schema: KeepSchema<TMeta>,\n): Promise<KeepItem<TMeta>> {\n return { ...item, meta: await parseKeepMeta(schema, item.meta) };\n}\n"],"mappings":";AAEO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAInD,YAAY,SAAiB,UAAgD,CAAC,GAAG;AAC/E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ,QAAQ;AACrB,SAAK,SAAS,QAAQ;AAAA,EACxB;AACF;AAGA,eAAsB,cAAiB,QAAuB,OAA4B;AACxF,MAAI;AACF,QAAI,WAAW,OAAQ,QAAO,MAAM,OAAO,MAAM,KAAK;AAEtD,QAAI,eAAe,QAAQ;AACzB,YAAMA,UAAS,MAAM,OAAO,UAAU,KAAK;AAC3C,UAAIA,QAAO,QAAS,QAAOA,QAAO;AAClC,YAAM,IAAI,0BAA0B,yDAAyD;AAAA,QAC3F,OAAOA,QAAO;AAAA,MAChB,CAAC;AAAA,IACH;AAEA,UAAM,SAAS,MAAM,OAAO,WAAW,EAAE,SAAS,KAAK;AACvD,QAAI,CAAC,OAAO,UAAU,WAAW,OAAQ,QAAO,OAAO;AACvD,UAAM,IAAI,0BAA0B,yDAAyD;AAAA,MAC3F,OAAO,OAAO;AAAA,IAChB,CAAC;AAAA,EACH,SAAS,OAAO;AACd,QAAI,iBAAiB,0BAA2B,OAAM;AACtD,UAAM,IAAI,0BAA0B,yDAAyD;AAAA,MAC3F;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,eAAsB,iBACpB,MACA,QAC0B;AAC1B,SAAO,EAAE,GAAG,MAAM,MAAM,MAAM,cAAc,QAAQ,KAAK,IAAI,EAAE;AACjE;","names":["result"]}
|