Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to pending entities with BBIDs / Introducing Kysely #323

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ const stylisticIssuesRules = {
properties: 'always'
}
],
'comma-dangle': ERROR,
'comma-spacing': ERROR,
'comma-style': ERROR,
'computed-property-spacing': ERROR,
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {
"build": "rimraf lib/* && babel src --out-dir lib --extensions .js,.ts && tsc",
"build-js-for-test": "rimraf lib/* && babel src --out-dir lib --source-maps inline --extensions .js,.ts",
"kysely-codegen": "kysely-codegen --out-file src/types/schema.ts --schema bookbrainz --camel-case",
"lint": "eslint .",
"lint-errors": "eslint --quiet .",
"lint-staged": "lint-staged",
Expand Down Expand Up @@ -71,6 +72,7 @@
"deep-diff": "^1.0.2",
"immutable": "^3.8.2",
"knex": "^2.4.2",
"kysely": "^0.27.4",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"pg": "^8.6.0",
Expand Down Expand Up @@ -99,6 +101,7 @@
"glob": "^7.1.2",
"husky": "^8.0.0",
"jsinspect": "^0.12.7",
"kysely-codegen": "^0.17.0",
"lint-staged": "^13.1.0",
"mocha": "^10.2.0",
"node-uuid": "^1.4.8",
Expand Down
152 changes: 0 additions & 152 deletions src/func/create-entity.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/func/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copied from bookbrainz-site
* Copyright (C) 2016 Sean Burke
* 2016 Ben Ockmore
* 2018 Shivam Tripathi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,33 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import {ORM} from '..';
import type {Transaction} from './types';

/**
* Adds 1 to the edit count of the specified editor
*
* @param {ORM} orm - the BookBrainz ORM, initialized during app setup
* @param {string} id - row ID of editor to be updated
* @param {Transaction} transacting - Bookshelf transaction object (must be in
* progress)
* @returns {Promise} - Resolves to the updated editor model
*/
export function incrementEditorEditCountById(
orm: ORM,
id: string,
transacting: Transaction
): Promise<any> {
const {Editor} = orm;
return new Editor({id})
.fetch({transacting})
.then((editor) => {
// @ts-expect-error -- Types for custom methods of Bookshelf models are lacking
editor.incrementEditCount();
return editor.save(null, {transacting});
});
}

/* eslint-disable camelcase */
function getEditorIDByMetaBrainzID(trx, metabrainzUserID) {
return trx('bookbrainz.editor')
Expand Down
105 changes: 0 additions & 105 deletions src/func/entity-sets.ts

This file was deleted.

53 changes: 0 additions & 53 deletions src/func/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,59 +79,6 @@ export function getAdditionalEntityProps(
}
}

export type EntitySetMetadataT = {
entityIdField: string;
idField: string;
mutableFields?: string[];
name: string;
propName: string;
};

/**
* @param {string} entityType - Entity type string
* @returns {Object} - Returns entitySetMetadata (derivedSets)
*/
export function getEntitySetMetadataByType(entityType: EntityTypeString): EntitySetMetadataT[] {
if (entityType === 'Edition') {
return [
{
entityIdField: 'languageSetId',
idField: 'id',
name: 'languageSet',
propName: 'languages'
},
{
entityIdField: 'publisherSetId',
idField: 'bbid',
name: 'publisherSet',
propName: 'publishers'
},
{
entityIdField: 'releaseEventSetId',
idField: 'id',
mutableFields: [
'date',
'areaId'
],
name: 'releaseEventSet',
propName: 'releaseEvents'
}
];
}
else if (entityType === 'Work') {
return [
{
entityIdField: 'languageSetId',
idField: 'id',
name: 'languageSet',
propName: 'languages'
}
];
}

return [];
}

/**
* Returns all entity models defined in bookbrainz-data-js
*
Expand Down
Loading