@voxgig/sdkgen 0.43.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) 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 +1 -1
  19. package/project/.sdk/src/cmp/go/Config_go.ts +9 -4
  20. package/project/.sdk/src/cmp/go/Gitignore_go.ts +47 -0
  21. package/project/.sdk/src/cmp/go/Main_go.ts +3 -0
  22. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +138 -0
  23. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +6 -3
  24. package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +18 -0
  25. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +6 -3
  26. package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +58 -0
  27. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +11 -7
  28. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +354 -0
  29. package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +6 -4
  30. package/project/.sdk/src/cmp/go/TestDirect_go.ts +18 -8
  31. package/project/.sdk/src/cmp/go/TestEntity_go.ts +105 -54
  32. package/project/.sdk/src/cmp/js/Config_js.ts +18 -0
  33. package/project/.sdk/src/cmp/js/Gitignore_js.ts +35 -0
  34. package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
  35. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +138 -0
  36. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +11 -6
  37. package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +18 -0
  38. package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +6 -3
  39. package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +58 -0
  40. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +6 -4
  41. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +384 -0
  42. package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +6 -4
  43. package/project/.sdk/src/cmp/js/TestDirect_js.ts +23 -12
  44. package/project/.sdk/src/cmp/js/TestEntity_js.ts +107 -74
  45. package/project/.sdk/src/cmp/js/fragment/Config.fragment.js +1 -5
  46. package/project/.sdk/src/cmp/lua/Config_lua.ts +9 -4
  47. package/project/.sdk/src/cmp/lua/Gitignore_lua.ts +39 -0
  48. package/project/.sdk/src/cmp/lua/Main_lua.ts +3 -0
  49. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +138 -0
  50. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +6 -3
  51. package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +18 -0
  52. package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +6 -3
  53. package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +58 -0
  54. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +6 -4
  55. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +360 -0
  56. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +6 -4
  57. package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +18 -8
  58. package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +95 -51
  59. package/project/.sdk/src/cmp/php/Config_php.ts +10 -8
  60. package/project/.sdk/src/cmp/php/Gitignore_php.ts +33 -0
  61. package/project/.sdk/src/cmp/php/Main_php.ts +3 -0
  62. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +138 -0
  63. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +6 -3
  64. package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +18 -0
  65. package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +6 -3
  66. package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +58 -0
  67. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +6 -4
  68. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +358 -0
  69. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +6 -4
  70. package/project/.sdk/src/cmp/php/TestDirect_php.ts +18 -8
  71. package/project/.sdk/src/cmp/php/TestEntity_php.ts +101 -54
  72. package/project/.sdk/src/cmp/py/Config_py.ts +9 -4
  73. package/project/.sdk/src/cmp/py/Gitignore_py.ts +55 -0
  74. package/project/.sdk/src/cmp/py/Main_py.ts +3 -0
  75. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +138 -0
  76. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +6 -3
  77. package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +18 -0
  78. package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +6 -3
  79. package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +58 -0
  80. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +9 -6
  81. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +356 -0
  82. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +9 -6
  83. package/project/.sdk/src/cmp/py/TestDirect_py.ts +18 -8
  84. package/project/.sdk/src/cmp/py/TestEntity_py.ts +100 -50
  85. package/project/.sdk/src/cmp/rb/Config_rb.ts +9 -4
  86. package/project/.sdk/src/cmp/rb/Gitignore_rb.ts +38 -0
  87. package/project/.sdk/src/cmp/rb/Main_rb.ts +3 -0
  88. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +138 -0
  89. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +6 -3
  90. package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +18 -0
  91. package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +6 -3
  92. package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +58 -0
  93. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +6 -4
  94. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +361 -0
  95. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +6 -4
  96. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +18 -8
  97. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +95 -51
  98. package/project/.sdk/src/cmp/ts/Config_ts.ts +18 -0
  99. package/project/.sdk/src/cmp/ts/Gitignore_ts.ts +37 -0
  100. package/project/.sdk/src/cmp/ts/Main_ts.ts +3 -0
  101. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +138 -0
  102. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +11 -6
  103. package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +18 -0
  104. package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +9 -5
  105. package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +58 -0
  106. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +6 -4
  107. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +384 -0
  108. package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +6 -4
  109. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +68 -20
  110. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +109 -74
  111. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +1 -5
  112. package/project/.sdk/tm/go/utility/prepare_auth.go +15 -1
  113. package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +7 -1
  114. package/project/.sdk/tm/lua/utility/prepare_auth.lua +9 -1
  115. package/project/.sdk/tm/php/utility/PrepareAuth.php +11 -1
  116. package/project/.sdk/tm/py/utility/prepare_auth.py +10 -1
  117. package/project/.sdk/tm/rb/utility/prepare_auth.rb +8 -1
  118. package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +7 -8
  119. package/project/.sdk/tm/ts/src/utility/PrepareAuthUtility.ts +7 -1
  120. package/src/cmp/ReadmeEntity.ts +11 -178
  121. package/src/cmp/ReadmeIntro.ts +11 -25
  122. package/src/cmp/ReadmeModel.ts +7 -5
  123. package/src/cmp/ReadmeOptions.ts +12 -74
  124. package/src/cmp/ReadmeRef.ts +11 -1372
  125. package/src/sdkgen.ts +2 -1
  126. package/src/utility.ts +12 -0
  127. /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,
@@ -17,12 +17,14 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
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
 
@@ -1,5 +1,8 @@
1
1
 
2
2
  import {
3
+ Model,
4
+ ModelEntity,
5
+ nom,
3
6
  depluralize,
4
7
  } from '@voxgig/apidef'
5
8
 
@@ -8,6 +11,7 @@ import {
8
11
  File,
9
12
  cmp,
10
13
  snakify,
14
+ isAuthActive,
11
15
  } from '@voxgig/sdkgen'
12
16
 
13
17
 
@@ -55,13 +59,21 @@ function normalizePathParams(
55
59
 
56
60
  const TestDirect = cmp(function TestDirect(props: any) {
57
61
  const ctx$ = props.ctx$
58
- const model = ctx$.model
62
+ const model: Model = ctx$.model
59
63
 
60
64
  const target = props.target
61
- const entity = props.entity
65
+ const entity: ModelEntity = props.entity
62
66
  const gomodule = props.gomodule
63
67
 
64
- const PROJECTNAME = model.Name.toUpperCase().replace(/[^A-Z_]/g, '_')
68
+ const PROJECTNAME = nom(model, 'Name').toUpperCase().replace(/[^A-Z_]/g, '_')
69
+
70
+ const authActive = isAuthActive(model)
71
+ const apikeyEnvEntry = authActive
72
+ ? `\n\t\t"${PROJECTNAME}_APIKEY": "NONE",`
73
+ : ''
74
+ const apikeyLiveField = authActive
75
+ ? `\n\t\t\t"apikey": env["${PROJECTNAME}_APIKEY"],`
76
+ : ''
65
77
 
66
78
  const opnames = Object.keys(entity.op)
67
79
  const hasLoad = opnames.includes('load')
@@ -85,7 +97,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
85
97
  const listParams = listPoint?.args?.params || []
86
98
 
87
99
  // Build the ENTID env var name for this entity
88
- const entidEnvVar = `${PROJECTNAME}_TEST_${entity.Name.toUpperCase().replace(/[^A-Z_]/g, '_')}_ENTID`
100
+ const entidEnvVar = `${PROJECTNAME}_TEST_${nom(entity, 'NAME').replace(/[^A-Z_]/g, '_')}_ENTID`
89
101
 
90
102
  File({ name: entity.name + '_direct_test.' + target.ext }, () => {
91
103
 
@@ -360,15 +372,13 @@ func ${entity.name}DirectSetup(mockres any) *${entity.name}DirectSetupResult {
360
372
 
361
373
  env := envOverride(map[string]any{
362
374
  "${entidEnvVar}": map[string]any{},
363
- "${PROJECTNAME}_TEST_LIVE": "FALSE",
364
- "${PROJECTNAME}_APIKEY": "NONE",
375
+ "${PROJECTNAME}_TEST_LIVE": "FALSE",${apikeyEnvEntry}
365
376
  })
366
377
 
367
378
  live := env["${PROJECTNAME}_TEST_LIVE"] == "TRUE"
368
379
 
369
380
  if live {
370
- mergedOpts := map[string]any{
371
- "apikey": env["${PROJECTNAME}_APIKEY"],
381
+ mergedOpts := map[string]any{${apikeyLiveField}
372
382
  }
373
383
  client := sdk.New${model.const.Name}SDK(mergedOpts)
374
384