@zapier/zapier-sdk 0.18.2 → 0.18.4
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 +13 -13
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +0 -18
- package/dist/api/schemas.d.ts +0 -158
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +0 -95
- package/dist/api/types.d.ts +2 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +400 -808
- package/dist/index.d.mts +67 -122
- package/dist/index.mjs +401 -809
- package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
- package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
- package/dist/plugins/listApps/index.d.ts +2 -8
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -6
- package/dist/plugins/listApps/index.test.js +62 -82
- package/dist/plugins/listApps/schemas.d.ts +35 -14
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +44 -14
- package/dist/plugins/listAuthentications/index.d.ts +4 -10
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +19 -31
- package/dist/plugins/listAuthentications/index.test.js +363 -127
- package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +10 -16
- package/dist/schemas/App.d.ts +28 -28
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +3 -8
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.test.js +12 -9
- package/dist/utils/domain-utils.d.ts +2 -15
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +0 -38
- package/dist/utils/function-utils.d.ts +1 -0
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +15 -3
- package/package.json +2 -2
- package/dist/api/client.integration.test.d.ts +0 -5
- package/dist/api/client.integration.test.d.ts.map +0 -1
- package/dist/api/client.integration.test.js +0 -318
- package/dist/api/client.methods.test.d.ts +0 -2
- package/dist/api/client.methods.test.d.ts.map +0 -1
- package/dist/api/client.methods.test.js +0 -158
- package/dist/api/router.d.ts +0 -16
- package/dist/api/router.d.ts.map +0 -1
- package/dist/api/router.js +0 -31
- package/dist/api/router.test.d.ts +0 -2
- package/dist/api/router.test.d.ts.map +0 -1
- package/dist/api/router.test.js +0 -103
- package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.js +0 -134
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
- package/dist/temporary-internal-core/index.d.ts +0 -18
- package/dist/temporary-internal-core/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/index.js +0 -18
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
- package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
- package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
- package/dist/temporary-internal-core/types/handler.d.ts +0 -51
- package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/handler.js +0 -8
- package/dist/temporary-internal-core/types/index.d.ts +0 -5
- package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/index.js +0 -4
- package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/app-locators.js +0 -39
- package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
- package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/string-utils.js +0 -52
- package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/transformations.js +0 -74
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
|
+
var apps = require('@zapier/zapier-sdk-core/v0/schemas/apps');
|
|
4
5
|
var authentications = require('@zapier/zapier-sdk-core/v0/schemas/authentications');
|
|
5
6
|
var promises = require('timers/promises');
|
|
6
7
|
var os = require('os');
|
|
@@ -716,10 +717,16 @@ function createPageFunction(coreFn) {
|
|
|
716
717
|
try {
|
|
717
718
|
const result = await coreFn(options);
|
|
718
719
|
if (result && typeof result === "object" && "data" in result) {
|
|
719
|
-
const
|
|
720
|
+
const paginatedResult = result;
|
|
721
|
+
let nextCursor;
|
|
722
|
+
if (paginatedResult.nextCursor) {
|
|
723
|
+
nextCursor = paginatedResult.nextCursor;
|
|
724
|
+
} else if (paginatedResult.links?.next) {
|
|
725
|
+
nextCursor = extractCursor({ next: paginatedResult.links.next });
|
|
726
|
+
}
|
|
720
727
|
return {
|
|
721
|
-
data: Array.isArray(data) ? data : [data],
|
|
722
|
-
nextCursor
|
|
728
|
+
data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
|
|
729
|
+
nextCursor
|
|
723
730
|
};
|
|
724
731
|
}
|
|
725
732
|
if (Array.isArray(result)) {
|
|
@@ -811,105 +818,230 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
811
818
|
};
|
|
812
819
|
return namedFunctions[functionName];
|
|
813
820
|
}
|
|
814
|
-
var
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
age_in_days: zod.z.number().optional(),
|
|
819
|
-
auth_type: zod.z.string().optional(),
|
|
820
|
-
banner: zod.z.string().optional(),
|
|
821
|
-
categories: zod.z.array(
|
|
822
|
-
zod.z.object({
|
|
823
|
-
id: zod.z.number(),
|
|
824
|
-
name: zod.z.string(),
|
|
825
|
-
slug: zod.z.string()
|
|
826
|
-
})
|
|
827
|
-
).optional(),
|
|
828
|
-
images: zod.z.object({
|
|
829
|
-
url_16x16: zod.z.string().optional(),
|
|
830
|
-
url_32x32: zod.z.string().optional(),
|
|
831
|
-
url_64x64: zod.z.string().optional(),
|
|
832
|
-
url_128x128: zod.z.string().optional()
|
|
833
|
-
}).optional(),
|
|
834
|
-
popularity: zod.z.number().optional(),
|
|
835
|
-
has_filters: zod.z.boolean().optional(),
|
|
836
|
-
has_reads: zod.z.boolean().optional(),
|
|
837
|
-
has_searches: zod.z.boolean().optional(),
|
|
838
|
-
has_searches_or_writes: zod.z.boolean().optional(),
|
|
839
|
-
has_upfront_fields: zod.z.boolean().optional(),
|
|
840
|
-
has_writes: zod.z.boolean().optional(),
|
|
841
|
-
is_beta: zod.z.boolean().optional(),
|
|
842
|
-
is_built_in: zod.z.boolean().optional(),
|
|
843
|
-
is_deprecated: zod.z.boolean().optional(),
|
|
844
|
-
is_featured: zod.z.boolean().optional(),
|
|
845
|
-
is_hidden: zod.z.boolean().optional(),
|
|
846
|
-
is_invite: zod.z.boolean().optional(),
|
|
847
|
-
is_premium: zod.z.boolean().optional(),
|
|
848
|
-
is_public: zod.z.boolean().optional(),
|
|
849
|
-
is_upcoming: zod.z.boolean().optional(),
|
|
850
|
-
version: zod.z.string().optional(),
|
|
851
|
-
visibility: zod.z.string().optional(),
|
|
852
|
-
actions: zod.z.object({
|
|
853
|
-
read: zod.z.number().optional(),
|
|
854
|
-
read_bulk: zod.z.number().optional(),
|
|
855
|
-
write: zod.z.number().optional(),
|
|
856
|
-
search: zod.z.number().optional(),
|
|
857
|
-
search_or_write: zod.z.number().optional(),
|
|
858
|
-
search_and_write: zod.z.number().optional(),
|
|
859
|
-
filter: zod.z.number().optional()
|
|
860
|
-
}).optional(),
|
|
861
|
-
description: zod.z.string().optional(),
|
|
862
|
-
primary_color: zod.z.string().optional(),
|
|
863
|
-
secondary_color: zod.z.string().optional(),
|
|
864
|
-
classification: zod.z.string().optional(),
|
|
865
|
-
api_docs_url: zod.z.string().optional(),
|
|
866
|
-
image: zod.z.string().optional()
|
|
867
|
-
});
|
|
868
|
-
zod.z.object({
|
|
869
|
-
count: zod.z.number(),
|
|
870
|
-
next: zod.z.string().nullable().optional(),
|
|
871
|
-
previous: zod.z.string().nullable().optional(),
|
|
872
|
-
results: zod.z.array(ImplementationMetaSchema)
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// src/temporary-internal-core/schemas/apps/index.ts
|
|
876
|
-
var ListAppsOptionsSchema = zod.z.object({
|
|
821
|
+
var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
822
|
+
offset: true
|
|
823
|
+
}).extend({
|
|
824
|
+
// Override appKeys to be an array instead of comma-separated string
|
|
877
825
|
appKeys: zod.z.array(zod.z.string()).optional().describe(
|
|
878
826
|
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
879
827
|
),
|
|
880
|
-
|
|
828
|
+
// Override pageSize to make optional (base has default value)
|
|
881
829
|
pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
|
|
830
|
+
// SDK specific property for pagination/iterator helpers
|
|
882
831
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
832
|
+
// SDK specific property for pagination/iterator helpers
|
|
883
833
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
884
834
|
}).merge(TelemetryMarkerSchema).describe("List all available apps with optional filtering");
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
835
|
+
|
|
836
|
+
// src/utils/string-utils.ts
|
|
837
|
+
function toTitleCase(input) {
|
|
838
|
+
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
839
|
+
}
|
|
840
|
+
function toSnakeCase(input) {
|
|
841
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
842
|
+
if (/^[0-9]/.test(result)) {
|
|
843
|
+
result = "_" + result;
|
|
844
|
+
}
|
|
845
|
+
return result;
|
|
846
|
+
}
|
|
847
|
+
function stripPageSuffix(functionName) {
|
|
848
|
+
return functionName.replace(/Page$/, "");
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/schemas/App.ts
|
|
852
|
+
var AppItemSchema = withFormatter(apps.AppItemSchema, {
|
|
853
|
+
format: (item) => {
|
|
854
|
+
const additionalKeys = [];
|
|
855
|
+
if (item.slug && item.slug !== item.key) {
|
|
856
|
+
additionalKeys.push(item.slug);
|
|
857
|
+
const snakeCaseSlug = toSnakeCase(item.slug);
|
|
858
|
+
if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
|
|
859
|
+
additionalKeys.push(snakeCaseSlug);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
title: item.title,
|
|
864
|
+
key: item.key,
|
|
865
|
+
keys: [item.key, ...additionalKeys],
|
|
866
|
+
description: item.description,
|
|
867
|
+
details: []
|
|
868
|
+
};
|
|
869
|
+
}
|
|
897
870
|
});
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
871
|
+
|
|
872
|
+
// src/utils/telemetry-utils.ts
|
|
873
|
+
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
874
|
+
return {
|
|
875
|
+
onMethodCalled: (data) => {
|
|
876
|
+
emitMethodCalled({
|
|
877
|
+
method_name: methodName,
|
|
878
|
+
execution_duration_ms: data.durationMs,
|
|
879
|
+
success_flag: data.success,
|
|
880
|
+
error_message: data.error?.message ?? null,
|
|
881
|
+
error_type: data.error?.constructor.name ?? null,
|
|
882
|
+
argument_count: data.argumentCount,
|
|
883
|
+
is_paginated: data.isPaginated
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// src/plugins/listApps/index.ts
|
|
890
|
+
var listAppsPlugin = ({ context }) => {
|
|
891
|
+
async function listAppsPage(options) {
|
|
892
|
+
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
893
|
+
const appKeys = options.appKeys ?? [];
|
|
894
|
+
const appLocators = await resolveAppKeys2({
|
|
895
|
+
appKeys: [...appKeys]
|
|
896
|
+
});
|
|
897
|
+
const implementationNameToLocator = {};
|
|
898
|
+
for (const locator of appLocators) {
|
|
899
|
+
implementationNameToLocator[locator.implementationName] = [
|
|
900
|
+
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
901
|
+
locator
|
|
902
|
+
];
|
|
903
|
+
}
|
|
904
|
+
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
905
|
+
if (duplicatedLookupAppKeys.length > 0) {
|
|
906
|
+
throw new Error(
|
|
907
|
+
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
911
|
+
return {
|
|
912
|
+
data: [],
|
|
913
|
+
links: { next: null },
|
|
914
|
+
meta: { count: 0, limit: 0, offset: 0 }
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
const implementationIds = appLocators.map((locator) => {
|
|
918
|
+
const version = locator.version || "latest";
|
|
919
|
+
return `${locator.implementationName}@${version}`;
|
|
920
|
+
});
|
|
921
|
+
return await api.get("/api/v0/apps", {
|
|
922
|
+
searchParams: {
|
|
923
|
+
appKeys: implementationIds.join(","),
|
|
924
|
+
...options.search && { search: options.search },
|
|
925
|
+
pageSize: options.pageSize.toString(),
|
|
926
|
+
...options.cursor && { offset: options.cursor }
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
const methodName = stripPageSuffix(listAppsPage.name);
|
|
931
|
+
const listAppsDefinition = createPaginatedFunction(
|
|
932
|
+
listAppsPage,
|
|
933
|
+
ListAppsSchema,
|
|
934
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
935
|
+
methodName
|
|
936
|
+
);
|
|
937
|
+
return {
|
|
938
|
+
listApps: listAppsDefinition,
|
|
939
|
+
context: {
|
|
940
|
+
meta: {
|
|
941
|
+
listApps: {
|
|
942
|
+
categories: ["app"],
|
|
943
|
+
type: "list",
|
|
944
|
+
itemType: "App",
|
|
945
|
+
inputSchema: ListAppsSchema,
|
|
946
|
+
outputSchema: AppItemSchema
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// src/utils/domain-utils.ts
|
|
954
|
+
function splitVersionedKey(versionedKey) {
|
|
955
|
+
const parts = versionedKey.split("@");
|
|
956
|
+
if (parts.length >= 2) {
|
|
957
|
+
const baseKey = parts[0];
|
|
958
|
+
const version = parts.slice(1).join("@");
|
|
959
|
+
return [baseKey, version];
|
|
960
|
+
}
|
|
961
|
+
return [versionedKey, void 0];
|
|
962
|
+
}
|
|
963
|
+
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
964
|
+
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
965
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
966
|
+
return {
|
|
967
|
+
...restOfImplementationMeta,
|
|
968
|
+
title: name,
|
|
969
|
+
key: selectedApi,
|
|
970
|
+
implementation_id: id,
|
|
971
|
+
version: appVersion
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
function normalizeActionItem(action) {
|
|
975
|
+
const { name, type, selected_api: selectedApi } = action;
|
|
976
|
+
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
977
|
+
return {
|
|
978
|
+
// Only include the fields we want - explicitly list them
|
|
979
|
+
id: action.id,
|
|
980
|
+
key: action.key,
|
|
981
|
+
description: action.description,
|
|
982
|
+
is_important: action.is_important,
|
|
983
|
+
is_hidden: action.is_hidden,
|
|
984
|
+
// Transformed fields
|
|
985
|
+
app_key: appKey,
|
|
986
|
+
app_version: appVersion,
|
|
987
|
+
action_type: type,
|
|
988
|
+
title: name,
|
|
989
|
+
// Map name to title
|
|
990
|
+
type: "action"
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
function isSlug(slug) {
|
|
994
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
995
|
+
}
|
|
996
|
+
function isSnakeCasedSlug(slug) {
|
|
997
|
+
if (slug.match(/^_[0-9]/)) {
|
|
998
|
+
slug = slug.slice(1);
|
|
999
|
+
}
|
|
1000
|
+
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1001
|
+
}
|
|
1002
|
+
function dashifySnakeCasedSlug(slug) {
|
|
1003
|
+
if (!isSnakeCasedSlug(slug)) {
|
|
1004
|
+
return slug;
|
|
1005
|
+
}
|
|
1006
|
+
if (slug.startsWith("_")) {
|
|
1007
|
+
slug = slug.slice(1);
|
|
1008
|
+
}
|
|
1009
|
+
return slug.replace(/_/g, "-");
|
|
1010
|
+
}
|
|
1011
|
+
function isUuid(appKey) {
|
|
1012
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1013
|
+
appKey
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
function toAppLocator(appKey) {
|
|
1017
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1018
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
1019
|
+
throw new Error(
|
|
1020
|
+
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1024
|
+
return {
|
|
1025
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
1026
|
+
slug,
|
|
1027
|
+
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1028
|
+
version
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
function isResolvedAppLocator(appLocator) {
|
|
1032
|
+
return !!appLocator.implementationName;
|
|
1033
|
+
}
|
|
1034
|
+
var ListActionsSchema = zod.z.object({
|
|
1035
|
+
appKey: AppKeyPropertySchema.describe(
|
|
1036
|
+
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
1037
|
+
),
|
|
1038
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
1039
|
+
"Filter actions by type"
|
|
901
1040
|
),
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
cursor: zod.z.string().optional().describe("
|
|
905
|
-
}).
|
|
906
|
-
// Normalize implementationIds to array
|
|
907
|
-
implementationIds: typeof data.implementationIds === "string" ? data.implementationIds === "" ? [] : data.implementationIds.split(",") : data.implementationIds ?? [],
|
|
908
|
-
search: data.search,
|
|
909
|
-
// Normalize pageSize to number
|
|
910
|
-
pageSize: typeof data.pageSize === "string" ? parseInt(data.pageSize, 10) : data.pageSize,
|
|
911
|
-
cursor: data.cursor
|
|
912
|
-
}));
|
|
1041
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
|
|
1042
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
1043
|
+
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
1044
|
+
}).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
|
|
913
1045
|
var NeedChoicesSchema = zod.z.object({
|
|
914
1046
|
key: zod.z.string().optional(),
|
|
915
1047
|
label: zod.z.string().optional(),
|
|
@@ -1025,34 +1157,6 @@ zod.z.object({
|
|
|
1025
1157
|
format: zod.z.string().optional(),
|
|
1026
1158
|
inputFormat: zod.z.array(zod.z.string()).optional()
|
|
1027
1159
|
});
|
|
1028
|
-
var AuthenticationSchema = zod.z.object({
|
|
1029
|
-
id: zod.z.number(),
|
|
1030
|
-
date: zod.z.string(),
|
|
1031
|
-
lastchanged: zod.z.string().optional(),
|
|
1032
|
-
account_id: zod.z.number(),
|
|
1033
|
-
customuser_id: zod.z.number().optional(),
|
|
1034
|
-
selected_api: zod.z.string(),
|
|
1035
|
-
destination_selected_api: zod.z.string().nullable().optional(),
|
|
1036
|
-
is_invite_only: zod.z.boolean(),
|
|
1037
|
-
is_private: zod.z.boolean(),
|
|
1038
|
-
shared_with_all: zod.z.boolean(),
|
|
1039
|
-
is_stale: zod.z.string().optional(),
|
|
1040
|
-
is_shared: zod.z.string().optional(),
|
|
1041
|
-
marked_stale_at: zod.z.string().nullable().optional(),
|
|
1042
|
-
label: zod.z.string().nullable().optional(),
|
|
1043
|
-
identifier: zod.z.string().nullable().optional(),
|
|
1044
|
-
title: zod.z.string().nullable().optional(),
|
|
1045
|
-
url: zod.z.string().optional(),
|
|
1046
|
-
groups: zod.z.string().optional(),
|
|
1047
|
-
members: zod.z.string().optional(),
|
|
1048
|
-
permissions: zod.z.record(zod.z.string(), zod.z.boolean()).optional()
|
|
1049
|
-
});
|
|
1050
|
-
zod.z.object({
|
|
1051
|
-
count: zod.z.number(),
|
|
1052
|
-
next: zod.z.string().nullable().optional(),
|
|
1053
|
-
previous: zod.z.string().nullable().optional(),
|
|
1054
|
-
results: zod.z.array(AuthenticationSchema)
|
|
1055
|
-
});
|
|
1056
1160
|
zod.z.object({
|
|
1057
1161
|
id: zod.z.number(),
|
|
1058
1162
|
code: zod.z.string(),
|
|
@@ -1085,479 +1189,157 @@ zod.z.object({
|
|
|
1085
1189
|
summary_schedule: zod.z.string(),
|
|
1086
1190
|
alert_triggers: zod.z.string(),
|
|
1087
1191
|
alert_actions: zod.z.string(),
|
|
1088
|
-
is_staff: zod.z.boolean(),
|
|
1089
|
-
is_zt_reviewer: zod.z.boolean(),
|
|
1090
|
-
is_high_value: zod.z.boolean(),
|
|
1091
|
-
is_temporary: zod.z.boolean(),
|
|
1092
|
-
banner_message: zod.z.string(),
|
|
1093
|
-
enable_totp_2fa: zod.z.boolean(),
|
|
1094
|
-
viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
|
|
1095
|
-
show_editor_migration_mesaging: zod.z.boolean(),
|
|
1096
|
-
switches: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
1097
|
-
organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
|
|
1098
|
-
primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
1099
|
-
has_active_zaps: zod.z.boolean(),
|
|
1100
|
-
has_google_sso: zod.z.boolean(),
|
|
1101
|
-
auth_realm: zod.z.string(),
|
|
1102
|
-
roles: zod.z.array(
|
|
1103
|
-
zod.z.object({
|
|
1104
|
-
account_id: zod.z.number(),
|
|
1105
|
-
role: zod.z.string()
|
|
1106
|
-
})
|
|
1107
|
-
)
|
|
1108
|
-
});
|
|
1109
|
-
zod.z.object({
|
|
1110
|
-
age_in_days: zod.z.string().optional(),
|
|
1111
|
-
api_docs_url: zod.z.string().nullable().optional(),
|
|
1112
|
-
app_profile_url: zod.z.string(),
|
|
1113
|
-
banner: zod.z.string().optional(),
|
|
1114
|
-
categories: zod.z.array(zod.z.string()).optional(),
|
|
1115
|
-
// Service category names
|
|
1116
|
-
canonical_id: zod.z.string().optional(),
|
|
1117
|
-
current_implementation_id: zod.z.string(),
|
|
1118
|
-
days_since_last_update: zod.z.string().optional(),
|
|
1119
|
-
description: zod.z.string(),
|
|
1120
|
-
external_url: zod.z.string(),
|
|
1121
|
-
hashtag: zod.z.string().optional(),
|
|
1122
|
-
id: zod.z.number().optional(),
|
|
1123
|
-
image: zod.z.string().optional(),
|
|
1124
|
-
images: zod.z.string().optional(),
|
|
1125
|
-
integration_overview_html: zod.z.string().nullable().optional(),
|
|
1126
|
-
internal_id: zod.z.string(),
|
|
1127
|
-
invite_url: zod.z.string().nullable().optional(),
|
|
1128
|
-
is_beta: zod.z.string().optional(),
|
|
1129
|
-
is_built_in: zod.z.string().optional(),
|
|
1130
|
-
is_featured: zod.z.string().optional(),
|
|
1131
|
-
is_premium: zod.z.boolean().optional(),
|
|
1132
|
-
is_public: zod.z.string().optional(),
|
|
1133
|
-
is_upcoming: zod.z.string().optional(),
|
|
1134
|
-
learn_more_url: zod.z.string(),
|
|
1135
|
-
name: zod.z.string(),
|
|
1136
|
-
popularity: zod.z.number(),
|
|
1137
|
-
primary_color: zod.z.string(),
|
|
1138
|
-
request_count: zod.z.string().optional(),
|
|
1139
|
-
slug: zod.z.string(),
|
|
1140
|
-
zap_usage_count: zod.z.number().nullable().optional()
|
|
1141
|
-
});
|
|
1142
|
-
var ServiceSchema = zod.z.object({
|
|
1143
|
-
id: zod.z.number().optional(),
|
|
1144
|
-
canonical_id: zod.z.string().optional(),
|
|
1145
|
-
current_implementation_id: zod.z.string(),
|
|
1146
|
-
name: zod.z.string(),
|
|
1147
|
-
slug: zod.z.string(),
|
|
1148
|
-
app_url: zod.z.string().optional(),
|
|
1149
|
-
learn_more_url: zod.z.string().optional(),
|
|
1150
|
-
description: zod.z.string(),
|
|
1151
|
-
primary_color: zod.z.string(),
|
|
1152
|
-
popularity: zod.z.number(),
|
|
1153
|
-
image: zod.z.string().optional(),
|
|
1154
|
-
images: zod.z.string().optional()
|
|
1155
|
-
});
|
|
1156
|
-
zod.z.object({
|
|
1157
|
-
results: zod.z.array(ServiceSchema),
|
|
1158
|
-
next: zod.z.string().nullable().optional(),
|
|
1159
|
-
previous: zod.z.string().nullable().optional()
|
|
1160
|
-
});
|
|
1161
|
-
zod.z.object({
|
|
1162
|
-
selected_api: zod.z.string(),
|
|
1163
|
-
action: zod.z.string(),
|
|
1164
|
-
type_of: zod.z.string(),
|
|
1165
|
-
authentication_id: zod.z.number().optional(),
|
|
1166
|
-
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1167
|
-
});
|
|
1168
|
-
zod.z.object({
|
|
1169
|
-
success: zod.z.boolean(),
|
|
1170
|
-
needs: zod.z.array(NeedSchema).optional(),
|
|
1171
|
-
errors: zod.z.array(zod.z.string()).optional(),
|
|
1172
|
-
last_fetched_at: zod.z.string().optional(),
|
|
1173
|
-
schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1174
|
-
});
|
|
1175
|
-
var ImplementationSchema = zod.z.object({
|
|
1176
|
-
selected_api: zod.z.string(),
|
|
1177
|
-
app_id: zod.z.number().optional(),
|
|
1178
|
-
auth_type: zod.z.string().optional(),
|
|
1179
|
-
auth_fields: zod.z.string().optional(),
|
|
1180
|
-
actions: zod.z.array(ActionSchema).optional(),
|
|
1181
|
-
is_deprecated: zod.z.boolean().optional(),
|
|
1182
|
-
is_private_only: zod.z.boolean().optional(),
|
|
1183
|
-
is_invite_only: zod.z.boolean().optional(),
|
|
1184
|
-
is_beta: zod.z.boolean().optional().default(false),
|
|
1185
|
-
is_premium: zod.z.boolean().optional().default(false),
|
|
1186
|
-
is_hidden: zod.z.string().optional(),
|
|
1187
|
-
name: zod.z.string().optional(),
|
|
1188
|
-
slug: zod.z.string().optional(),
|
|
1189
|
-
images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
|
|
1190
|
-
primary_color: zod.z.string().optional(),
|
|
1191
|
-
secondary_color: zod.z.string().optional(),
|
|
1192
|
-
current_implementation: zod.z.string().optional(),
|
|
1193
|
-
other_implementations: zod.z.string().optional()
|
|
1194
|
-
});
|
|
1195
|
-
zod.z.object({
|
|
1196
|
-
count: zod.z.number(),
|
|
1197
|
-
next: zod.z.string().nullable().optional(),
|
|
1198
|
-
previous: zod.z.string().nullable().optional(),
|
|
1199
|
-
results: zod.z.array(ImplementationSchema)
|
|
1200
|
-
});
|
|
1201
|
-
var
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
id: zod.z.number(),
|
|
1212
|
-
name: zod.z.string(),
|
|
1213
|
-
slug: zod.z.string()
|
|
1214
|
-
})
|
|
1215
|
-
).optional(),
|
|
1216
|
-
images: zod.z.object({
|
|
1217
|
-
url_16x16: zod.z.string().optional(),
|
|
1218
|
-
url_32x32: zod.z.string().optional(),
|
|
1219
|
-
url_64x64: zod.z.string().optional(),
|
|
1220
|
-
url_128x128: zod.z.string().optional()
|
|
1221
|
-
}).optional(),
|
|
1222
|
-
popularity: zod.z.number().optional(),
|
|
1223
|
-
has_filters: zod.z.boolean().optional(),
|
|
1224
|
-
has_reads: zod.z.boolean().optional(),
|
|
1225
|
-
has_searches: zod.z.boolean().optional(),
|
|
1226
|
-
has_searches_or_writes: zod.z.boolean().optional(),
|
|
1227
|
-
has_upfront_fields: zod.z.boolean().optional(),
|
|
1228
|
-
has_writes: zod.z.boolean().optional(),
|
|
1229
|
-
is_beta: zod.z.boolean().optional(),
|
|
1230
|
-
is_built_in: zod.z.boolean().optional(),
|
|
1231
|
-
is_deprecated: zod.z.boolean().optional(),
|
|
1232
|
-
is_featured: zod.z.boolean().optional(),
|
|
1233
|
-
is_hidden: zod.z.boolean().optional(),
|
|
1234
|
-
is_invite: zod.z.boolean().optional(),
|
|
1235
|
-
is_premium: zod.z.boolean().optional(),
|
|
1236
|
-
is_public: zod.z.boolean().optional(),
|
|
1237
|
-
is_upcoming: zod.z.boolean().optional(),
|
|
1238
|
-
version: zod.z.string().optional(),
|
|
1239
|
-
visibility: zod.z.string().optional(),
|
|
1240
|
-
actions: zod.z.object({
|
|
1241
|
-
read: zod.z.number().optional(),
|
|
1242
|
-
read_bulk: zod.z.number().optional(),
|
|
1243
|
-
write: zod.z.number().optional(),
|
|
1244
|
-
search: zod.z.number().optional(),
|
|
1245
|
-
search_or_write: zod.z.number().optional(),
|
|
1246
|
-
search_and_write: zod.z.number().optional(),
|
|
1247
|
-
filter: zod.z.number().optional()
|
|
1248
|
-
}).optional(),
|
|
1249
|
-
description: zod.z.string().optional(),
|
|
1250
|
-
primary_color: zod.z.string().optional(),
|
|
1251
|
-
secondary_color: zod.z.string().optional(),
|
|
1252
|
-
classification: zod.z.string().optional(),
|
|
1253
|
-
api_docs_url: zod.z.string().optional(),
|
|
1254
|
-
image: zod.z.string().optional()
|
|
1255
|
-
});
|
|
1256
|
-
zod.z.object({
|
|
1257
|
-
count: zod.z.number(),
|
|
1258
|
-
next: zod.z.string().nullable().optional(),
|
|
1259
|
-
previous: zod.z.string().nullable().optional(),
|
|
1260
|
-
results: zod.z.array(ImplementationMetaSchema2)
|
|
1261
|
-
});
|
|
1262
|
-
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
1263
|
-
page: zod.z.string().nullable().optional()
|
|
1264
|
-
});
|
|
1265
|
-
var NeedChoicesResponseLinksSchema = zod.z.object({
|
|
1266
|
-
next: zod.z.string().nullable().optional(),
|
|
1267
|
-
prev: zod.z.string().nullable().optional()
|
|
1268
|
-
});
|
|
1269
|
-
zod.z.object({
|
|
1270
|
-
selected_api: zod.z.string().optional().describe(
|
|
1271
|
-
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
|
|
1272
|
-
),
|
|
1273
|
-
authentication_id: zod.z.coerce.number().optional().describe(
|
|
1274
|
-
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
|
|
1275
|
-
),
|
|
1276
|
-
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
|
|
1277
|
-
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
|
|
1278
|
-
),
|
|
1279
|
-
page: zod.z.number().optional().default(0),
|
|
1280
|
-
prefill: zod.z.string().optional().describe(
|
|
1281
|
-
"The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
|
|
1282
|
-
),
|
|
1283
|
-
action_id: zod.z.string().optional().describe(
|
|
1284
|
-
"The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
|
|
1285
|
-
),
|
|
1286
|
-
input_field_id: zod.z.string().optional().describe(
|
|
1287
|
-
"The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
|
|
1288
|
-
)
|
|
1289
|
-
});
|
|
1290
|
-
zod.z.object({
|
|
1291
|
-
success: zod.z.boolean(),
|
|
1292
|
-
choices: zod.z.array(NeedChoicesSchema).optional(),
|
|
1293
|
-
next_page: zod.z.number().optional(),
|
|
1294
|
-
errors: zod.z.array(zod.z.string()).optional(),
|
|
1295
|
-
meta: NeedChoicesResponseMetaSchema.optional(),
|
|
1296
|
-
links: NeedChoicesResponseLinksSchema.optional()
|
|
1297
|
-
});
|
|
1298
|
-
|
|
1299
|
-
// src/utils/string-utils.ts
|
|
1300
|
-
function toTitleCase(input) {
|
|
1301
|
-
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1302
|
-
}
|
|
1303
|
-
function toSnakeCase(input) {
|
|
1304
|
-
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1305
|
-
if (/^[0-9]/.test(result)) {
|
|
1306
|
-
result = "_" + result;
|
|
1307
|
-
}
|
|
1308
|
-
return result;
|
|
1309
|
-
}
|
|
1310
|
-
function stripPageSuffix(functionName) {
|
|
1311
|
-
return functionName.replace(/Page$/, "");
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
// src/schemas/App.ts
|
|
1315
|
-
var AppItemSchema2 = withFormatter(
|
|
1316
|
-
ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
|
|
1317
|
-
title: zod.z.string(),
|
|
1318
|
-
// Mapped from name
|
|
1319
|
-
key: zod.z.string(),
|
|
1320
|
-
// Extracted from id (base part without version)
|
|
1321
|
-
implementation_id: zod.z.string()
|
|
1322
|
-
// Mapped from id (full versioned ID)
|
|
1323
|
-
}),
|
|
1324
|
-
{
|
|
1325
|
-
format: (item) => {
|
|
1326
|
-
const additionalKeys = [];
|
|
1327
|
-
if (item.slug && item.slug !== item.key) {
|
|
1328
|
-
additionalKeys.push(item.slug);
|
|
1329
|
-
const snakeCaseSlug = toSnakeCase(item.slug);
|
|
1330
|
-
if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
|
|
1331
|
-
additionalKeys.push(snakeCaseSlug);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
return {
|
|
1335
|
-
title: item.title,
|
|
1336
|
-
key: item.key,
|
|
1337
|
-
keys: [item.key, ...additionalKeys],
|
|
1338
|
-
description: item.description,
|
|
1339
|
-
details: []
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
);
|
|
1344
|
-
|
|
1345
|
-
// src/utils/telemetry-utils.ts
|
|
1346
|
-
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1347
|
-
return {
|
|
1348
|
-
onMethodCalled: (data) => {
|
|
1349
|
-
emitMethodCalled({
|
|
1350
|
-
method_name: methodName,
|
|
1351
|
-
execution_duration_ms: data.durationMs,
|
|
1352
|
-
success_flag: data.success,
|
|
1353
|
-
error_message: data.error?.message ?? null,
|
|
1354
|
-
error_type: data.error?.constructor.name ?? null,
|
|
1355
|
-
argument_count: data.argumentCount,
|
|
1356
|
-
is_paginated: data.isPaginated
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
// src/plugins/listApps/index.ts
|
|
1363
|
-
var listAppsPlugin = ({ context }) => {
|
|
1364
|
-
async function listAppsPage(options) {
|
|
1365
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1366
|
-
const appKeys = options.appKeys ?? [];
|
|
1367
|
-
const appLocators = await resolveAppKeys2({
|
|
1368
|
-
appKeys: [...appKeys]
|
|
1369
|
-
});
|
|
1370
|
-
const implementationNameToLocator = {};
|
|
1371
|
-
for (const locator of appLocators) {
|
|
1372
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
1373
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1374
|
-
locator
|
|
1375
|
-
];
|
|
1376
|
-
}
|
|
1377
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1378
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
1379
|
-
throw new Error(
|
|
1380
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1381
|
-
);
|
|
1382
|
-
}
|
|
1383
|
-
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
1384
|
-
return {
|
|
1385
|
-
data: [],
|
|
1386
|
-
nextCursor: void 0
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
const implementationIds = appLocators.map((locator) => {
|
|
1390
|
-
const version = locator.version || "latest";
|
|
1391
|
-
return `${locator.implementationName}@${version}`;
|
|
1392
|
-
});
|
|
1393
|
-
return await api.get("/api/v0/apps", {
|
|
1394
|
-
searchParams: {
|
|
1395
|
-
implementationIds: implementationIds.join(","),
|
|
1396
|
-
...options.search && { search: options.search },
|
|
1397
|
-
pageSize: options.pageSize.toString(),
|
|
1398
|
-
...options.cursor && { cursor: options.cursor }
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
}
|
|
1402
|
-
const methodName = stripPageSuffix(listAppsPage.name);
|
|
1403
|
-
const listAppsDefinition = createPaginatedFunction(
|
|
1404
|
-
listAppsPage,
|
|
1405
|
-
ListAppsOptionsSchema,
|
|
1406
|
-
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1407
|
-
methodName
|
|
1408
|
-
);
|
|
1409
|
-
return {
|
|
1410
|
-
listApps: listAppsDefinition,
|
|
1411
|
-
context: {
|
|
1412
|
-
meta: {
|
|
1413
|
-
listApps: {
|
|
1414
|
-
categories: ["app"],
|
|
1415
|
-
type: "list",
|
|
1416
|
-
itemType: "App",
|
|
1417
|
-
inputSchema: ListAppsOptionsSchema,
|
|
1418
|
-
outputSchema: AppItemSchema2
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
|
-
// src/utils/domain-utils.ts
|
|
1426
|
-
function splitVersionedKey(versionedKey) {
|
|
1427
|
-
const parts = versionedKey.split("@");
|
|
1428
|
-
if (parts.length >= 2) {
|
|
1429
|
-
const baseKey = parts[0];
|
|
1430
|
-
const version = parts.slice(1).join("@");
|
|
1431
|
-
return [baseKey, version];
|
|
1432
|
-
}
|
|
1433
|
-
return [versionedKey, void 0];
|
|
1434
|
-
}
|
|
1435
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
1436
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1437
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1438
|
-
return {
|
|
1439
|
-
...restOfImplementationMeta,
|
|
1440
|
-
title: name,
|
|
1441
|
-
key: selectedApi,
|
|
1442
|
-
implementation_id: id,
|
|
1443
|
-
version: appVersion
|
|
1444
|
-
};
|
|
1445
|
-
}
|
|
1446
|
-
function normalizeAuthenticationItem(auth, options = {}) {
|
|
1447
|
-
let appKey = options.app_key;
|
|
1448
|
-
let appVersion = options.app_version;
|
|
1449
|
-
if (auth.selected_api) {
|
|
1450
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
1451
|
-
auth.selected_api
|
|
1452
|
-
);
|
|
1453
|
-
if (!appKey) {
|
|
1454
|
-
appKey = extractedAppKey;
|
|
1455
|
-
}
|
|
1456
|
-
if (!appVersion) {
|
|
1457
|
-
appVersion = extractedVersion;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
const {
|
|
1461
|
-
selected_api: selectedApi,
|
|
1462
|
-
customuser_id: profileId,
|
|
1463
|
-
id,
|
|
1464
|
-
account_id: accountId,
|
|
1465
|
-
...restOfAuth
|
|
1466
|
-
} = auth;
|
|
1467
|
-
return {
|
|
1468
|
-
...restOfAuth,
|
|
1469
|
-
// Pass through all other API response fields except selected_api
|
|
1470
|
-
id: String(id),
|
|
1471
|
-
// Convert to string
|
|
1472
|
-
account_id: String(accountId),
|
|
1473
|
-
// Convert to string
|
|
1474
|
-
implementation_id: selectedApi,
|
|
1475
|
-
// Rename selected_api to implementation_id
|
|
1476
|
-
title: auth.title || auth.label || void 0,
|
|
1477
|
-
// Coerce title from label if missing
|
|
1478
|
-
is_expired: auth.is_stale,
|
|
1479
|
-
// Map is_stale to is_expired
|
|
1480
|
-
expired_at: auth.marked_stale_at,
|
|
1481
|
-
// Map marked_stale_at to expired_at
|
|
1482
|
-
app_key: appKey,
|
|
1483
|
-
// App key from implementations endpoint or parsed from selected_api
|
|
1484
|
-
app_version: appVersion,
|
|
1485
|
-
// Version from selected_api or provided
|
|
1486
|
-
profile_id: profileId != null ? String(profileId) : void 0
|
|
1487
|
-
// Map customuser_id to profile_id, convert to string
|
|
1488
|
-
};
|
|
1489
|
-
}
|
|
1490
|
-
function normalizeActionItem(action) {
|
|
1491
|
-
const { name, type, selected_api: selectedApi } = action;
|
|
1492
|
-
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
1493
|
-
return {
|
|
1494
|
-
// Only include the fields we want - explicitly list them
|
|
1495
|
-
id: action.id,
|
|
1496
|
-
key: action.key,
|
|
1497
|
-
description: action.description,
|
|
1498
|
-
is_important: action.is_important,
|
|
1499
|
-
is_hidden: action.is_hidden,
|
|
1500
|
-
// Transformed fields
|
|
1501
|
-
app_key: appKey,
|
|
1502
|
-
app_version: appVersion,
|
|
1503
|
-
action_type: type,
|
|
1504
|
-
title: name,
|
|
1505
|
-
// Map name to title
|
|
1506
|
-
type: "action"
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
function isSlug(slug) {
|
|
1510
|
-
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
1511
|
-
}
|
|
1512
|
-
function isSnakeCasedSlug(slug) {
|
|
1513
|
-
if (slug.match(/^_[0-9]/)) {
|
|
1514
|
-
slug = slug.slice(1);
|
|
1515
|
-
}
|
|
1516
|
-
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1517
|
-
}
|
|
1518
|
-
function dashifySnakeCasedSlug(slug) {
|
|
1519
|
-
if (!isSnakeCasedSlug(slug)) {
|
|
1520
|
-
return slug;
|
|
1521
|
-
}
|
|
1522
|
-
if (slug.startsWith("_")) {
|
|
1523
|
-
slug = slug.slice(1);
|
|
1524
|
-
}
|
|
1525
|
-
return slug.replace(/_/g, "-");
|
|
1526
|
-
}
|
|
1527
|
-
function isUuid(appKey) {
|
|
1528
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1529
|
-
appKey
|
|
1530
|
-
);
|
|
1531
|
-
}
|
|
1532
|
-
function toAppLocator(appKey) {
|
|
1533
|
-
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1534
|
-
if (isUuid(appKeyWithoutVersion)) {
|
|
1535
|
-
throw new Error(
|
|
1536
|
-
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1537
|
-
);
|
|
1538
|
-
}
|
|
1539
|
-
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1540
|
-
return {
|
|
1541
|
-
lookupAppKey: appKeyWithoutVersion,
|
|
1542
|
-
slug,
|
|
1543
|
-
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1544
|
-
version
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
function isResolvedAppLocator(appLocator) {
|
|
1548
|
-
return !!appLocator.implementationName;
|
|
1549
|
-
}
|
|
1550
|
-
var ListActionsSchema = zod.z.object({
|
|
1551
|
-
appKey: AppKeyPropertySchema.describe(
|
|
1552
|
-
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
1192
|
+
is_staff: zod.z.boolean(),
|
|
1193
|
+
is_zt_reviewer: zod.z.boolean(),
|
|
1194
|
+
is_high_value: zod.z.boolean(),
|
|
1195
|
+
is_temporary: zod.z.boolean(),
|
|
1196
|
+
banner_message: zod.z.string(),
|
|
1197
|
+
enable_totp_2fa: zod.z.boolean(),
|
|
1198
|
+
viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
|
|
1199
|
+
show_editor_migration_mesaging: zod.z.boolean(),
|
|
1200
|
+
switches: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
1201
|
+
organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
|
|
1202
|
+
primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
1203
|
+
has_active_zaps: zod.z.boolean(),
|
|
1204
|
+
has_google_sso: zod.z.boolean(),
|
|
1205
|
+
auth_realm: zod.z.string(),
|
|
1206
|
+
roles: zod.z.array(
|
|
1207
|
+
zod.z.object({
|
|
1208
|
+
account_id: zod.z.number(),
|
|
1209
|
+
role: zod.z.string()
|
|
1210
|
+
})
|
|
1211
|
+
)
|
|
1212
|
+
});
|
|
1213
|
+
zod.z.object({
|
|
1214
|
+
age_in_days: zod.z.string().optional(),
|
|
1215
|
+
api_docs_url: zod.z.string().nullable().optional(),
|
|
1216
|
+
app_profile_url: zod.z.string(),
|
|
1217
|
+
banner: zod.z.string().optional(),
|
|
1218
|
+
categories: zod.z.array(zod.z.string()).optional(),
|
|
1219
|
+
// Service category names
|
|
1220
|
+
canonical_id: zod.z.string().optional(),
|
|
1221
|
+
current_implementation_id: zod.z.string(),
|
|
1222
|
+
days_since_last_update: zod.z.string().optional(),
|
|
1223
|
+
description: zod.z.string(),
|
|
1224
|
+
external_url: zod.z.string(),
|
|
1225
|
+
hashtag: zod.z.string().optional(),
|
|
1226
|
+
id: zod.z.number().optional(),
|
|
1227
|
+
image: zod.z.string().optional(),
|
|
1228
|
+
images: zod.z.string().optional(),
|
|
1229
|
+
integration_overview_html: zod.z.string().nullable().optional(),
|
|
1230
|
+
internal_id: zod.z.string(),
|
|
1231
|
+
invite_url: zod.z.string().nullable().optional(),
|
|
1232
|
+
is_beta: zod.z.string().optional(),
|
|
1233
|
+
is_built_in: zod.z.string().optional(),
|
|
1234
|
+
is_featured: zod.z.string().optional(),
|
|
1235
|
+
is_premium: zod.z.boolean().optional(),
|
|
1236
|
+
is_public: zod.z.string().optional(),
|
|
1237
|
+
is_upcoming: zod.z.string().optional(),
|
|
1238
|
+
learn_more_url: zod.z.string(),
|
|
1239
|
+
name: zod.z.string(),
|
|
1240
|
+
popularity: zod.z.number(),
|
|
1241
|
+
primary_color: zod.z.string(),
|
|
1242
|
+
request_count: zod.z.string().optional(),
|
|
1243
|
+
slug: zod.z.string(),
|
|
1244
|
+
zap_usage_count: zod.z.number().nullable().optional()
|
|
1245
|
+
});
|
|
1246
|
+
var ServiceSchema = zod.z.object({
|
|
1247
|
+
id: zod.z.number().optional(),
|
|
1248
|
+
canonical_id: zod.z.string().optional(),
|
|
1249
|
+
current_implementation_id: zod.z.string(),
|
|
1250
|
+
name: zod.z.string(),
|
|
1251
|
+
slug: zod.z.string(),
|
|
1252
|
+
app_url: zod.z.string().optional(),
|
|
1253
|
+
learn_more_url: zod.z.string().optional(),
|
|
1254
|
+
description: zod.z.string(),
|
|
1255
|
+
primary_color: zod.z.string(),
|
|
1256
|
+
popularity: zod.z.number(),
|
|
1257
|
+
image: zod.z.string().optional(),
|
|
1258
|
+
images: zod.z.string().optional()
|
|
1259
|
+
});
|
|
1260
|
+
zod.z.object({
|
|
1261
|
+
results: zod.z.array(ServiceSchema),
|
|
1262
|
+
next: zod.z.string().nullable().optional(),
|
|
1263
|
+
previous: zod.z.string().nullable().optional()
|
|
1264
|
+
});
|
|
1265
|
+
zod.z.object({
|
|
1266
|
+
selected_api: zod.z.string(),
|
|
1267
|
+
action: zod.z.string(),
|
|
1268
|
+
type_of: zod.z.string(),
|
|
1269
|
+
authentication_id: zod.z.number().optional(),
|
|
1270
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1271
|
+
});
|
|
1272
|
+
zod.z.object({
|
|
1273
|
+
success: zod.z.boolean(),
|
|
1274
|
+
needs: zod.z.array(NeedSchema).optional(),
|
|
1275
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
1276
|
+
last_fetched_at: zod.z.string().optional(),
|
|
1277
|
+
schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1278
|
+
});
|
|
1279
|
+
var ImplementationSchema = zod.z.object({
|
|
1280
|
+
selected_api: zod.z.string(),
|
|
1281
|
+
app_id: zod.z.number().optional(),
|
|
1282
|
+
auth_type: zod.z.string().optional(),
|
|
1283
|
+
auth_fields: zod.z.string().optional(),
|
|
1284
|
+
actions: zod.z.array(ActionSchema).optional(),
|
|
1285
|
+
is_deprecated: zod.z.boolean().optional(),
|
|
1286
|
+
is_private_only: zod.z.boolean().optional(),
|
|
1287
|
+
is_invite_only: zod.z.boolean().optional(),
|
|
1288
|
+
is_beta: zod.z.boolean().optional().default(false),
|
|
1289
|
+
is_premium: zod.z.boolean().optional().default(false),
|
|
1290
|
+
is_hidden: zod.z.string().optional(),
|
|
1291
|
+
name: zod.z.string().optional(),
|
|
1292
|
+
slug: zod.z.string().optional(),
|
|
1293
|
+
images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
|
|
1294
|
+
primary_color: zod.z.string().optional(),
|
|
1295
|
+
secondary_color: zod.z.string().optional(),
|
|
1296
|
+
current_implementation: zod.z.string().optional(),
|
|
1297
|
+
other_implementations: zod.z.string().optional()
|
|
1298
|
+
});
|
|
1299
|
+
zod.z.object({
|
|
1300
|
+
count: zod.z.number(),
|
|
1301
|
+
next: zod.z.string().nullable().optional(),
|
|
1302
|
+
previous: zod.z.string().nullable().optional(),
|
|
1303
|
+
results: zod.z.array(ImplementationSchema)
|
|
1304
|
+
});
|
|
1305
|
+
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
1306
|
+
page: zod.z.string().nullable().optional()
|
|
1307
|
+
});
|
|
1308
|
+
var NeedChoicesResponseLinksSchema = zod.z.object({
|
|
1309
|
+
next: zod.z.string().nullable().optional(),
|
|
1310
|
+
prev: zod.z.string().nullable().optional()
|
|
1311
|
+
});
|
|
1312
|
+
zod.z.object({
|
|
1313
|
+
selected_api: zod.z.string().optional().describe(
|
|
1314
|
+
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
|
|
1553
1315
|
),
|
|
1554
|
-
|
|
1555
|
-
"
|
|
1316
|
+
authentication_id: zod.z.coerce.number().optional().describe(
|
|
1317
|
+
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
|
|
1556
1318
|
),
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1319
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
|
|
1320
|
+
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
|
|
1321
|
+
),
|
|
1322
|
+
page: zod.z.number().optional().default(0),
|
|
1323
|
+
prefill: zod.z.string().optional().describe(
|
|
1324
|
+
"The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
|
|
1325
|
+
),
|
|
1326
|
+
action_id: zod.z.string().optional().describe(
|
|
1327
|
+
"The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
|
|
1328
|
+
),
|
|
1329
|
+
input_field_id: zod.z.string().optional().describe(
|
|
1330
|
+
"The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
|
|
1331
|
+
)
|
|
1332
|
+
});
|
|
1333
|
+
zod.z.object({
|
|
1334
|
+
success: zod.z.boolean(),
|
|
1335
|
+
choices: zod.z.array(NeedChoicesSchema).optional(),
|
|
1336
|
+
next_page: zod.z.number().optional(),
|
|
1337
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
1338
|
+
meta: NeedChoicesResponseMetaSchema.optional(),
|
|
1339
|
+
links: NeedChoicesResponseLinksSchema.optional()
|
|
1340
|
+
});
|
|
1341
|
+
|
|
1342
|
+
// src/schemas/Action.ts
|
|
1561
1343
|
var ActionItemSchema = withFormatter(
|
|
1562
1344
|
ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
|
|
1563
1345
|
app_key: zod.z.string(),
|
|
@@ -2248,19 +2030,22 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
2248
2030
|
}
|
|
2249
2031
|
};
|
|
2250
2032
|
};
|
|
2251
|
-
var
|
|
2033
|
+
var ListAuthenticationsQuerySchema = authentications.ListAuthenticationsQuerySchema.omit(
|
|
2034
|
+
{
|
|
2035
|
+
offset: true
|
|
2036
|
+
}
|
|
2037
|
+
).extend({
|
|
2038
|
+
// Override appKey with our custom schema (array type, different description)
|
|
2252
2039
|
appKey: AppKeyPropertySchema.optional().describe(
|
|
2253
2040
|
"App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
2254
2041
|
),
|
|
2042
|
+
// Override authenticationIds to be an array instead of comma-separated string
|
|
2255
2043
|
authenticationIds: zod.z.array(zod.z.string()).optional().describe("List of authentication IDs to filter by"),
|
|
2256
|
-
|
|
2257
|
-
title: zod.z.string().optional().describe("Filter authentications by exact title match"),
|
|
2258
|
-
accountId: zod.z.string().optional().describe("Filter by account ID"),
|
|
2259
|
-
owner: zod.z.union([zod.z.string(), zod.z.literal("me")]).optional().describe(
|
|
2260
|
-
"Filter by owner, 'me' for your own authentications or a specific user ID"
|
|
2261
|
-
),
|
|
2044
|
+
// Override pageSize to make optional (needs to be fixed in `zapier-sdk-core`)
|
|
2262
2045
|
pageSize: zod.z.number().min(1).optional().describe("Number of authentications per page"),
|
|
2046
|
+
// SDK specific property for pagination/iterator helpers
|
|
2263
2047
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
2048
|
+
// SDK specific property for pagination/iterator helpers
|
|
2264
2049
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
2265
2050
|
}).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
|
|
2266
2051
|
var AuthenticationItemSchema = withFormatter(
|
|
@@ -2297,36 +2082,38 @@ var AuthenticationItemSchema = withFormatter(
|
|
|
2297
2082
|
var listAuthenticationsPlugin = ({ context }) => {
|
|
2298
2083
|
async function listAuthenticationsPage(options) {
|
|
2299
2084
|
const { api, getVersionedImplementationId } = context;
|
|
2300
|
-
const searchParams = {
|
|
2085
|
+
const searchParams = {
|
|
2086
|
+
pageSize: options.pageSize.toString()
|
|
2087
|
+
};
|
|
2301
2088
|
if (options.appKey) {
|
|
2302
2089
|
const implementationId = await getVersionedImplementationId(
|
|
2303
2090
|
options.appKey
|
|
2304
2091
|
);
|
|
2305
2092
|
if (implementationId) {
|
|
2306
2093
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2307
|
-
searchParams.
|
|
2094
|
+
searchParams.appKey = versionlessSelectedApi;
|
|
2308
2095
|
}
|
|
2309
2096
|
}
|
|
2310
2097
|
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
2311
|
-
searchParams.
|
|
2098
|
+
searchParams.authenticationIds = options.authenticationIds.join(",");
|
|
2312
2099
|
}
|
|
2313
2100
|
if (options.search) {
|
|
2314
2101
|
searchParams.search = options.search;
|
|
2315
|
-
}
|
|
2316
|
-
|
|
2102
|
+
}
|
|
2103
|
+
if (options.title) {
|
|
2104
|
+
searchParams.title = options.title;
|
|
2317
2105
|
}
|
|
2318
2106
|
if (options.accountId) {
|
|
2319
|
-
searchParams.
|
|
2107
|
+
searchParams.accountId = options.accountId;
|
|
2320
2108
|
}
|
|
2321
2109
|
if (options.owner) {
|
|
2322
2110
|
searchParams.owner = options.owner;
|
|
2323
2111
|
}
|
|
2324
|
-
searchParams.limit = options.pageSize.toString();
|
|
2325
2112
|
if (options.cursor) {
|
|
2326
2113
|
searchParams.offset = options.cursor;
|
|
2327
2114
|
}
|
|
2328
|
-
const
|
|
2329
|
-
"/
|
|
2115
|
+
const response = await api.get(
|
|
2116
|
+
"/api/v0/authentications",
|
|
2330
2117
|
{
|
|
2331
2118
|
searchParams,
|
|
2332
2119
|
customErrorHandler: ({ status }) => {
|
|
@@ -2347,23 +2134,12 @@ var listAuthenticationsPlugin = ({ context }) => {
|
|
|
2347
2134
|
authRequired: true
|
|
2348
2135
|
}
|
|
2349
2136
|
);
|
|
2350
|
-
|
|
2351
|
-
(auth) => normalizeAuthenticationItem(auth)
|
|
2352
|
-
);
|
|
2353
|
-
if (options.title) {
|
|
2354
|
-
auths = auths.filter(
|
|
2355
|
-
(auth) => auth.title === options.title
|
|
2356
|
-
);
|
|
2357
|
-
}
|
|
2358
|
-
return {
|
|
2359
|
-
data: auths,
|
|
2360
|
-
nextCursor: extractCursor(data)
|
|
2361
|
-
};
|
|
2137
|
+
return response;
|
|
2362
2138
|
}
|
|
2363
2139
|
const methodName = stripPageSuffix(listAuthenticationsPage.name);
|
|
2364
2140
|
const listAuthenticationsDefinition = createPaginatedFunction(
|
|
2365
2141
|
listAuthenticationsPage,
|
|
2366
|
-
|
|
2142
|
+
ListAuthenticationsQuerySchema,
|
|
2367
2143
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2368
2144
|
methodName
|
|
2369
2145
|
);
|
|
@@ -2375,7 +2151,7 @@ var listAuthenticationsPlugin = ({ context }) => {
|
|
|
2375
2151
|
categories: ["authentication"],
|
|
2376
2152
|
type: "list",
|
|
2377
2153
|
itemType: "Authentication",
|
|
2378
|
-
inputSchema:
|
|
2154
|
+
inputSchema: ListAuthenticationsQuerySchema,
|
|
2379
2155
|
outputSchema: AuthenticationItemSchema,
|
|
2380
2156
|
resolvers: {
|
|
2381
2157
|
appKey: appKeyResolver
|
|
@@ -2424,7 +2200,7 @@ var getAppPlugin = ({ sdk, context }) => {
|
|
|
2424
2200
|
type: "item",
|
|
2425
2201
|
itemType: "App",
|
|
2426
2202
|
inputSchema: GetAppSchema,
|
|
2427
|
-
outputSchema:
|
|
2203
|
+
outputSchema: AppItemSchema,
|
|
2428
2204
|
resolvers: {
|
|
2429
2205
|
appKey: appKeyResolver
|
|
2430
2206
|
}
|
|
@@ -3767,176 +3543,6 @@ function getTrackingBaseUrl({
|
|
|
3767
3543
|
return ZAPIER_BASE_URL;
|
|
3768
3544
|
}
|
|
3769
3545
|
|
|
3770
|
-
// src/temporary-internal-core/utils/string-utils.ts
|
|
3771
|
-
function splitVersionedKey2(versionedKey) {
|
|
3772
|
-
const parts = versionedKey.split("@");
|
|
3773
|
-
if (parts.length >= 2) {
|
|
3774
|
-
const baseKey = parts[0];
|
|
3775
|
-
const version = parts.slice(1).join("@");
|
|
3776
|
-
return [baseKey, version];
|
|
3777
|
-
}
|
|
3778
|
-
return [versionedKey, void 0];
|
|
3779
|
-
}
|
|
3780
|
-
|
|
3781
|
-
// src/temporary-internal-core/utils/transformations.ts
|
|
3782
|
-
function transformImplementationMetaToAppItem(implementationMeta) {
|
|
3783
|
-
const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
|
|
3784
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
3785
|
-
return {
|
|
3786
|
-
...restOfImplementationMeta,
|
|
3787
|
-
title: name,
|
|
3788
|
-
key: selectedApi,
|
|
3789
|
-
implementation_id: id,
|
|
3790
|
-
version: appVersion
|
|
3791
|
-
};
|
|
3792
|
-
}
|
|
3793
|
-
function extractPaginationCursor(response) {
|
|
3794
|
-
if (!response.next) {
|
|
3795
|
-
return void 0;
|
|
3796
|
-
}
|
|
3797
|
-
try {
|
|
3798
|
-
const url = new URL(response.next);
|
|
3799
|
-
const offset = url.searchParams.get("offset");
|
|
3800
|
-
return offset || void 0;
|
|
3801
|
-
} catch {
|
|
3802
|
-
return void 0;
|
|
3803
|
-
}
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
// src/temporary-internal-core/handlers/listApps.ts
|
|
3807
|
-
var DEFAULT_PAGE_SIZE = 20;
|
|
3808
|
-
async function augmentWithSearchResults({
|
|
3809
|
-
searchTerm,
|
|
3810
|
-
implementationIds,
|
|
3811
|
-
httpClient
|
|
3812
|
-
}) {
|
|
3813
|
-
const searchResponse = await httpClient.get(
|
|
3814
|
-
"/zapier/api/v4/implementations-meta/search/",
|
|
3815
|
-
{
|
|
3816
|
-
searchParams: { term: searchTerm }
|
|
3817
|
-
}
|
|
3818
|
-
);
|
|
3819
|
-
const byImplementationName = /* @__PURE__ */ new Map();
|
|
3820
|
-
for (const result of searchResponse.results) {
|
|
3821
|
-
const [implementationName] = splitVersionedKey2(result.id);
|
|
3822
|
-
const isPublic = result.visibility === "public";
|
|
3823
|
-
const existing = byImplementationName.get(implementationName);
|
|
3824
|
-
if (!existing || isPublic && !existing.isPublic) {
|
|
3825
|
-
byImplementationName.set(implementationName, { result, isPublic });
|
|
3826
|
-
}
|
|
3827
|
-
}
|
|
3828
|
-
const searchResults = Array.from(byImplementationName.values()).map(
|
|
3829
|
-
(entry) => transformImplementationMetaToAppItem(entry.result)
|
|
3830
|
-
);
|
|
3831
|
-
const implementationNameSet = new Set(
|
|
3832
|
-
implementationIds.map((id) => {
|
|
3833
|
-
const [name] = splitVersionedKey2(id);
|
|
3834
|
-
return name;
|
|
3835
|
-
})
|
|
3836
|
-
);
|
|
3837
|
-
const additionalIds = [];
|
|
3838
|
-
for (const result of searchResults) {
|
|
3839
|
-
const [implementationName] = splitVersionedKey2(result.key);
|
|
3840
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
3841
|
-
implementationNameSet.add(implementationName);
|
|
3842
|
-
additionalIds.push(result.implementation_id);
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
return [...implementationIds, ...additionalIds];
|
|
3846
|
-
}
|
|
3847
|
-
var handleListApps = async ({ request, deps }) => {
|
|
3848
|
-
const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
|
|
3849
|
-
const { httpClient } = deps;
|
|
3850
|
-
let { implementationIds } = validatedRequest;
|
|
3851
|
-
const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
3852
|
-
if (validatedRequest.search) {
|
|
3853
|
-
implementationIds = await augmentWithSearchResults({
|
|
3854
|
-
searchTerm: validatedRequest.search,
|
|
3855
|
-
implementationIds,
|
|
3856
|
-
httpClient
|
|
3857
|
-
});
|
|
3858
|
-
}
|
|
3859
|
-
if (implementationIds.length === 0) {
|
|
3860
|
-
if (validatedRequest.search) {
|
|
3861
|
-
return {
|
|
3862
|
-
data: [],
|
|
3863
|
-
nextCursor: void 0
|
|
3864
|
-
};
|
|
3865
|
-
}
|
|
3866
|
-
const searchParams2 = {
|
|
3867
|
-
latest_only: "true",
|
|
3868
|
-
selected_apis: "",
|
|
3869
|
-
limit: pageSize.toString()
|
|
3870
|
-
};
|
|
3871
|
-
if (validatedRequest.cursor) {
|
|
3872
|
-
searchParams2.offset = validatedRequest.cursor;
|
|
3873
|
-
}
|
|
3874
|
-
const implementationsResponse2 = await httpClient.get(
|
|
3875
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3876
|
-
{
|
|
3877
|
-
searchParams: searchParams2
|
|
3878
|
-
}
|
|
3879
|
-
);
|
|
3880
|
-
return {
|
|
3881
|
-
data: implementationsResponse2.results.map(
|
|
3882
|
-
transformImplementationMetaToAppItem
|
|
3883
|
-
),
|
|
3884
|
-
nextCursor: extractPaginationCursor(implementationsResponse2)
|
|
3885
|
-
};
|
|
3886
|
-
}
|
|
3887
|
-
const searchParams = {
|
|
3888
|
-
selected_apis: implementationIds.join(","),
|
|
3889
|
-
limit: pageSize.toString()
|
|
3890
|
-
};
|
|
3891
|
-
if (validatedRequest.cursor) {
|
|
3892
|
-
searchParams.offset = validatedRequest.cursor;
|
|
3893
|
-
}
|
|
3894
|
-
const implementationsResponse = await httpClient.get(
|
|
3895
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3896
|
-
{
|
|
3897
|
-
searchParams
|
|
3898
|
-
}
|
|
3899
|
-
);
|
|
3900
|
-
return {
|
|
3901
|
-
data: implementationsResponse.results.map(
|
|
3902
|
-
transformImplementationMetaToAppItem
|
|
3903
|
-
),
|
|
3904
|
-
nextCursor: extractPaginationCursor(implementationsResponse)
|
|
3905
|
-
};
|
|
3906
|
-
};
|
|
3907
|
-
|
|
3908
|
-
// src/api/router.ts
|
|
3909
|
-
var routes = [
|
|
3910
|
-
{
|
|
3911
|
-
method: "GET",
|
|
3912
|
-
pattern: /^\/api\/v0\/apps$/,
|
|
3913
|
-
handler: handleListApps,
|
|
3914
|
-
paramMap: []
|
|
3915
|
-
}
|
|
3916
|
-
];
|
|
3917
|
-
function findMatchingRoute(routeList, method, path) {
|
|
3918
|
-
for (const route of routeList) {
|
|
3919
|
-
if (route.method !== method) {
|
|
3920
|
-
continue;
|
|
3921
|
-
}
|
|
3922
|
-
const match = path.match(route.pattern);
|
|
3923
|
-
if (match) {
|
|
3924
|
-
const params = {};
|
|
3925
|
-
route.paramMap.forEach((name, index) => {
|
|
3926
|
-
params[name] = match[index + 1];
|
|
3927
|
-
});
|
|
3928
|
-
return {
|
|
3929
|
-
handler: route.handler,
|
|
3930
|
-
params
|
|
3931
|
-
};
|
|
3932
|
-
}
|
|
3933
|
-
}
|
|
3934
|
-
return null;
|
|
3935
|
-
}
|
|
3936
|
-
function matchRoute(method, path) {
|
|
3937
|
-
return findMatchingRoute(routes, method, path);
|
|
3938
|
-
}
|
|
3939
|
-
|
|
3940
3546
|
// src/api/client.ts
|
|
3941
3547
|
var pathConfig = {
|
|
3942
3548
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -4185,20 +3791,6 @@ var ZapierApiClient = class {
|
|
|
4185
3791
|
}
|
|
4186
3792
|
// Helper to perform HTTP requests with JSON handling
|
|
4187
3793
|
async fetchJson(method, path, data, options = {}) {
|
|
4188
|
-
const routeMatch = matchRoute(method, path);
|
|
4189
|
-
if (routeMatch) {
|
|
4190
|
-
const handlerRequest = {
|
|
4191
|
-
...typeof data === "object" ? data : {},
|
|
4192
|
-
...options.searchParams,
|
|
4193
|
-
...routeMatch.params
|
|
4194
|
-
};
|
|
4195
|
-
return routeMatch.handler({
|
|
4196
|
-
request: handlerRequest,
|
|
4197
|
-
deps: {
|
|
4198
|
-
httpClient: this
|
|
4199
|
-
}
|
|
4200
|
-
});
|
|
4201
|
-
}
|
|
4202
3794
|
const headers = { ...options.headers };
|
|
4203
3795
|
if (data && typeof data === "object") {
|
|
4204
3796
|
headers["Content-Type"] = "application/json";
|
|
@@ -4881,7 +4473,7 @@ function getCpuTime() {
|
|
|
4881
4473
|
|
|
4882
4474
|
// package.json
|
|
4883
4475
|
var package_default = {
|
|
4884
|
-
version: "0.18.
|
|
4476
|
+
version: "0.18.4"};
|
|
4885
4477
|
|
|
4886
4478
|
// src/plugins/eventEmission/builders.ts
|
|
4887
4479
|
function createBaseEvent(context = {}) {
|