diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 4f44fe8..1917490 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,8 +1,8 @@ # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json -language: "en-US" +language: 'en-US' early_access: false reviews: - profile: "assertive" + profile: 'assertive' request_changes_workflow: false high_level_summary: true poem: false @@ -13,4 +13,4 @@ reviews: enabled: true drafts: false chat: - auto_reply: true \ No newline at end of file + auto_reply: true diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 10d07bc..3ffc96e 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -30,7 +30,7 @@ services: volumes: - redis-data:/data healthcheck: - test: ["CMD-SHELL", "redis-cli ping | grep PONG"] + test: ['CMD-SHELL', 'redis-cli ping | grep PONG'] interval: 5s timeout: 5s retries: 5 @@ -45,4 +45,4 @@ services: ports: - 5540:5540 volumes: - - redis-insight:/data \ No newline at end of file + - redis-insight:/data diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index db22738..b946251 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -18,7 +18,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v5 - - name: Install system dependencies + - name: Install system dependencies run: | apt-get update apt-get install -y unzip @@ -35,4 +35,4 @@ jobs: - name: Test env: REDIS_URL: redis://redis:6379 - run: bun run test \ No newline at end of file + run: bun run test diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 6c4e748..80b7ece 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -22,7 +22,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v5 - - name: Install system dependencies + - name: Install system dependencies run: | apt-get update apt-get install -y unzip @@ -41,15 +41,12 @@ jobs: REDIS_URL: redis://redis:6379 run: bun run test - - name: Copy extra files - run: cp ./README.md ./LICENSE ./packages/cache - - name: Publish package to NPM env: NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }} - run: cd ./packages/cache && bun publish --tolerate-republish --access public + run: bun publish --tolerate-republish --access public - name: Publish package to GitHub env: NPM_CONFIG_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: cd ./packages/cache && bun publish --tolerate-republish --access public --registry https://npm.pkg.github.com \ No newline at end of file + run: bun publish --tolerate-republish --access public --registry https://npm.pkg.github.com diff --git a/packages/cache/.npmignore b/.npmignore similarity index 100% rename from packages/cache/.npmignore rename to .npmignore diff --git a/.oxfmtrc.json b/.oxfmtrc.json index de4f02e..6bd40dc 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -9,7 +9,7 @@ "insertFinalNewline": true, "jsxSingleQuote": true, "trailingComma": "all", - "ignorePatterns": [ + "ignorePatterns": [ "**/dist/*", "**/.next/*", "**/.turbo/*", @@ -21,5 +21,5 @@ "apps/next/src/app/(payload)/*", "apps/start/.wrangler/*", "apps/start/src/routeTree.gen.ts" - ], -} \ No newline at end of file + ] +} diff --git a/.oxlintrc.json b/.oxlintrc.json index 15ae40f..5af516a 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -1,9 +1,6 @@ { "$schema": "./node_modules/oxlint/configuration_schema.json", - "plugins": [ - "typescript", - "react" - ], + "plugins": ["typescript", "react"], "categories": { "correctness": "warn", "pedantic": "warn", @@ -105,9 +102,7 @@ ], "overrides": [ { - "files": [ - "**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}" - ], + "files": ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], "rules": { "for-direction": "error", "no-async-promise-executor": "error", @@ -165,9 +160,7 @@ } }, { - "files": [ - "**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}" - ], + "files": ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], "env": { "browser": true, "commonjs": true, @@ -176,12 +169,7 @@ } }, { - "files": [ - "**/*.ts", - "**/*.tsx", - "**/*.mts", - "**/*.cts" - ], + "files": ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"], "rules": { "no-class-assign": "off", "no-const-assign": "off", @@ -202,4 +190,4 @@ } } ] -} \ No newline at end of file +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 61dadd3..d788244 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -8,4 +8,4 @@ "vitest.explorer", "zenstack.zenstack-v3" ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index d0b0f3d..507f676 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,5 @@ "typescript.experimental.useTsgo": true, "[javascript][javascriptreact][typescript][typescriptreact][json][jsonc]": { "editor.defaultFormatter": "oxc.oxc-vscode" - }, + } } diff --git a/README.md b/README.md index d34a6ef..cad5a9c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ ZenStack Cache - Reduce response times and database load with query-level caching integrated with the ZenStack ORM. +Reduce response times and database load with query-level caching integrated with the ZenStack ORM. +
## Features -* đ **Redis Cache:** A central cache to scale across different systems. -* đĨī¸ **Memory Cache:** A simple cache when scale is not a concern. -* đ **Type-safety:** The caching options appear in the intellisense for all read queries. -* đˇī¸ **Tag-based Invalidation:** Easily invalidate multiple related cache entries. + +- đ **Redis Cache:** A central cache to scale across different systems. +- đĨī¸ **Memory Cache:** A simple cache when scale is not a concern. +- đ **Type-safety:** The caching options appear in the intellisense for all read queries. +- đˇī¸ **Tag-based Invalidation:** Easily invalidate multiple related cache entries. ## Requirements -* ZenStack (version >= `3.3.0`) -* Node.js (version >= `20.0.0`) -* Redis (version >= `7.0.0`) - * âšī¸ Only if you intend to use the `RedisCacheProvider` +- ZenStack (version >= `3.3.0`) +- Node.js (version >= `20.0.0`) +- Redis (version >= `7.0.0`) + - âšī¸ Only if you intend to use the `RedisCacheProvider` ## Installation @@ -115,21 +117,22 @@ After performing a query, you can check where the result came from. const publishedPostsStatus = client.$cache.status // 'hit' | 'miss' | 'stale' ``` -* `hit` - a cache entry in the `ttl` window was found, and the database was not queried. -* `miss` - a cache entry was not found, and the database was queried. -* `stale` - a cache entry in the `swr` window was found, and the database was queried in the background to revalidate it. +- `hit` - a cache entry in the `ttl` window was found, and the database was not queried. +- `miss` - a cache entry was not found, and the database was queried. +- `stale` - a cache entry in the `swr` window was found, and the database was queried in the background to revalidate it. ## Revalidation If the result was stale, you can choose to await its revalidation. + ```typescript const revalidatedPublishedPosts = await client.$cache.revalidation as Post[] ``` ## Cache Options -* `ttl` reduces response times and database load by serving cached results. -* `swr` reduces response times by serving cached results, but does not reduce database load because it performs a revalidation in the background after each request. +- `ttl` reduces response times and database load by serving cached results. +- `swr` reduces response times by serving cached results, but does not reduce database load because it performs a revalidation in the background after each request. > [!NOTE] > The total TTL of a cache entry is equal to its `ttl` + `swr`. The `ttl` window comes first, followed by the `swr` window. You can combine the two options to best suit the needs of your application. diff --git a/bun.lock b/bun.lock index e05a575..6c674f6 100644 --- a/bun.lock +++ b/bun.lock @@ -4,51 +4,30 @@ "workspaces": { "": { "name": "workspace", - "devDependencies": { - "@types/bun": "catalog:", - "@types/node": "catalog:", - "oxfmt": "0.20.0", - "oxlint": "1.35.0", - "tsdown": "0.18.3", - "turbo": "2.7.2", - "typescript": "catalog:", - "vitest": "4.0.17", - }, - }, - "packages/cache": { - "name": "@visualbravo/zenstack-cache", - "version": "0.0.0", "dependencies": { "decimal.js": "^10.6.0", - "ioredis": "catalog:", + "ioredis": "^5.0.0", "murmurhash": "^2.0.1", "stable-hash": "^0.0.6", "superjson": "^2.2.2", - "zod": "catalog:", + "zod": "^4.1.0", }, "devDependencies": { "@types/better-sqlite3": "7.6.13", - "@zenstack-cache/config": "workspace:*", + "@types/bun": "1.3.8", + "@types/node": "20.19.6", "better-sqlite3": "12.6.2", - "kysely": "catalog:", + "kysely": "0.28.8", + "oxfmt": "0.20.0", + "oxlint": "1.35.0", + "tsdown": "0.18.3", + "typescript": "5.9.3", + "vitest": "4.0.17", }, "peerDependencies": { - "@zenstackhq/orm": "catalog:", + "@zenstackhq/orm": "^3.3.0", }, }, - "packages/config": { - "name": "@zenstack-cache/config", - "version": "0.0.0", - }, - }, - "catalog": { - "@types/bun": "1.3.8", - "@types/node": "20.19.6", - "@zenstackhq/orm": "canary", - "ioredis": "^5.0.0", - "kysely": "~0.28.8", - "typescript": "^5.9.3", - "zod": "^4.1.0", }, "packages": { "@babel/generator": ["@babel/generator@7.28.6", "", { "dependencies": { "@babel/parser": "^7.28.6", "@babel/types": "^7.28.6", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-lOoVRwADj8hjf7al89tvQ2a1lf53Z+7tiXMgpZJL3maQPDxh0DgLMN62B2MKUOFcoodBHLMbDM6WAbKgNy5Suw=="], @@ -265,8 +244,6 @@ "@types/node": ["@types/node@20.19.6", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-uYssdp9z5zH5GQ0L4zEJ2ZuavYsJwkozjiUzCRfGtaaQcyjAMJ34aP8idv61QlqTozu6kudyr6JMq9Chf09dfA=="], - "@visualbravo/zenstack-cache": ["@visualbravo/zenstack-cache@workspace:packages/cache"], - "@vitest/expect": ["@vitest/expect@4.0.17", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", "@vitest/spy": "4.0.17", "@vitest/utils": "4.0.17", "chai": "^6.2.1", "tinyrainbow": "^3.0.3" } }, "sha512-mEoqP3RqhKlbmUmntNDDCJeTDavDR+fVYkSOw8qRwJFaW/0/5zA9zFeTrHqNtcmwh6j26yMmwx2PqUDPzt5ZAQ=="], "@vitest/mocker": ["@vitest/mocker@4.0.17", "", { "dependencies": { "@vitest/spy": "4.0.17", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, "peerDependencies": { "msw": "^2.4.9", "vite": "^6.0.0 || ^7.0.0-0" }, "optionalPeers": ["msw", "vite"] }, "sha512-+ZtQhLA3lDh1tI2wxe3yMsGzbp7uuJSWBM1iTIKCbppWTSBN09PUC+L+fyNlQApQoR+Ps8twt2pbSSXg2fQVEQ=="], @@ -281,8 +258,6 @@ "@vitest/utils": ["@vitest/utils@4.0.17", "", { "dependencies": { "@vitest/pretty-format": "4.0.17", "tinyrainbow": "^3.0.3" } }, "sha512-RG6iy+IzQpa9SB8HAFHJ9Y+pTzI+h8553MrciN9eC6TFBErqrQaTas4vG+MVj8S4uKk8uTT2p0vgZPnTdxd96w=="], - "@zenstack-cache/config": ["@zenstack-cache/config@workspace:packages/config"], - "@zenstackhq/common-helpers": ["@zenstackhq/common-helpers@3.3.0-beta.4", "", {}, "sha512-rN5MVtCcOffl45ej1ISx38RIcI5Gq0gEtYeRtvnWet51BFx23U3lsqGCXaGosemEc6dvplnXOQQkF3Z+RfogNw=="], "@zenstackhq/orm": ["@zenstackhq/orm@3.3.0-beta.4", "", { "dependencies": { "@paralleldrive/cuid2": "^2.2.2", "@zenstackhq/common-helpers": "3.3.0-beta.4", "@zenstackhq/schema": "3.3.0-beta.4", "cuid": "^3.0.0", "decimal.js": "^10.4.3", "json-stable-stringify": "^1.3.0", "kysely": "~0.28.8", "nanoid": "^5.0.9", "postgres-array": "^3.0.4", "toposort": "^2.0.2", "ts-pattern": "^5.7.1", "ulid": "^3.0.0", "uuid": "^11.0.5", "zod-validation-error": "^4.0.1" }, "peerDependencies": { "better-sqlite3": "^12.5.0", "mysql2": "^3.16.1", "pg": "^8.13.1", "sql.js": "^1.13.0", "zod": "^4.0.0" }, "optionalPeers": ["better-sqlite3", "mysql2", "pg", "sql.js"] }, "sha512-WXuk05amHYX+0Ap38LDUeZRFHEc5U5qD+dnaGYuoTcehFViD0I5s8TgH/nJL/EVkA5/NC2DsTdrdiRtwKfEyzg=="], @@ -539,20 +514,6 @@ "tunnel-agent": ["tunnel-agent@0.6.0", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w=="], - "turbo": ["turbo@2.7.2", "", { "optionalDependencies": { "turbo-darwin-64": "2.7.2", "turbo-darwin-arm64": "2.7.2", "turbo-linux-64": "2.7.2", "turbo-linux-arm64": "2.7.2", "turbo-windows-64": "2.7.2", "turbo-windows-arm64": "2.7.2" }, "bin": { "turbo": "bin/turbo" } }, "sha512-5JIA5aYBAJSAhrhbyag1ZuMSgUZnHtI+Sq3H8D3an4fL8PeF+L1yYvbEJg47akP1PFfATMf5ehkqFnxfkmuwZQ=="], - - "turbo-darwin-64": ["turbo-darwin-64@2.7.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-dxY3X6ezcT5vm3coK6VGixbrhplbQMwgNsCsvZamS/+/6JiebqW9DKt4NwpgYXhDY2HdH00I7FWs3wkVuan4rA=="], - - "turbo-darwin-arm64": ["turbo-darwin-arm64@2.7.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-1bXmuwPLqNFt3mzrtYcVx1sdJ8UYb124Bf48nIgcpMCGZy3kDhgxNv1503kmuK/37OGOZbsWSQFU4I08feIuSg=="], - - "turbo-linux-64": ["turbo-linux-64@2.7.2", "", { "os": "linux", "cpu": "x64" }, "sha512-kP+TiiMaiPugbRlv57VGLfcjFNsFbo8H64wMBCPV2270Or2TpDCBULMzZrvEsvWFjT3pBFvToYbdp8/Kw0jAQg=="], - - "turbo-linux-arm64": ["turbo-linux-arm64@2.7.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-VDJwQ0+8zjAfbyY6boNaWfP6RIez4ypKHxwkuB6SrWbOSk+vxTyW5/hEjytTwK8w/TsbKVcMDyvpora8tEsRFw=="], - - "turbo-windows-64": ["turbo-windows-64@2.7.2", "", { "os": "win32", "cpu": "x64" }, "sha512-rPjqQXVnI6A6oxgzNEE8DNb6Vdj2Wwyhfv3oDc+YM3U9P7CAcBIlKv/868mKl4vsBtz4ouWpTQNXG8vljgJO+w=="], - - "turbo-windows-arm64": ["turbo-windows-arm64@2.7.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-tcnHvBhO515OheIFWdxA+qUvZzNqqcHbLVFc1+n+TJ1rrp8prYicQtbtmsiKgMvr/54jb9jOabU62URAobnB7g=="], - "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], "ulid": ["ulid@3.0.2", "", { "bin": { "ulid": "dist/cli.js" } }, "sha512-yu26mwteFYzBAot7KVMqFGCVpsF6g8wXfJzQUHvu1no3+rRRSFcSV2nKeYvNPLD2J4b08jYBDhHUjeH0ygIl9w=="], diff --git a/package.json b/package.json index d71dfbd..eb967e7 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,139 @@ { - "name": "workspace", - "type": "module", + "name": "@visualbravo/zenstack-cache", "version": "1.0.5", - "private": "true", + "description": "Reduce response times and database load with query-level caching integrated with the ZenStack ORM.", + "keywords": [ + "accelerate", + "cache", + "caching", + "orm", + "prisma", + "redis", + "self-hosted", + "typescript", + "zenstack" + ], + "homepage": "https://github.com/visualbravo/zenstack-cache", + "bugs": { + "url": "https://github.com/visualbravo/zenstack-cache/issues" + }, "license": "MIT", + "repository": "github:visualbravo/zenstack-cache", + "type": "module", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.cts", + "exports": { + ".": { + "@zenstack-cache/source": "./src/index.ts", + "require": "./dist/index.cjs", + "import": "./dist/index.mjs" + }, + "./plugin": { + "@zenstack-cache/source": "./src/plugin.ts", + "require": "./dist/plugin.cjs", + "import": "./dist/plugin.mjs" + }, + "./providers/memory": { + "@zenstack-cache/source": "./src/providers/memory.ts", + "require": "./dist/providers/memory.cjs", + "import": "./dist/providers/memory.mjs" + }, + "./providers/redis": { + "@zenstack-cache/source": "./src/providers/redis.ts", + "require": "./dist/providers/redis.cjs", + "import": "./dist/providers/redis.mjs" + }, + "./schemas": { + "@zenstack-cache/source": "./src/schemas.ts", + "require": "./dist/schemas.cjs", + "import": "./dist/schemas.mjs" + }, + "./superjson": { + "@zenstack-cache/source": "./src/superjson.ts", + "require": "./dist/superjson.cjs", + "import": "./dist/superjson.mjs" + }, + "./types": { + "@zenstack-cache/source": "./src/types.ts", + "require": "./dist/types.cjs", + "import": "./dist/types.mjs" + }, + "./utils": { + "@zenstack-cache/source": "./src/utils.ts", + "require": "./dist/utils.cjs", + "import": "./dist/utils.mjs" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "exports": { + ".": { + "require": "./dist/index.cjs", + "import": "./dist/index.mjs" + }, + "./plugin": { + "require": "./dist/plugin.cjs", + "import": "./dist/plugin.mjs" + }, + "./providers/memory": { + "require": "./dist/providers/memory.cjs", + "import": "./dist/providers/memory.mjs" + }, + "./providers/redis": { + "require": "./dist/providers/redis.cjs", + "import": "./dist/providers/redis.mjs" + }, + "./schemas": { + "require": "./dist/schemas.cjs", + "import": "./dist/schemas.mjs" + }, + "./superjson": { + "require": "./dist/superjson.cjs", + "import": "./dist/superjson.mjs" + }, + "./types": { + "require": "./dist/types.cjs", + "import": "./dist/types.mjs" + }, + "./utils": { + "require": "./dist/utils.cjs", + "import": "./dist/utils.mjs" + }, + "./package.json": "./package.json" + } + }, "scripts": { - "dev": "turbo run dev", - "build": "turbo run build", - "build:packages": "turbo run build --filter=\"./packages/*\"", - "start": "turbo run start", + "build": "tsdown", + "watch": "tsdown --watch", "lint": "oxlint", "lint:fix": "oxlint --fix --fix-suggestions", "format:fix": "oxfmt", "test": "vitest run", "test:watch": "vitest --watch" }, + "dependencies": { + "decimal.js": "^10.6.0", + "ioredis": "^5.0.0", + "murmurhash": "^2.0.1", + "stable-hash": "^0.0.6", + "superjson": "^2.2.2", + "zod": "^4.1.0" + }, "devDependencies": { - "@types/bun": "catalog:", - "@types/node": "catalog:", + "@types/better-sqlite3": "7.6.13", + "@types/bun": "1.3.8", + "@types/node": "20.19.6", + "better-sqlite3": "12.6.2", + "kysely": "0.28.8", "oxfmt": "0.20.0", "oxlint": "1.35.0", "tsdown": "0.18.3", - "turbo": "2.7.2", - "typescript": "catalog:", + "typescript": "5.9.3", "vitest": "4.0.17" }, - "workspaces": { - "packages": [ - "packages/*" - ], - "catalog": { - "@zenstackhq/orm": "^3.3.0", - "zod": "^4.1.0", - "kysely": "~0.28.8", - "ioredis": "^5.0.0", - "typescript": "^5.9.3", - "@types/bun": "1.3.8", - "@types/node": "20.19.6" - } + "peerDependencies": { + "@zenstackhq/orm": "^3.3.0" }, "packageManager": "bun@1.3.8" } diff --git a/packages/cache/package.json b/packages/cache/package.json deleted file mode 100644 index 360b2ba..0000000 --- a/packages/cache/package.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "name": "@visualbravo/zenstack-cache", - "version": "1.0.5", - "keywords": [ - "accelerate", - "cache", - "caching", - "orm", - "prisma", - "redis", - "self-hosted", - "typescript", - "zenstack" - ], - "license": "MIT", - "repository": "github:visualbravo/zenstack-cache", - "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", - "types": "./dist/index.d.cts", - "exports": { - ".": { - "@zenstack-cache/source": "./src/index.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.mjs" - }, - "./plugin": { - "@zenstack-cache/source": "./src/plugin.ts", - "require": "./dist/plugin.cjs", - "import": "./dist/plugin.mjs" - }, - "./providers/memory": { - "@zenstack-cache/source": "./src/providers/memory.ts", - "require": "./dist/providers/memory.cjs", - "import": "./dist/providers/memory.mjs" - }, - "./providers/redis": { - "@zenstack-cache/source": "./src/providers/redis.ts", - "require": "./dist/providers/redis.cjs", - "import": "./dist/providers/redis.mjs" - }, - "./schemas": { - "@zenstack-cache/source": "./src/schemas.ts", - "require": "./dist/schemas.cjs", - "import": "./dist/schemas.mjs" - }, - "./superjson": { - "@zenstack-cache/source": "./src/superjson.ts", - "require": "./dist/superjson.cjs", - "import": "./dist/superjson.mjs" - }, - "./types": { - "@zenstack-cache/source": "./src/types.ts", - "require": "./dist/types.cjs", - "import": "./dist/types.mjs" - }, - "./utils": { - "@zenstack-cache/source": "./src/utils.ts", - "require": "./dist/utils.cjs", - "import": "./dist/utils.mjs" - }, - "./package.json": "./package.json" - }, - "publishConfig": { - "exports": { - ".": { - "require": "./dist/index.cjs", - "import": "./dist/index.mjs" - }, - "./plugin": { - "require": "./dist/plugin.cjs", - "import": "./dist/plugin.mjs" - }, - "./providers/memory": { - "require": "./dist/providers/memory.cjs", - "import": "./dist/providers/memory.mjs" - }, - "./providers/redis": { - "require": "./dist/providers/redis.cjs", - "import": "./dist/providers/redis.mjs" - }, - "./schemas": { - "require": "./dist/schemas.cjs", - "import": "./dist/schemas.mjs" - }, - "./superjson": { - "require": "./dist/superjson.cjs", - "import": "./dist/superjson.mjs" - }, - "./types": { - "require": "./dist/types.cjs", - "import": "./dist/types.mjs" - }, - "./utils": { - "require": "./dist/utils.cjs", - "import": "./dist/utils.mjs" - }, - "./package.json": "./package.json" - } - }, - "scripts": { - "build": "tsdown", - "watch": "tsdown --watch", - "lint": "oxlint", - "lint:fix": "oxlint --fix --fix-suggestions", - "format:fix": "oxfmt", - "test": "vitest run", - "test:watch": "vitest --watch" - }, - "dependencies": { - "decimal.js": "^10.6.0", - "ioredis": "catalog:", - "murmurhash": "^2.0.1", - "stable-hash": "^0.0.6", - "superjson": "^2.2.2", - "zod": "catalog:" - }, - "devDependencies": { - "@types/better-sqlite3": "7.6.13", - "@zenstack-cache/config": "workspace:*", - "better-sqlite3": "12.6.2", - "kysely": "catalog:" - }, - "peerDependencies": { - "@zenstackhq/orm": "catalog:" - }, - "packageManager": "bun@1.3.8" -} diff --git a/packages/cache/tsconfig.json b/packages/cache/tsconfig.json deleted file mode 100644 index 3fe75ec..0000000 --- a/packages/cache/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "@zenstack-cache/config/ts", - "compilerOptions": { - "rootDir": "./", - "paths": { - "*": ["./*"], - "@/*": ["./src/*"] - } - }, - "include": ["**/*.ts", "**/*.tsx"] -} diff --git a/packages/config/package.json b/packages/config/package.json deleted file mode 100644 index 39b5fbb..0000000 --- a/packages/config/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@zenstack-cache/config", - "type": "module", - "version": "1.0.5", - "private": true, - "exports": { - "./ts": "./ts.json" - }, - "packageManager": "bun@1.3.8" -} diff --git a/packages/config/ts.json b/packages/config/ts.json deleted file mode 100644 index 1bbbbde..0000000 --- a/packages/config/ts.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "outDir": "./", - "target": "ESNext", - "module": "Preserve", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - "strict": true, - "skipDefaultLibCheck": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": true, - "isolatedModules": true, - "customConditions": ["@zenstack-cache/source"] - }, - "exclude": ["**/dist", "**/node_modules"] -} diff --git a/packages/cache/src/index.ts b/src/index.ts similarity index 100% rename from packages/cache/src/index.ts rename to src/index.ts diff --git a/packages/cache/src/plugin.ts b/src/plugin.ts similarity index 100% rename from packages/cache/src/plugin.ts rename to src/plugin.ts diff --git a/packages/cache/src/providers/memory.ts b/src/providers/memory.ts similarity index 100% rename from packages/cache/src/providers/memory.ts rename to src/providers/memory.ts diff --git a/packages/cache/src/providers/redis.ts b/src/providers/redis.ts similarity index 100% rename from packages/cache/src/providers/redis.ts rename to src/providers/redis.ts diff --git a/packages/cache/src/schemas.ts b/src/schemas.ts similarity index 100% rename from packages/cache/src/schemas.ts rename to src/schemas.ts diff --git a/packages/cache/src/superjson.ts b/src/superjson.ts similarity index 100% rename from packages/cache/src/superjson.ts rename to src/superjson.ts diff --git a/packages/cache/src/types.ts b/src/types.ts similarity index 100% rename from packages/cache/src/types.ts rename to src/types.ts diff --git a/packages/cache/src/utils.ts b/src/utils.ts similarity index 100% rename from packages/cache/src/utils.ts rename to src/utils.ts diff --git a/packages/cache/tests/memory.test.ts b/tests/memory.test.ts similarity index 100% rename from packages/cache/tests/memory.test.ts rename to tests/memory.test.ts diff --git a/packages/cache/tests/redis.test.ts b/tests/redis.test.ts similarity index 100% rename from packages/cache/tests/redis.test.ts rename to tests/redis.test.ts diff --git a/packages/cache/tests/schemas/basic/input.ts b/tests/schemas/basic/input.ts similarity index 100% rename from packages/cache/tests/schemas/basic/input.ts rename to tests/schemas/basic/input.ts diff --git a/packages/cache/tests/schemas/basic/models.ts b/tests/schemas/basic/models.ts similarity index 100% rename from packages/cache/tests/schemas/basic/models.ts rename to tests/schemas/basic/models.ts diff --git a/packages/cache/tests/schemas/basic/schema.ts b/tests/schemas/basic/schema.ts similarity index 100% rename from packages/cache/tests/schemas/basic/schema.ts rename to tests/schemas/basic/schema.ts diff --git a/packages/cache/tests/schemas/basic/schema.zmodel b/tests/schemas/basic/schema.zmodel similarity index 100% rename from packages/cache/tests/schemas/basic/schema.zmodel rename to tests/schemas/basic/schema.zmodel diff --git a/tsconfig.json b/tsconfig.json index 1bbbbde..0bac8d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": ["ESNext"], - "outDir": "./", + "rootDir": "./src", + "outDir": "./dist", "target": "ESNext", "module": "Preserve", "moduleDetection": "force", diff --git a/packages/cache/tsdown.config.ts b/tsdown.config.ts similarity index 100% rename from packages/cache/tsdown.config.ts rename to tsdown.config.ts