@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.
- package/bin/voxgig-sdkgen +6 -6
- package/dist/action/action.js +1 -2
- package/dist/action/action.js.map +1 -1
- package/dist/action/feature.js +4 -2
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.js +4 -2
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Entity.js +2 -1
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Feature.js +11 -9
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureHook.js +2 -1
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/Main.js +6 -2
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/ReadmeEntity.js +2 -1
- package/dist/cmp/ReadmeEntity.js.map +1 -1
- package/dist/cmp/Test.d.ts +2 -0
- package/dist/cmp/Test.js +17 -0
- package/dist/cmp/Test.js.map +1 -0
- package/dist/sdkgen.d.ts +2 -1
- package/dist/sdkgen.js +17 -28
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/model/sdkgen.jsonic +9 -9
- package/package.json +8 -6
- package/project/.sdk/model/feature/log.jsonic +3 -3
- package/project/.sdk/model/feature/test.jsonic +8 -3
- package/project/.sdk/model/target/go.jsonic +19 -4
- package/project/.sdk/model/target/js.jsonic +2 -2
- package/project/.sdk/model/target/ts.jsonic +5 -5
- package/project/.sdk/src/cmp/go/Config_go.ts +119 -0
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +48 -0
- package/project/.sdk/src/cmp/go/Entity_go.ts +67 -0
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +22 -0
- package/project/.sdk/src/cmp/go/Main_go.ts +209 -0
- package/project/.sdk/src/cmp/go/Package_go.ts +89 -0
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +373 -0
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +341 -0
- package/project/.sdk/src/cmp/go/Test_go.ts +37 -0
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +146 -0
- package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +35 -0
- package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +26 -0
- package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +38 -0
- package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +38 -0
- package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +38 -0
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +250 -0
- package/project/.sdk/src/cmp/go/fragment/SdkError.fragment.go +22 -0
- package/project/.sdk/src/cmp/go/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/go/utility_go.ts +88 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +3 -3
- package/project/.sdk/src/cmp/js/Quick_js.ts +1 -1
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +85 -1
- package/project/.sdk/src/cmp/ts/Config_ts.ts +53 -6
- package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +3 -21
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +3 -5
- package/project/.sdk/src/cmp/ts/Main_ts.ts +23 -13
- package/project/.sdk/src/cmp/ts/Package_ts.ts +30 -11
- package/project/.sdk/src/cmp/ts/SdkError_ts.ts +42 -0
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +288 -0
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +349 -2
- package/project/.sdk/src/cmp/ts/TestMain_ts.ts +0 -3
- package/project/.sdk/src/cmp/ts/Test_ts.ts +23 -3
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +38 -5
- package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +30 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +50 -38
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +9 -7
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +47 -31
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +49 -31
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +50 -33
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +51 -32
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +51 -31
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +166 -34
- package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +25 -0
- package/project/.sdk/src/cmp/ts/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/ts/utility_ts.ts +55 -1
- package/project/.sdk/tm/go/Makefile +10 -0
- package/project/.sdk/tm/go/core/context.go +267 -0
- package/project/.sdk/tm/go/core/control.go +7 -0
- package/project/.sdk/tm/go/core/error.go +25 -0
- package/project/.sdk/tm/go/core/helpers.go +33 -0
- package/project/.sdk/tm/go/core/operation.go +61 -0
- package/project/.sdk/tm/go/core/response.go +55 -0
- package/project/.sdk/tm/go/core/result.go +73 -0
- package/project/.sdk/tm/go/core/spec.go +97 -0
- package/project/.sdk/tm/go/core/target.go +102 -0
- package/project/.sdk/tm/go/core/types.go +44 -0
- package/project/.sdk/tm/go/core/utility_type.go +54 -0
- package/project/.sdk/tm/go/feature/base_feature.go +40 -0
- package/project/.sdk/tm/go/feature/test_feature.go +196 -0
- package/project/.sdk/tm/go/src/feature/README.md +1 -0
- package/project/.sdk/tm/go/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/go/test/custom_utility_test.go +80 -0
- package/project/.sdk/tm/go/test/exists_test.go +16 -0
- package/project/.sdk/tm/go/test/primary_utility_test.go +899 -0
- package/project/.sdk/tm/go/test/runner_test.go +428 -0
- package/project/.sdk/tm/go/test/struct_runner_test.go +1094 -0
- package/project/.sdk/tm/go/test/struct_utility_test.go +1423 -0
- package/project/.sdk/tm/go/utility/clean.go +7 -0
- package/project/.sdk/tm/go/utility/done.go +20 -0
- package/project/.sdk/tm/go/utility/feature_add.go +10 -0
- package/project/.sdk/tm/go/utility/feature_hook.go +30 -0
- package/project/.sdk/tm/go/utility/feature_init.go +30 -0
- package/project/.sdk/tm/go/utility/fetcher.go +102 -0
- package/project/.sdk/tm/go/utility/make_context.go +7 -0
- package/project/.sdk/tm/go/utility/make_error.go +69 -0
- package/project/.sdk/tm/go/utility/make_fetch_def.go +44 -0
- package/project/.sdk/tm/go/utility/make_options.go +130 -0
- package/project/.sdk/tm/go/utility/make_request.go +59 -0
- package/project/.sdk/tm/go/utility/make_response.go +46 -0
- package/project/.sdk/tm/go/utility/make_result.go +55 -0
- package/project/.sdk/tm/go/utility/make_spec.go +68 -0
- package/project/.sdk/tm/go/utility/make_target.go +95 -0
- package/project/.sdk/tm/go/utility/make_url.go +41 -0
- package/project/.sdk/tm/go/utility/param.go +66 -0
- package/project/.sdk/tm/go/utility/prepare_auth.go +40 -0
- package/project/.sdk/tm/go/utility/prepare_body.go +14 -0
- package/project/.sdk/tm/go/utility/prepare_headers.go +22 -0
- package/project/.sdk/tm/go/utility/prepare_method.go +21 -0
- package/project/.sdk/tm/go/utility/prepare_params.go +41 -0
- package/project/.sdk/tm/go/utility/prepare_path.go +21 -0
- package/project/.sdk/tm/go/utility/prepare_query.go +47 -0
- package/project/.sdk/tm/go/utility/register.go +39 -0
- package/project/.sdk/tm/go/utility/result_basic.go +31 -0
- package/project/.sdk/tm/go/utility/result_body.go +17 -0
- package/project/.sdk/tm/go/utility/result_headers.go +22 -0
- package/project/.sdk/tm/go/utility/struct/go.mod +3 -0
- package/project/.sdk/tm/go/utility/struct/voxgigstruct.go +4891 -0
- package/project/.sdk/tm/go/utility/transform_request.go +32 -0
- package/project/.sdk/tm/go/utility/transform_response.go +45 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +2 -2
- package/project/.sdk/tm/ts/src/Context.ts +144 -0
- package/project/.sdk/tm/ts/src/Control.ts +20 -0
- package/project/.sdk/tm/ts/src/Operation.ts +24 -0
- package/project/.sdk/tm/ts/src/Response.ts +26 -0
- package/project/.sdk/tm/ts/src/Result.ts +30 -0
- package/project/.sdk/tm/ts/src/Spec.ts +40 -0
- package/project/.sdk/tm/ts/src/Target.ts +36 -0
- package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +1 -1
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +2 -2
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +158 -104
- package/project/.sdk/tm/ts/src/types.ts +18 -78
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +17 -31
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +3 -4
- package/project/.sdk/tm/ts/src/utility/{AddfeatureUtility.ts → FeatureAddUtility.ts} +2 -2
- package/project/.sdk/tm/ts/src/utility/{FeaturehookUtility.ts → FeatureHookUtility.ts} +8 -5
- package/project/.sdk/tm/ts/src/utility/FeatureInitUtility.ts +15 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +20 -2
- package/project/.sdk/tm/ts/src/utility/MakeContextUtility.ts +27 -0
- package/project/.sdk/tm/ts/src/utility/{ErrorUtility.ts → MakeErrorUtility.ts} +10 -6
- package/project/.sdk/tm/ts/src/utility/MakeFetchDefUtility.ts +46 -0
- package/project/.sdk/tm/ts/src/utility/{OptionsUtility.ts → MakeOptionsUtility.ts} +32 -7
- package/project/.sdk/tm/ts/src/utility/MakeRequestUtility.ts +66 -0
- package/project/.sdk/tm/ts/src/utility/MakeResponseUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/MakeResultUtility.ts +56 -0
- package/project/.sdk/tm/ts/src/utility/MakeSpecUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/MakeTargetUtility.ts +76 -0
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/{FindparamUtility.ts → ParamUtility.ts} +28 -8
- package/project/.sdk/tm/ts/src/utility/{AuthUtility.ts → PrepareAuthUtility.ts} +10 -4
- package/project/.sdk/tm/ts/src/utility/PrepareBodyUtility.ts +32 -0
- package/project/.sdk/tm/ts/src/utility/{HeadersUtility.ts → PrepareHeadersUtility.ts} +5 -7
- package/project/.sdk/tm/ts/src/utility/{MethodUtility.ts → PrepareMethodUtility.ts} +6 -6
- package/project/.sdk/tm/ts/src/utility/PrepareParamsUtility.ts +37 -0
- package/project/.sdk/tm/ts/src/utility/PreparePathUtility.ts +17 -0
- package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +30 -0
- package/project/.sdk/tm/ts/src/utility/{ResbasicUtility.ts → ResultBasicUtility.ts} +12 -7
- package/project/.sdk/tm/ts/src/utility/ResultBodyUtility.ts +22 -0
- package/project/.sdk/tm/ts/src/utility/ResultHeadersUtility.ts +26 -0
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +1113 -525
- package/project/.sdk/tm/ts/src/utility/{ReqformUtility.ts → TransformRequestUtility.ts} +9 -7
- package/project/.sdk/tm/ts/src/utility/{ResformUtility.ts → TransformResponseUtility.ts} +11 -8
- package/project/.sdk/tm/ts/src/utility/Utility.ts +52 -65
- package/project/.sdk/tm/ts/test/exists.test.ts +0 -1
- package/project/.sdk/tm/ts/test/runner.ts +36 -13
- package/project/.sdk/tm/ts/test/utility/Custom.test.ts +30 -29
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +385 -168
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +433 -189
- package/src/action/action.ts +1 -2
- package/src/action/feature.ts +7 -2
- package/src/action/target.ts +7 -7
- package/src/cmp/Entity.ts +7 -1
- package/src/cmp/Feature.ts +11 -9
- package/src/cmp/FeatureHook.ts +6 -1
- package/src/cmp/Main.ts +12 -2
- package/src/cmp/ReadmeEntity.ts +6 -1
- package/src/cmp/Test.ts +31 -0
- package/src/sdkgen.ts +19 -34
- package/src/types.ts +10 -1
- package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +0 -180
- package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +0 -29
- package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +0 -67
- package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +0 -46
- package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +0 -13
- package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +0 -15
- package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +0 -90
- package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +0 -37
- package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +0 -27
- package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +0 -66
- package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +0 -19
- package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +0 -23
- package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +0 -30
- package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +0 -36
- package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +0 -61
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
KIT,
|
|
4
|
+
getModelPath
|
|
5
|
+
} from '@voxgig/apidef'
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
ModelEntity
|
|
9
|
+
} from '@voxgig/apidef'
|
|
10
|
+
|
|
11
|
+
import { cmp, each, Folder } from '@voxgig/sdkgen'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { TestEntity } from './TestEntity_go'
|
|
15
|
+
import { TestDirect } from './TestDirect_go'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const Test = cmp(function Test(props: any) {
|
|
19
|
+
const { model, stdrep } = props.ctx$
|
|
20
|
+
const { target } = props
|
|
21
|
+
|
|
22
|
+
// Module name: concatenated lowercase
|
|
23
|
+
const orgPrefix = (model.origin || '').replace(/-sdk$/, '').replace(/[^a-z0-9]/gi, '')
|
|
24
|
+
const gomodule = orgPrefix + model.name + 'sdk'
|
|
25
|
+
|
|
26
|
+
Folder({ name: 'test' }, () => {
|
|
27
|
+
each(model.main[KIT].entity, (entity: ModelEntity) => {
|
|
28
|
+
TestEntity({ target, entity, gomodule })
|
|
29
|
+
TestDirect({ target, entity, gomodule })
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
Test
|
|
37
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"GOMODULE/core"
|
|
5
|
+
|
|
6
|
+
vs "github.com/voxgig/struct"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type EntityNameEntity struct {
|
|
10
|
+
name string
|
|
11
|
+
client *core.ProjectNameSDK
|
|
12
|
+
utility *core.Utility
|
|
13
|
+
entopts map[string]any
|
|
14
|
+
data map[string]any
|
|
15
|
+
match map[string]any
|
|
16
|
+
entctx *core.Context
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func NewEntityNameEntity(client *core.ProjectNameSDK, entopts map[string]any) *EntityNameEntity {
|
|
20
|
+
if entopts == nil {
|
|
21
|
+
entopts = map[string]any{}
|
|
22
|
+
}
|
|
23
|
+
if _, ok := entopts["active"]; !ok {
|
|
24
|
+
entopts["active"] = true
|
|
25
|
+
} else if entopts["active"] == false {
|
|
26
|
+
// keep false
|
|
27
|
+
} else {
|
|
28
|
+
entopts["active"] = true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
e := &EntityNameEntity{
|
|
32
|
+
name: "entityname",
|
|
33
|
+
client: client,
|
|
34
|
+
utility: client.GetUtility(),
|
|
35
|
+
entopts: entopts,
|
|
36
|
+
data: map[string]any{},
|
|
37
|
+
match: map[string]any{},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
e.entctx = e.utility.MakeContext(map[string]any{
|
|
41
|
+
"entity": e,
|
|
42
|
+
"entopts": entopts,
|
|
43
|
+
}, client.GetRootCtx())
|
|
44
|
+
|
|
45
|
+
e.utility.FeatureHook(e.entctx, "PostConstructEntity")
|
|
46
|
+
|
|
47
|
+
return e
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func (e *EntityNameEntity) GetName() string { return e.name }
|
|
51
|
+
|
|
52
|
+
func (e *EntityNameEntity) Make() core.Entity {
|
|
53
|
+
opts := map[string]any{}
|
|
54
|
+
for k, v := range e.entopts {
|
|
55
|
+
opts[k] = v
|
|
56
|
+
}
|
|
57
|
+
return NewEntityNameEntity(e.client, opts)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func (e *EntityNameEntity) Data(args ...any) any {
|
|
61
|
+
if len(args) > 0 && args[0] != nil {
|
|
62
|
+
e.data = core.ToMapAny(vs.Clone(args[0]))
|
|
63
|
+
if e.data == nil {
|
|
64
|
+
e.data = map[string]any{}
|
|
65
|
+
}
|
|
66
|
+
e.utility.FeatureHook(e.entctx, "SetData")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
e.utility.FeatureHook(e.entctx, "GetData")
|
|
70
|
+
out := vs.Clone(e.data)
|
|
71
|
+
return out
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func (e *EntityNameEntity) Match(args ...any) any {
|
|
75
|
+
if len(args) > 0 && args[0] != nil {
|
|
76
|
+
e.match = core.ToMapAny(vs.Clone(args[0]))
|
|
77
|
+
if e.match == nil {
|
|
78
|
+
e.match = map[string]any{}
|
|
79
|
+
}
|
|
80
|
+
e.utility.FeatureHook(e.entctx, "SetMatch")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
e.utility.FeatureHook(e.entctx, "GetMatch")
|
|
84
|
+
out := vs.Clone(e.match)
|
|
85
|
+
return out
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// #LoadOp
|
|
89
|
+
|
|
90
|
+
// #ListOp
|
|
91
|
+
|
|
92
|
+
// #CreateOp
|
|
93
|
+
|
|
94
|
+
// #UpdateOp
|
|
95
|
+
|
|
96
|
+
// #RemoveOp
|
|
97
|
+
|
|
98
|
+
func (e *EntityNameEntity) runOp(ctx *core.Context, postDone func()) (any, error) {
|
|
99
|
+
utility := e.utility
|
|
100
|
+
|
|
101
|
+
// #PreSelection-Hook
|
|
102
|
+
|
|
103
|
+
target, err := utility.MakeTarget(ctx)
|
|
104
|
+
ctx.Out["target"] = target
|
|
105
|
+
if err != nil {
|
|
106
|
+
return utility.MakeError(ctx, err)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// #PreSpec-Hook
|
|
110
|
+
|
|
111
|
+
spec, err := utility.MakeSpec(ctx)
|
|
112
|
+
ctx.Out["spec"] = spec
|
|
113
|
+
if err != nil {
|
|
114
|
+
return utility.MakeError(ctx, err)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// #PreRequest-Hook
|
|
118
|
+
|
|
119
|
+
resp, err := utility.MakeRequest(ctx)
|
|
120
|
+
ctx.Out["request"] = resp
|
|
121
|
+
if err != nil {
|
|
122
|
+
return utility.MakeError(ctx, err)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// #PreResponse-Hook
|
|
126
|
+
|
|
127
|
+
resp2, err := utility.MakeResponse(ctx)
|
|
128
|
+
ctx.Out["response"] = resp2
|
|
129
|
+
if err != nil {
|
|
130
|
+
return utility.MakeError(ctx, err)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// #PreResult-Hook
|
|
134
|
+
|
|
135
|
+
result, err := utility.MakeResult(ctx)
|
|
136
|
+
ctx.Out["result"] = result
|
|
137
|
+
if err != nil {
|
|
138
|
+
return utility.MakeError(ctx, err)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// #PreDone-Hook
|
|
142
|
+
|
|
143
|
+
postDone()
|
|
144
|
+
|
|
145
|
+
return utility.Done(ctx)
|
|
146
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"GOMODULE/core"
|
|
5
|
+
|
|
6
|
+
vs "github.com/voxgig/struct"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type entityCreateOp struct{}
|
|
10
|
+
|
|
11
|
+
// EJECT-START
|
|
12
|
+
|
|
13
|
+
func (e *EntityNameEntity) Create(reqdata map[string]any, ctrl map[string]any) (any, error) {
|
|
14
|
+
utility := e.utility
|
|
15
|
+
ctx := utility.MakeContext(map[string]any{
|
|
16
|
+
"opname": "create",
|
|
17
|
+
"ctrl": ctrl,
|
|
18
|
+
"match": e.match,
|
|
19
|
+
"data": e.data,
|
|
20
|
+
"reqdata": reqdata,
|
|
21
|
+
}, e.entctx)
|
|
22
|
+
|
|
23
|
+
return e.runOp(ctx, func() {
|
|
24
|
+
if ctx.Result != nil {
|
|
25
|
+
if ctx.Result.Resdata != nil {
|
|
26
|
+
e.data = core.ToMapAny(vs.Clone(ctx.Result.Resdata))
|
|
27
|
+
if e.data == nil {
|
|
28
|
+
e.data = map[string]any{}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// EJECT-END
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
type entityListOp struct{}
|
|
4
|
+
|
|
5
|
+
// EJECT-START
|
|
6
|
+
|
|
7
|
+
func (e *EntityNameEntity) List(reqmatch map[string]any, ctrl map[string]any) (any, error) {
|
|
8
|
+
utility := e.utility
|
|
9
|
+
ctx := utility.MakeContext(map[string]any{
|
|
10
|
+
"opname": "list",
|
|
11
|
+
"ctrl": ctrl,
|
|
12
|
+
"match": e.match,
|
|
13
|
+
"data": e.data,
|
|
14
|
+
"reqmatch": reqmatch,
|
|
15
|
+
}, e.entctx)
|
|
16
|
+
|
|
17
|
+
return e.runOp(ctx, func() {
|
|
18
|
+
if ctx.Result != nil {
|
|
19
|
+
if ctx.Result.Resmatch != nil {
|
|
20
|
+
e.match = ctx.Result.Resmatch
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// EJECT-END
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"GOMODULE/core"
|
|
5
|
+
|
|
6
|
+
vs "github.com/voxgig/struct"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type entityLoadOp struct{}
|
|
10
|
+
|
|
11
|
+
// EJECT-START
|
|
12
|
+
|
|
13
|
+
func (e *EntityNameEntity) Load(reqmatch map[string]any, ctrl map[string]any) (any, error) {
|
|
14
|
+
utility := e.utility
|
|
15
|
+
ctx := utility.MakeContext(map[string]any{
|
|
16
|
+
"opname": "load",
|
|
17
|
+
"ctrl": ctrl,
|
|
18
|
+
"match": e.match,
|
|
19
|
+
"data": e.data,
|
|
20
|
+
"reqmatch": reqmatch,
|
|
21
|
+
}, e.entctx)
|
|
22
|
+
|
|
23
|
+
return e.runOp(ctx, func() {
|
|
24
|
+
if ctx.Result != nil {
|
|
25
|
+
if ctx.Result.Resmatch != nil {
|
|
26
|
+
e.match = ctx.Result.Resmatch
|
|
27
|
+
}
|
|
28
|
+
if ctx.Result.Resdata != nil {
|
|
29
|
+
e.data = core.ToMapAny(vs.Clone(ctx.Result.Resdata))
|
|
30
|
+
if e.data == nil {
|
|
31
|
+
e.data = map[string]any{}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// EJECT-END
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"GOMODULE/core"
|
|
5
|
+
|
|
6
|
+
vs "github.com/voxgig/struct"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type entityRemoveOp struct{}
|
|
10
|
+
|
|
11
|
+
// EJECT-START
|
|
12
|
+
|
|
13
|
+
func (e *EntityNameEntity) Remove(reqmatch map[string]any, ctrl map[string]any) (any, error) {
|
|
14
|
+
utility := e.utility
|
|
15
|
+
ctx := utility.MakeContext(map[string]any{
|
|
16
|
+
"opname": "remove",
|
|
17
|
+
"ctrl": ctrl,
|
|
18
|
+
"match": e.match,
|
|
19
|
+
"data": e.data,
|
|
20
|
+
"reqmatch": reqmatch,
|
|
21
|
+
}, e.entctx)
|
|
22
|
+
|
|
23
|
+
return e.runOp(ctx, func() {
|
|
24
|
+
if ctx.Result != nil {
|
|
25
|
+
if ctx.Result.Resmatch != nil {
|
|
26
|
+
e.match = ctx.Result.Resmatch
|
|
27
|
+
}
|
|
28
|
+
if ctx.Result.Resdata != nil {
|
|
29
|
+
e.data = core.ToMapAny(vs.Clone(ctx.Result.Resdata))
|
|
30
|
+
if e.data == nil {
|
|
31
|
+
e.data = map[string]any{}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// EJECT-END
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package entity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"GOMODULE/core"
|
|
5
|
+
|
|
6
|
+
vs "github.com/voxgig/struct"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type entityUpdateOp struct{}
|
|
10
|
+
|
|
11
|
+
// EJECT-START
|
|
12
|
+
|
|
13
|
+
func (e *EntityNameEntity) Update(reqdata map[string]any, ctrl map[string]any) (any, error) {
|
|
14
|
+
utility := e.utility
|
|
15
|
+
ctx := utility.MakeContext(map[string]any{
|
|
16
|
+
"opname": "update",
|
|
17
|
+
"ctrl": ctrl,
|
|
18
|
+
"match": e.match,
|
|
19
|
+
"data": e.data,
|
|
20
|
+
"reqdata": reqdata,
|
|
21
|
+
}, e.entctx)
|
|
22
|
+
|
|
23
|
+
return e.runOp(ctx, func() {
|
|
24
|
+
if ctx.Result != nil {
|
|
25
|
+
if ctx.Result.Resmatch != nil {
|
|
26
|
+
e.match = ctx.Result.Resmatch
|
|
27
|
+
}
|
|
28
|
+
if ctx.Result.Resdata != nil {
|
|
29
|
+
e.data = core.ToMapAny(vs.Clone(ctx.Result.Resdata))
|
|
30
|
+
if e.data == nil {
|
|
31
|
+
e.data = map[string]any{}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// EJECT-END
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
package core
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
vs "github.com/voxgig/struct"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
type ProjectNameSDK struct {
|
|
8
|
+
Mode string
|
|
9
|
+
options map[string]any
|
|
10
|
+
utility *Utility
|
|
11
|
+
Features []Feature
|
|
12
|
+
rootctx *Context
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
func NewProjectNameSDK(options map[string]any) *ProjectNameSDK {
|
|
16
|
+
sdk := &ProjectNameSDK{
|
|
17
|
+
Mode: "live",
|
|
18
|
+
Features: []Feature{},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
sdk.utility = NewUtility()
|
|
22
|
+
|
|
23
|
+
config := MakeConfig()
|
|
24
|
+
|
|
25
|
+
sdk.rootctx = sdk.utility.MakeContext(map[string]any{
|
|
26
|
+
"client": sdk,
|
|
27
|
+
"utility": sdk.utility,
|
|
28
|
+
"config": config,
|
|
29
|
+
"options": options,
|
|
30
|
+
"shared": map[string]any{},
|
|
31
|
+
}, nil)
|
|
32
|
+
|
|
33
|
+
sdk.options = sdk.utility.MakeOptions(sdk.rootctx)
|
|
34
|
+
|
|
35
|
+
if vs.GetPath([]any{"feature", "test", "active"}, sdk.options) == true {
|
|
36
|
+
sdk.Mode = "test"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
sdk.rootctx.Options = sdk.options
|
|
40
|
+
|
|
41
|
+
// Add features from config.
|
|
42
|
+
featureOpts := ToMapAny(vs.GetProp(sdk.options, "feature"))
|
|
43
|
+
if featureOpts != nil {
|
|
44
|
+
for _, item := range vs.Items(featureOpts) {
|
|
45
|
+
fname, _ := item[0].(string)
|
|
46
|
+
fopts := ToMapAny(item[1])
|
|
47
|
+
if fopts != nil {
|
|
48
|
+
if active, ok := fopts["active"]; ok {
|
|
49
|
+
if ab, ok := active.(bool); ok && ab {
|
|
50
|
+
sdk.utility.FeatureAdd(sdk.rootctx, makeFeature(fname))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Add extension features.
|
|
58
|
+
if extend := vs.GetProp(sdk.options, "extend"); extend != nil {
|
|
59
|
+
if extList, ok := extend.([]any); ok {
|
|
60
|
+
for _, f := range extList {
|
|
61
|
+
if feat, ok := f.(Feature); ok {
|
|
62
|
+
sdk.utility.FeatureAdd(sdk.rootctx, feat)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Initialize features.
|
|
69
|
+
for _, f := range sdk.Features {
|
|
70
|
+
sdk.utility.FeatureInit(sdk.rootctx, f)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
sdk.utility.FeatureHook(sdk.rootctx, "PostConstruct")
|
|
74
|
+
|
|
75
|
+
return sdk
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func (sdk *ProjectNameSDK) OptionsMap() map[string]any {
|
|
79
|
+
out := vs.Clone(sdk.options)
|
|
80
|
+
if om, ok := out.(map[string]any); ok {
|
|
81
|
+
return om
|
|
82
|
+
}
|
|
83
|
+
return map[string]any{}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func (sdk *ProjectNameSDK) GetUtility() *Utility {
|
|
87
|
+
return CopyUtility(sdk.utility)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func (sdk *ProjectNameSDK) GetRootCtx() *Context {
|
|
91
|
+
return sdk.rootctx
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
func (sdk *ProjectNameSDK) Prepare(fetchargs map[string]any) (map[string]any, error) {
|
|
95
|
+
utility := sdk.utility
|
|
96
|
+
|
|
97
|
+
if fetchargs == nil {
|
|
98
|
+
fetchargs = map[string]any{}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var ctrl map[string]any
|
|
102
|
+
if c := vs.GetProp(fetchargs, "ctrl"); c != nil {
|
|
103
|
+
if cm, ok := c.(map[string]any); ok {
|
|
104
|
+
ctrl = cm
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if ctrl == nil {
|
|
108
|
+
ctrl = map[string]any{}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
ctx := utility.MakeContext(map[string]any{
|
|
112
|
+
"opname": "prepare",
|
|
113
|
+
"ctrl": ctrl,
|
|
114
|
+
}, sdk.rootctx)
|
|
115
|
+
|
|
116
|
+
options := sdk.options
|
|
117
|
+
|
|
118
|
+
path, _ := vs.GetProp(fetchargs, "path").(string)
|
|
119
|
+
method, _ := vs.GetProp(fetchargs, "method").(string)
|
|
120
|
+
if method == "" {
|
|
121
|
+
method = "GET"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
params := ToMapAny(vs.GetProp(fetchargs, "params"))
|
|
125
|
+
if params == nil {
|
|
126
|
+
params = map[string]any{}
|
|
127
|
+
}
|
|
128
|
+
query := ToMapAny(vs.GetProp(fetchargs, "query"))
|
|
129
|
+
if query == nil {
|
|
130
|
+
query = map[string]any{}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
headers := utility.PrepareHeaders(ctx)
|
|
134
|
+
|
|
135
|
+
base, _ := vs.GetProp(options, "base").(string)
|
|
136
|
+
prefix, _ := vs.GetProp(options, "prefix").(string)
|
|
137
|
+
suffix, _ := vs.GetProp(options, "suffix").(string)
|
|
138
|
+
|
|
139
|
+
ctx.Spec = NewSpec(map[string]any{
|
|
140
|
+
"base": base,
|
|
141
|
+
"prefix": prefix,
|
|
142
|
+
"suffix": suffix,
|
|
143
|
+
"path": path,
|
|
144
|
+
"method": method,
|
|
145
|
+
"params": params,
|
|
146
|
+
"query": query,
|
|
147
|
+
"headers": headers,
|
|
148
|
+
"body": vs.GetProp(fetchargs, "body"),
|
|
149
|
+
"step": "start",
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
// Merge user-provided headers.
|
|
153
|
+
if uh := vs.GetProp(fetchargs, "headers"); uh != nil {
|
|
154
|
+
if uhm, ok := uh.(map[string]any); ok {
|
|
155
|
+
for k, v := range uhm {
|
|
156
|
+
ctx.Spec.Headers[k] = v
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_, err := utility.PrepareAuth(ctx)
|
|
162
|
+
if err != nil {
|
|
163
|
+
return nil, err
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return utility.MakeFetchDef(ctx)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
func (sdk *ProjectNameSDK) Direct(fetchargs map[string]any) (map[string]any, error) {
|
|
170
|
+
utility := sdk.utility
|
|
171
|
+
|
|
172
|
+
fetchdef, err := sdk.Prepare(fetchargs)
|
|
173
|
+
if err != nil {
|
|
174
|
+
return map[string]any{"ok": false, "err": err}, nil
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if fetchargs == nil {
|
|
178
|
+
fetchargs = map[string]any{}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var ctrl map[string]any
|
|
182
|
+
if c := vs.GetProp(fetchargs, "ctrl"); c != nil {
|
|
183
|
+
if cm, ok := c.(map[string]any); ok {
|
|
184
|
+
ctrl = cm
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if ctrl == nil {
|
|
188
|
+
ctrl = map[string]any{}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
ctx := utility.MakeContext(map[string]any{
|
|
192
|
+
"opname": "direct",
|
|
193
|
+
"ctrl": ctrl,
|
|
194
|
+
}, sdk.rootctx)
|
|
195
|
+
|
|
196
|
+
url, _ := fetchdef["url"].(string)
|
|
197
|
+
fetched, fetchErr := utility.Fetcher(ctx, url, fetchdef)
|
|
198
|
+
|
|
199
|
+
if fetchErr != nil {
|
|
200
|
+
return map[string]any{"ok": false, "err": fetchErr}, nil
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if fetched == nil {
|
|
204
|
+
return map[string]any{
|
|
205
|
+
"ok": false,
|
|
206
|
+
"err": ctx.MakeError("direct_no_response", "response: undefined"),
|
|
207
|
+
}, nil
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if fm, ok := fetched.(map[string]any); ok {
|
|
211
|
+
status := ToInt(vs.GetProp(fm, "status"))
|
|
212
|
+
var jsonData any
|
|
213
|
+
if jf := vs.GetProp(fm, "json"); jf != nil {
|
|
214
|
+
if f, ok := jf.(func() any); ok {
|
|
215
|
+
jsonData = f()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return map[string]any{
|
|
220
|
+
"ok": status >= 200 && status < 300,
|
|
221
|
+
"status": status,
|
|
222
|
+
"headers": vs.GetProp(fm, "headers"),
|
|
223
|
+
"data": jsonData,
|
|
224
|
+
}, nil
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return map[string]any{"ok": false, "err": ctx.MakeError("direct_invalid", "invalid response type")}, nil
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// <[SLOT]>
|
|
231
|
+
|
|
232
|
+
func TestSDK(testopts map[string]any, sdkopts map[string]any) *ProjectNameSDK {
|
|
233
|
+
if sdkopts == nil {
|
|
234
|
+
sdkopts = map[string]any{}
|
|
235
|
+
}
|
|
236
|
+
sdkopts = vs.Clone(sdkopts).(map[string]any)
|
|
237
|
+
|
|
238
|
+
if testopts == nil {
|
|
239
|
+
testopts = map[string]any{}
|
|
240
|
+
}
|
|
241
|
+
testopts = vs.Clone(testopts).(map[string]any)
|
|
242
|
+
testopts["active"] = true
|
|
243
|
+
|
|
244
|
+
vs.SetPath(sdkopts, []any{"feature", "test"}, testopts)
|
|
245
|
+
|
|
246
|
+
sdk := NewProjectNameSDK(sdkopts)
|
|
247
|
+
sdk.Mode = "test"
|
|
248
|
+
|
|
249
|
+
return sdk
|
|
250
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package ProjectNamePkg
|
|
2
|
+
|
|
3
|
+
import "fmt"
|
|
4
|
+
|
|
5
|
+
// ProjectNameError represents an SDK error.
|
|
6
|
+
type ProjectNameError struct {
|
|
7
|
+
Code string
|
|
8
|
+
Message string
|
|
9
|
+
SDK string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
func (e *ProjectNameError) Error() string {
|
|
13
|
+
return fmt.Sprintf("%s: %s: %s", e.SDK, e.Code, e.Message)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func NewProjectNameError(code string, msg string) *ProjectNameError {
|
|
17
|
+
return &ProjectNameError{
|
|
18
|
+
Code: code,
|
|
19
|
+
Message: msg,
|
|
20
|
+
SDK: "ProjectName",
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"noEmitOnError": true,
|
|
6
|
+
"outDir":"../dist",
|
|
7
|
+
"rootDir":".",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"target": "es2022",
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationDir": "../dist"
|
|
14
|
+
}
|
|
15
|
+
}
|