@xano/cli 0.0.14 → 0.0.16

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 (66) hide show
  1. package/README.md +115 -14
  2. package/dist/commands/profile/create/index.d.ts +2 -0
  3. package/dist/commands/profile/create/index.js +15 -0
  4. package/dist/commands/profile/edit/index.d.ts +6 -0
  5. package/dist/commands/profile/edit/index.js +50 -1
  6. package/dist/commands/profile/list/index.js +5 -0
  7. package/dist/commands/profile/project/index.d.ts +6 -0
  8. package/dist/commands/profile/project/index.js +54 -0
  9. package/dist/commands/profile/token/index.d.ts +6 -0
  10. package/dist/commands/profile/token/index.js +54 -0
  11. package/dist/commands/profile/wizard/index.d.ts +2 -0
  12. package/dist/commands/profile/wizard/index.js +108 -0
  13. package/dist/commands/run/env/delete/index.d.ts +13 -0
  14. package/dist/commands/run/env/delete/index.js +65 -0
  15. package/dist/commands/run/env/get/index.d.ts +13 -0
  16. package/dist/commands/run/env/get/index.js +52 -0
  17. package/dist/commands/run/env/list/index.d.ts +11 -0
  18. package/dist/commands/run/env/list/index.js +58 -0
  19. package/dist/commands/run/env/set/index.d.ts +13 -0
  20. package/dist/commands/run/env/set/index.js +51 -0
  21. package/dist/commands/{ephemeral/run/job → run/exec}/index.d.ts +4 -3
  22. package/dist/commands/run/exec/index.js +353 -0
  23. package/dist/commands/{ephemeral/run/service → run/info}/index.d.ts +3 -5
  24. package/dist/commands/run/info/index.js +160 -0
  25. package/dist/commands/run/projects/create/index.d.ts +13 -0
  26. package/dist/commands/run/projects/create/index.js +75 -0
  27. package/dist/commands/run/projects/delete/index.d.ts +13 -0
  28. package/dist/commands/run/projects/delete/index.js +65 -0
  29. package/dist/commands/run/projects/list/index.d.ts +12 -0
  30. package/dist/commands/run/projects/list/index.js +66 -0
  31. package/dist/commands/run/projects/update/index.d.ts +15 -0
  32. package/dist/commands/run/projects/update/index.js +86 -0
  33. package/dist/commands/run/secrets/delete/index.d.ts +13 -0
  34. package/dist/commands/run/secrets/delete/index.js +65 -0
  35. package/dist/commands/run/secrets/get/index.d.ts +13 -0
  36. package/dist/commands/run/secrets/get/index.js +52 -0
  37. package/dist/commands/run/secrets/list/index.d.ts +11 -0
  38. package/dist/commands/run/secrets/list/index.js +62 -0
  39. package/dist/commands/run/secrets/set/index.d.ts +15 -0
  40. package/dist/commands/run/secrets/set/index.js +74 -0
  41. package/dist/commands/run/sessions/delete/index.d.ts +13 -0
  42. package/dist/commands/run/sessions/delete/index.js +65 -0
  43. package/dist/commands/run/sessions/get/index.d.ts +13 -0
  44. package/dist/commands/run/sessions/get/index.js +72 -0
  45. package/dist/commands/run/sessions/list/index.d.ts +12 -0
  46. package/dist/commands/run/sessions/list/index.js +64 -0
  47. package/dist/commands/run/sessions/start/index.d.ts +13 -0
  48. package/dist/commands/run/sessions/start/index.js +56 -0
  49. package/dist/commands/run/sessions/stop/index.d.ts +13 -0
  50. package/dist/commands/run/sessions/stop/index.js +56 -0
  51. package/dist/commands/run/sink/get/index.d.ts +13 -0
  52. package/dist/commands/run/sink/get/index.js +63 -0
  53. package/dist/commands/workspace/pull/index.d.ts +28 -0
  54. package/dist/commands/workspace/pull/index.js +238 -0
  55. package/dist/commands/workspace/push/index.d.ts +19 -0
  56. package/dist/commands/workspace/push/index.js +163 -0
  57. package/dist/lib/base-run-command.d.ts +42 -0
  58. package/dist/lib/base-run-command.js +75 -0
  59. package/dist/lib/run-http-client.d.ts +58 -0
  60. package/dist/lib/run-http-client.js +136 -0
  61. package/dist/lib/run-types.d.ts +226 -0
  62. package/dist/lib/run-types.js +5 -0
  63. package/oclif.manifest.json +1470 -218
  64. package/package.json +1 -1
  65. package/dist/commands/ephemeral/run/job/index.js +0 -311
  66. package/dist/commands/ephemeral/run/service/index.js +0 -287
@@ -0,0 +1,136 @@
1
+ /**
2
+ * HTTP client for Xano Run API
3
+ * Based on @xano/run-sdk HttpClient
4
+ */
5
+ export const DEFAULT_RUN_BASE_URL = 'https://app.xano.com/';
6
+ export class RunHttpClient {
7
+ config;
8
+ constructor(config) {
9
+ this.config = config;
10
+ }
11
+ /**
12
+ * Get the project ID
13
+ */
14
+ getProjectId() {
15
+ return this.config.projectId;
16
+ }
17
+ /**
18
+ * Build headers for a request
19
+ */
20
+ getHeaders(contentType = 'application/json') {
21
+ const headers = {
22
+ 'Content-Type': contentType,
23
+ 'Authorization': `Bearer ${this.config.authToken}`,
24
+ };
25
+ return headers;
26
+ }
27
+ /**
28
+ * Build a URL with optional query parameters
29
+ */
30
+ buildUrl(path, queryParams) {
31
+ const baseUrl = this.config.baseUrl.endsWith('/')
32
+ ? this.config.baseUrl.slice(0, -1)
33
+ : this.config.baseUrl;
34
+ const url = new URL(`${baseUrl}/api:run${path}`);
35
+ if (queryParams) {
36
+ for (const [key, value] of Object.entries(queryParams)) {
37
+ if (value !== undefined && value !== null) {
38
+ if (typeof value === 'object') {
39
+ url.searchParams.set(key, JSON.stringify(value));
40
+ }
41
+ else {
42
+ url.searchParams.set(key, String(value));
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return url.toString();
48
+ }
49
+ /**
50
+ * Build a URL scoped to the current project
51
+ */
52
+ buildProjectUrl(path, queryParams) {
53
+ const projectId = this.config.projectId;
54
+ if (!projectId) {
55
+ throw new Error('Project ID is required. Set it in your profile.');
56
+ }
57
+ return this.buildUrl(`/project/${projectId}${path}`, queryParams);
58
+ }
59
+ /**
60
+ * Build a URL scoped to a specific session
61
+ */
62
+ buildSessionUrl(sessionId, path = '', queryParams) {
63
+ return this.buildUrl(`/session/${sessionId}${path}`, queryParams);
64
+ }
65
+ /**
66
+ * Make an HTTP request
67
+ */
68
+ async request(url, options) {
69
+ const response = await fetch(url, options);
70
+ if (!response.ok) {
71
+ const error = new Error(`HTTP ${response.status}: ${response.statusText}`);
72
+ error.status = response.status;
73
+ try {
74
+ error.response = await response.json();
75
+ }
76
+ catch {
77
+ error.response = await response.text();
78
+ }
79
+ throw error;
80
+ }
81
+ const text = await response.text();
82
+ if (!text) {
83
+ return undefined;
84
+ }
85
+ return JSON.parse(text);
86
+ }
87
+ /**
88
+ * Make a GET request
89
+ */
90
+ async get(url) {
91
+ return this.request(url, {
92
+ method: 'GET',
93
+ headers: this.getHeaders(),
94
+ });
95
+ }
96
+ /**
97
+ * Make a POST request with JSON body
98
+ */
99
+ async post(url, body) {
100
+ return this.request(url, {
101
+ method: 'POST',
102
+ headers: this.getHeaders(),
103
+ body: body ? JSON.stringify(body) : undefined,
104
+ });
105
+ }
106
+ /**
107
+ * Make a POST request with XanoScript body
108
+ */
109
+ async postXanoScript(url, code) {
110
+ return this.request(url, {
111
+ method: 'POST',
112
+ headers: this.getHeaders('text/x-xanoscript'),
113
+ body: code,
114
+ });
115
+ }
116
+ /**
117
+ * Make a PATCH request
118
+ */
119
+ async patch(url, body) {
120
+ return this.request(url, {
121
+ method: 'PATCH',
122
+ headers: this.getHeaders(),
123
+ body: JSON.stringify(body),
124
+ });
125
+ }
126
+ /**
127
+ * Make a DELETE request
128
+ */
129
+ async delete(url, body) {
130
+ return this.request(url, {
131
+ method: 'DELETE',
132
+ headers: this.getHeaders(),
133
+ body: body ? JSON.stringify(body) : undefined,
134
+ });
135
+ }
136
+ }
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Types for Xano Run API
3
+ * Based on @xano/run-sdk types
4
+ */
5
+ export interface PaginatedResponse<T> {
6
+ items: T[];
7
+ itemsReceived?: number;
8
+ curPage?: number;
9
+ nextPage?: number | null;
10
+ prevPage?: number | null;
11
+ offset?: number;
12
+ perPage?: number;
13
+ itemsTotal?: number;
14
+ pageTotal?: number;
15
+ }
16
+ export interface XanoRunError extends Error {
17
+ status?: number;
18
+ response?: unknown;
19
+ }
20
+ export interface Project {
21
+ id: string;
22
+ created_at: string;
23
+ name: string;
24
+ description: string;
25
+ user_id: number;
26
+ access: 'private' | 'public';
27
+ }
28
+ export interface CreateProjectInput {
29
+ name: string;
30
+ description: string;
31
+ }
32
+ export interface UpdateProjectInput {
33
+ name?: string;
34
+ description?: string;
35
+ }
36
+ export interface EnvKeysResponse {
37
+ env: string[];
38
+ }
39
+ export interface EnvValueResponse {
40
+ name: string;
41
+ value: string;
42
+ }
43
+ export interface UpdateEnvInput {
44
+ name: string;
45
+ env: {
46
+ name: string;
47
+ value: string;
48
+ };
49
+ }
50
+ export type SecretType = 'kubernetes.io/dockerconfigjson' | 'kubernetes.io/service-account-token';
51
+ export interface SecretMetadata {
52
+ name: string;
53
+ type: SecretType;
54
+ repo?: string;
55
+ }
56
+ export interface SecretKeysResponse {
57
+ secrets: SecretMetadata[];
58
+ }
59
+ export interface SecretValueResponse {
60
+ name: string;
61
+ type: SecretType;
62
+ repo?: string;
63
+ value: string;
64
+ }
65
+ export interface UpdateSecretInput {
66
+ name: string;
67
+ secret: {
68
+ name: string;
69
+ type: SecretType;
70
+ value: string;
71
+ repo?: string;
72
+ };
73
+ }
74
+ export type RunType = 'job' | 'service';
75
+ export interface RunOptions {
76
+ args?: Record<string, unknown>;
77
+ env?: Record<string, string>;
78
+ }
79
+ export interface RunBackup {
80
+ resource: string;
81
+ size: number;
82
+ }
83
+ export interface RunDefinition {
84
+ id: string;
85
+ created_at: string;
86
+ updated_at: string;
87
+ name: string;
88
+ user_id: number;
89
+ project_id: string;
90
+ sig: string;
91
+ type: RunType;
92
+ args: unknown[] | Record<string, unknown>;
93
+ doc: string;
94
+ }
95
+ export interface SessionExecution {
96
+ id: string;
97
+ created_at: string;
98
+ updated_at: string;
99
+ run_id: string;
100
+ batch_id: string | null;
101
+ state: 'complete' | 'error' | string;
102
+ error_msg: string;
103
+ response: unknown;
104
+ label: string;
105
+ boot_time: number;
106
+ pre_time: number;
107
+ main_time: number;
108
+ post_time: number;
109
+ total_time: number;
110
+ tenant_id: number;
111
+ access: string;
112
+ backup: RunBackup;
113
+ _run: RunDefinition;
114
+ }
115
+ export interface EndpointInput {
116
+ source: string;
117
+ name: string;
118
+ type: string;
119
+ nullable: boolean;
120
+ default: string;
121
+ required: boolean;
122
+ }
123
+ export interface Endpoint {
124
+ url: string;
125
+ verb: string;
126
+ input: EndpointInput[];
127
+ }
128
+ export interface MetadataApi {
129
+ url: string;
130
+ }
131
+ export interface RunResult {
132
+ run?: {
133
+ id?: string | number;
134
+ session?: SessionExecution;
135
+ result?: {
136
+ response?: unknown;
137
+ boot_time?: number;
138
+ main_time?: number;
139
+ pre_time?: number;
140
+ post_time?: number;
141
+ total_time?: number;
142
+ };
143
+ debug?: string[];
144
+ problems?: Array<{
145
+ message?: string;
146
+ severity?: string;
147
+ }>;
148
+ };
149
+ service?: {
150
+ id: number;
151
+ run: {
152
+ id: number;
153
+ };
154
+ };
155
+ logs?: unknown[];
156
+ result?: {
157
+ state?: 'complete';
158
+ response?: unknown;
159
+ boot_time?: number;
160
+ pre_time?: number;
161
+ main_time?: number;
162
+ post_time?: number;
163
+ total_time?: number;
164
+ pre_result?: unknown;
165
+ endpoints?: Endpoint[];
166
+ metadata_api?: MetadataApi;
167
+ };
168
+ }
169
+ export interface DocInfoResult {
170
+ type: RunType;
171
+ input?: Record<string, unknown>;
172
+ env?: string[];
173
+ }
174
+ export type SessionStatus = 'running' | 'stopped' | 'error';
175
+ export interface Session {
176
+ id: string;
177
+ created_at: string;
178
+ updated_at: string;
179
+ project_id: string;
180
+ state: string;
181
+ }
182
+ export interface SessionDetail {
183
+ id: string;
184
+ name: string;
185
+ status: SessionStatus;
186
+ uptime: number | null;
187
+ url?: string;
188
+ doc: string;
189
+ createdAt: string;
190
+ access: 'private' | 'public';
191
+ projectId: string | null;
192
+ backupResource: string | null;
193
+ }
194
+ export interface UpdateSessionInput {
195
+ name?: string;
196
+ access?: 'private' | 'public';
197
+ }
198
+ export interface TableColumn {
199
+ name: string;
200
+ type: string;
201
+ description?: string;
202
+ isPrimaryKey: boolean;
203
+ }
204
+ export interface RunLogEntry {
205
+ id: number;
206
+ created_at: string;
207
+ log_type: string;
208
+ duration: number;
209
+ function_name?: string;
210
+ error_msg: string;
211
+ log_object: object;
212
+ output?: string | Record<string, unknown>;
213
+ input?: unknown[];
214
+ stack?: unknown[];
215
+ value_store?: Record<string, unknown>;
216
+ }
217
+ export interface SinkTable {
218
+ guid: string;
219
+ name: string;
220
+ columns: TableColumn[];
221
+ content: Record<string, unknown>[];
222
+ }
223
+ export interface SinkData {
224
+ tables: SinkTable[];
225
+ logs: RunLogEntry[];
226
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for Xano Run API
3
+ * Based on @xano/run-sdk types
4
+ */
5
+ export {};