@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/core",
3
- "version": "0.22.6",
3
+ "version": "0.22.7",
4
4
  "description": "Shared React core for the RoboSystems apps",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -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 a missing schema or one with no nodes is refused before any request.
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
- var _a;
134
- const nodes = (_a = graphData.custom_schema) === null || _a === void 0 ? void 0 : _a.nodes;
135
- if (!graphData.custom_schema || !Array.isArray(nodes) || nodes.length === 0) {
136
- throw new Error('A generic graph needs a schema that defines at least one node.');
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 graphData.custom_schema;
140
+ return schema;
139
141
  }
140
142
  /**
141
143
  * Hook for graph creation using the new unified endpoint