@semiont/core 0.2.34-build.88 → 0.2.34-build.90
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 +50 -18
- package/dist/index.d.ts +3742 -14
- package/dist/index.js +190 -4
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -6,22 +6,24 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@semiont/core)
|
|
7
7
|
[](https://github.com/The-AI-Alliance/semiont/blob/main/LICENSE)
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
>
|
|
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
|
|
16
|
-
- ✅ **
|
|
17
|
-
- ✅ **
|
|
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
|
|
19
|
+
## Who Should Use `@semiont/api-client` Instead
|
|
20
20
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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/
|
|
244
|
-
3. **@semiont/
|
|
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
|
-
-
|
|
248
|
-
-
|
|
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
|
-
**
|
|
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
|
|