@lark-apaas/db-schema-sync 0.1.16 → 0.1.17-alpha.20260901040719

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/bin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  __toESM,
7
7
  generateSchema,
8
8
  resolveEnvOptions
9
- } from "./chunk-SSQ5BI45.js";
9
+ } from "./chunk-I47YHGGZ.js";
10
10
 
11
11
  // node_modules/dotenv/package.json
12
12
  var require_package = __commonJS({
@@ -2417,19 +2417,80 @@ function extractTypeAnnotation(comment) {
2417
2417
  const typeStart = comment.indexOf("@type");
2418
2418
  if (typeStart === -1) return null;
2419
2419
  const afterType = comment.slice(typeStart + 5).trimStart();
2420
- if (!afterType.startsWith("{")) return null;
2420
+ if (!afterType) return null;
2421
+ if (afterType.startsWith("{")) {
2422
+ const braceEnd = matchBalanced(afterType, 0, "{", "}");
2423
+ if (braceEnd === -1) return null;
2424
+ return afterType.slice(0, consumeArraySuffixes(afterType, braceEnd)).trimEnd();
2425
+ }
2426
+ const parsedEnd = parseTypeExpression(afterType);
2427
+ if (parsedEnd === -1) return null;
2428
+ const rest = afterType.slice(parsedEnd).replace(/^\s+/, "");
2429
+ if (rest && !rest.startsWith("@") && continuesTypeExpression(rest)) return null;
2430
+ return afterType.slice(0, parsedEnd).trimEnd();
2431
+ }
2432
+ function matchBalanced(source, start, open, close) {
2421
2433
  let depth = 0;
2422
- let endIndex = 0;
2423
- for (let i = 0; i < afterType.length; i++) {
2424
- if (afterType[i] === "{") depth++;
2425
- if (afterType[i] === "}") depth--;
2426
- if (depth === 0) {
2427
- endIndex = i + 1;
2428
- break;
2434
+ for (let i = start; i < source.length; i++) {
2435
+ const quoted = skipStringLiteral(source, i);
2436
+ if (quoted !== -1) {
2437
+ i = quoted - 1;
2438
+ continue;
2439
+ }
2440
+ if (source[i] === open) depth++;
2441
+ else if (source[i] === close) {
2442
+ depth--;
2443
+ if (depth === 0) return i + 1;
2444
+ }
2445
+ }
2446
+ return -1;
2447
+ }
2448
+ function skipStringLiteral(source, i) {
2449
+ const quote = source[i];
2450
+ if (quote !== "'" && quote !== '"' && quote !== "`") return -1;
2451
+ for (let j = i + 1; j < source.length; j++) {
2452
+ if (source[j] === "\\") {
2453
+ j++;
2454
+ continue;
2429
2455
  }
2456
+ if (source[j] === quote) return j + 1;
2430
2457
  }
2431
- if (endIndex === 0) return null;
2432
- return afterType.slice(0, endIndex);
2458
+ return -1;
2459
+ }
2460
+ function consumeArraySuffixes(source, end) {
2461
+ let i = end;
2462
+ for (; ; ) {
2463
+ const suffix = /^\s*\[\s*\]/.exec(source.slice(i));
2464
+ if (!suffix) return i;
2465
+ i += suffix[0].length;
2466
+ }
2467
+ }
2468
+ function parseTypeExpression(source) {
2469
+ let i = parseTypeAtom(source, 0);
2470
+ if (i === -1) return -1;
2471
+ for (; ; ) {
2472
+ const union = /^\s*\|\s*/.exec(source.slice(i));
2473
+ if (!union) return i;
2474
+ const next = parseTypeAtom(source, i + union[0].length);
2475
+ if (next === -1) return i;
2476
+ i = next;
2477
+ }
2478
+ }
2479
+ function parseTypeAtom(source, start) {
2480
+ const quoted = skipStringLiteral(source, start);
2481
+ if (quoted !== -1) return consumeArraySuffixes(source, quoted);
2482
+ const identifier = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*/.exec(source.slice(start));
2483
+ if (!identifier) return -1;
2484
+ let i = start + identifier[0].length;
2485
+ if (source[i] === "<") {
2486
+ const generic = matchBalanced(source, i, "<", ">");
2487
+ if (generic === -1) return i;
2488
+ i = generic;
2489
+ }
2490
+ return consumeArraySuffixes(source, i);
2491
+ }
2492
+ function continuesTypeExpression(rest) {
2493
+ return /^(?:[|&<>[\].,()?:=]|extends\b|keyof\b|typeof\b|infer\b)/.test(rest);
2433
2494
  }
2434
2495
  function parseColumnComment(comment) {
2435
2496
  const typeValue = extractTypeAnnotation(comment);
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  generateSchemaFromData,
6
6
  normalizeApiResponse,
7
7
  resolveEnvOptions
8
- } from "./chunk-SSQ5BI45.js";
8
+ } from "./chunk-I47YHGGZ.js";
9
9
  export {
10
10
  generateSchema,
11
11
  generateSchemaCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/db-schema-sync",
3
- "version": "0.1.16",
3
+ "version": "0.1.17-alpha.20260901040719",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",