@dxtmisha/functional-basic 1.8.10 → 1.10.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 (199) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/ai-description.md +7 -3
  3. package/ai-mcp-resources.json +14 -2
  4. package/ai-resources/design-config.md +104 -0
  5. package/ai-resources/error-center.md +150 -0
  6. package/ai-types.md +1 -3233
  7. package/dist/library.d.ts +9991 -189
  8. package/dist/library.js +851 -835
  9. package/package.json +7 -2
  10. package/dist/classes/Api.d.ts +0 -209
  11. package/dist/classes/ApiCache.d.ts +0 -152
  12. package/dist/classes/ApiDataReturn.d.ts +0 -79
  13. package/dist/classes/ApiDefault.d.ts +0 -49
  14. package/dist/classes/ApiError.d.ts +0 -39
  15. package/dist/classes/ApiErrorItem.d.ts +0 -70
  16. package/dist/classes/ApiErrorStorage.d.ts +0 -92
  17. package/dist/classes/ApiHeaders.d.ts +0 -37
  18. package/dist/classes/ApiHydration.d.ts +0 -40
  19. package/dist/classes/ApiInstance.d.ts +0 -299
  20. package/dist/classes/ApiPreparation.d.ts +0 -58
  21. package/dist/classes/ApiResponse.d.ts +0 -154
  22. package/dist/classes/ApiStatus.d.ts +0 -131
  23. package/dist/classes/BroadcastMessage.d.ts +0 -76
  24. package/dist/classes/Cache.d.ts +0 -39
  25. package/dist/classes/CacheItem.d.ts +0 -65
  26. package/dist/classes/CacheStatic.d.ts +0 -36
  27. package/dist/classes/Cookie.d.ts +0 -54
  28. package/dist/classes/CookieBlock.d.ts +0 -30
  29. package/dist/classes/CookieBlockInstance.d.ts +0 -24
  30. package/dist/classes/CookieStorage.d.ts +0 -175
  31. package/dist/classes/DataStorage.d.ts +0 -107
  32. package/dist/classes/Datetime.d.ts +0 -571
  33. package/dist/classes/ErrorCenter.d.ts +0 -86
  34. package/dist/classes/ErrorCenterHandler.d.ts +0 -85
  35. package/dist/classes/ErrorCenterInstance.d.ts +0 -101
  36. package/dist/classes/EventItem.d.ts +0 -230
  37. package/dist/classes/Formatters.d.ts +0 -157
  38. package/dist/classes/Geo.d.ts +0 -172
  39. package/dist/classes/GeoFlag.d.ts +0 -135
  40. package/dist/classes/GeoInstance.d.ts +0 -264
  41. package/dist/classes/GeoIntl.d.ts +0 -291
  42. package/dist/classes/GeoPhone.d.ts +0 -110
  43. package/dist/classes/GeoUnit.d.ts +0 -207
  44. package/dist/classes/Global.d.ts +0 -29
  45. package/dist/classes/Hash.d.ts +0 -57
  46. package/dist/classes/HashInstance.d.ts +0 -29
  47. package/dist/classes/Icons.d.ts +0 -128
  48. package/dist/classes/Loading.d.ts +0 -62
  49. package/dist/classes/LoadingInstance.d.ts +0 -87
  50. package/dist/classes/Meta.d.ts +0 -189
  51. package/dist/classes/MetaManager.d.ts +0 -123
  52. package/dist/classes/MetaOg.d.ts +0 -120
  53. package/dist/classes/MetaStatic.d.ts +0 -179
  54. package/dist/classes/MetaTwitter.d.ts +0 -120
  55. package/dist/classes/Query.d.ts +0 -57
  56. package/dist/classes/QueryInstance.d.ts +0 -29
  57. package/dist/classes/ResumableTimer.d.ts +0 -85
  58. package/dist/classes/ScrollbarWidth.d.ts +0 -52
  59. package/dist/classes/SearchList.d.ts +0 -132
  60. package/dist/classes/SearchListData.d.ts +0 -144
  61. package/dist/classes/SearchListItem.d.ts +0 -49
  62. package/dist/classes/SearchListMatcher.d.ts +0 -58
  63. package/dist/classes/SearchListOptions.d.ts +0 -66
  64. package/dist/classes/ServerStorage.d.ts +0 -110
  65. package/dist/classes/StorageCallback.d.ts +0 -86
  66. package/dist/classes/Translate.d.ts +0 -117
  67. package/dist/classes/TranslateFile.d.ts +0 -81
  68. package/dist/classes/TranslateInstance.d.ts +0 -203
  69. package/dist/classes/UrlInstanceAbstract.d.ts +0 -98
  70. package/dist/classes/UrlItem.d.ts +0 -119
  71. package/dist/functions/addTagHighlightMatch.d.ts +0 -11
  72. package/dist/functions/anyToString.d.ts +0 -10
  73. package/dist/functions/applyTemplate.d.ts +0 -10
  74. package/dist/functions/arrFill.d.ts +0 -9
  75. package/dist/functions/blobToBase64.d.ts +0 -9
  76. package/dist/functions/capitalize.d.ts +0 -9
  77. package/dist/functions/copyObject.d.ts +0 -10
  78. package/dist/functions/copyObjectLite.d.ts +0 -9
  79. package/dist/functions/createElement.d.ts +0 -21
  80. package/dist/functions/domContentLoaded.d.ts +0 -13
  81. package/dist/functions/domQuerySelector.d.ts +0 -8
  82. package/dist/functions/domQuerySelectorAll.d.ts +0 -8
  83. package/dist/functions/encodeAttribute.d.ts +0 -8
  84. package/dist/functions/encodeLiteAttribute.d.ts +0 -8
  85. package/dist/functions/ensureMaxSize.d.ts +0 -10
  86. package/dist/functions/escapeExp.d.ts +0 -7
  87. package/dist/functions/eventStopPropagation.d.ts +0 -7
  88. package/dist/functions/executeFunction.d.ts +0 -12
  89. package/dist/functions/executePromise.d.ts +0 -11
  90. package/dist/functions/forEach.d.ts +0 -14
  91. package/dist/functions/frame.d.ts +0 -10
  92. package/dist/functions/getArrayHighlightMatch.d.ts +0 -10
  93. package/dist/functions/getAttributes.d.ts +0 -9
  94. package/dist/functions/getClipboardData.d.ts +0 -9
  95. package/dist/functions/getColumn.d.ts +0 -10
  96. package/dist/functions/getCurrentDate.d.ts +0 -19
  97. package/dist/functions/getCurrentTime.d.ts +0 -15
  98. package/dist/functions/getElement.d.ts +0 -9
  99. package/dist/functions/getElementId.d.ts +0 -26
  100. package/dist/functions/getElementImage.d.ts +0 -8
  101. package/dist/functions/getElementItem.d.ts +0 -12
  102. package/dist/functions/getElementOrWindow.d.ts +0 -8
  103. package/dist/functions/getElementSafeScript.d.ts +0 -9
  104. package/dist/functions/getExactSearchExp.d.ts +0 -8
  105. package/dist/functions/getExp.d.ts +0 -14
  106. package/dist/functions/getFirst.d.ts +0 -8
  107. package/dist/functions/getHydrationData.d.ts +0 -10
  108. package/dist/functions/getItemByPath.d.ts +0 -9
  109. package/dist/functions/getKey.d.ts +0 -8
  110. package/dist/functions/getLast.d.ts +0 -8
  111. package/dist/functions/getLength.d.ts +0 -10
  112. package/dist/functions/getLengthOfAllArray.d.ts +0 -8
  113. package/dist/functions/getMaxLengthAllArray.d.ts +0 -9
  114. package/dist/functions/getMinLengthAllArray.d.ts +0 -8
  115. package/dist/functions/getMouseClient.d.ts +0 -9
  116. package/dist/functions/getMouseClientX.d.ts +0 -8
  117. package/dist/functions/getMouseClientY.d.ts +0 -8
  118. package/dist/functions/getObjectByKeys.d.ts +0 -8
  119. package/dist/functions/getObjectNoUndefined.d.ts +0 -9
  120. package/dist/functions/getObjectOrNone.d.ts +0 -8
  121. package/dist/functions/getOnlyText.d.ts +0 -8
  122. package/dist/functions/getRandomItem.d.ts +0 -10
  123. package/dist/functions/getRandomText.d.ts +0 -12
  124. package/dist/functions/getRequestString.d.ts +0 -11
  125. package/dist/functions/getSearchExp.d.ts +0 -12
  126. package/dist/functions/getSeparatingSearchExp.d.ts +0 -9
  127. package/dist/functions/getStepPercent.d.ts +0 -9
  128. package/dist/functions/getStepValue.d.ts +0 -9
  129. package/dist/functions/goScroll.d.ts +0 -10
  130. package/dist/functions/goScrollSmooth.d.ts +0 -10
  131. package/dist/functions/goScrollTo.d.ts +0 -10
  132. package/dist/functions/handleShare.d.ts +0 -10
  133. package/dist/functions/inArray.d.ts +0 -9
  134. package/dist/functions/initScrollbarOffset.d.ts +0 -7
  135. package/dist/functions/intersectKey.d.ts +0 -9
  136. package/dist/functions/isApiSuccess.d.ts +0 -9
  137. package/dist/functions/isArray.d.ts +0 -8
  138. package/dist/functions/isDifferent.d.ts +0 -10
  139. package/dist/functions/isDomData.d.ts +0 -7
  140. package/dist/functions/isDomRuntime.d.ts +0 -10
  141. package/dist/functions/isElementVisible.d.ts +0 -11
  142. package/dist/functions/isEnter.d.ts +0 -9
  143. package/dist/functions/isFilled.d.ts +0 -10
  144. package/dist/functions/isFloat.d.ts +0 -8
  145. package/dist/functions/isFunction.d.ts +0 -9
  146. package/dist/functions/isInDom.d.ts +0 -9
  147. package/dist/functions/isInput.d.ts +0 -8
  148. package/dist/functions/isIntegerBetween.d.ts +0 -9
  149. package/dist/functions/isMetaKey.d.ts +0 -8
  150. package/dist/functions/isNull.d.ts +0 -9
  151. package/dist/functions/isNumber.d.ts +0 -8
  152. package/dist/functions/isObject.d.ts +0 -8
  153. package/dist/functions/isObjectNotArray.d.ts +0 -8
  154. package/dist/functions/isOnLine.d.ts +0 -7
  155. package/dist/functions/isSelected.d.ts +0 -9
  156. package/dist/functions/isSelectedByList.d.ts +0 -9
  157. package/dist/functions/isShare.d.ts +0 -7
  158. package/dist/functions/isString.d.ts +0 -8
  159. package/dist/functions/isTab.d.ts +0 -8
  160. package/dist/functions/isWindow.d.ts +0 -7
  161. package/dist/functions/random.d.ts +0 -9
  162. package/dist/functions/removeCommonPrefix.d.ts +0 -9
  163. package/dist/functions/replaceComponentName.d.ts +0 -9
  164. package/dist/functions/replaceRecursive.d.ts +0 -11
  165. package/dist/functions/replaceTemplate.d.ts +0 -10
  166. package/dist/functions/resizeImageByMax.d.ts +0 -19
  167. package/dist/functions/secondToTime.d.ts +0 -9
  168. package/dist/functions/setElementItem.d.ts +0 -11
  169. package/dist/functions/setValues.d.ts +0 -18
  170. package/dist/functions/sleep.d.ts +0 -8
  171. package/dist/functions/sortList.d.ts +0 -11
  172. package/dist/functions/splice.d.ts +0 -13
  173. package/dist/functions/strFill.d.ts +0 -9
  174. package/dist/functions/strSplit.d.ts +0 -12
  175. package/dist/functions/toArray.d.ts +0 -17
  176. package/dist/functions/toCamelCase.d.ts +0 -8
  177. package/dist/functions/toCamelCaseFirst.d.ts +0 -8
  178. package/dist/functions/toDate.d.ts +0 -8
  179. package/dist/functions/toKebabCase.d.ts +0 -15
  180. package/dist/functions/toNumber.d.ts +0 -19
  181. package/dist/functions/toNumberByMax.d.ts +0 -11
  182. package/dist/functions/toNumberPositive.d.ts +0 -9
  183. package/dist/functions/toPercent.d.ts +0 -9
  184. package/dist/functions/toPercentBy100.d.ts +0 -9
  185. package/dist/functions/toString.d.ts +0 -8
  186. package/dist/functions/transformation.d.ts +0 -21
  187. package/dist/functions/uint8ArrayToBase64.d.ts +0 -8
  188. package/dist/functions/uniqueArray.d.ts +0 -8
  189. package/dist/functions/writeClipboardData.d.ts +0 -8
  190. package/dist/media/errorCauseList.d.ts +0 -2
  191. package/dist/types/apiTypes.d.ts +0 -259
  192. package/dist/types/basicTypes.d.ts +0 -131
  193. package/dist/types/errorCenterTypes.d.ts +0 -50
  194. package/dist/types/formattersTypes.d.ts +0 -224
  195. package/dist/types/geoTypes.d.ts +0 -142
  196. package/dist/types/metaTypes.d.ts +0 -586
  197. package/dist/types/searchTypes.d.ts +0 -53
  198. package/dist/types/sortTypes.d.ts +0 -20
  199. package/dist/types/translateTypes.d.ts +0 -54
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.10.0] - 2026-08-30
6
+
7
+ ### Added
8
+ - **Geo Country Management (`Geo` / `GeoInstance`)**:
9
+ - Added `add(item: GeoItem)` and `addList(list: GeoItem[])` methods to dynamically register and merge custom country configurations into the geo registry.
10
+ - Initialized internal country list directly from the `@dxtmisha/media` dataset, making `getList()` dynamic.
11
+ - Added unit test coverage for `GeoInstance.add`, `GeoInstance.addList`, `Geo.add`, and `Geo.addList`.
12
+ - **AI Resources**:
13
+ - Added `error-center.md` architecture guide in `ai-resources/` and metadata descriptor in `ai-types-list/resources/error-center.json`.
14
+ - **Documentation**:
15
+ - Migrated package documentation to `src/storybook/` with comprehensive guides across English, Russian, and Vietnamese.
16
+
17
+ ## [1.9.0] - 2026-08-24
18
+
19
+ ### Added
20
+ - **`getImageSrc`**: Utility function to safely extract the image source string from `HTMLImageElement`, string URL, or `undefined`.
21
+ - **`resizeImage`**: Asynchronous utility function to scale down images that exceed a maximum size constraint (`maxSize`) returning a Data URL or the original source string.
22
+ - **Unit Tests**: Added test suites for `getImageSrc` and `resizeImage`.
23
+ - **Documentation**: Added MDX documentation and usage examples across English, Russian, and Vietnamese.
24
+ - **AI Types**: Generated type definitions for `getImageSrc` and `resizeImage`.
25
+
5
26
  ## [1.8.10] - 2026-08-20
6
27
 
7
28
  ### Changed
package/ai-description.md CHANGED
@@ -1,6 +1,10 @@
1
- This package is a comprehensive utility library designed for web applications, providing robust core functions for API requests, caching, internationalization (Geo/Intl), state management, DOM manipulation, and SEO metadata control. An AI assistant must study this file when implementing or refactoring features related to HTTP communication, localized data formatting, browser storage, query/hash state synchronization, or search filtering to ensure adherence to established patterns and type definitions.
1
+ An isomorphic TypeScript utility library that provides core infrastructure for HTTP client requests, SSR state hydration, internationalization, and client-side data management. It offers robust tools for URL state handling, DOM events, localization formatting, and error tracking across browser and server environments.
2
2
 
3
- Key Capabilities: API Integration, Request Caching, Internationalization, Cookie Management, Local Storage, URL State, DOM Utilities, Meta Tags, Search Matching, Error Handling
3
+ Study ai-types.md when configuring or executing HTTP requests, fetch interceptors, API caching, or SSR hydration; managing cookies, session/local storage, or request-isolated server storage; implementing internationalization, multi-language translations, locale-aware date/time calculations, phone masks, or unit conversions; manipulating URL query parameters and hash routing state; managing SEO meta tags, Open Graph, and Twitter Cards; building searchable list filters with text match highlighting; handling centralized application errors, global loading state, cross-tab broadcast messaging, or DOM event observation and helper utilities.
4
+
5
+ Key Capabilities: HTTP Client Management, API Response Caching, SSR State Hydration, Centralized Error Handling, Internationalization Formatting, Geographic Localization, Datetime Manipulation, Phone Dialing Masks, Unit Measurement Conversion, Translation Services, Cookie Management, Isomorphic Storage Isolation, URL State Synchronization, Query Parameter Handling, Hash State Routing, SEO Meta Management, Open Graph Tags, Twitter Card Metadata, Search List Filtering, Text Match Highlighting, DOM Event Control, Global Loading Tracking, Cross-Tab Messaging, Image Resizing Utilities, Clipboard Integration, Data Transformation
4
6
  ## Mandatory Rules
5
7
  You MUST evaluate whether your task relates to any of the following topics (even if not working directly with this package). If related material is present, you are strictly obligated to read and study the corresponding file before proceeding:
6
- - 'node_modules/@dxtmisha/functional-basic/ai-resources/api-reference.md': Provides code examples and usage patterns for HTTP clients, caching, data storage, localization, and DOM helpers from the @dxtmisha/functional-basic library. Guides AI assistants on how to properly implement core functional utilities in TypeScript applications.
8
+ - 'node_modules/@dxtmisha/functional-basic/ai-resources/api-reference.md': Comprehensive API reference and code examples for the @dxtmisha/functional-basic utility package. Covers HTTP networking, client/server storage, internationalization, DOM utilities, and general helper functions. Streamlines common frontend and SSR development tasks including state persistence, API integration, and formatting.
9
+ - 'node_modules/@dxtmisha/functional-basic/ai-resources/design-config.md': Defines configuration schemas, inheritance rules, and property references for design.config.json files across DXT UI monorepo packages. It standardizes settings for TypeScript declaration scanning, AI providers, Figma integration, and wiki generation. Serves as the operational guide for setting up design tokens and automated tooling workflows.
10
+ - 'node_modules/@dxtmisha/functional-basic/ai-resources/error-center.md': Defines mandatory error management standards and API rules using ErrorCenter in @dxtmisha/functional-basic. Prohibits direct console logging and enforces structured error dispatching across all application domains. Guides error registration, custom group handlers, and external telemetry integration.
@@ -13,8 +13,20 @@
13
13
  },
14
14
  {
15
15
  "uri": "@dxtmisha/functional-basic/ai-resources/api-reference.md",
16
- "name": "API Reference And Examples (@dxtmisha/functional-basic)",
16
+ "name": "Functional Basic API Reference (@dxtmisha/functional-basic)",
17
17
  "mimeType": "text/markdown",
18
- "description": "Provides code examples and usage patterns for HTTP clients, caching, data storage, localization, and DOM helpers from the @dxtmisha/functional-basic library. Guides AI assistants on how to properly implement core functional utilities in TypeScript applications."
18
+ "description": "Comprehensive API reference and code examples for the @dxtmisha/functional-basic utility package. Covers HTTP networking, client/server storage, internationalization, DOM utilities, and general helper functions. Streamlines common frontend and SSR development tasks including state persistence, API integration, and formatting."
19
+ },
20
+ {
21
+ "uri": "@dxtmisha/functional-basic/ai-resources/design-config.md",
22
+ "name": "Design Config Specification (@dxtmisha/functional-basic)",
23
+ "mimeType": "text/markdown",
24
+ "description": "Defines configuration schemas, inheritance rules, and property references for design.config.json files across DXT UI monorepo packages. It standardizes settings for TypeScript declaration scanning, AI providers, Figma integration, and wiki generation. Serves as the operational guide for setting up design tokens and automated tooling workflows."
25
+ },
26
+ {
27
+ "uri": "@dxtmisha/functional-basic/ai-resources/error-center.md",
28
+ "name": "Centralized Error Handling Guide (@dxtmisha/functional-basic)",
29
+ "mimeType": "text/markdown",
30
+ "description": "Defines mandatory error management standards and API rules using ErrorCenter in @dxtmisha/functional-basic. Prohibits direct console logging and enforces structured error dispatching across all application domains. Guides error registration, custom group handlers, and external telemetry integration."
19
31
  }
20
32
  ]
@@ -0,0 +1,104 @@
1
+ # `design.config.json` Configuration Guide
2
+
3
+ Configuration specification for DXT UI packages and monorepo root.
4
+
5
+ ---
6
+
7
+ ## 1. Overview & Inheritance Mechanism
8
+
9
+ `design.config.json` configures design system parameters, type scanning, AI generation, and wiki generation.
10
+
11
+ - **Inheritance via `extends`**: Packages extend parent configs using relative paths (`"extends": "../../design.config.json"`).
12
+ - **Merging Strategy**: Recursive shallow merge. Properties in child configs override inherited parent values.
13
+ - **Search Order**: Tools look for `design.config.json` in the current working directory, then scan up the directory tree up to 32 levels.
14
+
15
+ ---
16
+
17
+ ## 2. Property Reference
18
+
19
+ - `extends` (`string`): Relative path to parent configuration file to inherit from (e.g. `"../../design.config.json"`).
20
+ - `project` (`string`, default: `'ui'`): Project / namespace identifier (e.g. `"Ui"`, `"Basic"`), used in component prefixes and story paths.
21
+ - `name` (`string`, default: `'ui'`): Design system package name (e.g. `"d1"`, `"functional-basic"`).
22
+ - `alternativeName` (`string[]`): Array of alternative aliases or abbreviations for the design system.
23
+ - `typesPaths` (`string[]`, default: `['src']`): Whitelist of directory paths to scan for TypeScript declarations during `dxt-types`.
24
+ - `typesMatch` (`string | string[]`): Regex or substring patterns to include in declaration scanning.
25
+ - `typesExclude` (`string | string[]`): Regex or substring patterns to exclude from declaration scanning (e.g. `["\\.wiki\\.d\\.ts$", "wiki/", "library/"]`).
26
+ - `typesWithoutVue` (`boolean`, default: `false`): When `true`, skips Vue SFC scanning and forces standard `tsc` compilation instead of `vue-tsc`.
27
+ - `typesDir` (`string`, default: `'ai-types-temp'`): Directory path for temporary TypeScript declarations compilation.
28
+ - `distDir` (`string`, default: `'dist'`): Output directory path for compiled JavaScript files.
29
+ - `aiResourcesDir` (`string`, default: `'ai-resources'`): Directory path containing AI resource and prompt files.
30
+ - `promptScanDepth` (`number`, default: `6`): Maximum directory scan depth for collecting AI prompt packages.
31
+ - `separator` (`string`, default: `'/'`): Token path delimiter used when splitting design tokens into sub-branches.
32
+ - `separatorBasicName` (`string`): Base token name stripped during branch segmentation.
33
+ - `separatorLimit` (`number`): Maximum recursion depth for token key splitting.
34
+ - `wikiLanguage` (`string`, default: `'en'`): Target localization language code for wiki and Storybook docs (e.g. `'ru'`, `'en'`).
35
+ - `packagePrefix` (`string`): Monorepo scope prefix for package imports (e.g. `'@dxtmisha'`).
36
+ - `aiType` (`AiType`): AI backend provider (`'claude'`, `'claude-cli'`, `'claude-agent'`, `'gemini'`, `'gemini-cli'`, `'openai'`, `'zai'`).
37
+ - `aiModel` (`string`): Specific model identifier (e.g. `'gemini-3.7-flash'`, `'gpt-4o'`).
38
+ - `aiKey` (`string`): API key or token for AI provider.
39
+ - `aiConfig` (`Record<string, any>`, default: `{}`): Provider-specific options (temperature, tokens, headers).
40
+ - `aiTypesConcurrency` (`number`, default: `8`): Maximum number of type definition files processed by AI concurrently.
41
+ - `figmaToken` (`string`): Personal access token for Figma REST API integration.
42
+
43
+ ---
44
+
45
+ ## 3. Full Configuration Example
46
+
47
+ Complete `design.config.json` incorporating all available configuration properties:
48
+
49
+ ```json
50
+ {
51
+ "extends": "../../design.config.json",
52
+ "project": "Ui",
53
+ "name": "d1",
54
+ "alternativeName": [
55
+ "dd"
56
+ ],
57
+ "typesPaths": [
58
+ "src/components"
59
+ ],
60
+ "typesMatch": [
61
+ "Button",
62
+ "Input"
63
+ ],
64
+ "typesExclude": [
65
+ "\\.wiki\\.(d\\.)?ts$",
66
+ "wiki\\.(d\\.)?ts$",
67
+ "wikiData\\.(d\\.)?ts$",
68
+ "wiki/",
69
+ "library/"
70
+ ],
71
+ "typesWithoutVue": true,
72
+ "typesDir": "ai-types-temp",
73
+ "distDir": "dist",
74
+ "aiResourcesDir": "ai-resources",
75
+ "promptScanDepth": 6,
76
+ "separator": "/",
77
+ "separatorBasicName": "basic",
78
+ "separatorLimit": 3,
79
+ "wikiLanguage": "ru",
80
+ "packagePrefix": "@dxtmisha",
81
+ "aiType": "gemini",
82
+ "aiModel": "gemini-3.7-flash",
83
+ "aiKey": "AIzaSy...",
84
+ "aiConfig": {
85
+ "temperature": 0.2
86
+ },
87
+ "aiTypesConcurrency": 8,
88
+ "figmaToken": "figd_..."
89
+ }
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 4. Operational Guidelines for AI Assistants
95
+
96
+ 1. **Always extend root**: Child package configs must define `"extends": "../../design.config.json"` unless creating a standalone root.
97
+ 2. **Pure TS packages**: Always set `"typesWithoutVue": true` in non-Vue packages to prevent unnecessary `vue-tsc` invocations.
98
+ 3. **Filtering declarations**: Use `typesExclude` with regex patterns (`"\\.wiki\\.d\\.ts$"`, `"wiki/"`) to keep `ai-types.md` clean of internal build artifacts.
99
+ 4. **Accessing in code**: In scripts, read configuration through the static accessor `PropertiesConfig`:
100
+ ```typescript
101
+ import { PropertiesConfig } from '../Properties/PropertiesConfig'
102
+ const isExcluded = PropertiesConfig.getTypesExclude()
103
+ const skipVue = PropertiesConfig.isTypesWithoutVue()
104
+ ```
@@ -0,0 +1,150 @@
1
+ # Centralized Error Handling Guide (`ErrorCenter`)
2
+
3
+ Mandatory instructions for AI coding assistants on error management in `@dxtmisha/functional-basic`.
4
+
5
+ ---
6
+
7
+ ## 1. 🔴 Mandatory Rule: Zero Direct Console Logging
8
+
9
+ > **STRICT PROHIBITION**: Direct error logging via `console.error()`, `console.warn()`, or `console.log()` is **FORBIDDEN** across all library and application code.
10
+ > **MANDATORY**: Every caught exception, validation failure, network error, or unexpected state **MUST** be routed strictly through `ErrorCenter.on(...)`.
11
+
12
+ ---
13
+
14
+ ## 2. Core Architecture
15
+
16
+ `ErrorCenter` is a static facade (bridge) that delegates all operations to `ErrorCenterInstance`.
17
+
18
+ ```typescript
19
+ import { ErrorCenter, type ErrorCenterInstance } from '@dxtmisha/functional-basic';
20
+
21
+ // 1. Static global access
22
+ ErrorCenter.on({ group: 'api', code: 'timeout' });
23
+
24
+ // 2. Class Dependency Injection (DI) pattern
25
+ export class MyService {
26
+ constructor(
27
+ private errorCenter: ErrorCenterInstance = ErrorCenter.getItem()
28
+ ) {}
29
+
30
+ doAction() {
31
+ try {
32
+ // logic
33
+ } catch (e) {
34
+ this.errorCenter.on({ group: 'storage', code: 'error', details: e });
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 3. Error Structure (`ErrorCenterCauseItem`)
43
+
44
+ | Property | Type | Required | Description |
45
+ |---|---|:---:|---|
46
+ | `group` | `string \| undefined` | No | Domain category (`'api'`, `'intl'`, `'storage'`, `'auth'`, etc.). |
47
+ | `code` | `string` | **Yes** | Unique error code identifier within the group. |
48
+ | `priority` | `number` | No | Merge priority (default `500`). Higher priority overrides lower. |
49
+ | `label` | `string` | No | Short human-readable title / header. |
50
+ | `message` | `string` | No | Descriptive error message. |
51
+ | `details` | `unknown` | No | Raw error payload (Error instance, response data, context). |
52
+
53
+ ---
54
+
55
+ ## 4. Triggering Errors (`ErrorCenter.on`)
56
+
57
+ Use `ErrorCenter.on(...)` whenever handling exceptions or error conditions:
58
+
59
+ ```typescript
60
+ import { ErrorCenter } from '@dxtmisha/functional-basic';
61
+
62
+ // Try/Catch handling
63
+ try {
64
+ JSON.parse(invalidJsonString);
65
+ } catch (error) {
66
+ ErrorCenter.on({
67
+ group: 'transformation',
68
+ code: 'error',
69
+ details: error
70
+ });
71
+ }
72
+
73
+ // Custom domain error with payload
74
+ if (!isUserAuthorized) {
75
+ ErrorCenter.on({
76
+ group: 'auth',
77
+ code: 'unauthorized',
78
+ message: 'Session has expired.',
79
+ details: { userId: '123' }
80
+ });
81
+ }
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 5. Built-in Standard Error Groups & Codes
87
+
88
+ Pre-registered in `errorCauseList` (no manual registration needed):
89
+
90
+ | Group | Codes | Description |
91
+ |---|---|---|
92
+ | `api` | `forbidden` (403), `notFound` (404), `offline`, `server` (500), `timeout`, `unauthorized` (401), `unknown`, `cacheClear`, `cacheGet`, `cacheRemove`, `cacheSet` | HTTP requests & API cache failures |
93
+ | `intl` | `datetime`, `display`, `number`, `plural`, `relative`, `invalid` | Internationalization & date parsing errors |
94
+ | `storage` | `context`, `error` | `DataStorage`, `CookieStorage`, `ServerStorage` |
95
+ | `broadcast` | `error` | Cross-tab `BroadcastChannel` communication |
96
+ | `clipboard` | `error` | Clipboard read / write operations |
97
+ | `hydration` | `error` | Server / client state hydration mismatches |
98
+ | `share` | `error` | Web Share API errors |
99
+ | `transformation` | `error` | Data serialization / parsing errors |
100
+ | `translate` | `error` | Localization dictionary loading |
101
+
102
+ ---
103
+
104
+ ## 6. Registration & Handlers
105
+
106
+ ### 6.1 Registering Custom Causes (`add` / `addList`)
107
+ Store error templates in advance to keep code clean and decoupled:
108
+ ```typescript
109
+ ErrorCenter.add({
110
+ group: 'payment',
111
+ code: 'INSUFFICIENT_FUNDS',
112
+ label: 'Payment Failed',
113
+ message: 'You have insufficient funds to complete this transaction.'
114
+ });
115
+
116
+ ErrorCenter.addList([
117
+ { group: 'upload', code: 'TOO_LARGE', label: 'File Too Large', message: 'Max size is 10MB.' }
118
+ ]);
119
+ ```
120
+
121
+ ### 6.2 Group Handlers (`addHandler` / `addHandlerList`)
122
+ Subscribe to specific groups (e.g., to trigger UI toasts or alerts):
123
+ ```typescript
124
+ ErrorCenter.addHandler('api', (cause) => {
125
+ showToast(cause.label || 'Network Error', cause.message);
126
+ });
127
+
128
+ // Fallback handler for unassigned groups
129
+ ErrorCenter.addHandler(undefined, (cause) => {
130
+ showToast('Error', cause.message);
131
+ });
132
+ ```
133
+
134
+ ### 6.3 Universal Telemetry Callback (`addCallback`)
135
+ Invoked on **every** error event (ideal for Sentry, Datadog, logging services):
136
+ ```typescript
137
+ ErrorCenter.addCallback((cause) => {
138
+ Sentry.captureException(cause.details || new Error(cause.message), {
139
+ tags: { group: cause.group, code: cause.code },
140
+ extra: cause
141
+ });
142
+ });
143
+ ```
144
+
145
+ ### 6.4 Console Output Control (`setIsConsole`)
146
+ Control automatic console logging (supports boolean or filter callback):
147
+ ```typescript
148
+ ErrorCenter.setIsConsole(false); // Disable console logging completely
149
+ ErrorCenter.setIsConsole((cause) => cause.group !== 'analytics'); // Conditional filter
150
+ ```