@avaprotocol/sdk-js 2.17.0 → 3.0.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 (145) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +11 -1
  3. package/dist/index.d.ts +1 -370
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +856 -22369
  6. package/dist/index.mjs +820 -22402
  7. package/dist/v4/auth.d.ts +79 -0
  8. package/dist/v4/auth.d.ts.map +1 -0
  9. package/dist/v4/auth.js +92 -0
  10. package/dist/v4/builders/nodes.d.ts +106 -0
  11. package/dist/v4/builders/nodes.d.ts.map +1 -0
  12. package/dist/v4/builders/nodes.js +133 -0
  13. package/dist/v4/builders/triggers.d.ts +66 -0
  14. package/dist/v4/builders/triggers.d.ts.map +1 -0
  15. package/dist/v4/builders/triggers.js +74 -0
  16. package/dist/v4/chains.d.ts +19 -0
  17. package/dist/v4/chains.d.ts.map +1 -0
  18. package/dist/v4/chains.js +22 -0
  19. package/dist/v4/client.d.ts +60 -0
  20. package/dist/v4/client.d.ts.map +1 -0
  21. package/dist/v4/client.js +53 -0
  22. package/dist/v4/index.d.ts +19 -0
  23. package/dist/v4/index.d.ts.map +1 -0
  24. package/dist/v4/index.js +24 -0
  25. package/dist/v4/internal/errors.d.ts +36 -0
  26. package/dist/v4/internal/errors.d.ts.map +1 -0
  27. package/dist/v4/internal/errors.js +32 -0
  28. package/dist/v4/internal/transport.d.ts +64 -0
  29. package/dist/v4/internal/transport.d.ts.map +1 -0
  30. package/dist/v4/internal/transport.js +133 -0
  31. package/dist/v4/protocols/index.d.ts +2 -0
  32. package/dist/v4/protocols/index.d.ts.map +1 -0
  33. package/dist/v4/protocols/index.js +13 -0
  34. package/dist/v4/resources/auth.d.ts +45 -0
  35. package/dist/v4/resources/auth.d.ts.map +1 -0
  36. package/dist/v4/resources/auth.js +59 -0
  37. package/dist/v4/resources/executions.d.ts +74 -0
  38. package/dist/v4/resources/executions.d.ts.map +1 -0
  39. package/dist/v4/resources/executions.js +132 -0
  40. package/dist/v4/resources/health.d.ts +19 -0
  41. package/dist/v4/resources/health.d.ts.map +1 -0
  42. package/dist/v4/resources/health.js +19 -0
  43. package/dist/v4/resources/nodes.d.ts +29 -0
  44. package/dist/v4/resources/nodes.d.ts.map +1 -0
  45. package/dist/v4/resources/nodes.js +33 -0
  46. package/dist/v4/resources/operators.d.ts +23 -0
  47. package/dist/v4/resources/operators.d.ts.map +1 -0
  48. package/dist/v4/resources/operators.js +23 -0
  49. package/dist/v4/resources/secrets.d.ts +34 -0
  50. package/dist/v4/resources/secrets.d.ts.map +1 -0
  51. package/dist/v4/resources/secrets.js +38 -0
  52. package/dist/v4/resources/tokens.d.ts +28 -0
  53. package/dist/v4/resources/tokens.d.ts.map +1 -0
  54. package/dist/v4/resources/tokens.js +29 -0
  55. package/dist/v4/resources/triggers.d.ts +29 -0
  56. package/dist/v4/resources/triggers.d.ts.map +1 -0
  57. package/dist/v4/resources/triggers.js +33 -0
  58. package/dist/v4/resources/wallets.d.ts +72 -0
  59. package/dist/v4/resources/wallets.d.ts.map +1 -0
  60. package/dist/v4/resources/wallets.js +92 -0
  61. package/dist/v4/resources/workflows.d.ts +64 -0
  62. package/dist/v4/resources/workflows.d.ts.map +1 -0
  63. package/dist/v4/resources/workflows.js +91 -0
  64. package/package.json +9 -11
  65. package/dist/auth.d.ts +0 -2
  66. package/dist/auth.d.ts.map +0 -1
  67. package/dist/auth.js +0 -10
  68. package/dist/config.d.ts +0 -9
  69. package/dist/config.d.ts.map +0 -1
  70. package/dist/config.js +0 -19
  71. package/dist/models/edge.d.ts +0 -12
  72. package/dist/models/edge.d.ts.map +0 -1
  73. package/dist/models/edge.js +0 -19
  74. package/dist/models/execution.d.ts +0 -30
  75. package/dist/models/execution.d.ts.map +0 -1
  76. package/dist/models/execution.js +0 -100
  77. package/dist/models/node/balance.d.ts +0 -17
  78. package/dist/models/node/balance.d.ts.map +0 -1
  79. package/dist/models/node/balance.js +0 -78
  80. package/dist/models/node/branch.d.ts +0 -11
  81. package/dist/models/node/branch.d.ts.map +0 -1
  82. package/dist/models/node/branch.js +0 -63
  83. package/dist/models/node/contractRead.d.ts +0 -17
  84. package/dist/models/node/contractRead.d.ts.map +0 -1
  85. package/dist/models/node/contractRead.js +0 -91
  86. package/dist/models/node/contractWrite.d.ts +0 -17
  87. package/dist/models/node/contractWrite.d.ts.map +0 -1
  88. package/dist/models/node/contractWrite.js +0 -102
  89. package/dist/models/node/customCode.d.ts +0 -20
  90. package/dist/models/node/customCode.d.ts.map +0 -1
  91. package/dist/models/node/customCode.js +0 -74
  92. package/dist/models/node/ethTransfer.d.ts +0 -20
  93. package/dist/models/node/ethTransfer.d.ts.map +0 -1
  94. package/dist/models/node/ethTransfer.js +0 -58
  95. package/dist/models/node/factory.d.ts +0 -24
  96. package/dist/models/node/factory.d.ts.map +0 -1
  97. package/dist/models/node/factory.js +0 -108
  98. package/dist/models/node/filter.d.ts +0 -11
  99. package/dist/models/node/filter.d.ts.map +0 -1
  100. package/dist/models/node/filter.js +0 -57
  101. package/dist/models/node/graphqlQuery.d.ts +0 -21
  102. package/dist/models/node/graphqlQuery.d.ts.map +0 -1
  103. package/dist/models/node/graphqlQuery.js +0 -74
  104. package/dist/models/node/interface.d.ts +0 -20
  105. package/dist/models/node/interface.d.ts.map +0 -1
  106. package/dist/models/node/interface.js +0 -58
  107. package/dist/models/node/loop.d.ts +0 -15
  108. package/dist/models/node/loop.d.ts.map +0 -1
  109. package/dist/models/node/loop.js +0 -235
  110. package/dist/models/node/restApi.d.ts +0 -23
  111. package/dist/models/node/restApi.d.ts.map +0 -1
  112. package/dist/models/node/restApi.js +0 -84
  113. package/dist/models/secret.d.ts +0 -16
  114. package/dist/models/secret.d.ts.map +0 -1
  115. package/dist/models/secret.js +0 -28
  116. package/dist/models/step.d.ts +0 -33
  117. package/dist/models/step.d.ts.map +0 -1
  118. package/dist/models/step.js +0 -287
  119. package/dist/models/trigger/block.d.ts +0 -21
  120. package/dist/models/trigger/block.d.ts.map +0 -1
  121. package/dist/models/trigger/block.js +0 -81
  122. package/dist/models/trigger/cron.d.ts +0 -23
  123. package/dist/models/trigger/cron.d.ts.map +0 -1
  124. package/dist/models/trigger/cron.js +0 -77
  125. package/dist/models/trigger/event.d.ts +0 -22
  126. package/dist/models/trigger/event.d.ts.map +0 -1
  127. package/dist/models/trigger/event.js +0 -244
  128. package/dist/models/trigger/factory.d.ts +0 -27
  129. package/dist/models/trigger/factory.d.ts.map +0 -1
  130. package/dist/models/trigger/factory.js +0 -73
  131. package/dist/models/trigger/fixedTime.d.ts +0 -23
  132. package/dist/models/trigger/fixedTime.d.ts.map +0 -1
  133. package/dist/models/trigger/fixedTime.js +0 -69
  134. package/dist/models/trigger/interface.d.ts +0 -19
  135. package/dist/models/trigger/interface.d.ts.map +0 -1
  136. package/dist/models/trigger/interface.js +0 -35
  137. package/dist/models/trigger/manual.d.ts +0 -16
  138. package/dist/models/trigger/manual.d.ts.map +0 -1
  139. package/dist/models/trigger/manual.js +0 -117
  140. package/dist/models/workflow.d.ts +0 -53
  141. package/dist/models/workflow.d.ts.map +0 -1
  142. package/dist/models/workflow.js +0 -219
  143. package/dist/utils.d.ts +0 -82
  144. package/dist/utils.d.ts.map +0 -1
  145. package/dist/utils.js +0 -286
@@ -0,0 +1,79 @@
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. Required — callers
15
+ * MUST pass the user's currently-connected wallet chain (e.g.
16
+ * `await wallet.getChainId()`). The aggregator echoes this into
17
+ * the JWT `aud` claim, which becomes the default chain for
18
+ * subsequent wallet RPCs. Hardcoding a value here would silently
19
+ * route every request to the wrong chain.
20
+ *
21
+ * Source this from the wallet itself (`provider.getNetwork()`,
22
+ * `wallet.getChainId()`, EIP-1193 `eth_chainId`), NOT from
23
+ * user-typed input or URL params — those can lie, and a JWT
24
+ * minted against a forged chain id will route the user's wallet
25
+ * RPCs to the wrong chain bucket.
26
+ */
27
+ chainId: number;
28
+ /**
29
+ * Gateway binary version to stamp into the message. Required —
30
+ * fetch it once per session via `client.health.check()` and pass
31
+ * the `version` field through. Pinning a literal here (the old
32
+ * `"v4-sdk"` default) lies about which gateway the message was
33
+ * signed against and breaks support triage.
34
+ */
35
+ version: string;
36
+ /** Issuance timestamp; defaults to `new Date()`. */
37
+ issuedAt?: Date;
38
+ /** Token expiry; defaults to 24h from issuedAt. */
39
+ expireAt?: Date;
40
+ }
41
+ export interface BuiltAuthMessage {
42
+ readonly message: string;
43
+ readonly chainId: number;
44
+ readonly ownerAddress: string;
45
+ readonly expireAt: Date;
46
+ }
47
+ /**
48
+ * Build the canonical auth message a wallet must sign. Pure — does
49
+ * no signing — so it can run in the browser before opening the wallet
50
+ * popup.
51
+ *
52
+ * @example
53
+ * const { version } = await client.health.check();
54
+ * const chainId = await wallet.getChainId();
55
+ * const { message } = buildAuthMessage({ ownerAddress, chainId, version });
56
+ * const signature = await wallet.signMessage(message);
57
+ * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
58
+ */
59
+ export declare function buildAuthMessage(input: BuildAuthMessageInput): BuiltAuthMessage;
60
+ /**
61
+ * One-shot helper: build the message, sign it with the supplied
62
+ * private key, and return the payload ready for
63
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
64
+ * where the private key is in hand; browser flows use
65
+ * `buildAuthMessage` + a wallet's `personal_sign`.
66
+ *
67
+ * `chainId` and `version` are required for the same reasons as
68
+ * `buildAuthMessage` — silent defaults would lie about the chain
69
+ * the JWT is bound to and the gateway it was signed against.
70
+ */
71
+ export declare function signAuthMessage(privateKey: string, input: Omit<BuildAuthMessageInput, "ownerAddress"> & {
72
+ ownerAddress?: string;
73
+ }): Promise<{
74
+ message: string;
75
+ signature: string;
76
+ ownerAddress: string;
77
+ expireAt: Date;
78
+ }>;
79
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/v4/auth.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,wMAOT,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;OAaG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,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;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAuB/E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7E,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC,CA2BvF"}
@@ -0,0 +1,92 @@
1
+ import { Wallet, getAddress } from "ethers";
2
+ /**
3
+ * Canonical EIP-191 message template the aggregator's auth handler
4
+ * verifies. Must match the format documented in the API spec.
5
+ *
6
+ * Filled by `buildAuthMessage` below; the SDK exports both halves
7
+ * (build + sign) so non-SDK callers (web wallets, smart-account
8
+ * signers) can produce a message that exchanges cleanly.
9
+ */
10
+ export const AUTH_TEMPLATE = `Please sign the below text for ownership verification.
11
+
12
+ URI: https://app.avaprotocol.org
13
+ Chain ID: {chainId}
14
+ Version: {version}
15
+ Issued At: {issuedAt}
16
+ Expire At: {expireAt}
17
+ Wallet: {wallet}`;
18
+ /**
19
+ * Build the canonical auth message a wallet must sign. Pure — does
20
+ * no signing — so it can run in the browser before opening the wallet
21
+ * popup.
22
+ *
23
+ * @example
24
+ * const { version } = await client.health.check();
25
+ * const chainId = await wallet.getChainId();
26
+ * const { message } = buildAuthMessage({ ownerAddress, chainId, version });
27
+ * const signature = await wallet.signMessage(message);
28
+ * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
29
+ */
30
+ export function buildAuthMessage(input) {
31
+ if (!Number.isInteger(input.chainId) || input.chainId <= 0) {
32
+ throw new Error("buildAuthMessage: chainId must be a positive integer (the wallet's currently-connected chain).");
33
+ }
34
+ if (typeof input.version !== "string" || input.version.length === 0) {
35
+ throw new Error("buildAuthMessage: version must be a non-empty string (fetch it from `client.health.check()`).");
36
+ }
37
+ const issuedAt = input.issuedAt ?? new Date();
38
+ const expireAt = input.expireAt ?? new Date(issuedAt.getTime() + 24 * 60 * 60 * 1000);
39
+ // Canonicalize the address so the wire form matches what the
40
+ // aggregator extracts via crypto.PubkeyToAddress.
41
+ const ownerAddress = getAddress(input.ownerAddress);
42
+ const message = AUTH_TEMPLATE
43
+ .replace("{chainId}", String(input.chainId))
44
+ .replace("{version}", input.version)
45
+ .replace("{issuedAt}", toRFC3339Millis(issuedAt))
46
+ .replace("{expireAt}", toRFC3339Millis(expireAt))
47
+ .replace("{wallet}", ownerAddress);
48
+ return { message, chainId: input.chainId, ownerAddress, expireAt };
49
+ }
50
+ /**
51
+ * One-shot helper: build the message, sign it with the supplied
52
+ * private key, and return the payload ready for
53
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
54
+ * where the private key is in hand; browser flows use
55
+ * `buildAuthMessage` + a wallet's `personal_sign`.
56
+ *
57
+ * `chainId` and `version` are required for the same reasons as
58
+ * `buildAuthMessage` — silent defaults would lie about the chain
59
+ * the JWT is bound to and the gateway it was signed against.
60
+ */
61
+ export async function signAuthMessage(privateKey, input) {
62
+ // Defensive runtime guard for JS callers / TS callers casting through
63
+ // `any` who'd otherwise hit a cryptic "Cannot read properties of
64
+ // undefined" inside buildAuthMessage. The type-level requirement
65
+ // stands; this just makes the breaking-change error legible.
66
+ if (input == null || typeof input !== "object") {
67
+ throw new Error("signAuthMessage: input is required — pass { chainId, version } (chainId from the wallet's connected chain, version from client.health.check()).");
68
+ }
69
+ const signer = new Wallet(privateKey);
70
+ const built = buildAuthMessage({
71
+ ownerAddress: input.ownerAddress ?? signer.address,
72
+ chainId: input.chainId,
73
+ version: input.version,
74
+ issuedAt: input.issuedAt,
75
+ expireAt: input.expireAt,
76
+ });
77
+ // signMessage performs EIP-191 personal_sign — the same prefix
78
+ // accounts.TextHash uses on the verifier side.
79
+ const signature = await signer.signMessage(built.message);
80
+ return {
81
+ message: built.message,
82
+ signature,
83
+ ownerAddress: built.ownerAddress,
84
+ expireAt: built.expireAt,
85
+ };
86
+ }
87
+ // toRFC3339Millis renders a Date as `2026-05-25T12:00:00.000Z`. Matches
88
+ // the format the aggregator's verifier parses with the layout
89
+ // `2006-01-02T15:04:05.000Z`.
90
+ function toRFC3339Millis(d) {
91
+ return d.toISOString().replace(/(\.\d{3})\d*Z$/, "$1Z");
92
+ }
@@ -0,0 +1,106 @@
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?: ReadonlyArray<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?: ReadonlyArray<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
+ options?: {
65
+ summarize?: boolean;
66
+ };
67
+ }): v4.Node;
68
+ branch(opts: {
69
+ id: string;
70
+ name: string;
71
+ conditions: Array<{
72
+ id: string;
73
+ expression: string;
74
+ type?: "if" | "elseIf" | "else";
75
+ }>;
76
+ }): v4.Node;
77
+ filter(opts: {
78
+ id: string;
79
+ name: string;
80
+ expression: string;
81
+ inputVariable: string;
82
+ }): v4.Node;
83
+ loop(opts: {
84
+ id: string;
85
+ name: string;
86
+ inputVariable: string;
87
+ iterVar?: string;
88
+ runner: v4.Node;
89
+ }): v4.Node;
90
+ customCode(opts: {
91
+ id: string;
92
+ name: string;
93
+ source: string;
94
+ lang?: v4.Lang;
95
+ }): v4.Node;
96
+ balance(opts: {
97
+ id: string;
98
+ name: string;
99
+ address: string;
100
+ chain: string;
101
+ includeSpam?: boolean;
102
+ includeZeroBalances?: boolean;
103
+ minUsdValueCents?: number;
104
+ }): v4.Node;
105
+ }>;
106
+ //# 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,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrD,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;YACxB,QAA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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
+ ...(opts.options ? { options: opts.options } : {}),
77
+ },
78
+ };
79
+ },
80
+ branch(opts) {
81
+ return {
82
+ id: opts.id,
83
+ name: opts.name,
84
+ type: "branch",
85
+ config: { conditions: opts.conditions },
86
+ };
87
+ },
88
+ filter(opts) {
89
+ return {
90
+ id: opts.id,
91
+ name: opts.name,
92
+ type: "filter",
93
+ config: { expression: opts.expression, inputVariable: opts.inputVariable },
94
+ };
95
+ },
96
+ loop(opts) {
97
+ return {
98
+ id: opts.id,
99
+ name: opts.name,
100
+ type: "loop",
101
+ config: {
102
+ inputVariable: opts.inputVariable,
103
+ ...(opts.iterVar ? { iterVar: opts.iterVar } : {}),
104
+ runner: opts.runner,
105
+ },
106
+ };
107
+ },
108
+ customCode(opts) {
109
+ return {
110
+ id: opts.id,
111
+ name: opts.name,
112
+ type: "customCode",
113
+ config: {
114
+ source: opts.source,
115
+ lang: opts.lang ?? "javascript",
116
+ },
117
+ };
118
+ },
119
+ balance(opts) {
120
+ return {
121
+ id: opts.id,
122
+ name: opts.name,
123
+ type: "balance",
124
+ config: {
125
+ address: opts.address,
126
+ chain: opts.chain,
127
+ ...(opts.includeSpam !== undefined ? { includeSpam: opts.includeSpam } : {}),
128
+ ...(opts.includeZeroBalances !== undefined ? { includeZeroBalances: opts.includeZeroBalances } : {}),
129
+ ...(opts.minUsdValueCents !== undefined ? { minUsdValueCents: opts.minUsdValueCents } : {}),
130
+ },
131
+ };
132
+ },
133
+ });
@@ -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 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YACrB,wEAAwE;YACxE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;YAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAC3B,UAAU,CAAC,EAAE,KAAK,CAAC;gBACjB,SAAS,EAAE,MAAM,CAAC;gBAClB,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,UAAU,CAAC;gBACjE,SAAS,CAAC,EAAE,MAAM,CAAC;gBACnB,KAAK,EAAE,MAAM,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,19 @@
1
+ export declare const Chains: Readonly<{
2
+ /**
3
+ * The chain the auth handler signs the canonical EIP-191 message
4
+ * against. Defaults to Sepolia — keep this synced with the
5
+ * aggregator's `smart_wallet.chain_id` setting (currently Sepolia
6
+ * in dev/staging, Ethereum mainnet in production). This is the only
7
+ * chain constant the SDK adds on top of the catalog, because the
8
+ * catalog is consumer-agnostic and doesn't know about our auth flow.
9
+ */
10
+ EigenLayerAuth: 11155111;
11
+ EthereumMainnet: 1;
12
+ Sepolia: 11155111;
13
+ Holesky: 17000;
14
+ BaseMainnet: 8453;
15
+ BaseSepolia: 84532;
16
+ BnbMainnet: 56;
17
+ }>;
18
+ export type ChainId = (typeof Chains)[keyof typeof Chains] | number;
19
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/v4/chains.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,MAAM;IAEjB;;;;;;;OAOG;;;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC"}
@@ -0,0 +1,22 @@
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
+ // The full chain set comes from `@avaprotocol/protocols` (the data-only
7
+ // DeFi catalog), with one SDK-specific addition (`EigenLayerAuth`) for
8
+ // the auth-handler audience. New chains added to the catalog flow
9
+ // through automatically — bumping the catalog dep is enough.
10
+ import { Chains as CatalogChains } from "@avaprotocol/protocols";
11
+ export const Chains = Object.freeze({
12
+ ...CatalogChains,
13
+ /**
14
+ * The chain the auth handler signs the canonical EIP-191 message
15
+ * against. Defaults to Sepolia — keep this synced with the
16
+ * aggregator's `smart_wallet.chain_id` setting (currently Sepolia
17
+ * in dev/staging, Ethereum mainnet in production). This is the only
18
+ * chain constant the SDK adds on top of the catalog, because the
19
+ * catalog is consumer-agnostic and doesn't know about our auth flow.
20
+ */
21
+ EigenLayerAuth: 11155111,
22
+ });
@@ -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