@zapier/zapier-sdk 0.11.0 → 0.11.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 +12 -0
- package/README.md +149 -95
- package/dist/index.cjs +69 -25
- package/dist/index.d.mts +35 -2
- package/dist/index.mjs +69 -25
- package/dist/plugins/fetch/index.d.ts +14 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +14 -0
- package/dist/plugins/fetch/schemas.d.ts +25 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -0
- package/dist/plugins/fetch/schemas.js +33 -0
- package/dist/plugins/registry/index.d.ts +3 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +55 -34
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +6 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/plugins/fetch/index.ts +25 -0
- package/src/plugins/fetch/schemas.ts +37 -0
- package/src/plugins/registry/index.ts +66 -34
- package/src/types/sdk.ts +3 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -4,7 +4,7 @@ import type { FunctionRegistryEntry } from "../../types/sdk";
|
|
|
4
4
|
export interface RegisterPluginFunctionOptions {}
|
|
5
5
|
|
|
6
6
|
export interface RegistryPluginProvides {
|
|
7
|
-
getRegistry: () => {
|
|
7
|
+
getRegistry: (options?: { package?: string }) => {
|
|
8
8
|
functions: FunctionRegistryEntry[];
|
|
9
9
|
categories: {
|
|
10
10
|
key: string;
|
|
@@ -62,53 +62,85 @@ export const registryPlugin: Plugin<
|
|
|
62
62
|
itemType: meta.itemType,
|
|
63
63
|
returnType: meta.returnType,
|
|
64
64
|
inputSchema: meta.inputSchema,
|
|
65
|
+
inputParameters: meta.inputParameters,
|
|
65
66
|
outputSchema: meta.outputSchema,
|
|
66
67
|
categories: meta.categories || [],
|
|
67
68
|
resolvers: meta.resolvers,
|
|
69
|
+
packages: meta.packages,
|
|
68
70
|
};
|
|
69
71
|
})
|
|
70
72
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
71
73
|
|
|
72
74
|
const knownCategories = Object.keys(categoryDefinitions);
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
// Cache the entire registry result for each package
|
|
77
|
+
const registryCache = new Map<
|
|
78
|
+
string,
|
|
79
|
+
{ functions: FunctionRegistryEntry[]; categories: any[] }
|
|
80
|
+
>();
|
|
81
|
+
|
|
82
|
+
function getRegistry(options?: { package?: string }) {
|
|
83
|
+
const packageFilter = options?.package;
|
|
84
|
+
const cacheKey = packageFilter || "__all__";
|
|
85
|
+
|
|
86
|
+
// Return cached result if available
|
|
87
|
+
if (registryCache.has(cacheKey)) {
|
|
88
|
+
return registryCache.get(cacheKey)!;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Filter functions by package if specified
|
|
92
|
+
const filteredFunctions = packageFilter
|
|
93
|
+
? functions.filter(
|
|
88
94
|
(f) =>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(categoryKey === "other" &&
|
|
92
|
-
!f.categories.some((c) => knownCategories.includes(c))),
|
|
95
|
+
// Include if packages is undefined (belongs to all packages) or includes the specified package
|
|
96
|
+
!f.packages || f.packages.includes(packageFilter),
|
|
93
97
|
)
|
|
94
|
-
|
|
95
|
-
.sort(); // Alphabetize functions within each category
|
|
98
|
+
: functions;
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
// Build categories with filtered functions
|
|
101
|
+
const filteredCategories = knownCategories
|
|
102
|
+
.sort((a, b) => {
|
|
103
|
+
// Keep "other" category last
|
|
104
|
+
if (a === "other") return 1;
|
|
105
|
+
if (b === "other") return -1;
|
|
106
|
+
// Alphabetize by title, not key
|
|
107
|
+
const titleA = categoryDefinitions[a].title;
|
|
108
|
+
const titleB = categoryDefinitions[b].title;
|
|
109
|
+
return titleA.localeCompare(titleB);
|
|
110
|
+
})
|
|
111
|
+
.map((categoryKey) => {
|
|
112
|
+
// Find the functions that are in this category and match the package filter
|
|
113
|
+
const categoryFunctions = filteredFunctions
|
|
114
|
+
.filter(
|
|
115
|
+
(f) =>
|
|
116
|
+
f.categories.includes(categoryKey) ||
|
|
117
|
+
// If the category is "other" and the function is not in any other category, include it
|
|
118
|
+
(categoryKey === "other" &&
|
|
119
|
+
!f.categories.some((c) => knownCategories.includes(c))),
|
|
120
|
+
)
|
|
121
|
+
.map((f) => f.name)
|
|
122
|
+
.sort(); // Alphabetize functions within each category
|
|
123
|
+
|
|
124
|
+
const definition = categoryDefinitions[categoryKey];
|
|
125
|
+
const title = definition.title;
|
|
126
|
+
return {
|
|
127
|
+
key: categoryKey,
|
|
128
|
+
title,
|
|
129
|
+
titlePlural: definition.titlePlural ?? `${title}s`,
|
|
130
|
+
functions: categoryFunctions,
|
|
131
|
+
};
|
|
132
|
+
})
|
|
133
|
+
.filter((category) => category.functions.length > 0); // Only include categories with functions
|
|
106
134
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
categories,
|
|
135
|
+
const result = {
|
|
136
|
+
functions: filteredFunctions,
|
|
137
|
+
categories: filteredCategories,
|
|
111
138
|
};
|
|
139
|
+
|
|
140
|
+
// Cache the result
|
|
141
|
+
registryCache.set(cacheKey, result);
|
|
142
|
+
|
|
143
|
+
return result;
|
|
112
144
|
}
|
|
113
145
|
|
|
114
146
|
return {
|
package/src/types/sdk.ts
CHANGED
|
@@ -60,10 +60,12 @@ export interface FunctionRegistryEntry {
|
|
|
60
60
|
type?: "list" | "item";
|
|
61
61
|
itemType?: string;
|
|
62
62
|
returnType?: string;
|
|
63
|
-
inputSchema
|
|
63
|
+
inputSchema?: z.ZodSchema;
|
|
64
|
+
inputParameters?: Array<{ name: string; schema: z.ZodSchema }>;
|
|
64
65
|
outputSchema?: z.ZodSchema;
|
|
65
66
|
categories: string[];
|
|
66
67
|
resolvers?: Record<string, any>;
|
|
68
|
+
packages?: string[];
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
// Compose SDK functions from individual function interfaces
|