@constructive-sdk/cli 0.12.16 → 0.12.18

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 (73) hide show
  1. package/esm/public/cli/commands/blueprint-construction.d.ts +8 -0
  2. package/esm/public/cli/commands/blueprint-construction.js +392 -0
  3. package/esm/public/cli/commands/blueprint.js +0 -110
  4. package/esm/public/cli/commands/construct-blueprint.js +1 -1
  5. package/esm/public/cli/commands/provision-full-text-search.d.ts +8 -0
  6. package/esm/public/cli/commands/provision-full-text-search.js +34 -0
  7. package/esm/public/cli/commands/provision-index.d.ts +8 -0
  8. package/esm/public/cli/commands/provision-index.js +34 -0
  9. package/esm/public/cli/commands/provision-relation.d.ts +8 -0
  10. package/esm/public/cli/commands/provision-relation.js +34 -0
  11. package/esm/public/cli/commands/provision-table.d.ts +8 -0
  12. package/esm/public/cli/commands/provision-table.js +34 -0
  13. package/esm/public/cli/commands/provision-unique-constraint.d.ts +8 -0
  14. package/esm/public/cli/commands/provision-unique-constraint.js +34 -0
  15. package/esm/public/cli/commands/relation-provision.js +12 -34
  16. package/esm/public/cli/commands/resolve-blueprint-table.d.ts +8 -0
  17. package/esm/public/cli/commands/resolve-blueprint-table.js +48 -0
  18. package/esm/public/cli/commands/secure-table-provision.js +14 -36
  19. package/esm/public/cli/commands/storage-module.d.ts +8 -0
  20. package/esm/public/cli/commands/storage-module.js +536 -0
  21. package/esm/public/cli/commands.js +27 -11
  22. package/esm/public/cli/executor.d.ts +49 -17
  23. package/esm/public/orm/index.d.ts +53 -19
  24. package/esm/public/orm/index.js +8 -4
  25. package/esm/public/orm/input-types.d.ts +886 -249
  26. package/esm/public/orm/input-types.js +5 -0
  27. package/esm/public/orm/models/blueprintConstruction.d.ts +56 -0
  28. package/esm/public/orm/models/blueprintConstruction.js +96 -0
  29. package/esm/public/orm/models/index.d.ts +4 -2
  30. package/esm/public/orm/models/index.js +4 -2
  31. package/esm/public/orm/models/storageModule.d.ts +56 -0
  32. package/esm/public/orm/models/storageModule.js +96 -0
  33. package/esm/public/orm/mutation/index.d.ts +86 -26
  34. package/esm/public/orm/mutation/index.js +96 -36
  35. package/esm/public/orm/query/index.d.ts +16 -0
  36. package/esm/public/orm/query/index.js +28 -0
  37. package/package.json +3 -3
  38. package/public/cli/commands/blueprint-construction.d.ts +8 -0
  39. package/public/cli/commands/blueprint-construction.js +394 -0
  40. package/public/cli/commands/blueprint.js +0 -110
  41. package/public/cli/commands/construct-blueprint.js +1 -1
  42. package/public/cli/commands/provision-full-text-search.d.ts +8 -0
  43. package/public/cli/commands/provision-full-text-search.js +36 -0
  44. package/public/cli/commands/provision-index.d.ts +8 -0
  45. package/public/cli/commands/provision-index.js +36 -0
  46. package/public/cli/commands/provision-relation.d.ts +8 -0
  47. package/public/cli/commands/provision-relation.js +36 -0
  48. package/public/cli/commands/provision-table.d.ts +8 -0
  49. package/public/cli/commands/provision-table.js +36 -0
  50. package/public/cli/commands/provision-unique-constraint.d.ts +8 -0
  51. package/public/cli/commands/provision-unique-constraint.js +36 -0
  52. package/public/cli/commands/relation-provision.js +12 -34
  53. package/public/cli/commands/resolve-blueprint-table.d.ts +8 -0
  54. package/public/cli/commands/resolve-blueprint-table.js +50 -0
  55. package/public/cli/commands/secure-table-provision.js +14 -36
  56. package/public/cli/commands/storage-module.d.ts +8 -0
  57. package/public/cli/commands/storage-module.js +538 -0
  58. package/public/cli/commands.js +27 -11
  59. package/public/cli/executor.d.ts +49 -17
  60. package/public/orm/index.d.ts +53 -19
  61. package/public/orm/index.js +8 -4
  62. package/public/orm/input-types.d.ts +886 -249
  63. package/public/orm/input-types.js +5 -0
  64. package/public/orm/models/blueprintConstruction.d.ts +56 -0
  65. package/public/orm/models/blueprintConstruction.js +100 -0
  66. package/public/orm/models/index.d.ts +4 -2
  67. package/public/orm/models/index.js +11 -7
  68. package/public/orm/models/storageModule.d.ts +56 -0
  69. package/public/orm/models/storageModule.js +100 -0
  70. package/public/orm/mutation/index.d.ts +86 -26
  71. package/public/orm/mutation/index.js +96 -36
  72. package/public/orm/query/index.d.ts +16 -0
  73. package/public/orm/query/index.js +28 -0
@@ -194,30 +194,6 @@ export function createMutationOperations(client) {
194
194
  },
195
195
  ], connectionFieldsMap, 'RemoveNodeAtPathPayload'),
196
196
  }),
197
- setDataAtPath: (args, options) => new QueryBuilder({
198
- client,
199
- operation: 'mutation',
200
- operationName: 'SetDataAtPath',
201
- fieldName: 'setDataAtPath',
202
- ...buildCustomDocument('mutation', 'SetDataAtPath', 'setDataAtPath', options.select, args, [
203
- {
204
- name: 'input',
205
- type: 'SetDataAtPathInput!',
206
- },
207
- ], connectionFieldsMap, 'SetDataAtPathPayload'),
208
- }),
209
- setPropsAndCommit: (args, options) => new QueryBuilder({
210
- client,
211
- operation: 'mutation',
212
- operationName: 'SetPropsAndCommit',
213
- fieldName: 'setPropsAndCommit',
214
- ...buildCustomDocument('mutation', 'SetPropsAndCommit', 'setPropsAndCommit', options.select, args, [
215
- {
216
- name: 'input',
217
- type: 'SetPropsAndCommitInput!',
218
- },
219
- ], connectionFieldsMap, 'SetPropsAndCommitPayload'),
220
- }),
221
197
  copyTemplateToBlueprint: (args, options) => new QueryBuilder({
222
198
  client,
223
199
  operation: 'mutation',
@@ -230,18 +206,6 @@ export function createMutationOperations(client) {
230
206
  },
231
207
  ], connectionFieldsMap, 'CopyTemplateToBlueprintPayload'),
232
208
  }),
233
- provisionDatabaseWithUser: (args, options) => new QueryBuilder({
234
- client,
235
- operation: 'mutation',
236
- operationName: 'ProvisionDatabaseWithUser',
237
- fieldName: 'provisionDatabaseWithUser',
238
- ...buildCustomDocument('mutation', 'ProvisionDatabaseWithUser', 'provisionDatabaseWithUser', options.select, args, [
239
- {
240
- name: 'input',
241
- type: 'ProvisionDatabaseWithUserInput!',
242
- },
243
- ], connectionFieldsMap, 'ProvisionDatabaseWithUserPayload'),
244
- }),
245
209
  bootstrapUser: (args, options) => new QueryBuilder({
246
210
  client,
247
211
  operation: 'mutation',
@@ -266,6 +230,78 @@ export function createMutationOperations(client) {
266
230
  },
267
231
  ], connectionFieldsMap, 'SetFieldOrderPayload'),
268
232
  }),
233
+ provisionUniqueConstraint: (args, options) => new QueryBuilder({
234
+ client,
235
+ operation: 'mutation',
236
+ operationName: 'ProvisionUniqueConstraint',
237
+ fieldName: 'provisionUniqueConstraint',
238
+ ...buildCustomDocument('mutation', 'ProvisionUniqueConstraint', 'provisionUniqueConstraint', options.select, args, [
239
+ {
240
+ name: 'input',
241
+ type: 'ProvisionUniqueConstraintInput!',
242
+ },
243
+ ], connectionFieldsMap, 'ProvisionUniqueConstraintPayload'),
244
+ }),
245
+ provisionFullTextSearch: (args, options) => new QueryBuilder({
246
+ client,
247
+ operation: 'mutation',
248
+ operationName: 'ProvisionFullTextSearch',
249
+ fieldName: 'provisionFullTextSearch',
250
+ ...buildCustomDocument('mutation', 'ProvisionFullTextSearch', 'provisionFullTextSearch', options.select, args, [
251
+ {
252
+ name: 'input',
253
+ type: 'ProvisionFullTextSearchInput!',
254
+ },
255
+ ], connectionFieldsMap, 'ProvisionFullTextSearchPayload'),
256
+ }),
257
+ provisionIndex: (args, options) => new QueryBuilder({
258
+ client,
259
+ operation: 'mutation',
260
+ operationName: 'ProvisionIndex',
261
+ fieldName: 'provisionIndex',
262
+ ...buildCustomDocument('mutation', 'ProvisionIndex', 'provisionIndex', options.select, args, [
263
+ {
264
+ name: 'input',
265
+ type: 'ProvisionIndexInput!',
266
+ },
267
+ ], connectionFieldsMap, 'ProvisionIndexPayload'),
268
+ }),
269
+ setDataAtPath: (args, options) => new QueryBuilder({
270
+ client,
271
+ operation: 'mutation',
272
+ operationName: 'SetDataAtPath',
273
+ fieldName: 'setDataAtPath',
274
+ ...buildCustomDocument('mutation', 'SetDataAtPath', 'setDataAtPath', options.select, args, [
275
+ {
276
+ name: 'input',
277
+ type: 'SetDataAtPathInput!',
278
+ },
279
+ ], connectionFieldsMap, 'SetDataAtPathPayload'),
280
+ }),
281
+ setPropsAndCommit: (args, options) => new QueryBuilder({
282
+ client,
283
+ operation: 'mutation',
284
+ operationName: 'SetPropsAndCommit',
285
+ fieldName: 'setPropsAndCommit',
286
+ ...buildCustomDocument('mutation', 'SetPropsAndCommit', 'setPropsAndCommit', options.select, args, [
287
+ {
288
+ name: 'input',
289
+ type: 'SetPropsAndCommitInput!',
290
+ },
291
+ ], connectionFieldsMap, 'SetPropsAndCommitPayload'),
292
+ }),
293
+ provisionDatabaseWithUser: (args, options) => new QueryBuilder({
294
+ client,
295
+ operation: 'mutation',
296
+ operationName: 'ProvisionDatabaseWithUser',
297
+ fieldName: 'provisionDatabaseWithUser',
298
+ ...buildCustomDocument('mutation', 'ProvisionDatabaseWithUser', 'provisionDatabaseWithUser', options.select, args, [
299
+ {
300
+ name: 'input',
301
+ type: 'ProvisionDatabaseWithUserInput!',
302
+ },
303
+ ], connectionFieldsMap, 'ProvisionDatabaseWithUserPayload'),
304
+ }),
269
305
  insertNodeAtPath: (args, options) => new QueryBuilder({
270
306
  client,
271
307
  operation: 'mutation',
@@ -302,6 +338,18 @@ export function createMutationOperations(client) {
302
338
  },
303
339
  ], connectionFieldsMap, 'SetAndCommitPayload'),
304
340
  }),
341
+ provisionRelation: (args, options) => new QueryBuilder({
342
+ client,
343
+ operation: 'mutation',
344
+ operationName: 'ProvisionRelation',
345
+ fieldName: 'provisionRelation',
346
+ ...buildCustomDocument('mutation', 'ProvisionRelation', 'provisionRelation', options.select, args, [
347
+ {
348
+ name: 'input',
349
+ type: 'ProvisionRelationInput!',
350
+ },
351
+ ], connectionFieldsMap, 'ProvisionRelationPayload'),
352
+ }),
305
353
  applyRls: (args, options) => new QueryBuilder({
306
354
  client,
307
355
  operation: 'mutation',
@@ -386,6 +434,18 @@ export function createMutationOperations(client) {
386
434
  },
387
435
  ], connectionFieldsMap, 'OneTimeTokenPayload'),
388
436
  }),
437
+ provisionTable: (args, options) => new QueryBuilder({
438
+ client,
439
+ operation: 'mutation',
440
+ operationName: 'ProvisionTable',
441
+ fieldName: 'provisionTable',
442
+ ...buildCustomDocument('mutation', 'ProvisionTable', 'provisionTable', options.select, args, [
443
+ {
444
+ name: 'input',
445
+ type: 'ProvisionTableInput!',
446
+ },
447
+ ], connectionFieldsMap, 'ProvisionTablePayload'),
448
+ }),
389
449
  sendVerificationEmail: (args, options) => new QueryBuilder({
390
450
  client,
391
451
  operation: 'mutation',
@@ -34,6 +34,17 @@ export interface AppPermissionsGetMaskVariables {
34
34
  export interface OrgPermissionsGetMaskVariables {
35
35
  ids?: string[];
36
36
  }
37
+ /**
38
+ * Variables for resolveBlueprintTable
39
+ * Resolves a table_name (with optional schema_name) to a table_id. Resolution order: (1) if schema_name provided, exact lookup via metaschema_public.schema.name + metaschema_public.table; (2) check local table_map (tables created in current blueprint); (3) search metaschema_public.table by name across all schemas; (4) if multiple matches, throw ambiguous error asking for schema_name; (5) if no match, throw not-found error.
40
+ */
41
+ export interface ResolveBlueprintTableVariables {
42
+ databaseId?: string;
43
+ tableName?: string;
44
+ schemaName?: string;
45
+ tableMap?: unknown;
46
+ defaultSchemaId?: string;
47
+ }
37
48
  export interface AppPermissionsGetMaskByNamesVariables {
38
49
  names?: string[];
39
50
  }
@@ -161,6 +172,11 @@ export declare function createQueryOperations(client: OrmClient): {
161
172
  }) => QueryBuilder<{
162
173
  orgPermissionsGetMask: string | null;
163
174
  }>;
175
+ resolveBlueprintTable: (args: ResolveBlueprintTableVariables, options?: {
176
+ select?: Record<string, unknown>;
177
+ }) => QueryBuilder<{
178
+ resolveBlueprintTable: string | null;
179
+ }>;
164
180
  appPermissionsGetMaskByNames: (args: AppPermissionsGetMaskByNamesVariables, options?: {
165
181
  select?: Record<string, unknown>;
166
182
  }) => QueryBuilder<{
@@ -131,6 +131,34 @@ export function createQueryOperations(client) {
131
131
  },
132
132
  ], connectionFieldsMap, undefined),
133
133
  }),
134
+ resolveBlueprintTable: (args, options) => new QueryBuilder({
135
+ client,
136
+ operation: 'query',
137
+ operationName: 'ResolveBlueprintTable',
138
+ fieldName: 'resolveBlueprintTable',
139
+ ...buildCustomDocument('query', 'ResolveBlueprintTable', 'resolveBlueprintTable', options?.select, args, [
140
+ {
141
+ name: 'databaseId',
142
+ type: 'UUID',
143
+ },
144
+ {
145
+ name: 'tableName',
146
+ type: 'String',
147
+ },
148
+ {
149
+ name: 'schemaName',
150
+ type: 'String',
151
+ },
152
+ {
153
+ name: 'tableMap',
154
+ type: 'JSON',
155
+ },
156
+ {
157
+ name: 'defaultSchemaId',
158
+ type: 'UUID',
159
+ },
160
+ ], connectionFieldsMap, undefined),
161
+ }),
134
162
  appPermissionsGetMaskByNames: (args, options) => new QueryBuilder({
135
163
  client,
136
164
  operation: 'query',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-sdk/cli",
3
- "version": "0.12.16",
3
+ "version": "0.12.18",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive CLI SDK - Auto-generated GraphQL CLI with ORM client, context management, and interactive prompts",
6
6
  "main": "index.js",
@@ -55,11 +55,11 @@
55
55
  "yanse": "^0.2.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@constructive-io/graphql-codegen": "^4.28.1",
58
+ "@constructive-io/graphql-codegen": "^4.28.2",
59
59
  "@types/node": "^22.19.11",
60
60
  "makage": "^0.3.0",
61
61
  "tsx": "^4.19.0",
62
62
  "typescript": "^5.9.3"
63
63
  },
64
- "gitHead": "fc23b83307d007a14e54b1d0fc36614b9650a5dc"
64
+ "gitHead": "f1a0d4315e0f23ba6b8299a7dc2ddceab465d24d"
65
65
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CLI commands for BlueprintConstruction
3
+ * @generated by @constructive-io/graphql-codegen
4
+ * DO NOT EDIT - changes will be overwritten
5
+ */
6
+ import { CLIOptions, Inquirerer } from 'inquirerer';
7
+ declare const _default: (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
8
+ export default _default;
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * CLI commands for BlueprintConstruction
5
+ * @generated by @constructive-io/graphql-codegen
6
+ * DO NOT EDIT - changes will be overwritten
7
+ */
8
+ const inquirerer_1 = require("inquirerer");
9
+ const executor_1 = require("../executor");
10
+ const utils_1 = require("../utils");
11
+ const fieldSchema = {
12
+ id: 'uuid',
13
+ blueprintId: 'uuid',
14
+ databaseId: 'uuid',
15
+ schemaId: 'uuid',
16
+ status: 'string',
17
+ errorDetails: 'string',
18
+ tableMap: 'json',
19
+ constructedDefinition: 'json',
20
+ constructedAt: 'string',
21
+ createdAt: 'string',
22
+ updatedAt: 'string',
23
+ };
24
+ const usage = '\nblueprint-construction <command>\n\nCommands:\n list List blueprintConstruction records\n find-first Find first matching blueprintConstruction record\n get Get a blueprintConstruction by ID\n create Create a new blueprintConstruction\n update Update an existing blueprintConstruction\n delete Delete a blueprintConstruction\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\n --help, -h Show this help message\n';
25
+ exports.default = async (argv, prompter, _options) => {
26
+ if (argv.help || argv.h) {
27
+ console.log(usage);
28
+ process.exit(0);
29
+ }
30
+ const { first: subcommand, newArgv } = (0, inquirerer_1.extractFirst)(argv);
31
+ if (!subcommand) {
32
+ const answer = await prompter.prompt(argv, [
33
+ {
34
+ type: 'autocomplete',
35
+ name: 'subcommand',
36
+ message: 'What do you want to do?',
37
+ options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
38
+ },
39
+ ]);
40
+ return handleTableSubcommand(answer.subcommand, newArgv, prompter);
41
+ }
42
+ return handleTableSubcommand(subcommand, newArgv, prompter);
43
+ };
44
+ async function handleTableSubcommand(subcommand, argv, prompter) {
45
+ switch (subcommand) {
46
+ case 'list':
47
+ return handleList(argv, prompter);
48
+ case 'find-first':
49
+ return handleFindFirst(argv, prompter);
50
+ case 'get':
51
+ return handleGet(argv, prompter);
52
+ case 'create':
53
+ return handleCreate(argv, prompter);
54
+ case 'update':
55
+ return handleUpdate(argv, prompter);
56
+ case 'delete':
57
+ return handleDelete(argv, prompter);
58
+ default:
59
+ console.log(usage);
60
+ process.exit(1);
61
+ }
62
+ }
63
+ async function handleList(argv, _prompter) {
64
+ try {
65
+ const defaultSelect = {
66
+ id: true,
67
+ blueprintId: true,
68
+ databaseId: true,
69
+ schemaId: true,
70
+ status: true,
71
+ errorDetails: true,
72
+ tableMap: true,
73
+ constructedDefinition: true,
74
+ constructedAt: true,
75
+ createdAt: true,
76
+ updatedAt: true,
77
+ };
78
+ const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
79
+ const client = (0, executor_1.getClient)();
80
+ const result = await client.blueprintConstruction.findMany(findManyArgs).execute();
81
+ console.log(JSON.stringify(result, null, 2));
82
+ }
83
+ catch (error) {
84
+ console.error('Failed to list records.');
85
+ if (error instanceof Error) {
86
+ console.error(error.message);
87
+ }
88
+ process.exit(1);
89
+ }
90
+ }
91
+ async function handleFindFirst(argv, _prompter) {
92
+ try {
93
+ const defaultSelect = {
94
+ id: true,
95
+ blueprintId: true,
96
+ databaseId: true,
97
+ schemaId: true,
98
+ status: true,
99
+ errorDetails: true,
100
+ tableMap: true,
101
+ constructedDefinition: true,
102
+ constructedAt: true,
103
+ createdAt: true,
104
+ updatedAt: true,
105
+ };
106
+ const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
107
+ const client = (0, executor_1.getClient)();
108
+ const result = await client.blueprintConstruction.findFirst(findFirstArgs).execute();
109
+ console.log(JSON.stringify(result, null, 2));
110
+ }
111
+ catch (error) {
112
+ console.error('Failed to find record.');
113
+ if (error instanceof Error) {
114
+ console.error(error.message);
115
+ }
116
+ process.exit(1);
117
+ }
118
+ }
119
+ async function handleGet(argv, prompter) {
120
+ try {
121
+ const answers = await prompter.prompt(argv, [
122
+ {
123
+ type: 'text',
124
+ name: 'id',
125
+ message: 'id',
126
+ required: true,
127
+ },
128
+ ]);
129
+ const client = (0, executor_1.getClient)();
130
+ const result = await client.blueprintConstruction
131
+ .findOne({
132
+ id: answers.id,
133
+ select: {
134
+ id: true,
135
+ blueprintId: true,
136
+ databaseId: true,
137
+ schemaId: true,
138
+ status: true,
139
+ errorDetails: true,
140
+ tableMap: true,
141
+ constructedDefinition: true,
142
+ constructedAt: true,
143
+ createdAt: true,
144
+ updatedAt: true,
145
+ },
146
+ })
147
+ .execute();
148
+ console.log(JSON.stringify(result, null, 2));
149
+ }
150
+ catch (error) {
151
+ console.error('Record not found.');
152
+ if (error instanceof Error) {
153
+ console.error(error.message);
154
+ }
155
+ process.exit(1);
156
+ }
157
+ }
158
+ async function handleCreate(argv, prompter) {
159
+ try {
160
+ const rawAnswers = await prompter.prompt(argv, [
161
+ {
162
+ type: 'text',
163
+ name: 'blueprintId',
164
+ message: 'blueprintId',
165
+ required: true,
166
+ },
167
+ {
168
+ type: 'text',
169
+ name: 'databaseId',
170
+ message: 'databaseId',
171
+ required: true,
172
+ },
173
+ {
174
+ type: 'text',
175
+ name: 'schemaId',
176
+ message: 'schemaId',
177
+ required: false,
178
+ skipPrompt: true,
179
+ },
180
+ {
181
+ type: 'text',
182
+ name: 'status',
183
+ message: 'status',
184
+ required: false,
185
+ skipPrompt: true,
186
+ },
187
+ {
188
+ type: 'text',
189
+ name: 'errorDetails',
190
+ message: 'errorDetails',
191
+ required: false,
192
+ skipPrompt: true,
193
+ },
194
+ {
195
+ type: 'json',
196
+ name: 'tableMap',
197
+ message: 'tableMap',
198
+ required: false,
199
+ skipPrompt: true,
200
+ },
201
+ {
202
+ type: 'json',
203
+ name: 'constructedDefinition',
204
+ message: 'constructedDefinition',
205
+ required: false,
206
+ skipPrompt: true,
207
+ },
208
+ {
209
+ type: 'text',
210
+ name: 'constructedAt',
211
+ message: 'constructedAt',
212
+ required: false,
213
+ skipPrompt: true,
214
+ },
215
+ ]);
216
+ const answers = (0, utils_1.coerceAnswers)(rawAnswers, fieldSchema);
217
+ const cleanedData = (0, utils_1.stripUndefined)(answers, fieldSchema);
218
+ const client = (0, executor_1.getClient)();
219
+ const result = await client.blueprintConstruction
220
+ .create({
221
+ data: {
222
+ blueprintId: cleanedData.blueprintId,
223
+ databaseId: cleanedData.databaseId,
224
+ schemaId: cleanedData.schemaId,
225
+ status: cleanedData.status,
226
+ errorDetails: cleanedData.errorDetails,
227
+ tableMap: cleanedData.tableMap,
228
+ constructedDefinition: cleanedData.constructedDefinition,
229
+ constructedAt: cleanedData.constructedAt,
230
+ },
231
+ select: {
232
+ id: true,
233
+ blueprintId: true,
234
+ databaseId: true,
235
+ schemaId: true,
236
+ status: true,
237
+ errorDetails: true,
238
+ tableMap: true,
239
+ constructedDefinition: true,
240
+ constructedAt: true,
241
+ createdAt: true,
242
+ updatedAt: true,
243
+ },
244
+ })
245
+ .execute();
246
+ console.log(JSON.stringify(result, null, 2));
247
+ }
248
+ catch (error) {
249
+ console.error('Failed to create record.');
250
+ if (error instanceof Error) {
251
+ console.error(error.message);
252
+ }
253
+ process.exit(1);
254
+ }
255
+ }
256
+ async function handleUpdate(argv, prompter) {
257
+ try {
258
+ const rawAnswers = await prompter.prompt(argv, [
259
+ {
260
+ type: 'text',
261
+ name: 'id',
262
+ message: 'id',
263
+ required: true,
264
+ },
265
+ {
266
+ type: 'text',
267
+ name: 'blueprintId',
268
+ message: 'blueprintId',
269
+ required: false,
270
+ },
271
+ {
272
+ type: 'text',
273
+ name: 'databaseId',
274
+ message: 'databaseId',
275
+ required: false,
276
+ },
277
+ {
278
+ type: 'text',
279
+ name: 'schemaId',
280
+ message: 'schemaId',
281
+ required: false,
282
+ skipPrompt: true,
283
+ },
284
+ {
285
+ type: 'text',
286
+ name: 'status',
287
+ message: 'status',
288
+ required: false,
289
+ skipPrompt: true,
290
+ },
291
+ {
292
+ type: 'text',
293
+ name: 'errorDetails',
294
+ message: 'errorDetails',
295
+ required: false,
296
+ skipPrompt: true,
297
+ },
298
+ {
299
+ type: 'json',
300
+ name: 'tableMap',
301
+ message: 'tableMap',
302
+ required: false,
303
+ skipPrompt: true,
304
+ },
305
+ {
306
+ type: 'json',
307
+ name: 'constructedDefinition',
308
+ message: 'constructedDefinition',
309
+ required: false,
310
+ skipPrompt: true,
311
+ },
312
+ {
313
+ type: 'text',
314
+ name: 'constructedAt',
315
+ message: 'constructedAt',
316
+ required: false,
317
+ skipPrompt: true,
318
+ },
319
+ ]);
320
+ const answers = (0, utils_1.coerceAnswers)(rawAnswers, fieldSchema);
321
+ const cleanedData = (0, utils_1.stripUndefined)(answers, fieldSchema);
322
+ const client = (0, executor_1.getClient)();
323
+ const result = await client.blueprintConstruction
324
+ .update({
325
+ where: {
326
+ id: answers.id,
327
+ },
328
+ data: {
329
+ blueprintId: cleanedData.blueprintId,
330
+ databaseId: cleanedData.databaseId,
331
+ schemaId: cleanedData.schemaId,
332
+ status: cleanedData.status,
333
+ errorDetails: cleanedData.errorDetails,
334
+ tableMap: cleanedData.tableMap,
335
+ constructedDefinition: cleanedData.constructedDefinition,
336
+ constructedAt: cleanedData.constructedAt,
337
+ },
338
+ select: {
339
+ id: true,
340
+ blueprintId: true,
341
+ databaseId: true,
342
+ schemaId: true,
343
+ status: true,
344
+ errorDetails: true,
345
+ tableMap: true,
346
+ constructedDefinition: true,
347
+ constructedAt: true,
348
+ createdAt: true,
349
+ updatedAt: true,
350
+ },
351
+ })
352
+ .execute();
353
+ console.log(JSON.stringify(result, null, 2));
354
+ }
355
+ catch (error) {
356
+ console.error('Failed to update record.');
357
+ if (error instanceof Error) {
358
+ console.error(error.message);
359
+ }
360
+ process.exit(1);
361
+ }
362
+ }
363
+ async function handleDelete(argv, prompter) {
364
+ try {
365
+ const rawAnswers = await prompter.prompt(argv, [
366
+ {
367
+ type: 'text',
368
+ name: 'id',
369
+ message: 'id',
370
+ required: true,
371
+ },
372
+ ]);
373
+ const answers = (0, utils_1.coerceAnswers)(rawAnswers, fieldSchema);
374
+ const client = (0, executor_1.getClient)();
375
+ const result = await client.blueprintConstruction
376
+ .delete({
377
+ where: {
378
+ id: answers.id,
379
+ },
380
+ select: {
381
+ id: true,
382
+ },
383
+ })
384
+ .execute();
385
+ console.log(JSON.stringify(result, null, 2));
386
+ }
387
+ catch (error) {
388
+ console.error('Failed to delete record.');
389
+ if (error instanceof Error) {
390
+ console.error(error.message);
391
+ }
392
+ process.exit(1);
393
+ }
394
+ }