Skip to content

Commit

Permalink
feat!: update schema to ODM v2 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvxcheung authored Nov 28, 2023
1 parent 7f71c1c commit 5efa779
Show file tree
Hide file tree
Showing 30 changed files with 627 additions and 667 deletions.
81 changes: 48 additions & 33 deletions graphql/api/relationships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ import { TableRelationships } from './types';
* "InfobaseTrend",
* "polygons",
* "instruments",
* "setLUs",
* "partLUs",
* "sets",
* "parts",
* "contacts",
* "measureSets",
* "methodSteps",
* "methodSets",
* "languageLUs",
* "translationLUs",
* "languages",
* "translations",
* "sites",
* "samples",
* "measures"
* "StandardCurve"
* "measures",
* "StandardCurve",
* "countries",
* "zones"
*
* ]}
*/
export const tables = [
Expand All @@ -37,18 +40,21 @@ export const tables = [
'InfobaseTrend',
'polygons',
'instruments',
'setLUs',
'partLUs',
'sets',
'parts',
'contacts',
'measureSets',
'methodSteps',
'methodSets',
'languageLUs',
'translationLUs',
'languages',
'translations',
'sites',
'samples',
'measures',
'qualityReports',
'StandardCurve',
'countries',
'zones'
] as const;

/**
Expand Down Expand Up @@ -80,14 +86,14 @@ export const tableRelationships: TableRelationships = {
},
{
table: 'datasets',
foreignKeys: 'dataID',
foreignKeys: 'datasetID',
auth: { depth: 1, required: true },
},
{ table: 'methodSets', foreignKeys: 'mSRID' },
{ table: 'contacts', foreignKeys: 'contID' },
{ table: 'measures', foreignKeys: ['sampleID', 'sampID'] },
{ table: 'samples', foreignKeys: ['sampID', 'parSampID'] },
{ table: 'partLUs', foreignKeys: ['partID', 'purposeID'] },
{ table: 'parts', foreignKeys: ['partID', 'purposeID'] },
],
measures: [
{
Expand All @@ -97,15 +103,15 @@ export const tableRelationships: TableRelationships = {
},
{
table: 'datasets',
foreignKeys: 'dataID',
foreignKeys: 'datasetID',
auth: { depth: 1, required: true },
},
{ table: 'methodSets', foreignKeys: 'mSRID' },
{ table: 'samples', foreignKeys: ['sampID', 'sampleID'] },
{ table: 'polygons', foreignKeys: 'polygonID' },
{ table: 'measureSets', foreignKeys: 'measSetRepID' },
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'purpose', foreignKeys: ['partID', 'purposeID'] },
{ property: 'spec', foreignKeys: ['partID', 'specID'] },
Expand All @@ -118,6 +124,15 @@ export const tableRelationships: TableRelationships = {
],
},
],
qualityReports: [
{
table: 'measures',
foreignKeys: 'measureRepID',
auth: { depth: 1, required: true },
},
{ table: 'samples', foreignKeys: 'sampleID' },
// { table: 'contacts', foreignKeys: 'contactID' },
],
measureSets: [
{ table: 'methodSets', foreignKeys: 'mSRID' },
{
Expand All @@ -128,8 +143,8 @@ export const tableRelationships: TableRelationships = {
],
sites: [
{ table: 'sites', foreignKeys: ['siteID', 'parSiteID'] },
{ table: 'polygons', foreignKeys: 'polygonID' },
{ table: 'datasets', foreignKeys: 'dataID' },
// { table: 'polygons', foreignKeys: 'polygonID' },
// { table: 'datasets', foreignKeys: 'datasetID' },
{ table: 'measures', foreignKeys: 'siteID' },
{
table: 'samples',
Expand All @@ -156,13 +171,13 @@ export const tableRelationships: TableRelationships = {
},
{
table: 'samples',
foreignKeys: 'dataID',
foreignKeys: 'datasetID',
auth: { depth: 2, required: true },
},
{ table: 'measures', foreignKeys: 'dataID' },
{ table: 'polygons', foreignKeys: 'dataID' },
{ table: 'instruments', foreignKeys: 'dataID' },
{ table: 'sites', foreignKeys: 'dataID' },
{ table: 'measures', foreignKeys: 'datasetID' },
{ table: 'polygons', foreignKeys: 'datasetID' },
{ table: 'instruments', foreignKeys: 'datasetID' },
{ table: 'sites', foreignKeys: 'datasetID' },
],
polygons: [
{ table: 'measures', foreignKeys: 'polygonID' },
Expand All @@ -173,7 +188,7 @@ export const tableRelationships: TableRelationships = {
},
],
instruments: [
{ table: 'datasets', foreignKeys: 'dataID', auth: { depth: 3 } },
{ table: 'datasets', foreignKeys: 'datasetID', auth: { depth: 3 } },
{ table: 'methodSteps', foreignKeys: 'instID' },
],

Expand All @@ -184,7 +199,7 @@ export const tableRelationships: TableRelationships = {
],
methodSteps: [
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'meth', foreignKeys: ['partID', 'methID'] },
{ property: 'meas', foreignKeys: ['partID', 'measID'] },
Expand All @@ -207,15 +222,15 @@ export const tableRelationships: TableRelationships = {
{ table: 'measures', foreignKeys: 'mSRID' },
{ table: 'measureSets', foreignKeys: 'mSRID' },
],
languageLUs: [{ table: 'translationLUs', foreignKeys: 'langID' }],
translationLUs: [
{ table: 'languageLUs', foreignKeys: 'langID' },
{ table: 'partLUs', foreignKeys: 'partID' },
languages: [{ table: 'translations', foreignKeys: 'langID' }],
translations: [
{ table: 'languages', foreignKeys: 'langID' },
{ table: 'parts', foreignKeys: 'partID' },
],
allSites: [
{
table: 'datasets',
foreignKeys: 'dataID',
foreignKeys: 'datasetID',
auth: { depth: 1, required: true },
},
{
Expand All @@ -225,7 +240,7 @@ export const tableRelationships: TableRelationships = {
},
{ table: 'samples', foreignKeys: ['sampID', 'sampleID'] },
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'fraction', foreignKeys: ['partID', 'fractionID'] },
{ property: 'meas', foreignKeys: ['partID', 'measID'] },
Expand All @@ -235,7 +250,7 @@ export const tableRelationships: TableRelationships = {
allSitesAdj: [
{
table: 'datasets',
foreignKeys: 'dataID',
foreignKeys: 'datasetID',
auth: { depth: 1, required: true },
},
{
Expand All @@ -245,7 +260,7 @@ export const tableRelationships: TableRelationships = {
},
{ table: 'samples', foreignKeys: ['sampID', 'sampleID'] },
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'fraction', foreignKeys: ['partID', 'fractionID'] },
{ property: 'meas', foreignKeys: ['partID', 'measID'] },
Expand All @@ -254,7 +269,7 @@ export const tableRelationships: TableRelationships = {
],
Infobase: [
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'fraction', foreignKeys: ['partID', 'fractionid'] },
{ property: 'meas', foreignKeys: ['partID', 'measureid'] },
Expand All @@ -263,7 +278,7 @@ export const tableRelationships: TableRelationships = {
],
InfobaseTrend: [
{
table: 'partLUs',
table: 'parts',
properties: [
{ property: 'fraction', foreignKeys: ['partID', 'fractionid'] },
{ property: 'meas', foreignKeys: ['partID', 'measureid'] },
Expand Down
4 changes: 2 additions & 2 deletions graphql/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export const groups: { readonly [authGroup: string]: AuthFilters } = {
where: ['healthReg', 'Vancouver'],
},
datasets: {
whereIn: ['dataID', ['BCCDC', 'NML-WWPCR']],
whereIn: ['datasetID', ['BCCDC', 'NML-WWPCR']],
},
},
hnj: {
sites: {
whereIn: ['healthReg', ['Whitehorse', 'Haines Junction']],
},
datasets: {
whereIn: ['dataID', ['NML-WWPCR', 'NML-GXWW', 'onsite-GXWW']],
whereIn: ['datasetID', ['NML-WWPCR', 'NML-GXWW', 'onsite-GXWW']],
},
},
open: {
Expand Down
Loading

0 comments on commit 5efa779

Please sign in to comment.