@xano/cli 1.3.3 → 1.3.5-beta.0
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 +137 -3
- package/dist/base-command.d.ts +12 -1
- package/dist/base-command.js +36 -22
- package/dist/commands/branch/set_live/index.d.ts +14 -0
- package/dist/commands/branch/set_live/index.js +38 -0
- package/dist/commands/ephemeral/push/index.js +6 -1
- package/dist/commands/function/create/index.d.ts +15 -0
- package/dist/commands/function/create/index.js +39 -0
- package/dist/commands/function/edit/index.d.ts +15 -0
- package/dist/commands/function/edit/index.js +39 -0
- package/dist/commands/function/run/index.js +5 -11
- package/dist/commands/policy/catalogue/index.d.ts +16 -0
- package/dist/commands/policy/catalogue/index.js +60 -0
- package/dist/commands/policy/coverage/index.d.ts +17 -0
- package/dist/commands/policy/coverage/index.js +33 -0
- package/dist/commands/policy/create/index.d.ts +18 -0
- package/dist/commands/policy/create/index.js +44 -0
- package/dist/commands/policy/delete/index.d.ts +19 -0
- package/dist/commands/policy/delete/index.js +61 -0
- package/dist/commands/policy/evaluate/index.d.ts +32 -0
- package/dist/commands/policy/evaluate/index.js +71 -0
- package/dist/commands/policy/list/index.d.ts +14 -0
- package/dist/commands/policy/list/index.js +21 -0
- package/dist/commands/policy/parse/index.d.ts +19 -0
- package/dist/commands/policy/parse/index.js +18 -0
- package/dist/commands/policy/publish/index.d.ts +20 -0
- package/dist/commands/policy/publish/index.js +38 -0
- package/dist/commands/policy/runs/index.d.ts +54 -0
- package/dist/commands/policy/runs/index.js +273 -0
- package/dist/commands/policy/status/index.d.ts +21 -0
- package/dist/commands/policy/status/index.js +54 -0
- package/dist/commands/release/create/index.js +4 -0
- package/dist/commands/release/deploy/index.d.ts +19 -0
- package/dist/commands/release/deploy/index.js +68 -6
- package/dist/commands/release/import/index.js +5 -1
- package/dist/commands/release/list/index.d.ts +7 -0
- package/dist/commands/release/list/index.js +46 -9
- package/dist/commands/release/push/index.js +19 -1
- package/dist/commands/sandbox/delete/index.js +8 -0
- package/dist/commands/sandbox/pull/index.d.ts +7 -0
- package/dist/commands/sandbox/pull/index.js +49 -0
- package/dist/commands/sandbox/push/index.d.ts +4 -0
- package/dist/commands/sandbox/push/index.js +59 -2
- package/dist/commands/sandbox/reset/index.js +8 -0
- package/dist/commands/skills/pull/index.d.ts +30 -0
- package/dist/commands/skills/pull/index.js +118 -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 +40 -0
- package/dist/commands/tenant/deploy_release/index.js +182 -4
- 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 +31 -0
- package/dist/commands/tenant_deploy_request/bypass/index.js +109 -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 +25 -0
- package/dist/commands/tenant_deploy_request/get/index.js +113 -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 +38 -0
- package/dist/commands/tenant_deploy_request/set_status/index.js +159 -0
- package/dist/commands/workspace/pull/index.d.ts +17 -0
- package/dist/commands/workspace/pull/index.js +124 -7
- package/dist/commands/workspace/push/index.d.ts +23 -0
- package/dist/commands/workspace/push/index.js +188 -6
- package/dist/policy-command.d.ts +91 -0
- package/dist/policy-command.js +95 -0
- package/dist/utils/document-parser.d.ts +10 -0
- package/dist/utils/document-parser.js +21 -0
- package/dist/utils/export-compare.d.ts +52 -0
- package/dist/utils/export-compare.js +134 -0
- package/dist/utils/local-config.d.ts +23 -0
- package/dist/utils/local-config.js +62 -2
- package/dist/utils/multidoc-push.d.ts +124 -4
- package/dist/utils/multidoc-push.js +670 -49
- package/dist/utils/object-fetch.d.ts +86 -0
- package/dist/utils/object-fetch.js +265 -0
- package/dist/utils/policy/catalogue.d.ts +85 -0
- package/dist/utils/policy/catalogue.js +196 -0
- package/dist/utils/policy/coverage.d.ts +19 -0
- package/dist/utils/policy/coverage.js +93 -0
- package/dist/utils/policy/errors.d.ts +20 -0
- package/dist/utils/policy/errors.js +93 -0
- package/dist/utils/policy/feedback.d.ts +90 -0
- package/dist/utils/policy/feedback.js +210 -0
- package/dist/utils/policy/findings.d.ts +29 -0
- package/dist/utils/policy/findings.js +82 -0
- package/dist/utils/policy/gate.d.ts +138 -0
- package/dist/utils/policy/gate.js +193 -0
- package/dist/utils/policy/permission.d.ts +7 -0
- package/dist/utils/policy/permission.js +55 -0
- package/dist/utils/policy/push-gate.d.ts +5 -0
- package/dist/utils/policy/push-gate.js +43 -0
- package/dist/utils/policy/release.d.ts +85 -0
- package/dist/utils/policy/release.js +117 -0
- package/dist/utils/policy/request.d.ts +55 -0
- package/dist/utils/policy/request.js +119 -0
- package/dist/utils/policy/runs.d.ts +30 -0
- package/dist/utils/policy/runs.js +101 -0
- package/dist/utils/policy/status.d.ts +55 -0
- package/dist/utils/policy/status.js +127 -0
- package/dist/utils/policy/template.d.ts +66 -0
- package/dist/utils/policy/template.js +152 -0
- package/dist/utils/policy/types.d.ts +295 -0
- package/dist/utils/policy/types.js +1 -0
- package/dist/utils/reference-checker.d.ts +3 -0
- package/dist/utils/reference-checker.js +3 -2
- package/dist/utils/sandbox-marker.d.ts +9 -0
- package/dist/utils/sandbox-marker.js +119 -0
- package/dist/utils/sync-state.d.ts +71 -0
- package/dist/utils/sync-state.js +353 -0
- package/oclif.manifest.json +6472 -3181
- package/package.json +9 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class TenantDeployRequestCreate extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
title: Args.string({
|
|
6
|
+
description: 'Short title for the deploy request',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Open a tenant deploy request asking named reviewers to approve deploying a release to a tenant. Submits for review immediately unless --draft is passed.';
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano tenant_deploy_request create "Deploy v1.2 to prod" --tenant prod --release v1.2 --reviewers 12,45
|
|
13
|
+
Created deploy request #12: "Deploy v1.2 to prod" [pending]
|
|
14
|
+
`,
|
|
15
|
+
`$ xano tenant_deploy_request create "Deploy v1.2 to prod" --tenant prod --release v1.2 --draft`,
|
|
16
|
+
`$ xano tenant_deploy_request create "$PR_TITLE" --tenant prod --release v1.2 --description "$PR_BODY" --reviewers 12,45 -o json`,
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
description: Flags.string({
|
|
21
|
+
char: 'd',
|
|
22
|
+
description: 'Longer description of what is being deployed and why',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
draft: Flags.boolean({
|
|
26
|
+
default: false,
|
|
27
|
+
description: 'Save as a draft instead of submitting immediately (reviewers are not notified until submitted)',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
output: Flags.string({
|
|
31
|
+
char: 'o',
|
|
32
|
+
default: 'summary',
|
|
33
|
+
description: 'Output format',
|
|
34
|
+
options: ['summary', 'json'],
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
release: Flags.string({
|
|
38
|
+
char: 'r',
|
|
39
|
+
description: 'Name of the release to deploy',
|
|
40
|
+
required: true,
|
|
41
|
+
}),
|
|
42
|
+
reviewers: Flags.string({
|
|
43
|
+
description: 'Comma-separated user IDs to request review from',
|
|
44
|
+
required: false,
|
|
45
|
+
}),
|
|
46
|
+
tenant: Flags.string({
|
|
47
|
+
char: 't',
|
|
48
|
+
description: 'Name of the target tenant',
|
|
49
|
+
required: true,
|
|
50
|
+
}),
|
|
51
|
+
workspace: Flags.string({
|
|
52
|
+
char: 'w',
|
|
53
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
54
|
+
required: false,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
async run() {
|
|
58
|
+
const { args, flags } = await this.parse(TenantDeployRequestCreate);
|
|
59
|
+
const { profile } = this.resolveProfile(flags);
|
|
60
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
61
|
+
if (!workspaceId) {
|
|
62
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
63
|
+
}
|
|
64
|
+
const reviewerIds = flags.reviewers
|
|
65
|
+
? flags.reviewers.split(',').map((id) => Number.parseInt(id.trim(), 10))
|
|
66
|
+
: [];
|
|
67
|
+
const body = {
|
|
68
|
+
release_name: flags.release,
|
|
69
|
+
reviewer_ids: reviewerIds,
|
|
70
|
+
status: flags.draft ? 'draft' : 'pending',
|
|
71
|
+
tenant_name: flags.tenant,
|
|
72
|
+
title: args.title,
|
|
73
|
+
};
|
|
74
|
+
if (flags.description)
|
|
75
|
+
body.description = flags.description;
|
|
76
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request`;
|
|
77
|
+
try {
|
|
78
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
79
|
+
body: JSON.stringify(body),
|
|
80
|
+
headers: {
|
|
81
|
+
accept: 'application/json',
|
|
82
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
},
|
|
85
|
+
method: 'POST',
|
|
86
|
+
}, flags.verbose, profile.access_token);
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const message = await this.parseApiError(response, 'Failed to create tenant deploy request');
|
|
89
|
+
this.error(message);
|
|
90
|
+
}
|
|
91
|
+
const item = (await response.json());
|
|
92
|
+
if (flags.output === 'json') {
|
|
93
|
+
this.log(JSON.stringify(item, null, 2));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.log(`Created deploy request #${item.id}: "${item.title}" [${item.status}]`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
this.error(`Failed to create tenant deploy request: ${error.message}`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.error(`Failed to create tenant deploy request: ${String(error)}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class TenantDeployRequestEdit 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
|
+
description: 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
|
+
reviewers: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -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 ? (current.description ?? '') : flags.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 ? current.title : flags.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,25 @@
|
|
|
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
|
+
/**
|
|
20
|
+
* The policy gate's verdict on the request's release for its tenant, as a deploy now would meet it.
|
|
21
|
+
* Only a policy reader gets one; any refusal or failure is a reason it is not available, never an
|
|
22
|
+
* error of this command.
|
|
23
|
+
*/
|
|
24
|
+
private policyCheck;
|
|
25
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
import { fetchPolicyGate, gateLines, unavailableReason } from '../../../utils/policy/gate.js';
|
|
4
|
+
export default class TenantDeployRequestGet extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
id: Args.integer({
|
|
7
|
+
description: 'Tenant deploy request ID',
|
|
8
|
+
required: true,
|
|
9
|
+
}),
|
|
10
|
+
};
|
|
11
|
+
static description = 'Get details of a specific tenant deploy request';
|
|
12
|
+
static examples = [
|
|
13
|
+
`$ xano tenant_deploy_request get 12
|
|
14
|
+
Deploy request #12: "Deploy v1.2 to prod" [pending]
|
|
15
|
+
Tenant: prod
|
|
16
|
+
Release: v1.2
|
|
17
|
+
`,
|
|
18
|
+
`$ xano tenant_deploy_request get 12 -o json`,
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
...BaseCommand.baseFlags,
|
|
22
|
+
output: Flags.string({
|
|
23
|
+
char: 'o',
|
|
24
|
+
default: 'summary',
|
|
25
|
+
description: 'Output format',
|
|
26
|
+
options: ['summary', 'json'],
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
workspace: Flags.string({
|
|
30
|
+
char: 'w',
|
|
31
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
async run() {
|
|
36
|
+
const { args, flags } = await this.parse(TenantDeployRequestGet);
|
|
37
|
+
const { profile } = this.resolveProfile(flags);
|
|
38
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
39
|
+
if (!workspaceId) {
|
|
40
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
41
|
+
}
|
|
42
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}`;
|
|
43
|
+
try {
|
|
44
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
45
|
+
headers: {
|
|
46
|
+
accept: 'application/json',
|
|
47
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
48
|
+
},
|
|
49
|
+
method: 'GET',
|
|
50
|
+
}, flags.verbose, profile.access_token);
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
const message = await this.parseApiError(response, 'Failed to get tenant deploy request');
|
|
53
|
+
this.error(message);
|
|
54
|
+
}
|
|
55
|
+
const item = (await response.json());
|
|
56
|
+
const policyCheck = await this.policyCheck(item, { profile, verbose: flags.verbose, workspaceId });
|
|
57
|
+
if (flags.output === 'json') {
|
|
58
|
+
this.log(JSON.stringify({ ...item, policy_gate: policyCheck.answer ?? null,
|
|
59
|
+
...(policyCheck.unavailable ? { policy_gate_unavailable: policyCheck.unavailable } : {}) }, null, 2));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.log(`Deploy request #${item.id}: "${item.title}" [${item.status}]`);
|
|
63
|
+
this.log(` Tenant: ${item._tenant?.name || (item.deployment?.tenant?.id ? `#${item.deployment.tenant.id}` : 'unavailable')}`);
|
|
64
|
+
this.log(` Release: ${item._release?.name || (item.deployment?.release?.id ? `#${item.deployment.release.id}` : 'unavailable')}`);
|
|
65
|
+
if (item.description)
|
|
66
|
+
this.log(` Description: ${item.description}`);
|
|
67
|
+
if (item.reviewers?.length)
|
|
68
|
+
this.log(` Reviewers: ${item.reviewers.map((r) => r.id).join(', ')}`);
|
|
69
|
+
if (item.can_review !== undefined)
|
|
70
|
+
this.log(` Can review: ${item.can_review}`);
|
|
71
|
+
if (policyCheck.answer) {
|
|
72
|
+
this.log(`Policy check of release "${item._release?.name}" on tenant "${item._tenant?.name}":`);
|
|
73
|
+
for (const line of gateLines(policyCheck.answer))
|
|
74
|
+
this.log(line);
|
|
75
|
+
}
|
|
76
|
+
else if (policyCheck.unavailable) {
|
|
77
|
+
this.log(`Policy checks: not available (${policyCheck.unavailable})`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof Error) {
|
|
83
|
+
this.error(`Failed to get tenant deploy request: ${error.message}`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.error(`Failed to get tenant deploy request: ${String(error)}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The policy gate's verdict on the request's release for its tenant, as a deploy now would meet it.
|
|
92
|
+
* Only a policy reader gets one; any refusal or failure is a reason it is not available, never an
|
|
93
|
+
* error of this command.
|
|
94
|
+
*/
|
|
95
|
+
async policyCheck(item, target) {
|
|
96
|
+
// Terminal requests are historical records: previewing now can check a different base release.
|
|
97
|
+
if (['approved', 'closed'].includes(item.status))
|
|
98
|
+
return {};
|
|
99
|
+
const tenant = item._tenant?.name?.trim();
|
|
100
|
+
const release = item._release?.name?.trim();
|
|
101
|
+
if (!tenant || !release)
|
|
102
|
+
return { unavailable: 'the request does not name its tenant and release' };
|
|
103
|
+
try {
|
|
104
|
+
const result = await fetchPolicyGate({ verboseFetch: (...args) => this.verboseFetch(...args) }, { profile: target.profile, release, tenant, verbose: target.verbose, workspace: String(target.workspaceId) });
|
|
105
|
+
if ('answer' in result)
|
|
106
|
+
return result.answer.status === 'disabled' ? {} : { answer: result.answer };
|
|
107
|
+
return result.unavailable.payload?.code === 'policy_feature_disabled' ? {} : { unavailable: unavailableReason(result.unavailable) };
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return { unavailable: error instanceof Error ? error.message : String(error) };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -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,38 @@
|
|
|
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
|
+
'override-policy': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
status: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
/** Set once the policy gate refuses the deploy an approval triggered, the one failure that exits 2. */
|
|
22
|
+
private refusedByPolicyGate;
|
|
23
|
+
/** Exit 2 is the policy gate's refusal; every other failure, flag errors included, exits 1. */
|
|
24
|
+
protected catch(error: Error & {
|
|
25
|
+
oclif?: {
|
|
26
|
+
exit?: number;
|
|
27
|
+
};
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
run(): Promise<void>;
|
|
30
|
+
/** `--override-policy` overrides the deploy an approve can trigger, and its reason is `--reason`. */
|
|
31
|
+
private checkOverride;
|
|
32
|
+
/**
|
|
33
|
+
* The deploy this approval triggered was refused by the policy gate: its verdict, then the refusal,
|
|
34
|
+
* exiting 2. The vote that completes the approvals is recorded before the deploy, so the request
|
|
35
|
+
* stays approved, and a later deploy of the pair that overrides the gate completes it.
|
|
36
|
+
*/
|
|
37
|
+
private refuseByPolicyGate;
|
|
38
|
+
}
|