@nyrra/prismantix-cli 0.0.1 → 0.0.2-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -28
- package/bin/dev.js +1 -3
- package/bin/run.js +1 -3
- package/dist/api.d.ts +201 -173
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +237 -110
- package/dist/command-support.d.ts +13 -0
- package/dist/command-support.d.ts.map +1 -0
- package/dist/command-support.js +40 -0
- package/dist/commands/object/details.d.ts +13 -0
- package/dist/commands/object/details.d.ts.map +1 -0
- package/dist/commands/object/details.js +28 -0
- package/dist/commands/object/list.d.ts +13 -0
- package/dist/commands/object/list.d.ts.map +1 -0
- package/dist/commands/object/list.js +27 -0
- package/dist/commands/ontology/list.d.ts +10 -0
- package/dist/commands/ontology/list.d.ts.map +1 -0
- package/dist/commands/ontology/list.js +25 -0
- package/dist/commands/records/cancel.d.ts +13 -0
- package/dist/commands/records/cancel.d.ts.map +1 -0
- package/dist/commands/records/cancel.js +21 -0
- package/dist/commands/records/generate.d.ts +15 -0
- package/dist/commands/records/generate.d.ts.map +1 -0
- package/dist/commands/records/generate.js +56 -0
- package/dist/commands/{download.d.ts → records/pull.d.ts} +5 -11
- package/dist/commands/records/pull.d.ts.map +1 -0
- package/dist/commands/records/pull.js +59 -0
- package/dist/commands/records/status.d.ts +13 -0
- package/dist/commands/records/status.d.ts.map +1 -0
- package/dist/commands/records/status.js +22 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +39 -0
- package/dist/generation.d.ts +13 -0
- package/dist/generation.d.ts.map +1 -0
- package/dist/generation.js +77 -0
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +10 -0
- package/dist/workflow.d.ts +3 -14
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +85 -61
- package/oclif.manifest.json +266 -40
- package/package.json +74 -74
- package/dist/commands/download.d.ts.map +0 -1
- package/dist/commands/download.js +0 -136
- package/dist/commands/guided.d.ts +0 -7
- package/dist/commands/guided.d.ts.map +0 -1
- package/dist/commands/guided.js +0 -15
- package/dist/ui/guided-flow.d.ts +0 -20
- package/dist/ui/guided-flow.d.ts.map +0 -1
- package/dist/ui/guided-flow.js +0 -156
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guided.d.ts","sourceRoot":"","sources":["../../src/commands/guided.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IAC1C,OAAgB,WAAW,SACuB;IAClD,OAAgB,MAAM,UAAQ;IAEjB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAUjC"}
|
package/dist/commands/guided.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
import { renderGuidedFlow } from "../ui/guided-flow.js";
|
|
3
|
-
export default class Guided extends Command {
|
|
4
|
-
static description = "Launch the interactive PrismantiX export flow.";
|
|
5
|
-
static hidden = true;
|
|
6
|
-
async run() {
|
|
7
|
-
const result = await renderGuidedFlow({
|
|
8
|
-
cwd: process.cwd(),
|
|
9
|
-
env: process.env,
|
|
10
|
-
});
|
|
11
|
-
if (!result.ok) {
|
|
12
|
-
this.exit(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
package/dist/ui/guided-flow.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type DownloadResult, type ManifestSummary } from "../workflow.js";
|
|
2
|
-
export interface GuidedFlowResult {
|
|
3
|
-
readonly error?: string;
|
|
4
|
-
readonly ok: boolean;
|
|
5
|
-
readonly result?: DownloadResult;
|
|
6
|
-
}
|
|
7
|
-
export interface GuidedFlowProps {
|
|
8
|
-
readonly cwd?: string;
|
|
9
|
-
readonly env?: Record<string, string | undefined>;
|
|
10
|
-
readonly fetchImpl?: typeof fetch;
|
|
11
|
-
readonly now?: () => number;
|
|
12
|
-
readonly onComplete?: (result: GuidedFlowResult) => void;
|
|
13
|
-
readonly sleep?: (ms: number) => Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare function renderGuidedFlow(props?: GuidedFlowProps): Promise<GuidedFlowResult>;
|
|
16
|
-
export declare function GuidedFlow({ cwd, env, fetchImpl, now, onComplete, sleep, }: GuidedFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export declare function ManifestSummaryView({ summary, }: {
|
|
18
|
-
readonly summary: ManifestSummary;
|
|
19
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
//# sourceMappingURL=guided-flow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guided-flow.d.ts","sourceRoot":"","sources":["../../src/ui/guided-flow.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EAIpB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAID,wBAAsB,gBAAgB,CAAC,KAAK,GAAE,eAAoB,6BAcjE;AAED,wBAAgB,UAAU,CAAC,EAC1B,GAAG,EACH,GAAiB,EACjB,SAAS,EACT,GAAG,EACH,UAAU,EACV,KAAK,GACL,EAAE,eAAe,2CAyLjB;AAED,wBAAgB,mBAAmB,CAAC,EACnC,OAAO,GACP,EAAE;IACF,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;CAClC,2CAiBA"}
|
package/dist/ui/guided-flow.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Alert, PasswordInput, Spinner, StatusMessage, TextInput, UnorderedList, } from "@inkjs/ui";
|
|
3
|
-
import { Box, render, Text, useApp } from "ink";
|
|
4
|
-
import { useEffect, useMemo, useState } from "react";
|
|
5
|
-
import { DEFAULT_API_BASE_URL, DEFAULT_POLL_INTERVAL_MS, DEFAULT_TIMEOUT_MS, } from "../constants.js";
|
|
6
|
-
import { toCliUserError } from "../errors.js";
|
|
7
|
-
import { runDownloadWorkflow, summarizeManifest, } from "../workflow.js";
|
|
8
|
-
export async function renderGuidedFlow(props = {}) {
|
|
9
|
-
let result = { ok: false };
|
|
10
|
-
const instance = render(_jsx(GuidedFlow, { ...props, onComplete: (nextResult) => {
|
|
11
|
-
result = nextResult;
|
|
12
|
-
props.onComplete?.(nextResult);
|
|
13
|
-
} }));
|
|
14
|
-
await instance.waitUntilExit();
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
export function GuidedFlow({ cwd, env = process.env, fetchImpl, now, onComplete, sleep, }) {
|
|
18
|
-
const { exit } = useApp();
|
|
19
|
-
const envApiKey = env.PRISMANTIX_API_KEY?.trim();
|
|
20
|
-
const envClientId = env.PRISMANTIX_CLIENT_ID?.trim().toUpperCase();
|
|
21
|
-
const [apiKey, setApiKey] = useState(envApiKey ?? "");
|
|
22
|
-
const [clientId, setClientId] = useState(envClientId ?? "");
|
|
23
|
-
const [step, setStep] = useState(envApiKey ? "client" : "api-key");
|
|
24
|
-
const [events, setEvents] = useState([]);
|
|
25
|
-
const [inputError, setInputError] = useState();
|
|
26
|
-
const [manifestSummary, setManifestSummary] = useState();
|
|
27
|
-
const [result, setResult] = useState();
|
|
28
|
-
const [fatalError, setFatalError] = useState();
|
|
29
|
-
const apiBaseUrl = env.PRISMANTIX_API_BASE ?? DEFAULT_API_BASE_URL;
|
|
30
|
-
const outputDir = env.PRISMANTIX_OUTPUT_DIR;
|
|
31
|
-
const pollIntervalMs = readPositiveInteger(env.PRISMANTIX_POLL_INTERVAL_MS, DEFAULT_POLL_INTERVAL_MS);
|
|
32
|
-
const timeoutMs = readPositiveInteger(env.PRISMANTIX_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (step !== "running") {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
let cancelled = false;
|
|
38
|
-
runDownloadWorkflow({
|
|
39
|
-
apiBaseUrl,
|
|
40
|
-
apiKey,
|
|
41
|
-
clientId,
|
|
42
|
-
outputDir,
|
|
43
|
-
pollIntervalMs,
|
|
44
|
-
timeoutMs,
|
|
45
|
-
}, {
|
|
46
|
-
cwd,
|
|
47
|
-
fetchImpl,
|
|
48
|
-
now,
|
|
49
|
-
onEvent: (event) => {
|
|
50
|
-
if (cancelled) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (event.type === "manifest") {
|
|
54
|
-
setManifestSummary(summarizeManifest(event.manifest));
|
|
55
|
-
}
|
|
56
|
-
setEvents((previousEvents) => [
|
|
57
|
-
...previousEvents.slice(-7),
|
|
58
|
-
formatEvent(event),
|
|
59
|
-
]);
|
|
60
|
-
},
|
|
61
|
-
sleep,
|
|
62
|
-
})
|
|
63
|
-
.then((downloadResult) => {
|
|
64
|
-
if (cancelled) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
setResult(downloadResult);
|
|
68
|
-
setStep("done");
|
|
69
|
-
onComplete?.({ ok: true, result: downloadResult });
|
|
70
|
-
setTimeout(() => exit(), 0);
|
|
71
|
-
})
|
|
72
|
-
.catch((error) => {
|
|
73
|
-
if (cancelled) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const cliError = toCliUserError(error);
|
|
77
|
-
setFatalError(cliError.message);
|
|
78
|
-
setStep("error");
|
|
79
|
-
onComplete?.({ error: cliError.message, ok: false });
|
|
80
|
-
setTimeout(() => exit(), 0);
|
|
81
|
-
});
|
|
82
|
-
return () => {
|
|
83
|
-
cancelled = true;
|
|
84
|
-
};
|
|
85
|
-
}, [
|
|
86
|
-
apiBaseUrl,
|
|
87
|
-
apiKey,
|
|
88
|
-
clientId,
|
|
89
|
-
cwd,
|
|
90
|
-
exit,
|
|
91
|
-
fetchImpl,
|
|
92
|
-
now,
|
|
93
|
-
onComplete,
|
|
94
|
-
outputDir,
|
|
95
|
-
pollIntervalMs,
|
|
96
|
-
sleep,
|
|
97
|
-
step,
|
|
98
|
-
timeoutMs,
|
|
99
|
-
]);
|
|
100
|
-
const header = useMemo(() => (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Text, { bold: true, children: "PrismantiX Export" }), _jsxs(Text, { color: "gray", children: ["API: ", apiBaseUrl] })] })), [apiBaseUrl]);
|
|
101
|
-
if (step === "api-key") {
|
|
102
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [header, _jsx(Text, { children: "Enter PRISMANTIX_API_KEY" }), _jsx(PasswordInput, { placeholder: "API key", onSubmit: (value) => {
|
|
103
|
-
const nextApiKey = value.trim();
|
|
104
|
-
if (!nextApiKey) {
|
|
105
|
-
setInputError("API key is required.");
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setInputError(undefined);
|
|
109
|
-
setApiKey(nextApiKey);
|
|
110
|
-
setStep("client");
|
|
111
|
-
} }), inputError ? (_jsx(StatusMessage, { variant: "error", children: inputError })) : null] }));
|
|
112
|
-
}
|
|
113
|
-
if (step === "client") {
|
|
114
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [header, _jsxs(StatusMessage, { variant: "info", children: ["API key loaded from ", envApiKey ? "environment" : "prompt", "."] }), _jsx(Text, { children: "Enter client ID" }), _jsx(TextInput, { placeholder: clientId ? `Client ID (${clientId})` : "Client ID", onSubmit: (value) => {
|
|
115
|
-
const nextClientId = (value.trim() || clientId).toUpperCase();
|
|
116
|
-
if (!nextClientId) {
|
|
117
|
-
setInputError("Client ID is required.");
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
setInputError(undefined);
|
|
121
|
-
setClientId(nextClientId);
|
|
122
|
-
setStep("running");
|
|
123
|
-
} }), inputError ? (_jsx(StatusMessage, { variant: "error", children: inputError })) : null] }));
|
|
124
|
-
}
|
|
125
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [header, step === "running" ? _jsx(Spinner, { label: "Creating export" }) : null, manifestSummary ? (_jsx(ManifestSummaryView, { summary: manifestSummary })) : null, _jsx(EventLog, { events: events }), step === "done" && result ? (_jsxs(StatusMessage, { variant: "success", children: ["Downloaded ", result.files.length, " file(s) to ", result.outputDir] })) : null, step === "error" && fatalError ? (_jsx(Alert, { variant: "error", children: fatalError })) : null] }));
|
|
126
|
-
}
|
|
127
|
-
export function ManifestSummaryView({ summary, }) {
|
|
128
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: ["Manifest: ", summary.fileCount, " file(s), ", summary.totalRows, " total row(s)"] }), _jsx(UnorderedList, { children: summary.tables.map((table) => (_jsx(UnorderedList.Item, { children: _jsxs(Text, { children: [table.tableName, ": ", table.rowCount ?? 0, " row(s)"] }) }, table.tableName))) })] }));
|
|
129
|
-
}
|
|
130
|
-
function EventLog({ events }) {
|
|
131
|
-
if (events.length === 0) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
return (_jsx(Box, { flexDirection: "column", children: events.map((event) => (_jsx(Text, { color: "gray", children: event }, event))) }));
|
|
135
|
-
}
|
|
136
|
-
function formatEvent(event) {
|
|
137
|
-
switch (event.type) {
|
|
138
|
-
case "created":
|
|
139
|
-
return `Queued export ${event.exportId} for ${event.clientId}.`;
|
|
140
|
-
case "poll":
|
|
141
|
-
return `Export ${event.status.exportId}: ${event.status.status}.`;
|
|
142
|
-
case "manifest":
|
|
143
|
-
return `Manifest fetched for ${event.manifest.exportId}.`;
|
|
144
|
-
case "download-start":
|
|
145
|
-
return `Downloading ${event.file.tableName}.`;
|
|
146
|
-
case "download-complete":
|
|
147
|
-
return `Downloaded ${event.file.tableName}.`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function readPositiveInteger(value, fallback) {
|
|
151
|
-
if (!value) {
|
|
152
|
-
return fallback;
|
|
153
|
-
}
|
|
154
|
-
const parsed = Number(value);
|
|
155
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
156
|
-
}
|