@warlock.js/core 4.0.10 → 4.0.15
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/esm/cli/cli-commands.manager.js +344 -0
- package/esm/cli/cli-commands.manager.js.map +1 -0
- package/esm/cli/cli-commands.utils.js +182 -0
- package/esm/cli/cli-commands.utils.js.map +1 -0
- package/esm/cli/commands/build.command.js +8 -0
- package/esm/cli/commands/build.command.js.map +1 -0
- package/esm/cli/commands/dev-server.command.js +17 -0
- package/esm/cli/commands/dev-server.command.js.map +1 -0
- package/esm/cli/commands/start-production.command.js +65 -0
- package/esm/cli/commands/start-production.command.js.map +1 -0
- package/esm/cli/commands/typings-generator.command.js +40 -0
- package/esm/cli/commands/typings-generator.command.js.map +1 -0
- package/esm/cli/commands-loader.js +45 -0
- package/esm/cli/commands-loader.js.map +1 -0
- package/esm/cli/framework-cli-commands.js +6 -0
- package/esm/cli/framework-cli-commands.js.map +1 -0
- package/esm/cli/parse-cli-args.js +82 -0
- package/esm/cli/parse-cli-args.js.map +1 -0
- package/esm/cli/start.js +2 -0
- package/esm/cli/start.js.map +1 -0
- package/esm/cli/string-similarity.js +57 -0
- package/esm/cli/string-similarity.js.map +1 -0
- package/esm/config/config-loader.js +82 -0
- package/esm/config/config-loader.js.map +1 -0
- package/esm/config/config-manager.js +25 -0
- package/esm/config/config-manager.js.map +1 -0
- package/esm/config/load-config-files.js +19 -0
- package/esm/config/load-config-files.js.map +1 -0
- package/esm/dev2-server/create-worker.js +37 -0
- package/esm/dev2-server/create-worker.js.map +1 -0
- package/esm/dev2-server/dependency-graph.js +266 -0
- package/esm/dev2-server/dependency-graph.js.map +1 -0
- package/esm/dev2-server/dev-logger.js +63 -1
- package/esm/dev2-server/dev-logger.js.map +1 -1
- package/esm/dev2-server/development-server.js +138 -0
- package/esm/dev2-server/development-server.js.map +1 -0
- package/esm/dev2-server/events.js +4 -0
- package/esm/dev2-server/events.js.map +1 -0
- package/esm/dev2-server/file-event-handler.js +186 -0
- package/esm/dev2-server/file-event-handler.js.map +1 -0
- package/esm/dev2-server/file-manager.js +374 -0
- package/esm/dev2-server/file-manager.js.map +1 -0
- package/esm/dev2-server/file-operations.js +228 -0
- package/esm/dev2-server/file-operations.js.map +1 -0
- package/esm/dev2-server/files-orchestrator.js +326 -0
- package/esm/dev2-server/files-orchestrator.js.map +1 -0
- package/esm/dev2-server/files-watcher.js +95 -0
- package/esm/dev2-server/files-watcher.js.map +1 -0
- package/esm/dev2-server/flags.js +9 -0
- package/esm/dev2-server/flags.js.map +1 -0
- package/esm/dev2-server/health-checker/checkers/base-health-checker.js +71 -0
- package/esm/dev2-server/health-checker/checkers/base-health-checker.js.map +1 -0
- package/esm/dev2-server/health-checker/checkers/eslint-health-checker.js +217 -0
- package/esm/dev2-server/health-checker/checkers/eslint-health-checker.js.map +1 -0
- package/esm/dev2-server/health-checker/checkers/typescript-health-checker.js +279 -0
- package/esm/dev2-server/health-checker/checkers/typescript-health-checker.js.map +1 -0
- package/esm/dev2-server/health-checker/file-health-result.js +40 -0
- package/esm/dev2-server/health-checker/file-health-result.js.map +1 -0
- package/esm/dev2-server/health-checker/files-healthcare.manager.js +422 -0
- package/esm/dev2-server/health-checker/files-healthcare.manager.js.map +1 -0
- package/esm/dev2-server/import-transformer.js +248 -0
- package/esm/dev2-server/import-transformer.js.map +1 -0
- package/esm/dev2-server/layer-executor.js +309 -0
- package/esm/dev2-server/layer-executor.js.map +1 -0
- package/esm/dev2-server/manifest-manager.js +107 -0
- package/esm/dev2-server/manifest-manager.js.map +1 -0
- package/esm/dev2-server/module-loader.js +251 -0
- package/esm/dev2-server/module-loader.js.map +1 -0
- package/esm/dev2-server/package-json-manager.js +20 -0
- package/esm/dev2-server/package-json-manager.js.map +1 -0
- package/esm/dev2-server/parse-imports.js +328 -0
- package/esm/dev2-server/parse-imports.js.map +1 -0
- package/esm/dev2-server/runtime-import-helper.js +150 -0
- package/esm/dev2-server/runtime-import-helper.js.map +1 -0
- package/esm/dev2-server/special-files-collector.js +212 -0
- package/esm/dev2-server/special-files-collector.js.map +1 -0
- package/esm/dev2-server/transpile-file.js +12 -2
- package/esm/dev2-server/transpile-file.js.map +1 -1
- package/esm/dev2-server/type-generator.js +557 -0
- package/esm/dev2-server/type-generator.js.map +1 -0
- package/esm/dev2-server/utils.js +40 -0
- package/esm/dev2-server/utils.js.map +1 -0
- package/esm/manifest/manifest-manager.js +88 -0
- package/esm/manifest/manifest-manager.js.map +1 -0
- package/esm/production/build-app-production.js +8 -0
- package/esm/production/build-app-production.js.map +1 -0
- package/esm/production/esbuild-plugins.js +23 -0
- package/esm/production/esbuild-plugins.js.map +1 -0
- package/esm/production/production-builder.js +245 -0
- package/esm/production/production-builder.js.map +1 -0
- package/package.json +1 -1
- package/cjs/application.d.ts +0 -27
- package/cjs/application.d.ts.map +0 -1
- package/cjs/bootstrap/setup.d.ts +0 -7
- package/cjs/bootstrap/setup.d.ts.map +0 -1
- package/cjs/bootstrap/setup.js +0 -38
- package/cjs/bootstrap/setup.js.map +0 -1
- package/cjs/bootstrap.d.ts +0 -2
- package/cjs/bootstrap.d.ts.map +0 -1
- package/cjs/bootstrap.js +0 -5
- package/cjs/bootstrap.js.map +0 -1
- package/cjs/cache/database-cache-driver.d.ts +0 -56
- package/cjs/cache/database-cache-driver.d.ts.map +0 -1
- package/cjs/cache/database-cache-driver.js +0 -96
- package/cjs/cache/database-cache-driver.js.map +0 -1
- package/cjs/cache/index.d.ts +0 -3
- package/cjs/cache/index.d.ts.map +0 -1
- package/cjs/cache/index.js +0 -1
- package/cjs/cache/index.js.map +0 -1
- package/cjs/cli/cli-command.d.ts +0 -115
- package/cjs/cli/cli-command.d.ts.map +0 -1
- package/cjs/cli/cli-command.js +0 -224
- package/cjs/cli/cli-command.js.map +0 -1
- package/cjs/cli/cli-commands.manager.d.ts +0 -71
- package/cjs/cli/cli-commands.manager.d.ts.map +0 -1
- package/cjs/cli/cli-commands.utils.d.ts +0 -68
- package/cjs/cli/cli-commands.utils.d.ts.map +0 -1
- package/cjs/cli/commands/build.command.d.ts +0 -2
- package/cjs/cli/commands/build.command.d.ts.map +0 -1
- package/cjs/cli/commands/dev-server.command.d.ts +0 -2
- package/cjs/cli/commands/dev-server.command.d.ts.map +0 -1
- package/cjs/cli/commands/start-production.command.d.ts +0 -2
- package/cjs/cli/commands/start-production.command.d.ts.map +0 -1
- package/cjs/cli/commands/typings-generator.command.d.ts +0 -2
- package/cjs/cli/commands/typings-generator.command.d.ts.map +0 -1
- package/cjs/cli/commands-loader.d.ts +0 -18
- package/cjs/cli/commands-loader.d.ts.map +0 -1
- package/cjs/cli/framework-cli-commands.d.ts +0 -2
- package/cjs/cli/framework-cli-commands.d.ts.map +0 -1
- package/cjs/cli/index.d.ts +0 -3
- package/cjs/cli/index.d.ts.map +0 -1
- package/cjs/cli/index.js +0 -1
- package/cjs/cli/index.js.map +0 -1
- package/cjs/cli/parse-cli-args.d.ts +0 -18
- package/cjs/cli/parse-cli-args.d.ts.map +0 -1
- package/cjs/cli/start.d.ts +0 -2
- package/cjs/cli/start.d.ts.map +0 -1
- package/cjs/cli/string-similarity.d.ts +0 -44
- package/cjs/cli/string-similarity.d.ts.map +0 -1
- package/cjs/cli/types.d.ts +0 -201
- package/cjs/cli/types.d.ts.map +0 -1
- package/cjs/config/config-getter.d.ts +0 -35
- package/cjs/config/config-getter.d.ts.map +0 -1
- package/cjs/config/config-getter.js +0 -21
- package/cjs/config/config-getter.js.map +0 -1
- package/cjs/config/config-handlers.d.ts +0 -19
- package/cjs/config/config-handlers.d.ts.map +0 -1
- package/cjs/config/config-handlers.js +0 -47
- package/cjs/config/config-handlers.js.map +0 -1
- package/cjs/config/config-loader.d.ts +0 -37
- package/cjs/config/config-loader.d.ts.map +0 -1
- package/cjs/config/config-manager.d.ts +0 -22
- package/cjs/config/config-manager.d.ts.map +0 -1
- package/cjs/config/config-special-handlers.d.ts +0 -17
- package/cjs/config/config-special-handlers.d.ts.map +0 -1
- package/cjs/config/config-special-handlers.js +0 -23
- package/cjs/config/config-special-handlers.js.map +0 -1
- package/cjs/config/index.d.ts +0 -5
- package/cjs/config/index.d.ts.map +0 -1
- package/cjs/config/load-config-files.d.ts +0 -6
- package/cjs/config/load-config-files.d.ts.map +0 -1
- package/cjs/config/types.d.ts +0 -52
- package/cjs/config/types.d.ts.map +0 -1
- package/cjs/database/decorators/index.d.ts +0 -2
- package/cjs/database/decorators/index.d.ts.map +0 -1
- package/cjs/database/decorators/sluggable.d.ts +0 -2
- package/cjs/database/decorators/sluggable.d.ts.map +0 -1
- package/cjs/database/decorators/sluggable.js +0 -8
- package/cjs/database/decorators/sluggable.js.map +0 -1
- package/cjs/database/index.d.ts +0 -3
- package/cjs/database/index.d.ts.map +0 -1
- package/cjs/database/models/database-log/database-log.d.ts +0 -13
- package/cjs/database/models/database-log/database-log.d.ts.map +0 -1
- package/cjs/database/models/database-log/database-log.js +0 -16
- package/cjs/database/models/database-log/database-log.js.map +0 -1
- package/cjs/database/models/database-log/index.d.ts +0 -2
- package/cjs/database/models/database-log/index.d.ts.map +0 -1
- package/cjs/dev2-server/config-handlers.d.ts +0 -8
- package/cjs/dev2-server/config-handlers.d.ts.map +0 -1
- package/cjs/dev2-server/config-loader.d.ts +0 -61
- package/cjs/dev2-server/config-loader.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/base-connector.d.ts +0 -49
- package/cjs/dev2-server/connectors/base-connector.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/base-connector.js +0 -48
- package/cjs/dev2-server/connectors/base-connector.js.map +0 -1
- package/cjs/dev2-server/connectors/cache-connector.d.ts +0 -23
- package/cjs/dev2-server/connectors/cache-connector.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/cache-connector.js +0 -35
- package/cjs/dev2-server/connectors/cache-connector.js.map +0 -1
- package/cjs/dev2-server/connectors/connectors-manager.d.ts +0 -38
- package/cjs/dev2-server/connectors/connectors-manager.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/connectors-manager.js +0 -80
- package/cjs/dev2-server/connectors/connectors-manager.js.map +0 -1
- package/cjs/dev2-server/connectors/database-connector.d.ts +0 -23
- package/cjs/dev2-server/connectors/database-connector.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/database-connector.js +0 -42
- package/cjs/dev2-server/connectors/database-connector.js.map +0 -1
- package/cjs/dev2-server/connectors/http-connector.d.ts +0 -29
- package/cjs/dev2-server/connectors/http-connector.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/http-connector.js +0 -69
- package/cjs/dev2-server/connectors/http-connector.js.map +0 -1
- package/cjs/dev2-server/connectors/index.d.ts +0 -11
- package/cjs/dev2-server/connectors/index.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/types.d.ts +0 -49
- package/cjs/dev2-server/connectors/types.d.ts.map +0 -1
- package/cjs/dev2-server/connectors/types.js +0 -9
- package/cjs/dev2-server/connectors/types.js.map +0 -1
- package/cjs/dev2-server/create-worker.d.ts +0 -34
- package/cjs/dev2-server/create-worker.d.ts.map +0 -1
- package/cjs/dev2-server/dependency-graph.d.ts +0 -93
- package/cjs/dev2-server/dependency-graph.d.ts.map +0 -1
- package/cjs/dev2-server/dev-logger.d.ts +0 -14
- package/cjs/dev2-server/dev-logger.d.ts.map +0 -1
- package/cjs/dev2-server/dev-logger.js +0 -68
- package/cjs/dev2-server/dev-logger.js.map +0 -1
- package/cjs/dev2-server/development-server.d.ts +0 -47
- package/cjs/dev2-server/development-server.d.ts.map +0 -1
- package/cjs/dev2-server/events.d.ts +0 -5
- package/cjs/dev2-server/events.d.ts.map +0 -1
- package/cjs/dev2-server/file-event-handler.d.ts +0 -59
- package/cjs/dev2-server/file-event-handler.d.ts.map +0 -1
- package/cjs/dev2-server/file-manager.d.ts +0 -136
- package/cjs/dev2-server/file-manager.d.ts.map +0 -1
- package/cjs/dev2-server/file-operations.d.ts +0 -65
- package/cjs/dev2-server/file-operations.d.ts.map +0 -1
- package/cjs/dev2-server/files-orchestrator.d.ts +0 -122
- package/cjs/dev2-server/files-orchestrator.d.ts.map +0 -1
- package/cjs/dev2-server/files-watcher.d.ts +0 -67
- package/cjs/dev2-server/files-watcher.d.ts.map +0 -1
- package/cjs/dev2-server/flags.d.ts +0 -10
- package/cjs/dev2-server/flags.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/checkers/base-health-checker.d.ts +0 -52
- package/cjs/dev2-server/health-checker/checkers/base-health-checker.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/checkers/eslint-health-checker.d.ts +0 -40
- package/cjs/dev2-server/health-checker/checkers/eslint-health-checker.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/checkers/typescript-health-checker.d.ts +0 -56
- package/cjs/dev2-server/health-checker/checkers/typescript-health-checker.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/file-health-checker.contract.d.ts +0 -59
- package/cjs/dev2-server/health-checker/file-health-checker.contract.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/file-health-result.d.ts +0 -68
- package/cjs/dev2-server/health-checker/file-health-result.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/files-healthcare.manager.d.ts +0 -115
- package/cjs/dev2-server/health-checker/files-healthcare.manager.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/workers/eslint-health.worker.d.ts +0 -2
- package/cjs/dev2-server/health-checker/workers/eslint-health.worker.d.ts.map +0 -1
- package/cjs/dev2-server/health-checker/workers/ts-health.worker.d.ts +0 -2
- package/cjs/dev2-server/health-checker/workers/ts-health.worker.d.ts.map +0 -1
- package/cjs/dev2-server/import-transformer.d.ts +0 -16
- package/cjs/dev2-server/import-transformer.d.ts.map +0 -1
- package/cjs/dev2-server/index.d.ts +0 -1
- package/cjs/dev2-server/index.d.ts.map +0 -1
- package/cjs/dev2-server/layer-executor.d.ts +0 -60
- package/cjs/dev2-server/layer-executor.d.ts.map +0 -1
- package/cjs/dev2-server/manifest-manager.d.ts +0 -80
- package/cjs/dev2-server/manifest-manager.d.ts.map +0 -1
- package/cjs/dev2-server/module-loader.d.ts +0 -104
- package/cjs/dev2-server/module-loader.d.ts.map +0 -1
- package/cjs/dev2-server/package-json-manager.d.ts +0 -16
- package/cjs/dev2-server/package-json-manager.d.ts.map +0 -1
- package/cjs/dev2-server/parse-imports.d.ts +0 -13
- package/cjs/dev2-server/parse-imports.d.ts.map +0 -1
- package/cjs/dev2-server/path.d.ts +0 -39
- package/cjs/dev2-server/path.d.ts.map +0 -1
- package/cjs/dev2-server/path.js +0 -56
- package/cjs/dev2-server/path.js.map +0 -1
- package/cjs/dev2-server/runtime-import-helper.d.ts +0 -9
- package/cjs/dev2-server/runtime-import-helper.d.ts.map +0 -1
- package/cjs/dev2-server/special-files-collector.d.ts +0 -114
- package/cjs/dev2-server/special-files-collector.d.ts.map +0 -1
- package/cjs/dev2-server/start-development-server.d.ts +0 -7
- package/cjs/dev2-server/start-development-server.d.ts.map +0 -1
- package/cjs/dev2-server/transpile-file.d.ts +0 -11
- package/cjs/dev2-server/transpile-file.d.ts.map +0 -1
- package/cjs/dev2-server/transpile-file.js +0 -11
- package/cjs/dev2-server/transpile-file.js.map +0 -1
- package/cjs/dev2-server/tsconfig-manager.d.ts +0 -45
- package/cjs/dev2-server/tsconfig-manager.d.ts.map +0 -1
- package/cjs/dev2-server/tsconfig-manager.js +0 -102
- package/cjs/dev2-server/tsconfig-manager.js.map +0 -1
- package/cjs/dev2-server/type-generator.d.ts +0 -111
- package/cjs/dev2-server/type-generator.d.ts.map +0 -1
- package/cjs/dev2-server/types.d.ts +0 -16
- package/cjs/dev2-server/types.d.ts.map +0 -1
- package/cjs/dev2-server/utils.d.ts +0 -15
- package/cjs/dev2-server/utils.d.ts.map +0 -1
- package/cjs/http/config.d.ts +0 -10
- package/cjs/http/config.d.ts.map +0 -1
- package/cjs/http/config.js +0 -22
- package/cjs/http/config.js.map +0 -1
- package/cjs/http/createHttpApplication.d.ts +0 -3
- package/cjs/http/createHttpApplication.d.ts.map +0 -1
- package/cjs/http/createHttpApplication.js +0 -28
- package/cjs/http/createHttpApplication.js.map +0 -1
- package/cjs/http/database/RequestLog.d.ts +0 -13
- package/cjs/http/database/RequestLog.d.ts.map +0 -1
- package/cjs/http/database/RequestLog.js +0 -25
- package/cjs/http/database/RequestLog.js.map +0 -1
- package/cjs/http/errors/index.d.ts +0 -2
- package/cjs/http/errors/index.d.ts.map +0 -1
- package/cjs/http/errors/resource-not-found.error.d.ts +0 -17
- package/cjs/http/errors/resource-not-found.error.d.ts.map +0 -1
- package/cjs/http/errors/resource-not-found.error.js +0 -32
- package/cjs/http/errors/resource-not-found.error.js.map +0 -1
- package/cjs/http/events.d.ts +0 -4
- package/cjs/http/events.d.ts.map +0 -1
- package/cjs/http/events.js +0 -26
- package/cjs/http/events.js.map +0 -1
- package/cjs/http/index.d.ts +0 -16
- package/cjs/http/index.d.ts.map +0 -1
- package/cjs/http/middleware/cache-response-middleware.d.ts +0 -34
- package/cjs/http/middleware/cache-response-middleware.d.ts.map +0 -1
- package/cjs/http/middleware/cache-response-middleware.js +0 -45
- package/cjs/http/middleware/cache-response-middleware.js.map +0 -1
- package/cjs/http/middleware/index.d.ts +0 -3
- package/cjs/http/middleware/index.d.ts.map +0 -1
- package/cjs/http/middleware/inject-request-context.d.ts +0 -35
- package/cjs/http/middleware/inject-request-context.d.ts.map +0 -1
- package/cjs/http/middleware/inject-request-context.js +0 -104
- package/cjs/http/middleware/inject-request-context.js.map +0 -1
- package/cjs/http/plugins/index.d.ts +0 -3
- package/cjs/http/plugins/index.d.ts.map +0 -1
- package/cjs/http/plugins.d.ts +0 -3
- package/cjs/http/plugins.d.ts.map +0 -1
- package/cjs/http/plugins.js +0 -39
- package/cjs/http/plugins.js.map +0 -1
- package/cjs/http/request-controller.d.ts +0 -11
- package/cjs/http/request-controller.d.ts.map +0 -1
- package/cjs/http/request-controller.js +0 -9
- package/cjs/http/request-controller.js.map +0 -1
- package/cjs/http/request.d.ts +0 -376
- package/cjs/http/request.d.ts.map +0 -1
- package/cjs/http/request.js +0 -729
- package/cjs/http/request.js.map +0 -1
- package/cjs/http/response.d.ts +0 -271
- package/cjs/http/response.d.ts.map +0 -1
- package/cjs/http/response.js +0 -574
- package/cjs/http/response.js.map +0 -1
- package/cjs/http/server.d.ts +0 -8
- package/cjs/http/server.d.ts.map +0 -1
- package/cjs/http/server.js +0 -15
- package/cjs/http/server.js.map +0 -1
- package/cjs/http/types.d.ts +0 -174
- package/cjs/http/types.d.ts.map +0 -1
- package/cjs/http/uploaded-file.d.ts +0 -445
- package/cjs/http/uploaded-file.d.ts.map +0 -1
- package/cjs/http/uploaded-file.js +0 -694
- package/cjs/http/uploaded-file.js.map +0 -1
- package/cjs/http/uploads-config.d.ts +0 -26
- package/cjs/http/uploads-config.d.ts.map +0 -1
- package/cjs/http/uploads-config.js +0 -35
- package/cjs/http/uploads-config.js.map +0 -1
- package/cjs/http/uploads-types.d.ts +0 -236
- package/cjs/http/uploads-types.d.ts.map +0 -1
- package/cjs/image/image.d.ts +0 -382
- package/cjs/image/image.d.ts.map +0 -1
- package/cjs/image/image.js +0 -552
- package/cjs/image/image.js.map +0 -1
- package/cjs/image/index.d.ts +0 -2
- package/cjs/image/index.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -27
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/logger/index.d.ts +0 -3
- package/cjs/logger/index.d.ts.map +0 -1
- package/cjs/logger/logger.d.ts +0 -3
- package/cjs/logger/logger.d.ts.map +0 -1
- package/cjs/logger/logger.js +0 -16
- package/cjs/logger/logger.js.map +0 -1
- package/cjs/logger/types.d.ts +0 -39
- package/cjs/logger/types.d.ts.map +0 -1
- package/cjs/mail/config.d.ts +0 -83
- package/cjs/mail/config.d.ts.map +0 -1
- package/cjs/mail/config.js +0 -152
- package/cjs/mail/config.js.map +0 -1
- package/cjs/mail/events.d.ts +0 -96
- package/cjs/mail/events.d.ts.map +0 -1
- package/cjs/mail/events.js +0 -123
- package/cjs/mail/events.js.map +0 -1
- package/cjs/mail/index.d.ts +0 -10
- package/cjs/mail/index.d.ts.map +0 -1
- package/cjs/mail/mail.d.ts +0 -175
- package/cjs/mail/mail.d.ts.map +0 -1
- package/cjs/mail/mail.js +0 -286
- package/cjs/mail/mail.js.map +0 -1
- package/cjs/mail/mailer-pool.d.ts +0 -26
- package/cjs/mail/mailer-pool.d.ts.map +0 -1
- package/cjs/mail/mailer-pool.js +0 -95
- package/cjs/mail/mailer-pool.js.map +0 -1
- package/cjs/mail/react-mail.d.ts +0 -6
- package/cjs/mail/react-mail.d.ts.map +0 -1
- package/cjs/mail/react-mail.js +0 -25
- package/cjs/mail/react-mail.js.map +0 -1
- package/cjs/mail/send-mail.d.ts +0 -33
- package/cjs/mail/send-mail.d.ts.map +0 -1
- package/cjs/mail/send-mail.js +0 -309
- package/cjs/mail/send-mail.js.map +0 -1
- package/cjs/mail/test-mailbox.d.ts +0 -110
- package/cjs/mail/test-mailbox.d.ts.map +0 -1
- package/cjs/mail/test-mailbox.js +0 -143
- package/cjs/mail/test-mailbox.js.map +0 -1
- package/cjs/mail/types.d.ts +0 -245
- package/cjs/mail/types.d.ts.map +0 -1
- package/cjs/mail/types.js +0 -13
- package/cjs/mail/types.js.map +0 -1
- package/cjs/manifest/manifest-manager.d.ts +0 -74
- package/cjs/manifest/manifest-manager.d.ts.map +0 -1
- package/cjs/output/index.d.ts +0 -3
- package/cjs/output/index.d.ts.map +0 -1
- package/cjs/output/output.d.ts +0 -193
- package/cjs/output/output.d.ts.map +0 -1
- package/cjs/output/output.js +0 -599
- package/cjs/output/output.js.map +0 -1
- package/cjs/output/types.d.ts +0 -23
- package/cjs/output/types.d.ts.map +0 -1
- package/cjs/production/build-app-production.d.ts +0 -6
- package/cjs/production/build-app-production.d.ts.map +0 -1
- package/cjs/production/esbuild-plugins.d.ts +0 -5
- package/cjs/production/esbuild-plugins.d.ts.map +0 -1
- package/cjs/production/production-builder.d.ts +0 -76
- package/cjs/production/production-builder.d.ts.map +0 -1
- package/cjs/react/index.d.ts +0 -3
- package/cjs/react/index.d.ts.map +0 -1
- package/cjs/react/index.js +0 -7
- package/cjs/react/index.js.map +0 -1
- package/cjs/repositories/base-repository-manager.d.ts +0 -47
- package/cjs/repositories/base-repository-manager.d.ts.map +0 -1
- package/cjs/repositories/base-repository-manager.js +0 -63
- package/cjs/repositories/base-repository-manager.js.map +0 -1
- package/cjs/repositories/index.d.ts +0 -8
- package/cjs/repositories/index.d.ts.map +0 -1
- package/cjs/repositories/repository-destroyer-manager.d.ts +0 -21
- package/cjs/repositories/repository-destroyer-manager.d.ts.map +0 -1
- package/cjs/repositories/repository-destroyer-manager.js +0 -38
- package/cjs/repositories/repository-destroyer-manager.js.map +0 -1
- package/cjs/repositories/repository-filler-manager.d.ts +0 -60
- package/cjs/repositories/repository-filler-manager.d.ts.map +0 -1
- package/cjs/repositories/repository-filler-manager.js +0 -102
- package/cjs/repositories/repository-filler-manager.js.map +0 -1
- package/cjs/repositories/repository-filler.d.ts +0 -26
- package/cjs/repositories/repository-filler.d.ts.map +0 -1
- package/cjs/repositories/repository-filler.js +0 -63
- package/cjs/repositories/repository-filler.js.map +0 -1
- package/cjs/repositories/repository-list-manager.d.ts +0 -385
- package/cjs/repositories/repository-list-manager.d.ts.map +0 -1
- package/cjs/repositories/repository-list-manager.js +0 -812
- package/cjs/repositories/repository-list-manager.js.map +0 -1
- package/cjs/repositories/repository-listing.d.ts +0 -82
- package/cjs/repositories/repository-listing.d.ts.map +0 -1
- package/cjs/repositories/repository-listing.js +0 -177
- package/cjs/repositories/repository-listing.js.map +0 -1
- package/cjs/repositories/repository-manager.d.ts +0 -5
- package/cjs/repositories/repository-manager.d.ts.map +0 -1
- package/cjs/repositories/repository-manager.js +0 -2
- package/cjs/repositories/repository-manager.js.map +0 -1
- package/cjs/repositories/types.d.ts +0 -114
- package/cjs/repositories/types.d.ts.map +0 -1
- package/cjs/repositories/utils.d.ts +0 -3
- package/cjs/repositories/utils.d.ts.map +0 -1
- package/cjs/repositories/utils.js +0 -7
- package/cjs/repositories/utils.js.map +0 -1
- package/cjs/restful/index.d.ts +0 -2
- package/cjs/restful/index.d.ts.map +0 -1
- package/cjs/restful/restful.d.ts +0 -110
- package/cjs/restful/restful.d.ts.map +0 -1
- package/cjs/restful/restful.js +0 -317
- package/cjs/restful/restful.js.map +0 -1
- package/cjs/router/index.d.ts +0 -4
- package/cjs/router/index.d.ts.map +0 -1
- package/cjs/router/route-registry.d.ts +0 -30
- package/cjs/router/route-registry.d.ts.map +0 -1
- package/cjs/router/route-registry.js +0 -67
- package/cjs/router/route-registry.js.map +0 -1
- package/cjs/router/route.d.ts +0 -34
- package/cjs/router/route.d.ts.map +0 -1
- package/cjs/router/router.d.ts +0 -169
- package/cjs/router/router.d.ts.map +0 -1
- package/cjs/router/router.js +0 -564
- package/cjs/router/router.js.map +0 -1
- package/cjs/router/types.d.ts +0 -258
- package/cjs/router/types.d.ts.map +0 -1
- package/cjs/router/utils.d.ts +0 -5
- package/cjs/router/utils.d.ts.map +0 -1
- package/cjs/router/utils.js +0 -6
- package/cjs/router/utils.js.map +0 -1
- package/cjs/storage/config.d.ts +0 -8
- package/cjs/storage/config.d.ts.map +0 -1
- package/cjs/storage/config.js +0 -6
- package/cjs/storage/config.js.map +0 -1
- package/cjs/storage/drivers/cloud-driver.d.ts +0 -127
- package/cjs/storage/drivers/cloud-driver.d.ts.map +0 -1
- package/cjs/storage/drivers/cloud-driver.js +0 -406
- package/cjs/storage/drivers/cloud-driver.js.map +0 -1
- package/cjs/storage/drivers/do-spaces-driver.d.ts +0 -47
- package/cjs/storage/drivers/do-spaces-driver.d.ts.map +0 -1
- package/cjs/storage/drivers/do-spaces-driver.js +0 -52
- package/cjs/storage/drivers/do-spaces-driver.js.map +0 -1
- package/cjs/storage/drivers/local-driver.d.ts +0 -136
- package/cjs/storage/drivers/local-driver.d.ts.map +0 -1
- package/cjs/storage/drivers/local-driver.js +0 -409
- package/cjs/storage/drivers/local-driver.js.map +0 -1
- package/cjs/storage/drivers/r2-driver.d.ts +0 -50
- package/cjs/storage/drivers/r2-driver.d.ts.map +0 -1
- package/cjs/storage/drivers/r2-driver.js +0 -59
- package/cjs/storage/drivers/r2-driver.js.map +0 -1
- package/cjs/storage/drivers/s3-driver.d.ts +0 -32
- package/cjs/storage/drivers/s3-driver.d.ts.map +0 -1
- package/cjs/storage/drivers/s3-driver.js +0 -34
- package/cjs/storage/drivers/s3-driver.js.map +0 -1
- package/cjs/storage/index.d.ts +0 -12
- package/cjs/storage/index.d.ts.map +0 -1
- package/cjs/storage/scoped-storage.d.ts +0 -402
- package/cjs/storage/scoped-storage.d.ts.map +0 -1
- package/cjs/storage/scoped-storage.js +0 -488
- package/cjs/storage/scoped-storage.js.map +0 -1
- package/cjs/storage/storage-file.d.ts +0 -216
- package/cjs/storage/storage-file.d.ts.map +0 -1
- package/cjs/storage/storage-file.js +0 -358
- package/cjs/storage/storage-file.js.map +0 -1
- package/cjs/storage/storage.d.ts +0 -582
- package/cjs/storage/storage.d.ts.map +0 -1
- package/cjs/storage/storage.js +0 -941
- package/cjs/storage/storage.js.map +0 -1
- package/cjs/storage/types.d.ts +0 -728
- package/cjs/storage/types.d.ts.map +0 -1
- package/cjs/storage/utils/mime.d.ts +0 -33
- package/cjs/storage/utils/mime.d.ts.map +0 -1
- package/cjs/storage/utils/mime.js +0 -45
- package/cjs/storage/utils/mime.js.map +0 -1
- package/cjs/store/index.d.ts +0 -25
- package/cjs/store/index.d.ts.map +0 -1
- package/cjs/store/index.js +0 -52
- package/cjs/store/index.js.map +0 -1
- package/cjs/tests/boot-testing.d.ts +0 -7
- package/cjs/tests/boot-testing.d.ts.map +0 -1
- package/cjs/tests/boot-testing.js +0 -23
- package/cjs/tests/boot-testing.js.map +0 -1
- package/cjs/tests/create-http-test-application.d.ts +0 -25
- package/cjs/tests/create-http-test-application.d.ts.map +0 -1
- package/cjs/tests/create-http-test-application.js +0 -76
- package/cjs/tests/create-http-test-application.js.map +0 -1
- package/cjs/tests/http-response-output-test.d.ts +0 -42
- package/cjs/tests/http-response-output-test.d.ts.map +0 -1
- package/cjs/tests/http-response-output-test.js +0 -53
- package/cjs/tests/http-response-output-test.js.map +0 -1
- package/cjs/tests/http-test-response.d.ts +0 -75
- package/cjs/tests/http-test-response.d.ts.map +0 -1
- package/cjs/tests/index.d.ts +0 -4
- package/cjs/tests/index.d.ts.map +0 -1
- package/cjs/tests/init-testing.d.ts +0 -7
- package/cjs/tests/init-testing.d.ts.map +0 -1
- package/cjs/tests/types.d.ts +0 -10
- package/cjs/tests/types.d.ts.map +0 -1
- package/cjs/utils/app-log.d.ts +0 -8
- package/cjs/utils/app-log.d.ts.map +0 -1
- package/cjs/utils/app-log.js +0 -7
- package/cjs/utils/app-log.js.map +0 -1
- package/cjs/utils/cleanup-temp-files.d.ts +0 -5
- package/cjs/utils/cleanup-temp-files.d.ts.map +0 -1
- package/cjs/utils/database-log.d.ts +0 -25
- package/cjs/utils/database-log.d.ts.map +0 -1
- package/cjs/utils/database-log.js +0 -44
- package/cjs/utils/database-log.js.map +0 -1
- package/cjs/utils/date-output.d.ts +0 -69
- package/cjs/utils/date-output.d.ts.map +0 -1
- package/cjs/utils/date-output.js +0 -62
- package/cjs/utils/date-output.js.map +0 -1
- package/cjs/utils/date-output.test.d.ts +0 -2
- package/cjs/utils/date-output.test.d.ts.map +0 -1
- package/cjs/utils/download-file.d.ts +0 -3
- package/cjs/utils/download-file.d.ts.map +0 -1
- package/cjs/utils/environment.d.ts +0 -4
- package/cjs/utils/environment.d.ts.map +0 -1
- package/cjs/utils/environment.js +0 -6
- package/cjs/utils/environment.js.map +0 -1
- package/cjs/utils/get-localized.d.ts +0 -10
- package/cjs/utils/get-localized.d.ts.map +0 -1
- package/cjs/utils/get-localized.js +0 -15
- package/cjs/utils/get-localized.js.map +0 -1
- package/cjs/utils/get-localized.test.d.ts +0 -2
- package/cjs/utils/get-localized.test.d.ts.map +0 -1
- package/cjs/utils/index.d.ts +0 -13
- package/cjs/utils/index.d.ts.map +0 -1
- package/cjs/utils/internal.d.ts +0 -4
- package/cjs/utils/internal.d.ts.map +0 -1
- package/cjs/utils/paths.d.ts +0 -55
- package/cjs/utils/paths.d.ts.map +0 -1
- package/cjs/utils/paths.js +0 -89
- package/cjs/utils/paths.js.map +0 -1
- package/cjs/utils/promise-all-object.d.ts +0 -8
- package/cjs/utils/promise-all-object.d.ts.map +0 -1
- package/cjs/utils/promise-all-object.js +0 -12
- package/cjs/utils/promise-all-object.js.map +0 -1
- package/cjs/utils/queue.d.ts +0 -49
- package/cjs/utils/queue.d.ts.map +0 -1
- package/cjs/utils/queue.js +0 -89
- package/cjs/utils/queue.js.map +0 -1
- package/cjs/utils/sleep.d.ts +0 -2
- package/cjs/utils/sleep.d.ts.map +0 -1
- package/cjs/utils/sleep.js +0 -3
- package/cjs/utils/sleep.js.map +0 -1
- package/cjs/utils/sluggable.d.ts +0 -5
- package/cjs/utils/sluggable.d.ts.map +0 -1
- package/cjs/utils/sluggable.js +0 -15
- package/cjs/utils/sluggable.js.map +0 -1
- package/cjs/utils/sluggable.test.d.ts +0 -2
- package/cjs/utils/sluggable.test.d.ts.map +0 -1
- package/cjs/utils/to-json.d.ts +0 -2
- package/cjs/utils/to-json.d.ts.map +0 -1
- package/cjs/utils/to-json.js +0 -26
- package/cjs/utils/to-json.js.map +0 -1
- package/cjs/utils/types.d.ts +0 -22
- package/cjs/utils/types.d.ts.map +0 -1
- package/cjs/utils/urls.d.ts +0 -21
- package/cjs/utils/urls.d.ts.map +0 -1
- package/cjs/utils/urls.js +0 -31
- package/cjs/utils/urls.js.map +0 -1
- package/cjs/validation/database/exists-except-current-id.d.ts +0 -7
- package/cjs/validation/database/exists-except-current-id.d.ts.map +0 -1
- package/cjs/validation/database/exists-except-current-id.js +0 -23
- package/cjs/validation/database/exists-except-current-id.js.map +0 -1
- package/cjs/validation/database/exists-except-current-user.d.ts +0 -7
- package/cjs/validation/database/exists-except-current-user.d.ts.map +0 -1
- package/cjs/validation/database/exists-except-current-user.js +0 -25
- package/cjs/validation/database/exists-except-current-user.js.map +0 -1
- package/cjs/validation/database/exists.d.ts +0 -7
- package/cjs/validation/database/exists.d.ts.map +0 -1
- package/cjs/validation/database/exists.js +0 -21
- package/cjs/validation/database/exists.js.map +0 -1
- package/cjs/validation/database/index.d.ts +0 -12
- package/cjs/validation/database/index.d.ts.map +0 -1
- package/cjs/validation/database/types.d.ts +0 -68
- package/cjs/validation/database/types.d.ts.map +0 -1
- package/cjs/validation/database/unique-except-current-id.d.ts +0 -7
- package/cjs/validation/database/unique-except-current-id.d.ts.map +0 -1
- package/cjs/validation/database/unique-except-current-id.js +0 -23
- package/cjs/validation/database/unique-except-current-id.js.map +0 -1
- package/cjs/validation/database/unique-except-current-user.d.ts +0 -7
- package/cjs/validation/database/unique-except-current-user.d.ts.map +0 -1
- package/cjs/validation/database/unique-except-current-user.js +0 -25
- package/cjs/validation/database/unique-except-current-user.js.map +0 -1
- package/cjs/validation/database/unique.d.ts +0 -7
- package/cjs/validation/database/unique.d.ts.map +0 -1
- package/cjs/validation/database/unique.js +0 -30
- package/cjs/validation/database/unique.js.map +0 -1
- package/cjs/validation/file/file.d.ts +0 -22
- package/cjs/validation/file/file.d.ts.map +0 -1
- package/cjs/validation/file/file.js +0 -60
- package/cjs/validation/file/file.js.map +0 -1
- package/cjs/validation/file/index.d.ts +0 -6
- package/cjs/validation/file/index.d.ts.map +0 -1
- package/cjs/validation/index.d.ts +0 -16
- package/cjs/validation/index.d.ts.map +0 -1
- package/cjs/validation/init.d.ts +0 -7
- package/cjs/validation/init.d.ts.map +0 -1
- package/cjs/validation/init.js +0 -34
- package/cjs/validation/init.js.map +0 -1
- package/cjs/validation/plugins/database-plugin.d.ts +0 -14
- package/cjs/validation/plugins/database-plugin.d.ts.map +0 -1
- package/cjs/validation/plugins/database-plugin.js +0 -95
- package/cjs/validation/plugins/database-plugin.js.map +0 -1
- package/cjs/validation/plugins/file-plugin.d.ts +0 -11
- package/cjs/validation/plugins/file-plugin.d.ts.map +0 -1
- package/cjs/validation/plugins/file-plugin.js +0 -17
- package/cjs/validation/plugins/file-plugin.js.map +0 -1
- package/cjs/validation/plugins/index.d.ts +0 -9
- package/cjs/validation/plugins/index.d.ts.map +0 -1
- package/cjs/validation/plugins/localized-plugin.d.ts +0 -11
- package/cjs/validation/plugins/localized-plugin.d.ts.map +0 -1
- package/cjs/validation/plugins/localized-plugin.js +0 -19
- package/cjs/validation/plugins/localized-plugin.js.map +0 -1
- package/cjs/validation/types.d.ts +0 -87
- package/cjs/validation/types.d.ts.map +0 -1
- package/cjs/validation/validateAll.d.ts +0 -7
- package/cjs/validation/validateAll.d.ts.map +0 -1
- package/cjs/validation/validateAll.js +0 -39
- package/cjs/validation/validateAll.js.map +0 -1
- package/cjs/validation/validators/file-validator.d.ts +0 -40
- package/cjs/validation/validators/file-validator.d.ts.map +0 -1
- package/cjs/validation/validators/file-validator.js +0 -94
- package/cjs/validation/validators/file-validator.js.map +0 -1
- package/cjs/validation/validators/index.d.ts +0 -7
- package/cjs/validation/validators/index.d.ts.map +0 -1
- package/cjs/warlock-config/default-configurations.d.ts +0 -3
- package/cjs/warlock-config/default-configurations.d.ts.map +0 -1
- package/cjs/warlock-config/default-configurations.js +0 -8
- package/cjs/warlock-config/default-configurations.js.map +0 -1
- package/cjs/warlock-config/define-config.d.ts +0 -3
- package/cjs/warlock-config/define-config.d.ts.map +0 -1
- package/cjs/warlock-config/define-config.js +0 -3
- package/cjs/warlock-config/define-config.js.map +0 -1
- package/cjs/warlock-config/index.d.ts +0 -4
- package/cjs/warlock-config/index.d.ts.map +0 -1
- package/cjs/warlock-config/types.d.ts +0 -79
- package/cjs/warlock-config/types.d.ts.map +0 -1
- package/cjs/warlock-config/warlock-config.manager.d.ts +0 -83
- package/cjs/warlock-config/warlock-config.manager.d.ts.map +0 -1
- package/cjs/warlock-config/warlock-config.manager.js +0 -141
- package/cjs/warlock-config/warlock-config.manager.js.map +0 -1
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
'use strict';var reinforcements=require('@mongez/reinforcements'),dayjs=require('dayjs'),path=require('path'),image=require('../image/image.js');require('@mongez/config'),require('../config/config-handlers.js');var storage=require('../storage/storage.js');require('mime'),require('@aws-sdk/client-s3'),require('@aws-sdk/lib-storage'),require('@aws-sdk/s3-request-presigner'),require('crypto'),require('@mongez/fs'),require('fs'),require('fs/promises'),require('stream/promises');var paths=require('../utils/paths.js'),uploadsConfig=require('./uploads-config.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dayjs__default=/*#__PURE__*/_interopDefault(dayjs);var path__default=/*#__PURE__*/_interopDefault(path);/**
|
|
2
|
-
* UploadedFile - Handles multipart file uploads with storage and image integration
|
|
3
|
-
*
|
|
4
|
-
* Provides a fluent API for validating, transforming, and saving uploaded files
|
|
5
|
-
* to various storage drivers (local, S3, R2, etc.).
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* // Simple save with random name
|
|
10
|
-
* const file = await uploadedFile.save("avatars");
|
|
11
|
-
*
|
|
12
|
-
* // Original name with date prefix
|
|
13
|
-
* const file = await uploadedFile.save("avatars", {
|
|
14
|
-
* name: "original",
|
|
15
|
-
* prefix: { format: "yyyy/mm/dd", as: "directory" }
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // With image transformations
|
|
19
|
-
* const file = await uploadedFile
|
|
20
|
-
* .resize(800, 600)
|
|
21
|
-
* .quality(85)
|
|
22
|
-
* .format("webp")
|
|
23
|
-
* .save("avatars");
|
|
24
|
-
*
|
|
25
|
-
* // Different storage driver
|
|
26
|
-
* const file = await uploadedFile.use("s3").save("avatars");
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
class UploadedFile {
|
|
30
|
-
fileData;
|
|
31
|
-
/**
|
|
32
|
-
* File buffered content
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
bufferedFileContent;
|
|
36
|
-
/**
|
|
37
|
-
* Upload file hash (SHA-256)
|
|
38
|
-
*
|
|
39
|
-
* Populated after file is saved.
|
|
40
|
-
*/
|
|
41
|
-
hash = "";
|
|
42
|
-
/**
|
|
43
|
-
* Selected storage driver
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
_storage = storage.storage;
|
|
47
|
-
/**
|
|
48
|
-
* Saved StorageFile reference
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
_storageFile;
|
|
52
|
-
/**
|
|
53
|
-
* Queued image options (high-level API)
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
_imageOptions = {};
|
|
57
|
-
/**
|
|
58
|
-
* Full transform options or callback
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
_transformConfig;
|
|
62
|
-
/**
|
|
63
|
-
* Create a new UploadedFile instance
|
|
64
|
-
*
|
|
65
|
-
* @param fileData - Multipart file data from Fastify
|
|
66
|
-
* @throws Error if file data is invalid
|
|
67
|
-
*/
|
|
68
|
-
constructor(fileData) {
|
|
69
|
-
this.fileData = fileData;
|
|
70
|
-
if (!fileData?.filename) {
|
|
71
|
-
throw new Error("Invalid file data: filename is required");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// ============================================================
|
|
75
|
-
// File Properties
|
|
76
|
-
// ============================================================
|
|
77
|
-
/**
|
|
78
|
-
* Get file name (sanitized)
|
|
79
|
-
*
|
|
80
|
-
* Returns the original filename with special characters removed/replaced.
|
|
81
|
-
*/
|
|
82
|
-
get name() {
|
|
83
|
-
return paths.sanitizePath(this.fileData.filename);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get file MIME type
|
|
87
|
-
*
|
|
88
|
-
* @example "image/jpeg", "application/pdf"
|
|
89
|
-
*/
|
|
90
|
-
get mimeType() {
|
|
91
|
-
return this.fileData.mimetype;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get file extension (lowercase, without dot)
|
|
95
|
-
*
|
|
96
|
-
* @example "jpg", "png", "pdf"
|
|
97
|
-
*/
|
|
98
|
-
get extension() {
|
|
99
|
-
return path__default.default.extname(this.fileData.filename).replace(".", "").toLowerCase();
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get file size in bytes
|
|
103
|
-
*
|
|
104
|
-
* Buffers the file content if not already buffered.
|
|
105
|
-
*/
|
|
106
|
-
async size() {
|
|
107
|
-
const file = await this.buffer();
|
|
108
|
-
return file.length;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get file buffer
|
|
112
|
-
*
|
|
113
|
-
* Caches the buffer after first call for efficiency.
|
|
114
|
-
*/
|
|
115
|
-
async buffer() {
|
|
116
|
-
if (this.bufferedFileContent) {
|
|
117
|
-
return this.bufferedFileContent;
|
|
118
|
-
}
|
|
119
|
-
this.bufferedFileContent = await this.fileData.toBuffer();
|
|
120
|
-
return this.bufferedFileContent;
|
|
121
|
-
}
|
|
122
|
-
// ============================================================
|
|
123
|
-
// File Type Checks
|
|
124
|
-
// ============================================================
|
|
125
|
-
/**
|
|
126
|
-
* Check if file is an image based on MIME type
|
|
127
|
-
*/
|
|
128
|
-
get isImage() {
|
|
129
|
-
return this.mimeType.startsWith("image");
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Check if file is a video based on MIME type
|
|
133
|
-
*/
|
|
134
|
-
get isVideo() {
|
|
135
|
-
return this.mimeType.startsWith("video");
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Check if file is an audio based on MIME type
|
|
139
|
-
*/
|
|
140
|
-
get isAudio() {
|
|
141
|
-
return this.mimeType.startsWith("audio");
|
|
142
|
-
}
|
|
143
|
-
// ============================================================
|
|
144
|
-
// Storage Driver Selection
|
|
145
|
-
// ============================================================
|
|
146
|
-
/**
|
|
147
|
-
* Select a specific storage driver for this upload
|
|
148
|
-
*
|
|
149
|
-
* Returns this instance for chaining. The driver is used
|
|
150
|
-
* when `save()` or `saveAs()` is called.
|
|
151
|
-
*
|
|
152
|
-
* @param driver - Driver name from storage configuration
|
|
153
|
-
* @returns This instance for chaining
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* await file.use("s3").save("avatars");
|
|
158
|
-
* await file.use("r2").save("cdn/images");
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
use(driver) {
|
|
162
|
-
this._storage = storage.storage.use(driver);
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
165
|
-
// ============================================================
|
|
166
|
-
// High-Level Image Transform API
|
|
167
|
-
// ============================================================
|
|
168
|
-
/**
|
|
169
|
-
* Resize the image before saving
|
|
170
|
-
*
|
|
171
|
-
* Only applies to image files. Non-image files ignore this.
|
|
172
|
-
*
|
|
173
|
-
* @param width - Target width in pixels
|
|
174
|
-
* @param height - Optional target height (maintains aspect ratio if omitted)
|
|
175
|
-
* @returns This instance for chaining
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```typescript
|
|
179
|
-
* await file.resize(800).save("thumbnails");
|
|
180
|
-
* await file.resize(400, 400).save("avatars");
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
resize(width, height) {
|
|
184
|
-
this._imageOptions.resize = { width, height };
|
|
185
|
-
return this;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Set image output quality
|
|
189
|
-
*
|
|
190
|
-
* Quality affects file size and visual fidelity.
|
|
191
|
-
* Only applies to formats that support quality (JPEG, WebP, AVIF).
|
|
192
|
-
*
|
|
193
|
-
* @param value - Quality value (1-100)
|
|
194
|
-
* @returns This instance for chaining
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```typescript
|
|
198
|
-
* await file.quality(85).save("images");
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
quality(value) {
|
|
202
|
-
if (value < 1 || value > 100) {
|
|
203
|
-
throw new Error("Quality must be between 1 and 100");
|
|
204
|
-
}
|
|
205
|
-
this._imageOptions.quality = value;
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Convert image to a specific format
|
|
210
|
-
*
|
|
211
|
-
* Changes the output format and updates the file extension accordingly.
|
|
212
|
-
*
|
|
213
|
-
* @param format - Target image format (jpeg, png, webp, avif, etc.)
|
|
214
|
-
* @returns This instance for chaining
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```typescript
|
|
218
|
-
* await file.format("webp").save("images");
|
|
219
|
-
* await file.resize(800).format("avif").quality(80).save("optimized");
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
format(format) {
|
|
223
|
-
this._imageOptions.format = format;
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Rotate the image
|
|
228
|
-
*
|
|
229
|
-
* @param degrees - Rotation angle in degrees (positive = clockwise)
|
|
230
|
-
* @returns This instance for chaining
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```typescript
|
|
234
|
-
* await file.rotate(90).save("rotated");
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
rotate(degrees) {
|
|
238
|
-
this._imageOptions.rotate = degrees;
|
|
239
|
-
return this;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Apply blur effect to the image
|
|
243
|
-
*
|
|
244
|
-
* @param sigma - Blur intensity (default: 3, minimum: 0.3)
|
|
245
|
-
* @returns This instance for chaining
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* await file.blur(5).save("blurred");
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
blur(sigma = 3) {
|
|
253
|
-
if (sigma < 0.3) {
|
|
254
|
-
throw new Error("Blur sigma must be at least 0.3");
|
|
255
|
-
}
|
|
256
|
-
this._imageOptions.blur = sigma;
|
|
257
|
-
return this;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Convert image to grayscale (black and white)
|
|
261
|
-
*
|
|
262
|
-
* @returns This instance for chaining
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* ```typescript
|
|
266
|
-
* await file.grayscale().save("bw-images");
|
|
267
|
-
* ```
|
|
268
|
-
*/
|
|
269
|
-
grayscale() {
|
|
270
|
-
this._imageOptions.grayscale = true;
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
// ============================================================
|
|
274
|
-
// Full Transform Control
|
|
275
|
-
// ============================================================
|
|
276
|
-
/**
|
|
277
|
-
* Apply full image transformations
|
|
278
|
-
*
|
|
279
|
-
* Provides complete control over image processing. Can be used with:
|
|
280
|
-
* - An options object for predefined transforms
|
|
281
|
-
* - A callback function for chained operations
|
|
282
|
-
*
|
|
283
|
-
* @param config - Transform options or callback function
|
|
284
|
-
* @returns This instance for chaining
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```typescript
|
|
288
|
-
* // Using options object
|
|
289
|
-
* await file.transform({
|
|
290
|
-
* resize: { width: 800, fit: "inside" },
|
|
291
|
-
* quality: 85
|
|
292
|
-
* }).save("images");
|
|
293
|
-
*
|
|
294
|
-
* // Using callback for full control
|
|
295
|
-
* await file.transform(img =>
|
|
296
|
-
* img.resize({ width: 800 })
|
|
297
|
-
* .watermark("logo.png", { gravity: "southeast" })
|
|
298
|
-
* .sharpen()
|
|
299
|
-
* ).save("products");
|
|
300
|
-
* ```
|
|
301
|
-
*/
|
|
302
|
-
transform(config) {
|
|
303
|
-
this._transformConfig = config;
|
|
304
|
-
return this;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Get an Image instance for advanced manipulation
|
|
308
|
-
*
|
|
309
|
-
* Returns an Image instance from the file buffer for manual processing.
|
|
310
|
-
* Use this when you need operations not covered by the fluent API.
|
|
311
|
-
*
|
|
312
|
-
* @returns Promise resolving to Image instance
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* ```typescript
|
|
316
|
-
* const img = await file.toImage();
|
|
317
|
-
* await img
|
|
318
|
-
* .resize({ width: 800 })
|
|
319
|
-
* .watermark("logo.png", { gravity: "southeast" })
|
|
320
|
-
* .save("path/to/output.jpg");
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
async toImage() {
|
|
324
|
-
return new image.Image(await this.buffer());
|
|
325
|
-
}
|
|
326
|
-
// ============================================================
|
|
327
|
-
// Image Metadata
|
|
328
|
-
// ============================================================
|
|
329
|
-
/**
|
|
330
|
-
* Get file width and height (only for images)
|
|
331
|
-
*
|
|
332
|
-
* @returns Dimensions object, or empty object if not an image
|
|
333
|
-
*/
|
|
334
|
-
async dimensions() {
|
|
335
|
-
if (!this.isImage) {
|
|
336
|
-
return {};
|
|
337
|
-
}
|
|
338
|
-
return new image.Image(await this.buffer()).dimensions();
|
|
339
|
-
}
|
|
340
|
-
// ============================================================
|
|
341
|
-
// Validation
|
|
342
|
-
// ============================================================
|
|
343
|
-
/**
|
|
344
|
-
* Validate file against the given options
|
|
345
|
-
*
|
|
346
|
-
* @param options - Validation rules
|
|
347
|
-
* @throws Error if validation fails
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```typescript
|
|
351
|
-
* await file.validate({
|
|
352
|
-
* allowedMimeTypes: ["image/jpeg", "image/png"],
|
|
353
|
-
* maxSize: 5 * 1024 * 1024 // 5MB
|
|
354
|
-
* });
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
async validate(options) {
|
|
358
|
-
const { allowedMimeTypes, allowedExtensions, maxSize } = options;
|
|
359
|
-
if (allowedMimeTypes && !allowedMimeTypes.includes(this.mimeType)) {
|
|
360
|
-
throw new Error(`Invalid file type: ${this.mimeType}. Allowed types: ${allowedMimeTypes.join(", ")}`);
|
|
361
|
-
}
|
|
362
|
-
if (allowedExtensions && !allowedExtensions.includes(this.extension)) {
|
|
363
|
-
throw new Error(`Invalid file extension: ${this.extension}. Allowed extensions: ${allowedExtensions.join(", ")}`);
|
|
364
|
-
}
|
|
365
|
-
if (maxSize) {
|
|
366
|
-
const fileSize = await this.size();
|
|
367
|
-
if (fileSize > maxSize) {
|
|
368
|
-
throw new Error(`File too large: ${fileSize} bytes. Maximum allowed: ${maxSize} bytes`);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
// ============================================================
|
|
373
|
-
// Save Operations
|
|
374
|
-
// ============================================================
|
|
375
|
-
/**
|
|
376
|
-
* Save the file to a directory with automatic naming
|
|
377
|
-
*
|
|
378
|
-
* Uses the configured naming strategy and prefix options to generate
|
|
379
|
-
* the final path. Returns a StorageFile for accessing file metadata.
|
|
380
|
-
*
|
|
381
|
-
* @param directory - Target directory path
|
|
382
|
-
* @param options - Save options (name, prefix, driver, validate)
|
|
383
|
-
* @returns StorageFile instance with file metadata and operations
|
|
384
|
-
*
|
|
385
|
-
* @example
|
|
386
|
-
* ```typescript
|
|
387
|
-
* // Random name (default)
|
|
388
|
-
* await file.save("avatars");
|
|
389
|
-
* // → avatars/x7k9m2p4.jpg
|
|
390
|
-
*
|
|
391
|
-
* // Original name
|
|
392
|
-
* await file.save("avatars", { name: "original" });
|
|
393
|
-
* // → avatars/photo.jpg
|
|
394
|
-
*
|
|
395
|
-
* // With date directory
|
|
396
|
-
* await file.save("avatars", {
|
|
397
|
-
* prefix: { format: "yyyy/mm/dd", as: "directory" }
|
|
398
|
-
* });
|
|
399
|
-
* // → avatars/2025/12/21/x7k9m2p4.jpg
|
|
400
|
-
*
|
|
401
|
-
* // Original name with datetime prefix
|
|
402
|
-
* await file.save("avatars", { name: "original", prefix: true });
|
|
403
|
-
* // → avatars/21-12-2025-16-45-30-photo.jpg
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
async save(directory, options) {
|
|
407
|
-
// Validate if requested
|
|
408
|
-
if (options?.validate) {
|
|
409
|
-
await this.validate(options.validate);
|
|
410
|
-
}
|
|
411
|
-
// Resolve filename and prefix
|
|
412
|
-
const filename = this.resolveFilename(options);
|
|
413
|
-
const prefix = this.resolvePrefix(options?.prefix);
|
|
414
|
-
const location = this.buildLocation(directory, prefix, filename);
|
|
415
|
-
return this.saveToLocation(location, options?.driver);
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Save the file to an explicit path
|
|
419
|
-
*
|
|
420
|
-
* Unlike `save()`, this method uses the exact path you provide.
|
|
421
|
-
* No automatic naming or prefix is applied.
|
|
422
|
-
*
|
|
423
|
-
* @param location - Full file path (directory + filename)
|
|
424
|
-
* @param options - Save options (driver, validate)
|
|
425
|
-
* @returns StorageFile instance with file metadata
|
|
426
|
-
*
|
|
427
|
-
* @example
|
|
428
|
-
* ```typescript
|
|
429
|
-
* await file.saveAs("avatars/profile-123.png");
|
|
430
|
-
* await file.saveAs("products/2025/featured-image.webp");
|
|
431
|
-
* ```
|
|
432
|
-
*/
|
|
433
|
-
async saveAs(location, options) {
|
|
434
|
-
// Validate if requested
|
|
435
|
-
if (options?.validate) {
|
|
436
|
-
await this.validate(options.validate);
|
|
437
|
-
}
|
|
438
|
-
return this.saveToLocation(location, options?.driver);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Get the StorageFile reference if file has been saved
|
|
442
|
-
*
|
|
443
|
-
* Returns undefined if file hasn't been saved yet.
|
|
444
|
-
*/
|
|
445
|
-
get storageFile() {
|
|
446
|
-
return this._storageFile;
|
|
447
|
-
}
|
|
448
|
-
// ============================================================
|
|
449
|
-
// Internal Helpers
|
|
450
|
-
// ============================================================
|
|
451
|
-
/**
|
|
452
|
-
* Execute save to the specified location
|
|
453
|
-
* @internal
|
|
454
|
-
*/
|
|
455
|
-
async saveToLocation(location, driver) {
|
|
456
|
-
// Get file content (apply transforms if image)
|
|
457
|
-
const content = await this.getProcessedContent();
|
|
458
|
-
// Select storage
|
|
459
|
-
const storageInstance = this.resolveStorage(driver);
|
|
460
|
-
// Determine final location (adjust extension if format changed)
|
|
461
|
-
const finalLocation = this.adjustLocationForFormat(location);
|
|
462
|
-
// Save to storage
|
|
463
|
-
this._storageFile = await storageInstance.put(content, finalLocation, {
|
|
464
|
-
mimeType: this.getFinalMimeType(),
|
|
465
|
-
});
|
|
466
|
-
// Store hash from StorageFile
|
|
467
|
-
const info = await this._storageFile.data();
|
|
468
|
-
this.hash = info.hash || "";
|
|
469
|
-
return this._storageFile;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Get processed content (with transforms applied if applicable)
|
|
473
|
-
* @internal
|
|
474
|
-
*/
|
|
475
|
-
async getProcessedContent() {
|
|
476
|
-
const content = await this.buffer();
|
|
477
|
-
// If not an image or no transforms, return as-is
|
|
478
|
-
if (!this.isImage || !this.hasTransforms()) {
|
|
479
|
-
return content;
|
|
480
|
-
}
|
|
481
|
-
// Create Image and apply transforms
|
|
482
|
-
let img = new image.Image(content);
|
|
483
|
-
// Apply transform callback or options
|
|
484
|
-
if (typeof this._transformConfig === "function") {
|
|
485
|
-
img = this._transformConfig(img);
|
|
486
|
-
}
|
|
487
|
-
else if (this._transformConfig) {
|
|
488
|
-
img = img.apply(this._transformConfig);
|
|
489
|
-
}
|
|
490
|
-
// Apply high-level options on top
|
|
491
|
-
img = this.applyImageOptions(img);
|
|
492
|
-
return img.toBuffer();
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Apply high-level image options
|
|
496
|
-
* @internal
|
|
497
|
-
*/
|
|
498
|
-
applyImageOptions(img) {
|
|
499
|
-
const opts = this._imageOptions;
|
|
500
|
-
if (opts.resize) {
|
|
501
|
-
img = img.resize({ width: opts.resize.width, height: opts.resize.height });
|
|
502
|
-
}
|
|
503
|
-
if (opts.rotate !== undefined) {
|
|
504
|
-
img = img.rotate(opts.rotate);
|
|
505
|
-
}
|
|
506
|
-
if (opts.blur !== undefined) {
|
|
507
|
-
img = img.blur(opts.blur);
|
|
508
|
-
}
|
|
509
|
-
if (opts.grayscale) {
|
|
510
|
-
img = img.grayscale();
|
|
511
|
-
}
|
|
512
|
-
if (opts.quality !== undefined) {
|
|
513
|
-
img = img.quality(opts.quality);
|
|
514
|
-
}
|
|
515
|
-
if (opts.format) {
|
|
516
|
-
img = img.format(opts.format);
|
|
517
|
-
}
|
|
518
|
-
return img;
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Check if any transforms are queued
|
|
522
|
-
* @internal
|
|
523
|
-
*/
|
|
524
|
-
hasTransforms() {
|
|
525
|
-
return this._transformConfig !== undefined || Object.keys(this._imageOptions).length > 0;
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Resolve storage instance to use
|
|
529
|
-
* @internal
|
|
530
|
-
*/
|
|
531
|
-
resolveStorage(driver) {
|
|
532
|
-
if (this._storage) {
|
|
533
|
-
return this._storage;
|
|
534
|
-
}
|
|
535
|
-
if (driver) {
|
|
536
|
-
return storage.storage.use(driver);
|
|
537
|
-
}
|
|
538
|
-
return storage.storage;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Resolve the filename based on options and config
|
|
542
|
-
* @internal
|
|
543
|
-
*/
|
|
544
|
-
resolveFilename(options) {
|
|
545
|
-
const namingStrategy = options?.name ?? uploadsConfig.uploadsConfig("name") ?? "random";
|
|
546
|
-
let baseName;
|
|
547
|
-
if (namingStrategy === "original") {
|
|
548
|
-
baseName = path__default.default.basename(this.name, path__default.default.extname(this.name));
|
|
549
|
-
}
|
|
550
|
-
else if (namingStrategy === "random") {
|
|
551
|
-
const length = uploadsConfig.uploadsConfig("randomLength");
|
|
552
|
-
baseName = reinforcements.Random.string(length);
|
|
553
|
-
}
|
|
554
|
-
else {
|
|
555
|
-
// Custom name - strip extension if provided, we'll add it
|
|
556
|
-
baseName = path__default.default.basename(namingStrategy, path__default.default.extname(namingStrategy));
|
|
557
|
-
}
|
|
558
|
-
// Get extension (may be changed by format transform)
|
|
559
|
-
const ext = this.getFinalExtension();
|
|
560
|
-
return `${baseName}.${ext}`;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Resolve prefix based on options and config
|
|
564
|
-
* @internal
|
|
565
|
-
*/
|
|
566
|
-
resolvePrefix(prefix) {
|
|
567
|
-
// No prefix
|
|
568
|
-
if (prefix === false || prefix === undefined) {
|
|
569
|
-
const configPrefix = uploadsConfig.uploadsConfig("prefix");
|
|
570
|
-
if (!configPrefix) {
|
|
571
|
-
return "";
|
|
572
|
-
}
|
|
573
|
-
// Use config prefix if no explicit prefix provided
|
|
574
|
-
return this.resolvePrefix(configPrefix);
|
|
575
|
-
}
|
|
576
|
-
// Boolean true = use default format
|
|
577
|
-
if (prefix === true) {
|
|
578
|
-
const format = uploadsConfig.uploadsConfig("defaultPrefixFormat") ?? "dd-mm-yyyy-HH-ii-ss";
|
|
579
|
-
return this.formatDatePrefix(format, "file");
|
|
580
|
-
}
|
|
581
|
-
// String = static prefix
|
|
582
|
-
if (typeof prefix === "string") {
|
|
583
|
-
return prefix;
|
|
584
|
-
}
|
|
585
|
-
// PrefixOptions object
|
|
586
|
-
const parts = [];
|
|
587
|
-
// Add date format if specified
|
|
588
|
-
if (prefix.format) {
|
|
589
|
-
parts.push(this.formatDate(prefix.format));
|
|
590
|
-
}
|
|
591
|
-
// Add random string if specified
|
|
592
|
-
if (prefix.randomLength) {
|
|
593
|
-
parts.push(reinforcements.Random.string(prefix.randomLength));
|
|
594
|
-
}
|
|
595
|
-
const combined = parts.join("-");
|
|
596
|
-
const as = prefix.as ?? "file";
|
|
597
|
-
if (as === "directory") {
|
|
598
|
-
return combined ? `${combined}/` : "";
|
|
599
|
-
}
|
|
600
|
-
return combined ? `${combined}-` : "";
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Format a date prefix with the given format
|
|
604
|
-
* @internal
|
|
605
|
-
*/
|
|
606
|
-
formatDatePrefix(format, as) {
|
|
607
|
-
const formatted = this.formatDate(format);
|
|
608
|
-
return as === "directory" ? `${formatted}/` : `${formatted}-`;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Format current date using token-based format string
|
|
612
|
-
* @internal
|
|
613
|
-
*/
|
|
614
|
-
formatDate(format) {
|
|
615
|
-
return dayjs__default.default().format(format);
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Build final location from directory, prefix, and filename
|
|
619
|
-
* @internal
|
|
620
|
-
*/
|
|
621
|
-
buildLocation(directory, prefix, filename) {
|
|
622
|
-
// Clean up directory (remove trailing slash)
|
|
623
|
-
const dir = directory.replace(/\/$/, "");
|
|
624
|
-
// If prefix ends with /, it's a directory
|
|
625
|
-
if (prefix.endsWith("/")) {
|
|
626
|
-
return `${dir}/${prefix}${filename}`;
|
|
627
|
-
}
|
|
628
|
-
// Otherwise prefix is part of filename
|
|
629
|
-
return `${dir}/${prefix}${filename}`;
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Get final extension (accounting for format changes)
|
|
633
|
-
* @internal
|
|
634
|
-
*/
|
|
635
|
-
getFinalExtension() {
|
|
636
|
-
if (this._imageOptions.format) {
|
|
637
|
-
// Map formats to extensions
|
|
638
|
-
const format = this._imageOptions.format;
|
|
639
|
-
if (format === "jpeg")
|
|
640
|
-
return "jpg";
|
|
641
|
-
return format;
|
|
642
|
-
}
|
|
643
|
-
return this.extension;
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Get final MIME type (accounting for format changes)
|
|
647
|
-
* @internal
|
|
648
|
-
*/
|
|
649
|
-
getFinalMimeType() {
|
|
650
|
-
if (this._imageOptions.format) {
|
|
651
|
-
const format = this._imageOptions.format;
|
|
652
|
-
if (format === "jpeg" || format === "jpg")
|
|
653
|
-
return "image/jpeg";
|
|
654
|
-
return `image/${format}`;
|
|
655
|
-
}
|
|
656
|
-
return this.mimeType;
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Adjust location to use correct extension if format changed
|
|
660
|
-
* @internal
|
|
661
|
-
*/
|
|
662
|
-
adjustLocationForFormat(location) {
|
|
663
|
-
if (!this._imageOptions.format) {
|
|
664
|
-
return location;
|
|
665
|
-
}
|
|
666
|
-
const ext = this.getFinalExtension();
|
|
667
|
-
const currentExt = path__default.default.extname(location);
|
|
668
|
-
if (currentExt) {
|
|
669
|
-
return location.replace(currentExt, `.${ext}`);
|
|
670
|
-
}
|
|
671
|
-
return `${location}.${ext}`;
|
|
672
|
-
}
|
|
673
|
-
// ============================================================
|
|
674
|
-
// Serialization
|
|
675
|
-
// ============================================================
|
|
676
|
-
/**
|
|
677
|
-
* Convert to JSON representation
|
|
678
|
-
*
|
|
679
|
-
* Includes file metadata and base64 content for serialization.
|
|
680
|
-
*/
|
|
681
|
-
async toJSON() {
|
|
682
|
-
return {
|
|
683
|
-
name: this.name,
|
|
684
|
-
mimeType: this.mimeType,
|
|
685
|
-
extension: this.extension,
|
|
686
|
-
size: await this.size(),
|
|
687
|
-
isImage: this.isImage,
|
|
688
|
-
isVideo: this.isVideo,
|
|
689
|
-
isAudio: this.isAudio,
|
|
690
|
-
dimensions: this.isImage ? await this.dimensions() : undefined,
|
|
691
|
-
base64: (await this.buffer()).toString("base64"),
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
}exports.UploadedFile=UploadedFile;//# sourceMappingURL=uploaded-file.js.map
|