@zapier/zapier-sdk 0.9.0 → 0.11.0
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 +18 -0
- package/README.md +7 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +14 -0
- package/dist/api/debug.d.ts +1 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +42 -1
- package/dist/api/debug.test.d.ts +2 -0
- package/dist/api/debug.test.d.ts.map +1 -0
- package/dist/api/debug.test.js +59 -0
- package/dist/api/schemas.d.ts +451 -251
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +51 -29
- package/dist/index.cjs +968 -582
- package/dist/index.d.mts +2537 -2229
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.mjs +966 -576
- package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +9 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +4 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +10 -0
- package/dist/plugins/getAction/schemas.d.ts +5 -3
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -0
- package/dist/plugins/getApp/index.test.js +2 -2
- package/dist/plugins/getApp/schemas.d.ts +3 -1
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/schemas.js +2 -4
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +8 -0
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +4 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +9 -0
- package/dist/plugins/listActions/schemas.d.ts +5 -3
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -0
- package/dist/plugins/listApps/index.test.js +1 -1
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +3 -9
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +8 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +14 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
- package/dist/plugins/listInputFields/index.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +71 -5
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +8 -6
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +8 -2
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -0
- package/dist/plugins/runAction/schemas.d.ts +5 -3
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/resolvers/actionKey.d.ts +13 -7
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +8 -7
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/appKey.d.ts +2 -6
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.d.ts +7 -7
- package/dist/resolvers/authenticationId.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.js +16 -7
- package/dist/resolvers/index.d.ts +3 -35
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +4 -87
- package/dist/resolvers/inputFieldKey.d.ts +11 -0
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
- package/dist/resolvers/inputFieldKey.js +47 -0
- package/dist/resolvers/inputs.d.ts +13 -4
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +36 -0
- package/dist/schemas/Action.d.ts +8 -8
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +8 -3
- package/dist/schemas/App.d.ts +183 -11
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +7 -9
- package/dist/schemas/Auth.d.ts +12 -12
- package/dist/schemas/Auth.js +1 -1
- package/dist/schemas/Field.d.ts +112 -97
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +63 -52
- package/dist/schemas/Run.d.ts +3 -0
- package/dist/schemas/Run.d.ts.map +1 -0
- package/dist/schemas/Run.js +31 -0
- package/dist/schemas/UserProfile.d.ts +11 -11
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +21 -7
- package/dist/sdk.d.ts +11 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/domain.d.ts +17 -1
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +5 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +3 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +5 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +1 -16
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +7 -51
- package/dist/utils/schema-utils.d.ts +44 -21
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/dist/utils/schema-utils.js +17 -11
- package/dist/utils/string-utils.d.ts +12 -0
- package/dist/utils/string-utils.d.ts.map +1 -0
- package/dist/utils/string-utils.js +23 -0
- package/dist/utils/string-utils.test.d.ts +2 -0
- package/dist/utils/string-utils.test.d.ts.map +1 -0
- package/dist/utils/string-utils.test.js +36 -0
- package/package.json +1 -1
- package/src/api/client.ts +12 -0
- package/src/api/debug.test.ts +76 -0
- package/src/api/debug.ts +46 -2
- package/src/api/schemas.ts +51 -29
- package/src/index.ts +4 -5
- package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
- package/src/plugins/findFirstAuthentication/index.ts +14 -2
- package/src/plugins/findUniqueAuthentication/index.ts +4 -0
- package/src/plugins/getAction/index.ts +14 -0
- package/src/plugins/getApp/index.test.ts +2 -2
- package/src/plugins/getApp/index.ts +8 -0
- package/src/plugins/getApp/schemas.ts +7 -12
- package/src/plugins/getAuthentication/index.ts +8 -0
- package/src/plugins/getProfile/index.ts +4 -0
- package/src/plugins/getProfile/schemas.ts +4 -6
- package/src/plugins/listActions/index.ts +9 -0
- package/src/plugins/listActions/schemas.ts +20 -25
- package/src/plugins/listApps/index.test.ts +1 -1
- package/src/plugins/listApps/index.ts +4 -0
- package/src/plugins/listApps/schemas.ts +17 -26
- package/src/plugins/listAuthentications/index.ts +8 -0
- package/src/plugins/listInputFieldChoices/index.ts +21 -1
- package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
- package/src/plugins/listInputFields/index.test.ts +5 -9
- package/src/plugins/listInputFields/index.ts +89 -11
- package/src/plugins/listInputFields/schemas.ts +6 -3
- package/src/plugins/registry/index.ts +8 -2
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.ts +18 -0
- package/src/resolvers/actionKey.ts +15 -13
- package/src/resolvers/actionType.ts +10 -12
- package/src/resolvers/appKey.ts +2 -6
- package/src/resolvers/authenticationId.ts +25 -19
- package/src/resolvers/index.ts +7 -113
- package/src/resolvers/inputFieldKey.ts +70 -0
- package/src/resolvers/inputs.ts +51 -7
- package/src/schemas/Action.ts +8 -3
- package/src/schemas/App.ts +7 -9
- package/src/schemas/Auth.ts +1 -1
- package/src/schemas/Field.ts +97 -60
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +17 -7
- package/src/types/domain.ts +24 -1
- package/src/types/plugin.ts +5 -0
- package/src/types/sdk.ts +5 -0
- package/src/utils/domain-utils.ts +9 -67
- package/src/utils/schema-utils.ts +96 -44
- package/src/utils/string-utils.test.ts +45 -0
- package/src/utils/string-utils.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,19 +5,22 @@ var promises = require('timers/promises');
|
|
|
5
5
|
|
|
6
6
|
// src/types/properties.ts
|
|
7
7
|
function withFormatter(schema, formatMeta) {
|
|
8
|
-
schema._def
|
|
8
|
+
Object.assign(schema._def, {
|
|
9
|
+
formatMeta
|
|
10
|
+
});
|
|
9
11
|
return schema;
|
|
10
12
|
}
|
|
11
|
-
function withOutputSchema(inputSchema, outputSchema) {
|
|
12
|
-
inputSchema._def.outputSchema = outputSchema;
|
|
13
|
-
return inputSchema;
|
|
14
|
-
}
|
|
15
13
|
function withPositional(schema) {
|
|
16
|
-
schema._def
|
|
14
|
+
Object.assign(schema._def, {
|
|
15
|
+
positionalMeta: { positional: true }
|
|
16
|
+
});
|
|
17
17
|
return schema;
|
|
18
18
|
}
|
|
19
|
+
function schemaHasPositionalMeta(schema) {
|
|
20
|
+
return "positionalMeta" in schema._def;
|
|
21
|
+
}
|
|
19
22
|
function isPositional(schema) {
|
|
20
|
-
if (schema._def.positionalMeta?.positional) {
|
|
23
|
+
if (schemaHasPositionalMeta(schema) && schema._def.positionalMeta?.positional) {
|
|
21
24
|
return true;
|
|
22
25
|
}
|
|
23
26
|
if (schema instanceof zod.z.ZodOptional) {
|
|
@@ -604,243 +607,14 @@ function createPaginatedFunction(coreFn, schema) {
|
|
|
604
607
|
};
|
|
605
608
|
return namedFunctions[functionName];
|
|
606
609
|
}
|
|
607
|
-
var
|
|
608
|
-
zod.z.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
// From id, keeps the full version
|
|
616
|
-
version: zod.z.string().optional(),
|
|
617
|
-
// Extracted from implementation ID
|
|
618
|
-
description: zod.z.string().optional(),
|
|
619
|
-
slug: zod.z.string().optional()
|
|
620
|
-
}),
|
|
621
|
-
{
|
|
622
|
-
format: (item) => {
|
|
623
|
-
return {
|
|
624
|
-
title: item.title,
|
|
625
|
-
subtitle: `(${item.key})`,
|
|
626
|
-
details: []
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
);
|
|
631
|
-
|
|
632
|
-
// src/plugins/listApps/schemas.ts
|
|
633
|
-
var ListAppsSchema = withOutputSchema(
|
|
634
|
-
zod.z.object({
|
|
635
|
-
appKeys: zod.z.array(zod.z.string()).optional().describe(
|
|
636
|
-
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
637
|
-
),
|
|
638
|
-
search: zod.z.string().optional().describe("Search for apps by name"),
|
|
639
|
-
pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
|
|
640
|
-
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
641
|
-
}).describe("List all available apps with optional filtering"),
|
|
642
|
-
AppItemSchema
|
|
643
|
-
);
|
|
644
|
-
|
|
645
|
-
// src/utils/domain-utils.ts
|
|
646
|
-
function splitVersionedKey(versionedKey) {
|
|
647
|
-
const parts = versionedKey.split("@");
|
|
648
|
-
if (parts.length >= 2) {
|
|
649
|
-
const baseKey = parts[0];
|
|
650
|
-
const version = parts.slice(1).join("@");
|
|
651
|
-
return [baseKey, version];
|
|
652
|
-
}
|
|
653
|
-
return [versionedKey, void 0];
|
|
654
|
-
}
|
|
655
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
656
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
657
|
-
return {
|
|
658
|
-
title: implementationMeta.name,
|
|
659
|
-
key: selectedApi,
|
|
660
|
-
current_implementation_id: implementationMeta.id,
|
|
661
|
-
// Keep the full versioned ID
|
|
662
|
-
version: appVersion,
|
|
663
|
-
// Extract version separately
|
|
664
|
-
slug: implementationMeta.slug
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
function normalizeAuthenticationItem(auth, options = {}) {
|
|
668
|
-
let appKey = options.app_key;
|
|
669
|
-
let version = options.version;
|
|
670
|
-
if (auth.selected_api) {
|
|
671
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
672
|
-
auth.selected_api
|
|
673
|
-
);
|
|
674
|
-
if (!appKey) {
|
|
675
|
-
appKey = extractedAppKey;
|
|
676
|
-
}
|
|
677
|
-
if (!version) {
|
|
678
|
-
version = extractedVersion;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
const {
|
|
682
|
-
selected_api: selectedApi,
|
|
683
|
-
customuser_id: userId,
|
|
684
|
-
...restOfAuth
|
|
685
|
-
} = auth;
|
|
686
|
-
return {
|
|
687
|
-
...restOfAuth,
|
|
688
|
-
// Pass through all other API response fields except selected_api
|
|
689
|
-
implementation_id: selectedApi,
|
|
690
|
-
// Rename selected_api to implementation_id
|
|
691
|
-
title: auth.title || auth.label || void 0,
|
|
692
|
-
// Coerce title from label if missing
|
|
693
|
-
is_expired: auth.is_stale,
|
|
694
|
-
// Map is_stale to is_expired
|
|
695
|
-
expired_at: auth.marked_stale_at,
|
|
696
|
-
// Map marked_stale_at to expired_at
|
|
697
|
-
app_key: appKey,
|
|
698
|
-
// App key from implementations endpoint or parsed from selected_api
|
|
699
|
-
version,
|
|
700
|
-
// Version from selected_api or provided
|
|
701
|
-
user_id: userId
|
|
702
|
-
// Map customuser_id to user_id
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
function normalizeActionItem(action) {
|
|
706
|
-
const { name, type, selected_api: appKey, ...restOfAction } = action;
|
|
707
|
-
return {
|
|
708
|
-
...restOfAction,
|
|
709
|
-
app_key: appKey || "",
|
|
710
|
-
action_type: type,
|
|
711
|
-
title: name,
|
|
712
|
-
// Map name to title
|
|
713
|
-
type: "action"
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
function isSlug(slug) {
|
|
717
|
-
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
718
|
-
}
|
|
719
|
-
function isSnakeCasedSlug(slug) {
|
|
720
|
-
if (slug.match(/^_[0-9]/)) {
|
|
721
|
-
slug = slug.slice(1);
|
|
722
|
-
}
|
|
723
|
-
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
724
|
-
}
|
|
725
|
-
function dashifySnakeCasedSlug(slug) {
|
|
726
|
-
if (!isSnakeCasedSlug(slug)) {
|
|
727
|
-
return slug;
|
|
728
|
-
}
|
|
729
|
-
if (slug.startsWith("_")) {
|
|
730
|
-
slug = slug.slice(1);
|
|
731
|
-
}
|
|
732
|
-
return slug.replace(/_/g, "-");
|
|
733
|
-
}
|
|
734
|
-
function isUuid(appKey) {
|
|
735
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
736
|
-
appKey
|
|
737
|
-
);
|
|
738
|
-
}
|
|
739
|
-
function toAppLocator(appKey) {
|
|
740
|
-
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
741
|
-
if (isUuid(appKeyWithoutVersion)) {
|
|
742
|
-
throw new Error(
|
|
743
|
-
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
747
|
-
return {
|
|
748
|
-
lookupAppKey: appKeyWithoutVersion,
|
|
749
|
-
slug,
|
|
750
|
-
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
751
|
-
version
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function isResolvedAppLocator(appLocator) {
|
|
755
|
-
return !!appLocator.implementationName;
|
|
756
|
-
}
|
|
757
|
-
function toImplementationId(appLocator) {
|
|
758
|
-
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// src/plugins/listApps/index.ts
|
|
762
|
-
var listAppsPlugin = ({ context }) => {
|
|
763
|
-
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
764
|
-
const api = context.api;
|
|
765
|
-
const opts = options;
|
|
766
|
-
const appLocators = await context.resolveAppKeys({
|
|
767
|
-
appKeys: [...opts.appKeys ?? []]
|
|
768
|
-
});
|
|
769
|
-
const implementationNameToLocator = {};
|
|
770
|
-
for (const locator of appLocators) {
|
|
771
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
772
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
773
|
-
locator
|
|
774
|
-
];
|
|
775
|
-
}
|
|
776
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
777
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
778
|
-
throw new Error(
|
|
779
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
if (opts.search) {
|
|
783
|
-
const searchParams2 = {};
|
|
784
|
-
searchParams2.term = opts.search;
|
|
785
|
-
const searchEnvelope = await api.get(
|
|
786
|
-
"/api/v4/implementations-meta/search/",
|
|
787
|
-
{
|
|
788
|
-
searchParams: searchParams2
|
|
789
|
-
}
|
|
790
|
-
);
|
|
791
|
-
const implementations = searchEnvelope.results.map(
|
|
792
|
-
normalizeImplementationMetaToAppItem
|
|
793
|
-
);
|
|
794
|
-
const implementationNameSet = new Set(
|
|
795
|
-
appLocators.map((locator) => locator.implementationName)
|
|
796
|
-
);
|
|
797
|
-
for (const implementation of implementations) {
|
|
798
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
799
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
800
|
-
implementationNameSet.add(implementationName);
|
|
801
|
-
appLocators.push({
|
|
802
|
-
...toAppLocator(implementation.key),
|
|
803
|
-
implementationName
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
const searchParams = {};
|
|
809
|
-
if (opts.pageSize) {
|
|
810
|
-
searchParams.limit = opts.pageSize.toString();
|
|
811
|
-
}
|
|
812
|
-
if (appLocators.length === 0) {
|
|
813
|
-
searchParams.latest_only = "true";
|
|
814
|
-
}
|
|
815
|
-
if (opts.cursor) {
|
|
816
|
-
searchParams.offset = opts.cursor;
|
|
817
|
-
}
|
|
818
|
-
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
819
|
-
const implementationsEnvelope = await api.get(
|
|
820
|
-
"/api/v4/implementations-meta/lookup/",
|
|
821
|
-
{
|
|
822
|
-
searchParams
|
|
823
|
-
}
|
|
824
|
-
);
|
|
825
|
-
return {
|
|
826
|
-
data: implementationsEnvelope.results.map(
|
|
827
|
-
normalizeImplementationMetaToAppItem
|
|
828
|
-
),
|
|
829
|
-
nextCursor: extractCursor(implementationsEnvelope)
|
|
830
|
-
};
|
|
831
|
-
}, ListAppsSchema);
|
|
832
|
-
return {
|
|
833
|
-
listApps,
|
|
834
|
-
context: {
|
|
835
|
-
meta: {
|
|
836
|
-
listApps: {
|
|
837
|
-
categories: ["app"],
|
|
838
|
-
inputSchema: ListAppsSchema
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
};
|
|
610
|
+
var ListAppsSchema = zod.z.object({
|
|
611
|
+
appKeys: zod.z.array(zod.z.string()).optional().describe(
|
|
612
|
+
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
613
|
+
),
|
|
614
|
+
search: zod.z.string().optional().describe("Search for apps by name"),
|
|
615
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
|
|
616
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
617
|
+
}).describe("List all available apps with optional filtering");
|
|
844
618
|
var NeedChoicesSchema = zod.z.object({
|
|
845
619
|
key: zod.z.string().optional(),
|
|
846
620
|
label: zod.z.string().optional(),
|
|
@@ -940,7 +714,7 @@ zod.z.object({
|
|
|
940
714
|
choices: zod.z.array(ChoiceSchema).optional()
|
|
941
715
|
});
|
|
942
716
|
zod.z.object({
|
|
943
|
-
data: zod.z.array(zod.z.
|
|
717
|
+
data: zod.z.array(zod.z.unknown())
|
|
944
718
|
});
|
|
945
719
|
var ActionFieldChoiceSchema = zod.z.object({
|
|
946
720
|
value: zod.z.union([zod.z.string(), zod.z.number()]),
|
|
@@ -1030,9 +804,9 @@ var UserProfileSchema = zod.z.object({
|
|
|
1030
804
|
enable_totp_2fa: zod.z.boolean(),
|
|
1031
805
|
viewed_help: zod.z.record(zod.z.boolean()),
|
|
1032
806
|
show_editor_migration_mesaging: zod.z.boolean(),
|
|
1033
|
-
switches: zod.z.record(zod.z.
|
|
1034
|
-
organizations: zod.z.array(zod.z.
|
|
1035
|
-
primary_organization: zod.z.
|
|
807
|
+
switches: zod.z.record(zod.z.unknown()),
|
|
808
|
+
organizations: zod.z.array(zod.z.record(zod.z.unknown()).nullable()),
|
|
809
|
+
primary_organization: zod.z.record(zod.z.unknown()).nullable(),
|
|
1036
810
|
has_active_zaps: zod.z.boolean(),
|
|
1037
811
|
has_google_sso: zod.z.boolean(),
|
|
1038
812
|
auth_realm: zod.z.string(),
|
|
@@ -1048,8 +822,8 @@ zod.z.object({
|
|
|
1048
822
|
api_docs_url: zod.z.string().nullable().optional(),
|
|
1049
823
|
app_profile_url: zod.z.string(),
|
|
1050
824
|
banner: zod.z.string().optional(),
|
|
1051
|
-
categories: zod.z.array(zod.z.
|
|
1052
|
-
//
|
|
825
|
+
categories: zod.z.array(zod.z.string()).optional(),
|
|
826
|
+
// Service category names
|
|
1053
827
|
canonical_id: zod.z.string().optional(),
|
|
1054
828
|
current_implementation_id: zod.z.string(),
|
|
1055
829
|
days_since_last_update: zod.z.string().optional(),
|
|
@@ -1100,7 +874,7 @@ zod.z.object({
|
|
|
1100
874
|
action: zod.z.string(),
|
|
1101
875
|
type_of: zod.z.string(),
|
|
1102
876
|
authentication_id: zod.z.number().optional(),
|
|
1103
|
-
params: zod.z.record(zod.z.
|
|
877
|
+
params: zod.z.record(zod.z.unknown()).optional()
|
|
1104
878
|
});
|
|
1105
879
|
zod.z.object({
|
|
1106
880
|
success: zod.z.boolean(),
|
|
@@ -1136,18 +910,11 @@ zod.z.object({
|
|
|
1136
910
|
});
|
|
1137
911
|
var ImplementationMetaSchema = zod.z.object({
|
|
1138
912
|
id: zod.z.string(),
|
|
1139
|
-
// e.g. "
|
|
913
|
+
// e.g. "100HiresCLIAPI@1.2.1"
|
|
1140
914
|
name: zod.z.string(),
|
|
1141
915
|
slug: zod.z.string(),
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
url_32x32: zod.z.string().optional(),
|
|
1145
|
-
url_64x64: zod.z.string().optional(),
|
|
1146
|
-
url_128x128: zod.z.string().optional()
|
|
1147
|
-
}).optional(),
|
|
1148
|
-
// Include other fields for completeness but we'll only use what we need
|
|
1149
|
-
ageInDays: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
1150
|
-
authType: zod.z.string().nullable().optional(),
|
|
916
|
+
age_in_days: zod.z.number().optional(),
|
|
917
|
+
auth_type: zod.z.string().optional(),
|
|
1151
918
|
banner: zod.z.string().optional(),
|
|
1152
919
|
categories: zod.z.array(
|
|
1153
920
|
zod.z.object({
|
|
@@ -1156,18 +923,45 @@ var ImplementationMetaSchema = zod.z.object({
|
|
|
1156
923
|
slug: zod.z.string()
|
|
1157
924
|
})
|
|
1158
925
|
).optional(),
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
isPremium: zod.z.boolean().optional(),
|
|
1166
|
-
isPublic: zod.z.boolean().optional(),
|
|
1167
|
-
isUpcoming: zod.z.boolean().optional(),
|
|
926
|
+
images: zod.z.object({
|
|
927
|
+
url_16x16: zod.z.string().optional(),
|
|
928
|
+
url_32x32: zod.z.string().optional(),
|
|
929
|
+
url_64x64: zod.z.string().optional(),
|
|
930
|
+
url_128x128: zod.z.string().optional()
|
|
931
|
+
}).optional(),
|
|
1168
932
|
popularity: zod.z.number().optional(),
|
|
1169
|
-
|
|
1170
|
-
|
|
933
|
+
has_filters: zod.z.boolean().optional(),
|
|
934
|
+
has_reads: zod.z.boolean().optional(),
|
|
935
|
+
has_searches: zod.z.boolean().optional(),
|
|
936
|
+
has_searches_or_writes: zod.z.boolean().optional(),
|
|
937
|
+
has_upfront_fields: zod.z.boolean().optional(),
|
|
938
|
+
has_writes: zod.z.boolean().optional(),
|
|
939
|
+
is_beta: zod.z.boolean().optional(),
|
|
940
|
+
is_built_in: zod.z.boolean().optional(),
|
|
941
|
+
is_deprecated: zod.z.boolean().optional(),
|
|
942
|
+
is_featured: zod.z.boolean().optional(),
|
|
943
|
+
is_hidden: zod.z.boolean().optional(),
|
|
944
|
+
is_invite: zod.z.boolean().optional(),
|
|
945
|
+
is_premium: zod.z.boolean().optional(),
|
|
946
|
+
is_public: zod.z.boolean().optional(),
|
|
947
|
+
is_upcoming: zod.z.boolean().optional(),
|
|
948
|
+
version: zod.z.string().optional(),
|
|
949
|
+
visibility: zod.z.string().optional(),
|
|
950
|
+
actions: zod.z.object({
|
|
951
|
+
read: zod.z.number().optional(),
|
|
952
|
+
read_bulk: zod.z.number().optional(),
|
|
953
|
+
write: zod.z.number().optional(),
|
|
954
|
+
search: zod.z.number().optional(),
|
|
955
|
+
search_or_write: zod.z.number().optional(),
|
|
956
|
+
search_and_write: zod.z.number().optional(),
|
|
957
|
+
filter: zod.z.number().optional()
|
|
958
|
+
}).optional(),
|
|
959
|
+
description: zod.z.string().optional(),
|
|
960
|
+
primary_color: zod.z.string().optional(),
|
|
961
|
+
secondary_color: zod.z.string().optional(),
|
|
962
|
+
classification: zod.z.string().optional(),
|
|
963
|
+
api_docs_url: zod.z.string().optional(),
|
|
964
|
+
image: zod.z.string().optional()
|
|
1171
965
|
});
|
|
1172
966
|
zod.z.object({
|
|
1173
967
|
count: zod.z.number(),
|
|
@@ -1189,7 +983,7 @@ zod.z.object({
|
|
|
1189
983
|
authentication_id: zod.z.number().optional().describe(
|
|
1190
984
|
"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)."
|
|
1191
985
|
),
|
|
1192
|
-
params: zod.z.record(zod.z.
|
|
986
|
+
params: zod.z.record(zod.z.unknown()).optional().describe(
|
|
1193
987
|
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
|
|
1194
988
|
),
|
|
1195
989
|
page: zod.z.number().optional().default(0),
|
|
@@ -1212,25 +1006,261 @@ zod.z.object({
|
|
|
1212
1006
|
links: NeedChoicesResponseLinksSchema.optional()
|
|
1213
1007
|
});
|
|
1214
1008
|
|
|
1215
|
-
// src/schemas/
|
|
1216
|
-
var
|
|
1217
|
-
|
|
1218
|
-
app_key: zod.z.string(),
|
|
1219
|
-
// Mapped from selected_api
|
|
1220
|
-
action_type: ActionSchema.shape.type,
|
|
1221
|
-
// Mapped from original 'type' field
|
|
1009
|
+
// src/schemas/App.ts
|
|
1010
|
+
var AppItemSchema = withFormatter(
|
|
1011
|
+
ImplementationMetaSchema.omit({ name: true, id: true }).extend({
|
|
1222
1012
|
title: zod.z.string(),
|
|
1223
|
-
// Mapped from
|
|
1224
|
-
|
|
1225
|
-
//
|
|
1013
|
+
// Mapped from name
|
|
1014
|
+
key: zod.z.string(),
|
|
1015
|
+
// Extracted from id (base part without version)
|
|
1016
|
+
implementation_id: zod.z.string()
|
|
1017
|
+
// Mapped from id (full versioned ID)
|
|
1226
1018
|
}),
|
|
1227
1019
|
{
|
|
1228
1020
|
format: (item) => {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1021
|
+
return {
|
|
1022
|
+
title: item.title,
|
|
1023
|
+
key: item.key,
|
|
1024
|
+
description: item.description,
|
|
1025
|
+
details: []
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
);
|
|
1030
|
+
|
|
1031
|
+
// src/utils/domain-utils.ts
|
|
1032
|
+
function splitVersionedKey(versionedKey) {
|
|
1033
|
+
const parts = versionedKey.split("@");
|
|
1034
|
+
if (parts.length >= 2) {
|
|
1035
|
+
const baseKey = parts[0];
|
|
1036
|
+
const version = parts.slice(1).join("@");
|
|
1037
|
+
return [baseKey, version];
|
|
1038
|
+
}
|
|
1039
|
+
return [versionedKey, void 0];
|
|
1040
|
+
}
|
|
1041
|
+
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
1042
|
+
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1043
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1044
|
+
return {
|
|
1045
|
+
// Pass through all ImplementationMeta fields except id and name
|
|
1046
|
+
...restOfImplementationMeta,
|
|
1047
|
+
// Transform key fields
|
|
1048
|
+
title: name,
|
|
1049
|
+
key: selectedApi,
|
|
1050
|
+
implementation_id: id,
|
|
1051
|
+
// Keep the full versioned ID
|
|
1052
|
+
version: appVersion
|
|
1053
|
+
// Extract version separately
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
function normalizeAuthenticationItem(auth, options = {}) {
|
|
1057
|
+
let appKey = options.app_key;
|
|
1058
|
+
let version = options.version;
|
|
1059
|
+
if (auth.selected_api) {
|
|
1060
|
+
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
1061
|
+
auth.selected_api
|
|
1062
|
+
);
|
|
1063
|
+
if (!appKey) {
|
|
1064
|
+
appKey = extractedAppKey;
|
|
1065
|
+
}
|
|
1066
|
+
if (!version) {
|
|
1067
|
+
version = extractedVersion;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
const {
|
|
1071
|
+
selected_api: selectedApi,
|
|
1072
|
+
customuser_id: userId,
|
|
1073
|
+
...restOfAuth
|
|
1074
|
+
} = auth;
|
|
1075
|
+
return {
|
|
1076
|
+
...restOfAuth,
|
|
1077
|
+
// Pass through all other API response fields except selected_api
|
|
1078
|
+
implementation_id: selectedApi,
|
|
1079
|
+
// Rename selected_api to implementation_id
|
|
1080
|
+
title: auth.title || auth.label || void 0,
|
|
1081
|
+
// Coerce title from label if missing
|
|
1082
|
+
is_expired: auth.is_stale,
|
|
1083
|
+
// Map is_stale to is_expired
|
|
1084
|
+
expired_at: auth.marked_stale_at,
|
|
1085
|
+
// Map marked_stale_at to expired_at
|
|
1086
|
+
app_key: appKey,
|
|
1087
|
+
// App key from implementations endpoint or parsed from selected_api
|
|
1088
|
+
version,
|
|
1089
|
+
// Version from selected_api or provided
|
|
1090
|
+
user_id: userId
|
|
1091
|
+
// Map customuser_id to user_id
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function normalizeActionItem(action) {
|
|
1095
|
+
const { name, type, selected_api: appKey, ...restOfAction } = action;
|
|
1096
|
+
return {
|
|
1097
|
+
...restOfAction,
|
|
1098
|
+
app_key: appKey || "",
|
|
1099
|
+
action_type: type,
|
|
1100
|
+
title: name,
|
|
1101
|
+
// Map name to title
|
|
1102
|
+
type: "action"
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function isSlug(slug) {
|
|
1106
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
1107
|
+
}
|
|
1108
|
+
function isSnakeCasedSlug(slug) {
|
|
1109
|
+
if (slug.match(/^_[0-9]/)) {
|
|
1110
|
+
slug = slug.slice(1);
|
|
1111
|
+
}
|
|
1112
|
+
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1113
|
+
}
|
|
1114
|
+
function dashifySnakeCasedSlug(slug) {
|
|
1115
|
+
if (!isSnakeCasedSlug(slug)) {
|
|
1116
|
+
return slug;
|
|
1117
|
+
}
|
|
1118
|
+
if (slug.startsWith("_")) {
|
|
1119
|
+
slug = slug.slice(1);
|
|
1120
|
+
}
|
|
1121
|
+
return slug.replace(/_/g, "-");
|
|
1122
|
+
}
|
|
1123
|
+
function isUuid(appKey) {
|
|
1124
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1125
|
+
appKey
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
function toAppLocator(appKey) {
|
|
1129
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1130
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1135
|
+
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1136
|
+
return {
|
|
1137
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
1138
|
+
slug,
|
|
1139
|
+
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1140
|
+
version
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
function isResolvedAppLocator(appLocator) {
|
|
1144
|
+
return !!appLocator.implementationName;
|
|
1145
|
+
}
|
|
1146
|
+
function toImplementationId(appLocator) {
|
|
1147
|
+
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// src/plugins/listApps/index.ts
|
|
1151
|
+
var listAppsPlugin = ({ context }) => {
|
|
1152
|
+
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1153
|
+
const api = context.api;
|
|
1154
|
+
const opts = options;
|
|
1155
|
+
const appLocators = await context.resolveAppKeys({
|
|
1156
|
+
appKeys: [...opts.appKeys ?? []]
|
|
1157
|
+
});
|
|
1158
|
+
const implementationNameToLocator = {};
|
|
1159
|
+
for (const locator of appLocators) {
|
|
1160
|
+
implementationNameToLocator[locator.implementationName] = [
|
|
1161
|
+
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1162
|
+
locator
|
|
1163
|
+
];
|
|
1164
|
+
}
|
|
1165
|
+
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1166
|
+
if (duplicatedLookupAppKeys.length > 0) {
|
|
1167
|
+
throw new Error(
|
|
1168
|
+
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
if (opts.search) {
|
|
1172
|
+
const searchParams2 = {};
|
|
1173
|
+
searchParams2.term = opts.search;
|
|
1174
|
+
const searchEnvelope = await api.get(
|
|
1175
|
+
"/api/v4/implementations-meta/search/",
|
|
1176
|
+
{
|
|
1177
|
+
searchParams: searchParams2
|
|
1178
|
+
}
|
|
1179
|
+
);
|
|
1180
|
+
const implementations = searchEnvelope.results.map(
|
|
1181
|
+
normalizeImplementationMetaToAppItem
|
|
1182
|
+
);
|
|
1183
|
+
const implementationNameSet = new Set(
|
|
1184
|
+
appLocators.map((locator) => locator.implementationName)
|
|
1185
|
+
);
|
|
1186
|
+
for (const implementation of implementations) {
|
|
1187
|
+
const [implementationName] = splitVersionedKey(implementation.key);
|
|
1188
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
1189
|
+
implementationNameSet.add(implementationName);
|
|
1190
|
+
appLocators.push({
|
|
1191
|
+
...toAppLocator(implementation.key),
|
|
1192
|
+
implementationName
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
const searchParams = {};
|
|
1198
|
+
if (opts.pageSize) {
|
|
1199
|
+
searchParams.limit = opts.pageSize.toString();
|
|
1200
|
+
}
|
|
1201
|
+
if (appLocators.length === 0) {
|
|
1202
|
+
searchParams.latest_only = "true";
|
|
1203
|
+
}
|
|
1204
|
+
if (opts.cursor) {
|
|
1205
|
+
searchParams.offset = opts.cursor;
|
|
1206
|
+
}
|
|
1207
|
+
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
1208
|
+
const implementationsEnvelope = await api.get(
|
|
1209
|
+
"/api/v4/implementations-meta/lookup/",
|
|
1210
|
+
{
|
|
1211
|
+
searchParams
|
|
1212
|
+
}
|
|
1213
|
+
);
|
|
1214
|
+
return {
|
|
1215
|
+
data: implementationsEnvelope.results.map(
|
|
1216
|
+
normalizeImplementationMetaToAppItem
|
|
1217
|
+
),
|
|
1218
|
+
nextCursor: extractCursor(implementationsEnvelope)
|
|
1219
|
+
};
|
|
1220
|
+
}, ListAppsSchema);
|
|
1221
|
+
return {
|
|
1222
|
+
listApps,
|
|
1223
|
+
context: {
|
|
1224
|
+
meta: {
|
|
1225
|
+
listApps: {
|
|
1226
|
+
categories: ["app"],
|
|
1227
|
+
type: "list",
|
|
1228
|
+
itemType: "App",
|
|
1229
|
+
inputSchema: ListAppsSchema,
|
|
1230
|
+
outputSchema: AppItemSchema
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
};
|
|
1236
|
+
var ListActionsSchema = zod.z.object({
|
|
1237
|
+
appKey: AppKeyPropertySchema.describe(
|
|
1238
|
+
"App key of actions to list (e.g., 'SlackCLIAPI')"
|
|
1239
|
+
),
|
|
1240
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
1241
|
+
"Filter actions by type"
|
|
1242
|
+
),
|
|
1243
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
|
|
1244
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1245
|
+
}).describe("List all actions for a specific app");
|
|
1246
|
+
var ActionItemSchema = withFormatter(
|
|
1247
|
+
ActionSchema.omit({ type: true, name: true }).extend({
|
|
1248
|
+
app_key: zod.z.string(),
|
|
1249
|
+
// Mapped from selected_api
|
|
1250
|
+
action_type: ActionSchema.shape.type,
|
|
1251
|
+
// Mapped from original 'type' field
|
|
1252
|
+
title: zod.z.string(),
|
|
1253
|
+
// Mapped from original 'name' field
|
|
1254
|
+
type: zod.z.literal("action")
|
|
1255
|
+
// Fixed type identifier
|
|
1256
|
+
}),
|
|
1257
|
+
{
|
|
1258
|
+
format: (item) => {
|
|
1259
|
+
const details = [];
|
|
1260
|
+
details.push({
|
|
1261
|
+
text: `Type: ${item.action_type}`,
|
|
1262
|
+
style: "accent"
|
|
1263
|
+
});
|
|
1234
1264
|
if (item.app_key) {
|
|
1235
1265
|
details.push({
|
|
1236
1266
|
text: `App: ${item.app_key}`,
|
|
@@ -1238,31 +1268,208 @@ var ActionItemSchema = withFormatter(
|
|
|
1238
1268
|
});
|
|
1239
1269
|
}
|
|
1240
1270
|
if (item.description) {
|
|
1241
|
-
details.push({
|
|
1271
|
+
details.push({
|
|
1272
|
+
text: item.description,
|
|
1273
|
+
style: "dim"
|
|
1274
|
+
});
|
|
1242
1275
|
}
|
|
1243
1276
|
return {
|
|
1244
|
-
title: item.title || item.
|
|
1245
|
-
|
|
1277
|
+
title: item.title || item.key,
|
|
1278
|
+
id: item.id,
|
|
1279
|
+
key: item.key,
|
|
1280
|
+
description: item.description,
|
|
1246
1281
|
details
|
|
1247
1282
|
};
|
|
1248
1283
|
}
|
|
1249
1284
|
}
|
|
1250
1285
|
);
|
|
1251
1286
|
|
|
1252
|
-
// src/
|
|
1253
|
-
var
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1287
|
+
// src/resolvers/appKey.ts
|
|
1288
|
+
var appKeyResolver = {
|
|
1289
|
+
type: "static",
|
|
1290
|
+
inputType: "text",
|
|
1291
|
+
placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
// src/resolvers/actionType.ts
|
|
1295
|
+
var actionTypeResolver = {
|
|
1296
|
+
type: "dynamic",
|
|
1297
|
+
depends: ["appKey"],
|
|
1298
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1299
|
+
const actionsResponse = await sdk.listActions({
|
|
1300
|
+
appKey: resolvedParams.appKey
|
|
1301
|
+
});
|
|
1302
|
+
const types = [
|
|
1303
|
+
...new Set(actionsResponse.data.map((action) => action.action_type))
|
|
1304
|
+
];
|
|
1305
|
+
return types.map((type) => ({ key: type, name: type }));
|
|
1306
|
+
},
|
|
1307
|
+
prompt: (types) => ({
|
|
1308
|
+
type: "list",
|
|
1309
|
+
name: "actionType",
|
|
1310
|
+
message: "Select action type:",
|
|
1311
|
+
choices: types.map((type) => ({
|
|
1312
|
+
name: type.name,
|
|
1313
|
+
value: type.key
|
|
1314
|
+
}))
|
|
1315
|
+
})
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
// src/resolvers/actionKey.ts
|
|
1319
|
+
var actionKeyResolver = {
|
|
1320
|
+
type: "dynamic",
|
|
1321
|
+
depends: ["appKey", "actionType"],
|
|
1322
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1323
|
+
const actionsResponse = await sdk.listActions({
|
|
1324
|
+
appKey: resolvedParams.appKey
|
|
1325
|
+
});
|
|
1326
|
+
return actionsResponse.data.filter(
|
|
1327
|
+
(action) => action.action_type === resolvedParams.actionType
|
|
1328
|
+
);
|
|
1329
|
+
},
|
|
1330
|
+
prompt: (actions) => ({
|
|
1331
|
+
type: "list",
|
|
1332
|
+
name: "actionKey",
|
|
1333
|
+
message: "Select action:",
|
|
1334
|
+
choices: actions.map((action) => ({
|
|
1335
|
+
name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
|
|
1336
|
+
value: action.key
|
|
1337
|
+
}))
|
|
1338
|
+
})
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
// src/resolvers/authenticationId.ts
|
|
1342
|
+
var authenticationIdResolver = {
|
|
1343
|
+
type: "dynamic",
|
|
1344
|
+
depends: ["appKey"],
|
|
1345
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1346
|
+
const listOptions = {
|
|
1347
|
+
maxItems: 1e3
|
|
1348
|
+
};
|
|
1349
|
+
if (resolvedParams.appKey) {
|
|
1350
|
+
listOptions.appKey = resolvedParams.appKey;
|
|
1351
|
+
}
|
|
1352
|
+
const myAuths = await sdk.listAuthentications({
|
|
1353
|
+
...listOptions,
|
|
1354
|
+
owner: "me"
|
|
1355
|
+
});
|
|
1356
|
+
const allAuths = await sdk.listAuthentications(listOptions);
|
|
1357
|
+
const otherAuths = allAuths.data.filter(
|
|
1358
|
+
(auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
|
|
1359
|
+
);
|
|
1360
|
+
return [...myAuths.data, ...otherAuths];
|
|
1361
|
+
},
|
|
1362
|
+
prompt: (auths, params) => ({
|
|
1363
|
+
type: "list",
|
|
1364
|
+
name: "authenticationId",
|
|
1365
|
+
message: params.appKey ? `Select authentication for ${params.appKey}:` : "Select authentication:",
|
|
1366
|
+
choices: [
|
|
1367
|
+
...auths.map((auth) => ({
|
|
1368
|
+
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
1369
|
+
value: auth.id
|
|
1370
|
+
})),
|
|
1371
|
+
{
|
|
1372
|
+
name: "\u2197 Skip authentication (may fail)",
|
|
1373
|
+
value: null
|
|
1374
|
+
}
|
|
1375
|
+
]
|
|
1376
|
+
})
|
|
1377
|
+
};
|
|
1378
|
+
var authenticationIdGenericResolver = {
|
|
1379
|
+
...authenticationIdResolver,
|
|
1380
|
+
depends: []
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
// src/resolvers/inputs.ts
|
|
1384
|
+
function makeFieldsOptional(fields) {
|
|
1385
|
+
return fields.map((field) => {
|
|
1386
|
+
if (field.type === "input_field") {
|
|
1387
|
+
return {
|
|
1388
|
+
...field,
|
|
1389
|
+
is_required: false
|
|
1390
|
+
};
|
|
1391
|
+
} else if (field.type === "fieldset") {
|
|
1392
|
+
return {
|
|
1393
|
+
...field,
|
|
1394
|
+
fields: makeFieldsOptional(field.fields)
|
|
1395
|
+
};
|
|
1396
|
+
} else {
|
|
1397
|
+
return field;
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
var inputsResolver = {
|
|
1402
|
+
type: "fields",
|
|
1403
|
+
depends: ["appKey", "actionKey", "actionType", "authenticationId"],
|
|
1404
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1405
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
1406
|
+
appKey: resolvedParams.appKey,
|
|
1407
|
+
actionKey: resolvedParams.actionKey,
|
|
1408
|
+
actionType: resolvedParams.actionType,
|
|
1409
|
+
authenticationId: resolvedParams.authenticationId,
|
|
1410
|
+
inputs: resolvedParams.inputs
|
|
1411
|
+
// Pass along currently resolved inputs
|
|
1412
|
+
});
|
|
1413
|
+
return fieldsResponse.data;
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
var inputsAllOptionalResolver = {
|
|
1417
|
+
type: "fields",
|
|
1418
|
+
depends: ["appKey", "actionKey", "actionType", "authenticationId"],
|
|
1419
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1420
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
1421
|
+
appKey: resolvedParams.appKey,
|
|
1422
|
+
actionKey: resolvedParams.actionKey,
|
|
1423
|
+
actionType: resolvedParams.actionType,
|
|
1424
|
+
authenticationId: resolvedParams.authenticationId,
|
|
1425
|
+
inputs: resolvedParams.inputs
|
|
1426
|
+
// Pass along currently resolved inputs
|
|
1427
|
+
});
|
|
1428
|
+
return makeFieldsOptional(fieldsResponse.data);
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
// src/resolvers/inputFieldKey.ts
|
|
1433
|
+
function flattenRootFieldset(rootFieldset) {
|
|
1434
|
+
const result = [];
|
|
1435
|
+
function processItem(item) {
|
|
1436
|
+
if (item.type === "input_field") {
|
|
1437
|
+
result.push(item);
|
|
1438
|
+
} else if (item.type === "fieldset") {
|
|
1439
|
+
for (const field of item.fields) {
|
|
1440
|
+
processItem(field);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
for (const item of rootFieldset) {
|
|
1445
|
+
processItem(item);
|
|
1446
|
+
}
|
|
1447
|
+
return result;
|
|
1448
|
+
}
|
|
1449
|
+
var inputFieldKeyResolver = {
|
|
1450
|
+
type: "dynamic",
|
|
1451
|
+
depends: ["appKey", "actionKey", "actionType", "authenticationId"],
|
|
1452
|
+
fetch: async (sdk, resolvedParams) => {
|
|
1453
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
1454
|
+
appKey: resolvedParams.appKey,
|
|
1455
|
+
actionKey: resolvedParams.actionKey,
|
|
1456
|
+
actionType: resolvedParams.actionType,
|
|
1457
|
+
authenticationId: resolvedParams.authenticationId,
|
|
1458
|
+
inputs: resolvedParams.inputs
|
|
1459
|
+
// Pass along currently resolved inputs
|
|
1460
|
+
});
|
|
1461
|
+
return flattenRootFieldset(fieldsResponse.data);
|
|
1462
|
+
},
|
|
1463
|
+
prompt: (fields) => ({
|
|
1464
|
+
type: "list",
|
|
1465
|
+
name: "inputFieldKey",
|
|
1466
|
+
message: "Select input field:",
|
|
1467
|
+
choices: fields.map((field) => ({
|
|
1468
|
+
name: `${field.title || field.key} - ${field.value_type || "No type"} ${field.is_required ? "(required)" : "(optional)"}`,
|
|
1469
|
+
value: field.key
|
|
1470
|
+
}))
|
|
1471
|
+
})
|
|
1472
|
+
};
|
|
1266
1473
|
|
|
1267
1474
|
// src/plugins/listActions/index.ts
|
|
1268
1475
|
var listActionsPlugin = ({ context }) => {
|
|
@@ -1329,23 +1536,152 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1329
1536
|
meta: {
|
|
1330
1537
|
listActions: {
|
|
1331
1538
|
categories: ["action"],
|
|
1332
|
-
|
|
1539
|
+
type: "list",
|
|
1540
|
+
itemType: "Action",
|
|
1541
|
+
inputSchema: ListActionsSchema,
|
|
1542
|
+
outputSchema: ActionItemSchema,
|
|
1543
|
+
resolvers: {
|
|
1544
|
+
appKey: appKeyResolver,
|
|
1545
|
+
actionType: actionTypeResolver
|
|
1546
|
+
}
|
|
1333
1547
|
}
|
|
1334
1548
|
}
|
|
1335
1549
|
}
|
|
1336
|
-
};
|
|
1337
|
-
};
|
|
1338
|
-
var ListInputFieldsSchema = zod.z.object({
|
|
1339
|
-
appKey: AppKeyPropertySchema,
|
|
1340
|
-
actionType: ActionTypePropertySchema,
|
|
1341
|
-
actionKey: ActionKeyPropertySchema,
|
|
1342
|
-
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
1343
|
-
inputs: InputsPropertySchema.optional().describe(
|
|
1344
|
-
"Current input values that may affect available fields"
|
|
1345
|
-
),
|
|
1346
|
-
pageSize: zod.z.number().min(1).optional().describe("Number of input fields per page"),
|
|
1347
|
-
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1348
|
-
}).describe("Get the input fields required for a specific action");
|
|
1550
|
+
};
|
|
1551
|
+
};
|
|
1552
|
+
var ListInputFieldsSchema = zod.z.object({
|
|
1553
|
+
appKey: AppKeyPropertySchema,
|
|
1554
|
+
actionType: ActionTypePropertySchema,
|
|
1555
|
+
actionKey: ActionKeyPropertySchema,
|
|
1556
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
1557
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
1558
|
+
"Current input values that may affect available fields"
|
|
1559
|
+
),
|
|
1560
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of input fields per page"),
|
|
1561
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1562
|
+
}).describe("Get the input fields required for a specific action");
|
|
1563
|
+
var BaseFieldItemSchema = zod.z.object({
|
|
1564
|
+
type: zod.z.string(),
|
|
1565
|
+
// "input_field", "info_field", or "fieldset"
|
|
1566
|
+
key: zod.z.string()
|
|
1567
|
+
// From need.key
|
|
1568
|
+
});
|
|
1569
|
+
var InputFieldItemSchema = withFormatter(
|
|
1570
|
+
BaseFieldItemSchema.extend({
|
|
1571
|
+
type: zod.z.literal("input_field"),
|
|
1572
|
+
default_value: zod.z.string(),
|
|
1573
|
+
// Mapped from 'default' with fallback to ""
|
|
1574
|
+
depends_on: zod.z.array(zod.z.string()),
|
|
1575
|
+
// Mapped from 'depends_on' with fallback to []
|
|
1576
|
+
description: zod.z.string(),
|
|
1577
|
+
// Mapped from 'help_text' with fallback to ""
|
|
1578
|
+
invalidates_input_fields: zod.z.boolean(),
|
|
1579
|
+
// Mapped from 'alters_custom_fields' with fallback to false
|
|
1580
|
+
is_required: zod.z.boolean(),
|
|
1581
|
+
// Mapped from 'required' with fallback to false
|
|
1582
|
+
placeholder: zod.z.string(),
|
|
1583
|
+
// Mapped from 'placeholder' with fallback to ""
|
|
1584
|
+
title: zod.z.string(),
|
|
1585
|
+
// Mapped from 'label' with fallback to ""
|
|
1586
|
+
value_type: zod.z.string(),
|
|
1587
|
+
// Computed from InputFieldType enum
|
|
1588
|
+
format: zod.z.string().optional(),
|
|
1589
|
+
// Computed from InputFieldFormat enum (optional)
|
|
1590
|
+
items: zod.z.object({ type: zod.z.string() }).optional()
|
|
1591
|
+
// Computed from ItemsType enum (optional, only for arrays)
|
|
1592
|
+
}),
|
|
1593
|
+
{
|
|
1594
|
+
format: (item) => {
|
|
1595
|
+
const details = [];
|
|
1596
|
+
const typeInfo = [
|
|
1597
|
+
item.value_type && `Type: ${item.value_type}`,
|
|
1598
|
+
`Required: ${item.is_required ? "Yes" : "No"}`
|
|
1599
|
+
].filter(Boolean).join(" | ");
|
|
1600
|
+
if (typeInfo) {
|
|
1601
|
+
details.push({ text: typeInfo, style: "dim" });
|
|
1602
|
+
}
|
|
1603
|
+
if (item.description) {
|
|
1604
|
+
details.push({
|
|
1605
|
+
text: item.description,
|
|
1606
|
+
style: "normal"
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
if (item.default_value) {
|
|
1610
|
+
details.push({
|
|
1611
|
+
text: `Default: ${item.default_value}`,
|
|
1612
|
+
style: "accent"
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
if (item.placeholder) {
|
|
1616
|
+
details.push({
|
|
1617
|
+
text: `Placeholder: ${item.placeholder}`,
|
|
1618
|
+
style: "dim"
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
if (item.depends_on && item.depends_on.length > 0) {
|
|
1622
|
+
details.push({
|
|
1623
|
+
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
1624
|
+
style: "warning"
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
if (item.format) {
|
|
1628
|
+
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
1629
|
+
}
|
|
1630
|
+
if (item.items) {
|
|
1631
|
+
details.push({
|
|
1632
|
+
text: `Items type: ${item.items.type}`,
|
|
1633
|
+
style: "dim"
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
return {
|
|
1637
|
+
title: item.title || item.key,
|
|
1638
|
+
key: item.key,
|
|
1639
|
+
description: item.description,
|
|
1640
|
+
details
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
);
|
|
1645
|
+
var InfoFieldItemSchema = withFormatter(
|
|
1646
|
+
BaseFieldItemSchema.extend({
|
|
1647
|
+
type: zod.z.literal("info_field"),
|
|
1648
|
+
description: zod.z.string(),
|
|
1649
|
+
// From need.help_text
|
|
1650
|
+
title: zod.z.string().optional()
|
|
1651
|
+
// Optional title
|
|
1652
|
+
}),
|
|
1653
|
+
{
|
|
1654
|
+
format: (item) => ({
|
|
1655
|
+
title: item.title || "Info",
|
|
1656
|
+
key: item.key,
|
|
1657
|
+
description: item.description,
|
|
1658
|
+
details: [{ text: item.description, style: "normal" }]
|
|
1659
|
+
})
|
|
1660
|
+
}
|
|
1661
|
+
);
|
|
1662
|
+
var FieldsetItemSchema = BaseFieldItemSchema.extend({
|
|
1663
|
+
type: zod.z.literal("fieldset"),
|
|
1664
|
+
title: zod.z.string(),
|
|
1665
|
+
fields: zod.z.lazy(
|
|
1666
|
+
() => zod.z.array(
|
|
1667
|
+
zod.z.union([
|
|
1668
|
+
InputFieldItemSchema,
|
|
1669
|
+
InfoFieldItemSchema,
|
|
1670
|
+
FieldsetItemSchema
|
|
1671
|
+
])
|
|
1672
|
+
)
|
|
1673
|
+
)
|
|
1674
|
+
});
|
|
1675
|
+
var RootFieldItemSchema = zod.z.union([
|
|
1676
|
+
InputFieldItemSchema,
|
|
1677
|
+
InfoFieldItemSchema,
|
|
1678
|
+
FieldsetItemSchema
|
|
1679
|
+
]);
|
|
1680
|
+
|
|
1681
|
+
// src/utils/string-utils.ts
|
|
1682
|
+
function toTitleCase(input) {
|
|
1683
|
+
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(" ");
|
|
1684
|
+
}
|
|
1349
1685
|
|
|
1350
1686
|
// src/plugins/listInputFields/index.ts
|
|
1351
1687
|
function getInputFieldTypeFromNeed(need) {
|
|
@@ -1390,9 +1726,8 @@ function getItemsTypeFromNeed(need) {
|
|
|
1390
1726
|
function transformNeedToInputFieldItem(need) {
|
|
1391
1727
|
const itemsType = getItemsTypeFromNeed(need);
|
|
1392
1728
|
return {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
id: need.key,
|
|
1729
|
+
type: "input_field",
|
|
1730
|
+
key: need.key,
|
|
1396
1731
|
default_value: need.default || "",
|
|
1397
1732
|
depends_on: need.depends_on || [],
|
|
1398
1733
|
description: need.help_text || "",
|
|
@@ -1405,6 +1740,48 @@ function transformNeedToInputFieldItem(need) {
|
|
|
1405
1740
|
items: itemsType ? { type: itemsType } : void 0
|
|
1406
1741
|
};
|
|
1407
1742
|
}
|
|
1743
|
+
function transformNeedToInfoFieldItem(need) {
|
|
1744
|
+
return {
|
|
1745
|
+
type: "info_field",
|
|
1746
|
+
key: need.key,
|
|
1747
|
+
description: need.help_text || "",
|
|
1748
|
+
title: need.label
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
function transformNeedsToFields(needs) {
|
|
1752
|
+
const rootFields = [];
|
|
1753
|
+
const fieldsetMap = /* @__PURE__ */ new Map();
|
|
1754
|
+
for (const need of needs) {
|
|
1755
|
+
if (need.computed) {
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
if (need.parent_key) {
|
|
1759
|
+
let fieldset = fieldsetMap.get(need.parent_key);
|
|
1760
|
+
if (!fieldset) {
|
|
1761
|
+
fieldset = {
|
|
1762
|
+
type: "fieldset",
|
|
1763
|
+
key: need.parent_key,
|
|
1764
|
+
title: toTitleCase(need.parent_key),
|
|
1765
|
+
fields: []
|
|
1766
|
+
};
|
|
1767
|
+
fieldsetMap.set(need.parent_key, fieldset);
|
|
1768
|
+
rootFields.push(fieldset);
|
|
1769
|
+
}
|
|
1770
|
+
if (need.type === "copy" && need.help_text) {
|
|
1771
|
+
fieldset.fields.push(transformNeedToInfoFieldItem(need));
|
|
1772
|
+
} else {
|
|
1773
|
+
fieldset.fields.push(transformNeedToInputFieldItem(need));
|
|
1774
|
+
}
|
|
1775
|
+
} else {
|
|
1776
|
+
if (need.type === "copy" && need.help_text) {
|
|
1777
|
+
rootFields.push(transformNeedToInfoFieldItem(need));
|
|
1778
|
+
} else {
|
|
1779
|
+
rootFields.push(transformNeedToInputFieldItem(need));
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
return rootFields;
|
|
1784
|
+
}
|
|
1408
1785
|
var listInputFieldsPlugin = ({ context }) => {
|
|
1409
1786
|
const listInputFields = createPaginatedFunction(
|
|
1410
1787
|
async function listInputFieldsPage(options) {
|
|
@@ -1435,11 +1812,9 @@ var listInputFieldsPlugin = ({ context }) => {
|
|
|
1435
1812
|
`Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`
|
|
1436
1813
|
);
|
|
1437
1814
|
}
|
|
1438
|
-
const
|
|
1439
|
-
transformNeedToInputFieldItem
|
|
1440
|
-
);
|
|
1815
|
+
const rootFieldset = transformNeedsToFields(needsData.needs || []);
|
|
1441
1816
|
return {
|
|
1442
|
-
data:
|
|
1817
|
+
data: rootFieldset,
|
|
1443
1818
|
nextCursor: void 0
|
|
1444
1819
|
// No pagination needed since we return all input fields
|
|
1445
1820
|
};
|
|
@@ -1452,7 +1827,17 @@ var listInputFieldsPlugin = ({ context }) => {
|
|
|
1452
1827
|
meta: {
|
|
1453
1828
|
listInputFields: {
|
|
1454
1829
|
categories: ["action"],
|
|
1455
|
-
|
|
1830
|
+
type: "list",
|
|
1831
|
+
itemType: "RootFieldItem",
|
|
1832
|
+
inputSchema: ListInputFieldsSchema,
|
|
1833
|
+
outputSchema: RootFieldItemSchema,
|
|
1834
|
+
resolvers: {
|
|
1835
|
+
appKey: appKeyResolver,
|
|
1836
|
+
actionType: actionTypeResolver,
|
|
1837
|
+
actionKey: actionKeyResolver,
|
|
1838
|
+
authenticationId: authenticationIdResolver,
|
|
1839
|
+
inputs: inputsAllOptionalResolver
|
|
1840
|
+
}
|
|
1456
1841
|
}
|
|
1457
1842
|
}
|
|
1458
1843
|
}
|
|
@@ -1470,6 +1855,49 @@ var ListAuthenticationsSchema = zod.z.object({
|
|
|
1470
1855
|
pageSize: zod.z.number().min(1).optional().describe("Number of authentications per page"),
|
|
1471
1856
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1472
1857
|
}).describe("List available authentications with optional filtering");
|
|
1858
|
+
var AuthenticationItemSchema = withFormatter(
|
|
1859
|
+
AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
|
|
1860
|
+
{
|
|
1861
|
+
implementation_id: zod.z.string().optional(),
|
|
1862
|
+
// Renamed from selected_api
|
|
1863
|
+
is_expired: zod.z.string().optional(),
|
|
1864
|
+
// Mapped from is_stale
|
|
1865
|
+
expired_at: zod.z.string().nullable().optional(),
|
|
1866
|
+
// Mapped from marked_stale_at
|
|
1867
|
+
app_key: zod.z.string().optional(),
|
|
1868
|
+
// App key from implementations endpoint
|
|
1869
|
+
version: zod.z.string().optional(),
|
|
1870
|
+
// Version extracted from implementation_id
|
|
1871
|
+
user_id: zod.z.number().optional()
|
|
1872
|
+
}
|
|
1873
|
+
),
|
|
1874
|
+
{
|
|
1875
|
+
format: (item) => {
|
|
1876
|
+
const details = [];
|
|
1877
|
+
if (item.identifier) {
|
|
1878
|
+
details.push({
|
|
1879
|
+
text: `Identifier: ${item.identifier}`,
|
|
1880
|
+
style: "accent"
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
details.push({
|
|
1884
|
+
text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
|
|
1885
|
+
style: "dim"
|
|
1886
|
+
});
|
|
1887
|
+
if (item.marked_stale_at) {
|
|
1888
|
+
details.push({
|
|
1889
|
+
text: `\u26A0\uFE0F Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
1890
|
+
style: "warning"
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
return {
|
|
1894
|
+
title: item.title || `Authentication ${item.id}`,
|
|
1895
|
+
id: item.id?.toString(),
|
|
1896
|
+
details
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
);
|
|
1473
1901
|
|
|
1474
1902
|
// src/plugins/listAuthentications/index.ts
|
|
1475
1903
|
var listAuthenticationsPlugin = ({ context }) => {
|
|
@@ -1545,20 +1973,23 @@ var listAuthenticationsPlugin = ({ context }) => {
|
|
|
1545
1973
|
meta: {
|
|
1546
1974
|
listAuthentications: {
|
|
1547
1975
|
categories: ["authentication"],
|
|
1548
|
-
|
|
1976
|
+
type: "list",
|
|
1977
|
+
itemType: "Authentication",
|
|
1978
|
+
inputSchema: ListAuthenticationsSchema,
|
|
1979
|
+
outputSchema: AuthenticationItemSchema,
|
|
1980
|
+
resolvers: {
|
|
1981
|
+
appKey: appKeyResolver
|
|
1982
|
+
}
|
|
1549
1983
|
}
|
|
1550
1984
|
}
|
|
1551
1985
|
}
|
|
1552
1986
|
};
|
|
1553
1987
|
};
|
|
1554
|
-
var GetAppSchema =
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
}).describe("Get detailed information about a specific app"),
|
|
1560
|
-
AppItemSchema
|
|
1561
|
-
);
|
|
1988
|
+
var GetAppSchema = zod.z.object({
|
|
1989
|
+
appKey: AppKeyPropertySchema.describe(
|
|
1990
|
+
"App key of app to fetch (e.g., 'SlackCLIAPI')"
|
|
1991
|
+
)
|
|
1992
|
+
}).describe("Get detailed information about a specific app");
|
|
1562
1993
|
|
|
1563
1994
|
// src/plugins/getApp/index.ts
|
|
1564
1995
|
var getAppPlugin = ({ sdk }) => {
|
|
@@ -1579,7 +2010,13 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
1579
2010
|
meta: {
|
|
1580
2011
|
getApp: {
|
|
1581
2012
|
categories: ["app"],
|
|
1582
|
-
|
|
2013
|
+
type: "item",
|
|
2014
|
+
itemType: "App",
|
|
2015
|
+
inputSchema: GetAppSchema,
|
|
2016
|
+
outputSchema: AppItemSchema,
|
|
2017
|
+
resolvers: {
|
|
2018
|
+
appKey: appKeyResolver
|
|
2019
|
+
}
|
|
1583
2020
|
}
|
|
1584
2021
|
}
|
|
1585
2022
|
}
|
|
@@ -1612,7 +2049,15 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
1612
2049
|
meta: {
|
|
1613
2050
|
getAction: {
|
|
1614
2051
|
categories: ["action"],
|
|
1615
|
-
|
|
2052
|
+
type: "item",
|
|
2053
|
+
itemType: "Action",
|
|
2054
|
+
inputSchema: GetActionSchema,
|
|
2055
|
+
outputSchema: ActionItemSchema,
|
|
2056
|
+
resolvers: {
|
|
2057
|
+
appKey: appKeyResolver,
|
|
2058
|
+
actionType: actionTypeResolver,
|
|
2059
|
+
actionKey: actionKeyResolver
|
|
2060
|
+
}
|
|
1616
2061
|
}
|
|
1617
2062
|
}
|
|
1618
2063
|
}
|
|
@@ -1667,7 +2112,13 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
1667
2112
|
meta: {
|
|
1668
2113
|
getAuthentication: {
|
|
1669
2114
|
categories: ["authentication"],
|
|
1670
|
-
|
|
2115
|
+
type: "item",
|
|
2116
|
+
itemType: "Authentication",
|
|
2117
|
+
inputSchema: GetAuthenticationSchema,
|
|
2118
|
+
outputSchema: AuthenticationItemSchema,
|
|
2119
|
+
resolvers: {
|
|
2120
|
+
authenticationId: authenticationIdGenericResolver
|
|
2121
|
+
}
|
|
1671
2122
|
}
|
|
1672
2123
|
}
|
|
1673
2124
|
}
|
|
@@ -1691,8 +2142,14 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
|
|
|
1691
2142
|
...options,
|
|
1692
2143
|
maxItems: 1
|
|
1693
2144
|
});
|
|
2145
|
+
if (authsResponse.data.length === 0) {
|
|
2146
|
+
throw new ZapierResourceNotFoundError(
|
|
2147
|
+
"No authentication found matching the specified criteria",
|
|
2148
|
+
{ resourceType: "Authentication" }
|
|
2149
|
+
);
|
|
2150
|
+
}
|
|
1694
2151
|
return {
|
|
1695
|
-
data: authsResponse.data
|
|
2152
|
+
data: authsResponse.data[0]
|
|
1696
2153
|
};
|
|
1697
2154
|
},
|
|
1698
2155
|
FindFirstAuthenticationSchema
|
|
@@ -1703,7 +2160,10 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
|
|
|
1703
2160
|
meta: {
|
|
1704
2161
|
findFirstAuthentication: {
|
|
1705
2162
|
categories: ["authentication"],
|
|
1706
|
-
|
|
2163
|
+
type: "item",
|
|
2164
|
+
itemType: "Authentication",
|
|
2165
|
+
inputSchema: FindFirstAuthenticationSchema,
|
|
2166
|
+
outputSchema: AuthenticationItemSchema
|
|
1707
2167
|
}
|
|
1708
2168
|
}
|
|
1709
2169
|
}
|
|
@@ -1751,7 +2211,10 @@ var findUniqueAuthenticationPlugin = ({ sdk }) => {
|
|
|
1751
2211
|
meta: {
|
|
1752
2212
|
findUniqueAuthentication: {
|
|
1753
2213
|
categories: ["authentication"],
|
|
1754
|
-
|
|
2214
|
+
type: "item",
|
|
2215
|
+
itemType: "Authentication",
|
|
2216
|
+
inputSchema: FindUniqueAuthenticationSchema,
|
|
2217
|
+
outputSchema: AuthenticationItemSchema
|
|
1755
2218
|
}
|
|
1756
2219
|
}
|
|
1757
2220
|
}
|
|
@@ -1768,6 +2231,31 @@ var RunActionSchema = zod.z.object({
|
|
|
1768
2231
|
pageSize: zod.z.number().min(1).optional().describe("Number of results per page"),
|
|
1769
2232
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1770
2233
|
}).describe("Execute an action with the given inputs");
|
|
2234
|
+
function getStringProperty(obj, key) {
|
|
2235
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
2236
|
+
const value = obj[key];
|
|
2237
|
+
return typeof value === "string" ? value : void 0;
|
|
2238
|
+
}
|
|
2239
|
+
return void 0;
|
|
2240
|
+
}
|
|
2241
|
+
function formatActionResult(item) {
|
|
2242
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
2243
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
2244
|
+
return {
|
|
2245
|
+
title,
|
|
2246
|
+
id: getStringProperty(obj, "id"),
|
|
2247
|
+
key: getStringProperty(obj, "key"),
|
|
2248
|
+
description: getStringProperty(obj, "description"),
|
|
2249
|
+
data: item,
|
|
2250
|
+
// Let formatJsonOutput handle the JSON rendering
|
|
2251
|
+
details: []
|
|
2252
|
+
// Not used when data is provided
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
var ActionResultItemSchema = withFormatter(
|
|
2256
|
+
zod.z.unknown().describe("Action execution result"),
|
|
2257
|
+
{ format: formatActionResult }
|
|
2258
|
+
);
|
|
1771
2259
|
|
|
1772
2260
|
// src/plugins/runAction/index.ts
|
|
1773
2261
|
async function executeAction(actionOptions) {
|
|
@@ -1859,7 +2347,17 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
1859
2347
|
meta: {
|
|
1860
2348
|
runAction: {
|
|
1861
2349
|
categories: ["action"],
|
|
1862
|
-
|
|
2350
|
+
type: "list",
|
|
2351
|
+
itemType: "ActionResult",
|
|
2352
|
+
inputSchema: RunActionSchema,
|
|
2353
|
+
outputSchema: ActionResultItemSchema,
|
|
2354
|
+
resolvers: {
|
|
2355
|
+
appKey: appKeyResolver,
|
|
2356
|
+
actionType: actionTypeResolver,
|
|
2357
|
+
actionKey: actionKeyResolver,
|
|
2358
|
+
authenticationId: authenticationIdResolver,
|
|
2359
|
+
inputs: inputsResolver
|
|
2360
|
+
}
|
|
1863
2361
|
}
|
|
1864
2362
|
}
|
|
1865
2363
|
}
|
|
@@ -1931,6 +2429,7 @@ var requestPlugin = ({ context }) => {
|
|
|
1931
2429
|
meta: {
|
|
1932
2430
|
request: {
|
|
1933
2431
|
categories: ["http"],
|
|
2432
|
+
returnType: "Response",
|
|
1934
2433
|
inputSchema: RelayRequestSchema
|
|
1935
2434
|
}
|
|
1936
2435
|
}
|
|
@@ -2278,6 +2777,7 @@ var manifestPlugin = (params) => {
|
|
|
2278
2777
|
}
|
|
2279
2778
|
};
|
|
2280
2779
|
};
|
|
2780
|
+
var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
|
|
2281
2781
|
var UserProfileItemSchema = withFormatter(
|
|
2282
2782
|
UserProfileSchema.omit({ user_id: true }).extend({
|
|
2283
2783
|
full_name: zod.z.string()
|
|
@@ -2286,32 +2786,37 @@ var UserProfileItemSchema = withFormatter(
|
|
|
2286
2786
|
{
|
|
2287
2787
|
format: (item) => {
|
|
2288
2788
|
const details = [];
|
|
2289
|
-
|
|
2290
|
-
|
|
2789
|
+
if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
|
|
2790
|
+
return {
|
|
2791
|
+
title: "User Profile",
|
|
2792
|
+
subtitle: "Malformatted result item",
|
|
2793
|
+
details: []
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
if ("email" in item) {
|
|
2797
|
+
details.push({ text: item.email, style: "dim" });
|
|
2798
|
+
}
|
|
2799
|
+
if ("timezone" in item && item.timezone) {
|
|
2291
2800
|
details.push({
|
|
2292
2801
|
text: `Timezone: ${item.timezone}`,
|
|
2293
2802
|
style: "accent"
|
|
2294
2803
|
});
|
|
2295
2804
|
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2805
|
+
if ("since_signup" in item && item.since_signup) {
|
|
2806
|
+
details.push({
|
|
2807
|
+
text: `Member since: ${item.since_signup}`,
|
|
2808
|
+
style: "dim"
|
|
2809
|
+
});
|
|
2810
|
+
}
|
|
2300
2811
|
return {
|
|
2301
2812
|
title: item.full_name,
|
|
2302
|
-
|
|
2813
|
+
id: item.id.toString(),
|
|
2303
2814
|
details
|
|
2304
2815
|
};
|
|
2305
2816
|
}
|
|
2306
2817
|
}
|
|
2307
2818
|
);
|
|
2308
2819
|
|
|
2309
|
-
// src/plugins/getProfile/schemas.ts
|
|
2310
|
-
var GetProfileSchema = withOutputSchema(
|
|
2311
|
-
zod.z.object({}).optional().describe("Get current user's profile information"),
|
|
2312
|
-
UserProfileItemSchema
|
|
2313
|
-
);
|
|
2314
|
-
|
|
2315
2820
|
// src/plugins/getProfile/index.ts
|
|
2316
2821
|
var getProfilePlugin = ({ context }) => {
|
|
2317
2822
|
const getProfile = createFunction(async function getProfile2() {
|
|
@@ -2334,7 +2839,10 @@ var getProfilePlugin = ({ context }) => {
|
|
|
2334
2839
|
meta: {
|
|
2335
2840
|
getProfile: {
|
|
2336
2841
|
categories: ["account"],
|
|
2337
|
-
|
|
2842
|
+
type: "item",
|
|
2843
|
+
itemType: "Profile",
|
|
2844
|
+
inputSchema: GetProfileSchema,
|
|
2845
|
+
outputSchema: UserProfileItemSchema
|
|
2338
2846
|
}
|
|
2339
2847
|
}
|
|
2340
2848
|
}
|
|
@@ -2367,6 +2875,38 @@ function createDebugLogger(enabled) {
|
|
|
2367
2875
|
console.log(`[Zapier SDK] ${message}`, data || "");
|
|
2368
2876
|
};
|
|
2369
2877
|
}
|
|
2878
|
+
function censorHeaders(headers) {
|
|
2879
|
+
if (!headers) return headers;
|
|
2880
|
+
const headersObj = new Headers(headers);
|
|
2881
|
+
const authKeys = ["authorization", "x-api-key"];
|
|
2882
|
+
for (const [key, value] of headersObj.entries()) {
|
|
2883
|
+
if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
|
|
2884
|
+
const spaceIndex = value.indexOf(" ");
|
|
2885
|
+
if (spaceIndex > 0 && spaceIndex < value.length - 1) {
|
|
2886
|
+
const prefix = value.substring(0, spaceIndex + 1);
|
|
2887
|
+
const token = value.substring(spaceIndex + 1);
|
|
2888
|
+
if (token.length > 12) {
|
|
2889
|
+
const start = token.substring(0, 4);
|
|
2890
|
+
const end = token.substring(token.length - 4);
|
|
2891
|
+
headersObj.set(key, `${prefix}${start}...${end}`);
|
|
2892
|
+
} else {
|
|
2893
|
+
const firstChar = token.charAt(0);
|
|
2894
|
+
headersObj.set(key, `${prefix}${firstChar}...`);
|
|
2895
|
+
}
|
|
2896
|
+
} else {
|
|
2897
|
+
if (value.length > 12) {
|
|
2898
|
+
const start = value.substring(0, 4);
|
|
2899
|
+
const end = value.substring(value.length - 4);
|
|
2900
|
+
headersObj.set(key, `${start}...${end}`);
|
|
2901
|
+
} else {
|
|
2902
|
+
const firstChar = value.charAt(0);
|
|
2903
|
+
headersObj.set(key, `${firstChar}...`);
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
return Object.fromEntries(headersObj);
|
|
2909
|
+
}
|
|
2370
2910
|
function createDebugFetch(options) {
|
|
2371
2911
|
const { originalFetch, debugLog } = options;
|
|
2372
2912
|
return async (input, options2) => {
|
|
@@ -2374,7 +2914,7 @@ function createDebugFetch(options) {
|
|
|
2374
2914
|
const url = typeof input === "string" ? input : input.toString();
|
|
2375
2915
|
const method = options2?.method || "GET";
|
|
2376
2916
|
debugLog(`\u2192 ${method} ${url}`, {
|
|
2377
|
-
headers: options2?.headers,
|
|
2917
|
+
headers: censorHeaders(options2?.headers),
|
|
2378
2918
|
body: options2?.body && typeof options2.body === "string" ? (() => {
|
|
2379
2919
|
try {
|
|
2380
2920
|
return JSON.parse(options2.body);
|
|
@@ -2725,6 +3265,16 @@ var ZapierApiClient = class {
|
|
|
2725
3265
|
if ("errors" in data && Array.isArray(data.errors)) {
|
|
2726
3266
|
if (this.isApiErrorArray(data.errors)) {
|
|
2727
3267
|
return data.errors[0].detail || data.errors[0].title;
|
|
3268
|
+
} else if (data.errors.length > 0) {
|
|
3269
|
+
const firstError = data.errors[0];
|
|
3270
|
+
if (typeof firstError === "string") {
|
|
3271
|
+
return firstError;
|
|
3272
|
+
}
|
|
3273
|
+
try {
|
|
3274
|
+
return JSON.stringify(firstError);
|
|
3275
|
+
} catch {
|
|
3276
|
+
return String(firstError);
|
|
3277
|
+
}
|
|
2728
3278
|
}
|
|
2729
3279
|
}
|
|
2730
3280
|
}
|
|
@@ -2909,174 +3459,6 @@ var apiPlugin = (params) => {
|
|
|
2909
3459
|
};
|
|
2910
3460
|
};
|
|
2911
3461
|
|
|
2912
|
-
// src/resolvers/appKey.ts
|
|
2913
|
-
var appKeyResolver = {
|
|
2914
|
-
type: "static",
|
|
2915
|
-
inputType: "text",
|
|
2916
|
-
placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
2917
|
-
};
|
|
2918
|
-
|
|
2919
|
-
// src/resolvers/actionType.ts
|
|
2920
|
-
var actionTypeResolver = {
|
|
2921
|
-
type: "dynamic",
|
|
2922
|
-
depends: ["appKey"],
|
|
2923
|
-
fetch: async (sdk, resolvedParams) => {
|
|
2924
|
-
const actionsResponse = await sdk.listActions({
|
|
2925
|
-
appKey: resolvedParams.appKey
|
|
2926
|
-
});
|
|
2927
|
-
const types = [
|
|
2928
|
-
...new Set(actionsResponse.data.map((action) => action.action_type))
|
|
2929
|
-
];
|
|
2930
|
-
return types.map((type) => ({ key: type, name: type }));
|
|
2931
|
-
},
|
|
2932
|
-
prompt: (types) => ({
|
|
2933
|
-
type: "list",
|
|
2934
|
-
name: "actionType",
|
|
2935
|
-
message: "Select action type:",
|
|
2936
|
-
choices: types.map((type) => ({
|
|
2937
|
-
name: type.name,
|
|
2938
|
-
value: type.key
|
|
2939
|
-
}))
|
|
2940
|
-
})
|
|
2941
|
-
};
|
|
2942
|
-
|
|
2943
|
-
// src/resolvers/actionKey.ts
|
|
2944
|
-
var actionKeyResolver = {
|
|
2945
|
-
type: "dynamic",
|
|
2946
|
-
depends: ["appKey", "actionType"],
|
|
2947
|
-
fetch: async (sdk, resolvedParams) => {
|
|
2948
|
-
const actionsResponse = await sdk.listActions({
|
|
2949
|
-
appKey: resolvedParams.appKey
|
|
2950
|
-
});
|
|
2951
|
-
return actionsResponse.data.filter(
|
|
2952
|
-
(action) => action.action_type === resolvedParams.actionType
|
|
2953
|
-
);
|
|
2954
|
-
},
|
|
2955
|
-
prompt: (actions) => ({
|
|
2956
|
-
type: "list",
|
|
2957
|
-
name: "actionKey",
|
|
2958
|
-
message: "Select action:",
|
|
2959
|
-
choices: actions.map((action) => ({
|
|
2960
|
-
name: `${action.title || action.name || action.key} - ${action.description || "No description"}`,
|
|
2961
|
-
value: action.key
|
|
2962
|
-
}))
|
|
2963
|
-
})
|
|
2964
|
-
};
|
|
2965
|
-
|
|
2966
|
-
// src/resolvers/authenticationId.ts
|
|
2967
|
-
var authenticationIdResolver = {
|
|
2968
|
-
type: "dynamic",
|
|
2969
|
-
depends: ["appKey"],
|
|
2970
|
-
fetch: async (sdk, resolvedParams) => {
|
|
2971
|
-
const myAuths = await sdk.listAuthentications({
|
|
2972
|
-
appKey: resolvedParams.appKey,
|
|
2973
|
-
maxItems: 1e3,
|
|
2974
|
-
owner: "me"
|
|
2975
|
-
});
|
|
2976
|
-
const allAuths = await sdk.listAuthentications({
|
|
2977
|
-
appKey: resolvedParams.appKey,
|
|
2978
|
-
maxItems: 1e3
|
|
2979
|
-
});
|
|
2980
|
-
const otherAuths = allAuths.data.filter(
|
|
2981
|
-
(auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id)
|
|
2982
|
-
);
|
|
2983
|
-
return [...myAuths.data, ...otherAuths];
|
|
2984
|
-
},
|
|
2985
|
-
prompt: (auths, params) => ({
|
|
2986
|
-
type: "list",
|
|
2987
|
-
name: "authenticationId",
|
|
2988
|
-
message: `Select authentication for ${params.appKey}:`,
|
|
2989
|
-
choices: [
|
|
2990
|
-
...auths.map((auth) => ({
|
|
2991
|
-
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
2992
|
-
value: auth.id
|
|
2993
|
-
})),
|
|
2994
|
-
{
|
|
2995
|
-
name: "\u2197 Skip authentication (may fail)",
|
|
2996
|
-
value: null
|
|
2997
|
-
}
|
|
2998
|
-
]
|
|
2999
|
-
})
|
|
3000
|
-
};
|
|
3001
|
-
|
|
3002
|
-
// src/resolvers/inputs.ts
|
|
3003
|
-
var inputsResolver = {
|
|
3004
|
-
type: "fields",
|
|
3005
|
-
depends: ["appKey", "actionKey", "actionType", "authenticationId"],
|
|
3006
|
-
fetch: async (sdk, resolvedParams) => {
|
|
3007
|
-
const fieldsResponse = await sdk.listInputFields({
|
|
3008
|
-
appKey: resolvedParams.appKey,
|
|
3009
|
-
actionKey: resolvedParams.actionKey,
|
|
3010
|
-
actionType: resolvedParams.actionType,
|
|
3011
|
-
authenticationId: resolvedParams.authenticationId,
|
|
3012
|
-
inputs: resolvedParams.inputs
|
|
3013
|
-
// Pass along currently resolved inputs
|
|
3014
|
-
});
|
|
3015
|
-
return fieldsResponse.data;
|
|
3016
|
-
}
|
|
3017
|
-
};
|
|
3018
|
-
|
|
3019
|
-
// src/resolvers/index.ts
|
|
3020
|
-
var resolverRegistry = {
|
|
3021
|
-
appKey: appKeyResolver,
|
|
3022
|
-
actionType: actionTypeResolver,
|
|
3023
|
-
actionKey: actionKeyResolver,
|
|
3024
|
-
authenticationId: authenticationIdResolver,
|
|
3025
|
-
inputs: inputsResolver
|
|
3026
|
-
};
|
|
3027
|
-
function getResolver(name) {
|
|
3028
|
-
return resolverRegistry[name];
|
|
3029
|
-
}
|
|
3030
|
-
function getResolversForMissingParams(missingParams) {
|
|
3031
|
-
const resolvers = {};
|
|
3032
|
-
for (const param of missingParams) {
|
|
3033
|
-
const resolver = resolverRegistry[param];
|
|
3034
|
-
if (resolver) {
|
|
3035
|
-
resolvers[param] = resolver;
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
return resolvers;
|
|
3039
|
-
}
|
|
3040
|
-
function hasResolver(paramName) {
|
|
3041
|
-
return paramName in resolverRegistry;
|
|
3042
|
-
}
|
|
3043
|
-
function getResolvableParams() {
|
|
3044
|
-
return Object.keys(resolverRegistry);
|
|
3045
|
-
}
|
|
3046
|
-
function getResolutionOrder(paramName, resolved = /* @__PURE__ */ new Set()) {
|
|
3047
|
-
const resolver = getResolver(paramName);
|
|
3048
|
-
if (!resolver || resolver.type === "static") {
|
|
3049
|
-
return [paramName];
|
|
3050
|
-
}
|
|
3051
|
-
const order = [];
|
|
3052
|
-
if ("depends" in resolver && resolver.depends) {
|
|
3053
|
-
for (const dependency of resolver.depends) {
|
|
3054
|
-
if (!resolved.has(dependency)) {
|
|
3055
|
-
order.push(...getResolutionOrder(dependency, resolved));
|
|
3056
|
-
resolved.add(dependency);
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
}
|
|
3060
|
-
if (!resolved.has(paramName)) {
|
|
3061
|
-
order.push(paramName);
|
|
3062
|
-
resolved.add(paramName);
|
|
3063
|
-
}
|
|
3064
|
-
return order;
|
|
3065
|
-
}
|
|
3066
|
-
function getResolutionOrderForParams(paramNames) {
|
|
3067
|
-
const resolved = /* @__PURE__ */ new Set();
|
|
3068
|
-
const order = [];
|
|
3069
|
-
for (const paramName of paramNames) {
|
|
3070
|
-
const paramOrder = getResolutionOrder(paramName, resolved);
|
|
3071
|
-
for (const param of paramOrder) {
|
|
3072
|
-
if (!order.includes(param)) {
|
|
3073
|
-
order.push(param);
|
|
3074
|
-
}
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
return order;
|
|
3078
|
-
}
|
|
3079
|
-
|
|
3080
3462
|
// src/plugins/registry/index.ts
|
|
3081
3463
|
var registryPlugin = ({ sdk, context }) => {
|
|
3082
3464
|
const metaKeys = Object.keys(context.meta || {});
|
|
@@ -3106,10 +3488,16 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3106
3488
|
}
|
|
3107
3489
|
};
|
|
3108
3490
|
const functions = metaKeys.filter((key) => typeof sdk[key] === "function").map((key) => {
|
|
3491
|
+
const meta = context.meta[key];
|
|
3109
3492
|
return {
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3493
|
+
name: key,
|
|
3494
|
+
type: meta.type,
|
|
3495
|
+
itemType: meta.itemType,
|
|
3496
|
+
returnType: meta.returnType,
|
|
3497
|
+
inputSchema: meta.inputSchema,
|
|
3498
|
+
outputSchema: meta.outputSchema,
|
|
3499
|
+
categories: meta.categories || [],
|
|
3500
|
+
resolvers: meta.resolvers
|
|
3113
3501
|
};
|
|
3114
3502
|
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
3115
3503
|
const knownCategories = Object.keys(categoryDefinitions);
|
|
@@ -3143,52 +3531,43 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3143
3531
|
getRegistry
|
|
3144
3532
|
};
|
|
3145
3533
|
};
|
|
3146
|
-
var InputFieldChoiceItemSchema = withFormatter(
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
const title = item.label || item.key || "Choice";
|
|
3156
|
-
const subtitle = item.label && item.key && item.label !== item.key ? `(${item.key})` : void 0;
|
|
3157
|
-
const details = [];
|
|
3158
|
-
if (item.sample && item.sample !== item.key) {
|
|
3159
|
-
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
3160
|
-
}
|
|
3161
|
-
if (item.value && item.value !== item.key) {
|
|
3162
|
-
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
3163
|
-
}
|
|
3164
|
-
return {
|
|
3165
|
-
title,
|
|
3166
|
-
subtitle,
|
|
3167
|
-
details
|
|
3168
|
-
};
|
|
3534
|
+
var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
|
|
3535
|
+
format: (item) => {
|
|
3536
|
+
const title = item.label || item.key || "Choice";
|
|
3537
|
+
const details = [];
|
|
3538
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
3539
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
3540
|
+
}
|
|
3541
|
+
if (item.sample && item.sample !== item.key) {
|
|
3542
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
3169
3543
|
}
|
|
3544
|
+
if (item.value && item.value !== item.key) {
|
|
3545
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
3546
|
+
}
|
|
3547
|
+
return {
|
|
3548
|
+
title,
|
|
3549
|
+
key: item.key,
|
|
3550
|
+
details
|
|
3551
|
+
};
|
|
3170
3552
|
}
|
|
3171
|
-
);
|
|
3172
|
-
var ListInputFieldChoicesSchema =
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
}).describe("Get the available choices for a dynamic dropdown input field"),
|
|
3190
|
-
InputFieldChoiceItemSchema
|
|
3191
|
-
);
|
|
3553
|
+
});
|
|
3554
|
+
var ListInputFieldChoicesSchema = zod.z.object({
|
|
3555
|
+
// Required action identification
|
|
3556
|
+
appKey: AppKeyPropertySchema,
|
|
3557
|
+
actionType: ActionTypePropertySchema,
|
|
3558
|
+
actionKey: ActionKeyPropertySchema,
|
|
3559
|
+
// Input field specification
|
|
3560
|
+
inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for."),
|
|
3561
|
+
// Common parameters
|
|
3562
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
3563
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
3564
|
+
"Current input values that may affect available choices"
|
|
3565
|
+
),
|
|
3566
|
+
page: zod.z.number().int().min(0).optional().describe("Page number for paginated results"),
|
|
3567
|
+
// Pagination options (SDK-level)
|
|
3568
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of choices per page"),
|
|
3569
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
3570
|
+
}).describe("Get the available choices for a dynamic dropdown input field");
|
|
3192
3571
|
|
|
3193
3572
|
// src/plugins/listInputFieldChoices/index.ts
|
|
3194
3573
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
@@ -3242,7 +3621,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
3242
3621
|
transformNeedChoicesToInputFieldChoiceItem
|
|
3243
3622
|
);
|
|
3244
3623
|
let nextCursor;
|
|
3245
|
-
if (choicesData.next_page
|
|
3624
|
+
if (choicesData.next_page != null) {
|
|
3246
3625
|
nextCursor = choicesData.next_page.toString();
|
|
3247
3626
|
} else if (choicesData.links?.next) {
|
|
3248
3627
|
try {
|
|
@@ -3266,7 +3645,18 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
3266
3645
|
meta: {
|
|
3267
3646
|
listInputFieldChoices: {
|
|
3268
3647
|
categories: ["action"],
|
|
3269
|
-
|
|
3648
|
+
type: "list",
|
|
3649
|
+
itemType: "InputFieldChoice",
|
|
3650
|
+
inputSchema: ListInputFieldChoicesSchema,
|
|
3651
|
+
outputSchema: InputFieldChoiceItemSchema,
|
|
3652
|
+
resolvers: {
|
|
3653
|
+
appKey: appKeyResolver,
|
|
3654
|
+
actionType: actionTypeResolver,
|
|
3655
|
+
actionKey: actionKeyResolver,
|
|
3656
|
+
authenticationId: authenticationIdResolver,
|
|
3657
|
+
inputFieldKey: inputFieldKeyResolver,
|
|
3658
|
+
inputs: inputsAllOptionalResolver
|
|
3659
|
+
}
|
|
3270
3660
|
}
|
|
3271
3661
|
}
|
|
3272
3662
|
}
|
|
@@ -3358,6 +3748,7 @@ exports.actionTypeResolver = actionTypeResolver;
|
|
|
3358
3748
|
exports.apiPlugin = apiPlugin;
|
|
3359
3749
|
exports.appKeyResolver = appKeyResolver;
|
|
3360
3750
|
exports.appsPlugin = appsPlugin;
|
|
3751
|
+
exports.authenticationIdGenericResolver = authenticationIdGenericResolver;
|
|
3361
3752
|
exports.authenticationIdResolver = authenticationIdResolver;
|
|
3362
3753
|
exports.createFunction = createFunction;
|
|
3363
3754
|
exports.createSdk = createSdk;
|
|
@@ -3373,15 +3764,11 @@ exports.getAppPlugin = getAppPlugin;
|
|
|
3373
3764
|
exports.getAuthenticationPlugin = getAuthenticationPlugin;
|
|
3374
3765
|
exports.getPreferredManifestEntryKey = getPreferredManifestEntryKey;
|
|
3375
3766
|
exports.getProfilePlugin = getProfilePlugin;
|
|
3376
|
-
exports.getResolutionOrder = getResolutionOrder;
|
|
3377
|
-
exports.getResolutionOrderForParams = getResolutionOrderForParams;
|
|
3378
|
-
exports.getResolvableParams = getResolvableParams;
|
|
3379
|
-
exports.getResolver = getResolver;
|
|
3380
|
-
exports.getResolversForMissingParams = getResolversForMissingParams;
|
|
3381
3767
|
exports.getTokenFromCliLogin = getTokenFromCliLogin;
|
|
3382
3768
|
exports.getTokenFromEnv = getTokenFromEnv;
|
|
3383
3769
|
exports.getTokenFromEnvOrConfig = getTokenFromEnvOrConfig;
|
|
3384
|
-
exports.
|
|
3770
|
+
exports.inputFieldKeyResolver = inputFieldKeyResolver;
|
|
3771
|
+
exports.inputsAllOptionalResolver = inputsAllOptionalResolver;
|
|
3385
3772
|
exports.inputsResolver = inputsResolver;
|
|
3386
3773
|
exports.isPositional = isPositional;
|
|
3387
3774
|
exports.listActionsPlugin = listActionsPlugin;
|
|
@@ -3392,5 +3779,4 @@ exports.manifestPlugin = manifestPlugin;
|
|
|
3392
3779
|
exports.readManifestFromFile = readManifestFromFile;
|
|
3393
3780
|
exports.registryPlugin = registryPlugin;
|
|
3394
3781
|
exports.requestPlugin = requestPlugin;
|
|
3395
|
-
exports.resolverRegistry = resolverRegistry;
|
|
3396
3782
|
exports.runActionPlugin = runActionPlugin;
|