@xano/cli 1.2.0 → 1.3.1-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.
Files changed (192) hide show
  1. package/README.md +381 -4
  2. package/dist/base-command.d.ts +54 -36
  3. package/dist/base-command.js +246 -169
  4. package/dist/commands/auth/index.d.ts +1 -1
  5. package/dist/commands/auth/index.js +7 -7
  6. package/dist/commands/branch/create/index.d.ts +1 -1
  7. package/dist/commands/branch/create/index.js +1 -1
  8. package/dist/commands/branch/set_live/index.d.ts +22 -0
  9. package/dist/commands/branch/set_live/index.js +60 -1
  10. package/dist/commands/ephemeral/create/index.d.ts +18 -0
  11. package/dist/commands/ephemeral/create/index.js +103 -0
  12. package/dist/commands/ephemeral/delete/index.d.ts +18 -0
  13. package/dist/commands/ephemeral/delete/index.js +99 -0
  14. package/dist/commands/ephemeral/edit/index.d.ts +18 -0
  15. package/dist/commands/ephemeral/edit/index.js +109 -0
  16. package/dist/commands/ephemeral/get/index.d.ts +21 -0
  17. package/dist/commands/ephemeral/get/index.js +125 -0
  18. package/dist/commands/ephemeral/impersonate/index.d.ts +20 -0
  19. package/dist/commands/ephemeral/impersonate/index.js +120 -0
  20. package/dist/commands/ephemeral/list/index.d.ts +19 -0
  21. package/dist/commands/ephemeral/list/index.js +123 -0
  22. package/dist/commands/ephemeral/pull/index.d.ts +19 -0
  23. package/dist/commands/ephemeral/pull/index.js +163 -0
  24. package/dist/commands/ephemeral/push/index.d.ts +35 -0
  25. package/dist/commands/ephemeral/push/index.js +228 -0
  26. package/dist/commands/ephemeral/static_host/build/delete/index.d.ts +20 -0
  27. package/dist/commands/ephemeral/static_host/build/delete/index.js +121 -0
  28. package/dist/commands/ephemeral/static_host/build/get/index.d.ts +18 -0
  29. package/dist/commands/ephemeral/static_host/build/get/index.js +137 -0
  30. package/dist/commands/ephemeral/static_host/build/list/index.d.ts +18 -0
  31. package/dist/commands/ephemeral/static_host/build/list/index.js +137 -0
  32. package/dist/commands/ephemeral/static_host/build/pull/index.d.ts +53 -0
  33. package/dist/commands/ephemeral/static_host/build/pull/index.js +308 -0
  34. package/dist/commands/ephemeral/static_host/build/push/index.d.ts +24 -0
  35. package/dist/commands/ephemeral/static_host/build/push/index.js +250 -0
  36. package/dist/commands/ephemeral/static_host/create/index.d.ts +18 -0
  37. package/dist/commands/ephemeral/static_host/create/index.js +92 -0
  38. package/dist/commands/ephemeral/static_host/deploy/index.d.ts +19 -0
  39. package/dist/commands/ephemeral/static_host/deploy/index.js +112 -0
  40. package/dist/commands/ephemeral/static_host/edit/index.d.ts +24 -0
  41. package/dist/commands/ephemeral/static_host/edit/index.js +158 -0
  42. package/dist/commands/ephemeral/static_host/get/index.d.ts +19 -0
  43. package/dist/commands/ephemeral/static_host/get/index.js +101 -0
  44. package/dist/commands/ephemeral/static_host/list/index.d.ts +17 -0
  45. package/dist/commands/ephemeral/static_host/list/index.js +132 -0
  46. package/dist/commands/flatten/index.d.ts +34 -0
  47. package/dist/commands/flatten/index.js +140 -0
  48. package/dist/commands/function/create/index.d.ts +15 -0
  49. package/dist/commands/function/create/index.js +41 -1
  50. package/dist/commands/function/edit/index.d.ts +15 -0
  51. package/dist/commands/function/edit/index.js +66 -32
  52. package/dist/commands/function/get/index.js +2 -3
  53. package/dist/commands/function/run/index.d.ts +1 -0
  54. package/dist/commands/function/run/index.js +19 -6
  55. package/dist/commands/policy/catalogue/index.d.ts +15 -0
  56. package/dist/commands/policy/catalogue/index.js +29 -0
  57. package/dist/commands/policy/create/index.d.ts +18 -0
  58. package/dist/commands/policy/create/index.js +39 -0
  59. package/dist/commands/policy/delete/index.d.ts +19 -0
  60. package/dist/commands/policy/delete/index.js +61 -0
  61. package/dist/commands/policy/evaluate/index.d.ts +32 -0
  62. package/dist/commands/policy/evaluate/index.js +71 -0
  63. package/dist/commands/policy/list/index.d.ts +14 -0
  64. package/dist/commands/policy/list/index.js +21 -0
  65. package/dist/commands/policy/parse/index.d.ts +19 -0
  66. package/dist/commands/policy/parse/index.js +18 -0
  67. package/dist/commands/policy/publish/index.d.ts +20 -0
  68. package/dist/commands/policy/publish/index.js +38 -0
  69. package/dist/commands/policy/runs/index.d.ts +54 -0
  70. package/dist/commands/policy/runs/index.js +273 -0
  71. package/dist/commands/policy/status/index.d.ts +21 -0
  72. package/dist/commands/policy/status/index.js +54 -0
  73. package/dist/commands/profile/create/index.d.ts +1 -1
  74. package/dist/commands/profile/create/index.js +7 -7
  75. package/dist/commands/profile/me/index.js +1 -1
  76. package/dist/commands/profile/use/index.js +0 -4
  77. package/dist/commands/profile/wizard/index.d.ts +1 -1
  78. package/dist/commands/profile/wizard/index.js +12 -10
  79. package/dist/commands/profile/workspace/set/index.js +1 -1
  80. package/dist/commands/release/create/index.js +7 -0
  81. package/dist/commands/release/deploy/index.d.ts +28 -0
  82. package/dist/commands/release/deploy/index.js +90 -6
  83. package/dist/commands/release/edit/index.js +2 -2
  84. package/dist/commands/release/export/index.js +1 -2
  85. package/dist/commands/release/import/index.js +6 -2
  86. package/dist/commands/release/list/index.d.ts +7 -0
  87. package/dist/commands/release/list/index.js +54 -10
  88. package/dist/commands/release/pull/index.d.ts +0 -6
  89. package/dist/commands/release/pull/index.js +13 -99
  90. package/dist/commands/release/push/index.js +21 -3
  91. package/dist/commands/sandbox/env/get_all/index.js +1 -1
  92. package/dist/commands/sandbox/env/set_all/index.js +1 -1
  93. package/dist/commands/sandbox/get/index.js +1 -1
  94. package/dist/commands/sandbox/license/get/index.js +1 -1
  95. package/dist/commands/sandbox/license/set/index.js +1 -1
  96. package/dist/commands/sandbox/pull/index.d.ts +0 -1
  97. package/dist/commands/sandbox/pull/index.js +13 -81
  98. package/dist/commands/sandbox/push/index.d.ts +1 -1
  99. package/dist/commands/sandbox/push/index.js +11 -6
  100. package/dist/commands/skills/pull/index.d.ts +30 -0
  101. package/dist/commands/skills/pull/index.js +118 -0
  102. package/dist/commands/static_host/build/create/index.d.ts +1 -1
  103. package/dist/commands/static_host/build/create/index.js +2 -2
  104. package/dist/commands/static_host/build/pull/index.js +1 -1
  105. package/dist/commands/static_host/build/push/index.js +1 -1
  106. package/dist/commands/static_host/edit/index.js +1 -1
  107. package/dist/commands/tenant/backup/export/index.js +1 -2
  108. package/dist/commands/tenant/backup/import/index.js +1 -1
  109. package/dist/commands/tenant/cluster/create/index.js +1 -1
  110. package/dist/commands/tenant/cluster/license/get/index.js +1 -1
  111. package/dist/commands/tenant/cluster/license/set/index.js +1 -1
  112. package/dist/commands/tenant/create/index.d.ts +4 -1
  113. package/dist/commands/tenant/create/index.js +26 -5
  114. package/dist/commands/tenant/deploy_platform/index.js +1 -1
  115. package/dist/commands/tenant/deploy_release/index.d.ts +40 -0
  116. package/dist/commands/tenant/deploy_release/index.js +186 -4
  117. package/dist/commands/tenant/edit/index.d.ts +2 -0
  118. package/dist/commands/tenant/edit/index.js +46 -11
  119. package/dist/commands/tenant/env/get_all/index.js +1 -1
  120. package/dist/commands/tenant/env/set_all/index.js +1 -1
  121. package/dist/commands/tenant/impersonate/index.d.ts +1 -1
  122. package/dist/commands/tenant/impersonate/index.js +14 -14
  123. package/dist/commands/tenant/license/get/index.js +1 -1
  124. package/dist/commands/tenant/license/set/index.js +1 -1
  125. package/dist/commands/tenant/pull/index.d.ts +0 -6
  126. package/dist/commands/tenant/pull/index.js +14 -100
  127. package/dist/commands/tenant_deploy_request/bypass/index.d.ts +31 -0
  128. package/dist/commands/tenant_deploy_request/bypass/index.js +109 -0
  129. package/dist/commands/tenant_deploy_request/create/index.d.ts +21 -0
  130. package/dist/commands/tenant_deploy_request/create/index.js +108 -0
  131. package/dist/commands/tenant_deploy_request/edit/index.d.ts +22 -0
  132. package/dist/commands/tenant_deploy_request/edit/index.js +103 -0
  133. package/dist/commands/tenant_deploy_request/get/index.d.ts +25 -0
  134. package/dist/commands/tenant_deploy_request/get/index.js +116 -0
  135. package/dist/commands/tenant_deploy_request/list/index.d.ts +20 -0
  136. package/dist/commands/tenant_deploy_request/list/index.js +122 -0
  137. package/dist/commands/tenant_deploy_request/revision/index.d.ts +21 -0
  138. package/dist/commands/tenant_deploy_request/revision/index.js +83 -0
  139. package/dist/commands/tenant_deploy_request/set_status/index.d.ts +38 -0
  140. package/dist/commands/tenant_deploy_request/set_status/index.js +159 -0
  141. package/dist/commands/workspace/git/pull/index.d.ts +4 -4
  142. package/dist/commands/workspace/git/pull/index.js +158 -97
  143. package/dist/commands/workspace/pull/index.d.ts +9 -5
  144. package/dist/commands/workspace/pull/index.js +83 -106
  145. package/dist/commands/workspace/push/index.d.ts +19 -0
  146. package/dist/commands/workspace/push/index.js +124 -5
  147. package/dist/help.js +4 -2
  148. package/dist/policy-command.d.ts +90 -0
  149. package/dist/policy-command.js +94 -0
  150. package/dist/update-check.d.ts +1 -1
  151. package/dist/update-check.js +1 -1
  152. package/dist/utils/document-parser.d.ts +126 -0
  153. package/dist/utils/document-parser.js +332 -4
  154. package/dist/utils/flatten.d.ts +36 -0
  155. package/dist/utils/flatten.js +68 -0
  156. package/dist/utils/knowledge-sync.d.ts +1 -0
  157. package/dist/utils/knowledge-sync.js +11 -6
  158. package/dist/utils/microservice-wait.d.ts +53 -0
  159. package/dist/utils/microservice-wait.js +84 -0
  160. package/dist/utils/multidoc-push.d.ts +143 -2
  161. package/dist/utils/multidoc-push.js +479 -40
  162. package/dist/utils/paging.d.ts +2 -1
  163. package/dist/utils/paging.js +0 -1
  164. package/dist/utils/policy/catalogue.d.ts +7 -0
  165. package/dist/utils/policy/catalogue.js +72 -0
  166. package/dist/utils/policy/errors.d.ts +12 -0
  167. package/dist/utils/policy/errors.js +61 -0
  168. package/dist/utils/policy/feedback.d.ts +68 -0
  169. package/dist/utils/policy/feedback.js +165 -0
  170. package/dist/utils/policy/findings.d.ts +23 -0
  171. package/dist/utils/policy/findings.js +65 -0
  172. package/dist/utils/policy/gate.d.ts +161 -0
  173. package/dist/utils/policy/gate.js +201 -0
  174. package/dist/utils/policy/goal.d.ts +46 -0
  175. package/dist/utils/policy/goal.js +95 -0
  176. package/dist/utils/policy/permission.d.ts +23 -0
  177. package/dist/utils/policy/permission.js +84 -0
  178. package/dist/utils/policy/push-gate.d.ts +5 -0
  179. package/dist/utils/policy/push-gate.js +29 -0
  180. package/dist/utils/policy/release.d.ts +85 -0
  181. package/dist/utils/policy/release.js +115 -0
  182. package/dist/utils/policy/request.d.ts +55 -0
  183. package/dist/utils/policy/request.js +115 -0
  184. package/dist/utils/policy/runs.d.ts +30 -0
  185. package/dist/utils/policy/runs.js +101 -0
  186. package/dist/utils/policy/status.d.ts +47 -0
  187. package/dist/utils/policy/status.js +117 -0
  188. package/dist/utils/policy/types.d.ts +185 -0
  189. package/dist/utils/policy/types.js +1 -0
  190. package/dist/utils/reference-checker.js +14 -3
  191. package/oclif.manifest.json +8538 -3445
  192. package/package.json +16 -1
@@ -0,0 +1,109 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../base-command.js';
3
+ import { gateOverrideHint, gateRefusal, gateRefusalOutput } from '../../../utils/policy/gate.js';
4
+ export default class TenantDeployRequestBypass extends BaseCommand {
5
+ static args = {
6
+ id: Args.integer({
7
+ description: 'Tenant deploy request ID',
8
+ required: true,
9
+ }),
10
+ };
11
+ static description = "[CRITICAL] STOP and confirm with the user before running this; it deploys the release immediately, past the review workflow. Deploy the request's release past the approval gate under the tenant_center:deploy:bypass_approval permission. Only available if the tenant has enabled bypass (allow_deploy_bypass), and every use is logged with the given reason. The approval request's own status is left untouched. The deploy is still gated on the release's policy check: a refusal exits 2, and --override-policy proceeds past it with the same --reason (needs the workspace:policy update permission).";
12
+ static examples = [
13
+ `$ xano tenant_deploy_request bypass 12 --reason "Prod incident, reviewer unavailable"
14
+ Deployed tenant release, bypassing deploy request #12's approval gate.
15
+ `,
16
+ `$ xano tenant_deploy_request bypass 12 --reason "Prod incident; AUTH-001 finding accepted" --override-policy`,
17
+ ];
18
+ static flags = {
19
+ ...BaseCommand.baseFlags,
20
+ output: Flags.string({
21
+ char: 'o',
22
+ default: 'summary',
23
+ description: 'Output format',
24
+ options: ['summary', 'json'],
25
+ required: false,
26
+ }),
27
+ 'override-policy': Flags.boolean({
28
+ default: false,
29
+ description: 'Also proceed past a blocking policy gate, recording --reason as the override reason (needs the workspace:policy update permission; audited)',
30
+ }),
31
+ reason: Flags.string({
32
+ description: 'Reason for bypassing the approval gate (required, audited)',
33
+ required: true,
34
+ }),
35
+ workspace: Flags.string({
36
+ char: 'w',
37
+ description: 'Workspace ID (uses profile workspace if not provided)',
38
+ required: false,
39
+ }),
40
+ };
41
+ /** Set once the policy gate refuses the bypass deploy, the one failure that exits 2. */
42
+ refusedByPolicyGate = false;
43
+ /** Exit 2 is the policy gate's refusal; every other failure, flag errors included, exits 1. */
44
+ async catch(error) {
45
+ if (this.refusedByPolicyGate)
46
+ return super.catch(error);
47
+ return this.catchAsOperational(error);
48
+ }
49
+ async run() {
50
+ const { args, flags } = await this.parse(TenantDeployRequestBypass);
51
+ const { profile } = this.resolveProfile(flags);
52
+ const workspaceId = flags.workspace || profile.workspace;
53
+ if (!workspaceId) {
54
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
55
+ }
56
+ const body = {
57
+ reason: flags.reason,
58
+ ...(flags['override-policy'] ? { override_policy: true } : {}),
59
+ };
60
+ // A refusal by the policy gate exits 2 with its verdict; the catch that rewords other failures keeps it.
61
+ let refused = null;
62
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}/override`;
63
+ try {
64
+ const response = await this.verboseFetch(apiUrl, {
65
+ body: JSON.stringify(body),
66
+ headers: {
67
+ accept: 'application/json',
68
+ Authorization: `Bearer ${profile.access_token}`,
69
+ 'Content-Type': 'application/json',
70
+ },
71
+ method: 'POST',
72
+ }, flags.verbose, profile.access_token);
73
+ if (!response.ok) {
74
+ refused = await gateRefusal(response);
75
+ if (refused)
76
+ this.refuseByPolicyGate(refused, args.id, flags.output === 'json');
77
+ const message = await this.parseApiError(response, 'Failed to bypass tenant deploy request approval gate');
78
+ this.error(message);
79
+ }
80
+ const deploy = (await response.json());
81
+ if (flags.output === 'json') {
82
+ this.log(JSON.stringify(deploy, null, 2));
83
+ }
84
+ else {
85
+ this.log(`Deployed tenant release, bypassing deploy request #${args.id}'s approval gate.`);
86
+ if (deploy.duration_ms !== undefined)
87
+ this.log(` Time: ${(deploy.duration_ms / 1000).toFixed(1)}s`);
88
+ }
89
+ }
90
+ catch (error) {
91
+ if (refused)
92
+ throw error;
93
+ if (error instanceof Error) {
94
+ this.error(`Failed to bypass tenant deploy request approval gate: ${error.message}`);
95
+ }
96
+ else {
97
+ this.error(`Failed to bypass tenant deploy request approval gate: ${String(error)}`);
98
+ }
99
+ }
100
+ }
101
+ /** The bypass deploy was refused by the policy gate: its verdict, then the refusal, exiting 2. */
102
+ refuseByPolicyGate(refused, id, json) {
103
+ for (const line of gateRefusalOutput(refused, json))
104
+ this.log(line);
105
+ const override = `xano tenant_deploy_request bypass ${id} --reason "<why>" --override-policy`;
106
+ this.refusedByPolicyGate = true;
107
+ this.error(`${refused.message}${gateOverrideHint(refused.answer, override)}`, { exit: 2 });
108
+ }
109
+ }
@@ -0,0 +1,21 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class TenantDeployRequestCreate extends BaseCommand {
3
+ static args: {
4
+ title: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ draft: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ release: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ reviewers: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ tenant: 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,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,116 @@
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, with the policy check of its release on its tenant (what the deploy's policy gate would decide now), for a credential that reads policies";
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
+ Policy check of release "v1.2" on tenant "prod":
18
+ Policy gate: pass
19
+ This release has no blocking policy findings.
20
+ Release: v1.2 (policy run 301, pass)
21
+ Blocking findings in this release: 0
22
+ `,
23
+ `$ xano tenant_deploy_request get 12 -o json`,
24
+ ];
25
+ static flags = {
26
+ ...BaseCommand.baseFlags,
27
+ output: Flags.string({
28
+ char: 'o',
29
+ default: 'summary',
30
+ description: 'Output format',
31
+ options: ['summary', 'json'],
32
+ required: false,
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(TenantDeployRequestGet);
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 apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/approval_request/${args.id}`;
48
+ try {
49
+ const response = await this.verboseFetch(apiUrl, {
50
+ headers: {
51
+ accept: 'application/json',
52
+ Authorization: `Bearer ${profile.access_token}`,
53
+ },
54
+ method: 'GET',
55
+ }, flags.verbose, profile.access_token);
56
+ if (!response.ok) {
57
+ const message = await this.parseApiError(response, 'Failed to get tenant deploy request');
58
+ this.error(message);
59
+ }
60
+ const item = (await response.json());
61
+ const policyCheck = await this.policyCheck(item, { profile, verbose: flags.verbose, workspaceId });
62
+ if (flags.output === 'json') {
63
+ this.log(JSON.stringify({ ...item, policy_gate: policyCheck.answer ?? null,
64
+ ...(policyCheck.unavailable ? { policy_gate_unavailable: policyCheck.unavailable } : {}) }, null, 2));
65
+ }
66
+ else {
67
+ this.log(`Deploy request #${item.id}: "${item.title}" [${item.status}]`);
68
+ this.log(` Tenant: ${item._tenant?.name || (item.deployment?.tenant?.id ? `#${item.deployment.tenant.id}` : 'unavailable')}`);
69
+ this.log(` Release: ${item._release?.name || (item.deployment?.release?.id ? `#${item.deployment.release.id}` : 'unavailable')}`);
70
+ if (item.description)
71
+ this.log(` Description: ${item.description}`);
72
+ if (item.reviewers?.length)
73
+ this.log(` Reviewers: ${item.reviewers.map((r) => r.id).join(', ')}`);
74
+ if (item.can_review !== undefined)
75
+ this.log(` Can review: ${item.can_review}`);
76
+ if (policyCheck.answer) {
77
+ this.log(`Policy check of release "${item._release?.name}" on tenant "${item._tenant?.name}":`);
78
+ for (const line of gateLines(policyCheck.answer))
79
+ this.log(line);
80
+ }
81
+ else if (policyCheck.unavailable) {
82
+ this.log(`Policy checks: not available (${policyCheck.unavailable})`);
83
+ }
84
+ }
85
+ }
86
+ catch (error) {
87
+ if (error instanceof Error) {
88
+ this.error(`Failed to get tenant deploy request: ${error.message}`);
89
+ }
90
+ else {
91
+ this.error(`Failed to get tenant deploy request: ${String(error)}`);
92
+ }
93
+ }
94
+ }
95
+ /**
96
+ * The policy gate's verdict on the request's release for its tenant, as a deploy now would meet it.
97
+ * Only a policy reader gets one; any refusal or failure is a reason it is not available, never an
98
+ * error of this command.
99
+ */
100
+ async policyCheck(item, target) {
101
+ // Terminal requests are historical records: previewing now can check a different base release.
102
+ if (['approved', 'closed'].includes(item.status))
103
+ return {};
104
+ const tenant = item._tenant?.name?.trim();
105
+ const release = item._release?.name?.trim();
106
+ if (!tenant || !release)
107
+ return { unavailable: 'the request does not name its tenant and release' };
108
+ try {
109
+ const result = await fetchPolicyGate({ verboseFetch: (...args) => this.verboseFetch(...args) }, { profile: target.profile, release, tenant, verbose: target.verbose, workspace: String(target.workspaceId) });
110
+ return 'answer' in result ? { answer: result.answer } : { unavailable: unavailableReason(result.unavailable) };
111
+ }
112
+ catch (error) {
113
+ return { unavailable: error instanceof Error ? error.message : String(error) };
114
+ }
115
+ }
116
+ }
@@ -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
+ }