Skip to content

Commit

Permalink
feat!: replace schema inputs with inline keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
waynevanson committed Aug 26, 2023
1 parent bde3aa4 commit 681ab55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions packages/data-entry/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { Decoder } from 'io-ts/Decoder';

type GetSet<A> = Record<'get' | 'set', A>;

//
//
//
// make frontmatter get/set paths implicit: schema and data respectively.
// remove the whole writing to a file thing, gross
// also allow loading icon to happen somewhere without removing the form.
export type Datasource = Sum<{
Expand All @@ -23,8 +19,8 @@ export type Datasource = Sum<{

export interface Configuration {
datasource: Datasource;
schema: JsonSchema; //register definitions behind "data-entry" or "vault" key
uischema?: UISchemaElement; // get set
schema: Sum<{ inline: JsonSchema }>; //register definitions behind "data-entry" or "vault" key
uischema?: Sum<{ inline: UISchemaElement }>; // get set
}

export type Sum<T extends Record<string, unknown>> = keyof T extends never
Expand Down Expand Up @@ -64,18 +60,20 @@ const sum = <P extends Record<string, Decoder<unknown, unknown>>>(

/// schema
const datasource = sum({
file: decoder.struct({ path: decoder.string }),
file: decoder.struct({
path: decoder.string,
}),
folder: decoder.string,
});

export const configuration = pipe(
decoder.struct({
datasource,
schema: decoder.UnknownRecord,
schema: decoder.struct({ inline: decoder.UnknownRecord }),
}),
decoder.intersect(
decoder.partial({
uischema: decoder.UnknownRecord,
uischema: decoder.struct({ inline: decoder.UnknownRecord }),
}),
),
);
4 changes: 2 additions & 2 deletions packages/data-entry/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class MainPlugin extends Plugin {
fileName: (json.datasource as Record<'file', { path: string }>)
.file.path,
vault: this.app.vault,
schema: json.schema,
uischema: json.uischema as never,
schema: json.schema.inline,
uischema: json.uischema?.inline as never,
}}
>
<Application />
Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"test": {
"dependsOn": ["^format", "^lint", "^build"],
"inputs": ["**/src/**.tsx?", "package.json", "packages/*/package.json"]
"inputs": ["**/src/**.tsx?"]
},
"deploy": {
"dependsOn": ["build", "test"],
Expand Down

0 comments on commit 681ab55

Please sign in to comment.