@semiont/core 0.1.0 → 0.2.0-build.4

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @semiont/core
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@semiont/core.svg)](https://www.npmjs.com/package/@semiont/core)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@semiont/core.svg)](https://www.npmjs.com/package/@semiont/core)
5
+ [![License](https://img.shields.io/npm/l/@semiont/core.svg)](https://github.com/The-AI-Alliance/semiont/blob/main/LICENSE)
6
+
3
7
  Backend domain logic for the Semiont semantic knowledge platform. This package provides **internal backend utilities** for event sourcing, cryptography, DID generation, and type guards.
4
8
 
5
9
  > ⚠️ **Not for External Use**: If you're building applications that consume the Semiont API, use [`@semiont/api-client`](../api-client/README.md) instead. This package is for **backend internal use only**.
@@ -19,10 +23,18 @@ Backend domain logic for the Semiont semantic knowledge platform. This package p
19
23
 
20
24
  ## Installation
21
25
 
26
+ Install the latest stable release from npm:
27
+
22
28
  ```bash
23
29
  npm install @semiont/core
24
30
  ```
25
31
 
32
+ Or install the latest development build:
33
+
34
+ ```bash
35
+ npm install @semiont/core@dev
36
+ ```
37
+
26
38
  ## What's Included
27
39
 
28
40
  ### Event Sourcing Types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semiont/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-build.4",
4
4
  "description": "Core domain types for Semiont - Document, Annotation, and Graph models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,56 +0,0 @@
1
- /**
2
- * Runtime Configuration Validation
3
- *
4
- * Uses AJV to validate configuration files against the JSON Schema at runtime.
5
- * This catches invalid configurations before they cause runtime errors.
6
- */
7
- import type { SemiontConfig } from './config.types.js';
8
- /**
9
- * Error thrown when configuration validation fails
10
- */
11
- export declare class ConfigValidationError extends Error {
12
- readonly errors: unknown[];
13
- constructor(message: string, errors: unknown[]);
14
- /**
15
- * Get a formatted error message with all validation failures
16
- */
17
- getDetailedMessage(): string;
18
- }
19
- /**
20
- * Validates a configuration object against the JSON Schema
21
- *
22
- * @param config - The configuration object to validate
23
- * @returns The validated config, typed as SemiontConfig
24
- * @throws ConfigValidationError if validation fails
25
- *
26
- * @example
27
- * ```typescript
28
- * import { validateConfig } from '@semiont/core';
29
- *
30
- * try {
31
- * const config = validateConfig(loadedConfig);
32
- * // config is now typed and validated
33
- * } catch (error) {
34
- * if (error instanceof ConfigValidationError) {
35
- * console.error(error.getDetailedMessage());
36
- * }
37
- * }
38
- * ```
39
- */
40
- export declare function validateConfig(config: unknown): SemiontConfig;
41
- /**
42
- * Type guard that checks if a configuration is valid
43
- * Does not throw, returns boolean instead
44
- *
45
- * @param config - The configuration to check
46
- * @returns True if valid, false otherwise
47
- */
48
- export declare function isValidConfig(config: unknown): config is SemiontConfig;
49
- /**
50
- * Get validation errors for a config without throwing
51
- *
52
- * @param config - The configuration to validate
53
- * @returns Array of validation errors, or null if valid
54
- */
55
- export declare function getConfigErrors(config: unknown): unknown[] | null;
56
- //# sourceMappingURL=validate-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../../src/config/validate-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAkBvD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aAG5B,MAAM,EAAE,OAAO,EAAE;gBADjC,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,OAAO,EAAE;IAMnC;;OAEG;IACH,kBAAkB,IAAI,MAAM;CAiB7B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,CAS7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,CAKjE"}
@@ -1,114 +0,0 @@
1
- "use strict";
2
- /**
3
- * Runtime Configuration Validation
4
- *
5
- * Uses AJV to validate configuration files against the JSON Schema at runtime.
6
- * This catches invalid configurations before they cause runtime errors.
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ConfigValidationError = void 0;
13
- exports.validateConfig = validateConfig;
14
- exports.isValidConfig = isValidConfig;
15
- exports.getConfigErrors = getConfigErrors;
16
- const ajv_1 = __importDefault(require("ajv"));
17
- const ajv_formats_1 = __importDefault(require("ajv-formats"));
18
- const config_schema_json_1 = __importDefault(require("./config.schema.json"));
19
- // Initialize AJV with strict schema validation
20
- const ajv = new ajv_1.default({
21
- strict: true,
22
- strictSchema: true,
23
- strictNumbers: true,
24
- strictTypes: true,
25
- allErrors: true,
26
- verbose: true,
27
- });
28
- // Add format validators (email, uri, date-time, etc.)
29
- (0, ajv_formats_1.default)(ajv);
30
- // Compile the schema once at module load
31
- const validate = ajv.compile(config_schema_json_1.default);
32
- /**
33
- * Error thrown when configuration validation fails
34
- */
35
- class ConfigValidationError extends Error {
36
- errors;
37
- constructor(message, errors) {
38
- super(message);
39
- this.errors = errors;
40
- this.name = 'ConfigValidationError';
41
- }
42
- /**
43
- * Get a formatted error message with all validation failures
44
- */
45
- getDetailedMessage() {
46
- const lines = [this.message, ''];
47
- if (Array.isArray(this.errors)) {
48
- this.errors.forEach((err, idx) => {
49
- lines.push(`Error ${idx + 1}:`);
50
- lines.push(` Path: ${err.instancePath || '(root)'}`);
51
- lines.push(` Message: ${err.message}`);
52
- if (err.params) {
53
- lines.push(` Details: ${JSON.stringify(err.params)}`);
54
- }
55
- lines.push('');
56
- });
57
- }
58
- return lines.join('\n');
59
- }
60
- }
61
- exports.ConfigValidationError = ConfigValidationError;
62
- /**
63
- * Validates a configuration object against the JSON Schema
64
- *
65
- * @param config - The configuration object to validate
66
- * @returns The validated config, typed as SemiontConfig
67
- * @throws ConfigValidationError if validation fails
68
- *
69
- * @example
70
- * ```typescript
71
- * import { validateConfig } from '@semiont/core';
72
- *
73
- * try {
74
- * const config = validateConfig(loadedConfig);
75
- * // config is now typed and validated
76
- * } catch (error) {
77
- * if (error instanceof ConfigValidationError) {
78
- * console.error(error.getDetailedMessage());
79
- * }
80
- * }
81
- * ```
82
- */
83
- function validateConfig(config) {
84
- if (!validate(config)) {
85
- const errors = validate.errors || [];
86
- const errorCount = errors.length;
87
- const message = `Configuration validation failed with ${errorCount} error${errorCount === 1 ? '' : 's'}`;
88
- throw new ConfigValidationError(message, errors);
89
- }
90
- return config;
91
- }
92
- /**
93
- * Type guard that checks if a configuration is valid
94
- * Does not throw, returns boolean instead
95
- *
96
- * @param config - The configuration to check
97
- * @returns True if valid, false otherwise
98
- */
99
- function isValidConfig(config) {
100
- return validate(config) === true;
101
- }
102
- /**
103
- * Get validation errors for a config without throwing
104
- *
105
- * @param config - The configuration to validate
106
- * @returns Array of validation errors, or null if valid
107
- */
108
- function getConfigErrors(config) {
109
- if (validate(config)) {
110
- return null;
111
- }
112
- return validate.errors || [];
113
- }
114
- //# sourceMappingURL=validate-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../src/config/validate-config.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AA8EH,wCASC;AASD,sCAEC;AAQD,0CAKC;AA7GD,8CAAsB;AACtB,8DAAqC;AACrC,8EAA0C;AAG1C,+CAA+C;AAC/C,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC;IAClB,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;IACnB,WAAW,E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