automate.ax 0.3.1 → 0.4.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 (169) hide show
  1. package/README.md +58 -6
  2. package/dist/automation/account-planning.d.ts +17 -0
  3. package/dist/automation/account-planning.d.ts.map +1 -0
  4. package/dist/automation/account-planning.js +48 -0
  5. package/dist/automation/actions.d.ts.map +1 -1
  6. package/dist/automation/actions.js +3 -36
  7. package/dist/cli/usage.d.ts +2 -1
  8. package/dist/cli/usage.d.ts.map +1 -1
  9. package/dist/cli/usage.js +2 -1
  10. package/dist/components/core/actions.d.ts +29 -0
  11. package/dist/components/core/actions.d.ts.map +1 -0
  12. package/dist/components/core/actions.js +57 -0
  13. package/dist/components/core/index.d.ts +3 -0
  14. package/dist/components/core/index.d.ts.map +1 -0
  15. package/dist/components/core/index.js +2 -0
  16. package/dist/components/core/triggers.d.ts +21 -0
  17. package/dist/components/core/triggers.d.ts.map +1 -0
  18. package/dist/components/core/triggers.js +9 -0
  19. package/dist/components/gmail/actions/add-label.d.ts +12 -0
  20. package/dist/components/gmail/actions/add-label.d.ts.map +1 -0
  21. package/dist/components/gmail/actions/add-label.js +33 -0
  22. package/dist/components/gmail/actions/archive.d.ts +9 -0
  23. package/dist/components/gmail/actions/archive.d.ts.map +1 -0
  24. package/dist/components/gmail/actions/archive.js +7 -0
  25. package/dist/components/gmail/actions/create-label.d.ts +43 -0
  26. package/dist/components/gmail/actions/create-label.d.ts.map +1 -0
  27. package/dist/components/gmail/actions/create-label.js +27 -0
  28. package/dist/components/gmail/actions/delete-draft.d.ts +6 -0
  29. package/dist/components/gmail/actions/delete-draft.d.ts.map +1 -0
  30. package/dist/components/gmail/actions/delete-draft.js +20 -0
  31. package/dist/components/gmail/actions/delete-label.d.ts +6 -0
  32. package/dist/components/gmail/actions/delete-label.d.ts.map +1 -0
  33. package/dist/components/gmail/actions/delete-label.js +22 -0
  34. package/dist/components/gmail/actions/draft-email.d.ts +66 -0
  35. package/dist/components/gmail/actions/draft-email.d.ts.map +1 -0
  36. package/dist/components/gmail/actions/draft-email.js +32 -0
  37. package/dist/components/gmail/actions/draft-reply.d.ts +67 -0
  38. package/dist/components/gmail/actions/draft-reply.d.ts.map +1 -0
  39. package/dist/components/gmail/actions/draft-reply.js +42 -0
  40. package/dist/components/gmail/actions/forward.d.ts +67 -0
  41. package/dist/components/gmail/actions/forward.d.ts.map +1 -0
  42. package/dist/components/gmail/actions/forward.js +130 -0
  43. package/dist/components/gmail/actions/get-draft.d.ts +66 -0
  44. package/dist/components/gmail/actions/get-draft.d.ts.map +1 -0
  45. package/dist/components/gmail/actions/get-draft.js +28 -0
  46. package/dist/components/gmail/actions/get-message.d.ts +68 -0
  47. package/dist/components/gmail/actions/get-message.d.ts.map +1 -0
  48. package/dist/components/gmail/actions/get-message.js +24 -0
  49. package/dist/components/gmail/actions/get-messages.d.ts +63 -0
  50. package/dist/components/gmail/actions/get-messages.d.ts.map +1 -0
  51. package/dist/components/gmail/actions/get-messages.js +23 -0
  52. package/dist/components/gmail/actions/get-profile.d.ts +8 -0
  53. package/dist/components/gmail/actions/get-profile.d.ts.map +1 -0
  54. package/dist/components/gmail/actions/get-profile.js +23 -0
  55. package/dist/components/gmail/actions/get-raw-message.d.ts +11 -0
  56. package/dist/components/gmail/actions/get-raw-message.d.ts.map +1 -0
  57. package/dist/components/gmail/actions/get-raw-message.js +28 -0
  58. package/dist/components/gmail/actions/get-thread.d.ts +67 -0
  59. package/dist/components/gmail/actions/get-thread.d.ts.map +1 -0
  60. package/dist/components/gmail/actions/get-thread.js +28 -0
  61. package/dist/components/gmail/actions/has-label.d.ts +7 -0
  62. package/dist/components/gmail/actions/has-label.d.ts.map +1 -0
  63. package/dist/components/gmail/actions/has-label.js +23 -0
  64. package/dist/components/gmail/actions/index.d.ts +42 -0
  65. package/dist/components/gmail/actions/index.d.ts.map +1 -0
  66. package/dist/components/gmail/actions/index.js +41 -0
  67. package/dist/components/gmail/actions/is-important.d.ts +5 -0
  68. package/dist/components/gmail/actions/is-important.d.ts.map +1 -0
  69. package/dist/components/gmail/actions/is-important.js +3 -0
  70. package/dist/components/gmail/actions/is-starred.d.ts +5 -0
  71. package/dist/components/gmail/actions/is-starred.d.ts.map +1 -0
  72. package/dist/components/gmail/actions/is-starred.js +3 -0
  73. package/dist/components/gmail/actions/is-unread.d.ts +5 -0
  74. package/dist/components/gmail/actions/is-unread.d.ts.map +1 -0
  75. package/dist/components/gmail/actions/is-unread.js +3 -0
  76. package/dist/components/gmail/actions/list-labels.d.ts +27 -0
  77. package/dist/components/gmail/actions/list-labels.d.ts.map +1 -0
  78. package/dist/components/gmail/actions/list-labels.js +15 -0
  79. package/dist/components/gmail/actions/mark-as-important.d.ts +5 -0
  80. package/dist/components/gmail/actions/mark-as-important.d.ts.map +1 -0
  81. package/dist/components/gmail/actions/mark-as-important.js +3 -0
  82. package/dist/components/gmail/actions/mark-as-not-spam.d.ts +5 -0
  83. package/dist/components/gmail/actions/mark-as-not-spam.d.ts.map +1 -0
  84. package/dist/components/gmail/actions/mark-as-not-spam.js +3 -0
  85. package/dist/components/gmail/actions/mark-as-read.d.ts +5 -0
  86. package/dist/components/gmail/actions/mark-as-read.d.ts.map +1 -0
  87. package/dist/components/gmail/actions/mark-as-read.js +3 -0
  88. package/dist/components/gmail/actions/mark-as-spam.d.ts +5 -0
  89. package/dist/components/gmail/actions/mark-as-spam.d.ts.map +1 -0
  90. package/dist/components/gmail/actions/mark-as-spam.js +3 -0
  91. package/dist/components/gmail/actions/mark-as-unread.d.ts +5 -0
  92. package/dist/components/gmail/actions/mark-as-unread.d.ts.map +1 -0
  93. package/dist/components/gmail/actions/mark-as-unread.js +3 -0
  94. package/dist/components/gmail/actions/modify-labels.d.ts +12 -0
  95. package/dist/components/gmail/actions/modify-labels.d.ts.map +1 -0
  96. package/dist/components/gmail/actions/modify-labels.js +41 -0
  97. package/dist/components/gmail/actions/move-to-inbox.d.ts +5 -0
  98. package/dist/components/gmail/actions/move-to-inbox.d.ts.map +1 -0
  99. package/dist/components/gmail/actions/move-to-inbox.js +3 -0
  100. package/dist/components/gmail/actions/remove-label.d.ts +12 -0
  101. package/dist/components/gmail/actions/remove-label.d.ts.map +1 -0
  102. package/dist/components/gmail/actions/remove-label.js +33 -0
  103. package/dist/components/gmail/actions/reply-thread.d.ts +65 -0
  104. package/dist/components/gmail/actions/reply-thread.d.ts.map +1 -0
  105. package/dist/components/gmail/actions/reply-thread.js +35 -0
  106. package/dist/components/gmail/actions/reply.d.ts +66 -0
  107. package/dist/components/gmail/actions/reply.d.ts.map +1 -0
  108. package/dist/components/gmail/actions/reply.js +23 -0
  109. package/dist/components/gmail/actions/search-drafts.d.ts +18 -0
  110. package/dist/components/gmail/actions/search-drafts.d.ts.map +1 -0
  111. package/dist/components/gmail/actions/search-drafts.js +50 -0
  112. package/dist/components/gmail/actions/search-messages.d.ts +16 -0
  113. package/dist/components/gmail/actions/search-messages.d.ts.map +1 -0
  114. package/dist/components/gmail/actions/search-messages.js +45 -0
  115. package/dist/components/gmail/actions/search-threads.d.ts +15 -0
  116. package/dist/components/gmail/actions/search-threads.d.ts.map +1 -0
  117. package/dist/components/gmail/actions/search-threads.js +43 -0
  118. package/dist/components/gmail/actions/send-draft.d.ts +11 -0
  119. package/dist/components/gmail/actions/send-draft.d.ts.map +1 -0
  120. package/dist/components/gmail/actions/send-draft.js +18 -0
  121. package/dist/components/gmail/actions/send-email.d.ts +65 -0
  122. package/dist/components/gmail/actions/send-email.d.ts.map +1 -0
  123. package/dist/components/gmail/actions/send-email.js +35 -0
  124. package/dist/components/gmail/actions/star.d.ts +5 -0
  125. package/dist/components/gmail/actions/star.d.ts.map +1 -0
  126. package/dist/components/gmail/actions/star.js +3 -0
  127. package/dist/components/gmail/actions/trash.d.ts +15 -0
  128. package/dist/components/gmail/actions/trash.d.ts.map +1 -0
  129. package/dist/components/gmail/actions/trash.js +26 -0
  130. package/dist/components/gmail/actions/unmark-as-important.d.ts +5 -0
  131. package/dist/components/gmail/actions/unmark-as-important.d.ts.map +1 -0
  132. package/dist/components/gmail/actions/unmark-as-important.js +3 -0
  133. package/dist/components/gmail/actions/unstar.d.ts +5 -0
  134. package/dist/components/gmail/actions/unstar.d.ts.map +1 -0
  135. package/dist/components/gmail/actions/unstar.js +3 -0
  136. package/dist/components/gmail/actions/untrash.d.ts +15 -0
  137. package/dist/components/gmail/actions/untrash.d.ts.map +1 -0
  138. package/dist/components/gmail/actions/untrash.js +26 -0
  139. package/dist/components/gmail/actions/update-draft.d.ts +67 -0
  140. package/dist/components/gmail/actions/update-draft.d.ts.map +1 -0
  141. package/dist/components/gmail/actions/update-draft.js +67 -0
  142. package/dist/components/gmail/actions/update-label.d.ts +44 -0
  143. package/dist/components/gmail/actions/update-label.d.ts.map +1 -0
  144. package/dist/components/gmail/actions/update-label.js +38 -0
  145. package/dist/components/gmail/index.d.ts +5 -0
  146. package/dist/components/gmail/index.d.ts.map +1 -0
  147. package/dist/components/gmail/index.js +4 -0
  148. package/dist/components/gmail/lib/action-factories.d.ts +27 -0
  149. package/dist/components/gmail/lib/action-factories.d.ts.map +1 -0
  150. package/dist/components/gmail/lib/action-factories.js +55 -0
  151. package/dist/components/gmail/lib/gmail.d.ts +178 -0
  152. package/dist/components/gmail/lib/gmail.d.ts.map +1 -0
  153. package/dist/components/gmail/lib/gmail.js +411 -0
  154. package/dist/components/gmail/lib/schemas.d.ts +380 -0
  155. package/dist/components/gmail/lib/schemas.d.ts.map +1 -0
  156. package/dist/components/gmail/lib/schemas.js +226 -0
  157. package/dist/components/gmail/lib/scopes.d.ts +10 -0
  158. package/dist/components/gmail/lib/scopes.d.ts.map +1 -0
  159. package/dist/components/gmail/lib/scopes.js +16 -0
  160. package/dist/components/gmail/triggers/index.d.ts +2 -0
  161. package/dist/components/gmail/triggers/index.d.ts.map +1 -0
  162. package/dist/components/gmail/triggers/index.js +1 -0
  163. package/dist/components/gmail/triggers/on-new-email.d.ts +75 -0
  164. package/dist/components/gmail/triggers/on-new-email.d.ts.map +1 -0
  165. package/dist/components/gmail/triggers/on-new-email.js +30 -0
  166. package/dist/index.d.ts +1 -0
  167. package/dist/index.d.ts.map +1 -1
  168. package/dist/index.js +1 -0
  169. package/package.json +26 -6
package/README.md CHANGED
@@ -6,7 +6,6 @@ Happy-path Automate.ax package for automation authors. It provides the `automate
6
6
 
7
7
  ```bash
8
8
  bun add automate.ax
9
- bun add @automate.ax/components-core
10
9
  ```
11
10
 
12
11
  ## CLI
@@ -47,8 +46,7 @@ deployment.
47
46
  ## Automation
48
47
 
49
48
  ```ts
50
- import { log, onHttpRequest } from "@automate.ax/components-core"
51
- import { automation, transform } from "automate.ax"
49
+ import { automation, log, onHttpRequest, transform } from "automate.ax"
52
50
 
53
51
  export default automation("When a request is received", () => {
54
52
  const request = onHttpRequest({ scope: "automation" })
@@ -113,9 +111,63 @@ idempotent. Outputs do not enter the trigger event bus.
113
111
 
114
112
  ## Package Role
115
113
 
116
- Use `automate.ax` for app projects, automation and component authoring,
117
- deploy-time subscriptions, and the `automate` CLI. Install component packages
118
- such as `@automate.ax/components-core` for platform-provided actions and triggers.
114
+ Use `automate.ax` for app projects, automation and integration authoring,
115
+ deploy-time subscriptions, core actions and triggers, and the `automate` CLI.
119
116
  HTTP triggers return `202` immediately unless configured with
120
117
  `waitForResponse: true`; responding automations use the platform-provided
121
118
  `respondToHttpRequest` action.
119
+
120
+ Gmail actions are available directly from the SDK:
121
+
122
+ ```ts
123
+ import { sendEmail } from "automate.ax/gmail"
124
+
125
+ sendEmail({
126
+ from: {
127
+ address: "updates@example.com",
128
+ name: "Status Bot",
129
+ },
130
+ html: "<strong>The automation completed.</strong>",
131
+ replyTo: "support@example.com",
132
+ subject: "Status update",
133
+ to: {
134
+ address: "person@example.com",
135
+ name: "Alex",
136
+ },
137
+ })
138
+ ```
139
+
140
+ They use the default connected Google account unless the action receives an
141
+ `account` binding or account reference. The Gmail subpath includes rich message
142
+ composition, send-as aliases, named recipients, custom headers, priority,
143
+ inline attachments, drafts, replies, forwards, complete MIME parsing, threads,
144
+ raw messages, paginated search, profiles, labels, message state, archive, Spam,
145
+ and Trash actions.
146
+
147
+ `onNewEmail` subscribes to newly received inbox messages and emits that same
148
+ fully parsed message shape:
149
+
150
+ ```ts
151
+ import { automation } from "automate.ax"
152
+ import { markAsRead, onNewEmail } from "automate.ax/gmail"
153
+
154
+ export default automation("Read incoming mail", () => {
155
+ const email = onNewEmail()
156
+ markAsRead({ messageIds: email.messageId })
157
+ })
158
+ ```
159
+
160
+ Pass `account` to both calls to select a named Google account binding. Gmail
161
+ watches are shared by stable Google account identity and renewed by the
162
+ platform.
163
+
164
+ Search pagination is handled internally and returns stable message/thread or
165
+ draft identities. Batch-friendly mutations accept one message ID or up to 1,000
166
+ IDs and return the modified IDs for action chaining. Trash, untrash, and
167
+ multi-message reads bound request concurrency automatically.
168
+
169
+ Body-taking actions accept `text`, `html`, or both; when plain text is absent,
170
+ Automate.ax derives it from HTML for sent and received messages. Parsed messages
171
+ include structured addresses, duplicate-preserving headers, Gmail and RFC 5322
172
+ identities, labels, timestamps, snippets, bodies, and File-backed attachments.
173
+ Action inputs and outputs are inferred directly from documented schemas.
@@ -0,0 +1,17 @@
1
+ import { type IntegrationScopeRequirement } from "./integrations.js";
2
+ /**
3
+ * Records one integration account use and returns its planned selection.
4
+ *
5
+ * @param value - Static or signal-backed account selection.
6
+ * @param serviceId - Integration service required by the caller.
7
+ * @param requiredScopes - Provider scopes contributed by this use.
8
+ * @throws When the account selection does not match the required service.
9
+ */
10
+ export declare function planIntegrationAccountUse(value: unknown, serviceId: string, requiredScopes: IntegrationScopeRequirement[]): {
11
+ readonly dynamic: true;
12
+ readonly binding?: undefined;
13
+ } | {
14
+ readonly binding: string;
15
+ readonly dynamic: false;
16
+ };
17
+ //# sourceMappingURL=account-planning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-planning.d.ts","sourceRoot":"","sources":["../../src/automation/account-planning.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,2BAA2B,EACjC,0BAAsB;AAGvB;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,2BAA2B,EAAE;;;;;;EAW9C"}
@@ -0,0 +1,48 @@
1
+ import { DEFAULT_ACCOUNT_BINDING, isIntegrationAccountReference, serializedIntegrationAccountDefinition, } from "./integrations.js";
2
+ import { isSignal } from "./signal.js";
3
+ /**
4
+ * Records one integration account use and returns its planned selection.
5
+ *
6
+ * @param value - Static or signal-backed account selection.
7
+ * @param serviceId - Integration service required by the caller.
8
+ * @param requiredScopes - Provider scopes contributed by this use.
9
+ * @throws When the account selection does not match the required service.
10
+ */
11
+ export function planIntegrationAccountUse(value, serviceId, requiredScopes) {
12
+ const selection = getPlannedAccountSelection(value, serviceId);
13
+ globalThis.__AUTOMATION_PLANNING_CONTEXT__?.accountUses.push({
14
+ ...selection,
15
+ requiredScopes,
16
+ serviceId,
17
+ });
18
+ return selection;
19
+ }
20
+ /**
21
+ * Classifies an account input without evaluating signal transforms.
22
+ *
23
+ * @param value - Account selection supplied by an action or event function.
24
+ * @param serviceId - Integration service required by the caller.
25
+ * @throws When the account selection does not match the required service.
26
+ */
27
+ function getPlannedAccountSelection(value, serviceId) {
28
+ if (isSignal(value)) {
29
+ return { dynamic: true };
30
+ }
31
+ if (value === undefined || typeof value === "string") {
32
+ return {
33
+ binding: value ?? DEFAULT_ACCOUNT_BINDING,
34
+ dynamic: false,
35
+ };
36
+ }
37
+ if (!isIntegrationAccountReference(value)) {
38
+ throw new Error("Integration account input is not a named account binding.");
39
+ }
40
+ const definition = value[serializedIntegrationAccountDefinition];
41
+ if (definition.serviceId !== serviceId) {
42
+ throw new Error(`Expected a ${serviceId} account, but received a ${definition.serviceId} account.`);
43
+ }
44
+ return {
45
+ binding: definition.binding,
46
+ dynamic: false,
47
+ };
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":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M,CAAC,MAAM,CAAC,CAchB"}
@@ -2,6 +2,7 @@ import { mapValues } from "@zachsents/zippy";
2
2
  import { omit, pick } from "remeda";
3
3
  import { z } from "zod";
4
4
  import { actionAccountRequirementDefinition, DEFAULT_ACCOUNT_BINDING, isIntegrationAccountReference, serializedIntegrationAccountDefinition, } from "./integrations.js";
5
+ import { planIntegrationAccountUse } from "./account-planning.js";
5
6
  import { actionProvenance, createActionSignal, isSignal, signalTransform, signalValueType, subscriptionProvenance, transform, } from "./signal.js";
6
7
  import { consumeHookSlot } from "./runtime.js";
7
8
  const DEFAULT_ACTION_INPUT_SCHEMA = z.record(z.string(), z.never());
@@ -74,13 +75,8 @@ function invokeAction(options, input) {
74
75
  const slot = consumeHookSlot();
75
76
  const accountInput = options.account && "account" in input ? input.account : undefined;
76
77
  const schemaInput = options.account ? omit(input, ["account"]) : input;
77
- const planningContext = globalThis.__AUTOMATION_PLANNING_CONTEXT__;
78
- if (planningContext && options.account) {
79
- planningContext.accountUses.push({
80
- ...getPlannedAccountSelection(accountInput, options.account.serviceId),
81
- requiredScopes: options.account.requiredScopes,
82
- serviceId: options.account.serviceId,
83
- });
78
+ if (globalThis.__AUTOMATION_PLANNING_CONTEXT__ && options.account) {
79
+ planIntegrationAccountUse(accountInput, options.account.serviceId, options.account.requiredScopes);
84
80
  }
85
81
  const state = globalThis.__AUTOMATION_RUNTIME_STATE__;
86
82
  if (state?.phase === "orchestrate") {
@@ -157,35 +153,6 @@ async function resolveActionAccount(value, requirement, resolveAccountInput) {
157
153
  serviceId: requirement.serviceId,
158
154
  });
159
155
  }
160
- /**
161
- * Classifies an action account input without evaluating signal transforms.
162
- *
163
- * @param value - Account selection supplied to the action.
164
- * @param serviceId - Integration service required by the action.
165
- * @throws When the input is not a compatible account selection.
166
- */
167
- function getPlannedAccountSelection(value, serviceId) {
168
- if (isSignal(value)) {
169
- return { dynamic: true };
170
- }
171
- if (value === undefined || typeof value === "string") {
172
- return {
173
- binding: value ?? DEFAULT_ACCOUNT_BINDING,
174
- dynamic: false,
175
- };
176
- }
177
- if (!isIntegrationAccountReference(value)) {
178
- throw new Error("Action account input is not a named integration account binding.");
179
- }
180
- const definition = value[serializedIntegrationAccountDefinition];
181
- if (definition.serviceId !== serviceId) {
182
- throw new Error(`Action requires a ${serviceId} account, but received a ${definition.serviceId} account.`);
183
- }
184
- return {
185
- binding: definition.binding,
186
- dynamic: false,
187
- };
188
- }
189
156
  /**
190
157
  * Creates a string signal by interpolating in-memory values and signals.
191
158
  *
@@ -1,6 +1,7 @@
1
1
  import type { RunMainOptions } from "citty";
2
2
  /**
3
- * Prints CLI help with Automate.ax's own accent color and grouped root commands.
3
+ * Prints CLI help with Automate.ax's own accent color and grouped root
4
+ * commands.
4
5
  *
5
6
  * @param cmd - Command definition to render.
6
7
  * @param parent - Parent definition for a nested command.
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,cAAc,EAEf,MAAM,OAAO,CAAA;AA8Bd;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,CAO9D,CAAA"}
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,cAAc,EAEf,MAAM,OAAO,CAAA;AA8Bd;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,CAO9D,CAAA"}
package/dist/cli/usage.js CHANGED
@@ -26,7 +26,8 @@ const COMMAND_GROUPS = [
26
26
  },
27
27
  ];
28
28
  /**
29
- * Prints CLI help with Automate.ax's own accent color and grouped root commands.
29
+ * Prints CLI help with Automate.ax's own accent color and grouped root
30
+ * commands.
30
31
  *
31
32
  * @param cmd - Command definition to render.
32
33
  * @param parent - Parent definition for a nested command.
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ export declare const log: import("../..").DefinedAction<z.ZodObject<{
3
+ value: z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>;
4
+ }, z.core.$strip>, z.ZodVoid, never>;
5
+ export declare const add: import("../..").DefinedAction<z.ZodObject<{
6
+ a: z.ZodNumber;
7
+ b: z.ZodNumber;
8
+ }, z.core.$strip>, z.ZodNumber, never>;
9
+ export declare const multiply: import("../..").DefinedAction<z.ZodObject<{
10
+ a: z.ZodNumber;
11
+ b: z.ZodNumber;
12
+ }, z.core.$strip>, z.ZodNumber, never>;
13
+ export declare const subtract: import("../..").DefinedAction<z.ZodObject<{
14
+ a: z.ZodNumber;
15
+ b: z.ZodNumber;
16
+ }, z.core.$strip>, z.ZodNumber, never>;
17
+ export declare const sendEmail: import("../..").DefinedAction<z.ZodObject<{
18
+ subject: z.ZodString;
19
+ text: z.ZodString;
20
+ to: z.ZodEmail;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ id: z.ZodNullable<z.ZodString>;
23
+ }, z.core.$strip>, never>;
24
+ export declare const respondToHttpRequest: import("../..").DefinedAction<z.ZodObject<{
25
+ body: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Blob, Blob>]>>>;
26
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
27
+ status: z.ZodDefault<z.ZodNumber>;
28
+ }, z.core.$strip>, z.ZodVoid, never>;
29
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/core/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,GAAG;;oCAOmC,CAAA;AAEnD,eAAO,MAAM,GAAG;;;sCAQ4B,CAAA;AAE5C,eAAO,MAAM,QAAQ;;;sCAQuB,CAAA;AAE5C,eAAO,MAAM,QAAQ;;;sCAQuB,CAAA;AAE5C,eAAO,MAAM,SAAS;;;;;;yBAakD,CAAA;AAExE,eAAO,MAAM,oBAAoB;;;;oCAiB7B,CAAA"}
@@ -0,0 +1,57 @@
1
+ import { encodableSchema } from "@automate.ax/codec";
2
+ import { z } from "zod";
3
+ import { defineAction } from "../../automation/actions.js";
4
+ const HTTP_RESPONSE_OUTPUT_TYPE = "http.request.response";
5
+ export const log = defineAction("Log")
6
+ .input(z.object({
7
+ value: encodableSchema,
8
+ }))
9
+ .output(z.void())
10
+ .handler(({ input }) => console.log(input.value));
11
+ export const add = defineAction("Add")
12
+ .input(z.object({
13
+ a: z.number(),
14
+ b: z.number(),
15
+ }))
16
+ .output(z.number())
17
+ .handler(({ input }) => input.a + input.b);
18
+ export const multiply = defineAction("Multiply")
19
+ .input(z.object({
20
+ a: z.number(),
21
+ b: z.number(),
22
+ }))
23
+ .output(z.number())
24
+ .handler(({ input }) => input.a * input.b);
25
+ export const subtract = defineAction("Subtract")
26
+ .input(z.object({
27
+ a: z.number(),
28
+ b: z.number(),
29
+ }))
30
+ .output(z.number())
31
+ .handler(({ input }) => input.a - input.b);
32
+ export const sendEmail = defineAction("Send email")
33
+ .input(z.object({
34
+ subject: z.string(),
35
+ text: z.string(),
36
+ to: z.email(),
37
+ }))
38
+ .output(z.object({
39
+ id: z.string().nullable(),
40
+ }))
41
+ .handler(async ({ input, runtime }) => await runtime.sendEmail(input));
42
+ export const respondToHttpRequest = defineAction("Respond to HTTP request")
43
+ .input(z.object({
44
+ body: z
45
+ .union([z.string(), z.instanceof(Blob)])
46
+ .nullable()
47
+ .optional(),
48
+ headers: z.record(z.string(), z.string()).default({}),
49
+ status: z.number().int().min(100).max(599).default(200),
50
+ }))
51
+ .output(z.void())
52
+ .handler(async ({ input, runtime }) => {
53
+ await runtime.sendOutput({
54
+ data: input,
55
+ type: HTTP_RESPONSE_OUTPUT_TYPE,
56
+ });
57
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./actions.js";
2
+ export * from "./triggers.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/core/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,8BAA0B"}
@@ -0,0 +1,2 @@
1
+ export * from "./actions.js";
2
+ export * from "./triggers.js";
@@ -0,0 +1,21 @@
1
+ import type { Encodable } from "@automate.ax/codec";
2
+ export type HttpRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
3
+ export interface HttpRequestConfig {
4
+ scope: "project" | "automation";
5
+ waitForResponse?: boolean;
6
+ }
7
+ export type HttpRequestEvent = {
8
+ body: Encodable;
9
+ headers: Record<string, string>;
10
+ method: HttpRequestMethod;
11
+ path: string;
12
+ query: Record<string, string>;
13
+ url: string;
14
+ };
15
+ /**
16
+ * Subscribes the current automation to HTTP requests.
17
+ *
18
+ * @param config - Scope at which HTTP requests should be received.
19
+ */
20
+ export declare function onHttpRequest(config: HttpRequestConfig): import("../..").Signal<HttpRequestEvent>;
21
+ //# sourceMappingURL=triggers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/components/core/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGnD,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE3E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,SAAS,GAAG,YAAY,CAAA;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,4CAEtD"}
@@ -0,0 +1,9 @@
1
+ import { subscribe } from "../../automation/subscribe.js";
2
+ /**
3
+ * Subscribes the current automation to HTTP requests.
4
+ *
5
+ * @param config - Scope at which HTTP requests should be received.
6
+ */
7
+ export function onHttpRequest(config) {
8
+ return subscribe("http.request", config);
9
+ }
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Adds one Gmail label to one or many messages.
4
+ *
5
+ * Accepts a label display name or immutable label ID and returns the modified
6
+ * message IDs for action chaining.
7
+ */
8
+ export declare const addLabel: import("../../..").DefinedAction<z.ZodObject<{
9
+ label: z.ZodString;
10
+ messageIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
11
+ }, z.core.$strip>, z.ZodArray<z.ZodString>, "google">;
12
+ //# sourceMappingURL=add-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-label.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/add-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;qDAwBjB,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../../automation/actions.js";
3
+ import { findLabelId, getGmailApi, normalizeMessageIds } from "../lib/gmail.js";
4
+ import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
5
+ import { MESSAGE_IDS_SCHEMA } from "../lib/schemas.js";
6
+ /**
7
+ * Adds one Gmail label to one or many messages.
8
+ *
9
+ * Accepts a label display name or immutable label ID and returns the modified
10
+ * message IDs for action chaining.
11
+ */
12
+ export const addLabel = defineAction("Add Gmail label")
13
+ .describe("Adds a Gmail label to one or many messages.")
14
+ .account("google", GMAIL_MODIFY_REQUIREMENT)
15
+ .input(z.object({
16
+ /** Gmail label display name or immutable ID. */
17
+ label: z.string().min(1),
18
+ /** One ID or up to 1,000 immutable Gmail message IDs. */
19
+ messageIds: MESSAGE_IDS_SCHEMA,
20
+ }))
21
+ .output(z.string().array())
22
+ .handler(async ({ account, input }) => {
23
+ const gmailApi = getGmailApi(account.secret);
24
+ const messageIds = normalizeMessageIds(input.messageIds);
25
+ await gmailApi.users.messages.batchModify({
26
+ requestBody: {
27
+ addLabelIds: [await findLabelId(gmailApi, input.label)],
28
+ ids: messageIds,
29
+ },
30
+ userId: "me",
31
+ });
32
+ return messageIds;
33
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Archives one or many Gmail messages.
3
+ *
4
+ * The returned IDs can be passed directly to another batch-friendly action.
5
+ */
6
+ export declare const archive: import("../../..").DefinedAction<import("zod").ZodObject<{
7
+ messageIds: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
8
+ }, import("zod/v4/core").$strip>, import("zod").ZodArray<import("zod").ZodString>, "google">;
9
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/archive.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,OAAO;;4FAInB,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { defineMessageLabelMutation } from "../lib/action-factories.js";
2
+ /**
3
+ * Archives one or many Gmail messages.
4
+ *
5
+ * The returned IDs can be passed directly to another batch-friendly action.
6
+ */
7
+ export const archive = defineMessageLabelMutation("Archive Gmail messages", "Archives Gmail messages by removing them from the inbox.", { removeLabelIds: ["INBOX"] });
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ /** Creates a user-owned Gmail label and returns its complete metadata. */
3
+ export declare const createLabel: import("../../..").DefinedAction<z.ZodObject<{
4
+ color: z.ZodOptional<z.ZodObject<{
5
+ backgroundColor: z.ZodString;
6
+ textColor: z.ZodString;
7
+ }, z.core.$strip>>;
8
+ labelListVisibility: z.ZodOptional<z.ZodEnum<{
9
+ labelHide: "labelHide";
10
+ labelShow: "labelShow";
11
+ labelShowIfUnread: "labelShowIfUnread";
12
+ }>>;
13
+ messageListVisibility: z.ZodOptional<z.ZodEnum<{
14
+ hide: "hide";
15
+ show: "show";
16
+ }>>;
17
+ name: z.ZodString;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ color: z.ZodOptional<z.ZodObject<{
20
+ backgroundColor: z.ZodString;
21
+ textColor: z.ZodString;
22
+ }, z.core.$strip>>;
23
+ labelId: z.ZodString;
24
+ labelListVisibility: z.ZodOptional<z.ZodEnum<{
25
+ labelHide: "labelHide";
26
+ labelShow: "labelShow";
27
+ labelShowIfUnread: "labelShowIfUnread";
28
+ }>>;
29
+ messageListVisibility: z.ZodOptional<z.ZodEnum<{
30
+ hide: "hide";
31
+ show: "show";
32
+ }>>;
33
+ messagesTotal: z.ZodOptional<z.ZodNumber>;
34
+ messagesUnread: z.ZodOptional<z.ZodNumber>;
35
+ name: z.ZodString;
36
+ threadsTotal: z.ZodOptional<z.ZodNumber>;
37
+ threadsUnread: z.ZodOptional<z.ZodNumber>;
38
+ type: z.ZodOptional<z.ZodEnum<{
39
+ system: "system";
40
+ user: "user";
41
+ }>>;
42
+ }, z.core.$strip>, "google">;
43
+ //# sourceMappingURL=create-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-label.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/create-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,0EAA0E;AAC1E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA2BpB,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../../automation/actions.js";
3
+ import { getGmailApi, toGmailLabel } from "../lib/gmail.js";
4
+ import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
5
+ import { LABEL_COLOR_SCHEMA, LABEL_LIST_VISIBILITY_SCHEMA, LABEL_SCHEMA, MESSAGE_LIST_VISIBILITY_SCHEMA, } from "../lib/schemas.js";
6
+ /** Creates a user-owned Gmail label and returns its complete metadata. */
7
+ export const createLabel = defineAction("Create Gmail label")
8
+ .describe("Creates a user-owned Gmail label.")
9
+ .account("google", GMAIL_MODIFY_REQUIREMENT)
10
+ .input(z.object({
11
+ /** Optional supported Gmail label color. */
12
+ color: LABEL_COLOR_SCHEMA.optional(),
13
+ /** Visibility in Gmail's label list. */
14
+ labelListVisibility: LABEL_LIST_VISIBILITY_SCHEMA.optional(),
15
+ /** Visibility beside messages in Gmail's message list. */
16
+ messageListVisibility: MESSAGE_LIST_VISIBILITY_SCHEMA.optional(),
17
+ /** Human-readable label name. */
18
+ name: z.string().min(1),
19
+ }))
20
+ .output(LABEL_SCHEMA)
21
+ .handler(async ({ account, input }) => {
22
+ const { data: label } = await getGmailApi(account.secret).users.labels.create({
23
+ requestBody: input,
24
+ userId: "me",
25
+ });
26
+ return toGmailLabel(label);
27
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ /** Permanently deletes a Gmail draft and returns the deleted draft ID. */
3
+ export declare const deleteDraft: import("../../..").DefinedAction<z.ZodObject<{
4
+ draftId: z.ZodString;
5
+ }, z.core.$strip>, z.ZodString, "google">;
6
+ //# sourceMappingURL=delete-draft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-draft.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/delete-draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,0EAA0E;AAC1E,eAAO,MAAM,WAAW;;yCAgBpB,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../../automation/actions.js";
3
+ import { getGmailApi } from "../lib/gmail.js";
4
+ import { GMAIL_COMPOSE_REQUIREMENT } from "../lib/scopes.js";
5
+ /** Permanently deletes a Gmail draft and returns the deleted draft ID. */
6
+ export const deleteDraft = defineAction("Delete Gmail draft")
7
+ .describe("Permanently deletes a Gmail draft.")
8
+ .account("google", GMAIL_COMPOSE_REQUIREMENT)
9
+ .input(z.object({
10
+ /** Immutable Gmail draft ID to delete permanently. */
11
+ draftId: z.string().min(1),
12
+ }))
13
+ .output(z.string())
14
+ .handler(async ({ account, input }) => {
15
+ await getGmailApi(account.secret).users.drafts.delete({
16
+ id: input.draftId,
17
+ userId: "me",
18
+ });
19
+ return input.draftId;
20
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ /** Permanently deletes a user-owned Gmail label and returns its label ID. */
3
+ export declare const deleteLabel: import("../../..").DefinedAction<z.ZodObject<{
4
+ label: z.ZodString;
5
+ }, z.core.$strip>, z.ZodString, "google">;
6
+ //# sourceMappingURL=delete-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-label.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/delete-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,6EAA6E;AAC7E,eAAO,MAAM,WAAW;;yCAkBpB,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../../automation/actions.js";
3
+ import { findLabelId, getGmailApi } from "../lib/gmail.js";
4
+ import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
5
+ /** Permanently deletes a user-owned Gmail label and returns its label ID. */
6
+ export const deleteLabel = defineAction("Delete Gmail label")
7
+ .describe("Permanently deletes a user-owned Gmail label.")
8
+ .account("google", GMAIL_MODIFY_REQUIREMENT)
9
+ .input(z.object({
10
+ /** Gmail label display name or immutable ID to delete. */
11
+ label: z.string().min(1),
12
+ }))
13
+ .output(z.string())
14
+ .handler(async ({ account, input }) => {
15
+ const gmailApi = getGmailApi(account.secret);
16
+ const labelId = await findLabelId(gmailApi, input.label);
17
+ await gmailApi.users.labels.delete({
18
+ id: labelId,
19
+ userId: "me",
20
+ });
21
+ return labelId;
22
+ });