@bagelink/sdk 1.4.14 → 1.4.18

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/dist/index.cjs CHANGED
@@ -43,8 +43,11 @@ function schemaToType(schema) {
43
43
  return "number";
44
44
  case "boolean":
45
45
  return "boolean";
46
- case "array":
47
- return `${schemaToType(schema.items)}[]`;
46
+ case "array": {
47
+ const itemType = schemaToType(schema.items);
48
+ const needsParentheses = itemType.includes("|") || itemType.includes("&");
49
+ return needsParentheses ? `(${itemType})[]` : `${itemType}[]`;
50
+ }
48
51
  case "undefined":
49
52
  return "undefined";
50
53
  case "null":
@@ -414,7 +417,7 @@ function generateTypes(schemas) {
414
417
  `;
415
418
  }
416
419
  if (schema.type === "array" && schema.items) {
417
- return `export type ${typeName} = ${schemaToType(schema.items)}[];
420
+ return `export type ${typeName} = (${schemaToType(schema.items)})[];
418
421
  `;
419
422
  }
420
423
  if (!schema.properties) {
package/dist/index.mjs CHANGED
@@ -37,8 +37,11 @@ function schemaToType(schema) {
37
37
  return "number";
38
38
  case "boolean":
39
39
  return "boolean";
40
- case "array":
41
- return `${schemaToType(schema.items)}[]`;
40
+ case "array": {
41
+ const itemType = schemaToType(schema.items);
42
+ const needsParentheses = itemType.includes("|") || itemType.includes("&");
43
+ return needsParentheses ? `(${itemType})[]` : `${itemType}[]`;
44
+ }
42
45
  case "undefined":
43
46
  return "undefined";
44
47
  case "null":
@@ -408,7 +411,7 @@ function generateTypes(schemas) {
408
411
  `;
409
412
  }
410
413
  if (schema.type === "array" && schema.items) {
411
- return `export type ${typeName} = ${schemaToType(schema.items)}[];
414
+ return `export type ${typeName} = (${schemaToType(schema.items)})[];
412
415
  `;
413
416
  }
414
417
  if (!schema.properties) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/sdk",
3
3
  "type": "module",
4
- "version": "1.4.14",
4
+ "version": "1.4.18",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -11,7 +11,7 @@ export function generateTypes(schemas: SchemasObject): string {
11
11
  }
12
12
 
13
13
  if (schema.type === 'array' && schema.items) {
14
- return `export type ${typeName} = ${schemaToType(schema.items)}[];\n`
14
+ return `export type ${typeName} = (${schemaToType(schema.items)})[];\n`
15
15
  }
16
16
 
17
17
  // if (typeName === 'LocalizedJsonInt') {
@@ -57,8 +57,14 @@ export function schemaToType(schema?: SchemaObject): string {
57
57
  return 'number'
58
58
  case 'boolean':
59
59
  return 'boolean'
60
- case 'array':
61
- return `${schemaToType(schema.items)}[]`
60
+ case 'array': {
61
+ // Handle array items that might be union types
62
+ const itemType = schemaToType(schema.items)
63
+
64
+ // Add parentheses around union types to ensure correct syntax
65
+ const needsParentheses = itemType.includes('|') || itemType.includes('&')
66
+ return needsParentheses ? `(${itemType})[]` : `${itemType}[]`
67
+ }
62
68
  case 'undefined':
63
69
  return 'undefined'
64
70
  case 'null':