@looker/api-explorer 0.9.22 → 0.9.24

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 (203) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/lib/ApiExplorer.d.ts +4 -39
  3. package/lib/ApiExplorer.js +23 -24
  4. package/lib/ApiExplorer.js.map +1 -1
  5. package/lib/App.d.ts +1 -0
  6. package/lib/App.js +29 -0
  7. package/lib/App.js.map +1 -0
  8. package/lib/StandaloneApiExplorer.js +8 -13
  9. package/lib/StandaloneApiExplorer.js.map +1 -1
  10. package/lib/components/DocMarkdown/DocMarkdown.js +5 -5
  11. package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
  12. package/lib/components/DocSdkUsage/DocSdkUsage.js +3 -6
  13. package/lib/components/DocSdkUsage/DocSdkUsage.js.map +1 -1
  14. package/lib/components/DocSource/DocSource.js +5 -7
  15. package/lib/components/DocSource/DocSource.js.map +1 -1
  16. package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.d.ts +1 -1
  17. package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js +152 -8
  18. package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js.map +1 -1
  19. package/lib/components/SelectorContainer/SdkLanguageSelector.js +1 -1
  20. package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  21. package/lib/components/SideNav/SideNav.js +1 -1
  22. package/lib/components/SideNav/SideNav.js.map +1 -1
  23. package/lib/components/common/Loader.d.ts +1 -1
  24. package/lib/components/common/Loader.js.map +1 -1
  25. package/lib/esm/ApiExplorer.js +25 -26
  26. package/lib/esm/ApiExplorer.js.map +1 -1
  27. package/lib/esm/App.js +19 -0
  28. package/lib/esm/App.js.map +1 -0
  29. package/lib/esm/StandaloneApiExplorer.js +7 -10
  30. package/lib/esm/StandaloneApiExplorer.js.map +1 -1
  31. package/lib/esm/components/DocMarkdown/DocMarkdown.js +3 -3
  32. package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
  33. package/lib/esm/components/DocSdkUsage/DocSdkUsage.js +5 -7
  34. package/lib/esm/components/DocSdkUsage/DocSdkUsage.js.map +1 -1
  35. package/lib/esm/components/DocSource/DocSource.js +4 -5
  36. package/lib/esm/components/DocSource/DocSource.js.map +1 -1
  37. package/lib/esm/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js +153 -6
  38. package/lib/esm/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js.map +1 -1
  39. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +2 -2
  40. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  41. package/lib/esm/components/SideNav/SideNav.js +2 -2
  42. package/lib/esm/components/SideNav/SideNav.js.map +1 -1
  43. package/lib/esm/components/common/Loader.js.map +1 -1
  44. package/lib/esm/index.js +4 -18
  45. package/lib/esm/index.js.map +1 -1
  46. package/lib/esm/routes/AppRouter.js +2 -2
  47. package/lib/esm/routes/AppRouter.js.map +1 -1
  48. package/lib/esm/scenes/MethodScene/MethodScene.js +9 -11
  49. package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
  50. package/lib/esm/state/index.js +1 -0
  51. package/lib/esm/state/index.js.map +1 -1
  52. package/lib/esm/state/lodes/index.js +3 -0
  53. package/lib/{test-utils/envAdaptor.js.map → esm/state/lodes/index.js.map} +1 -1
  54. package/lib/esm/state/lodes/sagas.js +25 -0
  55. package/lib/esm/state/lodes/sagas.js.map +1 -0
  56. package/lib/esm/state/lodes/selectors.js +5 -0
  57. package/lib/esm/state/lodes/selectors.js.map +1 -0
  58. package/lib/esm/state/lodes/slice.js +30 -0
  59. package/lib/esm/state/lodes/slice.js.map +1 -0
  60. package/lib/esm/state/settings/sagas.js +28 -16
  61. package/lib/esm/state/settings/sagas.js.map +1 -1
  62. package/lib/esm/state/settings/selectors.js +5 -5
  63. package/lib/esm/state/settings/selectors.js.map +1 -1
  64. package/lib/esm/state/settings/slice.js +8 -8
  65. package/lib/esm/state/settings/slice.js.map +1 -1
  66. package/lib/esm/state/store.js +6 -3
  67. package/lib/esm/state/store.js.map +1 -1
  68. package/lib/esm/test-utils/index.js +1 -2
  69. package/lib/esm/test-utils/index.js.map +1 -1
  70. package/lib/esm/test-utils/lodes.js +12 -0
  71. package/lib/esm/test-utils/lodes.js.map +1 -0
  72. package/lib/esm/test-utils/redux.js +11 -8
  73. package/lib/esm/test-utils/redux.js.map +1 -1
  74. package/lib/esm/utils/index.js +0 -1
  75. package/lib/esm/utils/index.js.map +1 -1
  76. package/lib/esm/utils/lodeUtils.js +3 -7
  77. package/lib/esm/utils/lodeUtils.js.map +1 -1
  78. package/lib/index.d.ts +4 -1
  79. package/lib/index.js +52 -23
  80. package/lib/index.js.map +1 -1
  81. package/lib/routes/AppRouter.d.ts +2 -2
  82. package/lib/routes/AppRouter.js +2 -2
  83. package/lib/routes/AppRouter.js.map +1 -1
  84. package/lib/scenes/MethodScene/MethodScene.d.ts +2 -2
  85. package/lib/scenes/MethodScene/MethodScene.js +7 -9
  86. package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
  87. package/lib/state/index.d.ts +1 -0
  88. package/lib/state/index.js +13 -0
  89. package/lib/state/index.js.map +1 -1
  90. package/lib/state/lodes/index.d.ts +2 -0
  91. package/lib/state/lodes/index.js +32 -0
  92. package/lib/state/lodes/index.js.map +1 -0
  93. package/lib/state/lodes/sagas.d.ts +1 -0
  94. package/lib/state/lodes/sagas.js +34 -0
  95. package/lib/state/lodes/sagas.js.map +1 -0
  96. package/lib/state/lodes/selectors.d.ts +3 -0
  97. package/lib/state/lodes/selectors.js +17 -0
  98. package/lib/state/lodes/selectors.js.map +1 -0
  99. package/lib/state/lodes/slice.d.ts +29 -0
  100. package/lib/state/lodes/slice.js +45 -0
  101. package/lib/state/lodes/slice.js.map +1 -0
  102. package/lib/state/settings/sagas.js +28 -15
  103. package/lib/state/settings/sagas.js.map +1 -1
  104. package/lib/state/settings/selectors.js +5 -5
  105. package/lib/state/settings/selectors.js.map +1 -1
  106. package/lib/state/settings/slice.d.ts +13 -13
  107. package/lib/state/settings/slice.js +13 -13
  108. package/lib/state/settings/slice.js.map +1 -1
  109. package/lib/state/store.d.ts +3 -0
  110. package/lib/state/store.js +6 -2
  111. package/lib/state/store.js.map +1 -1
  112. package/lib/test-data/declarations.js +24 -0
  113. package/lib/test-data/declarations.js.map +1 -0
  114. package/lib/test-data/index.js +23 -0
  115. package/lib/test-data/index.js.map +1 -1
  116. package/lib/test-utils/index.d.ts +1 -2
  117. package/lib/test-utils/index.js +12 -28
  118. package/lib/test-utils/index.js.map +1 -1
  119. package/lib/test-utils/lodes.d.ts +4 -0
  120. package/lib/test-utils/lodes.js +23 -0
  121. package/lib/test-utils/lodes.js.map +1 -0
  122. package/lib/test-utils/redux.d.ts +3 -1
  123. package/lib/test-utils/redux.js +12 -8
  124. package/lib/test-utils/redux.js.map +1 -1
  125. package/lib/utils/index.d.ts +0 -1
  126. package/lib/utils/index.js +0 -24
  127. package/lib/utils/index.js.map +1 -1
  128. package/lib/utils/lodeUtils.d.ts +2 -2
  129. package/lib/utils/lodeUtils.js +3 -7
  130. package/lib/utils/lodeUtils.js.map +1 -1
  131. package/package.json +11 -10
  132. package/public/Looker.3.1.json +1343 -412
  133. package/public/Looker.4.0.json +3305 -661
  134. package/src/ApiExplorer.tsx +99 -102
  135. package/src/{index.tsx → App.tsx} +0 -0
  136. package/src/StandaloneApiExplorer.tsx +8 -16
  137. package/src/components/DocMarkdown/DocMarkdown.tsx +3 -3
  138. package/src/components/DocSdkUsage/DocSdkUsage.spec.tsx +2 -2
  139. package/src/components/DocSdkUsage/DocSdkUsage.tsx +5 -5
  140. package/src/components/DocSource/DocSource.tsx +4 -3
  141. package/src/components/ErrorBoundary/components/SomethingWentWrong/SomethingWentWrong.spec.tsx +1 -1
  142. package/src/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.tsx +170 -6
  143. package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +3 -5
  144. package/src/components/SelectorContainer/SdkLanguageSelector.tsx +2 -2
  145. package/src/components/SideNav/SideNav.tsx +2 -2
  146. package/src/components/common/Loader.tsx +1 -1
  147. package/src/{context/lode/index.ts → index.ts} +4 -1
  148. package/src/routes/AppRouter.tsx +5 -4
  149. package/src/scenes/MethodScene/MethodScene.tsx +11 -11
  150. package/src/state/index.ts +1 -0
  151. package/src/{context → state/lodes}/index.ts +2 -1
  152. package/src/state/lodes/sagas.spec.ts +92 -0
  153. package/src/state/lodes/sagas.ts +51 -0
  154. package/src/state/lodes/selectors.spec.ts +42 -0
  155. package/src/{test-utils/envAdaptor.ts → state/lodes/selectors.ts} +8 -5
  156. package/src/{test-utils/render_with_lode.tsx → state/lodes/slice.ts} +37 -37
  157. package/src/state/settings/sagas.spec.ts +25 -21
  158. package/src/state/settings/sagas.ts +16 -16
  159. package/src/state/settings/selectors.spec.ts +1 -5
  160. package/src/state/settings/selectors.ts +5 -5
  161. package/src/state/settings/slice.ts +12 -7
  162. package/src/state/store.ts +7 -2
  163. package/src/{context/lode/LodeContext.ts → test-data/declarations.ts} +17 -14
  164. package/src/test-data/index.ts +1 -0
  165. package/src/test-utils/index.ts +1 -5
  166. package/src/test-utils/lodes.tsx +41 -0
  167. package/src/test-utils/redux.tsx +19 -7
  168. package/src/utils/index.ts +0 -1
  169. package/src/utils/lodeUtils.ts +4 -6
  170. package/webpack.dev.config.js +3 -0
  171. package/webpack.prod.config.js +4 -0
  172. package/lib/context/index.d.ts +0 -1
  173. package/lib/context/index.js +0 -20
  174. package/lib/context/index.js.map +0 -1
  175. package/lib/context/lode/LodeContext.d.ts +0 -9
  176. package/lib/context/lode/LodeContext.js +0 -21
  177. package/lib/context/lode/LodeContext.js.map +0 -1
  178. package/lib/context/lode/index.d.ts +0 -1
  179. package/lib/context/lode/index.js +0 -20
  180. package/lib/context/lode/index.js.map +0 -1
  181. package/lib/esm/context/index.js +0 -2
  182. package/lib/esm/context/index.js.map +0 -1
  183. package/lib/esm/context/lode/LodeContext.js +0 -11
  184. package/lib/esm/context/lode/LodeContext.js.map +0 -1
  185. package/lib/esm/context/lode/index.js +0 -2
  186. package/lib/esm/context/lode/index.js.map +0 -1
  187. package/lib/esm/test-utils/envAdaptor.js +0 -5
  188. package/lib/esm/test-utils/envAdaptor.js.map +0 -1
  189. package/lib/esm/test-utils/render_with_lode.js +0 -19
  190. package/lib/esm/test-utils/render_with_lode.js.map +0 -1
  191. package/lib/esm/utils/envAdaptor.js +0 -84
  192. package/lib/esm/utils/envAdaptor.js.map +0 -1
  193. package/lib/test-utils/envAdaptor.d.ts +0 -2
  194. package/lib/test-utils/envAdaptor.js +0 -15
  195. package/lib/test-utils/render_with_lode.d.ts +0 -7
  196. package/lib/test-utils/render_with_lode.js +0 -36
  197. package/lib/test-utils/render_with_lode.js.map +0 -1
  198. package/lib/utils/envAdaptor.d.ts +0 -31
  199. package/lib/utils/envAdaptor.js +0 -106
  200. package/lib/utils/envAdaptor.js.map +0 -1
  201. package/src/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/somethingWentWrong.svg +0 -45
  202. package/src/utils/envAdaptor.spec.ts +0 -50
  203. package/src/utils/envAdaptor.ts +0 -147
@@ -23,9 +23,12 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- import type { IApixEnvAdaptor } from '../utils'
27
- import { registerEnvAdaptor, StandaloneEnvAdaptor } from '../utils'
26
+ import type { RootState } from '../store'
28
27
 
29
- export const registerTestEnvAdaptor = (envAdaptor?: IApixEnvAdaptor) => {
30
- registerEnvAdaptor(envAdaptor || new StandaloneEnvAdaptor())
31
- }
28
+ const selectLodeState = (state: RootState) => state.lodes
29
+
30
+ export const selectExamplesLode = (state: RootState) =>
31
+ selectLodeState(state).examples
32
+
33
+ export const selectDeclarationsLode = (state: RootState) =>
34
+ selectLodeState(state).declarations
@@ -23,47 +23,47 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
-
27
- import type { ReactElement } from 'react'
28
- import React from 'react'
29
- import type { RenderOptions } from '@testing-library/react'
30
- import type { Store } from 'redux'
31
-
32
- import { renderWithTheme } from '@looker/components-test-utils'
26
+ import { createSliceHooks } from '@looker/redux'
33
27
  import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen'
34
- import { LodeContext } from '../context'
35
- import type { RootState } from '../state'
36
- import { withReduxProvider } from './redux'
28
+ import type { PayloadAction } from '@reduxjs/toolkit'
29
+ import { createSlice } from '@reduxjs/toolkit'
37
30
 
38
- const withLode = (
39
- consumer: ReactElement<any>,
40
- examples: IExampleMine,
31
+ import { saga } from './sagas'
32
+
33
+ export interface LodesState {
34
+ examples?: IExampleMine
41
35
  declarations?: IDeclarationMine
42
- ) => {
43
- return (
44
- <LodeContext.Provider value={{ examples, declarations }}>
45
- {consumer}
46
- </LodeContext.Provider>
47
- )
36
+ error?: Error
48
37
  }
49
38
 
50
- export const renderWithLode = (
51
- component: ReactElement<any>,
52
- examples: IExampleMine,
53
- declarations?: IDeclarationMine,
54
- options?: Omit<RenderOptions, 'queries'>
55
- ) => {
56
- return renderWithTheme(withLode(component, examples, declarations), options)
39
+ export const defaultLodesState: LodesState = {
40
+ examples: undefined,
41
+ declarations: undefined,
57
42
  }
58
43
 
59
- export const renderWithReduxProviderAndLode = (
60
- component: ReactElement<any>,
61
- examples: IExampleMine,
62
- declarations?: IDeclarationMine,
63
- store?: Store<RootState>,
64
- options?: Omit<RenderOptions, 'queries'>
65
- ) =>
66
- renderWithTheme(
67
- withReduxProvider(withLode(component, examples, declarations), store),
68
- options
69
- )
44
+ export interface InitPayload {
45
+ examplesLodeUrl?: string
46
+ declarationsLodeUrl?: string
47
+ }
48
+
49
+ type InitSuccessAction = LodesState
50
+
51
+ export const lodesSlice = createSlice({
52
+ name: 'lodes',
53
+ initialState: defaultLodesState,
54
+ reducers: {
55
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
56
+ initLodesAction(_state, _action: PayloadAction<InitPayload>) {},
57
+ initLodesSuccessAction(state, action: PayloadAction<InitSuccessAction>) {
58
+ state.examples = action.payload.examples
59
+ state.declarations = action.payload.declarations
60
+ },
61
+ initLodesFailureAction(state, action: PayloadAction<Error>) {
62
+ state.error = action.payload
63
+ },
64
+ },
65
+ })
66
+
67
+ export const lodeActions = lodesSlice.actions
68
+ export const { useActions: useLodeActions, useStoreState: useLodesStoreState } =
69
+ createSliceHooks(lodesSlice, saga)
@@ -24,11 +24,11 @@
24
24
 
25
25
  */
26
26
  import ReduxSagaTester from 'redux-saga-tester'
27
- import { registerTestEnvAdaptor } from '../../test-utils'
28
27
 
29
- import { EnvAdaptorConstants, getEnvAdaptor } from '../../utils'
28
+ import { getEnvAdaptor, registerTestEnvAdaptor } from '@looker/extension-utils'
29
+ import { StoreConstants } from '@looker/run-it'
30
30
  import * as sagas from './sagas'
31
- import { actions, defaultSettings, slice } from './slice'
31
+ import { settingActions, defaultSettings, settingsSlice } from './slice'
32
32
 
33
33
  describe('Settings Sagas', () => {
34
34
  let sagaTester: ReduxSagaTester<any>
@@ -39,7 +39,7 @@ describe('Settings Sagas', () => {
39
39
  sagaTester = new ReduxSagaTester({
40
40
  initialState: { settings: { sdkLanguage: 'Go' } },
41
41
  reducers: {
42
- settings: slice.reducer,
42
+ settings: settingsSlice.reducer,
43
43
  },
44
44
  })
45
45
  localStorage.clear()
@@ -47,7 +47,7 @@ describe('Settings Sagas', () => {
47
47
  })
48
48
 
49
49
  describe('setSdkLanguageSaga', () => {
50
- const setSdkLanguageAction = actions.setSdkLanguageAction
50
+ const setSdkLanguageAction = settingActions.setSdkLanguageAction
51
51
 
52
52
  test('persists value sdkLanguage in localstorage', async () => {
53
53
  sagaTester.dispatch(setSdkLanguageAction({ sdkLanguage: 'Kotlin' }))
@@ -60,58 +60,62 @@ describe('Settings Sagas', () => {
60
60
  })
61
61
  )
62
62
  expect(localStorage.setItem).toHaveBeenLastCalledWith(
63
- EnvAdaptorConstants.LOCALSTORAGE_SETTINGS_KEY,
63
+ StoreConstants.LOCALSTORAGE_SETTINGS_KEY,
64
64
  JSON.stringify({ sdkLanguage: 'Kotlin' })
65
65
  )
66
66
  })
67
67
  })
68
68
 
69
69
  describe('initSaga', () => {
70
- const { initAction, initSuccessAction, initFailureAction } = actions
70
+ const {
71
+ initSettingsAction,
72
+ initSettingsSuccessAction,
73
+ initSettingsFailureAction,
74
+ } = settingActions
71
75
 
72
76
  test('sends initSuccess action with defaults on success if no persisted settings are found', async () => {
73
- sagaTester.dispatch(initAction())
74
- await sagaTester.waitFor('settings/initSuccessAction')
77
+ sagaTester.dispatch(initSettingsAction())
78
+ await sagaTester.waitFor('settings/initSettingsSuccessAction')
75
79
  const calledActions = sagaTester.getCalledActions()
76
80
  expect(calledActions).toHaveLength(2)
77
- expect(calledActions[0]).toEqual(initAction())
81
+ expect(calledActions[0]).toEqual(initSettingsAction())
78
82
  expect(calledActions[1]).toEqual(
79
- initSuccessAction({
83
+ initSettingsSuccessAction({
80
84
  ...defaultSettings,
81
85
  })
82
86
  )
83
87
  })
84
88
 
85
- test('sends initSuccess action with persisted language on success', async () => {
89
+ test('sends initSettingsSuccessAction with persisted language on success', async () => {
86
90
  jest
87
91
  .spyOn(getEnvAdaptor(), 'localStorageGetItem')
88
92
  .mockResolvedValueOnce(JSON.stringify({ sdkLanguage: 'Go' }))
89
93
 
90
- sagaTester.dispatch(initAction())
91
- await sagaTester.waitFor('settings/initSuccessAction')
94
+ sagaTester.dispatch(initSettingsAction())
95
+ await sagaTester.waitFor('settings/initSettingsSuccessAction')
92
96
  const calledActions = sagaTester.getCalledActions()
93
97
  expect(calledActions).toHaveLength(2)
94
- expect(calledActions[0]).toEqual(initAction())
98
+ expect(calledActions[0]).toEqual(initSettingsAction())
95
99
  expect(calledActions[1]).toEqual(
96
- initSuccessAction({
100
+ initSettingsSuccessAction({
97
101
  ...defaultSettings,
98
102
  sdkLanguage: 'Go',
99
103
  })
100
104
  )
101
105
  })
102
106
 
103
- test('sends initFailure action on error', async () => {
107
+ test('sends initSettingsFailureAction on error', async () => {
104
108
  const error = new Error('boom')
105
109
  jest
106
110
  .spyOn(getEnvAdaptor(), 'localStorageGetItem')
107
111
  .mockRejectedValueOnce(error)
108
112
 
109
- sagaTester.dispatch(initAction())
110
- await sagaTester.waitFor('settings/initFailureAction')
113
+ sagaTester.dispatch(initSettingsAction())
114
+ await sagaTester.waitFor('settings/initSettingsFailureAction')
111
115
  const calledActions = sagaTester.getCalledActions()
112
116
  expect(calledActions).toHaveLength(2)
113
- expect(calledActions[0]).toEqual(initAction())
114
- expect(calledActions[1]).toEqual(initFailureAction(error))
117
+ expect(calledActions[0]).toEqual(initSettingsAction())
118
+ expect(calledActions[1]).toEqual(initSettingsFailureAction(error))
115
119
  })
116
120
  })
117
121
  })
@@ -25,21 +25,21 @@
25
25
  */
26
26
  import { takeEvery, call, put, select } from 'typed-redux-saga'
27
27
 
28
- import { EnvAdaptorConstants, getEnvAdaptor } from '../../utils'
28
+ import { getEnvAdaptor } from '@looker/extension-utils'
29
+ import { StoreConstants } from '@looker/run-it'
29
30
  import type { RootState } from '../store'
30
- import { actions, defaultSettings } from './slice'
31
+ import { settingActions, defaultSettings } from './slice'
31
32
 
32
33
  /**
33
34
  * Serializes state to local storage
34
35
  */
35
36
  function* serializeToLocalStorageSaga() {
36
- const envAdaptor = getEnvAdaptor()
37
+ const adaptor = getEnvAdaptor()
37
38
  const settings = yield* select((state: RootState) => ({
38
39
  sdkLanguage: state.settings.sdkLanguage,
39
40
  }))
40
- yield* call(
41
- envAdaptor.localStorageSetItem,
42
- EnvAdaptorConstants.LOCALSTORAGE_SETTINGS_KEY,
41
+ adaptor.localStorageSetItem(
42
+ StoreConstants.LOCALSTORAGE_SETTINGS_KEY,
43
43
  JSON.stringify(settings)
44
44
  )
45
45
  }
@@ -47,11 +47,10 @@ function* serializeToLocalStorageSaga() {
47
47
  /**
48
48
  * Returns default settings overridden with any persisted state in local storage
49
49
  */
50
- function* deserializeLocalStorage() {
51
- const envAdaptor = getEnvAdaptor()
52
- const settings = yield* call(
53
- envAdaptor.localStorageGetItem,
54
- EnvAdaptorConstants.LOCALSTORAGE_SETTINGS_KEY
50
+ async function deserializeLocalStorage() {
51
+ const adaptor = getEnvAdaptor()
52
+ const settings = await adaptor.localStorageGetItem(
53
+ StoreConstants.LOCALSTORAGE_SETTINGS_KEY
55
54
  )
56
55
  return settings
57
56
  ? { ...defaultSettings, ...JSON.parse(settings) }
@@ -62,18 +61,19 @@ function* deserializeLocalStorage() {
62
61
  * Initializes the store with default settings and existing persisted settings
63
62
  */
64
63
  function* initSaga() {
65
- const { initSuccessAction, initFailureAction } = actions
64
+ const { initSettingsSuccessAction, initSettingsFailureAction } =
65
+ settingActions
66
66
  try {
67
67
  const settings = yield* call(deserializeLocalStorage)
68
- yield* put(initSuccessAction(settings))
68
+ yield* put(initSettingsSuccessAction(settings))
69
69
  } catch (error: any) {
70
- yield* put(initFailureAction(error))
70
+ yield* put(initSettingsFailureAction(error))
71
71
  }
72
72
  }
73
73
 
74
74
  export function* saga() {
75
- const { initAction, setSdkLanguageAction } = actions
75
+ const { initSettingsAction, setSdkLanguageAction } = settingActions
76
76
 
77
- yield* takeEvery(initAction, initSaga)
77
+ yield* takeEvery(initSettingsAction, initSaga)
78
78
  yield* takeEvery(setSdkLanguageAction, serializeToLocalStorageSaga)
79
79
  }
@@ -23,13 +23,9 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- import { createTestStore } from '../../test-utils'
26
+ import { createTestStore, preloadedState } from '../../test-utils'
27
27
  import { selectSdkLanguage, isInitialized } from './selectors'
28
28
 
29
- const preloadedState = {
30
- settings: { initialized: false, sdkLanguage: 'Python' },
31
- }
32
-
33
29
  const testStore = createTestStore()
34
30
 
35
31
  describe('Settings selectors', () => {
@@ -25,16 +25,16 @@
25
25
  */
26
26
  import type { RootState } from '../store'
27
27
 
28
- const getSettingsState = (state: RootState) => state.settings
28
+ const selectSettingsState = (state: RootState) => state.settings
29
29
 
30
30
  export const selectSdkLanguage = (state: RootState) =>
31
- getSettingsState(state).sdkLanguage
31
+ selectSettingsState(state).sdkLanguage
32
32
 
33
33
  export const selectSearchPattern = (state: RootState) =>
34
- getSettingsState(state).searchPattern
34
+ selectSettingsState(state).searchPattern
35
35
 
36
36
  export const selectSearchCriteria = (state: RootState) =>
37
- getSettingsState(state).searchCriteria
37
+ selectSettingsState(state).searchCriteria
38
38
 
39
39
  export const isInitialized = (state: RootState) =>
40
- getSettingsState(state).initialized
40
+ selectSettingsState(state).initialized
@@ -58,17 +58,20 @@ type SetSdkLanguageAction = Pick<SettingState, 'sdkLanguage'>
58
58
 
59
59
  export type InitSuccessPayload = UserDefinedSettings
60
60
 
61
- export const slice = createSlice({
61
+ export const settingsSlice = createSlice({
62
62
  name: 'settings',
63
63
  initialState: defaultSettingsState,
64
64
  reducers: {
65
65
  // eslint-disable-next-line @typescript-eslint/no-empty-function
66
- initAction() {},
67
- initSuccessAction(state, action: PayloadAction<InitSuccessPayload>) {
66
+ initSettingsAction() {},
67
+ initSettingsSuccessAction(
68
+ state,
69
+ action: PayloadAction<InitSuccessPayload>
70
+ ) {
68
71
  state.sdkLanguage = action.payload.sdkLanguage
69
72
  state.initialized = true
70
73
  },
71
- initFailureAction(state, action: PayloadAction<Error>) {
74
+ initSettingsFailureAction(state, action: PayloadAction<Error>) {
72
75
  state.error = action.payload
73
76
  state.initialized = false
74
77
  },
@@ -84,6 +87,8 @@ export const slice = createSlice({
84
87
  },
85
88
  })
86
89
 
87
- export const actions = slice.actions
88
- export const { useActions, useStoreState: useSettingsStoreState } =
89
- createSliceHooks(slice, saga)
90
+ export const settingActions = settingsSlice.actions
91
+ export const {
92
+ useActions: useSettingActions,
93
+ useStoreState: useSettingStoreState,
94
+ } = createSliceHooks(settingsSlice, saga)
@@ -26,17 +26,22 @@
26
26
  import { createStore } from '@looker/redux'
27
27
 
28
28
  import type { SettingState } from './settings'
29
- import { defaultSettingsState, slice } from './settings'
29
+ import { defaultSettingsState, settingsSlice } from './settings'
30
+ import type { LodesState } from './lodes'
31
+ import { lodesSlice, defaultLodesState } from './lodes'
30
32
 
31
33
  export const store = createStore({
32
34
  preloadedState: {
33
35
  settings: defaultSettingsState,
36
+ lodes: defaultLodesState,
34
37
  },
35
38
  reducer: {
36
- settings: slice.reducer,
39
+ settings: settingsSlice.reducer,
40
+ lodes: lodesSlice.reducer,
37
41
  },
38
42
  })
39
43
 
40
44
  export interface RootState {
41
45
  settings: SettingState
46
+ lodes: LodesState
42
47
  }
@@ -23,18 +23,21 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- import { createContext } from 'react'
27
- import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen'
28
-
29
- interface LodeContextProps {
30
- examples: IExampleMine
31
- declarations?: IDeclarationMine
32
- }
33
-
34
- export const defaultLodeContextValue: LodeContextProps = {
35
- examples: { commitHash: '', remoteOrigin: '', nuggets: {}, summaries: {} },
26
+ import type { IDeclarationMine } from '@looker/sdk-codegen'
27
+
28
+ export const declarations: IDeclarationMine = {
29
+ commitHash: '1e9348b797c2f3760d03c1f94c60f18e534e8298',
30
+ remoteOrigin: 'https://github.com/looker-open-source/sdk-codegen',
31
+ types: {
32
+ FullLode: {
33
+ line: 40,
34
+ sourceFile: 'packages/api-explorer/src/utils/lodeUtils.ts',
35
+ },
36
+ },
37
+ methods: {
38
+ getLoded: {
39
+ line: 45,
40
+ sourceFile: 'packages/api-explorer/src/utils/lodeUtils.ts',
41
+ },
42
+ },
36
43
  }
37
-
38
- export const LodeContext = createContext<LodeContextProps>(
39
- defaultLodeContextValue
40
- )
@@ -32,3 +32,4 @@ export {
32
32
  getLoadedSpecState,
33
33
  } from './specs'
34
34
  export { examples } from './examples'
35
+ export * from './declarations'
@@ -23,10 +23,6 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- export {
27
- renderWithLode,
28
- renderWithReduxProviderAndLode,
29
- } from './render_with_lode'
26
+ export * from './lodes'
30
27
  export * from './router'
31
28
  export * from './redux'
32
- export { registerTestEnvAdaptor } from './envAdaptor'
@@ -0,0 +1,41 @@
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2021 Looker Data Sciences, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ */
26
+ import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen'
27
+ import type { ReactElement } from 'react'
28
+ import type { RenderOptions } from '@testing-library/react'
29
+ import { renderWithTheme } from '@looker/components-test-utils'
30
+
31
+ import { createTestStore, withReduxProvider } from './redux'
32
+
33
+ export const renderWithLode = (
34
+ consumers: ReactElement<any>,
35
+ examples: IExampleMine,
36
+ declarations?: IDeclarationMine,
37
+ options?: Omit<RenderOptions, 'queries'>
38
+ ) => {
39
+ const store = createTestStore({ lodes: { examples, declarations } })
40
+ return renderWithTheme(withReduxProvider(consumers, store), options)
41
+ }
@@ -23,6 +23,7 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
+
26
27
  import type { ReactElement } from 'react'
27
28
  import React from 'react'
28
29
  import { Provider } from 'react-redux'
@@ -30,18 +31,24 @@ import type { Store } from 'redux'
30
31
  import { renderWithTheme } from '@looker/components-test-utils'
31
32
  import type { RenderOptions } from '@testing-library/react'
32
33
  import { createStore } from '@looker/redux'
34
+ import { BrowserAdaptor, registerEnvAdaptor } from '@looker/extension-utils'
35
+ import { initRunItSdk } from '@looker/run-it'
33
36
 
34
- import type { RootState, SettingState } from '../state'
35
- import { defaultSettingsState, store as defaultStore } from '../state'
36
- import { slice as settingsSlice } from '../state/settings'
37
- import { registerEnvAdaptor, StandaloneEnvAdaptor } from '../utils'
37
+ import type { LodesState, RootState, SettingState } from '../state'
38
+ import {
39
+ settingsSlice,
40
+ defaultLodesState,
41
+ defaultSettingsState,
42
+ store as defaultStore,
43
+ lodesSlice,
44
+ } from '../state'
38
45
  import { renderWithRouter } from './router'
39
46
 
40
47
  export const withReduxProvider = (
41
48
  consumers: ReactElement<any>,
42
49
  store: Store<RootState> = defaultStore
43
50
  ) => {
44
- registerEnvAdaptor(new StandaloneEnvAdaptor())
51
+ registerEnvAdaptor(new BrowserAdaptor(initRunItSdk()))
45
52
  return <Provider store={store}>{consumers}</Provider>
46
53
  }
47
54
 
@@ -59,8 +66,9 @@ export const renderWithRouterAndReduxProvider = (
59
66
  ) =>
60
67
  renderWithRouter(withReduxProvider(consumers, store), initialEntries, options)
61
68
 
62
- const preloadedState: RootState = {
69
+ export const preloadedState: RootState = {
63
70
  settings: defaultSettingsState,
71
+ lodes: defaultLodesState,
64
72
  }
65
73
 
66
74
  type DeepPartial<T> = {
@@ -74,6 +82,10 @@ export const createTestStore = (overrides?: DeepPartial<RootState>) =>
74
82
  ...preloadedState.settings,
75
83
  ...overrides?.settings,
76
84
  } as SettingState,
85
+ lodes: {
86
+ ...defaultLodesState,
87
+ ...overrides?.lodes,
88
+ } as LodesState,
77
89
  },
78
- reducer: { settings: settingsSlice.reducer },
90
+ reducer: { settings: settingsSlice.reducer, lodes: lodesSlice.reducer },
79
91
  })
@@ -33,4 +33,3 @@ export {
33
33
  } from './path'
34
34
  export { getLoded } from './lodeUtils'
35
35
  export { useWindowSize } from './useWindowSize'
36
- export * from './envAdaptor'
@@ -38,17 +38,17 @@ const fetchLode = async (lodeUrl: string) => {
38
38
  }
39
39
 
40
40
  interface FullLode {
41
- examples: IExampleMine
41
+ examples?: IExampleMine
42
42
  declarations?: IDeclarationMine
43
43
  }
44
44
 
45
45
  export const getLoded = async (
46
- examplesLodeUrl: string,
46
+ examplesLodeUrl?: string,
47
47
  declarationsLodeUrl?: string
48
48
  ): Promise<FullLode> => {
49
49
  // First try to load from the apix-files server
50
50
  let examples = await fetchLode(`${apixFilesHost}/examplesIndex.json`)
51
- if (!examples) {
51
+ if (!examples && examplesLodeUrl) {
52
52
  examples = await fetchLode(examplesLodeUrl)
53
53
  }
54
54
 
@@ -57,9 +57,7 @@ export const getLoded = async (
57
57
  declarations = await fetchLode(declarationsLodeUrl)
58
58
  }
59
59
 
60
- const lode: FullLode = {
61
- examples: { commitHash: '', nuggets: {}, remoteOrigin: '', summaries: {} },
62
- }
60
+ const lode: FullLode = { examples: undefined, declarations: undefined }
63
61
  if (examples) {
64
62
  lode.examples = JSON.parse(examples)
65
63
  }
@@ -30,6 +30,9 @@ const base = require('../../webpack.base.config')(__dirname)
30
30
  const browser = require('../../webpack.browser.config')()
31
31
 
32
32
  module.exports = merge(base, browser, {
33
+ entry: {
34
+ app: path.join(__dirname, 'src/App.tsx'),
35
+ },
33
36
  mode: 'development',
34
37
  devServer: {
35
38
  contentBase: path.join(__dirname, 'public'),
@@ -23,10 +23,14 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
+ const path = require('path')
26
27
  const { merge } = require('webpack-merge')
27
28
  const base = require('../../webpack.base.config')(__dirname)
28
29
  const browser = require('../../webpack.browser.config')()
29
30
 
30
31
  module.exports = merge(base, browser, {
32
+ entry: {
33
+ app: path.join(__dirname, 'src/index.ts'),
34
+ },
31
35
  mode: 'production',
32
36
  })
@@ -1 +0,0 @@
1
- export { LodeContext, defaultLodeContextValue } from './lode';
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "LodeContext", {
7
- enumerable: true,
8
- get: function get() {
9
- return _lode.LodeContext;
10
- }
11
- });
12
- Object.defineProperty(exports, "defaultLodeContextValue", {
13
- enumerable: true,
14
- get: function get() {
15
- return _lode.defaultLodeContextValue;
16
- }
17
- });
18
-
19
- var _lode = require("./lode");
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAyBA","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nexport { LodeContext, defaultLodeContextValue } from './lode'\n"],"file":"index.js"}
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen';
3
- interface LodeContextProps {
4
- examples: IExampleMine;
5
- declarations?: IDeclarationMine;
6
- }
7
- export declare const defaultLodeContextValue: LodeContextProps;
8
- export declare const LodeContext: import("react").Context<LodeContextProps>;
9
- export {};