quickbase-js 0.1.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -126
- package/dist/esm/quickbase.d.ts +2725 -2689
- package/dist/esm/quickbase.js +1763 -3524
- package/dist/esm/quickbase.js.map +1 -1
- package/dist/esm/quickbase.min.js +1 -1
- package/dist/esm/quickbase.min.js.map +1 -1
- package/dist/umd/quickbase.umd.js +1762 -3706
- package/dist/umd/quickbase.umd.js.map +1 -1
- package/dist/umd/quickbase.umd.min.js +1 -1
- package/dist/umd/quickbase.umd.min.js.map +1 -1
- package/package.json +27 -12
- package/CHANGELOG.md +0 -155
- package/build-common.js +0 -131
- package/build-esm.js +0 -71
- package/build-umd.js +0 -69
- package/examples/quicbase-jsCDN.html +0 -36
- package/examples/react.js +0 -48
- package/examples/vanillajs.html +0 -47
- package/open-api/fix-spec-main.ts +0 -97
- package/open-api/generate-override-report.ts +0 -214
- package/open-api/generate-unified-interface.ts +0 -256
- package/open-api/output/override-report.html +0 -11
- package/open-api/output/override-report.json +0 -14395
- package/open-api/output/quickbase-fixed.json +0 -11191
- package/open-api/regenerate-client.ts +0 -116
- package/open-api/schema/enhance-general.ts +0 -100
- package/open-api/schema/fix-arrays.ts +0 -69
- package/open-api/schema/tags/apps.ts +0 -90
- package/open-api/schema/tags/fields.ts +0 -471
- package/open-api/schema/tags/groups.ts +0 -51
- package/open-api/schema/tags/index.ts +0 -66
- package/open-api/schema/tags/records.ts +0 -115
- package/open-api/schema/tags/tables.ts +0 -211
- package/open-api/schema/tags/users.ts +0 -47
- package/open-api/types/spec.ts +0 -42
- package/open-api/utils/infer-schema.ts +0 -40
- package/open-api/utils/naming.ts +0 -10
- package/playwright.config.ts +0 -37
- package/rollup.config.js +0 -114
- package/specs/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -46878
- package/specs/split/apps.json +0 -1315
- package/specs/split/auth.json +0 -191
- package/specs/split/fields.json +0 -3869
- package/specs/split/records.json +0 -754
- package/specs/split/reports.json +0 -619
- package/specs/split/tables.json +0 -1605
- package/src/RateLimitError.ts +0 -12
- package/src/ThrottleBucket.ts +0 -36
- package/src/generated-unified/QuickbaseClient.ts +0 -359
- package/src/generated-unified/missing-types-report.json +0 -3
- package/src/index.ts +0 -1
- package/src/invokeMethod.ts +0 -357
- package/src/quickbaseClient.ts +0 -244
- package/src/tokenCache.ts +0 -51
- package/src/utils.ts +0 -7
- package/test-esm.js +0 -1
- package/test-results.json +0 -2050
- package/test-umd.js +0 -1
- package/test.ts +0 -1
- package/tests/playwright/qb/auth/cacheSwitching.test.ts +0 -159
- package/tests/playwright/qb/auth/fetchTempToken401.test.ts +0 -219
- package/tests/playwright/qb/auth/getAppWithTempToken.test.ts +0 -162
- package/tests/playwright/qb/auth/getAppWithUserToken.test.ts +0 -153
- package/tests/playwright/qb/auth/getTempToken.test.ts +0 -152
- package/tests/playwright/qb/auth/tempTokenPrefetch.test.ts +0 -179
- package/tests/playwright/qb/auth/tempTokenRenewal.test.ts +0 -133
- package/tests/setup.ts +0 -53
- package/tests/vitest/qb/apps/copyApp.test.ts +0 -76
- package/tests/vitest/qb/apps/createApp.test.ts +0 -64
- package/tests/vitest/qb/apps/deleteApp.test.ts +0 -76
- package/tests/vitest/qb/apps/getApp.test.ts +0 -44
- package/tests/vitest/qb/apps/getAppEvents.test.ts +0 -67
- package/tests/vitest/qb/apps/updateApp.test.ts +0 -58
- package/tests/vitest/qb/auth/retryUserToken401.test.ts +0 -56
- package/tests/vitest/qb/fields/createField.test.ts +0 -77
- package/tests/vitest/qb/fields/deleteFields.test.ts +0 -83
- package/tests/vitest/qb/fields/getField.test.ts +0 -85
- package/tests/vitest/qb/fields/getFieldUsage.test.ts +0 -174
- package/tests/vitest/qb/fields/getFields.test.ts +0 -232
- package/tests/vitest/qb/fields/getFieldsUsage.test.ts +0 -77
- package/tests/vitest/qb/fields/updateField.test.ts +0 -93
- package/tests/vitest/qb/index.ts +0 -29
- package/tests/vitest/qb/records/deleteRecords.test.ts +0 -110
- package/tests/vitest/qb/records/runQuery.test.ts +0 -146
- package/tests/vitest/qb/records/upsert.test.ts +0 -102
- package/tests/vitest/qb/tables/createTable.test.ts +0 -55
- package/tests/vitest/qb/tables/deleteTable.test.ts +0 -50
- package/tests/vitest/qb/tables/getAppTables.test.ts +0 -46
- package/tests/vitest/qb/tables/getRelationships.test.ts +0 -80
- package/tests/vitest/qb/tables/getTable.test.ts +0 -26
- package/tests/vitest/qb/tables/updateRelationship.test.ts +0 -277
- package/tests/vitest/qb/tables/updateTable.test.ts +0 -48
- package/tests/vitest/unit/apps/copyApp.test.ts +0 -488
- package/tests/vitest/unit/apps/createApp.test.ts +0 -186
- package/tests/vitest/unit/apps/deleteApp.test.ts +0 -216
- package/tests/vitest/unit/apps/getApp.test.ts +0 -128
- package/tests/vitest/unit/apps/getAppEvents.test.ts +0 -193
- package/tests/vitest/unit/apps/updateApp.test.ts +0 -381
- package/tests/vitest/unit/auth/fetchTempToken401.test.ts +0 -62
- package/tests/vitest/unit/auth/getTempToken.test.ts +0 -95
- package/tests/vitest/unit/auth/retryTempToken401.test.ts +0 -113
- package/tests/vitest/unit/auth/retryTempTokenTwo401.test.ts +0 -81
- package/tests/vitest/unit/auth/retryUserToken401.test.ts +0 -56
- package/tests/vitest/unit/fields/createField.test.ts +0 -387
- package/tests/vitest/unit/fields/deleteFields.test.ts +0 -141
- package/tests/vitest/unit/fields/getField.test.ts +0 -189
- package/tests/vitest/unit/fields/getFieldUsage.test.ts +0 -166
- package/tests/vitest/unit/fields/getFields.test.ts +0 -122
- package/tests/vitest/unit/fields/getFieldsUsage.test.ts +0 -160
- package/tests/vitest/unit/fields/updateField.test.ts +0 -280
- package/tests/vitest/unit/index.ts +0 -33
- package/tests/vitest/unit/rateLimit.test.ts +0 -189
- package/tests/vitest/unit/records/deleteRecords.test.ts +0 -112
- package/tests/vitest/unit/records/runQuery.test.ts +0 -102
- package/tests/vitest/unit/records/upsert.test.ts +0 -234
- package/tests/vitest/unit/tables/createTable.test.ts +0 -70
- package/tests/vitest/unit/tables/deleteTable.test.ts +0 -77
- package/tests/vitest/unit/tables/getAppTables.test.ts +0 -85
- package/tests/vitest/unit/tables/getRelationships.test.ts +0 -259
- package/tests/vitest/unit/tables/getTable.test.ts +0 -233
- package/tests/vitest/unit/tables/updateRelationship.test.ts +0 -305
- package/tests/vitest/unit/tables/updateTable.test.ts +0 -80
- package/tests/vitest/unit/tokenLifespan.test.ts +0 -138
- package/tests/vitest/unit/umd.test.ts +0 -8
- package/text.txt +0 -104
- package/tools/log-gen.ts +0 -235
- package/tools/log-gen.yaml +0 -4982
- package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -32
- package/versionrc.json +0 -9
- package/vitest.config.ts +0 -27
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
import { existsSync } from "fs";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
import fetch from "node-fetch";
|
|
7
|
-
import readline from "readline";
|
|
8
|
-
|
|
9
|
-
const CURRENT_JAR_VERSION = "7.12.0";
|
|
10
|
-
const MAVEN_METADATA_URL =
|
|
11
|
-
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml";
|
|
12
|
-
const CODEGEN_DIR = join(fileURLToPath(import.meta.url), ".."); // open-api/
|
|
13
|
-
const JARS_DIR = join(CODEGEN_DIR, "..", "tools", "openapi-jars"); // Updated to tools/openapi-jars/
|
|
14
|
-
const SPEC_INPUT = join(CODEGEN_DIR, "output", "quickbase-fixed.json"); // Relative to open-api/
|
|
15
|
-
const OUTPUT_DIR = join(CODEGEN_DIR, "..", "src", "generated"); // Up to root, then into src/generated/
|
|
16
|
-
|
|
17
|
-
async function getLatestVersion(): Promise<string> {
|
|
18
|
-
const response = await fetch(MAVEN_METADATA_URL);
|
|
19
|
-
if (!response.ok)
|
|
20
|
-
throw new Error(`Failed to fetch Maven metadata: ${response.statusText}`);
|
|
21
|
-
const text = await response.text();
|
|
22
|
-
const match = text.match(/<latest>(.*?)<\/latest>/);
|
|
23
|
-
if (!match)
|
|
24
|
-
throw new Error("Couldn’t parse latest version from Maven metadata");
|
|
25
|
-
return match[1];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function checkAndPromptForUpdate(messages: string[]): Promise<string> {
|
|
29
|
-
const latestVersion = await getLatestVersion();
|
|
30
|
-
if (latestVersion === CURRENT_JAR_VERSION) {
|
|
31
|
-
messages.push(`Current version (${CURRENT_JAR_VERSION}) is the latest.`);
|
|
32
|
-
return CURRENT_JAR_VERSION;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
messages.push(
|
|
36
|
-
`Newer version available: ${latestVersion} (current: ${CURRENT_JAR_VERSION})`
|
|
37
|
-
);
|
|
38
|
-
const rl = readline.createInterface({
|
|
39
|
-
input: process.stdin,
|
|
40
|
-
output: process.stdout,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
const prompt = "Do you want to update to the latest version? (y/n): ";
|
|
45
|
-
messages.push(prompt);
|
|
46
|
-
rl.question(prompt, (answer) => {
|
|
47
|
-
rl.close();
|
|
48
|
-
if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
|
|
49
|
-
messages.push(`Switching to version ${latestVersion}...`);
|
|
50
|
-
resolve(latestVersion);
|
|
51
|
-
} else {
|
|
52
|
-
messages.push(`Sticking with version ${CURRENT_JAR_VERSION}.`);
|
|
53
|
-
resolve(CURRENT_JAR_VERSION);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function ensureJarExists(
|
|
60
|
-
version: string,
|
|
61
|
-
messages: string[]
|
|
62
|
-
): Promise<string> {
|
|
63
|
-
const jarPath = join(JARS_DIR, `openapi-generator-cli-${version}.jar`);
|
|
64
|
-
const jarUrl = `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${version}/openapi-generator-cli-${version}.jar`;
|
|
65
|
-
|
|
66
|
-
if (!existsSync(jarPath)) {
|
|
67
|
-
messages.push(`Downloading OpenAPI Generator CLI v${version}...`);
|
|
68
|
-
try {
|
|
69
|
-
execSync(`curl -L -o ${jarPath} ${jarUrl}`, { stdio: "inherit" });
|
|
70
|
-
messages.push(`Downloaded ${jarPath}`);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
messages.push("Failed to download JAR.");
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
messages.push(`Using existing ${jarPath}`);
|
|
77
|
-
}
|
|
78
|
-
return jarPath;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function regenerateClient(jarPath: string, messages: string[]) {
|
|
82
|
-
messages.push("Regenerating client from spec...");
|
|
83
|
-
const command = `java -jar ${jarPath} generate -i ${SPEC_INPUT} -g typescript-fetch -o ${OUTPUT_DIR} --additional-properties=generateAliasAsModel=true`;
|
|
84
|
-
try {
|
|
85
|
-
execSync(command, { stdio: "inherit" });
|
|
86
|
-
messages.push("Client regeneration complete.");
|
|
87
|
-
} catch (error) {
|
|
88
|
-
messages.push("Regeneration failed.");
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function main() {
|
|
94
|
-
const messages: string[] = [];
|
|
95
|
-
try {
|
|
96
|
-
if (!existsSync(SPEC_INPUT)) {
|
|
97
|
-
console.error(
|
|
98
|
-
`Spec file ${SPEC_INPUT} does not exist. Run 'npm run fix-spec' first.`
|
|
99
|
-
);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
const versionToUse = await checkAndPromptForUpdate(messages);
|
|
103
|
-
const jarPath = await ensureJarExists(versionToUse, messages);
|
|
104
|
-
regenerateClient(jarPath, messages);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
console.error("Error occurred during process:", error);
|
|
107
|
-
} finally {
|
|
108
|
-
console.log("\n--- Key Messages ---");
|
|
109
|
-
messages.forEach((msg) => console.log(msg));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
main().catch((error) => {
|
|
114
|
-
console.error("Error in regeneration process:", error);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// schema/enhance-general.ts
|
|
2
|
-
import { Operation, Parameter, Spec } from "../types/spec.ts";
|
|
3
|
-
import { inferSchema } from "../utils/infer-schema.ts";
|
|
4
|
-
|
|
5
|
-
export function enhanceGeneral(spec: Spec): void {
|
|
6
|
-
spec.definitions = spec.definitions || {};
|
|
7
|
-
|
|
8
|
-
if (!spec.definitions["Record"]) {
|
|
9
|
-
spec.definitions["Record"] = {
|
|
10
|
-
type: "object",
|
|
11
|
-
additionalProperties: {
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: { value: { type: "string" } },
|
|
14
|
-
required: ["value"],
|
|
15
|
-
},
|
|
16
|
-
description: "A generic QuickBase record with field ID-value pairs",
|
|
17
|
-
};
|
|
18
|
-
console.log("Added Record to definitions");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!spec.definitions["Permission"]) {
|
|
22
|
-
spec.definitions["Permission"] = {
|
|
23
|
-
type: "object",
|
|
24
|
-
properties: {
|
|
25
|
-
role: { type: "string", description: "The role name" },
|
|
26
|
-
permissionType: {
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "Permission type (e.g., View, Modify)",
|
|
29
|
-
},
|
|
30
|
-
roleId: { type: "integer", description: "The role identifier" },
|
|
31
|
-
},
|
|
32
|
-
required: ["role", "permissionType", "roleId"],
|
|
33
|
-
description: "A single permission entry for a field",
|
|
34
|
-
};
|
|
35
|
-
console.log("Added Permission to definitions");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
for (const pathKey in spec.paths) {
|
|
39
|
-
for (const method in spec.paths[pathKey]) {
|
|
40
|
-
const operation: Operation = spec.paths[pathKey][method];
|
|
41
|
-
const opId =
|
|
42
|
-
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
43
|
-
|
|
44
|
-
if (operation.parameters) {
|
|
45
|
-
operation.parameters.forEach((param: Parameter) => {
|
|
46
|
-
if (param.in !== "body" && !param.type && !param.schema) {
|
|
47
|
-
param.type = param.name.includes("Id") ? "string" : "string";
|
|
48
|
-
console.log(
|
|
49
|
-
`Set default type 'string' for ${pathKey}(${method}).${param.name}`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (operation.responses) {
|
|
56
|
-
for (const status in operation.responses) {
|
|
57
|
-
const response = operation.responses[status];
|
|
58
|
-
if (response.schema) {
|
|
59
|
-
const cleanStatus = status.replace("/", "_");
|
|
60
|
-
const responseName = `${opId}${cleanStatus}Response`;
|
|
61
|
-
if (!spec.definitions[responseName]) {
|
|
62
|
-
console.log(
|
|
63
|
-
`Adding ${responseName} to definitions for ${pathKey}(${method})`
|
|
64
|
-
);
|
|
65
|
-
if (!response.schema.type && response["x-amf-mediaType"]) {
|
|
66
|
-
const mediaType = response["x-amf-mediaType"];
|
|
67
|
-
if (mediaType === "application/octet-stream") {
|
|
68
|
-
response.schema = {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: { data: { type: "string", format: "binary" } },
|
|
71
|
-
description:
|
|
72
|
-
response.schema?.description || "Binary file content",
|
|
73
|
-
};
|
|
74
|
-
} else if (mediaType === "application/x-yaml") {
|
|
75
|
-
response.schema = {
|
|
76
|
-
type: "object",
|
|
77
|
-
properties: { content: { type: "string", format: "yaml" } },
|
|
78
|
-
description: "YAML-formatted data",
|
|
79
|
-
};
|
|
80
|
-
} else if (
|
|
81
|
-
mediaType === "application/json" &&
|
|
82
|
-
response.schema.example
|
|
83
|
-
) {
|
|
84
|
-
response.schema = inferSchema(
|
|
85
|
-
response.schema.example,
|
|
86
|
-
responseName
|
|
87
|
-
);
|
|
88
|
-
response.schema.description =
|
|
89
|
-
response.description || `Response for ${opId}`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
spec.definitions[responseName] = response.schema;
|
|
93
|
-
}
|
|
94
|
-
response.schema = { $ref: `#/definitions/${responseName}` };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// schema/fix-arrays.ts
|
|
2
|
-
import { Parameter, Spec } from "../types/spec.ts";
|
|
3
|
-
|
|
4
|
-
export function fixArrays(spec: Spec): void {
|
|
5
|
-
for (const pathKey in spec.paths) {
|
|
6
|
-
for (const method in spec.paths[pathKey]) {
|
|
7
|
-
const operation = spec.paths[pathKey][method];
|
|
8
|
-
if (operation.parameters) {
|
|
9
|
-
operation.parameters.forEach((param: Parameter) => {
|
|
10
|
-
if (param.schema?.type === "array" && !param.schema.items) {
|
|
11
|
-
console.log(
|
|
12
|
-
`Fixing array schema for ${pathKey}(${method}).${param.name}`
|
|
13
|
-
);
|
|
14
|
-
param.schema.items = { type: "string" };
|
|
15
|
-
}
|
|
16
|
-
if (param.schema?.properties) {
|
|
17
|
-
for (const propKey in param.schema.properties) {
|
|
18
|
-
const prop = param.schema.properties[propKey];
|
|
19
|
-
if (prop.type === "array" && !prop.items) {
|
|
20
|
-
console.log(
|
|
21
|
-
`Fixing nested array for ${pathKey}(${method}).${param.name}.${propKey}`
|
|
22
|
-
);
|
|
23
|
-
prop.items = { type: "string" };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (operation.responses) {
|
|
30
|
-
for (const status in operation.responses) {
|
|
31
|
-
const response = operation.responses[status];
|
|
32
|
-
if (response.schema?.type === "array" && !response.schema.items) {
|
|
33
|
-
console.log(
|
|
34
|
-
`Fixing array schema for ${pathKey}(${method}).responses.${status}`
|
|
35
|
-
);
|
|
36
|
-
response.schema.items = { type: "string" };
|
|
37
|
-
}
|
|
38
|
-
if (response.schema?.properties) {
|
|
39
|
-
for (const propKey in response.schema.properties) {
|
|
40
|
-
// Fixed: Changed param to response
|
|
41
|
-
const prop = response.schema.properties[propKey];
|
|
42
|
-
if (prop.type === "array" && !prop.items) {
|
|
43
|
-
console.log(
|
|
44
|
-
`Fixing nested array for ${pathKey}(${method}).responses.${status}.${propKey}`
|
|
45
|
-
);
|
|
46
|
-
prop.items = { type: "string" };
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log("Fixing array schemas in definitions...");
|
|
56
|
-
const definitions = spec.definitions || {};
|
|
57
|
-
for (const defKey in definitions) {
|
|
58
|
-
const def = definitions[defKey];
|
|
59
|
-
if (def.properties) {
|
|
60
|
-
for (const propKey in def.properties) {
|
|
61
|
-
const prop = def.properties[propKey];
|
|
62
|
-
if (prop.type === "array" && !prop.items) {
|
|
63
|
-
console.log(`Fixing missing items in ${defKey}.${propKey}`);
|
|
64
|
-
prop.items = { type: "string" };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// schema/tags/apps.ts
|
|
2
|
-
import { Operation, Parameter, Spec } from "../../types/spec.ts";
|
|
3
|
-
import { normalizeDefinitionName } from "../../utils/naming.ts";
|
|
4
|
-
|
|
5
|
-
export function enhanceApps(
|
|
6
|
-
spec: Spec,
|
|
7
|
-
pathKey: string,
|
|
8
|
-
method: string,
|
|
9
|
-
operation: Operation
|
|
10
|
-
): void {
|
|
11
|
-
const opId =
|
|
12
|
-
operation.operationId || `${method}${pathKey.replace(/\W/g, "")}`;
|
|
13
|
-
if (operation.parameters && operation.tags?.includes("Apps")) {
|
|
14
|
-
operation.parameters.forEach((param: Parameter) => {
|
|
15
|
-
if (param.in === "body") {
|
|
16
|
-
if (!param.schema) param.schema = {};
|
|
17
|
-
let requestName =
|
|
18
|
-
param.schema.$ref?.split("/").pop() || `${opId}Request`;
|
|
19
|
-
requestName = normalizeDefinitionName(requestName);
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
!spec.definitions[requestName] ||
|
|
23
|
-
!spec.definitions[requestName].type ||
|
|
24
|
-
Object.keys(spec.definitions[requestName]?.properties || {})
|
|
25
|
-
.length === 0
|
|
26
|
-
) {
|
|
27
|
-
console.log(
|
|
28
|
-
`Defining schema for ${requestName} in ${pathKey}(${method})`
|
|
29
|
-
);
|
|
30
|
-
let properties;
|
|
31
|
-
if (pathKey.includes("/copy") && method === "post") {
|
|
32
|
-
properties = {
|
|
33
|
-
name: { type: "string", description: "The name of the new app." },
|
|
34
|
-
description: {
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "A description for the new app.",
|
|
37
|
-
},
|
|
38
|
-
properties: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {
|
|
41
|
-
keepData: {
|
|
42
|
-
type: "boolean",
|
|
43
|
-
description: "Whether to copy data.",
|
|
44
|
-
},
|
|
45
|
-
excludeFiles: {
|
|
46
|
-
type: "boolean",
|
|
47
|
-
description: "Whether to exclude files.",
|
|
48
|
-
},
|
|
49
|
-
usersAndRoles: {
|
|
50
|
-
type: "boolean",
|
|
51
|
-
description: "Whether to copy users and roles.",
|
|
52
|
-
},
|
|
53
|
-
assignUserToken: {
|
|
54
|
-
type: "boolean",
|
|
55
|
-
description: "Whether to assign the user token.",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
description: "Options for customizing the app copy process.",
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
} else {
|
|
62
|
-
properties = {
|
|
63
|
-
name: { type: "string", description: "The name of the app." },
|
|
64
|
-
description: {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "A description for the app.",
|
|
67
|
-
},
|
|
68
|
-
assignToken: {
|
|
69
|
-
type: "boolean",
|
|
70
|
-
description: "Whether to assign the user token.",
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
spec.definitions[requestName] = {
|
|
75
|
-
type: "object",
|
|
76
|
-
properties,
|
|
77
|
-
required: Object.keys(properties).filter(
|
|
78
|
-
(key) => key !== "description" && key !== "properties"
|
|
79
|
-
),
|
|
80
|
-
description: operation.summary || `Request body for ${opId}`,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
param.schema = { $ref: `#/definitions/${requestName}` };
|
|
84
|
-
console.log(
|
|
85
|
-
`Ensured ${requestName} in definitions for ${pathKey}(${method})`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|