@uipath/maestro-builder-sdk 6.4.0 → 6.5.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/dist/cli/commands/registry.js +68 -12
- package/dist/registry/archive/entry-policy.d.ts +36 -0
- package/dist/registry/archive/entry-policy.js +60 -0
- package/dist/registry/archive/extract.d.ts +31 -0
- package/dist/registry/archive/extract.js +92 -0
- package/dist/registry/archive/zip-reader.d.ts +38 -0
- package/dist/registry/archive/zip-reader.js +256 -0
- package/dist/registry/codecs/pyjson.d.ts +62 -0
- package/dist/registry/codecs/pyjson.js +208 -0
- package/dist/registry/compat/compare.d.ts +18 -0
- package/dist/registry/compat/compare.js +32 -0
- package/dist/registry/compat/paths.d.ts +4 -0
- package/dist/registry/compat/paths.js +17 -0
- package/dist/registry/compat/pystr.d.ts +50 -0
- package/dist/registry/compat/pystr.js +221 -0
- package/dist/registry/concurrency.d.ts +10 -0
- package/dist/registry/concurrency.js +34 -0
- package/dist/registry/curated-overlay.d.ts +36 -4
- package/dist/registry/curated-overlay.js +87 -14
- package/dist/registry/errors.d.ts +26 -0
- package/dist/registry/errors.js +38 -0
- package/dist/registry/extractor.d.ts +9 -10
- package/dist/registry/extractor.js +5 -15
- package/dist/registry/files.d.ts +26 -0
- package/dist/registry/files.js +160 -0
- package/dist/registry/generators/descriptors.d.ts +81 -0
- package/dist/registry/generators/descriptors.js +405 -0
- package/dist/registry/generators/fields.d.ts +46 -0
- package/dist/registry/generators/fields.js +111 -0
- package/dist/registry/generators/markdown/common.d.ts +21 -0
- package/dist/registry/generators/markdown/common.js +55 -0
- package/dist/registry/generators/markdown/index.d.ts +33 -0
- package/dist/registry/generators/markdown/index.js +37 -0
- package/dist/registry/generators/markdown/page.d.ts +8 -0
- package/dist/registry/generators/markdown/page.js +52 -0
- package/dist/registry/generators/markdown/pyvalue.d.ts +34 -0
- package/dist/registry/generators/markdown/pyvalue.js +106 -0
- package/dist/registry/generators/markdown/sections/choosing-object.d.ts +2 -0
- package/dist/registry/generators/markdown/sections/choosing-object.js +52 -0
- package/dist/registry/generators/markdown/sections/example.d.ts +22 -0
- package/dist/registry/generators/markdown/sections/example.js +295 -0
- package/dist/registry/generators/markdown/sections/filtering.d.ts +2 -0
- package/dist/registry/generators/markdown/sections/filtering.js +76 -0
- package/dist/registry/generators/markdown/sections/header.d.ts +2 -0
- package/dist/registry/generators/markdown/sections/header.js +37 -0
- package/dist/registry/generators/markdown/sections/inputs.d.ts +30 -0
- package/dist/registry/generators/markdown/sections/inputs.js +151 -0
- package/dist/registry/generators/markdown/sections/lookups.d.ts +12 -0
- package/dist/registry/generators/markdown/sections/lookups.js +150 -0
- package/dist/registry/generators/markdown/sections/outputs.d.ts +3 -0
- package/dist/registry/generators/markdown/sections/outputs.js +9 -0
- package/dist/registry/generators/markdown/sections/resolving-fields.d.ts +2 -0
- package/dist/registry/generators/markdown/sections/resolving-fields.js +139 -0
- package/dist/registry/generators/markdown/sections/schema-dynamic.d.ts +2 -0
- package/dist/registry/generators/markdown/sections/schema-dynamic.js +86 -0
- package/dist/registry/generators/materialize.d.ts +30 -0
- package/dist/registry/generators/materialize.js +132 -0
- package/dist/registry/generators/md-symbols.d.ts +22 -0
- package/dist/registry/generators/md-symbols.js +58 -0
- package/dist/registry/generators/triggers.d.ts +15 -0
- package/dist/registry/generators/triggers.js +85 -0
- package/dist/registry/generators/type-registry.d.ts +50 -0
- package/dist/registry/generators/type-registry.js +154 -0
- package/dist/registry/generators/type-tree.d.ts +65 -0
- package/dist/registry/generators/type-tree.js +179 -0
- package/dist/registry/library-build/build.d.ts +57 -0
- package/dist/registry/library-build/build.js +286 -0
- package/dist/registry/library-build/canonical.d.ts +119 -0
- package/dist/registry/library-build/canonical.js +512 -0
- package/dist/registry/library-build/cli.d.ts +45 -0
- package/dist/registry/library-build/cli.js +182 -0
- package/dist/registry/library-build/context.d.ts +107 -0
- package/dist/registry/library-build/context.js +267 -0
- package/dist/registry/library-build/enrich.d.ts +36 -0
- package/dist/registry/library-build/enrich.js +158 -0
- package/dist/registry/library-build/events.d.ts +108 -0
- package/dist/registry/library-build/events.js +476 -0
- package/dist/registry/library-build/generic-expand.d.ts +77 -0
- package/dist/registry/library-build/generic-expand.js +363 -0
- package/dist/registry/library-build/plan.d.ts +71 -0
- package/dist/registry/library-build/plan.js +270 -0
- package/dist/registry/library-build/py.d.ts +45 -0
- package/dist/registry/library-build/py.js +167 -0
- package/dist/registry/library-build/schema-action.d.ts +38 -0
- package/dist/registry/library-build/schema-action.js +107 -0
- package/dist/registry/library-build/write.d.ts +6 -0
- package/dist/registry/library-build/write.js +26 -0
- package/dist/registry/library-reader.d.ts +20 -0
- package/dist/registry/library-reader.js +50 -0
- package/dist/registry/lookup-specs.d.ts +55 -0
- package/dist/registry/lookup-specs.js +140 -0
- package/dist/registry/materialize-cli.js +28 -14
- package/dist/registry/materializer.d.ts +25 -3
- package/dist/registry/materializer.js +45 -29
- package/dist/registry/model/library.d.ts +254 -0
- package/dist/registry/model/library.js +23 -0
- package/dist/registry/naming.d.ts +54 -0
- package/dist/registry/naming.js +142 -0
- package/dist/registry/orphans.d.ts +4 -0
- package/dist/registry/orphans.js +86 -0
- package/dist/registry/prepare/actions.d.ts +26 -0
- package/dist/registry/prepare/actions.js +94 -0
- package/dist/registry/prepare/connections.d.ts +181 -0
- package/dist/registry/prepare/connections.js +399 -0
- package/dist/registry/prepare/event.d.ts +96 -0
- package/dist/registry/prepare/event.js +268 -0
- package/dist/registry/prepare/handoff.d.ts +21 -0
- package/dist/registry/prepare/handoff.js +91 -0
- package/dist/registry/prepare/ledger.d.ts +104 -0
- package/dist/registry/prepare/ledger.js +216 -0
- package/dist/registry/prepare/messages.d.ts +190 -0
- package/dist/registry/prepare/messages.js +472 -0
- package/dist/registry/prepare/objects.d.ts +130 -0
- package/dist/registry/prepare/objects.js +318 -0
- package/dist/registry/prepare/overlay.d.ts +149 -0
- package/dist/registry/prepare/overlay.js +487 -0
- package/dist/registry/prepare/parents.d.ts +41 -0
- package/dist/registry/prepare/parents.js +122 -0
- package/dist/registry/prepare/pipeline.d.ts +91 -0
- package/dist/registry/prepare/pipeline.js +376 -0
- package/dist/registry/prepare/regenerate.d.ts +9 -0
- package/dist/registry/prepare/regenerate.js +50 -0
- package/dist/registry/prepare/resolve.d.ts +199 -0
- package/dist/registry/prepare/resolve.js +470 -0
- package/dist/registry/prepare/retry.d.ts +83 -0
- package/dist/registry/prepare/retry.js +109 -0
- package/dist/registry/prepare/source-import.d.ts +54 -0
- package/dist/registry/prepare/source-import.js +192 -0
- package/dist/registry/prepare/support.d.ts +41 -0
- package/dist/registry/prepare/support.js +178 -0
- package/dist/registry/prepare-cli.d.ts +16 -5
- package/dist/registry/prepare-cli.js +60 -53
- package/dist/registry/pull-cli.js +8 -7
- package/dist/registry/reporter.d.ts +26 -0
- package/dist/registry/reporter.js +41 -0
- package/dist/registry/uip/client.d.ts +99 -0
- package/dist/registry/uip/client.js +226 -0
- package/dist/registry/uip/commands.d.ts +40 -0
- package/dist/registry/uip/commands.js +80 -0
- package/dist/registry/uip/envelope.d.ts +37 -0
- package/dist/registry/uip/envelope.js +84 -0
- package/dist/registry/uip/response-cache.d.ts +28 -0
- package/dist/registry/uip/response-cache.js +57 -0
- package/lib/README.md +10 -8
- package/package.json +3 -3
- package/dist/generators/_connections.py +0 -331
- package/dist/generators/_events.py +0 -355
- package/dist/generators/_lookups.py +0 -114
- package/dist/generators/_naming.py +0 -185
- package/dist/generators/_objects.py +0 -299
- package/dist/generators/_resolve.py +0 -319
- package/dist/generators/convert_library_to_md.py +0 -1441
- package/dist/generators/extract_library.py +0 -125
- package/dist/generators/generate_connectors_ts.py +0 -936
- package/dist/generators/generate_library_json.py +0 -2527
- package/dist/generators/generate_triggers_ts.py +0 -110
- package/dist/generators/materialize_registry.py +0 -155
- package/dist/generators/prepare_connector.py +0 -1860
- package/dist/registry/python.d.ts +0 -26
- package/dist/registry/python.js +0 -46
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IndexRow, LibraryEntry, LibraryIndex, V1Definition } from "./model/library.js";
|
|
2
|
+
export interface LoadedLibrary {
|
|
3
|
+
/** The `library-json` directory. */
|
|
4
|
+
readonly dir: string;
|
|
5
|
+
readonly index: LibraryIndex;
|
|
6
|
+
/** `objectName`s the curated ledger declares connector-invariant. */
|
|
7
|
+
readonly invariant: ReadonlySet<string>;
|
|
8
|
+
entryPath(row: IndexRow): string;
|
|
9
|
+
v1defPath(row: IndexRow): string;
|
|
10
|
+
/** The canonical entry, or `undefined` when the file the index names is missing. */
|
|
11
|
+
readEntry(row: IndexRow): LibraryEntry | undefined;
|
|
12
|
+
/** The sidecar, unwrapped from a one-element list, or `undefined` when absent. */
|
|
13
|
+
readV1Def(row: IndexRow): V1Definition | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** `<path minus .json>.v1def.json`, the sidecar beside an entry. */
|
|
16
|
+
export declare function sidecarPath(entryRelativePath: string): string;
|
|
17
|
+
export declare function readJsonFile(path: string): unknown;
|
|
18
|
+
/** A sidecar may be `[definition]` in some snapshots; the definition is what callers want. */
|
|
19
|
+
export declare function unwrapV1Def(raw: unknown): V1Definition | undefined;
|
|
20
|
+
export declare function loadLibrary(dir: string): LoadedLibrary;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading an extracted `library-json/` tree.
|
|
3
|
+
*
|
|
4
|
+
* Every generator walks the same index and opens the same two files per
|
|
5
|
+
* operation. This is that walk, once, with the path rules the Python spelled in
|
|
6
|
+
* three places: the entry is `index.json`'s `path`, the sidecar is the same path
|
|
7
|
+
* with `.json` swapped for `.v1def.json`, and a sidecar that is a one-element
|
|
8
|
+
* list is unwrapped.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { loadInvariantCollections } from "./lookup-specs.js";
|
|
13
|
+
/** `<path minus .json>.v1def.json`, the sidecar beside an entry. */
|
|
14
|
+
export function sidecarPath(entryRelativePath) {
|
|
15
|
+
return `${entryRelativePath.slice(0, -".json".length)}.v1def.json`;
|
|
16
|
+
}
|
|
17
|
+
export function readJsonFile(path) {
|
|
18
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
19
|
+
}
|
|
20
|
+
/** A sidecar may be `[definition]` in some snapshots; the definition is what callers want. */
|
|
21
|
+
export function unwrapV1Def(raw) {
|
|
22
|
+
if (Array.isArray(raw))
|
|
23
|
+
return (raw[0] ?? undefined);
|
|
24
|
+
if (raw && typeof raw === "object")
|
|
25
|
+
return raw;
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
export function loadLibrary(dir) {
|
|
29
|
+
const indexPath = join(dir, "index.json");
|
|
30
|
+
if (!existsSync(indexPath)) {
|
|
31
|
+
throw new Error(`library missing index.json: ${indexPath}`);
|
|
32
|
+
}
|
|
33
|
+
const index = readJsonFile(indexPath);
|
|
34
|
+
const invariant = loadInvariantCollections(dir);
|
|
35
|
+
return {
|
|
36
|
+
dir,
|
|
37
|
+
index,
|
|
38
|
+
invariant,
|
|
39
|
+
entryPath: (row) => join(dir, row.path),
|
|
40
|
+
v1defPath: (row) => join(dir, sidecarPath(row.path)),
|
|
41
|
+
readEntry(row) {
|
|
42
|
+
const path = join(dir, row.path);
|
|
43
|
+
return existsSync(path) ? readJsonFile(path) : undefined;
|
|
44
|
+
},
|
|
45
|
+
readV1Def(row) {
|
|
46
|
+
const path = join(dir, sidecarPath(row.path));
|
|
47
|
+
return existsSync(path) ? unwrapV1Def(readJsonFile(path)) : undefined;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FieldReference, LibraryField } from "./model/library.js";
|
|
2
|
+
export declare const LEDGER_FILENAME = "invariant-collections.json";
|
|
3
|
+
/**
|
|
4
|
+
* The ledger's `objectName` set, or an empty set. An absent or malformed
|
|
5
|
+
* ledger reads as empty rather than raising: the permissive path is the
|
|
6
|
+
* pre-ledger behaviour, so a bad edit loses exactness, never a build.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadInvariantCollections(libraryDir: string | undefined): Set<string>;
|
|
9
|
+
/** The field's `reference` block when it declares a resolvable value. */
|
|
10
|
+
export declare function referenceOf(field: {
|
|
11
|
+
reference?: unknown;
|
|
12
|
+
}): FieldReference | undefined;
|
|
13
|
+
/** True when resolving would return the value it was given. */
|
|
14
|
+
export declare function isIdentityLookup(reference: FieldReference): boolean;
|
|
15
|
+
export type LookupClass = "none" | "identity" | "invariant" | "lookup";
|
|
16
|
+
/** Only `'lookup'` earns a helper and a `--resolve`. */
|
|
17
|
+
export declare function classify(field: {
|
|
18
|
+
reference?: unknown;
|
|
19
|
+
}, invariant: ReadonlySet<string>): LookupClass;
|
|
20
|
+
/** The subset of `fields` that earns a `.by*` helper, in declaration order. */
|
|
21
|
+
export declare function resolvableLookupFields<F extends {
|
|
22
|
+
reference?: unknown;
|
|
23
|
+
}>(fields: readonly F[], invariant: ReadonlySet<string>): F[];
|
|
24
|
+
export type LookupStrategy = "dependent" | "filter" | "tree" | "scan";
|
|
25
|
+
/**
|
|
26
|
+
* Which retrieval strategy `prepare` uses. `dependsOn` wins outright because it
|
|
27
|
+
* is a prerequisite, not an optimisation; then a server-side filter beats a
|
|
28
|
+
* tree walk beats a full scan.
|
|
29
|
+
*/
|
|
30
|
+
export declare function lookupStrategy(reference: FieldReference): LookupStrategy;
|
|
31
|
+
/** One lookup field's retrieval contract, as the generated descriptor carries it. */
|
|
32
|
+
export interface LookupSpecData {
|
|
33
|
+
path: string;
|
|
34
|
+
by: string[];
|
|
35
|
+
value: string;
|
|
36
|
+
/** Insertion-ordered: the order of `lookupNames`. */
|
|
37
|
+
aliases: Map<string, string>;
|
|
38
|
+
strategy: LookupStrategy;
|
|
39
|
+
objectName?: string;
|
|
40
|
+
dependsOn?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `{ fieldName → spec }` for the lookup-bearing fields of any field list.
|
|
44
|
+
*
|
|
45
|
+
* `catalogReferences` supplies a `reference` for a field whose authoring
|
|
46
|
+
* vocabulary lacks one: the two declarations disagree about which fields they
|
|
47
|
+
* carry, and a lookup declared only in the catalog is still a lookup.
|
|
48
|
+
*/
|
|
49
|
+
export declare function specsFromFields(fields: readonly LibraryField[], invariant: ReadonlySet<string>, catalogReferences?: ReadonlyMap<string, FieldReference>): Map<string, LookupSpecData>;
|
|
50
|
+
/** The `reference` blocks the catalog's `inputSchema.fields` declare, by name. */
|
|
51
|
+
export declare function catalogReferences(entry: {
|
|
52
|
+
inputSchema?: {
|
|
53
|
+
fields?: LibraryField[];
|
|
54
|
+
} | null;
|
|
55
|
+
}): Map<string, FieldReference>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which connector input fields earn a `.by*` helper, and what the helper needs.
|
|
3
|
+
*
|
|
4
|
+
* A `reference` with a `lookupValue` says a field's value is an opaque id to be
|
|
5
|
+
* resolved against a live connection. Two classes are excluded: IDENTITY
|
|
6
|
+
* lookups, where `lookupValue` is the only `lookupNames` entry so resolving
|
|
7
|
+
* returns what it was given, and INVARIANT collections, whose ids are a property
|
|
8
|
+
* of the connector's API rather than of a connection (a country list), read from
|
|
9
|
+
* the curated `invariant-collections.json` ledger. Everything else is a lookup;
|
|
10
|
+
* the fallback direction is the safe one.
|
|
11
|
+
*
|
|
12
|
+
* Ported from `integrations/scripts/_lookups.py` and the `lookup_specs` half of
|
|
13
|
+
* `generate_connectors_ts.py`. `core/lookups.ts` keeps `check` and `compile`
|
|
14
|
+
* agreeing with this by importing it.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { pyTruthy } from "./generators/type-tree.js";
|
|
19
|
+
import { byAliases } from "./naming.js";
|
|
20
|
+
export const LEDGER_FILENAME = "invariant-collections.json";
|
|
21
|
+
/**
|
|
22
|
+
* The ledger's `objectName` set, or an empty set. An absent or malformed
|
|
23
|
+
* ledger reads as empty rather than raising: the permissive path is the
|
|
24
|
+
* pre-ledger behaviour, so a bad edit loses exactness, never a build.
|
|
25
|
+
*/
|
|
26
|
+
export function loadInvariantCollections(libraryDir) {
|
|
27
|
+
if (!libraryDir)
|
|
28
|
+
return new Set();
|
|
29
|
+
const path = join(libraryDir, LEDGER_FILENAME);
|
|
30
|
+
if (!existsSync(path))
|
|
31
|
+
return new Set();
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return new Set();
|
|
38
|
+
}
|
|
39
|
+
const rows = parsed?.collections;
|
|
40
|
+
if (!Array.isArray(rows))
|
|
41
|
+
return new Set();
|
|
42
|
+
const out = new Set();
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
if (row && typeof row === "object" && typeof row.objectName === "string") {
|
|
45
|
+
out.add(row.objectName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
/** The field's `reference` block when it declares a resolvable value. */
|
|
51
|
+
export function referenceOf(field) {
|
|
52
|
+
const reference = field.reference;
|
|
53
|
+
if (!reference || typeof reference !== "object" || Array.isArray(reference))
|
|
54
|
+
return undefined;
|
|
55
|
+
// `not reference.get("lookupValue")`: an empty list or dict is "no value"
|
|
56
|
+
// in Python and would be "a value" to a bare JavaScript test.
|
|
57
|
+
if (!pyTruthy(reference.lookupValue))
|
|
58
|
+
return undefined;
|
|
59
|
+
return reference;
|
|
60
|
+
}
|
|
61
|
+
/** True when resolving would return the value it was given. */
|
|
62
|
+
export function isIdentityLookup(reference) {
|
|
63
|
+
const names = reference.lookupNames ?? [];
|
|
64
|
+
return names.length === 1 && reference.lookupValue !== undefined && names.includes(reference.lookupValue);
|
|
65
|
+
}
|
|
66
|
+
/** Only `'lookup'` earns a helper and a `--resolve`. */
|
|
67
|
+
export function classify(field, invariant) {
|
|
68
|
+
const reference = referenceOf(field);
|
|
69
|
+
if (!reference)
|
|
70
|
+
return "none";
|
|
71
|
+
if (isIdentityLookup(reference))
|
|
72
|
+
return "identity";
|
|
73
|
+
if (reference.objectName !== undefined && invariant.has(reference.objectName))
|
|
74
|
+
return "invariant";
|
|
75
|
+
return "lookup";
|
|
76
|
+
}
|
|
77
|
+
/** The subset of `fields` that earns a `.by*` helper, in declaration order. */
|
|
78
|
+
export function resolvableLookupFields(fields, invariant) {
|
|
79
|
+
return fields.filter((f) => classify(f, invariant) === "lookup");
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Which retrieval strategy `prepare` uses. `dependsOn` wins outright because it
|
|
83
|
+
* is a prerequisite, not an optimisation; then a server-side filter beats a
|
|
84
|
+
* tree walk beats a full scan.
|
|
85
|
+
*/
|
|
86
|
+
export function lookupStrategy(reference) {
|
|
87
|
+
if (reference.dependsOn && reference.dependsOn.length > 0)
|
|
88
|
+
return "dependent";
|
|
89
|
+
if (reference.filterPattern)
|
|
90
|
+
return "filter";
|
|
91
|
+
if (reference.childPath)
|
|
92
|
+
return "tree";
|
|
93
|
+
return "scan";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `{ fieldName → spec }` for the lookup-bearing fields of any field list.
|
|
97
|
+
*
|
|
98
|
+
* `catalogReferences` supplies a `reference` for a field whose authoring
|
|
99
|
+
* vocabulary lacks one: the two declarations disagree about which fields they
|
|
100
|
+
* carry, and a lookup declared only in the catalog is still a lookup.
|
|
101
|
+
*/
|
|
102
|
+
export function specsFromFields(fields, invariant, catalogReferences) {
|
|
103
|
+
const specs = new Map();
|
|
104
|
+
for (const field of fields) {
|
|
105
|
+
const name = field.name;
|
|
106
|
+
if (!name)
|
|
107
|
+
continue;
|
|
108
|
+
let merged = field;
|
|
109
|
+
if (!(field.reference && typeof field.reference === "object") && catalogReferences?.has(name)) {
|
|
110
|
+
merged = { ...field, reference: catalogReferences.get(name) };
|
|
111
|
+
}
|
|
112
|
+
if (classify(merged, invariant) !== "lookup")
|
|
113
|
+
continue;
|
|
114
|
+
const reference = referenceOf(merged);
|
|
115
|
+
const names = (reference.lookupNames ?? []).map((n) => String(n));
|
|
116
|
+
const spec = {
|
|
117
|
+
path: reference.path || "",
|
|
118
|
+
by: names,
|
|
119
|
+
value: String(reference.lookupValue),
|
|
120
|
+
aliases: byAliases(names),
|
|
121
|
+
strategy: lookupStrategy(reference),
|
|
122
|
+
};
|
|
123
|
+
if (reference.objectName)
|
|
124
|
+
spec.objectName = String(reference.objectName);
|
|
125
|
+
if (reference.dependsOn && reference.dependsOn.length > 0)
|
|
126
|
+
spec.dependsOn = reference.dependsOn.map((d) => String(d));
|
|
127
|
+
specs.set(name, spec);
|
|
128
|
+
}
|
|
129
|
+
return specs;
|
|
130
|
+
}
|
|
131
|
+
/** The `reference` blocks the catalog's `inputSchema.fields` declare, by name. */
|
|
132
|
+
export function catalogReferences(entry) {
|
|
133
|
+
const out = new Map();
|
|
134
|
+
for (const field of entry.inputSchema?.fields ?? []) {
|
|
135
|
+
if (field.reference && typeof field.reference === "object" && field.name !== undefined) {
|
|
136
|
+
out.set(field.name, field.reference);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
@@ -1,46 +1,60 @@
|
|
|
1
|
+
import { exitCodeOf, messageOf } from "./errors.js";
|
|
1
2
|
import { materializeRegistry } from "./materializer.js";
|
|
2
3
|
/**
|
|
3
|
-
* Generate `library-md` and `connectors/` from an extracted `library-json`.
|
|
4
|
+
* Generate `library-md` and/or `connectors/` from an extracted `library-json`.
|
|
4
5
|
*
|
|
5
6
|
* Exposed as `run(argv)` rather than as a top-level script so the umbrella CLI
|
|
6
7
|
* can mount it the same way it mounts every other verb: `cli/common.ts` does
|
|
7
8
|
* `(await import(...)).run(argv)` and maps the returned code onto
|
|
8
|
-
* `process.exitCode`.
|
|
9
|
-
*
|
|
10
|
-
* this verb used to be reachable only through its own bin, and why the product
|
|
11
|
-
* CLI had to resolve that bin out of the package's `bin` map instead of
|
|
12
|
-
* delegating to `dist/cli/index.js` like it does for compile and check.
|
|
9
|
+
* `process.exitCode`. The `flow-registry-materialize` bin is a two-line shim
|
|
10
|
+
* over this function.
|
|
13
11
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* Either output may be omitted, but not both: an image build that already
|
|
13
|
+
* pulled the Markdown asks only for the descriptors, and a project that needs
|
|
14
|
+
* no descriptors asks only for the pages. `--python` and `--generator` are
|
|
15
|
+
* accepted for one release and ignored — nothing is spawned any more.
|
|
16
16
|
*/
|
|
17
|
-
const USAGE = "Usage: flow-sdk registry materialize --library-json <path> --library-md <path>
|
|
17
|
+
const USAGE = "Usage: flow-sdk registry materialize --library-json <path> [--library-md <path>] [--connectors <path>]\n" +
|
|
18
|
+
" [--import <specifier>] [--triggers <path>] [--connector-subset a,b]\n" +
|
|
19
|
+
" [--include-generic-expanded] [--check-symbols] [--check-orphans]";
|
|
20
|
+
const IGNORED = ["--python", "--generator"];
|
|
18
21
|
function value(args, name) {
|
|
19
22
|
const index = args.indexOf(name);
|
|
20
23
|
return index >= 0 ? args[index + 1] : undefined;
|
|
21
24
|
}
|
|
22
25
|
export async function run(argv) {
|
|
26
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
27
|
+
console.log(USAGE);
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
23
30
|
const libraryJsonPath = value(argv, "--library-json");
|
|
24
31
|
const libraryMarkdownPath = value(argv, "--library-md");
|
|
25
32
|
const connectorsPath = value(argv, "--connectors");
|
|
26
|
-
if (!libraryJsonPath || !libraryMarkdownPath
|
|
33
|
+
if (!libraryJsonPath || (!libraryMarkdownPath && !connectorsPath)) {
|
|
27
34
|
console.error(USAGE);
|
|
28
35
|
return 2;
|
|
29
36
|
}
|
|
37
|
+
for (const flag of IGNORED) {
|
|
38
|
+
if (argv.includes(flag)) {
|
|
39
|
+
console.error(`registry materialize: ${flag} is ignored — the generators run in-process now and the flag will be removed.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
30
42
|
try {
|
|
31
43
|
await materializeRegistry({
|
|
32
44
|
libraryJsonPath,
|
|
33
45
|
libraryMarkdownPath,
|
|
34
46
|
connectorsPath,
|
|
35
47
|
connectorImport: value(argv, "--import"),
|
|
36
|
-
pythonExecutable: value(argv, "--python"),
|
|
37
48
|
triggersPath: value(argv, "--triggers"),
|
|
38
|
-
|
|
49
|
+
connectorSubset: value(argv, "--connector-subset")?.split(",").filter((c) => c.length > 0),
|
|
50
|
+
includeGenericExpanded: argv.includes("--include-generic-expanded"),
|
|
51
|
+
checkSymbols: argv.includes("--check-symbols"),
|
|
52
|
+
checkOrphans: argv.includes("--check-orphans"),
|
|
39
53
|
});
|
|
40
54
|
return 0;
|
|
41
55
|
}
|
|
42
56
|
catch (error) {
|
|
43
|
-
console.error(
|
|
44
|
-
return
|
|
57
|
+
console.error(messageOf(error));
|
|
58
|
+
return exitCodeOf(error);
|
|
45
59
|
}
|
|
46
60
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type MaterializeResult } from "./generators/materialize.js";
|
|
2
|
+
import { type Reporter } from "./reporter.js";
|
|
1
3
|
export interface MaterializeRegistryOptions {
|
|
2
4
|
libraryJsonPath: string;
|
|
3
5
|
/** Where the Markdown goes. Omit to skip it — see `connectorsPath`. */
|
|
@@ -15,9 +17,29 @@ export interface MaterializeRegistryOptions {
|
|
|
15
17
|
*/
|
|
16
18
|
connectorSubset?: string[];
|
|
17
19
|
connectorImport?: string;
|
|
18
|
-
pythonExecutable?: string;
|
|
19
20
|
triggersPath?: string;
|
|
20
|
-
/**
|
|
21
|
+
/** Also emit descriptors for GenericExpanded entries. */
|
|
22
|
+
includeGenericExpanded?: boolean;
|
|
23
|
+
/** Fail when a Markdown page cites a symbol the descriptors do not export. */
|
|
24
|
+
checkSymbols?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Fail when an entry file has no `index.json` row, which makes it
|
|
27
|
+
* unresolvable. The image build asks for this; `registry pull` does not, and
|
|
28
|
+
* must not — see the call site for the live-library case that proves why.
|
|
29
|
+
*/
|
|
30
|
+
checkOrphans?: boolean;
|
|
31
|
+
reporter?: Reporter;
|
|
32
|
+
/** @deprecated No interpreter is involved any more; accepted and ignored. */
|
|
33
|
+
pythonExecutable?: string;
|
|
34
|
+
/** @deprecated The generators are part of the package; accepted and ignored. */
|
|
21
35
|
generatorPath?: string;
|
|
22
36
|
}
|
|
23
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Apply the SDK's curated corrections to an extracted library, then generate
|
|
39
|
+
* its Markdown and TypeScript views in-process.
|
|
40
|
+
*
|
|
41
|
+
* The product CLI downloads the raw registry archive and delegates directly to
|
|
42
|
+
* this API, so the corrections are applied here for every caller — including
|
|
43
|
+
* the connector start-trigger definitions absent from the raw dump.
|
|
44
|
+
*/
|
|
45
|
+
export declare function materializeRegistry(options: MaterializeRegistryOptions): Promise<MaterializeResult>;
|
|
@@ -1,34 +1,50 @@
|
|
|
1
|
-
import { packagedGenerator, runGenerator } from "./python.js";
|
|
2
1
|
import { applyCuratedOverlay } from "./curated-overlay.js";
|
|
2
|
+
import { assertNoOrphans } from "./orphans.js";
|
|
3
3
|
import { PACKAGE_NAME } from "../package-name.js";
|
|
4
|
+
import { materialize } from "./generators/materialize.js";
|
|
5
|
+
import { consoleReporter } from "./reporter.js";
|
|
6
|
+
/**
|
|
7
|
+
* Apply the SDK's curated corrections to an extracted library, then generate
|
|
8
|
+
* its Markdown and TypeScript views in-process.
|
|
9
|
+
*
|
|
10
|
+
* The product CLI downloads the raw registry archive and delegates directly to
|
|
11
|
+
* this API, so the corrections are applied here for every caller — including
|
|
12
|
+
* the connector start-trigger definitions absent from the raw dump.
|
|
13
|
+
*/
|
|
4
14
|
export async function materializeRegistry(options) {
|
|
5
|
-
// The
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
// The caller's reporter, forwarded: the overlay warns when it declines a
|
|
16
|
+
// correction the library resolves elsewhere, and a caller that asked for
|
|
17
|
+
// silence should not get that on stderr anyway.
|
|
18
|
+
await applyCuratedOverlay(options.libraryJsonPath, undefined, options.reporter ?? consoleReporter);
|
|
19
|
+
// OPT-IN, because this is the public API and `registry pull` comes through it.
|
|
20
|
+
//
|
|
21
|
+
// The check belongs to the image build, which is the only place the Python
|
|
22
|
+
// ever ran it (`unpack-library.sh`, never materialize_registry.py). Running it
|
|
23
|
+
// for every caller looked like a free upgrade and was not: the overlay used to
|
|
24
|
+
// copy four `event-*@1.0.0.json` files whose (nodeType, version) identity a
|
|
25
|
+
// LIVE library already carries at a different path, so no index row was added
|
|
26
|
+
// and the copy was an orphan by this definition. Against the committed zip
|
|
27
|
+
// those rows are missing and do get added, which is why the tests and the
|
|
28
|
+
// image stayed green while `registry pull` against a real registry threw.
|
|
29
|
+
//
|
|
30
|
+
// The overlay now declines that copy and warns, so this is no longer a trap —
|
|
31
|
+
// but it stays opt-in, because whether an unreachable entry file should fail
|
|
32
|
+
// the run is the image build's question rather than every caller's.
|
|
33
|
+
//
|
|
34
|
+
// It runs after the overlay, as the shell did: the overlay's job is to ADD the
|
|
35
|
+
// rows the raw dump lacks, so checking first would report orphans it is about
|
|
36
|
+
// to adopt.
|
|
37
|
+
if (options.checkOrphans)
|
|
38
|
+
assertNoOrphans(options.libraryJsonPath);
|
|
39
|
+
return materialize({
|
|
40
|
+
libraryJsonPath: options.libraryJsonPath,
|
|
41
|
+
libraryMarkdownPath: options.libraryMarkdownPath,
|
|
42
|
+
connectorsPath: options.connectorsPath,
|
|
43
|
+
connectorSubset: options.connectorSubset,
|
|
44
|
+
connectorImport: options.connectorImport ?? PACKAGE_NAME,
|
|
45
|
+
triggersPath: options.triggersPath,
|
|
46
|
+
includeGenericExpanded: options.includeGenericExpanded,
|
|
47
|
+
checkSymbols: options.checkSymbols,
|
|
48
|
+
reporter: options.reporter ?? consoleReporter,
|
|
33
49
|
});
|
|
34
50
|
}
|