@maschinenlesbar.org/ckan-cli 0.0.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/CONTRIBUTING.md +25 -0
- package/LICENSE +661 -0
- package/LICENSING.md +47 -0
- package/README.md +268 -0
- package/dist/src/cli/commands/catalogue.d.ts +4 -0
- package/dist/src/cli/commands/catalogue.d.ts.map +1 -0
- package/dist/src/cli/commands/catalogue.js +103 -0
- package/dist/src/cli/commands/catalogue.js.map +1 -0
- package/dist/src/cli/commands/portal.d.ts +4 -0
- package/dist/src/cli/commands/portal.d.ts.map +1 -0
- package/dist/src/cli/commands/portal.js +61 -0
- package/dist/src/cli/commands/portal.js.map +1 -0
- package/dist/src/cli/index.d.ts +3 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +6 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/io.d.ts +15 -0
- package/dist/src/cli/io.d.ts.map +1 -0
- package/dist/src/cli/io.js +8 -0
- package/dist/src/cli/io.js.map +1 -0
- package/dist/src/cli/program.d.ts +7 -0
- package/dist/src/cli/program.d.ts.map +1 -0
- package/dist/src/cli/program.js +77 -0
- package/dist/src/cli/program.js.map +1 -0
- package/dist/src/cli/run.d.ts +3 -0
- package/dist/src/cli/run.d.ts.map +1 -0
- package/dist/src/cli/run.js +48 -0
- package/dist/src/cli/run.js.map +1 -0
- package/dist/src/cli/shared.d.ts +61 -0
- package/dist/src/cli/shared.d.ts.map +1 -0
- package/dist/src/cli/shared.js +134 -0
- package/dist/src/cli/shared.js.map +1 -0
- package/dist/src/client/client.d.ts +71 -0
- package/dist/src/client/client.d.ts.map +1 -0
- package/dist/src/client/client.js +194 -0
- package/dist/src/client/client.js.map +1 -0
- package/dist/src/client/engine.d.ts +56 -0
- package/dist/src/client/engine.d.ts.map +1 -0
- package/dist/src/client/engine.js +193 -0
- package/dist/src/client/engine.js.map +1 -0
- package/dist/src/client/errors.d.ts +40 -0
- package/dist/src/client/errors.d.ts.map +1 -0
- package/dist/src/client/errors.js +73 -0
- package/dist/src/client/errors.js.map +1 -0
- package/dist/src/client/http.d.ts +31 -0
- package/dist/src/client/http.d.ts.map +1 -0
- package/dist/src/client/http.js +111 -0
- package/dist/src/client/http.js.map +1 -0
- package/dist/src/client/index.d.ts +13 -0
- package/dist/src/client/index.d.ts.map +1 -0
- package/dist/src/client/index.js +10 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/portals-list.d.ts +3 -0
- package/dist/src/client/portals-list.d.ts.map +1 -0
- package/dist/src/client/portals-list.js +294 -0
- package/dist/src/client/portals-list.js.map +1 -0
- package/dist/src/client/portals.d.ts +37 -0
- package/dist/src/client/portals.d.ts.map +1 -0
- package/dist/src/client/portals.js +122 -0
- package/dist/src/client/portals.js.map +1 -0
- package/dist/src/client/query.d.ts +9 -0
- package/dist/src/client/query.d.ts.map +1 -0
- package/dist/src/client/query.js +33 -0
- package/dist/src/client/query.js.map +1 -0
- package/dist/src/client/types.d.ts +99 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +8 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Assemble the full commander program. The program is built around an injectable
|
|
2
|
+
// CliDeps so the entire CLI can be driven in tests with a mocked client and
|
|
3
|
+
// captured output.
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { Command, InvalidArgumentError, Option } from "commander";
|
|
7
|
+
import { defaultIO } from "./io.js";
|
|
8
|
+
import { CkanClient } from "../client/client.js";
|
|
9
|
+
import { DEFAULT_BASE_URL } from "../client/engine.js";
|
|
10
|
+
import { MAX_TIMEOUT_MS } from "../client/http.js";
|
|
11
|
+
import { parseBaseUrl, parseBoundedInt, parseIntArg, parsePortal } from "./shared.js";
|
|
12
|
+
import { registerCatalogueCommands } from "./commands/catalogue.js";
|
|
13
|
+
import { registerPortalCommands } from "./commands/portal.js";
|
|
14
|
+
/**
|
|
15
|
+
* Single source of truth for the version: read from package.json at runtime
|
|
16
|
+
* rather than duplicating a literal that can silently drift after a release bump.
|
|
17
|
+
* From the compiled location (dist/src/cli/program.js) package.json is three
|
|
18
|
+
* directories up; the same offset holds for the source under src/cli.
|
|
19
|
+
*/
|
|
20
|
+
function readVersion() {
|
|
21
|
+
try {
|
|
22
|
+
const pkgUrl = new URL("../../../package.json", import.meta.url);
|
|
23
|
+
const pkg = JSON.parse(readFileSync(fileURLToPath(pkgUrl), "utf8"));
|
|
24
|
+
return pkg.version ?? "0.0.0";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "0.0.0";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const VERSION = readVersion();
|
|
31
|
+
/** Default dependencies: real client + real stdout/stderr + real environment. */
|
|
32
|
+
export const defaultDeps = {
|
|
33
|
+
io: defaultIO,
|
|
34
|
+
env: process.env,
|
|
35
|
+
createClient: (options) => new CkanClient(options),
|
|
36
|
+
};
|
|
37
|
+
export function buildProgram(deps = defaultDeps) {
|
|
38
|
+
const program = new Command();
|
|
39
|
+
program
|
|
40
|
+
.name("ckan")
|
|
41
|
+
.description("CLI for any CKAN open-data portal (Action API v3)")
|
|
42
|
+
.version(VERSION)
|
|
43
|
+
.option("--base-url <url>", "CKAN site URL (env CKAN_BASE_URL)", parseBaseUrl, deps.env["CKAN_BASE_URL"] || DEFAULT_BASE_URL)
|
|
44
|
+
.addOption(new Option("--portal <id>", "a known portal by id (see `ckan portals`)")
|
|
45
|
+
.argParser(parsePortal)
|
|
46
|
+
.conflicts("baseUrl"))
|
|
47
|
+
.option("--timeout <ms>", "per-request timeout in milliseconds", parseBoundedInt(0, MAX_TIMEOUT_MS))
|
|
48
|
+
.option("--user-agent <ua>", "User-Agent header value")
|
|
49
|
+
.option("--max-retries <n>", "retries for transient 429/503 responses", parseIntArg)
|
|
50
|
+
.option("--max-response-bytes <n>", "cap response body size in bytes (0 = unlimited; default 100 MiB)", parseIntArg)
|
|
51
|
+
.option("--compact", "print JSON on a single line instead of pretty-printed")
|
|
52
|
+
.showHelpAfterError();
|
|
53
|
+
// A bare invocation (no subcommand) should print help to stdout and exit 0,
|
|
54
|
+
// matching `ckan help` / `ckan --help`. Without an explicit root action,
|
|
55
|
+
// commander writes help to stderr and exits 1 for the empty-command case.
|
|
56
|
+
program.action(() => {
|
|
57
|
+
program.help();
|
|
58
|
+
});
|
|
59
|
+
// commander runs value parsers on flags but not on defaults, so a base URL
|
|
60
|
+
// taken from CKAN_BASE_URL is checked here, before any command runs.
|
|
61
|
+
program.hook("preAction", () => {
|
|
62
|
+
if (program.getOptionValueSource("baseUrl") !== "default" || program.opts()["portal"] !== undefined)
|
|
63
|
+
return;
|
|
64
|
+
try {
|
|
65
|
+
parseBaseUrl(program.opts().baseUrl);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (!(err instanceof InvalidArgumentError))
|
|
69
|
+
throw err;
|
|
70
|
+
program.error(`error: CKAN_BASE_URL: ${err.message}`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
registerCatalogueCommands(program, deps);
|
|
74
|
+
registerPortalCommands(program, deps);
|
|
75
|
+
return program;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../../src/cli/program.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,4EAA4E;AAC5E,mBAAmB;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE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CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/cli/run.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAiBvC,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBtF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Run the CLI and resolve to a process exit code. Kept separate from the bin
|
|
2
|
+
// shim so tests can call run() directly with injected deps and assert on the
|
|
3
|
+
// captured output and exit code without spawning a subprocess.
|
|
4
|
+
import { CommanderError } from "commander";
|
|
5
|
+
import { buildProgram, defaultDeps } from "./program.js";
|
|
6
|
+
import { CkanApiError, CkanError } from "../client/errors.js";
|
|
7
|
+
/**
|
|
8
|
+
* Apply exitOverride + output redirection to every command in the tree.
|
|
9
|
+
* commander does not propagate these to subcommands, so a parse error on a
|
|
10
|
+
* subcommand would otherwise call process.exit() and bypass our error handling.
|
|
11
|
+
*/
|
|
12
|
+
function configureTree(command, deps) {
|
|
13
|
+
command.exitOverride();
|
|
14
|
+
command.configureOutput({
|
|
15
|
+
writeOut: (str) => deps.io.out(str.replace(/\n$/, "")),
|
|
16
|
+
writeErr: (str) => deps.io.err(str.replace(/\n$/, "")),
|
|
17
|
+
});
|
|
18
|
+
for (const child of command.commands)
|
|
19
|
+
configureTree(child, deps);
|
|
20
|
+
}
|
|
21
|
+
export async function run(argv, deps = defaultDeps) {
|
|
22
|
+
const program = buildProgram(deps);
|
|
23
|
+
configureTree(program, deps);
|
|
24
|
+
try {
|
|
25
|
+
await program.parseAsync(argv, { from: "user" });
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if (err instanceof CommanderError) {
|
|
30
|
+
// Help/version requests exit 0; genuine parse errors carry their own code.
|
|
31
|
+
return err.exitCode;
|
|
32
|
+
}
|
|
33
|
+
if (err instanceof CkanApiError) {
|
|
34
|
+
deps.io.err(`Error: ${err.message}`);
|
|
35
|
+
// Map a few notable statuses to distinct exit codes for scripting.
|
|
36
|
+
if (err.status === 404)
|
|
37
|
+
return 4;
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
if (err instanceof CkanError) {
|
|
41
|
+
deps.io.err(`Error: ${err.message}`);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
deps.io.err(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/cli/run.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,+DAA+D;AAE/D,OAAO,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAAgB,EAAE,IAAa;IACpD,OAAO,CAAC,YAAY,EAAE,CAAC;IACvB,OAAO,CAAC,eAAe,CAAC;QACtB,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACtD,QAAQ,EAAE,CAAC,GAAG,E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C,EAAE,CAAC,CAAC;QACrF,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CliDeps } from "./io.js";
|
|
2
|
+
import type { EngineOptions } from "../client/engine.js";
|
|
3
|
+
/** commander value-parser: a non-negative integer. */
|
|
4
|
+
export declare function parseIntArg(value: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* commander value-parser: a value that is not blank. A blank filter would
|
|
7
|
+
* otherwise be dropped and the command would silently run unfiltered.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseNonEmpty(value: string): string;
|
|
10
|
+
/** commander accumulator for a repeatable option whose values must not be blank. */
|
|
11
|
+
export declare function collectNonEmpty(value: string, previous?: string[]): string[];
|
|
12
|
+
/** Build a commander value-parser for a non-negative integer within [min, max]. */
|
|
13
|
+
export declare function parseBoundedInt(min: number, max: number): (value: string) => number;
|
|
14
|
+
/**
|
|
15
|
+
* commander value-parser for --base-url: reject a non-http(s) scheme at parse
|
|
16
|
+
* time so `file:`, `ftp:`, etc. fail fast with a usage error rather than only
|
|
17
|
+
* being caught later in the transport. The default transport also re-checks the
|
|
18
|
+
* scheme per hop (and RequestEngine.buildUrl guards it for custom transports),
|
|
19
|
+
* but this surfaces the mistake up front and independently of the transport.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseBaseUrl(value: string): string;
|
|
22
|
+
/** commander value-parser for --portal: the URL of a portal in the built-in list. */
|
|
23
|
+
export declare function parsePortal(value: string): string;
|
|
24
|
+
export interface GlobalOptions {
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** The URL of the portal chosen with --portal. */
|
|
27
|
+
portal?: string;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
maxResponseBytes?: number;
|
|
32
|
+
compact?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Translate resolved global CLI options into client EngineOptions. */
|
|
35
|
+
export declare function toEngineOptions(global: GlobalOptions): EngineOptions;
|
|
36
|
+
/**
|
|
37
|
+
* Escape the control characters JSON.stringify leaves raw. It escapes C0 (including
|
|
38
|
+
* ESC) but not DEL or the C1 range U+0080–U+009F, and terminals may act on those —
|
|
39
|
+
* U+009B is the 8-bit form of CSI. The output is server data, so escape them; the
|
|
40
|
+
* result is equivalent, valid JSON (these characters only occur inside strings).
|
|
41
|
+
* Checked by char code so the source stays free of control bytes.
|
|
42
|
+
*/
|
|
43
|
+
export declare function escapeControlChars(json: string): string;
|
|
44
|
+
/** Render a JSON value to stdout, pretty by default, compact with --compact. */
|
|
45
|
+
export declare function renderJson(deps: CliDeps, global: GlobalOptions, value: unknown): void;
|
|
46
|
+
export interface ActionContext {
|
|
47
|
+
client: ReturnType<CliDeps["createClient"]>;
|
|
48
|
+
global: GlobalOptions;
|
|
49
|
+
/** This command's own parsed options. */
|
|
50
|
+
opts: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Wrap an async command action with consistent global-option resolution and
|
|
54
|
+
* client construction. The callback receives a context (client + resolved global
|
|
55
|
+
* options + this command's options) and the command's positional arguments.
|
|
56
|
+
*
|
|
57
|
+
* Commander invokes actions as (arg1, ..., argN, options, command); we slice off
|
|
58
|
+
* the trailing options object and command instance to recover the positionals.
|
|
59
|
+
*/
|
|
60
|
+
export declare function action(deps: CliDeps, fn: (ctx: ActionContext, positionals: string[]) => Promise<void>): (...args: unknown[]) => Promise<void>;
|
|
61
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cli/shared.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,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E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/D,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAQvC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Shared helpers used across CLI command groups: option parsers, the global
|
|
2
|
+
// option resolver, and the JSON result renderer.
|
|
3
|
+
import { InvalidArgumentError } from "commander";
|
|
4
|
+
import { findPortal } from "../client/portals.js";
|
|
5
|
+
import { PORTALS } from "../client/portals-list.js";
|
|
6
|
+
/** commander value-parser: a non-negative integer. */
|
|
7
|
+
export function parseIntArg(value) {
|
|
8
|
+
// Validate the literal shape rather than trusting Number(): that rejects
|
|
9
|
+
// empty/whitespace ("" and " " coerce to 0), hex (0x10) and exponent (1e3)
|
|
10
|
+
// notation, all of which Number() would silently accept.
|
|
11
|
+
if (!/^\d+$/.test(value)) {
|
|
12
|
+
throw new InvalidArgumentError("Expected a non-negative integer.");
|
|
13
|
+
}
|
|
14
|
+
const n = Number(value);
|
|
15
|
+
// Reject magnitudes that cannot be represented exactly (silent precision loss).
|
|
16
|
+
if (!Number.isSafeInteger(n)) {
|
|
17
|
+
throw new InvalidArgumentError("Expected a non-negative integer.");
|
|
18
|
+
}
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* commander value-parser: a value that is not blank. A blank filter would
|
|
23
|
+
* otherwise be dropped and the command would silently run unfiltered.
|
|
24
|
+
*/
|
|
25
|
+
export function parseNonEmpty(value) {
|
|
26
|
+
if (value.trim() === "") {
|
|
27
|
+
throw new InvalidArgumentError("Expected a non-empty value.");
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/** commander accumulator for a repeatable option whose values must not be blank. */
|
|
32
|
+
export function collectNonEmpty(value, previous = []) {
|
|
33
|
+
return previous.concat([parseNonEmpty(value)]);
|
|
34
|
+
}
|
|
35
|
+
/** Build a commander value-parser for a non-negative integer within [min, max]. */
|
|
36
|
+
export function parseBoundedInt(min, max) {
|
|
37
|
+
return (value) => {
|
|
38
|
+
const n = parseIntArg(value);
|
|
39
|
+
if (n < min)
|
|
40
|
+
throw new InvalidArgumentError(`Must be >= ${min}.`);
|
|
41
|
+
if (n > max)
|
|
42
|
+
throw new InvalidArgumentError(`Must be <= ${max}.`);
|
|
43
|
+
return n;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* commander value-parser for --base-url: reject a non-http(s) scheme at parse
|
|
48
|
+
* time so `file:`, `ftp:`, etc. fail fast with a usage error rather than only
|
|
49
|
+
* being caught later in the transport. The default transport also re-checks the
|
|
50
|
+
* scheme per hop (and RequestEngine.buildUrl guards it for custom transports),
|
|
51
|
+
* but this surfaces the mistake up front and independently of the transport.
|
|
52
|
+
*/
|
|
53
|
+
export function parseBaseUrl(value) {
|
|
54
|
+
let url;
|
|
55
|
+
try {
|
|
56
|
+
url = new URL(value);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new InvalidArgumentError("Expected an absolute http(s) URL.");
|
|
60
|
+
}
|
|
61
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
62
|
+
throw new InvalidArgumentError(`Unsupported scheme "${url.protocol}". Expected an http(s) URL.`);
|
|
63
|
+
}
|
|
64
|
+
if (/[?#]/.test(value)) {
|
|
65
|
+
throw new InvalidArgumentError("Expected a site URL without a query string or fragment.");
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
/** commander value-parser for --portal: the URL of a portal in the built-in list. */
|
|
70
|
+
export function parsePortal(value) {
|
|
71
|
+
const portal = findPortal(value, PORTALS);
|
|
72
|
+
if (!portal) {
|
|
73
|
+
throw new InvalidArgumentError(`Unknown portal "${value}". \`ckan portals\` lists the known ones.`);
|
|
74
|
+
}
|
|
75
|
+
return portal.url;
|
|
76
|
+
}
|
|
77
|
+
/** Translate resolved global CLI options into client EngineOptions. */
|
|
78
|
+
export function toEngineOptions(global) {
|
|
79
|
+
const options = {};
|
|
80
|
+
const baseUrl = global.portal ?? global.baseUrl;
|
|
81
|
+
if (baseUrl !== undefined)
|
|
82
|
+
options.baseUrl = baseUrl;
|
|
83
|
+
if (global.timeout !== undefined)
|
|
84
|
+
options.timeoutMs = global.timeout;
|
|
85
|
+
if (global.userAgent !== undefined)
|
|
86
|
+
options.userAgent = global.userAgent;
|
|
87
|
+
if (global.maxRetries !== undefined)
|
|
88
|
+
options.maxRetries = global.maxRetries;
|
|
89
|
+
if (global.maxResponseBytes !== undefined)
|
|
90
|
+
options.maxResponseBytes = global.maxResponseBytes;
|
|
91
|
+
return options;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Escape the control characters JSON.stringify leaves raw. It escapes C0 (including
|
|
95
|
+
* ESC) but not DEL or the C1 range U+0080–U+009F, and terminals may act on those —
|
|
96
|
+
* U+009B is the 8-bit form of CSI. The output is server data, so escape them; the
|
|
97
|
+
* result is equivalent, valid JSON (these characters only occur inside strings).
|
|
98
|
+
* Checked by char code so the source stays free of control bytes.
|
|
99
|
+
*/
|
|
100
|
+
export function escapeControlChars(json) {
|
|
101
|
+
let result = "";
|
|
102
|
+
let from = 0;
|
|
103
|
+
for (let i = 0; i < json.length; i++) {
|
|
104
|
+
const c = json.charCodeAt(i);
|
|
105
|
+
if (c >= 0x7f && c <= 0x9f) {
|
|
106
|
+
result += json.slice(from, i) + "\\u" + c.toString(16).padStart(4, "0");
|
|
107
|
+
from = i + 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return from === 0 ? json : result + json.slice(from);
|
|
111
|
+
}
|
|
112
|
+
/** Render a JSON value to stdout, pretty by default, compact with --compact. */
|
|
113
|
+
export function renderJson(deps, global, value) {
|
|
114
|
+
const text = escapeControlChars(global.compact ? JSON.stringify(value) : JSON.stringify(value, null, 2));
|
|
115
|
+
deps.io.out(text);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Wrap an async command action with consistent global-option resolution and
|
|
119
|
+
* client construction. The callback receives a context (client + resolved global
|
|
120
|
+
* options + this command's options) and the command's positional arguments.
|
|
121
|
+
*
|
|
122
|
+
* Commander invokes actions as (arg1, ..., argN, options, command); we slice off
|
|
123
|
+
* the trailing options object and command instance to recover the positionals.
|
|
124
|
+
*/
|
|
125
|
+
export function action(deps, fn) {
|
|
126
|
+
return async (...args) => {
|
|
127
|
+
const command = args[args.length - 1];
|
|
128
|
+
const positionals = args.slice(0, Math.max(0, args.length - 2));
|
|
129
|
+
const global = command.optsWithGlobals();
|
|
130
|
+
const client = deps.createClient(toEngineOptions(global));
|
|
131
|
+
await fn({ client, global, opts: command.opts() }, positionals);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/cli/shared.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,iDAAiD;AAGjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,sDAAsD;AACtD,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,yEAAyE;IACzE,2EAA2E;IAC3E,yDAAyD;IACzD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,oBAAoB,CAAC,kCAAkC,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK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C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAY,CAAC;QACjD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAa,CAAC;QAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,EAAmB,CAAC;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type EngineOptions } from "./engine.js";
|
|
2
|
+
import type { QueryParams } from "./query.js";
|
|
3
|
+
import type { Group, GroupListParams, JsonValue, License, ListParams, Organization, Package, PackageSearchParams, PackageSearchResult, Resource, Status, TagListParams } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The site root of a CKAN instance, from what a user is likely to paste: portals
|
|
6
|
+
* document their API as `<site>/api/3/action`, so that suffix (or `/api/3`) is
|
|
7
|
+
* dropped. A CKAN mounted under a sub-path (`https://host/ckan`) keeps it. A
|
|
8
|
+
* query string or fragment is refused.
|
|
9
|
+
*/
|
|
10
|
+
export declare function siteRoot(baseUrl: string): string;
|
|
11
|
+
export declare class CkanClient {
|
|
12
|
+
private readonly engine;
|
|
13
|
+
/** The site this client talks to, for error messages. */
|
|
14
|
+
private readonly site;
|
|
15
|
+
constructor(options?: EngineOptions);
|
|
16
|
+
/** Call any CKAN action by name and return its unwrapped `result`. */
|
|
17
|
+
action<T = JsonValue>(name: string, params?: QueryParams): Promise<T>;
|
|
18
|
+
/** Site title, CKAN version and enabled extensions of the portal. */
|
|
19
|
+
status(): Promise<Status>;
|
|
20
|
+
/**
|
|
21
|
+
* Full-text / faceted dataset search.
|
|
22
|
+
*
|
|
23
|
+
* CKAN reads a repeated `fq=` key as a Python list and pastes it into the Solr
|
|
24
|
+
* filter, which fails with HTTP 409. So a single filter is sent as `fq`, and
|
|
25
|
+
* several as CKAN's `fq_list` (each its own Solr filter query; all must
|
|
26
|
+
* match). `fq_list` is only used for two or more, because CKAN splits a lone
|
|
27
|
+
* `fq_list` value into characters. Facet fields go out as the JSON list CKAN
|
|
28
|
+
* expects in `facet.field`.
|
|
29
|
+
*/
|
|
30
|
+
packageSearch(params?: PackageSearchParams): Promise<PackageSearchResult>;
|
|
31
|
+
/** A single dataset by id or name. */
|
|
32
|
+
packageShow(id: string): Promise<Package>;
|
|
33
|
+
/** A single organization (publisher) by id or name. */
|
|
34
|
+
organizationShow(id: string): Promise<Organization>;
|
|
35
|
+
/** A single group (theme/category) by id or name. */
|
|
36
|
+
groupShow(id: string): Promise<Group>;
|
|
37
|
+
/** A single resource (distribution) by id. */
|
|
38
|
+
resourceShow(id: string): Promise<Resource>;
|
|
39
|
+
/** Dataset names, paged with limit/offset. */
|
|
40
|
+
packageList(params?: ListParams): Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Organization names, or full objects with `all_fields`. See `groupOrOrgList`
|
|
43
|
+
* for how an `all_fields` list is completed.
|
|
44
|
+
*/
|
|
45
|
+
organizationList(params?: GroupListParams): Promise<JsonValue[]>;
|
|
46
|
+
/** Group names, or full objects with `all_fields` (paged like organizationList). */
|
|
47
|
+
groupList(params?: GroupListParams): Promise<JsonValue[]>;
|
|
48
|
+
/** Tags, optionally only those containing a substring. */
|
|
49
|
+
tagList(params?: TagListParams): Promise<string[]>;
|
|
50
|
+
/** The licences this portal offers. */
|
|
51
|
+
licenseList(): Promise<License[]>;
|
|
52
|
+
/**
|
|
53
|
+
* `organization_list` / `group_list`. CKAN caps an `all_fields` list at
|
|
54
|
+
* `ckan.group_and_organization_list_all_fields_max` (25 by default) and
|
|
55
|
+
* silently drops the rest, even when a larger `limit` is asked for. So an
|
|
56
|
+
* `all_fields` list is fetched page by page until the server returns an empty
|
|
57
|
+
* page (or `limit` entries are collected). The next offset advances by the
|
|
58
|
+
* number of entries returned, which stays correct on a portal with a lower
|
|
59
|
+
* cap; a page can also come back short without being the last (Berlin hides
|
|
60
|
+
* some entries), so only an empty page ends the list. Entries are deduplicated
|
|
61
|
+
* (by `id`), and a page that adds nothing new ends the loop too, so a server
|
|
62
|
+
* that ignores `offset` cannot keep it going.
|
|
63
|
+
*/
|
|
64
|
+
private groupOrOrgList;
|
|
65
|
+
/**
|
|
66
|
+
* A `*_show` call. A blank id is rejected up front: `prune` would drop it and
|
|
67
|
+
* CKAN would answer with a 409 validation error instead.
|
|
68
|
+
*/
|
|
69
|
+
private show;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAEV,KAAK,EACL,eAAe,EACf,SAAS,EACT,OAAO,EACP,UAAU,EACV,YAAY,EACZ,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,aAAa,EACd,MAAM,YAAY,CAAC;AAsCpB;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAE9B,YAAY,OAAO,GAAE,aAAkB,EAGtC;IAED,sEAAsE;IAChE,MAAM,CAAC,CA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`).
|
|
3
|
+
import { DEFAULT_BASE_URL, RequestEngine } from "./engine.js";
|
|
4
|
+
import { CkanError, CkanParseError, describeCkanError } from "./errors.js";
|
|
5
|
+
const ACTION = "/api/3/action";
|
|
6
|
+
/**
|
|
7
|
+
* CKAN action names are always `[a-z0-9_]+`. Restricting to that allowlist closes
|
|
8
|
+
* the path-traversal hole (`../../..` escaping `/api/3/action/`) and the
|
|
9
|
+
* query/fragment-injection hole (a `?`/`#` in the name corrupting the query) for
|
|
10
|
+
* both the library and the CLI's generic `action` command.
|
|
11
|
+
*/
|
|
12
|
+
const ACTION_NAME = /^[a-z0-9_]+$/;
|
|
13
|
+
/** CKAN's default cap on an `all_fields` organization/group list. */
|
|
14
|
+
const ALL_FIELDS_PAGE = 25;
|
|
15
|
+
/** A key for a list entry — its `id`, else its JSON — to drop duplicates across pages. */
|
|
16
|
+
function entryKey(entry) {
|
|
17
|
+
if (typeof entry === "object" && entry !== null && !Array.isArray(entry)) {
|
|
18
|
+
const id = entry["id"];
|
|
19
|
+
if (typeof id === "string")
|
|
20
|
+
return `id:${id}`;
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(entry);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Drop undefined (and empty-string) values so only the parameters the caller
|
|
26
|
+
* actually set are sent. An empty string filter (e.g. `tags --query ""`) is
|
|
27
|
+
* treated as "no filter" rather than forwarded as `query=`.
|
|
28
|
+
*/
|
|
29
|
+
function prune(params) {
|
|
30
|
+
const out = {};
|
|
31
|
+
for (const [k, v] of Object.entries(params)) {
|
|
32
|
+
if (v === undefined || v === "")
|
|
33
|
+
continue;
|
|
34
|
+
out[k] = v;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The site root of a CKAN instance, from what a user is likely to paste: portals
|
|
40
|
+
* document their API as `<site>/api/3/action`, so that suffix (or `/api/3`) is
|
|
41
|
+
* dropped. A CKAN mounted under a sub-path (`https://host/ckan`) keeps it. A
|
|
42
|
+
* query string or fragment is refused.
|
|
43
|
+
*/
|
|
44
|
+
export function siteRoot(baseUrl) {
|
|
45
|
+
// The API path is appended to the base URL, so a query string or fragment in it
|
|
46
|
+
// would end up in front of `/api/3/action` and break every request.
|
|
47
|
+
if (/[?#]/.test(baseUrl)) {
|
|
48
|
+
throw new CkanError(`The base URL must not contain a query string or fragment: ${baseUrl}`);
|
|
49
|
+
}
|
|
50
|
+
return baseUrl.replace(/\/+$/, "").replace(/\/api\/3(\/action)?$/, "");
|
|
51
|
+
}
|
|
52
|
+
export class CkanClient {
|
|
53
|
+
engine;
|
|
54
|
+
/** The site this client talks to, for error messages. */
|
|
55
|
+
site;
|
|
56
|
+
constructor(options = {}) {
|
|
57
|
+
this.site = siteRoot(options.baseUrl ?? DEFAULT_BASE_URL);
|
|
58
|
+
this.engine = new RequestEngine({ ...options, baseUrl: this.site });
|
|
59
|
+
}
|
|
60
|
+
/** Call any CKAN action by name and return its unwrapped `result`. */
|
|
61
|
+
async action(name, params = {}) {
|
|
62
|
+
if (!ACTION_NAME.test(name)) {
|
|
63
|
+
throw new CkanError(`Invalid CKAN action name: "${name}"`);
|
|
64
|
+
}
|
|
65
|
+
const env = await this.engine.getJson(`${ACTION}/${name}`, prune(params));
|
|
66
|
+
// Another JSON API at the same path (or a proxy's JSON error page) is not an
|
|
67
|
+
// envelope; say so rather than "failed: undefined".
|
|
68
|
+
if (typeof env !== "object" || env === null || Array.isArray(env) || typeof env.success !== "boolean") {
|
|
69
|
+
throw new CkanParseError(`The answer to "${name}" is not a CKAN Action API response; is ${this.site} a CKAN site?`);
|
|
70
|
+
}
|
|
71
|
+
if (!env.success) {
|
|
72
|
+
throw new CkanError(`CKAN action "${name}" failed: ${describeCkanError(env.error)}`);
|
|
73
|
+
}
|
|
74
|
+
return env.result;
|
|
75
|
+
}
|
|
76
|
+
/** Site title, CKAN version and enabled extensions of the portal. */
|
|
77
|
+
status() {
|
|
78
|
+
return this.action("status_show");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Full-text / faceted dataset search.
|
|
82
|
+
*
|
|
83
|
+
* CKAN reads a repeated `fq=` key as a Python list and pastes it into the Solr
|
|
84
|
+
* filter, which fails with HTTP 409. So a single filter is sent as `fq`, and
|
|
85
|
+
* several as CKAN's `fq_list` (each its own Solr filter query; all must
|
|
86
|
+
* match). `fq_list` is only used for two or more, because CKAN splits a lone
|
|
87
|
+
* `fq_list` value into characters. Facet fields go out as the JSON list CKAN
|
|
88
|
+
* expects in `facet.field`.
|
|
89
|
+
*/
|
|
90
|
+
packageSearch(params = {}) {
|
|
91
|
+
const fq = (params.fq ?? []).filter((f) => f !== "");
|
|
92
|
+
const facetFields = params.facet_field ?? [];
|
|
93
|
+
return this.action("package_search", {
|
|
94
|
+
q: params.q,
|
|
95
|
+
fq: fq.length === 1 ? fq[0] : undefined,
|
|
96
|
+
fq_list: fq.length > 1 ? fq : undefined,
|
|
97
|
+
rows: params.rows,
|
|
98
|
+
start: params.start,
|
|
99
|
+
sort: params.sort,
|
|
100
|
+
"facet.field": facetFields.length > 0 ? JSON.stringify(facetFields) : undefined,
|
|
101
|
+
"facet.limit": params.facet_limit,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** A single dataset by id or name. */
|
|
105
|
+
packageShow(id) {
|
|
106
|
+
return this.show("package_show", id);
|
|
107
|
+
}
|
|
108
|
+
/** A single organization (publisher) by id or name. */
|
|
109
|
+
organizationShow(id) {
|
|
110
|
+
return this.show("organization_show", id);
|
|
111
|
+
}
|
|
112
|
+
/** A single group (theme/category) by id or name. */
|
|
113
|
+
groupShow(id) {
|
|
114
|
+
return this.show("group_show", id);
|
|
115
|
+
}
|
|
116
|
+
/** A single resource (distribution) by id. */
|
|
117
|
+
resourceShow(id) {
|
|
118
|
+
return this.show("resource_show", id);
|
|
119
|
+
}
|
|
120
|
+
/** Dataset names, paged with limit/offset. */
|
|
121
|
+
packageList(params = {}) {
|
|
122
|
+
return this.action("package_list", { limit: params.limit, offset: params.offset });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Organization names, or full objects with `all_fields`. See `groupOrOrgList`
|
|
126
|
+
* for how an `all_fields` list is completed.
|
|
127
|
+
*/
|
|
128
|
+
organizationList(params = {}) {
|
|
129
|
+
return this.groupOrOrgList("organization_list", params);
|
|
130
|
+
}
|
|
131
|
+
/** Group names, or full objects with `all_fields` (paged like organizationList). */
|
|
132
|
+
groupList(params = {}) {
|
|
133
|
+
return this.groupOrOrgList("group_list", params);
|
|
134
|
+
}
|
|
135
|
+
/** Tags, optionally only those containing a substring. */
|
|
136
|
+
tagList(params = {}) {
|
|
137
|
+
return this.action("tag_list", { query: params.query });
|
|
138
|
+
}
|
|
139
|
+
/** The licences this portal offers. */
|
|
140
|
+
licenseList() {
|
|
141
|
+
return this.action("license_list");
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* `organization_list` / `group_list`. CKAN caps an `all_fields` list at
|
|
145
|
+
* `ckan.group_and_organization_list_all_fields_max` (25 by default) and
|
|
146
|
+
* silently drops the rest, even when a larger `limit` is asked for. So an
|
|
147
|
+
* `all_fields` list is fetched page by page until the server returns an empty
|
|
148
|
+
* page (or `limit` entries are collected). The next offset advances by the
|
|
149
|
+
* number of entries returned, which stays correct on a portal with a lower
|
|
150
|
+
* cap; a page can also come back short without being the last (Berlin hides
|
|
151
|
+
* some entries), so only an empty page ends the list. Entries are deduplicated
|
|
152
|
+
* (by `id`), and a page that adds nothing new ends the loop too, so a server
|
|
153
|
+
* that ignores `offset` cannot keep it going.
|
|
154
|
+
*/
|
|
155
|
+
async groupOrOrgList(action, params) {
|
|
156
|
+
if (!params.all_fields) {
|
|
157
|
+
return this.action(action, { limit: params.limit, offset: params.offset });
|
|
158
|
+
}
|
|
159
|
+
const wanted = params.limit ?? Infinity;
|
|
160
|
+
let offset = params.offset ?? 0;
|
|
161
|
+
const seen = new Set();
|
|
162
|
+
const out = [];
|
|
163
|
+
while (out.length < wanted) {
|
|
164
|
+
const page = await this.action(action, {
|
|
165
|
+
all_fields: true,
|
|
166
|
+
limit: Math.min(ALL_FIELDS_PAGE, wanted - out.length),
|
|
167
|
+
offset: offset === 0 ? undefined : offset,
|
|
168
|
+
});
|
|
169
|
+
let added = 0;
|
|
170
|
+
for (const entry of page) {
|
|
171
|
+
const key = entryKey(entry);
|
|
172
|
+
if (seen.has(key))
|
|
173
|
+
continue;
|
|
174
|
+
seen.add(key);
|
|
175
|
+
out.push(entry);
|
|
176
|
+
added += 1;
|
|
177
|
+
}
|
|
178
|
+
if (page.length === 0 || added === 0)
|
|
179
|
+
break;
|
|
180
|
+
offset += page.length;
|
|
181
|
+
}
|
|
182
|
+
return out.slice(0, wanted);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A `*_show` call. A blank id is rejected up front: `prune` would drop it and
|
|
186
|
+
* CKAN would answer with a 409 validation error instead.
|
|
187
|
+
*/
|
|
188
|
+
async show(action, id) {
|
|
189
|
+
if (id.trim() === "")
|
|
190
|
+
throw new CkanError(`${action} needs an id or name.`);
|
|
191
|
+
return this.action(action, { id });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,sCAAsC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAkB3E,MAAM,MAAM,GAAG,eAAe,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC,qEAAqE;AACrE,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,0FAA0F;AAC1F,SAAS,QAAQ,CAAC,KAAgB;IA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