@semiont/core 0.2.34-build.88 → 0.2.34-build.89

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
@@ -6,22 +6,24 @@
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@semiont/core.svg)](https://www.npmjs.com/package/@semiont/core)
7
7
  [![License](https://img.shields.io/npm/l/@semiont/core.svg)](https://github.com/The-AI-Alliance/semiont/blob/main/LICENSE)
8
8
 
9
- Backend domain logic for the Semiont semantic knowledge platform. This package provides **internal backend utilities** for event sourcing, cryptography, DID generation, and type guards.
9
+ Core types and domain logic for the Semiont semantic knowledge platform. This package is the **source of truth for OpenAPI types** and provides backend utilities for event sourcing, URIs, DID generation, and the EventBus.
10
10
 
11
- > ⚠️ **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**.
11
+ > **Architecture Note**: This package generates TypeScript types from the OpenAPI specification. `@semiont/api-client` re-exports these types and provides HTTP client functionality.
12
12
 
13
13
  ## Who Should Use This
14
14
 
15
- - ✅ **Backend** (`apps/backend`) - Server implementation with event sourcing
16
- - ✅ **Internal Services** - System components requiring domain logic
17
- - ✅ **CLI Tools** - Command-line utilities with full system access
15
+ - ✅ **Backend** (`apps/backend`) - Server implementation, imports types from core
16
+ - ✅ **Packages** - Other monorepo packages that need OpenAPI types or EventBus
17
+ - ✅ **Internal Utilities** - Type generation, validation, domain logic
18
18
 
19
- ## Who Should NOT Use This
19
+ ## Who Should Use `@semiont/api-client` Instead
20
20
 
21
- - **External Applications** - Use [`@semiont/api-client`](../api-client/README.md)
22
- - **Frontend** - Use [`@semiont/api-client`](../api-client/README.md)
23
- - **MCP Servers** - Use [`@semiont/api-client`](../api-client/README.md)
24
- - **Demo Scripts** - Use [`@semiont/api-client`](../api-client/README.md)
21
+ - **External Applications** - For HTTP client + utilities
22
+ - **Frontend** (`apps/frontend`, `packages/react-ui`) - For API communication and W3C utilities
23
+ - **Demo Scripts** - For higher-level API access
24
+ - **MCP Servers** - For client-side annotation utilities
25
+
26
+ **Rule of thumb**: If you need to make HTTP requests or work with W3C selectors, use `@semiont/api-client`. If you only need types and domain logic, use `@semiont/core`.
25
27
 
26
28
  ## Installation
27
29
 
@@ -39,15 +41,44 @@ npm install @semiont/core@dev
39
41
 
40
42
  ## What's Included
41
43
 
44
+ ### OpenAPI Types (Generated)
45
+
46
+ TypeScript types generated from the OpenAPI specification - the **source of truth** for all API schemas:
47
+
48
+ ```typescript
49
+ import type { components, paths, operations } from '@semiont/core';
50
+
51
+ type Annotation = components['schemas']['Annotation'];
52
+ type Resource = components['schemas']['Resource'];
53
+ type CreateResourceRequest = components['schemas']['CreateResourceRequest'];
54
+ ```
55
+
56
+ These types are generated during the build process:
57
+ ```bash
58
+ npm run generate:openapi # Bundles spec → generates types.ts
59
+ ```
60
+
61
+ ### Branded Types
62
+
63
+ Compile-time type safety for URIs, tokens, and identifiers:
64
+
65
+ ```typescript
66
+ import { resourceUri, annotationUri, accessToken, entityType } from '@semiont/core';
67
+
68
+ const rUri = resourceUri('http://localhost:4000/resources/doc-123');
69
+ const token = accessToken('eyJhbGc...');
70
+ const eType = entityType('Person');
71
+ ```
72
+
42
73
  ### Event Sourcing Types
43
74
 
44
75
  Event types for the event-sourced architecture:
45
76
 
46
77
  ```typescript
47
78
  import type {
48
- DocumentEvent,
49
- DocumentCreatedEvent,
50
- DocumentArchivedEvent,
79
+ ResourceEvent,
80
+ ResourceCreatedEvent,
81
+ ResourceArchivedEvent,
51
82
  DocumentUnarchivedEvent,
52
83
  AnnotationAddedEvent,
53
84
  AnnotationRemovedEvent,
@@ -240,14 +271,15 @@ import { compareAnnotationIds, getEntityTypes, getBodySource } from '@semiont/ap
240
271
  Semiont follows a **spec-first architecture**:
241
272
 
242
273
  1. **OpenAPI Specification** ([specs/src/](../../specs/src/)) is the source of truth
243
- 2. **@semiont/api-client** generates types from OpenAPI and provides utilities
244
- 3. **@semiont/core** provides backend-specific domain logic not in the API
274
+ 2. **@semiont/core** generates types from OpenAPI and provides utilities
275
+ 3. **@semiont/api-client** re-exports types from core and provides HTTP client
245
276
 
246
277
  **Principle**:
247
- - API contract & data utilities → `@semiont/api-client`
248
- - Backend internal implementation → `@semiont/core`
278
+ - OpenAPI types & domain utilities → `@semiont/core` (source of truth)
279
+ - HTTP client & convenience re-exports → `@semiont/api-client`
280
+ - Backend internal implementation → imports from `@semiont/core`
249
281
 
250
- **Deduplication (2025-10-24)**: Selector utilities, locale utilities, and public annotation utilities were moved from this package to `@semiont/api-client` as part of the spec-first architecture migration.
282
+ **Type Generation Flow**: OpenAPI spec `@semiont/core/src/types.ts` (via `openapi-typescript`) re-exported by `@semiont/api-client` for convenience. This ensures no circular dependencies and clear build order.
251
283
 
252
284
  ## Development
253
285