@superbright/indexeddb-orm 0.1.1 → 0.1.2
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/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +1154 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -25
- package/.prettierignore +0 -9
- package/.prettierrc.cjs +0 -13
- package/CONSUMING_APP_GUIDE.md +0 -164
- package/MIGRATION_SUMMARY.md +0 -157
- package/docs/app-store-guide.md +0 -160
- package/docs/property-store.md +0 -192
- package/docs/structured-store-migration.md +0 -129
- package/examples/property-store-migration.ts +0 -164
- package/index.html +0 -29
- package/playground/main.ts +0 -38
- package/src/adapters/dexie.ts +0 -28
- package/src/adapters/structured-store.ts +0 -85
- package/src/adapters/zustand-app.ts +0 -221
- package/src/adapters/zustand-unified.ts +0 -342
- package/src/adapters/zustand.ts +0 -142
- package/src/api/app.ts +0 -270
- package/src/api/favorites.ts +0 -64
- package/src/api/properties.ts +0 -293
- package/src/api/users.ts +0 -66
- package/src/db.ts +0 -185
- package/src/debug.ts +0 -25
- package/src/errors.ts +0 -13
- package/src/index.ts +0 -34
- package/src/schema.ts +0 -48
- package/src/storage.ts +0 -71
- package/src/stores/property.ts +0 -133
- package/src/stores/unified.ts +0 -507
- package/src/units/favorites.ts +0 -19
- package/src/validation.ts +0 -32
- package/test-export.js +0 -6
- package/tests/orm.spec.ts +0 -17
- package/tests/setup.ts +0 -2
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -29
- package/vite.config.ts +0 -16
- package/vitest.config.ts +0 -9
package/src/units/favorites.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/units/favorites.ts
|
|
2
|
-
import * as api from "../api/favorites";
|
|
3
|
-
|
|
4
|
-
const favorites = {
|
|
5
|
-
async isFavorite(propertyId: string | number, unitId: string): Promise<boolean> {
|
|
6
|
-
return api.isUnitFavorited(propertyId, unitId);
|
|
7
|
-
},
|
|
8
|
-
async toggle(propertyId: string | number, unitId: string): Promise<string[]> {
|
|
9
|
-
return api.toggleFavoriteUnit(propertyId, unitId);
|
|
10
|
-
},
|
|
11
|
-
async set(propertyId: string | number, unitId: string, on: boolean): Promise<string[]> {
|
|
12
|
-
return api.setFavoriteUnit(propertyId, unitId, on);
|
|
13
|
-
},
|
|
14
|
-
async getAll(propertyId: string | number): Promise<string[]> {
|
|
15
|
-
return api.getFavoritedUnitsForProperty(propertyId);
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export {favorites}
|
package/src/validation.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// src/validation.ts
|
|
2
|
-
import type { z } from "zod";
|
|
3
|
-
import { SchemaMismatchError } from "./errors";
|
|
4
|
-
|
|
5
|
-
export type ValidationMode = "strict" | "warn" | "silent";
|
|
6
|
-
let mode: ValidationMode = "strict";
|
|
7
|
-
let onIssue: ((ctx: string, details: unknown) => void) | undefined;
|
|
8
|
-
|
|
9
|
-
export function configureValidation(opts: {
|
|
10
|
-
mode?: ValidationMode;
|
|
11
|
-
onIssue?: (ctx: string, details: unknown) => void;
|
|
12
|
-
}) {
|
|
13
|
-
if (opts.mode) mode = opts.mode;
|
|
14
|
-
onIssue = opts.onIssue;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function validate<T>(
|
|
18
|
-
schema: z.ZodType<T>,
|
|
19
|
-
value: unknown,
|
|
20
|
-
ctx: string,
|
|
21
|
-
): T | null {
|
|
22
|
-
const res = schema.safeParse(value);
|
|
23
|
-
if (res.success) return res.data;
|
|
24
|
-
|
|
25
|
-
const details = res.error.flatten();
|
|
26
|
-
onIssue?.(ctx, details);
|
|
27
|
-
|
|
28
|
-
if (mode === "strict")
|
|
29
|
-
throw new SchemaMismatchError(`ORM schema mismatch in ${ctx}`, details);
|
|
30
|
-
if (mode === "warn") console.warn(`ORM schema mismatch in ${ctx}`, details); // eslint-disable-line no-console
|
|
31
|
-
return null; // silent/warn → let caller decide how to proceed
|
|
32
|
-
}
|
package/test-export.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Quick test to verify the export works
|
|
2
|
-
import { createZustandPropertyStore, createZustandUnifiedStore } from './dist/index.es.js';
|
|
3
|
-
|
|
4
|
-
console.log('createZustandPropertyStore:', typeof createZustandPropertyStore);
|
|
5
|
-
console.log('createZustandUnifiedStore:', typeof createZustandUnifiedStore);
|
|
6
|
-
console.log('Are they the same function?', createZustandPropertyStore === createZustandUnifiedStore);
|
package/tests/orm.spec.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
-
import { resetDB } from "../src/db";
|
|
3
|
-
import { ensureUser } from "../src/api/users";
|
|
4
|
-
|
|
5
|
-
describe("IndexedDB ORM Starter", () => {
|
|
6
|
-
beforeEach(async () => {
|
|
7
|
-
await resetDB();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("reads users", async () => {
|
|
11
|
-
const uuid = "123e4567-e89b-12d3-a456-426614174000";
|
|
12
|
-
await ensureUser(() => uuid);
|
|
13
|
-
const user = await ensureUser(() => uuid);
|
|
14
|
-
expect(user).toBeDefined();
|
|
15
|
-
expect(user.uuid).toBe(uuid);
|
|
16
|
-
});
|
|
17
|
-
});
|
package/tests/setup.ts
DELETED
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Bundler",
|
|
6
|
-
"lib": [
|
|
7
|
-
"ES2020",
|
|
8
|
-
"DOM"
|
|
9
|
-
],
|
|
10
|
-
"strict": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationMap": false,
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"esModuleInterop": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"types": [
|
|
20
|
-
"vitest/globals"
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"src",
|
|
25
|
-
"tests",
|
|
26
|
-
"vitest.config.ts",
|
|
27
|
-
"playground"
|
|
28
|
-
]
|
|
29
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
build: {
|
|
5
|
-
lib: {
|
|
6
|
-
entry: "src/index.ts",
|
|
7
|
-
name: "IndexedDbOrm",
|
|
8
|
-
formats: ["es", "cjs"],
|
|
9
|
-
fileName: (format) => `index.${format}.js`,
|
|
10
|
-
},
|
|
11
|
-
rollupOptions: {
|
|
12
|
-
external: ["dexie", "zod"],
|
|
13
|
-
},
|
|
14
|
-
sourcemap: true,
|
|
15
|
-
},
|
|
16
|
-
});
|