@objectstack/spec 0.1.0 → 0.1.2
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 +134 -121
- package/dist/ai/agent.zod.d.ts +164 -0
- package/dist/ai/agent.zod.d.ts.map +1 -0
- package/dist/ai/agent.zod.js +51 -0
- package/dist/api/contract.zod.d.ts +1733 -0
- package/dist/api/contract.zod.d.ts.map +1 -0
- package/dist/api/contract.zod.js +138 -0
- package/dist/data/dataset.zod.d.ts +60 -0
- package/dist/data/dataset.zod.d.ts.map +1 -0
- package/dist/data/dataset.zod.js +54 -0
- package/dist/data/field.zod.d.ts +1808 -0
- package/dist/data/field.zod.d.ts.map +1 -0
- package/dist/data/field.zod.js +222 -0
- package/dist/data/flow.zod.d.ts +242 -0
- package/dist/data/flow.zod.d.ts.map +1 -0
- package/dist/data/flow.zod.js +77 -0
- package/dist/data/mapping.zod.d.ts +470 -0
- package/dist/data/mapping.zod.d.ts.map +1 -0
- package/dist/data/mapping.zod.js +65 -0
- package/dist/data/object.zod.d.ts +844 -0
- package/dist/data/object.zod.d.ts.map +1 -0
- package/dist/data/object.zod.js +81 -0
- package/dist/data/permission.zod.d.ts +163 -0
- package/dist/data/permission.zod.d.ts.map +1 -0
- package/dist/data/permission.zod.js +62 -0
- package/dist/data/query.zod.d.ts +438 -0
- package/dist/data/query.zod.d.ts.map +1 -0
- package/dist/data/query.zod.js +147 -0
- package/dist/data/sharing.zod.d.ts +63 -0
- package/dist/data/sharing.zod.d.ts.map +1 -0
- package/dist/data/sharing.zod.js +57 -0
- package/dist/data/trigger.zod.d.ts +354 -0
- package/dist/data/trigger.zod.d.ts.map +1 -0
- package/dist/data/trigger.zod.js +195 -0
- package/dist/data/validation.zod.d.ts +276 -0
- package/dist/data/validation.zod.d.ts.map +1 -0
- package/dist/data/validation.zod.js +105 -0
- package/dist/data/workflow.zod.d.ts +195 -0
- package/dist/data/workflow.zod.d.ts.map +1 -0
- package/dist/data/workflow.zod.js +64 -0
- package/dist/index.d.ts +41 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -5
- package/dist/system/api.zod.d.ts +294 -0
- package/dist/system/api.zod.d.ts.map +1 -0
- package/dist/system/api.zod.js +56 -0
- package/dist/system/constants/index.d.ts +11 -0
- package/dist/system/constants/index.d.ts.map +1 -0
- package/dist/system/constants/index.js +26 -0
- package/dist/system/constants/paths.d.ts +71 -0
- package/dist/system/constants/paths.d.ts.map +1 -0
- package/dist/system/constants/paths.js +65 -0
- package/dist/system/datasource.zod.d.ts +210 -0
- package/dist/system/datasource.zod.d.ts.map +1 -0
- package/dist/system/datasource.zod.js +90 -0
- package/dist/system/discovery.zod.d.ts +174 -0
- package/dist/system/discovery.zod.d.ts.map +1 -0
- package/dist/system/discovery.zod.js +53 -0
- package/dist/system/driver.zod.d.ts +1525 -0
- package/dist/system/driver.zod.d.ts.map +1 -0
- package/dist/system/driver.zod.js +290 -0
- package/dist/system/identity.zod.d.ts +204 -0
- package/dist/system/identity.zod.d.ts.map +1 -0
- package/dist/system/identity.zod.js +68 -0
- package/dist/system/license.zod.d.ts +110 -0
- package/dist/system/license.zod.d.ts.map +1 -0
- package/dist/system/license.zod.js +63 -0
- package/dist/system/manifest.zod.d.ts +397 -0
- package/dist/system/manifest.zod.d.ts.map +1 -0
- package/dist/system/manifest.zod.js +142 -0
- package/dist/system/plugin.zod.d.ts +3516 -0
- package/dist/system/plugin.zod.d.ts.map +1 -0
- package/dist/system/plugin.zod.js +226 -0
- package/dist/system/policy.zod.d.ts +209 -0
- package/dist/system/policy.zod.d.ts.map +1 -0
- package/dist/system/policy.zod.js +54 -0
- package/dist/system/role.zod.d.ts +34 -0
- package/dist/system/role.zod.d.ts.map +1 -0
- package/dist/system/role.zod.js +25 -0
- package/dist/system/territory.zod.d.ts +91 -0
- package/dist/system/territory.zod.d.ts.map +1 -0
- package/dist/system/territory.zod.js +64 -0
- package/dist/system/translation.zod.d.ts +171 -0
- package/dist/system/translation.zod.d.ts.map +1 -0
- package/dist/system/translation.zod.js +34 -0
- package/dist/system/types/index.d.ts +7 -0
- package/dist/system/types/index.d.ts.map +1 -0
- package/dist/system/types/index.js +22 -0
- package/dist/system/types/plugin.d.ts +113 -0
- package/dist/system/types/plugin.d.ts.map +1 -0
- package/dist/system/types/plugin.js +6 -0
- package/dist/system/webhook.zod.d.ts +106 -0
- package/dist/system/webhook.zod.d.ts.map +1 -0
- package/dist/system/webhook.zod.js +56 -0
- package/dist/ui/action.zod.d.ts +155 -0
- package/dist/ui/action.zod.d.ts.map +1 -0
- package/dist/ui/action.zod.js +54 -0
- package/dist/ui/app.zod.d.ts +405 -0
- package/dist/ui/app.zod.d.ts.map +1 -0
- package/dist/ui/app.zod.js +138 -0
- package/dist/ui/dashboard.zod.d.ts +213 -0
- package/dist/ui/dashboard.zod.d.ts.map +1 -0
- package/dist/ui/dashboard.zod.js +72 -0
- package/dist/ui/page.zod.d.ts +187 -0
- package/dist/ui/page.zod.d.ts.map +1 -0
- package/dist/ui/page.zod.js +48 -0
- package/dist/ui/report.zod.d.ts +233 -0
- package/dist/ui/report.zod.d.ts.map +1 -0
- package/dist/ui/report.zod.js +74 -0
- package/dist/ui/theme.zod.d.ts +1221 -0
- package/dist/ui/theme.zod.d.ts.map +1 -0
- package/dist/ui/theme.zod.js +202 -0
- package/dist/ui/view.zod.d.ts +887 -0
- package/dist/ui/view.zod.d.ts.map +1 -0
- package/dist/ui/view.zod.js +83 -0
- package/dist/ui/widget.zod.d.ts +350 -0
- package/dist/ui/widget.zod.d.ts.map +1 -0
- package/dist/ui/widget.zod.js +66 -0
- package/json-schema/AIKnowledge.json +30 -0
- package/json-schema/AIModelConfig.json +41 -0
- package/json-schema/AITool.json +33 -0
- package/json-schema/Action.json +162 -0
- package/json-schema/ActionParam.json +82 -0
- package/json-schema/Address.json +40 -0
- package/json-schema/Agent.json +140 -0
- package/json-schema/AggregationFunction.json +19 -0
- package/json-schema/AggregationNode.json +42 -0
- package/json-schema/Animation.json +56 -0
- package/json-schema/ApiCapabilities.json +28 -0
- package/json-schema/ApiEndpoint.json +162 -0
- package/json-schema/ApiError.json +27 -0
- package/json-schema/ApiMapping.json +28 -0
- package/json-schema/ApiRoutes.json +41 -0
- package/json-schema/App.json +297 -0
- package/json-schema/AppBranding.json +24 -0
- package/json-schema/AsyncValidation.json +70 -0
- package/json-schema/AuditPolicy.json +31 -0
- package/json-schema/AuthProtocol.json +17 -0
- package/json-schema/AuthProvider.json +171 -0
- package/json-schema/BaseResponse.json +63 -0
- package/json-schema/BorderRadius.json +44 -0
- package/json-schema/Breakpoints.json +36 -0
- package/json-schema/BulkRequest.json +29 -0
- package/json-schema/BulkResponse.json +108 -0
- package/json-schema/CalendarConfig.json +28 -0
- package/json-schema/ChartType.json +19 -0
- package/json-schema/ColorPalette.json +83 -0
- package/json-schema/ConditionalValidation.json +793 -0
- package/json-schema/CreateRequest.json +20 -0
- package/json-schema/CrossFieldValidation.json +56 -0
- package/json-schema/CustomValidator.json +57 -0
- package/json-schema/Dashboard.json +117 -0
- package/json-schema/DashboardNavItem.json +42 -0
- package/json-schema/DashboardWidget.json +89 -0
- package/json-schema/Dataset.json +63 -0
- package/json-schema/DatasetMode.json +16 -0
- package/json-schema/Datasource.json +75 -0
- package/json-schema/DatasourceCapabilities.json +36 -0
- package/json-schema/DeleteResponse.json +68 -0
- package/json-schema/Discovery.json +114 -0
- package/json-schema/DriverCapabilities.json +39 -0
- package/json-schema/DriverDefinition.json +66 -0
- package/json-schema/DriverInterface.json +58 -0
- package/json-schema/DriverOptions.json +23 -0
- package/json-schema/DriverType.json +10 -0
- package/json-schema/EmailAlertAction.json +37 -0
- package/json-schema/ExportRequest.json +786 -0
- package/json-schema/Feature.json +51 -0
- package/json-schema/Field.json +290 -0
- package/json-schema/FieldMapping.json +83 -0
- package/json-schema/FieldNode.json +32 -0
- package/json-schema/FieldPermission.json +22 -0
- package/json-schema/FieldType.json +42 -0
- package/json-schema/FieldUpdateAction.json +32 -0
- package/json-schema/FieldWidgetProps.json +327 -0
- package/json-schema/FilterNode.json +52 -0
- package/json-schema/FilterOperator.json +26 -0
- package/json-schema/Flow.json +186 -0
- package/json-schema/FlowEdge.json +37 -0
- package/json-schema/FlowNode.json +65 -0
- package/json-schema/FlowNodeAction.json +24 -0
- package/json-schema/FlowVariable.json +34 -0
- package/json-schema/FormSection.json +42 -0
- package/json-schema/FormView.json +99 -0
- package/json-schema/FormatValidation.json +59 -0
- package/json-schema/GanttConfig.json +32 -0
- package/json-schema/GroupNavItem.json +42 -0
- package/json-schema/HttpMethod.json +16 -0
- package/json-schema/I18nContext.json +12 -0
- package/json-schema/Index.json +30 -0
- package/json-schema/JoinNode.json +455 -0
- package/json-schema/JoinType.json +15 -0
- package/json-schema/KanbanConfig.json +31 -0
- package/json-schema/LDAPConfig.json +39 -0
- package/json-schema/License.json +57 -0
- package/json-schema/ListRecordResponse.json +103 -0
- package/json-schema/ListView.json +153 -0
- package/json-schema/Locale.json +10 -0
- package/json-schema/LocationCoordinates.json +36 -0
- package/json-schema/Logger.json +25 -0
- package/json-schema/LogicOperator.json +14 -0
- package/json-schema/Manifest.json +315 -0
- package/json-schema/Mapping.json +598 -0
- package/json-schema/MenuItem.json +28 -0
- package/json-schema/MetricType.json +14 -0
- package/json-schema/ModificationResult.json +46 -0
- package/json-schema/NavigationItem.json +214 -0
- package/json-schema/NetworkPolicy.json +31 -0
- package/json-schema/OIDCConfig.json +46 -0
- package/json-schema/OWDModel.json +14 -0
- package/json-schema/Object.json +428 -0
- package/json-schema/ObjectCapabilities.json +62 -0
- package/json-schema/ObjectNavItem.json +46 -0
- package/json-schema/ObjectPermission.json +42 -0
- package/json-schema/ObjectQLClient.json +12 -0
- package/json-schema/Page.json +117 -0
- package/json-schema/PageComponent.json +36 -0
- package/json-schema/PageNavItem.json +47 -0
- package/json-schema/PageRegion.json +63 -0
- package/json-schema/PasswordPolicy.json +41 -0
- package/json-schema/PermissionSet.json +96 -0
- package/json-schema/Plan.json +53 -0
- package/json-schema/Plugin.json +20 -0
- package/json-schema/PluginContext.json +91 -0
- package/json-schema/PluginLifecycle.json +11 -0
- package/json-schema/Policy.json +138 -0
- package/json-schema/Query.json +456 -0
- package/json-schema/RateLimit.json +26 -0
- package/json-schema/RecordData.json +11 -0
- package/json-schema/Report.json +219 -0
- package/json-schema/ReportChart.json +45 -0
- package/json-schema/ReportColumn.json +35 -0
- package/json-schema/ReportGrouping.json +38 -0
- package/json-schema/ReportType.json +15 -0
- package/json-schema/Role.json +32 -0
- package/json-schema/Router.json +12 -0
- package/json-schema/SAMLConfig.json +44 -0
- package/json-schema/Scheduler.json +12 -0
- package/json-schema/ScopedStorage.json +12 -0
- package/json-schema/ScriptValidation.json +48 -0
- package/json-schema/SelectOption.json +32 -0
- package/json-schema/SessionPolicy.json +27 -0
- package/json-schema/Shadow.json +44 -0
- package/json-schema/SharingLevel.json +13 -0
- package/json-schema/SharingRule.json +58 -0
- package/json-schema/SharingRuleType.json +15 -0
- package/json-schema/SingleRecordResponse.json +69 -0
- package/json-schema/SortNode.json +26 -0
- package/json-schema/Spacing.json +64 -0
- package/json-schema/StateMachineValidation.json +59 -0
- package/json-schema/SystemAPI.json +12 -0
- package/json-schema/Territory.json +77 -0
- package/json-schema/TerritoryModel.json +34 -0
- package/json-schema/TerritoryType.json +15 -0
- package/json-schema/Theme.json +543 -0
- package/json-schema/ThemeMode.json +14 -0
- package/json-schema/TransformType.json +18 -0
- package/json-schema/TranslationBundle.json +78 -0
- package/json-schema/TranslationData.json +75 -0
- package/json-schema/Trigger.json +73 -0
- package/json-schema/TriggerAction.json +14 -0
- package/json-schema/TriggerContext.json +61 -0
- package/json-schema/TriggerTiming.json +13 -0
- package/json-schema/Typography.json +142 -0
- package/json-schema/UniquenessValidation.json +59 -0
- package/json-schema/UpdateRequest.json +20 -0
- package/json-schema/UrlNavItem.json +51 -0
- package/json-schema/ValidationRule.json +794 -0
- package/json-schema/View.json +500 -0
- package/json-schema/Webhook.json +88 -0
- package/json-schema/WebhookReceiver.json +66 -0
- package/json-schema/WebhookTriggerType.json +16 -0
- package/json-schema/WindowFunction.json +24 -0
- package/json-schema/WindowFunctionNode.json +104 -0
- package/json-schema/WindowSpec.json +65 -0
- package/json-schema/WorkflowAction.json +84 -0
- package/json-schema/WorkflowRule.json +128 -0
- package/json-schema/WorkflowTriggerType.json +16 -0
- package/json-schema/ZIndex.json +44 -0
- package/package.json +34 -20
- package/dist/examples.d.ts +0 -28
- package/dist/examples.d.ts.map +0 -1
- package/dist/examples.js +0 -250
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/meta/field-type.d.ts +0 -54
- package/dist/types/meta/field-type.d.ts.map +0 -1
- package/dist/types/meta/field-type.js +0 -42
- package/dist/types/meta/index.d.ts +0 -13
- package/dist/types/meta/index.d.ts.map +0 -1
- package/dist/types/meta/index.js +0 -12
- package/dist/types/meta/object-entity.d.ts +0 -246
- package/dist/types/meta/object-entity.d.ts.map +0 -1
- package/dist/types/meta/object-entity.js +0 -9
- package/dist/types/meta/object-field.d.ts +0 -199
- package/dist/types/meta/object-field.d.ts.map +0 -1
- package/dist/types/meta/object-field.js +0 -9
- package/dist/types/meta/object-view.d.ts +0 -430
- package/dist/types/meta/object-view.d.ts.map +0 -1
- package/dist/types/meta/object-view.js +0 -9
- package/src/examples.ts +0 -257
- package/src/index.ts +0 -10
- package/src/types/index.ts +0 -9
- package/src/types/meta/field-type.ts +0 -91
- package/src/types/meta/index.ts +0 -13
- package/src/types/meta/object-entity.ts +0 -265
- package/src/types/meta/object-field.ts +0 -218
- package/src/types/meta/object-view.ts +0 -475
package/README.md
CHANGED
|
@@ -1,154 +1,167 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @objectstack/spec
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ObjectStack Protocol & Specification — The "Constitution" of the Ecosystem.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- **TypeScript Interfaces**: Shared types for the entire ObjectStack ecosystem
|
|
9
|
-
- **No Logic**: Only type definitions, no runtime code or business logic
|
|
10
|
-
- **Universal Compatibility**: Works in Node.js, Browser, and Electron environments
|
|
8
|
+
## 📜 Mission
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
This package defines the **DNA** of ObjectStack. It contains:
|
|
11
|
+
1. **Zod Schemas**: Runtime validation for the Kernel and CLI.
|
|
12
|
+
2. **TypeScript Interfaces**: `z.infer<>` types for the IDE and Plugin developers.
|
|
13
|
+
3. **JSON Schemas**: Auto-generated schemas for VS Code IntelliSense.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
**Guiding Principle:** *"Strict Types, No Logic"*
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
## 🚀 Installation
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- Text types: `text`, `textarea`, `email`, `url`
|
|
21
|
-
- Numeric types: `number`, `currency`, `percentage`
|
|
22
|
-
- Date/Time types: `date`, `datetime`
|
|
23
|
-
- Relation types: `lookup`
|
|
24
|
-
- Selection types: `select`, `multiselect`
|
|
25
|
-
- Special types: `boolean`, `json`, `file`, `image`
|
|
26
|
-
|
|
27
|
-
#### `ObjectField`
|
|
28
|
-
Represents a field definition within an entity:
|
|
29
|
-
```typescript
|
|
30
|
-
interface ObjectField {
|
|
31
|
-
name: string; // Field identifier
|
|
32
|
-
label: string; // Display label
|
|
33
|
-
type: FieldType; // Data type
|
|
34
|
-
required?: boolean; // Validation
|
|
35
|
-
unique?: boolean; // Constraint
|
|
36
|
-
lookupEntity?: string; // For lookup fields
|
|
37
|
-
// ... and more options
|
|
38
|
-
}
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install @objectstack/spec
|
|
39
21
|
```
|
|
40
22
|
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
## 📦 Architecture
|
|
24
|
+
|
|
25
|
+
The specification is divided into three protocols:
|
|
26
|
+
|
|
27
|
+
### 1. Data Protocol (`src/data`)
|
|
28
|
+
*Core Business Logic & Data Modeling*
|
|
29
|
+
* `Object`, `Field`, `Validation`
|
|
30
|
+
* `Query` (AST), `Mapping` (ETL)
|
|
31
|
+
* `Permission`, `Sharing`, `Flow`
|
|
32
|
+
|
|
33
|
+
### 2. UI Protocol (`src/ui`)
|
|
34
|
+
*Presentation & Interaction*
|
|
35
|
+
* `App`, `Page`, `View` (Grid/Kanban)
|
|
36
|
+
* `Dashboard` (Widgets), `Report`
|
|
37
|
+
* `Action` (Triggers)
|
|
38
|
+
|
|
39
|
+
### 3. System Protocol (`src/system`)
|
|
40
|
+
*Runtime Configuration & Security*
|
|
41
|
+
* `Manifest` (Config), `Datasource`
|
|
42
|
+
* `Role` (Hierarchy), `Identity` (Auth)
|
|
43
|
+
* `Webhook` (Integration), `Policy` (Compliance)
|
|
44
|
+
|
|
45
|
+
## 📚 Usage
|
|
46
|
+
|
|
47
|
+
### Validation (Runtime)
|
|
48
|
+
|
|
43
49
|
```typescript
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
primaryKey?: string; // Primary key field
|
|
50
|
-
displayField?: string; // Display field for lookups
|
|
51
|
-
// ... and more options
|
|
50
|
+
import { ObjectSchema } from '@objectstack/spec';
|
|
51
|
+
|
|
52
|
+
const result = ObjectSchema.safeParse(userConfig);
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
console.error("Invalid Object definition", result.error);
|
|
52
55
|
}
|
|
53
56
|
```
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
### Type Definitions (Compile Time)
|
|
59
|
+
|
|
57
60
|
```typescript
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
columns?: ViewColumn[]; // Column configuration
|
|
65
|
-
filters?: ViewFilter[]; // Default filters
|
|
66
|
-
sort?: ViewSort[]; // Default sort order
|
|
67
|
-
// ... and more options
|
|
68
|
-
}
|
|
61
|
+
import type { Object, Field } from '@objectstack/spec';
|
|
62
|
+
|
|
63
|
+
const myObject: Object = {
|
|
64
|
+
name: "project_task",
|
|
65
|
+
fields: { ... }
|
|
66
|
+
};
|
|
69
67
|
```
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
### JSON Schema (Tooling)
|
|
70
|
+
The package includes valid JSON Schemas in the `/json-schema` directory.
|
|
71
|
+
These can be used with:
|
|
72
|
+
* [Ajv](https://ajv.js.org/) (High-performance validator)
|
|
73
|
+
* [React Json Schema Form](https://rjsf-team.github.io/) (Auto-forms)
|
|
74
|
+
* VS Code `json.schemas` setting for IntelliSense.
|
|
75
|
+
|
|
76
|
+
## 🛠️ Development
|
|
72
77
|
|
|
73
|
-
###
|
|
78
|
+
### Build & Generate
|
|
74
79
|
|
|
75
80
|
```bash
|
|
76
|
-
|
|
81
|
+
# Generate JSON Schemas + Markdown Docs + Compile TS
|
|
82
|
+
pnpm build
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
###
|
|
85
|
+
### Testing
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
// Import all metamodel types
|
|
83
|
-
import { ObjectEntity, ObjectField, ObjectView, FieldType } from '@objectstack/spec';
|
|
87
|
+
This package includes comprehensive test coverage for all Zod schemas using **Vitest**.
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
```bash
|
|
90
|
+
# Run tests once
|
|
91
|
+
pnpm test
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
# Run tests in watch mode
|
|
94
|
+
pnpm test:watch
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const userEntity: ObjectEntity = {
|
|
95
|
-
name: 'User',
|
|
96
|
-
label: 'User',
|
|
97
|
-
pluralLabel: 'Users',
|
|
98
|
-
description: 'System user account',
|
|
99
|
-
fields: [
|
|
100
|
-
{
|
|
101
|
-
name: 'id',
|
|
102
|
-
label: 'ID',
|
|
103
|
-
type: 'text',
|
|
104
|
-
required: true,
|
|
105
|
-
readonly: true
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'email',
|
|
109
|
-
label: 'Email',
|
|
110
|
-
type: 'email',
|
|
111
|
-
required: true,
|
|
112
|
-
unique: true
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'name',
|
|
116
|
-
label: 'Full Name',
|
|
117
|
-
type: 'text',
|
|
118
|
-
required: true
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: 'role',
|
|
122
|
-
label: 'Role',
|
|
123
|
-
type: 'select',
|
|
124
|
-
required: true,
|
|
125
|
-
options: [
|
|
126
|
-
{ value: 'admin', label: 'Administrator' },
|
|
127
|
-
{ value: 'user', label: 'User' }
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
primaryKey: 'id',
|
|
132
|
-
displayField: 'name'
|
|
133
|
-
};
|
|
96
|
+
# Run tests with coverage report
|
|
97
|
+
pnpm test:coverage
|
|
134
98
|
```
|
|
135
99
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
100
|
+
#### Test Structure
|
|
101
|
+
|
|
102
|
+
Tests are co-located with schema files using the `.test.ts` suffix:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
src/
|
|
106
|
+
├── data/
|
|
107
|
+
│ ├── field.zod.ts # Schema definition
|
|
108
|
+
│ ├── field.test.ts # Tests
|
|
109
|
+
│ ├── object.zod.ts
|
|
110
|
+
│ └── object.test.ts
|
|
111
|
+
├── ui/
|
|
112
|
+
│ ├── view.zod.ts
|
|
113
|
+
│ └── view.test.ts
|
|
114
|
+
└── system/
|
|
115
|
+
├── manifest.zod.ts
|
|
116
|
+
└── manifest.test.ts
|
|
141
117
|
```
|
|
142
118
|
|
|
143
|
-
|
|
119
|
+
#### Test Coverage
|
|
144
120
|
|
|
145
|
-
|
|
121
|
+
Each test file includes:
|
|
122
|
+
* **Schema Validation Tests**: Verify valid inputs pass and invalid inputs fail
|
|
123
|
+
* **Default Value Tests**: Ensure default values are applied correctly
|
|
124
|
+
* **Type Tests**: Test discriminated unions and type narrowing
|
|
125
|
+
* **Constraint Tests**: Validate naming conventions (snake_case), regex patterns, enums
|
|
126
|
+
* **Real-World Examples**: Complete, realistic examples from CRM, HR, Sales domains
|
|
146
127
|
|
|
147
|
-
|
|
148
|
-
- **Strict Types, No Logic**: This repository contains only type definitions
|
|
149
|
-
- **Documentation as Code**: Every interface property has TSDoc comments for IntelliSense
|
|
150
|
-
- **Universal Compatibility**: Pure TypeScript with no platform-specific dependencies
|
|
128
|
+
**Current Coverage**: 263 tests across 13 test files with 100% coverage for tested schemas.
|
|
151
129
|
|
|
152
|
-
|
|
130
|
+
#### Writing Tests
|
|
153
131
|
|
|
154
|
-
|
|
132
|
+
When adding new schemas, follow these patterns:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { describe, it, expect } from 'vitest';
|
|
136
|
+
import { YourSchema } from './your-schema.zod';
|
|
137
|
+
|
|
138
|
+
describe('YourSchema', () => {
|
|
139
|
+
it('should accept valid data', () => {
|
|
140
|
+
const valid = { /* valid data */ };
|
|
141
|
+
expect(() => YourSchema.parse(valid)).not.toThrow();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should reject invalid data', () => {
|
|
145
|
+
const invalid = { /* invalid data */ };
|
|
146
|
+
expect(() => YourSchema.parse(invalid)).toThrow();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should apply defaults', () => {
|
|
150
|
+
const result = YourSchema.parse({ /* minimal data */ });
|
|
151
|
+
expect(result.someField).toBe('default-value');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Directory Structure
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
packages/spec/
|
|
160
|
+
├── src/ # Source Truth (Zod)
|
|
161
|
+
│ ├── data/ # ObjectQL Protocol
|
|
162
|
+
│ ├── ui/ # ObjectUI Protocol
|
|
163
|
+
│ └── system/ # ObjectOS Protocol
|
|
164
|
+
├── json-schema/ # Auto-generated (npm run gen:schema)
|
|
165
|
+
├── dist/ # Compiled JS/D.TS
|
|
166
|
+
└── vitest.config.ts # Test configuration
|
|
167
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* AI Model Configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare const AIModelConfigSchema: z.ZodObject<{
|
|
6
|
+
provider: z.ZodDefault<z.ZodEnum<["openai", "azure_openai", "anthropic", "local"]>>;
|
|
7
|
+
model: z.ZodString;
|
|
8
|
+
temperature: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
provider: "openai" | "azure_openai" | "anthropic" | "local";
|
|
13
|
+
model: string;
|
|
14
|
+
temperature: number;
|
|
15
|
+
maxTokens?: number | undefined;
|
|
16
|
+
topP?: number | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
model: string;
|
|
19
|
+
provider?: "openai" | "azure_openai" | "anthropic" | "local" | undefined;
|
|
20
|
+
temperature?: number | undefined;
|
|
21
|
+
maxTokens?: number | undefined;
|
|
22
|
+
topP?: number | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* AI Tool Definition
|
|
26
|
+
* References to Actions, Flows, or Objects available to the Agent.
|
|
27
|
+
*/
|
|
28
|
+
export declare const AIToolSchema: z.ZodObject<{
|
|
29
|
+
type: z.ZodEnum<["action", "flow", "query", "vector_search"]>;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
description: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* AI Knowledge Base
|
|
43
|
+
* RAG configuration.
|
|
44
|
+
*/
|
|
45
|
+
export declare const AIKnowledgeSchema: z.ZodObject<{
|
|
46
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
47
|
+
indexes: z.ZodArray<z.ZodString, "many">;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
indexes: string[];
|
|
50
|
+
topics: string[];
|
|
51
|
+
}, {
|
|
52
|
+
indexes: string[];
|
|
53
|
+
topics: string[];
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* AI Agent Schema
|
|
57
|
+
* Definition of an autonomous agent specialized for a domain.
|
|
58
|
+
*/
|
|
59
|
+
export declare const AgentSchema: z.ZodObject<{
|
|
60
|
+
/** Identity */
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
label: z.ZodString;
|
|
63
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
64
|
+
role: z.ZodString;
|
|
65
|
+
/** Cognition */
|
|
66
|
+
instructions: z.ZodString;
|
|
67
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
provider: z.ZodDefault<z.ZodEnum<["openai", "azure_openai", "anthropic", "local"]>>;
|
|
69
|
+
model: z.ZodString;
|
|
70
|
+
temperature: z.ZodDefault<z.ZodNumber>;
|
|
71
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
provider: "openai" | "azure_openai" | "anthropic" | "local";
|
|
75
|
+
model: string;
|
|
76
|
+
temperature: number;
|
|
77
|
+
maxTokens?: number | undefined;
|
|
78
|
+
topP?: number | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
model: string;
|
|
81
|
+
provider?: "openai" | "azure_openai" | "anthropic" | "local" | undefined;
|
|
82
|
+
temperature?: number | undefined;
|
|
83
|
+
maxTokens?: number | undefined;
|
|
84
|
+
topP?: number | undefined;
|
|
85
|
+
}>>;
|
|
86
|
+
/** Capabilities */
|
|
87
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
type: z.ZodEnum<["action", "flow", "query", "vector_search"]>;
|
|
89
|
+
name: z.ZodString;
|
|
90
|
+
description: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
93
|
+
name: string;
|
|
94
|
+
description?: string | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
97
|
+
name: string;
|
|
98
|
+
description?: string | undefined;
|
|
99
|
+
}>, "many">>;
|
|
100
|
+
knowledge: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
102
|
+
indexes: z.ZodArray<z.ZodString, "many">;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
indexes: string[];
|
|
105
|
+
topics: string[];
|
|
106
|
+
}, {
|
|
107
|
+
indexes: string[];
|
|
108
|
+
topics: string[];
|
|
109
|
+
}>>;
|
|
110
|
+
/** Interface */
|
|
111
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
access: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
label: string;
|
|
115
|
+
name: string;
|
|
116
|
+
active: boolean;
|
|
117
|
+
role: string;
|
|
118
|
+
instructions: string;
|
|
119
|
+
avatar?: string | undefined;
|
|
120
|
+
model?: {
|
|
121
|
+
provider: "openai" | "azure_openai" | "anthropic" | "local";
|
|
122
|
+
model: string;
|
|
123
|
+
temperature: number;
|
|
124
|
+
maxTokens?: number | undefined;
|
|
125
|
+
topP?: number | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
tools?: {
|
|
128
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
129
|
+
name: string;
|
|
130
|
+
description?: string | undefined;
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
knowledge?: {
|
|
133
|
+
indexes: string[];
|
|
134
|
+
topics: string[];
|
|
135
|
+
} | undefined;
|
|
136
|
+
access?: string[] | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
label: string;
|
|
139
|
+
name: string;
|
|
140
|
+
role: string;
|
|
141
|
+
instructions: string;
|
|
142
|
+
avatar?: string | undefined;
|
|
143
|
+
active?: boolean | undefined;
|
|
144
|
+
model?: {
|
|
145
|
+
model: string;
|
|
146
|
+
provider?: "openai" | "azure_openai" | "anthropic" | "local" | undefined;
|
|
147
|
+
temperature?: number | undefined;
|
|
148
|
+
maxTokens?: number | undefined;
|
|
149
|
+
topP?: number | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
tools?: {
|
|
152
|
+
type: "action" | "flow" | "query" | "vector_search";
|
|
153
|
+
name: string;
|
|
154
|
+
description?: string | undefined;
|
|
155
|
+
}[] | undefined;
|
|
156
|
+
knowledge?: {
|
|
157
|
+
indexes: string[];
|
|
158
|
+
topics: string[];
|
|
159
|
+
} | undefined;
|
|
160
|
+
access?: string[] | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
export type Agent = z.infer<typeof AgentSchema>;
|
|
163
|
+
export type AITool = z.infer<typeof AIToolSchema>;
|
|
164
|
+
//# sourceMappingURL=agent.zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.zod.d.ts","sourceRoot":"","sources":["../../src/ai/agent.zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;EAIvB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB,eAAe;;;;;IAMf,gBAAgB;;;;;;;;;;;;;;;;;;;;;IAIhB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;IAInB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAChD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentSchema = exports.AIKnowledgeSchema = exports.AIToolSchema = exports.AIModelConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* AI Model Configuration
|
|
7
|
+
*/
|
|
8
|
+
exports.AIModelConfigSchema = zod_1.z.object({
|
|
9
|
+
provider: zod_1.z.enum(['openai', 'azure_openai', 'anthropic', 'local']).default('openai'),
|
|
10
|
+
model: zod_1.z.string().describe('Model name (e.g. gpt-4, claude-3-opus)'),
|
|
11
|
+
temperature: zod_1.z.number().min(0).max(2).default(0.7),
|
|
12
|
+
maxTokens: zod_1.z.number().optional(),
|
|
13
|
+
topP: zod_1.z.number().optional(),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* AI Tool Definition
|
|
17
|
+
* References to Actions, Flows, or Objects available to the Agent.
|
|
18
|
+
*/
|
|
19
|
+
exports.AIToolSchema = zod_1.z.object({
|
|
20
|
+
type: zod_1.z.enum(['action', 'flow', 'query', 'vector_search']),
|
|
21
|
+
name: zod_1.z.string().describe('Reference name (Action Name, Flow Name)'),
|
|
22
|
+
description: zod_1.z.string().optional().describe('Override description for the LLM'),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* AI Knowledge Base
|
|
26
|
+
* RAG configuration.
|
|
27
|
+
*/
|
|
28
|
+
exports.AIKnowledgeSchema = zod_1.z.object({
|
|
29
|
+
topics: zod_1.z.array(zod_1.z.string()).describe('Topics/Tags to recruit knowledge from'),
|
|
30
|
+
indexes: zod_1.z.array(zod_1.z.string()).describe('Vector Store Indexes'),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* AI Agent Schema
|
|
34
|
+
* Definition of an autonomous agent specialized for a domain.
|
|
35
|
+
*/
|
|
36
|
+
exports.AgentSchema = zod_1.z.object({
|
|
37
|
+
/** Identity */
|
|
38
|
+
name: zod_1.z.string().regex(/^[a-z_][a-z0-9_]*$/).describe('Agent unique identifier'),
|
|
39
|
+
label: zod_1.z.string().describe('Agent display name'),
|
|
40
|
+
avatar: zod_1.z.string().optional(),
|
|
41
|
+
role: zod_1.z.string().describe('The persona/role (e.g. "Senior Support Engineer")'),
|
|
42
|
+
/** Cognition */
|
|
43
|
+
instructions: zod_1.z.string().describe('System Prompt / Prime Directives'),
|
|
44
|
+
model: exports.AIModelConfigSchema.optional(),
|
|
45
|
+
/** Capabilities */
|
|
46
|
+
tools: zod_1.z.array(exports.AIToolSchema).optional().describe('Available tools'),
|
|
47
|
+
knowledge: exports.AIKnowledgeSchema.optional().describe('RAG access'),
|
|
48
|
+
/** Interface */
|
|
49
|
+
active: zod_1.z.boolean().default(true),
|
|
50
|
+
access: zod_1.z.array(zod_1.z.string()).optional().describe('Who can chat with this agent'),
|
|
51
|
+
});
|