@integration-app/react 0.2.0 → 0.3.1

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 (57) hide show
  1. package/README.md +49 -34
  2. package/dist/index.d.ts +377 -160
  3. package/dist/index.js +517 -226
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.module.d.ts +377 -160
  6. package/dist/index.module.mjs +506 -227
  7. package/dist/index.module.mjs.map +1 -1
  8. package/dist/index.umd.d.ts +377 -160
  9. package/dist/index.umd.js +517 -230
  10. package/dist/index.umd.js.map +1 -1
  11. package/package.json +16 -9
  12. package/src/actions/useAction.ts +35 -0
  13. package/src/actions/useActionInstance.ts +56 -0
  14. package/src/actions/useActionInstances.ts +11 -0
  15. package/src/actions/useActions.ts +11 -0
  16. package/src/app-events/useAppEventSubscription.ts +6 -6
  17. package/src/app-events/useAppEventSubscriptions.ts +5 -4
  18. package/src/app-events/useAppEventType.ts +10 -7
  19. package/src/app-events/useAppEventTypes.ts +2 -4
  20. package/src/app-events/useAppEvents.ts +2 -4
  21. package/src/contexts/index.tsx +4 -0
  22. package/src/contexts/integration-app-context.tsx +11 -2
  23. package/src/data-collections/useDataCollectionSpec.ts +26 -0
  24. package/src/data-links/useDataLinkTable.ts +18 -0
  25. package/src/data-links/useDataLinkTableInstance.ts +39 -0
  26. package/src/data-links/useDataLinkTableInstances.ts +19 -0
  27. package/src/data-links/useDataLinkTables.ts +11 -0
  28. package/src/data-sources/useDataSource.ts +29 -6
  29. package/src/data-sources/useDataSourceEvents.ts +2 -4
  30. package/src/data-sources/useDataSourceInstance.ts +120 -26
  31. package/src/data-sources/useDataSourceInstanceCollection.ts +14 -4
  32. package/src/data-sources/useDataSourceInstanceLocations.ts +17 -6
  33. package/src/data-sources/useDataSourceInstances.ts +17 -0
  34. package/src/data-sources/useDataSources.ts +2 -4
  35. package/src/field-mappings/useFieldMapping.ts +29 -8
  36. package/src/field-mappings/useFieldMappingInstance.ts +37 -14
  37. package/src/field-mappings/useFieldMappingInstances.ts +6 -5
  38. package/src/field-mappings/useFieldMappings.ts +2 -4
  39. package/src/flows/useFlow.ts +28 -6
  40. package/src/flows/useFlowInstance.ts +62 -5
  41. package/src/flows/useFlowInstances.ts +2 -4
  42. package/src/flows/useFlowRun.ts +18 -6
  43. package/src/flows/useFlowRuns.ts +5 -5
  44. package/src/flows/useFlows.ts +5 -5
  45. package/src/hooks/useElement.tsx +142 -136
  46. package/src/hooks/useElements.tsx +44 -73
  47. package/src/hooks/useIntegrationAppSWR.tsx +13 -0
  48. package/src/index.tsx +29 -16
  49. package/src/integrations/useConnection.ts +14 -5
  50. package/src/integrations/useConnections.ts +3 -4
  51. package/src/integrations/useConnectorSpec.ts +14 -0
  52. package/src/integrations/useIntegration.ts +11 -7
  53. package/src/integrations/useIntegrations.ts +3 -4
  54. package/src/screens/useScreen.ts +19 -0
  55. package/rollup.config.mjs +0 -64
  56. package/src/hooks/useGetter.tsx +0 -38
  57. package/src/integrations/useConnectionSpec.ts +0 -25
package/rollup.config.mjs DELETED
@@ -1,64 +0,0 @@
1
- // Compile TypeScript files
2
- import typescript from '@rollup/plugin-typescript'
3
- // Convert CommonJS modules to ES6, so they can be included in a Rollup bundle
4
- import commonjs from '@rollup/plugin-commonjs'
5
- // Locate modules using the Node resolution algorithm, for using third party modules in node_modules
6
- import nodeResolve from '@rollup/plugin-node-resolve'
7
- // Flat dts files into one
8
- import dts from 'rollup-plugin-dts'
9
- // Convert .json files to ES6 modules
10
- import rollupJson from '@rollup/plugin-json'
11
-
12
- const config = [
13
- {
14
- input: './src/index.tsx',
15
- output: [
16
- {
17
- // CommonJS bundle
18
- file: './dist/index.js',
19
- format: 'cjs',
20
- sourcemap: true,
21
- },
22
- {
23
- // ESM bundle
24
- file: './dist/index.module.mjs',
25
- format: 'esm',
26
- sourcemap: true,
27
- },
28
- {
29
- // Universal Module Definition, works as `amd`, `cjs` and `iife` all in one
30
- file: './dist/index.umd.js',
31
- format: 'umd',
32
- name: 'integrationAppReact',
33
- sourcemap: true,
34
- },
35
- ],
36
- external: [/node_modules/, '@integration-app/sdk'],
37
- plugins: [
38
- typescript({
39
- tsconfig: 'tsconfig.json',
40
- }),
41
- commonjs(),
42
- nodeResolve({
43
- browser: true,
44
- }),
45
- rollupJson(),
46
- ],
47
- },
48
- // Generate dts files for each bundle from *.d.ts files
49
- {
50
- input: './dist/dts/index.d.ts',
51
- output: [
52
- { file: 'dist/index.d.ts', format: 'commonjs' },
53
- { file: 'dist/index.module.d.ts', format: 'es' },
54
- {
55
- file: 'dist/index.umd.d.ts',
56
- format: 'umd',
57
- name: 'integrationAppReact',
58
- },
59
- ],
60
- plugins: [dts()],
61
- },
62
- ]
63
-
64
- export default config
@@ -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
- }
@@ -1,25 +0,0 @@
1
- import { ConnectionSpec } from '@integration-app/sdk'
2
- import { useEffect, useState } from 'react'
3
- import { useIntegrationApp } from '../contexts/integration-app-context'
4
-
5
- export function useConnectorSpec(integrationKey: string) {
6
- const integrationApp = useIntegrationApp()
7
- const [data, setData] = useState<ConnectionSpec | null>(null)
8
- const [loading, setLoading] = useState(true)
9
- const [error, setError] = useState<Error>(null)
10
-
11
- useEffect(() => {
12
- if (!integrationApp) {
13
- return
14
- }
15
-
16
- integrationApp
17
- .integration(integrationKey)
18
- .getConnectorSpec()
19
- .then(setData)
20
- .catch(setError)
21
- .finally(() => setLoading(false))
22
- }, [integrationApp, integrationKey])
23
-
24
- return { data, loading, error }
25
- }