@frontal-labs/ontology 0.0.1 → 1.0.1

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/README.md CHANGED
@@ -1,32 +1,103 @@
1
1
  # @frontal-labs/ontology
2
2
 
3
- Ontology and model management APIs for schema, rules, and migrations.
3
+ Client for the Frontal Ontology platform (`/v1/ontology/*`). The API is composed
4
+ of independent subdomain services, each exposed as a namespace:
5
+ `engine`, `objects`, `relationships`, `schemas`, `versions`, `validation`,
6
+ `transformations`, `reasoning`, `rollouts`, `rollups`, `extract`, and `events`.
7
+ (The `graph` subdomain is served by `@frontal-labs/graph`.)
4
8
 
5
9
  ## Installation
6
10
 
7
11
  ```bash
8
- bun add @frontal-labs/ontology @frontal-labs/core
12
+ npm install @frontal-labs/ontology
9
13
  ```
10
14
 
15
+ `@frontal-labs/core` is included automatically as a dependency.
16
+
17
+ ## Quick Start
18
+
19
+ ```ts
20
+ import { ontology } from "@frontal-labs/ontology";
21
+
22
+ // Generate an ontology with the engine, then browse object types.
23
+ const proposal = await ontology.engine.generate({
24
+ description: "Model a billing dispute lifecycle with SLA states.",
25
+ });
26
+ const objectTypes = await ontology.objects.listObjectTypes({ limit: 10 });
27
+ ```
28
+
29
+ The `ontology` singleton reads `FRONTAL_API_KEY` and
30
+ `FRONTAL_ONTOLOGY_API_URL` from the environment.
31
+
11
32
  ## Usage
12
33
 
34
+ ### Explicit config
35
+
36
+ ```ts
37
+ import { createOntologyClient } from "@frontal-labs/ontology";
38
+
39
+ const ontology = createOntologyClient({
40
+ apiKey: process.env.FRONTAL_API_KEY!,
41
+ baseUrl: "https://api.frontal.dev/v1",
42
+ });
43
+
44
+ // Define/validate a schema via the schemas subdomain.
45
+ await ontology.schemas.create({
46
+ name: "Invoice",
47
+ fields: [
48
+ { name: "amount", type: "number", required: true },
49
+ { name: "currency", type: "string", required: true },
50
+ ],
51
+ });
52
+ ```
53
+
54
+ ### Shared client (multiple SDKs)
55
+
13
56
  ```ts
14
57
  import { FrontalClient } from "@frontal-labs/core";
15
58
  import { createOntologyClient } from "@frontal-labs/ontology";
16
59
 
17
60
  const client = new FrontalClient({
18
61
  apiKey: process.env.FRONTAL_API_KEY!,
19
- baseUrl: process.env.FRONTAL_API_URL ?? "https://api.frontal.dev/v1",
62
+ baseUrl: "https://api.frontal.dev/v1",
20
63
  });
21
64
 
22
65
  const ontology = createOntologyClient(client);
66
+ ```
67
+
68
+ ### Validate a payload
69
+
70
+ ```ts
71
+ await ontology.validation.validatePayload({
72
+ objectType: "Incident",
73
+ payload: { severity: "high" },
74
+ });
75
+ ```
76
+
77
+ ### AI-powered generation & inference
78
+
79
+ ```ts
80
+ const proposal = await ontology.engine.generate({
81
+ description: "Model a billing dispute lifecycle with ownership and SLA states.",
82
+ substrates: ["billing", "support"],
83
+ });
84
+ const inferred = await ontology.engine.inferClasses({ samples: [] });
85
+ ```
23
86
 
24
- const models = await ontology.list({ limit: 10 });
25
- await ontology.create({ name: "invoice", fields: [{ name: "amount", type: "number", required: true }] });
87
+ ### Versions & rollouts
88
+
89
+ ```ts
90
+ const bundle = await ontology.versions.createReleaseBundle({ version: "2.0.0" });
91
+ const rollout = await ontology.rollouts.create({ bundleId: bundle.id });
92
+ await ontology.rollouts.start(rollout.id);
93
+ const status = await ontology.rollouts.status(rollout.id);
26
94
  ```
27
95
 
28
- ## Configuration
96
+ ## Environment Variables
29
97
 
30
- - `FRONTAL_API_KEY`
31
- - `FRONTAL_ONTOLOGY_API_URL` (optional)
32
- - `FRONTAL_API_URL` (fallback)
98
+ | Variable | Required | Default | Description |
99
+ |----------|----------|---------|-------------|
100
+ | `FRONTAL_API_KEY` | Yes | — | Frontal API authentication key |
101
+ | `FRONTAL_API_URL` | No | `https://api.frontal.dev/v1` | Base URL for the Frontal API |
102
+ | `FRONTAL_ENV` | No | `development` | Runtime environment (`development`, `test`, `production`) |
103
+ | `FRONTAL_DEBUG` | No | `false` | Enable debug logging |
@@ -0,0 +1,36 @@
1
+ import { FrontalClient } from "@frontal-labs/core";
2
+ import { OntologySdk } from "./sdk";
3
+ /**
4
+ * Configuration for creating an {@link OntologySdk} client standalone.
5
+ *
6
+ * @property apiKey - Frontal API key.
7
+ * @property baseUrl - Override the default ontology API base URL.
8
+ * @property timeout - Request timeout in milliseconds (default 30_000).
9
+ * @property maxRetries - Maximum number of retry attempts (default 3).
10
+ */
11
+ export interface OntologyClientConfig {
12
+ apiKey: string;
13
+ baseUrl?: string;
14
+ timeout?: number;
15
+ maxRetries?: number;
16
+ }
17
+ /**
18
+ * Creates an {@link OntologySdk} from either an existing {@link FrontalClient}
19
+ * or a plain configuration object.
20
+ *
21
+ * @param config - A pre-configured FrontalClient or config options.
22
+ * @returns A fully-initialized OntologySdk.
23
+ */
24
+ export declare function createOntologyClient(config: OntologyClientConfig | FrontalClient): OntologySdk;
25
+ /**
26
+ * Convenience singleton that lazily creates an {@link OntologySdk} using the
27
+ * default environment configuration.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { ontology } from "@frontal-labs/ontology";
32
+ * const models = await ontology.schemas.list();
33
+ * ```
34
+ */
35
+ export declare const ontology: OntologySdk;
36
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAAG,aAAa,GAC3C,WAAW,CAAC;AA0Bf;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,aAWnB,CAAC"}
@@ -6,4 +6,16 @@ export declare const DEFAULT_ONTOLOGY_BASE_URL = "https://api.frontal.dev/v1";
6
6
  * Package version.
7
7
  */
8
8
  export declare const VERSION = "0.0.1";
9
+ /**
10
+ * Default timeout.
11
+ */
12
+ export declare const DEFAULT_TIMEOUT = 30000;
13
+ /**
14
+ * Default max retry number.
15
+ */
16
+ export declare const DEFAULT_MAX_RETRIES = 3;
17
+ /**
18
+ * Default retry delay.
19
+ */
20
+ export declare const DEFAULT_RETRY_DELAY = 1000;
9
21
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,+BAA+B,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,+BAA+B,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,17 +1,10 @@
1
- import { FrontalClient } from "@frontal-labs/core";
2
- import { OntologyService } from "./service";
3
- /** Config for standalone usage without @frontal-labs/core */
4
- export interface OntologyClientConfig {
5
- apiKey: string;
6
- baseUrl?: string;
7
- timeout?: number;
8
- maxRetries?: number;
9
- }
10
- /** Create from a FrontalClient instance */
11
- export declare function createOntologyClient(client: FrontalClient): OntologyService;
12
- /** Create standalone with just config */
13
- export declare function createOntologyClient(config: OntologyClientConfig): OntologyService;
14
- export declare const ontology: OntologyService;
1
+ /**
2
+ * @frontal-labs/ontology
3
+ *
4
+ * Define and manage Frontal ontology schemas and objects.
5
+ */
6
+ export { createOntologyClient, ontology, type OntologyClientConfig, } from "./client";
7
+ export { DEFAULT_ONTOLOGY_BASE_URL, VERSION } from "./constants";
15
8
  export * from "./schemas";
16
- export { OntologyService } from "./service";
9
+ export { OntologySdk } from "./sdk";
17
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAAC;AAC7E,yCAAyC;AACzC,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,eAAe,CAAC;AAyBnB,eAAO,MAAM,QAAQ,iBAAgD,CAAC;AAEtE,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,QAAQ,EACR,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACjE,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC"}