@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
@@ -1,1383 +1,22 @@
1
1
 
2
- import { cmp, each, Content, File } from 'jostraca'
3
-
4
- import {
5
- KIT,
6
- getModelPath
7
- } from '../types'
2
+ import { cmp } from 'jostraca'
8
3
 
9
4
  import { requirePath } from '../utility'
10
5
 
11
6
 
12
- const OP_SIGNATURES_TS: Record<string, { sig: string, returns: string, desc: string }> = {
13
- load: {
14
- sig: 'load(match: object, ctrl?: object)',
15
- returns: 'Promise<object>',
16
- desc: 'Load a single entity matching the given criteria.',
17
- },
18
- list: {
19
- sig: 'list(match: object, ctrl?: object)',
20
- returns: 'Promise<object[]>',
21
- desc: 'List entities matching the given criteria. Returns an array.',
22
- },
23
- create: {
24
- sig: 'create(data: object, ctrl?: object)',
25
- returns: 'Promise<object>',
26
- desc: 'Create a new entity with the given data.',
27
- },
28
- update: {
29
- sig: 'update(data: object, ctrl?: object)',
30
- returns: 'Promise<object>',
31
- desc: 'Update an existing entity. The data must include the entity `id`.',
32
- },
33
- remove: {
34
- sig: 'remove(match: object, ctrl?: object)',
35
- returns: 'Promise<void>',
36
- desc: 'Remove the entity matching the given criteria.',
37
- },
38
- }
39
-
40
- const OP_SIGNATURES_LUA: Record<string, { sig: string, returns: string, desc: string }> = {
41
- load: {
42
- sig: 'load(reqmatch, ctrl) -> any, err',
43
- returns: 'any, err',
44
- desc: 'Load a single entity matching the given criteria.',
45
- },
46
- list: {
47
- sig: 'list(reqmatch, ctrl) -> any, err',
48
- returns: 'any, err',
49
- desc: 'List entities matching the given criteria. Returns an array.',
50
- },
51
- create: {
52
- sig: 'create(reqdata, ctrl) -> any, err',
53
- returns: 'any, err',
54
- desc: 'Create a new entity with the given data.',
55
- },
56
- update: {
57
- sig: 'update(reqdata, ctrl) -> any, err',
58
- returns: 'any, err',
59
- desc: 'Update an existing entity. The data must include the entity `id`.',
60
- },
61
- remove: {
62
- sig: 'remove(reqmatch, ctrl) -> any, err',
63
- returns: 'any, err',
64
- desc: 'Remove the entity matching the given criteria.',
65
- },
66
- }
67
-
68
- const OP_SIGNATURES_RB: Record<string, { sig: string, returns: string, desc: string }> = {
69
- load: {
70
- sig: 'load(reqmatch, ctrl = nil) -> result, err',
71
- returns: 'result, err',
72
- desc: 'Load a single entity matching the given criteria.',
73
- },
74
- list: {
75
- sig: 'list(reqmatch, ctrl = nil) -> result, err',
76
- returns: 'result, err',
77
- desc: 'List entities matching the given criteria. Returns an array.',
78
- },
79
- create: {
80
- sig: 'create(reqdata, ctrl = nil) -> result, err',
81
- returns: 'result, err',
82
- desc: 'Create a new entity with the given data.',
83
- },
84
- update: {
85
- sig: 'update(reqdata, ctrl = nil) -> result, err',
86
- returns: 'result, err',
87
- desc: 'Update an existing entity. The data must include the entity `id`.',
88
- },
89
- remove: {
90
- sig: 'remove(reqmatch, ctrl = nil) -> result, err',
91
- returns: 'result, err',
92
- desc: 'Remove the entity matching the given criteria.',
93
- },
94
- }
95
-
96
- const OP_SIGNATURES_PY: Record<string, { sig: string, returns: string, desc: string }> = {
97
- load: {
98
- sig: 'load(reqmatch, ctrl=None) -> tuple',
99
- returns: '(result, err)',
100
- desc: 'Load a single entity matching the given criteria.',
101
- },
102
- list: {
103
- sig: 'list(reqmatch, ctrl=None) -> tuple',
104
- returns: '(result, err)',
105
- desc: 'List entities matching the given criteria. Returns an array.',
106
- },
107
- create: {
108
- sig: 'create(reqdata, ctrl=None) -> tuple',
109
- returns: '(result, err)',
110
- desc: 'Create a new entity with the given data.',
111
- },
112
- update: {
113
- sig: 'update(reqdata, ctrl=None) -> tuple',
114
- returns: '(result, err)',
115
- desc: 'Update an existing entity. The data must include the entity `id`.',
116
- },
117
- remove: {
118
- sig: 'remove(reqmatch, ctrl=None) -> tuple',
119
- returns: '(result, err)',
120
- desc: 'Remove the entity matching the given criteria.',
121
- },
122
- }
123
-
124
- const OP_SIGNATURES_PHP: Record<string, { sig: string, returns: string, desc: string }> = {
125
- load: {
126
- sig: 'load(array $reqmatch, ?array $ctrl = null): array',
127
- returns: 'array [$result, $err]',
128
- desc: 'Load a single entity matching the given criteria.',
129
- },
130
- list: {
131
- sig: 'list(array $reqmatch, ?array $ctrl = null): array',
132
- returns: 'array [$result, $err]',
133
- desc: 'List entities matching the given criteria. Returns an array.',
134
- },
135
- create: {
136
- sig: 'create(array $reqdata, ?array $ctrl = null): array',
137
- returns: 'array [$result, $err]',
138
- desc: 'Create a new entity with the given data.',
139
- },
140
- update: {
141
- sig: 'update(array $reqdata, ?array $ctrl = null): array',
142
- returns: 'array [$result, $err]',
143
- desc: 'Update an existing entity. The data must include the entity `id`.',
144
- },
145
- remove: {
146
- sig: 'remove(array $reqmatch, ?array $ctrl = null): array',
147
- returns: 'array [$result, $err]',
148
- desc: 'Remove the entity matching the given criteria.',
149
- },
150
- }
151
-
152
- const OP_SIGNATURES_GO: Record<string, { sig: string, returns: string, desc: string }> = {
153
- load: {
154
- sig: 'Load(reqmatch, ctrl map[string]any) (any, error)',
155
- returns: '(any, error)',
156
- desc: 'Load a single entity matching the given criteria.',
157
- },
158
- list: {
159
- sig: 'List(reqmatch, ctrl map[string]any) (any, error)',
160
- returns: '(any, error)',
161
- desc: 'List entities matching the given criteria. Returns an array.',
162
- },
163
- create: {
164
- sig: 'Create(reqdata, ctrl map[string]any) (any, error)',
165
- returns: '(any, error)',
166
- desc: 'Create a new entity with the given data.',
167
- },
168
- update: {
169
- sig: 'Update(reqdata, ctrl map[string]any) (any, error)',
170
- returns: '(any, error)',
171
- desc: 'Update an existing entity. The data must include the entity `id`.',
172
- },
173
- remove: {
174
- sig: 'Remove(reqmatch, ctrl map[string]any) (any, error)',
175
- returns: '(any, error)',
176
- desc: 'Remove the entity matching the given criteria.',
177
- },
178
- }
179
-
180
-
7
+ // Per-language REFERENCE.md generator lives in
8
+ // `project/.sdk/src/cmp/<lang>/ReadmeRef_<lang>.ts`. Each language emits
9
+ // its own constructor signature, op spelling, and code-block fence — a
10
+ // shared template would have to inline-switch on every line.
181
11
  const ReadmeRef = cmp(function ReadmeRef(props: any) {
182
- const { target } = props
183
- const { model } = props.ctx$
184
-
185
- const entity = getModelPath(model, `main.${KIT}.entity`)
186
- const feature = getModelPath(model, `main.${KIT}.feature`)
187
-
188
- const publishedEntities = each(entity).filter((e: any) => e.active !== false)
189
-
190
- const isGo = target.name === 'go'
191
- const isLua = target.name === 'lua'
192
- const isRb = target.name === 'rb'
193
- const isPhp = target.name === 'php'
194
- const isPy = target.name === 'py'
195
- const lang = isGo ? 'go' : isLua ? 'lua' : isRb ? 'rb' : isPhp ? 'php' : isPy ? 'py' : 'ts'
196
- const OP_SIGNATURES = isGo ? OP_SIGNATURES_GO : isLua ? OP_SIGNATURES_LUA : isRb ? OP_SIGNATURES_RB : isPhp ? OP_SIGNATURES_PHP : isPy ? OP_SIGNATURES_PY : OP_SIGNATURES_TS
197
-
198
- File({ name: 'REFERENCE.md' }, () => {
199
-
200
- Content(`# ${model.Name} ${target.title} SDK Reference
201
-
202
- Complete API reference for the ${model.Name} ${target.title} SDK.
203
-
204
-
205
- ## ${model.Name}SDK
206
-
207
- ### Constructor
208
-
209
- `)
210
-
211
- if (isPy) {
212
- Content(`\`\`\`python
213
- from ${model.name}_sdk import ${model.const.Name}SDK
214
-
215
- client = ${model.const.Name}SDK(options)
216
- \`\`\`
217
-
218
- Create a new SDK client instance.
219
-
220
- **Parameters:**
221
-
222
- | Name | Type | Description |
223
- | --- | --- | --- |
224
- | \`options\` | \`dict\` | SDK configuration options. |
225
- | \`options["apikey"]\` | \`str\` | API key for authentication. |
226
- | \`options["base"]\` | \`str\` | Base URL for API requests. |
227
- | \`options["prefix"]\` | \`str\` | URL prefix appended after base. |
228
- | \`options["suffix"]\` | \`str\` | URL suffix appended after path. |
229
- | \`options["headers"]\` | \`dict\` | Custom headers for all requests. |
230
- | \`options["feature"]\` | \`dict\` | Feature configuration. |
231
- | \`options["system"]\` | \`dict\` | System overrides (e.g. custom fetch). |
232
-
233
- `)
234
- }
235
- else if (isPhp) {
236
- Content(`\`\`\`php
237
- require_once __DIR__ . '/${model.name}_sdk.php';
238
-
239
- $client = new ${model.const.Name}SDK($options);
240
- \`\`\`
241
-
242
- Create a new SDK client instance.
243
-
244
- **Parameters:**
245
-
246
- | Name | Type | Description |
247
- | --- | --- | --- |
248
- | \`$options\` | \`array\` | SDK configuration options. |
249
- | \`$options["apikey"]\` | \`string\` | API key for authentication. |
250
- | \`$options["base"]\` | \`string\` | Base URL for API requests. |
251
- | \`$options["prefix"]\` | \`string\` | URL prefix appended after base. |
252
- | \`$options["suffix"]\` | \`string\` | URL suffix appended after path. |
253
- | \`$options["headers"]\` | \`array\` | Custom headers for all requests. |
254
- | \`$options["feature"]\` | \`array\` | Feature configuration. |
255
- | \`$options["system"]\` | \`array\` | System overrides (e.g. custom fetch). |
256
-
257
- `)
258
- }
259
- else if (isRb) {
260
- Content(`\`\`\`ruby
261
- require_relative '${model.name}_sdk'
262
-
263
- client = ${model.const.Name}SDK.new(options)
264
- \`\`\`
265
-
266
- Create a new SDK client instance.
267
-
268
- **Parameters:**
269
-
270
- | Name | Type | Description |
271
- | --- | --- | --- |
272
- | \`options\` | \`Hash\` | SDK configuration options. |
273
- | \`options["apikey"]\` | \`String\` | API key for authentication. |
274
- | \`options["base"]\` | \`String\` | Base URL for API requests. |
275
- | \`options["prefix"]\` | \`String\` | URL prefix appended after base. |
276
- | \`options["suffix"]\` | \`String\` | URL suffix appended after path. |
277
- | \`options["headers"]\` | \`Hash\` | Custom headers for all requests. |
278
- | \`options["feature"]\` | \`Hash\` | Feature configuration. |
279
- | \`options["system"]\` | \`Hash\` | System overrides (e.g. custom fetch). |
280
-
281
- `)
282
- }
283
- else if (isLua) {
284
- Content(`\`\`\`lua
285
- local sdk = require("${model.name}_sdk")
286
- local client = sdk.new(options)
287
- \`\`\`
288
-
289
- Create a new SDK client instance.
290
-
291
- **Parameters:**
292
-
293
- | Name | Type | Description |
294
- | --- | --- | --- |
295
- | \`options\` | \`table\` | SDK configuration options. |
296
- | \`options.apikey\` | \`string\` | API key for authentication. |
297
- | \`options.base\` | \`string\` | Base URL for API requests. |
298
- | \`options.prefix\` | \`string\` | URL prefix appended after base. |
299
- | \`options.suffix\` | \`string\` | URL suffix appended after path. |
300
- | \`options.headers\` | \`table\` | Custom headers for all requests. |
301
- | \`options.feature\` | \`table\` | Feature configuration. |
302
- | \`options.system\` | \`table\` | System overrides (e.g. custom fetch). |
303
-
304
- `)
305
- }
306
- else if (isGo) {
307
- Content(`\`\`\`go
308
- func New${model.const.Name}SDK(options map[string]any) *${model.const.Name}SDK
309
- \`\`\`
310
-
311
- Create a new SDK client instance.
312
-
313
- **Parameters:**
314
-
315
- | Name | Type | Description |
316
- | --- | --- | --- |
317
- | \`options\` | \`map[string]any\` | SDK configuration options. |
318
- | \`options["apikey"]\` | \`string\` | API key for authentication. |
319
- | \`options["base"]\` | \`string\` | Base URL for API requests. |
320
- | \`options["prefix"]\` | \`string\` | URL prefix appended after base. |
321
- | \`options["suffix"]\` | \`string\` | URL suffix appended after path. |
322
- | \`options["headers"]\` | \`map[string]any\` | Custom headers for all requests. |
323
- | \`options["feature"]\` | \`map[string]any\` | Feature configuration. |
324
- | \`options["system"]\` | \`map[string]any\` | System overrides (e.g. custom fetch). |
325
-
326
- `)
327
- }
328
- else {
329
- Content(`\`\`\`ts
330
- new ${model.Name}SDK(options?: object)
331
- \`\`\`
332
-
333
- Create a new SDK client instance.
334
-
335
- **Parameters:**
336
-
337
- | Name | Type | Description |
338
- | --- | --- | --- |
339
- | \`options\` | \`object\` | SDK configuration options. |
340
- | \`options.apikey\` | \`string\` | API key for authentication. |
341
- | \`options.base\` | \`string\` | Base URL for API requests. |
342
- | \`options.prefix\` | \`string\` | URL prefix appended after base. |
343
- | \`options.suffix\` | \`string\` | URL suffix appended after path. |
344
- | \`options.headers\` | \`object\` | Custom headers for all requests. |
345
- | \`options.feature\` | \`object\` | Feature configuration. |
346
- | \`options.system\` | \`object\` | System overrides (e.g. custom fetch). |
347
-
348
- `)
349
- }
350
-
351
-
352
- Content(`
353
- ### Static Methods
354
-
355
- `)
356
-
357
- if (isPy) {
358
- Content(`#### \`${model.const.Name}SDK.test(testopts=None, sdkopts=None)\`
359
-
360
- Create a test client with mock features active. Both arguments may be \`None\`.
361
-
362
- \`\`\`python
363
- client = ${model.const.Name}SDK.test()
364
- \`\`\`
365
-
366
- `)
367
- }
368
- else if (isPhp) {
369
- Content(`#### \`${model.const.Name}SDK::test($testopts = null, $sdkopts = null)\`
370
-
371
- Create a test client with mock features active. Both arguments may be \`null\`.
372
-
373
- \`\`\`php
374
- $client = ${model.const.Name}SDK::test();
375
- \`\`\`
376
-
377
- `)
378
- }
379
- else if (isRb) {
380
- Content(`#### \`${model.const.Name}SDK.test(testopts = nil, sdkopts = nil)\`
381
-
382
- Create a test client with mock features active. Both arguments may be \`nil\`.
383
-
384
- \`\`\`ruby
385
- client = ${model.const.Name}SDK.test
386
- \`\`\`
387
-
388
- `)
389
- }
390
- else if (isLua) {
391
- Content(`#### \`sdk.test(testopts, sdkopts)\`
392
-
393
- Create a test client with mock features active. Both arguments may be \`nil\`.
394
-
395
- \`\`\`lua
396
- local client = sdk.test(nil, nil)
397
- \`\`\`
398
-
399
- `)
400
- }
401
- else if (isGo) {
402
- Content(`#### \`TestSDK(testopts, sdkopts map[string]any) *${model.const.Name}SDK\`
403
-
404
- Create a test client with mock features active. Both arguments may be \`nil\`.
405
-
406
- \`\`\`go
407
- client := sdk.TestSDK(nil, nil)
408
- \`\`\`
409
-
410
- `)
411
- }
412
- else {
413
- Content(`#### \`${model.Name}SDK.test(testopts?, sdkopts?)\`
414
-
415
- Create a test client with mock features active.
416
-
417
- \`\`\`ts
418
- const client = ${model.Name}SDK.test()
419
- \`\`\`
420
-
421
- **Parameters:**
422
-
423
- | Name | Type | Description |
424
- | --- | --- | --- |
425
- | \`testopts\` | \`object\` | Test feature options. |
426
- | \`sdkopts\` | \`object\` | Additional SDK options merged with test defaults. |
427
-
428
- **Returns:** \`${model.Name}SDK\` instance in test mode.
429
-
430
- `)
431
- }
432
-
433
-
434
- Content(`
435
- ### Instance Methods
436
-
437
- `)
438
-
439
-
440
- // Entity factory methods
441
- publishedEntities.map((ent: any) => {
442
- if (isPy) {
443
- Content(`#### \`${ent.Name}(data=None)\`
444
-
445
- Create a new \`${ent.Name}Entity\` instance. Pass \`None\` for no initial data.
446
-
447
- `)
448
- }
449
- else if (isPhp) {
450
- Content(`#### \`${ent.Name}($data = null)\`
451
-
452
- Create a new \`${ent.Name}Entity\` instance. Pass \`null\` for no initial data.
453
-
454
- `)
455
- }
456
- else if (isRb) {
457
- Content(`#### \`${ent.Name}(data = nil)\`
458
-
459
- Create a new \`${ent.Name}\` entity instance. Pass \`nil\` for no initial data.
460
-
461
- `)
462
- }
463
- else if (isLua) {
464
- Content(`#### \`${ent.Name}(data)\`
465
-
466
- Create a new \`${ent.Name}\` entity instance. Pass \`nil\` for no initial data.
467
-
468
- `)
469
- }
470
- else if (isGo) {
471
- Content(`#### \`${ent.Name}(data map[string]any) ${model.const.Name}Entity\`
472
-
473
- Create a new \`${ent.Name}\` entity instance. Pass \`nil\` for no initial data.
474
-
475
- `)
476
- }
477
- else {
478
- Content(`#### \`${ent.Name}(data?: object)\`
479
-
480
- Create a new \`${ent.Name}\` entity instance.
481
-
482
- **Parameters:**
483
-
484
- | Name | Type | Description |
485
- | --- | --- | --- |
486
- | \`data\` | \`object\` | Initial entity data. |
487
-
488
- **Returns:** \`${ent.Name}Entity\` instance.
489
-
490
- `)
491
- }
492
- })
493
-
494
-
495
- if (isPy) {
496
- Content(`#### \`options_map() -> dict\`
497
-
498
- Return a deep copy of the current SDK options.
499
-
500
- #### \`get_utility() -> Utility\`
501
-
502
- Return a copy of the SDK utility object.
503
-
504
- #### \`direct(fetchargs=None) -> tuple\`
505
-
506
- Make a direct HTTP request to any API endpoint. Returns \`(result, err)\`.
507
-
508
- **Parameters:**
509
-
510
- | Name | Type | Description |
511
- | --- | --- | --- |
512
- | \`fetchargs["path"]\` | \`str\` | URL path with optional \`{param}\` placeholders. |
513
- | \`fetchargs["method"]\` | \`str\` | HTTP method (default: \`"GET"\`). |
514
- | \`fetchargs["params"]\` | \`dict\` | Path parameter values. |
515
- | \`fetchargs["query"]\` | \`dict\` | Query string parameters. |
516
- | \`fetchargs["headers"]\` | \`dict\` | Request headers (merged with defaults). |
517
- | \`fetchargs["body"]\` | \`any\` | Request body (dicts are JSON-serialized). |
518
-
519
- **Returns:** \`(result_dict, err)\`
520
-
521
- #### \`prepare(fetchargs=None) -> tuple\`
522
-
523
- Prepare a fetch definition without sending. Returns \`(fetchdef, err)\`.
524
-
525
- `)
526
- }
527
- else if (isPhp) {
528
- Content(`#### \`optionsMap(): array\`
529
-
530
- Return a deep copy of the current SDK options.
531
-
532
- #### \`getUtility(): ProjectNameUtility\`
533
-
534
- Return a copy of the SDK utility object.
535
-
536
- #### \`direct(array $fetchargs = []): array\`
537
-
538
- Make a direct HTTP request to any API endpoint. Returns \`[$result, $err]\`.
539
-
540
- **Parameters:**
541
-
542
- | Name | Type | Description |
543
- | --- | --- | --- |
544
- | \`$fetchargs["path"]\` | \`string\` | URL path with optional \`{param}\` placeholders. |
545
- | \`$fetchargs["method"]\` | \`string\` | HTTP method (default: \`"GET"\`). |
546
- | \`$fetchargs["params"]\` | \`array\` | Path parameter values for \`{param}\` substitution. |
547
- | \`$fetchargs["query"]\` | \`array\` | Query string parameters. |
548
- | \`$fetchargs["headers"]\` | \`array\` | Request headers (merged with defaults). |
549
- | \`$fetchargs["body"]\` | \`mixed\` | Request body (arrays are JSON-serialized). |
550
- | \`$fetchargs["ctrl"]\` | \`array\` | Control options. |
551
-
552
- **Returns:** \`array [$result, $err]\`
553
-
554
- #### \`prepare(array $fetchargs = []): array\`
555
-
556
- Prepare a fetch definition without sending the request. Returns \`[$fetchdef, $err]\`.
557
-
558
- `)
559
- }
560
- else if (isRb) {
561
- Content(`#### \`options_map -> Hash\`
562
-
563
- Return a deep copy of the current SDK options.
564
-
565
- #### \`get_utility -> Utility\`
566
-
567
- Return a copy of the SDK utility object.
568
-
569
- #### \`direct(fetchargs = {}) -> Hash, err\`
570
-
571
- Make a direct HTTP request to any API endpoint.
572
-
573
- **Parameters:**
574
-
575
- | Name | Type | Description |
576
- | --- | --- | --- |
577
- | \`fetchargs["path"]\` | \`String\` | URL path with optional \`{param}\` placeholders. |
578
- | \`fetchargs["method"]\` | \`String\` | HTTP method (default: \`"GET"\`). |
579
- | \`fetchargs["params"]\` | \`Hash\` | Path parameter values for \`{param}\` substitution. |
580
- | \`fetchargs["query"]\` | \`Hash\` | Query string parameters. |
581
- | \`fetchargs["headers"]\` | \`Hash\` | Request headers (merged with defaults). |
582
- | \`fetchargs["body"]\` | \`any\` | Request body (hashes are JSON-serialized). |
583
- | \`fetchargs["ctrl"]\` | \`Hash\` | Control options (e.g. \`{ "explain" => true }\`). |
584
-
585
- **Returns:** \`Hash, err\`
586
-
587
- #### \`prepare(fetchargs = {}) -> Hash, err\`
588
-
589
- Prepare a fetch definition without sending the request. Accepts the
590
- same parameters as \`direct()\`.
591
-
592
- **Returns:** \`Hash, err\`
593
-
594
- `)
595
- }
596
- else if (isLua) {
597
- Content(`#### \`options_map() -> table\`
598
-
599
- Return a deep copy of the current SDK options.
600
-
601
- #### \`get_utility() -> Utility\`
602
-
603
- Return a copy of the SDK utility object.
604
-
605
- #### \`direct(fetchargs) -> table, err\`
606
-
607
- Make a direct HTTP request to any API endpoint.
608
-
609
- **Parameters:**
610
-
611
- | Name | Type | Description |
612
- | --- | --- | --- |
613
- | \`fetchargs.path\` | \`string\` | URL path with optional \`{param}\` placeholders. |
614
- | \`fetchargs.method\` | \`string\` | HTTP method (default: \`"GET"\`). |
615
- | \`fetchargs.params\` | \`table\` | Path parameter values for \`{param}\` substitution. |
616
- | \`fetchargs.query\` | \`table\` | Query string parameters. |
617
- | \`fetchargs.headers\` | \`table\` | Request headers (merged with defaults). |
618
- | \`fetchargs.body\` | \`any\` | Request body (tables are JSON-serialized). |
619
- | \`fetchargs.ctrl\` | \`table\` | Control options (e.g. \`{ explain = true }\`). |
620
-
621
- **Returns:** \`table, err\`
622
-
623
- #### \`prepare(fetchargs) -> table, err\`
624
-
625
- Prepare a fetch definition without sending the request. Accepts the
626
- same parameters as \`direct()\`.
627
-
628
- **Returns:** \`table, err\`
629
-
630
- `)
631
- }
632
- else if (isGo) {
633
- Content(`#### \`OptionsMap() map[string]any\`
634
-
635
- Return a deep copy of the current SDK options.
636
-
637
- #### \`GetUtility() *Utility\`
638
-
639
- Return a copy of the SDK utility object.
640
-
641
- #### \`Direct(fetchargs map[string]any) (map[string]any, error)\`
642
-
643
- Make a direct HTTP request to any API endpoint.
644
-
645
- **Parameters:**
646
-
647
- | Name | Type | Description |
648
- | --- | --- | --- |
649
- | \`fetchargs["path"]\` | \`string\` | URL path with optional \`{param}\` placeholders. |
650
- | \`fetchargs["method"]\` | \`string\` | HTTP method (default: \`"GET"\`). |
651
- | \`fetchargs["params"]\` | \`map[string]any\` | Path parameter values for \`{param}\` substitution. |
652
- | \`fetchargs["query"]\` | \`map[string]any\` | Query string parameters. |
653
- | \`fetchargs["headers"]\` | \`map[string]any\` | Request headers (merged with defaults). |
654
- | \`fetchargs["body"]\` | \`any\` | Request body (maps are JSON-serialized). |
655
- | \`fetchargs["ctrl"]\` | \`map[string]any\` | Control options (e.g. \`map[string]any{"explain": true}\`). |
656
-
657
- **Returns:** \`(map[string]any, error)\`
658
-
659
- #### \`Prepare(fetchargs map[string]any) (map[string]any, error)\`
660
-
661
- Prepare a fetch definition without sending the request. Accepts the
662
- same parameters as \`Direct()\`.
663
-
664
- **Returns:** \`(map[string]any, error)\`
665
-
666
- `)
667
- }
668
- else {
669
- Content(`#### \`options()\`
670
-
671
- Return a deep copy of the current SDK options.
672
-
673
- **Returns:** \`object\`
674
-
675
- #### \`utility()\`
676
-
677
- Return a copy of the SDK utility object.
678
-
679
- **Returns:** \`object\`
680
-
681
- #### \`direct(fetchargs?: object)\`
682
-
683
- Make a direct HTTP request to any API endpoint.
684
-
685
- **Parameters:**
686
-
687
- | Name | Type | Description |
688
- | --- | --- | --- |
689
- | \`fetchargs.path\` | \`string\` | URL path with optional \`{param}\` placeholders. |
690
- | \`fetchargs.method\` | \`string\` | HTTP method (default: \`GET\`). |
691
- | \`fetchargs.params\` | \`object\` | Path parameter values for \`{param}\` substitution. |
692
- | \`fetchargs.query\` | \`object\` | Query string parameters. |
693
- | \`fetchargs.headers\` | \`object\` | Request headers (merged with defaults). |
694
- | \`fetchargs.body\` | \`any\` | Request body (objects are JSON-serialized). |
695
- | \`fetchargs.ctrl\` | \`object\` | Control options (e.g. \`{ explain: true }\`). |
696
-
697
- **Returns:** \`Promise<{ ok, status, headers, data } | Error>\`
698
-
699
- #### \`prepare(fetchargs?: object)\`
700
-
701
- Prepare a fetch definition without sending the request. Accepts the
702
- same parameters as \`direct()\`.
703
-
704
- **Returns:** \`Promise<{ url, method, headers, body } | Error>\`
705
-
706
- #### \`tester(testopts?, sdkopts?)\`
707
-
708
- Alias for \`${model.Name}SDK.test()\`.
709
-
710
- **Returns:** \`${model.Name}SDK\` instance in test mode.
711
-
712
- `)
713
- }
714
-
715
-
716
- // Entity reference sections
717
- publishedEntities.map((ent: any) => {
718
- const opnames = Object.keys(ent.op || {})
719
- const fields = ent.fields || []
720
-
721
- Content(`
722
- ---
723
-
724
- ## ${ent.Name}Entity
725
-
726
- `)
727
-
728
- if (ent.short) {
729
- Content(`${ent.short}
730
-
731
- `)
732
- }
733
-
734
- if (isPy) {
735
- Content(`\`\`\`python
736
- ${ent.name} = client.${ent.Name}()
737
- \`\`\`
738
-
739
- `)
740
- }
741
- else if (isPhp) {
742
- Content(`\`\`\`php
743
- $${ent.name} = $client->${ent.Name}();
744
- \`\`\`
745
-
746
- `)
747
- }
748
- else if (isRb) {
749
- Content(`\`\`\`ruby
750
- ${ent.name} = client.${ent.Name}
751
- \`\`\`
752
-
753
- `)
754
- }
755
- else if (isLua) {
756
- Content(`\`\`\`lua
757
- local ${ent.name} = client:${ent.Name}(nil)
758
- \`\`\`
759
-
760
- `)
761
- }
762
- else if (isGo) {
763
- Content(`\`\`\`go
764
- ${ent.name} := client.${ent.Name}(nil)
765
- \`\`\`
766
-
767
- `)
768
- }
769
- else {
770
- Content(`\`\`\`ts
771
- const ${ent.name} = client.${ent.Name}()
772
- \`\`\`
773
-
774
- `)
775
- }
776
-
777
-
778
- // Field schema
779
- if (fields.length > 0) {
780
- Content(`### Fields
781
-
782
- | Field | Type | Required | Description |
783
- | --- | --- | --- | --- |
784
- `)
785
- each(fields, (field: any) => {
786
- const req = field.req ? 'Yes' : 'No'
787
- const desc = field.short || ''
788
- Content(`| \`${field.name}\` | \`${field.type || 'any'}\` | ${req} | ${desc} |
789
- `)
790
- })
791
-
792
- Content(`
793
- `)
794
-
795
- // Field operations breakdown
796
- const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
797
- if (hasFieldOps) {
798
- Content(`### Field Usage by Operation
799
-
800
- | Field | load | list | create | update | remove |
801
- | --- | --- | --- | --- | --- | --- |
802
- `)
803
- each(fields, (field: any) => {
804
- const fops = field.op || {}
805
- const cols = ['load', 'list', 'create', 'update', 'remove'].map((op: string) => {
806
- if (!opnames.includes(op)) return '-'
807
- const fop = fops[op]
808
- if (null == fop) return '-'
809
- if (fop.active === false) return '-'
810
- return 'Yes'
811
- })
812
- Content(`| \`${field.name}\` | ${cols.join(' | ')} |
813
- `)
814
- })
815
-
816
- Content(`
817
- `)
818
- }
819
- }
820
-
821
-
822
- // Operation details
823
- if (opnames.length > 0) {
824
- Content(`### Operations
825
-
826
- `)
827
-
828
- opnames.map((opname: string) => {
829
- const info = OP_SIGNATURES[opname]
830
- if (!info) return
831
-
832
- Content(`#### \`${info.sig}\`
833
-
834
- ${info.desc}
835
-
836
- `)
837
-
838
- // Show example
839
- if (isPy) {
840
- if ('load' === opname || 'remove' === opname) {
841
- Content(`\`\`\`python
842
- result, err = client.${ent.Name}().${opname}({"id": "${ent.name}_id"})
843
- \`\`\`
844
-
845
- `)
846
- }
847
- else if ('list' === opname) {
848
- Content(`\`\`\`python
849
- results, err = client.${ent.Name}().list({})
850
- \`\`\`
851
-
852
- `)
853
- }
854
- else if ('create' === opname) {
855
- Content(`\`\`\`python
856
- result, err = client.${ent.Name}().create({
857
- `)
858
- each(fields, (field: any) => {
859
- if ('id' !== field.name && field.req) {
860
- Content(` "${field.name}": # ${field.type || 'value'},
861
- `)
862
- }
863
- })
864
- Content(`})
865
- \`\`\`
866
-
867
- `)
868
- }
869
- else if ('update' === opname) {
870
- Content(`\`\`\`python
871
- result, err = client.${ent.Name}().update({
872
- "id": "${ent.name}_id",
873
- # Fields to update
874
- })
875
- \`\`\`
876
-
877
- `)
878
- }
879
- }
880
- else if (isPhp) {
881
- if ('load' === opname || 'remove' === opname) {
882
- Content(`\`\`\`php
883
- [$result, $err] = $client->${ent.Name}()->${opname}(["id" => "${ent.name}_id"]);
884
- \`\`\`
885
-
886
- `)
887
- }
888
- else if ('list' === opname) {
889
- Content(`\`\`\`php
890
- [$results, $err] = $client->${ent.Name}()->list([]);
891
- \`\`\`
892
-
893
- `)
894
- }
895
- else if ('create' === opname) {
896
- Content(`\`\`\`php
897
- [$result, $err] = $client->${ent.Name}()->create([
898
- `)
899
- each(fields, (field: any) => {
900
- if ('id' !== field.name && field.req) {
901
- Content(` "${field.name}" => /* ${field.type || 'value'} */,
902
- `)
903
- }
904
- })
905
- Content(`]);
906
- \`\`\`
907
-
908
- `)
909
- }
910
- else if ('update' === opname) {
911
- Content(`\`\`\`php
912
- [$result, $err] = $client->${ent.Name}()->update([
913
- "id" => "${ent.name}_id",
914
- // Fields to update
915
- ]);
916
- \`\`\`
917
-
918
- `)
919
- }
920
- }
921
- else if (isRb) {
922
- if ('load' === opname || 'remove' === opname) {
923
- Content(`\`\`\`ruby
924
- result, err = client.${ent.Name}.${opname}({ "id" => "${ent.name}_id" })
925
- \`\`\`
926
-
927
- `)
928
- }
929
- else if ('list' === opname) {
930
- Content(`\`\`\`ruby
931
- results, err = client.${ent.Name}.list(nil)
932
- \`\`\`
933
-
934
- `)
935
- }
936
- else if ('create' === opname) {
937
- Content(`\`\`\`ruby
938
- result, err = client.${ent.Name}.create({
939
- `)
940
- each(fields, (field: any) => {
941
- if ('id' !== field.name && field.req) {
942
- Content(` "${field.name}" => # ${field.type || 'value'},
943
- `)
944
- }
945
- })
946
- Content(`})
947
- \`\`\`
948
-
949
- `)
950
- }
951
- else if ('update' === opname) {
952
- Content(`\`\`\`ruby
953
- result, err = client.${ent.Name}.update({
954
- "id" => "${ent.name}_id",
955
- # Fields to update
956
- })
957
- \`\`\`
958
-
959
- `)
960
- }
961
- }
962
- else if (isLua) {
963
- if ('load' === opname || 'remove' === opname) {
964
- Content(`\`\`\`lua
965
- local result, err = client:${ent.Name}(nil):${opname}({ id = "${ent.name}_id" }, nil)
966
- \`\`\`
967
-
968
- `)
969
- }
970
- else if ('list' === opname) {
971
- Content(`\`\`\`lua
972
- local results, err = client:${ent.Name}(nil):list(nil, nil)
973
- \`\`\`
974
-
975
- `)
976
- }
977
- else if ('create' === opname) {
978
- Content(`\`\`\`lua
979
- local result, err = client:${ent.Name}(nil):create({
980
- `)
981
- each(fields, (field: any) => {
982
- if ('id' !== field.name && field.req) {
983
- Content(` ${field.name} = --[[ ${field.type || 'value'} ]],
984
- `)
985
- }
986
- })
987
- Content(`}, nil)
988
- \`\`\`
989
-
990
- `)
991
- }
992
- else if ('update' === opname) {
993
- Content(`\`\`\`lua
994
- local result, err = client:${ent.Name}(nil):update({
995
- id = "${ent.name}_id",
996
- -- Fields to update
997
- }, nil)
998
- \`\`\`
999
-
1000
- `)
1001
- }
1002
- }
1003
- else if (isGo) {
1004
- if ('load' === opname || 'remove' === opname) {
1005
- const goOpName = opname.charAt(0).toUpperCase() + opname.slice(1)
1006
- Content(`\`\`\`go
1007
- result, err := client.${ent.Name}(nil).${goOpName}(map[string]any{"id": "${ent.name}_id"}, nil)
1008
- \`\`\`
1009
-
1010
- `)
1011
- }
1012
- else if ('list' === opname) {
1013
- Content(`\`\`\`go
1014
- results, err := client.${ent.Name}(nil).List(nil, nil)
1015
- \`\`\`
1016
-
1017
- `)
1018
- }
1019
- else if ('create' === opname) {
1020
- Content(`\`\`\`go
1021
- result, err := client.${ent.Name}(nil).Create(map[string]any{
1022
- `)
1023
- each(fields, (field: any) => {
1024
- if ('id' !== field.name && field.req) {
1025
- Content(` "${field.name}": /* ${field.type || 'value'} */,
1026
- `)
1027
- }
1028
- })
1029
- Content(`}, nil)
1030
- \`\`\`
1031
-
1032
- `)
1033
- }
1034
- else if ('update' === opname) {
1035
- Content(`\`\`\`go
1036
- result, err := client.${ent.Name}(nil).Update(map[string]any{
1037
- "id": "${ent.name}_id",
1038
- // Fields to update
1039
- }, nil)
1040
- \`\`\`
1041
-
1042
- `)
1043
- }
1044
- }
1045
- else {
1046
- if ('load' === opname || 'remove' === opname) {
1047
- Content(`\`\`\`ts
1048
- const result = await client.${ent.Name}().${opname}({ id: '${ent.name}_id' })
1049
- \`\`\`
1050
-
1051
- `)
1052
- }
1053
- else if ('list' === opname) {
1054
- Content(`\`\`\`ts
1055
- const results = await client.${ent.Name}().${opname}()
1056
- \`\`\`
1057
-
1058
- `)
1059
- }
1060
- else if ('create' === opname) {
1061
- Content(`\`\`\`ts
1062
- const result = await client.${ent.Name}().create({
1063
- `)
1064
- each(fields, (field: any) => {
1065
- if ('id' !== field.name && field.req) {
1066
- Content(` ${field.name}: /* ${field.type || 'value'} */,
1067
- `)
1068
- }
1069
- })
1070
- Content(`})
1071
- \`\`\`
1072
-
1073
- `)
1074
- }
1075
- else if ('update' === opname) {
1076
- Content(`\`\`\`ts
1077
- const result = await client.${ent.Name}().update({
1078
- id: '${ent.name}_id',
1079
- // Fields to update
1080
- })
1081
- \`\`\`
1082
-
1083
- `)
1084
- }
1085
- }
1086
- })
1087
- }
1088
-
1089
-
1090
- // Common methods
1091
- if (isPy) {
1092
- Content(`### Common Methods
1093
-
1094
- #### \`data_get() -> dict\`
1095
-
1096
- Get the entity data.
1097
-
1098
- #### \`data_set(data)\`
1099
-
1100
- Set the entity data.
1101
-
1102
- #### \`match_get() -> dict\`
1103
-
1104
- Get the entity match criteria.
1105
-
1106
- #### \`match_set(match)\`
1107
-
1108
- Set the entity match criteria.
1109
-
1110
- #### \`make() -> Entity\`
1111
-
1112
- Create a new \`${ent.Name}Entity\` instance with the same options.
1113
-
1114
- #### \`get_name() -> str\`
1115
-
1116
- Return the entity name.
1117
-
1118
- `)
1119
- }
1120
- else if (isPhp) {
1121
- Content(`### Common Methods
1122
-
1123
- #### \`dataGet(): array\`
1124
-
1125
- Get the entity data. Returns a copy of the current data.
1126
-
1127
- #### \`dataSet($data): void\`
1128
-
1129
- Set the entity data.
1130
-
1131
- #### \`matchGet(): array\`
1132
-
1133
- Get the entity match criteria.
1134
-
1135
- #### \`matchSet($match): void\`
1136
-
1137
- Set the entity match criteria.
1138
-
1139
- #### \`make(): ${ent.Name}Entity\`
1140
-
1141
- Create a new \`${ent.Name}Entity\` instance with the same client and
1142
- options.
1143
-
1144
- #### \`getName(): string\`
1145
-
1146
- Return the entity name.
1147
-
1148
- `)
1149
- }
1150
- else if (isRb) {
1151
- Content(`### Common Methods
1152
-
1153
- #### \`data_get -> Hash\`
1154
-
1155
- Get the entity data. Returns a copy of the current data.
1156
-
1157
- #### \`data_set(data)\`
1158
-
1159
- Set the entity data.
1160
-
1161
- #### \`match_get -> Hash\`
1162
-
1163
- Get the entity match criteria.
1164
-
1165
- #### \`match_set(match)\`
1166
-
1167
- Set the entity match criteria.
1168
-
1169
- #### \`make -> Entity\`
1170
-
1171
- Create a new \`${ent.Name}Entity\` instance with the same client and
1172
- options.
1173
-
1174
- #### \`get_name -> String\`
1175
-
1176
- Return the entity name.
1177
-
1178
- `)
1179
- }
1180
- else if (isLua) {
1181
- Content(`### Common Methods
1182
-
1183
- #### \`data_get() -> table\`
1184
-
1185
- Get the entity data. Returns a copy of the current data.
1186
-
1187
- #### \`data_set(data)\`
1188
-
1189
- Set the entity data.
1190
-
1191
- #### \`match_get() -> table\`
1192
-
1193
- Get the entity match criteria.
1194
-
1195
- #### \`match_set(match)\`
1196
-
1197
- Set the entity match criteria.
1198
-
1199
- #### \`make() -> Entity\`
1200
-
1201
- Create a new \`${ent.Name}Entity\` instance with the same client and
1202
- options.
1203
-
1204
- #### \`get_name() -> string\`
1205
-
1206
- Return the entity name.
1207
-
1208
- `)
1209
- }
1210
- else if (isGo) {
1211
- Content(`### Common Methods
1212
-
1213
- #### \`Data(args ...any) any\`
1214
-
1215
- Get or set the entity data. When called with data, sets the entity's
1216
- internal data and returns the current data. When called without
1217
- arguments, returns a copy of the current data.
1218
-
1219
- #### \`Match(args ...any) any\`
1220
-
1221
- Get or set the entity match criteria. Works the same as \`Data()\`.
1222
-
1223
- #### \`Make() Entity\`
1224
-
1225
- Create a new \`${ent.Name}Entity\` instance with the same client and
1226
- options.
1227
-
1228
- #### \`GetName() string\`
1229
-
1230
- Return the entity name.
1231
-
1232
- `)
1233
- }
1234
- else {
1235
- Content(`### Common Methods
1236
-
1237
- #### \`data(data?: object)\`
1238
-
1239
- Get or set the entity data. When called with data, sets the entity's
1240
- internal data and returns the current data. When called without
1241
- arguments, returns a copy of the current data.
1242
-
1243
- #### \`match(match?: object)\`
1244
-
1245
- Get or set the entity match criteria. Works the same as \`data()\`.
1246
-
1247
- #### \`make()\`
1248
-
1249
- Create a new \`${ent.Name}Entity\` instance with the same client and
1250
- options.
1251
-
1252
- #### \`client()\`
1253
-
1254
- Return the parent \`${model.Name}SDK\` instance.
1255
-
1256
- #### \`entopts()\`
1257
-
1258
- Return a copy of the entity options.
1259
-
1260
- `)
1261
- }
1262
- })
1263
-
1264
-
1265
- // Features section
1266
- const activeFeatures = each(feature).filter((f: any) => f.active)
1267
- if (activeFeatures.length > 0) {
1268
- Content(`
1269
- ---
1270
-
1271
- ## Features
1272
-
1273
- | Feature | Version | Description |
1274
- | --- | --- | --- |
1275
- `)
1276
-
1277
- activeFeatures.map((f: any) => {
1278
- Content(`| \`${f.name}\` | ${f.version || '0.0.1'} | ${f.title || ''} |
1279
- `)
1280
- })
1281
-
1282
- Content(`
1283
-
1284
- Features are activated via the \`feature\` option:
1285
-
1286
- `)
1287
-
1288
- if (isPy) {
1289
- Content(`\`\`\`python
1290
- client = ${model.const.Name}SDK({
1291
- "feature": {
1292
- `)
1293
- activeFeatures.map((f: any) => {
1294
- Content(` "${f.name}": {"active": True},
1295
- `)
1296
- })
1297
- Content(` },
1298
- })
1299
- \`\`\`
1300
-
1301
- `)
1302
- }
1303
- else if (isPhp) {
1304
- Content(`\`\`\`php
1305
- $client = new ${model.const.Name}SDK([
1306
- "feature" => [
1307
- `)
1308
- activeFeatures.map((f: any) => {
1309
- Content(` "${f.name}" => ["active" => true],
1310
- `)
1311
- })
1312
- Content(` ],
1313
- ]);
1314
- \`\`\`
1315
-
1316
- `)
1317
- }
1318
- else if (isRb) {
1319
- Content(`\`\`\`ruby
1320
- client = ${model.const.Name}SDK.new({
1321
- "feature" => {
1322
- `)
1323
- activeFeatures.map((f: any) => {
1324
- Content(` "${f.name}" => { "active" => true },
1325
- `)
1326
- })
1327
- Content(` },
1328
- })
1329
- \`\`\`
1330
-
1331
- `)
1332
- }
1333
- else if (isLua) {
1334
- Content(`\`\`\`lua
1335
- local client = sdk.new({
1336
- feature = {
1337
- `)
1338
- activeFeatures.map((f: any) => {
1339
- Content(` ${f.name} = { active = true },
1340
- `)
1341
- })
1342
- Content(` },
1343
- })
1344
- \`\`\`
1345
-
1346
- `)
1347
- }
1348
- else if (isGo) {
1349
- Content(`\`\`\`go
1350
- client := sdk.New${model.const.Name}SDK(map[string]any{
1351
- "feature": map[string]any{
1352
- `)
1353
- activeFeatures.map((f: any) => {
1354
- Content(` "${f.name}": map[string]any{"active": true},
1355
- `)
1356
- })
1357
- Content(` },
1358
- })
1359
- \`\`\`
1360
-
1361
- `)
1362
- }
1363
- else {
1364
- Content(`\`\`\`ts
1365
- const client = new ${model.Name}SDK({
1366
- feature: {
1367
- `)
1368
- activeFeatures.map((f: any) => {
1369
- Content(` ${f.name}: { active: true },
1370
- `)
1371
- })
1372
- Content(` }
1373
- })
1374
- \`\`\`
12
+ const { target, ctx$ } = props
1375
13
 
1376
- `)
1377
- }
1378
- }
14
+ const ReadmeRef_sdk =
15
+ requirePath(ctx$, `./cmp/${target.name}/ReadmeRef_${target.name}`, { ignore: true })
1379
16
 
1380
- })
17
+ if (ReadmeRef_sdk) {
18
+ ReadmeRef_sdk['ReadmeRef']({ target })
19
+ }
1381
20
  })
1382
21
 
1383
22