@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.154 → 0.0.1-alpha.156

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.
@@ -45866,11 +45866,20 @@ function parse(src, reviver, options) {
45866
45866
  }
45867
45867
  function stringify(value, replacer, options) {
45868
45868
  let _replacer = null;
45869
- if (Array.isArray(replacer)) {
45869
+ if (typeof replacer === 'function' || Array.isArray(replacer)) {
45870
45870
  _replacer = replacer;
45871
45871
  }
45872
+ else if (options === undefined && replacer) {
45873
+ options = replacer;
45874
+ }
45875
+ if (typeof options === 'string')
45876
+ options = options.length;
45877
+ if (typeof options === 'number') {
45878
+ const indent = Math.round(options);
45879
+ options = indent < 1 ? undefined : indent > 8 ? { indent: 8 } : { indent };
45880
+ }
45872
45881
  if (value === undefined) {
45873
- const { keepUndefined } = {};
45882
+ const { keepUndefined } = options ?? replacer ?? {};
45874
45883
  if (!keepUndefined)
45875
45884
  return undefined;
45876
45885
  }
@@ -45903,7 +45912,14 @@ const YamlEditor = ({ theme: theme$1, currentValues, onChange, editorUri }) => {
45903
45912
  const pendingExternalYamlRef = useRef(null);
45904
45913
  const isApplyingExternalUpdateRef = useRef(false);
45905
45914
  useEffect(() => {
45906
- const next = stringify(currentValues);
45915
+ const next = stringify(currentValues, {
45916
+ // Use literal block scalar for multiline strings
45917
+ blockQuote: "literal",
45918
+ // Preserve line breaks
45919
+ lineWidth: 0,
45920
+ // Use double quotes for strings that need escaping
45921
+ doubleQuotedAsJSON: false
45922
+ });
45907
45923
  if (isFocusedRef.current) {
45908
45924
  pendingExternalYamlRef.current = next ?? "";
45909
45925
  return;
@@ -46028,7 +46044,8 @@ const YamlEditorSingleton = ({
46028
46044
  backlink,
46029
46045
  designNewLayout,
46030
46046
  designNewLayoutHeight,
46031
- openNotification
46047
+ openNotification,
46048
+ readOnly = false
46032
46049
  }) => {
46033
46050
  const { token } = theme.useToken();
46034
46051
  const navigate = useNavigate();
@@ -46097,15 +46114,18 @@ const YamlEditorSingleton = ({
46097
46114
  height: designNewLayoutHeight || "75vh",
46098
46115
  value: yamlData,
46099
46116
  onChange: (value) => {
46100
- setYamlData(value || "");
46117
+ if (!readOnly) {
46118
+ setYamlData(value || "");
46119
+ }
46101
46120
  },
46102
46121
  theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs",
46103
46122
  options: {
46104
- theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs"
46123
+ theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs",
46124
+ readOnly
46105
46125
  }
46106
46126
  }
46107
46127
  ) }),
46108
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$i.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
46128
+ !readOnly && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$i.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
46109
46129
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", onClick: onSubmit, loading: isLoading, children: "Submit" }),
46110
46130
  backlink && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => navigate(backlink), children: "Cancel" })
46111
46131
  ] }) }),
@@ -46763,6 +46783,41 @@ const FormNamespaceInput = ({
46763
46783
  ] });
46764
46784
  };
46765
46785
 
46786
+ const isMultilineString = (value) => {
46787
+ if (!value || typeof value !== "string") {
46788
+ return false;
46789
+ }
46790
+ if (value.includes("\n")) {
46791
+ return true;
46792
+ }
46793
+ if (value.length > 80) {
46794
+ return true;
46795
+ }
46796
+ const multilineIndicators = ["#cloud-config", "#!/", "---", "```", "BEGIN", "END", "-----BEGIN", "-----END"];
46797
+ return multilineIndicators.some((indicator) => value.includes(indicator));
46798
+ };
46799
+ const isMultilineFromYaml = (yamlContent, fieldPath) => {
46800
+ if (!yamlContent || !fieldPath.length) {
46801
+ return false;
46802
+ }
46803
+ try {
46804
+ const lines = yamlContent.split("\n");
46805
+ const fieldName = fieldPath[fieldPath.length - 1];
46806
+ for (let i = 0; i < lines.length; i++) {
46807
+ const line = lines[i];
46808
+ if (line.includes(`${fieldName}:`) && line.includes("|")) {
46809
+ return true;
46810
+ }
46811
+ if (line.includes(`${fieldName}:`) && line.includes(">")) {
46812
+ return true;
46813
+ }
46814
+ }
46815
+ return false;
46816
+ } catch {
46817
+ return false;
46818
+ }
46819
+ };
46820
+
46766
46821
  const FormStringInput = ({
46767
46822
  name,
46768
46823
  arrKey,
@@ -46778,6 +46833,9 @@ const FormStringInput = ({
46778
46833
  }) => {
46779
46834
  const designNewLayout = useDesignNewLayout();
46780
46835
  const fixedName = name === "nodeName" ? "nodeNameBecauseOfSuddenBug" : name;
46836
+ const formFieldName = arrName || fixedName;
46837
+ const formValue = Form.useWatch(formFieldName);
46838
+ const isMultiline = useMemo(() => isMultilineString(formValue), [formValue]);
46781
46839
  const title = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
46782
46840
  getStringByName(name),
46783
46841
  required?.includes(getStringByName(name)) && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography.Text, { type: "danger", children: "*" })
@@ -46798,7 +46856,14 @@ const FormStringInput = ({
46798
46856
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
46799
46857
  validateTrigger: "onBlur",
46800
46858
  hasFeedback: designNewLayout ? { icons: feedbackIcons } : true,
46801
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { placeholder: getStringByName(name) })
46859
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
46860
+ Input.TextArea,
46861
+ {
46862
+ placeholder: getStringByName(name),
46863
+ rows: isMultiline ? 4 : 1,
46864
+ autoSize: !isMultiline ? { minRows: 1, maxRows: 1 } : { minRows: 2, maxRows: 10 }
46865
+ }
46866
+ )
46802
46867
  },
46803
46868
  arrKey !== void 0 ? arrKey : Array.isArray(name) ? name.slice(-1)[0] : name
46804
46869
  )
@@ -47208,6 +47273,38 @@ const FormInlineYamlEditor = ({ path, persistedControls, externalValue }) => {
47208
47273
  ) });
47209
47274
  };
47210
47275
 
47276
+ const getSortedPropertyKeys = ({
47277
+ name,
47278
+ sortPaths,
47279
+ properties
47280
+ }) => {
47281
+ if (!sortPaths || sortPaths.length === 0) {
47282
+ return Object.keys(properties);
47283
+ }
47284
+ const currentPath = Array.isArray(name) ? name : [name];
47285
+ const currentPathStr = JSON.stringify(currentPath);
47286
+ const currentSortPaths = sortPaths.filter((path) => {
47287
+ if (currentPath.length === 0) {
47288
+ return path.length === 1;
47289
+ }
47290
+ const pathStr = JSON.stringify(path.slice(0, -1));
47291
+ return pathStr === currentPathStr;
47292
+ });
47293
+ if (currentSortPaths.length === 0) {
47294
+ return Object.keys(properties);
47295
+ }
47296
+ const sortOrder = /* @__PURE__ */ new Map();
47297
+ currentSortPaths.forEach((path, index) => {
47298
+ const key = currentPath.length === 0 ? path[0] : path[path.length - 1];
47299
+ sortOrder.set(key, index);
47300
+ });
47301
+ return Object.keys(properties).sort((a, b) => {
47302
+ const aOrder = sortOrder.get(a) ?? Number.MAX_SAFE_INTEGER;
47303
+ const bOrder = sortOrder.get(b) ?? Number.MAX_SAFE_INTEGER;
47304
+ return aOrder - bOrder;
47305
+ });
47306
+ };
47307
+
47211
47308
  const Container = styled.div`
47212
47309
  display: grid;
47213
47310
  grid-template-columns: repeat(2, 1fr);
@@ -47465,6 +47562,7 @@ const getArrayFormItemFromSwagger = ({
47465
47562
  isEdit,
47466
47563
  expandedControls,
47467
47564
  persistedControls,
47565
+ sortPaths,
47468
47566
  urlParams,
47469
47567
  onRemoveByMinus
47470
47568
  }) => {
@@ -47577,6 +47675,7 @@ const getArrayFormItemFromSwagger = ({
47577
47675
  isEdit,
47578
47676
  expandedControls,
47579
47677
  persistedControls,
47678
+ sortPaths,
47580
47679
  urlParams,
47581
47680
  onRemoveByMinus: () => remove(field.name)
47582
47681
  })
@@ -47599,6 +47698,7 @@ const getArrayFormItemFromSwagger = ({
47599
47698
  isEdit,
47600
47699
  expandedControls,
47601
47700
  persistedControls,
47701
+ sortPaths,
47602
47702
  urlParams,
47603
47703
  onRemoveByMinus: () => remove(field.name)
47604
47704
  })
@@ -47643,9 +47743,10 @@ const getObjectFormItemsDraft = ({
47643
47743
  isEdit,
47644
47744
  expandedControls,
47645
47745
  persistedControls,
47746
+ sortPaths,
47646
47747
  urlParams
47647
47748
  }) => {
47648
- return /* @__PURE__ */ jsxRuntimeExports.jsx(HiddenContainer, { name, children: Object.keys(properties).map((el) => {
47749
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(HiddenContainer, { name, children: getSortedPropertyKeys({ name, sortPaths, properties }).map((el) => {
47649
47750
  if (properties[el]["x-kubernetes-preserve-unknown-fields"]) {
47650
47751
  const path = Array.isArray(name) ? [...name, String(el)] : [name, String(el)];
47651
47752
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -47782,6 +47883,7 @@ const getObjectFormItemsDraft = ({
47782
47883
  isEdit,
47783
47884
  expandedControls,
47784
47885
  persistedControls,
47886
+ sortPaths,
47785
47887
  urlParams
47786
47888
  });
47787
47889
  }
@@ -47803,6 +47905,7 @@ const getObjectFormItemsDraft = ({
47803
47905
  isEdit,
47804
47906
  expandedControls,
47805
47907
  persistedControls,
47908
+ sortPaths,
47806
47909
  urlParams
47807
47910
  }) : void 0;
47808
47911
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -47846,6 +47949,7 @@ const getObjectFormItemsDraft = ({
47846
47949
  isEdit,
47847
47950
  expandedControls,
47848
47951
  persistedControls,
47952
+ sortPaths,
47849
47953
  urlParams
47850
47954
  });
47851
47955
  }
@@ -47871,6 +47975,7 @@ const getObjectFormItemFromSwagger = ({
47871
47975
  isEdit,
47872
47976
  expandedControls,
47873
47977
  persistedControls,
47978
+ sortPaths,
47874
47979
  urlParams,
47875
47980
  onRemoveByMinus
47876
47981
  }) => {
@@ -47891,6 +47996,7 @@ const getObjectFormItemFromSwagger = ({
47891
47996
  isEdit,
47892
47997
  expandedControls,
47893
47998
  persistedControls,
47999
+ sortPaths,
47894
48000
  urlParams
47895
48001
  });
47896
48002
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -48206,6 +48312,7 @@ const BlackholeForm = ({
48206
48312
  hiddenPaths,
48207
48313
  expandedPaths,
48208
48314
  persistedPaths,
48315
+ sortPaths,
48209
48316
  prefillValuesSchema,
48210
48317
  prefillValueNamespaceOnly,
48211
48318
  isNameSpaced,
@@ -48884,6 +48991,7 @@ const BlackholeForm = ({
48884
48991
  isEdit: !isCreate,
48885
48992
  expandedControls: { onExpandOpen, onExpandClose, expandedKeys },
48886
48993
  persistedControls: { onPersistMark, onPersistUnmark, persistedKeys },
48994
+ sortPaths,
48887
48995
  urlParams
48888
48996
  }) }) }) }) }),
48889
48997
  !designNewLayout && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -49011,6 +49119,7 @@ const BlackholeFormDataProvider = ({
49011
49119
  hiddenPaths: data2.hiddenPaths,
49012
49120
  expandedPaths: data2.expandedPaths || [],
49013
49121
  persistedPaths: data2.persistedPaths || [],
49122
+ sortPaths: data2.sortPaths,
49014
49123
  kindName: data2.kindName || "",
49015
49124
  formPrefills: data2.formPrefills,
49016
49125
  namespacesData: data2.namespacesData
@@ -49065,6 +49174,7 @@ const BlackholeFormDataProvider = ({
49065
49174
  hiddenPaths: preparedData.hiddenPaths,
49066
49175
  expandedPaths: preparedData.expandedPaths,
49067
49176
  persistedPaths: preparedData.persistedPaths,
49177
+ sortPaths: preparedData.sortPaths,
49068
49178
  prefillValuesSchema: data.prefillValuesSchema,
49069
49179
  prefillValueNamespaceOnly: data.prefillValueNamespaceOnly,
49070
49180
  isCreate,
@@ -52546,5 +52656,5 @@ const useCrdData = ({
52546
52656
  });
52547
52657
  };
52548
52658
 
52549
- export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, CursorDefaultDiv, CursorPointerTag, CursorPointerTagMinContent, CustomSelect$4 as CustomSelect, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EarthIcon, EditIcon, EnrichedTable, EnrichedTableProvider, Events, FlexGrow, LockedIcon, LookingGlassIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard, MinusIcon, NodeTerminal, PaddingContainer, PauseCircleIcon, PlusIcon, PodLogs, PodLogsMonaco, PodTerminal, ProjectInfoCard, ResumeCircleIcon, Search, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UncontrolledSelect, UnlockedIcon, UpIcon, YamlEditorSingleton, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deepMerge, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBackLinkToTable, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getKinds, getLinkToApiForm, getLinkToBuiltinForm, getLinkToForm, getObjectFormItemsDraft, getPrefixSubarrays, getSortedKinds, getSortedKindsAll, getStringByName, getSwagger, getUppercase, groupsToTreeData, hslFromString, isFlatObject, kindByGvr, namespacedByGvr, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, pluralByKind, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
52659
+ export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, CursorDefaultDiv, CursorPointerTag, CursorPointerTagMinContent, CustomSelect$4 as CustomSelect, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EarthIcon, EditIcon, EnrichedTable, EnrichedTableProvider, Events, FlexGrow, LockedIcon, LookingGlassIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard, MinusIcon, NodeTerminal, PaddingContainer, PauseCircleIcon, PlusIcon, PodLogs, PodLogsMonaco, PodTerminal, ProjectInfoCard, ResumeCircleIcon, Search, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UncontrolledSelect, UnlockedIcon, UpIcon, YamlEditorSingleton, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deepMerge, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBackLinkToTable, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getKinds, getLinkToApiForm, getLinkToBuiltinForm, getLinkToForm, getObjectFormItemsDraft, getPrefixSubarrays, getSortedKinds, getSortedKindsAll, getStringByName, getSwagger, getUppercase, groupsToTreeData, hslFromString, isFlatObject, isMultilineFromYaml, isMultilineString, kindByGvr, namespacedByGvr, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, pluralByKind, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
52550
52660
  //# sourceMappingURL=openapi-k8s-toolkit.es.js.map