@directus/api 34.0.1 → 35.0.0
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/__utils__/items-utils.js +32 -0
- package/dist/__utils__/schemas.js +297 -0
- package/dist/__utils__/snapshots.js +899 -0
- package/dist/_virtual/rolldown_runtime.js +38 -0
- package/dist/ai/chat/constants/system-prompt.js +5 -1
- package/dist/ai/chat/controllers/chat.post.js +69 -61
- package/dist/ai/chat/lib/create-ui-stream.js +71 -45
- package/dist/ai/chat/lib/transform-file-parts.js +43 -32
- package/dist/ai/chat/middleware/load-settings.js +42 -41
- package/dist/ai/chat/models/chat-request.js +77 -69
- package/dist/ai/chat/models/providers.js +23 -18
- package/dist/ai/chat/router.js +10 -5
- package/dist/ai/chat/utils/chat-request-tool-to-ai-sdk-tool.js +40 -36
- package/dist/ai/chat/utils/fix-error-tool-calls.js +30 -28
- package/dist/ai/chat/utils/format-context.js +87 -89
- package/dist/ai/chat/utils/parse-json-schema-7.js +84 -73
- package/dist/ai/devtools/index.js +38 -0
- package/dist/ai/files/adapters/anthropic.js +29 -24
- package/dist/ai/files/adapters/google.js +60 -57
- package/dist/ai/files/adapters/index.js +5 -3
- package/dist/ai/files/adapters/openai.js +26 -21
- package/dist/ai/files/controllers/upload.js +101 -95
- package/dist/ai/files/lib/fetch-provider.js +27 -22
- package/dist/ai/files/lib/upload-to-provider.js +32 -25
- package/dist/ai/files/router.js +10 -5
- package/dist/ai/files/types.js +1 -1
- package/dist/ai/mcp/index.js +3 -1
- package/dist/ai/mcp/server.js +293 -301
- package/dist/ai/mcp/transport.js +22 -18
- package/dist/ai/mcp/types.js +1 -1
- package/dist/ai/providers/anthropic-file-support.js +91 -89
- package/dist/ai/providers/anthropic-tool-search.js +33 -0
- package/dist/ai/providers/index.js +5 -3
- package/dist/ai/providers/options.js +27 -24
- package/dist/ai/providers/registry.js +65 -60
- package/dist/ai/providers/types.js +1 -1
- package/dist/ai/telemetry/braintrust.js +27 -0
- package/dist/ai/telemetry/index.js +79 -0
- package/dist/ai/telemetry/langfuse.js +67 -0
- package/dist/ai/tools/assets/index.js +56 -55
- package/dist/ai/tools/collections/index.js +96 -89
- package/dist/ai/tools/define-tool.js +6 -2
- package/dist/ai/tools/fields/index.js +157 -162
- package/dist/ai/tools/files/index.js +109 -104
- package/dist/ai/tools/flows/index.js +99 -87
- package/dist/ai/tools/folders/index.js +103 -98
- package/dist/ai/tools/index.js +32 -28
- package/dist/ai/tools/items/index.js +149 -146
- package/dist/ai/tools/operations/index.js +88 -80
- package/dist/ai/tools/relations/index.js +100 -91
- package/dist/ai/tools/schema/index.js +240 -302
- package/dist/ai/tools/schema.js +198 -205
- package/dist/ai/tools/system/index.js +23 -22
- package/dist/ai/tools/trigger-flow/index.js +62 -49
- package/dist/ai/tools/types.js +1 -1
- package/dist/ai/tools/utils.js +20 -15
- package/dist/app.js +296 -288
- package/dist/auth/auth.js +46 -41
- package/dist/auth/drivers/index.js +7 -5
- package/dist/auth/drivers/ldap.js +314 -342
- package/dist/auth/drivers/local.js +86 -89
- package/dist/auth/drivers/oauth2.js +369 -385
- package/dist/auth/drivers/openid.js +429 -447
- package/dist/auth/drivers/saml.js +172 -172
- package/dist/auth/utils/generate-callback-url.js +38 -35
- package/dist/auth/utils/resolve-login-redirect.js +54 -60
- package/dist/auth.js +66 -60
- package/dist/bus/index.js +3 -1
- package/dist/bus/lib/use-bus.js +29 -19
- package/dist/cache.js +136 -124
- package/dist/cli/commands/bootstrap/index.js +61 -59
- package/dist/cli/commands/cache/clear.js +33 -0
- package/dist/cli/commands/count/index.js +25 -21
- package/dist/cli/commands/database/install.js +20 -16
- package/dist/cli/commands/database/migrate.js +26 -23
- package/dist/cli/commands/init/index.js +116 -100
- package/dist/cli/commands/init/questions.js +86 -48
- package/dist/cli/commands/roles/create.js +51 -37
- package/dist/cli/commands/schema/apply.js +188 -203
- package/dist/cli/commands/schema/snapshot.js +55 -56
- package/dist/cli/commands/security/key.js +9 -4
- package/dist/cli/commands/security/secret.js +8 -4
- package/dist/cli/commands/users/create.js +35 -23
- package/dist/cli/commands/users/passwd.js +37 -35
- package/dist/cli/index.js +53 -90
- package/dist/cli/load-extensions.js +25 -19
- package/dist/cli/run.js +9 -7
- package/dist/cli/utils/create-db-connection.js +56 -54
- package/dist/cli/utils/create-env/index.js +33 -35
- package/dist/cli/utils/drivers.js +16 -13
- package/dist/constants.js +132 -89
- package/dist/controllers/access.js +137 -140
- package/dist/controllers/activity.js +47 -46
- package/dist/controllers/assets.js +200 -241
- package/dist/controllers/auth.js +175 -175
- package/dist/controllers/collections.js +99 -99
- package/dist/controllers/comments.js +136 -138
- package/dist/controllers/dashboards.js +131 -132
- package/dist/controllers/deployment-webhooks.js +92 -93
- package/dist/controllers/deployment.js +330 -350
- package/dist/controllers/extensions.js +205 -199
- package/dist/controllers/fields.js +155 -164
- package/dist/controllers/files.js +250 -269
- package/dist/controllers/flows.js +150 -151
- package/dist/controllers/folders.js +138 -141
- package/dist/controllers/graphql.js +33 -28
- package/dist/controllers/items.js +157 -172
- package/dist/controllers/mcp.js +33 -31
- package/dist/controllers/metrics.js +33 -29
- package/dist/controllers/not-found.js +35 -28
- package/dist/controllers/notifications.js +138 -141
- package/dist/controllers/operations.js +131 -132
- package/dist/controllers/panels.js +131 -132
- package/dist/controllers/permissions.js +162 -166
- package/dist/controllers/policies.js +155 -160
- package/dist/controllers/presets.js +138 -141
- package/dist/controllers/relations.js +96 -102
- package/dist/controllers/revisions.js +40 -32
- package/dist/controllers/roles.js +152 -152
- package/dist/controllers/schema.js +97 -92
- package/dist/controllers/server.js +84 -81
- package/dist/controllers/settings.js +44 -40
- package/dist/controllers/shares.js +180 -213
- package/dist/controllers/translations.js +138 -141
- package/dist/controllers/tus.js +70 -72
- package/dist/controllers/users.js +303 -308
- package/dist/controllers/utils.js +149 -134
- package/dist/controllers/versions.js +178 -176
- package/dist/database/errors/dialects/mssql.js +137 -153
- package/dist/database/errors/dialects/mysql.js +123 -137
- package/dist/database/errors/dialects/oracle.js +24 -20
- package/dist/database/errors/dialects/postgres.js +91 -94
- package/dist/database/errors/dialects/sqlite.js +48 -46
- package/dist/database/errors/dialects/types.js +1 -1
- package/dist/database/errors/translate.js +47 -42
- package/dist/database/get-ast-from-query/get-ast-from-query.js +51 -52
- package/dist/database/get-ast-from-query/lib/convert-wildcards.js +74 -78
- package/dist/database/get-ast-from-query/lib/parse-fields.js +231 -246
- package/dist/database/get-ast-from-query/utils/get-allowed-sort.js +31 -34
- package/dist/database/get-ast-from-query/utils/get-deep-query.js +20 -15
- package/dist/database/get-ast-from-query/utils/get-related-collection.js +16 -12
- package/dist/database/helpers/capabilities/dialects/default.js +7 -3
- package/dist/database/helpers/capabilities/dialects/mysql.js +11 -9
- package/dist/database/helpers/capabilities/dialects/postgres.js +14 -14
- package/dist/database/helpers/capabilities/index.js +18 -7
- package/dist/database/helpers/capabilities/types.js +20 -15
- package/dist/database/helpers/date/dialects/default.js +7 -3
- package/dist/database/helpers/date/dialects/mssql.js +13 -8
- package/dist/database/helpers/date/dialects/mysql.js +17 -12
- package/dist/database/helpers/date/dialects/oracle.js +27 -27
- package/dist/database/helpers/date/dialects/sqlite.js +27 -28
- package/dist/database/helpers/date/index.js +20 -7
- package/dist/database/helpers/date/types.js +25 -22
- package/dist/database/helpers/fn/dialects/mssql.js +64 -63
- package/dist/database/helpers/fn/dialects/mysql.js +70 -67
- package/dist/database/helpers/fn/dialects/oracle.js +64 -63
- package/dist/database/helpers/fn/dialects/postgres.js +87 -84
- package/dist/database/helpers/fn/dialects/sqlite.js +61 -78
- package/dist/database/helpers/fn/index.js +20 -7
- package/dist/database/helpers/fn/json/parse-function.js +60 -61
- package/dist/database/helpers/fn/types.js +48 -56
- package/dist/database/helpers/geometry/dialects/mssql.js +42 -34
- package/dist/database/helpers/geometry/dialects/mysql.js +21 -12
- package/dist/database/helpers/geometry/dialects/oracle.js +49 -37
- package/dist/database/helpers/geometry/dialects/postgres.js +27 -18
- package/dist/database/helpers/geometry/dialects/redshift.js +21 -12
- package/dist/database/helpers/geometry/dialects/sqlite.js +19 -10
- package/dist/database/helpers/geometry/index.js +21 -7
- package/dist/database/helpers/geometry/types.js +59 -51
- package/dist/database/helpers/index.js +26 -21
- package/dist/database/helpers/number/dialects/default.js +7 -3
- package/dist/database/helpers/number/dialects/mssql.js +16 -11
- package/dist/database/helpers/number/dialects/oracle.js +12 -7
- package/dist/database/helpers/number/dialects/postgres.js +18 -15
- package/dist/database/helpers/number/dialects/sqlite.js +12 -7
- package/dist/database/helpers/number/index.js +20 -7
- package/dist/database/helpers/number/types.js +14 -9
- package/dist/database/helpers/number/utils/decimal-limit.js +17 -9
- package/dist/database/helpers/number/utils/maybe-stringify-big-int.js +9 -5
- package/dist/database/helpers/number/utils/number-in-range.js +18 -19
- package/dist/database/helpers/schema/dialects/cockroachdb.js +63 -81
- package/dist/database/helpers/schema/dialects/default.js +7 -3
- package/dist/database/helpers/schema/dialects/mssql.js +64 -84
- package/dist/database/helpers/schema/dialects/mysql.js +61 -103
- package/dist/database/helpers/schema/dialects/oracle.js +96 -116
- package/dist/database/helpers/schema/dialects/postgres.js +41 -52
- package/dist/database/helpers/schema/dialects/sqlite.js +31 -29
- package/dist/database/helpers/schema/index.js +22 -7
- package/dist/database/helpers/schema/types.js +151 -154
- package/dist/database/helpers/schema/utils/prep-query-params.js +38 -34
- package/dist/database/helpers/sequence/dialects/default.js +7 -3
- package/dist/database/helpers/sequence/dialects/postgres.js +23 -13
- package/dist/database/helpers/sequence/index.js +17 -7
- package/dist/database/helpers/sequence/types.js +11 -6
- package/dist/database/helpers/types.js +9 -6
- package/dist/database/index.js +255 -287
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.js +44 -40
- package/dist/database/migrations/20201029A-remove-system-relations.js +122 -120
- package/dist/database/migrations/20201029B-remove-system-collections.js +96 -91
- package/dist/database/migrations/20201029C-remove-system-fields.js +1527 -1636
- package/dist/database/migrations/20201105A-add-cascade-system-relations.js +114 -126
- package/dist/database/migrations/20201105B-change-webhook-url-type.js +15 -10
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +30 -28
- package/dist/database/migrations/20210304A-remove-locked-fields.js +12 -8
- package/dist/database/migrations/20210312A-webhooks-collections-text.js +15 -10
- package/dist/database/migrations/20210331A-add-refresh-interval.js +12 -8
- package/dist/database/migrations/20210415A-make-filesize-nullable.js +18 -13
- package/dist/database/migrations/20210416A-add-collections-accountability.js +13 -9
- package/dist/database/migrations/20210422A-remove-files-interface.js +7 -5
- package/dist/database/migrations/20210506A-rename-interfaces.js +77 -70
- package/dist/database/migrations/20210510A-restructure-relations.js +26 -25
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +83 -106
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +143 -162
- package/dist/database/migrations/20210521A-add-collections-icon-color.js +12 -8
- package/dist/database/migrations/20210525A-add-insights.js +33 -29
- package/dist/database/migrations/20210608A-add-deep-clone-config.js +12 -8
- package/dist/database/migrations/20210626A-change-filesize-bigint.js +22 -17
- package/dist/database/migrations/20210716A-add-conditions-to-fields.js +12 -8
- package/dist/database/migrations/20210721A-add-default-folder.js +16 -16
- package/dist/database/migrations/20210802A-replace-groups.js +35 -44
- package/dist/database/migrations/20210803A-add-required-to-fields.js +12 -8
- package/dist/database/migrations/20210805A-update-groups.js +26 -27
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +67 -82
- package/dist/database/migrations/20210811A-add-geometry-config.js +14 -10
- package/dist/database/migrations/20210831A-remove-limit-column.js +12 -8
- package/dist/database/migrations/20210903A-add-auth-provider.js +38 -33
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.js +14 -11
- package/dist/database/migrations/20210910A-move-module-setup.js +18 -14
- package/dist/database/migrations/20210920A-webhooks-url-not-null.js +18 -19
- package/dist/database/migrations/20210924A-add-collection-organization.js +19 -17
- package/dist/database/migrations/20210927A-replace-fields-group.js +48 -48
- package/dist/database/migrations/20210927B-replace-m2m-interface.js +8 -14
- package/dist/database/migrations/20210929A-rename-login-action.js +8 -12
- package/dist/database/migrations/20211007A-update-presets.js +79 -96
- package/dist/database/migrations/20211009A-add-auth-data.js +12 -8
- package/dist/database/migrations/20211016A-add-webhook-headers.js +12 -8
- package/dist/database/migrations/20211103A-set-unique-to-user-token.js +12 -8
- package/dist/database/migrations/20211103B-update-special-geometry.js +8 -18
- package/dist/database/migrations/20211104A-remove-collections-listing.js +12 -8
- package/dist/database/migrations/20211118A-add-notifications.js +28 -23
- package/dist/database/migrations/20211211A-add-shares.js +37 -37
- package/dist/database/migrations/20211230A-add-project-descriptor.js +12 -8
- package/dist/database/migrations/20220303A-remove-default-project-color.js +20 -15
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.js +14 -10
- package/dist/database/migrations/20220314A-add-translation-strings.js +12 -8
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.js +59 -70
- package/dist/database/migrations/20220323A-add-field-validation.js +14 -10
- package/dist/database/migrations/20220325A-fix-typecast-flags.js +36 -43
- package/dist/database/migrations/20220325B-add-default-language.js +26 -21
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.js +20 -15
- package/dist/database/migrations/20220429A-add-flows.js +80 -75
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.js +12 -8
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.js +12 -8
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.js +12 -8
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.js +8 -4
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.js +15 -12
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.js +12 -8
- package/dist/database/migrations/20220826A-add-origin-to-accountability.js +18 -14
- package/dist/database/migrations/20230401A-update-material-icons.js +22 -17
- package/dist/database/migrations/20230525A-add-preview-settings.js +12 -8
- package/dist/database/migrations/20230526A-migrate-translation-strings.js +56 -48
- package/dist/database/migrations/20230721A-require-shares-fields.js +52 -48
- package/dist/database/migrations/20230823A-add-content-versioning.js +34 -36
- package/dist/database/migrations/20230927A-themes.js +51 -47
- package/dist/database/migrations/20231009A-update-csv-fields-to-text.js +42 -38
- package/dist/database/migrations/20231009B-update-panel-options.js +64 -75
- package/dist/database/migrations/20231010A-add-extensions.js +11 -7
- package/dist/database/migrations/20231215A-add-focalpoints.js +14 -10
- package/dist/database/migrations/20240122A-add-report-url-fields.js +16 -12
- package/dist/database/migrations/20240204A-marketplace.js +98 -99
- package/dist/database/migrations/20240305A-change-useragent-type.js +16 -17
- package/dist/database/migrations/20240311A-deprecate-webhooks.js +97 -121
- package/dist/database/migrations/20240422A-public-registration.js +16 -12
- package/dist/database/migrations/20240515A-add-session-window.js +12 -8
- package/dist/database/migrations/20240701A-add-tus-data.js +14 -10
- package/dist/database/migrations/20240716A-update-files-date-fields.js +29 -27
- package/dist/database/migrations/20240806A-permissions-policies.js +202 -262
- package/dist/database/migrations/20240817A-update-icon-fields-length.js +50 -53
- package/dist/database/migrations/20240909A-separate-comments.js +53 -60
- package/dist/database/migrations/20240909B-consolidate-content-versioning.js +12 -8
- package/dist/database/migrations/20240924A-migrate-legacy-comments.js +67 -79
- package/dist/database/migrations/20240924B-populate-versioning-deltas.js +26 -31
- package/dist/database/migrations/20250224A-visual-editor.js +31 -31
- package/dist/database/migrations/20250609A-license-banner.js +17 -12
- package/dist/database/migrations/20250613A-add-project-id.js +22 -24
- package/dist/database/migrations/20250718A-add-direction.js +12 -8
- package/dist/database/migrations/20250813A-add-mcp.js +20 -16
- package/dist/database/migrations/20251012A-add-field-searchable.js +12 -8
- package/dist/database/migrations/20251014A-add-project-owner.js +40 -35
- package/dist/database/migrations/20251028A-add-retention-indexes.js +53 -40
- package/dist/database/migrations/20251103A-add-ai-settings.js +16 -12
- package/dist/database/migrations/20251224A-remove-webhooks.js +21 -17
- package/dist/database/migrations/20260110A-add-ai-provider-settings.js +45 -33
- package/dist/database/migrations/20260113A-add-revisions-index.js +49 -39
- package/dist/database/migrations/20260128A-add-collaborative-editing.js +12 -8
- package/dist/database/migrations/20260204A-add-deployment.js +34 -30
- package/dist/database/migrations/20260211A-add-deployment-webhooks.js +39 -35
- package/dist/database/migrations/run.js +113 -109
- package/dist/database/run-ast/lib/apply-query/add-join.js +81 -85
- package/dist/database/run-ast/lib/apply-query/aggregate.js +34 -23
- package/dist/database/run-ast/lib/apply-query/filter/get-filter-type.js +27 -19
- package/dist/database/run-ast/lib/apply-query/filter/index.js +136 -150
- package/dist/database/run-ast/lib/apply-query/filter/operator.js +174 -182
- package/dist/database/run-ast/lib/apply-query/filter/validate-operator.js +17 -17
- package/dist/database/run-ast/lib/apply-query/get-filter-path.js +17 -12
- package/dist/database/run-ast/lib/apply-query/get-operation.js +26 -17
- package/dist/database/run-ast/lib/apply-query/index.js +88 -88
- package/dist/database/run-ast/lib/apply-query/join-filter-with-cases.js +13 -11
- package/dist/database/run-ast/lib/apply-query/mock.js +9 -4
- package/dist/database/run-ast/lib/apply-query/pagination.js +14 -9
- package/dist/database/run-ast/lib/apply-query/search.js +75 -77
- package/dist/database/run-ast/lib/apply-query/sort.js +90 -86
- package/dist/database/run-ast/lib/get-db-query.js +181 -241
- package/dist/database/run-ast/lib/parse-current-level.js +54 -47
- package/dist/database/run-ast/modules/fetch-permitted-ast-root-fields.js +44 -27
- package/dist/database/run-ast/run-ast.js +131 -129
- package/dist/database/run-ast/types.js +1 -1
- package/dist/database/run-ast/utils/apply-case-when.js +29 -26
- package/dist/database/run-ast/utils/apply-function-to-column-name.js +29 -26
- package/dist/database/run-ast/utils/apply-parent-filters.js +58 -56
- package/dist/database/run-ast/utils/generate-alias.js +48 -52
- package/dist/database/run-ast/utils/get-column-pre-processor.js +66 -66
- package/dist/database/run-ast/utils/get-column.js +64 -64
- package/dist/database/run-ast/utils/get-field-alias.js +9 -5
- package/dist/database/run-ast/utils/get-inner-query-column-pre-processor.js +30 -23
- package/dist/database/run-ast/utils/merge-with-parent-items.js +127 -137
- package/dist/database/run-ast/utils/remove-temporary-fields.js +70 -78
- package/dist/database/run-ast/utils/with-preprocess-bindings.js +17 -14
- package/dist/database/seeds/run.js +77 -78
- package/dist/deployment/deployment.js +34 -29
- package/dist/deployment/drivers/index.js +4 -2
- package/dist/deployment/drivers/netlify.js +372 -358
- package/dist/deployment/drivers/vercel.js +276 -285
- package/dist/deployment/index.js +6 -2
- package/dist/deployment.js +66 -62
- package/dist/emitter.js +101 -89
- package/dist/extensions/index.js +12 -7
- package/dist/extensions/lib/get-extensions-path.js +13 -8
- package/dist/extensions/lib/get-extensions-settings.js +117 -128
- package/dist/extensions/lib/get-extensions.js +20 -11
- package/dist/extensions/lib/get-shared-deps-mapping.js +30 -26
- package/dist/extensions/lib/installation/index.js +12 -7
- package/dist/extensions/lib/installation/manager.js +100 -95
- package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.js +66 -43
- package/dist/extensions/lib/sandbox/generate-host-function-reference.js +19 -16
- package/dist/extensions/lib/sandbox/register/action.js +23 -17
- package/dist/extensions/lib/sandbox/register/call-reference.js +28 -21
- package/dist/extensions/lib/sandbox/register/filter.js +26 -20
- package/dist/extensions/lib/sandbox/register/index.js +7 -5
- package/dist/extensions/lib/sandbox/register/operation.js +27 -21
- package/dist/extensions/lib/sandbox/register/route.js +52 -43
- package/dist/extensions/lib/sandbox/sdk/generators/index.js +5 -3
- package/dist/extensions/lib/sandbox/sdk/generators/log.js +14 -11
- package/dist/extensions/lib/sandbox/sdk/generators/request.js +56 -48
- package/dist/extensions/lib/sandbox/sdk/generators/sleep.js +13 -10
- package/dist/extensions/lib/sandbox/sdk/index.js +4 -2
- package/dist/extensions/lib/sandbox/sdk/instantiate.js +32 -26
- package/dist/extensions/lib/sandbox/sdk/sdk.js +32 -9
- package/dist/extensions/lib/sandbox/sdk/utils/index.js +3 -1
- package/dist/extensions/lib/sandbox/sdk/utils/wrap.js +50 -47
- package/dist/extensions/lib/sync/status.js +30 -29
- package/dist/extensions/lib/sync/sync.js +83 -89
- package/dist/extensions/lib/sync/tracker.js +68 -71
- package/dist/extensions/lib/sync/utils.js +53 -54
- package/dist/extensions/lib/wrap-embeds.js +9 -6
- package/dist/extensions/manager.js +718 -746
- package/dist/flows.js +574 -427
- package/dist/index.js +3 -1
- package/dist/lock/index.js +3 -1
- package/dist/lock/lib/use-lock.js +28 -18
- package/dist/logger/index.js +186 -179
- package/dist/logger/logs-stream.js +45 -40
- package/dist/logger/redact-query.js +16 -12
- package/dist/mailer.js +61 -60
- package/dist/metrics/index.js +3 -1
- package/dist/metrics/lib/create-metrics.js +250 -233
- package/dist/metrics/lib/use-metrics.js +19 -14
- package/dist/metrics/types/metric.js +1 -1
- package/dist/middleware/authenticate.js +46 -47
- package/dist/middleware/cache.js +61 -57
- package/dist/middleware/collection-exists.js +24 -24
- package/dist/middleware/cors.js +17 -12
- package/dist/middleware/error-handler.js +77 -86
- package/dist/middleware/extract-token.js +37 -43
- package/dist/middleware/graphql.js +70 -68
- package/dist/middleware/rate-limiter-global.js +41 -38
- package/dist/middleware/rate-limiter-ip.js +36 -29
- package/dist/middleware/rate-limiter-registration.js +32 -29
- package/dist/middleware/request-counter.js +28 -0
- package/dist/middleware/respond.js +97 -109
- package/dist/middleware/sanitize-query.js +25 -27
- package/dist/middleware/schema.js +11 -6
- package/dist/middleware/use-collection.js +10 -5
- package/dist/middleware/validate-batch.js +41 -42
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +445 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/index.js +176 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/system/policy.js +54 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/any/any.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/any/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/argument/argument.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/argument/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/array/array.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/array/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/async-iterator/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.js +37 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/awaited/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/bigint/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/boolean/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/clone/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/clone/type.js +17 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/clone/value.js +35 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/composite/composite.js +42 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/composite/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/computed/computed.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/computed/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/const/const.js +52 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/const/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.js +17 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/create/immutable.js +32 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/create/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/create/type.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/date/date.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/date/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/discard/discard.js +12 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/discard/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/enum/enum.js +23 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/enum/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/error/error.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/error/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.js +11 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.js +25 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.js +267 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.js +29 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-undefined.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/index.js +7 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.js +11 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract.js +25 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/function/function.js +17 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/function/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/kind.js +204 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/type.js +293 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/value.js +68 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/helpers/helpers.js +8 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/helpers/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/index.js +6 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.js +27 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.js +24 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.js +24 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.js +67 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instance-type/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instantiate/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.js +102 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/integer/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/integer/integer.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.js +23 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.js +35 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-type.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.js +17 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/index.js +8 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.js +30 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.js +54 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/iterator/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/index.js +6 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-entries.js +17 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.js +52 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.js +38 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/literal/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/literal/literal.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-key.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.js +86 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/module/compute.js +144 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/module/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/module/module.js +44 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/never/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/never/never.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/not/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/not/not.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/null/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/null/null.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/number/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/number/number.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/object/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/object/object.js +33 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.js +27 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit.js +65 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/optional/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/optional/optional.js +29 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/parameters/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/partial/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/partial/partial.js +62 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/patterns/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.js +12 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.js +27 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.js +21 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick.js +63 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/promise/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/promise/promise.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.js +29 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/record/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/record/record.js +92 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/recursive/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.js +24 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/ref/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/ref/ref.js +19 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/regexp/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.js +19 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/registry/format.js +30 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/registry/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/registry/type.js +30 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/required/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/required/required.js +60 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/rest/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/rest/rest.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/return-type/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/schema/anyschema.js +1 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/schema/index.js +4 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/schema/schema.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/sets/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/sets/set.js +42 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/static/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/static/static.js +1 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/string/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/string/string.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbol/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbols/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.js +28 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.js +37 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/index.js +9 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.js +125 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.js +24 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.js +55 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.js +20 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/union.js +16 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/transform/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/transform/transform.js +51 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/tuple/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.js +24 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/index.js +10 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/javascript.js +123 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/json.js +263 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/type.js +191 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/uint8array/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/undefined/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/index.js +5 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union-create.js +14 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.js +33 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union-type.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union.js +13 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unknown/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.js +12 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unsafe/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.js +12 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/void/index.js +3 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/void/void.js +15 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/value/guard/guard.js +140 -0
- package/dist/node_modules/.pnpm/@sinclair_typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/value/guard/index.js +3 -0
- package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +1714 -0
- package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +1287 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +2151 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/index.js +8 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/utils.js +8 -0
- package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +2082 -0
- package/dist/node_modules/.pnpm/@vitest_spy@3.2.4/node_modules/@vitest/spy/dist/index.js +192 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +158 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +1535 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +155 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/helpers.js +244 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/index.js +621 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/source-map.js +890 -0
- package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js +3558 -0
- package/dist/node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/branding.js +13 -0
- package/dist/node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/index.js +115 -0
- package/dist/node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/messages.js +77 -0
- package/dist/node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/overloads.js +13 -0
- package/dist/node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/utils.js +30 -0
- package/dist/node_modules/.pnpm/js-tokens@9.0.1/node_modules/js-tokens/index.js +398 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/MockClient.js +79 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/MockConnection.js +64 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/Tracker.js +185 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/constants.js +30 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/index.js +37 -0
- package/dist/node_modules/.pnpm/knex-mock-client@3.0.2_knex@3.1.0_mysql2@3.15.3_pg@8.16.3_sqlite3@5.1.7_tedious@18.6.1_/node_modules/knex-mock-client/dist/utils.js +17 -0
- package/dist/node_modules/.pnpm/lodash.clonedeep@4.5.0/node_modules/lodash.clonedeep/index.js +1486 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +18 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +19 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +15 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +39 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +14 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +141 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +43 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +138 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +22 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +27 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +27 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +10 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +36 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +1258 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +21 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +478 -0
- package/dist/node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.js +84 -0
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +85 -0
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +15 -0
- package/dist/node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js +158 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +8 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js +41 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +50 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/index.CdQS2e2Q.js +38 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +66 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +2986 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_node@22.13.14_@vitest_ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/index.js +24 -0
- package/dist/operations/condition/index.js +23 -21
- package/dist/operations/exec/index.js +49 -44
- package/dist/operations/item-create/index.js +49 -36
- package/dist/operations/item-delete/index.js +56 -44
- package/dist/operations/item-read/index.js +56 -44
- package/dist/operations/item-update/index.js +62 -51
- package/dist/operations/json-web-token/index.js +33 -35
- package/dist/operations/log/index.js +14 -9
- package/dist/operations/mail/index.js +39 -25
- package/dist/operations/mail/rate-limiter.js +26 -25
- package/dist/operations/notification/index.js +52 -42
- package/dist/operations/request/index.js +47 -39
- package/dist/operations/sleep/index.js +11 -6
- package/dist/operations/throw-error/index.js +14 -9
- package/dist/operations/transform/index.js +12 -7
- package/dist/operations/trigger/index.js +42 -37
- package/dist/packages/types/dist/index.js +403 -0
- package/dist/permissions/cache.js +28 -25
- package/dist/permissions/lib/fetch-permissions.js +33 -26
- package/dist/permissions/lib/fetch-policies.js +42 -41
- package/dist/permissions/lib/fetch-roles-tree.js +10 -5
- package/dist/permissions/lib/with-app-minimal-permissions.js +14 -9
- package/dist/permissions/modules/fetch-accountability-collection-access/fetch-accountability-collection-access.js +56 -54
- package/dist/permissions/modules/fetch-accountability-policy-globals/fetch-accountability-policy-globals.js +14 -15
- package/dist/permissions/modules/fetch-allowed-collections/fetch-allowed-collections.js +26 -11
- package/dist/permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.js +40 -25
- package/dist/permissions/modules/fetch-allowed-fields/fetch-allowed-fields.js +34 -19
- package/dist/permissions/modules/fetch-global-access/fetch-global-access.js +33 -26
- package/dist/permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.js +38 -25
- package/dist/permissions/modules/fetch-policies-ip-access/fetch-policies-ip-access.js +27 -27
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-children.js +33 -48
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-query.js +55 -55
- package/dist/permissions/modules/process-ast/lib/field-map-from-ast.js +15 -7
- package/dist/permissions/modules/process-ast/lib/get-cases.js +30 -39
- package/dist/permissions/modules/process-ast/lib/inject-cases.js +44 -50
- package/dist/permissions/modules/process-ast/process-ast.js +45 -38
- package/dist/permissions/modules/process-ast/types.js +1 -1
- package/dist/permissions/modules/process-ast/utils/collections-in-field-map.js +10 -6
- package/dist/permissions/modules/process-ast/utils/context-has-dynamic-variables.js +6 -2
- package/dist/permissions/modules/process-ast/utils/dedupe-access.js +32 -28
- package/dist/permissions/modules/process-ast/utils/extract-paths-from-query.js +54 -58
- package/dist/permissions/modules/process-ast/utils/find-related-collection.js +12 -8
- package/dist/permissions/modules/process-ast/utils/flatten-filter.js +30 -33
- package/dist/permissions/modules/process-ast/utils/format-a2o-key.js +6 -2
- package/dist/permissions/modules/process-ast/utils/get-info-for-path.js +13 -6
- package/dist/permissions/modules/process-ast/utils/has-item-permissions.js +6 -2
- package/dist/permissions/modules/process-ast/utils/stringify-query-path.js +6 -2
- package/dist/permissions/modules/process-ast/utils/validate-path/create-error.js +13 -14
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-existence.js +16 -11
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-permissions.js +28 -27
- package/dist/permissions/modules/process-payload/lib/is-field-nullable.js +13 -10
- package/dist/permissions/modules/process-payload/process-payload.js +77 -82
- package/dist/permissions/modules/validate-access/lib/validate-collection-access.js +19 -9
- package/dist/permissions/modules/validate-access/lib/validate-item-access.js +108 -99
- package/dist/permissions/modules/validate-access/validate-access.js +33 -39
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-count.js +10 -7
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-users.js +14 -9
- package/dist/permissions/types.js +1 -1
- package/dist/permissions/utils/create-default-accountability.js +14 -10
- package/dist/permissions/utils/default-permission.js +10 -6
- package/dist/permissions/utils/extract-required-dynamic-variable-context.js +47 -42
- package/dist/permissions/utils/fetch-dynamic-variable-data.js +62 -69
- package/dist/permissions/utils/fetch-raw-permissions.js +33 -37
- package/dist/permissions/utils/fetch-share-info.js +17 -8
- package/dist/permissions/utils/filter-policies-by-ip.js +16 -14
- package/dist/permissions/utils/get-permissions-for-share.js +163 -176
- package/dist/permissions/utils/get-unaliased-field-key.js +21 -23
- package/dist/permissions/utils/merge-fields.js +23 -28
- package/dist/permissions/utils/merge-permissions.js +78 -104
- package/dist/permissions/utils/process-permissions.js +15 -10
- package/dist/permissions/utils/with-cache.js +30 -25
- package/dist/rate-limiter.js +28 -26
- package/dist/redis/index.js +5 -3
- package/dist/redis/lib/create-redis.js +15 -10
- package/dist/redis/lib/use-redis.js +21 -19
- package/dist/redis/utils/redis-config-available.js +14 -9
- package/dist/request/agent-with-ip-validation.js +27 -35
- package/dist/request/index.js +19 -14
- package/dist/request/is-denied-ip.js +41 -39
- package/dist/schedules/metrics.js +45 -42
- package/dist/schedules/project.js +26 -25
- package/dist/schedules/retention.js +105 -106
- package/dist/schedules/telemetry.js +30 -26
- package/dist/schedules/tus.js +24 -21
- package/dist/server.js +155 -151
- package/dist/services/access.js +43 -43
- package/dist/services/activity.js +11 -6
- package/dist/services/assets/name-deduper.js +28 -23
- package/dist/services/assets.js +292 -300
- package/dist/services/authentication.js +410 -444
- package/dist/services/collections.js +592 -646
- package/dist/services/comments.js +143 -132
- package/dist/services/dashboards.js +11 -6
- package/dist/services/deployment-projects.js +135 -138
- package/dist/services/deployment-runs.js +87 -92
- package/dist/services/deployment.js +459 -449
- package/dist/services/extensions.js +211 -227
- package/dist/services/fields/build-collection-and-field-relations.js +53 -53
- package/dist/services/fields/get-collection-meta-updates.js +68 -69
- package/dist/services/fields/get-collection-relation-list.js +26 -26
- package/dist/services/fields.js +732 -810
- package/dist/services/files/lib/extract-metadata.js +34 -31
- package/dist/services/files/lib/get-sharp-instance.js +14 -9
- package/dist/services/files/utils/get-metadata.js +101 -105
- package/dist/services/files/utils/parse-image-metadata.js +70 -64
- package/dist/services/files.js +409 -328
- package/dist/services/flows.js +34 -27
- package/dist/services/folders.js +83 -81
- package/dist/services/graphql/errors/execution.js +7 -2
- package/dist/services/graphql/errors/format.js +16 -11
- package/dist/services/graphql/errors/index.js +4 -2
- package/dist/services/graphql/errors/validation.js +7 -2
- package/dist/services/graphql/index.js +95 -94
- package/dist/services/graphql/resolvers/get-collection-type.js +34 -33
- package/dist/services/graphql/resolvers/get-field-type.js +51 -50
- package/dist/services/graphql/resolvers/get-relation-type.js +41 -38
- package/dist/services/graphql/resolvers/mutation.js +68 -73
- package/dist/services/graphql/resolvers/query.js +68 -68
- package/dist/services/graphql/resolvers/system-admin.js +279 -286
- package/dist/services/graphql/resolvers/system-global.js +414 -432
- package/dist/services/graphql/resolvers/system.js +406 -459
- package/dist/services/graphql/schema/get-types.js +182 -220
- package/dist/services/graphql/schema/index.js +189 -185
- package/dist/services/graphql/schema/parse-args.js +28 -33
- package/dist/services/graphql/schema/parse-query.js +106 -103
- package/dist/services/graphql/schema/read.js +451 -735
- package/dist/services/graphql/schema/write.js +119 -141
- package/dist/services/graphql/schema-cache.js +13 -7
- package/dist/services/graphql/subscription.js +91 -94
- package/dist/services/graphql/types/bigint.js +41 -42
- package/dist/services/graphql/types/date.js +10 -5
- package/dist/services/graphql/types/geojson.js +11 -6
- package/dist/services/graphql/types/hash.js +10 -5
- package/dist/services/graphql/types/string-or-float.js +31 -29
- package/dist/services/graphql/types/void.js +18 -13
- package/dist/services/graphql/utils/add-path-to-validation-error.js +18 -14
- package/dist/services/graphql/utils/aggregate-query.js +33 -37
- package/dist/services/graphql/utils/dedupe-resolvers.js +62 -0
- package/dist/services/graphql/utils/filter-replace-m2a.js +66 -63
- package/dist/services/graphql/utils/process-error.js +40 -41
- package/dist/services/graphql/utils/replace-fragments.js +30 -19
- package/dist/services/graphql/utils/replace-funcs.js +23 -19
- package/dist/services/graphql/utils/sanitize-gql-schema.js +79 -73
- package/dist/services/import-export.js +671 -633
- package/dist/services/index.js +95 -41
- package/dist/services/items.js +854 -945
- package/dist/services/mail/index.js +106 -104
- package/dist/services/mail/rate-limiter.js +26 -25
- package/dist/services/meta.js +71 -63
- package/dist/services/notifications.js +66 -58
- package/dist/services/operations.js +30 -25
- package/dist/services/panels.js +11 -6
- package/dist/services/payload.js +745 -832
- package/dist/services/permissions.js +143 -132
- package/dist/services/policies.js +74 -87
- package/dist/services/presets.js +11 -6
- package/dist/services/relations.js +438 -494
- package/dist/services/revisions.js +50 -44
- package/dist/services/roles.js +81 -87
- package/dist/services/schema.js +50 -52
- package/dist/services/server.js +320 -384
- package/dist/services/settings.js +31 -21
- package/dist/services/shares.js +138 -141
- package/dist/services/specifications.js +396 -526
- package/dist/services/tfa.js +64 -65
- package/dist/services/translations.js +46 -36
- package/dist/services/tus/data-store.js +186 -214
- package/dist/services/tus/index.js +4 -2
- package/dist/services/tus/lockers.js +77 -81
- package/dist/services/tus/server.js +109 -113
- package/dist/services/tus/utils/wait-timeout.js +16 -12
- package/dist/services/users.js +490 -525
- package/dist/services/utils.js +102 -129
- package/dist/services/versions.js +303 -314
- package/dist/services/websocket.js +45 -36
- package/dist/start.js +6 -1
- package/dist/storage/get-storage-driver.js +18 -15
- package/dist/storage/index.js +18 -16
- package/dist/storage/register-drivers.js +20 -17
- package/dist/storage/register-locations.js +28 -17
- package/dist/synchronization.js +106 -103
- package/dist/telemetry/counter/use-buffered-counter.js +138 -0
- package/dist/telemetry/counter/use-counters.js +32 -0
- package/dist/telemetry/index.js +5 -3
- package/dist/telemetry/lib/get-report.js +72 -58
- package/dist/telemetry/lib/send-report.js +24 -23
- package/dist/telemetry/lib/track.js +32 -28
- package/dist/telemetry/types/report.js +1 -1
- package/dist/telemetry/utils/check-user-limits.js +20 -16
- package/dist/telemetry/utils/format-api-request-counts.js +26 -0
- package/dist/telemetry/utils/get-extension-count.js +21 -18
- package/dist/telemetry/utils/get-field-count.js +12 -11
- package/dist/telemetry/utils/get-filesize-sum.js +9 -6
- package/dist/telemetry/utils/get-item-count.js +40 -34
- package/dist/telemetry/utils/get-random-wait-time.js +8 -4
- package/dist/telemetry/utils/get-settings.js +37 -34
- package/dist/telemetry/utils/get-user-item-count.js +24 -18
- package/dist/telemetry/utils/should-check-user-limits.js +14 -11
- package/dist/test-utils/README.md +316 -5
- package/dist/test-utils/cache.js +62 -57
- package/dist/test-utils/controllers.js +94 -93
- package/dist/test-utils/database.js +50 -50
- package/dist/test-utils/emitter.js +36 -36
- package/dist/test-utils/env.js +77 -0
- package/dist/test-utils/knex.js +208 -254
- package/dist/test-utils/schema.js +33 -33
- package/dist/test-utils/services/fields-service.js +36 -35
- package/dist/test-utils/services/files-service.js +33 -32
- package/dist/test-utils/services/folders-service.js +32 -31
- package/dist/test-utils/services/items-service.js +50 -35
- package/dist/test-utils/storage.js +150 -0
- package/dist/types/ast.js +1 -1
- package/dist/types/auth.js +1 -1
- package/dist/types/collection.js +1 -1
- package/dist/types/events.js +1 -1
- package/dist/types/index.js +9 -7
- package/dist/types/meta.js +9 -5
- package/dist/types/migration.js +1 -1
- package/dist/types/revision.js +1 -1
- package/dist/types/rolemap.js +1 -1
- package/dist/utils/apply-diff.js +276 -291
- package/dist/utils/apply-snapshot.js +27 -13
- package/dist/utils/async-handler.js +5 -1
- package/dist/utils/calculate-field-depth.js +70 -69
- package/dist/utils/compress.js +13 -10
- package/dist/utils/construct-flow-tree.js +29 -24
- package/dist/utils/create-admin.js +54 -46
- package/dist/utils/deep-map-response.js +64 -59
- package/dist/utils/delete-from-require-cache.js +15 -11
- package/dist/utils/destroy-piped-stream.js +13 -0
- package/dist/utils/encrypt.js +59 -59
- package/dist/utils/fetch-user-count/fetch-access-lookup.js +22 -22
- package/dist/utils/fetch-user-count/fetch-access-roles.js +31 -35
- package/dist/utils/fetch-user-count/fetch-active-users.js +6 -2
- package/dist/utils/fetch-user-count/fetch-user-count.js +56 -62
- package/dist/utils/fetch-user-count/get-user-count-query.js +19 -16
- package/dist/utils/filter-items.js +27 -30
- package/dist/utils/freeze-schema.js +28 -29
- package/dist/utils/generate-hash.js +11 -8
- package/dist/utils/generate-translations.js +436 -0
- package/dist/utils/get-accountability-for-role.js +35 -30
- package/dist/utils/get-accountability-for-token.js +50 -53
- package/dist/utils/get-address.js +20 -17
- package/dist/utils/get-allowed-log-levels.js +12 -9
- package/dist/utils/get-auth-providers.js +30 -23
- package/dist/utils/get-cache-headers.js +30 -37
- package/dist/utils/get-cache-key.js +29 -26
- package/dist/utils/get-collection-from-alias.js +14 -10
- package/dist/utils/get-column-path.js +62 -61
- package/dist/utils/get-config-from-env.js +43 -45
- package/dist/utils/get-default-index-name.js +23 -20
- package/dist/utils/get-default-value.js +43 -52
- package/dist/utils/get-field-relational-depth.js +24 -20
- package/dist/utils/get-field-system-rows.js +19 -16
- package/dist/utils/get-graphql-query-and-variables.js +9 -4
- package/dist/utils/get-graphql-type.js +32 -38
- package/dist/utils/get-ip-from-req.js +38 -42
- package/dist/utils/get-local-type.js +119 -129
- package/dist/utils/get-milliseconds.js +13 -8
- package/dist/utils/get-module-default.js +9 -5
- package/dist/utils/get-schema.js +160 -165
- package/dist/utils/get-secret.js +18 -13
- package/dist/utils/get-service.js +63 -59
- package/dist/utils/get-snapshot-diff.js +106 -134
- package/dist/utils/get-snapshot.js +70 -55
- package/dist/utils/get-string-byte-size.js +8 -4
- package/dist/utils/get-versioned-hash.js +12 -4
- package/dist/utils/import-file-url.js +10 -5
- package/dist/utils/is-directus-jwt.js +17 -14
- package/dist/utils/is-field-allowed.js +11 -7
- package/dist/utils/is-url-allowed.js +29 -29
- package/dist/utils/is-valid-uuid.js +22 -18
- package/dist/utils/job-queue.js +29 -25
- package/dist/utils/jwt.js +30 -27
- package/dist/utils/md.js +12 -7
- package/dist/utils/parse-filter-key.js +21 -14
- package/dist/utils/parse-numeric-string.js +20 -20
- package/dist/utils/parse-value.js +12 -9
- package/dist/utils/permissions-cacheable.js +45 -37
- package/dist/utils/redact-object.js +120 -125
- package/dist/utils/reduce-schema.js +53 -60
- package/dist/utils/require-text.js +8 -3
- package/dist/utils/require-yaml.js +10 -5
- package/dist/utils/sanitize-query.js +195 -213
- package/dist/utils/sanitize-schema.js +102 -83
- package/dist/utils/schedule.js +28 -24
- package/dist/utils/should-clear-cache.js +23 -18
- package/dist/utils/should-skip-cache.js +39 -40
- package/dist/utils/split-fields.js +33 -30
- package/dist/utils/stall.js +36 -32
- package/dist/utils/store.js +40 -0
- package/dist/utils/transaction.js +82 -81
- package/dist/utils/transformations.js +125 -129
- package/dist/utils/translations-shared.js +56 -0
- package/dist/utils/translations-validation.js +9 -0
- package/dist/utils/url.js +67 -66
- package/dist/utils/user-name.js +18 -14
- package/dist/utils/validate-diff.js +124 -150
- package/dist/utils/validate-env.js +16 -11
- package/dist/utils/validate-keys.js +22 -19
- package/dist/utils/validate-query.js +185 -198
- package/dist/utils/validate-snapshot.js +63 -73
- package/dist/utils/validate-storage.js +37 -35
- package/dist/utils/validate-user-count-integrity.js +28 -20
- package/dist/utils/verify-session-jwt.js +21 -21
- package/dist/utils/versioning/handle-version.js +96 -95
- package/dist/utils/versioning/merge-version-data.js +14 -9
- package/dist/utils/versioning/split-recursive.js +40 -26
- package/dist/websocket/authenticate.js +67 -66
- package/dist/websocket/collab/calculate-cache-metadata.js +99 -118
- package/dist/websocket/collab/collab.js +420 -479
- package/dist/websocket/collab/constants.js +16 -12
- package/dist/websocket/collab/filter-to-fields.js +18 -10
- package/dist/websocket/collab/messenger.js +252 -224
- package/dist/websocket/collab/payload-permissions.js +140 -149
- package/dist/websocket/collab/permissions-cache.js +188 -202
- package/dist/websocket/collab/room.js +569 -588
- package/dist/websocket/collab/store.js +9 -31
- package/dist/websocket/collab/types.js +1 -1
- package/dist/websocket/collab/verify-permissions.js +116 -98
- package/dist/websocket/controllers/base.js +331 -352
- package/dist/websocket/controllers/graphql.js +98 -104
- package/dist/websocket/controllers/hooks.js +117 -118
- package/dist/websocket/controllers/index.js +31 -29
- package/dist/websocket/controllers/logs.js +65 -53
- package/dist/websocket/controllers/rest.js +59 -47
- package/dist/websocket/errors.js +62 -55
- package/dist/websocket/handlers/heartbeat.js +77 -77
- package/dist/websocket/handlers/index.js +36 -35
- package/dist/websocket/handlers/items.js +111 -109
- package/dist/websocket/handlers/logs.js +122 -120
- package/dist/websocket/handlers/subscribe.js +165 -182
- package/dist/websocket/messages.js +90 -93
- package/dist/websocket/types.js +1 -1
- package/dist/websocket/utils/get-expires-at-for-token.js +12 -7
- package/dist/websocket/utils/items.js +123 -123
- package/dist/websocket/utils/message.js +26 -24
- package/dist/websocket/utils/wait-for-message.js +46 -43
- package/package.json +35 -32
- package/dist/ai/chat/constants/system-prompt.d.ts +0 -1
- package/dist/ai/chat/controllers/chat.post.d.ts +0 -2
- package/dist/ai/chat/lib/create-ui-stream.d.ts +0 -16
- package/dist/ai/chat/lib/transform-file-parts.d.ts +0 -12
- package/dist/ai/chat/middleware/load-settings.d.ts +0 -2
- package/dist/ai/chat/models/chat-request.d.ts +0 -167
- package/dist/ai/chat/models/providers.d.ts +0 -23
- package/dist/ai/chat/router.d.ts +0 -1
- package/dist/ai/chat/utils/chat-request-tool-to-ai-sdk-tool.d.ts +0 -9
- package/dist/ai/chat/utils/fix-error-tool-calls.d.ts +0 -12
- package/dist/ai/chat/utils/format-context.d.ts +0 -5
- package/dist/ai/chat/utils/parse-json-schema-7.d.ts +0 -13
- package/dist/ai/files/adapters/anthropic.d.ts +0 -3
- package/dist/ai/files/adapters/google.d.ts +0 -3
- package/dist/ai/files/adapters/index.d.ts +0 -3
- package/dist/ai/files/adapters/openai.d.ts +0 -3
- package/dist/ai/files/controllers/upload.d.ts +0 -2
- package/dist/ai/files/lib/fetch-provider.d.ts +0 -1
- package/dist/ai/files/lib/upload-to-provider.d.ts +0 -4
- package/dist/ai/files/router.d.ts +0 -1
- package/dist/ai/files/types.d.ts +0 -5
- package/dist/ai/mcp/index.d.ts +0 -1
- package/dist/ai/mcp/server.d.ts +0 -126
- package/dist/ai/mcp/transport.d.ts +0 -13
- package/dist/ai/mcp/types.d.ts +0 -15
- package/dist/ai/providers/anthropic-file-support.d.ts +0 -12
- package/dist/ai/providers/index.d.ts +0 -3
- package/dist/ai/providers/options.d.ts +0 -14
- package/dist/ai/providers/registry.d.ts +0 -6
- package/dist/ai/providers/types.d.ts +0 -34
- package/dist/ai/tools/assets/index.d.ts +0 -3
- package/dist/ai/tools/collections/index.d.ts +0 -84
- package/dist/ai/tools/define-tool.d.ts +0 -2
- package/dist/ai/tools/fields/index.d.ts +0 -101
- package/dist/ai/tools/files/index.d.ts +0 -235
- package/dist/ai/tools/flows/index.d.ts +0 -323
- package/dist/ai/tools/folders/index.d.ts +0 -95
- package/dist/ai/tools/index.d.ts +0 -15
- package/dist/ai/tools/items/index.d.ts +0 -87
- package/dist/ai/tools/operations/index.d.ts +0 -217
- package/dist/ai/tools/relations/index.d.ts +0 -73
- package/dist/ai/tools/schema/index.d.ts +0 -54
- package/dist/ai/tools/schema.d.ts +0 -485
- package/dist/ai/tools/system/index.d.ts +0 -3
- package/dist/ai/tools/trigger-flow/index.d.ts +0 -8
- package/dist/ai/tools/types.d.ts +0 -40
- package/dist/ai/tools/utils.d.ts +0 -9
- package/dist/app.d.ts +0 -2
- package/dist/auth/auth.d.ts +0 -47
- package/dist/auth/drivers/index.d.ts +0 -5
- package/dist/auth/drivers/ldap.d.ts +0 -18
- package/dist/auth/drivers/local.d.ts +0 -9
- package/dist/auth/drivers/oauth2.d.ts +0 -18
- package/dist/auth/drivers/openid.d.ts +0 -19
- package/dist/auth/drivers/saml.d.ts +0 -13
- package/dist/auth/utils/generate-callback-url.d.ts +0 -11
- package/dist/auth/utils/resolve-login-redirect.d.ts +0 -11
- package/dist/auth.d.ts +0 -3
- package/dist/bus/index.d.ts +0 -1
- package/dist/bus/lib/use-bus.d.ts +0 -9
- package/dist/cache.d.ts +0 -31
- package/dist/cli/commands/bootstrap/index.d.ts +0 -3
- package/dist/cli/commands/count/index.d.ts +0 -1
- package/dist/cli/commands/database/install.d.ts +0 -1
- package/dist/cli/commands/database/migrate.d.ts +0 -1
- package/dist/cli/commands/init/index.d.ts +0 -1
- package/dist/cli/commands/init/questions.d.ts +0 -21
- package/dist/cli/commands/roles/create.d.ts +0 -5
- package/dist/cli/commands/schema/apply.d.ts +0 -9
- package/dist/cli/commands/schema/snapshot.d.ts +0 -4
- package/dist/cli/commands/security/key.d.ts +0 -1
- package/dist/cli/commands/security/secret.d.ts +0 -1
- package/dist/cli/commands/users/create.d.ts +0 -5
- package/dist/cli/commands/users/passwd.d.ts +0 -4
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/load-extensions.d.ts +0 -1
- package/dist/cli/run.d.ts +0 -1
- package/dist/cli/utils/create-db-connection.d.ts +0 -13
- package/dist/cli/utils/create-env/index.d.ts +0 -3
- package/dist/cli/utils/drivers.d.ts +0 -3
- package/dist/constants.d.ts +0 -30
- package/dist/controllers/access.d.ts +0 -2
- package/dist/controllers/activity.d.ts +0 -2
- package/dist/controllers/assets.d.ts +0 -2
- package/dist/controllers/auth.d.ts +0 -2
- package/dist/controllers/collections.d.ts +0 -2
- package/dist/controllers/comments.d.ts +0 -2
- package/dist/controllers/dashboards.d.ts +0 -2
- package/dist/controllers/deployment-webhooks.d.ts +0 -2
- package/dist/controllers/deployment.d.ts +0 -2
- package/dist/controllers/extensions.d.ts +0 -2
- package/dist/controllers/fields.d.ts +0 -2
- package/dist/controllers/files.d.ts +0 -4
- package/dist/controllers/flows.d.ts +0 -2
- package/dist/controllers/folders.d.ts +0 -2
- package/dist/controllers/graphql.d.ts +0 -2
- package/dist/controllers/items.d.ts +0 -2
- package/dist/controllers/mcp.d.ts +0 -2
- package/dist/controllers/metrics.d.ts +0 -2
- package/dist/controllers/not-found.d.ts +0 -14
- package/dist/controllers/notifications.d.ts +0 -2
- package/dist/controllers/operations.d.ts +0 -2
- package/dist/controllers/panels.d.ts +0 -2
- package/dist/controllers/permissions.d.ts +0 -2
- package/dist/controllers/policies.d.ts +0 -2
- package/dist/controllers/presets.d.ts +0 -2
- package/dist/controllers/relations.d.ts +0 -2
- package/dist/controllers/revisions.d.ts +0 -2
- package/dist/controllers/roles.d.ts +0 -2
- package/dist/controllers/schema.d.ts +0 -2
- package/dist/controllers/server.d.ts +0 -2
- package/dist/controllers/settings.d.ts +0 -2
- package/dist/controllers/shares.d.ts +0 -2
- package/dist/controllers/translations.d.ts +0 -2
- package/dist/controllers/tus.d.ts +0 -2
- package/dist/controllers/users.d.ts +0 -2
- package/dist/controllers/utils.d.ts +0 -2
- package/dist/controllers/versions.d.ts +0 -2
- package/dist/database/errors/dialects/mssql.d.ts +0 -3
- package/dist/database/errors/dialects/mysql.d.ts +0 -3
- package/dist/database/errors/dialects/oracle.d.ts +0 -2
- package/dist/database/errors/dialects/postgres.d.ts +0 -3
- package/dist/database/errors/dialects/sqlite.d.ts +0 -3
- package/dist/database/errors/dialects/types.d.ts +0 -41
- package/dist/database/errors/translate.d.ts +0 -12
- package/dist/database/get-ast-from-query/get-ast-from-query.d.ts +0 -16
- package/dist/database/get-ast-from-query/lib/convert-wildcards.d.ts +0 -15
- package/dist/database/get-ast-from-query/lib/parse-fields.d.ts +0 -17
- package/dist/database/get-ast-from-query/utils/get-allowed-sort.d.ts +0 -9
- package/dist/database/get-ast-from-query/utils/get-deep-query.d.ts +0 -14
- package/dist/database/get-ast-from-query/utils/get-related-collection.d.ts +0 -2
- package/dist/database/helpers/capabilities/dialects/default.d.ts +0 -3
- package/dist/database/helpers/capabilities/dialects/mysql.d.ts +0 -4
- package/dist/database/helpers/capabilities/dialects/postgres.d.ts +0 -5
- package/dist/database/helpers/capabilities/index.d.ts +0 -7
- package/dist/database/helpers/capabilities/types.d.ts +0 -11
- package/dist/database/helpers/date/dialects/default.d.ts +0 -3
- package/dist/database/helpers/date/dialects/mssql.d.ts +0 -4
- package/dist/database/helpers/date/dialects/mysql.d.ts +0 -5
- package/dist/database/helpers/date/dialects/oracle.d.ts +0 -5
- package/dist/database/helpers/date/dialects/sqlite.d.ts +0 -5
- package/dist/database/helpers/date/index.d.ts +0 -7
- package/dist/database/helpers/date/types.d.ts +0 -7
- package/dist/database/helpers/fn/dialects/mssql.d.ts +0 -15
- package/dist/database/helpers/fn/dialects/mysql.d.ts +0 -16
- package/dist/database/helpers/fn/dialects/oracle.d.ts +0 -15
- package/dist/database/helpers/fn/dialects/postgres.d.ts +0 -28
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +0 -15
- package/dist/database/helpers/fn/index.d.ts +0 -7
- package/dist/database/helpers/fn/json/parse-function.d.ts +0 -19
- package/dist/database/helpers/fn/types.d.ts +0 -34
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +0 -14
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +0 -7
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +0 -15
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +0 -10
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +0 -7
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +0 -6
- package/dist/database/helpers/geometry/index.d.ts +0 -7
- package/dist/database/helpers/geometry/types.d.ts +0 -20
- package/dist/database/helpers/index.d.ts +0 -19
- package/dist/database/helpers/number/dialects/default.d.ts +0 -3
- package/dist/database/helpers/number/dialects/mssql.d.ts +0 -7
- package/dist/database/helpers/number/dialects/oracle.d.ts +0 -6
- package/dist/database/helpers/number/dialects/postgres.d.ts +0 -5
- package/dist/database/helpers/number/dialects/sqlite.d.ts +0 -6
- package/dist/database/helpers/number/index.d.ts +0 -7
- package/dist/database/helpers/number/types.d.ts +0 -12
- package/dist/database/helpers/number/utils/decimal-limit.d.ts +0 -4
- package/dist/database/helpers/number/utils/maybe-stringify-big-int.d.ts +0 -1
- package/dist/database/helpers/number/utils/number-in-range.d.ts +0 -3
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +0 -12
- package/dist/database/helpers/schema/dialects/default.d.ts +0 -3
- package/dist/database/helpers/schema/dialects/mssql.d.ts +0 -14
- package/dist/database/helpers/schema/dialects/mysql.d.ts +0 -10
- package/dist/database/helpers/schema/dialects/oracle.d.ts +0 -24
- package/dist/database/helpers/schema/dialects/postgres.d.ts +0 -8
- package/dist/database/helpers/schema/dialects/sqlite.d.ts +0 -8
- package/dist/database/helpers/schema/index.d.ts +0 -7
- package/dist/database/helpers/schema/types.d.ts +0 -63
- package/dist/database/helpers/schema/utils/prep-query-params.d.ts +0 -12
- package/dist/database/helpers/sequence/dialects/default.d.ts +0 -3
- package/dist/database/helpers/sequence/dialects/postgres.d.ts +0 -12
- package/dist/database/helpers/sequence/index.d.ts +0 -7
- package/dist/database/helpers/sequence/types.d.ts +0 -5
- package/dist/database/helpers/types.d.ts +0 -5
- package/dist/database/index.d.ts +0 -15
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +0 -3
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +0 -3
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +0 -3
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +0 -3
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +0 -8
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +0 -3
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +0 -3
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +0 -3
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +0 -3
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +0 -3
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +0 -3
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +0 -3
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +0 -3
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +0 -3
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +0 -3
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +0 -3
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +0 -3
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +0 -3
- package/dist/database/migrations/20210525A-add-insights.d.ts +0 -3
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +0 -3
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +0 -3
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +0 -3
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +0 -3
- package/dist/database/migrations/20210802A-replace-groups.d.ts +0 -3
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +0 -3
- package/dist/database/migrations/20210805A-update-groups.d.ts +0 -3
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +0 -3
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +0 -3
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +0 -3
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +0 -3
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +0 -3
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +0 -3
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +0 -3
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +0 -3
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +0 -3
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +0 -3
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +0 -3
- package/dist/database/migrations/20211007A-update-presets.d.ts +0 -3
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +0 -3
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +0 -3
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +0 -3
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +0 -3
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +0 -3
- package/dist/database/migrations/20211118A-add-notifications.d.ts +0 -3
- package/dist/database/migrations/20211211A-add-shares.d.ts +0 -3
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +0 -3
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +0 -3
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +0 -3
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +0 -3
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +0 -3
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +0 -3
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +0 -3
- package/dist/database/migrations/20220325B-add-default-language.d.ts +0 -3
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +0 -3
- package/dist/database/migrations/20220429A-add-flows.d.ts +0 -3
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +0 -3
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +0 -3
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +0 -3
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +0 -3
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +0 -3
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +0 -3
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +0 -3
- package/dist/database/migrations/20230401A-update-material-icons.d.ts +0 -3
- package/dist/database/migrations/20230525A-add-preview-settings.d.ts +0 -3
- package/dist/database/migrations/20230526A-migrate-translation-strings.d.ts +0 -3
- package/dist/database/migrations/20230721A-require-shares-fields.d.ts +0 -3
- package/dist/database/migrations/20230823A-add-content-versioning.d.ts +0 -3
- package/dist/database/migrations/20230927A-themes.d.ts +0 -3
- package/dist/database/migrations/20231009A-update-csv-fields-to-text.d.ts +0 -3
- package/dist/database/migrations/20231009B-update-panel-options.d.ts +0 -3
- package/dist/database/migrations/20231010A-add-extensions.d.ts +0 -3
- package/dist/database/migrations/20231215A-add-focalpoints.d.ts +0 -3
- package/dist/database/migrations/20240122A-add-report-url-fields.d.ts +0 -3
- package/dist/database/migrations/20240204A-marketplace.d.ts +0 -3
- package/dist/database/migrations/20240305A-change-useragent-type.d.ts +0 -3
- package/dist/database/migrations/20240311A-deprecate-webhooks.d.ts +0 -28
- package/dist/database/migrations/20240422A-public-registration.d.ts +0 -3
- package/dist/database/migrations/20240515A-add-session-window.d.ts +0 -3
- package/dist/database/migrations/20240701A-add-tus-data.d.ts +0 -3
- package/dist/database/migrations/20240716A-update-files-date-fields.d.ts +0 -3
- package/dist/database/migrations/20240806A-permissions-policies.d.ts +0 -3
- package/dist/database/migrations/20240817A-update-icon-fields-length.d.ts +0 -3
- package/dist/database/migrations/20240909A-separate-comments.d.ts +0 -3
- package/dist/database/migrations/20240909B-consolidate-content-versioning.d.ts +0 -3
- package/dist/database/migrations/20240924A-migrate-legacy-comments.d.ts +0 -3
- package/dist/database/migrations/20240924B-populate-versioning-deltas.d.ts +0 -3
- package/dist/database/migrations/20250224A-visual-editor.d.ts +0 -3
- package/dist/database/migrations/20250609A-license-banner.d.ts +0 -3
- package/dist/database/migrations/20250613A-add-project-id.d.ts +0 -3
- package/dist/database/migrations/20250718A-add-direction.d.ts +0 -3
- package/dist/database/migrations/20250813A-add-mcp.d.ts +0 -3
- package/dist/database/migrations/20251012A-add-field-searchable.d.ts +0 -3
- package/dist/database/migrations/20251014A-add-project-owner.d.ts +0 -3
- package/dist/database/migrations/20251028A-add-retention-indexes.d.ts +0 -3
- package/dist/database/migrations/20251103A-add-ai-settings.d.ts +0 -3
- package/dist/database/migrations/20251224A-remove-webhooks.d.ts +0 -3
- package/dist/database/migrations/20260110A-add-ai-provider-settings.d.ts +0 -3
- package/dist/database/migrations/20260113A-add-revisions-index.d.ts +0 -3
- package/dist/database/migrations/20260128A-add-collaborative-editing.d.ts +0 -3
- package/dist/database/migrations/20260204A-add-deployment.d.ts +0 -3
- package/dist/database/migrations/20260211A-add-deployment-webhooks.d.ts +0 -3
- package/dist/database/migrations/run.d.ts +0 -2
- package/dist/database/run-ast/lib/apply-query/add-join.d.ts +0 -54
- package/dist/database/run-ast/lib/apply-query/aggregate.d.ts +0 -3
- package/dist/database/run-ast/lib/apply-query/filter/get-filter-type.d.ts +0 -8
- package/dist/database/run-ast/lib/apply-query/filter/index.d.ts +0 -8
- package/dist/database/run-ast/lib/apply-query/filter/operator.d.ts +0 -3
- package/dist/database/run-ast/lib/apply-query/filter/validate-operator.d.ts +0 -2
- package/dist/database/run-ast/lib/apply-query/get-filter-path.d.ts +0 -1
- package/dist/database/run-ast/lib/apply-query/get-operation.d.ts +0 -7
- package/dist/database/run-ast/lib/apply-query/index.d.ts +0 -19
- package/dist/database/run-ast/lib/apply-query/join-filter-with-cases.d.ts +0 -2
- package/dist/database/run-ast/lib/apply-query/mock.d.ts +0 -3
- package/dist/database/run-ast/lib/apply-query/pagination.d.ts +0 -3
- package/dist/database/run-ast/lib/apply-query/search.d.ts +0 -4
- package/dist/database/run-ast/lib/apply-query/sort.d.ts +0 -19
- package/dist/database/run-ast/lib/get-db-query.d.ts +0 -14
- package/dist/database/run-ast/lib/parse-current-level.d.ts +0 -7
- package/dist/database/run-ast/modules/fetch-permitted-ast-root-fields.d.ts +0 -15
- package/dist/database/run-ast/run-ast.d.ts +0 -7
- package/dist/database/run-ast/types.d.ts +0 -20
- package/dist/database/run-ast/utils/apply-case-when.d.ts +0 -17
- package/dist/database/run-ast/utils/apply-function-to-column-name.d.ts +0 -12
- package/dist/database/run-ast/utils/apply-parent-filters.d.ts +0 -3
- package/dist/database/run-ast/utils/generate-alias.d.ts +0 -6
- package/dist/database/run-ast/utils/get-column-pre-processor.d.ts +0 -10
- package/dist/database/run-ast/utils/get-column.d.ts +0 -25
- package/dist/database/run-ast/utils/get-field-alias.d.ts +0 -2
- package/dist/database/run-ast/utils/get-inner-query-column-pre-processor.d.ts +0 -5
- package/dist/database/run-ast/utils/merge-with-parent-items.d.ts +0 -3
- package/dist/database/run-ast/utils/remove-temporary-fields.d.ts +0 -3
- package/dist/database/run-ast/utils/with-preprocess-bindings.d.ts +0 -2
- package/dist/database/seeds/run.d.ts +0 -2
- package/dist/deployment/deployment.d.ts +0 -117
- package/dist/deployment/drivers/index.d.ts +0 -2
- package/dist/deployment/drivers/netlify.d.ts +0 -37
- package/dist/deployment/drivers/vercel.d.ts +0 -35
- package/dist/deployment/index.d.ts +0 -2
- package/dist/deployment.d.ts +0 -29
- package/dist/emitter.d.ts +0 -21
- package/dist/extensions/index.d.ts +0 -2
- package/dist/extensions/lib/get-extensions-path.d.ts +0 -1
- package/dist/extensions/lib/get-extensions-settings.d.ts +0 -11
- package/dist/extensions/lib/get-extensions.d.ts +0 -5
- package/dist/extensions/lib/get-shared-deps-mapping.d.ts +0 -1
- package/dist/extensions/lib/installation/index.d.ts +0 -2
- package/dist/extensions/lib/installation/manager.d.ts +0 -5
- package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.d.ts +0 -28
- package/dist/extensions/lib/sandbox/generate-host-function-reference.d.ts +0 -11
- package/dist/extensions/lib/sandbox/register/action.d.ts +0 -6
- package/dist/extensions/lib/sandbox/register/call-reference.d.ts +0 -5
- package/dist/extensions/lib/sandbox/register/filter.d.ts +0 -6
- package/dist/extensions/lib/sandbox/register/index.d.ts +0 -5
- package/dist/extensions/lib/sandbox/register/operation.d.ts +0 -6
- package/dist/extensions/lib/sandbox/register/route.d.ts +0 -17
- package/dist/extensions/lib/sandbox/sdk/generators/index.d.ts +0 -3
- package/dist/extensions/lib/sandbox/sdk/generators/log.d.ts +0 -3
- package/dist/extensions/lib/sandbox/sdk/generators/request.d.ts +0 -12
- package/dist/extensions/lib/sandbox/sdk/generators/sleep.d.ts +0 -3
- package/dist/extensions/lib/sandbox/sdk/index.d.ts +0 -2
- package/dist/extensions/lib/sandbox/sdk/instantiate.d.ts +0 -11
- package/dist/extensions/lib/sandbox/sdk/sdk.d.ts +0 -20
- package/dist/extensions/lib/sandbox/sdk/utils/index.d.ts +0 -1
- package/dist/extensions/lib/sandbox/sdk/utils/wrap.d.ts +0 -13
- package/dist/extensions/lib/sync/status.d.ts +0 -11
- package/dist/extensions/lib/sync/sync.d.ts +0 -6
- package/dist/extensions/lib/sync/tracker.d.ts +0 -18
- package/dist/extensions/lib/sync/utils.d.ts +0 -24
- package/dist/extensions/lib/wrap-embeds.d.ts +0 -4
- package/dist/extensions/manager.d.ts +0 -164
- package/dist/flows.d.ts +0 -29
- package/dist/index.d.ts +0 -1
- package/dist/lock/index.d.ts +0 -1
- package/dist/lock/lib/use-lock.d.ts +0 -8
- package/dist/logger/index.d.ts +0 -14
- package/dist/logger/logs-stream.d.ts +0 -10
- package/dist/logger/redact-query.d.ts +0 -1
- package/dist/mailer.d.ts +0 -2
- package/dist/metrics/index.d.ts +0 -1
- package/dist/metrics/lib/create-metrics.d.ts +0 -15
- package/dist/metrics/lib/use-metrics.d.ts +0 -17
- package/dist/metrics/types/metric.d.ts +0 -1
- package/dist/middleware/authenticate.d.ts +0 -7
- package/dist/middleware/cache.d.ts +0 -3
- package/dist/middleware/collection-exists.d.ts +0 -6
- package/dist/middleware/cors.d.ts +0 -3
- package/dist/middleware/error-handler.d.ts +0 -2
- package/dist/middleware/extract-token.d.ts +0 -12
- package/dist/middleware/graphql.d.ts +0 -2
- package/dist/middleware/rate-limiter-global.d.ts +0 -5
- package/dist/middleware/rate-limiter-ip.d.ts +0 -5
- package/dist/middleware/rate-limiter-registration.d.ts +0 -5
- package/dist/middleware/respond.d.ts +0 -2
- package/dist/middleware/sanitize-query.d.ts +0 -7
- package/dist/middleware/schema.d.ts +0 -3
- package/dist/middleware/use-collection.d.ts +0 -7
- package/dist/middleware/validate-batch.d.ts +0 -1
- package/dist/operations/condition/index.d.ts +0 -6
- package/dist/operations/exec/index.d.ts +0 -5
- package/dist/operations/item-create/index.d.ts +0 -8
- package/dist/operations/item-delete/index.d.ts +0 -10
- package/dist/operations/item-read/index.d.ts +0 -10
- package/dist/operations/item-update/index.d.ts +0 -11
- package/dist/operations/json-web-token/index.d.ts +0 -10
- package/dist/operations/log/index.d.ts +0 -5
- package/dist/operations/mail/index.d.ts +0 -13
- package/dist/operations/mail/rate-limiter.d.ts +0 -1
- package/dist/operations/notification/index.d.ts +0 -10
- package/dist/operations/request/index.d.ts +0 -11
- package/dist/operations/sleep/index.d.ts +0 -5
- package/dist/operations/throw-error/index.d.ts +0 -7
- package/dist/operations/transform/index.d.ts +0 -5
- package/dist/operations/trigger/index.d.ts +0 -8
- package/dist/permissions/cache.d.ts +0 -2
- package/dist/permissions/lib/fetch-permissions.d.ts +0 -20
- package/dist/permissions/lib/fetch-policies.d.ts +0 -14
- package/dist/permissions/lib/fetch-roles-tree.d.ts +0 -6
- package/dist/permissions/lib/with-app-minimal-permissions.d.ts +0 -2
- package/dist/permissions/modules/fetch-accountability-collection-access/fetch-accountability-collection-access.d.ts +0 -7
- package/dist/permissions/modules/fetch-accountability-policy-globals/fetch-accountability-policy-globals.d.ts +0 -3
- package/dist/permissions/modules/fetch-allowed-collections/fetch-allowed-collections.d.ts +0 -7
- package/dist/permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.d.ts +0 -8
- package/dist/permissions/modules/fetch-allowed-fields/fetch-allowed-fields.d.ts +0 -15
- package/dist/permissions/modules/fetch-global-access/fetch-global-access.d.ts +0 -12
- package/dist/permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.d.ts +0 -11
- package/dist/permissions/modules/fetch-policies-ip-access/fetch-policies-ip-access.d.ts +0 -4
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-children.d.ts +0 -4
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-query.d.ts +0 -3
- package/dist/permissions/modules/process-ast/lib/field-map-from-ast.d.ts +0 -4
- package/dist/permissions/modules/process-ast/lib/get-cases.d.ts +0 -6
- package/dist/permissions/modules/process-ast/lib/inject-cases.d.ts +0 -9
- package/dist/permissions/modules/process-ast/process-ast.d.ts +0 -9
- package/dist/permissions/modules/process-ast/types.d.ts +0 -18
- package/dist/permissions/modules/process-ast/utils/collections-in-field-map.d.ts +0 -2
- package/dist/permissions/modules/process-ast/utils/context-has-dynamic-variables.d.ts +0 -2
- package/dist/permissions/modules/process-ast/utils/dedupe-access.d.ts +0 -12
- package/dist/permissions/modules/process-ast/utils/extract-paths-from-query.d.ts +0 -15
- package/dist/permissions/modules/process-ast/utils/find-related-collection.d.ts +0 -3
- package/dist/permissions/modules/process-ast/utils/flatten-filter.d.ts +0 -3
- package/dist/permissions/modules/process-ast/utils/format-a2o-key.d.ts +0 -1
- package/dist/permissions/modules/process-ast/utils/get-info-for-path.d.ts +0 -5
- package/dist/permissions/modules/process-ast/utils/has-item-permissions.d.ts +0 -2
- package/dist/permissions/modules/process-ast/utils/stringify-query-path.d.ts +0 -2
- package/dist/permissions/modules/process-ast/utils/validate-path/create-error.d.ts +0 -3
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-existence.d.ts +0 -2
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-permissions.d.ts +0 -2
- package/dist/permissions/modules/process-payload/lib/is-field-nullable.d.ts +0 -5
- package/dist/permissions/modules/process-payload/process-payload.d.ts +0 -14
- package/dist/permissions/modules/validate-access/lib/validate-collection-access.d.ts +0 -12
- package/dist/permissions/modules/validate-access/lib/validate-item-access.d.ts +0 -22
- package/dist/permissions/modules/validate-access/validate-access.d.ts +0 -16
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-count.d.ts +0 -1
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-users.d.ts +0 -4
- package/dist/permissions/types.d.ts +0 -7
- package/dist/permissions/utils/create-default-accountability.d.ts +0 -2
- package/dist/permissions/utils/default-permission.d.ts +0 -7
- package/dist/permissions/utils/extract-required-dynamic-variable-context.d.ts +0 -9
- package/dist/permissions/utils/fetch-dynamic-variable-data.d.ts +0 -9
- package/dist/permissions/utils/fetch-raw-permissions.d.ts +0 -11
- package/dist/permissions/utils/fetch-share-info.d.ts +0 -12
- package/dist/permissions/utils/filter-policies-by-ip.d.ts +0 -2
- package/dist/permissions/utils/get-permissions-for-share.d.ts +0 -4
- package/dist/permissions/utils/get-unaliased-field-key.d.ts +0 -5
- package/dist/permissions/utils/merge-fields.d.ts +0 -1
- package/dist/permissions/utils/merge-permissions.d.ts +0 -9
- package/dist/permissions/utils/process-permissions.d.ts +0 -17
- package/dist/permissions/utils/with-cache.d.ts +0 -12
- package/dist/rate-limiter.d.ts +0 -5
- package/dist/redis/index.d.ts +0 -3
- package/dist/redis/lib/create-redis.d.ts +0 -7
- package/dist/redis/lib/use-redis.d.ts +0 -16
- package/dist/redis/utils/redis-config-available.d.ts +0 -4
- package/dist/request/agent-with-ip-validation.d.ts +0 -10
- package/dist/request/index.d.ts +0 -5
- package/dist/request/is-denied-ip.d.ts +0 -1
- package/dist/schedules/metrics.d.ts +0 -7
- package/dist/schedules/project.d.ts +0 -4
- package/dist/schedules/retention.d.ts +0 -14
- package/dist/schedules/telemetry.d.ts +0 -11
- package/dist/schedules/tus.d.ts +0 -6
- package/dist/server.d.ts +0 -4
- package/dist/services/access.d.ts +0 -9
- package/dist/services/activity.d.ts +0 -5
- package/dist/services/assets/name-deduper.d.ts +0 -7
- package/dist/services/assets.d.ts +0 -35
- package/dist/services/authentication.d.ts +0 -26
- package/dist/services/collections.d.ts +0 -57
- package/dist/services/comments.d.ts +0 -12
- package/dist/services/dashboards.d.ts +0 -5
- package/dist/services/deployment-projects.d.ts +0 -49
- package/dist/services/deployment-runs.d.ts +0 -31
- package/dist/services/deployment.d.ts +0 -81
- package/dist/services/extensions.d.ts +0 -34
- package/dist/services/fields/build-collection-and-field-relations.d.ts +0 -21
- package/dist/services/fields/get-collection-meta-updates.d.ts +0 -11
- package/dist/services/fields/get-collection-relation-list.d.ts +0 -5
- package/dist/services/fields.d.ts +0 -49
- package/dist/services/files/lib/extract-metadata.d.ts +0 -3
- package/dist/services/files/lib/get-sharp-instance.d.ts +0 -2
- package/dist/services/files/utils/get-metadata.d.ts +0 -4
- package/dist/services/files/utils/parse-image-metadata.d.ts +0 -2
- package/dist/services/files.d.ts +0 -31
- package/dist/services/flows.d.ts +0 -8
- package/dist/services/folders.d.ts +0 -30
- package/dist/services/graphql/errors/execution.d.ts +0 -6
- package/dist/services/graphql/errors/format.d.ts +0 -6
- package/dist/services/graphql/errors/index.d.ts +0 -2
- package/dist/services/graphql/errors/validation.d.ts +0 -6
- package/dist/services/graphql/index.d.ts +0 -30
- package/dist/services/graphql/resolvers/get-collection-type.d.ts +0 -3
- package/dist/services/graphql/resolvers/get-field-type.d.ts +0 -3
- package/dist/services/graphql/resolvers/get-relation-type.d.ts +0 -3
- package/dist/services/graphql/resolvers/mutation.d.ts +0 -4
- package/dist/services/graphql/resolvers/query.d.ts +0 -8
- package/dist/services/graphql/resolvers/system-admin.d.ts +0 -5
- package/dist/services/graphql/resolvers/system-global.d.ts +0 -7
- package/dist/services/graphql/resolvers/system.d.ts +0 -5
- package/dist/services/graphql/schema/get-types.d.ts +0 -12
- package/dist/services/graphql/schema/index.d.ts +0 -32
- package/dist/services/graphql/schema/parse-args.d.ts +0 -9
- package/dist/services/graphql/schema/parse-query.d.ts +0 -7
- package/dist/services/graphql/schema/read.d.ts +0 -12
- package/dist/services/graphql/schema/write.d.ts +0 -9
- package/dist/services/graphql/schema-cache.d.ts +0 -3
- package/dist/services/graphql/subscription.d.ts +0 -22
- package/dist/services/graphql/types/bigint.d.ts +0 -2
- package/dist/services/graphql/types/date.d.ts +0 -2
- package/dist/services/graphql/types/geojson.d.ts +0 -2
- package/dist/services/graphql/types/hash.d.ts +0 -2
- package/dist/services/graphql/types/string-or-float.d.ts +0 -5
- package/dist/services/graphql/types/void.d.ts +0 -2
- package/dist/services/graphql/utils/add-path-to-validation-error.d.ts +0 -2
- package/dist/services/graphql/utils/aggregate-query.d.ts +0 -6
- package/dist/services/graphql/utils/filter-replace-m2a.d.ts +0 -7
- package/dist/services/graphql/utils/process-error.d.ts +0 -7
- package/dist/services/graphql/utils/replace-fragments.d.ts +0 -6
- package/dist/services/graphql/utils/replace-funcs.d.ts +0 -5
- package/dist/services/graphql/utils/sanitize-gql-schema.d.ts +0 -8
- package/dist/services/import-export.d.ts +0 -44
- package/dist/services/index.d.ts +0 -41
- package/dist/services/items.d.ts +0 -105
- package/dist/services/mail/index.d.ts +0 -32
- package/dist/services/mail/rate-limiter.d.ts +0 -1
- package/dist/services/meta.d.ts +0 -11
- package/dist/services/notifications.d.ts +0 -7
- package/dist/services/operations.d.ts +0 -8
- package/dist/services/panels.d.ts +0 -5
- package/dist/services/payload.d.ts +0 -77
- package/dist/services/permissions.d.ts +0 -14
- package/dist/services/policies.d.ts +0 -11
- package/dist/services/presets.d.ts +0 -5
- package/dist/services/relations.d.ts +0 -55
- package/dist/services/revisions.d.ts +0 -11
- package/dist/services/roles.d.ts +0 -9
- package/dist/services/schema.d.ts +0 -14
- package/dist/services/server.d.ts +0 -13
- package/dist/services/settings.d.ts +0 -6
- package/dist/services/shares.d.ts +0 -19
- package/dist/services/specifications.d.ts +0 -39
- package/dist/services/tfa.d.ts +0 -12
- package/dist/services/translations.d.ts +0 -8
- package/dist/services/tus/data-store.d.ts +0 -33
- package/dist/services/tus/index.d.ts +0 -2
- package/dist/services/tus/lockers.d.ts +0 -36
- package/dist/services/tus/server.d.ts +0 -8
- package/dist/services/tus/utils/wait-timeout.d.ts +0 -1
- package/dist/services/users.d.ts +0 -54
- package/dist/services/utils.d.ts +0 -15
- package/dist/services/versions.d.ts +0 -19
- package/dist/services/websocket.d.ts +0 -12
- package/dist/start.d.ts +0 -1
- package/dist/storage/get-storage-driver.d.ts +0 -3
- package/dist/storage/index.d.ts +0 -5
- package/dist/storage/register-drivers.d.ts +0 -2
- package/dist/storage/register-locations.d.ts +0 -2
- package/dist/synchronization.d.ts +0 -7
- package/dist/telemetry/index.d.ts +0 -3
- package/dist/telemetry/lib/get-report.d.ts +0 -5
- package/dist/telemetry/lib/send-report.d.ts +0 -10
- package/dist/telemetry/lib/track.d.ts +0 -10
- package/dist/telemetry/types/report.d.ts +0 -102
- package/dist/telemetry/utils/check-user-limits.d.ts +0 -5
- package/dist/telemetry/utils/get-extension-count.d.ts +0 -9
- package/dist/telemetry/utils/get-field-count.d.ts +0 -6
- package/dist/telemetry/utils/get-filesize-sum.d.ts +0 -5
- package/dist/telemetry/utils/get-item-count.d.ts +0 -30
- package/dist/telemetry/utils/get-random-wait-time.d.ts +0 -5
- package/dist/telemetry/utils/get-settings.d.ts +0 -26
- package/dist/telemetry/utils/get-user-item-count.d.ts +0 -13
- package/dist/telemetry/utils/should-check-user-limits.d.ts +0 -4
- package/dist/test-utils/cache.d.ts +0 -51
- package/dist/test-utils/controllers.d.ts +0 -65
- package/dist/test-utils/database.d.ts +0 -48
- package/dist/test-utils/emitter.d.ts +0 -35
- package/dist/test-utils/knex.d.ts +0 -164
- package/dist/test-utils/schema.d.ts +0 -26
- package/dist/test-utils/services/fields-service.d.ts +0 -28
- package/dist/test-utils/services/files-service.d.ts +0 -28
- package/dist/test-utils/services/folders-service.d.ts +0 -28
- package/dist/test-utils/services/items-service.d.ts +0 -23
- package/dist/types/ast.d.ts +0 -100
- package/dist/types/auth.d.ts +0 -42
- package/dist/types/collection.d.ts +0 -9
- package/dist/types/events.d.ts +0 -18
- package/dist/types/index.d.ts +0 -7
- package/dist/types/meta.d.ts +0 -4
- package/dist/types/migration.d.ts +0 -5
- package/dist/types/revision.d.ts +0 -7
- package/dist/types/rolemap.d.ts +0 -3
- package/dist/utils/apply-diff.d.ts +0 -8
- package/dist/utils/apply-snapshot.d.ts +0 -8
- package/dist/utils/async-handler.d.ts +0 -3
- package/dist/utils/calculate-field-depth.d.ts +0 -33
- package/dist/utils/compress.d.ts +0 -2
- package/dist/utils/construct-flow-tree.d.ts +0 -2
- package/dist/utils/create-admin.d.ts +0 -11
- package/dist/utils/deep-map-response.d.ts +0 -17
- package/dist/utils/delete-from-require-cache.d.ts +0 -1
- package/dist/utils/encrypt.d.ts +0 -2
- package/dist/utils/fetch-user-count/fetch-access-lookup.d.ts +0 -19
- package/dist/utils/fetch-user-count/fetch-access-roles.d.ts +0 -16
- package/dist/utils/fetch-user-count/fetch-active-users.d.ts +0 -6
- package/dist/utils/fetch-user-count/fetch-user-count.d.ts +0 -11
- package/dist/utils/fetch-user-count/get-user-count-query.d.ts +0 -20
- package/dist/utils/filter-items.d.ts +0 -2
- package/dist/utils/freeze-schema.d.ts +0 -3
- package/dist/utils/generate-hash.d.ts +0 -1
- package/dist/utils/get-accountability-for-role.d.ts +0 -7
- package/dist/utils/get-accountability-for-token.d.ts +0 -2
- package/dist/utils/get-address.d.ts +0 -2
- package/dist/utils/get-allowed-log-levels.d.ts +0 -3
- package/dist/utils/get-auth-providers.d.ts +0 -10
- package/dist/utils/get-cache-headers.d.ts +0 -10
- package/dist/utils/get-cache-key.d.ts +0 -2
- package/dist/utils/get-collection-from-alias.d.ts +0 -6
- package/dist/utils/get-column-path.d.ts +0 -26
- package/dist/utils/get-config-from-env.d.ts +0 -6
- package/dist/utils/get-default-index-name.d.ts +0 -13
- package/dist/utils/get-default-value.d.ts +0 -5
- package/dist/utils/get-field-relational-depth.d.ts +0 -13
- package/dist/utils/get-field-system-rows.d.ts +0 -2
- package/dist/utils/get-graphql-query-and-variables.d.ts +0 -2
- package/dist/utils/get-graphql-type.d.ts +0 -4
- package/dist/utils/get-ip-from-req.d.ts +0 -3
- package/dist/utils/get-local-type.d.ts +0 -9
- package/dist/utils/get-milliseconds.d.ts +0 -4
- package/dist/utils/get-module-default.d.ts +0 -3
- package/dist/utils/get-schema.d.ts +0 -10
- package/dist/utils/get-secret.d.ts +0 -4
- package/dist/utils/get-service.d.ts +0 -7
- package/dist/utils/get-snapshot-diff.d.ts +0 -2
- package/dist/utils/get-snapshot.d.ts +0 -6
- package/dist/utils/get-string-byte-size.d.ts +0 -4
- package/dist/utils/get-versioned-hash.d.ts +0 -1
- package/dist/utils/import-file-url.d.ts +0 -5
- package/dist/utils/is-directus-jwt.d.ts +0 -5
- package/dist/utils/is-field-allowed.d.ts +0 -4
- package/dist/utils/is-url-allowed.d.ts +0 -4
- package/dist/utils/is-valid-uuid.d.ts +0 -3
- package/dist/utils/job-queue.d.ts +0 -9
- package/dist/utils/jwt.d.ts +0 -3
- package/dist/utils/md.d.ts +0 -4
- package/dist/utils/parse-filter-key.d.ts +0 -7
- package/dist/utils/parse-numeric-string.d.ts +0 -2
- package/dist/utils/parse-value.d.ts +0 -4
- package/dist/utils/permissions-cacheable.d.ts +0 -8
- package/dist/utils/redact-object.d.ts +0 -23
- package/dist/utils/reduce-schema.d.ts +0 -7
- package/dist/utils/require-text.d.ts +0 -1
- package/dist/utils/require-yaml.d.ts +0 -1
- package/dist/utils/sanitize-query.d.ts +0 -5
- package/dist/utils/sanitize-schema.d.ts +0 -33
- package/dist/utils/schedule.d.ts +0 -5
- package/dist/utils/should-clear-cache.d.ts +0 -10
- package/dist/utils/should-skip-cache.d.ts +0 -7
- package/dist/utils/split-fields.d.ts +0 -4
- package/dist/utils/stall.d.ts +0 -26
- package/dist/utils/transaction.d.ts +0 -9
- package/dist/utils/transformations.d.ts +0 -6
- package/dist/utils/url.d.ts +0 -18
- package/dist/utils/user-name.d.ts +0 -2
- package/dist/utils/validate-diff.d.ts +0 -7
- package/dist/utils/validate-env.d.ts +0 -1
- package/dist/utils/validate-keys.d.ts +0 -5
- package/dist/utils/validate-query.d.ts +0 -4
- package/dist/utils/validate-snapshot.d.ts +0 -5
- package/dist/utils/validate-storage.d.ts +0 -1
- package/dist/utils/validate-user-count-integrity.d.ts +0 -6
- package/dist/utils/verify-session-jwt.d.ts +0 -7
- package/dist/utils/versioning/handle-version.d.ts +0 -3
- package/dist/utils/versioning/merge-version-data.d.ts +0 -2
- package/dist/utils/versioning/split-recursive.d.ts +0 -4
- package/dist/websocket/authenticate.d.ts +0 -5
- package/dist/websocket/collab/calculate-cache-metadata.d.ts +0 -9
- package/dist/websocket/collab/collab.d.ts +0 -63
- package/dist/websocket/collab/constants.d.ts +0 -1
- package/dist/websocket/collab/filter-to-fields.d.ts +0 -2
- package/dist/websocket/collab/messenger.d.ts +0 -43
- package/dist/websocket/collab/payload-permissions.d.ts +0 -18
- package/dist/websocket/collab/permissions-cache.d.ts +0 -52
- package/dist/websocket/collab/room.d.ts +0 -125
- package/dist/websocket/collab/store.d.ts +0 -7
- package/dist/websocket/collab/types.d.ts +0 -21
- package/dist/websocket/collab/verify-permissions.d.ts +0 -11
- package/dist/websocket/controllers/base.d.ts +0 -35
- package/dist/websocket/controllers/graphql.d.ts +0 -11
- package/dist/websocket/controllers/hooks.d.ts +0 -1
- package/dist/websocket/controllers/index.d.ts +0 -13
- package/dist/websocket/controllers/logs.d.ts +0 -17
- package/dist/websocket/controllers/rest.d.ts +0 -8
- package/dist/websocket/errors.d.ts +0 -16
- package/dist/websocket/handlers/heartbeat.d.ts +0 -11
- package/dist/websocket/handlers/index.d.ts +0 -7
- package/dist/websocket/handlers/items.d.ts +0 -6
- package/dist/websocket/handlers/logs.d.ts +0 -31
- package/dist/websocket/handlers/subscribe.d.ts +0 -38
- package/dist/websocket/messages.d.ts +0 -114
- package/dist/websocket/types.d.ts +0 -38
- package/dist/websocket/utils/get-expires-at-for-token.d.ts +0 -1
- package/dist/websocket/utils/items.d.ts +0 -43
- package/dist/websocket/utils/message.d.ts +0 -4
- package/dist/websocket/utils/wait-for-message.d.ts +0 -4
|
@@ -0,0 +1,2986 @@
|
|
|
1
|
+
import { assertTypes, createSimpleStackTrace } from "../../../../../@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/helpers.js";
|
|
2
|
+
import { getSafeTimers } from "../../../../../@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/index.js";
|
|
3
|
+
import { fn, isMockFunction, mocks, spyOn } from "../../../../../@vitest_spy@3.2.4/node_modules/@vitest/spy/dist/index.js";
|
|
4
|
+
import "../../../../../@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js";
|
|
5
|
+
import { Assertion, assert, expect, use, utils_exports } from "../../../../../chai@5.3.3/node_modules/chai/index.js";
|
|
6
|
+
import { ASYMMETRIC_MATCHERS_OBJECT, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, customMatchers, equals, getState, iterableEquality, setState, subsetEquality } from "../../../../../@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js";
|
|
7
|
+
import { parseSingleStack } from "../../../../../@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/source-map.js";
|
|
8
|
+
import { getCurrentTest, getNames, getTestName } from "../../../../../@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js";
|
|
9
|
+
import "../../../../../@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/index.js";
|
|
10
|
+
import "../../../../../@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/utils.js";
|
|
11
|
+
import { getCurrentEnvironment, getWorkerState, isChildProcess, resetModules, waitForImportsToResolve } from "./utils.XdZDrNZV.js";
|
|
12
|
+
import { commonjsGlobal, getDefaultExportFromCjs } from "./_commonjsHelpers.BFTU3MAI.js";
|
|
13
|
+
import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../../../../../@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js";
|
|
14
|
+
import { RealDate, mockDate, resetDate } from "./date.Bq6ZW5rf.js";
|
|
15
|
+
|
|
16
|
+
//#region ../node_modules/.pnpm/vitest@3.2.4_@types+node@22.13.14_@vitest+ui@3.2.4_happy-dom@20.0.10_jiti@2.6.1_jsdom@2_4abc0aa80426c2cc5a9175f21e1d4ebb/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
|
17
|
+
const unsupported = [
|
|
18
|
+
"matchSnapshot",
|
|
19
|
+
"toMatchSnapshot",
|
|
20
|
+
"toMatchInlineSnapshot",
|
|
21
|
+
"toThrowErrorMatchingSnapshot",
|
|
22
|
+
"toThrowErrorMatchingInlineSnapshot",
|
|
23
|
+
"throws",
|
|
24
|
+
"Throw",
|
|
25
|
+
"throw",
|
|
26
|
+
"toThrow",
|
|
27
|
+
"toThrowError"
|
|
28
|
+
];
|
|
29
|
+
function createExpectPoll(expect$1) {
|
|
30
|
+
return function poll(fn$1, options = {}) {
|
|
31
|
+
const state = getWorkerState();
|
|
32
|
+
const defaults = state.config.expect?.poll ?? {};
|
|
33
|
+
const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
|
|
34
|
+
const assertion = expect$1(null, message).withContext({ poll: true });
|
|
35
|
+
fn$1 = fn$1.bind(assertion);
|
|
36
|
+
const test = utils_exports.flag(assertion, "vitest-test");
|
|
37
|
+
if (!test) throw new Error("expect.poll() must be called inside a test");
|
|
38
|
+
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
|
39
|
+
const assertionFunction = Reflect.get(target, key, receiver);
|
|
40
|
+
if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
|
|
41
|
+
if (key === "assert") return assertionFunction;
|
|
42
|
+
if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
|
43
|
+
return function(...args) {
|
|
44
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
45
|
+
const promise = () => new Promise((resolve, reject) => {
|
|
46
|
+
let intervalId;
|
|
47
|
+
let timeoutId;
|
|
48
|
+
let lastError;
|
|
49
|
+
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
50
|
+
const check = async () => {
|
|
51
|
+
try {
|
|
52
|
+
utils_exports.flag(assertion, "_name", key);
|
|
53
|
+
const obj = await fn$1();
|
|
54
|
+
utils_exports.flag(assertion, "object", obj);
|
|
55
|
+
resolve(await assertionFunction.call(assertion, ...args));
|
|
56
|
+
clearTimeout(intervalId);
|
|
57
|
+
clearTimeout(timeoutId);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
lastError = err;
|
|
60
|
+
if (!utils_exports.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
timeoutId = setTimeout(() => {
|
|
64
|
+
clearTimeout(intervalId);
|
|
65
|
+
utils_exports.flag(assertion, "_isLastPollAttempt", true);
|
|
66
|
+
const rejectWithCause = (cause) => {
|
|
67
|
+
reject(copyStackTrace$1(new Error("Matcher did not succeed in time.", { cause }), STACK_TRACE_ERROR));
|
|
68
|
+
};
|
|
69
|
+
check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
|
|
70
|
+
}, timeout);
|
|
71
|
+
check();
|
|
72
|
+
});
|
|
73
|
+
let awaited = false;
|
|
74
|
+
test.onFinished ??= [];
|
|
75
|
+
test.onFinished.push(() => {
|
|
76
|
+
if (!awaited) {
|
|
77
|
+
const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
|
|
78
|
+
const name = utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
|
|
79
|
+
const assertionString = `expect.${name}.${negated}${String(key)}()`;
|
|
80
|
+
const error = new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`);
|
|
81
|
+
throw copyStackTrace$1(error, STACK_TRACE_ERROR);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
let resultPromise;
|
|
85
|
+
return {
|
|
86
|
+
then(onFulfilled, onRejected) {
|
|
87
|
+
awaited = true;
|
|
88
|
+
return (resultPromise ||= promise()).then(onFulfilled, onRejected);
|
|
89
|
+
},
|
|
90
|
+
catch(onRejected) {
|
|
91
|
+
return (resultPromise ||= promise()).catch(onRejected);
|
|
92
|
+
},
|
|
93
|
+
finally(onFinally) {
|
|
94
|
+
return (resultPromise ||= promise()).finally(onFinally);
|
|
95
|
+
},
|
|
96
|
+
[Symbol.toStringTag]: "Promise"
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
} });
|
|
100
|
+
return proxy;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function copyStackTrace$1(target, source) {
|
|
104
|
+
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
|
105
|
+
return target;
|
|
106
|
+
}
|
|
107
|
+
function commonjsRequire(path) {
|
|
108
|
+
throw new Error("Could not dynamically require \"" + path + "\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.");
|
|
109
|
+
}
|
|
110
|
+
var chaiSubset$1 = { exports: {} };
|
|
111
|
+
var chaiSubset = chaiSubset$1.exports;
|
|
112
|
+
var hasRequiredChaiSubset;
|
|
113
|
+
function requireChaiSubset() {
|
|
114
|
+
if (hasRequiredChaiSubset) return chaiSubset$1.exports;
|
|
115
|
+
hasRequiredChaiSubset = 1;
|
|
116
|
+
(function(module, exports) {
|
|
117
|
+
(function() {
|
|
118
|
+
(function(chaiSubset$2) {
|
|
119
|
+
if (typeof commonjsRequire === "function" && "object" === "object" && "object" === "object") {
|
|
120
|
+
return module.exports = chaiSubset$2;
|
|
121
|
+
} else {
|
|
122
|
+
return chai.use(chaiSubset$2);
|
|
123
|
+
}
|
|
124
|
+
})(function(chai$1, utils) {
|
|
125
|
+
var Assertion$1 = chai$1.Assertion;
|
|
126
|
+
var assertionPrototype = Assertion$1.prototype;
|
|
127
|
+
Assertion$1.addMethod("containSubset", function(expected) {
|
|
128
|
+
var actual = utils.flag(this, "object");
|
|
129
|
+
var showDiff = chai$1.config.showDiff;
|
|
130
|
+
assertionPrototype.assert.call(this, compare(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
|
|
131
|
+
});
|
|
132
|
+
chai$1.assert.containSubset = function(val, exp, msg) {
|
|
133
|
+
new chai$1.Assertion(val, msg).to.be.containSubset(exp);
|
|
134
|
+
};
|
|
135
|
+
function compare(expected, actual) {
|
|
136
|
+
if (expected === actual) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (typeof actual !== typeof expected) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if (typeof expected !== "object" || expected === null) {
|
|
143
|
+
return expected === actual;
|
|
144
|
+
}
|
|
145
|
+
if (!!expected && !actual) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (Array.isArray(expected)) {
|
|
149
|
+
if (typeof actual.length !== "number") {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
var aa = Array.prototype.slice.call(actual);
|
|
153
|
+
return expected.every(function(exp) {
|
|
154
|
+
return aa.some(function(act) {
|
|
155
|
+
return compare(exp, act);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (expected instanceof Date) {
|
|
160
|
+
if (actual instanceof Date) {
|
|
161
|
+
return expected.getTime() === actual.getTime();
|
|
162
|
+
} else {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return Object.keys(expected).every(function(key) {
|
|
167
|
+
var eo = expected[key];
|
|
168
|
+
var ao = actual[key];
|
|
169
|
+
if (typeof eo === "object" && eo !== null && ao !== null) {
|
|
170
|
+
return compare(eo, ao);
|
|
171
|
+
}
|
|
172
|
+
if (typeof eo === "function") {
|
|
173
|
+
return eo(ao);
|
|
174
|
+
}
|
|
175
|
+
return ao === eo;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}).call(chaiSubset);
|
|
180
|
+
})(chaiSubset$1);
|
|
181
|
+
return chaiSubset$1.exports;
|
|
182
|
+
}
|
|
183
|
+
var chaiSubsetExports = requireChaiSubset();
|
|
184
|
+
var Subset = /* @__PURE__ */ getDefaultExportFromCjs(chaiSubsetExports);
|
|
185
|
+
function createAssertionMessage(util, assertion, hasArgs) {
|
|
186
|
+
const not = util.flag(assertion, "negate") ? "not." : "";
|
|
187
|
+
const name = `${util.flag(assertion, "_name")}(${"expected"})`;
|
|
188
|
+
const promiseName = util.flag(assertion, "promise");
|
|
189
|
+
const promise = promiseName ? `.${promiseName}` : "";
|
|
190
|
+
return `expect(actual)${promise}.${not}${name}`;
|
|
191
|
+
}
|
|
192
|
+
function recordAsyncExpect(_test, promise, assertion, error) {
|
|
193
|
+
const test = _test;
|
|
194
|
+
if (test && promise instanceof Promise) {
|
|
195
|
+
promise = promise.finally(() => {
|
|
196
|
+
if (!test.promises) return;
|
|
197
|
+
const index = test.promises.indexOf(promise);
|
|
198
|
+
if (index !== -1) test.promises.splice(index, 1);
|
|
199
|
+
});
|
|
200
|
+
if (!test.promises) test.promises = [];
|
|
201
|
+
test.promises.push(promise);
|
|
202
|
+
let resolved = false;
|
|
203
|
+
test.onFinished ??= [];
|
|
204
|
+
test.onFinished.push(() => {
|
|
205
|
+
if (!resolved) {
|
|
206
|
+
const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
|
|
207
|
+
const stack = processor(error.stack);
|
|
208
|
+
console.warn([
|
|
209
|
+
`Promise returned by \`${assertion}\` was not awaited. `,
|
|
210
|
+
"Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
|
|
211
|
+
"Please remember to await the assertion.\n",
|
|
212
|
+
stack
|
|
213
|
+
].join(""));
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
then(onFulfilled, onRejected) {
|
|
218
|
+
resolved = true;
|
|
219
|
+
return promise.then(onFulfilled, onRejected);
|
|
220
|
+
},
|
|
221
|
+
catch(onRejected) {
|
|
222
|
+
return promise.catch(onRejected);
|
|
223
|
+
},
|
|
224
|
+
finally(onFinally) {
|
|
225
|
+
return promise.finally(onFinally);
|
|
226
|
+
},
|
|
227
|
+
[Symbol.toStringTag]: "Promise"
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return promise;
|
|
231
|
+
}
|
|
232
|
+
let _client;
|
|
233
|
+
function getSnapshotClient() {
|
|
234
|
+
if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
|
|
235
|
+
return equals(received, expected, [iterableEquality, subsetEquality]);
|
|
236
|
+
} });
|
|
237
|
+
return _client;
|
|
238
|
+
}
|
|
239
|
+
function getError(expected, promise) {
|
|
240
|
+
if (typeof expected !== "function") {
|
|
241
|
+
if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
|
|
242
|
+
return expected;
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
expected();
|
|
246
|
+
} catch (e) {
|
|
247
|
+
return e;
|
|
248
|
+
}
|
|
249
|
+
throw new Error("snapshot function didn't throw");
|
|
250
|
+
}
|
|
251
|
+
function getTestNames(test) {
|
|
252
|
+
return {
|
|
253
|
+
filepath: test.file.filepath,
|
|
254
|
+
name: getNames(test).slice(1).join(" > "),
|
|
255
|
+
testId: test.id
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const SnapshotPlugin = (chai$1, utils) => {
|
|
259
|
+
function getTest(assertionName, obj) {
|
|
260
|
+
const test = utils.flag(obj, "vitest-test");
|
|
261
|
+
if (!test) throw new Error(`'${assertionName}' cannot be used without test context`);
|
|
262
|
+
return test;
|
|
263
|
+
}
|
|
264
|
+
for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai$1.Assertion.prototype, key, function(properties, message) {
|
|
265
|
+
utils.flag(this, "_name", key);
|
|
266
|
+
const isNot = utils.flag(this, "negate");
|
|
267
|
+
if (isNot) throw new Error(`${key} cannot be used with "not"`);
|
|
268
|
+
const expected = utils.flag(this, "object");
|
|
269
|
+
const test = getTest(key, this);
|
|
270
|
+
if (typeof properties === "string" && typeof message === "undefined") {
|
|
271
|
+
message = properties;
|
|
272
|
+
properties = void 0;
|
|
273
|
+
}
|
|
274
|
+
const errorMessage = utils.flag(this, "message");
|
|
275
|
+
getSnapshotClient().assert({
|
|
276
|
+
received: expected,
|
|
277
|
+
message,
|
|
278
|
+
isInline: false,
|
|
279
|
+
properties,
|
|
280
|
+
errorMessage,
|
|
281
|
+
...getTestNames(test)
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
utils.addMethod(chai$1.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
|
|
285
|
+
utils.flag(this, "_name", "toMatchFileSnapshot");
|
|
286
|
+
const isNot = utils.flag(this, "negate");
|
|
287
|
+
if (isNot) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
|
|
288
|
+
const error = new Error("resolves");
|
|
289
|
+
const expected = utils.flag(this, "object");
|
|
290
|
+
const test = getTest("toMatchFileSnapshot", this);
|
|
291
|
+
const errorMessage = utils.flag(this, "message");
|
|
292
|
+
const promise = getSnapshotClient().assertRaw({
|
|
293
|
+
received: expected,
|
|
294
|
+
message,
|
|
295
|
+
isInline: false,
|
|
296
|
+
rawSnapshot: { file },
|
|
297
|
+
errorMessage,
|
|
298
|
+
...getTestNames(test)
|
|
299
|
+
});
|
|
300
|
+
return recordAsyncExpect(test, promise, createAssertionMessage(utils, this), error);
|
|
301
|
+
});
|
|
302
|
+
utils.addMethod(chai$1.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
|
303
|
+
utils.flag(this, "_name", "toMatchInlineSnapshot");
|
|
304
|
+
const isNot = utils.flag(this, "negate");
|
|
305
|
+
if (isNot) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
|
|
306
|
+
const test = getTest("toMatchInlineSnapshot", this);
|
|
307
|
+
const isInsideEach = test.each || test.suite?.each;
|
|
308
|
+
if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
|
309
|
+
const expected = utils.flag(this, "object");
|
|
310
|
+
const error = utils.flag(this, "error");
|
|
311
|
+
if (typeof properties === "string") {
|
|
312
|
+
message = inlineSnapshot;
|
|
313
|
+
inlineSnapshot = properties;
|
|
314
|
+
properties = void 0;
|
|
315
|
+
}
|
|
316
|
+
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
|
317
|
+
const errorMessage = utils.flag(this, "message");
|
|
318
|
+
getSnapshotClient().assert({
|
|
319
|
+
received: expected,
|
|
320
|
+
message,
|
|
321
|
+
isInline: true,
|
|
322
|
+
properties,
|
|
323
|
+
inlineSnapshot,
|
|
324
|
+
error,
|
|
325
|
+
errorMessage,
|
|
326
|
+
...getTestNames(test)
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
utils.addMethod(chai$1.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
|
|
330
|
+
utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
|
|
331
|
+
const isNot = utils.flag(this, "negate");
|
|
332
|
+
if (isNot) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
|
|
333
|
+
const expected = utils.flag(this, "object");
|
|
334
|
+
const test = getTest("toThrowErrorMatchingSnapshot", this);
|
|
335
|
+
const promise = utils.flag(this, "promise");
|
|
336
|
+
const errorMessage = utils.flag(this, "message");
|
|
337
|
+
getSnapshotClient().assert({
|
|
338
|
+
received: getError(expected, promise),
|
|
339
|
+
message,
|
|
340
|
+
errorMessage,
|
|
341
|
+
...getTestNames(test)
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
utils.addMethod(chai$1.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
|
345
|
+
const isNot = utils.flag(this, "negate");
|
|
346
|
+
if (isNot) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
|
|
347
|
+
const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
|
|
348
|
+
const isInsideEach = test.each || test.suite?.each;
|
|
349
|
+
if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
|
350
|
+
const expected = utils.flag(this, "object");
|
|
351
|
+
const error = utils.flag(this, "error");
|
|
352
|
+
const promise = utils.flag(this, "promise");
|
|
353
|
+
const errorMessage = utils.flag(this, "message");
|
|
354
|
+
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
|
355
|
+
getSnapshotClient().assert({
|
|
356
|
+
received: getError(expected, promise),
|
|
357
|
+
message,
|
|
358
|
+
inlineSnapshot,
|
|
359
|
+
isInline: true,
|
|
360
|
+
error,
|
|
361
|
+
errorMessage,
|
|
362
|
+
...getTestNames(test)
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
utils.addMethod(chai$1.expect, "addSnapshotSerializer", addSerializer);
|
|
366
|
+
};
|
|
367
|
+
use(JestExtend);
|
|
368
|
+
use(JestChaiExpect);
|
|
369
|
+
use(Subset);
|
|
370
|
+
use(SnapshotPlugin);
|
|
371
|
+
use(JestAsymmetricMatchers);
|
|
372
|
+
function createExpect(test) {
|
|
373
|
+
const expect$1 = (value, message) => {
|
|
374
|
+
const { assertionCalls } = getState(expect$1);
|
|
375
|
+
setState({ assertionCalls: assertionCalls + 1 }, expect$1);
|
|
376
|
+
const assert$1 = expect(value, message);
|
|
377
|
+
const _test = test || getCurrentTest();
|
|
378
|
+
if (_test) return assert$1.withTest(_test);
|
|
379
|
+
else return assert$1;
|
|
380
|
+
};
|
|
381
|
+
Object.assign(expect$1, expect);
|
|
382
|
+
Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
383
|
+
expect$1.getState = () => getState(expect$1);
|
|
384
|
+
expect$1.setState = (state) => setState(state, expect$1);
|
|
385
|
+
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
386
|
+
setState({
|
|
387
|
+
...globalState,
|
|
388
|
+
assertionCalls: 0,
|
|
389
|
+
isExpectingAssertions: false,
|
|
390
|
+
isExpectingAssertionsError: null,
|
|
391
|
+
expectedAssertionsNumber: null,
|
|
392
|
+
expectedAssertionsNumberErrorGen: null,
|
|
393
|
+
environment: getCurrentEnvironment(),
|
|
394
|
+
get testPath() {
|
|
395
|
+
return getWorkerState().filepath;
|
|
396
|
+
},
|
|
397
|
+
currentTestName: test ? getTestName(test) : globalState.currentTestName
|
|
398
|
+
}, expect$1);
|
|
399
|
+
expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
|
|
400
|
+
expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
401
|
+
expect$1.soft = (...args) => {
|
|
402
|
+
return expect$1(...args).withContext({ soft: true });
|
|
403
|
+
};
|
|
404
|
+
expect$1.poll = createExpectPoll(expect$1);
|
|
405
|
+
expect$1.unreachable = (message) => {
|
|
406
|
+
assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
|
407
|
+
};
|
|
408
|
+
function assertions(expected) {
|
|
409
|
+
const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
|
|
410
|
+
if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
|
|
411
|
+
expect$1.setState({
|
|
412
|
+
expectedAssertionsNumber: expected,
|
|
413
|
+
expectedAssertionsNumberErrorGen: errorGen
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function hasAssertions() {
|
|
417
|
+
const error = new Error("expected any number of assertion, but got none");
|
|
418
|
+
if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
|
|
419
|
+
expect$1.setState({
|
|
420
|
+
isExpectingAssertions: true,
|
|
421
|
+
isExpectingAssertionsError: error
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
utils_exports.addMethod(expect$1, "assertions", assertions);
|
|
425
|
+
utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
|
|
426
|
+
expect$1.extend(customMatchers);
|
|
427
|
+
return expect$1;
|
|
428
|
+
}
|
|
429
|
+
const globalExpect = createExpect();
|
|
430
|
+
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
431
|
+
value: globalExpect,
|
|
432
|
+
writable: true,
|
|
433
|
+
configurable: true
|
|
434
|
+
});
|
|
435
|
+
/**
|
|
436
|
+
* Gives access to injected context provided from the main thread.
|
|
437
|
+
* This usually returns a value provided by `globalSetup` or an external library.
|
|
438
|
+
*/
|
|
439
|
+
function inject(key) {
|
|
440
|
+
const workerState = getWorkerState();
|
|
441
|
+
return workerState.providedContext[key];
|
|
442
|
+
}
|
|
443
|
+
var fakeTimersSrc = {};
|
|
444
|
+
var global;
|
|
445
|
+
var hasRequiredGlobal;
|
|
446
|
+
function requireGlobal() {
|
|
447
|
+
if (hasRequiredGlobal) return global;
|
|
448
|
+
hasRequiredGlobal = 1;
|
|
449
|
+
/**
|
|
450
|
+
* A reference to the global object
|
|
451
|
+
* @type {object} globalObject
|
|
452
|
+
*/
|
|
453
|
+
var globalObject;
|
|
454
|
+
/* istanbul ignore else */
|
|
455
|
+
if (typeof commonjsGlobal !== "undefined") {
|
|
456
|
+
globalObject = commonjsGlobal;
|
|
457
|
+
} else if (typeof window !== "undefined") {
|
|
458
|
+
globalObject = window;
|
|
459
|
+
} else {
|
|
460
|
+
globalObject = self;
|
|
461
|
+
}
|
|
462
|
+
global = globalObject;
|
|
463
|
+
return global;
|
|
464
|
+
}
|
|
465
|
+
var throwsOnProto_1;
|
|
466
|
+
var hasRequiredThrowsOnProto;
|
|
467
|
+
function requireThrowsOnProto() {
|
|
468
|
+
if (hasRequiredThrowsOnProto) return throwsOnProto_1;
|
|
469
|
+
hasRequiredThrowsOnProto = 1;
|
|
470
|
+
/**
|
|
471
|
+
* Is true when the environment causes an error to be thrown for accessing the
|
|
472
|
+
* __proto__ property.
|
|
473
|
+
* This is necessary in order to support `node --disable-proto=throw`.
|
|
474
|
+
*
|
|
475
|
+
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
|
|
476
|
+
* @type {boolean}
|
|
477
|
+
*/
|
|
478
|
+
let throwsOnProto;
|
|
479
|
+
try {
|
|
480
|
+
const object$1 = {};
|
|
481
|
+
object$1.__proto__;
|
|
482
|
+
throwsOnProto = false;
|
|
483
|
+
} catch (_) {
|
|
484
|
+
/* istanbul ignore next */
|
|
485
|
+
throwsOnProto = true;
|
|
486
|
+
}
|
|
487
|
+
throwsOnProto_1 = throwsOnProto;
|
|
488
|
+
return throwsOnProto_1;
|
|
489
|
+
}
|
|
490
|
+
var copyPrototypeMethods;
|
|
491
|
+
var hasRequiredCopyPrototypeMethods;
|
|
492
|
+
function requireCopyPrototypeMethods() {
|
|
493
|
+
if (hasRequiredCopyPrototypeMethods) return copyPrototypeMethods;
|
|
494
|
+
hasRequiredCopyPrototypeMethods = 1;
|
|
495
|
+
var call = Function.call;
|
|
496
|
+
var throwsOnProto = requireThrowsOnProto();
|
|
497
|
+
var disallowedProperties = [
|
|
498
|
+
"size",
|
|
499
|
+
"caller",
|
|
500
|
+
"callee",
|
|
501
|
+
"arguments"
|
|
502
|
+
];
|
|
503
|
+
/* istanbul ignore next */
|
|
504
|
+
if (throwsOnProto) {
|
|
505
|
+
disallowedProperties.push("__proto__");
|
|
506
|
+
}
|
|
507
|
+
copyPrototypeMethods = function copyPrototypeMethods$1(prototype) {
|
|
508
|
+
return Object.getOwnPropertyNames(prototype).reduce(function(result, name) {
|
|
509
|
+
if (disallowedProperties.includes(name)) {
|
|
510
|
+
return result;
|
|
511
|
+
}
|
|
512
|
+
if (typeof prototype[name] !== "function") {
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
result[name] = call.bind(prototype[name]);
|
|
516
|
+
return result;
|
|
517
|
+
}, Object.create(null));
|
|
518
|
+
};
|
|
519
|
+
return copyPrototypeMethods;
|
|
520
|
+
}
|
|
521
|
+
var array;
|
|
522
|
+
var hasRequiredArray;
|
|
523
|
+
function requireArray() {
|
|
524
|
+
if (hasRequiredArray) return array;
|
|
525
|
+
hasRequiredArray = 1;
|
|
526
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
527
|
+
array = copyPrototype(Array.prototype);
|
|
528
|
+
return array;
|
|
529
|
+
}
|
|
530
|
+
var calledInOrder_1;
|
|
531
|
+
var hasRequiredCalledInOrder;
|
|
532
|
+
function requireCalledInOrder() {
|
|
533
|
+
if (hasRequiredCalledInOrder) return calledInOrder_1;
|
|
534
|
+
hasRequiredCalledInOrder = 1;
|
|
535
|
+
var every$1 = requireArray().every;
|
|
536
|
+
/**
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
function hasCallsLeft(callMap, spy) {
|
|
540
|
+
if (callMap[spy.id] === undefined) {
|
|
541
|
+
callMap[spy.id] = 0;
|
|
542
|
+
}
|
|
543
|
+
return callMap[spy.id] < spy.callCount;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* @private
|
|
547
|
+
*/
|
|
548
|
+
function checkAdjacentCalls(callMap, spy, index, spies) {
|
|
549
|
+
var calledBeforeNext = true;
|
|
550
|
+
if (index !== spies.length - 1) {
|
|
551
|
+
calledBeforeNext = spy.calledBefore(spies[index + 1]);
|
|
552
|
+
}
|
|
553
|
+
if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
|
|
554
|
+
callMap[spy.id] += 1;
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* A Sinon proxy object (fake, spy, stub)
|
|
561
|
+
* @typedef {object} SinonProxy
|
|
562
|
+
* @property {Function} calledBefore - A method that determines if this proxy was called before another one
|
|
563
|
+
* @property {string} id - Some id
|
|
564
|
+
* @property {number} callCount - Number of times this proxy has been called
|
|
565
|
+
*/
|
|
566
|
+
/**
|
|
567
|
+
* Returns true when the spies have been called in the order they were supplied in
|
|
568
|
+
* @param {SinonProxy[] | SinonProxy} spies An array of proxies, or several proxies as arguments
|
|
569
|
+
* @returns {boolean} true when spies are called in order, false otherwise
|
|
570
|
+
*/
|
|
571
|
+
function calledInOrder(spies) {
|
|
572
|
+
var callMap = {};
|
|
573
|
+
var _spies = arguments.length > 1 ? arguments : spies;
|
|
574
|
+
return every$1(_spies, checkAdjacentCalls.bind(null, callMap));
|
|
575
|
+
}
|
|
576
|
+
calledInOrder_1 = calledInOrder;
|
|
577
|
+
return calledInOrder_1;
|
|
578
|
+
}
|
|
579
|
+
var className_1;
|
|
580
|
+
var hasRequiredClassName;
|
|
581
|
+
function requireClassName() {
|
|
582
|
+
if (hasRequiredClassName) return className_1;
|
|
583
|
+
hasRequiredClassName = 1;
|
|
584
|
+
/**
|
|
585
|
+
* Returns a display name for a value from a constructor
|
|
586
|
+
* @param {object} value A value to examine
|
|
587
|
+
* @returns {(string|null)} A string or null
|
|
588
|
+
*/
|
|
589
|
+
function className(value) {
|
|
590
|
+
const name = value.constructor && value.constructor.name;
|
|
591
|
+
return name || null;
|
|
592
|
+
}
|
|
593
|
+
className_1 = className;
|
|
594
|
+
return className_1;
|
|
595
|
+
}
|
|
596
|
+
var deprecated = {};
|
|
597
|
+
var hasRequiredDeprecated;
|
|
598
|
+
function requireDeprecated() {
|
|
599
|
+
if (hasRequiredDeprecated) return deprecated;
|
|
600
|
+
hasRequiredDeprecated = 1;
|
|
601
|
+
(function(exports) {
|
|
602
|
+
/**
|
|
603
|
+
* Returns a function that will invoke the supplied function and print a
|
|
604
|
+
* deprecation warning to the console each time it is called.
|
|
605
|
+
* @param {Function} func
|
|
606
|
+
* @param {string} msg
|
|
607
|
+
* @returns {Function}
|
|
608
|
+
*/
|
|
609
|
+
exports.wrap = function(func, msg) {
|
|
610
|
+
var wrapped = function() {
|
|
611
|
+
exports.printWarning(msg);
|
|
612
|
+
return func.apply(this, arguments);
|
|
613
|
+
};
|
|
614
|
+
if (func.prototype) {
|
|
615
|
+
wrapped.prototype = func.prototype;
|
|
616
|
+
}
|
|
617
|
+
return wrapped;
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* Returns a string which can be supplied to `wrap()` to notify the user that a
|
|
621
|
+
* particular part of the sinon API has been deprecated.
|
|
622
|
+
* @param {string} packageName
|
|
623
|
+
* @param {string} funcName
|
|
624
|
+
* @returns {string}
|
|
625
|
+
*/
|
|
626
|
+
exports.defaultMsg = function(packageName, funcName) {
|
|
627
|
+
return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Prints a warning on the console, when it exists
|
|
631
|
+
* @param {string} msg
|
|
632
|
+
* @returns {undefined}
|
|
633
|
+
*/
|
|
634
|
+
exports.printWarning = function(msg) {
|
|
635
|
+
/* istanbul ignore next */
|
|
636
|
+
if (typeof process === "object" && process.emitWarning) {
|
|
637
|
+
process.emitWarning(msg);
|
|
638
|
+
} else if (console.info) {
|
|
639
|
+
console.info(msg);
|
|
640
|
+
} else {
|
|
641
|
+
console.log(msg);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
})(deprecated);
|
|
645
|
+
return deprecated;
|
|
646
|
+
}
|
|
647
|
+
var every;
|
|
648
|
+
var hasRequiredEvery;
|
|
649
|
+
function requireEvery() {
|
|
650
|
+
if (hasRequiredEvery) return every;
|
|
651
|
+
hasRequiredEvery = 1;
|
|
652
|
+
/**
|
|
653
|
+
* Returns true when fn returns true for all members of obj.
|
|
654
|
+
* This is an every implementation that works for all iterables
|
|
655
|
+
* @param {object} obj
|
|
656
|
+
* @param {Function} fn
|
|
657
|
+
* @returns {boolean}
|
|
658
|
+
*/
|
|
659
|
+
every = function every$1(obj, fn$1) {
|
|
660
|
+
var pass = true;
|
|
661
|
+
try {
|
|
662
|
+
obj.forEach(function() {
|
|
663
|
+
if (!fn$1.apply(this, arguments)) {
|
|
664
|
+
throw new Error();
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
} catch (e) {
|
|
668
|
+
pass = false;
|
|
669
|
+
}
|
|
670
|
+
return pass;
|
|
671
|
+
};
|
|
672
|
+
return every;
|
|
673
|
+
}
|
|
674
|
+
var functionName;
|
|
675
|
+
var hasRequiredFunctionName;
|
|
676
|
+
function requireFunctionName() {
|
|
677
|
+
if (hasRequiredFunctionName) return functionName;
|
|
678
|
+
hasRequiredFunctionName = 1;
|
|
679
|
+
/**
|
|
680
|
+
* Returns a display name for a function
|
|
681
|
+
* @param {Function} func
|
|
682
|
+
* @returns {string}
|
|
683
|
+
*/
|
|
684
|
+
functionName = function functionName$1(func) {
|
|
685
|
+
if (!func) {
|
|
686
|
+
return "";
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
return func.displayName || func.name || (String(func).match(/function ([^\s(]+)/) || [])[1];
|
|
690
|
+
} catch (e) {
|
|
691
|
+
return "";
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
return functionName;
|
|
695
|
+
}
|
|
696
|
+
var orderByFirstCall_1;
|
|
697
|
+
var hasRequiredOrderByFirstCall;
|
|
698
|
+
function requireOrderByFirstCall() {
|
|
699
|
+
if (hasRequiredOrderByFirstCall) return orderByFirstCall_1;
|
|
700
|
+
hasRequiredOrderByFirstCall = 1;
|
|
701
|
+
var sort = requireArray().sort;
|
|
702
|
+
var slice = requireArray().slice;
|
|
703
|
+
/**
|
|
704
|
+
* @private
|
|
705
|
+
*/
|
|
706
|
+
function comparator(a, b) {
|
|
707
|
+
var aCall = a.getCall(0);
|
|
708
|
+
var bCall = b.getCall(0);
|
|
709
|
+
var aId = aCall && aCall.callId || -1;
|
|
710
|
+
var bId = bCall && bCall.callId || -1;
|
|
711
|
+
return aId < bId ? -1 : 1;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* A Sinon proxy object (fake, spy, stub)
|
|
715
|
+
* @typedef {object} SinonProxy
|
|
716
|
+
* @property {Function} getCall - A method that can return the first call
|
|
717
|
+
*/
|
|
718
|
+
/**
|
|
719
|
+
* Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
|
|
720
|
+
* @param {SinonProxy[] | SinonProxy} spies
|
|
721
|
+
* @returns {SinonProxy[]}
|
|
722
|
+
*/
|
|
723
|
+
function orderByFirstCall(spies) {
|
|
724
|
+
return sort(slice(spies), comparator);
|
|
725
|
+
}
|
|
726
|
+
orderByFirstCall_1 = orderByFirstCall;
|
|
727
|
+
return orderByFirstCall_1;
|
|
728
|
+
}
|
|
729
|
+
var _function;
|
|
730
|
+
var hasRequired_function;
|
|
731
|
+
function require_function() {
|
|
732
|
+
if (hasRequired_function) return _function;
|
|
733
|
+
hasRequired_function = 1;
|
|
734
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
735
|
+
_function = copyPrototype(Function.prototype);
|
|
736
|
+
return _function;
|
|
737
|
+
}
|
|
738
|
+
var map;
|
|
739
|
+
var hasRequiredMap;
|
|
740
|
+
function requireMap() {
|
|
741
|
+
if (hasRequiredMap) return map;
|
|
742
|
+
hasRequiredMap = 1;
|
|
743
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
744
|
+
map = copyPrototype(Map.prototype);
|
|
745
|
+
return map;
|
|
746
|
+
}
|
|
747
|
+
var object;
|
|
748
|
+
var hasRequiredObject;
|
|
749
|
+
function requireObject() {
|
|
750
|
+
if (hasRequiredObject) return object;
|
|
751
|
+
hasRequiredObject = 1;
|
|
752
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
753
|
+
object = copyPrototype(Object.prototype);
|
|
754
|
+
return object;
|
|
755
|
+
}
|
|
756
|
+
var set;
|
|
757
|
+
var hasRequiredSet;
|
|
758
|
+
function requireSet() {
|
|
759
|
+
if (hasRequiredSet) return set;
|
|
760
|
+
hasRequiredSet = 1;
|
|
761
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
762
|
+
set = copyPrototype(Set.prototype);
|
|
763
|
+
return set;
|
|
764
|
+
}
|
|
765
|
+
var string;
|
|
766
|
+
var hasRequiredString;
|
|
767
|
+
function requireString() {
|
|
768
|
+
if (hasRequiredString) return string;
|
|
769
|
+
hasRequiredString = 1;
|
|
770
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
|
771
|
+
string = copyPrototype(String.prototype);
|
|
772
|
+
return string;
|
|
773
|
+
}
|
|
774
|
+
var prototypes;
|
|
775
|
+
var hasRequiredPrototypes;
|
|
776
|
+
function requirePrototypes() {
|
|
777
|
+
if (hasRequiredPrototypes) return prototypes;
|
|
778
|
+
hasRequiredPrototypes = 1;
|
|
779
|
+
prototypes = {
|
|
780
|
+
array: requireArray(),
|
|
781
|
+
function: require_function(),
|
|
782
|
+
map: requireMap(),
|
|
783
|
+
object: requireObject(),
|
|
784
|
+
set: requireSet(),
|
|
785
|
+
string: requireString()
|
|
786
|
+
};
|
|
787
|
+
return prototypes;
|
|
788
|
+
}
|
|
789
|
+
var typeDetect$1 = { exports: {} };
|
|
790
|
+
var typeDetect = typeDetect$1.exports;
|
|
791
|
+
var hasRequiredTypeDetect;
|
|
792
|
+
function requireTypeDetect() {
|
|
793
|
+
if (hasRequiredTypeDetect) return typeDetect$1.exports;
|
|
794
|
+
hasRequiredTypeDetect = 1;
|
|
795
|
+
(function(module, exports) {
|
|
796
|
+
(function(global$1, factory) {
|
|
797
|
+
module.exports = factory();
|
|
798
|
+
})(typeDetect, (function() {
|
|
799
|
+
var promiseExists = typeof Promise === "function";
|
|
800
|
+
var globalObject = typeof self === "object" ? self : commonjsGlobal;
|
|
801
|
+
var symbolExists = typeof Symbol !== "undefined";
|
|
802
|
+
var mapExists = typeof Map !== "undefined";
|
|
803
|
+
var setExists = typeof Set !== "undefined";
|
|
804
|
+
var weakMapExists = typeof WeakMap !== "undefined";
|
|
805
|
+
var weakSetExists = typeof WeakSet !== "undefined";
|
|
806
|
+
var dataViewExists = typeof DataView !== "undefined";
|
|
807
|
+
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
|
|
808
|
+
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
|
|
809
|
+
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
|
|
810
|
+
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
|
|
811
|
+
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
|
812
|
+
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
|
813
|
+
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
|
|
814
|
+
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
|
815
|
+
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
|
|
816
|
+
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
|
|
817
|
+
var toStringLeftSliceLength = 8;
|
|
818
|
+
var toStringRightSliceLength = -1;
|
|
819
|
+
/**
|
|
820
|
+
* ### typeOf (obj)
|
|
821
|
+
*
|
|
822
|
+
* Uses `Object.prototype.toString` to determine the type of an object,
|
|
823
|
+
* normalising behaviour across engine versions & well optimised.
|
|
824
|
+
*
|
|
825
|
+
* @param {Mixed} object
|
|
826
|
+
* @return {String} object type
|
|
827
|
+
* @api public
|
|
828
|
+
*/
|
|
829
|
+
function typeDetect$2(obj) {
|
|
830
|
+
var typeofObj = typeof obj;
|
|
831
|
+
if (typeofObj !== "object") {
|
|
832
|
+
return typeofObj;
|
|
833
|
+
}
|
|
834
|
+
if (obj === null) {
|
|
835
|
+
return "null";
|
|
836
|
+
}
|
|
837
|
+
if (obj === globalObject) {
|
|
838
|
+
return "global";
|
|
839
|
+
}
|
|
840
|
+
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
|
841
|
+
return "Array";
|
|
842
|
+
}
|
|
843
|
+
if (typeof window === "object" && window !== null) {
|
|
844
|
+
if (typeof window.location === "object" && obj === window.location) {
|
|
845
|
+
return "Location";
|
|
846
|
+
}
|
|
847
|
+
if (typeof window.document === "object" && obj === window.document) {
|
|
848
|
+
return "Document";
|
|
849
|
+
}
|
|
850
|
+
if (typeof window.navigator === "object") {
|
|
851
|
+
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
|
|
852
|
+
return "MimeTypeArray";
|
|
853
|
+
}
|
|
854
|
+
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
|
|
855
|
+
return "PluginArray";
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
|
|
859
|
+
if (obj.tagName === "BLOCKQUOTE") {
|
|
860
|
+
return "HTMLQuoteElement";
|
|
861
|
+
}
|
|
862
|
+
if (obj.tagName === "TD") {
|
|
863
|
+
return "HTMLTableDataCellElement";
|
|
864
|
+
}
|
|
865
|
+
if (obj.tagName === "TH") {
|
|
866
|
+
return "HTMLTableHeaderCellElement";
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
|
|
871
|
+
if (typeof stringTag === "string") {
|
|
872
|
+
return stringTag;
|
|
873
|
+
}
|
|
874
|
+
var objPrototype = Object.getPrototypeOf(obj);
|
|
875
|
+
if (objPrototype === RegExp.prototype) {
|
|
876
|
+
return "RegExp";
|
|
877
|
+
}
|
|
878
|
+
if (objPrototype === Date.prototype) {
|
|
879
|
+
return "Date";
|
|
880
|
+
}
|
|
881
|
+
if (promiseExists && objPrototype === Promise.prototype) {
|
|
882
|
+
return "Promise";
|
|
883
|
+
}
|
|
884
|
+
if (setExists && objPrototype === Set.prototype) {
|
|
885
|
+
return "Set";
|
|
886
|
+
}
|
|
887
|
+
if (mapExists && objPrototype === Map.prototype) {
|
|
888
|
+
return "Map";
|
|
889
|
+
}
|
|
890
|
+
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
|
891
|
+
return "WeakSet";
|
|
892
|
+
}
|
|
893
|
+
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
|
894
|
+
return "WeakMap";
|
|
895
|
+
}
|
|
896
|
+
if (dataViewExists && objPrototype === DataView.prototype) {
|
|
897
|
+
return "DataView";
|
|
898
|
+
}
|
|
899
|
+
if (mapExists && objPrototype === mapIteratorPrototype) {
|
|
900
|
+
return "Map Iterator";
|
|
901
|
+
}
|
|
902
|
+
if (setExists && objPrototype === setIteratorPrototype) {
|
|
903
|
+
return "Set Iterator";
|
|
904
|
+
}
|
|
905
|
+
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
|
906
|
+
return "Array Iterator";
|
|
907
|
+
}
|
|
908
|
+
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
|
909
|
+
return "String Iterator";
|
|
910
|
+
}
|
|
911
|
+
if (objPrototype === null) {
|
|
912
|
+
return "Object";
|
|
913
|
+
}
|
|
914
|
+
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
915
|
+
}
|
|
916
|
+
return typeDetect$2;
|
|
917
|
+
}));
|
|
918
|
+
})(typeDetect$1);
|
|
919
|
+
return typeDetect$1.exports;
|
|
920
|
+
}
|
|
921
|
+
var typeOf;
|
|
922
|
+
var hasRequiredTypeOf;
|
|
923
|
+
function requireTypeOf() {
|
|
924
|
+
if (hasRequiredTypeOf) return typeOf;
|
|
925
|
+
hasRequiredTypeOf = 1;
|
|
926
|
+
var type = requireTypeDetect();
|
|
927
|
+
/**
|
|
928
|
+
* Returns the lower-case result of running type from type-detect on the value
|
|
929
|
+
* @param {*} value
|
|
930
|
+
* @returns {string}
|
|
931
|
+
*/
|
|
932
|
+
typeOf = function typeOf$1(value) {
|
|
933
|
+
return type(value).toLowerCase();
|
|
934
|
+
};
|
|
935
|
+
return typeOf;
|
|
936
|
+
}
|
|
937
|
+
var valueToString_1;
|
|
938
|
+
var hasRequiredValueToString;
|
|
939
|
+
function requireValueToString() {
|
|
940
|
+
if (hasRequiredValueToString) return valueToString_1;
|
|
941
|
+
hasRequiredValueToString = 1;
|
|
942
|
+
/**
|
|
943
|
+
* Returns a string representation of the value
|
|
944
|
+
* @param {*} value
|
|
945
|
+
* @returns {string}
|
|
946
|
+
*/
|
|
947
|
+
function valueToString(value) {
|
|
948
|
+
if (value && value.toString) {
|
|
949
|
+
return value.toString();
|
|
950
|
+
}
|
|
951
|
+
return String(value);
|
|
952
|
+
}
|
|
953
|
+
valueToString_1 = valueToString;
|
|
954
|
+
return valueToString_1;
|
|
955
|
+
}
|
|
956
|
+
var lib;
|
|
957
|
+
var hasRequiredLib;
|
|
958
|
+
function requireLib() {
|
|
959
|
+
if (hasRequiredLib) return lib;
|
|
960
|
+
hasRequiredLib = 1;
|
|
961
|
+
lib = {
|
|
962
|
+
global: requireGlobal(),
|
|
963
|
+
calledInOrder: requireCalledInOrder(),
|
|
964
|
+
className: requireClassName(),
|
|
965
|
+
deprecated: requireDeprecated(),
|
|
966
|
+
every: requireEvery(),
|
|
967
|
+
functionName: requireFunctionName(),
|
|
968
|
+
orderByFirstCall: requireOrderByFirstCall(),
|
|
969
|
+
prototypes: requirePrototypes(),
|
|
970
|
+
typeOf: requireTypeOf(),
|
|
971
|
+
valueToString: requireValueToString()
|
|
972
|
+
};
|
|
973
|
+
return lib;
|
|
974
|
+
}
|
|
975
|
+
var hasRequiredFakeTimersSrc;
|
|
976
|
+
function requireFakeTimersSrc() {
|
|
977
|
+
if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
|
|
978
|
+
hasRequiredFakeTimersSrc = 1;
|
|
979
|
+
const globalObject = requireLib().global;
|
|
980
|
+
let timersModule, timersPromisesModule;
|
|
981
|
+
if (typeof __vitest_required__ !== "undefined") {
|
|
982
|
+
try {
|
|
983
|
+
timersModule = __vitest_required__.timers;
|
|
984
|
+
} catch (e) {}
|
|
985
|
+
try {
|
|
986
|
+
timersPromisesModule = __vitest_required__.timersPromises;
|
|
987
|
+
} catch (e) {}
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* @typedef {object} IdleDeadline
|
|
991
|
+
* @property {boolean} didTimeout - whether or not the callback was called before reaching the optional timeout
|
|
992
|
+
* @property {function():number} timeRemaining - a floating-point value providing an estimate of the number of milliseconds remaining in the current idle period
|
|
993
|
+
*/
|
|
994
|
+
/**
|
|
995
|
+
* Queues a function to be called during a browser's idle periods
|
|
996
|
+
* @callback RequestIdleCallback
|
|
997
|
+
* @param {function(IdleDeadline)} callback
|
|
998
|
+
* @param {{timeout: number}} options - an options object
|
|
999
|
+
* @returns {number} the id
|
|
1000
|
+
*/
|
|
1001
|
+
/**
|
|
1002
|
+
* @callback NextTick
|
|
1003
|
+
* @param {VoidVarArgsFunc} callback - the callback to run
|
|
1004
|
+
* @param {...*} args - optional arguments to call the callback with
|
|
1005
|
+
* @returns {void}
|
|
1006
|
+
*/
|
|
1007
|
+
/**
|
|
1008
|
+
* @callback SetImmediate
|
|
1009
|
+
* @param {VoidVarArgsFunc} callback - the callback to run
|
|
1010
|
+
* @param {...*} args - optional arguments to call the callback with
|
|
1011
|
+
* @returns {NodeImmediate}
|
|
1012
|
+
*/
|
|
1013
|
+
/**
|
|
1014
|
+
* @callback VoidVarArgsFunc
|
|
1015
|
+
* @param {...*} callback - the callback to run
|
|
1016
|
+
* @returns {void}
|
|
1017
|
+
*/
|
|
1018
|
+
/**
|
|
1019
|
+
* @typedef RequestAnimationFrame
|
|
1020
|
+
* @property {function(number):void} requestAnimationFrame
|
|
1021
|
+
* @returns {number} - the id
|
|
1022
|
+
*/
|
|
1023
|
+
/**
|
|
1024
|
+
* @typedef Performance
|
|
1025
|
+
* @property {function(): number} now
|
|
1026
|
+
*/
|
|
1027
|
+
/**
|
|
1028
|
+
* @typedef {object} Clock
|
|
1029
|
+
* @property {number} now - the current time
|
|
1030
|
+
* @property {Date} Date - the Date constructor
|
|
1031
|
+
* @property {number} loopLimit - the maximum number of timers before assuming an infinite loop
|
|
1032
|
+
* @property {RequestIdleCallback} requestIdleCallback
|
|
1033
|
+
* @property {function(number):void} cancelIdleCallback
|
|
1034
|
+
* @property {setTimeout} setTimeout
|
|
1035
|
+
* @property {clearTimeout} clearTimeout
|
|
1036
|
+
* @property {NextTick} nextTick
|
|
1037
|
+
* @property {queueMicrotask} queueMicrotask
|
|
1038
|
+
* @property {setInterval} setInterval
|
|
1039
|
+
* @property {clearInterval} clearInterval
|
|
1040
|
+
* @property {SetImmediate} setImmediate
|
|
1041
|
+
* @property {function(NodeImmediate):void} clearImmediate
|
|
1042
|
+
* @property {function():number} countTimers
|
|
1043
|
+
* @property {RequestAnimationFrame} requestAnimationFrame
|
|
1044
|
+
* @property {function(number):void} cancelAnimationFrame
|
|
1045
|
+
* @property {function():void} runMicrotasks
|
|
1046
|
+
* @property {function(string | number): number} tick
|
|
1047
|
+
* @property {function(string | number): Promise<number>} tickAsync
|
|
1048
|
+
* @property {function(): number} next
|
|
1049
|
+
* @property {function(): Promise<number>} nextAsync
|
|
1050
|
+
* @property {function(): number} runAll
|
|
1051
|
+
* @property {function(): number} runToFrame
|
|
1052
|
+
* @property {function(): Promise<number>} runAllAsync
|
|
1053
|
+
* @property {function(): number} runToLast
|
|
1054
|
+
* @property {function(): Promise<number>} runToLastAsync
|
|
1055
|
+
* @property {function(): void} reset
|
|
1056
|
+
* @property {function(number | Date): void} setSystemTime
|
|
1057
|
+
* @property {function(number): void} jump
|
|
1058
|
+
* @property {Performance} performance
|
|
1059
|
+
* @property {function(number[]): number[]} hrtime - process.hrtime (legacy)
|
|
1060
|
+
* @property {function(): void} uninstall Uninstall the clock.
|
|
1061
|
+
* @property {Function[]} methods - the methods that are faked
|
|
1062
|
+
* @property {boolean} [shouldClearNativeTimers] inherited from config
|
|
1063
|
+
* @property {{methodName:string, original:any}[] | undefined} timersModuleMethods
|
|
1064
|
+
* @property {{methodName:string, original:any}[] | undefined} timersPromisesModuleMethods
|
|
1065
|
+
* @property {Map<function(): void, AbortSignal>} abortListenerMap
|
|
1066
|
+
*/
|
|
1067
|
+
/**
|
|
1068
|
+
* Configuration object for the `install` method.
|
|
1069
|
+
* @typedef {object} Config
|
|
1070
|
+
* @property {number|Date} [now] a number (in milliseconds) or a Date object (default epoch)
|
|
1071
|
+
* @property {string[]} [toFake] names of the methods that should be faked.
|
|
1072
|
+
* @property {number} [loopLimit] the maximum number of timers that will be run when calling runAll()
|
|
1073
|
+
* @property {boolean} [shouldAdvanceTime] tells FakeTimers to increment mocked time automatically (default false)
|
|
1074
|
+
* @property {number} [advanceTimeDelta] increment mocked time every <<advanceTimeDelta>> ms (default: 20ms)
|
|
1075
|
+
* @property {boolean} [shouldClearNativeTimers] forwards clear timer calls to native functions if they are not fakes (default: false)
|
|
1076
|
+
* @property {boolean} [ignoreMissingTimers] default is false, meaning asking to fake timers that are not present will throw an error
|
|
1077
|
+
*/
|
|
1078
|
+
/**
|
|
1079
|
+
* The internal structure to describe a scheduled fake timer
|
|
1080
|
+
* @typedef {object} Timer
|
|
1081
|
+
* @property {Function} func
|
|
1082
|
+
* @property {*[]} args
|
|
1083
|
+
* @property {number} delay
|
|
1084
|
+
* @property {number} callAt
|
|
1085
|
+
* @property {number} createdAt
|
|
1086
|
+
* @property {boolean} immediate
|
|
1087
|
+
* @property {number} id
|
|
1088
|
+
* @property {Error} [error]
|
|
1089
|
+
*/
|
|
1090
|
+
/**
|
|
1091
|
+
* A Node timer
|
|
1092
|
+
* @typedef {object} NodeImmediate
|
|
1093
|
+
* @property {function(): boolean} hasRef
|
|
1094
|
+
* @property {function(): NodeImmediate} ref
|
|
1095
|
+
* @property {function(): NodeImmediate} unref
|
|
1096
|
+
*/
|
|
1097
|
+
/**
|
|
1098
|
+
* Mocks available features in the specified global namespace.
|
|
1099
|
+
* @param {*} _global Namespace to mock (e.g. `window`)
|
|
1100
|
+
* @returns {FakeTimers}
|
|
1101
|
+
*/
|
|
1102
|
+
function withGlobal(_global) {
|
|
1103
|
+
const maxTimeout = Math.pow(2, 31) - 1;
|
|
1104
|
+
const idCounterStart = 0xe8d4a51000;
|
|
1105
|
+
const NOOP = function() {
|
|
1106
|
+
return undefined;
|
|
1107
|
+
};
|
|
1108
|
+
const NOOP_ARRAY = function() {
|
|
1109
|
+
return [];
|
|
1110
|
+
};
|
|
1111
|
+
const isPresent = {};
|
|
1112
|
+
let timeoutResult, addTimerReturnsObject = false;
|
|
1113
|
+
if (_global.setTimeout) {
|
|
1114
|
+
isPresent.setTimeout = true;
|
|
1115
|
+
timeoutResult = _global.setTimeout(NOOP, 0);
|
|
1116
|
+
addTimerReturnsObject = typeof timeoutResult === "object";
|
|
1117
|
+
}
|
|
1118
|
+
isPresent.clearTimeout = Boolean(_global.clearTimeout);
|
|
1119
|
+
isPresent.setInterval = Boolean(_global.setInterval);
|
|
1120
|
+
isPresent.clearInterval = Boolean(_global.clearInterval);
|
|
1121
|
+
isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
|
|
1122
|
+
isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
|
|
1123
|
+
isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
|
|
1124
|
+
const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
|
|
1125
|
+
isPresent.performance = _global.performance && typeof _global.performance.now === "function";
|
|
1126
|
+
const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
|
|
1127
|
+
const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
|
|
1128
|
+
isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
|
|
1129
|
+
isPresent.requestAnimationFrame = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
|
|
1130
|
+
isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
|
|
1131
|
+
isPresent.requestIdleCallback = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
|
|
1132
|
+
isPresent.cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
|
|
1133
|
+
isPresent.setImmediate = _global.setImmediate && typeof _global.setImmediate === "function";
|
|
1134
|
+
isPresent.clearImmediate = _global.clearImmediate && typeof _global.clearImmediate === "function";
|
|
1135
|
+
isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
|
|
1136
|
+
if (_global.clearTimeout) {
|
|
1137
|
+
_global.clearTimeout(timeoutResult);
|
|
1138
|
+
}
|
|
1139
|
+
const NativeDate = _global.Date;
|
|
1140
|
+
const NativeIntl = isPresent.Intl ? Object.defineProperties(Object.create(null), Object.getOwnPropertyDescriptors(_global.Intl)) : undefined;
|
|
1141
|
+
let uniqueTimerId = idCounterStart;
|
|
1142
|
+
if (NativeDate === undefined) {
|
|
1143
|
+
throw new Error("The global scope doesn't have a `Date` object" + " (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)");
|
|
1144
|
+
}
|
|
1145
|
+
isPresent.Date = true;
|
|
1146
|
+
/**
|
|
1147
|
+
* The PerformanceEntry object encapsulates a single performance metric
|
|
1148
|
+
* that is part of the browser's performance timeline.
|
|
1149
|
+
*
|
|
1150
|
+
* This is an object returned by the `mark` and `measure` methods on the Performance prototype
|
|
1151
|
+
*/
|
|
1152
|
+
class FakePerformanceEntry {
|
|
1153
|
+
constructor(name, entryType, startTime, duration) {
|
|
1154
|
+
this.name = name;
|
|
1155
|
+
this.entryType = entryType;
|
|
1156
|
+
this.startTime = startTime;
|
|
1157
|
+
this.duration = duration;
|
|
1158
|
+
}
|
|
1159
|
+
toJSON() {
|
|
1160
|
+
return JSON.stringify({ ...this });
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* @param {number} num
|
|
1165
|
+
* @returns {boolean}
|
|
1166
|
+
*/
|
|
1167
|
+
function isNumberFinite(num) {
|
|
1168
|
+
if (Number.isFinite) {
|
|
1169
|
+
return Number.isFinite(num);
|
|
1170
|
+
}
|
|
1171
|
+
return isFinite(num);
|
|
1172
|
+
}
|
|
1173
|
+
let isNearInfiniteLimit = false;
|
|
1174
|
+
/**
|
|
1175
|
+
* @param {Clock} clock
|
|
1176
|
+
* @param {number} i
|
|
1177
|
+
*/
|
|
1178
|
+
function checkIsNearInfiniteLimit(clock, i) {
|
|
1179
|
+
if (clock.loopLimit && i === clock.loopLimit - 1) {
|
|
1180
|
+
isNearInfiniteLimit = true;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
*
|
|
1185
|
+
*/
|
|
1186
|
+
function resetIsNearInfiniteLimit() {
|
|
1187
|
+
isNearInfiniteLimit = false;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into
|
|
1191
|
+
* number of milliseconds. This is used to support human-readable strings passed
|
|
1192
|
+
* to clock.tick()
|
|
1193
|
+
* @param {string} str
|
|
1194
|
+
* @returns {number}
|
|
1195
|
+
*/
|
|
1196
|
+
function parseTime(str) {
|
|
1197
|
+
if (!str) {
|
|
1198
|
+
return 0;
|
|
1199
|
+
}
|
|
1200
|
+
const strings = str.split(":");
|
|
1201
|
+
const l = strings.length;
|
|
1202
|
+
let i = l;
|
|
1203
|
+
let ms = 0;
|
|
1204
|
+
let parsed;
|
|
1205
|
+
if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
|
|
1206
|
+
throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
|
|
1207
|
+
}
|
|
1208
|
+
while (i--) {
|
|
1209
|
+
parsed = parseInt(strings[i], 10);
|
|
1210
|
+
if (parsed >= 60) {
|
|
1211
|
+
throw new Error(`Invalid time ${str}`);
|
|
1212
|
+
}
|
|
1213
|
+
ms += parsed * Math.pow(60, l - i - 1);
|
|
1214
|
+
}
|
|
1215
|
+
return ms * 1e3;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Get the decimal part of the millisecond value as nanoseconds
|
|
1219
|
+
* @param {number} msFloat the number of milliseconds
|
|
1220
|
+
* @returns {number} an integer number of nanoseconds in the range [0,1e6)
|
|
1221
|
+
*
|
|
1222
|
+
* Example: nanoRemainer(123.456789) -> 456789
|
|
1223
|
+
*/
|
|
1224
|
+
function nanoRemainder(msFloat) {
|
|
1225
|
+
const modulo = 1e6;
|
|
1226
|
+
const remainder = msFloat * 1e6 % modulo;
|
|
1227
|
+
const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
|
|
1228
|
+
return Math.floor(positiveRemainder);
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Used to grok the `now` parameter to createClock.
|
|
1232
|
+
* @param {Date|number} epoch the system time
|
|
1233
|
+
* @returns {number}
|
|
1234
|
+
*/
|
|
1235
|
+
function getEpoch(epoch) {
|
|
1236
|
+
if (!epoch) {
|
|
1237
|
+
return 0;
|
|
1238
|
+
}
|
|
1239
|
+
if (typeof epoch.getTime === "function") {
|
|
1240
|
+
return epoch.getTime();
|
|
1241
|
+
}
|
|
1242
|
+
if (typeof epoch === "number") {
|
|
1243
|
+
return epoch;
|
|
1244
|
+
}
|
|
1245
|
+
throw new TypeError("now should be milliseconds since UNIX epoch");
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* @param {number} from
|
|
1249
|
+
* @param {number} to
|
|
1250
|
+
* @param {Timer} timer
|
|
1251
|
+
* @returns {boolean}
|
|
1252
|
+
*/
|
|
1253
|
+
function inRange(from, to, timer) {
|
|
1254
|
+
return timer && timer.callAt >= from && timer.callAt <= to;
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* @param {Clock} clock
|
|
1258
|
+
* @param {Timer} job
|
|
1259
|
+
*/
|
|
1260
|
+
function getInfiniteLoopError(clock, job) {
|
|
1261
|
+
const infiniteLoopError = new Error(`Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`);
|
|
1262
|
+
if (!job.error) {
|
|
1263
|
+
return infiniteLoopError;
|
|
1264
|
+
}
|
|
1265
|
+
const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
|
|
1266
|
+
let clockMethodPattern = new RegExp(String(Object.keys(clock).join("|")));
|
|
1267
|
+
if (addTimerReturnsObject) {
|
|
1268
|
+
clockMethodPattern = new RegExp(`\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`);
|
|
1269
|
+
}
|
|
1270
|
+
let matchedLineIndex = -1;
|
|
1271
|
+
job.error.stack.split("\n").some(function(line, i) {
|
|
1272
|
+
const matchedComputedTarget = line.match(computedTargetPattern);
|
|
1273
|
+
/* istanbul ignore if */
|
|
1274
|
+
if (matchedComputedTarget) {
|
|
1275
|
+
matchedLineIndex = i;
|
|
1276
|
+
return true;
|
|
1277
|
+
}
|
|
1278
|
+
const matchedClockMethod = line.match(clockMethodPattern);
|
|
1279
|
+
if (matchedClockMethod) {
|
|
1280
|
+
matchedLineIndex = i;
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
return matchedLineIndex >= 0;
|
|
1284
|
+
});
|
|
1285
|
+
const stack = `${infiniteLoopError}\n${job.type || "Microtask"} - ${job.func.name || "anonymous"}\n${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
|
|
1286
|
+
try {
|
|
1287
|
+
Object.defineProperty(infiniteLoopError, "stack", { value: stack });
|
|
1288
|
+
} catch (e) {}
|
|
1289
|
+
return infiniteLoopError;
|
|
1290
|
+
}
|
|
1291
|
+
function createDate() {
|
|
1292
|
+
class ClockDate extends NativeDate {
|
|
1293
|
+
/**
|
|
1294
|
+
* @param {number} year
|
|
1295
|
+
* @param {number} month
|
|
1296
|
+
* @param {number} date
|
|
1297
|
+
* @param {number} hour
|
|
1298
|
+
* @param {number} minute
|
|
1299
|
+
* @param {number} second
|
|
1300
|
+
* @param {number} ms
|
|
1301
|
+
* @returns void
|
|
1302
|
+
*/
|
|
1303
|
+
constructor(year, month, date, hour, minute, second, ms) {
|
|
1304
|
+
if (arguments.length === 0) {
|
|
1305
|
+
super(ClockDate.clock.now);
|
|
1306
|
+
} else {
|
|
1307
|
+
super(...arguments);
|
|
1308
|
+
}
|
|
1309
|
+
Object.defineProperty(this, "constructor", {
|
|
1310
|
+
value: NativeDate,
|
|
1311
|
+
enumerable: false
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
static [Symbol.hasInstance](instance) {
|
|
1315
|
+
return instance instanceof NativeDate;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
ClockDate.isFake = true;
|
|
1319
|
+
if (NativeDate.now) {
|
|
1320
|
+
ClockDate.now = function now() {
|
|
1321
|
+
return ClockDate.clock.now;
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
if (NativeDate.toSource) {
|
|
1325
|
+
ClockDate.toSource = function toSource() {
|
|
1326
|
+
return NativeDate.toSource();
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
ClockDate.toString = function toString() {
|
|
1330
|
+
return NativeDate.toString();
|
|
1331
|
+
};
|
|
1332
|
+
/**
|
|
1333
|
+
* A normal Class constructor cannot be called without `new`, but Date can, so we need
|
|
1334
|
+
* to wrap it in a Proxy in order to ensure this functionality of Date is kept intact
|
|
1335
|
+
* @type {ClockDate}
|
|
1336
|
+
*/
|
|
1337
|
+
const ClockDateProxy = new Proxy(ClockDate, { apply() {
|
|
1338
|
+
if (this instanceof ClockDate) {
|
|
1339
|
+
throw new TypeError("A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic.");
|
|
1340
|
+
}
|
|
1341
|
+
return new NativeDate(ClockDate.clock.now).toString();
|
|
1342
|
+
} });
|
|
1343
|
+
return ClockDateProxy;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Mirror Intl by default on our fake implementation
|
|
1347
|
+
*
|
|
1348
|
+
* Most of the properties are the original native ones,
|
|
1349
|
+
* but we need to take control of those that have a
|
|
1350
|
+
* dependency on the current clock.
|
|
1351
|
+
* @returns {object} the partly fake Intl implementation
|
|
1352
|
+
*/
|
|
1353
|
+
function createIntl() {
|
|
1354
|
+
const ClockIntl = {};
|
|
1355
|
+
Object.getOwnPropertyNames(NativeIntl).forEach((property) => ClockIntl[property] = NativeIntl[property]);
|
|
1356
|
+
ClockIntl.DateTimeFormat = function(...args) {
|
|
1357
|
+
const realFormatter = new NativeIntl.DateTimeFormat(...args);
|
|
1358
|
+
const formatter = {};
|
|
1359
|
+
[
|
|
1360
|
+
"formatRange",
|
|
1361
|
+
"formatRangeToParts",
|
|
1362
|
+
"resolvedOptions"
|
|
1363
|
+
].forEach((method) => {
|
|
1364
|
+
formatter[method] = realFormatter[method].bind(realFormatter);
|
|
1365
|
+
});
|
|
1366
|
+
["format", "formatToParts"].forEach((method) => {
|
|
1367
|
+
formatter[method] = function(date) {
|
|
1368
|
+
return realFormatter[method](date || ClockIntl.clock.now);
|
|
1369
|
+
};
|
|
1370
|
+
});
|
|
1371
|
+
return formatter;
|
|
1372
|
+
};
|
|
1373
|
+
ClockIntl.DateTimeFormat.prototype = Object.create(NativeIntl.DateTimeFormat.prototype);
|
|
1374
|
+
ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
|
|
1375
|
+
return ClockIntl;
|
|
1376
|
+
}
|
|
1377
|
+
function enqueueJob(clock, job) {
|
|
1378
|
+
if (!clock.jobs) {
|
|
1379
|
+
clock.jobs = [];
|
|
1380
|
+
}
|
|
1381
|
+
clock.jobs.push(job);
|
|
1382
|
+
}
|
|
1383
|
+
function runJobs(clock) {
|
|
1384
|
+
if (!clock.jobs) {
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
for (let i = 0; i < clock.jobs.length; i++) {
|
|
1388
|
+
const job = clock.jobs[i];
|
|
1389
|
+
job.func.apply(null, job.args);
|
|
1390
|
+
checkIsNearInfiniteLimit(clock, i);
|
|
1391
|
+
if (clock.loopLimit && i > clock.loopLimit) {
|
|
1392
|
+
throw getInfiniteLoopError(clock, job);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
resetIsNearInfiniteLimit();
|
|
1396
|
+
clock.jobs = [];
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* @param {Clock} clock
|
|
1400
|
+
* @param {Timer} timer
|
|
1401
|
+
* @returns {number} id of the created timer
|
|
1402
|
+
*/
|
|
1403
|
+
function addTimer(clock, timer) {
|
|
1404
|
+
if (timer.func === undefined) {
|
|
1405
|
+
throw new Error("Callback must be provided to timer calls");
|
|
1406
|
+
}
|
|
1407
|
+
if (addTimerReturnsObject) {
|
|
1408
|
+
if (typeof timer.func !== "function") {
|
|
1409
|
+
throw new TypeError(`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (isNearInfiniteLimit) {
|
|
1413
|
+
timer.error = new Error();
|
|
1414
|
+
}
|
|
1415
|
+
timer.type = timer.immediate ? "Immediate" : "Timeout";
|
|
1416
|
+
if (timer.hasOwnProperty("delay")) {
|
|
1417
|
+
if (typeof timer.delay !== "number") {
|
|
1418
|
+
timer.delay = parseInt(timer.delay, 10);
|
|
1419
|
+
}
|
|
1420
|
+
if (!isNumberFinite(timer.delay)) {
|
|
1421
|
+
timer.delay = 0;
|
|
1422
|
+
}
|
|
1423
|
+
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
|
|
1424
|
+
timer.delay = Math.max(0, timer.delay);
|
|
1425
|
+
}
|
|
1426
|
+
if (timer.hasOwnProperty("interval")) {
|
|
1427
|
+
timer.type = "Interval";
|
|
1428
|
+
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
|
|
1429
|
+
}
|
|
1430
|
+
if (timer.hasOwnProperty("animation")) {
|
|
1431
|
+
timer.type = "AnimationFrame";
|
|
1432
|
+
timer.animation = true;
|
|
1433
|
+
}
|
|
1434
|
+
if (timer.hasOwnProperty("idleCallback")) {
|
|
1435
|
+
timer.type = "IdleCallback";
|
|
1436
|
+
timer.idleCallback = true;
|
|
1437
|
+
}
|
|
1438
|
+
if (!clock.timers) {
|
|
1439
|
+
clock.timers = {};
|
|
1440
|
+
}
|
|
1441
|
+
timer.id = uniqueTimerId++;
|
|
1442
|
+
timer.createdAt = clock.now;
|
|
1443
|
+
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
1444
|
+
clock.timers[timer.id] = timer;
|
|
1445
|
+
if (addTimerReturnsObject) {
|
|
1446
|
+
const res = {
|
|
1447
|
+
refed: true,
|
|
1448
|
+
ref: function() {
|
|
1449
|
+
this.refed = true;
|
|
1450
|
+
return res;
|
|
1451
|
+
},
|
|
1452
|
+
unref: function() {
|
|
1453
|
+
this.refed = false;
|
|
1454
|
+
return res;
|
|
1455
|
+
},
|
|
1456
|
+
hasRef: function() {
|
|
1457
|
+
return this.refed;
|
|
1458
|
+
},
|
|
1459
|
+
refresh: function() {
|
|
1460
|
+
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
1461
|
+
clock.timers[timer.id] = timer;
|
|
1462
|
+
return res;
|
|
1463
|
+
},
|
|
1464
|
+
[Symbol.toPrimitive]: function() {
|
|
1465
|
+
return timer.id;
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
return res;
|
|
1469
|
+
}
|
|
1470
|
+
return timer.id;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Timer comparitor
|
|
1474
|
+
* @param {Timer} a
|
|
1475
|
+
* @param {Timer} b
|
|
1476
|
+
* @returns {number}
|
|
1477
|
+
*/
|
|
1478
|
+
function compareTimers(a, b) {
|
|
1479
|
+
if (a.callAt < b.callAt) {
|
|
1480
|
+
return -1;
|
|
1481
|
+
}
|
|
1482
|
+
if (a.callAt > b.callAt) {
|
|
1483
|
+
return 1;
|
|
1484
|
+
}
|
|
1485
|
+
if (a.immediate && !b.immediate) {
|
|
1486
|
+
return -1;
|
|
1487
|
+
}
|
|
1488
|
+
if (!a.immediate && b.immediate) {
|
|
1489
|
+
return 1;
|
|
1490
|
+
}
|
|
1491
|
+
if (a.createdAt < b.createdAt) {
|
|
1492
|
+
return -1;
|
|
1493
|
+
}
|
|
1494
|
+
if (a.createdAt > b.createdAt) {
|
|
1495
|
+
return 1;
|
|
1496
|
+
}
|
|
1497
|
+
if (a.id < b.id) {
|
|
1498
|
+
return -1;
|
|
1499
|
+
}
|
|
1500
|
+
if (a.id > b.id) {
|
|
1501
|
+
return 1;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* @param {Clock} clock
|
|
1506
|
+
* @param {number} from
|
|
1507
|
+
* @param {number} to
|
|
1508
|
+
* @returns {Timer}
|
|
1509
|
+
*/
|
|
1510
|
+
function firstTimerInRange(clock, from, to) {
|
|
1511
|
+
const timers$1 = clock.timers;
|
|
1512
|
+
let timer = null;
|
|
1513
|
+
let id, isInRange;
|
|
1514
|
+
for (id in timers$1) {
|
|
1515
|
+
if (timers$1.hasOwnProperty(id)) {
|
|
1516
|
+
isInRange = inRange(from, to, timers$1[id]);
|
|
1517
|
+
if (isInRange && (!timer || compareTimers(timer, timers$1[id]) === 1)) {
|
|
1518
|
+
timer = timers$1[id];
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return timer;
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* @param {Clock} clock
|
|
1526
|
+
* @returns {Timer}
|
|
1527
|
+
*/
|
|
1528
|
+
function firstTimer(clock) {
|
|
1529
|
+
const timers$1 = clock.timers;
|
|
1530
|
+
let timer = null;
|
|
1531
|
+
let id;
|
|
1532
|
+
for (id in timers$1) {
|
|
1533
|
+
if (timers$1.hasOwnProperty(id)) {
|
|
1534
|
+
if (!timer || compareTimers(timer, timers$1[id]) === 1) {
|
|
1535
|
+
timer = timers$1[id];
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return timer;
|
|
1540
|
+
}
|
|
1541
|
+
/**
|
|
1542
|
+
* @param {Clock} clock
|
|
1543
|
+
* @returns {Timer}
|
|
1544
|
+
*/
|
|
1545
|
+
function lastTimer(clock) {
|
|
1546
|
+
const timers$1 = clock.timers;
|
|
1547
|
+
let timer = null;
|
|
1548
|
+
let id;
|
|
1549
|
+
for (id in timers$1) {
|
|
1550
|
+
if (timers$1.hasOwnProperty(id)) {
|
|
1551
|
+
if (!timer || compareTimers(timer, timers$1[id]) === -1) {
|
|
1552
|
+
timer = timers$1[id];
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
return timer;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* @param {Clock} clock
|
|
1560
|
+
* @param {Timer} timer
|
|
1561
|
+
*/
|
|
1562
|
+
function callTimer(clock, timer) {
|
|
1563
|
+
if (typeof timer.interval === "number") {
|
|
1564
|
+
clock.timers[timer.id].callAt += timer.interval;
|
|
1565
|
+
} else {
|
|
1566
|
+
delete clock.timers[timer.id];
|
|
1567
|
+
}
|
|
1568
|
+
if (typeof timer.func === "function") {
|
|
1569
|
+
timer.func.apply(null, timer.args);
|
|
1570
|
+
} else {
|
|
1571
|
+
const eval2 = eval;
|
|
1572
|
+
(function() {
|
|
1573
|
+
eval2(timer.func);
|
|
1574
|
+
})();
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Gets clear handler name for a given timer type
|
|
1579
|
+
* @param {string} ttype
|
|
1580
|
+
*/
|
|
1581
|
+
function getClearHandler(ttype) {
|
|
1582
|
+
if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
|
|
1583
|
+
return `cancel${ttype}`;
|
|
1584
|
+
}
|
|
1585
|
+
return `clear${ttype}`;
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Gets schedule handler name for a given timer type
|
|
1589
|
+
* @param {string} ttype
|
|
1590
|
+
*/
|
|
1591
|
+
function getScheduleHandler(ttype) {
|
|
1592
|
+
if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
|
|
1593
|
+
return `request${ttype}`;
|
|
1594
|
+
}
|
|
1595
|
+
return `set${ttype}`;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Creates an anonymous function to warn only once
|
|
1599
|
+
*/
|
|
1600
|
+
function createWarnOnce() {
|
|
1601
|
+
let calls = 0;
|
|
1602
|
+
return function(msg) {
|
|
1603
|
+
!calls++ && console.warn(msg);
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
const warnOnce = createWarnOnce();
|
|
1607
|
+
/**
|
|
1608
|
+
* @param {Clock} clock
|
|
1609
|
+
* @param {number} timerId
|
|
1610
|
+
* @param {string} ttype
|
|
1611
|
+
*/
|
|
1612
|
+
function clearTimer(clock, timerId, ttype) {
|
|
1613
|
+
if (!timerId) {
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
if (!clock.timers) {
|
|
1617
|
+
clock.timers = {};
|
|
1618
|
+
}
|
|
1619
|
+
const id = Number(timerId);
|
|
1620
|
+
if (Number.isNaN(id) || id < idCounterStart) {
|
|
1621
|
+
const handlerName = getClearHandler(ttype);
|
|
1622
|
+
if (clock.shouldClearNativeTimers === true) {
|
|
1623
|
+
const nativeHandler = clock[`_${handlerName}`];
|
|
1624
|
+
return typeof nativeHandler === "function" ? nativeHandler(timerId) : undefined;
|
|
1625
|
+
}
|
|
1626
|
+
warnOnce(`FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.` + "\nTo automatically clean-up native timers, use `shouldClearNativeTimers`.");
|
|
1627
|
+
}
|
|
1628
|
+
if (clock.timers.hasOwnProperty(id)) {
|
|
1629
|
+
const timer = clock.timers[id];
|
|
1630
|
+
if (timer.type === ttype || timer.type === "Timeout" && ttype === "Interval" || timer.type === "Interval" && ttype === "Timeout") {
|
|
1631
|
+
delete clock.timers[id];
|
|
1632
|
+
} else {
|
|
1633
|
+
const clear = getClearHandler(ttype);
|
|
1634
|
+
const schedule = getScheduleHandler(timer.type);
|
|
1635
|
+
throw new Error(`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* @param {Clock} clock
|
|
1641
|
+
* @param {Config} config
|
|
1642
|
+
* @returns {Timer[]}
|
|
1643
|
+
*/
|
|
1644
|
+
function uninstall(clock, config) {
|
|
1645
|
+
let method, i, l;
|
|
1646
|
+
const installedHrTime = "_hrtime";
|
|
1647
|
+
const installedNextTick = "_nextTick";
|
|
1648
|
+
for (i = 0, l = clock.methods.length; i < l; i++) {
|
|
1649
|
+
method = clock.methods[i];
|
|
1650
|
+
if (method === "hrtime" && _global.process) {
|
|
1651
|
+
_global.process.hrtime = clock[installedHrTime];
|
|
1652
|
+
} else if (method === "nextTick" && _global.process) {
|
|
1653
|
+
_global.process.nextTick = clock[installedNextTick];
|
|
1654
|
+
} else if (method === "performance") {
|
|
1655
|
+
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(clock, `_${method}`);
|
|
1656
|
+
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
|
|
1657
|
+
Object.defineProperty(_global, method, originalPerfDescriptor);
|
|
1658
|
+
} else if (originalPerfDescriptor.configurable) {
|
|
1659
|
+
_global[method] = clock[`_${method}`];
|
|
1660
|
+
}
|
|
1661
|
+
} else {
|
|
1662
|
+
if (_global[method] && _global[method].hadOwnProperty) {
|
|
1663
|
+
_global[method] = clock[`_${method}`];
|
|
1664
|
+
} else {
|
|
1665
|
+
try {
|
|
1666
|
+
delete _global[method];
|
|
1667
|
+
} catch (ignore) {}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
if (clock.timersModuleMethods !== undefined) {
|
|
1671
|
+
for (let j = 0; j < clock.timersModuleMethods.length; j++) {
|
|
1672
|
+
const entry = clock.timersModuleMethods[j];
|
|
1673
|
+
timersModule[entry.methodName] = entry.original;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
if (clock.timersPromisesModuleMethods !== undefined) {
|
|
1677
|
+
for (let j = 0; j < clock.timersPromisesModuleMethods.length; j++) {
|
|
1678
|
+
const entry = clock.timersPromisesModuleMethods[j];
|
|
1679
|
+
timersPromisesModule[entry.methodName] = entry.original;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
if (config.shouldAdvanceTime === true) {
|
|
1684
|
+
_global.clearInterval(clock.attachedInterval);
|
|
1685
|
+
}
|
|
1686
|
+
clock.methods = [];
|
|
1687
|
+
for (const [listener, signal] of clock.abortListenerMap.entries()) {
|
|
1688
|
+
signal.removeEventListener("abort", listener);
|
|
1689
|
+
clock.abortListenerMap.delete(listener);
|
|
1690
|
+
}
|
|
1691
|
+
if (!clock.timers) {
|
|
1692
|
+
return [];
|
|
1693
|
+
}
|
|
1694
|
+
return Object.keys(clock.timers).map(function mapper(key) {
|
|
1695
|
+
return clock.timers[key];
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* @param {object} target the target containing the method to replace
|
|
1700
|
+
* @param {string} method the keyname of the method on the target
|
|
1701
|
+
* @param {Clock} clock
|
|
1702
|
+
*/
|
|
1703
|
+
function hijackMethod(target, method, clock) {
|
|
1704
|
+
clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(target, method);
|
|
1705
|
+
clock[`_${method}`] = target[method];
|
|
1706
|
+
if (method === "Date") {
|
|
1707
|
+
target[method] = clock[method];
|
|
1708
|
+
} else if (method === "Intl") {
|
|
1709
|
+
target[method] = clock[method];
|
|
1710
|
+
} else if (method === "performance") {
|
|
1711
|
+
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(target, method);
|
|
1712
|
+
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
|
|
1713
|
+
Object.defineProperty(clock, `_${method}`, originalPerfDescriptor);
|
|
1714
|
+
const perfDescriptor = Object.getOwnPropertyDescriptor(clock, method);
|
|
1715
|
+
Object.defineProperty(target, method, perfDescriptor);
|
|
1716
|
+
} else {
|
|
1717
|
+
target[method] = clock[method];
|
|
1718
|
+
}
|
|
1719
|
+
} else {
|
|
1720
|
+
target[method] = function() {
|
|
1721
|
+
return clock[method].apply(clock, arguments);
|
|
1722
|
+
};
|
|
1723
|
+
Object.defineProperties(target[method], Object.getOwnPropertyDescriptors(clock[method]));
|
|
1724
|
+
}
|
|
1725
|
+
target[method].clock = clock;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* @param {Clock} clock
|
|
1729
|
+
* @param {number} advanceTimeDelta
|
|
1730
|
+
*/
|
|
1731
|
+
function doIntervalTick(clock, advanceTimeDelta) {
|
|
1732
|
+
clock.tick(advanceTimeDelta);
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* @typedef {object} Timers
|
|
1736
|
+
* @property {setTimeout} setTimeout
|
|
1737
|
+
* @property {clearTimeout} clearTimeout
|
|
1738
|
+
* @property {setInterval} setInterval
|
|
1739
|
+
* @property {clearInterval} clearInterval
|
|
1740
|
+
* @property {Date} Date
|
|
1741
|
+
* @property {Intl} Intl
|
|
1742
|
+
* @property {SetImmediate=} setImmediate
|
|
1743
|
+
* @property {function(NodeImmediate): void=} clearImmediate
|
|
1744
|
+
* @property {function(number[]):number[]=} hrtime
|
|
1745
|
+
* @property {NextTick=} nextTick
|
|
1746
|
+
* @property {Performance=} performance
|
|
1747
|
+
* @property {RequestAnimationFrame=} requestAnimationFrame
|
|
1748
|
+
* @property {boolean=} queueMicrotask
|
|
1749
|
+
* @property {function(number): void=} cancelAnimationFrame
|
|
1750
|
+
* @property {RequestIdleCallback=} requestIdleCallback
|
|
1751
|
+
* @property {function(number): void=} cancelIdleCallback
|
|
1752
|
+
*/
|
|
1753
|
+
/** @type {Timers} */
|
|
1754
|
+
const timers = {
|
|
1755
|
+
setTimeout: _global.setTimeout,
|
|
1756
|
+
clearTimeout: _global.clearTimeout,
|
|
1757
|
+
setInterval: _global.setInterval,
|
|
1758
|
+
clearInterval: _global.clearInterval,
|
|
1759
|
+
Date: _global.Date
|
|
1760
|
+
};
|
|
1761
|
+
if (isPresent.setImmediate) {
|
|
1762
|
+
timers.setImmediate = _global.setImmediate;
|
|
1763
|
+
}
|
|
1764
|
+
if (isPresent.clearImmediate) {
|
|
1765
|
+
timers.clearImmediate = _global.clearImmediate;
|
|
1766
|
+
}
|
|
1767
|
+
if (isPresent.hrtime) {
|
|
1768
|
+
timers.hrtime = _global.process.hrtime;
|
|
1769
|
+
}
|
|
1770
|
+
if (isPresent.nextTick) {
|
|
1771
|
+
timers.nextTick = _global.process.nextTick;
|
|
1772
|
+
}
|
|
1773
|
+
if (isPresent.performance) {
|
|
1774
|
+
timers.performance = _global.performance;
|
|
1775
|
+
}
|
|
1776
|
+
if (isPresent.requestAnimationFrame) {
|
|
1777
|
+
timers.requestAnimationFrame = _global.requestAnimationFrame;
|
|
1778
|
+
}
|
|
1779
|
+
if (isPresent.queueMicrotask) {
|
|
1780
|
+
timers.queueMicrotask = _global.queueMicrotask;
|
|
1781
|
+
}
|
|
1782
|
+
if (isPresent.cancelAnimationFrame) {
|
|
1783
|
+
timers.cancelAnimationFrame = _global.cancelAnimationFrame;
|
|
1784
|
+
}
|
|
1785
|
+
if (isPresent.requestIdleCallback) {
|
|
1786
|
+
timers.requestIdleCallback = _global.requestIdleCallback;
|
|
1787
|
+
}
|
|
1788
|
+
if (isPresent.cancelIdleCallback) {
|
|
1789
|
+
timers.cancelIdleCallback = _global.cancelIdleCallback;
|
|
1790
|
+
}
|
|
1791
|
+
if (isPresent.Intl) {
|
|
1792
|
+
timers.Intl = NativeIntl;
|
|
1793
|
+
}
|
|
1794
|
+
const originalSetTimeout = _global.setImmediate || _global.setTimeout;
|
|
1795
|
+
/**
|
|
1796
|
+
* @param {Date|number} [start] the system time - non-integer values are floored
|
|
1797
|
+
* @param {number} [loopLimit] maximum number of timers that will be run when calling runAll()
|
|
1798
|
+
* @returns {Clock}
|
|
1799
|
+
*/
|
|
1800
|
+
function createClock(start, loopLimit) {
|
|
1801
|
+
start = Math.floor(getEpoch(start));
|
|
1802
|
+
loopLimit = loopLimit || 1e3;
|
|
1803
|
+
let nanos = 0;
|
|
1804
|
+
const adjustedSystemTime = [0, 0];
|
|
1805
|
+
const clock = {
|
|
1806
|
+
now: start,
|
|
1807
|
+
Date: createDate(),
|
|
1808
|
+
loopLimit
|
|
1809
|
+
};
|
|
1810
|
+
clock.Date.clock = clock;
|
|
1811
|
+
function getTimeToNextFrame() {
|
|
1812
|
+
return 16 - (clock.now - start) % 16;
|
|
1813
|
+
}
|
|
1814
|
+
function hrtime(prev) {
|
|
1815
|
+
const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
|
|
1816
|
+
const secsSinceStart = Math.floor(millisSinceStart / 1e3);
|
|
1817
|
+
const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];
|
|
1818
|
+
if (Array.isArray(prev)) {
|
|
1819
|
+
if (prev[1] > 1e9) {
|
|
1820
|
+
throw new TypeError("Number of nanoseconds can't exceed a billion");
|
|
1821
|
+
}
|
|
1822
|
+
const oldSecs = prev[0];
|
|
1823
|
+
let nanoDiff = remainderInNanos - prev[1];
|
|
1824
|
+
let secDiff = secsSinceStart - oldSecs;
|
|
1825
|
+
if (nanoDiff < 0) {
|
|
1826
|
+
nanoDiff += 1e9;
|
|
1827
|
+
secDiff -= 1;
|
|
1828
|
+
}
|
|
1829
|
+
return [secDiff, nanoDiff];
|
|
1830
|
+
}
|
|
1831
|
+
return [secsSinceStart, remainderInNanos];
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* A high resolution timestamp in milliseconds.
|
|
1835
|
+
* @typedef {number} DOMHighResTimeStamp
|
|
1836
|
+
*/
|
|
1837
|
+
/**
|
|
1838
|
+
* performance.now()
|
|
1839
|
+
* @returns {DOMHighResTimeStamp}
|
|
1840
|
+
*/
|
|
1841
|
+
function fakePerformanceNow() {
|
|
1842
|
+
const hrt = hrtime();
|
|
1843
|
+
const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
|
|
1844
|
+
return millis;
|
|
1845
|
+
}
|
|
1846
|
+
if (isPresent.hrtimeBigint) {
|
|
1847
|
+
hrtime.bigint = function() {
|
|
1848
|
+
const parts = hrtime();
|
|
1849
|
+
return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
|
|
1850
|
+
};
|
|
1851
|
+
}
|
|
1852
|
+
if (isPresent.Intl) {
|
|
1853
|
+
clock.Intl = createIntl();
|
|
1854
|
+
clock.Intl.clock = clock;
|
|
1855
|
+
}
|
|
1856
|
+
clock.requestIdleCallback = function requestIdleCallback(func, timeout) {
|
|
1857
|
+
let timeToNextIdlePeriod = 0;
|
|
1858
|
+
if (clock.countTimers() > 0) {
|
|
1859
|
+
timeToNextIdlePeriod = 50;
|
|
1860
|
+
}
|
|
1861
|
+
const result = addTimer(clock, {
|
|
1862
|
+
func,
|
|
1863
|
+
args: Array.prototype.slice.call(arguments, 2),
|
|
1864
|
+
delay: typeof timeout === "undefined" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),
|
|
1865
|
+
idleCallback: true
|
|
1866
|
+
});
|
|
1867
|
+
return Number(result);
|
|
1868
|
+
};
|
|
1869
|
+
clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
|
|
1870
|
+
return clearTimer(clock, timerId, "IdleCallback");
|
|
1871
|
+
};
|
|
1872
|
+
clock.setTimeout = function setTimeout(func, timeout) {
|
|
1873
|
+
return addTimer(clock, {
|
|
1874
|
+
func,
|
|
1875
|
+
args: Array.prototype.slice.call(arguments, 2),
|
|
1876
|
+
delay: timeout
|
|
1877
|
+
});
|
|
1878
|
+
};
|
|
1879
|
+
if (typeof _global.Promise !== "undefined" && utilPromisify) {
|
|
1880
|
+
clock.setTimeout[utilPromisify.custom] = function promisifiedSetTimeout(timeout, arg) {
|
|
1881
|
+
return new _global.Promise(function setTimeoutExecutor(resolve) {
|
|
1882
|
+
addTimer(clock, {
|
|
1883
|
+
func: resolve,
|
|
1884
|
+
args: [arg],
|
|
1885
|
+
delay: timeout
|
|
1886
|
+
});
|
|
1887
|
+
});
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
clock.clearTimeout = function clearTimeout(timerId) {
|
|
1891
|
+
return clearTimer(clock, timerId, "Timeout");
|
|
1892
|
+
};
|
|
1893
|
+
clock.nextTick = function nextTick(func) {
|
|
1894
|
+
return enqueueJob(clock, {
|
|
1895
|
+
func,
|
|
1896
|
+
args: Array.prototype.slice.call(arguments, 1),
|
|
1897
|
+
error: isNearInfiniteLimit ? new Error() : null
|
|
1898
|
+
});
|
|
1899
|
+
};
|
|
1900
|
+
clock.queueMicrotask = function queueMicrotask(func) {
|
|
1901
|
+
return clock.nextTick(func);
|
|
1902
|
+
};
|
|
1903
|
+
clock.setInterval = function setInterval(func, timeout) {
|
|
1904
|
+
timeout = parseInt(timeout, 10);
|
|
1905
|
+
return addTimer(clock, {
|
|
1906
|
+
func,
|
|
1907
|
+
args: Array.prototype.slice.call(arguments, 2),
|
|
1908
|
+
delay: timeout,
|
|
1909
|
+
interval: timeout
|
|
1910
|
+
});
|
|
1911
|
+
};
|
|
1912
|
+
clock.clearInterval = function clearInterval(timerId) {
|
|
1913
|
+
return clearTimer(clock, timerId, "Interval");
|
|
1914
|
+
};
|
|
1915
|
+
if (isPresent.setImmediate) {
|
|
1916
|
+
clock.setImmediate = function setImmediate(func) {
|
|
1917
|
+
return addTimer(clock, {
|
|
1918
|
+
func,
|
|
1919
|
+
args: Array.prototype.slice.call(arguments, 1),
|
|
1920
|
+
immediate: true
|
|
1921
|
+
});
|
|
1922
|
+
};
|
|
1923
|
+
if (typeof _global.Promise !== "undefined" && utilPromisify) {
|
|
1924
|
+
clock.setImmediate[utilPromisify.custom] = function promisifiedSetImmediate(arg) {
|
|
1925
|
+
return new _global.Promise(function setImmediateExecutor(resolve) {
|
|
1926
|
+
addTimer(clock, {
|
|
1927
|
+
func: resolve,
|
|
1928
|
+
args: [arg],
|
|
1929
|
+
immediate: true
|
|
1930
|
+
});
|
|
1931
|
+
});
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
clock.clearImmediate = function clearImmediate(timerId) {
|
|
1935
|
+
return clearTimer(clock, timerId, "Immediate");
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
clock.countTimers = function countTimers() {
|
|
1939
|
+
return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;
|
|
1940
|
+
};
|
|
1941
|
+
clock.requestAnimationFrame = function requestAnimationFrame(func) {
|
|
1942
|
+
const result = addTimer(clock, {
|
|
1943
|
+
func,
|
|
1944
|
+
delay: getTimeToNextFrame(),
|
|
1945
|
+
get args() {
|
|
1946
|
+
return [fakePerformanceNow()];
|
|
1947
|
+
},
|
|
1948
|
+
animation: true
|
|
1949
|
+
});
|
|
1950
|
+
return Number(result);
|
|
1951
|
+
};
|
|
1952
|
+
clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {
|
|
1953
|
+
return clearTimer(clock, timerId, "AnimationFrame");
|
|
1954
|
+
};
|
|
1955
|
+
clock.runMicrotasks = function runMicrotasks() {
|
|
1956
|
+
runJobs(clock);
|
|
1957
|
+
};
|
|
1958
|
+
/**
|
|
1959
|
+
* @param {number|string} tickValue milliseconds or a string parseable by parseTime
|
|
1960
|
+
* @param {boolean} isAsync
|
|
1961
|
+
* @param {Function} resolve
|
|
1962
|
+
* @param {Function} reject
|
|
1963
|
+
* @returns {number|undefined} will return the new `now` value or nothing for async
|
|
1964
|
+
*/
|
|
1965
|
+
function doTick(tickValue, isAsync, resolve, reject) {
|
|
1966
|
+
const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
|
|
1967
|
+
const ms = Math.floor(msFloat);
|
|
1968
|
+
const remainder = nanoRemainder(msFloat);
|
|
1969
|
+
let nanosTotal = nanos + remainder;
|
|
1970
|
+
let tickTo = clock.now + ms;
|
|
1971
|
+
if (msFloat < 0) {
|
|
1972
|
+
throw new TypeError("Negative ticks are not supported");
|
|
1973
|
+
}
|
|
1974
|
+
if (nanosTotal >= 1e6) {
|
|
1975
|
+
tickTo += 1;
|
|
1976
|
+
nanosTotal -= 1e6;
|
|
1977
|
+
}
|
|
1978
|
+
nanos = nanosTotal;
|
|
1979
|
+
let tickFrom = clock.now;
|
|
1980
|
+
let previous = clock.now;
|
|
1981
|
+
let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
|
|
1982
|
+
clock.duringTick = true;
|
|
1983
|
+
oldNow = clock.now;
|
|
1984
|
+
runJobs(clock);
|
|
1985
|
+
if (oldNow !== clock.now) {
|
|
1986
|
+
tickFrom += clock.now - oldNow;
|
|
1987
|
+
tickTo += clock.now - oldNow;
|
|
1988
|
+
}
|
|
1989
|
+
function doTickInner() {
|
|
1990
|
+
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
|
1991
|
+
while (timer && tickFrom <= tickTo) {
|
|
1992
|
+
if (clock.timers[timer.id]) {
|
|
1993
|
+
tickFrom = timer.callAt;
|
|
1994
|
+
clock.now = timer.callAt;
|
|
1995
|
+
oldNow = clock.now;
|
|
1996
|
+
try {
|
|
1997
|
+
runJobs(clock);
|
|
1998
|
+
callTimer(clock, timer);
|
|
1999
|
+
} catch (e) {
|
|
2000
|
+
firstException = firstException || e;
|
|
2001
|
+
}
|
|
2002
|
+
if (isAsync) {
|
|
2003
|
+
originalSetTimeout(nextPromiseTick);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
compensationCheck();
|
|
2007
|
+
}
|
|
2008
|
+
postTimerCall();
|
|
2009
|
+
}
|
|
2010
|
+
oldNow = clock.now;
|
|
2011
|
+
runJobs(clock);
|
|
2012
|
+
if (oldNow !== clock.now) {
|
|
2013
|
+
tickFrom += clock.now - oldNow;
|
|
2014
|
+
tickTo += clock.now - oldNow;
|
|
2015
|
+
}
|
|
2016
|
+
clock.duringTick = false;
|
|
2017
|
+
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
|
2018
|
+
if (timer) {
|
|
2019
|
+
try {
|
|
2020
|
+
clock.tick(tickTo - clock.now);
|
|
2021
|
+
} catch (e) {
|
|
2022
|
+
firstException = firstException || e;
|
|
2023
|
+
}
|
|
2024
|
+
} else {
|
|
2025
|
+
clock.now = tickTo;
|
|
2026
|
+
nanos = nanosTotal;
|
|
2027
|
+
}
|
|
2028
|
+
if (firstException) {
|
|
2029
|
+
throw firstException;
|
|
2030
|
+
}
|
|
2031
|
+
if (isAsync) {
|
|
2032
|
+
resolve(clock.now);
|
|
2033
|
+
} else {
|
|
2034
|
+
return clock.now;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
nextPromiseTick = isAsync && function() {
|
|
2038
|
+
try {
|
|
2039
|
+
compensationCheck();
|
|
2040
|
+
postTimerCall();
|
|
2041
|
+
doTickInner();
|
|
2042
|
+
} catch (e) {
|
|
2043
|
+
reject(e);
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
compensationCheck = function() {
|
|
2047
|
+
if (oldNow !== clock.now) {
|
|
2048
|
+
tickFrom += clock.now - oldNow;
|
|
2049
|
+
tickTo += clock.now - oldNow;
|
|
2050
|
+
previous += clock.now - oldNow;
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
postTimerCall = function() {
|
|
2054
|
+
timer = firstTimerInRange(clock, previous, tickTo);
|
|
2055
|
+
previous = tickFrom;
|
|
2056
|
+
};
|
|
2057
|
+
return doTickInner();
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
|
|
2061
|
+
* @returns {number} will return the new `now` value
|
|
2062
|
+
*/
|
|
2063
|
+
clock.tick = function tick(tickValue) {
|
|
2064
|
+
return doTick(tickValue, false);
|
|
2065
|
+
};
|
|
2066
|
+
if (typeof _global.Promise !== "undefined") {
|
|
2067
|
+
/**
|
|
2068
|
+
* @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
|
|
2069
|
+
* @returns {Promise}
|
|
2070
|
+
*/
|
|
2071
|
+
clock.tickAsync = function tickAsync(tickValue) {
|
|
2072
|
+
return new _global.Promise(function(resolve, reject) {
|
|
2073
|
+
originalSetTimeout(function() {
|
|
2074
|
+
try {
|
|
2075
|
+
doTick(tickValue, true, resolve, reject);
|
|
2076
|
+
} catch (e) {
|
|
2077
|
+
reject(e);
|
|
2078
|
+
}
|
|
2079
|
+
});
|
|
2080
|
+
});
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
clock.next = function next() {
|
|
2084
|
+
runJobs(clock);
|
|
2085
|
+
const timer = firstTimer(clock);
|
|
2086
|
+
if (!timer) {
|
|
2087
|
+
return clock.now;
|
|
2088
|
+
}
|
|
2089
|
+
clock.duringTick = true;
|
|
2090
|
+
try {
|
|
2091
|
+
clock.now = timer.callAt;
|
|
2092
|
+
callTimer(clock, timer);
|
|
2093
|
+
runJobs(clock);
|
|
2094
|
+
return clock.now;
|
|
2095
|
+
} finally {
|
|
2096
|
+
clock.duringTick = false;
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
if (typeof _global.Promise !== "undefined") {
|
|
2100
|
+
clock.nextAsync = function nextAsync() {
|
|
2101
|
+
return new _global.Promise(function(resolve, reject) {
|
|
2102
|
+
originalSetTimeout(function() {
|
|
2103
|
+
try {
|
|
2104
|
+
const timer = firstTimer(clock);
|
|
2105
|
+
if (!timer) {
|
|
2106
|
+
resolve(clock.now);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
let err;
|
|
2110
|
+
clock.duringTick = true;
|
|
2111
|
+
clock.now = timer.callAt;
|
|
2112
|
+
try {
|
|
2113
|
+
callTimer(clock, timer);
|
|
2114
|
+
} catch (e) {
|
|
2115
|
+
err = e;
|
|
2116
|
+
}
|
|
2117
|
+
clock.duringTick = false;
|
|
2118
|
+
originalSetTimeout(function() {
|
|
2119
|
+
if (err) {
|
|
2120
|
+
reject(err);
|
|
2121
|
+
} else {
|
|
2122
|
+
resolve(clock.now);
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
} catch (e) {
|
|
2126
|
+
reject(e);
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
});
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
clock.runAll = function runAll() {
|
|
2133
|
+
let numTimers, i;
|
|
2134
|
+
runJobs(clock);
|
|
2135
|
+
for (i = 0; i < clock.loopLimit; i++) {
|
|
2136
|
+
if (!clock.timers) {
|
|
2137
|
+
resetIsNearInfiniteLimit();
|
|
2138
|
+
return clock.now;
|
|
2139
|
+
}
|
|
2140
|
+
numTimers = Object.keys(clock.timers).length;
|
|
2141
|
+
if (numTimers === 0) {
|
|
2142
|
+
resetIsNearInfiniteLimit();
|
|
2143
|
+
return clock.now;
|
|
2144
|
+
}
|
|
2145
|
+
clock.next();
|
|
2146
|
+
checkIsNearInfiniteLimit(clock, i);
|
|
2147
|
+
}
|
|
2148
|
+
const excessJob = firstTimer(clock);
|
|
2149
|
+
throw getInfiniteLoopError(clock, excessJob);
|
|
2150
|
+
};
|
|
2151
|
+
clock.runToFrame = function runToFrame() {
|
|
2152
|
+
return clock.tick(getTimeToNextFrame());
|
|
2153
|
+
};
|
|
2154
|
+
if (typeof _global.Promise !== "undefined") {
|
|
2155
|
+
clock.runAllAsync = function runAllAsync() {
|
|
2156
|
+
return new _global.Promise(function(resolve, reject) {
|
|
2157
|
+
let i = 0;
|
|
2158
|
+
/**
|
|
2159
|
+
*
|
|
2160
|
+
*/
|
|
2161
|
+
function doRun() {
|
|
2162
|
+
originalSetTimeout(function() {
|
|
2163
|
+
try {
|
|
2164
|
+
runJobs(clock);
|
|
2165
|
+
let numTimers;
|
|
2166
|
+
if (i < clock.loopLimit) {
|
|
2167
|
+
if (!clock.timers) {
|
|
2168
|
+
resetIsNearInfiniteLimit();
|
|
2169
|
+
resolve(clock.now);
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
numTimers = Object.keys(clock.timers).length;
|
|
2173
|
+
if (numTimers === 0) {
|
|
2174
|
+
resetIsNearInfiniteLimit();
|
|
2175
|
+
resolve(clock.now);
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
clock.next();
|
|
2179
|
+
i++;
|
|
2180
|
+
doRun();
|
|
2181
|
+
checkIsNearInfiniteLimit(clock, i);
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
const excessJob = firstTimer(clock);
|
|
2185
|
+
reject(getInfiniteLoopError(clock, excessJob));
|
|
2186
|
+
} catch (e) {
|
|
2187
|
+
reject(e);
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
doRun();
|
|
2192
|
+
});
|
|
2193
|
+
};
|
|
2194
|
+
}
|
|
2195
|
+
clock.runToLast = function runToLast() {
|
|
2196
|
+
const timer = lastTimer(clock);
|
|
2197
|
+
if (!timer) {
|
|
2198
|
+
runJobs(clock);
|
|
2199
|
+
return clock.now;
|
|
2200
|
+
}
|
|
2201
|
+
return clock.tick(timer.callAt - clock.now);
|
|
2202
|
+
};
|
|
2203
|
+
if (typeof _global.Promise !== "undefined") {
|
|
2204
|
+
clock.runToLastAsync = function runToLastAsync() {
|
|
2205
|
+
return new _global.Promise(function(resolve, reject) {
|
|
2206
|
+
originalSetTimeout(function() {
|
|
2207
|
+
try {
|
|
2208
|
+
const timer = lastTimer(clock);
|
|
2209
|
+
if (!timer) {
|
|
2210
|
+
runJobs(clock);
|
|
2211
|
+
resolve(clock.now);
|
|
2212
|
+
}
|
|
2213
|
+
resolve(clock.tickAsync(timer.callAt - clock.now));
|
|
2214
|
+
} catch (e) {
|
|
2215
|
+
reject(e);
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
});
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
clock.reset = function reset() {
|
|
2222
|
+
nanos = 0;
|
|
2223
|
+
clock.timers = {};
|
|
2224
|
+
clock.jobs = [];
|
|
2225
|
+
clock.now = start;
|
|
2226
|
+
};
|
|
2227
|
+
clock.setSystemTime = function setSystemTime(systemTime) {
|
|
2228
|
+
const newNow = getEpoch(systemTime);
|
|
2229
|
+
const difference = newNow - clock.now;
|
|
2230
|
+
let id, timer;
|
|
2231
|
+
adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
|
|
2232
|
+
adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
|
|
2233
|
+
clock.now = newNow;
|
|
2234
|
+
nanos = 0;
|
|
2235
|
+
for (id in clock.timers) {
|
|
2236
|
+
if (clock.timers.hasOwnProperty(id)) {
|
|
2237
|
+
timer = clock.timers[id];
|
|
2238
|
+
timer.createdAt += difference;
|
|
2239
|
+
timer.callAt += difference;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
/**
|
|
2244
|
+
* @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
|
|
2245
|
+
* @returns {number} will return the new `now` value
|
|
2246
|
+
*/
|
|
2247
|
+
clock.jump = function jump(tickValue) {
|
|
2248
|
+
const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
|
|
2249
|
+
const ms = Math.floor(msFloat);
|
|
2250
|
+
for (const timer of Object.values(clock.timers)) {
|
|
2251
|
+
if (clock.now + ms > timer.callAt) {
|
|
2252
|
+
timer.callAt = clock.now + ms;
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
clock.tick(ms);
|
|
2256
|
+
};
|
|
2257
|
+
if (isPresent.performance) {
|
|
2258
|
+
clock.performance = Object.create(null);
|
|
2259
|
+
clock.performance.now = fakePerformanceNow;
|
|
2260
|
+
}
|
|
2261
|
+
if (isPresent.hrtime) {
|
|
2262
|
+
clock.hrtime = hrtime;
|
|
2263
|
+
}
|
|
2264
|
+
return clock;
|
|
2265
|
+
}
|
|
2266
|
+
/**
|
|
2267
|
+
* @param {Config=} [config] Optional config
|
|
2268
|
+
* @returns {Clock}
|
|
2269
|
+
*/
|
|
2270
|
+
function install(config) {
|
|
2271
|
+
if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === "number") {
|
|
2272
|
+
throw new TypeError(`FakeTimers.install called with ${String(config)} install requires an object parameter`);
|
|
2273
|
+
}
|
|
2274
|
+
if (_global.Date.isFake === true) {
|
|
2275
|
+
throw new TypeError("Can't install fake timers twice on the same global object.");
|
|
2276
|
+
}
|
|
2277
|
+
config = typeof config !== "undefined" ? config : {};
|
|
2278
|
+
config.shouldAdvanceTime = config.shouldAdvanceTime || false;
|
|
2279
|
+
config.advanceTimeDelta = config.advanceTimeDelta || 20;
|
|
2280
|
+
config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
|
|
2281
|
+
if (config.target) {
|
|
2282
|
+
throw new TypeError("config.target is no longer supported. Use `withGlobal(target)` instead.");
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* @param {string} timer/object the name of the thing that is not present
|
|
2286
|
+
* @param timer
|
|
2287
|
+
*/
|
|
2288
|
+
function handleMissingTimer(timer) {
|
|
2289
|
+
if (config.ignoreMissingTimers) {
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
throw new ReferenceError(`non-existent timers and/or objects cannot be faked: '${timer}'`);
|
|
2293
|
+
}
|
|
2294
|
+
let i, l;
|
|
2295
|
+
const clock = createClock(config.now, config.loopLimit);
|
|
2296
|
+
clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
|
|
2297
|
+
clock.uninstall = function() {
|
|
2298
|
+
return uninstall(clock, config);
|
|
2299
|
+
};
|
|
2300
|
+
clock.abortListenerMap = new Map();
|
|
2301
|
+
clock.methods = config.toFake || [];
|
|
2302
|
+
if (clock.methods.length === 0) {
|
|
2303
|
+
clock.methods = Object.keys(timers);
|
|
2304
|
+
}
|
|
2305
|
+
if (config.shouldAdvanceTime === true) {
|
|
2306
|
+
const intervalTick = doIntervalTick.bind(null, clock, config.advanceTimeDelta);
|
|
2307
|
+
const intervalId = _global.setInterval(intervalTick, config.advanceTimeDelta);
|
|
2308
|
+
clock.attachedInterval = intervalId;
|
|
2309
|
+
}
|
|
2310
|
+
if (clock.methods.includes("performance")) {
|
|
2311
|
+
const proto = (() => {
|
|
2312
|
+
if (hasPerformanceConstructorPrototype) {
|
|
2313
|
+
return _global.performance.constructor.prototype;
|
|
2314
|
+
}
|
|
2315
|
+
if (hasPerformancePrototype) {
|
|
2316
|
+
return _global.Performance.prototype;
|
|
2317
|
+
}
|
|
2318
|
+
})();
|
|
2319
|
+
if (proto) {
|
|
2320
|
+
Object.getOwnPropertyNames(proto).forEach(function(name) {
|
|
2321
|
+
if (name !== "now") {
|
|
2322
|
+
clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
|
|
2323
|
+
}
|
|
2324
|
+
});
|
|
2325
|
+
clock.performance.mark = (name) => new FakePerformanceEntry(name, "mark", 0, 0);
|
|
2326
|
+
clock.performance.measure = (name) => new FakePerformanceEntry(name, "measure", 0, 100);
|
|
2327
|
+
clock.performance.timeOrigin = getEpoch(config.now);
|
|
2328
|
+
} else if ((config.toFake || []).includes("performance")) {
|
|
2329
|
+
return handleMissingTimer("performance");
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
if (_global === globalObject && timersModule) {
|
|
2333
|
+
clock.timersModuleMethods = [];
|
|
2334
|
+
}
|
|
2335
|
+
if (_global === globalObject && timersPromisesModule) {
|
|
2336
|
+
clock.timersPromisesModuleMethods = [];
|
|
2337
|
+
}
|
|
2338
|
+
for (i = 0, l = clock.methods.length; i < l; i++) {
|
|
2339
|
+
const nameOfMethodToReplace = clock.methods[i];
|
|
2340
|
+
if (!isPresent[nameOfMethodToReplace]) {
|
|
2341
|
+
handleMissingTimer(nameOfMethodToReplace);
|
|
2342
|
+
continue;
|
|
2343
|
+
}
|
|
2344
|
+
if (nameOfMethodToReplace === "hrtime") {
|
|
2345
|
+
if (_global.process && typeof _global.process.hrtime === "function") {
|
|
2346
|
+
hijackMethod(_global.process, nameOfMethodToReplace, clock);
|
|
2347
|
+
}
|
|
2348
|
+
} else if (nameOfMethodToReplace === "nextTick") {
|
|
2349
|
+
if (_global.process && typeof _global.process.nextTick === "function") {
|
|
2350
|
+
hijackMethod(_global.process, nameOfMethodToReplace, clock);
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
hijackMethod(_global, nameOfMethodToReplace, clock);
|
|
2354
|
+
}
|
|
2355
|
+
if (clock.timersModuleMethods !== undefined && timersModule[nameOfMethodToReplace]) {
|
|
2356
|
+
const original = timersModule[nameOfMethodToReplace];
|
|
2357
|
+
clock.timersModuleMethods.push({
|
|
2358
|
+
methodName: nameOfMethodToReplace,
|
|
2359
|
+
original
|
|
2360
|
+
});
|
|
2361
|
+
timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
|
|
2362
|
+
}
|
|
2363
|
+
if (clock.timersPromisesModuleMethods !== undefined) {
|
|
2364
|
+
if (nameOfMethodToReplace === "setTimeout") {
|
|
2365
|
+
clock.timersPromisesModuleMethods.push({
|
|
2366
|
+
methodName: "setTimeout",
|
|
2367
|
+
original: timersPromisesModule.setTimeout
|
|
2368
|
+
});
|
|
2369
|
+
timersPromisesModule.setTimeout = (delay, value, options = {}) => new Promise((resolve, reject) => {
|
|
2370
|
+
const abort = () => {
|
|
2371
|
+
options.signal.removeEventListener("abort", abort);
|
|
2372
|
+
clock.abortListenerMap.delete(abort);
|
|
2373
|
+
clock.clearTimeout(handle);
|
|
2374
|
+
reject(options.signal.reason);
|
|
2375
|
+
};
|
|
2376
|
+
const handle = clock.setTimeout(() => {
|
|
2377
|
+
if (options.signal) {
|
|
2378
|
+
options.signal.removeEventListener("abort", abort);
|
|
2379
|
+
clock.abortListenerMap.delete(abort);
|
|
2380
|
+
}
|
|
2381
|
+
resolve(value);
|
|
2382
|
+
}, delay);
|
|
2383
|
+
if (options.signal) {
|
|
2384
|
+
if (options.signal.aborted) {
|
|
2385
|
+
abort();
|
|
2386
|
+
} else {
|
|
2387
|
+
options.signal.addEventListener("abort", abort);
|
|
2388
|
+
clock.abortListenerMap.set(abort, options.signal);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
});
|
|
2392
|
+
} else if (nameOfMethodToReplace === "setImmediate") {
|
|
2393
|
+
clock.timersPromisesModuleMethods.push({
|
|
2394
|
+
methodName: "setImmediate",
|
|
2395
|
+
original: timersPromisesModule.setImmediate
|
|
2396
|
+
});
|
|
2397
|
+
timersPromisesModule.setImmediate = (value, options = {}) => new Promise((resolve, reject) => {
|
|
2398
|
+
const abort = () => {
|
|
2399
|
+
options.signal.removeEventListener("abort", abort);
|
|
2400
|
+
clock.abortListenerMap.delete(abort);
|
|
2401
|
+
clock.clearImmediate(handle);
|
|
2402
|
+
reject(options.signal.reason);
|
|
2403
|
+
};
|
|
2404
|
+
const handle = clock.setImmediate(() => {
|
|
2405
|
+
if (options.signal) {
|
|
2406
|
+
options.signal.removeEventListener("abort", abort);
|
|
2407
|
+
clock.abortListenerMap.delete(abort);
|
|
2408
|
+
}
|
|
2409
|
+
resolve(value);
|
|
2410
|
+
});
|
|
2411
|
+
if (options.signal) {
|
|
2412
|
+
if (options.signal.aborted) {
|
|
2413
|
+
abort();
|
|
2414
|
+
} else {
|
|
2415
|
+
options.signal.addEventListener("abort", abort);
|
|
2416
|
+
clock.abortListenerMap.set(abort, options.signal);
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
} else if (nameOfMethodToReplace === "setInterval") {
|
|
2421
|
+
clock.timersPromisesModuleMethods.push({
|
|
2422
|
+
methodName: "setInterval",
|
|
2423
|
+
original: timersPromisesModule.setInterval
|
|
2424
|
+
});
|
|
2425
|
+
timersPromisesModule.setInterval = (delay, value, options = {}) => ({ [Symbol.asyncIterator]: () => {
|
|
2426
|
+
const createResolvable = () => {
|
|
2427
|
+
let resolve, reject;
|
|
2428
|
+
const promise = new Promise((res, rej) => {
|
|
2429
|
+
resolve = res;
|
|
2430
|
+
reject = rej;
|
|
2431
|
+
});
|
|
2432
|
+
promise.resolve = resolve;
|
|
2433
|
+
promise.reject = reject;
|
|
2434
|
+
return promise;
|
|
2435
|
+
};
|
|
2436
|
+
let done = false;
|
|
2437
|
+
let hasThrown = false;
|
|
2438
|
+
let returnCall;
|
|
2439
|
+
let nextAvailable = 0;
|
|
2440
|
+
const nextQueue = [];
|
|
2441
|
+
const handle = clock.setInterval(() => {
|
|
2442
|
+
if (nextQueue.length > 0) {
|
|
2443
|
+
nextQueue.shift().resolve();
|
|
2444
|
+
} else {
|
|
2445
|
+
nextAvailable++;
|
|
2446
|
+
}
|
|
2447
|
+
}, delay);
|
|
2448
|
+
const abort = () => {
|
|
2449
|
+
options.signal.removeEventListener("abort", abort);
|
|
2450
|
+
clock.abortListenerMap.delete(abort);
|
|
2451
|
+
clock.clearInterval(handle);
|
|
2452
|
+
done = true;
|
|
2453
|
+
for (const resolvable of nextQueue) {
|
|
2454
|
+
resolvable.resolve();
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
if (options.signal) {
|
|
2458
|
+
if (options.signal.aborted) {
|
|
2459
|
+
done = true;
|
|
2460
|
+
} else {
|
|
2461
|
+
options.signal.addEventListener("abort", abort);
|
|
2462
|
+
clock.abortListenerMap.set(abort, options.signal);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
return {
|
|
2466
|
+
next: async () => {
|
|
2467
|
+
if (options.signal?.aborted && !hasThrown) {
|
|
2468
|
+
hasThrown = true;
|
|
2469
|
+
throw options.signal.reason;
|
|
2470
|
+
}
|
|
2471
|
+
if (done) {
|
|
2472
|
+
return {
|
|
2473
|
+
done: true,
|
|
2474
|
+
value: undefined
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
if (nextAvailable > 0) {
|
|
2478
|
+
nextAvailable--;
|
|
2479
|
+
return {
|
|
2480
|
+
done: false,
|
|
2481
|
+
value
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
const resolvable = createResolvable();
|
|
2485
|
+
nextQueue.push(resolvable);
|
|
2486
|
+
await resolvable;
|
|
2487
|
+
if (returnCall && nextQueue.length === 0) {
|
|
2488
|
+
returnCall.resolve();
|
|
2489
|
+
}
|
|
2490
|
+
if (options.signal?.aborted && !hasThrown) {
|
|
2491
|
+
hasThrown = true;
|
|
2492
|
+
throw options.signal.reason;
|
|
2493
|
+
}
|
|
2494
|
+
if (done) {
|
|
2495
|
+
return {
|
|
2496
|
+
done: true,
|
|
2497
|
+
value: undefined
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
return {
|
|
2501
|
+
done: false,
|
|
2502
|
+
value
|
|
2503
|
+
};
|
|
2504
|
+
},
|
|
2505
|
+
return: async () => {
|
|
2506
|
+
if (done) {
|
|
2507
|
+
return {
|
|
2508
|
+
done: true,
|
|
2509
|
+
value: undefined
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
if (nextQueue.length > 0) {
|
|
2513
|
+
returnCall = createResolvable();
|
|
2514
|
+
await returnCall;
|
|
2515
|
+
}
|
|
2516
|
+
clock.clearInterval(handle);
|
|
2517
|
+
done = true;
|
|
2518
|
+
if (options.signal) {
|
|
2519
|
+
options.signal.removeEventListener("abort", abort);
|
|
2520
|
+
clock.abortListenerMap.delete(abort);
|
|
2521
|
+
}
|
|
2522
|
+
return {
|
|
2523
|
+
done: true,
|
|
2524
|
+
value: undefined
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
} });
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
return clock;
|
|
2533
|
+
}
|
|
2534
|
+
return {
|
|
2535
|
+
timers,
|
|
2536
|
+
createClock,
|
|
2537
|
+
install,
|
|
2538
|
+
withGlobal
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* @typedef {object} FakeTimers
|
|
2543
|
+
* @property {Timers} timers
|
|
2544
|
+
* @property {createClock} createClock
|
|
2545
|
+
* @property {Function} install
|
|
2546
|
+
* @property {withGlobal} withGlobal
|
|
2547
|
+
*/
|
|
2548
|
+
/** @type {FakeTimers} */
|
|
2549
|
+
const defaultImplementation = withGlobal(globalObject);
|
|
2550
|
+
fakeTimersSrc.timers = defaultImplementation.timers;
|
|
2551
|
+
fakeTimersSrc.createClock = defaultImplementation.createClock;
|
|
2552
|
+
fakeTimersSrc.install = defaultImplementation.install;
|
|
2553
|
+
fakeTimersSrc.withGlobal = withGlobal;
|
|
2554
|
+
return fakeTimersSrc;
|
|
2555
|
+
}
|
|
2556
|
+
var fakeTimersSrcExports = requireFakeTimersSrc();
|
|
2557
|
+
var FakeTimers = class {
|
|
2558
|
+
_global;
|
|
2559
|
+
_clock;
|
|
2560
|
+
_fakingTime;
|
|
2561
|
+
_fakingDate;
|
|
2562
|
+
_fakeTimers;
|
|
2563
|
+
_userConfig;
|
|
2564
|
+
_now = RealDate.now;
|
|
2565
|
+
constructor({ global: global$1, config }) {
|
|
2566
|
+
this._userConfig = config;
|
|
2567
|
+
this._fakingDate = null;
|
|
2568
|
+
this._fakingTime = false;
|
|
2569
|
+
this._fakeTimers = fakeTimersSrcExports.withGlobal(global$1);
|
|
2570
|
+
this._global = global$1;
|
|
2571
|
+
}
|
|
2572
|
+
clearAllTimers() {
|
|
2573
|
+
if (this._fakingTime) this._clock.reset();
|
|
2574
|
+
}
|
|
2575
|
+
dispose() {
|
|
2576
|
+
this.useRealTimers();
|
|
2577
|
+
}
|
|
2578
|
+
runAllTimers() {
|
|
2579
|
+
if (this._checkFakeTimers()) this._clock.runAll();
|
|
2580
|
+
}
|
|
2581
|
+
async runAllTimersAsync() {
|
|
2582
|
+
if (this._checkFakeTimers()) await this._clock.runAllAsync();
|
|
2583
|
+
}
|
|
2584
|
+
runOnlyPendingTimers() {
|
|
2585
|
+
if (this._checkFakeTimers()) this._clock.runToLast();
|
|
2586
|
+
}
|
|
2587
|
+
async runOnlyPendingTimersAsync() {
|
|
2588
|
+
if (this._checkFakeTimers()) await this._clock.runToLastAsync();
|
|
2589
|
+
}
|
|
2590
|
+
advanceTimersToNextTimer(steps = 1) {
|
|
2591
|
+
if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
|
|
2592
|
+
this._clock.next();
|
|
2593
|
+
this._clock.tick(0);
|
|
2594
|
+
if (this._clock.countTimers() === 0) break;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
async advanceTimersToNextTimerAsync(steps = 1) {
|
|
2598
|
+
if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
|
|
2599
|
+
await this._clock.nextAsync();
|
|
2600
|
+
this._clock.tick(0);
|
|
2601
|
+
if (this._clock.countTimers() === 0) break;
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
advanceTimersByTime(msToRun) {
|
|
2605
|
+
if (this._checkFakeTimers()) this._clock.tick(msToRun);
|
|
2606
|
+
}
|
|
2607
|
+
async advanceTimersByTimeAsync(msToRun) {
|
|
2608
|
+
if (this._checkFakeTimers()) await this._clock.tickAsync(msToRun);
|
|
2609
|
+
}
|
|
2610
|
+
advanceTimersToNextFrame() {
|
|
2611
|
+
if (this._checkFakeTimers()) this._clock.runToFrame();
|
|
2612
|
+
}
|
|
2613
|
+
runAllTicks() {
|
|
2614
|
+
if (this._checkFakeTimers()) this._clock.runMicrotasks();
|
|
2615
|
+
}
|
|
2616
|
+
useRealTimers() {
|
|
2617
|
+
if (this._fakingDate) {
|
|
2618
|
+
resetDate();
|
|
2619
|
+
this._fakingDate = null;
|
|
2620
|
+
}
|
|
2621
|
+
if (this._fakingTime) {
|
|
2622
|
+
this._clock.uninstall();
|
|
2623
|
+
this._fakingTime = false;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
useFakeTimers() {
|
|
2627
|
+
if (this._fakingDate) throw new Error("\"setSystemTime\" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.");
|
|
2628
|
+
if (!this._fakingTime) {
|
|
2629
|
+
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick" && timer !== "queueMicrotask");
|
|
2630
|
+
if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) throw new Error("process.nextTick cannot be mocked inside child_process");
|
|
2631
|
+
this._clock = this._fakeTimers.install({
|
|
2632
|
+
now: Date.now(),
|
|
2633
|
+
...this._userConfig,
|
|
2634
|
+
toFake: this._userConfig?.toFake || toFake,
|
|
2635
|
+
ignoreMissingTimers: true
|
|
2636
|
+
});
|
|
2637
|
+
this._fakingTime = true;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
reset() {
|
|
2641
|
+
if (this._checkFakeTimers()) {
|
|
2642
|
+
const { now } = this._clock;
|
|
2643
|
+
this._clock.reset();
|
|
2644
|
+
this._clock.setSystemTime(now);
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
setSystemTime(now) {
|
|
2648
|
+
const date = typeof now === "undefined" || now instanceof Date ? now : new Date(now);
|
|
2649
|
+
if (this._fakingTime) this._clock.setSystemTime(date);
|
|
2650
|
+
else {
|
|
2651
|
+
this._fakingDate = date ?? new Date(this.getRealSystemTime());
|
|
2652
|
+
mockDate(this._fakingDate);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
getMockedSystemTime() {
|
|
2656
|
+
return this._fakingTime ? new Date(this._clock.now) : this._fakingDate;
|
|
2657
|
+
}
|
|
2658
|
+
getRealSystemTime() {
|
|
2659
|
+
return this._now();
|
|
2660
|
+
}
|
|
2661
|
+
getTimerCount() {
|
|
2662
|
+
if (this._checkFakeTimers()) return this._clock.countTimers();
|
|
2663
|
+
return 0;
|
|
2664
|
+
}
|
|
2665
|
+
configure(config) {
|
|
2666
|
+
this._userConfig = config;
|
|
2667
|
+
}
|
|
2668
|
+
isFakeTimers() {
|
|
2669
|
+
return this._fakingTime;
|
|
2670
|
+
}
|
|
2671
|
+
_checkFakeTimers() {
|
|
2672
|
+
if (!this._fakingTime) throw new Error("Timers are not mocked. Try calling \"vi.useFakeTimers()\" first.");
|
|
2673
|
+
return this._fakingTime;
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
function copyStackTrace(target, source) {
|
|
2677
|
+
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
|
2678
|
+
return target;
|
|
2679
|
+
}
|
|
2680
|
+
function waitFor(callback, options = {}) {
|
|
2681
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
|
|
2682
|
+
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
|
2683
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
2684
|
+
return new Promise((resolve, reject) => {
|
|
2685
|
+
let lastError;
|
|
2686
|
+
let promiseStatus = "idle";
|
|
2687
|
+
let timeoutId;
|
|
2688
|
+
let intervalId;
|
|
2689
|
+
const onResolve = (result) => {
|
|
2690
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
2691
|
+
if (intervalId) clearInterval(intervalId);
|
|
2692
|
+
resolve(result);
|
|
2693
|
+
};
|
|
2694
|
+
const handleTimeout = () => {
|
|
2695
|
+
if (intervalId) clearInterval(intervalId);
|
|
2696
|
+
let error = lastError;
|
|
2697
|
+
if (!error) error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
|
2698
|
+
reject(error);
|
|
2699
|
+
};
|
|
2700
|
+
const checkCallback = () => {
|
|
2701
|
+
if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
|
|
2702
|
+
if (promiseStatus === "pending") return;
|
|
2703
|
+
try {
|
|
2704
|
+
const result = callback();
|
|
2705
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
2706
|
+
const thenable = result;
|
|
2707
|
+
promiseStatus = "pending";
|
|
2708
|
+
thenable.then((resolvedValue) => {
|
|
2709
|
+
promiseStatus = "resolved";
|
|
2710
|
+
onResolve(resolvedValue);
|
|
2711
|
+
}, (rejectedValue) => {
|
|
2712
|
+
promiseStatus = "rejected";
|
|
2713
|
+
lastError = rejectedValue;
|
|
2714
|
+
});
|
|
2715
|
+
} else {
|
|
2716
|
+
onResolve(result);
|
|
2717
|
+
return true;
|
|
2718
|
+
}
|
|
2719
|
+
} catch (error) {
|
|
2720
|
+
lastError = error;
|
|
2721
|
+
}
|
|
2722
|
+
};
|
|
2723
|
+
if (checkCallback() === true) return;
|
|
2724
|
+
timeoutId = setTimeout(handleTimeout, timeout);
|
|
2725
|
+
intervalId = setInterval(checkCallback, interval);
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
function waitUntil(callback, options = {}) {
|
|
2729
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
|
|
2730
|
+
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
|
2731
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
2732
|
+
return new Promise((resolve, reject) => {
|
|
2733
|
+
let promiseStatus = "idle";
|
|
2734
|
+
let timeoutId;
|
|
2735
|
+
let intervalId;
|
|
2736
|
+
const onReject = (error) => {
|
|
2737
|
+
if (intervalId) clearInterval(intervalId);
|
|
2738
|
+
if (!error) error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
|
2739
|
+
reject(error);
|
|
2740
|
+
};
|
|
2741
|
+
const onResolve = (result) => {
|
|
2742
|
+
if (!result) return;
|
|
2743
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
2744
|
+
if (intervalId) clearInterval(intervalId);
|
|
2745
|
+
resolve(result);
|
|
2746
|
+
return true;
|
|
2747
|
+
};
|
|
2748
|
+
const checkCallback = () => {
|
|
2749
|
+
if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
|
|
2750
|
+
if (promiseStatus === "pending") return;
|
|
2751
|
+
try {
|
|
2752
|
+
const result = callback();
|
|
2753
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
2754
|
+
const thenable = result;
|
|
2755
|
+
promiseStatus = "pending";
|
|
2756
|
+
thenable.then((resolvedValue) => {
|
|
2757
|
+
promiseStatus = "resolved";
|
|
2758
|
+
onResolve(resolvedValue);
|
|
2759
|
+
}, (rejectedValue) => {
|
|
2760
|
+
promiseStatus = "rejected";
|
|
2761
|
+
onReject(rejectedValue);
|
|
2762
|
+
});
|
|
2763
|
+
} else return onResolve(result);
|
|
2764
|
+
} catch (error) {
|
|
2765
|
+
onReject(error);
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
if (checkCallback() === true) return;
|
|
2769
|
+
timeoutId = setTimeout(onReject, timeout);
|
|
2770
|
+
intervalId = setInterval(checkCallback, interval);
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
function createVitest() {
|
|
2774
|
+
let _config = null;
|
|
2775
|
+
const workerState = getWorkerState();
|
|
2776
|
+
let _timers;
|
|
2777
|
+
const timers = () => _timers ||= new FakeTimers({
|
|
2778
|
+
global: globalThis,
|
|
2779
|
+
config: workerState.config.fakeTimers
|
|
2780
|
+
});
|
|
2781
|
+
const _stubsGlobal = /* @__PURE__ */ new Map();
|
|
2782
|
+
const _stubsEnv = /* @__PURE__ */ new Map();
|
|
2783
|
+
const _envBooleans = [
|
|
2784
|
+
"PROD",
|
|
2785
|
+
"DEV",
|
|
2786
|
+
"SSR"
|
|
2787
|
+
];
|
|
2788
|
+
const utils = {
|
|
2789
|
+
useFakeTimers(config) {
|
|
2790
|
+
if (isChildProcess()) {
|
|
2791
|
+
if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) throw new Error("vi.useFakeTimers({ toFake: [\"nextTick\"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.");
|
|
2792
|
+
}
|
|
2793
|
+
if (config) timers().configure({
|
|
2794
|
+
...workerState.config.fakeTimers,
|
|
2795
|
+
...config
|
|
2796
|
+
});
|
|
2797
|
+
else timers().configure(workerState.config.fakeTimers);
|
|
2798
|
+
timers().useFakeTimers();
|
|
2799
|
+
return utils;
|
|
2800
|
+
},
|
|
2801
|
+
isFakeTimers() {
|
|
2802
|
+
return timers().isFakeTimers();
|
|
2803
|
+
},
|
|
2804
|
+
useRealTimers() {
|
|
2805
|
+
timers().useRealTimers();
|
|
2806
|
+
return utils;
|
|
2807
|
+
},
|
|
2808
|
+
runOnlyPendingTimers() {
|
|
2809
|
+
timers().runOnlyPendingTimers();
|
|
2810
|
+
return utils;
|
|
2811
|
+
},
|
|
2812
|
+
async runOnlyPendingTimersAsync() {
|
|
2813
|
+
await timers().runOnlyPendingTimersAsync();
|
|
2814
|
+
return utils;
|
|
2815
|
+
},
|
|
2816
|
+
runAllTimers() {
|
|
2817
|
+
timers().runAllTimers();
|
|
2818
|
+
return utils;
|
|
2819
|
+
},
|
|
2820
|
+
async runAllTimersAsync() {
|
|
2821
|
+
await timers().runAllTimersAsync();
|
|
2822
|
+
return utils;
|
|
2823
|
+
},
|
|
2824
|
+
runAllTicks() {
|
|
2825
|
+
timers().runAllTicks();
|
|
2826
|
+
return utils;
|
|
2827
|
+
},
|
|
2828
|
+
advanceTimersByTime(ms) {
|
|
2829
|
+
timers().advanceTimersByTime(ms);
|
|
2830
|
+
return utils;
|
|
2831
|
+
},
|
|
2832
|
+
async advanceTimersByTimeAsync(ms) {
|
|
2833
|
+
await timers().advanceTimersByTimeAsync(ms);
|
|
2834
|
+
return utils;
|
|
2835
|
+
},
|
|
2836
|
+
advanceTimersToNextTimer() {
|
|
2837
|
+
timers().advanceTimersToNextTimer();
|
|
2838
|
+
return utils;
|
|
2839
|
+
},
|
|
2840
|
+
async advanceTimersToNextTimerAsync() {
|
|
2841
|
+
await timers().advanceTimersToNextTimerAsync();
|
|
2842
|
+
return utils;
|
|
2843
|
+
},
|
|
2844
|
+
advanceTimersToNextFrame() {
|
|
2845
|
+
timers().advanceTimersToNextFrame();
|
|
2846
|
+
return utils;
|
|
2847
|
+
},
|
|
2848
|
+
getTimerCount() {
|
|
2849
|
+
return timers().getTimerCount();
|
|
2850
|
+
},
|
|
2851
|
+
setSystemTime(time) {
|
|
2852
|
+
timers().setSystemTime(time);
|
|
2853
|
+
return utils;
|
|
2854
|
+
},
|
|
2855
|
+
getMockedSystemTime() {
|
|
2856
|
+
return timers().getMockedSystemTime();
|
|
2857
|
+
},
|
|
2858
|
+
getRealSystemTime() {
|
|
2859
|
+
return timers().getRealSystemTime();
|
|
2860
|
+
},
|
|
2861
|
+
clearAllTimers() {
|
|
2862
|
+
timers().clearAllTimers();
|
|
2863
|
+
return utils;
|
|
2864
|
+
},
|
|
2865
|
+
spyOn,
|
|
2866
|
+
fn,
|
|
2867
|
+
waitFor,
|
|
2868
|
+
waitUntil,
|
|
2869
|
+
hoisted(factory) {
|
|
2870
|
+
assertTypes(factory, "\"vi.hoisted\" factory", ["function"]);
|
|
2871
|
+
return factory();
|
|
2872
|
+
},
|
|
2873
|
+
mock(path, factory) {
|
|
2874
|
+
if (typeof path !== "string") throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
|
|
2875
|
+
const importer = getImporter("mock");
|
|
2876
|
+
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
|
2877
|
+
},
|
|
2878
|
+
unmock(path) {
|
|
2879
|
+
if (typeof path !== "string") throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
|
2880
|
+
_mocker().queueUnmock(path, getImporter("unmock"));
|
|
2881
|
+
},
|
|
2882
|
+
doMock(path, factory) {
|
|
2883
|
+
if (typeof path !== "string") throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
|
2884
|
+
const importer = getImporter("doMock");
|
|
2885
|
+
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
|
2886
|
+
},
|
|
2887
|
+
doUnmock(path) {
|
|
2888
|
+
if (typeof path !== "string") throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
|
2889
|
+
_mocker().queueUnmock(path, getImporter("doUnmock"));
|
|
2890
|
+
},
|
|
2891
|
+
async importActual(path) {
|
|
2892
|
+
return _mocker().importActual(path, getImporter("importActual"), _mocker().getMockContext().callstack);
|
|
2893
|
+
},
|
|
2894
|
+
async importMock(path) {
|
|
2895
|
+
return _mocker().importMock(path, getImporter("importMock"));
|
|
2896
|
+
},
|
|
2897
|
+
mockObject(value) {
|
|
2898
|
+
return _mocker().mockObject({ value }).value;
|
|
2899
|
+
},
|
|
2900
|
+
mocked(item, _options = {}) {
|
|
2901
|
+
return item;
|
|
2902
|
+
},
|
|
2903
|
+
isMockFunction(fn$1) {
|
|
2904
|
+
return isMockFunction(fn$1);
|
|
2905
|
+
},
|
|
2906
|
+
clearAllMocks() {
|
|
2907
|
+
[...mocks].reverse().forEach((spy) => spy.mockClear());
|
|
2908
|
+
return utils;
|
|
2909
|
+
},
|
|
2910
|
+
resetAllMocks() {
|
|
2911
|
+
[...mocks].reverse().forEach((spy) => spy.mockReset());
|
|
2912
|
+
return utils;
|
|
2913
|
+
},
|
|
2914
|
+
restoreAllMocks() {
|
|
2915
|
+
[...mocks].reverse().forEach((spy) => spy.mockRestore());
|
|
2916
|
+
return utils;
|
|
2917
|
+
},
|
|
2918
|
+
stubGlobal(name, value) {
|
|
2919
|
+
if (!_stubsGlobal.has(name)) _stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
|
|
2920
|
+
Object.defineProperty(globalThis, name, {
|
|
2921
|
+
value,
|
|
2922
|
+
writable: true,
|
|
2923
|
+
configurable: true,
|
|
2924
|
+
enumerable: true
|
|
2925
|
+
});
|
|
2926
|
+
return utils;
|
|
2927
|
+
},
|
|
2928
|
+
stubEnv(name, value) {
|
|
2929
|
+
if (!_stubsEnv.has(name)) _stubsEnv.set(name, process.env[name]);
|
|
2930
|
+
if (_envBooleans.includes(name)) process.env[name] = value ? "1" : "";
|
|
2931
|
+
else if (value === void 0) delete process.env[name];
|
|
2932
|
+
else process.env[name] = String(value);
|
|
2933
|
+
return utils;
|
|
2934
|
+
},
|
|
2935
|
+
unstubAllGlobals() {
|
|
2936
|
+
_stubsGlobal.forEach((original, name) => {
|
|
2937
|
+
if (!original) Reflect.deleteProperty(globalThis, name);
|
|
2938
|
+
else Object.defineProperty(globalThis, name, original);
|
|
2939
|
+
});
|
|
2940
|
+
_stubsGlobal.clear();
|
|
2941
|
+
return utils;
|
|
2942
|
+
},
|
|
2943
|
+
unstubAllEnvs() {
|
|
2944
|
+
_stubsEnv.forEach((original, name) => {
|
|
2945
|
+
if (original === void 0) delete process.env[name];
|
|
2946
|
+
else process.env[name] = original;
|
|
2947
|
+
});
|
|
2948
|
+
_stubsEnv.clear();
|
|
2949
|
+
return utils;
|
|
2950
|
+
},
|
|
2951
|
+
resetModules() {
|
|
2952
|
+
resetModules(workerState.moduleCache);
|
|
2953
|
+
return utils;
|
|
2954
|
+
},
|
|
2955
|
+
async dynamicImportSettled() {
|
|
2956
|
+
return waitForImportsToResolve();
|
|
2957
|
+
},
|
|
2958
|
+
setConfig(config) {
|
|
2959
|
+
if (!_config) _config = { ...workerState.config };
|
|
2960
|
+
Object.assign(workerState.config, config);
|
|
2961
|
+
},
|
|
2962
|
+
resetConfig() {
|
|
2963
|
+
if (_config) Object.assign(workerState.config, _config);
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2966
|
+
return utils;
|
|
2967
|
+
}
|
|
2968
|
+
const vitest = createVitest();
|
|
2969
|
+
const vi = vitest;
|
|
2970
|
+
function _mocker() {
|
|
2971
|
+
return typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, { get(_, name) {
|
|
2972
|
+
throw new Error(`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`);
|
|
2973
|
+
} });
|
|
2974
|
+
}
|
|
2975
|
+
function getImporter(name) {
|
|
2976
|
+
const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 });
|
|
2977
|
+
const stackArray = stackTrace.split("\n");
|
|
2978
|
+
const importerStackIndex = stackArray.findIndex((stack$1) => {
|
|
2979
|
+
return stack$1.includes(` at Object.${name}`) || stack$1.includes(`${name}@`);
|
|
2980
|
+
});
|
|
2981
|
+
const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
|
2982
|
+
return stack?.file || "";
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
//#endregion
|
|
2986
|
+
export { createExpect, globalExpect, inject, vi, vitest };
|