Skip to content

Commit

Permalink
Only require slug for schemas (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
leo authored Nov 4, 2024
1 parent aed2964 commit 40dcd8d
Show file tree
Hide file tree
Showing 19 changed files with 393 additions and 289 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const query = {

const schemas = [
{
pluralSlug: 'accounts',
slug: 'account',
},
];
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
"author": "ronin",
"license": "Apache-2.0",
"dependencies": {
"@paralleldrive/cuid2": "2.2.2"
"@paralleldrive/cuid2": "2.2.2",
"title": "3.5.3"
},
"devDependencies": {
"@biomejs/biome": "1.9.2",
"@types/bun": "1.1.10",
"@types/title": "3.4.3",
"tsup": "8.3.0",
"typescript": "5.6.2",
"zod": "3.23.8"
Expand Down
3 changes: 1 addition & 2 deletions src/instructions/for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { WithFilters } from '@/src/instructions/with';
import type { GetInstructions } from '@/src/types/query';
import type { Schema } from '@/src/types/schema';
import { RONIN_SCHEMA_SYMBOLS, RoninError, replaceInObject } from '@/src/utils';
import { getSchemaName } from '@/src/utils/schema';
import { composeConditions } from '@/src/utils/statement';

/**
Expand Down Expand Up @@ -35,7 +34,7 @@ export const handleFor = (

if (!forFilter) {
throw new RoninError({
message: `The provided \`for\` shortcut "${shortcut}" does not exist in schema "${getSchemaName(schema)}".`,
message: `The provided \`for\` shortcut "${shortcut}" does not exist in schema "${schema.name}".`,
code: 'INVALID_FOR_VALUE',
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/instructions/including.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { WithFilters } from '@/src/instructions/with';
import type { Instructions } from '@/src/types/query';
import type { Schema } from '@/src/types/schema';
import { RoninError, splitQuery } from '@/src/utils';
import { getSchemaBySlug, getSchemaName, getTableForSchema } from '@/src/utils/schema';
import { getSchemaBySlug, getTableForSchema } from '@/src/utils/schema';
import { composeConditions } from '@/src/utils/statement';

/**
Expand Down Expand Up @@ -40,7 +40,7 @@ export const handleIncluding = (

if (!includingQuery) {
throw new RoninError({
message: `The provided \`including\` shortcut "${shortcut}" does not exist in schema "${getSchemaName(schema)}".`,
message: `The provided \`including\` shortcut "${shortcut}" does not exist in schema "${schema.name}".`,
code: 'INVALID_INCLUDING_VALUE',
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export type SchemaFieldReferenceAction =
export type SchemaFieldReference = SchemaFieldBasics & {
type: 'reference';

// Make the `pluralSlug` required.
target: Omit<Partial<Schema>, 'pluralSlug'> & Pick<Schema, 'pluralSlug'>;
// Make the `slug` required.
target: Omit<Partial<Schema>, 'slug'> & Pick<Schema, 'slug'>;

kind?: 'one' | 'many';
actions?: {
Expand All @@ -39,7 +39,7 @@ export interface Schema {
name?: string;
pluralName?: string;
slug: string;
pluralSlug: string;
pluralSlug?: string;
identifiers?: {
title?: string;
slug?: string;
Expand Down
Loading

0 comments on commit 40dcd8d

Please sign in to comment.