@proveanything/smartlinks 2.1.20 → 2.1.23
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/adminCardsView.d.ts +1 -1
- package/dist/adminCardsView.js +70 -55
- package/dist/api/appObjects.d.ts +26 -0
- package/dist/api/appObjects.js +31 -1
- package/dist/api/conditions.d.ts +51 -0
- package/dist/api/conditions.js +57 -0
- package/dist/api/contact.d.ts +83 -1
- package/dist/api/contact.js +104 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/products.d.ts +22 -0
- package/dist/api/products.js +29 -0
- package/dist/api/proof.d.ts +30 -0
- package/dist/api/proof.js +37 -0
- package/dist/api/realtime.d.ts +19 -0
- package/dist/api/realtime.js +26 -1
- package/dist/docs/API_SUMMARY.md +396 -170
- package/dist/docs/admin-cards.md +1 -1
- package/dist/docs/app-manifest.md +19 -0
- package/dist/docs/assistant-apps.md +4 -0
- package/dist/docs/assistant-context.md +119 -0
- package/dist/docs/realtime.md +20 -0
- package/dist/docs/standard-query.md +187 -0
- package/dist/docs/utils.md +22 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +0 -1
- package/dist/openapi.yaml +675 -0
- package/dist/types/adminCards.d.ts +2 -1
- package/dist/types/appManifest.d.ts +64 -1
- package/dist/types/contact.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/query.d.ts +121 -0
- package/dist/types/query.js +5 -0
- package/dist/types/realtime.d.ts +7 -1
- package/dist/utils/conditions.d.ts +1 -1
- package/dist/utils/conditions.js +21 -6
- package/docs/API_SUMMARY.md +396 -170
- package/docs/admin-cards.md +1 -1
- package/docs/app-manifest.md +19 -0
- package/docs/assistant-apps.md +4 -0
- package/docs/assistant-context.md +119 -0
- package/docs/realtime.md +20 -0
- package/docs/standard-query.md +187 -0
- package/docs/utils.md +22 -8
- package/openapi.yaml +675 -0
- package/package.json +1 -1
package/dist/adminCardsView.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare function adminCardAge(at: number | null | undefined, now?: number
|
|
|
55
55
|
/** Add the card styles to the page once (the views call it; hosts rendering on the server can too). */
|
|
56
56
|
export declare function injectAdminCardStyles(doc?: Document | undefined): void;
|
|
57
57
|
/** The card stylesheet, for hosts that prefer to ship it themselves. */
|
|
58
|
-
export declare const ADMIN_CARD_CSS = "\n.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}\n.slc-grid>*{grid-column:span 12}\n@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}\n@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}\n.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));\n box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}\n.slc-head{display:flex;align-items:center;gap:8px;min-width:0}\n.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}\n.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}\n.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}\n.slc-refresh:focus-visible{outline:2px solid var(--_accent)}\n.slc-spin{animation:slc-spin 1s linear infinite}\n@keyframes slc-spin{to{transform:rotate(360deg)}}\n.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}\n.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}\n.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}\n.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}\n.slc-label{font-size:.875rem;color:var(--_muted)}\n.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}\n.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}\n.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}\n.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}\n.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}\n.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}\n.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}\n.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}\n.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}\n.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}\n.slc-item:first-child{border-top:0}\n.slc-item-main{flex:1;min-width:0}\n.slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}\n.slc-link{all:unset;cursor:pointer}\n.slc-link:hover .slc-item-title{text-decoration:underline}\n.slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}\n.slc-empty{font-size:.875rem;color:var(--_muted)}\n.slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}\n.slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}\n.slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}\n.slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}\n.slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}\n.slc-note{font-size:.75rem;color:var(--_muted)}\n.slc-note.slc-err{color:var(--_err)}\n.slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}\n@keyframes slc-pulse{50%{opacity:.5}}\n.slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}\n.slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}\n.slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}\n.slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}\n.slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}\n.slc-todo-text{flex:1;min-width:0}\n";
|
|
58
|
+
export declare const ADMIN_CARD_CSS = "\n.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}\n.slc-grid>*{grid-column:span 12}\n@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}\n@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}\n.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));\n box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}\n.slc-head{display:flex;align-items:center;gap:8px;min-width:0}\n.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}\n.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}\n.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}\n.slc-refresh:focus-visible{outline:2px solid var(--_accent)}\n.slc-spin{animation:slc-spin 1s linear infinite}\n@keyframes slc-spin{to{transform:rotate(360deg)}}\n.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}\n.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}\n.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}\n.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}\n.slc-label{font-size:.875rem;color:var(--_muted)}\n.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}\n.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}\n.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}\n.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}\n.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}\n.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}\n.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}\n.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}\n.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}\n.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}\n.slc-item:first-child{border-top:0}\n.slc-item-main{flex:1;min-width:0}\n.slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}\n.slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}\n.slc-link{all:unset;cursor:pointer}\n.slc-link:hover .slc-item-title{text-decoration:underline}\n.slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}\n.slc-empty{font-size:.875rem;color:var(--_muted)}\n.slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}\n.slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}\n.slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}\n.slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}\n.slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}\n.slc-note{font-size:.75rem;color:var(--_muted)}\n.slc-note.slc-err{color:var(--_err)}\n.slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}\n@keyframes slc-pulse{50%{opacity:.5}}\n.slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}\n.slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}\n.slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}\n.slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}\n.slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}\n.slc-todo-text{flex:1;min-width:0}\n";
|
|
59
59
|
/** The card views, bound to the host's React. Call once per app (module scope). */
|
|
60
60
|
export declare function createAdminCardViews(React: ReactLike): {
|
|
61
61
|
AdminCardView: (props: AdminCardViewProps) => any;
|
package/dist/adminCardsView.js
CHANGED
|
@@ -28,60 +28,61 @@ export function adminCardAge(at, now = Date.now()) {
|
|
|
28
28
|
return `${Math.round(s / 3600)} h ago`;
|
|
29
29
|
return `${Math.round(s / 86400)} d ago`;
|
|
30
30
|
}
|
|
31
|
-
const CSS = `
|
|
32
|
-
.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
|
|
33
|
-
.slc-grid>*{grid-column:span 12}
|
|
34
|
-
@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
|
|
35
|
-
@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
|
|
36
|
-
.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
|
|
37
|
-
box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
|
|
38
|
-
.slc-head{display:flex;align-items:center;gap:8px;min-width:0}
|
|
39
|
-
.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
40
|
-
.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
|
|
41
|
-
.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
|
|
42
|
-
.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
|
|
43
|
-
.slc-refresh:focus-visible{outline:2px solid var(--_accent)}
|
|
44
|
-
.slc-spin{animation:slc-spin 1s linear infinite}
|
|
45
|
-
@keyframes slc-spin{to{transform:rotate(360deg)}}
|
|
46
|
-
.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
|
|
47
|
-
.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
|
|
48
|
-
.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
|
|
49
|
-
.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
|
|
50
|
-
.slc-label{font-size:.875rem;color:var(--_muted)}
|
|
51
|
-
.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
|
|
52
|
-
.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
|
|
53
|
-
.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
|
|
54
|
-
.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
|
|
55
|
-
.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
|
|
56
|
-
.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
|
|
57
|
-
.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
|
|
58
|
-
.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
|
|
59
|
-
.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
|
|
60
|
-
.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
61
|
-
.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
|
|
62
|
-
.slc-item:first-child{border-top:0}
|
|
63
|
-
.slc-item-main{flex:1;min-width:0}
|
|
64
|
-
.slc-item-
|
|
65
|
-
.slc-item-
|
|
66
|
-
.slc-
|
|
67
|
-
.slc-link
|
|
68
|
-
.slc-link:
|
|
69
|
-
.slc-
|
|
70
|
-
.slc-
|
|
71
|
-
.slc-
|
|
72
|
-
.slc-btn
|
|
73
|
-
.slc-btn
|
|
74
|
-
.slc-btn
|
|
75
|
-
.slc-
|
|
76
|
-
.slc-note
|
|
77
|
-
.slc-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.slc-todo
|
|
81
|
-
.slc-todo-
|
|
82
|
-
.slc-todo-row
|
|
83
|
-
.slc-todo-row
|
|
84
|
-
.slc-todo-
|
|
31
|
+
const CSS = `
|
|
32
|
+
.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
|
|
33
|
+
.slc-grid>*{grid-column:span 12}
|
|
34
|
+
@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
|
|
35
|
+
@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
|
|
36
|
+
.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
|
|
37
|
+
box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
|
|
38
|
+
.slc-head{display:flex;align-items:center;gap:8px;min-width:0}
|
|
39
|
+
.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
40
|
+
.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
|
|
41
|
+
.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
|
|
42
|
+
.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
|
|
43
|
+
.slc-refresh:focus-visible{outline:2px solid var(--_accent)}
|
|
44
|
+
.slc-spin{animation:slc-spin 1s linear infinite}
|
|
45
|
+
@keyframes slc-spin{to{transform:rotate(360deg)}}
|
|
46
|
+
.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
|
|
47
|
+
.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
|
|
48
|
+
.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
|
|
49
|
+
.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
|
|
50
|
+
.slc-label{font-size:.875rem;color:var(--_muted)}
|
|
51
|
+
.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
|
|
52
|
+
.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
|
|
53
|
+
.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
|
|
54
|
+
.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
|
|
55
|
+
.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
|
|
56
|
+
.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
|
|
57
|
+
.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
|
|
58
|
+
.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
|
|
59
|
+
.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
|
|
60
|
+
.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
61
|
+
.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
|
|
62
|
+
.slc-item:first-child{border-top:0}
|
|
63
|
+
.slc-item-main{flex:1;min-width:0}
|
|
64
|
+
.slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}
|
|
65
|
+
.slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
66
|
+
.slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}
|
|
67
|
+
.slc-link{all:unset;cursor:pointer}
|
|
68
|
+
.slc-link:hover .slc-item-title{text-decoration:underline}
|
|
69
|
+
.slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}
|
|
70
|
+
.slc-empty{font-size:.875rem;color:var(--_muted)}
|
|
71
|
+
.slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}
|
|
72
|
+
.slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}
|
|
73
|
+
.slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}
|
|
74
|
+
.slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}
|
|
75
|
+
.slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
|
|
76
|
+
.slc-note{font-size:.75rem;color:var(--_muted)}
|
|
77
|
+
.slc-note.slc-err{color:var(--_err)}
|
|
78
|
+
.slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}
|
|
79
|
+
@keyframes slc-pulse{50%{opacity:.5}}
|
|
80
|
+
.slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}
|
|
81
|
+
.slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}
|
|
82
|
+
.slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}
|
|
83
|
+
.slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}
|
|
84
|
+
.slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}
|
|
85
|
+
.slc-todo-text{flex:1;min-width:0}
|
|
85
86
|
`;
|
|
86
87
|
let injected = false;
|
|
87
88
|
/** Add the card styles to the page once (the views call it; hosts rendering on the server can too). */
|
|
@@ -103,6 +104,20 @@ export function createAdminCardViews(React) {
|
|
|
103
104
|
function useStyles() {
|
|
104
105
|
React.useEffect(() => injectAdminCardStyles(), []);
|
|
105
106
|
}
|
|
107
|
+
/** A row's meta: an ISO timestamp reads as a short date ("12 Nov"); anything else as given. */
|
|
108
|
+
function formatMeta(meta, lang) {
|
|
109
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(meta))
|
|
110
|
+
return meta;
|
|
111
|
+
const d = new Date(meta);
|
|
112
|
+
if (Number.isNaN(d.getTime()))
|
|
113
|
+
return meta;
|
|
114
|
+
try {
|
|
115
|
+
return new Intl.DateTimeFormat(lang, { day: 'numeric', month: 'short' }).format(d);
|
|
116
|
+
}
|
|
117
|
+
catch (_a) {
|
|
118
|
+
return meta;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
106
121
|
function formatValue(v, lang) {
|
|
107
122
|
if (typeof v === 'number') {
|
|
108
123
|
try {
|
|
@@ -155,7 +170,7 @@ export function createAdminCardViews(React) {
|
|
|
155
170
|
? h('div', { className: 'slc-progress' }, h('div', { className: 'slc-bar', role: 'progressbar', 'aria-valuemin': 0, 'aria-valuemax': p.progress.total, 'aria-valuenow': p.progress.done }, h('span', { style: { width: `${Math.min(100, Math.round((p.progress.done / p.progress.total) * 100))}%` } })), h('span', null, p.progress.label || `${p.progress.done} of ${p.progress.total}`))
|
|
156
171
|
: null, items.length && !showEmpty
|
|
157
172
|
? h('ul', { className: 'slc-items' }, ...items.map((it, i) => {
|
|
158
|
-
const inner = h(React.Fragment, null, h('span', { className: 'slc-item-main' }, h('span', { className: 'slc-item-title' }, it.title), it.subtitle ? h('span', { className: 'slc-item-sub' }, it.subtitle) : null), it.meta ? h('span', { className: 'slc-item-meta' }, it.meta) : null);
|
|
173
|
+
const inner = h(React.Fragment, null, it.image ? h('img', { className: 'slc-item-img', src: it.image, alt: '', loading: 'lazy' }) : null, h('span', { className: 'slc-item-main' }, h('span', { className: 'slc-item-title' }, it.title), it.subtitle ? h('span', { className: 'slc-item-sub' }, it.subtitle) : null), it.meta ? h('span', { className: 'slc-item-meta' }, formatMeta(it.meta, lang)) : null);
|
|
159
174
|
return h('li', { key: i, className: 'slc-item' }, it.path && onAction
|
|
160
175
|
? h('button', { type: 'button', className: 'slc-link', style: { display: 'flex', alignItems: 'center', gap: 8, flex: 1, minWidth: 0 }, onClick: () => act({ label: it.title, path: it.path }) }, inner)
|
|
161
176
|
: inner);
|
package/dist/api/appObjects.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
1
2
|
import type { AppCase, CreateCaseInput, UpdateCaseInput, AppendHistoryInput, CaseSummaryRequest, CaseSummaryResponse, CaseListQueryParams, AppThread, CreateThreadInput, UpdateThreadInput, ReplyInput, ThreadListQueryParams, AppRecord, CreateRecordInput, CreateRecordResponse, UpdateRecordInput, UpsertRecordInput, UpsertRecordResponse, MatchRecordsInput, MatchResult, BulkUpsertItem, BulkUpsertResult, BulkDeleteResult, BulkDeleteInput, RecordListQueryParams, ResolveAllParams, ResolveAllResult, PreviewRuleParams, PreviewRuleResult, PaginatedResponse, AggregateRequest, AggregateResponse, RelatedResponse } from '../types/appObjects.js';
|
|
2
3
|
export declare namespace app {
|
|
3
4
|
/**
|
|
@@ -131,6 +132,31 @@ export declare namespace app {
|
|
|
131
132
|
* @see {@link updateWithToken} — use the edit token for a follow-up amendment
|
|
132
133
|
*/
|
|
133
134
|
function create(collectionId: string, appId: string, input: CreateRecordInput, admin?: boolean): Promise<CreateRecordResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* The standard query on an app's records (admin only): filter, sort, page, count and total in one
|
|
137
|
+
* call, reaching into a record's own fields by path, and following a record to its `product` and
|
|
138
|
+
* its `contact`.
|
|
139
|
+
* POST /admin/collection/:collectionId/app/:appId/records/query
|
|
140
|
+
*
|
|
141
|
+
* Fields: id, recordType, ref, status, visibility, customId, productId, variantId, batchId, proofId,
|
|
142
|
+
* contactId, authorId, parentType, parentId, createdAt, updatedAt, startsAt, expiresAt, and the
|
|
143
|
+
* documents data, owner and admin, reached by path: `"data.status"`, `"data.line.name"`.
|
|
144
|
+
*
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // How many work orders by status, and how many units on each
|
|
147
|
+
* await app.records.query(collectionId, appId, {
|
|
148
|
+
* where: { recordType: 'work_order' },
|
|
149
|
+
* groupBy: ['data.status'],
|
|
150
|
+
* aggregates: { orders: { count: true }, units: { sum: 'data.qty' } },
|
|
151
|
+
* })
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
function query(collectionId: string, appId: string, body?: StandardQuery): Promise<QueryResult>;
|
|
155
|
+
/**
|
|
156
|
+
* What a records query can use: its fields, what each can filter, sort, group or total, and its links.
|
|
157
|
+
* GET /admin/collection/:collectionId/app/:appId/records/query
|
|
158
|
+
*/
|
|
159
|
+
function queryFields(collectionId: string, appId: string): Promise<QueryDescription>;
|
|
134
160
|
/**
|
|
135
161
|
* List records with optional query parameters
|
|
136
162
|
* GET /records
|
package/dist/api/appObjects.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// src/api/appObjects.ts
|
|
2
1
|
import { request, post, patch, del, put } from '../http.js';
|
|
3
2
|
// ==================== APP NAMESPACE ====================
|
|
4
3
|
export var app;
|
|
@@ -242,6 +241,37 @@ export var app;
|
|
|
242
241
|
return post(path, input);
|
|
243
242
|
}
|
|
244
243
|
records_1.create = create;
|
|
244
|
+
/**
|
|
245
|
+
* The standard query on an app's records (admin only): filter, sort, page, count and total in one
|
|
246
|
+
* call, reaching into a record's own fields by path, and following a record to its `product` and
|
|
247
|
+
* its `contact`.
|
|
248
|
+
* POST /admin/collection/:collectionId/app/:appId/records/query
|
|
249
|
+
*
|
|
250
|
+
* Fields: id, recordType, ref, status, visibility, customId, productId, variantId, batchId, proofId,
|
|
251
|
+
* contactId, authorId, parentType, parentId, createdAt, updatedAt, startsAt, expiresAt, and the
|
|
252
|
+
* documents data, owner and admin, reached by path: `"data.status"`, `"data.line.name"`.
|
|
253
|
+
*
|
|
254
|
+
* ```typescript
|
|
255
|
+
* // How many work orders by status, and how many units on each
|
|
256
|
+
* await app.records.query(collectionId, appId, {
|
|
257
|
+
* where: { recordType: 'work_order' },
|
|
258
|
+
* groupBy: ['data.status'],
|
|
259
|
+
* aggregates: { orders: { count: true }, units: { sum: 'data.qty' } },
|
|
260
|
+
* })
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
async function query(collectionId, appId, body = {}) {
|
|
264
|
+
return post(`${basePath(collectionId, appId, true)}/query`, body);
|
|
265
|
+
}
|
|
266
|
+
records_1.query = query;
|
|
267
|
+
/**
|
|
268
|
+
* What a records query can use: its fields, what each can filter, sort, group or total, and its links.
|
|
269
|
+
* GET /admin/collection/:collectionId/app/:appId/records/query
|
|
270
|
+
*/
|
|
271
|
+
async function queryFields(collectionId, appId) {
|
|
272
|
+
return request(`${basePath(collectionId, appId, true)}/query`);
|
|
273
|
+
}
|
|
274
|
+
records_1.queryFields = queryFields;
|
|
245
275
|
/**
|
|
246
276
|
* List records with optional query parameters
|
|
247
277
|
* GET /records
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ConditionSet } from "../utils/conditions.js";
|
|
2
|
+
/** A saved condition: a named rule set pages, Hub blocks and apps refer to by id. */
|
|
3
|
+
export interface SavedCondition extends ConditionSet {
|
|
4
|
+
id: string;
|
|
5
|
+
/** What admins call it, e.g. "In the stadium". */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Switched off: it passes for everyone. */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Removed (kept, marked deleted). Lists leave these out. */
|
|
10
|
+
deleted?: boolean;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export type SaveConditionRequest = Omit<SavedCondition, "id" | "deleted">;
|
|
14
|
+
/**
|
|
15
|
+
* Saved conditions: named rule sets kept per collection (e.g. "UK only", "In the stadium"), so the same rule can be
|
|
16
|
+
* reused by id. They're checked on the device with `utils.validateCondition({ conditionId, collection })`, which
|
|
17
|
+
* loads a saved condition through `conditions.get` by itself.
|
|
18
|
+
*
|
|
19
|
+
* - Anyone can read a collection's saved conditions (`list`, `get`): they decide what a page shows.
|
|
20
|
+
* - Admins create and change them (`create`, `update`, `remove`).
|
|
21
|
+
*/
|
|
22
|
+
export declare namespace conditions {
|
|
23
|
+
/** Every saved condition in the collection (removed ones left out). */
|
|
24
|
+
function list(collectionId: string, admin?: boolean): Promise<SavedCondition[]>;
|
|
25
|
+
/**
|
|
26
|
+
* One saved condition. Public reads 404 for a removed one; an admin read returns it with `deleted: true`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const ukOnly = await conditions.get('coll_123', 'nfCmuWDY')
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function get(collectionId: string, conditionId: string, admin?: boolean): Promise<SavedCondition>;
|
|
34
|
+
/**
|
|
35
|
+
* Save a new condition (admin).
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const c = await conditions.create('coll_123', {
|
|
40
|
+
* title: 'UK only',
|
|
41
|
+
* type: 'and',
|
|
42
|
+
* conditions: [{ type: 'country', countries: ['GB'], contains: true }],
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function create(collectionId: string, data: SaveConditionRequest): Promise<SavedCondition>;
|
|
47
|
+
/** Change a saved condition (admin). Send the fields to change; `conditions` is replaced whole. */
|
|
48
|
+
function update(collectionId: string, conditionId: string, data: Partial<SaveConditionRequest>): Promise<SavedCondition>;
|
|
49
|
+
/** Remove a saved condition (admin). It's kept, marked deleted, and passes for everyone from then on. */
|
|
50
|
+
function remove(collectionId: string, conditionId: string): Promise<SavedCondition>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { request, post, put, del } from "../http.js";
|
|
2
|
+
/**
|
|
3
|
+
* Saved conditions: named rule sets kept per collection (e.g. "UK only", "In the stadium"), so the same rule can be
|
|
4
|
+
* reused by id. They're checked on the device with `utils.validateCondition({ conditionId, collection })`, which
|
|
5
|
+
* loads a saved condition through `conditions.get` by itself.
|
|
6
|
+
*
|
|
7
|
+
* - Anyone can read a collection's saved conditions (`list`, `get`): they decide what a page shows.
|
|
8
|
+
* - Admins create and change them (`create`, `update`, `remove`).
|
|
9
|
+
*/
|
|
10
|
+
export var conditions;
|
|
11
|
+
(function (conditions) {
|
|
12
|
+
const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/condition`;
|
|
13
|
+
const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/condition`;
|
|
14
|
+
/** Every saved condition in the collection (removed ones left out). */
|
|
15
|
+
async function list(collectionId, admin = false) {
|
|
16
|
+
return request(admin ? adm(collectionId) : pub(collectionId));
|
|
17
|
+
}
|
|
18
|
+
conditions.list = list;
|
|
19
|
+
/**
|
|
20
|
+
* One saved condition. Public reads 404 for a removed one; an admin read returns it with `deleted: true`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const ukOnly = await conditions.get('coll_123', 'nfCmuWDY')
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async function get(collectionId, conditionId, admin = false) {
|
|
28
|
+
return request(`${admin ? adm(collectionId) : pub(collectionId)}/${encodeURIComponent(conditionId)}`);
|
|
29
|
+
}
|
|
30
|
+
conditions.get = get;
|
|
31
|
+
/**
|
|
32
|
+
* Save a new condition (admin).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const c = await conditions.create('coll_123', {
|
|
37
|
+
* title: 'UK only',
|
|
38
|
+
* type: 'and',
|
|
39
|
+
* conditions: [{ type: 'country', countries: ['GB'], contains: true }],
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async function create(collectionId, data) {
|
|
44
|
+
return post(adm(collectionId), data);
|
|
45
|
+
}
|
|
46
|
+
conditions.create = create;
|
|
47
|
+
/** Change a saved condition (admin). Send the fields to change; `conditions` is replaced whole. */
|
|
48
|
+
async function update(collectionId, conditionId, data) {
|
|
49
|
+
return put(`${adm(collectionId)}/${encodeURIComponent(conditionId)}`, data);
|
|
50
|
+
}
|
|
51
|
+
conditions.update = update;
|
|
52
|
+
/** Remove a saved condition (admin). It's kept, marked deleted, and passes for everyone from then on. */
|
|
53
|
+
async function remove(collectionId, conditionId) {
|
|
54
|
+
return del(`${adm(collectionId)}/${encodeURIComponent(conditionId)}`);
|
|
55
|
+
}
|
|
56
|
+
conditions.remove = remove;
|
|
57
|
+
})(conditions || (conditions = {}));
|
package/dist/api/contact.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, ContactSearchParams, ContactSearchResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse, ContactSchemaResponse } from "../types/index.js";
|
|
1
|
+
import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, ContactSearchParams, ContactSearchResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse, ContactSchemaResponse, ContactDuplicatesResponse, ContactMergeResponse, ContactLinkLoginResponse } from "../types/index.js";
|
|
2
|
+
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
2
3
|
export declare namespace contact {
|
|
4
|
+
/**
|
|
5
|
+
* The standard query on contacts (admin only): filter, sort, page, count and total in one call.
|
|
6
|
+
* POST /admin/collection/:collectionId/contacts/query
|
|
7
|
+
*
|
|
8
|
+
* Fields: contactId, userId, firstName, lastName, displayName, company, email, phone, tags, source,
|
|
9
|
+
* locale, createdAt, updatedAt. Email and phone are the contact's main one. Deleted and erased
|
|
10
|
+
* contacts are never returned.
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* await contact.query(collectionId, {
|
|
14
|
+
* where: { tags: { hasAny: ['vip', 'trade'] }, createdAt: { gte: '2026-01-01' } },
|
|
15
|
+
* select: ['contactId', 'firstName', 'email'], count: true,
|
|
16
|
+
* })
|
|
17
|
+
* await contact.query(collectionId, { groupBy: ['company'], aggregates: { people: { count: true } } })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function query(collectionId: string, body?: StandardQuery): Promise<QueryResult>;
|
|
21
|
+
/**
|
|
22
|
+
* What a contacts query can use: its fields and what each can filter, sort, group or total.
|
|
23
|
+
* GET /admin/collection/:collectionId/contacts/query
|
|
24
|
+
*/
|
|
25
|
+
function queryFields(collectionId: string): Promise<QueryDescription>;
|
|
3
26
|
function create(collectionId: string, data: ContactCreateRequest): Promise<ContactResponse>;
|
|
4
27
|
function list(collectionId: string, params?: {
|
|
5
28
|
limit?: number;
|
|
@@ -50,5 +73,64 @@ export declare namespace contact {
|
|
|
50
73
|
*/
|
|
51
74
|
function publicGetSchema(collectionId: string): Promise<ContactSchemaResponse>;
|
|
52
75
|
function erase(collectionId: string, contactId: string, body?: any): Promise<ContactResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Admin: pairs of contacts that look like one person.
|
|
78
|
+
* GET /admin/collection/:collectionId/contacts/duplicates
|
|
79
|
+
*
|
|
80
|
+
* The pattern it finds: someone the collection knew by email first (an import, a list, a form) who
|
|
81
|
+
* later signed in. Their sign-in got a second contact, which could not take the email the first one
|
|
82
|
+
* already held — so one contact has the email and no sign-in, the other the sign-in (and everything
|
|
83
|
+
* they did) and no email. The match is made on the server, on verified addresses only.
|
|
84
|
+
*
|
|
85
|
+
* Checks a window of contacts per call; while `more` is true, call again with `offset` moved on by
|
|
86
|
+
* `scanned`.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const { pairs } = await contact.findDuplicates(collectionId)
|
|
91
|
+
* for (const pair of pairs) {
|
|
92
|
+
* await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId)
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
function findDuplicates(collectionId: string, params?: {
|
|
97
|
+
limit?: number;
|
|
98
|
+
offset?: number;
|
|
99
|
+
}): Promise<ContactDuplicatesResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Admin: fold contact `fromContactId` INTO contact `keepContactId`.
|
|
102
|
+
* POST /admin/collection/:collectionId/contacts/:keepContactId/merge
|
|
103
|
+
*
|
|
104
|
+
* The kept contact gains the other's sign-in, emails and phones, and anything it had no value for;
|
|
105
|
+
* its own values win. Everything recorded against the other contact moves to the kept one. Consent is
|
|
106
|
+
* never loosened: an opt-out on either contact stays an opt-out. The other contact is soft-deleted and
|
|
107
|
+
* marked with `customFields.mergedInto`.
|
|
108
|
+
*
|
|
109
|
+
* Refused (HTTP 409, `error` = a `ContactMergeErrorCode`) when the two have different sign-ins
|
|
110
|
+
* (`LOGIN_CONFLICT`) or are both members of the same loyalty scheme (`LOYALTY_CONFLICT`).
|
|
111
|
+
*/
|
|
112
|
+
function merge(collectionId: string, keepContactId: string, fromContactId: string): Promise<ContactMergeResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already
|
|
115
|
+
* holds its verified email or phone.
|
|
116
|
+
* POST /admin/collection/:collectionId/contacts/link-login
|
|
117
|
+
*
|
|
118
|
+
* For a service about to create a contact for a `userId`: call this first and only create when it
|
|
119
|
+
* throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact.
|
|
120
|
+
* The address is read from the sign-in itself and must be verified; nothing the caller says about an
|
|
121
|
+
* email is used. Never creates a contact.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* let contactId: string
|
|
126
|
+
* try {
|
|
127
|
+
* contactId = (await contact.linkLogin(collectionId, userId)).contactId
|
|
128
|
+
* } catch (err) {
|
|
129
|
+
* if (err.statusCode !== 404) throw err
|
|
130
|
+
* contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
function linkLogin(collectionId: string, userId: string): Promise<ContactLinkLoginResponse>;
|
|
53
135
|
function getUser(collectionId: string, userId: string): Promise<UserSearchResponse>;
|
|
54
136
|
}
|
package/dist/api/contact.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { request, post, del, patch } from "../http.js";
|
|
2
2
|
export var contact;
|
|
3
3
|
(function (contact) {
|
|
4
|
+
/**
|
|
5
|
+
* The standard query on contacts (admin only): filter, sort, page, count and total in one call.
|
|
6
|
+
* POST /admin/collection/:collectionId/contacts/query
|
|
7
|
+
*
|
|
8
|
+
* Fields: contactId, userId, firstName, lastName, displayName, company, email, phone, tags, source,
|
|
9
|
+
* locale, createdAt, updatedAt. Email and phone are the contact's main one. Deleted and erased
|
|
10
|
+
* contacts are never returned.
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* await contact.query(collectionId, {
|
|
14
|
+
* where: { tags: { hasAny: ['vip', 'trade'] }, createdAt: { gte: '2026-01-01' } },
|
|
15
|
+
* select: ['contactId', 'firstName', 'email'], count: true,
|
|
16
|
+
* })
|
|
17
|
+
* await contact.query(collectionId, { groupBy: ['company'], aggregates: { people: { count: true } } })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async function query(collectionId, body = {}) {
|
|
21
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/query`;
|
|
22
|
+
return post(path, body);
|
|
23
|
+
}
|
|
24
|
+
contact.query = query;
|
|
25
|
+
/**
|
|
26
|
+
* What a contacts query can use: its fields and what each can filter, sort, group or total.
|
|
27
|
+
* GET /admin/collection/:collectionId/contacts/query
|
|
28
|
+
*/
|
|
29
|
+
async function queryFields(collectionId) {
|
|
30
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/query`;
|
|
31
|
+
return request(path);
|
|
32
|
+
}
|
|
33
|
+
contact.queryFields = queryFields;
|
|
4
34
|
async function create(collectionId, data) {
|
|
5
35
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts`;
|
|
6
36
|
return post(path, data);
|
|
@@ -155,6 +185,80 @@ export var contact;
|
|
|
155
185
|
return post(path, body || {});
|
|
156
186
|
}
|
|
157
187
|
contact.erase = erase;
|
|
188
|
+
/**
|
|
189
|
+
* Admin: pairs of contacts that look like one person.
|
|
190
|
+
* GET /admin/collection/:collectionId/contacts/duplicates
|
|
191
|
+
*
|
|
192
|
+
* The pattern it finds: someone the collection knew by email first (an import, a list, a form) who
|
|
193
|
+
* later signed in. Their sign-in got a second contact, which could not take the email the first one
|
|
194
|
+
* already held — so one contact has the email and no sign-in, the other the sign-in (and everything
|
|
195
|
+
* they did) and no email. The match is made on the server, on verified addresses only.
|
|
196
|
+
*
|
|
197
|
+
* Checks a window of contacts per call; while `more` is true, call again with `offset` moved on by
|
|
198
|
+
* `scanned`.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* const { pairs } = await contact.findDuplicates(collectionId)
|
|
203
|
+
* for (const pair of pairs) {
|
|
204
|
+
* await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId)
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
async function findDuplicates(collectionId, params) {
|
|
209
|
+
const query = new URLSearchParams();
|
|
210
|
+
if ((params === null || params === void 0 ? void 0 : params.limit) !== undefined)
|
|
211
|
+
query.set("limit", String(params.limit));
|
|
212
|
+
if ((params === null || params === void 0 ? void 0 : params.offset) !== undefined)
|
|
213
|
+
query.set("offset", String(params.offset));
|
|
214
|
+
const qs = query.toString();
|
|
215
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/duplicates${qs ? `?${qs}` : ""}`;
|
|
216
|
+
return request(path);
|
|
217
|
+
}
|
|
218
|
+
contact.findDuplicates = findDuplicates;
|
|
219
|
+
/**
|
|
220
|
+
* Admin: fold contact `fromContactId` INTO contact `keepContactId`.
|
|
221
|
+
* POST /admin/collection/:collectionId/contacts/:keepContactId/merge
|
|
222
|
+
*
|
|
223
|
+
* The kept contact gains the other's sign-in, emails and phones, and anything it had no value for;
|
|
224
|
+
* its own values win. Everything recorded against the other contact moves to the kept one. Consent is
|
|
225
|
+
* never loosened: an opt-out on either contact stays an opt-out. The other contact is soft-deleted and
|
|
226
|
+
* marked with `customFields.mergedInto`.
|
|
227
|
+
*
|
|
228
|
+
* Refused (HTTP 409, `error` = a `ContactMergeErrorCode`) when the two have different sign-ins
|
|
229
|
+
* (`LOGIN_CONFLICT`) or are both members of the same loyalty scheme (`LOYALTY_CONFLICT`).
|
|
230
|
+
*/
|
|
231
|
+
async function merge(collectionId, keepContactId, fromContactId) {
|
|
232
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/${encodeURIComponent(keepContactId)}/merge`;
|
|
233
|
+
return post(path, { fromContactId });
|
|
234
|
+
}
|
|
235
|
+
contact.merge = merge;
|
|
236
|
+
/**
|
|
237
|
+
* Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already
|
|
238
|
+
* holds its verified email or phone.
|
|
239
|
+
* POST /admin/collection/:collectionId/contacts/link-login
|
|
240
|
+
*
|
|
241
|
+
* For a service about to create a contact for a `userId`: call this first and only create when it
|
|
242
|
+
* throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact.
|
|
243
|
+
* The address is read from the sign-in itself and must be verified; nothing the caller says about an
|
|
244
|
+
* email is used. Never creates a contact.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* let contactId: string
|
|
249
|
+
* try {
|
|
250
|
+
* contactId = (await contact.linkLogin(collectionId, userId)).contactId
|
|
251
|
+
* } catch (err) {
|
|
252
|
+
* if (err.statusCode !== 404) throw err
|
|
253
|
+
* contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
async function linkLogin(collectionId, userId) {
|
|
258
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/link-login`;
|
|
259
|
+
return post(path, { userId });
|
|
260
|
+
}
|
|
261
|
+
contact.linkLogin = linkLogin;
|
|
158
262
|
// get user
|
|
159
263
|
async function getUser(collectionId, userId) {
|
|
160
264
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/owner/${encodeURIComponent(userId)}`;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export { async } from "./async.js";
|
|
|
24
24
|
export { jobs } from "./jobs.js";
|
|
25
25
|
export { segments } from "./segments.js";
|
|
26
26
|
export { userGroups } from "./userGroups.js";
|
|
27
|
+
export { conditions } from "./conditions.js";
|
|
27
28
|
export { operations } from "./operations.js";
|
|
28
29
|
export { journeys } from "./journeys.js";
|
|
29
30
|
export { journeysAnalytics } from "./journeysAnalytics.js";
|
package/dist/api/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { async } from "./async.js";
|
|
|
26
26
|
export { jobs } from "./jobs.js";
|
|
27
27
|
export { segments } from "./segments.js";
|
|
28
28
|
export { userGroups } from "./userGroups.js";
|
|
29
|
+
export { conditions } from "./conditions.js";
|
|
29
30
|
export { operations } from "./operations.js";
|
|
30
31
|
export { journeys } from "./journeys.js";
|
|
31
32
|
export { journeysAnalytics } from "./journeysAnalytics.js";
|