@origostudio/core 0.0.40

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +365 -0
  2. package/README.md +11 -0
  3. package/package.json +25 -0
  4. package/package.json.bak +25 -0
  5. package/src/extension-api/extension-manager.d.ts +35 -0
  6. package/src/extension-api/extension-manager.js +300 -0
  7. package/src/extension-api/extension-manager.js.map +1 -0
  8. package/src/extension-api/index.d.ts +2 -0
  9. package/src/extension-api/index.js +6 -0
  10. package/src/extension-api/index.js.map +1 -0
  11. package/src/extension-api/types.d.ts +34 -0
  12. package/src/extension-api/types.js +3 -0
  13. package/src/extension-api/types.js.map +1 -0
  14. package/src/index.d.ts +3 -0
  15. package/src/index.js +7 -0
  16. package/src/index.js.map +1 -0
  17. package/src/schemas/capability.schema.json +104 -0
  18. package/src/schemas/contract.schema.json +52 -0
  19. package/src/schemas/domain.schema.json +47 -0
  20. package/src/schemas/entity.schema.json +72 -0
  21. package/src/schemas/extension.schema.json +39 -0
  22. package/src/schemas/permission.schema.json +21 -0
  23. package/src/types/ast.d.ts +17 -0
  24. package/src/types/ast.js +3 -0
  25. package/src/types/ast.js.map +1 -0
  26. package/src/types/domain.d.ts +101 -0
  27. package/src/types/domain.js +8 -0
  28. package/src/types/domain.js.map +1 -0
  29. package/src/types/validation.d.ts +12 -0
  30. package/src/types/validation.js +16 -0
  31. package/src/types/validation.js.map +1 -0
  32. package/src/validator/ast-validator.d.ts +11 -0
  33. package/src/validator/ast-validator.js +388 -0
  34. package/src/validator/ast-validator.js.map +1 -0
  35. package/src/validator/index.d.ts +23 -0
  36. package/src/validator/index.js +143 -0
  37. package/src/validator/index.js.map +1 -0
  38. package/src/validator/serializer.d.ts +11 -0
  39. package/src/validator/serializer.js +99 -0
  40. package/src/validator/serializer.js.map +1 -0
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/entity.schema.json",
4
+ "title": "Entity",
5
+ "description": "BADL Entity Definition",
6
+ "type": "object",
7
+ "$defs": {
8
+ "field": {
9
+ "type": "object",
10
+ "properties": {
11
+ "id": {
12
+ "type": "string"
13
+ },
14
+ "name": {
15
+ "type": "string"
16
+ },
17
+ "type": {
18
+ "type": "string",
19
+ "enum": ["string", "boolean", "date", "number", "array", "object"]
20
+ },
21
+ "itemType": {
22
+ "type": "string"
23
+ },
24
+ "label": {
25
+ "type": "string"
26
+ },
27
+ "references": {
28
+ "type": "string"
29
+ },
30
+ "validation": {
31
+ "type": "array",
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ },
36
+ "metadata_path": {
37
+ "type": "string"
38
+ },
39
+ "fields": {
40
+ "type": "array",
41
+ "items": {
42
+ "$ref": "#/$defs/field"
43
+ }
44
+ }
45
+ },
46
+ "required": ["id", "name", "type", "label", "validation", "metadata_path"],
47
+ "additionalProperties": false
48
+ }
49
+ },
50
+ "properties": {
51
+ "id": {
52
+ "type": "string"
53
+ },
54
+ "name": {
55
+ "type": "string"
56
+ },
57
+ "implements": {
58
+ "type": "array",
59
+ "items": {
60
+ "type": "string"
61
+ }
62
+ },
63
+ "fields": {
64
+ "type": "array",
65
+ "items": {
66
+ "$ref": "#/$defs/field"
67
+ }
68
+ }
69
+ },
70
+ "required": ["id", "name", "fields"],
71
+ "additionalProperties": false
72
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/extension.schema.json",
4
+ "title": "Extension",
5
+ "description": "BADL Extension Definition",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "minLength": 1,
11
+ "pattern": "^[a-zA-Z0-9_-]+$"
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "version": {
18
+ "type": "string",
19
+ "minLength": 1
20
+ },
21
+ "extension_type": {
22
+ "type": "string",
23
+ "minLength": 1
24
+ },
25
+ "implements": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "string"
29
+ },
30
+ "minItems": 1
31
+ },
32
+ "plugin_version_range": {
33
+ "type": "string",
34
+ "minLength": 1
35
+ }
36
+ },
37
+ "required": ["id", "name", "version", "extension_type", "implements", "plugin_version_range"],
38
+ "additionalProperties": false
39
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/permission.schema.json",
4
+ "title": "Permission",
5
+ "description": "BADL Role-Based Permission Definition",
6
+ "type": "object",
7
+ "properties": {
8
+ "role": {
9
+ "type": "string",
10
+ "description": "The role required for this permission",
11
+ "minLength": 1
12
+ },
13
+ "access": {
14
+ "type": "string",
15
+ "enum": ["grant", "deny"],
16
+ "default": "grant"
17
+ }
18
+ },
19
+ "required": ["role"],
20
+ "additionalProperties": false
21
+ }
@@ -0,0 +1,17 @@
1
+ import { Domain } from './domain';
2
+ export interface CanonicalAST {
3
+ schemaVersion: string;
4
+ domains: Domain[];
5
+ }
6
+ export interface ASTNode {
7
+ id: string;
8
+ type: string;
9
+ props?: Record<string, unknown>;
10
+ children?: ASTNode[];
11
+ }
12
+ export interface InteractionContract<TProps = Record<string, unknown>> {
13
+ id: string;
14
+ type: string;
15
+ props: TProps;
16
+ children?: InteractionContract[];
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../../../packages/core/src/types/ast.ts"],"names":[],"mappings":""}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+ /**
7
+ * BADL Capability Definition
8
+ */
9
+ export type Capability = Capability1 & Capability2;
10
+ export type Capability1 = {
11
+ [k: string]: unknown;
12
+ };
13
+ /**
14
+ * BADL Domain Definition
15
+ */
16
+ export interface Domain {
17
+ id: string;
18
+ name: string;
19
+ version: string;
20
+ domain: string;
21
+ entities: Entity[];
22
+ capabilities?: Capability[];
23
+ contracts?: Contract[];
24
+ extensions?: Extension[];
25
+ }
26
+ /**
27
+ * BADL Entity Definition
28
+ */
29
+ export interface EntityField {
30
+ id: string;
31
+ name: string;
32
+ type: 'string' | 'boolean' | 'date' | 'number' | 'array' | 'object';
33
+ itemType?: string;
34
+ label: string;
35
+ references?: string;
36
+ validation: string[];
37
+ metadata_path: string;
38
+ fields?: EntityField[];
39
+ }
40
+ export interface Entity {
41
+ id: string;
42
+ name: string;
43
+ implements?: string[];
44
+ fields: EntityField[];
45
+ }
46
+ export interface Capability2 {
47
+ id: string;
48
+ /**
49
+ * Strict vocabulary of core capability verbs
50
+ */
51
+ name: 'Create' | 'Read' | 'Update' | 'Delete' | 'List';
52
+ description: string;
53
+ type: 'Command' | 'Query';
54
+ /**
55
+ * Target entity for this capability
56
+ */
57
+ entityId: string;
58
+ outcome_ref: string[];
59
+ preconditions: string[];
60
+ postconditions: string[];
61
+ permissions: Permission[];
62
+ risk_level: 'low' | 'medium' | 'high' | 'critical';
63
+ interaction_contract_ref?: string;
64
+ async: boolean;
65
+ }
66
+ /**
67
+ * BADL Role-Based Permission Definition
68
+ */
69
+ export interface Permission {
70
+ /**
71
+ * The role required for this permission
72
+ */
73
+ role: string;
74
+ access?: 'grant' | 'deny';
75
+ }
76
+ /**
77
+ * BADL Contract Definition
78
+ */
79
+ export interface Contract {
80
+ id: string;
81
+ name: string;
82
+ requiredFields: {
83
+ name: string;
84
+ type: 'string' | 'boolean' | 'date' | 'number' | 'array' | 'object';
85
+ }[];
86
+ requiredCapabilities: {
87
+ name: 'Create' | 'Read' | 'Update' | 'Delete' | 'List';
88
+ type: 'Command' | 'Query';
89
+ }[];
90
+ }
91
+ /**
92
+ * BADL Extension Definition
93
+ */
94
+ export interface Extension {
95
+ id: string;
96
+ name: string;
97
+ version: string;
98
+ extension_type: string;
99
+ implements: string[];
100
+ plugin_version_range: string;
101
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.js","sourceRoot":"","sources":["../../../../../packages/core/src/types/domain.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
@@ -0,0 +1,12 @@
1
+ export interface ValidationError {
2
+ type: string;
3
+ message: string;
4
+ path?: string;
5
+ line?: number;
6
+ column?: number;
7
+ }
8
+ export type ASTErrorType = 'CONTRACT_BREACH' | 'INVALID_PERMISSION' | 'UNSECURED_CAPABILITY' | 'MISSING_MANIFEST_VERSION' | 'VERSION_MISMATCH';
9
+ export declare class ASTValidationError extends Error {
10
+ errors: ValidationError[];
11
+ constructor(errors: ValidationError[], message?: string);
12
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ASTValidationError = void 0;
4
+ class ASTValidationError extends Error {
5
+ errors;
6
+ constructor(errors, message = 'AST Validation Failed') {
7
+ const detailedMessage = errors.length > 0 ? `${message}: ${errors.map(e => e.message).join(' | ')}` : message;
8
+ super(detailedMessage);
9
+ this.name = 'ASTValidationError';
10
+ this.errors = errors;
11
+ // Fix prototype chain for instanceof when extending built-in Error in TS
12
+ Object.setPrototypeOf(this, ASTValidationError.prototype);
13
+ }
14
+ }
15
+ exports.ASTValidationError = ASTValidationError;
16
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../packages/core/src/types/validation.ts"],"names":[],"mappings":";;;AAeA,MAAa,kBAAmB,SAAQ,KAAK;IACpC,MAAM,CAAoB;IAEjC,YAAY,MAAyB,EAAE,OAAO,GAAG,uBAAuB;QACtE,MAAM,eAAe,GACnB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACxF,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF;AAbD,gDAaC"}
@@ -0,0 +1,11 @@
1
+ import { CanonicalAST } from '../types/ast';
2
+ import { ValidationError } from '../types/validation';
3
+ export declare const MAX_AST_DEPTH = 250;
4
+ /**
5
+ * Performs deep semantic validation on the Canonical AST before downstream code generation.
6
+ * Specifically checks for cyclic entity relationships and missing references.
7
+ *
8
+ * @param ast The Canonical AST to validate
9
+ * @returns {ValidationError[]} Array of validation errors, or empty array if valid.
10
+ */
11
+ export declare function validateAST(ast: CanonicalAST, localManifest?: Record<string, string>): ValidationError[];