diff --git a/assets/openapi.json b/assets/openapi.json index 13e0249..0e1b4fa 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -2489,15 +2489,6 @@ "id": { "type": "string" }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, "icon": { "type": "string" }, @@ -2690,15 +2681,9 @@ }, "discovery_excluded": { "type": "boolean" - }, - "ToGuildSource": { - "type": "object", - "additionalProperties": false } }, "required": [ - "ToGuildSource", - "__@annotationsKey@12300", "bans", "channel_ordering", "channels", @@ -5217,7 +5202,6 @@ ] }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "anyOf": [ @@ -5550,7 +5534,6 @@ "type": "string" }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "anyOf": [ @@ -6584,7 +6567,6 @@ "type": "string" }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "type": "object", @@ -7853,19 +7835,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "embeds", "flags", @@ -8041,19 +8013,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "created_at", "flags", "id", @@ -8109,19 +8071,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "closed", @@ -8320,19 +8272,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "bio", "bot", "connected_accounts", @@ -8429,19 +8371,9 @@ }, "session_nickname": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "activities", "client_info", "client_status", @@ -8732,19 +8664,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "from", "from_id", "id", @@ -8828,19 +8750,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "external_id", "id", "name", @@ -9042,19 +8954,9 @@ "view_nsfw_guilds": { "type": "boolean", "default": true - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "afk_timeout", "allow_accessibility_detection", "animate_emoji", @@ -9168,19 +9070,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "counter", "id", "key_id", @@ -9337,19 +9229,9 @@ }, "flags": { "$ref": "#/components/schemas/ThreadMemberFlags" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "flags", "id", @@ -9453,19 +9335,9 @@ "flags": { "type": "integer", "default": 0 - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "banner", "bio", "communication_disabled_until", @@ -9709,19 +9581,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "bans", "channel_ordering", "channels", @@ -9775,19 +9637,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "executor", "executor_id", "guild", @@ -9856,19 +9708,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "color", "colors", "flags", @@ -9940,19 +9782,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "code", "created_at", "creator", @@ -10009,19 +9841,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "animated", "available", "groups", @@ -10077,19 +9899,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "format_type", "id", "name", @@ -10123,19 +9935,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "id", "name", "stickers" @@ -10215,19 +10017,9 @@ }, "flags": { "type": "integer" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "code", @@ -10300,19 +10092,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "deaf", @@ -10386,19 +10168,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "application", "application_id", "avatar", @@ -10554,19 +10326,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "description", "discoverability_state", "discovery_eligibility_flags", @@ -10608,19 +10370,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "id", "members", "name", @@ -10657,19 +10409,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "id", "membership_state", "permissions", @@ -10948,19 +10690,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "badge_count", "channel", "channel_id", @@ -11046,19 +10778,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "id", @@ -11098,19 +10820,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "filename", "id", "message", @@ -13697,19 +13409,9 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "code", "consumed", "expired", @@ -13819,19 +13521,9 @@ }, "icon": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "id", "is_primary", "localizations", @@ -14208,19 +13900,9 @@ }, "link": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "required": [ - "__@annotationsKey@12300", "description", "icon", "id" @@ -16753,40 +16435,6 @@ ] } }, - "/users/@me/billing/location-info/": { - "get": { - "security": [ - { - "bearer": [] - } - ], - "responses": { - "default": { - "description": "No description available" - } - }, - "tags": [ - "users" - ] - } - }, - "/users/@me/billing/country-code/": { - "get": { - "security": [ - { - "bearer": [] - } - ], - "responses": { - "default": { - "description": "No description available" - } - }, - "tags": [ - "users" - ] - } - }, "/users/@me/applications/{application_id}/entitlements/": { "get": { "security": [ diff --git a/assets/schemas.json b/assets/schemas.json index 9b3dd7b..1458afd 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -2613,15 +2613,6 @@ "id": { "type": "string" }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, "icon": { "type": "string" }, @@ -2822,16 +2813,10 @@ }, "discovery_excluded": { "type": "boolean" - }, - "ToGuildSource": { - "type": "object", - "additionalProperties": false } }, "additionalProperties": false, "required": [ - "ToGuildSource", - "__@annotationsKey@12300", "bans", "channel_ordering", "channels", @@ -5544,7 +5529,6 @@ ] }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "anyOf": [ @@ -5883,7 +5867,6 @@ "type": "string" }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "anyOf": [ @@ -7007,7 +6990,6 @@ "type": "string" }, "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", "type": "array", "items": { "type": "object", @@ -8332,20 +8314,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "embeds", "flags", @@ -8526,20 +8498,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "created_at", "flags", "id", @@ -8597,20 +8559,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "closed", @@ -8810,20 +8762,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "bio", "bot", "connected_accounts", @@ -8921,20 +8863,10 @@ }, "session_nickname": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "activities", "client_info", "client_status", @@ -9234,20 +9166,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "from", "from_id", "id", @@ -9333,20 +9255,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "external_id", "id", "name", @@ -9551,20 +9463,10 @@ "view_nsfw_guilds": { "type": "boolean", "default": true - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "afk_timeout", "allow_accessibility_detection", "animate_emoji", @@ -9691,20 +9593,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "counter", "id", "key_id", @@ -9884,20 +9776,10 @@ }, "flags": { "$ref": "#/definitions/ThreadMemberFlags" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "flags", "id", @@ -10002,20 +9884,10 @@ "flags": { "type": "integer", "default": 0 - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "banner", "bio", "communication_disabled_until", @@ -10268,20 +10140,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "bans", "channel_ordering", "channels", @@ -10336,20 +10198,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "executor", "executor_id", "guild", @@ -10419,20 +10271,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "color", "colors", "flags", @@ -10507,20 +10349,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "code", "created_at", "creator", @@ -10578,20 +10410,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "animated", "available", "groups", @@ -10648,20 +10470,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "format_type", "id", "name", @@ -10696,20 +10508,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "id", "name", "stickers" @@ -10792,20 +10594,10 @@ }, "flags": { "type": "integer" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "code", @@ -10879,20 +10671,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "deaf", @@ -10967,20 +10749,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "application", "application_id", "avatar", @@ -11138,20 +10910,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "description", "discoverability_state", "discovery_eligibility_flags", @@ -11194,20 +10956,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "id", "members", "name", @@ -11245,20 +10997,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "id", "membership_state", "permissions", @@ -11558,20 +11300,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "badge_count", "channel", "channel_id", @@ -11662,20 +11394,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "channel", "channel_id", "id", @@ -11716,20 +11438,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "filename", "id", "message", @@ -14492,20 +14204,10 @@ }, "id": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "code", "consumed", "expired", @@ -14630,20 +14332,10 @@ }, "icon": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "id", "is_primary", "localizations", @@ -15049,20 +14741,10 @@ }, "link": { "type": "string" - }, - "__@annotationsKey@12300": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } } }, "additionalProperties": false, "required": [ - "__@annotationsKey@12300", "description", "icon", "id" diff --git a/scripts/schema.js b/scripts/schema.js index 171abb5..b4c156d 100644 --- a/scripts/schema.js +++ b/scripts/schema.js @@ -35,7 +35,7 @@ const fsp = require("fs/promises"); const TJS = require("typescript-json-schema"); const walk = require("./util/walk"); -const { redBright, yellowBright, bgRedBright, yellow, greenBright, green, cyanBright } = require("picocolors"); +const { redBright, yellowBright, bgRedBright, yellow, greenBright, green, cyanBright, blueBright, blue, cyan, bgRed, gray } = require("picocolors"); const schemaPath = path.join(__dirname, "..", "assets", "schemas.json"); const exclusionList = JSON.parse(fs.readFileSync(path.join(__dirname, "schemaExclusions.json"), { encoding: "utf8" })); @@ -64,6 +64,8 @@ "hasId", // ? ]; +const entityMethods = ["ToGuildSource"]; + const ExcludeAndWarn = [...exclusionList.manualWarn, ...exclusionList.manualWarnRe.map((r) => new RegExp(r))]; const Excluded = [...exclusionList.manual, ...exclusionList.manualRe.map((r) => new RegExp(r)), ...exclusionList.auto.map((r) => r.value)]; const Included = [...exclusionList.include, ...exclusionList.includeRe.map((r) => new RegExp(r))]; @@ -167,6 +169,14 @@ }); //.sort((a,b) => a.localeCompare(b)); + // remove node modules once and for all + console.log("Removing schemas from node modules..."); + schemas = schemas.filter((x) => !generator.getSymbols(x)[0].fullyQualifiedName.includes("/node_modules/")); + + // for (const s of schemas) { + // console.log(generator.getSymbols(s)[0].symbol); + // } + const elapsedList = stepSw.getElapsedAndReset(); process.stdout.write("Done in " + yellowBright(elapsedList.totalMilliseconds + "." + elapsedList.microseconds) + " ms\n"); console.log("Found", yellowBright(schemas.length), "schemas to process."); @@ -189,7 +199,7 @@ const schemaSw = Stopwatch.startNew(); for (const name of schemas) { process.stdout.write(`Processing schema ${name}... `); - const part = TJS.generateSchema(program, name, settings, [], generator); + let part = TJS.generateSchema(program, name, settings, [], generator); if (!part) continue; if (definitions[name]) { @@ -200,6 +210,12 @@ continue; } + // part = removeKeysMatchingRecursive(part, /^__@annotationsKey.*/, 128); + // part = removeArrayValuesMatchingRecursive(part, /^__@annotationsKey.*/, 128); + const _matchesRegex = (r) => (k, v, _) => (typeof k === "string" && k.match(r)) || (typeof v === "string" && v.match(r)); + part = await removeAllMatchingRecursive(part, _matchesRegex(/__@annotationsKey/)); + part = await removeAllMatchingRecursive(part, _matchesRegex(/ToGuildSource/)); + if (process.env.WRITE_SCHEMA_DIR === "true") writePromises.push(async () => await fsp.writeFile(path.join("schemas_orig", `${name}.json`), JSON.stringify(part, null, 4))); // testing: @@ -380,4 +396,50 @@ return diffs; } +async function removeAllMatchingRecursive(o, selector, maxDepth = 32, path = "$") { + // process.stdout.write("S"); + // console.log("scan @", path, "with depth", maxDepth, typeof o, o); + // await printEnd(path, path.length); + if (!o) return o; + for (const [k, v] of Object.entries(o)) { + if (selector(k, v, o)) { + process.stdout.write(yellowBright("R(" + gray(k) + " @ " + cyan(path) + ") ")); + delete o[k]; + } else if (maxDepth > 0 && typeof o != "string") { + process.stdout.write(gray(">")); + o[k] = await removeAllMatchingRecursive(o[k], selector, maxDepth - 1, path + "." + k); + process.stdout.write(cyan("\b \b")); + } + } + + return o; +} + main().then(() => {}); + +// this is broken, figure this out someday - would be really neat to have +async function printEnd(str, len) { + const width = process.stdout.columns || 80; + const height = process.stdout.rows || 25; + + const storePos = "\x1b[s"; + const restPos = "\x1b[u"; + const eraseAfter = "\x1b[0K"; + const eraseLine = "\x1b[2K"; + const down1 = "\x1b[1E"; + const up1 = "\x1b[1F"; + const setCol = (col) => `\x1b[${col}G`; + const setTopPos = (col) => `\x1b[1;${col}H`; + const setBottomPos = (col) => `\x1b[${height};${col}H`; + + const startColumn = Math.max(1, width - len + 1); + + process.stdout.write(`\n\n\n${up1}${up1}${up1}`); + // process.stdout.write(`${storePos}${down1}${eraseAfter}${setTopPos(startColumn)}${str}${restPos}`);//${up1}`); + process.stdout.write(`${storePos}${setCol(startColumn)}${str}${restPos}`); + await sleep(12); +} + +async function sleep(delay) { + return new Promise((res, rej) => setTimeout(res, delay)); +} diff --git a/src/schemas/uncategorised/MessageCreateSchema.ts b/src/schemas/uncategorised/MessageCreateSchema.ts index b9c8119..f131329 100644 --- a/src/schemas/uncategorised/MessageCreateSchema.ts +++ b/src/schemas/uncategorised/MessageCreateSchema.ts @@ -57,10 +57,7 @@ } | null; payload_json?: string; file?: { filename: string }; - /** - TODO: we should create an interface for attachments - TODO: OpenWAAO<-->attachment-style metadata conversion - **/ + // TODO: we should create an interface for attachments attachments?: (MessageCreateAttachment | MessageCreateCloudAttachment)[]; sticker_ids?: string[] | null; // null check: fixes Discord-Go components?: ActionRowComponent[] | null; // null check: fixes Discord-Go diff --git a/src/schemas/uncategorised/WebhookExecuteSchema.ts b/src/schemas/uncategorised/WebhookExecuteSchema.ts index 2d0fdbd..147a2d1 100644 --- a/src/schemas/uncategorised/WebhookExecuteSchema.ts +++ b/src/schemas/uncategorised/WebhookExecuteSchema.ts @@ -35,10 +35,7 @@ components?: any[]; file?: { filename: string }; payload_json?: string; - /** - TODO: we should create an interface for attachments - TODO: OpenWAAO<-->attachment-style metadata conversion - **/ + // TODO: we should create an interface for attachments attachments?: MessageCreateAttachment[]; flags?: number; thread_name?: string; diff --git a/src/util/entities/Session.ts b/src/util/entities/Session.ts index e6ada0d..a5cdeb7 100644 --- a/src/util/entities/Session.ts +++ b/src/util/entities/Session.ts @@ -24,8 +24,6 @@ import { randomUpperString } from "@spacebar/api"; import { DateBuilder, IpDataClient, TimeSpan } from "../util"; -//TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them - @Entity({ name: "sessions", })