diff --git a/docs/reference/jspsych-metadata.md b/docs/reference/jspsych-metadata.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/metadata/src/AuthorsMap.ts b/packages/metadata/src/AuthorsMap.ts index ec9ff0350a..1566f3e35c 100644 --- a/packages/metadata/src/AuthorsMap.ts +++ b/packages/metadata/src/AuthorsMap.ts @@ -8,7 +8,7 @@ */ export interface AuthorFields { /** The type of the author. */ - type?: string; + "@type"?: string; /** The name of the author. (required) */ name: string; /** The given name of the author. */ @@ -86,7 +86,7 @@ export class AuthorsMap { this.authors[name] = newAuthor; const unexpectedFields = Object.keys(author).filter( - (key) => !["type", "name", "givenName", "familyName", "identifier"].includes(key) + (key) => !["@type", "name", "givenName", "familyName", "identifier"].includes(key) ); if (unexpectedFields.length > 0) { console.warn( diff --git a/packages/metadata/src/VariablesMap.ts b/packages/metadata/src/VariablesMap.ts index dcf5ed6533..8e621bda29 100644 --- a/packages/metadata/src/VariablesMap.ts +++ b/packages/metadata/src/VariablesMap.ts @@ -7,7 +7,7 @@ * @typedef {VariableFields} */ export interface VariableFields { - type?: string; + "@type"?: string; name: string; // required description?: string | Record; value?: string; // string, boolean, or number @@ -56,7 +56,7 @@ export class VariablesMap { this.variables = {}; const trial_type_var: VariableFields = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown", @@ -67,7 +67,7 @@ export class VariablesMap { this.setVariable(trial_type_var); const trial_index_var: VariableFields = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_index", description: { default: "unknown", @@ -78,7 +78,7 @@ export class VariablesMap { this.setVariable(trial_index_var); const time_elapsed_var: VariableFields = { - type: "PropertyValue", + "@type": "PropertyValue", name: "time_elapsed", description: { default: "unknown", @@ -146,7 +146,7 @@ export class VariablesMap { const unexpectedFields = Object.keys(variable).filter( (key) => ![ - "type", + "@type", "name", "description", "value", diff --git a/packages/metadata/src/index.ts b/packages/metadata/src/index.ts index de27eef44a..758757ed52 100644 --- a/packages/metadata/src/index.ts +++ b/packages/metadata/src/index.ts @@ -113,7 +113,7 @@ export default class JsPsychMetadata { * as a way to update fields. * * @param {{ - * type?: string; + * @type?: string; * name: string; // required * description?: string | {}; * value?: string; // string, boolean, or number @@ -324,7 +324,7 @@ export default class JsPsychMetadata { if (!this.containsVariable(variable)) { // probs should have update description called here const new_var = { - type: "PropertyValue", + "@type": "PropertyValue", name: variable, description: { default: "unknown" }, value: type, diff --git a/packages/metadata/tests/metadata-maps.test.ts b/packages/metadata/tests/metadata-maps.test.ts index 5a68ac0947..2805cd50f4 100644 --- a/packages/metadata/tests/metadata-maps.test.ts +++ b/packages/metadata/tests/metadata-maps.test.ts @@ -11,11 +11,11 @@ let author_data = [ name: "Barrack Obama", }, { - type: "Author", + "@type": "Author", name: "Donald Trump", }, { - type: "Contributor", + "@type": "Contributor", name: "Stan Johnson", givenName: "Julio Jones", familyName: "Aaron", @@ -42,7 +42,7 @@ describe("AuthorsMap", () => { test("#setOverwrite", () => { const newJohnCena = { - type: "WWE Pro Wrestler", + "@type": "WWE Pro Wrestler", name: "John Cena", }; @@ -64,7 +64,7 @@ describe("AuthorsMap", () => { const variable_data: VariableFields[] = [ { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown", @@ -73,7 +73,7 @@ const variable_data: VariableFields[] = [ value: "string", }, { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_index", description: { default: "unknown", @@ -82,7 +82,7 @@ const variable_data: VariableFields[] = [ value: "numeric", }, { - type: "PropertyValue", + "@type": "PropertyValue", name: "time_elapsed", description: { default: "unknown", @@ -108,7 +108,7 @@ describe("VariablesMap", () => { test("#setOverwrite", () => { const newTrialType: VariableFields = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "different fields", @@ -143,7 +143,7 @@ describe("VariablesMap", () => { // // updating normal variable (exists and doesn't exist) test("#updateNormalVariables", () => { const compare = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown", @@ -169,7 +169,7 @@ describe("VariablesMap", () => { test("#updateLevels", () => { interface Compare { - type: string; + "@type": string; name: string; description: {}; value: string; @@ -177,7 +177,7 @@ describe("VariablesMap", () => { } const compare: Compare = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown", @@ -205,7 +205,7 @@ describe("VariablesMap", () => { // // updating name (checking references) test("#updatingName", () => { const compare = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown", @@ -227,7 +227,7 @@ describe("VariablesMap", () => { } let one_key_string = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: "unknown", value: "string", @@ -243,7 +243,7 @@ describe("VariablesMap", () => { } let two_key = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: { grown: "how tall the user is", @@ -262,7 +262,7 @@ describe("VariablesMap", () => { } let add_default = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: { default: "how tall the user is", @@ -272,7 +272,7 @@ describe("VariablesMap", () => { }; let expected = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: "what the user likes to eat", value: "string", @@ -288,7 +288,7 @@ describe("VariablesMap", () => { } let add_default = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: { default: "how tall the user is", @@ -299,7 +299,7 @@ describe("VariablesMap", () => { }; let expected = { - type: "PropertyValue", + "@type": "PropertyValue", name: "animation style", description: { diet: "what the user likes to eat", diff --git a/packages/metadata/tests/metadata-module.test.ts b/packages/metadata/tests/metadata-module.test.ts index dc492bb9a9..c5f80805b8 100644 --- a/packages/metadata/tests/metadata-module.test.ts +++ b/packages/metadata/tests/metadata-module.test.ts @@ -39,7 +39,7 @@ describe("JsPsychMetadata", () => { test("#setAndGetVariable", () => { const trialType = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: "Plugin type that has been used to run trials", value: "string", @@ -51,7 +51,7 @@ describe("JsPsychMetadata", () => { test("#deleteVariable", () => { const trialType = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: "Plugin type that has been used to run trials", value: "string", @@ -64,7 +64,7 @@ describe("JsPsychMetadata", () => { test("#updateVariable", () => { const trialType = { - type: "PropertyValue", + "@type": "PropertyValue", name: "trial_type", description: { default: "unknown",