Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize schemas #547

Merged
merged 134 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
31f8b56
Eliminate the usage of the XOR type
daanboer May 21, 2023
5a32063
Apply `@internal` to internal types
daanboer Jun 6, 2023
44c3909
Annotate species union types with `@discriminator type`
daanboer Jun 6, 2023
1c811d5
Add `Constant` storage
daanboer Jun 6, 2023
7e47c15
Add `as` cast to fix type error
daanboer Jun 6, 2023
134285c
Split the set header into a separate type
daanboer Jun 6, 2023
4a46728
Rename `data` to `value` in `LUT` storage type`
daanboer Jun 6, 2023
6e8d93c
Add `Expression` storage type
daanboer Jun 14, 2023
8b1d931
Switch to more simple generators for species types
daanboer Jul 4, 2023
e7d15e1
Annotate more types with `@internal`
daanboer Jul 4, 2023
c4c59b0
Add `stateIsAtom` type guard function
daanboer Jul 5, 2023
4ca1932
Reimplement `insert_state_tree` to support the new schema changes
daanboer Jul 5, 2023
9244ef2
Update `State` database collection type
daanboer Jul 6, 2023
92ac370
Introduce `KeyedSpecies`
daanboer Jul 6, 2023
2a73df8
Update CrossSection schema
daanboer Jul 6, 2023
9b24869
Update `State` schema
daanboer Jul 6, 2023
eb23f1a
Update state tests for database package
daanboer Jul 6, 2023
db1ef4f
Allow unspecified state descriptors as part of compound state
daanboer Jul 8, 2023
93a9be2
Update `@lxcat/schema` test data
daanboer Jul 8, 2023
ebe4fb0
Regenerate database state schema
daanboer Jul 8, 2023
cdfb7fc
Update `@lxcat/schema` tests to comply with new schema version
daanboer Jul 8, 2023
178ae3c
Add `zod` dependency to `@lxcat/schema`
daanboer Jul 16, 2023
1476e08
Add preliminary migrate script for schema
daanboer Jul 16, 2023
180fcb5
Move `SimpleParticle` and `AnyParticle` to dedicated module
daanboer Jul 18, 2023
666b553
Add restriction on `State` generic parameter
daanboer Jul 18, 2023
aff62f7
Add missing `immer` dep for `@lxcat/database`
daanboer Jul 18, 2023
18dfe7c
Use `KeyedSpecies`
daanboer Jul 18, 2023
d4c90da
Update state query generic constraints
daanboer Jul 18, 2023
43ad835
Remove unused `LutTable` component
daanboer Jul 19, 2023
62232f5
Cleanup minor (type) errors in `EditForm` component
daanboer Jul 19, 2023
071c264
Added `Unspecified` class of states
daanboer Jul 19, 2023
e879e1d
Fix build errors in `EditForm` component
daanboer Jul 19, 2023
352d25e
Fix build errors in `Chart`
daanboer Jul 19, 2023
f4db6d7
Update `State` collection schema
daanboer Jul 19, 2023
0047613
Remove redundant example code
daanboer Jul 19, 2023
6cb7f6f
Fix query generators for new schema
daanboer Jul 19, 2023
9297cad
Remove migrate file from version control
daanboer Jul 19, 2023
6996e1f
Start new edit set page using app router
daanboer Jul 20, 2023
237a8cd
Add preliminary `zod` version of schema
daanboer Jul 20, 2023
ef957a2
Add `General` tab to new edit form
daanboer Jul 20, 2023
6588f64
Annotate new files
daanboer Jul 20, 2023
cbbdc2b
Fix `LS1` and `J1L2` schema definitions
daanboer Jul 21, 2023
f4cba23
Add script to generate `AnySpecies` schema from `zod` definitions
daanboer Jul 21, 2023
a9d0172
Add `complete` flag to `SetHeader` definition
daanboer Jul 21, 2023
41fb021
Make species schemas more strict where appropriate
daanboer Jul 21, 2023
f7fff0b
Initial pass at automatic form generation from species schemas
daanboer Jul 21, 2023
d09a3ea
Add keys in `allOf` component and default value in `anyOf` component
daanboer Jul 24, 2023
55d8e26
Merge branch 'main' into enhance-schema
daanboer Aug 21, 2023
edf1353
Equalize schema and app `zod` versions
daanboer Aug 21, 2023
b802b8d
Add descriptions for `Singular`, `Compound`, and `Unspecified` option…
daanboer Aug 21, 2023
26015ae
Update new `EditForm` component
daanboer Aug 21, 2023
3007f64
Update copyright statement
daanboer Aug 21, 2023
bedab15
Add `drop_non_user` script
daanboer Aug 21, 2023
0f4c7a2
Fix warning in `Dialog`
daanboer Aug 21, 2023
3cb56b5
Fix zod types for `CSLData` and `Reaction`
daanboer Aug 21, 2023
3c23778
Update zod schema
daanboer Aug 21, 2023
25d0ab3
Update Zod types
daanboer Aug 28, 2023
7428dfa
Start using Zod types
daanboer Aug 28, 2023
e9c649e
`package.json` formatting
daanboer Sep 8, 2023
48b3802
Rework species parsing
daanboer Sep 8, 2023
39f41df
Add `serialize` function to `State`
daanboer Sep 8, 2023
aa1ff27
Add first state serializer tests
daanboer Sep 8, 2023
44eec8e
Fix `@lxcat/schema` vitest configuration
daanboer Sep 10, 2023
dc0d51b
Add more state tests
daanboer Sep 10, 2023
fc6af84
Add regression test for LTPMixture schema
daanboer Sep 10, 2023
9deb612
Start deprecation of old schema
daanboer Sep 11, 2023
ec2f032
Fix further `@lxcat/schema` references
daanboer Sep 11, 2023
e223f4d
Update JSON schema creation
daanboer Sep 12, 2023
687eb44
Fix build errors
daanboer Sep 12, 2023
62bfd55
Fix state charge serialization
daanboer Sep 13, 2023
0ebdbc8
Fix inspect page
daanboer Sep 13, 2023
a3397ea
Add note about selection page crash
daanboer Sep 13, 2023
862ee4e
Fix data selection page
daanboer Sep 13, 2023
879405d
Fix serializer tests
daanboer Sep 13, 2023
a4730ea
Continue fixing database tests
daanboer Sep 13, 2023
8bef8d2
Fix database state queries
daanboer Sep 15, 2023
0adfdbb
Testing external serializer functions
daanboer Sep 18, 2023
9a9bc25
Use separate function to serialize `ShellEntry`
daanboer Sep 19, 2023
9c527ee
Rename `LSTermImpl` -> `LSTermUncoupled`
daanboer Sep 19, 2023
0aee66f
Add LS1 coupled component
daanboer Sep 19, 2023
0e44b95
Push `SimpleParticle` down the tree
daanboer Sep 20, 2023
b3e163c
Add helper types for new serialization strategy
daanboer Sep 21, 2023
3c36c91
Use `makeComponent` for molecular components
daanboer Sep 21, 2023
87ed3ca
Split molecular types into serializable and non-serializable
daanboer Sep 22, 2023
99b15d5
`@lxcat/schema`: Emit ES6 with ESM imports
daanboer Sep 22, 2023
96faaaa
Remove `State` types
daanboer Sep 22, 2023
96f2ec7
Use zod refine to check validity of `state` and `reference` keys
daanboer Sep 22, 2023
62d76de
Perform key checks on `LTPMixture`
daanboer Sep 22, 2023
bd3b2ef
Move `SetHeader` and `SelfReference` to dedicated modules.
daanboer Sep 22, 2023
59cc9ee
Encapsulate exports and use `nodenext` module resolution
daanboer Sep 22, 2023
985a713
Fix database build
daanboer Sep 22, 2023
81d27fe
Merge remote-tracking branch 'origin/main' into enhance-schema
daanboer Sep 26, 2023
a3ef0bc
Update `module` setting in `schema` and `database` `tsconfig`
daanboer Sep 26, 2023
5abe8e1
Add additional fields to `CSLNameVariable`
daanboer Sep 26, 2023
97c300c
Fix `@lxcat/app` build errors
daanboer Sep 27, 2023
dcdff03
Update database cli setup script
daanboer Sep 27, 2023
9f8e17b
Fix data select/inspect/compute routes
daanboer Sep 27, 2023
db27106
Update state interface in edit form
daanboer Sep 29, 2023
5343367
Create `electronic` property upon type switch
daanboer Sep 29, 2023
0aa12b9
Merge remote-tracking branch 'origin/main' into enhance-schema
daanboer Oct 2, 2023
23e3e4a
Merge remote-tracking branch 'origin/main' into enhance-schema
daanboer Oct 16, 2023
daa128d
Fix `byIdJSON` function
daanboer Oct 27, 2023
de8d809
Merge remote-tracking branch 'origin/main' into enhance-schema
daanboer Oct 30, 2023
09dfb16
Add new `RouteBuilder` class
daanboer Nov 3, 2023
036c6c4
Add `async` api to `RouteBuilder`
daanboer Nov 3, 2023
b35a95e
Add `hasSessionOrAPIToken` and `hasDeveloperOrDownloadRole` middlewares
daanboer Nov 3, 2023
4df9076
Remove `dom` lib from `schema` tsconfig
daanboer Nov 4, 2023
c8d84b5
Pin `zod` version to `3.21.3`
daanboer Nov 5, 2023
18134fd
Add simple species routes
daanboer Nov 5, 2023
acd05b6
Pin `zod` version in `app`
daanboer Nov 5, 2023
f046e3f
Add model to pick species from database in set edit form
daanboer Nov 5, 2023
b035a45
Update flake lock file
daanboer Nov 7, 2023
2133764
Add array component for species form generation
daanboer Nov 7, 2023
bb90176
Fix type errors involving document self referencing
daanboer Nov 7, 2023
0b1dcc2
Allow for unspecified entries in rovibrational compounds
daanboer Nov 7, 2023
8d6623f
Add species picker in set edit form
daanboer Nov 7, 2023
cc4df7d
Update schema generation command
daanboer Nov 7, 2023
6bd1b0c
Secure endpoints using middleware
daanboer Nov 7, 2023
d869f45
Add species API tests
daanboer Nov 8, 2023
8c870f0
Fix `/scat-css/[id]` endpoint
daanboer Nov 8, 2023
f661739
Fix many database tests
daanboer Nov 8, 2023
01a453f
Fix and restrict atom and molecule schemas
daanboer Nov 8, 2023
3188d95
Fix reaction test
daanboer Nov 8, 2023
ded7009
Partially fix CS write tests
daanboer Nov 8, 2023
d107714
Fix more database tests
daanboer Nov 9, 2023
64d2f61
Overhaul database package
daanboer Nov 12, 2023
fd55010
Fix database package build
daanboer Nov 12, 2023
7d03127
Fix annotate script
daanboer Nov 12, 2023
7ca9813
Fix reuse compliance
daanboer Nov 12, 2023
2ba59d7
Tidy database package API
daanboer Nov 12, 2023
4ea4b00
Fix schema regression test
daanboer Nov 13, 2023
7434ae1
Merge remote-tracking branch 'origin/main' into enhance-schema
daanboer Nov 13, 2023
bed694f
Remove flake files from version control
daanboer Nov 13, 2023
54899fc
Fix `@lxcat/schema` and `@lxcat/app` REUSE compliance
daanboer Nov 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/e2e/scat-css-public-routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

import type { CrossSectionSetHeading } from "@lxcat/database/dist/css/public";
import type { CrossSectionSetRaw } from "@lxcat/schema/dist/css/input";
import type { LTPDocument } from "@lxcat/schema";
import { expect, test } from "@playwright/test";
import { readFile } from "fs/promises";
import {
Expand Down Expand Up @@ -68,14 +68,14 @@ test.describe("given 2 dummy sets", () => {
test.describe("/api/scat-css/[id]", () => {
test("given no refstyle should return csl", async ({ request }) => {
const res = await request.get(`/api/scat-css/${setId}`);
const set: CrossSectionSetRaw = await res.json();
const set: LTPDocument = await res.json();
const ref0 = Object.values(set.references)[0];
expect(ref0.id).toEqual("SomeMainId");
});

test("given bibtex refstyle should return bibtex string", async ({ request }) => {
const res = await request.get(`/api/scat-css/${setId}?refstyle=bibtex`);
const set: CrossSectionSetRaw = await res.json();
const set: LTPDocument = await res.json();
const expected = `@article{MyFamilyNameSome,
\tauthor = {MyFamilyName, MyGivenName},
\tjournal = {SomeJournal},
Expand All @@ -90,7 +90,7 @@ test.describe("given 2 dummy sets", () => {

test("given apa refstyle should return apa string", async ({ request }) => {
const res = await request.get(`/api/scat-css/${setId}?refstyle=apa`);
const set: CrossSectionSetRaw = await res.json();
const set: LTPDocument = await res.json();
const ref0 = Object.values(set.references)[0];
const expected =
"MyFamilyName, M. (n.d.). Some main reference title. In SomeJournal. https://doi.org/10.1109/5.771073\n";
Expand Down
5 changes: 4 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "next start",
"lint": "next lint",
"format": "dprint fmt",
"type-check": "tsc --pretty --noEmit",
"test": "vitest",
"test:e2e": "playwright test",
"annotate": "reuse annotate --license=AGPL-3.0-or-later --copyright='LXCat team' -r --skip-existing --exclude-year src e2e"
Expand Down Expand Up @@ -74,7 +75,7 @@
"unist-util-visit": "^5.0.0",
"vfile": "^5.3.7",
"vfile-matter": "^4.0.1",
"zod": "^3.22.4"
"zod": "3.21.3"
},
"devDependencies": {
"@babel/core": "^7.23.3",
Expand All @@ -83,6 +84,8 @@
"@playwright/test": "1.34.3",
"@types/cookie": "^0.5.3",
"@types/deep-equal": "^1.0.3",
"@types/json-schema": "^7.0.12",
"@types/mdast": "^4.0.0",
"@types/node": "20.9.0",
"@types/oidc-provider": "^7.14.0",
"@types/plotly.js-basic-dist": "^1.54.3",
Expand Down
2 changes: 1 addition & 1 deletion app/src/ScatteringCrossSection/CSTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const CSTable = ({ items }: Props) => {
{ isPartOf, ...item },
) => ({
...item,
typeTags: item.reaction.type_tags,
typeTags: item.reaction.typeTags,
reaction: <ReactionSummary {...item.reaction} />,
})),
}));
Expand Down
28 changes: 0 additions & 28 deletions app/src/ScatteringCrossSection/LutTable.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/ScatteringCrossSection/ReactionSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

import { State } from "@lxcat/database/dist/shared/types/collections";
import { Reaction } from "@lxcat/schema/dist/core/reaction";
import { type Reaction } from "@lxcat/schema/process";
import { Latex } from "../shared/Latex";

import { reactionAsLatex } from "./reaction";
Expand Down
2 changes: 1 addition & 1 deletion app/src/ScatteringCrossSection/json-ld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const toJSONLD = (section: CrossSectionItem) => {
name: `Scattering Cross Section of ${reactionAsText(section.reaction)}`,
keywords: [
"cross section",
...section.reaction.type_tags,
...section.reaction.typeTags,
// TODO add more keywords?
].join(", "),
distribution: [
Expand Down
10 changes: 5 additions & 5 deletions app/src/ScatteringCrossSection/reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

import { State } from "@lxcat/database/dist/shared/types/collections";
import { Reaction, ReactionEntry } from "@lxcat/schema/dist/core/reaction";
import { Reaction, ReactionEntry } from "@lxcat/schema/process";

function entryAsLatex(entry: ReactionEntry<State>) {
if (entry.count === 1) {
return entry.state.latex;
return entry.state.serialized.latex;
}
return `${entry.count}${entry.state.latex}`;
return `${entry.count}${entry.state.serialized.latex}`;
}
function entryAsText(entry: ReactionEntry<State>) {
if (entry.count === 1) {
return entry.state.id;
return entry.state.serialized.summary;
}
return `${entry.count}${entry.state.id}`;
return `${entry.count}${entry.state.serialized.summary}`;
}

/**
Expand Down
11 changes: 7 additions & 4 deletions app/src/ScatteringCrossSectionSet/AddForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

import { OrganizationFromDB } from "@lxcat/database/dist/auth/queries";
import { CrossSectionSetInputOwned } from "@lxcat/database/dist/css/queries/author_read";
import { CrossSectionSetRaw } from "@lxcat/schema/dist/css/input";
import { LTPDocument } from "@lxcat/schema";
import { useMemo } from "react";
import { EditForm } from "./EditForm";

interface Props {
onSubmit: (newSet: CrossSectionSetInputOwned, newMessage: string) => void;
// onSubmit: (newSet: CrossSectionSetInputOwned, newMessage: string) => void;
onSubmit: (newSet: any, newMessage: string) => void;
organizations: OrganizationFromDB[];
}

export const AddForm = ({ onSubmit, organizations }: Props) => {
const newSet: CrossSectionSetRaw = useMemo(() => {
const newSet: LTPDocument = useMemo(() => {
return {
$schema: "",
url: "",
termsOfUse: "",
name: "",
description: "",
complete: false,
Expand Down