@zapier/zapier-sdk 0.18.2 → 0.18.4

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 (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -13
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +0 -18
  5. package/dist/api/schemas.d.ts +0 -158
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +0 -95
  8. package/dist/api/types.d.ts +2 -1
  9. package/dist/api/types.d.ts.map +1 -1
  10. package/dist/index.cjs +400 -808
  11. package/dist/index.d.mts +67 -122
  12. package/dist/index.mjs +401 -809
  13. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  14. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  15. package/dist/plugins/listApps/index.d.ts +2 -8
  16. package/dist/plugins/listApps/index.d.ts.map +1 -1
  17. package/dist/plugins/listApps/index.js +4 -6
  18. package/dist/plugins/listApps/index.test.js +62 -82
  19. package/dist/plugins/listApps/schemas.d.ts +35 -14
  20. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  21. package/dist/plugins/listApps/schemas.js +44 -14
  22. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  23. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  24. package/dist/plugins/listAuthentications/index.js +19 -31
  25. package/dist/plugins/listAuthentications/index.test.js +363 -127
  26. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  27. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  28. package/dist/plugins/listAuthentications/schemas.js +10 -16
  29. package/dist/schemas/App.d.ts +28 -28
  30. package/dist/schemas/App.d.ts.map +1 -1
  31. package/dist/schemas/App.js +3 -8
  32. package/dist/sdk.d.ts +2 -2
  33. package/dist/sdk.test.js +12 -9
  34. package/dist/utils/domain-utils.d.ts +2 -15
  35. package/dist/utils/domain-utils.d.ts.map +1 -1
  36. package/dist/utils/domain-utils.js +0 -38
  37. package/dist/utils/function-utils.d.ts +1 -0
  38. package/dist/utils/function-utils.d.ts.map +1 -1
  39. package/dist/utils/function-utils.js +15 -3
  40. package/package.json +2 -2
  41. package/dist/api/client.integration.test.d.ts +0 -5
  42. package/dist/api/client.integration.test.d.ts.map +0 -1
  43. package/dist/api/client.integration.test.js +0 -318
  44. package/dist/api/client.methods.test.d.ts +0 -2
  45. package/dist/api/client.methods.test.d.ts.map +0 -1
  46. package/dist/api/client.methods.test.js +0 -158
  47. package/dist/api/router.d.ts +0 -16
  48. package/dist/api/router.d.ts.map +0 -1
  49. package/dist/api/router.js +0 -31
  50. package/dist/api/router.test.d.ts +0 -2
  51. package/dist/api/router.test.d.ts.map +0 -1
  52. package/dist/api/router.test.js +0 -103
  53. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  54. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  55. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  56. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  57. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  58. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  59. package/dist/temporary-internal-core/index.d.ts +0 -18
  60. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  61. package/dist/temporary-internal-core/index.js +0 -18
  62. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  63. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  64. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  65. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  66. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  67. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  68. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  69. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  70. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  71. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  72. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  73. package/dist/temporary-internal-core/types/handler.js +0 -8
  74. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  75. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  76. package/dist/temporary-internal-core/types/index.js +0 -4
  77. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  78. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  79. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  80. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  81. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  82. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  83. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
  84. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  85. package/dist/temporary-internal-core/utils/transformations.js +0 -74
@@ -1,79 +0,0 @@
1
- /**
2
- * Implementation schemas
3
- *
4
- * Covers:
5
- * - Implementation metadata
6
- * - Implementation listings
7
- * - Version information
8
- */
9
- import { z } from "zod";
10
- /**
11
- * Lightweight implementation metadata returned by /api/v4/implementations-meta/*
12
- */
13
- export const ImplementationMetaSchema = z.object({
14
- id: z.string(),
15
- name: z.string(),
16
- slug: z.string(),
17
- age_in_days: z.number().optional(),
18
- auth_type: z.string().optional(),
19
- banner: z.string().optional(),
20
- categories: z
21
- .array(z.object({
22
- id: z.number(),
23
- name: z.string(),
24
- slug: z.string(),
25
- }))
26
- .optional(),
27
- images: z
28
- .object({
29
- url_16x16: z.string().optional(),
30
- url_32x32: z.string().optional(),
31
- url_64x64: z.string().optional(),
32
- url_128x128: z.string().optional(),
33
- })
34
- .optional(),
35
- popularity: z.number().optional(),
36
- has_filters: z.boolean().optional(),
37
- has_reads: z.boolean().optional(),
38
- has_searches: z.boolean().optional(),
39
- has_searches_or_writes: z.boolean().optional(),
40
- has_upfront_fields: z.boolean().optional(),
41
- has_writes: z.boolean().optional(),
42
- is_beta: z.boolean().optional(),
43
- is_built_in: z.boolean().optional(),
44
- is_deprecated: z.boolean().optional(),
45
- is_featured: z.boolean().optional(),
46
- is_hidden: z.boolean().optional(),
47
- is_invite: z.boolean().optional(),
48
- is_premium: z.boolean().optional(),
49
- is_public: z.boolean().optional(),
50
- is_upcoming: z.boolean().optional(),
51
- version: z.string().optional(),
52
- visibility: z.string().optional(),
53
- actions: z
54
- .object({
55
- read: z.number().optional(),
56
- read_bulk: z.number().optional(),
57
- write: z.number().optional(),
58
- search: z.number().optional(),
59
- search_or_write: z.number().optional(),
60
- search_and_write: z.number().optional(),
61
- filter: z.number().optional(),
62
- })
63
- .optional(),
64
- description: z.string().optional(),
65
- primary_color: z.string().optional(),
66
- secondary_color: z.string().optional(),
67
- classification: z.string().optional(),
68
- api_docs_url: z.string().optional(),
69
- image: z.string().optional(),
70
- });
71
- /**
72
- * Paginated response from /api/v4/implementations-meta/lookup/ and search endpoints
73
- */
74
- export const ImplementationsMetaResponseSchema = z.object({
75
- count: z.number(),
76
- next: z.string().nullable().optional(),
77
- previous: z.string().nullable().optional(),
78
- results: z.array(ImplementationMetaSchema),
79
- });
@@ -1,51 +0,0 @@
1
- /**
2
- * Core handler types for temporary-internal-core
3
- *
4
- * These types define the contract that all handlers must follow.
5
- * This ensures consistency across extractions and makes it easier to
6
- * migrate handlers to the SDK API later.
7
- */
8
- import type { z } from "zod";
9
- /**
10
- * Base interface for handler dependencies
11
- *
12
- * All handlers receive dependencies via dependency injection.
13
- * This allows different implementations in different environments:
14
- * - SDK plugin injects: { httpClient: api } (SDK's ApiClient)
15
- * - SDK API injects: { httpClient: internalClient } (direct internal calls)
16
- * - Tests inject: { httpClient: mockClient } (mocked responses)
17
- *
18
- * Individual handlers define their own dependency interfaces extending this base.
19
- * The base interface is intentionally minimal - handlers specify their exact needs.
20
- */
21
- export interface HandlerDeps {
22
- }
23
- /**
24
- * Generic handler function type
25
- *
26
- * All handlers follow this signature:
27
- * - Take a validated request object
28
- * - Take injected dependencies
29
- * - Return a typed response
30
- *
31
- * @template TRequest - The request type (should match a Zod schema)
32
- * @template TResponse - The response type (should match a Zod schema)
33
- * @template TDeps - The dependencies type (extends HandlerDeps)
34
- */
35
- export interface Handler<TRequest, TResponse, TDeps extends HandlerDeps = HandlerDeps> {
36
- (params: {
37
- request: TRequest;
38
- deps: TDeps;
39
- }): Promise<TResponse>;
40
- }
41
- /**
42
- * Handler with schemas for runtime validation
43
- *
44
- * This extends the Handler interface with Zod schemas that can be used
45
- * for runtime validation of requests and responses.
46
- */
47
- export interface ValidatedHandler<TRequest, TResponse, TDeps extends HandlerDeps = HandlerDeps> extends Handler<TRequest, TResponse, TDeps> {
48
- requestSchema: z.ZodSchema<TRequest>;
49
- responseSchema: z.ZodSchema<TResponse>;
50
- }
51
- //# sourceMappingURL=handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/types/handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;CAG3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO,CACtB,QAAQ,EACR,SAAS,EACT,KAAK,SAAS,WAAW,GAAG,WAAW;IAEvC,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAClE;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAC/B,QAAQ,EACR,SAAS,EACT,KAAK,SAAS,WAAW,GAAG,WAAW,CACvC,SAAQ,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC;IAC3C,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;CACxC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Core handler types for temporary-internal-core
3
- *
4
- * These types define the contract that all handlers must follow.
5
- * This ensures consistency across extractions and makes it easier to
6
- * migrate handlers to the SDK API later.
7
- */
8
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * Core types for temporary-internal-core
3
- */
4
- export type { HandlerDeps, Handler, ValidatedHandler } from "./handler";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -1,4 +0,0 @@
1
- /**
2
- * Core types for temporary-internal-core
3
- */
4
- export {};
@@ -1,34 +0,0 @@
1
- /**
2
- * App locator utilities for resolving app keys to implementation IDs
3
- *
4
- * These utilities handle the mapping between user-friendly app identifiers
5
- * (slugs like "slack") and internal implementation IDs (like "SlackCLIAPI@1.0.0")
6
- */
7
- /**
8
- * Represents an app identifier that may need resolution
9
- */
10
- export interface AppLocator {
11
- lookupAppKey: string;
12
- slug?: string;
13
- implementationName?: string;
14
- version?: string;
15
- }
16
- /**
17
- * An app locator that has been resolved to an implementation name
18
- */
19
- export interface ResolvedAppLocator extends AppLocator {
20
- implementationName: string;
21
- }
22
- /**
23
- * Converts an app key to an app locator structure
24
- */
25
- export declare function toAppLocator(appKey: string): AppLocator;
26
- /**
27
- * Converts a resolved app locator to a full implementation ID
28
- */
29
- export declare function toImplementationId(appLocator: ResolvedAppLocator): string;
30
- /**
31
- * Type guard to check if an app locator has been resolved
32
- */
33
- export declare function isResolvedAppLocator(appLocator: AppLocator): appLocator is ResolvedAppLocator;
34
- //# sourceMappingURL=app-locators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-locators.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/app-locators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAqBvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,GACrB,UAAU,IAAI,kBAAkB,CAElC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * App locator utilities for resolving app keys to implementation IDs
3
- *
4
- * These utilities handle the mapping between user-friendly app identifiers
5
- * (slugs like "slack") and internal implementation IDs (like "SlackCLIAPI@1.0.0")
6
- */
7
- import { dashifySnakeCasedSlug, isSlug, isSnakeCasedSlug, isUuid, splitVersionedKey, } from "./string-utils";
8
- /**
9
- * Converts an app key to an app locator structure
10
- */
11
- export function toAppLocator(appKey) {
12
- const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
13
- if (isUuid(appKeyWithoutVersion)) {
14
- throw new Error(`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`);
15
- }
16
- const slug = isSlug(appKeyWithoutVersion)
17
- ? appKeyWithoutVersion
18
- : isSnakeCasedSlug(appKeyWithoutVersion)
19
- ? dashifySnakeCasedSlug(appKeyWithoutVersion)
20
- : undefined;
21
- return {
22
- lookupAppKey: appKeyWithoutVersion,
23
- slug,
24
- implementationName: slug ? undefined : appKeyWithoutVersion,
25
- version,
26
- };
27
- }
28
- /**
29
- * Converts a resolved app locator to a full implementation ID
30
- */
31
- export function toImplementationId(appLocator) {
32
- return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
33
- }
34
- /**
35
- * Type guard to check if an app locator has been resolved
36
- */
37
- export function isResolvedAppLocator(appLocator) {
38
- return !!appLocator.implementationName;
39
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Splits a versioned key to extract the base key and version
3
- *
4
- * @param versionedKey - Versioned key in format "KeyName@version" (e.g., "SlackCLIAPI@1.21.1")
5
- * @returns Tuple of [baseKey, version] or [versionedKey, undefined] if no @ symbol
6
- *
7
- * @example
8
- * splitVersionedKey("SlackCLIAPI@1.21.1") // ["SlackCLIAPI", "1.21.1"]
9
- * splitVersionedKey("SomeAPI") // ["SomeAPI", undefined]
10
- */
11
- export declare function splitVersionedKey(versionedKey: string): [string, string | undefined];
12
- /**
13
- * Checks if a string is a valid slug (kebab-case)
14
- */
15
- export declare function isSlug(slug: string): boolean;
16
- /**
17
- * Checks if a string is a valid snake_case slug
18
- */
19
- export declare function isSnakeCasedSlug(slug: string): boolean;
20
- /**
21
- * Converts snake_case to kebab-case
22
- */
23
- export declare function dashifySnakeCasedSlug(slug: string): string;
24
- /**
25
- * Checks if a string is a UUID
26
- */
27
- export declare function isUuid(appKey: string): boolean;
28
- //# sourceMappingURL=string-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/string-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GACnB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQ9B;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKtD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU1D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI9C"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Splits a versioned key to extract the base key and version
3
- *
4
- * @param versionedKey - Versioned key in format "KeyName@version" (e.g., "SlackCLIAPI@1.21.1")
5
- * @returns Tuple of [baseKey, version] or [versionedKey, undefined] if no @ symbol
6
- *
7
- * @example
8
- * splitVersionedKey("SlackCLIAPI@1.21.1") // ["SlackCLIAPI", "1.21.1"]
9
- * splitVersionedKey("SomeAPI") // ["SomeAPI", undefined]
10
- */
11
- export function splitVersionedKey(versionedKey) {
12
- const parts = versionedKey.split("@");
13
- if (parts.length >= 2) {
14
- const baseKey = parts[0];
15
- const version = parts.slice(1).join("@"); // Handle edge case of multiple @ symbols
16
- return [baseKey, version];
17
- }
18
- return [versionedKey, undefined];
19
- }
20
- /**
21
- * Checks if a string is a valid slug (kebab-case)
22
- */
23
- export function isSlug(slug) {
24
- return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
25
- }
26
- /**
27
- * Checks if a string is a valid snake_case slug
28
- */
29
- export function isSnakeCasedSlug(slug) {
30
- if (slug.match(/^_[0-9]/)) {
31
- slug = slug.slice(1);
32
- }
33
- return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
34
- }
35
- /**
36
- * Converts snake_case to kebab-case
37
- */
38
- export function dashifySnakeCasedSlug(slug) {
39
- if (!isSnakeCasedSlug(slug)) {
40
- return slug;
41
- }
42
- if (slug.startsWith("_")) {
43
- slug = slug.slice(1);
44
- }
45
- return slug.replace(/_/g, "-");
46
- }
47
- /**
48
- * Checks if a string is a UUID
49
- */
50
- export function isUuid(appKey) {
51
- return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(appKey);
52
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Transformation utilities for converting API responses to SDK types
3
- *
4
- * These will move to SDK API server as part of the response transformation layer
5
- */
6
- import type { ImplementationMeta } from "../schemas/implementations";
7
- import type { AppItem } from "../schemas/apps";
8
- import { type Authentication, type AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
9
- /**
10
- * Transforms ImplementationMeta from internal API to AppItem for SDK responses
11
- */
12
- export declare function transformImplementationMetaToAppItem(implementationMeta: ImplementationMeta): AppItem;
13
- /**
14
- * Extracts pagination cursor from API response
15
- */
16
- export declare function extractPaginationCursor(response: {
17
- next?: string | null;
18
- }): string | undefined;
19
- /**
20
- * Converts an API Authentication to an AuthenticationItem with normalized field names
21
- *
22
- * @param auth - Raw Authentication from API
23
- * @param options - Additional fields to include
24
- * @param options.app_key - selected_api from implementations endpoint
25
- * @param options.app_version - Version extracted from selected_api
26
- * @returns Normalized AuthenticationItem
27
- */
28
- export declare function normalizeAuthenticationItem(auth: Authentication, options?: {
29
- app_key?: string;
30
- app_version?: string;
31
- }): AuthenticationItem;
32
- //# sourceMappingURL=transformations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/transformations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,wBAAgB,oCAAoC,CAClD,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAYT;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAChD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAYrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACvD,kBAAkB,CAyCpB"}
@@ -1,74 +0,0 @@
1
- /**
2
- * Transformation utilities for converting API responses to SDK types
3
- *
4
- * These will move to SDK API server as part of the response transformation layer
5
- */
6
- import { splitVersionedKey } from "./string-utils";
7
- /**
8
- * Transforms ImplementationMeta from internal API to AppItem for SDK responses
9
- */
10
- export function transformImplementationMetaToAppItem(implementationMeta) {
11
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
12
- const { id, name, ...restOfImplementationMeta } = implementationMeta;
13
- return {
14
- ...restOfImplementationMeta,
15
- title: name,
16
- key: selectedApi,
17
- implementation_id: id,
18
- version: appVersion,
19
- };
20
- }
21
- /**
22
- * Extracts pagination cursor from API response
23
- */
24
- export function extractPaginationCursor(response) {
25
- if (!response.next) {
26
- return undefined;
27
- }
28
- try {
29
- const url = new URL(response.next);
30
- const offset = url.searchParams.get("offset");
31
- return offset || undefined;
32
- }
33
- catch {
34
- return undefined;
35
- }
36
- }
37
- /**
38
- * Converts an API Authentication to an AuthenticationItem with normalized field names
39
- *
40
- * @param auth - Raw Authentication from API
41
- * @param options - Additional fields to include
42
- * @param options.app_key - selected_api from implementations endpoint
43
- * @param options.app_version - Version extracted from selected_api
44
- * @returns Normalized AuthenticationItem
45
- */
46
- export function normalizeAuthenticationItem(auth, options = {}) {
47
- // Extract app key and version from selected_api if not provided
48
- let appKey = options.app_key;
49
- let appVersion = options.app_version;
50
- if (auth.selected_api) {
51
- const [extractedAppKey, extractedVersion] = splitVersionedKey(auth.selected_api);
52
- // Use extracted app key if not provided in options
53
- if (!appKey) {
54
- appKey = extractedAppKey;
55
- }
56
- // Use extracted version if not provided in options
57
- if (!appVersion) {
58
- appVersion = extractedVersion;
59
- }
60
- }
61
- const { selected_api: selectedApi, customuser_id: profileId, id, account_id: accountId, ...restOfAuth } = auth;
62
- return {
63
- ...restOfAuth, // Pass through all other API response fields except selected_api
64
- id: String(id), // Convert to string
65
- account_id: String(accountId), // Convert to string
66
- implementation_id: selectedApi, // Rename selected_api to implementation_id
67
- title: auth.title || auth.label || undefined, // Coerce title from label if missing
68
- is_expired: auth.is_stale, // Map is_stale to is_expired
69
- expired_at: auth.marked_stale_at, // Map marked_stale_at to expired_at
70
- app_key: appKey, // App key from implementations endpoint or parsed from selected_api
71
- app_version: appVersion, // Version from selected_api or provided
72
- profile_id: profileId != null ? String(profileId) : undefined, // Map customuser_id to profile_id, convert to string
73
- };
74
- }