apify-schema-tools 2.0.4 → 2.1.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.
Files changed (54) hide show
  1. package/.cspell/custom-dictionary.txt +1 -0
  2. package/.husky/pre-commit +0 -8
  3. package/CHANGELOG.md +21 -0
  4. package/README.md +109 -45
  5. package/biome.json +121 -9
  6. package/dist/apify-schema-tools.d.ts +1 -0
  7. package/dist/apify-schema-tools.d.ts.map +1 -1
  8. package/dist/apify-schema-tools.js +133 -106
  9. package/dist/apify-schema-tools.js.map +1 -1
  10. package/dist/apify.d.ts +1 -1
  11. package/dist/apify.d.ts.map +1 -1
  12. package/dist/apify.js +4 -2
  13. package/dist/apify.js.map +1 -1
  14. package/dist/configuration.d.ts +17 -16
  15. package/dist/configuration.d.ts.map +1 -1
  16. package/dist/configuration.js +8 -1
  17. package/dist/configuration.js.map +1 -1
  18. package/dist/json-schemas.d.ts.map +1 -1
  19. package/dist/json-schemas.js +31 -21
  20. package/dist/json-schemas.js.map +1 -1
  21. package/dist/typescript.d.ts +1 -0
  22. package/dist/typescript.d.ts.map +1 -1
  23. package/dist/typescript.js +294 -194
  24. package/dist/typescript.js.map +1 -1
  25. package/package.json +16 -5
  26. package/samples/all-defaults/src/generated/dataset.ts +1 -0
  27. package/samples/all-defaults/src/generated/input-utils.ts +5 -1
  28. package/samples/all-defaults/src/generated/input.ts +2 -0
  29. package/samples/all-defaults/src-schemas/input.json +6 -3
  30. package/samples/deep-merged-schemas/src/generated/dataset.ts +1 -0
  31. package/samples/deep-merged-schemas/src/generated/input-utils.ts +5 -1
  32. package/samples/deep-merged-schemas/src/generated/input.ts +2 -0
  33. package/samples/deep-merged-schemas/src-schemas/input.json +6 -3
  34. package/samples/merged-schemas/src/generated/dataset.ts +1 -0
  35. package/samples/merged-schemas/src/generated/input-utils.ts +5 -1
  36. package/samples/merged-schemas/src/generated/input.ts +3 -0
  37. package/samples/merged-schemas/src-schemas/input.json +6 -3
  38. package/samples/package-json-config/custom-src-schemas/input.json +6 -3
  39. package/samples/package-json-config/package.json +8 -2
  40. package/samples/package-json-config/src/custom-generated/dataset.ts +1 -0
  41. package/samples/package-json-config/src/custom-generated/input-utils.ts +5 -1
  42. package/samples/package-json-config/src/custom-generated/input.ts +2 -0
  43. package/src/apify-schema-tools.ts +179 -150
  44. package/src/apify.ts +6 -4
  45. package/src/configuration.ts +14 -5
  46. package/src/json-schemas.ts +44 -22
  47. package/src/typescript.ts +370 -207
  48. package/test/apify-schema-tools.test.ts +122 -124
  49. package/test/apify.test.ts +8 -6
  50. package/test/common.ts +2 -2
  51. package/test/configuration.test.ts +1 -1
  52. package/test/json-schemas.test.ts +56 -40
  53. package/test/typescript.test.ts +181 -31
  54. package/tsconfig.json +1 -1
@@ -1,10 +1,10 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import { generateInputDefaultsTSFileContent } from "../src/apify.js";
4
- import type { ObjectSchema } from "../src/json-schemas";
3
+ import { generateInputDefaultsTsFileContent } from "../src/apify.js";
4
+ import type { ObjectSchema } from "../src/json-schemas.js";
5
5
 
6
6
  describe("Apify utilities", () => {
7
- describe("generateInputDefaultsTSFileContent", () => {
7
+ describe("generateInputDefaultsTsFileContent", () => {
8
8
  it("should generate the correct content with default values", async () => {
9
9
  const inputSchema: ObjectSchema = {
10
10
  type: "object",
@@ -16,7 +16,7 @@ describe("Apify utilities", () => {
16
16
  required: ["name"],
17
17
  };
18
18
 
19
- const tsContent = generateInputDefaultsTSFileContent(inputSchema);
19
+ const tsContent = generateInputDefaultsTsFileContent(inputSchema);
20
20
 
21
21
  expect(tsContent).toEqual(
22
22
  `import { Actor } from "apify";
@@ -61,7 +61,7 @@ export function getInputWithDefaultValues(input?: Input | null): InputWithDefaul
61
61
  required: ["name"],
62
62
  };
63
63
 
64
- const tsContent = generateInputDefaultsTSFileContent(inputSchema);
64
+ const tsContent = generateInputDefaultsTsFileContent(inputSchema);
65
65
 
66
66
  expect(tsContent).toEqual(
67
67
  `import { Actor } from "apify";
@@ -81,7 +81,9 @@ export function getInputWithDefaultValues(input?: Input | null): InputWithDefaul
81
81
  return input as InputWithDefaults;
82
82
  }
83
83
  if (!input) {
84
- throw new Error(\`Input is required, because the following fields are required: $\{REQUIRED_INPUT_FIELDS_WITHOUT_DEFAULT.join(", ")\}\`);
84
+ throw new Error(\`Input is required, because the following fields are required: $\{
85
+ REQUIRED_INPUT_FIELDS_WITHOUT_DEFAULT.join(", ")
86
+ \}\`);
85
87
  }
86
88
  return input ?? {} as Input;
87
89
  }
package/test/common.ts CHANGED
@@ -5,14 +5,14 @@ export function getTestDir(suffix: string): string {
5
5
  return join(__dirname, `test-temp-${suffix}`);
6
6
  }
7
7
 
8
- export function setupTestDirectory(dirPath: string) {
8
+ export function setupTestDirectory(dirPath: string): void {
9
9
  // Create directory if it doesn't exist, do nothing if it already exists
10
10
  if (!existsSync(dirPath)) {
11
11
  mkdirSync(dirPath, { recursive: true });
12
12
  }
13
13
  }
14
14
 
15
- export function cleanupTestDirectory(dirPath: string) {
15
+ export function cleanupTestDirectory(dirPath: string): void {
16
16
  if (existsSync(dirPath)) {
17
17
  rmSync(dirPath, { recursive: true, force: true });
18
18
  }
@@ -2,9 +2,9 @@ import { existsSync } from "node:fs";
2
2
  import type { ArgumentParser } from "argparse";
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
4
  import {
5
+ addCommonCLIArgs,
5
6
  type CommonCLIArgs,
6
7
  Configuration,
7
- addCommonCLIArgs,
8
8
  parseConfigurationFromFileOrDefault,
9
9
  writeConfigurationToPackageJson,
10
10
  } from "../src/configuration.js";
@@ -1,14 +1,13 @@
1
- import { existsSync, mkdirSync, rmSync } from "node:fs";
2
1
  import { join } from "node:path";
3
2
  import { afterEach, describe, expect, it } from "vitest";
4
3
 
5
4
  import { writeFile } from "../src/filesystem.js";
6
5
  import {
7
- type ObjectSchema,
8
6
  compareDescriptions,
9
7
  compareSchemas,
10
8
  filterValidSchemaProperties,
11
9
  mergeObjectSchemas,
10
+ type ObjectSchema,
12
11
  readJsonSchema,
13
12
  readJsonSchemaField,
14
13
  writeSchemaToField,
@@ -29,7 +28,7 @@ describe("JSON schemas utilities", () => {
29
28
  const wrapperSchema = {
30
29
  type: "object",
31
30
  title: "Wrapper Schema",
32
- inputSchema: {
31
+ field1: {
33
32
  type: "object",
34
33
  properties: {
35
34
  name: { type: "string" },
@@ -37,7 +36,7 @@ describe("JSON schemas utilities", () => {
37
36
  },
38
37
  required: ["name"],
39
38
  },
40
- outputSchema: {
39
+ field2: {
41
40
  type: "object",
42
41
  properties: {
43
42
  result: { type: "string" },
@@ -47,9 +46,9 @@ describe("JSON schemas utilities", () => {
47
46
 
48
47
  writeFile(filePath, JSON.stringify(wrapperSchema));
49
48
 
50
- const inputSchema = readJsonSchemaField(filePath, "inputSchema");
49
+ const field1Schema = readJsonSchemaField(filePath, "field1");
51
50
 
52
- expect(inputSchema).toEqual({
51
+ expect(field1Schema).toEqual({
53
52
  type: "object",
54
53
  properties: {
55
54
  name: { type: "string" },
@@ -59,40 +58,6 @@ describe("JSON schemas utilities", () => {
59
58
  });
60
59
  });
61
60
 
62
- it("should read another field from the same schema file", () => {
63
- setupTestDirectory(TEST_DIR);
64
- const filePath = join(TEST_DIR, "wrapper-schema.json");
65
- const wrapperSchema = {
66
- type: "object",
67
- title: "Wrapper Schema",
68
- inputSchema: {
69
- type: "object",
70
- properties: {
71
- name: { type: "string" },
72
- age: { type: "number" },
73
- },
74
- required: ["name"],
75
- },
76
- outputSchema: {
77
- type: "object",
78
- properties: {
79
- result: { type: "string" },
80
- },
81
- },
82
- };
83
-
84
- writeFile(filePath, JSON.stringify(wrapperSchema));
85
-
86
- const outputSchema = readJsonSchemaField(filePath, "outputSchema");
87
-
88
- expect(outputSchema).toEqual({
89
- type: "object",
90
- properties: {
91
- result: { type: "string" },
92
- },
93
- });
94
- });
95
-
96
61
  it("should throw error when field does not exist", () => {
97
62
  setupTestDirectory(TEST_DIR);
98
63
  const filePath = join(TEST_DIR, "schema-without-field.json");
@@ -369,6 +334,7 @@ describe("JSON schemas utilities", () => {
369
334
  name: { type: "string" },
370
335
  phone: { type: "integer" },
371
336
  },
337
+ additionalProperties: true,
372
338
  };
373
339
 
374
340
  const additionalSchema: ObjectSchema = {
@@ -390,6 +356,7 @@ describe("JSON schemas utilities", () => {
390
356
  phone: { type: "string" }, // phone type changed to string
391
357
  address: { type: "string" },
392
358
  },
359
+ additionalProperties: true,
393
360
  });
394
361
  });
395
362
 
@@ -443,6 +410,35 @@ describe("JSON schemas utilities", () => {
443
410
  },
444
411
  });
445
412
  });
413
+
414
+ it("should override the additionalProperties setting", () => {
415
+ const baseSchema: ObjectSchema = {
416
+ type: "object",
417
+ properties: {
418
+ name: { type: "string" },
419
+ },
420
+ additionalProperties: true,
421
+ };
422
+
423
+ const additionalSchema: ObjectSchema = {
424
+ type: "object",
425
+ properties: {
426
+ age: { type: "number" },
427
+ },
428
+ additionalProperties: false, // this should override the base schema
429
+ };
430
+
431
+ const mergedSchema = mergeObjectSchemas(baseSchema, additionalSchema);
432
+
433
+ expect(mergedSchema).toEqual({
434
+ type: "object",
435
+ properties: {
436
+ name: { type: "string" },
437
+ age: { type: "number" },
438
+ },
439
+ additionalProperties: false, // additionalProperties is false now
440
+ });
441
+ });
446
442
  });
447
443
 
448
444
  describe("compareJsonSchemas", () => {
@@ -486,6 +482,26 @@ describe("JSON schemas utilities", () => {
486
482
  expect(compareSchemas(schema1, schema2)).toBe(false);
487
483
  });
488
484
 
485
+ it("returns false for schemas with different additionalProperties settings", () => {
486
+ const schema1: ObjectSchema = {
487
+ type: "object",
488
+ properties: {
489
+ name: { type: "string" },
490
+ },
491
+ additionalProperties: true,
492
+ };
493
+
494
+ const schema2: ObjectSchema = {
495
+ type: "object",
496
+ properties: {
497
+ name: { type: "string" },
498
+ },
499
+ additionalProperties: false, // different additionalProperties setting
500
+ };
501
+
502
+ expect(compareSchemas(schema1, schema2)).toBe(false);
503
+ });
504
+
489
505
  it("returns true for schemas with different descriptions, if ignoreDescriptions is true", () => {
490
506
  const schema1: ObjectSchema = {
491
507
  type: "object",
@@ -1,18 +1,17 @@
1
- import { afterEach, describe, expect, it } from "vitest";
2
-
3
- import { cleanupTestDirectory, getTestDir, setupTestDirectory } from "./common";
4
-
5
1
  import path from "node:path";
2
+ import { afterEach, describe, expect, it } from "vitest";
6
3
  import { readFile } from "../src/filesystem.js";
7
- import type { ObjectSchema } from "../src/json-schemas";
4
+ import type { ObjectSchema } from "../src/json-schemas.js";
8
5
  import {
9
6
  compareTypescriptInterfaces,
10
7
  jsonSchemaToTypeScriptInterface,
11
8
  parseTypeScriptInterface,
12
9
  readGeneratedTypeScriptFile,
13
10
  serializeTypeScriptInterface,
11
+ type TypeScriptInterface,
14
12
  writeTypeScriptFile,
15
13
  } from "../src/typescript.js";
14
+ import { cleanupTestDirectory, getTestDir, setupTestDirectory } from "./common.js";
16
15
 
17
16
  const TEST_DIR = getTestDir("typescript");
18
17
 
@@ -60,6 +59,22 @@ describe("TypeScript files utilities", () => {
60
59
  },
61
60
  },
62
61
  required: ["name"],
62
+ additionalProperties: {
63
+ type: "array",
64
+ items: {
65
+ type: "object",
66
+ properties: {
67
+ key: {
68
+ type: "string",
69
+ },
70
+ value: {
71
+ type: "number",
72
+ },
73
+ },
74
+ required: ["key", "value"],
75
+ additionalProperties: false,
76
+ },
77
+ },
63
78
  },
64
79
  },
65
80
  features: {
@@ -109,6 +124,25 @@ describe("TypeScript files utilities", () => {
109
124
  type: ["number", "string"],
110
125
  },
111
126
  },
127
+ additionalProperties: {
128
+ doc: undefined,
129
+ isRequired: true,
130
+ isArray: true,
131
+ properties: {
132
+ key: {
133
+ doc: undefined,
134
+ isRequired: true,
135
+ isArray: false,
136
+ type: "string",
137
+ },
138
+ value: {
139
+ doc: undefined,
140
+ isRequired: true,
141
+ isArray: false,
142
+ type: "number",
143
+ },
144
+ },
145
+ },
112
146
  },
113
147
  features: {
114
148
  doc: undefined,
@@ -123,6 +157,12 @@ describe("TypeScript files utilities", () => {
123
157
  type: ["boolean", "null"],
124
158
  },
125
159
  },
160
+ additionalProperties: {
161
+ doc: undefined,
162
+ isRequired: true,
163
+ isArray: false,
164
+ type: "unknown",
165
+ },
126
166
  });
127
167
  });
128
168
  });
@@ -158,6 +198,12 @@ describe("TypeScript files utilities", () => {
158
198
  type: ["number", "string"],
159
199
  },
160
200
  },
201
+ additionalProperties: {
202
+ doc: undefined,
203
+ isRequired: true,
204
+ isArray: false,
205
+ type: "boolean",
206
+ },
161
207
  },
162
208
  features: {
163
209
  doc: undefined,
@@ -187,12 +233,60 @@ export interface Shape {
187
233
  * The hex color value
188
234
  */
189
235
  value?: number | string;
236
+ [key: string]: boolean;
190
237
  }[];
191
238
  features: ("dotted" | "striped" | "solid")[];
192
239
  /**
193
240
  * Whether the shape is nice
194
241
  */
195
242
  isNice: boolean | null;
243
+ }`);
244
+ });
245
+
246
+ it("should serialize complex additionalProperties", () => {
247
+ const tsSchema: TypeScriptInterface = {
248
+ doc: "Test schema with additional properties",
249
+ isRequired: true,
250
+ isArray: false,
251
+ properties: {
252
+ name: {
253
+ doc: undefined,
254
+ isRequired: true,
255
+ isArray: false,
256
+ type: "string",
257
+ },
258
+ },
259
+ additionalProperties: {
260
+ doc: "Additional properties of any type",
261
+ isRequired: true,
262
+ isArray: true,
263
+ properties: {
264
+ key: {
265
+ doc: undefined,
266
+ isRequired: true,
267
+ isArray: false,
268
+ type: "string",
269
+ },
270
+ value: {
271
+ doc: undefined,
272
+ isRequired: true,
273
+ isArray: false,
274
+ type: "number",
275
+ },
276
+ },
277
+ },
278
+ };
279
+
280
+ expect(serializeTypeScriptInterface("Shape", tsSchema)).toBe(`\
281
+ /**
282
+ * Test schema with additional properties
283
+ */
284
+ export interface Shape {
285
+ name: string;
286
+ [key: string]: {
287
+ key: string;
288
+ value: number;
289
+ }[];
196
290
  }`);
197
291
  });
198
292
  });
@@ -211,6 +305,10 @@ export interface Shape {
211
305
  * The hex color value
212
306
  */
213
307
  value?: number | string;
308
+ [key: string]: {
309
+ key: string;
310
+ value: number;
311
+ }[];
214
312
  }[];
215
313
  features: ("dotted" | "striped" | "solid")[];
216
314
  /**
@@ -248,6 +346,26 @@ export interface Shape {
248
346
  type: ["number", "string"],
249
347
  },
250
348
  },
349
+ additionalProperties: {
350
+ doc: undefined,
351
+ isRequired: true,
352
+ isArray: true,
353
+ properties: {
354
+ key: {
355
+ doc: undefined,
356
+ isRequired: true,
357
+ isArray: false,
358
+ type: "string",
359
+ },
360
+ value: {
361
+ doc: undefined,
362
+ isRequired: true,
363
+ isArray: false,
364
+ type: "number",
365
+ },
366
+ },
367
+ additionalProperties: undefined,
368
+ },
251
369
  },
252
370
  features: {
253
371
  doc: undefined,
@@ -262,12 +380,13 @@ export interface Shape {
262
380
  type: ["boolean", "null"],
263
381
  },
264
382
  },
383
+ additionalProperties: undefined,
265
384
  });
266
385
  });
267
386
  });
268
387
 
269
388
  describe("compareTypescriptInterfaces", () => {
270
- const baseInterface = {
389
+ const baseInterface: TypeScriptInterface = {
271
390
  doc: "Base interface",
272
391
  isRequired: true,
273
392
  isArray: false,
@@ -288,7 +407,7 @@ export interface Shape {
288
407
  };
289
408
 
290
409
  it("should return true for identical interfaces", () => {
291
- const interfaceA = {
410
+ const interfaceA: TypeScriptInterface = {
292
411
  doc: "Test interface",
293
412
  isRequired: true,
294
413
  isArray: false,
@@ -307,7 +426,7 @@ export interface Shape {
307
426
  },
308
427
  },
309
428
  };
310
- const interfaceB = {
429
+ const interfaceB: TypeScriptInterface = {
311
430
  doc: "Test interface",
312
431
  isRequired: true,
313
432
  isArray: false,
@@ -332,7 +451,7 @@ export interface Shape {
332
451
 
333
452
  it("should return false for interfaces with different number of properties", () => {
334
453
  const interfaceA = baseInterface;
335
- const interfaceB = {
454
+ const interfaceB: TypeScriptInterface = {
336
455
  doc: "Test interface",
337
456
  isRequired: true,
338
457
  isArray: false,
@@ -363,7 +482,7 @@ export interface Shape {
363
482
 
364
483
  it("should return false for interfaces with different property names", () => {
365
484
  const interfaceA = baseInterface;
366
- const interfaceB = {
485
+ const interfaceB: TypeScriptInterface = {
367
486
  doc: "Test interface",
368
487
  isRequired: true,
369
488
  isArray: false,
@@ -386,9 +505,40 @@ export interface Shape {
386
505
  expect(compareTypescriptInterfaces(interfaceA, interfaceB)).toBe(false);
387
506
  });
388
507
 
508
+ it("should return false for interfaces with different additionalProperties", () => {
509
+ const interfaceA = baseInterface;
510
+ const interfaceB: TypeScriptInterface = {
511
+ doc: "Test interface",
512
+ isRequired: true,
513
+ isArray: false,
514
+ properties: {
515
+ name: {
516
+ doc: "User name",
517
+ isRequired: true,
518
+ isArray: false,
519
+ type: "string",
520
+ },
521
+ age: {
522
+ doc: undefined,
523
+ isRequired: false,
524
+ isArray: false,
525
+ type: "number",
526
+ },
527
+ },
528
+ additionalProperties: {
529
+ doc: "Additional properties",
530
+ isRequired: true,
531
+ isArray: false,
532
+ type: "boolean",
533
+ },
534
+ };
535
+
536
+ expect(compareTypescriptInterfaces(interfaceA, interfaceB)).toBe(false);
537
+ });
538
+
389
539
  it("should return false for properties with different types", () => {
390
540
  const interfaceA = baseInterface;
391
- const interfaceB = {
541
+ const interfaceB: TypeScriptInterface = {
392
542
  doc: "Test interface",
393
543
  isRequired: true,
394
544
  isArray: false,
@@ -413,7 +563,7 @@ export interface Shape {
413
563
 
414
564
  it("should return false for properties with different isRequired values", () => {
415
565
  const interfaceA = baseInterface;
416
- const interfaceB = {
566
+ const interfaceB: TypeScriptInterface = {
417
567
  doc: "Test interface",
418
568
  isRequired: true,
419
569
  isArray: false,
@@ -438,7 +588,7 @@ export interface Shape {
438
588
 
439
589
  it("should return false for properties with different isArray values", () => {
440
590
  const interfaceA = baseInterface;
441
- const interfaceB = {
591
+ const interfaceB: TypeScriptInterface = {
442
592
  doc: "Test interface",
443
593
  isRequired: true,
444
594
  isArray: false,
@@ -463,7 +613,7 @@ export interface Shape {
463
613
 
464
614
  it("should return false for properties with different documentation when ignoreDocs is false", () => {
465
615
  const interfaceA = baseInterface;
466
- const interfaceB = {
616
+ const interfaceB: TypeScriptInterface = {
467
617
  doc: "Test interface",
468
618
  isRequired: true,
469
619
  isArray: false,
@@ -489,7 +639,7 @@ export interface Shape {
489
639
 
490
640
  it("should return true for properties with different documentation when ignoreDocs is true", () => {
491
641
  const interfaceA = baseInterface;
492
- const interfaceB = {
642
+ const interfaceB: TypeScriptInterface = {
493
643
  doc: "Test interface",
494
644
  isRequired: true,
495
645
  isArray: false,
@@ -513,7 +663,7 @@ export interface Shape {
513
663
  });
514
664
 
515
665
  it("should handle enum properties correctly", () => {
516
- const interfaceA = {
666
+ const interfaceA: TypeScriptInterface = {
517
667
  doc: undefined,
518
668
  isRequired: true,
519
669
  isArray: false,
@@ -526,7 +676,7 @@ export interface Shape {
526
676
  },
527
677
  },
528
678
  };
529
- const interfaceB = {
679
+ const interfaceB: TypeScriptInterface = {
530
680
  doc: undefined,
531
681
  isRequired: true,
532
682
  isArray: false,
@@ -544,7 +694,7 @@ export interface Shape {
544
694
  });
545
695
 
546
696
  it("should return false for enum properties with different values", () => {
547
- const interfaceA = {
697
+ const interfaceA: TypeScriptInterface = {
548
698
  doc: undefined,
549
699
  isRequired: true,
550
700
  isArray: false,
@@ -557,7 +707,7 @@ export interface Shape {
557
707
  },
558
708
  },
559
709
  };
560
- const interfaceB = {
710
+ const interfaceB: TypeScriptInterface = {
561
711
  doc: undefined,
562
712
  isRequired: true,
563
713
  isArray: false,
@@ -575,7 +725,7 @@ export interface Shape {
575
725
  });
576
726
 
577
727
  it("should handle nested interface properties correctly", () => {
578
- const interfaceA = {
728
+ const interfaceA: TypeScriptInterface = {
579
729
  doc: undefined,
580
730
  isRequired: true,
581
731
  isArray: false,
@@ -601,7 +751,7 @@ export interface Shape {
601
751
  },
602
752
  },
603
753
  };
604
- const interfaceB = {
754
+ const interfaceB: TypeScriptInterface = {
605
755
  doc: undefined,
606
756
  isRequired: true,
607
757
  isArray: false,
@@ -632,7 +782,7 @@ export interface Shape {
632
782
  });
633
783
 
634
784
  it("should return false for nested interfaces with different structures", () => {
635
- const interfaceA = {
785
+ const interfaceA: TypeScriptInterface = {
636
786
  doc: undefined,
637
787
  isRequired: true,
638
788
  isArray: false,
@@ -658,7 +808,7 @@ export interface Shape {
658
808
  },
659
809
  },
660
810
  };
661
- const interfaceB = {
811
+ const interfaceB: TypeScriptInterface = {
662
812
  doc: undefined,
663
813
  isRequired: true,
664
814
  isArray: false,
@@ -684,7 +834,7 @@ export interface Shape {
684
834
  });
685
835
 
686
836
  it("should handle union types correctly", () => {
687
- const interfaceA = {
837
+ const interfaceA: TypeScriptInterface = {
688
838
  doc: undefined,
689
839
  isRequired: true,
690
840
  isArray: false,
@@ -697,7 +847,7 @@ export interface Shape {
697
847
  },
698
848
  },
699
849
  };
700
- const interfaceB = {
850
+ const interfaceB: TypeScriptInterface = {
701
851
  doc: undefined,
702
852
  isRequired: true,
703
853
  isArray: false,
@@ -715,7 +865,7 @@ export interface Shape {
715
865
  });
716
866
 
717
867
  it("should return false for union types with different order", () => {
718
- const interfaceA = {
868
+ const interfaceA: TypeScriptInterface = {
719
869
  doc: undefined,
720
870
  isRequired: true,
721
871
  isArray: false,
@@ -728,7 +878,7 @@ export interface Shape {
728
878
  },
729
879
  },
730
880
  };
731
- const interfaceB = {
881
+ const interfaceB: TypeScriptInterface = {
732
882
  doc: undefined,
733
883
  isRequired: true,
734
884
  isArray: false,
@@ -746,7 +896,7 @@ export interface Shape {
746
896
  });
747
897
 
748
898
  it("should return false when comparing interface property to basic type property", () => {
749
- const interfaceA = {
899
+ const interfaceA: TypeScriptInterface = {
750
900
  doc: undefined,
751
901
  isRequired: true,
752
902
  isArray: false,
@@ -766,7 +916,7 @@ export interface Shape {
766
916
  },
767
917
  },
768
918
  };
769
- const interfaceB = {
919
+ const interfaceB: TypeScriptInterface = {
770
920
  doc: undefined,
771
921
  isRequired: true,
772
922
  isArray: false,
@@ -784,7 +934,7 @@ export interface Shape {
784
934
  });
785
935
 
786
936
  it("should return false when comparing enum property to basic type property", () => {
787
- const interfaceA = {
937
+ const interfaceA: TypeScriptInterface = {
788
938
  doc: undefined,
789
939
  isRequired: true,
790
940
  isArray: false,
@@ -797,7 +947,7 @@ export interface Shape {
797
947
  },
798
948
  },
799
949
  };
800
- const interfaceB = {
950
+ const interfaceB: TypeScriptInterface = {
801
951
  doc: undefined,
802
952
  isRequired: true,
803
953
  isArray: false,
package/tsconfig.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "outDir": "dist",
8
8
  "noUnusedLocals": false,
9
9
  "skipLibCheck": true,
10
- "lib": ["DOM"],
10
+ "lib": ["DOM", "ES2022"],
11
11
  "baseUrl": ".",
12
12
  "paths": {
13
13
  "apify-schema-tools": ["src"]