@semiont/core 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-assembly.d.ts +54 -0
- package/dist/annotation-assembly.d.ts.map +1 -0
- package/dist/annotation-types.d.ts +30 -0
- package/dist/annotation-types.d.ts.map +1 -0
- package/dist/annotation-utils.d.ts +43 -0
- package/dist/annotation-utils.d.ts.map +1 -0
- package/dist/auth-types.d.ts +8 -0
- package/dist/auth-types.d.ts.map +1 -0
- package/dist/branded-types.d.ts +70 -0
- package/dist/branded-types.d.ts.map +1 -0
- package/dist/bridged-channels.d.ts +18 -0
- package/dist/bridged-channels.d.ts.map +1 -0
- package/dist/bus-log.d.ts +25 -0
- package/dist/bus-log.d.ts.map +1 -0
- package/dist/bus-protocol.d.ts +510 -0
- package/dist/bus-protocol.d.ts.map +1 -0
- package/dist/{config.types-oPv3Ajk-.d.ts → config/config.types.d.ts} +25 -23
- package/dist/config/config.types.d.ts.map +1 -0
- package/dist/config/configuration-error.d.ts +17 -0
- package/dist/config/configuration-error.d.ts.map +1 -0
- package/dist/config/environment-validator.d.ts +28 -0
- package/dist/config/environment-validator.d.ts.map +1 -0
- package/dist/config/node-config-loader.d.ts +4 -74
- package/dist/config/node-config-loader.d.ts.map +1 -0
- package/dist/config/platform-types.d.ts +26 -0
- package/dist/config/platform-types.d.ts.map +1 -0
- package/dist/config/toml-loader.d.ts +59 -0
- package/dist/config/toml-loader.d.ts.map +1 -0
- package/dist/did-utils.d.ts +76 -0
- package/dist/did-utils.d.ts.map +1 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/event-base.d.ts +70 -0
- package/dist/event-base.d.ts.map +1 -0
- package/dist/event-bus.d.ts +141 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-utils.d.ts +43 -0
- package/dist/event-utils.d.ts.map +1 -0
- package/dist/fuzzy-anchor.d.ts +81 -0
- package/dist/fuzzy-anchor.d.ts.map +1 -0
- package/dist/graph.d.ts +44 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/id-generation.d.ts +8 -0
- package/dist/id-generation.d.ts.map +1 -0
- package/dist/identifiers.d.ts +24 -0
- package/dist/identifiers.d.ts.map +1 -0
- package/dist/index.d.ts +59 -6022
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/dist/locales.d.ts +31 -0
- package/dist/locales.d.ts.map +1 -0
- package/dist/logger.d.ts +56 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/mime-utils.d.ts +38 -0
- package/dist/mime-utils.d.ts.map +1 -0
- package/dist/operators/burst-buffer.d.ts +61 -0
- package/dist/operators/burst-buffer.d.ts.map +1 -0
- package/dist/payload-types.d.ts +16 -0
- package/dist/payload-types.d.ts.map +1 -0
- package/dist/persisted-events.d.ts +76 -0
- package/dist/persisted-events.d.ts.map +1 -0
- package/dist/project.d.ts +69 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/resource-types.d.ts +15 -0
- package/dist/resource-types.d.ts.map +1 -0
- package/dist/resource-utils.d.ts +97 -0
- package/dist/resource-utils.d.ts.map +1 -0
- package/dist/serialize-per-key.d.ts +51 -0
- package/dist/serialize-per-key.d.ts.map +1 -0
- package/dist/svg-utils.d.ts +44 -0
- package/dist/svg-utils.d.ts.map +1 -0
- package/dist/tag-schemas.d.ts +27 -0
- package/dist/tag-schemas.d.ts.map +1 -0
- package/dist/text-context.d.ts +85 -0
- package/dist/text-context.d.ts.map +1 -0
- package/dist/text-encoding.d.ts +34 -0
- package/dist/text-encoding.d.ts.map +1 -0
- package/dist/transport.d.ts +274 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/type-guards.d.ts +44 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/types.d.ts +3517 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation.d.ts +57 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/web-annotation-utils.d.ts +154 -0
- package/dist/web-annotation-utils.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale information
|
|
3
|
+
* Copied from SDK for frontend use
|
|
4
|
+
*/
|
|
5
|
+
export interface LocaleInfo {
|
|
6
|
+
code: string;
|
|
7
|
+
nativeName: string;
|
|
8
|
+
englishName: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const LOCALES: readonly LocaleInfo[];
|
|
11
|
+
/**
|
|
12
|
+
* Get locale information by code
|
|
13
|
+
*/
|
|
14
|
+
export declare function getLocaleInfo(code: string | undefined): LocaleInfo | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get the native name of a language by its locale code
|
|
17
|
+
*/
|
|
18
|
+
export declare function getLocaleNativeName(code: string | undefined): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get the English name of a language by its locale code
|
|
21
|
+
*/
|
|
22
|
+
export declare function getLocaleEnglishName(code: string | undefined): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Format locale code for display as "Native Name (code)"
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatLocaleDisplay(code: string | undefined): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get all supported locale codes
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAllLocaleCodes(): readonly string[];
|
|
31
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../src/locales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,UAAU,EA8B/B,CAAC;AAOX;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAG9E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEjF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOhF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,MAAM,EAAE,CAErD"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface for observability
|
|
3
|
+
*
|
|
4
|
+
* This interface is intentionally framework-agnostic to work with any logger
|
|
5
|
+
* (winston, pino, bunyan, or simple console).
|
|
6
|
+
*
|
|
7
|
+
* Example usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import winston from 'winston';
|
|
10
|
+
*
|
|
11
|
+
* const logger = winston.createLogger({
|
|
12
|
+
* level: 'debug',
|
|
13
|
+
* transports: [new winston.transports.Console()]
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const service = new MyService(logger);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface Logger {
|
|
20
|
+
debug(message: string, meta?: any): void;
|
|
21
|
+
info(message: string, meta?: any): void;
|
|
22
|
+
warn(message: string, meta?: any): void;
|
|
23
|
+
error(message: string, meta?: any): void;
|
|
24
|
+
child(meta: Record<string, any>): Logger;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Serialize an error value into a form that JSON.stringify can handle
|
|
28
|
+
* meaningfully.
|
|
29
|
+
*
|
|
30
|
+
* Winston's default JSON formatter serializes `Error` instances as `{}`
|
|
31
|
+
* because `message`, `stack`, and `name` are non-enumerable properties on
|
|
32
|
+
* the Error prototype. That means `logger.error('x', { error })` with a
|
|
33
|
+
* raw Error argument produces useless log lines like
|
|
34
|
+
* `{"error":{},"message":"x",...}`, throwing away the information you
|
|
35
|
+
* actually need to diagnose the failure.
|
|
36
|
+
*
|
|
37
|
+
* This helper extracts the parts you want to see in a log — name,
|
|
38
|
+
* message, stack, and cause — and leaves non-Error values alone (so
|
|
39
|
+
* strings, numbers, and plain objects pass through unchanged).
|
|
40
|
+
*
|
|
41
|
+
* ## Usage
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* try {
|
|
45
|
+
* await doSomething();
|
|
46
|
+
* } catch (error) {
|
|
47
|
+
* logger.error('Something failed', { error: errField(error) });
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Use this at every `logger.error` call site that includes an `error`
|
|
52
|
+
* field derived from a catch block. Raw `{ error }` without this helper
|
|
53
|
+
* is almost always a bug.
|
|
54
|
+
*/
|
|
55
|
+
export declare function errField(error: unknown): unknown;
|
|
56
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUhD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIME type utilities for Semiont
|
|
3
|
+
*
|
|
4
|
+
* Initial support for:
|
|
5
|
+
* - text/plain
|
|
6
|
+
* - text/markdown
|
|
7
|
+
* - image/png
|
|
8
|
+
* - image/jpeg
|
|
9
|
+
* - application/pdf
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Map MIME type to file extension
|
|
13
|
+
*/
|
|
14
|
+
export declare function getExtensionForMimeType(mimeType: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Detect if MIME type is an image (png or jpeg only for now)
|
|
17
|
+
*/
|
|
18
|
+
export declare function isImageMimeType(mimeType: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Detect if MIME type is text-based (plain or markdown only for now)
|
|
21
|
+
*/
|
|
22
|
+
export declare function isTextMimeType(mimeType: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Detect if MIME type is PDF
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPdfMimeType(mimeType: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get category for MIME type (for routing to appropriate viewer)
|
|
29
|
+
*
|
|
30
|
+
* Categories represent annotation models, not file formats:
|
|
31
|
+
* - 'text': Text-based annotations (TextPositionSelector, TextQuoteSelector)
|
|
32
|
+
* - 'image': Spatial coordinate annotations (SvgSelector, FragmentSelector)
|
|
33
|
+
*
|
|
34
|
+
* PDFs use spatial coordinates for annotations, so they belong to 'image' category.
|
|
35
|
+
*/
|
|
36
|
+
export type MimeCategory = 'text' | 'image' | 'unsupported';
|
|
37
|
+
export declare function getMimeCategory(mimeType: string): MimeCategory;
|
|
38
|
+
//# sourceMappingURL=mime-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime-utils.d.ts","sourceRoot":"","sources":["../src/mime-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;AAE5D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAQ9D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive burst buffer RxJS operator.
|
|
3
|
+
*
|
|
4
|
+
* Passes the first event through immediately (zero latency for interactive use).
|
|
5
|
+
* If more events arrive within the burst window, switches to accumulate mode
|
|
6
|
+
* and flushes batches. Returns to passthrough mode after an idle period.
|
|
7
|
+
*
|
|
8
|
+
* Emits individual items (T) in passthrough mode and arrays (T[]) in batch mode.
|
|
9
|
+
* Consumers distinguish via Array.isArray().
|
|
10
|
+
*
|
|
11
|
+
* Threshold tuning:
|
|
12
|
+
* burstWindowMs — How long to wait for more events before flushing a batch.
|
|
13
|
+
* 50ms is a good default: longer than event-loop jitter (~1-5ms)
|
|
14
|
+
* but short enough to feel responsive.
|
|
15
|
+
* maxBatchSize — Force-flush at this size to bound memory. 500 is safe for
|
|
16
|
+
* Neo4j UNWIND queries. Increase if graph writes are cheap.
|
|
17
|
+
* idleTimeoutMs — How long after the last flush before returning to passthrough.
|
|
18
|
+
* 200ms is a good default. Must be >= burstWindowMs.
|
|
19
|
+
*
|
|
20
|
+
* See: BATCH-GRAPH-CONSUMER-RX.md for design rationale.
|
|
21
|
+
* See: packages/graph/docs/ARCHITECTURE.md for graph consumer context.
|
|
22
|
+
*/
|
|
23
|
+
import { OperatorFunction } from 'rxjs';
|
|
24
|
+
export interface BurstBufferOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Time window (ms) to detect burst activity after an event.
|
|
27
|
+
* If another event arrives within this window, it is buffered.
|
|
28
|
+
* The buffer flushes when no new event arrives for this duration (debounce).
|
|
29
|
+
*
|
|
30
|
+
* Recommended: 50ms.
|
|
31
|
+
*/
|
|
32
|
+
burstWindowMs: number;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum events to accumulate before forcing a flush.
|
|
35
|
+
* Prevents unbounded memory growth during sustained bursts.
|
|
36
|
+
*
|
|
37
|
+
* Recommended: 500.
|
|
38
|
+
*/
|
|
39
|
+
maxBatchSize: number;
|
|
40
|
+
/**
|
|
41
|
+
* Time (ms) of silence after the last flush before returning to passthrough mode.
|
|
42
|
+
* The next event after this timeout emits immediately (leading edge).
|
|
43
|
+
* Must be >= burstWindowMs.
|
|
44
|
+
*
|
|
45
|
+
* Recommended: 200ms.
|
|
46
|
+
*/
|
|
47
|
+
idleTimeoutMs: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Adaptive burst buffer operator.
|
|
51
|
+
*
|
|
52
|
+
* State machine:
|
|
53
|
+
* PASSTHROUGH → event arrives → emit immediately, transition to ACCUMULATING
|
|
54
|
+
* ACCUMULATING → event arrives → buffer it, reset burst timer
|
|
55
|
+
* ACCUMULATING → burst timer fires (no new events for burstWindowMs) → flush buffer as T[]
|
|
56
|
+
* ACCUMULATING → buffer reaches maxBatchSize → flush buffer as T[]
|
|
57
|
+
* After flush → idle timer starts
|
|
58
|
+
* Idle timer fires (no new events for idleTimeoutMs) → transition to PASSTHROUGH
|
|
59
|
+
*/
|
|
60
|
+
export declare function burstBuffer<T>(options: BurstBufferOptions): OperatorFunction<T, T | T[]>;
|
|
61
|
+
//# sourceMappingURL=burst-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"burst-buffer.d.ts","sourceRoot":"","sources":["../../src/operators/burst-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAc,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,gBAAgB,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAmG9B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload Type Aliases
|
|
3
|
+
*
|
|
4
|
+
* Convenience aliases for OpenAPI-generated schema types that are
|
|
5
|
+
* referenced across the codebase. Shorter than
|
|
6
|
+
* `components['schemas']['<Name>']` and carry intent.
|
|
7
|
+
*
|
|
8
|
+
* These aliases are not about the bus. They live here so that
|
|
9
|
+
* bus-protocol.ts can focus on channel-protocol concerns (EventMap,
|
|
10
|
+
* CHANNEL_SCHEMAS, scope classification).
|
|
11
|
+
*/
|
|
12
|
+
import type { components } from './types';
|
|
13
|
+
export type Selector = components['schemas']['TextPositionSelector'] | components['schemas']['TextQuoteSelector'] | components['schemas']['SvgSelector'] | components['schemas']['FragmentSelector'];
|
|
14
|
+
export type GatheredContext = components['schemas']['GatheredContext'];
|
|
15
|
+
export type SelectionData = components['schemas']['SelectionData'];
|
|
16
|
+
//# sourceMappingURL=payload-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-types.d.ts","sourceRoot":"","sources":["../src/payload-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAChB,UAAU,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,GAC7C,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,GAC1C,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,GACpC,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC,CAAC;AACvE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisted Events
|
|
3
|
+
*
|
|
4
|
+
* The 18 event types that get appended to the JSONL event log.
|
|
5
|
+
* Each maps a type string to its OpenAPI payload schema.
|
|
6
|
+
* The PersistedEvent union derives from this catalog.
|
|
7
|
+
*/
|
|
8
|
+
import type { components } from './types';
|
|
9
|
+
import type { AnnotationId, ResourceId } from './identifiers';
|
|
10
|
+
import type { Annotation } from './annotation-types';
|
|
11
|
+
import type { EventBase } from './event-base';
|
|
12
|
+
type AnnotationAddedPayload = components['schemas']['AnnotationAddedPayload'] & {
|
|
13
|
+
annotation: Annotation;
|
|
14
|
+
};
|
|
15
|
+
type AnnotationRemovedPayload = components['schemas']['AnnotationRemovedPayload'] & {
|
|
16
|
+
annotationId: AnnotationId;
|
|
17
|
+
};
|
|
18
|
+
type AnnotationBodyUpdatedPayload = components['schemas']['AnnotationBodyUpdatedPayload'] & {
|
|
19
|
+
annotationId: AnnotationId;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Maps each persisted event type string to its OpenAPI payload schema.
|
|
23
|
+
* Single source of truth for "what events get written to the log."
|
|
24
|
+
*/
|
|
25
|
+
type PersistedEventCatalog = {
|
|
26
|
+
'yield:created': components['schemas']['ResourceCreatedPayload'];
|
|
27
|
+
'yield:cloned': components['schemas']['ResourceClonedPayload'];
|
|
28
|
+
'yield:updated': components['schemas']['ResourceUpdatedPayload'];
|
|
29
|
+
'yield:moved': components['schemas']['ResourceMovedPayload'];
|
|
30
|
+
'yield:representation-added': components['schemas']['RepresentationAddedPayload'];
|
|
31
|
+
'yield:representation-removed': components['schemas']['RepresentationRemovedPayload'];
|
|
32
|
+
'mark:added': AnnotationAddedPayload;
|
|
33
|
+
'mark:removed': AnnotationRemovedPayload;
|
|
34
|
+
'mark:body-updated': AnnotationBodyUpdatedPayload;
|
|
35
|
+
'mark:archived': components['schemas']['ResourceArchivedPayload'];
|
|
36
|
+
'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
|
|
37
|
+
'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
|
|
38
|
+
'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
|
|
39
|
+
'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
|
|
40
|
+
'frame:tag-schema-added': components['schemas']['TagSchemaAddedPayload'];
|
|
41
|
+
'job:started': components['schemas']['JobStartedPayload'];
|
|
42
|
+
'job:progress': components['schemas']['JobProgressPayload'];
|
|
43
|
+
'job:completed': components['schemas']['JobCompletedPayload'];
|
|
44
|
+
'job:failed': components['schemas']['JobFailedPayload'];
|
|
45
|
+
};
|
|
46
|
+
/** System event types — persisted events that have no resourceId. */
|
|
47
|
+
type SystemEventType = 'frame:entity-type-added' | 'frame:tag-schema-added';
|
|
48
|
+
/** Extract the concrete persisted event type for a given type string. */
|
|
49
|
+
export type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
|
|
50
|
+
type: K;
|
|
51
|
+
payload: PersistedEventCatalog[K];
|
|
52
|
+
} : EventBase & {
|
|
53
|
+
type: K;
|
|
54
|
+
resourceId: ResourceId;
|
|
55
|
+
payload: PersistedEventCatalog[K];
|
|
56
|
+
};
|
|
57
|
+
/** The union of all 20 persisted event types. Discriminated on `type`. */
|
|
58
|
+
export type PersistedEvent = {
|
|
59
|
+
[K in keyof PersistedEventCatalog]: EventOfType<K>;
|
|
60
|
+
}[keyof PersistedEventCatalog];
|
|
61
|
+
export type PersistedEventType = PersistedEvent['type'];
|
|
62
|
+
/**
|
|
63
|
+
* Runtime list of every persisted event type.
|
|
64
|
+
*
|
|
65
|
+
* Single source of truth for code that needs to enumerate event types at
|
|
66
|
+
* runtime — most importantly the per-resource `events-stream` SSE route,
|
|
67
|
+
* which subscribes to all of them. The exhaustiveness check below makes
|
|
68
|
+
* it impossible to add a new member to `PersistedEventCatalog` without
|
|
69
|
+
* also adding it here: forgetting fails to typecheck rather than silently
|
|
70
|
+
* dropping the event from the events-stream.
|
|
71
|
+
*/
|
|
72
|
+
export declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "frame:entity-type-added", "frame:tag-schema-added", "job:started", "job:progress", "job:completed", "job:failed"];
|
|
73
|
+
/** Input type for appendEvent — PersistedEvent without id/timestamp (assigned at persistence time). */
|
|
74
|
+
export type EventInput = Omit<PersistedEvent, 'id' | 'timestamp'>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=persisted-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persisted-events.d.ts","sourceRoot":"","sources":["../src/persisted-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,UA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C,cAAc,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Semiont project rooted at a given directory.
|
|
3
|
+
*
|
|
4
|
+
* Computes all paths — durable and ephemeral — once at construction time.
|
|
5
|
+
* XDG environment variables are read here and nowhere else.
|
|
6
|
+
*
|
|
7
|
+
* Durable paths (inside the project root, committed or repo-local):
|
|
8
|
+
* eventsDir — .semiont/events/ (system of record, committed)
|
|
9
|
+
* representationsDir — representations/ (content store, committed)
|
|
10
|
+
*
|
|
11
|
+
* Ephemeral paths (outside the project root, never committed):
|
|
12
|
+
* configDir — $XDG_CONFIG_HOME/semiont/{name}/ (generated config for managed processes)
|
|
13
|
+
* dataHome — $XDG_DATA_HOME/semiont/{name}/ (persistent user data, e.g. database files)
|
|
14
|
+
* stateDir — $XDG_STATE_HOME/semiont/{name}/
|
|
15
|
+
* embeddingsDir — stateDir/embeddings/
|
|
16
|
+
* projectionsDir — stateDir/projections/
|
|
17
|
+
* jobsDir — stateDir/jobs/
|
|
18
|
+
* backendLogsDir — stateDir/backend/
|
|
19
|
+
* backendAppLogFile — backendLogsDir/app.log
|
|
20
|
+
* backendErrorLogFile — backendLogsDir/error.log
|
|
21
|
+
* runtimeDir — $XDG_RUNTIME_DIR/semiont/{name}/ (or $TMPDIR fallback)
|
|
22
|
+
* backendPidFile — runtimeDir/backend.pid
|
|
23
|
+
*
|
|
24
|
+
* Note: frontend paths are NOT project-scoped. The frontend service is bundled
|
|
25
|
+
* with the CLI and uses fixed XDG paths keyed by "frontend", not project name.
|
|
26
|
+
* See apps/cli/src/platforms/posix/handlers/frontend-paths.ts.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SemiontProject {
|
|
29
|
+
readonly root: string;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/** True if [git] sync = true in .semiont/config. When true, semiont stages
|
|
32
|
+
* working-tree and event-log changes in the git index automatically. */
|
|
33
|
+
readonly gitSync: boolean;
|
|
34
|
+
readonly eventsDir: string;
|
|
35
|
+
readonly representationsDir: string;
|
|
36
|
+
readonly configDir: string;
|
|
37
|
+
readonly dataHome: string;
|
|
38
|
+
readonly stateDir: string;
|
|
39
|
+
readonly embeddingsDir: string;
|
|
40
|
+
readonly projectionsDir: string;
|
|
41
|
+
readonly jobsDir: string;
|
|
42
|
+
readonly backendLogsDir: string;
|
|
43
|
+
readonly backendAppLogFile: string;
|
|
44
|
+
readonly backendErrorLogFile: string;
|
|
45
|
+
readonly runtimeDir: string;
|
|
46
|
+
readonly backendPidFile: string;
|
|
47
|
+
constructor(projectRoot: string, name?: string);
|
|
48
|
+
/**
|
|
49
|
+
* Read the current git branch for the project root.
|
|
50
|
+
* Returns null if the project is not a git repo or git is not available.
|
|
51
|
+
*/
|
|
52
|
+
gitBranch(): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Delete all ephemeral state for this project (stateDir + runtimeDir).
|
|
55
|
+
* Does not touch eventsDir or dataDir.
|
|
56
|
+
*/
|
|
57
|
+
destroy(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Read [git] sync from .semiont/config.
|
|
60
|
+
* Defaults to false if the section or key is absent.
|
|
61
|
+
*/
|
|
62
|
+
private static readGitSync;
|
|
63
|
+
/**
|
|
64
|
+
* Read the project name from .semiont/config [project] name = "..."
|
|
65
|
+
* Falls back to the directory basename if the config is absent or has no name.
|
|
66
|
+
*/
|
|
67
|
+
private static readName;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;6EACyE;IACzE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAG1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAGpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAG3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAG1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAGrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBAEpB,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAoC9C;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAY1B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;CAcxB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource input/output types
|
|
3
|
+
*/
|
|
4
|
+
export interface UpdateResourceInput {
|
|
5
|
+
name?: string;
|
|
6
|
+
entityTypes?: string[];
|
|
7
|
+
archived?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ResourceFilter {
|
|
10
|
+
entityTypes?: string[];
|
|
11
|
+
search?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=resource-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-types.d.ts","sourceRoot":"","sources":["../src/resource-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for working with W3C ResourceDescriptor
|
|
3
|
+
*/
|
|
4
|
+
import type { components } from './types';
|
|
5
|
+
import type { ResourceDescriptor } from './graph';
|
|
6
|
+
type Representation = components['schemas']['Representation'];
|
|
7
|
+
/**
|
|
8
|
+
* Get the resource ID from @id property
|
|
9
|
+
*
|
|
10
|
+
* @id is always a bare ID (UUID), never a full URI.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getResourceId(resource: ResourceDescriptor | undefined): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Get the primary representation (first or only representation)
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPrimaryRepresentation(resource: ResourceDescriptor | undefined): Representation | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get the media type from the primary representation
|
|
19
|
+
*/
|
|
20
|
+
export declare function getPrimaryMediaType(resource: ResourceDescriptor | undefined): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Get the checksum from the primary representation
|
|
23
|
+
*/
|
|
24
|
+
export declare function getChecksum(resource: ResourceDescriptor | undefined): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Get the language from the primary representation
|
|
27
|
+
*/
|
|
28
|
+
export declare function getLanguage(resource: ResourceDescriptor | undefined): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get storage URI from primary representation
|
|
31
|
+
*
|
|
32
|
+
* @param resource - ResourceDescriptor
|
|
33
|
+
* @returns Storage URI or undefined
|
|
34
|
+
*/
|
|
35
|
+
export declare function getStorageUri(resource: ResourceDescriptor | undefined): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Get creator agent from wasAttributedTo
|
|
38
|
+
* Handles both single agent and array of agents
|
|
39
|
+
*
|
|
40
|
+
* @param resource - ResourceDescriptor
|
|
41
|
+
* @returns First agent or undefined
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCreator(resource: ResourceDescriptor | undefined): components['schemas']['Agent'] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get derived-from URI
|
|
46
|
+
* Handles both single URI and array of URIs
|
|
47
|
+
*
|
|
48
|
+
* @param resource - ResourceDescriptor
|
|
49
|
+
* @returns First derivation URI or undefined
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDerivedFrom(resource: ResourceDescriptor | undefined): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Check if resource is archived (application-specific field)
|
|
54
|
+
*
|
|
55
|
+
* @param resource - ResourceDescriptor
|
|
56
|
+
* @returns True if archived, false otherwise
|
|
57
|
+
*/
|
|
58
|
+
export declare function isArchived(resource: ResourceDescriptor | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get entity types from resource (application-specific field)
|
|
61
|
+
*
|
|
62
|
+
* @param resource - ResourceDescriptor
|
|
63
|
+
* @returns Array of entity types, empty if not set
|
|
64
|
+
*/
|
|
65
|
+
export declare function getResourceEntityTypes(resource: ResourceDescriptor | undefined): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Check if resource is a draft (application-specific field)
|
|
68
|
+
*
|
|
69
|
+
* @param resource - ResourceDescriptor
|
|
70
|
+
* @returns True if draft, false otherwise
|
|
71
|
+
*/
|
|
72
|
+
export declare function isDraft(resource: ResourceDescriptor | undefined): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Map charset names to Node.js Buffer encoding names
|
|
75
|
+
* Node.js Buffer.toString() supports: 'utf8', 'utf16le', 'latin1', 'base64', 'hex', 'ascii', 'binary', 'ucs2'
|
|
76
|
+
*
|
|
77
|
+
* @param charset - Charset name (e.g., "UTF-8", "ISO-8859-1", "Windows-1252")
|
|
78
|
+
* @returns Node.js BufferEncoding
|
|
79
|
+
*/
|
|
80
|
+
export declare function getNodeEncoding(charset: string): BufferEncoding;
|
|
81
|
+
/**
|
|
82
|
+
* Decode a representation buffer to string using the correct charset
|
|
83
|
+
* Extracts charset from media type and uses appropriate encoding
|
|
84
|
+
*
|
|
85
|
+
* @param buffer - The raw representation data
|
|
86
|
+
* @param mediaType - Media type with optional charset (e.g., "text/plain; charset=iso-8859-1")
|
|
87
|
+
* @returns Decoded string
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const content = decodeRepresentation(buffer, "text/plain; charset=utf-8");
|
|
92
|
+
* const legacy = decodeRepresentation(buffer, "text/plain; charset=windows-1252");
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function decodeRepresentation(buffer: Buffer, mediaType: string): string;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=resource-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../src/resource-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,KAAK,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,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E,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAS9E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* serializePerKey — run async work serialized per key, parallel across keys.
|
|
3
|
+
*
|
|
4
|
+
* Invariant: two calls with the same `key` run strictly in sequence (the
|
|
5
|
+
* second `work` does not start until the first has settled). Calls with
|
|
6
|
+
* different keys overlap freely.
|
|
7
|
+
*
|
|
8
|
+
* Error isolation: a rejected work function does not poison subsequent
|
|
9
|
+
* tasks for the same key. The next task starts fresh from whatever state
|
|
10
|
+
* the failed task left behind. The rejection still propagates to *this*
|
|
11
|
+
* caller.
|
|
12
|
+
*
|
|
13
|
+
* Registry cleanup: the entry for a key is removed as soon as its chain
|
|
14
|
+
* empties, so the Map stays bounded by the number of keys with work
|
|
15
|
+
* currently in flight, not by the total number of keys ever seen.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const chains = new Map<string, Promise<void>>();
|
|
21
|
+
*
|
|
22
|
+
* async function write(resourceId: string, event: Event) {
|
|
23
|
+
* return serializePerKey(resourceId, chains, async () => {
|
|
24
|
+
* // Read-modify-write on a view file. Any two concurrent calls with
|
|
25
|
+
* // the same resourceId will be serialized; different resourceIds
|
|
26
|
+
* // will proceed in parallel.
|
|
27
|
+
* const view = await viewStorage.get(resourceId);
|
|
28
|
+
* applyEvent(view, event);
|
|
29
|
+
* await viewStorage.save(resourceId, view);
|
|
30
|
+
* });
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## When to use this vs RxJS `groupBy + concatMap`
|
|
35
|
+
*
|
|
36
|
+
* Use `serializePerKey` when the work arrives as **direct method calls**
|
|
37
|
+
* that need to block the caller until completion. This is the RPC shape
|
|
38
|
+
* — think `EventStore.appendEvent` calling `await views.materializeResource(...)`
|
|
39
|
+
* and needing the view written before any subscriber sees the published
|
|
40
|
+
* event.
|
|
41
|
+
*
|
|
42
|
+
* Use RxJS `groupBy(keyFn) + concatMap(...)` when the work arrives as an
|
|
43
|
+
* **event stream** that a component subscribes to once at startup. This
|
|
44
|
+
* is how `Smelter`, `GraphDBConsumer`, and `Gatherer` serialize their own
|
|
45
|
+
* per-resource work — see their implementations in `packages/make-meaning`.
|
|
46
|
+
*
|
|
47
|
+
* Both patterns solve the same logical problem ("serialize work per key").
|
|
48
|
+
* The choice is dictated by whether the caller is awaiting the result.
|
|
49
|
+
*/
|
|
50
|
+
export declare function serializePerKey<K, T>(key: K, chains: Map<K, Promise<void>>, work: () => Promise<T>): Promise<T>;
|
|
51
|
+
//# sourceMappingURL=serialize-per-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-per-key.d.ts","sourceRoot":"","sources":["../src/serialize-per-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,CAAC,EACxC,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Utilities for creating, parsing, and manipulating W3C-compliant SVG selectors
|
|
5
|
+
* for image annotation.
|
|
6
|
+
*/
|
|
7
|
+
export interface Point {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
export interface BoundingBox {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create W3C-compliant SVG rectangle selector
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRectangleSvg(start: Point, end: Point): string;
|
|
21
|
+
/**
|
|
22
|
+
* Create W3C-compliant SVG polygon selector
|
|
23
|
+
*/
|
|
24
|
+
export declare function createPolygonSvg(points: Point[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Create W3C-compliant SVG circle selector
|
|
27
|
+
*/
|
|
28
|
+
export declare function createCircleSvg(center: Point, radius: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parse SVG selector to extract shape type and data
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseSvgSelector(svg: string): {
|
|
33
|
+
type: 'rect' | 'polygon' | 'circle' | 'path';
|
|
34
|
+
data: any;
|
|
35
|
+
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Normalize coordinates from display space to image native resolution
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeCoordinates(point: Point, displayWidth: number, displayHeight: number, imageWidth: number, imageHeight: number): Point;
|
|
40
|
+
/**
|
|
41
|
+
* Scale entire SVG selector from display space to image native resolution
|
|
42
|
+
*/
|
|
43
|
+
export declare function scaleSvgToNative(svg: string, displayWidth: number, displayHeight: number, imageWidth: number, imageHeight: number): string;
|
|
44
|
+
//# sourceMappingURL=svg-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-utils.d.ts","sourceRoot":"","sources":["../src/svg-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,CAOnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAOxD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAC7C,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC7C,IAAI,EAAE,GAAG,CAAC;CACX,GAAG,IAAI,CA8CP;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,KAAK,CAKP;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAkCR"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tag-schema type aliases.
|
|
3
|
+
*
|
|
4
|
+
* These are type-only re-exports of the OpenAPI `TagSchema` and `TagCategory`
|
|
5
|
+
* shapes. The schemas themselves do not live in `@semiont/core` — they're
|
|
6
|
+
* registered at runtime per-KB via `frame.addTagSchema(...)` against a
|
|
7
|
+
* per-KB projection. This module just exposes the shape so KB authors and
|
|
8
|
+
* skill code can type their schema literals without the OpenAPI lookup
|
|
9
|
+
* syntax (`components['schemas']['TagSchema']`).
|
|
10
|
+
*/
|
|
11
|
+
import type { components } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* A structural-analysis schema (e.g. legal-irac, scientific-imrad).
|
|
14
|
+
*
|
|
15
|
+
* Defines a methodology framework as an id, name, description, domain hint,
|
|
16
|
+
* and an ordered list of categories. KBs and their skills register schemas
|
|
17
|
+
* with the runtime registry via `frame.addTagSchema(...)` at session start.
|
|
18
|
+
*/
|
|
19
|
+
export type TagSchema = components['schemas']['TagSchema'];
|
|
20
|
+
/**
|
|
21
|
+
* A single category within a {@link TagSchema} (e.g. 'Issue' in IRAC).
|
|
22
|
+
*
|
|
23
|
+
* Each category carries methodology-bound semantics: a name, a description,
|
|
24
|
+
* and examples used in the LLM prompt.
|
|
25
|
+
*/
|
|
26
|
+
export type TagCategory = components['schemas']['TagCategory'];
|
|
27
|
+
//# sourceMappingURL=tag-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-schemas.d.ts","sourceRoot":"","sources":["../src/tag-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC"}
|