@avaprotocol/sdk-js 2.17.0 → 4.0.0-dev.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 (140) hide show
  1. package/dist/index.d.ts +1 -370
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +737 -22356
  4. package/dist/index.mjs +699 -22386
  5. package/dist/v4/auth.d.ts +54 -0
  6. package/dist/v4/auth.d.ts.map +1 -0
  7. package/dist/v4/auth.js +70 -0
  8. package/dist/v4/builders/nodes.d.ts +103 -0
  9. package/dist/v4/builders/nodes.d.ts.map +1 -0
  10. package/dist/v4/builders/nodes.js +132 -0
  11. package/dist/v4/builders/triggers.d.ts +66 -0
  12. package/dist/v4/builders/triggers.d.ts.map +1 -0
  13. package/dist/v4/builders/triggers.js +74 -0
  14. package/dist/v4/chains.d.ts +16 -0
  15. package/dist/v4/chains.d.ts.map +1 -0
  16. package/dist/v4/chains.js +23 -0
  17. package/dist/v4/client.d.ts +60 -0
  18. package/dist/v4/client.d.ts.map +1 -0
  19. package/dist/v4/client.js +53 -0
  20. package/dist/v4/index.d.ts +18 -0
  21. package/dist/v4/index.d.ts.map +1 -0
  22. package/dist/v4/index.js +23 -0
  23. package/dist/v4/internal/errors.d.ts +36 -0
  24. package/dist/v4/internal/errors.d.ts.map +1 -0
  25. package/dist/v4/internal/errors.js +32 -0
  26. package/dist/v4/internal/transport.d.ts +64 -0
  27. package/dist/v4/internal/transport.d.ts.map +1 -0
  28. package/dist/v4/internal/transport.js +133 -0
  29. package/dist/v4/resources/auth.d.ts +39 -0
  30. package/dist/v4/resources/auth.d.ts.map +1 -0
  31. package/dist/v4/resources/auth.js +53 -0
  32. package/dist/v4/resources/executions.d.ts +68 -0
  33. package/dist/v4/resources/executions.d.ts.map +1 -0
  34. package/dist/v4/resources/executions.js +126 -0
  35. package/dist/v4/resources/health.d.ts +9 -0
  36. package/dist/v4/resources/health.d.ts.map +1 -0
  37. package/dist/v4/resources/health.js +9 -0
  38. package/dist/v4/resources/nodes.d.ts +9 -0
  39. package/dist/v4/resources/nodes.d.ts.map +1 -0
  40. package/dist/v4/resources/nodes.js +13 -0
  41. package/dist/v4/resources/operators.d.ts +9 -0
  42. package/dist/v4/resources/operators.d.ts.map +1 -0
  43. package/dist/v4/resources/operators.js +9 -0
  44. package/dist/v4/resources/secrets.d.ts +24 -0
  45. package/dist/v4/resources/secrets.d.ts.map +1 -0
  46. package/dist/v4/resources/secrets.js +28 -0
  47. package/dist/v4/resources/tokens.d.ts +16 -0
  48. package/dist/v4/resources/tokens.d.ts.map +1 -0
  49. package/dist/v4/resources/tokens.js +17 -0
  50. package/dist/v4/resources/triggers.d.ts +9 -0
  51. package/dist/v4/resources/triggers.d.ts.map +1 -0
  52. package/dist/v4/resources/triggers.js +13 -0
  53. package/dist/v4/resources/wallets.d.ts +25 -0
  54. package/dist/v4/resources/wallets.d.ts.map +1 -0
  55. package/dist/v4/resources/wallets.js +45 -0
  56. package/dist/v4/resources/workflows.d.ts +54 -0
  57. package/dist/v4/resources/workflows.d.ts.map +1 -0
  58. package/dist/v4/resources/workflows.js +81 -0
  59. package/package.json +4 -12
  60. package/dist/auth.d.ts +0 -2
  61. package/dist/auth.d.ts.map +0 -1
  62. package/dist/auth.js +0 -10
  63. package/dist/config.d.ts +0 -9
  64. package/dist/config.d.ts.map +0 -1
  65. package/dist/config.js +0 -19
  66. package/dist/models/edge.d.ts +0 -12
  67. package/dist/models/edge.d.ts.map +0 -1
  68. package/dist/models/edge.js +0 -19
  69. package/dist/models/execution.d.ts +0 -30
  70. package/dist/models/execution.d.ts.map +0 -1
  71. package/dist/models/execution.js +0 -100
  72. package/dist/models/node/balance.d.ts +0 -17
  73. package/dist/models/node/balance.d.ts.map +0 -1
  74. package/dist/models/node/balance.js +0 -78
  75. package/dist/models/node/branch.d.ts +0 -11
  76. package/dist/models/node/branch.d.ts.map +0 -1
  77. package/dist/models/node/branch.js +0 -63
  78. package/dist/models/node/contractRead.d.ts +0 -17
  79. package/dist/models/node/contractRead.d.ts.map +0 -1
  80. package/dist/models/node/contractRead.js +0 -91
  81. package/dist/models/node/contractWrite.d.ts +0 -17
  82. package/dist/models/node/contractWrite.d.ts.map +0 -1
  83. package/dist/models/node/contractWrite.js +0 -102
  84. package/dist/models/node/customCode.d.ts +0 -20
  85. package/dist/models/node/customCode.d.ts.map +0 -1
  86. package/dist/models/node/customCode.js +0 -74
  87. package/dist/models/node/ethTransfer.d.ts +0 -20
  88. package/dist/models/node/ethTransfer.d.ts.map +0 -1
  89. package/dist/models/node/ethTransfer.js +0 -58
  90. package/dist/models/node/factory.d.ts +0 -24
  91. package/dist/models/node/factory.d.ts.map +0 -1
  92. package/dist/models/node/factory.js +0 -108
  93. package/dist/models/node/filter.d.ts +0 -11
  94. package/dist/models/node/filter.d.ts.map +0 -1
  95. package/dist/models/node/filter.js +0 -57
  96. package/dist/models/node/graphqlQuery.d.ts +0 -21
  97. package/dist/models/node/graphqlQuery.d.ts.map +0 -1
  98. package/dist/models/node/graphqlQuery.js +0 -74
  99. package/dist/models/node/interface.d.ts +0 -20
  100. package/dist/models/node/interface.d.ts.map +0 -1
  101. package/dist/models/node/interface.js +0 -58
  102. package/dist/models/node/loop.d.ts +0 -15
  103. package/dist/models/node/loop.d.ts.map +0 -1
  104. package/dist/models/node/loop.js +0 -235
  105. package/dist/models/node/restApi.d.ts +0 -23
  106. package/dist/models/node/restApi.d.ts.map +0 -1
  107. package/dist/models/node/restApi.js +0 -84
  108. package/dist/models/secret.d.ts +0 -16
  109. package/dist/models/secret.d.ts.map +0 -1
  110. package/dist/models/secret.js +0 -28
  111. package/dist/models/step.d.ts +0 -33
  112. package/dist/models/step.d.ts.map +0 -1
  113. package/dist/models/step.js +0 -287
  114. package/dist/models/trigger/block.d.ts +0 -21
  115. package/dist/models/trigger/block.d.ts.map +0 -1
  116. package/dist/models/trigger/block.js +0 -81
  117. package/dist/models/trigger/cron.d.ts +0 -23
  118. package/dist/models/trigger/cron.d.ts.map +0 -1
  119. package/dist/models/trigger/cron.js +0 -77
  120. package/dist/models/trigger/event.d.ts +0 -22
  121. package/dist/models/trigger/event.d.ts.map +0 -1
  122. package/dist/models/trigger/event.js +0 -244
  123. package/dist/models/trigger/factory.d.ts +0 -27
  124. package/dist/models/trigger/factory.d.ts.map +0 -1
  125. package/dist/models/trigger/factory.js +0 -73
  126. package/dist/models/trigger/fixedTime.d.ts +0 -23
  127. package/dist/models/trigger/fixedTime.d.ts.map +0 -1
  128. package/dist/models/trigger/fixedTime.js +0 -69
  129. package/dist/models/trigger/interface.d.ts +0 -19
  130. package/dist/models/trigger/interface.d.ts.map +0 -1
  131. package/dist/models/trigger/interface.js +0 -35
  132. package/dist/models/trigger/manual.d.ts +0 -16
  133. package/dist/models/trigger/manual.d.ts.map +0 -1
  134. package/dist/models/trigger/manual.js +0 -117
  135. package/dist/models/workflow.d.ts +0 -53
  136. package/dist/models/workflow.d.ts.map +0 -1
  137. package/dist/models/workflow.js +0 -219
  138. package/dist/utils.d.ts +0 -82
  139. package/dist/utils.d.ts.map +0 -1
  140. package/dist/utils.js +0 -286
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Canonical EIP-191 message template the aggregator's auth handler
3
+ * verifies. Must match the format documented in the API spec.
4
+ *
5
+ * Filled by `buildAuthMessage` below; the SDK exports both halves
6
+ * (build + sign) so non-SDK callers (web wallets, smart-account
7
+ * signers) can produce a message that exchanges cleanly.
8
+ */
9
+ export declare const AUTH_TEMPLATE = "Please sign the below text for ownership verification.\n\nURI: https://app.avaprotocol.org\nChain ID: {chainId}\nVersion: {version}\nIssued At: {issuedAt}\nExpire At: {expireAt}\nWallet: {wallet}";
10
+ export interface BuildAuthMessageInput {
11
+ /** EOA the JWT will be bound to. Lowercased / checksummed both work. */
12
+ ownerAddress: string;
13
+ /**
14
+ * Chain id to embed in the canonical message. Defaults to
15
+ * `Chains.EigenLayerAuth` — the auth flow is chain-agnostic, the
16
+ * embedded id only tells the verifier which chain bucket the
17
+ * minted JWT belongs to.
18
+ */
19
+ chainId?: number;
20
+ /** SDK version string surfaced in the message (purely informational). */
21
+ version?: string;
22
+ /** Issuance timestamp; defaults to `new Date()`. */
23
+ issuedAt?: Date;
24
+ /** Token expiry; defaults to 24h from issuedAt. */
25
+ expireAt?: Date;
26
+ }
27
+ export interface BuiltAuthMessage {
28
+ readonly message: string;
29
+ readonly chainId: number;
30
+ readonly ownerAddress: string;
31
+ readonly expireAt: Date;
32
+ }
33
+ /**
34
+ * Build the canonical auth message a wallet must sign. Pure — does
35
+ * no signing — so it can run in the browser before opening the wallet
36
+ * popup.
37
+ */
38
+ export declare function buildAuthMessage(input: BuildAuthMessageInput): BuiltAuthMessage;
39
+ /**
40
+ * One-shot helper: build the message, sign it with the supplied
41
+ * private key, and return the payload ready for
42
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
43
+ * where the private key is in hand; browser flows use
44
+ * `buildAuthMessage` + a wallet's `personal_sign`.
45
+ */
46
+ export declare function signAuthMessage(privateKey: string, input?: Omit<BuildAuthMessageInput, "ownerAddress"> & {
47
+ ownerAddress?: string;
48
+ }): Promise<{
49
+ message: string;
50
+ signature: string;
51
+ ownerAddress: string;
52
+ expireAt: Date;
53
+ }>;
54
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/v4/auth.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,wMAOT,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAc/E;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9E,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC,CAkBvF"}
@@ -0,0 +1,70 @@
1
+ import { Wallet, getAddress } from "ethers";
2
+ import { Chains } from "./chains";
3
+ /**
4
+ * Canonical EIP-191 message template the aggregator's auth handler
5
+ * verifies. Must match the format documented in the API spec.
6
+ *
7
+ * Filled by `buildAuthMessage` below; the SDK exports both halves
8
+ * (build + sign) so non-SDK callers (web wallets, smart-account
9
+ * signers) can produce a message that exchanges cleanly.
10
+ */
11
+ export const AUTH_TEMPLATE = `Please sign the below text for ownership verification.
12
+
13
+ URI: https://app.avaprotocol.org
14
+ Chain ID: {chainId}
15
+ Version: {version}
16
+ Issued At: {issuedAt}
17
+ Expire At: {expireAt}
18
+ Wallet: {wallet}`;
19
+ /**
20
+ * Build the canonical auth message a wallet must sign. Pure — does
21
+ * no signing — so it can run in the browser before opening the wallet
22
+ * popup.
23
+ */
24
+ export function buildAuthMessage(input) {
25
+ const issuedAt = input.issuedAt ?? new Date();
26
+ const expireAt = input.expireAt ?? new Date(issuedAt.getTime() + 24 * 60 * 60 * 1000);
27
+ const chainId = input.chainId ?? Chains.EigenLayerAuth;
28
+ // Canonicalize the address so the wire form matches what the
29
+ // aggregator extracts via crypto.PubkeyToAddress.
30
+ const ownerAddress = getAddress(input.ownerAddress);
31
+ const message = AUTH_TEMPLATE
32
+ .replace("{chainId}", String(chainId))
33
+ .replace("{version}", input.version ?? "v4-sdk")
34
+ .replace("{issuedAt}", toRFC3339Millis(issuedAt))
35
+ .replace("{expireAt}", toRFC3339Millis(expireAt))
36
+ .replace("{wallet}", ownerAddress);
37
+ return { message, chainId, ownerAddress, expireAt };
38
+ }
39
+ /**
40
+ * One-shot helper: build the message, sign it with the supplied
41
+ * private key, and return the payload ready for
42
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
43
+ * where the private key is in hand; browser flows use
44
+ * `buildAuthMessage` + a wallet's `personal_sign`.
45
+ */
46
+ export async function signAuthMessage(privateKey, input) {
47
+ const signer = new Wallet(privateKey);
48
+ const built = buildAuthMessage({
49
+ ownerAddress: input?.ownerAddress ?? signer.address,
50
+ chainId: input?.chainId,
51
+ version: input?.version,
52
+ issuedAt: input?.issuedAt,
53
+ expireAt: input?.expireAt,
54
+ });
55
+ // signMessage performs EIP-191 personal_sign — the same prefix
56
+ // accounts.TextHash uses on the verifier side.
57
+ const signature = await signer.signMessage(built.message);
58
+ return {
59
+ message: built.message,
60
+ signature,
61
+ ownerAddress: built.ownerAddress,
62
+ expireAt: built.expireAt,
63
+ };
64
+ }
65
+ // toRFC3339Millis renders a Date as `2026-05-25T12:00:00.000Z`. Matches
66
+ // the format the aggregator's verifier parses with the layout
67
+ // `2006-01-02T15:04:05.000Z`.
68
+ function toRFC3339Millis(d) {
69
+ return d.toISOString().replace(/(\.\d{3})\d*Z$/, "$1Z");
70
+ }
@@ -0,0 +1,103 @@
1
+ import type { v4 } from "@avaprotocol/types";
2
+ /**
3
+ * Typed builders for the Node discriminated union. Same convention
4
+ * as `Triggers`: each builder returns a plain JSON object shaped
5
+ * like `v4.Node` (no class instances).
6
+ *
7
+ * import { Nodes } from "@avaprotocol/sdk-js";
8
+ * const node = Nodes.customCode({ id: "step1", name: "step1",
9
+ * source: "return {ok: true};" });
10
+ * await client.workflows.create({ trigger, nodes: [node], ... });
11
+ */
12
+ export declare const Nodes: Readonly<{
13
+ ethTransfer(opts: {
14
+ id: string;
15
+ name: string;
16
+ destination: string;
17
+ amountWei: string;
18
+ chainId?: number;
19
+ }): v4.Node;
20
+ contractWrite(opts: {
21
+ id: string;
22
+ name: string;
23
+ contractAddress: string;
24
+ contractAbi?: Array<Record<string, unknown>>;
25
+ methodCalls?: Array<{
26
+ methodName: string;
27
+ methodParams?: string[];
28
+ callData?: string;
29
+ applyToFields?: string[];
30
+ }>;
31
+ callData?: string;
32
+ isSimulated?: boolean;
33
+ valueWei?: string;
34
+ gasLimit?: string;
35
+ chainId?: number;
36
+ }): v4.Node;
37
+ contractRead(opts: {
38
+ id: string;
39
+ name: string;
40
+ contractAddress: string;
41
+ contractAbi?: Array<Record<string, unknown>>;
42
+ methodCalls?: Array<{
43
+ methodName: string;
44
+ methodParams?: string[];
45
+ callData?: string;
46
+ applyToFields?: string[];
47
+ }>;
48
+ chainId?: number;
49
+ }): v4.Node;
50
+ graphqlQuery(opts: {
51
+ id: string;
52
+ name: string;
53
+ url: string;
54
+ query: string;
55
+ variables?: Record<string, string>;
56
+ }): v4.Node;
57
+ restApi(opts: {
58
+ id: string;
59
+ name: string;
60
+ url: string;
61
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
62
+ body?: string;
63
+ headers?: Record<string, string>;
64
+ }): v4.Node;
65
+ branch(opts: {
66
+ id: string;
67
+ name: string;
68
+ conditions: Array<{
69
+ id: string;
70
+ expression: string;
71
+ type?: "if" | "elseIf" | "else";
72
+ }>;
73
+ }): v4.Node;
74
+ filter(opts: {
75
+ id: string;
76
+ name: string;
77
+ expression: string;
78
+ inputVariable: string;
79
+ }): v4.Node;
80
+ loop(opts: {
81
+ id: string;
82
+ name: string;
83
+ inputVariable: string;
84
+ iterVar?: string;
85
+ runner: v4.Node;
86
+ }): v4.Node;
87
+ customCode(opts: {
88
+ id: string;
89
+ name: string;
90
+ source: string;
91
+ lang?: v4.Lang;
92
+ }): v4.Node;
93
+ balance(opts: {
94
+ id: string;
95
+ name: string;
96
+ address: string;
97
+ chain: string;
98
+ includeSpam?: boolean;
99
+ includeZeroBalances?: boolean;
100
+ minUsdValueCents?: number;
101
+ }): v4.Node;
102
+ }>;
103
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/v4/builders/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK;sBACE;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,EAAE,CAAC,IAAI;wBAaS;QAClB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7C,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;YACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;SAC1B,CAAC,CAAC;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM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,IAAI,GAAG,QAAQ,GAAG,MAAM,CAAA;SAAE,CAAC,CAAC;KACxF,GAAG,EAAE,CAAC,IAAI;iBASE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,EAAE,CAAC,IAAI;eASnF;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;KACjB,GAAG,EAAE,CAAC,IAAI;qBAaM;QACf,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;KAChB,GAAG,EAAE,CAAC,IAAI;kBAYG;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,EAAE,CAAC,IAAI;EAcX,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Typed builders for the Node discriminated union. Same convention
3
+ * as `Triggers`: each builder returns a plain JSON object shaped
4
+ * like `v4.Node` (no class instances).
5
+ *
6
+ * import { Nodes } from "@avaprotocol/sdk-js";
7
+ * const node = Nodes.customCode({ id: "step1", name: "step1",
8
+ * source: "return {ok: true};" });
9
+ * await client.workflows.create({ trigger, nodes: [node], ... });
10
+ */
11
+ export const Nodes = Object.freeze({
12
+ ethTransfer(opts) {
13
+ return {
14
+ id: opts.id,
15
+ name: opts.name,
16
+ type: "ethTransfer",
17
+ config: {
18
+ destination: opts.destination,
19
+ amount: opts.amountWei,
20
+ ...(opts.chainId ? { chainId: opts.chainId } : {}),
21
+ },
22
+ };
23
+ },
24
+ contractWrite(opts) {
25
+ return {
26
+ id: opts.id,
27
+ name: opts.name,
28
+ type: "contractWrite",
29
+ config: {
30
+ contractAddress: opts.contractAddress,
31
+ ...(opts.contractAbi ? { contractAbi: opts.contractAbi } : {}),
32
+ ...(opts.methodCalls ? { methodCalls: opts.methodCalls } : {}),
33
+ ...(opts.callData ? { callData: opts.callData } : {}),
34
+ ...(opts.isSimulated !== undefined ? { isSimulated: opts.isSimulated } : {}),
35
+ ...(opts.valueWei ? { value: opts.valueWei } : {}),
36
+ ...(opts.gasLimit ? { gasLimit: opts.gasLimit } : {}),
37
+ ...(opts.chainId ? { chainId: opts.chainId } : {}),
38
+ },
39
+ };
40
+ },
41
+ contractRead(opts) {
42
+ return {
43
+ id: opts.id,
44
+ name: opts.name,
45
+ type: "contractRead",
46
+ config: {
47
+ contractAddress: opts.contractAddress,
48
+ ...(opts.contractAbi ? { contractAbi: opts.contractAbi } : {}),
49
+ ...(opts.methodCalls ? { methodCalls: opts.methodCalls } : {}),
50
+ ...(opts.chainId ? { chainId: opts.chainId } : {}),
51
+ },
52
+ };
53
+ },
54
+ graphqlQuery(opts) {
55
+ return {
56
+ id: opts.id,
57
+ name: opts.name,
58
+ type: "graphqlQuery",
59
+ config: {
60
+ url: opts.url,
61
+ query: opts.query,
62
+ ...(opts.variables ? { variables: opts.variables } : {}),
63
+ },
64
+ };
65
+ },
66
+ restApi(opts) {
67
+ return {
68
+ id: opts.id,
69
+ name: opts.name,
70
+ type: "restApi",
71
+ config: {
72
+ url: opts.url,
73
+ method: opts.method,
74
+ ...(opts.body ? { body: opts.body } : {}),
75
+ ...(opts.headers ? { headers: opts.headers } : {}),
76
+ },
77
+ };
78
+ },
79
+ branch(opts) {
80
+ return {
81
+ id: opts.id,
82
+ name: opts.name,
83
+ type: "branch",
84
+ config: { conditions: opts.conditions },
85
+ };
86
+ },
87
+ filter(opts) {
88
+ return {
89
+ id: opts.id,
90
+ name: opts.name,
91
+ type: "filter",
92
+ config: { expression: opts.expression, inputVariable: opts.inputVariable },
93
+ };
94
+ },
95
+ loop(opts) {
96
+ return {
97
+ id: opts.id,
98
+ name: opts.name,
99
+ type: "loop",
100
+ config: {
101
+ inputVariable: opts.inputVariable,
102
+ ...(opts.iterVar ? { iterVar: opts.iterVar } : {}),
103
+ runner: opts.runner,
104
+ },
105
+ };
106
+ },
107
+ customCode(opts) {
108
+ return {
109
+ id: opts.id,
110
+ name: opts.name,
111
+ type: "customCode",
112
+ config: {
113
+ source: opts.source,
114
+ lang: opts.lang ?? "javascript",
115
+ },
116
+ };
117
+ },
118
+ balance(opts) {
119
+ return {
120
+ id: opts.id,
121
+ name: opts.name,
122
+ type: "balance",
123
+ config: {
124
+ address: opts.address,
125
+ chain: opts.chain,
126
+ ...(opts.includeSpam !== undefined ? { includeSpam: opts.includeSpam } : {}),
127
+ ...(opts.includeZeroBalances !== undefined ? { includeZeroBalances: opts.includeZeroBalances } : {}),
128
+ ...(opts.minUsdValueCents !== undefined ? { minUsdValueCents: opts.minUsdValueCents } : {}),
129
+ },
130
+ };
131
+ },
132
+ });
@@ -0,0 +1,66 @@
1
+ import type { v4 } from "@avaprotocol/types";
2
+ /**
3
+ * Typed builders for the Trigger discriminated union. Output is a
4
+ * plain JSON object shaped like `v4.Trigger` (no class instances) so
5
+ * it round-trips cleanly across the REST boundary.
6
+ *
7
+ * Conventional usage:
8
+ *
9
+ * import { Triggers } from "@avaprotocol/sdk-js";
10
+ * const trigger = Triggers.cron({ name: "every5min", schedule: ["asterisk/5 * * * *"] });
11
+ * const wf = await client.workflows.create({ trigger, nodes, ... });
12
+ *
13
+ * The builders ARE NOT classes — calling each returns a plain object
14
+ * the REST surface accepts. Keep the same shape on the wire whether
15
+ * SDK callers use the builder or hand-assemble the object.
16
+ */
17
+ export declare const Triggers: Readonly<{
18
+ block(opts: {
19
+ name: string;
20
+ id?: string;
21
+ interval: number;
22
+ chainId?: number;
23
+ }): v4.Trigger;
24
+ cron(opts: {
25
+ name: string;
26
+ id?: string;
27
+ /** Crontab strings — multiple schedules OR together. */
28
+ schedule: string[];
29
+ timezone?: string;
30
+ }): v4.Trigger;
31
+ fixedTime(opts: {
32
+ name: string;
33
+ id?: string;
34
+ epochsMs: number[];
35
+ }): v4.Trigger;
36
+ manual(opts: {
37
+ name: string;
38
+ id?: string;
39
+ lang?: v4.Lang;
40
+ /** Payload returned in the trigger output when the workflow is triggered. */
41
+ data?: Record<string, unknown>;
42
+ /** Optional HTTP headers (for webhook-style testing). */
43
+ headers?: Record<string, string>;
44
+ /** Optional URL path params (for webhook-style testing). */
45
+ pathParams?: Record<string, string>;
46
+ }): v4.Trigger;
47
+ event(opts: {
48
+ name: string;
49
+ id?: string;
50
+ queries: Array<{
51
+ addresses?: string[];
52
+ /** Topic filters; empty string ("") matches any topic at that index. */
53
+ topics?: string[];
54
+ maxEventsPerBlock?: number;
55
+ conditions?: Array<{
56
+ fieldName: string;
57
+ operator: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains";
58
+ fieldType?: string;
59
+ value: Record<string, unknown>;
60
+ }>;
61
+ }>;
62
+ chainId?: number;
63
+ cooldownSeconds?: number;
64
+ }): v4.Trigger;
65
+ }>;
66
+ //# sourceMappingURL=triggers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/v4/builders/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ;gBACP;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,C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CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;aAChC,CAAC,CAAC;SACJ,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,GAAG,EAAE,CAAC,OAAO;EAYd,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Typed builders for the Trigger discriminated union. Output is a
3
+ * plain JSON object shaped like `v4.Trigger` (no class instances) so
4
+ * it round-trips cleanly across the REST boundary.
5
+ *
6
+ * Conventional usage:
7
+ *
8
+ * import { Triggers } from "@avaprotocol/sdk-js";
9
+ * const trigger = Triggers.cron({ name: "every5min", schedule: ["asterisk/5 * * * *"] });
10
+ * const wf = await client.workflows.create({ trigger, nodes, ... });
11
+ *
12
+ * The builders ARE NOT classes — calling each returns a plain object
13
+ * the REST surface accepts. Keep the same shape on the wire whether
14
+ * SDK callers use the builder or hand-assemble the object.
15
+ */
16
+ export const Triggers = Object.freeze({
17
+ block(opts) {
18
+ return {
19
+ type: "block",
20
+ name: opts.name,
21
+ ...(opts.id ? { id: opts.id } : {}),
22
+ // The OpenAPI Trigger schema is a discriminated union — the
23
+ // inline shape below carries the BlockTrigger's `config` slot
24
+ // alongside the discriminator. Both forms (`{type, config}` and
25
+ // the `BlockTrigger.type` enum) survive the wire-level merge
26
+ // oapi-codegen's serializer performs.
27
+ config: { interval: opts.interval, ...(opts.chainId ? { chainId: opts.chainId } : {}) },
28
+ };
29
+ },
30
+ cron(opts) {
31
+ return {
32
+ type: "cron",
33
+ name: opts.name,
34
+ ...(opts.id ? { id: opts.id } : {}),
35
+ config: {
36
+ schedules: opts.schedule,
37
+ ...(opts.timezone ? { timezone: opts.timezone } : {}),
38
+ },
39
+ };
40
+ },
41
+ fixedTime(opts) {
42
+ return {
43
+ type: "fixedTime",
44
+ name: opts.name,
45
+ ...(opts.id ? { id: opts.id } : {}),
46
+ config: { epochs: opts.epochsMs },
47
+ };
48
+ },
49
+ manual(opts) {
50
+ return {
51
+ type: "manual",
52
+ name: opts.name,
53
+ ...(opts.id ? { id: opts.id } : {}),
54
+ config: {
55
+ lang: opts.lang ?? "json",
56
+ ...(opts.data !== undefined ? { data: opts.data } : {}),
57
+ ...(opts.headers ? { headers: opts.headers } : {}),
58
+ ...(opts.pathParams ? { pathParams: opts.pathParams } : {}),
59
+ },
60
+ };
61
+ },
62
+ event(opts) {
63
+ return {
64
+ type: "event",
65
+ name: opts.name,
66
+ ...(opts.id ? { id: opts.id } : {}),
67
+ config: {
68
+ queries: opts.queries,
69
+ ...(opts.chainId ? { chainId: opts.chainId } : {}),
70
+ ...(opts.cooldownSeconds !== undefined ? { cooldownSeconds: opts.cooldownSeconds } : {}),
71
+ },
72
+ };
73
+ },
74
+ });
@@ -0,0 +1,16 @@
1
+ export declare const Chains: Readonly<{
2
+ EthereumMainnet: 1;
3
+ Sepolia: 11155111;
4
+ Holesky: 17000;
5
+ BaseMainnet: 8453;
6
+ BaseSepolia: 84532;
7
+ /**
8
+ * The chain the auth handler signs the canonical EIP-191 message
9
+ * against. Defaults to Sepolia — keep this synced with the
10
+ * aggregator's `smart_wallet.chain_id` setting (currently Sepolia
11
+ * in dev/staging, Ethereum mainnet in production).
12
+ */
13
+ EigenLayerAuth: 11155111;
14
+ }>;
15
+ export type ChainId = (typeof Chains)[keyof typeof Chains] | number;
16
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/v4/chains.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM;;;;;;IAMjB;;;;;OAKG;;EAEH,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC"}
@@ -0,0 +1,23 @@
1
+ // Chain ID constants for v4 callers. The aggregator's REST API accepts
2
+ // any int64 chainId on chain-aware requests — these constants exist so
3
+ // SDK callers don't sprinkle magic numbers and so the auth flow has a
4
+ // single source of truth for which chain JWTs are minted against.
5
+ //
6
+ // `EigenLayerAuth` is the chain the aggregator's auth handler treats
7
+ // as the canonical audience. It does NOT have to match the workflow's
8
+ // target chain — the v4 auth flow is chain-agnostic. Keep this in
9
+ // lockstep with the engine's smart-wallet config.
10
+ export const Chains = Object.freeze({
11
+ EthereumMainnet: 1,
12
+ Sepolia: 11155111,
13
+ Holesky: 17000,
14
+ BaseMainnet: 8453,
15
+ BaseSepolia: 84532,
16
+ /**
17
+ * The chain the auth handler signs the canonical EIP-191 message
18
+ * against. Defaults to Sepolia — keep this synced with the
19
+ * aggregator's `smart_wallet.chain_id` setting (currently Sepolia
20
+ * in dev/staging, Ethereum mainnet in production).
21
+ */
22
+ EigenLayerAuth: 11155111,
23
+ });
@@ -0,0 +1,60 @@
1
+ import { AuthResource } from "./resources/auth";
2
+ import { ExecutionsResource } from "./resources/executions";
3
+ import { HealthResource } from "./resources/health";
4
+ import { NodesResource } from "./resources/nodes";
5
+ import { OperatorsResource } from "./resources/operators";
6
+ import { SecretsResource } from "./resources/secrets";
7
+ import { TokensResource } from "./resources/tokens";
8
+ import { TriggersResource } from "./resources/triggers";
9
+ import { WalletsResource } from "./resources/wallets";
10
+ import { WorkflowsResource } from "./resources/workflows";
11
+ export interface ClientOptions {
12
+ /**
13
+ * Base URL of the REST API including the `/api/v1` prefix. Example:
14
+ * `https://gateway.avaprotocol.org/api/v1`. The SDK does not append
15
+ * `/api/v1` for you; partners running their own aggregator instance
16
+ * can point baseUrl elsewhere if their reverse proxy strips the prefix.
17
+ */
18
+ baseUrl: string;
19
+ /**
20
+ * Optional pre-minted JWT. Skip if you'll call
21
+ * `client.auth.exchange()` after construction.
22
+ */
23
+ token?: string;
24
+ /** Default request timeout in milliseconds. Defaults to 30s. */
25
+ defaultTimeoutMs?: number;
26
+ /** Override the fetch impl. Useful for tests and non-Node runtimes. */
27
+ fetchImpl?: typeof fetch;
28
+ }
29
+ /**
30
+ * v4 SDK entry point. Resource-grouped sub-clients (Stripe / OpenAI
31
+ * convention). Construct one Client per aggregator endpoint; all
32
+ * requests share the same transport (and therefore the same Bearer
33
+ * token + timeout + fetch impl).
34
+ *
35
+ * @example
36
+ * import { Client } from "@avaprotocol/sdk-js";
37
+ * const client = new Client({ baseUrl: process.env.AVS_REST_URL! });
38
+ * await client.auth.exchangeWithKey(process.env.TEST_PRIVATE_KEY!);
39
+ * const wf = await client.workflows.create({ ... });
40
+ * await client.workflows.cancel(wf.id);
41
+ */
42
+ export declare class Client {
43
+ readonly auth: AuthResource;
44
+ readonly executions: ExecutionsResource;
45
+ readonly health: HealthResource;
46
+ readonly nodes: NodesResource;
47
+ readonly operators: OperatorsResource;
48
+ readonly secrets: SecretsResource;
49
+ readonly tokens: TokensResource;
50
+ readonly triggers: TriggersResource;
51
+ readonly wallets: WalletsResource;
52
+ readonly workflows: WorkflowsResource;
53
+ private readonly transport;
54
+ constructor(opts: ClientOptions);
55
+ /** Replace the current Bearer token. */
56
+ setToken(token: string | undefined): void;
57
+ /** Current Bearer token. Returns undefined when anonymous. */
58
+ get token(): string | undefined;
59
+ }
60
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v4/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,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