@elyx-code/editor-ui 0.0.2
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 +2 -0
- package/package.json +109 -0
- package/src/App.tsx +31 -0
- package/src/Router.tsx +115 -0
- package/src/__mocks__/defaultModuleMock.ts +1 -0
- package/src/__mocks__/fileMock.ts +1 -0
- package/src/__mocks__/styleMock.ts +1 -0
- package/src/assets/Clock-11.1s-18px.svg +16 -0
- package/src/assets/Clock-11.1s-28px.svg +16 -0
- package/src/assets/authentication.svg +1 -0
- package/src/assets/canvas-backdrop-0.png +0 -0
- package/src/assets/canvas-backdrop-1.png +0 -0
- package/src/assets/canvas-backdrop-2.png +0 -0
- package/src/assets/canvas-backdrop-3.png +0 -0
- package/src/assets/canvas-backdrop-4.png +0 -0
- package/src/assets/canvas-backdrop-5.png +0 -0
- package/src/assets/canvas-backdrop.png +0 -0
- package/src/assets/checkmark-animation.gif +0 -0
- package/src/assets/checkmark-animation.mp4 +0 -0
- package/src/assets/code-formatting/format-black.svg +6 -0
- package/src/assets/code-formatting/format-dark-grey.svg +6 -0
- package/src/assets/code-formatting/format-light-grey.svg +6 -0
- package/src/assets/code-formatting/format-white.svg +6 -0
- package/src/assets/code-formatting/inline-black.svg +5 -0
- package/src/assets/code-formatting/inline-dark-grey.svg +5 -0
- package/src/assets/code-formatting/inline-light-grey.svg +5 -0
- package/src/assets/code-formatting/inline-white.svg +5 -0
- package/src/assets/contained-logo-full-word.png +0 -0
- package/src/assets/cron-job-color.png +0 -0
- package/src/assets/cron-job.png +0 -0
- package/src/assets/database-table-color.png +0 -0
- package/src/assets/database-table.png +0 -0
- package/src/assets/datatype-icons/black/any.svg +1 -0
- package/src/assets/datatype-icons/black/binary.svg +1 -0
- package/src/assets/datatype-icons/black/boolean.svg +3 -0
- package/src/assets/datatype-icons/black/date-time.svg +3 -0
- package/src/assets/datatype-icons/black/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/black/key-file.svg +1 -0
- package/src/assets/datatype-icons/black/list.svg +3 -0
- package/src/assets/datatype-icons/black/null.svg +3 -0
- package/src/assets/datatype-icons/black/number.svg +13 -0
- package/src/assets/datatype-icons/black/project.svg +12 -0
- package/src/assets/datatype-icons/black/sql-program.svg +2 -0
- package/src/assets/datatype-icons/black/text.svg +3 -0
- package/src/assets/datatype-icons/black/unknown.svg +3 -0
- package/src/assets/datatype-icons/black/uuid.svg +4 -0
- package/src/assets/datatype-icons/black/void.svg +1 -0
- package/src/assets/datatype-icons/dark-grey/any.svg +1 -0
- package/src/assets/datatype-icons/dark-grey/boolean.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/date-time.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/dark-grey/list.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/null.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/number.svg +13 -0
- package/src/assets/datatype-icons/dark-grey/project.svg +12 -0
- package/src/assets/datatype-icons/dark-grey/sql-program.svg +2 -0
- package/src/assets/datatype-icons/dark-grey/text.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/unknown.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/uuid.svg +4 -0
- package/src/assets/datatype-icons/dark-grey/void.svg +1 -0
- package/src/assets/datatype-icons/light-grey/any.svg +1 -0
- package/src/assets/datatype-icons/light-grey/boolean.svg +3 -0
- package/src/assets/datatype-icons/light-grey/date-time.svg +3 -0
- package/src/assets/datatype-icons/light-grey/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/light-grey/list.svg +3 -0
- package/src/assets/datatype-icons/light-grey/null.svg +3 -0
- package/src/assets/datatype-icons/light-grey/number.svg +13 -0
- package/src/assets/datatype-icons/light-grey/project.svg +12 -0
- package/src/assets/datatype-icons/light-grey/sql-program.svg +2 -0
- package/src/assets/datatype-icons/light-grey/text.svg +3 -0
- package/src/assets/datatype-icons/light-grey/unknown.svg +3 -0
- package/src/assets/datatype-icons/light-grey/uuid.svg +4 -0
- package/src/assets/datatype-icons/light-grey/void.svg +1 -0
- package/src/assets/edit.png +0 -0
- package/src/assets/execution.svg +13 -0
- package/src/assets/favicon.svg +14 -0
- package/src/assets/file-search.svg +1 -0
- package/src/assets/http-endpoint.png +0 -0
- package/src/assets/image-input-placeholder.png +0 -0
- package/src/assets/logo-full-word-white.png +0 -0
- package/src/assets/logo-full-word.png +0 -0
- package/src/assets/password.svg +85 -0
- package/src/assets/pencil.png +0 -0
- package/src/assets/publish-project-rich-icon-2.svg +1 -0
- package/src/assets/publish-project-rich-icon.svg +1 -0
- package/src/assets/relational-database.png +0 -0
- package/src/assets/resources.svg +3 -0
- package/src/assets/resume-icon-14px.png +0 -0
- package/src/assets/server.png +0 -0
- package/src/assets/small-status/checkmark.svg +4 -0
- package/src/assets/small-status/error.svg +4 -0
- package/src/assets/small-status/loading.svg +4 -0
- package/src/assets/small-status/skipped.svg +11 -0
- package/src/assets/sql-connection-config.svg +1 -0
- package/src/assets/sql-row-transformer.svg +1 -0
- package/src/assets/ssl-certificate-config.svg +1 -0
- package/src/assets/sync.svg +1 -0
- package/src/assets/testing-logic-icon.svg +1 -0
- package/src/assets/versions.svg +25 -0
- package/src/assets/visual-programming-icon.svg +1 -0
- package/src/assets/warning-sign-24px.png +0 -0
- package/src/auth/index.ts +318 -0
- package/src/components/DialogLoader.tsx +94 -0
- package/src/components/EntityDialogHeader.tsx +110 -0
- package/src/components/EntityDialogSectionHeader.tsx +214 -0
- package/src/components/GalleryAddExternalIntegrationInfoDialog.tsx +87 -0
- package/src/components/GenerateProjectStartingLogicPromptDialog.tsx +281 -0
- package/src/components/LegacyRouteRedirector.tsx +55 -0
- package/src/components/ProPlanChip.tsx +23 -0
- package/src/components/ReportBugDialog.tsx +412 -0
- package/src/components/RequestIntegrationAccessDialog.tsx +261 -0
- package/src/components/UseTemplateProjectDialog.tsx +193 -0
- package/src/components/WorkspaceLayout.tsx +152 -0
- package/src/components/animated-svg/AnimatedCheckmark.tsx +41 -0
- package/src/components/animated-svg/AnimatedCrossmark.tsx +51 -0
- package/src/components/animated-svg/AnimatedEmailSending.tsx +38 -0
- package/src/components/animated-svg/AnimatedLoading.tsx +72 -0
- package/src/components/animated-svg/animated-svg.css +239 -0
- package/src/components/canvas/Canvas.tsx +16 -0
- package/src/components/canvas/CreateEntityMenu.tsx +2020 -0
- package/src/components/canvas/canvas.css +10 -0
- package/src/components/canvas/create-entity-menu.css +579 -0
- package/src/components/canvas-search/CanvasSearch.tsx +501 -0
- package/src/components/canvas-search/canvas-search.css +126 -0
- package/src/components/canvas-settings-menu/CanvasSettingsMenuButton.tsx +515 -0
- package/src/components/canvas-settings-menu/canvas-settings-menu.css +96 -0
- package/src/components/circular-image-upload/CircularImageUpload.tsx +113 -0
- package/src/components/circular-image-upload/circular-image-upload.css +69 -0
- package/src/components/costs/CostsDialog.tsx +459 -0
- package/src/components/data-type/DataTypeBuilder.tsx +3127 -0
- package/src/components/data-type/data-type-builder.css +45 -0
- package/src/components/dialogs/BetaAcknowledgeDialog.tsx +43 -0
- package/src/components/dialogs/ComplexDataDialog.tsx +458 -0
- package/src/components/dialogs/CronBuilderDialog.tsx +2145 -0
- package/src/components/dialogs/ExternalIntegrationConnections.tsx +565 -0
- package/src/components/dialogs/JsonEditorDialog.tsx +1392 -0
- package/src/components/dialogs/StringEditorDialog.tsx +268 -0
- package/src/components/dialogs/argument-declaration/ArgumentDeclaration.tsx +1167 -0
- package/src/components/dialogs/argument-declaration/ArgumentDeclarationDialogContent.tsx +128 -0
- package/src/components/dialogs/beta-dialog.css +165 -0
- package/src/components/dialogs/condition/Condition.tsx +431 -0
- package/src/components/dialogs/condition/ConditionDialogContent.tsx +126 -0
- package/src/components/dialogs/definition-entity/DefinitionEntityDialogContent.tsx +973 -0
- package/src/components/dialogs/function-call/FunctionCall.tsx +442 -0
- package/src/components/dialogs/function-call/FunctionCallDialogContent.tsx +126 -0
- package/src/components/dialogs/function-declaration/FunctionDeclaration.tsx +926 -0
- package/src/components/dialogs/function-declaration/FunctionDeclarationDialogContent.tsx +124 -0
- package/src/components/dialogs/generating-project-starting-logic-overlay/GeneratingProjectStartingLogicOverlay.tsx +176 -0
- package/src/components/dialogs/generating-project-starting-logic-overlay/generating-project-starting-logic-overlay.css +13 -0
- package/src/components/dialogs/global-event/GlobalEvent.tsx +475 -0
- package/src/components/dialogs/global-event/GlobalEventDialogContent.tsx +126 -0
- package/src/components/dialogs/help/HelpDialog.tsx +217 -0
- package/src/components/dialogs/help/HelpDilalogHomeContent.tsx +178 -0
- package/src/components/dialogs/help/help-dialog.css +116 -0
- package/src/components/dialogs/help/help-icon/HelpIconButton.tsx +41 -0
- package/src/components/dialogs/help/help-icon/help-icon.css +9 -0
- package/src/components/dialogs/input-map/InputMap.tsx +635 -0
- package/src/components/dialogs/input-map/InputMapDialogContent.tsx +126 -0
- package/src/components/dialogs/json-editor-dialog.css +4 -0
- package/src/components/dialogs/loop/Loop.tsx +650 -0
- package/src/components/dialogs/loop/LoopDialogContent.tsx +122 -0
- package/src/components/dialogs/operation/Operation.tsx +440 -0
- package/src/components/dialogs/operation/OperationDialogContent.tsx +126 -0
- package/src/components/dialogs/output-map/OutputMap.tsx +536 -0
- package/src/components/dialogs/output-map/OutputMapDialogContent.tsx +126 -0
- package/src/components/dialogs/property/Property.tsx +1490 -0
- package/src/components/dialogs/property/PropertyDialogContent.tsx +106 -0
- package/src/components/dialogs/search-statement/ColumnSelector.tsx +334 -0
- package/src/components/dialogs/search-statement/ConditionBuilder.tsx +750 -0
- package/src/components/dialogs/search-statement/DataAggregationSection.tsx +621 -0
- package/src/components/dialogs/search-statement/DataSourceSelection.tsx +734 -0
- package/src/components/dialogs/search-statement/EntityMetadataSection.tsx +135 -0
- package/src/components/dialogs/search-statement/FilterConditionsSection.tsx +151 -0
- package/src/components/dialogs/search-statement/InlineInputMap.tsx +153 -0
- package/src/components/dialogs/search-statement/LiteralValue.tsx +616 -0
- package/src/components/dialogs/search-statement/MainSourceAndInputsSection.tsx +271 -0
- package/src/components/dialogs/search-statement/NestedSearchStatementBuilder.tsx +170 -0
- package/src/components/dialogs/search-statement/OutputFormatSection.tsx +1779 -0
- package/src/components/dialogs/search-statement/ResultsSection.tsx +344 -0
- package/src/components/dialogs/search-statement/SearchStatementBuilder.tsx +251 -0
- package/src/components/dialogs/search-statement/SearchStatementDialogContent.tsx +398 -0
- package/src/components/dialogs/search-statement/ValueSelector.tsx +766 -0
- package/src/components/dialogs/search-statement/search-statement-context.tsx +1630 -0
- package/src/components/dialogs/search-statement/search-statement-dialog.css +56 -0
- package/src/components/dialogs/search-statement/test.sql +111 -0
- package/src/components/dialogs/value-descriptor/ValueDescriptor.tsx +824 -0
- package/src/components/dialogs/value-descriptor/ValueDescriptorDialogContent.tsx +124 -0
- package/src/components/dialogs/variable-declaration/VariableDeclaration.tsx +836 -0
- package/src/components/dialogs/variable-declaration/VariableDeclarationDialogContent.tsx +106 -0
- package/src/components/dialogs/variable-instance/VariableInstance.tsx +443 -0
- package/src/components/dialogs/variable-instance/VariableInstanceDialogContent.tsx +124 -0
- package/src/components/draggable-entity-card/ArgumentDeclaration.tsx +736 -0
- package/src/components/draggable-entity-card/CollapseEntityButton.tsx +170 -0
- package/src/components/draggable-entity-card/ConditionCard.tsx +1062 -0
- package/src/components/draggable-entity-card/ConnectionDeleteButton.tsx +309 -0
- package/src/components/draggable-entity-card/DataTypeIcon.tsx +624 -0
- package/src/components/draggable-entity-card/DraggableEntityCard.tsx +617 -0
- package/src/components/draggable-entity-card/ErrorMapProperty.tsx +464 -0
- package/src/components/draggable-entity-card/EventCard.tsx +700 -0
- package/src/components/draggable-entity-card/ExecutionInProgressValue.tsx +327 -0
- package/src/components/draggable-entity-card/FunctionDeclarationCard.tsx +819 -0
- package/src/components/draggable-entity-card/InputMapProperty.tsx +1067 -0
- package/src/components/draggable-entity-card/InternalCall.tsx +978 -0
- package/src/components/draggable-entity-card/InternalCallExecutionNode.tsx +643 -0
- package/src/components/draggable-entity-card/LogicScopeCallerNode.tsx +262 -0
- package/src/components/draggable-entity-card/LoopCard.tsx +791 -0
- package/src/components/draggable-entity-card/MainValueInput.tsx +523 -0
- package/src/components/draggable-entity-card/MainValueOutput.tsx +458 -0
- package/src/components/draggable-entity-card/MethodDeclaration.tsx +1088 -0
- package/src/components/draggable-entity-card/NestedCondition.tsx +1025 -0
- package/src/components/draggable-entity-card/OutputMapProperty.tsx +843 -0
- package/src/components/draggable-entity-card/PassthroughEntityCard.tsx +1247 -0
- package/src/components/draggable-entity-card/ReturnedError.tsx +549 -0
- package/src/components/draggable-entity-card/SmallSuccessFailureNodes.tsx +523 -0
- package/src/components/draggable-entity-card/SuccessFailureNodes.tsx +509 -0
- package/src/components/draggable-entity-card/TestEntityButton.tsx +946 -0
- package/src/components/draggable-entity-card/TestMenu.tsx +523 -0
- package/src/components/draggable-entity-card/TestMenuValidationDropdown.tsx +84 -0
- package/src/components/draggable-entity-card/UnreachableMarker.tsx +114 -0
- package/src/components/draggable-entity-card/VariableCard.tsx +1577 -0
- package/src/components/draggable-entity-card/VariableScopeMarker.tsx +117 -0
- package/src/components/draggable-entity-card/collapse-entity-button.css +44 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityCard.tsx +1181 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityIcon.tsx +36 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityProperty.tsx +478 -0
- package/src/components/draggable-entity-card/definition-entity/DynamicFooterActions.tsx +112 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/ExportCredentialsFooterAction.tsx +461 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/RestablishConnectionFooterAction.tsx +199 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/restablish-connection-footer-action.css +85 -0
- package/src/components/draggable-entity-card/definition-entity/actions/google-drive/GoogleDriveFilePickerAPIFooterAction.tsx +277 -0
- package/src/components/draggable-entity-card/definition-entity/actions/google-drive/google-drive-file-picker-api-footer-action.css +107 -0
- package/src/components/draggable-entity-card/definition-entity/actions/persisted-entity/DatabaseFooterAction.tsx +452 -0
- package/src/components/draggable-entity-card/definition-entity/actions/persisted-entity/database-footer-action.css +86 -0
- package/src/components/draggable-entity-card/definition-entity/definition-entity-card.css +17 -0
- package/src/components/draggable-entity-card/draggable-entity-card.css +1140 -0
- package/src/components/draggable-entity-card/entity-locked-icon/EntityLockedIcon.tsx +133 -0
- package/src/components/draggable-entity-card/entity-locked-icon/entity-locked.css +8 -0
- package/src/components/draggable-entity-card/expand-properties-icon-button/ExpandPropertiesIconButton.tsx +84 -0
- package/src/components/draggable-entity-card/expand-properties-icon-button/expand-properties-icon-button.css +21 -0
- package/src/components/draggable-entity-card/implement-entity-icon/ImplementEntityIcon.tsx +74 -0
- package/src/components/draggable-entity-card/implement-entity-icon/implement-entity-icon.css +13 -0
- package/src/components/draggable-entity-card/logic-error/LogicErrorIconMenu.tsx +424 -0
- package/src/components/draggable-entity-card/logic-error/logic-error.css +23 -0
- package/src/components/draggable-entity-card/new-card-input-button/NewCardInputButton.tsx +193 -0
- package/src/components/draggable-entity-card/new-card-input-button/NewDynamicInputButton.tsx +214 -0
- package/src/components/draggable-entity-card/new-card-input-button/new-card-input-button.css +71 -0
- package/src/components/draggable-entity-card/new-card-output-button/NewCardOutputButton.tsx +192 -0
- package/src/components/draggable-entity-card/new-card-output-button/new-card-output-button.css +71 -0
- package/src/components/draggable-entity-card/termination-statement/TerminationStatementCard.tsx +1543 -0
- package/src/components/draggable-entity-card/termination-statement/termination-statement-card.css +17 -0
- package/src/components/draggable-entity-card/test-entity-button.css +55 -0
- package/src/components/draggable-entity-card/test-menu.css +181 -0
- package/src/components/draggable-entity-card/unreachable-marker.css +43 -0
- package/src/components/draggable-entity-card/variable-scope-marker.css +22 -0
- package/src/components/dynamic-value/DynamicValue.tsx +2395 -0
- package/src/components/dynamic-value/DynamicValueEntry.tsx +1957 -0
- package/src/components/dynamic-value/dynamic-value.css +230 -0
- package/src/components/editor/ElyxMonacoEditor.tsx +38 -0
- package/src/components/entity-error/EntityErrorListItem.tsx +47 -0
- package/src/components/entity-error/entity-error.css +198 -0
- package/src/components/entity-icon/EntityIcon.tsx +292 -0
- package/src/components/entity-icon/entity-icon.css +39 -0
- package/src/components/gallery-card/CreateNewProject.tsx +222 -0
- package/src/components/gallery-card/GalleryCard.tsx +171 -0
- package/src/components/gallery-card/MarketplaceCard.tsx +87 -0
- package/src/components/gallery-card/ProjectDuplicationCard.tsx +575 -0
- package/src/components/gallery-card/gallery-card.css +25 -0
- package/src/components/notifications/NotificationsIconButton.tsx +124 -0
- package/src/components/notifications/NotificationsPanel.tsx +385 -0
- package/src/components/notifications/notifications.css +189 -0
- package/src/components/online-users/LocalOnlineUsers.tsx +175 -0
- package/src/components/online-users/PageOnlineUsers.tsx +297 -0
- package/src/components/online-users/online-users.css +72 -0
- package/src/components/page-backdrop/PageBackdrop.tsx +8 -0
- package/src/components/page-backdrop/page-backdrop.css +7 -0
- package/src/components/project-configuration/DeleteProjectConfirmationDialog.tsx +134 -0
- package/src/components/project-configuration/ProjectConfigurationDialog.tsx +972 -0
- package/src/components/project-configuration/ProjectDataForm.tsx +121 -0
- package/src/components/project-configuration/UnpublishProjectConfirmationDialog.tsx +162 -0
- package/src/components/project-configuration/project-configuration-content.css +209 -0
- package/src/components/project-name/ProjectName.tsx +2025 -0
- package/src/components/project-name/project-name.css +599 -0
- package/src/components/publishing/Publication.tsx +133 -0
- package/src/components/publishing/history/PublicationHistoryContent.tsx +414 -0
- package/src/components/publishing/history/PublicationHistoryDialog.tsx +234 -0
- package/src/components/publishing/preview/PublicationPreviewDialog.tsx +1158 -0
- package/src/components/publishing/preview/PublishingPriceForecast.tsx +160 -0
- package/src/components/publishing/preview/PublishingResourcesDetails.tsx +91 -0
- package/src/components/publishing/publication-sequence/PublishingSequenceContent.tsx +375 -0
- package/src/components/publishing/publication-sequence/PublishingSequenceDialog.tsx +344 -0
- package/src/components/publishing/publishing-dialog.css +142 -0
- package/src/components/publishing/utils.ts +227 -0
- package/src/components/resources/ResourcesDialog.tsx +591 -0
- package/src/components/resources/UpgradeBanner.tsx +102 -0
- package/src/components/resources/codebase/CodebaseDetails.tsx +156 -0
- package/src/components/resources/cron-job/CronJobsList.tsx +532 -0
- package/src/components/resources/functions/FunctionsList.tsx +454 -0
- package/src/components/resources/http-api/HttpAPI.tsx +566 -0
- package/src/components/resources/http-api/HttpAPIClientModule.tsx +37 -0
- package/src/components/resources/logs/LogsViewer.tsx +768 -0
- package/src/components/resources/query.ts +74 -0
- package/src/components/resources/relational-database/DatabaseTable.tsx +905 -0
- package/src/components/resources/relational-database/RelationalDatabase.tsx +83 -0
- package/src/components/resources/relational-database/RelationalDatabaseSecrets.tsx +361 -0
- package/src/components/resources/resources-dialog.css +74 -0
- package/src/components/test-relational-database/DatabaseTable.tsx +913 -0
- package/src/components/test-relational-database/TestDatabaseDialogContent.tsx +670 -0
- package/src/components/test-relational-database/query.ts +74 -0
- package/src/components/toolbar/ToolBar.tsx +236 -0
- package/src/components/toolbar/toolbar.css +78 -0
- package/src/components/transaction-history/TransactionHistoryDialog.tsx +268 -0
- package/src/components/user/CurrentUserAvatar.tsx +65 -0
- package/src/components/user/UserChip.tsx +62 -0
- package/src/components/user/user.css +39 -0
- package/src/components/user-profile/ChangePasswordForm.tsx +67 -0
- package/src/components/user-profile/OwnUserProfileContent.tsx +665 -0
- package/src/components/user-profile/PublicUserProfileContent.tsx +99 -0
- package/src/components/user-profile/UserDataForm.tsx +75 -0
- package/src/components/user-profile/UserProfileDialog.tsx +110 -0
- package/src/components/user-profile/user-profile-content.css +25 -0
- package/src/config.ts +130 -0
- package/src/globals.d.ts +13 -0
- package/src/index.html +27 -0
- package/src/index.tsx +23 -0
- package/src/lib/badge/Badge.tsx +35 -0
- package/src/lib/badge/badge.css +32 -0
- package/src/lib/button/Button.tsx +129 -0
- package/src/lib/button/button.css +145 -0
- package/src/lib/canvas/canvas-undo-redo.ts +263 -0
- package/src/lib/canvas/defs.ts +170 -0
- package/src/lib/canvas/index.test.ts +189 -0
- package/src/lib/canvas/index.ts +6999 -0
- package/src/lib/canvas/utils.ts +59 -0
- package/src/lib/card/Card.tsx +62 -0
- package/src/lib/card/LoadingCard.tsx +82 -0
- package/src/lib/card/card.css +259 -0
- package/src/lib/chip/Chip.tsx +79 -0
- package/src/lib/chip/chip.css +0 -0
- package/src/lib/dialog/Dialog.tsx +122 -0
- package/src/lib/dialog/SmallDialog.tsx +61 -0
- package/src/lib/dialog/dialog.css +40 -0
- package/src/lib/display-data-structure/index.tsx +21 -0
- package/src/lib/dropdown/CanvasDropdownMenuCard.tsx +68 -0
- package/src/lib/dropdown/CanvasDropdownMenuCardOption.tsx +136 -0
- package/src/lib/dropdown/DropdownButton.tsx +104 -0
- package/src/lib/dropdown/DropdownMenuCard.tsx +324 -0
- package/src/lib/dropdown/DropdownMenuPopup.tsx +27 -0
- package/src/lib/dropdown/dropdown-button.css +76 -0
- package/src/lib/dropdown/dropdown-menu.css +151 -0
- package/src/lib/json-editor/RawJsonEditor.tsx +137 -0
- package/src/lib/json-editor/json-editor.css +35 -0
- package/src/lib/loader/Loader.tsx +120 -0
- package/src/lib/loader/loader.css +38 -0
- package/src/lib/pagination/Pagination.tsx +64 -0
- package/src/lib/popup/CanvasPopupBaseComponent.tsx +103 -0
- package/src/lib/popup/Popup.tsx +243 -0
- package/src/lib/popup/popup.css +16 -0
- package/src/lib/table/RowForm.tsx +301 -0
- package/src/lib/table/Table.tsx +1069 -0
- package/src/lib/table/table.css +249 -0
- package/src/lib/table/types.ts +108 -0
- package/src/lib/text-area/TextArea.tsx +183 -0
- package/src/lib/text-area/text-area.css +156 -0
- package/src/lib/text-field/TextField.tsx +218 -0
- package/src/lib/text-field/index.ts +8 -0
- package/src/lib/text-field/text-field.css +201 -0
- package/src/lib/tooltip/Tooltip.tsx +24 -0
- package/src/lib/tooltip/tooltip.css +17 -0
- package/src/localization/index.ts +47 -0
- package/src/main.css +343 -0
- package/src/pages/Auth.tsx +848 -0
- package/src/pages/Editor.tsx +883 -0
- package/src/pages/ErrorPage.tsx +179 -0
- package/src/pages/Gallery.tsx +1693 -0
- package/src/pages/NewPaymentMethodCallback.tsx +53 -0
- package/src/pages/NotFoundPage.tsx +126 -0
- package/src/pages/PricingPlans.tsx +155 -0
- package/src/pages/auth.css +304 -0
- package/src/pages/gallery.css +421 -0
- package/src/payments/index.ts +187 -0
- package/src/popup-notification/index.ts +90 -0
- package/src/services/database/index.ts +1 -0
- package/src/services/database/utils.ts +1301 -0
- package/src/services/editor/CanvasElement.tsx +2934 -0
- package/src/services/editor/CanvasElementConnectionDeleteButton.ts +204 -0
- package/src/services/editor/CanvasPopup.tsx +749 -0
- package/src/services/editor/EditorService.ts +8157 -0
- package/src/services/editor/area.ts +1312 -0
- package/src/services/editor/connections.ts +1019 -0
- package/src/services/editor/create/condition.ts +25 -0
- package/src/services/editor/create/definition-entity.ts +29 -0
- package/src/services/editor/create/function-call.ts +25 -0
- package/src/services/editor/create/global-event.ts +33 -0
- package/src/services/editor/create/loop.ts +25 -0
- package/src/services/editor/create/operation.ts +30 -0
- package/src/services/editor/create/utils.ts +140 -0
- package/src/services/editor/create/variable-declaration.ts +135 -0
- package/src/services/editor/create/variable-instance.ts +100 -0
- package/src/services/editor/editor-ui-extensions-context.ts +43 -0
- package/src/services/editor/entities-metadata.json +9310 -0
- package/src/services/editor/icons.ts +1093 -0
- package/src/services/editor/index.ts +1 -0
- package/src/services/editor/layout.ts +102 -0
- package/src/services/editor/modules/built-in-function-implementations/base.ts +14 -0
- package/src/services/editor/modules/built-in-function-implementations/create-persisted-entity/index.ts +56 -0
- package/src/services/editor/modules/built-in-function-implementations/delete-persisted-entity/index.ts +55 -0
- package/src/services/editor/modules/built-in-function-implementations/index.ts +4 -0
- package/src/services/editor/modules/built-in-function-implementations/update-persisted-entity/index.ts +56 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/get-files.ts +183 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/list-drives.ts +124 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/list-root-folders.ts +125 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/smart-fetch-document.ts +702 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/upload-document.ts +535 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-gemini/generate-content.ts +193 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-mail/get-emails.ts +586 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-mail/send-email.ts +386 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/index.ts +12 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/channels.ts +240 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/messages.ts +210 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/replies.ts +200 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/send-message.ts +177 -0
- package/src/services/editor/modules/operations-implementations/index.ts +1 -0
- package/src/services/editor/modules/search-node-implementation/index.ts +42 -0
- package/src/services/editor/modules/sql-migrations-generation.tsx +1054 -0
- package/src/services/editor/publication/publication.ts +578 -0
- package/src/services/editor/ui.ts +1348 -0
- package/src/services/editor/utils.ts +5868 -0
- package/src/services/editor/value-store.ts +619 -0
- package/src/services/execution/built-in-function-implementations.ts +422 -0
- package/src/services/execution/index.ts +4747 -0
- package/src/services/execution/logic.ts +121 -0
- package/src/services/execution/test-instance.tsx +2296 -0
- package/src/services/execution/utils.ts +33 -0
- package/src/services/execution/value-resolution.test.ts +424 -0
- package/src/services/execution/value-resolution.ts +4087 -0
- package/src/services/integrations/ExternalIntegrationsService.ts +439 -0
- package/src/services/integrations/api.ts +175 -0
- package/src/services/local-relational-database/idb_helper.ts +66 -0
- package/src/services/local-relational-database/index.ts +3308 -0
- package/src/services/local-relational-database/utils.ts +403 -0
- package/src/services/notifications/index.ts +525 -0
- package/src/services/user/index.ts +144 -0
- package/src/setupTests.ts +1 -0
- package/src/socket/socket.ts +248 -0
- package/src/socket/utils.ts +10 -0
- package/src/store/workspace.ts +12 -0
- package/src/theme.ts +19 -0
- package/src/utils/DOM.ts +39 -0
- package/src/utils/date.ts +169 -0
- package/src/utils/index.ts +158 -0
- package/src/utils/react.tsx +679 -0
- package/src/utils/testing.ts +103 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ILiteralValue,
|
|
3
|
+
ILiteralValueTransfer,
|
|
4
|
+
DataTypeState,
|
|
5
|
+
EntityWithValueState,
|
|
6
|
+
InputMapState,
|
|
7
|
+
ProjectState,
|
|
8
|
+
LiteralValueState,
|
|
9
|
+
createStateFromType,
|
|
10
|
+
Reference,
|
|
11
|
+
EntityId,
|
|
12
|
+
} from '@elyx-code/project-logic-tree';
|
|
13
|
+
import { getLiteralValueNameFromDataType } from '../execution/utils';
|
|
14
|
+
import { hydrateOrDiscardLiteralValue } from '../execution/value-resolution';
|
|
15
|
+
import { Logger } from '@elyx-code/common-ts-utils';
|
|
16
|
+
|
|
17
|
+
export enum DynamicValueTypes {
|
|
18
|
+
// --- Input values ---
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
This value is inherited from another variable that has this value resolved or hardcoded
|
|
22
|
+
If there are no breaks in the chain, we can deduce what the value will be in other entities, which we call "inheritance chain"
|
|
23
|
+
*/
|
|
24
|
+
Inherited = 'inherited',
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
This is the value that the entity takes by default when it is instanciated, if no other value is provided
|
|
28
|
+
*/
|
|
29
|
+
DefaultValue = 'default-value',
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
A empty value that is deemed required for the code to work:
|
|
33
|
+
- Could be an entry point external value when a test is being run, in which case the user needs to provide it
|
|
34
|
+
- Could be a value that is the first in the inheritance chain to be required and has inherited no value
|
|
35
|
+
*/
|
|
36
|
+
Missing = 'missing',
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
This is a value that should be provided by the user, but has not been provided yet
|
|
40
|
+
It is different from 'missing' because it is not required for the code to work, so it can be left as is,
|
|
41
|
+
different from 'empty' because it is not explicitly empty, but it is just not provided yet
|
|
42
|
+
*/
|
|
43
|
+
Undefined = 'undefined',
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
A value that is empty, but it is not required for the code to work so it can be left empty
|
|
47
|
+
Equivalent to 'null' in JavaScript,
|
|
48
|
+
Explicitly empty rather than the value not being provided, which is the case of 'undefined',
|
|
49
|
+
Also means that the data-type of the value needs to support 'null'
|
|
50
|
+
*/
|
|
51
|
+
Empty = 'empty',
|
|
52
|
+
|
|
53
|
+
// --- Output values ---
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
This is usually a value resulting from an operation,
|
|
57
|
+
simple operations that require no server-side logic, special permissions, or a lot of compute power
|
|
58
|
+
can be executed in the browser and shown to the user to help them debug their logic in the moment
|
|
59
|
+
*/
|
|
60
|
+
AutoCalculated = 'auto-calculated',
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
Some values are too complex to be calculated in the browser,
|
|
64
|
+
they require server-side logic, special permissions, or a lot of compute power
|
|
65
|
+
So we indicate that this values will be calculated when the logic runs, so we can do validation without having the actual value
|
|
66
|
+
*/
|
|
67
|
+
QueuedAutocalculation = 'queued-autocalculation',
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
This is a value that will be passed at runtime, when the project is deployed and running
|
|
71
|
+
For example, the data to an endpoint in an API call
|
|
72
|
+
They are often used as the arguments of function declarations or events, since when they are used they are passed values
|
|
73
|
+
But when tested in isolation, we need to provide them because they are external to the declaration
|
|
74
|
+
*/
|
|
75
|
+
External = 'external',
|
|
76
|
+
|
|
77
|
+
// --- Testing values ---
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
This is a value used only to test the logic of the project,
|
|
81
|
+
it is not used in production, they are ignored during deployment
|
|
82
|
+
*/
|
|
83
|
+
Testing = 'testing',
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
These are values that are returned from a test,
|
|
87
|
+
at the end of the execution of an operation or function,
|
|
88
|
+
they are efimeral, so we lose them after the execution of a test is done
|
|
89
|
+
*/
|
|
90
|
+
ExecutionResult = 'execution-result',
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface IValueInheritanceLink {
|
|
94
|
+
sources: IDynamicValue[];
|
|
95
|
+
target: EntityWithValueState;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface IDynamicValue {
|
|
99
|
+
value: LiteralValueState | null;
|
|
100
|
+
valueOwner: EntityWithValueState;
|
|
101
|
+
type: DynamicValueTypes;
|
|
102
|
+
inheritanceLink: IValueInheritanceLink | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface IValueStoreRecord {
|
|
106
|
+
// Value owner entity id (not by literal value id)
|
|
107
|
+
[key: EntityId]: LiteralValueState;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface IValueStoreClient {
|
|
111
|
+
initialized: boolean;
|
|
112
|
+
id: string;
|
|
113
|
+
project: ProjectState;
|
|
114
|
+
values: IValueStoreRecord;
|
|
115
|
+
onWriteCallback: (owner: EntityWithValueState, value: ILiteralValue) => void;
|
|
116
|
+
onRemoveCallback: (owner: EntityWithValueState) => void;
|
|
117
|
+
onWrite(
|
|
118
|
+
callback: (owner: EntityWithValueState, value: ILiteralValue) => void
|
|
119
|
+
): void;
|
|
120
|
+
onRemove(callback: (owner: EntityWithValueState) => void): void;
|
|
121
|
+
init(): void;
|
|
122
|
+
toJSON(): {
|
|
123
|
+
[key: string]: ILiteralValueTransfer;
|
|
124
|
+
};
|
|
125
|
+
writeValue(owner: EntityWithValueState, value: LiteralValueState): void;
|
|
126
|
+
readValue(ownerId: string): LiteralValueState | null;
|
|
127
|
+
removeValue(ownerId: string): void;
|
|
128
|
+
clear(): void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const PLACEHOLDER_VALUE_STORE_CLIENT: IValueStoreClient = {
|
|
132
|
+
initialized: false,
|
|
133
|
+
id: '',
|
|
134
|
+
project: null as unknown as ProjectState,
|
|
135
|
+
values: {},
|
|
136
|
+
onWriteCallback: () => {},
|
|
137
|
+
onRemoveCallback: () => {},
|
|
138
|
+
onWrite: () => {},
|
|
139
|
+
onRemove: () => {},
|
|
140
|
+
init: () => {},
|
|
141
|
+
toJSON: () => ({}),
|
|
142
|
+
writeValue: () => {},
|
|
143
|
+
readValue: () => null,
|
|
144
|
+
removeValue: () => {},
|
|
145
|
+
clear: () => {},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export function generatePlaceholderValueStore(
|
|
149
|
+
id: string,
|
|
150
|
+
project: ProjectState
|
|
151
|
+
): IValueStoreClient {
|
|
152
|
+
return {
|
|
153
|
+
...PLACEHOLDER_VALUE_STORE_CLIENT,
|
|
154
|
+
id,
|
|
155
|
+
project,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export class EfimeralValueStore implements IValueStoreClient {
|
|
160
|
+
initialized = false;
|
|
161
|
+
id: string;
|
|
162
|
+
project: ProjectState;
|
|
163
|
+
values: IValueStoreRecord = {};
|
|
164
|
+
|
|
165
|
+
onWriteCallback: (owner: EntityWithValueState, value: ILiteralValue) => void =
|
|
166
|
+
() => {};
|
|
167
|
+
onRemoveCallback: (owner: EntityWithValueState) => void = () => {};
|
|
168
|
+
|
|
169
|
+
constructor(id: string, project: ProjectState) {
|
|
170
|
+
this.id = id;
|
|
171
|
+
this.project = project;
|
|
172
|
+
this.init();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Set a callback to be called when a value is written
|
|
176
|
+
onWrite(
|
|
177
|
+
callback: (owner: EntityWithValueState, value: ILiteralValue) => void
|
|
178
|
+
) {
|
|
179
|
+
this.onWriteCallback = callback;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onRemove(callback: (owner: EntityWithValueState) => void) {
|
|
183
|
+
this.onRemoveCallback = callback;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Pre-load values from local storage based on project id
|
|
187
|
+
init() {
|
|
188
|
+
if (!this.project.id || this.initialized) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const parsedValues: {
|
|
193
|
+
[key: EntityId]: ILiteralValueTransfer;
|
|
194
|
+
} = {};
|
|
195
|
+
|
|
196
|
+
const instanciatedValue: {
|
|
197
|
+
// Value owner entity id
|
|
198
|
+
[key: string]: LiteralValueState;
|
|
199
|
+
} = {};
|
|
200
|
+
|
|
201
|
+
// Turn each object value into a 'LiteralValueState' class instance
|
|
202
|
+
Object.keys(parsedValues).forEach((key) => {
|
|
203
|
+
const value: ILiteralValueTransfer = parsedValues[key];
|
|
204
|
+
const newInstance = new LiteralValueState(value, this.project);
|
|
205
|
+
|
|
206
|
+
try {
|
|
207
|
+
if (value.parent) {
|
|
208
|
+
// Find and set parents
|
|
209
|
+
const parentInstance =
|
|
210
|
+
this.project.findSubscribedInstanceFromReference(
|
|
211
|
+
value.parent as Reference
|
|
212
|
+
) as DataTypeState | InputMapState;
|
|
213
|
+
|
|
214
|
+
if (!parentInstance) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
newInstance.setParent(parentInstance, null);
|
|
219
|
+
newInstance.hydrateAncestors();
|
|
220
|
+
newInstance.initChildren(null);
|
|
221
|
+
} else if (value.standaloneParent) {
|
|
222
|
+
const parentInstance =
|
|
223
|
+
this.project.findSubscribedInstanceFromReference(
|
|
224
|
+
value.standaloneParent as Reference
|
|
225
|
+
) as EntityWithValueState;
|
|
226
|
+
|
|
227
|
+
if (!parentInstance) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
newInstance.standalone = true;
|
|
232
|
+
newInstance.setStandaloneParent(parentInstance, null);
|
|
233
|
+
newInstance.hydrateAncestors();
|
|
234
|
+
newInstance.initChildren(null);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
instanciatedValue[key] = newInstance;
|
|
238
|
+
|
|
239
|
+
const parent = (newInstance.parent ||
|
|
240
|
+
newInstance.standaloneParent) as EntityWithValueState;
|
|
241
|
+
|
|
242
|
+
// Hydrate or discard the value
|
|
243
|
+
const result = hydrateOrDiscardLiteralValue(
|
|
244
|
+
newInstance,
|
|
245
|
+
parent,
|
|
246
|
+
this.project
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
if (result) {
|
|
250
|
+
instanciatedValue[key] = result;
|
|
251
|
+
} else {
|
|
252
|
+
// Remove the value from local storage
|
|
253
|
+
delete parsedValues[key];
|
|
254
|
+
}
|
|
255
|
+
} catch (e) {
|
|
256
|
+
Logger.error('Error hydrating ancestors: ', e);
|
|
257
|
+
// Remove the value from local storage
|
|
258
|
+
delete parsedValues[key];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
this.values = {
|
|
263
|
+
...this.values,
|
|
264
|
+
...instanciatedValue,
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
this.initialized = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
toJSON(): {
|
|
271
|
+
[key: string]: ILiteralValueTransfer;
|
|
272
|
+
} {
|
|
273
|
+
// Loop over each value and apply the '.toJSON()' method
|
|
274
|
+
const values: {
|
|
275
|
+
[key: string]: ILiteralValueTransfer;
|
|
276
|
+
} = {};
|
|
277
|
+
|
|
278
|
+
Object.keys(this.values).forEach((key) => {
|
|
279
|
+
values[key] = this.values[key].toJSON() as ILiteralValueTransfer;
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
return values;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
writeValue(owner: EntityWithValueState, value: LiteralValueState) {
|
|
286
|
+
if (!owner) {
|
|
287
|
+
throw new Error(
|
|
288
|
+
`The value owner entity is required when writing a value to a value store`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// find existing instace or create new ones
|
|
293
|
+
const existingInstance = this.values[owner.id];
|
|
294
|
+
|
|
295
|
+
let instance = existingInstance;
|
|
296
|
+
|
|
297
|
+
if (!instance) {
|
|
298
|
+
if (value instanceof LiteralValueState) {
|
|
299
|
+
instance = value;
|
|
300
|
+
} else if (!!value) {
|
|
301
|
+
instance = createStateFromType(
|
|
302
|
+
value,
|
|
303
|
+
this.project
|
|
304
|
+
) as LiteralValueState;
|
|
305
|
+
} else {
|
|
306
|
+
// Create new literal value transfer and instance from the owner data type
|
|
307
|
+
// And set the value to null
|
|
308
|
+
const newLiteralValueTransfer: ILiteralValueTransfer =
|
|
309
|
+
LiteralValueState.new(null);
|
|
310
|
+
newLiteralValueTransfer.standaloneParent = (
|
|
311
|
+
owner as EntityWithValueState
|
|
312
|
+
).toReference();
|
|
313
|
+
newLiteralValueTransfer.name = getLiteralValueNameFromDataType(
|
|
314
|
+
owner.getDataType(null)
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
instance = createStateFromType(
|
|
318
|
+
newLiteralValueTransfer,
|
|
319
|
+
this.project
|
|
320
|
+
) as LiteralValueState;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
instance.standalone = true;
|
|
325
|
+
|
|
326
|
+
if (!instance.initialData.standaloneParent) {
|
|
327
|
+
Logger.warn('instance.initialData: ', instance.initialData);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
instance.setStandaloneParent(owner as EntityWithValueState, null);
|
|
331
|
+
instance.hydrateAncestors();
|
|
332
|
+
instance.initChildren(null);
|
|
333
|
+
|
|
334
|
+
if (!!value) {
|
|
335
|
+
instance.metaSync(
|
|
336
|
+
{
|
|
337
|
+
...value,
|
|
338
|
+
},
|
|
339
|
+
null
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
instance.setValueAsType(value.valueAsType, null);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
this.values[owner.id] = instance;
|
|
346
|
+
|
|
347
|
+
this.onWriteCallback(owner as EntityWithValueState, instance);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
readValue(ownerId: string): LiteralValueState | null {
|
|
351
|
+
return this.values[ownerId] || null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
removeValue(ownerId: string) {
|
|
355
|
+
if (!this.values[ownerId]) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
delete this.values[ownerId];
|
|
360
|
+
|
|
361
|
+
const owner = this.project.get(ownerId) as EntityWithValueState;
|
|
362
|
+
|
|
363
|
+
if (!!owner) {
|
|
364
|
+
this.onRemoveCallback(owner);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Clear all values
|
|
369
|
+
clear() {
|
|
370
|
+
this.values = {};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export class LocalBrowserValueStore implements IValueStoreClient {
|
|
375
|
+
initialized = false;
|
|
376
|
+
id: string;
|
|
377
|
+
project: ProjectState;
|
|
378
|
+
values: IValueStoreRecord = {};
|
|
379
|
+
|
|
380
|
+
onWriteCallback: (owner: EntityWithValueState, value: ILiteralValue) => void =
|
|
381
|
+
() => {};
|
|
382
|
+
onRemoveCallback: (owner: EntityWithValueState) => void = () => {};
|
|
383
|
+
|
|
384
|
+
constructor(id: string, project: ProjectState) {
|
|
385
|
+
this.id = id;
|
|
386
|
+
this.project = project;
|
|
387
|
+
this.init();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Set a callback to be called when a value is written
|
|
391
|
+
onWrite(
|
|
392
|
+
callback: (owner: EntityWithValueState, value: ILiteralValue) => void
|
|
393
|
+
) {
|
|
394
|
+
this.onWriteCallback = callback;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
onRemove(callback: (owner: EntityWithValueState) => void) {
|
|
398
|
+
this.onRemoveCallback = callback;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Pre-load values from local storage based on project id
|
|
402
|
+
init() {
|
|
403
|
+
if (!this.project.id || this.initialized) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const values = localStorage.getItem(this.id);
|
|
408
|
+
|
|
409
|
+
if (!values) {
|
|
410
|
+
// Initialize with empty object
|
|
411
|
+
localStorage.setItem(this.id, JSON.stringify(this.values));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const parsedValues = JSON.parse(values || '{}');
|
|
415
|
+
|
|
416
|
+
const instanciatedValue: {
|
|
417
|
+
// Value owner entity id
|
|
418
|
+
[key: string]: LiteralValueState;
|
|
419
|
+
} = {};
|
|
420
|
+
|
|
421
|
+
// Turn each object value into a 'LiteralValueState' class instance
|
|
422
|
+
Object.keys(parsedValues).forEach((key) => {
|
|
423
|
+
const value: ILiteralValueTransfer = parsedValues[key];
|
|
424
|
+
const newInstance = new LiteralValueState(value, this.project);
|
|
425
|
+
|
|
426
|
+
try {
|
|
427
|
+
if (value.parent) {
|
|
428
|
+
// Find and set parents
|
|
429
|
+
const parentInstance =
|
|
430
|
+
this.project.findSubscribedInstanceFromReference(
|
|
431
|
+
value.parent as Reference
|
|
432
|
+
) as DataTypeState | InputMapState;
|
|
433
|
+
|
|
434
|
+
if (!parentInstance) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
newInstance.setParent(parentInstance, null);
|
|
439
|
+
newInstance.hydrateAncestors();
|
|
440
|
+
newInstance.initChildren(null);
|
|
441
|
+
} else if (value.standaloneParent) {
|
|
442
|
+
const parentInstance =
|
|
443
|
+
this.project.findSubscribedInstanceFromReference(
|
|
444
|
+
value.standaloneParent as Reference
|
|
445
|
+
) as EntityWithValueState;
|
|
446
|
+
|
|
447
|
+
if (!parentInstance) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
newInstance.standalone = true;
|
|
452
|
+
newInstance.setStandaloneParent(parentInstance, null);
|
|
453
|
+
newInstance.hydrateAncestors();
|
|
454
|
+
newInstance.initChildren(null);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
instanciatedValue[key] = newInstance;
|
|
458
|
+
|
|
459
|
+
const parent = (newInstance.parent ||
|
|
460
|
+
newInstance.standaloneParent) as EntityWithValueState;
|
|
461
|
+
|
|
462
|
+
// Hydrate or discard the value
|
|
463
|
+
const result = hydrateOrDiscardLiteralValue(
|
|
464
|
+
newInstance,
|
|
465
|
+
parent,
|
|
466
|
+
this.project
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
if (result) {
|
|
470
|
+
instanciatedValue[key] = result;
|
|
471
|
+
} else {
|
|
472
|
+
// Remove the value from local storage
|
|
473
|
+
delete parsedValues[key];
|
|
474
|
+
}
|
|
475
|
+
} catch (e) {
|
|
476
|
+
Logger.error('Error hydrating ancestors: ', e);
|
|
477
|
+
// Remove the value from local storage
|
|
478
|
+
delete parsedValues[key];
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
this.values = {
|
|
483
|
+
...this.values,
|
|
484
|
+
...instanciatedValue,
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
this.initialized = true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
toJSON(): {
|
|
491
|
+
[key: string]: ILiteralValueTransfer;
|
|
492
|
+
} {
|
|
493
|
+
// Loop over each value and apply the '.toJSON()' method
|
|
494
|
+
const values: {
|
|
495
|
+
[key: string]: ILiteralValueTransfer;
|
|
496
|
+
} = {};
|
|
497
|
+
|
|
498
|
+
Object.keys(this.values).forEach((key) => {
|
|
499
|
+
values[key] = this.values[key].toJSON() as ILiteralValueTransfer;
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
return values;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
writeValue(owner: EntityWithValueState, value: LiteralValueState) {
|
|
506
|
+
if (!owner) {
|
|
507
|
+
throw new Error(
|
|
508
|
+
`The value owner entity is required when writing a value to a value store`
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// find existing instace or create new ones
|
|
513
|
+
const existingInstance = this.values[owner.id];
|
|
514
|
+
|
|
515
|
+
let instance = existingInstance;
|
|
516
|
+
|
|
517
|
+
if (!instance) {
|
|
518
|
+
if (value instanceof LiteralValueState) {
|
|
519
|
+
instance = value;
|
|
520
|
+
} else if (!!value) {
|
|
521
|
+
instance = createStateFromType(
|
|
522
|
+
value,
|
|
523
|
+
this.project
|
|
524
|
+
) as LiteralValueState;
|
|
525
|
+
} else {
|
|
526
|
+
// Create new literal value transfer and instance from the owner data type
|
|
527
|
+
// And set the value to null
|
|
528
|
+
const newLiteralValueTransfer: ILiteralValueTransfer =
|
|
529
|
+
LiteralValueState.new(null);
|
|
530
|
+
newLiteralValueTransfer.standaloneParent = (
|
|
531
|
+
owner as EntityWithValueState
|
|
532
|
+
).toReference();
|
|
533
|
+
newLiteralValueTransfer.name = getLiteralValueNameFromDataType(
|
|
534
|
+
owner.getDataType(null)
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
instance = createStateFromType(
|
|
538
|
+
newLiteralValueTransfer,
|
|
539
|
+
this.project
|
|
540
|
+
) as LiteralValueState;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
instance.standalone = true;
|
|
545
|
+
|
|
546
|
+
if (!instance.initialData.standaloneParent) {
|
|
547
|
+
Logger.warn('instance.initialData: ', instance.initialData);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
instance.setStandaloneParent(owner as EntityWithValueState, null);
|
|
551
|
+
instance.hydrateAncestors();
|
|
552
|
+
instance.initChildren(null);
|
|
553
|
+
|
|
554
|
+
if (!!value) {
|
|
555
|
+
instance.metaSync(
|
|
556
|
+
{
|
|
557
|
+
...value,
|
|
558
|
+
},
|
|
559
|
+
null
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
instance.setValueAsType(value.valueAsType, null);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
this.values[owner.id] = instance;
|
|
566
|
+
|
|
567
|
+
const json = this.toJSON();
|
|
568
|
+
|
|
569
|
+
const stringifiedValue = JSON.stringify(json);
|
|
570
|
+
|
|
571
|
+
try {
|
|
572
|
+
// Save to local storage
|
|
573
|
+
localStorage.setItem(this.id, stringifiedValue);
|
|
574
|
+
} catch (e) {
|
|
575
|
+
// Sometimes memory can be full
|
|
576
|
+
Logger.error('Error saving to local storage: ', e);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
this.onWriteCallback(owner as EntityWithValueState, instance);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
readValue(ownerId: string): LiteralValueState | null {
|
|
583
|
+
return this.values[ownerId] || null;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
removeValue(ownerId: string) {
|
|
587
|
+
if (!this.values[ownerId]) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
delete this.values[ownerId];
|
|
592
|
+
|
|
593
|
+
const stringifiedValue = JSON.stringify(this.toJSON());
|
|
594
|
+
|
|
595
|
+
// Save to local storage
|
|
596
|
+
localStorage.setItem(this.id, stringifiedValue);
|
|
597
|
+
|
|
598
|
+
const owner = this.project.get(ownerId) as EntityWithValueState;
|
|
599
|
+
|
|
600
|
+
if (!!owner) {
|
|
601
|
+
this.onRemoveCallback(owner);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Clear all values
|
|
606
|
+
clear() {
|
|
607
|
+
this.values = {};
|
|
608
|
+
localStorage.removeItem(this.id);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
teardown() {
|
|
612
|
+
this.values = {};
|
|
613
|
+
this.initialized = false;
|
|
614
|
+
|
|
615
|
+
// Remove all callbacks
|
|
616
|
+
this.onWriteCallback = () => {};
|
|
617
|
+
this.onRemoveCallback = () => {};
|
|
618
|
+
}
|
|
619
|
+
}
|