Files
rojo/plugin/src/Types.lua
boatbomber cdc972a5ce Migrate DevSettings to PluginSettings for much better config flow (#572)
* Add the devsetting config options into settings

* Create dropdown component and add setting controls

* Static dropdwon width and spin arrow

* Improve dropdown option contrast and border

* Forgot to make the settings page respect the static spacing, oops

* Smaller arrow

* Vert padding

* Reset option for settings

* Hide reset button when on default

* Respect the logLevel setting

* Portal settings out to external typechecking module

* Implement new configs using the new singleton Settings

* Remove DevSettings

* Update test runner to use new settings

* More helpful test failure output

* Support non-plugin environment

* Migrate dropdown to new packages system

* Clean up components a tad
2022-08-20 22:39:34 -04:00

97 lines
2.2 KiB
Lua

local Packages = script.Parent.Parent.Packages
local t = require(Packages.t)
local Settings = require(script.Parent.Settings)
local strict = require(script.Parent.strict)
local RbxId = t.string
local ApiValue = t.keys(t.string)
local ApiInstanceMetadata = t.interface({
ignoreUnknownInstances = t.optional(t.boolean),
})
local ApiInstance = t.interface({
Id = RbxId,
Parent = t.optional(RbxId),
Name = t.string,
ClassName = t.string,
Properties = t.map(t.string, ApiValue),
Metadata = t.optional(ApiInstanceMetadata),
Children = t.array(RbxId),
})
local ApiInstanceUpdate = t.interface({
id = RbxId,
changedName = t.optional(t.string),
changedClassName = t.optional(t.string),
changedProperties = t.map(t.string, ApiValue),
changedMetadata = t.optional(ApiInstanceMetadata),
})
local ApiSubscribeMessage = t.interface({
removed = t.array(RbxId),
added = t.map(RbxId, ApiInstance),
updated = t.array(ApiInstanceUpdate),
})
local ApiInfoResponse = t.interface({
sessionId = t.string,
serverVersion = t.string,
protocolVersion = t.number,
expectedPlaceIds = t.optional(t.array(t.number)),
rootInstanceId = RbxId,
})
local ApiReadResponse = t.interface({
sessionId = t.string,
messageCursor = t.number,
instances = t.map(RbxId, ApiInstance),
})
local ApiSubscribeResponse = t.interface({
sessionId = t.string,
messageCursor = t.number,
messages = t.array(ApiSubscribeMessage),
})
local ApiError = t.interface({
kind = t.union(
t.literal("NotFound"),
t.literal("BadRequest"),
t.literal("InternalError")
),
details = t.string,
})
local function ifEnabled(innerCheck)
return function(...)
if Settings:get("typecheckingEnabled") then
return innerCheck(...)
else
return true
end
end
end
return strict("Types", {
ifEnabled = ifEnabled,
ApiInfoResponse = ApiInfoResponse,
ApiReadResponse = ApiReadResponse,
ApiSubscribeResponse = ApiSubscribeResponse,
ApiError = ApiError,
ApiInstance = ApiInstance,
ApiInstanceUpdate = ApiInstanceUpdate,
ApiInstanceMetadata = ApiInstanceMetadata,
ApiSubscribeMessage = ApiSubscribeMessage,
ApiValue = ApiValue,
RbxId = RbxId,
-- Deprecated aliases during transition
VirtualInstance = ApiInstance,
VirtualMetadata = ApiInstanceMetadata,
VirtualValue = ApiValue,
})