@ramathibodi/nuxt-commons 0.1.73 → 4.0.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 (260) hide show
  1. package/README.md +81 -55
  2. package/dist/module.json +4 -4
  3. package/dist/module.mjs +5 -4
  4. package/dist/runtime/bridges/authentication.d.ts +21 -0
  5. package/dist/runtime/bridges/authentication.js +20 -0
  6. package/dist/runtime/bridges/graphql.d.ts +17 -0
  7. package/dist/runtime/bridges/graphql.js +45 -0
  8. package/dist/runtime/components/Alert.d.vue.ts +3 -0
  9. package/dist/runtime/components/Alert.vue +17 -22
  10. package/dist/runtime/components/Alert.vue.d.ts +3 -0
  11. package/dist/runtime/components/BarcodeReader.d.vue.ts +9 -0
  12. package/dist/runtime/components/BarcodeReader.vue +56 -73
  13. package/dist/runtime/components/BarcodeReader.vue.d.ts +9 -0
  14. package/dist/runtime/components/ExportCSV.d.vue.ts +55 -0
  15. package/dist/runtime/components/ExportCSV.vue +39 -68
  16. package/dist/runtime/components/ExportCSV.vue.d.ts +55 -0
  17. package/dist/runtime/components/FileBtn.d.vue.ts +53 -0
  18. package/dist/runtime/components/FileBtn.vue +23 -38
  19. package/dist/runtime/components/FileBtn.vue.d.ts +53 -0
  20. package/dist/runtime/components/ImportCSV.d.vue.ts +52 -0
  21. package/dist/runtime/components/ImportCSV.vue +60 -99
  22. package/dist/runtime/components/ImportCSV.vue.d.ts +52 -0
  23. package/dist/runtime/components/MrzReader.d.vue.ts +19 -0
  24. package/dist/runtime/components/MrzReader.vue +128 -0
  25. package/dist/runtime/components/MrzReader.vue.d.ts +19 -0
  26. package/dist/runtime/components/SplitterPanel.d.vue.ts +15 -0
  27. package/dist/runtime/components/SplitterPanel.vue +18 -27
  28. package/dist/runtime/components/SplitterPanel.vue.d.ts +15 -0
  29. package/dist/runtime/components/TabsGroup.d.vue.ts +19 -0
  30. package/dist/runtime/components/TabsGroup.vue +8 -12
  31. package/dist/runtime/components/TabsGroup.vue.d.ts +19 -0
  32. package/dist/runtime/components/TextBarcode.d.vue.ts +12 -0
  33. package/dist/runtime/components/TextBarcode.vue +22 -33
  34. package/dist/runtime/components/TextBarcode.vue.d.ts +12 -0
  35. package/dist/runtime/components/device/IdCardButton.d.vue.ts +57 -0
  36. package/dist/runtime/components/device/IdCardButton.vue +30 -55
  37. package/dist/runtime/components/device/IdCardButton.vue.d.ts +57 -0
  38. package/dist/runtime/components/device/IdCardWebSocket.d.vue.ts +55 -0
  39. package/dist/runtime/components/device/IdCardWebSocket.vue +104 -153
  40. package/dist/runtime/components/device/IdCardWebSocket.vue.d.ts +55 -0
  41. package/dist/runtime/components/device/Scanner.d.vue.ts +66 -0
  42. package/dist/runtime/components/device/Scanner.vue +97 -166
  43. package/dist/runtime/components/device/Scanner.vue.d.ts +66 -0
  44. package/dist/runtime/components/dialog/Confirm.d.vue.ts +37 -0
  45. package/dist/runtime/components/dialog/Confirm.vue +30 -47
  46. package/dist/runtime/components/dialog/Confirm.vue.d.ts +37 -0
  47. package/dist/runtime/components/dialog/Host.d.vue.ts +9 -0
  48. package/dist/runtime/components/dialog/Host.vue +34 -53
  49. package/dist/runtime/components/dialog/Host.vue.d.ts +9 -0
  50. package/dist/runtime/components/dialog/Index.d.vue.ts +24 -0
  51. package/dist/runtime/components/dialog/Index.vue +20 -28
  52. package/dist/runtime/components/dialog/Index.vue.d.ts +24 -0
  53. package/dist/runtime/components/dialog/Loading.d.vue.ts +21 -0
  54. package/dist/runtime/components/dialog/Loading.vue +12 -17
  55. package/dist/runtime/components/dialog/Loading.vue.d.ts +21 -0
  56. package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +40 -0
  57. package/dist/runtime/components/dialog/default/Confirm.vue +29 -50
  58. package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +40 -0
  59. package/dist/runtime/components/dialog/default/Loading.d.vue.ts +23 -0
  60. package/dist/runtime/components/dialog/default/Loading.vue +12 -17
  61. package/dist/runtime/components/dialog/default/Loading.vue.d.ts +23 -0
  62. package/dist/runtime/components/dialog/default/Notify.d.vue.ts +23 -0
  63. package/dist/runtime/components/dialog/default/Notify.vue +19 -36
  64. package/dist/runtime/components/dialog/default/Notify.vue.d.ts +23 -0
  65. package/dist/runtime/components/dialog/default/Printing.d.vue.ts +21 -0
  66. package/dist/runtime/components/dialog/default/Printing.vue +13 -17
  67. package/dist/runtime/components/dialog/default/Printing.vue.d.ts +21 -0
  68. package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +29 -0
  69. package/dist/runtime/components/dialog/default/VerifyUser.vue +44 -70
  70. package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +29 -0
  71. package/dist/runtime/components/document/Form.d.vue.ts +9 -0
  72. package/dist/runtime/components/document/Form.vue +27 -34
  73. package/dist/runtime/components/document/Form.vue.d.ts +9 -0
  74. package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +24 -0
  75. package/dist/runtime/components/document/TemplateBuilder.vue +154 -182
  76. package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +24 -0
  77. package/dist/runtime/components/form/ActionPad.d.vue.ts +114 -0
  78. package/dist/runtime/components/form/ActionPad.vue +48 -73
  79. package/dist/runtime/components/form/ActionPad.vue.d.ts +114 -0
  80. package/dist/runtime/components/form/Birthdate.d.vue.ts +38 -0
  81. package/dist/runtime/components/form/Birthdate.vue +44 -64
  82. package/dist/runtime/components/form/Birthdate.vue.d.ts +38 -0
  83. package/dist/runtime/components/form/CheckboxGroup.d.vue.ts +41 -0
  84. package/dist/runtime/components/form/CheckboxGroup.vue +34 -52
  85. package/dist/runtime/components/form/CheckboxGroup.vue.d.ts +41 -0
  86. package/dist/runtime/components/form/CodeEditor.d.vue.ts +25 -0
  87. package/dist/runtime/components/form/CodeEditor.vue +18 -28
  88. package/dist/runtime/components/form/CodeEditor.vue.d.ts +25 -0
  89. package/dist/runtime/components/form/Date.d.vue.ts +86 -0
  90. package/dist/runtime/components/form/Date.vue +109 -150
  91. package/dist/runtime/components/form/Date.vue.d.ts +86 -0
  92. package/dist/runtime/components/form/DateTime.d.vue.ts +36 -0
  93. package/dist/runtime/components/form/DateTime.vue +94 -131
  94. package/dist/runtime/components/form/DateTime.vue.d.ts +36 -0
  95. package/dist/runtime/components/form/Dialog.d.vue.ts +69 -0
  96. package/dist/runtime/components/form/Dialog.vue +60 -84
  97. package/dist/runtime/components/form/Dialog.vue.d.ts +69 -0
  98. package/dist/runtime/components/form/EditPad.d.vue.ts +113 -0
  99. package/dist/runtime/components/form/EditPad.vue +49 -73
  100. package/dist/runtime/components/form/EditPad.vue.d.ts +113 -0
  101. package/dist/runtime/components/form/File.d.vue.ts +65 -0
  102. package/dist/runtime/components/form/File.vue +112 -174
  103. package/dist/runtime/components/form/File.vue.d.ts +65 -0
  104. package/dist/runtime/components/form/Hidden.d.vue.ts +12 -0
  105. package/dist/runtime/components/form/Hidden.vue +17 -22
  106. package/dist/runtime/components/form/Hidden.vue.d.ts +12 -0
  107. package/dist/runtime/components/form/Iterator.d.vue.ts +279 -0
  108. package/dist/runtime/components/form/Iterator.vue +162 -240
  109. package/dist/runtime/components/form/Iterator.vue.d.ts +279 -0
  110. package/dist/runtime/components/form/Login.d.vue.ts +32 -0
  111. package/dist/runtime/components/form/Login.vue +23 -43
  112. package/dist/runtime/components/form/Login.vue.d.ts +32 -0
  113. package/dist/runtime/components/form/Pad.d.vue.ts +674 -0
  114. package/dist/runtime/components/form/Pad.vue +166 -253
  115. package/dist/runtime/components/form/Pad.vue.d.ts +674 -0
  116. package/dist/runtime/components/form/SignPad.d.vue.ts +62 -0
  117. package/dist/runtime/components/form/SignPad.vue +80 -118
  118. package/dist/runtime/components/form/SignPad.vue.d.ts +62 -0
  119. package/dist/runtime/components/form/System.d.vue.ts +34 -0
  120. package/dist/runtime/components/form/System.vue +18 -24
  121. package/dist/runtime/components/form/System.vue.d.ts +34 -0
  122. package/dist/runtime/components/form/Table.d.vue.ts +221 -0
  123. package/dist/runtime/components/form/Table.vue +123 -170
  124. package/dist/runtime/components/form/Table.vue.d.ts +221 -0
  125. package/dist/runtime/components/form/TableData.d.vue.ts +102 -0
  126. package/dist/runtime/components/form/TableData.vue +109 -127
  127. package/dist/runtime/components/form/TableData.vue.d.ts +102 -0
  128. package/dist/runtime/components/form/Time.d.vue.ts +49 -0
  129. package/dist/runtime/components/form/Time.vue +64 -87
  130. package/dist/runtime/components/form/Time.vue.d.ts +49 -0
  131. package/dist/runtime/components/form/images/Capture.d.vue.ts +96 -0
  132. package/dist/runtime/components/form/images/Capture.vue +104 -139
  133. package/dist/runtime/components/form/images/Capture.vue.d.ts +96 -0
  134. package/dist/runtime/components/form/images/Edit.d.vue.ts +29 -0
  135. package/dist/runtime/components/form/images/Edit.vue +57 -69
  136. package/dist/runtime/components/form/images/Edit.vue.d.ts +29 -0
  137. package/dist/runtime/components/form/images/Field.d.vue.ts +27 -0
  138. package/dist/runtime/components/form/images/Field.vue +136 -194
  139. package/dist/runtime/components/form/images/Field.vue.d.ts +27 -0
  140. package/dist/runtime/components/form/images/Pad.d.vue.ts +13 -0
  141. package/dist/runtime/components/form/images/Pad.vue +23 -28
  142. package/dist/runtime/components/form/images/Pad.vue.d.ts +13 -0
  143. package/dist/runtime/components/label/Date.d.vue.ts +13 -0
  144. package/dist/runtime/components/label/Date.vue +13 -21
  145. package/dist/runtime/components/label/Date.vue.d.ts +13 -0
  146. package/dist/runtime/components/label/DateAgo.d.vue.ts +20 -0
  147. package/dist/runtime/components/label/DateAgo.vue +43 -67
  148. package/dist/runtime/components/label/DateAgo.vue.d.ts +20 -0
  149. package/dist/runtime/components/label/DateCount.d.vue.ts +22 -0
  150. package/dist/runtime/components/label/DateCount.vue +58 -97
  151. package/dist/runtime/components/label/DateCount.vue.d.ts +22 -0
  152. package/dist/runtime/components/label/Field.d.vue.ts +38 -0
  153. package/dist/runtime/components/label/Field.vue +18 -32
  154. package/dist/runtime/components/label/Field.vue.d.ts +38 -0
  155. package/dist/runtime/components/label/FormatMoney.d.vue.ts +12 -0
  156. package/dist/runtime/components/label/FormatMoney.vue +12 -20
  157. package/dist/runtime/components/label/FormatMoney.vue.d.ts +12 -0
  158. package/dist/runtime/components/label/Mask.d.vue.ts +10 -0
  159. package/dist/runtime/components/label/Mask.vue +21 -30
  160. package/dist/runtime/components/label/Mask.vue.d.ts +10 -0
  161. package/dist/runtime/components/label/Object.d.vue.ts +8 -0
  162. package/dist/runtime/components/label/Object.vue +10 -12
  163. package/dist/runtime/components/label/Object.vue.d.ts +8 -0
  164. package/dist/runtime/components/master/Autocomplete.d.vue.ts +70 -0
  165. package/dist/runtime/components/master/Autocomplete.vue +25 -26
  166. package/dist/runtime/components/master/Autocomplete.vue.d.ts +70 -0
  167. package/dist/runtime/components/master/Combobox.d.vue.ts +70 -0
  168. package/dist/runtime/components/master/Combobox.vue +26 -27
  169. package/dist/runtime/components/master/Combobox.vue.d.ts +70 -0
  170. package/dist/runtime/components/master/RadioGroup.d.vue.ts +51 -0
  171. package/dist/runtime/components/master/RadioGroup.vue +44 -47
  172. package/dist/runtime/components/master/RadioGroup.vue.d.ts +51 -0
  173. package/dist/runtime/components/master/Select.d.vue.ts +68 -0
  174. package/dist/runtime/components/master/Select.vue +25 -26
  175. package/dist/runtime/components/master/Select.vue.d.ts +68 -0
  176. package/dist/runtime/components/master/label.d.vue.ts +24 -0
  177. package/dist/runtime/components/master/label.vue +22 -34
  178. package/dist/runtime/components/master/label.vue.d.ts +24 -0
  179. package/dist/runtime/components/model/Autocomplete.d.vue.ts +82 -0
  180. package/dist/runtime/components/model/Autocomplete.vue +50 -37
  181. package/dist/runtime/components/model/Autocomplete.vue.d.ts +82 -0
  182. package/dist/runtime/components/model/Combobox.d.vue.ts +82 -0
  183. package/dist/runtime/components/model/Combobox.vue +51 -37
  184. package/dist/runtime/components/model/Combobox.vue.d.ts +82 -0
  185. package/dist/runtime/components/model/Pad.d.vue.ts +72 -0
  186. package/dist/runtime/components/model/Pad.vue +50 -53
  187. package/dist/runtime/components/model/Pad.vue.d.ts +72 -0
  188. package/dist/runtime/components/model/Select.d.vue.ts +72 -0
  189. package/dist/runtime/components/model/Select.vue +42 -32
  190. package/dist/runtime/components/model/Select.vue.d.ts +72 -0
  191. package/dist/runtime/components/model/Table.d.vue.ts +272 -0
  192. package/dist/runtime/components/model/Table.vue +121 -133
  193. package/dist/runtime/components/model/Table.vue.d.ts +272 -0
  194. package/dist/runtime/components/model/iterator.d.vue.ts +321 -0
  195. package/dist/runtime/components/model/iterator.vue +148 -175
  196. package/dist/runtime/components/model/iterator.vue.d.ts +321 -0
  197. package/dist/runtime/components/model/label.d.vue.ts +26 -0
  198. package/dist/runtime/components/model/label.vue +25 -35
  199. package/dist/runtime/components/model/label.vue.d.ts +26 -0
  200. package/dist/runtime/components/pdf/Print.d.vue.ts +17 -0
  201. package/dist/runtime/components/pdf/Print.vue +27 -38
  202. package/dist/runtime/components/pdf/Print.vue.d.ts +17 -0
  203. package/dist/runtime/components/pdf/View.d.vue.ts +52 -0
  204. package/dist/runtime/components/pdf/View.vue +58 -83
  205. package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
  206. package/dist/runtime/composables/alert.d.ts +4 -0
  207. package/dist/runtime/composables/api.d.ts +4 -0
  208. package/dist/runtime/composables/api.js +4 -2
  209. package/dist/runtime/composables/assetFile.js +4 -2
  210. package/dist/runtime/composables/dialog.d.ts +1 -1
  211. package/dist/runtime/composables/document/template.js +3 -3
  212. package/dist/runtime/composables/document/templateFormHidden.d.ts +4 -0
  213. package/dist/runtime/composables/document/templateFormTable.js +1 -0
  214. package/dist/runtime/composables/graphql.d.ts +2 -2
  215. package/dist/runtime/composables/graphql.js +5 -5
  216. package/dist/runtime/composables/graphqlModel.d.ts +6 -6
  217. package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
  218. package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
  219. package/dist/runtime/composables/graphqlModelOperation.js +2 -1
  220. package/dist/runtime/composables/graphqlOperation.js +5 -1
  221. package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
  222. package/dist/runtime/composables/localStorageModel.d.ts +4 -0
  223. package/dist/runtime/composables/lookupList.d.ts +4 -0
  224. package/dist/runtime/composables/lookupListMaster.js +3 -3
  225. package/dist/runtime/composables/menu.d.ts +4 -0
  226. package/dist/runtime/composables/menu.js +2 -2
  227. package/dist/runtime/composables/useMrzReader.d.ts +48 -0
  228. package/dist/runtime/composables/useMrzReader.js +423 -0
  229. package/dist/runtime/composables/useTesseract.d.ts +16 -0
  230. package/dist/runtime/composables/useTesseract.js +45 -0
  231. package/dist/runtime/composables/userPermission.d.ts +1 -1
  232. package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
  233. package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
  234. package/dist/runtime/labs/Calendar.vue +47 -75
  235. package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
  236. package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
  237. package/dist/runtime/labs/form/EditMobile.vue +19 -36
  238. package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
  239. package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
  240. package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
  241. package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
  242. package/dist/runtime/plugins/dialogManager.js +2 -2
  243. package/dist/runtime/plugins/permission.js +3 -3
  244. package/dist/runtime/types/bridge.d.ts +14 -0
  245. package/dist/runtime/utils/asset.d.ts +2 -0
  246. package/dist/runtime/utils/asset.js +49 -0
  247. package/dist/runtime/utils/datetime.js +1 -1
  248. package/dist/types.d.mts +2 -6
  249. package/package.json +79 -57
  250. package/scripts/ci-release.mjs +125 -0
  251. package/scripts/enrich-vue-docs-from-ai.mjs +197 -0
  252. package/scripts/generate-ai-summary.mjs +321 -0
  253. package/scripts/generate-composables-md.mjs +129 -0
  254. package/scripts/release-version.mjs +68 -0
  255. package/scripts/release.mjs +49 -0
  256. package/templates/public/tesseract/mrz.traineddata.gz +0 -0
  257. package/templates/public/tesseract/ocrb.traineddata.gz +0 -0
  258. package/dist/module.cjs +0 -5
  259. package/dist/module.d.ts +0 -8
  260. package/dist/types.d.ts +0 -7
@@ -0,0 +1,125 @@
1
+ import { execFileSync } from 'node:child_process'
2
+ import { readFileSync, writeFileSync } from 'node:fs'
3
+
4
+ import { findLatestVersionInReleaseLine, resolveReleasePlan } from './release-version.mjs'
5
+
6
+ function parseArgs(argv) {
7
+ const args = {}
8
+
9
+ for (let index = 0; index < argv.length; index += 1) {
10
+ const key = argv[index]
11
+
12
+ if (!key.startsWith('--')) {
13
+ continue
14
+ }
15
+
16
+ args[key.slice(2)] = argv[index + 1]
17
+ index += 1
18
+ }
19
+
20
+ return args
21
+ }
22
+
23
+ function exec(command, args, options = {}) {
24
+ return execFileSync(command, args, {
25
+ encoding: 'utf8',
26
+ stdio: ['inherit', 'pipe', 'inherit'],
27
+ ...options,
28
+ }).trim()
29
+ }
30
+
31
+ function run(command, args) {
32
+ execFileSync(command, args, { stdio: 'inherit' })
33
+ }
34
+
35
+ function formatNpmVersion(version) {
36
+ return version.startsWith('v') ? version : `v${version}`
37
+ }
38
+
39
+ function readPackageJson() {
40
+ return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
41
+ }
42
+
43
+ function writePackageJson(pkg) {
44
+ const packageJsonUrl = new URL('../package.json', import.meta.url)
45
+ writeFileSync(packageJsonUrl, `${JSON.stringify(pkg, null, 2)}\n`)
46
+ }
47
+
48
+ function getPublishedVersions(packageName) {
49
+ try {
50
+ const output = exec('npm', ['view', packageName, 'versions', '--json'])
51
+ const parsed = JSON.parse(output)
52
+
53
+ return Array.isArray(parsed) ? parsed : [parsed]
54
+ }
55
+ catch {
56
+ return []
57
+ }
58
+ }
59
+
60
+ function setPackageJson(pkg, updates) {
61
+ let dirty = false
62
+
63
+ for (const [key, value] of Object.entries(updates)) {
64
+ if (value != null && pkg[key] !== value) {
65
+ pkg[key] = value
66
+ dirty = true
67
+ }
68
+ }
69
+
70
+ if (dirty) {
71
+ writePackageJson(pkg)
72
+ }
73
+ }
74
+
75
+ function main() {
76
+ const args = parseArgs(process.argv.slice(2))
77
+ const releaseType = args.type
78
+ const packageName = args.name
79
+ const tagPrefix = args['tag-prefix'] ?? null
80
+
81
+ if (!releaseType || !packageName) {
82
+ throw new Error('Usage: node scripts/ci-release.mjs --type <patch|prerelease> --name <package-name> [--tag-prefix <prefix>]')
83
+ }
84
+
85
+ if (!['patch', 'prerelease'].includes(releaseType)) {
86
+ throw new Error(`Unsupported release type: ${releaseType}`)
87
+ }
88
+
89
+ const pkg = readPackageJson()
90
+ const publishedVersion = findLatestVersionInReleaseLine(pkg.version, getPublishedVersions(packageName))
91
+ const plan = resolveReleasePlan(pkg.version, publishedVersion)
92
+
93
+ setPackageJson(pkg, {
94
+ name: packageName,
95
+ version: plan.syncedPackageVersion,
96
+ })
97
+
98
+ let nextVersion
99
+
100
+ if (plan.releaseVersion) {
101
+ nextVersion = pkg.version === plan.releaseVersion
102
+ ? formatNpmVersion(plan.releaseVersion)
103
+ : exec('npm', ['version', '--no-git-tag-version', plan.releaseVersion])
104
+ }
105
+ else if (releaseType === 'patch') {
106
+ nextVersion = exec('npm', ['version', '--no-git-tag-version', 'patch'])
107
+ }
108
+ else {
109
+ nextVersion = exec('npm', ['version', '--no-git-tag-version', 'prerelease'])
110
+ }
111
+
112
+ if (releaseType === 'prerelease' && plan.releaseVersion) {
113
+ nextVersion = exec('npm', ['version', '--no-git-tag-version', 'prerelease'])
114
+ }
115
+
116
+ run('npm', ['publish'])
117
+
118
+ if (releaseType === 'patch') {
119
+ const gitTag = `${tagPrefix ?? ''}${nextVersion}`
120
+ run('git', ['tag', gitTag])
121
+ run('git', ['push', `https://gitlab-ci-token:${process.env.CI_JOB_TOKEN}@${process.env.CI_SERVER_HOST}/${process.env.CI_PROJECT_PATH}.git`, gitTag])
122
+ }
123
+ }
124
+
125
+ main()
@@ -0,0 +1,197 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ const rootDir = process.cwd()
5
+ const aiPath = path.join(rootDir, 'docs/ai-summary.json')
6
+ const docsDir = path.join(rootDir, 'docs/components')
7
+
8
+ if (!fs.existsSync(aiPath) || !fs.existsSync(docsDir)) {
9
+ console.log('Skip enrich: required docs/ai-summary.json or docs/components missing.')
10
+ process.exit(0)
11
+ }
12
+
13
+ const ai = JSON.parse(fs.readFileSync(aiPath, 'utf8'))
14
+ const componentMap = new Map(ai.components.map((c) => [c.path, c]))
15
+
16
+ function toPosix(p) {
17
+ return p.split(path.sep).join('/')
18
+ }
19
+
20
+ function guessSourcePathFromDoc(docFile) {
21
+ const rel = toPosix(path.relative(docsDir, docFile))
22
+ const noExt = rel.replace(/\.md$/, '')
23
+ return `src/runtime/components/${noExt}.vue`
24
+ }
25
+
26
+ function mdEscape(str) {
27
+ return String(str ?? '').replace(/\|/g, '\\|')
28
+ }
29
+
30
+ const propHints = {
31
+ modelName: { type: 'string', description: 'GraphQL model name used to resolve query/mutation operations.' },
32
+ modelBy: { type: 'Record<string, any>', description: 'Base filter object applied to read/search/create flows.' },
33
+ modelKey: { type: 'string', description: 'Unique key field used to identify and update existing rows/items.' },
34
+ fields: { type: 'Array<string | object>', description: 'Requested GraphQL fields used when loading records.' },
35
+ headers: { type: 'any[]', description: 'Column definitions used by table/iterator rendering.' },
36
+ itemTitle: { type: 'string', description: 'Item field used as display label.' },
37
+ itemValue: { type: 'string', description: 'Item field used as stored value.' },
38
+ filterKeys: { type: 'string | string[]', description: 'Keys used for client-side filtering/searching.' },
39
+ multiple: { type: 'boolean', description: 'Enables multi-select mode.' },
40
+ placeholder: { type: 'string', description: 'Placeholder text shown when input has no value.' },
41
+ noDataText: { type: 'string', description: 'Text shown when no matching data is available.' },
42
+ }
43
+
44
+ function inferTypeFromDocDefault(defaultCell) {
45
+ const v = (defaultCell || '').trim().replace(/^`|`$/g, '')
46
+ if (!v || v === '-' || v === 'undefined') return undefined
47
+ if (v === 'true' || v === 'false') return 'boolean'
48
+ if (/^-?\d+(\.\d+)?$/.test(v)) return 'number'
49
+ if ((v.startsWith("'") && v.endsWith("'")) || (v.startsWith('"') && v.endsWith('"'))) return 'string'
50
+ if (v.includes('=> []') || v === '[]') return 'any[]'
51
+ if (v.includes('=> ({') || v === '{}' || v === 'null') return 'Record<string, any>'
52
+ return undefined
53
+ }
54
+
55
+ function inferEventDescription(eventName, payload) {
56
+ if (eventName === 'update:modelValue') return 'Emitted when the bound model value changes.'
57
+ if (eventName === 'open:dialog') return 'Emitted when the component opens its dialog/form editor.'
58
+ if (eventName === 'close:dialog') return 'Emitted when the component closes its dialog/form editor.'
59
+ if (eventName === 'create') return 'Emitted after a create action completes.'
60
+ if (eventName === 'update') return 'Emitted after an update action completes.'
61
+ if (eventName === 'delete') return 'Emitted after a delete action completes.'
62
+ if (eventName === 'import') return 'Emitted after import data is parsed and ready.'
63
+ if (eventName === 'error') return 'Emitted when an operation fails.'
64
+ if (payload) return `Emits payload: \`${payload}\`.`
65
+ return 'Custom event emitted by this component.'
66
+ }
67
+
68
+ function splitRow(line) {
69
+ const cols = line.split('|').slice(1, -1).map((c) => c.trim())
70
+ return cols
71
+ }
72
+
73
+ function joinRow(cols) {
74
+ return `| ${cols.join(' | ')} |`
75
+ }
76
+
77
+ function updatePropsTable(lines, sectionStartIdx, component) {
78
+ // table starts after "## Props", header and separator rows
79
+ let i = sectionStartIdx + 1
80
+ while (i < lines.length && !lines[i].startsWith('|')) i++
81
+ if (i + 1 >= lines.length) return 0
82
+
83
+ const propsByName = new Map((component.props || []).map((p) => [p.name, p]))
84
+ let changed = 0
85
+
86
+ // skip header + separator
87
+ for (let r = i + 2; r < lines.length; r++) {
88
+ const line = lines[r]
89
+ if (!line.startsWith('|')) break
90
+ const cols = splitRow(line)
91
+ if (cols.length < 5) continue
92
+
93
+ const propName = cols[0].replace(/`/g, '').trim()
94
+ const meta = propsByName.get(propName)
95
+ const hint = propHints[propName]
96
+
97
+ const desc = cols[1]
98
+ const type = cols[2]
99
+ const def = cols[4]
100
+
101
+ if ((!desc || desc === '-') && meta?.description) cols[1] = mdEscape(meta.description)
102
+ else if ((!desc || desc === '-') && hint?.description) cols[1] = mdEscape(hint.description)
103
+
104
+ if ((type === '-' || !type) && meta?.type) cols[2] = `\`${mdEscape(meta.type)}\``
105
+ else if ((type === '-' || !type) && hint?.type) cols[2] = `\`${mdEscape(hint.type)}\``
106
+ else if ((type === '-' || !type)) {
107
+ const inferred = inferTypeFromDocDefault(def)
108
+ if (inferred) cols[2] = `\`${mdEscape(inferred)}\``
109
+ }
110
+
111
+ if ((!def || def === '-') && meta?.default !== undefined) cols[4] = `\`${mdEscape(meta.default)}\``
112
+
113
+ const next = joinRow(cols)
114
+ if (next !== line) {
115
+ lines[r] = next
116
+ changed++
117
+ }
118
+ }
119
+
120
+ return changed
121
+ }
122
+
123
+ function updateEventsTable(lines, sectionStartIdx, component) {
124
+ let i = sectionStartIdx + 1
125
+ while (i < lines.length && !lines[i].startsWith('|')) i++
126
+ if (i + 1 >= lines.length) return 0
127
+
128
+ const emitsByName = new Map((component.emits || []).map((e) => [e.event, e]))
129
+ let changed = 0
130
+
131
+ // skip header + separator
132
+ for (let r = i + 2; r < lines.length; r++) {
133
+ const line = lines[r]
134
+ if (!line.startsWith('|')) break
135
+ const cols = splitRow(line)
136
+ while (cols.length < 3) cols.push('')
137
+
138
+ const eventName = cols[0].replace(/`/g, '').trim()
139
+ const meta = emitsByName.get(eventName)
140
+ if (!meta) continue
141
+
142
+ const propsCol = cols[1]
143
+ const descCol = cols[2]
144
+
145
+ if ((!propsCol || propsCol === '-') && meta.payload) cols[1] = `\`${mdEscape(meta.payload)}\``
146
+ if (!descCol || descCol === '-') cols[2] = mdEscape(inferEventDescription(eventName, meta.payload))
147
+
148
+ const next = joinRow(cols)
149
+ if (next !== line) {
150
+ lines[r] = next
151
+ changed++
152
+ }
153
+ }
154
+
155
+ return changed
156
+ }
157
+
158
+ function processDocFile(docFile) {
159
+ const sourcePath = guessSourcePathFromDoc(docFile)
160
+ const component = componentMap.get(sourcePath)
161
+ if (!component) return 0
162
+
163
+ const content = fs.readFileSync(docFile, 'utf8')
164
+ const lines = content.split('\n')
165
+ let changed = 0
166
+
167
+ for (let i = 0; i < lines.length; i++) {
168
+ if (lines[i].trim() === '## Props') changed += updatePropsTable(lines, i, component)
169
+ if (lines[i].trim() === '## Events') changed += updateEventsTable(lines, i, component)
170
+ }
171
+
172
+ if (changed > 0) fs.writeFileSync(docFile, lines.join('\n'))
173
+ return changed
174
+ }
175
+
176
+ function walkMd(dir) {
177
+ const out = []
178
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
179
+ const full = path.join(dir, entry.name)
180
+ if (entry.isDirectory()) out.push(...walkMd(full))
181
+ else if (entry.name.endsWith('.md')) out.push(full)
182
+ }
183
+ return out
184
+ }
185
+
186
+ const mdFiles = walkMd(docsDir)
187
+ let changedFiles = 0
188
+ let changedRows = 0
189
+ for (const file of mdFiles) {
190
+ const changed = processDocFile(file)
191
+ if (changed > 0) {
192
+ changedFiles++
193
+ changedRows += changed
194
+ }
195
+ }
196
+
197
+ console.log(`Enriched ${changedRows} table rows across ${changedFiles} files.`)
@@ -0,0 +1,321 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ const rootDir = process.cwd()
5
+ const componentsDir = path.join(rootDir, 'src/runtime/components')
6
+ const composablesDir = path.join(rootDir, 'src/runtime/composables')
7
+ const outMdFile = path.join(rootDir, 'docs/ai-summary.md')
8
+ const outJsonFile = path.join(rootDir, 'docs/ai-summary.json')
9
+ const outTypeIndexFile = path.join(rootDir, 'docs/type-index.json')
10
+
11
+ function walkFiles(dir, exts = new Set(['.vue', '.ts'])) {
12
+ const result = []
13
+ if (!fs.existsSync(dir)) return result
14
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
15
+ const full = path.join(dir, entry.name)
16
+ if (entry.isDirectory()) {
17
+ result.push(...walkFiles(full, exts))
18
+ } else if (exts.has(path.extname(entry.name))) {
19
+ result.push(full)
20
+ }
21
+ }
22
+ return result.sort((a, b) => a.localeCompare(b))
23
+ }
24
+
25
+ function toPosix(p) {
26
+ return p.split(path.sep).join('/')
27
+ }
28
+
29
+ function extractTopDescription(content) {
30
+ const m = content.match(/\/\*\*([\s\S]*?)\*\//)
31
+ if (!m) return 'No top-level description found.'
32
+ const lines = m[1]
33
+ .split('\n')
34
+ .map((l) => l.replace(/^\s*\*\s?/, '').trim())
35
+ .filter(Boolean)
36
+ .filter((l) => !l.toLowerCase().includes('vue-docgen'))
37
+ return lines[0] || 'No top-level description found.'
38
+ }
39
+
40
+ function compact(str) {
41
+ return str.replace(/\s+/g, ' ').trim()
42
+ }
43
+
44
+ function findInterfaceBody(content, interfaceName) {
45
+ const needle = `interface ${interfaceName}`
46
+ const start = content.indexOf(needle)
47
+ if (start === -1) return null
48
+
49
+ const braceStart = content.indexOf('{', start)
50
+ if (braceStart === -1) return null
51
+
52
+ let depth = 0
53
+ for (let i = braceStart; i < content.length; i++) {
54
+ const ch = content[i]
55
+ if (ch === '{') depth++
56
+ if (ch === '}') depth--
57
+ if (depth === 0) {
58
+ return content.slice(braceStart + 1, i)
59
+ }
60
+ }
61
+ return null
62
+ }
63
+
64
+ function extractWithDefaults(content) {
65
+ const defaults = {}
66
+ const m = content.match(/withDefaults\s*\(\s*defineProps[\s\S]*?,\s*\{([\s\S]*?)\}\s*\)/)
67
+ if (!m) return defaults
68
+
69
+ const lines = m[1].split('\n')
70
+ for (const line of lines) {
71
+ const clean = line.trim()
72
+ if (!clean || clean.startsWith('//')) continue
73
+ const kv = clean.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.+?)(?:,\s*)?(?:\/\/\s*(.*))?$/)
74
+ if (!kv) continue
75
+ const key = kv[1]
76
+ const rawValue = kv[2].trim()
77
+ const description = (kv[3] || '').trim()
78
+ defaults[key] = { value: rawValue, description }
79
+ }
80
+
81
+ return defaults
82
+ }
83
+
84
+ function inferTypeFromDefault(rawValue) {
85
+ if (rawValue === 'true' || rawValue === 'false') return 'boolean'
86
+ if (rawValue === 'null') return 'null'
87
+ if (/^['"].*['"]$/.test(rawValue)) return 'string'
88
+ if (/^-?\d+(\.\d+)?$/.test(rawValue)) return 'number'
89
+ if (/^\(\)\s*=>\s*\[\s*\]$/.test(rawValue)) return 'any[]'
90
+ if (/^\(\)\s*=>\s*\(\s*\{\s*\}\s*\)$/.test(rawValue)) return 'Record<string, any>'
91
+ if (/^\(\)\s*=>\s*\[/.test(rawValue)) return 'any[]'
92
+ if (/^\(\)\s*=>\s*\(\s*\{/.test(rawValue)) return 'Record<string, any>'
93
+ return 'unknown'
94
+ }
95
+
96
+ function extractProps(content) {
97
+ const props = []
98
+ const ifaceBody = findInterfaceBody(content, 'Props')
99
+ const defaults = extractWithDefaults(content)
100
+
101
+ if (ifaceBody) {
102
+ const lines = ifaceBody.split('\n')
103
+ for (const line of lines) {
104
+ const m = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)(\?)?\s*:\s*([^/;]+(?:\|[^/;]+)*)[;]?\s*(?:\/\/\s*(.+))?\s*$/)
105
+ if (m) {
106
+ const name = m[1]
107
+ const optional = !!m[2]
108
+ const type = compact(m[3].trim())
109
+ const description = (m[4] || '').trim()
110
+ props.push({
111
+ name,
112
+ type,
113
+ required: !optional,
114
+ default: Object.prototype.hasOwnProperty.call(defaults, name) ? defaults[name].value : undefined,
115
+ description: description || (defaults[name]?.description || ''),
116
+ })
117
+ }
118
+ }
119
+ }
120
+
121
+ // Fallback for components where Props is empty and typed props come from imported intersections.
122
+ if (!props.length && Object.keys(defaults).length) {
123
+ for (const [name, meta] of Object.entries(defaults)) {
124
+ props.push({
125
+ name,
126
+ type: inferTypeFromDefault(meta.value),
127
+ required: false,
128
+ default: meta.value,
129
+ description: meta.description || 'Inferred from withDefaults()',
130
+ })
131
+ }
132
+ }
133
+
134
+ return props
135
+ }
136
+
137
+ function extractEmits(content) {
138
+ const emits = []
139
+
140
+ const typed = content.match(/defineEmits<\{([\s\S]*?)\}>\(\)/)
141
+ if (typed) {
142
+ const overloads = typed[1].matchAll(/\(\s*e\s*:\s*'([^']+)'\s*(?:,\s*([^)]*))?\)\s*:\s*void/g)
143
+ for (const m of overloads) {
144
+ emits.push({
145
+ event: m[1],
146
+ payload: m[2] ? compact(m[2]) : undefined,
147
+ })
148
+ }
149
+ }
150
+
151
+ const arr = content.match(/defineEmits\s*\(\s*\[([\s\S]*?)\]\s*\)/)
152
+ if (arr) {
153
+ const names = arr[1].matchAll(/'([^']+)'|"([^"]+)"/g)
154
+ for (const m of names) {
155
+ emits.push({ event: m[1] || m[2] })
156
+ }
157
+ }
158
+
159
+ return emits
160
+ }
161
+
162
+ function extractExports(content) {
163
+ const functions = []
164
+ const constants = []
165
+ const interfaces = []
166
+ const types = []
167
+ const enums = []
168
+
169
+ const fnMatches = content.matchAll(/export\s+function\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*?)\)\s*(?::\s*([^({;\n]+(?:<[\s\S]*?>)?))?\s*\{/g)
170
+ for (const m of fnMatches) {
171
+ functions.push({
172
+ name: m[1],
173
+ params: compact(m[2]),
174
+ returns: m[3] ? compact(m[3]) : undefined,
175
+ signature: compact(`function ${m[1]}(${m[2]})${m[3] ? `: ${m[3]}` : ''}`),
176
+ })
177
+ }
178
+
179
+ const constMatches = content.matchAll(/export\s+const\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*([^=;\n]+))?\s*=/g)
180
+ for (const m of constMatches) {
181
+ constants.push({
182
+ name: m[1],
183
+ type: m[2] ? compact(m[2]) : undefined,
184
+ })
185
+ }
186
+
187
+ const interfaceMatches = content.matchAll(/export\s+interface\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\n\}/g)
188
+ for (const m of interfaceMatches) {
189
+ interfaces.push({
190
+ name: m[1],
191
+ shape: compact(m[2]),
192
+ })
193
+ }
194
+
195
+ const typeMatches = content.matchAll(/export\s+type\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;\n]+(?:\n[^;\n]+)*)/g)
196
+ for (const m of typeMatches) {
197
+ types.push({
198
+ name: m[1],
199
+ definition: compact(m[2].replace(/\n/g, ' ')),
200
+ })
201
+ }
202
+
203
+ const enumMatches = content.matchAll(/export\s+enum\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}/g)
204
+ for (const m of enumMatches) {
205
+ const members = m[2]
206
+ .split('\n')
207
+ .map((line) => line.trim())
208
+ .filter(Boolean)
209
+ .map((line) => line.replace(/,$/, ''))
210
+ enums.push({
211
+ name: m[1],
212
+ members,
213
+ })
214
+ }
215
+
216
+ return { functions, constants, interfaces, types, enums }
217
+ }
218
+
219
+ const componentFiles = walkFiles(componentsDir, new Set(['.vue']))
220
+ const composableFiles = walkFiles(composablesDir, new Set(['.ts']))
221
+
222
+ const generatedAt = new Date().toISOString()
223
+ const docModel = {
224
+ generatedAt,
225
+ scope: {
226
+ componentCount: componentFiles.length,
227
+ composableCount: composableFiles.length,
228
+ },
229
+ components: [],
230
+ composables: [],
231
+ }
232
+
233
+ const lines = []
234
+ lines.push('# AI Summary')
235
+ lines.push('')
236
+ lines.push('AI-first summary generated from source files with explicit type metadata.')
237
+ lines.push('')
238
+ lines.push(`Generated at: ${generatedAt}`)
239
+ lines.push('')
240
+ lines.push('## Scope')
241
+ lines.push('')
242
+ lines.push(`- Components: ${componentFiles.length}`)
243
+ lines.push(`- Composables: ${composableFiles.length}`)
244
+ lines.push('')
245
+ lines.push('## Components')
246
+ lines.push('')
247
+
248
+ for (const file of componentFiles) {
249
+ const rel = toPosix(path.relative(rootDir, file))
250
+ const content = fs.readFileSync(file, 'utf8')
251
+ const summary = extractTopDescription(content)
252
+ const props = extractProps(content)
253
+ const emits = extractEmits(content)
254
+ const componentEntry = {
255
+ path: rel,
256
+ summary,
257
+ props,
258
+ emits,
259
+ }
260
+ docModel.components.push(componentEntry)
261
+
262
+ lines.push(`### \`${rel}\``)
263
+ lines.push(`- Summary: ${summary}`)
264
+ if (props.length) {
265
+ lines.push(`- Props (${props.length}):`)
266
+ for (const prop of props) {
267
+ const chunks = [
268
+ `type=${prop.type}`,
269
+ prop.required ? 'required=true' : 'required=false',
270
+ ]
271
+ if (prop.default !== undefined) chunks.push(`default=${prop.default}`)
272
+ if (prop.description) chunks.push(`desc=${prop.description}`)
273
+ lines.push(` - \`${prop.name}\` { ${chunks.join(' | ')} }`)
274
+ }
275
+ } else {
276
+ lines.push('- Props: None declared in a local `Props` interface.')
277
+ }
278
+ if (emits.length) {
279
+ lines.push(`- Emits (${emits.length}):`)
280
+ for (const e of emits) {
281
+ lines.push(` - \`${e.event}\`${e.payload ? ` payload: ${e.payload}` : ''}`)
282
+ }
283
+ } else {
284
+ lines.push('- Emits: None detected.')
285
+ }
286
+ lines.push('')
287
+ }
288
+
289
+ lines.push('## Composables')
290
+ lines.push('')
291
+
292
+ for (const file of composableFiles) {
293
+ const rel = toPosix(path.relative(rootDir, file))
294
+ const content = fs.readFileSync(file, 'utf8')
295
+ const summary = extractTopDescription(content)
296
+ const exports = extractExports(content)
297
+ const composableEntry = {
298
+ path: rel,
299
+ summary,
300
+ exports,
301
+ }
302
+ docModel.composables.push(composableEntry)
303
+
304
+ lines.push(`### \`${rel}\``)
305
+ lines.push(`- Summary: ${summary}`)
306
+ lines.push(`- Export functions (${exports.functions.length}): ${exports.functions.map((f) => `\`${f.signature}\``).join(', ') || 'none'}`)
307
+ lines.push(`- Export interfaces (${exports.interfaces.length}): ${exports.interfaces.map((i) => `\`${i.name}\``).join(', ') || 'none'}`)
308
+ lines.push(`- Export types (${exports.types.length}): ${exports.types.map((t) => `\`${t.name}\``).join(', ') || 'none'}`)
309
+ lines.push(`- Export consts (${exports.constants.length}): ${exports.constants.map((c) => `\`${c.name}\``).join(', ') || 'none'}`)
310
+ lines.push(`- Export enums (${exports.enums.length}): ${exports.enums.map((e) => `\`${e.name}\``).join(', ') || 'none'}`)
311
+ lines.push('')
312
+ }
313
+
314
+ fs.mkdirSync(path.dirname(outMdFile), { recursive: true })
315
+ fs.writeFileSync(outMdFile, lines.join('\n'))
316
+ fs.writeFileSync(outJsonFile, JSON.stringify(docModel, null, 2))
317
+ fs.writeFileSync(outTypeIndexFile, JSON.stringify(docModel, null, 2))
318
+
319
+ console.log(`Generated ${toPosix(path.relative(rootDir, outMdFile))}`)
320
+ console.log(`Generated ${toPosix(path.relative(rootDir, outJsonFile))}`)
321
+ console.log(`Generated ${toPosix(path.relative(rootDir, outTypeIndexFile))}`)