@mintlify/cli 4.0.1773 → 4.0.1775

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.
@@ -6104,6 +6104,12 @@ var DATABASE_ATTRS = [
6104
6104
  type: "string",
6105
6105
  placeholder: "Status",
6106
6106
  description: "Property name to group rows by."
6107
+ },
6108
+ {
6109
+ name: "sql",
6110
+ type: "string",
6111
+ placeholder: "SELECT * FROM roadmap LIMIT 50",
6112
+ description: "A read-only SQL query. When set, the block shows its results instead of the view."
6107
6113
  }
6108
6114
  ];
6109
6115
  var UPDATE_ATTRS = [
@@ -6579,6 +6585,64 @@ var isDatabaseId = (value) => typeof value === "string" && DATABASE_ID_PATTERN.t
6579
6585
  var isDatabaseView = (value) => DATABASE_VIEW_OPTIONS.some((view) => view === value);
6580
6586
  var resolveDatabaseView = (value) => isDatabaseView(value) ? value : DEFAULT_DATABASE_VIEW;
6581
6587
 
6588
+ // ../editor/dist/converter/utils/database-sql.js
6589
+ var DATABASE_SQL_ATTR = "sql";
6590
+ var INVALID_DATABASE_SQL = Symbol("invalid-database-sql");
6591
+ var QUOTED_UNSAFE = /&(?=#?[A-Za-z0-9]+;)|<(?=[A-Za-z/!?])|[`~\0\r\n]/;
6592
+ var TEMPLATE_UNSAFE = /[\\`~\0\r\n]|\$\{|<(?=!|\/|MDX)/g;
6593
+ var TEMPLATE_ESCAPES = {
6594
+ "\\": "\\\\",
6595
+ "`": "\\`",
6596
+ "~": "\\x7E",
6597
+ "\0": "\\x00",
6598
+ "\r": "\\r",
6599
+ "\n": "\\n",
6600
+ "${": "\\${",
6601
+ "<": "\\x3C"
6602
+ };
6603
+ var serializeDatabaseSql = (sql) => {
6604
+ if (!QUOTED_UNSAFE.test(sql)) {
6605
+ if (!sql.includes('"'))
6606
+ return `${DATABASE_SQL_ATTR}="${sql}"`;
6607
+ if (!sql.includes("'"))
6608
+ return `${DATABASE_SQL_ATTR}='${sql}'`;
6609
+ }
6610
+ const body = sql.replace(TEMPLATE_UNSAFE, (match) => {
6611
+ var _a;
6612
+ return (_a = TEMPLATE_ESCAPES[match]) !== null && _a !== void 0 ? _a : match;
6613
+ });
6614
+ return `${DATABASE_SQL_ATTR}={\`${body}\`}`;
6615
+ };
6616
+ var isSqlAttribute = (attribute) => attribute.type === "mdxJsxAttribute" && attribute.name === DATABASE_SQL_ATTR;
6617
+ var attributeString = (attribute) => {
6618
+ var _a, _b, _c;
6619
+ var _d;
6620
+ const { value } = attribute;
6621
+ if (typeof value === "string")
6622
+ return value;
6623
+ const statement = (_b = (_a = value === null || value === void 0 ? void 0 : value.data) === null || _a === void 0 ? void 0 : _a.estree) === null || _b === void 0 ? void 0 : _b.body[0];
6624
+ if ((statement === null || statement === void 0 ? void 0 : statement.type) !== "ExpressionStatement")
6625
+ return null;
6626
+ const { expression } = statement;
6627
+ if (expression.type === "Literal") {
6628
+ return typeof expression.value === "string" ? expression.value : null;
6629
+ }
6630
+ if (expression.type !== "TemplateLiteral" || expression.expressions.length > 0)
6631
+ return null;
6632
+ return (_d = (_c = expression.quasis[0]) === null || _c === void 0 ? void 0 : _c.value.cooked) !== null && _d !== void 0 ? _d : null;
6633
+ };
6634
+ var readDatabaseSql = (attributes) => {
6635
+ var _a;
6636
+ const matches = attributes.filter(isSqlAttribute);
6637
+ const [attribute] = matches;
6638
+ if (!attribute)
6639
+ return null;
6640
+ if (matches.length > 1)
6641
+ return INVALID_DATABASE_SQL;
6642
+ return (_a = attributeString(attribute)) !== null && _a !== void 0 ? _a : INVALID_DATABASE_SQL;
6643
+ };
6644
+ var withoutDatabaseSql = (attributes) => attributes.filter((attribute) => !isSqlAttribute(attribute));
6645
+
6582
6646
  // ../editor/dist/converter/utils/comment-thread-ids.js
6583
6647
  function parseCommentThreadIds(value) {
6584
6648
  if (typeof value !== "string")
@@ -12767,11 +12831,12 @@ function handleTree(node) {
12767
12831
  var DATABASE_VIEW_PROPS = ["view", "sort", "filter", "groupBy"];
12768
12832
  function handleDatabase(node, ctx) {
12769
12833
  var _a;
12770
- const parsed = parseMdxAttributes(node.attributes);
12771
- const isValid = ctx.databases === true && !!((_a = ctx.schema) !== null && _a !== void 0 ? _a : mintlifySchema).nodes[BLOCK_TYPES.database] && node.children.length === 0 && !(EXPRESSION_ATTRS_KEY in parsed) && !(NAMED_EXPRESSION_ATTRS_KEY in parsed) && isDatabaseId(parsed.id) && DATABASE_VIEW_PROPS.every((key) => parsed[key] === void 0 || typeof parsed[key] === "string");
12834
+ const sql = readDatabaseSql(node.attributes);
12835
+ const parsed = parseMdxAttributes(withoutDatabaseSql(node.attributes));
12836
+ const isValid = ctx.databases === true && sql !== INVALID_DATABASE_SQL && !!((_a = ctx.schema) !== null && _a !== void 0 ? _a : mintlifySchema).nodes[BLOCK_TYPES.database] && node.children.length === 0 && !(EXPRESSION_ATTRS_KEY in parsed) && !(NAMED_EXPRESSION_ATTRS_KEY in parsed) && isDatabaseId(parsed.id) && DATABASE_VIEW_PROPS.every((key) => parsed[key] === void 0 || typeof parsed[key] === "string");
12772
12837
  if (!isValid)
12773
12838
  return { type: BLOCK_TYPES.unknownTag, attrs: { mdxJsxNode: node } };
12774
- return { type: BLOCK_TYPES.database, attrs: partitionAttrs(parsed, DATABASE_ATTRS) };
12839
+ return { type: BLOCK_TYPES.database, attrs: Object.assign(Object.assign({}, partitionAttrs(parsed, DATABASE_ATTRS)), { sql }) };
12775
12840
  }
12776
12841
  var CELL_SPAN_ATTRS = /* @__PURE__ */ new Set(["colspan", "colSpan", "rowspan", "rowSpan"]);
12777
12842
  var TABLE_CLASS_ATTRS = /* @__PURE__ */ new Set(["class", "className"]);
@@ -15748,7 +15813,8 @@ function writeTreeChild(state, child) {
15748
15813
  function renderDatabase(state, node) {
15749
15814
  const props = [
15750
15815
  serializeJsxAttribute(node.attrs, "id", node.attrs.id),
15751
- ...["view", "sort", "filter", "groupBy"].map((key) => serializeReadableJsxAttribute(key, node.attrs[key]))
15816
+ ...["view", "sort", "filter", "groupBy"].map((key) => serializeReadableJsxAttribute(key, node.attrs[key])),
15817
+ typeof node.attrs.sql === "string" ? serializeDatabaseSql(node.attrs.sql) : null
15752
15818
  ].filter(Boolean);
15753
15819
  const propString = props.length > 0 ? ` ${props.join(" ")}` : "";
15754
15820
  state.write(`<Database${propString}${extraAttrsPropString(node.attrs, serializeLiteralJsxAttribute)} />`);
@@ -17811,10 +17877,12 @@ export {
17811
17877
  pmJsonToMdast,
17812
17878
  pmToMdx,
17813
17879
  pmToMdxPreservingSource,
17880
+ readDatabaseSql,
17814
17881
  resolveDatabaseView,
17815
17882
  safeJsonParse,
17816
17883
  sanitizeDomAttrs,
17817
17884
  serializeCommentThreadIds,
17885
+ serializeDatabaseSql,
17818
17886
  serializePropValue,
17819
17887
  startsWithPlaceholderParagraph,
17820
17888
  storedValueToTyped,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1773",
3
+ "version": "4.0.1775",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.1325",
49
- "@mintlify/link-rot": "3.0.1563",
48
+ "@mintlify/common": "1.0.1326",
49
+ "@mintlify/link-rot": "3.0.1564",
50
50
  "@mintlify/models": "0.0.383",
51
- "@mintlify/og": "0.0.124",
52
- "@mintlify/prebuild": "1.0.1497",
53
- "@mintlify/previewing": "4.0.1581",
51
+ "@mintlify/og": "0.0.125",
52
+ "@mintlify/prebuild": "1.0.1498",
53
+ "@mintlify/previewing": "4.0.1582",
54
54
  "@mintlify/validation": "0.1.954",
55
55
  "adm-zip": "0.6.0",
56
56
  "chalk": "5.2.0",
@@ -87,7 +87,7 @@
87
87
  "keytar": "7.9.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@mintlify/editor": "0.0.599",
90
+ "@mintlify/editor": "0.0.601",
91
91
  "@mintlify/ts-config": "2.0.2",
92
92
  "@tsconfig/recommended": "1.0.2",
93
93
  "@types/detect-port": "1.3.2",
@@ -106,5 +106,5 @@
106
106
  "vitest": "2.1.9",
107
107
  "vitest-mock-process": "1.0.4"
108
108
  },
109
- "gitHead": "9ab322608fd11550c226c31abfbf51e4c364d370"
109
+ "gitHead": "2ec569db5cd92824bbdb6c95599a9586e3c32c1e"
110
110
  }