@zapier/zapier-sdk 0.18.1 → 0.18.3

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +17 -17
  3. package/dist/api/router.d.ts.map +1 -1
  4. package/dist/api/router.js +1 -7
  5. package/dist/api/router.test.js +1 -7
  6. package/dist/api/schemas.d.ts +0 -49
  7. package/dist/api/schemas.d.ts.map +1 -1
  8. package/dist/api/schemas.js +0 -28
  9. package/dist/api/types.d.ts +2 -1
  10. package/dist/api/types.d.ts.map +1 -1
  11. package/dist/api/types.js +0 -10
  12. package/dist/index.cjs +38 -301
  13. package/dist/index.d.mts +114 -207
  14. package/dist/index.mjs +38 -301
  15. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  16. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  17. package/dist/plugins/getAuthentication/index.d.ts +3 -3
  18. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  19. package/dist/plugins/getAuthentication/index.js +3 -5
  20. package/dist/plugins/getAuthentication/index.test.js +4 -16
  21. package/dist/plugins/getAuthentication/schemas.d.ts +2 -4
  22. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
  23. package/dist/plugins/getAuthentication/schemas.js +1 -1
  24. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  25. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  26. package/dist/plugins/listAuthentications/index.js +19 -31
  27. package/dist/plugins/listAuthentications/index.test.js +347 -127
  28. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  29. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  30. package/dist/plugins/listAuthentications/schemas.js +10 -16
  31. package/dist/schemas/Auth.d.ts +11 -11
  32. package/dist/schemas/Auth.d.ts.map +1 -1
  33. package/dist/schemas/Auth.js +2 -12
  34. package/dist/sdk.d.ts +4 -2
  35. package/dist/sdk.d.ts.map +1 -1
  36. package/dist/temporary-internal-core/index.d.ts +0 -2
  37. package/dist/temporary-internal-core/index.d.ts.map +1 -1
  38. package/dist/temporary-internal-core/index.js +0 -2
  39. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -14
  40. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  41. package/dist/temporary-internal-core/utils/transformations.js +0 -38
  42. package/dist/utils/domain-utils.d.ts +2 -15
  43. package/dist/utils/domain-utils.d.ts.map +1 -1
  44. package/dist/utils/domain-utils.js +0 -38
  45. package/dist/utils/function-utils.d.ts +1 -0
  46. package/dist/utils/function-utils.d.ts.map +1 -1
  47. package/dist/utils/function-utils.js +15 -3
  48. package/package.json +2 -1
  49. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +0 -94
  50. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +0 -1
  51. package/dist/temporary-internal-core/handlers/getAuthentication.js +0 -68
  52. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +0 -2
  53. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +0 -1
  54. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +0 -248
  55. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +0 -150
  56. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +0 -1
  57. package/dist/temporary-internal-core/schemas/authentications/index.js +0 -97
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { ListAuthenticationsQuerySchema as ListAuthenticationsQuerySchema$1, AuthenticationItemSchema as AuthenticationItemSchema$1, GetAuthenticationParamSchema } from '@zapier/zapier-sdk-core/v0/schemas/authentications';
2
3
  import { setTimeout as setTimeout$1 } from 'timers/promises';
3
4
  import * as os from 'os';
4
5
 
@@ -693,10 +694,16 @@ function createPageFunction(coreFn) {
693
694
  try {
694
695
  const result = await coreFn(options);
695
696
  if (result && typeof result === "object" && "data" in result) {
696
- const data = result.data;
697
+ const paginatedResult = result;
698
+ let nextCursor;
699
+ if (paginatedResult.nextCursor) {
700
+ nextCursor = paginatedResult.nextCursor;
701
+ } else if (paginatedResult.links?.next) {
702
+ nextCursor = extractCursor({ next: paginatedResult.links.next });
703
+ }
697
704
  return {
698
- data: Array.isArray(data) ? data : [data],
699
- nextCursor: result.nextCursor
705
+ data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
706
+ nextCursor
700
707
  };
701
708
  }
702
709
  if (Array.isArray(result)) {
@@ -1002,34 +1009,6 @@ z.object({
1002
1009
  format: z.string().optional(),
1003
1010
  inputFormat: z.array(z.string()).optional()
1004
1011
  });
1005
- var AuthenticationSchema = z.object({
1006
- id: z.number(),
1007
- date: z.string(),
1008
- lastchanged: z.string().optional(),
1009
- account_id: z.number(),
1010
- customuser_id: z.number().optional(),
1011
- selected_api: z.string(),
1012
- destination_selected_api: z.string().nullable().optional(),
1013
- is_invite_only: z.boolean(),
1014
- is_private: z.boolean(),
1015
- shared_with_all: z.boolean(),
1016
- is_stale: z.string().optional(),
1017
- is_shared: z.string().optional(),
1018
- marked_stale_at: z.string().nullable().optional(),
1019
- label: z.string().nullable().optional(),
1020
- identifier: z.string().nullable().optional(),
1021
- title: z.string().nullable().optional(),
1022
- url: z.string().optional(),
1023
- groups: z.string().optional(),
1024
- members: z.string().optional(),
1025
- permissions: z.record(z.string(), z.boolean()).optional()
1026
- });
1027
- z.object({
1028
- count: z.number(),
1029
- next: z.string().nullable().optional(),
1030
- previous: z.string().nullable().optional(),
1031
- results: z.array(AuthenticationSchema)
1032
- });
1033
1012
  z.object({
1034
1013
  id: z.number(),
1035
1014
  code: z.string(),
@@ -1420,50 +1399,6 @@ function normalizeImplementationMetaToAppItem(implementationMeta) {
1420
1399
  version: appVersion
1421
1400
  };
1422
1401
  }
1423
- function normalizeAuthenticationItem(auth, options = {}) {
1424
- let appKey = options.app_key;
1425
- let appVersion = options.app_version;
1426
- if (auth.selected_api) {
1427
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
1428
- auth.selected_api
1429
- );
1430
- if (!appKey) {
1431
- appKey = extractedAppKey;
1432
- }
1433
- if (!appVersion) {
1434
- appVersion = extractedVersion;
1435
- }
1436
- }
1437
- const {
1438
- selected_api: selectedApi,
1439
- customuser_id: profileId,
1440
- id,
1441
- account_id: accountId,
1442
- ...restOfAuth
1443
- } = auth;
1444
- return {
1445
- ...restOfAuth,
1446
- // Pass through all other API response fields except selected_api
1447
- id: String(id),
1448
- // Convert to string
1449
- account_id: String(accountId),
1450
- // Convert to string
1451
- implementation_id: selectedApi,
1452
- // Rename selected_api to implementation_id
1453
- title: auth.title || auth.label || void 0,
1454
- // Coerce title from label if missing
1455
- is_expired: auth.is_stale,
1456
- // Map is_stale to is_expired
1457
- expired_at: auth.marked_stale_at,
1458
- // Map marked_stale_at to expired_at
1459
- app_key: appKey,
1460
- // App key from implementations endpoint or parsed from selected_api
1461
- app_version: appVersion,
1462
- // Version from selected_api or provided
1463
- profile_id: profileId != null ? String(profileId) : void 0
1464
- // Map customuser_id to profile_id, convert to string
1465
- };
1466
- }
1467
1402
  function normalizeActionItem(action) {
1468
1403
  const { name, type, selected_api: selectedApi } = action;
1469
1404
  const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
@@ -2225,42 +2160,26 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
2225
2160
  }
2226
2161
  };
2227
2162
  };
2228
- var ListAuthenticationsSchema = z.object({
2163
+ var ListAuthenticationsQuerySchema = ListAuthenticationsQuerySchema$1.omit(
2164
+ {
2165
+ offset: true
2166
+ }
2167
+ ).extend({
2168
+ // Override appKey with our custom schema (array type, different description)
2229
2169
  appKey: AppKeyPropertySchema.optional().describe(
2230
2170
  "App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')"
2231
2171
  ),
2172
+ // Override authenticationIds to be an array instead of comma-separated string
2232
2173
  authenticationIds: z.array(z.string()).optional().describe("List of authentication IDs to filter by"),
2233
- search: z.string().optional().describe("Search term to filter authentications by title"),
2234
- title: z.string().optional().describe("Filter authentications by exact title match"),
2235
- accountId: z.string().optional().describe("Filter by account ID"),
2236
- owner: z.union([z.string(), z.literal("me")]).optional().describe(
2237
- "Filter by owner, 'me' for your own authentications or a specific user ID"
2238
- ),
2174
+ // Override pageSize to make optional (needs to be fixed in `zapier-sdk-core`)
2239
2175
  pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
2176
+ // SDK specific property for pagination/iterator helpers
2240
2177
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
2178
+ // SDK specific property for pagination/iterator helpers
2241
2179
  cursor: z.string().optional().describe("Cursor to start from")
2242
2180
  }).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
2243
2181
  var AuthenticationItemSchema = withFormatter(
2244
- AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
2245
- {
2246
- id: z.string(),
2247
- // Converted from number
2248
- account_id: z.string(),
2249
- // Converted from number
2250
- implementation_id: z.string().optional(),
2251
- // Renamed from selected_api
2252
- is_expired: z.string().optional(),
2253
- // Mapped from is_stale
2254
- expired_at: z.string().nullable().optional(),
2255
- // Mapped from marked_stale_at
2256
- app_key: z.string().optional(),
2257
- // App key from implementations endpoint
2258
- app_version: z.string().optional(),
2259
- // Version extracted from implementation_id
2260
- profile_id: z.string().optional()
2261
- // Mapped from customuser_id, converted from number
2262
- }
2263
- ),
2182
+ AuthenticationItemSchema$1,
2264
2183
  {
2265
2184
  format: (item) => {
2266
2185
  const details = [];
@@ -2293,36 +2212,38 @@ var AuthenticationItemSchema = withFormatter(
2293
2212
  var listAuthenticationsPlugin = ({ context }) => {
2294
2213
  async function listAuthenticationsPage(options) {
2295
2214
  const { api, getVersionedImplementationId } = context;
2296
- const searchParams = {};
2215
+ const searchParams = {
2216
+ pageSize: options.pageSize.toString()
2217
+ };
2297
2218
  if (options.appKey) {
2298
2219
  const implementationId = await getVersionedImplementationId(
2299
2220
  options.appKey
2300
2221
  );
2301
2222
  if (implementationId) {
2302
2223
  const [versionlessSelectedApi] = splitVersionedKey(implementationId);
2303
- searchParams.versionless_selected_api = versionlessSelectedApi;
2224
+ searchParams.appKey = versionlessSelectedApi;
2304
2225
  }
2305
2226
  }
2306
2227
  if (options.authenticationIds && options.authenticationIds.length > 0) {
2307
- searchParams.ids = options.authenticationIds.join(",");
2228
+ searchParams.authenticationIds = options.authenticationIds.join(",");
2308
2229
  }
2309
2230
  if (options.search) {
2310
2231
  searchParams.search = options.search;
2311
- } else if (options.title) {
2312
- searchParams.search = options.title;
2232
+ }
2233
+ if (options.title) {
2234
+ searchParams.title = options.title;
2313
2235
  }
2314
2236
  if (options.accountId) {
2315
- searchParams.account_id = options.accountId;
2237
+ searchParams.accountId = options.accountId;
2316
2238
  }
2317
2239
  if (options.owner) {
2318
2240
  searchParams.owner = options.owner;
2319
2241
  }
2320
- searchParams.limit = options.pageSize.toString();
2321
2242
  if (options.cursor) {
2322
2243
  searchParams.offset = options.cursor;
2323
2244
  }
2324
- const data = await api.get(
2325
- "/zapier/api/v4/authentications/",
2245
+ const response = await api.get(
2246
+ "/api/v0/authentications",
2326
2247
  {
2327
2248
  searchParams,
2328
2249
  customErrorHandler: ({ status }) => {
@@ -2343,21 +2264,12 @@ var listAuthenticationsPlugin = ({ context }) => {
2343
2264
  authRequired: true
2344
2265
  }
2345
2266
  );
2346
- let auths = (data.results || []).map(
2347
- (auth) => normalizeAuthenticationItem(auth)
2348
- );
2349
- if (options.title) {
2350
- auths = auths.filter((auth) => auth.title === options.title);
2351
- }
2352
- return {
2353
- data: auths,
2354
- nextCursor: extractCursor(data)
2355
- };
2267
+ return response;
2356
2268
  }
2357
2269
  const methodName = stripPageSuffix(listAuthenticationsPage.name);
2358
2270
  const listAuthenticationsDefinition = createPaginatedFunction(
2359
2271
  listAuthenticationsPage,
2360
- ListAuthenticationsSchema,
2272
+ ListAuthenticationsQuerySchema,
2361
2273
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2362
2274
  methodName
2363
2275
  );
@@ -2369,7 +2281,7 @@ var listAuthenticationsPlugin = ({ context }) => {
2369
2281
  categories: ["authentication"],
2370
2282
  type: "list",
2371
2283
  itemType: "Authentication",
2372
- inputSchema: ListAuthenticationsSchema,
2284
+ inputSchema: ListAuthenticationsQuerySchema,
2373
2285
  outputSchema: AuthenticationItemSchema,
2374
2286
  resolvers: {
2375
2287
  appKey: appKeyResolver
@@ -2475,64 +2387,6 @@ var getActionPlugin = ({ sdk, context }) => {
2475
2387
  }
2476
2388
  };
2477
2389
  };
2478
- var AuthenticationSchema2 = z.object({
2479
- id: z.number(),
2480
- date: z.string(),
2481
- lastchanged: z.string().optional(),
2482
- account_id: z.number(),
2483
- customuser_id: z.number().optional(),
2484
- selected_api: z.string(),
2485
- destination_selected_api: z.string().nullable().optional(),
2486
- is_invite_only: z.boolean(),
2487
- is_private: z.boolean(),
2488
- shared_with_all: z.boolean(),
2489
- is_stale: z.string().optional(),
2490
- is_shared: z.string().optional(),
2491
- marked_stale_at: z.string().nullable().optional(),
2492
- label: z.string().nullable().optional(),
2493
- identifier: z.string().nullable().optional(),
2494
- title: z.string().nullable().optional(),
2495
- url: z.string().optional(),
2496
- groups: z.string().optional(),
2497
- members: z.string().optional(),
2498
- permissions: z.record(z.string(), z.boolean()).optional()
2499
- });
2500
- z.object({
2501
- count: z.number(),
2502
- next: z.string().nullable().optional(),
2503
- previous: z.string().nullable().optional(),
2504
- results: z.array(AuthenticationSchema2)
2505
- });
2506
- var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
2507
- selected_api: true,
2508
- customuser_id: true
2509
- }).extend({
2510
- // Override numeric IDs with string versions (converted by normalizeAuthenticationItem)
2511
- id: z.string(),
2512
- account_id: z.string(),
2513
- // Renamed fields
2514
- implementation_id: z.string().optional(),
2515
- profile_id: z.string().optional(),
2516
- // Mapped fields (originals preserved in ...restOfAuth)
2517
- is_expired: z.string().optional(),
2518
- expired_at: z.string().nullable().optional(),
2519
- // Computed fields
2520
- app_key: z.string().optional(),
2521
- app_version: z.string().optional()
2522
- });
2523
- var GetAuthenticationOptionsSchema = z.object({
2524
- authenticationId: z.union([z.string(), z.number().int().positive()]).describe("Authentication ID to retrieve")
2525
- }).describe("Get a specific authentication by ID");
2526
- var GetAuthenticationHandlerRequestSchema = z.object({
2527
- authenticationId: z.union([z.string(), z.number()]).describe("Authentication ID - string from searchParams or number")
2528
- }).transform((data) => ({
2529
- authenticationId: typeof data.authenticationId === "string" ? parseInt(data.authenticationId, 10) : data.authenticationId
2530
- }));
2531
- z.object({
2532
- data: z.lazy(() => AuthenticationItemSchema2)
2533
- });
2534
-
2535
- // src/plugins/getAuthentication/index.ts
2536
2390
  var getAuthenticationPlugin = ({ context }) => {
2537
2391
  async function getAuthentication(options) {
2538
2392
  const { api } = context;
@@ -2542,7 +2396,7 @@ var getAuthenticationPlugin = ({ context }) => {
2542
2396
  }
2543
2397
  const getAuthenticationDefinition = createFunction(
2544
2398
  getAuthentication,
2545
- GetAuthenticationOptionsSchema,
2399
+ GetAuthenticationParamSchema,
2546
2400
  createTelemetryCallback(
2547
2401
  context.eventEmission.emitMethodCalled,
2548
2402
  getAuthentication.name
@@ -2556,7 +2410,7 @@ var getAuthenticationPlugin = ({ context }) => {
2556
2410
  categories: ["authentication"],
2557
2411
  type: "item",
2558
2412
  itemType: "Authentication",
2559
- inputSchema: GetAuthenticationOptionsSchema,
2413
+ inputSchema: GetAuthenticationParamSchema,
2560
2414
  outputSchema: AuthenticationItemSchema,
2561
2415
  resolvers: {
2562
2416
  authenticationId: authenticationIdGenericResolver
@@ -3854,50 +3708,6 @@ function extractPaginationCursor(response) {
3854
3708
  return void 0;
3855
3709
  }
3856
3710
  }
3857
- function normalizeAuthenticationItem2(auth, options = {}) {
3858
- let appKey = options.app_key;
3859
- let appVersion = options.app_version;
3860
- if (auth.selected_api) {
3861
- const [extractedAppKey, extractedVersion] = splitVersionedKey2(
3862
- auth.selected_api
3863
- );
3864
- if (!appKey) {
3865
- appKey = extractedAppKey;
3866
- }
3867
- if (!appVersion) {
3868
- appVersion = extractedVersion;
3869
- }
3870
- }
3871
- const {
3872
- selected_api: selectedApi,
3873
- customuser_id: profileId,
3874
- id,
3875
- account_id: accountId,
3876
- ...restOfAuth
3877
- } = auth;
3878
- return {
3879
- ...restOfAuth,
3880
- // Pass through all other API response fields except selected_api
3881
- id: String(id),
3882
- // Convert to string
3883
- account_id: String(accountId),
3884
- // Convert to string
3885
- implementation_id: selectedApi,
3886
- // Rename selected_api to implementation_id
3887
- title: auth.title || auth.label || void 0,
3888
- // Coerce title from label if missing
3889
- is_expired: auth.is_stale,
3890
- // Map is_stale to is_expired
3891
- expired_at: auth.marked_stale_at,
3892
- // Map marked_stale_at to expired_at
3893
- app_key: appKey,
3894
- // App key from implementations endpoint or parsed from selected_api
3895
- app_version: appVersion,
3896
- // Version from selected_api or provided
3897
- profile_id: profileId != null ? String(profileId) : void 0
3898
- // Map customuser_id to profile_id, convert to string
3899
- };
3900
- }
3901
3711
 
3902
3712
  // src/temporary-internal-core/handlers/listApps.ts
3903
3713
  var DEFAULT_PAGE_SIZE = 20;
@@ -4001,73 +3811,6 @@ var handleListApps = async ({ request, deps }) => {
4001
3811
  };
4002
3812
  };
4003
3813
 
4004
- // src/temporary-internal-core/schemas/errors/index.ts
4005
- var ZapierError2 = class extends Error {
4006
- constructor(message, options = {}) {
4007
- super(message);
4008
- this.statusCode = options.statusCode;
4009
- this.errors = options.errors;
4010
- this.cause = options.cause;
4011
- this.response = options.response;
4012
- Object.setPrototypeOf(this, new.target.prototype);
4013
- }
4014
- };
4015
- var ZapierAuthenticationError2 = class extends ZapierError2 {
4016
- constructor(message, options = {}) {
4017
- super(message, options);
4018
- this.name = "ZapierAuthenticationError";
4019
- }
4020
- };
4021
- var ZapierResourceNotFoundError2 = class extends ZapierError2 {
4022
- constructor(message, options = {}) {
4023
- super(message, options);
4024
- this.name = "ZapierResourceNotFoundError";
4025
- this.resourceType = options.resourceType;
4026
- this.resourceId = options.resourceId;
4027
- }
4028
- };
4029
-
4030
- // src/temporary-internal-core/handlers/getAuthentication.ts
4031
- var handleGetAuthentication = async ({ request, deps }) => {
4032
- const validatedRequest = GetAuthenticationHandlerRequestSchema.parse(request);
4033
- const { httpClient } = deps;
4034
- const { authenticationId } = validatedRequest;
4035
- const authentication = await httpClient.get(
4036
- `/zapier/api/v4/authentications/${authenticationId}/`,
4037
- {
4038
- authRequired: true,
4039
- customErrorHandler: ({ status }) => {
4040
- if (status === 401) {
4041
- return new ZapierAuthenticationError2(
4042
- `Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
4043
- { statusCode: status }
4044
- );
4045
- }
4046
- if (status === 403) {
4047
- return new ZapierAuthenticationError2(
4048
- `Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`,
4049
- { statusCode: status }
4050
- );
4051
- }
4052
- if (status === 404) {
4053
- return new ZapierResourceNotFoundError2(
4054
- `Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`,
4055
- {
4056
- resourceType: "Authentication",
4057
- resourceId: String(authenticationId)
4058
- }
4059
- );
4060
- }
4061
- return void 0;
4062
- }
4063
- }
4064
- );
4065
- const normalizedAuthentication = normalizeAuthenticationItem2(authentication);
4066
- return {
4067
- data: normalizedAuthentication
4068
- };
4069
- };
4070
-
4071
3814
  // src/api/router.ts
4072
3815
  var routes = [
4073
3816
  {
@@ -4075,12 +3818,6 @@ var routes = [
4075
3818
  pattern: /^\/api\/v0\/apps$/,
4076
3819
  handler: handleListApps,
4077
3820
  paramMap: []
4078
- },
4079
- {
4080
- method: "GET",
4081
- pattern: /^\/api\/v0\/authentications\/([^\/]+)$/,
4082
- handler: handleGetAuthentication,
4083
- paramMap: ["authenticationId"]
4084
3821
  }
4085
3822
  ];
4086
3823
  function findMatchingRoute(routeList, method, path) {
@@ -5050,7 +4787,7 @@ function getCpuTime() {
5050
4787
 
5051
4788
  // package.json
5052
4789
  var package_default = {
5053
- version: "0.18.1"};
4790
+ version: "0.18.3"};
5054
4791
 
5055
4792
  // src/plugins/eventEmission/builders.ts
5056
4793
  function createBaseEvent(context = {}) {
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError } from "../../types/errors";
3
3
  import { findFirstAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
5
+ import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
7
  const mockAuthentications = [
8
8
  {
@@ -45,7 +45,7 @@ describe("findFirstAuthentication plugin", () => {
45
45
  context: {
46
46
  meta: {
47
47
  listAuthentications: {
48
- inputSchema: ListAuthenticationsSchema,
48
+ inputSchema: ListAuthenticationsQuerySchema,
49
49
  },
50
50
  },
51
51
  },
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
3
  import { findUniqueAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
5
+ import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
7
  const mockAuthentication = {
8
8
  id: "123",
@@ -46,7 +46,7 @@ describe("findUniqueAuthentication plugin", () => {
46
46
  context: {
47
47
  meta: {
48
48
  listAuthentications: {
49
- inputSchema: ListAuthenticationsSchema,
49
+ inputSchema: ListAuthenticationsQuerySchema,
50
50
  },
51
51
  },
52
52
  },
@@ -1,13 +1,13 @@
1
1
  import type { Plugin } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
- import { GetAuthenticationSchema, type GetAuthenticationOptions, type GetAuthenticationResponse } from "./schemas";
4
3
  import type { EventEmissionContext } from "../eventEmission";
4
+ import { GetAuthenticationParamSchema, type GetAuthenticationParam, type GetAuthenticationResponse } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
5
5
  export interface GetAuthenticationPluginProvides {
6
- getAuthentication: (options: GetAuthenticationOptions) => Promise<GetAuthenticationResponse>;
6
+ getAuthentication: (options: GetAuthenticationParam) => Promise<GetAuthenticationResponse>;
7
7
  context: {
8
8
  meta: {
9
9
  getAuthentication: {
10
- inputSchema: typeof GetAuthenticationSchema;
10
+ inputSchema: typeof GetAuthenticationParamSchema;
11
11
  };
12
12
  };
13
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,+BAA+B,CAsChC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EACL,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,oDAAoD,CAAC;AAE5D,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,4BAA4B,CAAC;aAClD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,+BAA+B,CAoChC,CAAC"}
@@ -1,16 +1,14 @@
1
- import { GetAuthenticationSchema, } from "./schemas";
2
1
  import { createFunction } from "../../utils/function-utils";
3
2
  import { authenticationIdGenericResolver } from "../../resolvers";
4
3
  import { AuthenticationItemSchema } from "../../schemas/Auth";
5
4
  import { createTelemetryCallback } from "../../utils/telemetry-utils";
5
+ import { GetAuthenticationParamSchema, } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
6
6
  export const getAuthenticationPlugin = ({ context }) => {
7
7
  async function getAuthentication(options) {
8
8
  const { api } = context;
9
- // Call the SDK API endpoint, which will be routed to the handler via handlerOverride in pathConfig.
10
- // When the handler is migrated to SDK API, this same API call will go over the network.
11
9
  return await api.get(`/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`);
12
10
  }
13
- const getAuthenticationDefinition = createFunction(getAuthentication, GetAuthenticationSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getAuthentication.name));
11
+ const getAuthenticationDefinition = createFunction(getAuthentication, GetAuthenticationParamSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getAuthentication.name));
14
12
  return {
15
13
  getAuthentication: getAuthenticationDefinition,
16
14
  context: {
@@ -19,7 +17,7 @@ export const getAuthenticationPlugin = ({ context }) => {
19
17
  categories: ["authentication"],
20
18
  type: "item",
21
19
  itemType: "Authentication",
22
- inputSchema: GetAuthenticationSchema,
20
+ inputSchema: GetAuthenticationParamSchema,
23
21
  outputSchema: AuthenticationItemSchema,
24
22
  resolvers: {
25
23
  authenticationId: authenticationIdGenericResolver,
@@ -53,22 +53,10 @@ describe("getAuthentication plugin", () => {
53
53
  authenticationId: true,
54
54
  })).rejects.toThrow(ZapierValidationError);
55
55
  });
56
- it("should throw validation error for negative authenticationId", async () => {
57
- const sdk = createTestSdk();
58
- await expect(sdk.getAuthentication({
59
- authenticationId: -1,
60
- })).rejects.toThrow(ZapierValidationError);
61
- });
62
- it("should throw validation error for zero authenticationId", async () => {
63
- const sdk = createTestSdk();
64
- await expect(sdk.getAuthentication({
65
- authenticationId: 0,
66
- })).rejects.toThrow(ZapierValidationError);
67
- });
68
56
  it("should accept valid authenticationId", async () => {
69
57
  const sdk = createTestSdk();
70
58
  const result = await sdk.getAuthentication({
71
- authenticationId: 123,
59
+ authenticationId: "123",
72
60
  });
73
61
  expect(result.data).toBeDefined();
74
62
  expect(result.data.id).toBe("123");
@@ -77,7 +65,7 @@ describe("getAuthentication plugin", () => {
77
65
  describe("SDK API endpoint routing", () => {
78
66
  it("should call the correct SDK API endpoint with path params", async () => {
79
67
  const sdk = createTestSdk();
80
- await sdk.getAuthentication({ authenticationId: 123 });
68
+ await sdk.getAuthentication({ authenticationId: "123" });
81
69
  expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/123");
82
70
  });
83
71
  it("should URI encode string authenticationId in path", async () => {
@@ -87,7 +75,7 @@ describe("getAuthentication plugin", () => {
87
75
  });
88
76
  it("should return data from API response", async () => {
89
77
  const sdk = createTestSdk();
90
- const result = await sdk.getAuthentication({ authenticationId: 123 });
78
+ const result = await sdk.getAuthentication({ authenticationId: "123" });
91
79
  expect(result.data).toEqual(mockAuthenticationItem);
92
80
  });
93
81
  });
@@ -95,7 +83,7 @@ describe("getAuthentication plugin", () => {
95
83
  it("should propagate errors from API client", async () => {
96
84
  mockApiClient.get = vi.fn().mockRejectedValue(new Error("API error"));
97
85
  const sdk = createTestSdk();
98
- await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow("API error");
86
+ await expect(sdk.getAuthentication({ authenticationId: "123" })).rejects.toThrow("API error");
99
87
  });
100
88
  });
101
89
  describe("plugin metadata", () => {
@@ -1,9 +1,7 @@
1
- import type { GetAuthenticationResponse } from "../../temporary-internal-core";
1
+ import type { GetAuthenticationResponse, GetAuthenticationParam } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
2
2
  import type { ZapierAuthenticationError, ZapierResourceNotFoundError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
3
- import type { GetAuthenticationOptions } from "../../temporary-internal-core/schemas/authentications";
4
- export { GetAuthenticationOptionsSchema as GetAuthenticationSchema, GetAuthenticationHandlerRequestSchema, GetAuthenticationResponseSchema, type GetAuthenticationOptions, type GetAuthenticationHandlerRequest, type GetAuthenticationResponse, } from "../../temporary-internal-core/schemas/authentications";
5
3
  export type GetAuthenticationError = ZapierAuthenticationError | ZapierResourceNotFoundError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
6
4
  export interface GetAuthenticationSdkFunction {
7
- getAuthentication: (options: GetAuthenticationOptions) => Promise<GetAuthenticationResponse>;
5
+ getAuthentication: (options: GetAuthenticationParam) => Promise<GetAuthenticationResponse>;
8
6
  }
9
7
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAEtG,OAAO,EACL,8BAA8B,IAAI,uBAAuB,EACzD,qCAAqC,EACrC,+BAA+B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,GAC/B,MAAM,uDAAuD,CAAC;AAG/D,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,2BAA2B,GAC3B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACzC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,2BAA2B,GAC3B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACzC"}
@@ -1 +1 @@
1
- export { GetAuthenticationOptionsSchema as GetAuthenticationSchema, GetAuthenticationHandlerRequestSchema, GetAuthenticationResponseSchema, } from "../../temporary-internal-core/schemas/authentications";
1
+ export {};
@@ -1,24 +1,18 @@
1
1
  import type { Plugin, GetSdkType } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
- import type { AuthenticationItem } from "../../types/domain";
4
- import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
3
+ import type { AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
4
+ import { ListAuthenticationsQuerySchema, type ListAuthenticationsOptions, type ListAuthenticationsPage } from "./schemas";
5
5
  import type { GetVersionedImplementationId } from "../manifest/schemas";
6
6
  import type { ManifestPluginProvides } from "../manifest";
7
7
  import type { EventEmissionContext } from "../eventEmission";
8
8
  export interface ListAuthenticationsPluginProvides {
9
- listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
10
- data: AuthenticationItem[];
11
- nextCursor?: string;
12
- }> & AsyncIterable<{
13
- data: AuthenticationItem[];
14
- nextCursor?: string;
15
- }> & {
9
+ listAuthentications: (options?: ListAuthenticationsOptions) => Promise<ListAuthenticationsPage> & AsyncIterable<ListAuthenticationsPage> & {
16
10
  items(): AsyncIterable<AuthenticationItem>;
17
11
  };
18
12
  context: {
19
13
  meta: {
20
14
  listAuthentications: {
21
- inputSchema: typeof ListAuthenticationsSchema;
15
+ inputSchema: typeof ListAuthenticationsQuerySchema;
22
16
  };
23
17
  };
24
18
  };