From 1503c242d858469d78772ae48ce662153160ba3a Mon Sep 17 00:00:00 2001 From: Daniel Haarhoff Date: Wed, 26 Jun 2024 10:50:28 +0100 Subject: [PATCH] Make OpenAlex field information available #13 --- src/data/requests.json.ts | 2 ++ src/lib/OpenAlex.ts | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/lib/OpenAlex.ts diff --git a/src/data/requests.json.ts b/src/data/requests.json.ts index 3188166..198356a 100644 --- a/src/data/requests.json.ts +++ b/src/data/requests.json.ts @@ -3,12 +3,14 @@ import { NodeTerminal } from '@effect/platform-node' import { Schema } from '@effect/schema' import { Effect } from 'effect' import * as LanguageCode from '../lib/LanguageCode.js' +import { FieldIdSchema } from '../lib/OpenAlex.js' import * as Temporal from '../lib/Temporal.js' const Requests = Schema.Array( Schema.Struct({ timestamp: Temporal.InstantFromStringSchema, language: Schema.optional(LanguageCode.LanguageCodeSchema, { nullable: true }), + fields: Schema.Array(FieldIdSchema), }), ) diff --git a/src/lib/OpenAlex.ts b/src/lib/OpenAlex.ts new file mode 100644 index 0000000..ef338fe --- /dev/null +++ b/src/lib/OpenAlex.ts @@ -0,0 +1,8 @@ +import { Schema } from '@effect/schema' +import { Brand } from 'effect' + +type FieldId = string & Brand.Brand<'OpenAlexFieldId'> + +const FieldId = Brand.nominal() + +export const FieldIdSchema = Schema.String.pipe(Schema.fromBrand(FieldId))