@superbright/indexeddb-orm 0.1.3 → 0.1.5
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 +21 -20
- package/dist/adapters/dexie.d.ts +14 -0
- package/dist/adapters/structured-store.d.ts +44 -0
- package/dist/adapters/zustand-store.d.ts +54 -0
- package/dist/api/favorites.d.ts +4 -0
- package/dist/api/properties.d.ts +22 -0
- package/dist/api/users.d.ts +5 -0
- package/dist/db.d.ts +15 -0
- package/dist/debug.d.ts +2 -0
- package/dist/errors.d.ts +8 -0
- package/dist/features/units/transformers.d.ts +75 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.mjs +779 -569
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.ts +2880 -0
- package/dist/storage.d.ts +14 -0
- package/dist/stores/store.d.ts +42 -0
- package/dist/units/favorites.d.ts +7 -0
- package/dist/validation.d.ts +7 -0
- package/package.json +21 -20
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AsyncStringStorage {
|
|
2
|
+
getItem(name: string): Promise<string | null>;
|
|
3
|
+
setItem(name: string, value: string): Promise<void>;
|
|
4
|
+
removeItem(name: string): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
type storeKeys = "property" | "user" | "app";
|
|
7
|
+
export declare function kvGet<T>(key: storeKeys): Promise<T | null>;
|
|
8
|
+
export declare function kvSet<T>(key: storeKeys, value: T): Promise<void>;
|
|
9
|
+
export declare function kvRemove(key: storeKeys): Promise<void>;
|
|
10
|
+
export declare function createORMStringStorage(opts?: {
|
|
11
|
+
prefix?: string;
|
|
12
|
+
fallbackToMemory?: boolean;
|
|
13
|
+
}): AsyncStringStorage;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ZodObject, ZodTypeAny } from "zod";
|
|
2
|
+
import { type UnifiedStoreData, type UserPropertyState, type Filters, type QueryParams, type ResultsMode, type SortBy, type TourContactData } from "../schema";
|
|
3
|
+
export declare class UnifiedStore {
|
|
4
|
+
private getState;
|
|
5
|
+
private setState;
|
|
6
|
+
initializeProperty(propertyId: string | number, slug: string): Promise<void>;
|
|
7
|
+
setUnitResults(units: unknown, schema?: ZodTypeAny): Promise<void>;
|
|
8
|
+
clearUnitResults(): Promise<void>;
|
|
9
|
+
setPropertyData(propertyId: string | number, data: unknown, schema?: ZodObject<any, any, any, any, any>): Promise<void>;
|
|
10
|
+
mergePropertyData(propertyId: string | number, partial: unknown, schema?: ZodObject<any, any, any, any, any>): Promise<void>;
|
|
11
|
+
upsertPropertyFromApi(apiProperty: unknown, schema?: ZodTypeAny): Promise<void>;
|
|
12
|
+
setCurrentProperty(propertyId: string | number, slug?: string): Promise<void>;
|
|
13
|
+
setCurrentPropertySlug(slug: string): Promise<void>;
|
|
14
|
+
setHasPreviouslySearched(slug: string): Promise<void>;
|
|
15
|
+
toggleFavorite(unitId: string): Promise<void>;
|
|
16
|
+
markUnitAsViewed(unitId: string, slug: string): Promise<void>;
|
|
17
|
+
setTourContactedOn(): Promise<void>;
|
|
18
|
+
getTourContactedOn(): Promise<string | null>;
|
|
19
|
+
setQuestionnaireResults(results: unknown): Promise<void>;
|
|
20
|
+
setTourContactData(data: TourContactData): Promise<void>;
|
|
21
|
+
setFilters(filters: Partial<Filters>): Promise<void>;
|
|
22
|
+
setTempFilters(filters: Partial<Filters>): Promise<void>;
|
|
23
|
+
setFiltersToDefault(): Promise<void>;
|
|
24
|
+
setApiFilters(filters: Partial<QueryParams>): Promise<void>;
|
|
25
|
+
handleTempFilterChange<K extends keyof Filters>(key: K, value: Filters[K]): Promise<void>;
|
|
26
|
+
submitFilterUpdate(): Promise<void>;
|
|
27
|
+
setResultsMode(mode: ResultsMode): Promise<void>;
|
|
28
|
+
setSortBy(sortBy: SortBy): Promise<void>;
|
|
29
|
+
setResolvedQuestionnaireValues(name: string, values: string[]): Promise<void>;
|
|
30
|
+
getUnitState(unitId: string): Promise<{
|
|
31
|
+
isFavorite: boolean;
|
|
32
|
+
viewedDate: string;
|
|
33
|
+
}>;
|
|
34
|
+
getResultsUrl(): Promise<string | null>;
|
|
35
|
+
getCurrentProperty(): Promise<UserPropertyState | null>;
|
|
36
|
+
getPropertyData(propertyId?: string | number): Promise<UserPropertyState | null>;
|
|
37
|
+
getFullState(): Promise<UnifiedStoreData>;
|
|
38
|
+
initialize(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export declare const store: UnifiedStore;
|
|
41
|
+
export { UnifiedStore as Store };
|
|
42
|
+
export type { UserPropertyState, Filters } from "../schema";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const favorites: {
|
|
2
|
+
isFavorite(propertyId: string | number, unitId: string): Promise<boolean>;
|
|
3
|
+
toggle(propertyId: string | number, unitId: string): Promise<string[]>;
|
|
4
|
+
set(propertyId: string | number, unitId: string, on: boolean): Promise<string[]>;
|
|
5
|
+
getAll(propertyId: string | number): Promise<string[]>;
|
|
6
|
+
};
|
|
7
|
+
export { favorites };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export type ValidationMode = "strict" | "warn" | "silent";
|
|
3
|
+
export declare function configureValidation(opts: {
|
|
4
|
+
mode?: ValidationMode;
|
|
5
|
+
onIssue?: (ctx: string, details: unknown) => void;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function validate<T>(schema: z.ZodType<T>, value: unknown, ctx: string): T | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superbright/indexeddb-orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Vite + TypeScript starter for an IndexedDB ORM (Dexie + Zod) with playground.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -15,23 +15,9 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"sideEffects": false,
|
|
18
|
-
"files": [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"clean": "rimraf dist",
|
|
22
|
-
"build": "pnpm clean && vite build && tsc -p tsconfig.build.json",
|
|
23
|
-
"prepare": "pnpm build",
|
|
24
|
-
"start": "vite --clearScreen false",
|
|
25
|
-
"dev": "concurrently -k -n PLAY,BUILD \"pnpm:start\" \"pnpm:watch\"",
|
|
26
|
-
"watch": "concurrently -k -n TYPES,BUNDLE \"pnpm:watch:types\" \"pnpm:watch:bundle\"",
|
|
27
|
-
"watch:types": "tsc -w -p tsconfig.build.json",
|
|
28
|
-
"watch:bundle": "vite build --watch",
|
|
29
|
-
"test": "vitest run",
|
|
30
|
-
"test:watch": "vitest",
|
|
31
|
-
"format": "pnpm format:write",
|
|
32
|
-
"format:write": "prettier --write .",
|
|
33
|
-
"format:check": "prettier --check ."
|
|
34
|
-
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
35
21
|
"dependencies": {
|
|
36
22
|
"dexie": "^4.0.8",
|
|
37
23
|
"zod": "^3.23.8"
|
|
@@ -45,6 +31,21 @@
|
|
|
45
31
|
"rimraf": "^5.0.5",
|
|
46
32
|
"typescript": "^5.4.5",
|
|
47
33
|
"vite": "^5.4.0",
|
|
48
|
-
"vitest": "^2.0.5"
|
|
34
|
+
"vitest": "^2.0.5",
|
|
35
|
+
"zustand": "^5.0.8"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"build": "pnpm clean && vite build && tsc -p tsconfig.build.json",
|
|
40
|
+
"start": "vite --clearScreen false",
|
|
41
|
+
"dev": "concurrently -k -n PLAY,BUILD \"pnpm:start\" \"pnpm:watch\"",
|
|
42
|
+
"watch": "concurrently -k -n TYPES,BUNDLE \"pnpm:watch:types\" \"pnpm:watch:bundle\"",
|
|
43
|
+
"watch:types": "tsc -w -p tsconfig.build.json",
|
|
44
|
+
"watch:bundle": "vite build --watch",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"format": "pnpm format:write",
|
|
48
|
+
"format:write": "prettier --write .",
|
|
49
|
+
"format:check": "prettier --check ."
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
}
|