Skip to content

Commit 3c1370a

Browse files
authored
Merge pull request #323 from kellnerd/entity-import-bbid
Adapt to pending entities with BBIDs / Introducing Kysely
2 parents f8623d2 + 7926bc2 commit 3c1370a

29 files changed

+1406
-656
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ const stylisticIssuesRules = {
200200
properties: 'always'
201201
}
202202
],
203-
'comma-dangle': ERROR,
204203
'comma-spacing': ERROR,
205204
'comma-style': ERROR,
206205
'computed-property-spacing': ERROR,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"scripts": {
1111
"build": "rimraf lib/* && babel src --out-dir lib --extensions .js,.ts && tsc",
1212
"build-js-for-test": "rimraf lib/* && babel src --out-dir lib --source-maps inline --extensions .js,.ts",
13+
"kysely-codegen": "kysely-codegen --out-file src/types/schema.ts --schema bookbrainz --camel-case",
1314
"lint": "eslint .",
1415
"lint-errors": "eslint --quiet .",
1516
"lint-staged": "lint-staged",
@@ -71,6 +72,7 @@
7172
"deep-diff": "^1.0.2",
7273
"immutable": "^3.8.2",
7374
"knex": "^2.4.2",
75+
"kysely": "^0.27.4",
7476
"lodash": "^4.17.21",
7577
"moment": "^2.29.1",
7678
"pg": "^8.6.0",
@@ -99,6 +101,7 @@
99101
"glob": "^7.1.2",
100102
"husky": "^8.0.0",
101103
"jsinspect": "^0.12.7",
104+
"kysely-codegen": "^0.17.0",
102105
"lint-staged": "^13.1.0",
103106
"mocha": "^10.2.0",
104107
"node-uuid": "^1.4.8",

src/func/create-entity.ts

Lines changed: 0 additions & 152 deletions
This file was deleted.

src/func/editor.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copied from bookbrainz-site
33
* Copyright (C) 2016 Sean Burke
44
* 2016 Ben Ockmore
5-
* 2018 Shivam Tripathi
65
*
76
* This program is free software; you can redistribute it and/or modify
87
* it under the terms of the GNU General Public License as published by
@@ -19,33 +18,6 @@
1918
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2019
*/
2120

22-
import {ORM} from '..';
23-
import type {Transaction} from './types';
24-
25-
/**
26-
* Adds 1 to the edit count of the specified editor
27-
*
28-
* @param {ORM} orm - the BookBrainz ORM, initialized during app setup
29-
* @param {string} id - row ID of editor to be updated
30-
* @param {Transaction} transacting - Bookshelf transaction object (must be in
31-
* progress)
32-
* @returns {Promise} - Resolves to the updated editor model
33-
*/
34-
export function incrementEditorEditCountById(
35-
orm: ORM,
36-
id: string,
37-
transacting: Transaction
38-
): Promise<any> {
39-
const {Editor} = orm;
40-
return new Editor({id})
41-
.fetch({transacting})
42-
.then((editor) => {
43-
// @ts-expect-error -- Types for custom methods of Bookshelf models are lacking
44-
editor.incrementEditCount();
45-
return editor.save(null, {transacting});
46-
});
47-
}
48-
4921
/* eslint-disable camelcase */
5022
function getEditorIDByMetaBrainzID(trx, metabrainzUserID) {
5123
return trx('bookbrainz.editor')

src/func/entity-sets.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/func/entity.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -79,59 +79,6 @@ export function getAdditionalEntityProps(
7979
}
8080
}
8181

82-
export type EntitySetMetadataT = {
83-
entityIdField: string;
84-
idField: string;
85-
mutableFields?: string[];
86-
name: string;
87-
propName: string;
88-
};
89-
90-
/**
91-
* @param {string} entityType - Entity type string
92-
* @returns {Object} - Returns entitySetMetadata (derivedSets)
93-
*/
94-
export function getEntitySetMetadataByType(entityType: EntityTypeString): EntitySetMetadataT[] {
95-
if (entityType === 'Edition') {
96-
return [
97-
{
98-
entityIdField: 'languageSetId',
99-
idField: 'id',
100-
name: 'languageSet',
101-
propName: 'languages'
102-
},
103-
{
104-
entityIdField: 'publisherSetId',
105-
idField: 'bbid',
106-
name: 'publisherSet',
107-
propName: 'publishers'
108-
},
109-
{
110-
entityIdField: 'releaseEventSetId',
111-
idField: 'id',
112-
mutableFields: [
113-
'date',
114-
'areaId'
115-
],
116-
name: 'releaseEventSet',
117-
propName: 'releaseEvents'
118-
}
119-
];
120-
}
121-
else if (entityType === 'Work') {
122-
return [
123-
{
124-
entityIdField: 'languageSetId',
125-
idField: 'id',
126-
name: 'languageSet',
127-
propName: 'languages'
128-
}
129-
];
130-
}
131-
132-
return [];
133-
}
134-
13582
/**
13683
* Returns all entity models defined in bookbrainz-data-js
13784
*

0 commit comments

Comments
 (0)