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