@voxgig/sdkgen 0.25.0 → 0.28.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.
Files changed (213) 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/Feature.js +11 -9
  11. package/dist/cmp/Feature.js.map +1 -1
  12. package/dist/cmp/FeatureHook.js +2 -1
  13. package/dist/cmp/FeatureHook.js.map +1 -1
  14. package/dist/cmp/Main.js +6 -2
  15. package/dist/cmp/Main.js.map +1 -1
  16. package/dist/cmp/ReadmeEntity.js +2 -1
  17. package/dist/cmp/ReadmeEntity.js.map +1 -1
  18. package/dist/cmp/Test.d.ts +2 -0
  19. package/dist/cmp/Test.js +17 -0
  20. package/dist/cmp/Test.js.map +1 -0
  21. package/dist/sdkgen.d.ts +2 -1
  22. package/dist/sdkgen.js +17 -28
  23. package/dist/sdkgen.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/types.d.ts +3 -1
  26. package/dist/types.js +4 -0
  27. package/dist/types.js.map +1 -1
  28. package/model/sdkgen.jsonic +9 -9
  29. package/package.json +8 -6
  30. package/project/.sdk/model/feature/log.jsonic +3 -3
  31. package/project/.sdk/model/feature/test.jsonic +8 -3
  32. package/project/.sdk/model/target/go.jsonic +19 -4
  33. package/project/.sdk/model/target/js.jsonic +2 -2
  34. package/project/.sdk/model/target/ts.jsonic +5 -5
  35. package/project/.sdk/src/cmp/go/Config_go.ts +119 -0
  36. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +48 -0
  37. package/project/.sdk/src/cmp/go/Entity_go.ts +67 -0
  38. package/project/.sdk/src/cmp/go/MainEntity_go.ts +22 -0
  39. package/project/.sdk/src/cmp/go/Main_go.ts +209 -0
  40. package/project/.sdk/src/cmp/go/Package_go.ts +89 -0
  41. package/project/.sdk/src/cmp/go/TestDirect_go.ts +373 -0
  42. package/project/.sdk/src/cmp/go/TestEntity_go.ts +341 -0
  43. package/project/.sdk/src/cmp/go/Test_go.ts +37 -0
  44. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +146 -0
  45. package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +35 -0
  46. package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +26 -0
  47. package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +38 -0
  48. package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +38 -0
  49. package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +38 -0
  50. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +250 -0
  51. package/project/.sdk/src/cmp/go/fragment/SdkError.fragment.go +22 -0
  52. package/project/.sdk/src/cmp/go/tsconfig.json +15 -0
  53. package/project/.sdk/src/cmp/go/utility_go.ts +88 -0
  54. package/project/.sdk/src/cmp/js/Main_js.ts +3 -3
  55. package/project/.sdk/src/cmp/js/Quick_js.ts +1 -1
  56. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -6
  57. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -6
  58. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +6 -6
  59. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +6 -6
  60. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +6 -6
  61. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +85 -1
  62. package/project/.sdk/src/cmp/ts/Config_ts.ts +53 -6
  63. package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +3 -21
  64. package/project/.sdk/src/cmp/ts/Entity_ts.ts +3 -5
  65. package/project/.sdk/src/cmp/ts/Main_ts.ts +23 -13
  66. package/project/.sdk/src/cmp/ts/Package_ts.ts +30 -11
  67. package/project/.sdk/src/cmp/ts/SdkError_ts.ts +42 -0
  68. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +288 -0
  69. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +349 -2
  70. package/project/.sdk/src/cmp/ts/TestMain_ts.ts +0 -3
  71. package/project/.sdk/src/cmp/ts/Test_ts.ts +23 -3
  72. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +38 -5
  73. package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +30 -0
  74. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +50 -38
  75. package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +9 -7
  76. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +47 -31
  77. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +49 -31
  78. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +50 -33
  79. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +51 -32
  80. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +51 -31
  81. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +166 -34
  82. package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +25 -0
  83. package/project/.sdk/src/cmp/ts/tsconfig.json +15 -0
  84. package/project/.sdk/src/cmp/ts/utility_ts.ts +55 -1
  85. package/project/.sdk/tm/go/Makefile +10 -0
  86. package/project/.sdk/tm/go/core/context.go +267 -0
  87. package/project/.sdk/tm/go/core/control.go +7 -0
  88. package/project/.sdk/tm/go/core/error.go +25 -0
  89. package/project/.sdk/tm/go/core/helpers.go +33 -0
  90. package/project/.sdk/tm/go/core/operation.go +61 -0
  91. package/project/.sdk/tm/go/core/response.go +55 -0
  92. package/project/.sdk/tm/go/core/result.go +73 -0
  93. package/project/.sdk/tm/go/core/spec.go +97 -0
  94. package/project/.sdk/tm/go/core/target.go +102 -0
  95. package/project/.sdk/tm/go/core/types.go +44 -0
  96. package/project/.sdk/tm/go/core/utility_type.go +54 -0
  97. package/project/.sdk/tm/go/feature/base_feature.go +40 -0
  98. package/project/.sdk/tm/go/feature/test_feature.go +196 -0
  99. package/project/.sdk/tm/go/src/feature/README.md +1 -0
  100. package/project/.sdk/tm/go/src/feature/base/.gitkeep +0 -0
  101. package/project/.sdk/tm/go/src/feature/test/.gitkeep +0 -0
  102. package/project/.sdk/tm/go/test/custom_utility_test.go +80 -0
  103. package/project/.sdk/tm/go/test/exists_test.go +16 -0
  104. package/project/.sdk/tm/go/test/primary_utility_test.go +899 -0
  105. package/project/.sdk/tm/go/test/runner_test.go +428 -0
  106. package/project/.sdk/tm/go/test/struct_runner_test.go +1094 -0
  107. package/project/.sdk/tm/go/test/struct_utility_test.go +1423 -0
  108. package/project/.sdk/tm/go/utility/clean.go +7 -0
  109. package/project/.sdk/tm/go/utility/done.go +20 -0
  110. package/project/.sdk/tm/go/utility/feature_add.go +10 -0
  111. package/project/.sdk/tm/go/utility/feature_hook.go +30 -0
  112. package/project/.sdk/tm/go/utility/feature_init.go +30 -0
  113. package/project/.sdk/tm/go/utility/fetcher.go +102 -0
  114. package/project/.sdk/tm/go/utility/make_context.go +7 -0
  115. package/project/.sdk/tm/go/utility/make_error.go +69 -0
  116. package/project/.sdk/tm/go/utility/make_fetch_def.go +44 -0
  117. package/project/.sdk/tm/go/utility/make_options.go +130 -0
  118. package/project/.sdk/tm/go/utility/make_request.go +59 -0
  119. package/project/.sdk/tm/go/utility/make_response.go +46 -0
  120. package/project/.sdk/tm/go/utility/make_result.go +55 -0
  121. package/project/.sdk/tm/go/utility/make_spec.go +68 -0
  122. package/project/.sdk/tm/go/utility/make_target.go +95 -0
  123. package/project/.sdk/tm/go/utility/make_url.go +41 -0
  124. package/project/.sdk/tm/go/utility/param.go +66 -0
  125. package/project/.sdk/tm/go/utility/prepare_auth.go +40 -0
  126. package/project/.sdk/tm/go/utility/prepare_body.go +14 -0
  127. package/project/.sdk/tm/go/utility/prepare_headers.go +22 -0
  128. package/project/.sdk/tm/go/utility/prepare_method.go +21 -0
  129. package/project/.sdk/tm/go/utility/prepare_params.go +41 -0
  130. package/project/.sdk/tm/go/utility/prepare_path.go +21 -0
  131. package/project/.sdk/tm/go/utility/prepare_query.go +47 -0
  132. package/project/.sdk/tm/go/utility/register.go +39 -0
  133. package/project/.sdk/tm/go/utility/result_basic.go +31 -0
  134. package/project/.sdk/tm/go/utility/result_body.go +17 -0
  135. package/project/.sdk/tm/go/utility/result_headers.go +22 -0
  136. package/project/.sdk/tm/go/utility/struct/go.mod +3 -0
  137. package/project/.sdk/tm/go/utility/struct/voxgigstruct.go +4891 -0
  138. package/project/.sdk/tm/go/utility/transform_request.go +32 -0
  139. package/project/.sdk/tm/go/utility/transform_response.go +45 -0
  140. package/project/.sdk/tm/js/src/feature/log/LogFeature.js +2 -2
  141. package/project/.sdk/tm/ts/src/Context.ts +144 -0
  142. package/project/.sdk/tm/ts/src/Control.ts +20 -0
  143. package/project/.sdk/tm/ts/src/Operation.ts +24 -0
  144. package/project/.sdk/tm/ts/src/Response.ts +26 -0
  145. package/project/.sdk/tm/ts/src/Result.ts +30 -0
  146. package/project/.sdk/tm/ts/src/Spec.ts +40 -0
  147. package/project/.sdk/tm/ts/src/Target.ts +36 -0
  148. package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +1 -1
  149. package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +2 -2
  150. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +158 -104
  151. package/project/.sdk/tm/ts/src/types.ts +18 -78
  152. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +17 -31
  153. package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +3 -4
  154. package/project/.sdk/tm/ts/src/utility/{AddfeatureUtility.ts → FeatureAddUtility.ts} +2 -2
  155. package/project/.sdk/tm/ts/src/utility/{FeaturehookUtility.ts → FeatureHookUtility.ts} +8 -5
  156. package/project/.sdk/tm/ts/src/utility/FeatureInitUtility.ts +15 -0
  157. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +20 -2
  158. package/project/.sdk/tm/ts/src/utility/MakeContextUtility.ts +27 -0
  159. package/project/.sdk/tm/ts/src/utility/{ErrorUtility.ts → MakeErrorUtility.ts} +10 -6
  160. package/project/.sdk/tm/ts/src/utility/MakeFetchDefUtility.ts +46 -0
  161. package/project/.sdk/tm/ts/src/utility/{OptionsUtility.ts → MakeOptionsUtility.ts} +32 -7
  162. package/project/.sdk/tm/ts/src/utility/MakeRequestUtility.ts +66 -0
  163. package/project/.sdk/tm/ts/src/utility/MakeResponseUtility.ts +61 -0
  164. package/project/.sdk/tm/ts/src/utility/MakeResultUtility.ts +56 -0
  165. package/project/.sdk/tm/ts/src/utility/MakeSpecUtility.ts +61 -0
  166. package/project/.sdk/tm/ts/src/utility/MakeTargetUtility.ts +76 -0
  167. package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +61 -0
  168. package/project/.sdk/tm/ts/src/utility/{FindparamUtility.ts → ParamUtility.ts} +28 -8
  169. package/project/.sdk/tm/ts/src/utility/{AuthUtility.ts → PrepareAuthUtility.ts} +10 -4
  170. package/project/.sdk/tm/ts/src/utility/PrepareBodyUtility.ts +32 -0
  171. package/project/.sdk/tm/ts/src/utility/{HeadersUtility.ts → PrepareHeadersUtility.ts} +5 -7
  172. package/project/.sdk/tm/ts/src/utility/{MethodUtility.ts → PrepareMethodUtility.ts} +6 -6
  173. package/project/.sdk/tm/ts/src/utility/PrepareParamsUtility.ts +37 -0
  174. package/project/.sdk/tm/ts/src/utility/PreparePathUtility.ts +17 -0
  175. package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +30 -0
  176. package/project/.sdk/tm/ts/src/utility/{ResbasicUtility.ts → ResultBasicUtility.ts} +12 -7
  177. package/project/.sdk/tm/ts/src/utility/ResultBodyUtility.ts +22 -0
  178. package/project/.sdk/tm/ts/src/utility/ResultHeadersUtility.ts +26 -0
  179. package/project/.sdk/tm/ts/src/utility/StructUtility.ts +1113 -525
  180. package/project/.sdk/tm/ts/src/utility/{ReqformUtility.ts → TransformRequestUtility.ts} +9 -7
  181. package/project/.sdk/tm/ts/src/utility/{ResformUtility.ts → TransformResponseUtility.ts} +11 -8
  182. package/project/.sdk/tm/ts/src/utility/Utility.ts +52 -65
  183. package/project/.sdk/tm/ts/test/exists.test.ts +0 -1
  184. package/project/.sdk/tm/ts/test/runner.ts +36 -13
  185. package/project/.sdk/tm/ts/test/utility/Custom.test.ts +30 -29
  186. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +385 -168
  187. package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +433 -189
  188. package/src/action/action.ts +1 -2
  189. package/src/action/feature.ts +7 -2
  190. package/src/action/target.ts +7 -7
  191. package/src/cmp/Entity.ts +7 -1
  192. package/src/cmp/Feature.ts +11 -9
  193. package/src/cmp/FeatureHook.ts +6 -1
  194. package/src/cmp/Main.ts +12 -2
  195. package/src/cmp/ReadmeEntity.ts +6 -1
  196. package/src/cmp/Test.ts +31 -0
  197. package/src/sdkgen.ts +19 -34
  198. package/src/types.ts +10 -1
  199. package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +0 -180
  200. package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +0 -29
  201. package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +0 -67
  202. package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +0 -46
  203. package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +0 -13
  204. package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +0 -15
  205. package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +0 -90
  206. package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +0 -37
  207. package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +0 -27
  208. package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +0 -66
  209. package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +0 -19
  210. package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +0 -23
  211. package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +0 -30
  212. package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +0 -36
  213. package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +0 -61
@@ -1,7 +1,7 @@
1
1
 
2
- main: sdk: feature: log: {
2
+ main: kit: feature: log: {
3
3
 
4
- name: .$KEY
4
+ name: key()
5
5
  title: Log
6
6
  version: '0.0.1'
7
7
  active: true
@@ -15,7 +15,7 @@ main: sdk: feature: log: {
15
15
  SetMatch: active: true
16
16
  GetMatch: active: true
17
17
 
18
- PreOperation: active: true
18
+ PreTarget: active: true
19
19
  PreSpec: active: true
20
20
  PreRequest: active: true
21
21
  PreResponse: active: true
@@ -1,11 +1,16 @@
1
1
 
2
- main: sdk: feature: test: {
2
+ main: kit: feature: test: {
3
3
 
4
- name: .$KEY
4
+ name: key()
5
5
  title: Test
6
6
  version: '0.0.1'
7
7
  active: true
8
8
 
9
+ config: {
10
+ # Test mode is not active by default, unlike most features
11
+ options: active: false
12
+ }
13
+
9
14
  hook: {
10
15
  PostConstruct: active: true
11
16
  PostConstructEntity: active: true
@@ -14,7 +19,7 @@ main: sdk: feature: test: {
14
19
  SetMatch: active: true
15
20
  GetMatch: active: true
16
21
 
17
- PreOperation: active: true
22
+ PreTarget: active: true
18
23
  PreSpec: active: true
19
24
  PreRequest: active: true
20
25
  PreResponse: active: true
@@ -1,7 +1,22 @@
1
1
 
2
- title: Golang
3
- ext: go
4
- comment: line: "//"
5
- module: name: $$name$$
2
+ main: kit: target: go: {
6
3
 
4
+ title: Golang
5
+ ext: go
6
+ comment: line: "//"
7
+ module: name: $$name$$
8
+ srcfeature: false
7
9
 
10
+ deps: &: {
11
+ kind: *'prod' | string
12
+ }
13
+
14
+ deps: {
15
+ 'github.com/voxgig/struct': { active: true, version: 'v0.0.0', replace: './utility/struct' }
16
+ }
17
+ }
18
+
19
+
20
+ main: kit: feature: &: target: go: deps: &: {
21
+ kind: *'prod' | string
22
+ }
@@ -1,5 +1,5 @@
1
1
 
2
- main: sdk: target: js: {
2
+ main: kit: target: js: {
3
3
 
4
4
  title: JavaScript
5
5
  ext: js
@@ -17,7 +17,7 @@ main: sdk: target: js: {
17
17
  }
18
18
 
19
19
 
20
- main: sdk: feature: &: target: js: deps: &: {
20
+ main: kit: feature: &: target: js: deps: &: {
21
21
  # TODO: fix aontu disjunctions!
22
22
  kind: *'prod' | string # 'peer' |'dev'
23
23
  }
@@ -1,5 +1,5 @@
1
1
 
2
- main: sdk: target: ts: {
2
+ main: kit: target: ts: {
3
3
 
4
4
  title: TypeScript
5
5
  ext: ts
@@ -13,14 +13,14 @@ main: sdk: target: ts: {
13
13
  }
14
14
 
15
15
  deps: {
16
- 'dotenv': { active: true, version: '^16.4.5', kind: dev }
17
- 'typescript': { active: true, version: '^5.8.3', kind: dev }
18
- '@types/node': { active: true, version: '^22.15.3', kind: dev }
16
+ 'dotenv': { active: true, version: '^17.3.1', kind: dev }
17
+ 'typescript': { active: true, version: '^5.9.3', kind: dev }
18
+ '@types/node': { active: true, version: '^25.3.3', kind: dev }
19
19
  }
20
20
  }
21
21
 
22
22
 
23
- main: sdk: feature: &: target: ts: deps: &: {
23
+ main: kit: feature: &: target: ts: deps: &: {
24
24
  # TODO: fix aontu disjunctions!
25
25
  kind: *'prod' | string # 'peer' |'dev'
26
26
  }
@@ -0,0 +1,119 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+
5
+ import {
6
+ Content,
7
+ File,
8
+ Fragment,
9
+ Line,
10
+ cmp,
11
+ each,
12
+ } from '@voxgig/sdkgen'
13
+
14
+
15
+ import {
16
+ KIT,
17
+ Model,
18
+ getModelPath,
19
+ nom,
20
+ } from '@voxgig/apidef'
21
+
22
+
23
+ import {
24
+ clean,
25
+ formatGoMap,
26
+ } from './utility_go'
27
+
28
+
29
+ const Config = cmp(async function Config(props: any) {
30
+ const ctx$ = props.ctx$
31
+ const target = props.target
32
+
33
+ const model: Model = ctx$.model
34
+
35
+ const entity = getModelPath(model, `main.${KIT}.entity`)
36
+ const feature = getModelPath(model, `main.${KIT}.feature`)
37
+
38
+ const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
39
+ const authPrefix = getModelPath(model, `main.${KIT}.config.auth.prefix`)
40
+ const baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`)
41
+
42
+ // Config is now in core/ package
43
+ File({ name: 'config.' + target.ext }, () => {
44
+
45
+ Content(`package core
46
+
47
+ `)
48
+
49
+ Content(`func MakeConfig() map[string]any {
50
+ return map[string]any{
51
+ "main": map[string]any{
52
+ "name": "${model.const.Name}",
53
+ },
54
+ "feature": map[string]any{
55
+ `)
56
+
57
+ each(feature, (f: any) => {
58
+ const fconfig = f.config || {}
59
+ Content(` "${f.name}": ${formatGoMap(fconfig, 3)},
60
+ `)
61
+ })
62
+
63
+ Content(` },
64
+ "options": map[string]any{
65
+ "base": "${baseUrl}",
66
+ "auth": map[string]any{
67
+ "prefix": "${authPrefix}",
68
+ },
69
+ "headers": ${formatGoMap(headers, 3)},
70
+ "entity": map[string]any{
71
+ `)
72
+
73
+ each(entity, (entity: any) => {
74
+ Content(` "${entity.name}": map[string]any{},
75
+ `)
76
+ })
77
+
78
+ Content(` },
79
+ },
80
+ "entity": ${formatGoMap(
81
+ Object.values(entity).reduce((a: any, n: any) => (a[n.name] = clean({
82
+ fields: n.fields,
83
+ name: n.name,
84
+ op: n.op,
85
+ relations: n.relations,
86
+ }), a), {}), 2)},
87
+ }
88
+ }
89
+
90
+ func makeFeature(name string) Feature {
91
+ switch name {
92
+ `)
93
+
94
+ each(feature, (f: any) => {
95
+ const fname = f.name.charAt(0).toUpperCase() + f.name.slice(1)
96
+ if (f.name !== 'base') {
97
+ Content(` case "${f.name}":
98
+ if New${fname}FeatureFunc != nil {
99
+ return New${fname}FeatureFunc()
100
+ }
101
+ `)
102
+ }
103
+ })
104
+
105
+ Content(` default:
106
+ if NewBaseFeatureFunc != nil {
107
+ return NewBaseFeatureFunc()
108
+ }
109
+ }
110
+ return nil
111
+ }
112
+ `)
113
+ })
114
+ })
115
+
116
+
117
+ export {
118
+ Config
119
+ }
@@ -0,0 +1,48 @@
1
+
2
+ import {
3
+ cmp, camelify,
4
+ Content, Fragment
5
+ } from '@voxgig/sdkgen'
6
+
7
+
8
+ import { formatGoMap } from './utility_go'
9
+
10
+
11
+ const EntityOperation = cmp(function Operation(props: any) {
12
+ const { model } = props.ctx$
13
+ const { ff, opname, entity, entrep, gomodule } = props
14
+
15
+ let { indent } = props
16
+
17
+ if (null != indent) {
18
+ indent = indent.substring(1)
19
+ if ('' == indent) {
20
+ indent = undefined
21
+ }
22
+ }
23
+
24
+ const entop = entity.op[opname]
25
+
26
+ Fragment({
27
+ from: ff + '/Entity' + camelify(opname) + 'Op.fragment.go',
28
+ eject: ['// EJECT-START', '// EJECT-END'],
29
+ indent,
30
+ replace: {
31
+ ...entrep,
32
+ 'GOMODULE': gomodule,
33
+ ProjectName: model.const.Name,
34
+ EntityName: entity.Name,
35
+ entityname: entity.name,
36
+ '#Feature-Hook': ({ name, indent }: any) =>
37
+ Content({ indent }, `
38
+ u.FeatureHook(ctx, "${name}")
39
+ `)
40
+
41
+ }
42
+ })
43
+ })
44
+
45
+
46
+ export {
47
+ EntityOperation
48
+ }
@@ -0,0 +1,67 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+ import {
5
+ cmp, each, camelify, names,
6
+ File, Content, Folder, Fragment, Line, FeatureHook, Slot
7
+ } from '@voxgig/sdkgen'
8
+
9
+ import { EntityOperation } from './EntityOperation_go'
10
+
11
+
12
+ const Entity = cmp(function Entity(props: any) {
13
+ const { model, stdrep } = props.ctx$
14
+ const { target, entity } = props
15
+
16
+ // Module name: concatenated lowercase
17
+ const orgPrefix = (model.origin || '').replace(/-sdk$/, '').replace(/[^a-z0-9]/gi, '')
18
+ const gomodule = orgPrefix + model.name + 'sdk'
19
+
20
+ const entrep = {
21
+ ...stdrep,
22
+ }
23
+
24
+ names(entrep, entity.Name, 'EntityName')
25
+
26
+ const ff = Path.normalize(__dirname + '/../../../src/cmp/go/fragment/')
27
+
28
+ // Entity files go to entity/ folder with snake_case names
29
+ Folder({ name: 'entity' }, () => {
30
+
31
+ File({ name: entity.name + '_entity.' + target.ext }, () => {
32
+
33
+ const opnames = Object.keys(entity.op)
34
+
35
+ const opfrags =
36
+ (['load', 'list', 'create', 'update', 'remove']
37
+ .reduce((a: any, opname: string) =>
38
+ (a['// #' + camelify(opname) + 'Op'] =
39
+ !opnames.includes(opname) ? '' : ({ indent }: any) => {
40
+ EntityOperation({ ff, opname, indent, entity, entrep, gomodule })
41
+ }, a), {}))
42
+
43
+ Fragment({
44
+ from: ff + 'Entity.fragment.go',
45
+ replace: {
46
+ ...entrep,
47
+ 'GOMODULE': gomodule,
48
+ ProjectName: model.const.Name,
49
+ EntityName: entity.Name,
50
+ entityname: entity.name,
51
+
52
+ '#Entity-Hook': ({ name, indent }: any) =>
53
+ Content({ indent }, `utility.FeatureHook(ctx, "${name}")`),
54
+
55
+ ...opfrags,
56
+ }
57
+ })
58
+
59
+ })
60
+ })
61
+ })
62
+
63
+
64
+
65
+ export {
66
+ Entity
67
+ }
@@ -0,0 +1,22 @@
1
+
2
+
3
+ import { cmp, Content } from '@voxgig/sdkgen'
4
+
5
+
6
+ const MainEntity = cmp(async function MainEntity(props: any) {
7
+ const { entity, gomodule } = props
8
+ const { model } = props.ctx$
9
+
10
+ Content(`
11
+ func (sdk *${model.const.Name}SDK) ${entity.Name}(data map[string]any) ${model.const.Name}Entity {
12
+ return New${entity.Name}EntityFunc(sdk, data)
13
+ }
14
+
15
+ `)
16
+
17
+ })
18
+
19
+
20
+ export {
21
+ MainEntity
22
+ }
@@ -0,0 +1,209 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+ import {
5
+ cmp, each, names, cmap,
6
+ List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
7
+ } from '@voxgig/sdkgen'
8
+
9
+
10
+ import type {
11
+ ModelEntity
12
+ } from '@voxgig/apidef'
13
+
14
+
15
+ import {
16
+ KIT,
17
+ getModelPath
18
+ } from '@voxgig/apidef'
19
+
20
+
21
+ import { Package } from './Package_go'
22
+ import { Config } from './Config_go'
23
+ import { MainEntity } from './MainEntity_go'
24
+
25
+
26
+ const Main = cmp(async function Main(props: any) {
27
+
28
+ const { target } = props
29
+ const { model } = props.ctx$
30
+
31
+ const entity: ModelEntity = getModelPath(model, `main.${KIT}.entity`)
32
+ const feature = getModelPath(model, `main.${KIT}.feature`)
33
+
34
+ // Module name: concatenated lowercase (e.g., voxgigsolardemosdk)
35
+ const orgPrefix = (model.origin || '').replace(/-sdk$/, '').replace(/[^a-z0-9]/gi, '')
36
+ const gomodule = orgPrefix + model.name + 'sdk'
37
+
38
+ Package({ target })
39
+
40
+ // Copy tm/go files with replacements
41
+ Copy({
42
+ from: 'tm/' + target.name,
43
+ exclude: [/src\//],
44
+ replace: {
45
+ ...props.ctx$.stdrep,
46
+ GOMODULE: gomodule,
47
+ }
48
+ })
49
+
50
+ // Generate main SDK file in core/ folder
51
+ Folder({ name: 'core' }, () => {
52
+
53
+ File({ name: model.name + '_sdk.' + target.ext }, () => {
54
+
55
+ Fragment(
56
+ {
57
+ from: Path.normalize(__dirname + '/../../../src/cmp/go/fragment/Main.fragment.go'),
58
+ replace: {
59
+ ...props.ctx$.stdrep,
60
+ 'ProjectNameModule': gomodule,
61
+
62
+ '#BuildFeatures': ({ indent }: any) => {
63
+ each(feature, (feat: any) => {
64
+ if (feat.name === 'base') {
65
+ Content({ indent }, `u.FeatureAdd(s.rootctx, NewBaseFeatureFunc())
66
+ `)
67
+ } else if (feat.name === 'test') {
68
+ Content({ indent }, `u.FeatureAdd(s.rootctx, NewTestFeatureFunc())
69
+ `)
70
+ }
71
+ })
72
+ },
73
+
74
+ '#Feature-Hook': ({ name, indent }: any) => Content({ indent }, `
75
+ s.utility.FeatureHook(s.rootctx, "${name}")
76
+ `),
77
+
78
+ }
79
+ },
80
+
81
+ // Entities - injected at SLOT
82
+ () => {
83
+ each(entity, (entity: ModelEntity) => {
84
+ const entitySDK = getModelPath(model, `main.${KIT}.entity.${entity.name}`)
85
+ const entprops = { target, entity, entitySDK, gomodule }
86
+ MainEntity(entprops)
87
+ })
88
+ })
89
+ })
90
+
91
+ Config({ target })
92
+
93
+ // Generate registry.go with all constructor function vars
94
+ File({ name: 'registry.' + target.ext }, () => {
95
+ Content(`package core
96
+
97
+ var UtilityRegistrar func(u *Utility)
98
+
99
+ var NewBaseFeatureFunc func() Feature
100
+
101
+ `)
102
+ // Feature constructor function vars (non-base)
103
+ each(feature, (feat: any) => {
104
+ if (feat.name !== 'base') {
105
+ const fname = feat.name.charAt(0).toUpperCase() + feat.name.slice(1)
106
+ Content(`var New${fname}FeatureFunc func() Feature
107
+
108
+ `)
109
+ }
110
+ })
111
+
112
+ // Entity constructor function vars
113
+ each(entity, (ent: any) => {
114
+ Content(`var New${ent.Name}EntityFunc func(client *${model.const.Name}SDK, entopts map[string]any) ${model.const.Name}Entity
115
+
116
+ `)
117
+ })
118
+ })
119
+ })
120
+
121
+ // Generate root package file
122
+ File({ name: model.name + '.' + target.ext }, () => {
123
+ Content(`package ${gomodule}
124
+
125
+ import (
126
+ "${gomodule}/core"
127
+ "${gomodule}/entity"
128
+ "${gomodule}/feature"
129
+ _ "${gomodule}/utility"
130
+ )
131
+
132
+ // Type aliases preserve external API.
133
+ type ${model.const.Name}SDK = core.${model.const.Name}SDK
134
+ type Context = core.Context
135
+ type Utility = core.Utility
136
+ type Feature = core.Feature
137
+ type Entity = core.Entity
138
+ type ${model.const.Name}Entity = core.${model.const.Name}Entity
139
+ type FetcherFunc = core.FetcherFunc
140
+ type Spec = core.Spec
141
+ type Result = core.Result
142
+ type Response = core.Response
143
+ type Operation = core.Operation
144
+ type Control = core.Control
145
+ type ${model.const.Name}Error = core.${model.const.Name}Error
146
+
147
+ // BaseFeature from feature package.
148
+ type BaseFeature = feature.BaseFeature
149
+
150
+ func init() {
151
+ `)
152
+
153
+ // Register feature constructors - base is always present
154
+ Content(` core.NewBaseFeatureFunc = func() core.Feature {
155
+ return feature.NewBaseFeature()
156
+ }
157
+ `)
158
+
159
+ // Register non-base feature constructors
160
+ each(feature, (feat: any) => {
161
+ if (feat.name !== 'base') {
162
+ const fname = feat.name.charAt(0).toUpperCase() + feat.name.slice(1)
163
+ Content(` core.New${fname}FeatureFunc = func() core.Feature {
164
+ return feature.New${fname}Feature()
165
+ }
166
+ `)
167
+ }
168
+ })
169
+
170
+ // Register entity constructors
171
+ each(entity, (ent: any) => {
172
+ Content(` core.New${ent.Name}EntityFunc = func(client *core.${model.const.Name}SDK, entopts map[string]any) core.${model.const.Name}Entity {
173
+ return entity.New${ent.Name}Entity(client, entopts)
174
+ }
175
+ `)
176
+ })
177
+
178
+ Content(`}
179
+
180
+ // Constructor re-exports.
181
+ var New${model.const.Name}SDK = core.New${model.const.Name}SDK
182
+ var TestSDK = core.TestSDK
183
+ var NewContext = core.NewContext
184
+ var NewSpec = core.NewSpec
185
+ var NewResult = core.NewResult
186
+ var NewResponse = core.NewResponse
187
+ var NewOperation = core.NewOperation
188
+ var MakeConfig = core.MakeConfig
189
+ `)
190
+
191
+ // Feature constructor re-exports - base is always present
192
+ Content(`var NewBaseFeature = feature.NewBaseFeature
193
+ `)
194
+
195
+ each(feature, (feat: any) => {
196
+ if (feat.name !== 'base') {
197
+ const fname = feat.name.charAt(0).toUpperCase() + feat.name.slice(1)
198
+ Content(`var New${fname}Feature = feature.New${fname}Feature
199
+ `)
200
+ }
201
+ })
202
+ })
203
+
204
+ })
205
+
206
+
207
+ export {
208
+ Main
209
+ }
@@ -0,0 +1,89 @@
1
+
2
+ import {
3
+ Content,
4
+ File,
5
+ cmp,
6
+ each,
7
+ } from '@voxgig/sdkgen'
8
+
9
+
10
+ import {
11
+ KIT,
12
+ Model,
13
+ getModelPath,
14
+ } from '@voxgig/apidef'
15
+
16
+
17
+ const Package = cmp(async function Package(props: any) {
18
+ const ctx$ = props.ctx$
19
+ const target = props.target
20
+
21
+ const model: Model = ctx$.model
22
+
23
+ const feature = getModelPath(model, `main.${KIT}.feature`)
24
+
25
+ // Module name: concatenated lowercase (e.g., voxgigsolardemosdk)
26
+ const orgPrefix = (model.origin || '').replace(/-sdk$/, '').replace(/[^a-z0-9]/gi, '')
27
+ const gomodule = orgPrefix + model.name + 'sdk'
28
+
29
+ File({ name: 'go.mod' }, () => {
30
+ Content(`module ${gomodule}
31
+
32
+ go 1.20
33
+
34
+ `)
35
+
36
+ // Collect dependencies from features
37
+ const deps: Record<string, string> = {}
38
+ const replaceDirs: Record<string, string> = {}
39
+
40
+ each(feature, (f: any) => {
41
+ const goDeps = f.deps?.go
42
+ if (goDeps) {
43
+ each(goDeps, (dep: any) => {
44
+ if (dep.active) {
45
+ deps[dep.key$] = dep.version
46
+ }
47
+ })
48
+ }
49
+ })
50
+
51
+ // Add target-level deps
52
+ const targetDeps = target.deps
53
+ if (targetDeps) {
54
+ each(targetDeps, (dep: any) => {
55
+ if (dep.active !== false) {
56
+ deps[dep.key$] = dep.version || 'v0.0.0'
57
+ if (dep.replace) {
58
+ replaceDirs[dep.key$] = dep.replace
59
+ }
60
+ }
61
+ })
62
+ }
63
+
64
+ if (Object.keys(deps).length > 0) {
65
+ Content(`require (
66
+ `)
67
+ for (const [name, version] of Object.entries(deps)) {
68
+ Content(`\t${name} ${version}
69
+ `)
70
+ }
71
+ Content(`)
72
+ `)
73
+ }
74
+
75
+ if (Object.keys(replaceDirs).length > 0) {
76
+ Content(`
77
+ `)
78
+ for (const [name, dir] of Object.entries(replaceDirs)) {
79
+ Content(`replace ${name} => ${dir}
80
+ `)
81
+ }
82
+ }
83
+ })
84
+ })
85
+
86
+
87
+ export {
88
+ Package
89
+ }