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