@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
package/cjs/storage/storage.js
DELETED
|
@@ -1,941 +0,0 @@
|
|
|
1
|
-
'use strict';var events=require('@mongez/events'),config=require('./config.js'),doSpacesDriver=require('./drivers/do-spaces-driver.js'),localDriver=require('./drivers/local-driver.js'),r2Driver=require('./drivers/r2-driver.js'),s3Driver=require('./drivers/s3-driver.js'),scopedStorage=require('./scoped-storage.js'),storageFile=require('./storage-file.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var events__default=/*#__PURE__*/_interopDefault(events);/**
|
|
2
|
-
* Storage Manager
|
|
3
|
-
*
|
|
4
|
-
* Provides a unified interface for file storage operations across multiple
|
|
5
|
-
* drivers (local, S3, R2, DigitalOcean Spaces). Extends `ScopedStorage` to
|
|
6
|
-
* inherit all base operations while adding driver management and events.
|
|
7
|
-
*
|
|
8
|
-
* All operations return `StorageFile` instances for a consistent, rich DX.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Basic usage (uses default driver)
|
|
13
|
-
* const file = await storage.put(buffer, "uploads/image.jpg");
|
|
14
|
-
*
|
|
15
|
-
* // With options
|
|
16
|
-
* const file = await storage.put(buffer, "uploads/image.jpg", {
|
|
17
|
-
* mimeType: "image/jpeg",
|
|
18
|
-
* cacheControl: "max-age=31536000"
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* // Using specific driver (also returns StorageFile)
|
|
22
|
-
* const file = await storage.use("s3").put(buffer, "path/to/file");
|
|
23
|
-
*
|
|
24
|
-
* // Get raw driver for advanced use
|
|
25
|
-
* const driver = storage.driver("s3");
|
|
26
|
-
* const data = await driver.put(buffer, "path/to/file"); // Returns StorageFileData
|
|
27
|
-
*
|
|
28
|
-
* // Stream operations for large files
|
|
29
|
-
* const stream = await storage.getStream("large-file.zip");
|
|
30
|
-
* await storage.putStream(readableStream, "output/file.zip");
|
|
31
|
-
*
|
|
32
|
-
* // Batch operations
|
|
33
|
-
* const results = await storage.deleteMany(["file1.txt", "file2.txt"]);
|
|
34
|
-
*
|
|
35
|
-
* // Event hooks
|
|
36
|
-
* storage.on("afterPut", ({ location, file }) => {
|
|
37
|
-
* console.log(`Uploaded ${location}`);
|
|
38
|
-
* });
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
class Storage extends scopedStorage.ScopedStorage {
|
|
42
|
-
/**
|
|
43
|
-
* Registered drivers (cached instances)
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
drivers = new Map();
|
|
47
|
-
/**
|
|
48
|
-
* Driver configurations
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
configs = new Map();
|
|
52
|
-
/**
|
|
53
|
-
* Default driver name
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
defaultDriverName;
|
|
57
|
-
/**
|
|
58
|
-
* Whether the storage has been initialized
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
initialized = false;
|
|
62
|
-
/**
|
|
63
|
-
* Create a new Storage manager instance
|
|
64
|
-
*
|
|
65
|
-
* Uses lazy initialization - driver is resolved on first access.
|
|
66
|
-
*/
|
|
67
|
-
constructor() {
|
|
68
|
-
// Temp placeholder - will be replaced on first access
|
|
69
|
-
super(null);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Ensure storage is initialized (lazy initialization)
|
|
73
|
-
*
|
|
74
|
-
* Called automatically on first driver access.
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
ensureInitialized() {
|
|
78
|
-
if (this.initialized)
|
|
79
|
-
return;
|
|
80
|
-
// Mark as initialized FIRST to prevent infinite recursion
|
|
81
|
-
this.initialized = true;
|
|
82
|
-
// Get default driver name from config
|
|
83
|
-
const defaultName = config.storageConfig("default", "local");
|
|
84
|
-
this.defaultDriverName = defaultName;
|
|
85
|
-
this.loadDriversFromConfig();
|
|
86
|
-
// Now set the actual driver
|
|
87
|
-
this._driver = this.resolveDriver(this.defaultDriverName);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get the underlying driver instance (triggers lazy init)
|
|
91
|
-
*
|
|
92
|
-
* @returns The raw storage driver
|
|
93
|
-
*/
|
|
94
|
-
get driver() {
|
|
95
|
-
this.ensureInitialized();
|
|
96
|
-
return this._driver;
|
|
97
|
-
}
|
|
98
|
-
// ============================================================
|
|
99
|
-
// Driver Management
|
|
100
|
-
// ============================================================
|
|
101
|
-
/**
|
|
102
|
-
* Load drivers from configuration
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
loadDriversFromConfig() {
|
|
106
|
-
const drivers = config.storageConfig("drivers", {});
|
|
107
|
-
for (const [name, config] of Object.entries(drivers)) {
|
|
108
|
-
this.configs.set(name, config);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get a scoped storage for a specific driver
|
|
113
|
-
*
|
|
114
|
-
* Returns a `ScopedStorage` instance that wraps the specified driver.
|
|
115
|
-
* Operations on the returned instance also return `StorageFile` objects.
|
|
116
|
-
*
|
|
117
|
-
* @param name - Driver name as defined in configuration
|
|
118
|
-
* @returns ScopedStorage instance for the specified driver
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* // Upload to S3
|
|
123
|
-
* const s3File = await storage.use("s3").put(buffer, "images/photo.jpg");
|
|
124
|
-
*
|
|
125
|
-
* // Upload to local
|
|
126
|
-
* const localFile = await storage.use("local").put(buffer, "temp/file.txt");
|
|
127
|
-
*
|
|
128
|
-
* // Both return StorageFile with identical API
|
|
129
|
-
* console.log(s3File.url);
|
|
130
|
-
* console.log(localFile.url);
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
use(name) {
|
|
134
|
-
return new scopedStorage.ScopedStorage(this.getDriver(name));
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get a raw driver instance
|
|
138
|
-
*
|
|
139
|
-
* Returns the underlying driver directly for advanced use cases.
|
|
140
|
-
* Unlike `use()`, calling methods on the raw driver returns
|
|
141
|
-
* `StorageFileData` instead of `StorageFile`.
|
|
142
|
-
*
|
|
143
|
-
* @param name - Driver name as defined in configuration
|
|
144
|
-
* @returns Raw driver instance implementing StorageDriverContract
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const driver = storage.getDriver("s3");
|
|
149
|
-
* const data = await driver.put(buffer, "path/to/file");
|
|
150
|
-
* // data is StorageFileData, not StorageFile
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
getDriver(name) {
|
|
154
|
-
return this.resolveDriver(name);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Use a cloud storage driver with extended cloud capabilities
|
|
158
|
-
*
|
|
159
|
-
* @param name - Cloud driver name (s3, r2, spaces)
|
|
160
|
-
* @returns Driver instance implementing CloudStorageDriverContract
|
|
161
|
-
* @throws Error if driver doesn't support cloud operations
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* const cloudDriver = storage.useCloud("s3");
|
|
166
|
-
* const presignedUrl = await cloudDriver.getPresignedUrl("private/doc.pdf");
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
useCloud(name) {
|
|
170
|
-
const instance = this.getDriver(name);
|
|
171
|
-
if (!this.isCloudDriver(instance)) {
|
|
172
|
-
throw new Error(`Driver "${name}" does not support cloud operations`);
|
|
173
|
-
}
|
|
174
|
-
return instance;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Register a new driver configuration at runtime
|
|
178
|
-
*
|
|
179
|
-
* Allows dynamic driver registration for multi-tenancy or
|
|
180
|
-
* runtime configuration scenarios.
|
|
181
|
-
*
|
|
182
|
-
* @param name - Unique driver name
|
|
183
|
-
* @param config - Driver configuration
|
|
184
|
-
* @returns This instance for chaining
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* storage.register("tenant-s3", {
|
|
189
|
-
* driver: "s3",
|
|
190
|
-
* bucket: "tenant-bucket",
|
|
191
|
-
* region: "us-east-1",
|
|
192
|
-
* accessKeyId: process.env.TENANT_AWS_KEY,
|
|
193
|
-
* secretAccessKey: process.env.TENANT_AWS_SECRET
|
|
194
|
-
* });
|
|
195
|
-
*
|
|
196
|
-
* await storage.use("tenant-s3").put(buffer, "file.txt");
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
register(name, config) {
|
|
200
|
-
this.configs.set(name, config);
|
|
201
|
-
this.drivers.delete(name); // Clear cached instance
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Set the default driver name
|
|
206
|
-
*
|
|
207
|
-
* @param name - Driver name to use as default
|
|
208
|
-
* @returns This instance for chaining
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* storage.setDefault("s3");
|
|
213
|
-
* await storage.put(buffer, "file.txt"); // Now uses S3
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
setDefault(name) {
|
|
217
|
-
this.defaultDriverName = name;
|
|
218
|
-
this._driver = this.getDriver(name);
|
|
219
|
-
return this;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Get current driver instance after resolving (async, respects resolver)
|
|
223
|
-
*
|
|
224
|
-
* Resolves the driver based on configuration, including any async
|
|
225
|
-
* resolver for multi-tenancy support.
|
|
226
|
-
*
|
|
227
|
-
* @returns Promise resolving to the current driver
|
|
228
|
-
*/
|
|
229
|
-
async currentDriver() {
|
|
230
|
-
const driverName = await this.resolveDefaultDriver();
|
|
231
|
-
return this.getDriver(driverName);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Check if current driver is a cloud driver
|
|
235
|
-
*
|
|
236
|
-
* @returns Promise resolving to true if the current driver supports cloud operations
|
|
237
|
-
*/
|
|
238
|
-
async isCloud() {
|
|
239
|
-
const driver = await this.currentDriver();
|
|
240
|
-
return this.isCloudDriver(driver);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Check if a driver instance supports cloud operations
|
|
244
|
-
* @internal
|
|
245
|
-
*/
|
|
246
|
-
isCloudDriver(driver) {
|
|
247
|
-
return "getPresignedUrl" in driver;
|
|
248
|
-
}
|
|
249
|
-
// ============================================================
|
|
250
|
-
// Event System
|
|
251
|
-
// ============================================================
|
|
252
|
-
/**
|
|
253
|
-
* Register an event handler
|
|
254
|
-
*
|
|
255
|
-
* Subscribe to storage events for logging, analytics, or side effects.
|
|
256
|
-
*
|
|
257
|
-
* @param event - Event type to listen for
|
|
258
|
-
* @param handler - Handler function
|
|
259
|
-
* @returns Event subscription for unsubscribing
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```typescript
|
|
263
|
-
* // Log all uploads
|
|
264
|
-
* storage.on("afterPut", ({ location, file }) => {
|
|
265
|
-
* console.log(`Uploaded ${file?.size} bytes to ${location}`);
|
|
266
|
-
* });
|
|
267
|
-
*
|
|
268
|
-
* // Track deletions
|
|
269
|
-
* storage.on("afterDelete", ({ location }) => {
|
|
270
|
-
* analytics.track("file_deleted", { path: location });
|
|
271
|
-
* });
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
on(event, handler) {
|
|
275
|
-
return events__default.default.subscribe(`storage.${event}`, handler);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Remove all handlers for an event type
|
|
279
|
-
*
|
|
280
|
-
* @param event - Event type to remove handlers for
|
|
281
|
-
* @returns This instance for chaining
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* ```typescript
|
|
285
|
-
* storage.off("afterPut"); // Remove all afterPut handlers
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
off(event) {
|
|
289
|
-
events__default.default.off(`storage.${event}`);
|
|
290
|
-
return this;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Emit an event to all registered handlers
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
296
|
-
async emit(event, payload) {
|
|
297
|
-
await events__default.default.triggerAll(`storage.${event}`, payload);
|
|
298
|
-
}
|
|
299
|
-
// ============================================================
|
|
300
|
-
// Overridden Operations with Events
|
|
301
|
-
// ============================================================
|
|
302
|
-
/**
|
|
303
|
-
* Store a file in storage
|
|
304
|
-
*
|
|
305
|
-
* Extends base `put()` with event emission for beforePut/afterPut hooks.
|
|
306
|
-
*
|
|
307
|
-
* @param file - File content as Buffer, string, UploadedFile, or Readable stream
|
|
308
|
-
* @param location - Destination path
|
|
309
|
-
* @param options - Storage options (mimeType, cacheControl, etc.)
|
|
310
|
-
* @returns StorageFile instance with cached metadata
|
|
311
|
-
*/
|
|
312
|
-
async put(file, location, options) {
|
|
313
|
-
const driver = await this.currentDriver();
|
|
314
|
-
const buffer = await this.toBuffer(file);
|
|
315
|
-
await this.emit("beforePut", {
|
|
316
|
-
driver: driver.name,
|
|
317
|
-
location,
|
|
318
|
-
timestamp: new Date(),
|
|
319
|
-
size: buffer.length,
|
|
320
|
-
});
|
|
321
|
-
const result = await driver.put(buffer, location, options);
|
|
322
|
-
await this.emit("afterPut", {
|
|
323
|
-
driver: driver.name,
|
|
324
|
-
location,
|
|
325
|
-
timestamp: new Date(),
|
|
326
|
-
file: result,
|
|
327
|
-
});
|
|
328
|
-
return storageFile.StorageFile.fromData(result, driver);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Store a file from a readable stream (for large files)
|
|
332
|
-
*
|
|
333
|
-
* Extends base `putStream()` with event emission.
|
|
334
|
-
*
|
|
335
|
-
* @param stream - Readable stream
|
|
336
|
-
* @param location - Destination path
|
|
337
|
-
* @param options - Storage options
|
|
338
|
-
* @returns StorageFile instance with cached metadata
|
|
339
|
-
*/
|
|
340
|
-
async putStream(stream, location, options) {
|
|
341
|
-
const driver = await this.currentDriver();
|
|
342
|
-
await this.emit("beforePut", {
|
|
343
|
-
driver: driver.name,
|
|
344
|
-
location,
|
|
345
|
-
timestamp: new Date(),
|
|
346
|
-
});
|
|
347
|
-
const result = await driver.putStream(stream, location, options);
|
|
348
|
-
await this.emit("afterPut", {
|
|
349
|
-
driver: driver.name,
|
|
350
|
-
location,
|
|
351
|
-
timestamp: new Date(),
|
|
352
|
-
file: result,
|
|
353
|
-
});
|
|
354
|
-
return storageFile.StorageFile.fromData(result, driver);
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Store a file from a URL
|
|
358
|
-
*
|
|
359
|
-
* Downloads content from the URL and stores it at the specified location.
|
|
360
|
-
*
|
|
361
|
-
* @param url - Source URL to download from
|
|
362
|
-
* @param location - Destination path
|
|
363
|
-
* @param options - Storage options
|
|
364
|
-
* @returns StorageFile instance with cached metadata
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
* ```typescript
|
|
368
|
-
* const file = await storage.putFromUrl(
|
|
369
|
-
* "https://example.com/image.jpg",
|
|
370
|
-
* "downloads/image.jpg"
|
|
371
|
-
* );
|
|
372
|
-
* ```
|
|
373
|
-
*/
|
|
374
|
-
async putFromUrl(url, location, options) {
|
|
375
|
-
const response = await fetch(url);
|
|
376
|
-
if (!response.ok) {
|
|
377
|
-
throw new Error(`Failed to fetch file from URL: ${response.statusText}`);
|
|
378
|
-
}
|
|
379
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
380
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
381
|
-
const mimeType = options?.mimeType || response.headers.get("content-type") || undefined;
|
|
382
|
-
return this.put(buffer, location, { ...options, mimeType });
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Store a file from base64 encoded string
|
|
386
|
-
*
|
|
387
|
-
* Decodes base64 content (with optional data URL prefix) and stores it.
|
|
388
|
-
*
|
|
389
|
-
* @param base64 - Base64 encoded file content (or data URL)
|
|
390
|
-
* @param location - Destination path
|
|
391
|
-
* @param options - Storage options
|
|
392
|
-
* @returns StorageFile instance with cached metadata
|
|
393
|
-
*
|
|
394
|
-
* @example
|
|
395
|
-
* ```typescript
|
|
396
|
-
* // From plain base64
|
|
397
|
-
* const file = await storage.putFromBase64(base64String, "images/photo.jpg");
|
|
398
|
-
*
|
|
399
|
-
* // From data URL (auto-extracts MIME type)
|
|
400
|
-
* const file = await storage.putFromBase64(
|
|
401
|
-
* "data:image/png;base64,iVBORw0KGgo...",
|
|
402
|
-
* "images/photo.png"
|
|
403
|
-
* );
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
async putFromBase64(base64, location, options) {
|
|
407
|
-
let data = base64;
|
|
408
|
-
let mimeType = options?.mimeType;
|
|
409
|
-
if (base64.startsWith("data:")) {
|
|
410
|
-
const match = base64.match(/^data:([^;]+);base64,(.+)$/);
|
|
411
|
-
if (match) {
|
|
412
|
-
mimeType = mimeType || match[1];
|
|
413
|
-
data = match[2];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
const buffer = Buffer.from(data, "base64");
|
|
417
|
-
return this.put(buffer, location, { ...options, mimeType });
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Retrieve file contents as Buffer
|
|
421
|
-
*
|
|
422
|
-
* Uses the current driver (with async resolution).
|
|
423
|
-
*
|
|
424
|
-
* @param location - File path
|
|
425
|
-
* @returns Buffer containing file contents
|
|
426
|
-
*/
|
|
427
|
-
async get(location) {
|
|
428
|
-
const driver = await this.currentDriver();
|
|
429
|
-
return driver.get(location);
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Get JSON content from a file
|
|
433
|
-
*
|
|
434
|
-
* Downloads and parses JSON file content.
|
|
435
|
-
*
|
|
436
|
-
* @param location - File path
|
|
437
|
-
* @returns Parsed JSON content
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```typescript
|
|
441
|
-
* const config = await storage.getJson("config/settings.json");
|
|
442
|
-
* console.log(config.apiKey);
|
|
443
|
-
* ```
|
|
444
|
-
*/
|
|
445
|
-
async getJson(location) {
|
|
446
|
-
const buffer = await this.get(location);
|
|
447
|
-
return JSON.parse(buffer.toString());
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Retrieve a file as a readable stream (for large files)
|
|
451
|
-
*
|
|
452
|
-
* @param location - File path
|
|
453
|
-
* @returns Readable stream of file contents
|
|
454
|
-
*/
|
|
455
|
-
async getStream(location) {
|
|
456
|
-
const driver = await this.currentDriver();
|
|
457
|
-
return driver.getStream(location);
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Delete a file
|
|
461
|
-
*
|
|
462
|
-
* Extends base `delete()` with event emission.
|
|
463
|
-
*
|
|
464
|
-
* @param location - File path or StorageFile
|
|
465
|
-
* @returns true if deleted, false if not found
|
|
466
|
-
*/
|
|
467
|
-
async delete(location) {
|
|
468
|
-
const driver = await this.currentDriver();
|
|
469
|
-
const path = typeof location === "string" ? location : location.path;
|
|
470
|
-
await this.emit("beforeDelete", {
|
|
471
|
-
driver: driver.name,
|
|
472
|
-
location: path,
|
|
473
|
-
timestamp: new Date(),
|
|
474
|
-
});
|
|
475
|
-
const result = await driver.delete(path);
|
|
476
|
-
await this.emit("afterDelete", {
|
|
477
|
-
driver: driver.name,
|
|
478
|
-
location: path,
|
|
479
|
-
timestamp: new Date(),
|
|
480
|
-
});
|
|
481
|
-
return result;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Delete multiple files at once
|
|
485
|
-
*
|
|
486
|
-
* @param locations - Array of file paths
|
|
487
|
-
* @returns Array of delete results with status for each file
|
|
488
|
-
*/
|
|
489
|
-
async deleteMany(locations) {
|
|
490
|
-
const driver = await this.currentDriver();
|
|
491
|
-
return driver.deleteMany(locations);
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Check if a file exists
|
|
495
|
-
*
|
|
496
|
-
* @param location - File path
|
|
497
|
-
* @returns true if file exists
|
|
498
|
-
*/
|
|
499
|
-
async exists(location) {
|
|
500
|
-
const driver = await this.currentDriver();
|
|
501
|
-
return driver.exists(location);
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Copy a file to a new location
|
|
505
|
-
*
|
|
506
|
-
* Extends base `copy()` with event emission.
|
|
507
|
-
*
|
|
508
|
-
* @param from - Source path or StorageFile
|
|
509
|
-
* @param to - Destination path
|
|
510
|
-
* @returns StorageFile instance at destination
|
|
511
|
-
*/
|
|
512
|
-
async copy(from, to) {
|
|
513
|
-
const driver = await this.currentDriver();
|
|
514
|
-
const fromPath = typeof from === "string" ? from : from.path;
|
|
515
|
-
await this.emit("beforeCopy", {
|
|
516
|
-
driver: driver.name,
|
|
517
|
-
location: to,
|
|
518
|
-
from: fromPath,
|
|
519
|
-
to,
|
|
520
|
-
timestamp: new Date(),
|
|
521
|
-
});
|
|
522
|
-
const result = await driver.copy(fromPath, to);
|
|
523
|
-
await this.emit("afterCopy", {
|
|
524
|
-
driver: driver.name,
|
|
525
|
-
location: to,
|
|
526
|
-
from: fromPath,
|
|
527
|
-
to,
|
|
528
|
-
timestamp: new Date(),
|
|
529
|
-
file: result,
|
|
530
|
-
});
|
|
531
|
-
return storageFile.StorageFile.fromData(result, driver);
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Move a file to a new location
|
|
535
|
-
*
|
|
536
|
-
* Extends base `move()` with event emission.
|
|
537
|
-
*
|
|
538
|
-
* @param from - Source path or StorageFile
|
|
539
|
-
* @param to - Destination path
|
|
540
|
-
* @returns StorageFile instance at destination
|
|
541
|
-
*/
|
|
542
|
-
async move(from, to) {
|
|
543
|
-
const driver = await this.currentDriver();
|
|
544
|
-
const fromPath = typeof from === "string" ? from : from.path;
|
|
545
|
-
await this.emit("beforeMove", {
|
|
546
|
-
driver: driver.name,
|
|
547
|
-
location: to,
|
|
548
|
-
from: fromPath,
|
|
549
|
-
to,
|
|
550
|
-
timestamp: new Date(),
|
|
551
|
-
});
|
|
552
|
-
const result = await driver.move(fromPath, to);
|
|
553
|
-
await this.emit("afterMove", {
|
|
554
|
-
driver: driver.name,
|
|
555
|
-
location: to,
|
|
556
|
-
from: fromPath,
|
|
557
|
-
to,
|
|
558
|
-
timestamp: new Date(),
|
|
559
|
-
file: result,
|
|
560
|
-
});
|
|
561
|
-
return storageFile.StorageFile.fromData(result, driver);
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* List files in a directory
|
|
565
|
-
*
|
|
566
|
-
* @param directory - Directory path (defaults to root)
|
|
567
|
-
* @param options - List options (recursive, limit, etc.)
|
|
568
|
-
* @returns Array of file information objects
|
|
569
|
-
*/
|
|
570
|
-
async list(directory, options) {
|
|
571
|
-
const driver = await this.currentDriver();
|
|
572
|
-
return driver.list(directory || "", options);
|
|
573
|
-
}
|
|
574
|
-
// ============================================================
|
|
575
|
-
// Metadata Operations
|
|
576
|
-
// ============================================================
|
|
577
|
-
/**
|
|
578
|
-
* Get file metadata without downloading
|
|
579
|
-
*
|
|
580
|
-
* @param location - File path
|
|
581
|
-
* @returns File information object
|
|
582
|
-
*/
|
|
583
|
-
async getInfo(location) {
|
|
584
|
-
const driver = await this.currentDriver();
|
|
585
|
-
return driver.getInfo(location);
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Get file size in bytes
|
|
589
|
-
*
|
|
590
|
-
* @param location - File path
|
|
591
|
-
* @returns File size in bytes
|
|
592
|
-
*/
|
|
593
|
-
async size(location) {
|
|
594
|
-
const driver = await this.currentDriver();
|
|
595
|
-
return driver.size(location);
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Get a StorageFile instance for OOP-style operations
|
|
599
|
-
*
|
|
600
|
-
* @param location - File path
|
|
601
|
-
* @returns StorageFile instance
|
|
602
|
-
*/
|
|
603
|
-
async file(location) {
|
|
604
|
-
const driver = await this.currentDriver();
|
|
605
|
-
return new storageFile.StorageFile(location, driver);
|
|
606
|
-
}
|
|
607
|
-
// ============================================================
|
|
608
|
-
// Path Operations (Local Driver Only)
|
|
609
|
-
// ============================================================
|
|
610
|
-
/**
|
|
611
|
-
* Get the absolute filesystem path for a location
|
|
612
|
-
*
|
|
613
|
-
* Only available for local driver.
|
|
614
|
-
*
|
|
615
|
-
* @param location - File path
|
|
616
|
-
* @throws Error if current driver is not a local driver
|
|
617
|
-
* @returns Absolute filesystem path
|
|
618
|
-
*/
|
|
619
|
-
async path(location) {
|
|
620
|
-
const driver = await this.currentDriver();
|
|
621
|
-
if (!("path" in driver) || typeof driver.path !== "function") {
|
|
622
|
-
throw new Error("path() is only available for local storage drivers");
|
|
623
|
-
}
|
|
624
|
-
return driver.path(location);
|
|
625
|
-
}
|
|
626
|
-
// ============================================================
|
|
627
|
-
// Cloud-Specific Operations
|
|
628
|
-
// ============================================================
|
|
629
|
-
/**
|
|
630
|
-
* Get a presigned URL for downloading a file
|
|
631
|
-
*
|
|
632
|
-
* Only available for cloud drivers.
|
|
633
|
-
*
|
|
634
|
-
* @param location - File path
|
|
635
|
-
* @param options - Presigned URL options (expiresIn)
|
|
636
|
-
* @throws Error if current driver is not a cloud driver
|
|
637
|
-
* @returns Presigned download URL
|
|
638
|
-
*
|
|
639
|
-
* @example
|
|
640
|
-
* ```typescript
|
|
641
|
-
* const url = await storage.getPresignedUrl("private/document.pdf", {
|
|
642
|
-
* expiresIn: 3600 // 1 hour
|
|
643
|
-
* });
|
|
644
|
-
* ```
|
|
645
|
-
*/
|
|
646
|
-
async getPresignedUrl(location, options) {
|
|
647
|
-
const driver = await this.currentDriver();
|
|
648
|
-
if (!this.isCloudDriver(driver)) {
|
|
649
|
-
throw new Error("Presigned URLs are only available for cloud storage drivers");
|
|
650
|
-
}
|
|
651
|
-
return driver.getPresignedUrl(location, options);
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Get a presigned URL for uploading a file directly to cloud storage
|
|
655
|
-
*
|
|
656
|
-
* Only available for cloud drivers.
|
|
657
|
-
*
|
|
658
|
-
* @param location - Destination path
|
|
659
|
-
* @param options - Upload options (expiresIn, contentType, maxSize)
|
|
660
|
-
* @throws Error if current driver is not a cloud driver
|
|
661
|
-
* @returns Presigned upload URL
|
|
662
|
-
*
|
|
663
|
-
* @example
|
|
664
|
-
* ```typescript
|
|
665
|
-
* const uploadUrl = await storage.getPresignedUploadUrl("uploads/file.pdf", {
|
|
666
|
-
* expiresIn: 3600,
|
|
667
|
-
* contentType: "application/pdf"
|
|
668
|
-
* });
|
|
669
|
-
*
|
|
670
|
-
* // Client can PUT directly to this URL
|
|
671
|
-
* ```
|
|
672
|
-
*/
|
|
673
|
-
async getPresignedUploadUrl(location, options) {
|
|
674
|
-
const driver = await this.currentDriver();
|
|
675
|
-
if (!this.isCloudDriver(driver)) {
|
|
676
|
-
throw new Error("Presigned upload URLs are only available for cloud storage drivers");
|
|
677
|
-
}
|
|
678
|
-
return driver.getPresignedUploadUrl(location, options);
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Get the bucket name for cloud storage
|
|
682
|
-
*
|
|
683
|
-
* Only available for cloud drivers.
|
|
684
|
-
*
|
|
685
|
-
* @throws Error if current driver is not a cloud driver
|
|
686
|
-
* @returns Bucket name
|
|
687
|
-
*/
|
|
688
|
-
async getBucket() {
|
|
689
|
-
const driver = await this.currentDriver();
|
|
690
|
-
if (!this.isCloudDriver(driver)) {
|
|
691
|
-
throw new Error("Bucket information is only available for cloud storage drivers");
|
|
692
|
-
}
|
|
693
|
-
return driver.getBucket();
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Get the region for cloud storage
|
|
697
|
-
*
|
|
698
|
-
* Only available for cloud drivers.
|
|
699
|
-
*
|
|
700
|
-
* @throws Error if current driver is not a cloud driver
|
|
701
|
-
* @returns Region name
|
|
702
|
-
*/
|
|
703
|
-
async getRegion() {
|
|
704
|
-
const driver = await this.currentDriver();
|
|
705
|
-
if (!this.isCloudDriver(driver)) {
|
|
706
|
-
throw new Error("Region information is only available for cloud storage drivers");
|
|
707
|
-
}
|
|
708
|
-
return driver.getRegion();
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Set storage class for a file (e.g., STANDARD, GLACIER, etc.)
|
|
712
|
-
*
|
|
713
|
-
* Only available for cloud drivers.
|
|
714
|
-
*
|
|
715
|
-
* @param location - File path
|
|
716
|
-
* @param storageClass - Target storage class
|
|
717
|
-
* @throws Error if current driver is not a cloud driver
|
|
718
|
-
*/
|
|
719
|
-
async setStorageClass(location, storageClass) {
|
|
720
|
-
const driver = await this.currentDriver();
|
|
721
|
-
if (!this.isCloudDriver(driver)) {
|
|
722
|
-
throw new Error("Storage class is only available for cloud storage drivers");
|
|
723
|
-
}
|
|
724
|
-
return driver.setStorageClass(location, storageClass);
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Set file visibility (public or private)
|
|
728
|
-
*
|
|
729
|
-
* Only available for cloud drivers.
|
|
730
|
-
*
|
|
731
|
-
* @param location - File path
|
|
732
|
-
* @param visibility - "public" or "private"
|
|
733
|
-
* @throws Error if current driver is not a cloud driver
|
|
734
|
-
*/
|
|
735
|
-
async setVisibility(location, visibility) {
|
|
736
|
-
const driver = await this.currentDriver();
|
|
737
|
-
if (!this.isCloudDriver(driver)) {
|
|
738
|
-
throw new Error("Visibility is only available for cloud storage drivers");
|
|
739
|
-
}
|
|
740
|
-
return driver.setVisibility(location, visibility);
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Get file visibility
|
|
744
|
-
*
|
|
745
|
-
* Only available for cloud drivers.
|
|
746
|
-
*
|
|
747
|
-
* @param location - File path
|
|
748
|
-
* @throws Error if current driver is not a cloud driver
|
|
749
|
-
* @returns Current visibility setting
|
|
750
|
-
*/
|
|
751
|
-
async getVisibility(location) {
|
|
752
|
-
const driver = await this.currentDriver();
|
|
753
|
-
if (!this.isCloudDriver(driver)) {
|
|
754
|
-
throw new Error("Visibility is only available for cloud storage drivers");
|
|
755
|
-
}
|
|
756
|
-
return driver.getVisibility(location);
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Get a temporary signed URL
|
|
760
|
-
*
|
|
761
|
-
* Creates a URL that provides temporary access to the file.
|
|
762
|
-
*
|
|
763
|
-
* @param location - File path
|
|
764
|
-
* @param expiresIn - Seconds until expiration (default: 3600)
|
|
765
|
-
* @returns Signed URL string
|
|
766
|
-
*/
|
|
767
|
-
async temporaryUrl(location, expiresIn) {
|
|
768
|
-
const driver = await this.currentDriver();
|
|
769
|
-
return driver.temporaryUrl(location, expiresIn);
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Validate a temporary URL token
|
|
773
|
-
*
|
|
774
|
-
* For local driver: validates HMAC-signed tokens
|
|
775
|
-
* For cloud drivers: returns invalid (cloud validates via presigned URL)
|
|
776
|
-
*
|
|
777
|
-
* @param token - The token from the temporary URL
|
|
778
|
-
* @returns Validation result with file info and convenience methods
|
|
779
|
-
*
|
|
780
|
-
* @example
|
|
781
|
-
* ```typescript
|
|
782
|
-
* const result = await storage.validateTemporaryToken(token);
|
|
783
|
-
*
|
|
784
|
-
* if (!result.valid) {
|
|
785
|
-
* return response.status(403).send(result.error);
|
|
786
|
-
* }
|
|
787
|
-
*
|
|
788
|
-
* // For local driver - use sendFile for efficiency
|
|
789
|
-
* if (result.absolutePath) {
|
|
790
|
-
* return response.sendFile(result.absolutePath);
|
|
791
|
-
* }
|
|
792
|
-
*
|
|
793
|
-
* // For cloud driver - stream the file
|
|
794
|
-
* const stream = await result.getStream!();
|
|
795
|
-
* stream.pipe(response.raw);
|
|
796
|
-
* ```
|
|
797
|
-
*/
|
|
798
|
-
async validateTemporaryToken(token) {
|
|
799
|
-
const driver = await this.currentDriver();
|
|
800
|
-
// Check if driver supports token validation
|
|
801
|
-
if (!("validateTemporaryToken" in driver) ||
|
|
802
|
-
typeof driver.validateTemporaryToken !== "function") {
|
|
803
|
-
// For cloud drivers, temporary URLs are presigned and validated by the cloud provider
|
|
804
|
-
return {
|
|
805
|
-
valid: false,
|
|
806
|
-
error: "invalid_token",
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
return driver.validateTemporaryToken(token);
|
|
810
|
-
}
|
|
811
|
-
// ============================================================
|
|
812
|
-
// Configuration Parsing
|
|
813
|
-
// ============================================================
|
|
814
|
-
/**
|
|
815
|
-
* Parse config into driver-specific options
|
|
816
|
-
* @internal
|
|
817
|
-
*/
|
|
818
|
-
parseOptions(config) {
|
|
819
|
-
const { driver, ...options } = config;
|
|
820
|
-
switch (driver) {
|
|
821
|
-
case "local":
|
|
822
|
-
return {
|
|
823
|
-
root: options.root,
|
|
824
|
-
urlPrefix: options.urlPrefix,
|
|
825
|
-
signatureKey: options.signatureKey,
|
|
826
|
-
};
|
|
827
|
-
case "s3":
|
|
828
|
-
this.validateCloudConfig(config, "s3");
|
|
829
|
-
return {
|
|
830
|
-
bucket: options.bucket,
|
|
831
|
-
region: options.region,
|
|
832
|
-
accessKeyId: options.accessKeyId,
|
|
833
|
-
secretAccessKey: options.secretAccessKey,
|
|
834
|
-
endpoint: options.endpoint,
|
|
835
|
-
urlPrefix: options.urlPrefix,
|
|
836
|
-
};
|
|
837
|
-
case "r2":
|
|
838
|
-
this.validateCloudConfig(config, "r2");
|
|
839
|
-
if (!options.accountId) {
|
|
840
|
-
throw new Error('R2 driver requires "accountId" configuration');
|
|
841
|
-
}
|
|
842
|
-
return {
|
|
843
|
-
bucket: options.bucket,
|
|
844
|
-
region: options.region || "auto",
|
|
845
|
-
accessKeyId: options.accessKeyId,
|
|
846
|
-
secretAccessKey: options.secretAccessKey,
|
|
847
|
-
endpoint: options.endpoint,
|
|
848
|
-
urlPrefix: options.urlPrefix,
|
|
849
|
-
accountId: options.accountId,
|
|
850
|
-
publicDomain: options.publicDomain,
|
|
851
|
-
};
|
|
852
|
-
case "spaces":
|
|
853
|
-
this.validateCloudConfig(config, "spaces");
|
|
854
|
-
return {
|
|
855
|
-
bucket: options.bucket,
|
|
856
|
-
region: options.region,
|
|
857
|
-
accessKeyId: options.accessKeyId,
|
|
858
|
-
secretAccessKey: options.secretAccessKey,
|
|
859
|
-
endpoint: options.endpoint,
|
|
860
|
-
urlPrefix: options.urlPrefix,
|
|
861
|
-
};
|
|
862
|
-
default:
|
|
863
|
-
throw new Error(`Unknown driver type: ${driver}`);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Validate cloud driver configuration has required fields
|
|
868
|
-
* @internal
|
|
869
|
-
*/
|
|
870
|
-
validateCloudConfig(config, driverName) {
|
|
871
|
-
const required = ["bucket", "accessKeyId", "secretAccessKey"];
|
|
872
|
-
if (driverName !== "r2") {
|
|
873
|
-
required.push("region");
|
|
874
|
-
}
|
|
875
|
-
for (const field of required) {
|
|
876
|
-
if (!config[field]) {
|
|
877
|
-
throw new Error(`${driverName.toUpperCase()} driver requires "${field}" configuration`);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
/**
|
|
882
|
-
* Get or create driver instance from cache
|
|
883
|
-
* @internal
|
|
884
|
-
*/
|
|
885
|
-
resolveDriver(name) {
|
|
886
|
-
// Ensure configs are loaded
|
|
887
|
-
this.ensureInitialized();
|
|
888
|
-
if (this.drivers.has(name)) {
|
|
889
|
-
return this.drivers.get(name);
|
|
890
|
-
}
|
|
891
|
-
const config = this.configs.get(name);
|
|
892
|
-
if (!config) {
|
|
893
|
-
throw new Error(`Storage driver "${name}" is not configured`);
|
|
894
|
-
}
|
|
895
|
-
const options = this.parseOptions(config);
|
|
896
|
-
let driver;
|
|
897
|
-
switch (config.driver) {
|
|
898
|
-
case "local":
|
|
899
|
-
driver = new localDriver.LocalDriver(options);
|
|
900
|
-
break;
|
|
901
|
-
case "s3":
|
|
902
|
-
driver = new s3Driver.S3Driver(options);
|
|
903
|
-
break;
|
|
904
|
-
case "r2":
|
|
905
|
-
driver = new r2Driver.R2Driver(options);
|
|
906
|
-
break;
|
|
907
|
-
case "spaces":
|
|
908
|
-
driver = new doSpacesDriver.DOSpacesDriver(options);
|
|
909
|
-
break;
|
|
910
|
-
default:
|
|
911
|
-
throw new Error(`Unknown storage driver type: ${config.driver}`);
|
|
912
|
-
}
|
|
913
|
-
this.drivers.set(name, driver);
|
|
914
|
-
return driver;
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* Resolve the default driver name (supports async resolver for multi-tenancy)
|
|
918
|
-
* @internal
|
|
919
|
-
*/
|
|
920
|
-
async resolveDefaultDriver() {
|
|
921
|
-
const resolver = config.storageConfig("resolver");
|
|
922
|
-
if (resolver) {
|
|
923
|
-
const resolved = await resolver();
|
|
924
|
-
return resolved || this.defaultDriverName;
|
|
925
|
-
}
|
|
926
|
-
return this.defaultDriverName;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Singleton storage instance
|
|
931
|
-
*
|
|
932
|
-
* Pre-configured storage manager ready for use throughout the application.
|
|
933
|
-
*
|
|
934
|
-
* @example
|
|
935
|
-
* ```typescript
|
|
936
|
-
* import { storage } from "@warlock.js/core";
|
|
937
|
-
*
|
|
938
|
-
* const file = await storage.put(buffer, "uploads/file.txt");
|
|
939
|
-
* ```
|
|
940
|
-
*/
|
|
941
|
-
const storage = new Storage();exports.Storage=Storage;exports.storage=storage;//# sourceMappingURL=storage.js.map
|