@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Authentication } from "../../types/domain";
|
|
2
|
+
import type { FindFirstAuthenticationOptions } from "./schemas";
|
|
3
|
+
/**
|
|
4
|
+
* Find the first authentication matching the given criteria
|
|
5
|
+
*
|
|
6
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
7
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Filtering and API configuration options
|
|
10
|
+
* @returns Promise<Authentication | null> - First matching authentication or null if not found
|
|
11
|
+
*/
|
|
12
|
+
export declare function findFirstAuthentication(options?: Partial<FindFirstAuthenticationOptions>): Promise<Authentication | null>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFirstAuthentication = findFirstAuthentication;
|
|
4
|
+
const listAuthentications_1 = require("../listAuthentications");
|
|
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
|
+
async function findFirstAuthentication(options = {}) {
|
|
15
|
+
// Use listAuthentications with limit 1 to get the first result
|
|
16
|
+
const auths = await (0, listAuthentications_1.listAuthentications)({
|
|
17
|
+
...options,
|
|
18
|
+
limit: 1,
|
|
19
|
+
});
|
|
20
|
+
return auths.length > 0 ? auths[0] : null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findFirstAuthentication } from "./index";
|
|
2
|
+
export declare const findFirstAuthenticationInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
account_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
owner: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
11
|
+
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
12
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
appKey?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
account_id?: string | undefined;
|
|
17
|
+
owner?: string | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
offset?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
search?: string | undefined;
|
|
22
|
+
appKey?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
account_id?: string | undefined;
|
|
25
|
+
owner?: string | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
offset?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
implementation: typeof findFirstAuthentication;
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFirstAuthenticationInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.findFirstAuthenticationInfo = {
|
|
8
|
+
name: index_1.findFirstAuthentication.name,
|
|
9
|
+
inputSchema: schemas_1.FindFirstAuthenticationSchema,
|
|
10
|
+
implementation: index_1.findFirstAuthentication,
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Authentication } from "../../types/domain";
|
|
3
|
+
export declare const FindFirstAuthenticationSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodOptional<z.ZodString>;
|
|
5
|
+
search: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
10
|
+
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
search?: string | undefined;
|
|
13
|
+
appKey?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
account_id?: string | undefined;
|
|
16
|
+
owner?: string | undefined;
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
offset?: number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
search?: string | undefined;
|
|
21
|
+
appKey?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
account_id?: string | undefined;
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
limit?: number | undefined;
|
|
26
|
+
offset?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type FindFirstAuthenticationOptions = z.infer<typeof FindFirstAuthenticationSchema> & {
|
|
29
|
+
/** Base URL for Zapier API */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Authentication token */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** Optional pre-instantiated API client */
|
|
34
|
+
api?: any;
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Custom fetch implementation */
|
|
38
|
+
fetch?: typeof globalThis.fetch;
|
|
39
|
+
};
|
|
40
|
+
export interface FindFirstAuthenticationSdkFunction {
|
|
41
|
+
findFirstAuthentication: (options?: Partial<FindFirstAuthenticationOptions>) => Promise<Authentication | null>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindFirstAuthenticationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
const schema_utils_1 = require("../../schema-utils");
|
|
7
|
+
const Auth_1 = require("../../schemas/Auth");
|
|
8
|
+
// Pure Zod schema - no resolver metadata!
|
|
9
|
+
exports.FindFirstAuthenticationSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
|
|
12
|
+
search: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Search term to filter authentications by title"),
|
|
16
|
+
title: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Filter authentications by exact title match"),
|
|
20
|
+
account_id: zod_1.z.string().optional().describe("Filter by account ID"),
|
|
21
|
+
owner: zod_1.z.string().optional().describe("Filter by owner"),
|
|
22
|
+
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
|
23
|
+
offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
|
|
24
|
+
})
|
|
25
|
+
.describe("Find the first authentication matching the criteria"), Auth_1.AuthItemSchema);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Authentication } from "../../types/domain";
|
|
2
|
+
import type { FindUniqueAuthenticationOptions } from "./schemas";
|
|
3
|
+
/**
|
|
4
|
+
* Find a unique authentication matching the given criteria
|
|
5
|
+
*
|
|
6
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
7
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Filtering and API configuration options
|
|
10
|
+
* @returns Promise<Authentication> - The unique matching authentication
|
|
11
|
+
* @throws Error if no authentication found or multiple authentications found
|
|
12
|
+
*/
|
|
13
|
+
export declare function findUniqueAuthentication(options?: Partial<FindUniqueAuthenticationOptions>): Promise<Authentication>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findUniqueAuthentication = findUniqueAuthentication;
|
|
4
|
+
const listAuthentications_1 = require("../listAuthentications");
|
|
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
|
+
async function findUniqueAuthentication(options = {}) {
|
|
16
|
+
// Use listAuthentications with a reasonable limit to check for uniqueness
|
|
17
|
+
const auths = await (0, listAuthentications_1.listAuthentications)({
|
|
18
|
+
...options,
|
|
19
|
+
limit: 2, // Get up to 2 to check for uniqueness
|
|
20
|
+
});
|
|
21
|
+
if (auths.length === 0) {
|
|
22
|
+
throw new Error("No authentication found matching the specified criteria");
|
|
23
|
+
}
|
|
24
|
+
if (auths.length > 1) {
|
|
25
|
+
throw new Error("Multiple authentications found matching the specified criteria. Expected exactly one.");
|
|
26
|
+
}
|
|
27
|
+
return auths[0];
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findUniqueAuthentication } from "./index";
|
|
2
|
+
export declare const findUniqueAuthenticationInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
account_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
owner: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
11
|
+
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
12
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
appKey?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
account_id?: string | undefined;
|
|
17
|
+
owner?: string | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
offset?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
search?: string | undefined;
|
|
22
|
+
appKey?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
account_id?: string | undefined;
|
|
25
|
+
owner?: string | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
offset?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
implementation: typeof findUniqueAuthentication;
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findUniqueAuthenticationInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.findUniqueAuthenticationInfo = {
|
|
8
|
+
name: index_1.findUniqueAuthentication.name,
|
|
9
|
+
inputSchema: schemas_1.FindUniqueAuthenticationSchema,
|
|
10
|
+
implementation: index_1.findUniqueAuthentication,
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Authentication } from "../../types/domain";
|
|
3
|
+
export declare const FindUniqueAuthenticationSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodOptional<z.ZodString>;
|
|
5
|
+
search: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
10
|
+
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
search?: string | undefined;
|
|
13
|
+
appKey?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
account_id?: string | undefined;
|
|
16
|
+
owner?: string | undefined;
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
offset?: number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
search?: string | undefined;
|
|
21
|
+
appKey?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
account_id?: string | undefined;
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
limit?: number | undefined;
|
|
26
|
+
offset?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type FindUniqueAuthenticationOptions = z.infer<typeof FindUniqueAuthenticationSchema> & {
|
|
29
|
+
/** Base URL for Zapier API */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Authentication token */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** Optional pre-instantiated API client */
|
|
34
|
+
api?: any;
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Custom fetch implementation */
|
|
38
|
+
fetch?: typeof globalThis.fetch;
|
|
39
|
+
};
|
|
40
|
+
export interface FindUniqueAuthenticationSdkFunction {
|
|
41
|
+
findUniqueAuthentication: (options?: Partial<FindUniqueAuthenticationOptions>) => Promise<Authentication>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindUniqueAuthenticationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
const schema_utils_1 = require("../../schema-utils");
|
|
7
|
+
const Auth_1 = require("../../schemas/Auth");
|
|
8
|
+
// Pure Zod schema - no resolver metadata!
|
|
9
|
+
exports.FindUniqueAuthenticationSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
|
|
12
|
+
search: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Search term to filter authentications by title"),
|
|
16
|
+
title: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Filter authentications by exact title match"),
|
|
20
|
+
account_id: zod_1.z.string().optional().describe("Filter by account ID"),
|
|
21
|
+
owner: zod_1.z.string().optional().describe("Filter by owner"),
|
|
22
|
+
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
|
23
|
+
offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
|
|
24
|
+
})
|
|
25
|
+
.describe("Find a unique authentication matching the criteria"), Auth_1.AuthItemSchema);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Authentication } from "../../types/domain";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ListAuthenticationsOptions } from "./schemas";
|
|
3
3
|
/**
|
|
4
4
|
* List available authentications with optional filtering
|
|
5
5
|
*
|
|
@@ -9,4 +9,4 @@ import type { ListAuthsOptions } from "./schemas";
|
|
|
9
9
|
* @param options - Filtering, pagination, and API configuration options
|
|
10
10
|
* @returns Promise<Authentication[]> with pagination metadata
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function listAuthentications(options?: Partial<ListAuthenticationsOptions>): Promise<Authentication[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.listAuthentications = listAuthentications;
|
|
4
4
|
const api_1 = require("../../api");
|
|
5
5
|
const getApp_1 = require("../getApp");
|
|
6
6
|
/**
|
|
@@ -12,14 +12,14 @@ const getApp_1 = require("../getApp");
|
|
|
12
12
|
* @param options - Filtering, pagination, and API configuration options
|
|
13
13
|
* @returns Promise<Authentication[]> with pagination metadata
|
|
14
14
|
*/
|
|
15
|
-
async function
|
|
15
|
+
async function listAuthentications(options = {}) {
|
|
16
16
|
const { token } = options;
|
|
17
17
|
if (!token && !process.env.ZAPIER_TOKEN) {
|
|
18
18
|
throw new Error("Authentication token is required to list authentications. Please provide token in options or set ZAPIER_TOKEN environment variable.");
|
|
19
19
|
}
|
|
20
20
|
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
21
21
|
// Local function to handle the actual API fetching
|
|
22
|
-
const
|
|
22
|
+
const listAuthenticationsInternal = async (options = {}) => {
|
|
23
23
|
// Build search parameters
|
|
24
24
|
const searchParams = {};
|
|
25
25
|
// Handle appKey filtering by getting the selected_api first
|
|
@@ -52,6 +52,13 @@ async function listAuths(options = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
// Add other query parameters if provided
|
|
55
|
+
// Use title as search if no explicit search provided
|
|
56
|
+
if (options.search) {
|
|
57
|
+
searchParams.search = options.search;
|
|
58
|
+
}
|
|
59
|
+
else if (options.title) {
|
|
60
|
+
searchParams.search = options.title;
|
|
61
|
+
}
|
|
55
62
|
if (options.account_id) {
|
|
56
63
|
searchParams.account_id = options.account_id;
|
|
57
64
|
}
|
|
@@ -77,7 +84,16 @@ async function listAuths(options = {}) {
|
|
|
77
84
|
},
|
|
78
85
|
});
|
|
79
86
|
// Transform API response
|
|
80
|
-
|
|
87
|
+
let auths = data.results || [];
|
|
88
|
+
// Coerce title from label if title is missing (API cleanup)
|
|
89
|
+
auths = auths.map((auth) => ({
|
|
90
|
+
...auth,
|
|
91
|
+
title: auth.title || auth.label || undefined,
|
|
92
|
+
}));
|
|
93
|
+
// Filter by exact title match if specified
|
|
94
|
+
if (options.title) {
|
|
95
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
96
|
+
}
|
|
81
97
|
// Add pagination metadata to the response
|
|
82
98
|
if (auths.length > 0) {
|
|
83
99
|
auths.__pagination = {
|
|
@@ -93,7 +109,7 @@ async function listAuths(options = {}) {
|
|
|
93
109
|
// If a limit is provided and no specific owner filter, prioritize owned auths
|
|
94
110
|
if (options.limit && options.owner === undefined) {
|
|
95
111
|
// First get owned auths
|
|
96
|
-
const ownedAuths = await
|
|
112
|
+
const ownedAuths = await listAuthenticationsInternal({
|
|
97
113
|
...options,
|
|
98
114
|
owner: "me",
|
|
99
115
|
});
|
|
@@ -102,7 +118,7 @@ async function listAuths(options = {}) {
|
|
|
102
118
|
return ownedAuths.slice(0, options.limit);
|
|
103
119
|
}
|
|
104
120
|
// Get all auths up to the original limit to fill remaining slots
|
|
105
|
-
const allAuths = await
|
|
121
|
+
const allAuths = await listAuthenticationsInternal({
|
|
106
122
|
...options,
|
|
107
123
|
owner: undefined,
|
|
108
124
|
});
|
|
@@ -114,5 +130,5 @@ async function listAuths(options = {}) {
|
|
|
114
130
|
return combined.slice(0, options.limit);
|
|
115
131
|
}
|
|
116
132
|
// Standard implementation for non-prioritized requests
|
|
117
|
-
return
|
|
133
|
+
return listAuthenticationsInternal(options);
|
|
118
134
|
}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { listAuthentications } from "./index";
|
|
2
|
+
export declare const listAuthenticationsInfo: {
|
|
3
3
|
name: string;
|
|
4
4
|
inputSchema: import("zod").ZodObject<{
|
|
5
5
|
appKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
8
|
account_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
9
|
owner: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
10
|
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
9
11
|
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
10
12
|
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
11
14
|
appKey?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
12
16
|
account_id?: string | undefined;
|
|
13
17
|
owner?: string | undefined;
|
|
14
18
|
limit?: number | undefined;
|
|
15
19
|
offset?: number | undefined;
|
|
16
20
|
}, {
|
|
21
|
+
search?: string | undefined;
|
|
17
22
|
appKey?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
18
24
|
account_id?: string | undefined;
|
|
19
25
|
owner?: string | undefined;
|
|
20
26
|
limit?: number | undefined;
|
|
21
27
|
offset?: number | undefined;
|
|
22
28
|
}>;
|
|
23
|
-
implementation: typeof
|
|
29
|
+
implementation: typeof listAuthentications;
|
|
24
30
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listAuthenticationsInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.listAuthenticationsInfo = {
|
|
8
|
+
name: index_1.listAuthentications.name,
|
|
9
|
+
inputSchema: schemas_1.ListAuthenticationsSchema,
|
|
10
|
+
implementation: index_1.listAuthentications,
|
|
11
|
+
};
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { Authentication } from "../../types/domain";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
4
4
|
appKey: z.ZodOptional<z.ZodString>;
|
|
5
|
+
search: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
5
7
|
account_id: z.ZodOptional<z.ZodString>;
|
|
6
8
|
owner: z.ZodOptional<z.ZodString>;
|
|
7
9
|
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
8
10
|
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
9
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
search?: string | undefined;
|
|
10
13
|
appKey?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
11
15
|
account_id?: string | undefined;
|
|
12
16
|
owner?: string | undefined;
|
|
13
17
|
limit?: number | undefined;
|
|
14
18
|
offset?: number | undefined;
|
|
15
19
|
}, {
|
|
20
|
+
search?: string | undefined;
|
|
16
21
|
appKey?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
17
23
|
account_id?: string | undefined;
|
|
18
24
|
owner?: string | undefined;
|
|
19
25
|
limit?: number | undefined;
|
|
20
26
|
offset?: number | undefined;
|
|
21
27
|
}>;
|
|
22
|
-
export type
|
|
28
|
+
export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema> & {
|
|
23
29
|
/** Base URL for Zapier API */
|
|
24
30
|
baseUrl?: string;
|
|
25
31
|
/** Authentication token */
|
|
@@ -31,6 +37,6 @@ export type ListAuthsOptions = z.infer<typeof ListAuthsSchema> & {
|
|
|
31
37
|
/** Custom fetch implementation */
|
|
32
38
|
fetch?: typeof globalThis.fetch;
|
|
33
39
|
};
|
|
34
|
-
export interface
|
|
35
|
-
|
|
40
|
+
export interface ListAuthenticationsSdkFunction {
|
|
41
|
+
listAuthentications: (options?: Partial<ListAuthenticationsOptions>) => Promise<Authentication[]>;
|
|
36
42
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ListAuthenticationsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const properties_1 = require("../../types/properties");
|
|
6
6
|
const schema_utils_1 = require("../../schema-utils");
|
|
7
7
|
const Auth_1 = require("../../schemas/Auth");
|
|
8
8
|
// Pure Zod schema - no resolver metadata!
|
|
9
|
-
exports.
|
|
9
|
+
exports.ListAuthenticationsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
10
|
.object({
|
|
11
11
|
appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
|
|
12
|
+
search: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Search term to filter authentications by title"),
|
|
16
|
+
title: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Filter authentications by exact title match"),
|
|
12
20
|
account_id: zod_1.z.string().optional().describe("Filter by account ID"),
|
|
13
21
|
owner: zod_1.z.string().optional().describe("Filter by owner"),
|
|
14
22
|
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from "./types/domain";
|
|
2
2
|
export * from "./types/properties";
|
|
3
3
|
export * from "./plugins/apps";
|
|
4
|
+
export { isPositional } from "./schema-utils";
|
|
4
5
|
export * from "./resolvers";
|
|
5
|
-
export {
|
|
6
|
+
export { listAuthentications } from "./functions/listAuthentications";
|
|
7
|
+
export { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
8
|
+
export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
6
9
|
export { listApps } from "./functions/listApps";
|
|
7
10
|
export { getApp } from "./functions/getApp";
|
|
8
11
|
export { listActions } from "./functions/listActions";
|
package/dist/index.js
CHANGED
|
@@ -14,17 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createZapierSdk = exports.bundleCode = exports.generateTypes = exports.listFields = exports.runAction = exports.getAction = exports.listActions = exports.getApp = exports.listApps = exports.
|
|
17
|
+
exports.createZapierSdk = exports.bundleCode = exports.generateTypes = exports.listFields = exports.runAction = exports.getAction = exports.listActions = exports.getApp = exports.listApps = exports.findUniqueAuthentication = exports.findFirstAuthentication = exports.listAuthentications = exports.isPositional = void 0;
|
|
18
18
|
// Export everything from types and plugins
|
|
19
19
|
__exportStar(require("./types/domain"), exports);
|
|
20
20
|
__exportStar(require("./types/properties"), exports);
|
|
21
21
|
__exportStar(require("./plugins/apps"), exports);
|
|
22
|
+
// Export schema utilities for CLI
|
|
23
|
+
var schema_utils_1 = require("./schema-utils");
|
|
24
|
+
Object.defineProperty(exports, "isPositional", { enumerable: true, get: function () { return schema_utils_1.isPositional; } });
|
|
22
25
|
// Export resolvers for CLI use
|
|
23
26
|
__exportStar(require("./resolvers"), exports);
|
|
24
27
|
// Note: SdkSchemas is now available via SDK.__registry
|
|
25
28
|
// Export individual functions for tree-shaking
|
|
26
|
-
var
|
|
27
|
-
Object.defineProperty(exports, "
|
|
29
|
+
var listAuthentications_1 = require("./functions/listAuthentications");
|
|
30
|
+
Object.defineProperty(exports, "listAuthentications", { enumerable: true, get: function () { return listAuthentications_1.listAuthentications; } });
|
|
31
|
+
var findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
|
|
32
|
+
Object.defineProperty(exports, "findFirstAuthentication", { enumerable: true, get: function () { return findFirstAuthentication_1.findFirstAuthentication; } });
|
|
33
|
+
var findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
|
|
34
|
+
Object.defineProperty(exports, "findUniqueAuthentication", { enumerable: true, get: function () { return findUniqueAuthentication_1.findUniqueAuthentication; } });
|
|
28
35
|
var listApps_1 = require("./functions/listApps");
|
|
29
36
|
Object.defineProperty(exports, "listApps", { enumerable: true, get: function () { return listApps_1.listApps; } });
|
|
30
37
|
var getApp_1 = require("./functions/getApp");
|
|
@@ -6,7 +6,7 @@ exports.authenticationIdResolver = {
|
|
|
6
6
|
depends: ["appKey"],
|
|
7
7
|
fetch: async (sdk, resolvedParams) => {
|
|
8
8
|
// Get auths for the specific app (owned auths will be prioritized automatically)
|
|
9
|
-
return await sdk.
|
|
9
|
+
return await sdk.listAuthentications({
|
|
10
10
|
appKey: resolvedParams.appKey,
|
|
11
11
|
limit: 1000,
|
|
12
12
|
});
|
package/dist/schema-utils.d.ts
CHANGED
|
@@ -37,3 +37,8 @@ export interface ResolverConfig {
|
|
|
37
37
|
export declare function withResolver<T extends z.ZodType>(schema: T, config: ResolverConfig): T;
|
|
38
38
|
export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
|
|
39
39
|
export declare function getFieldDescriptions(schema: z.ZodObject<any>): Record<string, string>;
|
|
40
|
+
export interface PositionalMetadata {
|
|
41
|
+
positional: true;
|
|
42
|
+
}
|
|
43
|
+
export declare function withPositional<T extends z.ZodType>(schema: T): T;
|
|
44
|
+
export declare function isPositional(schema: z.ZodType): boolean;
|
package/dist/schema-utils.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.getOutputSchema = getOutputSchema;
|
|
|
7
7
|
exports.withResolver = withResolver;
|
|
8
8
|
exports.getSchemaDescription = getSchemaDescription;
|
|
9
9
|
exports.getFieldDescriptions = getFieldDescriptions;
|
|
10
|
+
exports.withPositional = withPositional;
|
|
11
|
+
exports.isPositional = isPositional;
|
|
10
12
|
const zod_1 = require("zod");
|
|
11
13
|
// Helper function to add format metadata to schemas
|
|
12
14
|
function withFormatter(schema, formatMeta) {
|
|
@@ -50,3 +52,25 @@ function getFieldDescriptions(schema) {
|
|
|
50
52
|
}
|
|
51
53
|
return descriptions;
|
|
52
54
|
}
|
|
55
|
+
// Helper function to mark a parameter as positional for CLI
|
|
56
|
+
function withPositional(schema) {
|
|
57
|
+
// Store positional metadata on the schema definition
|
|
58
|
+
schema._def.positionalMeta = { positional: true };
|
|
59
|
+
return schema;
|
|
60
|
+
}
|
|
61
|
+
// Helper function to check if a parameter should be positional
|
|
62
|
+
function isPositional(schema) {
|
|
63
|
+
// Check the current schema first
|
|
64
|
+
if (schema._def.positionalMeta?.positional) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// If this is a ZodOptional, check the inner type
|
|
68
|
+
if (schema instanceof zod_1.z.ZodOptional) {
|
|
69
|
+
return isPositional(schema._def.innerType);
|
|
70
|
+
}
|
|
71
|
+
// If this is a ZodDefault, check the inner type
|
|
72
|
+
if (schema instanceof zod_1.z.ZodDefault) {
|
|
73
|
+
return isPositional(schema._def.innerType);
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
package/dist/schemas/Auth.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const AuthItemSchema: z.ZodObject<{
|
|
3
3
|
id: z.ZodNumber;
|
|
4
4
|
title: z.ZodOptional<z.ZodString>;
|
|
5
|
-
label: z.ZodOptional<z.ZodString>;
|
|
6
5
|
identifier: z.ZodOptional<z.ZodString>;
|
|
7
6
|
account_id: z.ZodOptional<z.ZodString>;
|
|
8
7
|
is_private: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -11,7 +10,6 @@ export declare const AuthItemSchema: z.ZodObject<{
|
|
|
11
10
|
}, "strip", z.ZodTypeAny, {
|
|
12
11
|
id: number;
|
|
13
12
|
title?: string | undefined;
|
|
14
|
-
label?: string | undefined;
|
|
15
13
|
identifier?: string | undefined;
|
|
16
14
|
account_id?: string | undefined;
|
|
17
15
|
is_private?: boolean | undefined;
|
|
@@ -20,7 +18,6 @@ export declare const AuthItemSchema: z.ZodObject<{
|
|
|
20
18
|
}, {
|
|
21
19
|
id: number;
|
|
22
20
|
title?: string | undefined;
|
|
23
|
-
label?: string | undefined;
|
|
24
21
|
identifier?: string | undefined;
|
|
25
22
|
account_id?: string | undefined;
|
|
26
23
|
is_private?: boolean | undefined;
|