@constructive-sdk/cli 0.12.1 → 0.12.4

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 (41) hide show
  1. package/esm/public/cli/commands/{field-module.d.ts → migrate-file.d.ts} +1 -1
  2. package/esm/public/cli/commands/migrate-file.js +110 -0
  3. package/{public/cli/commands/field-module.d.ts → esm/public/cli/commands/sql-action.d.ts} +1 -1
  4. package/esm/public/cli/commands/{sql-migration.js → sql-action.js} +4 -4
  5. package/esm/public/cli/commands.js +5 -5
  6. package/esm/public/cli/executor.d.ts +2 -2
  7. package/esm/public/orm/index.d.ts +4 -4
  8. package/esm/public/orm/index.js +4 -4
  9. package/esm/public/orm/input-types.d.ts +118 -247
  10. package/esm/public/orm/input-types.js +0 -1
  11. package/esm/public/orm/models/index.d.ts +2 -2
  12. package/esm/public/orm/models/index.js +2 -2
  13. package/esm/public/orm/models/migrateFile.d.ts +38 -0
  14. package/esm/public/orm/models/migrateFile.js +72 -0
  15. package/esm/public/orm/models/sqlAction.d.ts +38 -0
  16. package/esm/public/orm/models/{sqlMigration.js → sqlAction.js} +17 -17
  17. package/package.json +5 -5
  18. package/{esm/public/cli/commands/sql-migration.d.ts → public/cli/commands/migrate-file.d.ts} +1 -1
  19. package/public/cli/commands/migrate-file.js +112 -0
  20. package/public/cli/commands/{sql-migration.d.ts → sql-action.d.ts} +1 -1
  21. package/public/cli/commands/{sql-migration.js → sql-action.js} +4 -4
  22. package/public/cli/commands.js +5 -5
  23. package/public/cli/executor.d.ts +2 -2
  24. package/public/orm/index.d.ts +4 -4
  25. package/public/orm/index.js +4 -4
  26. package/public/orm/input-types.d.ts +118 -247
  27. package/public/orm/input-types.js +0 -1
  28. package/public/orm/models/index.d.ts +2 -2
  29. package/public/orm/models/index.js +7 -7
  30. package/public/orm/models/migrateFile.d.ts +38 -0
  31. package/public/orm/models/{sqlMigration.js → migrateFile.js} +19 -19
  32. package/public/orm/models/sqlAction.d.ts +38 -0
  33. package/public/orm/models/sqlAction.js +76 -0
  34. package/esm/public/cli/commands/field-module.js +0 -354
  35. package/esm/public/orm/models/fieldModule.d.ts +0 -56
  36. package/esm/public/orm/models/fieldModule.js +0 -96
  37. package/esm/public/orm/models/sqlMigration.d.ts +0 -38
  38. package/public/cli/commands/field-module.js +0 -356
  39. package/public/orm/models/fieldModule.d.ts +0 -56
  40. package/public/orm/models/fieldModule.js +0 -100
  41. package/public/orm/models/sqlMigration.d.ts +0 -38
@@ -1,354 +0,0 @@
1
- /**
2
- * CLI commands for FieldModule
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, stripUndefined } from '../utils';
9
- const fieldSchema = {
10
- id: 'uuid',
11
- databaseId: 'uuid',
12
- privateSchemaId: 'uuid',
13
- tableId: 'uuid',
14
- fieldId: 'uuid',
15
- nodeType: 'string',
16
- data: 'json',
17
- triggers: 'string',
18
- functions: 'string',
19
- };
20
- const usage = '\nfield-module <command>\n\nCommands:\n list List all fieldModule records\n get Get a fieldModule by ID\n create Create a new fieldModule\n update Update an existing fieldModule\n delete Delete a fieldModule\n\n --help, -h Show this help message\n';
21
- export default async (argv, prompter, _options) => {
22
- if (argv.help || argv.h) {
23
- console.log(usage);
24
- process.exit(0);
25
- }
26
- const { first: subcommand, newArgv } = extractFirst(argv);
27
- if (!subcommand) {
28
- const answer = await prompter.prompt(argv, [
29
- {
30
- type: 'autocomplete',
31
- name: 'subcommand',
32
- message: 'What do you want to do?',
33
- options: ['list', 'get', 'create', 'update', 'delete'],
34
- },
35
- ]);
36
- return handleTableSubcommand(answer.subcommand, newArgv, prompter);
37
- }
38
- return handleTableSubcommand(subcommand, newArgv, prompter);
39
- };
40
- async function handleTableSubcommand(subcommand, argv, prompter) {
41
- switch (subcommand) {
42
- case 'list':
43
- return handleList(argv, prompter);
44
- case 'get':
45
- return handleGet(argv, prompter);
46
- case 'create':
47
- return handleCreate(argv, prompter);
48
- case 'update':
49
- return handleUpdate(argv, prompter);
50
- case 'delete':
51
- return handleDelete(argv, prompter);
52
- default:
53
- console.log(usage);
54
- process.exit(1);
55
- }
56
- }
57
- async function handleList(_argv, _prompter) {
58
- try {
59
- const client = getClient();
60
- const result = await client.fieldModule
61
- .findMany({
62
- select: {
63
- id: true,
64
- databaseId: true,
65
- privateSchemaId: true,
66
- tableId: true,
67
- fieldId: true,
68
- nodeType: true,
69
- data: true,
70
- triggers: true,
71
- functions: true,
72
- },
73
- })
74
- .execute();
75
- console.log(JSON.stringify(result, null, 2));
76
- }
77
- catch (error) {
78
- console.error('Failed to list records.');
79
- if (error instanceof Error) {
80
- console.error(error.message);
81
- }
82
- process.exit(1);
83
- }
84
- }
85
- async function handleGet(argv, prompter) {
86
- try {
87
- const answers = await prompter.prompt(argv, [
88
- {
89
- type: 'text',
90
- name: 'id',
91
- message: 'id',
92
- required: true,
93
- },
94
- ]);
95
- const client = getClient();
96
- const result = await client.fieldModule
97
- .findOne({
98
- id: answers.id,
99
- select: {
100
- id: true,
101
- databaseId: true,
102
- privateSchemaId: true,
103
- tableId: true,
104
- fieldId: true,
105
- nodeType: true,
106
- data: true,
107
- triggers: true,
108
- functions: true,
109
- },
110
- })
111
- .execute();
112
- console.log(JSON.stringify(result, null, 2));
113
- }
114
- catch (error) {
115
- console.error('Record not found.');
116
- if (error instanceof Error) {
117
- console.error(error.message);
118
- }
119
- process.exit(1);
120
- }
121
- }
122
- async function handleCreate(argv, prompter) {
123
- try {
124
- const rawAnswers = await prompter.prompt(argv, [
125
- {
126
- type: 'text',
127
- name: 'databaseId',
128
- message: 'databaseId',
129
- required: true,
130
- },
131
- {
132
- type: 'text',
133
- name: 'privateSchemaId',
134
- message: 'privateSchemaId',
135
- required: false,
136
- skipPrompt: true,
137
- },
138
- {
139
- type: 'text',
140
- name: 'tableId',
141
- message: 'tableId',
142
- required: false,
143
- skipPrompt: true,
144
- },
145
- {
146
- type: 'text',
147
- name: 'fieldId',
148
- message: 'fieldId',
149
- required: false,
150
- skipPrompt: true,
151
- },
152
- {
153
- type: 'text',
154
- name: 'nodeType',
155
- message: 'nodeType',
156
- required: true,
157
- },
158
- {
159
- type: 'json',
160
- name: 'data',
161
- message: 'data',
162
- required: false,
163
- skipPrompt: true,
164
- },
165
- {
166
- type: 'text',
167
- name: 'triggers',
168
- message: 'triggers',
169
- required: false,
170
- skipPrompt: true,
171
- },
172
- {
173
- type: 'text',
174
- name: 'functions',
175
- message: 'functions',
176
- required: false,
177
- skipPrompt: true,
178
- },
179
- ]);
180
- const answers = coerceAnswers(rawAnswers, fieldSchema);
181
- const cleanedData = stripUndefined(answers, fieldSchema);
182
- const client = getClient();
183
- const result = await client.fieldModule
184
- .create({
185
- data: {
186
- databaseId: cleanedData.databaseId,
187
- privateSchemaId: cleanedData.privateSchemaId,
188
- tableId: cleanedData.tableId,
189
- fieldId: cleanedData.fieldId,
190
- nodeType: cleanedData.nodeType,
191
- data: cleanedData.data,
192
- triggers: cleanedData.triggers,
193
- functions: cleanedData.functions,
194
- },
195
- select: {
196
- id: true,
197
- databaseId: true,
198
- privateSchemaId: true,
199
- tableId: true,
200
- fieldId: true,
201
- nodeType: true,
202
- data: true,
203
- triggers: true,
204
- functions: true,
205
- },
206
- })
207
- .execute();
208
- console.log(JSON.stringify(result, null, 2));
209
- }
210
- catch (error) {
211
- console.error('Failed to create record.');
212
- if (error instanceof Error) {
213
- console.error(error.message);
214
- }
215
- process.exit(1);
216
- }
217
- }
218
- async function handleUpdate(argv, prompter) {
219
- try {
220
- const rawAnswers = await prompter.prompt(argv, [
221
- {
222
- type: 'text',
223
- name: 'id',
224
- message: 'id',
225
- required: true,
226
- },
227
- {
228
- type: 'text',
229
- name: 'databaseId',
230
- message: 'databaseId',
231
- required: false,
232
- },
233
- {
234
- type: 'text',
235
- name: 'privateSchemaId',
236
- message: 'privateSchemaId',
237
- required: false,
238
- skipPrompt: true,
239
- },
240
- {
241
- type: 'text',
242
- name: 'tableId',
243
- message: 'tableId',
244
- required: false,
245
- skipPrompt: true,
246
- },
247
- {
248
- type: 'text',
249
- name: 'fieldId',
250
- message: 'fieldId',
251
- required: false,
252
- skipPrompt: true,
253
- },
254
- {
255
- type: 'text',
256
- name: 'nodeType',
257
- message: 'nodeType',
258
- required: false,
259
- },
260
- {
261
- type: 'json',
262
- name: 'data',
263
- message: 'data',
264
- required: false,
265
- skipPrompt: true,
266
- },
267
- {
268
- type: 'text',
269
- name: 'triggers',
270
- message: 'triggers',
271
- required: false,
272
- skipPrompt: true,
273
- },
274
- {
275
- type: 'text',
276
- name: 'functions',
277
- message: 'functions',
278
- required: false,
279
- skipPrompt: true,
280
- },
281
- ]);
282
- const answers = coerceAnswers(rawAnswers, fieldSchema);
283
- const cleanedData = stripUndefined(answers, fieldSchema);
284
- const client = getClient();
285
- const result = await client.fieldModule
286
- .update({
287
- where: {
288
- id: answers.id,
289
- },
290
- data: {
291
- databaseId: cleanedData.databaseId,
292
- privateSchemaId: cleanedData.privateSchemaId,
293
- tableId: cleanedData.tableId,
294
- fieldId: cleanedData.fieldId,
295
- nodeType: cleanedData.nodeType,
296
- data: cleanedData.data,
297
- triggers: cleanedData.triggers,
298
- functions: cleanedData.functions,
299
- },
300
- select: {
301
- id: true,
302
- databaseId: true,
303
- privateSchemaId: true,
304
- tableId: true,
305
- fieldId: true,
306
- nodeType: true,
307
- data: true,
308
- triggers: true,
309
- functions: true,
310
- },
311
- })
312
- .execute();
313
- console.log(JSON.stringify(result, null, 2));
314
- }
315
- catch (error) {
316
- console.error('Failed to update record.');
317
- if (error instanceof Error) {
318
- console.error(error.message);
319
- }
320
- process.exit(1);
321
- }
322
- }
323
- async function handleDelete(argv, prompter) {
324
- try {
325
- const rawAnswers = await prompter.prompt(argv, [
326
- {
327
- type: 'text',
328
- name: 'id',
329
- message: 'id',
330
- required: true,
331
- },
332
- ]);
333
- const answers = coerceAnswers(rawAnswers, fieldSchema);
334
- const client = getClient();
335
- const result = await client.fieldModule
336
- .delete({
337
- where: {
338
- id: answers.id,
339
- },
340
- select: {
341
- id: true,
342
- },
343
- })
344
- .execute();
345
- console.log(JSON.stringify(result, null, 2));
346
- }
347
- catch (error) {
348
- console.error('Failed to delete record.');
349
- if (error instanceof Error) {
350
- console.error(error.message);
351
- }
352
- process.exit(1);
353
- }
354
- }
@@ -1,56 +0,0 @@
1
- /**
2
- * FieldModule model for ORM client
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- import { QueryBuilder } from '../query-builder';
8
- import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, StrictSelect } from '../select-types';
9
- import type { FieldModuleWithRelations, FieldModuleSelect, FieldModuleFilter, FieldModuleOrderBy, CreateFieldModuleInput, FieldModulePatch } from '../input-types';
10
- export declare class FieldModuleModel {
11
- private client;
12
- constructor(client: OrmClient);
13
- findMany<S extends FieldModuleSelect>(args: FindManyArgs<S, FieldModuleFilter, never, FieldModuleOrderBy> & {
14
- select: S;
15
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
16
- fieldModules: ConnectionResult<InferSelectResult<FieldModuleWithRelations, S>>;
17
- }>;
18
- findFirst<S extends FieldModuleSelect>(args: FindFirstArgs<S, FieldModuleFilter> & {
19
- select: S;
20
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
21
- fieldModules: {
22
- nodes: InferSelectResult<FieldModuleWithRelations, S>[];
23
- };
24
- }>;
25
- findOne<S extends FieldModuleSelect>(args: {
26
- id: string;
27
- select: S;
28
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
29
- fieldModule: InferSelectResult<FieldModuleWithRelations, S> | null;
30
- }>;
31
- create<S extends FieldModuleSelect>(args: CreateArgs<S, CreateFieldModuleInput['fieldModule']> & {
32
- select: S;
33
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
34
- createFieldModule: {
35
- fieldModule: InferSelectResult<FieldModuleWithRelations, S>;
36
- };
37
- }>;
38
- update<S extends FieldModuleSelect>(args: UpdateArgs<S, {
39
- id: string;
40
- }, FieldModulePatch> & {
41
- select: S;
42
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
43
- updateFieldModule: {
44
- fieldModule: InferSelectResult<FieldModuleWithRelations, S>;
45
- };
46
- }>;
47
- delete<S extends FieldModuleSelect>(args: DeleteArgs<{
48
- id: string;
49
- }, S> & {
50
- select: S;
51
- } & StrictSelect<S, FieldModuleSelect>): QueryBuilder<{
52
- deleteFieldModule: {
53
- fieldModule: InferSelectResult<FieldModuleWithRelations, S>;
54
- };
55
- }>;
56
- }
@@ -1,96 +0,0 @@
1
- import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
2
- import { connectionFieldsMap } from '../input-types';
3
- export class FieldModuleModel {
4
- client;
5
- constructor(client) {
6
- this.client = client;
7
- }
8
- findMany(args) {
9
- const { document, variables } = buildFindManyDocument('FieldModule', 'fieldModules', args.select, {
10
- where: args?.where,
11
- orderBy: args?.orderBy,
12
- first: args?.first,
13
- last: args?.last,
14
- after: args?.after,
15
- before: args?.before,
16
- offset: args?.offset,
17
- }, 'FieldModuleFilter', 'FieldModuleOrderBy', connectionFieldsMap);
18
- return new QueryBuilder({
19
- client: this.client,
20
- operation: 'query',
21
- operationName: 'FieldModule',
22
- fieldName: 'fieldModules',
23
- document,
24
- variables,
25
- });
26
- }
27
- findFirst(args) {
28
- const { document, variables } = buildFindFirstDocument('FieldModule', 'fieldModules', args.select, {
29
- where: args?.where,
30
- }, 'FieldModuleFilter', connectionFieldsMap);
31
- return new QueryBuilder({
32
- client: this.client,
33
- operation: 'query',
34
- operationName: 'FieldModule',
35
- fieldName: 'fieldModules',
36
- document,
37
- variables,
38
- });
39
- }
40
- findOne(args) {
41
- const { document, variables } = buildFindManyDocument('FieldModule', 'fieldModules', args.select, {
42
- where: {
43
- id: {
44
- equalTo: args.id,
45
- },
46
- },
47
- first: 1,
48
- }, 'FieldModuleFilter', 'FieldModuleOrderBy', connectionFieldsMap);
49
- return new QueryBuilder({
50
- client: this.client,
51
- operation: 'query',
52
- operationName: 'FieldModule',
53
- fieldName: 'fieldModule',
54
- document,
55
- variables,
56
- transform: (data) => ({
57
- fieldModule: data.fieldModules?.nodes?.[0] ?? null,
58
- }),
59
- });
60
- }
61
- create(args) {
62
- const { document, variables } = buildCreateDocument('FieldModule', 'createFieldModule', 'fieldModule', args.select, args.data, 'CreateFieldModuleInput', connectionFieldsMap);
63
- return new QueryBuilder({
64
- client: this.client,
65
- operation: 'mutation',
66
- operationName: 'FieldModule',
67
- fieldName: 'createFieldModule',
68
- document,
69
- variables,
70
- });
71
- }
72
- update(args) {
73
- const { document, variables } = buildUpdateByPkDocument('FieldModule', 'updateFieldModule', 'fieldModule', args.select, args.where.id, args.data, 'UpdateFieldModuleInput', 'id', 'fieldModulePatch', connectionFieldsMap);
74
- return new QueryBuilder({
75
- client: this.client,
76
- operation: 'mutation',
77
- operationName: 'FieldModule',
78
- fieldName: 'updateFieldModule',
79
- document,
80
- variables,
81
- });
82
- }
83
- delete(args) {
84
- const { document, variables } = buildDeleteByPkDocument('FieldModule', 'deleteFieldModule', 'fieldModule', {
85
- id: args.where.id,
86
- }, 'DeleteFieldModuleInput', args.select, connectionFieldsMap);
87
- return new QueryBuilder({
88
- client: this.client,
89
- operation: 'mutation',
90
- operationName: 'FieldModule',
91
- fieldName: 'deleteFieldModule',
92
- document,
93
- variables,
94
- });
95
- }
96
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * SqlMigration model for ORM client
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- import { QueryBuilder } from '../query-builder';
8
- import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, InferSelectResult, StrictSelect } from '../select-types';
9
- import type { SqlMigrationWithRelations, SqlMigrationSelect, SqlMigrationFilter, SqlMigrationOrderBy, CreateSqlMigrationInput } from '../input-types';
10
- export declare class SqlMigrationModel {
11
- private client;
12
- constructor(client: OrmClient);
13
- findMany<S extends SqlMigrationSelect>(args: FindManyArgs<S, SqlMigrationFilter, never, SqlMigrationOrderBy> & {
14
- select: S;
15
- } & StrictSelect<S, SqlMigrationSelect>): QueryBuilder<{
16
- sqlMigrations: ConnectionResult<InferSelectResult<SqlMigrationWithRelations, S>>;
17
- }>;
18
- findFirst<S extends SqlMigrationSelect>(args: FindFirstArgs<S, SqlMigrationFilter> & {
19
- select: S;
20
- } & StrictSelect<S, SqlMigrationSelect>): QueryBuilder<{
21
- sqlMigrations: {
22
- nodes: InferSelectResult<SqlMigrationWithRelations, S>[];
23
- };
24
- }>;
25
- findOne<S extends SqlMigrationSelect>(args: {
26
- id: number;
27
- select: S;
28
- } & StrictSelect<S, SqlMigrationSelect>): QueryBuilder<{
29
- sqlMigration: InferSelectResult<SqlMigrationWithRelations, S> | null;
30
- }>;
31
- create<S extends SqlMigrationSelect>(args: CreateArgs<S, CreateSqlMigrationInput['sqlMigration']> & {
32
- select: S;
33
- } & StrictSelect<S, SqlMigrationSelect>): QueryBuilder<{
34
- createSqlMigration: {
35
- sqlMigration: InferSelectResult<SqlMigrationWithRelations, S>;
36
- };
37
- }>;
38
- }