@voxgig/create-sdkgen 0.10.1 → 0.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/create-sdkgen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"main": "dist/create-sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/create-sdkgen.d.ts",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "25.6.0",
|
|
45
|
-
"memfs": "
|
|
46
|
-
"typescript": "
|
|
45
|
+
"memfs": "4.57.2",
|
|
46
|
+
"typescript": "6.0.3"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@voxgig/util": "
|
|
50
|
-
"aontu": "
|
|
51
|
-
"chokidar": "
|
|
52
|
-
"jostraca": "
|
|
53
|
-
"shape": "
|
|
49
|
+
"@voxgig/util": "0.4.0",
|
|
50
|
+
"aontu": "0.44.0",
|
|
51
|
+
"chokidar": "5.0.0",
|
|
52
|
+
"jostraca": "0.29.1",
|
|
53
|
+
"shape": "10.1.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
each,
|
|
11
11
|
} from '@voxgig/sdkgen'
|
|
12
12
|
|
|
13
|
+
import { camelify, lcf } from 'jostraca'
|
|
14
|
+
|
|
13
15
|
|
|
14
16
|
import type {
|
|
15
17
|
Model,
|
|
@@ -68,6 +70,12 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
68
70
|
|
|
69
71
|
const idmap = refs.reduce((a: any, ref) => (a[ref] = ref.toUpperCase(), a), {})
|
|
70
72
|
|
|
73
|
+
// Path params required across the entity's ops (excluding the entity's own
|
|
74
|
+
// id and any param renamed-to-id). The in-memory test mock's buildArgs
|
|
75
|
+
// searches existing entities by these fields, so they need to be present
|
|
76
|
+
// with values that match what the test code sends via setup.idmap.
|
|
77
|
+
const pathParams = collectEntityPathParams(entity)
|
|
78
|
+
|
|
71
79
|
let i = 1
|
|
72
80
|
|
|
73
81
|
refs.map((ref) => {
|
|
@@ -75,6 +83,12 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
75
83
|
const ent: any = data.existing[entity.name][id] = {}
|
|
76
84
|
|
|
77
85
|
makeEntityTestFields(entity, i++, ent)
|
|
86
|
+
for (const [paramName, paramValue] of pathParams) {
|
|
87
|
+
// Don't overwrite a real entity field with the same name.
|
|
88
|
+
if (ent[paramName] === undefined) {
|
|
89
|
+
ent[paramName] = paramValue
|
|
90
|
+
}
|
|
91
|
+
}
|
|
78
92
|
ent.id = id
|
|
79
93
|
})
|
|
80
94
|
|
|
@@ -87,6 +101,37 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
|
|
104
|
+
// Walk every op point on the entity, collect the names of path params, and
|
|
105
|
+
// pair each with its canonical idmap value. The canonical value mirrors the
|
|
106
|
+
// flow generator's path-param defaulting in apidef:
|
|
107
|
+
// `step.match[name] = name.replace(/_id$/,'') + '01'`
|
|
108
|
+
// Then setup.idmap maps that lower ref to upper: `company01 → COMPANY01`.
|
|
109
|
+
// So the value seeded into existing test data is the upper form: `COMPANY01`.
|
|
110
|
+
function collectEntityPathParams(entity: any): [string, string][] {
|
|
111
|
+
const out = new Map<string, string>()
|
|
112
|
+
const ops = entity?.op || {}
|
|
113
|
+
for (const opname of Object.keys(ops)) {
|
|
114
|
+
const op = ops[opname]
|
|
115
|
+
const points = op?.points || []
|
|
116
|
+
for (const point of points) {
|
|
117
|
+
const params = point?.args?.params || []
|
|
118
|
+
const renameMap: Record<string, string> = point?.rename?.param || {}
|
|
119
|
+
for (const param of params) {
|
|
120
|
+
if (!param?.name) continue
|
|
121
|
+
if ('id' === param.name) continue
|
|
122
|
+
// Skip params that ARE the entity's own id under URL rename.
|
|
123
|
+
const camel = lcf(camelify(param.name))
|
|
124
|
+
if ('id' === renameMap[camel]) continue
|
|
125
|
+
if (out.has(param.name)) continue
|
|
126
|
+
const baseName = param.name.replace(/_id$/, '')
|
|
127
|
+
out.set(param.name, baseName.toUpperCase() + '01')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return Array.from(out.entries())
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
90
135
|
function makeEntityTestFields(entity: ModelEntity, start: number, entdata: Record<string, any>) {
|
|
91
136
|
entdata = entdata ?? {}
|
|
92
137
|
let num = (start * size(entity.fields) * 10)
|