@zapier/zapier-sdk 0.1.0 → 0.1.1
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/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{listAuths → listAuthentications}/index.d.ts +2 -2
- package/dist/functions/{listAuths → listAuthentications}/index.js +23 -7
- package/dist/functions/{listAuths → listAuthentications}/info.d.ts +9 -3
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/{listAuths → listAuthentications}/schemas.d.ts +10 -4
- package/dist/functions/{listAuths → listAuthentications}/schemas.js +10 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +10 -3
- package/dist/resolvers/authenticationId.js +1 -1
- package/dist/schema-utils.d.ts +5 -0
- package/dist/schema-utils.js +24 -0
- package/dist/schemas/Auth.d.ts +0 -3
- package/dist/schemas/Auth.js +1 -8
- package/dist/sdk.js +18 -10
- package/dist/types/properties.js +2 -4
- package/dist/types/sdk.d.ts +4 -2
- package/package.json +1 -1
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{listAuths → listAuthentications}/index.ts +26 -9
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/{listAuths → listAuthentications}/schemas.ts +16 -4
- package/src/index.ts +6 -1
- package/src/resolvers/authenticationId.ts +1 -1
- package/src/schema-utils.ts +35 -0
- package/src/schemas/Auth.ts +1 -9
- package/src/sdk.ts +18 -6
- package/src/types/properties.ts +4 -4
- package/src/types/sdk.ts +6 -2
- package/dist/functions/listAuths/info.js +0 -11
- package/src/functions/listAuths/info.ts +0 -9
package/dist/schemas/Auth.js
CHANGED
|
@@ -9,7 +9,6 @@ const schema_utils_1 = require("../schema-utils");
|
|
|
9
9
|
exports.AuthItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
|
|
10
10
|
id: zod_1.z.number(),
|
|
11
11
|
title: zod_1.z.string().optional(),
|
|
12
|
-
label: zod_1.z.string().optional(),
|
|
13
12
|
identifier: zod_1.z.string().optional(),
|
|
14
13
|
account_id: zod_1.z.string().optional(),
|
|
15
14
|
is_private: zod_1.z.boolean().optional(),
|
|
@@ -24,12 +23,6 @@ exports.AuthItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
|
|
|
24
23
|
style: "accent",
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
if (item.label && item.title && item.label !== item.title) {
|
|
28
|
-
details.push({
|
|
29
|
-
text: `Label: ${item.label}`,
|
|
30
|
-
style: "normal",
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
26
|
details.push({
|
|
34
27
|
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
35
28
|
style: "dim",
|
|
@@ -41,7 +34,7 @@ exports.AuthItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
|
|
|
41
34
|
});
|
|
42
35
|
}
|
|
43
36
|
return {
|
|
44
|
-
title: item.title ||
|
|
37
|
+
title: item.title || `Authentication ${item.id}`,
|
|
45
38
|
subtitle: `(ID: ${item.id})`,
|
|
46
39
|
details,
|
|
47
40
|
};
|
package/dist/sdk.js
CHANGED
|
@@ -8,7 +8,9 @@ const getApp_1 = require("./functions/getApp");
|
|
|
8
8
|
const listActions_1 = require("./functions/listActions");
|
|
9
9
|
const getAction_1 = require("./functions/getAction");
|
|
10
10
|
const runAction_1 = require("./functions/runAction");
|
|
11
|
-
const
|
|
11
|
+
const listAuthentications_1 = require("./functions/listAuthentications");
|
|
12
|
+
const findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
|
|
13
|
+
const findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
|
|
12
14
|
const listFields_1 = require("./functions/listFields");
|
|
13
15
|
const generateTypes_1 = require("./functions/generateTypes");
|
|
14
16
|
const bundleCode_1 = require("./functions/bundleCode");
|
|
@@ -18,10 +20,12 @@ const info_2 = require("./functions/getApp/info");
|
|
|
18
20
|
const info_3 = require("./functions/listActions/info");
|
|
19
21
|
const info_4 = require("./functions/getAction/info");
|
|
20
22
|
const info_5 = require("./functions/runAction/info");
|
|
21
|
-
const info_6 = require("./functions/
|
|
22
|
-
const info_7 = require("./functions/
|
|
23
|
-
const info_8 = require("./functions/
|
|
24
|
-
const info_9 = require("./functions/
|
|
23
|
+
const info_6 = require("./functions/listAuthentications/info");
|
|
24
|
+
const info_7 = require("./functions/findFirstAuthentication/info");
|
|
25
|
+
const info_8 = require("./functions/findUniqueAuthentication/info");
|
|
26
|
+
const info_9 = require("./functions/listFields/info");
|
|
27
|
+
const info_10 = require("./functions/generateTypes/info");
|
|
28
|
+
const info_11 = require("./functions/bundleCode/info");
|
|
25
29
|
// Function registry as array - uses names from function info objects
|
|
26
30
|
const functionRegistry = [
|
|
27
31
|
info_1.listAppsInfo,
|
|
@@ -29,10 +33,12 @@ const functionRegistry = [
|
|
|
29
33
|
info_3.listActionsInfo,
|
|
30
34
|
info_4.getActionInfo,
|
|
31
35
|
info_5.runActionInfo,
|
|
32
|
-
info_6.
|
|
33
|
-
info_7.
|
|
34
|
-
info_8.
|
|
35
|
-
info_9.
|
|
36
|
+
info_6.listAuthenticationsInfo,
|
|
37
|
+
info_7.findFirstAuthenticationInfo,
|
|
38
|
+
info_8.findUniqueAuthenticationInfo,
|
|
39
|
+
info_9.listFieldsInfo,
|
|
40
|
+
info_10.generateTypesInfo,
|
|
41
|
+
info_11.bundleCodeInfo,
|
|
36
42
|
];
|
|
37
43
|
// Import plugin functions
|
|
38
44
|
const index_1 = require("./plugins/apps/index");
|
|
@@ -68,7 +74,9 @@ function createBaseZapierSdk(options = {}) {
|
|
|
68
74
|
listActions: (options = {}) => (0, listActions_1.listActions)({ ...options, api, token: finalToken }),
|
|
69
75
|
getAction: (options) => (0, getAction_1.getAction)({ ...options, api, token: finalToken }),
|
|
70
76
|
runAction: (options) => (0, runAction_1.runAction)({ ...options, api, token: finalToken }),
|
|
71
|
-
|
|
77
|
+
listAuthentications: (options = {}) => (0, listAuthentications_1.listAuthentications)({ ...options, api, token: finalToken }),
|
|
78
|
+
findFirstAuthentication: (options = {}) => (0, findFirstAuthentication_1.findFirstAuthentication)({ ...options, api, token: finalToken }),
|
|
79
|
+
findUniqueAuthentication: (options = {}) => (0, findUniqueAuthentication_1.findUniqueAuthentication)({ ...options, api, token: finalToken }),
|
|
72
80
|
listFields: (options) => (0, listFields_1.listFields)({ ...options, api, token: finalToken }),
|
|
73
81
|
generateTypes: (options) => (0, generateTypes_1.generateTypes)({ ...options, api, token: finalToken }),
|
|
74
82
|
bundleCode: (options) => (0, bundleCode_1.bundleCode)(options), // No API config needed
|
package/dist/types/properties.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParamsPropertySchema = exports.DebugPropertySchema = exports.OutputPropertySchema = exports.OffsetPropertySchema = exports.LimitPropertySchema = exports.InputsPropertySchema = exports.AuthenticationIdPropertySchema = exports.ActionKeyPropertySchema = exports.ActionTypePropertySchema = exports.AppKeyPropertySchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const schema_utils_1 = require("../schema-utils");
|
|
5
6
|
// Shared property definitions for common parameters across functions
|
|
6
7
|
// These can be reused in function schemas without duplication
|
|
7
|
-
exports.AppKeyPropertySchema = zod_1.z
|
|
8
|
-
.string()
|
|
9
|
-
.min(1)
|
|
10
|
-
.describe("App slug (e.g., 'slack', 'github')");
|
|
8
|
+
exports.AppKeyPropertySchema = (0, schema_utils_1.withPositional)(zod_1.z.string().min(1).describe("App slug (e.g., 'slack', 'github')"));
|
|
11
9
|
exports.ActionTypePropertySchema = zod_1.z
|
|
12
10
|
.enum(["read", "write", "search", "create", "update", "delete"])
|
|
13
11
|
.describe("Action type that matches the action's defined type");
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ import type { GetActionSdkFunction } from "../functions/getAction/schemas";
|
|
|
3
3
|
import type { GetAppSdkFunction } from "../functions/getApp/schemas";
|
|
4
4
|
import type { RunActionSdkFunction } from "../functions/runAction/schemas";
|
|
5
5
|
import type { ListFieldsSdkFunction } from "../functions/listFields/schemas";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ListAuthenticationsSdkFunction } from "../functions/listAuthentications/schemas";
|
|
7
|
+
import type { FindFirstAuthenticationSdkFunction } from "../functions/findFirstAuthentication/schemas";
|
|
8
|
+
import type { FindUniqueAuthenticationSdkFunction } from "../functions/findUniqueAuthentication/schemas";
|
|
7
9
|
import type { GenerateTypesSdkFunction } from "../functions/generateTypes/schemas";
|
|
8
10
|
import type { ListAppsSdkFunction } from "../functions/listApps/schemas";
|
|
9
11
|
import type { BundleCodeSdkFunction } from "../functions/bundleCode/schemas";
|
|
10
12
|
import type { AppsPluginSdkExtension } from "../plugins/apps/types";
|
|
11
|
-
export interface ZapierSdkFunctions extends ListActionsSdkFunction, GetActionSdkFunction, GetAppSdkFunction, RunActionSdkFunction, ListFieldsSdkFunction,
|
|
13
|
+
export interface ZapierSdkFunctions extends ListActionsSdkFunction, GetActionSdkFunction, GetAppSdkFunction, RunActionSdkFunction, ListFieldsSdkFunction, ListAuthenticationsSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, GenerateTypesSdkFunction, ListAppsSdkFunction, BundleCodeSdkFunction {
|
|
12
14
|
}
|
|
13
15
|
export interface ZapierSdkPlugins extends AppsPluginSdkExtension {
|
|
14
16
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Authentication } from "../../types/domain";
|
|
2
|
+
import { listAuthentications } from "../listAuthentications";
|
|
3
|
+
import type { FindFirstAuthenticationOptions } from "./schemas";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Find the first authentication matching the given criteria
|
|
7
|
+
*
|
|
8
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
9
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Filtering and API configuration options
|
|
12
|
+
* @returns Promise<Authentication | null> - First matching authentication or null if not found
|
|
13
|
+
*/
|
|
14
|
+
export async function findFirstAuthentication(
|
|
15
|
+
options: Partial<FindFirstAuthenticationOptions> = {},
|
|
16
|
+
): Promise<Authentication | null> {
|
|
17
|
+
// Use listAuthentications with limit 1 to get the first result
|
|
18
|
+
const auths = await listAuthentications({
|
|
19
|
+
...options,
|
|
20
|
+
limit: 1,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return auths.length > 0 ? auths[0] : null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { findFirstAuthentication } from "./index";
|
|
2
|
+
import { FindFirstAuthenticationSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const findFirstAuthenticationInfo = {
|
|
6
|
+
name: findFirstAuthentication.name,
|
|
7
|
+
inputSchema: FindFirstAuthenticationSchema,
|
|
8
|
+
implementation: findFirstAuthentication,
|
|
9
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
LimitPropertySchema,
|
|
5
|
+
OffsetPropertySchema,
|
|
6
|
+
} from "../../types/properties";
|
|
7
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
8
|
+
import { AuthItemSchema } from "../../schemas/Auth";
|
|
9
|
+
import type { Authentication } from "../../types/domain";
|
|
10
|
+
|
|
11
|
+
// Pure Zod schema - no resolver metadata!
|
|
12
|
+
export const FindFirstAuthenticationSchema = withOutputSchema(
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
|
+
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
|
+
),
|
|
18
|
+
search: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Search term to filter authentications by title"),
|
|
22
|
+
title: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Filter authentications by exact title match"),
|
|
26
|
+
account_id: z.string().optional().describe("Filter by account ID"),
|
|
27
|
+
owner: z.string().optional().describe("Filter by owner"),
|
|
28
|
+
limit: LimitPropertySchema.optional().describe(
|
|
29
|
+
"Maximum number of items to return (1-200)",
|
|
30
|
+
),
|
|
31
|
+
offset: OffsetPropertySchema.optional().describe(
|
|
32
|
+
"Number of items to skip for pagination",
|
|
33
|
+
),
|
|
34
|
+
})
|
|
35
|
+
.describe("Find the first authentication matching the criteria"),
|
|
36
|
+
AuthItemSchema,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Type inferred from schema + function config
|
|
40
|
+
export type FindFirstAuthenticationOptions = z.infer<
|
|
41
|
+
typeof FindFirstAuthenticationSchema
|
|
42
|
+
> & {
|
|
43
|
+
/** Base URL for Zapier API */
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
/** Authentication token */
|
|
46
|
+
token?: string;
|
|
47
|
+
/** Optional pre-instantiated API client */
|
|
48
|
+
api?: any;
|
|
49
|
+
/** Enable debug logging */
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
/** Custom fetch implementation */
|
|
52
|
+
fetch?: typeof globalThis.fetch;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
56
|
+
export interface FindFirstAuthenticationSdkFunction {
|
|
57
|
+
findFirstAuthentication: (
|
|
58
|
+
options?: Partial<FindFirstAuthenticationOptions>,
|
|
59
|
+
) => Promise<Authentication | null>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Authentication } from "../../types/domain";
|
|
2
|
+
import { listAuthentications } from "../listAuthentications";
|
|
3
|
+
import type { FindUniqueAuthenticationOptions } from "./schemas";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Find a unique authentication matching the given criteria
|
|
7
|
+
*
|
|
8
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
9
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Filtering and API configuration options
|
|
12
|
+
* @returns Promise<Authentication> - The unique matching authentication
|
|
13
|
+
* @throws Error if no authentication found or multiple authentications found
|
|
14
|
+
*/
|
|
15
|
+
export async function findUniqueAuthentication(
|
|
16
|
+
options: Partial<FindUniqueAuthenticationOptions> = {},
|
|
17
|
+
): Promise<Authentication> {
|
|
18
|
+
// Use listAuthentications with a reasonable limit to check for uniqueness
|
|
19
|
+
const auths = await listAuthentications({
|
|
20
|
+
...options,
|
|
21
|
+
limit: 2, // Get up to 2 to check for uniqueness
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (auths.length === 0) {
|
|
25
|
+
throw new Error("No authentication found matching the specified criteria");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (auths.length > 1) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Multiple authentications found matching the specified criteria. Expected exactly one.",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return auths[0];
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { findUniqueAuthentication } from "./index";
|
|
2
|
+
import { FindUniqueAuthenticationSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const findUniqueAuthenticationInfo = {
|
|
6
|
+
name: findUniqueAuthentication.name,
|
|
7
|
+
inputSchema: FindUniqueAuthenticationSchema,
|
|
8
|
+
implementation: findUniqueAuthentication,
|
|
9
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
LimitPropertySchema,
|
|
5
|
+
OffsetPropertySchema,
|
|
6
|
+
} from "../../types/properties";
|
|
7
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
8
|
+
import { AuthItemSchema } from "../../schemas/Auth";
|
|
9
|
+
import type { Authentication } from "../../types/domain";
|
|
10
|
+
|
|
11
|
+
// Pure Zod schema - no resolver metadata!
|
|
12
|
+
export const FindUniqueAuthenticationSchema = withOutputSchema(
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
|
+
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
|
+
),
|
|
18
|
+
search: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Search term to filter authentications by title"),
|
|
22
|
+
title: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Filter authentications by exact title match"),
|
|
26
|
+
account_id: z.string().optional().describe("Filter by account ID"),
|
|
27
|
+
owner: z.string().optional().describe("Filter by owner"),
|
|
28
|
+
limit: LimitPropertySchema.optional().describe(
|
|
29
|
+
"Maximum number of items to return (1-200)",
|
|
30
|
+
),
|
|
31
|
+
offset: OffsetPropertySchema.optional().describe(
|
|
32
|
+
"Number of items to skip for pagination",
|
|
33
|
+
),
|
|
34
|
+
})
|
|
35
|
+
.describe("Find a unique authentication matching the criteria"),
|
|
36
|
+
AuthItemSchema,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Type inferred from schema + function config
|
|
40
|
+
export type FindUniqueAuthenticationOptions = z.infer<
|
|
41
|
+
typeof FindUniqueAuthenticationSchema
|
|
42
|
+
> & {
|
|
43
|
+
/** Base URL for Zapier API */
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
/** Authentication token */
|
|
46
|
+
token?: string;
|
|
47
|
+
/** Optional pre-instantiated API client */
|
|
48
|
+
api?: any;
|
|
49
|
+
/** Enable debug logging */
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
/** Custom fetch implementation */
|
|
52
|
+
fetch?: typeof globalThis.fetch;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
56
|
+
export interface FindUniqueAuthenticationSdkFunction {
|
|
57
|
+
findUniqueAuthentication: (
|
|
58
|
+
options?: Partial<FindUniqueAuthenticationOptions>,
|
|
59
|
+
) => Promise<Authentication>;
|
|
60
|
+
}
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
AuthenticationsResponse,
|
|
5
5
|
} from "../../types/domain";
|
|
6
6
|
import { getApp } from "../getApp";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ListAuthenticationsOptions } from "./schemas";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* List available authentications with optional filtering
|
|
@@ -15,8 +15,8 @@ import type { ListAuthsOptions } from "./schemas";
|
|
|
15
15
|
* @param options - Filtering, pagination, and API configuration options
|
|
16
16
|
* @returns Promise<Authentication[]> with pagination metadata
|
|
17
17
|
*/
|
|
18
|
-
export async function
|
|
19
|
-
options: Partial<
|
|
18
|
+
export async function listAuthentications(
|
|
19
|
+
options: Partial<ListAuthenticationsOptions> = {},
|
|
20
20
|
): Promise<Authentication[]> {
|
|
21
21
|
const { token } = options;
|
|
22
22
|
|
|
@@ -29,8 +29,8 @@ export async function listAuths(
|
|
|
29
29
|
const api = getOrCreateApiClient(options);
|
|
30
30
|
|
|
31
31
|
// Local function to handle the actual API fetching
|
|
32
|
-
const
|
|
33
|
-
options:
|
|
32
|
+
const listAuthenticationsInternal = async (
|
|
33
|
+
options: ListAuthenticationsOptions = {},
|
|
34
34
|
): Promise<Authentication[]> => {
|
|
35
35
|
// Build search parameters
|
|
36
36
|
const searchParams: Record<string, string> = {};
|
|
@@ -68,6 +68,12 @@ export async function listAuths(
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// Add other query parameters if provided
|
|
71
|
+
// Use title as search if no explicit search provided
|
|
72
|
+
if (options.search) {
|
|
73
|
+
searchParams.search = options.search;
|
|
74
|
+
} else if (options.title) {
|
|
75
|
+
searchParams.search = options.title;
|
|
76
|
+
}
|
|
71
77
|
if (options.account_id) {
|
|
72
78
|
searchParams.account_id = options.account_id;
|
|
73
79
|
}
|
|
@@ -102,7 +108,18 @@ export async function listAuths(
|
|
|
102
108
|
);
|
|
103
109
|
|
|
104
110
|
// Transform API response
|
|
105
|
-
|
|
111
|
+
let auths = data.results || [];
|
|
112
|
+
|
|
113
|
+
// Coerce title from label if title is missing (API cleanup)
|
|
114
|
+
auths = auths.map((auth) => ({
|
|
115
|
+
...auth,
|
|
116
|
+
title: auth.title || (auth as any).label || undefined,
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
// Filter by exact title match if specified
|
|
120
|
+
if (options.title) {
|
|
121
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
122
|
+
}
|
|
106
123
|
|
|
107
124
|
// Add pagination metadata to the response
|
|
108
125
|
if (auths.length > 0) {
|
|
@@ -121,7 +138,7 @@ export async function listAuths(
|
|
|
121
138
|
// If a limit is provided and no specific owner filter, prioritize owned auths
|
|
122
139
|
if (options.limit && options.owner === undefined) {
|
|
123
140
|
// First get owned auths
|
|
124
|
-
const ownedAuths = await
|
|
141
|
+
const ownedAuths = await listAuthenticationsInternal({
|
|
125
142
|
...options,
|
|
126
143
|
owner: "me",
|
|
127
144
|
});
|
|
@@ -132,7 +149,7 @@ export async function listAuths(
|
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
// Get all auths up to the original limit to fill remaining slots
|
|
135
|
-
const allAuths = await
|
|
152
|
+
const allAuths = await listAuthenticationsInternal({
|
|
136
153
|
...options,
|
|
137
154
|
owner: undefined,
|
|
138
155
|
});
|
|
@@ -149,5 +166,5 @@ export async function listAuths(
|
|
|
149
166
|
}
|
|
150
167
|
|
|
151
168
|
// Standard implementation for non-prioritized requests
|
|
152
|
-
return
|
|
169
|
+
return listAuthenticationsInternal(options);
|
|
153
170
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { listAuthentications } from "./index";
|
|
2
|
+
import { ListAuthenticationsSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const listAuthenticationsInfo = {
|
|
6
|
+
name: listAuthentications.name,
|
|
7
|
+
inputSchema: ListAuthenticationsSchema,
|
|
8
|
+
implementation: listAuthentications,
|
|
9
|
+
};
|
|
@@ -9,12 +9,20 @@ import { AuthItemSchema } from "../../schemas/Auth";
|
|
|
9
9
|
import type { Authentication } from "../../types/domain";
|
|
10
10
|
|
|
11
11
|
// Pure Zod schema - no resolver metadata!
|
|
12
|
-
export const
|
|
12
|
+
export const ListAuthenticationsSchema = withOutputSchema(
|
|
13
13
|
z
|
|
14
14
|
.object({
|
|
15
15
|
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
16
|
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
17
|
),
|
|
18
|
+
search: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Search term to filter authentications by title"),
|
|
22
|
+
title: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Filter authentications by exact title match"),
|
|
18
26
|
account_id: z.string().optional().describe("Filter by account ID"),
|
|
19
27
|
owner: z.string().optional().describe("Filter by owner"),
|
|
20
28
|
limit: LimitPropertySchema.optional().describe(
|
|
@@ -29,7 +37,9 @@ export const ListAuthsSchema = withOutputSchema(
|
|
|
29
37
|
);
|
|
30
38
|
|
|
31
39
|
// Type inferred from schema + function config
|
|
32
|
-
export type
|
|
40
|
+
export type ListAuthenticationsOptions = z.infer<
|
|
41
|
+
typeof ListAuthenticationsSchema
|
|
42
|
+
> & {
|
|
33
43
|
/** Base URL for Zapier API */
|
|
34
44
|
baseUrl?: string;
|
|
35
45
|
/** Authentication token */
|
|
@@ -43,6 +53,8 @@ export type ListAuthsOptions = z.infer<typeof ListAuthsSchema> & {
|
|
|
43
53
|
};
|
|
44
54
|
|
|
45
55
|
// SDK function interface - ready to be mixed into main SDK interface
|
|
46
|
-
export interface
|
|
47
|
-
|
|
56
|
+
export interface ListAuthenticationsSdkFunction {
|
|
57
|
+
listAuthentications: (
|
|
58
|
+
options?: Partial<ListAuthenticationsOptions>,
|
|
59
|
+
) => Promise<Authentication[]>;
|
|
48
60
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,13 +3,18 @@ export * from "./types/domain";
|
|
|
3
3
|
export * from "./types/properties";
|
|
4
4
|
export * from "./plugins/apps";
|
|
5
5
|
|
|
6
|
+
// Export schema utilities for CLI
|
|
7
|
+
export { isPositional } from "./schema-utils";
|
|
8
|
+
|
|
6
9
|
// Export resolvers for CLI use
|
|
7
10
|
export * from "./resolvers";
|
|
8
11
|
|
|
9
12
|
// Note: SdkSchemas is now available via SDK.__registry
|
|
10
13
|
|
|
11
14
|
// Export individual functions for tree-shaking
|
|
12
|
-
export {
|
|
15
|
+
export { listAuthentications } from "./functions/listAuthentications";
|
|
16
|
+
export { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
17
|
+
export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
13
18
|
export { listApps } from "./functions/listApps";
|
|
14
19
|
export { getApp } from "./functions/getApp";
|
|
15
20
|
export { listActions } from "./functions/listActions";
|
|
@@ -15,7 +15,7 @@ export const authenticationIdResolver: AuthenticationIdResolver = {
|
|
|
15
15
|
depends: ["appKey"] as const,
|
|
16
16
|
fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
|
|
17
17
|
// Get auths for the specific app (owned auths will be prioritized automatically)
|
|
18
|
-
return await sdk.
|
|
18
|
+
return await sdk.listAuthentications({
|
|
19
19
|
appKey: resolvedParams.appKey,
|
|
20
20
|
limit: 1000,
|
|
21
21
|
});
|
package/src/schema-utils.ts
CHANGED
|
@@ -117,3 +117,38 @@ export function getFieldDescriptions(
|
|
|
117
117
|
|
|
118
118
|
return descriptions;
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Positional Parameter Metadata
|
|
123
|
+
// ============================================================================
|
|
124
|
+
|
|
125
|
+
export interface PositionalMetadata {
|
|
126
|
+
positional: true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Helper function to mark a parameter as positional for CLI
|
|
130
|
+
export function withPositional<T extends z.ZodType>(schema: T): T {
|
|
131
|
+
// Store positional metadata on the schema definition
|
|
132
|
+
(schema._def as any).positionalMeta = { positional: true };
|
|
133
|
+
return schema;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Helper function to check if a parameter should be positional
|
|
137
|
+
export function isPositional(schema: z.ZodType): boolean {
|
|
138
|
+
// Check the current schema first
|
|
139
|
+
if ((schema._def as any).positionalMeta?.positional) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// If this is a ZodOptional, check the inner type
|
|
144
|
+
if (schema instanceof z.ZodOptional) {
|
|
145
|
+
return isPositional(schema._def.innerType);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// If this is a ZodDefault, check the inner type
|
|
149
|
+
if (schema instanceof z.ZodDefault) {
|
|
150
|
+
return isPositional(schema._def.innerType);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return false;
|
|
154
|
+
}
|
package/src/schemas/Auth.ts
CHANGED
|
@@ -9,7 +9,6 @@ export const AuthItemSchema = withFormatter(
|
|
|
9
9
|
z.object({
|
|
10
10
|
id: z.number(),
|
|
11
11
|
title: z.string().optional(),
|
|
12
|
-
label: z.string().optional(),
|
|
13
12
|
identifier: z.string().optional(),
|
|
14
13
|
account_id: z.string().optional(),
|
|
15
14
|
is_private: z.boolean().optional(),
|
|
@@ -27,13 +26,6 @@ export const AuthItemSchema = withFormatter(
|
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
if (item.label && item.title && item.label !== item.title) {
|
|
31
|
-
details.push({
|
|
32
|
-
text: `Label: ${item.label}`,
|
|
33
|
-
style: "normal" as const,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
29
|
details.push({
|
|
38
30
|
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
39
31
|
style: "dim" as const,
|
|
@@ -47,7 +39,7 @@ export const AuthItemSchema = withFormatter(
|
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
return {
|
|
50
|
-
title: item.title ||
|
|
42
|
+
title: item.title || `Authentication ${item.id}`,
|
|
51
43
|
subtitle: `(ID: ${item.id})`,
|
|
52
44
|
details,
|
|
53
45
|
};
|
package/src/sdk.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { getApp } from "./functions/getApp";
|
|
|
6
6
|
import { listActions } from "./functions/listActions";
|
|
7
7
|
import { getAction } from "./functions/getAction";
|
|
8
8
|
import { runAction } from "./functions/runAction";
|
|
9
|
-
import {
|
|
9
|
+
import { listAuthentications } from "./functions/listAuthentications";
|
|
10
|
+
import { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
11
|
+
import { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
10
12
|
import { listFields } from "./functions/listFields";
|
|
11
13
|
import { generateTypes } from "./functions/generateTypes";
|
|
12
14
|
import { bundleCode } from "./functions/bundleCode";
|
|
@@ -17,7 +19,9 @@ import { getAppInfo } from "./functions/getApp/info";
|
|
|
17
19
|
import { listActionsInfo } from "./functions/listActions/info";
|
|
18
20
|
import { getActionInfo } from "./functions/getAction/info";
|
|
19
21
|
import { runActionInfo } from "./functions/runAction/info";
|
|
20
|
-
import {
|
|
22
|
+
import { listAuthenticationsInfo } from "./functions/listAuthentications/info";
|
|
23
|
+
import { findFirstAuthenticationInfo } from "./functions/findFirstAuthentication/info";
|
|
24
|
+
import { findUniqueAuthenticationInfo } from "./functions/findUniqueAuthentication/info";
|
|
21
25
|
import { listFieldsInfo } from "./functions/listFields/info";
|
|
22
26
|
import { generateTypesInfo } from "./functions/generateTypes/info";
|
|
23
27
|
import { bundleCodeInfo } from "./functions/bundleCode/info";
|
|
@@ -29,7 +33,9 @@ const functionRegistry = [
|
|
|
29
33
|
listActionsInfo,
|
|
30
34
|
getActionInfo,
|
|
31
35
|
runActionInfo,
|
|
32
|
-
|
|
36
|
+
listAuthenticationsInfo,
|
|
37
|
+
findFirstAuthenticationInfo,
|
|
38
|
+
findUniqueAuthenticationInfo,
|
|
33
39
|
listFieldsInfo,
|
|
34
40
|
generateTypesInfo,
|
|
35
41
|
bundleCodeInfo,
|
|
@@ -55,7 +61,9 @@ interface BaseZapierSdkWithFunctions {
|
|
|
55
61
|
listActions: ZapierSdk["listActions"];
|
|
56
62
|
getAction: ZapierSdk["getAction"];
|
|
57
63
|
runAction: ZapierSdk["runAction"];
|
|
58
|
-
|
|
64
|
+
listAuthentications: ZapierSdk["listAuthentications"];
|
|
65
|
+
findFirstAuthentication: ZapierSdk["findFirstAuthentication"];
|
|
66
|
+
findUniqueAuthentication: ZapierSdk["findUniqueAuthentication"];
|
|
59
67
|
listFields: ZapierSdk["listFields"];
|
|
60
68
|
generateTypes: ZapierSdk["generateTypes"];
|
|
61
69
|
bundleCode: ZapierSdk["bundleCode"];
|
|
@@ -111,8 +119,12 @@ function createBaseZapierSdk(
|
|
|
111
119
|
listActions({ ...options, api, token: finalToken }),
|
|
112
120
|
getAction: (options) => getAction({ ...options, api, token: finalToken }),
|
|
113
121
|
runAction: (options) => runAction({ ...options, api, token: finalToken }),
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
listAuthentications: (options = {}) =>
|
|
123
|
+
listAuthentications({ ...options, api, token: finalToken }),
|
|
124
|
+
findFirstAuthentication: (options = {}) =>
|
|
125
|
+
findFirstAuthentication({ ...options, api, token: finalToken }),
|
|
126
|
+
findUniqueAuthentication: (options = {}) =>
|
|
127
|
+
findUniqueAuthentication({ ...options, api, token: finalToken }),
|
|
116
128
|
listFields: (options) => listFields({ ...options, api, token: finalToken }),
|
|
117
129
|
generateTypes: (options) =>
|
|
118
130
|
generateTypes({ ...options, api, token: finalToken }),
|
package/src/types/properties.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { withPositional } from "../schema-utils";
|
|
2
3
|
|
|
3
4
|
// Shared property definitions for common parameters across functions
|
|
4
5
|
// These can be reused in function schemas without duplication
|
|
5
6
|
|
|
6
|
-
export const AppKeyPropertySchema =
|
|
7
|
-
.string()
|
|
8
|
-
|
|
9
|
-
.describe("App slug (e.g., 'slack', 'github')");
|
|
7
|
+
export const AppKeyPropertySchema = withPositional(
|
|
8
|
+
z.string().min(1).describe("App slug (e.g., 'slack', 'github')"),
|
|
9
|
+
);
|
|
10
10
|
|
|
11
11
|
export const ActionTypePropertySchema = z
|
|
12
12
|
.enum(["read", "write", "search", "create", "update", "delete"])
|