Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
197 changes: 104 additions & 93 deletions sdk/constructive-cli/src/admin/cli/commands.ts

Large diffs are not rendered by default.

350 changes: 196 additions & 154 deletions sdk/constructive-cli/src/admin/cli/commands/app-admin-grant.ts

Large diffs are not rendered by default.

350 changes: 196 additions & 154 deletions sdk/constructive-cli/src/admin/cli/commands/app-claimed-invite.ts

Large diffs are not rendered by default.

385 changes: 213 additions & 172 deletions sdk/constructive-cli/src/admin/cli/commands/app-grant.ts

Large diffs are not rendered by default.

689 changes: 373 additions & 316 deletions sdk/constructive-cli/src/admin/cli/commands/app-invite.ts

Large diffs are not rendered by default.

396 changes: 224 additions & 172 deletions sdk/constructive-cli/src/admin/cli/commands/app-membership-default.ts

Large diffs are not rendered by default.

726 changes: 394 additions & 332 deletions sdk/constructive-cli/src/admin/cli/commands/app-membership.ts

Large diffs are not rendered by default.

350 changes: 196 additions & 154 deletions sdk/constructive-cli/src/admin/cli/commands/app-owner-grant.ts

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,66 @@
* @generated by @constructive-io/graphql-codegen
* DO NOT EDIT - changes will be overwritten
*/
import { CLIOptions, Inquirerer, extractFirst } from "inquirerer";
import { getClient } from "../executor";
import { coerceAnswers, parseFindFirstArgs, parseFindManyArgs, stripUndefined } from "../utils";
import type { FieldSchema } from "../utils";
import type { CreateAppPermissionDefaultPermissionInput, AppPermissionDefaultPermissionPatch, AppPermissionDefaultPermissionSelect, AppPermissionDefaultPermissionFilter, AppPermissionDefaultPermissionOrderBy } from "../../orm/input-types";
import type { FindManyArgs, FindFirstArgs } from "../../orm/select-types";
import { CLIOptions, Inquirerer, extractFirst } from 'inquirerer';
import { getClient } from '../executor';
import { coerceAnswers, parseFindFirstArgs, parseFindManyArgs, stripUndefined } from '../utils';
import type { FieldSchema } from '../utils';
import type {
CreateAppPermissionDefaultPermissionInput,
AppPermissionDefaultPermissionPatch,
AppPermissionDefaultPermissionSelect,
AppPermissionDefaultPermissionFilter,
AppPermissionDefaultPermissionOrderBy,
} from '../../orm/input-types';
import type { FindManyArgs, FindFirstArgs } from '../../orm/select-types';
const fieldSchema: FieldSchema = {
createdAt: "string",
id: "uuid",
permissionId: "uuid",
updatedAt: "string"
createdAt: 'string',
id: 'uuid',
permissionId: 'uuid',
updatedAt: 'string',
};
const usage = "\napp-permission-default-permission <command>\n\nCommands:\n list List appPermissionDefaultPermission records\n find-first Find first matching appPermissionDefaultPermission record\n get Get a appPermissionDefaultPermission by ID\n create Create a new appPermissionDefaultPermission\n update Update an existing appPermissionDefaultPermission\n delete Delete a appPermissionDefaultPermission\n\nList Options:\n --limit <n> Max number of records to return (forward pagination)\n --last <n> Number of records from the end (backward pagination)\n --after <cursor> Cursor for forward pagination\n --before <cursor> Cursor for backward pagination\n --offset <n> Number of records to skip\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\nFind-First Options:\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\n --help, -h Show this help message\n";
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
const usage =
'\napp-permission-default-permission <command>\n\nCommands:\n list List appPermissionDefaultPermission records\n find-first Find first matching appPermissionDefaultPermission record\n get Get a appPermissionDefaultPermission by ID\n create Create a new appPermissionDefaultPermission\n update Update an existing appPermissionDefaultPermission\n delete Delete a appPermissionDefaultPermission\n\nList Options:\n --limit <n> Max number of records to return (forward pagination)\n --last <n> Number of records from the end (backward pagination)\n --after <cursor> Cursor for forward pagination\n --before <cursor> Cursor for backward pagination\n --offset <n> Number of records to skip\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\nFind-First Options:\n --select <fields> Comma-separated list of fields to return\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\n --condition.<f>.<op> Condition filter (dot-notation)\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\n --help, -h Show this help message\n';
export default async (
argv: Partial<Record<string, unknown>>,
prompter: Inquirerer,
_options: CLIOptions
) => {
if (argv.help || argv.h) {
console.log(usage);
process.exit(0);
}
const {
first: subcommand,
newArgv
} = extractFirst(argv);
const { first: subcommand, newArgv } = extractFirst(argv);
if (!subcommand) {
const answer = await prompter.prompt(argv, [{
type: "autocomplete",
name: "subcommand",
message: "What do you want to do?",
options: ["list", "find-first", "get", "create", "update", "delete"]
}]);
const answer = await prompter.prompt(argv, [
{
type: 'autocomplete',
name: 'subcommand',
message: 'What do you want to do?',
options: ['list', 'find-first', 'get', 'create', 'update', 'delete'],
},
]);
return handleTableSubcommand(answer.subcommand as string, newArgv, prompter);
}
return handleTableSubcommand(subcommand, newArgv, prompter);
};
async function handleTableSubcommand(subcommand: string, argv: Partial<Record<string, unknown>>, prompter: Inquirerer) {
async function handleTableSubcommand(
subcommand: string,
argv: Partial<Record<string, unknown>>,
prompter: Inquirerer
) {
switch (subcommand) {
case "list":
case 'list':
return handleList(argv, prompter);
case "find-first":
case 'find-first':
return handleFindFirst(argv, prompter);
case "get":
case 'get':
return handleGet(argv, prompter);
case "create":
case 'create':
return handleCreate(argv, prompter);
case "update":
case 'update':
return handleUpdate(argv, prompter);
case "delete":
case 'delete':
return handleDelete(argv, prompter);
default:
console.log(usage);
Expand All @@ -61,16 +75,22 @@ async function handleList(argv: Partial<Record<string, unknown>>, _prompter: Inq
createdAt: true,
id: true,
permissionId: true,
updatedAt: true
updatedAt: true,
};
const findManyArgs = parseFindManyArgs<FindManyArgs<AppPermissionDefaultPermissionSelect, AppPermissionDefaultPermissionFilter, AppPermissionDefaultPermissionOrderBy> & {
select: AppPermissionDefaultPermissionSelect;
}>(argv, defaultSelect);
const findManyArgs = parseFindManyArgs<
FindManyArgs<
AppPermissionDefaultPermissionSelect,
AppPermissionDefaultPermissionFilter,
AppPermissionDefaultPermissionOrderBy
> & {
select: AppPermissionDefaultPermissionSelect;
}
>(argv, defaultSelect);
const client = getClient();
const result = await client.appPermissionDefaultPermission.findMany(findManyArgs).execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Failed to list records.");
console.error('Failed to list records.');
if (error instanceof Error) {
console.error(error.message);
}
Expand All @@ -83,16 +103,22 @@ async function handleFindFirst(argv: Partial<Record<string, unknown>>, _prompter
createdAt: true,
id: true,
permissionId: true,
updatedAt: true
updatedAt: true,
};
const findFirstArgs = parseFindFirstArgs<FindFirstArgs<AppPermissionDefaultPermissionSelect, AppPermissionDefaultPermissionFilter, AppPermissionDefaultPermissionOrderBy> & {
select: AppPermissionDefaultPermissionSelect;
}>(argv, defaultSelect);
const findFirstArgs = parseFindFirstArgs<
FindFirstArgs<
AppPermissionDefaultPermissionSelect,
AppPermissionDefaultPermissionFilter,
AppPermissionDefaultPermissionOrderBy
> & {
select: AppPermissionDefaultPermissionSelect;
}
>(argv, defaultSelect);
const client = getClient();
const result = await client.appPermissionDefaultPermission.findFirst(findFirstArgs).execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Failed to find record.");
console.error('Failed to find record.');
if (error instanceof Error) {
console.error(error.message);
}
Expand All @@ -101,25 +127,29 @@ async function handleFindFirst(argv: Partial<Record<string, unknown>>, _prompter
}
async function handleGet(argv: Partial<Record<string, unknown>>, prompter: Inquirerer) {
try {
const answers = await prompter.prompt(argv, [{
type: "text",
name: "id",
message: "id",
required: true
}]);
const answers = await prompter.prompt(argv, [
{
type: 'text',
name: 'id',
message: 'id',
required: true,
},
]);
const client = getClient();
const result = await client.appPermissionDefaultPermission.findOne({
id: answers.id as string,
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true
}
}).execute();
const result = await client.appPermissionDefaultPermission
.findOne({
id: answers.id as string,
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true,
},
})
.execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Record not found.");
console.error('Record not found.');
if (error instanceof Error) {
console.error(error.message);
}
Expand All @@ -128,29 +158,36 @@ async function handleGet(argv: Partial<Record<string, unknown>>, prompter: Inqui
}
async function handleCreate(argv: Partial<Record<string, unknown>>, prompter: Inquirerer) {
try {
const rawAnswers = await prompter.prompt(argv, [{
type: "text",
name: "permissionId",
message: "permissionId",
required: true
}]);
const rawAnswers = await prompter.prompt(argv, [
{
type: 'text',
name: 'permissionId',
message: 'permissionId',
required: true,
},
]);
const answers = coerceAnswers(rawAnswers, fieldSchema);
const cleanedData = stripUndefined(answers, fieldSchema) as CreateAppPermissionDefaultPermissionInput["appPermissionDefaultPermission"];
const cleanedData = stripUndefined(
answers,
fieldSchema
) as CreateAppPermissionDefaultPermissionInput['appPermissionDefaultPermission'];
const client = getClient();
const result = await client.appPermissionDefaultPermission.create({
data: {
permissionId: cleanedData.permissionId
},
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true
}
}).execute();
const result = await client.appPermissionDefaultPermission
.create({
data: {
permissionId: cleanedData.permissionId,
},
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true,
},
})
.execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Failed to create record.");
console.error('Failed to create record.');
if (error instanceof Error) {
console.error(error.message);
}
Expand All @@ -159,37 +196,42 @@ async function handleCreate(argv: Partial<Record<string, unknown>>, prompter: In
}
async function handleUpdate(argv: Partial<Record<string, unknown>>, prompter: Inquirerer) {
try {
const rawAnswers = await prompter.prompt(argv, [{
type: "text",
name: "id",
message: "id",
required: true
}, {
type: "text",
name: "permissionId",
message: "permissionId",
required: false
}]);
const rawAnswers = await prompter.prompt(argv, [
{
type: 'text',
name: 'id',
message: 'id',
required: true,
},
{
type: 'text',
name: 'permissionId',
message: 'permissionId',
required: false,
},
]);
const answers = coerceAnswers(rawAnswers, fieldSchema);
const cleanedData = stripUndefined(answers, fieldSchema) as AppPermissionDefaultPermissionPatch;
const client = getClient();
const result = await client.appPermissionDefaultPermission.update({
where: {
id: answers.id as string
},
data: {
permissionId: cleanedData.permissionId
},
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true
}
}).execute();
const result = await client.appPermissionDefaultPermission
.update({
where: {
id: answers.id as string,
},
data: {
permissionId: cleanedData.permissionId,
},
select: {
createdAt: true,
id: true,
permissionId: true,
updatedAt: true,
},
})
.execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Failed to update record.");
console.error('Failed to update record.');
if (error instanceof Error) {
console.error(error.message);
}
Expand All @@ -198,28 +240,32 @@ async function handleUpdate(argv: Partial<Record<string, unknown>>, prompter: In
}
async function handleDelete(argv: Partial<Record<string, unknown>>, prompter: Inquirerer) {
try {
const rawAnswers = await prompter.prompt(argv, [{
type: "text",
name: "id",
message: "id",
required: true
}]);
const rawAnswers = await prompter.prompt(argv, [
{
type: 'text',
name: 'id',
message: 'id',
required: true,
},
]);
const answers = coerceAnswers(rawAnswers, fieldSchema);
const client = getClient();
const result = await client.appPermissionDefaultPermission.delete({
where: {
id: answers.id as string
},
select: {
id: true
}
}).execute();
const result = await client.appPermissionDefaultPermission
.delete({
where: {
id: answers.id as string,
},
select: {
id: true,
},
})
.execute();
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Failed to delete record.");
console.error('Failed to delete record.');
if (error instanceof Error) {
console.error(error.message);
}
process.exit(1);
}
}
}
Loading
Loading