hububb-saas-shared 1.2.51 → 1.2.53

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.
@@ -0,0 +1,19 @@
1
+ export declare function isGuideBodyHtml(body: string): boolean;
2
+ /** @deprecated Legacy HTML helper — new guides store markdown. */
3
+ export declare function escapeGuideHtml(text: string): string;
4
+ /** @deprecated Legacy HTML helper — new guides store markdown. */
5
+ export declare function plainTextToGuideHtml(body: string): string;
6
+ /** Best-effort conversion for guides saved as HTML before the markdown migration. */
7
+ export declare function htmlToMarkdown(html: string): string;
8
+ /** Returns markdown suitable for editors and react-markdown renderers. */
9
+ export declare function normalizeGuideBodyMarkdown(body: string | null | undefined): string;
10
+ /** @deprecated Use normalizeGuideBodyMarkdown */
11
+ export declare function normalizeGuideBodyForDisplay(body: string | null | undefined): string;
12
+ /** Prepares stored guide body for markdown editors. */
13
+ export declare function guideBodyToEditorMarkdown(body: string | null | undefined): string;
14
+ /** @deprecated Use guideBodyToEditorMarkdown */
15
+ export declare function guideBodyToEditorHtml(body: string | null | undefined): string;
16
+ export declare function stripGuideBodyPreview(body: string | null | undefined): string;
17
+ export declare function isGuideBodyEmpty(body: string | null | undefined): boolean;
18
+ /** @deprecated HTML sanitization is unused when rendering markdown. */
19
+ export declare const GUIDE_BODY_ALLOWED_TAGS: readonly ["p", "br", "strong", "b", "em", "i", "ul", "ol", "li", "h2", "h3", "h4", "a", "blockquote"];
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GUIDE_BODY_ALLOWED_TAGS = void 0;
4
+ exports.isGuideBodyHtml = isGuideBodyHtml;
5
+ exports.escapeGuideHtml = escapeGuideHtml;
6
+ exports.plainTextToGuideHtml = plainTextToGuideHtml;
7
+ exports.htmlToMarkdown = htmlToMarkdown;
8
+ exports.normalizeGuideBodyMarkdown = normalizeGuideBodyMarkdown;
9
+ exports.normalizeGuideBodyForDisplay = normalizeGuideBodyForDisplay;
10
+ exports.guideBodyToEditorMarkdown = guideBodyToEditorMarkdown;
11
+ exports.guideBodyToEditorHtml = guideBodyToEditorHtml;
12
+ exports.stripGuideBodyPreview = stripGuideBodyPreview;
13
+ exports.isGuideBodyEmpty = isGuideBodyEmpty;
14
+ const HTML_TAG_PATTERN = /<\s*[a-z][^>]*>/i;
15
+ function isGuideBodyHtml(body) {
16
+ return HTML_TAG_PATTERN.test(body);
17
+ }
18
+ /** @deprecated Legacy HTML helper — new guides store markdown. */
19
+ function escapeGuideHtml(text) {
20
+ return text
21
+ .replace(/&/g, '&amp;')
22
+ .replace(/</g, '&lt;')
23
+ .replace(/>/g, '&gt;')
24
+ .replace(/"/g, '&quot;')
25
+ .replace(/'/g, '&#39;');
26
+ }
27
+ /** @deprecated Legacy HTML helper — new guides store markdown. */
28
+ function plainTextToGuideHtml(body) {
29
+ const blocks = body
30
+ .split(/\n{2,}/)
31
+ .map((paragraph) => paragraph.trim())
32
+ .filter(Boolean);
33
+ if (blocks.length === 0)
34
+ return '';
35
+ return blocks
36
+ .map((paragraph) => `<p>${escapeGuideHtml(paragraph).replace(/\n/g, '<br />')}</p>`)
37
+ .join('');
38
+ }
39
+ /** Best-effort conversion for guides saved as HTML before the markdown migration. */
40
+ function htmlToMarkdown(html) {
41
+ let text = html
42
+ .replace(/\r\n/g, '\n')
43
+ .replace(/<br\s*\/?>/gi, '\n')
44
+ .replace(/<\/(p|div|h[1-6]|li|blockquote)>/gi, '\n')
45
+ .replace(/<(strong|b)[^>]*>([\s\S]*?)<\/\1>/gi, '**$2**')
46
+ .replace(/<(em|i)[^>]*>([\s\S]*?)<\/\1>/gi, '*$2*')
47
+ .replace(/<li[^>]*>/gi, '- ')
48
+ .replace(/<[^>]+>/g, '')
49
+ .replace(/&nbsp;/gi, ' ')
50
+ .replace(/&amp;/gi, '&')
51
+ .replace(/&lt;/gi, '<')
52
+ .replace(/&gt;/gi, '>')
53
+ .replace(/\n{3,}/g, '\n\n');
54
+ return text.trim();
55
+ }
56
+ /** Returns markdown suitable for editors and react-markdown renderers. */
57
+ function normalizeGuideBodyMarkdown(body) {
58
+ if (!(body === null || body === void 0 ? void 0 : body.trim()))
59
+ return '';
60
+ if (isGuideBodyHtml(body))
61
+ return htmlToMarkdown(body);
62
+ return body.trim();
63
+ }
64
+ /** @deprecated Use normalizeGuideBodyMarkdown */
65
+ function normalizeGuideBodyForDisplay(body) {
66
+ return normalizeGuideBodyMarkdown(body);
67
+ }
68
+ /** Prepares stored guide body for markdown editors. */
69
+ function guideBodyToEditorMarkdown(body) {
70
+ return normalizeGuideBodyMarkdown(body);
71
+ }
72
+ /** @deprecated Use guideBodyToEditorMarkdown */
73
+ function guideBodyToEditorHtml(body) {
74
+ return guideBodyToEditorMarkdown(body);
75
+ }
76
+ function stripGuideBodyPreview(body) {
77
+ const markdown = normalizeGuideBodyMarkdown(body);
78
+ if (!markdown)
79
+ return '';
80
+ return markdown
81
+ .replace(/```[\s\S]*?```/g, ' ')
82
+ .replace(/`([^`]+)`/g, '$1')
83
+ .replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
84
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
85
+ .replace(/^#{1,6}\s+/gm, '')
86
+ .replace(/^>\s+/gm, '')
87
+ .replace(/^[-*+]\s+/gm, '')
88
+ .replace(/^\d+\.\s+/gm, '')
89
+ .replace(/[*_~]/g, '')
90
+ .replace(/\s+/g, ' ')
91
+ .trim();
92
+ }
93
+ function isGuideBodyEmpty(body) {
94
+ return !normalizeGuideBodyMarkdown(body);
95
+ }
96
+ /** @deprecated HTML sanitization is unused when rendering markdown. */
97
+ exports.GUIDE_BODY_ALLOWED_TAGS = [
98
+ 'p',
99
+ 'br',
100
+ 'strong',
101
+ 'b',
102
+ 'em',
103
+ 'i',
104
+ 'ul',
105
+ 'ol',
106
+ 'li',
107
+ 'h2',
108
+ 'h3',
109
+ 'h4',
110
+ 'a',
111
+ 'blockquote',
112
+ ];
@@ -1,4 +1,5 @@
1
1
  export { GUIDE_ICON_KEYS, GUIDE_ICON_LABELS, GUIDE_ICON_PHOSPHOR_NAMES, type GuideIconKey } from './icons';
2
+ export { GUIDE_BODY_ALLOWED_TAGS, escapeGuideHtml, guideBodyToEditorHtml, guideBodyToEditorMarkdown, htmlToMarkdown, isGuideBodyEmpty, isGuideBodyHtml, normalizeGuideBodyForDisplay, normalizeGuideBodyMarkdown, plainTextToGuideHtml, stripGuideBodyPreview, } from './body';
2
3
  export declare const propertyGuideSchema: import("zod").ZodObject<{
3
4
  id: import("zod").ZodNumber;
4
5
  propertyId: import("zod").ZodNumber;
@@ -1,12 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.propertyGuideSchema = exports.GUIDE_ICON_PHOSPHOR_NAMES = exports.GUIDE_ICON_LABELS = exports.GUIDE_ICON_KEYS = void 0;
3
+ exports.propertyGuideSchema = exports.stripGuideBodyPreview = exports.plainTextToGuideHtml = exports.normalizeGuideBodyMarkdown = exports.normalizeGuideBodyForDisplay = exports.isGuideBodyHtml = exports.isGuideBodyEmpty = exports.htmlToMarkdown = exports.guideBodyToEditorMarkdown = exports.guideBodyToEditorHtml = exports.escapeGuideHtml = exports.GUIDE_BODY_ALLOWED_TAGS = exports.GUIDE_ICON_PHOSPHOR_NAMES = exports.GUIDE_ICON_LABELS = exports.GUIDE_ICON_KEYS = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const icons_1 = require("./icons");
6
6
  var icons_2 = require("./icons");
7
7
  Object.defineProperty(exports, "GUIDE_ICON_KEYS", { enumerable: true, get: function () { return icons_2.GUIDE_ICON_KEYS; } });
8
8
  Object.defineProperty(exports, "GUIDE_ICON_LABELS", { enumerable: true, get: function () { return icons_2.GUIDE_ICON_LABELS; } });
9
9
  Object.defineProperty(exports, "GUIDE_ICON_PHOSPHOR_NAMES", { enumerable: true, get: function () { return icons_2.GUIDE_ICON_PHOSPHOR_NAMES; } });
10
+ var body_1 = require("./body");
11
+ Object.defineProperty(exports, "GUIDE_BODY_ALLOWED_TAGS", { enumerable: true, get: function () { return body_1.GUIDE_BODY_ALLOWED_TAGS; } });
12
+ Object.defineProperty(exports, "escapeGuideHtml", { enumerable: true, get: function () { return body_1.escapeGuideHtml; } });
13
+ Object.defineProperty(exports, "guideBodyToEditorHtml", { enumerable: true, get: function () { return body_1.guideBodyToEditorHtml; } });
14
+ Object.defineProperty(exports, "guideBodyToEditorMarkdown", { enumerable: true, get: function () { return body_1.guideBodyToEditorMarkdown; } });
15
+ Object.defineProperty(exports, "htmlToMarkdown", { enumerable: true, get: function () { return body_1.htmlToMarkdown; } });
16
+ Object.defineProperty(exports, "isGuideBodyEmpty", { enumerable: true, get: function () { return body_1.isGuideBodyEmpty; } });
17
+ Object.defineProperty(exports, "isGuideBodyHtml", { enumerable: true, get: function () { return body_1.isGuideBodyHtml; } });
18
+ Object.defineProperty(exports, "normalizeGuideBodyForDisplay", { enumerable: true, get: function () { return body_1.normalizeGuideBodyForDisplay; } });
19
+ Object.defineProperty(exports, "normalizeGuideBodyMarkdown", { enumerable: true, get: function () { return body_1.normalizeGuideBodyMarkdown; } });
20
+ Object.defineProperty(exports, "plainTextToGuideHtml", { enumerable: true, get: function () { return body_1.plainTextToGuideHtml; } });
21
+ Object.defineProperty(exports, "stripGuideBodyPreview", { enumerable: true, get: function () { return body_1.stripGuideBodyPreview; } });
10
22
  exports.propertyGuideSchema = (0, zod_1.object)({
11
23
  id: (0, zod_1.number)().int(),
12
24
  propertyId: (0, zod_1.number)().int(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "hububb-saas-shared",
4
- "version": "1.2.51",
4
+ "version": "1.2.53",
5
5
  "description": "This is a shared package for the hububb saas project",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.js",