@zapier/zapier-sdk 0.15.2 → 0.15.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/dist/api/auth.d.ts +10 -0
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +35 -0
- package/dist/api/schemas.d.ts +38 -38
- package/dist/index.cjs +209 -27
- package/dist/index.d.mts +151 -59
- package/dist/index.mjs +209 -27
- package/dist/plugins/eventEmission/index.d.ts +1 -1
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +90 -22
- package/dist/plugins/eventEmission/index.test.js +179 -2
- package/dist/plugins/fetch/schemas.d.ts +2 -2
- package/dist/plugins/getAction/schemas.d.ts +2 -2
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/listActions/index.test.js +25 -0
- package/dist/plugins/listActions/schemas.d.ts +2 -2
- package/dist/plugins/listAuthentications/index.test.js +20 -0
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +6 -6
- package/dist/plugins/listInputFields/schemas.d.ts +6 -6
- package/dist/plugins/manifest/index.d.ts +42 -3
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +68 -1
- package/dist/plugins/manifest/index.test.js +513 -1
- package/dist/plugins/manifest/schemas.d.ts +75 -2
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +27 -3
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +6 -6
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/schemas/Auth.d.ts +6 -6
- package/dist/sdk.d.ts +23 -1
- package/dist/sdk.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -379,7 +379,7 @@ describe("manifestPlugin", () => {
|
|
|
379
379
|
const sdk = createTestSdk();
|
|
380
380
|
const context = sdk.getContext();
|
|
381
381
|
// This should now find the existing "SlackCLIAPI" entry
|
|
382
|
-
const
|
|
382
|
+
const { key: manifestKey } = await context.updateManifestEntry({
|
|
383
383
|
appKey: "slack", // Input is slug
|
|
384
384
|
entry: { implementationName: "SlackCLIAPI", version: "1.30.0" },
|
|
385
385
|
});
|
|
@@ -615,4 +615,516 @@ describe("readManifestFromFile", () => {
|
|
|
615
615
|
expect(result).toBe("some-random-key");
|
|
616
616
|
});
|
|
617
617
|
});
|
|
618
|
+
describe("Action management", () => {
|
|
619
|
+
const mockManifest = {
|
|
620
|
+
apps: {
|
|
621
|
+
slack: {
|
|
622
|
+
implementationName: "SlackCLIAPI",
|
|
623
|
+
version: "1.21.1",
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
};
|
|
627
|
+
let mockApiClient;
|
|
628
|
+
beforeEach(() => {
|
|
629
|
+
vi.clearAllMocks();
|
|
630
|
+
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
631
|
+
mockApiClient = {
|
|
632
|
+
get: vi.fn(),
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
afterEach(() => {
|
|
636
|
+
vi.restoreAllMocks();
|
|
637
|
+
});
|
|
638
|
+
const apiPlugin = () => ({
|
|
639
|
+
context: {
|
|
640
|
+
api: mockApiClient,
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
function createTestSdk(options = {}) {
|
|
644
|
+
return createSdk(options).addPlugin(apiPlugin).addPlugin(manifestPlugin);
|
|
645
|
+
}
|
|
646
|
+
describe("findActionEntry", () => {
|
|
647
|
+
it("should find an existing action by name", () => {
|
|
648
|
+
const manifest = {
|
|
649
|
+
apps: mockManifest.apps,
|
|
650
|
+
actions: {
|
|
651
|
+
"weekly-report": {
|
|
652
|
+
appKey: "slack",
|
|
653
|
+
actionKey: "post_message",
|
|
654
|
+
actionType: "write",
|
|
655
|
+
authenticationId: 123,
|
|
656
|
+
inputs: { channel: "#general" },
|
|
657
|
+
schema: {},
|
|
658
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
const sdk = createTestSdk({ manifest });
|
|
663
|
+
const context = sdk.getContext();
|
|
664
|
+
const action = context.findActionEntry({
|
|
665
|
+
name: "weekly-report",
|
|
666
|
+
manifest,
|
|
667
|
+
});
|
|
668
|
+
expect(action).toEqual({
|
|
669
|
+
appKey: "slack",
|
|
670
|
+
actionKey: "post_message",
|
|
671
|
+
actionType: "write",
|
|
672
|
+
authenticationId: 123,
|
|
673
|
+
inputs: { channel: "#general" },
|
|
674
|
+
schema: {},
|
|
675
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
it("should return null for non-existent action", () => {
|
|
679
|
+
const manifest = {
|
|
680
|
+
apps: mockManifest.apps,
|
|
681
|
+
actions: {},
|
|
682
|
+
};
|
|
683
|
+
const sdk = createTestSdk({ manifest });
|
|
684
|
+
const context = sdk.getContext();
|
|
685
|
+
const action = context.findActionEntry({
|
|
686
|
+
name: "non-existent",
|
|
687
|
+
manifest,
|
|
688
|
+
});
|
|
689
|
+
expect(action).toBeNull();
|
|
690
|
+
});
|
|
691
|
+
it("should return null when manifest has no actions section", () => {
|
|
692
|
+
const manifest = {
|
|
693
|
+
apps: mockManifest.apps,
|
|
694
|
+
};
|
|
695
|
+
const sdk = createTestSdk({ manifest });
|
|
696
|
+
const context = sdk.getContext();
|
|
697
|
+
const action = context.findActionEntry({
|
|
698
|
+
name: "any-action",
|
|
699
|
+
manifest,
|
|
700
|
+
});
|
|
701
|
+
expect(action).toBeNull();
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
describe("hasActionEntry", () => {
|
|
705
|
+
it("should return true for existing action", () => {
|
|
706
|
+
const manifest = {
|
|
707
|
+
apps: mockManifest.apps,
|
|
708
|
+
actions: {
|
|
709
|
+
"weekly-report": {
|
|
710
|
+
appKey: "slack",
|
|
711
|
+
actionKey: "post_message",
|
|
712
|
+
actionType: "write",
|
|
713
|
+
authenticationId: 123,
|
|
714
|
+
inputs: {},
|
|
715
|
+
schema: {},
|
|
716
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
};
|
|
720
|
+
const sdk = createTestSdk({ manifest });
|
|
721
|
+
const context = sdk.getContext();
|
|
722
|
+
const exists = context.hasActionEntry({
|
|
723
|
+
name: "weekly-report",
|
|
724
|
+
manifest,
|
|
725
|
+
});
|
|
726
|
+
expect(exists).toBe(true);
|
|
727
|
+
});
|
|
728
|
+
it("should return false for non-existent action", () => {
|
|
729
|
+
const manifest = {
|
|
730
|
+
apps: mockManifest.apps,
|
|
731
|
+
actions: {},
|
|
732
|
+
};
|
|
733
|
+
const sdk = createTestSdk({ manifest });
|
|
734
|
+
const context = sdk.getContext();
|
|
735
|
+
const exists = context.hasActionEntry({
|
|
736
|
+
name: "non-existent",
|
|
737
|
+
manifest,
|
|
738
|
+
});
|
|
739
|
+
expect(exists).toBe(false);
|
|
740
|
+
});
|
|
741
|
+
it("should return false when manifest has no actions section", () => {
|
|
742
|
+
const manifest = {
|
|
743
|
+
apps: mockManifest.apps,
|
|
744
|
+
};
|
|
745
|
+
const sdk = createTestSdk({ manifest });
|
|
746
|
+
const context = sdk.getContext();
|
|
747
|
+
const exists = context.hasActionEntry({ name: "any-action", manifest });
|
|
748
|
+
expect(exists).toBe(false);
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
describe("listActionEntries", () => {
|
|
752
|
+
it("should return all actions as [name, entry] tuples", async () => {
|
|
753
|
+
const mockManifestContent = JSON.stringify({
|
|
754
|
+
apps: mockManifest.apps,
|
|
755
|
+
actions: {
|
|
756
|
+
"weekly-report": {
|
|
757
|
+
appKey: "slack",
|
|
758
|
+
actionKey: "post_message",
|
|
759
|
+
actionType: "write",
|
|
760
|
+
authenticationId: 123,
|
|
761
|
+
inputs: { channel: "#general" },
|
|
762
|
+
schema: {},
|
|
763
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
764
|
+
},
|
|
765
|
+
"daily-summary": {
|
|
766
|
+
appKey: "slack",
|
|
767
|
+
actionKey: "post_message",
|
|
768
|
+
actionType: "write",
|
|
769
|
+
authenticationId: 123,
|
|
770
|
+
inputs: { channel: "#daily" },
|
|
771
|
+
schema: {},
|
|
772
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
});
|
|
776
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
777
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
778
|
+
const context = sdk.getContext();
|
|
779
|
+
const actions = await context.listActionEntries({
|
|
780
|
+
configPath: ".zapierrc",
|
|
781
|
+
});
|
|
782
|
+
expect(actions).toHaveLength(2);
|
|
783
|
+
expect(actions).toEqual([
|
|
784
|
+
[
|
|
785
|
+
"weekly-report",
|
|
786
|
+
{
|
|
787
|
+
appKey: "slack",
|
|
788
|
+
actionKey: "post_message",
|
|
789
|
+
actionType: "write",
|
|
790
|
+
authenticationId: 123,
|
|
791
|
+
inputs: { channel: "#general" },
|
|
792
|
+
schema: {},
|
|
793
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
794
|
+
},
|
|
795
|
+
],
|
|
796
|
+
[
|
|
797
|
+
"daily-summary",
|
|
798
|
+
{
|
|
799
|
+
appKey: "slack",
|
|
800
|
+
actionKey: "post_message",
|
|
801
|
+
actionType: "write",
|
|
802
|
+
authenticationId: 123,
|
|
803
|
+
inputs: { channel: "#daily" },
|
|
804
|
+
schema: {},
|
|
805
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
806
|
+
},
|
|
807
|
+
],
|
|
808
|
+
]);
|
|
809
|
+
});
|
|
810
|
+
it("should return empty array when no actions exist", async () => {
|
|
811
|
+
const mockManifestContent = JSON.stringify({
|
|
812
|
+
apps: mockManifest.apps,
|
|
813
|
+
});
|
|
814
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
815
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
816
|
+
const context = sdk.getContext();
|
|
817
|
+
const actions = await context.listActionEntries({
|
|
818
|
+
configPath: ".zapierrc",
|
|
819
|
+
});
|
|
820
|
+
expect(actions).toEqual([]);
|
|
821
|
+
});
|
|
822
|
+
it("should use default configPath when not provided", async () => {
|
|
823
|
+
const mockManifestContent = JSON.stringify({
|
|
824
|
+
apps: mockManifest.apps,
|
|
825
|
+
actions: {},
|
|
826
|
+
});
|
|
827
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
828
|
+
const sdk = createTestSdk();
|
|
829
|
+
const context = sdk.getContext();
|
|
830
|
+
await context.listActionEntries();
|
|
831
|
+
expect(mockResolve).toHaveBeenCalledWith(".zapierrc");
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
describe("addActionEntry", () => {
|
|
835
|
+
it("should successfully add a new action", async () => {
|
|
836
|
+
const mockManifestContent = JSON.stringify({
|
|
837
|
+
apps: mockManifest.apps,
|
|
838
|
+
});
|
|
839
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
840
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
841
|
+
const context = sdk.getContext();
|
|
842
|
+
const entry = {
|
|
843
|
+
appKey: "slack",
|
|
844
|
+
actionKey: "post_message",
|
|
845
|
+
actionType: "write",
|
|
846
|
+
authenticationId: 123,
|
|
847
|
+
inputs: { channel: "#general" },
|
|
848
|
+
schema: { type: "object" },
|
|
849
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
850
|
+
};
|
|
851
|
+
const { name, entry: returnedEntry, manifest: updatedManifest, } = await context.addActionEntry({
|
|
852
|
+
name: "weekly-report",
|
|
853
|
+
entry,
|
|
854
|
+
configPath: ".zapierrc",
|
|
855
|
+
});
|
|
856
|
+
expect(name).toBe("weekly-report");
|
|
857
|
+
expect(returnedEntry).toEqual(entry);
|
|
858
|
+
expect(updatedManifest.actions).toEqual({
|
|
859
|
+
"weekly-report": entry,
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
it("should throw error when action name already exists", async () => {
|
|
863
|
+
const mockManifestContent = JSON.stringify({
|
|
864
|
+
apps: mockManifest.apps,
|
|
865
|
+
actions: {
|
|
866
|
+
"weekly-report": {
|
|
867
|
+
appKey: "slack",
|
|
868
|
+
actionKey: "post_message",
|
|
869
|
+
actionType: "write",
|
|
870
|
+
authenticationId: 123,
|
|
871
|
+
inputs: {},
|
|
872
|
+
schema: {},
|
|
873
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
});
|
|
877
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
878
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
879
|
+
const context = sdk.getContext();
|
|
880
|
+
const entry = {
|
|
881
|
+
appKey: "slack",
|
|
882
|
+
actionKey: "post_message",
|
|
883
|
+
actionType: "write",
|
|
884
|
+
authenticationId: 123,
|
|
885
|
+
inputs: {},
|
|
886
|
+
schema: {},
|
|
887
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
888
|
+
};
|
|
889
|
+
await expect(context.addActionEntry({
|
|
890
|
+
name: "weekly-report",
|
|
891
|
+
entry,
|
|
892
|
+
configPath: ".zapierrc",
|
|
893
|
+
})).rejects.toThrow('Action "weekly-report" already exists. Please choose a different name or remove the existing action first.');
|
|
894
|
+
});
|
|
895
|
+
it("should allow duplicate name with skipWrite option", async () => {
|
|
896
|
+
const mockManifestContent = JSON.stringify({
|
|
897
|
+
apps: mockManifest.apps,
|
|
898
|
+
actions: {
|
|
899
|
+
"weekly-report": {
|
|
900
|
+
appKey: "slack",
|
|
901
|
+
actionKey: "post_message",
|
|
902
|
+
actionType: "write",
|
|
903
|
+
authenticationId: 123,
|
|
904
|
+
inputs: {},
|
|
905
|
+
schema: {},
|
|
906
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
});
|
|
910
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
911
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
912
|
+
const context = sdk.getContext();
|
|
913
|
+
const entry = {
|
|
914
|
+
appKey: "slack",
|
|
915
|
+
actionKey: "post_message",
|
|
916
|
+
actionType: "write",
|
|
917
|
+
authenticationId: 456,
|
|
918
|
+
inputs: {},
|
|
919
|
+
schema: {},
|
|
920
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
921
|
+
};
|
|
922
|
+
const { name, entry: returnedEntry } = await context.addActionEntry({
|
|
923
|
+
name: "weekly-report",
|
|
924
|
+
entry,
|
|
925
|
+
configPath: ".zapierrc",
|
|
926
|
+
skipWrite: true,
|
|
927
|
+
});
|
|
928
|
+
expect(name).toBe("weekly-report");
|
|
929
|
+
expect(returnedEntry).toEqual(entry);
|
|
930
|
+
});
|
|
931
|
+
it("should create actions section if it doesn't exist", async () => {
|
|
932
|
+
const mockManifestContent = JSON.stringify({
|
|
933
|
+
apps: mockManifest.apps,
|
|
934
|
+
});
|
|
935
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
936
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
937
|
+
const context = sdk.getContext();
|
|
938
|
+
const entry = {
|
|
939
|
+
appKey: "slack",
|
|
940
|
+
actionKey: "post_message",
|
|
941
|
+
actionType: "write",
|
|
942
|
+
authenticationId: 123,
|
|
943
|
+
inputs: {},
|
|
944
|
+
schema: {},
|
|
945
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
946
|
+
};
|
|
947
|
+
const { manifest: updatedManifest } = await context.addActionEntry({
|
|
948
|
+
name: "first-action",
|
|
949
|
+
entry,
|
|
950
|
+
configPath: ".zapierrc",
|
|
951
|
+
});
|
|
952
|
+
expect(updatedManifest.actions).toBeDefined();
|
|
953
|
+
expect(updatedManifest.actions).toEqual({
|
|
954
|
+
"first-action": entry,
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
describe("deleteActionEntry", () => {
|
|
959
|
+
it("should successfully delete an existing action", async () => {
|
|
960
|
+
const mockManifestContent = JSON.stringify({
|
|
961
|
+
apps: mockManifest.apps,
|
|
962
|
+
actions: {
|
|
963
|
+
"weekly-report": {
|
|
964
|
+
appKey: "slack",
|
|
965
|
+
actionKey: "post_message",
|
|
966
|
+
actionType: "write",
|
|
967
|
+
authenticationId: 123,
|
|
968
|
+
inputs: {},
|
|
969
|
+
schema: {},
|
|
970
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
971
|
+
},
|
|
972
|
+
"daily-summary": {
|
|
973
|
+
appKey: "slack",
|
|
974
|
+
actionKey: "post_message",
|
|
975
|
+
actionType: "write",
|
|
976
|
+
authenticationId: 123,
|
|
977
|
+
inputs: {},
|
|
978
|
+
schema: {},
|
|
979
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
});
|
|
983
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
984
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
985
|
+
const context = sdk.getContext();
|
|
986
|
+
const updatedManifest = await context.deleteActionEntry({
|
|
987
|
+
name: "weekly-report",
|
|
988
|
+
configPath: ".zapierrc",
|
|
989
|
+
});
|
|
990
|
+
expect(updatedManifest.actions).toEqual({
|
|
991
|
+
"daily-summary": {
|
|
992
|
+
appKey: "slack",
|
|
993
|
+
actionKey: "post_message",
|
|
994
|
+
actionType: "write",
|
|
995
|
+
authenticationId: 123,
|
|
996
|
+
inputs: {},
|
|
997
|
+
schema: {},
|
|
998
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
999
|
+
},
|
|
1000
|
+
});
|
|
1001
|
+
expect(updatedManifest.actions?.["weekly-report"]).toBeUndefined();
|
|
1002
|
+
});
|
|
1003
|
+
it("should throw error when action does not exist", async () => {
|
|
1004
|
+
const mockManifestContent = JSON.stringify({
|
|
1005
|
+
apps: mockManifest.apps,
|
|
1006
|
+
actions: {},
|
|
1007
|
+
});
|
|
1008
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1009
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1010
|
+
const context = sdk.getContext();
|
|
1011
|
+
await expect(context.deleteActionEntry({
|
|
1012
|
+
name: "non-existent",
|
|
1013
|
+
configPath: ".zapierrc",
|
|
1014
|
+
})).rejects.toThrow('Action "non-existent" does not exist.');
|
|
1015
|
+
});
|
|
1016
|
+
it("should work with skipWrite option", async () => {
|
|
1017
|
+
const mockManifestContent = JSON.stringify({
|
|
1018
|
+
apps: mockManifest.apps,
|
|
1019
|
+
actions: {
|
|
1020
|
+
"weekly-report": {
|
|
1021
|
+
appKey: "slack",
|
|
1022
|
+
actionKey: "post_message",
|
|
1023
|
+
actionType: "write",
|
|
1024
|
+
authenticationId: 123,
|
|
1025
|
+
inputs: {},
|
|
1026
|
+
schema: {},
|
|
1027
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
});
|
|
1031
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1032
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1033
|
+
const context = sdk.getContext();
|
|
1034
|
+
const updatedManifest = await context.deleteActionEntry({
|
|
1035
|
+
name: "weekly-report",
|
|
1036
|
+
configPath: ".zapierrc",
|
|
1037
|
+
skipWrite: true,
|
|
1038
|
+
});
|
|
1039
|
+
expect(updatedManifest.actions).toEqual({});
|
|
1040
|
+
});
|
|
1041
|
+
it("should handle deleting the last action", async () => {
|
|
1042
|
+
const mockManifestContent = JSON.stringify({
|
|
1043
|
+
apps: mockManifest.apps,
|
|
1044
|
+
actions: {
|
|
1045
|
+
"only-action": {
|
|
1046
|
+
appKey: "slack",
|
|
1047
|
+
actionKey: "post_message",
|
|
1048
|
+
actionType: "write",
|
|
1049
|
+
authenticationId: 123,
|
|
1050
|
+
inputs: {},
|
|
1051
|
+
schema: {},
|
|
1052
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1055
|
+
});
|
|
1056
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1057
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1058
|
+
const context = sdk.getContext();
|
|
1059
|
+
const updatedManifest = await context.deleteActionEntry({
|
|
1060
|
+
name: "only-action",
|
|
1061
|
+
configPath: ".zapierrc",
|
|
1062
|
+
});
|
|
1063
|
+
expect(updatedManifest.actions).toEqual({});
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
describe("action CRUD integration", () => {
|
|
1067
|
+
it("should support full CRUD workflow", async () => {
|
|
1068
|
+
const mockManifestContent = JSON.stringify({
|
|
1069
|
+
apps: mockManifest.apps,
|
|
1070
|
+
});
|
|
1071
|
+
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1072
|
+
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1073
|
+
const context = sdk.getContext();
|
|
1074
|
+
// Create first action
|
|
1075
|
+
const entry1 = {
|
|
1076
|
+
appKey: "slack",
|
|
1077
|
+
actionKey: "post_message",
|
|
1078
|
+
actionType: "write",
|
|
1079
|
+
authenticationId: 123,
|
|
1080
|
+
inputs: { channel: "#general" },
|
|
1081
|
+
schema: {},
|
|
1082
|
+
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1083
|
+
};
|
|
1084
|
+
const { manifest: manifest1 } = await context.addActionEntry({
|
|
1085
|
+
name: "action-1",
|
|
1086
|
+
entry: entry1,
|
|
1087
|
+
skipWrite: true,
|
|
1088
|
+
});
|
|
1089
|
+
// Create second action
|
|
1090
|
+
const entry2 = {
|
|
1091
|
+
appKey: "slack",
|
|
1092
|
+
actionKey: "post_message",
|
|
1093
|
+
actionType: "write",
|
|
1094
|
+
authenticationId: 123,
|
|
1095
|
+
inputs: { channel: "#daily" },
|
|
1096
|
+
schema: {},
|
|
1097
|
+
createdAt: "2025-11-18T13:00:00.000Z",
|
|
1098
|
+
};
|
|
1099
|
+
const { manifest: manifest2 } = await context.addActionEntry({
|
|
1100
|
+
name: "action-2",
|
|
1101
|
+
entry: entry2,
|
|
1102
|
+
manifest: manifest1,
|
|
1103
|
+
skipWrite: true,
|
|
1104
|
+
});
|
|
1105
|
+
// Verify both actions exist
|
|
1106
|
+
expect(context.hasActionEntry({ name: "action-1", manifest: manifest2 })).toBe(true);
|
|
1107
|
+
expect(context.hasActionEntry({ name: "action-2", manifest: manifest2 })).toBe(true);
|
|
1108
|
+
// Find action
|
|
1109
|
+
const foundAction = context.findActionEntry({
|
|
1110
|
+
name: "action-1",
|
|
1111
|
+
manifest: manifest2,
|
|
1112
|
+
});
|
|
1113
|
+
expect(foundAction).toEqual(entry1);
|
|
1114
|
+
// List actions
|
|
1115
|
+
mockReadFile.mockResolvedValue(JSON.stringify(manifest2));
|
|
1116
|
+
const actions = await context.listActionEntries({
|
|
1117
|
+
configPath: ".zapierrc",
|
|
1118
|
+
});
|
|
1119
|
+
expect(actions).toHaveLength(2);
|
|
1120
|
+
// Delete action
|
|
1121
|
+
const manifest3 = await context.deleteActionEntry({
|
|
1122
|
+
name: "action-1",
|
|
1123
|
+
skipWrite: true,
|
|
1124
|
+
});
|
|
1125
|
+
expect(context.hasActionEntry({ name: "action-1", manifest: manifest3 })).toBe(false);
|
|
1126
|
+
expect(context.hasActionEntry({ name: "action-2", manifest: manifest3 })).toBe(true);
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
});
|
|
618
1130
|
});
|
|
@@ -8,15 +8,45 @@ export type ManifestEntry = {
|
|
|
8
8
|
};
|
|
9
9
|
export type GetVersionedImplementationId = (appKey: string) => Promise<string | null>;
|
|
10
10
|
export type GetImplementation = (appKey: string) => Promise<AppItem | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Action entry for storing saved action configurations
|
|
13
|
+
* The key in the actions record IS the user-provided name
|
|
14
|
+
*/
|
|
15
|
+
export declare const ActionEntrySchema: z.ZodObject<{
|
|
16
|
+
appKey: z.ZodString;
|
|
17
|
+
actionKey: z.ZodString;
|
|
18
|
+
actionType: z.ZodString;
|
|
19
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
20
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
22
|
+
createdAt: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
schema: Record<string, unknown>;
|
|
25
|
+
appKey: string;
|
|
26
|
+
actionKey: string;
|
|
27
|
+
actionType: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
authenticationId?: number | null | undefined;
|
|
30
|
+
inputs?: Record<string, unknown> | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
schema: Record<string, unknown>;
|
|
33
|
+
appKey: string;
|
|
34
|
+
actionKey: string;
|
|
35
|
+
actionType: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
authenticationId?: number | null | undefined;
|
|
38
|
+
inputs?: Record<string, unknown> | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export type ActionEntry = z.infer<typeof ActionEntrySchema>;
|
|
11
41
|
export type Manifest = {
|
|
12
42
|
apps: Record<string, ManifestEntry>;
|
|
43
|
+
actions?: Record<string, ActionEntry>;
|
|
13
44
|
};
|
|
14
45
|
export type ResolveAppKeys = ({ appKeys, }: {
|
|
15
46
|
appKeys: string[];
|
|
16
47
|
}) => Promise<ResolvedAppLocator[]>;
|
|
17
48
|
/**
|
|
18
|
-
* Manifest schema for version locking
|
|
19
|
-
* Maps app keys to their locked version information
|
|
49
|
+
* Manifest schema for version locking and saved action configurations
|
|
20
50
|
*/
|
|
21
51
|
export declare const ManifestSchema: z.ZodObject<{
|
|
22
52
|
apps: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -29,16 +59,59 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
29
59
|
version: string;
|
|
30
60
|
implementationName: string;
|
|
31
61
|
}>>;
|
|
62
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
|
+
appKey: z.ZodString;
|
|
64
|
+
actionKey: z.ZodString;
|
|
65
|
+
actionType: z.ZodString;
|
|
66
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
67
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
68
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
69
|
+
createdAt: z.ZodString;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
schema: Record<string, unknown>;
|
|
72
|
+
appKey: string;
|
|
73
|
+
actionKey: string;
|
|
74
|
+
actionType: string;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
authenticationId?: number | null | undefined;
|
|
77
|
+
inputs?: Record<string, unknown> | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
schema: Record<string, unknown>;
|
|
80
|
+
appKey: string;
|
|
81
|
+
actionKey: string;
|
|
82
|
+
actionType: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
authenticationId?: number | null | undefined;
|
|
85
|
+
inputs?: Record<string, unknown> | undefined;
|
|
86
|
+
}>>>;
|
|
32
87
|
}, "strip", z.ZodTypeAny, {
|
|
33
88
|
apps: Record<string, {
|
|
34
89
|
version: string;
|
|
35
90
|
implementationName: string;
|
|
36
91
|
}>;
|
|
92
|
+
actions?: Record<string, {
|
|
93
|
+
schema: Record<string, unknown>;
|
|
94
|
+
appKey: string;
|
|
95
|
+
actionKey: string;
|
|
96
|
+
actionType: string;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
authenticationId?: number | null | undefined;
|
|
99
|
+
inputs?: Record<string, unknown> | undefined;
|
|
100
|
+
}> | undefined;
|
|
37
101
|
}, {
|
|
38
102
|
apps: Record<string, {
|
|
39
103
|
version: string;
|
|
40
104
|
implementationName: string;
|
|
41
105
|
}>;
|
|
106
|
+
actions?: Record<string, {
|
|
107
|
+
schema: Record<string, unknown>;
|
|
108
|
+
appKey: string;
|
|
109
|
+
actionKey: string;
|
|
110
|
+
actionType: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
authenticationId?: number | null | undefined;
|
|
113
|
+
inputs?: Record<string, unknown> | undefined;
|
|
114
|
+
}> | undefined;
|
|
42
115
|
}>;
|
|
43
116
|
export declare const ManifestPluginOptionsSchema: z.ZodObject<{
|
|
44
117
|
manifestPath: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5E,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAkB5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,EAC5B,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkB8C,CAAC;AAE1E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;EAYtC,CAAC"}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Action entry for storing saved action configurations
|
|
5
|
+
* The key in the actions record IS the user-provided name
|
|
6
|
+
*/
|
|
7
|
+
export const ActionEntrySchema = z.object({
|
|
8
|
+
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
9
|
+
actionKey: z.string().describe("Action key identifier"),
|
|
10
|
+
actionType: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Action type (e.g., 'read', 'write', 'search')"),
|
|
13
|
+
authenticationId: z
|
|
14
|
+
.number()
|
|
15
|
+
.nullable()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Authentication ID used"),
|
|
18
|
+
inputs: z.record(z.unknown()).optional().describe("Resolved input values"),
|
|
19
|
+
schema: z
|
|
20
|
+
.record(z.unknown())
|
|
21
|
+
.describe("Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"),
|
|
22
|
+
createdAt: z.string().describe("ISO 8601 timestamp when created"),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Manifest schema for version locking and saved action configurations
|
|
6
26
|
*/
|
|
7
27
|
export const ManifestSchema = z
|
|
8
28
|
.object({
|
|
@@ -12,8 +32,12 @@ export const ManifestSchema = z
|
|
|
12
32
|
.describe("Base implementation name without version (e.g., 'SlackCLIAPI')"),
|
|
13
33
|
version: z.string().describe("Version string (e.g., '1.21.1')"),
|
|
14
34
|
})),
|
|
35
|
+
actions: z
|
|
36
|
+
.record(z.string(), ActionEntrySchema)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Saved action configurations with their schemas"),
|
|
15
39
|
})
|
|
16
|
-
.describe("Manifest
|
|
40
|
+
.describe("Manifest for app version locking and action configurations");
|
|
17
41
|
export const ManifestPluginOptionsSchema = z.object({
|
|
18
42
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
19
43
|
manifest: z
|