@zapier/zapier-sdk 0.15.1 → 0.15.2
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 +6 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.integration.test.d.ts +5 -0
- package/dist/api/client.integration.test.d.ts.map +1 -0
- package/dist/api/client.integration.test.js +318 -0
- package/dist/api/client.js +31 -1
- package/dist/index.cjs +304 -104
- package/dist/index.d.mts +243 -31
- package/dist/index.mjs +304 -104
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts +1 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +18 -44
- package/dist/plugins/listApps/index.test.js +89 -288
- package/dist/plugins/listApps/schemas.d.ts +19 -26
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +19 -18
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/sdk.d.ts +1 -1
- package/dist/temporary-internal-core/handlers/listApps.d.ts +67 -0
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.js +121 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +2 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.test.js +328 -0
- package/dist/temporary-internal-core/index.d.ts +4 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.js +5 -1
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +582 -0
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/apps/index.js +95 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +511 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/implementations/index.js +79 -0
- package/dist/temporary-internal-core/types/handler.d.ts +51 -0
- package/dist/temporary-internal-core/types/handler.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/handler.js +8 -0
- package/dist/temporary-internal-core/types/index.d.ts +5 -0
- package/dist/temporary-internal-core/types/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/index.js +4 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts +54 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/app-locators.js +83 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts +18 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/transformations.js +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
* Checks if a string is a valid slug (kebab-case)
|
|
24
|
+
*/
|
|
25
|
+
export declare function isSlug(slug: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a string is a valid snake_case slug
|
|
28
|
+
*/
|
|
29
|
+
export declare function isSnakeCasedSlug(slug: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Converts snake_case to kebab-case
|
|
32
|
+
*/
|
|
33
|
+
export declare function dashifySnakeCasedSlug(slug: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a string is a UUID
|
|
36
|
+
*/
|
|
37
|
+
export declare function isUuid(appKey: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Splits a versioned key into base key and version
|
|
40
|
+
*/
|
|
41
|
+
export declare function splitVersionedKey(versionedKey: string): [string, string | undefined];
|
|
42
|
+
/**
|
|
43
|
+
* Converts an app key to an app locator structure
|
|
44
|
+
*/
|
|
45
|
+
export declare function toAppLocator(appKey: string): AppLocator;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a resolved app locator to a full implementation ID
|
|
48
|
+
*/
|
|
49
|
+
export declare function toImplementationId(appLocator: ResolvedAppLocator): string;
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if an app locator has been resolved
|
|
52
|
+
*/
|
|
53
|
+
export declare function isResolvedAppLocator(appLocator: AppLocator): appLocator is ResolvedAppLocator;
|
|
54
|
+
//# sourceMappingURL=app-locators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-locators.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/app-locators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;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,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;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GACnB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQ9B;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"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
* Checks if a string is a valid slug (kebab-case)
|
|
9
|
+
*/
|
|
10
|
+
export function isSlug(slug) {
|
|
11
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a string is a valid snake_case slug
|
|
15
|
+
*/
|
|
16
|
+
export function isSnakeCasedSlug(slug) {
|
|
17
|
+
if (slug.match(/^_[0-9]/)) {
|
|
18
|
+
slug = slug.slice(1);
|
|
19
|
+
}
|
|
20
|
+
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Converts snake_case to kebab-case
|
|
24
|
+
*/
|
|
25
|
+
export function dashifySnakeCasedSlug(slug) {
|
|
26
|
+
if (!isSnakeCasedSlug(slug)) {
|
|
27
|
+
return slug;
|
|
28
|
+
}
|
|
29
|
+
if (slug.startsWith("_")) {
|
|
30
|
+
slug = slug.slice(1);
|
|
31
|
+
}
|
|
32
|
+
return slug.replace(/_/g, "-");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a string is a UUID
|
|
36
|
+
*/
|
|
37
|
+
export function isUuid(appKey) {
|
|
38
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(appKey);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Splits a versioned key into base key and version
|
|
42
|
+
*/
|
|
43
|
+
export function splitVersionedKey(versionedKey) {
|
|
44
|
+
const parts = versionedKey.split("@");
|
|
45
|
+
if (parts.length >= 2) {
|
|
46
|
+
const baseKey = parts[0];
|
|
47
|
+
const version = parts.slice(1).join("@");
|
|
48
|
+
return [baseKey, version];
|
|
49
|
+
}
|
|
50
|
+
return [versionedKey, undefined];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts an app key to an app locator structure
|
|
54
|
+
*/
|
|
55
|
+
export function toAppLocator(appKey) {
|
|
56
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
57
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
58
|
+
throw new Error(`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`);
|
|
59
|
+
}
|
|
60
|
+
const slug = isSlug(appKeyWithoutVersion)
|
|
61
|
+
? appKeyWithoutVersion
|
|
62
|
+
: isSnakeCasedSlug(appKeyWithoutVersion)
|
|
63
|
+
? dashifySnakeCasedSlug(appKeyWithoutVersion)
|
|
64
|
+
: undefined;
|
|
65
|
+
return {
|
|
66
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
67
|
+
slug,
|
|
68
|
+
implementationName: slug ? undefined : appKeyWithoutVersion,
|
|
69
|
+
version,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Converts a resolved app locator to a full implementation ID
|
|
74
|
+
*/
|
|
75
|
+
export function toImplementationId(appLocator) {
|
|
76
|
+
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard to check if an app locator has been resolved
|
|
80
|
+
*/
|
|
81
|
+
export function isResolvedAppLocator(appLocator) {
|
|
82
|
+
return !!appLocator.implementationName;
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Transforms ImplementationMeta from internal API to AppItem for SDK responses
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformImplementationMetaToAppItem(implementationMeta: ImplementationMeta): AppItem;
|
|
12
|
+
/**
|
|
13
|
+
* Extracts pagination cursor from API response
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractPaginationCursor(response: {
|
|
16
|
+
next?: string | null;
|
|
17
|
+
}): string | undefined;
|
|
18
|
+
//# sourceMappingURL=transformations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAG/C;;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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 "./app-locators";
|
|
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
|
+
}
|