UNPKG

git-documentdb

Version:

Offline-first database that syncs with Git

481 lines 14.5 kB
"use strict"; /** * GitDocumentDB * Copyright (c) Hidekazu Kubota * * This source code is licensed under the Mozilla Public License Version 2.0 * found in the LICENSE file in the root directory of this source tree. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Err = void 0; /* eslint-disable unicorn/custom-error-definition */ /** * Namespace for errors * * @public */ var Err; (function (Err) { /** * BaseError * * @privateRemarks * Use 'unknown' type assertion for constructor arguments in subclass of BaseError * to use 'expect' in test. See https://github.com/facebook/jest/issues/8279 */ class BaseError extends Error { constructor(e) { super(e); this.name = new.target.name; Object.setPrototypeOf(this, new.target.prototype); } } /** * @public */ class UndefinedDatabaseNameError extends BaseError { constructor(e = `Database name is undefined: Option must have dbName`) { super(e); } } Err.UndefinedDatabaseNameError = UndefinedDatabaseNameError; /** * @public */ class CannotCreateDirectoryError extends BaseError { constructor(e = 'Cannot create directory') { super(e); } } Err.CannotCreateDirectoryError = CannotCreateDirectoryError; /** * @public */ class CannotWriteDataError extends BaseError { constructor(e = 'Cannot write data') { super(e); } } Err.CannotWriteDataError = CannotWriteDataError; /** * @public */ class CannotDeleteDataError extends BaseError { constructor(e = 'Cannot write data') { super(e); } } Err.CannotDeleteDataError = CannotDeleteDataError; /** * @public */ class InvalidCollectionPathCharacterError extends BaseError { constructor(name) { const e = `Invalid collectionPath character '${name}'`; super(e); } } Err.InvalidCollectionPathCharacterError = InvalidCollectionPathCharacterError; /** * @public */ class InvalidCollectionPathLengthError extends BaseError { constructor(collectionPath, minLength, maxLength) { super(`Invalid collectionPath length: A byte length of '${collectionPath}' must be equal to or more than ${minLength} and equal to or less than ${maxLength}.`); } } Err.InvalidCollectionPathLengthError = InvalidCollectionPathLengthError; /** * @public */ class InvalidWorkingDirectoryPathLengthError extends BaseError { constructor(path, minLength, maxLength) { super(`Invalid working directory path length: A byte length of '${path}' must be equal to or more than ${minLength} and equal to or less than ${maxLength}.`); } } Err.InvalidWorkingDirectoryPathLengthError = InvalidWorkingDirectoryPathLengthError; /** * @public */ class InvalidIdCharacterError extends BaseError { constructor(id) { const e = `Invalid ID character '${id}'`; super(e); } } Err.InvalidIdCharacterError = InvalidIdCharacterError; /** * @public */ class InvalidIdLengthError extends BaseError { constructor(id, minLength, maxLength) { super(`Invalid id length: A byte length of '${id}' must be equal to or more than ${minLength} and equal to or less than ${maxLength}.`); } } Err.InvalidIdLengthError = InvalidIdLengthError; /** * @public */ class InvalidJsonObjectError extends BaseError { constructor(idOrSha) { super(`Invalid JSON object: ${idOrSha}`); } } Err.InvalidJsonObjectError = InvalidJsonObjectError; /** * @public */ class InvalidJsonFileExtensionError extends BaseError { constructor() { super(`JSON file extension is invalid`); } } Err.InvalidJsonFileExtensionError = InvalidJsonFileExtensionError; /** * @public */ class InvalidDocTypeError extends BaseError { constructor(type) { super(`Invalid Document type: ${type}`); } } Err.InvalidDocTypeError = InvalidDocTypeError; /** * @public */ class UndefinedPersonalAccessTokenError extends BaseError { constructor() { super(`Personal Access Token of your GitHub account is needed.`); } } Err.UndefinedPersonalAccessTokenError = UndefinedPersonalAccessTokenError; /** * @public */ class UndefinedDocumentIdError extends BaseError { constructor(e = `Document id is undefined: A document must have an '_id' key`) { super(e); } } Err.UndefinedDocumentIdError = UndefinedDocumentIdError; /** * @public */ class UndefinedSyncError extends BaseError { constructor(e = `Sync is undefined`) { super(e); } } Err.UndefinedSyncError = UndefinedSyncError; /** * @public */ class RepositoryNotOpenError extends BaseError { constructor(e = 'Repository not opened') { super(e); } } Err.RepositoryNotOpenError = RepositoryNotOpenError; /** * @public */ class DocumentNotFoundError extends BaseError { constructor(e = 'Document not found') { super(e); } } Err.DocumentNotFoundError = DocumentNotFoundError; /** * @public */ class SameIdExistsError extends BaseError { constructor(e = 'The same id exists') { super(e); } } Err.SameIdExistsError = SameIdExistsError; /** * @public */ class DatabaseClosingError extends BaseError { constructor(e = 'Database is closing') { super(e); } } Err.DatabaseClosingError = DatabaseClosingError; /** * @public */ class DatabaseCloseTimeoutError extends BaseError { constructor(e = 'Queued operations are timeout') { super(e); } } Err.DatabaseCloseTimeoutError = DatabaseCloseTimeoutError; /** * @public */ class InvalidDbNameCharacterError extends BaseError { constructor(name) { const e = `Invalid dbName '${name}'`; super(e); } } Err.InvalidDbNameCharacterError = InvalidDbNameCharacterError; /** * @public */ class InvalidLocalDirCharacterError extends BaseError { constructor(name) { const e = `Invalid localDir character '${name}'`; super(e); } } Err.InvalidLocalDirCharacterError = InvalidLocalDirCharacterError; /** * @public */ class UndefinedRemoteURLError extends BaseError { constructor() { super(`Remote URL is undefined.`); } } Err.UndefinedRemoteURLError = UndefinedRemoteURLError; /** * @public */ class RemoteAlreadyRegisteredError extends BaseError { constructor(url) { super(`The remote repository has already been registered. :${url} Call removeRemote() before register it again.`); } } Err.RemoteAlreadyRegisteredError = RemoteAlreadyRegisteredError; /** * @public */ class AuthenticationTypeNotAllowCreateRepositoryError extends BaseError { constructor(type) { super(`This authentication type does not allow to create repository. Current value is '${type}'`); } } Err.AuthenticationTypeNotAllowCreateRepositoryError = AuthenticationTypeNotAllowCreateRepositoryError; /** * @public */ class UndefinedDBError extends BaseError { constructor() { super(`GitDocumentDB is undefined.`); } } Err.UndefinedDBError = UndefinedDBError; /** * @public */ class HttpProtocolRequiredError extends BaseError { constructor(url) { super(`HTTP protocol is required: ${url}`); } } Err.HttpProtocolRequiredError = HttpProtocolRequiredError; /** * @public */ class IntervalTooSmallError extends BaseError { constructor(min, current) { super(`Interval is too small. Minimum value is ${min}. Current value is ${current}.`); } } Err.IntervalTooSmallError = IntervalTooSmallError; /** * @public */ class FileRemoveTimeoutError extends BaseError { constructor() { super(`Removing file is timed out for some reason.`); } } Err.FileRemoveTimeoutError = FileRemoveTimeoutError; /** * @public */ class InvalidConflictStateError extends BaseError { constructor(mes) { super(mes); } } Err.InvalidConflictStateError = InvalidConflictStateError; /** * @public */ class InvalidConflictResolutionStrategyError extends BaseError { constructor() { super(`Conflict resolution strategy is invalid.`); } } Err.InvalidConflictResolutionStrategyError = InvalidConflictResolutionStrategyError; /** * @public */ class CannotOpenRepositoryError extends BaseError { constructor(err) { super(`Cannot open repository though .git directory exists. : ${err}`); } } Err.CannotOpenRepositoryError = CannotOpenRepositoryError; /** * @public */ class RepositoryNotFoundError extends BaseError { constructor(path) { super(`Repository does not exist, or you do not have permission to access the directory: ${path}`); } } Err.RepositoryNotFoundError = RepositoryNotFoundError; /** * @public */ class CannotConnectRemoteRepositoryError extends BaseError { constructor(retry, url, mes) { super(`Cannot connect to ${url}: ${mes}`); this.retry = retry; } } Err.CannotConnectRemoteRepositoryError = CannotConnectRemoteRepositoryError; /** * @public */ class RequestTimeoutError extends BaseError { constructor(url) { super(`Request timeout: ${url}`); } } Err.RequestTimeoutError = RequestTimeoutError; /** * @public */ class SocketTimeoutError extends BaseError { constructor(url) { super(`Socket timeout: ${url}`); } } Err.SocketTimeoutError = SocketTimeoutError; /** * @public */ class CannotCreateRepositoryError extends BaseError { constructor(reason) { super(`Cannot create repository: ${reason}`); } } Err.CannotCreateRepositoryError = CannotCreateRepositoryError; /** * @public */ class CannotCreateRemoteRepositoryError extends BaseError { constructor(reason) { super(`Cannot create remote repository: ${reason}`); } } Err.CannotCreateRemoteRepositoryError = CannotCreateRemoteRepositoryError; /** * @public */ class TaskCancelError extends BaseError { constructor(taskId) { super(`Task is canceled: ${taskId}`); } } Err.TaskCancelError = TaskCancelError; /** * @public */ class PersonalAccessTokenForAnotherAccountError extends BaseError { constructor() { super('This is a personal access token for another account.'); } } Err.PersonalAccessTokenForAnotherAccountError = PersonalAccessTokenForAnotherAccountError; /** * @public */ class PushWorkerError extends BaseError { constructor(mes) { super(`Error in push_worker: ${mes}`); } } Err.PushWorkerError = PushWorkerError; /** * @public */ class SyncWorkerError extends BaseError { constructor(mes) { super(`Error in sync_worker: ${mes}`); } } Err.SyncWorkerError = SyncWorkerError; /** * @public */ class ThreeWayMergeError extends BaseError { constructor(mes) { super(`Error in threeWayMerge: ${mes}`); } } Err.ThreeWayMergeError = ThreeWayMergeError; /** * @public */ class PushNotAllowedError extends BaseError { constructor(direction) { super(`Push is not allowed. Current sync direction setting is : ${direction}`); } } Err.PushNotAllowedError = PushNotAllowedError; /** * @public */ class GitMergeBranchError extends BaseError { constructor(mes) { super(`Merge branch error in Git : ${mes}`); } } Err.GitMergeBranchError = GitMergeBranchError; /** * @public */ class SyncIntervalLessThanOrEqualToRetryIntervalError extends BaseError { constructor(syncInterval, retryInterval) { super(`Sync interval is less than or equal to retry interval : ${syncInterval} < ${retryInterval}`); } } Err.SyncIntervalLessThanOrEqualToRetryIntervalError = SyncIntervalLessThanOrEqualToRetryIntervalError; /** * @public */ class ConsecutiveSyncSkippedError extends BaseError { constructor(taskLabel, taskId) { super(`Consecutive ${taskLabel} skipped (id: ${taskId})`); } } Err.ConsecutiveSyncSkippedError = ConsecutiveSyncSkippedError; /** * @public */ class CombineDatabaseError extends BaseError { constructor(mes) { super(`Combine database failed: ${mes})`); } } Err.CombineDatabaseError = CombineDatabaseError; /** * @public */ class NoMergeBaseFoundError extends BaseError { constructor() { super(`No merge base found`); } } Err.NoMergeBaseFoundError = NoMergeBaseFoundError; })(Err = exports.Err || (exports.Err = {})); //# sourceMappingURL=error.js.map