@unified-product-graph/cloud-server 0.6.0 → 0.7.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/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/tools-manifest.json +11 -11
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -1284,7 +1284,7 @@ var getChanges = async (args, { store }) => {
|
|
|
1284
1284
|
};
|
|
1285
1285
|
|
|
1286
1286
|
// src/tools/nodes.ts
|
|
1287
|
-
import { getLifecycleForType as getLifecycleForType2 } from "@unified-product-graph/core";
|
|
1287
|
+
import { getLifecycleForType as getLifecycleForType2, resolveEntityType as resolveEntityType2, UnknownEntityTypeError as UnknownEntityTypeError2 } from "@unified-product-graph/core";
|
|
1288
1288
|
import {
|
|
1289
1289
|
inferEdgeTypeWithTier,
|
|
1290
1290
|
checkPropertyTypes,
|
|
@@ -1438,16 +1438,24 @@ var createNode = async (args, { store }) => {
|
|
|
1438
1438
|
if (!args.product_id) return textError(`Missing required parameter: product_id`);
|
|
1439
1439
|
if (!args.type) return textError(`Missing required parameter: type`);
|
|
1440
1440
|
if (!args.title) return textError(`Missing required parameter: title`);
|
|
1441
|
+
let resolvedType;
|
|
1442
|
+
try {
|
|
1443
|
+
resolvedType = resolveEntityType2(args.type);
|
|
1444
|
+
} catch (err) {
|
|
1445
|
+
if (err instanceof UnknownEntityTypeError2) return textError(err.message);
|
|
1446
|
+
throw err;
|
|
1447
|
+
}
|
|
1448
|
+
const canonicalType = resolvedType.canonical;
|
|
1441
1449
|
const productId = args.product_id;
|
|
1442
1450
|
const newNode = {
|
|
1443
1451
|
id: nodeId(),
|
|
1444
|
-
type:
|
|
1452
|
+
type: canonicalType,
|
|
1445
1453
|
title: args.title
|
|
1446
1454
|
};
|
|
1447
1455
|
if (args.description) newNode.description = args.description;
|
|
1448
1456
|
if (args.tags) newNode.tags = args.tags;
|
|
1449
1457
|
if (args.properties) newNode.properties = args.properties;
|
|
1450
|
-
const nodeType =
|
|
1458
|
+
const nodeType = canonicalType;
|
|
1451
1459
|
const nId = newNode.id;
|
|
1452
1460
|
const properties = newNode.properties;
|
|
1453
1461
|
const { violations } = checkPropertyTypes(nodeType, properties);
|
|
@@ -1460,6 +1468,9 @@ var createNode = async (args, { store }) => {
|
|
|
1460
1468
|
properties
|
|
1461
1469
|
});
|
|
1462
1470
|
const warnings = [...lengthWarnings];
|
|
1471
|
+
if (resolvedType.alias) {
|
|
1472
|
+
warnings.push(`Type "${resolvedType.alias.from}" is deprecated \u2014 using canonical "${resolvedType.alias.to}".`);
|
|
1473
|
+
}
|
|
1463
1474
|
if (args.status) {
|
|
1464
1475
|
newNode.status = args.status;
|
|
1465
1476
|
const lifecycle = getLifecycleForType2(nodeType);
|
|
@@ -2666,7 +2677,7 @@ var repairDanglingEdges = async (args, { store }) => {
|
|
|
2666
2677
|
};
|
|
2667
2678
|
|
|
2668
2679
|
// src/tools/batch.ts
|
|
2669
|
-
import { getLifecycleForType as getLifecycleForType3 } from "@unified-product-graph/core";
|
|
2680
|
+
import { getLifecycleForType as getLifecycleForType3, resolveEntityType as resolveEntityType3, UnknownEntityTypeError as UnknownEntityTypeError3 } from "@unified-product-graph/core";
|
|
2670
2681
|
import {
|
|
2671
2682
|
inferEdgeTypeWithTier as inferEdgeTypeWithTier3,
|
|
2672
2683
|
validateEdgeTypePair as validateEdgeTypePair2,
|
|
@@ -2685,6 +2696,12 @@ var batchCreateNodes = async (args, { store }) => {
|
|
|
2685
2696
|
const n = nodes[i];
|
|
2686
2697
|
if (!n.type) return textError(`Node at index ${i}: missing required field "type"`);
|
|
2687
2698
|
if (!n.title) return textError(`Node at index ${i}: missing required field "title"`);
|
|
2699
|
+
try {
|
|
2700
|
+
resolveEntityType3(n.type);
|
|
2701
|
+
} catch (err) {
|
|
2702
|
+
if (err instanceof UnknownEntityTypeError3) return textError(`Node at index ${i}: ${err.message}`);
|
|
2703
|
+
throw err;
|
|
2704
|
+
}
|
|
2688
2705
|
if (n.properties !== void 0) {
|
|
2689
2706
|
const { violations } = checkPropertyTypes2(n.type, n.properties);
|
|
2690
2707
|
if (violations.length > 0) {
|
|
@@ -2701,7 +2718,7 @@ var batchCreateNodes = async (args, { store }) => {
|
|
|
2701
2718
|
const created = [];
|
|
2702
2719
|
for (let i = 0; i < nodes.length; i++) {
|
|
2703
2720
|
const n = nodes[i];
|
|
2704
|
-
const nodeType = n.type;
|
|
2721
|
+
const nodeType = resolveEntityType3(n.type).canonical;
|
|
2705
2722
|
const newId = nodeId();
|
|
2706
2723
|
let status = null;
|
|
2707
2724
|
if (n.status) {
|