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,737 @@
|
|
|
1
|
+
// The relationships conformance suite: each kind of relationship loaded with `with()`, `load()` and `loadMany()`, nested
|
|
2
|
+
// and constrained, with pivot columns and `ofMany`; one query per relationship, counted on `mimar:db.query`; the error
|
|
3
|
+
// for a relationship read but not loaded; `refresh()` loading again what a row had loaded. Then the queries through
|
|
4
|
+
// relationships: `has()` and `whereHas()`, `whereBelongsTo()`, the computed `withCount()` columns, `related()` and its
|
|
5
|
+
// writes; and the through relationships, which follow a path of others. Each test runs against the database under
|
|
6
|
+
// test, over tables the suite creates.
|
|
7
|
+
import assert from 'node:assert/strict';
|
|
8
|
+
import { after, before, beforeEach, describe, test } from 'node:test';
|
|
9
|
+
import { databaseQueryChannel, db } from '../../db/index.js';
|
|
10
|
+
import { belongsTo, belongsToMany, checkModels, column, describeModel, hasMany, hasManyThrough, hasOne, hasOneThrough, InvalidModelValueError, Model, ModelDefinitionError, RelationNotLoadedError, UnknownModelColumnError, UnknownRelationError, } from '../../model/index.js';
|
|
11
|
+
import { schema } from '../../schema/index.js';
|
|
12
|
+
import { openHarness } from './harness.js';
|
|
13
|
+
const tables = ['rel_posts_rel_tags', 'rel_comments', 'rel_profiles', 'rel_posts', 'rel_tags', 'rel_users'];
|
|
14
|
+
/** A query or row with its methods untyped, to reach the run-time checks of calls the type checker refuses. */
|
|
15
|
+
const untyped = (value) => value;
|
|
16
|
+
/** Runs the relationships conformance suite: `testRelationships('postgres', { connection: { url } })`. */
|
|
17
|
+
export function testRelationships(name, options) {
|
|
18
|
+
describe(`relationships: ${name}`, () => {
|
|
19
|
+
class User extends Model('rel_users', {
|
|
20
|
+
id: column.id(),
|
|
21
|
+
mentorId: column.foreignId().nullable(),
|
|
22
|
+
name: column.string(),
|
|
23
|
+
}) {
|
|
24
|
+
relations() {
|
|
25
|
+
return {
|
|
26
|
+
mentor: belongsTo(() => User),
|
|
27
|
+
mentees: hasMany(() => User, { foreignKey: 'mentorId' }),
|
|
28
|
+
posts: hasMany(() => Post),
|
|
29
|
+
profile: hasOne(() => Profile),
|
|
30
|
+
latestPost: hasOne(() => Post, { ofMany: 'latest' }),
|
|
31
|
+
firstPost: hasOne(() => Post, { ofMany: 'oldest' }),
|
|
32
|
+
topPost: hasOne(() => Post, { ofMany: { max: 'votes' } }),
|
|
33
|
+
popularPosts: hasMany(() => Post, { scope: (query) => query.where('votes', '>', 6) }),
|
|
34
|
+
postComments: hasManyThrough(() => Comment, 'posts.comments'),
|
|
35
|
+
approvedPostComments: hasManyThrough(() => Comment, 'posts.approvedComments'),
|
|
36
|
+
popularPostComments: hasManyThrough(() => Comment, 'popularPosts.comments'),
|
|
37
|
+
postTags: hasManyThrough(() => Tag, 'posts.tags'),
|
|
38
|
+
menteePosts: hasManyThrough(() => Post, 'mentees.posts'),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
shout() {
|
|
42
|
+
return this.name.toUpperCase();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class Profile extends Model('rel_profiles', {
|
|
46
|
+
id: column.id(),
|
|
47
|
+
userId: column.foreignId(),
|
|
48
|
+
bio: column.string(),
|
|
49
|
+
}) {
|
|
50
|
+
}
|
|
51
|
+
class Post extends Model('rel_posts', {
|
|
52
|
+
id: column.id(),
|
|
53
|
+
userId: column.foreignId(),
|
|
54
|
+
editorId: column.foreignId().nullable(),
|
|
55
|
+
title: column.string(),
|
|
56
|
+
votes: column.integer().default(),
|
|
57
|
+
}) {
|
|
58
|
+
relations() {
|
|
59
|
+
return {
|
|
60
|
+
user: belongsTo(() => User),
|
|
61
|
+
editor: belongsTo(() => User),
|
|
62
|
+
comments: hasMany(() => Comment),
|
|
63
|
+
approvedComments: hasMany(() => Comment, { foreignKey: 'postId', scope: (query) => query.where('approved', true) }),
|
|
64
|
+
tags: belongsToMany(() => Tag, { pivot: { columns: ['note'], timestamps: true } }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class Comment extends Model('rel_comments', {
|
|
69
|
+
id: column.id(),
|
|
70
|
+
postId: column.foreignId(),
|
|
71
|
+
userId: column.foreignId(),
|
|
72
|
+
body: column.string(),
|
|
73
|
+
approved: column.boolean().default(),
|
|
74
|
+
}) {
|
|
75
|
+
relations() {
|
|
76
|
+
return { post: belongsTo(() => Post), user: belongsTo(() => User), author: hasOneThrough(() => User, 'post.user') };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class Tag extends Model('rel_tags', { id: column.id(), name: column.string() }) {
|
|
80
|
+
relations() {
|
|
81
|
+
return { posts: belongsToMany(() => Post), commenters: hasManyThrough(() => User, 'posts.comments.user') };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let harness;
|
|
85
|
+
const unit = (work) => harness.unit(work);
|
|
86
|
+
/** What `work` returns, and the statements it ran. */
|
|
87
|
+
const counted = async (work) => {
|
|
88
|
+
let count = 0;
|
|
89
|
+
const subscriber = { start: (_event) => void count++ };
|
|
90
|
+
databaseQueryChannel.subscribe(subscriber);
|
|
91
|
+
try {
|
|
92
|
+
return [await work(), count];
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
databaseQueryChannel.unsubscribe(subscriber);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/** Ada wrote two posts, Grace one; Ada's first has two comments (one approved) and two tags. */
|
|
99
|
+
const seed = async () => {
|
|
100
|
+
const ada = await User.create({ name: 'Ada' });
|
|
101
|
+
const grace = await User.create({ name: 'Grace' });
|
|
102
|
+
await User.create({ name: 'Linus' });
|
|
103
|
+
await Profile.create({ userId: ada.id, bio: 'Countess' });
|
|
104
|
+
const first = await Post.create({ userId: ada.id, editorId: grace.id, title: 'First', votes: 5 });
|
|
105
|
+
const second = await Post.create({ userId: ada.id, title: 'Second', votes: 9 });
|
|
106
|
+
const third = await Post.create({ userId: grace.id, title: 'Third', votes: 1 });
|
|
107
|
+
await Comment.create({ postId: first.id, userId: grace.id, body: 'Nice', approved: true });
|
|
108
|
+
await Comment.create({ postId: first.id, userId: ada.id, body: 'Thanks' });
|
|
109
|
+
const news = await Tag.create({ name: 'news' });
|
|
110
|
+
const math = await Tag.create({ name: 'math' });
|
|
111
|
+
await db.table('rel_posts_rel_tags').insert([
|
|
112
|
+
{ post_id: first.id, tag_id: news.id, note: 'lead' },
|
|
113
|
+
{ post_id: first.id, tag_id: math.id, note: null },
|
|
114
|
+
{ post_id: third.id, tag_id: news.id, note: 'short' },
|
|
115
|
+
]);
|
|
116
|
+
return { ada, grace, first, second, third, news, math };
|
|
117
|
+
};
|
|
118
|
+
before(async () => {
|
|
119
|
+
harness = await openHarness(options, 'relationships');
|
|
120
|
+
await unit(async () => {
|
|
121
|
+
for (const table of tables)
|
|
122
|
+
await schema.dropIfExists(table);
|
|
123
|
+
await schema.create('rel_users', (table) => {
|
|
124
|
+
table.id();
|
|
125
|
+
table.foreignId('mentor_id').nullable();
|
|
126
|
+
table.string('name');
|
|
127
|
+
});
|
|
128
|
+
await schema.create('rel_profiles', (table) => {
|
|
129
|
+
table.id();
|
|
130
|
+
table.foreignId('user_id');
|
|
131
|
+
table.string('bio');
|
|
132
|
+
});
|
|
133
|
+
await schema.create('rel_posts', (table) => {
|
|
134
|
+
table.id();
|
|
135
|
+
table.foreignId('user_id');
|
|
136
|
+
table.foreignId('editor_id').nullable();
|
|
137
|
+
table.string('title');
|
|
138
|
+
table.integer('votes').default(0);
|
|
139
|
+
});
|
|
140
|
+
await schema.create('rel_comments', (table) => {
|
|
141
|
+
table.id();
|
|
142
|
+
table.foreignId('post_id');
|
|
143
|
+
table.foreignId('user_id');
|
|
144
|
+
table.string('body');
|
|
145
|
+
table.boolean('approved').default(false);
|
|
146
|
+
});
|
|
147
|
+
await schema.create('rel_tags', (table) => {
|
|
148
|
+
table.id();
|
|
149
|
+
table.string('name');
|
|
150
|
+
});
|
|
151
|
+
await schema.create('rel_posts_rel_tags', (table) => {
|
|
152
|
+
table.foreignId('post_id');
|
|
153
|
+
table.foreignId('tag_id');
|
|
154
|
+
table.string('note').nullable();
|
|
155
|
+
table.timestamp('created_at').nullable();
|
|
156
|
+
table.timestamp('updated_at').nullable();
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
beforeEach(async () => {
|
|
161
|
+
await unit(async () => {
|
|
162
|
+
for (const table of tables)
|
|
163
|
+
await db.table(table).all().delete();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
after(async () => {
|
|
167
|
+
await unit(async () => {
|
|
168
|
+
for (const table of tables)
|
|
169
|
+
await schema.dropIfExists(table);
|
|
170
|
+
});
|
|
171
|
+
assert.deepEqual(harness.reported, []);
|
|
172
|
+
await harness.close();
|
|
173
|
+
});
|
|
174
|
+
test('belongsTo, hasOne and hasMany load with one query each, and match each row its own', async () => {
|
|
175
|
+
await unit(async () => {
|
|
176
|
+
const { ada, grace } = await seed();
|
|
177
|
+
const [posts, queries] = await counted(() => Post.query().with('user', 'editor', 'comments').orderBy('id').get());
|
|
178
|
+
assert.equal(queries, 4, 'the posts, then one query per relationship');
|
|
179
|
+
assert.deepEqual(posts.map((post) => [post.title, post.user.name, post.editor?.name ?? null, post.comments.map((each) => each.body)]), [
|
|
180
|
+
['First', 'Ada', 'Grace', ['Nice', 'Thanks']],
|
|
181
|
+
['Second', 'Ada', null, []],
|
|
182
|
+
['Third', 'Grace', null, []],
|
|
183
|
+
]);
|
|
184
|
+
assert.ok(posts[0].user instanceof User);
|
|
185
|
+
assert.equal(posts[0].user.shout(), 'ADA', 'related rows keep their methods');
|
|
186
|
+
assert.notEqual(posts[1].comments, posts[2].comments, 'each row has its own array');
|
|
187
|
+
const [users] = await counted(() => User.query().with('profile', 'posts').orderBy('id').get());
|
|
188
|
+
assert.deepEqual(users.map((user) => [user.name, user.profile?.bio ?? null, user.posts.length]), [
|
|
189
|
+
['Ada', 'Countess', 2],
|
|
190
|
+
['Grace', null, 1],
|
|
191
|
+
['Linus', null, 0],
|
|
192
|
+
]);
|
|
193
|
+
assert.equal((await User.query().with('posts').findOrFail(grace.id)).posts[0].title, 'Third');
|
|
194
|
+
assert.equal((await Post.query().with('user').where('userId', ada.id).count()) > 0, true);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
test('no query is made for a relationship no row has a key for', async () => {
|
|
198
|
+
await unit(async () => {
|
|
199
|
+
await seed();
|
|
200
|
+
const [posts, queries] = await counted(() => Post.query().with('editor').where('editorId', null).get());
|
|
201
|
+
assert.equal(queries, 1);
|
|
202
|
+
assert.ok(posts.every((post) => post.editor === null));
|
|
203
|
+
const [none, empty] = await counted(() => Post.query().with('user', 'comments').where('title', 'Missing').get());
|
|
204
|
+
assert.deepEqual(none, []);
|
|
205
|
+
assert.equal(empty, 1);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
test('paths load nested relationships, one query per relationship on the path', async () => {
|
|
209
|
+
await unit(async () => {
|
|
210
|
+
await seed();
|
|
211
|
+
const [posts, queries] = await counted(() => Post.query().with('comments.user', 'user').orderBy('id').get());
|
|
212
|
+
assert.equal(queries, 4, 'posts, comments, their users, the posts’ users');
|
|
213
|
+
assert.deepEqual(posts[0].comments.map((comment) => `${comment.body} by ${comment.user.name}`), ['Nice by Grace', 'Thanks by Ada']);
|
|
214
|
+
const [deep, deepQueries] = await counted(() => Post.query().with('comments.user.posts').orderBy('id').first());
|
|
215
|
+
assert.equal(deepQueries, 4);
|
|
216
|
+
assert.deepEqual(deep.comments.map((comment) => comment.user.posts.map((post) => post.title)), [['Third'], ['First', 'Second']]);
|
|
217
|
+
assert.throws(() => Post.query().with('comments.user.posts.user'), {
|
|
218
|
+
message: "with() was given \"comments.user.posts.user\", 4 relationships deep. Paths go at most 3 deep; load deeper ones in a callback: with('comments', (query) => query.with('user.posts.user')).",
|
|
219
|
+
});
|
|
220
|
+
const [callback, callbackQueries] = await counted(() => Post.query()
|
|
221
|
+
.with('comments', (comments) => comments.with('user.posts.user'))
|
|
222
|
+
.orderBy('id')
|
|
223
|
+
.first());
|
|
224
|
+
assert.equal(callbackQueries, 5);
|
|
225
|
+
assert.equal(callback.comments[0].user.posts[0].user.name, 'Grace');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
test('a constraint narrows a relationship’s query; a declared scope always applies', async () => {
|
|
229
|
+
await unit(async () => {
|
|
230
|
+
const { first } = await seed();
|
|
231
|
+
const post = await Post.query()
|
|
232
|
+
.with('comments', (comments) => comments.where('approved', false).orderBy('id'))
|
|
233
|
+
.findOrFail(first.id);
|
|
234
|
+
assert.deepEqual(post.comments.map((comment) => comment.body), ['Thanks']);
|
|
235
|
+
const scoped = await Post.query().with('approvedComments').findOrFail(first.id);
|
|
236
|
+
assert.deepEqual(scoped.approvedComments.map((comment) => comment.body), ['Nice']);
|
|
237
|
+
const narrowed = await Post.query()
|
|
238
|
+
.with('approvedComments', (comments) => comments.where('body', 'Thanks'))
|
|
239
|
+
.findOrFail(first.id);
|
|
240
|
+
assert.deepEqual(narrowed.approvedComments, [], 'the constraint narrows the scope, it does not replace it');
|
|
241
|
+
const later = await Post.query()
|
|
242
|
+
.with('comments')
|
|
243
|
+
.with('comments', (comments) => comments.where('body', 'Nice'))
|
|
244
|
+
.findOrFail(first.id);
|
|
245
|
+
assert.equal(later.comments.length, 1, 'the later with() of a relationship wins');
|
|
246
|
+
const picked = await Post.query()
|
|
247
|
+
.with('comments', (comments) => comments.select('postId', 'body'))
|
|
248
|
+
.findOrFail(first.id);
|
|
249
|
+
assert.deepEqual(picked.comments.map((comment) => ({ ...comment })), [
|
|
250
|
+
{ postId: first.id, body: 'Nice' },
|
|
251
|
+
{ postId: first.id, body: 'Thanks' },
|
|
252
|
+
]);
|
|
253
|
+
await assert.rejects(Post.query()
|
|
254
|
+
.with('comments', (comments) => comments.select('body'))
|
|
255
|
+
.findOrFail(first.id), {
|
|
256
|
+
message: 'The rows loaded for comments have no postId, which matches them to their parents. A constraint that selects columns must select postId too.',
|
|
257
|
+
});
|
|
258
|
+
await assert.rejects(Post.query()
|
|
259
|
+
.with('comments', () => 'not a query')
|
|
260
|
+
.get(), { message: 'The function given to with() for comments must return the query it was given, with its clauses added.' });
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
test('belongsToMany joins through the pivot table and reads the pivot columns asked for', async () => {
|
|
264
|
+
await unit(async () => {
|
|
265
|
+
const { first, third, news } = await seed();
|
|
266
|
+
const [posts, queries] = await counted(() => Post.query().with('tags').orderBy('id').get());
|
|
267
|
+
assert.equal(queries, 2);
|
|
268
|
+
assert.deepEqual(posts.map((post) => post.tags.map((tag) => tag.name).sort()), [['math', 'news'], [], ['news']]);
|
|
269
|
+
const lead = posts[0].tags.find((tag) => tag.name === 'news');
|
|
270
|
+
assert.ok(lead instanceof Tag);
|
|
271
|
+
assert.equal(lead.pivot.note, 'lead');
|
|
272
|
+
assert.equal(lead.pivot.created_at, null);
|
|
273
|
+
assert.equal(Number(lead.pivot.post_id), first.id);
|
|
274
|
+
assert.deepEqual(Object.keys(lead).sort(), ['id', 'name', 'pivot'], 'no pivot column is left on the row');
|
|
275
|
+
assert.notEqual(posts[0].tags.find((tag) => tag.name === 'news'), posts[2].tags[0], 'a row per parent');
|
|
276
|
+
const tag = await Tag.query().with('posts').findOrFail(news.id);
|
|
277
|
+
assert.deepEqual(tag.posts.map((post) => post.id).sort(), [first.id, third.id].sort());
|
|
278
|
+
assert.ok(!('pivot' in tag.posts[0]), 'a relationship that asks for no pivot column has no pivot');
|
|
279
|
+
const constrained = await Post.query()
|
|
280
|
+
.with('tags', (tags) => tags.where('name', 'math'))
|
|
281
|
+
.findOrFail(first.id);
|
|
282
|
+
assert.deepEqual(constrained.tags.map((each) => each.name), ['math'], 'the constraint names the related model’s columns, written with its table');
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
test('hasOne with ofMany keeps one related row per parent', async () => {
|
|
286
|
+
await unit(async () => {
|
|
287
|
+
await seed();
|
|
288
|
+
const [users, queries] = await counted(() => User.query().with('latestPost', 'firstPost', 'topPost').orderBy('id').get());
|
|
289
|
+
assert.equal(queries, 4);
|
|
290
|
+
assert.deepEqual(users.map((user) => [user.latestPost?.title ?? null, user.firstPost?.title ?? null, user.topPost?.title ?? null]), [
|
|
291
|
+
['Second', 'First', 'Second'],
|
|
292
|
+
['Third', 'Third', 'Third'],
|
|
293
|
+
[null, null, null],
|
|
294
|
+
]);
|
|
295
|
+
const constrained = await User.query()
|
|
296
|
+
.with('latestPost', (posts) => posts.where('votes', '<', 9))
|
|
297
|
+
.orderBy('id')
|
|
298
|
+
.first();
|
|
299
|
+
assert.equal(constrained.latestPost?.title, 'First', 'the constraint applies before the latest is chosen');
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
test('load() and loadMany() load onto rows already read, and refresh() loads them again', async () => {
|
|
303
|
+
await unit(async () => {
|
|
304
|
+
const { first } = await seed();
|
|
305
|
+
const post = await Post.findOrFail(first.id);
|
|
306
|
+
const [loaded, queries] = await counted(() => post.load('user', 'comments.user'));
|
|
307
|
+
assert.equal(queries, 3);
|
|
308
|
+
assert.equal(loaded, post, 'the same row, returned');
|
|
309
|
+
assert.equal(loaded.comments[1].user.name, 'Ada');
|
|
310
|
+
const approved = await post.load('comments', (comments) => comments.where('approved', true));
|
|
311
|
+
assert.equal(approved.comments.length, 1);
|
|
312
|
+
const posts = await Post.query().orderBy('id').get();
|
|
313
|
+
const [many, manyQueries] = await counted(() => Post.loadMany(posts, 'user', 'tags'));
|
|
314
|
+
assert.equal(manyQueries, 2);
|
|
315
|
+
assert.equal(many, posts);
|
|
316
|
+
assert.deepEqual(many.map((each) => each.user.name), ['Ada', 'Ada', 'Grace']);
|
|
317
|
+
await assert.rejects(Post.loadMany([{ id: 1 }], 'user'), InvalidModelValueError);
|
|
318
|
+
const withUser = await Post.query().with('user', 'comments').findOrFail(first.id);
|
|
319
|
+
await Comment.create({ postId: first.id, userId: first.userId, body: 'More' });
|
|
320
|
+
await User.query().where('id', first.userId).update({ name: 'Ada L.' });
|
|
321
|
+
const updated = await withUser.update({ title: 'Updated' });
|
|
322
|
+
assert.equal(updated.comments.length, 2, 'a write keeps what was loaded, as it was');
|
|
323
|
+
const [refreshed, refreshQueries] = await counted(() => withUser.refresh());
|
|
324
|
+
assert.equal(refreshQueries, 3, 'the row, then each relationship it had loaded');
|
|
325
|
+
assert.equal(refreshed.user.name, 'Ada L.');
|
|
326
|
+
assert.equal(refreshed.comments.length, 3);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
test('every read that returns rows loads their relationships; cursor() refuses', async () => {
|
|
330
|
+
await unit(async () => {
|
|
331
|
+
const { first } = await seed();
|
|
332
|
+
assert.equal((await Post.query().with('user').find(first.id)).user.name, 'Ada');
|
|
333
|
+
assert.equal((await Post.query().with('user').where('id', first.id).sole()).user.name, 'Ada');
|
|
334
|
+
assert.equal((await Post.query().with('user').findMany([first.id]))[0].user.name, 'Ada');
|
|
335
|
+
const pages = [];
|
|
336
|
+
const [, chunkQueries] = await counted(() => Post.query()
|
|
337
|
+
.with('user')
|
|
338
|
+
.chunkById(2, (rows) => void pages.push(rows.map((row) => row.user.name))));
|
|
339
|
+
assert.deepEqual(pages, [['Ada', 'Ada'], ['Grace']]);
|
|
340
|
+
assert.equal(chunkQueries, 4, 'each page, and its users');
|
|
341
|
+
const names = [];
|
|
342
|
+
for await (const post of Post.query().with('user').lazyById(2))
|
|
343
|
+
names.push(post.user.name);
|
|
344
|
+
assert.deepEqual(names, ['Ada', 'Ada', 'Grace']);
|
|
345
|
+
assert.throws(() => Post.query().with('user').cursor(), {
|
|
346
|
+
message: "cursor() reads one Post at a time, so it cannot load relationships with them. Use lazyById(), which reads a page at a time and loads each page's relationships with one query each.",
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
test('reading a relationship that was not loaded throws in testing; JSON includes what was loaded', async () => {
|
|
351
|
+
await unit(async () => {
|
|
352
|
+
const { first } = await seed();
|
|
353
|
+
const post = await Post.findOrFail(first.id);
|
|
354
|
+
assert.throws(() => post.comments, RelationNotLoadedError);
|
|
355
|
+
assert.throws(() => post.user, {
|
|
356
|
+
message: "Post.user was read but not loaded. Add .with('user') to the query, or call post.load('user').",
|
|
357
|
+
});
|
|
358
|
+
assert.equal('user' in post, false, 'asking whether it is loaded does not throw');
|
|
359
|
+
assert.equal({ ...post }.title, 'First', 'nor does copying the columns');
|
|
360
|
+
const created = await Post.create({ userId: first.userId, title: 'New' });
|
|
361
|
+
assert.throws(() => created.user, RelationNotLoadedError);
|
|
362
|
+
const loaded = await Post.query().with('user', 'tags').findOrFail(first.id);
|
|
363
|
+
const json = JSON.parse(JSON.stringify(loaded));
|
|
364
|
+
assert.equal(json.user.name, 'Ada');
|
|
365
|
+
assert.ok(json.tags.some((tag) => tag.pivot.note === 'lead'));
|
|
366
|
+
assert.ok(!('comments' in json));
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
test('unknown relationships are refused when the query is built', async () => {
|
|
370
|
+
await unit(async () => {
|
|
371
|
+
assert.throws(() => Post.query().with('coments'), {
|
|
372
|
+
message: 'Post has no relationship "coments". Its relationships are: user, editor, comments, approvedComments, tags.',
|
|
373
|
+
});
|
|
374
|
+
assert.throws(() => Post.query().with('comments.writer'), UnknownRelationError);
|
|
375
|
+
assert.throws(() => Profile.query().with('user'), {
|
|
376
|
+
message: 'Profile has no relationship "user": it declares none. Declare them in relations(): override relations() { return { user: belongsTo(() => User) } }',
|
|
377
|
+
});
|
|
378
|
+
assert.throws(() => Post.query().with('comments.user', ((query) => query)), {
|
|
379
|
+
message: "with() constrains one relationship of Post, not the path \"comments.user\". Constrain the last one inside a callback: with('comments', (query) => query.with('user', …)).",
|
|
380
|
+
});
|
|
381
|
+
assert.throws(() => Post.query().with(5), InvalidModelValueError);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
test('has(), whereHas() and doesntHave() filter by related rows, in the one query', async () => {
|
|
385
|
+
await unit(async () => {
|
|
386
|
+
const { ada, grace } = await seed();
|
|
387
|
+
const titles = async (query) => (await query.get()).map((post) => post.title);
|
|
388
|
+
const [withComments, queries] = await counted(() => titles(Post.query().has('comments').orderBy('id')));
|
|
389
|
+
assert.deepEqual(withComments, ['First']);
|
|
390
|
+
assert.equal(queries, 1, 'an exists subquery, not a query of its own');
|
|
391
|
+
assert.deepEqual(await titles(Post.query().doesntHave('comments').orderBy('id')), ['Second', 'Third']);
|
|
392
|
+
assert.deepEqual(await titles(Post.query().has('comments', '>=', 2)), ['First']);
|
|
393
|
+
assert.deepEqual(await titles(Post.query().has('comments', '>', 2)), []);
|
|
394
|
+
assert.deepEqual(await titles(Post.query().has('comments', '<', 2).orderBy('id')), ['Second', 'Third'], 'a count of zero is counted');
|
|
395
|
+
assert.deepEqual(await titles(Post.query().has('comments', '=', 0).orderBy('id')), ['Second', 'Third']);
|
|
396
|
+
assert.deepEqual(await titles(Post.query().whereHas('comments', (comments) => comments.where('approved', true).where('body', 'Nice'))), ['First']);
|
|
397
|
+
assert.deepEqual(await titles(Post.query().whereHas('comments', (comments) => comments.where('body', 'Nope'))), []);
|
|
398
|
+
assert.deepEqual(await titles(Post.query()
|
|
399
|
+
.whereDoesntHave('comments', (comments) => comments.where('approved', true))
|
|
400
|
+
.orderBy('id')), ['Second', 'Third']);
|
|
401
|
+
assert.deepEqual(await titles(Post.query().whereHas('comments', undefined, '>=', 2)), ['First']);
|
|
402
|
+
// belongsTo, a nullable one, belongsToMany and hasOne.
|
|
403
|
+
assert.deepEqual(await titles(Post.query().whereHas('user', (users) => users.where('name', 'Grace'))), ['Third']);
|
|
404
|
+
assert.deepEqual(await titles(Post.query().has('editor')), ['First']);
|
|
405
|
+
assert.deepEqual(await titles(Post.query().doesntHave('editor').orderBy('id')), ['Second', 'Third']);
|
|
406
|
+
assert.deepEqual(await titles(Post.query().has('tags').orderBy('id')), ['First', 'Third']);
|
|
407
|
+
assert.deepEqual(await titles(Post.query().whereHas('tags', (tags) => tags.where('name', 'math'))), ['First']);
|
|
408
|
+
assert.deepEqual(await titles(Post.query().has('tags', '>=', 2)), ['First']);
|
|
409
|
+
const names = async (query) => (await query.get()).map((user) => user.name);
|
|
410
|
+
assert.deepEqual(await names(User.query().has('profile')), ['Ada']);
|
|
411
|
+
assert.deepEqual(await names(User.query().has('posts', '>=', 2)), ['Ada']);
|
|
412
|
+
assert.deepEqual(await names(User.query().doesntHave('posts')), ['Linus']);
|
|
413
|
+
// A path is nested conditions; the constraint and the count apply to the last relationship.
|
|
414
|
+
assert.deepEqual(await names(User.query().has('posts.comments')), ['Ada']);
|
|
415
|
+
assert.deepEqual(await names(User.query()
|
|
416
|
+
.whereHas('posts.tags', (tags) => tags.where('name', 'news'))
|
|
417
|
+
.orderBy('id')), ['Ada', 'Grace']);
|
|
418
|
+
assert.deepEqual(await names(User.query().whereHas('posts.comments', (comments) => comments.where('approved', true))), [
|
|
419
|
+
'Ada',
|
|
420
|
+
]);
|
|
421
|
+
assert.deepEqual(await names(User.query().has('posts.tags', '>=', 2)), ['Ada']);
|
|
422
|
+
// or, and a declared scope.
|
|
423
|
+
assert.deepEqual(await titles(Post.query().where('title', 'Second').orHas('tags').orderBy('id')), [
|
|
424
|
+
'First',
|
|
425
|
+
'Second',
|
|
426
|
+
'Third',
|
|
427
|
+
]);
|
|
428
|
+
assert.deepEqual(await titles(Post.query().has('comments').orDoesntHave('tags').orderBy('id')), ['First', 'Second']);
|
|
429
|
+
assert.deepEqual(await titles(Post.query().has('approvedComments')), ['First']);
|
|
430
|
+
assert.deepEqual(await titles(Post.query().whereHas('approvedComments', (comments) => comments.where('body', 'Thanks'))), [], 'the scope applies inside the subquery too');
|
|
431
|
+
// A model related to itself: the subquery reads its table under another name.
|
|
432
|
+
await grace.update({ mentorId: ada.id });
|
|
433
|
+
assert.deepEqual(await names(User.query().has('mentees')), ['Ada']);
|
|
434
|
+
assert.deepEqual(await names(User.query().has('mentor')), ['Grace']);
|
|
435
|
+
assert.deepEqual(await names(User.query().whereHas('mentees', (users) => users.where('name', 'Grace'))), ['Ada']);
|
|
436
|
+
assert.deepEqual(await names(User.query().has('mentees.mentees')), []);
|
|
437
|
+
await User.query().where('name', 'Linus').update({ mentorId: grace.id });
|
|
438
|
+
assert.deepEqual(await names(User.query().has('mentees.mentees')), ['Ada']);
|
|
439
|
+
assert.deepEqual(await names(User.query().doesntHave('mentor').orderBy('id')), ['Ada']);
|
|
440
|
+
// Mistakes.
|
|
441
|
+
assert.throws(() => Post.query().has('coments'), UnknownRelationError);
|
|
442
|
+
assert.throws(() => Post.query().has('comments', '>=', -1), {
|
|
443
|
+
message: 'has() counts related rows with a whole number of 0 or more, not -1.',
|
|
444
|
+
});
|
|
445
|
+
assert.throws(() => Post.query()
|
|
446
|
+
.whereHas('comments', (() => 'no'))
|
|
447
|
+
.toSql(), {
|
|
448
|
+
message: 'The function given to whereHas() for comments must return the query it was given, with its clauses added.',
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
test('whereBelongsTo() finds the belongsTo relationship from the rows given', async () => {
|
|
453
|
+
await unit(async () => {
|
|
454
|
+
const { ada, grace, first, news } = await seed();
|
|
455
|
+
assert.equal(await Comment.query().whereBelongsTo(first).count(), 2);
|
|
456
|
+
assert.deepEqual(await Comment.query().whereBelongsTo(grace).pluck('body'), ['Nice']);
|
|
457
|
+
assert.deepEqual(await Post.query().whereBelongsTo(grace, 'editor').pluck('title'), ['First']);
|
|
458
|
+
assert.equal(await Post.query().whereBelongsTo([ada, grace], 'user').count(), 3);
|
|
459
|
+
assert.equal(await Post.query().where('title', 'Nope').orWhereBelongsTo(grace, 'user').count(), 1);
|
|
460
|
+
assert.equal(await Post.query()
|
|
461
|
+
.whereBelongsTo([], 'user')
|
|
462
|
+
.count(), 0);
|
|
463
|
+
assert.throws(() => untyped(Post.query()).whereBelongsTo(ada), {
|
|
464
|
+
message: "Post has 2 belongsTo relationships to User: user, editor. Name the one to use: whereBelongsTo(row, 'user').",
|
|
465
|
+
});
|
|
466
|
+
assert.throws(() => untyped(Post.query()).whereBelongsTo(news), {
|
|
467
|
+
message: 'Post has no belongsTo relationship to Tag, so whereBelongsTo() cannot match the row. Pass a row of a model Post belongs to, or name the relationship.',
|
|
468
|
+
});
|
|
469
|
+
assert.throws(() => Post.query().whereBelongsTo(ada, 'comments'), {
|
|
470
|
+
message: 'whereBelongsTo() takes a belongsTo relationship, and Post.comments is a hasMany.',
|
|
471
|
+
});
|
|
472
|
+
assert.throws(() => untyped(Post.query()).whereBelongsTo(news, 'user'), {
|
|
473
|
+
message: 'whereBelongsTo() was given a row that is not a User, the model Post.user points at.',
|
|
474
|
+
});
|
|
475
|
+
assert.throws(() => untyped(Post.query()).whereBelongsTo([]), {
|
|
476
|
+
message: "whereBelongsTo() was given no rows, so it cannot tell which relationship to use. Name it: whereBelongsTo(users, 'user').",
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
test('withCount(), withExists() and withSum() add computed columns in the one query', async () => {
|
|
481
|
+
await unit(async () => {
|
|
482
|
+
const { ada, grace, first } = await seed();
|
|
483
|
+
const [posts, queries] = await counted(() => Post.query().withCount('comments', 'tags').withExists('editor').orderBy('id').get());
|
|
484
|
+
assert.equal(queries, 1);
|
|
485
|
+
assert.deepEqual(posts.map((post) => [post.title, post.commentsCount, post.tagsCount, post.editorExists]), [
|
|
486
|
+
['First', 2, 2, true],
|
|
487
|
+
['Second', 0, 0, false],
|
|
488
|
+
['Third', 0, 1, false],
|
|
489
|
+
]);
|
|
490
|
+
assert.ok(posts[0] instanceof Post, 'the rows are still instances');
|
|
491
|
+
assert.deepEqual((await Post.query()
|
|
492
|
+
.withCount('comments', (comments) => comments.where('approved', true))
|
|
493
|
+
.orderBy('id')
|
|
494
|
+
.get()).map((post) => post.commentsCount), [1, 0, 0]);
|
|
495
|
+
assert.deepEqual((await Post.query().withCount('approvedComments').orderBy('id').get()).map((post) => post.approvedCommentsCount), [1, 0, 0]);
|
|
496
|
+
const users = await User.query().withSum('posts', 'votes').withExists('profile').orderBy('id').get();
|
|
497
|
+
assert.deepEqual(users.map((user) => [user.name, user.postsSumVotes, user.profileExists]), [
|
|
498
|
+
['Ada', 14, true],
|
|
499
|
+
['Grace', 1, false],
|
|
500
|
+
['Linus', 0, false],
|
|
501
|
+
], 'a sum over no rows is 0');
|
|
502
|
+
assert.deepEqual((await User.query()
|
|
503
|
+
.withSum('posts', 'votes', (posts) => posts.where('votes', '>', 5))
|
|
504
|
+
.orderBy('id')
|
|
505
|
+
.get()).map((user) => user.postsSumVotes), [9, 0, 0]);
|
|
506
|
+
const picked = await Post.query().select('id', 'title').withCount('comments').orderBy('id').get();
|
|
507
|
+
assert.deepEqual(picked.map((post) => ({ ...post })), [
|
|
508
|
+
{ id: first.id, title: 'First', commentsCount: 2 },
|
|
509
|
+
{ id: picked[1].id, title: 'Second', commentsCount: 0 },
|
|
510
|
+
{ id: picked[2].id, title: 'Third', commentsCount: 0 },
|
|
511
|
+
], 'beside chosen columns, a plain object');
|
|
512
|
+
const [loaded, loadedQueries] = await counted(() => Post.query().with('user').withCount('comments').findOrFail(first.id));
|
|
513
|
+
assert.equal(loadedQueries, 2);
|
|
514
|
+
assert.deepEqual([loaded.user.name, loaded.commentsCount], ['Ada', 2]);
|
|
515
|
+
await grace.update({ mentorId: ada.id });
|
|
516
|
+
assert.deepEqual((await User.query().withCount('mentees').orderBy('id').get()).map((user) => user.menteesCount), [1, 0, 0]);
|
|
517
|
+
assert.throws(() => Post.query().withCount('user'), {
|
|
518
|
+
message: "withCount() aggregates a relationship of many rows, and Post.user is a belongsTo, of one. Use withExists('user').",
|
|
519
|
+
});
|
|
520
|
+
assert.throws(() => User.query().withSum('posts', 'vote'), UnknownModelColumnError);
|
|
521
|
+
assert.throws(() => Post.query().withCount('comments.user'), InvalidModelValueError);
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
test('related() is a query of the related rows, limited to the row', async () => {
|
|
525
|
+
await unit(async () => {
|
|
526
|
+
const { ada, first, second, news } = await seed();
|
|
527
|
+
assert.deepEqual(await first.related('comments').orderBy('id').pluck('body'), ['Nice', 'Thanks']);
|
|
528
|
+
assert.deepEqual(await first.related('comments').where('approved', true).pluck('body'), ['Nice']);
|
|
529
|
+
assert.deepEqual(await first.related('approvedComments').pluck('body'), ['Nice'], 'with its declared scope');
|
|
530
|
+
assert.equal((await first.related('user').first())?.name, 'Ada');
|
|
531
|
+
assert.equal(await second.related('editor').first(), null, 'a null foreign key finds nothing');
|
|
532
|
+
assert.equal(await ada.related('posts').count(), 2);
|
|
533
|
+
assert.deepEqual(await ada.related('latestPost').pluck('title'), ['Second'], 'ofMany picks the one row');
|
|
534
|
+
assert.deepEqual(await ada.related('firstPost').pluck('title'), ['First']);
|
|
535
|
+
assert.deepEqual(await ada.related('topPost').pluck('title'), ['Second']);
|
|
536
|
+
const tags = await first.related('tags').orderBy('name').get();
|
|
537
|
+
assert.deepEqual(tags.map((tag) => tag.name), ['math', 'news']);
|
|
538
|
+
assert.ok(tags[1] instanceof Tag);
|
|
539
|
+
assert.equal(tags[1].pivot.note, 'lead');
|
|
540
|
+
assert.deepEqual(Object.keys(tags[1]).sort(), ['id', 'name', 'pivot']);
|
|
541
|
+
assert.equal(await first.related('tags').where('name', 'news').count(), 1);
|
|
542
|
+
assert.deepEqual(await news.related('posts').orderBy('id').pluck('title'), ['First', 'Third']);
|
|
543
|
+
const [withUsers, queries] = await counted(() => first.related('comments').with('user').orderBy('id').get());
|
|
544
|
+
assert.equal(queries, 2);
|
|
545
|
+
assert.deepEqual(withUsers.map((comment) => comment.user.name), ['Grace', 'Ada']);
|
|
546
|
+
assert.throws(() => first.related('coments'), UnknownRelationError);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
test('create() through a hasMany or hasOne sets the foreign key from the row', async () => {
|
|
550
|
+
await unit(async () => {
|
|
551
|
+
const { ada, grace, first, second } = await seed();
|
|
552
|
+
const comment = await first.related('comments').create({ userId: ada.id, body: 'More' });
|
|
553
|
+
assert.ok(comment instanceof Comment);
|
|
554
|
+
assert.equal(comment.postId, first.id);
|
|
555
|
+
assert.equal(await first.related('comments').count(), 3);
|
|
556
|
+
// Profile declares no belongsTo back, so the type asks for the key; it must be the user's.
|
|
557
|
+
const profile = await grace.related('profile').create({ userId: grace.id, bio: 'Admiral' });
|
|
558
|
+
assert.equal(profile.userId, grace.id);
|
|
559
|
+
const mentee = await ada.related('mentees').create({ name: 'Mary' });
|
|
560
|
+
assert.equal(mentee.mentorId, ada.id, 'a key the declaration names');
|
|
561
|
+
await first.related('comments').create({ postId: first.id, userId: ada.id, body: 'Same key' });
|
|
562
|
+
await assert.rejects(first.related('comments').create({ postId: second.id, userId: ada.id, body: 'Elsewhere' }), {
|
|
563
|
+
message: `post.related('comments').create() sets postId to the Post's key, ${first.id}, and was given ${second.id}.`,
|
|
564
|
+
});
|
|
565
|
+
await assert.rejects(untyped(first.related('tags')).create({ name: 'x' }), {
|
|
566
|
+
message: "post.related('tags').create() is for hasMany and hasOne relationships, and Post.tags is a belongsToMany. To link rows, use post.related('tags').attach(…).",
|
|
567
|
+
});
|
|
568
|
+
await assert.rejects(untyped(first.related('user')).create({}), {
|
|
569
|
+
message: "post.related('user').create() is for hasMany and hasOne relationships, and Post.user is a belongsTo.",
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
test('attach(), detach(), sync() and toggle() write the pivot table', async () => {
|
|
574
|
+
await unit(async () => {
|
|
575
|
+
const { first, second, news, math } = await seed();
|
|
576
|
+
const science = await Tag.create({ name: 'science' });
|
|
577
|
+
const tagNames = async (post) => (await post.related('tags').orderBy('name').get()).map((tag) => tag.name);
|
|
578
|
+
await second.related('tags').attach([news.id, math]);
|
|
579
|
+
assert.deepEqual(await tagNames(second), ['math', 'news']);
|
|
580
|
+
const [linked] = await second.related('tags').where('name', 'news').get();
|
|
581
|
+
assert.notEqual(linked.pivot.created_at, null, 'the pivot keeps timestamps, so attach fills them');
|
|
582
|
+
await second.related('tags').attach(science, { note: 'new' });
|
|
583
|
+
assert.equal((await second.related('tags').where('name', 'science').first())?.pivot.note, 'new');
|
|
584
|
+
assert.equal(await second.related('tags').detach([math.id]), 1);
|
|
585
|
+
assert.deepEqual(await tagNames(second), ['news', 'science']);
|
|
586
|
+
assert.equal(await second.related('tags').detach(), 2);
|
|
587
|
+
assert.deepEqual(await tagNames(second), []);
|
|
588
|
+
assert.deepEqual(await tagNames(first), ['math', 'news'], 'only the row’s own links change');
|
|
589
|
+
const keys = (changes) => Object.fromEntries(Object.entries(changes).map(([name, list]) => [name, list.map(Number).sort()]));
|
|
590
|
+
const synced = await first.related('tags').sync(new Map([
|
|
591
|
+
[news.id, { note: 'lead' }],
|
|
592
|
+
[science.id, { note: 'sci' }],
|
|
593
|
+
]));
|
|
594
|
+
assert.deepEqual(keys(synced), { attached: [science.id], detached: [math.id], updated: [] });
|
|
595
|
+
assert.deepEqual(await tagNames(first), ['news', 'science']);
|
|
596
|
+
const changed = await first.related('tags').sync(new Map([[news.id, { note: 'top' }]]));
|
|
597
|
+
assert.deepEqual(keys(changed), { attached: [], detached: [science.id], updated: [news.id] });
|
|
598
|
+
assert.equal((await first.related('tags').first())?.pivot.note, 'top');
|
|
599
|
+
assert.deepEqual(keys(await first.related('tags').sync([news.id, news.id])), { attached: [], detached: [], updated: [] });
|
|
600
|
+
assert.deepEqual(keys(await first.related('tags').sync([])), { attached: [], detached: [news.id], updated: [] });
|
|
601
|
+
assert.deepEqual(await tagNames(first), []);
|
|
602
|
+
assert.deepEqual(keys(await first.related('tags').toggle([news, math.id])), {
|
|
603
|
+
attached: [math.id, news.id].sort(),
|
|
604
|
+
detached: [],
|
|
605
|
+
});
|
|
606
|
+
assert.deepEqual(keys(await first.related('tags').toggle([math.id, science.id])), {
|
|
607
|
+
attached: [science.id],
|
|
608
|
+
detached: [math.id],
|
|
609
|
+
});
|
|
610
|
+
assert.deepEqual(await tagNames(first), ['news', 'science']);
|
|
611
|
+
await assert.rejects(untyped(first.related('comments')).attach([1]), {
|
|
612
|
+
message: "post.related('comments').attach() is for belongsToMany relationships, and Post.comments is a hasMany. To add a row, use post.related('comments').create({ … }).",
|
|
613
|
+
});
|
|
614
|
+
await assert.rejects(first.related('tags').attach([first]), {
|
|
615
|
+
message: "post.related('tags').attach() takes keys of Tag rows, or the rows themselves, not object.",
|
|
616
|
+
});
|
|
617
|
+
await assert.rejects(first.related('tags').attach([1], 'note'), InvalidModelValueError);
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
test('a through relationship follows the relationships it names, with one query', async () => {
|
|
621
|
+
await unit(async () => {
|
|
622
|
+
const { ada, grace, news } = await seed();
|
|
623
|
+
const [users, queries] = await counted(() => User.query().with('postComments', 'postTags').orderBy('id').get());
|
|
624
|
+
assert.equal(queries, 3);
|
|
625
|
+
assert.deepEqual(users.map((user) => [
|
|
626
|
+
user.name,
|
|
627
|
+
user.postComments.map((each) => each.body).sort(),
|
|
628
|
+
user.postTags.map((each) => each.name).sort(),
|
|
629
|
+
]), [
|
|
630
|
+
['Ada', ['Nice', 'Thanks'], ['math', 'news']],
|
|
631
|
+
['Grace', [], ['news']],
|
|
632
|
+
['Linus', [], []],
|
|
633
|
+
]);
|
|
634
|
+
const reached = users[0].postComments[0];
|
|
635
|
+
assert.ok(reached instanceof Comment);
|
|
636
|
+
assert.deepEqual(Object.keys(reached).sort(), ['approved', 'body', 'id', 'postId', 'userId'], 'no column of the path is left on the row');
|
|
637
|
+
// belongsTo on the way, and one row.
|
|
638
|
+
const comments = await Comment.query().with('author').orderBy('id').get();
|
|
639
|
+
assert.deepEqual(comments.map((comment) => comment.author?.name ?? null), ['Ada', 'Ada']);
|
|
640
|
+
// Three deep, starting through a pivot table.
|
|
641
|
+
const tag = await Tag.query().with('commenters').findOrFail(news.id);
|
|
642
|
+
assert.deepEqual(tag.commenters.map((user) => user.name).sort(), ['Ada', 'Grace']);
|
|
643
|
+
// The model a path passes through twice: each table on the way has its own alias.
|
|
644
|
+
await grace.update({ mentorId: ada.id });
|
|
645
|
+
const mentors = await User.query().with('menteePosts').orderBy('id').get();
|
|
646
|
+
assert.deepEqual(mentors.map((user) => user.menteePosts.map((post) => post.title)), [['Third'], [], []]);
|
|
647
|
+
// The scopes of the relationships on the way apply, as does a constraint.
|
|
648
|
+
const scoped = await User.query().with('popularPostComments', 'approvedPostComments').findOrFail(ada.id);
|
|
649
|
+
assert.deepEqual(scoped.popularPostComments, [], 'only Second has more than 6 votes, and it has no comments');
|
|
650
|
+
assert.deepEqual(scoped.approvedPostComments.map((comment) => comment.body), ['Nice']);
|
|
651
|
+
const constrained = await User.query()
|
|
652
|
+
.with('postComments', (query) => query.where('approved', false))
|
|
653
|
+
.findOrFail(ada.id);
|
|
654
|
+
assert.deepEqual(constrained.postComments.map((comment) => comment.body), ['Thanks']);
|
|
655
|
+
assert.deepEqual((await ada.load('postTags')).postTags.map((each) => each.name).sort(), ['math', 'news']);
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
test('through relationships in has(), withCount() and related()', async () => {
|
|
659
|
+
await unit(async () => {
|
|
660
|
+
const { ada, grace } = await seed();
|
|
661
|
+
const names = async (query) => (await query.get()).map((user) => user.name);
|
|
662
|
+
assert.deepEqual(await names(User.query().has('postComments')), ['Ada']);
|
|
663
|
+
assert.deepEqual(await names(User.query()
|
|
664
|
+
.whereHas('postTags', (tags) => tags.where('name', 'news'))
|
|
665
|
+
.orderBy('id')), ['Ada', 'Grace']);
|
|
666
|
+
assert.deepEqual(await names(User.query().has('approvedPostComments')), ['Ada']);
|
|
667
|
+
assert.deepEqual(await names(User.query().has('popularPostComments')), []);
|
|
668
|
+
assert.deepEqual((await User.query().withCount('postComments', 'postTags').orderBy('id').get()).map((user) => [
|
|
669
|
+
user.postCommentsCount,
|
|
670
|
+
user.postTagsCount,
|
|
671
|
+
]), [
|
|
672
|
+
[2, 2],
|
|
673
|
+
[0, 1],
|
|
674
|
+
[0, 0],
|
|
675
|
+
]);
|
|
676
|
+
assert.deepEqual((await Tag.query().withCount('commenters').orderBy('name').get()).map((tag) => [tag.name, tag.commentersCount]), [
|
|
677
|
+
['math', 2],
|
|
678
|
+
['news', 2],
|
|
679
|
+
]);
|
|
680
|
+
assert.equal(await Comment.query().has('author').count(), 2);
|
|
681
|
+
assert.deepEqual(await ada.related('postComments').orderBy('id').pluck('body'), ['Nice', 'Thanks']);
|
|
682
|
+
assert.equal(await ada.related('postComments').where('approved', true).count(), 1);
|
|
683
|
+
const [comment] = await Comment.query().orderBy('id').get();
|
|
684
|
+
assert.equal((await comment.related('author').first())?.name, 'Ada');
|
|
685
|
+
await grace.update({ mentorId: ada.id });
|
|
686
|
+
assert.deepEqual(await names(User.query().has('menteePosts')), ['Ada']);
|
|
687
|
+
assert.deepEqual((await User.query().withCount('menteePosts').orderBy('id').get()).map((user) => user.menteePostsCount), [1, 0, 0]);
|
|
688
|
+
await assert.rejects(untyped(ada.related('postComments')).create({ body: 'x' }), {
|
|
689
|
+
message: "user.related('postComments').create() is for hasMany and hasOne relationships, and User.postComments is a hasManyThrough.",
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
test("fromRoute() through related() finds only the row's own related rows: another's is a 404", async () => {
|
|
694
|
+
await unit(async () => {
|
|
695
|
+
const { ada, grace, first, third, math } = await seed();
|
|
696
|
+
const routed = (params) => ({ params });
|
|
697
|
+
assert.equal((await ada.related('posts').fromRoute(routed({ post: String(first.id) }), 'post')).title, 'First');
|
|
698
|
+
await assert.rejects(ada.related('posts').fromRoute(routed({ post: String(third.id) }), 'post'), {
|
|
699
|
+
code: 'E_MODEL_NOT_FOUND',
|
|
700
|
+
status: 404,
|
|
701
|
+
});
|
|
702
|
+
assert.equal((await grace.related('posts').fromRoute(routed({ post: String(third.id) }), 'post')).title, 'Third');
|
|
703
|
+
// Through a pivot table, and through a path of relationships.
|
|
704
|
+
assert.equal((await first.related('tags').fromRoute(routed({ tag: String(math.id) }), 'tag')).name, 'math');
|
|
705
|
+
await assert.rejects(third.related('tags').fromRoute(routed({ tag: String(math.id) }), 'tag'), { status: 404 });
|
|
706
|
+
const [comment] = await first.related('comments').get();
|
|
707
|
+
const id = String(comment?.id);
|
|
708
|
+
assert.equal((await ada.related('postComments').fromRoute(routed({ comment: id }), 'comment')).id, comment?.id);
|
|
709
|
+
await assert.rejects(grace.related('postComments').fromRoute(routed({ comment: id }), 'comment'), { status: 404 });
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
test('a through relationship’s path is checked', async () => {
|
|
713
|
+
await unit(async () => {
|
|
714
|
+
class Odd extends Model('rel_users', { id: column.id(), mentorId: column.foreignId().nullable(), name: column.string() }) {
|
|
715
|
+
relations() {
|
|
716
|
+
return {
|
|
717
|
+
posts: hasMany(() => Post, { foreignKey: 'userId' }),
|
|
718
|
+
short: hasManyThrough(() => Post, 'posts'),
|
|
719
|
+
unknown: hasManyThrough(() => Comment, 'posts.remarks'),
|
|
720
|
+
elsewhere: hasManyThrough(() => Comment, 'posts.user'),
|
|
721
|
+
nested: hasManyThrough(() => User, 'posts.comments.author'),
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
assert.deepEqual(checkModels([{ model: Odd, source: 'test' }]), [
|
|
726
|
+
'Odd.short follows "posts". A through relationship follows two or three relationships the model declares: hasManyThrough(() => Post, \'environments.deployments\').',
|
|
727
|
+
'Odd.unknown follows "posts.remarks", and Post has no relationship "remarks".',
|
|
728
|
+
'Odd.elsewhere follows "posts.user", which reaches User, and it is declared to reach Comment.',
|
|
729
|
+
'Odd.nested follows "posts.comments.author", and Comment.author is itself a through relationship. Follow the relationships it follows.',
|
|
730
|
+
]);
|
|
731
|
+
assert.throws(() => Odd.query().has('short'), ModelDefinitionError);
|
|
732
|
+
assert.deepEqual(describeModel(User).relations.find((relation) => relation.name === 'postComments'), { name: 'postComments', kind: 'hasManyThrough', related: 'Comment', keys: 'through posts.comments' });
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
//# sourceMappingURL=relationships.js.map
|