@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,174 +1,144 @@
|
|
|
1
1
|
import { Buffer as w } from "node:buffer";
|
|
2
2
|
import { Transform as C } from "node:stream";
|
|
3
3
|
import { ReadableStream as D } from "node:stream/web";
|
|
4
|
-
import { DEFAULT_UPLOAD_CONFIG as
|
|
5
|
-
import { E_UploadType as
|
|
6
|
-
import { dirname as
|
|
7
|
-
import { pathExistsSync as
|
|
8
|
-
import { RESPONSE_STATUS as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return t;
|
|
16
|
-
}, E = (t, r, e) => new Promise((i, a) => {
|
|
17
|
-
var s = (l) => {
|
|
18
|
-
try {
|
|
19
|
-
n(e.next(l));
|
|
20
|
-
} catch (c) {
|
|
21
|
-
a(c);
|
|
22
|
-
}
|
|
23
|
-
}, o = (l) => {
|
|
24
|
-
try {
|
|
25
|
-
n(e.throw(l));
|
|
26
|
-
} catch (c) {
|
|
27
|
-
a(c);
|
|
28
|
-
}
|
|
29
|
-
}, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(s, o);
|
|
30
|
-
n((e = e.apply(t, r)).next());
|
|
31
|
-
});
|
|
32
|
-
function B(t) {
|
|
33
|
-
return E(this, null, function* () {
|
|
34
|
-
return new Promise((r, e) => {
|
|
35
|
-
let i = 0;
|
|
36
|
-
t.on("data", (a) => {
|
|
37
|
-
i += a.length;
|
|
38
|
-
}), t.on("end", () => r(i)), t.on("error", e);
|
|
39
|
-
});
|
|
4
|
+
import { DEFAULT_UPLOAD_CONFIG as y, BYTES_PER_MB as R } from "./upload.constant.js";
|
|
5
|
+
import { E_UploadType as E } from "./upload.type.js";
|
|
6
|
+
import { dirname as O } from "../path/path.util.js";
|
|
7
|
+
import { pathExistsSync as x, mkdirSync as z, createWriteStream as v } from "../fs/fs.util.js";
|
|
8
|
+
import { RESPONSE_STATUS as c } from "../../constant/response-status.js";
|
|
9
|
+
async function A(i) {
|
|
10
|
+
return new Promise((o, t) => {
|
|
11
|
+
let e = 0;
|
|
12
|
+
i.on("data", (n) => {
|
|
13
|
+
e += n.length;
|
|
14
|
+
}), i.on("end", () => o(e)), i.on("error", t);
|
|
40
15
|
});
|
|
41
16
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
});
|
|
17
|
+
async function S(i, o, t) {
|
|
18
|
+
const e = await (await o).file, n = e.createReadStream(), s = await A(n), r = t ?? g(), a = T(
|
|
19
|
+
{ filename: e.filename, fileSize: s },
|
|
20
|
+
r,
|
|
21
|
+
i
|
|
22
|
+
);
|
|
23
|
+
return a.isValid ? {
|
|
24
|
+
success: !0,
|
|
25
|
+
result: e,
|
|
26
|
+
message: "File validated successfully"
|
|
27
|
+
} : {
|
|
28
|
+
success: !1,
|
|
29
|
+
message: a.error || "File validation failed",
|
|
30
|
+
code: c.BAD_REQUEST.CODE
|
|
31
|
+
};
|
|
59
32
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
async function h(i, o, t) {
|
|
34
|
+
const n = (t ?? g())[i], s = await S(i, o, t);
|
|
35
|
+
if (!s.success)
|
|
36
|
+
return s;
|
|
37
|
+
const { createReadStream: r } = s.result;
|
|
38
|
+
let a = n.sizeLimit;
|
|
39
|
+
const f = new C({
|
|
40
|
+
transform(l, d, p) {
|
|
41
|
+
a -= l.length, a < 0 ? p(new Error(`File size exceeds limit of ${n.sizeLimit / R}MB`)) : p(null, l);
|
|
42
|
+
}
|
|
43
|
+
}), u = r().pipe(f);
|
|
44
|
+
return {
|
|
45
|
+
success: !0,
|
|
46
|
+
result: new D({
|
|
47
|
+
start(l) {
|
|
48
|
+
u.on("data", (d) => {
|
|
49
|
+
l.enqueue(typeof d == "string" ? w.from(d) : d);
|
|
50
|
+
}), u.on("end", () => l.close()), u.on("error", (d) => l.error(d));
|
|
70
51
|
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
success: !0,
|
|
74
|
-
result: new D({
|
|
75
|
-
start(f) {
|
|
76
|
-
m.on("data", (d) => {
|
|
77
|
-
f.enqueue(typeof d == "string" ? w.from(d) : d);
|
|
78
|
-
}), m.on("end", () => f.close()), m.on("error", (d) => f.error(d));
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
};
|
|
82
|
-
});
|
|
52
|
+
})
|
|
53
|
+
};
|
|
83
54
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
55
|
+
function F(i, o) {
|
|
56
|
+
const t = i.lastIndexOf(".");
|
|
57
|
+
if (t === -1)
|
|
87
58
|
return !1;
|
|
88
|
-
const
|
|
89
|
-
return
|
|
59
|
+
const e = i.substring(t + 1).toLowerCase();
|
|
60
|
+
return o.includes(e);
|
|
90
61
|
}
|
|
91
|
-
function
|
|
92
|
-
const { filename:
|
|
93
|
-
if (!
|
|
62
|
+
function T(i, o, t) {
|
|
63
|
+
const { filename: e, fileSize: n } = i, s = o[t], { allowedExtensions: r, sizeLimit: a } = s;
|
|
64
|
+
if (!F(e, r))
|
|
94
65
|
return {
|
|
95
66
|
isValid: !1,
|
|
96
|
-
error: `File extension not allowed for ${
|
|
67
|
+
error: `File extension not allowed for ${t.toLowerCase()} files. Allowed extensions: ${r.join(", ")}`
|
|
97
68
|
};
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
69
|
+
if (n !== void 0 && n > a) {
|
|
70
|
+
const f = Math.round(a / 1048576);
|
|
100
71
|
return {
|
|
101
72
|
isValid: !1,
|
|
102
|
-
error: `File size exceeds limit for ${
|
|
73
|
+
error: `File size exceeds limit for ${t.toLowerCase()} files. Maximum size: ${f}MB`
|
|
103
74
|
};
|
|
104
75
|
}
|
|
105
76
|
return { isValid: !0 };
|
|
106
77
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
78
|
+
function g(i) {
|
|
79
|
+
return { ...y, ...i };
|
|
109
80
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
const s = yield g(a, yield e, i);
|
|
144
|
-
if (!s.success)
|
|
145
|
-
return s;
|
|
146
|
-
const { createReadStream: o } = s.result, n = x(r);
|
|
147
|
-
z(n) || A(n, { recursive: !0 });
|
|
148
|
-
const l = o(), c = F(r);
|
|
149
|
-
return l.pipe(c), yield new Promise((m, f) => {
|
|
150
|
-
c.on("finish", () => m()), c.on("error", f), l.on("error", f);
|
|
151
|
-
}), {
|
|
152
|
-
success: !0,
|
|
153
|
-
result: r,
|
|
154
|
-
message: "File uploaded successfully",
|
|
155
|
-
code: u.OK.CODE
|
|
156
|
-
};
|
|
157
|
-
} catch (s) {
|
|
158
|
-
return {
|
|
159
|
-
success: !1,
|
|
160
|
-
message: s instanceof Error ? s.message : "File upload failed",
|
|
161
|
-
code: u.INTERNAL_SERVER_ERROR.CODE
|
|
162
|
-
};
|
|
81
|
+
async function N(i) {
|
|
82
|
+
const { path: o, file: t, config: e, type: n } = i;
|
|
83
|
+
if (!o || typeof o != "string")
|
|
84
|
+
return {
|
|
85
|
+
success: !1,
|
|
86
|
+
message: "Invalid path provided",
|
|
87
|
+
code: c.BAD_REQUEST.CODE
|
|
88
|
+
};
|
|
89
|
+
if (!t || typeof t != "object")
|
|
90
|
+
return {
|
|
91
|
+
success: !1,
|
|
92
|
+
message: "Invalid file provided",
|
|
93
|
+
code: c.BAD_REQUEST.CODE
|
|
94
|
+
};
|
|
95
|
+
if (e) {
|
|
96
|
+
const s = [E.IMAGE, E.VIDEO, E.DOCUMENT, E.OTHER];
|
|
97
|
+
for (const r of s) {
|
|
98
|
+
if (!e[r] || !Array.isArray(e[r].allowedExtensions) || e[r].allowedExtensions.length === 0)
|
|
99
|
+
return {
|
|
100
|
+
success: !1,
|
|
101
|
+
message: `Invalid config for ${r.toLowerCase()} files`,
|
|
102
|
+
code: c.BAD_REQUEST.CODE
|
|
103
|
+
};
|
|
104
|
+
if (typeof e[r].sizeLimit != "number" || e[r].sizeLimit <= 0)
|
|
105
|
+
return {
|
|
106
|
+
success: !1,
|
|
107
|
+
message: `Invalid size limit for ${r.toLowerCase()} files`,
|
|
108
|
+
code: c.BAD_REQUEST.CODE
|
|
109
|
+
};
|
|
163
110
|
}
|
|
164
|
-
}
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const s = await S(n, await t, e);
|
|
114
|
+
if (!s.success)
|
|
115
|
+
return s;
|
|
116
|
+
const { createReadStream: r } = s.result, a = O(o);
|
|
117
|
+
x(a) || z(a, { recursive: !0 });
|
|
118
|
+
const f = r(), m = v(o);
|
|
119
|
+
return f.pipe(m), await new Promise((u, l) => {
|
|
120
|
+
m.on("finish", () => u()), m.on("error", l), f.on("error", l);
|
|
121
|
+
}), {
|
|
122
|
+
success: !0,
|
|
123
|
+
result: o,
|
|
124
|
+
message: "File uploaded successfully",
|
|
125
|
+
code: c.OK.CODE
|
|
126
|
+
};
|
|
127
|
+
} catch (s) {
|
|
128
|
+
return {
|
|
129
|
+
success: !1,
|
|
130
|
+
message: s instanceof Error ? s.message : "File upload failed",
|
|
131
|
+
code: c.INTERNAL_SERVER_ERROR.CODE
|
|
132
|
+
};
|
|
133
|
+
}
|
|
165
134
|
}
|
|
166
135
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
136
|
+
g as createUploadConfig,
|
|
137
|
+
S as getAndValidateFile,
|
|
138
|
+
A as getFileSizeFromStream,
|
|
139
|
+
h as getFileWebStream,
|
|
140
|
+
N as upload,
|
|
141
|
+
F as validateFileExtension,
|
|
142
|
+
T as validateUpload
|
|
174
143
|
};
|
|
144
|
+
//# sourceMappingURL=upload.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.util.js","sources":["../../../src/node/upload/upload.util.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { Transform } from 'node:stream';\nimport { ReadableStream } from 'node:stream/web';\n\nimport type { I_Return } from '#typescript/index.js';\n\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { I_UploadConfig, I_UploadFile, I_UploadFileData, I_UploadOptions, I_UploadTypeConfig, I_UploadValidationConfig } from './upload.type.js';\n\nimport { createWriteStream, mkdirSync, pathExistsSync } from '../fs/index.js';\nimport { dirname } from '../path/index.js';\nimport { BYTES_PER_MB, DEFAULT_UPLOAD_CONFIG } from './upload.constant.js';\nimport { E_UploadType } from './upload.type.js';\n\n/**\n * Calculates the size of a file from a readable stream.\n * This function reads through the entire stream to determine the total byte size\n * by accumulating the length of each data chunk.\n *\n * @param stream - The readable stream to calculate the size for.\n * @returns A promise that resolves to the total size of the stream in bytes.\n */\nexport async function getFileSizeFromStream(stream: NodeJS.ReadableStream): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0;\n stream.on('data', (chunk) => {\n size += chunk.length;\n });\n stream.on('end', () => resolve(size));\n stream.on('error', reject);\n });\n}\n\n/**\n * Extracts and validates file data from an upload file.\n * This function processes upload files by:\n * - Extracting file metadata and creating a readable stream\n * - Calculating the file size from the stream\n * - Validating file size and extension against upload configuration\n * - Returning a standardized response with success status and error codes\n * - Providing validated file data for further processing\n *\n * @param type - The type of upload being processed (IMAGE, VIDEO, DOCUMENT, OTHER).\n * @param file - The upload file object containing file metadata and stream creation method.\n * @param config - Optional upload configuration. If not provided, uses default configuration.\n * @returns A promise that resolves to a standardized response containing validated file data or error information.\n */\nexport async function getAndValidateFile(type: E_UploadType, file: I_UploadFile, config?: I_UploadConfig): Promise<I_Return<I_UploadFileData>> {\n const fileData = await (await file).file;\n const stream = fileData.createReadStream();\n const fileSize = await getFileSizeFromStream(stream);\n const uploadConfig = config ?? createUploadConfig();\n\n const validationResult = validateUpload(\n { filename: fileData.filename, fileSize },\n uploadConfig,\n type,\n );\n\n if (!validationResult.isValid) {\n return {\n success: false,\n message: validationResult.error || 'File validation failed',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n return {\n success: true,\n result: fileData,\n message: 'File validated successfully',\n };\n}\n\n/**\n * Creates a validated web-readable stream from an upload file with size validation.\n * This function processes file uploads for web environments by:\n * - Validating file data using getAndValidateFile function\n * - Creating a size validation transform stream to monitor upload progress\n * - Returning a web-compatible ReadableStream with real-time validation\n * - Providing standardized error responses for validation failures\n * - Wrapping the stream in a standardized response format\n *\n * @param type - The type of upload being processed (IMAGE, VIDEO, DOCUMENT, OTHER).\n * @param file - The upload file object containing file metadata and stream creation method.\n * @param config - Optional upload configuration. If not provided, uses default configuration.\n * @returns A promise that resolves to a standardized response containing either a web ReadableStream or error information.\n */\nexport async function getFileWebStream(type: E_UploadType, file: I_UploadFile, config?: I_UploadConfig): Promise<I_Return<ReadableStream<Uint8Array>>> {\n const uploadConfig = config ?? createUploadConfig();\n const typeConfig = uploadConfig[type];\n\n const fileData = await getAndValidateFile(type, file, config);\n\n if (!fileData.success) {\n return fileData;\n }\n\n const { createReadStream } = fileData.result;\n\n let remainingBytes = typeConfig.sizeLimit;\n\n const sizeValidationStream = new Transform({\n transform(chunk: Buffer, _enc: BufferEncoding, cb) {\n remainingBytes -= chunk.length;\n\n if (remainingBytes < 0) {\n cb(new Error(`File size exceeds limit of ${typeConfig.sizeLimit / BYTES_PER_MB}MB`));\n }\n else {\n cb(null, chunk);\n }\n },\n });\n const originalStream = createReadStream();\n const validatedStream = originalStream.pipe(sizeValidationStream);\n\n return {\n success: true,\n result: new ReadableStream<Uint8Array>({\n start(controller) {\n validatedStream.on('data', (chunk: Buffer | string) => {\n controller.enqueue(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);\n });\n validatedStream.on('end', () => controller.close());\n validatedStream.on('error', (err: unknown) => controller.error(err));\n },\n }),\n };\n}\n\n/**\n * Validates if a file has an allowed extension.\n * This function extracts the file extension from the filename and checks if it's\n * included in the list of allowed extensions (case-insensitive comparison).\n *\n * @param filename - The filename to check for valid extension.\n * @param allowedExtensions - An array of allowed file extensions (without dots).\n * @returns True if the file extension is allowed, false otherwise.\n */\nexport function validateFileExtension(filename: string, allowedExtensions: string[]): boolean {\n const lastDotIndex = filename.lastIndexOf('.');\n\n if (lastDotIndex === -1) {\n return false;\n }\n\n const extension = filename.substring(lastDotIndex + 1).toLowerCase();\n\n return allowedExtensions.includes(extension);\n}\n\n/**\n * Validates an upload against the specified configuration.\n * This function performs comprehensive validation including:\n * - File extension validation against allowed extensions\n * - File size validation against size limits\n * - Returns detailed error messages for validation failures\n *\n * @param config - The validation configuration including filename and optional file size.\n * @param uploadConfig - The upload configuration containing allowed extensions and size limits.\n * @param uploadType - The type of upload being validated.\n * @returns An object indicating validation success and optional error message.\n */\nexport function validateUpload(\n config: I_UploadValidationConfig,\n uploadConfig: I_UploadConfig,\n uploadType: E_UploadType,\n): { isValid: boolean; error?: string } {\n const { filename, fileSize } = config;\n const typeConfig: I_UploadTypeConfig = uploadConfig[uploadType];\n\n const { allowedExtensions, sizeLimit } = typeConfig;\n\n if (!validateFileExtension(filename, allowedExtensions)) {\n return {\n isValid: false,\n error: `File extension not allowed for ${uploadType.toLowerCase()} files. Allowed extensions: ${allowedExtensions.join(', ')}`,\n };\n }\n\n if (fileSize !== undefined && fileSize > sizeLimit) {\n const maxSizeMB = Math.round(sizeLimit / (1024 * 1024));\n\n return {\n isValid: false,\n error: `File size exceeds limit for ${uploadType.toLowerCase()} files. Maximum size: ${maxSizeMB}MB`,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Creates a default upload configuration with predefined settings for different file types.\n * This function provides sensible defaults for image, video, document, and other file types,\n * including allowed extensions and size limits. The configuration can be customized with overrides.\n *\n * @param overrides - Optional configuration overrides to merge with the default configuration.\n * @returns A complete upload configuration object with defaults and any provided overrides.\n */\nexport function createUploadConfig(overrides?: Partial<I_UploadConfig>): I_UploadConfig {\n return { ...DEFAULT_UPLOAD_CONFIG, ...overrides };\n}\n\n/**\n * Uploads a file with comprehensive validation and error handling.\n * This function processes file uploads with the following features:\n * - Input validation for path and file parameters\n * - Configuration validation for all upload types\n * - File validation using getAndValidateFile function\n * - Automatic directory creation\n * - Stream-based file writing\n * - Comprehensive error handling with standardized response codes\n *\n * @param options - Upload configuration including file, path, type, and optional validation config.\n * @returns A promise that resolves to a standardized response with success status, message, file path, and response codes.\n */\nexport async function upload(options: I_UploadOptions): Promise<I_Return<string>> {\n const { path, file, config, type } = options;\n\n if (!path || typeof path !== 'string') {\n return {\n success: false,\n message: 'Invalid path provided',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n if (!file || typeof file !== 'object') {\n return {\n success: false,\n message: 'Invalid file provided',\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n\n if (config) {\n const requiredTypes = [E_UploadType.IMAGE, E_UploadType.VIDEO, E_UploadType.DOCUMENT, E_UploadType.OTHER];\n\n for (const requiredType of requiredTypes) {\n if (!config[requiredType] || !Array.isArray(config[requiredType].allowedExtensions) || config[requiredType].allowedExtensions.length === 0) {\n return {\n success: false,\n message: `Invalid config for ${requiredType.toLowerCase()} files`,\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n if (typeof config[requiredType].sizeLimit !== 'number' || config[requiredType].sizeLimit <= 0) {\n return {\n success: false,\n message: `Invalid size limit for ${requiredType.toLowerCase()} files`,\n code: RESPONSE_STATUS.BAD_REQUEST.CODE,\n };\n }\n }\n }\n\n try {\n const fileData = await getAndValidateFile(type, await file, config);\n\n if (!fileData.success) {\n return fileData;\n }\n\n const { createReadStream } = fileData.result;\n\n const dir = dirname(path);\n\n if (!pathExistsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n const writeStream = createReadStream();\n const out = createWriteStream(path);\n writeStream.pipe(out);\n\n await new Promise<void>((resolve, reject) => {\n out.on('finish', () => resolve());\n out.on('error', reject);\n writeStream.on('error', reject);\n });\n\n return {\n success: true,\n result: path,\n message: 'File uploaded successfully',\n code: RESPONSE_STATUS.OK.CODE,\n };\n }\n catch (error) {\n return {\n success: false,\n message: error instanceof Error ? error.message : 'File upload failed',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n}\n"],"names":["getFileSizeFromStream","stream","resolve","reject","size","chunk","getAndValidateFile","type","file","config","fileData","fileSize","uploadConfig","createUploadConfig","validationResult","validateUpload","RESPONSE_STATUS","getFileWebStream","typeConfig","createReadStream","remainingBytes","sizeValidationStream","Transform","_enc","cb","BYTES_PER_MB","validatedStream","ReadableStream","controller","Buffer","err","validateFileExtension","filename","allowedExtensions","lastDotIndex","extension","uploadType","sizeLimit","maxSizeMB","overrides","DEFAULT_UPLOAD_CONFIG","upload","options","path","requiredTypes","E_UploadType","requiredType","dir","dirname","pathExistsSync","mkdirSync","writeStream","out","createWriteStream","error"],"mappings":"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"}
|
package/dist/node/ws/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './ws.util.js';
|
|
2
2
|
export * from './ws.type.js';
|
package/dist/node/ws/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useServer as p } from "graphql-ws/use/ws";
|
|
2
|
+
import { WebSocketServer as u } from "ws";
|
|
3
|
+
function f(c) {
|
|
4
|
+
const { server: o, path: a, sessionParser: n } = c;
|
|
5
|
+
if (n) {
|
|
6
|
+
const r = new u({ noServer: !0 });
|
|
7
|
+
return o.on("upgrade", (e, t, s) => {
|
|
8
|
+
try {
|
|
9
|
+
if (new URL(e.url || "", "http://localhost").pathname !== a)
|
|
10
|
+
return;
|
|
11
|
+
n(e, {}, () => {
|
|
12
|
+
r.handleUpgrade(e, t, s, (i) => {
|
|
13
|
+
r.emit("connection", i, e);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
} catch {
|
|
17
|
+
t.destroy();
|
|
18
|
+
}
|
|
19
|
+
}), r;
|
|
20
|
+
}
|
|
21
|
+
return new u({ server: o, path: a });
|
|
22
|
+
}
|
|
23
|
+
function S(c) {
|
|
24
|
+
const { schema: o, server: a, context: n, onConnect: r } = c;
|
|
25
|
+
return p(
|
|
26
|
+
{
|
|
27
|
+
schema: o,
|
|
28
|
+
context: async (e) => {
|
|
29
|
+
const t = e.extra.request, s = n ? await n(t) : {};
|
|
30
|
+
return { req: t, ...s };
|
|
31
|
+
},
|
|
32
|
+
onConnect: async (e) => {
|
|
33
|
+
if (r) {
|
|
34
|
+
const t = e.extra.request;
|
|
35
|
+
await r(t);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
a
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
f as createWSServer,
|
|
44
|
+
S as initGraphQLWS
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=ws.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws.util.js","sources":["../../../src/node/ws/ws.util.ts"],"sourcesContent":["import type { Request, Response } from 'express';\nimport type { Buffer } from 'node:buffer';\nimport type { IncomingMessage } from 'node:http';\nimport type { Duplex } from 'node:stream';\n\nimport { useServer as createGraphQLWSServer } from 'graphql-ws/use/ws';\nimport { WebSocketServer } from 'ws';\n\nimport type { I_GraphqlWSOptions, I_WSOptions } from './ws.type.js';\n\n/**\n * Creates a WebSocket server with the specified configuration.\n * This function creates a WebSocket server instance that can be attached to an HTTP server\n * and configured with a specific path for WebSocket connections.\n *\n * @param options - Configuration options including the HTTP server instance and WebSocket path.\n * @returns A configured WebSocket server instance ready to handle connections.\n */\nexport function createWSServer(options: I_WSOptions): WebSocketServer {\n const { server, path, sessionParser } = options;\n\n if (sessionParser) {\n const wss = new WebSocketServer({ noServer: true });\n\n server.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer) => {\n try {\n const url = new URL(req.url || '', 'http://localhost');\n if (url.pathname !== path)\n return;\n\n sessionParser(req as Request, {} as Response, () => {\n wss.handleUpgrade(req, socket, head, (ws) => {\n wss.emit('connection', ws, req);\n });\n });\n }\n catch {\n socket.destroy();\n }\n });\n\n return wss;\n }\n\n return new WebSocketServer({ server, path });\n}\n\n/**\n * Initializes GraphQL WebSocket server with schema and WebSocket server.\n * This function sets up GraphQL subscriptions over WebSocket by creating a GraphQL WebSocket server\n * that can handle GraphQL operations including queries, mutations, and subscriptions.\n *\n * @param options - Configuration options including the GraphQL schema and WebSocket server instance.\n * @returns A configured GraphQL WebSocket server ready to handle GraphQL operations over WebSocket.\n */\nexport function initGraphQLWS(options: I_GraphqlWSOptions) {\n const { schema, server, context: makeExtraContext, onConnect } = options;\n\n return createGraphQLWSServer(\n {\n schema,\n context: async (ctx) => {\n const req = ctx.extra.request as IncomingMessage & { session?: any; user?: any };\n\n const extra = makeExtraContext ? await makeExtraContext(req) : {};\n return { req, ...extra };\n },\n onConnect: async (ctx) => {\n if (onConnect) {\n const req = ctx.extra.request as IncomingMessage & { session?: any; user?: any };\n await onConnect(req);\n }\n },\n },\n server,\n );\n}\n"],"names":["createWSServer","options","server","path","sessionParser","wss","WebSocketServer","req","socket","head","ws","initGraphQLWS","schema","makeExtraContext","onConnect","createGraphQLWSServer","ctx","extra"],"mappings":";;AAkBO,SAASA,EAAeC,GAAuC;AAClE,QAAM,EAAE,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,EAAA,IAAkBH;AAExC,MAAIG,GAAe;AACf,UAAMC,IAAM,IAAIC,EAAgB,EAAE,UAAU,IAAM;AAElD,WAAAJ,EAAO,GAAG,WAAW,CAACK,GAAsBC,GAAgBC,MAAiB;AACzE,UAAI;AAEA,YADY,IAAI,IAAIF,EAAI,OAAO,IAAI,kBAAkB,EAC7C,aAAaJ;AACjB;AAEJ,QAAAC,EAAcG,GAAgB,CAAA,GAAgB,MAAM;AAChD,UAAAF,EAAI,cAAcE,GAAKC,GAAQC,GAAM,CAACC,MAAO;AACzC,YAAAL,EAAI,KAAK,cAAcK,GAAIH,CAAG;AAAA,UAClC,CAAC;AAAA,QACL,CAAC;AAAA,MACL,QACM;AACF,QAAAC,EAAO,QAAA;AAAA,MACX;AAAA,IACJ,CAAC,GAEMH;AAAA,EACX;AAEA,SAAO,IAAIC,EAAgB,EAAE,QAAAJ,GAAQ,MAAAC,GAAM;AAC/C;AAUO,SAASQ,EAAcV,GAA6B;AACvD,QAAM,EAAE,QAAAW,GAAQ,QAAAV,GAAQ,SAASW,GAAkB,WAAAC,MAAcb;AAEjE,SAAOc;AAAAA,IACH;AAAA,MACI,QAAAH;AAAA,MACA,SAAS,OAAOI,MAAQ;AACpB,cAAMT,IAAMS,EAAI,MAAM,SAEhBC,IAAQJ,IAAmB,MAAMA,EAAiBN,CAAG,IAAI,CAAA;AAC/D,eAAO,EAAE,KAAAA,GAAK,GAAGU,EAAA;AAAA,MACrB;AAAA,MACA,WAAW,OAAOD,MAAQ;AACtB,YAAIF,GAAW;AACX,gBAAMP,IAAMS,EAAI,MAAM;AACtB,gBAAMF,EAAUP,CAAG;AAAA,QACvB;AAAA,MACJ;AAAA,IAAA;AAAA,IAEJL;AAAA,EAAA;AAER;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../../../../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"],"sourcesContent":["export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.BOqNVLsY.js';\nexport { mergeConfig } from 'vite';\nexport { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';\nimport 'node:os';\nimport './chunks/env.D4Lgay0q.js';\nimport 'std-env';\n\nfunction defineConfig(config) {\n\treturn config;\n}\nfunction defineProject(config) {\n\treturn config;\n}\n\nexport { defineConfig, defineProject };\n"],"names":["defineConfig","config"],"mappings":"AAOA,SAASA,EAAaC,GAAQ;AAC7B,SAAOA;AACR;","x_google_ignoreList":[0]}
|
|
@@ -6,13 +6,14 @@ import { getClient as p } from "./apollo-client.util.js";
|
|
|
6
6
|
import { ApolloErrorProvider as a } from "../apollo-error/apollo-error.provider.js";
|
|
7
7
|
import { ApolloErrorComponent as c } from "../apollo-error/apollo-error.component.js";
|
|
8
8
|
import { Toaster as f } from "react-hot-toast";
|
|
9
|
-
function g({ options:
|
|
9
|
+
function g({ options: o, children: l, onError: r }) {
|
|
10
10
|
const t = i(
|
|
11
|
-
() => p(
|
|
12
|
-
[
|
|
11
|
+
() => p(o ?? {}),
|
|
12
|
+
[o]
|
|
13
13
|
);
|
|
14
|
-
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError:
|
|
14
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError: r }, /* @__PURE__ */ e.createElement(n, { client: t }, /* @__PURE__ */ e.createElement(m, { client: t }, l)), !r && /* @__PURE__ */ e.createElement(c, null)), /* @__PURE__ */ e.createElement(f, { position: "top-right" }));
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
17
|
g as ApolloProvider
|
|
18
18
|
};
|
|
19
|
+
//# sourceMappingURL=apollo-client.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.component.js","sources":["../../../src/react/apollo-client/apollo-client.component.tsx"],"sourcesContent":["import { ApolloProvider as ApolloProviderDefault } from '@apollo/client/react';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from './apollo-client.type.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { ApolloClientProvider } from './apollo-client.context.js';\nimport { getClient } from './apollo-client.util.js';\n\n/**\n * Apollo Provider component that wraps the application with Apollo Client context.\n * This component provides the Apollo Client instance to all child components,\n * enabling GraphQL operations throughout the component tree. It includes\n * error handling and toast integration for a complete GraphQL experience.\n *\n * Features:\n * - Apollo Client context provision\n * - Error boundary integration\n * - Toast notification support\n * - Automatic error handling\n * - Development and production optimizations\n *\n * @param props - Component props containing options, children, and optional error override.\n * @param props.options - Apollo Client configuration options.\n * @param props.children - React children that will have access to Apollo Client context.\n * @param props.onError - Optional callback to override the default modal/toast error handling.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloProvider({ options, children, onError }: I_ApolloProviderProps) {\n const client = useMemo(\n () => getClient(options ?? {}),\n [options],\n );\n\n return (\n <>\n <ApolloErrorProvider onError={onError}>\n <ApolloClientProvider client={client}>\n <ApolloProviderDefault client={client}>{children}</ApolloProviderDefault>\n </ApolloClientProvider>\n {!onError && <ApolloErrorComponent />}\n </ApolloErrorProvider>\n <Toaster position=\"top-right\" />\n </>\n );\n}\n"],"names":["ApolloProvider","options","children","onError","client","useMemo","getClient","React","ApolloErrorProvider","ApolloClientProvider","ApolloProviderDefault","ApolloErrorComponent","Toaster"],"mappings":";;;;;;;;AA8BO,SAASA,EAAe,EAAE,SAAAC,GAAS,UAAAC,GAAU,SAAAC,KAAkC;AAClF,QAAMC,IAASC;AAAA,IACX,MAAMC,EAAUL,KAAW,EAAE;AAAA,IAC7B,CAACA,CAAO;AAAA,EAAA;AAGZ,SACI,gBAAAM,EAAA,cAAAA,EAAA,UAAA,sCACKC,GAAA,EAAoB,SAAAL,EAAA,mCAChBM,GAAA,EAAqB,QAAAL,EAAA,GAClB,gBAAAG,EAAA,cAACG,GAAA,EAAsB,QAAAN,EAAA,GAAiBF,CAAS,CACrD,GACC,CAACC,KAAW,gBAAAI,EAAA,cAACI,GAAA,IAAqB,CACvC,GACA,gBAAAJ,EAAA,cAACK,GAAA,EAAQ,UAAS,YAAA,CAAY,CAClC;AAER;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.constant.js","sources":["../../../src/react/apollo-client/apollo-client.constant.ts"],"sourcesContent":["/**\n * Default GraphQL endpoint URI for Apollo Client configuration.\n * This constant provides the standard GraphQL endpoint path that is commonly used\n * in web applications for GraphQL API communication.\n */\nexport const GRAPHQL_URI_DEFAULT = '/graphql';\n"],"names":["GRAPHQL_URI_DEFAULT"],"mappings":"AAKO,MAAMA,IAAsB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.context.js","sources":["../../../src/react/apollo-client/apollo-client.context.tsx"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\n\nimport * as React from 'react';\nimport { createContext } from 'react';\n\n/**\n * React context for providing Apollo Client instance to child components.\n * This context allows components to access the Apollo Client instance without\n * prop drilling, enabling direct access to client methods and cache operations.\n */\nconst ApolloClientContext = createContext<ApolloClient | null>(null);\n\n/**\n * Provider component that makes Apollo Client available to the component tree.\n * This component wraps the Apollo Client instance in a React context, allowing\n * any child component to access the client using the useApolloClient hook.\n *\n * @param props - Component props containing client and children.\n * @param props.client - The Apollo Client instance to provide to the component tree.\n * @param props.children - React children that will have access to the Apollo Client context.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloClientProvider({\n client,\n children,\n}: {\n client: ApolloClient;\n children: React.ReactNode;\n}) {\n return (\n <ApolloClientContext value={client}>\n {children}\n </ApolloClientContext>\n );\n}\n\nexport { ApolloClientContext };\n"],"names":["React","createContext","ApolloClientContext","ApolloClientProvider","client","children"],"mappings":"AAUA,YAAAA,OAAA;AAAA,SAAA,iBAAAC,SAAA;AAAA,MAAMC,IAAsBD,EAAmC,IAAI;AAY5D,SAASE,EAAqB;AAAA,EACjC,QAAAC;AAAA,EACA,UAAAC;AACJ,GAGG;AACC,SACI,gBAAAL,EAAA,cAACE,GAAA,EAAoB,OAAOE,EAAA,GACvBC,CACL;AAER;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,84 +1,78 @@
|
|
|
1
|
-
import { ApolloClient as
|
|
2
|
-
import { ApolloLink as
|
|
3
|
-
import { ErrorLink as
|
|
4
|
-
import { RemoveTypenameFromVariablesLink as
|
|
5
|
-
import { GraphQLWsLink as
|
|
6
|
-
import { OperationTypeNode as
|
|
7
|
-
import { createClient as
|
|
1
|
+
import { ApolloClient as d, InMemoryCache as w, CombinedGraphQLErrors as h, CombinedProtocolErrors as E, ServerError as g } from "@apollo/client/core";
|
|
2
|
+
import { ApolloLink as a } from "@apollo/client/link";
|
|
3
|
+
import { ErrorLink as C } from "@apollo/client/link/error";
|
|
4
|
+
import { RemoveTypenameFromVariablesLink as y } from "@apollo/client/link/remove-typename";
|
|
5
|
+
import { GraphQLWsLink as N } from "@apollo/client/link/subscriptions";
|
|
6
|
+
import { OperationTypeNode as $ } from "graphql";
|
|
7
|
+
import { createClient as b } from "graphql-ws";
|
|
8
8
|
import * as p from "react";
|
|
9
|
-
import { tap as
|
|
10
|
-
import { GRAPHQL_URI_DEFAULT as
|
|
11
|
-
import
|
|
12
|
-
import { createUploadLink as
|
|
13
|
-
import { hasCustomApolloErrorHandler as
|
|
9
|
+
import { tap as A } from "rxjs";
|
|
10
|
+
import { GRAPHQL_URI_DEFAULT as c } from "./apollo-client.constant.js";
|
|
11
|
+
import f from "./apollo-client.module.scss.js";
|
|
12
|
+
import { createUploadLink as T } from "./links/upload.js";
|
|
13
|
+
import { hasCustomApolloErrorHandler as U, showGlobalApolloError as u } from "../apollo-error/apollo-error.util.js";
|
|
14
14
|
import { log as s } from "../log/log.util.js";
|
|
15
|
-
import { toast as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (var o of w(e))
|
|
21
|
-
U.call(e, o) && L(r, o, e[o]);
|
|
22
|
-
return r;
|
|
23
|
-
};
|
|
24
|
-
const R = new m((r, e) => (r.setContext({ start: /* @__PURE__ */ new Date() }), e(r).pipe(
|
|
25
|
-
N(() => {
|
|
26
|
-
const o = (/* @__PURE__ */ new Date()).getTime() - r.getContext().start;
|
|
27
|
-
s.info(`Operation ${r.operationName} took ${o}ms to complete`);
|
|
15
|
+
import { toast as L } from "react-hot-toast";
|
|
16
|
+
const R = new a((o, e) => (o.setContext({ start: /* @__PURE__ */ new Date() }), e(o).pipe(
|
|
17
|
+
A(() => {
|
|
18
|
+
const t = (/* @__PURE__ */ new Date()).getTime() - o.getContext().start;
|
|
19
|
+
s.info(`Operation ${o.operationName} took ${t}ms to complete`);
|
|
28
20
|
})
|
|
29
|
-
))),
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`[GraphQL error] ${
|
|
21
|
+
))), S = new C(({ error: o, operation: e }) => {
|
|
22
|
+
const t = e?.operationName || "Unknown";
|
|
23
|
+
let i = "";
|
|
24
|
+
h.is(o) ? o.errors.forEach(({ message: r, locations: n, path: l }, m) => {
|
|
25
|
+
m === 0 && (i = r), s.error(
|
|
26
|
+
`[GraphQL error] ${t}: ${r}, Location: ${JSON.stringify(n, null, 4)}, Path: ${l}`
|
|
35
27
|
);
|
|
36
|
-
}) : E.is(
|
|
37
|
-
l === 0 && (
|
|
38
|
-
`[Protocol error]: ${
|
|
28
|
+
}) : E.is(o) ? o.errors.forEach(({ message: r, extensions: n }, l) => {
|
|
29
|
+
l === 0 && (i = r), s.error(
|
|
30
|
+
`[Protocol error]: ${r}, Extensions: ${JSON.stringify(n, null, 4)}`
|
|
39
31
|
);
|
|
40
|
-
}) :
|
|
32
|
+
}) : g.is(o) ? (i = o.message, s.error(`[Server error]: ${o.message}`)) : (i = o.message, s.error(`[Network error]: ${o.message}`)), o && i && typeof window < "u" && (U() ? u(o) : L.error((r) => /* @__PURE__ */ p.createElement("div", { className: f["error-container"] }, i, /* @__PURE__ */ p.createElement(
|
|
41
33
|
"button",
|
|
42
34
|
{
|
|
43
35
|
type: "button",
|
|
44
|
-
className:
|
|
36
|
+
className: f["error-details-button"],
|
|
45
37
|
onClick: () => {
|
|
46
|
-
u(
|
|
38
|
+
u(o), L.dismiss(r.id);
|
|
47
39
|
}
|
|
48
40
|
},
|
|
49
41
|
"Error Details"
|
|
50
42
|
))));
|
|
51
43
|
});
|
|
52
|
-
function
|
|
53
|
-
const { uri: e, wsUrl:
|
|
54
|
-
e || s.warn(`[Apollo] No GraphQL URI provided — using "${
|
|
55
|
-
const
|
|
56
|
-
uri: e
|
|
44
|
+
function v(o) {
|
|
45
|
+
const { uri: e, wsUrl: t, customLinks: i } = o, r = new y();
|
|
46
|
+
e || s.warn(`[Apollo] No GraphQL URI provided — using "${c}" as default`);
|
|
47
|
+
const n = T({
|
|
48
|
+
uri: e ?? c,
|
|
57
49
|
credentials: "include",
|
|
58
50
|
headers: {
|
|
59
51
|
"apollo-require-preflight": "true"
|
|
60
52
|
}
|
|
61
|
-
}), l =
|
|
62
|
-
({ operationType: k }) => k ===
|
|
53
|
+
}), l = t ? new N(b({ url: t })) : a.empty(), m = t ? a.split(
|
|
54
|
+
({ operationType: k }) => k === $.SUBSCRIPTION,
|
|
63
55
|
l,
|
|
64
|
-
|
|
65
|
-
) :
|
|
66
|
-
return
|
|
56
|
+
n
|
|
57
|
+
) : n;
|
|
58
|
+
return t && m === n && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
|
|
67
59
|
R,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
...
|
|
71
|
-
|
|
60
|
+
S,
|
|
61
|
+
r,
|
|
62
|
+
...i ?? [],
|
|
63
|
+
m
|
|
72
64
|
];
|
|
73
65
|
}
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
76
|
-
return new
|
|
66
|
+
function B(o) {
|
|
67
|
+
const e = a.from(v(o));
|
|
68
|
+
return new d({
|
|
77
69
|
link: e,
|
|
78
|
-
cache: new
|
|
79
|
-
|
|
70
|
+
cache: new w(),
|
|
71
|
+
...o
|
|
72
|
+
});
|
|
80
73
|
}
|
|
81
74
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
v as createApolloLinks,
|
|
76
|
+
B as getClient
|
|
84
77
|
};
|
|
78
|
+
//# sourceMappingURL=apollo-client.util.js.map
|