codicent-app-sdk 0.7.10 → 0.8.6
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/cjs/_virtual/scheduler.production.js +1 -0
- package/dist/cjs/components/DataMessagePicker.d.ts +7 -1
- package/dist/cjs/components/DataMessagePicker.d.ts.map +1 -1
- package/dist/cjs/components/DataMessagePicker.js +1 -1
- package/dist/cjs/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/cjs/components/ErrorBoundary.js +1 -1
- package/dist/cjs/components/ListView.d.ts +54 -1
- package/dist/cjs/components/ListView.d.ts.map +1 -1
- package/dist/cjs/components/ListView.js +1 -1
- package/dist/cjs/components/MessageItem.js +1 -1
- package/dist/cjs/components/RecordModal.d.ts +6 -1
- package/dist/cjs/components/RecordModal.d.ts.map +1 -1
- package/dist/cjs/components/RecordModal.js +1 -1
- package/dist/cjs/config/index.d.ts +1 -0
- package/dist/cjs/config/index.d.ts.map +1 -1
- package/dist/cjs/config/index.js +1 -1
- package/dist/cjs/hooks/useChat.d.ts +4 -1
- package/dist/cjs/hooks/useChat.d.ts.map +1 -1
- package/dist/cjs/hooks/useChat.js +1 -1
- package/dist/cjs/hooks/useCodicentApp.js +1 -1
- package/dist/cjs/hooks/useRealtimeVoiceAI.d.ts.map +1 -1
- package/dist/cjs/hooks/useRealtimeVoiceAI.js +1 -1
- package/dist/cjs/hooks/useToaster.d.ts +1 -1
- package/dist/cjs/hooks/useToaster.d.ts.map +1 -1
- package/dist/cjs/hooks/useToaster.js +1 -1
- package/dist/cjs/hooks/useUserRoles.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/core/dist/floating-ui.core.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/devtools/dist/floating-ui.devtools.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-aria/lib/activedescendant/useOptionWalker.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/Calendar/useCalendarStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDay/CalendarDay.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDay/useCalendarDayStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarDayGrid.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarGridDayCell.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarMonth/CalendarMonth.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarPicker/useCalendarPickerStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarYear/CalendarYear.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Combobox/useCombobox.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Combobox/useComboboxStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Listbox/useListboxStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Option/useOption.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Option/useOptionStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/contexts/ListboxContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/utils/dropdownKeyActions.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/utils/useComboboxPositioning.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/utils/useListboxSlot.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-context-selector/lib/createContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-context-selector/lib/useContextSelector.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-context-selector/lib/useHasParentContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-datepicker-compat/lib/components/DatePicker/useDatePickerStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-input/lib/components/Input/useInput.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-input/lib/components/Input/useInputStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-jsx-runtime/lib/jsx/createJSX.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-jsx-runtime/lib/utils/createCompatSlotComponent.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-jsx-runtime/lib/utils/warnIfElementTypeIsInvalid.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-portal/lib/components/Portal/Portal.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-portal/lib/components/Portal/renderPortal.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-portal/lib/components/Portal/usePortal.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-portal/lib/components/Portal/usePortalMountNode.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-portal/lib/components/Portal/usePortalMountNodeStyles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-positioning/lib/createPositionManager.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-positioning/lib/usePositioning.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-positioning/lib/utils/getReactFiberFromNode.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-tabster/lib/focus/focusVisiblePolyfill.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-tabster/lib/hooks/useDangerousNeverHidden.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tabster/lib/hooks/useModalAttributes.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-tabster/lib/hooks/useTabster.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-timepicker-compat/lib/components/TimePicker/useTimePickerStyles.styles.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/compose/assertSlots.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/compose/getIntrinsicElementProps.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/compose/slot.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/hooks/useFirstMount.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/hooks/useOnClickOutside.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/utils/getNativeElementProps.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/utils/properties.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/virtualParent/getParent.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/virtualParent/setVirtualParent.js +1 -1
- package/dist/cjs/node_modules/@griffel/core/src/__resetStyles.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/__styles.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/constants.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/getAtomicDebugSequenceTree.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/getResetDebugSequence.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/getSourceURLfromError.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/injectDevTools.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/isDevToolsEnabled.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/mergeDebugSequence.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/react-render-tracker/stackTrace.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/store.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/devtools/utils.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/insertionFactory.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/mergeClasses.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/renderer/createDOMRenderer.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/renderer/createIsomorphicStyleSheet.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/renderer/getStyleSheetForBucket.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/renderer/safeInsertRule.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/runtime/reduceToClassNameForSlots.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/runtime/utils/hashSequence.js +1 -0
- package/dist/cjs/node_modules/@griffel/core/src/runtime/utils/normalizeCSSBucketEntry.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/RendererContext.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/TextDirectionContext.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/__resetStyles.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/__styles.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/insertionFactory.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/useInsertionEffect.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/src/utils/canUseDOM.js +1 -0
- package/dist/cjs/node_modules/scheduler/cjs/scheduler.development.js +3 -3
- package/dist/cjs/node_modules/scheduler/cjs/scheduler.production.js +10 -0
- package/dist/cjs/node_modules/scheduler/index.js +1 -1
- package/dist/cjs/pages/Chat.d.ts.map +1 -1
- package/dist/cjs/pages/Chat.js +1 -1
- package/dist/cjs/pages/ListPage.d.ts +6 -1
- package/dist/cjs/pages/ListPage.d.ts.map +1 -1
- package/dist/cjs/pages/ListPage.js +1 -1
- package/dist/cjs/services/codicent.d.ts +23 -2
- package/dist/cjs/services/codicent.d.ts.map +1 -1
- package/dist/cjs/services/codicent.js +1 -1
- package/dist/cjs/types/index.d.ts +28 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.d.ts +3 -0
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/reference.d.ts +15 -0
- package/dist/cjs/utils/reference.d.ts.map +1 -0
- package/dist/cjs/utils/reference.js +1 -0
- package/dist/cjs/utils/telemetry.d.ts +27 -0
- package/dist/cjs/utils/telemetry.d.ts.map +1 -0
- package/dist/cjs/utils/telemetry.js +1 -0
- package/dist/esm/_virtual/scheduler.production.js +1 -0
- package/dist/esm/components/DataMessagePicker.d.ts +7 -1
- package/dist/esm/components/DataMessagePicker.d.ts.map +1 -1
- package/dist/esm/components/DataMessagePicker.js +1 -1
- package/dist/esm/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/esm/components/ErrorBoundary.js +1 -1
- package/dist/esm/components/ListView.d.ts +54 -1
- package/dist/esm/components/ListView.d.ts.map +1 -1
- package/dist/esm/components/ListView.js +1 -1
- package/dist/esm/components/MessageItem.js +1 -1
- package/dist/esm/components/RecordModal.d.ts +6 -1
- package/dist/esm/components/RecordModal.d.ts.map +1 -1
- package/dist/esm/components/RecordModal.js +1 -1
- package/dist/esm/config/index.d.ts +1 -0
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/hooks/useChat.d.ts +4 -1
- package/dist/esm/hooks/useChat.d.ts.map +1 -1
- package/dist/esm/hooks/useChat.js +1 -1
- package/dist/esm/hooks/useCodicentApp.js +1 -1
- package/dist/esm/hooks/useRealtimeVoiceAI.d.ts.map +1 -1
- package/dist/esm/hooks/useRealtimeVoiceAI.js +1 -1
- package/dist/esm/hooks/useToaster.d.ts +1 -1
- package/dist/esm/hooks/useToaster.d.ts.map +1 -1
- package/dist/esm/hooks/useToaster.js +1 -1
- package/dist/esm/hooks/useUserRoles.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/node_modules/@floating-ui/core/dist/floating-ui.core.js +1 -1
- package/dist/esm/node_modules/@floating-ui/devtools/dist/floating-ui.devtools.js +1 -1
- package/dist/esm/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
- package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +1 -1
- package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-aria/lib/activedescendant/useOptionWalker.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/Calendar/useCalendarStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDay/CalendarDay.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDay/useCalendarDayStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarDayGrid.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarGridDayCell.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarMonth/CalendarMonth.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarPicker/useCalendarPickerStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-calendar-compat/lib/components/CalendarYear/CalendarYear.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Combobox/useComboboxStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Listbox/useListboxStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Option/useOption.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Option/useOptionStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/contexts/ListboxContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/utils/dropdownKeyActions.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/utils/useComboboxPositioning.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/utils/useListboxSlot.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-context-selector/lib/createContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-context-selector/lib/useContextSelector.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-context-selector/lib/useHasParentContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-datepicker-compat/lib/components/DatePicker/useDatePickerStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-input/lib/components/Input/useInput.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-input/lib/components/Input/useInputStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-jsx-runtime/lib/jsx/createJSX.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-jsx-runtime/lib/utils/createCompatSlotComponent.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-jsx-runtime/lib/utils/warnIfElementTypeIsInvalid.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-portal/lib/components/Portal/Portal.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-portal/lib/components/Portal/renderPortal.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-portal/lib/components/Portal/usePortal.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-portal/lib/components/Portal/usePortalMountNode.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-portal/lib/components/Portal/usePortalMountNodeStyles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-positioning/lib/createPositionManager.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-positioning/lib/usePositioning.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-positioning/lib/utils/getReactFiberFromNode.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-tabster/lib/focus/focusVisiblePolyfill.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-tabster/lib/hooks/useDangerousNeverHidden.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tabster/lib/hooks/useModalAttributes.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-tabster/lib/hooks/useTabster.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-timepicker-compat/lib/components/TimePicker/useTimePickerStyles.styles.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/compose/assertSlots.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/compose/getIntrinsicElementProps.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/compose/slot.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/hooks/useFirstMount.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/hooks/useOnClickOutside.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/utils/getNativeElementProps.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/utils/properties.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/virtualParent/getParent.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/virtualParent/setVirtualParent.js +1 -1
- package/dist/esm/node_modules/@griffel/core/src/__resetStyles.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/__styles.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/constants.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/getAtomicDebugSequenceTree.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/getResetDebugSequence.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/getSourceURLfromError.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/injectDevTools.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/isDevToolsEnabled.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/mergeDebugSequence.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/react-render-tracker/stackTrace.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/store.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/devtools/utils.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/insertionFactory.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/mergeClasses.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/renderer/createDOMRenderer.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/renderer/createIsomorphicStyleSheet.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/renderer/getStyleSheetForBucket.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/renderer/safeInsertRule.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/runtime/reduceToClassNameForSlots.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/runtime/utils/hashSequence.js +1 -0
- package/dist/esm/node_modules/@griffel/core/src/runtime/utils/normalizeCSSBucketEntry.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/RendererContext.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/TextDirectionContext.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/__resetStyles.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/__styles.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/insertionFactory.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/useInsertionEffect.js +1 -0
- package/dist/esm/node_modules/@griffel/react/src/utils/canUseDOM.js +1 -0
- package/dist/esm/node_modules/scheduler/cjs/scheduler.development.js +3 -3
- package/dist/esm/node_modules/scheduler/cjs/scheduler.production.js +10 -0
- package/dist/esm/node_modules/scheduler/index.js +1 -1
- package/dist/esm/pages/Chat.d.ts.map +1 -1
- package/dist/esm/pages/Chat.js +1 -1
- package/dist/esm/pages/ListPage.d.ts +6 -1
- package/dist/esm/pages/ListPage.d.ts.map +1 -1
- package/dist/esm/pages/ListPage.js +1 -1
- package/dist/esm/services/codicent.d.ts +23 -2
- package/dist/esm/services/codicent.d.ts.map +1 -1
- package/dist/esm/services/codicent.js +1 -1
- package/dist/esm/types/index.d.ts +28 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/utils/index.d.ts +3 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/reference.d.ts +15 -0
- package/dist/esm/utils/reference.d.ts.map +1 -0
- package/dist/esm/utils/reference.js +1 -0
- package/dist/esm/utils/telemetry.d.ts +27 -0
- package/dist/esm/utils/telemetry.d.ts.map +1 -0
- package/dist/esm/utils/telemetry.js +1 -0
- package/dist/index.d.ts +165 -9
- package/package.json +1 -1
package/dist/esm/pages/Chat.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as o,useState as n,useEffect as r}from"react";import{makeStyles as i}from"@fluentui/react-components";import{useNavigate as s,useSearchParams as a}from"react-router-dom";import{CalendarWeekStart24Regular as m}from"@fluentui/react-icons";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import"../components/Spinner.js";import p from"../components/TextHeader.js";import c from"../components/TypingIndicator.js";import l from"../components/Prompt.js";import d from"../components/ChatInput.js";import{CombinedPlaceholderDialog as u}from"../components/CombinedPlaceholderDialog.js";import g from"../components/ChatMessage.js";import"../components/Header.js";import h from"../hooks/useStateWithLocalStorage.js";import{CodicentService as j}from"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as f}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"exceljs";import"./AppFrame.js";import"./Canvas.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Menu.js";import"./Log.js";import"./Login.js";import"./Home.js";import"./ListPage.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"./Purchase.js";import"../components/Content.js";import{Page as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as o,useState as n,useEffect as r}from"react";import{makeStyles as i}from"@fluentui/react-components";import{useNavigate as s,useSearchParams as a}from"react-router-dom";import{CalendarWeekStart24Regular as m}from"@fluentui/react-icons";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import"../components/Spinner.js";import p from"../components/TextHeader.js";import c from"../components/TypingIndicator.js";import l from"../components/Prompt.js";import d from"../components/ChatInput.js";import{CombinedPlaceholderDialog as u}from"../components/CombinedPlaceholderDialog.js";import g from"../components/ChatMessage.js";import"../components/Header.js";import h from"../hooks/useStateWithLocalStorage.js";import{CodicentService as j}from"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as f}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import{getGpsLocation as C}from"../utils/device.js";import"exceljs";import"./AppFrame.js";import"./Canvas.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Menu.js";import"./Log.js";import"./Login.js";import"./Home.js";import"./ListPage.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"./Purchase.js";import"../components/Content.js";import{Page as A}from"../components/Page.js";import"./QrScan.js";import b from"../hooks/useLocalization.js";import"../components/FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import{useChat as S}from"../hooks/useChat.js";import{useTemplateVariables as x}from"../hooks/useTemplateVariables.js";import"../hooks/useAppStyles.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/DataMessagePicker.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/QrCodeDialog.js";import"../components/QrScanner.js";import"../components/OfflineMessage.js";import"../components/LanguageSelector.js";import"../components/ListView.js";import"../components/RecordModal.js";import"../components/BulkUploadDialog.js";import"../components/CookieBanner.js";import"../components/audit/AuditCircularProgress.js";import"../components/audit/AuditHorizontalProgress.js";import"../components/audit/AuditRoleIndicator.js";import"../components/audit/AuditUnitSwitcher.js";import"../components/audit/AuditAnswerCell.js";import"../components/audit/AuditSearchBar.js";import"../components/audit/AuditFilterChips.js";import"../components/audit/AuditFilterBar.js";import"../components/audit/AuditGroupsProgress.js";import"../components/audit/AuditSummaryDashboard.js";import"../components/audit/AuditRequirementDialog.js";import"../components/audit/AuditUnitExportDialog.js";import"../components/audit/AuditUnitImportDialog.js";import"../components/audit/AuditBulkExportDialog.js";import"../components/audit/AuditBulkUploadDialog.js";import"../components/audit/AuditSortPresets.js";const w=i({chatContainer:{width:"100%",flex:1,maxWidth:"1600px",height:"100%",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},"@media (max-width: 480px)":{},backgroundPosition:"calc(50%) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",touchAction:"pan-y"},chatMessages:{display:"flex",flexDirection:"column",flex:1,padding:"16px",overflowY:"auto",touchAction:"pan-y"}}),v=({state:i,hideFooter:v,codicent:P,title:y,welcomeMessage:k})=>{const I=w(),{t:_,tAsync:F,getLanguageInfo:T}=b(),M=s(),B=o(null),[L,H]=a(),[D]=n((()=>{const e=L.get("codicent");return e?(sessionStorage.setItem("chat_codicent",e),e):P?(sessionStorage.removeItem("chat_codicent"),null):sessionStorage.getItem("chat_codicent")})),U=D||P,{messages:R,isBotTyping:V,handleSend:N,newChat:E,openChat:O}=S(i.stateMachine,U||void 0),[W,z]=n(null),[G,Q]=n(!1),[Y,$]=n(!1),{service:q,currentStateName:K}=i,[J,X]=n([]),[Z,ee]=n([]),[te,oe]=n(!1),[ne,re]=n(),[ie,se]=h(i.context.selectedApp+"_prompts",[]),[ae,me]=n(!1),[pe,ce]=n(null),{extractTemplateVariables:le,replaceTemplateVariables:de,extractFilePlaceholders:ue,replaceFilePlaceholders:ge,handleSelectFiles:he}=x(q.uploadFile);r((()=>{f("ENABLE_CHAT_GPS")&&C().then((e=>{e&&ce({lat:e.coords.latitude,lon:e.coords.longitude})})).catch((()=>{}))}),[]);const je=o(!1),fe=o(null);r((()=>{const e=window.history.length>1,t=Boolean(document.referrer&&document.referrer!==window.location.href);$(e||t)}),[]);r((()=>{f("SHOW_CHAT_PROMPTS")&&0===R.length&&i.service.getAppPrompts(U||void 0).then(se).catch((e=>{console.error("Failed to get prompts",e)}))}),[i.service,se,R.length,U]),r((()=>{setTimeout((()=>{B.current?.scrollIntoView({behavior:"smooth"})}),10)}),[R]),r((()=>{if(je.current)return;je.current=!0;const e=L.get("text"),t=L.get("id"),o=L.get("fid");if(D){console.log("Using temporary codicent from URL param:",D);const e=new URLSearchParams(L);e.delete("codicent"),H(e,{replace:!0})}if(e){(async()=>{const t=ue(e),o=le(e);E(),t.length>0||o.length>0?(ee(t),X(o),oe(!0),z(_(e))):z(_(e))})()}else t?O(t):o&&re(o)}),[]),r((()=>{ne&&"anonymous"===K&&fe.current!==ne&&(fe.current=ne,q.getFormById(ne).then((async e=>{E();const t=T().language,o=e.prompt.replace("{{fid}}",ne).replace("{{fname}}",e.name).replace("{{language}}",t);me(!0);const n=await F(o);me(!1),z(n),$(!1)})))}),[ne,E,q,z,K,F,T,me]),r((()=>{if(W&&!te){let e=W;Z.length>0&&(e=ge(e,Z)),J.length>0&&(e=de(e,J)),N(e),H({},{replace:!0}),z(null),X([]),ee([])}}),[W,te,N,H,ge,de,Z,J]);const Ce=e=>{const t=L.get("append");t&&(e+="\n---\n"+t),N(e,0,pe??void 0)};return e(A,{hideHeader:!0,hideFooter:!!ne||v,children:[e("div",{id:"chat-container",className:I.chatContainer,style:{backgroundImage:`url(${f("CHAT_BACKGROUND_IMAGE_URL")})`},children:[Y&&t("button",{onClick:()=>{Y&&M(-1)},"aria-label":_("Tillbaka"),style:{position:"absolute",top:12,left:12,zIndex:100,background:"var(--colorNeutralBackground1)",border:"none",cursor:"pointer",padding:8,borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",justifyContent:"center"},children:t(m,{style:{transform:"rotate(180deg)"}})}),t("div",{style:{marginLeft:Y?40:0},children:t(p,{title:y||_(f("APP_CHAT_TITLE")||"Chatt"),onNewChat:ne?void 0:()=>Q(!0)})}),e("div",{className:I.chatMessages,children:[k&&t(g,{sender:"bot",content:k}),f("SHOW_CHAT_PROMPTS")&&ie.length>0&&0===R.length&&t(g,{sender:"bot",content:_(f("CHAT_WELCOME")||_("Välkommen!")),children:ie.map(((o,n)=>e("div",{children:["> ",t("a",{href:"./#/chat",onClick:()=>{Ce(o.title+"\n---\n"+o.prompt)},children:_(o.title)}),t("br",{})]},`prompt-${n}`)))}),R.map(((o,n)=>e("div",{children:[(V&&n===R.length-1||!V&&n===R.length-2)&&t("div",{ref:B}),t(g,{sender:o.sender,content:o.content,isNew:o.isNew,showSuggestions:n===R.length-1,onSuggestionClicked:N},o.id)]},o.id))),ae&&t(g,{sender:"user",content:_("Översätter...")}),V&&t(c,{})]}),t(d,{codicent:U||i.context.selectedApp,disableSend:V,onSend:Ce,onSelectFiles:he,getImageUrl:j.getImageUrl,getFileInfo:e=>q.getFileInfo(e)})]}),t(l,{open:G,title:_("Vill du rensa chatten?"),content:_("En ny startas, men chatten kommer först sparas."),onYes:()=>{Q(!1),E()},onNo:()=>Q(!1)}),t(u,{open:te,templateVariables:J,filePlaceholders:Z,onTemplateVariablesChange:X,onFilePlaceholdersChange:ee,onConfirm:()=>oe(!1),onCancel:()=>{oe(!1),z(null),X([]),ee([])},uploadFile:q.uploadFile})]})};export{v as default};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ColumnDefinition } from "../components/ListView";
|
|
2
2
|
import type { ListConfig } from "../types";
|
|
3
3
|
import { CodicentAppState } from "../hooks/useCodicentApp";
|
|
4
|
+
import type { BulkAction } from "../types";
|
|
5
|
+
export type { BulkAction };
|
|
4
6
|
export interface ListPageProps {
|
|
5
7
|
state: CodicentAppState;
|
|
6
8
|
/** Returns column definitions for a given tag. Falls back to all data keys if not provided. */
|
|
@@ -12,6 +14,8 @@ export interface ListPageProps {
|
|
|
12
14
|
getListConfig?: (tag: string) => ListConfig | undefined;
|
|
13
15
|
/** Optional data filter applied after fetch. Useful for app-specific filtering (e.g. empty notes). */
|
|
14
16
|
filterData?: (data: DataMessage[], tag: string) => DataMessage[];
|
|
17
|
+
/** Returns bulk actions available for the given tag. When non-empty, row-selection checkboxes are shown. */
|
|
18
|
+
getBulkActions?: (tag: string) => BulkAction[] | undefined;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* ListPage — data fetch & cache behaviour
|
|
@@ -57,11 +61,12 @@ export interface ListPageProps {
|
|
|
57
61
|
* | `loadAll` | `"true"` | — | Removes PAGE_SIZE cap; disables Load-more |
|
|
58
62
|
* | `canAdd` | `"true"` | — | Shows Add Record button (opens RecordModal) |
|
|
59
63
|
* | `canEdit` | `"true"` | — | Shows per-row Edit/Delete buttons |
|
|
64
|
+
* | `canAttach` | `"true"` | — | Shows a file-attach control in the Add dialog (default off) |
|
|
60
65
|
* | `canExport` | `"false"` to hide | visible | Shows Export to Excel button |
|
|
61
66
|
* | `addUrl` | string | — | External URL opened on Add click (alternative to modal) |
|
|
62
67
|
* | `q` | string | — | Initial search term; kept in sync with search box |
|
|
63
68
|
* | `filter_<field>` | string | — | Client-side row filter; `%USERNAME%` resolves to current user |
|
|
64
69
|
*/
|
|
65
|
-
export declare const ListPage: ({ state, getColumnDefs, getListConfig, filterData }: ListPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare const ListPage: ({ state, getColumnDefs, getListConfig, filterData, getBulkActions }: ListPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
66
71
|
export default ListPage;
|
|
67
72
|
//# sourceMappingURL=ListPage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListPage.d.ts","sourceRoot":"","sources":["../../../src/pages/ListPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"ListPage.d.ts","sourceRoot":"","sources":["../../../src/pages/ListPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAuB3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAuE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,gBAAgB,CAAC;IACxB,+FAA+F;IAC/F,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,gBAAgB,EAAE,CAAC;IACpD;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IACxD,sGAAsG;IACtG,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,WAAW,EAAE,CAAC;IACjE,4GAA4G;IAC5G,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,GAAG,SAAS,CAAC;CAC5D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,QAAQ,wEAAyE,aAAa,4CAsmC1G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useState as o,useRef as n,useMemo as r,useEffect as i,useCallback as a}from"react";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import{makeStyles as s,Button as c,Dialog as l,DialogSurface as d,DialogBody as p,DialogTitle as m,DialogContent as u,DialogActions as g}from"@fluentui/react-components";import"../components/Spinner.js";import f from"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../components/Dialog.js";import"../components/ChatInput.js";import"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import{ArrowLeft24Regular as h,ArrowClockwise24Regular as j,ArrowDownload24Regular as x,Add24Regular as y}from"@fluentui/react-icons";import"../services/codicent.js";import{dataCache as w}from"../services/dataCache.js";import S from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import{exportToExcel as A}from"../utils/excelExport.js";import"./AppFrame.js";import"./Canvas.js";import"./Chat.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Menu.js";import"./Log.js";import"./Login.js";import"./Home.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import{useSearchParams as C,useNavigate as k}from"react-router-dom";import"./Purchase.js";import"../components/Content.js";import{Page as v}from"../components/Page.js";import"./QrScan.js";import b from"../hooks/useLocalization.js";import"../components/FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import"../hooks/useAppStyles.js";import{useUserRoles as D}from"../hooks/useUserRoles.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/AiInput.js";import I from"../components/SearchBox.js";import"../components/DataMessagePicker.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/QrCodeDialog.js";import"../components/QrScanner.js";import"../components/OfflineMessage.js";import"../components/LanguageSelector.js";import M from"../components/ListView.js";import{RecordModal as $}from"../components/RecordModal.js";import"../components/BulkUploadDialog.js";import"../components/CookieBanner.js";import"../components/audit/AuditCircularProgress.js";import"../components/audit/AuditHorizontalProgress.js";import"../components/audit/AuditRoleIndicator.js";import"../components/audit/AuditUnitSwitcher.js";import"../components/audit/AuditAnswerCell.js";import"../components/audit/AuditSearchBar.js";import"../components/audit/AuditFilterChips.js";import"../components/audit/AuditFilterBar.js";import"../components/audit/AuditGroupsProgress.js";import"../components/audit/AuditSummaryDashboard.js";import"../components/audit/AuditRequirementDialog.js";import"../components/audit/AuditUnitExportDialog.js";import"../components/audit/AuditUnitImportDialog.js";import"../components/audit/AuditBulkExportDialog.js";import"../components/audit/AuditBulkUploadDialog.js";import"../components/audit/AuditSortPresets.js";import{l as _}from"../node_modules/lodash/lodash.js";const P=s({container:{width:"100%",flex:1,maxWidth:"100%",height:"100%",minHeight:0,backgroundColor:"#ffffff",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},touchAction:"pan-y",paddingLeft:"16px",paddingRight:"16px"},listContainer:{position:"relative",overflow:"hidden",flex:1,minHeight:0,marginTop:"10px"},loadingIndicator:{padding:"8px 0",color:"#666"},headerRow:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",flexWrap:"wrap"},buttonGroup:{display:"flex",gap:"8px",flexWrap:"wrap"},addButton:{minWidth:"auto",whiteSpace:"nowrap"},recordsCount:{fontSize:"14px",color:"#666",marginTop:"8px"},backButton:{marginBottom:"10px"},searchBox:{marginTop:"8px"},loadMoreContainer:{display:"flex",justifyContent:"center",padding:"16px 0",borderTop:"1px solid #e0e0e0",marginTop:"4px"}}),T=500,B=({state:s,getColumnDefs:B,getListConfig:E,filterData:N})=>{const[R,L]=C(),F=R.get("tag")||"logbook",U=R.get("title")||"",H=R.get("contentTitle"),O="true"===R.get("loadAll"),W="true"===R.get("canAdd"),q="true"===R.get("canEdit"),z="false"!==R.get("canExport"),V=R.has("compact"),G=R.get("addUrl")||"",J=R.get("q")||"",Q=H?`${F}-${J}-${H}`:`${F}-${J||"all"}`,K=w.get(Q),[X,Y]=o(J),[Z,tt]=o(J),{service:et}=s,[ot,nt]=o((()=>K??[])),[rt,it]=o((()=>!K)),[at,st]=o((()=>!!K&&!O&&!H&&K.length>=T)),[ct,lt]=o(!1),dt=n(null),pt=n(J),mt=n(""),ut=n(0),gt=n(et);gt.current=et;const ft=!!et,[ht,jt]=o(0),[xt,yt]=o(null),wt=P(),{t:St}=b(),At=k(),{getCurrentUserName:Ct}=D(et,s.context.nickname,s.context.selectedApp),kt=r((()=>(H?[{key:H,title:H,maxWidth:250}]:E?E(F)?.columns??[]:B?B(F):[]).map((t=>({...t,title:t.title?St(t.title):void 0})))),[H,F,St,B,E]),[vt,bt]=o(!1),[Dt,It]=o(null),[Mt,$t]=o(!1),[_t,Pt]=o(null),Tt=r((()=>`listpage_searches_${F}`),[F]),Bt=t=>{try{const e=localStorage.getItem(t);return e?JSON.parse(e):[]}catch{return[]}},[Et,Nt]=o((()=>Bt(Tt)));i((()=>{Nt(Bt(Tt))}),[Tt]);const Rt=a((t=>{const e=t.trim();e&&Nt((t=>{const o=[e,...t.filter((t=>t!==e))].slice(0,20);try{localStorage.setItem(Tt,JSON.stringify(o))}catch{}return o}))}),[Tt]),Lt=a((t=>{Nt((e=>{const o=e.filter((e=>e!==t));try{localStorage.setItem(Tt,JSON.stringify(o))}catch{}return o}))}),[Tt]),Ft=r((()=>_.debounce((t=>tt(t)),500)),[tt]);i((()=>()=>{Ft.cancel()}),[Ft]);const Ut=a((t=>{Y(t),Ft(t)}),[Ft]),Ht=a((t=>{Rt(t)}),[Rt]);i((()=>{if(!R.get("q")){const t=R.get(`filter_${F}`);if(t){let e=t;if("%USERNAME%"===e){const t=Ct();if(!t)return;e=t}Y(e),tt(e),pt.current=e}}}),[F,R,Ct]),i((()=>{const t=R.get("q")||"";t!==pt.current&&t!==Z&&(Y(t),tt(t),pt.current=t,mt.current="")}),[R]),i((()=>(dt.current&&clearTimeout(dt.current),dt.current=setTimeout((()=>{if(pt.current!==X){const t=new URLSearchParams(R);X?t.set("q",X):t.delete("q"),L(t,{replace:!0}),pt.current=X}}),500),()=>{dt.current&&clearTimeout(dt.current)})),[X,R,L]),i((()=>{if(!gt.current)return;const t=`${F}-${H}-${O}-${ht}-${Z}`;if(t===mt.current)return;mt.current=t;const e=++ut.current,o=()=>e===ut.current,n=H?`${F}-${Z}-${H}`:`${F}-${Z||"all"}`,r=w.get(n);if(!r){if(st(!1),it(!0),H)gt.current.getMessagesFast([F],Z).then((t=>{if(!o())return;const e=t.map((t=>{const e=new Date(t.createdAt).toLocaleString();return{id:t.id,data:{[H]:new S(t.content).content,createdAt:e},fileId:null,fileIds:[],tags:[F],mentions:[gt.current.codicent],createdAt:e}}));w.set(n,e),nt(e)})).catch(console.warn).finally((()=>{o()&&it(!1)}));else{const t=Z||"",e=O||t?void 0:T;gt.current.readDataMessages(F,t,void 0,0,e).then((e=>{o()&&(w.set(n,e),nt(e),st(!O&&!t&&e.length===T))})).catch(console.warn).finally((()=>{o()&&it(!1)}))}return()=>{mt.current=""}}if(nt(r),it(!1),st(!O&&!H&&r.length>=T),!H&&!Z&&r.length>0){const t=r.reduce(((t,e)=>e.createdAt>t?e.createdAt:t),r[0].createdAt);gt.current.readDataMessages(F,"",void 0,void 0,void 0,t).then((t=>{o()&&nt((e=>{const o=new Set(e.map((t=>t.id))),r=t.filter((t=>!o.has(t.id)));if(0===r.length)return e;const i=[...r,...e];return w.set(n,i),i}))})).catch(console.warn)}}),[F,H,O,Z,ht,ft]);const Ot=r((()=>{const t={};R.forEach(((e,o)=>{o.startsWith("filter_")&&(t[o.replace("filter_","")]=e)}));let e=ot.map(((t,e)=>({item:t,index:e})));for(const[o,n]of Object.entries(t)){const t=n.replace("%USERNAME%",Ct()),r=s.context.nickname||"";e=e.filter((({item:e})=>{const n=e.data[o];return null!=n&&(String(n).includes(t)||String(n).includes(r))}))}if(N){const t=N(e.map((({item:t})=>t)),F),o=new Set(t.map((t=>t.id)));e=e.filter((({item:t})=>o.has(t.id)))}const o=e.map((({item:t,index:e})=>({...t.data,createdAt:t.createdAt,_id:t.id,originalMessageId:t.originalMessageId||t.id,_fileIds:t.fileIds??[],_index:e}))),n=E?.(F)?.deduplicateBy;if(n){const t=Array.isArray(n)?n:[n],e=e=>{for(const o of t){const t=e[o];if(null!=t&&""!==String(t).trim())return String(t)}},r=new Set;return o.filter((t=>{const o=e(t);return void 0===o||!r.has(o)&&(r.add(o),!0)}))}return o}),[ot,R,s.context.nickname,Ct,N,F,E]),Wt=r((()=>{const t=(X||"").trim().toLowerCase();if(!t)return Ot;const e=kt.filter((t=>!t.hidden)).map((t=>t.key));return Ot.filter((o=>{for(const n of e)if(Array.isArray(n))for(const e of n){const n=o[e];if(null!=n&&String(n).toLowerCase().includes(t))return!0}else{const e=o[n];if(null!=e&&String(e).toLowerCase().includes(t))return!0}return!1}))}),[Ot,X,kt]),qt=a((()=>{w.clearPattern(F),mt.current="",jt((t=>t+1))}),[F]),zt=a((async()=>{lt(!0);try{const t=await gt.current.readDataMessages(F,"",void 0,ot.length,T),e=[...ot,...t];nt(e),w.set(`${F}-all`,e),st(t.length===T)}catch(t){console.warn(t)}finally{lt(!1)}}),[ot,F]),Vt=a((t=>{yt(t)}),[]),Gt=()=>{$t(!1),Pt(null)},Jt=a((async()=>{const t=`${F}_${(new Date).toISOString().split("T")[0]}`.replace(/[/\\:*?"<>|]/g,"_");const e=null!==xt?xt:Wt;await A(e,kt,t,St)||console.warn("No data to export")}),[xt,Wt,kt,F,St]),Qt=r((()=>null!==xt?xt.length:Wt.length),[xt,Wt]);return t(v,{hideHeader:!0,children:e("div",{className:wt.container,children:[t("div",{className:wt.backButton,children:t(c,{appearance:"subtle",icon:t(h,{}),onClick:()=>At(-1),children:St("Tillbaka")})}),e("div",{className:wt.headerRow,children:[t(f,{title:St(U||"Loggbok")}),e("div",{className:wt.buttonGroup,children:[t(c,{appearance:"subtle",icon:t(j,{}),onClick:qt,title:St("Refresh"),children:St("Refresh")}),z&&t(c,{appearance:"subtle",icon:t(x,{}),onClick:Jt,title:St("Export to Excel"),children:St("Export to Excel")}),(W||G)&&t(c,{appearance:"primary",icon:t(y,{}),onClick:W?()=>{It(null),bt(!0)}:()=>window.open(G,"_blank"),className:wt.addButton,children:St("Add Record")})]})]}),t("div",{className:wt.searchBox,children:t(I,{placeholder:St("Sök")+"...",value:X,onChange:Ut,recentSearches:Et,onCommitSearch:Ht,onRemoveRecentSearch:Lt})}),!rt&&e("div",{className:wt.recordsCount,children:[St("Total"),": ",Qt," ",St("records"),Qt!==ot.length&&` (${St("filtered from")} ${ot.length})`]}),e("div",{className:wt.listContainer,children:[rt&&ot.length>0&&t("div",{className:wt.loadingIndicator,children:St("Söker")+"..."}),rt&&0===ot.length?t("p",{children:St("Söker")+"..."}):t(M,{data:Wt,columns:kt,canEdit:q,onEdit:(t,e)=>{const o=ot[e];o&&(It({data:{...o.data,_fileIds:o.fileIds??[]},index:e}),bt(!0))},onDelete:(t,e)=>{const o=ot[e];o&&(Pt({index:e,id:o.id}),$t(!0))},onToggleCheckbox:async(t,e,o,n)=>{const r=ot[n];if(r){const t=Array.isArray(e)?e[0]:e,i={...r.data,[t]:String(o)},a=await et.updateDataMessage(r.id,i);nt((t=>{const e=[...t];return e[n]={...r,id:a,data:i},e})),w.clearPattern(F)}},onEnumChange:async(t,e,o,n)=>{const r=ot[n];if(r){const t=Array.isArray(e)?e[0]:e,i={...r.data,[t]:o},a=await et.updateDataMessage(r.id,i);nt((t=>{const e=[...t];return e[n]={...r,id:a,data:i},e})),w.clearPattern(F)}},onFilteredDataChange:Vt,compact:V})]}),at&&!X.trim()&&t("div",{className:wt.loadMoreContainer,children:t(c,{appearance:"primary",size:"medium",onClick:zt,disabled:ct,children:ct?St("Laddar..."):St("Visa fler")+` (${ot.length} ${St("laddade")})`})}),t($,{open:vt,onClose:()=>bt(!1),onSave:async t=>{const e=new Set(kt.filter((t=>"thumbnail"===t.type)).map((t=>Array.isArray(t.key)?t.key[0]:t.key)));if(Dt){const o=ot[Dt.index];if(o){const n={};for(const o in t){if(e.has(o))continue;const r=t[o];n[o]=null==r?"":String(r)}const r=await et.updateDataMessage(o.id,n);nt((t=>{const e=[...t];return e[Dt.index]={...o,id:r,data:n},e})),w.clearPattern(F)}}else{const o={};for(const n in t){if(e.has(n))continue;const r=t[n];o[n]=null==r?"":String(r)}const n={id:await et.createDataMessage(F,o),data:o,createdAt:(new Date).toISOString(),fileId:null,fileIds:[],tags:[F],mentions:[et.codicent]};nt((t=>[n,...t])),w.clearPattern(F)}},columns:kt,initialData:Dt?.data}),t(l,{open:Mt,onOpenChange:(t,e)=>!e.open&&Gt(),children:t(d,{children:e(p,{children:[t(m,{children:St("Confirm Delete")}),t(u,{children:St("Are you sure you want to delete this record? This action cannot be undone.")}),e(g,{children:[t(c,{appearance:"secondary",onClick:Gt,children:St("Cancel")}),t(c,{appearance:"primary",onClick:async()=>{if(_t)try{await et.deleteDataMessage(_t.id),nt((t=>t.filter(((t,e)=>e!==_t.index)))),w.clearPattern(F)}catch(t){console.error("Failed to delete record:",t)}finally{$t(!1),Pt(null)}},children:St("Delete")})]})]})})})]})})};export{B as ListPage,B as default};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as r,useRef as n,useCallback as a,useMemo as o,useEffect as i}from"react";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import{makeStyles as s,Button as c,Dialog as l,DialogSurface as d,DialogBody as p,DialogTitle as m,DialogContent as u,DialogActions as g}from"@fluentui/react-components";import"../components/Spinner.js";import f from"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../components/Dialog.js";import"../components/ChatInput.js";import"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import{ArrowLeft24Regular as h,ArrowClockwise24Regular as y,ArrowDownload24Regular as j,Add24Regular as S}from"@fluentui/react-icons";import"../services/codicent.js";import{dataCache as x}from"../services/dataCache.js";import w from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import{exportToExcel as A}from"../utils/excelExport.js";import{formatReference as C}from"../utils/reference.js";import"./AppFrame.js";import"./Canvas.js";import"./Chat.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Menu.js";import"./Log.js";import"./Login.js";import"./Home.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import{useSearchParams as k,useNavigate as v}from"react-router-dom";import"./Purchase.js";import"../components/Content.js";import{Page as b}from"../components/Page.js";import"./QrScan.js";import D from"../hooks/useLocalization.js";import"../components/FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import"../hooks/useAppStyles.js";import M from"../hooks/useToaster.js";import{useUserRoles as I}from"../hooks/useUserRoles.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/AiInput.js";import $ from"../components/SearchBox.js";import T from"../components/DataMessagePicker.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/QrCodeDialog.js";import"../components/QrScanner.js";import"../components/OfflineMessage.js";import"../components/LanguageSelector.js";import _ from"../components/ListView.js";import{RecordModal as F}from"../components/RecordModal.js";import"../components/BulkUploadDialog.js";import"../components/CookieBanner.js";import"../components/audit/AuditCircularProgress.js";import"../components/audit/AuditHorizontalProgress.js";import"../components/audit/AuditRoleIndicator.js";import"../components/audit/AuditUnitSwitcher.js";import"../components/audit/AuditAnswerCell.js";import"../components/audit/AuditSearchBar.js";import"../components/audit/AuditFilterChips.js";import"../components/audit/AuditFilterBar.js";import"../components/audit/AuditGroupsProgress.js";import"../components/audit/AuditSummaryDashboard.js";import"../components/audit/AuditRequirementDialog.js";import"../components/audit/AuditUnitExportDialog.js";import"../components/audit/AuditUnitImportDialog.js";import"../components/audit/AuditBulkExportDialog.js";import"../components/audit/AuditBulkUploadDialog.js";import"../components/audit/AuditSortPresets.js";import{l as K}from"../node_modules/lodash/lodash.js";const P=s({container:{width:"100%",flex:1,maxWidth:"100%",height:"100%",minHeight:0,backgroundColor:"#ffffff",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},touchAction:"pan-y",paddingLeft:"16px",paddingRight:"16px"},listContainer:{position:"relative",overflow:"hidden",flex:1,minHeight:0,marginTop:"10px"},loadingIndicator:{padding:"8px 0",color:"#666"},headerRow:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",flexWrap:"wrap"},buttonGroup:{display:"flex",gap:"8px",flexWrap:"wrap"},addButton:{minWidth:"auto",whiteSpace:"nowrap"},recordsCount:{fontSize:"14px",color:"#666",marginTop:"8px"},backButton:{marginBottom:"10px"},searchBox:{marginTop:"8px"},loadMoreContainer:{display:"flex",justifyContent:"center",padding:"16px 0",borderTop:"1px solid #e0e0e0",marginTop:"4px"}}),R=500,B=({state:s,getColumnDefs:B,getListConfig:E,filterData:L,getBulkActions:N})=>{const[U,W]=k(),z=U.get("tag")||"logbook",O=U.get("title")||"",H=U.get("contentTitle"),q="true"===U.get("loadAll"),V="true"===U.get("canAdd"),G="true"===U.get("canEdit"),J="true"===U.get("canAttach"),Q="false"!==U.get("canExport"),X=U.has("compact"),Y=U.get("addUrl")||"",Z="true"===U.get("openAdd"),ee=U.get("q")||"",te=H?`${z}-${ee}-${H}`:`${z}-${ee||"all"}`,re=x.get(te),[ne,ae]=r(ee),[oe,ie]=r(ee),{service:se}=s,[ce,le]=r((()=>re??[])),[de,pe]=r((()=>!re)),[me,ue]=r((()=>!!re&&!q&&!H&&re.length>=R)),[ge,fe]=r(!1),he=n(null),ye=n(ee),je=n(""),Se=n(0),xe=n(se);xe.current=se;const we=!!se,[Ae,Ce]=r(0),[ke,ve]=r(null),[be,De]=r(!1),Me=P(),{t:Ie}=D(),$e=v(),{notify:Te,ToasterComponent:_e}=M(),[Fe,Ke]=r(new Set),Pe=a(((e,t)=>{Ke((r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}))}),[]),Re=e=>e instanceof Error?e.message:String(e),{getCurrentUserName:Be}=I(se,s.context.nickname,s.context.selectedApp),Ee=o((()=>(H?[{key:H,title:H,maxWidth:250}]:E?E(z)?.columns??[]:B?B(z):[]).map((e=>({...e,title:e.title?Ie(e.title):void 0})))),[H,z,Ie,B,E]),[Le,Ne]=r(!1),[Ue,We]=r(null),[ze,Oe]=r(!1),[He,qe]=r(null),Ve=o((()=>N?.(z)??[]),[N,z]),Ge=Ve.length>0,[Je,Qe]=r(new Set),[Xe,Ye]=r(null),[Ze,et]=r(null),[tt,rt]=r(null),[nt,at]=r(!1);i((()=>{Qe(new Set)}),[z]);const ot=a((e=>{Qe((t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r}))}),[]),it=a((e=>{Qe((t=>{const r=e.map((e=>String(e.originalMessageId??e._id??e.id??""))),n=r.length>0&&r.every((e=>t.has(e))),a=new Set(t);return n?r.forEach((e=>a.delete(e))):r.forEach((e=>a.add(e))),a}))}),[]),st=o((()=>`listpage_searches_${z}`),[z]),ct=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t):[]}catch{return[]}},[lt,dt]=r((()=>ct(st)));i((()=>{dt(ct(st))}),[st]);const pt=n(!1),mt=n(!1);i((()=>{Z&&V&&!pt.current&&(pt.current=!0,mt.current=!0,We(null),Ne(!0))}),[Z,V]);const ut=a((e=>{const t=e.trim();t&&dt((e=>{const r=[t,...e.filter((e=>e!==t))].slice(0,20);try{localStorage.setItem(st,JSON.stringify(r))}catch{}return r}))}),[st]),gt=a((e=>{dt((t=>{const r=t.filter((t=>t!==e));try{localStorage.setItem(st,JSON.stringify(r))}catch{}return r}))}),[st]),ft=o((()=>K.debounce((e=>ie(e)),500)),[ie]);i((()=>()=>{ft.cancel()}),[ft]);const ht=a((e=>{ae(e),ft(e)}),[ft]),yt=a((e=>{ut(e)}),[ut]);i((()=>{if(!U.get("q")){const e=U.get(`filter_${z}`);if(e){let t=e;if("%USERNAME%"===t){const e=Be();if(!e)return;t=e}ae(t),ie(t),ye.current=t}}}),[z,U,Be]),i((()=>{const e=U.get("q")||"";e!==ye.current&&e!==oe&&(ae(e),ie(e),ye.current=e,je.current="")}),[U]),i((()=>(he.current&&clearTimeout(he.current),he.current=setTimeout((()=>{if(ye.current!==ne){const e=new URLSearchParams(U);ne?e.set("q",ne):e.delete("q"),W(e,{replace:!0}),ye.current=ne}}),500),()=>{he.current&&clearTimeout(he.current)})),[ne,U,W]),i((()=>{if(!xe.current)return;const e=`${z}-${H}-${q}-${Ae}-${oe}`;if(e===je.current)return;je.current=e;const t=++Se.current,r=()=>t===Se.current,n=H?`${z}-${oe}-${H}`:`${z}-${oe||"all"}`,a=x.get(n);if(!a){if(ue(!1),pe(!0),H)xe.current.getMessagesFast([z],oe).then((e=>{if(!r())return;const t=e.map((e=>{const t=new Date(e.createdAt).toLocaleString();return{id:e.id,data:{[H]:new w(e.content).content,createdAt:t},fileId:null,fileIds:[],tags:[z],mentions:[xe.current.codicent],createdAt:t}}));x.set(n,t),le(t)})).catch(console.warn).finally((()=>{r()&&pe(!1)}));else{const e=oe||"",t=q||e?void 0:R;xe.current.readDataMessages(z,e,void 0,0,t).then((t=>{r()&&(x.set(n,t),le(t),ue(!q&&!e&&t.length===R))})).catch(console.warn).finally((()=>{r()&&pe(!1)}))}return()=>{je.current=""}}if(le(a),pe(!1),ue(!q&&!H&&a.length>=R),!H&&!oe&&a.length>0){const e=a.reduce(((e,t)=>t.createdAt>e?t.createdAt:e),a[0].createdAt);xe.current.readDataMessages(z,"",void 0,void 0,void 0,e).then((e=>{r()&&le((t=>{const r=new Set(t.map((e=>e.id))),a=e.filter((e=>!r.has(e.id)));if(0===a.length)return t;const o=[...a,...t];return x.set(n,o),o}))})).catch(console.warn)}}),[z,H,q,oe,Ae,we]);const jt=o((()=>{const e={};U.forEach(((t,r)=>{r.startsWith("filter_")&&(e[r.replace("filter_","")]=t)}));let t=ce.map(((e,t)=>({item:e,index:t})));for(const[r,n]of Object.entries(e)){if("__empty__"===n){t=t.filter((({item:e})=>{const t=e.data[r];return null==t||""===String(t).trim()}));continue}const e=n.replace("%USERNAME%",Be()),a=s.context.nickname||"";(e||a)&&(t=t.filter((({item:t})=>{const n=t.data[r];if(null==n)return!1;const o=String(n);return e&&o.includes(e)||a&&o.includes(a)})))}if(L){const e=L(t.map((({item:e})=>e)),z),r=new Map(t.map((({item:e,index:t})=>[e.id,t])));t=e.map((e=>{const t=r.get(e.id);return void 0===t?void 0:{item:e,index:t}})).filter((e=>void 0!==e))}const r=t.map((({item:e,index:t})=>({...e.data,createdAt:e.createdAt,_id:e.id,originalMessageId:e.originalMessageId||e.id,_fileIds:e.fileIds??[],_index:t}))),n=E?.(z)?.deduplicateBy;if(n){const e=Array.isArray(n)?n:[n],t=t=>{for(const r of e){const e=t[r];if(null!=e&&""!==String(e).trim())return String(e)}},a=new Set;return r.filter((e=>{const r=t(e);return void 0===r||!a.has(r)&&(a.add(r),!0)}))}return r}),[ce,U,s.context.nickname,Be,L,z,E]),St=o((()=>{const e=(ne||"").trim().toLowerCase();if(!e)return jt;const t=Ee.filter((e=>!e.hidden)).map((e=>e.key));if(e.includes("*")){const r=new RegExp(e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*"),"i");return jt.filter((e=>{for(const n of t)if(Array.isArray(n))for(const t of n){const n=e[t];if(null!=n&&r.test(String(n)))return!0}else{const t=e[n];if(null!=t&&r.test(String(t)))return!0}return!1}))}return jt.filter((r=>{for(const n of t)if(Array.isArray(n))for(const t of n){const n=r[t];if(null!=n&&String(n).toLowerCase().includes(e))return!0}else{const t=r[n];if(null!=t&&String(t).toLowerCase().includes(e))return!0}return!1}))}),[jt,ne,Ee]),xt=a((()=>{x.clearPattern(z),je.current="",Ce((e=>e+1))}),[z]),wt=a((async()=>{fe(!0);try{const e=await xe.current.readDataMessages(z,"",void 0,ce.length,R),t=[...ce,...e];le(t),x.set(`${z}-all`,t),ue(e.length===R)}catch(e){console.warn(e)}finally{fe(!1)}}),[ce,z]),At=a((e=>{ve(e)}),[]),Ct=a((e=>{De(e)}),[]);i((()=>{if(!be||!me||ge||de)return;const e=Se.current;fe(!0),xe.current.readDataMessages(z,"",void 0,ce.length,void 0).then((t=>{e===Se.current&&(le((e=>{const r=new Set(e.map((e=>e.id))),n=[...e,...t.filter((e=>!r.has(e.id)))];return x.set(`${z}-all`,n),n})),ue(!1))})).catch(console.warn).finally((()=>fe(!1)))}),[be,me,ge,de,z,ce.length]);const kt=()=>{Oe(!1),qe(null)},vt=a((async()=>{const e=`${z}_${(new Date).toISOString().split("T")[0]}`.replace(/[/\\:*?"<>|]/g,"_");const t=null!==ke?ke:St;await A(t,Ee,e,Ie)||console.warn("No data to export")}),[ke,St,Ee,z,Ie]),bt=o((()=>null!==ke?ke.length:St.length),[ke,St]),Dt=o((()=>{if(Xe)return Ee.find((e=>(Array.isArray(e.key)?e.key[0]:e.key)===Xe.referenceColumnKey))}),[Xe,Ee]),Mt=o((()=>{if(Dt?.referenceCascadeFromKey)return Ee.find((e=>(Array.isArray(e.key)?e.key[0]:e.key)===Dt.referenceCascadeFromKey))}),[Dt,Ee]),It=a((()=>{Ye(null),et(null),rt(null)}),[]),$t=a((async e=>{if(void 0!==e.setFieldKey&&se){at(!0);try{const t=ce.filter((e=>{const t=String(e.originalMessageId||e.id);return Je.has(t)}));for(const r of t)await se.updateDataMessage(r.id,{...r.data,[e.setFieldKey]:e.setFieldValue??""});x.clearPattern(z),Qe(new Set),xt(),Te(Ie("{n} poster uppdaterade").replace("{n}",String(t.length)),"","","success")}catch(e){Te(Ie("Uppdateringen misslyckades"),Re(e),"","error")}finally{at(!1)}}}),[ce,Je,se,z,xt,Te,Ie]),Tt=a((async e=>{if(e.handler&&se){at(!0);try{const t=ce.filter((e=>{const t=String(e.originalMessageId||e.id);return Je.has(t)}));await e.handler(t,se),x.clearPattern(z),Qe(new Set),xt(),Te(Ie("{n} poster uppdaterade").replace("{n}",String(t.length)),"","","success")}catch(e){Te(Ie("Uppdateringen misslyckades"),Re(e),"","error")}finally{at(!1)}}}),[ce,Je,se,z,xt,Te,Ie]),_t=a((async()=>{if(Xe&&Dt&&Ze&&(!Mt||tt)){at(!0);try{const e=Array.isArray(Dt.key)?Dt.key[0]:Dt.key,t=Dt.referenceLabelKey??`${e}_label`,r=C(Ze.tag,Ze.originalMessageId||Ze.id);let n,a,o,i;Mt&&tt&&(n=Array.isArray(Mt.key)?Mt.key[0]:Mt.key,a=Mt.referenceLabelKey??`${n}_label`,o=C(tt.tag,tt.originalMessageId||tt.id),i=tt.label);const s=ce.filter((e=>{const t=String(e.originalMessageId||e.id);return Je.has(t)}));for(const c of s){const s={...c.data,[e]:r,[t]:Ze.label};n&&o&&(s[n]=o,a&&i&&(s[a]=i)),await se.updateDataMessage(c.id,s)}x.clearPattern(z),Qe(new Set),It(),xt(),Te(Ie("{n} poster uppdaterade").replace("{n}",String(s.length)),"","","success")}catch(e){Te(Ie("Uppdateringen misslyckades"),Re(e),"","error")}finally{at(!1)}}}),[Xe,Dt,Mt,Ze,tt,ce,Je,se,z,It,xt,Te,Ie]);return e(b,{hideHeader:!0,children:[t(_e,{}),e("div",{className:Me.container,children:[t("div",{className:Me.backButton,children:t(c,{appearance:"subtle",icon:t(h,{}),onClick:()=>$e(-1),children:Ie("Tillbaka")})}),e("div",{className:Me.headerRow,children:[t(f,{title:Ie(O||"Loggbok")}),e("div",{className:Me.buttonGroup,children:[t(c,{appearance:"subtle",icon:t(y,{}),onClick:xt,title:Ie("Refresh"),children:Ie("Refresh")}),Q&&t(c,{appearance:"subtle",icon:t(j,{}),onClick:vt,title:Ie("Export to Excel"),children:Ie("Export to Excel")}),(V||Y)&&t(c,{appearance:"primary",icon:t(S,{}),onClick:V?()=>{We(null),Ne(!0)}:()=>window.open(Y,"_blank"),className:Me.addButton,children:Ie("Add Record")})]})]}),t("div",{className:Me.searchBox,children:t($,{placeholder:Ie("Sök")+"...",value:ne,onChange:ht,recentSearches:lt,onCommitSearch:yt,onRemoveRecentSearch:gt})}),!de&&e("div",{className:Me.recordsCount,children:[Ie("Total"),": ",bt," ",Ie("records"),bt!==ce.length&&` (${Ie("filtered from")} ${ce.length})`]}),e("div",{className:Me.listContainer,children:[Ge&&Je.size>0&&e("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",background:"#f0f6ff",border:"1px solid #cfe0ff",borderRadius:"4px",flexWrap:"wrap"},children:[e("span",{style:{fontWeight:600},children:[Je.size," ",Ie("valda")]}),Ve.map((e=>t(c,{appearance:"primary",size:"small",disabled:nt,onClick:()=>{void 0!==e.setFieldKey?$t(e):e.handler?Tt(e):(Ye(e),et(null),rt(null))},children:Ie(e.label)},e.label))),t(c,{appearance:"subtle",size:"small",onClick:()=>Qe(new Set),children:Ie("Rensa")})]}),de&&ce.length>0&&t("div",{className:Me.loadingIndicator,children:Ie("Söker")+"..."}),de&&0===ce.length?t("p",{children:Ie("Söker")+"..."}):t(_,{data:St,columns:Ee,canEdit:G,onEdit:(e,t)=>{const r=ce[t];r&&(We({data:{...r.data,_fileIds:r.fileIds??[]},index:t}),Ne(!0))},onDelete:(e,t)=>{const r=ce[t];r&&(qe({index:t,id:r.id}),Oe(!0))},onToggleCheckbox:async(e,t,r,n)=>{const a=ce[n];if(a){const e=Array.isArray(t)?t[0]:t,o={...a.data,[e]:String(r)};Pe(n,!0);try{const e=await se.updateDataMessage(a.id,o);le((t=>{const r=[...t];return r[n]={...a,id:e,data:o},r})),x.clearPattern(z),Te(Ie("Sparat"),"","","success")}catch(e){Te(Ie("Kunde inte spara"),Re(e),"","error")}finally{Pe(n,!1)}}},onEnumChange:async(e,t,r,n)=>{const a=ce[n];if(a){const e=Array.isArray(t)?t[0]:t,o={...a.data,[e]:r};Pe(n,!0);try{const e=await se.updateDataMessage(a.id,o);le((t=>{const r=[...t];return r[n]={...a,id:e,data:o},r})),x.clearPattern(z),Te(Ie("Sparat"),"","","success")}catch(e){Te(Ie("Kunde inte spara"),Re(e),"","error")}finally{Pe(n,!1)}}},onValueChange:async(e,t,r,n)=>{const a=ce[n];if(a){const e=Array.isArray(t)?t[0]:t,o={...a.data,[e]:r};Pe(n,!0);try{const e=await se.updateDataMessage(a.id,o);le((t=>{const r=[...t];return r[n]={...a,id:e,data:o},r})),x.clearPattern(z),Te(Ie("Sparat"),"","","success")}catch(e){Te(Ie("Kunde inte spara"),Re(e),"","error")}finally{Pe(n,!1)}}},onReferenceChange:async(e,t,r,n)=>{const a=ce[n];if(a){const e=Array.isArray(t)?t[0]:t,o=Ee.find((t=>(Array.isArray(t.key)?t.key[0]:t.key)===e)),i=o?.referenceLabelKey??`${e}_label`,s=C(r.tag,r.originalMessageId||r.id),c={...a.data,[e]:s,[i]:r.label};Pe(n,!0);try{const e=await se.updateDataMessage(a.id,c);le((t=>{const r=[...t];return r[n]={...a,id:e,data:c},r})),x.clearPattern(z),Te(Ie("Sparat"),"","","success")}catch(e){Te(Ie("Kunde inte spara"),Re(e),"","error")}finally{Pe(n,!1)}}},savingRows:Fe,service:se,onFilteredDataChange:At,onActiveFiltersChange:Ct,compact:X,selectable:Ge,selectedRowKeys:Je,onToggleRow:ot,onToggleAll:it},z)]}),me&&!ne.trim()&&t("div",{className:Me.loadMoreContainer,children:t(c,{appearance:"primary",size:"medium",onClick:wt,disabled:ge,children:ge?Ie("Laddar..."):Ie("Visa fler")+` (${ce.length} ${Ie("laddade")})`})}),t(F,{open:Le,onClose:()=>{Ne(!1),mt.current&&(mt.current=!1,$e(-1))},onSave:async(e,t)=>{const r=new Set(Ee.filter((e=>"thumbnail"===e.type)).map((e=>Array.isArray(e.key)?e.key[0]:e.key)));try{if(Ue){const t=ce[Ue.index];if(t){const n={};for(const t in e){if(r.has(t))continue;const a=e[t];n[t]=null==a?"":String(a)}const a=await se.updateDataMessage(t.id,n);le((e=>{const r=[...e];return r[Ue.index]={...t,id:a,data:n},r})),x.clearPattern(z)}}else{const n={};for(const t in e){if(r.has(t))continue;const a=e[t];n[t]=null==a?"":String(a)}const a={id:await se.createDataMessage(z,n,void 0,t),data:n,createdAt:(new Date).toISOString(),fileId:null,fileIds:t??[],tags:[z],mentions:[se.codicent]};le((e=>[a,...e])),x.clearPattern(z)}Te(Ie("Sparat"),"","","success")}catch(e){throw Te(Ie("Kunde inte spara"),Re(e),"","error"),e}},columns:Ee,initialData:Ue?.data,codicentService:se,allowAttachments:J}),t(l,{open:ze,onOpenChange:(e,t)=>!t.open&&kt(),children:t(d,{children:e(p,{children:[t(m,{children:Ie("Confirm Delete")}),t(u,{children:Ie("Are you sure you want to delete this record? This action cannot be undone.")}),e(g,{children:[t(c,{appearance:"secondary",onClick:kt,children:Ie("Cancel")}),t(c,{appearance:"primary",onClick:async()=>{if(He)try{await se.deleteDataMessage(He.id),le((e=>e.filter(((e,t)=>t!==He.index)))),x.clearPattern(z),Te(Ie("Borttaget"),"","","success")}catch(e){Te(Ie("Kunde inte ta bort"),Re(e),"","error")}finally{Oe(!1),qe(null)}},children:Ie("Delete")})]})]})})}),t(l,{open:!!Xe,onOpenChange:(e,t)=>!t.open&&It(),children:t(d,{children:e(p,{children:[t(m,{children:Xe?Ie(Xe.label):""}),t(u,{children:e("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"8px 0"},children:[e("div",{style:{color:"#444"},children:[Je.size," ",Ie("rader kommer att uppdateras")]}),Mt&&se&&Mt.referenceTag&&e("div",{children:[t("div",{style:{fontWeight:600,marginBottom:"4px"},children:Mt.title?Ie(Mt.title):Mt.referenceTag}),t(T,{service:se,tag:Mt.referenceTag,displayKeys:Mt.referenceDisplayKeys,searchKeys:Mt.referenceSearchKeys??Mt.referenceDisplayKeys,dataFilters:Mt.referenceFilters,value:tt?.label||"",onSelect:e=>{rt(e),et(null)}})]}),Dt&&se&&Dt.referenceTag&&e("div",{children:[t("div",{style:{fontWeight:600,marginBottom:"4px"},children:Dt.title?Ie(Dt.title):Dt.referenceTag}),t(T,{service:se,tag:Dt.referenceTag,displayKeys:Dt.referenceDisplayKeys,searchKeys:Dt.referenceSearchKeys??Dt.referenceDisplayKeys,dataFilters:(()=>{const e={...Dt.referenceFilters??{}};return Dt.referenceCascadeFilterField&&tt&&(e[Dt.referenceCascadeFilterField]=C(tt.tag,tt.originalMessageId||tt.id)),e})(),disabled:!!Mt&&!tt,value:Ze?.label||"",onSelect:e=>et(e)})]})]})}),e(g,{children:[t(c,{appearance:"secondary",onClick:It,disabled:nt,children:Ie("Cancel")}),t(c,{appearance:"primary",onClick:_t,disabled:nt||!Ze||!!Mt&&!tt||0===Je.size,children:Ie(nt?"Sparar...":"Tilldela")})]})]})})})]})]})};export{B as ListPage,B as default};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UsageEventInput } from "../utils/telemetry";
|
|
1
2
|
/** Enable BFF cookie-session mode. Once enabled, API calls use credentials:"include"
|
|
2
3
|
* and omit the Authorization header — the server-side BffCookieAuthMiddleware
|
|
3
4
|
* re-attaches the token from the HttpOnly cookie. */
|
|
@@ -60,7 +61,10 @@ export interface CodicentServiceOptions {
|
|
|
60
61
|
ANONYMOUS_TOKEN?: string;
|
|
61
62
|
}
|
|
62
63
|
export declare class CodicentService {
|
|
63
|
-
|
|
64
|
+
private static _flushListenersRegistered;
|
|
65
|
+
private static _pagehideHandler;
|
|
66
|
+
private static _visibilityHandler;
|
|
67
|
+
createDataMessage: (tag: string, data: object, codicent?: string, fileIds?: string[]) => Promise<string>;
|
|
64
68
|
readDataMessages: (tag: string, search?: string, codicent?: string, start?: number, length?: number, afterTimestamp?: string, beforeTimestamp?: string, dataFilters?: {
|
|
65
69
|
[key: string]: string;
|
|
66
70
|
}) => Promise<DataMessage[]>;
|
|
@@ -81,7 +85,13 @@ export declare class CodicentService {
|
|
|
81
85
|
codicent: string;
|
|
82
86
|
private options;
|
|
83
87
|
onUnauthorized?: () => void;
|
|
88
|
+
private telemetryUser;
|
|
89
|
+
private readonly sessionId;
|
|
90
|
+
private usageQueue;
|
|
91
|
+
private usageFlushTimer;
|
|
92
|
+
private static newSessionId;
|
|
84
93
|
constructor(options: CodicentServiceOptions);
|
|
94
|
+
dispose(): void;
|
|
85
95
|
getAppTheme: () => Promise<MessageData | null>;
|
|
86
96
|
getAppButtons: () => Promise<MessageData[]>;
|
|
87
97
|
getAppTasks: () => Promise<{
|
|
@@ -99,7 +109,7 @@ export declare class CodicentService {
|
|
|
99
109
|
static getFileUrl: (fileId: string, extension?: string) => string;
|
|
100
110
|
generateApiToken: (expires?: Date, forUserNickname?: string) => Promise<string>;
|
|
101
111
|
sendMessage: (message: string, parentId?: string, codicent?: string) => Promise<string>;
|
|
102
|
-
chat: (message: string, messageId?: string, codicent?: string) => Promise<ChatMessageReply>;
|
|
112
|
+
chat: (message: string, messageId?: string, codicent?: string, latitude?: number, longitude?: number) => Promise<ChatMessageReply>;
|
|
103
113
|
/**
|
|
104
114
|
* Helper method to make fetch requests with error handling.
|
|
105
115
|
* @param url The URL to fetch.
|
|
@@ -165,6 +175,17 @@ export declare class CodicentService {
|
|
|
165
175
|
url: any;
|
|
166
176
|
}>;
|
|
167
177
|
logAction: (message: string, nickname: string) => Promise<string>;
|
|
178
|
+
/** Posts a message to the dedicated logging codicent using the log token. */
|
|
179
|
+
private postToLog;
|
|
180
|
+
/** Sets the nickname attached to subsequent usage events. */
|
|
181
|
+
setTelemetryUser: (nickname?: string) => void;
|
|
182
|
+
/** Records a structured, metadata-only usage event (queued, fire-and-forget). */
|
|
183
|
+
trackEvent: (event: UsageEventInput, nickname?: string) => void;
|
|
184
|
+
private recordUsage;
|
|
185
|
+
private flushUsage;
|
|
186
|
+
/** Times an async action and records a metadata-only usage event for it. */
|
|
187
|
+
private timedAction;
|
|
188
|
+
private tagSafe;
|
|
168
189
|
createApp: () => Promise<string | null>;
|
|
169
190
|
findUsername: () => Promise<string | null>;
|
|
170
191
|
static downloadFile: (file: FileInfo) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqB1D;;sDAEsD;AACtD,eAAO,MAAM,UAAU,YAAa,OAAO,SAE1C,CAAC;AAEF,eAAO,MAAM,SAAS,eAAgB,CAAC;AAYvC,eAAO,M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AgB,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB9F,iBAAiB,CACrB,QAAQ,GAAE,MAAiB,GAC1B,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAepE;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,SACd,MAAM,kBACI,MAAM,YACb,MAAM,KACd,OAAO,CAAC,mBAAmB,CAAC,CA2B7B;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"exceljs";var n;let o="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-",i=!1;const r=t=>{i=t},c=()=>i,h=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,d=t=>{t&&"string"==typeof t?(o=t.endsWith("/")?t:t+"/",h()&&window.Codicent.init({token:s,baseUrl:o,signalRHost:a})):console.warn("Invalid base URL provided, using default")},l=t=>{t&&"string"==typeof t&&(a=t,h()&&window.Codicent.init({token:s,baseUrl:o,signalRHost:a}))},u=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:o,signalRHost:a}),!0);let p=u();if(!p){const t=setInterval((()=>{p=u(),p&&clearInterval(t)}),100)}class w{constructor(n){this.createDataMessage=async(t,e,n)=>await window.Codicent.data.create({codicent:n||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,n,o,a,s,i,r)=>await window.Codicent.data.read({codicent:n||this.codicent,tag:t,search:e,start:o,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.getLeafDataMessage=async(t,e)=>{const n=e||this.codicent;try{const e=await this.authFetch(`${this.options.API_BASE_URL}app/GetLeafMessageByOriginalMessageId?project=${encodeURIComponent(n)}&originalMessageId=${encodeURIComponent(t)}`);if(!e.ok)return null;const o=await e.json();if(!o||!o.content)return null;const a=o.content.indexOf("{");if(-1===a)return null;const s=JSON.parse(o.content.slice(a));return{id:o.id,fileId:o.fileId??null,fileIds:o.fileIds??[],data:s,createdAt:o.createdAt,tags:o.tags??[],mentions:o.mentions??[]}}catch{return null}},this.updateDataMessage=async(t,e,n)=>await window.Codicent.data.update({id:t,data:e,codicent:n||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const n=await e.text();return JSON.parse(n)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>[...(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const n=new e(t.content).content.split("\n"),o=n[0],a=n.slice(1).join("\n");return{id:t.id,title:o,content:a}})),...(await window.Codicent.getDataMessages({tags:["skill"],codicent:this.codicent})).map((t=>t.data)).filter((t=>t.name&&t.title)).map((t=>({id:t.name,title:t.title,content:t.content||t.description||""})))],this.getAppPrompts=async t=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:t||this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const n=await this.authFetch(`${o}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET"});if(!n.ok)throw n.status,new Error(`${n.statusText}`);return await n.text()},this.sendMessage=(t,e,n)=>window.Codicent.postMessage({message:`@${n||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,n)=>window.Codicent.getChatReply4({message:t,codicent:n||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,n=100,a=void 0,s,i=0)=>{const r=await this.authFetch(`${o}app/AppGetMessages`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:n})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,n=10)=>{let o=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:n});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{o=o.concat(t)})),e)try{const t=await this.getPublicFlow(e);o=o.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return o=o.filter(((t,e,n)=>e===n.findIndex((e=>e.id===t.id)))),o.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),o},this.registerUser=async(t,e,n,s)=>{const i=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:n})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:o,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const n=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!n.ok)return 404===n.status||400===n.status?null:401===n.status?(this.handleUnauthorized(),null):"";const a=await n.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const n=await fetch(`${o}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!n.ok)return 404===n.status||400===n.status?null:401===n.status?(this.handleUnauthorized(),null):"";const a=await n.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,n,a)=>{const s=await fetch(`${o}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:n})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${o}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.bffCreateSession=async()=>{try{const t=await fetch(`${o}bff/session`,{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${this.getToken()}`}});return t.ok?(r(!0),!0):(console.warn("BFF session creation failed:",t.status),!1)}catch(t){return console.warn("BFF session creation error:",t),!1}},this.bffLogout=async()=>{try{await fetch(`${o}bff/logout`,{method:"POST",credentials:"include"})}catch(t){console.warn("BFF logout error:",t)}finally{r(!1)}},this.bffMe=async()=>{try{const t=await fetch(`${o}bff/me`,{credentials:"include"});return t.ok?await t.json():null}catch{return null}},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await this.authFetch(`${o}app/AppGetApps`,{method:"GET"});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,n)=>e===n.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const n=await this.authFetch(`${o}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET"});if(!n.ok)throw n.status,new Error(`${n.statusText||"Failed to add follower!"}`);return await n.json()},this.cloneProject=async(t,e)=>{const n=await this.authFetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET"});if(!n.ok)throw n.status,new Error(`${n.statusText}`);let a=await n.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),n=JSON.parse(e),a=n.sub||n.userId,i=await this.authFetch(`${o}app/GetNickname?userId=${a}`,{method:"GET"});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),n=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==n&&(console.log("updating instructions",n),await window.Codicent.postMessage({message:n,type:"text",parentId:e[0].id})):(console.log("new instructions",n),await window.Codicent.postMessage({message:n,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const n=await this.authFetch(`${o}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET"});if(!n.ok)throw 401===n.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${n.statusText}`);const a=await n.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:n,picture:a})=>{const s=await this.authFetch(`${o}app/AddOrUpdateUser`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify({nickname:t,email:e,name:n,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const n=await this.authFetch(`${o}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET"});return!!n.ok||(console.warn(`requestInvite() => ${n.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const n=await this.authFetch(`${o}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET"});return!!n.ok||(console.warn(`updateMembersAccess() => ${n.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const n=await this.authFetch(`${o}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET"});if(!n.ok)throw 401===n.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${n.statusText}`);return await n.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:o,signalRHost:a})},this.getToken=()=>s,this.authFetch=async(t,e={})=>{const n=new Headers(e.headers);i||n.set("Authorization",`Bearer ${this.getToken()}`);const o=await fetch(t,{...e,...i?{credentials:"include"}:{},headers:n});return 401===o.status&&this.handleUnauthorized(),o},this.checkPurchaseStatus=async()=>{const t=await this.authFetch(`${o}payments/GetPaymentStatus`,{method:"GET"});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await this.authFetch(`${o}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:{"Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:"0"}});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,n=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),n&&n>0&&(a.trialPeriodDays=n);const s=await this.authFetch(`${o}payments/CreateCheckoutSession`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const n=await t(this.options.STRIPE_PUBLIC_KEY);if(!n)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(e),{error:a}=await n.redirectToCheckout({sessionId:o});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await this.authFetch(`${o}api/GetMessageHistory?messageId=${t}`,{method:"GET"});if(!e.ok)throw new Error("Failed to get chat history");let n=await e.json();return n=n.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),n},this.getPublicFlow=async t=>{const e=await this.authFetch(`${o}app/GetPublicFlow?codicent=${t}`,{method:"GET"});if(!e.ok)throw new Error("Failed to get public flow");const n=await e.json();return n.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n},this.getMessageContent=async t=>{const e=await this.authFetch(`${o}app/GetMessageContent?id=${t}`,{method:"GET"});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const n={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${o}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(n)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],n=atob(t),o=JSON.parse(n).nickname;if(!await this.addFollower(e,o))throw new Error("Failed to add follower: "+o)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.authFetch(`${o}app/GetForms?codicent=${this.codicent}`,{method:"GET"});if(!t.ok)throw new Error(t.statusText);return await t.json()},this.getFormById=async t=>{const e=await this.authFetch(`${o}app/GetFormById?id=${t}`,{method:"GET"});return await e.json()},this.getTodoStatus=async t=>{const e=await this.authFetch(`${o}app/GetTodoStatus?messageId=${t}`,{method:"GET"});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const n=await this.authFetch(`${o}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET"});if(!n.ok)return console.warn(`updateTodoStatus() => ${n.statusText}`),!1;return await n.json()},this.codicent="",this.options=n,d(n.API_BASE_URL),n.PUBSUB_URL&&l(n.PUBSUB_URL)}async request(t,e,n={}){const o={};n.headers&&n.headers.forEach((([t,e])=>{o[t]=e}));const a=await fetch(t,{...n,method:e,headers:o});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const n=`${o}realtime/session?voice=${t}&provider=${e}`,a=await this.authFetch(n);if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${o}realtime/config?provider=${t}`,n=await this.authFetch(e,{method:"GET"});return n.ok?await n.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}n=w,w.getImageUrl=(t,e)=>`${o}app/GetImage?fileId=${t}&width=${e}`,w.getFileUrl=(t,e)=>`${o}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,w.downloadFile=async t=>{fetch(n.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const n=window.URL.createObjectURL(e),o=document.createElement("a");o.style.display="none",o.href=n,o.download=t.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},w.getMiniChatReplyOld=async(t,e="codicent-mini",n)=>{let a={project:e,message:t};n&&(a.messageId=n);const r=await fetch(`${o}app/GetAi2ChatReply`,{method:"POST",credentials:"include",headers:[["Content-Type","application/json; charset=utf-8"],...i?[]:[["Authorization",`Bearer ${s}`]]],body:JSON.stringify(a)});if(!r.ok)return void r.status;return(await r.json()).content.replace("@codicent-mini","").trim()},w.getMiniChatReply=async(t,e="codicent-mini",n,a=3e5,r=2e3,c)=>{const h={project:e,message:t};let d;n&&(h.messageId=n),c&&(h.previousResponseId=c);try{const t=await fetch(`${o}app/StartAi2ChatAsync`,{method:"POST",credentials:"include",headers:[["Content-Type","application/json; charset=utf-8"],...i?[]:[["Authorization",`Bearer ${s}`]]],body:JSON.stringify(h)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(d=(await t.json()).promptMessageId,!d)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const l=Date.now();for(;Date.now()-l<a;)try{const t=await fetch(`${o}app/GetAi2ChatReplyStatus?promptMessageId=${d}`,{method:"GET",credentials:"include",headers:i?[]:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,r)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const n=await t.json(),a=n.content??n.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:n.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},w.getTranslations=async(t,e,n="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${o}app/GetTranslations`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json; charset=utf-8",...i?{}:{Authorization:`Bearer ${s}`}},body:JSON.stringify({project:n,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{w as CodicentService,c as isBffMode,d as setBaseUrl,r as setBffMode,l as setSignalRHost};
|
|
1
|
+
import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"exceljs";var s;let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",o="-",i=!1;const r=t=>t instanceof Error?`${t.name}: ${t.message}`.slice(0,300):String(t).slice(0,300),c=t=>{try{return new URL(t,n).pathname.replace(/\/+$/,"")}catch{return t.split("?")[0]}},h=t=>{i=t},d=()=>i,l=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,u=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",l()&&window.Codicent.init({token:o,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},p=t=>{t&&"string"==typeof t&&(a=t,l()&&window.Codicent.init({token:o,baseUrl:n,signalRHost:a}))},w=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:o,baseUrl:n,signalRHost:a}),!0);let g=w();if(!g){const t=setInterval((()=>{g=w(),g&&clearInterval(t)}),100)}class m{static newSessionId(){try{if("undefined"!=typeof crypto&&"randomUUID"in crypto)return crypto.randomUUID()}catch{}return`s-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}constructor(d){this.createDataMessage=async(t,e,s,n)=>this.timedAction("data_create",t,(async()=>{if(n&&n.length>0){const a=s||this.codicent,o=n.map((t=>`#file:${t}`)).join(" "),i=`@${a} #data #${t} ${o} ${JSON.stringify(e)}`;return await window.Codicent.postMessage({message:i})}return await window.Codicent.data.create({codicent:s||this.codicent,tag:t,data:e})})),this.readDataMessages=async(t,e,s,n,a,o,i,r)=>{const c=await window.Codicent.data.read({codicent:s||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:o,beforeTimestamp:i,dataFilters:r});return e&&e.trim()&&0===c.length&&0===(n??0)&&this.recordUsage({type:"deadend",name:"empty_search",target:t,ok:!1}),c},this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.getLeafDataMessage=async(t,e)=>{const s=e||this.codicent;try{const e=await this.authFetch(`${this.options.API_BASE_URL}app/GetLeafMessageByOriginalMessageId?project=${encodeURIComponent(s)}&originalMessageId=${encodeURIComponent(t)}`);if(!e.ok)return null;const n=await e.json();if(!n||!n.content)return null;const a=n.content.indexOf("{");if(-1===a)return null;const o=JSON.parse(n.content.slice(a));return{id:n.id,fileId:n.fileId??null,fileIds:n.fileIds??[],data:o,createdAt:n.createdAt,tags:n.tags??[],mentions:n.mentions??[]}}catch{return null}},this.updateDataMessage=async(t,e,s)=>this.timedAction("data_update","",(async()=>window.Codicent.data.update({id:t,data:e,codicent:s||this.codicent}))),this.deleteDataMessage=async(t,e)=>this.timedAction("data_delete","",(async()=>window.Codicent.data.delete({id:t,codicent:e||this.codicent}))),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const s=await e.text();return JSON.parse(s)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.telemetryUser="anonymous",this.sessionId=s.newSessionId(),this.usageQueue=[],this.usageFlushTimer=null,this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>[...(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const s=new e(t.content).content.split("\n"),n=s[0],a=s.slice(1).join("\n");return{id:t.id,title:n,content:a}})),...(await window.Codicent.getDataMessages({tags:["skill"],codicent:this.codicent})).map((t=>t.data)).filter((t=>t.name&&t.title)).map((t=>({id:t.name,title:t.title,content:t.content||t.description||""})))],this.getAppPrompts=async t=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:t||this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const s=await this.authFetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET"});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await s.text()},this.sendMessage=(t,e,s)=>window.Codicent.postMessage({message:`@${s||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,s,n,a)=>window.Codicent.getChatReply4({message:t,codicent:s||this.codicent,messageId:e,latitude:n,longitude:a}),this.getMessagesFast=async(t,e,s=100,a=void 0,o,i=0)=>{const r=await this.authFetch(`${n}app/AppGetMessages`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:o||this.codicent,search:e,start:i,length:s})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,s=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:s});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,s)=>e===s.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,s,o)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${o}`]],body:JSON.stringify({nickname:t,email:e,userId:s})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const s=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!s.ok)return 404===s.status||400===s.status?null:401===s.status?(this.handleUnauthorized(),null):"";const a=await s.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const s=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!s.ok)return 404===s.status||400===s.status?null:401===s.status?(this.handleUnauthorized(),null):"";const a=await s.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,s,a)=>{const o=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:s})});if(!o.ok)return"";return await o.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.bffCreateSession=async()=>{try{const t=await fetch(`${n}bff/session`,{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${this.getToken()}`}});return t.ok?(h(!0),!0):(console.warn("BFF session creation failed:",t.status),!1)}catch(t){return console.warn("BFF session creation error:",t),!1}},this.bffLogout=async()=>{try{await fetch(`${n}bff/logout`,{method:"POST",credentials:"include"})}catch(t){console.warn("BFF logout error:",t)}finally{h(!1)}},this.bffMe=async()=>{try{const t=await fetch(`${n}bff/me`,{credentials:"include"});return t.ok?await t.json():null}catch{return null}},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await this.authFetch(`${n}app/AppGetApps`,{method:"GET"});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,s)=>e===s.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const s=await this.authFetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET"});if(!s.ok)throw s.status,new Error(`${s.statusText||"Failed to add follower!"}`);return await s.json()},this.cloneProject=async(t,e)=>{const s=await this.authFetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET"});if(!s.ok)throw s.status,new Error(`${s.statusText}`);let a=await s.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=o.split(".")[1],e=atob(t),s=JSON.parse(e),a=s.sub||s.userId,i=await this.authFetch(`${n}app/GetNickname?userId=${a}`,{method:"GET"});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),s=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==s&&(console.log("updating instructions",s),await window.Codicent.postMessage({message:s,type:"text",parentId:e[0].id})):(console.log("new instructions",s),await window.Codicent.postMessage({message:s,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const s=await this.authFetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET"});if(!s.ok)throw 401===s.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${s.statusText}`);const a=await s.json(),{email:o,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:o,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:s,picture:a})=>{const o=await this.authFetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify({nickname:t,email:e,name:s,picture:a,description:""})});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const s=await this.authFetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET"});return!!s.ok||(console.warn(`requestInvite() => ${s.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const s=await this.authFetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET"});return!!s.ok||(console.warn(`updateMembersAccess() => ${s.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const s=await this.authFetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET"});if(!s.ok)throw 401===s.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${s.statusText}`);return await s.json()},this.setToken=t=>{o=t,o&&window.Codicent.init({token:o,baseUrl:n,signalRHost:a})},this.getToken=()=>o,this.authFetch=async(t,e={})=>{const s=new Headers(e.headers);let n;i||s.set("Authorization",`Bearer ${this.getToken()}`);try{n=await fetch(t,{...e,...i?{credentials:"include"}:{},headers:s})}catch(e){throw this.recordUsage({type:"api_error",name:c(t),ok:!1,error:r(e)}),e}return 401===n.status&&this.handleUnauthorized(),n.ok||401===n.status||404===n.status||this.recordUsage({type:"api_error",name:c(t),ok:!1,status:n.status}),n},this.checkPurchaseStatus=async()=>{const t=await this.authFetch(`${n}payments/GetPaymentStatus`,{method:"GET"});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await this.authFetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:{"Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:"0"}});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,s=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),s&&s>0&&(a.trialPeriodDays=s);const o=await this.authFetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(a)});if(!o.ok)throw new Error("Failed to create checkout session");const{id:i}=await o.json();return i},this.redirectToCheckout=async e=>{const s=await t(this.options.STRIPE_PUBLIC_KEY);if(!s)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await s.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await this.authFetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET"});if(!e.ok)throw new Error("Failed to get chat history");let s=await e.json();return s=s.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),s},this.getPublicFlow=async t=>{const e=await this.authFetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET"});if(!e.ok)throw new Error("Failed to get public flow");const s=await e.json();return s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),s},this.getMessageContent=async t=>{const e=await this.authFetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET"});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>this.options.APP_LOG_CODICENT?this.postToLog(`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`):"",this.postToLog=async(t,e=!1)=>{const s=await fetch(`${n}app/AddChatMessage`,{method:"POST",keepalive:e,headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify({content:t,type:"text"})});if(!s.ok)throw new Error(`${s.statusText||"Failed to post log message!"}`);return(await s.json()).id},this.setTelemetryUser=t=>{t&&(this.telemetryUser=t)},this.trackEvent=(t,e)=>{e&&(this.telemetryUser=e),this.recordUsage(t)},this.recordUsage=t=>{this.options.APP_LOG_CODICENT&&(this.usageQueue.push({...t,_ts:(new Date).toISOString()}),this.usageQueue.length>=20?this.flushUsage():this.usageFlushTimer||(this.usageFlushTimer=setTimeout((()=>this.flushUsage()),4e3)))},this.flushUsage=()=>{if(this.usageFlushTimer&&(clearTimeout(this.usageFlushTimer),this.usageFlushTimer=null),!this.options.APP_LOG_CODICENT||0===this.usageQueue.length)return;const t=this.usageQueue;this.usageQueue=[];const e="undefined"!=typeof navigator?String(navigator.platform||"").slice(0,40):"";for(const s of t){const t={ts:s._ts,type:s.type,name:s.name,...s.page?{page:s.page}:{},...s.target?{target:s.target}:{},...void 0===s.ok?{}:{ok:s.ok},...void 0===s.durationMs?{}:{durationMs:Math.round(s.durationMs)},...void 0===s.status?{}:{status:s.status},...s.error?{error:String(s.error).slice(0,300)}:{},session:this.sessionId,app:this.options.APP_NAME||"",user:this.telemetryUser,...e?{platform:e}:{}},n=`@${this.options.APP_LOG_CODICENT} #data #usage #${s.type} ${this.tagSafe(this.telemetryUser)}\n${JSON.stringify(t)}`;this.postToLog(n,!0).catch((()=>{}))}},this.timedAction=async(t,e,s)=>{const n=Date.now();try{const a=await s();return this.recordUsage({type:"action",name:t,target:e,ok:!0,durationMs:Date.now()-n}),a}catch(s){throw this.recordUsage({type:"action",name:t,target:e,ok:!1,durationMs:Date.now()-n,error:r(s)}),s}},this.tagSafe=t=>`#${(t||"anon").replace(/[^a-zA-Z0-9_]/g,"_").toLowerCase()}`,this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],s=atob(t),n=JSON.parse(s).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.authFetch(`${n}app/GetForms?codicent=${this.codicent}`,{method:"GET"});if(!t.ok)throw new Error(t.statusText);return await t.json()},this.getFormById=async t=>{const e=await this.authFetch(`${n}app/GetFormById?id=${t}`,{method:"GET"});return await e.json()},this.getTodoStatus=async t=>{const e=await this.authFetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET"});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const s=await this.authFetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET"});if(!s.ok)return console.warn(`updateTodoStatus() => ${s.statusText}`),!1;return await s.json()},this.codicent="",this.options=d,u(d.API_BASE_URL),d.PUBSUB_URL&&p(d.PUBSUB_URL),"undefined"==typeof window||s._flushListenersRegistered||(s._flushListenersRegistered=!0,s._pagehideHandler=()=>this.flushUsage(),s._visibilityHandler=()=>{"undefined"!=typeof document&&"hidden"===document.visibilityState&&this.flushUsage()},window.addEventListener("pagehide",s._pagehideHandler),window.addEventListener("visibilitychange",s._visibilityHandler))}dispose(){"undefined"!=typeof window&&(s._pagehideHandler&&(window.removeEventListener("pagehide",s._pagehideHandler),s._pagehideHandler=null),s._visibilityHandler&&(window.removeEventListener("visibilitychange",s._visibilityHandler),s._visibilityHandler=null),s._flushListenersRegistered=!1)}async request(t,e,s={}){const n={};s.headers&&s.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...s,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const s=`${n}realtime/session?voice=${t}&provider=${e}`,a=await this.authFetch(s);if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const o=await a.json(),i=o.client_secret?.value??o.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,s=await this.authFetch(e,{method:"GET"});return s.ok?await s.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}s=m,m._flushListenersRegistered=!1,m._pagehideHandler=null,m._visibilityHandler=null,m.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,m.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,m.downloadFile=async t=>{fetch(s.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const s=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=s,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(s)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},m.getMiniChatReplyOld=async(t,e="codicent-mini",s)=>{let a={project:e,message:t};s&&(a.messageId=s);const r=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",credentials:"include",headers:[["Content-Type","application/json; charset=utf-8"],...i?[]:[["Authorization",`Bearer ${o}`]]],body:JSON.stringify(a)});if(!r.ok)return void r.status;return(await r.json()).content.replace("@codicent-mini","").trim()},m.getMiniChatReply=async(t,e="codicent-mini",s,a=3e5,r=2e3,c)=>{const h={project:e,message:t};let d;s&&(h.messageId=s),c&&(h.previousResponseId=c);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",credentials:"include",headers:[["Content-Type","application/json; charset=utf-8"],...i?[]:[["Authorization",`Bearer ${o}`]]],body:JSON.stringify(h)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(d=(await t.json()).promptMessageId,!d)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const l=Date.now();for(;Date.now()-l<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${d}`,{method:"GET",credentials:"include",headers:i?[]:[["Authorization",`Bearer ${o}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,r)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const s=await t.json(),a=s.content??s.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:s.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},m.getTranslations=async(t,e,s="codicent-mini")=>{if(!o||"-"===o)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json; charset=utf-8",...i?{}:{Authorization:`Bearer ${o}`}},body:JSON.stringify({project:s,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{m as CodicentService,d as isBffMode,u as setBaseUrl,h as setBffMode,p as setSignalRHost};
|
|
@@ -28,6 +28,30 @@ export interface ButtonConfig {
|
|
|
28
28
|
export * from "./audit";
|
|
29
29
|
import type { ColumnAction, ColumnDefinition } from "../components/ListView";
|
|
30
30
|
export type { ColumnAction, ColumnDefinition };
|
|
31
|
+
import type { CodicentService } from "../services/codicent";
|
|
32
|
+
/**
|
|
33
|
+
* A bulk action available when rows are selected in a list.
|
|
34
|
+
* Exactly one of `referenceColumnKey`, `setFieldKey`, or `handler` should be set.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export interface BulkAction {
|
|
38
|
+
/** Display label for the bulk action button. */
|
|
39
|
+
label: string;
|
|
40
|
+
/**
|
|
41
|
+
* Column key of a `type: "reference"` column to bulk-set via a picker dialog.
|
|
42
|
+
* If that column declares `referenceCascadeFromKey`, the cascade-from column is also bulk-set.
|
|
43
|
+
*/
|
|
44
|
+
referenceColumnKey?: string;
|
|
45
|
+
/**
|
|
46
|
+
* When set, immediately sets this field to `setFieldValue` on all selected rows without a dialog.
|
|
47
|
+
*/
|
|
48
|
+
setFieldKey?: string;
|
|
49
|
+
setFieldValue?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Custom async handler. Called with selected rows + service; applied immediately, no dialog.
|
|
52
|
+
*/
|
|
53
|
+
handler?: (selectedRows: DataMessage[], service: CodicentService) => Promise<void>;
|
|
54
|
+
}
|
|
31
55
|
/**
|
|
32
56
|
* Configuration for a single list view, supporting column definitions and optional deduplication.
|
|
33
57
|
* @public
|
|
@@ -42,6 +66,10 @@ export interface ListConfig {
|
|
|
42
66
|
* (e.g. same customer number or offer number) and only the latest should be displayed.
|
|
43
67
|
*/
|
|
44
68
|
deduplicateBy?: string | string[];
|
|
69
|
+
/**
|
|
70
|
+
* Bulk actions available when rows are selected. Setting this enables row-selection checkboxes.
|
|
71
|
+
*/
|
|
72
|
+
bulkActions?: BulkAction[];
|
|
45
73
|
}
|
|
46
74
|
/**
|
|
47
75
|
* List definitions keyed by tag name (e.g., "customer2", "offertjson").
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAGD,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;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AM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,YAAY,EACV,QAAQ,EACR,UAAU,EACV,OAAO,EACP,IAAI,EACJ,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as MessageContent } from "./MessageContent";
|
|
2
2
|
export { default as generateBrandVariants } from "./theme";
|
|
3
3
|
export { default as log } from "./logging";
|
|
4
|
+
export { track, USAGE_EVENT_NAME } from "./telemetry";
|
|
5
|
+
export type { UsageEventInput, UsageEventType } from "./telemetry";
|
|
4
6
|
export { default as withWakeLock } from "./withWakeLock";
|
|
5
7
|
export { default as AppStateMachine } from "./appState";
|
|
6
8
|
export { createAppStateMachine } from "./appState";
|
|
@@ -12,6 +14,7 @@ export { exportToExcel } from "./excelExport";
|
|
|
12
14
|
export type { ExcelColumnDefinition } from "./excelExport";
|
|
13
15
|
export type { AppStateDefinition } from "./appState";
|
|
14
16
|
export { getTimeString } from "./helpers";
|
|
17
|
+
export { formatReference, referenceEntityName } from "./reference";
|
|
15
18
|
export { CacheManager, stateMachineCacheManager } from "./cacheManager";
|
|
16
19
|
export type { CacheEntry, CachedUserSession } from "./cacheManager";
|
|
17
20
|
export { resolveAuditConfig, calculateAuditTimeRemaining, getAuditUrgencyColor, calcValidUntil, formatValidityPeriod, parseValidityPeriod, isAnswerCompliant, getAuditComplianceRate, getAuditRoleCapabilities, getEffectiveAnswerOptions, DEFAULT_AUDIT_VALIDITY_PERIOD_MONTHS, AUDIT_CHECKBOX_OPTIONS, } from "./auditUtils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cA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E,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,oCAAoC,EACpC,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives the short entity name from a data-message tag, e.g. "sunhero-installer" -> "installer".
|
|
3
|
+
* Tags without a hyphen are returned unchanged (e.g. "customer2").
|
|
4
|
+
*/
|
|
5
|
+
export declare const referenceEntityName: (tag: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Builds the stable reference string stored in a reference column's field, e.g.
|
|
8
|
+
* formatReference("sunhero-installer", "abc-123") -> "#installer_abc-123".
|
|
9
|
+
*
|
|
10
|
+
* The same function must be used on both sides of a relationship (the linking row and the cascade
|
|
11
|
+
* target) so the values match for server-side `dataFilters` filtering. The value is a denormalized
|
|
12
|
+
* field value, not a parsed message tag.
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatReference: (tag: string, originalMessageId: string) => string;
|
|
15
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/utils/reference.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,MACiB,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,qBAAqB,MAAM,KAAG,MACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=s=>s.includes("-")?s.substring(s.lastIndexOf("-")+1):s,n=(n,t)=>`#${s(n)}_${t}`;export{n as formatReference,s as referenceEntityName};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type UsageEventType = "session" | "pageview" | "action" | "deadend" | "api_error" | "error";
|
|
2
|
+
export interface UsageEventInput {
|
|
3
|
+
type: UsageEventType;
|
|
4
|
+
/** Stable, low-cardinality name (route, action id, error name). */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Current page/route, if relevant. */
|
|
7
|
+
page?: string;
|
|
8
|
+
/** Data tag / entity type acted on (metadata only — never an id or value). */
|
|
9
|
+
target?: string;
|
|
10
|
+
/** Whether the action/request succeeded. */
|
|
11
|
+
ok?: boolean;
|
|
12
|
+
/** Duration in ms for timed actions. */
|
|
13
|
+
durationMs?: number;
|
|
14
|
+
/** HTTP status for api_error events. */
|
|
15
|
+
status?: number;
|
|
16
|
+
/** Error class/message, truncated (metadata only — no payloads). */
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const USAGE_EVENT_NAME = "usage-event";
|
|
20
|
+
/**
|
|
21
|
+
* Dispatch a usage event from anywhere in the UI. App.tsx listens for
|
|
22
|
+
* "usage-event" and forwards it to CodicentService.trackEvent. No-op outside
|
|
23
|
+
* a browser, and never throws — telemetry must not affect app behaviour.
|
|
24
|
+
*/
|
|
25
|
+
export declare const track: (event: UsageEventInput) => void;
|
|
26
|
+
export default track;
|
|
27
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,GACT,WAAW,GACX,OAAO,CAAC;AAEZ,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,KAAK,UAAW,eAAe,KAAG,IAO9C,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="usage-event",t=t=>{if("undefined"!=typeof window)try{window.dispatchEvent(new CustomEvent(e,{detail:t}))}catch{}};export{e as USAGE_EVENT_NAME,t as default,t as track};
|