@robosystems/core 0.22.6 → 0.22.7
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/package.json
CHANGED
|
@@ -47,7 +47,7 @@ export declare function useGraphCreation(): {
|
|
|
47
47
|
schema_extensions?: string[];
|
|
48
48
|
/**
|
|
49
49
|
* Generic graphs only, and required for them: the node/relationship
|
|
50
|
-
* schema to apply, with at least one node
|
|
50
|
+
* schema to apply, with at least one node unless it extends `base`.
|
|
51
51
|
*/
|
|
52
52
|
custom_schema?: Record<string, unknown>;
|
|
53
53
|
create_entity?: boolean;
|
|
@@ -127,15 +127,17 @@ export function useOperationMonitoring() {
|
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* The schema of a generic graph. A graph cannot be provisioned without a node
|
|
130
|
-
* table, so
|
|
130
|
+
* table, so the API's rule is applied before any request: a schema defines at
|
|
131
|
+
* least one node, or extends `base`, which brings the base tables with it.
|
|
131
132
|
*/
|
|
132
133
|
function genericSchema(graphData) {
|
|
133
|
-
|
|
134
|
-
const nodes =
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const schema = graphData.custom_schema;
|
|
135
|
+
const nodes = schema === null || schema === void 0 ? void 0 : schema.nodes;
|
|
136
|
+
const hasNodes = Array.isArray(nodes) && nodes.length > 0;
|
|
137
|
+
if (!schema || (!hasNodes && schema.extends !== 'base')) {
|
|
138
|
+
throw new Error("A generic graph needs a schema that defines at least one node, or extends 'base'.");
|
|
137
139
|
}
|
|
138
|
-
return
|
|
140
|
+
return schema;
|
|
139
141
|
}
|
|
140
142
|
/**
|
|
141
143
|
* Hook for graph creation using the new unified endpoint
|