@triggerix-ai/schema 0.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/LICENSE +21 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.mts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.mjs +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 imba97 <https://github.com/imba97>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const core=require("@triggerix/core"),a={oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object",properties:{$ref:{type:"string"}},required:["$ref"],additionalProperties:!1}]},m={type:"object",title:"Condition",description:"A single comparison condition",properties:{left:a,operator:{type:"string",enum:[...core.VALID_OPERATORS]},right:a},required:["left","operator"],additionalProperties:!1},f={type:"object",title:"ConditionGroup",description:"Logical grouping of conditions",properties:{type:{type:"string",enum:[...core.LOGICAL_OPERATORS]},conditions:{type:"array",items:{oneOf:[{$ref:"#/definitions/Condition"},{$ref:"#/definitions/ConditionGroup"}]},minItems:1}},required:["type","conditions"],additionalProperties:!1},u={$ref:"#/definitions/ActionNode"},n={type:"array",items:u},y={Sequence:{type:"object",properties:{type:{const:"sequence"},actions:{...n,minItems:1}},required:["type","actions"],additionalProperties:!1},Parallel:{type:"object",properties:{type:{const:"parallel"},actions:{...n,minItems:1}},required:["type","actions"],additionalProperties:!1},If:{type:"object",properties:{type:{const:"if"},condition:{oneOf:[{$ref:"#/definitions/Condition"},{$ref:"#/definitions/ConditionGroup"}]},then:{...n,minItems:1},else:n},required:["type","condition","then"],additionalProperties:!1},TryCatch:{type:"object",properties:{type:{const:"tryCatch"},try:{...n,minItems:1},catch:n,finally:n},required:["type","try"],additionalProperties:!1}};function g(e){const t={type:e.type};return e.description!==void 0&&(t.description=e.description),e.enum!==void 0&&(t.enum=e.enum),e.default!==void 0&&(t.default=e.default),t}function l(e){return{type:"string",enum:e.map(t=>t.id),description:"Must match an event type registered via AIRegistry"}}function h(e){return{type:"string",enum:e.map(t=>t.id),description:"Must match an action type registered via AIRegistry"}}function S(e){return{type:"string",enum:e.map(t=>t.type),description:"Must match a component type registered via ComponentRegistry"}}function O(e){return{type:"object",title:"Event",description:"Describes when a trigger fires",properties:{type:l(e),source:{type:"string",description:"Component name from components[].name. Required when the event originates from a component."},payload:{type:"object",description:"Optional event payload",additionalProperties:!0}},required:["type"],additionalProperties:!1}}function A(e){if(!e||Object.keys(e).length===0)return{type:"object",additionalProperties:!0};const t={},i=[];for(const[s,o]of Object.entries(e))t[s]=g(o),o.required&&i.push(s);const r={type:"object",properties:t,additionalProperties:!1};return i.length&&(r.required=i),r}function I(e){return{type:"object",title:"Action",description:e.description,properties:{type:h([e]),params:A(e.params)},required:["type"],additionalProperties:!1}}function p(e){return{oneOf:[...e.map(t=>I(t)),{$ref:"#/definitions/Sequence"},{$ref:"#/definitions/Parallel"},{$ref:"#/definitions/If"},{$ref:"#/definitions/TryCatch"}]}}function generateRuleSchema(e){const t=e.getActions();return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"Trigger",description:"An Event-Condition-Action rule",properties:{id:{type:"string",description:"Unique trigger identifier"},name:{type:"string",description:"Human-readable name"},event:O(e.getEvents()),conditions:{$ref:"#/definitions/ConditionGroup"},actions:{type:"array",items:p(t),minItems:1}},required:["id","event","actions"],additionalProperties:!1,definitions:{Condition:m,ConditionGroup:f,ActionNode:p(t),...y}}}function generateToolSchema(e){const{registry:t,component:i}=e,r={type:"array",items:generateRuleSchema(t),description:"Triggerix triggers to bind to component events"};if(!i)return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"TriggerixAIOutput",description:"Trigger-only output: a list of triggers to load",properties:{triggers:r},required:["triggers"],additionalProperties:!1};const s=i.getComponents(),o={type:"object",title:"ComponentInstance",description:"A component instance emitted by the AI",properties:{type:S(s),name:{type:"string",description:"Semantic local name, unique within one AI output. Used by trigger `event.source` and `$ref`."},props:{type:"object",additionalProperties:!0},children:{type:"array",items:{$ref:"#/definitions/ComponentInstance"}}},required:["type"],additionalProperties:!1};return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"TriggerixAIOutput",description:"Component + trigger output: components to render, triggers to bind",properties:{components:{type:"array",items:o,description:"Atomic components the renderer will mount"},triggers:r},required:["components","triggers"],additionalProperties:!1,definitions:{ComponentInstance:o}}}exports.generateRuleSchema=generateRuleSchema,exports.generateToolSchema=generateToolSchema;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentRegistry } from '@triggerix-ai/component';
|
|
2
|
+
import { AIRegistry } from '@triggerix-ai/registry';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subset of JSON Schema draft-07 sufficient for AI tool input definitions.
|
|
6
|
+
*/
|
|
7
|
+
interface JSONSchema {
|
|
8
|
+
$schema?: string;
|
|
9
|
+
$id?: string;
|
|
10
|
+
$ref?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | Array<'string' | 'number' | 'boolean' | 'object' | 'array' | 'null'>;
|
|
14
|
+
properties?: Record<string, JSONSchema>;
|
|
15
|
+
items?: JSONSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
enum?: unknown[];
|
|
18
|
+
oneOf?: JSONSchema[];
|
|
19
|
+
anyOf?: JSONSchema[];
|
|
20
|
+
allOf?: JSONSchema[];
|
|
21
|
+
additionalProperties?: boolean | JSONSchema;
|
|
22
|
+
minItems?: number;
|
|
23
|
+
definitions?: Record<string, JSONSchema>;
|
|
24
|
+
const?: unknown;
|
|
25
|
+
default?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Top-level options for `generateToolSchema`. */
|
|
29
|
+
interface GenerateToolSchemaOptions {
|
|
30
|
+
registry: AIRegistry;
|
|
31
|
+
/** When provided, enables component generation mode. */
|
|
32
|
+
component?: ComponentRegistry;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a JSON Schema for a single Triggerix trigger, constrained by the
|
|
36
|
+
* registry. Suitable for use as the `items` of a `triggers` array.
|
|
37
|
+
*/
|
|
38
|
+
declare function generateRuleSchema(registry: AIRegistry): JSONSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Generate the JSON Schema for the AI tool's `parameters` field.
|
|
41
|
+
*
|
|
42
|
+
* - With `component`: schema is `{ components: ComponentInstance[], triggers: Trigger[] }`
|
|
43
|
+
* - Without `component`: schema is `{ triggers: Trigger[] }` (trigger-only mode)
|
|
44
|
+
*/
|
|
45
|
+
declare function generateToolSchema(options: GenerateToolSchemaOptions): JSONSchema;
|
|
46
|
+
|
|
47
|
+
export { generateRuleSchema, generateToolSchema };
|
|
48
|
+
export type { GenerateToolSchemaOptions, JSONSchema };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentRegistry } from '@triggerix-ai/component';
|
|
2
|
+
import { AIRegistry } from '@triggerix-ai/registry';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subset of JSON Schema draft-07 sufficient for AI tool input definitions.
|
|
6
|
+
*/
|
|
7
|
+
interface JSONSchema {
|
|
8
|
+
$schema?: string;
|
|
9
|
+
$id?: string;
|
|
10
|
+
$ref?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | Array<'string' | 'number' | 'boolean' | 'object' | 'array' | 'null'>;
|
|
14
|
+
properties?: Record<string, JSONSchema>;
|
|
15
|
+
items?: JSONSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
enum?: unknown[];
|
|
18
|
+
oneOf?: JSONSchema[];
|
|
19
|
+
anyOf?: JSONSchema[];
|
|
20
|
+
allOf?: JSONSchema[];
|
|
21
|
+
additionalProperties?: boolean | JSONSchema;
|
|
22
|
+
minItems?: number;
|
|
23
|
+
definitions?: Record<string, JSONSchema>;
|
|
24
|
+
const?: unknown;
|
|
25
|
+
default?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Top-level options for `generateToolSchema`. */
|
|
29
|
+
interface GenerateToolSchemaOptions {
|
|
30
|
+
registry: AIRegistry;
|
|
31
|
+
/** When provided, enables component generation mode. */
|
|
32
|
+
component?: ComponentRegistry;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a JSON Schema for a single Triggerix trigger, constrained by the
|
|
36
|
+
* registry. Suitable for use as the `items` of a `triggers` array.
|
|
37
|
+
*/
|
|
38
|
+
declare function generateRuleSchema(registry: AIRegistry): JSONSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Generate the JSON Schema for the AI tool's `parameters` field.
|
|
41
|
+
*
|
|
42
|
+
* - With `component`: schema is `{ components: ComponentInstance[], triggers: Trigger[] }`
|
|
43
|
+
* - Without `component`: schema is `{ triggers: Trigger[] }` (trigger-only mode)
|
|
44
|
+
*/
|
|
45
|
+
declare function generateToolSchema(options: GenerateToolSchemaOptions): JSONSchema;
|
|
46
|
+
|
|
47
|
+
export { generateRuleSchema, generateToolSchema };
|
|
48
|
+
export type { GenerateToolSchemaOptions, JSONSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentRegistry } from '@triggerix-ai/component';
|
|
2
|
+
import { AIRegistry } from '@triggerix-ai/registry';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subset of JSON Schema draft-07 sufficient for AI tool input definitions.
|
|
6
|
+
*/
|
|
7
|
+
interface JSONSchema {
|
|
8
|
+
$schema?: string;
|
|
9
|
+
$id?: string;
|
|
10
|
+
$ref?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | Array<'string' | 'number' | 'boolean' | 'object' | 'array' | 'null'>;
|
|
14
|
+
properties?: Record<string, JSONSchema>;
|
|
15
|
+
items?: JSONSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
enum?: unknown[];
|
|
18
|
+
oneOf?: JSONSchema[];
|
|
19
|
+
anyOf?: JSONSchema[];
|
|
20
|
+
allOf?: JSONSchema[];
|
|
21
|
+
additionalProperties?: boolean | JSONSchema;
|
|
22
|
+
minItems?: number;
|
|
23
|
+
definitions?: Record<string, JSONSchema>;
|
|
24
|
+
const?: unknown;
|
|
25
|
+
default?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Top-level options for `generateToolSchema`. */
|
|
29
|
+
interface GenerateToolSchemaOptions {
|
|
30
|
+
registry: AIRegistry;
|
|
31
|
+
/** When provided, enables component generation mode. */
|
|
32
|
+
component?: ComponentRegistry;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a JSON Schema for a single Triggerix trigger, constrained by the
|
|
36
|
+
* registry. Suitable for use as the `items` of a `triggers` array.
|
|
37
|
+
*/
|
|
38
|
+
declare function generateRuleSchema(registry: AIRegistry): JSONSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Generate the JSON Schema for the AI tool's `parameters` field.
|
|
41
|
+
*
|
|
42
|
+
* - With `component`: schema is `{ components: ComponentInstance[], triggers: Trigger[] }`
|
|
43
|
+
* - Without `component`: schema is `{ triggers: Trigger[] }` (trigger-only mode)
|
|
44
|
+
*/
|
|
45
|
+
declare function generateToolSchema(options: GenerateToolSchemaOptions): JSONSchema;
|
|
46
|
+
|
|
47
|
+
export { generateRuleSchema, generateToolSchema };
|
|
48
|
+
export type { GenerateToolSchemaOptions, JSONSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{VALID_OPERATORS as c,LOGICAL_OPERATORS as u}from"@triggerix/core";const p={oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object",properties:{$ref:{type:"string"}},required:["$ref"],additionalProperties:!1}]},m={type:"object",title:"Condition",description:"A single comparison condition",properties:{left:p,operator:{type:"string",enum:[...c]},right:p},required:["left","operator"],additionalProperties:!1},y={type:"object",title:"ConditionGroup",description:"Logical grouping of conditions",properties:{type:{type:"string",enum:[...u]},conditions:{type:"array",items:{oneOf:[{$ref:"#/definitions/Condition"},{$ref:"#/definitions/ConditionGroup"}]},minItems:1}},required:["type","conditions"],additionalProperties:!1},f={$ref:"#/definitions/ActionNode"},i={type:"array",items:f},l={Sequence:{type:"object",properties:{type:{const:"sequence"},actions:{...i,minItems:1}},required:["type","actions"],additionalProperties:!1},Parallel:{type:"object",properties:{type:{const:"parallel"},actions:{...i,minItems:1}},required:["type","actions"],additionalProperties:!1},If:{type:"object",properties:{type:{const:"if"},condition:{oneOf:[{$ref:"#/definitions/Condition"},{$ref:"#/definitions/ConditionGroup"}]},then:{...i,minItems:1},else:i},required:["type","condition","then"],additionalProperties:!1},TryCatch:{type:"object",properties:{type:{const:"tryCatch"},try:{...i,minItems:1},catch:i,finally:i},required:["type","try"],additionalProperties:!1}};function g(e){const t={type:e.type};return e.description!==void 0&&(t.description=e.description),e.enum!==void 0&&(t.enum=e.enum),e.default!==void 0&&(t.default=e.default),t}function h(e){return{type:"string",enum:e.map(t=>t.id),description:"Must match an event type registered via AIRegistry"}}function b(e){return{type:"string",enum:e.map(t=>t.id),description:"Must match an action type registered via AIRegistry"}}function j(e){return{type:"string",enum:e.map(t=>t.type),description:"Must match a component type registered via ComponentRegistry"}}function q(e){return{type:"object",title:"Event",description:"Describes when a trigger fires",properties:{type:h(e),source:{type:"string",description:"Component name from components[].name. Required when the event originates from a component."},payload:{type:"object",description:"Optional event payload",additionalProperties:!0}},required:["type"],additionalProperties:!1}}function C(e){if(!e||Object.keys(e).length===0)return{type:"object",additionalProperties:!0};const t={},n=[];for(const[s,o]of Object.entries(e))t[s]=g(o),o.required&&n.push(s);const r={type:"object",properties:t,additionalProperties:!1};return n.length&&(r.required=n),r}function P(e){return{type:"object",title:"Action",description:e.description,properties:{type:b([e]),params:C(e.params)},required:["type"],additionalProperties:!1}}function a(e){return{oneOf:[...e.map(t=>P(t)),{$ref:"#/definitions/Sequence"},{$ref:"#/definitions/Parallel"},{$ref:"#/definitions/If"},{$ref:"#/definitions/TryCatch"}]}}function d(e){const t=e.getActions();return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"Trigger",description:"An Event-Condition-Action rule",properties:{id:{type:"string",description:"Unique trigger identifier"},name:{type:"string",description:"Human-readable name"},event:q(e.getEvents()),conditions:{$ref:"#/definitions/ConditionGroup"},actions:{type:"array",items:a(t),minItems:1}},required:["id","event","actions"],additionalProperties:!1,definitions:{Condition:m,ConditionGroup:y,ActionNode:a(t),...l}}}function A(e){const{registry:t,component:n}=e,r={type:"array",items:d(t),description:"Triggerix triggers to bind to component events"};if(!n)return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"TriggerixAIOutput",description:"Trigger-only output: a list of triggers to load",properties:{triggers:r},required:["triggers"],additionalProperties:!1};const s=n.getComponents(),o={type:"object",title:"ComponentInstance",description:"A component instance emitted by the AI",properties:{type:j(s),name:{type:"string",description:"Semantic local name, unique within one AI output. Used by trigger `event.source` and `$ref`."},props:{type:"object",additionalProperties:!0},children:{type:"array",items:{$ref:"#/definitions/ComponentInstance"}}},required:["type"],additionalProperties:!1};return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"TriggerixAIOutput",description:"Component + trigger output: components to render, triggers to bind",properties:{components:{type:"array",items:o,description:"Atomic components the renderer will mount"},triggers:r},required:["components","triggers"],additionalProperties:!1,definitions:{ComponentInstance:o}}}export{d as generateRuleSchema,A as generateToolSchema};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@triggerix-ai/schema",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "Dynamic constrained JSON Schema generator for Triggerix AI tool inputs",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/triggerix-lang/triggerix-ai#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git@github.com:triggerix-lang/triggerix-ai.git",
|
|
11
|
+
"directory": "packages/schema"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/triggerix-lang/triggerix-ai/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@triggerix/core": "^0.0.7",
|
|
34
|
+
"@triggerix-ai/component": "0.0.0",
|
|
35
|
+
"@triggerix-ai/registry": "0.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"unbuild": "^3.6.1"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"stub": "unbuild --stub",
|
|
42
|
+
"build": "unbuild"
|
|
43
|
+
}
|
|
44
|
+
}
|