@constructive-sdk/cli 0.12.7 → 0.12.8
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.
- package/admin/cli/commands/app-achievement.js +38 -15
- package/admin/cli/commands/app-admin-grant.js +38 -15
- package/admin/cli/commands/app-grant.js +40 -16
- package/admin/cli/commands/app-level-requirement.js +42 -17
- package/admin/cli/commands/app-level.js +40 -16
- package/admin/cli/commands/app-limit-default.js +32 -12
- package/admin/cli/commands/app-limit.js +36 -14
- package/admin/cli/commands/app-membership-default.js +40 -16
- package/admin/cli/commands/app-membership.js +58 -25
- package/admin/cli/commands/app-owner-grant.js +38 -15
- package/admin/cli/commands/app-permission-default.js +30 -11
- package/admin/cli/commands/app-permission.js +36 -14
- package/admin/cli/commands/app-step.js +38 -15
- package/admin/cli/commands/claimed-invite.js +38 -15
- package/admin/cli/commands/invite.js +50 -21
- package/admin/cli/commands/membership-type.js +34 -13
- package/admin/cli/commands/org-admin-grant.js +40 -16
- package/admin/cli/commands/org-chart-edge-grant.js +44 -18
- package/admin/cli/commands/org-chart-edge.js +42 -17
- package/admin/cli/commands/org-claimed-invite.js +40 -16
- package/admin/cli/commands/org-get-managers-record.js +30 -11
- package/admin/cli/commands/org-get-subordinates-record.js +30 -11
- package/admin/cli/commands/org-grant.js +42 -17
- package/admin/cli/commands/org-invite.js +54 -23
- package/admin/cli/commands/org-limit-default.js +32 -12
- package/admin/cli/commands/org-limit.js +38 -15
- package/admin/cli/commands/org-member.js +34 -13
- package/admin/cli/commands/org-membership-default.js +44 -18
- package/admin/cli/commands/org-membership.js +58 -25
- package/admin/cli/commands/org-owner-grant.js +40 -16
- package/admin/cli/commands/org-permission-default.js +32 -12
- package/admin/cli/commands/org-permission.js +36 -14
- package/admin/cli/utils.d.ts +38 -0
- package/admin/cli/utils.js +96 -0
- package/auth/cli/commands/audit-log.js +42 -17
- package/auth/cli/commands/connected-account.js +42 -17
- package/auth/cli/commands/crypto-address.js +40 -16
- package/auth/cli/commands/email.js +40 -16
- package/auth/cli/commands/phone-number.js +42 -17
- package/auth/cli/commands/role-type.js +30 -11
- package/auth/cli/commands/user.js +80 -16
- package/auth/cli/utils.d.ts +38 -0
- package/auth/cli/utils.js +96 -0
- package/esm/admin/cli/commands/app-achievement.js +39 -16
- package/esm/admin/cli/commands/app-admin-grant.js +39 -16
- package/esm/admin/cli/commands/app-grant.js +41 -17
- package/esm/admin/cli/commands/app-level-requirement.js +43 -18
- package/esm/admin/cli/commands/app-level.js +41 -17
- package/esm/admin/cli/commands/app-limit-default.js +33 -13
- package/esm/admin/cli/commands/app-limit.js +37 -15
- package/esm/admin/cli/commands/app-membership-default.js +41 -17
- package/esm/admin/cli/commands/app-membership.js +59 -26
- package/esm/admin/cli/commands/app-owner-grant.js +39 -16
- package/esm/admin/cli/commands/app-permission-default.js +31 -12
- package/esm/admin/cli/commands/app-permission.js +37 -15
- package/esm/admin/cli/commands/app-step.js +39 -16
- package/esm/admin/cli/commands/claimed-invite.js +39 -16
- package/esm/admin/cli/commands/invite.js +51 -22
- package/esm/admin/cli/commands/membership-type.js +35 -14
- package/esm/admin/cli/commands/org-admin-grant.js +41 -17
- package/esm/admin/cli/commands/org-chart-edge-grant.js +45 -19
- package/esm/admin/cli/commands/org-chart-edge.js +43 -18
- package/esm/admin/cli/commands/org-claimed-invite.js +41 -17
- package/esm/admin/cli/commands/org-get-managers-record.js +31 -12
- package/esm/admin/cli/commands/org-get-subordinates-record.js +31 -12
- package/esm/admin/cli/commands/org-grant.js +43 -18
- package/esm/admin/cli/commands/org-invite.js +55 -24
- package/esm/admin/cli/commands/org-limit-default.js +33 -13
- package/esm/admin/cli/commands/org-limit.js +39 -16
- package/esm/admin/cli/commands/org-member.js +35 -14
- package/esm/admin/cli/commands/org-membership-default.js +45 -19
- package/esm/admin/cli/commands/org-membership.js +59 -26
- package/esm/admin/cli/commands/org-owner-grant.js +41 -17
- package/esm/admin/cli/commands/org-permission-default.js +33 -13
- package/esm/admin/cli/commands/org-permission.js +37 -15
- package/esm/admin/cli/utils.d.ts +38 -0
- package/esm/admin/cli/utils.js +90 -0
- package/esm/auth/cli/commands/audit-log.js +43 -18
- package/esm/auth/cli/commands/connected-account.js +43 -18
- package/esm/auth/cli/commands/crypto-address.js +41 -17
- package/esm/auth/cli/commands/email.js +41 -17
- package/esm/auth/cli/commands/phone-number.js +43 -18
- package/esm/auth/cli/commands/role-type.js +31 -12
- package/esm/auth/cli/commands/user.js +81 -17
- package/esm/auth/cli/utils.d.ts +38 -0
- package/esm/auth/cli/utils.js +90 -0
- package/esm/objects/cli/commands/commit.js +45 -19
- package/esm/objects/cli/commands/get-all-record.js +31 -12
- package/esm/objects/cli/commands/object.js +41 -17
- package/esm/objects/cli/commands/ref.js +37 -15
- package/esm/objects/cli/commands/store.js +37 -15
- package/esm/objects/cli/utils.d.ts +38 -0
- package/esm/objects/cli/utils.js +90 -0
- package/esm/public/cli/commands/api-module.js +37 -15
- package/esm/public/cli/commands/api-schema.js +35 -14
- package/esm/public/cli/commands/api.js +41 -17
- package/esm/public/cli/commands/app-achievement.js +39 -16
- package/esm/public/cli/commands/app-admin-grant.js +39 -16
- package/esm/public/cli/commands/app-grant.js +41 -17
- package/esm/public/cli/commands/app-level-requirement.js +43 -18
- package/esm/public/cli/commands/app-level.js +41 -17
- package/esm/public/cli/commands/app-limit-default.js +33 -13
- package/esm/public/cli/commands/app-limit.js +37 -15
- package/esm/public/cli/commands/app-membership-default.js +41 -17
- package/esm/public/cli/commands/app-membership.js +59 -26
- package/esm/public/cli/commands/app-owner-grant.js +39 -16
- package/esm/public/cli/commands/app-permission-default.js +31 -12
- package/esm/public/cli/commands/app-permission.js +37 -15
- package/esm/public/cli/commands/app-step.js +39 -16
- package/esm/public/cli/commands/app.js +45 -19
- package/esm/public/cli/commands/ast-migration.js +53 -23
- package/esm/public/cli/commands/audit-log.js +43 -18
- package/esm/public/cli/commands/blueprint-template.js +67 -30
- package/esm/public/cli/commands/blueprint.js +61 -27
- package/esm/public/cli/commands/check-constraint.js +55 -24
- package/esm/public/cli/commands/claimed-invite.js +39 -16
- package/esm/public/cli/commands/commit.js +45 -19
- package/esm/public/cli/commands/connected-account.js +43 -18
- package/esm/public/cli/commands/connected-accounts-module.js +41 -17
- package/esm/public/cli/commands/crypto-address.js +41 -17
- package/esm/public/cli/commands/crypto-addresses-module.js +43 -18
- package/esm/public/cli/commands/crypto-auth-module.js +55 -24
- package/esm/public/cli/commands/database-provision-module.js +55 -24
- package/esm/public/cli/commands/database-transfer.js +55 -24
- package/esm/public/cli/commands/database.js +43 -18
- package/esm/public/cli/commands/default-ids-module.js +31 -12
- package/esm/public/cli/commands/default-privilege.js +41 -17
- package/esm/public/cli/commands/denormalized-table-field.js +51 -22
- package/esm/public/cli/commands/domain.js +39 -16
- package/esm/public/cli/commands/email.js +41 -17
- package/esm/public/cli/commands/emails-module.js +41 -17
- package/esm/public/cli/commands/embedding-chunk.js +63 -28
- package/esm/public/cli/commands/encrypted-secrets-module.js +37 -15
- package/esm/public/cli/commands/enum.js +51 -22
- package/esm/public/cli/commands/field.js +75 -34
- package/esm/public/cli/commands/foreign-key-constraint.js +63 -28
- package/esm/public/cli/commands/full-text-search.js +45 -19
- package/esm/public/cli/commands/get-all-record.js +31 -12
- package/esm/public/cli/commands/hierarchy-module.js +67 -30
- package/esm/public/cli/commands/index.js +65 -29
- package/esm/public/cli/commands/invite.js +51 -22
- package/esm/public/cli/commands/invites-module.js +55 -24
- package/esm/public/cli/commands/levels-module.js +79 -36
- package/esm/public/cli/commands/limits-module.js +63 -28
- package/esm/public/cli/commands/membership-type.js +35 -14
- package/esm/public/cli/commands/membership-types-module.js +37 -15
- package/esm/public/cli/commands/memberships-module.js +89 -41
- package/esm/public/cli/commands/migrate-file.js +33 -13
- package/esm/public/cli/commands/node-type-registry.js +89 -19
- package/esm/public/cli/commands/object.js +41 -17
- package/esm/public/cli/commands/org-admin-grant.js +41 -17
- package/esm/public/cli/commands/org-chart-edge-grant.js +45 -19
- package/esm/public/cli/commands/org-chart-edge.js +43 -18
- package/esm/public/cli/commands/org-claimed-invite.js +41 -17
- package/esm/public/cli/commands/org-get-managers-record.js +31 -12
- package/esm/public/cli/commands/org-get-subordinates-record.js +31 -12
- package/esm/public/cli/commands/org-grant.js +43 -18
- package/esm/public/cli/commands/org-invite.js +55 -24
- package/esm/public/cli/commands/org-limit-default.js +33 -13
- package/esm/public/cli/commands/org-limit.js +39 -16
- package/esm/public/cli/commands/org-member.js +35 -14
- package/esm/public/cli/commands/org-membership-default.js +45 -19
- package/esm/public/cli/commands/org-membership.js +59 -26
- package/esm/public/cli/commands/org-owner-grant.js +41 -17
- package/esm/public/cli/commands/org-permission-default.js +33 -13
- package/esm/public/cli/commands/org-permission.js +37 -15
- package/esm/public/cli/commands/permissions-module.js +61 -27
- package/esm/public/cli/commands/phone-number.js +43 -18
- package/esm/public/cli/commands/phone-numbers-module.js +41 -17
- package/esm/public/cli/commands/policy.js +61 -27
- package/esm/public/cli/commands/primary-key-constraint.js +53 -23
- package/esm/public/cli/commands/profiles-module.js +63 -28
- package/esm/public/cli/commands/ref.js +37 -15
- package/esm/public/cli/commands/relation-provision.js +89 -41
- package/esm/public/cli/commands/rls-module.js +49 -21
- package/esm/public/cli/commands/role-type.js +31 -12
- package/esm/public/cli/commands/schema-grant.js +39 -16
- package/esm/public/cli/commands/schema.js +55 -24
- package/esm/public/cli/commands/secrets-module.js +37 -15
- package/esm/public/cli/commands/secure-table-provision.js +63 -28
- package/esm/public/cli/commands/sessions-module.js +49 -21
- package/esm/public/cli/commands/site-metadatum.js +39 -16
- package/esm/public/cli/commands/site-module.js +37 -15
- package/esm/public/cli/commands/site-theme.js +35 -14
- package/esm/public/cli/commands/site.js +45 -19
- package/esm/public/cli/commands/sql-action.js +53 -23
- package/esm/public/cli/commands/store.js +37 -15
- package/esm/public/cli/commands/table-grant.js +45 -19
- package/esm/public/cli/commands/table-template-module.js +45 -19
- package/esm/public/cli/commands/table.js +65 -29
- package/esm/public/cli/commands/trigger-function.js +39 -16
- package/esm/public/cli/commands/trigger.js +53 -23
- package/esm/public/cli/commands/unique-constraint.js +55 -24
- package/esm/public/cli/commands/user-auth-module.js +79 -36
- package/esm/public/cli/commands/user.js +81 -17
- package/esm/public/cli/commands/users-module.js +41 -17
- package/esm/public/cli/commands/view-grant.js +41 -17
- package/esm/public/cli/commands/view-rule.js +39 -16
- package/esm/public/cli/commands/view-table.js +35 -14
- package/esm/public/cli/commands/view.js +59 -26
- package/esm/public/cli/commands.js +3 -3
- package/esm/public/cli/executor.d.ts +1 -1
- package/esm/public/cli/utils.d.ts +38 -0
- package/esm/public/cli/utils.js +90 -0
- package/esm/public/orm/index.d.ts +2 -2
- package/esm/public/orm/index.js +2 -2
- package/esm/public/orm/input-types.d.ts +161 -147
- package/esm/public/orm/models/index.d.ts +1 -1
- package/esm/public/orm/models/index.js +1 -1
- package/objects/cli/commands/commit.js +44 -18
- package/objects/cli/commands/get-all-record.js +30 -11
- package/objects/cli/commands/object.js +40 -16
- package/objects/cli/commands/ref.js +36 -14
- package/objects/cli/commands/store.js +36 -14
- package/objects/cli/utils.d.ts +38 -0
- package/objects/cli/utils.js +96 -0
- package/package.json +3 -3
- package/public/cli/commands/api-module.js +36 -14
- package/public/cli/commands/api-schema.js +34 -13
- package/public/cli/commands/api.js +40 -16
- package/public/cli/commands/app-achievement.js +38 -15
- package/public/cli/commands/app-admin-grant.js +38 -15
- package/public/cli/commands/app-grant.js +40 -16
- package/public/cli/commands/app-level-requirement.js +42 -17
- package/public/cli/commands/app-level.js +40 -16
- package/public/cli/commands/app-limit-default.js +32 -12
- package/public/cli/commands/app-limit.js +36 -14
- package/public/cli/commands/app-membership-default.js +40 -16
- package/public/cli/commands/app-membership.js +58 -25
- package/public/cli/commands/app-owner-grant.js +38 -15
- package/public/cli/commands/app-permission-default.js +30 -11
- package/public/cli/commands/app-permission.js +36 -14
- package/public/cli/commands/app-step.js +38 -15
- package/public/cli/commands/app.js +44 -18
- package/public/cli/commands/ast-migration.js +52 -22
- package/public/cli/commands/audit-log.js +42 -17
- package/public/cli/commands/blueprint-template.js +66 -29
- package/public/cli/commands/blueprint.js +60 -26
- package/public/cli/commands/check-constraint.js +54 -23
- package/public/cli/commands/claimed-invite.js +38 -15
- package/public/cli/commands/commit.js +44 -18
- package/public/cli/commands/connected-account.js +42 -17
- package/public/cli/commands/connected-accounts-module.js +40 -16
- package/public/cli/commands/crypto-address.js +40 -16
- package/public/cli/commands/crypto-addresses-module.js +42 -17
- package/public/cli/commands/crypto-auth-module.js +54 -23
- package/public/cli/commands/database-provision-module.js +54 -23
- package/public/cli/commands/database-transfer.js +54 -23
- package/public/cli/commands/database.js +42 -17
- package/public/cli/commands/default-ids-module.js +30 -11
- package/public/cli/commands/default-privilege.js +40 -16
- package/public/cli/commands/denormalized-table-field.js +50 -21
- package/public/cli/commands/domain.js +38 -15
- package/public/cli/commands/email.js +40 -16
- package/public/cli/commands/emails-module.js +40 -16
- package/public/cli/commands/embedding-chunk.js +62 -27
- package/public/cli/commands/encrypted-secrets-module.js +36 -14
- package/public/cli/commands/enum.js +50 -21
- package/public/cli/commands/field.js +74 -33
- package/public/cli/commands/foreign-key-constraint.js +62 -27
- package/public/cli/commands/full-text-search.js +44 -18
- package/public/cli/commands/get-all-record.js +30 -11
- package/public/cli/commands/hierarchy-module.js +66 -29
- package/public/cli/commands/index.js +64 -28
- package/public/cli/commands/invite.js +50 -21
- package/public/cli/commands/invites-module.js +54 -23
- package/public/cli/commands/levels-module.js +78 -35
- package/public/cli/commands/limits-module.js +62 -27
- package/public/cli/commands/membership-type.js +34 -13
- package/public/cli/commands/membership-types-module.js +36 -14
- package/public/cli/commands/memberships-module.js +88 -40
- package/public/cli/commands/migrate-file.js +32 -12
- package/public/cli/commands/node-type-registry.js +88 -18
- package/public/cli/commands/object.js +40 -16
- package/public/cli/commands/org-admin-grant.js +40 -16
- package/public/cli/commands/org-chart-edge-grant.js +44 -18
- package/public/cli/commands/org-chart-edge.js +42 -17
- package/public/cli/commands/org-claimed-invite.js +40 -16
- package/public/cli/commands/org-get-managers-record.js +30 -11
- package/public/cli/commands/org-get-subordinates-record.js +30 -11
- package/public/cli/commands/org-grant.js +42 -17
- package/public/cli/commands/org-invite.js +54 -23
- package/public/cli/commands/org-limit-default.js +32 -12
- package/public/cli/commands/org-limit.js +38 -15
- package/public/cli/commands/org-member.js +34 -13
- package/public/cli/commands/org-membership-default.js +44 -18
- package/public/cli/commands/org-membership.js +58 -25
- package/public/cli/commands/org-owner-grant.js +40 -16
- package/public/cli/commands/org-permission-default.js +32 -12
- package/public/cli/commands/org-permission.js +36 -14
- package/public/cli/commands/permissions-module.js +60 -26
- package/public/cli/commands/phone-number.js +42 -17
- package/public/cli/commands/phone-numbers-module.js +40 -16
- package/public/cli/commands/policy.js +60 -26
- package/public/cli/commands/primary-key-constraint.js +52 -22
- package/public/cli/commands/profiles-module.js +62 -27
- package/public/cli/commands/ref.js +36 -14
- package/public/cli/commands/relation-provision.js +88 -40
- package/public/cli/commands/rls-module.js +48 -20
- package/public/cli/commands/role-type.js +30 -11
- package/public/cli/commands/schema-grant.js +38 -15
- package/public/cli/commands/schema.js +54 -23
- package/public/cli/commands/secrets-module.js +36 -14
- package/public/cli/commands/secure-table-provision.js +62 -27
- package/public/cli/commands/sessions-module.js +48 -20
- package/public/cli/commands/site-metadatum.js +38 -15
- package/public/cli/commands/site-module.js +36 -14
- package/public/cli/commands/site-theme.js +34 -13
- package/public/cli/commands/site.js +44 -18
- package/public/cli/commands/sql-action.js +52 -22
- package/public/cli/commands/store.js +36 -14
- package/public/cli/commands/table-grant.js +44 -18
- package/public/cli/commands/table-template-module.js +44 -18
- package/public/cli/commands/table.js +64 -28
- package/public/cli/commands/trigger-function.js +38 -15
- package/public/cli/commands/trigger.js +52 -22
- package/public/cli/commands/unique-constraint.js +54 -23
- package/public/cli/commands/user-auth-module.js +78 -35
- package/public/cli/commands/user.js +80 -16
- package/public/cli/commands/users-module.js +40 -16
- package/public/cli/commands/view-grant.js +40 -16
- package/public/cli/commands/view-rule.js +38 -15
- package/public/cli/commands/view-table.js +34 -13
- package/public/cli/commands/view.js +58 -25
- package/public/cli/commands.js +3 -3
- package/public/cli/executor.d.ts +1 -1
- package/public/cli/utils.d.ts +38 -0
- package/public/cli/utils.js +96 -0
- package/public/orm/index.d.ts +2 -2
- package/public/orm/index.js +2 -2
- package/public/orm/input-types.d.ts +161 -147
- package/public/orm/models/index.d.ts +1 -1
- package/public/orm/models/index.js +4 -4
|
@@ -18,7 +18,7 @@ const fieldSchema = {
|
|
|
18
18
|
frzn: 'boolean',
|
|
19
19
|
createdAt: 'string',
|
|
20
20
|
};
|
|
21
|
-
const usage = '\nobject <command>\n\nCommands:\n list List
|
|
21
|
+
const usage = '\nobject <command>\n\nCommands:\n list List object records\n find-first Find first matching object record\n get Get a object by ID\n create Create a new object\n update Update an existing object\n delete Delete a object\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';
|
|
22
22
|
exports.default = async (argv, prompter, _options) => {
|
|
23
23
|
if (argv.help || argv.h) {
|
|
24
24
|
console.log(usage);
|
|
@@ -31,7 +31,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
31
31
|
type: 'autocomplete',
|
|
32
32
|
name: 'subcommand',
|
|
33
33
|
message: 'What do you want to do?',
|
|
34
|
-
options: ['list', 'get', 'create', 'update', 'delete'],
|
|
34
|
+
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
|
|
35
35
|
},
|
|
36
36
|
]);
|
|
37
37
|
return handleTableSubcommand(answer.subcommand, newArgv, prompter);
|
|
@@ -42,6 +42,8 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
42
42
|
switch (subcommand) {
|
|
43
43
|
case 'list':
|
|
44
44
|
return handleList(argv, prompter);
|
|
45
|
+
case 'find-first':
|
|
46
|
+
return handleFindFirst(argv, prompter);
|
|
45
47
|
case 'get':
|
|
46
48
|
return handleGet(argv, prompter);
|
|
47
49
|
case 'create':
|
|
@@ -55,22 +57,20 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
55
57
|
process.exit(1);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
async function handleList(
|
|
60
|
+
async function handleList(argv, _prompter) {
|
|
59
61
|
try {
|
|
62
|
+
const defaultSelect = {
|
|
63
|
+
id: true,
|
|
64
|
+
databaseId: true,
|
|
65
|
+
kids: true,
|
|
66
|
+
ktree: true,
|
|
67
|
+
data: true,
|
|
68
|
+
frzn: true,
|
|
69
|
+
createdAt: true,
|
|
70
|
+
};
|
|
71
|
+
const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
|
|
60
72
|
const client = (0, executor_1.getClient)();
|
|
61
|
-
const result = await client.object
|
|
62
|
-
.findMany({
|
|
63
|
-
select: {
|
|
64
|
-
id: true,
|
|
65
|
-
databaseId: true,
|
|
66
|
-
kids: true,
|
|
67
|
-
ktree: true,
|
|
68
|
-
data: true,
|
|
69
|
-
frzn: true,
|
|
70
|
-
createdAt: true,
|
|
71
|
-
},
|
|
72
|
-
})
|
|
73
|
-
.execute();
|
|
73
|
+
const result = await client.object.findMany(findManyArgs).execute();
|
|
74
74
|
console.log(JSON.stringify(result, null, 2));
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
@@ -81,6 +81,30 @@ async function handleList(_argv, _prompter) {
|
|
|
81
81
|
process.exit(1);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
async function handleFindFirst(argv, _prompter) {
|
|
85
|
+
try {
|
|
86
|
+
const defaultSelect = {
|
|
87
|
+
id: true,
|
|
88
|
+
databaseId: true,
|
|
89
|
+
kids: true,
|
|
90
|
+
ktree: true,
|
|
91
|
+
data: true,
|
|
92
|
+
frzn: true,
|
|
93
|
+
createdAt: true,
|
|
94
|
+
};
|
|
95
|
+
const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
|
|
96
|
+
const client = (0, executor_1.getClient)();
|
|
97
|
+
const result = await client.object.findFirst(findFirstArgs).execute();
|
|
98
|
+
console.log(JSON.stringify(result, null, 2));
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error('Failed to find record.');
|
|
102
|
+
if (error instanceof Error) {
|
|
103
|
+
console.error(error.message);
|
|
104
|
+
}
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
84
108
|
async function handleGet(argv, prompter) {
|
|
85
109
|
try {
|
|
86
110
|
const answers = await prompter.prompt(argv, [
|
|
@@ -15,7 +15,7 @@ const fieldSchema = {
|
|
|
15
15
|
storeId: 'uuid',
|
|
16
16
|
commitId: 'uuid',
|
|
17
17
|
};
|
|
18
|
-
const usage = '\nref <command>\n\nCommands:\n list List
|
|
18
|
+
const usage = '\nref <command>\n\nCommands:\n list List ref records\n find-first Find first matching ref record\n get Get a ref by ID\n create Create a new ref\n update Update an existing ref\n delete Delete a ref\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';
|
|
19
19
|
exports.default = async (argv, prompter, _options) => {
|
|
20
20
|
if (argv.help || argv.h) {
|
|
21
21
|
console.log(usage);
|
|
@@ -28,7 +28,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
28
28
|
type: 'autocomplete',
|
|
29
29
|
name: 'subcommand',
|
|
30
30
|
message: 'What do you want to do?',
|
|
31
|
-
options: ['list', 'get', 'create', 'update', 'delete'],
|
|
31
|
+
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
|
|
32
32
|
},
|
|
33
33
|
]);
|
|
34
34
|
return handleTableSubcommand(answer.subcommand, newArgv, prompter);
|
|
@@ -39,6 +39,8 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
39
39
|
switch (subcommand) {
|
|
40
40
|
case 'list':
|
|
41
41
|
return handleList(argv, prompter);
|
|
42
|
+
case 'find-first':
|
|
43
|
+
return handleFindFirst(argv, prompter);
|
|
42
44
|
case 'get':
|
|
43
45
|
return handleGet(argv, prompter);
|
|
44
46
|
case 'create':
|
|
@@ -52,20 +54,18 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
52
54
|
process.exit(1);
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
async function handleList(
|
|
57
|
+
async function handleList(argv, _prompter) {
|
|
56
58
|
try {
|
|
59
|
+
const defaultSelect = {
|
|
60
|
+
id: true,
|
|
61
|
+
name: true,
|
|
62
|
+
databaseId: true,
|
|
63
|
+
storeId: true,
|
|
64
|
+
commitId: true,
|
|
65
|
+
};
|
|
66
|
+
const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
|
|
57
67
|
const client = (0, executor_1.getClient)();
|
|
58
|
-
const result = await client.ref
|
|
59
|
-
.findMany({
|
|
60
|
-
select: {
|
|
61
|
-
id: true,
|
|
62
|
-
name: true,
|
|
63
|
-
databaseId: true,
|
|
64
|
-
storeId: true,
|
|
65
|
-
commitId: true,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
.execute();
|
|
68
|
+
const result = await client.ref.findMany(findManyArgs).execute();
|
|
69
69
|
console.log(JSON.stringify(result, null, 2));
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
@@ -76,6 +76,28 @@ async function handleList(_argv, _prompter) {
|
|
|
76
76
|
process.exit(1);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
async function handleFindFirst(argv, _prompter) {
|
|
80
|
+
try {
|
|
81
|
+
const defaultSelect = {
|
|
82
|
+
id: true,
|
|
83
|
+
name: true,
|
|
84
|
+
databaseId: true,
|
|
85
|
+
storeId: true,
|
|
86
|
+
commitId: true,
|
|
87
|
+
};
|
|
88
|
+
const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
|
|
89
|
+
const client = (0, executor_1.getClient)();
|
|
90
|
+
const result = await client.ref.findFirst(findFirstArgs).execute();
|
|
91
|
+
console.log(JSON.stringify(result, null, 2));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error('Failed to find record.');
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
console.error(error.message);
|
|
97
|
+
}
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
79
101
|
async function handleGet(argv, prompter) {
|
|
80
102
|
try {
|
|
81
103
|
const answers = await prompter.prompt(argv, [
|
|
@@ -15,7 +15,7 @@ const fieldSchema = {
|
|
|
15
15
|
hash: 'uuid',
|
|
16
16
|
createdAt: 'string',
|
|
17
17
|
};
|
|
18
|
-
const usage = '\nstore <command>\n\nCommands:\n list List
|
|
18
|
+
const usage = '\nstore <command>\n\nCommands:\n list List store records\n find-first Find first matching store record\n get Get a store by ID\n create Create a new store\n update Update an existing store\n delete Delete a store\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';
|
|
19
19
|
exports.default = async (argv, prompter, _options) => {
|
|
20
20
|
if (argv.help || argv.h) {
|
|
21
21
|
console.log(usage);
|
|
@@ -28,7 +28,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
28
28
|
type: 'autocomplete',
|
|
29
29
|
name: 'subcommand',
|
|
30
30
|
message: 'What do you want to do?',
|
|
31
|
-
options: ['list', 'get', 'create', 'update', 'delete'],
|
|
31
|
+
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
|
|
32
32
|
},
|
|
33
33
|
]);
|
|
34
34
|
return handleTableSubcommand(answer.subcommand, newArgv, prompter);
|
|
@@ -39,6 +39,8 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
39
39
|
switch (subcommand) {
|
|
40
40
|
case 'list':
|
|
41
41
|
return handleList(argv, prompter);
|
|
42
|
+
case 'find-first':
|
|
43
|
+
return handleFindFirst(argv, prompter);
|
|
42
44
|
case 'get':
|
|
43
45
|
return handleGet(argv, prompter);
|
|
44
46
|
case 'create':
|
|
@@ -52,20 +54,18 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
52
54
|
process.exit(1);
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
async function handleList(
|
|
57
|
+
async function handleList(argv, _prompter) {
|
|
56
58
|
try {
|
|
59
|
+
const defaultSelect = {
|
|
60
|
+
id: true,
|
|
61
|
+
name: true,
|
|
62
|
+
databaseId: true,
|
|
63
|
+
hash: true,
|
|
64
|
+
createdAt: true,
|
|
65
|
+
};
|
|
66
|
+
const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
|
|
57
67
|
const client = (0, executor_1.getClient)();
|
|
58
|
-
const result = await client.store
|
|
59
|
-
.findMany({
|
|
60
|
-
select: {
|
|
61
|
-
id: true,
|
|
62
|
-
name: true,
|
|
63
|
-
databaseId: true,
|
|
64
|
-
hash: true,
|
|
65
|
-
createdAt: true,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
.execute();
|
|
68
|
+
const result = await client.store.findMany(findManyArgs).execute();
|
|
69
69
|
console.log(JSON.stringify(result, null, 2));
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
@@ -76,6 +76,28 @@ async function handleList(_argv, _prompter) {
|
|
|
76
76
|
process.exit(1);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
async function handleFindFirst(argv, _prompter) {
|
|
80
|
+
try {
|
|
81
|
+
const defaultSelect = {
|
|
82
|
+
id: true,
|
|
83
|
+
name: true,
|
|
84
|
+
databaseId: true,
|
|
85
|
+
hash: true,
|
|
86
|
+
createdAt: true,
|
|
87
|
+
};
|
|
88
|
+
const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
|
|
89
|
+
const client = (0, executor_1.getClient)();
|
|
90
|
+
const result = await client.store.findFirst(findFirstArgs).execute();
|
|
91
|
+
console.log(JSON.stringify(result, null, 2));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error('Failed to find record.');
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
console.error(error.message);
|
|
97
|
+
}
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
79
101
|
async function handleGet(argv, prompter) {
|
|
80
102
|
try {
|
|
81
103
|
const answers = await prompter.prompt(argv, [
|
package/objects/cli/utils.d.ts
CHANGED
|
@@ -47,4 +47,42 @@ export declare function unflattenDotNotation(answers: Record<string, unknown>):
|
|
|
47
47
|
* @param paths - Comma-separated dot-notation field paths (e.g. 'clientMutationId,result.accessToken')
|
|
48
48
|
* @returns The nested select object for the ORM
|
|
49
49
|
*/
|
|
50
|
+
/**
|
|
51
|
+
* Parse a CLI flag as an integer.
|
|
52
|
+
* Handles minimist delivering numbers or strings depending on the input.
|
|
53
|
+
* Returns undefined when the flag is missing or not a valid number.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseIntFlag(argv: Record<string, unknown>, name: string): number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Parse a CLI flag as a string.
|
|
58
|
+
* Returns undefined when the flag is missing or not a string.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseStringFlag(argv: Record<string, unknown>, name: string): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Parse --orderBy flag as a comma-separated list of enum values.
|
|
63
|
+
* e.g. --orderBy NAME_ASC,CREATED_AT_DESC → ['NAME_ASC', 'CREATED_AT_DESC']
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseOrderByFlag(argv: Record<string, unknown>): string[] | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Parse --select flag into a select object, falling back to a default.
|
|
68
|
+
* e.g. --select id,name → { id: true, name: true }
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseSelectFlag(argv: Record<string, unknown>, defaultSelect: Record<string, unknown>): Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Build the full findManyArgs object from CLI argv.
|
|
73
|
+
* Parses all pagination, filtering, ordering, and field selection flags
|
|
74
|
+
* in one call. Accepts an optional `extraWhere` to merge with dot-notation
|
|
75
|
+
* --where flags (used by the search handler to inject search clauses).
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const findManyArgs = parseFindManyArgs(argv, { id: true, name: true });
|
|
79
|
+
* const result = await client.user.findMany(findManyArgs).execute();
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseFindManyArgs<T = Record<string, unknown>>(argv: Record<string, unknown>, defaultSelect: Record<string, unknown>, extraWhere?: Record<string, unknown>): T;
|
|
82
|
+
/**
|
|
83
|
+
* Build findFirst args from CLI argv.
|
|
84
|
+
* Like parseFindManyArgs but only includes select, where, and condition
|
|
85
|
+
* (no pagination flags — findFirst returns the first matching record).
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseFindFirstArgs<T = Record<string, unknown>>(argv: Record<string, unknown>, defaultSelect: Record<string, unknown>): T;
|
|
50
88
|
export declare function buildSelectFromPaths(paths: string): Record<string, unknown>;
|
package/objects/cli/utils.js
CHANGED
|
@@ -7,6 +7,12 @@ exports.coerceAnswers = coerceAnswers;
|
|
|
7
7
|
exports.stripUndefined = stripUndefined;
|
|
8
8
|
exports.parseMutationInput = parseMutationInput;
|
|
9
9
|
exports.unflattenDotNotation = unflattenDotNotation;
|
|
10
|
+
exports.parseIntFlag = parseIntFlag;
|
|
11
|
+
exports.parseStringFlag = parseStringFlag;
|
|
12
|
+
exports.parseOrderByFlag = parseOrderByFlag;
|
|
13
|
+
exports.parseSelectFlag = parseSelectFlag;
|
|
14
|
+
exports.parseFindManyArgs = parseFindManyArgs;
|
|
15
|
+
exports.parseFindFirstArgs = parseFindFirstArgs;
|
|
10
16
|
exports.buildSelectFromPaths = buildSelectFromPaths;
|
|
11
17
|
/**
|
|
12
18
|
* CLI utility functions for type coercion and input handling
|
|
@@ -163,6 +169,96 @@ function unflattenDotNotation(answers) {
|
|
|
163
169
|
* @param paths - Comma-separated dot-notation field paths (e.g. 'clientMutationId,result.accessToken')
|
|
164
170
|
* @returns The nested select object for the ORM
|
|
165
171
|
*/
|
|
172
|
+
/**
|
|
173
|
+
* Parse a CLI flag as an integer.
|
|
174
|
+
* Handles minimist delivering numbers or strings depending on the input.
|
|
175
|
+
* Returns undefined when the flag is missing or not a valid number.
|
|
176
|
+
*/
|
|
177
|
+
function parseIntFlag(argv, name) {
|
|
178
|
+
const val = argv[name];
|
|
179
|
+
if (typeof val === 'number')
|
|
180
|
+
return val;
|
|
181
|
+
if (typeof val === 'string') {
|
|
182
|
+
const n = parseInt(val, 10);
|
|
183
|
+
return isNaN(n) ? undefined : n;
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Parse a CLI flag as a string.
|
|
189
|
+
* Returns undefined when the flag is missing or not a string.
|
|
190
|
+
*/
|
|
191
|
+
function parseStringFlag(argv, name) {
|
|
192
|
+
const val = argv[name];
|
|
193
|
+
return typeof val === 'string' ? val : undefined;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Parse --orderBy flag as a comma-separated list of enum values.
|
|
197
|
+
* e.g. --orderBy NAME_ASC,CREATED_AT_DESC → ['NAME_ASC', 'CREATED_AT_DESC']
|
|
198
|
+
*/
|
|
199
|
+
function parseOrderByFlag(argv) {
|
|
200
|
+
const val = argv.orderBy;
|
|
201
|
+
return typeof val === 'string' ? val.split(',') : undefined;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Parse --select flag into a select object, falling back to a default.
|
|
205
|
+
* e.g. --select id,name → { id: true, name: true }
|
|
206
|
+
*/
|
|
207
|
+
function parseSelectFlag(argv, defaultSelect) {
|
|
208
|
+
const raw = argv.select;
|
|
209
|
+
return typeof raw === 'string' ? buildSelectFromPaths(raw) : defaultSelect;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Build the full findManyArgs object from CLI argv.
|
|
213
|
+
* Parses all pagination, filtering, ordering, and field selection flags
|
|
214
|
+
* in one call. Accepts an optional `extraWhere` to merge with dot-notation
|
|
215
|
+
* --where flags (used by the search handler to inject search clauses).
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* const findManyArgs = parseFindManyArgs(argv, { id: true, name: true });
|
|
219
|
+
* const result = await client.user.findMany(findManyArgs).execute();
|
|
220
|
+
*/
|
|
221
|
+
function parseFindManyArgs(argv, defaultSelect, extraWhere) {
|
|
222
|
+
const limit = parseIntFlag(argv, 'limit');
|
|
223
|
+
const last = parseIntFlag(argv, 'last');
|
|
224
|
+
const offset = parseIntFlag(argv, 'offset');
|
|
225
|
+
const after = parseStringFlag(argv, 'after');
|
|
226
|
+
const before = parseStringFlag(argv, 'before');
|
|
227
|
+
const select = parseSelectFlag(argv, defaultSelect);
|
|
228
|
+
const parsed = unflattenDotNotation(argv);
|
|
229
|
+
const where = (parsed.where ?? extraWhere)
|
|
230
|
+
? { ...(extraWhere ?? {}), ...(parsed.where ?? {}) }
|
|
231
|
+
: undefined;
|
|
232
|
+
const condition = parsed.condition;
|
|
233
|
+
const orderBy = parseOrderByFlag(argv);
|
|
234
|
+
return {
|
|
235
|
+
select,
|
|
236
|
+
...(limit !== undefined ? { first: limit } : {}),
|
|
237
|
+
...(after !== undefined ? { after } : {}),
|
|
238
|
+
...(last !== undefined ? { last } : {}),
|
|
239
|
+
...(before !== undefined ? { before } : {}),
|
|
240
|
+
...(offset !== undefined ? { offset } : {}),
|
|
241
|
+
...(where !== undefined ? { where } : {}),
|
|
242
|
+
...(condition !== undefined ? { condition } : {}),
|
|
243
|
+
...(orderBy !== undefined ? { orderBy } : {}),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Build findFirst args from CLI argv.
|
|
248
|
+
* Like parseFindManyArgs but only includes select, where, and condition
|
|
249
|
+
* (no pagination flags — findFirst returns the first matching record).
|
|
250
|
+
*/
|
|
251
|
+
function parseFindFirstArgs(argv, defaultSelect) {
|
|
252
|
+
const select = parseSelectFlag(argv, defaultSelect);
|
|
253
|
+
const parsed = unflattenDotNotation(argv);
|
|
254
|
+
const where = parsed.where;
|
|
255
|
+
const condition = parsed.condition;
|
|
256
|
+
return {
|
|
257
|
+
select,
|
|
258
|
+
...(where !== undefined ? { where } : {}),
|
|
259
|
+
...(condition !== undefined ? { condition } : {}),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
166
262
|
function buildSelectFromPaths(paths) {
|
|
167
263
|
const result = {};
|
|
168
264
|
const trimmedPaths = paths
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-sdk/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.8",
|
|
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.
|
|
58
|
+
"@constructive-io/graphql-codegen": "^4.27.0",
|
|
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": "
|
|
64
|
+
"gitHead": "2f6e083d11764a04b2a6bc14df5b2ca2725defc6"
|
|
65
65
|
}
|
|
@@ -15,7 +15,7 @@ const fieldSchema = {
|
|
|
15
15
|
name: 'string',
|
|
16
16
|
data: 'json',
|
|
17
17
|
};
|
|
18
|
-
const usage = '\napi-module <command>\n\nCommands:\n list List
|
|
18
|
+
const usage = '\napi-module <command>\n\nCommands:\n list List apiModule records\n find-first Find first matching apiModule record\n get Get a apiModule by ID\n create Create a new apiModule\n update Update an existing apiModule\n delete Delete a apiModule\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';
|
|
19
19
|
exports.default = async (argv, prompter, _options) => {
|
|
20
20
|
if (argv.help || argv.h) {
|
|
21
21
|
console.log(usage);
|
|
@@ -28,7 +28,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
28
28
|
type: 'autocomplete',
|
|
29
29
|
name: 'subcommand',
|
|
30
30
|
message: 'What do you want to do?',
|
|
31
|
-
options: ['list', 'get', 'create', 'update', 'delete'],
|
|
31
|
+
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
|
|
32
32
|
},
|
|
33
33
|
]);
|
|
34
34
|
return handleTableSubcommand(answer.subcommand, newArgv, prompter);
|
|
@@ -39,6 +39,8 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
39
39
|
switch (subcommand) {
|
|
40
40
|
case 'list':
|
|
41
41
|
return handleList(argv, prompter);
|
|
42
|
+
case 'find-first':
|
|
43
|
+
return handleFindFirst(argv, prompter);
|
|
42
44
|
case 'get':
|
|
43
45
|
return handleGet(argv, prompter);
|
|
44
46
|
case 'create':
|
|
@@ -52,20 +54,18 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
52
54
|
process.exit(1);
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
async function handleList(
|
|
57
|
+
async function handleList(argv, _prompter) {
|
|
56
58
|
try {
|
|
59
|
+
const defaultSelect = {
|
|
60
|
+
id: true,
|
|
61
|
+
databaseId: true,
|
|
62
|
+
apiId: true,
|
|
63
|
+
name: true,
|
|
64
|
+
data: true,
|
|
65
|
+
};
|
|
66
|
+
const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
|
|
57
67
|
const client = (0, executor_1.getClient)();
|
|
58
|
-
const result = await client.apiModule
|
|
59
|
-
.findMany({
|
|
60
|
-
select: {
|
|
61
|
-
id: true,
|
|
62
|
-
databaseId: true,
|
|
63
|
-
apiId: true,
|
|
64
|
-
name: true,
|
|
65
|
-
data: true,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
.execute();
|
|
68
|
+
const result = await client.apiModule.findMany(findManyArgs).execute();
|
|
69
69
|
console.log(JSON.stringify(result, null, 2));
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
@@ -76,6 +76,28 @@ async function handleList(_argv, _prompter) {
|
|
|
76
76
|
process.exit(1);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
async function handleFindFirst(argv, _prompter) {
|
|
80
|
+
try {
|
|
81
|
+
const defaultSelect = {
|
|
82
|
+
id: true,
|
|
83
|
+
databaseId: true,
|
|
84
|
+
apiId: true,
|
|
85
|
+
name: true,
|
|
86
|
+
data: true,
|
|
87
|
+
};
|
|
88
|
+
const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
|
|
89
|
+
const client = (0, executor_1.getClient)();
|
|
90
|
+
const result = await client.apiModule.findFirst(findFirstArgs).execute();
|
|
91
|
+
console.log(JSON.stringify(result, null, 2));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error('Failed to find record.');
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
console.error(error.message);
|
|
97
|
+
}
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
79
101
|
async function handleGet(argv, prompter) {
|
|
80
102
|
try {
|
|
81
103
|
const answers = await prompter.prompt(argv, [
|
|
@@ -14,7 +14,7 @@ const fieldSchema = {
|
|
|
14
14
|
schemaId: 'uuid',
|
|
15
15
|
apiId: 'uuid',
|
|
16
16
|
};
|
|
17
|
-
const usage = '\napi-schema <command>\n\nCommands:\n list List
|
|
17
|
+
const usage = '\napi-schema <command>\n\nCommands:\n list List apiSchema records\n find-first Find first matching apiSchema record\n get Get a apiSchema by ID\n create Create a new apiSchema\n update Update an existing apiSchema\n delete Delete a apiSchema\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';
|
|
18
18
|
exports.default = async (argv, prompter, _options) => {
|
|
19
19
|
if (argv.help || argv.h) {
|
|
20
20
|
console.log(usage);
|
|
@@ -27,7 +27,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
27
27
|
type: 'autocomplete',
|
|
28
28
|
name: 'subcommand',
|
|
29
29
|
message: 'What do you want to do?',
|
|
30
|
-
options: ['list', 'get', 'create', 'update', 'delete'],
|
|
30
|
+
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
|
|
31
31
|
},
|
|
32
32
|
]);
|
|
33
33
|
return handleTableSubcommand(answer.subcommand, newArgv, prompter);
|
|
@@ -38,6 +38,8 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
38
38
|
switch (subcommand) {
|
|
39
39
|
case 'list':
|
|
40
40
|
return handleList(argv, prompter);
|
|
41
|
+
case 'find-first':
|
|
42
|
+
return handleFindFirst(argv, prompter);
|
|
41
43
|
case 'get':
|
|
42
44
|
return handleGet(argv, prompter);
|
|
43
45
|
case 'create':
|
|
@@ -51,19 +53,17 @@ async function handleTableSubcommand(subcommand, argv, prompter) {
|
|
|
51
53
|
process.exit(1);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
|
-
async function handleList(
|
|
56
|
+
async function handleList(argv, _prompter) {
|
|
55
57
|
try {
|
|
58
|
+
const defaultSelect = {
|
|
59
|
+
id: true,
|
|
60
|
+
databaseId: true,
|
|
61
|
+
schemaId: true,
|
|
62
|
+
apiId: true,
|
|
63
|
+
};
|
|
64
|
+
const findManyArgs = (0, utils_1.parseFindManyArgs)(argv, defaultSelect);
|
|
56
65
|
const client = (0, executor_1.getClient)();
|
|
57
|
-
const result = await client.apiSchema
|
|
58
|
-
.findMany({
|
|
59
|
-
select: {
|
|
60
|
-
id: true,
|
|
61
|
-
databaseId: true,
|
|
62
|
-
schemaId: true,
|
|
63
|
-
apiId: true,
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
.execute();
|
|
66
|
+
const result = await client.apiSchema.findMany(findManyArgs).execute();
|
|
67
67
|
console.log(JSON.stringify(result, null, 2));
|
|
68
68
|
}
|
|
69
69
|
catch (error) {
|
|
@@ -74,6 +74,27 @@ async function handleList(_argv, _prompter) {
|
|
|
74
74
|
process.exit(1);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
async function handleFindFirst(argv, _prompter) {
|
|
78
|
+
try {
|
|
79
|
+
const defaultSelect = {
|
|
80
|
+
id: true,
|
|
81
|
+
databaseId: true,
|
|
82
|
+
schemaId: true,
|
|
83
|
+
apiId: true,
|
|
84
|
+
};
|
|
85
|
+
const findFirstArgs = (0, utils_1.parseFindFirstArgs)(argv, defaultSelect);
|
|
86
|
+
const client = (0, executor_1.getClient)();
|
|
87
|
+
const result = await client.apiSchema.findFirst(findFirstArgs).execute();
|
|
88
|
+
console.log(JSON.stringify(result, null, 2));
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error('Failed to find record.');
|
|
92
|
+
if (error instanceof Error) {
|
|
93
|
+
console.error(error.message);
|
|
94
|
+
}
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
77
98
|
async function handleGet(argv, prompter) {
|
|
78
99
|
try {
|
|
79
100
|
const answers = await prompter.prompt(argv, [
|