@openinc/parse-server-opendash 3.24.4 → 3.24.6

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.
@@ -57,22 +57,27 @@ class LinkResolver {
57
57
  const data = typeof content === "string"
58
58
  ? { base64: Buffer.from(content, "utf8").toString("base64") }
59
59
  : { base64: content.toString("base64") };
60
- const parseFile = await new Parse.File(fileName || "file", data).save({
61
- useMasterKey: true,
62
- });
63
- const asset = new types_1.Assets({
64
- file: parseFile,
65
- context: "documentation",
66
- tenant,
67
- user,
68
- description: fileName,
69
- meta: {
70
- importedByDocumentation: true,
71
- },
72
- });
73
- const savedAsset = await asset.save(null, { useMasterKey: true });
74
- const newURL = savedAsset.file?.url() || "";
75
- newLinkMap.set(absoluteLink, newURL);
60
+ try {
61
+ const parseFile = await new Parse.File(fileName || "file", data).save({
62
+ useMasterKey: true,
63
+ });
64
+ const asset = new types_1.Assets({
65
+ file: parseFile,
66
+ context: "documentation",
67
+ tenant,
68
+ user,
69
+ description: fileName,
70
+ meta: {
71
+ importedByDocumentation: true,
72
+ },
73
+ });
74
+ const savedAsset = await asset.save(null, { useMasterKey: true });
75
+ const newURL = savedAsset.file?.url() || "";
76
+ newLinkMap.set(absoluteLink, newURL);
77
+ }
78
+ catch (err) {
79
+ console.error(`[LinkResolver] Failed to upload linked asset for ${absoluteLink}:`, err);
80
+ }
76
81
  }
77
82
  console.log(`[LinkResolver] Resolved and uploaded ${newLinkMap.size} linked assets.`);
78
83
  // Finally, replace links in each file's content
@@ -94,15 +99,27 @@ class LinkResolver {
94
99
  let match;
95
100
  while ((match = regex.exec(content)) !== null) {
96
101
  const markdown = match[1];
97
- const link = match[2].trim();
98
- // Skip URLs
99
- if (/^https?:\/\//i.test(link) || /^mailto:/i.test(link))
102
+ const rawLink = match[2].trim();
103
+ // Skip URLs and mailto
104
+ if (/^https?:\/\//i.test(rawLink) || /^mailto:/i.test(rawLink))
105
+ continue;
106
+ // Skip pure anchor links
107
+ if (rawLink.startsWith("#"))
108
+ continue;
109
+ // If link contains a fragment, strip it (e.g., file.md#section → file.md)
110
+ const [linkPath] = rawLink.split("#");
111
+ if (!linkPath || !linkPath.trim())
100
112
  continue;
113
+ // Ignore links to other markdown files, but warn
114
+ if (/\.md$/i.test(linkPath.trim())) {
115
+ console.warn(`[LinkResolver] ⚠️ Ignoring link to markdown file "${linkPath.trim()}" in "${file.path}"`);
116
+ continue;
117
+ }
101
118
  const baseDir = path_1.default.posix.dirname(file.path);
102
- const absoluteLink = path_1.default.posix.normalize(path_1.default.posix.join("./docs", baseDir, link));
119
+ const absoluteLink = path_1.default.posix.normalize(path_1.default.posix.join("./docs", baseDir, linkPath.trim()));
103
120
  occurrences.push({
104
121
  filePath: file.path,
105
- link,
122
+ link: rawLink,
106
123
  absoluteLink,
107
124
  start: match.index,
108
125
  end: match.index + markdown.length,
@@ -26,7 +26,7 @@ async function saveProject(ticket, project, fetchOptions) {
26
26
  if (prevProject && prevProject.id !== project) {
27
27
  try {
28
28
  prevProject.relation("tickets").remove(ticket);
29
- await prevProject.save(null, fetchOptions);
29
+ await prevProject.save(null, { useMasterKey: true });
30
30
  }
31
31
  catch (err) {
32
32
  console.warn(`Failed to remove ticket from previous project ${prevProject.id}:`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.24.4",
3
+ "version": "3.24.6",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "keywords": [