@zapier/zapier-sdk 0.13.6 → 0.13.8
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/api/client.d.ts.map +1 -1
- package/dist/api/client.js +5 -5
- package/dist/api/client.test.d.ts +2 -0
- package/dist/api/client.test.d.ts.map +1 -0
- package/dist/api/client.test.js +80 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -1
- package/dist/api/schemas.d.ts +20 -20
- package/dist/api/types.d.ts +2 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +3 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.test.d.ts +2 -0
- package/dist/auth.test.d.ts.map +1 -0
- package/dist/auth.test.js +102 -0
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/index.cjs +89 -21
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +88 -22
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +4 -1
- package/dist/plugins/eventEmission/index.d.ts +2 -0
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +35 -9
- package/dist/plugins/eventEmission/index.test.js +100 -0
- package/dist/schemas/Action.d.ts +2 -2
- package/dist/schemas/Auth.d.ts +4 -4
- package/dist/schemas/Field.d.ts +10 -10
- package/dist/sdk.test.js +121 -1
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/url-utils.d.ts +19 -0
- package/dist/utils/url-utils.d.ts.map +1 -0
- package/dist/utils/url-utils.js +62 -0
- package/dist/utils/url-utils.test.d.ts +2 -0
- package/dist/utils/url-utils.test.d.ts.map +1 -0
- package/dist/utils/url-utils.test.js +103 -0
- package/package.json +8 -3
- package/src/api/auth.ts +0 -28
- package/src/api/client.ts +0 -491
- package/src/api/debug.test.ts +0 -76
- package/src/api/debug.ts +0 -154
- package/src/api/index.ts +0 -90
- package/src/api/polling.test.ts +0 -405
- package/src/api/polling.ts +0 -253
- package/src/api/schemas.ts +0 -465
- package/src/api/types.ts +0 -152
- package/src/auth.ts +0 -72
- package/src/constants.ts +0 -16
- package/src/index.ts +0 -111
- package/src/plugins/api/index.ts +0 -43
- package/src/plugins/apps/index.ts +0 -203
- package/src/plugins/apps/schemas.ts +0 -64
- package/src/plugins/eventEmission/builders.ts +0 -115
- package/src/plugins/eventEmission/index.test.ts +0 -169
- package/src/plugins/eventEmission/index.ts +0 -294
- package/src/plugins/eventEmission/transport.test.ts +0 -214
- package/src/plugins/eventEmission/transport.ts +0 -135
- package/src/plugins/eventEmission/types.ts +0 -58
- package/src/plugins/eventEmission/utils.ts +0 -121
- package/src/plugins/fetch/index.ts +0 -83
- package/src/plugins/fetch/schemas.ts +0 -37
- package/src/plugins/findFirstAuthentication/index.test.ts +0 -209
- package/src/plugins/findFirstAuthentication/index.ts +0 -68
- package/src/plugins/findFirstAuthentication/schemas.ts +0 -47
- package/src/plugins/findUniqueAuthentication/index.test.ts +0 -197
- package/src/plugins/findUniqueAuthentication/index.ts +0 -77
- package/src/plugins/findUniqueAuthentication/schemas.ts +0 -49
- package/src/plugins/getAction/index.test.ts +0 -239
- package/src/plugins/getAction/index.ts +0 -75
- package/src/plugins/getAction/schemas.ts +0 -41
- package/src/plugins/getApp/index.test.ts +0 -181
- package/src/plugins/getApp/index.ts +0 -60
- package/src/plugins/getApp/schemas.ts +0 -33
- package/src/plugins/getAuthentication/index.test.ts +0 -294
- package/src/plugins/getAuthentication/index.ts +0 -95
- package/src/plugins/getAuthentication/schemas.ts +0 -38
- package/src/plugins/getProfile/index.ts +0 -60
- package/src/plugins/getProfile/schemas.ts +0 -24
- package/src/plugins/listActions/index.test.ts +0 -526
- package/src/plugins/listActions/index.ts +0 -132
- package/src/plugins/listActions/schemas.ts +0 -55
- package/src/plugins/listApps/index.test.ts +0 -378
- package/src/plugins/listApps/index.ts +0 -159
- package/src/plugins/listApps/schemas.ts +0 -41
- package/src/plugins/listAuthentications/index.test.ts +0 -739
- package/src/plugins/listAuthentications/index.ts +0 -152
- package/src/plugins/listAuthentications/schemas.ts +0 -77
- package/src/plugins/listInputFieldChoices/index.test.ts +0 -653
- package/src/plugins/listInputFieldChoices/index.ts +0 -173
- package/src/plugins/listInputFieldChoices/schemas.ts +0 -125
- package/src/plugins/listInputFields/index.test.ts +0 -439
- package/src/plugins/listInputFields/index.ts +0 -294
- package/src/plugins/listInputFields/schemas.ts +0 -68
- package/src/plugins/manifest/index.test.ts +0 -776
- package/src/plugins/manifest/index.ts +0 -461
- package/src/plugins/manifest/schemas.ts +0 -60
- package/src/plugins/registry/index.ts +0 -160
- package/src/plugins/request/index.test.ts +0 -333
- package/src/plugins/request/index.ts +0 -105
- package/src/plugins/request/schemas.ts +0 -69
- package/src/plugins/runAction/index.test.ts +0 -388
- package/src/plugins/runAction/index.ts +0 -215
- package/src/plugins/runAction/schemas.ts +0 -60
- package/src/resolvers/actionKey.ts +0 -37
- package/src/resolvers/actionType.ts +0 -34
- package/src/resolvers/appKey.ts +0 -7
- package/src/resolvers/authenticationId.ts +0 -54
- package/src/resolvers/index.ts +0 -11
- package/src/resolvers/inputFieldKey.ts +0 -70
- package/src/resolvers/inputs.ts +0 -69
- package/src/schemas/Action.ts +0 -52
- package/src/schemas/App.ts +0 -45
- package/src/schemas/Auth.ts +0 -59
- package/src/schemas/Field.ts +0 -169
- package/src/schemas/Run.ts +0 -40
- package/src/schemas/UserProfile.ts +0 -60
- package/src/sdk.test.ts +0 -212
- package/src/sdk.ts +0 -178
- package/src/types/domain.test.ts +0 -50
- package/src/types/domain.ts +0 -66
- package/src/types/errors.ts +0 -278
- package/src/types/events.ts +0 -43
- package/src/types/functions.ts +0 -28
- package/src/types/optional-zapier-sdk-cli-login.d.ts +0 -37
- package/src/types/plugin.ts +0 -125
- package/src/types/properties.ts +0 -80
- package/src/types/sdk.ts +0 -111
- package/src/types/telemetry-events.ts +0 -85
- package/src/utils/array-utils.test.ts +0 -131
- package/src/utils/array-utils.ts +0 -41
- package/src/utils/domain-utils.test.ts +0 -433
- package/src/utils/domain-utils.ts +0 -267
- package/src/utils/file-utils.test.ts +0 -73
- package/src/utils/file-utils.ts +0 -94
- package/src/utils/function-utils.test.ts +0 -141
- package/src/utils/function-utils.ts +0 -245
- package/src/utils/pagination-utils.test.ts +0 -620
- package/src/utils/pagination-utils.ts +0 -242
- package/src/utils/schema-utils.ts +0 -207
- package/src/utils/string-utils.test.ts +0 -45
- package/src/utils/string-utils.ts +0 -54
- package/src/utils/validation.test.ts +0 -51
- package/src/utils/validation.ts +0 -44
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -20
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -23
package/dist/index.cjs
CHANGED
|
@@ -54,8 +54,8 @@ function isPositional(schema) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// src/constants.ts
|
|
57
|
+
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
57
58
|
var MAX_PAGE_LIMIT = 1e4;
|
|
58
|
-
var TRACKING_API_ENDPOINT = "https://zapier.com/api/v4/tracking/event/";
|
|
59
59
|
|
|
60
60
|
// src/types/properties.ts
|
|
61
61
|
var AppKeyPropertySchema = withPositional(
|
|
@@ -3340,7 +3340,10 @@ var ZapierApiClient = class {
|
|
|
3340
3340
|
}
|
|
3341
3341
|
return getTokenFromEnvOrConfig({
|
|
3342
3342
|
onEvent: this.options.onEvent,
|
|
3343
|
-
fetch: this.options.fetch
|
|
3343
|
+
fetch: this.options.fetch,
|
|
3344
|
+
baseUrl: this.options.baseUrl,
|
|
3345
|
+
authBaseUrl: this.options.authBaseUrl,
|
|
3346
|
+
authClientId: this.options.authClientId
|
|
3344
3347
|
});
|
|
3345
3348
|
}
|
|
3346
3349
|
// Helper to handle responses
|
|
@@ -3571,23 +3574,13 @@ var ZapierApiClient = class {
|
|
|
3571
3574
|
}
|
|
3572
3575
|
};
|
|
3573
3576
|
var createZapierApi = (options) => {
|
|
3574
|
-
const {
|
|
3575
|
-
baseUrl,
|
|
3576
|
-
token,
|
|
3577
|
-
getToken,
|
|
3578
|
-
debug = false,
|
|
3579
|
-
fetch: originalFetch = globalThis.fetch,
|
|
3580
|
-
onEvent
|
|
3581
|
-
} = options;
|
|
3577
|
+
const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
|
|
3582
3578
|
const debugLog = createDebugLogger(debug);
|
|
3583
3579
|
const debugFetch = createDebugFetch({ originalFetch, debugLog });
|
|
3584
3580
|
return new ZapierApiClient({
|
|
3585
|
-
|
|
3586
|
-
token,
|
|
3587
|
-
getToken,
|
|
3581
|
+
...options,
|
|
3588
3582
|
debug,
|
|
3589
|
-
fetch: debugFetch
|
|
3590
|
-
onEvent
|
|
3583
|
+
fetch: debugFetch
|
|
3591
3584
|
});
|
|
3592
3585
|
};
|
|
3593
3586
|
|
|
@@ -3595,7 +3588,9 @@ var createZapierApi = (options) => {
|
|
|
3595
3588
|
var apiPlugin = (params) => {
|
|
3596
3589
|
const {
|
|
3597
3590
|
fetch: customFetch = globalThis.fetch,
|
|
3598
|
-
baseUrl =
|
|
3591
|
+
baseUrl = ZAPIER_BASE_URL,
|
|
3592
|
+
authBaseUrl,
|
|
3593
|
+
authClientId,
|
|
3599
3594
|
token,
|
|
3600
3595
|
getToken,
|
|
3601
3596
|
onEvent,
|
|
@@ -3603,6 +3598,8 @@ var apiPlugin = (params) => {
|
|
|
3603
3598
|
} = params.context.options;
|
|
3604
3599
|
const api = createZapierApi({
|
|
3605
3600
|
baseUrl,
|
|
3601
|
+
authBaseUrl,
|
|
3602
|
+
authClientId,
|
|
3606
3603
|
token,
|
|
3607
3604
|
getToken,
|
|
3608
3605
|
debug,
|
|
@@ -4000,7 +3997,7 @@ function getCpuTime() {
|
|
|
4000
3997
|
|
|
4001
3998
|
// package.json
|
|
4002
3999
|
var package_default = {
|
|
4003
|
-
version: "0.13.
|
|
4000
|
+
version: "0.13.8"};
|
|
4004
4001
|
|
|
4005
4002
|
// src/plugins/eventEmission/builders.ts
|
|
4006
4003
|
function createBaseEvent(context = {}) {
|
|
@@ -4070,17 +4067,80 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4070
4067
|
};
|
|
4071
4068
|
}
|
|
4072
4069
|
|
|
4070
|
+
// src/utils/url-utils.ts
|
|
4071
|
+
function getZapierBaseUrl(baseUrl) {
|
|
4072
|
+
if (!baseUrl) {
|
|
4073
|
+
return void 0;
|
|
4074
|
+
}
|
|
4075
|
+
try {
|
|
4076
|
+
const url = new URL(baseUrl);
|
|
4077
|
+
const hostname = url.hostname;
|
|
4078
|
+
const hostParts = hostname.split(".");
|
|
4079
|
+
if (hostParts.length < 2) {
|
|
4080
|
+
return void 0;
|
|
4081
|
+
}
|
|
4082
|
+
const hasZapierPart = hostParts.some(
|
|
4083
|
+
(part) => part === "zapier" || part.startsWith("zapier-")
|
|
4084
|
+
);
|
|
4085
|
+
if (!hasZapierPart) {
|
|
4086
|
+
return void 0;
|
|
4087
|
+
}
|
|
4088
|
+
const rootDomain = hostParts.slice(-2).join(".");
|
|
4089
|
+
return `${url.protocol}//${rootDomain}`;
|
|
4090
|
+
} catch {
|
|
4091
|
+
return void 0;
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
function getTrackingBaseUrl({
|
|
4095
|
+
trackingBaseUrl,
|
|
4096
|
+
baseUrl
|
|
4097
|
+
}) {
|
|
4098
|
+
if (trackingBaseUrl) {
|
|
4099
|
+
return trackingBaseUrl;
|
|
4100
|
+
}
|
|
4101
|
+
if (process.env.ZAPIER_TRACKING_BASE_URL) {
|
|
4102
|
+
return process.env.ZAPIER_TRACKING_BASE_URL;
|
|
4103
|
+
}
|
|
4104
|
+
if (baseUrl) {
|
|
4105
|
+
const zapierBaseUrl = getZapierBaseUrl(baseUrl);
|
|
4106
|
+
if (zapierBaseUrl) {
|
|
4107
|
+
return zapierBaseUrl;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
if (baseUrl) {
|
|
4111
|
+
return baseUrl;
|
|
4112
|
+
}
|
|
4113
|
+
return ZAPIER_BASE_URL;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4073
4116
|
// src/plugins/eventEmission/index.ts
|
|
4074
4117
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4075
4118
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
4119
|
+
var transportStates = /* @__PURE__ */ new WeakMap();
|
|
4076
4120
|
async function silentEmit(transport, subject, event) {
|
|
4077
4121
|
try {
|
|
4078
|
-
|
|
4122
|
+
let state = transportStates.get(transport);
|
|
4123
|
+
if (!state) {
|
|
4124
|
+
state = { hasWorked: false, hasLoggedFailure: false };
|
|
4125
|
+
transportStates.set(transport, state);
|
|
4126
|
+
}
|
|
4127
|
+
transport.emit(subject, event).then(() => {
|
|
4128
|
+
state.hasWorked = true;
|
|
4129
|
+
}).catch((error) => {
|
|
4130
|
+
if (!state.hasWorked && !state.hasLoggedFailure) {
|
|
4131
|
+
state.hasLoggedFailure = true;
|
|
4132
|
+
console.warn(
|
|
4133
|
+
`[zapier-sdk] Tracking failed: ${error.message || "Unknown error"}`
|
|
4134
|
+
);
|
|
4135
|
+
console.warn(
|
|
4136
|
+
`[zapier-sdk] Hint: Set trackingBaseUrl parameter or ZAPIER_TRACKING_BASE_URL environment variable if using custom domains`
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
4079
4139
|
});
|
|
4080
4140
|
} catch {
|
|
4081
4141
|
}
|
|
4082
4142
|
}
|
|
4083
|
-
function getTransportConfig() {
|
|
4143
|
+
function getTransportConfig(options) {
|
|
4084
4144
|
const envTransport = process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
|
|
4085
4145
|
if (envTransport === "noop" || envTransport === "disabled") {
|
|
4086
4146
|
return { type: "noop" };
|
|
@@ -4088,14 +4148,20 @@ function getTransportConfig() {
|
|
|
4088
4148
|
if (envTransport === "console") {
|
|
4089
4149
|
return { type: "console" };
|
|
4090
4150
|
}
|
|
4091
|
-
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT ||
|
|
4151
|
+
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || `${getTrackingBaseUrl({
|
|
4152
|
+
trackingBaseUrl: options?.trackingBaseUrl,
|
|
4153
|
+
baseUrl: options?.baseUrl
|
|
4154
|
+
})}/api/v4/tracking/event/`;
|
|
4092
4155
|
return {
|
|
4093
4156
|
type: "http",
|
|
4094
4157
|
endpoint
|
|
4095
4158
|
};
|
|
4096
4159
|
}
|
|
4097
4160
|
var eventEmissionPlugin = ({ context }) => {
|
|
4098
|
-
const defaultTransport = getTransportConfig(
|
|
4161
|
+
const defaultTransport = getTransportConfig({
|
|
4162
|
+
trackingBaseUrl: context.options.trackingBaseUrl,
|
|
4163
|
+
baseUrl: context.options.baseUrl
|
|
4164
|
+
});
|
|
4099
4165
|
const config = {
|
|
4100
4166
|
enabled: context.options.eventEmission?.enabled ?? true,
|
|
4101
4167
|
transport: (
|
|
@@ -4307,11 +4373,13 @@ exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
|
|
|
4307
4373
|
exports.DebugPropertySchema = DebugPropertySchema;
|
|
4308
4374
|
exports.InputsPropertySchema = InputsPropertySchema;
|
|
4309
4375
|
exports.LimitPropertySchema = LimitPropertySchema;
|
|
4376
|
+
exports.MAX_PAGE_LIMIT = MAX_PAGE_LIMIT;
|
|
4310
4377
|
exports.OffsetPropertySchema = OffsetPropertySchema;
|
|
4311
4378
|
exports.OutputPropertySchema = OutputPropertySchema;
|
|
4312
4379
|
exports.ParamsPropertySchema = ParamsPropertySchema;
|
|
4313
4380
|
exports.RelayFetchSchema = RelayFetchSchema;
|
|
4314
4381
|
exports.RelayRequestSchema = RelayRequestSchema;
|
|
4382
|
+
exports.ZAPIER_BASE_URL = ZAPIER_BASE_URL;
|
|
4315
4383
|
exports.ZapierActionError = ZapierActionError;
|
|
4316
4384
|
exports.ZapierApiError = ZapierApiError;
|
|
4317
4385
|
exports.ZapierAppNotFoundError = ZapierAppNotFoundError;
|
package/dist/index.d.mts
CHANGED
|
@@ -2268,6 +2268,9 @@ interface BaseSdkOptions {
|
|
|
2268
2268
|
onEvent?: EventCallback;
|
|
2269
2269
|
fetch?: typeof fetch;
|
|
2270
2270
|
baseUrl?: string;
|
|
2271
|
+
authBaseUrl?: string;
|
|
2272
|
+
authClientId?: string;
|
|
2273
|
+
trackingBaseUrl?: string;
|
|
2271
2274
|
debug?: boolean;
|
|
2272
2275
|
manifestPath?: string;
|
|
2273
2276
|
manifest?: Manifest;
|
|
@@ -3191,6 +3194,9 @@ declare const inputFieldKeyResolver: DynamicResolver<InputFieldItem$1, {
|
|
|
3191
3194
|
interface AuthOptions {
|
|
3192
3195
|
onEvent?: EventCallback;
|
|
3193
3196
|
fetch?: typeof globalThis.fetch;
|
|
3197
|
+
baseUrl?: string;
|
|
3198
|
+
authBaseUrl?: string;
|
|
3199
|
+
authClientId?: string;
|
|
3194
3200
|
}
|
|
3195
3201
|
/**
|
|
3196
3202
|
* Gets the ZAPIER_TOKEN from environment variables.
|
|
@@ -3213,6 +3219,20 @@ declare function getTokenFromCliLogin(options?: AuthOptions): Promise<string | u
|
|
|
3213
3219
|
*/
|
|
3214
3220
|
declare function getTokenFromEnvOrConfig(options?: AuthOptions): Promise<string | undefined>;
|
|
3215
3221
|
|
|
3222
|
+
/**
|
|
3223
|
+
* SDK Constants
|
|
3224
|
+
*
|
|
3225
|
+
* This module contains shared constants used throughout the SDK.
|
|
3226
|
+
*/
|
|
3227
|
+
/**
|
|
3228
|
+
* Base URL for Zapier API endpoints
|
|
3229
|
+
*/
|
|
3230
|
+
declare const ZAPIER_BASE_URL: string;
|
|
3231
|
+
/**
|
|
3232
|
+
* Maximum number of items that can be requested per page across all paginated functions
|
|
3233
|
+
*/
|
|
3234
|
+
declare const MAX_PAGE_LIMIT = 10000;
|
|
3235
|
+
|
|
3216
3236
|
interface ZapierSdkOptions extends BaseSdkOptions {
|
|
3217
3237
|
}
|
|
3218
3238
|
declare function createSdk<TCurrentSdk = {}, TCurrentContext extends {
|
|
@@ -3326,4 +3346,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
|
|
|
3326
3346
|
}>;
|
|
3327
3347
|
declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
|
|
3328
3348
|
|
|
3329
|
-
export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type BaseEvent, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UpdateManifestEntryOptions, type UserProfile, type UserProfileItem, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
|
3349
|
+
export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type BaseEvent, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UpdateManifestEntryOptions, type UserProfile, type UserProfileItem, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type { FormattedItem, FormatMetadata } from "./utils/schema-utils";
|
|
|
25
25
|
export { toSnakeCase, toTitleCase } from "./utils/string-utils";
|
|
26
26
|
export * from "./resolvers";
|
|
27
27
|
export * from "./auth";
|
|
28
|
+
export * from "./constants";
|
|
28
29
|
export { RelayRequestSchema, RelayFetchSchema, } from "./plugins/request/schemas";
|
|
29
30
|
export { createZapierSdk, createZapierSdkWithoutRegistry, createSdk, ZapierSdkOptions, } from "./sdk";
|
|
30
31
|
export type { FunctionRegistryEntry } from "./types/sdk";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CA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AAE,MAAM,aAAa,CAAC;AAG7C,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,IAAI,EACJ,aAAa,EACb,cAAc,EACd,UAAU,EACV,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,8 @@ export { toSnakeCase, toTitleCase } from "./utils/string-utils";
|
|
|
28
28
|
export * from "./resolvers";
|
|
29
29
|
// Export auth utilities for CLI use
|
|
30
30
|
export * from "./auth";
|
|
31
|
+
// Export constants
|
|
32
|
+
export * from "./constants";
|
|
31
33
|
// All functions now available through the plugin system via createZapierSdk()
|
|
32
34
|
// Export plugin schemas for external use
|
|
33
35
|
export { RelayRequestSchema, RelayFetchSchema, } from "./plugins/request/schemas";
|
package/dist/index.mjs
CHANGED
|
@@ -32,8 +32,8 @@ function isPositional(schema) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// src/constants.ts
|
|
35
|
+
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
35
36
|
var MAX_PAGE_LIMIT = 1e4;
|
|
36
|
-
var TRACKING_API_ENDPOINT = "https://zapier.com/api/v4/tracking/event/";
|
|
37
37
|
|
|
38
38
|
// src/types/properties.ts
|
|
39
39
|
var AppKeyPropertySchema = withPositional(
|
|
@@ -3318,7 +3318,10 @@ var ZapierApiClient = class {
|
|
|
3318
3318
|
}
|
|
3319
3319
|
return getTokenFromEnvOrConfig({
|
|
3320
3320
|
onEvent: this.options.onEvent,
|
|
3321
|
-
fetch: this.options.fetch
|
|
3321
|
+
fetch: this.options.fetch,
|
|
3322
|
+
baseUrl: this.options.baseUrl,
|
|
3323
|
+
authBaseUrl: this.options.authBaseUrl,
|
|
3324
|
+
authClientId: this.options.authClientId
|
|
3322
3325
|
});
|
|
3323
3326
|
}
|
|
3324
3327
|
// Helper to handle responses
|
|
@@ -3549,23 +3552,13 @@ var ZapierApiClient = class {
|
|
|
3549
3552
|
}
|
|
3550
3553
|
};
|
|
3551
3554
|
var createZapierApi = (options) => {
|
|
3552
|
-
const {
|
|
3553
|
-
baseUrl,
|
|
3554
|
-
token,
|
|
3555
|
-
getToken,
|
|
3556
|
-
debug = false,
|
|
3557
|
-
fetch: originalFetch = globalThis.fetch,
|
|
3558
|
-
onEvent
|
|
3559
|
-
} = options;
|
|
3555
|
+
const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
|
|
3560
3556
|
const debugLog = createDebugLogger(debug);
|
|
3561
3557
|
const debugFetch = createDebugFetch({ originalFetch, debugLog });
|
|
3562
3558
|
return new ZapierApiClient({
|
|
3563
|
-
|
|
3564
|
-
token,
|
|
3565
|
-
getToken,
|
|
3559
|
+
...options,
|
|
3566
3560
|
debug,
|
|
3567
|
-
fetch: debugFetch
|
|
3568
|
-
onEvent
|
|
3561
|
+
fetch: debugFetch
|
|
3569
3562
|
});
|
|
3570
3563
|
};
|
|
3571
3564
|
|
|
@@ -3573,7 +3566,9 @@ var createZapierApi = (options) => {
|
|
|
3573
3566
|
var apiPlugin = (params) => {
|
|
3574
3567
|
const {
|
|
3575
3568
|
fetch: customFetch = globalThis.fetch,
|
|
3576
|
-
baseUrl =
|
|
3569
|
+
baseUrl = ZAPIER_BASE_URL,
|
|
3570
|
+
authBaseUrl,
|
|
3571
|
+
authClientId,
|
|
3577
3572
|
token,
|
|
3578
3573
|
getToken,
|
|
3579
3574
|
onEvent,
|
|
@@ -3581,6 +3576,8 @@ var apiPlugin = (params) => {
|
|
|
3581
3576
|
} = params.context.options;
|
|
3582
3577
|
const api = createZapierApi({
|
|
3583
3578
|
baseUrl,
|
|
3579
|
+
authBaseUrl,
|
|
3580
|
+
authClientId,
|
|
3584
3581
|
token,
|
|
3585
3582
|
getToken,
|
|
3586
3583
|
debug,
|
|
@@ -3978,7 +3975,7 @@ function getCpuTime() {
|
|
|
3978
3975
|
|
|
3979
3976
|
// package.json
|
|
3980
3977
|
var package_default = {
|
|
3981
|
-
version: "0.13.
|
|
3978
|
+
version: "0.13.8"};
|
|
3982
3979
|
|
|
3983
3980
|
// src/plugins/eventEmission/builders.ts
|
|
3984
3981
|
function createBaseEvent(context = {}) {
|
|
@@ -4048,17 +4045,80 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4048
4045
|
};
|
|
4049
4046
|
}
|
|
4050
4047
|
|
|
4048
|
+
// src/utils/url-utils.ts
|
|
4049
|
+
function getZapierBaseUrl(baseUrl) {
|
|
4050
|
+
if (!baseUrl) {
|
|
4051
|
+
return void 0;
|
|
4052
|
+
}
|
|
4053
|
+
try {
|
|
4054
|
+
const url = new URL(baseUrl);
|
|
4055
|
+
const hostname = url.hostname;
|
|
4056
|
+
const hostParts = hostname.split(".");
|
|
4057
|
+
if (hostParts.length < 2) {
|
|
4058
|
+
return void 0;
|
|
4059
|
+
}
|
|
4060
|
+
const hasZapierPart = hostParts.some(
|
|
4061
|
+
(part) => part === "zapier" || part.startsWith("zapier-")
|
|
4062
|
+
);
|
|
4063
|
+
if (!hasZapierPart) {
|
|
4064
|
+
return void 0;
|
|
4065
|
+
}
|
|
4066
|
+
const rootDomain = hostParts.slice(-2).join(".");
|
|
4067
|
+
return `${url.protocol}//${rootDomain}`;
|
|
4068
|
+
} catch {
|
|
4069
|
+
return void 0;
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
function getTrackingBaseUrl({
|
|
4073
|
+
trackingBaseUrl,
|
|
4074
|
+
baseUrl
|
|
4075
|
+
}) {
|
|
4076
|
+
if (trackingBaseUrl) {
|
|
4077
|
+
return trackingBaseUrl;
|
|
4078
|
+
}
|
|
4079
|
+
if (process.env.ZAPIER_TRACKING_BASE_URL) {
|
|
4080
|
+
return process.env.ZAPIER_TRACKING_BASE_URL;
|
|
4081
|
+
}
|
|
4082
|
+
if (baseUrl) {
|
|
4083
|
+
const zapierBaseUrl = getZapierBaseUrl(baseUrl);
|
|
4084
|
+
if (zapierBaseUrl) {
|
|
4085
|
+
return zapierBaseUrl;
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
if (baseUrl) {
|
|
4089
|
+
return baseUrl;
|
|
4090
|
+
}
|
|
4091
|
+
return ZAPIER_BASE_URL;
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4051
4094
|
// src/plugins/eventEmission/index.ts
|
|
4052
4095
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4053
4096
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
4097
|
+
var transportStates = /* @__PURE__ */ new WeakMap();
|
|
4054
4098
|
async function silentEmit(transport, subject, event) {
|
|
4055
4099
|
try {
|
|
4056
|
-
|
|
4100
|
+
let state = transportStates.get(transport);
|
|
4101
|
+
if (!state) {
|
|
4102
|
+
state = { hasWorked: false, hasLoggedFailure: false };
|
|
4103
|
+
transportStates.set(transport, state);
|
|
4104
|
+
}
|
|
4105
|
+
transport.emit(subject, event).then(() => {
|
|
4106
|
+
state.hasWorked = true;
|
|
4107
|
+
}).catch((error) => {
|
|
4108
|
+
if (!state.hasWorked && !state.hasLoggedFailure) {
|
|
4109
|
+
state.hasLoggedFailure = true;
|
|
4110
|
+
console.warn(
|
|
4111
|
+
`[zapier-sdk] Tracking failed: ${error.message || "Unknown error"}`
|
|
4112
|
+
);
|
|
4113
|
+
console.warn(
|
|
4114
|
+
`[zapier-sdk] Hint: Set trackingBaseUrl parameter or ZAPIER_TRACKING_BASE_URL environment variable if using custom domains`
|
|
4115
|
+
);
|
|
4116
|
+
}
|
|
4057
4117
|
});
|
|
4058
4118
|
} catch {
|
|
4059
4119
|
}
|
|
4060
4120
|
}
|
|
4061
|
-
function getTransportConfig() {
|
|
4121
|
+
function getTransportConfig(options) {
|
|
4062
4122
|
const envTransport = process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
|
|
4063
4123
|
if (envTransport === "noop" || envTransport === "disabled") {
|
|
4064
4124
|
return { type: "noop" };
|
|
@@ -4066,14 +4126,20 @@ function getTransportConfig() {
|
|
|
4066
4126
|
if (envTransport === "console") {
|
|
4067
4127
|
return { type: "console" };
|
|
4068
4128
|
}
|
|
4069
|
-
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT ||
|
|
4129
|
+
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || `${getTrackingBaseUrl({
|
|
4130
|
+
trackingBaseUrl: options?.trackingBaseUrl,
|
|
4131
|
+
baseUrl: options?.baseUrl
|
|
4132
|
+
})}/api/v4/tracking/event/`;
|
|
4070
4133
|
return {
|
|
4071
4134
|
type: "http",
|
|
4072
4135
|
endpoint
|
|
4073
4136
|
};
|
|
4074
4137
|
}
|
|
4075
4138
|
var eventEmissionPlugin = ({ context }) => {
|
|
4076
|
-
const defaultTransport = getTransportConfig(
|
|
4139
|
+
const defaultTransport = getTransportConfig({
|
|
4140
|
+
trackingBaseUrl: context.options.trackingBaseUrl,
|
|
4141
|
+
baseUrl: context.options.baseUrl
|
|
4142
|
+
});
|
|
4077
4143
|
const config = {
|
|
4078
4144
|
enabled: context.options.eventEmission?.enabled ?? true,
|
|
4079
4145
|
transport: (
|
|
@@ -4277,4 +4343,4 @@ function createZapierSdk(options = {}) {
|
|
|
4277
4343
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
4278
4344
|
}
|
|
4279
4345
|
|
|
4280
|
-
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
|
4346
|
+
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;KAChB,CAAC;CACH;AAGD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,iBAAiB,CA+BvD,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createZapierApi } from "../../api";
|
|
2
|
+
import { ZAPIER_BASE_URL } from "../../constants";
|
|
2
3
|
// API plugin requires no context and provides api in context
|
|
3
4
|
export const apiPlugin = (params) => {
|
|
4
5
|
// Extract all options - everything passed to the plugin
|
|
5
|
-
const { fetch: customFetch = globalThis.fetch, baseUrl =
|
|
6
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, authBaseUrl, authClientId, token, getToken, onEvent, debug = false, } = params.context.options;
|
|
6
7
|
// Create the API client - it will handle token resolution internally
|
|
7
8
|
const api = createZapierApi({
|
|
8
9
|
baseUrl,
|
|
10
|
+
authBaseUrl,
|
|
11
|
+
authClientId,
|
|
9
12
|
token,
|
|
10
13
|
getToken,
|
|
11
14
|
debug,
|
|
@@ -25,6 +25,8 @@ export interface EventEmissionProvides {
|
|
|
25
25
|
export declare const eventEmissionPlugin: Plugin<{}, {
|
|
26
26
|
options: {
|
|
27
27
|
eventEmission?: EventEmissionConfig;
|
|
28
|
+
trackingBaseUrl?: string;
|
|
29
|
+
baseUrl?: string;
|
|
28
30
|
};
|
|
29
31
|
}, EventEmissionProvides>;
|
|
30
32
|
export type { EventContext, ApplicationLifecycleEventData, EnhancedErrorEventData, } from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAUnE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,E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E,MAAM,CAAC;KAClB,CAAC;CACH,EACD,qBAAqB,CAoMtB,CAAC;AAGF,YAAY,EACV,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
|
|
@@ -7,23 +7,42 @@
|
|
|
7
7
|
import { createTransport } from "./transport";
|
|
8
8
|
import { generateEventId, getCurrentTimestamp, getReleaseId } from "./utils";
|
|
9
9
|
import { buildApplicationLifecycleEvent, buildErrorEventWithContext, } from "./builders";
|
|
10
|
-
import {
|
|
10
|
+
import { getTrackingBaseUrl } from "../../utils/url-utils";
|
|
11
11
|
const APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
12
12
|
const ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
13
|
-
//
|
|
13
|
+
// Track transport success/failure so we only log failure once.
|
|
14
|
+
const transportStates = new WeakMap();
|
|
15
|
+
// Silent emission wrapper with smart first-failure logging
|
|
14
16
|
async function silentEmit(transport, subject, event) {
|
|
15
17
|
try {
|
|
18
|
+
// Get or initialize state for this transport
|
|
19
|
+
let state = transportStates.get(transport);
|
|
20
|
+
if (!state) {
|
|
21
|
+
state = { hasWorked: false, hasLoggedFailure: false };
|
|
22
|
+
transportStates.set(transport, state);
|
|
23
|
+
}
|
|
16
24
|
// Fire and forget - don't await the transport
|
|
17
|
-
transport
|
|
18
|
-
|
|
25
|
+
transport
|
|
26
|
+
.emit(subject, event)
|
|
27
|
+
.then(() => {
|
|
28
|
+
// Mark as working if any emit succeeds
|
|
29
|
+
state.hasWorked = true;
|
|
30
|
+
})
|
|
31
|
+
.catch((error) => {
|
|
32
|
+
// Only log if we haven't seen it work and haven't logged yet
|
|
33
|
+
if (!state.hasWorked && !state.hasLoggedFailure) {
|
|
34
|
+
state.hasLoggedFailure = true;
|
|
35
|
+
console.warn(`[zapier-sdk] Tracking failed: ${error.message || "Unknown error"}`);
|
|
36
|
+
console.warn(`[zapier-sdk] Hint: Set trackingBaseUrl parameter or ZAPIER_TRACKING_BASE_URL environment variable if using custom domains`);
|
|
37
|
+
}
|
|
19
38
|
});
|
|
20
39
|
}
|
|
21
40
|
catch {
|
|
22
41
|
// Silently ignore all errors
|
|
23
42
|
}
|
|
24
43
|
}
|
|
25
|
-
// Helper to get transport config from environment or
|
|
26
|
-
function getTransportConfig() {
|
|
44
|
+
// Helper to get transport config from environment or options
|
|
45
|
+
function getTransportConfig(options) {
|
|
27
46
|
const envTransport = process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
|
|
28
47
|
if (envTransport === "noop" || envTransport === "disabled") {
|
|
29
48
|
return { type: "noop" };
|
|
@@ -31,15 +50,22 @@ function getTransportConfig() {
|
|
|
31
50
|
if (envTransport === "console") {
|
|
32
51
|
return { type: "console" };
|
|
33
52
|
}
|
|
34
|
-
// Default to HTTP transport
|
|
35
|
-
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT ||
|
|
53
|
+
// Default to HTTP transport with resolved tracking URL
|
|
54
|
+
const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT ||
|
|
55
|
+
`${getTrackingBaseUrl({
|
|
56
|
+
trackingBaseUrl: options?.trackingBaseUrl,
|
|
57
|
+
baseUrl: options?.baseUrl,
|
|
58
|
+
})}/api/v4/tracking/event/`;
|
|
36
59
|
return {
|
|
37
60
|
type: "http",
|
|
38
61
|
endpoint,
|
|
39
62
|
};
|
|
40
63
|
}
|
|
41
64
|
export const eventEmissionPlugin = ({ context }) => {
|
|
42
|
-
const defaultTransport = getTransportConfig(
|
|
65
|
+
const defaultTransport = getTransportConfig({
|
|
66
|
+
trackingBaseUrl: context.options.trackingBaseUrl,
|
|
67
|
+
baseUrl: context.options.baseUrl,
|
|
68
|
+
});
|
|
43
69
|
// Merge config: env var takes precedence over options, options take precedence over defaults
|
|
44
70
|
const config = {
|
|
45
71
|
enabled: context.options.eventEmission?.enabled ?? true,
|