@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,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,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,MAAM;IACjB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,IAAI,EAAE,aAAa;IAqB/B,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIzC,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;CACF"}
@@ -0,0 +1,53 @@
1
+ import { Transport } from "./internal/transport";
2
+ import { AuthResource } from "./resources/auth";
3
+ import { ExecutionsResource } from "./resources/executions";
4
+ import { HealthResource } from "./resources/health";
5
+ import { NodesResource } from "./resources/nodes";
6
+ import { OperatorsResource } from "./resources/operators";
7
+ import { SecretsResource } from "./resources/secrets";
8
+ import { TokensResource } from "./resources/tokens";
9
+ import { TriggersResource } from "./resources/triggers";
10
+ import { WalletsResource } from "./resources/wallets";
11
+ import { WorkflowsResource } from "./resources/workflows";
12
+ /**
13
+ * v4 SDK entry point. Resource-grouped sub-clients (Stripe / OpenAI
14
+ * convention). Construct one Client per aggregator endpoint; all
15
+ * requests share the same transport (and therefore the same Bearer
16
+ * token + timeout + fetch impl).
17
+ *
18
+ * @example
19
+ * import { Client } from "@avaprotocol/sdk-js";
20
+ * const client = new Client({ baseUrl: process.env.AVS_REST_URL! });
21
+ * await client.auth.exchangeWithKey(process.env.TEST_PRIVATE_KEY!);
22
+ * const wf = await client.workflows.create({ ... });
23
+ * await client.workflows.cancel(wf.id);
24
+ */
25
+ export class Client {
26
+ constructor(opts) {
27
+ const transportOpts = {
28
+ baseUrl: opts.baseUrl,
29
+ token: opts.token,
30
+ defaultTimeoutMs: opts.defaultTimeoutMs,
31
+ fetchImpl: opts.fetchImpl,
32
+ };
33
+ this.transport = new Transport(transportOpts);
34
+ this.auth = new AuthResource(this.transport);
35
+ this.executions = new ExecutionsResource(this.transport);
36
+ this.health = new HealthResource(this.transport);
37
+ this.nodes = new NodesResource(this.transport);
38
+ this.operators = new OperatorsResource(this.transport);
39
+ this.secrets = new SecretsResource(this.transport);
40
+ this.tokens = new TokensResource(this.transport);
41
+ this.triggers = new TriggersResource(this.transport);
42
+ this.wallets = new WalletsResource(this.transport);
43
+ this.workflows = new WorkflowsResource(this.transport);
44
+ }
45
+ /** Replace the current Bearer token. */
46
+ setToken(token) {
47
+ this.transport.setToken(token);
48
+ }
49
+ /** Current Bearer token. Returns undefined when anonymous. */
50
+ get token() {
51
+ return this.transport.getToken();
52
+ }
53
+ }
@@ -0,0 +1,19 @@
1
+ export { Client, type ClientOptions } from "./client";
2
+ export { Chains, type ChainId } from "./chains";
3
+ export { Triggers } from "./builders/triggers";
4
+ export { Nodes } from "./builders/nodes";
5
+ export { Protocols, type AbiFragment, type AddressByChain } from "./protocols";
6
+ export { buildAuthMessage, signAuthMessage, AUTH_TEMPLATE, type BuildAuthMessageInput, type BuiltAuthMessage, } from "./auth";
7
+ export { APIError, NetworkError, AuthRequiredError } from "./internal/errors";
8
+ export { AuthResource } from "./resources/auth";
9
+ export { ExecutionsResource } from "./resources/executions";
10
+ export { HealthResource } from "./resources/health";
11
+ export { NodesResource } from "./resources/nodes";
12
+ export { OperatorsResource } from "./resources/operators";
13
+ export { SecretsResource } from "./resources/secrets";
14
+ export { TokensResource } from "./resources/tokens";
15
+ export { TriggersResource } from "./resources/triggers";
16
+ export { WalletsResource } from "./resources/wallets";
17
+ export { WorkflowsResource } from "./resources/workflows";
18
+ export type { v4 } from "@avaprotocol/types";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK9E,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,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,YAAY,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,24 @@
1
+ // Public v4 entrypoint. Consumers should `import { Client } from
2
+ // "@avaprotocol/sdk-js"` once the v3 surface is retired and this
3
+ // becomes the root export. For now the v3 index re-exports the v4
4
+ // names alongside the v3 ones so partners can migrate incrementally.
5
+ export { Client } from "./client";
6
+ export { Chains } from "./chains";
7
+ export { Triggers } from "./builders/triggers";
8
+ export { Nodes } from "./builders/nodes";
9
+ export { Protocols } from "./protocols";
10
+ export { buildAuthMessage, signAuthMessage, AUTH_TEMPLATE, } from "./auth";
11
+ export { APIError, NetworkError, AuthRequiredError } from "./internal/errors";
12
+ // Resource classes are exported in case advanced consumers want to
13
+ // hand-construct one without going through Client. Most callers
14
+ // won't need these.
15
+ export { AuthResource } from "./resources/auth";
16
+ export { ExecutionsResource } from "./resources/executions";
17
+ export { HealthResource } from "./resources/health";
18
+ export { NodesResource } from "./resources/nodes";
19
+ export { OperatorsResource } from "./resources/operators";
20
+ export { SecretsResource } from "./resources/secrets";
21
+ export { TokensResource } from "./resources/tokens";
22
+ export { TriggersResource } from "./resources/triggers";
23
+ export { WalletsResource } from "./resources/wallets";
24
+ export { WorkflowsResource } from "./resources/workflows";
@@ -0,0 +1,36 @@
1
+ import type { v4 } from "@avaprotocol/types";
2
+ /**
3
+ * Thrown when the server returns a 4xx/5xx response. The aggregator
4
+ * speaks RFC 7807 problem+json (`application/problem+json`); this
5
+ * class surfaces every field plus the underlying HTTP status so SDK
6
+ * callers can pattern-match without re-parsing the body.
7
+ */
8
+ export declare class APIError extends Error {
9
+ /** HTTP status code (echoed from the response). */
10
+ readonly status: number;
11
+ /** Machine-readable error code (Problem.code), e.g. `AUTH_INVALID_TOKEN`. */
12
+ readonly code?: string;
13
+ /** Short human-readable summary (Problem.title). */
14
+ readonly title?: string;
15
+ /** Per-request identifier — also surfaced via X-Request-ID header. */
16
+ readonly requestId?: string;
17
+ /** The full parsed Problem body, when the server returned one. */
18
+ readonly problem?: v4.Problem;
19
+ constructor(status: number, init: {
20
+ code?: string;
21
+ title?: string;
22
+ detail?: string;
23
+ requestId?: string;
24
+ problem?: v4.Problem;
25
+ });
26
+ }
27
+ /** Thrown when the SDK can't reach the server (DNS failure, fetch threw). */
28
+ export declare class NetworkError extends Error {
29
+ readonly cause?: unknown;
30
+ constructor(message: string, cause?: unknown);
31
+ }
32
+ /** Thrown when the auth credential is missing or expired before a call. */
33
+ export declare class AuthRequiredError extends Error {
34
+ constructor(message?: string);
35
+ }
36
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/v4/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC;gBAG5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAA;KAAE;CAUrG;AAED,6EAA6E;AAC7E,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBACb,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK7C;AAED,2EAA2E;AAC3E,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,SAAgE;CAIpF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Thrown when the server returns a 4xx/5xx response. The aggregator
3
+ * speaks RFC 7807 problem+json (`application/problem+json`); this
4
+ * class surfaces every field plus the underlying HTTP status so SDK
5
+ * callers can pattern-match without re-parsing the body.
6
+ */
7
+ export class APIError extends Error {
8
+ constructor(status, init) {
9
+ super(init.detail || init.title || `HTTP ${status}`);
10
+ this.name = "APIError";
11
+ this.status = status;
12
+ this.code = init.code;
13
+ this.title = init.title;
14
+ this.requestId = init.requestId;
15
+ this.problem = init.problem;
16
+ }
17
+ }
18
+ /** Thrown when the SDK can't reach the server (DNS failure, fetch threw). */
19
+ export class NetworkError extends Error {
20
+ constructor(message, cause) {
21
+ super(message);
22
+ this.name = "NetworkError";
23
+ this.cause = cause;
24
+ }
25
+ }
26
+ /** Thrown when the auth credential is missing or expired before a call. */
27
+ export class AuthRequiredError extends Error {
28
+ constructor(message = "Authentication required — call client.auth.exchange() first") {
29
+ super(message);
30
+ this.name = "AuthRequiredError";
31
+ }
32
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Minimal fetch wrapper used by every v4 sub-client. Owns the
3
+ * baseURL, the Bearer JWT, default timeouts, and the
4
+ * problem+json → APIError translation.
5
+ *
6
+ * Built on top of `globalThis.fetch` so it works in Node 20+ and in
7
+ * the browser without bundling node-fetch. Streaming endpoints
8
+ * (executions:stream) bypass `request()` and use `stream()` instead so
9
+ * the response body can be read incrementally.
10
+ */
11
+ export interface TransportOptions {
12
+ /** Base URL including the `/api/v1` prefix, no trailing slash. */
13
+ readonly baseUrl: string;
14
+ /** Bearer JWT minted via POST /auth:exchange. */
15
+ token?: string;
16
+ /** Default request timeout in milliseconds (per request). */
17
+ defaultTimeoutMs?: number;
18
+ /** Optional fetch implementation override (tests / non-Node runtimes). */
19
+ fetchImpl?: typeof fetch;
20
+ }
21
+ export interface RequestOptions {
22
+ /** Path appended to baseUrl, e.g. `/workflows/01ABC`. */
23
+ path: string;
24
+ /** HTTP method — defaults to GET. */
25
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
26
+ /**
27
+ * Query parameters; arrays repeat the key
28
+ * (`?status=enabled&status=disabled`). Typed as `object` so
29
+ * resource handlers can pass through their own param interfaces
30
+ * without adding index signatures.
31
+ */
32
+ query?: object;
33
+ /** Body payload — JSON-serialized before send. */
34
+ body?: unknown;
35
+ /** Per-request timeout override. */
36
+ timeoutMs?: number;
37
+ /** Extra headers merged on top of the transport defaults. */
38
+ headers?: Record<string, string>;
39
+ /** Pre-resolved AbortSignal for cancellation. */
40
+ signal?: AbortSignal;
41
+ }
42
+ export declare class Transport {
43
+ private readonly baseUrl;
44
+ private readonly defaultTimeoutMs;
45
+ private readonly fetchImpl;
46
+ private bearerToken?;
47
+ constructor(opts: TransportOptions);
48
+ /** Replace the Bearer token. Used after `client.auth.exchange()`. */
49
+ setToken(token: string | undefined): void;
50
+ /** Read the current Bearer token (for tests / debugging). */
51
+ getToken(): string | undefined;
52
+ /** Issue a JSON request and decode the response body. */
53
+ request<T>(opts: RequestOptions): Promise<T>;
54
+ /**
55
+ * Issue a request and return the raw Response so the caller can
56
+ * read it incrementally. Used by the executions:stream SSE handler.
57
+ * Throws APIError on non-2xx exactly like `request()` does.
58
+ */
59
+ stream(opts: RequestOptions): Promise<Response>;
60
+ private send;
61
+ private toAPIError;
62
+ private buildUrl;
63
+ }
64
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/v4/internal/transport.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iDAAiD;IACjD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAEjB,IAAI,EAAE,gBAAgB;IAOlC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIzC,6DAA6D;IAC7D,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,yDAAyD;IACnD,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBlD;;;;OAIG;IACG,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;YAIvC,IAAI;YAgDJ,UAAU;IAyBxB,OAAO,CAAC,QAAQ;CAiBjB"}
@@ -0,0 +1,133 @@
1
+ import { APIError, NetworkError } from "./errors";
2
+ export class Transport {
3
+ constructor(opts) {
4
+ this.baseUrl = opts.baseUrl.replace(/\/$/, "");
5
+ this.defaultTimeoutMs = opts.defaultTimeoutMs ?? 30000;
6
+ this.fetchImpl = opts.fetchImpl ?? globalThis.fetch.bind(globalThis);
7
+ this.bearerToken = opts.token;
8
+ }
9
+ /** Replace the Bearer token. Used after `client.auth.exchange()`. */
10
+ setToken(token) {
11
+ this.bearerToken = token;
12
+ }
13
+ /** Read the current Bearer token (for tests / debugging). */
14
+ getToken() {
15
+ return this.bearerToken;
16
+ }
17
+ /** Issue a JSON request and decode the response body. */
18
+ async request(opts) {
19
+ const response = await this.send(opts);
20
+ if (response.status === 204) {
21
+ // 204 No Content — used by DELETE / PUT acks. Callers should
22
+ // type T as `void`.
23
+ return undefined;
24
+ }
25
+ const text = await response.text();
26
+ if (!text)
27
+ return undefined;
28
+ try {
29
+ return JSON.parse(text);
30
+ }
31
+ catch (err) {
32
+ throw new NetworkError(`Failed to parse JSON response from ${opts.path}: ${err.message}`, err);
33
+ }
34
+ }
35
+ /**
36
+ * Issue a request and return the raw Response so the caller can
37
+ * read it incrementally. Used by the executions:stream SSE handler.
38
+ * Throws APIError on non-2xx exactly like `request()` does.
39
+ */
40
+ async stream(opts) {
41
+ return this.send(opts);
42
+ }
43
+ async send(opts) {
44
+ const url = this.buildUrl(opts.path, opts.query);
45
+ const controller = new AbortController();
46
+ const timeoutMs = opts.timeoutMs ?? this.defaultTimeoutMs;
47
+ // timeoutMs <= 0 means "no timeout" (used by SSE streams). With
48
+ // a positive value we schedule an abort; otherwise the only
49
+ // cancellation channel is the caller-supplied signal.
50
+ const timeoutId = timeoutMs > 0
51
+ ? setTimeout(() => controller.abort(), timeoutMs)
52
+ : undefined;
53
+ if (opts.signal) {
54
+ opts.signal.addEventListener("abort", () => controller.abort(), { once: true });
55
+ }
56
+ const headers = {
57
+ Accept: "application/json",
58
+ ...opts.headers,
59
+ };
60
+ if (this.bearerToken) {
61
+ headers.Authorization = `Bearer ${this.bearerToken}`;
62
+ }
63
+ let body;
64
+ if (opts.body !== undefined && opts.body !== null) {
65
+ headers["Content-Type"] ?? (headers["Content-Type"] = "application/json");
66
+ body = JSON.stringify(opts.body);
67
+ }
68
+ let response;
69
+ try {
70
+ response = await this.fetchImpl(url, {
71
+ method: opts.method ?? "GET",
72
+ headers,
73
+ body,
74
+ signal: controller.signal,
75
+ });
76
+ }
77
+ catch (err) {
78
+ throw new NetworkError(`fetch ${opts.path}: ${err.message}`, err);
79
+ }
80
+ finally {
81
+ clearTimeout(timeoutId);
82
+ }
83
+ if (!response.ok) {
84
+ throw await this.toAPIError(response);
85
+ }
86
+ return response;
87
+ }
88
+ async toAPIError(response) {
89
+ const requestId = response.headers.get("X-Request-ID") ?? undefined;
90
+ const contentType = response.headers.get("Content-Type") ?? "";
91
+ const isProblem = contentType.includes("problem+json") || contentType.includes("application/json");
92
+ let problem;
93
+ let code;
94
+ let title;
95
+ let detail;
96
+ if (isProblem) {
97
+ try {
98
+ const text = await response.text();
99
+ if (text) {
100
+ const parsed = JSON.parse(text);
101
+ problem = parsed;
102
+ code = parsed.code ?? undefined;
103
+ title = parsed.title;
104
+ detail = parsed.detail ?? undefined;
105
+ }
106
+ }
107
+ catch {
108
+ // fall through — APIError still carries status + requestId.
109
+ }
110
+ }
111
+ return new APIError(response.status, { code, title, detail, requestId, problem });
112
+ }
113
+ buildUrl(path, query) {
114
+ const url = new URL(this.baseUrl + (path.startsWith("/") ? path : "/" + path));
115
+ if (query) {
116
+ for (const [key, value] of Object.entries(query)) {
117
+ if (value === undefined || value === null || value === "")
118
+ continue;
119
+ if (Array.isArray(value)) {
120
+ for (const v of value) {
121
+ if (v === undefined || v === null || v === "")
122
+ continue;
123
+ url.searchParams.append(key, String(v));
124
+ }
125
+ }
126
+ else {
127
+ url.searchParams.append(key, String(value));
128
+ }
129
+ }
130
+ }
131
+ return url.toString();
132
+ }
133
+ }
@@ -0,0 +1,2 @@
1
+ export { Protocols, type AbiFragment, type AddressByChain } from "@avaprotocol/protocols";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v4/protocols/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Protocol catalog re-export.
2
+ //
3
+ // Address/ABI/topic data lives in the standalone
4
+ // `@avaprotocol/protocols` package — the SDK ships a thin re-export
5
+ // so consumers don't have to install a second package and the
6
+ // existing `import { Protocols } from "@avaprotocol/sdk-js"` surface
7
+ // keeps working.
8
+ //
9
+ // Update `@avaprotocol/protocols` (https://github.com/AvaProtocol/protocols)
10
+ // when a new protocol address lands or a new chain comes online;
11
+ // bumping `@avaprotocol/protocols` minor version + republishing this
12
+ // SDK package picks it up automatically.
13
+ export { Protocols } from "@avaprotocol/protocols";
@@ -0,0 +1,48 @@
1
+ import type { v4 } from "@avaprotocol/types";
2
+ import { Transport } from "../internal/transport";
3
+ /**
4
+ * `client.auth.*` — JWT exchange for the REST API.
5
+ *
6
+ * The aggregator's POST /auth:exchange takes (ownerAddress, signature,
7
+ * message) and returns a JWT bound to the EOA. The SDK keeps the JWT
8
+ * on the shared transport so subsequent requests carry it as a
9
+ * Bearer token automatically.
10
+ */
11
+ export declare class AuthResource {
12
+ private readonly transport;
13
+ constructor(transport: Transport);
14
+ /**
15
+ * POST /auth:exchange — verify an EIP-191 signature and stash the
16
+ * returned JWT on the transport. Returns the raw response so
17
+ * callers can persist the token externally (browser localStorage,
18
+ * keychain, etc.).
19
+ */
20
+ exchange(req: v4.AuthExchangeRequest): Promise<v4.AuthExchangeResponse>;
21
+ /**
22
+ * Convenience wrapper: sign the canonical message with a private
23
+ * key, exchange it, and return the JWT. The exchanged token is
24
+ * stashed on the transport. Designed for Node tooling — browser
25
+ * callers should use `buildAuthMessage` + a wallet's
26
+ * `personal_sign` and then call `exchange()` directly.
27
+ *
28
+ * `uri`, `chainId`, and `version` are required for the same reasons
29
+ * as `buildAuthMessage` — silent defaults would lie about the origin
30
+ * the user is signing for, mis-route wallet RPCs, or hide which
31
+ * gateway minted the JWT. `version` is the gateway binary version;
32
+ * the simplest source is the `version` field returned by
33
+ * `client.health.check()`. `uri` is the calling origin (the studio
34
+ * URL the user is on right now).
35
+ */
36
+ exchangeWithKey(privateKey: string, opts: {
37
+ ownerAddress?: string;
38
+ uri: string;
39
+ chainId: number;
40
+ version: string;
41
+ }): Promise<v4.AuthExchangeResponse>;
42
+ /**
43
+ * Forget the currently-stored JWT. Future requests fall back to
44
+ * anonymous and most endpoints will return 401.
45
+ */
46
+ clear(): void;
47
+ }
48
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/v4/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD;;;;;OAKG;IACG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,GAAG,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAY7E;;;;;;;;;;;;;;OAcG;IACG,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAC7E,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IASnC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,61 @@
1
+ import { signAuthMessage } from "../auth";
2
+ /**
3
+ * `client.auth.*` — JWT exchange for the REST API.
4
+ *
5
+ * The aggregator's POST /auth:exchange takes (ownerAddress, signature,
6
+ * message) and returns a JWT bound to the EOA. The SDK keeps the JWT
7
+ * on the shared transport so subsequent requests carry it as a
8
+ * Bearer token automatically.
9
+ */
10
+ export class AuthResource {
11
+ constructor(transport) {
12
+ this.transport = transport;
13
+ }
14
+ /**
15
+ * POST /auth:exchange — verify an EIP-191 signature and stash the
16
+ * returned JWT on the transport. Returns the raw response so
17
+ * callers can persist the token externally (browser localStorage,
18
+ * keychain, etc.).
19
+ */
20
+ async exchange(req) {
21
+ const resp = await this.transport.request({
22
+ path: "/auth:exchange",
23
+ method: "POST",
24
+ body: req,
25
+ });
26
+ if (resp.token) {
27
+ this.transport.setToken(resp.token);
28
+ }
29
+ return resp;
30
+ }
31
+ /**
32
+ * Convenience wrapper: sign the canonical message with a private
33
+ * key, exchange it, and return the JWT. The exchanged token is
34
+ * stashed on the transport. Designed for Node tooling — browser
35
+ * callers should use `buildAuthMessage` + a wallet's
36
+ * `personal_sign` and then call `exchange()` directly.
37
+ *
38
+ * `uri`, `chainId`, and `version` are required for the same reasons
39
+ * as `buildAuthMessage` — silent defaults would lie about the origin
40
+ * the user is signing for, mis-route wallet RPCs, or hide which
41
+ * gateway minted the JWT. `version` is the gateway binary version;
42
+ * the simplest source is the `version` field returned by
43
+ * `client.health.check()`. `uri` is the calling origin (the studio
44
+ * URL the user is on right now).
45
+ */
46
+ async exchangeWithKey(privateKey, opts) {
47
+ const signed = await signAuthMessage(privateKey, opts);
48
+ return this.exchange({
49
+ ownerAddress: signed.ownerAddress,
50
+ signature: signed.signature,
51
+ message: signed.message,
52
+ });
53
+ }
54
+ /**
55
+ * Forget the currently-stored JWT. Future requests fall back to
56
+ * anonymous and most endpoints will return 401.
57
+ */
58
+ clear() {
59
+ this.transport.setToken(undefined);
60
+ }
61
+ }
@@ -0,0 +1,74 @@
1
+ import type { v4 } from "@avaprotocol/types";
2
+ import { Transport } from "../internal/transport";
3
+ export interface ListExecutionsParams {
4
+ /** Required for the flat list endpoint; pass one or more workflowIds. */
5
+ workflowId?: string[];
6
+ chainId?: number;
7
+ before?: string;
8
+ after?: string;
9
+ limit?: number;
10
+ }
11
+ export interface CountExecutionsParams {
12
+ workflowId?: string[];
13
+ chainId?: number;
14
+ }
15
+ export interface ExecutionStatsParams {
16
+ workflowId?: string[];
17
+ chainId?: number;
18
+ }
19
+ export interface RetrieveExecutionParams {
20
+ /**
21
+ * Workflow id the execution belongs to. Required because executions
22
+ * are stored under their parent workflow's chain-scoped prefix in
23
+ * BadgerDB — there is no global execution index.
24
+ */
25
+ workflowId: string;
26
+ }
27
+ export interface StreamExecutionParams {
28
+ workflowId: string;
29
+ /** Poll interval as a Go-style duration. Defaults to `1s`. */
30
+ interval?: string;
31
+ /** Optional AbortSignal to close the stream early. */
32
+ signal?: AbortSignal;
33
+ }
34
+ /**
35
+ * `client.executions.*` — read-only access to past workflow runs and
36
+ * a live SSE stream for in-flight ones. Workflow executions are
37
+ * created by the operator when a trigger fires (or by `workflows.trigger`
38
+ * for manual runs); this resource never creates them, only reads.
39
+ */
40
+ export declare class ExecutionsResource {
41
+ private readonly transport;
42
+ constructor(transport: Transport);
43
+ /** GET /executions */
44
+ list(params: ListExecutionsParams): Promise<v4.ExecutionList>;
45
+ /** GET /workflows/{id}/executions — convenience nested form. */
46
+ listForWorkflow(workflowId: string, params?: {
47
+ before?: string;
48
+ after?: string;
49
+ limit?: number;
50
+ }): Promise<v4.ExecutionList>;
51
+ /** GET /executions/{id}?workflowId=... */
52
+ retrieve(id: string, params: RetrieveExecutionParams): Promise<v4.Execution>;
53
+ /** GET /executions/{id}:getStatus?workflowId=... */
54
+ getStatus(id: string, params: RetrieveExecutionParams): Promise<v4.ExecutionStatusSummary>;
55
+ /** GET /executions:count */
56
+ count(params?: CountExecutionsParams): Promise<v4.ExecutionCount>;
57
+ /** GET /executions:stats */
58
+ stats(params?: ExecutionStatsParams): Promise<v4.ExecutionStats>;
59
+ /**
60
+ * GET /executions/{id}:stream — yields one `ExecutionStatusSummary`
61
+ * per status change. The stream closes on terminal status, when
62
+ * `signal` aborts, or when the connection drops. Implementation
63
+ * uses fetch streaming + a minimal SSE parser so it works in Node
64
+ * 20+ and browsers without an external EventSource polyfill.
65
+ */
66
+ stream(id: string, params: StreamExecutionParams): AsyncGenerator<v4.ExecutionStatusSummary, void, undefined>;
67
+ /**
68
+ * Poll-and-wait helper — yields the final ExecutionStatusSummary
69
+ * once the execution reaches a terminal status. Use `stream()`
70
+ * when you want every intermediate status update.
71
+ */
72
+ waitForTerminal(id: string, params: StreamExecutionParams): Promise<v4.ExecutionStatusSummary>;
73
+ }
74
+ //# sourceMappingURL=executions.d.ts.map