quickbase-js 1.1.0-beta.3 → 1.1.0-beta.5

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +115 -5
  3. package/build.js +175 -55
  4. package/dist/{quickbase.d.ts → esm/quickbase.d.ts} +1108 -349
  5. package/dist/{quickbase.js → esm/quickbase.js} +828 -263
  6. package/dist/esm/quickbase.js.map +1 -0
  7. package/dist/esm/quickbase.min.js +2 -0
  8. package/dist/esm/quickbase.min.js.map +1 -0
  9. package/dist/umd/quickbase.umd.d.ts +5341 -0
  10. package/dist/umd/quickbase.umd.js +7696 -0
  11. package/dist/umd/quickbase.umd.js.map +1 -0
  12. package/dist/umd/quickbase.umd.min.js +2 -0
  13. package/dist/umd/quickbase.umd.min.js.map +1 -0
  14. package/examples/react.js +12 -12
  15. package/examples/vanillajs.html +12 -12
  16. package/log-gen.yaml +536 -1915
  17. package/open-api/definitions/apps.ts +274 -0
  18. package/open-api/definitions/auth.ts +10 -0
  19. package/open-api/definitions/fields.ts +751 -0
  20. package/open-api/definitions/index.ts +18 -0
  21. package/open-api/definitions/records.ts +269 -0
  22. package/open-api/definitions/relationships.ts +90 -0
  23. package/open-api/definitions/reports.ts +10 -0
  24. package/open-api/definitions/tables.ts +112 -0
  25. package/{src/code-generation → open-api}/fix-spec-main.ts +3 -3
  26. package/{src/code-generation → open-api}/generate-unified-interface.ts +42 -17
  27. package/{src/code-generation → open-api}/output/quickbase-fixed.json +3244 -4586
  28. package/open-api/paths/apps.ts +100 -0
  29. package/open-api/paths/auth.ts +25 -0
  30. package/open-api/paths/fields.ts +207 -0
  31. package/open-api/paths/index.ts +17 -0
  32. package/open-api/paths/records.ts +68 -0
  33. package/open-api/paths/relationships.ts +32 -0
  34. package/open-api/paths/reports.ts +34 -0
  35. package/open-api/paths/tables.ts +162 -0
  36. package/{src/code-generation → open-api}/regenerate-client.ts +4 -4
  37. package/package.json +34 -25
  38. package/playwright-results.txt/.last-run.json +4 -0
  39. package/playwright.config.ts +1 -1
  40. package/rollup.config.mjs +114 -0
  41. package/src/generated-unified/QuickbaseClient.ts +7 -6
  42. package/test-artifacts/.last-run.json +4 -2
  43. package/test-esm.js +1 -0
  44. package/test-umd.js +1 -0
  45. package/test.ts +1 -0
  46. package/tests/playwright/qb/auth/umd.test.ts +10 -0
  47. package/tests/vitest/qb/fields/createField.test.ts +78 -0
  48. package/tests/vitest/qb/fields/deleteFields.test.ts +89 -0
  49. package/tests/vitest/qb/fields/getField.test.ts +85 -0
  50. package/tests/vitest/qb/fields/getFieldUsage.test.ts +174 -0
  51. package/tests/vitest/qb/fields/getFieldsUsage.test.ts +77 -0
  52. package/tests/vitest/qb/index.ts +25 -1
  53. package/tests/vitest/unit/fields/createField.test.ts +391 -0
  54. package/tests/vitest/unit/fields/deleteFields.test.ts +141 -0
  55. package/tests/vitest/unit/fields/getField.test.ts +189 -0
  56. package/tests/vitest/unit/fields/getFieldUsage.test.ts +147 -0
  57. package/tests/vitest/unit/fields/getFieldsUsage.test.ts +160 -0
  58. package/tests/vitest/unit/index.ts +30 -1
  59. package/tests/vitest/unit/umd.test.ts +8 -0
  60. package/{src → tools}/log-gen.ts +14 -10
  61. package/tools/openapi-jars/openapi-generator-cli-7.12.0.jar +0 -0
  62. package/tsconfig.build.json +17 -0
  63. package/tsconfig.json +5 -5
  64. package/dist/quickbase.js.map +0 -1
  65. package/rollup.config.js +0 -70
  66. package/src/code-generation/fix-spec-definitions.ts +0 -809
  67. package/src/code-generation/fix-spec-paths.ts +0 -439
  68. package/test-artifacts/test-results.json +0 -829
  69. /package/{src/specs → specs}/QuickBase_RESTful_API_2025-03-04T06_22_39.725Z.json +0 -0
@@ -0,0 +1,18 @@
1
+ // src/code-generation/definitions/index.ts
2
+ import { appsDefinitions } from "./apps.ts";
3
+ import { authDefinitions } from "./auth.ts";
4
+ import { fieldsDefinitions } from "./fields.ts";
5
+ import { recordsDefinitions } from "./records.ts";
6
+ import { relationshipsDefinitions } from "./relationships.ts";
7
+ import { reportsDefinitions } from "./reports.ts";
8
+ import { tablesDefinitions } from "./tables.ts";
9
+
10
+ export const definitions = {
11
+ ...appsDefinitions,
12
+ ...authDefinitions,
13
+ ...fieldsDefinitions,
14
+ ...recordsDefinitions,
15
+ ...relationshipsDefinitions,
16
+ ...reportsDefinitions,
17
+ ...tablesDefinitions,
18
+ };
@@ -0,0 +1,269 @@
1
+ // src/code-generation/definitions/records.ts
2
+ export const recordsDefinitions = {
3
+ Record: {
4
+ type: "object",
5
+ properties: {
6
+ _dummy: {
7
+ type: "string",
8
+ description: "Unused dummy property to force model generation.",
9
+ nullable: true,
10
+ },
11
+ },
12
+ additionalProperties: {
13
+ type: "object",
14
+ properties: {
15
+ value: {
16
+ anyOf: [
17
+ { type: "string" },
18
+ { type: "number" },
19
+ { type: "boolean" },
20
+ { type: "object" },
21
+ { type: "array" },
22
+ { type: "null" },
23
+ ],
24
+ description: "The value of the field.",
25
+ },
26
+ },
27
+ required: ["value"],
28
+ description: "The value object for a field ID key.",
29
+ },
30
+ description:
31
+ "A record with field ID keys (e.g., '6') and value objects (e.g., { value: 'data' }).",
32
+ },
33
+ UpsertRequest: {
34
+ type: "object",
35
+ required: ["to"],
36
+ properties: {
37
+ to: { type: "string", description: "The table identifier (dbid)." },
38
+ data: {
39
+ type: "array",
40
+ items: { $ref: "#/definitions/Record" },
41
+ description: "Array of records to upsert.",
42
+ },
43
+ mergeFieldId: {
44
+ type: "integer",
45
+ description: "The field ID to merge on (optional).",
46
+ },
47
+ fieldsToReturn: {
48
+ type: "array",
49
+ items: { type: "integer" },
50
+ description: "Field IDs to return in the response (optional).",
51
+ },
52
+ },
53
+ },
54
+ Upsert200Response: {
55
+ type: "object",
56
+ properties: {
57
+ data: {
58
+ type: "array",
59
+ items: {
60
+ type: "object",
61
+ additionalProperties: {
62
+ type: "object",
63
+ properties: {
64
+ value: {
65
+ anyOf: [
66
+ { type: "string" },
67
+ { type: "number" },
68
+ { type: "boolean" },
69
+ { type: "object" },
70
+ { type: "array" },
71
+ { type: "null" },
72
+ ],
73
+ description: "The value of the field.",
74
+ },
75
+ },
76
+ required: ["value"],
77
+ },
78
+ },
79
+ description: "Array of upserted records with field IDs and values.",
80
+ },
81
+ metadata: {
82
+ type: "object",
83
+ properties: {
84
+ createdRecordIds: {
85
+ type: "array",
86
+ items: { type: "integer" },
87
+ description: "IDs of newly created records.",
88
+ },
89
+ updatedRecordIds: {
90
+ type: "array",
91
+ items: { type: "integer" },
92
+ description: "IDs of updated records.",
93
+ },
94
+ unchangedRecordIds: {
95
+ type: "array",
96
+ items: { type: "integer" },
97
+ description: "IDs of unchanged records.",
98
+ },
99
+ totalNumberOfRecordsProcessed: {
100
+ type: "integer",
101
+ description: "Total records processed.",
102
+ },
103
+ },
104
+ required: ["totalNumberOfRecordsProcessed"],
105
+ },
106
+ },
107
+ },
108
+ Upsert207Response: {
109
+ type: "object",
110
+ properties: {
111
+ data: {
112
+ type: "array",
113
+ items: {
114
+ type: "object",
115
+ additionalProperties: {
116
+ type: "object",
117
+ properties: {
118
+ value: {
119
+ anyOf: [
120
+ { type: "string" },
121
+ { type: "number" },
122
+ { type: "boolean" },
123
+ { type: "object" },
124
+ { type: "array" },
125
+ { type: "null" },
126
+ ],
127
+ description: "The value of the field.",
128
+ },
129
+ },
130
+ required: ["value"],
131
+ },
132
+ },
133
+ description: "Array of successfully upserted records (may be empty).",
134
+ },
135
+ metadata: {
136
+ type: "object",
137
+ properties: {
138
+ createdRecordIds: { type: "array", items: { type: "integer" } },
139
+ updatedRecordIds: { type: "array", items: { type: "integer" } },
140
+ unchangedRecordIds: { type: "array", items: { type: "integer" } },
141
+ lineErrors: {
142
+ type: "object",
143
+ additionalProperties: { type: "array", items: { type: "string" } },
144
+ description: "Errors by line number (1-based index).",
145
+ },
146
+ totalNumberOfRecordsProcessed: { type: "integer" },
147
+ },
148
+ required: ["totalNumberOfRecordsProcessed"],
149
+ },
150
+ },
151
+ },
152
+ DeleteRecordsRequest: {
153
+ type: "object",
154
+ required: ["from", "where"],
155
+ properties: {
156
+ from: {
157
+ type: "string",
158
+ description:
159
+ "The table identifier (dbid) from which to delete records.",
160
+ },
161
+ where: {
162
+ type: "string",
163
+ description:
164
+ "A QuickBase query string specifying which records to delete.",
165
+ },
166
+ },
167
+ description:
168
+ "Request body for deleting records from a table using a query.",
169
+ },
170
+ DeleteRecords200Response: {
171
+ type: "object",
172
+ properties: {
173
+ numberDeleted: {
174
+ type: "integer",
175
+ description: "The number of records successfully deleted.",
176
+ },
177
+ },
178
+ required: ["numberDeleted"],
179
+ description: "Response body for successful deletion of records.",
180
+ },
181
+ RunQueryRequest: {
182
+ type: "object",
183
+ required: ["from"],
184
+ properties: {
185
+ from: { type: "string", description: "Table ID (dbid)" },
186
+ select: {
187
+ type: "array",
188
+ items: { type: "integer" },
189
+ description: "Field IDs to return",
190
+ },
191
+ where: { type: "string", description: "Query string" },
192
+ sortBy: {
193
+ type: "array",
194
+ items: {
195
+ type: "object",
196
+ properties: {
197
+ fieldId: { type: "integer" },
198
+ order: { type: "string", enum: ["ASC", "DESC"] },
199
+ },
200
+ },
201
+ description: "Sort criteria",
202
+ },
203
+ groupBy: {
204
+ type: "array",
205
+ items: {
206
+ type: "object",
207
+ properties: {
208
+ fieldId: { type: "integer" },
209
+ grouping: { type: "string", enum: ["equal-values"] },
210
+ },
211
+ },
212
+ description: "Grouping criteria",
213
+ },
214
+ options: {
215
+ type: "object",
216
+ properties: {
217
+ skip: { type: "integer", description: "Number of records to skip" },
218
+ top: {
219
+ type: "integer",
220
+ description: "Max number of records to return",
221
+ },
222
+ compareWithAppLocalTime: {
223
+ type: "boolean",
224
+ description: "Compare times with app local time",
225
+ },
226
+ },
227
+ },
228
+ },
229
+ },
230
+ RunQueryResponse: {
231
+ type: "object",
232
+ properties: {
233
+ data: {
234
+ type: "array",
235
+ items: {
236
+ type: "object",
237
+ additionalProperties: {
238
+ type: "object",
239
+ properties: { value: { type: "any" } },
240
+ },
241
+ },
242
+ description: "Array of record data with field IDs as keys",
243
+ },
244
+ fields: {
245
+ type: "array",
246
+ items: {
247
+ type: "object",
248
+ properties: {
249
+ id: { type: "integer" },
250
+ label: { type: "string" },
251
+ type: { type: "string" },
252
+ },
253
+ },
254
+ description: "Field metadata",
255
+ },
256
+ metadata: {
257
+ type: "object",
258
+ properties: {
259
+ numFields: { type: "integer" },
260
+ numRecords: { type: "integer" },
261
+ skip: { type: "integer" },
262
+ top: { type: "integer" },
263
+ totalRecords: { type: "integer" },
264
+ },
265
+ description: "Query metadata",
266
+ },
267
+ },
268
+ },
269
+ };
@@ -0,0 +1,90 @@
1
+ // src/code-generation/definitions/relationships.ts
2
+ export const relationshipsDefinitions = {
3
+ GetRelationships200Response: {
4
+ type: "object",
5
+ properties: {
6
+ metadata: {
7
+ type: "object",
8
+ properties: {
9
+ numRelationships: {
10
+ type: "integer",
11
+ description:
12
+ "The number of relationships in the current response object.",
13
+ },
14
+ skip: {
15
+ type: "integer",
16
+ description: "The number of relationships skipped.",
17
+ },
18
+ totalRelationships: {
19
+ type: "integer",
20
+ description: "The total number of relationships.",
21
+ },
22
+ },
23
+ required: ["numRelationships", "skip", "totalRelationships"],
24
+ description:
25
+ "Additional information about the results that may be helpful.",
26
+ },
27
+ relationships: {
28
+ type: "array",
29
+ items: { $ref: "#/definitions/Relationship" },
30
+ description: "The relationships in a table.",
31
+ },
32
+ },
33
+ required: ["metadata", "relationships"],
34
+ description: "Response containing relationships for a table.",
35
+ },
36
+ Relationship: {
37
+ type: "object",
38
+ properties: {
39
+ id: {
40
+ type: "integer",
41
+ description: "The relationship id (foreign key field id).",
42
+ },
43
+ parentTableId: {
44
+ type: "string",
45
+ description: "The parent table id of the relationship.",
46
+ },
47
+ childTableId: {
48
+ type: "string",
49
+ description: "The child table id of the relationship.",
50
+ },
51
+ foreignKeyField: {
52
+ $ref: "#/definitions/RelationshipField",
53
+ description: "The foreign key field information.",
54
+ },
55
+ isCrossApp: {
56
+ type: "boolean",
57
+ description: "Whether this is a cross-app relationship.",
58
+ },
59
+ lookupFields: {
60
+ type: "array",
61
+ items: { $ref: "#/definitions/RelationshipField" },
62
+ description: "The lookup fields array.",
63
+ },
64
+ summaryFields: {
65
+ type: "array",
66
+ items: { $ref: "#/definitions/RelationshipField" },
67
+ description: "The summary fields array.",
68
+ },
69
+ },
70
+ required: [
71
+ "id",
72
+ "parentTableId",
73
+ "childTableId",
74
+ "foreignKeyField",
75
+ "isCrossApp",
76
+ ],
77
+ description: "A relationship between tables.",
78
+ },
79
+ RelationshipField: {
80
+ type: "object",
81
+ properties: {
82
+ id: { type: "integer", description: "Field id." },
83
+ label: { type: "string", description: "Field label." },
84
+ type: { type: "string", description: "Field type." },
85
+ },
86
+ required: ["id", "label", "type"],
87
+ description:
88
+ "A field involved in a relationship (foreign key, lookup, or summary).",
89
+ },
90
+ };
@@ -0,0 +1,10 @@
1
+ // src/code-generation/definitions/reports.ts
2
+ export const reportsDefinitions = {
3
+ ReportRunResponse: {
4
+ type: "object",
5
+ properties: {
6
+ id: { type: "string" },
7
+ data: { type: "object" },
8
+ },
9
+ },
10
+ };
@@ -0,0 +1,112 @@
1
+ // src/code-generation/definitions/tables.ts
2
+ export const tablesDefinitions = {
3
+ Table: {
4
+ type: "object",
5
+ required: ["id", "name"],
6
+ properties: {
7
+ id: {
8
+ type: "string",
9
+ description: "The unique identifier (dbid) of the table.",
10
+ },
11
+ name: { type: "string", description: "The name of the table." },
12
+ alias: {
13
+ type: "string",
14
+ description: "The automatically-created table alias for the table.",
15
+ },
16
+ description: {
17
+ type: "string",
18
+ description:
19
+ "The description of the table, as configured by an application administrator.",
20
+ },
21
+ created: {
22
+ type: "string",
23
+ format: "date-time",
24
+ description:
25
+ "The time and date when the table was created, in ISO 8601 format (UTC).",
26
+ },
27
+ updated: {
28
+ type: "string",
29
+ format: "date-time",
30
+ description:
31
+ "The time and date when the table schema or data was last updated, in ISO 8601 format (UTC).",
32
+ },
33
+ nextRecordId: {
34
+ type: "integer",
35
+ description:
36
+ "The incremental Record ID that will be used when the next record is created.",
37
+ },
38
+ nextFieldId: {
39
+ type: "integer",
40
+ description:
41
+ "The incremental Field ID that will be used when the next field is created.",
42
+ },
43
+ defaultSortFieldId: {
44
+ type: "integer",
45
+ description:
46
+ "The id of the field that is configured for default sorting.",
47
+ },
48
+ defaultSortOrder: {
49
+ type: "string",
50
+ enum: ["ASC", "DESC"],
51
+ description:
52
+ "The default sort order for the table, either ascending (ASC) or descending (DESC).",
53
+ },
54
+ keyFieldId: {
55
+ type: "integer",
56
+ description:
57
+ "The id of the field that is configured to be the key on this table, usually the Quickbase Record ID.",
58
+ },
59
+ singleRecordName: {
60
+ type: "string",
61
+ description: "The builder-configured singular noun of the table.",
62
+ },
63
+ pluralRecordName: {
64
+ type: "string",
65
+ description: "The builder-configured plural noun of the table.",
66
+ },
67
+ sizeLimit: {
68
+ type: "string",
69
+ description: "The size limit for the table (e.g., '150 MB').",
70
+ },
71
+ spaceUsed: {
72
+ type: "string",
73
+ description:
74
+ "The amount of space currently being used by the table (e.g., '17 MB').",
75
+ },
76
+ spaceRemaining: {
77
+ type: "string",
78
+ description:
79
+ "The amount of space remaining for use by the table (e.g., '133 MB').",
80
+ },
81
+ },
82
+ },
83
+ UpdateTableRequest: {
84
+ type: "object",
85
+ properties: {
86
+ name: { type: "string", description: "The new name for the table." },
87
+ singleRecordName: {
88
+ type: "string",
89
+ description:
90
+ "The new singular noun for records in the table. Defaults to 'Record' if not provided.",
91
+ },
92
+ pluralRecordName: {
93
+ type: "string",
94
+ description:
95
+ "The new plural noun for records in the table. Defaults to 'Records' if not provided.",
96
+ },
97
+ description: {
98
+ type: "string",
99
+ description:
100
+ "The new description for the table. Defaults to blank if not provided.",
101
+ },
102
+ },
103
+ description:
104
+ "Request body for updating table properties. At least one property must be provided.",
105
+ },
106
+ DeleteTableResponse: {
107
+ type: "object",
108
+ properties: {
109
+ deletedTableId: { type: "string", description: "The deleted table id." },
110
+ },
111
+ },
112
+ };
@@ -3,8 +3,8 @@ import { promises as fs } from "fs";
3
3
  import path from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  import * as glob from "glob";
6
- import { paths } from "./fix-spec-paths.ts";
7
- import { definitions } from "./fix-spec-definitions.ts";
6
+ import { paths } from "./paths/index.ts";
7
+ import { definitions } from "./definitions/index.ts";
8
8
 
9
9
  interface Parameter {
10
10
  name: string;
@@ -166,7 +166,7 @@ async function fixQuickBaseSpec(): Promise<void> {
166
166
  console.log(`Writing fixed spec to ${path.basename(outputFile)}...`);
167
167
  await fs.mkdir(OUTPUT_DIR, { recursive: true });
168
168
  await fs.writeFile(outputFile, JSON.stringify(spec, null, 2), "utf8");
169
- console.log("Spec fixed successfully!");
169
+ console.log("Spec fixed successfully! Output written to:", outputFile);
170
170
  } catch (error) {
171
171
  console.error("Failed to fix spec:", error);
172
172
  process.exit(1);
@@ -1,15 +1,21 @@
1
- // src/code-generation/generate-unified-interface.ts
2
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
3
2
  import { join, dirname } from "path";
4
3
  import { fileURLToPath } from "url";
5
- import { simplifyName } from "../utils.ts";
6
4
  import { OpenAPIV2 } from "openapi-types";
7
5
 
8
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json");
10
- const OUTPUT_DIR = join(__dirname, "..", "generated-unified");
7
+ const SPEC_FILE = join(__dirname, "output", "quickbase-fixed.json"); // Remains relative to open-api/
8
+ const OUTPUT_DIR = join(__dirname, "..", "src", "generated-unified"); // Updated to src/generated-unified/
11
9
  const OUTPUT_FILE = join(OUTPUT_DIR, "QuickbaseClient.ts");
12
10
 
11
+ // Placeholder for simplifyName (since utils.ts is missing)
12
+ function simplifyName(name: string): string {
13
+ return name
14
+ .replace(/ById$/, "")
15
+ .replace(/Api$/, "")
16
+ .replace(/^(\w)/, (_, c) => c.toLowerCase());
17
+ }
18
+
13
19
  function generateInterface() {
14
20
  if (!existsSync(SPEC_FILE)) {
15
21
  console.error(
@@ -38,7 +44,7 @@ function generateInterface() {
38
44
  const op = operation as OpenAPIV2.OperationObject | undefined;
39
45
  if (!op || !op.operationId) continue;
40
46
 
41
- const opId = op.operationId;
47
+ const opId = simplifyName(op.operationId);
42
48
  const params = (op.parameters || [])
43
49
  .filter((p) => {
44
50
  const param = p as OpenAPIV2.ParameterObject;
@@ -96,8 +102,13 @@ function generateInterface() {
96
102
  console.log(`Generated ${OUTPUT_FILE}`);
97
103
  }
98
104
 
99
- function mapOpenApiTypeToTs(openApiType: string): string {
100
- switch (openApiType.toLowerCase()) {
105
+ function mapOpenApiTypeToTs(
106
+ openApiType: string | string[] | undefined
107
+ ): string {
108
+ const type = Array.isArray(openApiType)
109
+ ? openApiType[0]
110
+ : openApiType || "any";
111
+ switch (type.toLowerCase()) {
101
112
  case "integer":
102
113
  case "int":
103
114
  return "number";
@@ -111,30 +122,44 @@ function mapOpenApiTypeToTs(openApiType: string): string {
111
122
  }
112
123
 
113
124
  function mapRefToType(
114
- schema: OpenAPIV2.SchemaObject | OpenAPIV2.ReferenceObject,
125
+ schema: OpenAPIV2.SchemaObject | OpenAPIV2.ReferenceObject | undefined,
115
126
  modelImports: Set<string>
116
127
  ): string {
117
- if ("$ref" in schema) {
128
+ if (!schema) return "any";
129
+
130
+ if ("$ref" in schema && schema.$ref) {
118
131
  const model = schema.$ref.split("/").pop()!;
119
132
  modelImports.add(model);
120
133
  return model;
121
134
  }
135
+
122
136
  if (schema.type === "array" && schema.items) {
123
137
  const itemType =
124
- "$ref" in schema.items
138
+ "$ref" in schema.items && schema.items.$ref
125
139
  ? schema.items.$ref.split("/").pop()!
126
- : mapOpenApiTypeToTs(schema.items.type || "any");
127
- if ("$ref" in schema.items) modelImports.add(itemType);
140
+ : mapOpenApiTypeToTs(schema.items.type);
141
+ if ("$ref" in schema.items && schema.items.$ref) modelImports.add(itemType);
128
142
  return `${itemType}[]`;
129
143
  }
144
+
130
145
  if (schema.type === "object" && schema.additionalProperties) {
131
- const valueType = schema.additionalProperties.$ref
132
- ? schema.additionalProperties.$ref.split("/").pop()!
133
- : mapOpenApiTypeToTs(schema.additionalProperties.type || "any");
134
- if (schema.additionalProperties.$ref) modelImports.add(valueType);
146
+ const additionalProps = schema.additionalProperties as
147
+ | OpenAPIV2.SchemaObject
148
+ | OpenAPIV2.ReferenceObject
149
+ | boolean;
150
+ if (typeof additionalProps === "boolean") {
151
+ return "{ [key: string]: any }";
152
+ }
153
+ const valueType =
154
+ "$ref" in additionalProps && additionalProps.$ref
155
+ ? additionalProps.$ref.split("/").pop()!
156
+ : mapOpenApiTypeToTs(additionalProps.type);
157
+ if ("$ref" in additionalProps && additionalProps.$ref)
158
+ modelImports.add(valueType);
135
159
  return `{ [key: string]: ${valueType} }`;
136
160
  }
137
- return mapOpenApiTypeToTs(schema.type || "any");
161
+
162
+ return mapOpenApiTypeToTs(schema.type);
138
163
  }
139
164
 
140
165
  try {