Skip to content

Commit

Permalink
Merge pull request #31 from UN-OCHA/attachment-improvements
Browse files Browse the repository at this point in the history
🐛 Correct properties for attachment model
  • Loading branch information
Pl217 authored Nov 3, 2021
2 parents a4b5fde + 5963b71 commit 740307f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unocha/hpc-api-core",
"version": "0.2.0",
"version": "0.2.1",
"description": "Core libraries supporting HPC.Tools API Backend",
"license": "Apache-2.0",
"private": false,
Expand Down
15 changes: 10 additions & 5 deletions src/db/models/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { brandedType } from '../../util/io-ts';

import type { Brand } from '../../util/types';
import { defineLegacyVersionedModel } from '../util/legacy-versioned-model';
import { ATTACHMENT_PROTOTYPE_ID } from './attachmentPrototype';
import {
ATTACHMENT_PROTOTYPE_ID,
ATTACHMENT_TYPE,
} from './attachmentPrototype';
import { PLAN_ID } from './plan';

export type AttachmentId = Brand<
Expand All @@ -14,8 +17,10 @@ export type AttachmentId = Brand<

export const ATTACHMENT_ID = brandedType<number, AttachmentId>(t.number);

export const COST_ATTACHMENT_VALUE = t.type({
cost: t.number,
export const ATTACHMENT_OBJECT_TYPE = t.keyof({
governingEntity: null,
plan: null,
planEntity: null,
});

export default defineLegacyVersionedModel({
Expand Down Expand Up @@ -44,11 +49,11 @@ export default defineLegacyVersionedModel({
},
objectType: {
kind: 'checked',
type: t.string,
type: ATTACHMENT_OBJECT_TYPE,
},
type: {
kind: 'checked',
type: t.string,
type: ATTACHMENT_TYPE,
},
},
},
Expand Down
1 change: 0 additions & 1 deletion src/db/models/planVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default defineLegacyVersionedModel({
brand: PLAN_REPORTING_PERIOD_ID,
},
lastPublishedReportingPeriodId: { kind: 'checked', type: t.number },
// Even though this column isn't defined using DB enum only two values are used
clusterSelectionType: {
kind: 'checked',
type: PLAN_VERSION_CLUSTER_SELECTION_TYPE,
Expand Down

0 comments on commit 740307f

Please sign in to comment.