@voxgig/sdkgen 0.44.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/ReadmeEntity.js +9 -153
- package/dist/cmp/ReadmeEntity.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js +9 -14
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +6 -4
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeOptions.js +9 -61
- package/dist/cmp/ReadmeOptions.js.map +1 -1
- package/dist/cmp/ReadmeRef.js +10 -1328
- package/dist/cmp/ReadmeRef.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -2
- package/dist/sdkgen.js +2 -1
- package/dist/sdkgen.js.map +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +9 -0
- package/dist/utility.js.map +1 -1
- package/package.json +3 -3
- package/project/.sdk/src/cmp/go/Config_go.ts +9 -4
- package/project/.sdk/src/cmp/go/Entity_go.ts +2 -2
- package/project/.sdk/src/cmp/go/Main_go.ts +8 -4
- package/project/.sdk/src/cmp/go/Package_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +138 -0
- package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +8 -5
- package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +18 -0
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +8 -5
- package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +58 -0
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +13 -9
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +354 -0
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +8 -6
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +222 -41
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +142 -60
- package/project/.sdk/src/cmp/go/Test_go.ts +2 -2
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +21 -4
- package/project/.sdk/src/cmp/js/Config_js.ts +18 -0
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +138 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +11 -6
- package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +18 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +6 -3
- package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +58 -0
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +6 -4
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +384 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +6 -4
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +23 -12
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +107 -74
- package/project/.sdk/src/cmp/js/fragment/Config.fragment.js +1 -5
- package/project/.sdk/src/cmp/lua/Config_lua.ts +9 -4
- package/project/.sdk/src/cmp/lua/Package_lua.ts +9 -2
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +138 -0
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +6 -3
- package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +18 -0
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +6 -3
- package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +58 -0
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +6 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +360 -0
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +6 -4
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +172 -29
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +120 -52
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +20 -4
- package/project/.sdk/src/cmp/php/Config_php.ts +10 -8
- package/project/.sdk/src/cmp/php/Package_php.ts +7 -1
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +138 -0
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +6 -3
- package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +18 -0
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +6 -3
- package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +58 -0
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +6 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +358 -0
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +6 -4
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +171 -28
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +126 -55
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +17 -3
- package/project/.sdk/src/cmp/py/Config_py.ts +9 -4
- package/project/.sdk/src/cmp/py/Package_py.ts +8 -1
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +138 -0
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +6 -3
- package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +18 -0
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +6 -3
- package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +58 -0
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +9 -6
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +356 -0
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +9 -6
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +164 -27
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +125 -51
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +19 -4
- package/project/.sdk/src/cmp/rb/Config_rb.ts +9 -4
- package/project/.sdk/src/cmp/rb/Package_rb.ts +9 -2
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +138 -0
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +6 -3
- package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +18 -0
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +6 -3
- package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +58 -0
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +6 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +361 -0
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +6 -4
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +172 -29
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +120 -52
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +19 -3
- package/project/.sdk/src/cmp/ts/Config_ts.ts +18 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +138 -0
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +11 -6
- package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +18 -0
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +9 -5
- package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +58 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +6 -4
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +384 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +6 -4
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +213 -42
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +168 -75
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +1 -5
- package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +8 -1
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +8 -2
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +21 -1
- package/project/.sdk/tm/go/feature/test_feature.go +51 -3
- package/project/.sdk/tm/go/test/runner_test.go +106 -6
- package/project/.sdk/tm/go/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/go/utility/fetcher.go +10 -0
- package/project/.sdk/tm/go/utility/make_url.go +12 -0
- package/project/.sdk/tm/go/utility/prepare_auth.go +15 -1
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +7 -1
- package/project/.sdk/tm/lua/feature/test_feature.lua +41 -3
- package/project/.sdk/tm/lua/test/runner.lua +74 -0
- package/project/.sdk/tm/lua/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +13 -0
- package/project/.sdk/tm/lua/utility/make_url.lua +16 -0
- package/project/.sdk/tm/lua/utility/prepare_auth.lua +9 -1
- package/project/.sdk/tm/php/feature/TestFeature.php +185 -43
- package/project/.sdk/tm/php/test/Runner.php +62 -0
- package/project/.sdk/tm/php/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/php/utility/Fetcher.php +132 -9
- package/project/.sdk/tm/php/utility/MakeUrl.php +16 -0
- package/project/.sdk/tm/php/utility/PrepareAuth.php +11 -1
- package/project/.sdk/tm/py/feature/test_feature.py +35 -3
- package/project/.sdk/tm/py/test/runner.py +60 -0
- package/project/.sdk/tm/py/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/py/utility/fetcher.py +13 -0
- package/project/.sdk/tm/py/utility/make_url.py +13 -0
- package/project/.sdk/tm/py/utility/prepare_auth.py +10 -1
- package/project/.sdk/tm/rb/feature/test_feature.rb +36 -3
- package/project/.sdk/tm/rb/test/runner.rb +46 -0
- package/project/.sdk/tm/rb/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/rb/utility/fetcher.rb +49 -28
- package/project/.sdk/tm/rb/utility/make_url.rb +16 -0
- package/project/.sdk/tm/rb/utility/prepare_auth.rb +8 -1
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +7 -8
- package/project/.sdk/tm/ts/src/utility/PrepareAuthUtility.ts +7 -1
- package/project/.sdk/tm/ts/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/ts/test/utility.ts +120 -2
- package/src/cmp/ReadmeEntity.ts +11 -178
- package/src/cmp/ReadmeIntro.ts +11 -25
- package/src/cmp/ReadmeModel.ts +7 -5
- package/src/cmp/ReadmeOptions.ts +12 -74
- package/src/cmp/ReadmeRef.ts +11 -1372
- package/src/sdkgen.ts +2 -1
- package/src/utility.ts +12 -0
- /package/project/.sdk/tm/go/utility/{make_target.go → make_point.go} +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
|
|
2
|
+
import { cmp, each, Content, File, isAuthActive } from '@voxgig/sdkgen'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
KIT,
|
|
6
|
+
getModelPath,
|
|
7
|
+
} from '@voxgig/apidef'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const OP_SIGNATURES: Record<string, { sig: string, returns: string, desc: string }> = {
|
|
11
|
+
load: {
|
|
12
|
+
sig: 'Load(reqmatch, ctrl map[string]any) (any, error)',
|
|
13
|
+
returns: '(any, error)',
|
|
14
|
+
desc: 'Load a single entity matching the given criteria.',
|
|
15
|
+
},
|
|
16
|
+
list: {
|
|
17
|
+
sig: 'List(reqmatch, ctrl map[string]any) (any, error)',
|
|
18
|
+
returns: '(any, error)',
|
|
19
|
+
desc: 'List entities matching the given criteria. Returns an array.',
|
|
20
|
+
},
|
|
21
|
+
create: {
|
|
22
|
+
sig: 'Create(reqdata, ctrl map[string]any) (any, error)',
|
|
23
|
+
returns: '(any, error)',
|
|
24
|
+
desc: 'Create a new entity with the given data.',
|
|
25
|
+
},
|
|
26
|
+
update: {
|
|
27
|
+
sig: 'Update(reqdata, ctrl map[string]any) (any, error)',
|
|
28
|
+
returns: '(any, error)',
|
|
29
|
+
desc: 'Update an existing entity. The data must include the entity `id`.',
|
|
30
|
+
},
|
|
31
|
+
remove: {
|
|
32
|
+
sig: 'Remove(reqmatch, ctrl map[string]any) (any, error)',
|
|
33
|
+
returns: '(any, error)',
|
|
34
|
+
desc: 'Remove the entity matching the given criteria.',
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const ReadmeRef = cmp(function ReadmeRef(props: any) {
|
|
40
|
+
const { target } = props
|
|
41
|
+
const { model } = props.ctx$
|
|
42
|
+
|
|
43
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
44
|
+
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
45
|
+
|
|
46
|
+
const publishedEntities = each(entity).filter((e: any) => e.active !== false)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
File({ name: 'REFERENCE.md' }, () => {
|
|
50
|
+
|
|
51
|
+
Content(`# ${model.Name} ${target.title} SDK Reference
|
|
52
|
+
|
|
53
|
+
Complete API reference for the ${model.Name} ${target.title} SDK.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## ${model.Name}SDK
|
|
57
|
+
|
|
58
|
+
### Constructor
|
|
59
|
+
|
|
60
|
+
`)
|
|
61
|
+
|
|
62
|
+
Content(`\`\`\`go
|
|
63
|
+
func New${model.const.Name}SDK(options map[string]any) *${model.const.Name}SDK
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
Create a new SDK client instance.
|
|
67
|
+
|
|
68
|
+
**Parameters:**
|
|
69
|
+
|
|
70
|
+
| Name | Type | Description |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| \`options\` | \`map[string]any\` | SDK configuration options. |
|
|
73
|
+
| \`options["apikey"]\` | \`string\` | API key for authentication. |
|
|
74
|
+
| \`options["base"]\` | \`string\` | Base URL for API requests. |
|
|
75
|
+
| \`options["prefix"]\` | \`string\` | URL prefix appended after base. |
|
|
76
|
+
| \`options["suffix"]\` | \`string\` | URL suffix appended after path. |
|
|
77
|
+
| \`options["headers"]\` | \`map[string]any\` | Custom headers for all requests. |
|
|
78
|
+
| \`options["feature"]\` | \`map[string]any\` | Feature configuration. |
|
|
79
|
+
| \`options["system"]\` | \`map[string]any\` | System overrides (e.g. custom fetch). |
|
|
80
|
+
|
|
81
|
+
`)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
Content(`
|
|
85
|
+
### Static Methods
|
|
86
|
+
|
|
87
|
+
`)
|
|
88
|
+
|
|
89
|
+
Content(`#### \`TestSDK(testopts, sdkopts map[string]any) *${model.const.Name}SDK\`
|
|
90
|
+
|
|
91
|
+
Create a test client with mock features active. Both arguments may be \`nil\`.
|
|
92
|
+
|
|
93
|
+
\`\`\`go
|
|
94
|
+
client := sdk.TestSDK(nil, nil)
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
`)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Content(`
|
|
101
|
+
### Instance Methods
|
|
102
|
+
|
|
103
|
+
`)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// Entity factory methods
|
|
107
|
+
publishedEntities.map((ent: any) => {
|
|
108
|
+
Content(`#### \`${ent.Name}(data map[string]any) ${model.const.Name}Entity\`
|
|
109
|
+
|
|
110
|
+
Create a new \`${ent.Name}\` entity instance. Pass \`nil\` for no initial data.
|
|
111
|
+
|
|
112
|
+
`)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
Content(`#### \`OptionsMap() map[string]any\`
|
|
117
|
+
|
|
118
|
+
Return a deep copy of the current SDK options.
|
|
119
|
+
|
|
120
|
+
#### \`GetUtility() *Utility\`
|
|
121
|
+
|
|
122
|
+
Return a copy of the SDK utility object.
|
|
123
|
+
|
|
124
|
+
#### \`Direct(fetchargs map[string]any) (map[string]any, error)\`
|
|
125
|
+
|
|
126
|
+
Make a direct HTTP request to any API endpoint.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
|
|
130
|
+
| Name | Type | Description |
|
|
131
|
+
| --- | --- | --- |
|
|
132
|
+
| \`fetchargs["path"]\` | \`string\` | URL path with optional \`{param}\` placeholders. |
|
|
133
|
+
| \`fetchargs["method"]\` | \`string\` | HTTP method (default: \`"GET"\`). |
|
|
134
|
+
| \`fetchargs["params"]\` | \`map[string]any\` | Path parameter values for \`{param}\` substitution. |
|
|
135
|
+
| \`fetchargs["query"]\` | \`map[string]any\` | Query string parameters. |
|
|
136
|
+
| \`fetchargs["headers"]\` | \`map[string]any\` | Request headers (merged with defaults). |
|
|
137
|
+
| \`fetchargs["body"]\` | \`any\` | Request body (maps are JSON-serialized). |
|
|
138
|
+
| \`fetchargs["ctrl"]\` | \`map[string]any\` | Control options (e.g. \`map[string]any{"explain": true}\`). |
|
|
139
|
+
|
|
140
|
+
**Returns:** \`(map[string]any, error)\`
|
|
141
|
+
|
|
142
|
+
#### \`Prepare(fetchargs map[string]any) (map[string]any, error)\`
|
|
143
|
+
|
|
144
|
+
Prepare a fetch definition without sending the request. Accepts the
|
|
145
|
+
same parameters as \`Direct()\`.
|
|
146
|
+
|
|
147
|
+
**Returns:** \`(map[string]any, error)\`
|
|
148
|
+
|
|
149
|
+
`)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
// Entity reference sections
|
|
153
|
+
publishedEntities.map((ent: any) => {
|
|
154
|
+
const opnames = Object.keys(ent.op || {})
|
|
155
|
+
const fields = ent.fields || []
|
|
156
|
+
|
|
157
|
+
Content(`
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## ${ent.Name}Entity
|
|
161
|
+
|
|
162
|
+
`)
|
|
163
|
+
|
|
164
|
+
if (ent.short) {
|
|
165
|
+
Content(`${ent.short}
|
|
166
|
+
|
|
167
|
+
`)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
Content(`\`\`\`go
|
|
171
|
+
${ent.name} := client.${ent.Name}(nil)
|
|
172
|
+
\`\`\`
|
|
173
|
+
|
|
174
|
+
`)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
// Field schema
|
|
178
|
+
if (fields.length > 0) {
|
|
179
|
+
Content(`### Fields
|
|
180
|
+
|
|
181
|
+
| Field | Type | Required | Description |
|
|
182
|
+
| --- | --- | --- | --- |
|
|
183
|
+
`)
|
|
184
|
+
each(fields, (field: any) => {
|
|
185
|
+
const req = field.req ? 'Yes' : 'No'
|
|
186
|
+
const desc = field.short || ''
|
|
187
|
+
Content(`| \`${field.name}\` | \`${field.type || 'any'}\` | ${req} | ${desc} |
|
|
188
|
+
`)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
Content(`
|
|
192
|
+
`)
|
|
193
|
+
|
|
194
|
+
// Field operations breakdown
|
|
195
|
+
const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
|
|
196
|
+
if (hasFieldOps) {
|
|
197
|
+
Content(`### Field Usage by Operation
|
|
198
|
+
|
|
199
|
+
| Field | load | list | create | update | remove |
|
|
200
|
+
| --- | --- | --- | --- | --- | --- |
|
|
201
|
+
`)
|
|
202
|
+
each(fields, (field: any) => {
|
|
203
|
+
const fops = field.op || {}
|
|
204
|
+
const cols = ['load', 'list', 'create', 'update', 'remove'].map((op: string) => {
|
|
205
|
+
if (!opnames.includes(op)) return '-'
|
|
206
|
+
const fop = fops[op]
|
|
207
|
+
if (null == fop) return '-'
|
|
208
|
+
if (fop.active === false) return '-'
|
|
209
|
+
return 'Yes'
|
|
210
|
+
})
|
|
211
|
+
Content(`| \`${field.name}\` | ${cols.join(' | ')} |
|
|
212
|
+
`)
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
Content(`
|
|
216
|
+
`)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
// Operation details
|
|
222
|
+
if (opnames.length > 0) {
|
|
223
|
+
Content(`### Operations
|
|
224
|
+
|
|
225
|
+
`)
|
|
226
|
+
|
|
227
|
+
opnames.map((opname: string) => {
|
|
228
|
+
const info = OP_SIGNATURES[opname]
|
|
229
|
+
if (!info) return
|
|
230
|
+
|
|
231
|
+
Content(`#### \`${info.sig}\`
|
|
232
|
+
|
|
233
|
+
${info.desc}
|
|
234
|
+
|
|
235
|
+
`)
|
|
236
|
+
|
|
237
|
+
// Show example
|
|
238
|
+
if ('load' === opname || 'remove' === opname) {
|
|
239
|
+
const goOpName = opname.charAt(0).toUpperCase() + opname.slice(1)
|
|
240
|
+
Content(`\`\`\`go
|
|
241
|
+
result, err := client.${ent.Name}(nil).${goOpName}(map[string]any{"id": "${ent.name}_id"}, nil)
|
|
242
|
+
\`\`\`
|
|
243
|
+
|
|
244
|
+
`)
|
|
245
|
+
}
|
|
246
|
+
else if ('list' === opname) {
|
|
247
|
+
Content(`\`\`\`go
|
|
248
|
+
results, err := client.${ent.Name}(nil).List(nil, nil)
|
|
249
|
+
\`\`\`
|
|
250
|
+
|
|
251
|
+
`)
|
|
252
|
+
}
|
|
253
|
+
else if ('create' === opname) {
|
|
254
|
+
Content(`\`\`\`go
|
|
255
|
+
result, err := client.${ent.Name}(nil).Create(map[string]any{
|
|
256
|
+
`)
|
|
257
|
+
each(fields, (field: any) => {
|
|
258
|
+
if ('id' !== field.name && field.req) {
|
|
259
|
+
Content(` "${field.name}": /* ${field.type || 'value'} */,
|
|
260
|
+
`)
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
Content(`}, nil)
|
|
264
|
+
\`\`\`
|
|
265
|
+
|
|
266
|
+
`)
|
|
267
|
+
}
|
|
268
|
+
else if ('update' === opname) {
|
|
269
|
+
Content(`\`\`\`go
|
|
270
|
+
result, err := client.${ent.Name}(nil).Update(map[string]any{
|
|
271
|
+
"id": "${ent.name}_id",
|
|
272
|
+
// Fields to update
|
|
273
|
+
}, nil)
|
|
274
|
+
\`\`\`
|
|
275
|
+
|
|
276
|
+
`)
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// Common methods
|
|
283
|
+
Content(`### Common Methods
|
|
284
|
+
|
|
285
|
+
#### \`Data(args ...any) any\`
|
|
286
|
+
|
|
287
|
+
Get or set the entity data. When called with data, sets the entity's
|
|
288
|
+
internal data and returns the current data. When called without
|
|
289
|
+
arguments, returns a copy of the current data.
|
|
290
|
+
|
|
291
|
+
#### \`Match(args ...any) any\`
|
|
292
|
+
|
|
293
|
+
Get or set the entity match criteria. Works the same as \`Data()\`.
|
|
294
|
+
|
|
295
|
+
#### \`Make() Entity\`
|
|
296
|
+
|
|
297
|
+
Create a new \`${ent.Name}Entity\` instance with the same client and
|
|
298
|
+
options.
|
|
299
|
+
|
|
300
|
+
#### \`GetName() string\`
|
|
301
|
+
|
|
302
|
+
Return the entity name.
|
|
303
|
+
|
|
304
|
+
`)
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
// Features section
|
|
309
|
+
const activeFeatures = each(feature).filter((f: any) => f.active)
|
|
310
|
+
if (activeFeatures.length > 0) {
|
|
311
|
+
Content(`
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Features
|
|
315
|
+
|
|
316
|
+
| Feature | Version | Description |
|
|
317
|
+
| --- | --- | --- |
|
|
318
|
+
`)
|
|
319
|
+
|
|
320
|
+
activeFeatures.map((f: any) => {
|
|
321
|
+
Content(`| \`${f.name}\` | ${f.version || '0.0.1'} | ${f.title || ''} |
|
|
322
|
+
`)
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
Content(`
|
|
326
|
+
|
|
327
|
+
Features are activated via the \`feature\` option:
|
|
328
|
+
|
|
329
|
+
`)
|
|
330
|
+
|
|
331
|
+
Content(`\`\`\`go
|
|
332
|
+
client := sdk.New${model.const.Name}SDK(map[string]any{
|
|
333
|
+
"feature": map[string]any{
|
|
334
|
+
`)
|
|
335
|
+
activeFeatures.map((f: any) => {
|
|
336
|
+
Content(` "${f.name}": map[string]any{"active": true},
|
|
337
|
+
`)
|
|
338
|
+
})
|
|
339
|
+
Content(` },
|
|
340
|
+
})
|
|
341
|
+
\`\`\`
|
|
342
|
+
|
|
343
|
+
`)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
export {
|
|
353
|
+
ReadmeRef
|
|
354
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -12,17 +12,19 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
12
12
|
const { target, ctx$: { model } } = props
|
|
13
13
|
|
|
14
14
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
|
-
|
|
16
|
-
const gomodule =
|
|
15
|
+
// Go module path == repo path on GitHub (org from model.origin).
|
|
16
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
17
17
|
|
|
18
18
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
19
19
|
|
|
20
|
+
const apikeyArg = isAuthActive(model)
|
|
21
|
+
? `\n "apikey": os.Getenv("${model.NAME}_APIKEY"),\n`
|
|
22
|
+
: ''
|
|
23
|
+
|
|
20
24
|
Content(`\`\`\`go
|
|
21
25
|
import sdk "${gomodule}"
|
|
22
26
|
|
|
23
|
-
client := sdk.New${model.const.Name}SDK(map[string]any{
|
|
24
|
-
"apikey": os.Getenv("${model.NAME}_APIKEY"),
|
|
25
|
-
})
|
|
27
|
+
client := sdk.New${model.const.Name}SDK(map[string]any{${apikeyArg}})
|
|
26
28
|
|
|
27
29
|
`)
|
|
28
30
|
|
|
@@ -12,8 +12,8 @@ const ReadmeTopTest = cmp(function ReadmeTopTest(props: any) {
|
|
|
12
12
|
const { target, ctx$: { model } } = props
|
|
13
13
|
|
|
14
14
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
|
-
|
|
16
|
-
const gomodule =
|
|
15
|
+
// Go module path == repo path on GitHub (org from model.origin).
|
|
16
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
17
17
|
|
|
18
18
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
19
19
|
|