@voxgig/sdkgen 0.26.1 → 0.30.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 +1 -1
- package/dist/cmp/Feature.js +11 -9
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/Main.js +6 -2
- package/dist/cmp/Main.js.map +1 -1
- package/model/sdkgen.jsonic +1 -1
- package/package.json +5 -5
- package/project/.sdk/model/feature/log.jsonic +1 -1
- package/project/.sdk/model/feature/test.jsonic +1 -1
- package/project/.sdk/model/target/go.jsonic +19 -4
- package/project/.sdk/model/target/ts.jsonic +3 -3
- 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/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/EntityOperation_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/Main_ts.ts +4 -4
- 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 +14 -6
- package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
- package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +30 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +12 -12
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +12 -12
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +12 -12
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +13 -13
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +12 -12
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +102 -6
- package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +25 -0
- 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 +7 -7
- package/project/.sdk/tm/ts/src/types.ts +15 -205
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +2 -3
- package/project/.sdk/tm/ts/src/utility/{AddfeatureUtility.ts → FeatureAddUtility.ts} +2 -2
- package/project/.sdk/tm/ts/src/utility/{InitfeatureUtility.ts → FeatureInitUtility.ts} +2 -2
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +5 -3
- package/project/.sdk/tm/ts/src/utility/{ErrorUtility.ts → MakeErrorUtility.ts} +4 -4
- package/project/.sdk/tm/ts/src/utility/MakeFetchDefUtility.ts +46 -0
- package/project/.sdk/tm/ts/src/utility/{OptionsUtility.ts → MakeOptionsUtility.ts} +10 -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/{ResultUtility.ts → MakeResultUtility.ts} +6 -6
- package/project/.sdk/tm/ts/src/utility/MakeSpecUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/{SelectionUtility.ts → MakeTargetUtility.ts} +22 -24
- package/project/.sdk/tm/ts/src/utility/{FullurlUtility.ts → MakeUrlUtility.ts} +7 -8
- package/project/.sdk/tm/ts/src/utility/{FindparamUtility.ts → ParamUtility.ts} +21 -8
- package/project/.sdk/tm/ts/src/utility/{AuthUtility.ts → PrepareAuthUtility.ts} +4 -4
- package/project/.sdk/tm/ts/src/utility/{BodyUtility.ts → PrepareBodyUtility.ts} +7 -7
- 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 +3 -4
- package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +30 -0
- package/project/.sdk/tm/ts/src/utility/{ResbasicUtility.ts → ResultBasicUtility.ts} +11 -6
- package/project/.sdk/tm/ts/src/utility/{ResbodyUtility.ts → ResultBodyUtility.ts} +4 -3
- package/project/.sdk/tm/ts/src/utility/{ResheadersUtility.ts → ResultHeadersUtility.ts} +4 -3
- package/project/.sdk/tm/ts/src/utility/{ReqformUtility.ts → TransformRequestUtility.ts} +9 -7
- package/project/.sdk/tm/ts/src/utility/{ResformUtility.ts → TransformResponseUtility.ts} +10 -7
- package/project/.sdk/tm/ts/src/utility/Utility.ts +47 -62
- package/project/.sdk/tm/ts/test/runner.ts +25 -4
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +386 -175
- package/src/cmp/Feature.ts +11 -9
- package/src/cmp/Main.ts +8 -2
- package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +0 -15
- package/project/.sdk/tm/ts/src/utility/OperationUtility.ts +0 -23
- 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 -83
- package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +0 -61
- package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +0 -68
- /package/project/.sdk/tm/ts/src/utility/{FeaturehookUtility.ts → FeatureHookUtility.ts} +0 -0
- /package/project/.sdk/tm/ts/src/utility/{ContextUtility.ts → MakeContextUtility.ts} +0 -0
package/bin/voxgig-sdkgen
CHANGED
package/dist/cmp/Feature.js
CHANGED
|
@@ -5,16 +5,18 @@ const jostraca_1 = require("jostraca");
|
|
|
5
5
|
const Feature = (0, jostraca_1.cmp)(function Feature(props) {
|
|
6
6
|
const { target, feature, ctx$ } = props;
|
|
7
7
|
const { log } = ctx$;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
if (false !== target.srcfeature) {
|
|
9
|
+
(0, jostraca_1.Folder)({ name: 'src/feature/' + feature.name }, () => {
|
|
10
|
+
// TODO: Copy should just warn if from not found
|
|
11
|
+
(0, jostraca_1.Copy)({
|
|
12
|
+
from: 'tm/' + target.name + '/src/feature/' + feature.name,
|
|
13
|
+
replace: {
|
|
14
|
+
FEATURE_VERSION: feature.version,
|
|
15
|
+
FEATURE_Name: feature.Name,
|
|
16
|
+
}
|
|
17
|
+
});
|
|
16
18
|
});
|
|
17
|
-
}
|
|
19
|
+
}
|
|
18
20
|
log.info({
|
|
19
21
|
point: 'generate-feature', target, feature,
|
|
20
22
|
note: 'target:' + target.name + ', ' + 'feature: ' + feature.name
|
package/dist/cmp/Feature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feature.js","sourceRoot":"","sources":["../../src/cmp/Feature.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAE5C,MAAM,OAAO,GAAG,IAAA,cAAG,EAAC,SAAS,OAAO,CAAC,KAAU;IAC7C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IACvC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEpB,IAAA,iBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"Feature.js","sourceRoot":"","sources":["../../src/cmp/Feature.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAE5C,MAAM,OAAO,GAAG,IAAA,cAAG,EAAC,SAAS,OAAO,CAAC,KAAU;IAC7C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IACvC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEpB,IAAI,KAAK,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC;QAChC,IAAA,iBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;YACnD,gDAAgD;YAChD,IAAA,eAAI,EAAC;gBACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC,IAAI,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI;gBAC1D,OAAO,EAAE;oBACP,eAAe,EAAE,OAAO,CAAC,OAAO;oBAChC,YAAY,EAAE,OAAO,CAAC,IAAI;iBAC3B;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAC,IAAI,CAAC;QACP,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO;QAC1C,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI;KAClE,CAAC,CAAA;AAEJ,CAAC,CAAC,CAAA;AAIA,0BAAO"}
|
package/dist/cmp/Main.js
CHANGED
|
@@ -6,14 +6,18 @@ const utility_1 = require("../utility");
|
|
|
6
6
|
const Main = (0, jostraca_1.cmp)(function Main(props) {
|
|
7
7
|
const { target, ctx$ } = props;
|
|
8
8
|
const { model, stdrep, log } = ctx$;
|
|
9
|
-
|
|
9
|
+
const copyOpts = {
|
|
10
10
|
// This folder is relative to the .sdk folder in the project, as that is where
|
|
11
11
|
// the sdk is generated from.
|
|
12
12
|
from: 'tm/' + target.name,
|
|
13
13
|
replace: {
|
|
14
14
|
...stdrep,
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
|
+
if (false === target.srcfeature) {
|
|
18
|
+
copyOpts.exclude = [/src\//];
|
|
19
|
+
}
|
|
20
|
+
(0, jostraca_1.Copy)(copyOpts);
|
|
17
21
|
const Main_sdk = (0, utility_1.requirePath)(ctx$, `cmp/${target.name}/Main_${target.name}`);
|
|
18
22
|
Main_sdk['Main']({ model, target, stdrep });
|
|
19
23
|
log.info({ point: 'generate-main', target, note: 'target:' + target.name });
|
package/dist/cmp/Main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","sourceRoot":"","sources":["../../src/cmp/Main.ts"],"names":[],"mappings":";;;AACA,uCAA2C;AAE3C,wCAAwC;AAOxC,MAAM,IAAI,GAAG,IAAA,cAAG,EAAC,SAAS,IAAI,CAAC,KAAU;IACvC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAC9B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEnC,
|
|
1
|
+
{"version":3,"file":"Main.js","sourceRoot":"","sources":["../../src/cmp/Main.ts"],"names":[],"mappings":";;;AACA,uCAA2C;AAE3C,wCAAwC;AAOxC,MAAM,IAAI,GAAG,IAAA,cAAG,EAAC,SAAS,IAAI,CAAC,KAAU;IACvC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAC9B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEnC,MAAM,QAAQ,GAAQ;QACpB,8EAA8E;QAC9E,6BAA6B;QAC7B,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC,IAAI;QACzB,OAAO,EAAE;YACP,GAAG,MAAM;SACV;KACF,CAAA;IAED,IAAI,KAAK,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC;QAChC,QAAQ,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC;IAED,IAAA,eAAI,EAAC,QAAQ,CAAC,CAAA;IAEd,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAE5E,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAE3C,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;AAC7E,CAAC,CAAC,CAAA;AAIA,oBAAI"}
|
package/model/sdkgen.jsonic
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/sdkgen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"main": "dist/sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/sdkgen.d.ts",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@hapi/code": "^9.0.3",
|
|
44
44
|
"@types/js-yaml": "^4.0.9",
|
|
45
|
-
"@types/node": "25.
|
|
45
|
+
"@types/node": "25.5.0",
|
|
46
46
|
"json-schema-to-ts": "^3.1.1",
|
|
47
|
-
"memfs": "^4.56.
|
|
47
|
+
"memfs": "^4.56.11",
|
|
48
48
|
"typescript": "^5.9.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@redocly/openapi-core": ">=1 <2",
|
|
52
|
-
"@voxgig/util": ">=0",
|
|
53
|
-
"@voxgig/struct": ">=0",
|
|
54
52
|
"@voxgig/apidef": ">=3",
|
|
53
|
+
"@voxgig/struct": ">=0",
|
|
54
|
+
"@voxgig/util": ">=0",
|
|
55
55
|
"aontu": ">=0",
|
|
56
56
|
"jostraca": ">=0"
|
|
57
57
|
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
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
|
+
}
|
|
@@ -13,9 +13,9 @@ main: kit: target: ts: {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
deps: {
|
|
16
|
-
'dotenv': { active: true, version: '^
|
|
17
|
-
'typescript': { active: true, version: '^5.
|
|
18
|
-
'@types/node': { active: true, version: '^
|
|
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
|
|
|
@@ -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
|
+
}
|