@zapier/zapier-sdk-cli 0.13.3 → 0.13.5
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/CHANGELOG.md +15 -0
- package/dist/cli.cjs +113 -14
- package/dist/cli.mjs +114 -15
- package/dist/index.cjs +110 -10
- package/dist/index.d.mts +91 -2
- package/dist/index.d.ts +91 -2
- package/dist/index.mjs +111 -12
- package/dist/package.json +2 -2
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +1 -0
- package/dist/src/plugins/login/index.d.ts +8 -1
- package/dist/src/plugins/login/index.js +55 -9
- package/dist/src/sdk.d.ts +8 -0
- package/dist/src/sdk.js +1 -0
- package/dist/src/telemetry/builders.d.ts +42 -0
- package/dist/src/telemetry/builders.js +56 -0
- package/dist/src/telemetry/events.d.ts +37 -0
- package/dist/src/telemetry/events.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/index.ts +8 -0
- package/src/plugins/login/index.ts +69 -9
- package/src/sdk.ts +9 -0
- package/src/telemetry/builders.ts +114 -0
- package/src/telemetry/events.ts +39 -0
- package/src/utils/cli-generator.test.ts +102 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.13.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7184f27: Move typescript package from devDependencies to dependencies since it is needed at runtime for the CLI's add command.
|
|
8
|
+
|
|
9
|
+
## 0.13.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 80732ea: Add basic event-driven telemetry for key lifecycle events and CLI logins
|
|
14
|
+
- Updated dependencies [80732ea]
|
|
15
|
+
- @zapier/zapier-sdk@0.13.4
|
|
16
|
+
- @zapier/zapier-sdk-mcp@0.3.17
|
|
17
|
+
|
|
3
18
|
## 0.13.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1405,7 +1405,66 @@ var LoginSchema = zod.z.object({
|
|
|
1405
1405
|
timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)")
|
|
1406
1406
|
}).describe("Log in to Zapier to access your account");
|
|
1407
1407
|
|
|
1408
|
+
// package.json
|
|
1409
|
+
var package_default = {
|
|
1410
|
+
version: "0.13.5"};
|
|
1411
|
+
|
|
1412
|
+
// src/telemetry/builders.ts
|
|
1413
|
+
function createCliBaseEvent(context = {}) {
|
|
1414
|
+
return {
|
|
1415
|
+
event_id: zapierSdk.generateEventId(),
|
|
1416
|
+
timestamp_ms: zapierSdk.getCurrentTimestamp(),
|
|
1417
|
+
release_id: zapierSdk.getReleaseId(),
|
|
1418
|
+
customuser_id: context.customuser_id ?? null,
|
|
1419
|
+
account_id: context.account_id ?? null,
|
|
1420
|
+
identity_id: context.identity_id ?? null,
|
|
1421
|
+
visitor_id: context.visitor_id ?? null,
|
|
1422
|
+
correlation_id: context.correlation_id ?? null
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
function buildCliCommandExecutedEvent({
|
|
1426
|
+
data,
|
|
1427
|
+
context = {},
|
|
1428
|
+
cliVersion = package_default.version
|
|
1429
|
+
}) {
|
|
1430
|
+
const osInfo = zapierSdk.getOsInfo();
|
|
1431
|
+
const platformVersions = zapierSdk.getPlatformVersions();
|
|
1432
|
+
return {
|
|
1433
|
+
...createCliBaseEvent(context),
|
|
1434
|
+
system_name: "zapier-sdk-cli",
|
|
1435
|
+
session_id: context.session_id ?? null,
|
|
1436
|
+
cli_version: data.cli_version ?? cliVersion,
|
|
1437
|
+
cli_arguments: data.cli_arguments ?? null,
|
|
1438
|
+
cli_primary_command: data.cli_primary_command,
|
|
1439
|
+
os_platform: osInfo.platform,
|
|
1440
|
+
os_release: osInfo.release,
|
|
1441
|
+
os_architecture: osInfo.architecture,
|
|
1442
|
+
platform_versions: platformVersions,
|
|
1443
|
+
selected_api: context.selected_api ?? null,
|
|
1444
|
+
app_id: context.app_id ?? null,
|
|
1445
|
+
app_version_id: context.app_version_id ?? null,
|
|
1446
|
+
execution_duration_ms: data.execution_duration_ms ?? null,
|
|
1447
|
+
success_flag: data.success_flag,
|
|
1448
|
+
exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
|
|
1449
|
+
error_message: data.error_message ?? null,
|
|
1450
|
+
command_category: data.command_category ?? null,
|
|
1451
|
+
requires_auth: data.requires_auth ?? null,
|
|
1452
|
+
is_ci_environment: zapierSdk.isCi(),
|
|
1453
|
+
ci_platform: zapierSdk.getCiPlatform(),
|
|
1454
|
+
package_manager: data.package_manager ?? "pnpm",
|
|
1455
|
+
// Default based on project setup
|
|
1456
|
+
made_network_requests: data.made_network_requests ?? null,
|
|
1457
|
+
files_modified_count: data.files_modified_count ?? null,
|
|
1458
|
+
files_created_count: data.files_created_count ?? null,
|
|
1459
|
+
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
1460
|
+
peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
|
|
1461
|
+
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
1462
|
+
subprocess_count: data.subprocess_count ?? null
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1408
1466
|
// src/plugins/login/index.ts
|
|
1467
|
+
var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
|
|
1409
1468
|
var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options) {
|
|
1410
1469
|
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
1411
1470
|
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
@@ -1416,17 +1475,56 @@ var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options
|
|
|
1416
1475
|
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1417
1476
|
setTimeout(() => process.exit(0), 100);
|
|
1418
1477
|
}, LoginSchema);
|
|
1419
|
-
var loginPlugin = () =>
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1478
|
+
var loginPlugin = ({ context }) => {
|
|
1479
|
+
const loginWithTelemetry = async (options) => {
|
|
1480
|
+
const startTime = Date.now();
|
|
1481
|
+
let success = false;
|
|
1482
|
+
let errorMessage = null;
|
|
1483
|
+
try {
|
|
1484
|
+
await loginWithSdk(options);
|
|
1485
|
+
success = true;
|
|
1486
|
+
} catch (error) {
|
|
1487
|
+
success = false;
|
|
1488
|
+
errorMessage = error instanceof Error ? error.message : "Login failed";
|
|
1489
|
+
throw error;
|
|
1490
|
+
} finally {
|
|
1491
|
+
const event = buildCliCommandExecutedEvent({
|
|
1492
|
+
data: {
|
|
1493
|
+
cli_primary_command: "login",
|
|
1494
|
+
success_flag: success,
|
|
1495
|
+
execution_duration_ms: Date.now() - startTime,
|
|
1496
|
+
exit_code: success ? 0 : 1,
|
|
1497
|
+
error_message: errorMessage,
|
|
1498
|
+
command_category: "authentication",
|
|
1499
|
+
requires_auth: false,
|
|
1500
|
+
cli_arguments: [
|
|
1501
|
+
"login",
|
|
1502
|
+
options.timeout ? `--timeout=${options.timeout}` : null
|
|
1503
|
+
].filter(Boolean)
|
|
1504
|
+
},
|
|
1505
|
+
context: {
|
|
1506
|
+
session_id: context.session_id,
|
|
1507
|
+
selected_api: context.selected_api,
|
|
1508
|
+
app_id: context.app_id,
|
|
1509
|
+
app_version_id: context.app_version_id
|
|
1510
|
+
},
|
|
1511
|
+
cliVersion: package_default.version
|
|
1512
|
+
});
|
|
1513
|
+
context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
return {
|
|
1517
|
+
login: loginWithTelemetry,
|
|
1518
|
+
context: {
|
|
1519
|
+
meta: {
|
|
1520
|
+
login: {
|
|
1521
|
+
categories: ["account"],
|
|
1522
|
+
inputSchema: LoginSchema
|
|
1523
|
+
}
|
|
1426
1524
|
}
|
|
1427
1525
|
}
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1526
|
+
};
|
|
1527
|
+
};
|
|
1430
1528
|
var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
|
|
1431
1529
|
|
|
1432
1530
|
// src/plugins/logout/index.ts
|
|
@@ -2281,7 +2379,8 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2281
2379
|
// src/sdk.ts
|
|
2282
2380
|
function createZapierCliSdk(options = {}) {
|
|
2283
2381
|
let sdk2 = zapierSdk.createZapierSdkWithoutRegistry({
|
|
2284
|
-
debug: options.debug
|
|
2382
|
+
debug: options.debug,
|
|
2383
|
+
eventEmission: options.eventEmission
|
|
2285
2384
|
});
|
|
2286
2385
|
sdk2 = sdk2.addPlugin(bundleCodePlugin);
|
|
2287
2386
|
sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
|
|
@@ -2293,13 +2392,13 @@ function createZapierCliSdk(options = {}) {
|
|
|
2293
2392
|
return finalSdk;
|
|
2294
2393
|
}
|
|
2295
2394
|
|
|
2296
|
-
// package.json
|
|
2297
|
-
var
|
|
2298
|
-
version: "0.13.
|
|
2395
|
+
// package.json with { type: 'json' }
|
|
2396
|
+
var package_default2 = {
|
|
2397
|
+
version: "0.13.5"};
|
|
2299
2398
|
|
|
2300
2399
|
// src/cli.ts
|
|
2301
2400
|
var program = new commander.Command();
|
|
2302
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK").version(
|
|
2401
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
|
|
2303
2402
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
2304
2403
|
var sdk = createZapierCliSdk({
|
|
2305
2404
|
debug: isDebugMode
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, toSnakeCase, ZapierError, formatErrorMessage, isPositional } from '@zapier/zapier-sdk';
|
|
4
|
+
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, toSnakeCase, ZapierError, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, isPositional, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import chalk3 from 'chalk';
|
|
7
7
|
import util from 'util';
|
|
@@ -1372,7 +1372,66 @@ var LoginSchema = z.object({
|
|
|
1372
1372
|
timeout: z.string().optional().describe("Login timeout in seconds (default: 300)")
|
|
1373
1373
|
}).describe("Log in to Zapier to access your account");
|
|
1374
1374
|
|
|
1375
|
+
// package.json
|
|
1376
|
+
var package_default = {
|
|
1377
|
+
version: "0.13.5"};
|
|
1378
|
+
|
|
1379
|
+
// src/telemetry/builders.ts
|
|
1380
|
+
function createCliBaseEvent(context = {}) {
|
|
1381
|
+
return {
|
|
1382
|
+
event_id: generateEventId(),
|
|
1383
|
+
timestamp_ms: getCurrentTimestamp(),
|
|
1384
|
+
release_id: getReleaseId(),
|
|
1385
|
+
customuser_id: context.customuser_id ?? null,
|
|
1386
|
+
account_id: context.account_id ?? null,
|
|
1387
|
+
identity_id: context.identity_id ?? null,
|
|
1388
|
+
visitor_id: context.visitor_id ?? null,
|
|
1389
|
+
correlation_id: context.correlation_id ?? null
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
function buildCliCommandExecutedEvent({
|
|
1393
|
+
data,
|
|
1394
|
+
context = {},
|
|
1395
|
+
cliVersion = package_default.version
|
|
1396
|
+
}) {
|
|
1397
|
+
const osInfo = getOsInfo();
|
|
1398
|
+
const platformVersions = getPlatformVersions();
|
|
1399
|
+
return {
|
|
1400
|
+
...createCliBaseEvent(context),
|
|
1401
|
+
system_name: "zapier-sdk-cli",
|
|
1402
|
+
session_id: context.session_id ?? null,
|
|
1403
|
+
cli_version: data.cli_version ?? cliVersion,
|
|
1404
|
+
cli_arguments: data.cli_arguments ?? null,
|
|
1405
|
+
cli_primary_command: data.cli_primary_command,
|
|
1406
|
+
os_platform: osInfo.platform,
|
|
1407
|
+
os_release: osInfo.release,
|
|
1408
|
+
os_architecture: osInfo.architecture,
|
|
1409
|
+
platform_versions: platformVersions,
|
|
1410
|
+
selected_api: context.selected_api ?? null,
|
|
1411
|
+
app_id: context.app_id ?? null,
|
|
1412
|
+
app_version_id: context.app_version_id ?? null,
|
|
1413
|
+
execution_duration_ms: data.execution_duration_ms ?? null,
|
|
1414
|
+
success_flag: data.success_flag,
|
|
1415
|
+
exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
|
|
1416
|
+
error_message: data.error_message ?? null,
|
|
1417
|
+
command_category: data.command_category ?? null,
|
|
1418
|
+
requires_auth: data.requires_auth ?? null,
|
|
1419
|
+
is_ci_environment: isCi(),
|
|
1420
|
+
ci_platform: getCiPlatform(),
|
|
1421
|
+
package_manager: data.package_manager ?? "pnpm",
|
|
1422
|
+
// Default based on project setup
|
|
1423
|
+
made_network_requests: data.made_network_requests ?? null,
|
|
1424
|
+
files_modified_count: data.files_modified_count ?? null,
|
|
1425
|
+
files_created_count: data.files_created_count ?? null,
|
|
1426
|
+
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
1427
|
+
peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
|
|
1428
|
+
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
1429
|
+
subprocess_count: data.subprocess_count ?? null
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1375
1433
|
// src/plugins/login/index.ts
|
|
1434
|
+
var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
|
|
1376
1435
|
var loginWithSdk = createFunction(async function loginWithSdk2(options) {
|
|
1377
1436
|
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
1378
1437
|
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
@@ -1383,17 +1442,56 @@ var loginWithSdk = createFunction(async function loginWithSdk2(options) {
|
|
|
1383
1442
|
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1384
1443
|
setTimeout(() => process.exit(0), 100);
|
|
1385
1444
|
}, LoginSchema);
|
|
1386
|
-
var loginPlugin = () =>
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1445
|
+
var loginPlugin = ({ context }) => {
|
|
1446
|
+
const loginWithTelemetry = async (options) => {
|
|
1447
|
+
const startTime = Date.now();
|
|
1448
|
+
let success = false;
|
|
1449
|
+
let errorMessage = null;
|
|
1450
|
+
try {
|
|
1451
|
+
await loginWithSdk(options);
|
|
1452
|
+
success = true;
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
success = false;
|
|
1455
|
+
errorMessage = error instanceof Error ? error.message : "Login failed";
|
|
1456
|
+
throw error;
|
|
1457
|
+
} finally {
|
|
1458
|
+
const event = buildCliCommandExecutedEvent({
|
|
1459
|
+
data: {
|
|
1460
|
+
cli_primary_command: "login",
|
|
1461
|
+
success_flag: success,
|
|
1462
|
+
execution_duration_ms: Date.now() - startTime,
|
|
1463
|
+
exit_code: success ? 0 : 1,
|
|
1464
|
+
error_message: errorMessage,
|
|
1465
|
+
command_category: "authentication",
|
|
1466
|
+
requires_auth: false,
|
|
1467
|
+
cli_arguments: [
|
|
1468
|
+
"login",
|
|
1469
|
+
options.timeout ? `--timeout=${options.timeout}` : null
|
|
1470
|
+
].filter(Boolean)
|
|
1471
|
+
},
|
|
1472
|
+
context: {
|
|
1473
|
+
session_id: context.session_id,
|
|
1474
|
+
selected_api: context.selected_api,
|
|
1475
|
+
app_id: context.app_id,
|
|
1476
|
+
app_version_id: context.app_version_id
|
|
1477
|
+
},
|
|
1478
|
+
cliVersion: package_default.version
|
|
1479
|
+
});
|
|
1480
|
+
context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
return {
|
|
1484
|
+
login: loginWithTelemetry,
|
|
1485
|
+
context: {
|
|
1486
|
+
meta: {
|
|
1487
|
+
login: {
|
|
1488
|
+
categories: ["account"],
|
|
1489
|
+
inputSchema: LoginSchema
|
|
1490
|
+
}
|
|
1393
1491
|
}
|
|
1394
1492
|
}
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1397
1495
|
var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
|
|
1398
1496
|
|
|
1399
1497
|
// src/plugins/logout/index.ts
|
|
@@ -2248,7 +2346,8 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2248
2346
|
// src/sdk.ts
|
|
2249
2347
|
function createZapierCliSdk(options = {}) {
|
|
2250
2348
|
let sdk2 = createZapierSdkWithoutRegistry({
|
|
2251
|
-
debug: options.debug
|
|
2349
|
+
debug: options.debug,
|
|
2350
|
+
eventEmission: options.eventEmission
|
|
2252
2351
|
});
|
|
2253
2352
|
sdk2 = sdk2.addPlugin(bundleCodePlugin);
|
|
2254
2353
|
sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
|
|
@@ -2260,13 +2359,13 @@ function createZapierCliSdk(options = {}) {
|
|
|
2260
2359
|
return finalSdk;
|
|
2261
2360
|
}
|
|
2262
2361
|
|
|
2263
|
-
// package.json
|
|
2264
|
-
var
|
|
2265
|
-
version: "0.13.
|
|
2362
|
+
// package.json with { type: 'json' }
|
|
2363
|
+
var package_default2 = {
|
|
2364
|
+
version: "0.13.5"};
|
|
2266
2365
|
|
|
2267
2366
|
// src/cli.ts
|
|
2268
2367
|
var program = new Command();
|
|
2269
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK").version(
|
|
2368
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
|
|
2270
2369
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
2271
2370
|
var sdk = createZapierCliSdk({
|
|
2272
2371
|
debug: isDebugMode
|
package/dist/index.cjs
CHANGED
|
@@ -261,7 +261,66 @@ var LoginSchema = zod.z.object({
|
|
|
261
261
|
timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)")
|
|
262
262
|
}).describe("Log in to Zapier to access your account");
|
|
263
263
|
|
|
264
|
+
// package.json
|
|
265
|
+
var package_default = {
|
|
266
|
+
version: "0.13.5"};
|
|
267
|
+
|
|
268
|
+
// src/telemetry/builders.ts
|
|
269
|
+
function createCliBaseEvent(context = {}) {
|
|
270
|
+
return {
|
|
271
|
+
event_id: zapierSdk.generateEventId(),
|
|
272
|
+
timestamp_ms: zapierSdk.getCurrentTimestamp(),
|
|
273
|
+
release_id: zapierSdk.getReleaseId(),
|
|
274
|
+
customuser_id: context.customuser_id ?? null,
|
|
275
|
+
account_id: context.account_id ?? null,
|
|
276
|
+
identity_id: context.identity_id ?? null,
|
|
277
|
+
visitor_id: context.visitor_id ?? null,
|
|
278
|
+
correlation_id: context.correlation_id ?? null
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function buildCliCommandExecutedEvent({
|
|
282
|
+
data,
|
|
283
|
+
context = {},
|
|
284
|
+
cliVersion = package_default.version
|
|
285
|
+
}) {
|
|
286
|
+
const osInfo = zapierSdk.getOsInfo();
|
|
287
|
+
const platformVersions = zapierSdk.getPlatformVersions();
|
|
288
|
+
return {
|
|
289
|
+
...createCliBaseEvent(context),
|
|
290
|
+
system_name: "zapier-sdk-cli",
|
|
291
|
+
session_id: context.session_id ?? null,
|
|
292
|
+
cli_version: data.cli_version ?? cliVersion,
|
|
293
|
+
cli_arguments: data.cli_arguments ?? null,
|
|
294
|
+
cli_primary_command: data.cli_primary_command,
|
|
295
|
+
os_platform: osInfo.platform,
|
|
296
|
+
os_release: osInfo.release,
|
|
297
|
+
os_architecture: osInfo.architecture,
|
|
298
|
+
platform_versions: platformVersions,
|
|
299
|
+
selected_api: context.selected_api ?? null,
|
|
300
|
+
app_id: context.app_id ?? null,
|
|
301
|
+
app_version_id: context.app_version_id ?? null,
|
|
302
|
+
execution_duration_ms: data.execution_duration_ms ?? null,
|
|
303
|
+
success_flag: data.success_flag,
|
|
304
|
+
exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
|
|
305
|
+
error_message: data.error_message ?? null,
|
|
306
|
+
command_category: data.command_category ?? null,
|
|
307
|
+
requires_auth: data.requires_auth ?? null,
|
|
308
|
+
is_ci_environment: zapierSdk.isCi(),
|
|
309
|
+
ci_platform: zapierSdk.getCiPlatform(),
|
|
310
|
+
package_manager: data.package_manager ?? "pnpm",
|
|
311
|
+
// Default based on project setup
|
|
312
|
+
made_network_requests: data.made_network_requests ?? null,
|
|
313
|
+
files_modified_count: data.files_modified_count ?? null,
|
|
314
|
+
files_created_count: data.files_created_count ?? null,
|
|
315
|
+
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
316
|
+
peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
|
|
317
|
+
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
318
|
+
subprocess_count: data.subprocess_count ?? null
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
264
322
|
// src/plugins/login/index.ts
|
|
323
|
+
var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
|
|
265
324
|
var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options) {
|
|
266
325
|
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
267
326
|
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
@@ -272,17 +331,56 @@ var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options
|
|
|
272
331
|
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
273
332
|
setTimeout(() => process.exit(0), 100);
|
|
274
333
|
}, LoginSchema);
|
|
275
|
-
var loginPlugin = () =>
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
334
|
+
var loginPlugin = ({ context }) => {
|
|
335
|
+
const loginWithTelemetry = async (options) => {
|
|
336
|
+
const startTime = Date.now();
|
|
337
|
+
let success = false;
|
|
338
|
+
let errorMessage = null;
|
|
339
|
+
try {
|
|
340
|
+
await loginWithSdk(options);
|
|
341
|
+
success = true;
|
|
342
|
+
} catch (error) {
|
|
343
|
+
success = false;
|
|
344
|
+
errorMessage = error instanceof Error ? error.message : "Login failed";
|
|
345
|
+
throw error;
|
|
346
|
+
} finally {
|
|
347
|
+
const event = buildCliCommandExecutedEvent({
|
|
348
|
+
data: {
|
|
349
|
+
cli_primary_command: "login",
|
|
350
|
+
success_flag: success,
|
|
351
|
+
execution_duration_ms: Date.now() - startTime,
|
|
352
|
+
exit_code: success ? 0 : 1,
|
|
353
|
+
error_message: errorMessage,
|
|
354
|
+
command_category: "authentication",
|
|
355
|
+
requires_auth: false,
|
|
356
|
+
cli_arguments: [
|
|
357
|
+
"login",
|
|
358
|
+
options.timeout ? `--timeout=${options.timeout}` : null
|
|
359
|
+
].filter(Boolean)
|
|
360
|
+
},
|
|
361
|
+
context: {
|
|
362
|
+
session_id: context.session_id,
|
|
363
|
+
selected_api: context.selected_api,
|
|
364
|
+
app_id: context.app_id,
|
|
365
|
+
app_version_id: context.app_version_id
|
|
366
|
+
},
|
|
367
|
+
cliVersion: package_default.version
|
|
368
|
+
});
|
|
369
|
+
context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
return {
|
|
373
|
+
login: loginWithTelemetry,
|
|
374
|
+
context: {
|
|
375
|
+
meta: {
|
|
376
|
+
login: {
|
|
377
|
+
categories: ["account"],
|
|
378
|
+
inputSchema: LoginSchema
|
|
379
|
+
}
|
|
282
380
|
}
|
|
283
381
|
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
382
|
+
};
|
|
383
|
+
};
|
|
286
384
|
var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
|
|
287
385
|
|
|
288
386
|
// src/plugins/logout/index.ts
|
|
@@ -1137,7 +1235,8 @@ var addPlugin = ({ sdk, context }) => {
|
|
|
1137
1235
|
// src/sdk.ts
|
|
1138
1236
|
function createZapierCliSdk(options = {}) {
|
|
1139
1237
|
let sdk = zapierSdk.createZapierSdkWithoutRegistry({
|
|
1140
|
-
debug: options.debug
|
|
1238
|
+
debug: options.debug,
|
|
1239
|
+
eventEmission: options.eventEmission
|
|
1141
1240
|
});
|
|
1142
1241
|
sdk = sdk.addPlugin(bundleCodePlugin);
|
|
1143
1242
|
sdk = sdk.addPlugin(getLoginConfigPathPlugin);
|
|
@@ -1149,4 +1248,5 @@ function createZapierCliSdk(options = {}) {
|
|
|
1149
1248
|
return finalSdk;
|
|
1150
1249
|
}
|
|
1151
1250
|
|
|
1251
|
+
exports.buildCliCommandExecutedEvent = buildCliCommandExecutedEvent;
|
|
1152
1252
|
exports.createZapierCliSdk = createZapierCliSdk;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { ZapierSdk } from '@zapier/zapier-sdk';
|
|
1
|
+
import { ZapierSdk, BaseEvent } from '@zapier/zapier-sdk';
|
|
2
2
|
|
|
3
3
|
interface ZapierCliSdkOptions {
|
|
4
4
|
debug?: boolean;
|
|
5
|
+
eventEmission?: {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
transport?: {
|
|
8
|
+
type: "http" | "console" | "noop";
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
5
13
|
}
|
|
6
14
|
/**
|
|
7
15
|
* Create a Zapier SDK instance configured specifically for the CLI
|
|
@@ -9,4 +17,85 @@ interface ZapierCliSdkOptions {
|
|
|
9
17
|
*/
|
|
10
18
|
declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdk;
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
/**
|
|
21
|
+
* CLI-specific telemetry event definitions
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Event emitted when a CLI command is executed
|
|
26
|
+
*/
|
|
27
|
+
interface CliCommandExecutedEvent extends BaseEvent {
|
|
28
|
+
system_name: string;
|
|
29
|
+
session_id?: string | null;
|
|
30
|
+
cli_version?: string | null;
|
|
31
|
+
cli_arguments?: (string | null)[] | null;
|
|
32
|
+
cli_primary_command?: string | null;
|
|
33
|
+
os_platform?: string | null;
|
|
34
|
+
os_release?: string | null;
|
|
35
|
+
os_architecture?: string | null;
|
|
36
|
+
platform_versions?: Record<string, string | null> | null;
|
|
37
|
+
selected_api?: string | null;
|
|
38
|
+
app_id?: number | null;
|
|
39
|
+
app_version_id?: number | null;
|
|
40
|
+
execution_duration_ms?: number | null;
|
|
41
|
+
success_flag: boolean;
|
|
42
|
+
exit_code?: number | null;
|
|
43
|
+
error_message?: string | null;
|
|
44
|
+
command_category?: string | null;
|
|
45
|
+
requires_auth?: boolean | null;
|
|
46
|
+
is_ci_environment?: boolean | null;
|
|
47
|
+
ci_platform?: string | null;
|
|
48
|
+
package_manager?: string | null;
|
|
49
|
+
made_network_requests?: boolean | null;
|
|
50
|
+
files_modified_count?: number | null;
|
|
51
|
+
files_created_count?: number | null;
|
|
52
|
+
files_processed_size_bytes?: number | null;
|
|
53
|
+
peak_memory_usage_bytes?: number | null;
|
|
54
|
+
cpu_time_ms?: number | null;
|
|
55
|
+
subprocess_count?: number | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* CLI-specific event builders
|
|
60
|
+
*
|
|
61
|
+
* Provides builder functions for CLI command telemetry that auto-populate
|
|
62
|
+
* common CLI fields and system information.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
interface CliEventContext {
|
|
66
|
+
customuser_id?: number | null;
|
|
67
|
+
account_id?: number | null;
|
|
68
|
+
identity_id?: number | null;
|
|
69
|
+
visitor_id?: string | null;
|
|
70
|
+
correlation_id?: string | null;
|
|
71
|
+
session_id?: string | null;
|
|
72
|
+
selected_api?: string | null;
|
|
73
|
+
app_id?: number | null;
|
|
74
|
+
app_version_id?: number | null;
|
|
75
|
+
}
|
|
76
|
+
interface CliCommandExecutedEventData {
|
|
77
|
+
cli_primary_command: string;
|
|
78
|
+
success_flag: boolean;
|
|
79
|
+
execution_duration_ms?: number | null;
|
|
80
|
+
exit_code?: number | null;
|
|
81
|
+
error_message?: string | null;
|
|
82
|
+
command_category?: string | null;
|
|
83
|
+
requires_auth?: boolean | null;
|
|
84
|
+
cli_arguments?: (string | null)[] | null;
|
|
85
|
+
cli_version?: string | null;
|
|
86
|
+
made_network_requests?: boolean | null;
|
|
87
|
+
files_modified_count?: number | null;
|
|
88
|
+
files_created_count?: number | null;
|
|
89
|
+
files_processed_size_bytes?: number | null;
|
|
90
|
+
peak_memory_usage_bytes?: number | null;
|
|
91
|
+
cpu_time_ms?: number | null;
|
|
92
|
+
subprocess_count?: number | null;
|
|
93
|
+
package_manager?: string | null;
|
|
94
|
+
}
|
|
95
|
+
declare function buildCliCommandExecutedEvent({ data, context, cliVersion, }: {
|
|
96
|
+
data: CliCommandExecutedEventData;
|
|
97
|
+
context?: CliEventContext;
|
|
98
|
+
cliVersion?: string;
|
|
99
|
+
}): CliCommandExecutedEvent;
|
|
100
|
+
|
|
101
|
+
export { type CliCommandExecutedEvent, type CliCommandExecutedEventData, type CliEventContext, type ZapierCliSdkOptions, buildCliCommandExecutedEvent, createZapierCliSdk };
|