@dovetail-v2/refine 0.1.5-alpha.0 → 0.1.5-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/{MonacoYamlDiffEditor-c27ab21c.js → MonacoYamlDiffEditor-d4280e1a.js} +1 -1
  2. package/dist/{index-984f2ec7.js → index-ac7d0fe5.js} +395 -317
  3. package/dist/refine.js +216 -212
  4. package/dist/refine.umd.cjs +183 -105
  5. package/dist/style.css +1 -0
  6. package/lib/src/components/Form/useYamlForm.d.ts +2 -3
  7. package/lib/src/components/YamlEditor/MonacoYamlEditor.d.ts +1 -1
  8. package/lib/src/components/YamlEditor/YamlEditorComponent.d.ts +1 -1
  9. package/lib/src/hooks/useSchema.d.ts +7 -0
  10. package/lib/src/i18n.d.ts +1 -0
  11. package/lib/src/index.d.ts +1 -0
  12. package/lib/src/locales/en-US/index.d.ts +1 -0
  13. package/lib/src/utils/openapi.d.ts +6 -11
  14. package/lib/src/utils/schema.d.ts +1 -0
  15. package/package.json +1 -1
  16. package/lib/App.d.ts +0 -2
  17. package/lib/Dovetail.d.ts +0 -18
  18. package/lib/components/Breadcrumb/index.d.ts +0 -5
  19. package/lib/components/ConditionsTable/ConditionsTable.d.ts +0 -7
  20. package/lib/components/ConditionsTable/index.d.ts +0 -1
  21. package/lib/components/CreateButton/index.d.ts +0 -1
  22. package/lib/components/CronJobDropdown/index.d.ts +0 -8
  23. package/lib/components/CronjobJobsTable/index.d.ts +0 -8
  24. package/lib/components/DeleteButton/index.d.ts +0 -2
  25. package/lib/components/DeleteManyButton/index.d.ts +0 -4
  26. package/lib/components/DrawerShow/DrawerShow.d.ts +0 -8
  27. package/lib/components/DrawerShow/index.d.ts +0 -1
  28. package/lib/components/DurationTime/index.d.ts +0 -5
  29. package/lib/components/EditButton/index.d.ts +0 -2
  30. package/lib/components/EditField/index.d.ts +0 -15
  31. package/lib/components/ErrorContent/index.d.ts +0 -17
  32. package/lib/components/EventsTable/EventsTable.d.ts +0 -6
  33. package/lib/components/EventsTable/index.d.ts +0 -1
  34. package/lib/components/Form/FormModal.d.ts +0 -10
  35. package/lib/components/Form/RefineFormContent.d.ts +0 -11
  36. package/lib/components/Form/RefineFormPage.d.ts +0 -6
  37. package/lib/components/Form/YamlForm.d.ts +0 -28
  38. package/lib/components/Form/index.d.ts +0 -7
  39. package/lib/components/Form/type.d.ts +0 -17
  40. package/lib/components/Form/useReactHookForm.d.ts +0 -29
  41. package/lib/components/Form/useRefineForm.d.ts +0 -13
  42. package/lib/components/Form/useYamlForm.d.ts +0 -51
  43. package/lib/components/FormErrorAlert/index.d.ts +0 -9
  44. package/lib/components/FormLayout/index.d.ts +0 -7
  45. package/lib/components/FormWidgets/KeyValueListWidget.d.ts +0 -5
  46. package/lib/components/FormWidgets/MetadataForm.d.ts +0 -1
  47. package/lib/components/FormWidgets/NameInputWidget.d.ts +0 -50
  48. package/lib/components/FormWidgets/NamespaceSelectWidget.d.ts +0 -8
  49. package/lib/components/FormWidgets/index.d.ts +0 -4
  50. package/lib/components/FormWidgets/widget.d.ts +0 -5
  51. package/lib/components/ImageNames/index.d.ts +0 -5
  52. package/lib/components/IngressRulesComponent/index.d.ts +0 -5
  53. package/lib/components/IngressRulesTable/IngressRulesTable.d.ts +0 -7
  54. package/lib/components/IngressRulesTable/index.d.ts +0 -1
  55. package/lib/components/K8sDropdown/index.d.ts +0 -9
  56. package/lib/components/KeyValue/KeyValue.d.ts +0 -7
  57. package/lib/components/KeyValue/KeyValueAnnotation.d.ts +0 -5
  58. package/lib/components/KeyValue/KeyValueSecret.d.ts +0 -4
  59. package/lib/components/KeyValue/index.d.ts +0 -3
  60. package/lib/components/Layout/index.d.ts +0 -3
  61. package/lib/components/LinkFallback/index.d.ts +0 -3
  62. package/lib/components/ListPage/index.d.ts +0 -9
  63. package/lib/components/Menu/index.d.ts +0 -1
  64. package/lib/components/NamespacesFilter/index.d.ts +0 -11
  65. package/lib/components/NetworkPolicyRulesViewer/NetworkPolicyRulesViewer.d.ts +0 -8
  66. package/lib/components/NetworkPolicyRulesViewer/index.d.ts +0 -1
  67. package/lib/components/PageShow/PageShow.d.ts +0 -12
  68. package/lib/components/PageShow/index.d.ts +0 -1
  69. package/lib/components/PodContainersTable/PodContainersTable.d.ts +0 -8
  70. package/lib/components/PodContainersTable/index.d.ts +0 -1
  71. package/lib/components/PodDropdown/index.d.ts +0 -9
  72. package/lib/components/PodLog/index.d.ts +0 -6
  73. package/lib/components/PodSelectorTable/index.d.ts +0 -6
  74. package/lib/components/PodShellModal/PodShell.d.ts +0 -18
  75. package/lib/components/PodShellModal/index.d.ts +0 -9
  76. package/lib/components/PortsTable/index.d.ts +0 -7
  77. package/lib/components/ReferenceLink/index.d.ts +0 -8
  78. package/lib/components/ReplicasDropdown/index.d.ts +0 -9
  79. package/lib/components/ResourceCRUD/ResourceCRUD.d.ts +0 -7
  80. package/lib/components/ResourceCRUD/create/index.d.ts +0 -7
  81. package/lib/components/ResourceCRUD/index.d.ts +0 -4
  82. package/lib/components/ResourceCRUD/list/index.d.ts +0 -8
  83. package/lib/components/ResourceCRUD/show/index.d.ts +0 -8
  84. package/lib/components/ResourceFiledDisplays.d.ts +0 -6
  85. package/lib/components/ResourceLink/index.d.ts +0 -8
  86. package/lib/components/ResourceSelect/index.d.ts +0 -11
  87. package/lib/components/ResourceUsageBar/index.d.ts +0 -8
  88. package/lib/components/Separator/index.d.ts +0 -2
  89. package/lib/components/ServiceComponents/index.d.ts +0 -10
  90. package/lib/components/Shell/index.d.ts +0 -54
  91. package/lib/components/ShowContent/ShowContent.d.ts +0 -18
  92. package/lib/components/ShowContent/fields.d.ts +0 -68
  93. package/lib/components/ShowContent/groups.d.ts +0 -23
  94. package/lib/components/ShowContent/index.d.ts +0 -4
  95. package/lib/components/ShowContent/tabs.d.ts +0 -5
  96. package/lib/components/StateTag/StateTag.d.ts +0 -10
  97. package/lib/components/StateTag/index.d.ts +0 -1
  98. package/lib/components/Table/TableToolBar.d.ts +0 -8
  99. package/lib/components/Table/TableWidgets.d.ts +0 -6
  100. package/lib/components/Table/index.d.ts +0 -43
  101. package/lib/components/Tabs/index.d.ts +0 -10
  102. package/lib/components/Tags/index.d.ts +0 -6
  103. package/lib/components/TextTags/index.d.ts +0 -6
  104. package/lib/components/Time/index.d.ts +0 -8
  105. package/lib/components/ValueDisplay/index.d.ts +0 -9
  106. package/lib/components/WorkloadDropdown/index.d.ts +0 -9
  107. package/lib/components/WorkloadPodsTable/WorkloadPodsTable.d.ts +0 -9
  108. package/lib/components/WorkloadPodsTable/index.d.ts +0 -1
  109. package/lib/components/WorkloadReplicas/index.d.ts +0 -17
  110. package/lib/components/YamlEditor/MonacoYamlDiffEditor.d.ts +0 -9
  111. package/lib/components/YamlEditor/MonacoYamlEditor.d.ts +0 -19
  112. package/lib/components/YamlEditor/YamlEditorComponent.d.ts +0 -27
  113. package/lib/components/YamlEditor/index.d.ts +0 -1
  114. package/lib/components/YamlEditor/style.d.ts +0 -11
  115. package/lib/components/YamlEditor/yaml.worker.d.ts +0 -1
  116. package/lib/components/index.d.ts +0 -47
  117. package/lib/constants/auth.d.ts +0 -5
  118. package/lib/constants/index.d.ts +0 -3
  119. package/lib/constants/k8s.d.ts +0 -487
  120. package/lib/constants/state.d.ts +0 -15
  121. package/lib/contexts/component.d.ts +0 -7
  122. package/lib/contexts/configs.d.ts +0 -3
  123. package/lib/contexts/global-store.d.ts +0 -5
  124. package/lib/contexts/index.d.ts +0 -3
  125. package/lib/hooks/index.d.ts +0 -8
  126. package/lib/hooks/useDeleteModal/index.d.ts +0 -1
  127. package/lib/hooks/useDeleteModal/useDeleteManyModal.d.ts +0 -7
  128. package/lib/hooks/useDeleteModal/useDeleteModal.d.ts +0 -7
  129. package/lib/hooks/useDownloadYAML.d.ts +0 -7
  130. package/lib/hooks/useEagleTable/columns.d.ts +0 -41
  131. package/lib/hooks/useEagleTable/index.d.ts +0 -2
  132. package/lib/hooks/useEagleTable/useEagleTable.d.ts +0 -55
  133. package/lib/hooks/useEdit.d.ts +0 -4
  134. package/lib/hooks/useGlobalStore.d.ts +0 -3
  135. package/lib/hooks/useK8sYamlEditor.d.ts +0 -5
  136. package/lib/hooks/useNamespaceRefineFilter.d.ts +0 -5
  137. package/lib/hooks/useOpenForm.d.ts +0 -7
  138. package/lib/hooks/useSchema.d.ts +0 -14
  139. package/lib/hooks/useSubmitForm.d.ts +0 -14
  140. package/lib/hooks/useTableData.d.ts +0 -19
  141. package/lib/i18n.d.ts +0 -353
  142. package/lib/index.d.ts +0 -11
  143. package/lib/locales/en-US/index.d.ts +0 -175
  144. package/lib/locales/index.d.ts +0 -2
  145. package/lib/locales/zh-CN/index.d.ts +0 -175
  146. package/lib/main.d.ts +0 -3
  147. package/lib/models/cronjob-model.d.ts +0 -15
  148. package/lib/models/daemonset-model.d.ts +0 -15
  149. package/lib/models/deployment-model.d.ts +0 -13
  150. package/lib/models/event-model.d.ts +0 -7
  151. package/lib/models/index.d.ts +0 -19
  152. package/lib/models/ingress-model.d.ts +0 -20
  153. package/lib/models/job-model.d.ts +0 -20
  154. package/lib/models/network-policy-model.d.ts +0 -9
  155. package/lib/models/node-model.d.ts +0 -17
  156. package/lib/models/persistent-volume-claim.d.ts +0 -9
  157. package/lib/models/persistent-volume.d.ts +0 -9
  158. package/lib/models/pod-metrics-model.d.ts +0 -8
  159. package/lib/models/pod-model.d.ts +0 -20
  160. package/lib/models/resource-model.d.ts +0 -21
  161. package/lib/models/service-model.d.ts +0 -24
  162. package/lib/models/statefulset-model.d.ts +0 -13
  163. package/lib/models/storage-class.d.ts +0 -12
  164. package/lib/models/types/index.d.ts +0 -1
  165. package/lib/models/types/metric.d.ts +0 -25
  166. package/lib/models/workload-base-model.d.ts +0 -12
  167. package/lib/models/workload-model.d.ts +0 -18
  168. package/lib/pages/configmaps/index.d.ts +0 -4
  169. package/lib/pages/cronjobs/create/index.d.ts +0 -3
  170. package/lib/pages/cronjobs/index.d.ts +0 -3
  171. package/lib/pages/cronjobs/list/index.d.ts +0 -3
  172. package/lib/pages/cronjobs/show/index.d.ts +0 -3
  173. package/lib/pages/daemonsets/create/index.d.ts +0 -3
  174. package/lib/pages/daemonsets/index.d.ts +0 -3
  175. package/lib/pages/daemonsets/list/index.d.ts +0 -3
  176. package/lib/pages/daemonsets/show/index.d.ts +0 -3
  177. package/lib/pages/deployments/index.d.ts +0 -2
  178. package/lib/pages/deployments/list/index.d.ts +0 -3
  179. package/lib/pages/deployments/show/index.d.ts +0 -3
  180. package/lib/pages/ingresses/index.d.ts +0 -4
  181. package/lib/pages/jobs/index.d.ts +0 -4
  182. package/lib/pages/networkPolicies/index.d.ts +0 -4
  183. package/lib/pages/nodes/index.d.ts +0 -2
  184. package/lib/pages/nodes/list/index.d.ts +0 -3
  185. package/lib/pages/nodes/show/index.d.ts +0 -3
  186. package/lib/pages/persistentvolumeclaims/index.d.ts +0 -4
  187. package/lib/pages/persistentvolumes/index.d.ts +0 -4
  188. package/lib/pages/pods/create/index.d.ts +0 -3
  189. package/lib/pages/pods/index.d.ts +0 -3
  190. package/lib/pages/pods/list/index.d.ts +0 -3
  191. package/lib/pages/pods/show/index.d.ts +0 -3
  192. package/lib/pages/secrets/index.d.ts +0 -4
  193. package/lib/pages/services/index.d.ts +0 -4
  194. package/lib/pages/statefulsets/index.d.ts +0 -4
  195. package/lib/pages/storageclasses/form/index.d.ts +0 -9
  196. package/lib/pages/storageclasses/index.d.ts +0 -44
  197. package/lib/plugins/index.d.ts +0 -4
  198. package/lib/plugins/model-plugin.d.ts +0 -13
  199. package/lib/plugins/relation-plugin.d.ts +0 -26
  200. package/lib/plugins/type.d.ts +0 -8
  201. package/lib/providers/index.d.ts +0 -1
  202. package/lib/providers/router-provider/index.d.ts +0 -21
  203. package/lib/types/index.d.ts +0 -1
  204. package/lib/types/resource.d.ts +0 -62
  205. package/lib/utils/addId.d.ts +0 -3
  206. package/lib/utils/download.d.ts +0 -1
  207. package/lib/utils/error.d.ts +0 -20
  208. package/lib/utils/form.d.ts +0 -3
  209. package/lib/utils/k8s.d.ts +0 -3
  210. package/lib/utils/labels.d.ts +0 -9
  211. package/lib/utils/match-selector.d.ts +0 -3
  212. package/lib/utils/openapi.d.ts +0 -45
  213. package/lib/utils/schema.d.ts +0 -17
  214. package/lib/utils/selector.d.ts +0 -3
  215. package/lib/utils/shell.d.ts +0 -15
  216. package/lib/utils/string.d.ts +0 -1
  217. package/lib/utils/time.d.ts +0 -13
  218. package/lib/utils/unit.d.ts +0 -12
  219. package/lib/utils/yaml.d.ts +0 -2
@@ -1174,6 +1174,7 @@ var __publicField = (obj, key, value) => {
1174
1174
  const pv_phase_failed$1 = "Failed";
1175
1175
  const pv_phase_pending$1 = "Pending";
1176
1176
  const exec_pod = "Execute shell";
1177
+ const search$1 = "Search";
1177
1178
  const dovetail$1 = {
1178
1179
  copy: copy$2,
1179
1180
  reset_arguments: reset_arguments$1,
@@ -1344,7 +1345,8 @@ var __publicField = (obj, key, value) => {
1344
1345
  pv_phase_released: pv_phase_released$1,
1345
1346
  pv_phase_failed: pv_phase_failed$1,
1346
1347
  pv_phase_pending: pv_phase_pending$1,
1347
- exec_pod
1348
+ exec_pod,
1349
+ search: search$1
1348
1350
  };
1349
1351
  const EN = {
1350
1352
  dovetail: dovetail$1
@@ -8025,9 +8027,13 @@ var __publicField = (obj, key, value) => {
8025
8027
  }
8026
8028
  function resolveRef(schema, schemas, options) {
8027
8029
  var _a, _b;
8028
- const { prune } = options;
8030
+ const { prune, prePath = "#/components/schemas/" } = options;
8031
+ const kindObj = schema["x-kubernetes-group-version-kind"];
8032
+ if (kindObj) {
8033
+ schema.properties.kind = { const: kindObj[0].kind };
8034
+ }
8029
8035
  if (schema.$ref) {
8030
- const refKey = schema.$ref.replace("#/components/schemas/", "");
8036
+ const refKey = schema.$ref.replace(prePath, "");
8031
8037
  Object.assign(schema, schemas[refKey]);
8032
8038
  if (prune.metadata && [
8033
8039
  "io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta",
@@ -8080,30 +8086,47 @@ var __publicField = (obj, key, value) => {
8080
8086
  }
8081
8087
  class K8sOpenAPI {
8082
8088
  constructor(resourceBasePath) {
8083
- __publicField(this, "response", null);
8089
+ // private response: OpenAPIResponse | null = null;
8084
8090
  __publicField(this, "apiVersion");
8091
+ __publicField(this, "schemas", null);
8085
8092
  this.resourceBasePath = resourceBasePath;
8086
8093
  this.apiVersion = getApiVersion(resourceBasePath);
8087
8094
  }
8095
+ // Fetch and process OpenAPI schemas
8088
8096
  async fetch() {
8089
- const response = await fetch(
8090
- `/api/sks/api/v1/clusters/sks-mgmt/proxy/openapi/v3${this.resourceBasePath}`
8091
- );
8092
- return response.json();
8097
+ try {
8098
+ const response = await fetch(
8099
+ `/api/sks/api/v1/clusters/sks-mgmt/proxy/openapi/v3${this.resourceBasePath}`
8100
+ );
8101
+ const result = await response.json();
8102
+ this.schemas = Object.values(result.components.schemas);
8103
+ if (this.schemas) {
8104
+ this.processSchemas(result.components.schemas);
8105
+ }
8106
+ return this.schemas;
8107
+ } catch (error) {
8108
+ console.error("Failed to fetch OpenAPI schemas:", error);
8109
+ return null;
8110
+ }
8093
8111
  }
8094
- async findSchema(kind) {
8112
+ // Find schema by kind and version
8113
+ findSchema(kind) {
8095
8114
  var _a;
8096
- const result = this.response || await this.fetch();
8097
- const schema = Object.values(result.components.schemas).find(
8098
- (schema2) => {
8115
+ return (_a = this.schemas) == null ? void 0 : _a.find(
8116
+ (schema) => {
8099
8117
  var _a2;
8100
- return (_a2 = schema2["x-kubernetes-group-version-kind"]) == null ? void 0 : _a2.some(
8118
+ return (_a2 = schema["x-kubernetes-group-version-kind"]) == null ? void 0 : _a2.some(
8101
8119
  ({ kind: schemaKind, version: schemaVersion, group: schemaGroup }) => kind === schemaKind && this.apiVersion === `${schemaGroup ? schemaGroup + "/" : ""}${schemaVersion}`
8102
8120
  );
8103
8121
  }
8104
8122
  );
8105
- if (schema) {
8106
- resolveRef(schema, result.components.schemas, {
8123
+ }
8124
+ // Process and clean up schemas
8125
+ processSchemas(schemaMap) {
8126
+ var _a;
8127
+ (_a = this.schemas) == null ? void 0 : _a.forEach((schema) => {
8128
+ var _a2;
8129
+ resolveRef(schema, schemaMap, {
8107
8130
  prune: {
8108
8131
  description: true,
8109
8132
  optional: false,
@@ -8112,13 +8135,52 @@ var __publicField = (obj, key, value) => {
8112
8135
  xProperty: true
8113
8136
  }
8114
8137
  });
8115
- }
8116
- if ((_a = schema == null ? void 0 : schema.properties) == null ? void 0 : _a.status) {
8117
- schema == null ? true : delete schema.properties.status;
8118
- }
8119
- return schema;
8138
+ if ((_a2 = schema == null ? void 0 : schema.properties) == null ? void 0 : _a2.status) {
8139
+ delete schema.properties.status;
8140
+ }
8141
+ });
8120
8142
  }
8121
8143
  }
8144
+ function useApiGroupSchema(apiGroups) {
8145
+ const [state2, setState] = React.useState({
8146
+ schemas: null,
8147
+ schemasMap: {},
8148
+ loading: false,
8149
+ error: null
8150
+ });
8151
+ const fetchSchema = React.useCallback(async () => {
8152
+ setState((prev) => ({ ...prev, loading: true, error: null }));
8153
+ try {
8154
+ const results = await Promise.all(
8155
+ apiGroups.map(async (apiGroup) => {
8156
+ if (state2.schemasMap[apiGroup]) {
8157
+ return { apiGroup, schemas: state2.schemasMap[apiGroup] };
8158
+ }
8159
+ const openapi = new K8sOpenAPI(apiGroup);
8160
+ const groupSchemas = await openapi.fetch();
8161
+ return { apiGroup, schemas: groupSchemas || [] };
8162
+ })
8163
+ );
8164
+ const newSchemasMap = results.reduce((acc, { apiGroup, schemas }) => {
8165
+ acc[apiGroup] = schemas;
8166
+ return acc;
8167
+ }, {});
8168
+ const allSchemas = results.flatMap(({ schemas }) => schemas);
8169
+ setState({
8170
+ schemas: allSchemas,
8171
+ schemasMap: newSchemasMap,
8172
+ loading: false,
8173
+ error: null
8174
+ });
8175
+ } catch (e2) {
8176
+ setState((prev) => ({ ...prev, loading: false, error: e2 }));
8177
+ }
8178
+ }, [apiGroups, state2.schemasMap]);
8179
+ React.useEffect(() => {
8180
+ fetchSchema();
8181
+ }, [fetchSchema]);
8182
+ return { ...state2, fetchSchema };
8183
+ }
8122
8184
  function useSchema(options) {
8123
8185
  var _a;
8124
8186
  const [schema, setSchema] = React.useState(null);
@@ -8138,6 +8200,7 @@ var __publicField = (obj, key, value) => {
8138
8200
  setLoading(true);
8139
8201
  setError(null);
8140
8202
  try {
8203
+ await openapi.fetch();
8141
8204
  const schema2 = await openapi.findSchema((_a2 = resource == null ? void 0 : resource.meta) == null ? void 0 : _a2.kind);
8142
8205
  setSchema(schema2 || null);
8143
8206
  setError(null);
@@ -8151,7 +8214,7 @@ var __publicField = (obj, key, value) => {
8151
8214
  if (options == null ? void 0 : options.skip)
8152
8215
  return;
8153
8216
  fetchSchema();
8154
- }, [fetchSchema]);
8217
+ }, [fetchSchema, options == null ? void 0 : options.skip]);
8155
8218
  return {
8156
8219
  schema,
8157
8220
  loading,
@@ -18141,16 +18204,17 @@ var __publicField = (obj, key, value) => {
18141
18204
  const ErrorMsgStyle = "eh2qjnl";
18142
18205
  const ErrorWrapperStyle = "e19q2bnp";
18143
18206
  const YamlEditorStyle = "y16u5v3w";
18144
- const schemaMap = /* @__PURE__ */ new Map();
18145
18207
  const MonacoYamlEditor$1 = (props) => {
18146
18208
  const ref = React.useRef(null);
18147
- const instanceRef = React.useRef({ editor: null });
18209
+ const instanceRef = React.useRef({
18210
+ editor: null
18211
+ });
18148
18212
  const {
18149
18213
  defaultValue,
18150
18214
  id,
18151
18215
  height,
18152
18216
  readOnly,
18153
- schema,
18217
+ schemas,
18154
18218
  isScrollOnFocus,
18155
18219
  onChange,
18156
18220
  onValidate,
@@ -18160,24 +18224,21 @@ var __publicField = (obj, key, value) => {
18160
18224
  } = props;
18161
18225
  const uri = id ? monaco__namespace.Uri.parse(`${id}.yaml`) : void 0;
18162
18226
  React.useEffect(() => {
18163
- if (schema) {
18164
- schemaMap.set(id, {
18165
- // Id of the first schema
18227
+ const finalSchemas = [
18228
+ {
18166
18229
  uri: String(uri),
18167
- // Associate with our model
18168
- fileMatch: uri ? [String(uri)] : [],
18169
- schema
18170
- });
18171
- }
18172
- const schemas = [...schemaMap.values()];
18230
+ fileMatch: [String(uri)],
18231
+ schema: {
18232
+ oneOf: schemas || []
18233
+ }
18234
+ }
18235
+ ];
18173
18236
  monacoYaml.setDiagnosticsOptions({
18174
18237
  enableSchemaRequest: false,
18175
- hover: true,
18176
- completion: true,
18177
18238
  validate: true,
18178
18239
  format: true,
18179
18240
  isKubernetes: true,
18180
- schemas
18241
+ schemas: finalSchemas
18181
18242
  });
18182
18243
  const model = monaco__namespace.editor.createModel(defaultValue, "yaml", uri);
18183
18244
  const editor = monaco__namespace.editor.create(ref.current, {
@@ -18198,11 +18259,10 @@ var __publicField = (obj, key, value) => {
18198
18259
  onEditorCreate == null ? void 0 : onEditorCreate(editor);
18199
18260
  return () => {
18200
18261
  instanceRef.current.editor = null;
18201
- schemaMap.delete(id);
18202
18262
  model.dispose();
18203
18263
  editor.dispose();
18204
18264
  };
18205
- }, [schema, id, readOnly, isScrollOnFocus, getInstance]);
18265
+ }, [id, schemas, readOnly, isScrollOnFocus, getInstance]);
18206
18266
  React.useEffect(() => {
18207
18267
  const editor = instanceRef.current.editor;
18208
18268
  if (editor) {
@@ -18224,7 +18284,10 @@ var __publicField = (obj, key, value) => {
18224
18284
  const model = (_a = instanceRef.current.editor) == null ? void 0 : _a.getModel();
18225
18285
  const currentEditorUri = model == null ? void 0 : model.uri;
18226
18286
  if (model && uri2.toString() === (currentEditorUri == null ? void 0 : currentEditorUri.toString())) {
18227
- const marks = monaco__namespace.editor.getModelMarkers({ owner: "yaml", resource: currentEditorUri });
18287
+ const marks = monaco__namespace.editor.getModelMarkers({
18288
+ owner: "yaml",
18289
+ resource: currentEditorUri
18290
+ });
18228
18291
  const yamlMarks = marks.filter((m) => m.source === "YAML");
18229
18292
  const schemaMarks = marks.filter((m) => m.source !== "YAML");
18230
18293
  const yamlValid = yamlMarks.length === 0;
@@ -18234,7 +18297,11 @@ var __publicField = (obj, key, value) => {
18234
18297
  var _a2;
18235
18298
  return (_a2 = mark.source) == null ? void 0 : _a2.includes("yaml-schema");
18236
18299
  })) {
18237
- monaco__namespace.editor.setModelMarkers(model, "yaml", marks.map((mark) => ({ ...mark, source: "", resource: {} })));
18300
+ monaco__namespace.editor.setModelMarkers(
18301
+ model,
18302
+ "yaml",
18303
+ marks.map((mark) => ({ ...mark, source: "", resource: {} }))
18304
+ );
18238
18305
  }
18239
18306
  }
18240
18307
  });
@@ -18260,20 +18327,24 @@ var __publicField = (obj, key, value) => {
18260
18327
  const editor = instanceRef.current.editor;
18261
18328
  const stops = [];
18262
18329
  if (editor && isScrollOnFocus) {
18263
- stops.push(editor.onDidFocusEditorWidget(() => {
18264
- editor.updateOptions({
18265
- scrollbar: {
18266
- handleMouseWheel: true
18267
- }
18268
- });
18269
- }));
18270
- stops.push(editor.onDidBlurEditorWidget(() => {
18271
- editor.updateOptions({
18272
- scrollbar: {
18273
- handleMouseWheel: false
18274
- }
18275
- });
18276
- }));
18330
+ stops.push(
18331
+ editor.onDidFocusEditorWidget(() => {
18332
+ editor.updateOptions({
18333
+ scrollbar: {
18334
+ handleMouseWheel: true
18335
+ }
18336
+ });
18337
+ })
18338
+ );
18339
+ stops.push(
18340
+ editor.onDidBlurEditorWidget(() => {
18341
+ editor.updateOptions({
18342
+ scrollbar: {
18343
+ handleMouseWheel: false
18344
+ }
18345
+ });
18346
+ })
18347
+ );
18277
18348
  }
18278
18349
  return () => {
18279
18350
  stops.forEach((stop) => stop.dispose());
@@ -18316,7 +18387,7 @@ var __publicField = (obj, key, value) => {
18316
18387
  });
18317
18388
  }
18318
18389
  return /* @__PURE__ */ jsxRuntimeExports.jsx(MonacoYamlEditor$1, {
18319
- schema: {},
18390
+ schemas: [],
18320
18391
  defaultValue: yaml.dump(ingressOrEgress),
18321
18392
  height: "300px",
18322
18393
  className: EditorStyle$1,
@@ -31850,12 +31921,13 @@ WARNING: This link could potentially be dangerous`)) {
31850
31921
  }
31851
31922
  var copyToClipboard$1 = copy;
31852
31923
  const copyToClipboard$2 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard$1);
31853
- const ShellToolbar_1rkzbun = "";
31924
+ const ShellToolbar_ox6trc = "";
31854
31925
  const ToolbarStyle$1 = "tzxa6d";
31855
31926
  const ToolbarAreaStyle = "t1sxu3rr";
31856
31927
  const IconWrapperStyle = "ix8ych8";
31857
31928
  const IconStyle = "i58m6oo";
31858
31929
  const DividerStyle = "d1t2oa87";
31930
+ const TooltipStyle = "tuo8xdg";
31859
31931
  function ShellToolbar(props) {
31860
31932
  const {
31861
31933
  className,
@@ -31885,7 +31957,10 @@ WARNING: This link could potentially be dangerous`)) {
31885
31957
  })),
31886
31958
  slotsElements: {
31887
31959
  trigger: () => /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
31888
- title: t2("dovetail.font_size"),
31960
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
31961
+ className: TooltipStyle,
31962
+ children: t2("dovetail.font_size")
31963
+ }),
31889
31964
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
31890
31965
  style: {
31891
31966
  display: "flex",
@@ -31901,7 +31976,10 @@ WARNING: This link could potentially be dangerous`)) {
31901
31976
  }
31902
31977
  }),
31903
31978
  downloadLog: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
31904
- title: t2("dovetail.download_shell_content"),
31979
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
31980
+ className: TooltipStyle,
31981
+ children: t2("dovetail.download_shell_content")
31982
+ }),
31905
31983
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
31906
31984
  className: IconStyle,
31907
31985
  src: iconsReact.LogCollection16GrayIcon,
@@ -31910,7 +31988,10 @@ WARNING: This link could potentially be dangerous`)) {
31910
31988
  })
31911
31989
  }),
31912
31990
  clear: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
31913
- title: t2("dovetail.clear_shell"),
31991
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
31992
+ className: TooltipStyle,
31993
+ children: t2("dovetail.clear_shell")
31994
+ }),
31914
31995
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
31915
31996
  className: IconStyle,
31916
31997
  src: iconsReact.TrashBinDeletePermanently16GrayIcon,
@@ -31927,7 +32008,7 @@ WARNING: This link could potentially be dangerous`)) {
31927
32008
  }), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
31928
32009
  className: ToolbarAreaStyle,
31929
32010
  children: [/* @__PURE__ */ jsxRuntimeExports.jsx(eagle.SearchInput, {
31930
- placeholder: "Search...",
32011
+ placeholder: t2("dovetail.search"),
31931
32012
  size: "small",
31932
32013
  total: searchMatchedTotal,
31933
32014
  onChange: (str) => {
@@ -32266,7 +32347,8 @@ WARNING: This link could potentially be dangerous`)) {
32266
32347
  className: ContainerStyle,
32267
32348
  children: [!!error ? /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Alert, {
32268
32349
  style: {
32269
- margin: "4px 8px"
32350
+ margin: 8,
32351
+ marginBottom: 4
32270
32352
  },
32271
32353
  message: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", {
32272
32354
  className: ErrorAlertStyle,
@@ -37274,7 +37356,7 @@ WARNING: This link could potentially be dangerous`)) {
37274
37356
  height,
37275
37357
  readOnly,
37276
37358
  errorMsgs = [],
37277
- schema,
37359
+ schemas,
37278
37360
  eleRef,
37279
37361
  className
37280
37362
  } = props;
@@ -37486,7 +37568,7 @@ WARNING: This link could potentially be dangerous`)) {
37486
37568
  onValidate,
37487
37569
  onEditorCreate,
37488
37570
  onBlur: props.onBlur,
37489
- schema,
37571
+ schemas,
37490
37572
  readOnly
37491
37573
  }
37492
37574
  ) }) }),
@@ -37725,43 +37807,35 @@ WARNING: This link could potentially be dangerous`)) {
37725
37807
  }),
37726
37808
  [formLoading, form]
37727
37809
  );
37728
- const editorProps = React.useMemo(
37729
- () => {
37730
- var _a2;
37731
- return {
37732
- ref: editor,
37733
- defaultValue: schema && (editorOptions == null ? void 0 : editorOptions.isGenerateAnnotations) ? generateYamlBySchema(initialValues || {}, schema) : yaml.dump(initialValues),
37734
- schema,
37735
- id: ((_a2 = useResourceResult.resource) == null ? void 0 : _a2.name) || "",
37736
- errorMsgs: editorErrors,
37737
- onValidate(yamlValid, schemaValid) {
37738
- setIsYamlValid(yamlValid);
37739
- setIsSchemaValid(schemaValid);
37740
- if (yamlValid && schemaValid) {
37741
- setEditorErrors([]);
37742
- }
37743
- },
37744
- onEditorCreate(editorInstance) {
37745
- var _a3, _b;
37746
- const editorValue = yaml.dump(initialValues);
37747
- (_a3 = editor.current) == null ? void 0 : _a3.setEditorValue(editorValue);
37748
- (_b = editor.current) == null ? void 0 : _b.setValue(editorValue);
37749
- if (action === "edit") {
37750
- fold2(editorInstance);
37751
- }
37810
+ const schemas = React.useMemo(() => {
37811
+ return schema ? [schema] : [];
37812
+ }, [schema]);
37813
+ const editorProps = React.useMemo(() => {
37814
+ var _a2;
37815
+ return {
37816
+ ref: editor,
37817
+ defaultValue: schema && (editorOptions == null ? void 0 : editorOptions.isGenerateAnnotations) ? generateYamlBySchema(initialValues || {}, schema) : yaml.dump(initialValues),
37818
+ schemas,
37819
+ id: ((_a2 = useResourceResult.resource) == null ? void 0 : _a2.name) || "",
37820
+ errorMsgs: editorErrors,
37821
+ onValidate(yamlValid, schemaValid) {
37822
+ setIsYamlValid(yamlValid);
37823
+ setIsSchemaValid(schemaValid);
37824
+ if (yamlValid && schemaValid) {
37825
+ setEditorErrors([]);
37752
37826
  }
37753
- };
37754
- },
37755
- [
37756
- editorErrors,
37757
- editorOptions,
37758
- initialValues,
37759
- schema,
37760
- (_a = useResourceResult.resource) == null ? void 0 : _a.name,
37761
- action,
37762
- fold2
37763
- ]
37764
- );
37827
+ },
37828
+ onEditorCreate(editorInstance) {
37829
+ var _a3, _b;
37830
+ const editorValue = yaml.dump(initialValues);
37831
+ (_a3 = editor.current) == null ? void 0 : _a3.setEditorValue(editorValue);
37832
+ (_b = editor.current) == null ? void 0 : _b.setValue(editorValue);
37833
+ if (action === "edit") {
37834
+ fold2(editorInstance);
37835
+ }
37836
+ }
37837
+ };
37838
+ }, [schema, editorOptions == null ? void 0 : editorOptions.isGenerateAnnotations, initialValues, schemas, (_a = useResourceResult.resource) == null ? void 0 : _a.name, editorErrors, action, fold2]);
37765
37839
  return {
37766
37840
  form: formSF.form,
37767
37841
  formProps: {
@@ -37800,7 +37874,7 @@ WARNING: This link could potentially be dangerous`)) {
37800
37874
  editorProps,
37801
37875
  enableEditor,
37802
37876
  errorResponseBody,
37803
- schema,
37877
+ schemas: schema ? [schema] : [],
37804
37878
  isLoadingSchema,
37805
37879
  loadSchemaError,
37806
37880
  fetchSchema,
@@ -37892,9 +37966,9 @@ WARNING: This link could potentially be dangerous`)) {
37892
37966
  const formWrapperProps = isShowLayout ? {
37893
37967
  saveButtonProps
37894
37968
  } : {};
37895
- const schema = React.useMemo(() => {
37896
- return editorProps.schema || {};
37897
- }, [editorProps.schema]);
37969
+ const schemas = React.useMemo(() => {
37970
+ return editorProps.schemas || [];
37971
+ }, [editorProps.schemas]);
37898
37972
  const responseErrors = React.useMemo(() => errorResponseBody ? getCommonErrors(errorResponseBody, i18n2) : [], [errorResponseBody, i18n2]);
37899
37973
  const onFinish = React.useCallback(async (store) => {
37900
37974
  var _a, _b;
@@ -37929,7 +38003,7 @@ WARNING: This link could potentially be dangerous`)) {
37929
38003
  if (isLoadingSchema || (queryResult == null ? void 0 : queryResult.isLoading) && action === "edit") {
37930
38004
  return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Loading, {});
37931
38005
  }
37932
- return editorProps.schema || schemaStrategy !== "Required" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
38006
+ return editorProps.schemas || schemaStrategy !== "Required" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
37933
38007
  children: [/* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Form.Item, {
37934
38008
  style: {
37935
38009
  flex: 1
@@ -37937,7 +38011,7 @@ WARNING: This link could potentially be dangerous`)) {
37937
38011
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(YamlEditorComponent, {
37938
38012
  ...editorProps,
37939
38013
  className: EditorStyle,
37940
- schema,
38014
+ schemas,
37941
38015
  collapsable: false
37942
38016
  })
37943
38017
  }), /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Form.Item, {
@@ -39563,12 +39637,16 @@ WARNING: This link could potentially be dangerous`)) {
39563
39637
  exports2.addDefaultRenderToColumns = addDefaultRenderToColumns;
39564
39638
  exports2.dnsSubDomainRules = dnsSubDomainRules;
39565
39639
  exports2.dovetailRefineI18n = dovetailRefineI18n;
39640
+ exports2.generateSchemaTypeValue = generateSchemaTypeValue;
39641
+ exports2.generateValueFromSchema = generateValueFromSchema;
39566
39642
  exports2.modelPlugin = modelPlugin;
39567
39643
  exports2.namespaceRules = namespaceRules;
39568
39644
  exports2.relationPlugin = relationPlugin;
39645
+ exports2.resolveRef = resolveRef;
39569
39646
  exports2.rfc1035LabelRules = rfc1035LabelRules;
39570
39647
  exports2.rfc1123LabelRules = rfc1123LabelRules;
39571
39648
  exports2.routerProvider = routerProvider;
39649
+ exports2.useApiGroupSchema = useApiGroupSchema;
39572
39650
  exports2.useDeleteModal = useDeleteModal;
39573
39651
  exports2.useDownloadYAML = useDownloadYAML;
39574
39652
  exports2.useEagleTable = useEagleTable;
package/dist/style.css CHANGED
@@ -1513,6 +1513,7 @@
1513
1513
  .ix8ych8{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:16px;}
1514
1514
  .i58m6oo{cursor:pointer;}
1515
1515
  .d1t2oa87{width:1px;height:100%;background:rgba(172,186,211,0.60);margin:0 16px;}
1516
+ .tuo8xdg{white-space:nowrap;}
1516
1517
  /**
1517
1518
  * Copyright (c) 2014 The xterm.js authors. All rights reserved.
1518
1519
  * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
@@ -5,9 +5,8 @@ import { JSONSchema7 } from 'json-schema';
5
5
  import { Unstructured } from 'k8s-api-provider';
6
6
  import React from 'react';
7
7
  import { type YamlEditorHandle, type YamlEditorProps } from 'src/components/YamlEditor';
8
- type EditorProps = Omit<YamlEditorProps, 'schema'> & {
8
+ type EditorProps = YamlEditorProps & {
9
9
  ref: React.RefObject<YamlEditorHandle>;
10
- schema: JSONSchema7 | null;
11
10
  };
12
11
  export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = UseFormPropsCore<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & {
13
12
  submitOnEnter?: boolean;
@@ -32,7 +31,7 @@ export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TErr
32
31
  onClick: () => void;
33
32
  };
34
33
  editorProps: EditorProps;
35
- schema: JSONSchema7 | null;
34
+ schemas: JSONSchema7[] | null;
36
35
  isLoadingSchema: boolean;
37
36
  loadSchemaError: Error | null;
38
37
  fetchSchema: () => void;
@@ -12,7 +12,7 @@ type Props = {
12
12
  onEditorCreate?: (editor: monaco.editor.IStandaloneCodeEditor) => void;
13
13
  onBlur?: () => void;
14
14
  getInstance?: (ins: monaco.editor.IStandaloneCodeEditor) => void;
15
- schema?: JSONSchema7;
15
+ schemas?: JSONSchema7[] | null;
16
16
  readOnly?: boolean;
17
17
  };
18
18
  declare const MonacoYamlEditor: React.FC<Props>;
@@ -6,7 +6,7 @@ export type YamlEditorProps = {
6
6
  title?: string;
7
7
  defaultValue?: string;
8
8
  errorMsgs?: string[];
9
- schema: JSONSchema7;
9
+ schemas?: JSONSchema7[] | null;
10
10
  id?: string;
11
11
  className?: string;
12
12
  height?: string;
@@ -10,5 +10,12 @@ type UseSchemaResult = {
10
10
  error: Error | null;
11
11
  fetchSchema: () => void;
12
12
  };
13
+ export declare function useApiGroupSchema(apiGroups: string[]): {
14
+ fetchSchema: () => Promise<void>;
15
+ schemas: JSONSchema7[] | null;
16
+ schemasMap: Record<string, JSONSchema7[]>;
17
+ loading: boolean;
18
+ error: Error | null;
19
+ };
13
20
  export declare function useSchema(options?: UseSchemaOptions): UseSchemaResult;
14
21
  export {};
package/lib/src/i18n.d.ts CHANGED
@@ -173,6 +173,7 @@ export declare const resources: {
173
173
  pv_phase_failed: string;
174
174
  pv_phase_pending: string;
175
175
  exec_pod: string;
176
+ search: string;
176
177
  };
177
178
  };
178
179
  'zh-CN': {
@@ -9,3 +9,4 @@ export * from './types';
9
9
  export * from './contexts';
10
10
  export * from './models';
11
11
  export * from './plugins';
12
+ export * from './utils';
@@ -170,6 +170,7 @@ declare const _default: {
170
170
  pv_phase_failed: string;
171
171
  pv_phase_pending: string;
172
172
  exec_pod: string;
173
+ search: string;
173
174
  };
174
175
  };
175
176
  export default _default;
@@ -29,17 +29,12 @@ interface OpenAPIResponse {
29
29
  };
30
30
  }
31
31
  declare class K8sOpenAPI {
32
- resourceBasePath: string;
33
- response: OpenAPIResponse | null;
34
- apiVersion: string;
32
+ private resourceBasePath;
33
+ private apiVersion;
34
+ private schemas;
35
35
  constructor(resourceBasePath: string);
36
- fetch(): Promise<OpenAPIResponse>;
37
- findSchema(kind: string): Promise<(JSONSchema7 & {
38
- 'x-kubernetes-group-version-kind': {
39
- group: string;
40
- kind: string;
41
- version: string;
42
- }[];
43
- }) | undefined>;
36
+ fetch(): Promise<Array<OpenAPIResponse['components']['schemas'][string]> | null>;
37
+ findSchema(kind: string): JSONSchema7 | undefined;
38
+ private processSchemas;
44
39
  }
45
40
  export default K8sOpenAPI;
@@ -12,6 +12,7 @@ type ResolveOptions = {
12
12
  fields: string[];
13
13
  xProperty: boolean;
14
14
  };
15
+ prePath?: string;
15
16
  };
16
17
  export declare function resolveRef(schema: JSONSchema7, schemas: Record<string, JSONSchema7>, options: ResolveOptions): JSONSchema7;
17
18
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.1.5-alpha.0",
3
+ "version": "0.1.5-alpha.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
package/lib/App.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare function App(): JSX.Element;
2
- export default App;