@xano/cli 0.0.94 → 0.0.95-beta.2

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 (76) hide show
  1. package/README.md +19 -0
  2. package/dist/commands/ephemeral/access/index.d.ts +15 -0
  3. package/dist/commands/ephemeral/access/index.js +78 -0
  4. package/dist/commands/ephemeral/create/index.d.ts +17 -0
  5. package/dist/commands/ephemeral/create/index.js +102 -0
  6. package/dist/commands/ephemeral/delete/index.d.ts +16 -0
  7. package/dist/commands/ephemeral/delete/index.js +99 -0
  8. package/dist/commands/ephemeral/env/delete/index.d.ts +17 -0
  9. package/dist/commands/ephemeral/env/delete/index.js +105 -0
  10. package/dist/commands/ephemeral/env/get/index.d.ts +15 -0
  11. package/dist/commands/ephemeral/env/get/index.js +81 -0
  12. package/dist/commands/ephemeral/env/get_all/index.d.ts +16 -0
  13. package/dist/commands/ephemeral/env/get_all/index.js +94 -0
  14. package/dist/commands/ephemeral/env/list/index.d.ts +14 -0
  15. package/dist/commands/ephemeral/env/list/index.js +83 -0
  16. package/dist/commands/ephemeral/env/set/index.d.ts +16 -0
  17. package/dist/commands/ephemeral/env/set/index.js +90 -0
  18. package/dist/commands/ephemeral/env/set_all/index.d.ts +16 -0
  19. package/dist/commands/ephemeral/env/set_all/index.js +102 -0
  20. package/dist/commands/ephemeral/get/index.d.ts +14 -0
  21. package/dist/commands/ephemeral/get/index.js +102 -0
  22. package/dist/commands/ephemeral/impersonate/index.d.ts +16 -0
  23. package/dist/commands/ephemeral/impersonate/index.js +110 -0
  24. package/dist/commands/ephemeral/license/get/index.d.ts +16 -0
  25. package/dist/commands/ephemeral/license/get/index.js +94 -0
  26. package/dist/commands/ephemeral/license/set/index.d.ts +17 -0
  27. package/dist/commands/ephemeral/license/set/index.js +111 -0
  28. package/dist/commands/ephemeral/list/index.d.ts +15 -0
  29. package/dist/commands/ephemeral/list/index.js +109 -0
  30. package/dist/commands/ephemeral/pull/index.d.ts +18 -0
  31. package/dist/commands/ephemeral/pull/index.js +197 -0
  32. package/dist/commands/ephemeral/push/index.d.ts +19 -0
  33. package/dist/commands/ephemeral/push/index.js +158 -0
  34. package/dist/commands/ephemeral/shared/index.d.ts +15 -0
  35. package/dist/commands/ephemeral/shared/index.js +108 -0
  36. package/dist/commands/ephemeral/unit_test/list/index.d.ts +14 -0
  37. package/dist/commands/ephemeral/unit_test/list/index.js +105 -0
  38. package/dist/commands/ephemeral/unit_test/run/index.d.ts +15 -0
  39. package/dist/commands/ephemeral/unit_test/run/index.js +93 -0
  40. package/dist/commands/ephemeral/unit_test/run_all/index.d.ts +14 -0
  41. package/dist/commands/ephemeral/unit_test/run_all/index.js +183 -0
  42. package/dist/commands/ephemeral/workflow_test/delete/index.d.ts +18 -0
  43. package/dist/commands/ephemeral/workflow_test/delete/index.js +75 -0
  44. package/dist/commands/ephemeral/workflow_test/get/index.d.ts +18 -0
  45. package/dist/commands/ephemeral/workflow_test/get/index.js +77 -0
  46. package/dist/commands/ephemeral/workflow_test/list/index.d.ts +13 -0
  47. package/dist/commands/ephemeral/workflow_test/list/index.js +98 -0
  48. package/dist/commands/ephemeral/workflow_test/run/index.d.ts +18 -0
  49. package/dist/commands/ephemeral/workflow_test/run/index.js +91 -0
  50. package/dist/commands/ephemeral/workflow_test/run_all/index.d.ts +13 -0
  51. package/dist/commands/ephemeral/workflow_test/run_all/index.js +169 -0
  52. package/dist/commands/release/deploy/index.d.ts +17 -0
  53. package/dist/commands/release/deploy/index.js +107 -0
  54. package/dist/commands/tenant/create/index.d.ts +0 -1
  55. package/dist/commands/tenant/create/index.js +0 -5
  56. package/dist/commands/tenant/push/index.js +1 -1
  57. package/dist/commands/tenant/unit_test/list/index.d.ts +15 -0
  58. package/dist/commands/tenant/unit_test/list/index.js +140 -0
  59. package/dist/commands/tenant/unit_test/run/index.d.ts +16 -0
  60. package/dist/commands/tenant/unit_test/run/index.js +128 -0
  61. package/dist/commands/tenant/unit_test/run_all/index.d.ts +15 -0
  62. package/dist/commands/tenant/unit_test/run_all/index.js +215 -0
  63. package/dist/commands/tenant/workflow_test/delete/index.d.ts +19 -0
  64. package/dist/commands/tenant/workflow_test/delete/index.js +110 -0
  65. package/dist/commands/tenant/workflow_test/get/index.d.ts +19 -0
  66. package/dist/commands/tenant/workflow_test/get/index.js +112 -0
  67. package/dist/commands/tenant/workflow_test/list/index.d.ts +14 -0
  68. package/dist/commands/tenant/workflow_test/list/index.js +133 -0
  69. package/dist/commands/tenant/workflow_test/run/index.d.ts +19 -0
  70. package/dist/commands/tenant/workflow_test/run/index.js +126 -0
  71. package/dist/commands/tenant/workflow_test/run_all/index.d.ts +14 -0
  72. package/dist/commands/tenant/workflow_test/run_all/index.js +201 -0
  73. package/dist/help.d.ts +2 -1
  74. package/dist/help.js +39 -1
  75. package/oclif.manifest.json +5193 -2303
  76. package/package.json +16 -1
@@ -0,0 +1,215 @@
1
+ import { Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../../base-command.js';
3
+ export default class TenantUnitTestRunAll extends BaseCommand {
4
+ static description = 'Run all unit tests for a tenant';
5
+ static examples = [
6
+ `$ xano tenant unit-test run-all -t my-tenant
7
+ Running 5 unit tests...
8
+
9
+ PASS my-test [function: math]
10
+ FAIL data-validation [function: validate]
11
+ Error: assertion failed
12
+
13
+ Results: 4 passed, 1 failed
14
+ `,
15
+ `$ xano tenant unit-test run-all -t my-tenant -o json`,
16
+ ];
17
+ static flags = {
18
+ ...BaseCommand.baseFlags,
19
+ branch: Flags.string({
20
+ char: 'b',
21
+ description: 'Filter by branch name',
22
+ required: false,
23
+ }),
24
+ 'obj-type': Flags.string({
25
+ description: 'Filter by object type',
26
+ options: ['function', 'query', 'middleware'],
27
+ required: false,
28
+ }),
29
+ output: Flags.string({
30
+ char: 'o',
31
+ default: 'summary',
32
+ description: 'Output format',
33
+ options: ['summary', 'json'],
34
+ required: false,
35
+ }),
36
+ tenant: Flags.string({
37
+ char: 't',
38
+ description: 'Tenant name',
39
+ required: true,
40
+ }),
41
+ workspace: Flags.string({
42
+ char: 'w',
43
+ description: 'Workspace ID (uses profile workspace if not provided)',
44
+ required: false,
45
+ }),
46
+ };
47
+ async run() {
48
+ const { flags } = await this.parse(TenantUnitTestRunAll);
49
+ const profileName = flags.profile || this.getDefaultProfile();
50
+ const credentials = this.loadCredentialsFile();
51
+ if (!credentials || !(profileName in credentials.profiles)) {
52
+ this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
53
+ }
54
+ const profile = credentials.profiles[profileName];
55
+ if (!profile.instance_origin) {
56
+ this.error(`Profile '${profileName}' is missing instance_origin`);
57
+ }
58
+ if (!profile.access_token) {
59
+ this.error(`Profile '${profileName}' is missing access_token`);
60
+ }
61
+ const workspaceId = flags.workspace || profile.workspace;
62
+ if (!workspaceId) {
63
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
64
+ }
65
+ // Resolve tenant to get its workspace
66
+ const tenantUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(flags.tenant)}`;
67
+ let tenantWorkspaceId;
68
+ try {
69
+ const tenantResponse = await this.verboseFetch(tenantUrl, {
70
+ headers: {
71
+ accept: 'application/json',
72
+ Authorization: `Bearer ${profile.access_token}`,
73
+ },
74
+ method: 'GET',
75
+ }, flags.verbose, profile.access_token);
76
+ if (!tenantResponse.ok) {
77
+ const errorText = await tenantResponse.text();
78
+ this.error(`Failed to find tenant '${flags.tenant}': ${tenantResponse.status}\n${errorText}`);
79
+ }
80
+ const tenant = (await tenantResponse.json());
81
+ tenantWorkspaceId = String(tenant.workspace?.id || workspaceId);
82
+ }
83
+ catch (error) {
84
+ if (error instanceof Error) {
85
+ this.error(`Failed to resolve tenant: ${error.message}`);
86
+ }
87
+ else {
88
+ this.error(`Failed to resolve tenant: ${String(error)}`);
89
+ }
90
+ }
91
+ const baseUrl = `${profile.instance_origin}/api:meta/workspace/${tenantWorkspaceId}/unit_test`;
92
+ try {
93
+ const listParams = new URLSearchParams();
94
+ listParams.set('per_page', '10000');
95
+ if (flags.branch)
96
+ listParams.set('branch', flags.branch);
97
+ if (flags['obj-type'])
98
+ listParams.set('obj_type', flags['obj-type']);
99
+ const listResponse = await this.verboseFetch(`${baseUrl}?${listParams}`, {
100
+ headers: {
101
+ accept: 'application/json',
102
+ Authorization: `Bearer ${profile.access_token}`,
103
+ },
104
+ method: 'GET',
105
+ }, flags.verbose, profile.access_token);
106
+ if (!listResponse.ok) {
107
+ const errorText = await listResponse.text();
108
+ this.error(`Failed to list unit tests: ${listResponse.status}: ${listResponse.statusText}\n${errorText}`);
109
+ }
110
+ const data = (await listResponse.json());
111
+ let tests;
112
+ if (Array.isArray(data)) {
113
+ tests = data;
114
+ }
115
+ else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
116
+ tests = data.items;
117
+ }
118
+ else {
119
+ this.error('Unexpected API response format');
120
+ }
121
+ if (tests.length === 0) {
122
+ this.log('No unit tests found');
123
+ return;
124
+ }
125
+ if (flags.output === 'summary') {
126
+ this.log(`Running ${tests.length} unit test${tests.length === 1 ? '' : 's'}...\n`);
127
+ }
128
+ const results = [];
129
+ for (const test of tests) {
130
+ const runUrl = `${baseUrl}/${test.id}/run`;
131
+ try {
132
+ const runResponse = await this.verboseFetch(runUrl, {
133
+ headers: {
134
+ accept: 'application/json',
135
+ Authorization: `Bearer ${profile.access_token}`,
136
+ 'Content-Type': 'application/json',
137
+ },
138
+ method: 'POST',
139
+ }, flags.verbose, profile.access_token);
140
+ if (!runResponse.ok) {
141
+ const errorText = await runResponse.text();
142
+ results.push({
143
+ message: `API error ${runResponse.status}: ${errorText}`,
144
+ name: test.name,
145
+ obj_name: test.obj_name,
146
+ obj_type: test.obj_type,
147
+ status: 'fail',
148
+ });
149
+ if (flags.output === 'summary') {
150
+ this.log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
151
+ this.log(` Error: API error ${runResponse.status}`);
152
+ }
153
+ continue;
154
+ }
155
+ const runResult = (await runResponse.json());
156
+ const passed = runResult.status === 'ok';
157
+ const failedExpects = runResult.results?.filter((r) => r.status === 'fail') ?? [];
158
+ results.push({
159
+ message: failedExpects[0]?.message,
160
+ name: test.name,
161
+ obj_name: test.obj_name,
162
+ obj_type: test.obj_type,
163
+ status: passed ? 'pass' : 'fail',
164
+ });
165
+ if (flags.output === 'summary') {
166
+ if (passed) {
167
+ this.log(`PASS ${test.name} [${test.obj_type}: ${test.obj_name}]`);
168
+ }
169
+ else {
170
+ this.log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
171
+ for (const expect of failedExpects) {
172
+ if (expect.message) {
173
+ this.log(` Error: ${expect.message}`);
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+ catch (error) {
180
+ const message = error instanceof Error ? error.message : String(error);
181
+ results.push({
182
+ message,
183
+ name: test.name,
184
+ obj_name: test.obj_name,
185
+ obj_type: test.obj_type,
186
+ status: 'fail',
187
+ });
188
+ if (flags.output === 'summary') {
189
+ this.log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
190
+ this.log(` Error: ${message}`);
191
+ }
192
+ }
193
+ }
194
+ const passed = results.filter((r) => r.status === 'pass').length;
195
+ const failed = results.filter((r) => r.status === 'fail').length;
196
+ if (flags.output === 'json') {
197
+ this.log(JSON.stringify({ failed, passed, results }, null, 2));
198
+ }
199
+ else {
200
+ this.log(`\nResults: ${passed} passed, ${failed} failed`);
201
+ }
202
+ if (failed > 0) {
203
+ process.exitCode = 1;
204
+ }
205
+ }
206
+ catch (error) {
207
+ if (error instanceof Error) {
208
+ this.error(`Failed to run unit tests: ${error.message}`);
209
+ }
210
+ else {
211
+ this.error(`Failed to run unit tests: ${String(error)}`);
212
+ }
213
+ }
214
+ }
215
+ }
@@ -0,0 +1,19 @@
1
+ import BaseCommand from '../../../../base-command.js';
2
+ export default class TenantWorkflowTestDelete extends BaseCommand {
3
+ static args: {
4
+ workflow_test_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
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ workspace: 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,110 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../../base-command.js';
3
+ export default class TenantWorkflowTestDelete extends BaseCommand {
4
+ static args = {
5
+ workflow_test_id: Args.integer({
6
+ description: 'ID of the workflow test to delete',
7
+ required: true,
8
+ }),
9
+ };
10
+ static description = 'Delete a workflow test for a tenant';
11
+ static examples = [
12
+ `$ xano tenant workflow-test delete 42 -t my-tenant
13
+ Deleted workflow test 42
14
+ `,
15
+ `$ xano tenant workflow-test delete 42 -t my-tenant -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
+ tenant: Flags.string({
27
+ char: 't',
28
+ description: 'Tenant name',
29
+ required: true,
30
+ }),
31
+ workspace: Flags.string({
32
+ char: 'w',
33
+ description: 'Workspace ID (uses profile workspace if not provided)',
34
+ required: false,
35
+ }),
36
+ };
37
+ async run() {
38
+ const { args, flags } = await this.parse(TenantWorkflowTestDelete);
39
+ const profileName = flags.profile || this.getDefaultProfile();
40
+ const credentials = this.loadCredentialsFile();
41
+ if (!credentials || !(profileName in credentials.profiles)) {
42
+ this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
43
+ }
44
+ const profile = credentials.profiles[profileName];
45
+ if (!profile.instance_origin) {
46
+ this.error(`Profile '${profileName}' is missing instance_origin`);
47
+ }
48
+ if (!profile.access_token) {
49
+ this.error(`Profile '${profileName}' is missing access_token`);
50
+ }
51
+ const workspaceId = flags.workspace || profile.workspace;
52
+ if (!workspaceId) {
53
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
54
+ }
55
+ // Resolve tenant to get its workspace
56
+ const tenantUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(flags.tenant)}`;
57
+ let tenantWorkspaceId;
58
+ try {
59
+ const tenantResponse = await this.verboseFetch(tenantUrl, {
60
+ headers: {
61
+ accept: 'application/json',
62
+ Authorization: `Bearer ${profile.access_token}`,
63
+ },
64
+ method: 'GET',
65
+ }, flags.verbose, profile.access_token);
66
+ if (!tenantResponse.ok) {
67
+ const errorText = await tenantResponse.text();
68
+ this.error(`Failed to find tenant '${flags.tenant}': ${tenantResponse.status}\n${errorText}`);
69
+ }
70
+ const tenant = (await tenantResponse.json());
71
+ tenantWorkspaceId = String(tenant.workspace?.id || workspaceId);
72
+ }
73
+ catch (error) {
74
+ if (error instanceof Error) {
75
+ this.error(`Failed to resolve tenant: ${error.message}`);
76
+ }
77
+ else {
78
+ this.error(`Failed to resolve tenant: ${String(error)}`);
79
+ }
80
+ }
81
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${tenantWorkspaceId}/workflow_test/${args.workflow_test_id}`;
82
+ try {
83
+ const response = await this.verboseFetch(apiUrl, {
84
+ headers: {
85
+ accept: 'application/json',
86
+ Authorization: `Bearer ${profile.access_token}`,
87
+ },
88
+ method: 'DELETE',
89
+ }, flags.verbose, profile.access_token);
90
+ if (!response.ok) {
91
+ const errorText = await response.text();
92
+ this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
93
+ }
94
+ if (flags.output === 'json') {
95
+ this.log(JSON.stringify({ deleted: true, workflow_test_id: args.workflow_test_id }, null, 2));
96
+ }
97
+ else {
98
+ this.log(`Deleted workflow test ${args.workflow_test_id}`);
99
+ }
100
+ }
101
+ catch (error) {
102
+ if (error instanceof Error) {
103
+ this.error(`Failed to delete workflow test: ${error.message}`);
104
+ }
105
+ else {
106
+ this.error(`Failed to delete workflow test: ${String(error)}`);
107
+ }
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,19 @@
1
+ import BaseCommand from '../../../../base-command.js';
2
+ export default class TenantWorkflowTestGet extends BaseCommand {
3
+ static args: {
4
+ workflow_test_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
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ workspace: 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,112 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../../base-command.js';
3
+ export default class TenantWorkflowTestGet extends BaseCommand {
4
+ static args = {
5
+ workflow_test_id: Args.integer({
6
+ description: 'ID of the workflow test',
7
+ required: true,
8
+ }),
9
+ };
10
+ static description = 'Get a workflow test for a tenant';
11
+ static examples = [
12
+ `$ xano tenant workflow-test get 42 -t my-tenant`,
13
+ `$ xano tenant workflow-test get 42 -t my-tenant -o json`,
14
+ ];
15
+ static flags = {
16
+ ...BaseCommand.baseFlags,
17
+ output: Flags.string({
18
+ char: 'o',
19
+ default: 'summary',
20
+ description: 'Output format',
21
+ options: ['summary', 'json'],
22
+ required: false,
23
+ }),
24
+ tenant: Flags.string({
25
+ char: 't',
26
+ description: 'Tenant name',
27
+ required: true,
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(TenantWorkflowTestGet);
37
+ const profileName = flags.profile || this.getDefaultProfile();
38
+ const credentials = this.loadCredentialsFile();
39
+ if (!credentials || !(profileName in credentials.profiles)) {
40
+ this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
41
+ }
42
+ const profile = credentials.profiles[profileName];
43
+ if (!profile.instance_origin) {
44
+ this.error(`Profile '${profileName}' is missing instance_origin`);
45
+ }
46
+ if (!profile.access_token) {
47
+ this.error(`Profile '${profileName}' is missing access_token`);
48
+ }
49
+ const workspaceId = flags.workspace || profile.workspace;
50
+ if (!workspaceId) {
51
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
52
+ }
53
+ // Resolve tenant to get its workspace
54
+ const tenantUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(flags.tenant)}`;
55
+ let tenantWorkspaceId;
56
+ try {
57
+ const tenantResponse = await this.verboseFetch(tenantUrl, {
58
+ headers: {
59
+ accept: 'application/json',
60
+ Authorization: `Bearer ${profile.access_token}`,
61
+ },
62
+ method: 'GET',
63
+ }, flags.verbose, profile.access_token);
64
+ if (!tenantResponse.ok) {
65
+ const errorText = await tenantResponse.text();
66
+ this.error(`Failed to find tenant '${flags.tenant}': ${tenantResponse.status}\n${errorText}`);
67
+ }
68
+ const tenant = (await tenantResponse.json());
69
+ tenantWorkspaceId = String(tenant.workspace?.id || workspaceId);
70
+ }
71
+ catch (error) {
72
+ if (error instanceof Error) {
73
+ this.error(`Failed to resolve tenant: ${error.message}`);
74
+ }
75
+ else {
76
+ this.error(`Failed to resolve tenant: ${String(error)}`);
77
+ }
78
+ }
79
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${tenantWorkspaceId}/workflow_test/${args.workflow_test_id}`;
80
+ try {
81
+ const response = await this.verboseFetch(apiUrl, {
82
+ headers: {
83
+ accept: 'application/json',
84
+ Authorization: `Bearer ${profile.access_token}`,
85
+ },
86
+ method: 'GET',
87
+ }, flags.verbose, profile.access_token);
88
+ if (!response.ok) {
89
+ const errorText = await response.text();
90
+ this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
91
+ }
92
+ const test = await response.json();
93
+ if (flags.output === 'json') {
94
+ this.log(JSON.stringify(test, null, 2));
95
+ }
96
+ else {
97
+ const t = test;
98
+ this.log(`Workflow Test: ${t.name} (ID: ${t.id})`);
99
+ if (t.description)
100
+ this.log(` Description: ${t.description}`);
101
+ }
102
+ }
103
+ catch (error) {
104
+ if (error instanceof Error) {
105
+ this.error(`Failed to get workflow test: ${error.message}`);
106
+ }
107
+ else {
108
+ this.error(`Failed to get workflow test: ${String(error)}`);
109
+ }
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,14 @@
1
+ import BaseCommand from '../../../../base-command.js';
2
+ export default class TenantWorkflowTestList extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,133 @@
1
+ import { Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../../base-command.js';
3
+ export default class TenantWorkflowTestList extends BaseCommand {
4
+ static description = 'List workflow tests for a tenant';
5
+ static examples = [
6
+ `$ xano tenant workflow-test list -t my-tenant
7
+ Workflow tests for tenant my-tenant:
8
+ - my-test (ID: 1)
9
+ `,
10
+ `$ xano tenant workflow-test list -t my-tenant -w 5 -o json`,
11
+ ];
12
+ static flags = {
13
+ ...BaseCommand.baseFlags,
14
+ branch: Flags.string({
15
+ char: 'b',
16
+ description: 'Filter by branch name',
17
+ required: false,
18
+ }),
19
+ output: Flags.string({
20
+ char: 'o',
21
+ default: 'summary',
22
+ description: 'Output format',
23
+ options: ['summary', 'json'],
24
+ required: false,
25
+ }),
26
+ tenant: Flags.string({
27
+ char: 't',
28
+ description: 'Tenant name',
29
+ required: true,
30
+ }),
31
+ workspace: Flags.string({
32
+ char: 'w',
33
+ description: 'Workspace ID (uses profile workspace if not provided)',
34
+ required: false,
35
+ }),
36
+ };
37
+ async run() {
38
+ const { flags } = await this.parse(TenantWorkflowTestList);
39
+ const profileName = flags.profile || this.getDefaultProfile();
40
+ const credentials = this.loadCredentialsFile();
41
+ if (!credentials || !(profileName in credentials.profiles)) {
42
+ this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
43
+ }
44
+ const profile = credentials.profiles[profileName];
45
+ if (!profile.instance_origin) {
46
+ this.error(`Profile '${profileName}' is missing instance_origin`);
47
+ }
48
+ if (!profile.access_token) {
49
+ this.error(`Profile '${profileName}' is missing access_token`);
50
+ }
51
+ const workspaceId = flags.workspace || profile.workspace;
52
+ if (!workspaceId) {
53
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
54
+ }
55
+ // Resolve tenant to get its workspace
56
+ const tenantUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(flags.tenant)}`;
57
+ let tenantWorkspaceId;
58
+ try {
59
+ const tenantResponse = await this.verboseFetch(tenantUrl, {
60
+ headers: {
61
+ accept: 'application/json',
62
+ Authorization: `Bearer ${profile.access_token}`,
63
+ },
64
+ method: 'GET',
65
+ }, flags.verbose, profile.access_token);
66
+ if (!tenantResponse.ok) {
67
+ const errorText = await tenantResponse.text();
68
+ this.error(`Failed to find tenant '${flags.tenant}': ${tenantResponse.status}\n${errorText}`);
69
+ }
70
+ const tenant = (await tenantResponse.json());
71
+ tenantWorkspaceId = String(tenant.workspace?.id || workspaceId);
72
+ }
73
+ catch (error) {
74
+ if (error instanceof Error) {
75
+ this.error(`Failed to resolve tenant: ${error.message}`);
76
+ }
77
+ else {
78
+ this.error(`Failed to resolve tenant: ${String(error)}`);
79
+ }
80
+ }
81
+ const params = new URLSearchParams();
82
+ params.set('per_page', '10000');
83
+ if (flags.branch)
84
+ params.set('branch', flags.branch);
85
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${tenantWorkspaceId}/workflow_test?${params}`;
86
+ try {
87
+ const response = await this.verboseFetch(apiUrl, {
88
+ headers: {
89
+ accept: 'application/json',
90
+ Authorization: `Bearer ${profile.access_token}`,
91
+ },
92
+ method: 'GET',
93
+ }, flags.verbose, profile.access_token);
94
+ if (!response.ok) {
95
+ const errorText = await response.text();
96
+ this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
97
+ }
98
+ const data = (await response.json());
99
+ let tests;
100
+ if (Array.isArray(data)) {
101
+ tests = data;
102
+ }
103
+ else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
104
+ tests = data.items;
105
+ }
106
+ else {
107
+ this.error('Unexpected API response format');
108
+ }
109
+ if (flags.output === 'json') {
110
+ this.log(JSON.stringify(tests, null, 2));
111
+ }
112
+ else {
113
+ if (tests.length === 0) {
114
+ this.log('No workflow tests found');
115
+ }
116
+ else {
117
+ this.log(`Workflow tests for tenant ${flags.tenant}:`);
118
+ for (const test of tests) {
119
+ this.log(` - ${test.name} (ID: ${test.id})`);
120
+ }
121
+ }
122
+ }
123
+ }
124
+ catch (error) {
125
+ if (error instanceof Error) {
126
+ this.error(`Failed to list workflow tests: ${error.message}`);
127
+ }
128
+ else {
129
+ this.error(`Failed to list workflow tests: ${String(error)}`);
130
+ }
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,19 @@
1
+ import BaseCommand from '../../../../base-command.js';
2
+ export default class TenantWorkflowTestRun extends BaseCommand {
3
+ static args: {
4
+ workflow_test_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
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ workspace: 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
+ }