Skip to content

Commit

Permalink
fix: Fix ts schema generation import issue
Browse files Browse the repository at this point in the history
Changing tsconfig resolution caused generation to generate new (bad?) import lines. Replacing with regex from YousefED/typescript-json-schema#582 returned ref/definitions to normal
  • Loading branch information
FoxxMD committed Feb 14, 2024
1 parent aef7716 commit 49b9ee9
Show file tree
Hide file tree
Showing 6 changed files with 2,164 additions and 2,138 deletions.
26 changes: 26 additions & 0 deletions patches/typescript-json-schema+0.55.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/node_modules/typescript-json-schema/dist/typescript-json-schema.js b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
index 23cc6d1..221adc2 100644
--- a/node_modules/typescript-json-schema/dist/typescript-json-schema.js
+++ b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
@@ -55,7 +55,7 @@ var crypto_1 = require("crypto");
var ts = require("typescript");
var path_equal_1 = require("path-equal");
var vm = require("vm");
-var REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"\)|".*?")\.| /g;
+var REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"(, \{ assert: \{ "resolution-mode": "(import|require)" \} \})?\)|".*?")\.| /g;// /(\bimport\(".*?"\)|".*?")\.| /g;
var REGEX_TSCONFIG_NAME = /^.*\.json$/;
var REGEX_TJS_JSDOC = /^-([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
var REGEX_GROUP_JSDOC = /^[.]?([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
diff --git a/node_modules/typescript-json-schema/typescript-json-schema.ts b/node_modules/typescript-json-schema/typescript-json-schema.ts
index 5908567..c188383 100644
--- a/node_modules/typescript-json-schema/typescript-json-schema.ts
+++ b/node_modules/typescript-json-schema/typescript-json-schema.ts
@@ -9,7 +9,7 @@ export { Program, CompilerOptions, Symbol } from "typescript";

const vm = require("vm");

-const REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"\)|".*?")\.| /g;
+const REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"(, \{ assert: \{ "resolution-mode": "(import|require)" \} \})?\)|".*?")\.| /g;// /(\bimport\(".*?"\)|".*?")\.| /g;
const REGEX_TSCONFIG_NAME = /^.*\.json$/;
const REGEX_TJS_JSDOC = /^-([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
const REGEX_GROUP_JSDOC = /^[.]?([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
128 changes: 64 additions & 64 deletions src/backend/common/schema/aio-client.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/clients\",{assert:{\"resolution-mode\":\"import\"}}).ClientAIOConfig": {
"ClientAIOConfig": {
"anyOf": [
{
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmClientAIOConfig"
"$ref": "#/definitions/LastfmClientAIOConfig"
},
{
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientAIOConfig"
"$ref": "#/definitions/ListenBrainzClientAIOConfig"
},
{
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientAIOConfig"
"$ref": "#/definitions/MalojaClientAIOConfig"
}
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/clients\",{assert:{\"resolution-mode\":\"import\"}}).ClientAIOConfig"
"title": "ClientAIOConfig"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).CommonClientData": {
"CommonClientData": {
"properties": {
"maxRequestRetries": {
"default": 1,
Expand Down Expand Up @@ -59,7 +59,7 @@
"description": "Options used for increasing verbosity of logging in MS (used for debugging)",
"properties": {
"match": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).MatchLoggingOptions",
"$ref": "#/definitions/MatchLoggingOptions",
"title": "match"
}
},
Expand All @@ -80,44 +80,10 @@
"type": "number"
}
},
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).CommonClientData",
"title": "CommonClientData",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).MatchLoggingOptions": {
"description": "Scrobble matching (between new source track and existing client scrobbles) logging options. Used for debugging.",
"properties": {
"confidenceBreakdown": {
"default": false,
"description": "Include confidence breakdowns in track match logging, if applicable",
"examples": [
false
],
"title": "confidenceBreakdown",
"type": "boolean"
},
"onMatch": {
"default": false,
"description": "Log to DEBUG when a new track DOES match an existing scrobble",
"examples": [
false
],
"title": "onMatch",
"type": "boolean"
},
"onNoMatch": {
"default": false,
"description": "Log to DEBUG when a new track does NOT match an existing scrobble",
"examples": [
false
],
"title": "onNoMatch",
"type": "boolean"
}
},
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).MatchLoggingOptions",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmClientAIOConfig": {
"LastfmClientAIOConfig": {
"properties": {
"configureAs": {
"default": "client",
Expand All @@ -135,10 +101,10 @@
"data": {
"allOf": [
{
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).CommonClientData"
"$ref": "#/definitions/CommonClientData"
},
{
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmData"
"$ref": "#/definitions/LastfmData"
}
],
"description": "Specific data required to configure this client",
Expand Down Expand Up @@ -174,10 +140,10 @@
"name",
"type"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmClientAIOConfig",
"title": "LastfmClientAIOConfig",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmData": {
"LastfmData": {
"properties": {
"apiKey": {
"description": "API Key generated from Last.fm account",
Expand Down Expand Up @@ -232,10 +198,10 @@
"apiKey",
"secret"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/lastfm\",{assert:{\"resolution-mode\":\"import\"}}).LastfmData",
"title": "LastfmData",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientAIOConfig": {
"ListenBrainzClientAIOConfig": {
"properties": {
"configureAs": {
"default": "client",
Expand All @@ -251,7 +217,7 @@
"type": "string"
},
"data": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientData",
"$ref": "#/definitions/ListenBrainzClientData",
"description": "Specific data required to configure this client",
"title": "data"
},
Expand Down Expand Up @@ -285,10 +251,10 @@
"name",
"type"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientAIOConfig",
"title": "ListenBrainzClientAIOConfig",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientData": {
"ListenBrainzClientData": {
"properties": {
"maxRequestRetries": {
"default": 1,
Expand Down Expand Up @@ -332,7 +298,7 @@
"description": "Options used for increasing verbosity of logging in MS (used for debugging)",
"properties": {
"match": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).MatchLoggingOptions",
"$ref": "#/definitions/MatchLoggingOptions",
"title": "match"
}
},
Expand Down Expand Up @@ -379,13 +345,13 @@
"token",
"username"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/listenbrainz\",{assert:{\"resolution-mode\":\"import\"}}).ListenBrainzClientData",
"title": "ListenBrainzClientData",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientAIOConfig": {
"MalojaClientAIOConfig": {
"properties": {
"data": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientData",
"$ref": "#/definitions/MalojaClientData",
"description": "Specific data required to configure this client",
"title": "data"
},
Expand Down Expand Up @@ -419,10 +385,10 @@
"name",
"type"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientAIOConfig",
"title": "MalojaClientAIOConfig",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientData": {
"MalojaClientData": {
"properties": {
"apiKey": {
"description": "API Key for Maloja server",
Expand Down Expand Up @@ -474,7 +440,7 @@
"description": "Options used for increasing verbosity of logging in MS (used for debugging)",
"properties": {
"match": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/index\",{assert:{\"resolution-mode\":\"import\"}}).MatchLoggingOptions",
"$ref": "#/definitions/MatchLoggingOptions",
"title": "match"
}
},
Expand Down Expand Up @@ -507,10 +473,44 @@
"apiKey",
"url"
],
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/maloja\",{assert:{\"resolution-mode\":\"import\"}}).MalojaClientData",
"title": "MalojaClientData",
"type": "object"
},
"MatchLoggingOptions": {
"description": "Scrobble matching (between new source track and existing client scrobbles) logging options. Used for debugging.",
"properties": {
"confidenceBreakdown": {
"default": false,
"description": "Include confidence breakdowns in track match logging, if applicable",
"examples": [
false
],
"title": "confidenceBreakdown",
"type": "boolean"
},
"onMatch": {
"default": false,
"description": "Log to DEBUG when a new track DOES match an existing scrobble",
"examples": [
false
],
"title": "onMatch",
"type": "boolean"
},
"onNoMatch": {
"default": false,
"description": "Log to DEBUG when a new track does NOT match an existing scrobble",
"examples": [
false
],
"title": "onNoMatch",
"type": "boolean"
}
},
"title": "MatchLoggingOptions",
"type": "object"
},
"import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/common\",{assert:{\"resolution-mode\":\"import\"}}).RequestRetryOptions": {
"RequestRetryOptions": {
"properties": {
"maxRequestRetries": {
"default": 1,
Expand All @@ -531,18 +531,18 @@
"type": "number"
}
},
"title": "import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/common\",{assert:{\"resolution-mode\":\"import\"}}).RequestRetryOptions",
"title": "RequestRetryOptions",
"type": "object"
}
},
"properties": {
"clientDefaults": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/common\",{assert:{\"resolution-mode\":\"import\"}}).RequestRetryOptions",
"$ref": "#/definitions/RequestRetryOptions",
"title": "clientDefaults"
},
"clients": {
"items": {
"$ref": "#/definitions/import(\"/home/foxx/code/multi-scrobbler/src/backend/common/infrastructure/config/client/clients\",{assert:{\"resolution-mode\":\"import\"}}).ClientAIOConfig"
"$ref": "#/definitions/ClientAIOConfig"
},
"title": "clients",
"type": "array"
Expand Down
Loading

0 comments on commit 49b9ee9

Please sign in to comment.