@gravity-rail/cli 0.56.0 → 0.57.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.
- package/README.md +5 -1
- package/dist/{account-verify-phone-IK6O7IQJ.js → account-verify-phone-Q4FKI4PX.js} +3 -3
- package/dist/{chunk-5UCDTTIU.js → chunk-CB4K2FBU.js} +47 -3
- package/dist/chunk-CB4K2FBU.js.map +1 -0
- package/dist/{chunk-SSJ7CRGL.js → chunk-TY6HKHOV.js} +2 -2
- package/dist/cli-utils.js +1 -1
- package/dist/gr.js +1272 -420
- package/dist/gr.js.map +1 -1
- package/dist/lib.d.ts +32 -3
- package/dist/lib.js +752 -345
- package/dist/lib.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-5UCDTTIU.js.map +0 -1
- /package/dist/{account-verify-phone-IK6O7IQJ.js.map → account-verify-phone-Q4FKI4PX.js.map} +0 -0
- /package/dist/{chunk-SSJ7CRGL.js.map → chunk-TY6HKHOV.js.map} +0 -0
package/dist/lib.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
startAccountPhoneVerify,
|
|
34
34
|
stderr,
|
|
35
35
|
unwrapItems
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-TY6HKHOV.js";
|
|
37
37
|
import {
|
|
38
38
|
AGUIClient,
|
|
39
39
|
formatTimestamp,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
isRecord,
|
|
43
43
|
performOAuthFlow,
|
|
44
44
|
selectFromList
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-CB4K2FBU.js";
|
|
46
46
|
import {
|
|
47
47
|
AuthRequiredError,
|
|
48
48
|
CLIError,
|
|
@@ -258,7 +258,7 @@ function commandNeedsJsonBody(cmd, parsedArgs) {
|
|
|
258
258
|
}
|
|
259
259
|
return false;
|
|
260
260
|
}
|
|
261
|
-
if (cmd.acceptsJsonInput === true) {
|
|
261
|
+
if (cmd.acceptsJsonInput === true || cmd.pipesJsonInput !== void 0) {
|
|
262
262
|
return true;
|
|
263
263
|
}
|
|
264
264
|
if (parsedArgs.data !== void 0 || parsedArgs.file !== void 0) {
|
|
@@ -279,7 +279,19 @@ function commandNeedsJsonBody(cmd, parsedArgs) {
|
|
|
279
279
|
}
|
|
280
280
|
return false;
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
var PIPED_INPUT_FIRST_BYTE_WAIT_MS = 6e4;
|
|
283
|
+
function commandAwaitsPipedInput(cmd, parsedArgs) {
|
|
284
|
+
if (parsedArgs.data !== void 0 || parsedArgs.file !== void 0) return false;
|
|
285
|
+
const declared = cmd.pipesJsonInput;
|
|
286
|
+
return typeof declared === "function" ? declared(parsedArgs) : declared === true;
|
|
287
|
+
}
|
|
288
|
+
async function readCommandJsonInput(cmd, parsedArgs) {
|
|
289
|
+
if (!commandNeedsJsonBody(cmd, parsedArgs)) return void 0;
|
|
290
|
+
return readJsonInput(parsedArgs, {
|
|
291
|
+
pipedInputWaitMs: commandAwaitsPipedInput(cmd, parsedArgs) ? PIPED_INPUT_FIRST_BYTE_WAIT_MS : 0
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async function readJsonInput(args, options = {}) {
|
|
283
295
|
const dataStr = args.data;
|
|
284
296
|
const filePath = args.file;
|
|
285
297
|
if (dataStr) {
|
|
@@ -310,15 +322,17 @@ async function readJsonInput(args) {
|
|
|
310
322
|
if (process.stdin.isTTY === true) {
|
|
311
323
|
return void 0;
|
|
312
324
|
}
|
|
313
|
-
return readStdinIfPiped();
|
|
325
|
+
return readStdinIfPiped(options.pipedInputWaitMs ?? 0);
|
|
314
326
|
}
|
|
315
|
-
function readStdinIfPiped() {
|
|
327
|
+
function readStdinIfPiped(firstByteWaitMs) {
|
|
316
328
|
return new Promise((resolve, reject) => {
|
|
317
329
|
let data = "";
|
|
318
330
|
let settled = false;
|
|
331
|
+
let idleTimer;
|
|
319
332
|
const finish2 = (value) => {
|
|
320
333
|
if (settled) return;
|
|
321
334
|
settled = true;
|
|
335
|
+
if (idleTimer) clearTimeout(idleTimer);
|
|
322
336
|
resolve(value);
|
|
323
337
|
};
|
|
324
338
|
const flush = () => {
|
|
@@ -347,6 +361,15 @@ function readStdinIfPiped() {
|
|
|
347
361
|
flush();
|
|
348
362
|
return;
|
|
349
363
|
}
|
|
364
|
+
if (firstByteWaitMs > 0) {
|
|
365
|
+
idleTimer = setTimeout(() => {
|
|
366
|
+
if (!data) {
|
|
367
|
+
process.stdin.pause();
|
|
368
|
+
finish2(void 0);
|
|
369
|
+
}
|
|
370
|
+
}, firstByteWaitMs);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
350
373
|
finish2(void 0);
|
|
351
374
|
});
|
|
352
375
|
});
|
|
@@ -1383,9 +1406,9 @@ Optional
|
|
|
1383
1406
|
systemPrompt (string) Base instructions / identity
|
|
1384
1407
|
chatModelConfig (object|null) Chat model overrides (temperature, thinking, \u2026)
|
|
1385
1408
|
realtimeModelId (string|null) Voice/realtime model (see \`gr ai-models realtime\`)
|
|
1386
|
-
e.g. "xai:realtime:voice-agent-
|
|
1387
|
-
|
|
1388
|
-
|
|
1409
|
+
e.g. "xai:realtime:voice-agent-3" (Grok Voice 3, the
|
|
1410
|
+
default; not yet cleared for strict-routing workflows).
|
|
1411
|
+
"xai:realtime:voice-agent-2" is deprecated.
|
|
1389
1412
|
Native models auto-fill tts=native + default voice when
|
|
1390
1413
|
realtimeModelConfig is omitted.
|
|
1391
1414
|
realtimeModelConfig (object|null) Realtime config. Native example:
|
|
@@ -1403,11 +1426,7 @@ Attach an agent\u2019s models/identity to a workflow (draft), then publish:
|
|
|
1403
1426
|
gr workflows update --id <wf> -d '{"copyFromAgentId": <agentId>}'
|
|
1404
1427
|
gr workflows publish --workflow-id <wf>
|
|
1405
1428
|
|
|
1406
|
-
One-shot workflow voice WITHOUT creating an agent (preferred for "use Grok Voice
|
|
1407
|
-
gr workflows update --id <wf> -d '{"realtimeModelId":"xai:realtime:voice-agent-2"}'
|
|
1408
|
-
gr workflows publish --workflow-id <wf>
|
|
1409
|
-
|
|
1410
|
-
Opt a workflow into Grok Voice 3.0 (same xAI voices as 2.0; not the default):
|
|
1429
|
+
One-shot workflow voice WITHOUT creating an agent (preferred for "use Grok Voice 3"):
|
|
1411
1430
|
gr workflows update --id <wf> -d '{"realtimeModelId":"xai:realtime:voice-agent-3"}'
|
|
1412
1431
|
gr workflows publish --workflow-id <wf>
|
|
1413
1432
|
|
|
@@ -1435,11 +1454,10 @@ ${AGENT_FIELD_REFERENCE}`,
|
|
|
1435
1454
|
updateHelp: `Update an agent. All fields optional.
|
|
1436
1455
|
${AGENT_FIELD_REFERENCE}`,
|
|
1437
1456
|
createExamples: [
|
|
1438
|
-
`gr agents create -d '{"name":"Support","chatModelId":"openai:chat:gpt-6-luna","realtimeModelId":"xai:realtime:voice-agent-
|
|
1457
|
+
`gr agents create -d '{"name":"Support","chatModelId":"openai:chat:gpt-6-luna","realtimeModelId":"xai:realtime:voice-agent-3"}'`,
|
|
1439
1458
|
"gr agents create --file agent.json"
|
|
1440
1459
|
],
|
|
1441
1460
|
updateExamples: [
|
|
1442
|
-
`gr agents update --id 42 -d '{"realtimeModelId":"xai:realtime:voice-agent-2"}'`,
|
|
1443
1461
|
`gr agents update --id 42 -d '{"realtimeModelId":"xai:realtime:voice-agent-3"}'`,
|
|
1444
1462
|
"gr agents update --id 42 --file agent.json"
|
|
1445
1463
|
]
|
|
@@ -3164,23 +3182,24 @@ Assistant / models (live on the DRAFT revision \u2014 publish to go live)
|
|
|
3164
3182
|
chatModelId (string) Text chat model (see \`gr ai-models chat\`)
|
|
3165
3183
|
chatModelConfig (object|null) Chat model overrides
|
|
3166
3184
|
realtimeModelId (string|null) Voice/realtime model (see \`gr ai-models realtime\`)
|
|
3167
|
-
create: omit \u2192 xai:realtime:voice-agent-
|
|
3168
|
-
voice xai:voice:cosmo; null = voice off
|
|
3185
|
+
create: omit \u2192 xai:realtime:voice-agent-3 with
|
|
3186
|
+
voice xai:voice:cosmo; null = voice off.
|
|
3187
|
+
routingMode "strict": omit \u2192 no voice (use
|
|
3188
|
+
custom:realtime:composable)
|
|
3169
3189
|
update: null = voice off
|
|
3170
3190
|
One-shot switch (keeps the stored voice and
|
|
3171
3191
|
call settings; resets only a voice the new
|
|
3172
3192
|
model cannot use):
|
|
3173
|
-
{"realtimeModelId":"xai:realtime:voice-agent-2"}
|
|
3174
|
-
Opt in to Grok Voice 3.0 (not the default; not yet
|
|
3175
|
-
cleared for routingMode "strict"; same xAI voices):
|
|
3176
3193
|
{"realtimeModelId":"xai:realtime:voice-agent-3"}
|
|
3194
|
+
Grok Voice 3 is not yet cleared for routingMode
|
|
3195
|
+
"strict". voice-agent-2 is deprecated.
|
|
3177
3196
|
On create, a native model id with no stored or
|
|
3178
3197
|
copied config gets tts=native + that
|
|
3179
3198
|
provider's fallback voice. A composable id
|
|
3180
3199
|
still needs its own config. On update,
|
|
3181
3200
|
omitting the config keeps the stored one.
|
|
3182
3201
|
Explicit config replaces it:
|
|
3183
|
-
{"realtimeModelId":"xai:realtime:voice-agent-
|
|
3202
|
+
{"realtimeModelId":"xai:realtime:voice-agent-3",
|
|
3184
3203
|
"realtimeModelConfig":{"ttsModel":"native",
|
|
3185
3204
|
"voiceModel":"xai:voice:ara"}}
|
|
3186
3205
|
realtimeModelConfig (object|null) Realtime config. Omit on update to keep the
|
|
@@ -8360,7 +8379,7 @@ var bundlesDomain = {
|
|
|
8360
8379
|
},
|
|
8361
8380
|
{
|
|
8362
8381
|
path: ["bundles", "draft", "set"],
|
|
8363
|
-
description: 'Replace draft items from {"items": [...]};
|
|
8382
|
+
description: 'Replace draft items from {"items": [...]}. Journey items require {"key", "kind":"journey", "journeyUuid"}; the server captures the source Journey. An optional "links": [{"label", "url"}] replaces the draft links. Use --expected-generation from draft get to protect edits.',
|
|
8364
8383
|
requiresWorkspace: true,
|
|
8365
8384
|
mutates: true,
|
|
8366
8385
|
args: [BUNDLE_ARG, GENERATION_ARG],
|
|
@@ -9735,9 +9754,9 @@ var REALTIME_AUDIO_USD_PER_MIN = {
|
|
|
9735
9754
|
"xai:realtime:voice-agent": 0.05,
|
|
9736
9755
|
// Grok Voice Think Fast 1
|
|
9737
9756
|
"xai:realtime:voice-agent-2": 0.08,
|
|
9738
|
-
// Grok Voice
|
|
9757
|
+
// Grok Voice 2 (pinned grok-voice-2.0)
|
|
9739
9758
|
"xai:realtime:voice-agent-3": 0.08
|
|
9740
|
-
// Grok Voice 3
|
|
9759
|
+
// Grok Voice 3 — same audio rate as 2.0
|
|
9741
9760
|
};
|
|
9742
9761
|
var DEFAULT_REALTIME_AUDIO_USD_PER_MIN = 0.08;
|
|
9743
9762
|
var EST_AUDIO_MIN_PER_RUN = 3;
|
|
@@ -9816,6 +9835,10 @@ function runToBatchRow(job, workflowId, run, error, batchLabel, pinnedRevisionId
|
|
|
9816
9835
|
...job.realtime ? { realtime_model_id: job.modelId } : {},
|
|
9817
9836
|
...batchLabel ? { batch_label: batchLabel } : {},
|
|
9818
9837
|
run_id: run?.id,
|
|
9838
|
+
lane: run?.lane ?? null,
|
|
9839
|
+
outcome: run?.outcome ?? null,
|
|
9840
|
+
assistant_chat_model_id: run?.assistantChatModelId ?? null,
|
|
9841
|
+
assistant_realtime_model_id: run?.assistantRealtimeModelId ?? null,
|
|
9819
9842
|
error,
|
|
9820
9843
|
failure_reason: run?.failureReason ?? null,
|
|
9821
9844
|
passed: run?.passed ?? null,
|
|
@@ -10110,7 +10133,15 @@ var SCENARIO_COLUMNS = [
|
|
|
10110
10133
|
COL.id(),
|
|
10111
10134
|
COL.name(),
|
|
10112
10135
|
{ header: "PERSONA", getValue: (item) => item.personaName ?? "" },
|
|
10113
|
-
{ header: "CHANNEL", getValue: (item) => item.channel ?? "" }
|
|
10136
|
+
{ header: "CHANNEL", getValue: (item) => item.channel ?? "" },
|
|
10137
|
+
{
|
|
10138
|
+
header: "SEED",
|
|
10139
|
+
getValue: (item) => {
|
|
10140
|
+
const turns = Array.isArray(item.seedTurns) ? item.seedTurns.length : 0;
|
|
10141
|
+
if (turns === 0) return "";
|
|
10142
|
+
return item.singleTurn ? `${turns} turns, single-turn` : `${turns} turns`;
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10114
10145
|
];
|
|
10115
10146
|
var RUN_COLUMNS = [
|
|
10116
10147
|
COL.id(),
|
|
@@ -10202,7 +10233,7 @@ var qualificationsDomain = {
|
|
|
10202
10233
|
},
|
|
10203
10234
|
{
|
|
10204
10235
|
path: ["qualifications", "scenarios", "create"],
|
|
10205
|
-
description:
|
|
10236
|
+
description: 'Create a scenario on a qualification (pass JSON via --data). Seed history: "seedTurns": [{"speaker": "member"|"agent", "content": "..."}]; "singleTurn": true grades only the Agent reply to the last seeded member turn',
|
|
10206
10237
|
mutates: true,
|
|
10207
10238
|
requiresWorkspace: true,
|
|
10208
10239
|
args: [{ name: "qualification-id", description: "Qualification ID", required: true }],
|
|
@@ -10217,7 +10248,7 @@ var qualificationsDomain = {
|
|
|
10217
10248
|
},
|
|
10218
10249
|
{
|
|
10219
10250
|
path: ["qualifications", "scenarios", "update"],
|
|
10220
|
-
description:
|
|
10251
|
+
description: 'Update a scenario (pass JSON via --data). "seedTurns": [] clears the seed history; "singleTurn" needs seed turns that end on a member turn',
|
|
10221
10252
|
mutates: true,
|
|
10222
10253
|
requiresWorkspace: true,
|
|
10223
10254
|
args: [{ name: "id", description: "Scenario ID", required: true }],
|
|
@@ -12911,7 +12942,7 @@ var COLUMNS15 = [
|
|
|
12911
12942
|
];
|
|
12912
12943
|
var aiModelsDomain = {
|
|
12913
12944
|
name: "ai-models",
|
|
12914
|
-
description: `List available AI models (chat, realtime/voice stacks, speaker voices). Use realtime ids as workflow/agent realtimeModelId; voice ids go in realtimeModelConfig.voiceModel. One-shot workflow voice: gr workflows update -d '{"realtimeModelId":"xai:realtime:voice-agent-
|
|
12945
|
+
description: `List available AI models (chat, realtime/voice stacks, speaker voices). Use realtime ids as workflow/agent realtimeModelId; voice ids go in realtimeModelConfig.voiceModel. One-shot workflow voice: gr workflows update -d '{"realtimeModelId":"xai:realtime:voice-agent-3"}' then publish.`,
|
|
12915
12946
|
commands: [
|
|
12916
12947
|
{
|
|
12917
12948
|
path: ["ai-models", "list"],
|
|
@@ -12933,7 +12964,7 @@ var aiModelsDomain = {
|
|
|
12933
12964
|
},
|
|
12934
12965
|
{
|
|
12935
12966
|
path: ["ai-models", "realtime"],
|
|
12936
|
-
description: "List realtime/voice stacks (use as realtimeModelId). e.g. xai:realtime:voice-agent-
|
|
12967
|
+
description: "List realtime/voice stacks (use as realtimeModelId). e.g. xai:realtime:voice-agent-3 = Grok Voice 3 (default). Deprecated models (xai:realtime:voice-agent-2) are not listed.",
|
|
12937
12968
|
requiresWorkspace: false,
|
|
12938
12969
|
handler: async ({ ctx }) => {
|
|
12939
12970
|
const result2 = await requireAuth(ctx).apiClient.getRealtimeModels();
|
|
@@ -14219,7 +14250,9 @@ var memberMemoriesDomain = {
|
|
|
14219
14250
|
{ name: "key", description: "Memory key", required: true },
|
|
14220
14251
|
{
|
|
14221
14252
|
name: "type",
|
|
14222
|
-
|
|
14253
|
+
// The API refuses preferences and semantic deletes (a Member cannot
|
|
14254
|
+
// be shown to own those AgentCore records), so they are not offered.
|
|
14255
|
+
description: "Memory type (basic, summaries, episodic)"
|
|
14223
14256
|
}
|
|
14224
14257
|
],
|
|
14225
14258
|
handler: async ({ ctx, workspace, args }) => {
|
|
@@ -20280,6 +20313,92 @@ async function streamSyncRun(response, verbose) {
|
|
|
20280
20313
|
console.log(JSON.stringify(lastRun, null, 2));
|
|
20281
20314
|
}
|
|
20282
20315
|
}
|
|
20316
|
+
var SYNC_RUN_OPTION_ARGS = [
|
|
20317
|
+
{ name: "dry-run", description: "Test sync without making changes", isFlag: true },
|
|
20318
|
+
{
|
|
20319
|
+
name: "full-resync",
|
|
20320
|
+
description: "Clear checkpoints and re-sync all records",
|
|
20321
|
+
isFlag: true
|
|
20322
|
+
},
|
|
20323
|
+
{ name: "quiet", description: "Only output final result JSON", isFlag: true },
|
|
20324
|
+
{ name: "entity-type", description: "Scope to entity type: member or record" },
|
|
20325
|
+
{
|
|
20326
|
+
name: "board-id",
|
|
20327
|
+
description: "Scope to a single board mapping (requires --entity-type)"
|
|
20328
|
+
},
|
|
20329
|
+
{
|
|
20330
|
+
name: "record-limit",
|
|
20331
|
+
description: "Cap the run to a preview sample (1..200). Requires --dry-run and --entity-type."
|
|
20332
|
+
}
|
|
20333
|
+
];
|
|
20334
|
+
var VALID_ENTITY_TYPES = ["member", "record"];
|
|
20335
|
+
function parseSyncRunOptions(args) {
|
|
20336
|
+
const dryRun = args["dry-run"] === true;
|
|
20337
|
+
const fullResync = args["full-resync"] === true;
|
|
20338
|
+
const quiet = args["quiet"] === true;
|
|
20339
|
+
const rawEntityType = args["entity-type"];
|
|
20340
|
+
let entityType;
|
|
20341
|
+
if (rawEntityType) {
|
|
20342
|
+
if (!VALID_ENTITY_TYPES.includes(rawEntityType)) {
|
|
20343
|
+
throw new CLIError(
|
|
20344
|
+
`Invalid --entity-type "${rawEntityType}". Allowed values: ${VALID_ENTITY_TYPES.join(", ")}`
|
|
20345
|
+
);
|
|
20346
|
+
}
|
|
20347
|
+
entityType = rawEntityType;
|
|
20348
|
+
}
|
|
20349
|
+
const boardId = args["board-id"];
|
|
20350
|
+
const rawRecordLimit = args["record-limit"];
|
|
20351
|
+
let recordLimit;
|
|
20352
|
+
if (rawRecordLimit !== void 0 && rawRecordLimit !== "") {
|
|
20353
|
+
const parsed = Number(rawRecordLimit);
|
|
20354
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 200) {
|
|
20355
|
+
throw new CLIError(
|
|
20356
|
+
`Invalid --record-limit "${rawRecordLimit}". Must be an integer between 1 and 200.`
|
|
20357
|
+
);
|
|
20358
|
+
}
|
|
20359
|
+
if (!dryRun) {
|
|
20360
|
+
throw new CLIError("--record-limit requires --dry-run: capped runs are preview-only.");
|
|
20361
|
+
}
|
|
20362
|
+
if (entityType === void 0) {
|
|
20363
|
+
throw new CLIError(
|
|
20364
|
+
"--record-limit requires --entity-type: capped previews must target a single entity type."
|
|
20365
|
+
);
|
|
20366
|
+
}
|
|
20367
|
+
recordLimit = parsed;
|
|
20368
|
+
}
|
|
20369
|
+
if (fullResync && (dryRun || recordLimit !== void 0)) {
|
|
20370
|
+
throw new CLIError(
|
|
20371
|
+
"--full-resync is incompatible with --dry-run / --record-limit: checkpoint reset must happen on a non-preview run."
|
|
20372
|
+
);
|
|
20373
|
+
}
|
|
20374
|
+
return { dryRun, fullResync, quiet, entityType, boardId, recordLimit };
|
|
20375
|
+
}
|
|
20376
|
+
async function runSyncAndStream(ctx, workspace, connectionId, options) {
|
|
20377
|
+
const { dryRun, fullResync, quiet, entityType, boardId, recordLimit } = options;
|
|
20378
|
+
if (!quiet) {
|
|
20379
|
+
const flags = [
|
|
20380
|
+
dryRun && "(dry run)",
|
|
20381
|
+
fullResync && "(full re-sync)",
|
|
20382
|
+
entityType && `(${entityType} only)`,
|
|
20383
|
+
boardId && `(board ${boardId})`,
|
|
20384
|
+
recordLimit !== void 0 && `(limit ${recordLimit})`
|
|
20385
|
+
].filter(Boolean).join(" ");
|
|
20386
|
+
console.error(`Starting sync for connection ${connectionId}${flags ? ` ${flags}` : ""}...`);
|
|
20387
|
+
}
|
|
20388
|
+
const response = await requireAuth(ctx).apiClient.startSyncRun(workspace, connectionId, {
|
|
20389
|
+
dryRun,
|
|
20390
|
+
resetCheckpoints: fullResync,
|
|
20391
|
+
entityType,
|
|
20392
|
+
boardId,
|
|
20393
|
+
recordLimit
|
|
20394
|
+
});
|
|
20395
|
+
if (!response.ok) {
|
|
20396
|
+
const text = await response.text();
|
|
20397
|
+
console.error(`Sync failed: ${response.status} ${text}`);
|
|
20398
|
+
process.exit(1);
|
|
20399
|
+
}
|
|
20400
|
+
await streamSyncRun(response, !quiet);
|
|
20401
|
+
}
|
|
20283
20402
|
var syncDomain = {
|
|
20284
20403
|
name: "sync",
|
|
20285
20404
|
description: "Run and monitor connection syncs",
|
|
@@ -20289,22 +20408,7 @@ var syncDomain = {
|
|
|
20289
20408
|
description: "Start a sync run and stream progress (SSE)",
|
|
20290
20409
|
args: [
|
|
20291
20410
|
{ name: "connection-id", description: "Connection ID", required: true },
|
|
20292
|
-
|
|
20293
|
-
{
|
|
20294
|
-
name: "full-resync",
|
|
20295
|
-
description: "Clear checkpoints and re-sync all records",
|
|
20296
|
-
isFlag: true
|
|
20297
|
-
},
|
|
20298
|
-
{ name: "quiet", description: "Only output final result JSON", isFlag: true },
|
|
20299
|
-
{ name: "entity-type", description: "Scope to entity type: member or record" },
|
|
20300
|
-
{
|
|
20301
|
-
name: "board-id",
|
|
20302
|
-
description: "Scope to a single board mapping (requires --entity-type)"
|
|
20303
|
-
},
|
|
20304
|
-
{
|
|
20305
|
-
name: "record-limit",
|
|
20306
|
-
description: "Cap the run to a preview sample (1..200). Requires --dry-run and --entity-type."
|
|
20307
|
-
}
|
|
20411
|
+
...SYNC_RUN_OPTION_ARGS
|
|
20308
20412
|
],
|
|
20309
20413
|
examples: [
|
|
20310
20414
|
"sync run --connection-id 6",
|
|
@@ -20318,76 +20422,7 @@ var syncDomain = {
|
|
|
20318
20422
|
mutates: true,
|
|
20319
20423
|
handler: async ({ ctx, args, workspace }) => {
|
|
20320
20424
|
const connectionId = requireNumber(args, "connection-id");
|
|
20321
|
-
|
|
20322
|
-
const fullResync = args["full-resync"] === true;
|
|
20323
|
-
const quiet = args["quiet"] === true;
|
|
20324
|
-
const VALID_ENTITY_TYPES = ["member", "record"];
|
|
20325
|
-
const rawEntityType = args["entity-type"];
|
|
20326
|
-
let entityType;
|
|
20327
|
-
if (rawEntityType) {
|
|
20328
|
-
if (!VALID_ENTITY_TYPES.includes(rawEntityType)) {
|
|
20329
|
-
throw new CLIError(
|
|
20330
|
-
`Invalid --entity-type "${rawEntityType}". Allowed values: ${VALID_ENTITY_TYPES.join(", ")}`
|
|
20331
|
-
);
|
|
20332
|
-
}
|
|
20333
|
-
entityType = rawEntityType;
|
|
20334
|
-
}
|
|
20335
|
-
const boardId = args["board-id"];
|
|
20336
|
-
const rawRecordLimit = args["record-limit"];
|
|
20337
|
-
let recordLimit;
|
|
20338
|
-
if (rawRecordLimit !== void 0 && rawRecordLimit !== "") {
|
|
20339
|
-
const parsed = Number(rawRecordLimit);
|
|
20340
|
-
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 200) {
|
|
20341
|
-
throw new CLIError(
|
|
20342
|
-
`Invalid --record-limit "${rawRecordLimit}". Must be an integer between 1 and 200.`
|
|
20343
|
-
);
|
|
20344
|
-
}
|
|
20345
|
-
if (!dryRun) {
|
|
20346
|
-
throw new CLIError(
|
|
20347
|
-
"--record-limit requires --dry-run: capped runs are preview-only."
|
|
20348
|
-
);
|
|
20349
|
-
}
|
|
20350
|
-
if (entityType === void 0) {
|
|
20351
|
-
throw new CLIError(
|
|
20352
|
-
"--record-limit requires --entity-type: capped previews must target a single entity type."
|
|
20353
|
-
);
|
|
20354
|
-
}
|
|
20355
|
-
recordLimit = parsed;
|
|
20356
|
-
}
|
|
20357
|
-
if (fullResync && (dryRun || recordLimit !== void 0)) {
|
|
20358
|
-
throw new CLIError(
|
|
20359
|
-
"--full-resync is incompatible with --dry-run / --record-limit: checkpoint reset must happen on a non-preview run."
|
|
20360
|
-
);
|
|
20361
|
-
}
|
|
20362
|
-
if (!quiet) {
|
|
20363
|
-
const flags = [
|
|
20364
|
-
dryRun && "(dry run)",
|
|
20365
|
-
fullResync && "(full re-sync)",
|
|
20366
|
-
entityType && `(${entityType} only)`,
|
|
20367
|
-
boardId && `(board ${boardId})`,
|
|
20368
|
-
recordLimit !== void 0 && `(limit ${recordLimit})`
|
|
20369
|
-
].filter(Boolean).join(" ");
|
|
20370
|
-
console.error(
|
|
20371
|
-
`Starting sync for connection ${connectionId}${flags ? ` ${flags}` : ""}...`
|
|
20372
|
-
);
|
|
20373
|
-
}
|
|
20374
|
-
const response = await requireAuth(ctx).apiClient.startSyncRun(
|
|
20375
|
-
workspace,
|
|
20376
|
-
connectionId,
|
|
20377
|
-
{
|
|
20378
|
-
dryRun,
|
|
20379
|
-
resetCheckpoints: fullResync,
|
|
20380
|
-
entityType,
|
|
20381
|
-
boardId,
|
|
20382
|
-
recordLimit
|
|
20383
|
-
}
|
|
20384
|
-
);
|
|
20385
|
-
if (!response.ok) {
|
|
20386
|
-
const text = await response.text();
|
|
20387
|
-
console.error(`Sync failed: ${response.status} ${text}`);
|
|
20388
|
-
process.exit(1);
|
|
20389
|
-
}
|
|
20390
|
-
await streamSyncRun(response, !quiet);
|
|
20425
|
+
await runSyncAndStream(ctx, workspace, connectionId, parseSyncRunOptions(args));
|
|
20391
20426
|
}
|
|
20392
20427
|
},
|
|
20393
20428
|
{
|
|
@@ -21147,71 +21182,6 @@ var ENCOUNTER_RUN_COLUMNS = [
|
|
|
21147
21182
|
getValue: (item) => summarizeReasons(item.attribution?.collections, "errorReasonCounts")
|
|
21148
21183
|
}
|
|
21149
21184
|
];
|
|
21150
|
-
var ONBOARDING_START_COLUMNS = [
|
|
21151
|
-
{ header: "MODE", getValue: (item) => item.mode ?? "" },
|
|
21152
|
-
{ header: "WORKFLOW ID", getValue: (item) => item.workflowId ?? "" },
|
|
21153
|
-
{ header: "RUN ID", getValue: (item) => item.runId ?? "" }
|
|
21154
|
-
];
|
|
21155
|
-
var ONBOARDING_PAIR_COLUMNS = [
|
|
21156
|
-
{ header: "DEPARTMENT", getValue: (item) => String(item.departmentId ?? "") },
|
|
21157
|
-
{ header: "PATIENT STATUS", getValue: (item) => item.patientStatus ?? "" },
|
|
21158
|
-
{ header: "STATUS", getValue: (item) => item.status ?? "" },
|
|
21159
|
-
{ header: "STOP REASON", getValue: (item) => item.stopReason ?? "" },
|
|
21160
|
-
{ header: "GEN", getValue: (item) => String(item.generation ?? "") },
|
|
21161
|
-
{ header: "NEXT OFFSET", getValue: (item) => String(item.nextOffset ?? "") },
|
|
21162
|
-
{ header: "PAGES (RUN)", getValue: (item) => String(item.pagesDone ?? 0) },
|
|
21163
|
-
{ header: "~FETCHED", getValue: (item) => String(item.totals?.fetched ?? 0) },
|
|
21164
|
-
{ header: "~APPLIED", getValue: (item) => String(item.totals?.applied ?? 0) },
|
|
21165
|
-
{ header: "~SKIPPED", getValue: (item) => String(item.totals?.skipped ?? 0) },
|
|
21166
|
-
{ header: "~FAILED", getValue: (item) => String(item.totals?.failed ?? 0) },
|
|
21167
|
-
{ header: "RUN ID", getValue: (item) => item.runId ?? "" }
|
|
21168
|
-
];
|
|
21169
|
-
var RESUMABLE_PAIR_STATUSES = /* @__PURE__ */ new Set([
|
|
21170
|
-
"failed",
|
|
21171
|
-
"aborted",
|
|
21172
|
-
"truncated",
|
|
21173
|
-
"pending",
|
|
21174
|
-
"running",
|
|
21175
|
-
"waiting"
|
|
21176
|
-
]);
|
|
21177
|
-
function onboardingStatusLines(status, connectionId) {
|
|
21178
|
-
const lines = [];
|
|
21179
|
-
const execution = status.execution;
|
|
21180
|
-
if (execution) {
|
|
21181
|
-
const failure = execution.failureCode ? ` (failure: ${execution.failureCode})` : "";
|
|
21182
|
-
lines.push(
|
|
21183
|
-
`Temporal execution: ${execution.workflowId} run ${execution.runId ?? "-"} \u2014 ${execution.status}${failure}`
|
|
21184
|
-
);
|
|
21185
|
-
} else {
|
|
21186
|
-
lines.push("Temporal execution: none recorded");
|
|
21187
|
-
}
|
|
21188
|
-
if (status.waitingUntil) {
|
|
21189
|
-
lines.push(
|
|
21190
|
-
`Waiting for the operator window (21:00\u201308:00 America/New_York) until ${status.waitingUntil}`
|
|
21191
|
-
);
|
|
21192
|
-
}
|
|
21193
|
-
if (status.preview) {
|
|
21194
|
-
const previewPairs = status.preview.pairs ?? [];
|
|
21195
|
-
const admitted = previewPairs.reduce((n, p) => n + (p.totals?.admitted ?? 0), 0);
|
|
21196
|
-
const notAdmitted = previewPairs.reduce(
|
|
21197
|
-
(n, p) => n + (p.totals?.notAdmitted ?? 0),
|
|
21198
|
-
0
|
|
21199
|
-
);
|
|
21200
|
-
lines.push(
|
|
21201
|
-
`Latest preview: ${previewPairs.length} pair(s), ~${admitted} admission-eligible (incl. already-linked), ~${notAdmitted} not admitted (read-only)`
|
|
21202
|
-
);
|
|
21203
|
-
}
|
|
21204
|
-
lines.push("Counts are approximate.");
|
|
21205
|
-
const unfinished = (status.pairs ?? []).some(
|
|
21206
|
-
(p) => p.inCurrentCohort && RESUMABLE_PAIR_STATUSES.has(p.status) && p.runId
|
|
21207
|
-
);
|
|
21208
|
-
if (unfinished && execution?.status !== "running") {
|
|
21209
|
-
lines.push(
|
|
21210
|
-
`Unfinished pairs continue only on an explicit resume: gr fhir-connections onboarding-import start --id ${connectionId} --resume --allow-write`
|
|
21211
|
-
);
|
|
21212
|
-
}
|
|
21213
|
-
return lines;
|
|
21214
|
-
}
|
|
21215
21185
|
var fhirConnectionsDomain = {
|
|
21216
21186
|
name: "fhir-connections",
|
|
21217
21187
|
description: "Manage FHIR connections",
|
|
@@ -21269,77 +21239,6 @@ var fhirConnectionsDomain = {
|
|
|
21269
21239
|
);
|
|
21270
21240
|
outputData(runs, ctx, ENCOUNTER_RUN_COLUMNS);
|
|
21271
21241
|
}
|
|
21272
|
-
},
|
|
21273
|
-
{
|
|
21274
|
-
// athenahealth onboarding import (PR-C): one explicit, audited
|
|
21275
|
-
// operator execution per connection, at most 50 pages per pair per
|
|
21276
|
-
// run. Thin over the SDK; the server decides everything.
|
|
21277
|
-
path: ["fhir-connections", "onboarding-import", "start"],
|
|
21278
|
-
description: "Start an athenahealth onboarding import (or --resume / --override / --dry-run preview)",
|
|
21279
|
-
requiresWorkspace: true,
|
|
21280
|
-
mutates: true,
|
|
21281
|
-
args: [
|
|
21282
|
-
{ name: "id", description: "FHIR connection ID", required: true },
|
|
21283
|
-
{
|
|
21284
|
-
name: "dry-run",
|
|
21285
|
-
description: "Preview: read and classify admission only, write no Members",
|
|
21286
|
-
isFlag: true
|
|
21287
|
-
},
|
|
21288
|
-
{
|
|
21289
|
-
name: "resume",
|
|
21290
|
-
description: "Continue unfinished (failed, truncated, aborted) pairs at their stored frontier",
|
|
21291
|
-
isFlag: true
|
|
21292
|
-
},
|
|
21293
|
-
{
|
|
21294
|
-
name: "override",
|
|
21295
|
-
description: "Rescan completed pairs from offset 0 under a new generation",
|
|
21296
|
-
isFlag: true
|
|
21297
|
-
}
|
|
21298
|
-
],
|
|
21299
|
-
examples: [
|
|
21300
|
-
"fhir-connections onboarding-import start --id 12 --dry-run --allow-write",
|
|
21301
|
-
"fhir-connections onboarding-import start --id 12 --allow-write",
|
|
21302
|
-
"fhir-connections onboarding-import start --id 12 --resume --allow-write"
|
|
21303
|
-
],
|
|
21304
|
-
handler: async ({ ctx, workspace, args }) => {
|
|
21305
|
-
const connectionId = requireNumber(args, "id");
|
|
21306
|
-
const started = await requireAuth(ctx).apiClient.fhirStartOnboardingImport(
|
|
21307
|
-
workspace,
|
|
21308
|
-
connectionId,
|
|
21309
|
-
{
|
|
21310
|
-
dryRun: args["dry-run"] === true,
|
|
21311
|
-
resume: args["resume"] === true,
|
|
21312
|
-
override: args["override"] === true
|
|
21313
|
-
}
|
|
21314
|
-
);
|
|
21315
|
-
outputSingle(started, ctx, ONBOARDING_START_COLUMNS);
|
|
21316
|
-
hint(ctx, [
|
|
21317
|
-
`Started. Follow progress with: gr fhir-connections onboarding-import status --id ${connectionId}`
|
|
21318
|
-
]);
|
|
21319
|
-
}
|
|
21320
|
-
},
|
|
21321
|
-
{
|
|
21322
|
-
path: ["fhir-connections", "onboarding-import", "status"],
|
|
21323
|
-
description: "Show athenahealth onboarding-import progress and its Temporal execution (read-only)",
|
|
21324
|
-
requiresWorkspace: true,
|
|
21325
|
-
args: [{ name: "id", description: "FHIR connection ID", required: true }],
|
|
21326
|
-
examples: [
|
|
21327
|
-
"fhir-connections onboarding-import status --id 12",
|
|
21328
|
-
"fhir-connections onboarding-import status --id 12 --output-format json"
|
|
21329
|
-
],
|
|
21330
|
-
handler: async ({ ctx, workspace, args }) => {
|
|
21331
|
-
const connectionId = requireNumber(args, "id");
|
|
21332
|
-
const status = await requireAuth(ctx).apiClient.fhirGetOnboardingImportStatus(
|
|
21333
|
-
workspace,
|
|
21334
|
-
connectionId
|
|
21335
|
-
);
|
|
21336
|
-
if (ctx.jq || (ctx.outputFormat ?? "table") !== "table") {
|
|
21337
|
-
outputSingle(status, ctx);
|
|
21338
|
-
return;
|
|
21339
|
-
}
|
|
21340
|
-
outputData(status.pairs, ctx, ONBOARDING_PAIR_COLUMNS);
|
|
21341
|
-
hint(ctx, onboardingStatusLines(status, connectionId));
|
|
21342
|
-
}
|
|
21343
21242
|
}
|
|
21344
21243
|
]
|
|
21345
21244
|
};
|
|
@@ -21664,7 +21563,312 @@ var documoFaxDomain = {
|
|
|
21664
21563
|
]
|
|
21665
21564
|
};
|
|
21666
21565
|
|
|
21566
|
+
// src/domains/integrations/connection-commands.ts
|
|
21567
|
+
var POLL_INTERVAL_MIN_MINUTES = 15;
|
|
21568
|
+
var POLL_INTERVAL_MAX_MINUTES = 1440;
|
|
21569
|
+
function connectionIdArg(target) {
|
|
21570
|
+
return {
|
|
21571
|
+
name: "connection-id",
|
|
21572
|
+
description: `Connection ID (default: the workspace's ${target.label} connection)`
|
|
21573
|
+
};
|
|
21574
|
+
}
|
|
21575
|
+
async function resolveConnectionId(ctx, workspace, target, args) {
|
|
21576
|
+
const explicit = optionalNumber(args, "connection-id");
|
|
21577
|
+
if (explicit !== void 0) return explicit;
|
|
21578
|
+
const connections = await requireAuth(ctx).apiClient.listAppConnections(workspace);
|
|
21579
|
+
const matches = connections.filter((c) => c.connectionType === target.connectionType);
|
|
21580
|
+
if (matches.length === 0) {
|
|
21581
|
+
throw new CLIError(
|
|
21582
|
+
`No ${target.label} connection in this workspace. Run: gr ${target.command} install`
|
|
21583
|
+
);
|
|
21584
|
+
}
|
|
21585
|
+
if (matches.length > 1) {
|
|
21586
|
+
const ids = matches.map((c) => c.id).join(", ");
|
|
21587
|
+
throw new CLIError(
|
|
21588
|
+
`This workspace has ${matches.length} ${target.label} connections (${ids}). Pass --connection-id.`
|
|
21589
|
+
);
|
|
21590
|
+
}
|
|
21591
|
+
return matches[0].id;
|
|
21592
|
+
}
|
|
21593
|
+
function parsePollInterval(raw) {
|
|
21594
|
+
const minutes = Number(raw);
|
|
21595
|
+
if (!Number.isInteger(minutes) || minutes < POLL_INTERVAL_MIN_MINUTES || minutes > POLL_INTERVAL_MAX_MINUTES) {
|
|
21596
|
+
throw new CLIError(
|
|
21597
|
+
`Invalid --poll-interval "${String(raw)}". Must be a whole number of minutes between ${POLL_INTERVAL_MIN_MINUTES} and ${POLL_INTERVAL_MAX_MINUTES}.`
|
|
21598
|
+
);
|
|
21599
|
+
}
|
|
21600
|
+
return minutes;
|
|
21601
|
+
}
|
|
21602
|
+
function connectionCommands(target) {
|
|
21603
|
+
const c = target.command;
|
|
21604
|
+
const connectionId = connectionIdArg(target);
|
|
21605
|
+
return [
|
|
21606
|
+
{
|
|
21607
|
+
path: [c, "sync-config", "get"],
|
|
21608
|
+
description: `Get the ${target.label} sync configuration`,
|
|
21609
|
+
requiresWorkspace: true,
|
|
21610
|
+
args: [connectionId],
|
|
21611
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21612
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21613
|
+
const result2 = await requireAuth(ctx).apiClient.getConnectionSyncConfig(workspace, id);
|
|
21614
|
+
outputSingle(result2, ctx);
|
|
21615
|
+
}
|
|
21616
|
+
},
|
|
21617
|
+
{
|
|
21618
|
+
path: [c, "sync-config", "set"],
|
|
21619
|
+
// `sync-config get -o json | … | sync-config set` pipes the whole
|
|
21620
|
+
// configuration; with --poll-interval alone there is no body to wait for.
|
|
21621
|
+
pipesJsonInput: (args) => args["poll-interval"] === void 0,
|
|
21622
|
+
description: `Replace the ${target.label} sync configuration (--data), or change one setting of the saved configuration (--poll-interval)`,
|
|
21623
|
+
mutates: true,
|
|
21624
|
+
requiresWorkspace: true,
|
|
21625
|
+
args: [
|
|
21626
|
+
connectionId,
|
|
21627
|
+
{
|
|
21628
|
+
name: "poll-interval",
|
|
21629
|
+
description: `Inbound poll cadence in minutes (${POLL_INTERVAL_MIN_MINUTES}..${POLL_INTERVAL_MAX_MINUTES}). Without --data, updates the saved configuration.`
|
|
21630
|
+
}
|
|
21631
|
+
],
|
|
21632
|
+
examples: [
|
|
21633
|
+
`gr ${c} sync-config get -w <ws> -o json > sync-config.json`,
|
|
21634
|
+
`gr ${c} sync-config set -w <ws> --allow-write --file sync-config.json`,
|
|
21635
|
+
`gr ${c} sync-config set -w <ws> --allow-write --poll-interval 60`
|
|
21636
|
+
],
|
|
21637
|
+
handler: async ({ ctx, workspace, args, data }) => {
|
|
21638
|
+
const rawInterval = args["poll-interval"];
|
|
21639
|
+
const hasInterval = rawInterval !== void 0 && rawInterval !== "";
|
|
21640
|
+
if (!data && !hasInterval) {
|
|
21641
|
+
throw new CLIError(
|
|
21642
|
+
"Pass the configuration (--data, --file, or stdin) or --poll-interval"
|
|
21643
|
+
);
|
|
21644
|
+
}
|
|
21645
|
+
if (data !== void 0 && (typeof data !== "object" || data === null || Array.isArray(data) || Object.keys(data).length === 0)) {
|
|
21646
|
+
throw new CLIError(
|
|
21647
|
+
"The configuration must be a non-empty JSON object (start from `sync-config get -o json`)"
|
|
21648
|
+
);
|
|
21649
|
+
}
|
|
21650
|
+
const minutes = hasInterval ? parsePollInterval(rawInterval) : void 0;
|
|
21651
|
+
const api = requireAuth(ctx).apiClient;
|
|
21652
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21653
|
+
const base = data ?? await api.getConnectionSyncConfig(workspace, id);
|
|
21654
|
+
const config = minutes === void 0 ? base : { ...base, inboundPollIntervalMinutes: minutes };
|
|
21655
|
+
const result2 = await api.updateConnectionSyncConfig(workspace, id, config);
|
|
21656
|
+
outputSingle(result2, ctx);
|
|
21657
|
+
}
|
|
21658
|
+
},
|
|
21659
|
+
{
|
|
21660
|
+
path: [c, "sync", "capabilities"],
|
|
21661
|
+
description: `What the ${target.label} sync engine supports (entities, directions, modes)`,
|
|
21662
|
+
requiresWorkspace: true,
|
|
21663
|
+
args: [connectionId],
|
|
21664
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21665
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21666
|
+
const result2 = await requireAuth(ctx).apiClient.getConnectionSyncCapabilities(
|
|
21667
|
+
workspace,
|
|
21668
|
+
id
|
|
21669
|
+
);
|
|
21670
|
+
outputSingle(result2, ctx);
|
|
21671
|
+
}
|
|
21672
|
+
},
|
|
21673
|
+
{
|
|
21674
|
+
path: [c, "sync", "run"],
|
|
21675
|
+
description: `Start a ${target.label} sync run and stream its progress`,
|
|
21676
|
+
mutates: true,
|
|
21677
|
+
requiresWorkspace: true,
|
|
21678
|
+
args: [connectionId, ...SYNC_RUN_OPTION_ARGS],
|
|
21679
|
+
examples: [
|
|
21680
|
+
`gr ${c} sync run -w <ws> --allow-write --dry-run --entity-type member --record-limit 5`,
|
|
21681
|
+
`gr ${c} sync run -w <ws> --allow-write`,
|
|
21682
|
+
`gr ${c} sync run -w <ws> --allow-write --full-resync --quiet`
|
|
21683
|
+
],
|
|
21684
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21685
|
+
const options = parseSyncRunOptions(args);
|
|
21686
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21687
|
+
await runSyncAndStream(ctx, workspace, id, options);
|
|
21688
|
+
}
|
|
21689
|
+
},
|
|
21690
|
+
{
|
|
21691
|
+
path: [c, "sync", "runs"],
|
|
21692
|
+
description: `List recent ${target.label} sync runs`,
|
|
21693
|
+
requiresWorkspace: true,
|
|
21694
|
+
args: [connectionId, { name: "limit", description: "Max runs to return (default 20)" }],
|
|
21695
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21696
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21697
|
+
const runs = await requireAuth(ctx).apiClient.getSyncRuns(
|
|
21698
|
+
workspace,
|
|
21699
|
+
id,
|
|
21700
|
+
optionalNumber(args, "limit") ?? 20
|
|
21701
|
+
);
|
|
21702
|
+
outputData(runs, ctx, RUN_COLUMNS2);
|
|
21703
|
+
}
|
|
21704
|
+
},
|
|
21705
|
+
{
|
|
21706
|
+
path: [c, "sync", "run-items"],
|
|
21707
|
+
description: `List the items of one ${target.label} sync run`,
|
|
21708
|
+
requiresWorkspace: true,
|
|
21709
|
+
args: [
|
|
21710
|
+
connectionId,
|
|
21711
|
+
{ name: "run-id", description: "Run ID (from sync runs)", required: true },
|
|
21712
|
+
{ name: "limit", description: "Max items to return (default 500)" }
|
|
21713
|
+
],
|
|
21714
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21715
|
+
const runId = requireString(args, "run-id");
|
|
21716
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21717
|
+
const items = await requireAuth(ctx).apiClient.getSyncRunItems(
|
|
21718
|
+
workspace,
|
|
21719
|
+
id,
|
|
21720
|
+
runId,
|
|
21721
|
+
optionalNumber(args, "limit") ?? 500
|
|
21722
|
+
);
|
|
21723
|
+
outputData(items, ctx, ITEM_COLUMNS2);
|
|
21724
|
+
}
|
|
21725
|
+
},
|
|
21726
|
+
{
|
|
21727
|
+
path: [c, "sync", "checkpoint"],
|
|
21728
|
+
description: `Show the ${target.label} sync checkpoint (where the next run resumes)`,
|
|
21729
|
+
requiresWorkspace: true,
|
|
21730
|
+
args: [
|
|
21731
|
+
connectionId,
|
|
21732
|
+
{ name: "direction", description: "'inbound' (default) or 'outbound'" },
|
|
21733
|
+
{ name: "sync-key", description: "Sync key (default 'default')" }
|
|
21734
|
+
],
|
|
21735
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21736
|
+
const direction = args["direction"] ?? "inbound";
|
|
21737
|
+
if (direction !== "inbound" && direction !== "outbound") {
|
|
21738
|
+
throw new CLIError(
|
|
21739
|
+
`--direction must be 'inbound' or 'outbound', got '${direction}'`
|
|
21740
|
+
);
|
|
21741
|
+
}
|
|
21742
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21743
|
+
const result2 = await requireAuth(ctx).apiClient.getConnectionSyncCheckpoint(
|
|
21744
|
+
workspace,
|
|
21745
|
+
id,
|
|
21746
|
+
direction,
|
|
21747
|
+
args["sync-key"] ?? "default"
|
|
21748
|
+
);
|
|
21749
|
+
outputSingle(result2, ctx);
|
|
21750
|
+
}
|
|
21751
|
+
},
|
|
21752
|
+
{
|
|
21753
|
+
path: [c, "sync", "member-summary"],
|
|
21754
|
+
description: `Count members by ${target.label} sync state (linked, failed, never synced)`,
|
|
21755
|
+
requiresWorkspace: true,
|
|
21756
|
+
args: [connectionId],
|
|
21757
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21758
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21759
|
+
const result2 = await requireAuth(ctx).apiClient.getMemberSyncSummary(workspace, id);
|
|
21760
|
+
outputSingle(result2, ctx);
|
|
21761
|
+
}
|
|
21762
|
+
},
|
|
21763
|
+
{
|
|
21764
|
+
path: [c, "field-keys"],
|
|
21765
|
+
description: `List the Member field keys the ${target.label} connection holds values for`,
|
|
21766
|
+
requiresWorkspace: true,
|
|
21767
|
+
args: [connectionId],
|
|
21768
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21769
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21770
|
+
const result2 = await requireAuth(ctx).apiClient.listConnectionMemberFieldKeys(
|
|
21771
|
+
workspace,
|
|
21772
|
+
id
|
|
21773
|
+
);
|
|
21774
|
+
outputData(result2.keys, ctx);
|
|
21775
|
+
}
|
|
21776
|
+
},
|
|
21777
|
+
{
|
|
21778
|
+
path: [c, "reconciliation", "relink"],
|
|
21779
|
+
description: `Let sync re-link a member you unlinked from ${target.label} (clears the manual-unlink exclusion). Idempotent: cleared=false when there was none.`,
|
|
21780
|
+
mutates: true,
|
|
21781
|
+
requiresWorkspace: true,
|
|
21782
|
+
args: [connectionId, { name: "member-id", description: "Member ID", required: true }],
|
|
21783
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21784
|
+
const memberId = requireNumber(args, "member-id");
|
|
21785
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21786
|
+
const result2 = await requireAuth(ctx).apiClient.clearConnectionMemberExclusion(
|
|
21787
|
+
workspace,
|
|
21788
|
+
id,
|
|
21789
|
+
memberId
|
|
21790
|
+
);
|
|
21791
|
+
outputSingle(result2, ctx);
|
|
21792
|
+
}
|
|
21793
|
+
},
|
|
21794
|
+
{
|
|
21795
|
+
path: [c, "reconciliation", "link-by-identity"],
|
|
21796
|
+
description: `Start the background run that links unlinked members to their ${target.label} records by identity, then syncs them. Prints the run's workflowId. Refused (400) when the connector has no identity resolver, and (409) while the connection is disabled or a run is already in flight.`,
|
|
21797
|
+
mutates: true,
|
|
21798
|
+
requiresWorkspace: true,
|
|
21799
|
+
args: [connectionId],
|
|
21800
|
+
examples: [
|
|
21801
|
+
`gr ${c} reconciliation link-by-identity -w <ws> --allow-write`,
|
|
21802
|
+
`gr ${c} reconciliation linked -w <ws> # check the new links afterwards`
|
|
21803
|
+
],
|
|
21804
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
21805
|
+
const id = await resolveConnectionId(ctx, workspace, target, args);
|
|
21806
|
+
const result2 = await requireAuth(ctx).apiClient.linkUnlinkedMembersByIdentity(
|
|
21807
|
+
workspace,
|
|
21808
|
+
id
|
|
21809
|
+
);
|
|
21810
|
+
outputSingle(result2, ctx);
|
|
21811
|
+
}
|
|
21812
|
+
}
|
|
21813
|
+
];
|
|
21814
|
+
}
|
|
21815
|
+
|
|
21667
21816
|
// src/domains/integrations/hubspot.ts
|
|
21817
|
+
var HUBSPOT = {
|
|
21818
|
+
command: "hubspot",
|
|
21819
|
+
label: "HubSpot",
|
|
21820
|
+
connectionType: "hubspot_connection"
|
|
21821
|
+
};
|
|
21822
|
+
var OBJECT_TYPES = ["contacts", "companies", "deals"];
|
|
21823
|
+
var SEARCHABLE_OBJECT_TYPES = ["contacts", "companies"];
|
|
21824
|
+
var SEARCH_COLUMNS = [
|
|
21825
|
+
{ header: "ID", getValue: (item) => item.id ?? "" },
|
|
21826
|
+
{ header: "TYPE", getValue: (item) => item.objectType ?? "" },
|
|
21827
|
+
{ header: "NAME", getValue: (item) => item.name ?? "" },
|
|
21828
|
+
{ header: "EMAIL", getValue: (item) => item.email ?? "" },
|
|
21829
|
+
{
|
|
21830
|
+
header: "MEMBER",
|
|
21831
|
+
getValue: (item) => item.existingMember ? `${item.existingMember.memberId} (${item.existingMember.matchType})` : ""
|
|
21832
|
+
}
|
|
21833
|
+
];
|
|
21834
|
+
var MATCH_COLUMNS2 = [
|
|
21835
|
+
{ header: "MEMBER", getValue: (item) => String(item.memberId ?? "") },
|
|
21836
|
+
{ header: "RECORD", getValue: (item) => item.hubspotRecordId ?? "" },
|
|
21837
|
+
{ header: "MATCH", getValue: (item) => item.matchType ?? "" },
|
|
21838
|
+
{ header: "OBJECT", getValue: (item) => item.objectType ?? "" }
|
|
21839
|
+
];
|
|
21840
|
+
var LINKED_COLUMNS2 = [
|
|
21841
|
+
{ header: "MEMBER", getValue: (item) => String(item.memberId ?? "") },
|
|
21842
|
+
{ header: "RECORD", getValue: (item) => item.hubspotRecordId ?? "" },
|
|
21843
|
+
{ header: "NAME", getValue: (item) => item.memberName ?? "" },
|
|
21844
|
+
{ header: "LAST SYNC", getValue: (item) => item.lastSyncStatus ?? "" }
|
|
21845
|
+
];
|
|
21846
|
+
var IMPORT_COLUMNS = [
|
|
21847
|
+
{ header: "HUBSPOT ID", getValue: (item) => item.hubspotId ?? "" },
|
|
21848
|
+
{ header: "MEMBER", getValue: (item) => String(item.memberId ?? "") },
|
|
21849
|
+
{ header: "OK", getValue: (item) => item.success ? "yes" : "no" },
|
|
21850
|
+
{ header: "ERROR", getValue: (item) => item.error ?? "" }
|
|
21851
|
+
];
|
|
21852
|
+
function importRecordsFrom(data) {
|
|
21853
|
+
const body = data;
|
|
21854
|
+
const rows = Array.isArray(body) ? body : Array.isArray(body?.records) ? body.records : Array.isArray(body?.results) ? body.results : void 0;
|
|
21855
|
+
if (!rows) {
|
|
21856
|
+
throw new CLIError(
|
|
21857
|
+
'JSON input must be {"records":[...]}, a `gr hubspot search -o json` response, or an array'
|
|
21858
|
+
);
|
|
21859
|
+
}
|
|
21860
|
+
return rows.map((row, index) => {
|
|
21861
|
+
const hubspotId = row?.hubspotId ?? row?.id;
|
|
21862
|
+
if (!hubspotId) throw new CLIError(`Record ${index} has no hubspotId (or id)`);
|
|
21863
|
+
return {
|
|
21864
|
+
hubspotId: String(hubspotId),
|
|
21865
|
+
name: row.name ?? null,
|
|
21866
|
+
email: row.email ?? null,
|
|
21867
|
+
phone: row.phone ?? null,
|
|
21868
|
+
objectType: row.objectType ?? "contacts"
|
|
21869
|
+
};
|
|
21870
|
+
});
|
|
21871
|
+
}
|
|
21668
21872
|
var hubspotDomain = {
|
|
21669
21873
|
name: "hubspot",
|
|
21670
21874
|
description: "HubSpot CRM integration",
|
|
@@ -21676,18 +21880,21 @@ var hubspotDomain = {
|
|
|
21676
21880
|
requiresWorkspace: true,
|
|
21677
21881
|
examples: [
|
|
21678
21882
|
"# When the response shows platformAppAvailable=true, the workspace connects through",
|
|
21679
|
-
"# the shared Gravity Rail HubSpot app:
|
|
21680
|
-
"gr hubspot
|
|
21681
|
-
"gr hubspot authorize -w <ws> --allow-write # then open the returned authorizeUrl",
|
|
21883
|
+
"# the shared Gravity Rail HubSpot app: one command, then open the authorizeUrl.",
|
|
21884
|
+
"gr hubspot connect -w <ws> --allow-write",
|
|
21682
21885
|
"",
|
|
21683
21886
|
"# To use your own HubSpot app instead (a Projects-platform app; HubSpot no longer",
|
|
21684
21887
|
"# allows new private or developer apps):",
|
|
21685
21888
|
'# 1. install -> creates the connection; the response includes the OAuth "callbackUrl"',
|
|
21686
21889
|
"# 2. in HubSpot: give your app that callbackUrl as a Redirect URL, with CRM scopes",
|
|
21687
|
-
"# (contacts/companies/deals read+write)
|
|
21890
|
+
"# (contacts/companies/deals read+write), plus crm.lists.read and",
|
|
21891
|
+
"# crm.objects.owners.read, forms, and scheduler.meetings.meeting-link.read",
|
|
21892
|
+
"# as OPTIONAL scopes (HubSpot rejects the authorize",
|
|
21893
|
+
"# request if the app lacks them).",
|
|
21894
|
+
"# Copy the Client ID + Secret.",
|
|
21688
21895
|
"# 3. configure -> save that Client ID / Secret",
|
|
21689
21896
|
'# 4. authorize -> returns an "authorizeUrl"; open it to grant access.',
|
|
21690
|
-
"gr hubspot
|
|
21897
|
+
"gr hubspot install -w <ws> --allow-write",
|
|
21691
21898
|
`gr hubspot configure -w <ws> --allow-write -d '{"clientId":"...","clientSecret":"..."}'`,
|
|
21692
21899
|
"gr hubspot authorize -w <ws> --allow-write # then open the returned authorizeUrl"
|
|
21693
21900
|
],
|
|
@@ -21696,6 +21903,33 @@ var hubspotDomain = {
|
|
|
21696
21903
|
outputSingle(result2, ctx);
|
|
21697
21904
|
}
|
|
21698
21905
|
},
|
|
21906
|
+
{
|
|
21907
|
+
path: ["hubspot", "connect"],
|
|
21908
|
+
description: "Install HubSpot if needed and start OAuth: prints the authorizeUrl to open and the exact callbackUrl the HubSpot app must allow",
|
|
21909
|
+
mutates: true,
|
|
21910
|
+
requiresWorkspace: true,
|
|
21911
|
+
examples: ["gr hubspot connect -w <ws> --allow-write"],
|
|
21912
|
+
handler: async ({ ctx, workspace }) => {
|
|
21913
|
+
const api = requireAuth(ctx).apiClient;
|
|
21914
|
+
const installed = await api.installHubspot(workspace);
|
|
21915
|
+
if (!installed.configured) {
|
|
21916
|
+
outputSingle(installed, ctx);
|
|
21917
|
+
throw new CLIError(
|
|
21918
|
+
"HubSpot is installed but has no app credentials. Register the callbackUrl above on your HubSpot app, then run: gr hubspot configure, then gr hubspot connect"
|
|
21919
|
+
);
|
|
21920
|
+
}
|
|
21921
|
+
const started = await api.startHubspotOAuth(workspace);
|
|
21922
|
+
outputSingle(
|
|
21923
|
+
{
|
|
21924
|
+
connectionId: started.connectionId,
|
|
21925
|
+
usesPlatformApp: started.usesPlatformApp,
|
|
21926
|
+
callbackUrl: started.callbackUrl,
|
|
21927
|
+
authorizeUrl: started.authorizeUrl
|
|
21928
|
+
},
|
|
21929
|
+
ctx
|
|
21930
|
+
);
|
|
21931
|
+
}
|
|
21932
|
+
},
|
|
21699
21933
|
{
|
|
21700
21934
|
path: ["hubspot", "status"],
|
|
21701
21935
|
description: "Get HubSpot connection status (shows configured/connected state + the OAuth callback URL)",
|
|
@@ -21707,6 +21941,8 @@ var hubspotDomain = {
|
|
|
21707
21941
|
},
|
|
21708
21942
|
{
|
|
21709
21943
|
path: ["hubspot", "configure"],
|
|
21944
|
+
// Reads its body from --data, --file or piped stdin.
|
|
21945
|
+
acceptsJsonInput: true,
|
|
21710
21946
|
description: "Configure HubSpot credentials (setup step 3): save the Client ID / Secret",
|
|
21711
21947
|
mutates: true,
|
|
21712
21948
|
requiresWorkspace: true,
|
|
@@ -21734,7 +21970,7 @@ var hubspotDomain = {
|
|
|
21734
21970
|
},
|
|
21735
21971
|
{
|
|
21736
21972
|
path: ["hubspot", "disconnect"],
|
|
21737
|
-
description: "Disconnect HubSpot",
|
|
21973
|
+
description: "Disconnect HubSpot: clear the stored OAuth tokens and return the connection to setup (HubSpot keeps the app install)",
|
|
21738
21974
|
mutates: true,
|
|
21739
21975
|
requiresWorkspace: true,
|
|
21740
21976
|
handler: async ({ ctx, workspace }) => {
|
|
@@ -21773,121 +22009,270 @@ var hubspotDomain = {
|
|
|
21773
22009
|
}
|
|
21774
22010
|
},
|
|
21775
22011
|
{
|
|
21776
|
-
path: ["hubspot", "
|
|
21777
|
-
description: "
|
|
22012
|
+
path: ["hubspot", "search"],
|
|
22013
|
+
description: "Search HubSpot contacts or companies; each result shows the workspace member it matches",
|
|
21778
22014
|
requiresWorkspace: true,
|
|
21779
|
-
|
|
21780
|
-
|
|
21781
|
-
|
|
21782
|
-
|
|
21783
|
-
|
|
21784
|
-
|
|
21785
|
-
|
|
21786
|
-
|
|
21787
|
-
|
|
22015
|
+
args: [
|
|
22016
|
+
{
|
|
22017
|
+
name: "query",
|
|
22018
|
+
description: "Contacts whose email, or companies whose name, contains this text; empty lists all"
|
|
22019
|
+
},
|
|
22020
|
+
{ name: "object-type", description: "'contacts' (default) or 'companies'" },
|
|
22021
|
+
{ name: "limit", description: "Max results (1..100, default 20)" },
|
|
22022
|
+
{
|
|
22023
|
+
name: "after",
|
|
22024
|
+
description: "Cursor from a previous page (nextCursor); only without --query"
|
|
22025
|
+
}
|
|
22026
|
+
],
|
|
22027
|
+
examples: [
|
|
22028
|
+
"gr hubspot search -w <ws> --query smith",
|
|
22029
|
+
"gr hubspot search -w <ws> --object-type companies --limit 50"
|
|
22030
|
+
],
|
|
22031
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
22032
|
+
const objectType = args["object-type"] ?? "contacts";
|
|
22033
|
+
if (!SEARCHABLE_OBJECT_TYPES.includes(objectType)) {
|
|
22034
|
+
throw new CLIError(
|
|
22035
|
+
`--object-type must be one of ${SEARCHABLE_OBJECT_TYPES.join(", ")}, got '${objectType}'`
|
|
22036
|
+
);
|
|
22037
|
+
}
|
|
22038
|
+
if (args["query"] && args["after"]) {
|
|
22039
|
+
throw new CLIError("--after pages only the listing without --query");
|
|
22040
|
+
}
|
|
22041
|
+
const result2 = await requireAuth(ctx).apiClient.searchHubspotRecords(workspace, {
|
|
22042
|
+
query: args["query"] ?? "",
|
|
22043
|
+
objectType,
|
|
22044
|
+
limit: optionalNumber(args, "limit") ?? 20,
|
|
22045
|
+
...args["after"] ? { after: String(args["after"]) } : {}
|
|
22046
|
+
});
|
|
22047
|
+
if (ctx.outputFormat !== "table") {
|
|
22048
|
+
outputSingle(result2, ctx);
|
|
22049
|
+
return;
|
|
22050
|
+
}
|
|
22051
|
+
outputData(result2.results, ctx, SEARCH_COLUMNS);
|
|
22052
|
+
if (result2.hasMore && result2.nextCursor && !args["query"]) {
|
|
22053
|
+
console.error(`More results: --after ${result2.nextCursor}`);
|
|
22054
|
+
}
|
|
21788
22055
|
}
|
|
21789
22056
|
},
|
|
21790
22057
|
{
|
|
21791
|
-
path: ["hubspot", "
|
|
21792
|
-
|
|
22058
|
+
path: ["hubspot", "import-members"],
|
|
22059
|
+
// Its input is usually the previous command's output: wait for the pipe.
|
|
22060
|
+
pipesJsonInput: true,
|
|
22061
|
+
description: "Create (or update and link) workspace members from HubSpot records (max 100 per call)",
|
|
21793
22062
|
mutates: true,
|
|
21794
22063
|
requiresWorkspace: true,
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21805
|
-
|
|
22064
|
+
args: [
|
|
22065
|
+
{
|
|
22066
|
+
name: "member-role-id",
|
|
22067
|
+
description: "Member role for new members (overrides memberRoleId in the body)"
|
|
22068
|
+
},
|
|
22069
|
+
{
|
|
22070
|
+
name: "ids",
|
|
22071
|
+
description: "Comma-separated HubSpot IDs: import only these rows of the input"
|
|
22072
|
+
},
|
|
22073
|
+
{ name: "add-to-org", description: "Also add new members to the org", isFlag: true },
|
|
22074
|
+
{
|
|
22075
|
+
name: "org-role",
|
|
22076
|
+
description: "Org role with --add-to-org: 'member' (default), 'admin', 'owner'"
|
|
22077
|
+
}
|
|
22078
|
+
],
|
|
22079
|
+
examples: [
|
|
22080
|
+
"gr hubspot search -w <ws> --query smith -o json \\",
|
|
22081
|
+
" | gr hubspot import-members -w <ws> --member-role-id 3 --allow-write",
|
|
22082
|
+
"gr hubspot search -w <ws> -o json > found.json",
|
|
22083
|
+
"gr hubspot import-members -w <ws> --file found.json --ids 101,102 --member-role-id 3 --allow-write"
|
|
22084
|
+
],
|
|
22085
|
+
handler: async ({ ctx, workspace, args, data }) => {
|
|
22086
|
+
if (!data) {
|
|
22087
|
+
throw new CLIError(
|
|
22088
|
+
"JSON input required (--data, --file, or stdin): pipe `gr hubspot search -o json`"
|
|
22089
|
+
);
|
|
22090
|
+
}
|
|
22091
|
+
let records = importRecordsFrom(data);
|
|
22092
|
+
const rawIds = args["ids"];
|
|
22093
|
+
if (rawIds) {
|
|
22094
|
+
const wanted = new Set(
|
|
22095
|
+
rawIds.split(",").map((id) => id.trim()).filter(Boolean)
|
|
22096
|
+
);
|
|
22097
|
+
records = records.filter((r) => wanted.has(r.hubspotId));
|
|
22098
|
+
const missing = [...wanted].filter((id) => !records.some((r) => r.hubspotId === id));
|
|
22099
|
+
if (missing.length > 0) {
|
|
22100
|
+
throw new CLIError(`--ids not found in the input: ${missing.join(", ")}`);
|
|
22101
|
+
}
|
|
22102
|
+
}
|
|
22103
|
+
if (records.length === 0) throw new CLIError("No records to import");
|
|
22104
|
+
if (records.length > 100) {
|
|
22105
|
+
throw new CLIError(`At most 100 records per import; got ${records.length}`);
|
|
22106
|
+
}
|
|
22107
|
+
const bodyRoleId = data?.memberRoleId;
|
|
22108
|
+
const memberRoleId = optionalNumber(args, "member-role-id") ?? (typeof bodyRoleId === "number" ? bodyRoleId : void 0);
|
|
22109
|
+
if (memberRoleId === void 0) {
|
|
22110
|
+
throw new CLIError("--member-role-id is required (see: gr member-roles list)");
|
|
22111
|
+
}
|
|
22112
|
+
const addToOrg = args["add-to-org"] === true || data?.addToOrg === true;
|
|
22113
|
+
const orgRole = args["org-role"] ?? data?.orgRole;
|
|
22114
|
+
const result2 = await requireAuth(ctx).apiClient.importHubspotMembers(workspace, {
|
|
22115
|
+
records,
|
|
22116
|
+
memberRoleId,
|
|
22117
|
+
addToOrg,
|
|
22118
|
+
...orgRole ? { orgRole } : {}
|
|
22119
|
+
});
|
|
22120
|
+
if (ctx.outputFormat !== "table") {
|
|
22121
|
+
outputSingle(result2, ctx);
|
|
22122
|
+
return;
|
|
22123
|
+
}
|
|
22124
|
+
outputData(result2.results, ctx, IMPORT_COLUMNS);
|
|
22125
|
+
console.error(`Imported ${result2.imported}, failed ${result2.failed}`);
|
|
21806
22126
|
}
|
|
21807
22127
|
},
|
|
21808
22128
|
{
|
|
21809
|
-
path: ["hubspot", "reconciliation"],
|
|
21810
|
-
description: "Find
|
|
22129
|
+
path: ["hubspot", "reconciliation", "matches"],
|
|
22130
|
+
description: "Find unlinked members with a likely HubSpot record (by email/phone); queries HubSpot",
|
|
21811
22131
|
requiresWorkspace: true,
|
|
21812
22132
|
args: [
|
|
21813
|
-
{ name: "offset", description: "
|
|
21814
|
-
{ name: "limit", description: "Max
|
|
22133
|
+
{ name: "offset", description: "Scan offset (default 0)" },
|
|
22134
|
+
{ name: "limit", description: "Max members to scan (default 50, max 200)" }
|
|
21815
22135
|
],
|
|
21816
22136
|
handler: async ({ ctx, workspace, args }) => {
|
|
21817
|
-
const offset = args["offset"] ? Number(args["offset"]) : void 0;
|
|
21818
|
-
const limit = args["limit"] ? Number(args["limit"]) : void 0;
|
|
21819
22137
|
const result2 = await requireAuth(ctx).apiClient.getHubspotReconciliationMatches(
|
|
21820
22138
|
workspace,
|
|
21821
|
-
{
|
|
21822
|
-
offset,
|
|
21823
|
-
limit
|
|
21824
|
-
}
|
|
22139
|
+
{ offset: optionalNumber(args, "offset"), limit: optionalNumber(args, "limit") }
|
|
21825
22140
|
);
|
|
21826
|
-
outputData(result2, ctx);
|
|
22141
|
+
outputData(result2, ctx, MATCH_COLUMNS2);
|
|
21827
22142
|
}
|
|
21828
22143
|
},
|
|
21829
22144
|
{
|
|
21830
|
-
path: ["hubspot", "linked
|
|
21831
|
-
description: "List members linked to HubSpot
|
|
22145
|
+
path: ["hubspot", "reconciliation", "linked"],
|
|
22146
|
+
description: "List members linked to HubSpot records",
|
|
21832
22147
|
requiresWorkspace: true,
|
|
21833
|
-
args:
|
|
22148
|
+
args: [
|
|
22149
|
+
...LIST_PAGINATION_ARGS,
|
|
22150
|
+
{ name: "search", description: "Filter by member name/email/phone or HubSpot ID" }
|
|
22151
|
+
],
|
|
21834
22152
|
handler: async ({ ctx, workspace, args }) => {
|
|
21835
22153
|
const pag = parsePaginationArgs(args);
|
|
22154
|
+
const search = args["search"] ? String(args["search"]) : void 0;
|
|
22155
|
+
const api = requireAuth(ctx).apiClient;
|
|
21836
22156
|
if (pag.all) {
|
|
21837
22157
|
const allItems = await fetchAllPages(
|
|
21838
|
-
({ page, pageSize }) =>
|
|
22158
|
+
({ page, pageSize }) => api.getLinkedHubspotMembers(workspace, { page, pageSize, search })
|
|
21839
22159
|
);
|
|
21840
|
-
outputData(allItems, ctx);
|
|
22160
|
+
outputData(allItems, ctx, LINKED_COLUMNS2);
|
|
21841
22161
|
return;
|
|
21842
22162
|
}
|
|
21843
|
-
const
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21848
|
-
|
|
21849
|
-
);
|
|
21850
|
-
outputData(listResult(result2, true), ctx);
|
|
22163
|
+
const result2 = await api.getLinkedHubspotMembers(workspace, {
|
|
22164
|
+
...pag.page ? { page: pag.page } : {},
|
|
22165
|
+
...pag.pageSize ? { pageSize: pag.pageSize } : {},
|
|
22166
|
+
...search ? { search } : {}
|
|
22167
|
+
});
|
|
22168
|
+
outputData(listResult(result2, true), ctx, LINKED_COLUMNS2);
|
|
21851
22169
|
}
|
|
21852
22170
|
},
|
|
21853
22171
|
{
|
|
21854
|
-
path: ["hubspot", "link
|
|
21855
|
-
description: "Link a member to a HubSpot
|
|
22172
|
+
path: ["hubspot", "reconciliation", "link"],
|
|
22173
|
+
description: "Link a member to a HubSpot record",
|
|
21856
22174
|
mutates: true,
|
|
21857
22175
|
requiresWorkspace: true,
|
|
21858
22176
|
args: [
|
|
21859
22177
|
{ name: "member-id", description: "Member ID", required: true },
|
|
21860
|
-
{ name: "
|
|
22178
|
+
{ name: "record-id", description: "HubSpot record ID", required: true },
|
|
22179
|
+
{ name: "object-type", description: "HubSpot object type (default 'contacts')" }
|
|
22180
|
+
],
|
|
22181
|
+
examples: [
|
|
22182
|
+
"gr hubspot reconciliation link -w <ws> --member-id 42 --record-id 101 --allow-write"
|
|
21861
22183
|
],
|
|
21862
22184
|
handler: async ({ ctx, workspace, args }) => {
|
|
22185
|
+
const objectType = args["object-type"] ? String(args["object-type"]) : void 0;
|
|
21863
22186
|
const result2 = await requireAuth(ctx).apiClient.linkMemberToHubspot(workspace, {
|
|
21864
22187
|
memberId: requireNumber(args, "member-id"),
|
|
21865
|
-
hubspotRecordId: requireString(args, "
|
|
22188
|
+
hubspotRecordId: requireString(args, "record-id"),
|
|
22189
|
+
...objectType ? { objectType } : {}
|
|
21866
22190
|
});
|
|
21867
22191
|
outputSingle(result2, ctx);
|
|
21868
22192
|
}
|
|
21869
22193
|
},
|
|
21870
22194
|
{
|
|
21871
|
-
path: ["hubspot", "
|
|
21872
|
-
|
|
22195
|
+
path: ["hubspot", "reconciliation", "link-bulk"],
|
|
22196
|
+
// Its input is usually the previous command's output: wait for the pipe.
|
|
22197
|
+
pipesJsonInput: true,
|
|
22198
|
+
description: 'Link many members at once. Body: {"links":[{"memberId":1,"recordId":"101"}]} (hubspotRecordId is accepted too); `reconciliation matches -o json` pipes in',
|
|
22199
|
+
mutates: true,
|
|
22200
|
+
requiresWorkspace: true,
|
|
22201
|
+
examples: [
|
|
22202
|
+
"gr hubspot reconciliation matches -w <ws> -o json \\",
|
|
22203
|
+
" | gr hubspot reconciliation link-bulk -w <ws> --allow-write"
|
|
22204
|
+
],
|
|
22205
|
+
handler: async ({ ctx, workspace, data }) => {
|
|
22206
|
+
const body = data;
|
|
22207
|
+
const rows = Array.isArray(body) ? body : body?.links;
|
|
22208
|
+
if (!Array.isArray(rows) || rows.length === 0) {
|
|
22209
|
+
throw new CLIError('JSON input must be {"links":[...]} or an array of matches');
|
|
22210
|
+
}
|
|
22211
|
+
const links = rows.map((row, index) => {
|
|
22212
|
+
const memberId = Number(row?.memberId);
|
|
22213
|
+
const recordId = row?.recordId ?? row?.hubspotRecordId;
|
|
22214
|
+
if (!Number.isInteger(memberId) || !recordId) {
|
|
22215
|
+
throw new CLIError(
|
|
22216
|
+
`links[${index}] needs a numeric memberId and a recordId (or hubspotRecordId)`
|
|
22217
|
+
);
|
|
22218
|
+
}
|
|
22219
|
+
return {
|
|
22220
|
+
memberId,
|
|
22221
|
+
hubspotRecordId: String(recordId),
|
|
22222
|
+
...row.objectType ? { objectType: String(row.objectType) } : {}
|
|
22223
|
+
};
|
|
22224
|
+
});
|
|
22225
|
+
const result2 = await requireAuth(ctx).apiClient.bulkLinkMembersToHubspot(workspace, {
|
|
22226
|
+
links
|
|
22227
|
+
});
|
|
22228
|
+
outputSingle(result2, ctx);
|
|
22229
|
+
}
|
|
22230
|
+
},
|
|
22231
|
+
{
|
|
22232
|
+
path: ["hubspot", "reconciliation", "unlink"],
|
|
22233
|
+
description: "Unlink a member from HubSpot (sync will not re-link them until reconciliation relink)",
|
|
21873
22234
|
mutates: true,
|
|
21874
22235
|
requiresWorkspace: true,
|
|
21875
22236
|
args: [{ name: "member-id", description: "Member ID", required: true }],
|
|
21876
22237
|
handler: async ({ ctx, workspace, args }) => {
|
|
21877
|
-
await requireAuth(ctx).apiClient.unlinkMemberFromHubspot(
|
|
22238
|
+
const result2 = await requireAuth(ctx).apiClient.unlinkMemberFromHubspot(
|
|
21878
22239
|
workspace,
|
|
21879
22240
|
requireNumber(args, "member-id")
|
|
21880
22241
|
);
|
|
21881
|
-
|
|
22242
|
+
outputSingle(result2, ctx);
|
|
21882
22243
|
}
|
|
21883
22244
|
},
|
|
21884
22245
|
{
|
|
21885
|
-
path: ["hubspot", "
|
|
21886
|
-
description: "List
|
|
22246
|
+
path: ["hubspot", "properties"],
|
|
22247
|
+
description: "List HubSpot property definitions: the sync-mappable contact properties by default, or every property of --object-type as HubSpot defines it",
|
|
21887
22248
|
requiresWorkspace: true,
|
|
21888
|
-
|
|
21889
|
-
|
|
21890
|
-
|
|
22249
|
+
args: [
|
|
22250
|
+
{
|
|
22251
|
+
name: "object-type",
|
|
22252
|
+
description: "Raw HubSpot schema for 'contacts', 'companies' or 'deals'"
|
|
22253
|
+
}
|
|
22254
|
+
],
|
|
22255
|
+
examples: [
|
|
22256
|
+
"gr hubspot properties -w <ws>",
|
|
22257
|
+
"gr hubspot properties -w <ws> --object-type deals -o json"
|
|
22258
|
+
],
|
|
22259
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
22260
|
+
const objectType = args["object-type"];
|
|
22261
|
+
const api = requireAuth(ctx).apiClient;
|
|
22262
|
+
if (objectType === void 0) {
|
|
22263
|
+
outputData(await api.getHubspotContactProperties(workspace), ctx);
|
|
22264
|
+
return;
|
|
22265
|
+
}
|
|
22266
|
+
if (!OBJECT_TYPES.includes(objectType)) {
|
|
22267
|
+
throw new CLIError(
|
|
22268
|
+
`--object-type must be one of ${OBJECT_TYPES.join(", ")}, got '${objectType}'`
|
|
22269
|
+
);
|
|
22270
|
+
}
|
|
22271
|
+
const result2 = await api.getHubspotObjectProperties(
|
|
22272
|
+
workspace,
|
|
22273
|
+
objectType
|
|
22274
|
+
);
|
|
22275
|
+
outputSingle(result2, ctx);
|
|
21891
22276
|
}
|
|
21892
22277
|
},
|
|
21893
22278
|
{
|
|
@@ -21899,6 +22284,22 @@ var hubspotDomain = {
|
|
|
21899
22284
|
outputData(result2, ctx);
|
|
21900
22285
|
}
|
|
21901
22286
|
},
|
|
22287
|
+
{
|
|
22288
|
+
path: ["hubspot", "sync", "logs"],
|
|
22289
|
+
description: "List HubSpot managed-rule executions (newest first, cursor-paged)",
|
|
22290
|
+
requiresWorkspace: true,
|
|
22291
|
+
args: [
|
|
22292
|
+
{ name: "page-size", description: "Rows per page" },
|
|
22293
|
+
{ name: "cursor", description: "Cursor from a previous page (nextCursor)" }
|
|
22294
|
+
],
|
|
22295
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
22296
|
+
const result2 = await requireAuth(ctx).apiClient.getHubspotSyncLogs(workspace, {
|
|
22297
|
+
pageSize: optionalNumber(args, "page-size"),
|
|
22298
|
+
cursor: args["cursor"] ? String(args["cursor"]) : void 0
|
|
22299
|
+
});
|
|
22300
|
+
outputSingle(result2, ctx);
|
|
22301
|
+
}
|
|
22302
|
+
},
|
|
21902
22303
|
{
|
|
21903
22304
|
path: ["hubspot", "transform-presets"],
|
|
21904
22305
|
description: "List available HubSpot field transform presets",
|
|
@@ -21907,7 +22308,8 @@ var hubspotDomain = {
|
|
|
21907
22308
|
const result2 = await requireAuth(ctx).apiClient.getHubspotTransformPresets(workspace);
|
|
21908
22309
|
outputData(result2, ctx);
|
|
21909
22310
|
}
|
|
21910
|
-
}
|
|
22311
|
+
},
|
|
22312
|
+
...connectionCommands(HUBSPOT)
|
|
21911
22313
|
]
|
|
21912
22314
|
};
|
|
21913
22315
|
|
|
@@ -22183,37 +22585,39 @@ var salesforceDomain = {
|
|
|
22183
22585
|
commands: [
|
|
22184
22586
|
{
|
|
22185
22587
|
path: ["salesforce", "install"],
|
|
22186
|
-
description: "Install Salesforce (setup step 1): create the connection
|
|
22588
|
+
description: "Install Salesforce (setup step 1): create the connection for an environment, then authorize",
|
|
22187
22589
|
mutates: true,
|
|
22188
22590
|
requiresWorkspace: true,
|
|
22189
22591
|
args: [
|
|
22190
22592
|
{
|
|
22191
|
-
name: "
|
|
22192
|
-
description: "Salesforce
|
|
22593
|
+
name: "environment",
|
|
22594
|
+
description: "Salesforce environment: production (default) or sandbox"
|
|
22595
|
+
},
|
|
22596
|
+
{
|
|
22597
|
+
name: "my-domain",
|
|
22598
|
+
description: "The org's My Domain host (e.g. acme.my.salesforce.com), only for an org that blocks login.salesforce.com / test.salesforce.com"
|
|
22193
22599
|
}
|
|
22194
22600
|
],
|
|
22195
22601
|
examples: [
|
|
22196
|
-
"#
|
|
22197
|
-
|
|
22198
|
-
|
|
22199
|
-
"#
|
|
22200
|
-
"#
|
|
22201
|
-
|
|
22202
|
-
'# 4. authorize -> returns an "authorizeUrl"; open it to grant access. status then',
|
|
22203
|
-
"# reports configured=true and connected=true.",
|
|
22602
|
+
"# One-click setup through the shared Gravity Rail Salesforce app:",
|
|
22603
|
+
"# 1. install -> creates the connection for the chosen environment",
|
|
22604
|
+
'# 2. authorize -> returns an "authorizeUrl"; open it, sign in and approve access.',
|
|
22605
|
+
"# status then reports connected=true.",
|
|
22606
|
+
"# Advanced (own app): run configure between install and authorize, with an app whose",
|
|
22607
|
+
'# Callback URL is the status "callbackUrl".',
|
|
22204
22608
|
"",
|
|
22205
22609
|
"gr salesforce install -w <ws> --allow-write",
|
|
22206
|
-
"gr salesforce install -w <ws> --
|
|
22207
|
-
"gr salesforce
|
|
22208
|
-
|
|
22209
|
-
"gr salesforce authorize -w <ws> --allow-write # then open the returned authorizeUrl"
|
|
22610
|
+
"gr salesforce install -w <ws> --environment sandbox --allow-write",
|
|
22611
|
+
"gr salesforce authorize -w <ws> --allow-write # then open the returned authorizeUrl",
|
|
22612
|
+
"gr salesforce status -w <ws>"
|
|
22210
22613
|
],
|
|
22211
22614
|
handler: async ({ ctx, workspace, args }) => {
|
|
22212
|
-
const
|
|
22213
|
-
const
|
|
22214
|
-
|
|
22215
|
-
typeof
|
|
22216
|
-
|
|
22615
|
+
const environment = args["environment"];
|
|
22616
|
+
const myDomain = args["my-domain"];
|
|
22617
|
+
const result2 = await requireAuth(ctx).apiClient.installSalesforce(workspace, {
|
|
22618
|
+
...typeof environment === "string" ? { environment } : {},
|
|
22619
|
+
...typeof myDomain === "string" ? { myDomain } : {}
|
|
22620
|
+
});
|
|
22217
22621
|
outputSingle(result2, ctx);
|
|
22218
22622
|
}
|
|
22219
22623
|
},
|
|
@@ -22228,12 +22632,12 @@ var salesforceDomain = {
|
|
|
22228
22632
|
},
|
|
22229
22633
|
{
|
|
22230
22634
|
path: ["salesforce", "configure"],
|
|
22231
|
-
description: "
|
|
22635
|
+
description: "Advanced: save your own Salesforce app's Client ID / Secret and environment, then open the returned authorizeUrl",
|
|
22232
22636
|
mutates: true,
|
|
22233
22637
|
requiresWorkspace: true,
|
|
22234
22638
|
examples: [
|
|
22235
22639
|
"gr salesforce configure -w <ws> --allow-write \\",
|
|
22236
|
-
` -d '{"clientId":"3MVG9...","clientSecret":"1A2B...","
|
|
22640
|
+
` -d '{"clientId":"3MVG9...","clientSecret":"1A2B...","environment":"production"}'`
|
|
22237
22641
|
],
|
|
22238
22642
|
handler: async ({ ctx, workspace, data }) => {
|
|
22239
22643
|
if (!data) throw new CLIError("JSON data required (--data, --file, or stdin)");
|
|
@@ -22246,7 +22650,7 @@ var salesforceDomain = {
|
|
|
22246
22650
|
},
|
|
22247
22651
|
{
|
|
22248
22652
|
path: ["salesforce", "authorize"],
|
|
22249
|
-
description: "Authorize Salesforce via OAuth (setup step
|
|
22653
|
+
description: "Authorize Salesforce via OAuth (setup step 2): returns an authorizeUrl to open in a browser",
|
|
22250
22654
|
mutates: true,
|
|
22251
22655
|
requiresWorkspace: true,
|
|
22252
22656
|
handler: async ({ ctx, workspace }) => {
|
|
@@ -27193,7 +27597,7 @@ var topLevelCommands = [
|
|
|
27193
27597
|
mutates: true,
|
|
27194
27598
|
args: [{ name: "phone", description: "E.164 phone number (optional; prompts if omitted)" }],
|
|
27195
27599
|
handler: async (hctx) => {
|
|
27196
|
-
const { accountVerifyPhoneCommand } = await import("./account-verify-phone-
|
|
27600
|
+
const { accountVerifyPhoneCommand } = await import("./account-verify-phone-Q4FKI4PX.js");
|
|
27197
27601
|
await accountVerifyPhoneCommand(hctx);
|
|
27198
27602
|
}
|
|
27199
27603
|
},
|
|
@@ -27300,6 +27704,7 @@ export {
|
|
|
27300
27704
|
CommandRegistry,
|
|
27301
27705
|
LIST_PAGINATION_ARGS,
|
|
27302
27706
|
PAGINATION_ARGS,
|
|
27707
|
+
PIPED_INPUT_FIRST_BYTE_WAIT_MS,
|
|
27303
27708
|
WORKSPACE_EXPORT_ZIP,
|
|
27304
27709
|
authBrowserCommand,
|
|
27305
27710
|
authImportDevCommand,
|
|
@@ -27307,6 +27712,7 @@ export {
|
|
|
27307
27712
|
authSwitchCommand,
|
|
27308
27713
|
buildCliConciergeAppContext,
|
|
27309
27714
|
chatCommand,
|
|
27715
|
+
commandAwaitsPipedInput,
|
|
27310
27716
|
commandNeedsJsonBody,
|
|
27311
27717
|
conciergeCommand,
|
|
27312
27718
|
conciergeOutboundCommand,
|
|
@@ -27351,6 +27757,7 @@ export {
|
|
|
27351
27757
|
parseGlobalOptions,
|
|
27352
27758
|
parsePaginationArgs,
|
|
27353
27759
|
profilesFromDevRealms,
|
|
27760
|
+
readCommandJsonInput,
|
|
27354
27761
|
readJsonInput,
|
|
27355
27762
|
registerPublicDomains,
|
|
27356
27763
|
requireAuth,
|