@automate.ax/api-contract 0.75.0 → 0.77.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.
Files changed (91) hide show
  1. package/dist/account.d.ts +373 -8
  2. package/dist/account.js +245 -14
  3. package/dist/api-key.d.ts +17 -9
  4. package/dist/api-key.js +4 -4
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +1 -1
  7. package/dist/authorization.d.ts +5 -5
  8. package/dist/authorization.js +21 -5
  9. package/dist/automation.d.ts +171 -6
  10. package/dist/automation.js +83 -3
  11. package/dist/deployment.d.ts +166 -10
  12. package/dist/deployment.js +113 -44
  13. package/dist/errors.d.ts +1 -1
  14. package/dist/errors.js +1 -1
  15. package/dist/events/airtable.d.ts +1 -1
  16. package/dist/events/airtable.js +1 -1
  17. package/dist/events/asana.d.ts +1 -1
  18. package/dist/events/asana.js +1 -1
  19. package/dist/events/brevo.d.ts +1 -1
  20. package/dist/events/brevo.js +1 -1
  21. package/dist/events/github.d.ts +1 -1
  22. package/dist/events/github.js +1 -1
  23. package/dist/events/gmail.d.ts +1 -1
  24. package/dist/events/gmail.js +1 -1
  25. package/dist/events/google-calendar.d.ts +1 -1
  26. package/dist/events/google-calendar.js +1 -1
  27. package/dist/events/google-forms.d.ts +1 -1
  28. package/dist/events/google-forms.js +1 -1
  29. package/dist/events/google-meet.d.ts +20 -0
  30. package/dist/events/google-meet.js +38 -0
  31. package/dist/events/index.d.ts +17 -0
  32. package/dist/events/index.js +2 -0
  33. package/dist/events/linear.d.ts +1 -1
  34. package/dist/events/linear.js +1 -1
  35. package/dist/events/mailhook.d.ts +1 -1
  36. package/dist/events/mailhook.js +1 -1
  37. package/dist/events/microsoft.d.ts +1 -1
  38. package/dist/events/microsoft.js +1 -1
  39. package/dist/events/resend.d.ts +1 -1
  40. package/dist/events/resend.js +1 -1
  41. package/dist/events/slack.d.ts +1 -1
  42. package/dist/events/slack.js +1 -1
  43. package/dist/events/trello.d.ts +1 -1
  44. package/dist/events/trello.js +1 -1
  45. package/dist/events/vercel.d.ts +1 -1
  46. package/dist/events/vercel.js +1 -1
  47. package/dist/events/whatsapp.d.ts +1 -1
  48. package/dist/events/whatsapp.js +1 -1
  49. package/dist/execution-data.d.ts +90 -0
  50. package/dist/execution-data.js +53 -0
  51. package/dist/index.d.ts +2022 -392
  52. package/dist/index.js +30 -9
  53. package/dist/org.d.ts +44 -36
  54. package/dist/org.js +6 -6
  55. package/dist/project.d.ts +24 -16
  56. package/dist/project.js +6 -6
  57. package/dist/runtime.d.ts +38 -3
  58. package/dist/runtime.js +54 -2
  59. package/dist/schemas.d.ts +21 -1
  60. package/dist/schemas.js +20 -1
  61. package/package.json +17 -6
  62. package/src/account.ts +263 -18
  63. package/src/api-key.ts +8 -4
  64. package/src/auth.ts +1 -1
  65. package/src/authorization.ts +23 -5
  66. package/src/automation.ts +90 -3
  67. package/src/deployment.ts +119 -44
  68. package/src/errors.ts +1 -1
  69. package/src/events/airtable.ts +1 -1
  70. package/src/events/asana.ts +1 -1
  71. package/src/events/brevo.ts +1 -1
  72. package/src/events/github.ts +1 -1
  73. package/src/events/gmail.ts +1 -1
  74. package/src/events/google-calendar.ts +1 -1
  75. package/src/events/google-forms.ts +1 -1
  76. package/src/events/google-meet.ts +48 -0
  77. package/src/events/index.ts +2 -0
  78. package/src/events/linear.ts +1 -1
  79. package/src/events/mailhook.ts +1 -1
  80. package/src/events/microsoft.ts +1 -1
  81. package/src/events/resend.ts +1 -1
  82. package/src/events/slack.ts +1 -1
  83. package/src/events/trello.ts +1 -1
  84. package/src/events/vercel.ts +1 -1
  85. package/src/events/whatsapp.ts +1 -1
  86. package/src/execution-data.ts +69 -0
  87. package/src/index.ts +61 -8
  88. package/src/org.ts +10 -6
  89. package/src/project.ts +10 -6
  90. package/src/runtime.ts +68 -2
  91. package/src/schemas.ts +23 -1
package/src/runtime.ts CHANGED
@@ -2,14 +2,22 @@ import { encodableSchema } from "@automate.ax/codec"
2
2
  import type { GatewayModelId } from "@ai-sdk/gateway"
3
3
  import { oc } from "@orpc/contract"
4
4
  import stableStringify from "fast-json-stable-stringify"
5
- import { z } from "zod"
5
+ import * as z from "zod"
6
6
  import { automationErrorSchema } from "./errors"
7
7
 
8
+ export type { GatewayModelId } from "@ai-sdk/gateway"
9
+
8
10
  /** Default model used by the platform Vercel AI Gateway account. */
9
11
  export const DEFAULT_GATEWAY_MODEL_ID =
10
12
  "openai/gpt-4.1-nano" satisfies GatewayModelId
11
13
  export const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default"
12
14
  export const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$"
15
+ export const AUTOMATION_LOG_MAX_ENTRIES = 1_000
16
+ export const AUTOMATION_TRACE_MAX_SPANS = 250
17
+ export const AUTOMATION_OBSERVABILITY_MAX_FIELDS = 64
18
+ export const AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES = 64 * 1_024
19
+ export const AUTOMATION_LOG_MAX_MESSAGE_LENGTH = 16_384
20
+ export const AUTOMATION_TRACE_MAX_NAME_LENGTH = 256
13
21
 
14
22
  const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive()
15
23
  const HOOK_SCOPE_PATH_SCHEMA = z
@@ -18,6 +26,23 @@ const HOOK_SCOPE_PATH_SCHEMA = z
18
26
  .nonnegative()
19
27
  .array()
20
28
  .default([])
29
+ const OBSERVABILITY_FIELDS_SCHEMA = z
30
+ .record(z.string().min(1).max(128), encodableSchema)
31
+ .refine(
32
+ (fields) =>
33
+ Object.keys(fields).length <= AUTOMATION_OBSERVABILITY_MAX_FIELDS,
34
+ `Observability fields may contain at most ${AUTOMATION_OBSERVABILITY_MAX_FIELDS} entries.`,
35
+ )
36
+ const LOG_INDEX_SCHEMA = z
37
+ .number()
38
+ .int()
39
+ .min(0)
40
+ .max(AUTOMATION_LOG_MAX_ENTRIES - 1)
41
+ const TRACE_SPAN_INDEX_SCHEMA = z
42
+ .number()
43
+ .int()
44
+ .min(0)
45
+ .max(AUTOMATION_TRACE_MAX_SPANS - 1)
21
46
 
22
47
  const AUTOMATION_INVOCATION_RUN_AT_SCHEMA = z.union([
23
48
  z.date(),
@@ -683,6 +708,24 @@ export const runtimeContract = {
683
708
  ]),
684
709
  )
685
710
  .output(z.void()),
711
+ completeTraceSpan: oc
712
+ .input(
713
+ z
714
+ .object({
715
+ completedAt: z.date(),
716
+ spanIndex: TRACE_SPAN_INDEX_SCHEMA,
717
+ })
718
+ .and(
719
+ z.union([
720
+ z.object({ status: z.literal("succeeded") }),
721
+ z.object({
722
+ failure: automationErrorSchema,
723
+ status: z.literal("failed"),
724
+ }),
725
+ ]),
726
+ ),
727
+ )
728
+ .output(z.void()),
686
729
  generate: oc
687
730
  .input(RUNTIME_GENERATION_INPUT_SCHEMA)
688
731
  .output(generationResultSchema),
@@ -713,7 +756,7 @@ export const runtimeContract = {
713
756
  )
714
757
  .output(
715
758
  z.object({
716
- connectionId: z.string().min(1),
759
+ connectionMethodId: z.string().min(1),
717
760
  secret: z.record(z.string(), z.unknown()),
718
761
  serviceId: z.string(),
719
762
  }),
@@ -729,6 +772,29 @@ export const runtimeContract = {
729
772
  }),
730
773
  )
731
774
  .output(z.void()),
775
+ sendLog: oc
776
+ .input(
777
+ z.object({
778
+ fields: OBSERVABILITY_FIELDS_SCHEMA.optional(),
779
+ level: z.enum(["debug", "info", "warn", "error"]),
780
+ logIndex: LOG_INDEX_SCHEMA,
781
+ message: z.string().min(1).max(AUTOMATION_LOG_MAX_MESSAGE_LENGTH),
782
+ spanIndex: TRACE_SPAN_INDEX_SCHEMA.optional(),
783
+ timestamp: z.date(),
784
+ }),
785
+ )
786
+ .output(z.void()),
787
+ startTraceSpan: oc
788
+ .input(
789
+ z.object({
790
+ attributes: OBSERVABILITY_FIELDS_SCHEMA.optional(),
791
+ name: z.string().min(1).max(AUTOMATION_TRACE_MAX_NAME_LENGTH),
792
+ parentSpanIndex: TRACE_SPAN_INDEX_SCHEMA.optional(),
793
+ spanIndex: TRACE_SPAN_INDEX_SCHEMA,
794
+ startedAt: z.date(),
795
+ }),
796
+ )
797
+ .output(z.void()),
732
798
  sendEmail: oc
733
799
  .input(
734
800
  z
package/src/schemas.ts CHANGED
@@ -1,3 +1,25 @@
1
- import { z } from "zod"
1
+ import * as z from "zod"
2
+
3
+ export const cursorPaginationInputSchema = z.object({
4
+ cursor: z.string().min(1).optional(),
5
+ limit: z.number().int().min(1).max(100).default(50),
6
+ })
7
+
8
+ export const cursorPageInfoSchema = z.object({
9
+ hasMore: z.boolean(),
10
+ nextCursor: z.string().nullable(),
11
+ })
12
+
13
+ /**
14
+ * Builds the common cursor-paginated collection response.
15
+ *
16
+ * @param itemSchema - Schema for one collection item.
17
+ */
18
+ export function cursorPageOutputSchema<T extends z.ZodType>(itemSchema: T) {
19
+ return z.object({
20
+ items: itemSchema.array(),
21
+ pageInfo: cursorPageInfoSchema,
22
+ })
23
+ }
2
24
 
3
25
  export const reasonableNameSchema = z.string().min(1).max(255).trim()