Schema fixes, api bug fix
This commit is contained in:
parent
23b88b5068
commit
05285114cd
Binary file not shown.
Binary file not shown.
@ -20,6 +20,14 @@
|
|||||||
Regenerates the `spacebarchat/server/assets/schemas.json` file, used for API/Gateway input validation.
|
Regenerates the `spacebarchat/server/assets/schemas.json` file, used for API/Gateway input validation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const conWarn = console.warn;
|
||||||
|
console.warn = (...args) => {
|
||||||
|
// silence some expected warnings
|
||||||
|
if (args[0] === "initializer is expression for property id") return;
|
||||||
|
if (args[0].startsWith("unknown initializer for property ") && args[0].endsWith("[object Object]")) return;
|
||||||
|
conWarn(...args);
|
||||||
|
}
|
||||||
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const TJS = require("typescript-json-schema");
|
const TJS = require("typescript-json-schema");
|
||||||
@ -35,6 +43,10 @@ const settings = {
|
|||||||
defaultProps: false,
|
defaultProps: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ExcludeAndWarn = [
|
||||||
|
/^Record/,
|
||||||
|
/^Partial/,
|
||||||
|
]
|
||||||
const Excluded = [
|
const Excluded = [
|
||||||
"DefaultSchema",
|
"DefaultSchema",
|
||||||
"Schema",
|
"Schema",
|
||||||
@ -62,6 +74,21 @@ const Excluded = [
|
|||||||
"AnySchema",
|
"AnySchema",
|
||||||
"SMTPConnection.CustomAuthenticationResponse",
|
"SMTPConnection.CustomAuthenticationResponse",
|
||||||
"TransportMakeRequestResponse",
|
"TransportMakeRequestResponse",
|
||||||
|
// Emma [it/its] @ Rory& - 2025-10-14
|
||||||
|
/.*\..*/,
|
||||||
|
/^Axios.*/,
|
||||||
|
/^APIKeyConfiguration\..*/,
|
||||||
|
/^AccountSetting\..*/,
|
||||||
|
/^BulkContactManagement\..*/,
|
||||||
|
/^Campaign.*/,
|
||||||
|
/^Contact.*/,
|
||||||
|
/^DNS\..*/,
|
||||||
|
/^Delete.*/,
|
||||||
|
/^Destroy.*/,
|
||||||
|
/^Template\..*/,
|
||||||
|
/^Webhook\..*/,
|
||||||
|
/^(BigDecimal|BigInteger|Blob|Boolean|Document|Error|LazyRequest|List|Map|Normalized|Numeric)Schema/,
|
||||||
|
/^Put/
|
||||||
];
|
];
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
@ -74,16 +101,24 @@ function main() {
|
|||||||
|
|
||||||
let schemas = generator.getUserSymbols().filter((x) => {
|
let schemas = generator.getUserSymbols().filter((x) => {
|
||||||
return (
|
return (
|
||||||
(x.endsWith("Schema") ||
|
(
|
||||||
x.endsWith("Response") ||
|
x.endsWith("Schema")
|
||||||
x.startsWith("API")) &&
|
||x.endsWith("Response")
|
||||||
!Excluded.includes(x)
|
|| x.startsWith("API")
|
||||||
|
)
|
||||||
|
&& !ExcludeAndWarn.some(exc => {
|
||||||
|
const match = exc instanceof RegExp ? exc.test(x) : x === exc;
|
||||||
|
if (match) console.warn("Warning: Excluding schema", x);
|
||||||
|
return match;
|
||||||
|
})
|
||||||
|
&& !Excluded.some(exc => exc instanceof RegExp ? exc.test(x) : x === exc)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
var definitions = {};
|
var definitions = {};
|
||||||
|
|
||||||
for (const name of schemas) {
|
for (const name of schemas) {
|
||||||
|
console.log("Processing schema", name);
|
||||||
const part = TJS.generateSchema(program, name, settings, [], generator);
|
const part = TJS.generateSchema(program, name, settings, [], generator);
|
||||||
if (!part) continue;
|
if (!part) continue;
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { route } from "api";
|
import { route } from "@spacebar/api";
|
||||||
|
|
||||||
const router: Router = Router({ mergeParams: true });
|
const router: Router = Router({ mergeParams: true });
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
|||||||
type: 1,
|
type: 1,
|
||||||
dependent_sku_id: null,
|
dependent_sku_id: null,
|
||||||
application_id: "",
|
application_id: "",
|
||||||
manifets_labels: [],
|
manifest_labels: [],
|
||||||
access_type: 2,
|
access_type: 2,
|
||||||
name: "",
|
name: "",
|
||||||
features: [],
|
features: [],
|
||||||
|
|||||||
@ -18,5 +18,4 @@
|
|||||||
|
|
||||||
import { Team } from "@spacebar/util";
|
import { Team } from "@spacebar/util";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
export type TeamListResponse = Team[];
|
||||||
export interface TeamListResponse extends Array<Team> {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user