@semiont/core 0.2.34 → 0.2.35-build.101
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 +63 -2
- package/dist/index.js +80 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
1
|
+
import { Subject, OperatorFunction } from 'rxjs';
|
|
2
2
|
import { ErrorObject } from 'ajv';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -4136,6 +4136,67 @@ declare class ScopedEventBus {
|
|
|
4136
4136
|
scope(subScope: string): ScopedEventBus;
|
|
4137
4137
|
}
|
|
4138
4138
|
|
|
4139
|
+
/**
|
|
4140
|
+
* Adaptive burst buffer RxJS operator.
|
|
4141
|
+
*
|
|
4142
|
+
* Passes the first event through immediately (zero latency for interactive use).
|
|
4143
|
+
* If more events arrive within the burst window, switches to accumulate mode
|
|
4144
|
+
* and flushes batches. Returns to passthrough mode after an idle period.
|
|
4145
|
+
*
|
|
4146
|
+
* Emits individual items (T) in passthrough mode and arrays (T[]) in batch mode.
|
|
4147
|
+
* Consumers distinguish via Array.isArray().
|
|
4148
|
+
*
|
|
4149
|
+
* Threshold tuning:
|
|
4150
|
+
* burstWindowMs — How long to wait for more events before flushing a batch.
|
|
4151
|
+
* 50ms is a good default: longer than event-loop jitter (~1-5ms)
|
|
4152
|
+
* but short enough to feel responsive.
|
|
4153
|
+
* maxBatchSize — Force-flush at this size to bound memory. 500 is safe for
|
|
4154
|
+
* Neo4j UNWIND queries. Increase if graph writes are cheap.
|
|
4155
|
+
* idleTimeoutMs — How long after the last flush before returning to passthrough.
|
|
4156
|
+
* 200ms is a good default. Must be >= burstWindowMs.
|
|
4157
|
+
*
|
|
4158
|
+
* See: BATCH-GRAPH-CONSUMER-RX.md for design rationale.
|
|
4159
|
+
* See: packages/graph/docs/ARCHITECTURE.md for graph consumer context.
|
|
4160
|
+
*/
|
|
4161
|
+
|
|
4162
|
+
interface BurstBufferOptions {
|
|
4163
|
+
/**
|
|
4164
|
+
* Time window (ms) to detect burst activity after an event.
|
|
4165
|
+
* If another event arrives within this window, it is buffered.
|
|
4166
|
+
* The buffer flushes when no new event arrives for this duration (debounce).
|
|
4167
|
+
*
|
|
4168
|
+
* Recommended: 50ms.
|
|
4169
|
+
*/
|
|
4170
|
+
burstWindowMs: number;
|
|
4171
|
+
/**
|
|
4172
|
+
* Maximum events to accumulate before forcing a flush.
|
|
4173
|
+
* Prevents unbounded memory growth during sustained bursts.
|
|
4174
|
+
*
|
|
4175
|
+
* Recommended: 500.
|
|
4176
|
+
*/
|
|
4177
|
+
maxBatchSize: number;
|
|
4178
|
+
/**
|
|
4179
|
+
* Time (ms) of silence after the last flush before returning to passthrough mode.
|
|
4180
|
+
* The next event after this timeout emits immediately (leading edge).
|
|
4181
|
+
* Must be >= burstWindowMs.
|
|
4182
|
+
*
|
|
4183
|
+
* Recommended: 200ms.
|
|
4184
|
+
*/
|
|
4185
|
+
idleTimeoutMs: number;
|
|
4186
|
+
}
|
|
4187
|
+
/**
|
|
4188
|
+
* Adaptive burst buffer operator.
|
|
4189
|
+
*
|
|
4190
|
+
* State machine:
|
|
4191
|
+
* PASSTHROUGH → event arrives → emit immediately, transition to ACCUMULATING
|
|
4192
|
+
* ACCUMULATING → event arrives → buffer it, reset burst timer
|
|
4193
|
+
* ACCUMULATING → burst timer fires (no new events for burstWindowMs) → flush buffer as T[]
|
|
4194
|
+
* ACCUMULATING → buffer reaches maxBatchSize → flush buffer as T[]
|
|
4195
|
+
* After flush → idle timer starts
|
|
4196
|
+
* Idle timer fires (no new events for idleTimeoutMs) → transition to PASSTHROUGH
|
|
4197
|
+
*/
|
|
4198
|
+
declare function burstBuffer<T>(options: BurstBufferOptions): OperatorFunction<T, T | T[]>;
|
|
4199
|
+
|
|
4139
4200
|
/**
|
|
4140
4201
|
* Logger interface for observability
|
|
4141
4202
|
*
|
|
@@ -5204,4 +5265,4 @@ declare class ConfigurationError extends Error {
|
|
|
5204
5265
|
declare const CORE_TYPES_VERSION = "0.1.0";
|
|
5205
5266
|
declare const SDK_VERSION = "0.1.0";
|
|
5206
5267
|
|
|
5207
|
-
export { APIError, type AWSConfig, type AccessToken, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationProgress, type AnnotationRemovedEvent, type AnnotationUri, type AppConfig, type AuthCode, type BackendServiceConfig, type BaseEvent, type BaseUrl, type BodyItem, type BodyOperation, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, type ConfigFileReader, ConfigurationError, ConflictError, type ContentFormat$1 as ContentFormat, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type Email, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityType, type EntityTypeStats, type Environment, type EnvironmentConfig, EventBus, type EventMap, type EventMetadata, type EventName, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GenerationContext, type GenerationProgress, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type InferenceServiceConfig, type JobCompletedEvent, type JobFailedEvent, type JobId, type JobProgressEvent, type JobStartedEvent, type Logger, type MCPToken, type McpServiceConfig, type Motivation$2 as Motivation, NotFoundError, type PlatformType, type ProxyServiceConfig, type RefreshToken, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, type SemiontConfig, SemiontError, type ServiceConfig, type ServicePlatformConfig, type ServicesConfig, type SiteConfig, type StoredEvent, type SystemEvent, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, type ValidationResult, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, type components, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent$1 as isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, type operations, parseAndMergeConfigs, parseEnvironment, type paths, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
|
|
5268
|
+
export { APIError, type AWSConfig, type AccessToken, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationProgress, type AnnotationRemovedEvent, type AnnotationUri, type AppConfig, type AuthCode, type BackendServiceConfig, type BaseEvent, type BaseUrl, type BodyItem, type BodyOperation, type BurstBufferOptions, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, type ConfigFileReader, ConfigurationError, ConflictError, type ContentFormat$1 as ContentFormat, type CreateAnnotationInternal, type CreationMethod, type DatabaseServiceConfig, type Email, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityType, type EntityTypeStats, type Environment, type EnvironmentConfig, EventBus, type EventMap, type EventMetadata, type EventName, type EventQuery, type EventSignature, type FilesystemServiceConfig, type FrontendServiceConfig, type GenerationContext, type GenerationProgress, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphDatabaseType, type GraphPath, type GraphServiceConfig, type InferenceServiceConfig, type JobCompletedEvent, type JobFailedEvent, type JobId, type JobProgressEvent, type JobStartedEvent, type Logger, type MCPToken, type McpServiceConfig, type Motivation$2 as Motivation, NotFoundError, type PlatformType, type ProxyServiceConfig, type RefreshToken, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, type SemiontConfig, SemiontError, type ServiceConfig, type ServicePlatformConfig, type ServicesConfig, type SiteConfig, type StoredEvent, type SystemEvent, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, type ValidationResult, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, burstBuffer, cloneToken, type components, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent$1 as isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, type operations, parseAndMergeConfigs, parseEnvironment, type paths, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
1
|
+
import { Subject, Observable } from 'rxjs';
|
|
2
2
|
import Ajv from 'ajv';
|
|
3
3
|
import addFormats from 'ajv-formats';
|
|
4
4
|
|
|
@@ -293,6 +293,84 @@ var ScopedEventBus = class _ScopedEventBus {
|
|
|
293
293
|
return new _ScopedEventBus(this.parent, `${this.scopePrefix}:${subScope}`);
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
|
+
function burstBuffer(options) {
|
|
297
|
+
const { burstWindowMs, maxBatchSize, idleTimeoutMs } = options;
|
|
298
|
+
return (source) => new Observable((subscriber) => {
|
|
299
|
+
let mode = "passthrough";
|
|
300
|
+
let buffer = [];
|
|
301
|
+
let burstTimer = null;
|
|
302
|
+
let idleTimer = null;
|
|
303
|
+
function clearBurstTimer() {
|
|
304
|
+
if (burstTimer !== null) {
|
|
305
|
+
clearTimeout(burstTimer);
|
|
306
|
+
burstTimer = null;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function clearIdleTimer() {
|
|
310
|
+
if (idleTimer !== null) {
|
|
311
|
+
clearTimeout(idleTimer);
|
|
312
|
+
idleTimer = null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function flush() {
|
|
316
|
+
if (buffer.length === 0) return;
|
|
317
|
+
const batch = buffer;
|
|
318
|
+
buffer = [];
|
|
319
|
+
subscriber.next(batch);
|
|
320
|
+
}
|
|
321
|
+
function startIdleTimer() {
|
|
322
|
+
clearIdleTimer();
|
|
323
|
+
idleTimer = setTimeout(() => {
|
|
324
|
+
idleTimer = null;
|
|
325
|
+
mode = "passthrough";
|
|
326
|
+
}, idleTimeoutMs);
|
|
327
|
+
}
|
|
328
|
+
const subscription = source.subscribe({
|
|
329
|
+
next(value) {
|
|
330
|
+
clearIdleTimer();
|
|
331
|
+
if (mode === "passthrough") {
|
|
332
|
+
subscriber.next(value);
|
|
333
|
+
mode = "accumulating";
|
|
334
|
+
burstTimer = setTimeout(() => {
|
|
335
|
+
burstTimer = null;
|
|
336
|
+
flush();
|
|
337
|
+
startIdleTimer();
|
|
338
|
+
}, burstWindowMs);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
buffer.push(value);
|
|
342
|
+
clearBurstTimer();
|
|
343
|
+
if (buffer.length >= maxBatchSize) {
|
|
344
|
+
flush();
|
|
345
|
+
startIdleTimer();
|
|
346
|
+
} else {
|
|
347
|
+
burstTimer = setTimeout(() => {
|
|
348
|
+
burstTimer = null;
|
|
349
|
+
flush();
|
|
350
|
+
startIdleTimer();
|
|
351
|
+
}, burstWindowMs);
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
error(err) {
|
|
355
|
+
clearBurstTimer();
|
|
356
|
+
clearIdleTimer();
|
|
357
|
+
flush();
|
|
358
|
+
subscriber.error(err);
|
|
359
|
+
},
|
|
360
|
+
complete() {
|
|
361
|
+
clearBurstTimer();
|
|
362
|
+
clearIdleTimer();
|
|
363
|
+
flush();
|
|
364
|
+
subscriber.complete();
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
return () => {
|
|
368
|
+
clearBurstTimer();
|
|
369
|
+
clearIdleTimer();
|
|
370
|
+
subscription.unsubscribe();
|
|
371
|
+
};
|
|
372
|
+
});
|
|
373
|
+
}
|
|
296
374
|
|
|
297
375
|
// src/annotation-utils.ts
|
|
298
376
|
function findBodyItem(body, targetItem) {
|
|
@@ -2297,6 +2375,6 @@ function getAllPlatformTypes() {
|
|
|
2297
2375
|
var CORE_TYPES_VERSION = "0.1.0";
|
|
2298
2376
|
var SDK_VERSION = "0.1.0";
|
|
2299
2377
|
|
|
2300
|
-
export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, cloneToken, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, parseAndMergeConfigs, parseEnvironment, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
|
|
2378
|
+
export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationIdToURI, annotationUri, authCode, baseUrl, burstBuffer, cloneToken, createConfigLoader, deepMerge, didToAgent, displayConfiguration, email, entityType, extractResourceUriFromAnnotationUri, findBodyItem, formatErrors, getAllPlatformTypes, getAnnotationUriFromEvent, getEventType, getNodeEnvForEnvironment, googleCredential, hasAWSConfig, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent2 as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, listEnvironmentNames, mcpToken, parseAndMergeConfigs, parseEnvironment, refreshToken, resolveEnvVars, resourceAnnotationUri, resourceId, resourceIdToURI, resourceUri, searchQuery, uriToAnnotationId, uriToAnnotationIdOrPassthrough, uriToResourceId, userDID, userId, userToAgent, userToDid, validateEnvironment, validateEnvironmentConfig, validateSemiontConfig, validateSiteConfig };
|
|
2301
2379
|
//# sourceMappingURL=index.js.map
|
|
2302
2380
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/branded-types.ts","../src/creation-methods.ts","../src/identifiers.ts","../src/uri-utils.ts","../src/events.ts","../src/event-utils.ts","../src/event-bus.ts","../src/annotation-utils.ts","../src/type-guards.ts","../src/errors.ts","../src/did-utils.ts","../src/config/configuration-error.ts","../src/config/config.schema.json","../src/config/config-validator.ts","../src/config/environment-loader.ts","../src/config/environment-validator.ts","../src/config/platform-types.ts","../src/index.ts"],"names":["annotationUri","resourceUri","baseUrl","isResourceEvent","resourceId","userId"],"mappings":";;;;;AA0CO,SAAS,MAAM,KAAA,EAAsB;AAAE,EAAA,OAAO,KAAA;AAAgB;AAC9D,SAAS,SAAS,KAAA,EAAyB;AAAE,EAAA,OAAO,KAAA;AAAmB;AACvE,SAAS,iBAAiB,KAAA,EAAiC;AAAE,EAAA,OAAO,KAAA;AAA2B;AAC/F,SAAS,YAAY,KAAA,EAA4B;AAAE,EAAA,OAAO,KAAA;AAAsB;AAChF,SAAS,aAAa,KAAA,EAA6B;AAAE,EAAA,OAAO,KAAA;AAAuB;AACnF,SAAS,SAAS,KAAA,EAAyB;AAAE,EAAA,OAAO,KAAA;AAAmB;AACvE,SAAS,WAAW,KAAA,EAA2B;AAAE,EAAA,OAAO,KAAA;AAAqB;AAC7E,SAAS,MAAM,KAAA,EAAsB;AAAE,EAAA,OAAO,KAAA;AAAgB;AAC9D,SAAS,QAAQ,KAAA,EAAwB;AAAE,EAAA,OAAO,KAAA;AAAkB;AACpE,SAAS,WAAW,KAAA,EAA2B;AAAE,EAAA,OAAO,KAAA;AAAqB;AAC7E,SAAS,YAAY,KAAA,EAA4B;AAAE,EAAA,OAAO,KAAA;AAAsB;AAChF,SAAS,QAAQ,KAAA,EAAwB;AAAE,EAAA,OAAO,KAAA;AAAkB;AAmBpE,SAAS,YAAY,GAAA,EAA0B;AACpD,EAAA,IAAI,CAAC,IAAI,UAAA,CAAW,SAAS,KAAK,CAAC,GAAA,CAA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;AC4LO,IAAM,kBAAA,GAAqB;AAC3B,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * Branded string types for compile-time type safety\n *\n * These types are zero-cost at runtime but prevent mixing\n * different string types at compile time.\n */\n\nimport type { components } from './types';\n\n// ============================================================================\n// OPENAPI-GENERATED TYPES (use directly from spec)\n// ============================================================================\n\nexport type Motivation = components['schemas']['Motivation'];\nexport type ContentFormat = components['schemas']['ContentFormat'];\n\n// ============================================================================\n// AUTHENTICATION & TOKENS\n// ============================================================================\n\nexport type Email = string & { readonly __brand: 'Email' };\nexport type AuthCode = string & { readonly __brand: 'AuthCode' };\nexport type GoogleCredential = string & { readonly __brand: 'GoogleCredential' };\nexport type AccessToken = string & { readonly __brand: 'AccessToken' };\nexport type RefreshToken = string & { readonly __brand: 'RefreshToken' };\nexport type MCPToken = string & { readonly __brand: 'MCPToken' };\nexport type CloneToken = string & { readonly __brand: 'CloneToken' };\n\n// ============================================================================\n// SYSTEM IDENTIFIERS\n// ============================================================================\n\nexport type JobId = string & { readonly __brand: 'JobId' };\nexport type UserDID = string & { readonly __brand: 'UserDID' };\nexport type EntityType = string & { readonly __brand: 'EntityType' };\nexport type SearchQuery = string & { readonly __brand: 'SearchQuery' };\nexport type BaseUrl = string & { readonly __brand: 'BaseUrl' };\n\n// ============================================================================\n// HELPER FUNCTIONS (minimal validation, just branding)\n// ============================================================================\n\nexport function email(value: string): Email { return value as Email; }\nexport function authCode(value: string): AuthCode { return value as AuthCode; }\nexport function googleCredential(value: string): GoogleCredential { return value as GoogleCredential; }\nexport function accessToken(value: string): AccessToken { return value as AccessToken; }\nexport function refreshToken(value: string): RefreshToken { return value as RefreshToken; }\nexport function mcpToken(value: string): MCPToken { return value as MCPToken; }\nexport function cloneToken(value: string): CloneToken { return value as CloneToken; }\nexport function jobId(value: string): JobId { return value as JobId; }\nexport function userDID(value: string): UserDID { return value as UserDID; }\nexport function entityType(value: string): EntityType { return value as EntityType; }\nexport function searchQuery(value: string): SearchQuery { return value as SearchQuery; }\nexport function baseUrl(value: string): BaseUrl { return value as BaseUrl; }\n\n// Motivation and ContentFormat use OpenAPI enums - no helpers needed\n// Use the enum values directly from the OpenAPI spec\n\n// ============================================================================\n// HTTP URI TYPES\n// ============================================================================\n\n// Branded type definitions for HTTP URIs returned by the API\nexport type ResourceUri = string & { readonly __brand: 'ResourceUri' };\n\n// W3C flat format for content negotiation: http://localhost:4000/annotations/{id}\nexport type AnnotationUri = string & { readonly __brand: 'AnnotationUri' };\n\n// Nested format for CRUD operations: http://localhost:4000/resources/{resourceId}/annotations/{annotationId}\nexport type ResourceAnnotationUri = string & { readonly __brand: 'ResourceAnnotationUri' };\n\n// Factory functions with runtime validation\nexport function resourceUri(uri: string): ResourceUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceUri, got: ${uri}`);\n }\n return uri as ResourceUri;\n}\n\nexport function annotationUri(uri: string): AnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected AnnotationUri, got: ${uri}`);\n }\n return uri as AnnotationUri;\n}\n\nexport function resourceAnnotationUri(uri: string): ResourceAnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceAnnotationUri, got: ${uri}`);\n }\n // Additional validation: must contain /resources/ and /annotations/\n if (!uri.includes('/resources/') || !uri.includes('/annotations/')) {\n throw new TypeError(`Expected nested ResourceAnnotationUri format, got: ${uri}`);\n }\n return uri as ResourceAnnotationUri;\n}\n","/**\n * Resource creation methods - How resources are created in the system\n */\n\n/**\n * Enumeration of all possible resource creation methods\n */\nexport const CREATION_METHODS = {\n API: 'api',\n UPLOAD: 'upload',\n UI: 'ui',\n REFERENCE: 'reference',\n CLONE: 'clone',\n GENERATED: 'generated',\n} as const;\n\n/**\n * Type for resource creation methods\n */\nexport type CreationMethod = typeof CREATION_METHODS[keyof typeof CREATION_METHODS];","/**\n * Branded identifier types for compile-time type safety.\n *\n * These types prevent mixing up resource IDs, annotation IDs, and user IDs\n * at compile time while having zero runtime overhead.\n *\n * URI types (ResourceUri, AnnotationUri) are in @semiont/api-client\n * since they deal with HTTP URIs returned by the API.\n */\n\n// Branded type definitions for IDs only\nexport type ResourceId = string & { readonly __brand: 'ResourceId' };\nexport type AnnotationId = string & { readonly __brand: 'AnnotationId' };\nexport type UserId = string & { readonly __brand: 'UserId' };\n\n// Type guards with runtime validation\nexport function isResourceId(value: string): value is ResourceId {\n return !value.includes('/');\n}\n\nexport function isAnnotationId(value: string): value is AnnotationId {\n return !value.includes('/');\n}\n\n// Factory functions with runtime validation\nexport function resourceId(id: string): ResourceId {\n if (id.includes('/')) {\n throw new TypeError(`Expected ResourceId, got URI: ${id}`);\n }\n return id as ResourceId;\n}\n\nexport function annotationId(id: string): AnnotationId {\n if (id.includes('/')) {\n throw new TypeError(`Expected AnnotationId, got URI: ${id}`);\n }\n return id as AnnotationId;\n}\n\nexport function userId(id: string): UserId {\n return id as UserId;\n}\n","/**\n * URI utilities for W3C annotations\n *\n * Converts between short resource/annotation IDs and full URIs.\n * Full URIs are required by W3C Web Annotation Data Model.\n */\n\nimport { resourceId, annotationId, type ResourceId, type AnnotationId } from './identifiers';\nimport { resourceUri, annotationUri, type ResourceUri, type AnnotationUri, type ResourceAnnotationUri } from './branded-types';\n\n/**\n * Convert resource ID to full URI\n *\n * @param id - Short resource ID (e.g., \"doc-abc123\")\n * @param publicURL - Backend base URL\n * @returns Full URI (e.g., \"https://api.semiont.app/resources/doc-abc123\")\n *\n * @example\n * resourceIdToURI(\"doc-abc123\", \"https://api.semiont.app\")\n * // => \"https://api.semiont.app/resources/doc-abc123\"\n */\nexport function resourceIdToURI(id: ResourceId, publicURL: string): ResourceUri {\n // Remove trailing slash if present\n const normalizedBase = publicURL.endsWith('/') ? publicURL.slice(0, -1) : publicURL;\n return resourceUri(`${normalizedBase}/resources/${id}` );\n}\n\n/**\n * Extract resource ID from full URI\n *\n * @param uri - Full resource URI (e.g., \"https://api.semiont.app/resources/doc-abc123\")\n * @returns Short resource ID (e.g., \"doc-abc123\")\n * @throws Error if URI format is invalid\n *\n * @example\n * uriToResourceId(\"https://api.semiont.app/resources/doc-abc123\")\n * // => \"doc-abc123\"\n */\nexport function uriToResourceId(uri: string): ResourceId {\n const url = new URL(uri);\n const match = url.pathname.match(/\\/resources\\/([^/]+)/);\n if (!match || !match[1]) {\n throw new Error(`Invalid resource URI: ${uri}`);\n }\n return resourceId(match[1]);\n}\n\n/**\n * Convert annotation ID to full URI\n *\n * @param id - Short annotation ID (e.g., \"anno-xyz789\")\n * @param publicURL - Backend base URL\n * @returns Full URI (e.g., \"https://api.semiont.app/annotations/anno-xyz789\")\n *\n * @example\n * annotationIdToURI(\"anno-xyz789\", \"https://api.semiont.app\")\n * // => \"https://api.semiont.app/annotations/anno-xyz789\"\n */\nexport function annotationIdToURI(id: AnnotationId, publicURL: string): AnnotationUri {\n // Remove trailing slash if present\n const normalizedBase = publicURL.endsWith('/') ? publicURL.slice(0, -1) : publicURL;\n return annotationUri(`${normalizedBase}/annotations/${id}`);\n}\n\n/**\n * Extract annotation ID from full URI\n *\n * @param uri - Full annotation URI (e.g., \"https://api.semiont.app/annotations/anno-xyz789\")\n * @returns Short annotation ID (e.g., \"anno-xyz789\")\n * @throws Error if URI format is invalid\n *\n * @example\n * uriToAnnotationId(\"https://api.semiont.app/annotations/anno-xyz789\")\n * // => \"anno-xyz789\"\n */\nexport function uriToAnnotationId(uri: string): AnnotationId {\n const url = new URL(uri);\n const match = url.pathname.match(/\\/annotations\\/([^/]+)/);\n if (!match || !match[1]) {\n throw new Error(`Invalid annotation URI: ${uri}`);\n }\n return annotationId(match[1]);\n}\n\n/**\n * Extract annotation ID from URI or pass through if already an ID\n *\n * Defensive version of uriToAnnotationId that handles both:\n * - Full URIs: \"https://api.semiont.app/annotations/anno-xyz789\" → \"anno-xyz789\"\n * - Already IDs: \"anno-xyz789\" → \"anno-xyz789\"\n *\n * @param uriOrId - Full annotation URI or short ID\n * @returns Short annotation ID\n *\n * @example\n * uriToAnnotationIdOrPassthrough(\"https://api.semiont.app/annotations/anno-xyz789\")\n * // => \"anno-xyz789\"\n *\n * uriToAnnotationIdOrPassthrough(\"anno-xyz789\")\n * // => \"anno-xyz789\"\n */\nexport function uriToAnnotationIdOrPassthrough(uriOrId: string): AnnotationId {\n // Try parsing as URI first\n try {\n return uriToAnnotationId(uriOrId);\n } catch {\n // If it fails, assume it's already an ID and return as-is\n return annotationId(uriOrId);\n }\n}\n\n/**\n * Extract resource URI from nested annotation URI\n *\n * @param annotationUri - Nested ResourceAnnotationUri (e.g., \"https://api.semiont.app/resources/doc-123/annotations/anno-456\")\n * @returns Resource URI (e.g., \"https://api.semiont.app/resources/doc-123\")\n * @throws Error if URI format is invalid\n *\n * @example\n * extractResourceUriFromAnnotationUri(\"https://api.semiont.app/resources/doc-123/annotations/anno-456\")\n * // => \"https://api.semiont.app/resources/doc-123\"\n */\nexport function extractResourceUriFromAnnotationUri(annotationUri: ResourceAnnotationUri): ResourceUri {\n const parts = annotationUri.split('/annotations/');\n if (parts.length !== 2) {\n throw new Error(`Invalid annotation URI format: ${annotationUri}`);\n }\n return resourceUri(parts[0]);\n}\n","/**\n * Resource Event Types\n *\n * Event-sourced architecture for resource state management\n * Events are stored in an append-only log (JSONL format)\n *\n * Federation-ready design:\n * - resourceId uses content hashes (doc-sha256:...)\n * - userId uses DID format (did:web:org.com:users:alice)\n * - prevEventHash creates tamper-evident chains\n * - Optional signatures for cross-org verification\n */\n\nimport type { CreationMethod } from './creation-methods';\nimport type { components } from './types';\nimport type { AnnotationUri, JobId } from './branded-types';\nimport type { ResourceId, AnnotationId, UserId } from './identifiers';\n\n// Import OpenAPI types\ntype Annotation = components['schemas']['Annotation'];\ntype ContentFormat = components['schemas']['ContentFormat'];\ntype Motivation = components['schemas']['Motivation'];\n\nexport interface BaseEvent {\n id: string; // Unique event ID (UUID)\n timestamp: string; // ISO 8601 timestamp (for humans, NOT for ordering)\n resourceId?: ResourceId; // Optional - present for resource-scoped events, absent for system events\n // Use isSystemEvent() / isResourceScopedEvent() type guards for routing\n userId: UserId; // DID format: did:web:org.com:users:alice (federation-ready)\n version: number; // Event schema version\n}\n\n// Resource lifecycle events\nexport interface ResourceCreatedEvent extends BaseEvent {\n type: 'resource.created';\n payload: {\n name: string;\n format: ContentFormat; // MIME type (validated enum)\n contentChecksum: string; // SHA-256 of content (should match resourceId)\n contentByteSize?: number; // Size of content in bytes\n creationMethod: CreationMethod; // How the resource was created\n entityTypes?: string[];\n\n // First-class fields (promoted from metadata)\n language?: string; // Language/locale code (e.g., 'en', 'es', 'fr')\n isDraft?: boolean; // Draft status for generated resources\n generatedFrom?: string; // Annotation/Reference ID that triggered generation\n generationPrompt?: string; // Prompt used for AI generation (events-only, not on Resource)\n };\n}\n\nexport interface ResourceClonedEvent extends BaseEvent {\n type: 'resource.cloned';\n payload: {\n name: string;\n format: ContentFormat; // MIME type (validated enum)\n contentChecksum: string; // SHA-256 of new content\n contentByteSize?: number; // Size of content in bytes\n parentResourceId: string; // Content hash of parent resource\n creationMethod: CreationMethod; // How the resource was created\n entityTypes?: string[];\n\n // First-class fields (promoted from metadata)\n language?: string; // Language/locale code (e.g., 'en', 'es', 'fr')\n };\n}\n\nexport interface ResourceArchivedEvent extends BaseEvent {\n type: 'resource.archived';\n payload: {\n reason?: string;\n };\n}\n\nexport interface ResourceUnarchivedEvent extends BaseEvent {\n type: 'resource.unarchived';\n payload: Record<string, never>; // Empty payload\n}\n\n// Representation events (multi-format support)\nexport interface RepresentationAddedEvent extends BaseEvent {\n type: 'representation.added';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n representation: {\n '@id': string; // Unique ID (content hash)\n mediaType: string; // MIME type (e.g., 'text/markdown', 'application/pdf')\n byteSize: number; // Size in bytes\n checksum: string; // Content hash (SHA-256)\n created: string; // ISO 8601 timestamp\n rel?: 'original' | 'thumbnail' | 'preview' | 'optimized' | 'derived' | 'other';\n storageUri?: string; // Where bytes are stored (optional)\n filename?: string; // Original filename (optional)\n language?: string; // IETF BCP 47 language tag (optional, for translations)\n width?: number; // Pixels (images/video)\n height?: number; // Pixels (images/video)\n duration?: number; // Seconds (audio/video)\n };\n };\n}\n\nexport interface RepresentationRemovedEvent extends BaseEvent {\n type: 'representation.removed';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n checksum: string; // Which representation to remove\n };\n}\n\n// Unified annotation events\n// Single principle: An annotation is an annotation. The motivation field tells you what kind it is.\nexport interface AnnotationAddedEvent extends BaseEvent {\n type: 'annotation.added';\n payload: {\n annotation: Omit<Annotation, 'creator' | 'created'>; // W3C Annotation (creator/created come from event metadata)\n };\n}\n\nexport interface AnnotationRemovedEvent extends BaseEvent {\n type: 'annotation.removed';\n payload: {\n annotationId: AnnotationId; // Branded type for compile-time safety\n };\n}\n\n// Body operation types for fine-grained annotation body modifications\nexport type BodyItem =\n | { type: 'TextualBody'; value: string; purpose?: Motivation; format?: string; language?: string }\n | { type: 'SpecificResource'; source: string; purpose?: Motivation };\n\nexport type BodyOperation =\n | { op: 'add'; item: BodyItem }\n | { op: 'remove'; item: BodyItem }\n | { op: 'replace'; oldItem: BodyItem; newItem: BodyItem };\n\nexport interface AnnotationBodyUpdatedEvent extends BaseEvent {\n type: 'annotation.body.updated';\n payload: {\n annotationId: AnnotationId; // Branded type for compile-time safety\n operations: BodyOperation[];\n };\n}\n\n// Job progress events (resource-level)\n// Emitted by background workers for real-time progress updates\nexport interface JobStartedEvent extends BaseEvent {\n type: 'job.started';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n totalSteps?: number; // Optional - total number of steps if known\n };\n}\n\nexport interface JobProgressEvent extends BaseEvent {\n type: 'job.progress';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n percentage: number; // 0-100\n currentStep?: string; // Human-readable current step (e.g., \"Scanning for Person\")\n processedSteps?: number; // Number of steps completed\n totalSteps?: number; // Total number of steps\n foundCount?: number; // For detection: number of entities found so far\n message?: string; // Optional status message\n progress?: any; // For new job types: full progress object\n };\n}\n\nexport interface JobCompletedEvent extends BaseEvent {\n type: 'job.completed';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n totalSteps?: number; // Total steps completed\n foundCount?: number; // For detection: total entities found\n resultResourceId?: ResourceId; // For generation: ID of generated resource (branded type)\n annotationUri?: AnnotationUri; // For generation: URI of annotation that triggered generation\n message?: string; // Optional completion message\n result?: any; // For new job types: full result object\n };\n}\n\nexport interface JobFailedEvent extends BaseEvent {\n type: 'job.failed';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n error: string; // Error message\n details?: string; // Optional detailed error information\n };\n}\n\n// Entity tag events (resource-level)\nexport interface EntityTagAddedEvent extends BaseEvent {\n type: 'entitytag.added';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n entityType: string;\n };\n}\n\nexport interface EntityTagRemovedEvent extends BaseEvent {\n type: 'entitytag.removed';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n entityType: string;\n };\n}\n\n// Entity type events (global collection)\nexport interface EntityTypeAddedEvent extends BaseEvent {\n type: 'entitytype.added';\n resourceId?: undefined; // System-level event - no resource scope\n payload: {\n entityType: string; // The entity type being added to global collection\n };\n}\n\n// Union type of all events\nexport type ResourceEvent =\n | ResourceCreatedEvent\n | ResourceClonedEvent\n | ResourceArchivedEvent\n | ResourceUnarchivedEvent\n | RepresentationAddedEvent // Multi-format support\n | RepresentationRemovedEvent // Multi-format support\n | AnnotationAddedEvent\n | AnnotationRemovedEvent\n | AnnotationBodyUpdatedEvent\n | JobStartedEvent // Job progress\n | JobProgressEvent // Job progress\n | JobCompletedEvent // Job progress\n | JobFailedEvent // Job progress\n | EntityTagAddedEvent // Resource-level\n | EntityTagRemovedEvent // Resource-level\n | EntityTypeAddedEvent; // Global collection\n\n// Extract just the event type strings from the union\nexport type ResourceEventType = ResourceEvent['type'];\n\n// System-level events (no resource scope)\nexport type SystemEvent = EntityTypeAddedEvent;\n\n// Resource-scoped events (require resourceId)\nexport type ResourceScopedEvent = Exclude<ResourceEvent, SystemEvent>;\n\n// Type guards\nexport function isResourceEvent(event: any): event is ResourceEvent {\n return event &&\n typeof event.id === 'string' &&\n typeof event.timestamp === 'string' &&\n (event.resourceId === undefined || typeof event.resourceId === 'string') && // resourceId now optional\n typeof event.type === 'string' &&\n event.type.includes('.');\n}\n\n/**\n * Type guard: Check if event is system-level (no resourceId)\n * System events affect global state, not individual resources\n */\nexport function isSystemEvent(event: ResourceEvent): event is SystemEvent {\n return event.type === 'entitytype.added';\n}\n\n/**\n * Type guard: Check if event is resource-scoped (has resourceId)\n * Resource events affect a specific resource's state\n */\nexport function isResourceScopedEvent(event: ResourceEvent): event is ResourceScopedEvent {\n return !isSystemEvent(event);\n}\n\nexport function getEventType<T extends ResourceEvent>(\n event: ResourceEvent\n): T['type'] {\n return event.type as T['type'];\n}\n\n// Event metadata for querying and indexing\nexport interface EventMetadata {\n sequenceNumber: number; // Position in the event log (source of truth for ordering)\n streamPosition: number; // Byte position in JSONL file\n timestamp: string; // When stored (for humans, not ordering)\n prevEventHash?: string; // SHA-256 of previous event (chain integrity, null for first event)\n checksum?: string; // SHA-256 of this event for integrity\n}\n\n// Optional signature for federation\nexport interface EventSignature {\n algorithm: 'ed25519'; // Signature algorithm\n publicKey: string; // User's public key (base64)\n signature: string; // Event signature (base64)\n keyId?: string; // Key identifier for rotation\n}\n\n// Event with metadata (as stored)\nexport interface StoredEvent<T extends ResourceEvent = ResourceEvent> {\n event: T;\n metadata: EventMetadata;\n signature?: EventSignature; // Optional, for federation (unused in MVP)\n}\n\n// Query filters for event retrieval\nexport interface EventQuery {\n resourceId?: ResourceId;\n userId?: string;\n eventTypes?: ResourceEvent['type'][];\n fromTimestamp?: string;\n toTimestamp?: string;\n fromSequence?: number;\n limit?: number;\n}\n\n// Annotation collections for a resource (view storage projection)\n// Annotations are NOT part of the resource - they reference the resource\nexport interface ResourceAnnotations {\n resourceId: ResourceId; // Which resource these annotations belong to (branded type)\n annotations: Annotation[]; // All annotations (highlights, references, assessments, etc.)\n version: number; // Event count for this resource's annotation stream\n updatedAt: string; // Last annotation event timestamp\n}","/**\n * Event Type Guards and Extraction Utilities\n *\n * Domain logic for working with resource events.\n * No React dependencies - safe to use in any JavaScript environment.\n */\n\nimport type { StoredEvent } from './events';\nimport type { AnnotationUri } from './branded-types';\n\n// =============================================================================\n// EVENT TYPE GUARDS AND EXTRACTION\n// =============================================================================\n\n/**\n * Extract annotation ID from event payload\n * Returns null if event is not annotation-related\n *\n * For annotation.added: extracts full URI from payload.annotation.id\n * For annotation.removed/body.updated: constructs full URI from payload.annotationId (UUID) + resourceId\n */\nexport function getAnnotationUriFromEvent(event: StoredEvent): AnnotationUri | null {\n const eventData = event.event;\n\n if (eventData.type === 'annotation.added') {\n // annotation.added has the full annotation object with id as full URI\n return eventData.payload.annotation.id as AnnotationUri || null;\n }\n\n if (eventData.type === 'annotation.removed' || eventData.type === 'annotation.body.updated') {\n // These events have annotationId (UUID only), need to construct full URI\n // Extract base URL from resourceId (format: http://host/resources/id)\n if (eventData.payload.annotationId && eventData.resourceId) {\n try {\n const resourceUri = eventData.resourceId;\n // Extract base URL by removing the /resources/{id} part\n const baseUrl = resourceUri.substring(0, resourceUri.lastIndexOf('/resources/'));\n return `${baseUrl}/annotations/${eventData.payload.annotationId}` as AnnotationUri;\n } catch (e) {\n return null;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Check if an event is related to a specific annotation\n */\nexport function isEventRelatedToAnnotation(event: StoredEvent, annotationUri: AnnotationUri): boolean {\n const eventAnnotationUri = getAnnotationUriFromEvent(event);\n return eventAnnotationUri === annotationUri;\n}\n\n/**\n * Type guard to check if event is a resource event\n */\nexport function isResourceEvent(event: any): event is StoredEvent {\n return event &&\n typeof event.event === 'object' &&\n typeof event.event.id === 'string' &&\n typeof event.event.timestamp === 'string' &&\n typeof event.event.resourceId === 'string' &&\n typeof event.event.type === 'string' &&\n typeof event.metadata === 'object' &&\n typeof event.metadata.sequenceNumber === 'number';\n}\n","/**\n * RxJS-based Event Bus\n *\n * Framework-agnostic event bus providing direct access to typed RxJS Subjects.\n *\n * Can be used in Node.js, browser, workers, CLI - anywhere RxJS runs.\n */\n\nimport { Subject } from 'rxjs';\nimport type { EventMap } from './event-map';\n\n/**\n * RxJS-based event bus\n *\n * Provides direct access to RxJS Subjects for each event type.\n * Use standard RxJS patterns for emitting and subscribing.\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n *\n * // Emit events\n * eventBus.get('attend:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe to events\n * const subscription = eventBus.get('attend:hover').subscribe(({ annotationId }) => {\n * console.log('Hover:', annotationId);\n * });\n *\n * // Use RxJS operators\n * import { debounceTime } from 'rxjs/operators';\n * eventBus.get('attend:hover')\n * .pipe(debounceTime(100))\n * .subscribe(handleHover);\n *\n * // Cleanup\n * subscription.unsubscribe();\n * eventBus.destroy();\n * ```\n */\nexport class EventBus {\n private subjects: Map<keyof EventMap, Subject<any>>;\n private isDestroyed: boolean;\n\n constructor() {\n this.subjects = new Map();\n this.isDestroyed = false;\n }\n\n /**\n * Get the RxJS Subject for an event\n *\n * Returns a typed Subject that can be used with all RxJS operators.\n * Subjects are created lazily on first access.\n *\n * @param eventName - The event name\n * @returns The RxJS Subject for this event\n *\n * @example\n * ```typescript\n * // Emit\n * eventBus.get('attend:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe\n * const sub = eventBus.get('attend:hover').subscribe(handleHover);\n *\n * // With operators\n * eventBus.get('attend:hover')\n * .pipe(debounceTime(100), distinctUntilChanged())\n * .subscribe(handleHover);\n * ```\n */\n get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]> {\n if (this.isDestroyed) {\n throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);\n }\n\n if (!this.subjects.has(eventName)) {\n this.subjects.set(eventName, new Subject<EventMap[K]>());\n }\n return this.subjects.get(eventName)!;\n }\n\n /**\n * Destroy the event bus and complete all subjects\n *\n * After calling destroy(), no new events can be emitted or subscribed to.\n * All active subscriptions will be completed.\n */\n destroy(): void {\n if (this.isDestroyed) {\n return;\n }\n\n for (const subject of this.subjects.values()) {\n subject.complete();\n }\n\n this.subjects.clear();\n this.isDestroyed = true;\n }\n\n /**\n * Check if the event bus has been destroyed\n */\n get destroyed(): boolean {\n return this.isDestroyed;\n }\n\n /**\n * Create a resource-scoped event bus\n *\n * Events emitted or subscribed through the scoped bus are isolated to that resource.\n * Internally, events are namespaced but the API remains identical to the parent bus.\n *\n * @param resourceId - Resource identifier to scope events to\n * @returns A scoped event bus for this resource\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n * const resource1 = eventBus.scope('resource-1');\n * const resource2 = eventBus.scope('resource-2');\n *\n * // These are isolated - only resource1 subscribers will fire\n * resource1.get('detection:progress').next({ status: 'started' });\n * ```\n */\n scope(resourceId: string): ScopedEventBus {\n return new ScopedEventBus(this, resourceId);\n }\n}\n\n/**\n * Resource-scoped event bus\n *\n * Provides isolated event streams per resource while maintaining the same API\n * as the parent EventBus. Events are internally namespaced by resourceId.\n */\nexport class ScopedEventBus {\n constructor(\n private parent: EventBus,\n private scopePrefix: string\n ) {}\n\n /**\n * Get the RxJS Subject for a scoped event\n *\n * Returns the same type as the parent bus, but events are isolated to this scope.\n * Internally uses namespaced keys but preserves type safety.\n *\n * @param event - The event name\n * @returns The RxJS Subject for this scoped event\n */\n get<E extends keyof EventMap>(event: E): Subject<EventMap[E]> {\n // Internally namespace the event key, but preserve return type\n const scopedKey = `${this.scopePrefix}:${event as string}`;\n\n // Access parent's subjects map directly (needs cast for private access)\n const parentSubjects = (this.parent as any).subjects as Map<string, Subject<any>>;\n\n if (!parentSubjects.has(scopedKey)) {\n parentSubjects.set(scopedKey, new Subject<EventMap[E]>());\n }\n return parentSubjects.get(scopedKey)!;\n }\n\n /**\n * Create a nested scope\n *\n * Allows hierarchical scoping like `resource-1:subsystem-a`\n *\n * @param subScope - Additional scope level\n * @returns A nested scoped event bus\n */\n scope(subScope: string): ScopedEventBus {\n return new ScopedEventBus(this.parent, `${this.scopePrefix}:${subScope}`);\n }\n}\n","/**\n * Backend-specific annotation utility functions\n */\n\nimport type { components } from './types';\nimport type { BodyItem } from './events';\n\ntype Annotation = components['schemas']['Annotation'];\n\n/**\n * Find a body item in an array\n * Returns the index of the first matching item, or -1 if not found\n */\nexport function findBodyItem(body: Annotation['body'], targetItem: BodyItem): number {\n if (!Array.isArray(body)) {\n return -1;\n }\n\n for (let i = 0; i < body.length; i++) {\n const item = body[i];\n\n // Check if this is a valid body item that can be matched\n if (\n typeof item === 'object' &&\n item !== null &&\n 'type' in item &&\n 'purpose' in item\n ) {\n const itemType = (item as { type: unknown }).type;\n const itemPurpose = (item as { purpose: unknown }).purpose;\n\n // Type and purpose must match\n if (itemType !== targetItem.type || itemPurpose !== targetItem.purpose) {\n continue;\n }\n\n // For TextualBody, match by value\n if (targetItem.type === 'TextualBody' && 'value' in item) {\n const itemValue = (item as { value: unknown }).value;\n if (itemValue === targetItem.value) {\n return i;\n }\n }\n\n // For SpecificResource, match by source\n if (targetItem.type === 'SpecificResource' && 'source' in item) {\n const itemSource = (item as { source: unknown }).source;\n if (itemSource === targetItem.source) {\n return i;\n }\n }\n }\n }\n\n return -1;\n}\n","/**\n * Common type guard utilities\n */\n\n/**\n * Check if value is a string\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Check if value is a number (not NaN)\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !isNaN(value);\n}\n\n/**\n * Check if value is an object (not null, not array)\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Check if value is an array\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/**\n * Check if value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Check if value is a function\n */\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Check if value is null\n */\nexport function isNull(value: unknown): value is null {\n return value === null;\n}\n\n/**\n * Check if value is undefined\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined;\n}\n\n/**\n * Check if value is null or undefined\n */\nexport function isNullish(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n\n/**\n * Check if value is defined (not null or undefined)\n */\nexport function isDefined<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}","/**\n * Common error classes\n */\n\n/**\n * Base error class for Semiont applications\n */\nexport class SemiontError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: Record<string, any>\n ) {\n super(message);\n this.name = 'SemiontError';\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when validation fails\n */\nexport class ValidationError extends SemiontError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'VALIDATION_ERROR', details);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Error thrown by scripts\n */\nexport class ScriptError extends SemiontError {\n constructor(message: string, code: string = 'SCRIPT_ERROR', details?: Record<string, any>) {\n super(message, code, details);\n this.name = 'ScriptError';\n }\n}\n\n/**\n * Error thrown when a resource is not found\n */\nexport class NotFoundError extends SemiontError {\n constructor(resource: string, id?: string) {\n const message = id ? `${resource} with id '${id}' not found` : `${resource} not found`;\n super(message, 'NOT_FOUND', { resource, id });\n this.name = 'NotFoundError';\n }\n}\n\n/**\n * Error thrown when user is not authorized\n */\nexport class UnauthorizedError extends SemiontError {\n constructor(message: string = 'Unauthorized', details?: Record<string, any>) {\n super(message, 'UNAUTHORIZED', details);\n this.name = 'UnauthorizedError';\n }\n}\n\n/**\n * Error thrown when operation would conflict with existing data\n */\nexport class ConflictError extends SemiontError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'CONFLICT', details);\n this.name = 'ConflictError';\n }\n}\n\n/**\n * API Error class for handling HTTP errors\n * Used by API clients to represent failed HTTP requests\n */\nexport class APIError extends Error {\n constructor(\n public status: number,\n public data: any,\n message?: string\n ) {\n super(message || `API Error: ${status}`);\n this.name = 'APIError';\n Error.captureStackTrace(this, this.constructor);\n }\n}","/**\n * DID (Decentralized Identifier) and W3C Agent utilities\n *\n * Provides utilities for working with DID:WEB identifiers and converting\n * between user representations and W3C Web Annotation Agent objects.\n */\n\nimport type { components } from './types';\n\ntype Agent = components['schemas']['Agent'];\n\n/**\n * Convert a user object to a DID:WEB identifier\n *\n * Format: did:web:domain.com:users:userId\n * Example: did:web:example.com:users:abc123\n *\n * This is used for W3C Web Annotation compliance and federation readiness.\n *\n * @param user - User object with id and domain\n * @returns DID:WEB identifier string\n */\nexport function userToDid(user: { id: string; domain: string }): string {\n return `did:web:${user.domain}:users:${user.id}`;\n}\n\n/**\n * Convert a user object to a W3C Agent object with DID:WEB identifier\n *\n * Creates a full Agent object for W3C Web Annotation compliance.\n * Includes DID:WEB identifier, type, and name.\n *\n * @param user - User object with id, domain, name, and email\n * @returns W3C Agent object\n */\nexport function userToAgent(user: {\n id: string;\n domain: string;\n name: string | null;\n email: string;\n}): Agent {\n return {\n type: 'Person' as const,\n id: userToDid(user),\n name: user.name || user.email,\n };\n}\n\n/**\n * Convert a DID string to a minimal W3C Agent object\n *\n * Used when reconstructing annotations from events where only the DID is available.\n * Creates a minimal Agent with just the required fields (id, type).\n * Name is derived from the DID for display purposes.\n *\n * @param did - DID:WEB identifier string\n * @returns Minimal W3C Agent object\n */\nexport function didToAgent(did: string): Agent {\n // Extract user ID from DID format: did:web:domain.com:users:userId\n const parts = did.split(':');\n const userId = parts[parts.length - 1] || 'unknown';\n\n return {\n type: 'Person' as const,\n id: did,\n name: userId, // Use user ID as name since we don't have full user data\n };\n}\n","/**\n * Configuration Error Class\n * \n * Custom error class for configuration validation and loading errors.\n * Provides structured error information with helpful suggestions.\n */\n\nexport class ConfigurationError extends Error {\n public override readonly cause?: Error;\n\n constructor(\n message: string,\n public environment?: string,\n public suggestion?: string,\n cause?: Error\n ) {\n super(message);\n this.name = 'ConfigurationError';\n this.cause = cause;\n }\n \n /**\n * Format the error nicely for CLI output\n */\n override toString(): string {\n let output = `❌ ${this.message}`;\n if (this.environment) {\n output += `\\n Environment: ${this.environment}`;\n }\n if (this.suggestion) {\n output += `\\n 💡 Suggestion: ${this.suggestion}`;\n }\n return output;\n }\n}","{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://semiont.org/schemas/config.json\",\n \"definitions\": {\n \"PlatformType\": {\n \"type\": \"string\",\n \"enum\": [\n \"posix\",\n \"container\",\n \"aws\",\n \"external\"\n ]\n },\n \"ServicePlatformConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"type\": {\n \"$ref\": \"#/definitions/PlatformType\"\n }\n },\n \"required\": [\n \"type\"\n ]\n },\n \"ResourceRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"cpu\": {\n \"type\": \"string\"\n },\n \"memory\": {\n \"type\": \"string\"\n },\n \"gpu\": {\n \"type\": \"integer\"\n },\n \"gpus\": {\n \"type\": \"integer\"\n },\n \"replicas\": {\n \"type\": \"integer\"\n },\n \"ephemeralStorage\": {\n \"type\": \"string\"\n },\n \"memoryReservation\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n },\n \"SecurityRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"readOnlyRootFilesystem\": {\n \"type\": \"boolean\"\n },\n \"runAsNonRoot\": {\n \"type\": \"boolean\"\n },\n \"runAsUser\": {\n \"type\": \"integer\"\n },\n \"runAsGroup\": {\n \"type\": \"integer\"\n },\n \"capabilities\": {\n \"oneOf\": [\n {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"add\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"drop\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n }\n ]\n },\n \"privileged\": {\n \"type\": \"boolean\"\n },\n \"allowPrivilegeEscalation\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"BuildRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"BackendServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"devMode\": {\n \"type\": \"boolean\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"publicURL\": {\n \"type\": \"string\"\n },\n \"corsOrigin\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"cpu\": {\n \"type\": \"string\"\n },\n \"memory\": {\n \"type\": \"string\"\n },\n \"semiontRepo\": {\n \"type\": \"string\"\n },\n \"databaseUrl\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"redisUrl\": {\n \"type\": \"string\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"port\",\n \"publicURL\",\n \"corsOrigin\"\n ],\n \"additionalProperties\": false\n },\n \"FrontendServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"devMode\": {\n \"type\": \"boolean\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"siteName\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"semiontRepo\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n },\n \"databaseUrl\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"publicURL\": {\n \"type\": \"string\"\n },\n \"allowedOrigins\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"port\",\n \"siteName\"\n ],\n \"additionalProperties\": false\n },\n \"ProxyServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\"envoy\", \"nginx\", \"haproxy\"],\n \"default\": \"envoy\"\n },\n \"port\": {\n \"type\": \"integer\",\n \"default\": 8080\n },\n \"adminPort\": {\n \"type\": \"integer\",\n \"default\": 9901\n },\n \"backendPort\": {\n \"type\": \"integer\",\n \"default\": 4000\n },\n \"frontendPort\": {\n \"type\": \"integer\",\n \"default\": 3000\n },\n \"image\": {\n \"type\": \"string\",\n \"default\": \"envoyproxy/envoy:v1.28-latest\"\n },\n \"configPath\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"port\"\n ],\n \"additionalProperties\": false\n },\n \"DatabaseServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"host\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"user\": {\n \"type\": \"string\"\n },\n \"username\": {\n \"type\": \"string\"\n },\n \"password\": {\n \"type\": \"string\"\n },\n \"database\": {\n \"type\": \"string\"\n },\n \"storageSize\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"host\",\n \"port\"\n ],\n \"additionalProperties\": false\n },\n \"GraphDatabaseType\": {\n \"type\": \"string\",\n \"enum\": [\n \"neo4j\",\n \"janusgraph\",\n \"neptune\",\n \"memory\"\n ]\n },\n \"GraphServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"$ref\": \"#/definitions/GraphDatabaseType\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"uri\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"username\": {\n \"type\": \"string\"\n },\n \"password\": {\n \"type\": \"string\"\n },\n \"database\": {\n \"type\": \"string\"\n },\n \"host\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"storage\": {\n \"type\": \"string\"\n },\n \"index\": {\n \"type\": \"string\"\n },\n \"endpoint\": {\n \"type\": \"string\"\n },\n \"region\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"janusgraphVersion\": {\n \"type\": \"string\"\n },\n \"javaOptions\": {\n \"type\": \"string\"\n },\n \"heapSize\": {\n \"type\": \"string\"\n },\n \"pageCacheSize\": {\n \"type\": \"string\"\n },\n \"noAuth\": {\n \"type\": \"boolean\"\n },\n \"dataPath\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\"\n ],\n \"allOf\": [\n {\n \"if\": {\n \"properties\": {\n \"type\": {\n \"const\": \"neo4j\"\n }\n }\n },\n \"then\": {\n \"required\": [\n \"uri\",\n \"username\",\n \"password\",\n \"database\"\n ]\n }\n }\n ],\n \"additionalProperties\": false\n },\n \"FilesystemServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"path\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"path\"\n ],\n \"additionalProperties\": false\n },\n \"InferenceServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"model\": {\n \"type\": \"string\"\n },\n \"maxTokens\": {\n \"type\": \"integer\"\n },\n \"endpoint\": {\n \"type\": \"string\"\n },\n \"baseURL\": {\n \"type\": \"string\"\n },\n \"apiKey\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"organization\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"apiKey\"\n ],\n \"additionalProperties\": false\n },\n \"McpServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"dependsOn\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\"\n ],\n \"additionalProperties\": false\n },\n \"ServicesConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"backend\": {\n \"$ref\": \"#/definitions/BackendServiceConfig\"\n },\n \"frontend\": {\n \"$ref\": \"#/definitions/FrontendServiceConfig\"\n },\n \"database\": {\n \"$ref\": \"#/definitions/DatabaseServiceConfig\"\n },\n \"graph\": {\n \"$ref\": \"#/definitions/GraphServiceConfig\"\n },\n \"filesystem\": {\n \"$ref\": \"#/definitions/FilesystemServiceConfig\"\n },\n \"inference\": {\n \"$ref\": \"#/definitions/InferenceServiceConfig\"\n },\n \"mcp\": {\n \"$ref\": \"#/definitions/McpServiceConfig\"\n },\n \"proxy\": {\n \"$ref\": \"#/definitions/ProxyServiceConfig\"\n }\n },\n \"additionalProperties\": true\n },\n \"SiteConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"siteName\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Display name for the site\"\n },\n \"domain\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Primary domain for the site\"\n },\n \"adminEmail\": {\n \"type\": \"string\",\n \"format\": \"email\",\n \"description\": \"Administrator email address\"\n },\n \"supportEmail\": {\n \"type\": \"string\",\n \"format\": \"email\",\n \"description\": \"Support email address (optional)\"\n },\n \"oauthAllowedDomains\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"minItems\": 1,\n \"description\": \"Email domains allowed for OAuth authentication\"\n }\n },\n \"required\": [\n \"domain\"\n ],\n \"additionalProperties\": false\n },\n \"AppConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"features\": {\n \"type\": \"object\",\n \"properties\": {\n \"enableAnalytics\": {\n \"type\": \"boolean\"\n },\n \"enableMaintenanceMode\": {\n \"type\": \"boolean\"\n },\n \"enableDebugLogging\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"security\": {\n \"type\": \"object\",\n \"properties\": {\n \"sessionTimeout\": {\n \"type\": \"integer\",\n \"minimum\": 60,\n \"description\": \"Session timeout in seconds\"\n },\n \"maxLoginAttempts\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"description\": \"Maximum failed login attempts before lockout\"\n },\n \"corsAllowedOrigins\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"enableLocalAuth\": {\n \"type\": \"boolean\",\n \"description\": \"Enable local username/password authentication\"\n },\n \"jwtSecret\": {\n \"type\": \"string\",\n \"minLength\": 32,\n \"description\": \"JWT signing secret (base64 encoded, 32+ bytes)\"\n }\n },\n \"additionalProperties\": false\n },\n \"performance\": {\n \"type\": \"object\",\n \"properties\": {\n \"enableCaching\": {\n \"type\": \"boolean\"\n },\n \"cacheTimeout\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"description\": \"Cache timeout in seconds\"\n },\n \"maxRequestSize\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]+(kb|mb|gb)$\",\n \"description\": \"Maximum request size (e.g., '10mb')\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"additionalProperties\": false\n },\n \"EnvironmentConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"_comment\": {\n \"type\": \"string\",\n \"description\": \"Optional comment for documentation\"\n },\n \"_metadata\": {\n \"type\": \"object\",\n \"properties\": {\n \"environment\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"environment\",\n \"projectRoot\"\n ]\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Environment name\"\n },\n \"platform\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"$ref\": \"#/definitions/PlatformType\"\n }\n }\n },\n \"services\": {\n \"$ref\": \"#/definitions/ServicesConfig\"\n },\n \"site\": {\n \"$ref\": \"#/definitions/SiteConfig\"\n },\n \"app\": {\n \"$ref\": \"#/definitions/AppConfig\"\n },\n \"env\": {\n \"type\": \"object\",\n \"properties\": {\n \"NODE_ENV\": {\n \"type\": \"string\",\n \"enum\": [\n \"development\",\n \"production\",\n \"test\"\n ]\n }\n },\n \"additionalProperties\": true\n },\n \"logLevel\": {\n \"type\": \"string\",\n \"enum\": [\n \"error\",\n \"warn\",\n \"info\",\n \"http\",\n \"debug\"\n ],\n \"description\": \"Logging verbosity level\"\n },\n \"deployment\": {\n \"type\": \"object\",\n \"properties\": {\n \"imageTagStrategy\": {\n \"type\": \"string\",\n \"enum\": [\n \"mutable\",\n \"immutable\",\n \"git-hash\"\n ]\n }\n }\n }\n },\n \"required\": [\n \"services\"\n ],\n \"additionalProperties\": false\n },\n \"SemiontConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"version\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$\",\n \"description\": \"Config file version (semver)\"\n },\n \"project\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Project name\"\n },\n \"site\": {\n \"$ref\": \"#/definitions/SiteConfig\"\n },\n \"app\": {\n \"$ref\": \"#/definitions/AppConfig\"\n },\n \"services\": {\n \"$ref\": \"#/definitions/ServicesConfig\"\n }\n },\n \"required\": [\n \"version\",\n \"project\",\n \"site\"\n ],\n \"additionalProperties\": false\n }\n }\n}\n","/**\n * Config Schema Validator\n *\n * Validates configuration data against JSON Schema using Ajv (JSON Schema validator).\n * Provides runtime validation for semiont.json and environment config files.\n */\n\nimport Ajv, { type ErrorObject } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport configSchema from './config.schema.json' with { type: 'json' };\n\n// Initialize Ajv with config-compatible settings\nconst ajv = new Ajv({\n allErrors: true, // Return all errors, not just the first one\n coerceTypes: true, // Coerce types (e.g., \"123\" -> 123)\n removeAdditional: false, // Don't remove additional properties\n useDefaults: true, // Apply default values from schema\n strict: false\n});\n\n// Add format validators (email, uri, date-time, etc.)\naddFormats(ajv);\n\n// Load schema\najv.addSchema(configSchema, 'config');\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ErrorObject[] | null;\n errorMessage?: string;\n}\n\n/**\n * Validate semiont.json config\n */\nexport function validateSemiontConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/SemiontConfig');\n if (!validate) {\n throw new Error('SemiontConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Validate environment config (environments/*.json)\n */\nexport function validateEnvironmentConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/EnvironmentConfig');\n if (!validate) {\n throw new Error('EnvironmentConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Validate site config\n */\nexport function validateSiteConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/SiteConfig');\n if (!validate) {\n throw new Error('SiteConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Format validation errors into human-readable message\n */\nexport function formatErrors(errors: ErrorObject[]): string {\n if (errors.length === 0) return 'Validation failed';\n\n const messages = errors.map(err => {\n const path = err.instancePath || 'root';\n const message = err.message || 'validation error';\n\n if (err.keyword === 'required' && 'missingProperty' in err.params) {\n return `Missing required property: ${err.params.missingProperty}`;\n }\n\n if (err.keyword === 'type' && 'type' in err.params) {\n return `${path}: ${message} (expected ${err.params.type})`;\n }\n\n if (err.keyword === 'enum' && 'allowedValues' in err.params) {\n return `${path}: must be one of [${(err.params.allowedValues as string[]).join(', ')}]`;\n }\n\n if (err.keyword === 'format') {\n return `${path}: invalid format (${message})`;\n }\n\n if (err.keyword === 'minLength' || err.keyword === 'minItems') {\n return `${path}: ${message}`;\n }\n\n return `${path}: ${message}`;\n });\n\n return messages.join('; ');\n}\n","/**\n * Environment Loader Module\n *\n * Responsible for parsing and merging environment configurations.\n * Pure functions only - callers handle filesystem I/O.\n */\n\nimport { ConfigurationError } from './configuration-error';\nimport { PlatformType } from './platform-types';\nimport { isObject } from '../index';\nimport { validateEnvironmentConfig } from './config-validator';\nimport type {\n EnvironmentConfig,\n SiteConfig,\n AppConfig,\n SemiontConfig,\n ServicesConfig,\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n ServicePlatformConfig\n} from './config.types';\n\n/**\n * Re-export generated types from JSON Schema\n * These types are automatically generated from config.schema.json\n */\nexport type {\n EnvironmentConfig,\n SiteConfig,\n AppConfig,\n SemiontConfig,\n PlatformType,\n ServicesConfig,\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n ServicePlatformConfig\n};\n\n/**\n * Generic service configuration\n * Platform-specific fields should be accessed through platform-specific interfaces\n */\nexport interface ServiceConfig {\n platform?: {\n type: PlatformType;\n };\n // Generic fields that apply across platforms\n port?: number;\n name?: string;\n // Platform-specific fields are loosely typed here\n // Platforms should validate and type these properly\n [key: string]: any;\n}\n\nexport interface AWSConfig {\n region: string;\n accountId: string;\n certificateArn?: string;\n hostedZoneId?: string;\n rootDomain?: string;\n stacks?: {\n data?: string;\n app?: string;\n };\n database?: {\n name?: string;\n instanceClass?: string;\n allocatedStorage?: number;\n backupRetentionDays?: number;\n multiAZ?: boolean;\n };\n ecs?: {\n desiredCount?: number;\n minCapacity?: number;\n maxCapacity?: number;\n };\n monitoring?: {\n enableDetailedMonitoring?: boolean;\n logRetentionDays?: number;\n };\n}\n\n/**\n * Deep merge utility for configuration objects\n * Pure function - no side effects\n */\nexport function deepMerge(target: any, ...sources: any[]): any {\n if (!sources.length) return target;\n const source = sources.shift();\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} });\n deepMerge(target[key], source[key]);\n } else {\n Object.assign(target, { [key]: source[key] });\n }\n }\n }\n\n return deepMerge(target, ...sources);\n}\n\n\n/**\n * Recursively resolve environment variable placeholders in configuration\n * Replaces ${VAR_NAME} with the value from the provided env object\n * Pure function - accepts env as parameter instead of using process.env\n *\n * @param obj - Configuration object to process\n * @param env - Environment variables object\n * @returns Configuration with resolved environment variables\n */\nexport function resolveEnvVars(obj: any, env: Record<string, string | undefined>): any {\n if (typeof obj === 'string') {\n // Replace ${VAR_NAME} with actual environment variable value\n return obj.replace(/\\$\\{([^}]+)\\}/g, (match, varName) => {\n return env[varName] || match;\n });\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveEnvVars(item, env));\n }\n\n if (obj && typeof obj === 'object') {\n const resolved: any = {};\n for (const key in obj) {\n resolved[key] = resolveEnvVars(obj[key], env);\n }\n return resolved;\n }\n\n return obj;\n}\n\n/**\n * Parse and merge configuration files\n * Pure function - accepts file contents as strings instead of reading from filesystem\n *\n * @param baseContent - Contents of semiont.json (null if file doesn't exist)\n * @param envContent - Contents of environment-specific JSON file\n * @param env - Environment variables object\n * @param environment - Environment name\n * @param projectRoot - Project root path (for metadata only)\n * @returns Merged and validated environment configuration\n * @throws ConfigurationError if parsing or validation fails\n */\nexport function parseAndMergeConfigs(\n baseContent: string | null,\n envContent: string,\n env: Record<string, string | undefined>,\n environment: string,\n projectRoot: string\n): EnvironmentConfig {\n try {\n // Parse base config\n let baseConfig: any = {};\n if (baseContent) {\n baseConfig = JSON.parse(baseContent);\n }\n\n // Parse environment config\n const envConfig = JSON.parse(envContent);\n\n // Merge configurations: base defaults -> environment config\n const merged = deepMerge(\n {},\n { site: baseConfig.site }, // Site config from semiont.json\n baseConfig.defaults || {}, // Default config from semiont.json\n envConfig // Environment-specific overrides\n );\n\n // Resolve environment variables in the merged configuration\n const resolved = resolveEnvVars(merged, env);\n\n // Ensure services exists (even if empty)\n if (!resolved.services) {\n resolved.services = {};\n }\n\n // Validate NODE_ENV if specified\n if (resolved.env?.NODE_ENV) {\n const validNodeEnv = ['development', 'production', 'test'];\n if (!validNodeEnv.includes(resolved.env.NODE_ENV)) {\n throw new ConfigurationError(\n `Invalid NODE_ENV value: ${resolved.env.NODE_ENV}`,\n environment,\n `NODE_ENV must be one of: ${validNodeEnv.join(', ')}`\n );\n }\n }\n\n // Add metadata about where this config came from\n const configWithMetadata = {\n ...resolved,\n _metadata: {\n environment,\n projectRoot\n }\n };\n\n // Validate with AJV\n const validationResult = validateEnvironmentConfig(configWithMetadata);\n\n if (!validationResult.valid) {\n throw new ConfigurationError(\n `Invalid environment configuration: ${validationResult.errorMessage}`,\n environment,\n `Fix the validation errors in your environments/${environment}.json file`\n );\n }\n\n return configWithMetadata as EnvironmentConfig;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error; // Re-throw our custom errors\n }\n\n if (error instanceof SyntaxError && error.message.includes('JSON')) {\n throw new ConfigurationError(\n `Invalid JSON syntax in configuration file`,\n environment,\n `Check for missing commas, quotes, or brackets. Use a JSON validator to verify syntax.`\n );\n }\n\n const message = error instanceof Error ? error.message : String(error);\n throw new ConfigurationError(\n `Failed to parse environment configuration: ${message}`,\n environment,\n `Check the configuration files are valid JSON`\n );\n }\n}\n\n/**\n * Get NODE_ENV value from environment config\n *\n * @param config - Environment configuration\n * @returns NODE_ENV value (defaults to 'development' if not specified)\n */\nexport function getNodeEnvForEnvironment(config: EnvironmentConfig): 'development' | 'production' | 'test' {\n const nodeEnv = config.env?.NODE_ENV;\n\n // Default to 'development' if not specified\n return nodeEnv || 'development';\n}\n\n/**\n * List environment names from filenames\n * Pure function - accepts array of filenames instead of reading from filesystem\n *\n * @param files - Array of filenames from environments directory\n * @returns Sorted array of environment names\n */\nexport function listEnvironmentNames(files: string[]): string[] {\n return files\n .filter(file => file.endsWith('.json'))\n .map(file => {\n // Extract filename from path (handle directory separators)\n const lastSlash = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\\\'));\n const filename = lastSlash >= 0 ? file.substring(lastSlash + 1) : file;\n // Remove '.json' suffix\n return filename.slice(0, -5);\n })\n .sort();\n}\n\n/**\n * Type guard to check if config has AWS settings\n * \n * @param config - Environment configuration\n * @returns True if AWS configuration is present\n */\nexport function hasAWSConfig(config: EnvironmentConfig): config is EnvironmentConfig & { aws: AWSConfig } {\n return !!(config as any).aws && !!(config as any).aws.region;\n}\n\n/**\n * Display configuration for debugging\n *\n * @param config - Configuration to display\n */\nexport function displayConfiguration(config: EnvironmentConfig): void {\n console.log('Environment Configuration:');\n console.log(JSON.stringify(config, null, 2));\n}\n\n/**\n * File reader abstraction for platform-agnostic config loading\n * Implementations provide platform-specific file I/O (Node.js, Deno, Bun, etc.)\n */\nexport type ConfigFileReader = {\n /** Read file if it exists, return null otherwise */\n readIfExists: (path: string) => string | null;\n /** Read file, throw error if it doesn't exist */\n readRequired: (path: string) => string;\n};\n\n/**\n * Create a config loader with a specific file reader implementation\n * Higher-order function that returns a platform-specific config loader\n *\n * @param reader - Platform-specific file reader implementation\n * @returns Function to load environment config from filesystem\n *\n * @example\n * ```typescript\n * import * as fs from 'fs';\n * import { createConfigLoader } from '@semiont/core';\n *\n * const nodeReader = {\n * readIfExists: (path) => fs.existsSync(path) ? fs.readFileSync(path, 'utf-8') : null,\n * readRequired: (path) => {\n * if (!fs.existsSync(path)) throw new Error(`File not found: ${path}`);\n * return fs.readFileSync(path, 'utf-8');\n * },\n * };\n *\n * const loadConfig = createConfigLoader(nodeReader);\n * const config = loadConfig('/project/root', 'production');\n * ```\n */\nexport function createConfigLoader(reader: ConfigFileReader) {\n return (projectRoot: string, environment: string): EnvironmentConfig => {\n // Read base semiont.json (optional)\n const baseContent = reader.readIfExists(`${projectRoot}/semiont.json`);\n\n // Read environment-specific config (required)\n const envContent = reader.readRequired(`${projectRoot}/environments/${environment}.json`);\n\n // Use pure function to parse and merge\n return parseAndMergeConfigs(baseContent, envContent, process.env, environment, projectRoot);\n };\n}\n\n","/**\n * Environment validation utilities\n *\n * Pure functions - accept available environments as parameter instead of reading from filesystem\n */\n\nexport type Environment = string; // Allow any environment name\n\n/**\n * Type guard to check if a string is a valid Environment\n * @param value - The environment string to check\n * @param availableEnvironments - List of valid environment names\n */\nexport function isValidEnvironment(value: string | undefined, availableEnvironments: string[]): value is Environment {\n if (!value) return false;\n return availableEnvironments.includes(value);\n}\n\n/**\n * Parse environment string to Environment type\n * @param value - The environment string to parse\n * @param availableEnvironments - List of valid environment names\n * @returns Valid Environment type\n * @throws Error if environment is invalid or not provided\n */\nexport function parseEnvironment(value: string | undefined, availableEnvironments: string[]): Environment {\n if (!value) {\n throw new Error('Environment is required');\n }\n if (!isValidEnvironment(value, availableEnvironments)) {\n throw new Error(`Invalid environment: ${value}. Available environments: ${availableEnvironments.join(', ')}`);\n }\n return value;\n}\n\n/**\n * Validate and return environment or throw error\n * @param value - The environment string to validate\n * @param availableEnvironments - List of valid environment names\n * @throws Error if environment is invalid\n */\nexport function validateEnvironment(value: string | undefined, availableEnvironments: string[]): Environment {\n if (!value) {\n throw new Error('Environment is required');\n }\n if (!isValidEnvironment(value, availableEnvironments)) {\n throw new Error(`Invalid environment: ${value}. Available environments: ${availableEnvironments.join(', ')}`);\n }\n return value;\n}","/**\n * Platform Types Module\n *\n * Re-exports PlatformType from schema-generated types.\n * Platforms represent WHERE services run (infrastructure targets).\n */\n\nimport { PlatformType as SchemaPlatformType } from './config.types';\n\n/**\n * Platform type literals from JSON Schema\n * These represent the infrastructure targets where services can be deployed\n */\nexport type PlatformType = SchemaPlatformType;\n\n/**\n * Type guard to check if a string is a valid platform type\n *\n * @param value - Value to check\n * @returns True if value is a valid PlatformType\n */\nexport function isValidPlatformType(value: string): value is PlatformType {\n return ['aws', 'container', 'posix', 'external'].includes(value);\n}\n\n/**\n * Get all valid platform types\n *\n * @returns Array of all platform types\n */\nexport function getAllPlatformTypes(): PlatformType[] {\n return ['aws', 'container', 'posix', 'external'];\n}","/**\n * @semiont/core\n *\n * Core domain logic and utilities for the Semiont semantic knowledge platform.\n * OpenAPI types are generated here and exported for use across the monorepo.\n */\n\n// OpenAPI-generated types (source of truth for API schemas)\nexport type { components, paths, operations } from './types';\n\n// Branded types (compile-time type safety)\nexport type {\n // OpenAPI types\n Motivation,\n ContentFormat,\n // Authentication & tokens\n Email,\n AuthCode,\n GoogleCredential,\n AccessToken,\n RefreshToken,\n MCPToken,\n CloneToken,\n // System identifiers\n JobId,\n UserDID,\n EntityType,\n SearchQuery,\n BaseUrl,\n // HTTP URI types\n ResourceUri,\n AnnotationUri,\n ResourceAnnotationUri,\n} from './branded-types';\nexport {\n // Helper functions\n email,\n authCode,\n googleCredential,\n accessToken,\n refreshToken,\n mcpToken,\n cloneToken,\n jobId,\n userDID,\n entityType,\n searchQuery,\n baseUrl,\n // URI factory functions\n resourceUri,\n annotationUri,\n resourceAnnotationUri,\n} from './branded-types';\n\n// Creation methods\nexport { CREATION_METHODS } from './creation-methods';\nexport type { CreationMethod } from './creation-methods';\n\n// Identifier types (only IDs - URIs are in @semiont/api-client)\nexport type { ResourceId, AnnotationId, UserId } from './identifiers';\nexport {\n resourceId,\n annotationId,\n userId,\n isResourceId,\n isAnnotationId,\n} from './identifiers';\n\n// URI utilities\nexport {\n resourceIdToURI,\n uriToResourceId,\n annotationIdToURI,\n uriToAnnotationId,\n uriToAnnotationIdOrPassthrough,\n extractResourceUriFromAnnotationUri,\n} from './uri-utils';\n\n// Graph types\nexport type {\n GraphConnection,\n GraphPath,\n EntityTypeStats,\n} from './graph';\n\n// Event types\nexport type {\n BaseEvent,\n ResourceEvent,\n ResourceEventType,\n SystemEvent,\n ResourceScopedEvent,\n ResourceCreatedEvent,\n ResourceClonedEvent,\n ResourceArchivedEvent,\n ResourceUnarchivedEvent,\n RepresentationAddedEvent,\n RepresentationRemovedEvent,\n AnnotationAddedEvent,\n AnnotationRemovedEvent,\n AnnotationBodyUpdatedEvent,\n JobStartedEvent,\n JobProgressEvent,\n JobCompletedEvent,\n JobFailedEvent,\n BodyOperation,\n BodyItem,\n EntityTagAddedEvent,\n EntityTagRemovedEvent,\n EventMetadata,\n EventSignature,\n StoredEvent,\n EventQuery,\n ResourceAnnotations,\n} from './events';\nexport {\n isResourceEvent,\n isSystemEvent,\n isResourceScopedEvent,\n getEventType,\n} from './events';\n\n// Event utilities\nexport {\n getAnnotationUriFromEvent,\n isEventRelatedToAnnotation,\n isResourceEvent as isStoredEvent,\n} from './event-utils';\n\n// Event bus (RxJS-based, framework-agnostic)\nexport { EventBus, ScopedEventBus } from './event-bus';\n\n// Logger interface (framework-agnostic)\nexport type { Logger } from './logger';\n\n// Event protocol (application-level events for event bus)\nexport type {\n EventMap,\n EventName,\n SelectionData,\n AnnotationProgress,\n GenerationProgress,\n Selector,\n GenerationContext,\n} from './event-map';\n\n// Backend-specific annotation utilities\nexport { findBodyItem } from './annotation-utils';\n\n// Resource types\nexport type { UpdateResourceInput, ResourceFilter } from './resource-types';\n\n// Annotation types\nexport type { AnnotationCategory, CreateAnnotationInternal } from './annotation-types';\n\n// Auth types\nexport type { GoogleAuthRequest } from './auth-types';\n\n// Utility functions\nexport * from './type-guards';\nexport * from './errors';\nexport * from './did-utils';\n\n// Configuration - Pure functions only (no filesystem dependencies)\n// Callers should read config files themselves and pass contents to parseAndMergeConfigs\n// Or use createConfigLoader with a platform-specific file reader\nexport {\n deepMerge,\n resolveEnvVars,\n parseAndMergeConfigs,\n createConfigLoader,\n listEnvironmentNames,\n getNodeEnvForEnvironment,\n hasAWSConfig,\n displayConfiguration,\n // Types\n type EnvironmentConfig,\n type ServiceConfig,\n type AWSConfig,\n type SiteConfig,\n type AppConfig,\n type ConfigFileReader,\n} from './config/environment-loader';\n\nexport {\n parseEnvironment,\n validateEnvironment,\n type Environment,\n} from './config/environment-validator';\nexport {\n formatErrors,\n validateSemiontConfig,\n validateEnvironmentConfig,\n validateSiteConfig,\n type ValidationResult,\n} from './config/config-validator';\nexport { ConfigurationError } from './config/configuration-error';\nexport type { ProxyServiceConfig } from './config/config.types';\nexport {\n type PlatformType,\n isValidPlatformType,\n getAllPlatformTypes,\n} from './config/platform-types';\n\n// Schema-generated configuration types\nexport type {\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n McpServiceConfig,\n ServicesConfig,\n SemiontConfig,\n GraphDatabaseType,\n ServicePlatformConfig\n} from './config/config.types';\n\n// Version information\nexport const CORE_TYPES_VERSION = '0.1.0';\nexport const SDK_VERSION = '0.1.0';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/branded-types.ts","../src/creation-methods.ts","../src/identifiers.ts","../src/uri-utils.ts","../src/events.ts","../src/event-utils.ts","../src/event-bus.ts","../src/operators/burst-buffer.ts","../src/annotation-utils.ts","../src/type-guards.ts","../src/errors.ts","../src/did-utils.ts","../src/config/configuration-error.ts","../src/config/config.schema.json","../src/config/config-validator.ts","../src/config/environment-loader.ts","../src/config/environment-validator.ts","../src/config/platform-types.ts","../src/index.ts"],"names":["annotationUri","resourceUri","baseUrl","isResourceEvent","resourceId","userId"],"mappings":";;;;;AA0CO,SAAS,MAAM,KAAA,EAAsB;AAAE,EAAA,OAAO,KAAA;AAAgB;AAC9D,SAAS,SAAS,KAAA,EAAyB;AAAE,EAAA,OAAO,KAAA;AAAmB;AACvE,SAAS,iBAAiB,KAAA,EAAiC;AAAE,EAAA,OAAO,KAAA;AAA2B;AAC/F,SAAS,YAAY,KAAA,EAA4B;AAAE,EAAA,OAAO,KAAA;AAAsB;AAChF,SAAS,aAAa,KAAA,EAA6B;AAAE,EAAA,OAAO,KAAA;AAAuB;AACnF,SAAS,SAAS,KAAA,EAAyB;AAAE,EAAA,OAAO,KAAA;AAAmB;AACvE,SAAS,WAAW,KAAA,EAA2B;AAAE,EAAA,OAAO,KAAA;AAAqB;AAC7E,SAAS,MAAM,KAAA,EAAsB;AAAE,EAAA,OAAO,KAAA;AAAgB;AAC9D,SAAS,QAAQ,KAAA,EAAwB;AAAE,EAAA,OAAO,KAAA;AAAkB;AACpE,SAAS,WAAW,KAAA,EAA2B;AAAE,EAAA,OAAO,KAAA;AAAqB;AAC7E,SAAS,YAAY,KAAA,EAA4B;AAAE,EAAA,OAAO,KAAA;AAAsB;AAChF,SAAS,QAAQ,KAAA,EAAwB;AAAE,EAAA,OAAO,KAAA;AAAkB;AAmBpE,SAAS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AAuD;AACnH,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AACnB,EAAA,OAAO,qBAAA,CAAsB,SAAS,KAAK,CAAA;AAC7C;AASO,SAAS,gBAAA,CAAiB,OAA2B,qBAAA,EAA8C;AACxG,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,MAAM,yBAAyB,CAAA;AAAA,EAC3C;AACA,EAAA,IAAI,CAAC,kBAAA,CAAmB,KAAA,EAAO,qBAAqB,CAAA,EAAG;AACrD,IAAA,MAAM,IAAI,MAAM,CAAA,qBAAA,EAAwB,KAAK,6BAA6B,qBAAA,CAAsB,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9G;AACA,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,mBAAA,CAAoB,OAA2B,qBAAA,EAA8C;AAC3G,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,MAAM,yBAAyB,CAAA;AAAA,EAC3C;AACA,EAAA,IAAI,CAAC,kBAAA,CAAmB,KAAA,EAAO,qBAAqB,CAAA,EAAG;AACrD,IAAA,MAAM,IAAI,MAAM,CAAA,qBAAA,EAAwB,KAAK,6BAA6B,qBAAA,CAAsB,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9G;AACA,EAAA,OAAO,KAAA;AACT;;;AC5BO,SAAS,oBAAoB,KAAA,EAAsC;AACxE,EAAA,OAAO,CAAC,KAAA,EAAO,WAAA,EAAa,SAAS,UAAU,CAAA,CAAE,SAAS,KAAK,CAAA;AACjE;AAOO,SAAS,mBAAA,GAAsC;AACpD,EAAA,OAAO,CAAC,KAAA,EAAO,WAAA,EAAa,OAAA,EAAS,UAAU,CAAA;AACjD;;;AC+LO,IAAM,kBAAA,GAAqB;AAC3B,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * Branded string types for compile-time type safety\n *\n * These types are zero-cost at runtime but prevent mixing\n * different string types at compile time.\n */\n\nimport type { components } from './types';\n\n// ============================================================================\n// OPENAPI-GENERATED TYPES (use directly from spec)\n// ============================================================================\n\nexport type Motivation = components['schemas']['Motivation'];\nexport type ContentFormat = components['schemas']['ContentFormat'];\n\n// ============================================================================\n// AUTHENTICATION & TOKENS\n// ============================================================================\n\nexport type Email = string & { readonly __brand: 'Email' };\nexport type AuthCode = string & { readonly __brand: 'AuthCode' };\nexport type GoogleCredential = string & { readonly __brand: 'GoogleCredential' };\nexport type AccessToken = string & { readonly __brand: 'AccessToken' };\nexport type RefreshToken = string & { readonly __brand: 'RefreshToken' };\nexport type MCPToken = string & { readonly __brand: 'MCPToken' };\nexport type CloneToken = string & { readonly __brand: 'CloneToken' };\n\n// ============================================================================\n// SYSTEM IDENTIFIERS\n// ============================================================================\n\nexport type JobId = string & { readonly __brand: 'JobId' };\nexport type UserDID = string & { readonly __brand: 'UserDID' };\nexport type EntityType = string & { readonly __brand: 'EntityType' };\nexport type SearchQuery = string & { readonly __brand: 'SearchQuery' };\nexport type BaseUrl = string & { readonly __brand: 'BaseUrl' };\n\n// ============================================================================\n// HELPER FUNCTIONS (minimal validation, just branding)\n// ============================================================================\n\nexport function email(value: string): Email { return value as Email; }\nexport function authCode(value: string): AuthCode { return value as AuthCode; }\nexport function googleCredential(value: string): GoogleCredential { return value as GoogleCredential; }\nexport function accessToken(value: string): AccessToken { return value as AccessToken; }\nexport function refreshToken(value: string): RefreshToken { return value as RefreshToken; }\nexport function mcpToken(value: string): MCPToken { return value as MCPToken; }\nexport function cloneToken(value: string): CloneToken { return value as CloneToken; }\nexport function jobId(value: string): JobId { return value as JobId; }\nexport function userDID(value: string): UserDID { return value as UserDID; }\nexport function entityType(value: string): EntityType { return value as EntityType; }\nexport function searchQuery(value: string): SearchQuery { return value as SearchQuery; }\nexport function baseUrl(value: string): BaseUrl { return value as BaseUrl; }\n\n// Motivation and ContentFormat use OpenAPI enums - no helpers needed\n// Use the enum values directly from the OpenAPI spec\n\n// ============================================================================\n// HTTP URI TYPES\n// ============================================================================\n\n// Branded type definitions for HTTP URIs returned by the API\nexport type ResourceUri = string & { readonly __brand: 'ResourceUri' };\n\n// W3C flat format for content negotiation: http://localhost:4000/annotations/{id}\nexport type AnnotationUri = string & { readonly __brand: 'AnnotationUri' };\n\n// Nested format for CRUD operations: http://localhost:4000/resources/{resourceId}/annotations/{annotationId}\nexport type ResourceAnnotationUri = string & { readonly __brand: 'ResourceAnnotationUri' };\n\n// Factory functions with runtime validation\nexport function resourceUri(uri: string): ResourceUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceUri, got: ${uri}`);\n }\n return uri as ResourceUri;\n}\n\nexport function annotationUri(uri: string): AnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected AnnotationUri, got: ${uri}`);\n }\n return uri as AnnotationUri;\n}\n\nexport function resourceAnnotationUri(uri: string): ResourceAnnotationUri {\n if (!uri.startsWith('http://') && !uri.startsWith('https://')) {\n throw new TypeError(`Expected ResourceAnnotationUri, got: ${uri}`);\n }\n // Additional validation: must contain /resources/ and /annotations/\n if (!uri.includes('/resources/') || !uri.includes('/annotations/')) {\n throw new TypeError(`Expected nested ResourceAnnotationUri format, got: ${uri}`);\n }\n return uri as ResourceAnnotationUri;\n}\n","/**\n * Resource creation methods - How resources are created in the system\n */\n\n/**\n * Enumeration of all possible resource creation methods\n */\nexport const CREATION_METHODS = {\n API: 'api',\n UPLOAD: 'upload',\n UI: 'ui',\n REFERENCE: 'reference',\n CLONE: 'clone',\n GENERATED: 'generated',\n} as const;\n\n/**\n * Type for resource creation methods\n */\nexport type CreationMethod = typeof CREATION_METHODS[keyof typeof CREATION_METHODS];","/**\n * Branded identifier types for compile-time type safety.\n *\n * These types prevent mixing up resource IDs, annotation IDs, and user IDs\n * at compile time while having zero runtime overhead.\n *\n * URI types (ResourceUri, AnnotationUri) are in @semiont/api-client\n * since they deal with HTTP URIs returned by the API.\n */\n\n// Branded type definitions for IDs only\nexport type ResourceId = string & { readonly __brand: 'ResourceId' };\nexport type AnnotationId = string & { readonly __brand: 'AnnotationId' };\nexport type UserId = string & { readonly __brand: 'UserId' };\n\n// Type guards with runtime validation\nexport function isResourceId(value: string): value is ResourceId {\n return !value.includes('/');\n}\n\nexport function isAnnotationId(value: string): value is AnnotationId {\n return !value.includes('/');\n}\n\n// Factory functions with runtime validation\nexport function resourceId(id: string): ResourceId {\n if (id.includes('/')) {\n throw new TypeError(`Expected ResourceId, got URI: ${id}`);\n }\n return id as ResourceId;\n}\n\nexport function annotationId(id: string): AnnotationId {\n if (id.includes('/')) {\n throw new TypeError(`Expected AnnotationId, got URI: ${id}`);\n }\n return id as AnnotationId;\n}\n\nexport function userId(id: string): UserId {\n return id as UserId;\n}\n","/**\n * URI utilities for W3C annotations\n *\n * Converts between short resource/annotation IDs and full URIs.\n * Full URIs are required by W3C Web Annotation Data Model.\n */\n\nimport { resourceId, annotationId, type ResourceId, type AnnotationId } from './identifiers';\nimport { resourceUri, annotationUri, type ResourceUri, type AnnotationUri, type ResourceAnnotationUri } from './branded-types';\n\n/**\n * Convert resource ID to full URI\n *\n * @param id - Short resource ID (e.g., \"doc-abc123\")\n * @param publicURL - Backend base URL\n * @returns Full URI (e.g., \"https://api.semiont.app/resources/doc-abc123\")\n *\n * @example\n * resourceIdToURI(\"doc-abc123\", \"https://api.semiont.app\")\n * // => \"https://api.semiont.app/resources/doc-abc123\"\n */\nexport function resourceIdToURI(id: ResourceId, publicURL: string): ResourceUri {\n // Remove trailing slash if present\n const normalizedBase = publicURL.endsWith('/') ? publicURL.slice(0, -1) : publicURL;\n return resourceUri(`${normalizedBase}/resources/${id}` );\n}\n\n/**\n * Extract resource ID from full URI\n *\n * @param uri - Full resource URI (e.g., \"https://api.semiont.app/resources/doc-abc123\")\n * @returns Short resource ID (e.g., \"doc-abc123\")\n * @throws Error if URI format is invalid\n *\n * @example\n * uriToResourceId(\"https://api.semiont.app/resources/doc-abc123\")\n * // => \"doc-abc123\"\n */\nexport function uriToResourceId(uri: string): ResourceId {\n const url = new URL(uri);\n const match = url.pathname.match(/\\/resources\\/([^/]+)/);\n if (!match || !match[1]) {\n throw new Error(`Invalid resource URI: ${uri}`);\n }\n return resourceId(match[1]);\n}\n\n/**\n * Convert annotation ID to full URI\n *\n * @param id - Short annotation ID (e.g., \"anno-xyz789\")\n * @param publicURL - Backend base URL\n * @returns Full URI (e.g., \"https://api.semiont.app/annotations/anno-xyz789\")\n *\n * @example\n * annotationIdToURI(\"anno-xyz789\", \"https://api.semiont.app\")\n * // => \"https://api.semiont.app/annotations/anno-xyz789\"\n */\nexport function annotationIdToURI(id: AnnotationId, publicURL: string): AnnotationUri {\n // Remove trailing slash if present\n const normalizedBase = publicURL.endsWith('/') ? publicURL.slice(0, -1) : publicURL;\n return annotationUri(`${normalizedBase}/annotations/${id}`);\n}\n\n/**\n * Extract annotation ID from full URI\n *\n * @param uri - Full annotation URI (e.g., \"https://api.semiont.app/annotations/anno-xyz789\")\n * @returns Short annotation ID (e.g., \"anno-xyz789\")\n * @throws Error if URI format is invalid\n *\n * @example\n * uriToAnnotationId(\"https://api.semiont.app/annotations/anno-xyz789\")\n * // => \"anno-xyz789\"\n */\nexport function uriToAnnotationId(uri: string): AnnotationId {\n const url = new URL(uri);\n const match = url.pathname.match(/\\/annotations\\/([^/]+)/);\n if (!match || !match[1]) {\n throw new Error(`Invalid annotation URI: ${uri}`);\n }\n return annotationId(match[1]);\n}\n\n/**\n * Extract annotation ID from URI or pass through if already an ID\n *\n * Defensive version of uriToAnnotationId that handles both:\n * - Full URIs: \"https://api.semiont.app/annotations/anno-xyz789\" → \"anno-xyz789\"\n * - Already IDs: \"anno-xyz789\" → \"anno-xyz789\"\n *\n * @param uriOrId - Full annotation URI or short ID\n * @returns Short annotation ID\n *\n * @example\n * uriToAnnotationIdOrPassthrough(\"https://api.semiont.app/annotations/anno-xyz789\")\n * // => \"anno-xyz789\"\n *\n * uriToAnnotationIdOrPassthrough(\"anno-xyz789\")\n * // => \"anno-xyz789\"\n */\nexport function uriToAnnotationIdOrPassthrough(uriOrId: string): AnnotationId {\n // Try parsing as URI first\n try {\n return uriToAnnotationId(uriOrId);\n } catch {\n // If it fails, assume it's already an ID and return as-is\n return annotationId(uriOrId);\n }\n}\n\n/**\n * Extract resource URI from nested annotation URI\n *\n * @param annotationUri - Nested ResourceAnnotationUri (e.g., \"https://api.semiont.app/resources/doc-123/annotations/anno-456\")\n * @returns Resource URI (e.g., \"https://api.semiont.app/resources/doc-123\")\n * @throws Error if URI format is invalid\n *\n * @example\n * extractResourceUriFromAnnotationUri(\"https://api.semiont.app/resources/doc-123/annotations/anno-456\")\n * // => \"https://api.semiont.app/resources/doc-123\"\n */\nexport function extractResourceUriFromAnnotationUri(annotationUri: ResourceAnnotationUri): ResourceUri {\n const parts = annotationUri.split('/annotations/');\n if (parts.length !== 2) {\n throw new Error(`Invalid annotation URI format: ${annotationUri}`);\n }\n return resourceUri(parts[0]);\n}\n","/**\n * Resource Event Types\n *\n * Event-sourced architecture for resource state management\n * Events are stored in an append-only log (JSONL format)\n *\n * Federation-ready design:\n * - resourceId uses content hashes (doc-sha256:...)\n * - userId uses DID format (did:web:org.com:users:alice)\n * - prevEventHash creates tamper-evident chains\n * - Optional signatures for cross-org verification\n */\n\nimport type { CreationMethod } from './creation-methods';\nimport type { components } from './types';\nimport type { AnnotationUri, JobId } from './branded-types';\nimport type { ResourceId, AnnotationId, UserId } from './identifiers';\n\n// Import OpenAPI types\ntype Annotation = components['schemas']['Annotation'];\ntype ContentFormat = components['schemas']['ContentFormat'];\ntype Motivation = components['schemas']['Motivation'];\n\nexport interface BaseEvent {\n id: string; // Unique event ID (UUID)\n timestamp: string; // ISO 8601 timestamp (for humans, NOT for ordering)\n resourceId?: ResourceId; // Optional - present for resource-scoped events, absent for system events\n // Use isSystemEvent() / isResourceScopedEvent() type guards for routing\n userId: UserId; // DID format: did:web:org.com:users:alice (federation-ready)\n version: number; // Event schema version\n}\n\n// Resource lifecycle events\nexport interface ResourceCreatedEvent extends BaseEvent {\n type: 'resource.created';\n payload: {\n name: string;\n format: ContentFormat; // MIME type (validated enum)\n contentChecksum: string; // SHA-256 of content (should match resourceId)\n contentByteSize?: number; // Size of content in bytes\n creationMethod: CreationMethod; // How the resource was created\n entityTypes?: string[];\n\n // First-class fields (promoted from metadata)\n language?: string; // Language/locale code (e.g., 'en', 'es', 'fr')\n isDraft?: boolean; // Draft status for generated resources\n generatedFrom?: string; // Annotation/Reference ID that triggered generation\n generationPrompt?: string; // Prompt used for AI generation (events-only, not on Resource)\n };\n}\n\nexport interface ResourceClonedEvent extends BaseEvent {\n type: 'resource.cloned';\n payload: {\n name: string;\n format: ContentFormat; // MIME type (validated enum)\n contentChecksum: string; // SHA-256 of new content\n contentByteSize?: number; // Size of content in bytes\n parentResourceId: string; // Content hash of parent resource\n creationMethod: CreationMethod; // How the resource was created\n entityTypes?: string[];\n\n // First-class fields (promoted from metadata)\n language?: string; // Language/locale code (e.g., 'en', 'es', 'fr')\n };\n}\n\nexport interface ResourceArchivedEvent extends BaseEvent {\n type: 'resource.archived';\n payload: {\n reason?: string;\n };\n}\n\nexport interface ResourceUnarchivedEvent extends BaseEvent {\n type: 'resource.unarchived';\n payload: Record<string, never>; // Empty payload\n}\n\n// Representation events (multi-format support)\nexport interface RepresentationAddedEvent extends BaseEvent {\n type: 'representation.added';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n representation: {\n '@id': string; // Unique ID (content hash)\n mediaType: string; // MIME type (e.g., 'text/markdown', 'application/pdf')\n byteSize: number; // Size in bytes\n checksum: string; // Content hash (SHA-256)\n created: string; // ISO 8601 timestamp\n rel?: 'original' | 'thumbnail' | 'preview' | 'optimized' | 'derived' | 'other';\n storageUri?: string; // Where bytes are stored (optional)\n filename?: string; // Original filename (optional)\n language?: string; // IETF BCP 47 language tag (optional, for translations)\n width?: number; // Pixels (images/video)\n height?: number; // Pixels (images/video)\n duration?: number; // Seconds (audio/video)\n };\n };\n}\n\nexport interface RepresentationRemovedEvent extends BaseEvent {\n type: 'representation.removed';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n checksum: string; // Which representation to remove\n };\n}\n\n// Unified annotation events\n// Single principle: An annotation is an annotation. The motivation field tells you what kind it is.\nexport interface AnnotationAddedEvent extends BaseEvent {\n type: 'annotation.added';\n payload: {\n annotation: Omit<Annotation, 'creator' | 'created'>; // W3C Annotation (creator/created come from event metadata)\n };\n}\n\nexport interface AnnotationRemovedEvent extends BaseEvent {\n type: 'annotation.removed';\n payload: {\n annotationId: AnnotationId; // Branded type for compile-time safety\n };\n}\n\n// Body operation types for fine-grained annotation body modifications\nexport type BodyItem =\n | { type: 'TextualBody'; value: string; purpose?: Motivation; format?: string; language?: string }\n | { type: 'SpecificResource'; source: string; purpose?: Motivation };\n\nexport type BodyOperation =\n | { op: 'add'; item: BodyItem }\n | { op: 'remove'; item: BodyItem }\n | { op: 'replace'; oldItem: BodyItem; newItem: BodyItem };\n\nexport interface AnnotationBodyUpdatedEvent extends BaseEvent {\n type: 'annotation.body.updated';\n payload: {\n annotationId: AnnotationId; // Branded type for compile-time safety\n operations: BodyOperation[];\n };\n}\n\n// Job progress events (resource-level)\n// Emitted by background workers for real-time progress updates\nexport interface JobStartedEvent extends BaseEvent {\n type: 'job.started';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n totalSteps?: number; // Optional - total number of steps if known\n };\n}\n\nexport interface JobProgressEvent extends BaseEvent {\n type: 'job.progress';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n percentage: number; // 0-100\n currentStep?: string; // Human-readable current step (e.g., \"Scanning for Person\")\n processedSteps?: number; // Number of steps completed\n totalSteps?: number; // Total number of steps\n foundCount?: number; // For detection: number of entities found so far\n message?: string; // Optional status message\n progress?: any; // For new job types: full progress object\n };\n}\n\nexport interface JobCompletedEvent extends BaseEvent {\n type: 'job.completed';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n totalSteps?: number; // Total steps completed\n foundCount?: number; // For detection: total entities found\n resultResourceId?: ResourceId; // For generation: ID of generated resource (branded type)\n annotationUri?: AnnotationUri; // For generation: URI of annotation that triggered generation\n message?: string; // Optional completion message\n result?: any; // For new job types: full result object\n };\n}\n\nexport interface JobFailedEvent extends BaseEvent {\n type: 'job.failed';\n resourceId: ResourceId; // Required - job is scoped to a resource\n payload: {\n jobId: JobId;\n jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';\n error: string; // Error message\n details?: string; // Optional detailed error information\n };\n}\n\n// Entity tag events (resource-level)\nexport interface EntityTagAddedEvent extends BaseEvent {\n type: 'entitytag.added';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n entityType: string;\n };\n}\n\nexport interface EntityTagRemovedEvent extends BaseEvent {\n type: 'entitytag.removed';\n resourceId: ResourceId; // Required - resource-scoped event\n payload: {\n entityType: string;\n };\n}\n\n// Entity type events (global collection)\nexport interface EntityTypeAddedEvent extends BaseEvent {\n type: 'entitytype.added';\n resourceId?: undefined; // System-level event - no resource scope\n payload: {\n entityType: string; // The entity type being added to global collection\n };\n}\n\n// Union type of all events\nexport type ResourceEvent =\n | ResourceCreatedEvent\n | ResourceClonedEvent\n | ResourceArchivedEvent\n | ResourceUnarchivedEvent\n | RepresentationAddedEvent // Multi-format support\n | RepresentationRemovedEvent // Multi-format support\n | AnnotationAddedEvent\n | AnnotationRemovedEvent\n | AnnotationBodyUpdatedEvent\n | JobStartedEvent // Job progress\n | JobProgressEvent // Job progress\n | JobCompletedEvent // Job progress\n | JobFailedEvent // Job progress\n | EntityTagAddedEvent // Resource-level\n | EntityTagRemovedEvent // Resource-level\n | EntityTypeAddedEvent; // Global collection\n\n// Extract just the event type strings from the union\nexport type ResourceEventType = ResourceEvent['type'];\n\n// System-level events (no resource scope)\nexport type SystemEvent = EntityTypeAddedEvent;\n\n// Resource-scoped events (require resourceId)\nexport type ResourceScopedEvent = Exclude<ResourceEvent, SystemEvent>;\n\n// Type guards\nexport function isResourceEvent(event: any): event is ResourceEvent {\n return event &&\n typeof event.id === 'string' &&\n typeof event.timestamp === 'string' &&\n (event.resourceId === undefined || typeof event.resourceId === 'string') && // resourceId now optional\n typeof event.type === 'string' &&\n event.type.includes('.');\n}\n\n/**\n * Type guard: Check if event is system-level (no resourceId)\n * System events affect global state, not individual resources\n */\nexport function isSystemEvent(event: ResourceEvent): event is SystemEvent {\n return event.type === 'entitytype.added';\n}\n\n/**\n * Type guard: Check if event is resource-scoped (has resourceId)\n * Resource events affect a specific resource's state\n */\nexport function isResourceScopedEvent(event: ResourceEvent): event is ResourceScopedEvent {\n return !isSystemEvent(event);\n}\n\nexport function getEventType<T extends ResourceEvent>(\n event: ResourceEvent\n): T['type'] {\n return event.type as T['type'];\n}\n\n// Event metadata for querying and indexing\nexport interface EventMetadata {\n sequenceNumber: number; // Position in the event log (source of truth for ordering)\n streamPosition: number; // Byte position in JSONL file\n timestamp: string; // When stored (for humans, not ordering)\n prevEventHash?: string; // SHA-256 of previous event (chain integrity, null for first event)\n checksum?: string; // SHA-256 of this event for integrity\n}\n\n// Optional signature for federation\nexport interface EventSignature {\n algorithm: 'ed25519'; // Signature algorithm\n publicKey: string; // User's public key (base64)\n signature: string; // Event signature (base64)\n keyId?: string; // Key identifier for rotation\n}\n\n// Event with metadata (as stored)\nexport interface StoredEvent<T extends ResourceEvent = ResourceEvent> {\n event: T;\n metadata: EventMetadata;\n signature?: EventSignature; // Optional, for federation (unused in MVP)\n}\n\n// Query filters for event retrieval\nexport interface EventQuery {\n resourceId?: ResourceId;\n userId?: string;\n eventTypes?: ResourceEvent['type'][];\n fromTimestamp?: string;\n toTimestamp?: string;\n fromSequence?: number;\n limit?: number;\n}\n\n// Annotation collections for a resource (view storage projection)\n// Annotations are NOT part of the resource - they reference the resource\nexport interface ResourceAnnotations {\n resourceId: ResourceId; // Which resource these annotations belong to (branded type)\n annotations: Annotation[]; // All annotations (highlights, references, assessments, etc.)\n version: number; // Event count for this resource's annotation stream\n updatedAt: string; // Last annotation event timestamp\n}","/**\n * Event Type Guards and Extraction Utilities\n *\n * Domain logic for working with resource events.\n * No React dependencies - safe to use in any JavaScript environment.\n */\n\nimport type { StoredEvent } from './events';\nimport type { AnnotationUri } from './branded-types';\n\n// =============================================================================\n// EVENT TYPE GUARDS AND EXTRACTION\n// =============================================================================\n\n/**\n * Extract annotation ID from event payload\n * Returns null if event is not annotation-related\n *\n * For annotation.added: extracts full URI from payload.annotation.id\n * For annotation.removed/body.updated: constructs full URI from payload.annotationId (UUID) + resourceId\n */\nexport function getAnnotationUriFromEvent(event: StoredEvent): AnnotationUri | null {\n const eventData = event.event;\n\n if (eventData.type === 'annotation.added') {\n // annotation.added has the full annotation object with id as full URI\n return eventData.payload.annotation.id as AnnotationUri || null;\n }\n\n if (eventData.type === 'annotation.removed' || eventData.type === 'annotation.body.updated') {\n // These events have annotationId (UUID only), need to construct full URI\n // Extract base URL from resourceId (format: http://host/resources/id)\n if (eventData.payload.annotationId && eventData.resourceId) {\n try {\n const resourceUri = eventData.resourceId;\n // Extract base URL by removing the /resources/{id} part\n const baseUrl = resourceUri.substring(0, resourceUri.lastIndexOf('/resources/'));\n return `${baseUrl}/annotations/${eventData.payload.annotationId}` as AnnotationUri;\n } catch (e) {\n return null;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Check if an event is related to a specific annotation\n */\nexport function isEventRelatedToAnnotation(event: StoredEvent, annotationUri: AnnotationUri): boolean {\n const eventAnnotationUri = getAnnotationUriFromEvent(event);\n return eventAnnotationUri === annotationUri;\n}\n\n/**\n * Type guard to check if event is a resource event\n */\nexport function isResourceEvent(event: any): event is StoredEvent {\n return event &&\n typeof event.event === 'object' &&\n typeof event.event.id === 'string' &&\n typeof event.event.timestamp === 'string' &&\n typeof event.event.resourceId === 'string' &&\n typeof event.event.type === 'string' &&\n typeof event.metadata === 'object' &&\n typeof event.metadata.sequenceNumber === 'number';\n}\n","/**\n * RxJS-based Event Bus\n *\n * Framework-agnostic event bus providing direct access to typed RxJS Subjects.\n *\n * Can be used in Node.js, browser, workers, CLI - anywhere RxJS runs.\n */\n\nimport { Subject } from 'rxjs';\nimport type { EventMap } from './event-map';\n\n/**\n * RxJS-based event bus\n *\n * Provides direct access to RxJS Subjects for each event type.\n * Use standard RxJS patterns for emitting and subscribing.\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n *\n * // Emit events\n * eventBus.get('attend:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe to events\n * const subscription = eventBus.get('attend:hover').subscribe(({ annotationId }) => {\n * console.log('Hover:', annotationId);\n * });\n *\n * // Use RxJS operators\n * import { debounceTime } from 'rxjs/operators';\n * eventBus.get('attend:hover')\n * .pipe(debounceTime(100))\n * .subscribe(handleHover);\n *\n * // Cleanup\n * subscription.unsubscribe();\n * eventBus.destroy();\n * ```\n */\nexport class EventBus {\n private subjects: Map<keyof EventMap, Subject<any>>;\n private isDestroyed: boolean;\n\n constructor() {\n this.subjects = new Map();\n this.isDestroyed = false;\n }\n\n /**\n * Get the RxJS Subject for an event\n *\n * Returns a typed Subject that can be used with all RxJS operators.\n * Subjects are created lazily on first access.\n *\n * @param eventName - The event name\n * @returns The RxJS Subject for this event\n *\n * @example\n * ```typescript\n * // Emit\n * eventBus.get('attend:hover').next({ annotationId: 'ann-1' });\n *\n * // Subscribe\n * const sub = eventBus.get('attend:hover').subscribe(handleHover);\n *\n * // With operators\n * eventBus.get('attend:hover')\n * .pipe(debounceTime(100), distinctUntilChanged())\n * .subscribe(handleHover);\n * ```\n */\n get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]> {\n if (this.isDestroyed) {\n throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);\n }\n\n if (!this.subjects.has(eventName)) {\n this.subjects.set(eventName, new Subject<EventMap[K]>());\n }\n return this.subjects.get(eventName)!;\n }\n\n /**\n * Destroy the event bus and complete all subjects\n *\n * After calling destroy(), no new events can be emitted or subscribed to.\n * All active subscriptions will be completed.\n */\n destroy(): void {\n if (this.isDestroyed) {\n return;\n }\n\n for (const subject of this.subjects.values()) {\n subject.complete();\n }\n\n this.subjects.clear();\n this.isDestroyed = true;\n }\n\n /**\n * Check if the event bus has been destroyed\n */\n get destroyed(): boolean {\n return this.isDestroyed;\n }\n\n /**\n * Create a resource-scoped event bus\n *\n * Events emitted or subscribed through the scoped bus are isolated to that resource.\n * Internally, events are namespaced but the API remains identical to the parent bus.\n *\n * @param resourceId - Resource identifier to scope events to\n * @returns A scoped event bus for this resource\n *\n * @example\n * ```typescript\n * const eventBus = new EventBus();\n * const resource1 = eventBus.scope('resource-1');\n * const resource2 = eventBus.scope('resource-2');\n *\n * // These are isolated - only resource1 subscribers will fire\n * resource1.get('detection:progress').next({ status: 'started' });\n * ```\n */\n scope(resourceId: string): ScopedEventBus {\n return new ScopedEventBus(this, resourceId);\n }\n}\n\n/**\n * Resource-scoped event bus\n *\n * Provides isolated event streams per resource while maintaining the same API\n * as the parent EventBus. Events are internally namespaced by resourceId.\n */\nexport class ScopedEventBus {\n constructor(\n private parent: EventBus,\n private scopePrefix: string\n ) {}\n\n /**\n * Get the RxJS Subject for a scoped event\n *\n * Returns the same type as the parent bus, but events are isolated to this scope.\n * Internally uses namespaced keys but preserves type safety.\n *\n * @param event - The event name\n * @returns The RxJS Subject for this scoped event\n */\n get<E extends keyof EventMap>(event: E): Subject<EventMap[E]> {\n // Internally namespace the event key, but preserve return type\n const scopedKey = `${this.scopePrefix}:${event as string}`;\n\n // Access parent's subjects map directly (needs cast for private access)\n const parentSubjects = (this.parent as any).subjects as Map<string, Subject<any>>;\n\n if (!parentSubjects.has(scopedKey)) {\n parentSubjects.set(scopedKey, new Subject<EventMap[E]>());\n }\n return parentSubjects.get(scopedKey)!;\n }\n\n /**\n * Create a nested scope\n *\n * Allows hierarchical scoping like `resource-1:subsystem-a`\n *\n * @param subScope - Additional scope level\n * @returns A nested scoped event bus\n */\n scope(subScope: string): ScopedEventBus {\n return new ScopedEventBus(this.parent, `${this.scopePrefix}:${subScope}`);\n }\n}\n","/**\n * Adaptive burst buffer RxJS operator.\n *\n * Passes the first event through immediately (zero latency for interactive use).\n * If more events arrive within the burst window, switches to accumulate mode\n * and flushes batches. Returns to passthrough mode after an idle period.\n *\n * Emits individual items (T) in passthrough mode and arrays (T[]) in batch mode.\n * Consumers distinguish via Array.isArray().\n *\n * Threshold tuning:\n * burstWindowMs — How long to wait for more events before flushing a batch.\n * 50ms is a good default: longer than event-loop jitter (~1-5ms)\n * but short enough to feel responsive.\n * maxBatchSize — Force-flush at this size to bound memory. 500 is safe for\n * Neo4j UNWIND queries. Increase if graph writes are cheap.\n * idleTimeoutMs — How long after the last flush before returning to passthrough.\n * 200ms is a good default. Must be >= burstWindowMs.\n *\n * See: BATCH-GRAPH-CONSUMER-RX.md for design rationale.\n * See: packages/graph/docs/ARCHITECTURE.md for graph consumer context.\n */\n\nimport { Observable, OperatorFunction } from 'rxjs';\n\nexport interface BurstBufferOptions {\n /**\n * Time window (ms) to detect burst activity after an event.\n * If another event arrives within this window, it is buffered.\n * The buffer flushes when no new event arrives for this duration (debounce).\n *\n * Recommended: 50ms.\n */\n burstWindowMs: number;\n\n /**\n * Maximum events to accumulate before forcing a flush.\n * Prevents unbounded memory growth during sustained bursts.\n *\n * Recommended: 500.\n */\n maxBatchSize: number;\n\n /**\n * Time (ms) of silence after the last flush before returning to passthrough mode.\n * The next event after this timeout emits immediately (leading edge).\n * Must be >= burstWindowMs.\n *\n * Recommended: 200ms.\n */\n idleTimeoutMs: number;\n}\n\n/**\n * Adaptive burst buffer operator.\n *\n * State machine:\n * PASSTHROUGH → event arrives → emit immediately, transition to ACCUMULATING\n * ACCUMULATING → event arrives → buffer it, reset burst timer\n * ACCUMULATING → burst timer fires (no new events for burstWindowMs) → flush buffer as T[]\n * ACCUMULATING → buffer reaches maxBatchSize → flush buffer as T[]\n * After flush → idle timer starts\n * Idle timer fires (no new events for idleTimeoutMs) → transition to PASSTHROUGH\n */\nexport function burstBuffer<T>(\n options: BurstBufferOptions\n): OperatorFunction<T, T | T[]> {\n const { burstWindowMs, maxBatchSize, idleTimeoutMs } = options;\n\n return (source: Observable<T>) =>\n new Observable<T | T[]>((subscriber) => {\n let mode: 'passthrough' | 'accumulating' = 'passthrough';\n let buffer: T[] = [];\n let burstTimer: ReturnType<typeof setTimeout> | null = null;\n let idleTimer: ReturnType<typeof setTimeout> | null = null;\n\n function clearBurstTimer() {\n if (burstTimer !== null) {\n clearTimeout(burstTimer);\n burstTimer = null;\n }\n }\n\n function clearIdleTimer() {\n if (idleTimer !== null) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n }\n\n function flush() {\n if (buffer.length === 0) return;\n const batch = buffer;\n buffer = [];\n subscriber.next(batch);\n }\n\n function startIdleTimer() {\n clearIdleTimer();\n idleTimer = setTimeout(() => {\n idleTimer = null;\n mode = 'passthrough';\n }, idleTimeoutMs);\n }\n\n const subscription = source.subscribe({\n next(value: T) {\n clearIdleTimer();\n\n if (mode === 'passthrough') {\n // Leading edge: emit immediately\n subscriber.next(value);\n // Transition to accumulating — next event within burstWindowMs gets buffered\n mode = 'accumulating';\n // Start a burst timer: if nothing else arrives, start idle countdown\n burstTimer = setTimeout(() => {\n burstTimer = null;\n flush(); // flush anything accumulated (normally empty at this point)\n startIdleTimer();\n }, burstWindowMs);\n return;\n }\n\n // mode === 'accumulating'\n buffer.push(value);\n\n // Reset the burst window timer (debounce pattern)\n clearBurstTimer();\n\n if (buffer.length >= maxBatchSize) {\n // Force flush at max batch size\n flush();\n startIdleTimer();\n } else {\n // Debounce: flush after burstWindowMs of silence\n burstTimer = setTimeout(() => {\n burstTimer = null;\n flush();\n startIdleTimer();\n }, burstWindowMs);\n }\n },\n\n error(err) {\n clearBurstTimer();\n clearIdleTimer();\n flush();\n subscriber.error(err);\n },\n\n complete() {\n clearBurstTimer();\n clearIdleTimer();\n flush();\n subscriber.complete();\n },\n });\n\n // Teardown: clean up timers and unsubscribe from source\n return () => {\n clearBurstTimer();\n clearIdleTimer();\n subscription.unsubscribe();\n };\n });\n}\n","/**\n * Backend-specific annotation utility functions\n */\n\nimport type { components } from './types';\nimport type { BodyItem } from './events';\n\ntype Annotation = components['schemas']['Annotation'];\n\n/**\n * Find a body item in an array\n * Returns the index of the first matching item, or -1 if not found\n */\nexport function findBodyItem(body: Annotation['body'], targetItem: BodyItem): number {\n if (!Array.isArray(body)) {\n return -1;\n }\n\n for (let i = 0; i < body.length; i++) {\n const item = body[i];\n\n // Check if this is a valid body item that can be matched\n if (\n typeof item === 'object' &&\n item !== null &&\n 'type' in item &&\n 'purpose' in item\n ) {\n const itemType = (item as { type: unknown }).type;\n const itemPurpose = (item as { purpose: unknown }).purpose;\n\n // Type and purpose must match\n if (itemType !== targetItem.type || itemPurpose !== targetItem.purpose) {\n continue;\n }\n\n // For TextualBody, match by value\n if (targetItem.type === 'TextualBody' && 'value' in item) {\n const itemValue = (item as { value: unknown }).value;\n if (itemValue === targetItem.value) {\n return i;\n }\n }\n\n // For SpecificResource, match by source\n if (targetItem.type === 'SpecificResource' && 'source' in item) {\n const itemSource = (item as { source: unknown }).source;\n if (itemSource === targetItem.source) {\n return i;\n }\n }\n }\n }\n\n return -1;\n}\n","/**\n * Common type guard utilities\n */\n\n/**\n * Check if value is a string\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Check if value is a number (not NaN)\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !isNaN(value);\n}\n\n/**\n * Check if value is an object (not null, not array)\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Check if value is an array\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/**\n * Check if value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Check if value is a function\n */\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Check if value is null\n */\nexport function isNull(value: unknown): value is null {\n return value === null;\n}\n\n/**\n * Check if value is undefined\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined;\n}\n\n/**\n * Check if value is null or undefined\n */\nexport function isNullish(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n\n/**\n * Check if value is defined (not null or undefined)\n */\nexport function isDefined<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}","/**\n * Common error classes\n */\n\n/**\n * Base error class for Semiont applications\n */\nexport class SemiontError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: Record<string, any>\n ) {\n super(message);\n this.name = 'SemiontError';\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when validation fails\n */\nexport class ValidationError extends SemiontError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'VALIDATION_ERROR', details);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Error thrown by scripts\n */\nexport class ScriptError extends SemiontError {\n constructor(message: string, code: string = 'SCRIPT_ERROR', details?: Record<string, any>) {\n super(message, code, details);\n this.name = 'ScriptError';\n }\n}\n\n/**\n * Error thrown when a resource is not found\n */\nexport class NotFoundError extends SemiontError {\n constructor(resource: string, id?: string) {\n const message = id ? `${resource} with id '${id}' not found` : `${resource} not found`;\n super(message, 'NOT_FOUND', { resource, id });\n this.name = 'NotFoundError';\n }\n}\n\n/**\n * Error thrown when user is not authorized\n */\nexport class UnauthorizedError extends SemiontError {\n constructor(message: string = 'Unauthorized', details?: Record<string, any>) {\n super(message, 'UNAUTHORIZED', details);\n this.name = 'UnauthorizedError';\n }\n}\n\n/**\n * Error thrown when operation would conflict with existing data\n */\nexport class ConflictError extends SemiontError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'CONFLICT', details);\n this.name = 'ConflictError';\n }\n}\n\n/**\n * API Error class for handling HTTP errors\n * Used by API clients to represent failed HTTP requests\n */\nexport class APIError extends Error {\n constructor(\n public status: number,\n public data: any,\n message?: string\n ) {\n super(message || `API Error: ${status}`);\n this.name = 'APIError';\n Error.captureStackTrace(this, this.constructor);\n }\n}","/**\n * DID (Decentralized Identifier) and W3C Agent utilities\n *\n * Provides utilities for working with DID:WEB identifiers and converting\n * between user representations and W3C Web Annotation Agent objects.\n */\n\nimport type { components } from './types';\n\ntype Agent = components['schemas']['Agent'];\n\n/**\n * Convert a user object to a DID:WEB identifier\n *\n * Format: did:web:domain.com:users:userId\n * Example: did:web:example.com:users:abc123\n *\n * This is used for W3C Web Annotation compliance and federation readiness.\n *\n * @param user - User object with id and domain\n * @returns DID:WEB identifier string\n */\nexport function userToDid(user: { id: string; domain: string }): string {\n return `did:web:${user.domain}:users:${user.id}`;\n}\n\n/**\n * Convert a user object to a W3C Agent object with DID:WEB identifier\n *\n * Creates a full Agent object for W3C Web Annotation compliance.\n * Includes DID:WEB identifier, type, and name.\n *\n * @param user - User object with id, domain, name, and email\n * @returns W3C Agent object\n */\nexport function userToAgent(user: {\n id: string;\n domain: string;\n name: string | null;\n email: string;\n}): Agent {\n return {\n type: 'Person' as const,\n id: userToDid(user),\n name: user.name || user.email,\n };\n}\n\n/**\n * Convert a DID string to a minimal W3C Agent object\n *\n * Used when reconstructing annotations from events where only the DID is available.\n * Creates a minimal Agent with just the required fields (id, type).\n * Name is derived from the DID for display purposes.\n *\n * @param did - DID:WEB identifier string\n * @returns Minimal W3C Agent object\n */\nexport function didToAgent(did: string): Agent {\n // Extract user ID from DID format: did:web:domain.com:users:userId\n const parts = did.split(':');\n const userId = parts[parts.length - 1] || 'unknown';\n\n return {\n type: 'Person' as const,\n id: did,\n name: userId, // Use user ID as name since we don't have full user data\n };\n}\n","/**\n * Configuration Error Class\n * \n * Custom error class for configuration validation and loading errors.\n * Provides structured error information with helpful suggestions.\n */\n\nexport class ConfigurationError extends Error {\n public override readonly cause?: Error;\n\n constructor(\n message: string,\n public environment?: string,\n public suggestion?: string,\n cause?: Error\n ) {\n super(message);\n this.name = 'ConfigurationError';\n this.cause = cause;\n }\n \n /**\n * Format the error nicely for CLI output\n */\n override toString(): string {\n let output = `❌ ${this.message}`;\n if (this.environment) {\n output += `\\n Environment: ${this.environment}`;\n }\n if (this.suggestion) {\n output += `\\n 💡 Suggestion: ${this.suggestion}`;\n }\n return output;\n }\n}","{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"$id\": \"https://semiont.org/schemas/config.json\",\n \"definitions\": {\n \"PlatformType\": {\n \"type\": \"string\",\n \"enum\": [\n \"posix\",\n \"container\",\n \"aws\",\n \"external\"\n ]\n },\n \"ServicePlatformConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"type\": {\n \"$ref\": \"#/definitions/PlatformType\"\n }\n },\n \"required\": [\n \"type\"\n ]\n },\n \"ResourceRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"cpu\": {\n \"type\": \"string\"\n },\n \"memory\": {\n \"type\": \"string\"\n },\n \"gpu\": {\n \"type\": \"integer\"\n },\n \"gpus\": {\n \"type\": \"integer\"\n },\n \"replicas\": {\n \"type\": \"integer\"\n },\n \"ephemeralStorage\": {\n \"type\": \"string\"\n },\n \"memoryReservation\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n },\n \"SecurityRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"readOnlyRootFilesystem\": {\n \"type\": \"boolean\"\n },\n \"runAsNonRoot\": {\n \"type\": \"boolean\"\n },\n \"runAsUser\": {\n \"type\": \"integer\"\n },\n \"runAsGroup\": {\n \"type\": \"integer\"\n },\n \"capabilities\": {\n \"oneOf\": [\n {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"add\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"drop\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n }\n ]\n },\n \"privileged\": {\n \"type\": \"boolean\"\n },\n \"allowPrivilegeEscalation\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"BuildRequirements\": {\n \"type\": \"object\",\n \"properties\": {\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"BackendServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"devMode\": {\n \"type\": \"boolean\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"publicURL\": {\n \"type\": \"string\"\n },\n \"corsOrigin\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"cpu\": {\n \"type\": \"string\"\n },\n \"memory\": {\n \"type\": \"string\"\n },\n \"semiontRepo\": {\n \"type\": \"string\"\n },\n \"databaseUrl\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"redisUrl\": {\n \"type\": \"string\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"port\",\n \"publicURL\",\n \"corsOrigin\"\n ],\n \"additionalProperties\": false\n },\n \"FrontendServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"devMode\": {\n \"type\": \"boolean\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"siteName\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"semiontRepo\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n },\n \"databaseUrl\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"publicURL\": {\n \"type\": \"string\"\n },\n \"allowedOrigins\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"port\",\n \"siteName\"\n ],\n \"additionalProperties\": false\n },\n \"ProxyServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\"envoy\", \"nginx\", \"haproxy\"],\n \"default\": \"envoy\"\n },\n \"port\": {\n \"type\": \"integer\",\n \"default\": 8080\n },\n \"adminPort\": {\n \"type\": \"integer\",\n \"default\": 9901\n },\n \"backendPort\": {\n \"type\": \"integer\",\n \"default\": 4000\n },\n \"frontendPort\": {\n \"type\": \"integer\",\n \"default\": 3000\n },\n \"image\": {\n \"type\": \"string\",\n \"default\": \"envoyproxy/envoy:v1.28-latest\"\n },\n \"configPath\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"port\"\n ],\n \"additionalProperties\": false\n },\n \"DatabaseServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"host\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"user\": {\n \"type\": \"string\"\n },\n \"username\": {\n \"type\": \"string\"\n },\n \"password\": {\n \"type\": \"string\"\n },\n \"database\": {\n \"type\": \"string\"\n },\n \"storageSize\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"host\",\n \"port\"\n ],\n \"additionalProperties\": false\n },\n \"GraphDatabaseType\": {\n \"type\": \"string\",\n \"enum\": [\n \"neo4j\",\n \"janusgraph\",\n \"neptune\",\n \"memory\"\n ]\n },\n \"GraphServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"$ref\": \"#/definitions/GraphDatabaseType\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"uri\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"username\": {\n \"type\": \"string\"\n },\n \"password\": {\n \"type\": \"string\"\n },\n \"database\": {\n \"type\": \"string\"\n },\n \"host\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"storage\": {\n \"type\": \"string\"\n },\n \"index\": {\n \"type\": \"string\"\n },\n \"endpoint\": {\n \"type\": \"string\"\n },\n \"region\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"janusgraphVersion\": {\n \"type\": \"string\"\n },\n \"javaOptions\": {\n \"type\": \"string\"\n },\n \"heapSize\": {\n \"type\": \"string\"\n },\n \"pageCacheSize\": {\n \"type\": \"string\"\n },\n \"noAuth\": {\n \"type\": \"boolean\"\n },\n \"dataPath\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\"\n ],\n \"allOf\": [\n {\n \"if\": {\n \"properties\": {\n \"type\": {\n \"const\": \"neo4j\"\n }\n }\n },\n \"then\": {\n \"required\": [\n \"uri\",\n \"username\",\n \"password\",\n \"database\"\n ]\n }\n }\n ],\n \"additionalProperties\": false\n },\n \"FilesystemServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"path\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"path\"\n ],\n \"additionalProperties\": false\n },\n \"InferenceServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"model\": {\n \"type\": \"string\"\n },\n \"maxTokens\": {\n \"type\": \"integer\"\n },\n \"endpoint\": {\n \"type\": \"string\"\n },\n \"baseURL\": {\n \"type\": \"string\"\n },\n \"apiKey\": {\n \"type\": \"string\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"organization\": {\n \"type\": \"string\"\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\",\n \"type\",\n \"apiKey\"\n ],\n \"additionalProperties\": false\n },\n \"McpServiceConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"platform\": {\n \"$ref\": \"#/definitions/ServicePlatformConfig\"\n },\n \"command\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\"\n },\n \"port\": {\n \"type\": \"integer\"\n },\n \"dependsOn\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"timeout\": {\n \"type\": \"integer\"\n },\n \"wait\": {\n \"type\": \"integer\"\n },\n \"logsEndpoint\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n },\n \"resources\": {\n \"$ref\": \"#/definitions/ResourceRequirements\"\n },\n \"security\": {\n \"$ref\": \"#/definitions/SecurityRequirements\"\n },\n \"build\": {\n \"oneOf\": [\n {\n \"type\": \"boolean\"\n },\n {\n \"$ref\": \"#/definitions/BuildRequirements\"\n }\n ]\n },\n \"dockerfile\": {\n \"type\": \"string\"\n },\n \"buildContext\": {\n \"type\": \"string\"\n },\n \"buildArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"buildTarget\": {\n \"type\": \"string\"\n },\n \"prebuilt\": {\n \"type\": \"boolean\"\n },\n \"noCache\": {\n \"type\": \"boolean\"\n },\n \"secrets\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"labels\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"annotations\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"dependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"externalDependencies\": {\n \"type\": \"array\",\n \"items\": {\n \"oneOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\"\n },\n \"healthCheck\": {\n \"type\": \"string\"\n }\n }\n }\n ]\n }\n },\n \"environment\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"env\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"platform\"\n ],\n \"additionalProperties\": false\n },\n \"ServicesConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"backend\": {\n \"$ref\": \"#/definitions/BackendServiceConfig\"\n },\n \"frontend\": {\n \"$ref\": \"#/definitions/FrontendServiceConfig\"\n },\n \"database\": {\n \"$ref\": \"#/definitions/DatabaseServiceConfig\"\n },\n \"graph\": {\n \"$ref\": \"#/definitions/GraphServiceConfig\"\n },\n \"filesystem\": {\n \"$ref\": \"#/definitions/FilesystemServiceConfig\"\n },\n \"inference\": {\n \"$ref\": \"#/definitions/InferenceServiceConfig\"\n },\n \"mcp\": {\n \"$ref\": \"#/definitions/McpServiceConfig\"\n },\n \"proxy\": {\n \"$ref\": \"#/definitions/ProxyServiceConfig\"\n }\n },\n \"additionalProperties\": true\n },\n \"SiteConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"siteName\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Display name for the site\"\n },\n \"domain\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Primary domain for the site\"\n },\n \"adminEmail\": {\n \"type\": \"string\",\n \"format\": \"email\",\n \"description\": \"Administrator email address\"\n },\n \"supportEmail\": {\n \"type\": \"string\",\n \"format\": \"email\",\n \"description\": \"Support email address (optional)\"\n },\n \"oauthAllowedDomains\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"minItems\": 1,\n \"description\": \"Email domains allowed for OAuth authentication\"\n }\n },\n \"required\": [\n \"domain\"\n ],\n \"additionalProperties\": false\n },\n \"AppConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"features\": {\n \"type\": \"object\",\n \"properties\": {\n \"enableAnalytics\": {\n \"type\": \"boolean\"\n },\n \"enableMaintenanceMode\": {\n \"type\": \"boolean\"\n },\n \"enableDebugLogging\": {\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n },\n \"security\": {\n \"type\": \"object\",\n \"properties\": {\n \"sessionTimeout\": {\n \"type\": \"integer\",\n \"minimum\": 60,\n \"description\": \"Session timeout in seconds\"\n },\n \"maxLoginAttempts\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"description\": \"Maximum failed login attempts before lockout\"\n },\n \"corsAllowedOrigins\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"enableLocalAuth\": {\n \"type\": \"boolean\",\n \"description\": \"Enable local username/password authentication\"\n },\n \"jwtSecret\": {\n \"type\": \"string\",\n \"minLength\": 32,\n \"description\": \"JWT signing secret (base64 encoded, 32+ bytes)\"\n }\n },\n \"additionalProperties\": false\n },\n \"performance\": {\n \"type\": \"object\",\n \"properties\": {\n \"enableCaching\": {\n \"type\": \"boolean\"\n },\n \"cacheTimeout\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"description\": \"Cache timeout in seconds\"\n },\n \"maxRequestSize\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]+(kb|mb|gb)$\",\n \"description\": \"Maximum request size (e.g., '10mb')\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"additionalProperties\": false\n },\n \"EnvironmentConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"_comment\": {\n \"type\": \"string\",\n \"description\": \"Optional comment for documentation\"\n },\n \"_metadata\": {\n \"type\": \"object\",\n \"properties\": {\n \"environment\": {\n \"type\": \"string\"\n },\n \"projectRoot\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"environment\",\n \"projectRoot\"\n ]\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Environment name\"\n },\n \"platform\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"$ref\": \"#/definitions/PlatformType\"\n }\n }\n },\n \"services\": {\n \"$ref\": \"#/definitions/ServicesConfig\"\n },\n \"site\": {\n \"$ref\": \"#/definitions/SiteConfig\"\n },\n \"app\": {\n \"$ref\": \"#/definitions/AppConfig\"\n },\n \"env\": {\n \"type\": \"object\",\n \"properties\": {\n \"NODE_ENV\": {\n \"type\": \"string\",\n \"enum\": [\n \"development\",\n \"production\",\n \"test\"\n ]\n }\n },\n \"additionalProperties\": true\n },\n \"logLevel\": {\n \"type\": \"string\",\n \"enum\": [\n \"error\",\n \"warn\",\n \"info\",\n \"http\",\n \"debug\"\n ],\n \"description\": \"Logging verbosity level\"\n },\n \"deployment\": {\n \"type\": \"object\",\n \"properties\": {\n \"imageTagStrategy\": {\n \"type\": \"string\",\n \"enum\": [\n \"mutable\",\n \"immutable\",\n \"git-hash\"\n ]\n }\n }\n }\n },\n \"required\": [\n \"services\"\n ],\n \"additionalProperties\": false\n },\n \"SemiontConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"version\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$\",\n \"description\": \"Config file version (semver)\"\n },\n \"project\": {\n \"type\": \"string\",\n \"minLength\": 1,\n \"description\": \"Project name\"\n },\n \"site\": {\n \"$ref\": \"#/definitions/SiteConfig\"\n },\n \"app\": {\n \"$ref\": \"#/definitions/AppConfig\"\n },\n \"services\": {\n \"$ref\": \"#/definitions/ServicesConfig\"\n }\n },\n \"required\": [\n \"version\",\n \"project\",\n \"site\"\n ],\n \"additionalProperties\": false\n }\n }\n}\n","/**\n * Config Schema Validator\n *\n * Validates configuration data against JSON Schema using Ajv (JSON Schema validator).\n * Provides runtime validation for semiont.json and environment config files.\n */\n\nimport Ajv, { type ErrorObject } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport configSchema from './config.schema.json' with { type: 'json' };\n\n// Initialize Ajv with config-compatible settings\nconst ajv = new Ajv({\n allErrors: true, // Return all errors, not just the first one\n coerceTypes: true, // Coerce types (e.g., \"123\" -> 123)\n removeAdditional: false, // Don't remove additional properties\n useDefaults: true, // Apply default values from schema\n strict: false\n});\n\n// Add format validators (email, uri, date-time, etc.)\naddFormats(ajv);\n\n// Load schema\najv.addSchema(configSchema, 'config');\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ErrorObject[] | null;\n errorMessage?: string;\n}\n\n/**\n * Validate semiont.json config\n */\nexport function validateSemiontConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/SemiontConfig');\n if (!validate) {\n throw new Error('SemiontConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Validate environment config (environments/*.json)\n */\nexport function validateEnvironmentConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/EnvironmentConfig');\n if (!validate) {\n throw new Error('EnvironmentConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Validate site config\n */\nexport function validateSiteConfig(data: unknown): ValidationResult {\n const validate = ajv.getSchema('config#/definitions/SiteConfig');\n if (!validate) {\n throw new Error('SiteConfig schema not found');\n }\n\n const valid = validate(data);\n\n if (!valid) {\n return {\n valid: false,\n errors: validate.errors || null,\n errorMessage: formatErrors(validate.errors || [])\n };\n }\n\n return { valid: true, errors: null };\n}\n\n/**\n * Format validation errors into human-readable message\n */\nexport function formatErrors(errors: ErrorObject[]): string {\n if (errors.length === 0) return 'Validation failed';\n\n const messages = errors.map(err => {\n const path = err.instancePath || 'root';\n const message = err.message || 'validation error';\n\n if (err.keyword === 'required' && 'missingProperty' in err.params) {\n return `Missing required property: ${err.params.missingProperty}`;\n }\n\n if (err.keyword === 'type' && 'type' in err.params) {\n return `${path}: ${message} (expected ${err.params.type})`;\n }\n\n if (err.keyword === 'enum' && 'allowedValues' in err.params) {\n return `${path}: must be one of [${(err.params.allowedValues as string[]).join(', ')}]`;\n }\n\n if (err.keyword === 'format') {\n return `${path}: invalid format (${message})`;\n }\n\n if (err.keyword === 'minLength' || err.keyword === 'minItems') {\n return `${path}: ${message}`;\n }\n\n return `${path}: ${message}`;\n });\n\n return messages.join('; ');\n}\n","/**\n * Environment Loader Module\n *\n * Responsible for parsing and merging environment configurations.\n * Pure functions only - callers handle filesystem I/O.\n */\n\nimport { ConfigurationError } from './configuration-error';\nimport { PlatformType } from './platform-types';\nimport { isObject } from '../index';\nimport { validateEnvironmentConfig } from './config-validator';\nimport type {\n EnvironmentConfig,\n SiteConfig,\n AppConfig,\n SemiontConfig,\n ServicesConfig,\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n ServicePlatformConfig\n} from './config.types';\n\n/**\n * Re-export generated types from JSON Schema\n * These types are automatically generated from config.schema.json\n */\nexport type {\n EnvironmentConfig,\n SiteConfig,\n AppConfig,\n SemiontConfig,\n PlatformType,\n ServicesConfig,\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n ServicePlatformConfig\n};\n\n/**\n * Generic service configuration\n * Platform-specific fields should be accessed through platform-specific interfaces\n */\nexport interface ServiceConfig {\n platform?: {\n type: PlatformType;\n };\n // Generic fields that apply across platforms\n port?: number;\n name?: string;\n // Platform-specific fields are loosely typed here\n // Platforms should validate and type these properly\n [key: string]: any;\n}\n\nexport interface AWSConfig {\n region: string;\n accountId: string;\n certificateArn?: string;\n hostedZoneId?: string;\n rootDomain?: string;\n stacks?: {\n data?: string;\n app?: string;\n };\n database?: {\n name?: string;\n instanceClass?: string;\n allocatedStorage?: number;\n backupRetentionDays?: number;\n multiAZ?: boolean;\n };\n ecs?: {\n desiredCount?: number;\n minCapacity?: number;\n maxCapacity?: number;\n };\n monitoring?: {\n enableDetailedMonitoring?: boolean;\n logRetentionDays?: number;\n };\n}\n\n/**\n * Deep merge utility for configuration objects\n * Pure function - no side effects\n */\nexport function deepMerge(target: any, ...sources: any[]): any {\n if (!sources.length) return target;\n const source = sources.shift();\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} });\n deepMerge(target[key], source[key]);\n } else {\n Object.assign(target, { [key]: source[key] });\n }\n }\n }\n\n return deepMerge(target, ...sources);\n}\n\n\n/**\n * Recursively resolve environment variable placeholders in configuration\n * Replaces ${VAR_NAME} with the value from the provided env object\n * Pure function - accepts env as parameter instead of using process.env\n *\n * @param obj - Configuration object to process\n * @param env - Environment variables object\n * @returns Configuration with resolved environment variables\n */\nexport function resolveEnvVars(obj: any, env: Record<string, string | undefined>): any {\n if (typeof obj === 'string') {\n // Replace ${VAR_NAME} with actual environment variable value\n return obj.replace(/\\$\\{([^}]+)\\}/g, (match, varName) => {\n return env[varName] || match;\n });\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveEnvVars(item, env));\n }\n\n if (obj && typeof obj === 'object') {\n const resolved: any = {};\n for (const key in obj) {\n resolved[key] = resolveEnvVars(obj[key], env);\n }\n return resolved;\n }\n\n return obj;\n}\n\n/**\n * Parse and merge configuration files\n * Pure function - accepts file contents as strings instead of reading from filesystem\n *\n * @param baseContent - Contents of semiont.json (null if file doesn't exist)\n * @param envContent - Contents of environment-specific JSON file\n * @param env - Environment variables object\n * @param environment - Environment name\n * @param projectRoot - Project root path (for metadata only)\n * @returns Merged and validated environment configuration\n * @throws ConfigurationError if parsing or validation fails\n */\nexport function parseAndMergeConfigs(\n baseContent: string | null,\n envContent: string,\n env: Record<string, string | undefined>,\n environment: string,\n projectRoot: string\n): EnvironmentConfig {\n try {\n // Parse base config\n let baseConfig: any = {};\n if (baseContent) {\n baseConfig = JSON.parse(baseContent);\n }\n\n // Parse environment config\n const envConfig = JSON.parse(envContent);\n\n // Merge configurations: base defaults -> environment config\n const merged = deepMerge(\n {},\n { site: baseConfig.site }, // Site config from semiont.json\n baseConfig.defaults || {}, // Default config from semiont.json\n envConfig // Environment-specific overrides\n );\n\n // Resolve environment variables in the merged configuration\n const resolved = resolveEnvVars(merged, env);\n\n // Ensure services exists (even if empty)\n if (!resolved.services) {\n resolved.services = {};\n }\n\n // Validate NODE_ENV if specified\n if (resolved.env?.NODE_ENV) {\n const validNodeEnv = ['development', 'production', 'test'];\n if (!validNodeEnv.includes(resolved.env.NODE_ENV)) {\n throw new ConfigurationError(\n `Invalid NODE_ENV value: ${resolved.env.NODE_ENV}`,\n environment,\n `NODE_ENV must be one of: ${validNodeEnv.join(', ')}`\n );\n }\n }\n\n // Add metadata about where this config came from\n const configWithMetadata = {\n ...resolved,\n _metadata: {\n environment,\n projectRoot\n }\n };\n\n // Validate with AJV\n const validationResult = validateEnvironmentConfig(configWithMetadata);\n\n if (!validationResult.valid) {\n throw new ConfigurationError(\n `Invalid environment configuration: ${validationResult.errorMessage}`,\n environment,\n `Fix the validation errors in your environments/${environment}.json file`\n );\n }\n\n return configWithMetadata as EnvironmentConfig;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error; // Re-throw our custom errors\n }\n\n if (error instanceof SyntaxError && error.message.includes('JSON')) {\n throw new ConfigurationError(\n `Invalid JSON syntax in configuration file`,\n environment,\n `Check for missing commas, quotes, or brackets. Use a JSON validator to verify syntax.`\n );\n }\n\n const message = error instanceof Error ? error.message : String(error);\n throw new ConfigurationError(\n `Failed to parse environment configuration: ${message}`,\n environment,\n `Check the configuration files are valid JSON`\n );\n }\n}\n\n/**\n * Get NODE_ENV value from environment config\n *\n * @param config - Environment configuration\n * @returns NODE_ENV value (defaults to 'development' if not specified)\n */\nexport function getNodeEnvForEnvironment(config: EnvironmentConfig): 'development' | 'production' | 'test' {\n const nodeEnv = config.env?.NODE_ENV;\n\n // Default to 'development' if not specified\n return nodeEnv || 'development';\n}\n\n/**\n * List environment names from filenames\n * Pure function - accepts array of filenames instead of reading from filesystem\n *\n * @param files - Array of filenames from environments directory\n * @returns Sorted array of environment names\n */\nexport function listEnvironmentNames(files: string[]): string[] {\n return files\n .filter(file => file.endsWith('.json'))\n .map(file => {\n // Extract filename from path (handle directory separators)\n const lastSlash = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\\\'));\n const filename = lastSlash >= 0 ? file.substring(lastSlash + 1) : file;\n // Remove '.json' suffix\n return filename.slice(0, -5);\n })\n .sort();\n}\n\n/**\n * Type guard to check if config has AWS settings\n * \n * @param config - Environment configuration\n * @returns True if AWS configuration is present\n */\nexport function hasAWSConfig(config: EnvironmentConfig): config is EnvironmentConfig & { aws: AWSConfig } {\n return !!(config as any).aws && !!(config as any).aws.region;\n}\n\n/**\n * Display configuration for debugging\n *\n * @param config - Configuration to display\n */\nexport function displayConfiguration(config: EnvironmentConfig): void {\n console.log('Environment Configuration:');\n console.log(JSON.stringify(config, null, 2));\n}\n\n/**\n * File reader abstraction for platform-agnostic config loading\n * Implementations provide platform-specific file I/O (Node.js, Deno, Bun, etc.)\n */\nexport type ConfigFileReader = {\n /** Read file if it exists, return null otherwise */\n readIfExists: (path: string) => string | null;\n /** Read file, throw error if it doesn't exist */\n readRequired: (path: string) => string;\n};\n\n/**\n * Create a config loader with a specific file reader implementation\n * Higher-order function that returns a platform-specific config loader\n *\n * @param reader - Platform-specific file reader implementation\n * @returns Function to load environment config from filesystem\n *\n * @example\n * ```typescript\n * import * as fs from 'fs';\n * import { createConfigLoader } from '@semiont/core';\n *\n * const nodeReader = {\n * readIfExists: (path) => fs.existsSync(path) ? fs.readFileSync(path, 'utf-8') : null,\n * readRequired: (path) => {\n * if (!fs.existsSync(path)) throw new Error(`File not found: ${path}`);\n * return fs.readFileSync(path, 'utf-8');\n * },\n * };\n *\n * const loadConfig = createConfigLoader(nodeReader);\n * const config = loadConfig('/project/root', 'production');\n * ```\n */\nexport function createConfigLoader(reader: ConfigFileReader) {\n return (projectRoot: string, environment: string): EnvironmentConfig => {\n // Read base semiont.json (optional)\n const baseContent = reader.readIfExists(`${projectRoot}/semiont.json`);\n\n // Read environment-specific config (required)\n const envContent = reader.readRequired(`${projectRoot}/environments/${environment}.json`);\n\n // Use pure function to parse and merge\n return parseAndMergeConfigs(baseContent, envContent, process.env, environment, projectRoot);\n };\n}\n\n","/**\n * Environment validation utilities\n *\n * Pure functions - accept available environments as parameter instead of reading from filesystem\n */\n\nexport type Environment = string; // Allow any environment name\n\n/**\n * Type guard to check if a string is a valid Environment\n * @param value - The environment string to check\n * @param availableEnvironments - List of valid environment names\n */\nexport function isValidEnvironment(value: string | undefined, availableEnvironments: string[]): value is Environment {\n if (!value) return false;\n return availableEnvironments.includes(value);\n}\n\n/**\n * Parse environment string to Environment type\n * @param value - The environment string to parse\n * @param availableEnvironments - List of valid environment names\n * @returns Valid Environment type\n * @throws Error if environment is invalid or not provided\n */\nexport function parseEnvironment(value: string | undefined, availableEnvironments: string[]): Environment {\n if (!value) {\n throw new Error('Environment is required');\n }\n if (!isValidEnvironment(value, availableEnvironments)) {\n throw new Error(`Invalid environment: ${value}. Available environments: ${availableEnvironments.join(', ')}`);\n }\n return value;\n}\n\n/**\n * Validate and return environment or throw error\n * @param value - The environment string to validate\n * @param availableEnvironments - List of valid environment names\n * @throws Error if environment is invalid\n */\nexport function validateEnvironment(value: string | undefined, availableEnvironments: string[]): Environment {\n if (!value) {\n throw new Error('Environment is required');\n }\n if (!isValidEnvironment(value, availableEnvironments)) {\n throw new Error(`Invalid environment: ${value}. Available environments: ${availableEnvironments.join(', ')}`);\n }\n return value;\n}","/**\n * Platform Types Module\n *\n * Re-exports PlatformType from schema-generated types.\n * Platforms represent WHERE services run (infrastructure targets).\n */\n\nimport { PlatformType as SchemaPlatformType } from './config.types';\n\n/**\n * Platform type literals from JSON Schema\n * These represent the infrastructure targets where services can be deployed\n */\nexport type PlatformType = SchemaPlatformType;\n\n/**\n * Type guard to check if a string is a valid platform type\n *\n * @param value - Value to check\n * @returns True if value is a valid PlatformType\n */\nexport function isValidPlatformType(value: string): value is PlatformType {\n return ['aws', 'container', 'posix', 'external'].includes(value);\n}\n\n/**\n * Get all valid platform types\n *\n * @returns Array of all platform types\n */\nexport function getAllPlatformTypes(): PlatformType[] {\n return ['aws', 'container', 'posix', 'external'];\n}","/**\n * @semiont/core\n *\n * Core domain logic and utilities for the Semiont semantic knowledge platform.\n * OpenAPI types are generated here and exported for use across the monorepo.\n */\n\n// OpenAPI-generated types (source of truth for API schemas)\nexport type { components, paths, operations } from './types';\n\n// Branded types (compile-time type safety)\nexport type {\n // OpenAPI types\n Motivation,\n ContentFormat,\n // Authentication & tokens\n Email,\n AuthCode,\n GoogleCredential,\n AccessToken,\n RefreshToken,\n MCPToken,\n CloneToken,\n // System identifiers\n JobId,\n UserDID,\n EntityType,\n SearchQuery,\n BaseUrl,\n // HTTP URI types\n ResourceUri,\n AnnotationUri,\n ResourceAnnotationUri,\n} from './branded-types';\nexport {\n // Helper functions\n email,\n authCode,\n googleCredential,\n accessToken,\n refreshToken,\n mcpToken,\n cloneToken,\n jobId,\n userDID,\n entityType,\n searchQuery,\n baseUrl,\n // URI factory functions\n resourceUri,\n annotationUri,\n resourceAnnotationUri,\n} from './branded-types';\n\n// Creation methods\nexport { CREATION_METHODS } from './creation-methods';\nexport type { CreationMethod } from './creation-methods';\n\n// Identifier types (only IDs - URIs are in @semiont/api-client)\nexport type { ResourceId, AnnotationId, UserId } from './identifiers';\nexport {\n resourceId,\n annotationId,\n userId,\n isResourceId,\n isAnnotationId,\n} from './identifiers';\n\n// URI utilities\nexport {\n resourceIdToURI,\n uriToResourceId,\n annotationIdToURI,\n uriToAnnotationId,\n uriToAnnotationIdOrPassthrough,\n extractResourceUriFromAnnotationUri,\n} from './uri-utils';\n\n// Graph types\nexport type {\n GraphConnection,\n GraphPath,\n EntityTypeStats,\n} from './graph';\n\n// Event types\nexport type {\n BaseEvent,\n ResourceEvent,\n ResourceEventType,\n SystemEvent,\n ResourceScopedEvent,\n ResourceCreatedEvent,\n ResourceClonedEvent,\n ResourceArchivedEvent,\n ResourceUnarchivedEvent,\n RepresentationAddedEvent,\n RepresentationRemovedEvent,\n AnnotationAddedEvent,\n AnnotationRemovedEvent,\n AnnotationBodyUpdatedEvent,\n JobStartedEvent,\n JobProgressEvent,\n JobCompletedEvent,\n JobFailedEvent,\n BodyOperation,\n BodyItem,\n EntityTagAddedEvent,\n EntityTagRemovedEvent,\n EventMetadata,\n EventSignature,\n StoredEvent,\n EventQuery,\n ResourceAnnotations,\n} from './events';\nexport {\n isResourceEvent,\n isSystemEvent,\n isResourceScopedEvent,\n getEventType,\n} from './events';\n\n// Event utilities\nexport {\n getAnnotationUriFromEvent,\n isEventRelatedToAnnotation,\n isResourceEvent as isStoredEvent,\n} from './event-utils';\n\n// Event bus (RxJS-based, framework-agnostic)\nexport { EventBus, ScopedEventBus } from './event-bus';\n\n// RxJS operators\nexport { burstBuffer, type BurstBufferOptions } from './operators/burst-buffer';\n\n// Logger interface (framework-agnostic)\nexport type { Logger } from './logger';\n\n// Event protocol (application-level events for event bus)\nexport type {\n EventMap,\n EventName,\n SelectionData,\n AnnotationProgress,\n GenerationProgress,\n Selector,\n GenerationContext,\n} from './event-map';\n\n// Backend-specific annotation utilities\nexport { findBodyItem } from './annotation-utils';\n\n// Resource types\nexport type { UpdateResourceInput, ResourceFilter } from './resource-types';\n\n// Annotation types\nexport type { AnnotationCategory, CreateAnnotationInternal } from './annotation-types';\n\n// Auth types\nexport type { GoogleAuthRequest } from './auth-types';\n\n// Utility functions\nexport * from './type-guards';\nexport * from './errors';\nexport * from './did-utils';\n\n// Configuration - Pure functions only (no filesystem dependencies)\n// Callers should read config files themselves and pass contents to parseAndMergeConfigs\n// Or use createConfigLoader with a platform-specific file reader\nexport {\n deepMerge,\n resolveEnvVars,\n parseAndMergeConfigs,\n createConfigLoader,\n listEnvironmentNames,\n getNodeEnvForEnvironment,\n hasAWSConfig,\n displayConfiguration,\n // Types\n type EnvironmentConfig,\n type ServiceConfig,\n type AWSConfig,\n type SiteConfig,\n type AppConfig,\n type ConfigFileReader,\n} from './config/environment-loader';\n\nexport {\n parseEnvironment,\n validateEnvironment,\n type Environment,\n} from './config/environment-validator';\nexport {\n formatErrors,\n validateSemiontConfig,\n validateEnvironmentConfig,\n validateSiteConfig,\n type ValidationResult,\n} from './config/config-validator';\nexport { ConfigurationError } from './config/configuration-error';\nexport type { ProxyServiceConfig } from './config/config.types';\nexport {\n type PlatformType,\n isValidPlatformType,\n getAllPlatformTypes,\n} from './config/platform-types';\n\n// Schema-generated configuration types\nexport type {\n BackendServiceConfig,\n FrontendServiceConfig,\n DatabaseServiceConfig,\n GraphServiceConfig,\n FilesystemServiceConfig,\n InferenceServiceConfig,\n McpServiceConfig,\n ServicesConfig,\n SemiontConfig,\n GraphDatabaseType,\n ServicePlatformConfig\n} from './config/config.types';\n\n// Version information\nexport const CORE_TYPES_VERSION = '0.1.0';\nexport const SDK_VERSION = '0.1.0';\n"]}
|