@xano/cli 1.0.6-beta.19 → 1.0.6-beta.20
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/README.md +57 -0
- package/dist/commands/tenant/create/index.d.ts +3 -0
- package/dist/commands/tenant/create/index.js +21 -0
- package/dist/commands/tenant/deploy_release/index.d.ts +21 -0
- package/dist/commands/tenant/deploy_release/index.js +94 -2
- package/dist/commands/tenant/edit/index.d.ts +2 -0
- package/dist/commands/tenant/edit/index.js +39 -4
- package/dist/commands/tenant_deploy_request/bypass/index.d.ts +20 -0
- package/dist/commands/tenant_deploy_request/bypass/index.js +79 -0
- package/dist/commands/tenant_deploy_request/create/index.d.ts +21 -0
- package/dist/commands/tenant_deploy_request/create/index.js +108 -0
- package/dist/commands/tenant_deploy_request/edit/index.d.ts +22 -0
- package/dist/commands/tenant_deploy_request/edit/index.js +103 -0
- package/dist/commands/tenant_deploy_request/get/index.d.ts +19 -0
- package/dist/commands/tenant_deploy_request/get/index.js +75 -0
- package/dist/commands/tenant_deploy_request/list/index.d.ts +20 -0
- package/dist/commands/tenant_deploy_request/list/index.js +122 -0
- package/dist/commands/tenant_deploy_request/revision/index.d.ts +21 -0
- package/dist/commands/tenant_deploy_request/revision/index.js +83 -0
- package/dist/commands/tenant_deploy_request/set_status/index.d.ts +21 -0
- package/dist/commands/tenant_deploy_request/set_status/index.js +112 -0
- package/oclif.manifest.json +4130 -3316
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestEdit extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
id: Args.integer({
|
|
6
|
+
description: 'Tenant deploy request ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = "Edit a tenant deploy request's title, description or reviewers. The author or an existing reviewer may do this.";
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano tenant_deploy_request edit 12 --title "Deploy v1.2.1 to prod"
|
|
13
|
+
Updated deploy request #12: "Deploy v1.2.1 to prod" [pending]
|
|
14
|
+
`,
|
|
15
|
+
`$ xano tenant_deploy_request edit 12 --reviewers 12,45,67 -o json`,
|
|
16
|
+
];
|
|
17
|
+
static flags = {
|
|
18
|
+
...BaseCommand.baseFlags,
|
|
19
|
+
description: Flags.string({
|
|
20
|
+
char: 'd',
|
|
21
|
+
description: 'New description',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
output: Flags.string({
|
|
25
|
+
char: 'o',
|
|
26
|
+
default: 'summary',
|
|
27
|
+
description: 'Output format',
|
|
28
|
+
options: ['summary', 'json'],
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
reviewers: Flags.string({
|
|
32
|
+
description: 'Replacement comma-separated user IDs to request review from',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
title: Flags.string({
|
|
36
|
+
description: 'New title',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
workspace: Flags.string({
|
|
40
|
+
char: 'w',
|
|
41
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
42
|
+
required: false,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
async run() {
|
|
46
|
+
const { args, flags } = await this.parse(TenantDeployRequestEdit);
|
|
47
|
+
const { profile } = this.resolveProfile(flags);
|
|
48
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
49
|
+
if (!workspaceId) {
|
|
50
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
51
|
+
}
|
|
52
|
+
const baseUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}`;
|
|
53
|
+
try {
|
|
54
|
+
const getResponse = await this.verboseFetch(baseUrl, {
|
|
55
|
+
headers: {
|
|
56
|
+
accept: 'application/json',
|
|
57
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
58
|
+
},
|
|
59
|
+
method: 'GET',
|
|
60
|
+
}, flags.verbose, profile.access_token);
|
|
61
|
+
if (!getResponse.ok) {
|
|
62
|
+
const message = await this.parseApiError(getResponse, 'Failed to fetch tenant deploy request');
|
|
63
|
+
this.error(message);
|
|
64
|
+
}
|
|
65
|
+
const current = (await getResponse.json());
|
|
66
|
+
const body = {
|
|
67
|
+
description: flags.description !== undefined ? flags.description : (current.description ?? ''),
|
|
68
|
+
reviewer_ids: flags.reviewers
|
|
69
|
+
? flags.reviewers.split(',').map((id) => Number.parseInt(id.trim(), 10))
|
|
70
|
+
: (current.reviewers ?? []).map((r) => r.id),
|
|
71
|
+
title: flags.title !== undefined ? flags.title : current.title,
|
|
72
|
+
};
|
|
73
|
+
const putResponse = await this.verboseFetch(baseUrl, {
|
|
74
|
+
body: JSON.stringify(body),
|
|
75
|
+
headers: {
|
|
76
|
+
accept: 'application/json',
|
|
77
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
},
|
|
80
|
+
method: 'PUT',
|
|
81
|
+
}, flags.verbose, profile.access_token);
|
|
82
|
+
if (!putResponse.ok) {
|
|
83
|
+
const message = await this.parseApiError(putResponse, 'Failed to edit tenant deploy request');
|
|
84
|
+
this.error(message);
|
|
85
|
+
}
|
|
86
|
+
const item = (await putResponse.json());
|
|
87
|
+
if (flags.output === 'json') {
|
|
88
|
+
this.log(JSON.stringify(item, null, 2));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.log(`Updated deploy request #${item.id}: "${item.title}" [${item.status}]`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
this.error(`Failed to edit tenant deploy request: ${error.message}`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.error(`Failed to edit tenant deploy request: ${String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class TenantDeployRequestGet extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
5
|
+
max?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: string[];
|
|
11
|
+
static flags: {
|
|
12
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestGet extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
id: Args.integer({
|
|
6
|
+
description: 'Tenant deploy request ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Get details of a specific tenant deploy request';
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano tenant_deploy_request get 12
|
|
13
|
+
Deploy request #12: "Deploy v1.2 to prod" [pending]
|
|
14
|
+
`,
|
|
15
|
+
`$ xano tenant_deploy_request get 12 -o json`,
|
|
16
|
+
];
|
|
17
|
+
static flags = {
|
|
18
|
+
...BaseCommand.baseFlags,
|
|
19
|
+
output: Flags.string({
|
|
20
|
+
char: 'o',
|
|
21
|
+
default: 'summary',
|
|
22
|
+
description: 'Output format',
|
|
23
|
+
options: ['summary', 'json'],
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
workspace: Flags.string({
|
|
27
|
+
char: 'w',
|
|
28
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(TenantDeployRequestGet);
|
|
34
|
+
const { profile } = this.resolveProfile(flags);
|
|
35
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
36
|
+
if (!workspaceId) {
|
|
37
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
38
|
+
}
|
|
39
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}`;
|
|
40
|
+
try {
|
|
41
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
42
|
+
headers: {
|
|
43
|
+
accept: 'application/json',
|
|
44
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
45
|
+
},
|
|
46
|
+
method: 'GET',
|
|
47
|
+
}, flags.verbose, profile.access_token);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const message = await this.parseApiError(response, 'Failed to get tenant deploy request');
|
|
50
|
+
this.error(message);
|
|
51
|
+
}
|
|
52
|
+
const item = (await response.json());
|
|
53
|
+
if (flags.output === 'json') {
|
|
54
|
+
this.log(JSON.stringify(item, null, 2));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.log(`Deploy request #${item.id}: "${item.title}" [${item.status}]`);
|
|
58
|
+
if (item.description)
|
|
59
|
+
this.log(` Description: ${item.description}`);
|
|
60
|
+
if (item.reviewers?.length)
|
|
61
|
+
this.log(` Reviewers: ${item.reviewers.map((r) => r.id).join(', ')}`);
|
|
62
|
+
if (item.can_review !== undefined)
|
|
63
|
+
this.log(` Can review: ${item.can_review}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof Error) {
|
|
68
|
+
this.error(`Failed to get tenant deploy request: ${error.message}`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.error(`Failed to get tenant deploy request: ${String(error)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class TenantDeployRequestList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
mine: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'per-page': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
release: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
tenant: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'to-review': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestList extends BaseCommand {
|
|
4
|
+
static description = 'List tenant deploy requests (deployment approval requests) in a workspace';
|
|
5
|
+
static examples = [
|
|
6
|
+
`$ xano tenant_deploy_request list
|
|
7
|
+
Deploy requests in workspace 5:
|
|
8
|
+
- #12 "Deploy v1.2 to prod" [pending] -> prod / v1.2
|
|
9
|
+
`,
|
|
10
|
+
`$ xano tenant_deploy_request list --tenant prod --status pending`,
|
|
11
|
+
`$ xano tenant_deploy_request list --tenant prod --release v1.2`,
|
|
12
|
+
`$ xano tenant_deploy_request list --to-review -o json`,
|
|
13
|
+
];
|
|
14
|
+
static flags = {
|
|
15
|
+
...BaseCommand.baseFlags,
|
|
16
|
+
mine: Flags.boolean({
|
|
17
|
+
default: false,
|
|
18
|
+
description: 'Only requests you authored',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
output: Flags.string({
|
|
22
|
+
char: 'o',
|
|
23
|
+
default: 'summary',
|
|
24
|
+
description: 'Output format',
|
|
25
|
+
options: ['summary', 'json'],
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
page: Flags.integer({
|
|
29
|
+
default: 1,
|
|
30
|
+
description: 'Page number',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
'per-page': Flags.integer({
|
|
34
|
+
default: 25,
|
|
35
|
+
description: 'Items per page',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
release: Flags.string({
|
|
39
|
+
char: 'r',
|
|
40
|
+
description: 'Filter to requests targeting this release. Applied client-side (the API has no release filter), after --page/--per-page, so a narrow page size can hide matches on other pages.',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
status: Flags.string({
|
|
44
|
+
description: 'Filter by status',
|
|
45
|
+
options: ['draft', 'pending', 'changes_requested', 'approved', 'closed'],
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
48
|
+
tenant: Flags.string({
|
|
49
|
+
description: 'Filter to requests targeting this tenant',
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
52
|
+
'to-review': Flags.boolean({
|
|
53
|
+
default: false,
|
|
54
|
+
description: 'Only requests you are able to review',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
workspace: Flags.string({
|
|
58
|
+
char: 'w',
|
|
59
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
async run() {
|
|
64
|
+
const { flags } = await this.parse(TenantDeployRequestList);
|
|
65
|
+
const { profile } = this.resolveProfile(flags);
|
|
66
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
67
|
+
if (!workspaceId) {
|
|
68
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
69
|
+
}
|
|
70
|
+
const params = new URLSearchParams();
|
|
71
|
+
if (flags.status)
|
|
72
|
+
params.set('status', flags.status);
|
|
73
|
+
if (flags.tenant)
|
|
74
|
+
params.set('tenant_name', flags.tenant);
|
|
75
|
+
if (flags.mine)
|
|
76
|
+
params.set('mine', 'true');
|
|
77
|
+
if (flags['to-review'])
|
|
78
|
+
params.set('to_review', 'true');
|
|
79
|
+
params.set('page', String(flags.page));
|
|
80
|
+
params.set('per_page', String(flags['per-page']));
|
|
81
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request?${params}`;
|
|
82
|
+
try {
|
|
83
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
84
|
+
headers: {
|
|
85
|
+
accept: 'application/json',
|
|
86
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
87
|
+
},
|
|
88
|
+
method: 'GET',
|
|
89
|
+
}, flags.verbose, profile.access_token);
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
const message = await this.parseApiError(response, 'Failed to list tenant deploy requests');
|
|
92
|
+
this.error(message);
|
|
93
|
+
}
|
|
94
|
+
const data = (await response.json());
|
|
95
|
+
const allItems = Array.isArray(data) ? data : (data.items ?? []);
|
|
96
|
+
const items = flags.release ? allItems.filter((item) => item._release?.name === flags.release) : allItems;
|
|
97
|
+
if (flags.output === 'json') {
|
|
98
|
+
this.log(JSON.stringify(items, null, 2));
|
|
99
|
+
}
|
|
100
|
+
else if (items.length === 0) {
|
|
101
|
+
this.log('No tenant deploy requests found');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.log(`Deploy requests in workspace ${workspaceId}:`);
|
|
105
|
+
for (const item of items) {
|
|
106
|
+
const review = item.can_review ? ' (reviewable)' : '';
|
|
107
|
+
const tenantName = item._tenant?.name ?? '?';
|
|
108
|
+
const releaseName = item._release?.name ?? '?';
|
|
109
|
+
this.log(` - #${item.id} "${item.title}" [${item.status}]${review} -> ${tenantName} / ${releaseName}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof Error) {
|
|
115
|
+
this.error(`Failed to list tenant deploy requests: ${error.message}`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.error(`Failed to list tenant deploy requests: ${String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class TenantDeployRequestRevision extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
5
|
+
max?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: string[];
|
|
11
|
+
static flags: {
|
|
12
|
+
note: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
release: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestRevision extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
id: Args.integer({
|
|
6
|
+
description: 'Tenant deploy request ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Link a newer release candidate to an existing tenant deploy request after changes were requested. The previous candidate is kept in the revision history and the request returns to pending. Author only.';
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano tenant_deploy_request revision 12 --release v1.2.1 --note "Added the missing migration"
|
|
13
|
+
Deploy request #12 is now: pending
|
|
14
|
+
`,
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
...BaseCommand.baseFlags,
|
|
18
|
+
note: Flags.string({
|
|
19
|
+
description: 'Note describing what changed in this revision',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
output: Flags.string({
|
|
23
|
+
char: 'o',
|
|
24
|
+
default: 'summary',
|
|
25
|
+
description: 'Output format',
|
|
26
|
+
options: ['summary', 'json'],
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
release: Flags.string({
|
|
30
|
+
char: 'r',
|
|
31
|
+
description: 'Name of the new release to review',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
workspace: Flags.string({
|
|
35
|
+
char: 'w',
|
|
36
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
async run() {
|
|
41
|
+
const { args, flags } = await this.parse(TenantDeployRequestRevision);
|
|
42
|
+
const { profile } = this.resolveProfile(flags);
|
|
43
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
44
|
+
if (!workspaceId) {
|
|
45
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
46
|
+
}
|
|
47
|
+
const body = {
|
|
48
|
+
note: flags.note ?? '',
|
|
49
|
+
release_name: flags.release,
|
|
50
|
+
};
|
|
51
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}/revision`;
|
|
52
|
+
try {
|
|
53
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
54
|
+
body: JSON.stringify(body),
|
|
55
|
+
headers: {
|
|
56
|
+
accept: 'application/json',
|
|
57
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
},
|
|
60
|
+
method: 'POST',
|
|
61
|
+
}, flags.verbose, profile.access_token);
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const message = await this.parseApiError(response, 'Failed to add revision to tenant deploy request');
|
|
64
|
+
this.error(message);
|
|
65
|
+
}
|
|
66
|
+
const item = (await response.json());
|
|
67
|
+
if (flags.output === 'json') {
|
|
68
|
+
this.log(JSON.stringify(item, null, 2));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.log(`Deploy request #${item.id} is now: ${item.status}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof Error) {
|
|
76
|
+
this.error(`Failed to add revision to tenant deploy request: ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.error(`Failed to add revision to tenant deploy request: ${String(error)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class TenantDeployRequestSetStatus extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
5
|
+
max?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: string[];
|
|
11
|
+
static flags: {
|
|
12
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
status: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestSetStatus extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
id: Args.integer({
|
|
6
|
+
description: 'Tenant deploy request ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = "[CRITICAL] STOP and confirm with the user before running --status approve; if this is the vote that completes the tenant's required reviewer count, it deploys the release to the tenant immediately as part of approving. Change a tenant deploy request's status (draft, submit, approve, request_changes, close, or reopen).";
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano tenant_deploy_request set_status 12 --status submit
|
|
13
|
+
Deploy request #12 is now: pending
|
|
14
|
+
`,
|
|
15
|
+
`$ xano tenant_deploy_request set_status 12 --status approve
|
|
16
|
+
Vote recorded on deploy request #12: 1/2 required reviewers.
|
|
17
|
+
`,
|
|
18
|
+
`$ xano tenant_deploy_request set_status 12 --status approve
|
|
19
|
+
Deploy request #12 is now: approved (2/2 required reviewers)
|
|
20
|
+
Deployed to tenant as part of this approval.
|
|
21
|
+
`,
|
|
22
|
+
`$ xano tenant_deploy_request set_status 12 --status request_changes --reason "Needs a migration note"`,
|
|
23
|
+
`$ xano tenant_deploy_request set_status 12 --status close --reason "Superseded by #14"`,
|
|
24
|
+
`$ xano tenant_deploy_request set_status 12 --status reopen`,
|
|
25
|
+
];
|
|
26
|
+
static flags = {
|
|
27
|
+
...BaseCommand.baseFlags,
|
|
28
|
+
output: Flags.string({
|
|
29
|
+
char: 'o',
|
|
30
|
+
default: 'summary',
|
|
31
|
+
description: 'Output format',
|
|
32
|
+
options: ['summary', 'json'],
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
reason: Flags.string({
|
|
36
|
+
description: 'Reason for this status change. Required for request_changes and close.',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
status: Flags.string({
|
|
40
|
+
description: 'The status transition to apply',
|
|
41
|
+
options: ['draft', 'submit', 'approve', 'request_changes', 'close', 'reopen'],
|
|
42
|
+
required: true,
|
|
43
|
+
}),
|
|
44
|
+
workspace: Flags.string({
|
|
45
|
+
char: 'w',
|
|
46
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
47
|
+
required: false,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
async run() {
|
|
51
|
+
const { args, flags } = await this.parse(TenantDeployRequestSetStatus);
|
|
52
|
+
const { profile } = this.resolveProfile(flags);
|
|
53
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
54
|
+
if (!workspaceId) {
|
|
55
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
56
|
+
}
|
|
57
|
+
if ((flags.status === 'request_changes' || flags.status === 'close') && !flags.reason) {
|
|
58
|
+
this.error(`--reason is required when --status is "${flags.status}"`);
|
|
59
|
+
}
|
|
60
|
+
const body = {
|
|
61
|
+
action: flags.status,
|
|
62
|
+
reason: flags.reason ?? '',
|
|
63
|
+
};
|
|
64
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}/status`;
|
|
65
|
+
try {
|
|
66
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
67
|
+
body: JSON.stringify(body),
|
|
68
|
+
headers: {
|
|
69
|
+
accept: 'application/json',
|
|
70
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
method: 'POST',
|
|
74
|
+
}, flags.verbose, profile.access_token);
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
const message = await this.parseApiError(response, 'Failed to change tenant deploy request status');
|
|
77
|
+
this.error(message);
|
|
78
|
+
}
|
|
79
|
+
const item = (await response.json());
|
|
80
|
+
if (flags.output === 'json') {
|
|
81
|
+
this.log(JSON.stringify(item, null, 2));
|
|
82
|
+
}
|
|
83
|
+
else if (flags.status === 'approve' && item.fully_approved === false) {
|
|
84
|
+
// required_reviewers > 1: this vote didn't complete the quorum, so status
|
|
85
|
+
// stays "pending" and nothing was deployed yet.
|
|
86
|
+
this.log(`Vote recorded on deploy request #${item.id}: ${item.approvals_count}/${item.required_reviewers} required reviewers.`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const quorum = item.approvals_count !== undefined && item.required_reviewers !== undefined
|
|
90
|
+
? ` (${item.approvals_count}/${item.required_reviewers} required reviewers)`
|
|
91
|
+
: '';
|
|
92
|
+
this.log(`Deploy request #${item.id} is now: ${item.status}${quorum}`);
|
|
93
|
+
if (flags.status === 'approve') {
|
|
94
|
+
if (item.resolution?.deploy_status === 'deployed') {
|
|
95
|
+
this.log('Deployed to tenant as part of this approval.');
|
|
96
|
+
}
|
|
97
|
+
else if (item.resolution?.deploy_status === 'failed') {
|
|
98
|
+
this.log(`Approved, but the deploy failed: ${item.resolution.deploy_error ?? 'unknown error'}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error instanceof Error) {
|
|
105
|
+
this.error(`Failed to change tenant deploy request status: ${error.message}`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.error(`Failed to change tenant deploy request status: ${String(error)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|