@avaprotocol/sdk-js 2.17.0 → 3.1.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 +26 -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 +873 -22359
  6. package/dist/index.mjs +831 -22386
  7. package/dist/v4/auth.d.ts +92 -0
  8. package/dist/v4/auth.d.ts.map +1 -0
  9. package/dist/v4/auth.js +108 -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 +48 -0
  35. package/dist/v4/resources/auth.d.ts.map +1 -0
  36. package/dist/v4/resources/auth.js +61 -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,92 @@
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: {uri}\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
+ * Origin URL the user is authenticating against. Required — callers
15
+ * MUST pass the actual studio/app origin the user is on right now
16
+ * (e.g. `https://app.avaprotocol.org` in production, `http://localhost:3000`
17
+ * in local dev). Shows up in the wallet popup as the "site" the user
18
+ * is granting access to, so a dishonest value reads as a phishing
19
+ * attempt or a config bug. The aggregator currently does not validate
20
+ * this field, but it's a candidate for cross-origin replay protection
21
+ * if it's ever turned on server-side.
22
+ */
23
+ uri: string;
24
+ /**
25
+ * Chain ID to embed in the canonical message. Required — callers
26
+ * MUST pass the user's currently-connected wallet chain (e.g.
27
+ * `await wallet.getChainId()`). The aggregator echoes this into
28
+ * the JWT `aud` claim, which becomes the default chain for
29
+ * subsequent wallet RPCs. Hardcoding a value here would silently
30
+ * route every request to the wrong chain.
31
+ *
32
+ * Source this from the wallet itself (`provider.getNetwork()`,
33
+ * `wallet.getChainId()`, EIP-1193 `eth_chainId`), NOT from
34
+ * user-typed input or URL params — those can lie, and a JWT
35
+ * minted against a forged chain id will route the user's wallet
36
+ * RPCs to the wrong chain bucket.
37
+ */
38
+ chainId: number;
39
+ /**
40
+ * Gateway binary version to stamp into the message. Required —
41
+ * fetch it once per session via `client.health.check()` and pass
42
+ * the `version` field through. Pinning a literal here (the old
43
+ * `"v4-sdk"` default) lies about which gateway the message was
44
+ * signed against and breaks support triage.
45
+ */
46
+ version: string;
47
+ /** Issuance timestamp; defaults to `new Date()`. */
48
+ issuedAt?: Date;
49
+ /** Token expiry; defaults to 24h from issuedAt. */
50
+ expireAt?: Date;
51
+ }
52
+ export interface BuiltAuthMessage {
53
+ readonly message: string;
54
+ readonly chainId: number;
55
+ readonly ownerAddress: string;
56
+ readonly expireAt: Date;
57
+ }
58
+ /**
59
+ * Build the canonical auth message a wallet must sign. Pure — does
60
+ * no signing — so it can run in the browser before opening the wallet
61
+ * popup.
62
+ *
63
+ * @example
64
+ * const { version } = await client.health.check();
65
+ * const chainId = await wallet.getChainId();
66
+ * const uri = window.location.origin; // or the studio's getSiteUrlOrDefault()
67
+ * const { message } = buildAuthMessage({ ownerAddress, uri, chainId, version });
68
+ * const signature = await wallet.signMessage(message);
69
+ * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
70
+ */
71
+ export declare function buildAuthMessage(input: BuildAuthMessageInput): BuiltAuthMessage;
72
+ /**
73
+ * One-shot helper: build the message, sign it with the supplied
74
+ * private key, and return the payload ready for
75
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
76
+ * where the private key is in hand; browser flows use
77
+ * `buildAuthMessage` + a wallet's `personal_sign`.
78
+ *
79
+ * `uri`, `chainId`, and `version` are required for the same reasons as
80
+ * `buildAuthMessage` — silent defaults would lie about the origin the
81
+ * user is signing for, the chain the JWT is bound to, or the gateway
82
+ * it was signed against.
83
+ */
84
+ export declare function signAuthMessage(privateKey: string, input: Omit<BuildAuthMessageInput, "ownerAddress"> & {
85
+ ownerAddress?: string;
86
+ }): Promise<{
87
+ message: string;
88
+ signature: string;
89
+ ownerAddress: string;
90
+ expireAt: Date;
91
+ }>;
92
+ //# 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,kLAOT,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;;;;;;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;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CA0C/E;AAED;;;;;;;;;;;GAWG;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,CA4BvF"}
@@ -0,0 +1,108 @@
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: {uri}
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 uri = window.location.origin; // or the studio's getSiteUrlOrDefault()
27
+ * const { message } = buildAuthMessage({ ownerAddress, uri, chainId, version });
28
+ * const signature = await wallet.signMessage(message);
29
+ * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
30
+ */
31
+ export function buildAuthMessage(input) {
32
+ const trimmedUri = typeof input.uri === "string" ? input.uri.trim() : "";
33
+ if (!trimmedUri) {
34
+ throw new Error("buildAuthMessage: uri must be a non-empty string (the origin the user is signing into, e.g. window.location.origin).");
35
+ }
36
+ try {
37
+ new URL(trimmedUri);
38
+ }
39
+ catch {
40
+ throw new Error("buildAuthMessage: uri must be a valid URL (e.g. window.location.origin).");
41
+ }
42
+ if (!Number.isInteger(input.chainId) || input.chainId <= 0) {
43
+ throw new Error("buildAuthMessage: chainId must be a positive integer (the wallet's currently-connected chain).");
44
+ }
45
+ if (typeof input.version !== "string" || input.version.length === 0) {
46
+ throw new Error("buildAuthMessage: version must be a non-empty string (fetch it from `client.health.check()`).");
47
+ }
48
+ const issuedAt = input.issuedAt ?? new Date();
49
+ const expireAt = input.expireAt ?? new Date(issuedAt.getTime() + 24 * 60 * 60 * 1000);
50
+ // Canonicalize the address so the wire form matches what the
51
+ // aggregator extracts via crypto.PubkeyToAddress.
52
+ const ownerAddress = getAddress(input.ownerAddress);
53
+ const replacements = {
54
+ "{uri}": trimmedUri,
55
+ "{chainId}": String(input.chainId),
56
+ "{version}": input.version,
57
+ "{issuedAt}": toRFC3339Millis(issuedAt),
58
+ "{expireAt}": toRFC3339Millis(expireAt),
59
+ "{wallet}": ownerAddress,
60
+ };
61
+ const message = AUTH_TEMPLATE.replace(/\{uri\}|\{chainId\}|\{version\}|\{issuedAt\}|\{expireAt\}|\{wallet\}/g, (m) => replacements[m]);
62
+ return { message, chainId: input.chainId, ownerAddress, expireAt };
63
+ }
64
+ /**
65
+ * One-shot helper: build the message, sign it with the supplied
66
+ * private key, and return the payload ready for
67
+ * `client.auth.exchange()`. Only useful in tests / Node tooling
68
+ * where the private key is in hand; browser flows use
69
+ * `buildAuthMessage` + a wallet's `personal_sign`.
70
+ *
71
+ * `uri`, `chainId`, and `version` are required for the same reasons as
72
+ * `buildAuthMessage` — silent defaults would lie about the origin the
73
+ * user is signing for, the chain the JWT is bound to, or the gateway
74
+ * it was signed against.
75
+ */
76
+ export async function signAuthMessage(privateKey, input) {
77
+ // Defensive runtime guard for JS callers / TS callers casting through
78
+ // `any` who'd otherwise hit a cryptic "Cannot read properties of
79
+ // undefined" inside buildAuthMessage. The type-level requirement
80
+ // stands; this just makes the breaking-change error legible.
81
+ if (input == null || typeof input !== "object") {
82
+ throw new Error("signAuthMessage: input is required — pass { uri, chainId, version } (uri from the calling origin, chainId from the wallet's connected chain, version from client.health.check()).");
83
+ }
84
+ const signer = new Wallet(privateKey);
85
+ const built = buildAuthMessage({
86
+ ownerAddress: input.ownerAddress ?? signer.address,
87
+ uri: input.uri,
88
+ chainId: input.chainId,
89
+ version: input.version,
90
+ issuedAt: input.issuedAt,
91
+ expireAt: input.expireAt,
92
+ });
93
+ // signMessage performs EIP-191 personal_sign — the same prefix
94
+ // accounts.TextHash uses on the verifier side.
95
+ const signature = await signer.signMessage(built.message);
96
+ return {
97
+ message: built.message,
98
+ signature,
99
+ ownerAddress: built.ownerAddress,
100
+ expireAt: built.expireAt,
101
+ };
102
+ }
103
+ // toRFC3339Millis renders a Date as `2026-05-25T12:00:00.000Z`. Matches
104
+ // the format the aggregator's verifier parses with the layout
105
+ // `2006-01-02T15:04:05.000Z`.
106
+ function toRFC3339Millis(d) {
107
+ return d.toISOString().replace(/(\.\d{3})\d*Z$/, "$1Z");
108
+ }
@@ -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,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,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,EAAE,CAAC,IAAI;uBAkBQ;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,C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AE,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,133 @@
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
+ ...(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 +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,CAAA;KAAE,GAAG,EAAE,CAAC,OAAO;eAc/E;QACT,IAAI,EAAE,MAAM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C,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
+ });