@origostudio/origo-design 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.
Files changed (209) hide show
  1. package/.editorconfig +13 -0
  2. package/.gitattributes +22 -0
  3. package/.perf-baseline.json +12 -0
  4. package/.prettierignore +13 -0
  5. package/.prettierrc +10 -0
  6. package/.vscode/extensions.json +3 -0
  7. package/BRANCH-PROTECTION.md +25 -0
  8. package/CHANGELOG.md +292 -0
  9. package/LICENSE +21 -0
  10. package/README.md +11 -0
  11. package/commitlint.config.js +6 -0
  12. package/dist/packages/cli/CHANGELOG.md +92 -0
  13. package/dist/packages/cli/README.md +11 -0
  14. package/dist/packages/cli/package.json +16 -0
  15. package/dist/packages/cli/package.json.bak +16 -0
  16. package/dist/packages/cli/src/commands/generate/entity.d.ts +2 -0
  17. package/dist/packages/cli/src/commands/generate/entity.js +24 -0
  18. package/dist/packages/cli/src/commands/generate/entity.js.map +1 -0
  19. package/dist/packages/cli/src/commands/generate/index.d.ts +2 -0
  20. package/dist/packages/cli/src/commands/generate/index.js +30 -0
  21. package/dist/packages/cli/src/commands/generate/index.js.map +1 -0
  22. package/dist/packages/cli/src/commands/init.d.ts +5 -0
  23. package/dist/packages/cli/src/commands/init.js +27 -0
  24. package/dist/packages/cli/src/commands/init.js.map +1 -0
  25. package/dist/packages/cli/src/commands/new.d.ts +2 -0
  26. package/dist/packages/cli/src/commands/new.js +24 -0
  27. package/dist/packages/cli/src/commands/new.js.map +1 -0
  28. package/dist/packages/cli/src/commands/validate.d.ts +2 -0
  29. package/dist/packages/cli/src/commands/validate.js +50 -0
  30. package/dist/packages/cli/src/commands/validate.js.map +1 -0
  31. package/dist/packages/cli/src/index.d.ts +11 -0
  32. package/dist/packages/cli/src/index.js +15 -0
  33. package/dist/packages/cli/src/index.js.map +1 -0
  34. package/dist/packages/cli/src/lib/cli.d.ts +1 -0
  35. package/dist/packages/cli/src/lib/cli.js +7 -0
  36. package/dist/packages/cli/src/lib/cli.js.map +1 -0
  37. package/dist/packages/cli/src/lib/generator.d.ts +16 -0
  38. package/dist/packages/cli/src/lib/generator.js +165 -0
  39. package/dist/packages/cli/src/lib/generator.js.map +1 -0
  40. package/dist/packages/cli/src/lib/scaffolding.d.ts +5 -0
  41. package/dist/packages/cli/src/lib/scaffolding.js +87 -0
  42. package/dist/packages/cli/src/lib/scaffolding.js.map +1 -0
  43. package/dist/packages/cli/src/lib/validation.d.ts +4 -0
  44. package/dist/packages/cli/src/lib/validation.js +191 -0
  45. package/dist/packages/cli/src/lib/validation.js.map +1 -0
  46. package/dist/packages/cli/src/main.d.ts +4 -0
  47. package/dist/packages/cli/src/main.js +38 -0
  48. package/dist/packages/cli/src/main.js.map +1 -0
  49. package/dist/packages/cli/src/templates/entity.json +6 -0
  50. package/dist/packages/cli/src/templates/extension.json +8 -0
  51. package/dist/packages/cli/src/templates/index.d.ts +29 -0
  52. package/dist/packages/cli/src/templates/index.js +61 -0
  53. package/dist/packages/cli/src/templates/index.js.map +1 -0
  54. package/dist/packages/cli/src/templates/origo.json +16 -0
  55. package/dist/packages/cli/src/utils/errors.d.ts +15 -0
  56. package/dist/packages/cli/src/utils/errors.js +58 -0
  57. package/dist/packages/cli/src/utils/errors.js.map +1 -0
  58. package/dist/packages/core/CHANGELOG.md +275 -0
  59. package/dist/packages/core/README.md +11 -0
  60. package/dist/packages/core/package.json +21 -0
  61. package/dist/packages/core/package.json.bak +21 -0
  62. package/dist/packages/core/src/extension-api/extension-manager.d.ts +35 -0
  63. package/dist/packages/core/src/extension-api/extension-manager.js +300 -0
  64. package/dist/packages/core/src/extension-api/extension-manager.js.map +1 -0
  65. package/dist/packages/core/src/extension-api/index.d.ts +2 -0
  66. package/dist/packages/core/src/extension-api/index.js +6 -0
  67. package/dist/packages/core/src/extension-api/index.js.map +1 -0
  68. package/dist/packages/core/src/extension-api/types.d.ts +34 -0
  69. package/dist/packages/core/src/extension-api/types.js +3 -0
  70. package/dist/packages/core/src/extension-api/types.js.map +1 -0
  71. package/dist/packages/core/src/index.d.ts +3 -0
  72. package/dist/packages/core/src/index.js +7 -0
  73. package/dist/packages/core/src/index.js.map +1 -0
  74. package/dist/packages/core/src/schemas/capability.schema.json +104 -0
  75. package/dist/packages/core/src/schemas/contract.schema.json +52 -0
  76. package/dist/packages/core/src/schemas/domain.schema.json +47 -0
  77. package/dist/packages/core/src/schemas/entity.schema.json +72 -0
  78. package/dist/packages/core/src/schemas/extension.schema.json +39 -0
  79. package/dist/packages/core/src/schemas/permission.schema.json +21 -0
  80. package/dist/packages/core/src/types/ast.d.ts +17 -0
  81. package/dist/packages/core/src/types/ast.js +3 -0
  82. package/dist/packages/core/src/types/ast.js.map +1 -0
  83. package/dist/packages/core/src/types/domain.d.ts +101 -0
  84. package/dist/packages/core/src/types/domain.js +8 -0
  85. package/dist/packages/core/src/types/domain.js.map +1 -0
  86. package/dist/packages/core/src/types/validation.d.ts +12 -0
  87. package/dist/packages/core/src/types/validation.js +16 -0
  88. package/dist/packages/core/src/types/validation.js.map +1 -0
  89. package/dist/packages/core/src/validator/ast-validator.d.ts +11 -0
  90. package/dist/packages/core/src/validator/ast-validator.js +388 -0
  91. package/dist/packages/core/src/validator/ast-validator.js.map +1 -0
  92. package/dist/packages/core/src/validator/index.d.ts +23 -0
  93. package/dist/packages/core/src/validator/index.js +143 -0
  94. package/dist/packages/core/src/validator/index.js.map +1 -0
  95. package/dist/packages/core/src/validator/serializer.d.ts +11 -0
  96. package/dist/packages/core/src/validator/serializer.js +99 -0
  97. package/dist/packages/core/src/validator/serializer.js.map +1 -0
  98. package/eslint.config.js +114 -0
  99. package/generate_prompts.js +19 -0
  100. package/jest.config.ts +5 -0
  101. package/jest.preset.js +3 -0
  102. package/nx.json +169 -0
  103. package/package.json +115 -0
  104. package/packages/angular-renderer/CHANGELOG.md +274 -0
  105. package/packages/angular-renderer/README.md +11 -0
  106. package/packages/angular-renderer/package.json +20 -0
  107. package/packages/angular-renderer/playwright-ct.config.ts +23 -0
  108. package/packages/angular-renderer/src/adapters/web/adapter.ts +145 -0
  109. package/packages/angular-renderer/src/adapters/web/experience-adapter.service.ts +21 -0
  110. package/packages/angular-renderer/src/components/primitives/button/button.component.html +9 -0
  111. package/packages/angular-renderer/src/components/primitives/button/button.component.pw.ts +19 -0
  112. package/packages/angular-renderer/src/components/primitives/button/button.component.scss +31 -0
  113. package/packages/angular-renderer/src/components/primitives/button/button.component.ts +67 -0
  114. package/packages/angular-renderer/src/components/primitives/primitives.a11y.pw.ts +33 -0
  115. package/packages/angular-renderer/src/components/primitives/text-input/text-input.component.html +10 -0
  116. package/packages/angular-renderer/src/components/primitives/text-input/text-input.component.pw.ts +29 -0
  117. package/packages/angular-renderer/src/components/primitives/text-input/text-input.component.scss +42 -0
  118. package/packages/angular-renderer/src/components/primitives/text-input/text-input.component.ts +84 -0
  119. package/packages/angular-renderer/src/components/primitives/vbox/vbox.component.html +2 -0
  120. package/packages/angular-renderer/src/components/primitives/vbox/vbox.component.pw.ts +19 -0
  121. package/packages/angular-renderer/src/components/primitives/vbox/vbox.component.scss +5 -0
  122. package/packages/angular-renderer/src/components/primitives/vbox/vbox.component.ts +74 -0
  123. package/packages/angular-renderer/src/index.ts +7 -0
  124. package/packages/angular-renderer/src/lib/renderer.component.ts +118 -0
  125. package/packages/angular-renderer/src/lib/renderer.tokens.ts +9 -0
  126. package/packages/angular-renderer/src/lib/test-utils.ts +26 -0
  127. package/packages/angular-renderer/src/lib/theme.provider.ts +83 -0
  128. package/packages/angular-renderer/src/test-setup.ts +8 -0
  129. package/packages/cli/CHANGELOG.md +92 -0
  130. package/packages/cli/README.md +11 -0
  131. package/packages/cli/package.json +16 -0
  132. package/packages/cli/src/commands/generate/entity.ts +20 -0
  133. package/packages/cli/src/commands/generate/index.ts +28 -0
  134. package/packages/cli/src/commands/init.ts +28 -0
  135. package/packages/cli/src/commands/new.ts +22 -0
  136. package/packages/cli/src/commands/validate.ts +47 -0
  137. package/packages/cli/src/index.ts +11 -0
  138. package/packages/cli/src/lib/cli.ts +3 -0
  139. package/packages/cli/src/lib/generator.ts +181 -0
  140. package/packages/cli/src/lib/scaffolding.ts +104 -0
  141. package/packages/cli/src/lib/validation.ts +218 -0
  142. package/packages/cli/src/main.ts +38 -0
  143. package/packages/cli/src/templates/entity.json +6 -0
  144. package/packages/cli/src/templates/extension.json +8 -0
  145. package/packages/cli/src/templates/index.ts +94 -0
  146. package/packages/cli/src/templates/origo.json +16 -0
  147. package/packages/cli/src/utils/errors.ts +80 -0
  148. package/packages/core/CHANGELOG.md +275 -0
  149. package/packages/core/README.md +11 -0
  150. package/packages/core/package-lock.json +1035 -0
  151. package/packages/core/package.json +21 -0
  152. package/packages/core/scripts/generate-types.ts +23 -0
  153. package/packages/core/src/extension-api/extension-manager.ts +378 -0
  154. package/packages/core/src/extension-api/index.ts +2 -0
  155. package/packages/core/src/extension-api/types.ts +37 -0
  156. package/packages/core/src/index.ts +3 -0
  157. package/packages/core/src/schemas/__fixtures__/target-page.json +222 -0
  158. package/packages/core/src/schemas/capability.schema.json +104 -0
  159. package/packages/core/src/schemas/contract.schema.json +52 -0
  160. package/packages/core/src/schemas/domain.schema.json +47 -0
  161. package/packages/core/src/schemas/entity.schema.json +72 -0
  162. package/packages/core/src/schemas/extension.schema.json +39 -0
  163. package/packages/core/src/schemas/permission.schema.json +21 -0
  164. package/packages/core/src/types/ast.ts +20 -0
  165. package/packages/core/src/types/domain.ts +105 -0
  166. package/packages/core/src/types/validation.ts +29 -0
  167. package/packages/core/src/validator/ast-validator.ts +406 -0
  168. package/packages/core/src/validator/index.ts +207 -0
  169. package/packages/core/src/validator/serializer.ts +120 -0
  170. package/packages/core/test/fixtures/target-page.json +87 -0
  171. package/packages/design-tokens/CHANGELOG.md +273 -0
  172. package/packages/design-tokens/README.md +11 -0
  173. package/packages/design-tokens/package.json +25 -0
  174. package/packages/design-tokens/src/build.ts +97 -0
  175. package/packages/design-tokens/src/compile.ts +60 -0
  176. package/packages/design-tokens/src/index.ts +7 -0
  177. package/packages/design-tokens/src/runtime/index.ts +2 -0
  178. package/packages/design-tokens/src/runtime/theme-fetcher.ts +90 -0
  179. package/packages/design-tokens/src/runtime/theme-injector.ts +149 -0
  180. package/packages/design-tokens/src/schemas/base-tokens.schema.json +127 -0
  181. package/packages/design-tokens/src/schemas/semantic-tokens.schema.json +52 -0
  182. package/packages/design-tokens/src/tokens/base.json +46 -0
  183. package/packages/design-tokens/src/tokens/semantic.json +33 -0
  184. package/packages/playground/CHANGELOG.md +12 -0
  185. package/packages/playground/package.json +10 -0
  186. package/packages/playground/public/favicon.ico +0 -0
  187. package/packages/playground/src/app/app.component.html +1 -0
  188. package/packages/playground/src/app/app.component.scss +4 -0
  189. package/packages/playground/src/app/app.component.ts +13 -0
  190. package/packages/playground/src/app/app.config.ts +9 -0
  191. package/packages/playground/src/editor/badl-editor.component.html +1 -0
  192. package/packages/playground/src/editor/badl-editor.component.scss +10 -0
  193. package/packages/playground/src/editor/badl-editor.component.ts +57 -0
  194. package/packages/playground/src/editor/editor.worker.ts +1 -0
  195. package/packages/playground/src/editor/json.worker.ts +1 -0
  196. package/packages/playground/src/editor/monaco-environment.ts +11 -0
  197. package/packages/playground/src/editor/schema-registry.ts +30 -0
  198. package/packages/playground/src/index.html +13 -0
  199. package/packages/playground/src/main.ts +5 -0
  200. package/packages/playground/src/schemas/capability.schema.json +104 -0
  201. package/packages/playground/src/schemas/contract.schema.json +52 -0
  202. package/packages/playground/src/schemas/domain.schema.json +47 -0
  203. package/packages/playground/src/schemas/entity.schema.json +72 -0
  204. package/packages/playground/src/schemas/extension.schema.json +39 -0
  205. package/packages/playground/src/schemas/permission.schema.json +21 -0
  206. package/packages/playground/src/styles.scss +8 -0
  207. package/packages/playground/src/test-setup.ts +146 -0
  208. package/packages/playground/vite.config.ts +12 -0
  209. package/packages/playground/vitest.config.mjs +24 -0
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/capability.schema.json",
4
+ "title": "Capability",
5
+ "description": "BADL Capability Definition",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "minLength": 1
11
+ },
12
+ "name": {
13
+ "type": "string",
14
+ "enum": ["Create", "Read", "Update", "Delete", "List"],
15
+ "description": "Strict vocabulary of core capability verbs"
16
+ },
17
+ "description": {
18
+ "type": "string"
19
+ },
20
+ "type": {
21
+ "type": "string",
22
+ "enum": ["Command", "Query"]
23
+ },
24
+ "entityId": {
25
+ "type": "string",
26
+ "minLength": 1,
27
+ "description": "Target entity for this capability"
28
+ },
29
+ "outcome_ref": {
30
+ "type": "array",
31
+ "items": {
32
+ "type": "string"
33
+ }
34
+ },
35
+ "preconditions": {
36
+ "type": "array",
37
+ "items": {
38
+ "type": "string"
39
+ }
40
+ },
41
+ "postconditions": {
42
+ "type": "array",
43
+ "items": {
44
+ "type": "string"
45
+ }
46
+ },
47
+ "permissions": {
48
+ "type": "array",
49
+ "items": {
50
+ "$ref": "permission.schema.json"
51
+ }
52
+ },
53
+ "risk_level": {
54
+ "type": "string",
55
+ "enum": ["low", "medium", "high", "critical"]
56
+ },
57
+ "interaction_contract_ref": {
58
+ "type": "string"
59
+ },
60
+ "async": {
61
+ "type": "boolean"
62
+ }
63
+ },
64
+ "required": [
65
+ "id",
66
+ "name",
67
+ "description",
68
+ "type",
69
+ "entityId",
70
+ "outcome_ref",
71
+ "preconditions",
72
+ "postconditions",
73
+ "permissions",
74
+ "risk_level",
75
+ "async"
76
+ ],
77
+ "additionalProperties": false,
78
+ "allOf": [
79
+ {
80
+ "if": {
81
+ "properties": {
82
+ "name": { "enum": ["Create", "Update", "Delete"] }
83
+ }
84
+ },
85
+ "then": {
86
+ "properties": {
87
+ "type": { "const": "Command" }
88
+ }
89
+ }
90
+ },
91
+ {
92
+ "if": {
93
+ "properties": {
94
+ "name": { "enum": ["Read", "List"] }
95
+ }
96
+ },
97
+ "then": {
98
+ "properties": {
99
+ "type": { "const": "Query" }
100
+ }
101
+ }
102
+ }
103
+ ]
104
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/contract.schema.json",
4
+ "title": "Contract",
5
+ "description": "BADL Contract Definition",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string"
10
+ },
11
+ "name": {
12
+ "type": "string"
13
+ },
14
+ "requiredFields": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "properties": {
19
+ "name": {
20
+ "type": "string"
21
+ },
22
+ "type": {
23
+ "type": "string",
24
+ "enum": ["string", "boolean", "date", "number", "array", "object"]
25
+ }
26
+ },
27
+ "required": ["name", "type"],
28
+ "additionalProperties": false
29
+ }
30
+ },
31
+ "requiredCapabilities": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "object",
35
+ "properties": {
36
+ "name": {
37
+ "type": "string",
38
+ "enum": ["Create", "Read", "Update", "Delete", "List"]
39
+ },
40
+ "type": {
41
+ "type": "string",
42
+ "enum": ["Command", "Query"]
43
+ }
44
+ },
45
+ "required": ["name", "type"],
46
+ "additionalProperties": false
47
+ }
48
+ }
49
+ },
50
+ "required": ["id", "name", "requiredFields", "requiredCapabilities"],
51
+ "additionalProperties": false
52
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.design/schemas/v1/domain.schema.json",
4
+ "title": "Domain",
5
+ "description": "BADL Domain Definition",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string"
10
+ },
11
+ "name": {
12
+ "type": "string"
13
+ },
14
+ "version": {
15
+ "type": "string"
16
+ },
17
+ "domain": {
18
+ "type": "string"
19
+ },
20
+ "entities": {
21
+ "type": "array",
22
+ "items": {
23
+ "$ref": "entity.schema.json"
24
+ }
25
+ },
26
+ "capabilities": {
27
+ "type": "array",
28
+ "items": {
29
+ "$ref": "capability.schema.json"
30
+ }
31
+ },
32
+ "contracts": {
33
+ "type": "array",
34
+ "items": {
35
+ "$ref": "contract.schema.json"
36
+ }
37
+ },
38
+ "extensions": {
39
+ "type": "array",
40
+ "items": {
41
+ "$ref": "extension.schema.json"
42
+ }
43
+ }
44
+ },
45
+ "required": ["id", "name", "version", "domain", "entities"],
46
+ "additionalProperties": false
47
+ }
@@ -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,20 @@
1
+ import { Domain } from './domain';
2
+
3
+ export interface CanonicalAST {
4
+ schemaVersion: string;
5
+ domains: Domain[];
6
+ }
7
+
8
+ export interface ASTNode {
9
+ id: string;
10
+ type: string;
11
+ props?: Record<string, unknown>;
12
+ children?: ASTNode[];
13
+ }
14
+
15
+ export interface InteractionContract<TProps = Record<string, unknown>> {
16
+ id: string;
17
+ type: string;
18
+ props: TProps;
19
+ children?: InteractionContract[];
20
+ }
@@ -0,0 +1,105 @@
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
+ /**
8
+ * BADL Capability Definition
9
+ */
10
+ export type Capability = Capability1 & Capability2;
11
+ export type Capability1 = {
12
+ [k: string]: unknown;
13
+ };
14
+
15
+ /**
16
+ * BADL Domain Definition
17
+ */
18
+ export interface Domain {
19
+ id: string;
20
+ name: string;
21
+ version: string;
22
+ domain: string;
23
+ entities: Entity[];
24
+ capabilities?: Capability[];
25
+ contracts?: Contract[];
26
+ extensions?: Extension[];
27
+ }
28
+ /**
29
+ * BADL Entity Definition
30
+ */
31
+ export interface EntityField {
32
+ id: string;
33
+ name: string;
34
+ type: 'string' | 'boolean' | 'date' | 'number' | 'array' | 'object';
35
+ itemType?: string;
36
+ label: string;
37
+ references?: string;
38
+ validation: string[];
39
+ metadata_path: string;
40
+ fields?: EntityField[];
41
+ }
42
+
43
+ export interface Entity {
44
+ id: string;
45
+ name: string;
46
+ implements?: string[];
47
+ fields: EntityField[];
48
+ }
49
+ export interface Capability2 {
50
+ id: string;
51
+ /**
52
+ * Strict vocabulary of core capability verbs
53
+ */
54
+ name: 'Create' | 'Read' | 'Update' | 'Delete' | 'List';
55
+ description: string;
56
+ type: 'Command' | 'Query';
57
+ /**
58
+ * Target entity for this capability
59
+ */
60
+ entityId: string;
61
+ outcome_ref: string[];
62
+ preconditions: string[];
63
+ postconditions: string[];
64
+ permissions: Permission[];
65
+ risk_level: 'low' | 'medium' | 'high' | 'critical';
66
+ interaction_contract_ref?: string;
67
+ async: boolean;
68
+ }
69
+ /**
70
+ * BADL Role-Based Permission Definition
71
+ */
72
+ export interface Permission {
73
+ /**
74
+ * The role required for this permission
75
+ */
76
+ role: string;
77
+ access?: 'grant' | 'deny';
78
+ }
79
+ /**
80
+ * BADL Contract Definition
81
+ */
82
+ export interface Contract {
83
+ id: string;
84
+ name: string;
85
+ requiredFields: {
86
+ name: string;
87
+ type: 'string' | 'boolean' | 'date' | 'number' | 'array' | 'object';
88
+ }[];
89
+ requiredCapabilities: {
90
+ name: 'Create' | 'Read' | 'Update' | 'Delete' | 'List';
91
+ type: 'Command' | 'Query';
92
+ }[];
93
+ }
94
+
95
+ /**
96
+ * BADL Extension Definition
97
+ */
98
+ export interface Extension {
99
+ id: string;
100
+ name: string;
101
+ version: string;
102
+ extension_type: string;
103
+ implements: string[];
104
+ plugin_version_range: string;
105
+ }
@@ -0,0 +1,29 @@
1
+ export interface ValidationError {
2
+ type: string;
3
+ message: string;
4
+ path?: string;
5
+ line?: number;
6
+ column?: number;
7
+ }
8
+
9
+ export type ASTErrorType =
10
+ | 'CONTRACT_BREACH'
11
+ | 'INVALID_PERMISSION'
12
+ | 'UNSECURED_CAPABILITY'
13
+ | 'MISSING_MANIFEST_VERSION'
14
+ | 'VERSION_MISMATCH';
15
+
16
+ export class ASTValidationError extends Error {
17
+ public errors: ValidationError[];
18
+
19
+ constructor(errors: ValidationError[], message = 'AST Validation Failed') {
20
+ const detailedMessage =
21
+ errors.length > 0 ? `${message}: ${errors.map(e => e.message).join(' | ')}` : message;
22
+ super(detailedMessage);
23
+ this.name = 'ASTValidationError';
24
+ this.errors = errors;
25
+
26
+ // Fix prototype chain for instanceof when extending built-in Error in TS
27
+ Object.setPrototypeOf(this, ASTValidationError.prototype);
28
+ }
29
+ }