Skip to content

Commit d87d4a3

Browse files
committed
refactor: extract models into separate module to allow docify templates to become widgets (finos#1533)
1 parent e25a6df commit d87d4a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5119
-86
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Calm Models
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- 'main'
10+
push:
11+
branches:
12+
- 'main'
13+
14+
jobs:
15+
shared:
16+
name: Build, Test, and Lint Calm Models Module
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout PR Branch
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
25+
with:
26+
node-version: v22
27+
28+
- name: Install workspace
29+
run: npm ci
30+
31+
- name: Lint Shared Module
32+
run: npm run lint --workspace=calm-models
33+
34+
- name: Build workspace
35+
run: npm run build --workspace=calm-models
36+
37+
- name: Run tests with coverage for Calm Models
38+
run: npm run test --workspace=calm-models

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ codebase, fostering a robust understanding, efficient development, and seamless
1616
architectures.
1717

1818
This repository contains the Common Architecture Language Model (CALM) Specification, as well as capabilities being
19-
built to utilize the
20-
specification. This page lists the domains and capabilities being built by the official AasC community.
19+
built to utilize the specification. This page lists the domains and capabilities being built by the official AasC community.
2120

2221
Whilst others are welcome to build their own capabilities, away from the AasC monorepo, we encourage you to join the
2322
community and contribute your projects to the AasC monorepo which has the benefits of being visible to the whole
@@ -26,13 +25,13 @@ your project.
2625

2726
## Projects
2827

29-
| Project | Lead Maintainers | Builds |
30-
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31-
| [Common Architecture Language Model](./calm) | [@rocketstack-matt](https://github.com/rocketstack-matt), [@jpgough-ms](https://github.com/jpgough-ms) | [![Validation of CALM Samples](https://github.com/finos/architecture-as-code/actions/workflows/validate-spectral.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/validate-spectral.yml) |
32-
| [CLI](./cli) & [Shared](./shared) | [@aidanm3341](https://github.com/aidanm3341), [@lbulanti-ms](https://github.com/lbulanti-ms), [@willosborne](https://github.com/willosborne), [@grahampacker-ms](https://github.com/grahampacker-ms) [@Thels](https://github.com/Thels) [@LeighFinegold](https://github.com/LeighFinegold) | [![Build CLI](https://github.com/finos/architecture-as-code/actions/workflows/build-cli.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-cli.yml) |
33-
| [CALM Hub](./calm-hub) | [@jpgough-ms](https://github.com/jpgough-ms) | [![Build Calm Hub](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml) |
34-
| [Docs](./docs) | [@rocketstack-matt](https://github.com/rocketstack-matt) | [![Sync Docs to S3](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml) [![Build Docs](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml) |
35-
| [Visualizer](./calm-visualizer) | [@oliviajanejohns](https://github.com/oliviajanejohns) [@aidanm3341](https://github.com/aidanm3341) [@aamanrebello](https://github.com/aamanrebello) [@yoofitt96](https://github.com/YoofiTT96) | [![Build CALM Hub UI](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml) |
28+
| Project | Lead Maintainers | Builds |
29+
|------------------------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30+
| [Common Architecture Language Model](./calm) | [@rocketstack-matt](https://github.com/rocketstack-matt), [@jpgough-ms](https://github.com/jpgough-ms) | [![Validation of CALM Samples](https://github.com/finos/architecture-as-code/actions/workflows/validate-spectral.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/validate-spectral.yml) |
31+
| [CLI](./cli), [Shared](./shared), [Models](./calm-models) & [Widget Framewrok](./calm-widgets) | [@aidanm3341](https://github.com/aidanm3341), [@lbulanti-ms](https://github.com/lbulanti-ms), [@willosborne](https://github.com/willosborne), [@grahampacker-ms](https://github.com/grahampacker-ms) [@Thels](https://github.com/Thels) [@LeighFinegold](https://github.com/LeighFinegold) | [![Build CLI](https://github.com/finos/architecture-as-code/actions/workflows/build-cli.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-cli.yml) |
32+
| [CALM Hub](./calm-hub) | [@jpgough-ms](https://github.com/jpgough-ms) | [![Build Calm Hub](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml) |
33+
| [CALM Hub UI](./calm-hub-ui) | [@oliviajanejohns](https://github.com/oliviajanejohns) [@aidanm3341](https://github.com/aidanm3341) [@aamanrebello](https://github.com/aamanrebello) [@yoofitt96](https://github.com/YoofiTT96) | [![Build CALM Hub UI](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml) |
34+
| [Docs](./docs) | [@rocketstack-matt](https://github.com/rocketstack-matt) | [![Sync Docs to S3](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml) [![Build Docs](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml) |
3635

3736
## Getting Involved
3837

calm-hub-ui/src/service/adr-service/adr-service.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios, { AxiosInstance } from 'axios';
22
import { getToken } from '../../authService.js';
3-
import { CalmAdrMeta } from 'shared/src/view-model/adr.js';
3+
import { CalmAdrMeta } from '@finos/calm-shared/src/view-model/adr.js';
44

55
export class AdrService {
66
private readonly ax: AxiosInstance;

calm-hub-ui/src/visualizer/components/drawer/Drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
33
import {
44
CalmArchitectureSchema,
55
CalmNodeSchema,
6-
} from '../../../../../shared/src/types/core-types.js';
6+
} from '../../../../../calm-models/src/types/core-types.js';
77
import { CytoscapeNode, Edge } from '../../contracts/contracts.js';
88
import { VisualizerContainer } from '../visualizer-container/VisualizerContainer.js';
99
import { Data } from '../../../model/calm.js';

calm-hub-ui/src/visualizer/contracts/contracts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import cytoscape from 'cytoscape';
2-
import { CalmInterfaceSchema } from '@finos/calm-shared/src/types/core-types.js';
3-
import { CalmControlsSchema } from '@finos/calm-shared/src/types/control-types.js';
2+
import { CalmInterfaceSchema, CalmControlsSchema } from '@finos/calm-models/src/types/control-types.js';
43

54
export type CytoscapeNode = {
65
classes?: string;

calm-models/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CALM Models
2+
3+
This module contains the TypeScript type definitions and interfaces for the Common Architecture Language Model (CALM). It serves as a shared foundation for type safety across all CALM tooling and prevents circular dependencies between modules.
4+
5+
## Module Structure
6+
7+
The `calm-models` module is organized into three sub-modules:
8+
9+
### 1. **types**
10+
A 1:1 mapping to the CALM schema definitions. These types directly represent the JSON schema structure of CALM documents and provide strict type safety for schema validation and parsing.
11+
12+
### 2. **model**
13+
An internal business model built to allow for lazy loading of nested CALM documents when required. This layer provides rich object models with methods and computed properties that support complex operations on CALM data.
14+
15+
### 3. **canonical**
16+
A flattened data model used for templating. This represents CALM data in a simplified, template-friendly format that's optimized for rendering documentation and generating output files.
17+
18+
## What Should Be In This Module
19+
20+
**Include:**
21+
- **types/**: Direct TypeScript mappings of CALM JSON schema definitions
22+
- **models/**: Business logic types supporting lazy loading and document relationships
23+
- **canonical/**: Flattened, template-optimized data structures
24+
- Any additional approved model representations of CALM data used by the CALM tooling.
25+
26+
## What Should NOT Be In This Module
27+
**Avoid:**
28+
- Business logic or processing functions
29+
- Template rendering code
30+
- Widget implementations
31+
- CLI-specific utilities
32+
- File system operations
33+
- Network requests or API clients
34+
- Complex validation logic (keep validation types, not validation implementations)
35+
36+
## Dependencies
37+
38+
This module should maintain minimal dependencies to avoid becoming a bottleneck:
39+
- Only essential TypeScript utility libraries
40+
- No dependency on other CALM modules (`shared`, `calm-widgets`, etc.)
41+
- Avoid heavy runtime dependencies
42+
43+
## Usage
44+
45+
Other modules in the CALM ecosystem import types from this module's sub-modules:
46+
47+
```typescript
48+
// Import direct schema types from types/
49+
import {
50+
CalmNodeSchema,
51+
CalmNodeTypeSchema,
52+
CalmInteractsRelationshipSchema
53+
} from '@finos/calm-models/types';
54+
55+
// Import business model classes from model/
56+
import {
57+
CalmNode,
58+
CalmRelationship,
59+
CalmInteractsType,
60+
CalmConnectsType
61+
} from '@finos/calm-models/model';
62+
63+
// Import flattened template types from canonical/
64+
import {
65+
CalmCoreCanonicalModel,
66+
CalmNodeCanonicalModel,
67+
CalmDecisionCanonicalModel
68+
} from '@finos/calm-models/canonical';
69+
```
70+
71+
For any questions about whether a type belongs in this module, consult the lead maintainers or discuss in the relevant GitHub issue.

calm-models/eslint.config.mjs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import globals from "globals";
3+
import tsParser from "@typescript-eslint/parser";
4+
import path from "node:path";
5+
import { fileURLToPath } from "node:url";
6+
import js from "@eslint/js";
7+
import { FlatCompat } from "@eslint/eslintrc";
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
const compat = new FlatCompat({
12+
baseDirectory: __dirname,
13+
recommendedConfig: js.configs.recommended,
14+
allConfig: js.configs.all
15+
});
16+
17+
export default [
18+
...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
19+
{
20+
plugins: {
21+
"@typescript-eslint": typescriptEslint,
22+
},
23+
24+
languageOptions: {
25+
globals: {
26+
...globals.browser,
27+
},
28+
29+
parser: tsParser,
30+
ecmaVersion: "latest",
31+
sourceType: "module",
32+
},
33+
34+
rules: {
35+
indent: ["error", 4],
36+
"linebreak-style": ["error", "unix"],
37+
quotes: ["error", "single"],
38+
semi: ["error", "always"],
39+
"no-unused-vars": "off",
40+
"@typescript-eslint/no-unused-vars": [
41+
"error",
42+
{
43+
"argsIgnorePattern": "^_",
44+
"varsIgnorePattern": "^_",
45+
"caughtErrorsIgnorePattern": "^_"
46+
}
47+
],
48+
"@typescript-eslint/no-unused-expressions": [
49+
"error",
50+
{
51+
"allowShortCircuit": true,
52+
"allowTernary": true,
53+
"allowTaggedTemplates": true
54+
}
55+
]
56+
}
57+
},
58+
];

0 commit comments

Comments
 (0)