@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
@@ -0,0 +1,33 @@
1
+ package core
2
+
3
+ func ToMapAny(v any) map[string]any {
4
+ if v == nil {
5
+ return nil
6
+ }
7
+ if m, ok := v.(map[string]any); ok {
8
+ return m
9
+ }
10
+ return nil
11
+ }
12
+
13
+ func ToInt(v any) int {
14
+ switch n := v.(type) {
15
+ case int:
16
+ return n
17
+ case float64:
18
+ return int(n)
19
+ case float32:
20
+ return int(n)
21
+ case int64:
22
+ return int(n)
23
+ default:
24
+ return -1
25
+ }
26
+ }
27
+
28
+ func getCtxProp(m map[string]any, key string) any {
29
+ if m == nil {
30
+ return nil
31
+ }
32
+ return m[key]
33
+ }
@@ -0,0 +1,61 @@
1
+ package core
2
+
3
+ import (
4
+ vs "github.com/voxgig/struct"
5
+ )
6
+
7
+ type Operation struct {
8
+ Entity string
9
+ Name string
10
+ Input string
11
+ Targets []map[string]any
12
+ Alias map[string]any
13
+ }
14
+
15
+ func NewOperation(opmap map[string]any) *Operation {
16
+ entity, _ := vs.GetProp(opmap, "entity").(string)
17
+ if entity == "" {
18
+ entity = "_"
19
+ }
20
+ name, _ := vs.GetProp(opmap, "name").(string)
21
+ if name == "" {
22
+ name = "_"
23
+ }
24
+ input, _ := vs.GetProp(opmap, "input").(string)
25
+ if input == "" {
26
+ input = "_"
27
+ }
28
+
29
+ var targets []map[string]any
30
+ rawTargets := vs.GetProp(opmap, "targets")
31
+ if rawTargets != nil {
32
+ if tlist, ok := rawTargets.([]any); ok {
33
+ for _, t := range tlist {
34
+ if tm, ok := t.(map[string]any); ok {
35
+ targets = append(targets, tm)
36
+ }
37
+ }
38
+ } else if tlist, ok := rawTargets.([]map[string]any); ok {
39
+ targets = tlist
40
+ }
41
+ }
42
+ if targets == nil {
43
+ targets = []map[string]any{}
44
+ }
45
+
46
+ var alias map[string]any
47
+ rawAlias := vs.GetProp(opmap, "alias")
48
+ if rawAlias != nil {
49
+ if am, ok := rawAlias.(map[string]any); ok {
50
+ alias = am
51
+ }
52
+ }
53
+
54
+ return &Operation{
55
+ Entity: entity,
56
+ Name: name,
57
+ Input: input,
58
+ Targets: targets,
59
+ Alias: alias,
60
+ }
61
+ }
@@ -0,0 +1,55 @@
1
+ package core
2
+
3
+ import (
4
+ vs "github.com/voxgig/struct"
5
+ )
6
+
7
+ type Response struct {
8
+ Status int
9
+ StatusText string
10
+ Headers any
11
+ JsonFunc func() any
12
+ Body any
13
+ Err error
14
+ }
15
+
16
+ func NewResponse(resmap map[string]any) *Response {
17
+ status := -1
18
+ if s := vs.GetProp(resmap, "status"); s != nil {
19
+ status = ToInt(s)
20
+ }
21
+
22
+ statusText := ""
23
+ if st := vs.GetProp(resmap, "statusText"); st != nil {
24
+ if s, ok := st.(string); ok {
25
+ statusText = s
26
+ }
27
+ }
28
+
29
+ headers := vs.GetProp(resmap, "headers")
30
+
31
+ var jsonFunc func() any
32
+ if jf := vs.GetProp(resmap, "json"); jf != nil {
33
+ if f, ok := jf.(func() any); ok {
34
+ jsonFunc = f
35
+ }
36
+ }
37
+
38
+ body := vs.GetProp(resmap, "body")
39
+
40
+ var err error
41
+ if e := vs.GetProp(resmap, "err"); e != nil {
42
+ if er, ok := e.(error); ok {
43
+ err = er
44
+ }
45
+ }
46
+
47
+ return &Response{
48
+ Status: status,
49
+ StatusText: statusText,
50
+ Headers: headers,
51
+ JsonFunc: jsonFunc,
52
+ Body: body,
53
+ Err: err,
54
+ }
55
+ }
@@ -0,0 +1,73 @@
1
+ package core
2
+
3
+ import (
4
+ vs "github.com/voxgig/struct"
5
+ )
6
+
7
+ type Result struct {
8
+ Ok bool
9
+ Status int
10
+ StatusText string
11
+ Headers map[string]any
12
+ Body any
13
+ Err error
14
+ Resdata any
15
+ Resmatch map[string]any
16
+ }
17
+
18
+ func NewResult(resmap map[string]any) *Result {
19
+ ok := false
20
+ if o := vs.GetProp(resmap, "ok"); o != nil {
21
+ if b, is := o.(bool); is {
22
+ ok = b
23
+ }
24
+ }
25
+
26
+ status := -1
27
+ if s := vs.GetProp(resmap, "status"); s != nil {
28
+ status = ToInt(s)
29
+ }
30
+
31
+ statusText := ""
32
+ if st := vs.GetProp(resmap, "statusText"); st != nil {
33
+ if s, ok := st.(string); ok {
34
+ statusText = s
35
+ }
36
+ }
37
+
38
+ headers := map[string]any{}
39
+ if h := vs.GetProp(resmap, "headers"); h != nil {
40
+ if hm, ok := h.(map[string]any); ok {
41
+ headers = hm
42
+ }
43
+ }
44
+
45
+ body := vs.GetProp(resmap, "body")
46
+
47
+ var err error
48
+ if e := vs.GetProp(resmap, "err"); e != nil {
49
+ if er, ok := e.(error); ok {
50
+ err = er
51
+ }
52
+ }
53
+
54
+ resdata := vs.GetProp(resmap, "resdata")
55
+
56
+ var resmatch map[string]any
57
+ if rm := vs.GetProp(resmap, "resmatch"); rm != nil {
58
+ if rmm, ok := rm.(map[string]any); ok {
59
+ resmatch = rmm
60
+ }
61
+ }
62
+
63
+ return &Result{
64
+ Ok: ok,
65
+ Status: status,
66
+ StatusText: statusText,
67
+ Headers: headers,
68
+ Body: body,
69
+ Err: err,
70
+ Resdata: resdata,
71
+ Resmatch: resmatch,
72
+ }
73
+ }
@@ -0,0 +1,97 @@
1
+ package core
2
+
3
+ type Spec struct {
4
+ Parts []any
5
+ Headers map[string]any
6
+ Alias map[string]any
7
+ Base string
8
+ Prefix string
9
+ Suffix string
10
+ Params map[string]any
11
+ Query map[string]any
12
+ Step string
13
+ Method string
14
+ Body any
15
+ Url string
16
+ Path string
17
+ }
18
+
19
+ func NewSpec(specmap map[string]any) *Spec {
20
+ s := &Spec{
21
+ Headers: map[string]any{},
22
+ Alias: map[string]any{},
23
+ Params: map[string]any{},
24
+ Query: map[string]any{},
25
+ Method: "GET",
26
+ }
27
+
28
+ if specmap == nil {
29
+ return s
30
+ }
31
+
32
+ if v, ok := specmap["parts"]; ok && v != nil {
33
+ if parts, ok := v.([]any); ok {
34
+ s.Parts = parts
35
+ }
36
+ }
37
+ if v, ok := specmap["headers"]; ok && v != nil {
38
+ if h, ok := v.(map[string]any); ok {
39
+ s.Headers = h
40
+ }
41
+ }
42
+ if v, ok := specmap["alias"]; ok && v != nil {
43
+ if a, ok := v.(map[string]any); ok {
44
+ s.Alias = a
45
+ }
46
+ }
47
+ if v, ok := specmap["base"]; ok && v != nil {
48
+ if b, ok := v.(string); ok {
49
+ s.Base = b
50
+ }
51
+ }
52
+ if v, ok := specmap["prefix"]; ok && v != nil {
53
+ if p, ok := v.(string); ok {
54
+ s.Prefix = p
55
+ }
56
+ }
57
+ if v, ok := specmap["suffix"]; ok && v != nil {
58
+ if sf, ok := v.(string); ok {
59
+ s.Suffix = sf
60
+ }
61
+ }
62
+ if v, ok := specmap["params"]; ok && v != nil {
63
+ if p, ok := v.(map[string]any); ok {
64
+ s.Params = p
65
+ }
66
+ }
67
+ if v, ok := specmap["query"]; ok && v != nil {
68
+ if q, ok := v.(map[string]any); ok {
69
+ s.Query = q
70
+ }
71
+ }
72
+ if v, ok := specmap["step"]; ok && v != nil {
73
+ if st, ok := v.(string); ok {
74
+ s.Step = st
75
+ }
76
+ }
77
+ if v, ok := specmap["method"]; ok && v != nil {
78
+ if m, ok := v.(string); ok {
79
+ s.Method = m
80
+ }
81
+ }
82
+ if v, ok := specmap["body"]; ok {
83
+ s.Body = v
84
+ }
85
+ if v, ok := specmap["url"]; ok && v != nil {
86
+ if u, ok := v.(string); ok {
87
+ s.Url = u
88
+ }
89
+ }
90
+ if v, ok := specmap["path"]; ok && v != nil {
91
+ if p, ok := v.(string); ok {
92
+ s.Path = p
93
+ }
94
+ }
95
+
96
+ return s
97
+ }
@@ -0,0 +1,102 @@
1
+ package core
2
+
3
+ import (
4
+ vs "github.com/voxgig/struct"
5
+ )
6
+
7
+ type Target struct {
8
+ Args map[string]any
9
+ Rename map[string]any
10
+ Method string
11
+ Orig string
12
+ Parts []any
13
+ Params []any
14
+ Select map[string]any
15
+ Active bool
16
+ Relations []any
17
+ Alias map[string]any
18
+ Transform map[string]any
19
+ }
20
+
21
+ func NewTarget(altmap map[string]any) *Target {
22
+ t := &Target{}
23
+
24
+ if args := vs.GetProp(altmap, "args"); args != nil {
25
+ if am, ok := args.(map[string]any); ok {
26
+ t.Args = am
27
+ }
28
+ }
29
+ if t.Args == nil {
30
+ t.Args = map[string]any{"params": []any{}}
31
+ }
32
+
33
+ if rename := vs.GetProp(altmap, "rename"); rename != nil {
34
+ if rm, ok := rename.(map[string]any); ok {
35
+ t.Rename = rm
36
+ }
37
+ }
38
+ if t.Rename == nil {
39
+ t.Rename = map[string]any{"params": map[string]any{}}
40
+ }
41
+
42
+ if m := vs.GetProp(altmap, "method"); m != nil {
43
+ t.Method, _ = m.(string)
44
+ }
45
+
46
+ if o := vs.GetProp(altmap, "orig"); o != nil {
47
+ t.Orig, _ = o.(string)
48
+ }
49
+
50
+ if p := vs.GetProp(altmap, "parts"); p != nil {
51
+ if pl, ok := p.([]any); ok {
52
+ t.Parts = pl
53
+ }
54
+ }
55
+ if t.Parts == nil {
56
+ t.Parts = []any{}
57
+ }
58
+
59
+ if p := vs.GetProp(altmap, "params"); p != nil {
60
+ if pl, ok := p.([]any); ok {
61
+ t.Params = pl
62
+ }
63
+ }
64
+
65
+ if s := vs.GetProp(altmap, "select"); s != nil {
66
+ if sm, ok := s.(map[string]any); ok {
67
+ t.Select = sm
68
+ }
69
+ }
70
+
71
+ if a := vs.GetProp(altmap, "active"); a != nil {
72
+ if ab, ok := a.(bool); ok {
73
+ t.Active = ab
74
+ }
75
+ }
76
+
77
+ if r := vs.GetProp(altmap, "relations"); r != nil {
78
+ if rl, ok := r.([]any); ok {
79
+ t.Relations = rl
80
+ }
81
+ }
82
+
83
+ if a := vs.GetProp(altmap, "alias"); a != nil {
84
+ if am, ok := a.(map[string]any); ok {
85
+ t.Alias = am
86
+ }
87
+ }
88
+ if t.Alias == nil {
89
+ t.Alias = map[string]any{}
90
+ }
91
+
92
+ if tf := vs.GetProp(altmap, "transform"); tf != nil {
93
+ if tm, ok := tf.(map[string]any); ok {
94
+ t.Transform = tm
95
+ }
96
+ }
97
+ if t.Transform == nil {
98
+ t.Transform = map[string]any{}
99
+ }
100
+
101
+ return t
102
+ }
@@ -0,0 +1,44 @@
1
+ package core
2
+
3
+ type Feature interface {
4
+ GetVersion() string
5
+ GetName() string
6
+ GetActive() bool
7
+
8
+ Init(ctx *Context, options map[string]any)
9
+
10
+ PostConstruct(ctx *Context)
11
+ PostConstructEntity(ctx *Context)
12
+ SetData(ctx *Context)
13
+ GetData(ctx *Context)
14
+ GetMatch(ctx *Context)
15
+
16
+ PreTarget(ctx *Context)
17
+ PreSelection(ctx *Context)
18
+ PreSpec(ctx *Context)
19
+ PreRequest(ctx *Context)
20
+ PreResponse(ctx *Context)
21
+ PreResult(ctx *Context)
22
+ PreDone(ctx *Context)
23
+ PreUnexpected(ctx *Context)
24
+ PostOperation(ctx *Context)
25
+ SetMatch(ctx *Context)
26
+ }
27
+
28
+ type Entity interface {
29
+ GetName() string
30
+ Make() Entity
31
+ Data(data ...any) any
32
+ Match(match ...any) any
33
+ }
34
+
35
+ type ProjectNameEntity interface {
36
+ Entity
37
+ Load(reqmatch map[string]any, ctrl map[string]any) (any, error)
38
+ List(reqmatch map[string]any, ctrl map[string]any) (any, error)
39
+ Create(reqdata map[string]any, ctrl map[string]any) (any, error)
40
+ Update(reqdata map[string]any, ctrl map[string]any) (any, error)
41
+ Remove(reqmatch map[string]any, ctrl map[string]any) (any, error)
42
+ }
43
+
44
+ type FetcherFunc func(ctx *Context, fullurl string, fetchdef map[string]any) (any, error)
@@ -0,0 +1,54 @@
1
+ package core
2
+
3
+ type Utility struct {
4
+ Clean func(ctx *Context, val any) any
5
+ Done func(ctx *Context) (any, error)
6
+ MakeError func(ctx *Context, err error) (any, error)
7
+ FeatureAdd func(ctx *Context, f Feature)
8
+ FeatureHook func(ctx *Context, name string)
9
+ FeatureInit func(ctx *Context, f Feature)
10
+ Fetcher FetcherFunc
11
+ MakeFetchDef func(ctx *Context) (map[string]any, error)
12
+ MakeContext func(ctxmap map[string]any, basectx *Context) *Context
13
+ MakeOptions func(ctx *Context) map[string]any
14
+ MakeRequest func(ctx *Context) (*Response, error)
15
+ MakeResponse func(ctx *Context) (*Response, error)
16
+ MakeResult func(ctx *Context) (*Result, error)
17
+ MakeTarget func(ctx *Context) (map[string]any, error)
18
+ MakeSpec func(ctx *Context) (*Spec, error)
19
+ MakeUrl func(ctx *Context) (string, error)
20
+ Param func(ctx *Context, paramdef any) any
21
+ PrepareAuth func(ctx *Context) (*Spec, error)
22
+ PrepareBody func(ctx *Context) any
23
+ PrepareHeaders func(ctx *Context) map[string]any
24
+ PrepareMethod func(ctx *Context) string
25
+ PrepareParams func(ctx *Context) map[string]any
26
+ PreparePath func(ctx *Context) string
27
+ PrepareQuery func(ctx *Context) map[string]any
28
+ ResultBasic func(ctx *Context) *Result
29
+ ResultBody func(ctx *Context) *Result
30
+ ResultHeaders func(ctx *Context) *Result
31
+ TransformRequest func(ctx *Context) any
32
+ TransformResponse func(ctx *Context) any
33
+ Custom map[string]any
34
+ }
35
+
36
+ func NewUtility() *Utility {
37
+ u := &Utility{
38
+ Custom: map[string]any{},
39
+ }
40
+ if UtilityRegistrar != nil {
41
+ UtilityRegistrar(u)
42
+ }
43
+ return u
44
+ }
45
+
46
+ func CopyUtility(src *Utility) *Utility {
47
+ u := &Utility{}
48
+ *u = *src
49
+ u.Custom = map[string]any{}
50
+ for k, v := range src.Custom {
51
+ u.Custom[k] = v
52
+ }
53
+ return u
54
+ }
@@ -0,0 +1,40 @@
1
+ package feature
2
+
3
+ import (
4
+ "GOMODULE/core"
5
+ )
6
+
7
+ type BaseFeature struct {
8
+ Version string
9
+ Name string
10
+ Active bool
11
+ }
12
+
13
+ func NewBaseFeature() *BaseFeature {
14
+ return &BaseFeature{
15
+ Version: "0.0.1",
16
+ Name: "base",
17
+ Active: true,
18
+ }
19
+ }
20
+
21
+ func (f *BaseFeature) GetVersion() string { return f.Version }
22
+ func (f *BaseFeature) GetName() string { return f.Name }
23
+ func (f *BaseFeature) GetActive() bool { return f.Active }
24
+
25
+ func (f *BaseFeature) Init(ctx *core.Context, options map[string]any) {}
26
+ func (f *BaseFeature) PostConstruct(ctx *core.Context) {}
27
+ func (f *BaseFeature) PostConstructEntity(ctx *core.Context) {}
28
+ func (f *BaseFeature) SetData(ctx *core.Context) {}
29
+ func (f *BaseFeature) GetData(ctx *core.Context) {}
30
+ func (f *BaseFeature) GetMatch(ctx *core.Context) {}
31
+ func (f *BaseFeature) SetMatch(ctx *core.Context) {}
32
+ func (f *BaseFeature) PreTarget(ctx *core.Context) {}
33
+ func (f *BaseFeature) PreSelection(ctx *core.Context) {}
34
+ func (f *BaseFeature) PreSpec(ctx *core.Context) {}
35
+ func (f *BaseFeature) PreRequest(ctx *core.Context) {}
36
+ func (f *BaseFeature) PreResponse(ctx *core.Context) {}
37
+ func (f *BaseFeature) PreResult(ctx *core.Context) {}
38
+ func (f *BaseFeature) PreDone(ctx *core.Context) {}
39
+ func (f *BaseFeature) PreUnexpected(ctx *core.Context) {}
40
+ func (f *BaseFeature) PostOperation(ctx *core.Context) {}