codicent-app-sdk 0.3.119 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -26
- package/dist/cjs/_virtual/jsQR.js +1 -0
- package/dist/cjs/bootstrap.d.ts +112 -0
- package/dist/cjs/bootstrap.d.ts.map +1 -0
- package/dist/cjs/bootstrap.js +1 -0
- package/dist/cjs/components/AiInput.js +1 -1
- package/dist/cjs/components/AudioIcon.js +1 -1
- package/dist/cjs/components/BulkUploadDialog.d.ts +16 -0
- package/dist/cjs/components/BulkUploadDialog.d.ts.map +1 -0
- package/dist/cjs/components/BulkUploadDialog.js +1 -0
- package/dist/cjs/components/ChatInput.js +1 -1
- package/dist/cjs/components/ChatMessage.js +1 -1
- package/dist/cjs/components/CombinedPlaceholderDialog.js +1 -1
- package/dist/cjs/components/ErrorBoundary.d.ts +17 -0
- package/dist/cjs/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/cjs/components/ErrorBoundary.js +1 -0
- package/dist/cjs/components/Footer.js +1 -1
- package/dist/cjs/components/GenericJsonRenderer.d.ts +20 -0
- package/dist/cjs/components/GenericJsonRenderer.d.ts.map +1 -0
- package/dist/cjs/components/GenericJsonRenderer.js +1 -0
- package/dist/cjs/components/Header.js +1 -1
- package/dist/cjs/components/HtmlView.js +1 -1
- package/dist/cjs/components/LanguageSelector.d.ts +11 -0
- package/dist/cjs/components/LanguageSelector.d.ts.map +1 -0
- package/dist/cjs/components/LanguageSelector.js +1 -0
- package/dist/cjs/components/ListView.d.ts +39 -0
- package/dist/cjs/components/ListView.d.ts.map +1 -0
- package/dist/cjs/components/ListView.js +1 -0
- package/dist/cjs/components/MessageInput.js +1 -1
- package/dist/cjs/components/MessageItem.js +1 -1
- package/dist/cjs/components/OfflineMessage.d.ts +6 -0
- package/dist/cjs/components/OfflineMessage.d.ts.map +1 -0
- package/dist/cjs/components/OfflineMessage.js +1 -0
- package/dist/cjs/components/Profile.js +1 -1
- package/dist/cjs/components/Prompt.js +1 -1
- package/dist/cjs/components/QrScanner.d.ts +12 -0
- package/dist/cjs/components/QrScanner.d.ts.map +1 -0
- package/dist/cjs/components/QrScanner.js +1 -0
- package/dist/cjs/components/RecordModal.d.ts +13 -0
- package/dist/cjs/components/RecordModal.d.ts.map +1 -0
- package/dist/cjs/components/RecordModal.js +1 -0
- package/dist/cjs/components/SnapFooter.js +1 -1
- package/dist/cjs/components/TextHeader.js +1 -1
- package/dist/cjs/components/TypingIndicator.js +1 -1
- package/dist/cjs/components/UploadFile.js +1 -1
- package/dist/cjs/components/UrlProcessor.js +1 -1
- package/dist/cjs/components/VoiceIcon.js +1 -1
- package/dist/cjs/components/index.d.ts +9 -0
- package/dist/cjs/components/index.d.ts.map +1 -1
- package/dist/cjs/config/index.d.ts +2 -0
- package/dist/cjs/config/index.d.ts.map +1 -1
- package/dist/cjs/config/index.js +1 -1
- package/dist/cjs/hooks/index.d.ts +3 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/useAuthState.d.ts.map +1 -1
- package/dist/cjs/hooks/useAuthState.js +1 -1
- package/dist/cjs/hooks/useCodicentState.js +1 -1
- package/dist/cjs/hooks/useDebugLogs.d.ts +6 -0
- package/dist/cjs/hooks/useDebugLogs.d.ts.map +1 -0
- package/dist/cjs/hooks/useDebugLogs.js +1 -0
- package/dist/cjs/hooks/useObserveDataSchemas.d.ts +42 -0
- package/dist/cjs/hooks/useObserveDataSchemas.d.ts.map +1 -0
- package/dist/cjs/hooks/useObserveDataSchemas.js +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/node_modules/@auth0/auth0-react/dist/auth0-react.esm.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-button/lib/contexts/ButtonContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/Checkbox.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/renderCheckbox.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/useCheckbox.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/useCheckboxStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-combobox/lib/components/Combobox/useCombobox.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/Dialog/Dialog.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/Dialog/renderDialog.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/Dialog/useDialog.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/Dialog/useDialogContextValues.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogActions/DialogActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogActions/renderDialogActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogActions/useDialogActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogActions/useDialogActionsStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogBackdropMotion.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogBody/DialogBody.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogBody/renderDialogBody.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogBody/useDialogBody.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogBody/useDialogBodyStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogContent/DialogContent.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogContent/renderDialogContent.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogContent/useDialogContent.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogContent/useDialogContentStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/DialogSurface.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/renderDialogSurface.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurface.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurfaceContextValues.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurfaceStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogSurfaceMotion.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/DialogTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/renderDialogTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/useDialogTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/useDialogTitleStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/DialogTrigger.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/renderDialogTrigger.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/useDialogTrigger.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/components/MotionRefForwarder.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/contexts/dialogContext.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/contexts/dialogSurfaceContext.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/utils/useDisableBodyScroll.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/utils/useDisableBodyScroll.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-dialog/lib/utils/useFocusFirstElement.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/contexts/IconDirectionContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-0.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-1.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-14.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-3.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-5.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-6.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-menu/lib/components/Menu/useMenu.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-menu/lib/components/MenuItem/useMenuItem.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/MessageBarActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/renderMessageBarActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActions.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActionsContextValues.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActionsStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/MessageBarTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/renderMessageBarTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/useMessageBarTitle.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/useMessageBarTitleStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-motion/lib/slots/presenceMotionSlot.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-motion-components-preview/lib/components/Fade/Fade.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-positioning/lib/utils/mergeArrowOffset.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/FluentProvider.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/createCSSRuleFromTheme.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/renderFluentProvider.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProvider.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderContextValues.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderThemeStyleTag.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-search/lib/components/SearchBox/useSearchBox.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/CustomStyleHooksContext/CustomStyleHooksContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/OverridesContext/OverridesContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/ProviderContext/ProviderContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/ThemeClassNameContext/ThemeClassNameContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/ThemeContext/ThemeContext.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-shared-contexts/lib/TooltipVisibilityContext/TooltipContext.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tabster/lib/hooks/useIsNavigatingWithKeyboard.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-timepicker-compat/lib/components/TimePicker/useTimePicker.js +1 -1
- package/dist/cjs/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/Tooltip.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/private/constants.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/renderTooltip.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/useTooltip.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/useTooltipStyles.styles.js +1 -0
- package/dist/cjs/node_modules/@fluentui/react-utilities/lib/ssr/SSRContext.js +1 -1
- package/dist/cjs/node_modules/@fluentui/tokens/lib/alias/lightColor.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/alias/lightColorPalette.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/borderRadius.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/colorPalette.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/colors.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/curves.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/durations.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/fonts.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/spacings.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/global/strokeWidths.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/sharedColorNames.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/statusColorMapping.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/utils/createLightTheme.js +1 -0
- package/dist/cjs/node_modules/@fluentui/tokens/lib/utils/shadows.js +1 -0
- package/dist/cjs/node_modules/@griffel/react/TextDirectionContext.esm.js +1 -1
- package/dist/cjs/node_modules/jsqr/dist/jsQR.js +1 -0
- package/dist/cjs/pages/AppFrame.js +1 -1
- package/dist/cjs/pages/Chat.js +1 -1
- package/dist/cjs/pages/Compose.js +1 -1
- package/dist/cjs/pages/CrmPage.js +1 -1
- package/dist/cjs/pages/CrmPagePersistent.js +1 -1
- package/dist/cjs/pages/Debug.d.ts +4 -0
- package/dist/cjs/pages/Debug.d.ts.map +1 -0
- package/dist/cjs/pages/Debug.js +1 -0
- package/dist/cjs/pages/FormAccept.js +1 -1
- package/dist/cjs/pages/FormInvite.js +1 -1
- package/dist/cjs/pages/FormPage.d.ts +11 -0
- package/dist/cjs/pages/FormPage.d.ts.map +1 -0
- package/dist/cjs/pages/FormPage.js +1 -0
- package/dist/cjs/pages/Help.d.ts +7 -0
- package/dist/cjs/pages/Help.d.ts.map +1 -0
- package/dist/cjs/pages/Help.js +1 -0
- package/dist/cjs/pages/HtmlViewer.js +1 -1
- package/dist/cjs/pages/Login.js +1 -1
- package/dist/cjs/pages/Purchase.js +1 -1
- package/dist/cjs/pages/QrScan.d.ts +12 -0
- package/dist/cjs/pages/QrScan.d.ts.map +1 -0
- package/dist/cjs/pages/QrScan.js +1 -0
- package/dist/cjs/pages/Sales.js +1 -1
- package/dist/cjs/pages/SchemaEditor.d.ts +2 -0
- package/dist/cjs/pages/SchemaEditor.d.ts.map +1 -0
- package/dist/cjs/pages/SchemaEditor.js +1 -0
- package/dist/cjs/pages/Search.js +1 -1
- package/dist/cjs/pages/Snap.js +1 -1
- package/dist/cjs/pages/index.d.ts +5 -0
- package/dist/cjs/pages/index.d.ts.map +1 -1
- package/dist/cjs/services/codicent.d.ts +7 -0
- 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 +188 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/utils/appState.d.ts.map +1 -1
- package/dist/cjs/utils/appState.js +1 -1
- package/dist/esm/_virtual/jsQR.js +1 -0
- package/dist/esm/bootstrap.d.ts +112 -0
- package/dist/esm/bootstrap.d.ts.map +1 -0
- package/dist/esm/bootstrap.js +1 -0
- package/dist/esm/components/AiInput.js +1 -1
- package/dist/esm/components/AudioIcon.js +1 -1
- package/dist/esm/components/BulkUploadDialog.d.ts +16 -0
- package/dist/esm/components/BulkUploadDialog.d.ts.map +1 -0
- package/dist/esm/components/BulkUploadDialog.js +1 -0
- package/dist/esm/components/ChatInput.js +1 -1
- package/dist/esm/components/ChatMessage.js +1 -1
- package/dist/esm/components/CombinedPlaceholderDialog.js +1 -1
- package/dist/esm/components/ErrorBoundary.d.ts +17 -0
- package/dist/esm/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/esm/components/ErrorBoundary.js +1 -0
- package/dist/esm/components/Footer.js +1 -1
- package/dist/esm/components/GenericJsonRenderer.d.ts +20 -0
- package/dist/esm/components/GenericJsonRenderer.d.ts.map +1 -0
- package/dist/esm/components/GenericJsonRenderer.js +1 -0
- package/dist/esm/components/Header.js +1 -1
- package/dist/esm/components/HtmlView.js +1 -1
- package/dist/esm/components/LanguageSelector.d.ts +11 -0
- package/dist/esm/components/LanguageSelector.d.ts.map +1 -0
- package/dist/esm/components/LanguageSelector.js +1 -0
- package/dist/esm/components/ListView.d.ts +39 -0
- package/dist/esm/components/ListView.d.ts.map +1 -0
- package/dist/esm/components/ListView.js +1 -0
- package/dist/esm/components/MessageInput.js +1 -1
- package/dist/esm/components/MessageItem.js +1 -1
- package/dist/esm/components/OfflineMessage.d.ts +6 -0
- package/dist/esm/components/OfflineMessage.d.ts.map +1 -0
- package/dist/esm/components/OfflineMessage.js +1 -0
- package/dist/esm/components/Profile.js +1 -1
- package/dist/esm/components/Prompt.js +1 -1
- package/dist/esm/components/QrScanner.d.ts +12 -0
- package/dist/esm/components/QrScanner.d.ts.map +1 -0
- package/dist/esm/components/QrScanner.js +1 -0
- package/dist/esm/components/RecordModal.d.ts +13 -0
- package/dist/esm/components/RecordModal.d.ts.map +1 -0
- package/dist/esm/components/RecordModal.js +1 -0
- package/dist/esm/components/SnapFooter.js +1 -1
- package/dist/esm/components/TextHeader.js +1 -1
- package/dist/esm/components/TypingIndicator.js +1 -1
- package/dist/esm/components/UploadFile.js +1 -1
- package/dist/esm/components/UrlProcessor.js +1 -1
- package/dist/esm/components/VoiceIcon.js +1 -1
- package/dist/esm/components/index.d.ts +9 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/config/index.d.ts +2 -0
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/hooks/index.d.ts +3 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/useAuthState.d.ts.map +1 -1
- package/dist/esm/hooks/useAuthState.js +1 -1
- package/dist/esm/hooks/useCodicentState.js +1 -1
- package/dist/esm/hooks/useDebugLogs.d.ts +6 -0
- package/dist/esm/hooks/useDebugLogs.d.ts.map +1 -0
- package/dist/esm/hooks/useDebugLogs.js +1 -0
- package/dist/esm/hooks/useObserveDataSchemas.d.ts +42 -0
- package/dist/esm/hooks/useObserveDataSchemas.d.ts.map +1 -0
- package/dist/esm/hooks/useObserveDataSchemas.js +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/node_modules/@auth0/auth0-react/dist/auth0-react.esm.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-button/lib/contexts/ButtonContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/Checkbox.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/renderCheckbox.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/useCheckbox.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-checkbox/lib/components/Checkbox/useCheckboxStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-combobox/lib/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/Dialog/Dialog.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/Dialog/renderDialog.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/Dialog/useDialog.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/Dialog/useDialogContextValues.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogActions/DialogActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogActions/renderDialogActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogActions/useDialogActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogActions/useDialogActionsStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogBackdropMotion.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogBody/DialogBody.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogBody/renderDialogBody.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogBody/useDialogBody.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogBody/useDialogBodyStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogContent/DialogContent.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogContent/renderDialogContent.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogContent/useDialogContent.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogContent/useDialogContentStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/DialogSurface.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/renderDialogSurface.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurface.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurfaceContextValues.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurface/useDialogSurfaceStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogSurfaceMotion.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/DialogTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/renderDialogTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/useDialogTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTitle/useDialogTitleStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/DialogTrigger.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/renderDialogTrigger.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/DialogTrigger/useDialogTrigger.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/components/MotionRefForwarder.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/contexts/dialogContext.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/contexts/dialogSurfaceContext.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/utils/useDisableBodyScroll.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/utils/useDisableBodyScroll.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-dialog/lib/utils/useFocusFirstElement.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-icons/lib/contexts/IconDirectionContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-0.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-1.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-14.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-3.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-5.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-6.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-menu/lib/components/Menu/useMenu.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-menu/lib/components/MenuItem/useMenuItem.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/MessageBarActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/renderMessageBarActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActions.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActionsContextValues.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarActions/useMessageBarActionsStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/MessageBarTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/renderMessageBarTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/useMessageBarTitle.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-message-bar/lib/components/MessageBarTitle/useMessageBarTitleStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-motion/lib/slots/presenceMotionSlot.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-motion-components-preview/lib/components/Fade/Fade.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-positioning/lib/utils/mergeArrowOffset.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/FluentProvider.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/createCSSRuleFromTheme.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/renderFluentProvider.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProvider.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderContextValues.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-provider/lib/components/FluentProvider/useFluentProviderThemeStyleTag.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-search/lib/components/SearchBox/useSearchBox.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/CustomStyleHooksContext/CustomStyleHooksContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/OverridesContext/OverridesContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/ProviderContext/ProviderContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/ThemeClassNameContext/ThemeClassNameContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/ThemeContext/ThemeContext.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-shared-contexts/lib/TooltipVisibilityContext/TooltipContext.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tabster/lib/hooks/useIsNavigatingWithKeyboard.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-timepicker-compat/lib/components/TimePicker/useTimePicker.js +1 -1
- package/dist/esm/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/Tooltip.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/private/constants.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/renderTooltip.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/useTooltip.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-tooltip/lib/components/Tooltip/useTooltipStyles.styles.js +1 -0
- package/dist/esm/node_modules/@fluentui/react-utilities/lib/ssr/SSRContext.js +1 -1
- package/dist/esm/node_modules/@fluentui/tokens/lib/alias/lightColor.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/alias/lightColorPalette.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/borderRadius.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/colorPalette.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/colors.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/curves.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/durations.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/fonts.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/spacings.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/global/strokeWidths.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/sharedColorNames.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/statusColorMapping.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/utils/createLightTheme.js +1 -0
- package/dist/esm/node_modules/@fluentui/tokens/lib/utils/shadows.js +1 -0
- package/dist/esm/node_modules/@griffel/react/TextDirectionContext.esm.js +1 -1
- package/dist/esm/node_modules/jsqr/dist/jsQR.js +1 -0
- package/dist/esm/pages/AppFrame.js +1 -1
- package/dist/esm/pages/Chat.js +1 -1
- package/dist/esm/pages/Compose.js +1 -1
- package/dist/esm/pages/CrmPage.js +1 -1
- package/dist/esm/pages/CrmPagePersistent.js +1 -1
- package/dist/esm/pages/Debug.d.ts +4 -0
- package/dist/esm/pages/Debug.d.ts.map +1 -0
- package/dist/esm/pages/Debug.js +1 -0
- package/dist/esm/pages/FormAccept.js +1 -1
- package/dist/esm/pages/FormInvite.js +1 -1
- package/dist/esm/pages/FormPage.d.ts +11 -0
- package/dist/esm/pages/FormPage.d.ts.map +1 -0
- package/dist/esm/pages/FormPage.js +1 -0
- package/dist/esm/pages/Help.d.ts +7 -0
- package/dist/esm/pages/Help.d.ts.map +1 -0
- package/dist/esm/pages/Help.js +1 -0
- package/dist/esm/pages/HtmlViewer.js +1 -1
- package/dist/esm/pages/Login.js +1 -1
- package/dist/esm/pages/Purchase.js +1 -1
- package/dist/esm/pages/QrScan.d.ts +12 -0
- package/dist/esm/pages/QrScan.d.ts.map +1 -0
- package/dist/esm/pages/QrScan.js +1 -0
- package/dist/esm/pages/Sales.js +1 -1
- package/dist/esm/pages/SchemaEditor.d.ts +2 -0
- package/dist/esm/pages/SchemaEditor.d.ts.map +1 -0
- package/dist/esm/pages/SchemaEditor.js +1 -0
- package/dist/esm/pages/Search.js +1 -1
- package/dist/esm/pages/Snap.js +1 -1
- package/dist/esm/pages/index.d.ts +5 -0
- package/dist/esm/pages/index.d.ts.map +1 -1
- package/dist/esm/services/codicent.d.ts +7 -0
- 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 +188 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/utils/appState.d.ts.map +1 -1
- package/dist/esm/utils/appState.js +1 -1
- package/dist/index.d.ts +523 -28
- package/package.json +4 -3
|
@@ -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":"AAiBA,eAAO,MAAM,UAAU,QAAS,MAAM,SAerC,CAAC;AA8BF,MAAM,WAAW,QAAQ;IACvB,Q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AsB7B;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";var o;let a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,a,n)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),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 o=new e(t.content).content.split("\n"),a=o[0],n=o.slice(1).join("\n");return{id:t.id,title:a,content:n}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent: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 o=await fetch(`${a}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,n=void 0,s,i=0)=>{const r=await this.request(`${a}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${a}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.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 o=await fetch(`${a}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${a}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:n})=>{const s=await fetch(`${a}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:n,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${a}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${a}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.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 o=await fetch(`${a}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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 fetch(`${a}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["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=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({priceId:t,successUrl:window.location.href,cancelUrl:window.location.href})});if(!e.ok)throw new Error("Failed to create checkout session");const{id:o}=await e.json();return o},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const a=await this.createCheckoutSession(e),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${a}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${a}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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 o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],o=atob(t),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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.request(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${a}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,s(o.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.downloadFile=async t=>{fetch(o.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 o=window.URL.createObjectURL(e),a=document.createElement("a");a.style.display="none",a.href=o,a.download=t.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=3e5,i=2e3)=>{const r={project:e,message:t};let c;o&&(r.messageId=o);try{const t=await fetch(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(r)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(c=(await t.json()).promptMessageId,!c)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const h=Date.now();for(;Date.now()-h<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${c}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json();return o.content.replace(`@${e}`,"").replace("@codicent-mini","").trim()}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()};export{c as CodicentService,s as setBaseUrl};
|
|
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";var o;let a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,a,n)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||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 o=await e.text();return JSON.parse(o)}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 o=new e(t.content).content.split("\n"),a=o[0],n=o.slice(1).join("\n");return{id:t.id,title:a,content:n}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent: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 o=await fetch(`${a}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,n=void 0,s,i=0)=>{const r=await this.request(`${a}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${a}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.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 o=await fetch(`${a}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${a}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:n})=>{const s=await fetch(`${a}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:n,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${a}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${a}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.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 o=await fetch(`${a}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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 fetch(`${a}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["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,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,n={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(n.source=e),o&&o>0&&(n.trialPeriodDays=o);const s=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(n)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const a=await this.createCheckoutSession(e),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${a}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${a}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});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 o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],o=atob(t),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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.request(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${a}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,s(o.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.downloadFile=async t=>{fetch(o.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 o=window.URL.createObjectURL(e),a=document.createElement("a");a.style.display="none",a.href=o,a.download=t.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=3e5,i=2e3)=>{const r={project:e,message:t};let c;o&&(r.messageId=o);try{const t=await fetch(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(r)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(c=(await t.json()).promptMessageId,!c)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const h=Date.now();for(;Date.now()-h<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${c}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json();return o.content.replace(`@${e}`,"").replace("@codicent-mini","").trim()}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()};export{c as CodicentService,s as setBaseUrl};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Public TypeScript type definitions for codicent-app-sdk
|
|
3
|
+
* @module codicent-app-sdk/types
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for a button in the app navigation
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface ButtonConfig {
|
|
11
|
+
/** Button title/label */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Target URL or special action (e.g., "voice:...", "mailto:...", "./#/path") */
|
|
14
|
+
url: string;
|
|
15
|
+
/** Button type/style variant */
|
|
16
|
+
type?: string;
|
|
17
|
+
/** Required claim for button visibility (RBAC) */
|
|
18
|
+
claim?: string;
|
|
19
|
+
/** Inverse claim - hide button if user has this claim */
|
|
20
|
+
notClaim?: string;
|
|
21
|
+
/** Optional subtitle for compound buttons */
|
|
22
|
+
subtitle?: string;
|
|
23
|
+
/** Sub-buttons for multi-option buttons */
|
|
24
|
+
options?: ButtonConfig[];
|
|
25
|
+
}
|
|
26
|
+
import type { ColumnAction, ColumnDefinition } from "../components/ListView";
|
|
27
|
+
export type { ColumnAction, ColumnDefinition };
|
|
28
|
+
/**
|
|
29
|
+
* List definitions keyed by tag name (e.g., "customer2", "offertjson")
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export interface ListDefinitions {
|
|
33
|
+
[tagName: string]: ColumnDefinition[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* AI chat instructions configuration
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export interface ChatInstructions {
|
|
40
|
+
/** Text-based chat instructions (system prompt for chat AI) */
|
|
41
|
+
chat?: string;
|
|
42
|
+
/** Voice-based chat instructions (system prompt for voice AI) */
|
|
43
|
+
voice?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Per-app configuration for multi-app SDK instances
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export interface AppButtonsConfig {
|
|
50
|
+
/** Navigation buttons for this app */
|
|
51
|
+
buttons: ButtonConfig[];
|
|
52
|
+
/** Task definitions (legacy, may be deprecated) */
|
|
53
|
+
tasks: {
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
content: string;
|
|
57
|
+
}[];
|
|
58
|
+
/** Optional list of suggested questions for chat prompts */
|
|
59
|
+
questions?: string[];
|
|
60
|
+
/** Voice AI instructions for this app */
|
|
61
|
+
voiceInstructions: string;
|
|
62
|
+
/** Whether to show HTML view in this app */
|
|
63
|
+
showHtmlView?: boolean;
|
|
64
|
+
/** Text chat AI instructions for this app */
|
|
65
|
+
chatInstructions: string;
|
|
66
|
+
/** List view column definitions per tag */
|
|
67
|
+
listDefinitions?: ListDefinitions;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Translation dictionary: { [translationKey: string]: translatedText }
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export interface TranslationDictionary {
|
|
74
|
+
[key: string]: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Translations map: { [languageCode: string]: TranslationDictionary }
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export interface Translations {
|
|
81
|
+
[languageCode: string]: TranslationDictionary;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Feature module flags
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export interface ModuleFlags {
|
|
88
|
+
/** Enable sales/CRM module */
|
|
89
|
+
sales?: boolean;
|
|
90
|
+
/** Enable voice AI module */
|
|
91
|
+
voice?: boolean;
|
|
92
|
+
/** Enable forms module */
|
|
93
|
+
forms?: boolean;
|
|
94
|
+
/** Enable search module */
|
|
95
|
+
search?: boolean;
|
|
96
|
+
/** Enable QR code scanning module */
|
|
97
|
+
qr?: boolean;
|
|
98
|
+
/** Enable snap/camera module */
|
|
99
|
+
snap?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Props for ListView component
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export interface ListViewProps {
|
|
106
|
+
/** Array of data records to display */
|
|
107
|
+
data: Record<string, unknown>[];
|
|
108
|
+
/** Column definitions (if omitted, auto-generates from data keys) */
|
|
109
|
+
columns?: ColumnDefinition[];
|
|
110
|
+
/** Enable edit action */
|
|
111
|
+
canEdit?: boolean;
|
|
112
|
+
/** Edit callback */
|
|
113
|
+
onEdit?: (item: Record<string, unknown>, index: number) => void;
|
|
114
|
+
/** Delete callback */
|
|
115
|
+
onDelete?: (item: Record<string, unknown>, index: number) => void;
|
|
116
|
+
/** Checkbox toggle callback */
|
|
117
|
+
onToggleCheckbox?: (item: Record<string, unknown>, key: string | string[], newValue: boolean, index: number) => void;
|
|
118
|
+
/** Callback when filtered data changes (for parent component to track) */
|
|
119
|
+
onFilteredDataChange?: (filteredData: Record<string, unknown>[]) => void;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Props for Chat component
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
export interface ChatProps {
|
|
126
|
+
/** Codicent/project to chat with */
|
|
127
|
+
codicent?: string;
|
|
128
|
+
/** Initial message to send on mount */
|
|
129
|
+
initialMessage?: string;
|
|
130
|
+
/** Custom chat instructions (overrides default) */
|
|
131
|
+
instructions?: string;
|
|
132
|
+
/** Show/hide message bar */
|
|
133
|
+
showMessageBar?: boolean;
|
|
134
|
+
/** Custom placeholder text for input */
|
|
135
|
+
placeholder?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Schema definition for data tags
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export interface SchemaDefinition {
|
|
142
|
+
/** JSON Schema for the tag */
|
|
143
|
+
schema: object;
|
|
144
|
+
/** UI hints for form generation */
|
|
145
|
+
uiSchema?: object;
|
|
146
|
+
}
|
|
147
|
+
export type { UserInfo, MemberInfo, AppInfo, Form, TranslationResponse, CodicentServiceOptions, } from "../services/codicent";
|
|
148
|
+
export type { AppConfig, AppConfigOptions } from "../config";
|
|
149
|
+
export type { CodicentAppState } from "../hooks/useCodicentApp";
|
|
150
|
+
/**
|
|
151
|
+
* Data message structure (returned by readDataMessages)
|
|
152
|
+
* Defined in global.d.ts as part of the Codicent global API
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export interface DataMessage {
|
|
156
|
+
id: string;
|
|
157
|
+
fileId: string | null;
|
|
158
|
+
fileIds: string[];
|
|
159
|
+
data: {
|
|
160
|
+
[key: string]: string;
|
|
161
|
+
};
|
|
162
|
+
createdAt: string;
|
|
163
|
+
tags: string[];
|
|
164
|
+
mentions: string[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* File information structure
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
export interface FileInfo {
|
|
171
|
+
id: string;
|
|
172
|
+
filename: string;
|
|
173
|
+
contentType: string;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Generic message structure
|
|
178
|
+
* Note: There's also a Message interface in hooks/useChat that may differ
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
export interface CodicentMessage {
|
|
182
|
+
id: string;
|
|
183
|
+
content: string;
|
|
184
|
+
parentId?: string;
|
|
185
|
+
type?: string;
|
|
186
|
+
createdAt: Date;
|
|
187
|
+
}
|
|
188
|
+
//# sourceM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,KAAK,IAAI;IAqB7E,OAAO,CAAC,YAAY;IAoCb,MAAM;IAIb,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAY7B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IA2BpC;;OAEG;YACW,oBAAoB;IAalC;;OAEG;YACW,gBAAgB;IAmB9B;;OAEG;YACW,YAAY;IAqB1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAwCpC;;OAEG;IACH,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,sBAAsB;IAmgB9B,IAAI,KAAK,kBAER;IAED,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,OAAO;IAiBR,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAI5C,UAAU,IAAI,QAAQ,CAAC,YAAY,CAAC;IAIpC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC;IAI5C,mBAAmB;IAKnB,MAAM;IAaN,cAAc,CAAC,KAAK,EAAE,MAAM;IAK5B,MAAM;CAad;AAGD,eAAO,MAAM,qBAAqB,YAAa,eAAe,iBAAiB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,oBAErG,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"../_virtual/index.js";import{getConfigValue as e}from"../config/index.js";import{CacheManager as i}from"./cacheManager.js";class n extends t.StateMachine{constructor(t,n){if(super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.service=t,this.onStateChange=n,this.cacheManager=new i("state_machine"),e("ENABLE_STATE_CACHE")&&e("OPTIMISTIC_CACHE_LOAD")){const t=this.loadFromCache();t?this.hydrateFromCache(t):this.resetContext()}else this.resetContext();this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e("APP_NAME")?localStorage.removeItem("selectedApp"):this.context.selectedApp=localStorage.getItem("selectedApp")||void 0,e("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}loadFromCache(){if(!e("ENABLE_STATE_CACHE"))return null;const t=this.cacheManager.get("user_session");return t?this.isValidCacheStructure(t.data)?(console.log("AppStateMachine: Loaded session from cache",{nickname:t.data.nickname,selectedApp:t.data.selectedApp,appsCount:t.data.apps?.length||0,age:Math.round((Date.now()-t.cachedAt)/1e3)+"s"}),t.data):(console.warn("AppStateMachine: Invalid cache structure, clearing cache"),this.cacheManager.invalidate("user_session"),null):null}hydrateFromCache(t){this.context={...this.context,nickname:t.nickname,name:t.name,selectedApp:t.selectedApp,apps:t.apps,hasValidPurchase:t.hasValidPurchase,isRegistered:t.isRegistered,hasAccess:!0,hasApps:t.apps.length>0,appsLoaded:!0,isFromCache:!0,needsValidation:e("VALIDATE_CACHE_IN_BACKGROUND")},t.selectedApp&&(this.service.codicent=t.selectedApp),e("VALIDATE_CACHE_IN_BACKGROUND")&&this.scheduleBackgroundValidation()}isValidCacheStructure(t){return"object"==typeof t&&null!==t&&"string"==typeof t.nickname&&"string"==typeof t.selectedApp&&Array.isArray(t.apps)&&"boolean"==typeof t.isRegistered&&"boolean"==typeof t.hasValidPurchase}scheduleBackgroundValidation(){e("VALIDATE_CACHE_IN_BACKGROUND")&&setTimeout((async()=>{try{const t=await Promise.all([this.validateRegistration(),this.validatePurchase(),this.validateApps()]);t.every((t=>t.valid))?(console.log("AppStateMachine: Background validation passed, updating cache"),this.saveToCache(),this.updateContext({needsValidation:!1})):(console.warn("AppStateMachine: Background validation failed",t),this.handleCacheValidationFailure(t))}catch(t){console.warn("AppStateMachine: Background validation error:",t)}}),100)}async validateRegistration(){try{const t=await this.service.getNickname();return{valid:t===this.context.nickname,data:{nickname:t}}}catch(t){return console.warn("AppStateMachine: Failed to validate registration",t),{valid:!1}}}async validatePurchase(){if(!e("SUBSCRIPTION_NEEDED"))return{valid:!0};try{const t=await this.service.checkSubscriptionStatus();return{valid:"active"===t===this.context.hasValidPurchase,data:{hasValidPurchase:"active"===t}}}catch(t){return console.warn("AppStateMachine: Failed to validate purchase",t),{valid:!1}}}async validateApps(){try{let t=await this.service.getApps();if(null===t)return{valid:!1};e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX")))));return{valid:this.areAppsEqual(t,this.context.apps||[]),data:{apps:t}}}catch(t){return console.warn("AppStateMachine: Failed to validate apps",t),{valid:!1}}}areAppsEqual(t,e){return t.length===e.length&&t.every((t=>e.some((e=>e.id===t.id))))}handleCacheValidationFailure(t){"strict"===e("CACHE_FAILURE_MODE")?(console.warn("AppStateMachine: Strict mode - invalidating cache"),this.cacheManager.invalidate("user_session"),this.updateContext({isFromCache:!1,needsValidation:!1,hasAccess:!1}),t[0].valid?!t[1].valid&&e("SUBSCRIPTION_NEEDED")?this.current=this.allStates.needsPurchase:t[2].valid||(this.current=this.allStates.gettingApps):this.current=this.allStates.registering):(console.warn("AppStateMachine: Lenient mode - continuing with cache, marking as needing update"),this.updateContext({needsValidation:!0}),t.forEach((t=>{t.data&&this.updateContext(t.data)})),this.saveToCache()),this.update()}saveToCache(){if(!e("ENABLE_STATE_CACHE"))return;if(!this.context.nickname||!this.context.selectedApp)return;const t={nickname:this.context.nickname,name:this.context.name||"",selectedApp:this.context.selectedApp,apps:this.context.apps||[],hasValidPurchase:this.context.hasValidPurchase||!1,isRegistered:this.context.isRegistered||!1,cachedAt:Date.now(),expiresAt:Date.now()+e("SESSION_CACHE_TTL"),version:"1.0.0"};this.cacheManager.set("user_session",t,e("SESSION_CACHE_TTL")),console.log("AppStateMachine: Saved session to cache")}initializeStateMachine(){const i=new t.State,n=new t.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.State,a=new t.State,o=new t.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),r=new t.State,c=new t.State({entering:()=>{this.checkPurchase()}}),d=new t.State({entering:()=>{this.handlePurchase()}}),h=new t.State({entering:()=>{this.getApps()}}),p=new t.State,l=new t.State,A=new t.State({entering:()=>{e("ENABLE_STATE_CACHE")&&!this.context.isFromCache&&this.saveToCache()}}),u=new t.State,g=new t.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),x=new t.State({entering:()=>{e("ENABLE_STATE_CACHE")&&this.cacheManager.clear(),localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0,isFromCache:!1,needsValidation:!1}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),C=new t.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),T=new t.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),S=new t.State({entering:()=>{this.service.setToken(e("ANONYMOUS_TOKEN")),this.service.codicent=e("ANONYMOUS_CODICENT")||e("APP_NAME")||""}}),E=new t.State({entering:()=>{console.log("AppStateMachine: State - restoring from cache")}}),m=new t.State({entering:()=>{console.log("AppStateMachine: State - validating cache")}});i.addTransition(E,{condition:()=>!0===this.context.isFromCache&&e("ENABLE_STATE_CACHE")}),i.addTransition(n,{condition:()=>!this.context.isFromCache||!e("ENABLE_STATE_CACHE")}),E.addTransition(A,{condition:()=>!0===this.context.hasAccess&&!0===this.context.isFromCache}),E.addTransition(n,{condition:()=>!this.context.hasAccess||!this.context.isFromCache}),n.addTransition(a,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(u,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(a,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(u,{condition:()=>!!this.context.error}),a.addTransition(T,{}),T.addTransition(o,{condition:()=>!1===this.context.isRegistered}),T.addTransition(r,{condition:()=>!0===this.context.isRegistered}),T.addTransition(u,{condition:()=>!!this.context.error}),r.addTransition(g,{condition:()=>!!this.context.nickname}),r.addTransition(u,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(u,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e("APP_NAME")&&this.context.hasApps}),h.addTransition(C,{condition:()=>!e("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),C.addTransition(p,{condition:()=>!!this.context.selectedApp}),C.addTransition(u,{condition:()=>!!this.context.error}),p.addTransition(A,{condition:()=>!e("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(A,{condition:()=>!e("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(A,{condition:()=>this.context.apps.some((t=>t.id===e("APP_NAME"))),action:()=>{const t=e("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e("APP_NAME"))}),A.addTransition(g,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),o.addTransition(r,{condition:()=>!0===this.context.isRegistered}),o.addTransition(u,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,T,o].forEach((t=>{t.addTransition(u,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(u,{condition:()=>!!this.context.error})})),[a,r,A,l].forEach((t=>{t.addTransition(x,{condition:()=>!1===this.context.isAuthenticated})})),r.addTransition(g,{condition:()=>!this.context.user&&!!this.context.nickname}),g.addTransition(c,{condition:()=>!!this.context.name&&e("SUBSCRIPTION_NEEDED")}),g.addTransition(h,{condition:()=>!!this.context.name&&!e("SUBSCRIPTION_NEEDED")}),u.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),u.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),u.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),u.addTransition(g,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),u.addTransition(C,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),u.addTransition(T,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),x.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,A,s,u,x,n,a,r].forEach((t=>{t.addTransition(S,{condition:()=>!0===this.context.isAnonymous&&!!e("ANONYMOUS_TOKEN")})}));const v={initial:i,authenticating:n,notAuthenticated:s,authenticated:a,checkingCodicentAccess:T,registering:o,registered:r,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:C,checkingAccess:p,noAccess:l,error:u,loadingUser:g,loggingOut:x,hasAccess:A,anonymous:S,restoringFromCache:E,validatingCache:m};return this.states.push(...Object.values(v)),this.current=v.initial,v}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){e("ENABLE_STATE_CACHE")&&this.cacheManager.clear(),localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}const s=(t,e)=>new n(t,e);export{n as AppStateMachine,s as createAppStateMachine,n as default};
|
|
1
|
+
import{d as t}from"../_virtual/index.js";import{getConfigValue as e}from"../config/index.js";import{CacheManager as i}from"./cacheManager.js";class n extends t.StateMachine{constructor(t,n){if(super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.service=t,this.onStateChange=n,this.cacheManager=new i("state_machine"),e("ENABLE_STATE_CACHE")&&e("OPTIMISTIC_CACHE_LOAD")){const t=this.loadFromCache();t?this.hydrateFromCache(t):this.resetContext()}else this.resetContext();this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e("APP_NAME")?localStorage.removeItem("selectedApp"):this.context.selectedApp=localStorage.getItem("selectedApp")||void 0,e("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}loadFromCache(){if(!e("ENABLE_STATE_CACHE"))return null;const t=this.cacheManager.get("user_session");return t?this.isValidCacheStructure(t.data)?(console.log("AppStateMachine: Loaded session from cache",{nickname:t.data.nickname,selectedApp:t.data.selectedApp,appsCount:t.data.apps?.length||0,age:Math.round((Date.now()-t.cachedAt)/1e3)+"s"}),t.data):(console.warn("AppStateMachine: Invalid cache structure, clearing cache"),this.cacheManager.invalidate("user_session"),null):null}hydrateFromCache(t){this.context={...this.context,nickname:t.nickname,name:t.name,selectedApp:t.selectedApp,apps:t.apps,hasValidPurchase:t.hasValidPurchase,isRegistered:t.isRegistered,hasAccess:!0,hasApps:t.apps.length>0,appsLoaded:!0,isFromCache:!0,needsValidation:e("VALIDATE_CACHE_IN_BACKGROUND")},t.selectedApp&&(this.service.codicent=t.selectedApp),e("VALIDATE_CACHE_IN_BACKGROUND")&&this.scheduleBackgroundValidation()}isValidCacheStructure(t){return"object"==typeof t&&null!==t&&"string"==typeof t.nickname&&"string"==typeof t.selectedApp&&Array.isArray(t.apps)&&"boolean"==typeof t.isRegistered&&"boolean"==typeof t.hasValidPurchase}scheduleBackgroundValidation(){e("VALIDATE_CACHE_IN_BACKGROUND")&&setTimeout((async()=>{try{const t=await Promise.all([this.validateRegistration(),this.validatePurchase(),this.validateApps()]);t.every((t=>t.valid))?(console.log("AppStateMachine: Background validation passed, updating cache"),this.saveToCache(),this.updateContext({needsValidation:!1})):(console.warn("AppStateMachine: Background validation failed",t),this.handleCacheValidationFailure(t))}catch(t){console.warn("AppStateMachine: Background validation error:",t)}}),100)}async validateRegistration(){try{const t=await this.service.getNickname();return{valid:t===this.context.nickname,data:{nickname:t}}}catch(t){return console.warn("AppStateMachine: Failed to validate registration",t),{valid:!1}}}async validatePurchase(){if(!e("SUBSCRIPTION_NEEDED"))return{valid:!0};try{const t=await this.service.checkSubscriptionStatus(),e="active"===t||"trialing"===t;return{valid:e===this.context.hasValidPurchase,data:{hasValidPurchase:e}}}catch(t){return console.warn("AppStateMachine: Failed to validate purchase",t),{valid:!1}}}async validateApps(){try{let t=await this.service.getApps();if(null===t)return{valid:!1};e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX")))));return{valid:this.areAppsEqual(t,this.context.apps||[]),data:{apps:t}}}catch(t){return console.warn("AppStateMachine: Failed to validate apps",t),{valid:!1}}}areAppsEqual(t,e){return t.length===e.length&&t.every((t=>e.some((e=>e.id===t.id))))}handleCacheValidationFailure(t){"strict"===e("CACHE_FAILURE_MODE")?(console.warn("AppStateMachine: Strict mode - invalidating cache"),this.cacheManager.invalidate("user_session"),this.updateContext({isFromCache:!1,needsValidation:!1,hasAccess:!1}),t[0].valid?!t[1].valid&&e("SUBSCRIPTION_NEEDED")?this.current=this.allStates.needsPurchase:t[2].valid||(this.current=this.allStates.gettingApps):this.current=this.allStates.registering):(console.warn("AppStateMachine: Lenient mode - continuing with cache, marking as needing update"),this.updateContext({needsValidation:!0}),t.forEach((t=>{t.data&&this.updateContext(t.data)})),this.saveToCache()),this.update()}saveToCache(){if(!e("ENABLE_STATE_CACHE"))return;if(!this.context.nickname||!this.context.selectedApp)return;const t={nickname:this.context.nickname,name:this.context.name||"",selectedApp:this.context.selectedApp,apps:this.context.apps||[],hasValidPurchase:this.context.hasValidPurchase||!1,isRegistered:this.context.isRegistered||!1,cachedAt:Date.now(),expiresAt:Date.now()+e("SESSION_CACHE_TTL"),version:"1.0.0"};this.cacheManager.set("user_session",t,e("SESSION_CACHE_TTL")),console.log("AppStateMachine: Saved session to cache")}initializeStateMachine(){const i=new t.State,n=new t.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.State,a=new t.State,o=new t.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),r=new t.State,c=new t.State({entering:()=>{this.checkPurchase()}}),d=new t.State({entering:()=>{this.handlePurchase()}}),h=new t.State({entering:()=>{this.getApps()}}),p=new t.State,l=new t.State,A=new t.State({entering:()=>{e("ENABLE_STATE_CACHE")&&!this.context.isFromCache&&this.saveToCache()}}),u=new t.State,g=new t.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),x=new t.State({entering:()=>{e("ENABLE_STATE_CACHE")&&this.cacheManager.clear(),localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0,isFromCache:!1,needsValidation:!1}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),C=new t.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),T=new t.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),S=new t.State({entering:()=>{this.service.setToken(e("ANONYMOUS_TOKEN")),this.service.codicent=e("ANONYMOUS_CODICENT")||e("APP_NAME")||""}}),E=new t.State({entering:()=>{console.log("AppStateMachine: State - restoring from cache")}}),m=new t.State({entering:()=>{console.log("AppStateMachine: State - validating cache")}});i.addTransition(E,{condition:()=>!0===this.context.isFromCache&&e("ENABLE_STATE_CACHE")}),i.addTransition(n,{condition:()=>!this.context.isFromCache||!e("ENABLE_STATE_CACHE")}),E.addTransition(A,{condition:()=>!0===this.context.hasAccess&&!0===this.context.isFromCache}),E.addTransition(n,{condition:()=>!this.context.hasAccess||!this.context.isFromCache}),n.addTransition(a,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(u,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(a,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(u,{condition:()=>!!this.context.error}),a.addTransition(T,{}),T.addTransition(o,{condition:()=>!1===this.context.isRegistered}),T.addTransition(r,{condition:()=>!0===this.context.isRegistered}),T.addTransition(u,{condition:()=>!!this.context.error}),r.addTransition(g,{condition:()=>!!this.context.nickname}),r.addTransition(u,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(u,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e("APP_NAME")&&this.context.hasApps}),h.addTransition(C,{condition:()=>!e("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),C.addTransition(p,{condition:()=>!!this.context.selectedApp}),C.addTransition(u,{condition:()=>!!this.context.error}),p.addTransition(A,{condition:()=>!e("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(A,{condition:()=>!e("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(A,{condition:()=>this.context.apps.some((t=>t.id===e("APP_NAME"))),action:()=>{const t=e("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e("APP_NAME"))}),A.addTransition(g,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),o.addTransition(r,{condition:()=>!0===this.context.isRegistered}),o.addTransition(u,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,T,o].forEach((t=>{t.addTransition(u,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(u,{condition:()=>!!this.context.error})})),[a,r,A,l].forEach((t=>{t.addTransition(x,{condition:()=>!1===this.context.isAuthenticated})})),r.addTransition(g,{condition:()=>!this.context.user&&!!this.context.nickname}),g.addTransition(c,{condition:()=>!!this.context.name&&e("SUBSCRIPTION_NEEDED")}),g.addTransition(h,{condition:()=>!!this.context.name&&!e("SUBSCRIPTION_NEEDED")}),u.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),u.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),u.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),u.addTransition(g,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),u.addTransition(C,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),u.addTransition(T,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),x.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,A,s,u,x,n,a,r].forEach((t=>{t.addTransition(S,{condition:()=>!0===this.context.isAnonymous&&!!e("ANONYMOUS_TOKEN")})}));const v={initial:i,authenticating:n,notAuthenticated:s,authenticated:a,checkingCodicentAccess:T,registering:o,registered:r,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:C,checkingAccess:p,noAccess:l,error:u,loadingUser:g,loggingOut:x,hasAccess:A,anonymous:S,restoringFromCache:E,validatingCache:m};return this.states.push(...Object.values(v)),this.current=v.initial,v}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t||"trialing"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){e("ENABLE_STATE_CACHE")&&this.cacheManager.clear(),localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}const s=(t,e)=>new n(t,e);export{n as AppStateMachine,s as createAppStateMachine,n as default};
|