@zapier/zapier-sdk 0.13.5 → 0.13.7
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 +15 -0
- package/dist/api/schemas.d.ts +38 -38
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +170 -177
- package/dist/index.mjs +1 -1
- package/dist/plugins/fetch/schemas.d.ts +4 -4
- package/dist/plugins/getAction/schemas.d.ts +2 -2
- package/dist/plugins/listActions/schemas.d.ts +6 -6
- package/dist/plugins/listApps/schemas.d.ts +6 -6
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listInputFields/schemas.d.ts +8 -8
- package/dist/plugins/request/schemas.d.ts +8 -8
- package/dist/plugins/runAction/schemas.d.ts +8 -8
- package/dist/schemas/Action.d.ts +2 -2
- package/dist/schemas/App.d.ts +8 -8
- package/dist/types/sdk.d.ts +2 -8
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/api/auth.ts +0 -28
- package/src/api/client.ts +0 -491
- package/src/api/debug.test.ts +0 -76
- package/src/api/debug.ts +0 -154
- package/src/api/index.ts +0 -90
- package/src/api/polling.test.ts +0 -405
- package/src/api/polling.ts +0 -253
- package/src/api/schemas.ts +0 -465
- package/src/api/types.ts +0 -152
- package/src/auth.ts +0 -72
- package/src/constants.ts +0 -16
- package/src/index.ts +0 -111
- package/src/plugins/api/index.ts +0 -43
- package/src/plugins/apps/index.ts +0 -203
- package/src/plugins/apps/schemas.ts +0 -64
- package/src/plugins/eventEmission/builders.ts +0 -115
- package/src/plugins/eventEmission/index.test.ts +0 -169
- package/src/plugins/eventEmission/index.ts +0 -294
- package/src/plugins/eventEmission/transport.test.ts +0 -214
- package/src/plugins/eventEmission/transport.ts +0 -135
- package/src/plugins/eventEmission/types.ts +0 -58
- package/src/plugins/eventEmission/utils.ts +0 -121
- package/src/plugins/fetch/index.ts +0 -83
- package/src/plugins/fetch/schemas.ts +0 -37
- package/src/plugins/findFirstAuthentication/index.test.ts +0 -209
- package/src/plugins/findFirstAuthentication/index.ts +0 -68
- package/src/plugins/findFirstAuthentication/schemas.ts +0 -47
- package/src/plugins/findUniqueAuthentication/index.test.ts +0 -197
- package/src/plugins/findUniqueAuthentication/index.ts +0 -77
- package/src/plugins/findUniqueAuthentication/schemas.ts +0 -49
- package/src/plugins/getAction/index.test.ts +0 -239
- package/src/plugins/getAction/index.ts +0 -75
- package/src/plugins/getAction/schemas.ts +0 -41
- package/src/plugins/getApp/index.test.ts +0 -181
- package/src/plugins/getApp/index.ts +0 -60
- package/src/plugins/getApp/schemas.ts +0 -33
- package/src/plugins/getAuthentication/index.test.ts +0 -294
- package/src/plugins/getAuthentication/index.ts +0 -95
- package/src/plugins/getAuthentication/schemas.ts +0 -38
- package/src/plugins/getProfile/index.ts +0 -60
- package/src/plugins/getProfile/schemas.ts +0 -24
- package/src/plugins/listActions/index.test.ts +0 -526
- package/src/plugins/listActions/index.ts +0 -132
- package/src/plugins/listActions/schemas.ts +0 -55
- package/src/plugins/listApps/index.test.ts +0 -378
- package/src/plugins/listApps/index.ts +0 -159
- package/src/plugins/listApps/schemas.ts +0 -41
- package/src/plugins/listAuthentications/index.test.ts +0 -739
- package/src/plugins/listAuthentications/index.ts +0 -152
- package/src/plugins/listAuthentications/schemas.ts +0 -77
- package/src/plugins/listInputFieldChoices/index.test.ts +0 -653
- package/src/plugins/listInputFieldChoices/index.ts +0 -173
- package/src/plugins/listInputFieldChoices/schemas.ts +0 -125
- package/src/plugins/listInputFields/index.test.ts +0 -439
- package/src/plugins/listInputFields/index.ts +0 -294
- package/src/plugins/listInputFields/schemas.ts +0 -68
- package/src/plugins/manifest/index.test.ts +0 -776
- package/src/plugins/manifest/index.ts +0 -461
- package/src/plugins/manifest/schemas.ts +0 -60
- package/src/plugins/registry/index.ts +0 -160
- package/src/plugins/request/index.test.ts +0 -333
- package/src/plugins/request/index.ts +0 -105
- package/src/plugins/request/schemas.ts +0 -69
- package/src/plugins/runAction/index.test.ts +0 -388
- package/src/plugins/runAction/index.ts +0 -215
- package/src/plugins/runAction/schemas.ts +0 -60
- package/src/resolvers/actionKey.ts +0 -37
- package/src/resolvers/actionType.ts +0 -34
- package/src/resolvers/appKey.ts +0 -7
- package/src/resolvers/authenticationId.ts +0 -54
- package/src/resolvers/index.ts +0 -11
- package/src/resolvers/inputFieldKey.ts +0 -70
- package/src/resolvers/inputs.ts +0 -69
- package/src/schemas/Action.ts +0 -52
- package/src/schemas/App.ts +0 -45
- package/src/schemas/Auth.ts +0 -59
- package/src/schemas/Field.ts +0 -169
- package/src/schemas/Run.ts +0 -40
- package/src/schemas/UserProfile.ts +0 -60
- package/src/sdk.test.ts +0 -212
- package/src/sdk.ts +0 -178
- package/src/types/domain.test.ts +0 -50
- package/src/types/domain.ts +0 -66
- package/src/types/errors.ts +0 -278
- package/src/types/events.ts +0 -43
- package/src/types/functions.ts +0 -28
- package/src/types/optional-zapier-sdk-cli-login.d.ts +0 -37
- package/src/types/plugin.ts +0 -125
- package/src/types/properties.ts +0 -80
- package/src/types/sdk.ts +0 -117
- package/src/types/telemetry-events.ts +0 -85
- package/src/utils/array-utils.test.ts +0 -131
- package/src/utils/array-utils.ts +0 -41
- package/src/utils/domain-utils.test.ts +0 -433
- package/src/utils/domain-utils.ts +0 -267
- package/src/utils/file-utils.test.ts +0 -73
- package/src/utils/file-utils.ts +0 -94
- package/src/utils/function-utils.test.ts +0 -141
- package/src/utils/function-utils.ts +0 -245
- package/src/utils/pagination-utils.test.ts +0 -620
- package/src/utils/pagination-utils.ts +0 -242
- package/src/utils/schema-utils.ts +0 -207
- package/src/utils/string-utils.test.ts +0 -45
- package/src/utils/string-utils.ts +0 -54
- package/src/utils/validation.test.ts +0 -51
- package/src/utils/validation.ts +0 -44
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -20
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -23
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
-
import type { ApiClient } from "../../api";
|
|
3
|
-
import type { AuthenticationsResponse } from "../../api/types";
|
|
4
|
-
import type { AuthenticationItem } from "../../types/domain";
|
|
5
|
-
import {
|
|
6
|
-
ListAuthenticationsSchema,
|
|
7
|
-
type ListAuthenticationsOptions,
|
|
8
|
-
type ListAuthenticationsPage,
|
|
9
|
-
} from "./schemas";
|
|
10
|
-
import {
|
|
11
|
-
normalizeAuthenticationItem,
|
|
12
|
-
splitVersionedKey,
|
|
13
|
-
} from "../../utils/domain-utils";
|
|
14
|
-
import { ZapierAuthenticationError } from "../../types/errors";
|
|
15
|
-
import {
|
|
16
|
-
createPaginatedFunction,
|
|
17
|
-
extractCursor,
|
|
18
|
-
} from "../../utils/function-utils";
|
|
19
|
-
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
20
|
-
import type { ManifestPluginProvides } from "../manifest";
|
|
21
|
-
import { appKeyResolver } from "../../resolvers";
|
|
22
|
-
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
23
|
-
|
|
24
|
-
export interface ListAuthenticationsPluginProvides {
|
|
25
|
-
listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
|
|
26
|
-
data: AuthenticationItem[];
|
|
27
|
-
nextCursor?: string;
|
|
28
|
-
}> &
|
|
29
|
-
AsyncIterable<{ data: AuthenticationItem[]; nextCursor?: string }> & {
|
|
30
|
-
items(): AsyncIterable<AuthenticationItem>;
|
|
31
|
-
};
|
|
32
|
-
context: {
|
|
33
|
-
meta: {
|
|
34
|
-
listAuthentications: {
|
|
35
|
-
inputSchema: typeof ListAuthenticationsSchema;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const listAuthenticationsPlugin: Plugin<
|
|
42
|
-
GetSdkType<ManifestPluginProvides>,
|
|
43
|
-
{
|
|
44
|
-
api: ApiClient;
|
|
45
|
-
getVersionedImplementationId: GetVersionedImplementationId;
|
|
46
|
-
},
|
|
47
|
-
ListAuthenticationsPluginProvides
|
|
48
|
-
> = ({ context }) => {
|
|
49
|
-
const listAuthentications = createPaginatedFunction(
|
|
50
|
-
async function listAuthenticationsPage(
|
|
51
|
-
options: ListAuthenticationsOptions & { cursor?: string } & {
|
|
52
|
-
pageSize: number;
|
|
53
|
-
},
|
|
54
|
-
): Promise<ListAuthenticationsPage> {
|
|
55
|
-
const { api, getVersionedImplementationId } = context;
|
|
56
|
-
// Build search parameters
|
|
57
|
-
const searchParams: Record<string, string> = {};
|
|
58
|
-
|
|
59
|
-
// Handle appKey filtering by getting the selected_api first
|
|
60
|
-
if (options.appKey) {
|
|
61
|
-
const implementationId = await getVersionedImplementationId(
|
|
62
|
-
options.appKey,
|
|
63
|
-
);
|
|
64
|
-
if (implementationId) {
|
|
65
|
-
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
66
|
-
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Add authenticationIds as ids parameter if provided
|
|
71
|
-
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
72
|
-
searchParams.ids = options.authenticationIds.join(",");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Add other query parameters if provided
|
|
76
|
-
// Use title as search if no explicit search provided
|
|
77
|
-
if (options.search) {
|
|
78
|
-
searchParams.search = options.search;
|
|
79
|
-
} else if (options.title) {
|
|
80
|
-
searchParams.search = options.title;
|
|
81
|
-
}
|
|
82
|
-
if (options.accountId) {
|
|
83
|
-
searchParams.account_id = options.accountId;
|
|
84
|
-
}
|
|
85
|
-
if (options.owner) {
|
|
86
|
-
searchParams.owner = options.owner;
|
|
87
|
-
}
|
|
88
|
-
// pageSize is now guaranteed to be set by the higher-order function
|
|
89
|
-
searchParams.limit = options.pageSize.toString();
|
|
90
|
-
if (options.cursor) {
|
|
91
|
-
// Convert cursor back to offset for the API
|
|
92
|
-
searchParams.offset = options.cursor;
|
|
93
|
-
}
|
|
94
|
-
const data: AuthenticationsResponse = await api.get(
|
|
95
|
-
"/api/v4/authentications/",
|
|
96
|
-
{
|
|
97
|
-
searchParams,
|
|
98
|
-
customErrorHandler: ({ status }) => {
|
|
99
|
-
if (status === 401) {
|
|
100
|
-
return new ZapierAuthenticationError(
|
|
101
|
-
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
102
|
-
{ statusCode: status },
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
if (status === 403) {
|
|
106
|
-
return new ZapierAuthenticationError(
|
|
107
|
-
`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
|
|
108
|
-
{ statusCode: status },
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
return undefined;
|
|
112
|
-
},
|
|
113
|
-
authRequired: true,
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
// Transform API response and filter by exact title match if specified
|
|
118
|
-
let auths = (data.results || []).map((auth) =>
|
|
119
|
-
normalizeAuthenticationItem(auth),
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
// Filter by exact title match if specified
|
|
123
|
-
if (options.title) {
|
|
124
|
-
auths = auths.filter((auth) => auth.title === options.title);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
data: auths,
|
|
129
|
-
nextCursor: extractCursor(data),
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
ListAuthenticationsSchema,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
listAuthentications,
|
|
137
|
-
context: {
|
|
138
|
-
meta: {
|
|
139
|
-
listAuthentications: {
|
|
140
|
-
categories: ["authentication"],
|
|
141
|
-
type: "list",
|
|
142
|
-
itemType: "Authentication",
|
|
143
|
-
inputSchema: ListAuthenticationsSchema,
|
|
144
|
-
outputSchema: AuthenticationItemSchema,
|
|
145
|
-
resolvers: {
|
|
146
|
-
appKey: appKeyResolver,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { AppKeyPropertySchema } from "../../types/properties";
|
|
3
|
-
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
4
|
-
import type { AuthenticationItem } from "../../types/domain";
|
|
5
|
-
import type {
|
|
6
|
-
ZapierAuthenticationError,
|
|
7
|
-
ZapierApiError,
|
|
8
|
-
ZapierAppNotFoundError,
|
|
9
|
-
ZapierValidationError,
|
|
10
|
-
ZapierUnknownError,
|
|
11
|
-
} from "../../types/errors";
|
|
12
|
-
|
|
13
|
-
// Pure Zod schema - no resolver metadata!
|
|
14
|
-
export const ListAuthenticationsSchema = z
|
|
15
|
-
.object({
|
|
16
|
-
appKey: AppKeyPropertySchema.optional().describe(
|
|
17
|
-
"App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')",
|
|
18
|
-
),
|
|
19
|
-
authenticationIds: z
|
|
20
|
-
.array(z.string())
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("List of authentication IDs to filter by"),
|
|
23
|
-
search: z
|
|
24
|
-
.string()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe("Search term to filter authentications by title"),
|
|
27
|
-
title: z
|
|
28
|
-
.string()
|
|
29
|
-
.optional()
|
|
30
|
-
.describe("Filter authentications by exact title match"),
|
|
31
|
-
accountId: z.string().optional().describe("Filter by account ID"),
|
|
32
|
-
owner: z
|
|
33
|
-
.union([z.string(), z.literal("me")])
|
|
34
|
-
.optional()
|
|
35
|
-
.describe(
|
|
36
|
-
"Filter by owner, 'me' for your own authentications or a specific user ID",
|
|
37
|
-
),
|
|
38
|
-
pageSize: z
|
|
39
|
-
.number()
|
|
40
|
-
.min(1)
|
|
41
|
-
.optional()
|
|
42
|
-
.describe("Number of authentications per page"),
|
|
43
|
-
maxItems: z
|
|
44
|
-
.number()
|
|
45
|
-
.min(1)
|
|
46
|
-
.optional()
|
|
47
|
-
.describe("Maximum total items to return across all pages"),
|
|
48
|
-
cursor: z.string().optional().describe("Cursor to start from"),
|
|
49
|
-
})
|
|
50
|
-
.describe("List available authentications with optional filtering");
|
|
51
|
-
|
|
52
|
-
// Type inferred from schema
|
|
53
|
-
export type ListAuthenticationsOptions = z.infer<
|
|
54
|
-
typeof ListAuthenticationsSchema
|
|
55
|
-
>;
|
|
56
|
-
|
|
57
|
-
// Page result structure
|
|
58
|
-
export interface ListAuthenticationsPage {
|
|
59
|
-
data: AuthenticationItem[];
|
|
60
|
-
nextCursor?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Error union for this function
|
|
64
|
-
export type ListAuthenticationsError =
|
|
65
|
-
| ZapierAuthenticationError
|
|
66
|
-
| ZapierApiError
|
|
67
|
-
| ZapierAppNotFoundError
|
|
68
|
-
| ZapierValidationError
|
|
69
|
-
| ZapierUnknownError;
|
|
70
|
-
|
|
71
|
-
// SDK function interface - ready to be mixed into main SDK interface
|
|
72
|
-
export interface ListAuthenticationsSdkFunction {
|
|
73
|
-
listAuthentications: PaginatedSdkFunction<
|
|
74
|
-
ListAuthenticationsOptions,
|
|
75
|
-
AuthenticationItem
|
|
76
|
-
>;
|
|
77
|
-
}
|