@xano/cli 1.0.6-beta.7 → 1.1.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 (56) hide show
  1. package/README.md +3 -61
  2. package/dist/base-command.d.ts +0 -2
  3. package/dist/base-command.js +4 -10
  4. package/dist/commands/release/pull/index.d.ts +6 -0
  5. package/dist/commands/release/pull/index.js +95 -10
  6. package/dist/commands/sandbox/pull/index.d.ts +1 -0
  7. package/dist/commands/sandbox/pull/index.js +77 -10
  8. package/dist/commands/tenant/pull/index.d.ts +6 -0
  9. package/dist/commands/tenant/pull/index.js +95 -10
  10. package/dist/commands/workspace/git/pull/index.js +3 -53
  11. package/dist/commands/workspace/pull/index.d.ts +6 -0
  12. package/dist/commands/workspace/pull/index.js +95 -10
  13. package/dist/utils/document-parser.d.ts +0 -85
  14. package/dist/utils/document-parser.js +1 -214
  15. package/dist/utils/knowledge-sync.d.ts +0 -1
  16. package/dist/utils/knowledge-sync.js +5 -11
  17. package/dist/utils/paging.d.ts +1 -2
  18. package/dist/utils/reference-checker.js +0 -13
  19. package/oclif.manifest.json +3174 -5182
  20. package/package.json +1 -10
  21. package/dist/commands/ephemeral/create/index.d.ts +0 -18
  22. package/dist/commands/ephemeral/create/index.js +0 -103
  23. package/dist/commands/ephemeral/delete/index.d.ts +0 -18
  24. package/dist/commands/ephemeral/delete/index.js +0 -99
  25. package/dist/commands/ephemeral/edit/index.d.ts +0 -18
  26. package/dist/commands/ephemeral/edit/index.js +0 -109
  27. package/dist/commands/ephemeral/get/index.d.ts +0 -21
  28. package/dist/commands/ephemeral/get/index.js +0 -125
  29. package/dist/commands/ephemeral/impersonate/index.d.ts +0 -20
  30. package/dist/commands/ephemeral/impersonate/index.js +0 -120
  31. package/dist/commands/ephemeral/list/index.d.ts +0 -19
  32. package/dist/commands/ephemeral/list/index.js +0 -123
  33. package/dist/commands/ephemeral/pull/index.d.ts +0 -19
  34. package/dist/commands/ephemeral/pull/index.js +0 -164
  35. package/dist/commands/ephemeral/push/index.d.ts +0 -25
  36. package/dist/commands/ephemeral/push/index.js +0 -144
  37. package/dist/commands/ephemeral/static_host/build/delete/index.d.ts +0 -20
  38. package/dist/commands/ephemeral/static_host/build/delete/index.js +0 -121
  39. package/dist/commands/ephemeral/static_host/build/get/index.d.ts +0 -18
  40. package/dist/commands/ephemeral/static_host/build/get/index.js +0 -137
  41. package/dist/commands/ephemeral/static_host/build/list/index.d.ts +0 -18
  42. package/dist/commands/ephemeral/static_host/build/list/index.js +0 -137
  43. package/dist/commands/ephemeral/static_host/build/pull/index.d.ts +0 -53
  44. package/dist/commands/ephemeral/static_host/build/pull/index.js +0 -308
  45. package/dist/commands/ephemeral/static_host/build/push/index.d.ts +0 -24
  46. package/dist/commands/ephemeral/static_host/build/push/index.js +0 -250
  47. package/dist/commands/ephemeral/static_host/create/index.d.ts +0 -18
  48. package/dist/commands/ephemeral/static_host/create/index.js +0 -92
  49. package/dist/commands/ephemeral/static_host/deploy/index.d.ts +0 -19
  50. package/dist/commands/ephemeral/static_host/deploy/index.js +0 -112
  51. package/dist/commands/ephemeral/static_host/edit/index.d.ts +0 -24
  52. package/dist/commands/ephemeral/static_host/edit/index.js +0 -158
  53. package/dist/commands/ephemeral/static_host/get/index.d.ts +0 -19
  54. package/dist/commands/ephemeral/static_host/get/index.js +0 -101
  55. package/dist/commands/ephemeral/static_host/list/index.d.ts +0 -17
  56. package/dist/commands/ephemeral/static_host/list/index.js +0 -132
@@ -1,120 +0,0 @@
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
- async getImpersonateResponse(profile, workspaceId, tenantName, guest = false) {
87
- const query = guest ? '?guest_read_only=true' : '';
88
- const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(tenantName)}/impersonate${query}`;
89
- const { verbose } = await this.parse(EphemeralImpersonate).then((r) => r.flags);
90
- const response = await this.verboseFetch(apiUrl, {
91
- headers: {
92
- Authorization: `Bearer ${profile.access_token}`,
93
- accept: 'application/json',
94
- },
95
- method: 'GET',
96
- }, verbose, profile.access_token);
97
- if (!response.ok) {
98
- const errorText = await response.text();
99
- throw new Error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
100
- }
101
- const result = (await response.json());
102
- if (!result._ti) {
103
- throw new Error('No one-time token returned from impersonate API');
104
- }
105
- return result;
106
- }
107
- getFrontendUrl(instanceOrigin) {
108
- try {
109
- const url = new URL(instanceOrigin);
110
- if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') {
111
- url.port = '4200';
112
- return url.origin;
113
- }
114
- }
115
- catch {
116
- // fall through
117
- }
118
- return instanceOrigin;
119
- }
120
- }
@@ -1,19 +0,0 @@
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
- }
@@ -1,123 +0,0 @@
1
- import { Flags } from '@oclif/core';
2
- import BaseCommand from '../../../base-command.js';
3
- import { buildPagingJson } from '../../../utils/paging.js';
4
- export default class EphemeralList extends BaseCommand {
5
- static description = 'List ephemeral tenants in a workspace, or across the whole instance with --global';
6
- static examples = [
7
- `$ xano ephemeral list
8
- Ephemeral tenants in workspace 5:
9
- - PR preview (e4f2-9ab1-...) [ok] - expires in 1h 0m
10
- - Demo (e7a3-2c10-...) [ok] - expires in 23h 12m
11
- `,
12
- `$ xano ephemeral list --global
13
- Ephemeral tenants (all workspaces):
14
- - PR preview (e4f2-9ab1-...) [ok] - expires in 1h 0m
15
- `,
16
- `$ xano ephemeral list -w 5 -o json`,
17
- ];
18
- static flags = {
19
- ...BaseCommand.baseFlags,
20
- global: Flags.boolean({
21
- default: false,
22
- description: 'List ephemeral tenants across the whole instance (all workspaces)',
23
- required: false,
24
- }),
25
- output: Flags.string({
26
- char: 'o',
27
- default: 'summary',
28
- description: 'Output format',
29
- options: ['summary', 'json'],
30
- required: false,
31
- }),
32
- workspace: Flags.string({
33
- char: 'w',
34
- description: 'Workspace ID (uses profile workspace if not provided)',
35
- required: false,
36
- }),
37
- };
38
- async run() {
39
- const { flags } = await this.parse(EphemeralList);
40
- const { profile } = this.resolveProfile(flags);
41
- let workspaceId;
42
- let apiUrl;
43
- if (flags.global) {
44
- apiUrl = `${profile.instance_origin}/api:meta/ephemeral`;
45
- }
46
- else {
47
- workspaceId = flags.workspace || profile.workspace;
48
- if (!workspaceId) {
49
- this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
50
- }
51
- apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/ephemeral`;
52
- }
53
- try {
54
- const response = await this.verboseFetch(apiUrl, {
55
- headers: {
56
- accept: 'application/json',
57
- Authorization: `Bearer ${profile.access_token}`,
58
- },
59
- method: 'GET',
60
- }, flags.verbose, profile.access_token);
61
- if (!response.ok) {
62
- const errorText = await response.text();
63
- this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
64
- }
65
- const data = (await response.json());
66
- let tenants;
67
- if (Array.isArray(data)) {
68
- tenants = data;
69
- }
70
- else if (data && typeof data === 'object' && Array.isArray(data.items)) {
71
- tenants = data.items;
72
- }
73
- else {
74
- this.error('Unexpected API response format');
75
- }
76
- if (flags.output === 'json') {
77
- this.log(JSON.stringify(buildPagingJson({ items: tenants }, { tier: 'none' }), null, 2));
78
- }
79
- else if (tenants.length === 0) {
80
- this.log('No ephemeral tenants found');
81
- }
82
- else {
83
- this.log(flags.global ? 'Ephemeral tenants (all workspaces):' : `Ephemeral tenants in workspace ${workspaceId}:`);
84
- for (const tenant of tenants) {
85
- const state = tenant.state ? ` [${tenant.state}]` : '';
86
- const expires = ` - expires ${this.formatExpiration(tenant.ephemeral_expires_at)}`;
87
- const workspaceLabel = flags.global && tenant.workspace_id ? ` (workspace ${tenant.workspace_id})` : '';
88
- this.log(` - ${tenant.display || tenant.name} (${tenant.name})${state}${expires}${workspaceLabel}`);
89
- }
90
- }
91
- }
92
- catch (error) {
93
- if (error instanceof Error) {
94
- this.error(`Failed to list ephemeral tenants: ${error.message}`);
95
- }
96
- else {
97
- this.error(`Failed to list ephemeral tenants: ${String(error)}`);
98
- }
99
- }
100
- }
101
- /**
102
- * Render a unix-epoch-seconds expiration as a human-readable "in Xh Ym" string,
103
- * falling back to an ISO timestamp if the value has already passed or is malformed.
104
- */
105
- formatExpiration(expiresAt) {
106
- if (!expiresAt) {
107
- return '-';
108
- }
109
- // The API serializes the timestamp field as a date string
110
- // ("2026-07-24 19:49:15+0000"); tolerate a raw unix-epoch number too.
111
- const expiresMs = typeof expiresAt === 'number' ? expiresAt * 1000 : Date.parse(String(expiresAt).replace(' ', 'T'));
112
- if (Number.isNaN(expiresMs)) {
113
- return String(expiresAt);
114
- }
115
- const diffSeconds = (expiresMs - Date.now()) / 1000;
116
- if (diffSeconds <= 0) {
117
- return `${new Date(expiresMs).toISOString()} (expired)`;
118
- }
119
- const hours = Math.floor(diffSeconds / 3600);
120
- const minutes = Math.floor((diffSeconds % 3600) / 60);
121
- return `in ${hours}h ${minutes}m`;
122
- }
123
- }
@@ -1,19 +0,0 @@
1
- import BaseCommand from '../../../base-command.js';
2
- export default class EphemeralPull 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
- directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- draft: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
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
- }
@@ -1,164 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import * as fs from 'node:fs';
3
- import * as path from 'node:path';
4
- import snakeCase from 'lodash.snakecase';
5
- import BaseCommand from '../../../base-command.js';
6
- import { buildApiGroupFolderResolver, buildChannelServerResolver, parseDocument, resolveDocumentPath, } from '../../../utils/document-parser.js';
7
- export default class EphemeralPull extends BaseCommand {
8
- static args = {
9
- tenant_name: Args.string({
10
- description: 'Ephemeral tenant name to pull from',
11
- required: true,
12
- }),
13
- };
14
- static description = 'Pull an ephemeral tenant multidoc from the Xano Metadata API and split into individual files';
15
- static examples = [
16
- `$ xano ephemeral pull e4f2-9ab1-xyz1
17
- Pulled 42 documents from tenant e4f2-9ab1-xyz1 to current directory
18
- `,
19
- `$ xano ephemeral pull e4f2-9ab1-xyz1 -d ./my-tenant
20
- Pulled 42 documents from tenant e4f2-9ab1-xyz1 to ./my-tenant
21
- `,
22
- `$ xano ephemeral pull e4f2-9ab1-xyz1 -d ./output -w 40
23
- Pulled 15 documents from tenant e4f2-9ab1-xyz1 to ./output
24
- `,
25
- `$ xano ephemeral pull e4f2-9ab1-xyz1 --profile production --env --records
26
- Pulled 58 documents from tenant e4f2-9ab1-xyz1
27
- `,
28
- `$ xano ephemeral pull e4f2-9ab1-xyz1 --draft`,
29
- ];
30
- static flags = {
31
- ...BaseCommand.baseFlags,
32
- directory: Flags.string({
33
- char: 'd',
34
- default: '.',
35
- description: 'Output directory for pulled documents (defaults to current directory)',
36
- required: false,
37
- }),
38
- draft: Flags.boolean({
39
- default: false,
40
- description: 'Include draft versions',
41
- required: false,
42
- }),
43
- env: Flags.boolean({
44
- default: false,
45
- description: 'Include environment variables',
46
- required: false,
47
- }),
48
- records: Flags.boolean({
49
- default: false,
50
- description: 'Include records',
51
- required: false,
52
- }),
53
- workspace: Flags.string({
54
- char: 'w',
55
- description: 'Workspace ID (optional if set in profile)',
56
- required: false,
57
- }),
58
- };
59
- async run() {
60
- const { args, flags } = await this.parse(EphemeralPull);
61
- const { profileName, profile } = this.resolveProfile(flags);
62
- // Determine workspace_id from flag or profile
63
- let workspaceId;
64
- if (flags.workspace) {
65
- workspaceId = flags.workspace;
66
- }
67
- else if (profile.workspace) {
68
- workspaceId = profile.workspace;
69
- }
70
- else {
71
- this.error(`Workspace ID is required. Either:\n` +
72
- ` 1. Provide it as a flag: xano ephemeral pull <tenant_name> -w <workspace_id>\n` +
73
- ` 2. Set it in your profile using: xano profile:edit ${profileName} -w <workspace_id>`);
74
- }
75
- const tenantName = args.tenant_name;
76
- // Build query parameters
77
- const queryParams = new URLSearchParams({
78
- env: flags.env.toString(),
79
- include_draft: flags.draft.toString(),
80
- records: flags.records.toString(),
81
- });
82
- // Construct the API URL
83
- const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}/multidoc?${queryParams.toString()}`;
84
- // Fetch multidoc from the API
85
- let responseText;
86
- const requestHeaders = {
87
- accept: 'application/json',
88
- Authorization: `Bearer ${profile.access_token}`,
89
- };
90
- try {
91
- const response = await this.verboseFetch(apiUrl, {
92
- headers: requestHeaders,
93
- method: 'GET',
94
- }, flags.verbose, profile.access_token);
95
- if (!response.ok) {
96
- const errorText = await response.text();
97
- this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
98
- }
99
- responseText = await response.text();
100
- }
101
- catch (error) {
102
- if (error instanceof Error) {
103
- this.error(`Failed to fetch multidoc: ${error.message}`);
104
- }
105
- else {
106
- this.error(`Failed to fetch multidoc: ${String(error)}`);
107
- }
108
- }
109
- // Split the response into individual documents
110
- const rawDocuments = responseText.split('\n---\n');
111
- // Parse each document
112
- const documents = [];
113
- for (const raw of rawDocuments) {
114
- const trimmed = raw.trim();
115
- if (!trimmed) {
116
- continue;
117
- }
118
- const parsed = parseDocument(trimmed);
119
- if (parsed) {
120
- documents.push(parsed);
121
- }
122
- }
123
- if (documents.length === 0) {
124
- this.log('No documents found in response');
125
- return;
126
- }
127
- // Resolve the output directory
128
- const outputDir = path.resolve(flags.directory);
129
- // Create the output directory if it doesn't exist
130
- fs.mkdirSync(outputDir, { recursive: true });
131
- // Resolve api_group names to unique folder names, disambiguating collisions
132
- const getApiGroupFolder = buildApiGroupFolderResolver(documents, snakeCase);
133
- // Resolve a realtime v2 channel path -> owning realtime_server name, so
134
- // messages can nest under their channel's server (see resolver docs).
135
- const getChannelServer = buildChannelServerResolver(documents);
136
- // Track filenames per type to handle duplicates
137
- const filenameCounters = new Map();
138
- let writtenCount = 0;
139
- for (const doc of documents) {
140
- const { baseName, typeDir } = resolveDocumentPath(doc, outputDir, {
141
- getApiGroupFolder,
142
- getChannelServer,
143
- join: path.join,
144
- snakeCase,
145
- });
146
- fs.mkdirSync(typeDir, { recursive: true });
147
- // Track duplicates per directory
148
- const dirKey = path.relative(outputDir, typeDir);
149
- if (!filenameCounters.has(dirKey)) {
150
- filenameCounters.set(dirKey, new Map());
151
- }
152
- const typeCounters = filenameCounters.get(dirKey);
153
- const count = typeCounters.get(baseName) || 0;
154
- typeCounters.set(baseName, count + 1);
155
- // Append numeric suffix for duplicates
156
- let filename;
157
- filename = count === 0 ? `${baseName}.xs` : `${baseName}_${count + 1}.xs`;
158
- const filePath = path.join(typeDir, filename);
159
- fs.writeFileSync(filePath, doc.content, 'utf8');
160
- writtenCount++;
161
- }
162
- this.log(`Pulled ${writtenCount} documents from tenant ${tenantName} to ${flags.directory}`);
163
- }
164
- }
@@ -1,25 +0,0 @@
1
- import BaseCommand from '../../../base-command.js';
2
- export default class EphemeralPush 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
- directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- 'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- env: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
- force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
- guids: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
- records: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
- sync: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
- transaction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
- truncate: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
- workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
- config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
- };
24
- run(): Promise<void>;
25
- }
@@ -1,144 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import * as fs from 'node:fs';
3
- import { resolve } from 'node:path';
4
- import BaseCommand from '../../../base-command.js';
5
- import { executePush } from '../../../utils/multidoc-push.js';
6
- export default class EphemeralPush extends BaseCommand {
7
- static args = {
8
- tenant_name: Args.string({
9
- description: 'Ephemeral tenant name to push to',
10
- required: true,
11
- }),
12
- };
13
- static description = '[IMPORTANT] ALWAYS run --dry-run first and show the user the output before pushing. Push local documents to an ephemeral tenant via multidoc import. By default, only changed files are pushed (partial mode). Use --sync to push all files. Shows a preview of changes before pushing unless --force is specified. Use --dry-run to preview only.';
14
- static examples = [
15
- `$ xano ephemeral push e4f2-9ab1-xyz1
16
- Push from current directory (default partial mode)
17
- `,
18
- `$ xano ephemeral push e4f2-9ab1-xyz1 -d ./my-workspace
19
- Push from a specific directory
20
- `,
21
- `$ xano ephemeral push e4f2-9ab1-xyz1 --sync
22
- Push all files to the ephemeral tenant
23
- `,
24
- `$ xano ephemeral push e4f2-9ab1-xyz1 --sync --delete
25
- Push all files and delete remote objects not included
26
- `,
27
- `$ xano ephemeral push e4f2-9ab1-xyz1 --dry-run
28
- Preview changes without pushing
29
- `,
30
- `$ xano ephemeral push e4f2-9ab1-xyz1 --force
31
- Skip preview and push immediately
32
- `,
33
- `$ xano ephemeral push e4f2-9ab1-xyz1 --records --env`,
34
- `$ xano ephemeral push e4f2-9ab1-xyz1 --truncate`,
35
- ];
36
- static flags = {
37
- ...BaseCommand.baseFlags,
38
- directory: Flags.string({
39
- char: 'd',
40
- default: '.',
41
- description: 'Directory containing documents to push (defaults to current directory)',
42
- required: false,
43
- }),
44
- delete: Flags.boolean({
45
- default: false,
46
- description: 'Delete remote objects not included in the push (requires --sync)',
47
- required: false,
48
- }),
49
- 'dry-run': Flags.boolean({
50
- default: false,
51
- description: 'Show preview of changes without pushing (exit after preview)',
52
- required: false,
53
- }),
54
- env: Flags.boolean({
55
- default: false,
56
- description: 'Include environment variables in import',
57
- required: false,
58
- }),
59
- force: Flags.boolean({
60
- default: false,
61
- description: 'Skip preview and confirmation prompt (for CI/CD pipelines)',
62
- required: false,
63
- }),
64
- guids: Flags.boolean({
65
- allowNo: true,
66
- default: true,
67
- description: 'Write server-assigned GUIDs back to local files (use --no-guids to skip)',
68
- required: false,
69
- }),
70
- records: Flags.boolean({
71
- default: false,
72
- description: 'Include records in import',
73
- required: false,
74
- }),
75
- sync: Flags.boolean({
76
- default: false,
77
- description: 'Full push — send all files, not just changed ones. Required for --delete.',
78
- required: false,
79
- }),
80
- transaction: Flags.boolean({
81
- allowNo: true,
82
- default: true,
83
- description: '[CRITICAL] DO NOT run with --no-transaction without explicit user confirmation; this disables rollback. Wraps import in a database transaction (use --no-transaction for debugging purposes).',
84
- required: false,
85
- }),
86
- truncate: Flags.boolean({
87
- default: false,
88
- description: '[CRITICAL] STOP and confirm with the user; this truncates live tables before importing.',
89
- required: false,
90
- }),
91
- workspace: Flags.string({
92
- char: 'w',
93
- description: 'Workspace ID (uses profile workspace if not provided)',
94
- required: false,
95
- }),
96
- };
97
- async run() {
98
- const { args, flags } = await this.parse(EphemeralPush);
99
- const { profile } = this.resolveProfile(flags);
100
- const workspaceId = flags.workspace || profile.workspace;
101
- if (!workspaceId) {
102
- this.error('No workspace ID provided. Ephemeral tenants require a workspace — use --workspace or set one in your profile.');
103
- }
104
- const inputDir = resolve(flags.directory);
105
- if (!fs.existsSync(inputDir)) {
106
- this.error(`Directory not found: ${inputDir}`);
107
- }
108
- if (!fs.statSync(inputDir).isDirectory()) {
109
- this.error(`Not a directory: ${inputDir}`);
110
- }
111
- const tenantName = args.tenant_name;
112
- const baseUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}`;
113
- const target = {
114
- buildDryRunUrl: (params) => `${baseUrl}/multidoc/dry-run?${params.toString()}`,
115
- buildPushUrl: (params) => `${baseUrl}/multidoc?${params.toString()}`,
116
- cliVersion: this.config.version,
117
- instanceOrigin: profile.instance_origin,
118
- label: `ephemeral tenant ${tenantName}`,
119
- sourceWorkspaceId: profile.workspace,
120
- supportsBranches: false,
121
- supportsPartial: true,
122
- warnOnWorkspaceMismatch: false,
123
- };
124
- const pushFlags = {
125
- delete: flags.delete,
126
- 'dry-run': flags['dry-run'],
127
- env: flags.env,
128
- force: flags.force,
129
- guids: flags.guids,
130
- records: flags.records,
131
- sync: flags.sync,
132
- transaction: flags.transaction,
133
- truncate: flags.truncate,
134
- verbose: flags.verbose,
135
- };
136
- await executePush({
137
- accessToken: profile.access_token,
138
- branch: '',
139
- command: this,
140
- inputDir,
141
- verboseFetch: this.verboseFetch.bind(this),
142
- }, target, pushFlags);
143
- }
144
- }
@@ -1,20 +0,0 @@
1
- import BaseCommand from '../../../../../base-command.js';
2
- export default class EphemeralStaticHostBuildDelete 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
- build_id: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
- 'static-host': 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
- private confirm;
20
- }