@zapier/zapier-sdk 0.31.4 → 0.32.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - c7be13e: Fix bug where `add` command hangs after completing successfully
8
+
9
+ ## 0.32.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 250cb7d: Store CLI login credentials in system keychain.
14
+
3
15
  ## 0.31.4
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -4,8 +4,9 @@
4
4
 
5
5
  - [Closed Beta](#closed-beta)
6
6
  - [Documentation](#documentation)
7
- - [Installation](#installation)
8
7
  - [Quick Start](#quick-start)
8
+ - [Installation](#installation)
9
+ - [Walkthrough](#walkthrough)
9
10
  - [Factory](#factory)
10
11
  - [Available Functions](#available-functions)
11
12
  - [Accounts](#accounts)
@@ -50,20 +51,32 @@ While the dust settles, that documentation may be incomplete, and this README ma
50
51
 
51
52
  Agents are sometimes blocked from viewing docs on npm, so you may want to provide them a link to the official docs or copy the docs here into a prompt.
52
53
 
53
- ## Installation
54
+ ## Quick Start
55
+
56
+ _For new projects._
57
+
58
+ The following will create a new project from scratch, set up the SDK and the SDK CLI, and give you a working starter example to get you going:
54
59
 
55
60
  ```bash
56
- # If you're starting a new project:
57
- cd your-project-dir
58
- npm init -y
59
- npx tsc --init
60
- # Also, set `"type": "module"` in your package.json for the code examples below.
61
+ # Create a new Zapier SDK project (scaffolds files, installs deps, and logs you in).
62
+ npx @zapier/zapier-sdk-cli init my-zapier-app
63
+
64
+ # Or skip the interactive prompts and accept all defaults.
65
+ npx @zapier/zapier-sdk-cli init my-zapier-app --skip-prompts
66
+ ```
67
+
68
+ ## Installation
69
+
70
+ _For existing projects._
61
71
 
72
+ If you already have a project and want to start integrating apps through Zapier using the SDK:
73
+
74
+ ```bash
62
75
  npm install @zapier/zapier-sdk
63
76
  npm install -D @zapier/zapier-sdk-cli @types/node typescript
64
77
  ```
65
78
 
66
- ## Quick Start
79
+ ## Walkthrough
67
80
 
68
81
  Assuming you've installed the CLI package into your project (see instructions above), you (or an agent) can start using it right away. This is useful for introspecting actions, connections, etc. that you want to use in code, but you can also use it to directly use integrations.
69
82
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AA2oBjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AA4oBjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
@@ -420,7 +420,8 @@ class ZapierApiClient {
420
420
  // If we know auth is required, and we don't have a token, throw an error
421
421
  // before we even make a request.
422
422
  if (options.authRequired) {
423
- if (headers.get("Authorization") == null && authToken == null) {
423
+ const authHeaderName = pathConfig?.authHeader ?? "Authorization";
424
+ if (headers.get(authHeaderName) == null && authToken == null) {
424
425
  const message = isCliLoginAvailable() === false
425
426
  ? "Authentication required but no credentials available. " +
426
427
  "To use CLI login, install the CLI as a dev dependency " +
@@ -43,8 +43,8 @@ export declare const NeedSchema: z.ZodObject<{
43
43
  string: "string";
44
44
  boolean: "boolean";
45
45
  file: "file";
46
- filter: "filter";
47
46
  integer: "integer";
47
+ filter: "filter";
48
48
  text: "text";
49
49
  datetime: "datetime";
50
50
  decimal: "decimal";
@@ -65,8 +65,8 @@ export declare const ActionPermissionsSchema: z.ZodObject<{
65
65
  export declare const ActionSchema: z.ZodObject<{
66
66
  id: z.ZodOptional<z.ZodString>;
67
67
  type: z.ZodEnum<{
68
- filter: "filter";
69
68
  search: "search";
69
+ filter: "filter";
70
70
  read: "read";
71
71
  read_bulk: "read_bulk";
72
72
  run: "run";
@@ -287,8 +287,8 @@ export declare const NeedsResponseSchema: z.ZodObject<{
287
287
  string: "string";
288
288
  boolean: "boolean";
289
289
  file: "file";
290
- filter: "filter";
291
290
  integer: "integer";
291
+ filter: "filter";
292
292
  text: "text";
293
293
  datetime: "datetime";
294
294
  decimal: "decimal";
@@ -312,8 +312,8 @@ export declare const ImplementationSchema: z.ZodObject<{
312
312
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
313
313
  id: z.ZodOptional<z.ZodString>;
314
314
  type: z.ZodEnum<{
315
- filter: "filter";
316
315
  search: "search";
316
+ filter: "filter";
317
317
  read: "read";
318
318
  read_bulk: "read_bulk";
319
319
  run: "run";
@@ -354,8 +354,8 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
354
354
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
355
355
  id: z.ZodOptional<z.ZodString>;
356
356
  type: z.ZodEnum<{
357
- filter: "filter";
358
357
  search: "search";
358
+ filter: "filter";
359
359
  read: "read";
360
360
  read_bulk: "read_bulk";
361
361
  run: "run";
package/dist/auth.d.ts CHANGED
@@ -55,6 +55,12 @@ interface CliLoginOptions {
55
55
  };
56
56
  debug?: boolean;
57
57
  }
58
+ type CliLoginModule = typeof import("@zapier/zapier-sdk-cli-login");
59
+ /**
60
+ * Inject an already-loaded CLI login module so the SDK skips its dynamic import.
61
+ * This guarantees CLI and SDK share the same module instance in the same process.
62
+ */
63
+ export declare function injectCliLogin(module: CliLoginModule): void;
58
64
  /**
59
65
  * Returns whether a CLI login package is available.
60
66
  * `undefined` if no import has been attempted yet, `true` if found, `false` if not.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;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W,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhB"}
package/dist/auth.js CHANGED
@@ -201,6 +201,13 @@ async function getCliLogin() {
201
201
  return undefined;
202
202
  }
203
203
  }
204
+ /**
205
+ * Inject an already-loaded CLI login module so the SDK skips its dynamic import.
206
+ * This guarantees CLI and SDK share the same module instance in the same process.
207
+ */
208
+ export function injectCliLogin(module) {
209
+ cachedCliLogin = module;
210
+ }
204
211
  /**
205
212
  * Returns whether a CLI login package is available.
206
213
  * `undefined` if no import has been attempted yet, `true` if found, `false` if not.
package/dist/index.cjs CHANGED
@@ -4303,6 +4303,9 @@ async function getCliLogin() {
4303
4303
  return void 0;
4304
4304
  }
4305
4305
  }
4306
+ function injectCliLogin(module) {
4307
+ cachedCliLogin = module;
4308
+ }
4306
4309
  function isCliLoginAvailable() {
4307
4310
  if (cachedCliLogin === void 0) return void 0;
4308
4311
  return cachedCliLogin !== false;
@@ -4734,7 +4737,8 @@ var ZapierApiClient = class {
4734
4737
  headers.set(authHeaderName, getAuthorizationHeader(authToken));
4735
4738
  }
4736
4739
  if (options.authRequired) {
4737
- if (headers.get("Authorization") == null && authToken == null) {
4740
+ const authHeaderName = pathConfig2?.authHeader ?? "Authorization";
4741
+ if (headers.get(authHeaderName) == null && authToken == null) {
4738
4742
  const message = isCliLoginAvailable() === false ? "Authentication required but no credentials available. To use CLI login, install the CLI as a dev dependency (e.g. `npm install -D @zapier/zapier-sdk-cli`) and log in (e.g. `npx zapier-sdk login`). Alternatively, set the ZAPIER_CREDENTIALS environment variable or ZAPIER_CREDENTIALS_CLIENT_ID and ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables." : "Authentication required but no credentials available. Please log in (e.g. `npx zapier-sdk login`) or set the ZAPIER_CREDENTIALS environment variable or ZAPIER_CREDENTIALS_CLIENT_ID and ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables.";
4739
4743
  throw new ZapierAuthenticationError(message);
4740
4744
  }
@@ -5499,7 +5503,7 @@ function getCpuTime() {
5499
5503
 
5500
5504
  // package.json
5501
5505
  var package_default = {
5502
- version: "0.31.4"};
5506
+ version: "0.32.1"};
5503
5507
 
5504
5508
  // src/plugins/eventEmission/builders.ts
5505
5509
  function createBaseEvent(context = {}) {
@@ -5623,6 +5627,20 @@ var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEven
5623
5627
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
5624
5628
  var METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
5625
5629
  var transportStates = /* @__PURE__ */ new WeakMap();
5630
+ async function emitWithTimeout(transport, subject, event) {
5631
+ try {
5632
+ await Promise.race([
5633
+ transport.emit(subject, event),
5634
+ new Promise((resolve2) => {
5635
+ const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5636
+ if (typeof timer.unref === "function") {
5637
+ timer.unref();
5638
+ }
5639
+ })
5640
+ ]);
5641
+ } catch {
5642
+ }
5643
+ }
5626
5644
  async function silentEmit(transport, subject, event, userContextPromise) {
5627
5645
  try {
5628
5646
  let state = transportStates.get(transport);
@@ -5701,6 +5719,7 @@ var eventEmissionPlugin = ({ context }) => {
5701
5719
  })();
5702
5720
  const startupTime = Date.now();
5703
5721
  let shutdownStartTime = null;
5722
+ let closed = false;
5704
5723
  if (!config.enabled) {
5705
5724
  return {
5706
5725
  context: {
@@ -5720,6 +5739,8 @@ var eventEmissionPlugin = ({ context }) => {
5720
5739
  correlation_id: null
5721
5740
  }),
5722
5741
  emitMethodCalled: () => {
5742
+ },
5743
+ close: async () => {
5723
5744
  }
5724
5745
  }
5725
5746
  }
@@ -5762,6 +5783,7 @@ var eventEmissionPlugin = ({ context }) => {
5762
5783
  if (typeof process?.on === "function") {
5763
5784
  removeExistingListeners();
5764
5785
  const exitHandler = (code) => {
5786
+ if (closed) return;
5765
5787
  const uptime = Date.now() - startupTime;
5766
5788
  const shutdownDuration = shutdownStartTime ? Date.now() - shutdownStartTime : null;
5767
5789
  const exitEvent = buildApplicationLifecycleEvent({
@@ -5795,18 +5817,11 @@ var eventEmissionPlugin = ({ context }) => {
5795
5817
  errorEvent = { ...errorEvent, ...userContext };
5796
5818
  } catch {
5797
5819
  }
5798
- try {
5799
- await Promise.race([
5800
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
5801
- new Promise((resolve2) => {
5802
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5803
- if (typeof timer.unref === "function") {
5804
- timer.unref();
5805
- }
5806
- })
5807
- ]);
5808
- } catch {
5809
- }
5820
+ await emitWithTimeout(
5821
+ transport,
5822
+ ERROR_OCCURRED_EVENT_SUBJECT,
5823
+ errorEvent
5824
+ );
5810
5825
  };
5811
5826
  registeredListeners.uncaughtException = uncaughtExceptionHandler;
5812
5827
  process.on("uncaughtException", uncaughtExceptionHandler);
@@ -5830,18 +5845,11 @@ var eventEmissionPlugin = ({ context }) => {
5830
5845
  errorEvent = { ...errorEvent, ...userContext };
5831
5846
  } catch {
5832
5847
  }
5833
- try {
5834
- await Promise.race([
5835
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
5836
- new Promise((resolve2) => {
5837
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5838
- if (typeof timer.unref === "function") {
5839
- timer.unref();
5840
- }
5841
- })
5842
- ]);
5843
- } catch {
5844
- }
5848
+ await emitWithTimeout(
5849
+ transport,
5850
+ ERROR_OCCURRED_EVENT_SUBJECT,
5851
+ errorEvent
5852
+ );
5845
5853
  };
5846
5854
  registeredListeners.unhandledRejection = unhandledRejectionHandler;
5847
5855
  process.on("unhandledRejection", unhandledRejectionHandler);
@@ -5859,18 +5867,11 @@ var eventEmissionPlugin = ({ context }) => {
5859
5867
  signalEvent = { ...signalEvent, ...userContext };
5860
5868
  } catch {
5861
5869
  }
5862
- try {
5863
- await Promise.race([
5864
- transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
5865
- new Promise((resolve2) => {
5866
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5867
- if (typeof timer.unref === "function") {
5868
- timer.unref();
5869
- }
5870
- })
5871
- ]);
5872
- } catch {
5873
- }
5870
+ await emitWithTimeout(
5871
+ transport,
5872
+ APPLICATION_LIFECYCLE_EVENT_SUBJECT,
5873
+ signalEvent
5874
+ );
5874
5875
  const exitCode = signal === "SIGINT" ? 130 : 143;
5875
5876
  process.exit(exitCode);
5876
5877
  };
@@ -5882,6 +5883,30 @@ var eventEmissionPlugin = ({ context }) => {
5882
5883
  process.on("SIGTERM", sigtermHandler);
5883
5884
  }
5884
5885
  }
5886
+ const close = async (exitCode) => {
5887
+ if (closed) return;
5888
+ closed = true;
5889
+ const uptime = Date.now() - startupTime;
5890
+ const shutdownDuration = shutdownStartTime ? Date.now() - shutdownStartTime : null;
5891
+ let exitEvent = buildApplicationLifecycleEvent({
5892
+ lifecycle_event_type: "exit",
5893
+ exit_code: exitCode ?? 0,
5894
+ uptime_ms: uptime,
5895
+ is_graceful_shutdown: (exitCode ?? 0) === 0,
5896
+ shutdown_duration_ms: shutdownDuration
5897
+ });
5898
+ try {
5899
+ const userContext = await getUserContext;
5900
+ exitEvent = { ...exitEvent, ...userContext };
5901
+ } catch {
5902
+ }
5903
+ await emitWithTimeout(
5904
+ transport,
5905
+ APPLICATION_LIFECYCLE_EVENT_SUBJECT,
5906
+ exitEvent
5907
+ );
5908
+ removeExistingListeners();
5909
+ };
5885
5910
  return {
5886
5911
  context: {
5887
5912
  eventEmission: {
@@ -5902,7 +5927,8 @@ var eventEmissionPlugin = ({ context }) => {
5902
5927
  event,
5903
5928
  getUserContext
5904
5929
  );
5905
- }
5930
+ },
5931
+ close
5906
5932
  }
5907
5933
  }
5908
5934
  };
@@ -6085,6 +6111,7 @@ exports.getPreferredManifestEntryKey = getPreferredManifestEntryKey;
6085
6111
  exports.getProfilePlugin = getProfilePlugin;
6086
6112
  exports.getReleaseId = getReleaseId;
6087
6113
  exports.getTokenFromCliLogin = getTokenFromCliLogin;
6114
+ exports.injectCliLogin = injectCliLogin;
6088
6115
  exports.inputFieldKeyResolver = inputFieldKeyResolver;
6089
6116
  exports.inputsAllOptionalResolver = inputsAllOptionalResolver;
6090
6117
  exports.inputsResolver = inputsResolver;
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ import { z } from 'zod';
3
3
  import { ConnectionSchema, ConnectionsResponseSchema, ConnectionItem as ConnectionItem$2, GetConnectionResponse } from '@zapier/zapier-sdk-core/v0/schemas/connections';
4
4
  import { AppItem as AppItem$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
5
5
  import { ClientCredentialsItem as ClientCredentialsItem$1, ClientCredentialsCreatedItem } from '@zapier/zapier-sdk-core/v0/schemas/client-credentials';
6
+ import * as _zapier_zapier_sdk_cli_login from '@zapier/zapier-sdk-cli-login';
6
7
 
7
8
  /**
8
9
  * SDK Event System
@@ -387,6 +388,7 @@ interface EventEmissionContext {
387
388
  emit<T extends any>(subject: string, event: T): void;
388
389
  createBaseEvent(): Promise<BaseEvent>;
389
390
  emitMethodCalled(data: MethodCalledEventData): void;
391
+ close(exitCode?: number): Promise<void>;
390
392
  };
391
393
  }
392
394
  interface EventEmissionProvides {
@@ -612,6 +614,7 @@ declare const NeedSchema: z.ZodObject<{
612
614
  boolean: "boolean";
613
615
  file: "file";
614
616
  integer: "integer";
617
+ filter: "filter";
615
618
  text: "text";
616
619
  datetime: "datetime";
617
620
  decimal: "decimal";
@@ -619,7 +622,6 @@ declare const NeedSchema: z.ZodObject<{
619
622
  password: "password";
620
623
  dict: "dict";
621
624
  code: "code";
622
- filter: "filter";
623
625
  json: "json";
624
626
  }>>;
625
627
  list: z.ZodOptional<z.ZodBoolean>;
@@ -818,6 +820,7 @@ declare const NeedsResponseSchema: z.ZodObject<{
818
820
  boolean: "boolean";
819
821
  file: "file";
820
822
  integer: "integer";
823
+ filter: "filter";
821
824
  text: "text";
822
825
  datetime: "datetime";
823
826
  decimal: "decimal";
@@ -825,7 +828,6 @@ declare const NeedsResponseSchema: z.ZodObject<{
825
828
  password: "password";
826
829
  dict: "dict";
827
830
  code: "code";
828
- filter: "filter";
829
831
  json: "json";
830
832
  }>>;
831
833
  list: z.ZodOptional<z.ZodBoolean>;
@@ -2578,17 +2580,6 @@ type ClientCredentialsItem = z.infer<typeof ClientCredentialsItemSchema>;
2578
2580
 
2579
2581
  declare const clientIdResolver: DynamicResolver<ClientCredentialsItem, {}>;
2580
2582
 
2581
- /**
2582
- * SDK Authentication Utilities
2583
- *
2584
- * This module provides SDK-level authentication utilities focused
2585
- * on token acquisition. It uses the credentials system for resolution
2586
- * and handles different credential types appropriately.
2587
- *
2588
- * CLI-specific functionality like login/logout is handled by the
2589
- * @zapier/zapier-sdk-cli-login package.
2590
- */
2591
-
2592
2583
  /**
2593
2584
  * Options for resolving auth tokens.
2594
2585
  */
@@ -2631,6 +2622,12 @@ interface CliLoginOptions {
2631
2622
  };
2632
2623
  debug?: boolean;
2633
2624
  }
2625
+ type CliLoginModule = typeof _zapier_zapier_sdk_cli_login;
2626
+ /**
2627
+ * Inject an already-loaded CLI login module so the SDK skips its dynamic import.
2628
+ * This guarantees CLI and SDK share the same module instance in the same process.
2629
+ */
2630
+ declare function injectCliLogin(module: CliLoginModule): void;
2634
2631
  /**
2635
2632
  * Returns whether a CLI login package is available.
2636
2633
  * `undefined` if no import has been attempted yet, `true` if found, `false` if not.
@@ -2962,4 +2959,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
2962
2959
  }>;
2963
2960
  declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
2964
2961
 
2965
- export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
2962
+ export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
package/dist/index.mjs CHANGED
@@ -4281,6 +4281,9 @@ async function getCliLogin() {
4281
4281
  return void 0;
4282
4282
  }
4283
4283
  }
4284
+ function injectCliLogin(module) {
4285
+ cachedCliLogin = module;
4286
+ }
4284
4287
  function isCliLoginAvailable() {
4285
4288
  if (cachedCliLogin === void 0) return void 0;
4286
4289
  return cachedCliLogin !== false;
@@ -4712,7 +4715,8 @@ var ZapierApiClient = class {
4712
4715
  headers.set(authHeaderName, getAuthorizationHeader(authToken));
4713
4716
  }
4714
4717
  if (options.authRequired) {
4715
- if (headers.get("Authorization") == null && authToken == null) {
4718
+ const authHeaderName = pathConfig2?.authHeader ?? "Authorization";
4719
+ if (headers.get(authHeaderName) == null && authToken == null) {
4716
4720
  const message = isCliLoginAvailable() === false ? "Authentication required but no credentials available. To use CLI login, install the CLI as a dev dependency (e.g. `npm install -D @zapier/zapier-sdk-cli`) and log in (e.g. `npx zapier-sdk login`). Alternatively, set the ZAPIER_CREDENTIALS environment variable or ZAPIER_CREDENTIALS_CLIENT_ID and ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables." : "Authentication required but no credentials available. Please log in (e.g. `npx zapier-sdk login`) or set the ZAPIER_CREDENTIALS environment variable or ZAPIER_CREDENTIALS_CLIENT_ID and ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables.";
4717
4721
  throw new ZapierAuthenticationError(message);
4718
4722
  }
@@ -5477,7 +5481,7 @@ function getCpuTime() {
5477
5481
 
5478
5482
  // package.json
5479
5483
  var package_default = {
5480
- version: "0.31.4"};
5484
+ version: "0.32.1"};
5481
5485
 
5482
5486
  // src/plugins/eventEmission/builders.ts
5483
5487
  function createBaseEvent(context = {}) {
@@ -5601,6 +5605,20 @@ var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEven
5601
5605
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
5602
5606
  var METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
5603
5607
  var transportStates = /* @__PURE__ */ new WeakMap();
5608
+ async function emitWithTimeout(transport, subject, event) {
5609
+ try {
5610
+ await Promise.race([
5611
+ transport.emit(subject, event),
5612
+ new Promise((resolve2) => {
5613
+ const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5614
+ if (typeof timer.unref === "function") {
5615
+ timer.unref();
5616
+ }
5617
+ })
5618
+ ]);
5619
+ } catch {
5620
+ }
5621
+ }
5604
5622
  async function silentEmit(transport, subject, event, userContextPromise) {
5605
5623
  try {
5606
5624
  let state = transportStates.get(transport);
@@ -5679,6 +5697,7 @@ var eventEmissionPlugin = ({ context }) => {
5679
5697
  })();
5680
5698
  const startupTime = Date.now();
5681
5699
  let shutdownStartTime = null;
5700
+ let closed = false;
5682
5701
  if (!config.enabled) {
5683
5702
  return {
5684
5703
  context: {
@@ -5698,6 +5717,8 @@ var eventEmissionPlugin = ({ context }) => {
5698
5717
  correlation_id: null
5699
5718
  }),
5700
5719
  emitMethodCalled: () => {
5720
+ },
5721
+ close: async () => {
5701
5722
  }
5702
5723
  }
5703
5724
  }
@@ -5740,6 +5761,7 @@ var eventEmissionPlugin = ({ context }) => {
5740
5761
  if (typeof process?.on === "function") {
5741
5762
  removeExistingListeners();
5742
5763
  const exitHandler = (code) => {
5764
+ if (closed) return;
5743
5765
  const uptime = Date.now() - startupTime;
5744
5766
  const shutdownDuration = shutdownStartTime ? Date.now() - shutdownStartTime : null;
5745
5767
  const exitEvent = buildApplicationLifecycleEvent({
@@ -5773,18 +5795,11 @@ var eventEmissionPlugin = ({ context }) => {
5773
5795
  errorEvent = { ...errorEvent, ...userContext };
5774
5796
  } catch {
5775
5797
  }
5776
- try {
5777
- await Promise.race([
5778
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
5779
- new Promise((resolve2) => {
5780
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5781
- if (typeof timer.unref === "function") {
5782
- timer.unref();
5783
- }
5784
- })
5785
- ]);
5786
- } catch {
5787
- }
5798
+ await emitWithTimeout(
5799
+ transport,
5800
+ ERROR_OCCURRED_EVENT_SUBJECT,
5801
+ errorEvent
5802
+ );
5788
5803
  };
5789
5804
  registeredListeners.uncaughtException = uncaughtExceptionHandler;
5790
5805
  process.on("uncaughtException", uncaughtExceptionHandler);
@@ -5808,18 +5823,11 @@ var eventEmissionPlugin = ({ context }) => {
5808
5823
  errorEvent = { ...errorEvent, ...userContext };
5809
5824
  } catch {
5810
5825
  }
5811
- try {
5812
- await Promise.race([
5813
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
5814
- new Promise((resolve2) => {
5815
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5816
- if (typeof timer.unref === "function") {
5817
- timer.unref();
5818
- }
5819
- })
5820
- ]);
5821
- } catch {
5822
- }
5826
+ await emitWithTimeout(
5827
+ transport,
5828
+ ERROR_OCCURRED_EVENT_SUBJECT,
5829
+ errorEvent
5830
+ );
5823
5831
  };
5824
5832
  registeredListeners.unhandledRejection = unhandledRejectionHandler;
5825
5833
  process.on("unhandledRejection", unhandledRejectionHandler);
@@ -5837,18 +5845,11 @@ var eventEmissionPlugin = ({ context }) => {
5837
5845
  signalEvent = { ...signalEvent, ...userContext };
5838
5846
  } catch {
5839
5847
  }
5840
- try {
5841
- await Promise.race([
5842
- transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
5843
- new Promise((resolve2) => {
5844
- const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
5845
- if (typeof timer.unref === "function") {
5846
- timer.unref();
5847
- }
5848
- })
5849
- ]);
5850
- } catch {
5851
- }
5848
+ await emitWithTimeout(
5849
+ transport,
5850
+ APPLICATION_LIFECYCLE_EVENT_SUBJECT,
5851
+ signalEvent
5852
+ );
5852
5853
  const exitCode = signal === "SIGINT" ? 130 : 143;
5853
5854
  process.exit(exitCode);
5854
5855
  };
@@ -5860,6 +5861,30 @@ var eventEmissionPlugin = ({ context }) => {
5860
5861
  process.on("SIGTERM", sigtermHandler);
5861
5862
  }
5862
5863
  }
5864
+ const close = async (exitCode) => {
5865
+ if (closed) return;
5866
+ closed = true;
5867
+ const uptime = Date.now() - startupTime;
5868
+ const shutdownDuration = shutdownStartTime ? Date.now() - shutdownStartTime : null;
5869
+ let exitEvent = buildApplicationLifecycleEvent({
5870
+ lifecycle_event_type: "exit",
5871
+ exit_code: exitCode ?? 0,
5872
+ uptime_ms: uptime,
5873
+ is_graceful_shutdown: (exitCode ?? 0) === 0,
5874
+ shutdown_duration_ms: shutdownDuration
5875
+ });
5876
+ try {
5877
+ const userContext = await getUserContext;
5878
+ exitEvent = { ...exitEvent, ...userContext };
5879
+ } catch {
5880
+ }
5881
+ await emitWithTimeout(
5882
+ transport,
5883
+ APPLICATION_LIFECYCLE_EVENT_SUBJECT,
5884
+ exitEvent
5885
+ );
5886
+ removeExistingListeners();
5887
+ };
5863
5888
  return {
5864
5889
  context: {
5865
5890
  eventEmission: {
@@ -5880,7 +5905,8 @@ var eventEmissionPlugin = ({ context }) => {
5880
5905
  event,
5881
5906
  getUserContext
5882
5907
  );
5883
- }
5908
+ },
5909
+ close
5884
5910
  }
5885
5911
  }
5886
5912
  };
@@ -5969,4 +5995,4 @@ var BaseSdkOptionsSchema = z.object({
5969
5995
  // Use credentials instead
5970
5996
  });
5971
5997
 
5972
- export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
5998
+ export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
@@ -25,6 +25,7 @@ export interface EventEmissionContext {
25
25
  emit<T extends any>(subject: string, event: T): void;
26
26
  createBaseEvent(): Promise<BaseEvent>;
27
27
  emitMethodCalled(data: MethodCalledEventData): void;
28
+ close(exitCode?: number): Promise<void>;
28
29
  };
29
30
  }
30
31
  export interface EventEmissionProvides {
@@ -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;AAWnE,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAsCnE;;;GAGG;AACH,wBAAgB,qBAAqB,SAEpC;AAGD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAA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S,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
@@ -41,6 +41,22 @@ const ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
41
41
  const METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
42
42
  // Track transport success/failure so we only log failure once.
43
43
  const transportStates = new WeakMap();
44
+ async function emitWithTimeout(transport, subject, event) {
45
+ try {
46
+ await Promise.race([
47
+ transport.emit(subject, event),
48
+ new Promise((resolve) => {
49
+ const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
50
+ if (typeof timer.unref === "function") {
51
+ timer.unref();
52
+ }
53
+ }),
54
+ ]);
55
+ }
56
+ catch {
57
+ // Silently ignore telemetry failures
58
+ }
59
+ }
44
60
  // Silent emission wrapper with smart first-failure logging
45
61
  async function silentEmit(transport, subject, event, userContextPromise) {
46
62
  try {
@@ -135,6 +151,7 @@ export const eventEmissionPlugin = ({ context }) => {
135
151
  })();
136
152
  const startupTime = Date.now();
137
153
  let shutdownStartTime = null;
154
+ let closed = false;
138
155
  // If disabled, return noop implementations
139
156
  if (!config.enabled) {
140
157
  return {
@@ -154,6 +171,7 @@ export const eventEmissionPlugin = ({ context }) => {
154
171
  correlation_id: null,
155
172
  }),
156
173
  emitMethodCalled: () => { },
174
+ close: async () => { },
157
175
  },
158
176
  },
159
177
  };
@@ -201,6 +219,8 @@ export const eventEmissionPlugin = ({ context }) => {
201
219
  removeExistingListeners();
202
220
  // Handle normal process exit
203
221
  const exitHandler = (code) => {
222
+ if (closed)
223
+ return;
204
224
  const uptime = Date.now() - startupTime;
205
225
  const shutdownDuration = shutdownStartTime
206
226
  ? Date.now() - shutdownStartTime
@@ -235,21 +255,7 @@ export const eventEmissionPlugin = ({ context }) => {
235
255
  catch {
236
256
  // Continue with original event if user context fails
237
257
  }
238
- // Wait up to 300ms for telemetry to send before allowing process to exit
239
- try {
240
- await Promise.race([
241
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
242
- new Promise((resolve) => {
243
- const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
244
- if (typeof timer.unref === "function") {
245
- timer.unref();
246
- }
247
- }),
248
- ]);
249
- }
250
- catch {
251
- // Silently ignore telemetry failures
252
- }
258
+ await emitWithTimeout(transport, ERROR_OCCURRED_EVENT_SUBJECT, errorEvent);
253
259
  };
254
260
  registeredListeners.uncaughtException = uncaughtExceptionHandler;
255
261
  process.on("uncaughtException", uncaughtExceptionHandler);
@@ -281,21 +287,7 @@ export const eventEmissionPlugin = ({ context }) => {
281
287
  catch {
282
288
  // Continue with original event if user context fails
283
289
  }
284
- // Wait up to 300ms for telemetry to send
285
- try {
286
- await Promise.race([
287
- transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
288
- new Promise((resolve) => {
289
- const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
290
- if (typeof timer.unref === "function") {
291
- timer.unref();
292
- }
293
- }),
294
- ]);
295
- }
296
- catch {
297
- // Silently ignore telemetry failures
298
- }
290
+ await emitWithTimeout(transport, ERROR_OCCURRED_EVENT_SUBJECT, errorEvent);
299
291
  };
300
292
  registeredListeners.unhandledRejection = unhandledRejectionHandler;
301
293
  process.on("unhandledRejection", unhandledRejectionHandler);
@@ -317,21 +309,7 @@ export const eventEmissionPlugin = ({ context }) => {
317
309
  catch {
318
310
  // Continue with original event if user context fails
319
311
  }
320
- // Wait up to 300ms for telemetry to send
321
- try {
322
- await Promise.race([
323
- transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
324
- new Promise((resolve) => {
325
- const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
326
- if (typeof timer.unref === "function") {
327
- timer.unref();
328
- }
329
- }),
330
- ]);
331
- }
332
- catch {
333
- // Silently ignore telemetry failures
334
- }
312
+ await emitWithTimeout(transport, APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent);
335
313
  // Exit with appropriate code (128 + signal number)
336
314
  const exitCode = signal === "SIGINT" ? 130 : 143;
337
315
  process.exit(exitCode);
@@ -345,6 +323,31 @@ export const eventEmissionPlugin = ({ context }) => {
345
323
  process.on("SIGTERM", sigtermHandler);
346
324
  }
347
325
  }
326
+ const close = async (exitCode) => {
327
+ if (closed)
328
+ return;
329
+ closed = true;
330
+ const uptime = Date.now() - startupTime;
331
+ const shutdownDuration = shutdownStartTime
332
+ ? Date.now() - shutdownStartTime
333
+ : null;
334
+ let exitEvent = buildApplicationLifecycleEvent({
335
+ lifecycle_event_type: "exit",
336
+ exit_code: exitCode ?? 0,
337
+ uptime_ms: uptime,
338
+ is_graceful_shutdown: (exitCode ?? 0) === 0,
339
+ shutdown_duration_ms: shutdownDuration,
340
+ });
341
+ try {
342
+ const userContext = await getUserContext;
343
+ exitEvent = { ...exitEvent, ...userContext };
344
+ }
345
+ catch {
346
+ // Continue with original event if user context fails
347
+ }
348
+ await emitWithTimeout(transport, APPLICATION_LIFECYCLE_EVENT_SUBJECT, exitEvent);
349
+ removeExistingListeners();
350
+ };
348
351
  return {
349
352
  context: {
350
353
  eventEmission: {
@@ -361,6 +364,7 @@ export const eventEmissionPlugin = ({ context }) => {
361
364
  };
362
365
  silentEmit(transport, METHOD_CALLED_EVENT_SUBJECT, event, getUserContext);
363
366
  },
367
+ close,
364
368
  },
365
369
  },
366
370
  };
@@ -661,6 +661,98 @@ describe("emitMethodCalled call_context", () => {
661
661
  expect(mockTransport.emit).toHaveBeenCalledWith("platform.sdk.MethodCalledEvent", expect.objectContaining({ call_context: "mcp" }));
662
662
  });
663
663
  });
664
+ describe("close()", () => {
665
+ beforeEach(() => {
666
+ vi.clearAllMocks();
667
+ cleanupEventListeners();
668
+ mockGetToken.mockResolvedValue(undefined);
669
+ });
670
+ afterEach(() => {
671
+ cleanupEventListeners();
672
+ });
673
+ it("should emit exit lifecycle event", async () => {
674
+ const plugin = eventEmissionPlugin({
675
+ sdk: {},
676
+ context: {
677
+ meta: {},
678
+ options: {
679
+ eventEmission: {
680
+ enabled: true,
681
+ transport: { type: "console" },
682
+ },
683
+ },
684
+ },
685
+ });
686
+ await plugin.context.eventEmission.close(0);
687
+ expect(mockTransport.emit).toHaveBeenCalledWith("platform.sdk.ApplicationLifecycleEvent", expect.objectContaining({
688
+ lifecycle_event_type: "exit",
689
+ exit_code: 0,
690
+ is_graceful_shutdown: true,
691
+ }));
692
+ });
693
+ it("should be idempotent — second call is a no-op", async () => {
694
+ const plugin = eventEmissionPlugin({
695
+ sdk: {},
696
+ context: {
697
+ meta: {},
698
+ options: {
699
+ eventEmission: {
700
+ enabled: true,
701
+ transport: { type: "console" },
702
+ },
703
+ },
704
+ },
705
+ });
706
+ await plugin.context.eventEmission.close(0);
707
+ const callCountAfterFirst = mockTransport.emit.mock.calls.filter((call) => call[0] === "platform.sdk.ApplicationLifecycleEvent" &&
708
+ call[1]?.lifecycle_event_type === "exit").length;
709
+ await plugin.context.eventEmission.close(0);
710
+ const callCountAfterSecond = mockTransport.emit.mock.calls.filter((call) => call[0] === "platform.sdk.ApplicationLifecycleEvent" &&
711
+ call[1]?.lifecycle_event_type === "exit").length;
712
+ expect(callCountAfterSecond).toBe(callCountAfterFirst);
713
+ });
714
+ it("should remove process listeners after close", async () => {
715
+ const initialExitCount = process.listenerCount("exit");
716
+ const plugin = eventEmissionPlugin({
717
+ sdk: {},
718
+ context: {
719
+ meta: {},
720
+ options: {
721
+ eventEmission: {
722
+ enabled: true,
723
+ transport: { type: "console" },
724
+ },
725
+ },
726
+ },
727
+ });
728
+ expect(process.listenerCount("exit")).toBe(initialExitCount + 1);
729
+ await plugin.context.eventEmission.close(0);
730
+ expect(process.listenerCount("exit")).toBe(initialExitCount);
731
+ });
732
+ it("should handle transport failures silently", async () => {
733
+ const failingTransport = {
734
+ emit: vi.fn().mockRejectedValue(new Error("Network error")),
735
+ close: vi.fn().mockResolvedValue(undefined),
736
+ };
737
+ vi.mocked(createTransport).mockReturnValueOnce(failingTransport);
738
+ const plugin = eventEmissionPlugin({
739
+ sdk: {},
740
+ context: {
741
+ meta: {},
742
+ options: {
743
+ eventEmission: {
744
+ enabled: true,
745
+ transport: {
746
+ type: "http",
747
+ endpoint: "https://example.com",
748
+ },
749
+ },
750
+ },
751
+ },
752
+ });
753
+ await expect(plugin.context.eventEmission.close(1)).resolves.toBeUndefined();
754
+ });
755
+ });
664
756
  describe("Process Listener Cleanup", () => {
665
757
  beforeEach(() => {
666
758
  // Clean up any listeners from previous tests
@@ -6,8 +6,8 @@ export declare const GetActionSchema: z.ZodObject<{
6
6
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
7
7
  };
8
8
  actionType: z.ZodEnum<{
9
- filter: "filter";
10
9
  search: "search";
10
+ filter: "filter";
11
11
  read: "read";
12
12
  read_bulk: "read_bulk";
13
13
  run: "run";
@@ -5,8 +5,8 @@ export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
5
5
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
6
6
  };
7
7
  actionType: z.ZodEnum<{
8
- filter: "filter";
9
8
  search: "search";
9
+ filter: "filter";
10
10
  read: "read";
11
11
  read_bulk: "read_bulk";
12
12
  run: "run";
@@ -7,8 +7,8 @@ export declare const ListActionsSchema: z.ZodObject<{
7
7
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
8
8
  };
9
9
  actionType: z.ZodOptional<z.ZodEnum<{
10
- filter: "filter";
11
10
  search: "search";
11
+ filter: "filter";
12
12
  read: "read";
13
13
  read_bulk: "read_bulk";
14
14
  run: "run";
@@ -13,8 +13,8 @@ export declare const ListInputFieldChoicesSchema: z.ZodObject<{
13
13
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
14
14
  };
15
15
  actionType: z.ZodEnum<{
16
- filter: "filter";
17
16
  search: "search";
17
+ filter: "filter";
18
18
  read: "read";
19
19
  read_bulk: "read_bulk";
20
20
  run: "run";
@@ -7,8 +7,8 @@ export declare const ListInputFieldsSchema: z.ZodObject<{
7
7
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
8
8
  };
9
9
  actionType: z.ZodEnum<{
10
- filter: "filter";
11
10
  search: "search";
11
+ filter: "filter";
12
12
  read: "read";
13
13
  read_bulk: "read_bulk";
14
14
  run: "run";
@@ -437,6 +437,7 @@ describe("request plugin", () => {
437
437
  emit: () => { },
438
438
  createBaseEvent: (() => ({})),
439
439
  emitMethodCalled: emitSpy,
440
+ close: async () => { },
440
441
  },
441
442
  },
442
443
  });
@@ -6,8 +6,8 @@ export declare const RunActionSchema: z.ZodObject<{
6
6
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
7
7
  };
8
8
  actionType: z.ZodEnum<{
9
- filter: "filter";
10
9
  search: "search";
10
+ filter: "filter";
11
11
  read: "read";
12
12
  read_bulk: "read_bulk";
13
13
  run: "run";
@@ -8,8 +8,8 @@ export declare const ActionItemSchema: z.ZodObject<{
8
8
  app_key: z.ZodString;
9
9
  app_version: z.ZodOptional<z.ZodString>;
10
10
  action_type: z.ZodEnum<{
11
- filter: "filter";
12
11
  search: "search";
12
+ filter: "filter";
13
13
  read: "read";
14
14
  read_bulk: "read_bulk";
15
15
  run: "run";
@@ -3,8 +3,8 @@ export declare const AppKeyPropertySchema: z.ZodString & {
3
3
  _def: z.core.$ZodStringDef & import("..").PositionalMetadata;
4
4
  };
5
5
  export declare const ActionTypePropertySchema: z.ZodEnum<{
6
- filter: "filter";
7
6
  search: "search";
7
+ filter: "filter";
8
8
  read: "read";
9
9
  read_bulk: "read_bulk";
10
10
  run: "run";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.31.4",
3
+ "version": "0.32.1",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -45,7 +45,7 @@
45
45
  "tsup": "^8.5.0",
46
46
  "typescript": "^5.8.3",
47
47
  "vitest": "^3.2.3",
48
- "@zapier/zapier-sdk-cli-login": "0.7.0"
48
+ "@zapier/zapier-sdk-cli-login": "0.8.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup",