mimarjs 0.0.1-alpha.0 → 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 +49 -3
- 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 +272 -11
- 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,519 @@
|
|
|
1
|
+
// The worker behind `queue:work`: one process, up to `concurrency` jobs in flight as async tasks. It reserves jobs from
|
|
2
|
+
// its queues in the order given, runs each attempt (runner.ts), and owns what follows: acknowledging, retrying with
|
|
3
|
+
// backoff, failing for good and recording the failure. Between reservations it checks the restart signal, paused
|
|
4
|
+
// queues and its limits.
|
|
5
|
+
//
|
|
6
|
+
// A stop signal (SIGTERM, Ctrl+C) stops reserving; jobs in flight get SERVER_SHUTDOWN_TIMEOUT to finish, then their
|
|
7
|
+
// signals abort and they go back on the queue without counting as an attempt. An attempt still running past its
|
|
8
|
+
// timeout plus QUEUE_TIMEOUT_GRACE is hung: the other jobs get the grace to finish and the worker exits with code 1,
|
|
9
|
+
// for its supervisor to restart. When the event loop itself is blocked, no timer can run, so a watchdog on a
|
|
10
|
+
// worker_threads thread kills the process instead.
|
|
11
|
+
import { randomUUID } from 'node:crypto'
|
|
12
|
+
import { Worker as Thread } from 'node:worker_threads'
|
|
13
|
+
import { MimarError } from '../errors/index.ts'
|
|
14
|
+
import { openScope, type ScopeApplication } from '../scope/index.ts'
|
|
15
|
+
import { humanize } from '../time/index.ts'
|
|
16
|
+
import type { ReservedJob } from './driver.ts'
|
|
17
|
+
import { type Envelope, encodeEnvelope } from './envelope.ts'
|
|
18
|
+
import { type AnyJob, backoffAfter } from './job.ts'
|
|
19
|
+
import type { QueueManager, RestoredJob } from './manager.ts'
|
|
20
|
+
import { type AttemptOutcome, runAttempt, runFailedHook } from './runner.ts'
|
|
21
|
+
|
|
22
|
+
/** Thrown into the failed record of a job no worker could run: its name is not registered on this application. */
|
|
23
|
+
export class UnknownJobError extends MimarError {
|
|
24
|
+
constructor(name: string, version: string) {
|
|
25
|
+
super(
|
|
26
|
+
'E_UNKNOWN_JOB',
|
|
27
|
+
`The job "${name}" is not registered on the application running this worker (version ${version}). It may have been renamed or removed, or dispatched by a newer release: deploy the code that defines it, then run queue:retry.`,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Recorded when a job comes back with no attempts left: an earlier attempt ended without a result. */
|
|
33
|
+
export class MaxAttemptsExceededError extends MimarError {
|
|
34
|
+
constructor(name: string, tries: number) {
|
|
35
|
+
super(
|
|
36
|
+
'E_MAX_ATTEMPTS',
|
|
37
|
+
`The job "${name}" was reserved more than its ${tries === 1 ? 'one attempt' : `${tries} attempts`} allow. An earlier attempt ended without a result: its worker died or was killed, or the job ran longer than QUEUE_RETRY_AFTER.`,
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Recorded when a job's `retryUntil` has passed. */
|
|
43
|
+
export class RetryUntilPassedError extends MimarError {
|
|
44
|
+
constructor(name: string) {
|
|
45
|
+
super('E_RETRY_UNTIL', `The job "${name}" ran out of time: its retryUntil has passed since it was dispatched.`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface WorkerOptions {
|
|
50
|
+
/** The connection to work (QUEUE_CONNECTION when omitted). */
|
|
51
|
+
readonly connection?: string
|
|
52
|
+
/** The queues to take jobs from, earlier names first. Default: the connection's queue. */
|
|
53
|
+
readonly queues?: readonly string[]
|
|
54
|
+
/** Jobs in flight at once. Default 1. */
|
|
55
|
+
readonly concurrency?: number
|
|
56
|
+
/** Milliseconds to wait when the queues are empty. Default 3000. */
|
|
57
|
+
readonly sleep?: number
|
|
58
|
+
/** Stop after taking this many jobs. */
|
|
59
|
+
readonly maxJobs?: number
|
|
60
|
+
/** Stop after this many milliseconds. */
|
|
61
|
+
readonly maxTime?: number
|
|
62
|
+
/** Stop when the queues are empty. */
|
|
63
|
+
readonly stopWhenEmpty?: boolean
|
|
64
|
+
/** Milliseconds jobs in flight get to finish once `signal` aborts. Default: SERVER_SHUTDOWN_TIMEOUT. */
|
|
65
|
+
readonly shutdownTimeout?: number
|
|
66
|
+
/** Stops the worker gracefully. */
|
|
67
|
+
readonly signal?: AbortSignal
|
|
68
|
+
/** Receives a line for each job that starts and ends. */
|
|
69
|
+
readonly log?: (line: string) => void
|
|
70
|
+
/** Ends the process after a hung job. Default: `process.exit`. */
|
|
71
|
+
readonly exit?: (code: number) => void
|
|
72
|
+
/** Watches for a blocked event loop from a thread. Default true. */
|
|
73
|
+
readonly watchdog?: boolean
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Why a worker stopped. */
|
|
77
|
+
export type WorkerStop = 'signal' | 'restart' | 'max-jobs' | 'max-time' | 'empty' | 'hung'
|
|
78
|
+
|
|
79
|
+
export interface WorkerResult {
|
|
80
|
+
readonly stop: WorkerStop
|
|
81
|
+
/** Jobs taken from the queues. */
|
|
82
|
+
readonly processed: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function pause(ms: number, signal?: AbortSignal): Promise<void> {
|
|
86
|
+
return new Promise((resolve) => {
|
|
87
|
+
if (signal?.aborted) return resolve()
|
|
88
|
+
const timer = setTimeout(done, ms)
|
|
89
|
+
function done() {
|
|
90
|
+
clearTimeout(timer)
|
|
91
|
+
signal?.removeEventListener('abort', done)
|
|
92
|
+
resolve()
|
|
93
|
+
}
|
|
94
|
+
signal?.addEventListener('abort', done, { once: true })
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function errorText(error: unknown): string {
|
|
99
|
+
return error instanceof Error ? error.message : String(error)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// The watchdog thread. It reads the main thread's heartbeat and the earliest deadline of the jobs in flight from shared
|
|
103
|
+
// memory; when the deadline has passed and the heartbeat has stopped, the event loop is blocked and only the operating
|
|
104
|
+
// system can stop the process. `process.exit` in a thread ends only the thread, so it sends SIGKILL.
|
|
105
|
+
const watchdogSource = `
|
|
106
|
+
const { workerData, parentPort } = require('node:worker_threads')
|
|
107
|
+
const { writeSync } = require('node:fs')
|
|
108
|
+
const shared = new BigInt64Array(workerData.buffer)
|
|
109
|
+
const job = { name: '' }
|
|
110
|
+
parentPort.on('message', (message) => { job.name = message })
|
|
111
|
+
setInterval(() => {
|
|
112
|
+
const now = BigInt(Temporal.Now.instant().epochMilliseconds)
|
|
113
|
+
const heartbeat = Atomics.load(shared, 0)
|
|
114
|
+
const deadline = Atomics.load(shared, 1)
|
|
115
|
+
if (deadline > 0n && now > deadline + 1000n && now - heartbeat > 2000n) {
|
|
116
|
+
writeSync(2, 'The job "' + job.name + '" has blocked the event loop for ' + Math.round(Number(now - heartbeat) / 1000) + ' seconds, past its timeout and QUEUE_TIMEOUT_GRACE, so its worker is killed for its supervisor to restart. A job that blocks the event loop belongs in a worker_threads task, or on a queue of its own with --concurrency=1.\\n')
|
|
117
|
+
process.kill(process.pid, 'SIGKILL')
|
|
118
|
+
}
|
|
119
|
+
}, 250)
|
|
120
|
+
`
|
|
121
|
+
|
|
122
|
+
class Watchdog {
|
|
123
|
+
readonly #shared = new BigInt64Array(new SharedArrayBuffer(16))
|
|
124
|
+
readonly #thread: Thread
|
|
125
|
+
readonly #beat: ReturnType<typeof setInterval>
|
|
126
|
+
readonly #deadlines = new Map<symbol, { at: number; name: string }>()
|
|
127
|
+
#name = ''
|
|
128
|
+
|
|
129
|
+
constructor() {
|
|
130
|
+
this.#thread = new Thread(watchdogSource, { eval: true, workerData: { buffer: this.#shared.buffer } })
|
|
131
|
+
this.#thread.unref()
|
|
132
|
+
this.#beatNow()
|
|
133
|
+
this.#beat = setInterval(() => this.#beatNow(), 500)
|
|
134
|
+
this.#beat.unref()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#beatNow(): void {
|
|
138
|
+
Atomics.store(this.#shared, 0, BigInt(Temporal.Now.instant().epochMilliseconds))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Sets or clears the deadline of one attempt. */
|
|
142
|
+
deadline(attempt: symbol, name: string, at: number | null): void {
|
|
143
|
+
if (at === null) this.#deadlines.delete(attempt)
|
|
144
|
+
else this.#deadlines.set(attempt, { at, name })
|
|
145
|
+
let earliest: { at: number; name: string } | null = null
|
|
146
|
+
for (const entry of this.#deadlines.values()) if (earliest === null || entry.at < earliest.at) earliest = entry
|
|
147
|
+
if (earliest !== null && earliest.name !== this.#name) {
|
|
148
|
+
this.#name = earliest.name
|
|
149
|
+
this.#thread.postMessage(earliest.name)
|
|
150
|
+
}
|
|
151
|
+
this.#beatNow()
|
|
152
|
+
Atomics.store(this.#shared, 1, BigInt(earliest?.at ?? 0))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async stop(): Promise<void> {
|
|
156
|
+
clearInterval(this.#beat)
|
|
157
|
+
await this.#thread.terminate()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Works one connection's queues until it is told to stop. */
|
|
162
|
+
export class QueueWorker {
|
|
163
|
+
readonly #manager: QueueManager
|
|
164
|
+
readonly #app: ScopeApplication
|
|
165
|
+
readonly #connection: string
|
|
166
|
+
readonly #queues: readonly string[]
|
|
167
|
+
readonly #concurrency: number
|
|
168
|
+
readonly #options: WorkerOptions
|
|
169
|
+
readonly #shutdownTimeout: number
|
|
170
|
+
readonly #inFlight = new Map<ReservedJob, Promise<void>>()
|
|
171
|
+
/** Aborts the signals of the attempts in flight when the worker stops before they end. */
|
|
172
|
+
readonly #interrupt = new AbortController()
|
|
173
|
+
/** Wakes the loop from a wait when a job hangs. */
|
|
174
|
+
readonly #wake = new AbortController()
|
|
175
|
+
/** Aborts on the stop signal or a hung job: what every wait of the loop listens to. */
|
|
176
|
+
readonly #halt: AbortSignal
|
|
177
|
+
#halted: Promise<void> | null = null
|
|
178
|
+
#watchdog: Watchdog | null = null
|
|
179
|
+
#interrupting = false
|
|
180
|
+
#abandoned = false
|
|
181
|
+
/** The hung job's processing, which ends once its attempt is recorded. */
|
|
182
|
+
#hung: Promise<void> | null = null
|
|
183
|
+
|
|
184
|
+
constructor(manager: QueueManager, options: WorkerOptions & { shutdownTimeout: number }) {
|
|
185
|
+
this.#manager = manager
|
|
186
|
+
this.#app = manager.app
|
|
187
|
+
this.#connection = options.connection ?? manager.config.default
|
|
188
|
+
this.#queues = options.queues !== undefined && options.queues.length > 0 ? options.queues : [manager.defaultQueue(this.#connection)]
|
|
189
|
+
const concurrency = options.concurrency ?? 1
|
|
190
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
191
|
+
throw new MimarError('E_INVALID_WORKER', `A worker's concurrency is a whole number of at least 1, not ${concurrency}.`)
|
|
192
|
+
}
|
|
193
|
+
this.#concurrency = concurrency
|
|
194
|
+
this.#options = options
|
|
195
|
+
this.#shutdownTimeout = options.shutdownTimeout
|
|
196
|
+
this.#halt = options.signal === undefined ? this.#wake.signal : AbortSignal.any([options.signal, this.#wake.signal])
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
get connection(): string {
|
|
200
|
+
return this.#connection
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
get queues(): readonly string[] {
|
|
204
|
+
return this.#queues
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
#log(line: string): void {
|
|
208
|
+
if (this.#options.log === undefined) return
|
|
209
|
+
const time = Temporal.Instant.fromEpochMilliseconds(this.#manager.clock.now().epochMilliseconds)
|
|
210
|
+
.toZonedDateTimeISO(Temporal.Now.timeZoneId())
|
|
211
|
+
.toPlainDateTime()
|
|
212
|
+
.toString({ smallestUnit: 'second' })
|
|
213
|
+
.replace('T', ' ')
|
|
214
|
+
this.#options.log(`${time} ${line}`)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Runs the worker's own reads and writes (reserving, acknowledging, recording) in a unit of work of their own: not
|
|
219
|
+
* the command's, whose signal aborts on Ctrl+C while those writes must still happen.
|
|
220
|
+
*/
|
|
221
|
+
async #unit<T>(work: () => Promise<T>): Promise<T> {
|
|
222
|
+
const handle = openScope(this.#app, 'job')
|
|
223
|
+
try {
|
|
224
|
+
return await handle.run(work)
|
|
225
|
+
} finally {
|
|
226
|
+
await handle.finish()
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Works until a stop: the signal, `queue:restart`, a limit, empty queues (`stopWhenEmpty`) or a hung job. */
|
|
231
|
+
async run(): Promise<WorkerResult> {
|
|
232
|
+
const manager = this.#manager
|
|
233
|
+
const driver = manager.driver(this.#connection)
|
|
234
|
+
const signal = this.#options.signal
|
|
235
|
+
const startedAt = performance.now()
|
|
236
|
+
const restartAtStart = await this.#unit(() => manager.restartedAt())
|
|
237
|
+
const halt = this.#halt
|
|
238
|
+
this.#halted = new Promise<void>((resolve) => {
|
|
239
|
+
if (halt.aborted) resolve()
|
|
240
|
+
else halt.addEventListener('abort', () => resolve(), { once: true })
|
|
241
|
+
})
|
|
242
|
+
const sleep = this.#options.sleep ?? 3000
|
|
243
|
+
const maxJobs = this.#options.maxJobs ?? null
|
|
244
|
+
const maxTime = this.#options.maxTime ?? null
|
|
245
|
+
if (this.#options.watchdog !== false) this.#watchdog = new Watchdog()
|
|
246
|
+
let processed = 0
|
|
247
|
+
let stop: WorkerStop | null = null
|
|
248
|
+
try {
|
|
249
|
+
while (stop === null) {
|
|
250
|
+
if (signal?.aborted) stop = 'signal'
|
|
251
|
+
else if (this.#hung !== null) stop = 'hung'
|
|
252
|
+
else if (maxTime !== null && performance.now() - startedAt >= maxTime) stop = 'max-time'
|
|
253
|
+
else if (maxJobs !== null && processed >= maxJobs) stop = 'max-jobs'
|
|
254
|
+
if (stop !== null) break
|
|
255
|
+
|
|
256
|
+
if (this.#inFlight.size >= this.#concurrency) {
|
|
257
|
+
await this.#settleOne()
|
|
258
|
+
continue
|
|
259
|
+
}
|
|
260
|
+
let reserved: ReservedJob[] = []
|
|
261
|
+
try {
|
|
262
|
+
const wanted = Math.min(
|
|
263
|
+
this.#concurrency - this.#inFlight.size,
|
|
264
|
+
maxJobs === null ? Number.POSITIVE_INFINITY : maxJobs - processed,
|
|
265
|
+
)
|
|
266
|
+
const next = await this.#unit(async () => {
|
|
267
|
+
// Between jobs: a restart asked for since this worker started stops it.
|
|
268
|
+
if ((await manager.restartedAt()) !== restartAtStart) return 'restart' as const
|
|
269
|
+
const queues = await manager.active(this.#connection, this.#queues)
|
|
270
|
+
if (queues.length === 0) return []
|
|
271
|
+
// A driver may wait for a job only while nothing runs, so a finished job frees its slot at once.
|
|
272
|
+
const wait = this.#inFlight.size === 0 && this.#options.stopWhenEmpty !== true
|
|
273
|
+
return driver.pop(queues, wanted, { wait, signal: halt })
|
|
274
|
+
})
|
|
275
|
+
if (next === 'restart') {
|
|
276
|
+
stop = 'restart'
|
|
277
|
+
break
|
|
278
|
+
}
|
|
279
|
+
reserved = next
|
|
280
|
+
} catch (error) {
|
|
281
|
+
this.#app.report(error, { during: `reserving jobs on the queue connection "${this.#connection}"` })
|
|
282
|
+
await pause(sleep, halt)
|
|
283
|
+
continue
|
|
284
|
+
}
|
|
285
|
+
if (reserved.length === 0) {
|
|
286
|
+
if (this.#inFlight.size > 0) {
|
|
287
|
+
if (this.#options.stopWhenEmpty) await this.#settleOne()
|
|
288
|
+
else await Promise.race([this.#settleOne(), pause(sleep, halt)])
|
|
289
|
+
} else if (this.#options.stopWhenEmpty) stop = 'empty'
|
|
290
|
+
else await pause(sleep, halt)
|
|
291
|
+
continue
|
|
292
|
+
}
|
|
293
|
+
for (const job of reserved) {
|
|
294
|
+
processed++
|
|
295
|
+
const running: Promise<void> = this.#unit(() => this.#process(job))
|
|
296
|
+
.catch((error: unknown) => this.#app.report(error, { during: 'processing a queued job' }))
|
|
297
|
+
.finally(() => this.#inFlight.delete(job))
|
|
298
|
+
this.#inFlight.set(job, running)
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (stop === 'hung') {
|
|
302
|
+
// The other jobs have had the grace; the hung one stays running until the process ends.
|
|
303
|
+
await this.#hung
|
|
304
|
+
this.#abandoned = true
|
|
305
|
+
} else await this.#drain(stop === 'signal')
|
|
306
|
+
} finally {
|
|
307
|
+
await this.#watchdog?.stop()
|
|
308
|
+
this.#watchdog = null
|
|
309
|
+
}
|
|
310
|
+
if (stop === 'hung') {
|
|
311
|
+
this.#log('A job is hung: the worker exits with code 1.')
|
|
312
|
+
;(this.#options.exit ?? ((code: number) => process.exit(code)))(1)
|
|
313
|
+
}
|
|
314
|
+
return { stop, processed }
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Waits for one job in flight to end, for the stop signal or for a job to hang. */
|
|
318
|
+
async #settleOne(): Promise<void> {
|
|
319
|
+
await Promise.race([...this.#inFlight.values(), this.#halted])
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Waits for the jobs in flight. On a stop signal they get the shutdown timeout, then their signals abort and they
|
|
324
|
+
* get the grace; any still running are left reserved, to be retried after QUEUE_RETRY_AFTER.
|
|
325
|
+
*/
|
|
326
|
+
async #drain(signalled: boolean): Promise<void> {
|
|
327
|
+
if (this.#inFlight.size === 0) return
|
|
328
|
+
const all = () => Promise.allSettled([...this.#inFlight.values()]).then(() => true as const)
|
|
329
|
+
if (!signalled) {
|
|
330
|
+
const stopped = this.#halted!.then(() => false as const)
|
|
331
|
+
if ((await Promise.race([all(), stopped])) === true) return
|
|
332
|
+
if (this.#hung !== null) {
|
|
333
|
+
await this.#hung
|
|
334
|
+
this.#abandoned = true
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
this.#log(
|
|
339
|
+
`Stopping: waiting up to ${humanize(`${this.#shutdownTimeout}ms`, { exact: true })} for ${this.#inFlight.size === 1 ? 'one job' : `${this.#inFlight.size} jobs`} to finish.`,
|
|
340
|
+
)
|
|
341
|
+
if ((await Promise.race([all(), pause(this.#shutdownTimeout).then(() => false as const)])) === true) return
|
|
342
|
+
this.#interrupting = true
|
|
343
|
+
this.#interrupt.abort(new MimarError('E_WORKER_STOPPING', 'The worker is stopping.'))
|
|
344
|
+
if ((await Promise.race([all(), pause(this.#manager.grace).then(() => false as const)])) === true) return
|
|
345
|
+
this.#abandoned = true
|
|
346
|
+
this.#log(
|
|
347
|
+
`${this.#inFlight.size === 1 ? 'One job is' : `${this.#inFlight.size} jobs are`} still running and stay reserved: they will be retried after QUEUE_RETRY_AFTER.`,
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async #process(reserved: ReservedJob): Promise<void> {
|
|
352
|
+
const manager = this.#manager
|
|
353
|
+
let restored: RestoredJob
|
|
354
|
+
try {
|
|
355
|
+
restored = manager.restore(reserved.envelope)
|
|
356
|
+
} catch (error) {
|
|
357
|
+
await this.#failUnreadable(reserved, error)
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
const { envelope } = restored
|
|
361
|
+
const job = manager.job(envelope.name)
|
|
362
|
+
if (job === undefined) {
|
|
363
|
+
await this.#failForGood(reserved, restored, null, new UnknownJobError(envelope.name, manager.version), true)
|
|
364
|
+
return
|
|
365
|
+
}
|
|
366
|
+
if (envelope.batch !== undefined && (await manager.batchCancelled(envelope.batch))) {
|
|
367
|
+
// The batch's other jobs still count this one, so its finally callback comes.
|
|
368
|
+
await this.#follow(envelope, () => manager.completed(envelope))
|
|
369
|
+
await this.#ack(reserved)
|
|
370
|
+
await manager.releaseUnique(envelope)
|
|
371
|
+
this.#log(`${job.name} ${envelope.id} skipped: its batch was cancelled`)
|
|
372
|
+
return
|
|
373
|
+
}
|
|
374
|
+
const attempt = reserved.attempts - envelope.interrupted
|
|
375
|
+
if (attempt > job.tries) {
|
|
376
|
+
await this.#failForGood(reserved, restored, job, new MaxAttemptsExceededError(job.name, job.tries), true)
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
if (this.#outOfTime(job, envelope)) {
|
|
380
|
+
await this.#failForGood(reserved, restored, job, new RetryUntilPassedError(job.name), true)
|
|
381
|
+
return
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const label = `${job.name} ${envelope.id}`
|
|
385
|
+
this.#log(`${label} running (attempt ${attempt})`)
|
|
386
|
+
const started = performance.now()
|
|
387
|
+
const key = Symbol(job.name)
|
|
388
|
+
const outcome = await runAttempt({
|
|
389
|
+
app: this.#app,
|
|
390
|
+
job,
|
|
391
|
+
id: envelope.id,
|
|
392
|
+
payload: envelope.payload,
|
|
393
|
+
attempt,
|
|
394
|
+
queue: reserved.queue,
|
|
395
|
+
connection: this.#connection,
|
|
396
|
+
batchId: envelope.batch ?? envelope.batchCallback ?? null,
|
|
397
|
+
values: restored.values,
|
|
398
|
+
hidden: restored.hidden,
|
|
399
|
+
grace: manager.grace,
|
|
400
|
+
stop: this.#interrupt.signal,
|
|
401
|
+
deadline: (at) => this.#watchdog?.deadline(key, job.name, at),
|
|
402
|
+
})
|
|
403
|
+
if (this.#abandoned) return
|
|
404
|
+
const took = `${Math.round(performance.now() - started)} ms`
|
|
405
|
+
if (this.#interrupting && outcome.kind !== 'done') {
|
|
406
|
+
await this.#release(reserved, { ...envelope, interrupted: envelope.interrupted + 1 }, 0)
|
|
407
|
+
this.#log(`${label} interrupted, back on the queue`)
|
|
408
|
+
return
|
|
409
|
+
}
|
|
410
|
+
await this.#settle(reserved, restored, job, attempt, outcome, label, took)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async #settle(
|
|
414
|
+
reserved: ReservedJob,
|
|
415
|
+
restored: RestoredJob,
|
|
416
|
+
job: AnyJob,
|
|
417
|
+
attempt: number,
|
|
418
|
+
outcome: AttemptOutcome,
|
|
419
|
+
label: string,
|
|
420
|
+
took: string,
|
|
421
|
+
): Promise<void> {
|
|
422
|
+
const { envelope } = restored
|
|
423
|
+
switch (outcome.kind) {
|
|
424
|
+
case 'done':
|
|
425
|
+
// Before the job leaves its queue: a worker that dies here runs the job again, rather than lose what follows.
|
|
426
|
+
await this.#follow(envelope, () => this.#manager.completed(envelope))
|
|
427
|
+
await this.#ack(reserved)
|
|
428
|
+
await this.#manager.releaseUnique(envelope)
|
|
429
|
+
this.#log(`${label} done in ${took}`)
|
|
430
|
+
return
|
|
431
|
+
case 'released':
|
|
432
|
+
await this.#release(reserved, envelope, outcome.delay)
|
|
433
|
+
this.#log(`${label} released${outcome.delay > 0 ? ` for ${humanize(`${outcome.delay}ms`, { exact: true })}` : ''}`)
|
|
434
|
+
return
|
|
435
|
+
case 'fail':
|
|
436
|
+
this.#app.report(outcome.error, { job: job.name, id: envelope.id, attempt })
|
|
437
|
+
await this.#failForGood(reserved, restored, job, outcome.error, false)
|
|
438
|
+
return
|
|
439
|
+
default: {
|
|
440
|
+
if (outcome.kind === 'hung' && this.#hung === null) {
|
|
441
|
+
// The handler cannot be stopped: the worker stops reserving, gives the other jobs the grace, records
|
|
442
|
+
// this attempt and exits. Recording it last keeps another worker from taking the job while it runs.
|
|
443
|
+
this.#hung = this.#inFlight.get(reserved) ?? Promise.resolve()
|
|
444
|
+
this.#wake.abort()
|
|
445
|
+
const others = [...this.#inFlight].filter(([other]) => other !== reserved).map(([, running]) => running)
|
|
446
|
+
await Promise.race([Promise.allSettled(others), pause(this.#manager.grace)])
|
|
447
|
+
}
|
|
448
|
+
this.#app.report(outcome.error, { job: job.name, id: envelope.id, attempt })
|
|
449
|
+
const counted: Envelope = { ...envelope, exceptions: envelope.exceptions + 1 }
|
|
450
|
+
const settled = { ...restored, envelope: counted }
|
|
451
|
+
if (attempt >= job.tries || counted.exceptions >= job.maxExceptions || this.#outOfTime(job, envelope)) {
|
|
452
|
+
await this.#failForGood(reserved, settled, job, outcome.error, false)
|
|
453
|
+
return
|
|
454
|
+
}
|
|
455
|
+
const delay = backoffAfter(job, attempt)
|
|
456
|
+
await this.#release(reserved, counted, delay)
|
|
457
|
+
this.#log(
|
|
458
|
+
`${label} failed (${errorText(outcome.error)}), retrying${delay > 0 ? ` in ${humanize(`${delay}ms`, { exact: true })}` : ''}`,
|
|
459
|
+
)
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
#outOfTime(job: AnyJob, envelope: Envelope): boolean {
|
|
465
|
+
return job.retryUntil !== null && this.#manager.clock.now().epochMilliseconds >= envelope.dispatchedAt + job.retryUntil
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
async #ack(reserved: ReservedJob): Promise<void> {
|
|
469
|
+
try {
|
|
470
|
+
await this.#manager.driver(this.#connection).ack(reserved)
|
|
471
|
+
} catch (error) {
|
|
472
|
+
this.#app.report(error, { during: `removing a finished job from the queue connection "${this.#connection}"` })
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
async #release(reserved: ReservedJob, envelope: Envelope, delay: number): Promise<void> {
|
|
477
|
+
try {
|
|
478
|
+
await this.#manager.driver(this.#connection).release(reserved, delay, encodeEnvelope(envelope))
|
|
479
|
+
} catch (error) {
|
|
480
|
+
this.#app.report(error, { during: `putting a job back on the queue connection "${this.#connection}"` })
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** Runs the job's `failed` hook, records the failure, and removes the job from its queue. */
|
|
485
|
+
async #failForGood(reserved: ReservedJob, restored: RestoredJob, job: AnyJob | null, error: unknown, report: boolean): Promise<void> {
|
|
486
|
+
const { envelope } = restored
|
|
487
|
+
if (report) this.#app.report(error, { job: envelope.name, id: envelope.id })
|
|
488
|
+
if (job !== null) await runFailedHook(this.#app, job, envelope.payload, error, restored)
|
|
489
|
+
await this.#record({ id: envelope.id, queue: reserved.queue, envelope: encodeEnvelope(envelope) }, error)
|
|
490
|
+
await this.#follow(envelope, () => this.#manager.failedForGood(envelope))
|
|
491
|
+
await this.#ack(reserved)
|
|
492
|
+
await this.#manager.releaseUnique(envelope)
|
|
493
|
+
this.#log(`${envelope.name} ${envelope.id} failed: ${errorText(error)}`)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Runs what follows a job (its chain, its batch); an error there is reported, and the job still leaves its queue. */
|
|
497
|
+
async #follow(envelope: Envelope, work: () => Promise<void>): Promise<void> {
|
|
498
|
+
try {
|
|
499
|
+
await work()
|
|
500
|
+
} catch (error) {
|
|
501
|
+
this.#app.report(error, { during: `dispatching what follows the job "${envelope.name}"`, id: envelope.id })
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async #failUnreadable(reserved: ReservedJob, error: unknown): Promise<void> {
|
|
506
|
+
this.#app.report(error, { during: `reading a job on the queue connection "${this.#connection}"` })
|
|
507
|
+
await this.#record({ id: randomUUID(), queue: reserved.queue, envelope: reserved.envelope }, error)
|
|
508
|
+
await this.#ack(reserved)
|
|
509
|
+
this.#log(`An unreadable job failed: ${errorText(error)}`)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
async #record(job: { id: string; queue: string; envelope: string }, error: unknown): Promise<void> {
|
|
513
|
+
try {
|
|
514
|
+
await this.#manager.failed().record({ ...job, connection: this.#connection }, error)
|
|
515
|
+
} catch (recordError) {
|
|
516
|
+
this.#app.report(recordError, { during: 'recording a failed job' })
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MissingRedisPackageError, type RedisClient, RedisManager, redis, UnknownRedisConnectionError } from './redis.ts'
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Redis connections. The framework does not wrap Redis commands: `redis.connection()` is the node-redis client itself,
|
|
2
|
+
// made from the REDIS_ variables on first use and closed when the application stops. node-redis traces its own
|
|
3
|
+
// commands on the `node-redis:command` diagnostics channel.
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import type { RedisClientType } from 'redis'
|
|
7
|
+
import type { RedisConfig, RedisConnectionConfig } from '../config/index.ts'
|
|
8
|
+
import { MimarError } from '../errors/index.ts'
|
|
9
|
+
import { currentApplication } from '../scope/index.ts'
|
|
10
|
+
import type { Frozen } from '../support/index.ts'
|
|
11
|
+
import { milliseconds } from '../time/index.ts'
|
|
12
|
+
|
|
13
|
+
/** A node-redis client: `await client.set('key', 'value')`. */
|
|
14
|
+
export type RedisClient = RedisClientType
|
|
15
|
+
|
|
16
|
+
/** The `redis` package is an optional peer: installed by the applications that use Redis. */
|
|
17
|
+
export class MissingRedisPackageError extends MimarError {
|
|
18
|
+
constructor(what: string) {
|
|
19
|
+
super('E_MISSING_DRIVER_PACKAGE', `${what} needs the "redis" package, which is not installed. Install it: npm install redis`)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A connection name that is not configured. */
|
|
24
|
+
export class UnknownRedisConnectionError extends MimarError {
|
|
25
|
+
constructor(name: string, known: readonly string[]) {
|
|
26
|
+
super(
|
|
27
|
+
'E_UNKNOWN_REDIS_CONNECTION',
|
|
28
|
+
`There is no Redis connection named "${name}". The connections are: ${known.join(', ')}. Add one in config/redis.ts.`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface RedisModule {
|
|
34
|
+
createClient(options: object): RedisClient
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The node-redis options of one connection. A URL gives the address and credentials; the database is always set. */
|
|
38
|
+
function clientOptions(name: string, config: Frozen<RedisConnectionConfig>): object {
|
|
39
|
+
const socket = { connectTimeout: 10_000, reconnectStrategy: (retries: number) => Math.min(100 * 2 ** retries, 3_000) }
|
|
40
|
+
const credentials = {
|
|
41
|
+
...(config.username === null ? {} : { username: config.username }),
|
|
42
|
+
...(config.password === null ? {} : { password: config.password }),
|
|
43
|
+
}
|
|
44
|
+
// A command waits to be sent while the connection is down, but not for ever: after the timeout it fails.
|
|
45
|
+
const common = {
|
|
46
|
+
name: `mimar-${name}`,
|
|
47
|
+
database: config.database,
|
|
48
|
+
commandOptions: { timeout: milliseconds(config.timeout) },
|
|
49
|
+
...credentials,
|
|
50
|
+
}
|
|
51
|
+
if (config.url !== null) return { url: config.url, socket, ...common }
|
|
52
|
+
return { socket: { ...socket, host: config.host, port: config.port }, ...common }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Where `connection` is, for messages: never its password. */
|
|
56
|
+
function address(config: Frozen<RedisConnectionConfig>): string {
|
|
57
|
+
if (config.url === null) return `${config.host}:${config.port}/${config.database}`
|
|
58
|
+
try {
|
|
59
|
+
const url = new URL(config.url)
|
|
60
|
+
return url.protocol === 'unix:' ? url.pathname : `${url.hostname}:${url.port || 6379}/${config.database}`
|
|
61
|
+
} catch {
|
|
62
|
+
return 'REDIS_URL'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class RedisManager {
|
|
67
|
+
readonly #config: Frozen<RedisConfig>
|
|
68
|
+
readonly #basePath: string
|
|
69
|
+
readonly #log: (message: string, values: Record<string, unknown>) => void
|
|
70
|
+
readonly #clients = new Map<string, RedisClient>()
|
|
71
|
+
#module: RedisModule | undefined
|
|
72
|
+
|
|
73
|
+
constructor(options: {
|
|
74
|
+
config: Frozen<RedisConfig>
|
|
75
|
+
/** The application root: the `redis` package is looked up from there, as the application installs it. */
|
|
76
|
+
basePath: string
|
|
77
|
+
/** Where connection failures are written: one line when a connection fails, none while it keeps retrying. */
|
|
78
|
+
log?: (message: string, values: Record<string, unknown>) => void
|
|
79
|
+
}) {
|
|
80
|
+
this.#config = options.config
|
|
81
|
+
this.#basePath = options.basePath
|
|
82
|
+
this.#log = options.log ?? (() => {})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The configured connection names. */
|
|
86
|
+
names(): string[] {
|
|
87
|
+
return Object.keys(this.#config.connections)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Whether the `redis` package can be loaded. */
|
|
91
|
+
installed(): boolean {
|
|
92
|
+
try {
|
|
93
|
+
this.#load('Redis')
|
|
94
|
+
return true
|
|
95
|
+
} catch {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The client of `name`, made and connected on first use. Commands sent while it connects wait for it. */
|
|
101
|
+
connection(name = 'default', what = 'Redis'): RedisClient {
|
|
102
|
+
const existing = this.#clients.get(name)
|
|
103
|
+
if (existing !== undefined) return existing
|
|
104
|
+
const config = this.#config.connections[name]
|
|
105
|
+
if (config === undefined) throw new UnknownRedisConnectionError(name, this.names())
|
|
106
|
+
const client = this.#load(what).createClient(clientOptions(name, config))
|
|
107
|
+
let failing = false
|
|
108
|
+
client.on('error', (error: Error) => {
|
|
109
|
+
if (failing) return
|
|
110
|
+
failing = true
|
|
111
|
+
this.#log(`The Redis connection ${name} (${address(config)}) failed: ${error.message}. It is retrying.`, { connection: name })
|
|
112
|
+
})
|
|
113
|
+
client.on('ready', () => {
|
|
114
|
+
failing = false
|
|
115
|
+
})
|
|
116
|
+
this.#clients.set(name, client)
|
|
117
|
+
client.connect().catch(() => {})
|
|
118
|
+
return client
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Closes every client: pending commands finish first. */
|
|
122
|
+
async close(): Promise<void> {
|
|
123
|
+
const clients = [...this.#clients.values()]
|
|
124
|
+
this.#clients.clear()
|
|
125
|
+
await Promise.all(
|
|
126
|
+
clients.map(async (client) => {
|
|
127
|
+
if (client.isOpen) await client.close().catch(() => client.destroy())
|
|
128
|
+
else client.destroy()
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#load(what: string): RedisModule {
|
|
134
|
+
if (this.#module !== undefined) return this.#module
|
|
135
|
+
const require = createRequire(join(this.#basePath, 'package.json'))
|
|
136
|
+
try {
|
|
137
|
+
this.#module = require('redis') as RedisModule
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if ((error as { code?: string }).code === 'MODULE_NOT_FOUND') {
|
|
140
|
+
try {
|
|
141
|
+
this.#module = createRequire(import.meta.url)('redis') as RedisModule
|
|
142
|
+
} catch {
|
|
143
|
+
throw new MissingRedisPackageError(what)
|
|
144
|
+
}
|
|
145
|
+
} else throw error
|
|
146
|
+
}
|
|
147
|
+
return this.#module
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The application's Redis connections. */
|
|
152
|
+
export const redis = Object.freeze({
|
|
153
|
+
/**
|
|
154
|
+
* The node-redis client of a connection: `default` (REDIS_DB) unless named. It connects on first use and closes
|
|
155
|
+
* when the application stops: `await redis.connection().set('key', 'value', { expiration: { type: 'EX', value: 60 } })`.
|
|
156
|
+
*/
|
|
157
|
+
connection: (name = 'default'): RedisClient => currentApplication('redis.connection()').resolve(RedisManager).connection(name),
|
|
158
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|