xmlui 0.7.21 → 0.7.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{apiInterceptorWorker-LRHkKnha.mjs → apiInterceptorWorker-BZ3Gd4mb.mjs} +25 -10
- package/dist/{grammar.tmLanguage-DNepe_jP.mjs → grammar.tmLanguage-JAlHWPqw.mjs} +1 -1
- package/dist/{index-5NLXyjX0.mjs → index-C9zkAour.mjs} +27520 -25814
- package/dist/index.css +1 -1
- package/dist/scripts/bin/build-lib.js +10 -4
- package/dist/scripts/bin/build.js +1 -4
- package/dist/scripts/bin/index.js +7 -7
- package/dist/scripts/bin/preview.js +19 -2
- package/dist/scripts/bin/start.js +2 -4
- package/dist/scripts/bin/viteConfig.js +2 -11
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -1
- package/dist/scripts/src/components/APICall/APICall.js +3 -3
- package/dist/scripts/src/components/APICall/APICallNative.js +2 -2
- package/dist/scripts/src/components/Accordion/Accordion.js +5 -5
- package/dist/scripts/src/components/Accordion/AccordionContext.js +1 -1
- package/dist/scripts/src/components/Accordion/AccordionItem.js +5 -5
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +3 -3
- package/dist/scripts/src/components/Accordion/AccordionNative.js +3 -3
- package/dist/scripts/src/components/Alert/Alert.js +4 -4
- package/dist/scripts/src/components/App/App.js +5 -5
- package/dist/scripts/src/components/App/AppNative.js +33 -34
- package/dist/scripts/src/components/App/Sheet.js +4 -4
- package/dist/scripts/src/components/AppHeader/AppHeader.js +6 -6
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +9 -9
- package/dist/scripts/src/components/AppState/AppState.js +2 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +2 -2
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +7 -7
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +29 -31
- package/dist/scripts/src/components/Avatar/Avatar.js +4 -4
- package/dist/scripts/src/components/Avatar/AvatarNative.js +1 -1
- package/dist/scripts/src/components/Backdrop/Backdrop.js +4 -4
- package/dist/scripts/src/components/Badge/Badge.js +5 -5
- package/dist/scripts/src/components/Badge/BadgeNative.js +5 -5
- package/dist/scripts/src/components/Bookmark/Bookmark.js +7 -3
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +6 -5
- package/dist/scripts/src/components/Breakout/Breakout.js +2 -2
- package/dist/scripts/src/components/Button/Button.js +6 -6
- package/dist/scripts/src/components/Button/ButtonNative.js +3 -3
- package/dist/scripts/src/components/ButtonGroup/ButtonGroup.js +5 -5
- package/dist/scripts/src/components/Card/Card.js +5 -5
- package/dist/scripts/src/components/Card/CardNative.js +7 -7
- package/dist/scripts/src/components/Carousel/Carousel.js +5 -5
- package/dist/scripts/src/components/Carousel/CarouselItem.js +3 -3
- package/dist/scripts/src/components/Carousel/CarouselItemNative.js +3 -3
- package/dist/scripts/src/components/Carousel/CarouselNative.js +6 -6
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +3 -3
- package/dist/scripts/src/components/ChangeListener/ChangeListenerNative.js +1 -1
- package/dist/scripts/src/components/Checkbox/Checkbox.js +6 -6
- package/dist/scripts/src/components/ColorPicker/ColorPicker.js +46 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +54 -0
- package/dist/scripts/src/components/Column/Column.js +2 -2
- package/dist/scripts/src/components/Column/ColumnNative.js +2 -2
- package/dist/scripts/src/components/ComponentProvider.js +191 -97
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +4 -4
- package/dist/scripts/src/components/ContentSeparator/ContentSeparatorNative.js +1 -1
- package/dist/scripts/src/components/DatePicker/DatePicker.js +4 -4
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +18 -19
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +6 -6
- package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +5 -5
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +4 -4
- package/dist/scripts/src/components/EmojiSelector/EmojiSelectorNative.js +1 -1
- package/dist/scripts/src/components/FileInput/FileInput.js +6 -6
- package/dist/scripts/src/components/FileInput/FileInputNative.js +6 -6
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +3 -3
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +6 -7
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +8 -6
- package/dist/scripts/src/components/FlowLayout/FlowLayoutNative.js +27 -16
- package/dist/scripts/src/components/Footer/Footer.js +4 -4
- package/dist/scripts/src/components/Footer/FooterNative.js +2 -2
- package/dist/scripts/src/components/Form/Form.js +5 -5
- package/dist/scripts/src/components/Form/FormNative.js +29 -29
- package/dist/scripts/src/components/FormItem/FormItem.js +4 -4
- package/dist/scripts/src/components/FormItem/FormItemNative.js +26 -16
- package/dist/scripts/src/components/FormItem/HelperText.js +3 -3
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +5 -6
- package/dist/scripts/src/components/FormItem/Validations.js +5 -5
- package/dist/scripts/src/components/FormSection/FormSection.js +2 -2
- package/dist/scripts/src/components/Heading/Heading.js +17 -4
- package/dist/scripts/src/components/Heading/HeadingNative.js +25 -14
- package/dist/scripts/src/components/HoverCard/HoverCard.js +3 -3
- package/dist/scripts/src/components/HoverCard/HovercardNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1208 -19
- package/dist/scripts/src/components/Icon/Icon.js +3 -3
- package/dist/scripts/src/components/Icon/IconNative.js +3 -3
- package/dist/scripts/src/components/IconInfoCard/IconInfoCard.js +5 -4
- package/dist/scripts/src/components/IconProvider.js +49 -49
- package/dist/scripts/src/components/Image/Image.js +4 -4
- package/dist/scripts/src/components/Image/ImageNative.js +2 -2
- package/dist/scripts/src/components/Input/InputAdornment.js +3 -3
- package/dist/scripts/src/components/Items/Items.js +3 -3
- package/dist/scripts/src/components/Link/Link.js +6 -6
- package/dist/scripts/src/components/Link/LinkNative.js +29 -11
- package/dist/scripts/src/components/List/List.js +14 -16
- package/dist/scripts/src/components/List/ListNative.js +193 -223
- package/dist/scripts/src/components/Logo/Logo.js +2 -2
- package/dist/scripts/src/components/Logo/LogoNative.js +2 -2
- package/dist/scripts/src/components/Markdown/Markdown.js +3 -3
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +5 -5
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +8 -8
- package/dist/scripts/src/components/NavGroup/NavGroup.js +6 -6
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +8 -8
- package/dist/scripts/src/components/NavLink/NavLink.js +5 -5
- package/dist/scripts/src/components/NavLink/NavLinkNative.js +6 -6
- package/dist/scripts/src/components/NavPanel/NavPanel.js +5 -5
- package/dist/scripts/src/components/NavPanel/NavPanelNative.js +6 -6
- package/dist/scripts/src/components/NoResult/NoResult.js +4 -4
- package/dist/scripts/src/components/NoResult/NoResultNative.js +2 -2
- package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -4
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +7 -7
- package/dist/scripts/src/components/OffCanvas/OffCanvas.js +5 -5
- package/dist/scripts/src/components/OffCanvas/OffCanvasNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +4 -4
- package/dist/scripts/src/components/PageHeader/PageHeader.js +2 -2
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +2 -2
- package/dist/scripts/src/components/Pages/Pages.js +3 -3
- package/dist/scripts/src/components/Pages/PagesNative.js +2 -2
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +3 -3
- package/dist/scripts/src/components/PositionedContainer/PositionedContainerNative.js +1 -1
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +3 -3
- package/dist/scripts/src/components/ProgressBar/ProgressBarNative.js +1 -1
- package/dist/scripts/src/components/Queue/Queue.js +3 -3
- package/dist/scripts/src/components/Queue/QueueNative.js +5 -5
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -4
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +6 -6
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +2 -2
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +3 -3
- package/dist/scripts/src/components/Redirect/Redirect.js +2 -2
- package/dist/scripts/src/components/Select/Select.js +7 -7
- package/dist/scripts/src/components/Select/SelectNative.js +36 -37
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +2 -2
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +2 -2
- package/dist/scripts/src/components/Slider/Slider.js +40 -25
- package/dist/scripts/src/components/Slider/SliderNative.js +98 -3
- package/dist/scripts/src/components/SlotItem.js +2 -2
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +3 -3
- package/dist/scripts/src/components/Spinner/Spinner.js +3 -3
- package/dist/scripts/src/components/Spinner/SpinnerNative.js +3 -4
- package/dist/scripts/src/components/Splitter/Splitter.js +6 -6
- package/dist/scripts/src/components/Splitter/SplitterNative.js +3 -3
- package/dist/scripts/src/components/Stack/Stack.js +6 -6
- package/dist/scripts/src/components/Stack/StackNative.js +3 -3
- package/dist/scripts/src/components/StickyBox/StickyBox.js +3 -3
- package/dist/scripts/src/components/StickyBox/StickyBoxNative.js +1 -1
- package/dist/scripts/src/components/Switch/Switch.js +6 -6
- package/dist/scripts/src/components/Table/Table.js +9 -9
- package/dist/scripts/src/components/Table/TableNative.js +15 -15
- package/dist/scripts/src/components/Table/useRowSelection.js +4 -4
- package/dist/scripts/src/components/TableHeader/TableHeader.js +2 -2
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +7 -5
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +29 -24
- package/dist/scripts/src/components/Tabs/TabContext.js +1 -1
- package/dist/scripts/src/components/Tabs/TabItem.js +3 -3
- package/dist/scripts/src/components/Tabs/TabItemNative.js +2 -2
- package/dist/scripts/src/components/Tabs/Tabs.js +5 -5
- package/dist/scripts/src/components/Tabs/TabsNative.js +2 -2
- package/dist/scripts/src/components/Text/Text.js +5 -4
- package/dist/scripts/src/components/Text/TextNative.js +6 -7
- package/dist/scripts/src/components/TextArea/TextArea.js +4 -4
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +6 -6
- package/dist/scripts/src/components/TextBox/TextBox.js +4 -4
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +5 -5
- package/dist/scripts/src/components/Theme/Theme.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +7 -7
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +11 -11
- package/dist/scripts/src/components/ThemeChanger/ToneChangerButton.js +5 -5
- package/dist/scripts/src/components/Toggle/Toggle.js +4 -4
- package/dist/scripts/src/components/Toolbar/Toolbar.js +2 -2
- package/dist/scripts/src/components/ToolbarButton/ToolbarButton.js +2 -2
- package/dist/scripts/src/components/Tree/TreeComponent.js +4 -4
- package/dist/scripts/src/components/Tree/TreeNative.js +2 -2
- package/dist/scripts/src/components/TrendLabel/TrendLabel.js +2 -2
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +8 -8
- package/dist/scripts/src/components/abstractions.js +6 -2
- package/dist/scripts/src/components/container-helpers.js +2 -2
- package/dist/scripts/src/components-core/CompoundComponent.js +2 -2
- package/dist/scripts/src/components-core/Fragment.js +2 -2
- package/dist/scripts/src/components-core/InspectorContext.js +5 -5
- package/dist/scripts/src/components-core/LoaderComponent.js +6 -3
- package/dist/scripts/src/components-core/RestApiProxy.js +4 -4
- package/dist/scripts/src/components-core/Slot.js +2 -2
- package/dist/scripts/src/components-core/TableOfContentsContext.js +12 -2
- package/dist/scripts/src/components-core/XmluiCodeHighlighter.js +2 -2
- package/dist/scripts/src/components-core/action/APICall.js +10 -10
- package/dist/scripts/src/components-core/action/FileDownloadAction.js +1 -1
- package/dist/scripts/src/components-core/action/FileUploadAction.js +3 -3
- package/dist/scripts/src/components-core/action/NavigateAction.js +1 -1
- package/dist/scripts/src/components-core/action/TimedAction.js +1 -1
- package/dist/scripts/src/components-core/component-hooks.js +2 -2
- package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +5 -5
- package/dist/scripts/src/components-core/loader/DataLoader.js +18 -10
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +5 -5
- package/dist/scripts/src/components-core/loader/Loader.js +3 -3
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +5 -5
- package/dist/scripts/src/components-core/loader/PageableLoader.js +7 -4
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +21 -15
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +2 -2
- package/dist/scripts/src/components-core/rendering/Container.js +16 -16
- package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +1 -1
- package/dist/scripts/src/components-core/rendering/InvalidComponent.js +1 -1
- package/dist/scripts/src/components-core/rendering/StateContainer.js +15 -15
- package/dist/scripts/src/components-core/rendering/reducer.js +1 -1
- package/dist/scripts/src/components-core/rendering/renderChild.js +1 -1
- package/dist/scripts/src/components-core/rendering/valueExtractor.js +4 -4
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +1 -1
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +2 -2
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +1 -1
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +3 -3
- package/dist/scripts/src/components-core/script-runner/syncProxy.js +1 -1
- package/dist/scripts/src/components-core/script-runner/visitors.js +1 -1
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +10 -10
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +1 -1
- package/dist/scripts/src/components-core/theming/layout-resolver.js +356 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +1 -1
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +9 -3
- package/dist/scripts/src/components-core/utils/actionUtils.js +3 -3
- package/dist/scripts/src/components-core/utils/compound-utils.js +1 -1
- package/dist/scripts/src/components-core/utils/css-utils.js +2 -2
- package/dist/scripts/src/components-core/utils/extractParam.js +47 -3
- package/dist/scripts/src/components-core/utils/hooks.js +3 -3
- package/dist/scripts/src/parsers/scripting/modules.js +1 -1
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +6 -2
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +14 -15
- package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
- package/dist/scripts/src/syntax/textMate/xmlui.json +27 -93
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +5438 -4508
- package/dist/xmlui-metadata.umd.js +23 -18
- package/dist/xmlui-standalone.umd.js +204 -193
- package/dist/xmlui.d.ts +3 -2
- package/dist/xmlui.mjs +1 -1
- package/package.json +3 -3
- package/dist/scripts/package.json +0 -210
- package/dist/scripts/src/components/Chart/Chart.js +0 -24
- package/dist/scripts/src/components/Chart/ChartNative.js +0 -165
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +0 -116
- package/dist/scripts/src/components/ModalDialog/Dialog.js +0 -20
- package/dist/scripts/src/components/Range/Range.js +0 -56
- package/dist/scripts/src/components/Range/RangeNative.js +0 -8
- package/dist/scripts/src/components/RawHtml/RawHtml.js +0 -39
- package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +0 -13
- package/dist/scripts/src/components-core/StandaloneApp.js +0 -589
- package/dist/scripts/src/components-core/abstractions/standalone.js +0 -2
- package/dist/scripts/src/components-core/appContext/date-functions.js +0 -19
- package/dist/scripts/src/components-core/appContext/math-function.js +0 -27
- package/dist/scripts/src/components-core/appContext/misc-utils.js +0 -13
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +0 -198
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +0 -94
- package/dist/scripts/src/components-core/interception/Backend.js +0 -129
- package/dist/scripts/src/components-core/interception/Errors.js +0 -129
- package/dist/scripts/src/components-core/interception/InMemoryDb.js +0 -41
- package/dist/scripts/src/components-core/interception/IndexedDb.js +0 -205
- package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +0 -145
- package/dist/scripts/src/components-core/interception/abstractions.js +0 -2
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +0 -46
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +0 -9
- package/dist/scripts/src/components-core/markup-check.js +0 -279
- package/dist/scripts/src/components-core/rendering/AppContent.js +0 -339
- package/dist/scripts/src/components-core/rendering/AppRoot.js +0 -55
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +0 -44
- package/dist/scripts/src/components-core/utils/classnames.js +0 -58
- package/dist/scripts/src/components-core/utils/date-utils.js +0 -78
- package/dist/scripts/src/components-core/utils/request-params.js +0 -70
- package/dist/scripts/src/index.js +0 -66
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ApiInterceptor = exports.AuthService = void 0;
|
|
13
|
-
const msw_1 = require("msw");
|
|
14
|
-
const lodash_es_1 = require("lodash-es");
|
|
15
|
-
const Backend_1 = require("@components-core/interception/Backend");
|
|
16
|
-
const IndexedDb_1 = require("@components-core/interception/IndexedDb");
|
|
17
|
-
const request_params_1 = require("@components-core/utils/request-params");
|
|
18
|
-
const Errors_1 = require("@components-core/interception/Errors");
|
|
19
|
-
const EngineError_1 = require("@components-core/EngineError");
|
|
20
|
-
const InMemoryDb_1 = require("@components-core/interception/InMemoryDb");
|
|
21
|
-
function mergeHeaders(...sources) {
|
|
22
|
-
const result = {};
|
|
23
|
-
for (const source of sources) {
|
|
24
|
-
if (!(0, lodash_es_1.isObject)(source)) {
|
|
25
|
-
throw new TypeError("All arguments must be of type object");
|
|
26
|
-
}
|
|
27
|
-
const headers = new Headers(source);
|
|
28
|
-
for (const [key, value] of headers.entries()) {
|
|
29
|
-
if (value === undefined || value === "undefined") {
|
|
30
|
-
delete result[key];
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
result[key] = value;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return new Headers(result);
|
|
38
|
-
}
|
|
39
|
-
// Represents the authentication service used within an API interceptor
|
|
40
|
-
class AuthService {
|
|
41
|
-
constructor(auth) {
|
|
42
|
-
const cachedLoggedInUser = JSON.parse(sessionStorage.getItem("session-logged-in-user"));
|
|
43
|
-
this.loggedInUser = cachedLoggedInUser || (auth === null || auth === void 0 ? void 0 : auth.defaultLoggedInUser);
|
|
44
|
-
}
|
|
45
|
-
login(newLoggedInUser) {
|
|
46
|
-
this.loggedInUser = newLoggedInUser;
|
|
47
|
-
sessionStorage.setItem("session-logged-in-user", JSON.stringify(newLoggedInUser));
|
|
48
|
-
}
|
|
49
|
-
logout() {
|
|
50
|
-
this.loggedInUser = null;
|
|
51
|
-
sessionStorage.removeItem("session-logged-in-user");
|
|
52
|
-
}
|
|
53
|
-
getCookieToken() {
|
|
54
|
-
return sessionStorage.getItem("session-anonymous-token");
|
|
55
|
-
}
|
|
56
|
-
setCookieToken(token) {
|
|
57
|
-
sessionStorage.setItem("session-anonymous-token", token);
|
|
58
|
-
}
|
|
59
|
-
getLoggedInUser() {
|
|
60
|
-
return this.loggedInUser;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.AuthService = AuthService;
|
|
64
|
-
function initDb(apiDef) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
switch (apiDef.type) {
|
|
68
|
-
case "in-memory":
|
|
69
|
-
return new InMemoryDb_1.InMemoryDb((_a = apiDef.schemaDescriptor) === null || _a === void 0 ? void 0 : _a.tables, apiDef.initialData, apiDef.config);
|
|
70
|
-
default:
|
|
71
|
-
const indexedDb = new IndexedDb_1.IndexedDb((_b = apiDef.schemaDescriptor) === null || _b === void 0 ? void 0 : _b.tables, apiDef.initialData, apiDef.config);
|
|
72
|
-
yield indexedDb.initialize();
|
|
73
|
-
return indexedDb;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// An API interceptor implementation
|
|
78
|
-
class ApiInterceptor {
|
|
79
|
-
constructor(apiDef) {
|
|
80
|
-
this.apiDef = apiDef;
|
|
81
|
-
this.backend = null;
|
|
82
|
-
}
|
|
83
|
-
initialize() {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
// --- Transfer the handlers of API operations to the backend implementation
|
|
86
|
-
const backendOperations = {};
|
|
87
|
-
Object.entries(this.apiDef.operations || {}).forEach(([key, value]) => {
|
|
88
|
-
backendOperations[key] = value.handler;
|
|
89
|
-
});
|
|
90
|
-
const db = yield initDb(this.apiDef);
|
|
91
|
-
const authService = new AuthService(this.apiDef.auth);
|
|
92
|
-
const definition = {
|
|
93
|
-
operations: backendOperations,
|
|
94
|
-
initialize: this.apiDef.initialize,
|
|
95
|
-
helpers: this.apiDef.helpers,
|
|
96
|
-
};
|
|
97
|
-
this.backend = new Backend_1.Backend(definition, db, authService);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
getOperations() {
|
|
101
|
-
return this.apiDef.operations || {};
|
|
102
|
-
}
|
|
103
|
-
getApiUrl() {
|
|
104
|
-
return this.apiDef.apiUrl || "";
|
|
105
|
-
}
|
|
106
|
-
// Use the "msw" package to execute the interceptor operation
|
|
107
|
-
executeOperation(operationId, req, cookies, params) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
var _a, _b;
|
|
110
|
-
if (this.backend === null) {
|
|
111
|
-
throw new Error("Interceptor not initialized");
|
|
112
|
-
}
|
|
113
|
-
const operation = (_a = this.apiDef.operations) === null || _a === void 0 ? void 0 : _a[operationId];
|
|
114
|
-
if (!operation) {
|
|
115
|
-
throw new Error(`Unknown API interceptor operation: ${operationId}`);
|
|
116
|
-
}
|
|
117
|
-
let reqBody;
|
|
118
|
-
try {
|
|
119
|
-
if (operation.requestShape === "formData") {
|
|
120
|
-
const formData = yield req.formData();
|
|
121
|
-
const obj = {};
|
|
122
|
-
for (const key of formData.keys()) {
|
|
123
|
-
const all = formData.getAll(key);
|
|
124
|
-
if (all.length === 1) {
|
|
125
|
-
obj[key] = all[0];
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
obj[key] = all;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
reqBody = obj;
|
|
132
|
-
}
|
|
133
|
-
else if (operation.requestShape === "blob") {
|
|
134
|
-
reqBody = yield req.blob();
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
reqBody = yield req.json();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (e) { }
|
|
141
|
-
// --- Map path parameters
|
|
142
|
-
const mappedParams = this.convertRequestParams({
|
|
143
|
-
pathParams: params,
|
|
144
|
-
queryParams: Object.fromEntries(new URL(req.url).searchParams),
|
|
145
|
-
requestBody: reqBody,
|
|
146
|
-
cookies: cookies,
|
|
147
|
-
requestHeaders: Object.fromEntries(req.headers.entries()) || {},
|
|
148
|
-
}, operation);
|
|
149
|
-
//artificial delay for http requests
|
|
150
|
-
yield (0, msw_1.delay)();
|
|
151
|
-
const cookieService = new Backend_1.CookieService();
|
|
152
|
-
const headerService = new Backend_1.HeaderService();
|
|
153
|
-
try {
|
|
154
|
-
const ret = yield this.backend.executeOperation(operationId, mappedParams, cookieService, headerService);
|
|
155
|
-
const emptyBody = ret === undefined || ret === null;
|
|
156
|
-
const successStatusCode = (_b = operation.successStatusCode) !== null && _b !== void 0 ? _b : (emptyBody ? Errors_1.HttpStatusCode.NoContent : Errors_1.HttpStatusCode.Ok);
|
|
157
|
-
const headers = mergeHeaders(cookieService.getCookieHeader(), headerService.getHeaders());
|
|
158
|
-
if (ret instanceof File) {
|
|
159
|
-
headers.append("Content-type", ret.type);
|
|
160
|
-
headers.append("Content-Length", ret.size + "");
|
|
161
|
-
headers.append("Content-Disposition", `attachment; filename="${ret.name}"; filename*=utf-8''${ret.name}`);
|
|
162
|
-
return msw_1.HttpResponse.arrayBuffer(yield ret.arrayBuffer(), {
|
|
163
|
-
headers: headers,
|
|
164
|
-
status: successStatusCode,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
if (emptyBody) {
|
|
168
|
-
return new msw_1.HttpResponse(null, {
|
|
169
|
-
headers: headers,
|
|
170
|
-
status: successStatusCode,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return msw_1.HttpResponse.json(ret, {
|
|
174
|
-
headers: headers,
|
|
175
|
-
status: successStatusCode,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
catch (e) {
|
|
179
|
-
console.error(e);
|
|
180
|
-
if (e instanceof EngineError_1.ThrowStatementError && e.errorObject instanceof Errors_1.HttpError) {
|
|
181
|
-
return msw_1.HttpResponse.json(e.errorObject.details, {
|
|
182
|
-
headers: cookieService.getCookieHeader(),
|
|
183
|
-
status: e.errorObject.status,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return msw_1.HttpResponse.json({ message: e === null || e === void 0 ? void 0 : e.message }, {
|
|
187
|
-
headers: cookieService.getCookieHeader(),
|
|
188
|
-
status: Errors_1.HttpStatusCode.InternalServerError,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
// Ensures that type path and query params are converted according to the operation definition
|
|
194
|
-
convertRequestParams(params, operation) {
|
|
195
|
-
return Object.assign(Object.assign({}, params), { pathParams: (0, request_params_1.convertRequestParamPart)(params.pathParams, operation.pathParamTypes), queryParams: (0, request_params_1.convertRequestParamPart)(params.queryParams, operation.queryParamTypes) });
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.ApiInterceptor = ApiInterceptor;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.ApiInterceptorProvider = ApiInterceptorProvider;
|
|
46
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
47
|
-
const react_1 = require("react");
|
|
48
|
-
const useApiInterceptorContext_1 = require("./useApiInterceptorContext");
|
|
49
|
-
const misc_1 = require("@components-core/utils/misc");
|
|
50
|
-
// This React component injects the API interceptor into the application's context
|
|
51
|
-
function ApiInterceptorProvider({ interceptor, children, apiWorker, useHashBasedRouting, }) {
|
|
52
|
-
const [initialized, setInitialized] = (0, react_1.useState)(!interceptor);
|
|
53
|
-
// --- Whenever the interceptor changes, update the provider accordingly
|
|
54
|
-
(0, react_1.useEffect)(() => {
|
|
55
|
-
if (interceptor) {
|
|
56
|
-
setInitialized(false);
|
|
57
|
-
// --- We use "msw" to manage the API interception
|
|
58
|
-
let interceptorWorker;
|
|
59
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
// --- Create the worker on the fly
|
|
61
|
-
if (process.env.VITE_MOCK_ENABLED) {
|
|
62
|
-
const { createApiInterceptorWorker } = yield Promise.resolve().then(() => __importStar(require("./apiInterceptorWorker")));
|
|
63
|
-
if (interceptor) {
|
|
64
|
-
interceptorWorker = yield createApiInterceptorWorker(interceptor, apiWorker);
|
|
65
|
-
// if the apiWorker comes from the outside, we don't handle the lifecycle here
|
|
66
|
-
if (!apiWorker) {
|
|
67
|
-
const workerFileLocation = (0, misc_1.normalizePath)(process.env.VITE_MOCK_WORKER_LOCATION || "mockServiceWorker.js");
|
|
68
|
-
yield interceptorWorker.start({
|
|
69
|
-
onUnhandledRequest: "bypass",
|
|
70
|
-
quiet: true,
|
|
71
|
-
serviceWorker: {
|
|
72
|
-
url: workerFileLocation,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
setInitialized(true);
|
|
79
|
-
}))();
|
|
80
|
-
return () => {
|
|
81
|
-
// if the apiWorker comes from the outside, we don't handle the lifecycle here
|
|
82
|
-
if (!apiWorker) {
|
|
83
|
-
interceptorWorker === null || interceptorWorker === void 0 ? void 0 : interceptorWorker.stop();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}, [apiWorker, interceptor, useHashBasedRouting]);
|
|
88
|
-
const contextValue = (0, react_1.useMemo)(() => {
|
|
89
|
-
return {
|
|
90
|
-
isMocked: (url) => interceptor !== undefined && !!process.env.VITE_MOCK_ENABLED,
|
|
91
|
-
};
|
|
92
|
-
}, [interceptor]);
|
|
93
|
-
return ((0, jsx_runtime_1.jsx)(useApiInterceptorContext_1.ApiInterceptorContext.Provider, { value: contextValue, children: initialized ? children || null : null }));
|
|
94
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Backend = exports.HeaderService = exports.CookieService = exports.defaultBackendEnvironment = void 0;
|
|
16
|
-
const lodash_es_1 = require("lodash-es");
|
|
17
|
-
const misc_1 = require("@components-core/utils/misc");
|
|
18
|
-
const statementUtils_1 = require("@components-core/utils/statementUtils");
|
|
19
|
-
const Errors_1 = __importDefault(require("@components-core/interception/Errors"));
|
|
20
|
-
const date_functions_1 = require("@components-core/appContext/date-functions");
|
|
21
|
-
const misc_utils_1 = require("@components-core/appContext/misc-utils");
|
|
22
|
-
const date_utils_1 = require("@components-core/utils/date-utils");
|
|
23
|
-
// Use this backend environment as the default
|
|
24
|
-
exports.defaultBackendEnvironment = {
|
|
25
|
-
getDate: (date) => date ? new Date(date) : new Date(),
|
|
26
|
-
};
|
|
27
|
-
const mapValuesDeep = (obj, cb) => {
|
|
28
|
-
if ((0, lodash_es_1.isArray)(obj)) {
|
|
29
|
-
return obj.map((innerObj) => mapValuesDeep(innerObj, cb));
|
|
30
|
-
}
|
|
31
|
-
else if ((0, lodash_es_1.isObject)(obj)) {
|
|
32
|
-
return (0, lodash_es_1.mapValues)(obj, (val) => mapValuesDeep(val, cb));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return cb(obj);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
class CookieService {
|
|
39
|
-
constructor() {
|
|
40
|
-
this.cookies = {};
|
|
41
|
-
}
|
|
42
|
-
setCookie(key, value) {
|
|
43
|
-
this.cookies[key] = value;
|
|
44
|
-
}
|
|
45
|
-
getCookieHeader() {
|
|
46
|
-
const cookieArrays = [];
|
|
47
|
-
Object.entries(this.cookies).forEach(([key, value]) => {
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
value.forEach(val => cookieArrays.push(['Set-Cookie', `${key}=${val}`]));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
cookieArrays.push(['Set-Cookie', `${key}=${value}`]);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return new Headers(cookieArrays);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.CookieService = CookieService;
|
|
59
|
-
class HeaderService {
|
|
60
|
-
constructor() {
|
|
61
|
-
this.headers = {};
|
|
62
|
-
}
|
|
63
|
-
setHeader(key, value) {
|
|
64
|
-
this.headers[key] = value;
|
|
65
|
-
}
|
|
66
|
-
getHeaders() {
|
|
67
|
-
const headersArray = [];
|
|
68
|
-
Object.entries(this.headers).forEach(([key, value]) => {
|
|
69
|
-
headersArray.push([key, value]);
|
|
70
|
-
});
|
|
71
|
-
return new Headers(headersArray);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.HeaderService = HeaderService;
|
|
75
|
-
class Backend {
|
|
76
|
-
constructor(definition, db, authService) {
|
|
77
|
-
this.definition = definition;
|
|
78
|
-
this.db = db;
|
|
79
|
-
this.authService = authService;
|
|
80
|
-
this.apiStateHash = {};
|
|
81
|
-
this.resolvedHelpers = mapValuesDeep(definition.helpers, (helper) => {
|
|
82
|
-
if (typeof helper === "string") {
|
|
83
|
-
return (...params) => this.runFn(helper, ...params);
|
|
84
|
-
}
|
|
85
|
-
return helper;
|
|
86
|
-
});
|
|
87
|
-
if (definition.initialize) {
|
|
88
|
-
this.runFn(definition.initialize);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
executeOperation(operationId, requestParams, cookieService, headerService) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
var _a;
|
|
94
|
-
const handler = (_a = this.definition.operations) === null || _a === void 0 ? void 0 : _a[operationId];
|
|
95
|
-
if (!handler) {
|
|
96
|
-
throw new Error(`Unknown backend operation: ${operationId}`);
|
|
97
|
-
}
|
|
98
|
-
return yield this.runFn(handler, requestParams, cookieService, headerService);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
runFn(src, ...args) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
104
|
-
let localContext = Object.assign(Object.assign({}, this.resolvedHelpers), { "$db": this.db, "$state": this.apiStateHash, "$authService": this.authService, "$env": exports.defaultBackendEnvironment, "$loggedInUser": this.authService.getLoggedInUser(), "$pathParams": (_a = args[0]) === null || _a === void 0 ? void 0 : _a.pathParams, "$queryParams": (_b = args[0]) === null || _b === void 0 ? void 0 : _b.queryParams, "$requestBody": (_c = args[0]) === null || _c === void 0 ? void 0 : _c.requestBody, "$cookies": (_d = args[0]) === null || _d === void 0 ? void 0 : _d.cookies, "$requestHeaders": (_e = args[0]) === null || _e === void 0 ? void 0 : _e.requestHeaders, "$cookieService": args[1], "$headerService": args[2] //TODO really ugly, temporary solution
|
|
105
|
-
});
|
|
106
|
-
const evalContext = createEvalContext({
|
|
107
|
-
localContext: localContext,
|
|
108
|
-
eventArgs: args,
|
|
109
|
-
appContext: Object.assign(Object.assign(Object.assign({}, date_functions_1.dateFunctions), misc_utils_1.miscellaneousUtils), { delay: misc_1.delay,
|
|
110
|
-
Errors: Errors_1.default, createFile: (...args) => new File(args[0], args[1], args[2]), getDate: date_utils_1.getDate }),
|
|
111
|
-
});
|
|
112
|
-
yield (0, statementUtils_1.runEventHandlerCode)(src, evalContext);
|
|
113
|
-
return ((_g = (_f = evalContext.mainThread) === null || _f === void 0 ? void 0 : _f.blocks) === null || _g === void 0 ? void 0 : _g.length)
|
|
114
|
-
? evalContext.mainThread.blocks[evalContext.mainThread.blocks.length - 1].returnValue
|
|
115
|
-
: undefined;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.Backend = Backend;
|
|
120
|
-
function createEvalContext(parts) {
|
|
121
|
-
return Object.assign({
|
|
122
|
-
mainThread: {
|
|
123
|
-
childThreads: [],
|
|
124
|
-
blocks: [{ vars: {} }],
|
|
125
|
-
loops: [],
|
|
126
|
-
breakLabelValue: -1,
|
|
127
|
-
},
|
|
128
|
-
}, parts);
|
|
129
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConflictError = exports.UnauthorizedError = exports.NotFoundError = exports.HttpError = exports.HttpStatusCode = void 0;
|
|
4
|
-
//stolen from axios
|
|
5
|
-
var HttpStatusCode;
|
|
6
|
-
(function (HttpStatusCode) {
|
|
7
|
-
HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
|
|
8
|
-
HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
9
|
-
HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
|
|
10
|
-
HttpStatusCode[HttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
|
|
11
|
-
HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
|
|
12
|
-
HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
|
|
13
|
-
HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
|
|
14
|
-
HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
15
|
-
HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
|
|
16
|
-
HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
|
|
17
|
-
HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
|
|
18
|
-
HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
|
|
19
|
-
HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
20
|
-
HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
|
|
21
|
-
HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
22
|
-
HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
23
|
-
HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
|
|
24
|
-
HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
|
|
25
|
-
HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
|
|
26
|
-
HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
|
|
27
|
-
HttpStatusCode[HttpStatusCode["Unused"] = 306] = "Unused";
|
|
28
|
-
HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
29
|
-
HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
30
|
-
HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
|
|
31
|
-
HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
|
|
32
|
-
HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
33
|
-
HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
|
|
34
|
-
HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
|
|
35
|
-
HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
36
|
-
HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
37
|
-
HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
38
|
-
HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
39
|
-
HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
|
|
40
|
-
HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
|
|
41
|
-
HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
|
|
42
|
-
HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
43
|
-
HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
44
|
-
HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
|
|
45
|
-
HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
46
|
-
HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
47
|
-
HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
48
|
-
HttpStatusCode[HttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
|
|
49
|
-
HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
50
|
-
HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
51
|
-
HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
|
|
52
|
-
HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
|
|
53
|
-
HttpStatusCode[HttpStatusCode["TooEarly"] = 425] = "TooEarly";
|
|
54
|
-
HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
55
|
-
HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
56
|
-
HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
57
|
-
HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
58
|
-
HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
59
|
-
HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
|
|
60
|
-
HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
|
|
61
|
-
HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
|
|
62
|
-
HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
63
|
-
HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
64
|
-
HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
65
|
-
HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
66
|
-
HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
67
|
-
HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
68
|
-
HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
|
|
69
|
-
HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
70
|
-
})(HttpStatusCode || (exports.HttpStatusCode = HttpStatusCode = {}));
|
|
71
|
-
class HttpError extends Error {
|
|
72
|
-
constructor(status, details) {
|
|
73
|
-
super((details === null || details === void 0 ? void 0 : details.message) || "Not found");
|
|
74
|
-
this.details = details;
|
|
75
|
-
this.status = status;
|
|
76
|
-
Object.setPrototypeOf(this, HttpError.prototype);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.HttpError = HttpError;
|
|
80
|
-
class NotFoundError extends HttpError {
|
|
81
|
-
constructor(details) {
|
|
82
|
-
super(HttpStatusCode.NotFound, details);
|
|
83
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.NotFoundError = NotFoundError;
|
|
87
|
-
class UnauthorizedError extends HttpError {
|
|
88
|
-
constructor(details) {
|
|
89
|
-
super(HttpStatusCode.Unauthorized, details);
|
|
90
|
-
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.UnauthorizedError = UnauthorizedError;
|
|
94
|
-
class ConflictError extends HttpError {
|
|
95
|
-
constructor(details) {
|
|
96
|
-
super(HttpStatusCode.Conflict, details);
|
|
97
|
-
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.ConflictError = ConflictError;
|
|
101
|
-
function convertErrorDetails(messageOrDetails) {
|
|
102
|
-
let details;
|
|
103
|
-
if (messageOrDetails) {
|
|
104
|
-
if (typeof messageOrDetails === "string") {
|
|
105
|
-
details = {
|
|
106
|
-
message: messageOrDetails,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
details = messageOrDetails;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return details;
|
|
114
|
-
}
|
|
115
|
-
const Errors = {
|
|
116
|
-
NotFound404: (messageOrDetails) => {
|
|
117
|
-
return new NotFoundError(convertErrorDetails(messageOrDetails));
|
|
118
|
-
},
|
|
119
|
-
Unauthorized401: (messageOrDetails) => {
|
|
120
|
-
return new UnauthorizedError(convertErrorDetails(messageOrDetails));
|
|
121
|
-
},
|
|
122
|
-
HttpError: (errorCode, messageOrDetails) => {
|
|
123
|
-
return new HttpError(errorCode, convertErrorDetails(messageOrDetails));
|
|
124
|
-
},
|
|
125
|
-
Conflict409: (messageOrDetails) => {
|
|
126
|
-
return new ConflictError(convertErrorDetails(messageOrDetails));
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
exports.default = Errors;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.InMemoryDb = void 0;
|
|
13
|
-
class InMemoryDb {
|
|
14
|
-
constructor(tables, initialData = {}, config) {
|
|
15
|
-
this.tables = tables;
|
|
16
|
-
this.initialData = initialData;
|
|
17
|
-
this.config = config;
|
|
18
|
-
}
|
|
19
|
-
getItems(collectionName) {
|
|
20
|
-
throw new Error("Method not implemented.");
|
|
21
|
-
}
|
|
22
|
-
getItem(collectionName, predicate) {
|
|
23
|
-
throw new Error("Method not implemented.");
|
|
24
|
-
}
|
|
25
|
-
getItemById(collectionName, id) {
|
|
26
|
-
throw new Error("Method not implemented.");
|
|
27
|
-
}
|
|
28
|
-
deleteItems(collectionName, predicate) {
|
|
29
|
-
throw new Error("Method not implemented.");
|
|
30
|
-
}
|
|
31
|
-
insertItem(collectionName, item) {
|
|
32
|
-
throw new Error("Method not implemented.");
|
|
33
|
-
}
|
|
34
|
-
updateItem(collectionName, item) {
|
|
35
|
-
throw new Error("Method not implemented.");
|
|
36
|
-
}
|
|
37
|
-
initialize() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.InMemoryDb = InMemoryDb;
|