@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/dist/index.mjs CHANGED
@@ -1,50 +1,834 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __async = (__this, __arguments, generator) => {
21
- return new Promise((resolve, reject) => {
22
- var fulfilled = (value) => {
23
- try {
24
- step(generator.next(value));
25
- } catch (e) {
26
- reject(e);
27
- }
28
- };
29
- var rejected = (value) => {
30
- try {
31
- step(generator.throw(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- };
36
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
- step((generator = generator.apply(__this, __arguments)).next());
38
- });
39
- };
1
+ // src/client.ts
2
+ import {
3
+ FrontalClient,
4
+ getDefaultClient,
5
+ HttpClient
6
+ } from "@frontal-labs/core";
40
7
 
41
- // src/index.ts
42
- import { FrontalClient, getDefaultClient, HttpClient } from "@frontal-labs/core";
8
+ // src/constants.ts
9
+ var DEFAULT_ONTOLOGY_BASE_URL = "https://api.frontal.dev/v1";
10
+ var VERSION = "0.0.1";
11
+ var DEFAULT_TIMEOUT = 3e4;
12
+ var DEFAULT_MAX_RETRIES = 3;
13
+ var DEFAULT_RETRY_DELAY = 1e3;
43
14
 
44
- // src/service.ts
15
+ // src/sdk.ts
45
16
  import {
17
+ asPagePayload,
46
18
  createPageResult
47
19
  } from "@frontal-labs/core";
20
+ var OntologySdk = class {
21
+ engine;
22
+ objects;
23
+ relationships;
24
+ schemas;
25
+ versions;
26
+ validation;
27
+ transformations;
28
+ reasoning;
29
+ rollouts;
30
+ rollups;
31
+ extract;
32
+ events;
33
+ /**
34
+ * @param http - The HTTP client used to make API requests.
35
+ */
36
+ constructor(http) {
37
+ this.engine = new EngineNamespace(http);
38
+ this.objects = new ObjectsNamespace(http);
39
+ this.relationships = new RelationshipsNamespace(http);
40
+ this.schemas = new SchemasNamespace(http);
41
+ this.versions = new VersionsNamespace(http);
42
+ this.validation = new ValidationNamespace(http);
43
+ this.transformations = new TransformationsNamespace(http);
44
+ this.reasoning = new ReasoningNamespace(http);
45
+ this.rollouts = new RolloutsNamespace(http);
46
+ this.rollups = new RollupsNamespace(http);
47
+ this.extract = new ExtractNamespace(http);
48
+ this.events = new EventsNamespace(http);
49
+ }
50
+ };
51
+ var SubdomainBase = class {
52
+ constructor(http, base) {
53
+ this.http = http;
54
+ this.base = base;
55
+ }
56
+ /**
57
+ * Returns the capabilities of this subdomain service.
58
+ */
59
+ capabilities() {
60
+ return this.http.get(`${this.base}/capabilities`);
61
+ }
62
+ /**
63
+ * Health check for this subdomain service.
64
+ */
65
+ health() {
66
+ return this.http.get(`${this.base}/health`);
67
+ }
68
+ /**
69
+ * Returns service info/metadata for this subdomain service.
70
+ */
71
+ info() {
72
+ return this.http.get(`${this.base}/info`);
73
+ }
74
+ /**
75
+ * Lists asynchronous runs for this subdomain.
76
+ * @param opts - Pagination options.
77
+ */
78
+ async runs(opts = {}) {
79
+ const raw = await this.http.get(`${this.base}/runs`, opts);
80
+ return createPageResult(
81
+ asPagePayload(raw),
82
+ (c) => this.runs({ ...opts, cursor: c })
83
+ );
84
+ }
85
+ /**
86
+ * Creates a new asynchronous run.
87
+ * @param input - The run input payload.
88
+ */
89
+ createRun(input) {
90
+ return this.http.post(`${this.base}/runs`, input);
91
+ }
92
+ /**
93
+ * Fetches an asynchronous run by ID.
94
+ * @param runId - The run ID.
95
+ */
96
+ run(runId) {
97
+ return this.http.get(`${this.base}/runs/${runId}`);
98
+ }
99
+ };
100
+ var EngineNamespace = class extends SubdomainBase {
101
+ constructor(http) {
102
+ super(http, "/ontology/engine");
103
+ }
104
+ /**
105
+ * Generates an ontology from a description.
106
+ * @param input - Generation parameters.
107
+ */
108
+ generate(input) {
109
+ return this.http.post("/ontology/engine/ontologies/generate", input);
110
+ }
111
+ /**
112
+ * Validates an ontology definition.
113
+ * @param input - The ontology to validate.
114
+ */
115
+ validate(input) {
116
+ return this.http.post("/ontology/engine/ontologies/validate", input);
117
+ }
118
+ /**
119
+ * Exports an ontology in a standard format.
120
+ * @param input - Export parameters.
121
+ */
122
+ export(input) {
123
+ return this.http.post("/ontology/engine/ontologies/export", input);
124
+ }
125
+ /**
126
+ * Exports an ontology as SHACL shapes.
127
+ * @param input - Export parameters.
128
+ */
129
+ exportShacl(input) {
130
+ return this.http.post("/ontology/engine/ontologies/export-shacl", input);
131
+ }
132
+ /**
133
+ * Infers class definitions from source data.
134
+ * @param input - Inference parameters.
135
+ */
136
+ inferClasses(input) {
137
+ return this.http.post("/ontology/engine/ontologies/infer-classes", input);
138
+ }
139
+ /**
140
+ * Infers property definitions from source data.
141
+ * @param input - Inference parameters.
142
+ */
143
+ inferProperties(input) {
144
+ return this.http.post(
145
+ "/ontology/engine/ontologies/infer-properties",
146
+ input
147
+ );
148
+ }
149
+ /**
150
+ * Compares two ontology versions.
151
+ * @param input - Comparison parameters (fromVersion, toVersion).
152
+ */
153
+ compareVersions(input) {
154
+ return this.http.post(
155
+ "/ontology/engine/ontologies/compare-versions",
156
+ input
157
+ );
158
+ }
159
+ };
160
+ var ObjectsNamespace = class extends SubdomainBase {
161
+ constructor(http) {
162
+ super(http, "/ontology/objects");
163
+ }
164
+ /**
165
+ * Lists object types with pagination.
166
+ * @param opts - Pagination options.
167
+ */
168
+ async listObjectTypes(opts = {}) {
169
+ const raw = await this.http.get("/ontology/objects/object-types", opts);
170
+ return createPageResult(
171
+ asPagePayload(raw),
172
+ (c) => this.listObjectTypes({ ...opts, cursor: c })
173
+ );
174
+ }
175
+ /**
176
+ * Fetches an object type by ID.
177
+ * @param id - The object type ID.
178
+ */
179
+ getObjectType(id) {
180
+ return this.http.get(`/ontology/objects/object-types/${id}`);
181
+ }
182
+ /**
183
+ * Creates or updates an object type.
184
+ * @param id - The object type ID.
185
+ * @param body - The object type definition.
186
+ */
187
+ putObjectType(id, body) {
188
+ return this.http.put(`/ontology/objects/object-types/${id}`, body);
189
+ }
190
+ /**
191
+ * Deletes an object type.
192
+ * @param id - The object type ID.
193
+ */
194
+ deleteObjectType(id) {
195
+ return this.http.delete(`/ontology/objects/object-types/${id}`);
196
+ }
197
+ /**
198
+ * Lists object instances with pagination.
199
+ * @param opts - Pagination options.
200
+ */
201
+ async listObjects(opts = {}) {
202
+ const raw = await this.http.get("/ontology/objects/objects", opts);
203
+ return createPageResult(
204
+ asPagePayload(raw),
205
+ (c) => this.listObjects({ ...opts, cursor: c })
206
+ );
207
+ }
208
+ /**
209
+ * Fetches an object instance by ID.
210
+ * @param id - The object ID.
211
+ */
212
+ getObject(id) {
213
+ return this.http.get(`/ontology/objects/objects/${id}`);
214
+ }
215
+ /**
216
+ * Creates or updates an object instance.
217
+ * @param id - The object ID.
218
+ * @param body - The object data.
219
+ */
220
+ putObject(id, body) {
221
+ return this.http.put(`/ontology/objects/objects/${id}`, body);
222
+ }
223
+ /**
224
+ * Deletes an object instance.
225
+ * @param id - The object ID.
226
+ */
227
+ deleteObject(id) {
228
+ return this.http.delete(`/ontology/objects/objects/${id}`);
229
+ }
230
+ };
231
+ var RelationshipsNamespace = class extends SubdomainBase {
232
+ constructor(http) {
233
+ super(http, "/ontology/relationships");
234
+ }
235
+ /**
236
+ * Lists relationship types with pagination.
237
+ * @param opts - Pagination options.
238
+ */
239
+ async listTypes(opts = {}) {
240
+ const raw = await this.http.get(
241
+ "/ontology/relationships/relationship-types",
242
+ opts
243
+ );
244
+ return createPageResult(
245
+ asPagePayload(raw),
246
+ (c) => this.listTypes({ ...opts, cursor: c })
247
+ );
248
+ }
249
+ /**
250
+ * Deletes a relationship type.
251
+ * @param id - The relationship type ID.
252
+ */
253
+ deleteType(id) {
254
+ return this.http.delete(`/ontology/relationships/relationship-types/${id}`);
255
+ }
256
+ /**
257
+ * Lists relationship instances with pagination.
258
+ * @param opts - Pagination options.
259
+ */
260
+ async list(opts = {}) {
261
+ const raw = await this.http.get(
262
+ "/ontology/relationships/relationships",
263
+ opts
264
+ );
265
+ return createPageResult(
266
+ asPagePayload(raw),
267
+ (c) => this.list({ ...opts, cursor: c })
268
+ );
269
+ }
270
+ /**
271
+ * Fetches a relationship instance by ID.
272
+ * @param id - The relationship ID.
273
+ */
274
+ get(id) {
275
+ return this.http.get(`/ontology/relationships/relationships/${id}`);
276
+ }
277
+ /**
278
+ * Creates or updates a relationship instance.
279
+ * @param id - The relationship ID.
280
+ * @param body - The relationship data.
281
+ */
282
+ put(id, body) {
283
+ return this.http.put(`/ontology/relationships/relationships/${id}`, body);
284
+ }
285
+ /**
286
+ * Deletes a relationship instance.
287
+ * @param id - The relationship ID.
288
+ */
289
+ delete(id) {
290
+ return this.http.delete(`/ontology/relationships/relationships/${id}`);
291
+ }
292
+ };
293
+ var SchemasNamespace = class extends SubdomainBase {
294
+ constructor(http) {
295
+ super(http, "/ontology/schemas");
296
+ }
297
+ /**
298
+ * Lists schema definitions with pagination.
299
+ * @param opts - Pagination options.
300
+ */
301
+ async list(opts = {}) {
302
+ const raw = await this.http.get("/ontology/schemas/schemas", opts);
303
+ return createPageResult(
304
+ asPagePayload(raw),
305
+ (c) => this.list({ ...opts, cursor: c })
306
+ );
307
+ }
308
+ /**
309
+ * Creates a new schema definition.
310
+ * @param body - The schema definition.
311
+ */
312
+ create(body) {
313
+ return this.http.post("/ontology/schemas/schemas", body);
314
+ }
315
+ /**
316
+ * Validates a schema definition.
317
+ * @param body - The schema to validate.
318
+ */
319
+ validate(body) {
320
+ return this.http.post("/ontology/schemas/schemas/validate", body);
321
+ }
322
+ /**
323
+ * Fetches a schema definition by ID.
324
+ * @param id - The schema ID.
325
+ */
326
+ get(id) {
327
+ return this.http.get(`/ontology/schemas/schemas/${id}`);
328
+ }
329
+ /**
330
+ * Deletes a schema definition.
331
+ * @param id - The schema ID.
332
+ */
333
+ delete(id) {
334
+ return this.http.delete(`/ontology/schemas/schemas/${id}`);
335
+ }
336
+ };
337
+ var VersionsNamespace = class extends SubdomainBase {
338
+ constructor(http) {
339
+ super(http, "/ontology/versions");
340
+ }
341
+ /**
342
+ * Creates a new version.
343
+ * @param body - Version creation payload.
344
+ */
345
+ create(body) {
346
+ return this.http.post("/ontology/versions/versions", body);
347
+ }
348
+ /**
349
+ * Compares two versions.
350
+ * @param body - Comparison parameters.
351
+ */
352
+ compare(body) {
353
+ return this.http.post("/ontology/versions/versions/compare", body);
354
+ }
355
+ /**
356
+ * Fetches a version by ID.
357
+ * @param id - The version ID.
358
+ */
359
+ get(id) {
360
+ return this.http.get(`/ontology/versions/versions/${id}`);
361
+ }
362
+ /**
363
+ * Deletes a version.
364
+ * @param id - The version ID.
365
+ */
366
+ delete(id) {
367
+ return this.http.delete(`/ontology/versions/versions/${id}`);
368
+ }
369
+ /**
370
+ * Verifies an audit trail for a version.
371
+ * @param body - Audit verification payload.
372
+ */
373
+ auditVerify(body) {
374
+ return this.http.post("/ontology/versions/audit/verify", body);
375
+ }
376
+ /**
377
+ * Lists release bundles with pagination.
378
+ * @param opts - Pagination options.
379
+ */
380
+ async listReleaseBundles(opts = {}) {
381
+ const raw = await this.http.get("/ontology/versions/release-bundles", opts);
382
+ return createPageResult(
383
+ asPagePayload(raw),
384
+ (c) => this.listReleaseBundles({ ...opts, cursor: c })
385
+ );
386
+ }
387
+ /**
388
+ * Creates a new release bundle.
389
+ * @param body - Release bundle payload.
390
+ */
391
+ createReleaseBundle(body) {
392
+ return this.http.post("/ontology/versions/release-bundles", body);
393
+ }
394
+ /**
395
+ * Fetches a release bundle by ID.
396
+ * @param id - The release bundle ID.
397
+ */
398
+ getReleaseBundle(id) {
399
+ return this.http.get(`/ontology/versions/release-bundles/${id}`);
400
+ }
401
+ };
402
+ var ValidationNamespace = class extends SubdomainBase {
403
+ constructor(http) {
404
+ super(http, "/ontology/validation");
405
+ }
406
+ /**
407
+ * Validates a payload against a schema.
408
+ * @param body - The payload to validate.
409
+ */
410
+ validatePayload(body) {
411
+ return this.http.post("/ontology/validation/payloads/validate", body);
412
+ }
413
+ /**
414
+ * Lists validation rules with pagination.
415
+ * @param opts - Pagination options.
416
+ */
417
+ async listRules(opts = {}) {
418
+ const raw = await this.http.get("/ontology/validation/rules", opts);
419
+ return createPageResult(
420
+ asPagePayload(raw),
421
+ (c) => this.listRules({ ...opts, cursor: c })
422
+ );
423
+ }
424
+ /**
425
+ * Creates a validation rule.
426
+ * @param body - The rule definition.
427
+ */
428
+ createRule(body) {
429
+ return this.http.post("/ontology/validation/rules", body);
430
+ }
431
+ /**
432
+ * Fetches a validation rule by ID.
433
+ * @param id - The rule ID.
434
+ */
435
+ getRule(id) {
436
+ return this.http.get(`/ontology/validation/rules/${id}`);
437
+ }
438
+ /**
439
+ * Deletes a validation rule.
440
+ * @param id - The rule ID.
441
+ */
442
+ deleteRule(id) {
443
+ return this.http.delete(`/ontology/validation/rules/${id}`);
444
+ }
445
+ };
446
+ var TransformationsNamespace = class extends SubdomainBase {
447
+ constructor(http) {
448
+ super(http, "/ontology/transformations");
449
+ }
450
+ /**
451
+ * Creates a data transformation.
452
+ * @param body - The transformation definition.
453
+ */
454
+ create(body) {
455
+ return this.http.post("/ontology/transformations/transformations", body);
456
+ }
457
+ };
458
+ var ReasoningNamespace = class extends SubdomainBase {
459
+ constructor(http) {
460
+ super(http, "/ontology/reasoning");
461
+ }
462
+ /**
463
+ * Generates an explanation for a reasoning result.
464
+ * @param body - Explanation request.
465
+ */
466
+ explain(body) {
467
+ return this.http.post("/ontology/reasoning/explain", body);
468
+ }
469
+ /**
470
+ * Retrieves facts based on criteria.
471
+ * @param body - Fact query parameters.
472
+ */
473
+ facts(body) {
474
+ return this.http.post("/ontology/reasoning/facts", body);
475
+ }
476
+ /**
477
+ * Loads facts into the reasoning graph.
478
+ * @param body - Facts graph data.
479
+ */
480
+ loadFactsGraph(body) {
481
+ return this.http.post("/ontology/reasoning/facts/load-graph", body);
482
+ }
483
+ /**
484
+ * Performs forward chaining reasoning.
485
+ * @param body - Forward reasoning parameters.
486
+ */
487
+ reasonForward(body) {
488
+ return this.http.post("/ontology/reasoning/reason/forward", body);
489
+ }
490
+ /**
491
+ * Performs backward chaining reasoning.
492
+ * @param body - Backward reasoning parameters.
493
+ */
494
+ reasonBackward(body) {
495
+ return this.http.post("/ontology/reasoning/reason/backward", body);
496
+ }
497
+ /**
498
+ * Lists reasoning rules with pagination.
499
+ * @param opts - Pagination options.
500
+ */
501
+ async listRules(opts = {}) {
502
+ const raw = await this.http.get("/ontology/reasoning/rules", opts);
503
+ return createPageResult(
504
+ asPagePayload(raw),
505
+ (c) => this.listRules({ ...opts, cursor: c })
506
+ );
507
+ }
508
+ /**
509
+ * Creates a reasoning rule.
510
+ * @param body - The rule definition.
511
+ */
512
+ createRule(body) {
513
+ return this.http.post("/ontology/reasoning/rules", body);
514
+ }
515
+ /**
516
+ * Updates a reasoning rule.
517
+ * @param id - The rule ID.
518
+ * @param body - The updated rule fields.
519
+ */
520
+ updateRule(id, body) {
521
+ return this.http.put(`/ontology/reasoning/rules/${id}`, body);
522
+ }
523
+ /**
524
+ * Deletes a reasoning rule.
525
+ * @param id - The rule ID.
526
+ */
527
+ deleteRule(id) {
528
+ return this.http.delete(`/ontology/reasoning/rules/${id}`);
529
+ }
530
+ };
531
+ var RolloutsNamespace = class extends SubdomainBase {
532
+ constructor(http) {
533
+ super(http, "/ontology/rollouts");
534
+ }
535
+ /**
536
+ * Lists rollouts with pagination.
537
+ * @param opts - Pagination options.
538
+ */
539
+ async list(opts = {}) {
540
+ const raw = await this.http.get("/ontology/rollouts/rollouts", opts);
541
+ return createPageResult(
542
+ asPagePayload(raw),
543
+ (c) => this.list({ ...opts, cursor: c })
544
+ );
545
+ }
546
+ /**
547
+ * Creates a new rollout.
548
+ * @param body - Rollout configuration.
549
+ */
550
+ create(body) {
551
+ return this.http.post("/ontology/rollouts/rollouts", body);
552
+ }
553
+ /**
554
+ * Fetches a rollout by ID.
555
+ * @param id - The rollout ID.
556
+ */
557
+ get(id) {
558
+ return this.http.get(`/ontology/rollouts/rollouts/${id}`);
559
+ }
560
+ /**
561
+ * Updates a rollout.
562
+ * @param id - The rollout ID.
563
+ * @param body - The updated rollout fields.
564
+ */
565
+ update(id, body) {
566
+ return this.http.put(`/ontology/rollouts/rollouts/${id}`, body);
567
+ }
568
+ /**
569
+ * Deletes a rollout.
570
+ * @param id - The rollout ID.
571
+ */
572
+ delete(id) {
573
+ return this.http.delete(`/ontology/rollouts/rollouts/${id}`);
574
+ }
575
+ /**
576
+ * Starts a rollout.
577
+ * @param id - The rollout ID.
578
+ * @param body - Start parameters.
579
+ */
580
+ start(id, body = {}) {
581
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/start`, body);
582
+ }
583
+ /**
584
+ * Pauses a rollout.
585
+ * @param id - The rollout ID.
586
+ * @param body - Pause parameters.
587
+ */
588
+ pause(id, body = {}) {
589
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/pause`, body);
590
+ }
591
+ /**
592
+ * Resumes a paused rollout.
593
+ * @param id - The rollout ID.
594
+ * @param body - Resume parameters.
595
+ */
596
+ resume(id, body = {}) {
597
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/resume`, body);
598
+ }
599
+ /**
600
+ * Rolls back a rollout.
601
+ * @param id - The rollout ID.
602
+ * @param body - Rollback parameters.
603
+ */
604
+ rollback(id, body = {}) {
605
+ return this.http.post(`/ontology/rollouts/rollouts/${id}/rollback`, body);
606
+ }
607
+ /**
608
+ * Returns the current status of a rollout.
609
+ * @param id - The rollout ID.
610
+ */
611
+ status(id) {
612
+ return this.http.get(`/ontology/rollouts/rollouts/${id}/status`);
613
+ }
614
+ };
615
+ var RollupsNamespace = class extends SubdomainBase {
616
+ constructor(http) {
617
+ super(http, "/ontology/rollups");
618
+ }
619
+ /**
620
+ * Lists rollups with pagination.
621
+ * @param opts - Pagination options.
622
+ */
623
+ async list(opts = {}) {
624
+ const raw = await this.http.get("/ontology/rollups/rollups", opts);
625
+ return createPageResult(
626
+ asPagePayload(raw),
627
+ (c) => this.list({ ...opts, cursor: c })
628
+ );
629
+ }
630
+ /**
631
+ * Creates a rollup job.
632
+ * @param body - Rollup configuration.
633
+ */
634
+ create(body) {
635
+ return this.http.post("/ontology/rollups/rollups", body);
636
+ }
637
+ /**
638
+ * Fetches a rollup by ID.
639
+ * @param id - The rollup ID.
640
+ */
641
+ get(id) {
642
+ return this.http.get(`/ontology/rollups/rollups/${id}`);
643
+ }
644
+ /**
645
+ * Updates a rollup.
646
+ * @param id - The rollup ID.
647
+ * @param body - The updated rollup fields.
648
+ */
649
+ update(id, body) {
650
+ return this.http.put(`/ontology/rollups/rollups/${id}`, body);
651
+ }
652
+ /**
653
+ * Deletes a rollup.
654
+ * @param id - The rollup ID.
655
+ */
656
+ delete(id) {
657
+ return this.http.delete(`/ontology/rollups/rollups/${id}`);
658
+ }
659
+ /**
660
+ * Executes a rollup.
661
+ * @param id - The rollup ID.
662
+ * @param body - Execution parameters.
663
+ */
664
+ execute(id, body = {}) {
665
+ return this.http.post(`/ontology/rollups/rollups/${id}/execute`, body);
666
+ }
667
+ /**
668
+ * Previews a rollup result without persisting it.
669
+ * @param id - The rollup ID.
670
+ * @param body - Preview parameters.
671
+ */
672
+ preview(id, body = {}) {
673
+ return this.http.post(`/ontology/rollups/rollups/${id}/preview`, body);
674
+ }
675
+ /**
676
+ * Fetches the result of a rollup execution.
677
+ * @param id - The rollup ID.
678
+ */
679
+ result(id) {
680
+ return this.http.get(`/ontology/rollups/rollups/${id}/result`);
681
+ }
682
+ /**
683
+ * Fetches the result of a specific rollup execution.
684
+ * @param executionId - The execution ID.
685
+ */
686
+ executionResult(executionId) {
687
+ return this.http.get(`/ontology/rollups/rollup-results/${executionId}`);
688
+ }
689
+ };
690
+ var ExtractNamespace = class extends SubdomainBase {
691
+ constructor(http) {
692
+ super(http, "/ontology/extract");
693
+ }
694
+ /**
695
+ * Analyzes source data for extraction.
696
+ * @param body - Analysis parameters.
697
+ */
698
+ analyze(body) {
699
+ return this.http.post("/ontology/extract/extract/analyze", body);
700
+ }
701
+ /**
702
+ * Extracts architecture from source data.
703
+ * @param body - Architecture extraction parameters.
704
+ */
705
+ architecture(body) {
706
+ return this.http.post("/ontology/extract/extract/architecture", body);
707
+ }
708
+ /**
709
+ * Extracts coreference chains from source data.
710
+ * @param body - Coreference extraction parameters.
711
+ */
712
+ coreferences(body) {
713
+ return this.http.post("/ontology/extract/extract/coreferences", body);
714
+ }
715
+ /**
716
+ * Extracts entities from source data.
717
+ * @param body - Entity extraction parameters.
718
+ */
719
+ entities(body) {
720
+ return this.http.post("/ontology/extract/extract/entities", body);
721
+ }
722
+ /**
723
+ * Extracts events from source data.
724
+ * @param body - Event extraction parameters.
725
+ */
726
+ events(body) {
727
+ return this.http.post("/ontology/extract/extract/events", body);
728
+ }
729
+ /**
730
+ * Extracts relations from source data.
731
+ * @param body - Relation extraction parameters.
732
+ */
733
+ relations(body) {
734
+ return this.http.post("/ontology/extract/extract/relations", body);
735
+ }
736
+ /**
737
+ * Extracts RDF triplets from source data.
738
+ * @param body - Triplet extraction parameters.
739
+ */
740
+ triplets(body) {
741
+ return this.http.post("/ontology/extract/extract/triplets", body);
742
+ }
743
+ };
744
+ var EventsNamespace = class extends SubdomainBase {
745
+ constructor(http) {
746
+ super(http, "/ontology/events");
747
+ }
748
+ /**
749
+ * Lists events with pagination.
750
+ * @param opts - Pagination options.
751
+ */
752
+ async list(opts = {}) {
753
+ const raw = await this.http.get("/ontology/events/events", opts);
754
+ return createPageResult(
755
+ asPagePayload(raw),
756
+ (c) => this.list({ ...opts, cursor: c })
757
+ );
758
+ }
759
+ /**
760
+ * Creates a new event.
761
+ * @param body - The event payload.
762
+ */
763
+ create(body) {
764
+ return this.http.post("/ontology/events/events", body);
765
+ }
766
+ /**
767
+ * Fetches an event by ID.
768
+ * @param id - The event ID.
769
+ */
770
+ get(id) {
771
+ return this.http.get(`/ontology/events/events/${id}`);
772
+ }
773
+ /**
774
+ * Creates an event checkpoint for a consumer.
775
+ * @param body - Checkpoint data.
776
+ */
777
+ createCheckpoint(body) {
778
+ return this.http.post("/ontology/events/events/checkpoints", body);
779
+ }
780
+ /**
781
+ * Fetches the checkpoint for a consumer.
782
+ * @param consumer - The consumer identifier.
783
+ */
784
+ getCheckpoint(consumer) {
785
+ return this.http.get(`/ontology/events/events/checkpoints/${consumer}`);
786
+ }
787
+ /**
788
+ * Acquires a lease for event processing.
789
+ * @param body - Lease acquisition parameters.
790
+ */
791
+ acquireLease(body) {
792
+ return this.http.post("/ontology/events/events/leases/acquire", body);
793
+ }
794
+ /**
795
+ * Acknowledges a lease after processing.
796
+ * @param body - Lease acknowledgment parameters.
797
+ */
798
+ acknowledgeLease(body) {
799
+ return this.http.post("/ontology/events/events/leases/acknowledge", body);
800
+ }
801
+ };
802
+
803
+ // src/client.ts
804
+ import { env } from "@frontal-labs/core";
805
+ function createOntologyClient(clientOrConfig) {
806
+ if (clientOrConfig instanceof FrontalClient) {
807
+ return new OntologySdk(clientOrConfig.httpClient);
808
+ }
809
+ const http = new HttpClient({
810
+ apiKey: clientOrConfig.apiKey,
811
+ baseUrl: clientOrConfig.baseUrl ?? env.FRONTAL_API_URL ?? DEFAULT_ONTOLOGY_BASE_URL,
812
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
813
+ maxRetries: clientOrConfig.maxRetries ?? DEFAULT_MAX_RETRIES,
814
+ retryDelay: DEFAULT_RETRY_DELAY,
815
+ headers: {},
816
+ environment: env.FRONTAL_ENV,
817
+ debug: env.FRONTAL_DEBUG ?? false
818
+ });
819
+ return new OntologySdk(http);
820
+ }
821
+ var _ontologyCache;
822
+ var ontology = new Proxy({}, {
823
+ get(_t, prop) {
824
+ if (!_ontologyCache) {
825
+ _ontologyCache = createOntologyClient(getDefaultClient());
826
+ }
827
+ const inst = _ontologyCache;
828
+ const val = inst[prop];
829
+ return typeof val === "function" ? val.bind(inst) : val;
830
+ }
831
+ });
48
832
 
49
833
  // src/schemas.ts
50
834
  import { timestampSchema } from "@frontal-labs/core";
@@ -86,7 +870,7 @@ var FieldDefinitionSchema = z.object({
86
870
  dimensions: z.number().int().optional(),
87
871
  items: z.string().optional(),
88
872
  description: z.string().optional()
89
- }).passthrough();
873
+ }).loose();
90
874
  var RelationshipDefinitionSchema = z.object({
91
875
  name: z.string().optional(),
92
876
  type: RelationshipTypeSchema,
@@ -99,27 +883,27 @@ var RelationshipDefinitionSchema = z.object({
99
883
  }).optional(),
100
884
  computed: z.record(z.string(), z.unknown()).optional(),
101
885
  description: z.string().optional()
102
- }).passthrough();
886
+ }).loose();
103
887
  var SubstrateRoutingSchema = z.object({
104
888
  operational: z.string().optional(),
105
889
  analytical: z.string().optional(),
106
890
  semantic: z.string().optional(),
107
891
  cache: z.string().optional()
108
- }).passthrough();
892
+ }).loose();
109
893
  var SemanticMetadataSchema = z.object({
110
894
  description: z.string().optional(),
111
895
  lifecycle: z.array(z.string()).optional(),
112
896
  criticalFields: z.array(z.string()).optional(),
113
897
  significantEvents: z.array(z.string()).optional(),
114
898
  tags: z.array(z.string()).optional()
115
- }).passthrough();
899
+ }).loose();
116
900
  var IndexDefinitionSchema = z.object({
117
901
  name: z.string().optional(),
118
902
  fields: z.array(z.string()).min(1),
119
903
  substrate: z.string().optional(),
120
904
  unique: z.boolean().default(false),
121
905
  type: z.enum(["btree", "hash", "gin", "gist", "brin"]).default("btree")
122
- }).passthrough();
906
+ }).loose();
123
907
  var ModelDefinitionSchema = z.object({
124
908
  name: z.string(),
125
909
  displayName: z.string().optional(),
@@ -139,7 +923,7 @@ var ModelSchema = ModelDefinitionSchema.extend({
139
923
  createdAt: timestampSchema,
140
924
  updatedAt: timestampSchema,
141
925
  entityCount: z.number().int().optional()
142
- }).passthrough();
926
+ }).loose();
143
927
  var MigrationPlanSchema = z.object({
144
928
  id: z.string(),
145
929
  modelId: z.string(),
@@ -167,7 +951,7 @@ var MigrationPlanSchema = z.object({
167
951
  "immediate"
168
952
  ]),
169
953
  createdAt: timestampSchema
170
- }).passthrough();
954
+ }).loose();
171
955
  var RuleDefinitionSchema = z.object({
172
956
  name: z.string(),
173
957
  description: z.string().optional(),
@@ -184,238 +968,8 @@ var MixinDefinitionSchema = z.object({
184
968
  relationships: z.record(z.string(), RelationshipDefinitionSchema).optional(),
185
969
  appliesTo: z.array(z.string()).optional()
186
970
  }).strict();
187
-
188
- // src/service.ts
189
- var asPagePayload = (raw) => raw;
190
- var OntologyService = class {
191
- constructor(http) {
192
- this.http = http;
193
- this.migrations = new MigrationsNamespace(this.http);
194
- this.rules = new RulesNamespace(this.http);
195
- this.mixins = new MixinsNamespace(this.http);
196
- this.generation = new GenerationNamespace(this.http);
197
- }
198
- use(name) {
199
- return new ModelAccessor(name, this.http);
200
- }
201
- list() {
202
- return __async(this, arguments, function* (opts = {}) {
203
- const raw = yield this.http.get("/ontology/engine/runs", opts);
204
- return createPageResult(
205
- asPagePayload(raw),
206
- (cursor) => this.list(__spreadProps(__spreadValues({}, opts), { cursor }))
207
- );
208
- });
209
- }
210
- create(definition) {
211
- return __async(this, null, function* () {
212
- const body = ModelDefinitionSchema.parse(definition);
213
- return this.http.post("/ontology/engine/runs", body);
214
- });
215
- }
216
- validate(definition) {
217
- return __async(this, null, function* () {
218
- const body = ModelDefinitionSchema.parse(definition);
219
- return this.http.post("/ontology/engine/ontologies/validate", body);
220
- });
221
- }
222
- checkIntegrity() {
223
- return __async(this, null, function* () {
224
- return this.http.get("/ontology/engine/health");
225
- });
226
- }
227
- };
228
- var ModelAccessor = class {
229
- constructor(_name, http) {
230
- this._name = _name;
231
- this.http = http;
232
- }
233
- get(version) {
234
- return __async(this, null, function* () {
235
- const params = version ? { version } : void 0;
236
- return this.http.get("/ontology/engine/runs", params);
237
- });
238
- }
239
- update(definition) {
240
- return __async(this, null, function* () {
241
- return this.http.post("/ontology/engine/runs", definition);
242
- });
243
- }
244
- delete(force = false) {
245
- return __async(this, null, function* () {
246
- return this.http.post("/ontology/engine/runs", {
247
- action: "delete-model",
248
- force
249
- });
250
- });
251
- }
252
- relationships() {
253
- return __async(this, null, function* () {
254
- return this.http.get("/ontology/engine/runs");
255
- });
256
- }
257
- addRelationship(definition) {
258
- return __async(this, null, function* () {
259
- const body = RelationshipDefinitionSchema.parse(definition);
260
- return this.http.post("/ontology/engine/runs", body);
261
- });
262
- }
263
- removeRelationship(relationshipId) {
264
- return __async(this, null, function* () {
265
- return this.http.post("/ontology/engine/runs", {
266
- action: "delete-relationship",
267
- relationshipId
268
- });
269
- });
270
- }
271
- validateData() {
272
- return __async(this, null, function* () {
273
- return this.http.post("/ontology/engine/ontologies/validate");
274
- });
275
- }
276
- versions() {
277
- return __async(this, null, function* () {
278
- return this.http.get("/ontology/engine/runs");
279
- });
280
- }
281
- };
282
- var MigrationsNamespace = class {
283
- constructor(http) {
284
- this.http = http;
285
- }
286
- plan(request) {
287
- return __async(this, null, function* () {
288
- return this.http.post(
289
- "/ontology/engine/ontologies/compare-versions",
290
- request
291
- );
292
- });
293
- }
294
- apply(planId, strategy = "zero-downtime") {
295
- return __async(this, null, function* () {
296
- return this.http.post("/ontology/engine/runs", { planId, strategy });
297
- });
298
- }
299
- rollback(_migrationId) {
300
- return __async(this, null, function* () {
301
- return this.http.post("/ontology/engine/runs");
302
- });
303
- }
304
- history() {
305
- return __async(this, arguments, function* (opts = {}) {
306
- const raw = yield this.http.get("/ontology/engine/runs", opts);
307
- return createPageResult(
308
- asPagePayload(raw),
309
- (cursor) => this.history(__spreadProps(__spreadValues({}, opts), { cursor }))
310
- );
311
- });
312
- }
313
- };
314
- var RulesNamespace = class {
315
- constructor(http) {
316
- this.http = http;
317
- }
318
- list() {
319
- return __async(this, null, function* () {
320
- return this.http.get("/ontology/engine/runs");
321
- });
322
- }
323
- create(definition) {
324
- return __async(this, null, function* () {
325
- const body = RuleDefinitionSchema.parse(definition);
326
- return this.http.post("/ontology/engine/runs", body);
327
- });
328
- }
329
- update(_ruleId, definition) {
330
- return __async(this, null, function* () {
331
- return this.http.post("/ontology/engine/runs", definition);
332
- });
333
- }
334
- delete(ruleId) {
335
- return __async(this, null, function* () {
336
- return this.http.post("/ontology/engine/runs", {
337
- action: "delete-rule",
338
- ruleId
339
- });
340
- });
341
- }
342
- evaluate(opts) {
343
- return __async(this, null, function* () {
344
- return this.http.post("/ontology/engine/ontologies/validate", opts);
345
- });
346
- }
347
- };
348
- var MixinsNamespace = class {
349
- constructor(http) {
350
- this.http = http;
351
- }
352
- list() {
353
- return __async(this, null, function* () {
354
- return this.http.get("/ontology/engine/runs");
355
- });
356
- }
357
- create(definition) {
358
- return __async(this, null, function* () {
359
- const body = MixinDefinitionSchema.parse(definition);
360
- return this.http.post("/ontology/engine/runs", body);
361
- });
362
- }
363
- };
364
- var GenerationNamespace = class {
365
- constructor(http) {
366
- this.http = http;
367
- }
368
- generate(description, opts) {
369
- return __async(this, null, function* () {
370
- return this.http.post("/ontology/engine/ontologies/generate", __spreadValues({
371
- description
372
- }, opts));
373
- });
374
- }
375
- infer(opts) {
376
- return __async(this, null, function* () {
377
- return this.http.post("/ontology/engine/ontologies/infer-classes", opts);
378
- });
379
- }
380
- suggestions() {
381
- return __async(this, arguments, function* (opts = {}) {
382
- return this.http.get("/ontology/engine/runs", opts);
383
- });
384
- }
385
- acceptSuggestion(_suggestionId) {
386
- return __async(this, null, function* () {
387
- return this.http.post("/ontology/engine/runs");
388
- });
389
- }
390
- rejectSuggestion(_suggestionId, reason) {
391
- return __async(this, null, function* () {
392
- return this.http.post("/ontology/engine/runs", {
393
- reason
394
- });
395
- });
396
- }
397
- };
398
-
399
- // src/index.ts
400
- function createOntologyClient(clientOrConfig) {
401
- var _a, _b, _c, _d, _e;
402
- if (clientOrConfig instanceof FrontalClient) {
403
- return new OntologyService(clientOrConfig._http);
404
- }
405
- const http = new HttpClient({
406
- apiKey: clientOrConfig.apiKey,
407
- baseUrl: (_c = (_b = (_a = clientOrConfig.baseUrl) != null ? _a : process.env.FRONTAL_ONTOLOGY_API_URL) != null ? _b : process.env.FRONTAL_API_URL) != null ? _c : "https://api.frontal.dev/v1",
408
- timeout: (_d = clientOrConfig.timeout) != null ? _d : 3e4,
409
- maxRetries: (_e = clientOrConfig.maxRetries) != null ? _e : 3,
410
- retryDelay: 1e3,
411
- headers: {},
412
- environment: "production",
413
- debug: false
414
- });
415
- return new OntologyService(http);
416
- }
417
- var ontology = new OntologyService(getDefaultClient()._http);
418
971
  export {
972
+ DEFAULT_ONTOLOGY_BASE_URL,
419
973
  FieldDefinitionSchema,
420
974
  FieldTypeSchema,
421
975
  IndexDefinitionSchema,
@@ -423,12 +977,13 @@ export {
423
977
  MixinDefinitionSchema,
424
978
  ModelDefinitionSchema,
425
979
  ModelSchema,
426
- OntologyService,
980
+ OntologySdk,
427
981
  RelationshipDefinitionSchema,
428
982
  RelationshipTypeSchema,
429
983
  RuleDefinitionSchema,
430
984
  SemanticMetadataSchema,
431
985
  SubstrateRoutingSchema,
986
+ VERSION,
432
987
  createOntologyClient,
433
988
  ontology
434
989
  };