@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.2 → 1.2.0-alpha.21
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 +119 -0
- package/dist/mockServiceWorker.js +349 -0
- package/dist/openapi-k8s-toolkit.es.js +42693 -11594
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +43090 -11961
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/api/bff/search/getKinds.d.ts +1 -1
- package/dist/types/components/atoms/ContentCard/ContentCard.styled.d.ts +2 -0
- package/dist/types/components/molecules/BlackholeForm/atoms/HiddenContainer/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/molecules/FormListInput/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/molecules/FormRangeInput/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/molecules/FormStringMultilineInput/helpers.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/BlackholeForm.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/context.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/casts.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/getSortedPropertyKeys.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/hiddenExpanded.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/prefills.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeForm/utilsErrorHandler.test.d.ts +1 -0
- package/dist/types/components/molecules/BlackholeForm/organisms/BlackholeFormProvider/BlackholeFormProvider.test.d.ts +2 -0
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTable/EnrichedTable.d.ts +2 -1
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.d.ts +4 -2
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.test.d.ts +8 -0
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTableProvider/EnrichedTableProvider.d.ts +1 -0
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTableProvider/utils.d.ts +2 -1
- package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTableProvider/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/Events/molecules/EventRow/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/Events/reducer.test.d.ts +1 -0
- package/dist/types/components/molecules/Events/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/ManageableBreadcrumbs/organisms/ManageableBreadcrumbsProvider/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/ManageableSidebar/organisms/ManageableSidebarProvider/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/MarketPlace/molecules/MarketplaceCard/utils.test.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/NodeTerminal.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/XTerminal.d.ts +3 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/types.d.ts +7 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/types.d.ts +12 -0
- package/dist/types/components/molecules/Terminals/VMVNC/VMVNC.d.ts +9 -0
- package/dist/types/components/molecules/Terminals/VMVNC/hooks/useVNCClient.d.ts +29 -0
- package/dist/types/components/molecules/Terminals/VMVNC/hooks/useVNCClient.test.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/VMVNC/index.d.ts +2 -0
- package/dist/types/components/molecules/Terminals/VMVNC/molecules/VMVNCToolbar/VMVNCToolbar.d.ts +17 -0
- package/dist/types/components/molecules/Terminals/VMVNC/molecules/VMVNCToolbar/index.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/VMVNC/molecules/VMVNCToolbar/styled.d.ts +1364 -0
- package/dist/types/components/molecules/Terminals/VMVNC/molecules/index.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/VMVNC/styled.d.ts +834 -0
- package/dist/types/components/molecules/Terminals/index.d.ts +2 -0
- package/dist/types/components/molecules/index.d.ts +2 -2
- package/dist/types/components/organisms/DynamicComponents/molecules/Annotations/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ArrayOfObjectsToKeyValues/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ConverterBytes/ConverterBytes.d.ts +13 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/ConverterCores.d.ts +19 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/EnrichedTable/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/Events/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ItemCounter/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/KeyCounter/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/Labels/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/LabelsToSearchParams/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/OwnerRefs/guard.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/OwnerRefs/organsisms/RefsList/molecules/RefElement/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ParsedText/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PodLogs/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PodTerminal/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/PrometheusGraph.d.ts +6 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/atoms/WidthHeightDiv/WidthHeightDiv.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/atoms/WidthHeightDiv/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/atoms/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/helpers.d.ts +6 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/index.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/multi/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/multi/usePromMatrixToLineMulti.d.ts +8 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/multi/usePromMatrixToLineMulti.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/single/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/single/usePromMatrixToLineSingle.d.ts +8 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryRangeMatrix/single/usePromMatrixToLineSingle.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryScalar/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryScalar/usePromScalar.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryScalar/usePromScalar.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryVector/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryVector/usePromVector.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/queryVector/usePromVector.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/index.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaMulti/MatrixToAreaMulti.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaMulti/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaSingle/MatrixToAreaSingle.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaSingle/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaStacked/MatrixToAreaStacked.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToAreaStacked/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToLineMulti/MatrixToLineMulti.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToLineMulti/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToLineSingle/MatrixToLineSingle.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToLineSingle/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToReducedBar/MatrixToReducedBar.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToReducedBar/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToTableRows/MatrixToTableRows.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/MatrixToTableRows/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/matrix/index.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/scalar/ScalarToGauge/ScalarToGauge.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/scalar/ScalarToGauge/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/scalar/ScalarToStat/ScalarToStat.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/scalar/ScalarToStat/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/scalar/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarGauge/VectorToBarGauge.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarGauge/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarHorizontal/VectorToBarHorizontal.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarHorizontal/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarVertical/VectorToBarVertical.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToBarVertical/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToGaugeRadial/VectorToGaugeRadial.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToGaugeRadial/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToPie/VectorToPie.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToPie/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToTableRows/VectorToTableRows.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/VectorToTableRows/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/organisms/vector/index.d.ts +6 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/types/chartsProps.d.ts +48 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/types/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/types/responses.d.ts +27 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/buildPrometheusRangeParams/buildPrometheusRangeParams.d.ts +10 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/buildPrometheusRangeParams/buildPrometheusRangeParams.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/buildPrometheusRangeParams/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/formatters/formatBytes.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/formatters/formatTimestamp.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/formatters/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/index.d.ts +9 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/index.d.ts +8 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toAreaStacked/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toAreaStacked/matrixToAreaStackedAdapter.d.ts +14 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toAreaStacked/matrixToAreaStackedAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toLine/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toLine/matrixToLineAdapter.d.ts +12 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toLine/matrixToLineAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toReducedVector/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toReducedVector/matrixToReducedVectorAdapter.d.ts +8 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toReducedVector/matrixToReducedVectorAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toTableRows/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toTableRows/matrixToTableRowsAdapter.d.ts +12 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/matrixAdapter/toTableRows/matrixToTableRowsAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/index.d.ts +4 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toGauge/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toGauge/scalarToGaugeAdapter.d.ts +15 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toGauge/scalarToGaugeAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toStat/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toStat/scalarToStatAdapter.d.ts +11 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/scalarAdapter/toStat/scalarToStatAdapter.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/helpers/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/helpers/pickSeriesId.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/helpers/pickSeriesId.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/index.d.ts +10 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/prometheusVectorUtils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toBar/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toBar/vectorToBarAdapter.d.ts +18 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toBarGauge/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toBarGauge/vectorToBarGaugeAdapter.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toGaugeRadial/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toGaugeRadial/vectorToGaugeRadialAdapter.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toPie/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toPie/vectorToPieAdapter.d.ts +7 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toTableRows/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/vectorAdapter/toTableRows/vectorToTableRowsAdapter.d.ts +8 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/StatusText/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/Taints/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/Tolerations/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/VMVNC/VMVNC.d.ts +6 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/VMVNC/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/YamlEditorSingleton/utils.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/index.d.ts +3 -0
- package/dist/types/components/organisms/DynamicComponents/types.d.ts +57 -2
- package/dist/types/components/organisms/DynamicRenderer/DynamicRenderer.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/DynamicRendererWithProviders.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/factoryConfigProvider/factoryConfigProvider.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/factoryConfigProvider/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/{hybridDataProvider.d.ts → providers/hybridDataProvider/hybridDataProvider.d.ts} +1 -1
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/hybridDataProvider/hybridDataProvider.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/hybridDataProvider/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/multiK8sProvider/index.d.ts +2 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/{multiK8sProvider.d.ts → providers/multiK8sProvider/multiK8sProvider.d.ts} +1 -1
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/multiK8sProvider/multiK8sProvider.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/multiQueryProvider/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/multiQueryProvider/multiQueryProvider.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/partsOfUrlContext/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/partsOfUrlContext/partsOfUrlContext.test.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/themeContext/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicRendererWithProviders/providers/themeContext/themeContext.test.d.ts +1 -0
- package/dist/types/hooks/useApiResource.d.ts +1 -0
- package/dist/types/hooks/useBuiltinResource.d.ts +1 -0
- package/dist/types/hooks/useCrdResource.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResource.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResource.test.d.ts +2 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResourceWithoutKinds.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResourceWithoutKinds.test.d.ts +2 -0
- package/dist/types/hooks/useK8sSmartResource/useManyK8sSmartResource.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useManyK8sSmartResource.test.d.ts +2 -0
- package/dist/types/hooks/useK8sSmartResource/useSmartResourceParams.d.ts +5 -5
- package/dist/types/hooks/useK8sSmartResource/useSmartResourceParams.test.d.ts +2 -0
- package/dist/types/hooks/useKinds.d.ts +8 -0
- package/dist/types/hooks/useListThenWatch/reducer.test.d.ts +1 -0
- package/dist/types/hooks/useListThenWatch/useInfiniteSentinel.test.d.ts +2 -0
- package/dist/types/hooks/useListThenWatch/useListWatch.d.ts +1 -0
- package/dist/types/hooks/useListThenWatch/useListWatch.test.d.ts +2 -0
- package/dist/types/hooks/useListThenWatch/utils.test.d.ts +1 -0
- package/dist/types/hooks/useResourceScope/index.d.ts +1 -0
- package/dist/types/hooks/useResourceScope/useResourceScope.d.ts +12 -0
- package/dist/types/hooks/useResourceScope/useResourceScope.test.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/localTypes/bff/table.d.ts +2 -1
- package/dist/types/localTypes/factories/converterBytes.d.ts +10 -0
- package/dist/types/localTypes/factories/converterCores.d.ts +7 -0
- package/dist/types/localTypes/k8s.d.ts +1 -0
- package/dist/types/localTypes/navigations.d.ts +3 -0
- package/dist/types/localTypes/richTable.d.ts +4 -0
- package/dist/types/utils/converterBytes/converterBytes.d.ts +35 -0
- package/dist/types/utils/converterBytes/converterBytes.test.d.ts +1 -0
- package/dist/types/utils/converterBytes/index.d.ts +1 -0
- package/dist/types/utils/converterCores/converterCores.d.ts +45 -0
- package/dist/types/utils/converterCores/converterCores.test.d.ts +1 -0
- package/dist/types/utils/converterCores/index.d.ts +1 -0
- package/dist/types/utils/converterDates/converterDates.d.ts +33 -0
- package/dist/types/utils/converterDates/converterDates.test.d.ts +1 -0
- package/dist/types/utils/converterDates/index.d.ts +2 -0
- package/dist/types/utils/createContextFactory/createContextFactory.test.d.ts +2 -0
- package/dist/types/utils/deepMerge/deepMerge.test.d.ts +1 -0
- package/dist/types/utils/filterSelectOptions/filterSelectOptions.test.d.ts +1 -0
- package/dist/types/utils/getAllPathsFromObj/getAllPathsFromObj.test.d.ts +1 -0
- package/dist/types/utils/getGroupsByCategory/getGroupsByCategory.test.d.ts +2 -0
- package/dist/types/utils/getPrefixSubArrays/getPrefixSubArrays.test.d.ts +1 -0
- package/dist/types/utils/getResourceLink/getResourceLink.test.d.ts +1 -0
- package/dist/types/utils/getSortedKinds/getSortedKinds.test.d.ts +1 -0
- package/dist/types/utils/getSortedKindsAll/getSortedKindsAll.test.d.ts +1 -0
- package/dist/types/utils/getStringByName/getStringByName.test.d.ts +1 -0
- package/dist/types/utils/getUppercase/getUppercase.test.d.ts +1 -0
- package/dist/types/utils/groupsToTreeData/groupsToTreeData.test.d.ts +1 -0
- package/dist/types/utils/hslFromString/hslFromString.test.d.ts +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/isFlatObject/isFlatObject.test.d.ts +1 -0
- package/dist/types/utils/kindByGvr/kindByGvr.test.d.ts +1 -0
- package/dist/types/utils/namespacedByGvr/namespacedByGvr.test.d.ts +1 -0
- package/dist/types/utils/nestedStringsArrayInclude/nestedStringsArrayInclude.test.d.ts +1 -0
- package/dist/types/utils/normalizeValuesForQuotas/normalizeValuesForQuotas.test.d.ts +1 -0
- package/dist/types/utils/parseForQuotaValues/parseForQuotaValues.test.d.ts +1 -0
- package/dist/types/utils/pluralByKind/pluralByKind.test.d.ts +1 -0
- package/dist/types/utils/prepareUrlsToFetchForDynamicRenderer/prepareUrlsToFetchForDynamicRenderer.test.d.ts +1 -0
- package/dist/types/utils/tableLocations/tableLocations.test.d.ts +1 -0
- package/package.json +12 -2
- package/dist/types/components/organisms/DynamicComponents/molecules/ConverterBytes/types.d.ts +0 -10
- package/dist/types/components/organisms/DynamicComponents/molecules/ConverterBytes/utils.d.ts +0 -15
- /package/dist/types/components/organisms/DynamicRendererWithProviders/{factoryConfigProvider.d.ts → providers/factoryConfigProvider/factoryConfigProvider.d.ts} +0 -0
- /package/dist/types/components/organisms/DynamicRendererWithProviders/{multiQueryProvider.d.ts → providers/multiQueryProvider/multiQueryProvider.d.ts} +0 -0
- /package/dist/types/components/organisms/DynamicRendererWithProviders/{partsOfUrlContext.d.ts → providers/partsOfUrlContext/partsOfUrlContext.d.ts} +0 -0
- /package/dist/types/components/organisms/DynamicRendererWithProviders/{themeContext.d.ts → providers/themeContext/themeContext.d.ts} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
## 📘 openapi-k8s-toolkit
|
|
2
|
+
|
|
3
|
+
A modular, extensible UI toolkit for building Kubernetes-powered applications — without writing repetitive CRUD logic or UI boilerplate.
|
|
4
|
+
|
|
5
|
+
This toolkit provides:
|
|
6
|
+
|
|
7
|
+
- 🧩 **Composable UI blocks** (tables, terminals, log viewers, dashboards, cards)
|
|
8
|
+
- ⚙️ **Smart data providers** that fetch and normalize Kubernetes and OpenAPI-driven resources
|
|
9
|
+
- 📄 **Schema-based OpenAPI/Kubernetes forms** with validation, presets, and dynamic layouts
|
|
10
|
+
- 📡 **Real-time Websocket live data streaming** for Pods, Events, Logs, Terminals, etc.
|
|
11
|
+
- 🏗 **A powerful Factory Engine** that renders pages and components from declarative configuration (JSON/YAML)
|
|
12
|
+
- 🎨 **Customizable Storybook Docs** with live configuration playgrounds
|
|
13
|
+
|
|
14
|
+
Whether you're building a full Kubernetes console, a DevOps dashboard, a tenant-aware SaaS admin, or automation portal — this toolkit helps you build fast, stays extensible, and avoids reinventing the same patterns.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🚀 Key Concepts
|
|
19
|
+
|
|
20
|
+
### 🔧 1. Dynamic Component Factory
|
|
21
|
+
|
|
22
|
+
Instead of manually wiring dozens of components together, define **what** should render — not **how**.
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
type: EnrichedTable
|
|
26
|
+
data:
|
|
27
|
+
id: pods-table
|
|
28
|
+
cluster: dev
|
|
29
|
+
k8sResourceToFetch:
|
|
30
|
+
plural: pods
|
|
31
|
+
apiVersion: v1
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The factory resolves:
|
|
35
|
+
|
|
36
|
+
- Routing context (`cluster`, `namespace`, `resource`)
|
|
37
|
+
- Data fetching configuration
|
|
38
|
+
- Permissions
|
|
39
|
+
- UI layout behavior
|
|
40
|
+
|
|
41
|
+
…and renders the right component — fully wired.
|
|
42
|
+
|
|
43
|
+
Storybook includes live playgrounds for each factory type.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### 📡 2. Smart Data Hooks
|
|
48
|
+
|
|
49
|
+
The toolkit includes advanced hooks that abstract K8s + OpenAPI internals:
|
|
50
|
+
|
|
51
|
+
- `useK8sSmartResource`
|
|
52
|
+
- `useMultiQuery`
|
|
53
|
+
- live event streams
|
|
54
|
+
- generative OpenAPI form helpers
|
|
55
|
+
|
|
56
|
+
They handle:
|
|
57
|
+
|
|
58
|
+
- label/field selectors
|
|
59
|
+
- live logs and terminals
|
|
60
|
+
- resource normalization
|
|
61
|
+
- error states + retry logic
|
|
62
|
+
- batching and subscription reuse
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### 📑 3. Kubernetes Tables
|
|
67
|
+
|
|
68
|
+
Tables are:
|
|
69
|
+
|
|
70
|
+
- Cluster/WebSocket aware
|
|
71
|
+
- Automatically enriched using Kubernetes metadata
|
|
72
|
+
- Customizable (columns, sorting, grouping, row actions, links to forms, etc.)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 🧪 4. Forms Powered by OpenAPI + Kubernetes
|
|
77
|
+
|
|
78
|
+
Forms are auto-built from CRDs, OpenAPI schemas, and Kubernetes metadata — but still fully overrideable:
|
|
79
|
+
|
|
80
|
+
- custom fields
|
|
81
|
+
- computed fields
|
|
82
|
+
- presets & blueprints
|
|
83
|
+
- etc
|
|
84
|
+
|
|
85
|
+
Think _"Kubernetes + JSON Schema form generator on steroids."_ 💉💪
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 📚 5. Storybook Included
|
|
90
|
+
|
|
91
|
+
Every major module ships with a **docs-only Storybook entry** and an interactive control system to generate YAML/JSON config.
|
|
92
|
+
You can preview factories components if they are not tightly wired to backend
|
|
93
|
+
|
|
94
|
+
## 🛠 Installation & Usage
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install openapi-k8s-toolkit
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then import what you like
|
|
101
|
+
|
|
102
|
+
## ✨ Why this exists
|
|
103
|
+
|
|
104
|
+
Building Kubernetes-aware UIs repeatedly results in the same pain:
|
|
105
|
+
|
|
106
|
+
- API quirks
|
|
107
|
+
- forms from CRDs
|
|
108
|
+
- live resource tables
|
|
109
|
+
- labels/fields selectors
|
|
110
|
+
- permissions
|
|
111
|
+
- routing based on cluster/namespace/object
|
|
112
|
+
|
|
113
|
+
This toolkit abstracts those patterns into reusable building blocks so teams can focus on **intent and experience, not plumbing.**
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🤝 Contributing
|
|
118
|
+
|
|
119
|
+
[Check this out](./CONTRIBUTING.md)
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock Service Worker.
|
|
6
|
+
* @see https://github.com/mswjs/msw
|
|
7
|
+
* - Please do NOT modify this file.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const PACKAGE_VERSION = '2.12.4'
|
|
11
|
+
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
|
|
12
|
+
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
13
|
+
const activeClientIds = new Set()
|
|
14
|
+
|
|
15
|
+
addEventListener('install', function () {
|
|
16
|
+
self.skipWaiting()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
addEventListener('activate', function (event) {
|
|
20
|
+
event.waitUntil(self.clients.claim())
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
addEventListener('message', async function (event) {
|
|
24
|
+
const clientId = Reflect.get(event.source || {}, 'id')
|
|
25
|
+
|
|
26
|
+
if (!clientId || !self.clients) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const client = await self.clients.get(clientId)
|
|
31
|
+
|
|
32
|
+
if (!client) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const allClients = await self.clients.matchAll({
|
|
37
|
+
type: 'window',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
switch (event.data) {
|
|
41
|
+
case 'KEEPALIVE_REQUEST': {
|
|
42
|
+
sendToClient(client, {
|
|
43
|
+
type: 'KEEPALIVE_RESPONSE',
|
|
44
|
+
})
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'INTEGRITY_CHECK_REQUEST': {
|
|
49
|
+
sendToClient(client, {
|
|
50
|
+
type: 'INTEGRITY_CHECK_RESPONSE',
|
|
51
|
+
payload: {
|
|
52
|
+
packageVersion: PACKAGE_VERSION,
|
|
53
|
+
checksum: INTEGRITY_CHECKSUM,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case 'MOCK_ACTIVATE': {
|
|
60
|
+
activeClientIds.add(clientId)
|
|
61
|
+
|
|
62
|
+
sendToClient(client, {
|
|
63
|
+
type: 'MOCKING_ENABLED',
|
|
64
|
+
payload: {
|
|
65
|
+
client: {
|
|
66
|
+
id: client.id,
|
|
67
|
+
frameType: client.frameType,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
case 'CLIENT_CLOSED': {
|
|
75
|
+
activeClientIds.delete(clientId)
|
|
76
|
+
|
|
77
|
+
const remainingClients = allClients.filter((client) => {
|
|
78
|
+
return client.id !== clientId
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// Unregister itself when there are no more clients
|
|
82
|
+
if (remainingClients.length === 0) {
|
|
83
|
+
self.registration.unregister()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
break
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
addEventListener('fetch', function (event) {
|
|
92
|
+
const requestInterceptedAt = Date.now()
|
|
93
|
+
|
|
94
|
+
// Bypass navigation requests.
|
|
95
|
+
if (event.request.mode === 'navigate') {
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Opening the DevTools triggers the "only-if-cached" request
|
|
100
|
+
// that cannot be handled by the worker. Bypass such requests.
|
|
101
|
+
if (
|
|
102
|
+
event.request.cache === 'only-if-cached' &&
|
|
103
|
+
event.request.mode !== 'same-origin'
|
|
104
|
+
) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Bypass all requests when there are no active clients.
|
|
109
|
+
// Prevents the self-unregistered worked from handling requests
|
|
110
|
+
// after it's been terminated (still remains active until the next reload).
|
|
111
|
+
if (activeClientIds.size === 0) {
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const requestId = crypto.randomUUID()
|
|
116
|
+
event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @param {FetchEvent} event
|
|
121
|
+
* @param {string} requestId
|
|
122
|
+
* @param {number} requestInterceptedAt
|
|
123
|
+
*/
|
|
124
|
+
async function handleRequest(event, requestId, requestInterceptedAt) {
|
|
125
|
+
const client = await resolveMainClient(event)
|
|
126
|
+
const requestCloneForEvents = event.request.clone()
|
|
127
|
+
const response = await getResponse(
|
|
128
|
+
event,
|
|
129
|
+
client,
|
|
130
|
+
requestId,
|
|
131
|
+
requestInterceptedAt,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
// Send back the response clone for the "response:*" life-cycle events.
|
|
135
|
+
// Ensure MSW is active and ready to handle the message, otherwise
|
|
136
|
+
// this message will pend indefinitely.
|
|
137
|
+
if (client && activeClientIds.has(client.id)) {
|
|
138
|
+
const serializedRequest = await serializeRequest(requestCloneForEvents)
|
|
139
|
+
|
|
140
|
+
// Clone the response so both the client and the library could consume it.
|
|
141
|
+
const responseClone = response.clone()
|
|
142
|
+
|
|
143
|
+
sendToClient(
|
|
144
|
+
client,
|
|
145
|
+
{
|
|
146
|
+
type: 'RESPONSE',
|
|
147
|
+
payload: {
|
|
148
|
+
isMockedResponse: IS_MOCKED_RESPONSE in response,
|
|
149
|
+
request: {
|
|
150
|
+
id: requestId,
|
|
151
|
+
...serializedRequest,
|
|
152
|
+
},
|
|
153
|
+
response: {
|
|
154
|
+
type: responseClone.type,
|
|
155
|
+
status: responseClone.status,
|
|
156
|
+
statusText: responseClone.statusText,
|
|
157
|
+
headers: Object.fromEntries(responseClone.headers.entries()),
|
|
158
|
+
body: responseClone.body,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
responseClone.body ? [serializedRequest.body, responseClone.body] : [],
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return response
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Resolve the main client for the given event.
|
|
171
|
+
* Client that issues a request doesn't necessarily equal the client
|
|
172
|
+
* that registered the worker. It's with the latter the worker should
|
|
173
|
+
* communicate with during the response resolving phase.
|
|
174
|
+
* @param {FetchEvent} event
|
|
175
|
+
* @returns {Promise<Client | undefined>}
|
|
176
|
+
*/
|
|
177
|
+
async function resolveMainClient(event) {
|
|
178
|
+
const client = await self.clients.get(event.clientId)
|
|
179
|
+
|
|
180
|
+
if (activeClientIds.has(event.clientId)) {
|
|
181
|
+
return client
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (client?.frameType === 'top-level') {
|
|
185
|
+
return client
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const allClients = await self.clients.matchAll({
|
|
189
|
+
type: 'window',
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
return allClients
|
|
193
|
+
.filter((client) => {
|
|
194
|
+
// Get only those clients that are currently visible.
|
|
195
|
+
return client.visibilityState === 'visible'
|
|
196
|
+
})
|
|
197
|
+
.find((client) => {
|
|
198
|
+
// Find the client ID that's recorded in the
|
|
199
|
+
// set of clients that have registered the worker.
|
|
200
|
+
return activeClientIds.has(client.id)
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @param {FetchEvent} event
|
|
206
|
+
* @param {Client | undefined} client
|
|
207
|
+
* @param {string} requestId
|
|
208
|
+
* @param {number} requestInterceptedAt
|
|
209
|
+
* @returns {Promise<Response>}
|
|
210
|
+
*/
|
|
211
|
+
async function getResponse(event, client, requestId, requestInterceptedAt) {
|
|
212
|
+
// Clone the request because it might've been already used
|
|
213
|
+
// (i.e. its body has been read and sent to the client).
|
|
214
|
+
const requestClone = event.request.clone()
|
|
215
|
+
|
|
216
|
+
function passthrough() {
|
|
217
|
+
// Cast the request headers to a new Headers instance
|
|
218
|
+
// so the headers can be manipulated with.
|
|
219
|
+
const headers = new Headers(requestClone.headers)
|
|
220
|
+
|
|
221
|
+
// Remove the "accept" header value that marked this request as passthrough.
|
|
222
|
+
// This prevents request alteration and also keeps it compliant with the
|
|
223
|
+
// user-defined CORS policies.
|
|
224
|
+
const acceptHeader = headers.get('accept')
|
|
225
|
+
if (acceptHeader) {
|
|
226
|
+
const values = acceptHeader.split(',').map((value) => value.trim())
|
|
227
|
+
const filteredValues = values.filter(
|
|
228
|
+
(value) => value !== 'msw/passthrough',
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
if (filteredValues.length > 0) {
|
|
232
|
+
headers.set('accept', filteredValues.join(', '))
|
|
233
|
+
} else {
|
|
234
|
+
headers.delete('accept')
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return fetch(requestClone, { headers })
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Bypass mocking when the client is not active.
|
|
242
|
+
if (!client) {
|
|
243
|
+
return passthrough()
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Bypass initial page load requests (i.e. static assets).
|
|
247
|
+
// The absence of the immediate/parent client in the map of the active clients
|
|
248
|
+
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
|
249
|
+
// and is not ready to handle requests.
|
|
250
|
+
if (!activeClientIds.has(client.id)) {
|
|
251
|
+
return passthrough()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Notify the client that a request has been intercepted.
|
|
255
|
+
const serializedRequest = await serializeRequest(event.request)
|
|
256
|
+
const clientMessage = await sendToClient(
|
|
257
|
+
client,
|
|
258
|
+
{
|
|
259
|
+
type: 'REQUEST',
|
|
260
|
+
payload: {
|
|
261
|
+
id: requestId,
|
|
262
|
+
interceptedAt: requestInterceptedAt,
|
|
263
|
+
...serializedRequest,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
[serializedRequest.body],
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
switch (clientMessage.type) {
|
|
270
|
+
case 'MOCK_RESPONSE': {
|
|
271
|
+
return respondWithMock(clientMessage.data)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
case 'PASSTHROUGH': {
|
|
275
|
+
return passthrough()
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return passthrough()
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @param {Client} client
|
|
284
|
+
* @param {any} message
|
|
285
|
+
* @param {Array<Transferable>} transferrables
|
|
286
|
+
* @returns {Promise<any>}
|
|
287
|
+
*/
|
|
288
|
+
function sendToClient(client, message, transferrables = []) {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
const channel = new MessageChannel()
|
|
291
|
+
|
|
292
|
+
channel.port1.onmessage = (event) => {
|
|
293
|
+
if (event.data && event.data.error) {
|
|
294
|
+
return reject(event.data.error)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
resolve(event.data)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
client.postMessage(message, [
|
|
301
|
+
channel.port2,
|
|
302
|
+
...transferrables.filter(Boolean),
|
|
303
|
+
])
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @param {Response} response
|
|
309
|
+
* @returns {Response}
|
|
310
|
+
*/
|
|
311
|
+
function respondWithMock(response) {
|
|
312
|
+
// Setting response status code to 0 is a no-op.
|
|
313
|
+
// However, when responding with a "Response.error()", the produced Response
|
|
314
|
+
// instance will have status code set to 0. Since it's not possible to create
|
|
315
|
+
// a Response instance with status code 0, handle that use-case separately.
|
|
316
|
+
if (response.status === 0) {
|
|
317
|
+
return Response.error()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const mockedResponse = new Response(response.body, response)
|
|
321
|
+
|
|
322
|
+
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
|
|
323
|
+
value: true,
|
|
324
|
+
enumerable: true,
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
return mockedResponse
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @param {Request} request
|
|
332
|
+
*/
|
|
333
|
+
async function serializeRequest(request) {
|
|
334
|
+
return {
|
|
335
|
+
url: request.url,
|
|
336
|
+
mode: request.mode,
|
|
337
|
+
method: request.method,
|
|
338
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
339
|
+
cache: request.cache,
|
|
340
|
+
credentials: request.credentials,
|
|
341
|
+
destination: request.destination,
|
|
342
|
+
integrity: request.integrity,
|
|
343
|
+
redirect: request.redirect,
|
|
344
|
+
referrer: request.referrer,
|
|
345
|
+
referrerPolicy: request.referrerPolicy,
|
|
346
|
+
body: await request.arrayBuffer(),
|
|
347
|
+
keepalive: request.keepalive,
|
|
348
|
+
}
|
|
349
|
+
}
|