@xano/cli 1.2.0 → 1.3.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 (116) hide show
  1. package/README.md +112 -3
  2. package/dist/base-command.d.ts +43 -36
  3. package/dist/base-command.js +223 -160
  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/ephemeral/create/index.d.ts +18 -0
  9. package/dist/commands/ephemeral/create/index.js +103 -0
  10. package/dist/commands/ephemeral/delete/index.d.ts +18 -0
  11. package/dist/commands/ephemeral/delete/index.js +99 -0
  12. package/dist/commands/ephemeral/edit/index.d.ts +18 -0
  13. package/dist/commands/ephemeral/edit/index.js +109 -0
  14. package/dist/commands/ephemeral/get/index.d.ts +21 -0
  15. package/dist/commands/ephemeral/get/index.js +125 -0
  16. package/dist/commands/ephemeral/impersonate/index.d.ts +20 -0
  17. package/dist/commands/ephemeral/impersonate/index.js +120 -0
  18. package/dist/commands/ephemeral/list/index.d.ts +19 -0
  19. package/dist/commands/ephemeral/list/index.js +123 -0
  20. package/dist/commands/ephemeral/pull/index.d.ts +19 -0
  21. package/dist/commands/ephemeral/pull/index.js +163 -0
  22. package/dist/commands/ephemeral/push/index.d.ts +35 -0
  23. package/dist/commands/ephemeral/push/index.js +223 -0
  24. package/dist/commands/ephemeral/static_host/build/delete/index.d.ts +20 -0
  25. package/dist/commands/ephemeral/static_host/build/delete/index.js +121 -0
  26. package/dist/commands/ephemeral/static_host/build/get/index.d.ts +18 -0
  27. package/dist/commands/ephemeral/static_host/build/get/index.js +137 -0
  28. package/dist/commands/ephemeral/static_host/build/list/index.d.ts +18 -0
  29. package/dist/commands/ephemeral/static_host/build/list/index.js +137 -0
  30. package/dist/commands/ephemeral/static_host/build/pull/index.d.ts +53 -0
  31. package/dist/commands/ephemeral/static_host/build/pull/index.js +308 -0
  32. package/dist/commands/ephemeral/static_host/build/push/index.d.ts +24 -0
  33. package/dist/commands/ephemeral/static_host/build/push/index.js +250 -0
  34. package/dist/commands/ephemeral/static_host/create/index.d.ts +18 -0
  35. package/dist/commands/ephemeral/static_host/create/index.js +92 -0
  36. package/dist/commands/ephemeral/static_host/deploy/index.d.ts +19 -0
  37. package/dist/commands/ephemeral/static_host/deploy/index.js +112 -0
  38. package/dist/commands/ephemeral/static_host/edit/index.d.ts +24 -0
  39. package/dist/commands/ephemeral/static_host/edit/index.js +158 -0
  40. package/dist/commands/ephemeral/static_host/get/index.d.ts +19 -0
  41. package/dist/commands/ephemeral/static_host/get/index.js +101 -0
  42. package/dist/commands/ephemeral/static_host/list/index.d.ts +17 -0
  43. package/dist/commands/ephemeral/static_host/list/index.js +132 -0
  44. package/dist/commands/flatten/index.d.ts +34 -0
  45. package/dist/commands/flatten/index.js +140 -0
  46. package/dist/commands/function/create/index.js +1 -1
  47. package/dist/commands/function/edit/index.js +26 -32
  48. package/dist/commands/function/get/index.js +2 -3
  49. package/dist/commands/function/run/index.d.ts +1 -0
  50. package/dist/commands/function/run/index.js +19 -6
  51. package/dist/commands/profile/create/index.d.ts +1 -1
  52. package/dist/commands/profile/create/index.js +7 -7
  53. package/dist/commands/profile/me/index.js +1 -1
  54. package/dist/commands/profile/use/index.js +0 -4
  55. package/dist/commands/profile/wizard/index.d.ts +1 -1
  56. package/dist/commands/profile/wizard/index.js +12 -10
  57. package/dist/commands/profile/workspace/set/index.js +1 -1
  58. package/dist/commands/release/edit/index.js +2 -2
  59. package/dist/commands/release/export/index.js +1 -2
  60. package/dist/commands/release/import/index.js +1 -1
  61. package/dist/commands/release/pull/index.d.ts +0 -6
  62. package/dist/commands/release/pull/index.js +13 -99
  63. package/dist/commands/release/push/index.js +2 -2
  64. package/dist/commands/sandbox/env/get_all/index.js +1 -1
  65. package/dist/commands/sandbox/env/set_all/index.js +1 -1
  66. package/dist/commands/sandbox/get/index.js +1 -1
  67. package/dist/commands/sandbox/license/get/index.js +1 -1
  68. package/dist/commands/sandbox/license/set/index.js +1 -1
  69. package/dist/commands/sandbox/pull/index.d.ts +0 -1
  70. package/dist/commands/sandbox/pull/index.js +13 -81
  71. package/dist/commands/sandbox/push/index.d.ts +1 -1
  72. package/dist/commands/sandbox/push/index.js +5 -5
  73. package/dist/commands/static_host/build/create/index.d.ts +1 -1
  74. package/dist/commands/static_host/build/create/index.js +2 -2
  75. package/dist/commands/static_host/build/pull/index.js +1 -1
  76. package/dist/commands/static_host/build/push/index.js +1 -1
  77. package/dist/commands/static_host/edit/index.js +1 -1
  78. package/dist/commands/tenant/backup/export/index.js +1 -2
  79. package/dist/commands/tenant/backup/import/index.js +1 -1
  80. package/dist/commands/tenant/cluster/create/index.js +1 -1
  81. package/dist/commands/tenant/cluster/license/get/index.js +1 -1
  82. package/dist/commands/tenant/cluster/license/set/index.js +1 -1
  83. package/dist/commands/tenant/create/index.d.ts +1 -1
  84. package/dist/commands/tenant/create/index.js +6 -6
  85. package/dist/commands/tenant/deploy_platform/index.js +1 -1
  86. package/dist/commands/tenant/edit/index.js +7 -7
  87. package/dist/commands/tenant/env/get_all/index.js +1 -1
  88. package/dist/commands/tenant/env/set_all/index.js +1 -1
  89. package/dist/commands/tenant/impersonate/index.d.ts +1 -1
  90. package/dist/commands/tenant/impersonate/index.js +14 -14
  91. package/dist/commands/tenant/license/get/index.js +1 -1
  92. package/dist/commands/tenant/license/set/index.js +1 -1
  93. package/dist/commands/tenant/pull/index.d.ts +0 -6
  94. package/dist/commands/tenant/pull/index.js +14 -100
  95. package/dist/commands/workspace/git/pull/index.d.ts +4 -4
  96. package/dist/commands/workspace/git/pull/index.js +158 -97
  97. package/dist/commands/workspace/pull/index.d.ts +1 -7
  98. package/dist/commands/workspace/pull/index.js +17 -103
  99. package/dist/help.js +4 -2
  100. package/dist/update-check.d.ts +1 -1
  101. package/dist/update-check.js +1 -1
  102. package/dist/utils/document-parser.d.ts +116 -0
  103. package/dist/utils/document-parser.js +311 -4
  104. package/dist/utils/flatten.d.ts +36 -0
  105. package/dist/utils/flatten.js +68 -0
  106. package/dist/utils/knowledge-sync.d.ts +1 -0
  107. package/dist/utils/knowledge-sync.js +11 -6
  108. package/dist/utils/microservice-wait.d.ts +53 -0
  109. package/dist/utils/microservice-wait.js +84 -0
  110. package/dist/utils/multidoc-push.d.ts +88 -0
  111. package/dist/utils/multidoc-push.js +378 -15
  112. package/dist/utils/paging.d.ts +2 -1
  113. package/dist/utils/paging.js +0 -1
  114. package/dist/utils/reference-checker.js +14 -3
  115. package/oclif.manifest.json +5264 -3170
  116. package/package.json +10 -1
@@ -0,0 +1,18 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class EphemeralDelete extends BaseCommand {
3
+ static args: {
4
+ tenant_name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ run(): Promise<void>;
17
+ private confirm;
18
+ }
@@ -0,0 +1,99 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../base-command.js';
3
+ export default class EphemeralDelete extends BaseCommand {
4
+ static args = {
5
+ tenant_name: Args.string({
6
+ description: 'Ephemeral tenant name to delete',
7
+ required: true,
8
+ }),
9
+ };
10
+ static description = 'Delete an ephemeral tenant permanently. This destroys all associated infrastructure and cannot be undone.';
11
+ static examples = [
12
+ `$ xano ephemeral delete e4f2-9ab1-xyz1
13
+ Are you sure you want to delete tenant e4f2-9ab1-xyz1? This action cannot be undone. (y/N) y
14
+ Deleted tenant e4f2-9ab1-xyz1
15
+ `,
16
+ `$ xano ephemeral delete e4f2-9ab1-xyz1 --force
17
+ Deleted tenant e4f2-9ab1-xyz1
18
+ `,
19
+ `$ xano ephemeral delete e4f2-9ab1-xyz1 -f -o json`,
20
+ ];
21
+ static flags = {
22
+ ...BaseCommand.baseFlags,
23
+ force: Flags.boolean({
24
+ char: 'f',
25
+ default: false,
26
+ description: '[CRITICAL] NEVER run without explicit user confirmation. Skips the confirmation prompt.',
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
+ workspace: Flags.string({
37
+ char: 'w',
38
+ description: 'Workspace ID (uses profile workspace if not provided)',
39
+ required: false,
40
+ }),
41
+ };
42
+ async run() {
43
+ const { args, flags } = await this.parse(EphemeralDelete);
44
+ const { profile } = this.resolveProfile(flags);
45
+ const workspaceId = flags.workspace || profile.workspace;
46
+ if (!workspaceId) {
47
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
48
+ }
49
+ const tenantName = args.tenant_name;
50
+ if (!flags.force) {
51
+ const confirmed = await this.confirm(`Are you sure you want to delete tenant ${tenantName}? This action cannot be undone.`);
52
+ if (!confirmed) {
53
+ this.log('Deletion cancelled.');
54
+ return;
55
+ }
56
+ }
57
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}`;
58
+ try {
59
+ const response = await this.verboseFetch(apiUrl, {
60
+ headers: {
61
+ 'accept': 'application/json',
62
+ 'Authorization': `Bearer ${profile.access_token}`,
63
+ },
64
+ method: 'DELETE',
65
+ }, flags.verbose, profile.access_token);
66
+ if (!response.ok) {
67
+ const errorText = await response.text();
68
+ this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
69
+ }
70
+ if (flags.output === 'json') {
71
+ this.log(JSON.stringify({ deleted: true, tenant_name: tenantName }, null, 2));
72
+ }
73
+ else {
74
+ this.log(`Deleted tenant ${tenantName}`);
75
+ }
76
+ }
77
+ catch (error) {
78
+ if (error instanceof Error) {
79
+ this.error(`Failed to delete ephemeral tenant: ${error.message}`);
80
+ }
81
+ else {
82
+ this.error(`Failed to delete ephemeral tenant: ${String(error)}`);
83
+ }
84
+ }
85
+ }
86
+ async confirm(message) {
87
+ const readline = await import('node:readline');
88
+ const rl = readline.createInterface({
89
+ input: process.stdin,
90
+ output: process.stdout,
91
+ });
92
+ return new Promise((resolve) => {
93
+ rl.question(`${message} (y/N) `, (answer) => {
94
+ rl.close();
95
+ resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
96
+ });
97
+ });
98
+ }
99
+ }
@@ -0,0 +1,18 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class EphemeralEdit extends BaseCommand {
3
+ static args: {
4
+ tenant_name: 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
+ display: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,109 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../base-command.js';
3
+ export default class EphemeralEdit extends BaseCommand {
4
+ static args = {
5
+ tenant_name: Args.string({
6
+ description: 'Ephemeral tenant name to edit',
7
+ required: true,
8
+ }),
9
+ };
10
+ static description = 'Edit an existing ephemeral tenant';
11
+ static examples = [
12
+ `$ xano ephemeral edit e4f2-9ab1-xyz1 --display "New Name" --description "Updated description"
13
+ Updated tenant: New Name (e4f2-9ab1-xyz1) - ID: 42
14
+ `,
15
+ `$ xano ephemeral edit e4f2-9ab1-xyz1 -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
+ display: Flags.string({
25
+ description: 'New display name',
26
+ required: false,
27
+ }),
28
+ output: Flags.string({
29
+ char: 'o',
30
+ default: 'summary',
31
+ description: 'Output format',
32
+ options: ['summary', 'json'],
33
+ required: false,
34
+ }),
35
+ workspace: Flags.string({
36
+ char: 'w',
37
+ description: 'Workspace ID (uses profile workspace if not provided)',
38
+ required: false,
39
+ }),
40
+ };
41
+ async run() {
42
+ const { args, flags } = await this.parse(EphemeralEdit);
43
+ const { profile } = this.resolveProfile(flags);
44
+ const workspaceId = flags.workspace || profile.workspace;
45
+ if (!workspaceId) {
46
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
47
+ }
48
+ const tenantName = args.tenant_name;
49
+ const baseUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}`;
50
+ const headers = {
51
+ 'accept': 'application/json',
52
+ 'Authorization': `Bearer ${profile.access_token}`,
53
+ 'Content-Type': 'application/json',
54
+ };
55
+ try {
56
+ // Fetch current tenant state (PUT requires all fields)
57
+ const getResponse = await this.verboseFetch(baseUrl, {
58
+ headers: {
59
+ 'accept': 'application/json',
60
+ 'Authorization': `Bearer ${profile.access_token}`,
61
+ },
62
+ method: 'GET',
63
+ }, flags.verbose, profile.access_token);
64
+ if (!getResponse.ok) {
65
+ const errorText = await getResponse.text();
66
+ this.error(`Failed to fetch tenant: ${getResponse.status} ${getResponse.statusText}\n${errorText}`);
67
+ }
68
+ const current = await getResponse.json();
69
+ // Merge in user-provided values
70
+ const body = {
71
+ description: flags.description === undefined ? (current.description ?? '') : flags.description,
72
+ display: flags.display === undefined ? (current.display ?? current.name) : flags.display,
73
+ domain: current.domain ?? '',
74
+ ingress: current.ingress ?? false,
75
+ proxy: current.proxy ?? '',
76
+ rbac: {
77
+ enabled: current.rbac?.enabled ?? false,
78
+ },
79
+ tag: current.tag ?? [],
80
+ tasks: current.tasks ?? false,
81
+ };
82
+ // Update tenant
83
+ const putResponse = await this.verboseFetch(baseUrl, {
84
+ body: JSON.stringify(body),
85
+ headers,
86
+ method: 'PUT',
87
+ }, flags.verbose, profile.access_token);
88
+ if (!putResponse.ok) {
89
+ const errorText = await putResponse.text();
90
+ this.error(`API request failed with status ${putResponse.status}: ${putResponse.statusText}\n${errorText}`);
91
+ }
92
+ const tenant = await putResponse.json();
93
+ if (flags.output === 'json') {
94
+ this.log(JSON.stringify(tenant, null, 2));
95
+ }
96
+ else {
97
+ this.log(`Updated tenant: ${tenant.display || tenant.name} (${tenant.name}) - ID: ${tenant.id}`);
98
+ }
99
+ }
100
+ catch (error) {
101
+ if (error instanceof Error) {
102
+ this.error(`Failed to edit ephemeral tenant: ${error.message}`);
103
+ }
104
+ else {
105
+ this.error(`Failed to edit ephemeral tenant: ${String(error)}`);
106
+ }
107
+ }
108
+ }
109
+ }
@@ -0,0 +1,21 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class EphemeralGet extends BaseCommand {
3
+ static args: {
4
+ tenant_name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ /**
17
+ * Render a unix-epoch-seconds expiration as a human-readable "in Xh Ym" string,
18
+ * falling back to an ISO timestamp if the value has already passed or is absent.
19
+ */
20
+ private formatExpiration;
21
+ }
@@ -0,0 +1,125 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import BaseCommand from '../../../base-command.js';
3
+ export default class EphemeralGet extends BaseCommand {
4
+ static args = {
5
+ tenant_name: Args.string({
6
+ description: 'Ephemeral tenant name to retrieve',
7
+ required: true,
8
+ }),
9
+ };
10
+ static description = 'Get details of a specific ephemeral tenant';
11
+ static examples = [
12
+ `$ xano ephemeral get e4f2-9ab1-xyz1
13
+ Tenant: PR preview (e4f2-9ab1-xyz1)
14
+ State: ok
15
+ License: tier1
16
+ Expires: in 1h 0m
17
+ `,
18
+ `$ xano ephemeral get e4f2-9ab1-xyz1 -w 5 -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(EphemeralGet);
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 tenantName = args.tenant_name;
43
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}`;
44
+ try {
45
+ const response = await this.verboseFetch(apiUrl, {
46
+ headers: {
47
+ accept: 'application/json',
48
+ Authorization: `Bearer ${profile.access_token}`,
49
+ },
50
+ method: 'GET',
51
+ }, flags.verbose, profile.access_token);
52
+ if (!response.ok) {
53
+ const errorText = await response.text();
54
+ this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
55
+ }
56
+ const tenant = (await response.json());
57
+ if (flags.output === 'json') {
58
+ this.log(JSON.stringify(tenant, null, 2));
59
+ }
60
+ else {
61
+ this.log(`Tenant: ${tenant.display || tenant.name} (${tenant.name})`);
62
+ if (tenant.state)
63
+ this.log(` State: ${tenant.state}`);
64
+ if (tenant.license)
65
+ this.log(` License: ${tenant.license}`);
66
+ if (tenant.xano_domain)
67
+ this.log(` Domain: ${tenant.xano_domain}`);
68
+ if (tenant.domain)
69
+ this.log(` Custom Domain: ${tenant.domain}`);
70
+ if (tenant.cluster?.name)
71
+ this.log(` Cluster: ${tenant.cluster.name}`);
72
+ const releaseName = typeof tenant.release === 'string' ? tenant.release : tenant.release?.name;
73
+ const releaseId = typeof tenant.release === 'object' ? tenant.release?.id : undefined;
74
+ if (releaseName)
75
+ this.log(` Release: ${releaseName} (ID: ${releaseId})`);
76
+ if (tenant.platform?.name)
77
+ this.log(` Platform: ${tenant.platform.name}`);
78
+ if (tenant.version !== undefined)
79
+ this.log(` Version: ${tenant.version}`);
80
+ if (tenant.tasks !== undefined)
81
+ this.log(` Tasks: ${tenant.tasks}`);
82
+ if (tenant.ingress !== undefined)
83
+ this.log(` Ingress: ${tenant.ingress}`);
84
+ if (tenant.type)
85
+ this.log(` Type: ${tenant.type}`);
86
+ this.log(` Expires: ${this.formatExpiration(tenant.ephemeral_expires_at)}`);
87
+ if (tenant.deployed_at) {
88
+ const d = new Date(tenant.deployed_at);
89
+ const deployedDate = Number.isNaN(d.getTime()) ? tenant.deployed_at : d.toISOString().split('T')[0];
90
+ this.log(` Deployed: ${deployedDate}`);
91
+ }
92
+ }
93
+ }
94
+ catch (error) {
95
+ if (error instanceof Error) {
96
+ this.error(`Failed to get ephemeral tenant: ${error.message}`);
97
+ }
98
+ else {
99
+ this.error(`Failed to get ephemeral tenant: ${String(error)}`);
100
+ }
101
+ }
102
+ }
103
+ /**
104
+ * Render a unix-epoch-seconds expiration as a human-readable "in Xh Ym" string,
105
+ * falling back to an ISO timestamp if the value has already passed or is absent.
106
+ */
107
+ formatExpiration(expiresAt) {
108
+ if (!expiresAt) {
109
+ return '-';
110
+ }
111
+ // The API serializes the timestamp field as a date string
112
+ // ("2026-07-24 19:49:15+0000"); tolerate a raw unix-epoch number too.
113
+ const expiresMs = typeof expiresAt === 'number' ? expiresAt * 1000 : Date.parse(String(expiresAt).replace(' ', 'T'));
114
+ if (Number.isNaN(expiresMs)) {
115
+ return String(expiresAt);
116
+ }
117
+ const diffSeconds = (expiresMs - Date.now()) / 1000;
118
+ if (diffSeconds <= 0) {
119
+ return `${new Date(expiresMs).toISOString()} (expired)`;
120
+ }
121
+ const hours = Math.floor(diffSeconds / 3600);
122
+ const minutes = Math.floor((diffSeconds % 3600) / 60);
123
+ return `in ${hours}h ${minutes}m`;
124
+ }
125
+ }
@@ -0,0 +1,20 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class EphemeralImpersonate extends BaseCommand {
3
+ static args: {
4
+ tenant_name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ guest: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'url-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ run(): Promise<void>;
18
+ private getFrontendUrl;
19
+ private getImpersonateResponse;
20
+ }
@@ -0,0 +1,120 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import open from 'open';
3
+ import BaseCommand from '../../../base-command.js';
4
+ export default class EphemeralImpersonate extends BaseCommand {
5
+ static args = {
6
+ tenant_name: Args.string({
7
+ description: 'Ephemeral tenant name to impersonate',
8
+ required: true,
9
+ }),
10
+ };
11
+ static description = 'Impersonate an ephemeral tenant and open it in the browser';
12
+ static examples = [
13
+ `$ xano ephemeral impersonate e4f2-9ab1-xyz1
14
+ Opening browser...
15
+ Impersonation successful!
16
+ `,
17
+ `$ xano ephemeral impersonate e4f2-9ab1-xyz1 -o json`,
18
+ `$ xano ephemeral impersonate e4f2-9ab1-xyz1 --guest --url-only`,
19
+ ];
20
+ static flags = {
21
+ ...BaseCommand.baseFlags,
22
+ guest: Flags.boolean({
23
+ char: 'g',
24
+ default: false,
25
+ description: 'Mint a read-only guest session (browse only; no schema/data/config changes)',
26
+ required: false,
27
+ }),
28
+ output: Flags.string({
29
+ char: 'o',
30
+ default: 'summary',
31
+ description: 'Output format',
32
+ options: ['summary', 'json'],
33
+ required: false,
34
+ }),
35
+ 'url-only': Flags.boolean({
36
+ char: 'u',
37
+ default: false,
38
+ description: 'Print the URL without opening the browser',
39
+ required: false,
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 { args, flags } = await this.parse(EphemeralImpersonate);
49
+ const { profile } = this.resolveProfile(flags);
50
+ const workspaceId = flags.workspace || profile.workspace;
51
+ if (!workspaceId) {
52
+ this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
53
+ }
54
+ const tenantName = args.tenant_name;
55
+ try {
56
+ const response = await this.getImpersonateResponse(profile, workspaceId, tenantName, flags.guest);
57
+ if (flags.output === 'json') {
58
+ this.log(JSON.stringify(response, null, 2));
59
+ }
60
+ else {
61
+ const frontendUrl = this.getFrontendUrl(profile.instance_origin);
62
+ const params = new URLSearchParams({
63
+ _ti: response._ti,
64
+ });
65
+ const impersonateUrl = `${frontendUrl}/impersonate?${params.toString()}`;
66
+ if (flags['url-only']) {
67
+ this.log(impersonateUrl);
68
+ }
69
+ else {
70
+ this.log('Opening browser...');
71
+ await open(impersonateUrl);
72
+ this.log('Impersonation successful!');
73
+ }
74
+ }
75
+ process.exit(0);
76
+ }
77
+ catch (error) {
78
+ if (error instanceof Error) {
79
+ this.error(`Failed to impersonate tenant: ${error.message}`);
80
+ }
81
+ else {
82
+ this.error(`Failed to impersonate tenant: ${String(error)}`);
83
+ }
84
+ }
85
+ }
86
+ getFrontendUrl(instanceOrigin) {
87
+ try {
88
+ const url = new URL(instanceOrigin);
89
+ if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') {
90
+ url.port = '4200';
91
+ return url.origin;
92
+ }
93
+ }
94
+ catch {
95
+ // fall through
96
+ }
97
+ return instanceOrigin;
98
+ }
99
+ async getImpersonateResponse(profile, workspaceId, tenantName, guest = false) {
100
+ const query = guest ? '?guest_read_only=true' : '';
101
+ const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(tenantName)}/impersonate${query}`;
102
+ const { verbose } = await this.parse(EphemeralImpersonate).then((r) => r.flags);
103
+ const response = await this.verboseFetch(apiUrl, {
104
+ headers: {
105
+ accept: 'application/json',
106
+ Authorization: `Bearer ${profile.access_token}`,
107
+ },
108
+ method: 'GET',
109
+ }, verbose, profile.access_token);
110
+ if (!response.ok) {
111
+ const errorText = await response.text();
112
+ throw new Error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
113
+ }
114
+ const result = (await response.json());
115
+ if (!result._ti) {
116
+ throw new Error('No one-time token returned from impersonate API');
117
+ }
118
+ return result;
119
+ }
120
+ }
@@ -0,0 +1,19 @@
1
+ import BaseCommand from '../../../base-command.js';
2
+ export default class EphemeralList extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ global: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ config: 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
+ /**
15
+ * Render a unix-epoch-seconds expiration as a human-readable "in Xh Ym" string,
16
+ * falling back to an ISO timestamp if the value has already passed or is malformed.
17
+ */
18
+ private formatExpiration;
19
+ }