@cyberskill/shared 2.28.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/commitlint/index.js +1 -0
- package/dist/config/commitlint/index.js.map +1 -0
- package/dist/config/config.test.unit.d.ts +1 -0
- package/dist/config/config.type.js +1 -0
- package/dist/config/config.type.js.map +1 -0
- package/dist/config/config.type.test.unit.d.ts +1 -0
- package/dist/config/config.util.js +25 -33
- package/dist/config/config.util.js.map +1 -0
- package/dist/config/env/env.constant.js +1 -0
- package/dist/config/env/env.constant.js.map +1 -0
- package/dist/config/env/env.util.js +1 -0
- package/dist/config/env/env.util.js.map +1 -0
- package/dist/config/env/index.js +1 -0
- package/dist/config/env/index.js.map +1 -0
- package/dist/config/eslint/index.d.ts +4 -0
- package/dist/config/eslint/index.js +5 -12
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +29 -33
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
- package/dist/config/graphql-codegen/index.js +1 -0
- package/dist/config/graphql-codegen/index.js.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/lint-staged/index.js +1 -0
- package/dist/config/lint-staged/index.js.map +1 -0
- package/dist/config/storybook/index.js +1 -0
- package/dist/config/storybook/index.js.map +1 -0
- package/dist/config/storybook/storybook.main.js +1 -0
- package/dist/config/storybook/storybook.main.js.map +1 -0
- package/dist/config/storybook/storybook.preview.js +11 -13
- package/dist/config/storybook/storybook.preview.js.map +1 -0
- package/dist/config/vitest/index.js +1 -0
- package/dist/config/vitest/index.js.map +1 -0
- package/dist/config/vitest/vitest.e2e.js +2 -1
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.js +20 -8
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +2 -1
- package/dist/constant/common.js.map +1 -0
- package/dist/constant/constant.test.unit.d.ts +1 -0
- package/dist/constant/index.js +1 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/response-status.js +1 -0
- package/dist/constant/response-status.js.map +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +22 -48
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
- package/dist/node/apollo-server/index.js +1 -0
- package/dist/node/apollo-server/index.js.map +1 -0
- package/dist/node/cli/index.js +110 -165
- package/dist/node/cli/index.js.map +1 -0
- package/dist/node/command/command.test.unit.d.ts +1 -0
- package/dist/node/command/command.type.js +1 -0
- package/dist/node/command/command.type.js.map +1 -0
- package/dist/node/command/command.util.js +142 -169
- package/dist/node/command/command.util.js.map +1 -0
- package/dist/node/command/index.js +1 -0
- package/dist/node/command/index.js.map +1 -0
- package/dist/node/express/express.type.d.ts +4 -0
- package/dist/node/express/express.util.js +56 -71
- package/dist/node/express/express.util.js.map +1 -0
- package/dist/node/express/index.js +1 -0
- package/dist/node/express/index.js.map +1 -0
- package/dist/node/fs/fs.test.unit.d.ts +1 -0
- package/dist/node/fs/fs.util.js +46 -60
- package/dist/node/fs/fs.util.js.map +1 -0
- package/dist/node/fs/index.js +1 -0
- package/dist/node/fs/index.js.map +1 -0
- package/dist/node/log/index.js +1 -0
- package/dist/node/log/index.js.map +1 -0
- package/dist/node/log/log.test.unit.d.ts +1 -0
- package/dist/node/log/log.type.js +1 -0
- package/dist/node/log/log.type.js.map +1 -0
- package/dist/node/log/log.util.js +30 -30
- package/dist/node/log/log.util.js.map +1 -0
- package/dist/node/mongo/index.d.ts +2 -0
- package/dist/node/mongo/index.js +21 -12
- package/dist/node/mongo/index.js.map +1 -0
- package/dist/node/mongo/mongo.constant.js +1 -0
- package/dist/node/mongo/mongo.constant.js.map +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +5 -315
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
- package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
- package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
- package/dist/node/mongo/mongo.controller.native.js +214 -0
- package/dist/node/mongo/mongo.controller.native.js.map +1 -0
- package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
- package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
- package/dist/node/mongo/mongo.populate.d.ts +15 -0
- package/dist/node/mongo/mongo.populate.js +269 -0
- package/dist/node/mongo/mongo.populate.js.map +1 -0
- package/dist/node/mongo/mongo.type.js +1 -0
- package/dist/node/mongo/mongo.type.js.map +1 -0
- package/dist/node/mongo/mongo.util.d.ts +52 -0
- package/dist/node/mongo/mongo.util.js +111 -409
- package/dist/node/mongo/mongo.util.js.map +1 -0
- package/dist/node/package/index.js +1 -0
- package/dist/node/package/index.js.map +1 -0
- package/dist/node/package/package.test.unit.d.ts +1 -0
- package/dist/node/package/package.type.js +1 -0
- package/dist/node/package/package.type.js.map +1 -0
- package/dist/node/package/package.util.js +197 -226
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +27 -25
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.d.ts +2 -0
- package/dist/node/path/path.constant.js +131 -150
- package/dist/node/path/path.constant.js.map +1 -0
- package/dist/node/path/path.util.js +1 -0
- package/dist/node/path/path.util.js.map +1 -0
- package/dist/node/storage/index.js +1 -0
- package/dist/node/storage/index.js.map +1 -0
- package/dist/node/storage/storage.constant.js +1 -0
- package/dist/node/storage/storage.constant.js.map +1 -0
- package/dist/node/storage/storage.util.js +111 -158
- package/dist/node/storage/storage.util.js.map +1 -0
- package/dist/node/upload/index.js +1 -0
- package/dist/node/upload/index.js.map +1 -0
- package/dist/node/upload/upload.constant.js +1 -0
- package/dist/node/upload/upload.constant.js.map +1 -0
- package/dist/node/upload/upload.type.js +1 -0
- package/dist/node/upload/upload.type.js.map +1 -0
- package/dist/node/upload/upload.util.js +120 -150
- package/dist/node/upload/upload.util.js.map +1 -0
- package/dist/node/ws/index.d.ts +1 -1
- package/dist/node/ws/index.js +2 -1
- package/dist/node/ws/index.js.map +1 -0
- package/dist/node/ws/ws.util.js +46 -0
- package/dist/node/ws/ws.util.js.map +1 -0
- package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +1 -0
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +5 -4
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.context.js +1 -0
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.util.js +52 -58
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
- package/dist/react/apollo-client/index.js +1 -0
- package/dist/react/apollo-client/index.js.map +1 -0
- package/dist/react/apollo-client/links/index.js +1 -0
- package/dist/react/apollo-client/links/index.js.map +1 -0
- package/dist/react/apollo-client/links/upload.js +72 -74
- package/dist/react/apollo-client/links/upload.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +12 -18
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
- package/dist/react/apollo-client-nextjs/index.js +1 -0
- package/dist/react/apollo-client-nextjs/index.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.component.js +62 -23
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.context.js +1 -0
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js +7 -6
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
- package/dist/react/apollo-error/apollo-error.util.js +7 -6
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
- package/dist/react/apollo-error/index.js +1 -0
- package/dist/react/apollo-error/index.js.map +1 -0
- package/dist/react/i18next/i18next.hook.js +1 -0
- package/dist/react/i18next/i18next.hook.js.map +1 -0
- package/dist/react/i18next/i18next.util.js +1 -0
- package/dist/react/i18next/i18next.util.js.map +1 -0
- package/dist/react/i18next/index.js +1 -0
- package/dist/react/i18next/index.js.map +1 -0
- package/dist/react/loading/index.js +1 -0
- package/dist/react/loading/index.js.map +1 -0
- package/dist/react/loading/loading.component.js +31 -46
- package/dist/react/loading/loading.component.js.map +1 -0
- package/dist/react/loading/loading.context.js +1 -0
- package/dist/react/loading/loading.context.js.map +1 -0
- package/dist/react/loading/loading.hook.js +1 -0
- package/dist/react/loading/loading.hook.js.map +1 -0
- package/dist/react/loading/loading.module.scss.js +1 -0
- package/dist/react/loading/loading.module.scss.js.map +1 -0
- package/dist/react/loading/loading.provider.js +1 -0
- package/dist/react/loading/loading.provider.js.map +1 -0
- package/dist/react/log/index.js +1 -0
- package/dist/react/log/index.js.map +1 -0
- package/dist/react/log/log.util.js +5 -4
- package/dist/react/log/log.util.js.map +1 -0
- package/dist/react/next-intl/index.js +1 -0
- package/dist/react/next-intl/index.js.map +1 -0
- package/dist/react/next-intl/next-intl.constant.js +1 -0
- package/dist/react/next-intl/next-intl.constant.js.map +1 -0
- package/dist/react/next-intl/next-intl.context.js +1 -0
- package/dist/react/next-intl/next-intl.context.js.map +1 -0
- package/dist/react/next-intl/next-intl.hoc.js +14 -22
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
- package/dist/react/next-intl/next-intl.hook.js +1 -0
- package/dist/react/next-intl/next-intl.hook.js.map +1 -0
- package/dist/react/next-intl/next-intl.provider.js +8 -7
- package/dist/react/next-intl/next-intl.provider.js.map +1 -0
- package/dist/react/storage/index.js +1 -0
- package/dist/react/storage/index.js.map +1 -0
- package/dist/react/storage/storage.hook.js +44 -59
- package/dist/react/storage/storage.hook.js.map +1 -0
- package/dist/react/storage/storage.test.unit.d.ts +1 -0
- package/dist/react/storage/storage.util.js +29 -53
- package/dist/react/storage/storage.util.js.map +1 -0
- package/dist/react/toast/index.js +1 -0
- package/dist/react/toast/index.js.map +1 -0
- package/dist/react/userback/index.js +1 -0
- package/dist/react/userback/index.js.map +1 -0
- package/dist/react/userback/userback.component.js +19 -42
- package/dist/react/userback/userback.component.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/typescript/common.type.js +1 -0
- package/dist/typescript/common.type.js.map +1 -0
- package/dist/typescript/index.js +1 -0
- package/dist/typescript/index.js.map +1 -0
- package/dist/typescript/typescript.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.d.ts +2 -0
- package/dist/util/common/common.util.js +30 -37
- package/dist/util/common/common.util.js.map +1 -0
- package/dist/util/common/index.js +1 -0
- package/dist/util/common/index.js.map +1 -0
- package/dist/util/index.js +11 -9
- package/dist/util/index.js.map +1 -0
- package/dist/util/object/index.js +1 -0
- package/dist/util/object/index.js.map +1 -0
- package/dist/util/object/object.util.js +73 -76
- package/dist/util/object/object.util.js.map +1 -0
- package/dist/util/serializer/index.js +1 -0
- package/dist/util/serializer/index.js.map +1 -0
- package/dist/util/serializer/serializer.util.js +1 -0
- package/dist/util/serializer/serializer.util.js.map +1 -0
- package/dist/util/string/index.js +5 -3
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.d.ts +12 -0
- package/dist/util/string/string.util.js +64 -44
- package/dist/util/string/string.util.js.map +1 -0
- package/dist/util/validate/index.js +1 -0
- package/dist/util/validate/index.js.map +1 -0
- package/dist/util/validate/validate.util.js +1 -0
- package/dist/util/validate/validate.util.js.map +1 -0
- package/package.json +76 -96
- package/public/tsconfig.base.json +7 -3
- package/README.md +0 -470
- package/dist/config/commitlint/index.cjs +0 -1
- package/dist/config/config.type.cjs +0 -1
- package/dist/config/config.util.cjs +0 -1
- package/dist/config/env/env.constant.cjs +0 -1
- package/dist/config/env/env.util.cjs +0 -1
- package/dist/config/env/index.cjs +0 -1
- package/dist/config/eslint/index.cjs +0 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
- package/dist/config/graphql-codegen/index.cjs +0 -1
- package/dist/config/index.cjs +0 -1
- package/dist/config/lint-staged/index.cjs +0 -1
- package/dist/config/storybook/index.cjs +0 -1
- package/dist/config/storybook/storybook.main.cjs +0 -1
- package/dist/config/storybook/storybook.preview.cjs +0 -1
- package/dist/config/vitest/index.cjs +0 -1
- package/dist/config/vitest/vitest.e2e.cjs +0 -1
- package/dist/config/vitest/vitest.unit.cjs +0 -1
- package/dist/constant/common.cjs +0 -1
- package/dist/constant/index.cjs +0 -1
- package/dist/constant/response-status.cjs +0 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
- package/dist/node/apollo-server/index.cjs +0 -1
- package/dist/node/cli/index.cjs +0 -3
- package/dist/node/command/command.type.cjs +0 -1
- package/dist/node/command/command.util.cjs +0 -2
- package/dist/node/command/index.cjs +0 -1
- package/dist/node/express/express.util.cjs +0 -1
- package/dist/node/express/index.cjs +0 -1
- package/dist/node/fs/fs.util.cjs +0 -4
- package/dist/node/fs/index.cjs +0 -1
- package/dist/node/log/index.cjs +0 -1
- package/dist/node/log/log.type.cjs +0 -1
- package/dist/node/log/log.util.cjs +0 -1
- package/dist/node/mongo/index.cjs +0 -1
- package/dist/node/mongo/mongo.constant.cjs +0 -1
- package/dist/node/mongo/mongo.controller.cjs +0 -1
- package/dist/node/mongo/mongo.controller.js +0 -956
- package/dist/node/mongo/mongo.type.cjs +0 -1
- package/dist/node/mongo/mongo.util.cjs +0 -2
- package/dist/node/package/index.cjs +0 -1
- package/dist/node/package/package.type.cjs +0 -1
- package/dist/node/package/package.util.cjs +0 -1
- package/dist/node/path/index.cjs +0 -1
- package/dist/node/path/path.constant.cjs +0 -1
- package/dist/node/path/path.util.cjs +0 -1
- package/dist/node/storage/index.cjs +0 -1
- package/dist/node/storage/storage.constant.cjs +0 -1
- package/dist/node/storage/storage.util.cjs +0 -1
- package/dist/node/upload/index.cjs +0 -1
- package/dist/node/upload/upload.constant.cjs +0 -1
- package/dist/node/upload/upload.type.cjs +0 -1
- package/dist/node/upload/upload.util.cjs +0 -1
- package/dist/node/ws/index.cjs +0 -1
- package/dist/node/ws/ts.util.cjs +0 -1
- package/dist/node/ws/ts.util.js +0 -68
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
- package/dist/react/apollo-client/index.cjs +0 -1
- package/dist/react/apollo-client/links/index.cjs +0 -1
- package/dist/react/apollo-client/links/upload.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
- package/dist/react/apollo-client-nextjs/index.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
- package/dist/react/apollo-error/index.cjs +0 -1
- package/dist/react/i18next/i18next.hook.cjs +0 -1
- package/dist/react/i18next/i18next.util.cjs +0 -1
- package/dist/react/i18next/index.cjs +0 -1
- package/dist/react/loading/index.cjs +0 -1
- package/dist/react/loading/loading.component.cjs +0 -6
- package/dist/react/loading/loading.context.cjs +0 -1
- package/dist/react/loading/loading.hook.cjs +0 -1
- package/dist/react/loading/loading.module.scss.cjs +0 -1
- package/dist/react/loading/loading.provider.cjs +0 -1
- package/dist/react/log/index.cjs +0 -1
- package/dist/react/log/log.util.cjs +0 -1
- package/dist/react/next-intl/index.cjs +0 -1
- package/dist/react/next-intl/next-intl.constant.cjs +0 -1
- package/dist/react/next-intl/next-intl.context.cjs +0 -1
- package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
- package/dist/react/next-intl/next-intl.hook.cjs +0 -1
- package/dist/react/next-intl/next-intl.provider.cjs +0 -1
- package/dist/react/storage/index.cjs +0 -1
- package/dist/react/storage/storage.hook.cjs +0 -1
- package/dist/react/storage/storage.util.cjs +0 -1
- package/dist/react/toast/index.cjs +0 -1
- package/dist/react/userback/index.cjs +0 -1
- package/dist/react/userback/userback.component.cjs +0 -1
- package/dist/typescript/common.type.cjs +0 -1
- package/dist/typescript/index.cjs +0 -1
- package/dist/util/common/common.util.cjs +0 -1
- package/dist/util/common/index.cjs +0 -1
- package/dist/util/index.cjs +0 -1
- package/dist/util/object/index.cjs +0 -1
- package/dist/util/object/object.util.cjs +0 -1
- package/dist/util/serializer/index.cjs +0 -1
- package/dist/util/serializer/serializer.util.cjs +0 -1
- package/dist/util/string/index.cjs +0 -1
- package/dist/util/string/string.util.cjs +0 -1
- package/dist/util/validate/index.cjs +0 -1
- package/dist/util/validate/validate.util.cjs +0 -1
- /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
|
@@ -1,143 +1,106 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { STORAGE_KEY_EXTENSION as
|
|
5
|
-
import { catchError as s, log as
|
|
6
|
-
import { getEnv as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
m(t.next(u));
|
|
11
|
-
} catch (v) {
|
|
12
|
-
d(v);
|
|
13
|
-
}
|
|
14
|
-
}, O = (u) => {
|
|
15
|
-
try {
|
|
16
|
-
m(t.throw(u));
|
|
17
|
-
} catch (v) {
|
|
18
|
-
d(v);
|
|
19
|
-
}
|
|
20
|
-
}, m = (u) => u.done ? i(u.value) : Promise.resolve(u.value).then(y, O);
|
|
21
|
-
m((t = t.apply(e, r)).next());
|
|
22
|
-
});
|
|
23
|
-
const h = N(), o = {
|
|
24
|
-
baseDir: h.CYBERSKILL_STORAGE_DIRECTORY
|
|
1
|
+
import w from "localforage";
|
|
2
|
+
import i from "node:fs/promises";
|
|
3
|
+
import E from "node:path";
|
|
4
|
+
import { STORAGE_KEY_EXTENSION as d, NODE_FS_DRIVER_NAME as v, STORAGE_STORE_NAME as R, STORAGE_INSTANCE_NAME as I } from "./storage.constant.js";
|
|
5
|
+
import { catchError as s, log as h } from "../log/log.util.js";
|
|
6
|
+
import { getEnv as S } from "../../config/env/env.util.js";
|
|
7
|
+
const l = S(), a = {
|
|
8
|
+
baseDir: l.CYBERSKILL_STORAGE_DIRECTORY
|
|
25
9
|
};
|
|
26
|
-
function
|
|
27
|
-
return `${encodeURIComponent(
|
|
10
|
+
function g(r) {
|
|
11
|
+
return `${encodeURIComponent(r)}${d}`;
|
|
28
12
|
}
|
|
29
|
-
function
|
|
30
|
-
return decodeURIComponent(
|
|
13
|
+
function _(r) {
|
|
14
|
+
return decodeURIComponent(r.slice(0, -d.length));
|
|
31
15
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
16
|
+
function y(r, e) {
|
|
17
|
+
return E.join(e, g(r));
|
|
34
18
|
}
|
|
35
|
-
const
|
|
36
|
-
_driver:
|
|
19
|
+
const c = {
|
|
20
|
+
_driver: v,
|
|
37
21
|
_support: !0,
|
|
38
22
|
/** Ensures the storage directory exists and respects custom baseDir overrides. */
|
|
39
|
-
_initStorage(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
23
|
+
async _initStorage(r) {
|
|
24
|
+
try {
|
|
25
|
+
const e = typeof r == "object" && r !== null && "baseDir" in r ? r.baseDir : void 0;
|
|
26
|
+
typeof e == "string" && e.length > 0 ? a.baseDir = e : a.baseDir = l.CYBERSKILL_STORAGE_DIRECTORY, await i.mkdir(a.baseDir, { recursive: !0 });
|
|
27
|
+
} catch (e) {
|
|
28
|
+
throw h.error("[Storage:init]", e), e;
|
|
29
|
+
}
|
|
48
30
|
},
|
|
49
31
|
/** Deletes all stored entries by recreating the directory. */
|
|
50
|
-
clear() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
yield l.rm(e, { recursive: !0, force: !0 }), yield l.mkdir(e, { recursive: !0 });
|
|
54
|
-
});
|
|
32
|
+
async clear() {
|
|
33
|
+
const { baseDir: r } = a;
|
|
34
|
+
await i.rm(r, { recursive: !0, force: !0 }), await i.mkdir(r, { recursive: !0 });
|
|
55
35
|
},
|
|
56
36
|
/** Reads and parses a stored value; returns null when the file is missing. */
|
|
57
|
-
getItem(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
});
|
|
37
|
+
async getItem(r) {
|
|
38
|
+
const { baseDir: e } = a, t = y(r, e);
|
|
39
|
+
try {
|
|
40
|
+
const n = await i.readFile(t, "utf8");
|
|
41
|
+
return JSON.parse(n);
|
|
42
|
+
} catch (n) {
|
|
43
|
+
if (n.code === "ENOENT")
|
|
44
|
+
return null;
|
|
45
|
+
throw n;
|
|
46
|
+
}
|
|
69
47
|
},
|
|
70
48
|
/** Iterates through all keys, invoking the iterator until it returns a value. */
|
|
71
|
-
iterate(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
});
|
|
49
|
+
async iterate(r) {
|
|
50
|
+
const e = await c.keys();
|
|
51
|
+
let t = 1;
|
|
52
|
+
for (const n of e) {
|
|
53
|
+
const D = await c.getItem(n), f = r(D, n, t);
|
|
54
|
+
if (f !== void 0)
|
|
55
|
+
return f;
|
|
56
|
+
t += 1;
|
|
57
|
+
}
|
|
82
58
|
},
|
|
83
59
|
/** Returns the key name at the given index or null when out of bounds. */
|
|
84
|
-
key(
|
|
85
|
-
return
|
|
86
|
-
var r;
|
|
87
|
-
return (r = (yield a.keys())[e]) != null ? r : null;
|
|
88
|
-
});
|
|
60
|
+
async key(r) {
|
|
61
|
+
return (await c.keys())[r] ?? null;
|
|
89
62
|
},
|
|
90
63
|
/** Lists all stored keys. */
|
|
91
|
-
keys() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
});
|
|
64
|
+
async keys() {
|
|
65
|
+
const { baseDir: r } = a;
|
|
66
|
+
try {
|
|
67
|
+
return (await i.readdir(r)).filter((t) => t.endsWith(d)).map(_);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
if (e.code === "ENOENT")
|
|
70
|
+
return [];
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
102
73
|
},
|
|
103
74
|
/** Returns the count of stored keys. */
|
|
104
|
-
length() {
|
|
105
|
-
return
|
|
106
|
-
return (yield a.keys()).length;
|
|
107
|
-
});
|
|
75
|
+
async length() {
|
|
76
|
+
return (await c.keys()).length;
|
|
108
77
|
},
|
|
109
78
|
/** Removes a stored value for the given key. */
|
|
110
|
-
removeItem(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
yield l.rm(t, { force: !0 });
|
|
114
|
-
});
|
|
79
|
+
async removeItem(r) {
|
|
80
|
+
const { baseDir: e } = a, t = y(r, e);
|
|
81
|
+
await i.rm(t, { force: !0 });
|
|
115
82
|
},
|
|
116
83
|
/** Stores a value as JSON on disk. */
|
|
117
|
-
setItem(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return yield l.mkdir(t, { recursive: !0 }), yield l.writeFile(i, JSON.stringify(r), "utf8"), r;
|
|
121
|
-
});
|
|
84
|
+
async setItem(r, e) {
|
|
85
|
+
const { baseDir: t } = a, n = y(r, t);
|
|
86
|
+
return await i.mkdir(t, { recursive: !0 }), await i.writeFile(n, JSON.stringify(e), "utf8"), e;
|
|
122
87
|
}
|
|
123
88
|
};
|
|
124
|
-
let
|
|
125
|
-
function
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}), yield c, D);
|
|
138
|
-
});
|
|
89
|
+
let o = null, m = null;
|
|
90
|
+
async function u() {
|
|
91
|
+
return o ? (await o, m) : (o = (async () => {
|
|
92
|
+
await w.defineDriver(c), a.baseDir = l.CYBERSKILL_STORAGE_DIRECTORY;
|
|
93
|
+
const r = await w.getDriver(v), e = {
|
|
94
|
+
baseDir: a.baseDir,
|
|
95
|
+
name: I,
|
|
96
|
+
storeName: R
|
|
97
|
+
};
|
|
98
|
+
await r._initStorage(e), m = r;
|
|
99
|
+
})().catch((r) => {
|
|
100
|
+
throw o = null, r;
|
|
101
|
+
}), await o, m);
|
|
139
102
|
}
|
|
140
|
-
const
|
|
103
|
+
const A = {
|
|
141
104
|
/**
|
|
142
105
|
* Retrieves a value from persistent storage by key.
|
|
143
106
|
* This method fetches data that was previously stored using the set method.
|
|
@@ -146,15 +109,12 @@ const w = {
|
|
|
146
109
|
* @param key - The unique identifier for the stored value.
|
|
147
110
|
* @returns A promise that resolves to the stored value or null if not found.
|
|
148
111
|
*/
|
|
149
|
-
get(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return s(r, { returnValue: null });
|
|
156
|
-
}
|
|
157
|
-
});
|
|
112
|
+
async get(r) {
|
|
113
|
+
try {
|
|
114
|
+
return await (await u()).getItem(r) ?? null;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return s(e, { returnValue: null });
|
|
117
|
+
}
|
|
158
118
|
},
|
|
159
119
|
/**
|
|
160
120
|
* Stores a value in persistent storage with a unique key.
|
|
@@ -165,14 +125,12 @@ const w = {
|
|
|
165
125
|
* @param value - The data to store (will be automatically serialized).
|
|
166
126
|
* @returns A promise that resolves when the storage operation is complete.
|
|
167
127
|
*/
|
|
168
|
-
set(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
});
|
|
128
|
+
async set(r, e) {
|
|
129
|
+
try {
|
|
130
|
+
await (await u()).setItem(r, e);
|
|
131
|
+
} catch (t) {
|
|
132
|
+
s(t);
|
|
133
|
+
}
|
|
176
134
|
},
|
|
177
135
|
/**
|
|
178
136
|
* Removes a value from persistent storage by key.
|
|
@@ -181,14 +139,12 @@ const w = {
|
|
|
181
139
|
* @param key - The unique identifier of the value to remove.
|
|
182
140
|
* @returns A promise that resolves when the removal operation is complete.
|
|
183
141
|
*/
|
|
184
|
-
remove(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
});
|
|
142
|
+
async remove(r) {
|
|
143
|
+
try {
|
|
144
|
+
await (await u()).removeItem(r);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
s(e);
|
|
147
|
+
}
|
|
192
148
|
},
|
|
193
149
|
/**
|
|
194
150
|
* Retrieves all storage keys.
|
|
@@ -197,15 +153,13 @@ const w = {
|
|
|
197
153
|
*
|
|
198
154
|
* @returns A promise that resolves to an array of storage keys.
|
|
199
155
|
*/
|
|
200
|
-
keys() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
});
|
|
156
|
+
async keys() {
|
|
157
|
+
try {
|
|
158
|
+
const e = await (await u()).keys();
|
|
159
|
+
return Array.isArray(e) ? e : (h.warn("[Storage:keys] Invalid keys response:", e), []);
|
|
160
|
+
} catch (r) {
|
|
161
|
+
return s(r, { returnValue: [] });
|
|
162
|
+
}
|
|
209
163
|
},
|
|
210
164
|
/**
|
|
211
165
|
* Gets a human-readable log link for a storage key.
|
|
@@ -215,16 +169,15 @@ const w = {
|
|
|
215
169
|
* @param key - The storage key to generate a log link for.
|
|
216
170
|
* @returns A promise that resolves to a formatted log link string or null if an error occurs.
|
|
217
171
|
*/
|
|
218
|
-
getLogLink(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
});
|
|
172
|
+
async getLogLink(r) {
|
|
173
|
+
try {
|
|
174
|
+
return `${E.join(l.CYBERSKILL_STORAGE_DIRECTORY, g(r))} (key: ${r})`;
|
|
175
|
+
} catch (e) {
|
|
176
|
+
return s(e, { returnValue: null });
|
|
177
|
+
}
|
|
226
178
|
}
|
|
227
179
|
};
|
|
228
180
|
export {
|
|
229
|
-
|
|
181
|
+
A as storage
|
|
230
182
|
};
|
|
183
|
+
//# sourceMappingURL=storage.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.util.js","sources":["../../../src/node/storage/storage.util.ts"],"sourcesContent":["import localForage from 'localforage';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { getEnv } from '#config/env/index.js';\n\nimport type { LocalForageDriver, NodeFsDriverState, NodeLocalForageOptions } from './storage.type.js';\n\nimport { catchError, log } from '../log/index.js';\nimport { NODE_FS_DRIVER_NAME, STORAGE_INSTANCE_NAME, STORAGE_KEY_EXTENSION, STORAGE_STORE_NAME } from './storage.constant.js';\n\nconst env = getEnv();\n\nconst nodeFsDriverState: NodeFsDriverState = {\n baseDir: env.CYBERSKILL_STORAGE_DIRECTORY,\n};\n\n/**\n * Encodes a storage key into a filename-safe string.\n */\nfunction encodeKey(key: string): string {\n return `${encodeURIComponent(key)}${STORAGE_KEY_EXTENSION}`;\n}\n\n/**\n * Decodes a filename-safe key back to the original storage key.\n */\nfunction decodeKey(fileName: string): string {\n return decodeURIComponent(fileName.slice(0, -STORAGE_KEY_EXTENSION.length));\n}\n\n/**\n * Maps a storage key to an absolute file path inside the storage directory.\n */\nfunction getFilePath(key: string, baseDir: string): string {\n return path.join(baseDir, encodeKey(key));\n}\n\n/**\n * Custom localForage driver that stores JSON-encoded values on the filesystem.\n */\nconst nodeFsDriver: LocalForageDriver = {\n _driver: NODE_FS_DRIVER_NAME,\n _support: true,\n /** Ensures the storage directory exists and respects custom baseDir overrides. */\n async _initStorage(options: unknown) {\n try {\n const baseDirFromOptions = typeof options === 'object' && options !== null && 'baseDir' in options\n ? (options as { baseDir?: unknown }).baseDir\n : undefined;\n\n if (typeof baseDirFromOptions === 'string' && baseDirFromOptions.length > 0) {\n nodeFsDriverState.baseDir = baseDirFromOptions;\n }\n else {\n nodeFsDriverState.baseDir = env.CYBERSKILL_STORAGE_DIRECTORY;\n }\n\n await fs.mkdir(nodeFsDriverState.baseDir, { recursive: true });\n }\n catch (error) {\n log.error('[Storage:init]', error);\n throw error;\n }\n },\n /** Deletes all stored entries by recreating the directory. */\n async clear() {\n const { baseDir } = nodeFsDriverState;\n\n await fs.rm(baseDir, { recursive: true, force: true });\n await fs.mkdir(baseDir, { recursive: true });\n },\n /** Reads and parses a stored value; returns null when the file is missing. */\n async getItem<T>(key: string): Promise<T | null> {\n const { baseDir } = nodeFsDriverState;\n const filePath = getFilePath(key, baseDir);\n\n try {\n const content = await fs.readFile(filePath, 'utf8');\n\n return JSON.parse(content) as T;\n }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n },\n /** Iterates through all keys, invoking the iterator until it returns a value. */\n async iterate<T, U>(iterator: (value: T, key: string, iterationNumber: number) => U): Promise<U> {\n const keys = await nodeFsDriver.keys();\n let iterationNumber = 1;\n\n for (const key of keys) {\n const value = await nodeFsDriver.getItem<T>(key);\n\n const result = iterator(value as T, key, iterationNumber);\n\n if (result !== undefined) {\n return result;\n }\n iterationNumber += 1;\n }\n\n return undefined as unknown as U;\n },\n /** Returns the key name at the given index or null when out of bounds. */\n async key(keyIndex: number): Promise<string> {\n const keys = await nodeFsDriver.keys();\n\n return keys[keyIndex] ?? null as unknown as string;\n },\n /** Lists all stored keys. */\n async keys(): Promise<string[]> {\n const { baseDir } = nodeFsDriverState;\n\n try {\n const files = await fs.readdir(baseDir);\n\n return files\n .filter(file => file.endsWith(STORAGE_KEY_EXTENSION))\n .map(decodeKey);\n }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n },\n /** Returns the count of stored keys. */\n async length(): Promise<number> {\n const keys = await nodeFsDriver.keys();\n\n return keys.length;\n },\n /** Removes a stored value for the given key. */\n async removeItem(key: string): Promise<void> {\n const { baseDir } = nodeFsDriverState;\n const filePath = getFilePath(key, baseDir);\n\n await fs.rm(filePath, { force: true });\n },\n /** Stores a value as JSON on disk. */\n async setItem<T>(key: string, value: T): Promise<T> {\n const { baseDir } = nodeFsDriverState;\n const filePath = getFilePath(key, baseDir);\n\n await fs.mkdir(baseDir, { recursive: true });\n await fs.writeFile(filePath, JSON.stringify(value), 'utf8');\n\n return value;\n },\n};\n\nlet initPromise: Promise<void> | null = null;\nlet driverInstance: LocalForageDriver | null = null;\n\n/**\n * Prepares and returns the filesystem-backed localForage driver.\n * We bypass localForage's default driver selection and explicitly initialize\n * our custom driver to ensure Node compatibility.\n */\nasync function ensureLocalForageReady(): Promise<LocalForageDriver> {\n if (initPromise) {\n await initPromise;\n return driverInstance as LocalForageDriver;\n }\n\n initPromise = (async () => {\n await localForage.defineDriver(nodeFsDriver);\n nodeFsDriverState.baseDir = env.CYBERSKILL_STORAGE_DIRECTORY;\n const driver = await localForage.getDriver(NODE_FS_DRIVER_NAME);\n\n const initOptions = {\n baseDir: nodeFsDriverState.baseDir,\n name: STORAGE_INSTANCE_NAME,\n storeName: STORAGE_STORE_NAME,\n } satisfies NodeLocalForageOptions;\n\n await driver._initStorage(initOptions as unknown as Parameters<typeof driver._initStorage>[0]);\n driverInstance = driver;\n })().catch((error) => {\n initPromise = null;\n throw error;\n });\n\n await initPromise;\n\n return driverInstance as LocalForageDriver;\n}\n\n/**\n * Persistent storage utility object for data persistence across application sessions.\n * This object provides methods for storing, retrieving, and managing data using localForage,\n * with automatic initialization and error handling.\n */\nexport const storage = {\n /**\n * Retrieves a value from persistent storage by key.\n * This method fetches data that was previously stored using the set method.\n * Returns null if the key doesn't exist or if an error occurs.\n *\n * @param key - The unique identifier for the stored value.\n * @returns A promise that resolves to the stored value or null if not found.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n try {\n const driver = await ensureLocalForageReady();\n const result = await driver.getItem<T>(key);\n\n return result ?? null;\n }\n catch (error) {\n return catchError(error, { returnValue: null });\n }\n },\n /**\n * Stores a value in persistent storage with a unique key.\n * This method saves data that can be retrieved later using the get method.\n * The data is automatically serialized and stored in the configured storage directory.\n *\n * @param key - The unique identifier for the value to store.\n * @param value - The data to store (will be automatically serialized).\n * @returns A promise that resolves when the storage operation is complete.\n */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n try {\n const driver = await ensureLocalForageReady();\n\n await driver.setItem(key, value);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Removes a value from persistent storage by key.\n * This method permanently deletes the stored data associated with the specified key.\n *\n * @param key - The unique identifier of the value to remove.\n * @returns A promise that resolves when the removal operation is complete.\n */\n async remove(key: string): Promise<void> {\n try {\n const driver = await ensureLocalForageReady();\n\n await driver.removeItem(key);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Retrieves all storage keys.\n * This method returns an array of all keys that currently have stored values.\n * Returns an empty array if no keys exist or if an error occurs.\n *\n * @returns A promise that resolves to an array of storage keys.\n */\n async keys(): Promise<string[]> {\n try {\n const driver = await ensureLocalForageReady();\n const keys = await driver.keys();\n\n if (!Array.isArray(keys)) {\n log.warn(`[Storage:keys] Invalid keys response:`, keys);\n return [];\n }\n\n return keys;\n }\n catch (error) {\n return catchError(error, { returnValue: [] });\n }\n },\n /**\n * Gets a human-readable log link for a storage key.\n * This method provides a formatted string that shows the storage directory path\n * and the key name for debugging and manual inspection purposes.\n *\n * @param key - The storage key to generate a log link for.\n * @returns A promise that resolves to a formatted log link string or null if an error occurs.\n */\n async getLogLink(key: string): Promise<string | null> {\n try {\n const storagePath = path.join(env.CYBERSKILL_STORAGE_DIRECTORY, encodeKey(key));\n\n return `${storagePath} (key: ${key})`;\n }\n catch (error) {\n return catchError(error, { returnValue: null });\n }\n },\n\n};\n"],"names":["env","getEnv","nodeFsDriverState","encodeKey","key","STORAGE_KEY_EXTENSION","decodeKey","fileName","getFilePath","baseDir","path","nodeFsDriver","NODE_FS_DRIVER_NAME","options","baseDirFromOptions","fs","error","log","filePath","content","iterator","keys","iterationNumber","value","result","keyIndex","file","initPromise","driverInstance","ensureLocalForageReady","localForage","driver","initOptions","STORAGE_INSTANCE_NAME","STORAGE_STORE_NAME","storage","catchError"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.constant.js","sources":["../../../src/node/upload/upload.constant.ts"],"sourcesContent":["import { E_UploadType } from './upload.type.js';\n\nexport const BYTES_PER_MB = 1024 * 1024;\n\nexport const DEFAULT_UPLOAD_CONFIG = {\n [E_UploadType.IMAGE]: {\n allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'],\n sizeLimit: 5 * 1024 * 1024, // 5MB\n },\n [E_UploadType.VIDEO]: {\n allowedExtensions: ['mp4', 'avi', 'mov', 'wmv', 'flv', 'webm'],\n sizeLimit: 500 * 1024 * 1024, // 500MB\n },\n [E_UploadType.AUDIO]: {\n allowedExtensions: ['mp3', 'wav', 'ogg', 'm4a', 'aac'],\n sizeLimit: 50 * 1024 * 1024, // 50MB\n },\n [E_UploadType.DOCUMENT]: {\n allowedExtensions: ['pdf', 'doc', 'docx', 'txt', 'rtf'],\n sizeLimit: 10 * 1024 * 1024, // 10MB\n },\n [E_UploadType.OTHER]: {\n allowedExtensions: ['zip', 'rar', 'tar', 'gz'],\n sizeLimit: 5 * 1024 * 1024, // 5MB\n },\n};\n"],"names":["BYTES_PER_MB","DEFAULT_UPLOAD_CONFIG","E_UploadType"],"mappings":";AAEO,MAAMA,IAAe,OAAO,MAEtBC,IAAwB;AAAA,EACjC,CAACC,EAAa,KAAK,GAAG;AAAA,IAClB,mBAAmB,CAAC,OAAO,QAAQ,OAAO,OAAO,QAAQ,KAAK;AAAA,IAC9D,WAAW,IAAI,OAAO;AAAA;AAAA,EAAA;AAAA,EAE1B,CAACA,EAAa,KAAK,GAAG;AAAA,IAClB,mBAAmB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAAA,IAC7D,WAAW,MAAM,OAAO;AAAA;AAAA,EAAA;AAAA,EAE5B,CAACA,EAAa,KAAK,GAAG;AAAA,IAClB,mBAAmB,CAAC,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,IACrD,WAAW,KAAK,OAAO;AAAA;AAAA,EAAA;AAAA,EAE3B,CAACA,EAAa,QAAQ,GAAG;AAAA,IACrB,mBAAmB,CAAC,OAAO,OAAO,QAAQ,OAAO,KAAK;AAAA,IACtD,WAAW,KAAK,OAAO;AAAA;AAAA,EAAA;AAAA,EAE3B,CAACA,EAAa,KAAK,GAAG;AAAA,IAClB,mBAAmB,CAAC,OAAO,OAAO,OAAO,IAAI;AAAA,IAC7C,WAAW,IAAI,OAAO;AAAA;AAAA,EAAA;AAE9B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.type.js","sources":["../../../src/node/upload/upload.type.ts"],"sourcesContent":["export enum E_UploadType {\n IMAGE = 'IMAGE',\n VIDEO = 'VIDEO',\n AUDIO = 'AUDIO',\n DOCUMENT = 'DOCUMENT',\n OTHER = 'OTHER',\n}\n\nexport interface I_UploadValidationConfig {\n filename: string;\n fileSize?: number;\n}\n\nexport interface I_UploadTypeConfig {\n allowedExtensions: string[];\n sizeLimit: number;\n}\n\nexport interface I_UploadConfig {\n [E_UploadType.IMAGE]: I_UploadTypeConfig;\n [E_UploadType.VIDEO]: I_UploadTypeConfig;\n [E_UploadType.AUDIO]: I_UploadTypeConfig;\n [E_UploadType.DOCUMENT]: I_UploadTypeConfig;\n [E_UploadType.OTHER]: I_UploadTypeConfig;\n}\n\nexport interface I_UploadFileData {\n createReadStream: () => NodeJS.ReadableStream;\n filename: string;\n}\n\nexport interface I_UploadFile {\n file: I_UploadFileData;\n}\n\nexport interface I_UploadOptions {\n file: Promise<I_UploadFile>;\n path: string;\n type: E_UploadType;\n config?: I_UploadConfig;\n}\n"],"names":["E_UploadType"],"mappings":"AAAO,IAAKA,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,QAAQ,SACRA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,QAAQ,SALAA,IAAAA,KAAA,CAAA,CAAA;"}
|