@siteping/widget 0.10.7 → 0.10.9

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.
Files changed (45) hide show
  1. package/dist/{chunk-GKRKCSID.cjs → chunk-AFLWWD6M.cjs} +11 -11
  2. package/dist/chunk-AFLWWD6M.cjs.map +1 -0
  3. package/dist/{chunk-7ZBKJ6NW.js → chunk-ATTI2TS4.js} +11 -11
  4. package/dist/chunk-ATTI2TS4.js.map +1 -0
  5. package/dist/{chunk-NVNA5AI2.cjs → chunk-BP5TH2CD.js} +11 -11
  6. package/dist/chunk-BP5TH2CD.js.map +1 -0
  7. package/dist/{chunk-FDQWFGRR.js → chunk-OSADAHGS.cjs} +11 -11
  8. package/dist/chunk-OSADAHGS.cjs.map +1 -0
  9. package/dist/email.d.cts +19 -0
  10. package/dist/email.d.ts +19 -0
  11. package/dist/filters.d.cts +29 -4
  12. package/dist/filters.d.ts +29 -4
  13. package/dist/index.cjs +50 -50
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.global.js +107 -119
  16. package/dist/index.global.js.map +1 -1
  17. package/dist/index.js +51 -51
  18. package/dist/index.js.map +1 -1
  19. package/dist/panel-2FEECS2N.cjs +2 -0
  20. package/dist/{panel-M2QKMFYO.cjs.map → panel-2FEECS2N.cjs.map} +1 -1
  21. package/dist/panel-CSFFA5FF.cjs +2 -0
  22. package/dist/{panel-XUTDVTAR.cjs.map → panel-CSFFA5FF.cjs.map} +1 -1
  23. package/dist/panel-S2UR5BSD.js +2 -0
  24. package/dist/{panel-7URHNKQH.js.map → panel-S2UR5BSD.js.map} +1 -1
  25. package/dist/panel-SGSUHR7V.js +2 -0
  26. package/dist/{panel-FUPBUN6F.js.map → panel-SGSUHR7V.js.map} +1 -1
  27. package/dist/react.cjs +42 -42
  28. package/dist/react.cjs.map +1 -1
  29. package/dist/react.js +46 -46
  30. package/dist/react.js.map +1 -1
  31. package/dist/siteping-core.d.cts +3 -2
  32. package/dist/siteping-core.d.ts +3 -2
  33. package/dist/store-helpers.d.cts +13 -4
  34. package/dist/store-helpers.d.ts +13 -4
  35. package/dist/types.d.cts +4 -4
  36. package/dist/types.d.ts +4 -4
  37. package/package.json +5 -5
  38. package/dist/chunk-7ZBKJ6NW.js.map +0 -1
  39. package/dist/chunk-FDQWFGRR.js.map +0 -1
  40. package/dist/chunk-GKRKCSID.cjs.map +0 -1
  41. package/dist/chunk-NVNA5AI2.cjs.map +0 -1
  42. package/dist/panel-7URHNKQH.js +0 -2
  43. package/dist/panel-FUPBUN6F.js +0 -2
  44. package/dist/panel-M2QKMFYO.cjs +0 -2
  45. package/dist/panel-XUTDVTAR.cjs +0 -2
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The one email pattern every Siteping surface validates against.
3
+ *
4
+ * The widget's identity modal and the HTTP handler's schema used to disagree
5
+ * (a permissive regex on one side, an ASCII-only default on the other), so an
6
+ * address the modal accepted — and persisted in localStorage for good — came
7
+ * back as a 400 on every submission afterwards. One pattern, imported on both
8
+ * sides, makes that drift impossible.
9
+ *
10
+ * Deliberately Unicode-aware: internationalised local parts and domains
11
+ * (`françois@exemple.fr`, `user@münchen.de`) are real addresses and common in
12
+ * the audience this widget serves. Structure follows the usual rules — a
13
+ * local part of 1 to 64 characters with no leading, trailing or doubled dot,
14
+ * dot-separated domain labels of at most 63 characters that neither start nor
15
+ * end with a hyphen, and a final label of at least two characters.
16
+ */
17
+ export declare const EMAIL_PATTERN: RegExp;
18
+ /** Whether `value` is an email address Siteping accepts — see {@link EMAIL_PATTERN}. */
19
+ export declare function isValidEmail(value: string): boolean;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The one email pattern every Siteping surface validates against.
3
+ *
4
+ * The widget's identity modal and the HTTP handler's schema used to disagree
5
+ * (a permissive regex on one side, an ASCII-only default on the other), so an
6
+ * address the modal accepted — and persisted in localStorage for good — came
7
+ * back as a 400 on every submission afterwards. One pattern, imported on both
8
+ * sides, makes that drift impossible.
9
+ *
10
+ * Deliberately Unicode-aware: internationalised local parts and domains
11
+ * (`françois@exemple.fr`, `user@münchen.de`) are real addresses and common in
12
+ * the audience this widget serves. Structure follows the usual rules — a
13
+ * local part of 1 to 64 characters with no leading, trailing or doubled dot,
14
+ * dot-separated domain labels of at most 63 characters that neither start nor
15
+ * end with a hyphen, and a final label of at least two characters.
16
+ */
17
+ export declare const EMAIL_PATTERN: RegExp;
18
+ /** Whether `value` is an email address Siteping accepts — see {@link EMAIL_PATTERN}. */
19
+ export declare function isValidEmail(value: string): boolean;
@@ -12,16 +12,41 @@
12
12
  * 5. urlPattern
13
13
  * 6. search (lowercase substring match on `message`)
14
14
  *
15
- * Pagination clamps `limit` to a maximum of 100 and treats `page` as 1-based,
16
- * matching the public API contract documented on `getFeedbacks`. A page or
17
- * limit below 1 is clamped up to 1 rather than indexing backwards from the
18
- * end of the match set.
15
+ * Pagination goes through `clampPagination`: `limit` capped at 100, `page`
16
+ * 1-based, both clamped up to 1 rather than indexing backwards from the end
17
+ * of the match set. Query adapters reuse the same helper so every store
18
+ * paginates identically.
19
19
  */
20
20
  import type { FeedbackQuery, FeedbackRecord } from "./types.cjs";
21
+ /** Default page size when the caller omits `query.limit`. */
22
+ export declare const DEFAULT_PAGE_LIMIT = 50;
23
+ /** Maximum allowed page size — defends against memory blow-ups on hostile callers. */
24
+ export declare const MAX_PAGE_LIMIT = 100;
21
25
  export interface FilterResult {
22
26
  feedbacks: FeedbackRecord[];
23
27
  total: number;
24
28
  }
29
+ /** Normalised pagination window — see {@link clampPagination}. */
30
+ export interface Pagination {
31
+ /** 1-based page number, at least 1. */
32
+ page: number;
33
+ /** Page size in `[1, MAX_PAGE_LIMIT]`. */
34
+ limit: number;
35
+ /** Offset of the first row: `(page - 1) * limit`. */
36
+ skip: number;
37
+ }
38
+ /**
39
+ * Normalise `page` / `limit` to the store contract: `page` is 1-based and
40
+ * clamped up to 1, `limit` defaults to 50 and is clamped into `[1, 100]`,
41
+ * non-finite values fall back to the defaults. `skip` is the derived row
42
+ * offset for query backends (`OFFSET`, Prisma `skip`).
43
+ *
44
+ * Shared by the in-memory pipeline and query adapters (`PrismaStore`) so
45
+ * every store paginates identically — the HTTP schema clamps the same way,
46
+ * but direct callers (dashboard store mode, server actions) reach the store
47
+ * without a schema in front of them.
48
+ */
49
+ export declare function clampPagination(query: Pick<FeedbackQuery, "page" | "limit">): Pagination;
25
50
  /**
26
51
  * Apply the standard feedback filter + pagination pipeline against an
27
52
  * in-memory snapshot. Used by `MemoryStore.getFeedbacks` and
package/dist/filters.d.ts CHANGED
@@ -12,16 +12,41 @@
12
12
  * 5. urlPattern
13
13
  * 6. search (lowercase substring match on `message`)
14
14
  *
15
- * Pagination clamps `limit` to a maximum of 100 and treats `page` as 1-based,
16
- * matching the public API contract documented on `getFeedbacks`. A page or
17
- * limit below 1 is clamped up to 1 rather than indexing backwards from the
18
- * end of the match set.
15
+ * Pagination goes through `clampPagination`: `limit` capped at 100, `page`
16
+ * 1-based, both clamped up to 1 rather than indexing backwards from the end
17
+ * of the match set. Query adapters reuse the same helper so every store
18
+ * paginates identically.
19
19
  */
20
20
  import type { FeedbackQuery, FeedbackRecord } from "./types.js";
21
+ /** Default page size when the caller omits `query.limit`. */
22
+ export declare const DEFAULT_PAGE_LIMIT = 50;
23
+ /** Maximum allowed page size — defends against memory blow-ups on hostile callers. */
24
+ export declare const MAX_PAGE_LIMIT = 100;
21
25
  export interface FilterResult {
22
26
  feedbacks: FeedbackRecord[];
23
27
  total: number;
24
28
  }
29
+ /** Normalised pagination window — see {@link clampPagination}. */
30
+ export interface Pagination {
31
+ /** 1-based page number, at least 1. */
32
+ page: number;
33
+ /** Page size in `[1, MAX_PAGE_LIMIT]`. */
34
+ limit: number;
35
+ /** Offset of the first row: `(page - 1) * limit`. */
36
+ skip: number;
37
+ }
38
+ /**
39
+ * Normalise `page` / `limit` to the store contract: `page` is 1-based and
40
+ * clamped up to 1, `limit` defaults to 50 and is clamped into `[1, 100]`,
41
+ * non-finite values fall back to the defaults. `skip` is the derived row
42
+ * offset for query backends (`OFFSET`, Prisma `skip`).
43
+ *
44
+ * Shared by the in-memory pipeline and query adapters (`PrismaStore`) so
45
+ * every store paginates identically — the HTTP schema clamps the same way,
46
+ * but direct callers (dashboard store mode, server actions) reach the store
47
+ * without a schema in front of them.
48
+ */
49
+ export declare function clampPagination(query: Pick<FeedbackQuery, "page" | "limit">): Pagination;
25
50
  /**
26
51
  * Apply the standard feedback filter + pagination pipeline against an
27
52
  * in-memory snapshot. Used by `MemoryStore.getFeedbacks` and