@zapier/zapier-sdk 0.46.1 → 0.47.0
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 +12 -0
- package/dist/index.cjs +59 -1
- package/dist/index.d.mts +76 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +59 -2
- package/dist/utils/plugin-utils.d.ts +76 -1
- package/dist/utils/plugin-utils.d.ts.map +1 -1
- package/dist/utils/plugin-utils.js +100 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.47.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e45ce2f: Add `composePlugins(...subPlugins)` for bundling N plugins into a single `Plugin<TSdk, TProvides>` so a consumer can call `addPlugin(combined)` once. Bag-mode composition: throws on duplicate root keys or duplicate `context.meta` keys, intersects each sub-plugin's TSdk requirements, and flows through the existing single-plugin `addPlugin` without the type-widening an array overload would impose.
|
|
8
|
+
|
|
9
|
+
## 0.46.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fcb47ea: Set npm package homepage links to public SDK documentation.
|
|
14
|
+
|
|
3
15
|
## 0.46.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -970,6 +970,63 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
970
970
|
}
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
|
+
function mergeRootKeysWithCollisionCheck(target, source, seen) {
|
|
974
|
+
for (const key of Object.keys(source)) {
|
|
975
|
+
if (seen.has(key)) {
|
|
976
|
+
throw new Error(
|
|
977
|
+
`composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
seen.add(key);
|
|
981
|
+
target[key] = source[key];
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
985
|
+
for (const key of Object.keys(source)) {
|
|
986
|
+
if (seen.has(key)) {
|
|
987
|
+
throw new Error(
|
|
988
|
+
`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
seen.add(key);
|
|
992
|
+
target[key] = source[key];
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
996
|
+
for (const key of Object.keys(source)) {
|
|
997
|
+
if (seen.has(key)) {
|
|
998
|
+
throw new Error(
|
|
999
|
+
`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
seen.add(key);
|
|
1003
|
+
target[key] = source[key];
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function composePlugins(...plugins) {
|
|
1007
|
+
return (sdk) => {
|
|
1008
|
+
const merged = { context: { meta: {} } };
|
|
1009
|
+
const seenRoot = /* @__PURE__ */ new Set();
|
|
1010
|
+
const seenMeta = /* @__PURE__ */ new Set();
|
|
1011
|
+
const seenContext = /* @__PURE__ */ new Set();
|
|
1012
|
+
for (const plugin of plugins) {
|
|
1013
|
+
const { context, ...rootKeys } = plugin(sdk);
|
|
1014
|
+
mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
|
|
1015
|
+
if (context) {
|
|
1016
|
+
const { meta, ...nonMetaContext } = context;
|
|
1017
|
+
if (meta) {
|
|
1018
|
+
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
1019
|
+
}
|
|
1020
|
+
mergeContextKeysWithCollisionCheck(
|
|
1021
|
+
merged.context,
|
|
1022
|
+
nonMetaContext,
|
|
1023
|
+
seenContext
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
return merged;
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
973
1030
|
function getStringProperty(obj, key) {
|
|
974
1031
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
975
1032
|
const value = obj[key];
|
|
@@ -5563,7 +5620,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
5563
5620
|
}
|
|
5564
5621
|
|
|
5565
5622
|
// src/sdk-version.ts
|
|
5566
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
5623
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.47.0" : void 0) || "unknown";
|
|
5567
5624
|
|
|
5568
5625
|
// src/utils/open-url.ts
|
|
5569
5626
|
var nodePrefix = "node:";
|
|
@@ -8574,6 +8631,7 @@ exports.buildMethodCalledEvent = buildMethodCalledEvent;
|
|
|
8574
8631
|
exports.clearTokenCache = clearTokenCache;
|
|
8575
8632
|
exports.clientCredentialsNameResolver = clientCredentialsNameResolver;
|
|
8576
8633
|
exports.clientIdResolver = clientIdResolver;
|
|
8634
|
+
exports.composePlugins = composePlugins;
|
|
8577
8635
|
exports.connectionIdGenericResolver = connectionIdGenericResolver;
|
|
8578
8636
|
exports.connectionIdResolver = connectionIdResolver;
|
|
8579
8637
|
exports.connectionsPlugin = connectionsPlugin;
|
package/dist/index.d.mts
CHANGED
|
@@ -8467,6 +8467,81 @@ declare function createPaginatedPluginMethod<const TName extends string, TSdk ex
|
|
|
8467
8467
|
}, TInput, TResponse extends {
|
|
8468
8468
|
data: unknown[];
|
|
8469
8469
|
}>(sdk: TSdk, config: PaginatedPluginMethodConfig<TSdk, TInput, TResponse, TName>): PaginatedPluginMethodReturn<TName, TInput, ItemOf<TResponse>>;
|
|
8470
|
+
/**
|
|
8471
|
+
* Maps a tuple of plugins to a tuple of their TSdk requirement types.
|
|
8472
|
+
*
|
|
8473
|
+
* SdkRequirementsOf<[Plugin<{ api }, _>, Plugin<{ options }, _>]>
|
|
8474
|
+
* = [{ api }, { options }]
|
|
8475
|
+
*/
|
|
8476
|
+
type SdkRequirementsOf<T extends readonly Plugin<any, any>[]> = {
|
|
8477
|
+
[K in keyof T]: T[K] extends Plugin<infer Sdk, any> ? Sdk : never;
|
|
8478
|
+
};
|
|
8479
|
+
/**
|
|
8480
|
+
* Maps a tuple of plugins to a tuple of their TProvides output types.
|
|
8481
|
+
*
|
|
8482
|
+
* ProvidesOf<[Plugin<_, { hello }>, Plugin<_, { goodbye }>]>
|
|
8483
|
+
* = [{ hello }, { goodbye }]
|
|
8484
|
+
*/
|
|
8485
|
+
type ProvidesOf<T extends readonly Plugin<any, any>[]> = {
|
|
8486
|
+
[K in keyof T]: T[K] extends Plugin<any, infer Provides> ? Provides : never;
|
|
8487
|
+
};
|
|
8488
|
+
/**
|
|
8489
|
+
* Intersects every member of a tuple into a single combined type. The
|
|
8490
|
+
* result is an object that has every property of every member at once.
|
|
8491
|
+
*
|
|
8492
|
+
* IntersectAll<[{ api }, { options }]> = { api } & { options }
|
|
8493
|
+
* IntersectAll<[]> = {}
|
|
8494
|
+
*
|
|
8495
|
+
* Walks recursively: head & IntersectAll<tail>, base case is the empty
|
|
8496
|
+
* tuple. Why intersection (`&`) and not union (`|`): the composed plugin
|
|
8497
|
+
* must require ALL of the sub-plugins' needs at once — an SDK that has
|
|
8498
|
+
* both `api` AND `options` — not "either api or options."
|
|
8499
|
+
*/
|
|
8500
|
+
type IntersectAll<T extends readonly unknown[]> = T extends readonly [
|
|
8501
|
+
infer Head,
|
|
8502
|
+
...infer Tail
|
|
8503
|
+
] ? Head & IntersectAll<Tail> : {};
|
|
8504
|
+
/**
|
|
8505
|
+
* The TSdk a composed plugin requires: every sub-plugin's TSdk requirement,
|
|
8506
|
+
* all at once. Composing a plugin that needs `{ api }` with one that needs
|
|
8507
|
+
* `{ options }` yields a composed plugin that needs `{ api } & { options }`.
|
|
8508
|
+
*/
|
|
8509
|
+
type ComposeSdk<T extends readonly Plugin<any, any>[]> = IntersectAll<SdkRequirementsOf<T>>;
|
|
8510
|
+
/**
|
|
8511
|
+
* What a composed plugin provides: every sub-plugin's TProvides combined.
|
|
8512
|
+
* Composing a plugin that provides `{ hello }` with one that provides
|
|
8513
|
+
* `{ goodbye }` yields `{ hello } & { goodbye }`.
|
|
8514
|
+
*/
|
|
8515
|
+
type ComposeProvides<T extends readonly Plugin<any, any>[]> = IntersectAll<ProvidesOf<T>>;
|
|
8516
|
+
/**
|
|
8517
|
+
* Bundle N plugins into a single plugin so a consumer can call
|
|
8518
|
+
* `addPlugin(combined)` once. Use this when an extension package wants to
|
|
8519
|
+
* expose granular sub-plugins for tree-shaking *and* a one-call convenience
|
|
8520
|
+
* entry point.
|
|
8521
|
+
*
|
|
8522
|
+
* Three commitments (per the boilerplate-reduction design):
|
|
8523
|
+
* 1. **Bag mode.** Sub-plugins must not depend on each other; order is
|
|
8524
|
+
* irrelevant. If you need pipeline composition (later sub-plugins
|
|
8525
|
+
* reading earlier sub-plugins' outputs), use a regular `definePlugin`
|
|
8526
|
+
* callback that calls each `createPluginMethod` in turn.
|
|
8527
|
+
* 2. **Over-approximation of TSdk.** The composed plugin requires the
|
|
8528
|
+
* intersection of every sub-plugin's requirements (all of them, all at
|
|
8529
|
+
* once). Works fine for homogeneous-deps groups; widens slightly for
|
|
8530
|
+
* heterogeneous ones, which keeps the variadic types tractable.
|
|
8531
|
+
* 3. **Collision detection.** Throws on duplicate root keys, duplicate
|
|
8532
|
+
* `context.meta` keys, and duplicate non-meta `context.*` keys. Note
|
|
8533
|
+
* this only applies *inside* a single `composePlugins(...)` call —
|
|
8534
|
+
* cross-`addPlugin` overrides (e.g. a CLI plugin overriding meta from
|
|
8535
|
+
* a core SDK plugin) still go through `addPlugin`'s last-write-wins
|
|
8536
|
+
* merge unchanged.
|
|
8537
|
+
*
|
|
8538
|
+
* Why prefer this over an `addPlugin([...])` array overload: TypeScript's
|
|
8539
|
+
* overload resolution interacts badly with arrays carrying a mix of
|
|
8540
|
+
* `TProvides` shapes — chained inference downstream of `addPlugin([...])`
|
|
8541
|
+
* tends to widen and lose individual method types. A single composed
|
|
8542
|
+
* plugin flows through the existing single-plugin `addPlugin` cleanly.
|
|
8543
|
+
*/
|
|
8544
|
+
declare function composePlugins<const Ts extends readonly Plugin<any, any>[]>(...plugins: Ts): Plugin<ComposeSdk<Ts>, ComposeProvides<Ts>>;
|
|
8470
8545
|
|
|
8471
8546
|
/**
|
|
8472
8547
|
* @deprecated `getRegistry` is now built into every sdk produced by
|
|
@@ -8479,4 +8554,4 @@ declare const registryPlugin: (sdk: {
|
|
|
8479
8554
|
};
|
|
8480
8555
|
}) => {};
|
|
8481
8556
|
|
|
8482
|
-
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionProperty, ActionPropertySchema, type ActionItem as ActionResolverItem, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeItem, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppFactoryInput, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppProperty, AppPropertySchema, type ApplicationLifecycleEventData, type ApprovalStatus, type AppsPluginProvides, type AppsProperty, AppsPropertySchema, type ArrayResolver, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionEntry, ConnectionEntrySchema, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionProperty, ConnectionPropertySchema, type ConnectionsMap, ConnectionsMapSchema, type ConnectionsPluginProvides, type ConnectionsProperty, ConnectionsPropertySchema, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type CreateTableFieldsPluginProvides, type CreateTablePluginProvides, type CreateTableRecordsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DeleteTableFieldsPluginProvides, type DeleteTablePluginProvides, type DeleteTableRecordsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type EventEmissionProvides, type FetchPluginProvides, type Field, type FieldsProperty, FieldsPropertySchema, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetProfilePluginProvides, type GetTablePluginProvides, type GetTableRecordPluginProvides, type InfoFieldItem, type InputFieldItem, type InputFieldProperty, InputFieldPropertySchema, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type ListTableFieldsPluginProvides, type ListTableRecordsPluginProvides, type ListTablesPluginProvides, 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 OutputFormatter, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type PaginatedSdkResult, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginMeta, type PluginProvides, type PositionalMetadata, type RateLimitInfo, type RecordProperty, RecordPropertySchema, type RecordsProperty, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedAppLocator, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type ResolverMetadata, type RootFieldItem, type RunActionPluginProvides, type SdkEvent, type SdkPage, type StaticResolver, type TableProperty, TablePropertySchema, type TablesProperty, TablesPropertySchema, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UpdateTableRecordsPluginProvides, type UserProfile, type UserProfileItem, type WithAddPlugin, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, type ZapierCache, type ZapierCacheEntry, type ZapierCacheSetOptions, 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, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
8557
|
+
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionProperty, ActionPropertySchema, type ActionItem as ActionResolverItem, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeItem, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppFactoryInput, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppProperty, AppPropertySchema, type ApplicationLifecycleEventData, type ApprovalStatus, type AppsPluginProvides, type AppsProperty, AppsPropertySchema, type ArrayResolver, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionEntry, ConnectionEntrySchema, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionProperty, ConnectionPropertySchema, type ConnectionsMap, ConnectionsMapSchema, type ConnectionsPluginProvides, type ConnectionsProperty, ConnectionsPropertySchema, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type CreateTableFieldsPluginProvides, type CreateTablePluginProvides, type CreateTableRecordsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DeleteTableFieldsPluginProvides, type DeleteTablePluginProvides, type DeleteTableRecordsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type EventEmissionProvides, type FetchPluginProvides, type Field, type FieldsProperty, FieldsPropertySchema, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetProfilePluginProvides, type GetTablePluginProvides, type GetTableRecordPluginProvides, type InfoFieldItem, type InputFieldItem, type InputFieldProperty, InputFieldPropertySchema, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type ListTableFieldsPluginProvides, type ListTableRecordsPluginProvides, type ListTablesPluginProvides, 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 OutputFormatter, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type PaginatedSdkResult, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginMeta, type PluginProvides, type PositionalMetadata, type RateLimitInfo, type RecordProperty, RecordPropertySchema, type RecordsProperty, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedAppLocator, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type ResolverMetadata, type RootFieldItem, type RunActionPluginProvides, type SdkEvent, type SdkPage, type StaticResolver, type TableProperty, TablePropertySchema, type TablesProperty, TablesPropertySchema, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UpdateTableRecordsPluginProvides, type UserProfile, type UserProfileItem, type WithAddPlugin, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, type ZapierCache, type ZapierCacheEntry, type ZapierCacheSetOptions, 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, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export { createZapierSdk, createZapierSdkWithoutRegistry, createSdk, createOptio
|
|
|
56
56
|
export type { FunctionRegistryEntry, FunctionDeprecation, } from "./types/registry";
|
|
57
57
|
export { BaseSdkOptionsSchema } from "./types/sdk";
|
|
58
58
|
export type { Plugin, PluginMeta, PluginProvides, WithAddPlugin, } from "./types/plugin";
|
|
59
|
-
export { definePlugin, createPluginMethod, createPaginatedPluginMethod, } from "./utils/plugin-utils";
|
|
59
|
+
export { definePlugin, createPluginMethod, createPaginatedPluginMethod, composePlugins, } from "./utils/plugin-utils";
|
|
60
60
|
export type { ActionItem as ActionResolverItem } from "./resolvers/actionKey";
|
|
61
61
|
export type { ActionTypeItem } from "./resolvers/actionType";
|
|
62
62
|
export type { ResolvedAppLocator } from "./utils/domain-utils";
|
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,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAA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,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,GACtB,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,EACf,sBAAsB,GACvB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ export * from "./plugins/tables/updateTableRecords";
|
|
|
66
66
|
// Export the main combined SDK and new flexible SDK creator
|
|
67
67
|
export { createZapierSdk, createZapierSdkWithoutRegistry, createSdk, createOptionsPlugin, } from "./sdk";
|
|
68
68
|
export { BaseSdkOptionsSchema } from "./types/sdk";
|
|
69
|
-
export { definePlugin, createPluginMethod, createPaginatedPluginMethod, } from "./utils/plugin-utils";
|
|
69
|
+
export { definePlugin, createPluginMethod, createPaginatedPluginMethod, composePlugins, } from "./utils/plugin-utils";
|
|
70
70
|
// Export registry plugin for manual use
|
|
71
71
|
export { registryPlugin } from "./plugins/registry";
|
|
72
72
|
export { generateEventId, getCurrentTimestamp, getReleaseId, getOsInfo, getPlatformVersions, isCi, getCiPlatform, getMemoryUsage, getCpuTime, buildApplicationLifecycleEvent, buildErrorEventWithContext, buildErrorEvent, createBaseEvent, buildMethodCalledEvent, } from "./plugins/eventEmission";
|
package/dist/index.mjs
CHANGED
|
@@ -968,6 +968,63 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
968
968
|
}
|
|
969
969
|
};
|
|
970
970
|
}
|
|
971
|
+
function mergeRootKeysWithCollisionCheck(target, source, seen) {
|
|
972
|
+
for (const key of Object.keys(source)) {
|
|
973
|
+
if (seen.has(key)) {
|
|
974
|
+
throw new Error(
|
|
975
|
+
`composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
seen.add(key);
|
|
979
|
+
target[key] = source[key];
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
983
|
+
for (const key of Object.keys(source)) {
|
|
984
|
+
if (seen.has(key)) {
|
|
985
|
+
throw new Error(
|
|
986
|
+
`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
seen.add(key);
|
|
990
|
+
target[key] = source[key];
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
994
|
+
for (const key of Object.keys(source)) {
|
|
995
|
+
if (seen.has(key)) {
|
|
996
|
+
throw new Error(
|
|
997
|
+
`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
seen.add(key);
|
|
1001
|
+
target[key] = source[key];
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function composePlugins(...plugins) {
|
|
1005
|
+
return (sdk) => {
|
|
1006
|
+
const merged = { context: { meta: {} } };
|
|
1007
|
+
const seenRoot = /* @__PURE__ */ new Set();
|
|
1008
|
+
const seenMeta = /* @__PURE__ */ new Set();
|
|
1009
|
+
const seenContext = /* @__PURE__ */ new Set();
|
|
1010
|
+
for (const plugin of plugins) {
|
|
1011
|
+
const { context, ...rootKeys } = plugin(sdk);
|
|
1012
|
+
mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
|
|
1013
|
+
if (context) {
|
|
1014
|
+
const { meta, ...nonMetaContext } = context;
|
|
1015
|
+
if (meta) {
|
|
1016
|
+
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
1017
|
+
}
|
|
1018
|
+
mergeContextKeysWithCollisionCheck(
|
|
1019
|
+
merged.context,
|
|
1020
|
+
nonMetaContext,
|
|
1021
|
+
seenContext
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return merged;
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
971
1028
|
function getStringProperty(obj, key) {
|
|
972
1029
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
973
1030
|
const value = obj[key];
|
|
@@ -5561,7 +5618,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
5561
5618
|
}
|
|
5562
5619
|
|
|
5563
5620
|
// src/sdk-version.ts
|
|
5564
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
5621
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.47.0" : void 0) || "unknown";
|
|
5565
5622
|
|
|
5566
5623
|
// src/utils/open-url.ts
|
|
5567
5624
|
var nodePrefix = "node:";
|
|
@@ -8496,4 +8553,4 @@ var registryPlugin = definePlugin((_sdk) => {
|
|
|
8496
8553
|
return {};
|
|
8497
8554
|
});
|
|
8498
8555
|
|
|
8499
|
-
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
8556
|
+
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { z } from "zod";
|
|
24
24
|
import type { PaginatedSdkResult } from "../types/functions";
|
|
25
|
-
import type { PluginMeta, PluginProvides } from "../types/plugin";
|
|
25
|
+
import type { Plugin, PluginMeta, PluginProvides } from "../types/plugin";
|
|
26
26
|
/**
|
|
27
27
|
* Identity helper that preserves the narrow inferred return type of a plugin.
|
|
28
28
|
*
|
|
@@ -164,5 +164,80 @@ export declare function createPaginatedPluginMethod<const TName extends string,
|
|
|
164
164
|
}, TInput, TResponse extends {
|
|
165
165
|
data: unknown[];
|
|
166
166
|
}>(sdk: TSdk, config: PaginatedPluginMethodConfig<TSdk, TInput, TResponse, TName>): PaginatedPluginMethodReturn<TName, TInput, ItemOf<TResponse>>;
|
|
167
|
+
/**
|
|
168
|
+
* Maps a tuple of plugins to a tuple of their TSdk requirement types.
|
|
169
|
+
*
|
|
170
|
+
* SdkRequirementsOf<[Plugin<{ api }, _>, Plugin<{ options }, _>]>
|
|
171
|
+
* = [{ api }, { options }]
|
|
172
|
+
*/
|
|
173
|
+
type SdkRequirementsOf<T extends readonly Plugin<any, any>[]> = {
|
|
174
|
+
[K in keyof T]: T[K] extends Plugin<infer Sdk, any> ? Sdk : never;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Maps a tuple of plugins to a tuple of their TProvides output types.
|
|
178
|
+
*
|
|
179
|
+
* ProvidesOf<[Plugin<_, { hello }>, Plugin<_, { goodbye }>]>
|
|
180
|
+
* = [{ hello }, { goodbye }]
|
|
181
|
+
*/
|
|
182
|
+
type ProvidesOf<T extends readonly Plugin<any, any>[]> = {
|
|
183
|
+
[K in keyof T]: T[K] extends Plugin<any, infer Provides> ? Provides : never;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Intersects every member of a tuple into a single combined type. The
|
|
187
|
+
* result is an object that has every property of every member at once.
|
|
188
|
+
*
|
|
189
|
+
* IntersectAll<[{ api }, { options }]> = { api } & { options }
|
|
190
|
+
* IntersectAll<[]> = {}
|
|
191
|
+
*
|
|
192
|
+
* Walks recursively: head & IntersectAll<tail>, base case is the empty
|
|
193
|
+
* tuple. Why intersection (`&`) and not union (`|`): the composed plugin
|
|
194
|
+
* must require ALL of the sub-plugins' needs at once — an SDK that has
|
|
195
|
+
* both `api` AND `options` — not "either api or options."
|
|
196
|
+
*/
|
|
197
|
+
type IntersectAll<T extends readonly unknown[]> = T extends readonly [
|
|
198
|
+
infer Head,
|
|
199
|
+
...infer Tail
|
|
200
|
+
] ? Head & IntersectAll<Tail> : {};
|
|
201
|
+
/**
|
|
202
|
+
* The TSdk a composed plugin requires: every sub-plugin's TSdk requirement,
|
|
203
|
+
* all at once. Composing a plugin that needs `{ api }` with one that needs
|
|
204
|
+
* `{ options }` yields a composed plugin that needs `{ api } & { options }`.
|
|
205
|
+
*/
|
|
206
|
+
type ComposeSdk<T extends readonly Plugin<any, any>[]> = IntersectAll<SdkRequirementsOf<T>>;
|
|
207
|
+
/**
|
|
208
|
+
* What a composed plugin provides: every sub-plugin's TProvides combined.
|
|
209
|
+
* Composing a plugin that provides `{ hello }` with one that provides
|
|
210
|
+
* `{ goodbye }` yields `{ hello } & { goodbye }`.
|
|
211
|
+
*/
|
|
212
|
+
type ComposeProvides<T extends readonly Plugin<any, any>[]> = IntersectAll<ProvidesOf<T>>;
|
|
213
|
+
/**
|
|
214
|
+
* Bundle N plugins into a single plugin so a consumer can call
|
|
215
|
+
* `addPlugin(combined)` once. Use this when an extension package wants to
|
|
216
|
+
* expose granular sub-plugins for tree-shaking *and* a one-call convenience
|
|
217
|
+
* entry point.
|
|
218
|
+
*
|
|
219
|
+
* Three commitments (per the boilerplate-reduction design):
|
|
220
|
+
* 1. **Bag mode.** Sub-plugins must not depend on each other; order is
|
|
221
|
+
* irrelevant. If you need pipeline composition (later sub-plugins
|
|
222
|
+
* reading earlier sub-plugins' outputs), use a regular `definePlugin`
|
|
223
|
+
* callback that calls each `createPluginMethod` in turn.
|
|
224
|
+
* 2. **Over-approximation of TSdk.** The composed plugin requires the
|
|
225
|
+
* intersection of every sub-plugin's requirements (all of them, all at
|
|
226
|
+
* once). Works fine for homogeneous-deps groups; widens slightly for
|
|
227
|
+
* heterogeneous ones, which keeps the variadic types tractable.
|
|
228
|
+
* 3. **Collision detection.** Throws on duplicate root keys, duplicate
|
|
229
|
+
* `context.meta` keys, and duplicate non-meta `context.*` keys. Note
|
|
230
|
+
* this only applies *inside* a single `composePlugins(...)` call —
|
|
231
|
+
* cross-`addPlugin` overrides (e.g. a CLI plugin overriding meta from
|
|
232
|
+
* a core SDK plugin) still go through `addPlugin`'s last-write-wins
|
|
233
|
+
* merge unchanged.
|
|
234
|
+
*
|
|
235
|
+
* Why prefer this over an `addPlugin([...])` array overload: TypeScript's
|
|
236
|
+
* overload resolution interacts badly with arrays carrying a mix of
|
|
237
|
+
* `TProvides` shapes — chained inference downstream of `addPlugin([...])`
|
|
238
|
+
* tends to widen and lose individual method types. A single composed
|
|
239
|
+
* plugin flows through the existing single-plugin `addPlugin` cleanly.
|
|
240
|
+
*/
|
|
241
|
+
export declare function composePlugins<const Ts extends readonly Plugin<any, any>[]>(...plugins: Ts): Plugin<ComposeSdk<Ts>, ComposeProvides<Ts>>;
|
|
167
242
|
export {};
|
|
168
243
|
//# sourceMappingURL=plugin-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-utils.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-utils.ts"],"names":[],"mapp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,3 +130,103 @@ export function createPaginatedPluginMethod(sdk, config) {
|
|
|
130
130
|
},
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
+
// ----------------------------------------------------------------------------
|
|
134
|
+
// composePlugins — runtime merge helpers
|
|
135
|
+
// ----------------------------------------------------------------------------
|
|
136
|
+
// Three merge rules, one per shape of key the function deals with. Each is
|
|
137
|
+
// a small, single-purpose helper so the main loop reads top-to-bottom.
|
|
138
|
+
/**
|
|
139
|
+
* Merge root-level keys (the SDK methods a plugin contributes) into the
|
|
140
|
+
* accumulator. Throws on collision: composePlugins is bag-mode, so two
|
|
141
|
+
* sub-plugins registering the same method name is a programmer error.
|
|
142
|
+
*/
|
|
143
|
+
function mergeRootKeysWithCollisionCheck(target, source, seen) {
|
|
144
|
+
for (const key of Object.keys(source)) {
|
|
145
|
+
if (seen.has(key)) {
|
|
146
|
+
throw new Error(`composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`);
|
|
147
|
+
}
|
|
148
|
+
seen.add(key);
|
|
149
|
+
target[key] = source[key];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Merge per-method metadata (the registry view of input/output schemas,
|
|
154
|
+
* categories, etc.) with the same collision rule as root keys. Even when
|
|
155
|
+
* two sub-plugins' root method keys differ, registry-level shadowing
|
|
156
|
+
* is dangerous, so silent overwrites aren't allowed.
|
|
157
|
+
*/
|
|
158
|
+
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
159
|
+
for (const key of Object.keys(source)) {
|
|
160
|
+
if (seen.has(key)) {
|
|
161
|
+
throw new Error(`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`);
|
|
162
|
+
}
|
|
163
|
+
seen.add(key);
|
|
164
|
+
target[key] = source[key];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Merge non-meta context keys (everything under `context.*` that isn't
|
|
169
|
+
* `meta`) into the accumulator. Throws on collision — bag mode says
|
|
170
|
+
* sub-plugins shouldn't be re-providing shared infrastructure like
|
|
171
|
+
* `context.api`, so two of them claiming the same context slot is a
|
|
172
|
+
* programmer error. Note that this only applies *inside* a single
|
|
173
|
+
* `composePlugins(...)` call; cross-`addPlugin` overrides go through
|
|
174
|
+
* `addPlugin`'s last-write-wins merge, which is unaffected by this check.
|
|
175
|
+
*/
|
|
176
|
+
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
177
|
+
for (const key of Object.keys(source)) {
|
|
178
|
+
if (seen.has(key)) {
|
|
179
|
+
throw new Error(`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`);
|
|
180
|
+
}
|
|
181
|
+
seen.add(key);
|
|
182
|
+
target[key] = source[key];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Bundle N plugins into a single plugin so a consumer can call
|
|
187
|
+
* `addPlugin(combined)` once. Use this when an extension package wants to
|
|
188
|
+
* expose granular sub-plugins for tree-shaking *and* a one-call convenience
|
|
189
|
+
* entry point.
|
|
190
|
+
*
|
|
191
|
+
* Three commitments (per the boilerplate-reduction design):
|
|
192
|
+
* 1. **Bag mode.** Sub-plugins must not depend on each other; order is
|
|
193
|
+
* irrelevant. If you need pipeline composition (later sub-plugins
|
|
194
|
+
* reading earlier sub-plugins' outputs), use a regular `definePlugin`
|
|
195
|
+
* callback that calls each `createPluginMethod` in turn.
|
|
196
|
+
* 2. **Over-approximation of TSdk.** The composed plugin requires the
|
|
197
|
+
* intersection of every sub-plugin's requirements (all of them, all at
|
|
198
|
+
* once). Works fine for homogeneous-deps groups; widens slightly for
|
|
199
|
+
* heterogeneous ones, which keeps the variadic types tractable.
|
|
200
|
+
* 3. **Collision detection.** Throws on duplicate root keys, duplicate
|
|
201
|
+
* `context.meta` keys, and duplicate non-meta `context.*` keys. Note
|
|
202
|
+
* this only applies *inside* a single `composePlugins(...)` call —
|
|
203
|
+
* cross-`addPlugin` overrides (e.g. a CLI plugin overriding meta from
|
|
204
|
+
* a core SDK plugin) still go through `addPlugin`'s last-write-wins
|
|
205
|
+
* merge unchanged.
|
|
206
|
+
*
|
|
207
|
+
* Why prefer this over an `addPlugin([...])` array overload: TypeScript's
|
|
208
|
+
* overload resolution interacts badly with arrays carrying a mix of
|
|
209
|
+
* `TProvides` shapes — chained inference downstream of `addPlugin([...])`
|
|
210
|
+
* tends to widen and lose individual method types. A single composed
|
|
211
|
+
* plugin flows through the existing single-plugin `addPlugin` cleanly.
|
|
212
|
+
*/
|
|
213
|
+
export function composePlugins(...plugins) {
|
|
214
|
+
return ((sdk) => {
|
|
215
|
+
const merged = { context: { meta: {} } };
|
|
216
|
+
const seenRoot = new Set();
|
|
217
|
+
const seenMeta = new Set();
|
|
218
|
+
const seenContext = new Set();
|
|
219
|
+
for (const plugin of plugins) {
|
|
220
|
+
const { context, ...rootKeys } = plugin(sdk);
|
|
221
|
+
mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
|
|
222
|
+
if (context) {
|
|
223
|
+
const { meta, ...nonMetaContext } = context;
|
|
224
|
+
if (meta) {
|
|
225
|
+
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
226
|
+
}
|
|
227
|
+
mergeContextKeysWithCollisionCheck(merged.context, nonMetaContext, seenContext);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return merged;
|
|
231
|
+
});
|
|
232
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"url": "https://gitlab.com/zapier/zapier-sdk/zapier-sdk.git",
|
|
69
69
|
"directory": "packages/zapier-sdk"
|
|
70
70
|
},
|
|
71
|
+
"homepage": "https://docs.zapier.com/sdk",
|
|
71
72
|
"publishConfig": {
|
|
72
73
|
"access": "public"
|
|
73
74
|
},
|