@whoa-chat/core 0.3.0 → 0.3.1
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/LICENSE +14 -0
- package/dist/src/appearance.d.ts +0 -14
- package/dist/src/appearance.js +1 -1
- package/dist/src/brand.d.ts +0 -9
- package/dist/src/cardTree.d.ts +0 -15
- package/dist/src/conversation.d.ts +0 -8
- package/dist/src/dashboard.d.ts +5 -8
- package/dist/src/eventNote.d.ts +0 -1
- package/dist/src/links.d.ts +0 -12
- package/dist/src/mentions.d.ts +0 -4
- package/dist/src/panels.d.ts +13 -9
- package/dist/src/panels.js +1 -1
- package/dist/src/types.d.ts +1 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (c) 2026 Super Simple Co. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This package is proprietary. It is not open source.
|
|
4
|
+
|
|
5
|
+
You may use it only in your own apps, only to connect them to Whoa Chat
|
|
6
|
+
(https://whoa.chat), and only while your Whoa Chat workspace is active, under
|
|
7
|
+
the Whoa Chat terms of service: https://whoa.chat/terms/
|
|
8
|
+
|
|
9
|
+
You may not copy, modify, redistribute or sublicense it, use it with any other
|
|
10
|
+
service, or decompile or reverse-engineer it, except where the law allows it
|
|
11
|
+
regardless of these terms. In particular you may not use it, in whole or in
|
|
12
|
+
part, to build or train a product that competes with Whoa Chat.
|
|
13
|
+
|
|
14
|
+
THE PACKAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
package/dist/src/appearance.d.ts
CHANGED
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
export type AppearanceColors = {
|
|
2
|
-
/** The chat's accent: the merchant's own bubbles, the send button and links (merchant view only). */
|
|
3
2
|
accent?: string;
|
|
4
|
-
/** The button that opens the chat in the app's admin. */
|
|
5
3
|
launcher?: string;
|
|
6
|
-
/** The website widget's launcher, send button and highlights. */
|
|
7
4
|
widgetAccent?: string;
|
|
8
5
|
};
|
|
9
6
|
export type Appearance = {
|
|
10
7
|
colors?: AppearanceColors;
|
|
11
|
-
/** Per language: replacements for the curated keys below (chat keys as in the locales, widget keys as "widget.<key>"). */
|
|
12
8
|
texts?: Record<string, Record<string, string>>;
|
|
13
9
|
};
|
|
14
10
|
export declare const COLOR_KEYS: readonly ["accent", "launcher", "widgetAccent"];
|
|
15
|
-
/** The chat's languages (packages/react/locales). */
|
|
16
11
|
export declare const CHAT_LANGS: readonly ["en", "bg", "da", "de", "es", "fr", "it", "ja", "nl", "pl", "pt-BR", "pt-PT", "sv", "zh-CN", "zh-TW"];
|
|
17
|
-
/** The widget's languages (widget.js). */
|
|
18
12
|
export declare const WIDGET_LANGS: readonly ["en", "de", "fr", "es", "it", "nl", "pt", "bg"];
|
|
19
13
|
export type TextKey = {
|
|
20
14
|
key: string;
|
|
21
15
|
label: string;
|
|
22
16
|
help: string;
|
|
23
17
|
};
|
|
24
|
-
/** The merchant-facing chat strings a workspace may reword. */
|
|
25
18
|
export declare const CHAT_TEXT_KEYS: TextKey[];
|
|
26
|
-
/** The website widget's texts a workspace may reword (stored as "widget.<key>"). */
|
|
27
19
|
export declare const WIDGET_TEXT_KEYS: TextKey[];
|
|
28
|
-
/** Only known colours (6-digit hex), languages and keys, each text bounded: the registry item may be edited by hand. */
|
|
29
20
|
export declare const cleanAppearance: (raw: unknown) => Appearance | undefined;
|
|
30
21
|
export declare const contrast: (a: string, b: string) => number;
|
|
31
|
-
/** White or near-black, whichever reads better on the colour. */
|
|
32
22
|
export declare const textOn: (hex: string) => "#16131d" | "#ffffff";
|
|
33
|
-
/** Whether text on the colour meets WCAG AA (4.5:1). */
|
|
34
23
|
export declare const readable: (hex: string) => boolean;
|
|
35
|
-
/** A hover shade: a little darker (or lighter for a dark colour). */
|
|
36
24
|
export declare const hoverOf: (hex: string) => string;
|
|
37
|
-
/** The colour darkened until it reads on white at AA, for links. */
|
|
38
25
|
export declare const linkOn: (hex: string, bg?: string) => string;
|
|
39
|
-
/** The chat's CSS variables for a workspace's colours; empty when none are set, so nothing changes. */
|
|
40
26
|
export declare const chatColorVars: (colors: AppearanceColors | undefined) => Record<string, string>;
|
package/dist/src/appearance.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const T=["accent","launcher","widgetAccent"],x=["en","bg","da","de","es","fr","it","ja","nl","pl","pt-BR","pt-PT","sv","zh-CN","zh-TW"],A=["en","de","fr","es","it","nl","pt","bg"],C=[{key:"supportChat.emptyTitle",label:"Empty chat title",help:"The heading before the first message."},{key:"supportChat.emptyBody",label:"Empty chat text",help:"Who answers and how fast, under that heading."},{key:"supportChat.emptyBodyShort",label:"Empty chat text, short",help:"The shorter version in small chat windows."},{key:"supportChat.placeholder",label:"Message box",help:"The hint in the box the merchant types in."},{key:"supportChat.launcher.replyTime",label:"Reply time",help:"Shown under the chat's title."},{key:"supportChat.launcher.team",label:"Team line",help:"Who is there to help."},{key:"supportChat.launcher.open",label:"Open button label",help:"Read out by screen readers on the launcher."},{key:"supportChat.availability.away",label:"Away",help:"When nobody on the team is online."},{key:"supportChat.availability.backSoon",label:"Back soon",help:"When the team is on a short break."},{key:"supportChat.availability.tip",label:"Tip while away",help:"What to include so the team can answer faster."},{key:"supportChat.preview.fromTeam",label:"Team byline",help:"Under the team's cards. {{app}} is your app's name."},{key:"supportChat.preview.helpPerks",label:"Help offer note",help:"A line under the offer of help."},{key:"supportChat.inbox.helpDefault",label:"Setup help offer",help:"The offer's message when the teammate writes none."},{key:"supportChat.helpOffer.yes",label:"Accept help button",help:"On the offer of setup help."},{key:"supportChat.helpOffer.no",label:"Decline help button",help:"On the offer of setup help."},{key:"supportChat.review.title",label:"Review card title",help:"The ask for an App Store review."},{key:"supportChat.review.body",label:"Review card text",help:"Why a review helps."},{key:"supportChat.review.cta",label:"Review button",help:"Opens your App Store listing."},{key:"supportChat.review.thanks",label:"Review thanks",help:"After they open the review page."},{key:"supportChat.review.thanksCopy",label:"Review thanks text",help:"{{agent}} is the teammate who asked."}],v=[{key:"widget.launcher",label:"Launcher",help:"The button on your site."},{key:"widget.title",label:"Title",help:"At the top of the panel."},{key:"widget.intro",label:"Greeting",help:"The first message a visitor sees."},{key:"widget.placeholder",label:"Question box",help:"The hint in the box."},{key:"widget.note",label:"AI note",help:"Under the box, about where answers come from."},{key:"widget.talk",label:"Talk to the team link",help:"Hands the visitor to your team."},{key:"widget.teamPlaceholder",label:"Message to the team box",help:"Once they write to your team."},{key:"widget.teamNote",label:"AI used up",help:"When the visitor's AI questions are used up."},{key:"widget.sentTeam",label:"Sent to the team",help:"After a message to your team."},{key:"widget.emailAsk",label:"Email ask",help:"Asks for an address to reply to."},{key:"widget.limit",label:"Last question",help:"After the visitor's last AI question."},{key:"widget.already",label:"Already a customer",help:"The link to the chat inside your app."}],R=new Set(C.map(e=>e.key)),O=new Set(v.map(e=>e.key)),S=/^#[0-9a-f]{6}$/,E=300,I=e=>{if(!e||typeof e!="object")return;const t=e,n={},a=t.colors??{},s={};for(const r of T){const l=typeof a[r]=="string"?a[r].trim().toLowerCase():"";S.test(l)&&(s[r]=l)}Object.keys(s).length&&(n.colors=s);const o=t.texts??{},p={};for(const[r,l]of Object.entries(o).slice(0,30)){const f=x.includes(r),k=A.includes(r);if(!f&&!k||!l||typeof l!="object")continue;const c={};for(const[u,y]of Object.entries(l).slice(0,80))typeof y!="string"||!y.trim()||(f&&R.has(u)||k&&O.has(u))&&(c[u]=y.trim().slice(0,E));Object.keys(c).length&&(p[r]=c)}return Object.keys(p).length&&(n.texts=p),Object.keys(n).length?n:void 0},W=e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},d=e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)),g=e=>{const[t,n,a]=d(e).map(W);return .2126*t+.7152*n+.0722*a},i=(e,t)=>{const[n,a]=[g(e),g(t)].sort((s,o)=>o-s);return(n+.05)/(a+.05)},m="#16131d",h="#ffffff",b=e=>i(e,h)>=i(e,m)?h:m,K=e=>i(e,b(e))>=4.5,w=(e,t,n)=>{const a=d(e),s=d(t);return`#${a.map((o,p)=>Math.round(o+(s[p]-o)*n).toString(16).padStart(2,"0")).join("")}`},j=e=>w(e,g(e)>.2?"#000000":h,.12),_=(e,t=h)=>{let n=e;for(let a=0;a<12&&i(n,t)<4.5;a++)n=w(n,"#000000",.15);return n},H=e=>{const t={};return e?.accent&&(t["--sc-accent"]=e.accent,t["--sc-on-accent"]=b(e.accent),t["--sc-accent-hover"]=j(e.accent),t["--sc-accent-link"]=_(e.accent)),e?.launcher&&(t["--sc-launcher"]=e.launcher,t["--sc-on-launcher"]=b(e.launcher)),t};export{x as CHAT_LANGS,C as CHAT_TEXT_KEYS,T as COLOR_KEYS,A as WIDGET_LANGS,v as WIDGET_TEXT_KEYS,H as chatColorVars,I as cleanAppearance,i as contrast,j as hoverOf,_ as linkOn,K as readable,b as textOn};
|
|
1
|
+
const T=["accent","launcher","widgetAccent"],x=["en","bg","da","de","es","fr","it","ja","nl","pl","pt-BR","pt-PT","sv","zh-CN","zh-TW"],A=["en","de","fr","es","it","nl","pt","bg"],C=[{key:"supportChat.emptyTitle",label:"Empty chat title",help:"The heading before the first message."},{key:"supportChat.emptyBody",label:"Empty chat text",help:"Who answers and how fast, under that heading. {{team}} is your support team's name."},{key:"supportChat.emptyBodyShort",label:"Empty chat text, short",help:"The shorter version in small chat windows."},{key:"supportChat.placeholder",label:"Message box",help:"The hint in the box the merchant types in."},{key:"supportChat.launcher.replyTime",label:"Reply time",help:"Shown under the chat's title."},{key:"supportChat.launcher.team",label:"Team line",help:"Who is there to help."},{key:"supportChat.launcher.open",label:"Open button label",help:"Read out by screen readers on the launcher."},{key:"supportChat.availability.away",label:"Away",help:"When nobody on the team is online."},{key:"supportChat.availability.backSoon",label:"Back soon",help:"When the team is on a short break."},{key:"supportChat.availability.tip",label:"Tip while away",help:"What to include so the team can answer faster."},{key:"supportChat.preview.fromTeam",label:"Team byline",help:"Under the team's cards. {{app}} is your app's name."},{key:"supportChat.preview.helpPerks",label:"Help offer note",help:"A line under the offer of help."},{key:"supportChat.inbox.helpDefault",label:"Setup help offer",help:"The offer's message when the teammate writes none."},{key:"supportChat.helpOffer.yes",label:"Accept help button",help:"On the offer of setup help."},{key:"supportChat.helpOffer.no",label:"Decline help button",help:"On the offer of setup help."},{key:"supportChat.review.title",label:"Review card title",help:"The ask for an App Store review."},{key:"supportChat.review.body",label:"Review card text",help:"Why a review helps."},{key:"supportChat.review.cta",label:"Review button",help:"Opens your App Store listing."},{key:"supportChat.review.thanks",label:"Review thanks",help:"After they open the review page."},{key:"supportChat.review.thanksCopy",label:"Review thanks text",help:"{{agent}} is the teammate who asked."}],v=[{key:"widget.launcher",label:"Launcher",help:"The button on your site."},{key:"widget.title",label:"Title",help:"At the top of the panel."},{key:"widget.intro",label:"Greeting",help:"The first message a visitor sees."},{key:"widget.placeholder",label:"Question box",help:"The hint in the box."},{key:"widget.note",label:"AI note",help:"Under the box, about where answers come from."},{key:"widget.talk",label:"Talk to the team link",help:"Hands the visitor to your team."},{key:"widget.teamPlaceholder",label:"Message to the team box",help:"Once they write to your team."},{key:"widget.teamNote",label:"AI used up",help:"When the visitor's AI questions are used up."},{key:"widget.sentTeam",label:"Sent to the team",help:"After a message to your team."},{key:"widget.emailAsk",label:"Email ask",help:"Asks for an address to reply to."},{key:"widget.limit",label:"Last question",help:"After the visitor's last AI question."},{key:"widget.already",label:"Already a customer",help:"The link to the chat inside your app."}],R=new Set(C.map(e=>e.key)),O=new Set(v.map(e=>e.key)),S=/^#[0-9a-f]{6}$/,E=300,I=e=>{if(!e||typeof e!="object")return;const t=e,n={},a=t.colors??{},s={};for(const r of T){const l=typeof a[r]=="string"?a[r].trim().toLowerCase():"";S.test(l)&&(s[r]=l)}Object.keys(s).length&&(n.colors=s);const o=t.texts??{},p={};for(const[r,l]of Object.entries(o).slice(0,30)){const f=x.includes(r),k=A.includes(r);if(!f&&!k||!l||typeof l!="object")continue;const c={};for(const[u,y]of Object.entries(l).slice(0,80))typeof y!="string"||!y.trim()||(f&&R.has(u)||k&&O.has(u))&&(c[u]=y.trim().slice(0,E));Object.keys(c).length&&(p[r]=c)}return Object.keys(p).length&&(n.texts=p),Object.keys(n).length?n:void 0},W=e=>{const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},d=e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)),g=e=>{const[t,n,a]=d(e).map(W);return .2126*t+.7152*n+.0722*a},i=(e,t)=>{const[n,a]=[g(e),g(t)].sort((s,o)=>o-s);return(n+.05)/(a+.05)},m="#16131d",h="#ffffff",b=e=>i(e,h)>=i(e,m)?h:m,K=e=>i(e,b(e))>=4.5,w=(e,t,n)=>{const a=d(e),s=d(t);return`#${a.map((o,p)=>Math.round(o+(s[p]-o)*n).toString(16).padStart(2,"0")).join("")}`},j=e=>w(e,g(e)>.2?"#000000":h,.12),_=(e,t=h)=>{let n=e;for(let a=0;a<12&&i(n,t)<4.5;a++)n=w(n,"#000000",.15);return n},H=e=>{const t={};return e?.accent&&(t["--sc-accent"]=e.accent,t["--sc-on-accent"]=b(e.accent),t["--sc-accent-hover"]=j(e.accent),t["--sc-accent-link"]=_(e.accent)),e?.launcher&&(t["--sc-launcher"]=e.launcher,t["--sc-on-launcher"]=b(e.launcher)),t};export{x as CHAT_LANGS,C as CHAT_TEXT_KEYS,T as COLOR_KEYS,A as WIDGET_LANGS,v as WIDGET_TEXT_KEYS,H as chatColorVars,I as cleanAppearance,i as contrast,j as hoverOf,_ as linkOn,K as readable,b as textOn};
|
package/dist/src/brand.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
/** How a workspace names itself to merchants: its app, its support team and its AI. Workspace data, never code. */
|
|
2
1
|
export type Brand = {
|
|
3
|
-
/** The app's short name, as merchants say it ("Open Acme from your Shopify admin"). */
|
|
4
2
|
app: string;
|
|
5
|
-
/** The app's full name, as listed in the App Store (email footers, AI prompts). */
|
|
6
3
|
appFull: string;
|
|
7
|
-
/** The support team's name (email senders, cards, "replied to your chat with ..."). */
|
|
8
4
|
team: string;
|
|
9
|
-
/** The AI's name on its messages. */
|
|
10
5
|
bot: string;
|
|
11
|
-
/** The AI as the team and merchants call it ("Hand to ..."). */
|
|
12
6
|
botFull: string;
|
|
13
|
-
/** The app's icon: an absolute URL, or a path the host serves. */
|
|
14
7
|
logo: string;
|
|
15
8
|
};
|
|
16
|
-
/** Until a workspace sets its own: plain words, no product name. */
|
|
17
9
|
export declare const NEUTRAL_BRAND: Brand;
|
|
18
|
-
/** A stored brand with every field filled in (short or missing ones fall back to the neutral words). */
|
|
19
10
|
export declare const brandOf: (b: Partial<Brand> | null | undefined) => Brand;
|
package/dist/src/cardTree.d.ts
CHANGED
|
@@ -2,20 +2,14 @@ export type CardBlock = "card" | "title" | "text" | "stat" | "row" | "list" | "i
|
|
|
2
2
|
export type CardTone = "neutral" | "good" | "warn" | "bad" | "accent" | "gradient";
|
|
3
3
|
export type CardNode = {
|
|
4
4
|
t: CardBlock;
|
|
5
|
-
/** Words this block shows (title, text, stat label, badge, button, list item). */
|
|
6
5
|
text?: string;
|
|
7
|
-
/** A stat's value, or an item's value on the right. */
|
|
8
6
|
value?: string;
|
|
9
|
-
/** A small line under a stat or item. */
|
|
10
7
|
hint?: string;
|
|
11
8
|
tone?: CardTone;
|
|
12
|
-
/** An https link: the button opens it; an image shows it. */
|
|
13
9
|
href?: string;
|
|
14
10
|
src?: string;
|
|
15
11
|
alt?: string;
|
|
16
|
-
/** A meter's fill, 0 to 100. */
|
|
17
12
|
fill?: number;
|
|
18
|
-
/** How it looks, from a fixed set of checked values (never raw CSS). */
|
|
19
13
|
style?: CardStyle;
|
|
20
14
|
children?: CardNode[];
|
|
21
15
|
};
|
|
@@ -26,30 +20,21 @@ export type CardStyle = {
|
|
|
26
20
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
27
21
|
weight?: "regular" | "medium" | "bold";
|
|
28
22
|
align?: "start" | "center" | "end";
|
|
29
|
-
/** A box's layout: its children in a row or a column, spread how, lined up how. */
|
|
30
23
|
direction?: "row" | "column";
|
|
31
24
|
justify?: "start" | "center" | "end" | "between";
|
|
32
25
|
items?: "start" | "center" | "end" | "stretch";
|
|
33
26
|
padding?: number;
|
|
34
27
|
gap?: number;
|
|
35
28
|
radius?: number;
|
|
36
|
-
/** Takes the room left in a row. */
|
|
37
29
|
grow?: boolean;
|
|
38
|
-
/** An image's size in px. */
|
|
39
30
|
width?: number;
|
|
40
31
|
height?: number;
|
|
41
32
|
};
|
|
42
33
|
export declare const CARD_BLOCKS: CardBlock[];
|
|
43
|
-
/** The style props a block was given, each checked; anything else is dropped. */
|
|
44
34
|
export declare const cleanCardStyle: (o: Record<string, unknown>) => CardStyle | undefined;
|
|
45
|
-
/** The card as drawn, or null when it is not one: a "card" at the top, known blocks only, bounded in size. */
|
|
46
35
|
export declare const cleanCardTree: (raw: unknown) => CardNode | null;
|
|
47
|
-
/** A card's words in one line, for the conversation list and notifications. */
|
|
48
36
|
export declare const cardSummary: (tree: CardNode) => string;
|
|
49
37
|
export type AdminThing = "order" | "subscription" | "product" | "variant" | "customer";
|
|
50
38
|
export declare const ADMIN_THINGS: AdminThing[];
|
|
51
|
-
/** The id in what was typed: a number of 9 or more digits, or a gid. */
|
|
52
39
|
export declare const adminId: (typed: string) => string | null;
|
|
53
|
-
/** The built-in card for one order, product or customer, opening it in the store's Shopify admin: by its id when
|
|
54
|
-
* given one (a long number), else as a search there for what was typed (an order number, a name). */
|
|
55
40
|
export declare const adminLinkCard: (store: string, thing: AdminThing, ref: string) => CardNode | null;
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
export declare const SHOP_DOMAIN: RegExp;
|
|
2
|
-
/** An app's short key inside its workspace (letters and digits); the first app has none. */
|
|
3
2
|
export declare const APP_KEY: RegExp;
|
|
4
|
-
/** A conversation with a store, whichever app it is for. */
|
|
5
3
|
export declare const STORE_THREAD: {
|
|
6
4
|
test: (id: string) => boolean;
|
|
7
5
|
};
|
|
8
|
-
/** The conversation id for a store and an app (null: the workspace's first app). */
|
|
9
6
|
export declare const conversationId: (shop: string, appKey?: string | null) => string;
|
|
10
|
-
/** The store and app key of a conversation id; null when it is not a store conversation. */
|
|
11
7
|
export declare const parseConversation: (id: string) => {
|
|
12
8
|
shop: string;
|
|
13
9
|
app: string | null;
|
|
14
10
|
} | null;
|
|
15
|
-
/** The store's myshopify domain behind a conversation id (the id itself when it is not a store conversation). */
|
|
16
11
|
export declare const storeOf: (id: string) => string;
|
|
17
|
-
/** The app key of a conversation id; null for the first app and for mail-/web- conversations. */
|
|
18
12
|
export declare const appKeyOf: (id: string) => string | null;
|
|
19
|
-
/** A short key from an app's name, unique among the keys already taken. */
|
|
20
13
|
export declare const newAppKey: (name: string, taken: Iterable<string>) => string;
|
|
21
|
-
/** Items scoped to apps (saved replies, connectors: app keys, "-" the first app; empty: every app) for one app. */
|
|
22
14
|
export declare const forApp: <T extends {
|
|
23
15
|
apps?: string[];
|
|
24
16
|
}>(items: T[], appKey: string) => T[];
|
package/dist/src/dashboard.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** A change since the day before; better says which way is good (a rank is better down). */
|
|
2
1
|
export type DashChange = {
|
|
3
2
|
by: number;
|
|
4
3
|
better: "up" | "down";
|
|
@@ -6,18 +5,17 @@ export type DashChange = {
|
|
|
6
5
|
export type DashRow = {
|
|
7
6
|
label: string;
|
|
8
7
|
value: string;
|
|
9
|
-
change?: DashChange | null;
|
|
8
|
+
change?: DashChange | null;
|
|
10
9
|
focus?: string;
|
|
11
10
|
};
|
|
12
11
|
export type DashTable = {
|
|
13
12
|
columns: string[];
|
|
14
13
|
rows: {
|
|
15
|
-
cells: string[];
|
|
16
|
-
shop?: string;
|
|
17
|
-
aside?: string;
|
|
14
|
+
cells: string[];
|
|
15
|
+
shop?: string;
|
|
16
|
+
aside?: string;
|
|
18
17
|
extra?: boolean;
|
|
19
18
|
}[];
|
|
20
|
-
/** The toggle's two labels when some rows are extra: to show them, and to hide them again. */
|
|
21
19
|
more?: {
|
|
22
20
|
show: string;
|
|
23
21
|
hide: string;
|
|
@@ -68,7 +66,7 @@ export type DashBlock = {
|
|
|
68
66
|
}[];
|
|
69
67
|
}[];
|
|
70
68
|
} | ({
|
|
71
|
-
type: "bars";
|
|
69
|
+
type: "bars";
|
|
72
70
|
table?: DashTable;
|
|
73
71
|
} & DashBars) | ({
|
|
74
72
|
type: "table";
|
|
@@ -82,5 +80,4 @@ export type Dashboard = {
|
|
|
82
80
|
asOf?: string | null;
|
|
83
81
|
blocks: DashBlock[];
|
|
84
82
|
};
|
|
85
|
-
/** Whatever an app sent, cut to blocks the inbox can draw: known types and fields, capped, store links to stores only. */
|
|
86
83
|
export declare const cleanDashboard: (raw: unknown) => Dashboard | null;
|
package/dist/src/eventNote.d.ts
CHANGED
|
@@ -9,5 +9,4 @@ export type ChatEvent = {
|
|
|
9
9
|
fields: ChatEventField[];
|
|
10
10
|
};
|
|
11
11
|
export declare const eventTypeFor: (title: string) => string;
|
|
12
|
-
/** Null when the text is not shaped like a lifecycle note. */
|
|
13
12
|
export declare const parseEventNote: (text: string, type?: string) => ChatEvent | null;
|
package/dist/src/links.d.ts
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
|
-
/** [label](https://...): only http(s), so a label can never hide a javascript: or file: link. */
|
|
2
1
|
export declare const MD_LINK: RegExp;
|
|
3
|
-
/** A pasted string that is one web address, and nothing else. */
|
|
4
2
|
export declare const isUrl: (s: string) => boolean;
|
|
5
|
-
/** The words a link stands for, for previews and plain text: "[the guide](https://...)" reads "the guide". */
|
|
6
3
|
export declare const linkLabels: (text: string) => string;
|
|
7
|
-
/** A link as the text stores it: its label in brackets, or the address alone. */
|
|
8
4
|
export declare const linkToken: (url: string, label?: string | null) => string;
|
|
9
|
-
/** A shortcut the workspace saved for the composer's link button. */
|
|
10
5
|
export type SavedLink = {
|
|
11
6
|
name: string;
|
|
12
7
|
url: string;
|
|
13
8
|
};
|
|
14
|
-
/** The workspace's saved links as stored: https only, named, at most 50, no repeats. */
|
|
15
9
|
export declare const cleanLinks: (raw: unknown) => SavedLink[];
|
|
16
|
-
/** One entry in the link button's list. group: where it opens (the workspace's own, its app, Shopify). */
|
|
17
10
|
export type LinkShortcut = {
|
|
18
11
|
label: string;
|
|
19
12
|
url: string;
|
|
20
13
|
group: "saved" | "app" | "shopify";
|
|
21
14
|
};
|
|
22
15
|
export declare const SHOPIFY_ADMIN_LINKS: LinkShortcut[];
|
|
23
|
-
/** A page of the workspace's own app, by its handle in the admin (admin.shopify.com/apps/<handle>). */
|
|
24
16
|
export declare const appPageUrl: (handle: string, path: string) => string;
|
|
25
|
-
/** How an app's admin pages read as a link badge: a path segment, its name, and the name of one item's page
|
|
26
|
-
* ({id} fills in the number, e.g. "#{id}"). Set per app in Settings. */
|
|
27
17
|
export type AppLinkPage = {
|
|
28
18
|
segment: string;
|
|
29
19
|
name: string;
|
|
30
20
|
item?: string;
|
|
31
21
|
};
|
|
32
|
-
/** One app's pages as the chat names them: its handle in admin.shopify.com/apps/<handle>, its name and logo. */
|
|
33
22
|
export type AppLinks = {
|
|
34
23
|
handle: string;
|
|
35
24
|
name: string;
|
|
36
25
|
logo?: string;
|
|
37
26
|
pages: AppLinkPage[];
|
|
38
27
|
};
|
|
39
|
-
/** Only well-formed rows, each value bounded (the list may be edited by hand or over MCP). */
|
|
40
28
|
export declare const cleanAppPages: (raw: unknown) => AppLinkPage[];
|
package/dist/src/mentions.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
/** The teammate a draft starts with ("@shekhar ..." or "Shekhar, ..."): such a draft is a private note to them. */
|
|
2
1
|
export declare const noteTarget: (text: string, agents: string[]) => string | null;
|
|
3
|
-
/** Every teammate named anywhere in a note, with or without @. */
|
|
4
2
|
export declare const mentionsIn: (text: string, agents: string[]) => string[];
|
|
5
|
-
/** A note split into plain text and mentions, for drawing the mentions as chips. */
|
|
6
3
|
export declare const splitMentions: (text: string, agents: string[]) => {
|
|
7
4
|
text: string;
|
|
8
5
|
agent?: string;
|
|
9
6
|
}[];
|
|
10
|
-
/** The "@sh" being typed at the end of a draft, for suggesting teammates. */
|
|
11
7
|
export declare const typingMention: (text: string) => string | null;
|
package/dist/src/panels.d.ts
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
/** A chip in a fact row: an app, a tag, a plan. The icon is an https image, drawn small. */
|
|
2
1
|
export type FactChip = {
|
|
3
2
|
label: string;
|
|
4
3
|
icon?: string | null;
|
|
5
4
|
muted?: boolean;
|
|
6
5
|
};
|
|
7
|
-
/** One row of the store panel: a label, then plain text, a strong line with detail, or chips. */
|
|
8
6
|
export type FactRow = {
|
|
9
7
|
label: string;
|
|
10
8
|
text?: string;
|
|
11
9
|
strong?: string;
|
|
12
10
|
chips?: FactChip[];
|
|
13
|
-
/** Shown when chips is an empty list, such as "None found". */
|
|
14
11
|
empty?: string;
|
|
15
12
|
};
|
|
16
|
-
/** The connector's storePanel answer, about one store. */
|
|
17
13
|
export type StorePanel = {
|
|
18
14
|
rows: FactRow[];
|
|
19
|
-
/** When the store last had the app open. */
|
|
20
15
|
lastSeenAt?: string | null;
|
|
21
|
-
/** The storefront page the store's name opens. */
|
|
22
16
|
storefrontUrl?: string | null;
|
|
17
|
+
fields?: Record<string, string>;
|
|
23
18
|
};
|
|
24
|
-
|
|
19
|
+
export type CustomField = {
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
type: "text" | "number" | "money" | "link";
|
|
23
|
+
currency?: string;
|
|
24
|
+
from: "team" | "app";
|
|
25
|
+
};
|
|
26
|
+
export declare const FIELD_TYPES: readonly ["text", "number", "money", "link"];
|
|
27
|
+
export declare const fieldKey: (label: string) => string;
|
|
28
|
+
export declare const cleanCustomFields: (raw: unknown) => CustomField[];
|
|
29
|
+
export declare const cleanFieldValue: (field: CustomField, raw: unknown) => string | null | undefined;
|
|
30
|
+
export declare const formatField: (field: CustomField, value: string, locale?: string) => string;
|
|
25
31
|
export declare const cleanStorePanel: (raw: unknown) => StorePanel;
|
|
26
|
-
/** A store's standing as its app sees it (set up, half done, not yet): a dot on its avatar, the label on hover. */
|
|
27
32
|
export type StoreStatus = {
|
|
28
33
|
tone: "good" | "partial" | "none";
|
|
29
34
|
label: string;
|
|
30
35
|
};
|
|
31
|
-
/** The connector's storeStatus answer, kept to the stores asked about. */
|
|
32
36
|
export declare const cleanStoreStatuses: (raw: unknown, shops: string[]) => Record<string, StoreStatus>;
|
package/dist/src/panels.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const u=(t,n)=>typeof t=="string"&&t.trim()?t.trim().slice(0,n):void 0,a=t=>typeof t=="string"&&/^https:\/\/[^\s"'<>]+$/.test(t)&&t.length<1e3?t:null,k=["text","number","money","link"],y=/^[a-z0-9][a-z0-9-]{0,39}$/,F=t=>t.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),h=t=>{const n=[];for(const o of Array.isArray(t)?t.slice(0,20):[]){const e=o&&typeof o=="object"?o:{},r=u(e.label,40),s=typeof e.key=="string"&&y.test(e.key)?e.key:r?F(r):"";if(!r||!y.test(s)||n.some(i=>i.key===s))continue;const c=k.includes(e.type)?e.type:"text",p=typeof e.currency=="string"&&/^[A-Z]{3}$/.test(e.currency.toUpperCase())?e.currency.toUpperCase():"USD";n.push({key:s,label:r,type:c,...c==="money"?{currency:p}:{},from:e.from==="app"?"app":"team"})}return n},w=(t,n)=>{const o=typeof n=="number"?Number.isFinite(n)?String(n):"":typeof n=="string"?n.trim():"";if(!o)return null;if(t.type==="number"||t.type==="money"){const e=o.replace(/[\s,]/g,"").replace(/^[^\d.-]+/,"");return/^-?\d+(\.\d+)?$/.test(e)&&e.length<=20?String(Number(e)):void 0}return t.type==="link"?a(o)??void 0:o.slice(0,200)},R=(t,n,o="en-US")=>{const e=Number(n);if((t.type==="money"||t.type==="number")&&Number.isFinite(e)){const r=Math.abs(e)>=100||Number.isInteger(e)?0:2;try{return new Intl.NumberFormat(o,{...t.type==="money"?{style:"currency",currency:t.currency??"USD"}:{},minimumFractionDigits:r,maximumFractionDigits:r}).format(e)}catch{return n}}return n},x=t=>{const n={};if(!t||typeof t!="object"||Array.isArray(t))return n;for(const[o,e]of Object.entries(t).slice(0,30)){if(!y.test(o))continue;const r=typeof e=="number"&&Number.isFinite(e)?String(e):u(e,200);r&&(n[o]=r)}return n},S=t=>typeof t=="string"&&!Number.isNaN(Date.parse(t))?new Date(t).toISOString():null,C=t=>{const n=t&&typeof t=="object"?t:{},o=[];for(const r of Array.isArray(n.rows)?n.rows.slice(0,20):[]){if(!r||typeof r!="object")continue;const s=r,c=u(s.label,40);if(!c)continue;const p=Array.isArray(s.chips)?s.chips.slice(0,30).map(l=>l&&typeof l=="object"?l:{}).flatMap(l=>{const d=u(l.label,60),b=a(l.icon);return d?[{label:d,...b?{icon:b}:{},...l.muted===!0?{muted:!0}:{}}]:[]}):void 0,i={label:c},g=u(s.text,500),m=u(s.strong,120),f=u(s.empty,60);g&&(i.text=g),m&&(i.strong=m),p&&(i.chips=p),f&&(i.empty=f),(i.text||i.strong||i.chips)&&o.push(i)}const e=x(n.fields);return{rows:o,lastSeenAt:S(n.lastSeenAt),storefrontUrl:a(n.storefrontUrl),...Object.keys(e).length?{fields:e}:{}}},A=(t,n)=>{const o=t&&typeof t=="object"?t.status:null,e={};for(const r of n){const s=o&&typeof o=="object"?o[r]:void 0,c=u(s?.label,120);c&&(s?.tone==="good"||s?.tone==="partial"||s?.tone==="none")&&(e[r]={tone:s.tone,label:c})}return e};export{k as FIELD_TYPES,h as cleanCustomFields,w as cleanFieldValue,C as cleanStorePanel,A as cleanStoreStatuses,F as fieldKey,R as formatField};
|
package/dist/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whoa-chat/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Types and helpers shared by Whoa Chat's server, its chat components and the apps that host it. No React.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://whoa.chat/docs/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|