mod-arch-core 1.0.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 (178) hide show
  1. package/README.md +44 -0
  2. package/dist/__tests__/__mocks__/mockGenericResponse.d.ts +8 -0
  3. package/dist/__tests__/__mocks__/mockGenericResponse.d.ts.map +1 -0
  4. package/dist/__tests__/__mocks__/mockGenericResponse.js +6 -0
  5. package/dist/__tests__/__mocks__/mockGenericResponse.js.map +1 -0
  6. package/dist/__tests__/__mocks__/styleMock.d.ts +2 -0
  7. package/dist/__tests__/__mocks__/styleMock.d.ts.map +1 -0
  8. package/dist/__tests__/__mocks__/styleMock.js +3 -0
  9. package/dist/__tests__/__mocks__/styleMock.js.map +1 -0
  10. package/dist/__tests__/unit/jest.setup.d.ts +2 -0
  11. package/dist/__tests__/unit/jest.setup.d.ts.map +1 -0
  12. package/dist/__tests__/unit/jest.setup.js +48 -0
  13. package/dist/__tests__/unit/jest.setup.js.map +1 -0
  14. package/dist/__tests__/unit/testUtils/hooks.d.ts +80 -0
  15. package/dist/__tests__/unit/testUtils/hooks.d.ts.map +1 -0
  16. package/dist/__tests__/unit/testUtils/hooks.js +126 -0
  17. package/dist/__tests__/unit/testUtils/hooks.js.map +1 -0
  18. package/dist/__tests__/unit/testUtils/hooks.spec.d.ts +2 -0
  19. package/dist/__tests__/unit/testUtils/hooks.spec.d.ts.map +1 -0
  20. package/dist/__tests__/unit/testUtils/hooks.spec.js +192 -0
  21. package/dist/__tests__/unit/testUtils/hooks.spec.js.map +1 -0
  22. package/dist/api/__tests__/errorUtils.spec.d.ts +2 -0
  23. package/dist/api/__tests__/errorUtils.spec.d.ts.map +1 -0
  24. package/dist/api/__tests__/errorUtils.spec.js +27 -0
  25. package/dist/api/__tests__/errorUtils.spec.js.map +1 -0
  26. package/dist/api/apiUtils.d.ts +16 -0
  27. package/dist/api/apiUtils.d.ts.map +1 -0
  28. package/dist/api/apiUtils.js +96 -0
  29. package/dist/api/apiUtils.js.map +1 -0
  30. package/dist/api/const.d.ts +3 -0
  31. package/dist/api/const.d.ts.map +1 -0
  32. package/dist/api/const.js +4 -0
  33. package/dist/api/const.js.map +1 -0
  34. package/dist/api/errorUtils.d.ts +2 -0
  35. package/dist/api/errorUtils.d.ts.map +1 -0
  36. package/dist/api/errorUtils.js +22 -0
  37. package/dist/api/errorUtils.js.map +1 -0
  38. package/dist/api/index.d.ts +7 -0
  39. package/dist/api/index.d.ts.map +1 -0
  40. package/dist/api/index.js +8 -0
  41. package/dist/api/index.js.map +1 -0
  42. package/dist/api/k8s.d.ts +10 -0
  43. package/dist/api/k8s.d.ts.map +1 -0
  44. package/dist/api/k8s.js +16 -0
  45. package/dist/api/k8s.js.map +1 -0
  46. package/dist/api/types.d.ts +19 -0
  47. package/dist/api/types.d.ts.map +1 -0
  48. package/dist/api/types.js +2 -0
  49. package/dist/api/types.js.map +1 -0
  50. package/dist/api/useAPIState.d.ts +3 -0
  51. package/dist/api/useAPIState.d.ts.map +1 -0
  52. package/dist/api/useAPIState.js +22 -0
  53. package/dist/api/useAPIState.js.map +1 -0
  54. package/dist/config/transform.file.d.ts +3 -0
  55. package/dist/config/transform.file.d.ts.map +1 -0
  56. package/dist/config/transform.file.js +4 -0
  57. package/dist/config/transform.file.js.map +1 -0
  58. package/dist/config/transform.style.d.ts +2 -0
  59. package/dist/config/transform.style.d.ts.map +1 -0
  60. package/dist/config/transform.style.js +4 -0
  61. package/dist/config/transform.style.js.map +1 -0
  62. package/dist/context/BrowserStorageContext.d.ts +25 -0
  63. package/dist/context/BrowserStorageContext.d.ts.map +1 -0
  64. package/dist/context/BrowserStorageContext.js +97 -0
  65. package/dist/context/BrowserStorageContext.js.map +1 -0
  66. package/dist/context/ModularArchContext.d.ts +20 -0
  67. package/dist/context/ModularArchContext.d.ts.map +1 -0
  68. package/dist/context/ModularArchContext.js +67 -0
  69. package/dist/context/ModularArchContext.js.map +1 -0
  70. package/dist/context/NotificationContext.d.ts +15 -0
  71. package/dist/context/NotificationContext.d.ts.map +1 -0
  72. package/dist/context/NotificationContext.js +43 -0
  73. package/dist/context/NotificationContext.js.map +1 -0
  74. package/dist/context/__tests__/ModularArchContext.test.d.ts +2 -0
  75. package/dist/context/__tests__/ModularArchContext.test.d.ts.map +1 -0
  76. package/dist/context/__tests__/ModularArchContext.test.js +331 -0
  77. package/dist/context/__tests__/ModularArchContext.test.js.map +1 -0
  78. package/dist/context/index.d.ts +4 -0
  79. package/dist/context/index.d.ts.map +1 -0
  80. package/dist/context/index.js +4 -0
  81. package/dist/context/index.js.map +1 -0
  82. package/dist/hooks/__tests__/useModularArchContext.test.d.ts +2 -0
  83. package/dist/hooks/__tests__/useModularArchContext.test.d.ts.map +1 -0
  84. package/dist/hooks/__tests__/useModularArchContext.test.js +39 -0
  85. package/dist/hooks/__tests__/useModularArchContext.test.js.map +1 -0
  86. package/dist/hooks/__tests__/useNamespaces.test.d.ts +2 -0
  87. package/dist/hooks/__tests__/useNamespaces.test.d.ts.map +1 -0
  88. package/dist/hooks/__tests__/useNamespaces.test.js +62 -0
  89. package/dist/hooks/__tests__/useNamespaces.test.js.map +1 -0
  90. package/dist/hooks/index.d.ts +8 -0
  91. package/dist/hooks/index.d.ts.map +1 -0
  92. package/dist/hooks/index.js +8 -0
  93. package/dist/hooks/index.js.map +1 -0
  94. package/dist/hooks/useModularArchContext.d.ts +5 -0
  95. package/dist/hooks/useModularArchContext.d.ts.map +1 -0
  96. package/dist/hooks/useModularArchContext.js +11 -0
  97. package/dist/hooks/useModularArchContext.js.map +1 -0
  98. package/dist/hooks/useNamespaceSelector.d.ts +10 -0
  99. package/dist/hooks/useNamespaceSelector.d.ts.map +1 -0
  100. package/dist/hooks/useNamespaceSelector.js +13 -0
  101. package/dist/hooks/useNamespaceSelector.js.map +1 -0
  102. package/dist/hooks/useNamespaces.d.ts +6 -0
  103. package/dist/hooks/useNamespaces.d.ts.map +1 -0
  104. package/dist/hooks/useNamespaces.js +34 -0
  105. package/dist/hooks/useNamespaces.js.map +1 -0
  106. package/dist/hooks/useNotification.d.ts +18 -0
  107. package/dist/hooks/useNotification.d.ts.map +1 -0
  108. package/dist/hooks/useNotification.js +74 -0
  109. package/dist/hooks/useNotification.js.map +1 -0
  110. package/dist/hooks/useQueryParamNamespaces.d.ts +2 -0
  111. package/dist/hooks/useQueryParamNamespaces.d.ts.map +1 -0
  112. package/dist/hooks/useQueryParamNamespaces.js +9 -0
  113. package/dist/hooks/useQueryParamNamespaces.js.map +1 -0
  114. package/dist/hooks/useSettings.d.ts +9 -0
  115. package/dist/hooks/useSettings.d.ts.map +1 -0
  116. package/dist/hooks/useSettings.js +72 -0
  117. package/dist/hooks/useSettings.js.map +1 -0
  118. package/dist/hooks/useTimeBasedRefresh.d.ts +4 -0
  119. package/dist/hooks/useTimeBasedRefresh.d.ts.map +1 -0
  120. package/dist/hooks/useTimeBasedRefresh.js +32 -0
  121. package/dist/hooks/useTimeBasedRefresh.js.map +1 -0
  122. package/dist/index.d.ts +6 -0
  123. package/dist/index.d.ts.map +1 -0
  124. package/dist/index.js +11 -0
  125. package/dist/index.js.map +1 -0
  126. package/dist/jest.config.d.ts +21 -0
  127. package/dist/jest.config.d.ts.map +1 -0
  128. package/dist/jest.config.js +41 -0
  129. package/dist/jest.config.js.map +1 -0
  130. package/dist/types/common.d.ts +68 -0
  131. package/dist/types/common.d.ts.map +1 -0
  132. package/dist/types/common.js +14 -0
  133. package/dist/types/common.js.map +1 -0
  134. package/dist/types/index.d.ts +3 -0
  135. package/dist/types/index.d.ts.map +1 -0
  136. package/dist/types/index.js +5 -0
  137. package/dist/types/index.js.map +1 -0
  138. package/dist/types/typeHelpers.d.ts +147 -0
  139. package/dist/types/typeHelpers.d.ts.map +1 -0
  140. package/dist/types/typeHelpers.js +2 -0
  141. package/dist/types/typeHelpers.js.map +1 -0
  142. package/dist/utilities/appUtils.d.ts +2 -0
  143. package/dist/utilities/appUtils.d.ts.map +1 -0
  144. package/dist/utilities/appUtils.js +4 -0
  145. package/dist/utilities/appUtils.js.map +1 -0
  146. package/dist/utilities/const.d.ts +8 -0
  147. package/dist/utilities/const.d.ts.map +1 -0
  148. package/dist/utilities/const.js +9 -0
  149. package/dist/utilities/const.js.map +1 -0
  150. package/dist/utilities/index.d.ts +9 -0
  151. package/dist/utilities/index.d.ts.map +1 -0
  152. package/dist/utilities/index.js +10 -0
  153. package/dist/utilities/index.js.map +1 -0
  154. package/dist/utilities/useDeepCompareMemoize.d.ts +2 -0
  155. package/dist/utilities/useDeepCompareMemoize.d.ts.map +1 -0
  156. package/dist/utilities/useDeepCompareMemoize.js +10 -0
  157. package/dist/utilities/useDeepCompareMemoize.js.map +1 -0
  158. package/dist/utilities/useEventListener.d.ts +2 -0
  159. package/dist/utilities/useEventListener.d.ts.map +1 -0
  160. package/dist/utilities/useEventListener.js +10 -0
  161. package/dist/utilities/useEventListener.js.map +1 -0
  162. package/dist/utilities/useFetchState.d.ts +92 -0
  163. package/dist/utilities/useFetchState.d.ts.map +1 -0
  164. package/dist/utilities/useFetchState.js +153 -0
  165. package/dist/utilities/useFetchState.js.map +1 -0
  166. package/dist/utilities/useGenericObjectState.d.ts +9 -0
  167. package/dist/utilities/useGenericObjectState.d.ts.map +1 -0
  168. package/dist/utilities/useGenericObjectState.js +14 -0
  169. package/dist/utilities/useGenericObjectState.js.map +1 -0
  170. package/dist/utilities/useMakeFetchObject.d.ts +4 -0
  171. package/dist/utilities/useMakeFetchObject.d.ts.map +1 -0
  172. package/dist/utilities/useMakeFetchObject.js +6 -0
  173. package/dist/utilities/useMakeFetchObject.js.map +1 -0
  174. package/dist/utilities/utils.d.ts +26 -0
  175. package/dist/utilities/utils.d.ts.map +1 -0
  176. package/dist/utilities/utils.js +104 -0
  177. package/dist/utilities/utils.js.map +1 -0
  178. package/package.json +92 -0
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The type `{}` doesn't mean "any empty object", it means "any non-nullish value".
3
+ *
4
+ * Use the `AnyObject` type for objects whose structure is unknown.
5
+ *
6
+ * @see https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492
7
+ */
8
+ export type AnyObject = Record<string, unknown>;
9
+ /**
10
+ * Takes a type and makes all properties partial within it.
11
+ *
12
+ * TODO: Implement the SDK & Patch logic -- this should stop being needed as things will be defined as Patches
13
+ */
14
+ export type RecursivePartial<T> = T extends object ? {
15
+ [P in keyof T]?: RecursivePartial<T[P]>;
16
+ } : T;
17
+ /**
18
+ * Partial only some properties.
19
+ *
20
+ * eg. PartialSome<FooBarBaz, 'foo' | 'bar'>
21
+ */
22
+ export type PartialSome<Type, Keys extends keyof Type> = Pick<Partial<Type>, Keys> & Omit<Type, Keys>;
23
+ /**
24
+ * Unions all values of an object togethers -- antithesis to `keyof myObj`.
25
+ */
26
+ export type ValueOf<T> = T[keyof T];
27
+ /**
28
+ * Never allow any properties of `Type`.
29
+ *
30
+ * Utility type, probably never a reason to export.
31
+ */
32
+ type Never<Type> = {
33
+ [K in keyof Type]?: never;
34
+ };
35
+ /**
36
+ * Either TypeA properties or TypeB properties -- never both.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * type MyType = EitherNotBoth<{ foo: boolean }, { bar: boolean }>;
41
+ *
42
+ * // Valid usages:
43
+ * const objA: MyType = {
44
+ * foo: true,
45
+ * };
46
+ * const objB: MyType = {
47
+ * bar: true,
48
+ * };
49
+ *
50
+ * // TS Error -- can't have both properties:
51
+ * const objBoth: MyType = {
52
+ * foo: true,
53
+ * bar: true,
54
+ * };
55
+ *
56
+ * // TS Error -- must have at least one property:
57
+ * const objNeither: MyType = {
58
+ * };
59
+ * ```
60
+ */
61
+ export type EitherNotBoth<TypeA, TypeB> = (TypeA & Never<TypeB>) | (TypeB & Never<TypeA>);
62
+ /**
63
+ * Either TypeA properties or TypeB properties or neither of the properties -- never both.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * type MyType = EitherOrBoth<{ foo: boolean }, { bar: boolean }>;
68
+ *
69
+ * // Valid usages:
70
+ * const objA: MyType = {
71
+ * foo: true,
72
+ * };
73
+ * const objB: MyType = {
74
+ * bar: true,
75
+ * };
76
+ * const objBoth: MyType = {
77
+ * foo: true,
78
+ * bar: true,
79
+ * };
80
+ *
81
+ * // TS Error -- can't omit both properties:
82
+ * const objNeither: MyType = {
83
+ * };
84
+ * ```
85
+ */
86
+ export type EitherOrBoth<TypeA, TypeB> = EitherNotBoth<TypeA, TypeB> | (TypeA & TypeB);
87
+ /**
88
+ * Either TypeA properties or TypeB properties or neither of the properties -- never both.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * type MyType = EitherOrNone<{ foo: boolean }, { bar: boolean }>;
93
+ *
94
+ * // Valid usages:
95
+ * const objA: MyType = {
96
+ * foo: true,
97
+ * };
98
+ * const objB: MyType = {
99
+ * bar: true,
100
+ * };
101
+ * const objNeither: MyType = {
102
+ * };
103
+ *
104
+ * // TS Error -- can't have both properties:
105
+ * const objBoth: MyType = {
106
+ * foo: true,
107
+ * bar: true,
108
+ * };
109
+ * ```
110
+ */
111
+ export type EitherOrNone<TypeA, TypeB> = EitherNotBoth<TypeA, TypeB> | (Never<TypeA> & Never<TypeB>);
112
+ type Explode<T> = keyof T extends infer K ? K extends unknown ? {
113
+ [I in keyof T]: I extends K ? T[I] : never;
114
+ } : never : never;
115
+ type AtMostOne<T> = Explode<Partial<T>>;
116
+ type AtLeastOne<T, U = {
117
+ [K in keyof T]: Pick<T, K>;
118
+ }> = Partial<T> & U[keyof U];
119
+ /**
120
+ * Create a type where exactly one of multiple properties must be supplied.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * type Foo = ExactlyOne<{ a: number, b: string, c: boolean}>;
125
+ *
126
+ * // Valid usages:
127
+ * const objA: Foo = {
128
+ * a: 1,
129
+ * };
130
+ * const objB: Foo = {
131
+ * b: 'hi',
132
+ * };
133
+ * const objC: Foo = {
134
+ * c: true,
135
+ * };
136
+ *
137
+ * // TS Error -- can't have more than one property:
138
+ * const objAll: Foo = {
139
+ * a: 1,
140
+ * b: 'hi',
141
+ * c: true,
142
+ * };
143
+ * ```
144
+ */
145
+ export type ExactlyOne<T> = AtMostOne<T> & AtLeastOne<T>;
146
+ export {};
147
+ //# sourceMappingURL=typeHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeHelpers.d.ts","sourceRoot":"","sources":["../../types/typeHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC9C;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACxC,GACD,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,IAAI,SAAS,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAChF,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpC;;;;GAIG;AACH,KAAK,KAAK,CAAC,IAAI,IAAI;KAChB,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,KAAK;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,EAAE,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,EAAE,KAAK,IACjC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,GAC3B,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAGlC,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,MAAM,CAAC,GACrC,CAAC,SAAS,OAAO,GACf;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,GAC9C,KAAK,GACP,KAAK,CAAC;AACV,KAAK,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;CAAE,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=typeHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeHelpers.js","sourceRoot":"","sources":["../../types/typeHelpers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const logout: () => Promise<unknown>;
2
+ //# sourceMappingURL=appUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../utilities/appUtils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,QAAO,OAAO,CAAC,OAAO,CAEyC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const logout = () =>
2
+ /* eslint-disable-next-line no-console */
3
+ fetch('/oauth/sign_out').catch((err) => console.error('Error logging out', err));
4
+ //# sourceMappingURL=appUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appUtils.js","sourceRoot":"","sources":["../../utilities/appUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,GAAqB,EAAE;AAC3C,yCAAyC;AACzC,KAAK,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare enum DeploymentMode {
2
+ Standalone = "standalone",
3
+ Federated = "federated",
4
+ Kubeflow = "kubeflow"
5
+ }
6
+ declare const POLL_INTERVAL = 30000;
7
+ export { POLL_INTERVAL };
8
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../utilities/const.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AAED,QAAA,MAAM,aAAa,QAAQ,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ export var DeploymentMode;
2
+ (function (DeploymentMode) {
3
+ DeploymentMode["Standalone"] = "standalone";
4
+ DeploymentMode["Federated"] = "federated";
5
+ DeploymentMode["Kubeflow"] = "kubeflow";
6
+ })(DeploymentMode || (DeploymentMode = {}));
7
+ const POLL_INTERVAL = 30000;
8
+ export { POLL_INTERVAL };
9
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../utilities/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,2CAAyB,CAAA;IACzB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;AACvB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,aAAa,GAAG,KAAK,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './appUtils';
2
+ export * from './const';
3
+ export * from './useDeepCompareMemoize';
4
+ export * from './useEventListener';
5
+ export * from './useFetchState';
6
+ export * from './useGenericObjectState';
7
+ export * from './useMakeFetchObject';
8
+ export * from './utils';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utilities/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ // Export all utility functions
2
+ export * from './appUtils';
3
+ export * from './const';
4
+ export * from './useDeepCompareMemoize';
5
+ export * from './useEventListener';
6
+ export * from './useFetchState';
7
+ export * from './useGenericObjectState';
8
+ export * from './useMakeFetchObject';
9
+ export * from './utils';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utilities/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const useDeepCompareMemoize: <T>(value: T) => T;
2
+ //# sourceMappingURL=useDeepCompareMemoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeepCompareMemoize.d.ts","sourceRoot":"","sources":["../../utilities/useDeepCompareMemoize.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CAQnD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import * as _ from 'lodash-es';
3
+ export const useDeepCompareMemoize = (value) => {
4
+ const ref = React.useRef(value);
5
+ if (!_.isEqual(value, ref.current)) {
6
+ ref.current = value;
7
+ }
8
+ return ref.current;
9
+ };
10
+ //# sourceMappingURL=useDeepCompareMemoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeepCompareMemoize.js","sourceRoot":"","sources":["../../utilities/useDeepCompareMemoize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAE/B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAI,KAAQ,EAAK,EAAE;IACtD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAI,KAAK,CAAC,CAAC;IAEnC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const useEventListener: (eventTarget: EventTarget, event: keyof WindowEventMap, cb: EventListener) => void;
2
+ //# sourceMappingURL=useEventListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEventListener.d.ts","sourceRoot":"","sources":["../../utilities/useEventListener.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAC3B,aAAa,WAAW,EACxB,OAAO,MAAM,cAAc,EAC3B,IAAI,aAAa,KAChB,IAOF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ export const useEventListener = (eventTarget, event, cb) => {
3
+ React.useEffect(() => {
4
+ eventTarget.addEventListener(event, cb);
5
+ return () => {
6
+ eventTarget.removeEventListener(event, cb);
7
+ };
8
+ }, [cb, event, eventTarget]);
9
+ };
10
+ //# sourceMappingURL=useEventListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEventListener.js","sourceRoot":"","sources":["../../utilities/useEventListener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAAwB,EACxB,KAA2B,EAC3B,EAAiB,EACX,EAAE;IACR,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { APIOptions } from '../api/types';
2
+ /**
3
+ * Allows "I'm not ready" rejections if you lack a lazy provided prop
4
+ * e.g. Promise.reject(new NotReadyError('Do not have namespace'))
5
+ */
6
+ export declare class NotReadyError extends Error {
7
+ constructor(reason: string);
8
+ }
9
+ /**
10
+ * Checks to see if it's a standard error handled by useStateFetch .catch block.
11
+ */
12
+ export declare const isCommonStateError: (e: Error) => boolean;
13
+ /** Provided as a promise, so you can await a refresh before enabling buttons / closing modals.
14
+ * Returns the successful value or nothing if the call was cancelled / didn't complete. */
15
+ export type FetchStateRefreshPromise<Type> = () => Promise<Type | undefined>;
16
+ /** Return state */
17
+ export type FetchState<Type> = [
18
+ data: Type,
19
+ loaded: boolean,
20
+ loadError: Error | undefined,
21
+ /** This promise should never throw to the .catch */
22
+ refresh: FetchStateRefreshPromise<Type>
23
+ ];
24
+ type SetStateLazy<Type> = (lastState: Type) => Type;
25
+ export type AdHocUpdate<Type> = (updateLater: (updater: SetStateLazy<Type>) => void) => void;
26
+ /**
27
+ * All callbacks will receive a APIOptions, which includes a signal to provide to a RequestInit.
28
+ * This will allow the call to be cancelled if the hook needs to unload. It is recommended that you
29
+ * upgrade your API handlers to support this.
30
+ */
31
+ type FetchStateCallbackPromiseReturn<Return> = (opts: APIOptions) => Return;
32
+ /**
33
+ * Standard usage. Your callback should return a Promise that resolves to your data.
34
+ */
35
+ export type FetchStateCallbackPromise<Type> = FetchStateCallbackPromiseReturn<Promise<Type>>;
36
+ /**
37
+ * Advanced usage. If you have a need to include a lazy refresh state to your data, you can use this
38
+ * functionality. It works on the lazy React.setState functionality.
39
+ *
40
+ * Note: When using, you're giving up immediate setState, so you'll want to call the setStateLater
41
+ * function immediately to get back that functionality.
42
+ *
43
+ * Example:
44
+ * ```
45
+ * React.useCallback(() =>
46
+ * new Promise(() => {
47
+ * MyAPICall().then((...) =>
48
+ * resolve((setStateLater) => { // << providing a function instead of the value
49
+ * setStateLater({ ...someInitialData })
50
+ * // ...some time later, after more calls / in a callback / etc
51
+ * setStateLater((lastState) => ({ ...lastState, data: additionalData }))
52
+ * })
53
+ * )
54
+ * })
55
+ * );
56
+ * ```
57
+ */
58
+ export type FetchStateCallbackPromiseAdHoc<Type> = FetchStateCallbackPromiseReturn<Promise<AdHocUpdate<Type>>>;
59
+ export type FetchOptions = {
60
+ /** To enable auto refresh */
61
+ refreshRate: number;
62
+ /**
63
+ * Makes your promise pure from the sense of if it changes you do not want the previous data. When
64
+ * you recompute your fetchCallbackPromise, do you want to drop the values stored? This will
65
+ * reset everything; result, loaded, & error state. Intended purpose is if your promise is keyed
66
+ * off of a value that if it changes you should drop all data as it's fundamentally a different
67
+ * thing - sharing old state is misleading.
68
+ *
69
+ * Note: Doing this could have undesired side effects. Consider your hook's dependents and the
70
+ * state of your data.
71
+ * Note: This is only read as initial value; changes do nothing.
72
+ */
73
+ initialPromisePurity: boolean;
74
+ };
75
+ /**
76
+ * A boilerplate helper utility. Given a callback that returns a promise, it will store state and
77
+ * handle refreshes on intervals as needed.
78
+ *
79
+ * Note: Your callback *should* support the opts property so the call can be cancelled.
80
+ */
81
+ export declare const useFetchState: <Type>(
82
+ /** React.useCallback result. */
83
+ fetchCallbackPromise: FetchStateCallbackPromise<Type | AdHocUpdate<Type>>,
84
+ /**
85
+ * A preferred default states - this is ignored after the first render
86
+ * Note: This is only read as initial value; changes do nothing.
87
+ */
88
+ initialDefaultState: Type,
89
+ /** Configurable features */
90
+ { refreshRate, initialPromisePurity }?: Partial<FetchOptions>) => FetchState<Type>;
91
+ export {};
92
+ //# sourceMappingURL=useFetchState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchState.d.ts","sourceRoot":"","sources":["../../utilities/useFetchState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,MAAM,EAAE,MAAM;CAI3B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,KAAK,KAAG,OAY7C,CAAC;AAEF;0FAC0F;AAC1F,MAAM,MAAM,wBAAwB,CAAC,IAAI,IAAI,MAAM,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;AAE7E,mBAAmB;AACnB,MAAM,MAAM,UAAU,CAAC,IAAI,IAAI;IAC7B,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,OAAO;IACf,SAAS,EAAE,KAAK,GAAG,SAAS;IAC5B,oDAAoD;IACpD,OAAO,EAAE,wBAAwB,CAAC,IAAI,CAAC;CACxC,CAAC;AAEF,KAAK,YAAY,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,IAAI,KAAK,IAAI,CAAC;AACpD,MAAM,MAAM,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC;AAK7F;;;;GAIG;AACH,KAAK,+BAA+B,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,yBAAyB,CAAC,IAAI,IAAI,+BAA+B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,8BAA8B,CAAC,IAAI,IAAI,+BAA+B,CAChF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;OAUG;IACH,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI;AAChC,gCAAgC;AAChC,sBAAsB,yBAAyB,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AACzE;;;GAGG;AACH,qBAAqB,IAAI;AACzB,4BAA4B;AAC5B,wCAAmD,OAAO,CAAC,YAAY,CAAM,KAC5E,UAAU,CAAC,IAAI,CAsIjB,CAAC"}
@@ -0,0 +1,153 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Allows "I'm not ready" rejections if you lack a lazy provided prop
4
+ * e.g. Promise.reject(new NotReadyError('Do not have namespace'))
5
+ */
6
+ export class NotReadyError extends Error {
7
+ constructor(reason) {
8
+ super(`Not ready yet. ${reason}`);
9
+ this.name = 'NotReadyError';
10
+ }
11
+ }
12
+ /**
13
+ * Checks to see if it's a standard error handled by useStateFetch .catch block.
14
+ */
15
+ export const isCommonStateError = (e) => {
16
+ if (e.name === 'NotReadyError') {
17
+ // An escape hatch for callers to reject the call at this fetchCallbackPromise reference
18
+ // Re-compute your callback to re-trigger again
19
+ return true;
20
+ }
21
+ if (e.name === 'AbortError') {
22
+ // Abort errors are silent
23
+ return true;
24
+ }
25
+ return false;
26
+ };
27
+ const isAdHocUpdate = (r) => typeof r === 'function';
28
+ /**
29
+ * A boilerplate helper utility. Given a callback that returns a promise, it will store state and
30
+ * handle refreshes on intervals as needed.
31
+ *
32
+ * Note: Your callback *should* support the opts property so the call can be cancelled.
33
+ */
34
+ export const useFetchState = (
35
+ /** React.useCallback result. */
36
+ fetchCallbackPromise,
37
+ /**
38
+ * A preferred default states - this is ignored after the first render
39
+ * Note: This is only read as initial value; changes do nothing.
40
+ */
41
+ initialDefaultState,
42
+ /** Configurable features */
43
+ { refreshRate = 0, initialPromisePurity = false } = {}) => {
44
+ const initialDefaultStateRef = React.useRef(initialDefaultState);
45
+ const [result, setResult] = React.useState(initialDefaultState);
46
+ const [loaded, setLoaded] = React.useState(false);
47
+ const [loadError, setLoadError] = React.useState(undefined);
48
+ const abortCallbackRef = React.useRef(() => undefined);
49
+ const changePendingRef = React.useRef(true);
50
+ /** Setup on initial hook a singular reset function. DefaultState & resetDataOnNewPromise are initial render states. */
51
+ const cleanupRef = React.useRef(() => {
52
+ if (initialPromisePurity) {
53
+ setResult(initialDefaultState);
54
+ setLoaded(false);
55
+ setLoadError(undefined);
56
+ }
57
+ });
58
+ React.useEffect(() => {
59
+ cleanupRef.current();
60
+ }, [fetchCallbackPromise]);
61
+ const call = React.useCallback(() => {
62
+ let alreadyAborted = false;
63
+ const abortController = new AbortController();
64
+ /** Note: this promise cannot "catch" beyond this instance -- unless a runtime error. */
65
+ const doRequest = () => fetchCallbackPromise({ signal: abortController.signal })
66
+ .then((r) => {
67
+ changePendingRef.current = false;
68
+ if (alreadyAborted) {
69
+ return undefined;
70
+ }
71
+ if (r === undefined) {
72
+ // Undefined is an unacceptable response. If you want "nothing", pass `null` -- this is likely an API issue though.
73
+ // eslint-disable-next-line no-console
74
+ console.error('useFetchState Error: Got undefined back from a promise. This is likely an error with your call. Preventing setting.');
75
+ return undefined;
76
+ }
77
+ setLoadError(undefined);
78
+ if (isAdHocUpdate(r)) {
79
+ r((setState) => {
80
+ if (alreadyAborted) {
81
+ return undefined;
82
+ }
83
+ setResult(setState);
84
+ setLoaded(true);
85
+ return undefined;
86
+ });
87
+ return undefined;
88
+ }
89
+ setResult(r);
90
+ setLoaded(true);
91
+ return r;
92
+ })
93
+ .catch((e) => {
94
+ changePendingRef.current = false;
95
+ if (alreadyAborted) {
96
+ return undefined;
97
+ }
98
+ if (isCommonStateError(e)) {
99
+ return undefined;
100
+ }
101
+ setLoadError(e);
102
+ return undefined;
103
+ });
104
+ const unload = () => {
105
+ changePendingRef.current = false;
106
+ if (alreadyAborted) {
107
+ return;
108
+ }
109
+ alreadyAborted = true;
110
+ abortController.abort();
111
+ };
112
+ return [doRequest(), unload];
113
+ }, [fetchCallbackPromise]);
114
+ // Use a memmo to update the `changePendingRef` immediately on change.
115
+ React.useMemo(() => {
116
+ changePendingRef.current = true;
117
+ // React to changes to the `call` reference.
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ }, [call]);
120
+ React.useEffect(() => {
121
+ let interval;
122
+ const callAndSave = () => {
123
+ const [, unload] = call();
124
+ abortCallbackRef.current = unload;
125
+ };
126
+ callAndSave();
127
+ if (refreshRate > 0) {
128
+ interval = setInterval(() => {
129
+ abortCallbackRef.current();
130
+ callAndSave();
131
+ }, refreshRate);
132
+ }
133
+ return () => {
134
+ clearInterval(interval);
135
+ abortCallbackRef.current();
136
+ };
137
+ }, [call, refreshRate]);
138
+ // Use a reference for `call` to ensure a stable reference to `refresh` is always returned
139
+ const callRef = React.useRef(call);
140
+ callRef.current = call;
141
+ const refresh = React.useCallback(() => {
142
+ abortCallbackRef.current();
143
+ const [callPromise, unload] = callRef.current();
144
+ abortCallbackRef.current = unload;
145
+ return callPromise;
146
+ }, []);
147
+ // Return the default reset state if a change is pending and initialPromisePurity is true
148
+ if (initialPromisePurity && changePendingRef.current) {
149
+ return [initialDefaultStateRef.current, false, undefined, refresh];
150
+ }
151
+ return [result, loaded, loadError, refresh];
152
+ };
153
+ //# sourceMappingURL=useFetchState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchState.js","sourceRoot":"","sources":["../../utilities/useFetchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,MAAc;QACxB,KAAK,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAQ,EAAW,EAAE;IACtD,IAAI,CAAC,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAC/B,wFAAwF;QACxF,+CAA+C;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC5B,0BAA0B;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAkBF,MAAM,aAAa,GAAG,CAAO,CAA2B,EAA0B,EAAE,CAClF,OAAO,CAAC,KAAK,UAAU,CAAC;AAyD1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;AAC3B,gCAAgC;AAChC,oBAAyE;AACzE;;;GAGG;AACH,mBAAyB;AACzB,4BAA4B;AAC5B,EAAE,WAAW,GAAG,CAAC,EAAE,oBAAoB,GAAG,KAAK,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G,OAAO,CAAC,OAAO,EAAE,CAAC;QAChD,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,yFAAyF;IACzF,IAAI,oBAAoB,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACrD,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { UpdateObjectAtPropAndValue } from '../types';
2
+ export type GenericObjectState<T> = [
3
+ data: T,
4
+ setData: UpdateObjectAtPropAndValue<T>,
5
+ resetDefault: () => void
6
+ ];
7
+ declare const useGenericObjectState: <T>(defaultData: T) => GenericObjectState<T>;
8
+ export default useGenericObjectState;
9
+ //# sourceMappingURL=useGenericObjectState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGenericObjectState.d.ts","sourceRoot":"","sources":["../../utilities/useGenericObjectState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC;IACtC,YAAY,EAAE,MAAM,IAAI;CACzB,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,CAAC,EAAE,aAAa,CAAC,KAAG,kBAAkB,CAAC,CAAC,CAatE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ const useGenericObjectState = (defaultData) => {
3
+ const [value, setValue] = React.useState(defaultData);
4
+ const setPropValue = React.useCallback((propKey, propValue) => {
5
+ setValue((oldValue) => ({ ...oldValue, [propKey]: propValue }));
6
+ }, []);
7
+ const defaultDataRef = React.useRef(defaultData);
8
+ const resetToDefault = React.useCallback(() => {
9
+ setValue(defaultDataRef.current);
10
+ }, []);
11
+ return [value, setPropValue, resetToDefault];
12
+ };
13
+ export default useGenericObjectState;
14
+ //# sourceMappingURL=useGenericObjectState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGenericObjectState.js","sourceRoot":"","sources":["../../utilities/useGenericObjectState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,MAAM,qBAAqB,GAAG,CAAI,WAAc,EAAyB,EAAE;IACzE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAI,WAAW,CAAC,CAAC;IAEzD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAgC,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;QAC3F,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5C,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FetchStateObject } from '../types';
2
+ import { FetchState } from '../utilities/useFetchState';
3
+ export declare const useMakeFetchObject: <T>(fetchState: FetchState<T>) => FetchStateObject<T>;
4
+ //# sourceMappingURL=useMakeFetchObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMakeFetchObject.d.ts","sourceRoot":"","sources":["../../utilities/useMakeFetchObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,YAAY,UAAU,CAAC,CAAC,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAGnF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export const useMakeFetchObject = (fetchState) => {
3
+ const [data, loaded, error, refresh] = fetchState;
4
+ return React.useMemo(() => ({ data, loaded, error, refresh }), [data, loaded, error, refresh]);
5
+ };
6
+ //# sourceMappingURL=useMakeFetchObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMakeFetchObject.js","sourceRoot":"","sources":["../../utilities/useMakeFetchObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAI,UAAyB,EAAuB,EAAE;IACtF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AACjG,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { DeploymentMode } from '../utilities';
2
+ declare global {
3
+ interface Window {
4
+ centraldashboard: any;
5
+ }
6
+ }
7
+ export declare const asEnumMember: <T extends object>(member: T[keyof T] | string | number | undefined | null, e: T) => T[keyof T] | null;
8
+ export declare const isEnumMember: <T extends object>(member: T[keyof T] | string | number | undefined | unknown | null, e: T) => member is T[keyof T];
9
+ /**
10
+ * Utility function to load the Kubeflow dashboard script for kubeflow deployments
11
+ * @param deploymentMode - The current deployment mode
12
+ * @param onSuccess - Callback function to execute when script loads successfully
13
+ * @param onError - Callback function to execute when script fails to load
14
+ */
15
+ export declare const kubeflowScriptLoader: (deploymentMode: DeploymentMode, onSuccess: () => void, onError?: (error?: Error) => void) => void;
16
+ /**
17
+ * Utility function to initialize Kubeflow namespace selection integration
18
+ * @param deploymentMode - The current deployment mode
19
+ * @param scriptLoaded - Whether the Kubeflow dashboard script is loaded
20
+ * @param onNamespaceSelected - Callback function when a namespace is selected
21
+ * @param onError - Callback function to execute when initialization fails
22
+ * @param mandatoryNamespace - Optional mandatory namespace that disables selection
23
+ * @returns boolean - Whether initialization was attempted
24
+ */
25
+ export declare const kubeflowNamespaceLoader: (deploymentMode: DeploymentMode, scriptLoaded: boolean, onNamespaceSelected: (namespace: string) => void, onError?: (error: Error) => void, mandatoryNamespace?: string) => boolean;
26
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../utilities/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QAEd,gBAAgB,EAAE,GAAG,CAAC;KACvB;CACF;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,EAC3C,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,EACvD,GAAG,CAAC,KACH,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,IAAiD,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,EAC3C,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,EACjE,GAAG,CAAC,KACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAQrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,cAAc,EAC9B,WAAW,MAAM,IAAI,EACrB,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,KAChC,IA0CF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,cAAc,EAC9B,cAAc,OAAO,EACrB,qBAAqB,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,EAChD,UAAU,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,qBAAqB,MAAM,KAC1B,OAkCF,CAAC"}