apinow-sdk 0.28.3 → 0.29.1
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.
- package/dist/cli.js +3 -9
- package/dist/index.d.ts +33 -19
- package/dist/index.js +7 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -210,7 +210,6 @@ program
|
|
|
210
210
|
.requiredOption('--description <desc>', 'Description')
|
|
211
211
|
.option('--method <method>', 'HTTP method', 'POST')
|
|
212
212
|
.option('--price <usdc>', 'USDC price per call', '0.01')
|
|
213
|
-
.option('--splits <json>', 'Splits JSON array [{address, basisPoints, label?, tokenAddress?}] — basisPoints must sum to 10000')
|
|
214
213
|
.option('-k, --key <privateKey>', 'Wallet private key')
|
|
215
214
|
.action(async (opts) => {
|
|
216
215
|
try {
|
|
@@ -223,8 +222,6 @@ program
|
|
|
223
222
|
httpMethod: opts.method.toUpperCase(),
|
|
224
223
|
paymentOptions: [{ usdAmount: opts.price, amount: opts.price }],
|
|
225
224
|
};
|
|
226
|
-
if (opts.splits)
|
|
227
|
-
body.splits = JSON.parse(opts.splits);
|
|
228
225
|
const data = await fetchJson(`${API_BASE}/api/endpoints`, {
|
|
229
226
|
method: 'POST',
|
|
230
227
|
headers: await walletHeaders(privateKey),
|
|
@@ -245,7 +242,6 @@ program
|
|
|
245
242
|
.option('--url <url>', 'New URL')
|
|
246
243
|
.option('--price <usdc>', 'New USDC price')
|
|
247
244
|
.option('--status <status>', 'New status')
|
|
248
|
-
.option('--splits <json>', 'Splits JSON array — changing splits redeploys the splitter contract (V2 is immutable)')
|
|
249
245
|
.option('-k, --key <privateKey>', 'Wallet private key')
|
|
250
246
|
.action(async (id, opts) => {
|
|
251
247
|
try {
|
|
@@ -259,8 +255,6 @@ program
|
|
|
259
255
|
body.status = opts.status;
|
|
260
256
|
if (opts.price)
|
|
261
257
|
body.paymentOptions = [{ usdAmount: opts.price, amount: opts.price }];
|
|
262
|
-
if (opts.splits)
|
|
263
|
-
body.splits = JSON.parse(opts.splits);
|
|
264
258
|
const data = await fetchJson(`${API_BASE}/api/endpoints/${id}`, {
|
|
265
259
|
method: 'PUT',
|
|
266
260
|
headers: await walletHeaders(privateKey),
|
|
@@ -495,7 +489,7 @@ program
|
|
|
495
489
|
.option('--graph <json>', 'Graph JSON (nodes + outputNode)')
|
|
496
490
|
.option('--prompt <prompt>', 'AI prompt to generate workflow')
|
|
497
491
|
.option('--price <usdc>', 'Total price', '0.10')
|
|
498
|
-
.option('--splits <json>', 'Splits JSON array
|
|
492
|
+
.option('--splits <json>', 'Splits JSON array. Each entry: {address, [basisPoints|amount|percent], label?, tokenAddress?}.')
|
|
499
493
|
.option('-k, --key <privateKey>', 'Wallet private key')
|
|
500
494
|
.action(async (opts) => {
|
|
501
495
|
try {
|
|
@@ -529,7 +523,7 @@ program
|
|
|
529
523
|
.option('--description <desc>', 'New description (7-day cooldown)')
|
|
530
524
|
.option('--status <status>', 'New status')
|
|
531
525
|
.option('--price <usdc>', 'New total price — auto-bumps version')
|
|
532
|
-
.option('--splits <json>', 'Splits JSON array
|
|
526
|
+
.option('--splits <json>', 'Splits JSON array (entries accept basisPoints|amount|percent). Auto-bumps version; redeploys splitter if structurally changed.')
|
|
533
527
|
.option('--changelog <msg>', 'Label for the auto-created version snapshot')
|
|
534
528
|
.option('-k, --key <privateKey>', 'Wallet private key')
|
|
535
529
|
.action(async (id, opts) => {
|
|
@@ -654,7 +648,7 @@ program
|
|
|
654
648
|
.description('Create a new version of a workflow (graph/price/splits)')
|
|
655
649
|
.option('--graph <json>', 'Graph JSON (inherits current if omitted)')
|
|
656
650
|
.option('--price <usdc>', 'Total price')
|
|
657
|
-
.option('--splits <json>', 'Splits JSON array')
|
|
651
|
+
.option('--splits <json>', 'Splits JSON array (entries accept basisPoints|amount|percent)')
|
|
658
652
|
.option('--changelog <msg>', 'Changelog message')
|
|
659
653
|
.option('--no-default', 'Create as non-default (keeps current version active)')
|
|
660
654
|
.option('-k, --key <privateKey>', 'Wallet private key')
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const APINOW_SDK_VERSION = "0.
|
|
1
|
+
export declare const APINOW_SDK_VERSION = "0.29.1";
|
|
2
2
|
export interface CallOptions {
|
|
3
3
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
4
4
|
body?: Record<string, any>;
|
|
@@ -51,6 +51,29 @@ export interface SplitConfig {
|
|
|
51
51
|
tokenAddress?: string;
|
|
52
52
|
recipientAddress?: string;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A single split entry as accepted by the workflow write endpoints
|
|
56
|
+
* (create / update / new version). Specify EXACTLY ONE of
|
|
57
|
+
* `basisPoints`, `amount`, or `percent` — the backend normalizes to
|
|
58
|
+
* basis points against the workflow's `totalPrice`:
|
|
59
|
+
*
|
|
60
|
+
* { address, basisPoints: 3000 } // 30.00 %
|
|
61
|
+
* { address, amount: "0.05" } // USDC dollars
|
|
62
|
+
* { address, percent: 30 } // 30.00 %
|
|
63
|
+
*
|
|
64
|
+
* The array as a whole must still sum to 10000 bps (100%). Mix and match
|
|
65
|
+
* per entry; amount / percent are just convenience forms so you don't
|
|
66
|
+
* have to compute bps manually.
|
|
67
|
+
*/
|
|
68
|
+
export interface SplitInput {
|
|
69
|
+
address: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
tokenAddress?: string;
|
|
72
|
+
recipientAddress?: string;
|
|
73
|
+
basisPoints?: number;
|
|
74
|
+
amount?: number | string;
|
|
75
|
+
percent?: number | string;
|
|
76
|
+
}
|
|
54
77
|
/**
|
|
55
78
|
* Thrown by authed writes when the backend returns a non-2xx. Exposes status
|
|
56
79
|
* code and parsed JSON body so callers can branch on e.g. 429 cooldowns
|
|
@@ -118,13 +141,6 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
118
141
|
* Get public endpoint info (free, no payment).
|
|
119
142
|
*/
|
|
120
143
|
info(namespace: string, endpointName: string): Promise<any>;
|
|
121
|
-
/**
|
|
122
|
-
* Create an endpoint. If `splits` are provided they must sum to exactly
|
|
123
|
-
* `10000` basis points; the server deploys a 0xSplits V2 splitter after
|
|
124
|
-
* creation and stores `splitterAddress` on the endpoint. Non-fatal if
|
|
125
|
-
* the splitter deploy fails — endpoint will exist without one and can be
|
|
126
|
-
* retried via `updateEndpoint({ splits })`.
|
|
127
|
-
*/
|
|
128
144
|
createEndpoint(config: {
|
|
129
145
|
namespace: string;
|
|
130
146
|
endpointName: string;
|
|
@@ -143,15 +159,8 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
143
159
|
exampleQuery?: any;
|
|
144
160
|
exampleOutput?: any;
|
|
145
161
|
docsUrl?: string;
|
|
146
|
-
splits?: SplitConfig[];
|
|
147
162
|
}): Promise<any>;
|
|
148
163
|
getEndpoint(id: string): Promise<any>;
|
|
149
|
-
/**
|
|
150
|
-
* Update an endpoint. Changing `splits` (structurally) redeploys the
|
|
151
|
-
* splitter contract (V2 is immutable); the old address is archived on
|
|
152
|
-
* `previousSplitters[]` and the platform drains leftover USDC from it.
|
|
153
|
-
* `splits` must sum to `10000` basis points when non-empty.
|
|
154
|
-
*/
|
|
155
164
|
updateEndpoint(id: string, updates: {
|
|
156
165
|
url?: string;
|
|
157
166
|
description?: string;
|
|
@@ -163,7 +172,6 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
163
172
|
tokenSymbol?: string;
|
|
164
173
|
}>;
|
|
165
174
|
status?: string;
|
|
166
|
-
splits?: SplitConfig[];
|
|
167
175
|
querySchema?: any;
|
|
168
176
|
responseSchema?: any;
|
|
169
177
|
exampleQuery?: any;
|
|
@@ -190,6 +198,12 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
190
198
|
* Get workflow details by ID.
|
|
191
199
|
*/
|
|
192
200
|
getWorkflow(workflowId: string): Promise<any>;
|
|
201
|
+
/**
|
|
202
|
+
* Create a workflow. `splits` accepts either `SplitConfig[]`
|
|
203
|
+
* (`basisPoints`) or the more ergonomic `SplitInput[]` — mix and
|
|
204
|
+
* match `basisPoints | amount | percent` per entry. The server
|
|
205
|
+
* normalizes to basis points against `totalPrice`.
|
|
206
|
+
*/
|
|
193
207
|
createWorkflow(config: {
|
|
194
208
|
name?: string;
|
|
195
209
|
description?: string;
|
|
@@ -205,7 +219,7 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
205
219
|
};
|
|
206
220
|
prompt?: string;
|
|
207
221
|
totalPrice?: string;
|
|
208
|
-
splits?:
|
|
222
|
+
splits?: SplitInput[];
|
|
209
223
|
chain?: string;
|
|
210
224
|
}): Promise<any>;
|
|
211
225
|
/**
|
|
@@ -220,7 +234,7 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
220
234
|
description?: string;
|
|
221
235
|
status?: string;
|
|
222
236
|
totalPrice?: string;
|
|
223
|
-
splits?:
|
|
237
|
+
splits?: SplitInput[];
|
|
224
238
|
graph?: {
|
|
225
239
|
nodes: any[];
|
|
226
240
|
outputNode: string;
|
|
@@ -263,7 +277,7 @@ export declare function createClient(config: ApinowConfig): {
|
|
|
263
277
|
outputMapping?: any;
|
|
264
278
|
};
|
|
265
279
|
totalPrice?: string;
|
|
266
|
-
splits?:
|
|
280
|
+
splits?: SplitInput[];
|
|
267
281
|
mermaidDiagram?: string;
|
|
268
282
|
executionMode?: "balanced" | "optimistic" | "settle_first";
|
|
269
283
|
changelog?: string;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { x402Client, wrapFetchWithPayment } from '@x402/fetch';
|
|
|
2
2
|
import { registerExactEvmScheme } from '@x402/evm/exact/client';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
4
|
const APINOW_BASE = 'https://www.apinow.fun';
|
|
5
|
-
export const APINOW_SDK_VERSION = '0.
|
|
5
|
+
export const APINOW_SDK_VERSION = '0.29.1';
|
|
6
6
|
/**
|
|
7
7
|
* Default base URL. In a browser we prefer the current origin so that
|
|
8
8
|
* signed-auth writes stay same-origin and don't hit a CORS preflight
|
|
@@ -226,13 +226,6 @@ export function createClient(config) {
|
|
|
226
226
|
return res.json();
|
|
227
227
|
},
|
|
228
228
|
// ─── Endpoint CRUD ───
|
|
229
|
-
/**
|
|
230
|
-
* Create an endpoint. If `splits` are provided they must sum to exactly
|
|
231
|
-
* `10000` basis points; the server deploys a 0xSplits V2 splitter after
|
|
232
|
-
* creation and stores `splitterAddress` on the endpoint. Non-fatal if
|
|
233
|
-
* the splitter deploy fails — endpoint will exist without one and can be
|
|
234
|
-
* retried via `updateEndpoint({ splits })`.
|
|
235
|
-
*/
|
|
236
229
|
async createEndpoint(config) {
|
|
237
230
|
return authedJson(`${baseUrl}/api/endpoints`, {
|
|
238
231
|
method: 'POST',
|
|
@@ -245,12 +238,6 @@ export function createClient(config) {
|
|
|
245
238
|
throw new Error(`Failed to get endpoint: ${res.status}`);
|
|
246
239
|
return res.json();
|
|
247
240
|
},
|
|
248
|
-
/**
|
|
249
|
-
* Update an endpoint. Changing `splits` (structurally) redeploys the
|
|
250
|
-
* splitter contract (V2 is immutable); the old address is archived on
|
|
251
|
-
* `previousSplitters[]` and the platform drains leftover USDC from it.
|
|
252
|
-
* `splits` must sum to `10000` basis points when non-empty.
|
|
253
|
-
*/
|
|
254
241
|
async updateEndpoint(id, updates) {
|
|
255
242
|
return authedJson(`${baseUrl}/api/endpoints/${id}`, {
|
|
256
243
|
method: 'PUT',
|
|
@@ -301,6 +288,12 @@ export function createClient(config) {
|
|
|
301
288
|
throw new Error(`Failed to get workflow: ${res.status}`);
|
|
302
289
|
return res.json();
|
|
303
290
|
},
|
|
291
|
+
/**
|
|
292
|
+
* Create a workflow. `splits` accepts either `SplitConfig[]`
|
|
293
|
+
* (`basisPoints`) or the more ergonomic `SplitInput[]` — mix and
|
|
294
|
+
* match `basisPoints | amount | percent` per entry. The server
|
|
295
|
+
* normalizes to basis points against `totalPrice`.
|
|
296
|
+
*/
|
|
304
297
|
async createWorkflow(config) {
|
|
305
298
|
return authedJson(`${baseUrl}/api/workflows`, {
|
|
306
299
|
method: 'POST',
|
package/package.json
CHANGED