@odla-ai/crm 0.3.2 → 0.5.0

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.
@@ -191,6 +191,32 @@ interface CrmConfigRow {
191
191
  settings: Record<string, unknown>;
192
192
  updatedAt: number;
193
193
  }
194
+ /** Structured upstream identity for a record received from another app. */
195
+ interface CrmRecordOrigin {
196
+ id: string;
197
+ key: string;
198
+ recordId: string;
199
+ sourceId: string;
200
+ sourceRecordId: string;
201
+ sourceUrl?: string;
202
+ payloadVersion: number;
203
+ firstReceivedAt: number;
204
+ lastReceivedAt: number;
205
+ }
206
+ /** Latest delivery state for one local record → remote target edge. */
207
+ interface CrmRecordDelivery {
208
+ id: string;
209
+ key: string;
210
+ recordId: string;
211
+ targetId: string;
212
+ remoteRecordId?: string;
213
+ status: "delivered" | "failed";
214
+ attempts: number;
215
+ payloadVersion: number;
216
+ lastAttemptAt: number;
217
+ deliveredAt?: number;
218
+ error?: string;
219
+ }
194
220
  /** Outcome of validating + coercing input for a type (see `prepare`). On
195
221
  * success, `attrs` are the columns to WRITE (never null — odla-db rejects null
196
222
  * on a typed scalar) and `retract` names the slots/promoted columns to CLEAR
@@ -249,6 +275,9 @@ interface TypeFacets {
249
275
  interface TypeDef {
250
276
  label: string;
251
277
  labelPlural?: string;
278
+ /** Optional admin collection group. Hosts can keep people and portfolio
279
+ * records in separate workspaces without moving either outside the CRM. */
280
+ workspace?: string;
252
281
  /** Field mapped to the promoted `name` column. Default `"name"`. */
253
282
  nameField?: string;
254
283
  /** `email`-typed field mapped to `primaryEmail` (lowercased) and backed by
@@ -378,6 +407,10 @@ interface RecordDetail {
378
407
  tags: CrmTag[];
379
408
  channels: CrmContactChannel[];
380
409
  links: CrmLink[];
410
+ /** Structured upstream identities; absent only from pre-upgrade custom APIs. */
411
+ origins?: CrmRecordOrigin[];
412
+ /** Latest outbound state per target; absent only from pre-upgrade custom APIs. */
413
+ deliveries?: CrmRecordDelivery[];
381
414
  }
382
415
  /** One list window plus the total matching count. */
383
416
  interface RecordPage {
@@ -827,9 +860,12 @@ interface ActivityFeedProps {
827
860
  /** Toggle a task between done and open. */
828
861
  onToggleTask: (activity: CrmActivity, done: boolean) => void;
829
862
  busy?: boolean;
863
+ /** Exact activity opened from a Discussion deep link. It receives keyboard
864
+ * focus once present without changing or mutating the feed. */
865
+ focusedActivityId?: string;
830
866
  }
831
867
  /** Composer (note ⇄ task) above the newest-first feed. */
832
- declare function ActivityFeed({ activities, onAddNote, onAddTask, onToggleTask, busy }: ActivityFeedProps): preact.JSX.Element;
868
+ declare function ActivityFeed({ activities, onAddNote, onAddTask, onToggleTask, busy, focusedActivityId, }: ActivityFeedProps): preact.JSX.Element;
833
869
 
834
870
  /** One bulk operation offered over the current selection. */
835
871
  interface BulkAction {
package/dist/ui/index.js CHANGED
@@ -595,12 +595,43 @@ function RecordPanel({
595
595
  ] }, link.id)) })
596
596
  ] });
597
597
  const stage = def.pipeline ? /* @__PURE__ */ jsx7("div", { className: "crm-panel-stage", children: /* @__PURE__ */ jsx7(StageControl, { crm, record, onMove: onMoveStage, disabled: saving }) }) : null;
598
+ const network = detail.origins?.length || detail.deliveries?.length ? /* @__PURE__ */ jsxs7("div", { className: "crm-panel-connections", children: [
599
+ detail.origins?.length ? /* @__PURE__ */ jsxs7("section", { children: [
600
+ /* @__PURE__ */ jsx7("h3", { children: "Received from" }),
601
+ /* @__PURE__ */ jsx7("ul", { className: "crm-link-list", children: detail.origins.map((origin) => /* @__PURE__ */ jsxs7("li", { children: [
602
+ /* @__PURE__ */ jsx7("strong", { children: origin.sourceId }),
603
+ " ",
604
+ /* @__PURE__ */ jsx7("code", { children: origin.sourceRecordId }),
605
+ /* @__PURE__ */ jsxs7("span", { children: [
606
+ " \xB7 ",
607
+ new Date(origin.lastReceivedAt).toLocaleString()
608
+ ] })
609
+ ] }, origin.key)) })
610
+ ] }) : null,
611
+ detail.deliveries?.length ? /* @__PURE__ */ jsxs7("section", { children: [
612
+ /* @__PURE__ */ jsx7("h3", { children: "Shared with" }),
613
+ /* @__PURE__ */ jsx7("ul", { className: "crm-link-list", children: detail.deliveries.map((delivery) => /* @__PURE__ */ jsxs7("li", { children: [
614
+ /* @__PURE__ */ jsx7("strong", { children: delivery.targetId }),
615
+ " ",
616
+ /* @__PURE__ */ jsx7("span", { className: "crm-badge", children: delivery.status }),
617
+ /* @__PURE__ */ jsxs7("span", { children: [
618
+ " \xB7 ",
619
+ new Date(delivery.lastAttemptAt).toLocaleString()
620
+ ] }),
621
+ delivery.error ? /* @__PURE__ */ jsxs7("span", { children: [
622
+ " \xB7 ",
623
+ delivery.error
624
+ ] }) : null
625
+ ] }, delivery.key)) })
626
+ ] }) : null
627
+ ] }) : null;
598
628
  const builtInTabs = [
599
629
  ...stagePlacement === "tab" && stage ? [{ id: "stage", label: "Stage", panel: stage }] : [],
600
630
  { id: "profile", label: "Profile", panel: profile },
601
631
  ...activitySlot ? [{ id: "activity", label: "Activity", panel: activitySlot }] : [],
602
632
  ...facetPlacement === "tabs" && billing ? [{ id: "billing", label: "Billing", panel: billing }] : [],
603
- { id: "connections", label: "Connections", panel: connections }
633
+ { id: "connections", label: "Connections", panel: connections },
634
+ ...network ? [{ id: "network", label: "Network", panel: network }] : []
604
635
  ];
605
636
  const configuredTabs = tabs ?? extendTabs?.(builtInTabs) ?? builtInTabs;
606
637
  const resolvedTabs = configuredTabs.filter((item) => typeof item.visible === "function" ? item.visible(detail) : item.visible !== false).map((item) => ({
@@ -816,15 +847,28 @@ function CrmWorkspace({
816
847
  }
817
848
 
818
849
  // src/ui/activity-feed.tsx
819
- import { useState as useState5 } from "preact/hooks";
850
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState5 } from "preact/hooks";
820
851
  import { Button as Button4, Checkbox as Checkbox2, Input as Input2, Segmented, Textarea as Textarea2 } from "@odla-ai/ui/components";
821
852
  import { Fragment, jsx as jsx9, jsxs as jsxs9 } from "preact/jsx-runtime";
822
853
  var when = (at) => new Date(at).toISOString().replace("T", " ").slice(0, 16);
823
- function ActivityFeed({ activities, onAddNote, onAddTask, onToggleTask, busy = false }) {
854
+ function ActivityFeed({
855
+ activities,
856
+ onAddNote,
857
+ onAddTask,
858
+ onToggleTask,
859
+ busy = false,
860
+ focusedActivityId
861
+ }) {
824
862
  const [mode, setMode] = useState5("note");
825
863
  const [body, setBody] = useState5("");
826
864
  const [dueAt, setDueAt] = useState5("");
827
865
  const [waitingOn, setWaitingOn] = useState5("");
866
+ const focused = useRef2(null);
867
+ useEffect2(() => {
868
+ if (!focusedActivityId || !focused.current) return;
869
+ focused.current.focus({ preventScroll: true });
870
+ focused.current.scrollIntoView?.({ block: "center" });
871
+ }, [activities, focusedActivityId]);
828
872
  const submit = () => {
829
873
  const text = body.trim();
830
874
  if (!text) return;
@@ -885,32 +929,42 @@ function ActivityFeed({ activities, onAddNote, onAddTask, onToggleTask, busy = f
885
929
  ] }),
886
930
  /* @__PURE__ */ jsx9(Button4, { mini: true, onClick: submit, disabled: busy || !body.trim(), children: "Add" })
887
931
  ] }),
888
- /* @__PURE__ */ jsx9("ul", { className: "crm-activity-list", children: activities.map((activity) => /* @__PURE__ */ jsxs9("li", { className: `crm-activity kind-${activity.kind}`, children: [
889
- activity.kind === "task" ? /* @__PURE__ */ jsx9(
890
- Checkbox2,
891
- {
892
- checked: activity.status === "done",
893
- disabled: busy,
894
- onChange: (event) => onToggleTask(activity, event.currentTarget.checked),
895
- label: /* @__PURE__ */ jsxs9(Fragment, { children: [
896
- activity.body,
897
- activity.dueAt != null && /* @__PURE__ */ jsxs9("span", { className: "crm-activity-due", children: [
898
- " \xB7 due ",
899
- when(activity.dueAt).slice(0, 10)
900
- ] }),
901
- activity.waitingOn && /* @__PURE__ */ jsxs9("span", { className: "crm-activity-waiting", children: [
902
- " \xB7 waiting on ",
903
- activity.waitingOn
904
- ] })
932
+ /* @__PURE__ */ jsx9("ul", { className: "crm-activity-list", children: activities.map((activity) => /* @__PURE__ */ jsxs9(
933
+ "li",
934
+ {
935
+ className: `crm-activity kind-${activity.kind}`,
936
+ ref: activity.id === focusedActivityId ? focused : void 0,
937
+ tabIndex: activity.id === focusedActivityId ? -1 : void 0,
938
+ "aria-current": activity.id === focusedActivityId ? "true" : void 0,
939
+ children: [
940
+ activity.kind === "task" ? /* @__PURE__ */ jsx9(
941
+ Checkbox2,
942
+ {
943
+ checked: activity.status === "done",
944
+ disabled: busy,
945
+ onChange: (event) => onToggleTask(activity, event.currentTarget.checked),
946
+ label: /* @__PURE__ */ jsxs9(Fragment, { children: [
947
+ activity.body,
948
+ activity.dueAt != null && /* @__PURE__ */ jsxs9("span", { className: "crm-activity-due", children: [
949
+ " \xB7 due ",
950
+ when(activity.dueAt).slice(0, 10)
951
+ ] }),
952
+ activity.waitingOn && /* @__PURE__ */ jsxs9("span", { className: "crm-activity-waiting", children: [
953
+ " \xB7 waiting on ",
954
+ activity.waitingOn
955
+ ] })
956
+ ] })
957
+ }
958
+ ) : /* @__PURE__ */ jsx9("p", { children: activity.body }),
959
+ /* @__PURE__ */ jsxs9("span", { className: "crm-activity-meta", children: [
960
+ activity.kind,
961
+ " \xB7 ",
962
+ when(activity.createdAt)
905
963
  ] })
906
- }
907
- ) : /* @__PURE__ */ jsx9("p", { children: activity.body }),
908
- /* @__PURE__ */ jsxs9("span", { className: "crm-activity-meta", children: [
909
- activity.kind,
910
- " \xB7 ",
911
- when(activity.createdAt)
912
- ] })
913
- ] }, activity.id)) })
964
+ ]
965
+ },
966
+ activity.id
967
+ )) })
914
968
  ] });
915
969
  }
916
970