carto-cli 0.1.0-rc.1
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.
- package/.nvmrc +1 -0
- package/ARCHITECTURE.md +497 -0
- package/CHANGELOG.md +28 -0
- package/LICENSE +15 -0
- package/MAP_JSON.md +516 -0
- package/README.md +1595 -0
- package/WORKFLOW_JSON.md +623 -0
- package/dist/api.js +489 -0
- package/dist/auth-oauth.js +485 -0
- package/dist/auth-server.js +432 -0
- package/dist/browser.js +30 -0
- package/dist/colors.js +45 -0
- package/dist/commands/activity.js +427 -0
- package/dist/commands/admin.js +177 -0
- package/dist/commands/ai.js +489 -0
- package/dist/commands/auth.js +652 -0
- package/dist/commands/connections.js +412 -0
- package/dist/commands/credentials.js +606 -0
- package/dist/commands/imports.js +234 -0
- package/dist/commands/maps.js +1022 -0
- package/dist/commands/org.js +195 -0
- package/dist/commands/sql.js +326 -0
- package/dist/commands/users.js +459 -0
- package/dist/commands/workflows.js +1025 -0
- package/dist/config.js +320 -0
- package/dist/download.js +108 -0
- package/dist/help.js +285 -0
- package/dist/http.js +139 -0
- package/dist/index.js +1133 -0
- package/dist/logo.js +11 -0
- package/dist/prompt.js +67 -0
- package/dist/schedule-parser.js +287 -0
- package/jest.config.ts +43 -0
- package/package.json +53 -0
package/dist/help.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showHelp = showHelp;
|
|
4
|
+
const colors_1 = require("./colors");
|
|
5
|
+
// Import package version
|
|
6
|
+
const packageJson = require('../package.json');
|
|
7
|
+
function showHelp() {
|
|
8
|
+
console.log((0, colors_1.bold)('CARTO CLI') + ` v${packageJson.version} - Geospatial Cloud Native Platform Admin Tool\n`);
|
|
9
|
+
console.log('Usage: ' + (0, colors_1.bold)('carto') + ' [options] <command> [subcommand] [args]\n');
|
|
10
|
+
console.log((0, colors_1.bold)('Authentication:'));
|
|
11
|
+
console.log(' auth login [profile] Interactive browser-based login');
|
|
12
|
+
console.log(' --env <env> Auth environment: production|staging|local|dedicated-NN');
|
|
13
|
+
console.log(' (only configure if instructed by support)');
|
|
14
|
+
console.log(' Suggests profile name: tenant/org/user@email.com');
|
|
15
|
+
console.log(' --organization-name <name> Login with SSO to specific organization (required for SSO)');
|
|
16
|
+
console.log(' Use quotes for spaces: --organization-name "My Org"');
|
|
17
|
+
console.log(' auth login --m2m M2M OAuth login for CI/CD (non-interactive)');
|
|
18
|
+
console.log(' Reuses existing valid token if available');
|
|
19
|
+
console.log(' --client-id <id> M2M client ID (or set CARTO_M2M_CLIENT_ID)');
|
|
20
|
+
console.log(' --client-secret <secret> M2M client secret (or set CARTO_M2M_CLIENT_SECRET)');
|
|
21
|
+
console.log(' --api-base-url <url> API base URL (default: https://gcp-us-east1.api.carto.com)');
|
|
22
|
+
console.log(' --force, -f Force new token (ignore existing valid token)');
|
|
23
|
+
console.log(' auth logout [profile] Remove stored credentials');
|
|
24
|
+
console.log(' auth status [profile] Show authentication status, tenant, org, user, and available profiles');
|
|
25
|
+
console.log(' auth use <profile> Switch default profile');
|
|
26
|
+
console.log(' auth whoami Show current user info\n');
|
|
27
|
+
console.log((0, colors_1.bold)('Credentials:'));
|
|
28
|
+
console.log(' credentials list [type] List all credentials (tokens, spa, m2m, oauth)');
|
|
29
|
+
console.log(' credentials create token Create API Access Token');
|
|
30
|
+
console.log(' --connection <name> Connection name');
|
|
31
|
+
console.log(' --source <table> Table/tileset/query source');
|
|
32
|
+
console.log(' --apis <list> Allowed APIs (comma-separated: sql,maps,imports,lds)');
|
|
33
|
+
console.log(' --referer <url> Allowed referer URL');
|
|
34
|
+
console.log(' credentials create spa Create SPA OAuth Client');
|
|
35
|
+
console.log(' --title <name> Application title');
|
|
36
|
+
console.log(' --login-uri <url> Login initiation URI');
|
|
37
|
+
console.log(' --callback <url> Callback URL');
|
|
38
|
+
console.log(' --logout-url <url> Logout URL');
|
|
39
|
+
console.log(' --web-origin <url> Web origin');
|
|
40
|
+
console.log(' --allowed-origin <url> Allowed origin');
|
|
41
|
+
console.log(' credentials create m2m Create M2M OAuth Client');
|
|
42
|
+
console.log(' --title <name> Application title');
|
|
43
|
+
console.log(' credentials get <type> <id> Get credential details (type: token, spa, m2m, oauth)');
|
|
44
|
+
console.log(' credentials update <type> <id> Update credential (type: token, spa, m2m, oauth)');
|
|
45
|
+
console.log(' credentials delete <type> <id> Delete credential (type: token, spa, m2m, oauth)');
|
|
46
|
+
console.log(' credentials revoke <type> <id> Revoke credential (alias for delete)\n');
|
|
47
|
+
console.log((0, colors_1.bold)('Maps:'));
|
|
48
|
+
console.log(' maps list [--all] List your maps (--all fetches all pages)');
|
|
49
|
+
console.log(' --page <n> Page number (default: 1)');
|
|
50
|
+
console.log(' --page-size <n> Items per page (default: 10)');
|
|
51
|
+
console.log(' --search <query> Search maps by text');
|
|
52
|
+
console.log(' --privacy <level> Filter by privacy level');
|
|
53
|
+
console.log(' --mine Show only your maps');
|
|
54
|
+
console.log(' maps get <id> Get detailed map information including datasets and connections');
|
|
55
|
+
console.log(' maps update <id> [json] Update an existing map with JSON config');
|
|
56
|
+
console.log(' --file <path> Read JSON from file (or pipe via stdin)');
|
|
57
|
+
console.log(' maps delete <id> Delete a map');
|
|
58
|
+
console.log(' maps clone <id> Clone a map within the same organization');
|
|
59
|
+
console.log(' --title <title> Override cloned map title (optional)');
|
|
60
|
+
console.log(' maps copy <id> Copy map between profiles (organizations)');
|
|
61
|
+
console.log(' --dest-profile <name> Destination profile (required)');
|
|
62
|
+
console.log(' --source-profile <name> Source profile (default: current profile)');
|
|
63
|
+
console.log(' --connection <name> Legacy: single connection for all datasets');
|
|
64
|
+
console.log(' --connection-mapping <m> Map connections: "source1=dest1,source2=dest2"');
|
|
65
|
+
console.log(' --skip-source-validation Skip validating table/query accessibility');
|
|
66
|
+
console.log(' --title <title> Override map title');
|
|
67
|
+
console.log(' --keep-privacy Preserve privacy setting (default: true)');
|
|
68
|
+
console.log('');
|
|
69
|
+
console.log(' ' + (0, colors_1.dim)('Connection resolution (in priority order):'));
|
|
70
|
+
console.log(' ' + (0, colors_1.dim)(' 1. Manual mapping (--connection-mapping)'));
|
|
71
|
+
console.log(' ' + (0, colors_1.dim)(' 2. Auto-map by name (default behavior)'));
|
|
72
|
+
console.log(' ' + (0, colors_1.dim)(' 3. Legacy single connection (--connection)'));
|
|
73
|
+
console.log(' ' + (0, colors_1.dim)(' After connection mapping, validates dataset sources are accessible'));
|
|
74
|
+
console.log(' ' + (0, colors_1.dim)(' Use --skip-source-validation to bypass (creates broken map)\n'));
|
|
75
|
+
console.log((0, colors_1.bold)('Workflows:'));
|
|
76
|
+
console.log(' workflows list [options] List your workflows');
|
|
77
|
+
console.log(' --orderBy <field> Order by field');
|
|
78
|
+
console.log(' --orderDirection <dir> Order direction (ASC/DESC)');
|
|
79
|
+
console.log(' --pageSize <number> Items per page');
|
|
80
|
+
console.log(' --page <number> Page number');
|
|
81
|
+
console.log(' --search <term> Search term');
|
|
82
|
+
console.log(' --privacy <level> Privacy level');
|
|
83
|
+
console.log(' --tags <json-array> Filter by tags');
|
|
84
|
+
console.log(' workflows get <id> [options] Get workflow details');
|
|
85
|
+
console.log(' --client <name> Client identifier');
|
|
86
|
+
console.log(' workflows update <id> [json] Update workflow configuration');
|
|
87
|
+
console.log(' --file <path> Read JSON from file (or pipe via stdin)');
|
|
88
|
+
console.log(' workflows delete <id> Delete a workflow');
|
|
89
|
+
console.log(' workflows copy <id> Copy workflow between profiles');
|
|
90
|
+
console.log(' --source-profile <profile> Source profile (default: current profile)');
|
|
91
|
+
console.log(' --dest-profile <profile> Destination profile (required)');
|
|
92
|
+
console.log(' --connection <name> Destination connection name (optional, auto-maps by name)');
|
|
93
|
+
console.log(' --title <title> Override workflow title (optional)');
|
|
94
|
+
console.log(' --skip-source-validation Skip validating source table accessibility');
|
|
95
|
+
console.log(' workflows schedule add <id> Add schedule to workflow');
|
|
96
|
+
console.log(' --expression <expr> Schedule expression (required)');
|
|
97
|
+
console.log(' --connection <name> Connection name (optional, derived from workflow)');
|
|
98
|
+
console.log(' workflows schedule update <id> Update workflow schedule');
|
|
99
|
+
console.log(' --expression <expr> New schedule expression (required)');
|
|
100
|
+
console.log(' --connection <name> Connection name (optional)');
|
|
101
|
+
console.log(' workflows schedule remove <id> Remove workflow schedule');
|
|
102
|
+
console.log(' --connection <name> Connection name (optional)');
|
|
103
|
+
console.log('');
|
|
104
|
+
console.log(' ' + (0, colors_1.dim)('Schedule Expression Formats:'));
|
|
105
|
+
console.log(' ' + (0, colors_1.dim)(' BigQuery/CARTO DW: "every day 08:00", "every monday 09:00", "every 2 hours"'));
|
|
106
|
+
console.log(' ' + (0, colors_1.dim)(' Snowflake/PostgreSQL: "0 8 * * *", "0 9 * * 1", "0 */2 * * *" (cron)'));
|
|
107
|
+
console.log(' ' + (0, colors_1.dim)(' Databricks: "0 0 8 * * ?", "0 0 9 ? * MON" (quartz cron)\n'));
|
|
108
|
+
console.log((0, colors_1.bold)('Connections:'));
|
|
109
|
+
console.log(' connections list [--all] List your connections (--all fetches all pages)');
|
|
110
|
+
console.log(' --page <n> Page number (default: 1)');
|
|
111
|
+
console.log(' --page-size <n> Items per page (default: 10)');
|
|
112
|
+
console.log(' --search <query> Search connections by text');
|
|
113
|
+
console.log(' connections get <id> Get connection details');
|
|
114
|
+
console.log(' connections browse <name> [path] Browse connection resources (projects/datasets/tables)');
|
|
115
|
+
console.log(' --page <n> Page number (default: 1)');
|
|
116
|
+
console.log(' --page-size <n> Items per page (default: 30)');
|
|
117
|
+
console.log(' connections describe <name> <table-path> Get table schema and details');
|
|
118
|
+
console.log(' connections create Create a new connection');
|
|
119
|
+
console.log(' connections update <id> Update connection');
|
|
120
|
+
console.log(' connections delete <id> Delete connection\n');
|
|
121
|
+
console.log((0, colors_1.bold)('Imports:'));
|
|
122
|
+
console.log(' imports create Import geospatial file (waits for completion)');
|
|
123
|
+
console.log(' --file <path> Local file to upload');
|
|
124
|
+
console.log(' --url <url> Remote file URL to import');
|
|
125
|
+
console.log(' --connection <name> Connection name (required)');
|
|
126
|
+
console.log(' --destination <fqn> Target table name (required)');
|
|
127
|
+
console.log(' --overwrite Overwrite existing table');
|
|
128
|
+
console.log(' --no-autoguessing Disable column type detection');
|
|
129
|
+
console.log(' --async Return immediately (don\'t wait)');
|
|
130
|
+
console.log(' ');
|
|
131
|
+
console.log(' Supported formats: CSV, GeoJSON, GeoPackage, GeoParquet, KML, KMZ, Shapefile (zip)');
|
|
132
|
+
console.log(' Size limit: 1GB per file\n');
|
|
133
|
+
console.log((0, colors_1.bold)('SQL:'));
|
|
134
|
+
console.log(' sql query <conn> [sql] Run SQL query and return results');
|
|
135
|
+
console.log(' --cache Use GET with caching (cached 1yr, 1min timeout)');
|
|
136
|
+
console.log(' --file <path> Read SQL from file');
|
|
137
|
+
console.log(' Default: POST (no cache, no URL limit, 1min timeout)');
|
|
138
|
+
console.log(' sql job <conn> [sql] Run SQL job (DDL/DML, no results returned)');
|
|
139
|
+
console.log(' --file <path> Read SQL from file');
|
|
140
|
+
console.log(' Polls until complete, no timeout');
|
|
141
|
+
console.log(' SQL can be passed as arg, stdin, or --file\n');
|
|
142
|
+
console.log((0, colors_1.bold)('Organization:'));
|
|
143
|
+
console.log(' org stats View organization statistics and quotas');
|
|
144
|
+
console.log(' Shows users, resources, quotas, and AI limits');
|
|
145
|
+
console.log(' (displays available data based on your permissions)\n');
|
|
146
|
+
console.log((0, colors_1.bold)('Users:'));
|
|
147
|
+
console.log(' users list [--all] List all users in the organization');
|
|
148
|
+
console.log(' --page <n> Page number (default: 1)');
|
|
149
|
+
console.log(' --page-size <n> Items per page (default: 100)');
|
|
150
|
+
console.log(' --role <role> Filter by role (Builder, Viewer, Guest)');
|
|
151
|
+
console.log(' --search <query> Search users by name or email');
|
|
152
|
+
console.log(' users get <user-id|email> Get detailed user information');
|
|
153
|
+
console.log(' Accepts user ID or email address');
|
|
154
|
+
console.log(' users invite <email> Invite new users to the organization');
|
|
155
|
+
console.log(' --role <role> Role to assign (Builder/Viewer/Guest, default: Viewer)');
|
|
156
|
+
console.log(' Multiple emails: comma-separated or multiple arguments');
|
|
157
|
+
console.log(' users invitations List pending invitations');
|
|
158
|
+
console.log(' users resend-invitation <token> Resend a pending invitation');
|
|
159
|
+
console.log(' users cancel-invitation <token> Cancel a pending invitation');
|
|
160
|
+
console.log(' users delete <user-id|email> <receiver-id|email>');
|
|
161
|
+
console.log(' Delete user and transfer resources');
|
|
162
|
+
console.log(' Accepts user IDs or email addresses\n');
|
|
163
|
+
console.log((0, colors_1.bold)('Activity Data:'));
|
|
164
|
+
console.log(' activity export Export activity data logs (Enterprise Large+)');
|
|
165
|
+
console.log(' --start-date <date> Start date (required, ISO format: 2025-10-01)');
|
|
166
|
+
console.log(' --end-date <date> End date (required, ISO format: 2025-10-07)');
|
|
167
|
+
console.log(' --format <csv|parquet> Export format (default: csv)');
|
|
168
|
+
console.log(' --category <name> Category: activity|apiUsage|userList|groupList (default: all)');
|
|
169
|
+
console.log(' --output-dir <path> Output directory (default: ./activity-data)');
|
|
170
|
+
console.log(' Automatically waits for export and downloads files');
|
|
171
|
+
console.log('');
|
|
172
|
+
console.log(' activity query Query activity data with DuckDB SQL (Enterprise Large+)');
|
|
173
|
+
console.log(' --start-date <date> Start date (required, ISO format: 2025-10-01)');
|
|
174
|
+
console.log(' --end-date <date> End date (required, ISO format: 2025-10-07)');
|
|
175
|
+
console.log(' --sql <query> DuckDB SQL query (required)');
|
|
176
|
+
console.log(' --no-cache Force fresh download, ignore cache');
|
|
177
|
+
console.log(' Auto-downloads if needed, caches in /tmp for reuse');
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log(' ' + (0, colors_1.dim)('Available tables: activity, apiUsage, userList, groupList'));
|
|
180
|
+
console.log(' ' + (0, colors_1.dim)('SQL: DuckDB syntax - json_extract_string(data, \'$.field\')'));
|
|
181
|
+
console.log(' ' + (0, colors_1.dim)('Schema: https://docs.carto.com/carto-user-manual/settings/activity-data\n'));
|
|
182
|
+
console.log((0, colors_1.bold)('AI Features:'));
|
|
183
|
+
console.log(' aifeature aiagent <map-id> [msg] Chat with map AI agent');
|
|
184
|
+
console.log(' --conversation-id <id> Continue existing conversation');
|
|
185
|
+
console.log(' --file <path> Read message from file');
|
|
186
|
+
console.log(' Interactive mode if no message provided\n');
|
|
187
|
+
console.log((0, colors_1.bold)('AI Proxy:'));
|
|
188
|
+
console.log(' aiproxy info Show LiteLLM proxy connection details');
|
|
189
|
+
console.log(' aiproxy models List available LLM models');
|
|
190
|
+
console.log(' aiproxy chat [msg] Direct OpenAI-compatible chat');
|
|
191
|
+
console.log(' --model <name> Model to use (required, see: aiproxy models)');
|
|
192
|
+
console.log(' --system <text> System prompt');
|
|
193
|
+
console.log(' --temperature <n> Temperature 0-2 (default: 1)');
|
|
194
|
+
console.log(' --max-tokens <n> Max response tokens');
|
|
195
|
+
console.log(' --top-p <n> Top-p sampling (default: 1)');
|
|
196
|
+
console.log(' --file <path> Read message from file\n');
|
|
197
|
+
console.log((0, colors_1.bold)('Admin (Superadmin):'));
|
|
198
|
+
console.log(' admin list <type> [--all] List all resources (maps/workflows/connections)');
|
|
199
|
+
console.log(' --page <n> Page number (default: 1)');
|
|
200
|
+
console.log(' --page-size <n> Items per page (default: 10)');
|
|
201
|
+
console.log(' --search <query> Search resources by text');
|
|
202
|
+
console.log(' admin batch-delete Batch delete resources');
|
|
203
|
+
console.log(' admin transfer Transfer resources between users\n');
|
|
204
|
+
console.log((0, colors_1.bold)('Global Options:'));
|
|
205
|
+
console.log(' --json Output in JSON format');
|
|
206
|
+
console.log(' --debug Show request details (method, URL, headers)');
|
|
207
|
+
console.log(' --yes, -y Skip confirmation prompts (for automation/scripts)');
|
|
208
|
+
console.log(' --token <token> Override API token');
|
|
209
|
+
console.log(' --base-url <url> Override base API URL');
|
|
210
|
+
console.log(' --profile <name> Use specific profile (default: "default")');
|
|
211
|
+
console.log(' --version, -v Show version');
|
|
212
|
+
console.log(' --help, -h Show help');
|
|
213
|
+
console.log('');
|
|
214
|
+
console.log(' ' + (0, colors_1.dim)('Note: Deletion commands (delete, batch-delete) require typing "delete" to confirm.'));
|
|
215
|
+
console.log(' ' + (0, colors_1.dim)(' Use --yes or --json flags to skip confirmation (for automation).\n'));
|
|
216
|
+
console.log((0, colors_1.bold)('Environment Variables:'));
|
|
217
|
+
console.log(' CARTO_API_TOKEN API token for authentication');
|
|
218
|
+
console.log(' CARTO_PROFILE Profile to use (overrides current_profile)');
|
|
219
|
+
console.log(' CARTO_AUTH_ENV Auth environment (only set if instructed by support)');
|
|
220
|
+
console.log(' CARTO_AUTH_PORT Callback server port for login (default: 3003)');
|
|
221
|
+
console.log(' CARTO_M2M_CLIENT_ID M2M OAuth client ID (for --m2m login)');
|
|
222
|
+
console.log(' CARTO_M2M_CLIENT_SECRET M2M OAuth client secret (for --m2m login)');
|
|
223
|
+
console.log(' CARTO_API_BASE_URL API base URL for M2M (default: gcp-us-east1.api.carto.com)\n');
|
|
224
|
+
console.log((0, colors_1.bold)('Examples:'));
|
|
225
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth login'));
|
|
226
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth login production'));
|
|
227
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth login --organization-name "cartodb" # SSO login'));
|
|
228
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth login --m2m --client-id <id> --client-secret <secret> # CI/CD'));
|
|
229
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth status'));
|
|
230
|
+
console.log(' $ ' + (0, colors_1.dim)('carto auth use production'));
|
|
231
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps list --json'));
|
|
232
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps list --all --search "sales"'));
|
|
233
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps list --mine'));
|
|
234
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps list --page 2 --page-size 20'));
|
|
235
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps list --profile production'));
|
|
236
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps get 69b0e7cc-026a-4feb-87bb-a82cc6ac5189'));
|
|
237
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps update <id> \'{"title":"Updated Title"}\''));
|
|
238
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps copy map123 --dest-profile prod # Auto-map connections by name'));
|
|
239
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps copy map123 --dest-profile prod --connection-mapping "dev-bq=prod-bq"'));
|
|
240
|
+
console.log(' $ ' + (0, colors_1.dim)('carto connections list'));
|
|
241
|
+
console.log(' $ ' + (0, colors_1.dim)('carto connections browse carto_dw'));
|
|
242
|
+
console.log(' $ ' + (0, colors_1.dim)('carto connections browse carto_dw "carto-demo-data"'));
|
|
243
|
+
console.log(' $ ' + (0, colors_1.dim)('carto connections describe carto_dw "carto-demo-data.demo_tables.nyc_collisions"'));
|
|
244
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows update <id> \'{"config":{...}}\''));
|
|
245
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps delete map123 # Interactive: prompts for confirmation'));
|
|
246
|
+
console.log(' $ ' + (0, colors_1.dim)('carto maps delete map123 --yes # Automated: skips confirmation'));
|
|
247
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows delete workflow123'));
|
|
248
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows copy workflow123 --dest-profile prod # Auto-map connection by name'));
|
|
249
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows copy workflow123 --dest-profile prod --connection prod-bigquery'));
|
|
250
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows schedule add 04f513c1-4157-4211-b067-36531d167a40 --expression "every day 08:00"'));
|
|
251
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows schedule add workflow123 --expression "0 9 * * 1"'));
|
|
252
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows schedule update workflow123 --expression "every 2 hours"'));
|
|
253
|
+
console.log(' $ ' + (0, colors_1.dim)('carto workflows schedule remove workflow123'));
|
|
254
|
+
console.log(' $ ' + (0, colors_1.dim)('carto imports create --file ./data.csv --connection carto_dw --destination project.dataset.table'));
|
|
255
|
+
console.log(' $ ' + (0, colors_1.dim)('carto imports create --url https://example.com/data.geojson --connection bigquery --destination my.table'));
|
|
256
|
+
console.log(' $ ' + (0, colors_1.dim)('carto sql query carto_dw "SELECT * FROM dataset.table LIMIT 10"'));
|
|
257
|
+
console.log(' $ ' + (0, colors_1.dim)('carto sql query carto_dw "SELECT * FROM dataset.table" --cache'));
|
|
258
|
+
console.log(' $ ' + (0, colors_1.dim)('carto sql query carto_dw --file query.sql'));
|
|
259
|
+
console.log(' $ ' + (0, colors_1.dim)('echo "SELECT COUNT(*) FROM dataset.table" | carto sql query carto_dw'));
|
|
260
|
+
console.log(' $ ' + (0, colors_1.dim)('carto sql job carto_dw "CREATE TABLE dataset.newtable AS SELECT..."'));
|
|
261
|
+
console.log(' $ ' + (0, colors_1.dim)('carto org stats'));
|
|
262
|
+
console.log(' $ ' + (0, colors_1.dim)('carto org stats --json'));
|
|
263
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users list'));
|
|
264
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users list --role Builder --all'));
|
|
265
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users get google-oauth2|123456789'));
|
|
266
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users get jatorre@carto.com'));
|
|
267
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users invite user@example.com --role Builder'));
|
|
268
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users invite user1@example.com,user2@example.com --role Viewer'));
|
|
269
|
+
console.log(' $ ' + (0, colors_1.dim)('carto users invitations'));
|
|
270
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials list'));
|
|
271
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials list tokens'));
|
|
272
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials create token --connection carto_dw --source "demo_tables.*" --apis sql,maps'));
|
|
273
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials create spa --title "My Web App" --callback "https://app.com/callback"'));
|
|
274
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials create m2m --title "Backend Service"'));
|
|
275
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials get token eyJhbGc...'));
|
|
276
|
+
console.log(' $ ' + (0, colors_1.dim)('carto credentials delete spa lI8HFi7xecGjABEdd468zKy9v08ncFBC'));
|
|
277
|
+
console.log(' $ ' + (0, colors_1.dim)('carto activity export --start-date 2025-10-01 --end-date 2025-10-07'));
|
|
278
|
+
console.log(' $ ' + (0, colors_1.dim)('carto activity query --start-date 2025-10-01 --end-date 2025-10-07 --sql "SELECT COUNT(*) FROM activity"'));
|
|
279
|
+
console.log(' $ ' + (0, colors_1.dim)('carto aifeature aiagent <map-id> "What are the traffic patterns?"'));
|
|
280
|
+
console.log(' $ ' + (0, colors_1.dim)('echo "Analyze data" | carto aifeature aiagent <map-id>'));
|
|
281
|
+
console.log(' $ ' + (0, colors_1.dim)('carto aiproxy info'));
|
|
282
|
+
console.log(' $ ' + (0, colors_1.dim)('carto aiproxy models'));
|
|
283
|
+
console.log(' $ ' + (0, colors_1.dim)('carto aiproxy chat "Explain quantum physics" --model carto::gemini-2.5-flash'));
|
|
284
|
+
console.log(' $ ' + (0, colors_1.dim)('carto admin list maps --all\n'));
|
|
285
|
+
}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.request = request;
|
|
7
|
+
exports.streamRequest = streamRequest;
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const http_1 = __importDefault(require("http"));
|
|
10
|
+
const url_1 = require("url");
|
|
11
|
+
function request(url, options) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const parsedUrl = new url_1.URL(url);
|
|
14
|
+
const isHttps = parsedUrl.protocol === 'https:';
|
|
15
|
+
const lib = isHttps ? https_1.default : http_1.default;
|
|
16
|
+
const requestOptions = {
|
|
17
|
+
hostname: parsedUrl.hostname,
|
|
18
|
+
port: parsedUrl.port,
|
|
19
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
20
|
+
method: options.method,
|
|
21
|
+
headers: options.headers || {},
|
|
22
|
+
};
|
|
23
|
+
const req = lib.request(requestOptions, (res) => {
|
|
24
|
+
let data = '';
|
|
25
|
+
res.on('data', (chunk) => {
|
|
26
|
+
data += chunk;
|
|
27
|
+
});
|
|
28
|
+
res.on('end', () => {
|
|
29
|
+
resolve({
|
|
30
|
+
statusCode: res.statusCode || 0,
|
|
31
|
+
headers: res.headers,
|
|
32
|
+
body: data,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
req.on('error', (error) => {
|
|
37
|
+
reject(error);
|
|
38
|
+
});
|
|
39
|
+
if (options.body) {
|
|
40
|
+
if (Buffer.isBuffer(options.body)) {
|
|
41
|
+
// Handle binary data (file uploads)
|
|
42
|
+
req.write(options.body);
|
|
43
|
+
}
|
|
44
|
+
else if (typeof options.body === 'string') {
|
|
45
|
+
req.write(options.body);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Handle JSON objects
|
|
49
|
+
req.write(JSON.stringify(options.body));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
req.end();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Streaming request for NDJSON (newline-delimited JSON) responses
|
|
57
|
+
* Used for AI Features API streaming responses
|
|
58
|
+
*/
|
|
59
|
+
function streamRequest(url, options, onChunk) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const parsedUrl = new url_1.URL(url);
|
|
62
|
+
const isHttps = parsedUrl.protocol === 'https:';
|
|
63
|
+
const lib = isHttps ? https_1.default : http_1.default;
|
|
64
|
+
const requestOptions = {
|
|
65
|
+
hostname: parsedUrl.hostname,
|
|
66
|
+
port: parsedUrl.port,
|
|
67
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
68
|
+
method: options.method,
|
|
69
|
+
headers: options.headers || {},
|
|
70
|
+
};
|
|
71
|
+
const req = lib.request(requestOptions, (res) => {
|
|
72
|
+
if (res.statusCode && res.statusCode >= 400) {
|
|
73
|
+
let errorData = '';
|
|
74
|
+
res.on('data', (chunk) => {
|
|
75
|
+
errorData += chunk;
|
|
76
|
+
});
|
|
77
|
+
res.on('end', () => {
|
|
78
|
+
reject(new Error(`HTTP ${res.statusCode}: ${errorData}`));
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let buffer = '';
|
|
83
|
+
res.on('data', async (chunk) => {
|
|
84
|
+
buffer += chunk.toString();
|
|
85
|
+
// Process complete lines (NDJSON format)
|
|
86
|
+
const lines = buffer.split('\n');
|
|
87
|
+
// Keep the last incomplete line in the buffer
|
|
88
|
+
buffer = lines.pop() || '';
|
|
89
|
+
// Process each complete line
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
const trimmed = line.trim();
|
|
92
|
+
if (trimmed) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(trimmed);
|
|
95
|
+
await onChunk(parsed);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
// Skip invalid JSON lines (e.g., keep-alive messages)
|
|
99
|
+
if (trimmed !== '{}') {
|
|
100
|
+
console.error('Failed to parse JSON line:', trimmed);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
res.on('end', async () => {
|
|
107
|
+
// Process any remaining data in buffer
|
|
108
|
+
if (buffer.trim()) {
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(buffer.trim());
|
|
111
|
+
await onChunk(parsed);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
// Ignore parsing error for final buffer
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
resolve();
|
|
118
|
+
});
|
|
119
|
+
res.on('error', (error) => {
|
|
120
|
+
reject(error);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
req.on('error', (error) => {
|
|
124
|
+
reject(error);
|
|
125
|
+
});
|
|
126
|
+
if (options.body) {
|
|
127
|
+
if (Buffer.isBuffer(options.body)) {
|
|
128
|
+
req.write(options.body);
|
|
129
|
+
}
|
|
130
|
+
else if (typeof options.body === 'string') {
|
|
131
|
+
req.write(options.body);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
req.write(JSON.stringify(options.body));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
req.end();
|
|
138
|
+
});
|
|
139
|
+
}
|