@voxgig/apidef 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apidef.js +14 -1
- package/dist/apidef.js.map +1 -1
- package/dist/guide/heuristic01.js +189 -50
- package/dist/guide/heuristic01.js.map +1 -1
- package/dist/guide.js +36 -8
- package/dist/guide.js.map +1 -1
- package/dist/parse.d.ts +2 -1
- package/dist/parse.js +81 -3
- package/dist/parse.js.map +1 -1
- package/dist/transform/clean.d.ts +3 -0
- package/dist/transform/clean.js +16 -0
- package/dist/transform/clean.js.map +1 -0
- package/dist/transform/field.js +24 -1
- package/dist/transform/field.js.map +1 -1
- package/dist/transform/operation.js +88 -23
- package/dist/transform/operation.js.map +1 -1
- package/dist/transform.d.ts +1 -8
- package/dist/transform.js +121 -94
- package/dist/transform.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.d.ts +6 -1
- package/dist/utility.js +42 -14
- package/dist/utility.js.map +1 -1
- package/model/apidef.jsonic +1 -0
- package/package.json +8 -9
- package/src/apidef.ts +24 -3
- package/src/guide/heuristic01.ts +263 -59
- package/src/guide.ts +48 -9
- package/src/parse.ts +106 -4
- package/src/transform/clean.ts +28 -0
- package/src/transform/field.ts +27 -1
- package/src/transform/operation.ts +118 -31
- package/src/transform.ts +28 -21
- package/src/utility.ts +48 -14
package/src/utility.ts
CHANGED
|
@@ -8,6 +8,26 @@ import type {
|
|
|
8
8
|
} from './types'
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
function getdlog(
|
|
12
|
+
tagin?: string,
|
|
13
|
+
filepath?: string)
|
|
14
|
+
: ((...args: any[]) => void) &
|
|
15
|
+
{ tag: string, file: string, log: (fp?: string) => any[] } {
|
|
16
|
+
const tag = tagin || '-'
|
|
17
|
+
const file = Path.basename(filepath || '-')
|
|
18
|
+
const g = global as any
|
|
19
|
+
g.__dlog__ = (g.__dlog__ || [])
|
|
20
|
+
const dlog = (...args: any[]) =>
|
|
21
|
+
g.__dlog__.push([tag, file, Date.now(), ...args])
|
|
22
|
+
dlog.tag = tag
|
|
23
|
+
dlog.file = file
|
|
24
|
+
dlog.log = (filepath?: string, f?: string | null) =>
|
|
25
|
+
(f = null == filepath ? null : Path.basename(filepath),
|
|
26
|
+
g.__dlog__.filter((n: any[]) => n[0] === tag && (null == f || n[2] === f)))
|
|
27
|
+
return dlog
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
11
31
|
function loadFile(path: string, what: string, fs: FsUtil, log: Log) {
|
|
12
32
|
try {
|
|
13
33
|
const source = fs.readFileSync(path, 'utf8')
|
|
@@ -36,27 +56,35 @@ function depluralize(word: string): string {
|
|
|
36
56
|
|
|
37
57
|
// Common irregular plurals
|
|
38
58
|
const irregulars: Record<string, string> = {
|
|
59
|
+
'analyses': 'analysis',
|
|
60
|
+
'appendices': 'appendix',
|
|
61
|
+
'axes': 'axis',
|
|
39
62
|
'children': 'child',
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
63
|
+
'courses': 'course',
|
|
64
|
+
'crises': 'crisis',
|
|
65
|
+
'criteria': 'criterion',
|
|
66
|
+
'data': 'datum',
|
|
67
|
+
'diagnoses': 'diagnosis',
|
|
43
68
|
'feet': 'foot',
|
|
69
|
+
'furnace': 'furnaces',
|
|
44
70
|
'geese': 'goose',
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'data': 'datum',
|
|
48
|
-
'criteria': 'criterion',
|
|
49
|
-
'phenomena': 'phenomenon',
|
|
71
|
+
'horses': 'horse',
|
|
72
|
+
'house': 'houses',
|
|
50
73
|
'indices': 'index',
|
|
74
|
+
'license': 'licenses',
|
|
51
75
|
'matrices': 'matrix',
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'crises': 'crisis',
|
|
56
|
-
'diagnoses': 'diagnosis',
|
|
76
|
+
'men': 'man',
|
|
77
|
+
'mice': 'mouse',
|
|
78
|
+
'notice': 'notices',
|
|
57
79
|
'oases': 'oasis',
|
|
80
|
+
'people': 'person',
|
|
81
|
+
'phenomena': 'phenomenon',
|
|
82
|
+
'practice': 'practices',
|
|
83
|
+
'promise': 'promises',
|
|
84
|
+
'teeth': 'tooth',
|
|
58
85
|
'theses': 'thesis',
|
|
59
|
-
'
|
|
86
|
+
'vertices': 'vertex',
|
|
87
|
+
'women': 'woman',
|
|
60
88
|
}
|
|
61
89
|
|
|
62
90
|
if (irregulars[word]) {
|
|
@@ -65,6 +93,11 @@ function depluralize(word: string): string {
|
|
|
65
93
|
|
|
66
94
|
// Rules for regular plurals (applied in order)
|
|
67
95
|
|
|
96
|
+
if (word.endsWith('ies') && word.length > 3) {
|
|
97
|
+
return word.slice(0, -3) + 'y'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
68
101
|
// -ies -> -y (cities -> city)
|
|
69
102
|
if (word.endsWith('ies') && word.length > 3) {
|
|
70
103
|
return word.slice(0, -3) + 'y'
|
|
@@ -153,6 +186,7 @@ function writeChanged(
|
|
|
153
186
|
|
|
154
187
|
|
|
155
188
|
export {
|
|
189
|
+
getdlog,
|
|
156
190
|
loadFile,
|
|
157
191
|
formatJsonSrc,
|
|
158
192
|
depluralize,
|