@tanstack/db
Version:
A reactive client store for building super fast apps on sync
82 lines (76 loc) • 2.06 kB
JavaScript
import { CollectionConfigurationError } from "../errors.js";
class CollectionRequiresGetKeyError extends CollectionConfigurationError {
constructor() {
super(
`Collection requires a "getKey" function in the config.
The getKey function extracts a unique identifier from each item.
Example:
createCollection({
getKey: (item) => item.id,
sync: { sync: () => {} },
})`
);
}
}
class InvalidGetKeyError extends CollectionConfigurationError {
constructor(actualType) {
super(
`"getKey" must be a function, but received ${actualType}.
Example:
createCollection({
getKey: (item) => item.id,
sync: { sync: () => {} },
})`
);
}
}
class InvalidSyncConfigError extends CollectionConfigurationError {
constructor(actualType) {
super(
`"sync" must be an object with a "sync" function, but received ${actualType}.
Example:
createCollection({
getKey: (item) => item.id,
sync: {
sync: ({ begin, write, commit, markReady }) => {
// your sync logic
},
},
})`
);
}
}
class InvalidSyncFunctionError extends CollectionConfigurationError {
constructor(actualType) {
super(
`"sync.sync" must be a function, but received ${actualType}.
The sync property should be an object containing a sync function:
sync: {
sync: ({ begin, write, commit, markReady }) => {
// your sync logic
},
}`
);
}
}
class InvalidCallbackOptionError extends CollectionConfigurationError {
constructor(optionName, actualType) {
super(`"${optionName}" must be a function, but received ${actualType}.`);
}
}
class InvalidOptionTypeError extends CollectionConfigurationError {
constructor(optionName, expectedType, actualType) {
super(
`"${optionName}" must be ${expectedType}, but received ${actualType}.`
);
}
}
export {
CollectionRequiresGetKeyError,
InvalidCallbackOptionError,
InvalidGetKeyError,
InvalidOptionTypeError,
InvalidSyncConfigError,
InvalidSyncFunctionError
};
//# sourceMappingURL=config-errors.js.map