@cyberskill/shared 3.11.0 → 3.12.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.
Files changed (191) hide show
  1. package/dist/config/commitlint/index.d.ts +1 -5
  2. package/dist/config/env/index.d.ts +1 -3
  3. package/dist/config/eslint/index.d.ts +1 -1198
  4. package/dist/config/graphql-codegen/index.d.ts +1 -2
  5. package/dist/config/index.d.ts +1 -2
  6. package/dist/config/lint-staged/index.d.ts +1 -5
  7. package/dist/config/storybook/index.d.ts +1 -2
  8. package/dist/config/vitest/index.d.ts +1 -3
  9. package/dist/config/vitest/vitest.e2e.d.ts +1 -20
  10. package/dist/config/vitest/vitest.e2e.js +1 -1
  11. package/dist/config/vitest/vitest.unit.d.ts +1 -22
  12. package/dist/config/vitest/vitest.unit.js +1 -1
  13. package/dist/constant/index.d.ts +1 -5
  14. package/dist/node/apollo-server/index.d.ts +1 -2
  15. package/dist/node/cli/index.d.ts +1 -2
  16. package/dist/node/command/index.d.ts +1 -2
  17. package/dist/node/express/index.d.ts +1 -2
  18. package/dist/node/fs/index.d.ts +1 -2
  19. package/dist/node/log/index.d.ts +1 -2
  20. package/dist/node/mongo/index.d.ts +1 -6
  21. package/dist/node/package/index.d.ts +1 -2
  22. package/dist/node/path/index.d.ts +1 -2
  23. package/dist/node/storage/index.d.ts +1 -3
  24. package/dist/node/upload/index.d.ts +1 -3
  25. package/dist/node/upload/upload.util.js.map +1 -1
  26. package/dist/node/ws/index.d.ts +1 -2
  27. package/dist/node_modules/.pnpm/vitest@4.1.2_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.3_@types_nod_0827261ede788764a5d99ac6bdf44bde/node_modules/vitest/dist/config.js +8 -0
  28. package/dist/node_modules/.pnpm/{vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.1_@types_nod_5f6c16f4d4385f16c87b17afc93c851f → vitest@4.1.2_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.3_@types_nod_0827261ede788764a5d99ac6bdf44bde}/node_modules/vitest/dist/config.js.map +1 -1
  29. package/dist/react/apollo-client/index.d.ts +1 -9
  30. package/dist/react/apollo-client/links/index.d.ts +1 -1
  31. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +1 -16
  32. package/dist/react/apollo-client-nextjs/index.d.ts +1 -2
  33. package/dist/react/apollo-error/apollo-error.component.js +6 -2
  34. package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
  35. package/dist/react/apollo-error/index.d.ts +1 -6
  36. package/dist/react/i18next/index.d.ts +1 -2
  37. package/dist/react/loading/index.d.ts +1 -5
  38. package/dist/react/log/index.d.ts +1 -2
  39. package/dist/react/next-intl/index.d.ts +1 -6
  40. package/dist/react/storage/index.d.ts +1 -2
  41. package/dist/react/toast/index.d.ts +1 -1
  42. package/dist/react/userback/index.d.ts +1 -2
  43. package/dist/src/config/commitlint/index.d.ts +5 -0
  44. package/dist/{config → src/config}/config.type.d.ts +1 -1
  45. package/dist/{config → src/config}/config.util.d.ts +1 -1
  46. package/dist/src/config/env/index.d.ts +3 -0
  47. package/dist/src/config/eslint/index.d.ts +1198 -0
  48. package/dist/src/config/graphql-codegen/index.d.ts +2 -0
  49. package/dist/src/config/index.d.ts +2 -0
  50. package/dist/src/config/lint-staged/index.d.ts +5 -0
  51. package/dist/src/config/storybook/index.d.ts +2 -0
  52. package/dist/src/config/vitest/index.d.ts +3 -0
  53. package/dist/src/config/vitest/vitest.e2e.d.ts +20 -0
  54. package/dist/src/config/vitest/vitest.unit.d.ts +22 -0
  55. package/dist/src/constant/index.d.ts +5 -0
  56. package/dist/src/node/apollo-server/index.d.ts +2 -0
  57. package/dist/src/node/cli/index.d.ts +2 -0
  58. package/dist/src/node/command/index.d.ts +2 -0
  59. package/dist/src/node/express/index.d.ts +2 -0
  60. package/dist/src/node/fs/index.d.ts +2 -0
  61. package/dist/src/node/log/index.d.ts +2 -0
  62. package/dist/{node → src/node}/log/log.type.d.ts +2 -2
  63. package/dist/{node → src/node}/log/log.util.d.ts +1 -1
  64. package/dist/src/node/mongo/index.d.ts +6 -0
  65. package/dist/{node → src/node}/mongo/mongo.controller.helpers.d.ts +1 -1
  66. package/dist/{node → src/node}/mongo/mongo.controller.mongoose.d.ts +1 -1
  67. package/dist/{node → src/node}/mongo/mongo.controller.native.d.ts +1 -1
  68. package/dist/{node → src/node}/mongo/mongo.controller.type.d.ts +1 -1
  69. package/dist/src/node/package/index.d.ts +2 -0
  70. package/dist/{node → src/node}/package/package.util.d.ts +1 -1
  71. package/dist/src/node/path/index.d.ts +2 -0
  72. package/dist/src/node/storage/index.d.ts +3 -0
  73. package/dist/src/node/upload/index.d.ts +3 -0
  74. package/dist/{node → src/node}/upload/upload.util.d.ts +1 -1
  75. package/dist/src/node/ws/index.d.ts +2 -0
  76. package/dist/{react → src/react}/apollo-client/apollo-client.type.d.ts +1 -1
  77. package/dist/src/react/apollo-client/index.d.ts +9 -0
  78. package/dist/src/react/apollo-client/links/index.d.ts +1 -0
  79. package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +16 -0
  80. package/dist/src/react/apollo-client-nextjs/index.d.ts +2 -0
  81. package/dist/src/react/apollo-error/index.d.ts +6 -0
  82. package/dist/src/react/i18next/index.d.ts +2 -0
  83. package/dist/src/react/loading/index.d.ts +5 -0
  84. package/dist/{react → src/react}/loading/loading.provider.d.ts +1 -1
  85. package/dist/src/react/log/index.d.ts +2 -0
  86. package/dist/src/react/log/log.type.d.ts +1 -0
  87. package/dist/{react → src/react}/log/log.util.d.ts +1 -1
  88. package/dist/src/react/next-intl/index.d.ts +6 -0
  89. package/dist/{react → src/react}/next-intl/next-intl.hoc.d.ts +1 -1
  90. package/dist/{react → src/react}/next-intl/next-intl.type.d.ts +1 -1
  91. package/dist/src/react/storage/index.d.ts +2 -0
  92. package/dist/{react → src/react}/storage/storage.hook.d.ts +1 -1
  93. package/dist/src/react/toast/index.d.ts +1 -0
  94. package/dist/src/react/userback/index.d.ts +2 -0
  95. package/dist/src/typescript/index.d.ts +5 -0
  96. package/dist/src/util/common/index.d.ts +5 -0
  97. package/dist/src/util/index.d.ts +9 -0
  98. package/dist/src/util/log/index.d.ts +2 -0
  99. package/dist/{util → src/util}/log/log.util.d.ts +1 -1
  100. package/dist/src/util/object/index.d.ts +4 -0
  101. package/dist/src/util/serializer/index.d.ts +2 -0
  102. package/dist/src/util/string/index.d.ts +5 -0
  103. package/dist/src/util/validate/index.d.ts +4 -0
  104. package/dist/typescript/index.d.ts +1 -5
  105. package/dist/util/common/index.d.ts +1 -5
  106. package/dist/util/index.d.ts +1 -9
  107. package/dist/util/log/index.d.ts +1 -2
  108. package/dist/util/object/index.d.ts +1 -4
  109. package/dist/util/object/object.util.js +5 -3
  110. package/dist/util/object/object.util.js.map +1 -1
  111. package/dist/util/serializer/index.d.ts +1 -2
  112. package/dist/util/serializer/serializer.util.js +10 -10
  113. package/dist/util/serializer/serializer.util.js.map +1 -1
  114. package/dist/util/string/index.d.ts +1 -5
  115. package/dist/util/validate/index.d.ts +1 -4
  116. package/package.json +21 -21
  117. package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.1_@types_nod_5f6c16f4d4385f16c87b17afc93c851f/node_modules/vitest/dist/config.js +0 -8
  118. package/dist/react/log/log.type.d.ts +0 -1
  119. /package/dist/{config → src/config}/env/env.constant.d.ts +0 -0
  120. /package/dist/{config → src/config}/env/env.type.d.ts +0 -0
  121. /package/dist/{config → src/config}/env/env.util.d.ts +0 -0
  122. /package/dist/{config → src/config}/graphql-codegen/graphql-codegen.type.d.ts +0 -0
  123. /package/dist/{config → src/config}/graphql-codegen/graphql-codegen.util.d.ts +0 -0
  124. /package/dist/{config → src/config}/storybook/storybook.main.d.ts +0 -0
  125. /package/dist/{config → src/config}/storybook/storybook.preview.d.ts +0 -0
  126. /package/dist/{config → src/config}/vitest/vitest.unit.setup.d.ts +0 -0
  127. /package/dist/{constant → src/constant}/common.d.ts +0 -0
  128. /package/dist/{constant → src/constant}/response-status.d.ts +0 -0
  129. /package/dist/{node → src/node}/apollo-server/apollo-server.type.d.ts +0 -0
  130. /package/dist/{node → src/node}/apollo-server/apollo-server.util.d.ts +0 -0
  131. /package/dist/{node → src/node}/command/command.type.d.ts +0 -0
  132. /package/dist/{node → src/node}/command/command.util.d.ts +0 -0
  133. /package/dist/{node → src/node}/express/express.type.d.ts +0 -0
  134. /package/dist/{node → src/node}/express/express.util.d.ts +0 -0
  135. /package/dist/{node → src/node}/fs/fs.type.d.ts +0 -0
  136. /package/dist/{node → src/node}/fs/fs.util.d.ts +0 -0
  137. /package/dist/{node → src/node}/mongo/mongo.constant.d.ts +0 -0
  138. /package/dist/{node → src/node}/mongo/mongo.controller.d.ts +0 -0
  139. /package/dist/{node → src/node}/mongo/mongo.dynamic-populate.d.ts +0 -0
  140. /package/dist/{node → src/node}/mongo/mongo.internal-types.d.ts +0 -0
  141. /package/dist/{node → src/node}/mongo/mongo.populate.d.ts +0 -0
  142. /package/dist/{node → src/node}/mongo/mongo.type.d.ts +0 -0
  143. /package/dist/{node → src/node}/mongo/mongo.util.d.ts +0 -0
  144. /package/dist/{node → src/node}/package/package.type.d.ts +0 -0
  145. /package/dist/{node → src/node}/path/path.constant.d.ts +0 -0
  146. /package/dist/{node → src/node}/path/path.util.d.ts +0 -0
  147. /package/dist/{node → src/node}/storage/storage.constant.d.ts +0 -0
  148. /package/dist/{node → src/node}/storage/storage.type.d.ts +0 -0
  149. /package/dist/{node → src/node}/storage/storage.util.d.ts +0 -0
  150. /package/dist/{node → src/node}/upload/upload.constant.d.ts +0 -0
  151. /package/dist/{node → src/node}/upload/upload.type.d.ts +0 -0
  152. /package/dist/{node → src/node}/ws/ws.type.d.ts +0 -0
  153. /package/dist/{node → src/node}/ws/ws.util.d.ts +0 -0
  154. /package/dist/{react → src/react}/apollo-client/apollo-client.component.d.ts +0 -0
  155. /package/dist/{react → src/react}/apollo-client/apollo-client.constant.d.ts +0 -0
  156. /package/dist/{react → src/react}/apollo-client/apollo-client.context.d.ts +0 -0
  157. /package/dist/{react → src/react}/apollo-client/apollo-client.hook.d.ts +0 -0
  158. /package/dist/{react → src/react}/apollo-client/apollo-client.util.d.ts +0 -0
  159. /package/dist/{react → src/react}/apollo-client/links/upload.d.ts +0 -0
  160. /package/dist/{react → src/react}/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +0 -0
  161. /package/dist/{react → src/react}/apollo-client-nextjs/apollo-client-nextjs.util.d.ts +0 -0
  162. /package/dist/{react → src/react}/apollo-error/apollo-error.component.d.ts +0 -0
  163. /package/dist/{react → src/react}/apollo-error/apollo-error.context.d.ts +0 -0
  164. /package/dist/{react → src/react}/apollo-error/apollo-error.hook.d.ts +0 -0
  165. /package/dist/{react → src/react}/apollo-error/apollo-error.provider.d.ts +0 -0
  166. /package/dist/{react → src/react}/apollo-error/apollo-error.type.d.ts +0 -0
  167. /package/dist/{react → src/react}/apollo-error/apollo-error.util.d.ts +0 -0
  168. /package/dist/{react → src/react}/i18next/i18next.hook.d.ts +0 -0
  169. /package/dist/{react → src/react}/i18next/i18next.util.d.ts +0 -0
  170. /package/dist/{react → src/react}/loading/loading.component.d.ts +0 -0
  171. /package/dist/{react → src/react}/loading/loading.context.d.ts +0 -0
  172. /package/dist/{react → src/react}/loading/loading.hook.d.ts +0 -0
  173. /package/dist/{react → src/react}/loading/loading.type.d.ts +0 -0
  174. /package/dist/{react → src/react}/next-intl/next-intl.constant.d.ts +0 -0
  175. /package/dist/{react → src/react}/next-intl/next-intl.context.d.ts +0 -0
  176. /package/dist/{react → src/react}/next-intl/next-intl.hook.d.ts +0 -0
  177. /package/dist/{react → src/react}/next-intl/next-intl.provider.d.ts +0 -0
  178. /package/dist/{react → src/react}/storage/storage.util.d.ts +0 -0
  179. /package/dist/{react → src/react}/userback/userback.component.d.ts +0 -0
  180. /package/dist/{react → src/react}/userback/userback.type.d.ts +0 -0
  181. /package/dist/{typescript → src/typescript}/common.type.d.ts +0 -0
  182. /package/dist/{typescript → src/typescript}/react.type.d.ts +0 -0
  183. /package/dist/{util → src/util}/common/common.type.d.ts +0 -0
  184. /package/dist/{util → src/util}/common/common.util.d.ts +0 -0
  185. /package/dist/{util → src/util}/log/log.type.d.ts +0 -0
  186. /package/dist/{util → src/util}/object/object.util.d.ts +0 -0
  187. /package/dist/{util → src/util}/serializer/serializer.type.d.ts +0 -0
  188. /package/dist/{util → src/util}/serializer/serializer.util.d.ts +0 -0
  189. /package/dist/{util → src/util}/string/string.type.d.ts +0 -0
  190. /package/dist/{util → src/util}/string/string.util.d.ts +0 -0
  191. /package/dist/{util → src/util}/validate/validate.util.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.util.js","names":[],"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: [...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: [...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 *\n * @remarks\n * **Wire format protocol:** Non-JSON-native types are serialized as wrapper objects with the shape\n * `{ __type: string, value: unknown }`. For example:\n * - Date → `{ __type: 'Date', value: '2024-01-01T00:00:00.000Z' }`\n * - Map → `{ __type: 'Map', value: [['key', 'val']] }`\n * - Set → `{ __type: 'Set', value: [1, 2, 3] }`\n * - RegExp → `{ __type: 'RegExp', value: { source: '...', flags: '...' } }`\n * - BigInt → `{ __type: 'BigInt', value: '12345' }`\n *\n * **Cross-service compatibility:** Any service that deserializes data produced by this serializer\n * must use the same `__type` protocol. Plain `JSON.parse` will return the wrapper objects as-is\n * without reconstructing the original types.\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"],"mappings":";AAyBA,IAAM,IAEF;CACA,MAAM;EACF,KAAK,MAAiB,aAAa;EACnC,YAAW,OAAM;GAAE,QAAQ;GAAQ,OAAO,EAAE,aAAa;GAAE;EAC3D,cAAa,MAAK,IAAI,KAAK,EAAY;EAC1C;CACD,KAAK;EACD,KAAK,MAAkC,aAAa;EACpD,YAAW,OAAM;GAAE,QAAQ;GAAO,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC;GAAE;EAC3D,cAAa,MAAK,IAAI,IAAI,EAA0B;EACvD;CACD,KAAK;EACD,KAAK,MAAyB,aAAa;EAC3C,YAAW,OAAM;GAAE,QAAQ;GAAO,OAAO,CAAC,GAAG,EAAE;GAAE;EACjD,cAAa,MAAK,IAAI,IAAI,EAAe;EAC5C;CACD,QAAQ;EACJ,KAAK,MAAmB,aAAa;EACrC,YAAW,OAAM;GACb,QAAQ;GACR,OAAO;IAAE,QAAQ,EAAE;IAAQ,OAAO,EAAE;IAAO;GAC9C;EACD,cAAc,MAAM;GAChB,IAAM,EAAE,WAAQ,aAAU;AAC1B,UAAO,IAAI,OAAO,GAAQ,EAAM;;EAEvC;CACD,QAAQ;EACJ,KAAK,MAAmB,OAAO,KAAM;EACrC,YAAW,OAAM;GAAE,QAAQ;GAAU,OAAO,EAAE,UAAU;GAAE;EAC1D,cAAa,MAAK,OAAO,EAAY;EACxC;CACJ,EAuBY,IAAoC;CAU7C,UAAU,GAAO;AACb,SAAO,KAAK,UAAU,GAAO,SAAU,GAAM,GAAK;GAG9C,IAAM,IADU,KACc;AAE9B,OAAI,aAAyB,KACzB,QAAO,EAAa,KAAK,UAAU,EAAc;AAGrD,QAAK,IAAM,KAAQ,OAAO,KAAK,EAAa,EAA8B;IACtE,IAAM,IAAU,EAAa;AAE7B,QAAI,EAAQ,GAAG,EAAI,CACf,QAAQ,EAAmC,UAAU,EAAI;;AAIjE,UAAO;IACT;;CAWN,YAAY,GAAM;AACd,SAAO,KAAK,MAAM,IAAO,GAAM,MAAQ;AACnC,OACI,KACG,OAAO,KAAQ,YACf,YAAY,KACZ,OAAO,EAAI,UAAW,UAC3B;IAEE,IAAM,IAAU,EADH,EAAI;AAGjB,QAAI,EACA,QAAO,EAAQ,YAAY,EAAI,MAAM;;AAG7C,UAAO;IACT;;CAET"}
1
+ {"version":3,"file":"serializer.util.js","names":[],"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: [...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: [...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\nconst typeHandlersValues = (Object.entries(typeHandlers) as [\n T_SerializerKnownTypes,\n I_Handler<T_SerializerKnownTypes>,\n][])\n .filter(([key]) => key !== 'Date')\n .map(([, handler]) => handler);\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 *\n * @remarks\n * **Wire format protocol:** Non-JSON-native types are serialized as wrapper objects with the shape\n * `{ __type: string, value: unknown }`. For example:\n * - Date → `{ __type: 'Date', value: '2024-01-01T00:00:00.000Z' }`\n * - Map → `{ __type: 'Map', value: [['key', 'val']] }`\n * - Set → `{ __type: 'Set', value: [1, 2, 3] }`\n * - RegExp → `{ __type: 'RegExp', value: { source: '...', flags: '...' } }`\n * - BigInt → `{ __type: 'BigInt', value: '12345' }`\n *\n * **Cross-service compatibility:** Any service that deserializes data produced by this serializer\n * must use the same `__type` protocol. Plain `JSON.parse` will return the wrapper objects as-is\n * without reconstructing the original types.\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 (let i = 0; i < typeHandlersValues.length; i++) {\n const handler = typeHandlersValues[i]!;\n\n if (handler.is(val)) {\n return handler.serialize(val as I_SerializerValueMap[T_SerializerKnownTypes]);\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"],"mappings":";AAyBA,IAAM,IAEF;CACA,MAAM;EACF,KAAK,MAAiB,aAAa;EACnC,YAAW,OAAM;GAAE,QAAQ;GAAQ,OAAO,EAAE,aAAa;GAAE;EAC3D,cAAa,MAAK,IAAI,KAAK,EAAY;EAC1C;CACD,KAAK;EACD,KAAK,MAAkC,aAAa;EACpD,YAAW,OAAM;GAAE,QAAQ;GAAO,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC;GAAE;EAC3D,cAAa,MAAK,IAAI,IAAI,EAA0B;EACvD;CACD,KAAK;EACD,KAAK,MAAyB,aAAa;EAC3C,YAAW,OAAM;GAAE,QAAQ;GAAO,OAAO,CAAC,GAAG,EAAE;GAAE;EACjD,cAAa,MAAK,IAAI,IAAI,EAAe;EAC5C;CACD,QAAQ;EACJ,KAAK,MAAmB,aAAa;EACrC,YAAW,OAAM;GACb,QAAQ;GACR,OAAO;IAAE,QAAQ,EAAE;IAAQ,OAAO,EAAE;IAAO;GAC9C;EACD,cAAc,MAAM;GAChB,IAAM,EAAE,WAAQ,aAAU;AAC1B,UAAO,IAAI,OAAO,GAAQ,EAAM;;EAEvC;CACD,QAAQ;EACJ,KAAK,MAAmB,OAAO,KAAM;EACrC,YAAW,OAAM;GAAE,QAAQ;GAAU,OAAO,EAAE,UAAU;GAAE;EAC1D,cAAa,MAAK,OAAO,EAAY;EACxC;CACJ,EAEK,IAAsB,OAAO,QAAQ,EAAa,CAInD,QAAQ,CAAC,OAAS,MAAQ,OAAO,CACjC,KAAK,GAAG,OAAa,EAAQ,EAuBrB,IAAoC;CAU7C,UAAU,GAAO;AACb,SAAO,KAAK,UAAU,GAAO,SAAU,GAAM,GAAK;GAG9C,IAAM,IADU,KACc;AAE9B,OAAI,aAAyB,KACzB,QAAO,EAAa,KAAK,UAAU,EAAc;AAGrD,QAAK,IAAI,IAAI,GAAG,IAAI,EAAmB,QAAQ,KAAK;IAChD,IAAM,IAAU,EAAmB;AAEnC,QAAI,EAAQ,GAAG,EAAI,CACf,QAAO,EAAQ,UAAU,EAAoD;;AAIrF,UAAO;IACT;;CAWN,YAAY,GAAM;AACd,SAAO,KAAK,MAAM,IAAO,GAAM,MAAQ;AACnC,OACI,KACG,OAAO,KAAQ,YACf,YAAY,KACZ,OAAO,EAAI,UAAW,UAC3B;IAEE,IAAM,IAAU,EADH,EAAI;AAGjB,QAAI,EACA,QAAO,EAAQ,YAAY,EAAI,MAAM;;AAG7C,UAAO;IACT;;CAET"}
@@ -1,5 +1 @@
1
- /**
2
- * Re-exports all string manipulation utilities and types.
3
- */
4
- export * from './string.type.js';
5
- export * from './string.util.js';
1
+ export {}
@@ -1,4 +1 @@
1
- /**
2
- * Re-exports all validation utilities.
3
- */
4
- export * from './validate.util.js';
1
+ export {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "3.11.0",
4
+ "version": "3.12.0",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -232,9 +232,9 @@
232
232
  "@antfu/eslint-config": "7.7.3",
233
233
  "@apollo/client": "4.1.6",
234
234
  "@apollo/client-integration-nextjs": "0.14.4",
235
- "@apollo/server": "5.4.0",
235
+ "@apollo/server": "5.5.0",
236
236
  "@as-integrations/express5": "1.1.2",
237
- "@dotenvx/dotenvx": "1.57.0",
237
+ "@dotenvx/dotenvx": "1.58.0",
238
238
  "@eddeee888/gcg-typescript-resolver-files": "0.15.0",
239
239
  "@eslint-react/eslint-plugin": "2.13.0",
240
240
  "@graphql-codegen/cli": "6.2.1",
@@ -252,7 +252,7 @@
252
252
  "cors": "2.8.6",
253
253
  "date-fns": "4.1.0",
254
254
  "envalid": "8.1.1",
255
- "eslint-config-next": "16.2.0",
255
+ "eslint-config-next": "16.2.1",
256
256
  "eslint-plugin-format": "2.0.1",
257
257
  "eslint-plugin-react-hooks": "7.0.1",
258
258
  "eslint-plugin-react-refresh": "0.5.2",
@@ -263,36 +263,36 @@
263
263
  "extract-files": "13.0.0",
264
264
  "fs-extra": "11.3.4",
265
265
  "globals": "17.4.0",
266
- "graphql": "16.13.1",
266
+ "graphql": "16.13.2",
267
267
  "graphql-upload": "17.0.0",
268
- "graphql-ws": "6.0.7",
268
+ "graphql-ws": "6.0.8",
269
269
  "helmet": "8.1.0",
270
- "i18next": "25.8.20",
270
+ "i18next": "25.10.10",
271
271
  "migrate-mongo": "14.0.7",
272
- "mongodb": "7.1.0",
273
- "mongoose": "9.3.1",
272
+ "mongodb": "7.1.1",
273
+ "mongoose": "9.3.3",
274
274
  "mongoose-aggregate-paginate-v2": "1.1.4",
275
- "mongoose-paginate-v2": "1.9.3",
275
+ "mongoose-paginate-v2": "1.9.4",
276
276
  "next-intl": "4.8.3",
277
277
  "qs": "6.15.0",
278
278
  "react": "19.2.4",
279
279
  "react-dom": "19.2.4",
280
280
  "react-hot-toast": "2.6.0",
281
- "react-i18next": "16.5.8",
281
+ "react-i18next": "16.6.6",
282
282
  "rxjs": "7.8.2",
283
- "ws": "8.19.0",
283
+ "ws": "8.20.0",
284
284
  "yargs": "18.0.0"
285
285
  },
286
286
  "devDependencies": {
287
287
  "@commitlint/cli": "20.5.0",
288
288
  "@commitlint/config-conventional": "20.5.0",
289
289
  "@eslint/config-inspector": "1.5.0",
290
- "@next/eslint-plugin-next": "16.2.0",
290
+ "@next/eslint-plugin-next": "16.2.1",
291
291
  "@semantic-release/changelog": "6.0.3",
292
292
  "@semantic-release/git": "10.0.1",
293
293
  "@semantic-release/github": "12.0.6",
294
- "@storybook/react": "10.3.1",
295
- "@storybook/react-vite": "10.3.1",
294
+ "@storybook/react": "10.3.3",
295
+ "@storybook/react-vite": "10.3.3",
296
296
  "@testing-library/dom": "10.4.1",
297
297
  "@testing-library/jest-dom": "6.9.1",
298
298
  "@testing-library/react": "16.3.2",
@@ -312,8 +312,8 @@
312
312
  "@types/react-dom": "19.2.3",
313
313
  "@types/ws": "8.18.1",
314
314
  "@types/yargs": "17.0.35",
315
- "@vitest/browser": "4.1.0",
316
- "@vitest/coverage-istanbul": "4.1.0",
315
+ "@vitest/browser": "4.1.2",
316
+ "@vitest/coverage-istanbul": "4.1.2",
317
317
  "conventional-changelog-conventionalcommits": "9.3.0",
318
318
  "eslint": "10.1.0",
319
319
  "glob": "13.0.6",
@@ -325,10 +325,10 @@
325
325
  "semantic-release": "25.0.3",
326
326
  "simple-git-hooks": "2.13.1",
327
327
  "tsx": "4.21.0",
328
- "typescript": "5.9.3",
329
- "vite": "8.0.1",
328
+ "typescript": "6.0.2",
329
+ "vite": "8.0.3",
330
330
  "vite-plugin-dts": "4.5.4",
331
- "vitest": "4.1.0"
331
+ "vitest": "4.1.2"
332
332
  },
333
333
  "publishConfig": {
334
334
  "access": "public",
@@ -337,7 +337,7 @@
337
337
  },
338
338
  "pnpm": {
339
339
  "overrides": {
340
- "minimatch": ">=10.2.3"
340
+ "minimatch": ">=10.2.4"
341
341
  }
342
342
  }
343
343
  }
@@ -1,8 +0,0 @@
1
- //#region node_modules/.pnpm/vitest@4.1.0_@types+node@25.5.0_jsdom@29.0.1_@noble+hashes@1.8.0__vite@8.0.1_@types+nod_5f6c16f4d4385f16c87b17afc93c851f/node_modules/vitest/dist/config.js
2
- function e(e) {
3
- return e;
4
- }
5
- //#endregion
6
- export { e as defineConfig };
7
-
8
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- export type { I_CatchErrorOptions } from '../../util/log/index.js';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes