@voxgig/sdkgen 0.24.0 → 0.26.1

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 (98) hide show
  1. package/bin/voxgig-sdkgen +6 -6
  2. package/dist/action/action.js +1 -2
  3. package/dist/action/action.js.map +1 -1
  4. package/dist/action/feature.js +4 -2
  5. package/dist/action/feature.js.map +1 -1
  6. package/dist/action/target.js +4 -2
  7. package/dist/action/target.js.map +1 -1
  8. package/dist/cmp/Entity.js +2 -1
  9. package/dist/cmp/Entity.js.map +1 -1
  10. package/dist/cmp/FeatureHook.js +2 -1
  11. package/dist/cmp/FeatureHook.js.map +1 -1
  12. package/dist/cmp/Main.js.map +1 -1
  13. package/dist/cmp/ReadmeEntity.js +2 -1
  14. package/dist/cmp/ReadmeEntity.js.map +1 -1
  15. package/dist/cmp/Test.d.ts +2 -0
  16. package/dist/cmp/Test.js +17 -0
  17. package/dist/cmp/Test.js.map +1 -0
  18. package/dist/sdkgen.d.ts +2 -1
  19. package/dist/sdkgen.js +17 -28
  20. package/dist/sdkgen.js.map +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/types.d.ts +3 -1
  23. package/dist/types.js +4 -0
  24. package/dist/types.js.map +1 -1
  25. package/model/sdkgen.jsonic +8 -8
  26. package/package.json +8 -6
  27. package/project/.sdk/model/feature/log.jsonic +2 -2
  28. package/project/.sdk/model/feature/test.jsonic +7 -2
  29. package/project/.sdk/model/target/js.jsonic +2 -2
  30. package/project/.sdk/model/target/ts.jsonic +2 -2
  31. package/project/.sdk/src/cmp/js/Main_js.ts +3 -3
  32. package/project/.sdk/src/cmp/js/Quick_js.ts +1 -1
  33. package/project/.sdk/src/cmp/ts/Config_ts.ts +53 -6
  34. package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +3 -21
  35. package/project/.sdk/src/cmp/ts/Entity_ts.ts +3 -5
  36. package/project/.sdk/src/cmp/ts/Main_ts.ts +22 -12
  37. package/project/.sdk/src/cmp/ts/Package_ts.ts +32 -12
  38. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +341 -2
  39. package/project/.sdk/src/cmp/ts/TestMain_ts.ts +0 -3
  40. package/project/.sdk/src/cmp/ts/Test_ts.ts +21 -3
  41. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +38 -5
  42. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +50 -38
  43. package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +9 -7
  44. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +47 -31
  45. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +49 -31
  46. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +50 -33
  47. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +50 -31
  48. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +51 -31
  49. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +70 -34
  50. package/project/.sdk/src/cmp/ts/tsconfig.json +15 -0
  51. package/project/.sdk/src/cmp/ts/utility_ts.ts +55 -1
  52. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +158 -104
  53. package/project/.sdk/tm/ts/src/types.ts +164 -34
  54. package/project/.sdk/tm/ts/src/utility/AuthUtility.ts +8 -2
  55. package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +9 -6
  56. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +17 -31
  57. package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +14 -54
  58. package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +1 -1
  59. package/project/.sdk/tm/ts/src/utility/ErrorUtility.ts +7 -3
  60. package/project/.sdk/tm/ts/src/utility/FeaturehookUtility.ts +8 -5
  61. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +18 -2
  62. package/project/.sdk/tm/ts/src/utility/FindparamUtility.ts +12 -5
  63. package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +21 -5
  64. package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +3 -1
  65. package/project/.sdk/tm/ts/src/utility/OperationUtility.ts +23 -0
  66. package/project/.sdk/tm/ts/src/utility/OptionsUtility.ts +25 -3
  67. package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +10 -10
  68. package/project/.sdk/tm/ts/src/utility/PreparePathUtility.ts +18 -0
  69. package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +2 -2
  70. package/project/.sdk/tm/ts/src/utility/ReqformUtility.ts +2 -2
  71. package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +20 -3
  72. package/project/.sdk/tm/ts/src/utility/ResbasicUtility.ts +1 -1
  73. package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +5 -3
  74. package/project/.sdk/tm/ts/src/utility/ResformUtility.ts +3 -3
  75. package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +9 -7
  76. package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +35 -4
  77. package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +24 -4
  78. package/project/.sdk/tm/ts/src/utility/SelectionUtility.ts +78 -0
  79. package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +34 -27
  80. package/project/.sdk/tm/ts/src/utility/StructUtility.ts +1117 -509
  81. package/project/.sdk/tm/ts/src/utility/Utility.ts +10 -8
  82. package/project/.sdk/tm/ts/test/exists.test.ts +0 -1
  83. package/project/.sdk/tm/ts/test/runner.ts +12 -10
  84. package/project/.sdk/tm/ts/test/utility/Custom.test.ts +30 -29
  85. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +53 -47
  86. package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +433 -189
  87. package/src/action/action.ts +1 -2
  88. package/src/action/feature.ts +7 -2
  89. package/src/action/target.ts +7 -7
  90. package/src/cmp/Entity.ts +7 -1
  91. package/src/cmp/FeatureHook.ts +6 -1
  92. package/src/cmp/Main.ts +4 -0
  93. package/src/cmp/ReadmeEntity.ts +6 -1
  94. package/src/cmp/Test.ts +31 -0
  95. package/src/sdkgen.ts +19 -34
  96. package/src/types.ts +10 -1
  97. package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +0 -180
  98. package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +0 -90
@@ -17,8 +17,8 @@ const Main = cmp(async function Main(props: any) {
17
17
  const { target } = props
18
18
  const { model } = props.ctx$
19
19
 
20
- const { entity } = model.main.api
21
- const { feature } = model.main.sdk
20
+ const { entity } = model.main.kit
21
+ const { feature } = model.main.kit
22
22
 
23
23
  Package({ target })
24
24
 
@@ -72,7 +72,7 @@ const Main = cmp(async function Main(props: any) {
72
72
  }, () => {
73
73
  each(entity, (entity: any) => {
74
74
  // console.log('ENTITY', entity.name)
75
- MainEntity({ target, entity, entitySDK: model.main.sdk.entity[entity.name] })
75
+ MainEntity({ target, entity, entitySDK: model.main.kit.entity[entity.name] })
76
76
  })
77
77
  })
78
78
  })
@@ -21,7 +21,7 @@ const Quick = cmp(function Quick(props: any) {
21
21
 
22
22
  // TODO: selected features should be active by default!
23
23
 
24
- const featureOptions = each(model.main.sdk.feature)
24
+ const featureOptions = each(model.main.kit.feature)
25
25
  .filter((f: any) => f.active)
26
26
  .reduce((a: any, f: any) => a + `\n ${f.name}: { active: true },`, '')
27
27
 
@@ -1,21 +1,44 @@
1
1
 
2
2
  import * as Path from 'node:path'
3
3
 
4
+
4
5
  import {
5
- cmp, each, indent,
6
- File, Content, Fragment
6
+ Content,
7
+ File,
8
+ Fragment,
9
+ Line,
10
+ cmp,
11
+ each,
12
+ indent,
7
13
  } from '@voxgig/sdkgen'
8
14
 
9
15
 
16
+ import {
17
+ KIT,
18
+ Model,
19
+ getModelPath,
20
+ nom,
21
+ } from '@voxgig/apidef'
22
+
23
+
24
+ import {
25
+ clean,
26
+ formatJson,
27
+ } from './utility_ts'
10
28
 
11
29
 
12
30
  const Config = cmp(async function Config(props: any) {
13
- const { target, ctx$: { model } } = props
14
- const { main: { sdk: { entity } } } = model
31
+ const ctx$ = props.ctx$
32
+ const target = props.target
33
+
34
+ const model: Model = ctx$.model
35
+
36
+ const entity = getModelPath(model, `main.${KIT}.entity`)
37
+ const feature = getModelPath(model, `main.${KIT}.feature`)
15
38
 
16
39
  const ff = Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/')
17
40
 
18
- const headers = model?.main?.sdk?.config?.headers || {}
41
+ const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
19
42
 
20
43
  File({ name: 'Config.' + target.ext }, () => {
21
44
 
@@ -23,13 +46,37 @@ const Config = cmp(async function Config(props: any) {
23
46
  from: ff + 'Config.fragment.ts',
24
47
 
25
48
  replace: {
49
+
26
50
  "'HEADERS'": indent(JSON.stringify(headers, null, 2), 4).trim(),
51
+
52
+ '// #ImportFeatures': () => each(feature, (f: any) => {
53
+ Line(`import { ${nom(f, 'Name')}Feature } from ` +
54
+ `'./feature/${f.name}/${nom(f, 'Name')}Feature'`)
55
+ }),
56
+
57
+ '// #FeatureClasses': () => each(feature, (f: any) => {
58
+ Line(` ${f.name}: ${nom(f, 'Name')}Feature`)
59
+ }),
60
+
61
+ '// #FeatureConfigs': () => each(feature, (f: any) => {
62
+ Line(` ${f.name}: ${formatJson(f.config, { margin: 4 })}`)
63
+ }),
64
+
65
+
27
66
  '// #EntityConfigs': () => each(entity, (entity: any) => {
28
67
  Content(`
29
68
  ${entity.name}: {
30
69
  },
31
70
  `)
32
- })
71
+ }),
72
+
73
+ "'ENTITYMAP'": formatJson(Object.values(entity)
74
+ .reduce((a: any, n: any) => (a[n.name] = clean({
75
+ fields: n.fields,
76
+ name: n.name,
77
+ op: n.op,
78
+ relations: n.relations,
79
+ }), a), {}), { margin: 2 }).trim(),
33
80
  }
34
81
  })
35
82
  })
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  import { jsonify } from '@voxgig/struct'
9
9
 
10
- import { formatJSONSrc } from './utility_ts'
10
+ import { formatJSONSrc, formatJson } from './utility_ts'
11
11
 
12
12
 
13
13
  const EntityOperation = cmp(function Operation(props: any) {
@@ -22,17 +22,6 @@ const EntityOperation = cmp(function Operation(props: any) {
22
22
  }
23
23
 
24
24
  const entop = entity.op[opname]
25
- const path = entop.path
26
-
27
- // // TODO: move up to to common Entity
28
- // const params = JSON.stringify((path.match(/\{[^}]+\}/g) || [])
29
- // .map((p: string) => p.substring(1, p.length - 1))
30
- // .filter((p: string) => null != p && '' !== p))
31
-
32
- // const aliasmap = JSON.stringify(entitySDK.alias.field)
33
- const aliasmap = JSON.stringify(entity.alias.field)
34
-
35
- // const hasp = '' != entop.place
36
25
 
37
26
  Fragment({
38
27
  from: ff + '/Entity' + camelify(opname) + 'Op.fragment.ts',
@@ -43,17 +32,10 @@ const EntityOperation = cmp(function Operation(props: any) {
43
32
  SdkName: model.const.Name,
44
33
  EntityName: entity.Name,
45
34
  entityname: entity.name,
46
- PATH: entop.path,
47
- "['PATHALT']": entop.pathalt,
48
- "['PARAM-LIST']": jsonify(Object.keys(entop.param)),
49
- "{ 'ALIAS': 'MAP' }": aliasmap,
50
- "'REQFORM'": formatJSONSrc(JSON.stringify(entop.reqform)),
51
- "'RESFORM'": formatJSONSrc(JSON.stringify(entop.resform)),
52
- "'VALIDATE'": formatJSONSrc(JSON.stringify(entop.validate)),
53
-
35
+ "['ALTS']": formatJson(entop.alts, { margin: 6 }).trim(),
54
36
  '#Feature-Hook': ({ name, indent }: any) =>
55
37
  Content({ indent }, `
56
- fres = featurehook(ctx, '${name}')
38
+ fres = featureHook(ctx, '${name}')
57
39
  if (fres instanceof Promise) { await fres }
58
40
  `)
59
41
 
@@ -7,7 +7,7 @@ import {
7
7
  } from '@voxgig/sdkgen'
8
8
 
9
9
  import { EntityOperation } from './EntityOperation_ts'
10
- import { EntityTest } from './EntityTest_ts'
10
+ // import { EntityTest } from './EntityTest_ts'
11
11
 
12
12
 
13
13
  const Entity = cmp(function Entity(props: any) {
@@ -19,7 +19,6 @@ const Entity = cmp(function Entity(props: any) {
19
19
  }
20
20
 
21
21
  names(entrep, entity.Name, 'EntityName')
22
- // console.log('ENTREP', entrep)
23
22
 
24
23
  const ff = Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/')
25
24
 
@@ -46,7 +45,7 @@ const Entity = cmp(function Entity(props: any) {
46
45
 
47
46
  '#Feature-Hook': ({ name, indent }: any) =>
48
47
  Content({ indent }, `
49
- fres = featurehook(ctx, '${name}')
48
+ fres = featureHook(ctx, '${name}')
50
49
  if (fres instanceof Promise) { await fres }
51
50
  `.trim()),
52
51
 
@@ -57,8 +56,7 @@ if (fres instanceof Promise) { await fres }
57
56
  })
58
57
  })
59
58
 
60
-
61
- EntityTest({ target, entity, entrep, ff })
59
+ // EntityTest({ target, entity, entrep, ff })
62
60
  })
63
61
 
64
62
 
@@ -7,22 +7,35 @@ import {
7
7
  } from '@voxgig/sdkgen'
8
8
 
9
9
 
10
+ import type {
11
+ ModelEntity
12
+ } from '@voxgig/apidef'
13
+
14
+
15
+ import {
16
+ KIT,
17
+ getModelPath
18
+ } from '@voxgig/apidef'
19
+
20
+
10
21
  import { Package } from './Package_ts'
11
22
  import { Config } from './Config_ts'
12
23
  import { MainEntity } from './MainEntity_ts'
13
- import { Test } from './Test_ts'
24
+ // import { Test } from './Test_ts'
14
25
 
15
26
 
16
27
  const Main = cmp(async function Main(props: any) {
28
+
29
+ // Needs type: target object
17
30
  const { target } = props
18
31
  const { model } = props.ctx$
19
32
 
20
- const { entity } = model.main.api
21
- const { feature } = model.main.sdk
33
+ const entity: ModelEntity = getModelPath(model, `main.${KIT}.entity`)
34
+ const feature = getModelPath(model, `main.${KIT}.feature`)
22
35
 
23
36
  Package({ target })
24
37
 
25
- Test({ target })
38
+ // Test({ target })
26
39
 
27
40
  Folder({ name: 'src' }, () => {
28
41
 
@@ -30,10 +43,6 @@ const Main = cmp(async function Main(props: any) {
30
43
 
31
44
  Line(`// ${model.const.Name} ${target.Name} SDK\n`)
32
45
 
33
- List({ item: feature }, ({ item }: any) =>
34
- Line(`import { ${item.Name + 'Feature'} } ` +
35
- `from './feature/${item.name}/${item.Name}Feature'`))
36
-
37
46
  List({ item: entity }, ({ item }: any) =>
38
47
  Line(`import { ${item.Name}Entity } from './entity/${item.Name}Entity'`))
39
48
 
@@ -46,11 +55,11 @@ const Main = cmp(async function Main(props: any) {
46
55
  '#BuildFeatures': ({ indent }: any) => {
47
56
  List({ item: feature, line: false }, ({ item }: any) =>
48
57
  Line({ indent },
49
- `addfeature(ctx, new ${item.Name}Feature())`))
58
+ `addfeature(this._rootctx, new ${item.Name}Feature())`))
50
59
  },
51
60
 
52
61
  '#Feature-Hook': ({ name, indent }: any) => Content({ indent }, `
53
- fres = featurehook(ctx, '${name}')
62
+ fres = featureHook(ctx, '${name}')
54
63
  if (fres instanceof Promise) { await fres }
55
64
  `),
56
65
 
@@ -69,8 +78,9 @@ if (fres instanceof Promise) { await fres }
69
78
 
70
79
  // Entities
71
80
  () => {
72
- each(entity, (entity: any) => {
73
- const entprops = { target, entity, entitySDK: model.main.api.entity[entity.name] }
81
+ each(entity, (entity: ModelEntity) => {
82
+ const entitySDK = getModelPath(model, `main.${KIT}.entity.${entity.name}`)
83
+ const entprops = { target, entity, entitySDK }
74
84
  MainEntity(entprops)
75
85
  })
76
86
  })
@@ -1,14 +1,28 @@
1
1
 
2
2
  import {
3
- cmp, omap, each, cmap,
4
- File, Content,
3
+ Content,
4
+ File,
5
+ cmp,
6
+ each,
7
+ omap,
5
8
  } from '@voxgig/sdkgen'
6
9
 
7
10
 
11
+ import {
12
+ KIT,
13
+ Model,
14
+ getModelPath,
15
+ nom,
16
+ } from '@voxgig/apidef'
17
+
8
18
 
9
19
  const Package = cmp(async function Package(props: any) {
10
- const { target, ctx$: { model } } = props
11
- const { main: { sdk: { feature } } } = model
20
+ const ctx$ = props.ctx$
21
+ const target = props.target
22
+
23
+ const model: Model = ctx$.model
24
+
25
+ const feature = getModelPath(model, `main.${KIT}.feature`)
12
26
 
13
27
  const only = (kind: string, deps: any) =>
14
28
  omap(deps, ([k, v]: any) => [v.active && kind === v.kind ? k : undefined, v.version])
@@ -18,7 +32,9 @@ const Package = cmp(async function Package(props: any) {
18
32
  each(feature, (feature: any) =>
19
33
  omap(feature.deps?.[target.name], ([k, v]: any) =>
20
34
  [v.active ? k : undefined, v]))
35
+
21
36
  // TODO: sort by version; rules for version choice?
37
+ // TODO: non-node dep kinds
22
38
  .reduce((a: any, deps: any) => (each(deps, (dep: any) =>
23
39
  a[dep.kind][dep.key$] = dep.version), a),
24
40
  {
@@ -28,20 +44,22 @@ const Package = cmp(async function Package(props: any) {
28
44
  })
29
45
 
30
46
  const sdkname = model.name
47
+ const SdkName = nom(model, 'Name')
31
48
  const origin = null == model.origin ? '' : `@${model.origin}/`
49
+ const sdknamesuffix = model.origin?.endsWith('-sdk') ? '' : '-sdk'
32
50
 
33
51
  // TODO: complete SDK meta data in model and use here
34
52
  const pkg = {
35
- name: `${origin}${sdkname}-sdk`,
53
+ name: `${origin}${sdkname}${sdknamesuffix}`,
36
54
  version: `0.0.1`,
37
55
  description: 'DESCRIPTION',
38
- main: `dist/${model.const.Name}SDK.js`,
56
+ main: `dist/${SdkName}SDK.js`,
39
57
  type: 'commonjs',
40
- types: `dist/${model.const.Name}SDK.d.ts`,
58
+ types: `dist/${SdkName}SDK.d.ts`,
41
59
  scripts: {
42
- 'test': 'node --enable-source-maps --test dist-test/**/*.test.js',
43
- 'test-some': 'node --enable-source-maps ' +
44
- '--test-name-pattern=\"$npm_config_pattern\" --test dist-test/**/*.test.js',
60
+ 'test': 'node --enable-source-maps --test \'dist-test/**/*.test.js\'',
61
+ 'test-some': 'node --enable-source-maps --experimental-test-isolation=none ' +
62
+ '--test-name-pattern=\"$TEST_PATTERN\" --test \'dist-test/**/*.test.js\'',
45
63
  'test-utility': 'node --enable-source-maps --test test/utility/*.test.ts',
46
64
 
47
65
  "watch": "tsc --build src test -w",
@@ -49,14 +67,16 @@ const Package = cmp(async function Package(props: any) {
49
67
  "clean": "rm -rf node_modules yarn.lock package-lock.json",
50
68
  "reset": "npm run clean && npm i && npm run build && npm test",
51
69
  },
52
- author: `${model.const.Name}`,
70
+ author: `${SdkName}`,
71
+
72
+ // TODO: needs to be config
53
73
  license: 'MIT',
74
+
54
75
  dependencies: deps.prod,
55
76
  peerDependencies: deps.peer,
56
77
  devDependencies: deps.dev,
57
78
  }
58
79
 
59
-
60
80
  File({ name: 'package.json' }, () => {
61
81
  Content(JSON.stringify(pkg, null, 2))
62
82
  })