@zapier/zapier-sdk 0.31.0 → 0.31.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/CHANGELOG.md +6 -0
- package/dist/index.cjs +57 -16
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +57 -16
- package/dist/plugins/eventEmission/builders.js +3 -3
- package/dist/plugins/eventEmission/builders.test.d.ts +2 -0
- package/dist/plugins/eventEmission/builders.test.d.ts.map +1 -0
- package/dist/plugins/eventEmission/builders.test.js +56 -0
- package/dist/plugins/eventEmission/types.d.ts +3 -0
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +7 -0
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +6 -0
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -0
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +2 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +6 -0
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +6 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -8
- package/dist/utils/telemetry-context.d.ts +12 -0
- package/dist/utils/telemetry-context.d.ts.map +1 -1
- package/dist/utils/telemetry-context.js +18 -0
- package/dist/utils/telemetry-context.test.js +63 -1
- package/dist/utils/telemetry-utils.d.ts.map +1 -1
- package/dist/utils/telemetry-utils.js +5 -0
- package/dist/utils/telemetry-utils.test.js +61 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -491,6 +491,16 @@ function runWithTelemetryContext(fn) {
|
|
|
491
491
|
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
492
492
|
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
493
493
|
}
|
|
494
|
+
function setMethodMetadata(metadata) {
|
|
495
|
+
if (!telemetryStore) return;
|
|
496
|
+
const store = telemetryStore.getStore();
|
|
497
|
+
if (!store) return;
|
|
498
|
+
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
499
|
+
}
|
|
500
|
+
function getMethodMetadata() {
|
|
501
|
+
if (!telemetryStore) return void 0;
|
|
502
|
+
return telemetryStore.getStore()?.methodMetadata;
|
|
503
|
+
}
|
|
494
504
|
|
|
495
505
|
// src/plugins/fetch/index.ts
|
|
496
506
|
function transformUrlToRelayPath(url) {
|
|
@@ -1043,6 +1053,7 @@ var AppItemSchema = withFormatter(apps.AppItemSchema, {
|
|
|
1043
1053
|
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1044
1054
|
return {
|
|
1045
1055
|
onMethodCalled: (data) => {
|
|
1056
|
+
const metadata = getMethodMetadata();
|
|
1046
1057
|
emitMethodCalled({
|
|
1047
1058
|
method_name: methodName,
|
|
1048
1059
|
execution_duration_ms: data.durationMs,
|
|
@@ -1050,7 +1061,10 @@ function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
|
1050
1061
|
error_message: data.error?.message ?? null,
|
|
1051
1062
|
error_type: data.error?.constructor.name ?? null,
|
|
1052
1063
|
argument_count: data.argumentCount,
|
|
1053
|
-
is_paginated: data.isPaginated
|
|
1064
|
+
is_paginated: data.isPaginated,
|
|
1065
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
1066
|
+
operation_type: metadata?.operationType ?? null,
|
|
1067
|
+
operation_key: metadata?.operationKey ?? null
|
|
1054
1068
|
});
|
|
1055
1069
|
}
|
|
1056
1070
|
};
|
|
@@ -1790,6 +1804,10 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1790
1804
|
{ configType: "current_implementation_id" }
|
|
1791
1805
|
);
|
|
1792
1806
|
}
|
|
1807
|
+
setMethodMetadata({
|
|
1808
|
+
selectedApi,
|
|
1809
|
+
operationType: options.actionType ?? null
|
|
1810
|
+
});
|
|
1793
1811
|
const searchParams = {
|
|
1794
1812
|
global: "true",
|
|
1795
1813
|
public_only: "true",
|
|
@@ -2168,6 +2186,11 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
2168
2186
|
{ configType: "current_implementation_id" }
|
|
2169
2187
|
);
|
|
2170
2188
|
}
|
|
2189
|
+
setMethodMetadata({
|
|
2190
|
+
selectedApi,
|
|
2191
|
+
operationType: actionType,
|
|
2192
|
+
operationKey: actionKey
|
|
2193
|
+
});
|
|
2171
2194
|
const { data: action } = await sdk.getAction({
|
|
2172
2195
|
appKey,
|
|
2173
2196
|
actionType,
|
|
@@ -2287,6 +2310,7 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
2287
2310
|
options.appKey
|
|
2288
2311
|
);
|
|
2289
2312
|
if (implementationId) {
|
|
2313
|
+
setMethodMetadata({ selectedApi: implementationId });
|
|
2290
2314
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2291
2315
|
searchParams.app_key = versionlessSelectedApi;
|
|
2292
2316
|
} else {
|
|
@@ -2653,6 +2677,10 @@ var GetActionSchema = zod.z.object({
|
|
|
2653
2677
|
var getActionPlugin = ({ sdk, context }) => {
|
|
2654
2678
|
async function getAction(options) {
|
|
2655
2679
|
const { actionKey, actionType, appKey } = options;
|
|
2680
|
+
setMethodMetadata({
|
|
2681
|
+
operationType: actionType,
|
|
2682
|
+
operationKey: actionKey
|
|
2683
|
+
});
|
|
2656
2684
|
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2657
2685
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2658
2686
|
return { data: action };
|
|
@@ -2862,8 +2890,7 @@ var RunActionSchema = zod.z.object({
|
|
|
2862
2890
|
async function executeAction(actionOptions) {
|
|
2863
2891
|
const {
|
|
2864
2892
|
api,
|
|
2865
|
-
|
|
2866
|
-
appKey,
|
|
2893
|
+
selectedApi,
|
|
2867
2894
|
actionId,
|
|
2868
2895
|
actionKey,
|
|
2869
2896
|
actionType,
|
|
@@ -2871,13 +2898,6 @@ async function executeAction(actionOptions) {
|
|
|
2871
2898
|
connectionId,
|
|
2872
2899
|
timeoutMs
|
|
2873
2900
|
} = actionOptions;
|
|
2874
|
-
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
2875
|
-
if (!selectedApi) {
|
|
2876
|
-
throw new ZapierConfigurationError(
|
|
2877
|
-
"No current_implementation_id found for app",
|
|
2878
|
-
{ configType: "current_implementation_id" }
|
|
2879
|
-
);
|
|
2880
|
-
}
|
|
2881
2901
|
const runRequestData = {
|
|
2882
2902
|
selected_api: selectedApi,
|
|
2883
2903
|
action_id: actionId,
|
|
@@ -2920,6 +2940,18 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2920
2940
|
timeoutMs
|
|
2921
2941
|
} = options;
|
|
2922
2942
|
const resolvedConnectionId = connectionId ?? authenticationId;
|
|
2943
|
+
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
2944
|
+
if (!selectedApi) {
|
|
2945
|
+
throw new ZapierConfigurationError(
|
|
2946
|
+
"No current_implementation_id found for app",
|
|
2947
|
+
{ configType: "current_implementation_id" }
|
|
2948
|
+
);
|
|
2949
|
+
}
|
|
2950
|
+
setMethodMetadata({
|
|
2951
|
+
selectedApi,
|
|
2952
|
+
operationType: actionType,
|
|
2953
|
+
operationKey: actionKey
|
|
2954
|
+
});
|
|
2923
2955
|
const actionData = await sdk.getAction({
|
|
2924
2956
|
appKey,
|
|
2925
2957
|
actionKey,
|
|
@@ -2933,8 +2965,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2933
2965
|
const actionId = actionData.data.id;
|
|
2934
2966
|
const result = await executeAction({
|
|
2935
2967
|
api,
|
|
2936
|
-
|
|
2937
|
-
appKey,
|
|
2968
|
+
selectedApi,
|
|
2938
2969
|
// Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
|
|
2939
2970
|
// we retrieve actions (probably legacy reasons), so we just pass along all the things!
|
|
2940
2971
|
actionId,
|
|
@@ -5058,6 +5089,11 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
5058
5089
|
{ configType: "current_implementation_id" }
|
|
5059
5090
|
);
|
|
5060
5091
|
}
|
|
5092
|
+
setMethodMetadata({
|
|
5093
|
+
selectedApi,
|
|
5094
|
+
operationType: actionType,
|
|
5095
|
+
operationKey: actionKey
|
|
5096
|
+
});
|
|
5061
5097
|
const { data: action } = await sdk.getAction({
|
|
5062
5098
|
appKey,
|
|
5063
5099
|
actionType,
|
|
@@ -5177,6 +5213,11 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
5177
5213
|
{ configType: "current_implementation_id" }
|
|
5178
5214
|
);
|
|
5179
5215
|
}
|
|
5216
|
+
setMethodMetadata({
|
|
5217
|
+
selectedApi,
|
|
5218
|
+
operationType: actionType,
|
|
5219
|
+
operationKey: actionKey
|
|
5220
|
+
});
|
|
5180
5221
|
const { data: action } = await sdk.getAction({
|
|
5181
5222
|
appKey,
|
|
5182
5223
|
actionType,
|
|
@@ -5428,7 +5469,7 @@ function getCpuTime() {
|
|
|
5428
5469
|
|
|
5429
5470
|
// package.json
|
|
5430
5471
|
var package_default = {
|
|
5431
|
-
version: "0.31.
|
|
5472
|
+
version: "0.31.1"};
|
|
5432
5473
|
|
|
5433
5474
|
// src/plugins/eventEmission/builders.ts
|
|
5434
5475
|
function createBaseEvent(context = {}) {
|
|
@@ -5509,13 +5550,13 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5509
5550
|
is_paginated: data.is_paginated ?? false,
|
|
5510
5551
|
sdk_version: package_default.version,
|
|
5511
5552
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5512
|
-
selected_api: context.selected_api ?? null,
|
|
5553
|
+
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
5513
5554
|
app_id: context.app_id ?? null,
|
|
5514
5555
|
app_version_id: context.app_version_id ?? null,
|
|
5515
5556
|
zap_id: context.zap_id ?? null,
|
|
5516
5557
|
node_id: context.node_id ?? null,
|
|
5517
|
-
operation_type: null,
|
|
5518
|
-
operation_key: null,
|
|
5558
|
+
operation_type: data.operation_type ?? null,
|
|
5559
|
+
operation_key: data.operation_key ?? null,
|
|
5519
5560
|
call_context: null,
|
|
5520
5561
|
is_retry: false,
|
|
5521
5562
|
retry_attempt: null,
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -469,6 +469,16 @@ function runWithTelemetryContext(fn) {
|
|
|
469
469
|
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
470
470
|
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
471
471
|
}
|
|
472
|
+
function setMethodMetadata(metadata) {
|
|
473
|
+
if (!telemetryStore) return;
|
|
474
|
+
const store = telemetryStore.getStore();
|
|
475
|
+
if (!store) return;
|
|
476
|
+
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
477
|
+
}
|
|
478
|
+
function getMethodMetadata() {
|
|
479
|
+
if (!telemetryStore) return void 0;
|
|
480
|
+
return telemetryStore.getStore()?.methodMetadata;
|
|
481
|
+
}
|
|
472
482
|
|
|
473
483
|
// src/plugins/fetch/index.ts
|
|
474
484
|
function transformUrlToRelayPath(url) {
|
|
@@ -1021,6 +1031,7 @@ var AppItemSchema = withFormatter(AppItemSchema$1, {
|
|
|
1021
1031
|
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1022
1032
|
return {
|
|
1023
1033
|
onMethodCalled: (data) => {
|
|
1034
|
+
const metadata = getMethodMetadata();
|
|
1024
1035
|
emitMethodCalled({
|
|
1025
1036
|
method_name: methodName,
|
|
1026
1037
|
execution_duration_ms: data.durationMs,
|
|
@@ -1028,7 +1039,10 @@ function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
|
1028
1039
|
error_message: data.error?.message ?? null,
|
|
1029
1040
|
error_type: data.error?.constructor.name ?? null,
|
|
1030
1041
|
argument_count: data.argumentCount,
|
|
1031
|
-
is_paginated: data.isPaginated
|
|
1042
|
+
is_paginated: data.isPaginated,
|
|
1043
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
1044
|
+
operation_type: metadata?.operationType ?? null,
|
|
1045
|
+
operation_key: metadata?.operationKey ?? null
|
|
1032
1046
|
});
|
|
1033
1047
|
}
|
|
1034
1048
|
};
|
|
@@ -1768,6 +1782,10 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1768
1782
|
{ configType: "current_implementation_id" }
|
|
1769
1783
|
);
|
|
1770
1784
|
}
|
|
1785
|
+
setMethodMetadata({
|
|
1786
|
+
selectedApi,
|
|
1787
|
+
operationType: options.actionType ?? null
|
|
1788
|
+
});
|
|
1771
1789
|
const searchParams = {
|
|
1772
1790
|
global: "true",
|
|
1773
1791
|
public_only: "true",
|
|
@@ -2146,6 +2164,11 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
2146
2164
|
{ configType: "current_implementation_id" }
|
|
2147
2165
|
);
|
|
2148
2166
|
}
|
|
2167
|
+
setMethodMetadata({
|
|
2168
|
+
selectedApi,
|
|
2169
|
+
operationType: actionType,
|
|
2170
|
+
operationKey: actionKey
|
|
2171
|
+
});
|
|
2149
2172
|
const { data: action } = await sdk.getAction({
|
|
2150
2173
|
appKey,
|
|
2151
2174
|
actionType,
|
|
@@ -2265,6 +2288,7 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
2265
2288
|
options.appKey
|
|
2266
2289
|
);
|
|
2267
2290
|
if (implementationId) {
|
|
2291
|
+
setMethodMetadata({ selectedApi: implementationId });
|
|
2268
2292
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2269
2293
|
searchParams.app_key = versionlessSelectedApi;
|
|
2270
2294
|
} else {
|
|
@@ -2631,6 +2655,10 @@ var GetActionSchema = z.object({
|
|
|
2631
2655
|
var getActionPlugin = ({ sdk, context }) => {
|
|
2632
2656
|
async function getAction(options) {
|
|
2633
2657
|
const { actionKey, actionType, appKey } = options;
|
|
2658
|
+
setMethodMetadata({
|
|
2659
|
+
operationType: actionType,
|
|
2660
|
+
operationKey: actionKey
|
|
2661
|
+
});
|
|
2634
2662
|
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2635
2663
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2636
2664
|
return { data: action };
|
|
@@ -2840,8 +2868,7 @@ var RunActionSchema = z.object({
|
|
|
2840
2868
|
async function executeAction(actionOptions) {
|
|
2841
2869
|
const {
|
|
2842
2870
|
api,
|
|
2843
|
-
|
|
2844
|
-
appKey,
|
|
2871
|
+
selectedApi,
|
|
2845
2872
|
actionId,
|
|
2846
2873
|
actionKey,
|
|
2847
2874
|
actionType,
|
|
@@ -2849,13 +2876,6 @@ async function executeAction(actionOptions) {
|
|
|
2849
2876
|
connectionId,
|
|
2850
2877
|
timeoutMs
|
|
2851
2878
|
} = actionOptions;
|
|
2852
|
-
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
2853
|
-
if (!selectedApi) {
|
|
2854
|
-
throw new ZapierConfigurationError(
|
|
2855
|
-
"No current_implementation_id found for app",
|
|
2856
|
-
{ configType: "current_implementation_id" }
|
|
2857
|
-
);
|
|
2858
|
-
}
|
|
2859
2879
|
const runRequestData = {
|
|
2860
2880
|
selected_api: selectedApi,
|
|
2861
2881
|
action_id: actionId,
|
|
@@ -2898,6 +2918,18 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2898
2918
|
timeoutMs
|
|
2899
2919
|
} = options;
|
|
2900
2920
|
const resolvedConnectionId = connectionId ?? authenticationId;
|
|
2921
|
+
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
2922
|
+
if (!selectedApi) {
|
|
2923
|
+
throw new ZapierConfigurationError(
|
|
2924
|
+
"No current_implementation_id found for app",
|
|
2925
|
+
{ configType: "current_implementation_id" }
|
|
2926
|
+
);
|
|
2927
|
+
}
|
|
2928
|
+
setMethodMetadata({
|
|
2929
|
+
selectedApi,
|
|
2930
|
+
operationType: actionType,
|
|
2931
|
+
operationKey: actionKey
|
|
2932
|
+
});
|
|
2901
2933
|
const actionData = await sdk.getAction({
|
|
2902
2934
|
appKey,
|
|
2903
2935
|
actionKey,
|
|
@@ -2911,8 +2943,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2911
2943
|
const actionId = actionData.data.id;
|
|
2912
2944
|
const result = await executeAction({
|
|
2913
2945
|
api,
|
|
2914
|
-
|
|
2915
|
-
appKey,
|
|
2946
|
+
selectedApi,
|
|
2916
2947
|
// Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
|
|
2917
2948
|
// we retrieve actions (probably legacy reasons), so we just pass along all the things!
|
|
2918
2949
|
actionId,
|
|
@@ -5036,6 +5067,11 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
5036
5067
|
{ configType: "current_implementation_id" }
|
|
5037
5068
|
);
|
|
5038
5069
|
}
|
|
5070
|
+
setMethodMetadata({
|
|
5071
|
+
selectedApi,
|
|
5072
|
+
operationType: actionType,
|
|
5073
|
+
operationKey: actionKey
|
|
5074
|
+
});
|
|
5039
5075
|
const { data: action } = await sdk.getAction({
|
|
5040
5076
|
appKey,
|
|
5041
5077
|
actionType,
|
|
@@ -5155,6 +5191,11 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
5155
5191
|
{ configType: "current_implementation_id" }
|
|
5156
5192
|
);
|
|
5157
5193
|
}
|
|
5194
|
+
setMethodMetadata({
|
|
5195
|
+
selectedApi,
|
|
5196
|
+
operationType: actionType,
|
|
5197
|
+
operationKey: actionKey
|
|
5198
|
+
});
|
|
5158
5199
|
const { data: action } = await sdk.getAction({
|
|
5159
5200
|
appKey,
|
|
5160
5201
|
actionType,
|
|
@@ -5406,7 +5447,7 @@ function getCpuTime() {
|
|
|
5406
5447
|
|
|
5407
5448
|
// package.json
|
|
5408
5449
|
var package_default = {
|
|
5409
|
-
version: "0.31.
|
|
5450
|
+
version: "0.31.1"};
|
|
5410
5451
|
|
|
5411
5452
|
// src/plugins/eventEmission/builders.ts
|
|
5412
5453
|
function createBaseEvent(context = {}) {
|
|
@@ -5487,13 +5528,13 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5487
5528
|
is_paginated: data.is_paginated ?? false,
|
|
5488
5529
|
sdk_version: package_default.version,
|
|
5489
5530
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5490
|
-
selected_api: context.selected_api ?? null,
|
|
5531
|
+
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
5491
5532
|
app_id: context.app_id ?? null,
|
|
5492
5533
|
app_version_id: context.app_version_id ?? null,
|
|
5493
5534
|
zap_id: context.zap_id ?? null,
|
|
5494
5535
|
node_id: context.node_id ?? null,
|
|
5495
|
-
operation_type: null,
|
|
5496
|
-
operation_key: null,
|
|
5536
|
+
operation_type: data.operation_type ?? null,
|
|
5537
|
+
operation_key: data.operation_key ?? null,
|
|
5497
5538
|
call_context: null,
|
|
5498
5539
|
is_retry: false,
|
|
5499
5540
|
retry_attempt: null,
|
|
@@ -88,13 +88,13 @@ export function buildMethodCalledEvent(data, context = {}) {
|
|
|
88
88
|
is_paginated: data.is_paginated ?? false,
|
|
89
89
|
sdk_version: sdkPackageJson.version,
|
|
90
90
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
91
|
-
selected_api: context.selected_api ?? null,
|
|
91
|
+
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
92
92
|
app_id: context.app_id ?? null,
|
|
93
93
|
app_version_id: context.app_version_id ?? null,
|
|
94
94
|
zap_id: context.zap_id ?? null,
|
|
95
95
|
node_id: context.node_id ?? null,
|
|
96
|
-
operation_type: null,
|
|
97
|
-
operation_key: null,
|
|
96
|
+
operation_type: data.operation_type ?? null,
|
|
97
|
+
operation_key: data.operation_key ?? null,
|
|
98
98
|
call_context: null,
|
|
99
99
|
is_retry: false,
|
|
100
100
|
retry_attempt: null,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/builders.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { buildMethodCalledEvent } from "./builders";
|
|
3
|
+
describe("buildMethodCalledEvent", () => {
|
|
4
|
+
it("should use data.selected_api when provided", () => {
|
|
5
|
+
const event = buildMethodCalledEvent({
|
|
6
|
+
method_name: "runAction",
|
|
7
|
+
execution_duration_ms: 100,
|
|
8
|
+
success_flag: true,
|
|
9
|
+
argument_count: 1,
|
|
10
|
+
selected_api: "SlackCLIAPI@1.0.0",
|
|
11
|
+
});
|
|
12
|
+
expect(event.selected_api).toBe("SlackCLIAPI@1.0.0");
|
|
13
|
+
});
|
|
14
|
+
it("should use data.operation_type and data.operation_key when provided", () => {
|
|
15
|
+
const event = buildMethodCalledEvent({
|
|
16
|
+
method_name: "runAction",
|
|
17
|
+
execution_duration_ms: 100,
|
|
18
|
+
success_flag: true,
|
|
19
|
+
argument_count: 1,
|
|
20
|
+
operation_type: "write",
|
|
21
|
+
operation_key: "send_message",
|
|
22
|
+
});
|
|
23
|
+
expect(event.operation_type).toBe("write");
|
|
24
|
+
expect(event.operation_key).toBe("send_message");
|
|
25
|
+
});
|
|
26
|
+
it("should fall back to null when data fields are not provided", () => {
|
|
27
|
+
const event = buildMethodCalledEvent({
|
|
28
|
+
method_name: "listApps",
|
|
29
|
+
execution_duration_ms: 50,
|
|
30
|
+
success_flag: true,
|
|
31
|
+
argument_count: 0,
|
|
32
|
+
});
|
|
33
|
+
expect(event.selected_api).toBeNull();
|
|
34
|
+
expect(event.operation_type).toBeNull();
|
|
35
|
+
expect(event.operation_key).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
it("should prefer data.selected_api over context.selected_api", () => {
|
|
38
|
+
const event = buildMethodCalledEvent({
|
|
39
|
+
method_name: "runAction",
|
|
40
|
+
execution_duration_ms: 100,
|
|
41
|
+
success_flag: true,
|
|
42
|
+
argument_count: 1,
|
|
43
|
+
selected_api: "SlackCLIAPI@2.0.0",
|
|
44
|
+
}, { selected_api: "SlackCLIAPI@1.0.0" });
|
|
45
|
+
expect(event.selected_api).toBe("SlackCLIAPI@2.0.0");
|
|
46
|
+
});
|
|
47
|
+
it("should fall back to context.selected_api when data.selected_api is not provided", () => {
|
|
48
|
+
const event = buildMethodCalledEvent({
|
|
49
|
+
method_name: "runAction",
|
|
50
|
+
execution_duration_ms: 100,
|
|
51
|
+
success_flag: true,
|
|
52
|
+
argument_count: 1,
|
|
53
|
+
}, { selected_api: "SlackCLIAPI@1.0.0" });
|
|
54
|
+
expect(event.selected_api).toBe("SlackCLIAPI@1.0.0");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -59,5 +59,8 @@ export interface MethodCalledEventData {
|
|
|
59
59
|
error_type?: string | null;
|
|
60
60
|
argument_count: number;
|
|
61
61
|
is_paginated?: boolean;
|
|
62
|
+
selected_api?: string | null;
|
|
63
|
+
operation_type?: string | null;
|
|
64
|
+
operation_key?: string | null;
|
|
62
65
|
}
|
|
63
66
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CA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AAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAOhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAOhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE,AADuC,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,uBAAuB,CAyDxB,CAAC"}
|
|
@@ -4,9 +4,16 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
4
4
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, } from "../../resolvers";
|
|
5
5
|
import { ActionItemSchema } from "../../schemas/Action";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
7
8
|
export const getActionPlugin = ({ sdk, context }) => {
|
|
8
9
|
async function getAction(options) {
|
|
9
10
|
const { actionKey, actionType, appKey } = options;
|
|
11
|
+
// selectedApi is intentionally omitted — getAction doesn't resolve a versioned
|
|
12
|
+
// implementation ID; it delegates to sdk.listActions, which sets selectedApi in its own scope.
|
|
13
|
+
setMethodMetadata({
|
|
14
|
+
operationType: actionType,
|
|
15
|
+
operationKey: actionKey,
|
|
16
|
+
});
|
|
10
17
|
// Use the listActions function from the SDK to search for the specific action across all pages
|
|
11
18
|
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
12
19
|
if ((action.key === actionKey || action.id === actionKey) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.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AC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,kCAAkC,CAoFnC,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
4
4
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
5
|
import { fetchImplementationNeeds } from "../../services/implementations";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
7
8
|
export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
8
9
|
async function getInputFieldsSchema(options) {
|
|
9
10
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -14,6 +15,11 @@ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
14
15
|
if (!selectedApi) {
|
|
15
16
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
16
17
|
}
|
|
18
|
+
setMethodMetadata({
|
|
19
|
+
selectedApi,
|
|
20
|
+
operationType: actionType,
|
|
21
|
+
operationKey: actionKey,
|
|
22
|
+
});
|
|
17
23
|
const { data: action } = await sdk.getAction({
|
|
18
24
|
appKey,
|
|
19
25
|
actionType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,C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BAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,yBAAyB,CA0G1B,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { createPaginatedFunction } from "../../utils/function-utils";
|
|
|
6
6
|
import { appKeyResolver, actionTypeResolver } from "../../resolvers";
|
|
7
7
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
8
8
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
9
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
9
10
|
export const listActionsPlugin = ({ context }) => {
|
|
10
11
|
const methodMeta = {
|
|
11
12
|
categories: ["action"],
|
|
@@ -25,6 +26,11 @@ export const listActionsPlugin = ({ context }) => {
|
|
|
25
26
|
if (!selectedApi) {
|
|
26
27
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
27
28
|
}
|
|
29
|
+
// operationKey is intentionally omitted — listActions is a list-level operation with no specific action key.
|
|
30
|
+
setMethodMetadata({
|
|
31
|
+
selectedApi,
|
|
32
|
+
operationType: options.actionType ?? null,
|
|
33
|
+
});
|
|
28
34
|
const searchParams = {
|
|
29
35
|
global: "true",
|
|
30
36
|
public_only: "true",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CACf,OAAO,CAAC,EAAE,sBAAsB,KAC7B,OAAO,CAAC,mBAAmB,CAAC,GAC/B,aAAa,CAAC,mBAAmB,CAAC,GAAG;QACnC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;KACxC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,6BAA6B,CA4G9B,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { ConnectionItemSchema } from "../../schemas/Connection";
|
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
7
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
8
8
|
import { ZapierAuthenticationError } from "../../types/errors";
|
|
9
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
9
10
|
export const listConnectionsPlugin = ({ context }) => {
|
|
10
11
|
async function listConnectionsPage(options) {
|
|
11
12
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -16,6 +17,7 @@ export const listConnectionsPlugin = ({ context }) => {
|
|
|
16
17
|
if (options.appKey) {
|
|
17
18
|
const implementationId = await getVersionedImplementationId(options.appKey);
|
|
18
19
|
if (implementationId) {
|
|
20
|
+
setMethodMetadata({ selectedApi: implementationId });
|
|
19
21
|
// Extract versionless app key to pass to handler
|
|
20
22
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
21
23
|
searchParams.app_key = versionlessSelectedApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAcxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/index.ts"],"names":[],"mappings":"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|
|
5
5
|
import { fetchImplementationNeeds, fetchImplementationChoices, } from "../../services/implementations";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
7
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
8
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
8
9
|
// Transform NeedChoices to InputFieldChoiceItem
|
|
9
10
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
10
11
|
return {
|
|
@@ -26,6 +27,11 @@ export const listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
26
27
|
if (!selectedApi) {
|
|
27
28
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
28
29
|
}
|
|
30
|
+
setMethodMetadata({
|
|
31
|
+
selectedApi,
|
|
32
|
+
operationType: actionType,
|
|
33
|
+
operationKey: actionKey,
|
|
34
|
+
});
|
|
29
35
|
// Get action details
|
|
30
36
|
const { data: action } = await sdk.getAction({
|
|
31
37
|
appKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAYxE,OAAO,KAAK,EAAE,oBAAoB,EA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AAuC;AACnG,AAD4D,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,2EAA2E;AACrG,6BAA6B,CAiG9B,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { RootFieldItemSchema } from "../../schemas/Field";
|
|
|
6
6
|
import { toTitleCase, stripPageSuffix } from "../../utils/string-utils";
|
|
7
7
|
import { fetchImplementationNeeds } from "../../services/implementations";
|
|
8
8
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
9
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
9
10
|
// Enums for input field transformation
|
|
10
11
|
var InputFieldType;
|
|
11
12
|
(function (InputFieldType) {
|
|
@@ -157,6 +158,11 @@ export const listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
157
158
|
if (!selectedApi) {
|
|
158
159
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
159
160
|
}
|
|
161
|
+
setMethodMetadata({
|
|
162
|
+
selectedApi,
|
|
163
|
+
operationType: actionType,
|
|
164
|
+
operationKey: actionKey,
|
|
165
|
+
});
|
|
160
166
|
// Need to call getAction here because it resolves both action.key AND action.id
|
|
161
167
|
// eg: `create_report` or `core:39487493`
|
|
162
168
|
const { data: action } = await sdk.getAction({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,o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AuC;AACnG,AAD4D,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,4CAA4C;AACtE,uBAAuB,CAqHxB,CAAC"}
|
|
@@ -6,13 +6,9 @@ import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdReso
|
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
7
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
8
8
|
import { DEFAULT_ACTION_TIMEOUT_MS } from "../../constants";
|
|
9
|
+
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
9
10
|
async function executeAction(actionOptions) {
|
|
10
|
-
const { api,
|
|
11
|
-
// Use the manifest plugin to get the current implementation ID
|
|
12
|
-
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
13
|
-
if (!selectedApi) {
|
|
14
|
-
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
15
|
-
}
|
|
11
|
+
const { api, selectedApi, actionId, actionKey, actionType, executionOptions, connectionId, timeoutMs, } = actionOptions;
|
|
16
12
|
// Step 1: POST to /actions/v1/runs to start execution
|
|
17
13
|
const runRequestData = {
|
|
18
14
|
selected_api: selectedApi,
|
|
@@ -49,6 +45,15 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
49
45
|
const { appKey, actionKey, actionType, connectionId, authenticationId, inputs = {}, timeoutMs, } = options;
|
|
50
46
|
// Support both connectionId (new) and authenticationId (deprecated)
|
|
51
47
|
const resolvedConnectionId = connectionId ?? authenticationId;
|
|
48
|
+
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
49
|
+
if (!selectedApi) {
|
|
50
|
+
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
51
|
+
}
|
|
52
|
+
setMethodMetadata({
|
|
53
|
+
selectedApi,
|
|
54
|
+
operationType: actionType,
|
|
55
|
+
operationKey: actionKey,
|
|
56
|
+
});
|
|
52
57
|
// Validate that the action exists using the getAction plugin
|
|
53
58
|
const actionData = await sdk.getAction({
|
|
54
59
|
appKey: appKey,
|
|
@@ -63,8 +68,7 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
63
68
|
// Execute the action using the Actions API (supports all action types)
|
|
64
69
|
const result = await executeAction({
|
|
65
70
|
api,
|
|
66
|
-
|
|
67
|
-
appKey,
|
|
71
|
+
selectedApi,
|
|
68
72
|
// Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
|
|
69
73
|
// we retrieve actions (probably legacy reasons), so we just pass along all the things!
|
|
70
74
|
actionId,
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-local storage context for per-invocation telemetry state. Each top-level
|
|
3
|
+
* SDK method call runs in its own ALS scope (via runWithTelemetryContext), isolating
|
|
4
|
+
* its depth counter and method metadata from concurrent calls.
|
|
5
|
+
*/
|
|
6
|
+
export interface MethodMetadata {
|
|
7
|
+
selectedApi?: string | null;
|
|
8
|
+
operationType?: string | null;
|
|
9
|
+
operationKey?: string | null;
|
|
10
|
+
}
|
|
1
11
|
export declare function isTelemetryNested(): boolean;
|
|
2
12
|
export declare function runWithTelemetryContext<T>(fn: () => T): T;
|
|
13
|
+
export declare function setMethodMetadata(metadata: MethodMetadata): void;
|
|
14
|
+
export declare function getMethodMetadata(): MethodMetadata | undefined;
|
|
3
15
|
//# sourceMappingURL=telemetry-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-context.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry-context.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAoBD,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAIzD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAKhE;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAG9D"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-local storage context for per-invocation telemetry state. Each top-level
|
|
3
|
+
* SDK method call runs in its own ALS scope (via runWithTelemetryContext), isolating
|
|
4
|
+
* its depth counter and method metadata from concurrent calls.
|
|
5
|
+
*/
|
|
1
6
|
// Intentional dynamic require — one-time environment detection for AsyncLocalStorage
|
|
2
7
|
// availability (e.g., unavailable in browsers). This is NOT lazy loading.
|
|
3
8
|
let telemetryStore = null;
|
|
@@ -21,3 +26,16 @@ export function runWithTelemetryContext(fn) {
|
|
|
21
26
|
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
22
27
|
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
23
28
|
}
|
|
29
|
+
export function setMethodMetadata(metadata) {
|
|
30
|
+
if (!telemetryStore)
|
|
31
|
+
return;
|
|
32
|
+
const store = telemetryStore.getStore();
|
|
33
|
+
if (!store)
|
|
34
|
+
return;
|
|
35
|
+
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
36
|
+
}
|
|
37
|
+
export function getMethodMetadata() {
|
|
38
|
+
if (!telemetryStore)
|
|
39
|
+
return undefined;
|
|
40
|
+
return telemetryStore.getStore()?.methodMetadata;
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { isTelemetryNested, runWithTelemetryContext, } from "./telemetry-context";
|
|
2
|
+
import { isTelemetryNested, runWithTelemetryContext, setMethodMetadata, getMethodMetadata, } from "./telemetry-context";
|
|
3
3
|
describe("telemetry-context", () => {
|
|
4
4
|
describe("isTelemetryNested", () => {
|
|
5
5
|
it("returns false outside any context", () => {
|
|
@@ -69,6 +69,68 @@ describe("telemetry-context", () => {
|
|
|
69
69
|
expect(task2Result?.nested).toBe(false);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
+
describe("setMethodMetadata / getMethodMetadata", () => {
|
|
73
|
+
it("round-trips metadata within ALS context", () => {
|
|
74
|
+
runWithTelemetryContext(() => {
|
|
75
|
+
setMethodMetadata({
|
|
76
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
77
|
+
operationType: "write",
|
|
78
|
+
operationKey: "send_message",
|
|
79
|
+
});
|
|
80
|
+
const metadata = getMethodMetadata();
|
|
81
|
+
expect(metadata).toEqual({
|
|
82
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
83
|
+
operationType: "write",
|
|
84
|
+
operationKey: "send_message",
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it("returns undefined outside any ALS context", () => {
|
|
89
|
+
expect(getMethodMetadata()).toBeUndefined();
|
|
90
|
+
});
|
|
91
|
+
it("is isolated between different runWithTelemetryContext scopes", () => {
|
|
92
|
+
runWithTelemetryContext(() => {
|
|
93
|
+
setMethodMetadata({ selectedApi: "parent" });
|
|
94
|
+
runWithTelemetryContext(() => {
|
|
95
|
+
setMethodMetadata({ selectedApi: "child" });
|
|
96
|
+
expect(getMethodMetadata()?.selectedApi).toBe("child");
|
|
97
|
+
});
|
|
98
|
+
expect(getMethodMetadata()?.selectedApi).toBe("parent");
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
it("merges partial metadata updates", () => {
|
|
102
|
+
runWithTelemetryContext(() => {
|
|
103
|
+
setMethodMetadata({ selectedApi: "SlackCLIAPI@1.0.0" });
|
|
104
|
+
setMethodMetadata({ operationType: "write" });
|
|
105
|
+
const metadata = getMethodMetadata();
|
|
106
|
+
expect(metadata).toEqual({
|
|
107
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
108
|
+
operationType: "write",
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
it("is readable in .then() handler within same ALS scope (paginated pattern)", async () => {
|
|
113
|
+
await runWithTelemetryContext(async () => {
|
|
114
|
+
setMethodMetadata({
|
|
115
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
116
|
+
operationType: "write",
|
|
117
|
+
operationKey: "send_message",
|
|
118
|
+
});
|
|
119
|
+
const result = await Promise.resolve("done").then(() => {
|
|
120
|
+
return getMethodMetadata();
|
|
121
|
+
});
|
|
122
|
+
expect(result).toEqual({
|
|
123
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
124
|
+
operationType: "write",
|
|
125
|
+
operationKey: "send_message",
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it("is a no-op outside ALS context", () => {
|
|
130
|
+
setMethodMetadata({ selectedApi: "test" });
|
|
131
|
+
expect(getMethodMetadata()).toBeUndefined();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
72
134
|
describe("runWithTelemetryContext", () => {
|
|
73
135
|
it("returns the value from the wrapped function", () => {
|
|
74
136
|
const result = runWithTelemetryContext(() => 42);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-utils.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry-utils.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC,kBAAkB,CAAC,EAC3E,UAAU,EAAE,MAAM,GACjB,kBAAkB,CAkBpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getMethodMetadata } from "./telemetry-context";
|
|
1
2
|
/**
|
|
2
3
|
* Creates a standardized telemetry callback for SDK method invocations.
|
|
3
4
|
*
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
export function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
42
43
|
return {
|
|
43
44
|
onMethodCalled: (data) => {
|
|
45
|
+
const metadata = getMethodMetadata();
|
|
44
46
|
emitMethodCalled({
|
|
45
47
|
method_name: methodName,
|
|
46
48
|
execution_duration_ms: data.durationMs,
|
|
@@ -49,6 +51,9 @@ export function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
|
49
51
|
error_type: data.error?.constructor.name ?? null,
|
|
50
52
|
argument_count: data.argumentCount,
|
|
51
53
|
is_paginated: data.isPaginated,
|
|
54
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
55
|
+
operation_type: metadata?.operationType ?? null,
|
|
56
|
+
operation_key: metadata?.operationKey ?? null,
|
|
52
57
|
});
|
|
53
58
|
},
|
|
54
59
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest";
|
|
2
2
|
import { createTelemetryCallback } from "./telemetry-utils";
|
|
3
|
+
import { runWithTelemetryContext, setMethodMetadata, } from "./telemetry-context";
|
|
3
4
|
describe("createTelemetryCallback", () => {
|
|
4
5
|
it("should create callback that emits telemetry with explicit method name", () => {
|
|
5
6
|
const mockEmit = vi.fn();
|
|
@@ -19,6 +20,9 @@ describe("createTelemetryCallback", () => {
|
|
|
19
20
|
error_type: null,
|
|
20
21
|
argument_count: 2,
|
|
21
22
|
is_paginated: false,
|
|
23
|
+
selected_api: null,
|
|
24
|
+
operation_type: null,
|
|
25
|
+
operation_key: null,
|
|
22
26
|
});
|
|
23
27
|
});
|
|
24
28
|
it("should include error details when method fails", () => {
|
|
@@ -41,6 +45,9 @@ describe("createTelemetryCallback", () => {
|
|
|
41
45
|
error_type: "Error",
|
|
42
46
|
argument_count: 1,
|
|
43
47
|
is_paginated: false,
|
|
48
|
+
selected_api: null,
|
|
49
|
+
operation_type: null,
|
|
50
|
+
operation_key: null,
|
|
44
51
|
});
|
|
45
52
|
});
|
|
46
53
|
it("should handle paginated method calls", () => {
|
|
@@ -61,6 +68,9 @@ describe("createTelemetryCallback", () => {
|
|
|
61
68
|
error_type: null,
|
|
62
69
|
argument_count: 1,
|
|
63
70
|
is_paginated: true,
|
|
71
|
+
selected_api: null,
|
|
72
|
+
operation_type: null,
|
|
73
|
+
operation_key: null,
|
|
64
74
|
});
|
|
65
75
|
});
|
|
66
76
|
it("should handle custom error types", () => {
|
|
@@ -89,6 +99,57 @@ describe("createTelemetryCallback", () => {
|
|
|
89
99
|
error_type: "CustomError",
|
|
90
100
|
argument_count: 3,
|
|
91
101
|
is_paginated: false,
|
|
102
|
+
selected_api: null,
|
|
103
|
+
operation_type: null,
|
|
104
|
+
operation_key: null,
|
|
92
105
|
});
|
|
93
106
|
});
|
|
107
|
+
it("should include ALS metadata when set", () => {
|
|
108
|
+
const mockEmit = vi.fn();
|
|
109
|
+
const callback = createTelemetryCallback(mockEmit, "runAction");
|
|
110
|
+
runWithTelemetryContext(() => {
|
|
111
|
+
setMethodMetadata({
|
|
112
|
+
selectedApi: "SlackCLIAPI@1.0.0",
|
|
113
|
+
operationType: "write",
|
|
114
|
+
operationKey: "send_message",
|
|
115
|
+
});
|
|
116
|
+
callback.onMethodCalled({
|
|
117
|
+
methodName: "ignoredName",
|
|
118
|
+
durationMs: 100,
|
|
119
|
+
success: true,
|
|
120
|
+
argumentCount: 1,
|
|
121
|
+
isPaginated: false,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
expect(mockEmit).toHaveBeenCalledWith({
|
|
125
|
+
method_name: "runAction",
|
|
126
|
+
execution_duration_ms: 100,
|
|
127
|
+
success_flag: true,
|
|
128
|
+
error_message: null,
|
|
129
|
+
error_type: null,
|
|
130
|
+
argument_count: 1,
|
|
131
|
+
is_paginated: false,
|
|
132
|
+
selected_api: "SlackCLIAPI@1.0.0",
|
|
133
|
+
operation_type: "write",
|
|
134
|
+
operation_key: "send_message",
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
it("should default metadata fields to null when no ALS metadata is set", () => {
|
|
138
|
+
const mockEmit = vi.fn();
|
|
139
|
+
const callback = createTelemetryCallback(mockEmit, "listApps");
|
|
140
|
+
runWithTelemetryContext(() => {
|
|
141
|
+
callback.onMethodCalled({
|
|
142
|
+
methodName: "ignoredName",
|
|
143
|
+
durationMs: 50,
|
|
144
|
+
success: true,
|
|
145
|
+
argumentCount: 0,
|
|
146
|
+
isPaginated: false,
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
|
150
|
+
selected_api: null,
|
|
151
|
+
operation_type: null,
|
|
152
|
+
operation_key: null,
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
94
155
|
});
|