@ramathibodi/nuxt-commons 4.0.12 → 4.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/dialog/ImportProgress.d.vue.ts +35 -0
- package/dist/runtime/components/dialog/ImportProgress.vue +53 -0
- package/dist/runtime/components/dialog/ImportProgress.vue.d.ts +35 -0
- package/dist/runtime/components/document/TemplateBuilder.vue +112 -7
- package/dist/runtime/components/model/Pad.vue +2 -1
- package/dist/runtime/components/model/Table.d.vue.ts +79 -12
- package/dist/runtime/components/model/Table.vue +106 -3
- package/dist/runtime/components/model/Table.vue.d.ts +79 -12
- package/dist/runtime/components/model/iterator.d.vue.ts +117 -29
- package/dist/runtime/components/model/iterator.vue +117 -5
- package/dist/runtime/components/model/iterator.vue.d.ts +117 -29
- package/dist/runtime/composables/apiModel.d.ts +20 -1
- package/dist/runtime/composables/apiModel.js +24 -16
- package/dist/runtime/composables/document/template.d.ts +61 -0
- package/dist/runtime/composables/document/template.js +59 -0
- package/dist/runtime/composables/document/validateTemplate.d.ts +62 -0
- package/dist/runtime/composables/document/validateTemplate.js +378 -0
- package/dist/runtime/composables/graphqlModel.d.ts +20 -1
- package/dist/runtime/composables/graphqlModel.js +24 -16
- package/dist/runtime/composables/graphqlModelOperation.d.ts +1 -0
- package/dist/runtime/composables/importProgress.d.ts +34 -0
- package/dist/runtime/composables/importProgress.js +50 -0
- package/dist/runtime/utils/virtualize.d.ts +15 -0
- package/dist/runtime/utils/virtualize.js +10 -0
- package/package.json +2 -1
- package/scripts/validate-document-template.mjs +158 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Codegen-style validator for Document Template JSON.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node scripts/validate-document-template.mjs [file|glob ...] [options]
|
|
7
|
+
* cat template.json | node scripts/validate-document-template.mjs
|
|
8
|
+
*
|
|
9
|
+
* Options:
|
|
10
|
+
* --strict Promote builder-unsafe warnings to errors (exit 1 on them too).
|
|
11
|
+
* --json Emit machine-readable JSON: [{ file, result }].
|
|
12
|
+
* --quiet Print errors only (suppress warnings and infos).
|
|
13
|
+
* -h, --help Show this help.
|
|
14
|
+
*
|
|
15
|
+
* Exit code: 1 if any input has errors (warnings count as errors under --strict),
|
|
16
|
+
* otherwise 0.
|
|
17
|
+
*
|
|
18
|
+
* Shares the exact validation core used by the `useDocumentTemplate` runtime via
|
|
19
|
+
* jiti (the TypeScript loader Nuxt already ships), so the CLI and the composable
|
|
20
|
+
* can never diverge.
|
|
21
|
+
*/
|
|
22
|
+
import { readFileSync } from 'node:fs'
|
|
23
|
+
import { fileURLToPath } from 'node:url'
|
|
24
|
+
import { dirname, resolve, relative } from 'node:path'
|
|
25
|
+
import process from 'node:process'
|
|
26
|
+
import { createJiti } from 'jiti'
|
|
27
|
+
|
|
28
|
+
const dir = dirname(fileURLToPath(import.meta.url))
|
|
29
|
+
const repoRoot = resolve(dir, '..')
|
|
30
|
+
|
|
31
|
+
const jiti = createJiti(import.meta.url)
|
|
32
|
+
const { validateDocumentTemplate } = await jiti.import(
|
|
33
|
+
resolve(repoRoot, 'src/runtime/composables/document/validateTemplate.ts'),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
// --- arg parsing -----------------------------------------------------------
|
|
37
|
+
const argv = process.argv.slice(2)
|
|
38
|
+
const flags = new Set(argv.filter(a => a.startsWith('-')))
|
|
39
|
+
const files = argv.filter(a => !a.startsWith('-'))
|
|
40
|
+
|
|
41
|
+
if (flags.has('-h') || flags.has('--help')) {
|
|
42
|
+
printHelp()
|
|
43
|
+
process.exit(0)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const strict = flags.has('--strict')
|
|
47
|
+
const asJson = flags.has('--json')
|
|
48
|
+
const quiet = flags.has('--quiet')
|
|
49
|
+
|
|
50
|
+
// --- input collection ------------------------------------------------------
|
|
51
|
+
/** @type {{ file: string, content: string }[]} */
|
|
52
|
+
const inputs = []
|
|
53
|
+
|
|
54
|
+
if (files.length === 0) {
|
|
55
|
+
const stdin = readFileSync(0, 'utf8')
|
|
56
|
+
if (!stdin.trim()) {
|
|
57
|
+
console.error('No input: pass file paths/globs or pipe JSON via stdin.')
|
|
58
|
+
process.exit(2)
|
|
59
|
+
}
|
|
60
|
+
inputs.push({ file: '<stdin>', content: stdin })
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const resolved = await expandGlobs(files)
|
|
64
|
+
if (resolved.length === 0) {
|
|
65
|
+
console.error(`No files matched: ${files.join(', ')}`)
|
|
66
|
+
process.exit(2)
|
|
67
|
+
}
|
|
68
|
+
for (const f of resolved) {
|
|
69
|
+
try {
|
|
70
|
+
inputs.push({ file: f, content: readFileSync(f, 'utf8') })
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.error(`Cannot read ${f}: ${e.message}`)
|
|
74
|
+
process.exit(2)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// --- validation ------------------------------------------------------------
|
|
80
|
+
const results = inputs.map(({ file, content }) => ({
|
|
81
|
+
file,
|
|
82
|
+
result: validateDocumentTemplate(content, { strict }),
|
|
83
|
+
}))
|
|
84
|
+
|
|
85
|
+
const hadErrors = results.some(r => !r.result.valid)
|
|
86
|
+
|
|
87
|
+
if (asJson) {
|
|
88
|
+
const rel = f => (f === '<stdin>' ? f : relative(repoRoot, resolve(f)))
|
|
89
|
+
console.log(JSON.stringify(results.map(r => ({ file: rel(r.file), result: r.result })), null, 2))
|
|
90
|
+
process.exit(hadErrors ? 1 : 0)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// --- human report ----------------------------------------------------------
|
|
94
|
+
let totalErrors = 0
|
|
95
|
+
let totalWarnings = 0
|
|
96
|
+
let totalInfos = 0
|
|
97
|
+
|
|
98
|
+
for (const { file, result } of results) {
|
|
99
|
+
const shown = quiet ? result.errors : result.issues
|
|
100
|
+
totalErrors += result.errors.length
|
|
101
|
+
totalWarnings += result.warnings.length
|
|
102
|
+
totalInfos += result.infos.length
|
|
103
|
+
|
|
104
|
+
const status = result.valid ? (result.warnings.length ? 'WARN' : 'OK') : 'FAIL'
|
|
105
|
+
console.log(`\n${status} ${file}`)
|
|
106
|
+
if (shown.length === 0) {
|
|
107
|
+
if (!quiet) console.log(' no issues')
|
|
108
|
+
continue
|
|
109
|
+
}
|
|
110
|
+
for (const issue of shown) {
|
|
111
|
+
const tag = issue.severity.toUpperCase().padEnd(7)
|
|
112
|
+
const loc = issue.path || '(root)'
|
|
113
|
+
console.log(` ${tag} ${loc} ${issue.code} ${issue.message}`)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log(
|
|
118
|
+
`\n${results.length} file(s): ${totalErrors} error(s), ${totalWarnings} warning(s), ${totalInfos} info(s)`
|
|
119
|
+
+ (strict ? ' [strict]' : ''),
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
process.exit(hadErrors ? 1 : 0)
|
|
123
|
+
|
|
124
|
+
// --- helpers ---------------------------------------------------------------
|
|
125
|
+
async function expandGlobs(patterns) {
|
|
126
|
+
const out = []
|
|
127
|
+
for (const p of patterns) {
|
|
128
|
+
if (/[*?[\]{}]/.test(p)) {
|
|
129
|
+
try {
|
|
130
|
+
const { glob } = await import('node:fs/promises')
|
|
131
|
+
for await (const entry of glob(p)) out.push(entry)
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
console.error(`Globbing not supported in this Node version for "${p}"; pass explicit file paths.`)
|
|
135
|
+
process.exit(2)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
out.push(p)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// De-dupe while preserving order.
|
|
143
|
+
return [...new Set(out)]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function printHelp() {
|
|
147
|
+
console.log(`Validate Document Template JSON.
|
|
148
|
+
|
|
149
|
+
Usage:
|
|
150
|
+
node scripts/validate-document-template.mjs [file|glob ...] [options]
|
|
151
|
+
cat template.json | node scripts/validate-document-template.mjs
|
|
152
|
+
|
|
153
|
+
Options:
|
|
154
|
+
--strict Promote builder-unsafe warnings to errors.
|
|
155
|
+
--json Emit machine-readable JSON.
|
|
156
|
+
--quiet Print errors only.
|
|
157
|
+
-h, --help Show this help.`)
|
|
158
|
+
}
|