@budibase/backend-core 2.9.38 → 2.9.39-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/dist/index.js +3027 -3025
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +5 -5
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/accounts/accounts.js +100 -0
- package/dist/src/accounts/accounts.js.map +7 -0
- package/dist/src/accounts/api.js +78 -0
- package/dist/src/accounts/api.js.map +7 -0
- package/dist/src/accounts/index.js +23 -0
- package/dist/src/accounts/index.js.map +7 -0
- package/dist/src/auth/auth.js +208 -0
- package/dist/src/auth/auth.js.map +7 -0
- package/dist/src/auth/index.js +23 -0
- package/dist/src/auth/index.js.map +7 -0
- package/dist/src/auth/tests/auth.spec.js +37 -0
- package/dist/src/auth/tests/auth.spec.js.map +7 -0
- package/dist/src/blacklist/blacklist.js +88 -0
- package/dist/src/blacklist/blacklist.js.map +7 -0
- package/dist/src/blacklist/index.js +23 -0
- package/dist/src/blacklist/index.js.map +7 -0
- package/dist/src/blacklist/tests/blacklist.spec.js +61 -0
- package/dist/src/blacklist/tests/blacklist.spec.js.map +7 -0
- package/dist/src/cache/appMetadata.js +86 -0
- package/dist/src/cache/appMetadata.js.map +7 -0
- package/dist/src/cache/base/index.js +102 -0
- package/dist/src/cache/base/index.js.map +7 -0
- package/dist/src/cache/generic.js +69 -0
- package/dist/src/cache/generic.js.map +7 -0
- package/dist/src/cache/index.js +51 -0
- package/dist/src/cache/index.js.map +7 -0
- package/dist/src/cache/tests/writethrough.spec.js +132 -0
- package/dist/src/cache/tests/writethrough.spec.js.map +7 -0
- package/dist/src/cache/user.js +99 -0
- package/dist/src/cache/user.js.map +7 -0
- package/dist/src/cache/writethrough.js +144 -0
- package/dist/src/cache/writethrough.js.map +7 -0
- package/dist/src/configs/configs.js +228 -0
- package/dist/src/configs/configs.js.map +7 -0
- package/dist/src/configs/index.js +23 -0
- package/dist/src/configs/index.js.map +7 -0
- package/dist/src/configs/tests/configs.spec.js +182 -0
- package/dist/src/configs/tests/configs.spec.js.map +7 -0
- package/dist/src/constants/db.js +107 -0
- package/dist/src/constants/db.js.map +7 -0
- package/dist/src/constants/index.js +25 -0
- package/dist/src/constants/index.js.map +7 -0
- package/dist/src/constants/misc.js +92 -0
- package/dist/src/constants/misc.js.map +7 -0
- package/dist/src/context/Context.js +36 -0
- package/dist/src/context/Context.js.map +7 -0
- package/dist/src/context/identity.js +87 -0
- package/dist/src/context/identity.js.map +7 -0
- package/dist/src/context/index.js +45 -0
- package/dist/src/context/index.js.map +7 -0
- package/dist/src/context/mainContext.js +320 -0
- package/dist/src/context/mainContext.js.map +7 -0
- package/dist/src/context/tests/index.spec.js +147 -0
- package/dist/src/context/tests/index.spec.js.map +7 -0
- package/dist/src/context/types.js +17 -0
- package/dist/src/context/types.js.map +7 -0
- package/dist/src/db/Replication.js +89 -0
- package/dist/src/db/Replication.js.map +7 -0
- package/dist/src/db/constants.js +39 -0
- package/dist/src/db/constants.js.map +7 -0
- package/dist/src/db/couch/DatabaseImpl.js +224 -0
- package/dist/src/db/couch/DatabaseImpl.js.map +7 -0
- package/dist/src/db/couch/connections.js +103 -0
- package/dist/src/db/couch/connections.js.map +7 -0
- package/dist/src/db/couch/index.js +44 -0
- package/dist/src/db/couch/index.js.map +7 -0
- package/dist/src/db/couch/pouchDB.js +118 -0
- package/dist/src/db/couch/pouchDB.js.map +7 -0
- package/dist/src/db/couch/pouchDump.js +2 -0
- package/dist/src/db/couch/pouchDump.js.map +7 -0
- package/dist/src/db/couch/utils.js +76 -0
- package/dist/src/db/couch/utils.js.map +7 -0
- package/dist/src/db/db.d.ts +1 -1
- package/dist/src/db/db.js +73 -0
- package/dist/src/db/db.js.map +7 -0
- package/dist/src/db/errors.js +43 -0
- package/dist/src/db/errors.js.map +7 -0
- package/dist/src/db/index.js +64 -0
- package/dist/src/db/index.js.map +7 -0
- package/dist/src/db/lucene.d.ts +2 -1
- package/dist/src/db/lucene.js +595 -0
- package/dist/src/db/lucene.js.map +7 -0
- package/dist/src/db/searchIndexes/index.js +23 -0
- package/dist/src/db/searchIndexes/index.js.map +7 -0
- package/dist/src/db/searchIndexes/searchIndexes.js +82 -0
- package/dist/src/db/searchIndexes/searchIndexes.js.map +7 -0
- package/dist/src/db/tests/index.spec.js +24 -0
- package/dist/src/db/tests/index.spec.js.map +7 -0
- package/dist/src/db/tests/lucene.spec.js +312 -0
- package/dist/src/db/tests/lucene.spec.js.map +7 -0
- package/dist/src/db/tests/pouch.spec.js +63 -0
- package/dist/src/db/tests/pouch.spec.js.map +7 -0
- package/dist/src/db/tests/utils.spec.js +50 -0
- package/dist/src/db/tests/utils.spec.js.map +7 -0
- package/dist/src/db/utils.d.ts +1 -1
- package/dist/src/db/utils.js +198 -0
- package/dist/src/db/utils.js.map +7 -0
- package/dist/src/db/views.js +223 -0
- package/dist/src/db/views.js.map +7 -0
- package/dist/src/docIds/conversions.js +83 -0
- package/dist/src/docIds/conversions.js.map +7 -0
- package/dist/src/docIds/ids.js +101 -0
- package/dist/src/docIds/ids.js.map +7 -0
- package/dist/src/docIds/index.js +25 -0
- package/dist/src/docIds/index.js.map +7 -0
- package/dist/src/docIds/newid.js +32 -0
- package/dist/src/docIds/newid.js.map +7 -0
- package/dist/src/docIds/params.js +136 -0
- package/dist/src/docIds/params.js.map +7 -0
- package/dist/src/docUpdates/index.js +61 -0
- package/dist/src/docUpdates/index.js.map +7 -0
- package/dist/src/environment.js +181 -0
- package/dist/src/environment.js.map +7 -0
- package/dist/src/errors/errors.js +126 -0
- package/dist/src/errors/errors.js.map +7 -0
- package/dist/src/errors/index.js +23 -0
- package/dist/src/errors/index.js.map +7 -0
- package/dist/src/events/analytics.js +42 -0
- package/dist/src/events/analytics.js.map +7 -0
- package/dist/src/events/asyncEvents/index.js +25 -0
- package/dist/src/events/asyncEvents/index.js.map +7 -0
- package/dist/src/events/asyncEvents/publisher.js +39 -0
- package/dist/src/events/asyncEvents/publisher.js.map +7 -0
- package/dist/src/events/asyncEvents/queue.js +42 -0
- package/dist/src/events/asyncEvents/queue.js.map +7 -0
- package/dist/src/events/backfill.js +172 -0
- package/dist/src/events/backfill.js.map +7 -0
- package/dist/src/events/documentId.js +51 -0
- package/dist/src/events/documentId.js.map +7 -0
- package/dist/src/events/events.js +63 -0
- package/dist/src/events/events.js.map +7 -0
- package/dist/src/events/identification.js +275 -0
- package/dist/src/events/identification.js.map +7 -0
- package/dist/src/events/index.js +62 -0
- package/dist/src/events/index.js.map +7 -0
- package/dist/src/events/processors/AnalyticsProcessor.js +76 -0
- package/dist/src/events/processors/AnalyticsProcessor.js.map +7 -0
- package/dist/src/events/processors/AuditLogsProcessor.js +97 -0
- package/dist/src/events/processors/AuditLogsProcessor.js.map +7 -0
- package/dist/src/events/processors/LoggingProcessor.js +58 -0
- package/dist/src/events/processors/LoggingProcessor.js.map +7 -0
- package/dist/src/events/processors/Processors.js +57 -0
- package/dist/src/events/processors/Processors.js.map +7 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js +53 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js.map +7 -0
- package/dist/src/events/processors/index.js +57 -0
- package/dist/src/events/processors/index.js.map +7 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js +126 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +7 -0
- package/dist/src/events/processors/posthog/index.js +36 -0
- package/dist/src/events/processors/posthog/index.js.map +7 -0
- package/dist/src/events/processors/posthog/rateLimiting.js +105 -0
- package/dist/src/events/processors/posthog/rateLimiting.js.map +7 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js +154 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js.map +7 -0
- package/dist/src/events/processors/types.js +29 -0
- package/dist/src/events/processors/types.js.map +7 -0
- package/dist/src/events/publishers/account.js +49 -0
- package/dist/src/events/publishers/account.js.map +7 -0
- package/dist/src/events/publishers/app.js +145 -0
- package/dist/src/events/publishers/app.js.map +7 -0
- package/dist/src/events/publishers/auditLog.js +42 -0
- package/dist/src/events/publishers/auditLog.js.map +7 -0
- package/dist/src/events/publishers/auth.js +80 -0
- package/dist/src/events/publishers/auth.js.map +7 -0
- package/dist/src/events/publishers/automation.js +111 -0
- package/dist/src/events/publishers/automation.js.map +7 -0
- package/dist/src/events/publishers/backfill.js +92 -0
- package/dist/src/events/publishers/backfill.js.map +7 -0
- package/dist/src/events/publishers/backup.js +49 -0
- package/dist/src/events/publishers/backup.js.map +7 -0
- package/dist/src/events/publishers/datasource.js +59 -0
- package/dist/src/events/publishers/datasource.js.map +7 -0
- package/dist/src/events/publishers/email.js +38 -0
- package/dist/src/events/publishers/email.js.map +7 -0
- package/dist/src/events/publishers/environmentVariable.js +53 -0
- package/dist/src/events/publishers/environmentVariable.js.map +7 -0
- package/dist/src/events/publishers/group.js +105 -0
- package/dist/src/events/publishers/group.js.map +7 -0
- package/dist/src/events/publishers/index.js +108 -0
- package/dist/src/events/publishers/index.js.map +7 -0
- package/dist/src/events/publishers/installation.js +56 -0
- package/dist/src/events/publishers/installation.js.map +7 -0
- package/dist/src/events/publishers/layout.js +42 -0
- package/dist/src/events/publishers/layout.js.map +7 -0
- package/dist/src/events/publishers/license.js +78 -0
- package/dist/src/events/publishers/license.js.map +7 -0
- package/dist/src/events/publishers/org.js +53 -0
- package/dist/src/events/publishers/org.js.map +7 -0
- package/dist/src/events/publishers/plugin.js +61 -0
- package/dist/src/events/publishers/plugin.js.map +7 -0
- package/dist/src/events/publishers/query.js +85 -0
- package/dist/src/events/publishers/query.js.map +7 -0
- package/dist/src/events/publishers/role.js +71 -0
- package/dist/src/events/publishers/role.js.map +7 -0
- package/dist/src/events/publishers/rows.js +43 -0
- package/dist/src/events/publishers/rows.js.map +7 -0
- package/dist/src/events/publishers/screen.js +52 -0
- package/dist/src/events/publishers/screen.js.map +7 -0
- package/dist/src/events/publishers/serve.js +53 -0
- package/dist/src/events/publishers/serve.js.map +7 -0
- package/dist/src/events/publishers/table.js +79 -0
- package/dist/src/events/publishers/table.js.map +7 -0
- package/dist/src/events/publishers/user.js +191 -0
- package/dist/src/events/publishers/user.js.map +7 -0
- package/dist/src/events/publishers/view.js +102 -0
- package/dist/src/events/publishers/view.js.map +7 -0
- package/dist/src/{featureFlags → features}/index.d.ts +1 -0
- package/dist/src/features/index.js +105 -0
- package/dist/src/features/index.js.map +7 -0
- package/dist/src/features/installation.d.ts +1 -0
- package/dist/src/features/installation.js +42 -0
- package/dist/src/features/installation.js.map +7 -0
- package/dist/src/features/tests/featureFlags.spec.js +86 -0
- package/dist/src/features/tests/featureFlags.spec.js.map +7 -0
- package/dist/src/helpers.js +31 -0
- package/dist/src/helpers.js.map +7 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +154 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/installation.js +139 -0
- package/dist/src/installation.js.map +7 -0
- package/dist/src/logging/alerts.js +49 -0
- package/dist/src/logging/alerts.js.map +7 -0
- package/dist/src/logging/correlation/correlation.js +41 -0
- package/dist/src/logging/correlation/correlation.js.map +7 -0
- package/dist/src/logging/correlation/index.js +23 -0
- package/dist/src/logging/correlation/index.js.map +7 -0
- package/dist/src/logging/correlation/middleware.js +37 -0
- package/dist/src/logging/correlation/middleware.js.map +7 -0
- package/dist/src/logging/index.js +48 -0
- package/dist/src/logging/index.js.map +7 -0
- package/dist/src/logging/pino/logger.js +197 -0
- package/dist/src/logging/pino/logger.js.map +7 -0
- package/dist/src/logging/pino/middleware.js +77 -0
- package/dist/src/logging/pino/middleware.js.map +7 -0
- package/dist/src/logging/system.js +110 -0
- package/dist/src/logging/system.js.map +7 -0
- package/dist/src/logging/tests/system.spec.js +59 -0
- package/dist/src/logging/tests/system.spec.js.map +7 -0
- package/dist/src/middleware/adminOnly.js +31 -0
- package/dist/src/middleware/adminOnly.js.map +7 -0
- package/dist/src/middleware/auditLog.js +27 -0
- package/dist/src/middleware/auditLog.js.map +7 -0
- package/dist/src/middleware/authenticated.js +178 -0
- package/dist/src/middleware/authenticated.js.map +7 -0
- package/dist/src/middleware/builderOnly.js +48 -0
- package/dist/src/middleware/builderOnly.js.map +7 -0
- package/dist/src/middleware/builderOrAdmin.js +48 -0
- package/dist/src/middleware/builderOrAdmin.js.map +7 -0
- package/dist/src/middleware/csrf.js +60 -0
- package/dist/src/middleware/csrf.js.map +7 -0
- package/dist/src/middleware/errorHandling.js +62 -0
- package/dist/src/middleware/errorHandling.js.map +7 -0
- package/dist/src/middleware/index.js +95 -0
- package/dist/src/middleware/index.js.map +7 -0
- package/dist/src/middleware/internalApi.js +39 -0
- package/dist/src/middleware/internalApi.js.map +7 -0
- package/dist/src/middleware/joi-validator.js +73 -0
- package/dist/src/middleware/joi-validator.js.map +7 -0
- package/dist/src/middleware/matchers.js +62 -0
- package/dist/src/middleware/matchers.js.map +7 -0
- package/dist/src/middleware/passport/datasource/google.js +103 -0
- package/dist/src/middleware/passport/datasource/google.js.map +7 -0
- package/dist/src/middleware/passport/local.js +73 -0
- package/dist/src/middleware/passport/local.js.map +7 -0
- package/dist/src/middleware/passport/sso/google.js +93 -0
- package/dist/src/middleware/passport/sso/google.js.map +7 -0
- package/dist/src/middleware/passport/sso/oidc.js +135 -0
- package/dist/src/middleware/passport/sso/oidc.js.map +7 -0
- package/dist/src/middleware/passport/sso/sso.js +149 -0
- package/dist/src/middleware/passport/sso/sso.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js +77 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js +143 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js +167 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js.map +7 -0
- package/dist/src/middleware/passport/utils.js +62 -0
- package/dist/src/middleware/passport/utils.js.map +7 -0
- package/dist/src/middleware/querystringToBody.js +45 -0
- package/dist/src/middleware/querystringToBody.js.map +7 -0
- package/dist/src/middleware/tenancy.js +46 -0
- package/dist/src/middleware/tenancy.js.map +7 -0
- package/dist/src/middleware/tests/builder.spec.js +169 -0
- package/dist/src/middleware/tests/builder.spec.js.map +7 -0
- package/dist/src/middleware/tests/matchers.spec.js +120 -0
- package/dist/src/middleware/tests/matchers.spec.js.map +7 -0
- package/dist/src/migrations/definitions.js +63 -0
- package/dist/src/migrations/definitions.js.map +7 -0
- package/dist/src/migrations/index.js +25 -0
- package/dist/src/migrations/index.js.map +7 -0
- package/dist/src/migrations/migrations.js +178 -0
- package/dist/src/migrations/migrations.js.map +7 -0
- package/dist/src/migrations/tests/migrations.spec.js +78 -0
- package/dist/src/migrations/tests/migrations.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/app.js +65 -0
- package/dist/src/objectStore/buckets/app.js.map +7 -0
- package/dist/src/objectStore/buckets/global.js +63 -0
- package/dist/src/objectStore/buckets/global.js.map +7 -0
- package/dist/src/objectStore/buckets/index.js +27 -0
- package/dist/src/objectStore/buckets/index.js.map +7 -0
- package/dist/src/objectStore/buckets/plugins.js +101 -0
- package/dist/src/objectStore/buckets/plugins.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js +171 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js +87 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js +123 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js.map +7 -0
- package/dist/src/objectStore/cloudfront.js +74 -0
- package/dist/src/objectStore/cloudfront.js.map +7 -0
- package/dist/src/objectStore/index.js +27 -0
- package/dist/src/objectStore/index.js.map +7 -0
- package/dist/src/objectStore/objectStore.js +372 -0
- package/dist/src/objectStore/objectStore.js.map +7 -0
- package/dist/src/objectStore/utils.js +58 -0
- package/dist/src/objectStore/utils.js.map +7 -0
- package/dist/src/platform/index.js +45 -0
- package/dist/src/platform/index.js.map +7 -0
- package/dist/src/platform/platformDb.js +33 -0
- package/dist/src/platform/platformDb.js.map +7 -0
- package/dist/src/platform/tenants.js +123 -0
- package/dist/src/platform/tenants.js.map +7 -0
- package/dist/src/platform/tests/tenants.spec.js +46 -0
- package/dist/src/platform/tests/tenants.spec.js.map +7 -0
- package/dist/src/platform/users.js +104 -0
- package/dist/src/platform/users.js.map +7 -0
- package/dist/src/plugin/index.js +23 -0
- package/dist/src/plugin/index.js.map +7 -0
- package/dist/src/plugin/tests/validation.spec.js +97 -0
- package/dist/src/plugin/tests/validation.spec.js.map +7 -0
- package/dist/src/plugin/utils.js +153 -0
- package/dist/src/plugin/utils.js.map +7 -0
- package/dist/src/queue/constants.js +35 -0
- package/dist/src/queue/constants.js.map +7 -0
- package/dist/src/queue/inMemoryQueue.js +139 -0
- package/dist/src/queue/inMemoryQueue.js.map +7 -0
- package/dist/src/queue/index.js +25 -0
- package/dist/src/queue/index.js.map +7 -0
- package/dist/src/queue/listeners.js +177 -0
- package/dist/src/queue/listeners.js.map +7 -0
- package/dist/src/queue/queue.js +85 -0
- package/dist/src/queue/queue.js.map +7 -0
- package/dist/src/redis/index.js +48 -0
- package/dist/src/redis/index.js.map +7 -0
- package/dist/src/redis/init.js +128 -0
- package/dist/src/redis/init.js.map +7 -0
- package/dist/src/redis/redis.js +277 -0
- package/dist/src/redis/redis.js.map +7 -0
- package/dist/src/redis/redlockImpl.js +145 -0
- package/dist/src/redis/redlockImpl.js.map +7 -0
- package/dist/src/redis/utils.js +136 -0
- package/dist/src/redis/utils.js.map +7 -0
- package/dist/src/security/encryption.js +184 -0
- package/dist/src/security/encryption.js.map +7 -0
- package/dist/src/security/permissions.js +188 -0
- package/dist/src/security/permissions.js.map +7 -0
- package/dist/src/security/roles.d.ts +1 -12
- package/dist/src/security/roles.js +337 -0
- package/dist/src/security/roles.js.map +7 -0
- package/dist/src/security/sessions.js +135 -0
- package/dist/src/security/sessions.js.map +7 -0
- package/dist/src/security/tests/encryption.spec.js +51 -0
- package/dist/src/security/tests/encryption.spec.js.map +7 -0
- package/dist/src/security/tests/permissions.spec.js +154 -0
- package/dist/src/security/tests/permissions.spec.js.map +7 -0
- package/dist/src/security/tests/sessions.spec.js +33 -0
- package/dist/src/security/tests/sessions.spec.js.map +7 -0
- package/dist/src/tenancy/db.js +33 -0
- package/dist/src/tenancy/db.js.map +7 -0
- package/dist/src/tenancy/index.js +25 -0
- package/dist/src/tenancy/index.js.map +7 -0
- package/dist/src/tenancy/tenancy.js +129 -0
- package/dist/src/tenancy/tenancy.js.map +7 -0
- package/dist/src/tenancy/tests/tenancy.spec.js +154 -0
- package/dist/src/tenancy/tests/tenancy.spec.js.map +7 -0
- package/dist/src/timers/index.js +23 -0
- package/dist/src/timers/index.js.map +7 -0
- package/dist/src/timers/timers.js +51 -0
- package/dist/src/timers/timers.js.map +7 -0
- package/dist/src/users/db.d.ts +9 -1
- package/dist/src/users/db.js +381 -0
- package/dist/src/users/db.js.map +7 -0
- package/dist/src/users/events.js +152 -0
- package/dist/src/users/events.js.map +7 -0
- package/dist/src/users/index.js +36 -0
- package/dist/src/users/index.js.map +7 -0
- package/dist/src/users/lookup.js +110 -0
- package/dist/src/users/lookup.js.map +7 -0
- package/dist/src/users/users.js +257 -0
- package/dist/src/users/users.js.map +7 -0
- package/dist/src/users/utils.js +95 -0
- package/dist/src/users/utils.js.map +7 -0
- package/dist/src/utils/hashing.js +53 -0
- package/dist/src/utils/hashing.js.map +7 -0
- package/dist/src/utils/index.js +27 -0
- package/dist/src/utils/index.js.map +7 -0
- package/dist/src/utils/stringUtils.js +33 -0
- package/dist/src/utils/stringUtils.js.map +7 -0
- package/dist/src/utils/tests/utils.spec.js +165 -0
- package/dist/src/utils/tests/utils.spec.js.map +7 -0
- package/dist/src/utils/utils.js +207 -0
- package/dist/src/utils/utils.js.map +7 -0
- package/dist/tests/core/logging.js +57 -0
- package/dist/tests/core/logging.js.map +7 -0
- package/dist/tests/core/utilities/index.js +54 -0
- package/dist/tests/core/utilities/index.js.map +7 -0
- package/dist/tests/core/utilities/jestUtils.js +50 -0
- package/dist/tests/core/utilities/jestUtils.js.map +7 -0
- package/dist/tests/core/utilities/mocks/alerts.js +41 -0
- package/dist/tests/core/utilities/mocks/alerts.js.map +7 -0
- package/dist/tests/core/utilities/mocks/date.js +32 -0
- package/dist/tests/core/utilities/mocks/date.js.map +7 -0
- package/dist/tests/core/utilities/mocks/events.js +133 -0
- package/dist/tests/core/utilities/mocks/events.js.map +7 -0
- package/dist/tests/core/utilities/mocks/fetch.js +39 -0
- package/dist/tests/core/utilities/mocks/fetch.js.map +7 -0
- package/dist/tests/core/utilities/mocks/index.js +55 -0
- package/dist/tests/core/utilities/mocks/index.js.map +7 -0
- package/dist/tests/core/utilities/mocks/licenses.d.ts +2 -0
- package/dist/tests/core/utilities/mocks/licenses.js +145 -0
- package/dist/tests/core/utilities/mocks/licenses.js.map +7 -0
- package/dist/tests/core/utilities/mocks/posthog.js +9 -0
- package/dist/tests/core/utilities/mocks/posthog.js.map +7 -0
- package/dist/tests/core/utilities/structures/Chance.js +48 -0
- package/dist/tests/core/utilities/structures/Chance.js.map +7 -0
- package/dist/tests/core/utilities/structures/accounts.js +148 -0
- package/dist/tests/core/utilities/structures/accounts.js.map +7 -0
- package/dist/tests/core/utilities/structures/apps.js +47 -0
- package/dist/tests/core/utilities/structures/apps.js.map +7 -0
- package/dist/tests/core/utilities/structures/common.js +35 -0
- package/dist/tests/core/utilities/structures/common.js.map +7 -0
- package/dist/tests/core/utilities/structures/db.js +40 -0
- package/dist/tests/core/utilities/structures/db.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/index.js +23 -0
- package/dist/tests/core/utilities/structures/documents/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js +39 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js +48 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +7 -0
- package/dist/tests/core/utilities/structures/generator.js +40 -0
- package/dist/tests/core/utilities/structures/generator.js.map +7 -0
- package/dist/tests/core/utilities/structures/index.js +81 -0
- package/dist/tests/core/utilities/structures/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/koa.js +42 -0
- package/dist/tests/core/utilities/structures/koa.js.map +7 -0
- package/dist/tests/core/utilities/structures/licenses.js +175 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +7 -0
- package/dist/tests/core/utilities/structures/plugins.js +46 -0
- package/dist/tests/core/utilities/structures/plugins.js.map +7 -0
- package/dist/tests/core/utilities/structures/quotas.js +94 -0
- package/dist/tests/core/utilities/structures/quotas.js.map +7 -0
- package/dist/tests/core/utilities/structures/scim.js +90 -0
- package/dist/tests/core/utilities/structures/scim.js.map +7 -0
- package/dist/tests/core/utilities/structures/shared.js +46 -0
- package/dist/tests/core/utilities/structures/shared.js.map +7 -0
- package/dist/tests/core/utilities/structures/sso.js +144 -0
- package/dist/tests/core/utilities/structures/sso.js.map +7 -0
- package/dist/tests/core/utilities/structures/tenants.js +32 -0
- package/dist/tests/core/utilities/structures/tenants.js.map +7 -0
- package/dist/tests/core/utilities/structures/userGroups.js +36 -0
- package/dist/tests/core/utilities/structures/userGroups.js.map +7 -0
- package/dist/tests/core/utilities/structures/users.js +96 -0
- package/dist/tests/core/utilities/structures/users.js.map +7 -0
- package/dist/tests/core/utilities/testContainerUtils.js +100 -0
- package/dist/tests/core/utilities/testContainerUtils.js.map +7 -0
- package/dist/tests/core/utilities/utils/index.js +39 -0
- package/dist/tests/core/utilities/utils/index.js.map +7 -0
- package/dist/tests/core/utilities/utils/time.js +31 -0
- package/dist/tests/core/utilities/utils/time.js.map +7 -0
- package/dist/tests/extra/DBTestConfiguration.js +61 -0
- package/dist/tests/extra/DBTestConfiguration.js.map +7 -0
- package/dist/tests/extra/index.js +42 -0
- package/dist/tests/extra/index.js.map +7 -0
- package/dist/tests/extra/testEnv.js +106 -0
- package/dist/tests/extra/testEnv.js.map +7 -0
- package/dist/tests/index.js +23 -0
- package/dist/tests/index.js.map +7 -0
- package/dist/tests/jestEnv.js +8 -0
- package/dist/tests/jestEnv.js.map +7 -0
- package/dist/tests/jestSetup.js +41 -0
- package/dist/tests/jestSetup.js.map +7 -0
- package/package.json +5 -5
- package/dist/tests.js +0 -8476
- package/dist/tests.js.map +0 -7
- package/dist/tests.js.meta.json +0 -1
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var lucene_exports = {};
|
|
30
|
+
__export(lucene_exports, {
|
|
31
|
+
QueryBuilder: () => QueryBuilder,
|
|
32
|
+
fullSearch: () => fullSearch,
|
|
33
|
+
paginatedSearch: () => paginatedSearch,
|
|
34
|
+
removeKeyNumbering: () => removeKeyNumbering
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(lucene_exports);
|
|
37
|
+
var import_node_fetch = __toESM(require("node-fetch"));
|
|
38
|
+
var import_couch = require("./couch");
|
|
39
|
+
var import_types = require("@budibase/types");
|
|
40
|
+
const QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
41
|
+
function removeKeyNumbering(key) {
|
|
42
|
+
if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
|
|
43
|
+
const parts = key.split(":");
|
|
44
|
+
parts.shift();
|
|
45
|
+
return parts.join(":");
|
|
46
|
+
} else {
|
|
47
|
+
return key;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class QueryBuilder {
|
|
51
|
+
#dbName;
|
|
52
|
+
#index;
|
|
53
|
+
#query;
|
|
54
|
+
#limit;
|
|
55
|
+
#sort;
|
|
56
|
+
#bookmark;
|
|
57
|
+
#sortOrder;
|
|
58
|
+
#sortType;
|
|
59
|
+
#includeDocs;
|
|
60
|
+
#version;
|
|
61
|
+
#indexBuilder;
|
|
62
|
+
#noEscaping = false;
|
|
63
|
+
#skip;
|
|
64
|
+
static {
|
|
65
|
+
this.maxLimit = 200;
|
|
66
|
+
}
|
|
67
|
+
constructor(dbName, index, base) {
|
|
68
|
+
this.#dbName = dbName;
|
|
69
|
+
this.#index = index;
|
|
70
|
+
this.#query = {
|
|
71
|
+
allOr: false,
|
|
72
|
+
onEmptyFilter: import_types.EmptyFilterOption.RETURN_ALL,
|
|
73
|
+
string: {},
|
|
74
|
+
fuzzy: {},
|
|
75
|
+
range: {},
|
|
76
|
+
equal: {},
|
|
77
|
+
notEqual: {},
|
|
78
|
+
empty: {},
|
|
79
|
+
notEmpty: {},
|
|
80
|
+
oneOf: {},
|
|
81
|
+
contains: {},
|
|
82
|
+
notContains: {},
|
|
83
|
+
containsAny: {},
|
|
84
|
+
...base
|
|
85
|
+
};
|
|
86
|
+
this.#limit = 50;
|
|
87
|
+
this.#sortOrder = "ascending";
|
|
88
|
+
this.#sortType = "string";
|
|
89
|
+
this.#includeDocs = true;
|
|
90
|
+
}
|
|
91
|
+
disableEscaping() {
|
|
92
|
+
this.#noEscaping = true;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
setIndexBuilder(builderFn) {
|
|
96
|
+
this.#indexBuilder = builderFn;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
setVersion(version) {
|
|
100
|
+
if (version != null) {
|
|
101
|
+
this.#version = version;
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
setTable(tableId) {
|
|
106
|
+
this.#query.equal.tableId = tableId;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
setLimit(limit) {
|
|
110
|
+
if (limit != null) {
|
|
111
|
+
this.#limit = limit;
|
|
112
|
+
}
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
setSort(sort) {
|
|
116
|
+
if (sort != null) {
|
|
117
|
+
this.#sort = sort;
|
|
118
|
+
}
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
setSortOrder(sortOrder) {
|
|
122
|
+
if (sortOrder != null) {
|
|
123
|
+
this.#sortOrder = sortOrder;
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
setSortType(sortType) {
|
|
128
|
+
if (sortType != null) {
|
|
129
|
+
this.#sortType = sortType;
|
|
130
|
+
}
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
setBookmark(bookmark) {
|
|
134
|
+
if (bookmark != null) {
|
|
135
|
+
this.#bookmark = bookmark;
|
|
136
|
+
}
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
setSkip(skip) {
|
|
140
|
+
this.#skip = skip;
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
excludeDocs() {
|
|
144
|
+
this.#includeDocs = false;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
includeDocs() {
|
|
148
|
+
this.#includeDocs = true;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
addString(key, partial) {
|
|
152
|
+
this.#query.string[key] = partial;
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
addFuzzy(key, fuzzy) {
|
|
156
|
+
this.#query.fuzzy[key] = fuzzy;
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
addRange(key, low, high) {
|
|
160
|
+
this.#query.range[key] = {
|
|
161
|
+
low,
|
|
162
|
+
high
|
|
163
|
+
};
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
addEqual(key, value) {
|
|
167
|
+
this.#query.equal[key] = value;
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
addNotEqual(key, value) {
|
|
171
|
+
this.#query.notEqual[key] = value;
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
addEmpty(key, value) {
|
|
175
|
+
this.#query.empty[key] = value;
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
addNotEmpty(key, value) {
|
|
179
|
+
this.#query.notEmpty[key] = value;
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
addOneOf(key, value) {
|
|
183
|
+
this.#query.oneOf[key] = value;
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
addContains(key, value) {
|
|
187
|
+
this.#query.contains[key] = value;
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
addNotContains(key, value) {
|
|
191
|
+
this.#query.notContains[key] = value;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
addContainsAny(key, value) {
|
|
195
|
+
this.#query.containsAny[key] = value;
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
setAllOr() {
|
|
199
|
+
this.#query.allOr = true;
|
|
200
|
+
}
|
|
201
|
+
setOnEmptyFilter(value) {
|
|
202
|
+
this.#query.onEmptyFilter = value;
|
|
203
|
+
}
|
|
204
|
+
handleSpaces(input) {
|
|
205
|
+
if (this.#noEscaping) {
|
|
206
|
+
return input;
|
|
207
|
+
} else {
|
|
208
|
+
return input.replace(/ /g, "_");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Preprocesses a value before going into a lucene search.
|
|
213
|
+
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
|
214
|
+
* @param value The value to process
|
|
215
|
+
* @param options The preprocess options
|
|
216
|
+
* @returns {string|*}
|
|
217
|
+
*/
|
|
218
|
+
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
219
|
+
const hasVersion = !!this.#version;
|
|
220
|
+
const originalType = typeof value;
|
|
221
|
+
if (value && lowercase) {
|
|
222
|
+
value = value.toLowerCase ? value.toLowerCase() : value;
|
|
223
|
+
}
|
|
224
|
+
if (!this.#noEscaping && escape && originalType === "string") {
|
|
225
|
+
value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
|
|
226
|
+
}
|
|
227
|
+
if (originalType === "string" && !isNaN(value) && !type) {
|
|
228
|
+
value = `"${value}"`;
|
|
229
|
+
} else if (hasVersion && wrap) {
|
|
230
|
+
value = originalType === "number" ? value : `"${value}"`;
|
|
231
|
+
}
|
|
232
|
+
return value;
|
|
233
|
+
}
|
|
234
|
+
isMultiCondition() {
|
|
235
|
+
let count = 0;
|
|
236
|
+
for (let filters of Object.values(this.#query)) {
|
|
237
|
+
if (typeof filters === "object") {
|
|
238
|
+
count += Object.keys(filters).length;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return count > 1;
|
|
242
|
+
}
|
|
243
|
+
compressFilters(filters) {
|
|
244
|
+
const compressed = {};
|
|
245
|
+
for (let key of Object.keys(filters)) {
|
|
246
|
+
const finalKey = removeKeyNumbering(key);
|
|
247
|
+
if (compressed[finalKey]) {
|
|
248
|
+
compressed[finalKey] = compressed[finalKey].concat(filters[key]);
|
|
249
|
+
} else {
|
|
250
|
+
compressed[finalKey] = filters[key];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const final = {};
|
|
254
|
+
let count = 1;
|
|
255
|
+
for (let [key, value] of Object.entries(compressed)) {
|
|
256
|
+
final[`${count++}:${key}`] = value;
|
|
257
|
+
}
|
|
258
|
+
return final;
|
|
259
|
+
}
|
|
260
|
+
buildSearchQuery() {
|
|
261
|
+
const builder = this;
|
|
262
|
+
let allOr = this.#query && this.#query.allOr;
|
|
263
|
+
let query = allOr ? "" : "*:*";
|
|
264
|
+
let allFiltersEmpty = true;
|
|
265
|
+
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
266
|
+
let tableId = "";
|
|
267
|
+
if (this.#query.equal.tableId) {
|
|
268
|
+
tableId = this.#query.equal.tableId;
|
|
269
|
+
delete this.#query.equal.tableId;
|
|
270
|
+
}
|
|
271
|
+
const equal = (key, value) => {
|
|
272
|
+
if (!value && value !== 0) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
276
|
+
};
|
|
277
|
+
const contains = (key, value, mode = "AND") => {
|
|
278
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
if (!Array.isArray(value)) {
|
|
282
|
+
return `${key}:${value}`;
|
|
283
|
+
}
|
|
284
|
+
let statement = `${builder.preprocess(value[0], { escape: true })}`;
|
|
285
|
+
for (let i = 1; i < value.length; i++) {
|
|
286
|
+
statement += ` ${mode} ${builder.preprocess(value[i], {
|
|
287
|
+
escape: true
|
|
288
|
+
})}`;
|
|
289
|
+
}
|
|
290
|
+
return `${key}:(${statement})`;
|
|
291
|
+
};
|
|
292
|
+
const fuzzy = (key, value) => {
|
|
293
|
+
if (!value) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
value = builder.preprocess(value, {
|
|
297
|
+
escape: true,
|
|
298
|
+
lowercase: true,
|
|
299
|
+
type: "fuzzy"
|
|
300
|
+
});
|
|
301
|
+
return `${key}:/.*${value}.*/`;
|
|
302
|
+
};
|
|
303
|
+
const notContains = (key, value) => {
|
|
304
|
+
const allPrefix = allOr ? "*:* AND " : "";
|
|
305
|
+
const mode = allOr ? "AND" : void 0;
|
|
306
|
+
return allPrefix + "NOT " + contains(key, value, mode);
|
|
307
|
+
};
|
|
308
|
+
const containsAny = (key, value) => {
|
|
309
|
+
return contains(key, value, "OR");
|
|
310
|
+
};
|
|
311
|
+
const oneOf = (key, value) => {
|
|
312
|
+
if (!value) {
|
|
313
|
+
return `*:*`;
|
|
314
|
+
}
|
|
315
|
+
if (!Array.isArray(value)) {
|
|
316
|
+
if (typeof value === "string") {
|
|
317
|
+
value = value.split(",");
|
|
318
|
+
} else {
|
|
319
|
+
return "";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
let orStatement = `${builder.preprocess(value[0], allPreProcessingOpts)}`;
|
|
323
|
+
for (let i = 1; i < value.length; i++) {
|
|
324
|
+
orStatement += ` OR ${builder.preprocess(
|
|
325
|
+
value[i],
|
|
326
|
+
allPreProcessingOpts
|
|
327
|
+
)}`;
|
|
328
|
+
}
|
|
329
|
+
return `${key}:(${orStatement})`;
|
|
330
|
+
};
|
|
331
|
+
function build(structure, queryFn, opts) {
|
|
332
|
+
let built = "";
|
|
333
|
+
for (let [key, value] of Object.entries(structure)) {
|
|
334
|
+
key = removeKeyNumbering(key);
|
|
335
|
+
key = builder.preprocess(builder.handleSpaces(key), {
|
|
336
|
+
escape: true
|
|
337
|
+
});
|
|
338
|
+
let expression = queryFn(key, value);
|
|
339
|
+
if (expression == null) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (built.length > 0 || query.length > 0) {
|
|
343
|
+
const mode = opts?.mode ? opts.mode : allOr ? "OR" : "AND";
|
|
344
|
+
built += ` ${mode} `;
|
|
345
|
+
}
|
|
346
|
+
built += expression;
|
|
347
|
+
if (typeof value !== "string" && value != null || typeof value === "string" && value !== tableId && value !== "") {
|
|
348
|
+
allFiltersEmpty = false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (opts?.returnBuilt) {
|
|
352
|
+
return built;
|
|
353
|
+
} else {
|
|
354
|
+
query += built;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (this.#query.string) {
|
|
358
|
+
build(this.#query.string, (key, value) => {
|
|
359
|
+
if (!value) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
value = builder.preprocess(value, {
|
|
363
|
+
escape: true,
|
|
364
|
+
lowercase: true,
|
|
365
|
+
type: "string"
|
|
366
|
+
});
|
|
367
|
+
return `${key}:${value}*`;
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (this.#query.range) {
|
|
371
|
+
build(this.#query.range, (key, value) => {
|
|
372
|
+
if (!value) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
if (value.low == null || value.low === "") {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
if (value.high == null || value.high === "") {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
const low = builder.preprocess(value.low, allPreProcessingOpts);
|
|
382
|
+
const high = builder.preprocess(value.high, allPreProcessingOpts);
|
|
383
|
+
return `${key}:[${low} TO ${high}]`;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
if (this.#query.fuzzy) {
|
|
387
|
+
build(this.#query.fuzzy, fuzzy);
|
|
388
|
+
}
|
|
389
|
+
if (this.#query.equal) {
|
|
390
|
+
build(this.#query.equal, equal);
|
|
391
|
+
}
|
|
392
|
+
if (this.#query.notEqual) {
|
|
393
|
+
build(this.#query.notEqual, (key, value) => {
|
|
394
|
+
if (!value) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
if (typeof value === "boolean") {
|
|
398
|
+
return `(*:* AND !${key}:${value})`;
|
|
399
|
+
}
|
|
400
|
+
return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (this.#query.empty) {
|
|
404
|
+
build(this.#query.empty, (key) => `(*:* -${key}:["" TO *])`);
|
|
405
|
+
}
|
|
406
|
+
if (this.#query.notEmpty) {
|
|
407
|
+
build(this.#query.notEmpty, (key) => `${key}:["" TO *]`);
|
|
408
|
+
}
|
|
409
|
+
if (this.#query.oneOf) {
|
|
410
|
+
build(this.#query.oneOf, oneOf);
|
|
411
|
+
}
|
|
412
|
+
if (this.#query.contains) {
|
|
413
|
+
build(this.#query.contains, contains);
|
|
414
|
+
}
|
|
415
|
+
if (this.#query.notContains) {
|
|
416
|
+
build(this.compressFilters(this.#query.notContains), notContains);
|
|
417
|
+
}
|
|
418
|
+
if (this.#query.containsAny) {
|
|
419
|
+
build(this.#query.containsAny, containsAny);
|
|
420
|
+
}
|
|
421
|
+
if (tableId) {
|
|
422
|
+
query = this.isMultiCondition() ? `(${query})` : query;
|
|
423
|
+
allOr = false;
|
|
424
|
+
build({ tableId }, equal);
|
|
425
|
+
}
|
|
426
|
+
if (allFiltersEmpty) {
|
|
427
|
+
if (this.#query.onEmptyFilter === import_types.EmptyFilterOption.RETURN_NONE) {
|
|
428
|
+
return "";
|
|
429
|
+
} else if (this.#query?.allOr) {
|
|
430
|
+
return query.replace("()", "(*:*)");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return query;
|
|
434
|
+
}
|
|
435
|
+
buildSearchBody() {
|
|
436
|
+
let body = {
|
|
437
|
+
q: this.buildSearchQuery(),
|
|
438
|
+
limit: Math.min(this.#limit, QueryBuilder.maxLimit),
|
|
439
|
+
include_docs: this.#includeDocs
|
|
440
|
+
};
|
|
441
|
+
if (this.#bookmark) {
|
|
442
|
+
body.bookmark = this.#bookmark;
|
|
443
|
+
}
|
|
444
|
+
if (this.#sort) {
|
|
445
|
+
const order = this.#sortOrder === "descending" ? "-" : "";
|
|
446
|
+
const type = `<${this.#sortType}>`;
|
|
447
|
+
body.sort = `${order}${this.handleSpaces(this.#sort)}${type}`;
|
|
448
|
+
}
|
|
449
|
+
return body;
|
|
450
|
+
}
|
|
451
|
+
async run() {
|
|
452
|
+
if (this.#skip) {
|
|
453
|
+
await this.#skipItems(this.#skip);
|
|
454
|
+
}
|
|
455
|
+
return await this.#execute();
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Lucene queries do not support pagination and use bookmarks instead.
|
|
459
|
+
* For the given builder, walk through pages using bookmarks until the desired
|
|
460
|
+
* page has been met.
|
|
461
|
+
*/
|
|
462
|
+
async #skipItems(skip) {
|
|
463
|
+
const prevIncludeDocs = this.#includeDocs;
|
|
464
|
+
const prevLimit = this.#limit;
|
|
465
|
+
this.excludeDocs();
|
|
466
|
+
let skipRemaining = skip;
|
|
467
|
+
let iterationFetched = 0;
|
|
468
|
+
do {
|
|
469
|
+
const toSkip = Math.min(QueryBuilder.maxLimit, skipRemaining);
|
|
470
|
+
this.setLimit(toSkip);
|
|
471
|
+
const { bookmark, rows } = await this.#execute();
|
|
472
|
+
this.setBookmark(bookmark);
|
|
473
|
+
iterationFetched = rows.length;
|
|
474
|
+
skipRemaining -= rows.length;
|
|
475
|
+
} while (skipRemaining > 0 && iterationFetched > 0);
|
|
476
|
+
this.#includeDocs = prevIncludeDocs;
|
|
477
|
+
this.#limit = prevLimit;
|
|
478
|
+
}
|
|
479
|
+
async #execute() {
|
|
480
|
+
const { url, cookie } = (0, import_couch.getCouchInfo)();
|
|
481
|
+
const fullPath = `${url}/${this.#dbName}/_design/database/_search/${this.#index}`;
|
|
482
|
+
const body = this.buildSearchBody();
|
|
483
|
+
try {
|
|
484
|
+
return await runQuery(fullPath, body, cookie);
|
|
485
|
+
} catch (err) {
|
|
486
|
+
if (err.status === 404 && this.#indexBuilder) {
|
|
487
|
+
await this.#indexBuilder();
|
|
488
|
+
return await runQuery(fullPath, body, cookie);
|
|
489
|
+
} else {
|
|
490
|
+
throw err;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
async function runQuery(url, body, cookie) {
|
|
496
|
+
const response = await (0, import_node_fetch.default)(url, {
|
|
497
|
+
body: JSON.stringify(body),
|
|
498
|
+
method: "POST",
|
|
499
|
+
headers: {
|
|
500
|
+
Authorization: cookie
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
if (response.status === 404) {
|
|
504
|
+
throw response;
|
|
505
|
+
}
|
|
506
|
+
const json = await response.json();
|
|
507
|
+
let output = {
|
|
508
|
+
rows: [],
|
|
509
|
+
totalRows: 0
|
|
510
|
+
};
|
|
511
|
+
if (json.rows != null && json.rows.length > 0) {
|
|
512
|
+
output.rows = json.rows.map((row) => row.doc);
|
|
513
|
+
}
|
|
514
|
+
if (json.bookmark) {
|
|
515
|
+
output.bookmark = json.bookmark;
|
|
516
|
+
}
|
|
517
|
+
if (json.total_rows) {
|
|
518
|
+
output.totalRows = json.total_rows;
|
|
519
|
+
}
|
|
520
|
+
return output;
|
|
521
|
+
}
|
|
522
|
+
async function recursiveSearch(dbName, index, query, params) {
|
|
523
|
+
const bookmark = params.bookmark;
|
|
524
|
+
const rows = params.rows || [];
|
|
525
|
+
if (rows.length >= params.limit) {
|
|
526
|
+
return rows;
|
|
527
|
+
}
|
|
528
|
+
let pageSize = QueryBuilder.maxLimit;
|
|
529
|
+
if (rows.length > params.limit - QueryBuilder.maxLimit) {
|
|
530
|
+
pageSize = params.limit - rows.length;
|
|
531
|
+
}
|
|
532
|
+
const page = await new QueryBuilder(dbName, index, query).setVersion(params.version).setTable(params.tableId).setBookmark(bookmark).setLimit(pageSize).setSort(params.sort).setSortOrder(params.sortOrder).setSortType(params.sortType).run();
|
|
533
|
+
if (!page.rows.length) {
|
|
534
|
+
return rows;
|
|
535
|
+
}
|
|
536
|
+
if (page.rows.length < QueryBuilder.maxLimit) {
|
|
537
|
+
return [...rows, ...page.rows];
|
|
538
|
+
}
|
|
539
|
+
const newParams = {
|
|
540
|
+
...params,
|
|
541
|
+
bookmark: page.bookmark,
|
|
542
|
+
rows: [...rows, ...page.rows]
|
|
543
|
+
};
|
|
544
|
+
return await recursiveSearch(dbName, index, query, newParams);
|
|
545
|
+
}
|
|
546
|
+
async function paginatedSearch(dbName, index, query, params) {
|
|
547
|
+
let limit = params.limit;
|
|
548
|
+
if (limit == null || isNaN(limit) || limit < 0) {
|
|
549
|
+
limit = 50;
|
|
550
|
+
}
|
|
551
|
+
limit = Math.min(limit, QueryBuilder.maxLimit);
|
|
552
|
+
const search = new QueryBuilder(dbName, index, query);
|
|
553
|
+
if (params.version) {
|
|
554
|
+
search.setVersion(params.version);
|
|
555
|
+
}
|
|
556
|
+
if (params.tableId) {
|
|
557
|
+
search.setTable(params.tableId);
|
|
558
|
+
}
|
|
559
|
+
if (params.sort) {
|
|
560
|
+
search.setSort(params.sort).setSortOrder(params.sortOrder).setSortType(params.sortType);
|
|
561
|
+
}
|
|
562
|
+
if (params.indexer) {
|
|
563
|
+
search.setIndexBuilder(params.indexer);
|
|
564
|
+
}
|
|
565
|
+
if (params.disableEscaping) {
|
|
566
|
+
search.disableEscaping();
|
|
567
|
+
}
|
|
568
|
+
const searchResults = await search.setBookmark(params.bookmark).setLimit(limit).run();
|
|
569
|
+
search.setBookmark(searchResults.bookmark).setLimit(1);
|
|
570
|
+
if (params.tableId) {
|
|
571
|
+
search.setTable(params.tableId);
|
|
572
|
+
}
|
|
573
|
+
const nextResults = await search.run();
|
|
574
|
+
return {
|
|
575
|
+
...searchResults,
|
|
576
|
+
hasNextPage: nextResults.rows && nextResults.rows.length > 0
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
async function fullSearch(dbName, index, query, params) {
|
|
580
|
+
let limit = params.limit;
|
|
581
|
+
if (limit == null || isNaN(limit) || limit < 0) {
|
|
582
|
+
limit = 1e3;
|
|
583
|
+
}
|
|
584
|
+
params.limit = Math.min(limit, 1e3);
|
|
585
|
+
const rows = await recursiveSearch(dbName, index, query, params);
|
|
586
|
+
return { rows };
|
|
587
|
+
}
|
|
588
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
589
|
+
0 && (module.exports = {
|
|
590
|
+
QueryBuilder,
|
|
591
|
+
fullSearch,
|
|
592
|
+
paginatedSearch,
|
|
593
|
+
removeKeyNumbering
|
|
594
|
+
});
|
|
595
|
+
//# sourceMappingURL=lucene.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/db/lucene.ts"],
|
|
4
|
+
"sourcesContent": ["import fetch from \"node-fetch\"\nimport { getCouchInfo } from \"./couch\"\nimport { SearchFilters, Row, EmptyFilterOption } from \"@budibase/types\"\n\nconst QUERY_START_REGEX = /\\d[0-9]*:/g\n\ninterface SearchResponse<T> {\n rows: T[] | any[]\n bookmark?: string\n totalRows: number\n}\n\ninterface PaginatedSearchResponse<T> extends SearchResponse<T> {\n hasNextPage: boolean\n}\n\nexport type SearchParams<T> = {\n tableId?: string\n sort?: string\n sortOrder?: string\n sortType?: string\n limit?: number\n bookmark?: string\n version?: string\n indexer?: () => Promise<any>\n disableEscaping?: boolean\n rows?: T | Row[]\n}\n\nexport function removeKeyNumbering(key: any): string {\n if (typeof key === \"string\" && key.match(QUERY_START_REGEX) != null) {\n const parts = key.split(\":\")\n // remove the number\n parts.shift()\n return parts.join(\":\")\n } else {\n return key\n }\n}\n\n/**\n * Class to build lucene query URLs.\n * Optionally takes a base lucene query object.\n */\nexport class QueryBuilder<T> {\n #dbName: string\n #index: string\n #query: SearchFilters\n #limit: number\n #sort?: string\n #bookmark?: string\n #sortOrder: string\n #sortType: string\n #includeDocs: boolean\n #version?: string\n #indexBuilder?: () => Promise<any>\n #noEscaping = false\n #skip?: number\n\n static readonly maxLimit = 200\n\n constructor(dbName: string, index: string, base?: SearchFilters) {\n this.#dbName = dbName\n this.#index = index\n this.#query = {\n allOr: false,\n onEmptyFilter: EmptyFilterOption.RETURN_ALL,\n string: {},\n fuzzy: {},\n range: {},\n equal: {},\n notEqual: {},\n empty: {},\n notEmpty: {},\n oneOf: {},\n contains: {},\n notContains: {},\n containsAny: {},\n ...base,\n }\n this.#limit = 50\n this.#sortOrder = \"ascending\"\n this.#sortType = \"string\"\n this.#includeDocs = true\n }\n\n disableEscaping() {\n this.#noEscaping = true\n return this\n }\n\n setIndexBuilder(builderFn: () => Promise<any>) {\n this.#indexBuilder = builderFn\n return this\n }\n\n setVersion(version?: string) {\n if (version != null) {\n this.#version = version\n }\n return this\n }\n\n setTable(tableId: string) {\n this.#query.equal!.tableId = tableId\n return this\n }\n\n setLimit(limit?: number) {\n if (limit != null) {\n this.#limit = limit\n }\n return this\n }\n\n setSort(sort?: string) {\n if (sort != null) {\n this.#sort = sort\n }\n return this\n }\n\n setSortOrder(sortOrder?: string) {\n if (sortOrder != null) {\n this.#sortOrder = sortOrder\n }\n return this\n }\n\n setSortType(sortType?: string) {\n if (sortType != null) {\n this.#sortType = sortType\n }\n return this\n }\n\n setBookmark(bookmark?: string) {\n if (bookmark != null) {\n this.#bookmark = bookmark\n }\n return this\n }\n\n setSkip(skip: number | undefined) {\n this.#skip = skip\n return this\n }\n\n excludeDocs() {\n this.#includeDocs = false\n return this\n }\n\n includeDocs() {\n this.#includeDocs = true\n return this\n }\n\n addString(key: string, partial: string) {\n this.#query.string![key] = partial\n return this\n }\n\n addFuzzy(key: string, fuzzy: string) {\n this.#query.fuzzy![key] = fuzzy\n return this\n }\n\n addRange(key: string, low: string | number, high: string | number) {\n this.#query.range![key] = {\n low,\n high,\n }\n return this\n }\n\n addEqual(key: string, value: any) {\n this.#query.equal![key] = value\n return this\n }\n\n addNotEqual(key: string, value: any) {\n this.#query.notEqual![key] = value\n return this\n }\n\n addEmpty(key: string, value: any) {\n this.#query.empty![key] = value\n return this\n }\n\n addNotEmpty(key: string, value: any) {\n this.#query.notEmpty![key] = value\n return this\n }\n\n addOneOf(key: string, value: any) {\n this.#query.oneOf![key] = value\n return this\n }\n\n addContains(key: string, value: any) {\n this.#query.contains![key] = value\n return this\n }\n\n addNotContains(key: string, value: any) {\n this.#query.notContains![key] = value\n return this\n }\n\n addContainsAny(key: string, value: any) {\n this.#query.containsAny![key] = value\n return this\n }\n\n setAllOr() {\n this.#query.allOr = true\n }\n\n setOnEmptyFilter(value: EmptyFilterOption) {\n this.#query.onEmptyFilter = value\n }\n\n handleSpaces(input: string) {\n if (this.#noEscaping) {\n return input\n } else {\n return input.replace(/ /g, \"_\")\n }\n }\n\n /**\n * Preprocesses a value before going into a lucene search.\n * Transforms strings to lowercase and wraps strings and bools in quotes.\n * @param value The value to process\n * @param options The preprocess options\n * @returns {string|*}\n */\n preprocess(value: any, { escape, lowercase, wrap, type }: any = {}) {\n const hasVersion = !!this.#version\n // Determine if type needs wrapped\n const originalType = typeof value\n // Convert to lowercase\n if (value && lowercase) {\n value = value.toLowerCase ? value.toLowerCase() : value\n }\n // Escape characters\n if (!this.#noEscaping && escape && originalType === \"string\") {\n value = `${value}`.replace(/[ \\/#+\\-&|!(){}\\]^\"~*?:\\\\]/g, \"\\\\$&\")\n }\n\n // Wrap in quotes\n if (originalType === \"string\" && !isNaN(value) && !type) {\n value = `\"${value}\"`\n } else if (hasVersion && wrap) {\n value = originalType === \"number\" ? value : `\"${value}\"`\n }\n return value\n }\n\n isMultiCondition() {\n let count = 0\n for (let filters of Object.values(this.#query)) {\n // not contains is one massive filter in allOr mode\n if (typeof filters === \"object\") {\n count += Object.keys(filters).length\n }\n }\n return count > 1\n }\n\n compressFilters(filters: Record<string, string[]>) {\n const compressed: typeof filters = {}\n for (let key of Object.keys(filters)) {\n const finalKey = removeKeyNumbering(key)\n if (compressed[finalKey]) {\n compressed[finalKey] = compressed[finalKey].concat(filters[key])\n } else {\n compressed[finalKey] = filters[key]\n }\n }\n // add prefixes back\n const final: typeof filters = {}\n let count = 1\n for (let [key, value] of Object.entries(compressed)) {\n final[`${count++}:${key}`] = value\n }\n return final\n }\n\n buildSearchQuery() {\n const builder = this\n let allOr = this.#query && this.#query.allOr\n let query = allOr ? \"\" : \"*:*\"\n let allFiltersEmpty = true\n const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }\n let tableId: string = \"\"\n if (this.#query.equal!.tableId) {\n tableId = this.#query.equal!.tableId\n delete this.#query.equal!.tableId\n }\n\n const equal = (key: string, value: any) => {\n // 0 evaluates to false, which means we would return all rows if we don't check it\n if (!value && value !== 0) {\n return null\n }\n return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`\n }\n\n const contains = (key: string, value: any, mode = \"AND\") => {\n if (!value || (Array.isArray(value) && value.length === 0)) {\n return null\n }\n if (!Array.isArray(value)) {\n return `${key}:${value}`\n }\n let statement = `${builder.preprocess(value[0], { escape: true })}`\n for (let i = 1; i < value.length; i++) {\n statement += ` ${mode} ${builder.preprocess(value[i], {\n escape: true,\n })}`\n }\n return `${key}:(${statement})`\n }\n\n const fuzzy = (key: string, value: any) => {\n if (!value) {\n return null\n }\n value = builder.preprocess(value, {\n escape: true,\n lowercase: true,\n type: \"fuzzy\",\n })\n return `${key}:/.*${value}.*/`\n }\n\n const notContains = (key: string, value: any) => {\n const allPrefix = allOr ? \"*:* AND \" : \"\"\n const mode = allOr ? \"AND\" : undefined\n return allPrefix + \"NOT \" + contains(key, value, mode)\n }\n\n const containsAny = (key: string, value: any) => {\n return contains(key, value, \"OR\")\n }\n\n const oneOf = (key: string, value: any) => {\n if (!value) {\n return `*:*`\n }\n if (!Array.isArray(value)) {\n if (typeof value === \"string\") {\n value = value.split(\",\")\n } else {\n return \"\"\n }\n }\n let orStatement = `${builder.preprocess(value[0], allPreProcessingOpts)}`\n for (let i = 1; i < value.length; i++) {\n orStatement += ` OR ${builder.preprocess(\n value[i],\n allPreProcessingOpts\n )}`\n }\n return `${key}:(${orStatement})`\n }\n\n function build(\n structure: any,\n queryFn: (key: string, value: any) => string | null,\n opts?: { returnBuilt?: boolean; mode?: string }\n ) {\n let built = \"\"\n for (let [key, value] of Object.entries(structure)) {\n // check for new format - remove numbering if needed\n key = removeKeyNumbering(key)\n key = builder.preprocess(builder.handleSpaces(key), {\n escape: true,\n })\n let expression = queryFn(key, value)\n if (expression == null) {\n continue\n }\n if (built.length > 0 || query.length > 0) {\n const mode = opts?.mode ? opts.mode : allOr ? \"OR\" : \"AND\"\n built += ` ${mode} `\n }\n built += expression\n if (\n (typeof value !== \"string\" && value != null) ||\n (typeof value === \"string\" && value !== tableId && value !== \"\")\n ) {\n allFiltersEmpty = false\n }\n }\n if (opts?.returnBuilt) {\n return built\n } else {\n query += built\n }\n }\n\n // Construct the actual lucene search query string from JSON structure\n if (this.#query.string) {\n build(this.#query.string, (key: string, value: any) => {\n if (!value) {\n return null\n }\n value = builder.preprocess(value, {\n escape: true,\n lowercase: true,\n type: \"string\",\n })\n return `${key}:${value}*`\n })\n }\n if (this.#query.range) {\n build(this.#query.range, (key: string, value: any) => {\n if (!value) {\n return null\n }\n if (value.low == null || value.low === \"\") {\n return null\n }\n if (value.high == null || value.high === \"\") {\n return null\n }\n const low = builder.preprocess(value.low, allPreProcessingOpts)\n const high = builder.preprocess(value.high, allPreProcessingOpts)\n return `${key}:[${low} TO ${high}]`\n })\n }\n if (this.#query.fuzzy) {\n build(this.#query.fuzzy, fuzzy)\n }\n if (this.#query.equal) {\n build(this.#query.equal, equal)\n }\n if (this.#query.notEqual) {\n build(this.#query.notEqual, (key: string, value: any) => {\n if (!value) {\n return null\n }\n if (typeof value === \"boolean\") {\n return `(*:* AND !${key}:${value})`\n }\n return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`\n })\n }\n if (this.#query.empty) {\n build(this.#query.empty, (key: string) => `(*:* -${key}:[\"\" TO *])`)\n }\n if (this.#query.notEmpty) {\n build(this.#query.notEmpty, (key: string) => `${key}:[\"\" TO *]`)\n }\n if (this.#query.oneOf) {\n build(this.#query.oneOf, oneOf)\n }\n if (this.#query.contains) {\n build(this.#query.contains, contains)\n }\n if (this.#query.notContains) {\n build(this.compressFilters(this.#query.notContains), notContains)\n }\n if (this.#query.containsAny) {\n build(this.#query.containsAny, containsAny)\n }\n // make sure table ID is always added as an AND\n if (tableId) {\n query = this.isMultiCondition() ? `(${query})` : query\n allOr = false\n build({ tableId }, equal)\n }\n if (allFiltersEmpty) {\n if (this.#query.onEmptyFilter === EmptyFilterOption.RETURN_NONE) {\n return \"\"\n } else if (this.#query?.allOr) {\n return query.replace(\"()\", \"(*:*)\")\n }\n }\n return query\n }\n\n buildSearchBody() {\n let body: any = {\n q: this.buildSearchQuery(),\n limit: Math.min(this.#limit, QueryBuilder.maxLimit),\n include_docs: this.#includeDocs,\n }\n if (this.#bookmark) {\n body.bookmark = this.#bookmark\n }\n if (this.#sort) {\n const order = this.#sortOrder === \"descending\" ? \"-\" : \"\"\n const type = `<${this.#sortType}>`\n body.sort = `${order}${this.handleSpaces(this.#sort)}${type}`\n }\n return body\n }\n\n async run() {\n if (this.#skip) {\n await this.#skipItems(this.#skip)\n }\n return await this.#execute()\n }\n\n /**\n * Lucene queries do not support pagination and use bookmarks instead.\n * For the given builder, walk through pages using bookmarks until the desired\n * page has been met.\n */\n async #skipItems(skip: number) {\n // Lucene does not support pagination.\n // Handle pagination by finding the right bookmark\n const prevIncludeDocs = this.#includeDocs\n const prevLimit = this.#limit\n\n this.excludeDocs()\n let skipRemaining = skip\n let iterationFetched = 0\n do {\n const toSkip = Math.min(QueryBuilder.maxLimit, skipRemaining)\n this.setLimit(toSkip)\n const { bookmark, rows } = await this.#execute()\n this.setBookmark(bookmark)\n iterationFetched = rows.length\n skipRemaining -= rows.length\n } while (skipRemaining > 0 && iterationFetched > 0)\n\n this.#includeDocs = prevIncludeDocs\n this.#limit = prevLimit\n }\n\n async #execute() {\n const { url, cookie } = getCouchInfo()\n const fullPath = `${url}/${this.#dbName}/_design/database/_search/${\n this.#index\n }`\n const body = this.buildSearchBody()\n try {\n return await runQuery<T>(fullPath, body, cookie)\n } catch (err: any) {\n if (err.status === 404 && this.#indexBuilder) {\n await this.#indexBuilder()\n return await runQuery<T>(fullPath, body, cookie)\n } else {\n throw err\n }\n }\n }\n}\n\n/**\n * Executes a lucene search query.\n * @param url The query URL\n * @param body The request body defining search criteria\n * @param cookie The auth cookie for CouchDB\n * @returns {Promise<{rows: []}>}\n */\nasync function runQuery<T>(\n url: string,\n body: any,\n cookie: string\n): Promise<SearchResponse<T>> {\n const response = await fetch(url, {\n body: JSON.stringify(body),\n method: \"POST\",\n headers: {\n Authorization: cookie,\n },\n })\n\n if (response.status === 404) {\n throw response\n }\n const json = await response.json()\n\n let output: SearchResponse<T> = {\n rows: [],\n totalRows: 0,\n }\n if (json.rows != null && json.rows.length > 0) {\n output.rows = json.rows.map((row: any) => row.doc)\n }\n if (json.bookmark) {\n output.bookmark = json.bookmark\n }\n if (json.total_rows) {\n output.totalRows = json.total_rows\n }\n return output\n}\n\n/**\n * Gets round the fixed limit of 200 results from a query by fetching as many\n * pages as required and concatenating the results. This recursively operates\n * until enough results have been found.\n * @param dbName {string} Which database to run a lucene query on\n * @param index {string} Which search index to utilise\n * @param query {object} The JSON query structure\n * @param params {object} The search params including:\n * tableId {string} The table ID to search\n * sort {string} The sort column\n * sortOrder {string} The sort order (\"ascending\" or \"descending\")\n * sortType {string} Whether to treat sortable values as strings or\n * numbers. (\"string\" or \"number\")\n * limit {number} The number of results to fetch\n * bookmark {string|null} Current bookmark in the recursive search\n * rows {array|null} Current results in the recursive search\n * @returns {Promise<*[]|*>}\n */\nasync function recursiveSearch<T>(\n dbName: string,\n index: string,\n query: any,\n params: any\n): Promise<any> {\n const bookmark = params.bookmark\n const rows = params.rows || []\n if (rows.length >= params.limit) {\n return rows\n }\n let pageSize = QueryBuilder.maxLimit\n if (rows.length > params.limit - QueryBuilder.maxLimit) {\n pageSize = params.limit - rows.length\n }\n const page = await new QueryBuilder<T>(dbName, index, query)\n .setVersion(params.version)\n .setTable(params.tableId)\n .setBookmark(bookmark)\n .setLimit(pageSize)\n .setSort(params.sort)\n .setSortOrder(params.sortOrder)\n .setSortType(params.sortType)\n .run()\n if (!page.rows.length) {\n return rows\n }\n if (page.rows.length < QueryBuilder.maxLimit) {\n return [...rows, ...page.rows]\n }\n const newParams = {\n ...params,\n bookmark: page.bookmark,\n rows: [...rows, ...page.rows],\n }\n return await recursiveSearch(dbName, index, query, newParams)\n}\n\n/**\n * Performs a paginated search. A bookmark will be returned to allow the next\n * page to be fetched. There is a max limit off 200 results per page in a\n * paginated search.\n * @param dbName {string} Which database to run a lucene query on\n * @param index {string} Which search index to utilise\n * @param query {object} The JSON query structure\n * @param params {object} The search params including:\n * tableId {string} The table ID to search\n * sort {string} The sort column\n * sortOrder {string} The sort order (\"ascending\" or \"descending\")\n * sortType {string} Whether to treat sortable values as strings or\n * numbers. (\"string\" or \"number\")\n * limit {number} The desired page size\n * bookmark {string} The bookmark to resume from\n * @returns {Promise<{hasNextPage: boolean, rows: *[]}>}\n */\nexport async function paginatedSearch<T>(\n dbName: string,\n index: string,\n query: SearchFilters,\n params: SearchParams<T>\n) {\n let limit = params.limit\n if (limit == null || isNaN(limit) || limit < 0) {\n limit = 50\n }\n limit = Math.min(limit, QueryBuilder.maxLimit)\n const search = new QueryBuilder<T>(dbName, index, query)\n if (params.version) {\n search.setVersion(params.version)\n }\n if (params.tableId) {\n search.setTable(params.tableId)\n }\n if (params.sort) {\n search\n .setSort(params.sort)\n .setSortOrder(params.sortOrder)\n .setSortType(params.sortType)\n }\n if (params.indexer) {\n search.setIndexBuilder(params.indexer)\n }\n if (params.disableEscaping) {\n search.disableEscaping()\n }\n const searchResults = await search\n .setBookmark(params.bookmark)\n .setLimit(limit)\n .run()\n\n // Try fetching 1 row in the next page to see if another page of results\n // exists or not\n search.setBookmark(searchResults.bookmark).setLimit(1)\n if (params.tableId) {\n search.setTable(params.tableId)\n }\n const nextResults = await search.run()\n\n return {\n ...searchResults,\n hasNextPage: nextResults.rows && nextResults.rows.length > 0,\n }\n}\n\n/**\n * Performs a full search, fetching multiple pages if required to return the\n * desired amount of results. There is a limit of 1000 results to avoid\n * heavy performance hits, and to avoid client components breaking from\n * handling too much data.\n * @param dbName {string} Which database to run a lucene query on\n * @param index {string} Which search index to utilise\n * @param query {object} The JSON query structure\n * @param params {object} The search params including:\n * tableId {string} The table ID to search\n * sort {string} The sort column\n * sortOrder {string} The sort order (\"ascending\" or \"descending\")\n * sortType {string} Whether to treat sortable values as strings or\n * numbers. (\"string\" or \"number\")\n * limit {number} The desired number of results\n * @returns {Promise<{rows: *}>}\n */\nexport async function fullSearch<T>(\n dbName: string,\n index: string,\n query: SearchFilters,\n params: SearchParams<T>\n) {\n let limit = params.limit\n if (limit == null || isNaN(limit) || limit < 0) {\n limit = 1000\n }\n params.limit = Math.min(limit, 1000)\n const rows = await recursiveSearch<T>(dbName, index, query, params)\n return { rows }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAkB;AAClB,mBAA6B;AAC7B,mBAAsD;AAEtD,MAAM,oBAAoB;AAyBnB,SAAS,mBAAmB,KAAkB;AACnD,MAAI,OAAO,QAAQ,YAAY,IAAI,MAAM,iBAAiB,KAAK,MAAM;AACnE,UAAM,QAAQ,IAAI,MAAM,GAAG;AAE3B,UAAM,MAAM;AACZ,WAAO,MAAM,KAAK,GAAG;AAAA,EACvB,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAMO,MAAM,aAAgB;AAAA,EAC3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f,WACG,QAAQ,OAAO,IAAI,EACnB,aAAa,OAAO,SAAS,EAC7B,YAAY,OAAO,QAAQ;AAAA,EAChC;AACA,MAAI,OAAO,SAAS;AAClB,WAAO,gBAAgB,OAAO,OAAO;AAAA,EACvC;AACA,MAAI,OAAO,iBAAiB;AAC1B,WAAO,gBAAgB;AAAA,EACzB;AACA,QAAM,gBAAgB,MAAM,OACzB,YAAY,OAAO,QAAQ,EAC3B,SAAS,KAAK,EACd,IAAI;AAIP,SAAO,YAAY,cAAc,QAAQ,EAAE,SAAS,CAAC;AACrD,MAAI,OAAO,SAAS;AAClB,WAAO,SAAS,OAAO,OAAO;AAAA,EAChC;AACA,QAAM,cAAc,MAAM,OAAO,IAAI;AAErC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,aAAa,YAAY,QAAQ,YAAY,KAAK,SAAS;AAAA,EAC7D;AACF;AAmBA,eAAsB,WACpB,QACA,OACA,OACA,QACA;AACA,MAAI,QAAQ,OAAO;AACnB,MAAI,SAAS,QAAQ,MAAM,KAAK,KAAK,QAAQ,GAAG;AAC9C,YAAQ;AAAA,EACV;AACA,SAAO,QAAQ,KAAK,IAAI,OAAO,GAAI;AACnC,QAAM,OAAO,MAAM,gBAAmB,QAAQ,OAAO,OAAO,MAAM;AAClE,SAAO,EAAE,KAAK;AAChB;",
|
|
6
|
+
"names": ["fetch"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var searchIndexes_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(searchIndexes_exports);
|
|
18
|
+
__reExport(searchIndexes_exports, require("./searchIndexes"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./searchIndexes")
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.js.map
|