@ensembleapp/client-sdk 0.0.15 → 0.0.17
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/index.js +159 -98
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24878,8 +24878,140 @@ var createWidget = ({
|
|
|
24878
24878
|
render
|
|
24879
24879
|
});
|
|
24880
24880
|
|
|
24881
|
-
// lib/widgets/
|
|
24881
|
+
// lib/widgets/VendorCards.tsx
|
|
24882
24882
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
24883
|
+
var vendorCardsSchema = zod_default.object({
|
|
24884
|
+
fromLocation: zod_default.string().describe("The location the user is searching for"),
|
|
24885
|
+
fromCoordinates: zod_default.object({
|
|
24886
|
+
latitude: zod_default.number(),
|
|
24887
|
+
longitude: zod_default.number()
|
|
24888
|
+
}).describe("The location's lat/lng coordinates. This must come from the previous geocoding tool as-is - do NOT guess"),
|
|
24889
|
+
vendors: zod_default.array(zod_default.object({
|
|
24890
|
+
vendor_id: zod_default.string(),
|
|
24891
|
+
notes: zod_default.string().optional().describe("Why this vendor was recommended"),
|
|
24892
|
+
vendorCoordinates: zod_default.object({
|
|
24893
|
+
latitude: zod_default.number(),
|
|
24894
|
+
longitude: zod_default.number()
|
|
24895
|
+
}).describe("The lat/lng coordinates of this vendor. This must come from the vendor's location.coordinates from the previous vendor search tool - do NOT guess")
|
|
24896
|
+
}))
|
|
24897
|
+
}).describe("displaying a list of vendor cards. Use this widget to represent data from CareNetwork vendor search tool.");
|
|
24898
|
+
function VendorCards({ payload, enriched }) {
|
|
24899
|
+
if (!enriched || !enriched.vendorDetails || !enriched.distanceMatrix) {
|
|
24900
|
+
return /* @__PURE__ */ jsx8("div", { children: "Outdated vendor-cards widget" });
|
|
24901
|
+
}
|
|
24902
|
+
const { vendorDetails, distanceMatrix } = enriched;
|
|
24903
|
+
const vendorData = vendorDetails?.data ?? {};
|
|
24904
|
+
const distances = distanceMatrix?.data ?? [];
|
|
24905
|
+
const formatDistance = (meters) => {
|
|
24906
|
+
const miles = meters / 1609.34;
|
|
24907
|
+
return miles < 0.1 ? "< 0.1 mi" : `${miles.toFixed(1)} mi`;
|
|
24908
|
+
};
|
|
24909
|
+
return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: payload.vendors.map((v, index) => {
|
|
24910
|
+
const data = vendorData[v.vendor_id];
|
|
24911
|
+
const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "";
|
|
24912
|
+
const address = data?.location?.address;
|
|
24913
|
+
const distanceEntry = distances.find((d) => d.destinationIndex === index);
|
|
24914
|
+
const distance = distanceEntry && distanceEntry.distanceMeters ? formatDistance(distanceEntry.distanceMeters) : void 0;
|
|
24915
|
+
const hourlyRate = data?.financials?.fees?.find((f) => f.fee_type?.includes("Hourly"))?.amount;
|
|
24916
|
+
const avgRating = data?.avg_rating;
|
|
24917
|
+
const reviewCount = data?.review_count;
|
|
24918
|
+
const booleans = data?.booleans;
|
|
24919
|
+
const verification = data?.verification;
|
|
24920
|
+
return /* @__PURE__ */ jsxs7(
|
|
24921
|
+
"div",
|
|
24922
|
+
{
|
|
24923
|
+
style: {
|
|
24924
|
+
display: "flex",
|
|
24925
|
+
flexDirection: "column",
|
|
24926
|
+
gap: "0.2rem",
|
|
24927
|
+
padding: "1rem",
|
|
24928
|
+
background: "#ffffff",
|
|
24929
|
+
border: "1px solid #e5e7eb",
|
|
24930
|
+
borderRadius: "0.5rem",
|
|
24931
|
+
boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
|
|
24932
|
+
fontSize: "0.875rem"
|
|
24933
|
+
},
|
|
24934
|
+
children: [
|
|
24935
|
+
/* @__PURE__ */ jsx8("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start" }, children: /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
24936
|
+
/* @__PURE__ */ jsx8("div", { style: {
|
|
24937
|
+
width: "2rem",
|
|
24938
|
+
height: "2rem",
|
|
24939
|
+
borderRadius: "9999px",
|
|
24940
|
+
background: "#bfd1f5",
|
|
24941
|
+
display: "flex",
|
|
24942
|
+
alignItems: "center",
|
|
24943
|
+
justifyContent: "center",
|
|
24944
|
+
fontWeight: 600,
|
|
24945
|
+
fontSize: "0.875rem",
|
|
24946
|
+
color: "#374151"
|
|
24947
|
+
}, children: name17.charAt(0).toUpperCase() }),
|
|
24948
|
+
/* @__PURE__ */ jsx8("span", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827" }, children: name17 })
|
|
24949
|
+
] }) }),
|
|
24950
|
+
/* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", color: "#6b7280" }, children: [
|
|
24951
|
+
/* @__PURE__ */ jsx8("span", { style: { color: "#facc15" }, children: "\u2605" }),
|
|
24952
|
+
/* @__PURE__ */ jsx8("span", { children: avgRating?.toFixed(1) ?? "\u2014" }),
|
|
24953
|
+
/* @__PURE__ */ jsxs7("span", { style: { color: "#9ca3af" }, children: [
|
|
24954
|
+
"(",
|
|
24955
|
+
reviewCount ?? 0,
|
|
24956
|
+
" reviews)"
|
|
24957
|
+
] })
|
|
24958
|
+
] }),
|
|
24959
|
+
address && /* @__PURE__ */ jsx8("div", { style: { color: "#6b7280" }, children: address }),
|
|
24960
|
+
distance && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280" }, children: [
|
|
24961
|
+
/* @__PURE__ */ jsx8("span", { children: "\u{1F4CD}" }),
|
|
24962
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
24963
|
+
distance,
|
|
24964
|
+
" from ",
|
|
24965
|
+
payload.fromLocation
|
|
24966
|
+
] })
|
|
24967
|
+
] }),
|
|
24968
|
+
hourlyRate && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280" }, children: [
|
|
24969
|
+
/* @__PURE__ */ jsx8("span", { children: "\u{1F4B0}" }),
|
|
24970
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
24971
|
+
"Rate: $",
|
|
24972
|
+
hourlyRate,
|
|
24973
|
+
"/hr"
|
|
24974
|
+
] })
|
|
24975
|
+
] }),
|
|
24976
|
+
v.notes && /* @__PURE__ */ jsxs7("div", { style: { color: "#374151", marginTop: "0.4rem" }, children: [
|
|
24977
|
+
/* @__PURE__ */ jsx8("span", { style: { marginRight: "0.25rem" }, children: "\u2728" }),
|
|
24978
|
+
/* @__PURE__ */ jsx8("strong", { children: "Recommendation notes" }),
|
|
24979
|
+
/* @__PURE__ */ jsx8("div", { style: { marginLeft: "1.25rem", marginTop: "0.25rem", color: "#6b7280" }, children: v.notes })
|
|
24980
|
+
] }),
|
|
24981
|
+
/* @__PURE__ */ jsxs7("div", { style: {
|
|
24982
|
+
display: "flex",
|
|
24983
|
+
flexWrap: "wrap",
|
|
24984
|
+
gap: "0.5rem",
|
|
24985
|
+
marginTop: "0.25rem",
|
|
24986
|
+
paddingTop: "0.5rem",
|
|
24987
|
+
borderTop: "1px solid #f3f4f6"
|
|
24988
|
+
}, children: [
|
|
24989
|
+
verification?.verified && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
|
|
24990
|
+
/* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
|
|
24991
|
+
" Verified"
|
|
24992
|
+
] }),
|
|
24993
|
+
booleans?.is_agency_insured && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
|
|
24994
|
+
/* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
|
|
24995
|
+
" Insured"
|
|
24996
|
+
] }),
|
|
24997
|
+
booleans?.free_in_home_evaluation && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#3b82f6", fontSize: "0.75rem" }, children: [
|
|
24998
|
+
/* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u{1F3E0}" }),
|
|
24999
|
+
" Free In-Home Evaluation"
|
|
25000
|
+
] }),
|
|
25001
|
+
booleans?.can_request_same_caregiver && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280", fontSize: "0.75rem" }, children: [
|
|
25002
|
+
/* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u{1F464}" }),
|
|
25003
|
+
" Same Caregiver Available"
|
|
25004
|
+
] })
|
|
25005
|
+
] })
|
|
25006
|
+
]
|
|
25007
|
+
},
|
|
25008
|
+
v.vendor_id
|
|
25009
|
+
);
|
|
25010
|
+
}) });
|
|
25011
|
+
}
|
|
25012
|
+
|
|
25013
|
+
// lib/widgets/default-widgets.tsx
|
|
25014
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
24883
25015
|
var defaultChatWidgets = [
|
|
24884
25016
|
createWidget({
|
|
24885
25017
|
widgetType: "person-card",
|
|
@@ -24888,7 +25020,7 @@ var defaultChatWidgets = [
|
|
|
24888
25020
|
profileUri: zod_default.string().optional(),
|
|
24889
25021
|
details: zod_default.record(zod_default.any()).optional()
|
|
24890
25022
|
}).describe("showing a person card with name, photo and additional details"),
|
|
24891
|
-
render: (payload) => /* @__PURE__ */
|
|
25023
|
+
render: (payload) => /* @__PURE__ */ jsx9(
|
|
24892
25024
|
"div",
|
|
24893
25025
|
{
|
|
24894
25026
|
style: {
|
|
@@ -24901,8 +25033,8 @@ var defaultChatWidgets = [
|
|
|
24901
25033
|
borderRadius: "0.5rem",
|
|
24902
25034
|
boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)"
|
|
24903
25035
|
},
|
|
24904
|
-
children: /* @__PURE__ */
|
|
24905
|
-
payload.profileUri && /* @__PURE__ */
|
|
25036
|
+
children: /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "flex-start", gap: "0.75rem" }, children: [
|
|
25037
|
+
payload.profileUri && /* @__PURE__ */ jsx9(
|
|
24906
25038
|
"img",
|
|
24907
25039
|
{
|
|
24908
25040
|
src: payload.profileUri,
|
|
@@ -24917,14 +25049,14 @@ var defaultChatWidgets = [
|
|
|
24917
25049
|
loading: "lazy"
|
|
24918
25050
|
}
|
|
24919
25051
|
),
|
|
24920
|
-
/* @__PURE__ */
|
|
24921
|
-
/* @__PURE__ */
|
|
24922
|
-
payload.details ? /* @__PURE__ */
|
|
24923
|
-
/* @__PURE__ */
|
|
25052
|
+
/* @__PURE__ */ jsxs8("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
25053
|
+
/* @__PURE__ */ jsx9("div", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827", marginBottom: "0.25rem" }, children: payload.name }),
|
|
25054
|
+
payload.details ? /* @__PURE__ */ jsx9("div", { style: { display: "flex", flexDirection: "column", gap: "0.25rem" }, children: Object.entries(payload.details).map(([key, value]) => /* @__PURE__ */ jsxs8("div", { style: { display: "flex", gap: "0.5rem", fontSize: "0.875rem" }, children: [
|
|
25055
|
+
/* @__PURE__ */ jsxs8("span", { style: { color: "#6b7280", fontWeight: 500, minWidth: "fit-content" }, children: [
|
|
24924
25056
|
key,
|
|
24925
25057
|
":"
|
|
24926
25058
|
] }),
|
|
24927
|
-
/* @__PURE__ */
|
|
25059
|
+
/* @__PURE__ */ jsx9("span", { style: { color: "#374151" }, children: String(value) })
|
|
24928
25060
|
] }, key)) }) : null
|
|
24929
25061
|
] })
|
|
24930
25062
|
] })
|
|
@@ -24937,7 +25069,7 @@ var defaultChatWidgets = [
|
|
|
24937
25069
|
uri: zod_default.string().url(),
|
|
24938
25070
|
text: zod_default.string().optional()
|
|
24939
25071
|
}).describe("rendering a clickable link"),
|
|
24940
|
-
render: (payload) => /* @__PURE__ */
|
|
25072
|
+
render: (payload) => /* @__PURE__ */ jsx9(
|
|
24941
25073
|
"a",
|
|
24942
25074
|
{
|
|
24943
25075
|
href: payload.uri,
|
|
@@ -24972,102 +25104,31 @@ var defaultChatWidgets = [
|
|
|
24972
25104
|
}),
|
|
24973
25105
|
createWidget({
|
|
24974
25106
|
widgetType: "vendor-cards",
|
|
24975
|
-
schema:
|
|
24976
|
-
vendors: zod_default.array(zod_default.object({
|
|
24977
|
-
vendor_id: zod_default.string(),
|
|
24978
|
-
rank: zod_default.number().optional().describe("ranking position of the vendor from 1 to N when applicable"),
|
|
24979
|
-
reason: zod_default.string().optional().describe("reason for the vendor ranking when applicable")
|
|
24980
|
-
}))
|
|
24981
|
-
}).describe("displaying a list of vendor cards with rankings and reasons. Only use this widget when calling Care Network vendor search tools."),
|
|
25107
|
+
schema: vendorCardsSchema,
|
|
24982
25108
|
enrich: {
|
|
25109
|
+
/** fetch vendor details from the list of IDs */
|
|
24983
25110
|
vendorDetails: {
|
|
24984
25111
|
toolId: "CPgsswom7FkUYvplmy6H",
|
|
24985
25112
|
inputs: {
|
|
24986
25113
|
vendorIds: "${vendors|map('vendor_id')|join(',')}"
|
|
24987
25114
|
}
|
|
25115
|
+
},
|
|
25116
|
+
/* calculate distance from user to each vendor */
|
|
25117
|
+
distanceMatrix: {
|
|
25118
|
+
toolId: "DwsbeKAxOctXSGgghvW8",
|
|
25119
|
+
inputs: {
|
|
25120
|
+
origin: "${fromCoordinates}",
|
|
25121
|
+
destinations: "${vendors|map('vendorCoordinates')}"
|
|
25122
|
+
}
|
|
24988
25123
|
}
|
|
24989
25124
|
},
|
|
24990
|
-
render: (payload,
|
|
24991
|
-
|
|
24992
|
-
|
|
24993
|
-
|
|
24994
|
-
|
|
24995
|
-
|
|
24996
|
-
|
|
24997
|
-
return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: typedPayload.vendors.map((v) => {
|
|
24998
|
-
const data = vendorData[v.vendor_id];
|
|
24999
|
-
const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "Care Provider";
|
|
25000
|
-
const languages = data?.languages ?? [];
|
|
25001
|
-
const ageGroups = data?.details?.age_groups ?? [];
|
|
25002
|
-
const services = data?.details?.services ?? [];
|
|
25003
|
-
const address = data?.location?.formatted_address;
|
|
25004
|
-
const hours = data?.scheduling?.hours;
|
|
25005
|
-
return /* @__PURE__ */ jsxs7(
|
|
25006
|
-
"div",
|
|
25007
|
-
{
|
|
25008
|
-
style: {
|
|
25009
|
-
display: "flex",
|
|
25010
|
-
flexDirection: "column",
|
|
25011
|
-
gap: "0.5rem",
|
|
25012
|
-
padding: "1rem",
|
|
25013
|
-
background: "#ffffff",
|
|
25014
|
-
border: "1px solid #e5e7eb",
|
|
25015
|
-
borderRadius: "0.5rem",
|
|
25016
|
-
boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)"
|
|
25017
|
-
},
|
|
25018
|
-
children: [
|
|
25019
|
-
/* @__PURE__ */ jsxs7("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
25020
|
-
/* @__PURE__ */ jsxs7("span", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827" }, children: [
|
|
25021
|
-
v.rank ? `#${v.rank} ` : "",
|
|
25022
|
-
name17
|
|
25023
|
-
] }),
|
|
25024
|
-
hours && /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: hours })
|
|
25025
|
-
] }),
|
|
25026
|
-
address && /* @__PURE__ */ jsx8("div", { style: { fontSize: "0.875rem", color: "#6b7280" }, children: address }),
|
|
25027
|
-
services.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: services.map((service) => /* @__PURE__ */ jsx8(
|
|
25028
|
-
"span",
|
|
25029
|
-
{
|
|
25030
|
-
style: {
|
|
25031
|
-
fontSize: "0.75rem",
|
|
25032
|
-
padding: "0.125rem 0.5rem",
|
|
25033
|
-
background: "#dbeafe",
|
|
25034
|
-
color: "#1e40af",
|
|
25035
|
-
borderRadius: "9999px"
|
|
25036
|
-
},
|
|
25037
|
-
children: service
|
|
25038
|
-
},
|
|
25039
|
-
service
|
|
25040
|
-
)) }),
|
|
25041
|
-
languages.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: languages.map((lang) => /* @__PURE__ */ jsx8(
|
|
25042
|
-
"span",
|
|
25043
|
-
{
|
|
25044
|
-
style: {
|
|
25045
|
-
fontSize: "0.75rem",
|
|
25046
|
-
padding: "0.125rem 0.5rem",
|
|
25047
|
-
background: "#f3e8ff",
|
|
25048
|
-
color: "#7c3aed",
|
|
25049
|
-
borderRadius: "9999px"
|
|
25050
|
-
},
|
|
25051
|
-
children: formatLanguage(lang)
|
|
25052
|
-
},
|
|
25053
|
-
lang
|
|
25054
|
-
)) }),
|
|
25055
|
-
ageGroups.length > 0 && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: [
|
|
25056
|
-
/* @__PURE__ */ jsx8("strong", { children: "Ages:" }),
|
|
25057
|
-
" ",
|
|
25058
|
-
ageGroups.join(", ")
|
|
25059
|
-
] }),
|
|
25060
|
-
v.reason && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.875rem", color: "#374151" }, children: [
|
|
25061
|
-
/* @__PURE__ */ jsx8("strong", { children: "Why:" }),
|
|
25062
|
-
" ",
|
|
25063
|
-
v.reason
|
|
25064
|
-
] })
|
|
25065
|
-
]
|
|
25066
|
-
},
|
|
25067
|
-
v.vendor_id
|
|
25068
|
-
);
|
|
25069
|
-
}) });
|
|
25070
|
-
}
|
|
25125
|
+
render: (payload, enriched) => /* @__PURE__ */ jsx9(
|
|
25126
|
+
VendorCards,
|
|
25127
|
+
{
|
|
25128
|
+
payload,
|
|
25129
|
+
enriched
|
|
25130
|
+
}
|
|
25131
|
+
)
|
|
25071
25132
|
})
|
|
25072
25133
|
];
|
|
25073
25134
|
export {
|