@constructive-sdk/cli 0.29.1 → 0.29.2

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 (199) hide show
  1. package/api/cli/commands/api.js +44 -0
  2. package/api/cli/commands/check-constraint.js +0 -22
  3. package/api/cli/commands/composite-type.js +0 -22
  4. package/api/cli/commands/database-setting.js +44 -0
  5. package/api/cli/commands/domain.js +66 -0
  6. package/api/cli/commands/enum.js +0 -22
  7. package/api/cli/commands/field.js +0 -22
  8. package/api/cli/commands/foreign-key-constraint.js +0 -22
  9. package/api/cli/commands/index.js +0 -22
  10. package/api/cli/commands/policy.js +0 -22
  11. package/api/cli/commands/primary-key-constraint.js +0 -22
  12. package/api/cli/commands/schema.js +0 -22
  13. package/api/cli/commands/site.js +44 -0
  14. package/api/cli/commands/spatial-relation.js +0 -22
  15. package/api/cli/commands/table.js +0 -22
  16. package/api/cli/commands/trigger.js +0 -22
  17. package/api/cli/commands/unique-constraint.js +0 -22
  18. package/api/cli/commands/view.js +0 -22
  19. package/api/orm/input-types.d.ts +144 -171
  20. package/auth/cli/commands/create-org-api-key.d.ts +8 -0
  21. package/auth/cli/commands/create-org-api-key.js +36 -0
  22. package/auth/cli/commands/create-org-principal.d.ts +8 -0
  23. package/auth/cli/commands/create-org-principal.js +36 -0
  24. package/auth/cli/commands/delete-org-principal.d.ts +8 -0
  25. package/auth/cli/commands/delete-org-principal.js +36 -0
  26. package/auth/cli/commands/org-api-key-list.d.ts +8 -0
  27. package/auth/cli/commands/org-api-key-list.js +224 -0
  28. package/auth/cli/commands/principal-entity.d.ts +8 -0
  29. package/auth/cli/commands/principal-entity.js +282 -0
  30. package/auth/cli/commands/principal-scope-override.d.ts +8 -0
  31. package/auth/cli/commands/principal-scope-override.js +171 -0
  32. package/auth/cli/commands/principal.d.ts +8 -0
  33. package/auth/cli/commands/principal.js +171 -0
  34. package/auth/cli/commands/revoke-org-api-key.d.ts +8 -0
  35. package/auth/cli/commands/revoke-org-api-key.js +36 -0
  36. package/auth/cli/commands.js +19 -3
  37. package/auth/cli/executor.d.ts +28 -4
  38. package/auth/orm/index.d.ts +32 -4
  39. package/auth/orm/index.js +8 -0
  40. package/auth/orm/input-types.d.ts +915 -145
  41. package/auth/orm/input-types.js +7 -0
  42. package/auth/orm/models/index.d.ts +4 -0
  43. package/auth/orm/models/index.js +9 -1
  44. package/auth/orm/models/orgApiKeyList.d.ts +36 -0
  45. package/auth/orm/models/orgApiKeyList.js +80 -0
  46. package/auth/orm/models/principal.d.ts +45 -0
  47. package/auth/orm/models/principal.js +93 -0
  48. package/auth/orm/models/principalEntity.d.ts +54 -0
  49. package/auth/orm/models/principalEntity.js +104 -0
  50. package/auth/orm/models/principalScopeOverride.d.ts +36 -0
  51. package/auth/orm/models/principalScopeOverride.js +80 -0
  52. package/auth/orm/mutation/index.d.ts +33 -1
  53. package/auth/orm/mutation/index.js +48 -0
  54. package/auth/orm/query/index.d.ts +4 -4
  55. package/auth/orm/query/index.js +7 -7
  56. package/compute/cli/commands/function-graph-execution.js +0 -22
  57. package/compute/cli/commands/function-graph.js +0 -20
  58. package/compute/cli/commands/platform-namespace-event.d.ts +8 -0
  59. package/compute/cli/commands/platform-namespace-event.js +510 -0
  60. package/compute/cli/commands/platform-namespace.d.ts +8 -0
  61. package/compute/cli/commands/platform-namespace.js +436 -0
  62. package/compute/cli/commands/resource-event.d.ts +8 -0
  63. package/compute/cli/commands/resource-event.js +356 -0
  64. package/compute/cli/commands/resource.d.ts +8 -0
  65. package/compute/cli/commands/resource.js +520 -0
  66. package/compute/cli/commands.js +13 -5
  67. package/compute/cli/executor.d.ts +10 -6
  68. package/compute/orm/index.d.ts +15 -7
  69. package/compute/orm/index.js +10 -2
  70. package/compute/orm/input-types.d.ts +1159 -221
  71. package/compute/orm/input-types.js +4 -0
  72. package/compute/orm/models/index.d.ts +5 -1
  73. package/compute/orm/models/index.js +11 -3
  74. package/compute/orm/models/platformNamespace.d.ts +54 -0
  75. package/compute/orm/models/platformNamespace.js +104 -0
  76. package/compute/orm/models/platformNamespaceEvent.d.ts +56 -0
  77. package/compute/orm/models/platformNamespaceEvent.js +107 -0
  78. package/compute/orm/models/resource.d.ts +54 -0
  79. package/compute/orm/models/resource.js +104 -0
  80. package/compute/orm/models/resourceEvent.d.ts +56 -0
  81. package/compute/orm/models/resourceEvent.js +107 -0
  82. package/compute/orm/mutation/index.d.ts +9 -9
  83. package/compute/orm/mutation/index.js +12 -12
  84. package/esm/api/cli/commands/api.js +44 -0
  85. package/esm/api/cli/commands/check-constraint.js +0 -22
  86. package/esm/api/cli/commands/composite-type.js +0 -22
  87. package/esm/api/cli/commands/database-setting.js +44 -0
  88. package/esm/api/cli/commands/domain.js +66 -0
  89. package/esm/api/cli/commands/enum.js +0 -22
  90. package/esm/api/cli/commands/field.js +0 -22
  91. package/esm/api/cli/commands/foreign-key-constraint.js +0 -22
  92. package/esm/api/cli/commands/index.js +0 -22
  93. package/esm/api/cli/commands/policy.js +0 -22
  94. package/esm/api/cli/commands/primary-key-constraint.js +0 -22
  95. package/esm/api/cli/commands/schema.js +0 -22
  96. package/esm/api/cli/commands/site.js +44 -0
  97. package/esm/api/cli/commands/spatial-relation.js +0 -22
  98. package/esm/api/cli/commands/table.js +0 -22
  99. package/esm/api/cli/commands/trigger.js +0 -22
  100. package/esm/api/cli/commands/unique-constraint.js +0 -22
  101. package/esm/api/cli/commands/view.js +0 -22
  102. package/esm/api/orm/input-types.d.ts +144 -171
  103. package/esm/auth/cli/commands/create-org-api-key.d.ts +8 -0
  104. package/esm/auth/cli/commands/create-org-api-key.js +34 -0
  105. package/esm/auth/cli/commands/create-org-principal.d.ts +8 -0
  106. package/esm/auth/cli/commands/create-org-principal.js +34 -0
  107. package/esm/auth/cli/commands/delete-org-principal.d.ts +8 -0
  108. package/esm/auth/cli/commands/delete-org-principal.js +34 -0
  109. package/esm/auth/cli/commands/org-api-key-list.d.ts +8 -0
  110. package/esm/auth/cli/commands/org-api-key-list.js +222 -0
  111. package/esm/auth/cli/commands/principal-entity.d.ts +8 -0
  112. package/esm/auth/cli/commands/principal-entity.js +280 -0
  113. package/esm/auth/cli/commands/principal-scope-override.d.ts +8 -0
  114. package/esm/auth/cli/commands/principal-scope-override.js +169 -0
  115. package/esm/auth/cli/commands/principal.d.ts +8 -0
  116. package/esm/auth/cli/commands/principal.js +169 -0
  117. package/esm/auth/cli/commands/revoke-org-api-key.d.ts +8 -0
  118. package/esm/auth/cli/commands/revoke-org-api-key.js +34 -0
  119. package/esm/auth/cli/commands.js +19 -3
  120. package/esm/auth/cli/executor.d.ts +28 -4
  121. package/esm/auth/orm/index.d.ts +32 -4
  122. package/esm/auth/orm/index.js +8 -0
  123. package/esm/auth/orm/input-types.d.ts +915 -145
  124. package/esm/auth/orm/input-types.js +7 -0
  125. package/esm/auth/orm/models/index.d.ts +4 -0
  126. package/esm/auth/orm/models/index.js +4 -0
  127. package/esm/auth/orm/models/orgApiKeyList.d.ts +36 -0
  128. package/esm/auth/orm/models/orgApiKeyList.js +76 -0
  129. package/esm/auth/orm/models/principal.d.ts +45 -0
  130. package/esm/auth/orm/models/principal.js +89 -0
  131. package/esm/auth/orm/models/principalEntity.d.ts +54 -0
  132. package/esm/auth/orm/models/principalEntity.js +100 -0
  133. package/esm/auth/orm/models/principalScopeOverride.d.ts +36 -0
  134. package/esm/auth/orm/models/principalScopeOverride.js +76 -0
  135. package/esm/auth/orm/mutation/index.d.ts +33 -1
  136. package/esm/auth/orm/mutation/index.js +48 -0
  137. package/esm/auth/orm/query/index.d.ts +4 -4
  138. package/esm/auth/orm/query/index.js +7 -7
  139. package/esm/compute/cli/commands/function-graph-execution.js +0 -22
  140. package/esm/compute/cli/commands/function-graph.js +0 -20
  141. package/esm/compute/cli/commands/platform-namespace-event.d.ts +8 -0
  142. package/esm/compute/cli/commands/platform-namespace-event.js +508 -0
  143. package/esm/compute/cli/commands/platform-namespace.d.ts +8 -0
  144. package/esm/compute/cli/commands/platform-namespace.js +434 -0
  145. package/esm/compute/cli/commands/resource-event.d.ts +8 -0
  146. package/esm/compute/cli/commands/resource-event.js +354 -0
  147. package/esm/compute/cli/commands/resource.d.ts +8 -0
  148. package/esm/compute/cli/commands/resource.js +518 -0
  149. package/esm/compute/cli/commands.js +13 -5
  150. package/esm/compute/cli/executor.d.ts +10 -6
  151. package/esm/compute/orm/index.d.ts +15 -7
  152. package/esm/compute/orm/index.js +10 -2
  153. package/esm/compute/orm/input-types.d.ts +1159 -221
  154. package/esm/compute/orm/input-types.js +4 -0
  155. package/esm/compute/orm/models/index.d.ts +5 -1
  156. package/esm/compute/orm/models/index.js +5 -1
  157. package/esm/compute/orm/models/platformNamespace.d.ts +54 -0
  158. package/esm/compute/orm/models/platformNamespace.js +100 -0
  159. package/esm/compute/orm/models/platformNamespaceEvent.d.ts +56 -0
  160. package/esm/compute/orm/models/platformNamespaceEvent.js +103 -0
  161. package/esm/compute/orm/models/resource.d.ts +54 -0
  162. package/esm/compute/orm/models/resource.js +100 -0
  163. package/esm/compute/orm/models/resourceEvent.d.ts +56 -0
  164. package/esm/compute/orm/models/resourceEvent.js +103 -0
  165. package/esm/compute/orm/mutation/index.d.ts +9 -9
  166. package/esm/compute/orm/mutation/index.js +12 -12
  167. package/esm/modules/cli/commands/merkle-store-module.js +22 -0
  168. package/esm/modules/cli/commands/principal-auth-module.d.ts +8 -0
  169. package/esm/modules/cli/commands/principal-auth-module.js +580 -0
  170. package/esm/modules/cli/commands/resource-module.d.ts +8 -0
  171. package/esm/modules/cli/commands/resource-module.js +602 -0
  172. package/esm/modules/cli/commands.js +9 -5
  173. package/esm/modules/cli/executor.d.ts +4 -2
  174. package/esm/modules/orm/index.d.ts +8 -4
  175. package/esm/modules/orm/index.js +8 -4
  176. package/esm/modules/orm/input-types.d.ts +868 -411
  177. package/esm/modules/orm/models/index.d.ts +4 -2
  178. package/esm/modules/orm/models/index.js +4 -2
  179. package/esm/modules/orm/models/principalAuthModule.d.ts +54 -0
  180. package/esm/modules/orm/models/principalAuthModule.js +100 -0
  181. package/esm/modules/orm/models/resourceModule.d.ts +54 -0
  182. package/esm/modules/orm/models/resourceModule.js +100 -0
  183. package/modules/cli/commands/merkle-store-module.js +22 -0
  184. package/modules/cli/commands/principal-auth-module.d.ts +8 -0
  185. package/modules/cli/commands/principal-auth-module.js +582 -0
  186. package/modules/cli/commands/resource-module.d.ts +8 -0
  187. package/modules/cli/commands/resource-module.js +604 -0
  188. package/modules/cli/commands.js +9 -5
  189. package/modules/cli/executor.d.ts +4 -2
  190. package/modules/orm/index.d.ts +8 -4
  191. package/modules/orm/index.js +8 -4
  192. package/modules/orm/input-types.d.ts +868 -411
  193. package/modules/orm/models/index.d.ts +4 -2
  194. package/modules/orm/models/index.js +10 -6
  195. package/modules/orm/models/principalAuthModule.d.ts +54 -0
  196. package/modules/orm/models/principalAuthModule.js +104 -0
  197. package/modules/orm/models/resourceModule.d.ts +54 -0
  198. package/modules/orm/models/resourceModule.js +104 -0
  199. package/package.json +4 -4
@@ -0,0 +1,602 @@
1
+ /**
2
+ * CLI commands for ResourceModule
3
+ * @generated by @constructive-io/graphql-codegen
4
+ * DO NOT EDIT - changes will be overwritten
5
+ */
6
+ import { extractFirst } from 'inquirerer';
7
+ import { getClient } from '../executor';
8
+ import { coerceAnswers, parseFindFirstArgs, parseFindManyArgs, stripUndefined } from '../utils';
9
+ const fieldSchema = {
10
+ id: 'uuid',
11
+ databaseId: 'uuid',
12
+ schemaId: 'uuid',
13
+ privateSchemaId: 'uuid',
14
+ publicSchemaName: 'string',
15
+ privateSchemaName: 'string',
16
+ resourcesTableId: 'uuid',
17
+ resourceEventsTableId: 'uuid',
18
+ resourcesTableName: 'string',
19
+ resourceEventsTableName: 'string',
20
+ apiName: 'string',
21
+ privateApiName: 'string',
22
+ scope: 'string',
23
+ prefix: 'string',
24
+ entityTableId: 'uuid',
25
+ namespaceModuleId: 'uuid',
26
+ policies: 'json',
27
+ provisions: 'json',
28
+ defaultPermissions: 'string',
29
+ };
30
+ const usage = '\nresource-module <command>\n\nCommands:\n list List resourceModule records\n find-first Find first matching resourceModule record\n get Get a resourceModule by ID\n create Create a new resourceModule\n update Update an existing resourceModule\n delete Delete a resourceModule\n\nList Options:\n --limit <n> Max number of records to return (forward pagination)\n --last <n> Number of records from the end (backward pagination)\n --after <cursor> Cursor for forward pagination\n --before <cursor> Cursor for backward pagination\n --offset <n> Number of records to skip\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\nFind-First Options:\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\n --help, -h Show this help message\n';
31
+ export default async (argv, prompter, _options) => {
32
+ if (argv.help || argv.h) {
33
+ console.log(usage);
34
+ process.exit(0);
35
+ }
36
+ const { first: subcommand, newArgv } = extractFirst(argv);
37
+ if (!subcommand) {
38
+ const answer = await prompter.prompt(argv, [
39
+ {
40
+ type: 'autocomplete',
41
+ name: 'subcommand',
42
+ message: 'What do you want to do?',
43
+ options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
44
+ },
45
+ ]);
46
+ return handleTableSubcommand(answer.subcommand, newArgv, prompter);
47
+ }
48
+ return handleTableSubcommand(subcommand, newArgv, prompter);
49
+ };
50
+ async function handleTableSubcommand(subcommand, argv, prompter) {
51
+ switch (subcommand) {
52
+ case 'list':
53
+ return handleList(argv, prompter);
54
+ case 'find-first':
55
+ return handleFindFirst(argv, prompter);
56
+ case 'get':
57
+ return handleGet(argv, prompter);
58
+ case 'create':
59
+ return handleCreate(argv, prompter);
60
+ case 'update':
61
+ return handleUpdate(argv, prompter);
62
+ case 'delete':
63
+ return handleDelete(argv, prompter);
64
+ default:
65
+ console.log(usage);
66
+ process.exit(1);
67
+ }
68
+ }
69
+ async function handleList(argv, _prompter) {
70
+ try {
71
+ const defaultSelect = {
72
+ id: true,
73
+ databaseId: true,
74
+ schemaId: true,
75
+ privateSchemaId: true,
76
+ publicSchemaName: true,
77
+ privateSchemaName: true,
78
+ resourcesTableId: true,
79
+ resourceEventsTableId: true,
80
+ resourcesTableName: true,
81
+ resourceEventsTableName: true,
82
+ apiName: true,
83
+ privateApiName: true,
84
+ scope: true,
85
+ prefix: true,
86
+ entityTableId: true,
87
+ namespaceModuleId: true,
88
+ policies: true,
89
+ provisions: true,
90
+ defaultPermissions: true,
91
+ };
92
+ const findManyArgs = parseFindManyArgs(argv, defaultSelect);
93
+ const client = getClient();
94
+ const result = await client.resourceModule.findMany(findManyArgs).execute();
95
+ console.log(JSON.stringify(result, null, 2));
96
+ }
97
+ catch (error) {
98
+ console.error('Failed to list records.');
99
+ if (error instanceof Error) {
100
+ console.error(error.message);
101
+ }
102
+ process.exit(1);
103
+ }
104
+ }
105
+ async function handleFindFirst(argv, _prompter) {
106
+ try {
107
+ const defaultSelect = {
108
+ id: true,
109
+ databaseId: true,
110
+ schemaId: true,
111
+ privateSchemaId: true,
112
+ publicSchemaName: true,
113
+ privateSchemaName: true,
114
+ resourcesTableId: true,
115
+ resourceEventsTableId: true,
116
+ resourcesTableName: true,
117
+ resourceEventsTableName: true,
118
+ apiName: true,
119
+ privateApiName: true,
120
+ scope: true,
121
+ prefix: true,
122
+ entityTableId: true,
123
+ namespaceModuleId: true,
124
+ policies: true,
125
+ provisions: true,
126
+ defaultPermissions: true,
127
+ };
128
+ const findFirstArgs = parseFindFirstArgs(argv, defaultSelect);
129
+ const client = getClient();
130
+ const result = await client.resourceModule.findFirst(findFirstArgs).execute();
131
+ console.log(JSON.stringify(result, null, 2));
132
+ }
133
+ catch (error) {
134
+ console.error('Failed to find record.');
135
+ if (error instanceof Error) {
136
+ console.error(error.message);
137
+ }
138
+ process.exit(1);
139
+ }
140
+ }
141
+ async function handleGet(argv, prompter) {
142
+ try {
143
+ const answers = await prompter.prompt(argv, [
144
+ {
145
+ type: 'text',
146
+ name: 'id',
147
+ message: 'id',
148
+ required: true,
149
+ },
150
+ ]);
151
+ const client = getClient();
152
+ const result = await client.resourceModule
153
+ .findOne({
154
+ id: answers.id,
155
+ select: {
156
+ id: true,
157
+ databaseId: true,
158
+ schemaId: true,
159
+ privateSchemaId: true,
160
+ publicSchemaName: true,
161
+ privateSchemaName: true,
162
+ resourcesTableId: true,
163
+ resourceEventsTableId: true,
164
+ resourcesTableName: true,
165
+ resourceEventsTableName: true,
166
+ apiName: true,
167
+ privateApiName: true,
168
+ scope: true,
169
+ prefix: true,
170
+ entityTableId: true,
171
+ namespaceModuleId: true,
172
+ policies: true,
173
+ provisions: true,
174
+ defaultPermissions: true,
175
+ },
176
+ })
177
+ .execute();
178
+ console.log(JSON.stringify(result, null, 2));
179
+ }
180
+ catch (error) {
181
+ console.error('Record not found.');
182
+ if (error instanceof Error) {
183
+ console.error(error.message);
184
+ }
185
+ process.exit(1);
186
+ }
187
+ }
188
+ async function handleCreate(argv, prompter) {
189
+ try {
190
+ const rawAnswers = await prompter.prompt(argv, [
191
+ {
192
+ type: 'text',
193
+ name: 'databaseId',
194
+ message: 'databaseId',
195
+ required: true,
196
+ },
197
+ {
198
+ type: 'text',
199
+ name: 'schemaId',
200
+ message: 'schemaId',
201
+ required: false,
202
+ skipPrompt: true,
203
+ },
204
+ {
205
+ type: 'text',
206
+ name: 'privateSchemaId',
207
+ message: 'privateSchemaId',
208
+ required: false,
209
+ skipPrompt: true,
210
+ },
211
+ {
212
+ type: 'text',
213
+ name: 'publicSchemaName',
214
+ message: 'publicSchemaName',
215
+ required: false,
216
+ skipPrompt: true,
217
+ },
218
+ {
219
+ type: 'text',
220
+ name: 'privateSchemaName',
221
+ message: 'privateSchemaName',
222
+ required: false,
223
+ skipPrompt: true,
224
+ },
225
+ {
226
+ type: 'text',
227
+ name: 'resourcesTableId',
228
+ message: 'resourcesTableId',
229
+ required: false,
230
+ skipPrompt: true,
231
+ },
232
+ {
233
+ type: 'text',
234
+ name: 'resourceEventsTableId',
235
+ message: 'resourceEventsTableId',
236
+ required: false,
237
+ skipPrompt: true,
238
+ },
239
+ {
240
+ type: 'text',
241
+ name: 'resourcesTableName',
242
+ message: 'resourcesTableName',
243
+ required: false,
244
+ skipPrompt: true,
245
+ },
246
+ {
247
+ type: 'text',
248
+ name: 'resourceEventsTableName',
249
+ message: 'resourceEventsTableName',
250
+ required: false,
251
+ skipPrompt: true,
252
+ },
253
+ {
254
+ type: 'text',
255
+ name: 'apiName',
256
+ message: 'apiName',
257
+ required: false,
258
+ skipPrompt: true,
259
+ },
260
+ {
261
+ type: 'text',
262
+ name: 'privateApiName',
263
+ message: 'privateApiName',
264
+ required: false,
265
+ skipPrompt: true,
266
+ },
267
+ {
268
+ type: 'text',
269
+ name: 'scope',
270
+ message: 'scope',
271
+ required: false,
272
+ skipPrompt: true,
273
+ },
274
+ {
275
+ type: 'text',
276
+ name: 'prefix',
277
+ message: 'prefix',
278
+ required: false,
279
+ skipPrompt: true,
280
+ },
281
+ {
282
+ type: 'text',
283
+ name: 'entityTableId',
284
+ message: 'entityTableId',
285
+ required: false,
286
+ skipPrompt: true,
287
+ },
288
+ {
289
+ type: 'text',
290
+ name: 'namespaceModuleId',
291
+ message: 'namespaceModuleId',
292
+ required: false,
293
+ skipPrompt: true,
294
+ },
295
+ {
296
+ type: 'json',
297
+ name: 'policies',
298
+ message: 'policies',
299
+ required: false,
300
+ skipPrompt: true,
301
+ },
302
+ {
303
+ type: 'json',
304
+ name: 'provisions',
305
+ message: 'provisions',
306
+ required: false,
307
+ skipPrompt: true,
308
+ },
309
+ {
310
+ type: 'text',
311
+ name: 'defaultPermissions',
312
+ message: 'defaultPermissions',
313
+ required: false,
314
+ skipPrompt: true,
315
+ },
316
+ ]);
317
+ const answers = coerceAnswers(rawAnswers, fieldSchema);
318
+ const cleanedData = stripUndefined(answers, fieldSchema);
319
+ const client = getClient();
320
+ const result = await client.resourceModule
321
+ .create({
322
+ data: {
323
+ databaseId: cleanedData.databaseId,
324
+ schemaId: cleanedData.schemaId,
325
+ privateSchemaId: cleanedData.privateSchemaId,
326
+ publicSchemaName: cleanedData.publicSchemaName,
327
+ privateSchemaName: cleanedData.privateSchemaName,
328
+ resourcesTableId: cleanedData.resourcesTableId,
329
+ resourceEventsTableId: cleanedData.resourceEventsTableId,
330
+ resourcesTableName: cleanedData.resourcesTableName,
331
+ resourceEventsTableName: cleanedData.resourceEventsTableName,
332
+ apiName: cleanedData.apiName,
333
+ privateApiName: cleanedData.privateApiName,
334
+ scope: cleanedData.scope,
335
+ prefix: cleanedData.prefix,
336
+ entityTableId: cleanedData.entityTableId,
337
+ namespaceModuleId: cleanedData.namespaceModuleId,
338
+ policies: cleanedData.policies,
339
+ provisions: cleanedData.provisions,
340
+ defaultPermissions: cleanedData.defaultPermissions,
341
+ },
342
+ select: {
343
+ id: true,
344
+ databaseId: true,
345
+ schemaId: true,
346
+ privateSchemaId: true,
347
+ publicSchemaName: true,
348
+ privateSchemaName: true,
349
+ resourcesTableId: true,
350
+ resourceEventsTableId: true,
351
+ resourcesTableName: true,
352
+ resourceEventsTableName: true,
353
+ apiName: true,
354
+ privateApiName: true,
355
+ scope: true,
356
+ prefix: true,
357
+ entityTableId: true,
358
+ namespaceModuleId: true,
359
+ policies: true,
360
+ provisions: true,
361
+ defaultPermissions: true,
362
+ },
363
+ })
364
+ .execute();
365
+ console.log(JSON.stringify(result, null, 2));
366
+ }
367
+ catch (error) {
368
+ console.error('Failed to create record.');
369
+ if (error instanceof Error) {
370
+ console.error(error.message);
371
+ }
372
+ process.exit(1);
373
+ }
374
+ }
375
+ async function handleUpdate(argv, prompter) {
376
+ try {
377
+ const rawAnswers = await prompter.prompt(argv, [
378
+ {
379
+ type: 'text',
380
+ name: 'id',
381
+ message: 'id',
382
+ required: true,
383
+ },
384
+ {
385
+ type: 'text',
386
+ name: 'databaseId',
387
+ message: 'databaseId',
388
+ required: false,
389
+ },
390
+ {
391
+ type: 'text',
392
+ name: 'schemaId',
393
+ message: 'schemaId',
394
+ required: false,
395
+ skipPrompt: true,
396
+ },
397
+ {
398
+ type: 'text',
399
+ name: 'privateSchemaId',
400
+ message: 'privateSchemaId',
401
+ required: false,
402
+ skipPrompt: true,
403
+ },
404
+ {
405
+ type: 'text',
406
+ name: 'publicSchemaName',
407
+ message: 'publicSchemaName',
408
+ required: false,
409
+ skipPrompt: true,
410
+ },
411
+ {
412
+ type: 'text',
413
+ name: 'privateSchemaName',
414
+ message: 'privateSchemaName',
415
+ required: false,
416
+ skipPrompt: true,
417
+ },
418
+ {
419
+ type: 'text',
420
+ name: 'resourcesTableId',
421
+ message: 'resourcesTableId',
422
+ required: false,
423
+ skipPrompt: true,
424
+ },
425
+ {
426
+ type: 'text',
427
+ name: 'resourceEventsTableId',
428
+ message: 'resourceEventsTableId',
429
+ required: false,
430
+ skipPrompt: true,
431
+ },
432
+ {
433
+ type: 'text',
434
+ name: 'resourcesTableName',
435
+ message: 'resourcesTableName',
436
+ required: false,
437
+ skipPrompt: true,
438
+ },
439
+ {
440
+ type: 'text',
441
+ name: 'resourceEventsTableName',
442
+ message: 'resourceEventsTableName',
443
+ required: false,
444
+ skipPrompt: true,
445
+ },
446
+ {
447
+ type: 'text',
448
+ name: 'apiName',
449
+ message: 'apiName',
450
+ required: false,
451
+ skipPrompt: true,
452
+ },
453
+ {
454
+ type: 'text',
455
+ name: 'privateApiName',
456
+ message: 'privateApiName',
457
+ required: false,
458
+ skipPrompt: true,
459
+ },
460
+ {
461
+ type: 'text',
462
+ name: 'scope',
463
+ message: 'scope',
464
+ required: false,
465
+ skipPrompt: true,
466
+ },
467
+ {
468
+ type: 'text',
469
+ name: 'prefix',
470
+ message: 'prefix',
471
+ required: false,
472
+ skipPrompt: true,
473
+ },
474
+ {
475
+ type: 'text',
476
+ name: 'entityTableId',
477
+ message: 'entityTableId',
478
+ required: false,
479
+ skipPrompt: true,
480
+ },
481
+ {
482
+ type: 'text',
483
+ name: 'namespaceModuleId',
484
+ message: 'namespaceModuleId',
485
+ required: false,
486
+ skipPrompt: true,
487
+ },
488
+ {
489
+ type: 'json',
490
+ name: 'policies',
491
+ message: 'policies',
492
+ required: false,
493
+ skipPrompt: true,
494
+ },
495
+ {
496
+ type: 'json',
497
+ name: 'provisions',
498
+ message: 'provisions',
499
+ required: false,
500
+ skipPrompt: true,
501
+ },
502
+ {
503
+ type: 'text',
504
+ name: 'defaultPermissions',
505
+ message: 'defaultPermissions',
506
+ required: false,
507
+ skipPrompt: true,
508
+ },
509
+ ]);
510
+ const answers = coerceAnswers(rawAnswers, fieldSchema);
511
+ const cleanedData = stripUndefined(answers, fieldSchema);
512
+ const client = getClient();
513
+ const result = await client.resourceModule
514
+ .update({
515
+ where: {
516
+ id: answers.id,
517
+ },
518
+ data: {
519
+ databaseId: cleanedData.databaseId,
520
+ schemaId: cleanedData.schemaId,
521
+ privateSchemaId: cleanedData.privateSchemaId,
522
+ publicSchemaName: cleanedData.publicSchemaName,
523
+ privateSchemaName: cleanedData.privateSchemaName,
524
+ resourcesTableId: cleanedData.resourcesTableId,
525
+ resourceEventsTableId: cleanedData.resourceEventsTableId,
526
+ resourcesTableName: cleanedData.resourcesTableName,
527
+ resourceEventsTableName: cleanedData.resourceEventsTableName,
528
+ apiName: cleanedData.apiName,
529
+ privateApiName: cleanedData.privateApiName,
530
+ scope: cleanedData.scope,
531
+ prefix: cleanedData.prefix,
532
+ entityTableId: cleanedData.entityTableId,
533
+ namespaceModuleId: cleanedData.namespaceModuleId,
534
+ policies: cleanedData.policies,
535
+ provisions: cleanedData.provisions,
536
+ defaultPermissions: cleanedData.defaultPermissions,
537
+ },
538
+ select: {
539
+ id: true,
540
+ databaseId: true,
541
+ schemaId: true,
542
+ privateSchemaId: true,
543
+ publicSchemaName: true,
544
+ privateSchemaName: true,
545
+ resourcesTableId: true,
546
+ resourceEventsTableId: true,
547
+ resourcesTableName: true,
548
+ resourceEventsTableName: true,
549
+ apiName: true,
550
+ privateApiName: true,
551
+ scope: true,
552
+ prefix: true,
553
+ entityTableId: true,
554
+ namespaceModuleId: true,
555
+ policies: true,
556
+ provisions: true,
557
+ defaultPermissions: true,
558
+ },
559
+ })
560
+ .execute();
561
+ console.log(JSON.stringify(result, null, 2));
562
+ }
563
+ catch (error) {
564
+ console.error('Failed to update record.');
565
+ if (error instanceof Error) {
566
+ console.error(error.message);
567
+ }
568
+ process.exit(1);
569
+ }
570
+ }
571
+ async function handleDelete(argv, prompter) {
572
+ try {
573
+ const rawAnswers = await prompter.prompt(argv, [
574
+ {
575
+ type: 'text',
576
+ name: 'id',
577
+ message: 'id',
578
+ required: true,
579
+ },
580
+ ]);
581
+ const answers = coerceAnswers(rawAnswers, fieldSchema);
582
+ const client = getClient();
583
+ const result = await client.resourceModule
584
+ .delete({
585
+ where: {
586
+ id: answers.id,
587
+ },
588
+ select: {
589
+ id: true,
590
+ },
591
+ })
592
+ .execute();
593
+ console.log(JSON.stringify(result, null, 2));
594
+ }
595
+ catch (error) {
596
+ console.error('Failed to delete record.');
597
+ if (error instanceof Error) {
598
+ console.error(error.message);
599
+ }
600
+ process.exit(1);
601
+ }
602
+ }