@voxgig/sdkgen 0.24.0 → 0.25.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/sdkgen",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/sdkgen.d.ts",
@@ -41,9 +41,9 @@
41
41
  "devDependencies": {
42
42
  "@hapi/code": "^9.0.3",
43
43
  "@types/js-yaml": "^4.0.9",
44
- "@types/node": "24.1.0",
44
+ "@types/node": "24.2.0",
45
45
  "json-schema-to-ts": "^3.1.1",
46
- "memfs": "^4.25.1",
46
+ "memfs": "^4.36.0",
47
47
  "typescript": "^5.9.2"
48
48
  },
49
49
  "peerDependencies": {
@@ -57,7 +57,7 @@ function basicSetup(extra?: any) {
57
57
  if ('TRUE' === setup.dm.p.${model.NAME}_TEST_LIVE) {
58
58
  client = new ${model.Name}SDK(merge([
59
59
  {
60
- apikey: process.env.${model.Name}_APIKEY,
60
+ apikey: process.env.${model.NAME}_APIKEY,
61
61
  },
62
62
  extra])
63
63
  )
@@ -29,10 +29,11 @@ const Package = cmp(async function Package(props: any) {
29
29
 
30
30
  const sdkname = model.name
31
31
  const origin = null == model.origin ? '' : `@${model.origin}/`
32
+ const sdknamesuffix = model.origin?.endsWith('-sdk') ? '' : '-sdk'
32
33
 
33
34
  // TODO: complete SDK meta data in model and use here
34
35
  const pkg = {
35
- name: `${origin}${sdkname}-sdk`,
36
+ name: `${origin}${sdkname}${sdknamesuffix}`,
36
37
  version: `0.0.1`,
37
38
  description: 'DESCRIPTION',
38
39
  main: `dist/${model.const.Name}SDK.js`,
@@ -36,12 +36,12 @@ function spec(ctx: Context) {
36
36
  let hasQuery = false
37
37
  const paramQuery: any = {}
38
38
  for (let paramName of op.params) {
39
- paramQuery[paramName] = null == ctx.spec.params[paramName] ? undefined : true
39
+ paramQuery[paramName] = null == ctx.spec.params[paramName] ? false : true
40
40
  hasQuery = true
41
41
  }
42
+
42
43
  if (hasQuery) {
43
44
  const foundParamAlts = select(op.pathalt, paramQuery)
44
- console.log('PQ', paramQuery, foundParamAlts)
45
45
  if (0 < size(foundParamAlts)) {
46
46
  ctx.spec.path = foundParamAlts[0].path
47
47
  }
@@ -756,11 +756,12 @@ function merge(val: any): any {
756
756
  parent: any,
757
757
  path: string[]
758
758
  ) {
759
+ // No key at top.
759
760
  if (null == key) {
760
761
  return val
761
762
  }
762
763
 
763
- // Get the curent value at the current path in obj.
764
+ // Get the current value at the current path in obj.
764
765
  // NOTE: this is not exactly efficient, and should be optimised.
765
766
  let lenpath = path.length
766
767
  cI = lenpath - 1
@@ -768,20 +769,37 @@ function merge(val: any): any {
768
769
  cur[cI] = getpath(out, slice(path, 0, lenpath - 1))
769
770
  }
770
771
 
772
+ // console.log('AAA', path, cur[cI])
773
+
771
774
  // Create node if needed.
772
775
  if (!isnode(cur[cI])) {
773
776
  cur[cI] = islist(parent) ? [] : {}
774
777
  }
775
778
 
779
+ // console.log('BBB', path, cur[cI])
780
+
781
+ // console.log('VAL', path, val, isnode(val), isempty(val))
782
+
776
783
  // Node child is just ahead of us on the stack, since
777
784
  // `walk` traverses leaves before nodes.
778
- if (isnode(val) && !isempty(val)) {
779
- setprop(cur[cI], key, cur[cI + 1])
780
- cur[cI + 1] = UNDEF
785
+ if (isnode(val)) {
786
+ const missing = UNDEF === getprop(cur[cI], key)
787
+ if (!isempty(val) || missing) { // || ) {
788
+ // console.log('CCC')
789
+
790
+ // if (missing) {
791
+ // console.log('MISSING', key, val, cur[cI], cur[cI + 1])
792
+ // }
793
+
794
+ const mval = missing ? val : cur[cI + 1]
795
+ setprop(cur[cI], key, mval)
796
+ cur[cI + 1] = UNDEF
797
+ }
781
798
  }
782
799
 
783
800
  // Scalar child.
784
801
  else {
802
+ // console.log('DDD', cur[cI], key, val)
785
803
  setprop(cur[cI], key, val)
786
804
  }
787
805
 
@@ -2304,6 +2322,8 @@ const _injecthandler: Injector = (
2304
2322
  const iscmd = isfunc(val) && (UNDEF === ref || ref.startsWith(S_DS))
2305
2323
 
2306
2324
  // Only call val function if it is a special command ($NAME format).
2325
+ // TODO: OR if meta.'$CALL'
2326
+
2307
2327
  if (iscmd) {
2308
2328
  out = (val as Injector)(inj, val, ref, store)
2309
2329
  }