@frontal-labs/ontology 0.0.1 → 1.0.0

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/src/sdk.ts ADDED
@@ -0,0 +1,883 @@
1
+ import {
2
+ asPagePayload,
3
+ createPageResult,
4
+ type HttpClient,
5
+ type PageResult,
6
+ } from "@frontal-labs/core";
7
+
8
+ /**
9
+ * Client for the Frontal OntologySdk API (`/v1/ontology/*`).
10
+ *
11
+ * The ontology platform is composed of independent subdomain services that
12
+ * share a common envelope (`capabilities`, `health`, `info`, and asynchronous
13
+ * `runs`). Each subdomain is exposed as a namespace on {@link OntologySdk}.
14
+ * The `graph` subdomain is served by the dedicated `@frontal-labs/graph`
15
+ * package and is intentionally not duplicated here.
16
+ *
17
+ * Paths are written without the leading `/v1` because the client base URL
18
+ * already includes it.
19
+ */
20
+ export class OntologySdk {
21
+ readonly engine: EngineNamespace;
22
+ readonly objects: ObjectsNamespace;
23
+ readonly relationships: RelationshipsNamespace;
24
+ readonly schemas: SchemasNamespace;
25
+ readonly versions: VersionsNamespace;
26
+ readonly validation: ValidationNamespace;
27
+ readonly transformations: TransformationsNamespace;
28
+ readonly reasoning: ReasoningNamespace;
29
+ readonly rollouts: RolloutsNamespace;
30
+ readonly rollups: RollupsNamespace;
31
+ readonly extract: ExtractNamespace;
32
+ readonly events: EventsNamespace;
33
+
34
+ /**
35
+ * @param http - The HTTP client used to make API requests.
36
+ */
37
+ constructor(http: HttpClient) {
38
+ this.engine = new EngineNamespace(http);
39
+ this.objects = new ObjectsNamespace(http);
40
+ this.relationships = new RelationshipsNamespace(http);
41
+ this.schemas = new SchemasNamespace(http);
42
+ this.versions = new VersionsNamespace(http);
43
+ this.validation = new ValidationNamespace(http);
44
+ this.transformations = new TransformationsNamespace(http);
45
+ this.reasoning = new ReasoningNamespace(http);
46
+ this.rollouts = new RolloutsNamespace(http);
47
+ this.rollups = new RollupsNamespace(http);
48
+ this.extract = new ExtractNamespace(http);
49
+ this.events = new EventsNamespace(http);
50
+ }
51
+ }
52
+
53
+ /** Generic request body type for API calls. */
54
+ type Body = Record<string, unknown>;
55
+
56
+ /** Options for paginated list operations. */
57
+ interface ListOpts {
58
+ limit?: number;
59
+ cursor?: string;
60
+ [key: string]: unknown;
61
+ }
62
+
63
+ /**
64
+ * Shared behaviour for every ontology subdomain: capability/health/info probes
65
+ * and the asynchronous `runs` collection.
66
+ */
67
+ /**
68
+ * Shared base class for every ontology subdomain namespace.
69
+ * Provides capability/health/info probes and async run management.
70
+ */
71
+ abstract class SubdomainBase {
72
+ protected constructor(
73
+ protected readonly http: HttpClient,
74
+ protected readonly base: string
75
+ ) {}
76
+
77
+ /**
78
+ * Returns the capabilities of this subdomain service.
79
+ */
80
+ capabilities(): Promise<Record<string, unknown>> {
81
+ return this.http.get(`${this.base}/capabilities`);
82
+ }
83
+ /**
84
+ * Health check for this subdomain service.
85
+ */
86
+ health(): Promise<Record<string, unknown>> {
87
+ return this.http.get(`${this.base}/health`);
88
+ }
89
+ /**
90
+ * Returns service info/metadata for this subdomain service.
91
+ */
92
+ info(): Promise<Record<string, unknown>> {
93
+ return this.http.get(`${this.base}/info`);
94
+ }
95
+
96
+ /**
97
+ * Lists asynchronous runs for this subdomain.
98
+ * @param opts - Pagination options.
99
+ */
100
+ async runs(
101
+ opts: ListOpts = {}
102
+ ): Promise<PageResult<Record<string, unknown>>> {
103
+ const raw = await this.http.get(`${this.base}/runs`, opts);
104
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
105
+ this.runs({ ...opts, cursor: c })
106
+ );
107
+ }
108
+ /**
109
+ * Creates a new asynchronous run.
110
+ * @param input - The run input payload.
111
+ */
112
+ createRun(input: Body): Promise<Record<string, unknown>> {
113
+ return this.http.post(`${this.base}/runs`, input);
114
+ }
115
+ /**
116
+ * Fetches an asynchronous run by ID.
117
+ * @param runId - The run ID.
118
+ */
119
+ run(runId: string): Promise<Record<string, unknown>> {
120
+ return this.http.get(`${this.base}/runs/${runId}`);
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Engine subdomain: ontology generation, validation, export, and inference.
126
+ */
127
+ export class EngineNamespace extends SubdomainBase {
128
+ constructor(http: HttpClient) {
129
+ super(http, "/ontology/engine");
130
+ }
131
+ /**
132
+ * Generates an ontology from a description.
133
+ * @param input - Generation parameters.
134
+ */
135
+ generate(input: Body): Promise<Record<string, unknown>> {
136
+ return this.http.post("/ontology/engine/ontologies/generate", input);
137
+ }
138
+ /**
139
+ * Validates an ontology definition.
140
+ * @param input - The ontology to validate.
141
+ */
142
+ validate(input: Body): Promise<Record<string, unknown>> {
143
+ return this.http.post("/ontology/engine/ontologies/validate", input);
144
+ }
145
+ /**
146
+ * Exports an ontology in a standard format.
147
+ * @param input - Export parameters.
148
+ */
149
+ export(input: Body): Promise<Record<string, unknown>> {
150
+ return this.http.post("/ontology/engine/ontologies/export", input);
151
+ }
152
+ /**
153
+ * Exports an ontology as SHACL shapes.
154
+ * @param input - Export parameters.
155
+ */
156
+ exportShacl(input: Body): Promise<Record<string, unknown>> {
157
+ return this.http.post("/ontology/engine/ontologies/export-shacl", input);
158
+ }
159
+ /**
160
+ * Infers class definitions from source data.
161
+ * @param input - Inference parameters.
162
+ */
163
+ inferClasses(input: Body): Promise<Record<string, unknown>> {
164
+ return this.http.post("/ontology/engine/ontologies/infer-classes", input);
165
+ }
166
+ /**
167
+ * Infers property definitions from source data.
168
+ * @param input - Inference parameters.
169
+ */
170
+ inferProperties(input: Body): Promise<Record<string, unknown>> {
171
+ return this.http.post(
172
+ "/ontology/engine/ontologies/infer-properties",
173
+ input
174
+ );
175
+ }
176
+ /**
177
+ * Compares two ontology versions.
178
+ * @param input - Comparison parameters (fromVersion, toVersion).
179
+ */
180
+ compareVersions(input: Body): Promise<Record<string, unknown>> {
181
+ return this.http.post(
182
+ "/ontology/engine/ontologies/compare-versions",
183
+ input
184
+ );
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Objects subdomain: CRUD for object types and object instances.
190
+ */
191
+ export class ObjectsNamespace extends SubdomainBase {
192
+ constructor(http: HttpClient) {
193
+ super(http, "/ontology/objects");
194
+ }
195
+ /**
196
+ * Lists object types with pagination.
197
+ * @param opts - Pagination options.
198
+ */
199
+ async listObjectTypes(
200
+ opts: ListOpts = {}
201
+ ): Promise<PageResult<Record<string, unknown>>> {
202
+ const raw = await this.http.get("/ontology/objects/object-types", opts);
203
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
204
+ this.listObjectTypes({ ...opts, cursor: c })
205
+ );
206
+ }
207
+ /**
208
+ * Fetches an object type by ID.
209
+ * @param id - The object type ID.
210
+ */
211
+ getObjectType(id: string): Promise<Record<string, unknown>> {
212
+ return this.http.get(`/ontology/objects/object-types/${id}`);
213
+ }
214
+ /**
215
+ * Creates or updates an object type.
216
+ * @param id - The object type ID.
217
+ * @param body - The object type definition.
218
+ */
219
+ putObjectType(id: string, body: Body): Promise<Record<string, unknown>> {
220
+ return this.http.put(`/ontology/objects/object-types/${id}`, body);
221
+ }
222
+ /**
223
+ * Deletes an object type.
224
+ * @param id - The object type ID.
225
+ */
226
+ deleteObjectType(id: string): Promise<void> {
227
+ return this.http.delete(`/ontology/objects/object-types/${id}`);
228
+ }
229
+ /**
230
+ * Lists object instances with pagination.
231
+ * @param opts - Pagination options.
232
+ */
233
+ async listObjects(
234
+ opts: ListOpts = {}
235
+ ): Promise<PageResult<Record<string, unknown>>> {
236
+ const raw = await this.http.get("/ontology/objects/objects", opts);
237
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
238
+ this.listObjects({ ...opts, cursor: c })
239
+ );
240
+ }
241
+ /**
242
+ * Fetches an object instance by ID.
243
+ * @param id - The object ID.
244
+ */
245
+ getObject(id: string): Promise<Record<string, unknown>> {
246
+ return this.http.get(`/ontology/objects/objects/${id}`);
247
+ }
248
+ /**
249
+ * Creates or updates an object instance.
250
+ * @param id - The object ID.
251
+ * @param body - The object data.
252
+ */
253
+ putObject(id: string, body: Body): Promise<Record<string, unknown>> {
254
+ return this.http.put(`/ontology/objects/objects/${id}`, body);
255
+ }
256
+ /**
257
+ * Deletes an object instance.
258
+ * @param id - The object ID.
259
+ */
260
+ deleteObject(id: string): Promise<void> {
261
+ return this.http.delete(`/ontology/objects/objects/${id}`);
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Relationships subdomain: CRUD for relationship types and instances.
267
+ */
268
+ export class RelationshipsNamespace extends SubdomainBase {
269
+ constructor(http: HttpClient) {
270
+ super(http, "/ontology/relationships");
271
+ }
272
+ /**
273
+ * Lists relationship types with pagination.
274
+ * @param opts - Pagination options.
275
+ */
276
+ async listTypes(
277
+ opts: ListOpts = {}
278
+ ): Promise<PageResult<Record<string, unknown>>> {
279
+ const raw = await this.http.get(
280
+ "/ontology/relationships/relationship-types",
281
+ opts
282
+ );
283
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
284
+ this.listTypes({ ...opts, cursor: c })
285
+ );
286
+ }
287
+ /**
288
+ * Deletes a relationship type.
289
+ * @param id - The relationship type ID.
290
+ */
291
+ deleteType(id: string): Promise<void> {
292
+ return this.http.delete(`/ontology/relationships/relationship-types/${id}`);
293
+ }
294
+ /**
295
+ * Lists relationship instances with pagination.
296
+ * @param opts - Pagination options.
297
+ */
298
+ async list(
299
+ opts: ListOpts = {}
300
+ ): Promise<PageResult<Record<string, unknown>>> {
301
+ const raw = await this.http.get(
302
+ "/ontology/relationships/relationships",
303
+ opts
304
+ );
305
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
306
+ this.list({ ...opts, cursor: c })
307
+ );
308
+ }
309
+ /**
310
+ * Fetches a relationship instance by ID.
311
+ * @param id - The relationship ID.
312
+ */
313
+ get(id: string): Promise<Record<string, unknown>> {
314
+ return this.http.get(`/ontology/relationships/relationships/${id}`);
315
+ }
316
+ /**
317
+ * Creates or updates a relationship instance.
318
+ * @param id - The relationship ID.
319
+ * @param body - The relationship data.
320
+ */
321
+ put(id: string, body: Body): Promise<Record<string, unknown>> {
322
+ return this.http.put(`/ontology/relationships/relationships/${id}`, body);
323
+ }
324
+ /**
325
+ * Deletes a relationship instance.
326
+ * @param id - The relationship ID.
327
+ */
328
+ delete(id: string): Promise<void> {
329
+ return this.http.delete(`/ontology/relationships/relationships/${id}`);
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Schemas subdomain: manage schema (model) definitions.
335
+ */
336
+ export class SchemasNamespace extends SubdomainBase {
337
+ constructor(http: HttpClient) {
338
+ super(http, "/ontology/schemas");
339
+ }
340
+ /**
341
+ * Lists schema definitions with pagination.
342
+ * @param opts - Pagination options.
343
+ */
344
+ async list(
345
+ opts: ListOpts = {}
346
+ ): Promise<PageResult<Record<string, unknown>>> {
347
+ const raw = await this.http.get("/ontology/schemas/schemas", opts);
348
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
349
+ this.list({ ...opts, cursor: c })
350
+ );
351
+ }
352
+ /**
353
+ * Creates a new schema definition.
354
+ * @param body - The schema definition.
355
+ */
356
+ create(body: Body): Promise<Record<string, unknown>> {
357
+ return this.http.post("/ontology/schemas/schemas", body);
358
+ }
359
+ /**
360
+ * Validates a schema definition.
361
+ * @param body - The schema to validate.
362
+ */
363
+ validate(body: Body): Promise<Record<string, unknown>> {
364
+ return this.http.post("/ontology/schemas/schemas/validate", body);
365
+ }
366
+ /**
367
+ * Fetches a schema definition by ID.
368
+ * @param id - The schema ID.
369
+ */
370
+ get(id: string): Promise<Record<string, unknown>> {
371
+ return this.http.get(`/ontology/schemas/schemas/${id}`);
372
+ }
373
+ /**
374
+ * Deletes a schema definition.
375
+ * @param id - The schema ID.
376
+ */
377
+ delete(id: string): Promise<void> {
378
+ return this.http.delete(`/ontology/schemas/schemas/${id}`);
379
+ }
380
+ }
381
+
382
+ /**
383
+ * Versions subdomain: version management, comparison, and release bundles.
384
+ */
385
+ export class VersionsNamespace extends SubdomainBase {
386
+ constructor(http: HttpClient) {
387
+ super(http, "/ontology/versions");
388
+ }
389
+ /**
390
+ * Creates a new version.
391
+ * @param body - Version creation payload.
392
+ */
393
+ create(body: Body): Promise<Record<string, unknown>> {
394
+ return this.http.post("/ontology/versions/versions", body);
395
+ }
396
+ /**
397
+ * Compares two versions.
398
+ * @param body - Comparison parameters.
399
+ */
400
+ compare(body: Body): Promise<Record<string, unknown>> {
401
+ return this.http.post("/ontology/versions/versions/compare", body);
402
+ }
403
+ /**
404
+ * Fetches a version by ID.
405
+ * @param id - The version ID.
406
+ */
407
+ get(id: string): Promise<Record<string, unknown>> {
408
+ return this.http.get(`/ontology/versions/versions/${id}`);
409
+ }
410
+ /**
411
+ * Deletes a version.
412
+ * @param id - The version ID.
413
+ */
414
+ delete(id: string): Promise<void> {
415
+ return this.http.delete(`/ontology/versions/versions/${id}`);
416
+ }
417
+ /**
418
+ * Verifies an audit trail for a version.
419
+ * @param body - Audit verification payload.
420
+ */
421
+ auditVerify(body: Body): Promise<Record<string, unknown>> {
422
+ return this.http.post("/ontology/versions/audit/verify", body);
423
+ }
424
+ /**
425
+ * Lists release bundles with pagination.
426
+ * @param opts - Pagination options.
427
+ */
428
+ async listReleaseBundles(
429
+ opts: ListOpts = {}
430
+ ): Promise<PageResult<Record<string, unknown>>> {
431
+ const raw = await this.http.get("/ontology/versions/release-bundles", opts);
432
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
433
+ this.listReleaseBundles({ ...opts, cursor: c })
434
+ );
435
+ }
436
+ /**
437
+ * Creates a new release bundle.
438
+ * @param body - Release bundle payload.
439
+ */
440
+ createReleaseBundle(body: Body): Promise<Record<string, unknown>> {
441
+ return this.http.post("/ontology/versions/release-bundles", body);
442
+ }
443
+ /**
444
+ * Fetches a release bundle by ID.
445
+ * @param id - The release bundle ID.
446
+ */
447
+ getReleaseBundle(id: string): Promise<Record<string, unknown>> {
448
+ return this.http.get(`/ontology/versions/release-bundles/${id}`);
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Validation subdomain: payload validation and rule management.
454
+ */
455
+ export class ValidationNamespace extends SubdomainBase {
456
+ constructor(http: HttpClient) {
457
+ super(http, "/ontology/validation");
458
+ }
459
+ /**
460
+ * Validates a payload against a schema.
461
+ * @param body - The payload to validate.
462
+ */
463
+ validatePayload(body: Body): Promise<Record<string, unknown>> {
464
+ return this.http.post("/ontology/validation/payloads/validate", body);
465
+ }
466
+ /**
467
+ * Lists validation rules with pagination.
468
+ * @param opts - Pagination options.
469
+ */
470
+ async listRules(
471
+ opts: ListOpts = {}
472
+ ): Promise<PageResult<Record<string, unknown>>> {
473
+ const raw = await this.http.get("/ontology/validation/rules", opts);
474
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
475
+ this.listRules({ ...opts, cursor: c })
476
+ );
477
+ }
478
+ /**
479
+ * Creates a validation rule.
480
+ * @param body - The rule definition.
481
+ */
482
+ createRule(body: Body): Promise<Record<string, unknown>> {
483
+ return this.http.post("/ontology/validation/rules", body);
484
+ }
485
+ /**
486
+ * Fetches a validation rule by ID.
487
+ * @param id - The rule ID.
488
+ */
489
+ getRule(id: string): Promise<Record<string, unknown>> {
490
+ return this.http.get(`/ontology/validation/rules/${id}`);
491
+ }
492
+ /**
493
+ * Deletes a validation rule.
494
+ * @param id - The rule ID.
495
+ */
496
+ deleteRule(id: string): Promise<void> {
497
+ return this.http.delete(`/ontology/validation/rules/${id}`);
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Transformations subdomain: data transformation management.
503
+ */
504
+ export class TransformationsNamespace extends SubdomainBase {
505
+ constructor(http: HttpClient) {
506
+ super(http, "/ontology/transformations");
507
+ }
508
+ /**
509
+ * Creates a data transformation.
510
+ * @param body - The transformation definition.
511
+ */
512
+ create(body: Body): Promise<Record<string, unknown>> {
513
+ return this.http.post("/ontology/transformations/transformations", body);
514
+ }
515
+ }
516
+
517
+ /**
518
+ * Reasoning subdomain: explainability, facts, and forward/backward chaining.
519
+ */
520
+ export class ReasoningNamespace extends SubdomainBase {
521
+ constructor(http: HttpClient) {
522
+ super(http, "/ontology/reasoning");
523
+ }
524
+ /**
525
+ * Generates an explanation for a reasoning result.
526
+ * @param body - Explanation request.
527
+ */
528
+ explain(body: Body): Promise<Record<string, unknown>> {
529
+ return this.http.post("/ontology/reasoning/explain", body);
530
+ }
531
+ /**
532
+ * Retrieves facts based on criteria.
533
+ * @param body - Fact query parameters.
534
+ */
535
+ facts(body: Body): Promise<Record<string, unknown>> {
536
+ return this.http.post("/ontology/reasoning/facts", body);
537
+ }
538
+ /**
539
+ * Loads facts into the reasoning graph.
540
+ * @param body - Facts graph data.
541
+ */
542
+ loadFactsGraph(body: Body): Promise<Record<string, unknown>> {
543
+ return this.http.post("/ontology/reasoning/facts/load-graph", body);
544
+ }
545
+ /**
546
+ * Performs forward chaining reasoning.
547
+ * @param body - Forward reasoning parameters.
548
+ */
549
+ reasonForward(body: Body): Promise<Record<string, unknown>> {
550
+ return this.http.post("/ontology/reasoning/reason/forward", body);
551
+ }
552
+ /**
553
+ * Performs backward chaining reasoning.
554
+ * @param body - Backward reasoning parameters.
555
+ */
556
+ reasonBackward(body: Body): Promise<Record<string, unknown>> {
557
+ return this.http.post("/ontology/reasoning/reason/backward", body);
558
+ }
559
+ /**
560
+ * Lists reasoning rules with pagination.
561
+ * @param opts - Pagination options.
562
+ */
563
+ async listRules(
564
+ opts: ListOpts = {}
565
+ ): Promise<PageResult<Record<string, unknown>>> {
566
+ const raw = await this.http.get("/ontology/reasoning/rules", opts);
567
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
568
+ this.listRules({ ...opts, cursor: c })
569
+ );
570
+ }
571
+ /**
572
+ * Creates a reasoning rule.
573
+ * @param body - The rule definition.
574
+ */
575
+ createRule(body: Body): Promise<Record<string, unknown>> {
576
+ return this.http.post("/ontology/reasoning/rules", body);
577
+ }
578
+ /**
579
+ * Updates a reasoning rule.
580
+ * @param id - The rule ID.
581
+ * @param body - The updated rule fields.
582
+ */
583
+ updateRule(id: string, body: Body): Promise<Record<string, unknown>> {
584
+ return this.http.put(`/ontology/reasoning/rules/${id}`, body);
585
+ }
586
+ /**
587
+ * Deletes a reasoning rule.
588
+ * @param id - The rule ID.
589
+ */
590
+ deleteRule(id: string): Promise<void> {
591
+ return this.http.delete(`/ontology/reasoning/rules/${id}`);
592
+ }
593
+ }
594
+
595
+ /**
596
+ * Rollouts subdomain: manage rollout campaigns (create, pause, resume, rollback).
597
+ */
598
+ export class RolloutsNamespace extends SubdomainBase {
599
+ constructor(http: HttpClient) {
600
+ super(http, "/ontology/rollouts");
601
+ }
602
+ /**
603
+ * Lists rollouts with pagination.
604
+ * @param opts - Pagination options.
605
+ */
606
+ async list(
607
+ opts: ListOpts = {}
608
+ ): Promise<PageResult<Record<string, unknown>>> {
609
+ const raw = await this.http.get("/ontology/rollouts/rollouts", opts);
610
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
611
+ this.list({ ...opts, cursor: c })
612
+ );
613
+ }
614
+ /**
615
+ * Creates a new rollout.
616
+ * @param body - Rollout configuration.
617
+ */
618
+ create(body: Body): Promise<Record<string, unknown>> {
619
+ return this.http.post("/ontology/rollouts/rollouts", body);
620
+ }
621
+ /**
622
+ * Fetches a rollout by ID.
623
+ * @param id - The rollout ID.
624
+ */
625
+ get(id: string): Promise<Record<string, unknown>> {
626
+ return this.http.get(`/ontology/rollouts/rollouts/${id}`);
627
+ }
628
+ /**
629
+ * Updates a rollout.
630
+ * @param id - The rollout ID.
631
+ * @param body - The updated rollout fields.
632
+ */
633
+ update(id: string, body: Body): Promise<Record<string, unknown>> {
634
+ return this.http.put(`/ontology/rollouts/rollouts/${id}`, body);
635
+ }
636
+ /**
637
+ * Deletes a rollout.
638
+ * @param id - The rollout ID.
639
+ */
640
+ delete(id: string): Promise<void> {
641
+ return this.http.delete(`/ontology/rollouts/rollouts/${id}`);
642
+ }
643
+ /**
644
+ * Starts a rollout.
645
+ * @param id - The rollout ID.
646
+ * @param body - Start parameters.
647
+ */
648
+ start(id: string, body: Body = {}): Promise<Record<string, unknown>> {
649
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/start`, body);
650
+ }
651
+ /**
652
+ * Pauses a rollout.
653
+ * @param id - The rollout ID.
654
+ * @param body - Pause parameters.
655
+ */
656
+ pause(id: string, body: Body = {}): Promise<Record<string, unknown>> {
657
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/pause`, body);
658
+ }
659
+ /**
660
+ * Resumes a paused rollout.
661
+ * @param id - The rollout ID.
662
+ * @param body - Resume parameters.
663
+ */
664
+ resume(id: string, body: Body = {}): Promise<Record<string, unknown>> {
665
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/resume`, body);
666
+ }
667
+ /**
668
+ * Rolls back a rollout.
669
+ * @param id - The rollout ID.
670
+ * @param body - Rollback parameters.
671
+ */
672
+ rollback(id: string, body: Body = {}): Promise<Record<string, unknown>> {
673
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/rollback`, body);
674
+ }
675
+ /**
676
+ * Returns the current status of a rollout.
677
+ * @param id - The rollout ID.
678
+ */
679
+ status(id: string): Promise<Record<string, unknown>> {
680
+ return this.http.get(`/ontology/rollouts/rollouts/${id}/status`);
681
+ }
682
+ }
683
+
684
+ /**
685
+ * Rollups subdomain: data rollup/aggregation jobs.
686
+ */
687
+ export class RollupsNamespace extends SubdomainBase {
688
+ constructor(http: HttpClient) {
689
+ super(http, "/ontology/rollups");
690
+ }
691
+ /**
692
+ * Lists rollups with pagination.
693
+ * @param opts - Pagination options.
694
+ */
695
+ async list(
696
+ opts: ListOpts = {}
697
+ ): Promise<PageResult<Record<string, unknown>>> {
698
+ const raw = await this.http.get("/ontology/rollups/rollups", opts);
699
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
700
+ this.list({ ...opts, cursor: c })
701
+ );
702
+ }
703
+ /**
704
+ * Creates a rollup job.
705
+ * @param body - Rollup configuration.
706
+ */
707
+ create(body: Body): Promise<Record<string, unknown>> {
708
+ return this.http.post("/ontology/rollups/rollups", body);
709
+ }
710
+ /**
711
+ * Fetches a rollup by ID.
712
+ * @param id - The rollup ID.
713
+ */
714
+ get(id: string): Promise<Record<string, unknown>> {
715
+ return this.http.get(`/ontology/rollups/rollups/${id}`);
716
+ }
717
+ /**
718
+ * Updates a rollup.
719
+ * @param id - The rollup ID.
720
+ * @param body - The updated rollup fields.
721
+ */
722
+ update(id: string, body: Body): Promise<Record<string, unknown>> {
723
+ return this.http.put(`/ontology/rollups/rollups/${id}`, body);
724
+ }
725
+ /**
726
+ * Deletes a rollup.
727
+ * @param id - The rollup ID.
728
+ */
729
+ delete(id: string): Promise<void> {
730
+ return this.http.delete(`/ontology/rollups/rollups/${id}`);
731
+ }
732
+ /**
733
+ * Executes a rollup.
734
+ * @param id - The rollup ID.
735
+ * @param body - Execution parameters.
736
+ */
737
+ execute(id: string, body: Body = {}): Promise<Record<string, unknown>> {
738
+ return this.http.post(`/ontology/rollups/rollups/${id}/execute`, body);
739
+ }
740
+ /**
741
+ * Previews a rollup result without persisting it.
742
+ * @param id - The rollup ID.
743
+ * @param body - Preview parameters.
744
+ */
745
+ preview(id: string, body: Body = {}): Promise<Record<string, unknown>> {
746
+ return this.http.post(`/ontology/rollups/rollups/${id}/preview`, body);
747
+ }
748
+ /**
749
+ * Fetches the result of a rollup execution.
750
+ * @param id - The rollup ID.
751
+ */
752
+ result(id: string): Promise<Record<string, unknown>> {
753
+ return this.http.get(`/ontology/rollups/rollups/${id}/result`);
754
+ }
755
+ /**
756
+ * Fetches the result of a specific rollup execution.
757
+ * @param executionId - The execution ID.
758
+ */
759
+ executionResult(executionId: string): Promise<Record<string, unknown>> {
760
+ return this.http.get(`/ontology/rollups/rollup-results/${executionId}`);
761
+ }
762
+ }
763
+
764
+ /**
765
+ * Extract subdomain: extract structured data (entities, events, relations, etc.).
766
+ */
767
+ export class ExtractNamespace extends SubdomainBase {
768
+ constructor(http: HttpClient) {
769
+ super(http, "/ontology/extract");
770
+ }
771
+ /**
772
+ * Analyzes source data for extraction.
773
+ * @param body - Analysis parameters.
774
+ */
775
+ analyze(body: Body): Promise<Record<string, unknown>> {
776
+ return this.http.post("/ontology/extract/extract/analyze", body);
777
+ }
778
+ /**
779
+ * Extracts architecture from source data.
780
+ * @param body - Architecture extraction parameters.
781
+ */
782
+ architecture(body: Body): Promise<Record<string, unknown>> {
783
+ return this.http.post("/ontology/extract/extract/architecture", body);
784
+ }
785
+ /**
786
+ * Extracts coreference chains from source data.
787
+ * @param body - Coreference extraction parameters.
788
+ */
789
+ coreferences(body: Body): Promise<Record<string, unknown>> {
790
+ return this.http.post("/ontology/extract/extract/coreferences", body);
791
+ }
792
+ /**
793
+ * Extracts entities from source data.
794
+ * @param body - Entity extraction parameters.
795
+ */
796
+ entities(body: Body): Promise<Record<string, unknown>> {
797
+ return this.http.post("/ontology/extract/extract/entities", body);
798
+ }
799
+ /**
800
+ * Extracts events from source data.
801
+ * @param body - Event extraction parameters.
802
+ */
803
+ events(body: Body): Promise<Record<string, unknown>> {
804
+ return this.http.post("/ontology/extract/extract/events", body);
805
+ }
806
+ /**
807
+ * Extracts relations from source data.
808
+ * @param body - Relation extraction parameters.
809
+ */
810
+ relations(body: Body): Promise<Record<string, unknown>> {
811
+ return this.http.post("/ontology/extract/extract/relations", body);
812
+ }
813
+ /**
814
+ * Extracts RDF triplets from source data.
815
+ * @param body - Triplet extraction parameters.
816
+ */
817
+ triplets(body: Body): Promise<Record<string, unknown>> {
818
+ return this.http.post("/ontology/extract/extract/triplets", body);
819
+ }
820
+ }
821
+
822
+ /**
823
+ * Events subdomain: event management and consumer checkpoints.
824
+ */
825
+ export class EventsNamespace extends SubdomainBase {
826
+ constructor(http: HttpClient) {
827
+ super(http, "/ontology/events");
828
+ }
829
+ /**
830
+ * Lists events with pagination.
831
+ * @param opts - Pagination options.
832
+ */
833
+ async list(
834
+ opts: ListOpts = {}
835
+ ): Promise<PageResult<Record<string, unknown>>> {
836
+ const raw = await this.http.get("/ontology/events/events", opts);
837
+ return createPageResult(asPagePayload<Record<string, unknown>>(raw), (c) =>
838
+ this.list({ ...opts, cursor: c })
839
+ );
840
+ }
841
+ /**
842
+ * Creates a new event.
843
+ * @param body - The event payload.
844
+ */
845
+ create(body: Body): Promise<Record<string, unknown>> {
846
+ return this.http.post("/ontology/events/events", body);
847
+ }
848
+ /**
849
+ * Fetches an event by ID.
850
+ * @param id - The event ID.
851
+ */
852
+ get(id: string): Promise<Record<string, unknown>> {
853
+ return this.http.get(`/ontology/events/events/${id}`);
854
+ }
855
+ /**
856
+ * Creates an event checkpoint for a consumer.
857
+ * @param body - Checkpoint data.
858
+ */
859
+ createCheckpoint(body: Body): Promise<Record<string, unknown>> {
860
+ return this.http.post("/ontology/events/events/checkpoints", body);
861
+ }
862
+ /**
863
+ * Fetches the checkpoint for a consumer.
864
+ * @param consumer - The consumer identifier.
865
+ */
866
+ getCheckpoint(consumer: string): Promise<Record<string, unknown>> {
867
+ return this.http.get(`/ontology/events/events/checkpoints/${consumer}`);
868
+ }
869
+ /**
870
+ * Acquires a lease for event processing.
871
+ * @param body - Lease acquisition parameters.
872
+ */
873
+ acquireLease(body: Body): Promise<Record<string, unknown>> {
874
+ return this.http.post("/ontology/events/events/leases/acquire", body);
875
+ }
876
+ /**
877
+ * Acknowledges a lease after processing.
878
+ * @param body - Lease acknowledgment parameters.
879
+ */
880
+ acknowledgeLease(body: Body): Promise<Record<string, unknown>> {
881
+ return this.http.post("/ontology/events/events/leases/acknowledge", body);
882
+ }
883
+ }