Skip to content

Commit

Permalink
removed unused schemas, updated create collection schema field
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Nov 14, 2024
1 parent 121f8f5 commit a775f6b
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 169 deletions.
88 changes: 0 additions & 88 deletions src/models/generated/schemasPublic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,6 @@ export interface EntityMention {
}


/**
* Response for GET /text-reuse-clusters
*/
export interface FindTextReuseClustersResponse {
clusters: unknown[];
info: {
[k: string]: unknown;
};
}


/**
* A newspaper
*/
Expand Down Expand Up @@ -251,60 +240,6 @@ export interface Newspaper {
}


/**
* An object containing search results for a facet
*/
export interface SearchFacet {
/**
* The type of facet
*/
type: string;
/**
* The number of buckets in the facet
*/
numBuckets: number;
buckets: SearchFacetBucket[] | SearchFacetRangeBucket[];
}
/**
* Facet bucket
*/
export interface SearchFacetBucket {
/**
* Number of items in the bucket
*/
count: number;
/**
* Value that represents the bucket.
*/
value: string | number;
/**
* Label of the value, if relevant.
*/
label?: string;
}
/**
* Facet bucket
*/
export interface SearchFacetRangeBucket {
/**
* Number of items in the bucket
*/
count: number;
/**
* Value of the 'type' element
*/
val: number;
/**
* Lower bound of the range
*/
lower?: number;
/**
* Lower bound of the range
*/
upper?: number;
}


/**
* Facet bucket
*/
Expand All @@ -324,29 +259,6 @@ export interface SearchFacetBucket {
}


/**
* Facet bucket
*/
export interface SearchFacetRangeBucket {
/**
* Number of items in the bucket
*/
count: number;
/**
* Value of the 'type' element
*/
val: number;
/**
* Lower bound of the range
*/
lower?: number;
/**
* Lower bound of the range
*/
upper?: number;
}


/**
* Text reuse cluster details.
*/
Expand Down
11 changes: 6 additions & 5 deletions src/models/generated/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,23 @@ export interface ImpressoNamedEntityRecognitionEntity {
}


export type StatusOfTheCollection = string;

/**
* Create new collection request
*/
export interface NewCollection {
export interface NewCollectionRequest {
name: string;
description?: string;
status?: StatusOfTheCollection;
/**
* Access level of the collection.
*/
accessLevel?: "public" | "private";
}


/**
* Request to update collectible items in a collection
*/
export interface UpdateCollectableItems {
export interface UpdateCollectableItemsRequest {
/**
* IDs of the items to add to the collection
*/
Expand Down
2 changes: 1 addition & 1 deletion src/schema/schemas/ContentItem.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ContentItem",
"title": "Content Item",
"description": "A journal/magazine content item (article, advertisement, etc.)",
"type": "object",
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion src/schema/schemas/EntityDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "An entity like location, person, etc",
"type": "object",
"title": "EntityDetails",
"title": "Entity Details",
"additionalProperties": false,
"properties": {
"uid": {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/schemasPublic/ContentItem.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ContentItem",
"title": "Content Item",
"description": "A journal/magazine content item (article, advertisement, etc.)",
"type": "object",
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion src/schema/schemasPublic/EntityDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "An entity: location or person.",
"type": "object",
"title": "EntityDetails",
"title": "Entity Details",
"additionalProperties": false,
"properties": {
"uid": {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/schemasPublic/EntityMention.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "An entity (location, persion) mention.",
"type": "object",
"title": "EntityMention",
"title": "Entity Mention",
"additionalProperties": false,
"properties": {
"uid": {
Expand Down
30 changes: 0 additions & 30 deletions src/schema/schemasPublic/SearchFacet.json

This file was deleted.

26 changes: 0 additions & 26 deletions src/schema/schemasPublic/SearchFacetRangeBucket.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/schema/schemasPublic/TopicMention.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "TopicMention",
"title": "Topic Mention",
"description": "Topic presence in a content item.",
"type": "object",
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion src/schema/shared/CollectableItemsUpdatedResponse.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Request to update collectible items in a collection",
"title": "CollectableItemsUpdatedResponse",
"title": "Collectable Items Updated Response",
"type": "object",
"required": ["totalAdded", "totalRemoved"],
"properties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "New Collection",
"title": "New Collection Request",
"description": "Create new collection request",
"type": "object",
"additionalProperties": false,
Expand All @@ -14,12 +14,10 @@
"type": "string",
"maxLength": 500
},
"status": {
"accessLevel": {
"type": "string",
"minLength": 2,
"maxLength": 3,
"title": "Status of the collection",
"examples": ["PRI", "PUB"]
"description": "Access level of the collection.",
"enum": ["public", "private"]
}
},
"required": ["name"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Request to update collectible items in a collection",
"title": "UpdateCollectableItems",
"title": "Update Collectable Items Request",
"type": "object",
"properties": {
"add": {
Expand Down
4 changes: 2 additions & 2 deletions src/services/collectable-items/collectable-items.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import lodash from 'lodash'
import { Op } from 'sequelize'
import CollectableItemGroup from '../../models/collectable-items-groups.model'
import { STATUS_DELETED, STATUS_PUBLIC, STATUS_SHARED } from '../../models/collections.model'
import { CollectableItemsUpdatedResponse, UpdateCollectableItems } from '../../models/generated/shared'
import { CollectableItemsUpdatedResponse, UpdateCollectableItemsRequest } from '../../models/generated/shared'
import User from '../../models/users.model'
import { ImpressoApplication } from '../../types'
import { measureTime } from '../../util/instruments'
Expand Down Expand Up @@ -298,7 +298,7 @@ export class Service {
*/
async patch(
id: NullableId,
data: UpdateCollectableItems,
data: UpdateCollectableItemsRequest,
params: Params<PatchQuery> & WithUser
): Promise<CollectableItemsUpdatedResponse> {
if (id != null) throw new Error('Patch operation is not supported on a single item')
Expand Down
4 changes: 2 additions & 2 deletions src/services/collectable-items/collectable-items.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const docs: ServiceSwaggerOptions = {
// the `RefParser.bundle` will fail with an error
// "MissingPointerError: Token ":id" does not exist."
requestBody: {
content: getRequestBodyContent('UpdateCollectableItems'),
content: getRequestBodyContent('UpdateCollectableItemsRequest'),
},
responses: getStandardResponses({
method: 'patchMulti',
Expand All @@ -43,7 +43,7 @@ export const docs: ServiceSwaggerOptions = {
description: 'Update items in the collection',
parameters: patchParameters,
requestBody: {
content: getRequestBodyContent('UpdateCollectableItems'),
content: getRequestBodyContent('UpdateCollectableItemsRequest'),
},
responses: getStandardResponses({
method: 'patchMulti',
Expand Down
11 changes: 11 additions & 0 deletions src/services/collections/collections.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ module.exports = {
},
'POST'
),
// rename accessLevel (public schema) to status (private schema)
// TODO: make this nicer
context => {
if (context.data.accessLevel != null) {
if (context.data.accessLevel === 'public') {
context.data.status = 'PUB'
} else if (context.data.accessLevel === 'private') {
context.data.status = 'PRI'
}
}
},
],
update: [],
patch: [
Expand Down
4 changes: 2 additions & 2 deletions src/services/collections/collections.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const getDocs = (isPublicApi: boolean): ServiceSwaggerOptions => ({
operationId: 'createCollection',
description: 'Create a new collection',
requestBody: {
content: getRequestBodyContent('NewCollection'),
content: getRequestBodyContent('NewCollectionRequest'),
},
responses: getStandardResponses({
method: 'create',
Expand All @@ -122,7 +122,7 @@ export const getDocs = (isPublicApi: boolean): ServiceSwaggerOptions => ({
},
],
requestBody: {
content: getRequestBodyContent('NewCollection'),
content: getRequestBodyContent('NewCollectionRequest'),
},
responses: getStandardResponses({
method: 'patch',
Expand Down

0 comments on commit a775f6b

Please sign in to comment.