"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = init;
exports.func = void 0;
var func = _interopRequireWildcard(require("./func"));
exports.func = func;
var util = _interopRequireWildcard(require("./util"));
var _knex = require("knex");
var _bookshelf = _interopRequireDefault(require("@metabrainz/bookshelf"));
var _achievementType = _interopRequireDefault(require("./models/achievementType"));
var _achievementUnlock = _interopRequireDefault(require("./models/achievementUnlock"));
var _adminLog = _interopRequireDefault(require("./models/adminLog"));
var _alias = _interopRequireDefault(require("./models/alias"));
var _aliasSet = _interopRequireDefault(require("./models/aliasSet"));
var _annotation = _interopRequireDefault(require("./models/annotation"));
var _area = _interopRequireDefault(require("./models/area"));
var _areaType = _interopRequireDefault(require("./models/areaType"));
var _author = _interopRequireDefault(require("./models/entities/author"));
var _authorCredit = _interopRequireDefault(require("./models/authorCredit"));
var _authorCreditName = _interopRequireDefault(require("./models/authorCreditName"));
var _authorData = _interopRequireDefault(require("./models/data/authorData"));
var _authorHeader = _interopRequireDefault(require("./models/headers/authorHeader"));
var _authorImport = _interopRequireDefault(require("./models/imports/authorImport"));
var _authorRevision = _interopRequireDefault(require("./models/revisions/authorRevision"));
var _authorType = _interopRequireDefault(require("./models/authorType"));
var _disambiguation = _interopRequireDefault(require("./models/disambiguation"));
var _edition = _interopRequireDefault(require("./models/entities/edition"));
var _editionData = _interopRequireDefault(require("./models/data/editionData"));
var _editionFormat = _interopRequireDefault(require("./models/editionFormat"));
var _editionGroup = _interopRequireDefault(require("./models/entities/editionGroup"));
var _editionGroupData = _interopRequireDefault(require("./models/data/editionGroupData"));
var _editionGroupHeader = _interopRequireDefault(require("./models/headers/editionGroupHeader"));
var _editionGroupImport = _interopRequireDefault(require("./models/imports/editionGroupImport"));
var _editionGroupRevision = _interopRequireDefault(require("./models/revisions/editionGroupRevision"));
var _editionGroupType = _interopRequireDefault(require("./models/editionGroupType"));
var _editionHeader = _interopRequireDefault(require("./models/headers/editionHeader"));
var _editionImport = _interopRequireDefault(require("./models/imports/editionImport"));
var _editionRevision = _interopRequireDefault(require("./models/revisions/editionRevision"));
var _editionStatus = _interopRequireDefault(require("./models/editionStatus"));
var _editor = _interopRequireDefault(require("./models/editor"));
var _editorEntityVisits = _interopRequireDefault(require("./models/editorEntityVisits"));
var _editorType = _interopRequireDefault(require("./models/editorType"));
var _entity = _interopRequireDefault(require("./models/entity"));
var _externalServiceOauth = _interopRequireDefault(require("./models/externalServiceOauth"));
var _gender = _interopRequireDefault(require("./models/gender"));
var _identifier = _interopRequireDefault(require("./models/identifier"));
var _identifierSet = _interopRequireDefault(require("./models/identifierSet"));
var _identifierType = _interopRequireDefault(require("./models/identifierType"));
var _language = _interopRequireDefault(require("./models/language"));
var _languageSet = _interopRequireDefault(require("./models/languageSet"));
var _note = _interopRequireDefault(require("./models/note"));
var _publisher = _interopRequireDefault(require("./models/entities/publisher"));
var _publisherData = _interopRequireDefault(require("./models/data/publisherData"));
var _publisherHeader = _interopRequireDefault(require("./models/headers/publisherHeader"));
var _publisherImport = _interopRequireDefault(require("./models/imports/publisherImport"));
var _publisherRevision = _interopRequireDefault(require("./models/revisions/publisherRevision"));
var _publisherSet = _interopRequireDefault(require("./models/publisherSet"));
var _publisherType = _interopRequireDefault(require("./models/publisherType"));
var _relationship = _interopRequireDefault(require("./models/relationship"));
var _relationshipAttribute = _interopRequireDefault(require("./models/relationshipAttribute"));
var _relationshipAttributeSet = _interopRequireDefault(require("./models/relationshipAttributeSet"));
var _relationshipAttributeTextValue = _interopRequireDefault(require("./models/relationshipAttributeTextValue"));
var _relationshipAttributeType = _interopRequireDefault(require("./models/relationshipAttributeType"));
var _relationshipSet = _interopRequireDefault(require("./models/relationshipSet"));
var _relationshipType = _interopRequireDefault(require("./models/relationshipType"));
var _relationshipTypeAttributeType = _interopRequireDefault(require("./models/relationshipTypeAttributeType"));
var _releaseEvent = _interopRequireDefault(require("./models/releaseEvent"));
var _releaseEventSet = _interopRequireDefault(require("./models/releaseEventSet"));
var _revision = _interopRequireDefault(require("./models/revision"));
var _series = _interopRequireDefault(require("./models/entities/series"));
var _seriesData = _interopRequireDefault(require("./models/data/seriesData"));
var _seriesHeader = _interopRequireDefault(require("./models/headers/seriesHeader"));
var _seriesImport = _interopRequireDefault(require("./models/imports/seriesImport"));
var _seriesOrderingType = _interopRequireDefault(require("./models/seriesOrderingType"));
var _seriesRevision = _interopRequireDefault(require("./models/revisions/seriesRevision"));
var _titleType = _interopRequireDefault(require("./models/titleType"));
var _titleUnlock = _interopRequireDefault(require("./models/titleUnlock"));
var _userCollection = _interopRequireDefault(require("./models/userCollection"));
var _userCollectionCollaborator = _interopRequireDefault(require("./models/userCollectionCollaborator"));
var _userCollectionItem = _interopRequireDefault(require("./models/userCollectionItem"));
var _work = _interopRequireDefault(require("./models/entities/work"));
var _workData = _interopRequireDefault(require("./models/data/workData"));
var _workHeader = _interopRequireDefault(require("./models/headers/workHeader"));
var _workImport = _interopRequireDefault(require("./models/imports/workImport"));
var _workRevision = _interopRequireDefault(require("./models/revisions/workRevision"));
var _workType = _interopRequireDefault(require("./models/workType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/*
* Copyright (C) 2015 Ben Ockmore
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// eslint-disable-line import/no-namespace
/**
* Initialize the database connection and models.
* @param {Knex.Config} config - A knex.js configuration object.
* @returns {Object} All data models.
*/
function init(config) {
const bookshelf = (0, _bookshelf.default)((0, _knex.knex)(config));
bookshelf.plugin('bookshelf-virtuals-plugin');
// Initialize these here to set up dependencies
const AuthorData = (0, _authorData.default)(bookshelf);
const EditionData = (0, _editionData.default)(bookshelf);
const EditionGroupData = (0, _editionGroupData.default)(bookshelf);
const PublisherData = (0, _publisherData.default)(bookshelf);
const SeriesData = (0, _seriesData.default)(bookshelf);
const WorkData = (0, _workData.default)(bookshelf);
return {
AchievementType: (0, _achievementType.default)(bookshelf),
AchievementUnlock: (0, _achievementUnlock.default)(bookshelf),
AdminLog: (0, _adminLog.default)(bookshelf),
Alias: (0, _alias.default)(bookshelf),
AliasSet: (0, _aliasSet.default)(bookshelf),
Annotation: (0, _annotation.default)(bookshelf),
Area: (0, _area.default)(bookshelf),
AreaType: (0, _areaType.default)(bookshelf),
Author: (0, _author.default)(bookshelf),
AuthorCredit: (0, _authorCredit.default)(bookshelf),
AuthorCreditName: (0, _authorCreditName.default)(bookshelf),
AuthorData,
AuthorHeader: (0, _authorHeader.default)(bookshelf),
AuthorImport: (0, _authorImport.default)(bookshelf),
AuthorRevision: (0, _authorRevision.default)(bookshelf),
AuthorType: (0, _authorType.default)(bookshelf),
Disambiguation: (0, _disambiguation.default)(bookshelf),
Edition: (0, _edition.default)(bookshelf),
EditionData,
EditionFormat: (0, _editionFormat.default)(bookshelf),
EditionGroup: (0, _editionGroup.default)(bookshelf),
EditionGroupData,
EditionGroupHeader: (0, _editionGroupHeader.default)(bookshelf),
EditionGroupImport: (0, _editionGroupImport.default)(bookshelf),
EditionGroupRevision: (0, _editionGroupRevision.default)(bookshelf),
EditionGroupType: (0, _editionGroupType.default)(bookshelf),
EditionHeader: (0, _editionHeader.default)(bookshelf),
EditionImport: (0, _editionImport.default)(bookshelf),
EditionRevision: (0, _editionRevision.default)(bookshelf),
EditionStatus: (0, _editionStatus.default)(bookshelf),
Editor: (0, _editor.default)(bookshelf),
EditorEntityVisits: (0, _editorEntityVisits.default)(bookshelf),
EditorType: (0, _editorType.default)(bookshelf),
Entity: (0, _entity.default)(bookshelf),
ExternalServiceOauth: (0, _externalServiceOauth.default)(bookshelf),
Gender: (0, _gender.default)(bookshelf),
Identifier: (0, _identifier.default)(bookshelf),
IdentifierSet: (0, _identifierSet.default)(bookshelf),
IdentifierType: (0, _identifierType.default)(bookshelf),
Language: (0, _language.default)(bookshelf),
LanguageSet: (0, _languageSet.default)(bookshelf),
Note: (0, _note.default)(bookshelf),
Publisher: (0, _publisher.default)(bookshelf),
PublisherData,
PublisherHeader: (0, _publisherHeader.default)(bookshelf),
PublisherImport: (0, _publisherImport.default)(bookshelf),
PublisherRevision: (0, _publisherRevision.default)(bookshelf),
PublisherSet: (0, _publisherSet.default)(bookshelf),
PublisherType: (0, _publisherType.default)(bookshelf),
Relationship: (0, _relationship.default)(bookshelf),
RelationshipAttribute: (0, _relationshipAttribute.default)(bookshelf),
RelationshipAttributeSet: (0, _relationshipAttributeSet.default)(bookshelf),
RelationshipAttributeTextValue: (0, _relationshipAttributeTextValue.default)(bookshelf),
RelationshipAttributeType: (0, _relationshipAttributeType.default)(bookshelf),
RelationshipSet: (0, _relationshipSet.default)(bookshelf),
RelationshipType: (0, _relationshipType.default)(bookshelf),
RelationshipTypeAttributeType: (0, _relationshipTypeAttributeType.default)(bookshelf),
ReleaseEvent: (0, _releaseEvent.default)(bookshelf),
ReleaseEventSet: (0, _releaseEventSet.default)(bookshelf),
Revision: (0, _revision.default)(bookshelf),
Series: (0, _series.default)(bookshelf),
SeriesData,
SeriesHeader: (0, _seriesHeader.default)(bookshelf),
SeriesImport: (0, _seriesImport.default)(bookshelf),
SeriesOrderingType: (0, _seriesOrderingType.default)(bookshelf),
SeriesRevision: (0, _seriesRevision.default)(bookshelf),
TitleType: (0, _titleType.default)(bookshelf),
TitleUnlock: (0, _titleUnlock.default)(bookshelf),
UserCollection: (0, _userCollection.default)(bookshelf),
UserCollectionCollaborator: (0, _userCollectionCollaborator.default)(bookshelf),
UserCollectionItem: (0, _userCollectionItem.default)(bookshelf),
Work: (0, _work.default)(bookshelf),
WorkData,
WorkHeader: (0, _workHeader.default)(bookshelf),
WorkImport: (0, _workImport.default)(bookshelf),
WorkRevision: (0, _workRevision.default)(bookshelf),
WorkType: (0, _workType.default)(bookshelf),
bookshelf,
func,
util
};
}