@formo/cli 0.2.0 → 1.0.2
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/README.md +154 -40
- package/dist/commands/alerts.d.ts +16 -3
- package/dist/commands/alerts.js +94 -24
- package/dist/commands/analytics.d.ts +25 -0
- package/dist/commands/analytics.js +153 -0
- package/dist/commands/boards.d.ts +11 -2
- package/dist/commands/boards.js +49 -17
- package/dist/commands/charts.d.ts +30 -3
- package/dist/commands/charts.js +297 -33
- package/dist/commands/contracts.d.ts +17 -13
- package/dist/commands/contracts.js +165 -53
- package/dist/commands/events.d.ts +9 -0
- package/dist/commands/events.js +64 -0
- package/dist/commands/import.d.ts +8 -4
- package/dist/commands/import.js +33 -11
- package/dist/commands/profiles.d.ts +35 -2
- package/dist/commands/profiles.js +260 -32
- package/dist/commands/query.js +5 -1
- package/dist/commands/segments.d.ts +6 -2
- package/dist/commands/segments.js +20 -6
- package/dist/index.js +15 -3
- package/dist/lib/client.d.ts +10 -1
- package/dist/lib/client.js +27 -4
- package/dist/lib/config.js +10 -0
- package/dist/lib/json.d.ts +5 -0
- package/dist/lib/json.js +54 -0
- package/dist/lib/sql.d.ts +31 -0
- package/dist/lib/sql.js +151 -0
- package/package.json +3 -3
|
@@ -2,52 +2,117 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contracts = void 0;
|
|
4
4
|
exports.listContractsRun = listContractsRun;
|
|
5
|
+
exports.getContractRun = getContractRun;
|
|
6
|
+
exports.getContractRecommendationsRun = getContractRecommendationsRun;
|
|
5
7
|
exports.buildCreateContractBody = buildCreateContractBody;
|
|
6
8
|
exports.createContractRun = createContractRun;
|
|
7
9
|
exports.buildUpdateContractBody = buildUpdateContractBody;
|
|
8
10
|
exports.updateContractRun = updateContractRun;
|
|
11
|
+
exports.updateContractPipelineRun = updateContractPipelineRun;
|
|
12
|
+
exports.buildUpdateContractPipelineBody = buildUpdateContractPipelineBody;
|
|
9
13
|
exports.deleteContractRun = deleteContractRun;
|
|
10
14
|
const incur_1 = require("incur");
|
|
11
15
|
const client_1 = require("../lib/client");
|
|
16
|
+
const json_1 = require("../lib/json");
|
|
12
17
|
exports.contracts = incur_1.Cli.create('contracts', {
|
|
13
|
-
description: 'Smart contract commands — register, list, update, and remove tracked contracts',
|
|
18
|
+
description: 'Smart contract commands — register, list, recommend, update, toggle pipeline inclusion, and remove tracked contracts',
|
|
14
19
|
});
|
|
20
|
+
function buildPaginationParams(options = {}) {
|
|
21
|
+
const params = {};
|
|
22
|
+
if (options.page !== undefined)
|
|
23
|
+
params.page = options.page;
|
|
24
|
+
if (options.size !== undefined)
|
|
25
|
+
params.size = options.size;
|
|
26
|
+
return params;
|
|
27
|
+
}
|
|
28
|
+
function parseChain(chain) {
|
|
29
|
+
const value = typeof chain === 'number' ? chain : Number(chain);
|
|
30
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
31
|
+
throw new Error('chain must be a positive integer');
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
15
35
|
// ── List contracts ──
|
|
16
|
-
function listContractsRun() {
|
|
36
|
+
function listContractsRun(options = {}) {
|
|
17
37
|
(0, client_1.requireApiKey)();
|
|
18
38
|
const client = (0, client_1.createClient)();
|
|
19
|
-
return client.get('/v0/contracts/'
|
|
39
|
+
return client.get('/v0/contracts/', {
|
|
40
|
+
params: buildPaginationParams(options),
|
|
41
|
+
});
|
|
20
42
|
}
|
|
21
43
|
exports.contracts.command('list', {
|
|
22
44
|
description: 'List all tracked contracts for the project',
|
|
45
|
+
options: incur_1.z.object({
|
|
46
|
+
page: incur_1.z.coerce.number().optional().describe('Page number (1-indexed, default 1)'),
|
|
47
|
+
size: incur_1.z.coerce.number().optional().describe('Page size (default 100, max 200)'),
|
|
48
|
+
}),
|
|
23
49
|
examples: [{ description: 'List all project contracts' }],
|
|
24
50
|
hint: 'Requires contracts:read scope on your API key.',
|
|
51
|
+
run({ options }) {
|
|
52
|
+
return listContractsRun(options);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
// ── Get a contract ──
|
|
56
|
+
function getContractRun(chain, address) {
|
|
57
|
+
(0, client_1.requireApiKey)();
|
|
58
|
+
const client = (0, client_1.createClient)();
|
|
59
|
+
return client.get(`/v0/contracts/${encodeURIComponent(chain)}/${encodeURIComponent(address)}`);
|
|
60
|
+
}
|
|
61
|
+
// ── Recommended contracts ──
|
|
62
|
+
function getContractRecommendationsRun() {
|
|
63
|
+
(0, client_1.requireApiKey)();
|
|
64
|
+
const client = (0, client_1.createClient)();
|
|
65
|
+
return client.get('/v0/contracts/recommendations');
|
|
66
|
+
}
|
|
67
|
+
exports.contracts.command('recommendations', {
|
|
68
|
+
description: 'List contracts the project already interacts with but has not added yet',
|
|
69
|
+
options: incur_1.z.object({}),
|
|
70
|
+
examples: [
|
|
71
|
+
{
|
|
72
|
+
description: 'Show recommended contracts to add for decoding/monitoring',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
hint: 'Requires contracts:read scope on your API key.',
|
|
25
76
|
run() {
|
|
26
|
-
return
|
|
77
|
+
return getContractRecommendationsRun();
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
exports.contracts.command('get', {
|
|
81
|
+
description: 'Get a tracked contract by chain and address',
|
|
82
|
+
args: incur_1.z.object({
|
|
83
|
+
chain: incur_1.z.string().describe('Chain ID'),
|
|
84
|
+
address: incur_1.z.string().describe('Contract address (0x...)'),
|
|
85
|
+
}),
|
|
86
|
+
examples: [
|
|
87
|
+
{
|
|
88
|
+
args: {
|
|
89
|
+
chain: '1',
|
|
90
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
91
|
+
},
|
|
92
|
+
description: 'Get a tracked USDC contract',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
hint: 'Requires contracts:read scope on your API key.',
|
|
96
|
+
run({ args }) {
|
|
97
|
+
return getContractRun(args.chain, args.address);
|
|
27
98
|
},
|
|
28
99
|
});
|
|
29
100
|
function buildCreateContractBody(options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
throw new Error('--abi must be a valid JSON array');
|
|
36
|
-
}
|
|
37
|
-
let parsedEvents;
|
|
38
|
-
try {
|
|
39
|
-
parsedEvents = JSON.parse(options.events);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
throw new Error('--events must be valid JSON');
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
101
|
+
const parsedAbi = (0, json_1.parseJsonArray)(options.abi, '--abi');
|
|
102
|
+
const parsedEvents = (0, json_1.parseJsonArray)(options.events, '--events');
|
|
103
|
+
const body = {
|
|
45
104
|
address: options.address,
|
|
46
|
-
chain: options.chain,
|
|
105
|
+
chain: parseChain(options.chain),
|
|
47
106
|
name: options.name,
|
|
48
|
-
abi: parsedAbi,
|
|
107
|
+
abi: JSON.stringify(parsedAbi),
|
|
49
108
|
events: parsedEvents,
|
|
50
109
|
};
|
|
110
|
+
if (options.startBlock !== undefined)
|
|
111
|
+
body.start_block = options.startBlock;
|
|
112
|
+
if (options.includeInPipeline !== undefined) {
|
|
113
|
+
body.include_in_pipeline = options.includeInPipeline;
|
|
114
|
+
}
|
|
115
|
+
return body;
|
|
51
116
|
}
|
|
52
117
|
function createContractRun(options) {
|
|
53
118
|
(0, client_1.requireApiKey)();
|
|
@@ -57,20 +122,25 @@ function createContractRun(options) {
|
|
|
57
122
|
exports.contracts.command('create', {
|
|
58
123
|
description: 'Register a new smart contract to track',
|
|
59
124
|
options: incur_1.z.object({
|
|
60
|
-
address: incur_1.z.string().describe('Contract address (0x
|
|
125
|
+
address: incur_1.z.string().describe('Contract address (0x...)'),
|
|
61
126
|
chain: incur_1.z.coerce.number().describe('Chain ID (e.g. 1 for Ethereum, 137 for Polygon)'),
|
|
62
127
|
name: incur_1.z.string().describe('Human-readable contract name'),
|
|
63
128
|
abi: incur_1.z.string().describe('Contract ABI as a JSON string'),
|
|
64
|
-
events: incur_1.z.string().describe('
|
|
129
|
+
events: incur_1.z.string().describe('JSON array of ABI event objects to monitor (max 10)'),
|
|
130
|
+
startBlock: incur_1.z.coerce.number().optional().describe('Optional start block'),
|
|
131
|
+
includeInPipeline: incur_1.z
|
|
132
|
+
.boolean()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe('Whether to include this contract in the Goldsky events pipeline'),
|
|
65
135
|
}),
|
|
66
136
|
examples: [
|
|
67
137
|
{
|
|
68
138
|
options: {
|
|
69
|
-
address: '
|
|
139
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
70
140
|
chain: 1,
|
|
71
|
-
name: '
|
|
72
|
-
abi: '[{"type":"event","name":"Transfer"}]',
|
|
73
|
-
events: '{"Transfer":
|
|
141
|
+
name: 'USDC',
|
|
142
|
+
abi: '[{"anonymous":false,"type":"event","name":"Transfer","inputs":[]}]',
|
|
143
|
+
events: '[{"anonymous":false,"type":"event","name":"Transfer","inputs":[]}]',
|
|
74
144
|
},
|
|
75
145
|
description: 'Register an ERC-20 contract on Ethereum',
|
|
76
146
|
},
|
|
@@ -80,50 +150,54 @@ exports.contracts.command('create', {
|
|
|
80
150
|
return createContractRun(options);
|
|
81
151
|
},
|
|
82
152
|
});
|
|
83
|
-
function buildUpdateContractBody(options) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
throw new Error('--abi must be a valid JSON array');
|
|
90
|
-
}
|
|
91
|
-
let parsedEvents;
|
|
92
|
-
try {
|
|
93
|
-
parsedEvents = JSON.parse(options.events);
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
throw new Error('--events must be valid JSON');
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
153
|
+
function buildUpdateContractBody(chain, address, options) {
|
|
154
|
+
const parsedAbi = (0, json_1.parseJsonArray)(options.abi, '--abi');
|
|
155
|
+
const parsedEvents = (0, json_1.parseJsonArray)(options.events, '--events');
|
|
156
|
+
const body = {
|
|
157
|
+
address,
|
|
158
|
+
chain: parseChain(chain),
|
|
99
159
|
name: options.name,
|
|
100
|
-
abi: parsedAbi,
|
|
160
|
+
abi: JSON.stringify(parsedAbi),
|
|
101
161
|
events: parsedEvents,
|
|
102
162
|
};
|
|
163
|
+
if (options.startBlock !== undefined)
|
|
164
|
+
body.start_block = options.startBlock;
|
|
165
|
+
if (options.includeInPipeline !== undefined) {
|
|
166
|
+
body.include_in_pipeline = options.includeInPipeline;
|
|
167
|
+
}
|
|
168
|
+
return body;
|
|
103
169
|
}
|
|
104
170
|
function updateContractRun(chain, address, options) {
|
|
105
171
|
(0, client_1.requireApiKey)();
|
|
106
172
|
const client = (0, client_1.createClient)();
|
|
107
|
-
return client.put(`/v0/contracts/${encodeURIComponent(chain)}/${encodeURIComponent(address)}`, buildUpdateContractBody(options));
|
|
173
|
+
return client.put(`/v0/contracts/${encodeURIComponent(chain)}/${encodeURIComponent(address)}`, buildUpdateContractBody(chain, address, options));
|
|
108
174
|
}
|
|
109
175
|
exports.contracts.command('update', {
|
|
110
176
|
description: 'Update a tracked contract',
|
|
111
177
|
args: incur_1.z.object({
|
|
112
178
|
chain: incur_1.z.string().describe('Chain ID'),
|
|
113
|
-
address: incur_1.z.string().describe('Contract address (0x
|
|
179
|
+
address: incur_1.z.string().describe('Contract address (0x...)'),
|
|
114
180
|
}),
|
|
115
181
|
options: incur_1.z.object({
|
|
116
182
|
name: incur_1.z.string().describe('Updated contract name'),
|
|
117
183
|
abi: incur_1.z.string().describe('Updated ABI as a JSON string'),
|
|
118
|
-
events: incur_1.z.string().describe('Updated
|
|
184
|
+
events: incur_1.z.string().describe('Updated JSON array of ABI event objects to monitor'),
|
|
185
|
+
startBlock: incur_1.z.coerce.number().optional().describe('Optional start block'),
|
|
186
|
+
includeInPipeline: incur_1.z
|
|
187
|
+
.boolean()
|
|
188
|
+
.optional()
|
|
189
|
+
.describe('Whether to include this contract in the Goldsky events pipeline'),
|
|
119
190
|
}),
|
|
120
191
|
examples: [
|
|
121
192
|
{
|
|
122
|
-
args: {
|
|
193
|
+
args: {
|
|
194
|
+
chain: '1',
|
|
195
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
196
|
+
},
|
|
123
197
|
options: {
|
|
124
|
-
name: '
|
|
125
|
-
abi: '[{"type":"event","name":"Transfer"}]',
|
|
126
|
-
events: '{"Transfer":
|
|
198
|
+
name: 'USD Coin',
|
|
199
|
+
abi: '[{"anonymous":false,"type":"event","name":"Transfer","inputs":[]}]',
|
|
200
|
+
events: '[{"anonymous":false,"type":"event","name":"Transfer","inputs":[]}]',
|
|
127
201
|
},
|
|
128
202
|
description: 'Update a contract',
|
|
129
203
|
},
|
|
@@ -133,6 +207,41 @@ exports.contracts.command('update', {
|
|
|
133
207
|
return updateContractRun(args.chain, args.address, options);
|
|
134
208
|
},
|
|
135
209
|
});
|
|
210
|
+
// ── Toggle contract pipeline inclusion ──
|
|
211
|
+
function updateContractPipelineRun(chain, address, includeInPipeline) {
|
|
212
|
+
(0, client_1.requireApiKey)();
|
|
213
|
+
const client = (0, client_1.createClient)();
|
|
214
|
+
return client.patch(`/v0/contracts/${encodeURIComponent(chain)}/${encodeURIComponent(address)}/pipeline`, buildUpdateContractPipelineBody(includeInPipeline));
|
|
215
|
+
}
|
|
216
|
+
function buildUpdateContractPipelineBody(includeInPipeline) {
|
|
217
|
+
return { include_in_pipeline: includeInPipeline };
|
|
218
|
+
}
|
|
219
|
+
exports.contracts.command('pipeline', {
|
|
220
|
+
description: 'Toggle whether a tracked contract is included in the project events pipeline',
|
|
221
|
+
args: incur_1.z.object({
|
|
222
|
+
chain: incur_1.z.string().describe('Chain ID'),
|
|
223
|
+
address: incur_1.z.string().describe('Contract address (0x...)'),
|
|
224
|
+
}),
|
|
225
|
+
options: incur_1.z.object({
|
|
226
|
+
includeInPipeline: incur_1.z
|
|
227
|
+
.boolean()
|
|
228
|
+
.describe('true to include the contract in the pipeline, false to exclude it'),
|
|
229
|
+
}),
|
|
230
|
+
examples: [
|
|
231
|
+
{
|
|
232
|
+
args: {
|
|
233
|
+
chain: '1',
|
|
234
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
235
|
+
},
|
|
236
|
+
options: { includeInPipeline: false },
|
|
237
|
+
description: 'Keep ABI decoding but exclude this contract from pipeline deploys',
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
hint: 'Requires contracts:write scope on your API key.',
|
|
241
|
+
run({ args, options }) {
|
|
242
|
+
return updateContractPipelineRun(args.chain, args.address, options.includeInPipeline);
|
|
243
|
+
},
|
|
244
|
+
});
|
|
136
245
|
// ── Delete a contract ──
|
|
137
246
|
function deleteContractRun(chain, address) {
|
|
138
247
|
(0, client_1.requireApiKey)();
|
|
@@ -143,11 +252,14 @@ exports.contracts.command('delete', {
|
|
|
143
252
|
description: 'Remove a tracked contract',
|
|
144
253
|
args: incur_1.z.object({
|
|
145
254
|
chain: incur_1.z.string().describe('Chain ID'),
|
|
146
|
-
address: incur_1.z.string().describe('Contract address (0x
|
|
255
|
+
address: incur_1.z.string().describe('Contract address (0x...)'),
|
|
147
256
|
}),
|
|
148
257
|
examples: [
|
|
149
258
|
{
|
|
150
|
-
args: {
|
|
259
|
+
args: {
|
|
260
|
+
chain: '1',
|
|
261
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
262
|
+
},
|
|
151
263
|
description: 'Delete a contract',
|
|
152
264
|
},
|
|
153
265
|
],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cli } from 'incur';
|
|
2
|
+
export declare const events: Cli.Cli<{}, undefined, undefined>;
|
|
3
|
+
export interface IngestEventsOptions {
|
|
4
|
+
events?: string;
|
|
5
|
+
event?: string;
|
|
6
|
+
writeKey?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildIngestEventsBody(options: IngestEventsOptions): Record<string, unknown>[];
|
|
9
|
+
export declare function ingestEventsRun(options: IngestEventsOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.events = void 0;
|
|
4
|
+
exports.buildIngestEventsBody = buildIngestEventsBody;
|
|
5
|
+
exports.ingestEventsRun = ingestEventsRun;
|
|
6
|
+
const incur_1 = require("incur");
|
|
7
|
+
const client_1 = require("../lib/client");
|
|
8
|
+
const json_1 = require("../lib/json");
|
|
9
|
+
exports.events = incur_1.Cli.create('events', {
|
|
10
|
+
description: 'Event ingestion commands — send raw analytics events with a project SDK write key',
|
|
11
|
+
});
|
|
12
|
+
function getWriteKey(options) {
|
|
13
|
+
return options.writeKey ?? process.env.FORMO_WRITE_KEY;
|
|
14
|
+
}
|
|
15
|
+
function buildIngestEventsBody(options) {
|
|
16
|
+
if (options.events) {
|
|
17
|
+
const events = (0, json_1.parseJsonArrayOfObjects)(options.events, '--events');
|
|
18
|
+
if (events.length === 0) {
|
|
19
|
+
throw new Error('--events must contain at least one event');
|
|
20
|
+
}
|
|
21
|
+
return events;
|
|
22
|
+
}
|
|
23
|
+
if (options.event) {
|
|
24
|
+
return [(0, json_1.parseJsonObject)(options.event, '--event')];
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Provide --event or --events');
|
|
27
|
+
}
|
|
28
|
+
function ingestEventsRun(options) {
|
|
29
|
+
const writeKey = getWriteKey(options);
|
|
30
|
+
if (!writeKey) {
|
|
31
|
+
throw new Error('No event write key configured. Pass --write-key or set FORMO_WRITE_KEY.');
|
|
32
|
+
}
|
|
33
|
+
const client = (0, client_1.createEventsClient)(writeKey);
|
|
34
|
+
return client.post('/v0/raw_events', buildIngestEventsBody(options));
|
|
35
|
+
}
|
|
36
|
+
exports.events.command('ingest', {
|
|
37
|
+
description: 'Send one or more raw events to the Formo events API',
|
|
38
|
+
options: incur_1.z.object({
|
|
39
|
+
event: incur_1.z
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Single event as a JSON object; wrapped in an array before sending'),
|
|
43
|
+
events: incur_1.z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('JSON array of event objects to send'),
|
|
47
|
+
writeKey: incur_1.z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Project SDK write key. Defaults to FORMO_WRITE_KEY.'),
|
|
51
|
+
}),
|
|
52
|
+
examples: [
|
|
53
|
+
{
|
|
54
|
+
options: {
|
|
55
|
+
event: '{"type":"track","channel":"cli","version":"1","anonymous_id":"anon_123","address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","event":"CLI Test","context":{},"properties":{},"original_timestamp":"2026-04-27T23:05:38.000Z","sent_at":"2026-04-27T23:05:42.000Z","message_id":"cli-test-1"}',
|
|
56
|
+
},
|
|
57
|
+
description: 'Send one custom event using FORMO_WRITE_KEY',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
hint: 'Uses the events.formo.so API and requires a project SDK write key, not a workspace API key.',
|
|
61
|
+
run({ options }) {
|
|
62
|
+
return ingestEventsRun(options);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Cli } from 'incur';
|
|
2
2
|
export declare const importCmd: Cli.Cli<{}, undefined, undefined>;
|
|
3
3
|
export interface ImportWalletsOptions {
|
|
4
|
-
addresses
|
|
5
|
-
|
|
4
|
+
addresses?: string;
|
|
5
|
+
rows?: string;
|
|
6
|
+
writeKey?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function buildImportBody(options: ImportWalletsOptions): {
|
|
8
|
-
addresses:
|
|
9
|
-
|
|
9
|
+
addresses: unknown[];
|
|
10
|
+
rows: Record<string, unknown>[];
|
|
11
|
+
} | {
|
|
12
|
+
addresses: unknown[];
|
|
13
|
+
rows?: undefined;
|
|
10
14
|
};
|
|
11
15
|
export declare function importWalletsRun(options: ImportWalletsOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
package/dist/commands/import.js
CHANGED
|
@@ -5,23 +5,31 @@ exports.buildImportBody = buildImportBody;
|
|
|
5
5
|
exports.importWalletsRun = importWalletsRun;
|
|
6
6
|
const incur_1 = require("incur");
|
|
7
7
|
const client_1 = require("../lib/client");
|
|
8
|
+
const json_1 = require("../lib/json");
|
|
8
9
|
exports.importCmd = incur_1.Cli.create('import', {
|
|
9
10
|
description: 'Import commands — bulk import wallet addresses into your project',
|
|
10
11
|
});
|
|
11
12
|
function buildImportBody(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
throw new Error('
|
|
13
|
+
if (options.rows) {
|
|
14
|
+
const rows = (0, json_1.parseJsonArrayOfObjects)(options.rows, '--rows');
|
|
15
|
+
const addresses = rows.map((row) => row.address);
|
|
16
|
+
if (addresses.some((address) => typeof address !== 'string' || !address)) {
|
|
17
|
+
throw new Error('--rows entries must each include a non-empty string address');
|
|
17
18
|
}
|
|
19
|
+
return {
|
|
20
|
+
addresses,
|
|
21
|
+
rows,
|
|
22
|
+
};
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
throw new Error('--addresses
|
|
24
|
+
if (!options.addresses) {
|
|
25
|
+
throw new Error('Provide --addresses or --rows');
|
|
26
|
+
}
|
|
27
|
+
const addresses = (0, json_1.parseJsonArray)(options.addresses, '--addresses');
|
|
28
|
+
if (addresses.some((address) => typeof address !== 'string' || !address)) {
|
|
29
|
+
throw new Error('--addresses must be a JSON array of wallet address strings');
|
|
21
30
|
}
|
|
22
31
|
return {
|
|
23
|
-
addresses
|
|
24
|
-
writeKey: options.writeKey,
|
|
32
|
+
addresses,
|
|
25
33
|
};
|
|
26
34
|
}
|
|
27
35
|
function importWalletsRun(options) {
|
|
@@ -34,17 +42,31 @@ exports.importCmd.command('wallets', {
|
|
|
34
42
|
options: incur_1.z.object({
|
|
35
43
|
addresses: incur_1.z
|
|
36
44
|
.string()
|
|
45
|
+
.optional()
|
|
37
46
|
.describe('JSON array of wallet address strings to import'),
|
|
38
|
-
|
|
47
|
+
rows: incur_1.z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('JSON array of {address,properties?} objects for imports with profile properties'),
|
|
51
|
+
writeKey: incur_1.z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('Deprecated; import now uses the project write key server-side')
|
|
55
|
+
.meta({ deprecated: true }),
|
|
39
56
|
}),
|
|
40
57
|
examples: [
|
|
41
58
|
{
|
|
42
59
|
options: {
|
|
43
60
|
addresses: '["0xabc…","0xdef…"]',
|
|
44
|
-
writeKey: 'write_key_xxx',
|
|
45
61
|
},
|
|
46
62
|
description: 'Import two wallet addresses',
|
|
47
63
|
},
|
|
64
|
+
{
|
|
65
|
+
options: {
|
|
66
|
+
rows: '[{"address":"0xabc…","properties":{"display_name":"Alice"}}]',
|
|
67
|
+
},
|
|
68
|
+
description: 'Import wallets with profile properties',
|
|
69
|
+
},
|
|
48
70
|
],
|
|
49
71
|
hint: 'Requires profiles:write scope. Only available on Scale and Enterprise plans.',
|
|
50
72
|
run({ options }) {
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { Cli } from 'incur';
|
|
2
2
|
export declare const profiles: Cli.Cli<{}, undefined, undefined>;
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export interface LifecycleThresholdOptions {
|
|
4
|
+
newWindowDays?: number;
|
|
5
|
+
churnWindowDays?: number;
|
|
6
|
+
powerUserMinActiveDays?: number;
|
|
7
|
+
powerUserWindowDays?: number;
|
|
8
|
+
resurrectedGapDays?: number;
|
|
9
|
+
atRiskMinDaysInactive?: number;
|
|
10
|
+
atRiskPriorActiveDaysThreshold?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface GetProfileOptions extends LifecycleThresholdOptions {
|
|
13
|
+
expand?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function getProfileRun(address: string, optionsOrExpand?: GetProfileOptions | string): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
16
|
+
export interface SearchProfilesOptions extends LifecycleThresholdOptions {
|
|
5
17
|
address?: string;
|
|
18
|
+
search?: string;
|
|
6
19
|
page?: number;
|
|
7
20
|
size?: number;
|
|
8
21
|
orderBy?: string;
|
|
@@ -11,21 +24,41 @@ export interface SearchProfilesOptions {
|
|
|
11
24
|
conditions?: string;
|
|
12
25
|
logic?: 'and' | 'or';
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse and validate the --conditions JSON. Ensures it is an array of
|
|
29
|
+
* `{ field, op, value }` objects whose `field` is a typed path (e.g.
|
|
30
|
+
* `users.net_worth_usd`) — a bare name like `net_worth_usd` is silently
|
|
31
|
+
* dropped by the API, so it is rejected here. Exported for unit testing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseSearchConditions(raw: string): unknown[];
|
|
14
34
|
export declare function searchProfilesRun(options: SearchProfilesOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
15
35
|
export interface UpdateProfileOptions {
|
|
16
36
|
properties: string;
|
|
17
37
|
}
|
|
18
38
|
export declare function buildUpdateProfileBody(options: UpdateProfileOptions): Record<string, unknown>;
|
|
19
39
|
export declare function updateProfileRun(address: string, options: UpdateProfileOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
40
|
+
export interface BatchUpdateProfilesOptions {
|
|
41
|
+
rows: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function buildBatchUpdateProfilesBody(options: BatchUpdateProfilesOptions): Record<string, unknown>[];
|
|
44
|
+
export declare function batchUpdateProfilesRun(options: BatchUpdateProfilesOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
45
|
+
export declare const profilesProperties: Cli.Cli<{}, undefined, undefined>;
|
|
20
46
|
export declare const profilesLabels: Cli.Cli<{}, undefined, undefined>;
|
|
21
47
|
export interface CreateProfileLabelOptions {
|
|
22
48
|
tagId?: string;
|
|
23
49
|
value?: string;
|
|
24
50
|
chainId?: string;
|
|
51
|
+
timestamp?: string;
|
|
52
|
+
isDeleted?: boolean;
|
|
25
53
|
labels?: string;
|
|
26
54
|
}
|
|
27
55
|
export declare function buildCreateLabelBody(options: CreateProfileLabelOptions): unknown;
|
|
28
56
|
export declare function createProfileLabelRun(address: string, options: CreateProfileLabelOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
57
|
+
export interface BatchCreateProfileLabelsOptions {
|
|
58
|
+
labels: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function buildBatchCreateLabelsBody(options: BatchCreateProfileLabelsOptions): Record<string, unknown>[];
|
|
61
|
+
export declare function batchCreateProfileLabelsRun(options: BatchCreateProfileLabelsOptions): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
29
62
|
export interface DeleteProfileLabelOptions {
|
|
30
63
|
tagId: string;
|
|
31
64
|
chainId?: string;
|