automate.ax 0.1.3

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/dist/automation/actions.d.ts +200 -0
  4. package/dist/automation/actions.d.ts.map +1 -0
  5. package/dist/automation/actions.js +286 -0
  6. package/dist/automation/automation.d.ts +16 -0
  7. package/dist/automation/automation.d.ts.map +1 -0
  8. package/dist/automation/automation.js +10 -0
  9. package/dist/automation/integrations.d.ts +63 -0
  10. package/dist/automation/integrations.d.ts.map +1 -0
  11. package/dist/automation/integrations.js +58 -0
  12. package/dist/automation/runtime.d.ts +73 -0
  13. package/dist/automation/runtime.d.ts.map +1 -0
  14. package/dist/automation/runtime.js +92 -0
  15. package/dist/automation/signal.d.ts +58 -0
  16. package/dist/automation/signal.d.ts.map +1 -0
  17. package/dist/automation/signal.js +80 -0
  18. package/dist/automation/subscribe.d.ts +10 -0
  19. package/dist/automation/subscribe.d.ts.map +1 -0
  20. package/dist/automation/subscribe.js +16 -0
  21. package/dist/cli/command-names.d.ts +46 -0
  22. package/dist/cli/command-names.d.ts.map +1 -0
  23. package/dist/cli/command-names.js +46 -0
  24. package/dist/cli/commands/accept.d.ts +20 -0
  25. package/dist/cli/commands/accept.d.ts.map +1 -0
  26. package/dist/cli/commands/accept.js +42 -0
  27. package/dist/cli/commands/debug.d.ts +4 -0
  28. package/dist/cli/commands/debug.d.ts.map +1 -0
  29. package/dist/cli/commands/debug.js +52 -0
  30. package/dist/cli/commands/deploy.d.ts +24 -0
  31. package/dist/cli/commands/deploy.d.ts.map +1 -0
  32. package/dist/cli/commands/deploy.js +292 -0
  33. package/dist/cli/commands/login.d.ts +20 -0
  34. package/dist/cli/commands/login.d.ts.map +1 -0
  35. package/dist/cli/commands/login.js +145 -0
  36. package/dist/cli/commands/logout.d.ts +4 -0
  37. package/dist/cli/commands/logout.d.ts.map +1 -0
  38. package/dist/cli/commands/logout.js +32 -0
  39. package/dist/cli/commands/me.d.ts +4 -0
  40. package/dist/cli/commands/me.d.ts.map +1 -0
  41. package/dist/cli/commands/me.js +48 -0
  42. package/dist/cli/commands/org-api-key-create.d.ts +26 -0
  43. package/dist/cli/commands/org-api-key-create.d.ts.map +1 -0
  44. package/dist/cli/commands/org-api-key-create.js +51 -0
  45. package/dist/cli/commands/org-api-key-delete.d.ts +33 -0
  46. package/dist/cli/commands/org-api-key-delete.d.ts.map +1 -0
  47. package/dist/cli/commands/org-api-key-delete.js +57 -0
  48. package/dist/cli/commands/org-api-key-list.d.ts +16 -0
  49. package/dist/cli/commands/org-api-key-list.d.ts.map +1 -0
  50. package/dist/cli/commands/org-api-key-list.js +58 -0
  51. package/dist/cli/commands/org-api-key-rename.d.ts +32 -0
  52. package/dist/cli/commands/org-api-key-rename.d.ts.map +1 -0
  53. package/dist/cli/commands/org-api-key-rename.js +54 -0
  54. package/dist/cli/commands/org-api-key.d.ts +2 -0
  55. package/dist/cli/commands/org-api-key.d.ts.map +1 -0
  56. package/dist/cli/commands/org-api-key.js +18 -0
  57. package/dist/cli/commands/org-billing.d.ts +16 -0
  58. package/dist/cli/commands/org-billing.d.ts.map +1 -0
  59. package/dist/cli/commands/org-billing.js +78 -0
  60. package/dist/cli/commands/org-create.d.ts +20 -0
  61. package/dist/cli/commands/org-create.d.ts.map +1 -0
  62. package/dist/cli/commands/org-create.js +64 -0
  63. package/dist/cli/commands/org-delete.d.ts +27 -0
  64. package/dist/cli/commands/org-delete.d.ts.map +1 -0
  65. package/dist/cli/commands/org-delete.js +53 -0
  66. package/dist/cli/commands/org-invite.d.ts +39 -0
  67. package/dist/cli/commands/org-invite.d.ts.map +1 -0
  68. package/dist/cli/commands/org-invite.js +66 -0
  69. package/dist/cli/commands/org-leave.d.ts +27 -0
  70. package/dist/cli/commands/org-leave.d.ts.map +1 -0
  71. package/dist/cli/commands/org-leave.js +56 -0
  72. package/dist/cli/commands/org-list.d.ts +4 -0
  73. package/dist/cli/commands/org-list.d.ts.map +1 -0
  74. package/dist/cli/commands/org-list.js +36 -0
  75. package/dist/cli/commands/org-remove.d.ts +33 -0
  76. package/dist/cli/commands/org-remove.d.ts.map +1 -0
  77. package/dist/cli/commands/org-remove.js +66 -0
  78. package/dist/cli/commands/org-rename.d.ts +26 -0
  79. package/dist/cli/commands/org-rename.d.ts.map +1 -0
  80. package/dist/cli/commands/org-rename.js +58 -0
  81. package/dist/cli/commands/org-show.d.ts +16 -0
  82. package/dist/cli/commands/org-show.d.ts.map +1 -0
  83. package/dist/cli/commands/org-show.js +48 -0
  84. package/dist/cli/commands/org-upgrade.d.ts +42 -0
  85. package/dist/cli/commands/org-upgrade.d.ts.map +1 -0
  86. package/dist/cli/commands/org-upgrade.js +171 -0
  87. package/dist/cli/commands/org.d.ts +2 -0
  88. package/dist/cli/commands/org.d.ts.map +1 -0
  89. package/dist/cli/commands/org.js +32 -0
  90. package/dist/cli/commands/project-create.d.ts +27 -0
  91. package/dist/cli/commands/project-create.d.ts.map +1 -0
  92. package/dist/cli/commands/project-create.js +61 -0
  93. package/dist/cli/commands/project-delete.d.ts +27 -0
  94. package/dist/cli/commands/project-delete.d.ts.map +1 -0
  95. package/dist/cli/commands/project-delete.js +55 -0
  96. package/dist/cli/commands/project-list.d.ts +17 -0
  97. package/dist/cli/commands/project-list.d.ts.map +1 -0
  98. package/dist/cli/commands/project-list.js +89 -0
  99. package/dist/cli/commands/project-rename.d.ts +26 -0
  100. package/dist/cli/commands/project-rename.d.ts.map +1 -0
  101. package/dist/cli/commands/project-rename.js +60 -0
  102. package/dist/cli/commands/project-show.d.ts +16 -0
  103. package/dist/cli/commands/project-show.d.ts.map +1 -0
  104. package/dist/cli/commands/project-show.js +37 -0
  105. package/dist/cli/commands/project.d.ts +2 -0
  106. package/dist/cli/commands/project.d.ts.map +1 -0
  107. package/dist/cli/commands/project.js +20 -0
  108. package/dist/cli/index.d.ts +19 -0
  109. package/dist/cli/index.d.ts.map +1 -0
  110. package/dist/cli/index.js +63 -0
  111. package/dist/cli/lib/api-client.d.ts +3 -0
  112. package/dist/cli/lib/api-client.d.ts.map +1 -0
  113. package/dist/cli/lib/api-client.js +14 -0
  114. package/dist/cli/lib/auth-client.d.ts +80 -0
  115. package/dist/cli/lib/auth-client.d.ts.map +1 -0
  116. package/dist/cli/lib/auth-client.js +61 -0
  117. package/dist/cli/lib/automation-build.d.ts +30 -0
  118. package/dist/cli/lib/automation-build.d.ts.map +1 -0
  119. package/dist/cli/lib/automation-build.js +90 -0
  120. package/dist/cli/lib/config-dir.d.ts +47 -0
  121. package/dist/cli/lib/config-dir.d.ts.map +1 -0
  122. package/dist/cli/lib/config-dir.js +146 -0
  123. package/dist/cli/lib/detail-block.d.ts +16 -0
  124. package/dist/cli/lib/detail-block.d.ts.map +1 -0
  125. package/dist/cli/lib/detail-block.js +25 -0
  126. package/dist/cli/lib/env.d.ts +4 -0
  127. package/dist/cli/lib/env.d.ts.map +1 -0
  128. package/dist/cli/lib/env.js +7 -0
  129. package/dist/cli/lib/hijack-clack-logger.d.ts +2 -0
  130. package/dist/cli/lib/hijack-clack-logger.d.ts.map +1 -0
  131. package/dist/cli/lib/hijack-clack-logger.js +8 -0
  132. package/dist/cli/lib/io.d.ts +19 -0
  133. package/dist/cli/lib/io.d.ts.map +1 -0
  134. package/dist/cli/lib/io.js +87 -0
  135. package/dist/cli/lib/json-output.d.ts +9 -0
  136. package/dist/cli/lib/json-output.d.ts.map +1 -0
  137. package/dist/cli/lib/json-output.js +12 -0
  138. package/dist/cli/lib/organization-detail-block.d.ts +30 -0
  139. package/dist/cli/lib/organization-detail-block.d.ts.map +1 -0
  140. package/dist/cli/lib/organization-detail-block.js +72 -0
  141. package/dist/cli/lib/project-config.d.ts +10 -0
  142. package/dist/cli/lib/project-config.d.ts.map +1 -0
  143. package/dist/cli/lib/project-config.js +21 -0
  144. package/dist/cli/lib/spinner.d.ts +18 -0
  145. package/dist/cli/lib/spinner.d.ts.map +1 -0
  146. package/dist/cli/lib/spinner.js +111 -0
  147. package/dist/cli/usage.d.ts +9 -0
  148. package/dist/cli/usage.d.ts.map +1 -0
  149. package/dist/cli/usage.js +468 -0
  150. package/dist/cli/utils.d.ts +291 -0
  151. package/dist/cli/utils.d.ts.map +1 -0
  152. package/dist/cli/utils.js +561 -0
  153. package/dist/cli.d.ts +3 -0
  154. package/dist/cli.d.ts.map +1 -0
  155. package/dist/cli.js +5 -0
  156. package/dist/config.d.ts +11 -0
  157. package/dist/config.d.ts.map +1 -0
  158. package/dist/config.js +9 -0
  159. package/dist/index.d.ts +8 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +7 -0
  162. package/package.json +92 -0
@@ -0,0 +1,20 @@
1
+ import { defineCommand } from "citty";
2
+ import { commandNames } from "../command-names.js";
3
+ import { projectCreateCommand } from "./project-create.js";
4
+ import { projectDeleteCommand } from "./project-delete.js";
5
+ import { projectListCommand } from "./project-list.js";
6
+ import { projectRenameCommand } from "./project-rename.js";
7
+ import { projectShowCommand } from "./project-show.js";
8
+ export const projectCommand = defineCommand({
9
+ meta: {
10
+ name: commandNames.project.root,
11
+ description: "Manage projects",
12
+ },
13
+ subCommands: {
14
+ [commandNames.project.create]: projectCreateCommand,
15
+ [commandNames.project.delete]: projectDeleteCommand,
16
+ [commandNames.project.list]: projectListCommand,
17
+ [commandNames.project.rename]: projectRenameCommand,
18
+ [commandNames.project.show]: projectShowCommand,
19
+ },
20
+ });
@@ -0,0 +1,19 @@
1
+ import "./lib/hijack-clack-logger.js";
2
+ export declare const showUsage: typeof import("citty").showUsage;
3
+ /** Root CLI command definition. */
4
+ export declare const main: import("citty").CommandDef<{
5
+ readonly json: {
6
+ readonly type: "boolean";
7
+ readonly description: "Output JSON";
8
+ readonly default: false;
9
+ };
10
+ }>;
11
+ /**
12
+ * Runs the Automate.ax CLI and formats failures for the selected output mode.
13
+ *
14
+ * @param rawArgs - Command-line arguments excluding the runtime executable.
15
+ */
16
+ export declare function runMain(rawArgs?: string[]): Promise<void> | Promise<{
17
+ result: unknown;
18
+ }>;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAgBlC,eAAO,MAAM,SAAS,kCAAe,CAAA;AAGrC,mCAAmC;AACnC,eAAO,MAAM,IAAI;;;;;;EAyBf,CAAA;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,WAAwB;;GAgBtD"}
@@ -0,0 +1,63 @@
1
+ import "./lib/hijack-clack-logger.js";
2
+ import { defineCommand, runCommand, runMain as runCittyMain } from "citty";
3
+ import { commandNames } from "./command-names.js";
4
+ import { acceptCommand } from "./commands/accept.js";
5
+ import { debugCommand } from "./commands/debug.js";
6
+ import { deployCommand } from "./commands/deploy.js";
7
+ import { loginCommand } from "./commands/login.js";
8
+ import { logoutCommand } from "./commands/logout.js";
9
+ import { organizationCommand } from "./commands/org.js";
10
+ import { orgInviteCommand } from "./commands/org-invite.js";
11
+ import { orgUpgradeCommand } from "./commands/org-upgrade.js";
12
+ import { projectCommand } from "./commands/project.js";
13
+ import { meCommand } from "./commands/me.js";
14
+ import { showUsage as cliShowUsage } from "./usage.js";
15
+ import { writeJsonError } from "./utils.js";
16
+ export const showUsage = cliShowUsage;
17
+ const CLI_VERSION = "0.1.2";
18
+ /** Root CLI command definition. */
19
+ export const main = defineCommand({
20
+ meta: {
21
+ name: commandNames.root,
22
+ version: CLI_VERSION,
23
+ description: "Automate.ax CLI",
24
+ },
25
+ args: {
26
+ json: {
27
+ type: "boolean",
28
+ description: "Output JSON",
29
+ default: false,
30
+ },
31
+ },
32
+ subCommands: {
33
+ [commandNames.accept]: acceptCommand,
34
+ [commandNames.debug]: debugCommand,
35
+ [commandNames.deploy]: deployCommand,
36
+ [commandNames.invite]: orgInviteCommand,
37
+ [commandNames.login]: loginCommand,
38
+ [commandNames.logout]: logoutCommand,
39
+ [commandNames.me]: meCommand,
40
+ [commandNames.org.root]: organizationCommand,
41
+ [commandNames.project.root]: projectCommand,
42
+ [commandNames.upgrade]: orgUpgradeCommand,
43
+ },
44
+ });
45
+ /**
46
+ * Runs the Automate.ax CLI and formats failures for the selected output mode.
47
+ *
48
+ * @param rawArgs - Command-line arguments excluding the runtime executable.
49
+ */
50
+ export function runMain(rawArgs = process.argv.slice(2)) {
51
+ // JSON mode uses runCommand so Citty doesn't print human usage/errors.
52
+ // Tradeoff: Citty's built-in --help/--version handling is bypassed when
53
+ // --json is present, so those combinations currently return JSON errors.
54
+ return (rawArgs.includes("--json")
55
+ ? runCommand(main, { rawArgs })
56
+ : runCittyMain(main, { rawArgs, showUsage })).catch((error) => {
57
+ if (rawArgs.includes("--json")) {
58
+ writeJsonError(error);
59
+ process.exit(1);
60
+ }
61
+ throw error;
62
+ });
63
+ }
@@ -0,0 +1,3 @@
1
+ import type { Client } from "@automate.ax/client";
2
+ export declare const apiClient: Client;
3
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAOjD,eAAO,MAAM,SAAS,EAAE,MAUvB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { createORPCClient } from "@orpc/client";
2
+ import { RPCLink } from "@orpc/client/fetch";
3
+ import { joinURL } from "ufo";
4
+ import { loadSavedTokenSync } from "../utils.js";
5
+ import { env } from "./env.js";
6
+ export const apiClient = createORPCClient(new RPCLink({
7
+ headers: () => {
8
+ const token = loadSavedTokenSync();
9
+ if (!token)
10
+ throw new Error("API credentials are unavailable.");
11
+ return { authorization: `Bearer ${token}` };
12
+ },
13
+ url: joinURL(env.APP_ORIGIN, "/api/rpc"),
14
+ }));
@@ -0,0 +1,80 @@
1
+ export interface CliAuthUser {
2
+ createdAt: Date | string;
3
+ email: string;
4
+ emailVerified: boolean;
5
+ id: string;
6
+ image?: string | null;
7
+ isAnonymous?: boolean | null;
8
+ name: string;
9
+ updatedAt: Date | string;
10
+ }
11
+ export interface CliAuthSession {
12
+ user: CliAuthUser;
13
+ }
14
+ export interface CliSubscription {
15
+ plan: string;
16
+ status: string;
17
+ }
18
+ export interface CliAuthClient {
19
+ device: {
20
+ code(input: {
21
+ client_id: string;
22
+ }): Promise<{
23
+ device_code: string;
24
+ user_code: string;
25
+ }>;
26
+ token(input: {
27
+ client_id: string;
28
+ device_code: string;
29
+ fetchOptions?: {
30
+ headers: Record<string, string>;
31
+ };
32
+ grant_type: string;
33
+ }): Promise<{
34
+ access_token: string;
35
+ }>;
36
+ };
37
+ getSession(): Promise<CliAuthSession | null>;
38
+ organization: {
39
+ acceptInvitation(input: {
40
+ invitationId: string;
41
+ }): Promise<{
42
+ member: {
43
+ organizationId: string;
44
+ role: string;
45
+ };
46
+ }>;
47
+ };
48
+ signIn: {
49
+ anonymous(): Promise<CliAuthSession>;
50
+ };
51
+ signOut(): Promise<unknown>;
52
+ subscription: {
53
+ billingPortal(input: {
54
+ customerType: "organization";
55
+ disableRedirect: true;
56
+ referenceId: string;
57
+ returnUrl: string;
58
+ }): Promise<{
59
+ url: string;
60
+ }>;
61
+ list(input: {
62
+ query: {
63
+ customerType: "organization";
64
+ referenceId: string;
65
+ };
66
+ }): Promise<CliSubscription[]>;
67
+ upgrade(input: {
68
+ cancelUrl: string;
69
+ customerType: "organization";
70
+ disableRedirect: true;
71
+ plan: "pro";
72
+ referenceId: string;
73
+ successUrl: string;
74
+ }): Promise<{
75
+ url: string | null;
76
+ }>;
77
+ };
78
+ }
79
+ export declare const authClient: CliAuthClient;
80
+ //# sourceMappingURL=auth-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/auth-client.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,OAAO,CAAA;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE;QACN,IAAI,CAAC,KAAK,EAAE;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YAC1C,WAAW,EAAE,MAAM,CAAA;YACnB,SAAS,EAAE,MAAM,CAAA;SAClB,CAAC,CAAA;QACF,KAAK,CAAC,KAAK,EAAE;YACX,SAAS,EAAE,MAAM,CAAA;YACjB,WAAW,EAAE,MAAM,CAAA;YACnB,YAAY,CAAC,EAAE;gBACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;aAChC,CAAA;YACD,UAAU,EAAE,MAAM,CAAA;SACnB,GAAG,OAAO,CAAC;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACtC,CAAA;IACD,UAAU,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC5C,YAAY,EAAE;QACZ,gBAAgB,CAAC,KAAK,EAAE;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YACzD,MAAM,EAAE;gBACN,cAAc,EAAE,MAAM,CAAA;gBACtB,IAAI,EAAE,MAAM,CAAA;aACb,CAAA;SACF,CAAC,CAAA;KACH,CAAA;IACD,MAAM,EAAE;QACN,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAAA;KACrC,CAAA;IACD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3B,YAAY,EAAE;QACZ,aAAa,CAAC,KAAK,EAAE;YACnB,YAAY,EAAE,cAAc,CAAA;YAC5B,eAAe,EAAE,IAAI,CAAA;YACrB,WAAW,EAAE,MAAM,CAAA;YACnB,SAAS,EAAE,MAAM,CAAA;SAClB,GAAG,OAAO,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QAC5B,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,EAAE;gBACL,YAAY,EAAE,cAAc,CAAA;gBAC5B,WAAW,EAAE,MAAM,CAAA;aACpB,CAAA;SACF,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,EAAE;YACb,SAAS,EAAE,MAAM,CAAA;YACjB,YAAY,EAAE,cAAc,CAAA;YAC5B,eAAe,EAAE,IAAI,CAAA;YACrB,IAAI,EAAE,KAAK,CAAA;YACX,WAAW,EAAE,MAAM,CAAA;YACnB,UAAU,EAAE,MAAM,CAAA;SACnB,GAAG,OAAO,CAAC;YAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC,CAAA;KACpC,CAAA;CACF;AAED,eAAO,MAAM,UAAU,EAAE,aA8BvB,CAAA"}
@@ -0,0 +1,61 @@
1
+ import { apiKeyClient } from "@better-auth/api-key/client";
2
+ import { stripeClient } from "@better-auth/stripe/client";
3
+ import { createAuthClient } from "better-auth/client";
4
+ import { anonymousClient, deviceAuthorizationClient, emailOTPClient, organizationClient, } from "better-auth/client/plugins";
5
+ import { createAccessControl } from "better-auth/plugins/access";
6
+ import { adminAc, defaultStatements, memberAc, ownerAc, } from "better-auth/plugins/organization/access";
7
+ import { joinURL } from "ufo";
8
+ import { loadSavedTokenSync, saveTokenSync } from "../utils.js";
9
+ import { env } from "./env.js";
10
+ /** Access-control statements available to CLI organization roles. */
11
+ const statement = {
12
+ ...defaultStatements,
13
+ project: ["create", "update", "delete"],
14
+ };
15
+ const ac = createAccessControl(statement);
16
+ /** Project permissions granted to organization members. */
17
+ const member = ac.newRole({
18
+ project: ["create"],
19
+ ...memberAc.statements,
20
+ });
21
+ /** Project permissions granted to organization administrators. */
22
+ const admin = ac.newRole({
23
+ project: ["create", "update"],
24
+ ...adminAc.statements,
25
+ });
26
+ /** Project permissions granted to organization owners. */
27
+ const owner = ac.newRole({
28
+ project: ["create", "update", "delete"],
29
+ ...ownerAc.statements,
30
+ });
31
+ export const authClient = createAuthClient({
32
+ baseURL: joinURL(env.APP_ORIGIN, "/api/auth"),
33
+ fetchOptions: {
34
+ throw: true,
35
+ auth: {
36
+ type: "Bearer",
37
+ token: () => loadSavedTokenSync() || "",
38
+ },
39
+ onSuccess: (ctx) => {
40
+ const token = ctx.response.headers.get("set-auth-token");
41
+ if (token) {
42
+ saveTokenSync(token);
43
+ }
44
+ },
45
+ },
46
+ plugins: [
47
+ organizationClient({
48
+ ac,
49
+ roles: {
50
+ owner,
51
+ admin,
52
+ member,
53
+ },
54
+ }),
55
+ anonymousClient(),
56
+ emailOTPClient(),
57
+ apiKeyClient(),
58
+ stripeClient({ subscription: true }),
59
+ deviceAuthorizationClient(),
60
+ ],
61
+ });
@@ -0,0 +1,30 @@
1
+ export declare const AUTOMATION_BUILD_DIR = ".automate/build";
2
+ export interface AutomationFile {
3
+ path: string;
4
+ relativePath: string;
5
+ }
6
+ export interface AutomationBuildResult {
7
+ dir: string;
8
+ automations: Array<{
9
+ body: Blob;
10
+ identityKey: string;
11
+ }>;
12
+ }
13
+ /**
14
+ * Finds automation entry points below a project directory.
15
+ *
16
+ * @param dir - Project directory to search.
17
+ */
18
+ export declare function findAutomationFiles(dir: string): Promise<{
19
+ path: string;
20
+ relativePath: string;
21
+ }[]>;
22
+ /**
23
+ * Bundles automation entry points and reads their deployable artifacts.
24
+ *
25
+ * @param projectDir - Project directory that owns the automations.
26
+ * @param automationFiles - Automation entry points to build.
27
+ * @throws When two source paths produce the same artifact filename.
28
+ */
29
+ export declare function buildAutomations(projectDir: string, automationFiles: AutomationFile[]): Promise<AutomationBuildResult>;
30
+ //# sourceMappingURL=automation-build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation-build.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/automation-build.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,oBAAoB,CAAA;AAErD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,IAAI,CAAA;QACV,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;CACH;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM;;;KAkBpD;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,cAAc,EAAE,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAoChC"}
@@ -0,0 +1,90 @@
1
+ import { mkdir, readFile, rm } from "node:fs/promises";
2
+ import { build as esbuild } from "esbuild";
3
+ import { globby } from "globby";
4
+ import path from "node:path";
5
+ export const AUTOMATION_BUILD_DIR = ".automate/build";
6
+ /**
7
+ * Finds automation entry points below a project directory.
8
+ *
9
+ * @param dir - Project directory to search.
10
+ */
11
+ export async function findAutomationFiles(dir) {
12
+ const resolvedDir = path.resolve(dir);
13
+ return (await globby("**/*.automation.ts", {
14
+ absolute: true,
15
+ cwd: resolvedDir,
16
+ gitignore: true,
17
+ onlyFiles: true,
18
+ }))
19
+ .map((automationPath) => ({
20
+ path: automationPath,
21
+ relativePath: path.relative(resolvedDir, automationPath),
22
+ }))
23
+ .toSorted((a, b) => a.relativePath.localeCompare(b.relativePath));
24
+ }
25
+ /**
26
+ * Bundles automation entry points and reads their deployable artifacts.
27
+ *
28
+ * @param projectDir - Project directory that owns the automations.
29
+ * @param automationFiles - Automation entry points to build.
30
+ * @throws When two source paths produce the same artifact filename.
31
+ */
32
+ export async function buildAutomations(projectDir, automationFiles) {
33
+ const buildDir = path.join(path.resolve(projectDir), AUTOMATION_BUILD_DIR);
34
+ await rm(buildDir, { recursive: true, force: true });
35
+ await mkdir(buildDir, { recursive: true });
36
+ const automations = [];
37
+ const artifactStems = new Set();
38
+ for (const automationFile of automationFiles) {
39
+ const artifactStem = getAutomationArtifactStem(automationFile.relativePath);
40
+ if (artifactStems.has(artifactStem)) {
41
+ throw new Error(`Multiple automation files resolve to the same build artifact name: ${artifactStem}`);
42
+ }
43
+ artifactStems.add(artifactStem);
44
+ automations.push({
45
+ body: new Blob([
46
+ await readFile(await bundleBuildFile(automationFile.path, path.join(buildDir, "bundles"), `${artifactStem}.js`)),
47
+ ]),
48
+ identityKey: automationFile.relativePath,
49
+ });
50
+ }
51
+ return {
52
+ dir: buildDir,
53
+ automations,
54
+ };
55
+ }
56
+ /**
57
+ * Converts an automation source path into a filesystem-safe artifact stem.
58
+ *
59
+ * @param relativePath - Automation path relative to its project.
60
+ */
61
+ function getAutomationArtifactStem(relativePath) {
62
+ return relativePath
63
+ .replace(/\.automation\.[cm]?[jt]sx?$/, "")
64
+ .split(/[\\/]+/)
65
+ .filter((part) => part.length > 0)
66
+ .map((part) => part.replaceAll(/[^A-Za-z0-9._-]+/g, "-"))
67
+ .join("-");
68
+ }
69
+ /**
70
+ * Bundles one automation entry point into an ECMAScript module.
71
+ *
72
+ * @param sourcePath - Automation entry point to bundle.
73
+ * @param outdir - Directory where the bundle should be written.
74
+ * @param filename - Output bundle filename.
75
+ */
76
+ async function bundleBuildFile(sourcePath, outdir, filename) {
77
+ await mkdir(outdir, { recursive: true });
78
+ const outfile = path.join(outdir, filename);
79
+ await esbuild({
80
+ bundle: true,
81
+ entryPoints: [sourcePath],
82
+ format: "esm",
83
+ logLevel: "silent",
84
+ outfile,
85
+ platform: "node",
86
+ target: "node24",
87
+ write: true,
88
+ });
89
+ return outfile;
90
+ }
@@ -0,0 +1,47 @@
1
+ export declare const configFileNames: readonly ["automate.config.ts", "automate.config.mts", "automate.config.cts", "automate.config.js", "automate.config.mjs", "automate.config.cjs", "automate.config.json"];
2
+ export type ConfigDirPriority = 0 | 1 | 2;
3
+ export interface ConfigDirMatch {
4
+ configPath: string;
5
+ dir: string;
6
+ priority: ConfigDirPriority;
7
+ }
8
+ export interface FindConfigDirMatchesOptions {
9
+ cwd?: string;
10
+ maxDownDepth?: number;
11
+ }
12
+ /**
13
+ * Finds the nearest project config directories around a working directory.
14
+ *
15
+ * @param options - Search root and maximum downward traversal depth.
16
+ * @param options.cwd - Directory from which to begin searching.
17
+ * @param options.maxDownDepth - Maximum descendant depth to inspect.
18
+ */
19
+ export declare function findConfigDirMatches({ cwd, maxDownDepth, }?: FindConfigDirMatchesOptions): Promise<{
20
+ configPath: string;
21
+ dir: string;
22
+ priority: 1;
23
+ }[] | {
24
+ configPath: string;
25
+ dir: string;
26
+ priority: 2;
27
+ }[] | {
28
+ configPath: string;
29
+ dir: string;
30
+ priority: 0;
31
+ }[]>;
32
+ /**
33
+ * Resolves a user-selected directory and finds its project config file.
34
+ *
35
+ * @param dir - Directory path, relative to the supplied working directory.
36
+ * @param options - Resolution options.
37
+ * @param options.cwd - Base directory for resolving `dir`.
38
+ * @throws When the directory contains no recognized config file.
39
+ */
40
+ export declare function findExplicitConfigDirMatch(dir: string, { cwd }?: {
41
+ cwd?: string;
42
+ }): Promise<{
43
+ configPath: string;
44
+ dir: string;
45
+ priority: 0;
46
+ }>;
47
+ //# sourceMappingURL=config-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-dir.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/config-dir.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,2KAQlB,CAAA;AAOV,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEzC,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,iBAAiB,CAAA;CAC5B;AAED,MAAM,WAAW,2BAA2B;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,GAAmB,EACnB,YAAgB,GACjB,GAAE,2BAAgC;;;;;;;;;;;;KAiBlC;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,MAAM,EACX,EAAE,GAAmB,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO;;;;GAkB/C"}
@@ -0,0 +1,146 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { globby } from "globby";
4
+ export const configFileNames = [
5
+ "automate.config.ts",
6
+ "automate.config.mts",
7
+ "automate.config.cts",
8
+ "automate.config.js",
9
+ "automate.config.mjs",
10
+ "automate.config.cjs",
11
+ "automate.config.json",
12
+ ];
13
+ /** Preference order used when a directory contains multiple config formats. */
14
+ const configNamePriority = new Map(configFileNames.map((fileName, index) => [fileName, index]));
15
+ /**
16
+ * Finds the nearest project config directories around a working directory.
17
+ *
18
+ * @param options - Search root and maximum downward traversal depth.
19
+ * @param options.cwd - Directory from which to begin searching.
20
+ * @param options.maxDownDepth - Maximum descendant depth to inspect.
21
+ */
22
+ export async function findConfigDirMatches({ cwd = process.cwd(), maxDownDepth = 5, } = {}) {
23
+ const resolvedCwd = path.resolve(cwd);
24
+ const currentConfigPath = await findConfigPath(resolvedCwd);
25
+ if (currentConfigPath) {
26
+ return [
27
+ {
28
+ configPath: currentConfigPath,
29
+ dir: resolvedCwd,
30
+ priority: 0,
31
+ },
32
+ ];
33
+ }
34
+ const parentMatch = await findParentConfigDirMatch(resolvedCwd);
35
+ if (parentMatch)
36
+ return [parentMatch];
37
+ return findDownConfigDirMatches(resolvedCwd, maxDownDepth);
38
+ }
39
+ /**
40
+ * Resolves a user-selected directory and finds its project config file.
41
+ *
42
+ * @param dir - Directory path, relative to the supplied working directory.
43
+ * @param options - Resolution options.
44
+ * @param options.cwd - Base directory for resolving `dir`.
45
+ * @throws When the directory contains no recognized config file.
46
+ */
47
+ export async function findExplicitConfigDirMatch(dir, { cwd = process.cwd() } = {}) {
48
+ const resolvedDir = path.resolve(cwd, dir);
49
+ const configPath = await findConfigPath(resolvedDir);
50
+ if (!configPath) {
51
+ throw new Error(`No config found in ${resolvedDir}. Expected one of: ${configFileNames.join(", ")}`);
52
+ }
53
+ return {
54
+ configPath,
55
+ dir: resolvedDir,
56
+ priority: 0,
57
+ };
58
+ }
59
+ /**
60
+ * Walks parent directories looking for the nearest project config.
61
+ *
62
+ * @param cwd - Directory whose parents should be searched.
63
+ */
64
+ async function findParentConfigDirMatch(cwd) {
65
+ let dir = path.dirname(cwd);
66
+ while (dir !== cwd) {
67
+ const configPath = await findConfigPath(dir);
68
+ if (configPath) {
69
+ return {
70
+ configPath,
71
+ dir,
72
+ priority: 1,
73
+ };
74
+ }
75
+ const parent = path.dirname(dir);
76
+ if (parent === dir)
77
+ return null;
78
+ dir = parent;
79
+ }
80
+ return null;
81
+ }
82
+ /**
83
+ * Finds project configs below a directory within a fixed depth.
84
+ *
85
+ * @param cwd - Directory whose descendants should be searched.
86
+ * @param maxDepth - Maximum number of descendant levels to inspect.
87
+ */
88
+ async function findDownConfigDirMatches(cwd, maxDepth) {
89
+ const configPathByDir = new Map();
90
+ for (const configPath of await globby(configFileNames.map((fileName) => `**/${fileName}`), {
91
+ absolute: true,
92
+ cwd,
93
+ deep: maxDepth + 1,
94
+ gitignore: true,
95
+ onlyFiles: true,
96
+ })) {
97
+ const dir = path.dirname(configPath);
98
+ const currentConfigPath = configPathByDir.get(dir);
99
+ if (!currentConfigPath ||
100
+ getConfigNamePriority(configPath) <
101
+ getConfigNamePriority(currentConfigPath)) {
102
+ configPathByDir.set(dir, configPath);
103
+ }
104
+ }
105
+ return Array.from(configPathByDir.entries())
106
+ .map(([dir, configPath]) => ({
107
+ configPath,
108
+ dir,
109
+ priority: 2,
110
+ }))
111
+ .toSorted((a, b) => a.dir.localeCompare(b.dir));
112
+ }
113
+ /**
114
+ * Finds the highest-priority recognized config file in a directory.
115
+ *
116
+ * @param dir - Directory to inspect.
117
+ */
118
+ async function findConfigPath(dir) {
119
+ for (const fileName of configFileNames) {
120
+ const configPath = path.join(dir, fileName);
121
+ if (await isFile(configPath))
122
+ return configPath;
123
+ }
124
+ return null;
125
+ }
126
+ /**
127
+ * Checks whether a path points to a regular file.
128
+ *
129
+ * @param filePath - Filesystem path to inspect.
130
+ */
131
+ async function isFile(filePath) {
132
+ try {
133
+ return (await fs.stat(filePath)).isFile();
134
+ }
135
+ catch {
136
+ return false;
137
+ }
138
+ }
139
+ /**
140
+ * Looks up a config filename's selection priority.
141
+ *
142
+ * @param configPath - Full config path whose basename should be ranked.
143
+ */
144
+ function getConfigNamePriority(configPath) {
145
+ return configNamePriority.get(path.basename(configPath)) ?? Infinity;
146
+ }
@@ -0,0 +1,16 @@
1
+ /** Layout options for a terminal detail block. */
2
+ type DetailBlockOptions = {
3
+ keyAlignment?: "left" | "right";
4
+ lineSpacing?: number;
5
+ padding?: number;
6
+ separator?: string | null;
7
+ };
8
+ /**
9
+ * Renders labeled values as an aligned, multiline terminal detail block.
10
+ *
11
+ * @param details - Labels mapped to values; nullish values are omitted.
12
+ * @param options - Alignment, spacing, padding, and separator settings.
13
+ */
14
+ export declare function renderDetailBlock(details: Record<string, string | number | boolean | null | undefined>, options?: DetailBlockOptions): string;
15
+ export {};
16
+ //# sourceMappingURL=detail-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detail-block.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/detail-block.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,KAAK,kBAAkB,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EACrE,OAAO,GAAE,kBAAuB,UA2BjC"}
@@ -0,0 +1,25 @@
1
+ import stringWidth from "string-width";
2
+ /**
3
+ * Renders labeled values as an aligned, multiline terminal detail block.
4
+ *
5
+ * @param details - Labels mapped to values; nullish values are omitted.
6
+ * @param options - Alignment, spacing, padding, and separator settings.
7
+ */
8
+ export function renderDetailBlock(details, options = {}) {
9
+ const { keyAlignment = "left", lineSpacing = 0, padding = 2, separator = "", } = options;
10
+ const entries = Object.entries(details).filter(([, v]) => v != null);
11
+ const keyWidth = Math.max(0, ...entries.map(([key]) => stringWidth(key)));
12
+ return entries
13
+ .map(([key, value]) => {
14
+ const keyPadding = " ".repeat(keyWidth - stringWidth(key));
15
+ const valuePadding = " ".repeat(padding);
16
+ const separatorValue = separator || "";
17
+ const continuationPadding = " ".repeat(keyWidth + stringWidth(separatorValue) + padding);
18
+ const [firstLine = "", ...remainingLines] = String(value).split("\n");
19
+ return [
20
+ `${keyAlignment === "right" ? `${keyPadding}${key}` : key}${separatorValue}${keyAlignment === "right" ? valuePadding : `${keyPadding}${valuePadding}`}${firstLine}`,
21
+ ...remainingLines.map((line) => `${continuationPadding}${line}`),
22
+ ].join("\n");
23
+ })
24
+ .join("\n".repeat(Math.max(0, Math.trunc(lineSpacing)) + 1));
25
+ }
@@ -0,0 +1,4 @@
1
+ export declare const env: {
2
+ APP_ORIGIN: string;
3
+ };
4
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;CAIK,CAAA"}
@@ -0,0 +1,7 @@
1
+ import z from "zod";
2
+ const DEFAULT_APP_ORIGIN = "https://automate.ax";
3
+ export const env = z
4
+ .object({
5
+ APP_ORIGIN: z.url().prefault(DEFAULT_APP_ORIGIN),
6
+ })
7
+ .parse(process.env);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hijack-clack-logger.d.ts.map