@dovetail-v2/refine 0.0.12 → 0.0.14-beta.0

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 (67) hide show
  1. package/dist/{MonacoYamlDiffEditor.6b29d662.js → MonacoYamlDiffEditor.8847f437.js} +3 -4
  2. package/dist/{index.01461ca8.js → index.0c2122ef.js} +8408 -3450
  3. package/dist/refine.js +82 -71
  4. package/dist/refine.umd.cjs +8330 -3373
  5. package/dist/style.css +1440 -1
  6. package/lib/src/Dovetail.d.ts +5 -1
  7. package/lib/src/components/CronJobDropdown/index.d.ts +2 -2
  8. package/lib/src/components/DrawerShow/DrawerShow.d.ts +4 -5
  9. package/lib/src/components/ErrorContent/index.d.ts +12 -0
  10. package/lib/src/components/EventsTable/EventsTable.d.ts +2 -0
  11. package/lib/src/components/EventsTable/index.d.ts +1 -0
  12. package/lib/src/components/K8sDropdown/index.d.ts +2 -2
  13. package/lib/src/components/ListPage/index.d.ts +1 -1
  14. package/lib/src/components/PageShow/PageShow.d.ts +5 -6
  15. package/lib/src/components/PodLog/index.d.ts +6 -0
  16. package/lib/src/components/ResourceCRUD/create/index.d.ts +5 -5
  17. package/lib/src/components/ResourceCRUD/list/index.d.ts +4 -5
  18. package/lib/src/components/ResourceCRUD/show/index.d.ts +5 -6
  19. package/lib/src/components/ShowContent/ShowContent.d.ts +5 -6
  20. package/lib/src/components/ShowContent/fields.d.ts +13 -10
  21. package/lib/src/components/Table/index.d.ts +6 -2
  22. package/lib/src/components/WorkloadDropdown/index.d.ts +2 -2
  23. package/lib/src/components/WorkloadReplicas/index.d.ts +1 -1
  24. package/lib/src/components/YamlEditor/MonacoYamlEditor.d.ts +1 -1
  25. package/lib/src/components/YamlEditor/YamlEditorComponent.d.ts +2 -1
  26. package/lib/src/components/YamlForm/index.d.ts +6 -0
  27. package/lib/src/components/index.d.ts +1 -0
  28. package/lib/src/constants/k8s.d.ts +22 -0
  29. package/lib/src/contexts/component.d.ts +6 -0
  30. package/lib/src/contexts/global-store.d.ts +6 -0
  31. package/lib/src/contexts/index.d.ts +1 -0
  32. package/lib/src/hooks/index.d.ts +1 -0
  33. package/lib/src/hooks/useDownloadYAML.d.ts +2 -2
  34. package/lib/src/hooks/useEagleForm.d.ts +16 -9
  35. package/lib/src/hooks/useEagleTable/columns.d.ts +13 -13
  36. package/lib/src/hooks/useEagleTable/useEagleTable.d.ts +7 -8
  37. package/lib/src/hooks/useGlobalStore.d.ts +3 -0
  38. package/lib/src/hooks/useK8sYamlEditor.d.ts +5 -0
  39. package/lib/src/hooks/useSchema.d.ts +9 -2
  40. package/lib/src/i18n.d.ts +20 -0
  41. package/lib/src/index.d.ts +2 -1
  42. package/lib/src/locales/en-US/index.d.ts +3 -0
  43. package/lib/src/locales/zh-CN/index.d.ts +17 -0
  44. package/lib/src/model/pod-model.d.ts +2 -0
  45. package/lib/src/models/cronjob-model.d.ts +14 -0
  46. package/lib/src/models/index.d.ts +8 -0
  47. package/lib/src/models/job-model.d.ts +15 -0
  48. package/lib/src/models/pod-metrics-model.d.ts +9 -0
  49. package/lib/src/models/pod-model.d.ts +20 -0
  50. package/lib/src/models/resource-model.d.ts +21 -0
  51. package/lib/src/models/types/index.d.ts +1 -0
  52. package/lib/src/models/types/metric.d.ts +25 -0
  53. package/lib/src/models/workload-base-model.d.ts +13 -0
  54. package/lib/src/models/workload-model.d.ts +17 -0
  55. package/lib/src/pages/configmaps/index.d.ts +3 -3
  56. package/lib/src/pages/jobs/index.d.ts +3 -4
  57. package/lib/src/pages/secrets/index.d.ts +3 -3
  58. package/lib/src/pages/services/index.d.ts +3 -0
  59. package/lib/src/plugins/index.d.ts +2 -0
  60. package/lib/src/plugins/model-plugin.d.ts +12 -0
  61. package/lib/src/plugins/relation-plugin.d.ts +27 -0
  62. package/lib/src/plugins/type.d.ts +8 -0
  63. package/lib/src/types/index.d.ts +0 -1
  64. package/lib/src/types/resource.d.ts +9 -21
  65. package/lib/src/utils/match-selector.d.ts +3 -0
  66. package/lib/src/utils/selector.d.ts +3 -0
  67. package/package.json +18 -6
@@ -10,4 +10,6 @@ export declare class PodModel extends WorkloadModel<Pod> {
10
10
  get imageNames(): string[];
11
11
  get restartCount(): number;
12
12
  get readyDisplay(): string;
13
+ get readyContainerCount(): number | undefined;
14
+ get containerCount(): number | undefined;
13
15
  }
@@ -0,0 +1,14 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import { CronJob } from 'kubernetes-types/batch/v1';
3
+ import { WorkloadBaseModel } from './workload-base-model';
4
+ type RequiredCronJob = Required<CronJob> & Unstructured;
5
+ export declare class CronJobModel extends WorkloadBaseModel {
6
+ _rawYaml: RequiredCronJob;
7
+ _globalStore: GlobalStore;
8
+ spec?: RequiredCronJob['spec'];
9
+ status?: RequiredCronJob['status'];
10
+ constructor(_rawYaml: RequiredCronJob, _globalStore: GlobalStore);
11
+ suspend(): RequiredCronJob;
12
+ resume(): RequiredCronJob;
13
+ }
14
+ export {};
@@ -0,0 +1,8 @@
1
+ export * from './job-model';
2
+ export * from './workload-model';
3
+ export * from './workload-base-model';
4
+ export * from './pod-model';
5
+ export * from './pod-metrics-model';
6
+ export * from './resource-model';
7
+ export * from './workload-model';
8
+ export * from './cronjob-model';
@@ -0,0 +1,15 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import { Job } from 'kubernetes-types/batch/v1';
3
+ import { WorkloadBaseModel } from './workload-base-model';
4
+ type RequiredJob = Required<Job> & Unstructured;
5
+ export declare class JobModel extends WorkloadBaseModel {
6
+ _rawYaml: RequiredJob;
7
+ _globalStore: GlobalStore;
8
+ spec?: RequiredJob['spec'];
9
+ status?: RequiredJob['status'];
10
+ constructor(_rawYaml: RequiredJob, _globalStore: GlobalStore);
11
+ get duration(): number;
12
+ get durationDisplay(): string | undefined;
13
+ get completionsDisplay(): string;
14
+ }
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import { GlobalStore } from 'k8s-api-provider';
2
+ import { ResourceModel } from './resource-model';
3
+ import { PodMetrics, ResourceQuantity } from './types/metric';
4
+ export declare class PodMetricsModel extends ResourceModel<PodMetrics> {
5
+ _rawYaml: PodMetrics;
6
+ _globalStore: GlobalStore;
7
+ usage: ResourceQuantity;
8
+ constructor(_rawYaml: PodMetrics, _globalStore: GlobalStore);
9
+ }
@@ -0,0 +1,20 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import type { Pod } from 'kubernetes-types/core/v1';
3
+ import { ResourceQuantity } from './types/metric';
4
+ import { WorkloadBaseModel } from './workload-base-model';
5
+ type RequiredPod = Required<Pod> & Unstructured;
6
+ export declare class PodModel extends WorkloadBaseModel {
7
+ _rawYaml: RequiredPod;
8
+ _globalStore: GlobalStore;
9
+ request: ResourceQuantity;
10
+ limit: ResourceQuantity;
11
+ spec?: RequiredPod['spec'];
12
+ status?: RequiredPod['status'];
13
+ constructor(_rawYaml: RequiredPod, _globalStore: GlobalStore);
14
+ get imageNames(): string[];
15
+ get restartCount(): number;
16
+ get readyDisplay(): string;
17
+ get readyContainerCount(): number | undefined;
18
+ get containerCount(): number;
19
+ }
20
+ export {};
@@ -0,0 +1,21 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ export type IResourceModel = Unstructured & ResourceModel;
3
+ export declare class ResourceModel<T extends Unstructured = Unstructured> {
4
+ _rawYaml: T;
5
+ _globalStore: GlobalStore;
6
+ id: string;
7
+ apiVersion: T['apiVersion'];
8
+ kind: T['kind'];
9
+ metadata: T['metadata'];
10
+ constructor(_rawYaml: T, _globalStore: GlobalStore);
11
+ init(): Promise<void>;
12
+ get name(): string | undefined;
13
+ get namespace(): string | undefined;
14
+ get labels(): {
15
+ [name: string]: string;
16
+ } | undefined;
17
+ get annotations(): {
18
+ [name: string]: string;
19
+ } | undefined;
20
+ restore(): T;
21
+ }
@@ -0,0 +1 @@
1
+ export * from './metric';
@@ -0,0 +1,25 @@
1
+ import { Unstructured } from 'k8s-api-provider';
2
+ type Quantity = string;
3
+ export type ContainerMetrics = {
4
+ name: string;
5
+ usage: {
6
+ cpu?: Quantity;
7
+ memory?: Quantity;
8
+ };
9
+ };
10
+ export type PodMetrics = {
11
+ timestamp: string;
12
+ window: string;
13
+ containers: ContainerMetrics[];
14
+ } & Unstructured;
15
+ export type ResourceQuantity = {
16
+ cpu: {
17
+ si: string;
18
+ value: number;
19
+ };
20
+ memory: {
21
+ si: string;
22
+ value: number;
23
+ };
24
+ };
25
+ export {};
@@ -0,0 +1,13 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import type { DaemonSet, Deployment, StatefulSet } from 'kubernetes-types/apps/v1';
3
+ import type { CronJob, Job } from 'kubernetes-types/batch/v1';
4
+ import { Pod } from 'kubernetes-types/core/v1';
5
+ import { ResourceModel } from './resource-model';
6
+ type WorkloadBaseTypes = Required<Deployment | StatefulSet | Job | DaemonSet | CronJob | Pod> & Unstructured;
7
+ export declare class WorkloadBaseModel extends ResourceModel<WorkloadBaseTypes> {
8
+ _rawYaml: WorkloadBaseTypes;
9
+ _globalStore: GlobalStore;
10
+ constructor(_rawYaml: WorkloadBaseTypes, _globalStore: GlobalStore);
11
+ get imageNames(): string[];
12
+ }
13
+ export {};
@@ -0,0 +1,17 @@
1
+ import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import type { DaemonSet, Deployment, StatefulSet } from 'kubernetes-types/apps/v1';
3
+ import { WorkloadBaseModel } from './workload-base-model';
4
+ type WorkloadTypes = Required<Deployment | StatefulSet | DaemonSet> & Unstructured;
5
+ export declare class WorkloadModel extends WorkloadBaseModel {
6
+ _rawYaml: WorkloadTypes;
7
+ _globalStore: GlobalStore;
8
+ restarts: number;
9
+ spec?: WorkloadTypes['spec'];
10
+ status?: WorkloadTypes['status'];
11
+ constructor(_rawYaml: WorkloadTypes, _globalStore: GlobalStore);
12
+ init(): Promise<void>;
13
+ private getRestarts;
14
+ redeploy(): WorkloadTypes;
15
+ scale(value: number): WorkloadTypes;
16
+ }
17
+ export {};
@@ -1,3 +1,3 @@
1
- import { ResourceModel } from '../../model';
2
- import { Resource, ResourceConfig } from '../../types';
3
- export declare const ConfigMapConfig: ResourceConfig<Resource, ResourceModel>;
1
+ import { ResourceModel } from '../../models';
2
+ import { ResourceConfig } from '../../types';
3
+ export declare const ConfigMapConfig: ResourceConfig<ResourceModel>;
@@ -1,4 +1,3 @@
1
- import { Job } from 'kubernetes-types/batch/v1';
2
- import { JobModel } from '../../model';
3
- import { ResourceConfig, WithId } from '../../types';
4
- export declare const JobConfig: ResourceConfig<WithId<Job>, JobModel>;
1
+ import { JobModel } from '../../models';
2
+ import { ResourceConfig } from '../../types';
3
+ export declare const JobConfig: ResourceConfig<JobModel>;
@@ -1,3 +1,3 @@
1
- import { ResourceModel } from '../../model';
2
- import { Resource, ResourceConfig } from '../../types';
3
- export declare const SecretsConfig: ResourceConfig<Resource, ResourceModel>;
1
+ import { ResourceModel } from '../../models';
2
+ import { ResourceConfig } from '../../types';
3
+ export declare const SecretsConfig: ResourceConfig<ResourceModel>;
@@ -0,0 +1,3 @@
1
+ import { ResourceModel } from '../../models';
2
+ import { ResourceConfig } from '../../types';
3
+ export declare const ServicesConfig: ResourceConfig<ResourceModel>;
@@ -0,0 +1,2 @@
1
+ import { IProviderPlugin } from 'k8s-api-provider';
2
+ export declare const ProviderPlugins: IProviderPlugin<import("k8s-api-provider").Unstructured>[];
@@ -0,0 +1,12 @@
1
+ import { GlobalStore, Unstructured, UnstructuredList, IProviderPlugin, DataList } from 'k8s-api-provider';
2
+ import { ResourceModel } from '../models';
3
+ declare class ModelPlugin implements IProviderPlugin<ResourceModel> {
4
+ _globalStore?: GlobalStore;
5
+ init(globalStore: GlobalStore): void;
6
+ processData(res: UnstructuredList): Promise<DataList<ResourceModel<Unstructured>>>;
7
+ processItem(item: Unstructured): Promise<ResourceModel>;
8
+ restoreData(res: DataList<ResourceModel>): UnstructuredList;
9
+ restoreItem(item: ResourceModel): Unstructured;
10
+ }
11
+ export declare const modelPlugin: ModelPlugin;
12
+ export {};
@@ -0,0 +1,27 @@
1
+ import { GlobalStore, Unstructured, UnstructuredList } from 'k8s-api-provider';
2
+ import { LabelSelector, ObjectMeta } from 'kubernetes-types/meta/v1';
3
+ import { ResourceModel } from '../models';
4
+ export type Relation = {
5
+ kind: string;
6
+ apiVersion: string;
7
+ type: 'creates' | 'uses' | 'applies' | 'owner' | 'selects';
8
+ inbound: boolean;
9
+ name?: string;
10
+ namespace?: string;
11
+ selector?: LabelSelector;
12
+ };
13
+ export type ExtendObjectMeta = ObjectMeta & {
14
+ relations?: Relation[];
15
+ };
16
+ declare class RelationPlugin {
17
+ private globalStore?;
18
+ init(globalStore: GlobalStore): void;
19
+ processData(res: UnstructuredList): Promise<UnstructuredList>;
20
+ processItem(item: Unstructured): Promise<ResourceModel>;
21
+ restoreData(res: UnstructuredList): UnstructuredList;
22
+ restoreItem(item: Unstructured): Unstructured;
23
+ private processPodSelector;
24
+ private appendRelation;
25
+ }
26
+ export declare const relationPlugin: RelationPlugin;
27
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Unstructured } from 'k8s-api-provider';
2
+ import { ListMeta } from 'kubernetes-types/meta/v1';
3
+ export type DataList<Output extends Unstructured = Unstructured> = {
4
+ apiVersion: string;
5
+ kind: string;
6
+ metadata: ListMeta;
7
+ items: Array<Unstructured & Output>;
8
+ };
@@ -1,2 +1 @@
1
1
  export * from './resource';
2
- export * from './metric';
@@ -1,41 +1,29 @@
1
1
  /// <reference types="react" />
2
- import { i18n } from 'i18next';
3
- import { ObjectMeta } from 'kubernetes-types/meta/v1';
4
2
  import { ShowField } from '../components/ShowContent';
5
3
  import { Column } from '../components/Table';
6
- import { ResourceModel } from '../model';
4
+ import { ResourceModel } from '../models';
7
5
  export declare enum RESOURCE_GROUP {
8
6
  WORKLOAD = "WORKLOAD",
9
- CORE = "CORE"
7
+ STORAGE = "STORAGE",
8
+ NETWORK = "NETWORK",
9
+ CLUSTER = "CLUSTER"
10
10
  }
11
11
  export type WithId<T> = T & {
12
12
  id: string;
13
13
  };
14
- export interface Resource {
15
- id: string;
16
- apiVersion?: string;
17
- /**
18
- * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
19
- */
20
- kind?: string;
21
- /**
22
- * Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
23
- */
24
- metadata?: ObjectMeta;
25
- }
26
- export type ResourceConfig<Raw extends Resource = Resource, Model extends ResourceModel = ResourceModel> = {
14
+ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
27
15
  name: string;
28
16
  kind: string;
29
17
  basePath: string;
30
18
  apiVersion: string;
31
19
  label: string;
32
20
  parent?: RESOURCE_GROUP;
33
- formatter?: (v: Raw) => Model;
21
+ formatter?: (v: Model) => Model;
34
22
  initValue?: Record<string, unknown>;
35
- columns?: (i18n: i18n) => Column<Model>[];
36
- showFields?: (i18n: i18n) => ShowField<Model>[][];
23
+ columns?: () => Column<Model>[];
24
+ showFields?: () => ShowField<Model>[][];
37
25
  Dropdown?: React.FC<{
38
- data: Model;
26
+ record: Model;
39
27
  }>;
40
28
  isCustom?: boolean;
41
29
  };
@@ -0,0 +1,3 @@
1
+ import { LabelSelector } from 'kubernetes-types/meta/v1';
2
+ import { PodModel } from '../models/pod-model';
3
+ export declare function matchSelector(pod: PodModel, selector: LabelSelector): boolean;
@@ -0,0 +1,3 @@
1
+ import { LabelSelector } from 'kubernetes-types/meta/v1';
2
+ import { PodModel } from '../models';
3
+ export declare function matchSelector(pod: PodModel, selector: LabelSelector): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.0.12",
3
+ "version": "0.0.14-beta.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -12,13 +12,15 @@
12
12
  "dependencies": {
13
13
  "@cloudtower/eagle": "^0.26.11",
14
14
  "@cloudtower/icons-react": "^0.26.11",
15
+ "@patternfly/react-core": "^5.1.1",
16
+ "@patternfly/react-log-viewer": "^5.0.0",
15
17
  "@refinedev/core": "^4.38.0",
16
18
  "@refinedev/inferencer": "^4.5.4",
17
19
  "antd": "4.5.0",
18
20
  "dayjs": "^1.11.10",
19
- "i18next": "^20.1.0",
21
+ "i18next": "^23.2.3",
20
22
  "js-yaml": "^4.1.0",
21
- "k8s-api-provider": "^0.0.6",
23
+ "k8s-api-provider": "0.0.15-beta.0",
22
24
  "ky": "^0.33.3",
23
25
  "lodash-es": "^4.17.21",
24
26
  "mitt": "^3.0.1",
@@ -34,11 +36,13 @@
34
36
  "devDependencies": {
35
37
  "@babel/core": "^7.4.0",
36
38
  "@babel/preset-env": "^7.1.6",
39
+ "@kubernetes/client-node": "^0.20.0",
37
40
  "@linaria/core": "^4.5.4",
38
41
  "@linaria/react": "^4.5.4",
39
42
  "@linaria/vite": "^4.5.4",
40
43
  "@playwright/test": "^1.39.0",
41
44
  "@refinedev/cli": "^2.9.0",
45
+ "@types/body-parser": "^1.19.5",
42
46
  "@types/js-yaml": "^4.0.6",
43
47
  "@types/json-schema": "^7.0.13",
44
48
  "@types/lodash-es": "^4.17.9",
@@ -50,18 +54,24 @@
50
54
  "@typescript-eslint/eslint-plugin": "^6.7.5",
51
55
  "@typescript-eslint/parser": "^6.7.5",
52
56
  "@vitejs/plugin-react": "^4.0.0",
57
+ "body-parser": "^1.20.2",
53
58
  "eslint": "^8.38.0",
54
59
  "eslint-plugin-react-hooks": "^4.6.0",
55
60
  "eslint-plugin-react-refresh": "^0.3.4",
56
61
  "kubernetes-types": "^1.26.0",
57
- "vite": "^3.2.7"
62
+ "vite": "^3.2.7",
63
+ "vite-plugin-commonjs": "^0.10.0",
64
+ "jest": "^29",
65
+ "ts-jest": "^29",
66
+ "@types/jest": "^29",
67
+ "@babel/preset-typescript": "^7.10.4"
58
68
  },
59
69
  "peerDependencies": {
60
70
  "@cloudtower/eagle": "^0.26.9",
61
71
  "@cloudtower/icons-react": "^0.26.9",
62
72
  "@refinedev/core": "^4.38.0",
63
73
  "antd": "4.5.0",
64
- "i18next": "^20.1.0",
74
+ "i18next": "^23.2.3",
65
75
  "react": "^16.12.0",
66
76
  "react-dom": "^16.12.0",
67
77
  "react-router-dom": "^5.1.2"
@@ -72,7 +82,9 @@
72
82
  "build": "tsc --emitDeclarationOnly && vite build",
73
83
  "preview": "refine start",
74
84
  "refine": "refine",
75
- "test": "npx playwright test --workers 1",
85
+ "unit-test": "jest",
86
+ "playwright-test": "npx playwright test --workers 1",
87
+ "test": "yarn unit-test && yarn playwright-test",
76
88
  "lint": "eslint src --ext .ts,.tsx"
77
89
  },
78
90
  "browserslist": {