@graph-knowledge/api 0.3.0 → 0.4.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/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/lib/constants/element-defaults.js +1 -0
- package/src/lib/types/element-input-types.d.ts +29 -1
- package/src/lib/validators/element-type-validators/bezier-curve-validator.d.ts +12 -0
- package/src/lib/validators/element-type-validators/bezier-curve-validator.js +47 -0
- package/src/lib/validators/element-validator-registry.js +2 -0
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { IBatchOperations, BatchUpdateElementInput } from "./lib/interfaces
|
|
|
9
9
|
export type { ITemplateOperations } from "./lib/interfaces/template-operations.interface";
|
|
10
10
|
export type { IElementTypeValidator, IElementValidatorRegistry } from "./lib/interfaces/element-validator.interface";
|
|
11
11
|
export type { CreateDocumentInput, UpdateDocumentInput, DocumentResult, CreateNodeInput, UpdateNodeInput, NodeResult, CreateTemplateInput } from "./lib/types/api-types";
|
|
12
|
-
export type { BaseElementInput, RectangleInput, TextInput, ConnectorInput, ConnectorAnchor, LineStyle, MarkerType, UmlClassInput, UmlInterfaceInput, UmlComponentInput, UmlPackageInput, UmlArtifactInput, UmlNoteInput, TriangleInput, DiamondInput, HexagonInput, EllipseInput, LineInput, BlockArrowInput, BlockArrowDirection, CustomShapeInput, AnyElementInput, UpdateElementInput } from "./lib/types/element-input-types";
|
|
12
|
+
export type { BaseElementInput, RectangleInput, TextInput, ConnectorInput, ConnectorAnchor, LineStyle, MarkerType, UmlClassInput, UmlInterfaceInput, UmlComponentInput, UmlPackageInput, UmlArtifactInput, UmlNoteInput, TriangleInput, DiamondInput, HexagonInput, EllipseInput, LineInput, BezierCurveInput, BlockArrowInput, BlockArrowDirection, CustomShapeInput, AnyElementInput, UpdateElementInput } from "./lib/types/element-input-types";
|
|
13
13
|
export { GraphKnowledgeAPIError, AuthenticationError, NotFoundError, ValidationError, PermissionError } from "./lib/errors/api-errors";
|
|
14
14
|
export type { Document, GraphNode, GraphElement } from "./lib/models";
|
|
15
15
|
export { CURRENT_DOCUMENT_SCHEMA_VERSION } from "./lib/models";
|
|
@@ -263,6 +263,34 @@ export interface LineInput extends BaseElementInput {
|
|
|
263
263
|
/** Line style (reuses LineStyle from connectors) */
|
|
264
264
|
lineStyle?: LineStyle;
|
|
265
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Input for creating a cubic bezier curve element.
|
|
268
|
+
*
|
|
269
|
+
* The curve is defined by two endpoints and two control points:
|
|
270
|
+
* - Start point: (x, y)
|
|
271
|
+
* - End point: (x + width, y + height)
|
|
272
|
+
* - Control point 1: offset from start (controlPoint1X, controlPoint1Y)
|
|
273
|
+
* - Control point 2: offset from end (controlPoint2X, controlPoint2Y)
|
|
274
|
+
*
|
|
275
|
+
* If control points are omitted, a default S-curve is computed.
|
|
276
|
+
*/
|
|
277
|
+
export interface BezierCurveInput extends BaseElementInput {
|
|
278
|
+
type: "bezier-curve";
|
|
279
|
+
/** Stroke color (hex) */
|
|
280
|
+
strokeColor?: string;
|
|
281
|
+
/** Stroke width in pixels */
|
|
282
|
+
strokeWidth?: number;
|
|
283
|
+
/** Line style */
|
|
284
|
+
lineStyle?: LineStyle;
|
|
285
|
+
/** Control point 1 X offset from start */
|
|
286
|
+
controlPoint1X?: number;
|
|
287
|
+
/** Control point 1 Y offset from start */
|
|
288
|
+
controlPoint1Y?: number;
|
|
289
|
+
/** Control point 2 X offset from end */
|
|
290
|
+
controlPoint2X?: number;
|
|
291
|
+
/** Control point 2 Y offset from end */
|
|
292
|
+
controlPoint2Y?: number;
|
|
293
|
+
}
|
|
266
294
|
/**
|
|
267
295
|
* Direction for block arrow elements.
|
|
268
296
|
*/
|
|
@@ -300,7 +328,7 @@ export interface CustomShapeInput extends BaseElementInput {
|
|
|
300
328
|
/**
|
|
301
329
|
* Union of all element input types.
|
|
302
330
|
*/
|
|
303
|
-
export type AnyElementInput = RectangleInput | TextInput | ConnectorInput | UmlClassInput | UmlInterfaceInput | UmlComponentInput | UmlPackageInput | UmlArtifactInput | UmlNoteInput | TriangleInput | DiamondInput | HexagonInput | EllipseInput | LineInput | BlockArrowInput | CustomShapeInput;
|
|
331
|
+
export type AnyElementInput = RectangleInput | TextInput | ConnectorInput | UmlClassInput | UmlInterfaceInput | UmlComponentInput | UmlPackageInput | UmlArtifactInput | UmlNoteInput | TriangleInput | DiamondInput | HexagonInput | EllipseInput | LineInput | BezierCurveInput | BlockArrowInput | CustomShapeInput;
|
|
304
332
|
/**
|
|
305
333
|
* Input for updating an existing element.
|
|
306
334
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IElementTypeValidator } from "../../interfaces/element-validator.interface";
|
|
2
|
+
import { AnyElementInput } from "../../types/element-input-types";
|
|
3
|
+
import { BaseElementValidator } from "./base-element-validator";
|
|
4
|
+
/**
|
|
5
|
+
* Validator for bezier curve elements.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BezierCurveValidator extends BaseElementValidator implements IElementTypeValidator {
|
|
8
|
+
readonly elementType = "bezier-curve";
|
|
9
|
+
validate(input: AnyElementInput): void;
|
|
10
|
+
private validateLineStyle;
|
|
11
|
+
private validateNumber;
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BezierCurveValidator = void 0;
|
|
4
|
+
const api_errors_1 = require("../../errors/api-errors");
|
|
5
|
+
const base_element_validator_1 = require("./base-element-validator");
|
|
6
|
+
/**
|
|
7
|
+
* Validator for bezier curve elements.
|
|
8
|
+
*/
|
|
9
|
+
class BezierCurveValidator extends base_element_validator_1.BaseElementValidator {
|
|
10
|
+
elementType = "bezier-curve";
|
|
11
|
+
validate(input) {
|
|
12
|
+
if (input.type !== "bezier-curve") {
|
|
13
|
+
throw new api_errors_1.ValidationError(`Expected type "bezier-curve", got "${input.type}"`, "type");
|
|
14
|
+
}
|
|
15
|
+
const curveInput = input;
|
|
16
|
+
// Validate common properties
|
|
17
|
+
this.validateCommon(curveInput);
|
|
18
|
+
// Validate stroke properties
|
|
19
|
+
this.validateColor(curveInput.strokeColor, "strokeColor");
|
|
20
|
+
this.validateStrokeWidth(curveInput.strokeWidth, "strokeWidth");
|
|
21
|
+
this.validateLineStyle(curveInput.lineStyle);
|
|
22
|
+
// Validate control point offsets (must be numbers if provided)
|
|
23
|
+
this.validateNumber(curveInput.controlPoint1X, "controlPoint1X");
|
|
24
|
+
this.validateNumber(curveInput.controlPoint1Y, "controlPoint1Y");
|
|
25
|
+
this.validateNumber(curveInput.controlPoint2X, "controlPoint2X");
|
|
26
|
+
this.validateNumber(curveInput.controlPoint2Y, "controlPoint2Y");
|
|
27
|
+
}
|
|
28
|
+
validateLineStyle(value) {
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return;
|
|
31
|
+
if (typeof value !== "string") {
|
|
32
|
+
throw new api_errors_1.ValidationError("lineStyle must be a string", "lineStyle");
|
|
33
|
+
}
|
|
34
|
+
const validStyles = ["solid", "dashed", "dotted"];
|
|
35
|
+
if (!validStyles.includes(value)) {
|
|
36
|
+
throw new api_errors_1.ValidationError(`lineStyle must be one of: ${validStyles.join(", ")}`, "lineStyle");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
validateNumber(value, field) {
|
|
40
|
+
if (value === undefined)
|
|
41
|
+
return;
|
|
42
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
43
|
+
throw new api_errors_1.ValidationError(`${field} must be a valid number`, field);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.BezierCurveValidator = BezierCurveValidator;
|
|
@@ -8,6 +8,7 @@ const connector_validator_1 = require("./element-type-validators/connector-valid
|
|
|
8
8
|
const uml_validators_1 = require("./element-type-validators/uml-validators");
|
|
9
9
|
const basic_shape_validators_1 = require("./element-type-validators/basic-shape-validators");
|
|
10
10
|
const line_validator_1 = require("./element-type-validators/line-validator");
|
|
11
|
+
const bezier_curve_validator_1 = require("./element-type-validators/bezier-curve-validator");
|
|
11
12
|
const block_arrow_validator_1 = require("./element-type-validators/block-arrow-validator");
|
|
12
13
|
const custom_shape_validator_1 = require("./element-type-validators/custom-shape-validator");
|
|
13
14
|
/**
|
|
@@ -39,6 +40,7 @@ class ElementValidatorRegistry {
|
|
|
39
40
|
this.register(new basic_shape_validators_1.HexagonValidator());
|
|
40
41
|
this.register(new basic_shape_validators_1.EllipseValidator());
|
|
41
42
|
this.register(new line_validator_1.LineValidator());
|
|
43
|
+
this.register(new bezier_curve_validator_1.BezierCurveValidator());
|
|
42
44
|
this.register(new block_arrow_validator_1.BlockArrowValidator());
|
|
43
45
|
}
|
|
44
46
|
register(validator) {
|