-
-
Notifications
You must be signed in to change notification settings - Fork 87
[RFC] SGv2.1.1 #256
[RFC] SGv2.1.1 #256
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just skimmed over really fast so might have missed something.
src/lib/settings/GatewayDriver.js
Outdated
register(name, schema = {}, options = {}) { | ||
register(name, defaultSchema = {}, { download = true, provider = this.client.options.providers.default } = {}) { | ||
if (typeof name !== 'string') throw new TypeError('You must pass a name for your new gateway and it must be a string.'); | ||
if (!this.client.methods.util.isObject(defaultSchema)) throw new TypeError('Schema must be a valid object or left undefined for an empty object.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just require Util here
src/lib/Client.js
Outdated
this.gateways.register('users', undefined, this.options.gateways.users, false); | ||
this.gateways.register('clientStorage', this.gateways.clientStorageSchema, this.options.gateways.clientStorage, false); | ||
this.gateways.register('guilds', this.gateways.guildsSchema, { download: false, ...this.options.gateways.guilds }); | ||
this.gateways.register('users', {}, { download: false, ...this.options.gateways.users }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a gateways.userSchema option and set it here instead of an empty object, even if the option by default is an empty object, keeps it consistent with the other ones
} | ||
throw new TypeError(`Invalid value. Expected object, string or Array<string>. Got: ${getDeepTypeName(key)}`); | ||
if (typeof options === 'undefined' && guild && guild.constructor.name === 'Object') [guild, options] = [null, guild]; | ||
if (guild) guild = this.gateway._resolveGuild(guild); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be changed to use the internal resolver for Klasa. There's no reason for this method to be duplicated for Settings when it should be relatively the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that at the moment, the Guild's SettingResolver is incredibly slow and requires await
(Configuration#update
doesn't use async
for performance). Plus it takes three arguments and the error message is misleading.
src/lib/settings/Gateway.js
Outdated
@@ -176,19 +107,8 @@ class Gateway extends GatewayStorage { | |||
*/ | |||
async sync(input, download) { | |||
if (typeof input === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We talked about this in staff chat.
This PR is ready to land and addresses many issues in the current version of SettingGateway. Requesting review from @UnseenFaith and @bdistin. I'll write the changelog and guides once I come back home. |
Description of the PR
This PR ports several refactors from #228 and goes further by fixing several bugs that are caused in other places. The objective of this PR is to backport some bugfixes that need to be merged quickly while improving the interface in general.
The problem with #228 is that its design has not been fully decided, and it's supposed to implement SQL improvements but goes much further than that. However, some bugfixes don't merge due to QueryBuilder and QueryType not being 100% finished nor ready for production.
Probably fixes #247
Changes Proposed in this Pull Request (List new items in CHANGELOG.MD)
Added:
Util.objectToTuples
for object overload -> array overload inConfiguration#update
.Changed:
Configuration#update
.SchemaFolder#getSQL
toSchemaFolder#sqlSchema
.SchemaPiece#sql
's type from[string, string]
tostring
.data
fromnull
to{}
, allowing object spread to attach the id of the executed task inTask#run
.Configuration#update
.Gateway#getPath
to takepiece: null
as an option for mixed output.GatewayStorage
to not depend on being inherited.Util.isClass
andUtil.isObject
for a ~5 times performance boost.Util.makeObject
to take an object as third parameter, allowing SettingGateway's internals to append properties withoutObject.assign
.Removed:
Gateway#getEntry
(mixed getEntry and insertEntry intoGateway#get
),Gateway#createEntry
, andGateway#insertEntry
.Gateway#options
andGateway#defaultSchema
.Provider
's nice option. As it was only used by the JSON provider. Should use a better system instead.Fixed:
Util.deepClone
trying to iterate overWeakMap
s andWeakSet
s.Configuration#_syncStatus
resolved too early.Semver Classification