@integration-app/react 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/dist/index.d.ts +371 -165
  2. package/dist/index.js +510 -234
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.module.d.ts +371 -165
  5. package/dist/index.module.mjs +500 -235
  6. package/dist/index.module.mjs.map +1 -1
  7. package/dist/index.umd.d.ts +371 -165
  8. package/dist/index.umd.js +510 -238
  9. package/dist/index.umd.js.map +1 -1
  10. package/package.json +5 -2
  11. package/src/actions/useAction.ts +35 -0
  12. package/src/actions/useActionInstance.ts +56 -0
  13. package/src/actions/useActionInstances.ts +11 -0
  14. package/src/actions/useActions.ts +11 -0
  15. package/src/app-events/useAppEventSubscription.ts +6 -6
  16. package/src/app-events/useAppEventSubscriptions.ts +5 -4
  17. package/src/app-events/useAppEventType.ts +10 -7
  18. package/src/app-events/useAppEventTypes.ts +2 -4
  19. package/src/app-events/useAppEvents.ts +2 -4
  20. package/src/contexts/index.tsx +4 -0
  21. package/src/data-collections/useDataCollectionSpec.ts +26 -0
  22. package/src/data-links/useDataLinkTable.ts +18 -0
  23. package/src/data-links/useDataLinkTableInstance.ts +39 -0
  24. package/src/data-links/useDataLinkTableInstances.ts +19 -0
  25. package/src/data-links/useDataLinkTables.ts +11 -0
  26. package/src/data-sources/useDataSource.ts +29 -6
  27. package/src/data-sources/useDataSourceEvents.ts +2 -4
  28. package/src/data-sources/useDataSourceInstance.ts +120 -26
  29. package/src/data-sources/useDataSourceInstanceCollection.ts +14 -4
  30. package/src/data-sources/useDataSourceInstanceLocations.ts +17 -6
  31. package/src/data-sources/useDataSourceInstances.ts +5 -4
  32. package/src/data-sources/useDataSources.ts +2 -4
  33. package/src/field-mappings/useFieldMapping.ts +29 -8
  34. package/src/field-mappings/useFieldMappingInstance.ts +35 -12
  35. package/src/field-mappings/useFieldMappingInstances.ts +5 -4
  36. package/src/field-mappings/useFieldMappings.ts +2 -4
  37. package/src/flows/useFlow.ts +29 -8
  38. package/src/flows/useFlowInstance.ts +62 -5
  39. package/src/flows/useFlowInstances.ts +2 -4
  40. package/src/flows/useFlowRun.ts +18 -6
  41. package/src/flows/useFlowRuns.ts +5 -5
  42. package/src/flows/useFlows.ts +5 -5
  43. package/src/hooks/useElement.tsx +137 -149
  44. package/src/hooks/useElements.tsx +44 -73
  45. package/src/hooks/useIntegrationAppSWR.tsx +13 -0
  46. package/src/index.tsx +27 -14
  47. package/src/integrations/useConnection.ts +14 -5
  48. package/src/integrations/useConnections.ts +3 -4
  49. package/src/integrations/useConnectorSpec.ts +7 -18
  50. package/src/integrations/useIntegration.ts +11 -7
  51. package/src/integrations/useIntegrations.ts +3 -4
  52. package/src/screens/useScreen.ts +19 -0
  53. package/rollup.dts.config.mjs +0 -21
  54. package/src/flows/useFlowTemplate.ts +0 -0
  55. package/src/flows/useFlowTemplates.ts +0 -0
  56. package/src/hooks/useGetter.tsx +0 -38
@@ -0,0 +1,19 @@
1
+ import {
2
+ CreateScreenRequest,
3
+ Screen,
4
+ ScreenAccessor,
5
+ ScreenSelector,
6
+ UpdateScreenRequest,
7
+ } from '@integration-app/sdk'
8
+ import { useElement } from '../hooks/useElement'
9
+
10
+ export function useScreen(selector: ScreenSelector | string) {
11
+ const { item: screen, ...rest } = useElement<
12
+ Screen,
13
+ UpdateScreenRequest,
14
+ CreateScreenRequest,
15
+ ScreenAccessor
16
+ >(selector, (integrationApp) => integrationApp.screen(selector))
17
+
18
+ return { screen, ...rest }
19
+ }
@@ -1,21 +0,0 @@
1
- // Flat dts files into one
2
- import dts from 'rollup-plugin-dts'
3
-
4
- const config = [
5
- // Generate dts files for each bundle from *.d.ts files
6
- {
7
- input: './dist/dts/index.d.ts',
8
- output: [
9
- { file: 'dist/index.d.ts', format: 'commonjs' },
10
- { file: 'dist/index.module.d.ts', format: 'es' },
11
- {
12
- file: 'dist/index.umd.d.ts',
13
- format: 'umd',
14
- name: 'integrationAppReact',
15
- },
16
- ],
17
- plugins: [dts()],
18
- },
19
- ]
20
-
21
- export default config
File without changes
File without changes
@@ -1,38 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { useIntegrationApp } from '../contexts/integration-app-context'
3
-
4
- export default function useGetter<Type = any>(
5
- key: string,
6
- getter: () => Promise<Type>,
7
- ) {
8
- const integrationApp = useIntegrationApp()
9
- const [data, setData] = useState<Type>()
10
- const [loading, setLoading] = useState<boolean>(true)
11
- const [error, setError] = useState<Error>(null)
12
- const [refreshCounter, setRefreshCounter] = useState<number>(0)
13
-
14
- function refresh() {
15
- setRefreshCounter(refreshCounter + 1)
16
- }
17
-
18
- useEffect(() => {
19
- if (key !== undefined) {
20
- setLoading(true)
21
- setError(null)
22
- if (integrationApp) {
23
- getter()
24
- .then(setData)
25
- .catch(setError)
26
- .finally(() => setLoading(false))
27
- } else {
28
- setError(
29
- new Error(
30
- 'IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?',
31
- ),
32
- )
33
- }
34
- }
35
- }, [integrationApp, key, refreshCounter])
36
-
37
- return { data, loading, error, refresh }
38
- }