mimarjs 0.0.0-stage → 0.0.1-alpha.1
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/LICENSE +21 -0
- package/README.md +50 -2
- package/bin/mimar.js +32 -0
- package/dist/auth/auth.d.ts +86 -0
- package/dist/auth/auth.d.ts.map +1 -0
- package/dist/auth/auth.js +212 -0
- package/dist/auth/auth.js.map +1 -0
- package/dist/auth/errors.d.ts +44 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +66 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/manager.d.ts +109 -0
- package/dist/auth/manager.d.ts.map +1 -0
- package/dist/auth/manager.js +113 -0
- package/dist/auth/manager.js.map +1 -0
- package/dist/auth/middleware.d.ts +26 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +152 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/passwords.d.ts +45 -0
- package/dist/auth/passwords.d.ts.map +1 -0
- package/dist/auth/passwords.js +104 -0
- package/dist/auth/passwords.js.map +1 -0
- package/dist/auth/policy.d.ts +57 -0
- package/dist/auth/policy.d.ts.map +1 -0
- package/dist/auth/policy.js +115 -0
- package/dist/auth/policy.js.map +1 -0
- package/dist/auth/setup.d.ts +55 -0
- package/dist/auth/setup.d.ts.map +1 -0
- package/dist/auth/setup.js +50 -0
- package/dist/auth/setup.js.map +1 -0
- package/dist/auth/state.d.ts +19 -0
- package/dist/auth/state.d.ts.map +1 -0
- package/dist/auth/state.js +19 -0
- package/dist/auth/state.js.map +1 -0
- package/dist/auth/tokens.d.ts +22 -0
- package/dist/auth/tokens.d.ts.map +1 -0
- package/dist/auth/tokens.js +51 -0
- package/dist/auth/tokens.js.map +1 -0
- package/dist/auth/verification.d.ts +31 -0
- package/dist/auth/verification.d.ts.map +1 -0
- package/dist/auth/verification.js +77 -0
- package/dist/auth/verification.js.map +1 -0
- package/dist/aws/index.d.ts +2 -0
- package/dist/aws/index.d.ts.map +1 -0
- package/dist/aws/index.js +2 -0
- package/dist/aws/index.js.map +1 -0
- package/dist/aws/signer.d.ts +47 -0
- package/dist/aws/signer.d.ts.map +1 -0
- package/dist/aws/signer.js +130 -0
- package/dist/aws/signer.js.map +1 -0
- package/dist/broadcast/index.d.ts +2 -0
- package/dist/broadcast/index.d.ts.map +1 -0
- package/dist/broadcast/index.js +2 -0
- package/dist/broadcast/index.js.map +1 -0
- package/dist/cache/cache.d.ts +129 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +407 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/database.d.ts +38 -0
- package/dist/cache/database.d.ts.map +1 -0
- package/dist/cache/database.js +210 -0
- package/dist/cache/database.js.map +1 -0
- package/dist/cache/file.d.ts +18 -0
- package/dist/cache/file.d.ts.map +1 -0
- package/dist/cache/file.js +237 -0
- package/dist/cache/file.js.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +9 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/manager.d.ts +42 -0
- package/dist/cache/manager.d.ts.map +1 -0
- package/dist/cache/manager.js +107 -0
- package/dist/cache/manager.js.map +1 -0
- package/dist/cache/module.d.ts +41 -0
- package/dist/cache/module.d.ts.map +1 -0
- package/dist/cache/module.js +49 -0
- package/dist/cache/module.js.map +1 -0
- package/dist/cache/rate-limiter.d.ts +76 -0
- package/dist/cache/rate-limiter.d.ts.map +1 -0
- package/dist/cache/rate-limiter.js +119 -0
- package/dist/cache/rate-limiter.js.map +1 -0
- package/dist/cache/redis.d.ts +19 -0
- package/dist/cache/redis.d.ts.map +1 -0
- package/dist/cache/redis.js +99 -0
- package/dist/cache/redis.js.map +1 -0
- package/dist/cache/store.d.ts +78 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/store.js +162 -0
- package/dist/cache/store.js.map +1 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/pages.d.ts +51 -0
- package/dist/client/pages.d.ts.map +1 -0
- package/dist/client/pages.js +2 -0
- package/dist/client/pages.js.map +1 -0
- package/dist/client/routes.d.ts +22 -0
- package/dist/client/routes.d.ts.map +1 -0
- package/dist/client/routes.js +66 -0
- package/dist/client/routes.js.map +1 -0
- package/dist/client/wire.d.ts +44 -0
- package/dist/client/wire.d.ts.map +1 -0
- package/dist/client/wire.js +2 -0
- package/dist/client/wire.js.map +1 -0
- package/dist/config/config.d.ts +39 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +44 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/sections.d.ts +243 -0
- package/dist/config/sections.d.ts.map +1 -0
- package/dist/config/sections.js +250 -0
- package/dist/config/sections.js.map +1 -0
- package/dist/console/command.d.ts +82 -0
- package/dist/console/command.d.ts.map +1 -0
- package/dist/console/command.js +82 -0
- package/dist/console/command.js.map +1 -0
- package/dist/console/index.d.ts +4 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/console/index.js +4 -0
- package/dist/console/index.js.map +1 -0
- package/dist/console/io.d.ts +79 -0
- package/dist/console/io.d.ts.map +1 -0
- package/dist/console/io.js +214 -0
- package/dist/console/io.js.map +1 -0
- package/dist/console/kernel.d.ts +38 -0
- package/dist/console/kernel.d.ts.map +1 -0
- package/dist/console/kernel.js +279 -0
- package/dist/console/kernel.js.map +1 -0
- package/dist/container/container.d.ts +47 -0
- package/dist/container/container.d.ts.map +1 -0
- package/dist/container/container.js +130 -0
- package/dist/container/container.js.map +1 -0
- package/dist/container/index.d.ts +2 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +2 -0
- package/dist/container/index.js.map +1 -0
- package/dist/cookie/index.d.ts +2 -0
- package/dist/cookie/index.d.ts.map +1 -0
- package/dist/cookie/index.js +2 -0
- package/dist/cookie/index.js.map +1 -0
- package/dist/crypt/crypt.d.ts +48 -0
- package/dist/crypt/crypt.d.ts.map +1 -0
- package/dist/crypt/crypt.js +151 -0
- package/dist/crypt/crypt.js.map +1 -0
- package/dist/crypt/index.d.ts +2 -0
- package/dist/crypt/index.d.ts.map +1 -0
- package/dist/crypt/index.js +2 -0
- package/dist/crypt/index.js.map +1 -0
- package/dist/db/codec.d.ts +36 -0
- package/dist/db/codec.d.ts.map +1 -0
- package/dist/db/codec.js +129 -0
- package/dist/db/codec.js.map +1 -0
- package/dist/db/contract.d.ts +103 -0
- package/dist/db/contract.d.ts.map +1 -0
- package/dist/db/contract.js +2 -0
- package/dist/db/contract.js.map +1 -0
- package/dist/db/db.d.ts +41 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +48 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/drivers/better-sqlite3.d.ts +4 -0
- package/dist/db/drivers/better-sqlite3.d.ts.map +1 -0
- package/dist/db/drivers/better-sqlite3.js +49 -0
- package/dist/db/drivers/better-sqlite3.js.map +1 -0
- package/dist/db/drivers/mysql.d.ts +5 -0
- package/dist/db/drivers/mysql.d.ts.map +1 -0
- package/dist/db/drivers/mysql.js +318 -0
- package/dist/db/drivers/mysql.js.map +1 -0
- package/dist/db/drivers/pgsql.d.ts +5 -0
- package/dist/db/drivers/pgsql.d.ts.map +1 -0
- package/dist/db/drivers/pgsql.js +261 -0
- package/dist/db/drivers/pgsql.js.map +1 -0
- package/dist/db/drivers/sqlite.d.ts +51 -0
- package/dist/db/drivers/sqlite.d.ts.map +1 -0
- package/dist/db/drivers/sqlite.js +251 -0
- package/dist/db/drivers/sqlite.js.map +1 -0
- package/dist/db/errors.d.ts +65 -0
- package/dist/db/errors.d.ts.map +1 -0
- package/dist/db/errors.js +101 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/grammars/grammar.d.ts +77 -0
- package/dist/db/grammars/grammar.d.ts.map +1 -0
- package/dist/db/grammars/grammar.js +345 -0
- package/dist/db/grammars/grammar.js.map +1 -0
- package/dist/db/grammars/mysql.d.ts +45 -0
- package/dist/db/grammars/mysql.d.ts.map +1 -0
- package/dist/db/grammars/mysql.js +147 -0
- package/dist/db/grammars/mysql.js.map +1 -0
- package/dist/db/grammars/pgsql.d.ts +20 -0
- package/dist/db/grammars/pgsql.d.ts.map +1 -0
- package/dist/db/grammars/pgsql.js +66 -0
- package/dist/db/grammars/pgsql.js.map +1 -0
- package/dist/db/grammars/sqlite.d.ts +27 -0
- package/dist/db/grammars/sqlite.d.ts.map +1 -0
- package/dist/db/grammars/sqlite.js +95 -0
- package/dist/db/grammars/sqlite.js.map +1 -0
- package/dist/db/index.d.ts +18 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +17 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/kysely/index.d.ts +2 -0
- package/dist/db/kysely/index.d.ts.map +1 -0
- package/dist/db/kysely/index.js +2 -0
- package/dist/db/kysely/index.js.map +1 -0
- package/dist/db/kysely/kysely.d.ts +15 -0
- package/dist/db/kysely/kysely.d.ts.map +1 -0
- package/dist/db/kysely/kysely.js +127 -0
- package/dist/db/kysely/kysely.js.map +1 -0
- package/dist/db/manager.d.ts +138 -0
- package/dist/db/manager.d.ts.map +1 -0
- package/dist/db/manager.js +776 -0
- package/dist/db/manager.js.map +1 -0
- package/dist/db/pool.d.ts +28 -0
- package/dist/db/pool.d.ts.map +1 -0
- package/dist/db/pool.js +114 -0
- package/dist/db/pool.js.map +1 -0
- package/dist/db/query/builder.d.ts +290 -0
- package/dist/db/query/builder.d.ts.map +1 -0
- package/dist/db/query/builder.js +957 -0
- package/dist/db/query/builder.js.map +1 -0
- package/dist/db/query/state.d.ts +183 -0
- package/dist/db/query/state.d.ts.map +1 -0
- package/dist/db/query/state.js +48 -0
- package/dist/db/query/state.js.map +1 -0
- package/dist/db/sql.d.ts +82 -0
- package/dist/db/sql.d.ts.map +1 -0
- package/dist/db/sql.js +143 -0
- package/dist/db/sql.js.map +1 -0
- package/dist/env/env.d.ts +61 -0
- package/dist/env/env.d.ts.map +1 -0
- package/dist/env/env.js +184 -0
- package/dist/env/env.js.map +1 -0
- package/dist/env/index.d.ts +2 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +2 -0
- package/dist/env/index.js.map +1 -0
- package/dist/errors/errors.d.ts +42 -0
- package/dist/errors/errors.d.ts.map +1 -0
- package/dist/errors/errors.js +60 -0
- package/dist/errors/errors.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/events/event.d.ts +52 -0
- package/dist/events/event.d.ts.map +1 -0
- package/dist/events/event.js +77 -0
- package/dist/events/event.js.map +1 -0
- package/dist/events/fake.d.ts +22 -0
- package/dist/events/fake.d.ts.map +1 -0
- package/dist/events/fake.js +53 -0
- package/dist/events/fake.js.map +1 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +6 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/listener.d.ts +49 -0
- package/dist/events/listener.d.ts.map +1 -0
- package/dist/events/listener.js +31 -0
- package/dist/events/listener.js.map +1 -0
- package/dist/events/manager.d.ts +54 -0
- package/dist/events/manager.d.ts.map +1 -0
- package/dist/events/manager.js +166 -0
- package/dist/events/manager.js.map +1 -0
- package/dist/events/module.d.ts +10 -0
- package/dist/events/module.d.ts.map +1 -0
- package/dist/events/module.js +12 -0
- package/dist/events/module.js.map +1 -0
- package/dist/factory/factory.d.ts +93 -0
- package/dist/factory/factory.d.ts.map +1 -0
- package/dist/factory/factory.js +261 -0
- package/dist/factory/factory.js.map +1 -0
- package/dist/factory/fake.d.ts +92 -0
- package/dist/factory/fake.d.ts.map +1 -0
- package/dist/factory/fake.js +328 -0
- package/dist/factory/fake.js.map +1 -0
- package/dist/factory/index.d.ts +4 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory/index.js +4 -0
- package/dist/factory/index.js.map +1 -0
- package/dist/factory/seed.d.ts +21 -0
- package/dist/factory/seed.d.ts.map +1 -0
- package/dist/factory/seed.js +55 -0
- package/dist/factory/seed.js.map +1 -0
- package/dist/feature/index.d.ts +2 -0
- package/dist/feature/index.d.ts.map +1 -0
- package/dist/feature/index.js +2 -0
- package/dist/feature/index.js.map +1 -0
- package/dist/foundation/application.d.ts +156 -0
- package/dist/foundation/application.d.ts.map +1 -0
- package/dist/foundation/application.js +1258 -0
- package/dist/foundation/application.js.map +1 -0
- package/dist/foundation/cache-commands.d.ts +7 -0
- package/dist/foundation/cache-commands.d.ts.map +1 -0
- package/dist/foundation/cache-commands.js +48 -0
- package/dist/foundation/cache-commands.js.map +1 -0
- package/dist/foundation/command-result.d.ts +14 -0
- package/dist/foundation/command-result.d.ts.map +1 -0
- package/dist/foundation/command-result.js +43 -0
- package/dist/foundation/command-result.js.map +1 -0
- package/dist/foundation/commands.d.ts +159 -0
- package/dist/foundation/commands.d.ts.map +1 -0
- package/dist/foundation/commands.js +404 -0
- package/dist/foundation/commands.js.map +1 -0
- package/dist/foundation/database-commands.d.ts +24 -0
- package/dist/foundation/database-commands.d.ts.map +1 -0
- package/dist/foundation/database-commands.js +304 -0
- package/dist/foundation/database-commands.js.map +1 -0
- package/dist/foundation/debug-page.d.ts +11 -0
- package/dist/foundation/debug-page.d.ts.map +1 -0
- package/dist/foundation/debug-page.js +112 -0
- package/dist/foundation/debug-page.js.map +1 -0
- package/dist/foundation/dev-vite.d.ts +2 -0
- package/dist/foundation/dev-vite.d.ts.map +1 -0
- package/dist/foundation/dev-vite.js +39 -0
- package/dist/foundation/dev-vite.js.map +1 -0
- package/dist/foundation/dev.d.ts +31 -0
- package/dist/foundation/dev.d.ts.map +1 -0
- package/dist/foundation/dev.js +430 -0
- package/dist/foundation/dev.js.map +1 -0
- package/dist/foundation/discovery.d.ts +41 -0
- package/dist/foundation/discovery.d.ts.map +1 -0
- package/dist/foundation/discovery.js +69 -0
- package/dist/foundation/discovery.js.map +1 -0
- package/dist/foundation/error-pages.d.ts +10 -0
- package/dist/foundation/error-pages.d.ts.map +1 -0
- package/dist/foundation/error-pages.js +38 -0
- package/dist/foundation/error-pages.js.map +1 -0
- package/dist/foundation/exceptions.d.ts +20 -0
- package/dist/foundation/exceptions.d.ts.map +1 -0
- package/dist/foundation/exceptions.js +36 -0
- package/dist/foundation/exceptions.js.map +1 -0
- package/dist/foundation/generators.d.ts +71 -0
- package/dist/foundation/generators.d.ts.map +1 -0
- package/dist/foundation/generators.js +577 -0
- package/dist/foundation/generators.js.map +1 -0
- package/dist/foundation/helpers.d.ts +7 -0
- package/dist/foundation/helpers.d.ts.map +1 -0
- package/dist/foundation/helpers.js +12 -0
- package/dist/foundation/helpers.js.map +1 -0
- package/dist/foundation/index.d.ts +8 -0
- package/dist/foundation/index.d.ts.map +1 -0
- package/dist/foundation/index.js +8 -0
- package/dist/foundation/index.js.map +1 -0
- package/dist/foundation/install-api.d.ts +4 -0
- package/dist/foundation/install-api.d.ts.map +1 -0
- package/dist/foundation/install-api.js +91 -0
- package/dist/foundation/install-api.js.map +1 -0
- package/dist/foundation/provider.d.ts +83 -0
- package/dist/foundation/provider.d.ts.map +1 -0
- package/dist/foundation/provider.js +13 -0
- package/dist/foundation/provider.js.map +1 -0
- package/dist/foundation/queue-commands.d.ts +38 -0
- package/dist/foundation/queue-commands.d.ts.map +1 -0
- package/dist/foundation/queue-commands.js +279 -0
- package/dist/foundation/queue-commands.js.map +1 -0
- package/dist/foundation/route-types.d.ts +22 -0
- package/dist/foundation/route-types.d.ts.map +1 -0
- package/dist/foundation/route-types.js +158 -0
- package/dist/foundation/route-types.js.map +1 -0
- package/dist/foundation/schedule-commands.d.ts +4 -0
- package/dist/foundation/schedule-commands.d.ts.map +1 -0
- package/dist/foundation/schedule-commands.js +128 -0
- package/dist/foundation/schedule-commands.js.map +1 -0
- package/dist/foundation/stubs/api.d.ts +9 -0
- package/dist/foundation/stubs/api.d.ts.map +1 -0
- package/dist/foundation/stubs/api.js +225 -0
- package/dist/foundation/stubs/api.js.map +1 -0
- package/dist/foundation/stubs/handler.d.ts +15 -0
- package/dist/foundation/stubs/handler.d.ts.map +1 -0
- package/dist/foundation/stubs/handler.js +54 -0
- package/dist/foundation/stubs/handler.js.map +1 -0
- package/dist/foundation/stubs/others.d.ts +53 -0
- package/dist/foundation/stubs/others.d.ts.map +1 -0
- package/dist/foundation/stubs/others.js +159 -0
- package/dist/foundation/stubs/others.js.map +1 -0
- package/dist/foundation/test-command.d.ts +9 -0
- package/dist/foundation/test-command.d.ts.map +1 -0
- package/dist/foundation/test-command.js +43 -0
- package/dist/foundation/test-command.js.map +1 -0
- package/dist/hash/hash.d.ts +44 -0
- package/dist/hash/hash.d.ts.map +1 -0
- package/dist/hash/hash.js +94 -0
- package/dist/hash/hash.js.map +1 -0
- package/dist/hash/index.d.ts +2 -0
- package/dist/hash/index.d.ts.map +1 -0
- package/dist/hash/index.js +2 -0
- package/dist/hash/index.js.map +1 -0
- package/dist/http/cookies.d.ts +37 -0
- package/dist/http/cookies.d.ts.map +1 -0
- package/dist/http/cookies.js +86 -0
- package/dist/http/cookies.js.map +1 -0
- package/dist/http/csrf.d.ts +24 -0
- package/dist/http/csrf.d.ts.map +1 -0
- package/dist/http/csrf.js +93 -0
- package/dist/http/csrf.js.map +1 -0
- package/dist/http/form.d.ts +11 -0
- package/dist/http/form.d.ts.map +1 -0
- package/dist/http/form.js +57 -0
- package/dist/http/form.js.map +1 -0
- package/dist/http/index.d.ts +18 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +18 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/kernel.d.ts +82 -0
- package/dist/http/kernel.d.ts.map +1 -0
- package/dist/http/kernel.js +454 -0
- package/dist/http/kernel.js.map +1 -0
- package/dist/http/maintenance.d.ts +25 -0
- package/dist/http/maintenance.d.ts.map +1 -0
- package/dist/http/maintenance.js +70 -0
- package/dist/http/maintenance.js.map +1 -0
- package/dist/http/middleware.d.ts +75 -0
- package/dist/http/middleware.d.ts.map +1 -0
- package/dist/http/middleware.js +169 -0
- package/dist/http/middleware.js.map +1 -0
- package/dist/http/multipart.d.ts +4 -0
- package/dist/http/multipart.d.ts.map +1 -0
- package/dist/http/multipart.js +95 -0
- package/dist/http/multipart.js.map +1 -0
- package/dist/http/render.d.ts +19 -0
- package/dist/http/render.d.ts.map +1 -0
- package/dist/http/render.js +65 -0
- package/dist/http/render.js.map +1 -0
- package/dist/http/request.d.ts +106 -0
- package/dist/http/request.d.ts.map +1 -0
- package/dist/http/request.js +313 -0
- package/dist/http/request.js.map +1 -0
- package/dist/http/response.d.ts +128 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +217 -0
- package/dist/http/response.js.map +1 -0
- package/dist/http/server.d.ts +27 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +76 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/signature.d.ts +10 -0
- package/dist/http/signature.d.ts.map +1 -0
- package/dist/http/signature.js +42 -0
- package/dist/http/signature.js.map +1 -0
- package/dist/http/throttle.d.ts +26 -0
- package/dist/http/throttle.d.ts.map +1 -0
- package/dist/http/throttle.js +52 -0
- package/dist/http/throttle.js.map +1 -0
- package/dist/http/types.d.ts +66 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +5 -0
- package/dist/http/types.js.map +1 -0
- package/dist/http/uploads.d.ts +46 -0
- package/dist/http/uploads.d.ts.map +1 -0
- package/dist/http/uploads.js +130 -0
- package/dist/http/uploads.js.map +1 -0
- package/dist/http/wire.d.ts +15 -0
- package/dist/http/wire.d.ts.map +1 -0
- package/dist/http/wire.js +114 -0
- package/dist/http/wire.js.map +1 -0
- package/dist/http/write.d.ts +13 -0
- package/dist/http/write.d.ts.map +1 -0
- package/dist/http/write.js +161 -0
- package/dist/http/write.js.map +1 -0
- package/dist/http-client/index.d.ts +2 -0
- package/dist/http-client/index.d.ts.map +1 -0
- package/dist/http-client/index.js +2 -0
- package/dist/http-client/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/inertia/index.d.ts +5 -0
- package/dist/inertia/index.d.ts.map +1 -0
- package/dist/inertia/index.js +4 -0
- package/dist/inertia/index.js.map +1 -0
- package/dist/inertia/inertia.d.ts +159 -0
- package/dist/inertia/inertia.d.ts.map +1 -0
- package/dist/inertia/inertia.js +406 -0
- package/dist/inertia/inertia.js.map +1 -0
- package/dist/inertia/props.d.ts +138 -0
- package/dist/inertia/props.d.ts.map +1 -0
- package/dist/inertia/props.js +138 -0
- package/dist/inertia/props.js.map +1 -0
- package/dist/inertia/resolve.d.ts +51 -0
- package/dist/inertia/resolve.d.ts.map +1 -0
- package/dist/inertia/resolve.js +289 -0
- package/dist/inertia/resolve.js.map +1 -0
- package/dist/inertia/response.d.ts +24 -0
- package/dist/inertia/response.d.ts.map +1 -0
- package/dist/inertia/response.js +49 -0
- package/dist/inertia/response.js.map +1 -0
- package/dist/inertia/ssr-worker.d.ts +25 -0
- package/dist/inertia/ssr-worker.d.ts.map +1 -0
- package/dist/inertia/ssr-worker.js +55 -0
- package/dist/inertia/ssr-worker.js.map +1 -0
- package/dist/inertia/ssr.d.ts +49 -0
- package/dist/inertia/ssr.d.ts.map +1 -0
- package/dist/inertia/ssr.js +273 -0
- package/dist/inertia/ssr.js.map +1 -0
- package/dist/log/channels.d.ts +27 -0
- package/dist/log/channels.d.ts.map +1 -0
- package/dist/log/channels.js +95 -0
- package/dist/log/channels.js.map +1 -0
- package/dist/log/index.d.ts +4 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/index.js +4 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/log.d.ts +69 -0
- package/dist/log/log.d.ts.map +1 -0
- package/dist/log/log.js +173 -0
- package/dist/log/log.js.map +1 -0
- package/dist/log/record.d.ts +26 -0
- package/dist/log/record.d.ts.map +1 -0
- package/dist/log/record.js +89 -0
- package/dist/log/record.js.map +1 -0
- package/dist/mail/address.d.ts +27 -0
- package/dist/mail/address.d.ts.map +1 -0
- package/dist/mail/address.js +44 -0
- package/dist/mail/address.js.map +1 -0
- package/dist/mail/auth.d.ts +6 -0
- package/dist/mail/auth.d.ts.map +1 -0
- package/dist/mail/auth.js +39 -0
- package/dist/mail/auth.js.map +1 -0
- package/dist/mail/components.d.ts +29 -0
- package/dist/mail/components.d.ts.map +1 -0
- package/dist/mail/components.js +87 -0
- package/dist/mail/components.js.map +1 -0
- package/dist/mail/fake.d.ts +42 -0
- package/dist/mail/fake.d.ts.map +1 -0
- package/dist/mail/fake.js +111 -0
- package/dist/mail/fake.js.map +1 -0
- package/dist/mail/index.d.ts +9 -0
- package/dist/mail/index.d.ts.map +1 -0
- package/dist/mail/index.js +9 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/mail/mail.d.ts +56 -0
- package/dist/mail/mail.d.ts.map +1 -0
- package/dist/mail/mail.js +68 -0
- package/dist/mail/mail.js.map +1 -0
- package/dist/mail/manager.d.ts +77 -0
- package/dist/mail/manager.d.ts.map +1 -0
- package/dist/mail/manager.js +160 -0
- package/dist/mail/manager.js.map +1 -0
- package/dist/mail/text.d.ts +3 -0
- package/dist/mail/text.d.ts.map +1 -0
- package/dist/mail/text.js +161 -0
- package/dist/mail/text.js.map +1 -0
- package/dist/mail/transport.d.ts +57 -0
- package/dist/mail/transport.d.ts.map +1 -0
- package/dist/mail/transport.js +41 -0
- package/dist/mail/transport.js.map +1 -0
- package/dist/migrations/create-database.d.ts +6 -0
- package/dist/migrations/create-database.d.ts.map +1 -0
- package/dist/migrations/create-database.js +23 -0
- package/dist/migrations/create-database.js.map +1 -0
- package/dist/migrations/dump.d.ts +27 -0
- package/dist/migrations/dump.d.ts.map +1 -0
- package/dist/migrations/dump.js +258 -0
- package/dist/migrations/dump.js.map +1 -0
- package/dist/migrations/files.d.ts +40 -0
- package/dist/migrations/files.d.ts.map +1 -0
- package/dist/migrations/files.js +101 -0
- package/dist/migrations/files.js.map +1 -0
- package/dist/migrations/index.d.ts +5 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +5 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrator.d.ts +97 -0
- package/dist/migrations/migrator.d.ts.map +1 -0
- package/dist/migrations/migrator.js +383 -0
- package/dist/migrations/migrator.js.map +1 -0
- package/dist/model/checks.d.ts +10 -0
- package/dist/model/checks.d.ts.map +1 -0
- package/dist/model/checks.js +171 -0
- package/dist/model/checks.js.map +1 -0
- package/dist/model/columns.d.ts +153 -0
- package/dist/model/columns.d.ts.map +1 -0
- package/dist/model/columns.js +96 -0
- package/dist/model/columns.js.map +1 -0
- package/dist/model/describe.d.ts +36 -0
- package/dist/model/describe.d.ts.map +1 -0
- package/dist/model/describe.js +57 -0
- package/dist/model/describe.js.map +1 -0
- package/dist/model/drift.d.ts +15 -0
- package/dist/model/drift.d.ts.map +1 -0
- package/dist/model/drift.js +123 -0
- package/dist/model/drift.js.map +1 -0
- package/dist/model/errors.d.ts +33 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +55 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/index.d.ts +14 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +13 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/keys.d.ts +37 -0
- package/dist/model/keys.d.ts.map +1 -0
- package/dist/model/keys.js +39 -0
- package/dist/model/keys.js.map +1 -0
- package/dist/model/loading.d.ts +8 -0
- package/dist/model/loading.d.ts.map +1 -0
- package/dist/model/loading.js +201 -0
- package/dist/model/loading.js.map +1 -0
- package/dist/model/meta.d.ts +27 -0
- package/dist/model/meta.d.ts.map +1 -0
- package/dist/model/meta.js +110 -0
- package/dist/model/meta.js.map +1 -0
- package/dist/model/model.d.ts +107 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +667 -0
- package/dist/model/model.js.map +1 -0
- package/dist/model/query.d.ts +214 -0
- package/dist/model/query.d.ts.map +1 -0
- package/dist/model/query.js +869 -0
- package/dist/model/query.js.map +1 -0
- package/dist/model/related.d.ts +40 -0
- package/dist/model/related.d.ts.map +1 -0
- package/dist/model/related.js +274 -0
- package/dist/model/related.js.map +1 -0
- package/dist/model/relations.d.ts +160 -0
- package/dist/model/relations.d.ts.map +1 -0
- package/dist/model/relations.js +44 -0
- package/dist/model/relations.js.map +1 -0
- package/dist/model/types.d.ts +461 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +2 -0
- package/dist/model/types.js.map +1 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +2 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/pagination/index.d.ts +2 -0
- package/dist/pagination/index.d.ts.map +1 -0
- package/dist/pagination/index.js +2 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/paginator.d.ts +174 -0
- package/dist/pagination/paginator.d.ts.map +1 -0
- package/dist/pagination/paginator.js +413 -0
- package/dist/pagination/paginator.js.map +1 -0
- package/dist/queue/batches.d.ts +152 -0
- package/dist/queue/batches.d.ts.map +1 -0
- package/dist/queue/batches.js +344 -0
- package/dist/queue/batches.js.map +1 -0
- package/dist/queue/database.d.ts +35 -0
- package/dist/queue/database.d.ts.map +1 -0
- package/dist/queue/database.js +137 -0
- package/dist/queue/database.js.map +1 -0
- package/dist/queue/driver.d.ts +72 -0
- package/dist/queue/driver.d.ts.map +1 -0
- package/dist/queue/driver.js +17 -0
- package/dist/queue/driver.js.map +1 -0
- package/dist/queue/envelope.d.ts +66 -0
- package/dist/queue/envelope.d.ts.map +1 -0
- package/dist/queue/envelope.js +81 -0
- package/dist/queue/envelope.js.map +1 -0
- package/dist/queue/failed.d.ts +43 -0
- package/dist/queue/failed.d.ts.map +1 -0
- package/dist/queue/failed.js +76 -0
- package/dist/queue/failed.js.map +1 -0
- package/dist/queue/fake.d.ts +68 -0
- package/dist/queue/fake.d.ts.map +1 -0
- package/dist/queue/fake.js +93 -0
- package/dist/queue/fake.js.map +1 -0
- package/dist/queue/index.d.ts +15 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +15 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/job.d.ts +137 -0
- package/dist/queue/job.d.ts.map +1 -0
- package/dist/queue/job.js +154 -0
- package/dist/queue/job.js.map +1 -0
- package/dist/queue/manager.d.ts +116 -0
- package/dist/queue/manager.d.ts.map +1 -0
- package/dist/queue/manager.js +545 -0
- package/dist/queue/manager.js.map +1 -0
- package/dist/queue/middleware.d.ts +33 -0
- package/dist/queue/middleware.d.ts.map +1 -0
- package/dist/queue/middleware.js +88 -0
- package/dist/queue/middleware.js.map +1 -0
- package/dist/queue/module.d.ts +42 -0
- package/dist/queue/module.d.ts.map +1 -0
- package/dist/queue/module.js +68 -0
- package/dist/queue/module.js.map +1 -0
- package/dist/queue/redis.d.ts +27 -0
- package/dist/queue/redis.d.ts.map +1 -0
- package/dist/queue/redis.js +189 -0
- package/dist/queue/redis.js.map +1 -0
- package/dist/queue/runner.d.ts +79 -0
- package/dist/queue/runner.d.ts.map +1 -0
- package/dist/queue/runner.js +129 -0
- package/dist/queue/runner.js.map +1 -0
- package/dist/queue/sqs.d.ts +59 -0
- package/dist/queue/sqs.d.ts.map +1 -0
- package/dist/queue/sqs.js +323 -0
- package/dist/queue/sqs.js.map +1 -0
- package/dist/queue/worker.d.ts +59 -0
- package/dist/queue/worker.d.ts.map +1 -0
- package/dist/queue/worker.js +466 -0
- package/dist/queue/worker.js.map +1 -0
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +2 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/redis/redis.d.ts +41 -0
- package/dist/redis/redis.d.ts.map +1 -0
- package/dist/redis/redis.js +140 -0
- package/dist/redis/redis.js.map +1 -0
- package/dist/reverb/index.d.ts +2 -0
- package/dist/reverb/index.d.ts.map +1 -0
- package/dist/reverb/index.js +2 -0
- package/dist/reverb/index.js.map +1 -0
- package/dist/routing/index.d.ts +6 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +6 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/paths.d.ts +27 -0
- package/dist/routing/paths.d.ts.map +1 -0
- package/dist/routing/paths.js +45 -0
- package/dist/routing/paths.js.map +1 -0
- package/dist/routing/router.d.ts +137 -0
- package/dist/routing/router.d.ts.map +1 -0
- package/dist/routing/router.js +236 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/routing/routing.d.ts +34 -0
- package/dist/routing/routing.d.ts.map +1 -0
- package/dist/routing/routing.js +57 -0
- package/dist/routing/routing.js.map +1 -0
- package/dist/routing/table.d.ts +35 -0
- package/dist/routing/table.d.ts.map +1 -0
- package/dist/routing/table.js +247 -0
- package/dist/routing/table.js.map +1 -0
- package/dist/routing/urls.d.ts +34 -0
- package/dist/routing/urls.d.ts.map +1 -0
- package/dist/routing/urls.js +116 -0
- package/dist/routing/urls.js.map +1 -0
- package/dist/schedule/cron.d.ts +35 -0
- package/dist/schedule/cron.d.ts.map +1 -0
- package/dist/schedule/cron.js +212 -0
- package/dist/schedule/cron.js.map +1 -0
- package/dist/schedule/index.d.ts +5 -0
- package/dist/schedule/index.d.ts.map +1 -0
- package/dist/schedule/index.js +5 -0
- package/dist/schedule/index.js.map +1 -0
- package/dist/schedule/schedule.d.ts +38 -0
- package/dist/schedule/schedule.d.ts.map +1 -0
- package/dist/schedule/schedule.js +70 -0
- package/dist/schedule/schedule.js.map +1 -0
- package/dist/schedule/scheduler.d.ts +89 -0
- package/dist/schedule/scheduler.d.ts.map +1 -0
- package/dist/schedule/scheduler.js +404 -0
- package/dist/schedule/scheduler.js.map +1 -0
- package/dist/schedule/task.d.ts +150 -0
- package/dist/schedule/task.d.ts.map +1 -0
- package/dist/schedule/task.js +323 -0
- package/dist/schedule/task.js.map +1 -0
- package/dist/schema/blueprint.d.ts +256 -0
- package/dist/schema/blueprint.d.ts.map +1 -0
- package/dist/schema/blueprint.js +458 -0
- package/dist/schema/blueprint.js.map +1 -0
- package/dist/schema/builder.d.ts +40 -0
- package/dist/schema/builder.d.ts.map +1 -0
- package/dist/schema/builder.js +153 -0
- package/dist/schema/builder.js.map +1 -0
- package/dist/schema/grammars/grammar.d.ts +112 -0
- package/dist/schema/grammars/grammar.d.ts.map +1 -0
- package/dist/schema/grammars/grammar.js +231 -0
- package/dist/schema/grammars/grammar.js.map +1 -0
- package/dist/schema/grammars/mysql.d.ts +43 -0
- package/dist/schema/grammars/mysql.d.ts.map +1 -0
- package/dist/schema/grammars/mysql.js +220 -0
- package/dist/schema/grammars/mysql.js.map +1 -0
- package/dist/schema/grammars/pgsql.d.ts +33 -0
- package/dist/schema/grammars/pgsql.d.ts.map +1 -0
- package/dist/schema/grammars/pgsql.js +218 -0
- package/dist/schema/grammars/pgsql.js.map +1 -0
- package/dist/schema/grammars/sqlite-text.d.ts +24 -0
- package/dist/schema/grammars/sqlite-text.d.ts.map +1 -0
- package/dist/schema/grammars/sqlite-text.js +174 -0
- package/dist/schema/grammars/sqlite-text.js.map +1 -0
- package/dist/schema/grammars/sqlite.d.ts +39 -0
- package/dist/schema/grammars/sqlite.d.ts.map +1 -0
- package/dist/schema/grammars/sqlite.js +484 -0
- package/dist/schema/grammars/sqlite.js.map +1 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schema.d.ts +48 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +47 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/scope/context.d.ts +39 -0
- package/dist/scope/context.d.ts.map +1 -0
- package/dist/scope/context.js +113 -0
- package/dist/scope/context.js.map +1 -0
- package/dist/scope/index.d.ts +3 -0
- package/dist/scope/index.d.ts.map +1 -0
- package/dist/scope/index.js +3 -0
- package/dist/scope/index.js.map +1 -0
- package/dist/scope/scope.d.ts +116 -0
- package/dist/scope/scope.d.ts.map +1 -0
- package/dist/scope/scope.js +148 -0
- package/dist/scope/scope.js.map +1 -0
- package/dist/session/cache-store.d.ts +17 -0
- package/dist/session/cache-store.d.ts.map +1 -0
- package/dist/session/cache-store.js +45 -0
- package/dist/session/cache-store.js.map +1 -0
- package/dist/session/database.d.ts +32 -0
- package/dist/session/database.d.ts.map +1 -0
- package/dist/session/database.js +98 -0
- package/dist/session/database.js.map +1 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +7 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +61 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +217 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/middleware.d.ts +6 -0
- package/dist/session/middleware.d.ts.map +1 -0
- package/dist/session/middleware.js +76 -0
- package/dist/session/middleware.js.map +1 -0
- package/dist/session/session.d.ts +118 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +223 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/stores.d.ts +36 -0
- package/dist/session/stores.d.ts.map +1 -0
- package/dist/session/stores.js +151 -0
- package/dist/session/stores.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/str/index.d.ts +2 -0
- package/dist/str/index.d.ts.map +1 -0
- package/dist/str/index.js +2 -0
- package/dist/str/index.js.map +1 -0
- package/dist/str/str.d.ts +27 -0
- package/dist/str/str.d.ts.map +1 -0
- package/dist/str/str.js +102 -0
- package/dist/str/str.js.map +1 -0
- package/dist/support/clock.d.ts +6 -0
- package/dist/support/clock.d.ts.map +1 -0
- package/dist/support/clock.js +7 -0
- package/dist/support/clock.js.map +1 -0
- package/dist/support/data.d.ts +29 -0
- package/dist/support/data.d.ts.map +1 -0
- package/dist/support/data.js +160 -0
- package/dist/support/data.js.map +1 -0
- package/dist/support/index.d.ts +8 -0
- package/dist/support/index.d.ts.map +1 -0
- package/dist/support/index.js +7 -0
- package/dist/support/index.js.map +1 -0
- package/dist/support/register.d.ts +14 -0
- package/dist/support/register.d.ts.map +1 -0
- package/dist/support/register.js +2 -0
- package/dist/support/register.js.map +1 -0
- package/dist/support/text.d.ts +8 -0
- package/dist/support/text.d.ts.map +1 -0
- package/dist/support/text.js +19 -0
- package/dist/support/text.js.map +1 -0
- package/dist/support/type-assertions.d.ts +7 -0
- package/dist/support/type-assertions.d.ts.map +1 -0
- package/dist/support/type-assertions.js +10 -0
- package/dist/support/type-assertions.js.map +1 -0
- package/dist/support/types.d.ts +34 -0
- package/dist/support/types.d.ts.map +1 -0
- package/dist/support/types.js +31 -0
- package/dist/support/types.js.map +1 -0
- package/dist/support/units.d.ts +17 -0
- package/dist/support/units.d.ts.map +1 -0
- package/dist/support/units.js +54 -0
- package/dist/support/units.js.map +1 -0
- package/dist/task/index.d.ts +2 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/index.js +2 -0
- package/dist/task/index.js.map +1 -0
- package/dist/task/task.d.ts +68 -0
- package/dist/task/task.d.ts.map +1 -0
- package/dist/task/task.js +162 -0
- package/dist/task/task.js.map +1 -0
- package/dist/testing/assert-database.d.ts +10 -0
- package/dist/testing/assert-database.d.ts.map +1 -0
- package/dist/testing/assert-database.js +125 -0
- package/dist/testing/assert-database.js.map +1 -0
- package/dist/testing/conformance/cache.d.ts +24 -0
- package/dist/testing/conformance/cache.d.ts.map +1 -0
- package/dist/testing/conformance/cache.js +397 -0
- package/dist/testing/conformance/cache.js.map +1 -0
- package/dist/testing/conformance/column-types.d.ts +44 -0
- package/dist/testing/conformance/column-types.d.ts.map +1 -0
- package/dist/testing/conformance/column-types.js +47 -0
- package/dist/testing/conformance/column-types.js.map +1 -0
- package/dist/testing/conformance/database.d.ts +11 -0
- package/dist/testing/conformance/database.d.ts.map +1 -0
- package/dist/testing/conformance/database.js +410 -0
- package/dist/testing/conformance/database.js.map +1 -0
- package/dist/testing/conformance/factories.d.ts +4 -0
- package/dist/testing/conformance/factories.d.ts.map +1 -0
- package/dist/testing/conformance/factories.js +313 -0
- package/dist/testing/conformance/factories.js.map +1 -0
- package/dist/testing/conformance/harness.d.ts +30 -0
- package/dist/testing/conformance/harness.d.ts.map +1 -0
- package/dist/testing/conformance/harness.js +85 -0
- package/dist/testing/conformance/harness.js.map +1 -0
- package/dist/testing/conformance/index.d.ts +13 -0
- package/dist/testing/conformance/index.d.ts.map +1 -0
- package/dist/testing/conformance/index.js +12 -0
- package/dist/testing/conformance/index.js.map +1 -0
- package/dist/testing/conformance/migrations.d.ts +4 -0
- package/dist/testing/conformance/migrations.d.ts.map +1 -0
- package/dist/testing/conformance/migrations.js +313 -0
- package/dist/testing/conformance/migrations.js.map +1 -0
- package/dist/testing/conformance/models.d.ts +4 -0
- package/dist/testing/conformance/models.d.ts.map +1 -0
- package/dist/testing/conformance/models.js +715 -0
- package/dist/testing/conformance/models.js.map +1 -0
- package/dist/testing/conformance/pagination.d.ts +4 -0
- package/dist/testing/conformance/pagination.d.ts.map +1 -0
- package/dist/testing/conformance/pagination.js +283 -0
- package/dist/testing/conformance/pagination.js.map +1 -0
- package/dist/testing/conformance/query-builder.d.ts +4 -0
- package/dist/testing/conformance/query-builder.d.ts.map +1 -0
- package/dist/testing/conformance/query-builder.js +725 -0
- package/dist/testing/conformance/query-builder.js.map +1 -0
- package/dist/testing/conformance/queue.d.ts +29 -0
- package/dist/testing/conformance/queue.d.ts.map +1 -0
- package/dist/testing/conformance/queue.js +203 -0
- package/dist/testing/conformance/queue.js.map +1 -0
- package/dist/testing/conformance/relationships.d.ts +4 -0
- package/dist/testing/conformance/relationships.d.ts.map +1 -0
- package/dist/testing/conformance/relationships.js +737 -0
- package/dist/testing/conformance/relationships.js.map +1 -0
- package/dist/testing/conformance/schema.d.ts +4 -0
- package/dist/testing/conformance/schema.d.ts.map +1 -0
- package/dist/testing/conformance/schema.js +320 -0
- package/dist/testing/conformance/schema.js.map +1 -0
- package/dist/testing/conformance/session.d.ts +22 -0
- package/dist/testing/conformance/session.d.ts.map +1 -0
- package/dist/testing/conformance/session.js +162 -0
- package/dist/testing/conformance/session.js.map +1 -0
- package/dist/testing/database.d.ts +28 -0
- package/dist/testing/database.d.ts.map +1 -0
- package/dist/testing/database.js +213 -0
- package/dist/testing/database.js.map +1 -0
- package/dist/testing/files.d.ts +11 -0
- package/dist/testing/files.d.ts.map +1 -0
- package/dist/testing/files.js +44 -0
- package/dist/testing/files.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/inertia.d.ts +35 -0
- package/dist/testing/inertia.d.ts.map +1 -0
- package/dist/testing/inertia.js +127 -0
- package/dist/testing/inertia.js.map +1 -0
- package/dist/testing/query-log.d.ts +10 -0
- package/dist/testing/query-log.d.ts.map +1 -0
- package/dist/testing/query-log.js +31 -0
- package/dist/testing/query-log.js.map +1 -0
- package/dist/testing/response.d.ts +100 -0
- package/dist/testing/response.d.ts.map +1 -0
- package/dist/testing/response.js +329 -0
- package/dist/testing/response.js.map +1 -0
- package/dist/testing/testing.d.ts +191 -0
- package/dist/testing/testing.d.ts.map +1 -0
- package/dist/testing/testing.js +449 -0
- package/dist/testing/testing.js.map +1 -0
- package/dist/time/index.d.ts +3 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +2 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/time.d.ts +39 -0
- package/dist/time/time.d.ts.map +1 -0
- package/dist/time/time.js +130 -0
- package/dist/time/time.js.map +1 -0
- package/dist/tracing/index.d.ts +2 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +2 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/validation/index.d.ts +6 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +6 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/input.d.ts +89 -0
- package/dist/validation/input.d.ts.map +1 -0
- package/dist/validation/input.js +241 -0
- package/dist/validation/input.js.map +1 -0
- package/dist/validation/messages.d.ts +7 -0
- package/dist/validation/messages.d.ts.map +1 -0
- package/dist/validation/messages.js +93 -0
- package/dist/validation/messages.js.map +1 -0
- package/dist/validation/presence.d.ts +32 -0
- package/dist/validation/presence.d.ts.map +1 -0
- package/dist/validation/presence.js +17 -0
- package/dist/validation/presence.js.map +1 -0
- package/dist/validation/rules.d.ts +321 -0
- package/dist/validation/rules.d.ts.map +1 -0
- package/dist/validation/rules.js +603 -0
- package/dist/validation/rules.js.map +1 -0
- package/dist/validation/standard.d.ts +33 -0
- package/dist/validation/standard.d.ts.map +1 -0
- package/dist/validation/standard.js +10 -0
- package/dist/validation/standard.js.map +1 -0
- package/dist/view/channel.d.ts +13 -0
- package/dist/view/channel.d.ts.map +1 -0
- package/dist/view/channel.js +6 -0
- package/dist/view/channel.js.map +1 -0
- package/dist/view/head.d.ts +60 -0
- package/dist/view/head.d.ts.map +1 -0
- package/dist/view/head.js +122 -0
- package/dist/view/head.js.map +1 -0
- package/dist/view/helpers.d.ts +17 -0
- package/dist/view/helpers.d.ts.map +1 -0
- package/dist/view/helpers.js +19 -0
- package/dist/view/helpers.js.map +1 -0
- package/dist/view/html.d.ts +25 -0
- package/dist/view/html.d.ts.map +1 -0
- package/dist/view/html.js +291 -0
- package/dist/view/html.js.map +1 -0
- package/dist/view/index.d.ts +7 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/index.js +7 -0
- package/dist/view/index.js.map +1 -0
- package/dist/view/translate.d.ts +14 -0
- package/dist/view/translate.d.ts.map +1 -0
- package/dist/view/translate.js +42 -0
- package/dist/view/translate.js.map +1 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +3 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/plugin.d.ts +51 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +273 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/vite.d.ts +68 -0
- package/dist/vite/vite.d.ts.map +1 -0
- package/dist/vite/vite.js +228 -0
- package/dist/vite/vite.js.map +1 -0
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +2 -0
- package/dist/workflow/index.js.map +1 -0
- package/docs/authentication.md +428 -0
- package/docs/authorization.md +203 -0
- package/docs/cache.md +215 -0
- package/docs/configuration.md +86 -0
- package/docs/console.md +99 -0
- package/docs/container.md +58 -0
- package/docs/csrf.md +54 -0
- package/docs/database-testing.md +121 -0
- package/docs/database.md +314 -0
- package/docs/documentation.md +49 -0
- package/docs/encryption.md +104 -0
- package/docs/errors.md +85 -0
- package/docs/events.md +136 -0
- package/docs/factories.md +144 -0
- package/docs/hashing.md +78 -0
- package/docs/inertia.md +469 -0
- package/docs/installation.md +87 -0
- package/docs/lifecycle.md +84 -0
- package/docs/logging.md +49 -0
- package/docs/middleware.md +64 -0
- package/docs/migrations.md +192 -0
- package/docs/models.md +301 -0
- package/docs/pagination.md +129 -0
- package/docs/passwords.md +151 -0
- package/docs/providers.md +51 -0
- package/docs/queries.md +239 -0
- package/docs/queues.md +407 -0
- package/docs/rate-limiting.md +64 -0
- package/docs/redis.md +76 -0
- package/docs/relationships.md +251 -0
- package/docs/requests.md +53 -0
- package/docs/responses.md +71 -0
- package/docs/routing.md +84 -0
- package/docs/scheduling.md +177 -0
- package/docs/seeding.md +96 -0
- package/docs/session.md +138 -0
- package/docs/structure.md +45 -0
- package/docs/testing.md +134 -0
- package/docs/upgrade.md +42 -0
- package/docs/uploads.md +74 -0
- package/docs/validation.md +105 -0
- package/docs/verification.md +125 -0
- package/docs/views.md +94 -0
- package/docs/vite.md +193 -0
- package/package.json +270 -3
- package/src/auth/auth.ts +260 -0
- package/src/auth/errors.ts +69 -0
- package/src/auth/index.ts +34 -0
- package/src/auth/manager.ts +205 -0
- package/src/auth/middleware.ts +169 -0
- package/src/auth/passwords.ts +117 -0
- package/src/auth/policy.ts +184 -0
- package/src/auth/setup.ts +96 -0
- package/src/auth/state.ts +24 -0
- package/src/auth/tokens.ts +66 -0
- package/src/auth/verification.ts +85 -0
- package/src/aws/index.ts +10 -0
- package/src/aws/signer.ts +170 -0
- package/src/broadcast/index.ts +1 -0
- package/src/cache/cache.ts +495 -0
- package/src/cache/database.ts +243 -0
- package/src/cache/file.ts +262 -0
- package/src/cache/index.ts +26 -0
- package/src/cache/manager.ts +138 -0
- package/src/cache/module.ts +59 -0
- package/src/cache/rate-limiter.ts +183 -0
- package/src/cache/redis.ts +122 -0
- package/src/cache/store.ts +239 -0
- package/src/client/index.ts +3 -0
- package/src/client/pages.ts +90 -0
- package/src/client/routes.ts +90 -0
- package/src/client/wire.ts +93 -0
- package/src/config/config.ts +83 -0
- package/src/config/index.ts +27 -0
- package/src/config/sections.ts +501 -0
- package/src/console/command.ts +171 -0
- package/src/console/index.ts +13 -0
- package/src/console/io.ts +285 -0
- package/src/console/kernel.ts +309 -0
- package/src/container/container.ts +174 -0
- package/src/container/index.ts +1 -0
- package/src/cookie/index.ts +1 -0
- package/src/crypt/crypt.ts +185 -0
- package/src/crypt/index.ts +1 -0
- package/src/db/codec.ts +143 -0
- package/src/db/contract.ts +128 -0
- package/src/db/db.ts +72 -0
- package/src/db/drivers/better-sqlite3.ts +62 -0
- package/src/db/drivers/mysql.ts +379 -0
- package/src/db/drivers/pgsql.ts +293 -0
- package/src/db/drivers/sqlite.ts +321 -0
- package/src/db/errors.ts +149 -0
- package/src/db/grammars/grammar.ts +429 -0
- package/src/db/grammars/mysql.ts +181 -0
- package/src/db/grammars/pgsql.ts +83 -0
- package/src/db/grammars/sqlite.ts +109 -0
- package/src/db/index.ts +107 -0
- package/src/db/kysely/index.ts +1 -0
- package/src/db/kysely/kysely.ts +182 -0
- package/src/db/manager.ts +891 -0
- package/src/db/pool.ts +127 -0
- package/src/db/query/builder.ts +1245 -0
- package/src/db/query/state.ts +210 -0
- package/src/db/sql.ts +196 -0
- package/src/env/env.ts +224 -0
- package/src/env/index.ts +11 -0
- package/src/errors/errors.ts +83 -0
- package/src/errors/index.ts +1 -0
- package/src/events/event.ts +113 -0
- package/src/events/fake.ts +73 -0
- package/src/events/index.ts +16 -0
- package/src/events/listener.ts +86 -0
- package/src/events/manager.ts +192 -0
- package/src/events/module.ts +14 -0
- package/src/factory/factory.ts +394 -0
- package/src/factory/fake.ts +431 -0
- package/src/factory/index.ts +14 -0
- package/src/factory/seed.ts +72 -0
- package/src/feature/index.ts +1 -0
- package/src/foundation/application.ts +1419 -0
- package/src/foundation/cache-commands.ts +49 -0
- package/src/foundation/command-result.ts +46 -0
- package/src/foundation/commands.ts +432 -0
- package/src/foundation/database-commands.ts +321 -0
- package/src/foundation/debug-page.ts +142 -0
- package/src/foundation/dev-vite.ts +32 -0
- package/src/foundation/dev.ts +464 -0
- package/src/foundation/discovery.ts +96 -0
- package/src/foundation/error-pages.ts +32 -0
- package/src/foundation/exceptions.ts +56 -0
- package/src/foundation/generators.ts +642 -0
- package/src/foundation/helpers.ts +15 -0
- package/src/foundation/index.ts +16 -0
- package/src/foundation/install-api.ts +109 -0
- package/src/foundation/provider.ts +98 -0
- package/src/foundation/queue-commands.ts +301 -0
- package/src/foundation/route-types.ts +199 -0
- package/src/foundation/schedule-commands.ts +139 -0
- package/src/foundation/stubs/api.ts +232 -0
- package/src/foundation/stubs/handler.ts +76 -0
- package/src/foundation/stubs/others.ts +188 -0
- package/src/foundation/test-command.ts +40 -0
- package/src/hash/hash.ts +138 -0
- package/src/hash/index.ts +1 -0
- package/src/http/busboy.d.ts +31 -0
- package/src/http/cookies.ts +104 -0
- package/src/http/csrf.ts +102 -0
- package/src/http/form.ts +60 -0
- package/src/http/index.ts +87 -0
- package/src/http/kernel.ts +509 -0
- package/src/http/maintenance.ts +85 -0
- package/src/http/middleware.ts +229 -0
- package/src/http/multipart.ts +105 -0
- package/src/http/render.ts +77 -0
- package/src/http/request.ts +368 -0
- package/src/http/response.ts +301 -0
- package/src/http/server.ts +95 -0
- package/src/http/signature.ts +42 -0
- package/src/http/throttle.ts +67 -0
- package/src/http/types.ts +71 -0
- package/src/http/uploads.ts +139 -0
- package/src/http/wire.ts +104 -0
- package/src/http/write.ts +158 -0
- package/src/http-client/index.ts +1 -0
- package/src/index.ts +20 -0
- package/src/inertia/index.ts +26 -0
- package/src/inertia/inertia.ts +590 -0
- package/src/inertia/props.ts +237 -0
- package/src/inertia/resolve.ts +326 -0
- package/src/inertia/response.ts +66 -0
- package/src/inertia/ssr-worker.ts +66 -0
- package/src/inertia/ssr.ts +369 -0
- package/src/log/channels.ts +101 -0
- package/src/log/index.ts +3 -0
- package/src/log/log.ts +216 -0
- package/src/log/record.ts +107 -0
- package/src/mail/address.ts +60 -0
- package/src/mail/auth.ts +54 -0
- package/src/mail/components.ts +98 -0
- package/src/mail/fake.ts +131 -0
- package/src/mail/index.ts +38 -0
- package/src/mail/mail.ts +124 -0
- package/src/mail/manager.ts +212 -0
- package/src/mail/text.ts +150 -0
- package/src/mail/transport.ts +88 -0
- package/src/migrations/create-database.ts +27 -0
- package/src/migrations/dump.ts +317 -0
- package/src/migrations/files.ts +118 -0
- package/src/migrations/index.ts +21 -0
- package/src/migrations/migrator.ts +499 -0
- package/src/model/checks.ts +189 -0
- package/src/model/columns.ts +221 -0
- package/src/model/describe.ts +95 -0
- package/src/model/drift.ts +150 -0
- package/src/model/errors.ts +69 -0
- package/src/model/index.ts +96 -0
- package/src/model/keys.ts +73 -0
- package/src/model/loading.ts +226 -0
- package/src/model/meta.ts +120 -0
- package/src/model/model.ts +788 -0
- package/src/model/query.ts +1100 -0
- package/src/model/related.ts +336 -0
- package/src/model/relations.ts +211 -0
- package/src/model/types.ts +557 -0
- package/src/notification/index.ts +1 -0
- package/src/pagination/index.ts +21 -0
- package/src/pagination/paginator.ts +545 -0
- package/src/queue/batches.ts +481 -0
- package/src/queue/database.ts +177 -0
- package/src/queue/driver.ts +85 -0
- package/src/queue/envelope.ts +133 -0
- package/src/queue/failed.ts +119 -0
- package/src/queue/fake.ts +145 -0
- package/src/queue/index.ts +88 -0
- package/src/queue/job.ts +295 -0
- package/src/queue/manager.ts +636 -0
- package/src/queue/middleware.ts +111 -0
- package/src/queue/module.ts +74 -0
- package/src/queue/redis.ts +223 -0
- package/src/queue/runner.ts +185 -0
- package/src/queue/sqs.ts +381 -0
- package/src/queue/worker.ts +519 -0
- package/src/redis/index.ts +1 -0
- package/src/redis/redis.ts +158 -0
- package/src/reverb/index.ts +1 -0
- package/src/routing/index.ts +15 -0
- package/src/routing/paths.ts +67 -0
- package/src/routing/router.ts +346 -0
- package/src/routing/routing.ts +80 -0
- package/src/routing/table.ts +281 -0
- package/src/routing/urls.ts +139 -0
- package/src/schedule/cron.ts +221 -0
- package/src/schedule/index.ts +11 -0
- package/src/schedule/schedule.ts +99 -0
- package/src/schedule/scheduler.ts +455 -0
- package/src/schedule/task.ts +381 -0
- package/src/schema/blueprint.ts +684 -0
- package/src/schema/builder.ts +178 -0
- package/src/schema/grammars/grammar.ts +348 -0
- package/src/schema/grammars/mysql.ts +241 -0
- package/src/schema/grammars/pgsql.ts +248 -0
- package/src/schema/grammars/sqlite-text.ts +177 -0
- package/src/schema/grammars/sqlite.ts +540 -0
- package/src/schema/index.ts +25 -0
- package/src/schema/schema.ts +87 -0
- package/src/scope/context.ts +124 -0
- package/src/scope/index.ts +26 -0
- package/src/scope/scope.ts +250 -0
- package/src/session/cache-store.ts +57 -0
- package/src/session/database.ts +121 -0
- package/src/session/index.ts +24 -0
- package/src/session/manager.ts +251 -0
- package/src/session/middleware.ts +79 -0
- package/src/session/session.ts +282 -0
- package/src/session/stores.ts +173 -0
- package/src/storage/index.ts +1 -0
- package/src/str/index.ts +1 -0
- package/src/str/str.ts +115 -0
- package/src/support/clock.ts +11 -0
- package/src/support/data.ts +156 -0
- package/src/support/index.ts +26 -0
- package/src/support/register.ts +13 -0
- package/src/support/text.ts +17 -0
- package/src/support/type-assertions.ts +14 -0
- package/src/support/types.ts +80 -0
- package/src/support/units.ts +67 -0
- package/src/task/index.ts +14 -0
- package/src/task/task.ts +199 -0
- package/src/testing/assert-database.ts +145 -0
- package/src/testing/conformance/cache.ts +453 -0
- package/src/testing/conformance/column-types.ts +47 -0
- package/src/testing/conformance/database.ts +512 -0
- package/src/testing/conformance/factories.ts +350 -0
- package/src/testing/conformance/harness.ts +107 -0
- package/src/testing/conformance/index.ts +12 -0
- package/src/testing/conformance/migrations.ts +400 -0
- package/src/testing/conformance/models.ts +810 -0
- package/src/testing/conformance/pagination.ts +324 -0
- package/src/testing/conformance/query-builder.ts +900 -0
- package/src/testing/conformance/queue.ts +239 -0
- package/src/testing/conformance/relationships.ts +948 -0
- package/src/testing/conformance/schema.ts +373 -0
- package/src/testing/conformance/session.ts +190 -0
- package/src/testing/database.ts +245 -0
- package/src/testing/files.ts +46 -0
- package/src/testing/index.ts +15 -0
- package/src/testing/inertia.ts +151 -0
- package/src/testing/query-log.ts +34 -0
- package/src/testing/response.ts +391 -0
- package/src/testing/testing.ts +593 -0
- package/src/time/index.ts +2 -0
- package/src/time/time.ts +143 -0
- package/src/tracing/index.ts +1 -0
- package/src/validation/index.ts +38 -0
- package/src/validation/input.ts +334 -0
- package/src/validation/messages.ts +96 -0
- package/src/validation/presence.ts +52 -0
- package/src/validation/rules.ts +839 -0
- package/src/validation/standard.ts +45 -0
- package/src/view/channel.ts +16 -0
- package/src/view/head.ts +165 -0
- package/src/view/helpers.ts +29 -0
- package/src/view/html.ts +303 -0
- package/src/view/index.ts +6 -0
- package/src/view/translate.ts +48 -0
- package/src/vite/index.ts +2 -0
- package/src/vite/plugin.ts +311 -0
- package/src/vite/vite.ts +302 -0
- package/src/workflow/index.ts +1 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// The `database` cache store: entries in the `cache` table and locks in `cache_locks`, made by `cache.createTables()`
|
|
2
|
+
// in a migration and shared by every process that uses the database.
|
|
3
|
+
//
|
|
4
|
+
// Keys are kept as the hex of their UTF-8 bytes. MySQL compares text without regard to case, so `User` and `user`
|
|
5
|
+
// would otherwise be one row; hex has one spelling per key, sorts and matches prefixes the same on every database.
|
|
6
|
+
// Expiry times are epoch milliseconds read from the application's clock.
|
|
7
|
+
import { createHash } from 'node:crypto'
|
|
8
|
+
import { ConfigRepository } from '../config/index.ts'
|
|
9
|
+
import type { DatabaseConnection } from '../db/index.ts'
|
|
10
|
+
import type { Blueprint } from '../schema/index.ts'
|
|
11
|
+
import { currentApplication } from '../scope/index.ts'
|
|
12
|
+
import type { Clock } from '../support/index.ts'
|
|
13
|
+
import { type CacheStore, storedInteger } from './store.ts'
|
|
14
|
+
|
|
15
|
+
/** The expiry of an entry that does not expire: the end of year 9999. */
|
|
16
|
+
const forever = 253_402_300_799_999
|
|
17
|
+
|
|
18
|
+
/** Hex of at most this many bytes of a key; a longer key keeps them and adds a hash of the whole. */
|
|
19
|
+
const keptBytes = 160
|
|
20
|
+
|
|
21
|
+
/** The stored form of a key or lock name. The `-` never appears in hex, so a long key cannot equal a short one. */
|
|
22
|
+
export function rowKey(key: string): string {
|
|
23
|
+
const bytes = Buffer.from(key, 'utf8')
|
|
24
|
+
if (bytes.length <= 2 * keptBytes) return bytes.toString('hex')
|
|
25
|
+
return `${bytes.subarray(0, keptBytes).toString('hex')}-${createHash('sha256').update(bytes).digest('hex')}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DatabaseCacheStoreOptions {
|
|
29
|
+
/** The connection to use, looked up on every call. */
|
|
30
|
+
readonly connection: () => DatabaseConnection
|
|
31
|
+
readonly table: string
|
|
32
|
+
readonly clock: Clock
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CacheRow {
|
|
36
|
+
key: string
|
|
37
|
+
value: string
|
|
38
|
+
expiration: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface LockRow {
|
|
42
|
+
key: string
|
|
43
|
+
owner: string
|
|
44
|
+
expiration: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class DatabaseCacheStore implements CacheStore {
|
|
48
|
+
readonly #connection: () => DatabaseConnection
|
|
49
|
+
readonly #table: string
|
|
50
|
+
readonly #lockTable: string
|
|
51
|
+
readonly #clock: Clock
|
|
52
|
+
|
|
53
|
+
constructor(options: DatabaseCacheStoreOptions) {
|
|
54
|
+
this.#connection = options.connection
|
|
55
|
+
this.#table = options.table
|
|
56
|
+
this.#lockTable = `${options.table}_locks`
|
|
57
|
+
this.#clock = options.clock
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#now(): number {
|
|
61
|
+
return this.#clock.now().epochMilliseconds
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#expiration(ttl: number | null): number {
|
|
65
|
+
return ttl === null ? forever : this.#now() + ttl
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#entries() {
|
|
69
|
+
return this.#connection().table<CacheRow>(this.#table)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Runs lock queries where other processes see them at once: outside the transactions of this unit of work. SQLite
|
|
74
|
+
* has one writer, which an open transaction holds, so there they run inside it.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Runs a lock's statements outside any transaction. MySQL may pick one of several processes racing for a lock
|
|
78
|
+
* as a deadlock victim; its statement was undone, so the work runs again (three times in all).
|
|
79
|
+
*/
|
|
80
|
+
async #locks<T>(work: (connection: DatabaseConnection) => Promise<T>): Promise<T> {
|
|
81
|
+
const connection = this.#connection()
|
|
82
|
+
if (connection.driver.singleWriter) return work(connection)
|
|
83
|
+
for (let attempt = 1; ; attempt++) {
|
|
84
|
+
try {
|
|
85
|
+
return await connection.outsideTransaction(() => work(connection))
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// A QueryError, known by its kind: the cache is loaded without the database layer, so it does not import the class.
|
|
88
|
+
const kind = (error as { kind?: unknown } | null)?.kind
|
|
89
|
+
const retry = kind === 'deadlock' || kind === 'serialization'
|
|
90
|
+
if (!retry || attempt >= 3) throw error
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async get(key: string): Promise<string | null> {
|
|
96
|
+
const row = await this.#entries().select('value').where('key', rowKey(key)).where('expiration', '>', this.#now()).first()
|
|
97
|
+
return row === null || row === undefined ? null : String(row.value)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async many(keys: readonly string[]): Promise<(string | null)[]> {
|
|
101
|
+
if (keys.length === 0) return []
|
|
102
|
+
const stored = keys.map(rowKey)
|
|
103
|
+
const rows = await this.#entries()
|
|
104
|
+
.select('key', 'value')
|
|
105
|
+
.whereIn('key', [...new Set(stored)])
|
|
106
|
+
.where('expiration', '>', this.#now())
|
|
107
|
+
.get()
|
|
108
|
+
const values = new Map(rows.map((row) => [String(row.key), String(row.value)]))
|
|
109
|
+
return stored.map((key) => values.get(key) ?? null)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async put(key: string, value: string, ttl: number | null): Promise<void> {
|
|
113
|
+
await this.#entries().upsert({ key: rowKey(key), value, expiration: this.#expiration(ttl) }, 'key', ['value', 'expiration'])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async add(key: string, value: string, ttl: number | null): Promise<boolean> {
|
|
117
|
+
const stored = rowKey(key)
|
|
118
|
+
const expiration = this.#expiration(ttl)
|
|
119
|
+
if ((await this.#entries().insertOrIgnore({ key: stored, value, expiration })) > 0) return true
|
|
120
|
+
// The key has a row: take it over only if it has expired, in one statement, so of two callers one wins.
|
|
121
|
+
const replaced = await this.#entries().where('key', stored).where('expiration', '<=', this.#now()).update({ value, expiration })
|
|
122
|
+
return replaced > 0
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async increment(key: string, by: number): Promise<number | null> {
|
|
126
|
+
const stored = rowKey(key)
|
|
127
|
+
for (;;) {
|
|
128
|
+
const row = await this.#entries().select('value').where('key', stored).where('expiration', '>', this.#now()).first()
|
|
129
|
+
if (row === null || row === undefined) {
|
|
130
|
+
if (await this.add(key, String(by), null)) return by
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
133
|
+
const old = String(row.value)
|
|
134
|
+
const current = storedInteger(old)
|
|
135
|
+
if (current === null) return null
|
|
136
|
+
if (by === 0) return current
|
|
137
|
+
// Compare and swap: the update applies only if no one changed the value since it was read.
|
|
138
|
+
const swapped = await this.#entries()
|
|
139
|
+
.where('key', stored)
|
|
140
|
+
.where('value', old)
|
|
141
|
+
.where('expiration', '>', this.#now())
|
|
142
|
+
.update({ value: String(current + by) })
|
|
143
|
+
if (swapped > 0) return current + by
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async forget(key: string): Promise<boolean> {
|
|
148
|
+
const stored = rowKey(key)
|
|
149
|
+
const live = await this.#entries().where('key', stored).where('expiration', '>', this.#now()).delete()
|
|
150
|
+
if (live === 0) await this.#entries().where('key', stored).delete()
|
|
151
|
+
return live > 0
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async flush(prefix: string): Promise<void> {
|
|
155
|
+
const query = this.#entries()
|
|
156
|
+
await (prefix === '' ? query : query.whereLike('key', `${rowKey(prefix)}%`, { caseSensitive: true })).delete()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
acquireLock(name: string, owner: string, ttl: number): Promise<boolean> {
|
|
160
|
+
return this.#locks(async (connection) => {
|
|
161
|
+
const locks = () => connection.table<LockRow>(this.#lockTable)
|
|
162
|
+
const key = rowKey(name)
|
|
163
|
+
const expiration = this.#now() + ttl
|
|
164
|
+
if ((await locks().insertOrIgnore({ key, owner, expiration })) > 0) return true
|
|
165
|
+
const taken = await locks()
|
|
166
|
+
.where('key', key)
|
|
167
|
+
.where((query) => query.where('owner', owner).orWhere('expiration', '<=', this.#now()))
|
|
168
|
+
.update({ owner, expiration })
|
|
169
|
+
return taken > 0
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
refreshLock(name: string, owner: string, ttl: number): Promise<boolean> {
|
|
174
|
+
return this.#locks(async (connection) => {
|
|
175
|
+
const refreshed = await connection
|
|
176
|
+
.table<LockRow>(this.#lockTable)
|
|
177
|
+
.where('key', rowKey(name))
|
|
178
|
+
.where('owner', owner)
|
|
179
|
+
.where('expiration', '>', this.#now())
|
|
180
|
+
.update({ expiration: this.#now() + ttl })
|
|
181
|
+
return refreshed > 0
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
releaseLock(name: string, owner: string): Promise<boolean> {
|
|
186
|
+
return this.#locks(async (connection) => {
|
|
187
|
+
const released = await connection
|
|
188
|
+
.table<LockRow>(this.#lockTable)
|
|
189
|
+
.where('key', rowKey(name))
|
|
190
|
+
.where('owner', owner)
|
|
191
|
+
.where('expiration', '>', this.#now())
|
|
192
|
+
.delete()
|
|
193
|
+
return released > 0
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
lockOwner(name: string): Promise<string | null> {
|
|
198
|
+
return this.#locks(async (connection) => {
|
|
199
|
+
const row = await connection
|
|
200
|
+
.table<LockRow>(this.#lockTable)
|
|
201
|
+
.select('owner')
|
|
202
|
+
.where('key', rowKey(name))
|
|
203
|
+
.where('expiration', '>', this.#now())
|
|
204
|
+
.first()
|
|
205
|
+
return row === null || row === undefined ? null : String(row.owner)
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async prune(): Promise<number> {
|
|
210
|
+
const now = this.#now()
|
|
211
|
+
const entries = await this.#entries().where('expiration', '<=', now).delete()
|
|
212
|
+
const locks = await this.#locks((connection) => connection.table<LockRow>(this.#lockTable).where('expiration', '<=', now).delete())
|
|
213
|
+
return entries + locks
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The columns of the cache table. */
|
|
218
|
+
export function cacheColumns(table: Blueprint): void {
|
|
219
|
+
table.string('key', 512).primary()
|
|
220
|
+
table.longText('value')
|
|
221
|
+
table.bigInteger('expiration').index()
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The columns of the cache's lock table. */
|
|
225
|
+
export function cacheLockColumns(table: Blueprint): void {
|
|
226
|
+
table.string('key', 512).primary()
|
|
227
|
+
table.string('owner')
|
|
228
|
+
table.bigInteger('expiration').index()
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Makes the tables the `database` store uses (CACHE_TABLE, `cache` by default, and `<table>_locks`) on
|
|
233
|
+
* CACHE_CONNECTION, or on the migration's connection when that is unset. Call it in a migration: `await cache.createTables()`.
|
|
234
|
+
*/
|
|
235
|
+
export async function createCacheTables(): Promise<void> {
|
|
236
|
+
const { connection, table } = currentApplication('cache.createTables()').resolve(ConfigRepository).framework.cache
|
|
237
|
+
// Loaded here, in a migration: the rest of the cache (and the HTTP layer's rate limits, which use it) loads nothing
|
|
238
|
+
// of the database layer.
|
|
239
|
+
const { schema } = await import('../schema/index.ts')
|
|
240
|
+
const builder = connection === null ? schema : schema.connection(connection)
|
|
241
|
+
await builder.create(table, cacheColumns)
|
|
242
|
+
await builder.create(`${table}_locks`, cacheLockColumns)
|
|
243
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// The `file` cache store: one file per entry under storage/framework/cache, shared by the processes of one machine.
|
|
2
|
+
// Writes go to a temporary file renamed into place, so a reader never sees half an entry. Changes that read first
|
|
3
|
+
// (add, increment, locks) hold a per-key lock file while they read and write.
|
|
4
|
+
import { createHash, randomUUID } from 'node:crypto'
|
|
5
|
+
import { mkdir, open, readdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises'
|
|
6
|
+
import { dirname, join } from 'node:path'
|
|
7
|
+
import { setTimeout as wait } from 'node:timers/promises'
|
|
8
|
+
import { MimarError } from '../errors/index.ts'
|
|
9
|
+
import type { Clock } from '../support/index.ts'
|
|
10
|
+
import { type CacheStore, storedInteger } from './store.ts'
|
|
11
|
+
|
|
12
|
+
/** How long a change waits for another process's lock file on the same key. */
|
|
13
|
+
const mutexTimeout = 10_000
|
|
14
|
+
/** A lock file older than this was left by a process that died while holding it. */
|
|
15
|
+
const staleMutex = 30_000
|
|
16
|
+
|
|
17
|
+
interface FileEntry {
|
|
18
|
+
key: string
|
|
19
|
+
value: string
|
|
20
|
+
expires: number | null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface FileLock {
|
|
24
|
+
name: string
|
|
25
|
+
owner: string
|
|
26
|
+
expires: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function hashed(text: string): string {
|
|
30
|
+
return createHash('sha256').update(text).digest('hex')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Runs a file operation, again a few times on Windows while it fails with EPERM, EACCES or EBUSY: there a file that
|
|
35
|
+
* another caller is deleting, or holds open while it is replaced, refuses access for a moment.
|
|
36
|
+
*/
|
|
37
|
+
async function retryOnWindows<T>(operation: () => Promise<T>): Promise<T> {
|
|
38
|
+
for (let attempt = 1; ; attempt++) {
|
|
39
|
+
try {
|
|
40
|
+
return await operation()
|
|
41
|
+
} catch (error) {
|
|
42
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
43
|
+
const transient = process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES' || code === 'EBUSY')
|
|
44
|
+
if (!transient || attempt === 10) throw error
|
|
45
|
+
await wait(attempt * 5)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function readJson<T>(path: string): Promise<T | null> {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(await retryOnWindows(() => readFile(path, 'utf8'))) as T
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
55
|
+
if (code === 'ENOENT' || error instanceof SyntaxError) return null
|
|
56
|
+
throw error
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function writeJson(path: string, value: unknown): Promise<void> {
|
|
61
|
+
await mkdir(dirname(path), { recursive: true })
|
|
62
|
+
const temporary = `${path}.${randomUUID()}.tmp`
|
|
63
|
+
await writeFile(temporary, JSON.stringify(value), { mode: 0o600 })
|
|
64
|
+
await retryOnWindows(() => rename(temporary, path))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Every file under `directory`, recursively; none when it does not exist. */
|
|
68
|
+
async function filesUnder(directory: string): Promise<string[]> {
|
|
69
|
+
try {
|
|
70
|
+
const entries = await readdir(directory, { recursive: true, withFileTypes: true })
|
|
71
|
+
return entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name))
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return []
|
|
74
|
+
throw error
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether opening a lock file failed because someone else holds it. On Windows a lock file that its holder is deleting
|
|
80
|
+
* cannot be opened until the delete completes, and the open fails with EPERM (or EACCES) instead of EEXIST.
|
|
81
|
+
*/
|
|
82
|
+
function lockTaken(error: unknown): boolean {
|
|
83
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
84
|
+
return code === 'EEXIST' || (process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES'))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class FileCacheStore implements CacheStore {
|
|
88
|
+
readonly #directory: string
|
|
89
|
+
readonly #clock: Clock
|
|
90
|
+
|
|
91
|
+
constructor(directory: string, clock: Clock) {
|
|
92
|
+
this.#directory = directory
|
|
93
|
+
this.#clock = clock
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#now(): number {
|
|
97
|
+
return this.#clock.now().epochMilliseconds
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#entryPath(key: string): string {
|
|
101
|
+
const hash = hashed(key)
|
|
102
|
+
return join(this.#directory, 'data', hash.slice(0, 2), hash.slice(2, 4), hash)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#lockPath(name: string): string {
|
|
106
|
+
return join(this.#directory, 'locks', hashed(name))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async #live(key: string): Promise<FileEntry | null> {
|
|
110
|
+
const entry = await readJson<FileEntry>(this.#entryPath(key))
|
|
111
|
+
if (entry === null || entry.key !== key || typeof entry.value !== 'string') return null
|
|
112
|
+
if (entry.expires !== null && entry.expires <= this.#now()) return null
|
|
113
|
+
return entry
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async #heldLock(name: string): Promise<FileLock | null> {
|
|
117
|
+
const lock = await readJson<FileLock>(this.#lockPath(name))
|
|
118
|
+
if (lock === null || lock.name !== name || lock.expires <= this.#now()) return null
|
|
119
|
+
return lock
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#write(key: string, value: string, ttl: number | null): Promise<void> {
|
|
123
|
+
return writeJson(this.#entryPath(key), { key, value, expires: ttl === null ? null : this.#now() + ttl } satisfies FileEntry)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Runs `work` while this process alone may change the file at `path`. */
|
|
127
|
+
async #exclusive<R>(path: string, work: () => Promise<R>): Promise<R> {
|
|
128
|
+
const mutex = `${path}.lock`
|
|
129
|
+
await mkdir(dirname(path), { recursive: true })
|
|
130
|
+
const started = performance.now()
|
|
131
|
+
for (;;) {
|
|
132
|
+
try {
|
|
133
|
+
await (await open(mutex, 'wx')).close()
|
|
134
|
+
break
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (!lockTaken(error)) throw error
|
|
137
|
+
const age = await stat(mutex).then(
|
|
138
|
+
(info) => performance.timeOrigin + performance.now() - info.mtimeMs,
|
|
139
|
+
() => 0,
|
|
140
|
+
)
|
|
141
|
+
if (age > staleMutex) await rm(mutex, { force: true })
|
|
142
|
+
else if (performance.now() - started > mutexTimeout) {
|
|
143
|
+
throw new MimarError(
|
|
144
|
+
'E_CACHE_BUSY',
|
|
145
|
+
`The file cache could not change an entry: another process held its lock file (${mutex}) for more than ${mutexTimeout / 1000} seconds.`,
|
|
146
|
+
)
|
|
147
|
+
} else await wait(2)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
return await work()
|
|
152
|
+
} finally {
|
|
153
|
+
await rm(mutex, { force: true })
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async get(key: string): Promise<string | null> {
|
|
158
|
+
return (await this.#live(key))?.value ?? null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
put(key: string, value: string, ttl: number | null): Promise<void> {
|
|
162
|
+
return this.#exclusive(this.#entryPath(key), () => this.#write(key, value, ttl))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
add(key: string, value: string, ttl: number | null): Promise<boolean> {
|
|
166
|
+
return this.#exclusive(this.#entryPath(key), async () => {
|
|
167
|
+
if ((await this.#live(key)) !== null) return false
|
|
168
|
+
await this.#write(key, value, ttl)
|
|
169
|
+
return true
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
increment(key: string, by: number): Promise<number | null> {
|
|
174
|
+
const path = this.#entryPath(key)
|
|
175
|
+
return this.#exclusive(path, async () => {
|
|
176
|
+
const entry = await this.#live(key)
|
|
177
|
+
if (entry === null) {
|
|
178
|
+
await this.#write(key, String(by), null)
|
|
179
|
+
return by
|
|
180
|
+
}
|
|
181
|
+
const current = storedInteger(entry.value)
|
|
182
|
+
if (current === null) return null
|
|
183
|
+
await writeJson(path, { ...entry, value: String(current + by) } satisfies FileEntry)
|
|
184
|
+
return current + by
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
forget(key: string): Promise<boolean> {
|
|
189
|
+
const path = this.#entryPath(key)
|
|
190
|
+
return this.#exclusive(path, async () => {
|
|
191
|
+
const live = (await this.#live(key)) !== null
|
|
192
|
+
await rm(path, { force: true })
|
|
193
|
+
return live
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Removes the file at `path` if `test` says so of what it holds, while no other process changes it. */
|
|
198
|
+
#removeIf(path: string, test: (record: Record<string, unknown> | null) => boolean): Promise<boolean> {
|
|
199
|
+
return this.#exclusive(path, async () => {
|
|
200
|
+
if (!test(await readJson<Record<string, unknown>>(path))) return false
|
|
201
|
+
await rm(path, { force: true })
|
|
202
|
+
return true
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The entry and lock files under `folder`, without the temporary and lock files beside them. */
|
|
207
|
+
async #records(folder: string): Promise<string[]> {
|
|
208
|
+
return (await filesUnder(join(this.#directory, folder))).filter((path) => !path.endsWith('.tmp') && !path.endsWith('.lock'))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async flush(prefix: string): Promise<void> {
|
|
212
|
+
for (const path of await this.#records('data')) {
|
|
213
|
+
await this.#removeIf(path, (entry) => typeof entry?.key === 'string' && entry.key.startsWith(prefix))
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
acquireLock(name: string, owner: string, ttl: number): Promise<boolean> {
|
|
218
|
+
const path = this.#lockPath(name)
|
|
219
|
+
return this.#exclusive(path, async () => {
|
|
220
|
+
const held = await this.#heldLock(name)
|
|
221
|
+
if (held !== null && held.owner !== owner) return false
|
|
222
|
+
await writeJson(path, { name, owner, expires: this.#now() + ttl } satisfies FileLock)
|
|
223
|
+
return true
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
refreshLock(name: string, owner: string, ttl: number): Promise<boolean> {
|
|
228
|
+
const path = this.#lockPath(name)
|
|
229
|
+
return this.#exclusive(path, async () => {
|
|
230
|
+
const held = await this.#heldLock(name)
|
|
231
|
+
if (held === null || held.owner !== owner) return false
|
|
232
|
+
await writeJson(path, { name, owner, expires: this.#now() + ttl } satisfies FileLock)
|
|
233
|
+
return true
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
releaseLock(name: string, owner: string): Promise<boolean> {
|
|
238
|
+
const path = this.#lockPath(name)
|
|
239
|
+
return this.#exclusive(path, async () => {
|
|
240
|
+
const held = await this.#heldLock(name)
|
|
241
|
+
if (held === null || held.owner !== owner) return false
|
|
242
|
+
await rm(path, { force: true })
|
|
243
|
+
return true
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async lockOwner(name: string): Promise<string | null> {
|
|
248
|
+
return (await this.#heldLock(name))?.owner ?? null
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async prune(): Promise<number> {
|
|
252
|
+
const now = this.#now()
|
|
253
|
+
let removed = 0
|
|
254
|
+
for (const folder of ['data', 'locks']) {
|
|
255
|
+
for (const path of await this.#records(folder)) {
|
|
256
|
+
const expired = (record: Record<string, unknown> | null) => typeof record?.expires === 'number' && record.expires <= now
|
|
257
|
+
if (await this.#removeIf(path, expired)) removed++
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return removed
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Cache,
|
|
3
|
+
CacheIntegerError,
|
|
4
|
+
CacheKeyError,
|
|
5
|
+
type CacheOperationEvent,
|
|
6
|
+
type CacheOptions,
|
|
7
|
+
CacheValueError,
|
|
8
|
+
cacheOperationChannel,
|
|
9
|
+
Lock,
|
|
10
|
+
LockTimeoutError,
|
|
11
|
+
} from './cache.ts'
|
|
12
|
+
export { cacheColumns, cacheLockColumns, createCacheTables, DatabaseCacheStore, type DatabaseCacheStoreOptions } from './database.ts'
|
|
13
|
+
export { FileCacheStore } from './file.ts'
|
|
14
|
+
export { CacheManager, type CacheManagerOptions, UnknownCacheStoreError } from './manager.ts'
|
|
15
|
+
export { cache } from './module.ts'
|
|
16
|
+
export {
|
|
17
|
+
type Attempt,
|
|
18
|
+
type BucketState,
|
|
19
|
+
CacheRateLimitStore,
|
|
20
|
+
type Limit,
|
|
21
|
+
MemoryRateLimitStore,
|
|
22
|
+
RateLimiter,
|
|
23
|
+
type RateLimitStore,
|
|
24
|
+
} from './rate-limiter.ts'
|
|
25
|
+
export { RedisCacheStore } from './redis.ts'
|
|
26
|
+
export { type CacheStore, type CacheStoreContext, type CacheStoreFactory, MemoryCacheStore, NullCacheStore } from './store.ts'
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Builds the cache stores by name, once each: the five built in and those registered with `app.cache().extend()`.
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import type { CacheConfig } from '../config/index.ts'
|
|
4
|
+
import type { DatabaseConnection } from '../db/index.ts'
|
|
5
|
+
import { MimarError } from '../errors/index.ts'
|
|
6
|
+
import type { RedisManager } from '../redis/index.ts'
|
|
7
|
+
import type { Clock, Frozen } from '../support/index.ts'
|
|
8
|
+
import { Cache } from './cache.ts'
|
|
9
|
+
import { DatabaseCacheStore } from './database.ts'
|
|
10
|
+
import { FileCacheStore } from './file.ts'
|
|
11
|
+
import { RedisCacheStore } from './redis.ts'
|
|
12
|
+
import { type CacheStore, type CacheStoreFactory, MemoryCacheStore, NullCacheStore } from './store.ts'
|
|
13
|
+
|
|
14
|
+
/** A store name that is neither built in nor registered. */
|
|
15
|
+
export class UnknownCacheStoreError extends MimarError {
|
|
16
|
+
constructor(name: string, known: readonly string[]) {
|
|
17
|
+
super(
|
|
18
|
+
'E_UNKNOWN_DRIVER',
|
|
19
|
+
`There is no cache store named "${name}". The stores are: ${known.join(', ')}. Register another with app.cache().extend().`,
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CacheManagerOptions {
|
|
25
|
+
readonly config: Frozen<CacheConfig>
|
|
26
|
+
readonly basePath: string
|
|
27
|
+
readonly clock: Clock
|
|
28
|
+
readonly drivers?: ReadonlyMap<string, CacheStoreFactory>
|
|
29
|
+
/** The `database` store's connection by name, or the default connection for null. */
|
|
30
|
+
readonly database?: (name: string | null) => DatabaseConnection
|
|
31
|
+
/** The application's Redis connections, for the `redis` store. */
|
|
32
|
+
readonly redis?: () => RedisManager
|
|
33
|
+
/** Records a failure of background work. */
|
|
34
|
+
readonly report?: (error: unknown) => void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class CacheManager {
|
|
38
|
+
static readonly builtInStores: readonly string[] = ['database', 'file', 'memory', 'null', 'redis']
|
|
39
|
+
|
|
40
|
+
readonly config: Frozen<CacheConfig>
|
|
41
|
+
readonly #options: CacheManagerOptions
|
|
42
|
+
readonly #drivers: ReadonlyMap<string, CacheStoreFactory>
|
|
43
|
+
readonly #caches = new Map<string, Cache>()
|
|
44
|
+
readonly #stores = new Map<string, CacheStore>()
|
|
45
|
+
|
|
46
|
+
constructor(options: CacheManagerOptions) {
|
|
47
|
+
this.config = options.config
|
|
48
|
+
this.#options = options
|
|
49
|
+
this.#drivers = options.drivers ?? new Map()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Whether `name` is a store this manager can build. */
|
|
53
|
+
static knows(name: string, drivers: ReadonlyMap<string, unknown>): boolean {
|
|
54
|
+
return CacheManager.builtInStores.includes(name) || drivers.has(name)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Every store name: the built-in ones and the registered ones. */
|
|
58
|
+
names(): string[] {
|
|
59
|
+
return [...new Set([...CacheManager.builtInStores, ...this.#drivers.keys()])].sort()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The cache on the default store (CACHE_STORE). */
|
|
63
|
+
default(): Cache {
|
|
64
|
+
return this.store(this.config.store)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The cache on the store `name`: `cache.store('redis')`. */
|
|
68
|
+
store(name: string): Cache {
|
|
69
|
+
const existing = this.#caches.get(name)
|
|
70
|
+
if (existing !== undefined) return existing
|
|
71
|
+
const store = this.#store(name)
|
|
72
|
+
const cache = new Cache({
|
|
73
|
+
name,
|
|
74
|
+
store,
|
|
75
|
+
prefix: this.config.prefix,
|
|
76
|
+
clock: this.#options.clock,
|
|
77
|
+
shared: name !== 'memory' && name !== 'null',
|
|
78
|
+
...(this.#options.report === undefined ? {} : { report: this.#options.report }),
|
|
79
|
+
})
|
|
80
|
+
this.#caches.set(name, cache)
|
|
81
|
+
return cache
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Removes the expired entries and locks of the store `name`; null when the store removes them itself. */
|
|
85
|
+
async prune(name: string): Promise<number | null> {
|
|
86
|
+
const store = this.#store(name)
|
|
87
|
+
return store.prune === undefined ? null : store.prune()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Closes the stores that opened something. */
|
|
91
|
+
async close(): Promise<void> {
|
|
92
|
+
const stores = [...this.#stores.values()]
|
|
93
|
+
this.#stores.clear()
|
|
94
|
+
this.#caches.clear()
|
|
95
|
+
await Promise.all(stores.map((store) => store.close?.()))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#store(name: string): CacheStore {
|
|
99
|
+
const existing = this.#stores.get(name)
|
|
100
|
+
if (existing !== undefined) return existing
|
|
101
|
+
const store = this.#build(name)
|
|
102
|
+
this.#stores.set(name, store)
|
|
103
|
+
return store
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#build(name: string): CacheStore {
|
|
107
|
+
const { config, basePath, clock } = this.#options
|
|
108
|
+
const custom = this.#drivers.get(name)
|
|
109
|
+
if (custom !== undefined) return custom({ config, basePath, clock })
|
|
110
|
+
switch (name) {
|
|
111
|
+
case 'memory':
|
|
112
|
+
return new MemoryCacheStore(clock, config.memoryLimit)
|
|
113
|
+
case 'null':
|
|
114
|
+
return new NullCacheStore()
|
|
115
|
+
case 'file':
|
|
116
|
+
return new FileCacheStore(join(basePath, config.files), clock)
|
|
117
|
+
case 'database': {
|
|
118
|
+
const database = this.#options.database
|
|
119
|
+
if (database === undefined) {
|
|
120
|
+
throw new MimarError(
|
|
121
|
+
'E_UNKNOWN_DRIVER',
|
|
122
|
+
'The database cache store needs the database: this cache manager was made without one.',
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
return new DatabaseCacheStore({ connection: () => database(config.connection), table: config.table, clock })
|
|
126
|
+
}
|
|
127
|
+
case 'redis': {
|
|
128
|
+
const redis = this.#options.redis
|
|
129
|
+
if (redis === undefined) {
|
|
130
|
+
throw new MimarError('E_UNKNOWN_DRIVER', 'The redis cache store needs Redis: this cache manager was made without it.')
|
|
131
|
+
}
|
|
132
|
+
return new RedisCacheStore(() => redis().connection(config.redisConnection, 'The redis cache store'))
|
|
133
|
+
}
|
|
134
|
+
default:
|
|
135
|
+
throw new UnknownCacheStoreError(name, this.names())
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|