Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @123ishatest/louter

## 0.5.3

### Patch Changes

- Add getKinds() to ContentManager

## 0.5.2

### Patch Changes
Expand Down
39 changes: 11 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@123ishatest/louter",
"private": false,
"version": "0.5.2",
"version": "0.5.3",
"publishConfig": {
"access": "public",
"provenance": true
Expand Down
4 changes: 4 additions & 0 deletions src/content/ContentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export class ContentManager<const Kinds extends Record<string, ZodType<{ id: str
}
}

public getKinds(): (keyof Kinds)[] {
return Object.keys(this._kinds);
}

public getMap<Kind extends keyof Kinds>(kind: Kind): Record<string, z.infer<Kinds[Kind]>> {
const map = this._content[kind];
if (!map) {
Expand Down
19 changes: 19 additions & 0 deletions tests/content/content-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,22 @@ it('throws an error when a schema does not exist', () => {
manager.getSchema('wrong');
}).toThrow(ContentKindNotFoundError);
});

it('can get a list of all kinds', () => {
// Arrange
const manager = new ContentManager({
example: z.strictObject({
id: z.string(),
amount: z.number(),
}),
other: z.strictObject({
id: z.string(),
}),
});

// Act
const kinds = manager.getKinds();

// Assert
expect(kinds).toStrictEqual(['example', 'other']);
});
Loading