@automate.ax/api-contract 0.12.0 → 0.14.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.
@@ -1,4 +1,9 @@
1
1
  export declare const eventsContract: {
2
+ slackEvent: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
3
+ type: import("zod").ZodString;
4
+ }, import("zod/v4/core").$loose>, import("zod").ZodObject<{
5
+ challenge: import("zod").ZodOptional<import("zod").ZodString>;
6
+ }, import("zod/v4/core").$strip>, Record<never, never>, Record<never, never>>;
2
7
  gmailPush: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
3
8
  message: import("zod").ZodObject<{
4
9
  data: import("zod").ZodString;
@@ -1,8 +1,10 @@
1
1
  import { googleCalendarEventsContract } from "./google-calendar.js";
2
2
  import { googleFormsEventsContract } from "./google-forms.js";
3
3
  import { gmailEventsContract } from "./gmail.js";
4
+ import { slackEventsContract } from "./slack.js";
4
5
  export const eventsContract = {
5
6
  ...googleCalendarEventsContract,
6
7
  ...googleFormsEventsContract,
7
8
  ...gmailEventsContract,
9
+ ...slackEventsContract,
8
10
  };
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ export declare const slackEventsContract: {
3
+ slackEvent: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
4
+ type: z.ZodString;
5
+ }, z.core.$loose>, z.ZodObject<{
6
+ challenge: z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
8
+ };
@@ -0,0 +1,22 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ export const slackEventsContract = {
4
+ slackEvent: oc
5
+ .route({
6
+ method: "POST",
7
+ path: "/events/slack",
8
+ operationId: "receiveSlackEvent",
9
+ summary: "Receive a Slack event",
10
+ description: "Receives and authenticates callbacks delivered by the Slack Events API.",
11
+ tags: ["Events"],
12
+ successStatus: 200,
13
+ })
14
+ .input(z.looseObject({
15
+ /** Slack callback category. */
16
+ type: z.string(),
17
+ }))
18
+ .output(z.object({
19
+ /** Request URL verification challenge, when Slack is configuring it. */
20
+ challenge: z.string().optional(),
21
+ })),
22
+ };
package/dist/index.d.ts CHANGED
@@ -742,6 +742,11 @@ export declare const contract: {
742
742
  }, import("zod/v4/core").$strip>, import("zod").ZodVoid, Record<never, never>, Record<never, never>>;
743
743
  };
744
744
  events: {
745
+ slackEvent: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
746
+ type: import("zod").ZodString;
747
+ }, import("zod/v4/core").$loose>, import("zod").ZodObject<{
748
+ challenge: import("zod").ZodOptional<import("zod").ZodString>;
749
+ }, import("zod/v4/core").$strip>, Record<never, never>, Record<never, never>>;
745
750
  gmailPush: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
746
751
  message: import("zod").ZodObject<{
747
752
  data: import("zod").ZodString;
@@ -777,16 +782,38 @@ export declare const contract: {
777
782
  slot: import("zod").ZodNumber;
778
783
  }, import("zod/v4/core").$strip>>>;
779
784
  }, import("zod/v4/core").$strip>, import("zod").ZodVoid, Record<never, never>, Record<never, never>>;
780
- completeInvocation: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
785
+ completeInvocation: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
786
+ status: import("zod").ZodLiteral<"closed">;
787
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
788
+ failure: import("zod").ZodObject<{
789
+ message: import("zod").ZodString;
790
+ name: import("zod").ZodString;
791
+ }, import("zod/v4/core").$strip>;
792
+ status: import("zod").ZodLiteral<"failed">;
793
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
781
794
  output: import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
782
- }, import("zod/v4/core").$strip>, import("zod").ZodVoid, Record<never, never>, Record<never, never>>;
795
+ status: import("zod").ZodLiteral<"succeeded">;
796
+ }, import("zod/v4/core").$strip>], "status">, import("zod").ZodVoid, Record<never, never>, Record<never, never>>;
783
797
  loadInvocation: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, import("zod").ZodObject<{
784
798
  context: import("zod").ZodObject<{
785
- actionOutputs: import("zod").ZodArray<import("zod").ZodObject<{
799
+ actionOutputs: import("zod").ZodArray<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
800
+ actionInvocationId: import("zod").ZodString;
801
+ slot: import("zod").ZodNumber;
802
+ status: import("zod").ZodLiteral<"closed">;
803
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
804
+ actionInvocationId: import("zod").ZodString;
805
+ failure: import("zod").ZodObject<{
806
+ message: import("zod").ZodString;
807
+ name: import("zod").ZodString;
808
+ }, import("zod/v4/core").$strip>;
809
+ slot: import("zod").ZodNumber;
810
+ status: import("zod").ZodLiteral<"failed">;
811
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
786
812
  actionInvocationId: import("zod").ZodString;
787
813
  output: import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
788
814
  slot: import("zod").ZodNumber;
789
- }, import("zod/v4/core").$strip>>;
815
+ status: import("zod").ZodLiteral<"succeeded">;
816
+ }, import("zod/v4/core").$strip>], "status">>;
790
817
  contextId: import("zod").ZodString;
791
818
  events: import("zod").ZodArray<import("zod").ZodObject<{
792
819
  automationEventId: import("zod").ZodString;
@@ -806,6 +833,11 @@ export declare const contract: {
806
833
  inputHash: import("zod").ZodString;
807
834
  name: import("zod").ZodString;
808
835
  slot: import("zod").ZodNumber;
836
+ status: import("zod").ZodEnum<{
837
+ succeeded: "succeeded";
838
+ failed: "failed";
839
+ closed: "closed";
840
+ }>;
809
841
  }, import("zod/v4/core").$strip>>;
810
842
  contextId: import("zod").ZodString;
811
843
  events: import("zod").ZodArray<import("zod").ZodObject<{
package/dist/runtime.d.ts CHANGED
@@ -10,16 +10,38 @@ export declare const runtimeContract: {
10
10
  slot: z.ZodNumber;
11
11
  }, z.core.$strip>>>;
12
12
  }, z.core.$strip>, z.ZodVoid, Record<never, never>, Record<never, never>>;
13
- completeInvocation: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
13
+ completeInvocation: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodDiscriminatedUnion<[z.ZodObject<{
14
+ status: z.ZodLiteral<"closed">;
15
+ }, z.core.$strip>, z.ZodObject<{
16
+ failure: z.ZodObject<{
17
+ message: z.ZodString;
18
+ name: z.ZodString;
19
+ }, z.core.$strip>;
20
+ status: z.ZodLiteral<"failed">;
21
+ }, z.core.$strip>, z.ZodObject<{
14
22
  output: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
15
- }, z.core.$strip>, z.ZodVoid, Record<never, never>, Record<never, never>>;
23
+ status: z.ZodLiteral<"succeeded">;
24
+ }, z.core.$strip>], "status">, z.ZodVoid, Record<never, never>, Record<never, never>>;
16
25
  loadInvocation: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
17
26
  context: z.ZodObject<{
18
- actionOutputs: z.ZodArray<z.ZodObject<{
27
+ actionOutputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
28
+ actionInvocationId: z.ZodString;
29
+ slot: z.ZodNumber;
30
+ status: z.ZodLiteral<"closed">;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ actionInvocationId: z.ZodString;
33
+ failure: z.ZodObject<{
34
+ message: z.ZodString;
35
+ name: z.ZodString;
36
+ }, z.core.$strip>;
37
+ slot: z.ZodNumber;
38
+ status: z.ZodLiteral<"failed">;
39
+ }, z.core.$strip>, z.ZodObject<{
19
40
  actionInvocationId: z.ZodString;
20
41
  output: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
21
42
  slot: z.ZodNumber;
22
- }, z.core.$strip>>;
43
+ status: z.ZodLiteral<"succeeded">;
44
+ }, z.core.$strip>], "status">>;
23
45
  contextId: z.ZodString;
24
46
  events: z.ZodArray<z.ZodObject<{
25
47
  automationEventId: z.ZodString;
@@ -39,6 +61,11 @@ export declare const runtimeContract: {
39
61
  inputHash: z.ZodString;
40
62
  name: z.ZodString;
41
63
  slot: z.ZodNumber;
64
+ status: z.ZodEnum<{
65
+ succeeded: "succeeded";
66
+ failed: "failed";
67
+ closed: "closed";
68
+ }>;
42
69
  }, z.core.$strip>>;
43
70
  contextId: z.ZodString;
44
71
  events: z.ZodArray<z.ZodObject<{
package/dist/runtime.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import { encodableSchema } from "@automate.ax/codec";
2
2
  import { oc } from "@orpc/contract";
3
3
  import { z } from "zod";
4
+ const SIGNAL_FAILURE_SCHEMA = z.object({
5
+ message: z.string(),
6
+ name: z.string(),
7
+ });
8
+ const TERMINAL_ACTION_STATUS_SCHEMA = z.enum(["closed", "failed", "succeeded"]);
4
9
  export const runtimeContract = {
5
10
  commit: oc
6
11
  .input(z.object({
@@ -18,18 +23,40 @@ export const runtimeContract = {
18
23
  }))
19
24
  .output(z.void()),
20
25
  completeInvocation: oc
21
- .input(z.object({
22
- output: encodableSchema,
23
- }))
26
+ .input(z.discriminatedUnion("status", [
27
+ z.object({ status: z.literal("closed") }),
28
+ z.object({
29
+ failure: SIGNAL_FAILURE_SCHEMA,
30
+ status: z.literal("failed"),
31
+ }),
32
+ z.object({
33
+ output: encodableSchema,
34
+ status: z.literal("succeeded"),
35
+ }),
36
+ ]))
24
37
  .output(z.void()),
25
38
  loadInvocation: oc.output(z.object({
26
39
  context: z.object({
27
40
  actionOutputs: z
28
- .object({
29
- actionInvocationId: z.string(),
30
- output: encodableSchema,
31
- slot: z.number().int(),
32
- })
41
+ .discriminatedUnion("status", [
42
+ z.object({
43
+ actionInvocationId: z.string(),
44
+ slot: z.number().int(),
45
+ status: z.literal("closed"),
46
+ }),
47
+ z.object({
48
+ actionInvocationId: z.string(),
49
+ failure: SIGNAL_FAILURE_SCHEMA,
50
+ slot: z.number().int(),
51
+ status: z.literal("failed"),
52
+ }),
53
+ z.object({
54
+ actionInvocationId: z.string(),
55
+ output: encodableSchema,
56
+ slot: z.number().int(),
57
+ status: z.literal("succeeded"),
58
+ }),
59
+ ])
33
60
  .array(),
34
61
  contextId: z.string(),
35
62
  events: z
@@ -53,6 +80,7 @@ export const runtimeContract = {
53
80
  inputHash: z.string(),
54
81
  name: z.string(),
55
82
  slot: z.number().int(),
83
+ status: TERMINAL_ACTION_STATUS_SCHEMA,
56
84
  })
57
85
  .array(),
58
86
  contextId: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/api-contract",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Public oRPC contract for the Automate.ax API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@automate.ax/codec": "0.12.0",
29
+ "@automate.ax/codec": "0.14.0",
30
30
  "@orpc/contract": "1.13.14",
31
31
  "zod": "^4.3.6"
32
32
  },
@@ -1,9 +1,11 @@
1
1
  import { googleCalendarEventsContract } from "./google-calendar"
2
2
  import { googleFormsEventsContract } from "./google-forms"
3
3
  import { gmailEventsContract } from "./gmail"
4
+ import { slackEventsContract } from "./slack"
4
5
 
5
6
  export const eventsContract = {
6
7
  ...googleCalendarEventsContract,
7
8
  ...googleFormsEventsContract,
8
9
  ...gmailEventsContract,
10
+ ...slackEventsContract,
9
11
  }
@@ -0,0 +1,28 @@
1
+ import { oc } from "@orpc/contract"
2
+ import { z } from "zod"
3
+
4
+ export const slackEventsContract = {
5
+ slackEvent: oc
6
+ .route({
7
+ method: "POST",
8
+ path: "/events/slack",
9
+ operationId: "receiveSlackEvent",
10
+ summary: "Receive a Slack event",
11
+ description:
12
+ "Receives and authenticates callbacks delivered by the Slack Events API.",
13
+ tags: ["Events"],
14
+ successStatus: 200,
15
+ })
16
+ .input(
17
+ z.looseObject({
18
+ /** Slack callback category. */
19
+ type: z.string(),
20
+ }),
21
+ )
22
+ .output(
23
+ z.object({
24
+ /** Request URL verification challenge, when Slack is configuring it. */
25
+ challenge: z.string().optional(),
26
+ }),
27
+ ),
28
+ }
package/src/runtime.ts CHANGED
@@ -2,6 +2,13 @@ import { encodableSchema } from "@automate.ax/codec"
2
2
  import { oc } from "@orpc/contract"
3
3
  import { z } from "zod"
4
4
 
5
+ const SIGNAL_FAILURE_SCHEMA = z.object({
6
+ message: z.string(),
7
+ name: z.string(),
8
+ })
9
+
10
+ const TERMINAL_ACTION_STATUS_SCHEMA = z.enum(["closed", "failed", "succeeded"])
11
+
5
12
  export const runtimeContract = {
6
13
  commit: oc
7
14
  .input(
@@ -22,20 +29,42 @@ export const runtimeContract = {
22
29
  .output(z.void()),
23
30
  completeInvocation: oc
24
31
  .input(
25
- z.object({
26
- output: encodableSchema,
27
- }),
32
+ z.discriminatedUnion("status", [
33
+ z.object({ status: z.literal("closed") }),
34
+ z.object({
35
+ failure: SIGNAL_FAILURE_SCHEMA,
36
+ status: z.literal("failed"),
37
+ }),
38
+ z.object({
39
+ output: encodableSchema,
40
+ status: z.literal("succeeded"),
41
+ }),
42
+ ]),
28
43
  )
29
44
  .output(z.void()),
30
45
  loadInvocation: oc.output(
31
46
  z.object({
32
47
  context: z.object({
33
48
  actionOutputs: z
34
- .object({
35
- actionInvocationId: z.string(),
36
- output: encodableSchema,
37
- slot: z.number().int(),
38
- })
49
+ .discriminatedUnion("status", [
50
+ z.object({
51
+ actionInvocationId: z.string(),
52
+ slot: z.number().int(),
53
+ status: z.literal("closed"),
54
+ }),
55
+ z.object({
56
+ actionInvocationId: z.string(),
57
+ failure: SIGNAL_FAILURE_SCHEMA,
58
+ slot: z.number().int(),
59
+ status: z.literal("failed"),
60
+ }),
61
+ z.object({
62
+ actionInvocationId: z.string(),
63
+ output: encodableSchema,
64
+ slot: z.number().int(),
65
+ status: z.literal("succeeded"),
66
+ }),
67
+ ])
39
68
  .array(),
40
69
  contextId: z.string(),
41
70
  events: z
@@ -61,6 +90,7 @@ export const runtimeContract = {
61
90
  inputHash: z.string(),
62
91
  name: z.string(),
63
92
  slot: z.number().int(),
93
+ status: TERMINAL_ACTION_STATUS_SCHEMA,
64
94
  })
65
95
  .array(),
66
96
  contextId: z.string(),