Merge pull request #14 from IBims2CooleTim/main

Fixed a few small spelling errors

- The future of MarcSync is decleared.
This commit is contained in:
Marcel Lorbeer 2023-10-01 02:07:43 +02:00 committed by GitHub
commit 31229509fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 193 additions and 193 deletions

View File

@ -1,17 +1,17 @@
local AuthorizationError = require(script.Parent.Errors.Authorization)
local CollectionError = require(script.Parent.Errors.Collection)
local EntryError = require(script.Parent.Errors.Entry)
local AuthorizationError = require(script.Parent.Errors.Autorisierung)
local CollectionError = require(script.Parent.Errors.Sammlung)
local EntryError = require(script.Parent.Errors.Eintrag)
local HttpService = game:GetService("HttpService")
function errorHandler(type: string, resultBody: any, resultObject: {})
function fehlerMisshandlung(type: string, resultBody: any, resultObject: {})
local Error;
if typeof(resultBody) == typeof({}) and resultBody["message"] then
Error = resultBody["message"]
elseif typeof(resultBody) == typeof("") then
Error = resultBody
else
Error = "An Unexpected Error occoured."
Error = "Es ist ein unerwarteter Fehler aufgetreten."
end
if type == "collection" then
@ -37,7 +37,7 @@ end
local utils = {}
function utils.makeHTTPRequest(type: string, method: string, url: string, body: {}, authorization: string):{["success"]: boolean, ["message"]: string}
function utils.macheHypertexttransferprotokollAnfrage(type: string, method: string, url: string, body: {}, authorization: string):{["success"]: boolean, ["message"]: string}
local resultObj;
local resultBody;
local success = pcall(function()
@ -51,10 +51,10 @@ function utils.makeHTTPRequest(type: string, method: string, url: string, body:
end
end)
if success and resultBody and resultBody["success"] then
if resultBody["warning"] then warn('[MarcSync HTTPRequest Handler] MarcSync HTTP Request returned warning for URL "'..url..'" with body: "'..HttpService:JSONEncode(body)..'": '..resultBody["warning"]) end
if resultBody["warning"] then warn('[MarkSynchronisation Hypertexttransferprotokoll Misshandler] Die MarcSync-HTTP-Anfrage hat eine Warnung zurückgegeben für die URL "'..url..'" mit Koerper: "'..HttpService:JSONEncode(body)..'": '..resultBody["warning"]) end
return resultBody
end
return errorHandler(type, resultBody, resultObj)
return fehlerMisshandlung(type, resultBody, resultObj)
end
return utils

View File

@ -1,5 +0,0 @@
return {
InvalidAccessToken = function(message: string):string
return ("[MarcSync Exception] InvalidAccessToken: %s"):format(message)
end
}

View File

@ -0,0 +1,5 @@
return {
InvalidAccessToken = function(message: string):string
return ("[MarkSynchronisationsausnahme] InvaliederZugriffsToken: %s"):format(message)
end
}

View File

@ -1,8 +0,0 @@
return {
CollectionNotFound = function(message: string):string
return ("[MarcSync Exception] CollectionNotFound: %s"):format(message)
end,
CollectionAlreadyExists = function(message: string):string
return ("[MarcSync Exception] CollectionAlreadyExists: %s"):format(message)
end
}

View File

@ -0,0 +1,8 @@
return {
InvalidEntryData = function(message: string):string
return ("[MarkSynchronisationsausnahme] InvaliedeEintragsDaten: %s"):format(message)
end,
EntryNotFound = function(message: string):string
return ("[MarkSynchronisationsausnahme] EintragNichtGefunden: %s"):format(message)
end
}

View File

@ -1,8 +0,0 @@
return {
InvalidEntryData = function(message: string):string
return ("[MarcSync Exception] InvalidEntryData: %s"):format(message)
end,
EntryNotFound = function(message: string):string
return ("[MarcSync Exception] EntryNotFound: %s"):format(message)
end
}

View File

@ -0,0 +1,8 @@
return {
CollectionNotFound = function(message: string):string
return ("[MarkSynchronisationsausnahme] SammlungNichtGefunden: %s"):format(message)
end,
CollectionAlreadyExists = function(message: string):string
return ("[MarkSynchronisationsausnahme] SammlungExistiertBereits: %s"):format(message)
end
}

View File

@ -5,53 +5,53 @@ local tokens = {
-- DO NOT EDIT THE FOLLOWING LINES BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING!
local Utils = require(script.Parent.Utils)
local Utils = require(script.Parent.Dienstprogramme)
local MarcSyncClient = {}
MarcSyncClient.getVersion = function(self:typeof(MarcSyncClient), clientId: number?):string
MarcSyncClient.bekommeVersion = function(self:typeof(MarcSyncClient), clientId: number?):string
self:_checkInstallation()
local url = ""
if clientId then url = "/"..clientId end
local result = Utils.makeHTTPRequest("GET", "https://api.marcsync.dev/v0/utils/version"..url);
local result = Utils.macheHypertexttransferprotokollAnfrage("GET", "https://api.marcsync.dev/v0/utils/version"..url);
return result["version"]
end
MarcSyncClient.createCollection = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Collection).new())
if not self._accessToken then error("[MarcSync] Please set a Token before using MarcSync.") end
if not collectionName then error("No CollectionName Provided") end
local result = Utils.makeHTTPRequest("collection", "POST", "https://api.marcsync.dev/v0/collection/"..collectionName, {}, self._accessToken);
MarcSyncClient.erzeugeSammlung = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Sammlung).new())
if not self._accessToken then error("[MarkSynchronisation] Bitte legen Sie ein Token fest, bevor Sie MarcSync verwenden.") end
if not collectionName then error("Kein CollectionName angegeben") end
local result = Utils.macheHypertexttransferprotokollAnfrage("collection", "POST", "https://api.marcsync.dev/v0/collection/"..collectionName, {}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
result = require(script.Parent.Objects.Collection).new(collectionName, self._accessToken)
result = require(script.Parent.Objects.Sammlung).neu(collectionName, self._accessToken)
return result
end
MarcSyncClient.fetchCollection = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Collection).new())
MarcSyncClient.bringeSammlung = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Sammlung).new())
self:_checkInstallation()
if not collectionName then error("No CollectionName Provided") end
local result = Utils.makeHTTPRequest("collection", "GET", "https://api.marcsync.dev/v0/collection/"..collectionName, {}, self._accessToken);
if not collectionName then error("Kein CollectionName angegeben") end
local result = Utils.macheHypertexttransferprotokollAnfrage("collection", "GET", "https://api.marcsync.dev/v0/collection/"..collectionName, {}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
result = require(script.Parent.Objects.Collection).new(collectionName, self._accessToken)
result = require(script.Parent.Objects.Sammlung).neu(collectionName, self._accessToken)
return result
end
MarcSyncClient.getCollection = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Collection).new())
if typeof(self) ~= "table" then error("Please use : instead of .") end
MarcSyncClient.bekommeSammlung = function(self:typeof(MarcSyncClient), collectionName: string):typeof(require(script.Parent.Objects.Sammlung).new())
if typeof(self) ~= "table" then error("Bitte verwenden Sie : anstelle von .") end
self:_checkInstallation()
if not collectionName then error("No CollectionName Provided") end
return require(script.Parent.Objects.Collection).new(collectionName, self._accessToken)
if not collectionName then error("Kein CollectionName angegeben") end
return require(script.Parent.Objects.Sammlung).neu(collectionName, self._accessToken)
end
return {
new = function(accessToken: string):typeof(MarcSyncClient)
if not accessToken then warn("Token not provided while creating a new MarcSync Object.") end
if not tokens[accessToken] then warn("Token provided for creating a new MarcSync Object not Found in Token Table, using it as token instead.") else accessToken = tokens[accessToken] end
neu = function(accessToken: string):typeof(MarcSyncClient)
if not accessToken then warn("Beim Erstellen eines neuen MarcSync-Objekts wurde kein Token bereitgestellt.") end
if not tokens[accessToken] then warn("Token zum Erstellen eines neuen MarcSync-Objekts, das nicht in der Token-Tabelle gefunden wird und stattdessen als Token verwendet wird.") else accessToken = tokens[accessToken] end
local self = {}
self._accessToken = accessToken
self._checkInstallation = function()
if not self then error("Please Setup MarcSync before using MarcSync.") end
if not self._accessToken then error("[MarcSync] Please set a Token before using MarcSync.") end
if not self then error("Bitte richten Sie MarcSync ein, bevor Sie MarcSync verwenden.") end
if not self._accessToken then error("[MarkSynchronisation] Bitte legen Sie ein Token fest, bevor Sie MarcSync verwenden.") end
--print(HttpService.HttpEnabled)
--if not HttpService.HttpEnabled then error("Please Enable HTTPService in order to use MarcSync.") end
end

View File

@ -1,76 +0,0 @@
local Utils = require(script.Parent.Parent.Utils)
local Entry = require(script.Parent.Entry)
local types = {
EntryData = require(script.Parent.Parent.Types.EntryData).getType()
}
local Collection = {}
Collection.createEntry = function(self:typeof(Collection), data:typeof(types.EntryData)):typeof(Entry.new())
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
local result = Utils.makeHTTPRequest("entry", "POST", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["data"]=data}, self._accessToken);
if result["success"] and result["objectId"] then
data["_id"] = result["objectId"]
result = require(script.Parent.Entry).new(self._collectionName, data, self._accessToken)
else
error(result["errorMessage"])
end
return result
end
Collection.updateEntries = function(self:typeof(Collection), filters:typeof(types.EntryData), data:typeof(types.EntryData)):number
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
return result["modifiedEntries"]
end
Collection.getEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):{[number]:typeof(Entry.new())}
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
if not filters then filters = {} end
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName.."?isQuery=true", {["filters"]=filters}, self._accessToken);
if result["success"] and result["entries"] then
local _result = {}
for index,entry in pairs(result["entries"]) do
_result[index] = require(script.Parent.Entry).new(self._collectionName, entry, self._accessToken)
end
result = _result
else
error(result["errorMessage"])
end
return result
end
Collection.deleteEntries = function(self:typeof(Collection), filters:typeof(types.EntryData)):number
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
local result = Utils.makeHTTPRequest("DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
return result["deletedEntries"]
end
Collection.drop = function(self:typeof(Collection))
if not self._collectionName then error("[MarcSync: Collection] Invalid Object created or trying to access an destroied object.") end
local result = Utils.makeHTTPRequest("collection", "DELETE", "https://api.marcsync.dev/v0/collection/"..self._collectionName, {}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
self = nil
end
return {
new = function(collectionName: string, accessToken: string):typeof(Collection)
local self = {}
self._collectionName = collectionName
self._accessToken = accessToken
self = setmetatable(self, {
__index = Collection
})
return self
end
}

View File

@ -0,0 +1,56 @@
local Utils = require(script.Parent.Parent.Dienstprogramme)
local types = {
EntryData = require(script.Parent.Parent.Types.EntryData).bekommeRassenindentifikationsspezifizierunginstanztextaufzaehlbar()
}
local Entry = {}
Entry.bekommeWert = function(self:typeof(Entry), key:string):any
if not key then return nil end
return self._entryData[key]
end
Entry.bekommeWerte = function(self:typeof(Entry)):typeof(types.EntryData)
return self._entryData
end
Entry.aktualisiereWerte = function(self:typeof(Entry), data:typeof(types.EntryData)):number
local result = Utils.macheHypertexttransferprotokollAnfrage("eintrag", "PUT", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken);
if result["success"] and result["modifiedEntries"] and result["modifiedEntries"] > 0 then
for i,v in pairs(data) do
self._entryData[i] = v
end
elseif not result["success"] then
error(result["errorMessage"])
end
return result["modifiedEntries"]
end
Entry.loesche = function(self:typeof(Entry))
if typeof(self) ~= "table" then error("Bitte verwenden Sie : anstelle von .") end
local result = Utils.macheHypertexttransferprotokollAnfrage("eintrag", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
self = nil
end
return {
neu = function(tableId:string, entryData:typeof(types.EntryData), accessToken:string):typeof(Entry)
if not tableId or not entryData or not entryData["_id"] or not accessToken then error("[MarkSynchronisation: Eintrag] Es wurde versucht, ein ungültiges Eintragsobjekt zu erstellen.") end
local self = {}
self._tableId = tableId
self._entryData = entryData
self._objectId = entryData["_id"]
self._accessToken = accessToken
self = setmetatable(self, {
__index = Entry
})
return self
end
}

View File

@ -1,56 +0,0 @@
local Utils = require(script.Parent.Parent.Utils)
local types = {
EntryData = require(script.Parent.Parent.Types.EntryData).getType()
}
local Entry = {}
Entry.getValue = function(self:typeof(Entry), key:string):any
if not key then return nil end
return self._entryData[key]
end
Entry.getValues = function(self:typeof(Entry)):typeof(types.EntryData)
return self._entryData
end
Entry.updateValues = function(self:typeof(Entry), data:typeof(types.EntryData)):number
local result = Utils.makeHTTPRequest("entry", "PUT", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId},["data"]=data}, self._accessToken);
if result["success"] and result["modifiedEntries"] and result["modifiedEntries"] > 0 then
for i,v in pairs(data) do
self._entryData[i] = v
end
elseif not result["success"] then
error(result["errorMessage"])
end
return result["modifiedEntries"]
end
Entry.delete = function(self:typeof(Entry))
if typeof(self) ~= "table" then error("Please use : instead of .") end
local result = Utils.makeHTTPRequest("entry", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._tableId, {["filters"]={["_id"]=self._objectId}}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
self = nil
end
return {
new = function(tableId:string, entryData:typeof(types.EntryData), accessToken:string):typeof(Entry)
if not tableId or not entryData or not entryData["_id"] or not accessToken then error("[MarcSync: Entry] Tried creating invalid Entry Object.") end
local self = {}
self._tableId = tableId
self._entryData = entryData
self._objectId = entryData["_id"]
self._accessToken = accessToken
self = setmetatable(self, {
__index = Entry
})
return self
end
}

View File

@ -0,0 +1,76 @@
local Utils = require(script.Parent.Parent.Dienstprogramme)
local Entry = require(script.Parent.Eintrag)
local types = {
EntryData = require(script.Parent.Parent.Types.EintragsDaten).bekommeRassenindentifikationsspezifizierunginstanztextaufzaehlbar()
}
local Collection = {}
Collection.erzeugeEintrag = function(self:typeof(Collection), data:typeof(types.EntryData)):typeof(Entry.new())
if not self._collectionName then error("[MarkSynchronisation: Sammlung] Ungültiges Objekt erstellt oder versucht, auf ein zerstörtes Objekt zuzugreifen.") end
local result = Utils.macheHypertexttransferprotokollAnfrage("entry", "POST", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["data"]=data}, self._accessToken);
if result["success"] and result["objectId"] then
data["_id"] = result["objectId"]
result = require(script.Parent.Entry).neu(self._collectionName, data, self._accessToken)
else
error(result["errorMessage"])
end
return result
end
Collection.aktualisiereEintrag = function(self:typeof(Collection), filters:typeof(types.EntryData), data:typeof(types.EntryData)):number
if not self._collectionName then error("[MarkSynchronisation: Sammlung] Ungültiges Objekt erstellt oder versucht, auf ein zerstörtes Objekt zuzugreifen.") end
local result = Utils.macheHypertexttransferprotokollAnfrage("eintrag", "PUT", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters,["data"]=data}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
return result["modifiedEntries"]
end
Collection.bekommeEintraege = function(self:typeof(Collection), filters:typeof(types.EntryData)):{[number]:typeof(Entry.new())}
if not self._collectionName then error("[MarkSynchronisation: Sammlung] Ungültiges Objekt erstellt oder versucht, auf ein zerstörtes Objekt zuzugreifen.") end
if not filters then filters = {} end
local result = Utils.macheHypertexttransferprotokollAnfrage("eintrag", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName.."?isQuery=true", {["filters"]=filters}, self._accessToken);
if result["success"] and result["entries"] then
local _result = {}
for index,entry in pairs(result["entries"]) do
_result[index] = require(script.Parent.Entry).neu(self._collectionName, entry, self._accessToken)
end
result = _result
else
error(result["errorMessage"])
end
return result
end
Collection.loescheEintrag = function(self:typeof(Collection), filters:typeof(types.EntryData)):number
if not self._collectionName then error("[MarkSynchronisation: Sammlung] Ungültiges Objekt erstellt oder versucht, auf ein zerstörtes Objekt zuzugreifen.") end
local result = Utils.macheHypertexttransferprotokollAnfrage("eintrag", "DELETE", "https://api.marcsync.dev/v0/entries/"..self._collectionName, {["filters"]=filters}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
return result["deletedEntries"]
end
Collection.fallenlassen = function(self:typeof(Collection))
if not self._collectionName then error("[MarkSynchronisation: Sammlung] Ungültiges Objekt erstellt oder versucht, auf ein zerstörtes Objekt zuzugreifen.") end
local result = Utils.macheHypertexttransferprotokollAnfrage("sammlung", "DELETE", "https://api.marcsync.dev/v0/collection/"..self._collectionName, {}, self._accessToken);
if not result["success"] then error(result["errorMessage"]) end
self = nil
end
return {
neu = function(collectionName: string, accessToken: string):typeof(Collection)
local self = {}
self._collectionName = collectionName
self._accessToken = accessToken
self = setmetatable(self, {
__index = Collection
})
return self
end
}

View File

@ -0,0 +1,9 @@
type EntryData = {
[string]: any
}
return {
bekommeRassenindentifikationsspezifizierunginstanztextaufzaehlbar = function(): EntryData
return {}
end,
}

View File

@ -1,9 +0,0 @@
type EntryData = {
[string]: any
}
return {
getType = function(): EntryData
return {}
end,
}