@semiont/core 0.2.31 → 0.2.32-build.69
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.d.ts +120 -119
- package/dist/index.js +90 -322
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,13 +105,13 @@ declare function uriToAnnotationId(uri: string): AnnotationId;
|
|
|
105
105
|
*/
|
|
106
106
|
|
|
107
107
|
type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
|
|
108
|
-
type Annotation$
|
|
108
|
+
type Annotation$3 = components['schemas']['Annotation'];
|
|
109
109
|
/**
|
|
110
110
|
* Represents a connection between resources through annotations
|
|
111
111
|
*/
|
|
112
112
|
interface GraphConnection {
|
|
113
113
|
targetResource: ResourceDescriptor;
|
|
114
|
-
annotations: Annotation$
|
|
114
|
+
annotations: Annotation$3[];
|
|
115
115
|
relationshipType?: string;
|
|
116
116
|
bidirectional: boolean;
|
|
117
117
|
}
|
|
@@ -120,7 +120,7 @@ interface GraphConnection {
|
|
|
120
120
|
*/
|
|
121
121
|
interface GraphPath {
|
|
122
122
|
resources: ResourceDescriptor[];
|
|
123
|
-
annotations: Annotation$
|
|
123
|
+
annotations: Annotation$3[];
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Statistics about entity types in the graph
|
|
@@ -143,7 +143,7 @@ interface EntityTypeStats {
|
|
|
143
143
|
* - Optional signatures for cross-org verification
|
|
144
144
|
*/
|
|
145
145
|
|
|
146
|
-
type Annotation$
|
|
146
|
+
type Annotation$2 = components['schemas']['Annotation'];
|
|
147
147
|
type ContentFormat = components['schemas']['ContentFormat'];
|
|
148
148
|
type Motivation = components['schemas']['Motivation'];
|
|
149
149
|
interface BaseEvent {
|
|
@@ -221,7 +221,7 @@ interface RepresentationRemovedEvent extends BaseEvent {
|
|
|
221
221
|
interface AnnotationAddedEvent extends BaseEvent {
|
|
222
222
|
type: 'annotation.added';
|
|
223
223
|
payload: {
|
|
224
|
-
annotation: Omit<Annotation$
|
|
224
|
+
annotation: Omit<Annotation$2, 'creator' | 'created'>;
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
interface AnnotationRemovedEvent extends BaseEvent {
|
|
@@ -373,7 +373,7 @@ interface EventQuery {
|
|
|
373
373
|
}
|
|
374
374
|
interface ResourceAnnotations {
|
|
375
375
|
resourceId: ResourceId;
|
|
376
|
-
annotations: Annotation$
|
|
376
|
+
annotations: Annotation$2[];
|
|
377
377
|
version: number;
|
|
378
378
|
updatedAt: string;
|
|
379
379
|
}
|
|
@@ -382,7 +382,7 @@ interface ResourceAnnotations {
|
|
|
382
382
|
* Backend-specific annotation utility functions
|
|
383
383
|
*/
|
|
384
384
|
|
|
385
|
-
type Annotation$
|
|
385
|
+
type Annotation$1 = components['schemas']['Annotation'];
|
|
386
386
|
/**
|
|
387
387
|
* Check if two body items match (for remove/replace operations)
|
|
388
388
|
* Matches by type, value/source, and purpose fields
|
|
@@ -392,7 +392,7 @@ declare function bodyItemsMatch(item1: BodyItem, item2: BodyItem): boolean;
|
|
|
392
392
|
* Find a body item in an array
|
|
393
393
|
* Returns the index of the first matching item, or -1 if not found
|
|
394
394
|
*/
|
|
395
|
-
declare function findBodyItem(body: Annotation$
|
|
395
|
+
declare function findBodyItem(body: Annotation$1['body'], targetItem: BodyItem): number;
|
|
396
396
|
|
|
397
397
|
/**
|
|
398
398
|
* Resource input/output types
|
|
@@ -413,13 +413,13 @@ interface ResourceFilter {
|
|
|
413
413
|
* Annotation types
|
|
414
414
|
*/
|
|
415
415
|
|
|
416
|
-
type Annotation
|
|
416
|
+
type Annotation = components['schemas']['Annotation'];
|
|
417
417
|
type AnnotationCategory = 'highlight' | 'reference';
|
|
418
418
|
interface CreateAnnotationInternal {
|
|
419
419
|
id: string;
|
|
420
|
-
motivation: Annotation
|
|
421
|
-
target: Annotation
|
|
422
|
-
body: Annotation
|
|
420
|
+
motivation: Annotation['motivation'];
|
|
421
|
+
target: Annotation['target'];
|
|
422
|
+
body: Annotation['body'];
|
|
423
423
|
creator: components['schemas']['Agent'];
|
|
424
424
|
}
|
|
425
425
|
|
|
@@ -558,76 +558,6 @@ declare class APIError extends Error {
|
|
|
558
558
|
constructor(status: number, data: any, message?: string);
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
-
/**
|
|
562
|
-
* HTTP Client Utilities
|
|
563
|
-
*
|
|
564
|
-
* Reusable fetch wrapper for making authenticated HTTP requests.
|
|
565
|
-
* Used by both frontend (via TanStack Query) and backend (direct calls).
|
|
566
|
-
*/
|
|
567
|
-
/**
|
|
568
|
-
* Configuration for HTTP client
|
|
569
|
-
*/
|
|
570
|
-
interface HttpClientConfig {
|
|
571
|
-
baseUrl: string;
|
|
572
|
-
token?: string;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Fetch helper with authentication and error handling
|
|
576
|
-
*
|
|
577
|
-
* @param endpoint - API endpoint (e.g., '/api/resources')
|
|
578
|
-
* @param options - Standard fetch options
|
|
579
|
-
* @param token - Optional authentication token
|
|
580
|
-
* @returns Typed response data
|
|
581
|
-
* @throws APIError on HTTP errors
|
|
582
|
-
*/
|
|
583
|
-
declare function fetchAPI<T>(endpoint: string, options?: RequestInit, token?: string, baseUrl?: string): Promise<T>;
|
|
584
|
-
/**
|
|
585
|
-
* Create a configured fetch function with a base URL
|
|
586
|
-
* Useful for creating client-specific fetch instances
|
|
587
|
-
*
|
|
588
|
-
* @param baseUrl - Base URL for all requests (e.g., 'http://localhost:4000')
|
|
589
|
-
* @returns Configured fetch function
|
|
590
|
-
*/
|
|
591
|
-
declare function createFetchAPI(baseUrl: string): <T>(endpoint: string, options?: RequestInit, token?: string) => Promise<T>;
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Utility functions for AnnotationHistory component
|
|
595
|
-
* Extracted to reduce component complexity and improve testability
|
|
596
|
-
*
|
|
597
|
-
* NOTE: This file contains UI-specific logic and should eventually move to the frontend package.
|
|
598
|
-
* It has been updated to work with unified annotation events (annotation.added/removed/body.updated)
|
|
599
|
-
* instead of separate highlight/reference/assessment events.
|
|
600
|
-
*/
|
|
601
|
-
|
|
602
|
-
type Annotation = components['schemas']['Annotation'];
|
|
603
|
-
type TranslateFn = (key: string, params?: Record<string, string | number>) => string;
|
|
604
|
-
declare function formatEventType(type: ResourceEventType, t: TranslateFn): string;
|
|
605
|
-
declare function getEventEmoji(type: ResourceEventType, event?: StoredEvent): string;
|
|
606
|
-
declare function formatRelativeTime(timestamp: string, t: TranslateFn): string;
|
|
607
|
-
declare function getEventDisplayContent(event: StoredEvent, _references: Annotation[], // underscore prefix to indicate intentionally unused for now
|
|
608
|
-
_highlights: Annotation[], // underscore prefix to indicate intentionally unused for now
|
|
609
|
-
allEvents: StoredEvent[]): {
|
|
610
|
-
exact: string;
|
|
611
|
-
isQuoted: boolean;
|
|
612
|
-
isTag: boolean;
|
|
613
|
-
} | null;
|
|
614
|
-
declare function getEventEntityTypes(event: StoredEvent): string[];
|
|
615
|
-
type ResourceCreatedDetails = {
|
|
616
|
-
type: 'created';
|
|
617
|
-
userId: string;
|
|
618
|
-
method: CreationMethod;
|
|
619
|
-
};
|
|
620
|
-
type ResourceClonedDetails = {
|
|
621
|
-
type: 'cloned';
|
|
622
|
-
userId: string;
|
|
623
|
-
method: CreationMethod;
|
|
624
|
-
sourceDocId: string;
|
|
625
|
-
};
|
|
626
|
-
type ResourceCreationDetails = ResourceCreatedDetails | ResourceClonedDetails;
|
|
627
|
-
declare function getResourceCreationDetails(event: StoredEvent): ResourceCreationDetails | null;
|
|
628
|
-
declare function getAnnotationIdFromEvent(event: StoredEvent): string | null;
|
|
629
|
-
declare function isEventRelatedToAnnotation(event: StoredEvent, annotationId: AnnotationId): boolean;
|
|
630
|
-
|
|
631
561
|
/**
|
|
632
562
|
* DID (Decentralized Identifier) and W3C Agent utilities
|
|
633
563
|
*
|
|
@@ -1357,15 +1287,33 @@ interface AWSConfig {
|
|
|
1357
1287
|
};
|
|
1358
1288
|
}
|
|
1359
1289
|
/**
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1290
|
+
* Deep merge utility for configuration objects
|
|
1291
|
+
* Pure function - no side effects
|
|
1292
|
+
*/
|
|
1293
|
+
declare function deepMerge(target: any, ...sources: any[]): any;
|
|
1294
|
+
/**
|
|
1295
|
+
* Recursively resolve environment variable placeholders in configuration
|
|
1296
|
+
* Replaces ${VAR_NAME} with the value from the provided env object
|
|
1297
|
+
* Pure function - accepts env as parameter instead of using process.env
|
|
1362
1298
|
*
|
|
1363
|
-
* @param
|
|
1364
|
-
* @param
|
|
1365
|
-
* @returns
|
|
1366
|
-
* @throws ConfigurationError if files are missing or invalid
|
|
1299
|
+
* @param obj - Configuration object to process
|
|
1300
|
+
* @param env - Environment variables object
|
|
1301
|
+
* @returns Configuration with resolved environment variables
|
|
1367
1302
|
*/
|
|
1368
|
-
declare function
|
|
1303
|
+
declare function resolveEnvVars(obj: any, env: Record<string, string | undefined>): any;
|
|
1304
|
+
/**
|
|
1305
|
+
* Parse and merge configuration files
|
|
1306
|
+
* Pure function - accepts file contents as strings instead of reading from filesystem
|
|
1307
|
+
*
|
|
1308
|
+
* @param baseContent - Contents of semiont.json (null if file doesn't exist)
|
|
1309
|
+
* @param envContent - Contents of environment-specific JSON file
|
|
1310
|
+
* @param env - Environment variables object
|
|
1311
|
+
* @param environment - Environment name
|
|
1312
|
+
* @param projectRoot - Project root path (for metadata only)
|
|
1313
|
+
* @returns Merged and validated environment configuration
|
|
1314
|
+
* @throws ConfigurationError if parsing or validation fails
|
|
1315
|
+
*/
|
|
1316
|
+
declare function parseAndMergeConfigs(baseContent: string | null, envContent: string, env: Record<string, string | undefined>, environment: string, projectRoot: string): EnvironmentConfig;
|
|
1369
1317
|
/**
|
|
1370
1318
|
* Get NODE_ENV value from environment config
|
|
1371
1319
|
*
|
|
@@ -1373,21 +1321,70 @@ declare function loadEnvironmentConfig(projectRoot: string, environment: string)
|
|
|
1373
1321
|
* @returns NODE_ENV value (defaults to 'development' if not specified)
|
|
1374
1322
|
*/
|
|
1375
1323
|
declare function getNodeEnvForEnvironment(config: EnvironmentConfig): 'development' | 'production' | 'test';
|
|
1324
|
+
/**
|
|
1325
|
+
* List environment names from filenames
|
|
1326
|
+
* Pure function - accepts array of filenames instead of reading from filesystem
|
|
1327
|
+
*
|
|
1328
|
+
* @param files - Array of filenames from environments directory
|
|
1329
|
+
* @returns Sorted array of environment names
|
|
1330
|
+
*/
|
|
1331
|
+
declare function listEnvironmentNames(files: string[]): string[];
|
|
1332
|
+
/**
|
|
1333
|
+
* Type guard to check if config has AWS settings
|
|
1334
|
+
*
|
|
1335
|
+
* @param config - Environment configuration
|
|
1336
|
+
* @returns True if AWS configuration is present
|
|
1337
|
+
*/
|
|
1338
|
+
declare function hasAWSConfig(config: EnvironmentConfig): config is EnvironmentConfig & {
|
|
1339
|
+
aws: AWSConfig;
|
|
1340
|
+
};
|
|
1341
|
+
/**
|
|
1342
|
+
* Display configuration for debugging
|
|
1343
|
+
*
|
|
1344
|
+
* @param config - Configuration to display
|
|
1345
|
+
*/
|
|
1346
|
+
declare function displayConfiguration(config: EnvironmentConfig): void;
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Filesystem-based wrapper for environment loading
|
|
1350
|
+
*
|
|
1351
|
+
* This module provides convenient filesystem-based wrappers around the pure
|
|
1352
|
+
* configuration functions. These are intended for application code that needs
|
|
1353
|
+
* to load config from disk.
|
|
1354
|
+
*
|
|
1355
|
+
* The pure functions (parseAndMergeConfigs, etc.) remain testable without
|
|
1356
|
+
* filesystem mocking.
|
|
1357
|
+
*/
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Load environment configuration from filesystem
|
|
1361
|
+
* Convenience wrapper around parseAndMergeConfigs for application code
|
|
1362
|
+
*
|
|
1363
|
+
* @param projectRoot - Absolute path to project directory containing semiont.json
|
|
1364
|
+
* @param environment - Environment name (must match a file in environments/)
|
|
1365
|
+
* @returns Merged environment configuration
|
|
1366
|
+
* @throws ConfigurationError if files are missing or invalid
|
|
1367
|
+
*/
|
|
1368
|
+
declare function loadEnvironmentConfig(projectRoot: string, environment: string): EnvironmentConfig;
|
|
1376
1369
|
/**
|
|
1377
1370
|
* Get available environments by scanning environments directory
|
|
1371
|
+
* Convenience wrapper around listEnvironmentNames for application code
|
|
1378
1372
|
*
|
|
1379
1373
|
* @returns Array of environment names
|
|
1380
1374
|
*/
|
|
1381
1375
|
declare function getAvailableEnvironments(): string[];
|
|
1376
|
+
/**
|
|
1377
|
+
* Check if an environment exists
|
|
1378
|
+
*
|
|
1379
|
+
* @param environment - Environment name to check
|
|
1380
|
+
* @returns True if environment exists
|
|
1381
|
+
*/
|
|
1382
|
+
declare function isValidEnvironment(environment: string): boolean;
|
|
1382
1383
|
|
|
1383
1384
|
/**
|
|
1384
1385
|
* Environment validation utilities
|
|
1385
1386
|
*/
|
|
1386
1387
|
type Environment = string;
|
|
1387
|
-
/**
|
|
1388
|
-
* Type guard to check if a string is a valid Environment
|
|
1389
|
-
*/
|
|
1390
|
-
declare function isValidEnvironment(value: string | undefined): value is Environment;
|
|
1391
1388
|
/**
|
|
1392
1389
|
* Parse environment string to Environment type
|
|
1393
1390
|
* @param value - The environment string to parse
|
|
@@ -1402,6 +1399,35 @@ declare function parseEnvironment(value: string | undefined): Environment;
|
|
|
1402
1399
|
*/
|
|
1403
1400
|
declare function validateEnvironment(value: string | undefined): Environment;
|
|
1404
1401
|
|
|
1402
|
+
/**
|
|
1403
|
+
* Config Schema Validator
|
|
1404
|
+
*
|
|
1405
|
+
* Validates configuration data against JSON Schema using Ajv (JSON Schema validator).
|
|
1406
|
+
* Provides runtime validation for semiont.json and environment config files.
|
|
1407
|
+
*/
|
|
1408
|
+
|
|
1409
|
+
interface ValidationResult {
|
|
1410
|
+
valid: boolean;
|
|
1411
|
+
errors: ErrorObject[] | null;
|
|
1412
|
+
errorMessage?: string;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Validate semiont.json config
|
|
1416
|
+
*/
|
|
1417
|
+
declare function validateSemiontConfig(data: unknown): ValidationResult;
|
|
1418
|
+
/**
|
|
1419
|
+
* Validate environment config (environments/*.json)
|
|
1420
|
+
*/
|
|
1421
|
+
declare function validateEnvironmentConfig(data: unknown): ValidationResult;
|
|
1422
|
+
/**
|
|
1423
|
+
* Validate site config
|
|
1424
|
+
*/
|
|
1425
|
+
declare function validateSiteConfig(data: unknown): ValidationResult;
|
|
1426
|
+
/**
|
|
1427
|
+
* Format validation errors into human-readable message
|
|
1428
|
+
*/
|
|
1429
|
+
declare function formatErrors(errors: ErrorObject[]): string;
|
|
1430
|
+
|
|
1405
1431
|
/**
|
|
1406
1432
|
* Configuration Error Class
|
|
1407
1433
|
*
|
|
@@ -1454,31 +1480,6 @@ declare function getEnvironmentsPath(projectRoot?: string): string;
|
|
|
1454
1480
|
*/
|
|
1455
1481
|
declare function getSemiontConfigPath(projectRoot?: string): string;
|
|
1456
1482
|
|
|
1457
|
-
/**
|
|
1458
|
-
* Config Schema Validator
|
|
1459
|
-
*
|
|
1460
|
-
* Validates configuration data against JSON Schema using Ajv (JSON Schema validator).
|
|
1461
|
-
* Provides runtime validation for semiont.json and environment config files.
|
|
1462
|
-
*/
|
|
1463
|
-
|
|
1464
|
-
interface ValidationResult {
|
|
1465
|
-
valid: boolean;
|
|
1466
|
-
errors: ErrorObject[] | null;
|
|
1467
|
-
errorMessage?: string;
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Validate semiont.json config
|
|
1471
|
-
*/
|
|
1472
|
-
declare function validateSemiontConfig(data: unknown): ValidationResult;
|
|
1473
|
-
/**
|
|
1474
|
-
* Validate environment config (environments/*.json)
|
|
1475
|
-
*/
|
|
1476
|
-
declare function validateEnvironmentConfig(data: unknown): ValidationResult;
|
|
1477
|
-
/**
|
|
1478
|
-
* Validate site config
|
|
1479
|
-
*/
|
|
1480
|
-
declare function validateSiteConfig(data: unknown): ValidationResult;
|
|
1481
|
-
|
|
1482
1483
|
/**
|
|
1483
1484
|
* @semiont/core
|
|
1484
1485
|
*
|
|
@@ -1489,4 +1490,4 @@ declare function validateSiteConfig(data: unknown): ValidationResult;
|
|
|
1489
1490
|
declare const CORE_TYPES_VERSION = "0.1.0";
|
|
1490
1491
|
declare const SDK_VERSION = "0.1.0";
|
|
1491
1492
|
|
|
1492
|
-
export { APIError, type AWSConfig, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationRemovedEvent, type AppConfig, type BackendServiceConfig, type BaseEvent, type BodyItem, type BodyOperation, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityTypeStats, type Environment, type EnvironmentConfig, type EventMetadata, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GoogleAuthRequest, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type
|
|
1493
|
+
export { APIError, type AWSConfig, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationRemovedEvent, type AppConfig, type BackendServiceConfig, type BaseEvent, type BodyItem, type BodyOperation, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityTypeStats, type Environment, type EnvironmentConfig, type EventMetadata, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GoogleAuthRequest, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type InferenceServiceConfig, type JobCompletedEvent, type JobFailedEvent, type JobProgressEvent, type JobStartedEvent, type McpServiceConfig, NotFoundError, type PlatformType, type ProxyServiceConfig, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, SDK_VERSION, ScriptError, type SemiontConfig, SemiontError, type ServiceConfig, type ServicePlatformConfig, type ServicesConfig, type SiteConfig, type StoredEvent, type SystemEvent, UnauthorizedError, type UpdateResourceInput, type UserId, ValidationError, type ValidationResult, annotationId, annotationIdToURI, bodyItemsMatch, calculateChecksum, deepMerge, didToAgent, displayConfiguration, findBodyItem, findProjectRoot, formatErrors, generateId, generateToken, generateUuid, getAllPlatformTypes, getAvailableEnvironments, getEnvironmentsPath, getEventType, getNodeEnvForEnvironment, getSemiontConfigPath, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isFunction, isNull, isNullish, isNumber, isObject, isProjectRoot, isResourceEvent, isResourceId, isResourceScopedEvent, isString, isSystemEvent, isUndefined, isValidEnvironment, isValidPlatformType, listEnvironmentNames, loadEnvironmentConfig, parseAndMergeConfigs, parseEnvironment, resolveEnvVars, resourceId, resourceIdToURI, uriToAnnotationId, uriToResourceId, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig, verifyChecksum };
|