@cyberskill/shared 3.0.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 +1 -0
- 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.js +1 -0
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +1 -0
- 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 +1 -0
- 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 +1 -0
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.js +1 -0
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +110 -102
- 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 +53 -35
- 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 +1 -0
- 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 +1 -0
- 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 +106 -363
- 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 +20 -20
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +1 -0
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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/{ts.util.js → ws.util.js} +1 -0
- package/dist/node/ws/ws.util.js.map +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 +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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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.util.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- package/dist/react/userback/userback.component.js.map +1 -0
- 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.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.js +1 -0
- 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 +58 -87
- 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 -858
- 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_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.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.util.js","sources":["../../../src/util/object/object.util.ts"],"sourcesContent":["/**\n * Check if a string is a valid JSON string.\n * This function attempts to parse the string as JSON and returns true if successful,\n * false if the string is not valid JSON.\n *\n * @param str - The string to check for valid JSON format.\n * @returns True if the string is a valid JSON string, false otherwise.\n */\nexport function isJSON(str: string): boolean {\n try {\n JSON.parse(str);\n return true;\n }\n catch {\n return false;\n }\n}\n\n/**\n * Gets a nested value from an object using a path array.\n * This function traverses the object following the provided path and returns\n * the value at the specified location, or undefined if the path doesn't exist.\n *\n * @param obj - The object to get the value from.\n * @param path - An array of keys representing the path to the desired value.\n * @returns The value at the specified path, or undefined if the path doesn't exist.\n */\nexport function getNestedValue<T>(obj: T, path: (string | number)[]): unknown {\n // Optimization: Loop is faster than reduce and allows early exit\n let current: unknown = obj;\n const len = path.length;\n\n for (let i = 0; i < len; i++) {\n // Optimization: Early return if current value is null/undefined or not an object\n // This avoids unnecessary key lookups and type checks\n if (current == null || typeof current !== 'object') {\n return undefined;\n }\n\n const key = path[i];\n\n if (key !== undefined && key in (current as Record<string | number, unknown>)) {\n current = (current as Record<string | number, unknown>)[key];\n }\n else {\n return undefined;\n }\n }\n\n return current;\n}\n\nfunction setNestedValueHelper<T>(obj: T, path: (string | number)[], value: unknown, index: number): T {\n if (index >= path.length)\n return obj;\n\n const head = path[index];\n\n if (index === path.length - 1) {\n return {\n ...(obj as Record<string | number, unknown>),\n [head as string | number]: value,\n } as T;\n }\n\n const current = (obj as Record<string | number, unknown>)[head as string | number];\n\n return {\n ...(obj as Record<string | number, unknown>),\n [head as string | number | symbol]: setNestedValueHelper(\n typeof current === 'object' && current !== null\n ? (current as object)\n : {},\n path,\n value,\n index + 1,\n ),\n } as T;\n}\n\n/**\n * Sets a nested value in an object using a path array.\n * This function creates the path if it doesn't exist and sets the value at the specified location.\n * The function returns a new object with the updated value, maintaining immutability.\n *\n * @param obj - The object to set the value in.\n * @param path - An array of keys representing the path to the desired location.\n * @param value - The value to set at the specified path.\n * @returns A new object with the updated value at the specified path.\n */\nexport function setNestedValue<T>(obj: T, path: (string | number)[], value: unknown): T {\n if (path.length === 0)\n return obj;\n\n return setNestedValueHelper(obj, path, value, 0);\n}\n\n/**\n * Deep clones an object or array.\n * This function creates a deep copy of the input, recursively cloning objects and arrays.\n * Primitive values, dates, and other non-plain objects are returned as is (or cloned if supported).\n * Note: This implementation focuses on plain objects and arrays. For complex types like Map/Set/Buffer/ObjectId,\n * it returns the reference or handles them according to specific logic.\n *\n * @param obj - The object to clone.\n * @returns A deep copy of the object.\n */\nexport function deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as unknown as T;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as unknown as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as unknown as T;\n }\n\n // Handle Mongoose ObjectId and other custom classes by returning reference\n // structuredClone would fail here. We assume if it's not a plain object, we keep the reference\n // unless we want to implement specific cloning logic for every type.\n // However, we want to clone POJOs (Plain Old JavaScript Objects).\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n return obj;\n }\n\n const result = {} as Record<string, unknown>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n }\n\n return result as T;\n}\n\n/**\n * Deep merges multiple objects into a single object.\n * @param args - The objects to merge. Can be empty, in which case returns an empty object.\n * @returns The merged object.\n */\nexport function deepMerge<T = Record<string, unknown>>(\n ...args: (object | null | undefined)[]\n): T;\n\n/**\n * Deep merges multiple arrays into a single array.\n * @param args - The arrays to merge. Can be empty, in which case returns an empty array.\n * @returns The merged array.\n */\nexport function deepMerge<T = unknown[]>(\n ...args: (unknown[] | null | undefined)[]\n): T;\n\n/**\n * Implementation of deepMerge function.\n * @param args - The objects or arrays to merge.\n * @returns The merged result.\n */\nexport function deepMerge<T = Record<string, unknown> | unknown[]>(\n ...args: (object | unknown[] | null | undefined)[]\n): T {\n // Handle empty arguments\n if (args.length === 0) {\n return {} as T;\n }\n\n // Filter out null/undefined and convert to empty objects/arrays\n const validArgs = args.filter((arg): arg is object => arg !== null && arg !== undefined);\n\n // If no valid arguments after filtering, return empty object/array\n if (validArgs.length === 0) {\n return {} as T;\n }\n\n // If only one argument, return it directly\n if (validArgs.length === 1) {\n return validArgs[0] as T;\n }\n\n // Check if all arguments are arrays\n if (validArgs.every(Array.isArray)) {\n return ([] as unknown[]).concat(...validArgs) as T;\n }\n\n // Check if all arguments are objects (but not arrays)\n if (validArgs.every(arg => typeof arg === 'object' && arg !== null && !Array.isArray(arg))) {\n const result = {} as Record<string, unknown>;\n\n for (const arg of validArgs) {\n const obj = arg as Record<string, unknown>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n if (Object.prototype.hasOwnProperty.call(result, key)) {\n const existingValue = result[key];\n if (\n typeof value === 'object' && value !== null\n && typeof existingValue === 'object' && existingValue !== null\n ) {\n if (Array.isArray(value) && Array.isArray(existingValue)) {\n result[key] = existingValue.concat(value);\n }\n else if (!Array.isArray(value) && !Array.isArray(existingValue)) {\n result[key] = deepMerge(\n existingValue as Record<string, unknown>,\n value as Record<string, unknown>,\n );\n }\n else {\n // One is array, other is object (shouldn't happen with strict types but possible)\n // Overwrite\n result[key] = value;\n }\n }\n else {\n result[key] = value;\n }\n }\n else {\n result[key] = value;\n }\n }\n }\n }\n return result as T;\n }\n\n // Check if all arguments are primitive values\n if (validArgs.every(arg => typeof arg !== 'object' || arg === null)) {\n throw new Error(\n 'deepMerge: Cannot merge primitive values. All arguments must be objects or arrays.',\n );\n }\n\n // Mixed types error\n const hasArrays = validArgs.some(Array.isArray);\n const hasObjects = validArgs.some(arg =>\n typeof arg === 'object' && arg !== null && !Array.isArray(arg),\n );\n\n if (hasArrays && hasObjects) {\n throw new Error(\n 'deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects.',\n );\n }\n\n // Fallback for unexpected cases\n throw new Error(\n 'deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type.',\n );\n}\n\n/**\n * Normalizes MongoDB filters to support both dot notation strings and nested objects.\n * This function converts nested object filters to dot notation format while preserving\n * MongoDB operators to ensure consistent behavior across different filter input formats.\n *\n * @param filter - The filter object to normalize.\n * @returns A normalized filter object with nested objects converted to dot notation,\n * while preserving MongoDB operators as nested objects.\n *\n * @example\n * ```typescript\n * // Both of these will work the same way:\n * normalizeMongoFilter({ \"location.countryId\": \"240\" })\n * normalizeMongoFilter({ location: { countryId: \"240\" } })\n * // Both return: { \"location.countryId\": \"240\" }\n *\n * // MongoDB operators are preserved:\n * normalizeMongoFilter({ id: { $in: [\"240\", \"59\"] } })\n * // Returns: { id: { $in: [\"240\", \"59\"] } }\n * ```\n */\nexport function normalizeMongoFilter<T extends Record<string, unknown>>(filter: T): T {\n if (!filter || typeof filter !== 'object') {\n return filter;\n }\n\n const normalized: Record<string, unknown> = {};\n\n /**\n *\n */\n function flatten(current: Record<string, unknown>, prefix: string) {\n for (const key in current) {\n if (!Object.prototype.hasOwnProperty.call(current, key))\n continue;\n\n const value = current[key];\n const newKey = prefix ? `${prefix}.${key}` : key;\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n // Check for Mongo operator\n let hasMongoOperator = false;\n for (const subKey in value as Record<string, unknown>) {\n if (Object.prototype.hasOwnProperty.call(value, subKey) && subKey.startsWith('$')) {\n hasMongoOperator = true;\n break;\n }\n }\n\n if (hasMongoOperator) {\n normalized[newKey] = value;\n }\n else {\n flatten(value as Record<string, unknown>, newKey);\n }\n }\n else {\n normalized[newKey] = value;\n }\n }\n }\n\n flatten(filter, '');\n\n return normalized as T;\n}\n"],"names":["isJSON","str","getNestedValue","obj","path","current","len","i","key","setNestedValueHelper","value","index","head","setNestedValue","deepClone","item","proto","result","deepMerge","args","validArgs","arg","existingValue","hasArrays","hasObjects","normalizeMongoFilter","filter","normalized","flatten","prefix","newKey","hasMongoOperator","subKey"],"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":"serializer.util.js","sources":["../../../src/util/serializer/serializer.util.ts"],"sourcesContent":["import type {\n I_Serializer,\n I_SerializerTypeWrapper,\n I_SerializerValueMap,\n T_SerializerKnownTypes,\n} from './serializer.type.js';\n\n/**\n * Interface for handling serialization and deserialization of specific types.\n * Each handler provides methods to check if a value is of the specific type,\n * serialize it to a format that can be JSON stringified, and deserialize it back.\n */\ninterface I_Handler<T extends T_SerializerKnownTypes> {\n /** Checks if a value is of the specific type */\n is: (value: unknown) => value is I_SerializerValueMap[T];\n /** Serializes a value of the specific type to a format that can be JSON stringified */\n serialize: (value: I_SerializerValueMap[T]) => I_SerializerTypeWrapper<T>;\n /** Deserializes a value back to the specific type */\n deserialize: (value: unknown) => I_SerializerValueMap[T];\n}\n\n/**\n * Type handlers for different JavaScript types that cannot be directly serialized to JSON.\n * Each handler provides methods to serialize and deserialize specific types like Date, Map, Set, etc.\n */\nconst typeHandlers: {\n [K in T_SerializerKnownTypes]: I_Handler<K>;\n} = {\n Date: {\n is: (v): v is Date => v instanceof Date,\n serialize: v => ({ __type: 'Date', value: v.toISOString() }),\n deserialize: v => new Date(v as string),\n },\n Map: {\n is: (v): v is Map<unknown, unknown> => v instanceof Map,\n serialize: v => ({ __type: 'Map', value: Array.from(v.entries()) }),\n deserialize: v => new Map(v as [unknown, unknown][]),\n },\n Set: {\n is: (v): v is Set<unknown> => v instanceof Set,\n serialize: v => ({ __type: 'Set', value: Array.from(v) }),\n deserialize: v => new Set(v as unknown[]),\n },\n RegExp: {\n is: (v): v is RegExp => v instanceof RegExp,\n serialize: v => ({\n __type: 'RegExp',\n value: { source: v.source, flags: v.flags },\n }),\n deserialize: (v) => {\n const { source, flags } = v as { source: string; flags: string };\n return new RegExp(source, flags);\n },\n },\n BigInt: {\n is: (v): v is bigint => typeof v === 'bigint',\n serialize: v => ({ __type: 'BigInt', value: v.toString() }),\n deserialize: v => BigInt(v as string),\n },\n};\n\n/**\n * A serializer that can handle complex JavaScript types that cannot be directly JSON stringified.\n * This serializer extends JSON.stringify and JSON.parse to handle types like Date, Map, Set, RegExp, and BigInt.\n *\n * The serializer works by:\n * 1. During serialization: Wrapping special types with type information before JSON stringification\n * 2. During deserialization: Detecting wrapped types and reconstructing them to their original form\n */\nexport const serializer: I_Serializer<unknown> = {\n /**\n * Serializes a value to a JSON string.\n * If the value is of a known type (Date, Map, Set, RegExp, BigInt),\n * it will be serialized using the corresponding handler.\n * Otherwise, it will be serialized as is.\n *\n * @param value - The value to serialize to a JSON string.\n * @returns The serialized JSON string that can be safely stored or transmitted.\n */\n serialize(value) {\n return JSON.stringify(value, function (_key, val) {\n // eslint-disable-next-line ts/no-this-alias\n const context = this;\n const originalValue = context[_key];\n\n if (originalValue instanceof Date) {\n return typeHandlers.Date.serialize(originalValue);\n }\n\n for (const type of Object.keys(typeHandlers) as T_SerializerKnownTypes[]) {\n const handler = typeHandlers[type];\n\n if (handler.is(val)) {\n return (handler as I_Handler<typeof type>).serialize(val);\n }\n }\n\n return val;\n });\n },\n /**\n * Deserializes a JSON string to its original value.\n * If the value is of a known type (Date, Map, Set, RegExp, BigInt),\n * it will be deserialized using the corresponding handler.\n * Otherwise, it will be deserialized as is.\n *\n * @param json - The JSON string to deserialize back to its original form.\n * @returns The deserialized value with all special types reconstructed.\n */\n deserialize(json) {\n return JSON.parse(json, (_key, val) => {\n if (\n val\n && typeof val === 'object'\n && '__type' in val\n && typeof val.__type === 'string'\n ) {\n const type = val.__type as T_SerializerKnownTypes;\n const handler = typeHandlers[type];\n\n if (handler) {\n return handler.deserialize(val.value);\n }\n }\n return val;\n });\n },\n};\n"],"names":["typeHandlers","v","source","flags","serializer","value","_key","val","originalValue","type","handler","json"],"mappings":"AAyBA,MAAMA,IAEF;AAAA,EACA,MAAM;AAAA,IACF,IAAI,CAACC,MAAiBA,aAAa;AAAA,IACnC,WAAW,QAAM,EAAE,QAAQ,QAAQ,OAAOA,EAAE;IAC5C,aAAa,CAAAA,MAAK,IAAI,KAAKA,CAAW;AAAA,EAAA;AAAA,EAE1C,KAAK;AAAA,IACD,IAAI,CAACA,MAAkCA,aAAa;AAAA,IACpD,WAAW,CAAAA,OAAM,EAAE,QAAQ,OAAO,OAAO,MAAM,KAAKA,EAAE,QAAA,CAAS,EAAA;AAAA,IAC/D,aAAa,CAAAA,MAAK,IAAI,IAAIA,CAAyB;AAAA,EAAA;AAAA,EAEvD,KAAK;AAAA,IACD,IAAI,CAACA,MAAyBA,aAAa;AAAA,IAC3C,WAAW,QAAM,EAAE,QAAQ,OAAO,OAAO,MAAM,KAAKA,CAAC;IACrD,aAAa,CAAAA,MAAK,IAAI,IAAIA,CAAc;AAAA,EAAA;AAAA,EAE5C,QAAQ;AAAA,IACJ,IAAI,CAACA,MAAmBA,aAAa;AAAA,IACrC,WAAW,CAAAA,OAAM;AAAA,MACb,QAAQ;AAAA,MACR,OAAO,EAAE,QAAQA,EAAE,QAAQ,OAAOA,EAAE,MAAA;AAAA,IAAM;AAAA,IAE9C,aAAa,CAACA,MAAM;AAChB,YAAM,EAAE,QAAAC,GAAQ,OAAAC,EAAA,IAAUF;AAC1B,aAAO,IAAI,OAAOC,GAAQC,CAAK;AAAA,IACnC;AAAA,EAAA;AAAA,EAEJ,QAAQ;AAAA,IACJ,IAAI,CAACF,MAAmB,OAAOA,KAAM;AAAA,IACrC,WAAW,QAAM,EAAE,QAAQ,UAAU,OAAOA,EAAE;IAC9C,aAAa,CAAAA,MAAK,OAAOA,CAAW;AAAA,EAAA;AAE5C,GAUaG,IAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU7C,UAAUC,GAAO;AACb,WAAO,KAAK,UAAUA,GAAO,SAAUC,GAAMC,GAAK;AAG9C,YAAMC,IADU,KACcF,CAAI;AAElC,UAAIE,aAAyB;AACzB,eAAOR,EAAa,KAAK,UAAUQ,CAAa;AAGpD,iBAAWC,KAAQ,OAAO,KAAKT,CAAY,GAA+B;AACtE,cAAMU,IAAUV,EAAaS,CAAI;AAEjC,YAAIC,EAAQ,GAAGH,CAAG;AACd,iBAAQG,EAAmC,UAAUH,CAAG;AAAA,MAEhE;AAEA,aAAOA;AAAA,IACX,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,YAAYI,GAAM;AACd,WAAO,KAAK,MAAMA,GAAM,CAACL,GAAMC,MAAQ;AACnC,UACIA,KACG,OAAOA,KAAQ,YACf,YAAYA,KACZ,OAAOA,EAAI,UAAW,UAC3B;AACE,cAAME,IAAOF,EAAI,QACXG,IAAUV,EAAaS,CAAI;AAEjC,YAAIC;AACA,iBAAOA,EAAQ,YAAYH,EAAI,KAAK;AAAA,MAE5C;AACA,aAAOA;AAAA,IACX,CAAC;AAAA,EACL;AACJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.util.js","sources":["../../../src/util/string/string.util.ts"],"sourcesContent":["import type { T_Object } from '#typescript/index.js';\n\nimport type { I_SlugifyOptions } from './string.type.js';\n\nimport { removeAccent } from '../common/common.util.js';\n\n/**\n * Generates a slug from a string.\n * The slug is a URL-friendly version of the string, removing special characters\n * and converting spaces to hyphens.\n *\n * @param input - The string to be slugified.\n * @param options - Options for slugification.\n * @returns The slugified string.\n */\nfunction slugify(input: string, options?: I_SlugifyOptions): string {\n let slug = input.trim();\n\n // 1. Remove accents\n slug = removeAccent(slug);\n\n // 2. To lower case if requested (default true)\n if (options?.lower !== false) {\n slug = slug.toLowerCase();\n }\n\n // 3. Replace invalid characters with space (keeping alphanumeric, hyphens, and spaces)\n slug = slug.replace(/[^a-z0-9\\s-]/gi, ' ');\n\n // 4. Replace multiple spaces or hyphens with a single hyphen\n slug = slug.replace(/[\\s-]+/g, '-');\n\n // 5. Remove leading/trailing hyphens\n slug = slug.replace(/^-+|-+$/g, '');\n\n return slug;\n}\n\n/**\n * Generates a slug from a string or an object containing strings.\n * The slug is a URL-friendly version of the string, removing special characters\n * and converting spaces to hyphens. This function can handle both single strings\n * and objects with string values.\n *\n * @param input - The string or object to be slugified.\n * @param options - Options for slugification including replacement character, case sensitivity, locale, etc.\n * @returns The slugified string or object with the same structure as the input.\n */\nexport function generateSlug<T = string>(\n input: T,\n options?: I_SlugifyOptions,\n): T {\n const slugifyWithOptions = (value: string) =>\n slugify(value ?? '', options);\n\n if (typeof input === 'object' && input !== null) {\n const result: T_Object = {};\n\n for (const [key, value] of Object.entries(input)) {\n result[key] = slugifyWithOptions(value as string);\n }\n\n return result as T;\n }\n\n return slugifyWithOptions(input as string) as T;\n}\n\n/**\n * Generates a short ID from a UUID.\n * The ID is a substring of the UUID, providing a shorter identifier.\n * Note: This is NOT cryptographically secure and collisions are possible,\n * but suitable for display purposes where uniqueness is handled elsewhere.\n *\n * @param uuid - The UUID to be converted to a short ID.\n * @param length - The desired length of the short ID (default: 4 characters).\n * @returns A short ID string of the specified length derived from the UUID.\n */\nexport function generateShortId(uuid: string, length = 4): string {\n // Simple hash function (FNV-1a variant) to generate a hex string from the UUID\n let hash = 0x811C9DC5;\n for (let i = 0; i < uuid.length; i++) {\n hash ^= uuid.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n // Convert to unsigned 32-bit integer hex string\n const hex = (hash >>> 0).toString(16).padStart(8, '0');\n\n // If we need more than 8 chars, we can just append part of the original UUID (stripped of dashes)\n // or use a different strategy. For short IDs (usually < 8), the hash is fine.\n // If length > 8, we fallback to just slicing the clean UUID.\n if (length > 8) {\n return uuid.replace(/-/g, '').slice(0, length);\n }\n\n return hex.slice(0, length);\n}\n\n/**\n * Internal helper that fills `length` characters from `charset` using\n * rejection-sampling over `crypto.getRandomValues` to avoid modulo bias.\n * Random values are requested in bounded chunks to keep allocations small.\n *\n * @param length - Number of characters to generate.\n * @param charset - The pool of characters to draw from.\n * @returns A randomly generated string of the requested length.\n */\nfunction generateRandomFromCharset(length: number, charset: string): string {\n const limit = Math.floor(2 ** 32 / charset.length) * charset.length;\n const result: string[] = [];\n const MAX_UINT32_VALUES_PER_CALL = 16384;\n\n while (result.length < length) {\n const remaining = length - result.length;\n const chunkSize = remaining > MAX_UINT32_VALUES_PER_CALL ? MAX_UINT32_VALUES_PER_CALL : remaining;\n const values = new Uint32Array(chunkSize);\n crypto.getRandomValues(values);\n\n for (const value of values) {\n if (result.length >= length) {\n break;\n }\n if (value < limit) {\n result.push(charset[value % charset.length] as string);\n }\n }\n }\n\n return result.join('');\n}\n\n/**\n * Generates a random password of a given length.\n * The password contains a mix of letters (both cases), numbers, and special characters\n * to ensure complexity and security.\n *\n * @param length - The desired length of the password (default: 8 characters).\n * @returns A randomly generated password string with the specified length.\n * @throws {RangeError} If `length` is not a non-negative safe integer.\n */\nexport function generateRandomPassword(length = 8): string {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new RangeError('length must be a non-negative safe integer');\n }\n\n const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?';\n\n return generateRandomFromCharset(length, charset);\n}\n\n/**\n * Generates a random string of a given length using a secure random number generator.\n * This function is a cryptographically secure alternative to Math.random().toString(36).\n *\n * @param length - The desired length of the string (default: 8 characters).\n * @param charset - The characters to use (default: lowercase alphanumeric).\n * @returns A randomly generated string.\n * @throws {RangeError} If `length` is not a non-negative safe integer.\n * @throws {RangeError} If `charset` is empty or exceeds 2^32 characters.\n */\nexport function generateRandomString(\n length = 8,\n charset = 'abcdefghijklmnopqrstuvwxyz0123456789',\n): string {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new RangeError('length must be a non-negative safe integer');\n }\n\n if (charset.length === 0 || charset.length > 2 ** 32) {\n throw new RangeError('charset.length must be between 1 and 2^32');\n }\n\n return generateRandomFromCharset(length, charset);\n}\n\n/**\n * Get the file name from a URL.\n * This function extracts the file name from a URL, optionally including or excluding\n * the file extension. It handles URLs with query parameters and fragments.\n *\n * @param url - The URL to extract the file name from (default: empty string).\n * @param getExtension - Whether to include the file extension in the result (default: false).\n * @returns The file name extracted from the URL, with or without the extension.\n */\nexport function getFileName(url = '', getExtension = false): string {\n const withoutQuery = url.split(/[?#]/)[0] || '';\n const fileName = withoutQuery.substring(withoutQuery.lastIndexOf('/') + 1);\n\n if (getExtension) {\n return fileName;\n }\n\n const dotIndex = fileName.lastIndexOf('.');\n\n return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;\n}\n\n/**\n * Extracts a substring between two strings.\n * This function finds the first occurrence of the starting string, then finds the first\n * occurrence of the ending string after the starting string, and returns the content between them.\n *\n * @param s - The original string to search within.\n * @param a - The starting string that marks the beginning of the desired substring.\n * @param b - The ending string that marks the end of the desired substring.\n * @returns The substring between the two specified strings, or an empty string if either string is not found.\n */\nexport function substringBetween(s: string, a: string, b: string): string {\n const start = s.indexOf(a);\n\n if (start === -1) {\n return '';\n }\n\n const from = start + a.length;\n const end = s.indexOf(b, from);\n\n if (end === -1) {\n return '';\n }\n\n return s.slice(from, end);\n}\n"],"names":["removeAccent","slugify","input","options","slug","generateSlug","slugifyWithOptions","value","result","key","generateShortId","uuid","length","hash","i","hex","generateRandomFromCharset","charset","limit","MAX_UINT32_VALUES_PER_CALL","remaining","chunkSize","values","generateRandomPassword","generateRandomString","getFileName","url","getExtension","withoutQuery","fileName","dotIndex","substringBetween","s","a","b","start","from","end"],"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":"validate.util.js","sources":["../../../src/util/validate/validate.util.ts"],"sourcesContent":["/**\n * A collection of validation utility functions for common data validation tasks.\n * This object provides methods to validate various data types and formats.\n */\nexport const validate = {\n /**\n * Checks if a value is empty.\n * This function provides comprehensive empty checking for different data types:\n * - For strings, it checks if the string is empty or contains only whitespace.\n * - For arrays, it checks if the array has no elements.\n * - For objects, it checks if the object has no own properties.\n * - For Maps and Sets, it checks if they are empty.\n * - For WeakMaps and WeakSets, it returns true (as they are not enumerable).\n * - For ArrayBuffer views, it checks if the byte length is 0.\n * - For Dates, it returns false.\n * - For null and undefined, it returns true.\n * - For all other types, it returns false.\n *\n * @param value - The value to check for emptiness.\n * @returns True if the value is empty, false otherwise.\n */\n isEmpty(value: unknown): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n\n if (typeof value === 'string') {\n return value.trim().length === 0;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (typeof value === 'object') {\n if (value instanceof Date) {\n return false;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (value instanceof WeakMap || value instanceof WeakSet) {\n return true;\n }\n\n if (ArrayBuffer.isView(value)) {\n return value.byteLength === 0;\n }\n\n return Object.keys(value).length === 0;\n }\n\n return false;\n },\n /**\n * Checks if a string is a valid IP address (IPv4 or IPv6).\n * This function validates IP addresses according to standard formats:\n * - IPv4: Four octets separated by dots, each between 0–255.\n * - IPv6: Eight groups of four hex digits, possibly compressed with `::`.\n *\n * @param ip - The IP address string to validate.\n * @returns True if the IP is valid IPv4 or IPv6, false otherwise.\n */\n isValidIP(ip: string): boolean {\n const ipv4Parts = ip.split('.');\n\n if (ipv4Parts.length === 4 && ipv4Parts.every(octet =>\n /^\\d+$/.test(octet)\n && Number(octet) >= 0\n && Number(octet) <= 255,\n )) {\n return true;\n }\n\n const ipv6Regex = /^(?:(?:[a-f\\d]{1,4}:){7}(?:[a-f\\d]{1,4}|:)|(?:[a-f\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-f\\d]{1,4}|:)|(?:[a-f\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,2}|:)|(?:[a-f\\d]{1,4}:){4}(?:(?::[a-f\\d]{1,4})?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,3}|:)|(?:[a-f\\d]{1,4}:){3}(?:(?::[a-f\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,4}|:)|(?:[a-f\\d]{1,4}:){2}(?:(?::[a-f\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,5}|:)|[a-f\\d]{1,4}:(?:(?::[a-f\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,6}|:)|:(?:(?::[a-f\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-f\\d]{1,4}){1,7}|:))(?:%[0-9a-z]+)?$/i;\n\n return ipv6Regex.test(ip);\n },\n};\n"],"names":["validate","value","ip","ipv4Parts","octet"],"mappings":"AAIO,MAAMA,IAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBpB,QAAQC,GAAyB;AAC7B,WAAIA,KAAU,OACH,KAGP,OAAOA,KAAU,WACVA,EAAM,OAAO,WAAW,IAG/B,MAAM,QAAQA,CAAK,IACZA,EAAM,WAAW,IAGxB,OAAOA,KAAU,WACbA,aAAiB,OACV,KAGPA,aAAiB,OAAOA,aAAiB,MAClCA,EAAM,SAAS,IAGtBA,aAAiB,WAAWA,aAAiB,UACtC,KAGP,YAAY,OAAOA,CAAK,IACjBA,EAAM,eAAe,IAGzB,OAAO,KAAKA,CAAK,EAAE,WAAW,IAGlC;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,UAAUC,GAAqB;AAC3B,UAAMC,IAAYD,EAAG,MAAM,GAAG;AAE9B,WAAIC,EAAU,WAAW,KAAKA,EAAU;AAAA,MAAM,CAAAC,MAC1C,QAAQ,KAAKA,CAAK,KACf,OAAOA,CAAK,KAAK,KACjB,OAAOA,CAAK,KAAK;AAAA,IAAA,IAEb,KAGO,+iCAED,KAAKF,CAAE;AAAA,EAC5B;AACJ;"}
|
package/package.json
CHANGED
|
@@ -1,193 +1,160 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.0",
|
|
3
|
+
"version": "3.1.0",
|
|
5
4
|
"description": "CyberSkill Shared",
|
|
6
|
-
"author": "Stephen Cheng",
|
|
7
|
-
"license": "MIT",
|
|
8
5
|
"homepage": "https://github.com/cyberskill-world/shared#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/cyberskill-world/shared/issues"
|
|
8
|
+
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/cyberskill-world/shared.git"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Stephen Cheng",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"./dist/style.css"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
17
19
|
"exports": {
|
|
18
20
|
"./config": {
|
|
19
21
|
"types": "./dist/config/index.d.ts",
|
|
20
|
-
"import": "./dist/config/index.js"
|
|
21
|
-
"require": "./dist/config/index.cjs"
|
|
22
|
+
"import": "./dist/config/index.js"
|
|
22
23
|
},
|
|
23
24
|
"./config/commitlint": {
|
|
24
25
|
"types": "./dist/config/commitlint/index.d.ts",
|
|
25
|
-
"import": "./dist/config/commitlint/index.js"
|
|
26
|
-
"require": "./dist/config/commitlint/index.cjs"
|
|
26
|
+
"import": "./dist/config/commitlint/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./config/env": {
|
|
29
29
|
"types": "./dist/config/env/index.d.ts",
|
|
30
|
-
"import": "./dist/config/env/index.js"
|
|
31
|
-
"require": "./dist/config/env/index.cjs"
|
|
30
|
+
"import": "./dist/config/env/index.js"
|
|
32
31
|
},
|
|
33
32
|
"./config/eslint": {
|
|
34
33
|
"types": "./dist/config/eslint/index.d.ts",
|
|
35
|
-
"import": "./dist/config/eslint/index.js"
|
|
36
|
-
"require": "./dist/config/eslint/index.cjs"
|
|
34
|
+
"import": "./dist/config/eslint/index.js"
|
|
37
35
|
},
|
|
38
36
|
"./config/graphql-codegen": {
|
|
39
37
|
"types": "./dist/config/graphql-codegen/index.d.ts",
|
|
40
|
-
"import": "./dist/config/graphql-codegen/index.js"
|
|
41
|
-
"require": "./dist/config/graphql-codegen/index.cjs"
|
|
38
|
+
"import": "./dist/config/graphql-codegen/index.js"
|
|
42
39
|
},
|
|
43
40
|
"./config/lint-staged": {
|
|
44
41
|
"types": "./dist/config/lint-staged/index.d.ts",
|
|
45
|
-
"import": "./dist/config/lint-staged/index.js"
|
|
46
|
-
"require": "./dist/config/lint-staged/index.cjs"
|
|
42
|
+
"import": "./dist/config/lint-staged/index.js"
|
|
47
43
|
},
|
|
48
44
|
"./config/vitest": {
|
|
49
45
|
"types": "./dist/config/vitest/index.d.ts",
|
|
50
|
-
"import": "./dist/config/vitest/index.js"
|
|
51
|
-
"require": "./dist/config/vitest/index.cjs"
|
|
46
|
+
"import": "./dist/config/vitest/index.js"
|
|
52
47
|
},
|
|
53
48
|
"./config/storybook": {
|
|
54
49
|
"types": "./dist/config/storybook/index.d.ts",
|
|
55
|
-
"import": "./dist/config/storybook/index.js"
|
|
56
|
-
"require": "./dist/config/storybook/index.cjs"
|
|
50
|
+
"import": "./dist/config/storybook/index.js"
|
|
57
51
|
},
|
|
58
52
|
"./constant": {
|
|
59
53
|
"types": "./dist/constant/index.d.ts",
|
|
60
|
-
"import": "./dist/constant/index.js"
|
|
61
|
-
"require": "./dist/constant/index.cjs"
|
|
54
|
+
"import": "./dist/constant/index.js"
|
|
62
55
|
},
|
|
63
56
|
"./node/apollo-server": {
|
|
64
57
|
"types": "./dist/node/apollo-server/index.d.ts",
|
|
65
|
-
"import": "./dist/node/apollo-server/index.js"
|
|
66
|
-
"require": "./dist/node/apollo-server/index.cjs"
|
|
58
|
+
"import": "./dist/node/apollo-server/index.js"
|
|
67
59
|
},
|
|
68
60
|
"./node/cli": {
|
|
69
61
|
"types": "./dist/node/cli/index.d.ts",
|
|
70
|
-
"import": "./dist/node/cli/index.js"
|
|
71
|
-
"require": "./dist/node/cli/index.cjs"
|
|
62
|
+
"import": "./dist/node/cli/index.js"
|
|
72
63
|
},
|
|
73
64
|
"./node/command": {
|
|
74
65
|
"types": "./dist/node/command/index.d.ts",
|
|
75
|
-
"import": "./dist/node/command/index.js"
|
|
76
|
-
"require": "./dist/node/command/index.cjs"
|
|
66
|
+
"import": "./dist/node/command/index.js"
|
|
77
67
|
},
|
|
78
68
|
"./node/express": {
|
|
79
69
|
"types": "./dist/node/express/index.d.ts",
|
|
80
|
-
"import": "./dist/node/express/index.js"
|
|
81
|
-
"require": "./dist/node/express/index.cjs"
|
|
70
|
+
"import": "./dist/node/express/index.js"
|
|
82
71
|
},
|
|
83
72
|
"./node/fs": {
|
|
84
73
|
"types": "./dist/node/fs/index.d.ts",
|
|
85
|
-
"import": "./dist/node/fs/index.js"
|
|
86
|
-
"require": "./dist/node/fs/index.cjs"
|
|
74
|
+
"import": "./dist/node/fs/index.js"
|
|
87
75
|
},
|
|
88
76
|
"./node/log": {
|
|
89
77
|
"types": "./dist/node/log/index.d.ts",
|
|
90
|
-
"import": "./dist/node/log/index.js"
|
|
91
|
-
"require": "./dist/node/log/index.cjs"
|
|
78
|
+
"import": "./dist/node/log/index.js"
|
|
92
79
|
},
|
|
93
80
|
"./node/mongo": {
|
|
94
81
|
"types": "./dist/node/mongo/index.d.ts",
|
|
95
|
-
"import": "./dist/node/mongo/index.js"
|
|
96
|
-
"require": "./dist/node/mongo/index.cjs"
|
|
82
|
+
"import": "./dist/node/mongo/index.js"
|
|
97
83
|
},
|
|
98
84
|
"./node/package": {
|
|
99
85
|
"types": "./dist/node/package/index.d.ts",
|
|
100
|
-
"import": "./dist/node/package/index.js"
|
|
101
|
-
"require": "./dist/node/package/index.cjs"
|
|
86
|
+
"import": "./dist/node/package/index.js"
|
|
102
87
|
},
|
|
103
88
|
"./node/path": {
|
|
104
89
|
"types": "./dist/node/path/index.d.ts",
|
|
105
|
-
"import": "./dist/node/path/index.js"
|
|
106
|
-
"require": "./dist/node/path/index.cjs"
|
|
90
|
+
"import": "./dist/node/path/index.js"
|
|
107
91
|
},
|
|
108
92
|
"./node/storage": {
|
|
109
93
|
"types": "./dist/node/storage/index.d.ts",
|
|
110
|
-
"import": "./dist/node/storage/index.js"
|
|
111
|
-
"require": "./dist/node/storage/index.cjs"
|
|
94
|
+
"import": "./dist/node/storage/index.js"
|
|
112
95
|
},
|
|
113
96
|
"./node/upload": {
|
|
114
97
|
"types": "./dist/node/upload/index.d.ts",
|
|
115
|
-
"import": "./dist/node/upload/index.js"
|
|
116
|
-
"require": "./dist/node/upload/index.cjs"
|
|
98
|
+
"import": "./dist/node/upload/index.js"
|
|
117
99
|
},
|
|
118
100
|
"./node/ws": {
|
|
119
101
|
"types": "./dist/node/ws/index.d.ts",
|
|
120
|
-
"import": "./dist/node/ws/index.js"
|
|
121
|
-
"require": "./dist/node/ws/index.cjs"
|
|
102
|
+
"import": "./dist/node/ws/index.js"
|
|
122
103
|
},
|
|
123
104
|
"./react/apollo-client": {
|
|
124
105
|
"types": "./dist/react/apollo-client/index.d.ts",
|
|
125
|
-
"import": "./dist/react/apollo-client/index.js"
|
|
126
|
-
"require": "./dist/react/apollo-client/index.cjs"
|
|
106
|
+
"import": "./dist/react/apollo-client/index.js"
|
|
127
107
|
},
|
|
128
108
|
"./react/apollo-client-nextjs": {
|
|
129
109
|
"types": "./dist/react/apollo-client-nextjs/index.d.ts",
|
|
130
|
-
"import": "./dist/react/apollo-client-nextjs/index.js"
|
|
131
|
-
"require": "./dist/react/apollo-client-nextjs/index.cjs"
|
|
110
|
+
"import": "./dist/react/apollo-client-nextjs/index.js"
|
|
132
111
|
},
|
|
133
112
|
"./react/apollo-client-nextjs/rsc": {
|
|
134
113
|
"types": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts",
|
|
135
|
-
"import": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js"
|
|
136
|
-
"require": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs"
|
|
114
|
+
"import": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js"
|
|
137
115
|
},
|
|
138
116
|
"./react/apollo-error": {
|
|
139
117
|
"types": "./dist/react/apollo-error/index.d.ts",
|
|
140
|
-
"import": "./dist/react/apollo-error/index.js"
|
|
141
|
-
"require": "./dist/react/apollo-error/index.cjs"
|
|
118
|
+
"import": "./dist/react/apollo-error/index.js"
|
|
142
119
|
},
|
|
143
120
|
"./react/i18next": {
|
|
144
121
|
"types": "./dist/react/i18next/index.d.ts",
|
|
145
|
-
"import": "./dist/react/i18next/index.js"
|
|
146
|
-
"require": "./dist/react/i18next/index.cjs"
|
|
122
|
+
"import": "./dist/react/i18next/index.js"
|
|
147
123
|
},
|
|
148
124
|
"./react/loading": {
|
|
149
125
|
"types": "./dist/react/loading/index.d.ts",
|
|
150
|
-
"import": "./dist/react/loading/index.js"
|
|
151
|
-
"require": "./dist/react/loading/index.cjs"
|
|
126
|
+
"import": "./dist/react/loading/index.js"
|
|
152
127
|
},
|
|
153
128
|
"./react/log": {
|
|
154
129
|
"types": "./dist/react/log/index.d.ts",
|
|
155
|
-
"import": "./dist/react/log/index.js"
|
|
156
|
-
"require": "./dist/react/log/index.cjs"
|
|
130
|
+
"import": "./dist/react/log/index.js"
|
|
157
131
|
},
|
|
158
132
|
"./react/next-intl": {
|
|
159
133
|
"types": "./dist/react/next-intl/index.d.ts",
|
|
160
|
-
"import": "./dist/react/next-intl/index.js"
|
|
161
|
-
"require": "./dist/react/next-intl/index.cjs"
|
|
134
|
+
"import": "./dist/react/next-intl/index.js"
|
|
162
135
|
},
|
|
163
136
|
"./react/storage": {
|
|
164
137
|
"types": "./dist/react/storage/index.d.ts",
|
|
165
|
-
"import": "./dist/react/storage/index.js"
|
|
166
|
-
"require": "./dist/react/storage/index.cjs"
|
|
138
|
+
"import": "./dist/react/storage/index.js"
|
|
167
139
|
},
|
|
168
140
|
"./react/toast": {
|
|
169
141
|
"types": "./dist/react/toast/index.d.ts",
|
|
170
|
-
"import": "./dist/react/toast/index.js"
|
|
171
|
-
"require": "./dist/react/toast/index.cjs"
|
|
142
|
+
"import": "./dist/react/toast/index.js"
|
|
172
143
|
},
|
|
173
144
|
"./react/userback": {
|
|
174
145
|
"types": "./dist/react/userback/index.d.ts",
|
|
175
|
-
"import": "./dist/react/userback/index.js"
|
|
176
|
-
"require": "./dist/react/userback/index.cjs"
|
|
146
|
+
"import": "./dist/react/userback/index.js"
|
|
177
147
|
},
|
|
178
148
|
"./typescript": {
|
|
179
149
|
"types": "./dist/typescript/index.d.ts",
|
|
180
|
-
"import": "./dist/typescript/index.js"
|
|
181
|
-
"require": "./dist/typescript/index.cjs"
|
|
150
|
+
"import": "./dist/typescript/index.js"
|
|
182
151
|
},
|
|
183
152
|
"./util": {
|
|
184
153
|
"types": "./dist/util/index.d.ts",
|
|
185
|
-
"import": "./dist/util/index.js"
|
|
186
|
-
"require": "./dist/util/index.cjs"
|
|
154
|
+
"import": "./dist/util/index.js"
|
|
187
155
|
},
|
|
188
156
|
"./style.css": {
|
|
189
|
-
"import": "./dist/style.css"
|
|
190
|
-
"require": "./dist/style.css"
|
|
157
|
+
"import": "./dist/style.css"
|
|
191
158
|
}
|
|
192
159
|
},
|
|
193
160
|
"bin": {
|
|
@@ -197,9 +164,6 @@
|
|
|
197
164
|
"dist",
|
|
198
165
|
"public"
|
|
199
166
|
],
|
|
200
|
-
"engines": {
|
|
201
|
-
"node": ">=24.0.0"
|
|
202
|
-
},
|
|
203
167
|
"scripts": {
|
|
204
168
|
"ai:setup": "tsx src/node/cli/index.ts ai:setup",
|
|
205
169
|
"build": "vite build",
|
|
@@ -226,8 +190,8 @@
|
|
|
226
190
|
"@eslint-react/eslint-plugin": "2.13.0",
|
|
227
191
|
"@graphql-codegen/cli": "6.1.2",
|
|
228
192
|
"@graphql-codegen/client-preset": "5.2.3",
|
|
229
|
-
"@nestjs/common": "11.1.
|
|
230
|
-
"@nestjs/core": "11.1.
|
|
193
|
+
"@nestjs/common": "11.1.15",
|
|
194
|
+
"@nestjs/core": "11.1.15",
|
|
231
195
|
"@userback/widget": "0.3.12",
|
|
232
196
|
"@vitejs/plugin-react-swc": "4.2.3",
|
|
233
197
|
"body-parser": "2.2.2",
|
|
@@ -246,7 +210,7 @@
|
|
|
246
210
|
"express-session": "1.19.0",
|
|
247
211
|
"express-useragent": "2.1.0",
|
|
248
212
|
"extract-files": "13.0.0",
|
|
249
|
-
"fs-extra": "11.3.
|
|
213
|
+
"fs-extra": "11.3.4",
|
|
250
214
|
"globals": "17.4.0",
|
|
251
215
|
"graphql": "16.13.0",
|
|
252
216
|
"graphql-upload": "17.0.0",
|
|
@@ -261,7 +225,6 @@
|
|
|
261
225
|
"mongoose-aggregate-paginate-v2": "1.1.4",
|
|
262
226
|
"mongoose-paginate-v2": "1.9.1",
|
|
263
227
|
"next-intl": "4.8.3",
|
|
264
|
-
"node-fetch": "3.3.2",
|
|
265
228
|
"qs": "6.15.0",
|
|
266
229
|
"react": "19.2.4",
|
|
267
230
|
"react-dom": "19.2.4",
|
|
@@ -277,6 +240,9 @@
|
|
|
277
240
|
"@commitlint/config-conventional": "20.4.2",
|
|
278
241
|
"@eslint/config-inspector": "1.4.2",
|
|
279
242
|
"@next/eslint-plugin-next": "16.1.6",
|
|
243
|
+
"@semantic-release/changelog": "6.0.3",
|
|
244
|
+
"@semantic-release/git": "10.0.1",
|
|
245
|
+
"@semantic-release/github": "12.0.6",
|
|
280
246
|
"@storybook/react": "10.2.14",
|
|
281
247
|
"@storybook/react-vite": "10.2.14",
|
|
282
248
|
"@testing-library/jest-dom": "6.9.1",
|
|
@@ -301,10 +267,12 @@
|
|
|
301
267
|
"eslint": "10.0.2",
|
|
302
268
|
"eslint-config-next": "16.1.6",
|
|
303
269
|
"glob": "13.0.6",
|
|
270
|
+
"jsdom": "28.1.0",
|
|
304
271
|
"lint-staged": "16.3.1",
|
|
305
272
|
"node-modules-inspector": "1.3.2",
|
|
306
273
|
"npm-run-all2": "8.0.4",
|
|
307
274
|
"sass": "1.97.3",
|
|
275
|
+
"semantic-release": "25.0.3",
|
|
308
276
|
"simple-git-hooks": "2.13.1",
|
|
309
277
|
"tsx": "4.21.0",
|
|
310
278
|
"typescript": "5.9.3",
|
|
@@ -312,10 +280,13 @@
|
|
|
312
280
|
"vite-plugin-dts": "4.5.4",
|
|
313
281
|
"vitest": "4.0.18"
|
|
314
282
|
},
|
|
283
|
+
"engines": {
|
|
284
|
+
"node": ">=24.0.0"
|
|
285
|
+
},
|
|
315
286
|
"publishConfig": {
|
|
316
287
|
"access": "public",
|
|
317
|
-
"
|
|
318
|
-
"
|
|
288
|
+
"provenance": true,
|
|
289
|
+
"registry": "https://registry.npmjs.org/"
|
|
319
290
|
},
|
|
320
291
|
"pnpm": {
|
|
321
292
|
"overrides": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={extends:["@commitlint/config-conventional"],ignores:[e=>e.includes("[🚀 CI - Deploy]")]};exports.default=t;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.E_ConfigType=(t=>(t.ESLINT="eslint",t.COMMITLINT="commitlint",t.LINT_STAGED="lint-staged",t.VITEST_REACT_E2E="vitest-react-e2e",t.VITEST_REACT_UNIT="vitest-react-unit",t))(exports.E_ConfigType||{});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@antfu/eslint-config"),n=require("./config.type.cjs"),i=require("./eslint/index.cjs"),f=require("./vitest/vitest.e2e.cjs"),g=require("./vitest/vitest.unit.cjs"),o=require("../util/object/object.util.cjs"),T=(...e)=>{const t=o.deepMerge(...Array.isArray(i.default)?i.default:[i.default],...e),{ignores:r,...s}=t;return u({stylistic:{semi:!0,indent:4},formatters:!0,yaml:!1,react:!0},s,...Array.isArray(r)?[{ignores:r}]:[])},a={[n.E_ConfigType.ESLINT]:e=>T(e),[n.E_ConfigType.COMMITLINT]:e=>o.deepMerge(e),[n.E_ConfigType.LINT_STAGED]:e=>o.deepMerge(e),[n.E_ConfigType.VITEST_REACT_UNIT]:e=>g.vitestUnit(e),[n.E_ConfigType.VITEST_REACT_E2E]:e=>f.vitestE2E(e)};function E(e,...t){const r=a[e];if(!t||t.length===0)return r({});if(!r)throw new Error(`Unknown config type: ${e}`);return r(...t)}exports.mergeConfigs=E;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=".cyberskill-storage";exports.CYBERSKILL_STORAGE_DIRECTORY=e;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@dotenvx/dotenvx"),n=require("envalid"),i=require("node:os"),a=require("node:path"),r=require("node:process"),l=require("./env.constant.cjs"),u=require("../../typescript/common.type.cjs");let t=!1;const d=n.makeValidator(e=>typeof e=="boolean"?e:typeof e=="string");function o(){r.env.NODE_ENV!==u.E_Environment.PRODUCTION&&!t&&(E.config(),t=!0)}function s(){o();const e=n.cleanEnv(r.env,{CWD:n.str({default:r.cwd()}),DEBUG:d({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:n.str({default:a.join(i.homedir(),l.CYBERSKILL_STORAGE_DIRECTORY)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}exports.getEnv=s;exports.loadEnvFile=o;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./env.constant.cjs"),e=require("./env.util.cjs");exports.CYBERSKILL_STORAGE_DIRECTORY=t.CYBERSKILL_STORAGE_DIRECTORY;exports.getEnv=e.getEnv;exports.loadEnvFile=e.loadEnvFile;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("globals");function s(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const r=s(l),a=[{languageOptions:{globals:{...r.node,...r.browser}},rules:{"perfectionist/sort-imports":["error",{internalPattern:["^#.*","^@/.*"]}],"dot-notation":"off"},ignores:["**/node_modules/**","**/.git/**","build","dist",".agent"]}];exports.default=a;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@eddeee888/gcg-typescript-resolver-files"),c=require("../env/env.util.cjs");c.loadEnvFile();function u({uri:t,from:i,to:e,target:n="client"}){const r=n==="client",o=n==="server";return{schema:t,ignoreNoDocuments:!0,overwrite:!0,...r&&{documents:[i]},generates:{...r&&{[e]:{preset:"client",presetConfig:{fragmentMasking:!1,persistedDocuments:!0},config:{useTypeImports:!0,namingConvention:"keep"}}},...o&&{[e]:s.defineConfig()}}}}exports.createGraphqlCodegenConfig=u;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./graphql-codegen.util.cjs");exports.createGraphqlCodegenConfig=e.createGraphqlCodegenConfig;
|
package/dist/config/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.type.cjs"),r=require("./config.util.cjs");Object.defineProperty(exports,"E_ConfigType",{enumerable:!0,get:()=>e.E_ConfigType});exports.mergeConfigs=r.mergeConfigs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"*.ts":()=>"tsc --noEmit","*":["eslint --fix --no-cache"]};exports.default=e;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./storybook.main.cjs"),e=require("./storybook.preview.cjs");exports.storybookMain=o.storybookMain;exports.storybookPreview=e.storybookPreview;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../util/object/object.util.cjs");function e(o){const t={stories:["../src/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"],addons:["@storybook/addon-essentials","@storybook/addon-interactions","@storybook/addon-links"],framework:{name:"@storybook/react-vite",options:{}}};return s.deepMerge(t,o)}exports.storybookMain=e;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(e){const r={parameters:{controls:{matchers:{color:/(background|color)$/i,date:/Date$/i}},backgrounds:{default:"light",values:[{name:"light",value:"#ffffff"},{name:"dark",value:"#333333"}]}}};return{...r,...e,parameters:{...r.parameters,...e?.parameters}}}exports.storybookPreview=a;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./vitest.e2e.cjs"),e=require("./vitest.unit.cjs");exports.vitestE2E=t.vitestE2E;exports.vitestUnit=e.vitestUnit;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("../../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.cjs"),o=require("../../util/object/object.util.cjs");function n(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return i.defineConfig(o.deepMerge(r,e))}exports.vitestE2E=n;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@vitejs/plugin-react-swc"),i=require("../../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.cjs"),s=require("../../util/object/object.util.cjs");function n(e){const t={plugins:[r()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"],coverage:{provider:"istanbul",reporter:["text","lcov"],reportsDirectory:"./coverage",thresholds:{statements:80,branches:80,functions:80,lines:80}}}};return i.defineConfig(s.deepMerge(t,e))}exports.vitestUnit=n;
|
package/dist/constant/common.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=typeof window<"u";exports.IS_BROWSER=e;
|
package/dist/constant/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./common.cjs"),e=require("./response-status.cjs");exports.IS_BROWSER=S.IS_BROWSER;exports.RESPONSE_STATUS=e.RESPONSE_STATUS;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};exports.RESPONSE_STATUS=E;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@apollo/server"),a=require("@apollo/server/plugin/drainHttpServer"),r=require("@apollo/server/plugin/landingPage/default"),n=require("../log/log.util.cjs");function t(e){return new l.ApolloServer({schema:e.schema,plugins:[e.isDev?r.ApolloServerPluginLandingPageLocalDefault():r.ApolloServerPluginLandingPageProductionDefault(),a.ApolloServerPluginDrainHttpServer({httpServer:e.server}),...e.drainServer?[{async serverWillStart(){return{async drainServer(){e.drainServer?.(),n.log.info("Apollo Server drainServer hook called")}}}}]:[]],...e.isDev&&{introspection:!0,includeStacktraceInErrorResponses:!0}})}exports.createApolloServer=t;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./apollo-server.util.cjs"),r=require("@as-integrations/express5");exports.createApolloServer=e.createApolloServer;Object.defineProperty(exports,"expressMiddleware",{enumerable:!0,get:()=>r.expressMiddleware});
|
package/dist/node/cli/index.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";const s=require("node:process"),E=require("yargs/helpers"),C=require("yargs/yargs"),a=require("../command/command.util.cjs"),d=require("../package/package.util.cjs"),o=require("../fs/fs.util.cjs"),f=require("../path/path.util.cjs"),n=require("../path/path.constant.cjs"),r=require("../log/log.util.cjs"),u=require("../log/log.type.cjs");function h(){try{return JSON.parse(o.readFileSync(f.resolve(__dirname,"../../../package.json"),"utf-8")).version}catch{return"1.0.0"}}async function g(){o.pathExistsSync(n.PATH.TS_CONFIG)?await a.runCommand("Performing TypeScript validation",await n.command.typescriptCheck()):r.log.warn("No TypeScript configuration found. Skipping type check.")}async function p(t=!1){const i=t?await n.command.eslintFix():await n.command.eslintCheck(),c=t?"Running ESLint with auto-fix":"Running ESLint check";try{await a.runCommand(c,i,{timeout:6e4,throwOnError:!0})}catch(e){e.code==="ETIMEDOUT"||e.killed||e.signal==="SIGTERM"?(r.log.warn("Lint check timed out. Retrying with debug mode enabled..."),s.env.DEBUG="true",await a.runCommand(`${c} (Debug Mode)`,i)):r.catchError(e)}}function l(t,i){if(!i.length)return;const c=t==="Errors"?"red":"yellow";r.log.printBoxedLog(t==="Errors"?"✖ Errors":"⚠ Warnings",i,c)}async function m(){setTimeout(async()=>{const t=await a.getStoredErrorLists()||[],i=t.filter(e=>e.type===u.E_IssueType.Error),c=t.filter(e=>e.type===u.E_IssueType.Warning);!i.length&&!c.length?r.log.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(l("Warnings",c),l("Errors",i),i.length>0&&s.exit(1))},0)}async function k(){await a.clearAllErrorLists();const t=await d.getPackage({name:n.CYBERSKILL_PACKAGE_NAME});if(!t.success){r.log.error("Failed to retrieve package information. Aborting lint-staged.");return}t.result.isCurrentProject&&await a.runCommand(`Building package: ${n.CYBERSKILL_PACKAGE_NAME}`,await n.command.build()),await a.runCommand("Executing lint-staged",await n.command.lintStaged()),m()}async function A(){await a.runCommand("Inspecting ESLint configuration",await n.command.eslintInspect())}async function S(){await a.clearAllErrorLists(),await g(),await p(),m()}async function _(){await a.clearAllErrorLists(),await g(),await p(!0),m()}async function I(){await a.clearAllErrorLists(),await a.runCommand("Validating commit message",await n.command.commitLint()),m()}async function w(){await a.runCommand("Configuring Git hooks",await n.command.configureGitHook()),o.removeSync(n.PATH.GIT_HOOK);const t=await a.resolveCommands(n.createGitHooksConfig);o.writeFileSync(n.PATH.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4)),o.addGitIgnoreEntry(n.PATH.GIT_IGNORE,n.SIMPLE_GIT_HOOK_JSON),await a.runCommand("Setting up simple-git-hooks",await n.command.simpleGitHooks())}async function y(){try{await a.runCommand(`Checking for ${n.AG_KIT_PACKAGE_NAME}`,`pnpm list -g ${n.AG_KIT_PACKAGE_NAME}`)}catch{await a.runCommand(`Installing ${n.AG_KIT_PACKAGE_NAME} globally`,`pnpm i -g ${n.AG_KIT_PACKAGE_NAME}`)}o.pathExistsSync(n.PATH.DOT_AGENT)?await a.runCommand("Updating AI agent","ag-kit update -y"):await a.runCommand("Initializing AI agent","ag-kit init"),o.addGitIgnoreEntry(n.PATH.GIT_EXCLUDE,n.DOT_AGENT)}async function T(){await d.installDependencies(),await w()}async function M(){o.removeSync(n.PATH.NODE_MODULES,n.PATH.PNPM_LOCK_YAML),await a.runCommand("Pruning pnpm store",await n.command.pnpmPruneStore()),await a.runCommand("Clearing pnpm cache",await n.command.pnpmCleanCache()),await d.installDependencies(),await w(),await y()}async function L(){await a.runCommand("Inspecting project dependencies",await n.command.nodeModulesInspect())}async function G(){await a.runCommand("Running unit tests",await n.command.testUnit())}async function P(){await a.runCommand("Running end-to-end tests",await n.command.testE2e())}async function b(t){await a.runCommand("Creating MongoDB migration",await n.command.mongoMigrateCreate(t))}async function v(){await a.runCommand("Running MongoDB migrations",await n.command.mongoMigrateUp())}async function D(){await a.runCommand("Rolling back MongoDB migration",await n.command.mongoMigrateDown())}async function O(){await a.runCommand("Starting Storybook development server",await n.command.storybookDev())}async function N(){await a.runCommand("Building Storybook",await n.command.storybookBuild())}(async()=>{try{await C(E.hideBin(s.argv)).scriptName(n.CYBERSKILL_CLI).usage("$0 <command> [options]").command("ai:setup","Setup AI agent environment",y).command("lint","Check code for linting issues",S).command("lint:fix","Fix linting issues automatically",_).command("lint:inspect","View active ESLint configuration",A).command("lint-staged","Run lint checks on staged files",k).command("commitlint","Validate commit message format",I).command("ready","Initialize project and dependencies",T).command("reset","Reset the project and reinstall dependencies",M).command("inspect","Analyze installed project dependencies",L).command("test:unit","Run unit test suite",G).command("test:e2e","Run end-to-end test suite",P).command("mongo:migrate:create <name>","Create a MongoDB migration",t=>t.positional("name",{describe:"Migration name",type:"string"}),async t=>{if(!t.name){r.log.error("Migration name is required.");return}await b(t.name)}).command("mongo:migrate:up","Apply all MongoDB migrations",v).command("mongo:migrate:down","Rollback last MongoDB migration",D).command("storybook:dev","Start Storybook development server",O).command("storybook:build","Build Storybook for production",N).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(h()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
3
|
-
`).parse()}catch(t){r.catchError(t),s.exit(1)}})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.E_CommandType=(e=>(e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e))(exports.E_CommandType||{});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("node:child_process"),m=require("node:process"),P=require("node:util"),E=require("../storage/storage.util.cjs"),w=require("../package/package.util.cjs"),g=require("../path/path.constant.cjs"),l=require("../log/log.type.cjs"),i=require("../log/log.util.cjs"),d=require("../../config/env/env.util.cjs");function T(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const S=T(P),x=S.promisify(L.exec);async function y(){const r=await w.getPackage();return r.success?r.result.name:Date.now().toString()}async function _(r){if(r.length===0)return;const e=await y();try{const s=[...await C(),...r];await E.storage.set(e,s),setTimeout(async()=>{const o=await E.storage.getLogLink(e);o&&i.log.info(`📂 Open the error list manually: ${o}`)},0)}catch(t){i.catchError(t)}}async function C(){try{const r=await y();return await E.storage.get(r)??[]}catch(r){return i.catchError(r,{returnValue:[]})}}async function v(){try{const r=await y();await E.storage.remove(r)}catch(r){i.catchError(r)}}async function O(r){const e=[],t=[];let s="";const o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,n=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,u=/^✖\s+(.*?)\s+\[(.*?)\]$/;r.split(`
|
|
2
|
-
`).forEach(a=>{if(a.startsWith("/"))s=a.trim();else{const c=o.exec(a)||[],f=n.exec(a)||[],p=u.exec(a)||[];c.length&&s?e.push({file:s,position:`${c[1]}:${c[2]}`,type:c[3]===l.E_IssueType.Error?l.E_IssueType.Error:l.E_IssueType.Warning,message:c?.[4]?.trim()??"",rule:c?.[5]?.trim()??""}):f.length?e.push({file:f?.[1]??"",position:`${f[2]}:${f[3]}`,type:f[4]===l.E_IssueType.Error?l.E_IssueType.Error:l.E_IssueType.Warning,message:f?.[5]?.trim()??""}):p.length?e.push({file:"commitlint",type:l.E_IssueType.Error,message:p?.[1]?.trim()??"",rule:p?.[2]?.trim()??""}):t.push(a.trim())}}),e.length&&await _(e),d.getEnv().DEBUG&&t.length&&(i.log.warn("Unmatched lines:"),t.forEach(a=>i.log.info(` ${a}`)))}async function $(r){try{const e=JSON.parse(r),t=[];e.forEach(({filePath:s,messages:o})=>{o.forEach(({severity:n,line:u,column:a,ruleId:c,message:f})=>{t.push({type:n===2?l.E_IssueType.Error:l.E_IssueType.Warning,file:s,position:`${u}:${a}`,rule:c,message:f})})}),t.length&&await _(t)}catch{await O(r)}}async function b(r,e=$,t={}){const s=new AbortController;m.on("SIGINT",()=>{i.log.warn("Process interrupted. Terminating..."),s.abort(),m.exit()});try{if(typeof r=="string"){const{stdout:o,stderr:n}=await x(r,{maxBuffer:104857600,signal:s.signal,timeout:t.timeout});await Promise.all([o,n].map(u=>u&&e(u)))}}catch(o){const{stdout:n,stderr:u,message:a}=o;await Promise.all([n,u].map(c=>c&&e(c))),!u&&!n&&i.log.error(`Command failed: ${a}`)}}function j(r){return{raw:!0,cmd:r}}function h(r,e){return e?.isCurrentProject?`${g.PNPM_EXEC_CLI} ${g.TSX_CLI} ${g.CYBERSKILL_CLI_PATH} ${r}`:`${g.PNPM_EXEC_CLI} ${g.CYBERSKILL_CLI} ${r}`}function I(r,e){return typeof r=="function"?h(r(e),e):typeof r=="object"&&r?.raw===!0?r.cmd:typeof r=="string"?h(r,e):r}async function k(r){const e=await w.getPackage({name:g.CYBERSKILL_PACKAGE_NAME});if(e.success){const t={isCurrentProject:e.result.isCurrentProject},s=typeof r=="function"?r(t):r;return Object.fromEntries(Object.entries(s).map(([o,n])=>[o,I(n,t)]))}}async function N(r,e,t={}){let s;try{const o=Date.now();i.log.start(`${r}`),d.getEnv().DEBUG?i.log.info(`→ ${e}`):s=setInterval(()=>{const n=Math.floor((Date.now()-o)/1e3);n>0&&m.stdout.write(`\r⏳ ${r}... ${n}s`)},100),await b(e,$,t),s&&(clearInterval(s),m.stdout.write("\r\x1B[K")),i.log.success(`${r} done.`)}catch(o){if(s&&(clearInterval(s),m.stdout.write("\r\x1B[K")),t.throwOnError)throw o;i.catchError(o)}}exports.clearAllErrorLists=v;exports.formatCommand=I;exports.getStoredErrorLists=C;exports.rawCommand=j;exports.resolveCommands=k;exports.runCommand=N;
|