Skip to content

Commit 30c613a

Browse files
authored
Merge pull request #7 from event-catalog/added-lint-for-data-stores
feat(linter): added support for data stores
2 parents 4c12a59 + b996254 commit 30c613a

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed

.changeset/witty-jars-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@eventcatalog/linter": patch
3+
---
4+
5+
feat(linter): added support for data stores

src/scanner/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const RESOURCE_PATTERNS: Record<ResourceType, string[]> = {
3333
entity: ['**/entities/*/index.{md,mdx}', '**/entities/*/versioned/*/index.{md,mdx}'],
3434
user: ['users/*.{md,mdx}'],
3535
team: ['teams/*.{md,mdx}'],
36+
dataStore: ['**/containers/*/index.{md,mdx}', '**/containers/*/versioned/*/index.{md,mdx}'],
3637
};
3738

3839
export const extractResourceInfo = (filePath: string, resourceType: ResourceType): { id: string; version?: string } => {

src/schemas/data-store.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { z } from 'zod';
2+
import { baseSchema } from './common';
3+
4+
export const dataStoreSchema = z
5+
.object({
6+
container_type: z.enum(['database', 'cache', 'objectStore', 'searchIndex', 'dataWarehouse', 'dataLake', 'externalSaaS']),
7+
technology: z.string().optional(),
8+
authoritative: z.boolean().optional(),
9+
access_mode: z.enum(['read', 'write', 'readWrite', 'appendOnly']),
10+
classification: z.enum(['public', 'internal', 'confidential', 'regulated']),
11+
residency: z.string().optional(),
12+
retention: z.string().optional(),
13+
})
14+
.merge(baseSchema);

src/schemas/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './flow';
77
export * from './entity';
88
export * from './user';
99
export * from './team';
10+
export * from './data-store';
1011

1112
import { domainSchema } from './domain';
1213
import { serviceSchema } from './service';
@@ -16,6 +17,7 @@ import { flowSchema } from './flow';
1617
import { entitySchema } from './entity';
1718
import { userSchema } from './user';
1819
import { teamSchema } from './team';
20+
import { dataStoreSchema } from './data-store';
1921

2022
export const schemas = {
2123
domain: domainSchema,
@@ -28,6 +30,7 @@ export const schemas = {
2830
entity: entitySchema,
2931
user: userSchema,
3032
team: teamSchema,
33+
dataStore: dataStoreSchema,
3134
} as const;
3235

3336
export type ResourceType = keyof typeof schemas;

src/schemas/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ export const serviceSchema = z
66
sends: z.array(pointerSchema).optional(),
77
receives: z.array(pointerSchema).optional(),
88
entities: z.array(pointerSchema).optional(),
9+
writesTo: z.array(pointerSchema).optional(),
10+
readsFrom: z.array(pointerSchema).optional(),
911
})
1012
.merge(baseSchema);

tests/schema-validator.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,34 @@ describe('validateSchema', () => {
257257
expect(errors[0].message).toContain('Invalid email');
258258
});
259259
});
260+
261+
describe('data store validation', () => {
262+
it('should pass with valid data store frontmatter', () => {
263+
const parsedFile = createParsedFile('dataStore', {
264+
id: 'user-data-store',
265+
name: 'User Data Store',
266+
version: '1.0.0',
267+
container_type: 'database',
268+
technology: 'PostgreSQL',
269+
authoritative: true,
270+
access_mode: 'readWrite',
271+
classification: 'public',
272+
residency: 'US',
273+
retention: '1 year',
274+
});
275+
const errors = validateSchema(parsedFile);
276+
expect(errors).toHaveLength(0);
277+
});
278+
279+
it('should fail with invalid container type', () => {
280+
const parsedFile = createParsedFile('dataStore', {
281+
id: 'user-data-store',
282+
name: 'User Data Store',
283+
version: '1.0.0',
284+
container_type: 'invalid-container-type',
285+
});
286+
const errors = validateSchema(parsedFile);
287+
expect(errors.length).toBeGreaterThan(0);
288+
});
289+
});
260290
});

0 commit comments

Comments
 (0)