@integration-app/react 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/dist/index.d.ts +145 -107
  2. package/dist/index.js +90 -69
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.module.d.ts +145 -107
  5. package/dist/index.module.mjs +87 -69
  6. package/dist/index.module.mjs.map +1 -1
  7. package/dist/index.umd.d.ts +145 -107
  8. package/dist/index.umd.js +91 -70
  9. package/dist/index.umd.js.map +1 -1
  10. package/package.json +6 -6
  11. package/src/_modules/README.txt +1 -0
  12. package/src/_modules/awesome-debounce-promise.ts +8 -0
  13. package/src/actions/useAction.ts +4 -2
  14. package/src/actions/useActionInstance.ts +6 -2
  15. package/src/app-data-schemas/useAppDataSchema.ts +20 -0
  16. package/src/app-data-schemas/useAppDataSchemaInstance.ts +43 -0
  17. package/src/app-data-schemas/useAppDataSchemaInstances.ts +19 -0
  18. package/src/app-data-schemas/useAppDataSchemas.ts +11 -0
  19. package/src/app-events/useAppEventSubscription.ts +7 -5
  20. package/src/app-events/useAppEventType.ts +4 -2
  21. package/src/contexts/integration-app-context.tsx +6 -0
  22. package/src/customers/useCustomer.ts +2 -2
  23. package/src/data-collections/useDataCollectionSpec.ts +5 -2
  24. package/src/data-links/useDataLinkTable.ts +4 -2
  25. package/src/data-links/useDataLinkTableInstance.ts +2 -2
  26. package/src/data-sources/useDataSource.ts +6 -2
  27. package/src/data-sources/useDataSourceInstance.ts +10 -12
  28. package/src/field-mappings/useFieldMapping.ts +8 -2
  29. package/src/field-mappings/useFieldMappingInstance.ts +4 -2
  30. package/src/flows/useFlow.ts +4 -2
  31. package/src/flows/useFlowInstance.ts +8 -3
  32. package/src/flows/useFlowRun.ts +2 -2
  33. package/src/hooks/useElement.tsx +43 -32
  34. package/src/hooks/useElements.tsx +6 -0
  35. package/src/index.tsx +5 -1
  36. package/src/integrations/useIntegration.ts +4 -2
  37. package/tsconfig.json +2 -2
  38. package/rollup.dts.config.mjs +0 -21
  39. package/src/data-sources/useDataSourceInstanceLocations.ts +0 -41
@@ -2,19 +2,21 @@ import {
2
2
  AppEventSubscription,
3
3
  AppEventSubscriptionAccessor,
4
4
  AppEventSubscriptionSelector,
5
- IAppEventSubscriptionUpdate,
5
+ AppEventSubscriptionUpdateRequest,
6
6
  } from '@integration-app/sdk'
7
7
  import { useElement } from '../hooks/useElement'
8
8
 
9
9
  export function useAppEventSubscription(
10
- selector: string | AppEventSubscriptionSelector,
10
+ selector: string | AppEventSubscriptionSelector | undefined,
11
11
  ) {
12
12
  const { item: appEventSubscription, ...rest } = useElement<
13
13
  AppEventSubscription,
14
- IAppEventSubscriptionUpdate,
15
- IAppEventSubscriptionUpdate,
14
+ AppEventSubscriptionUpdateRequest,
15
+ AppEventSubscriptionUpdateRequest,
16
16
  AppEventSubscriptionAccessor
17
- >(selector, (integrationApp) => integrationApp.appEventSubscription(selector))
17
+ >(selector, (integrationApp) =>
18
+ selector ? integrationApp.appEventSubscription(selector) : undefined,
19
+ )
18
20
 
19
21
  return { appEventSubscription, ...rest }
20
22
  }
@@ -6,13 +6,15 @@ import {
6
6
  import { AppEventTypeAccessor } from '@integration-app/sdk'
7
7
  import { useElement } from '../hooks/useElement'
8
8
 
9
- export function useAppEventType(id: string) {
9
+ export function useAppEventType(selector: string | undefined) {
10
10
  const { item: appEventType, ...rest } = useElement<
11
11
  AppEventType,
12
12
  UpdateAppEventTypeRequest,
13
13
  CreateAppEventTypeRequest,
14
14
  AppEventTypeAccessor
15
- >(id, (integrationApp) => integrationApp.appEventType(id))
15
+ >(selector, (integrationApp) =>
16
+ selector ? integrationApp.appEventType(selector) : undefined,
17
+ )
16
18
 
17
19
  return { appEventType, ...rest }
18
20
  }
@@ -1,6 +1,8 @@
1
1
  import { IntegrationAppClient } from '@integration-app/sdk'
2
2
  import { createContext, ReactNode, useContext, useMemo } from 'react'
3
3
 
4
+ /* FIXME: strictNullCheck temporary fix */
5
+ // @ts-expect-error TS(2345): Argument of type 'null' is not assignable to param... Remove this comment to see the full error message
4
6
  const IntegrationAppContext = createContext<IntegrationAppClient>(null)
5
7
 
6
8
  IntegrationAppContext.displayName = 'IntegrationAppClientContext'
@@ -26,7 +28,11 @@ export const IntegrationAppProvider = ({
26
28
  fetchToken,
27
29
  credentials,
28
30
  fetchCredentials,
31
+ /* FIXME: strictNullCheck temporary fix */
32
+ // @ts-expect-error TS(2322): Type 'null' is not assignable to type 'string'.
29
33
  apiUri = null,
34
+ /* FIXME: strictNullCheck temporary fix */
35
+ // @ts-expect-error TS(2322): Type 'null' is not assignable to type 'string'.
30
36
  uiUri = null,
31
37
  children,
32
38
  }: IntegrationAppProviderProps) => {
@@ -7,13 +7,13 @@ import {
7
7
  } from '@integration-app/sdk'
8
8
  import { useElement } from '../hooks/useElement'
9
9
 
10
- export function useCustomer(selector: UserSelector | string) {
10
+ export function useCustomer(selector: UserSelector | string | undefined) {
11
11
  const { item: customer, ...rest } = useElement<
12
12
  User,
13
13
  UpdateUserRequest,
14
14
  CreateUserRequest,
15
15
  UserAccessor
16
- >(selector, (c) => c.customer(selector))
16
+ >(selector, (c) => (selector ? c.customer(selector) : undefined))
17
17
 
18
18
  return { customer, ...rest }
19
19
  }
@@ -1,5 +1,5 @@
1
- import { useIntegrationApp } from 'contexts/integration-app-context'
2
1
  import { DataCollectionSpec, parseDataLocationPath } from '@integration-app/sdk'
2
+ import { useIntegrationApp } from 'contexts/integration-app-context'
3
3
  import useSWR from 'swr'
4
4
 
5
5
  export function useDataCollectionSpec({
@@ -19,7 +19,10 @@ export function useDataCollectionSpec({
19
19
  dataCollectionKey && integrationId
20
20
  ? `/integrations/${integrationId}/data/${dataCollectionKey}`
21
21
  : null,
22
- () => client.integration(integrationId).getDataLocation(dataCollectionKey),
22
+ () =>
23
+ /* FIXME: strictNullCheck temporary fix */
24
+ // @ts-expect-error TS(2345): Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message
25
+ client.integration(integrationId).getDataCollection(dataCollectionKey),
23
26
  )
24
27
 
25
28
  return dataCollectionSpec
@@ -6,13 +6,15 @@ import {
6
6
  } from '@integration-app/sdk'
7
7
  import { useElement } from '../hooks/useElement'
8
8
 
9
- export function useDataLinkTable(selector: string) {
9
+ export function useDataLinkTable(selector: string | undefined) {
10
10
  const { item: dataLinkTable, ...rest } = useElement<
11
11
  DataLinkTable,
12
12
  UpdateDataLinkTableRequest,
13
13
  CreateDataLinkTableRequest,
14
14
  DataLinkTableAccessor
15
- >(selector, (integrationApp) => integrationApp.dataLinkTable(selector))
15
+ >(selector, (integrationApp) =>
16
+ selector ? integrationApp.dataLinkTable(selector) : undefined,
17
+ )
16
18
 
17
19
  return { dataLinkTable, ...rest }
18
20
  }
@@ -8,7 +8,7 @@ import {
8
8
  import { useElement } from '../hooks/useElement'
9
9
 
10
10
  export function useDataLinkTableInstance(
11
- selector: string | DataLinkTableInstanceSelector,
11
+ selector: string | DataLinkTableInstanceSelector | undefined,
12
12
  ) {
13
13
  const {
14
14
  item: dataLinkTableInstance,
@@ -21,7 +21,7 @@ export function useDataLinkTableInstance(
21
21
  CreateDataLinkTableInstanceRequest,
22
22
  DataLinkTableInstanceAccessor
23
23
  >(selector, (integrationApp) =>
24
- integrationApp.dataLinkTableInstance(selector),
24
+ selector ? integrationApp.dataLinkTableInstance(selector) : undefined,
25
25
  )
26
26
 
27
27
  return {
@@ -7,7 +7,9 @@ import {
7
7
  } from '@integration-app/sdk'
8
8
  import { useElement } from '../hooks/useElement'
9
9
 
10
- export function useDataSource(selector: string | DataSourceSelector) {
10
+ export function useDataSource(
11
+ selector: string | DataSourceSelector | undefined,
12
+ ) {
11
13
  const {
12
14
  item: dataSource,
13
15
  refresh,
@@ -18,7 +20,9 @@ export function useDataSource(selector: string | DataSourceSelector) {
18
20
  UpdateDataSourceRequest,
19
21
  CreateDataSourceRequest,
20
22
  DataSourceAccessor
21
- >(selector, (integrationApp) => integrationApp.dataSource(selector))
23
+ >(selector, (integrationApp) =>
24
+ selector ? integrationApp.dataSource(selector) : undefined,
25
+ )
22
26
 
23
27
  async function apply(integrationKeys: string[]) {
24
28
  const result = await accessor?.apply(integrationKeys)
@@ -7,14 +7,13 @@ import {
7
7
  OpenDataSourceConfigurationOptions,
8
8
  DataSourceInstance,
9
9
  UpdateDataSourceInstanceRequest,
10
- DataDirectoryListRequest,
11
10
  DataCollectionListRequest,
12
11
  CreateDataSourceInstanceRequest,
13
12
  } from '@integration-app/sdk'
14
13
  import { useElement } from '../hooks/useElement'
15
14
 
16
15
  export function useDataSourceInstance(
17
- selector: string | DataSourceInstanceSelector,
16
+ selector: string | DataSourceInstanceSelector | undefined,
18
17
  ) {
19
18
  const {
20
19
  item: dataSourceInstance,
@@ -26,7 +25,9 @@ export function useDataSourceInstance(
26
25
  UpdateDataSourceInstanceRequest,
27
26
  CreateDataSourceInstanceRequest,
28
27
  DataSourceInstanceAccessor
29
- >(selector, (integrationApp) => integrationApp.dataSourceInstance(selector))
28
+ >(selector, (integrationApp) =>
29
+ selector ? integrationApp.dataSourceInstance(selector) : undefined,
30
+ )
30
31
 
31
32
  async function setup() {
32
33
  await accessor?.setup()
@@ -86,14 +87,20 @@ export function useDataSourceInstance(
86
87
  }
87
88
 
88
89
  async function createRecord(request?: DataCollectionCreateRequest) {
90
+ /* FIXME: strictNullCheck temporary fix */
91
+ // @ts-expect-error TS(2345): Argument of type 'DataCollectionCreateRequest | un... Remove this comment to see the full error message
89
92
  return accessor?.createRecord(request)
90
93
  }
91
94
 
92
95
  async function updateRecord(request?: DataCollectionUpdateRequest) {
96
+ /* FIXME: strictNullCheck temporary fix */
97
+ // @ts-expect-error TS(2345): Argument of type 'DataCollectionUpdateRequest | un... Remove this comment to see the full error message
93
98
  return accessor?.updateRecord(request)
94
99
  }
95
100
 
96
101
  async function deleteRecord(id?: string) {
102
+ /* FIXME: strictNullCheck temporary fix */
103
+ // @ts-expect-error TS(2345): Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message
97
104
  return accessor?.deleteRecord(id)
98
105
  }
99
106
 
@@ -105,14 +112,6 @@ export function useDataSourceInstance(
105
112
  return accessor?.getCollection()
106
113
  }
107
114
 
108
- async function getLocations(
109
- request: DataDirectoryListRequest & {
110
- path?: string
111
- },
112
- ) {
113
- return accessor?.getLocations(request)
114
- }
115
-
116
115
  return {
117
116
  dataSourceInstance,
118
117
  accessor,
@@ -134,7 +133,6 @@ export function useDataSourceInstance(
134
133
  updateRecord,
135
134
  deleteRecord,
136
135
  unifiedFieldsToNative,
137
- getLocations,
138
136
  getCollection,
139
137
 
140
138
  ...rest,
@@ -7,7 +7,9 @@ import {
7
7
  } from '@integration-app/sdk'
8
8
  import { useElement } from '../hooks/useElement'
9
9
 
10
- export function useFieldMapping(selector: FieldMappingSelector | string) {
10
+ export function useFieldMapping(
11
+ selector: FieldMappingSelector | string | undefined,
12
+ ) {
11
13
  const {
12
14
  item: fieldMapping,
13
15
  accessor,
@@ -18,11 +20,15 @@ export function useFieldMapping(selector: FieldMappingSelector | string) {
18
20
  UpdateFieldMappingRequest,
19
21
  CreateFieldMappingRequest,
20
22
  FieldMappingAccessor
21
- >(selector, (integrationApp) => integrationApp.fieldMapping(selector))
23
+ >(selector, (integrationApp) =>
24
+ selector ? integrationApp.fieldMapping(selector) : undefined,
25
+ )
22
26
 
23
27
  async function apply(integrationKeys: string[]): Promise<FieldMapping[]> {
24
28
  const result = await accessor?.apply(integrationKeys)
25
29
  await refresh()
30
+ /* FIXME: strictNullCheck temporary fix */
31
+ // @ts-expect-error TS(2322): Type 'FieldMapping[] | undefined' is not assignabl... Remove this comment to see the full error message
26
32
  return result
27
33
  }
28
34
 
@@ -9,7 +9,7 @@ import {
9
9
  import { useElement } from '../hooks/useElement'
10
10
 
11
11
  export function useFieldMappingInstance(
12
- selector: string | FieldMappingInstanceSelector,
12
+ selector: string | FieldMappingInstanceSelector | undefined,
13
13
  ) {
14
14
  const {
15
15
  item: fieldMappingInstance,
@@ -21,7 +21,9 @@ export function useFieldMappingInstance(
21
21
  UpdateFieldMappingInstanceRequest,
22
22
  CreateFieldMappingInstanceRequest,
23
23
  FieldMappingInstanceAccessor
24
- >(selector, (integrationApp) => integrationApp.fieldMappingInstance(selector))
24
+ >(selector, (integrationApp) =>
25
+ selector ? integrationApp.fieldMappingInstance(selector) : undefined,
26
+ )
25
27
 
26
28
  async function setup() {
27
29
  await accessor?.setup()
@@ -7,7 +7,7 @@ import {
7
7
  } from '@integration-app/sdk'
8
8
  import { useElement } from '../hooks/useElement'
9
9
 
10
- export function useFlow(selector: string | FlowSelector) {
10
+ export function useFlow(selector: string | FlowSelector | undefined) {
11
11
  const {
12
12
  item: flow,
13
13
  accessor,
@@ -15,12 +15,14 @@ export function useFlow(selector: string | FlowSelector) {
15
15
  ...rest
16
16
  } = useElement<Flow, UpdateFlowRequest, CreateFlowRequest, FlowAccessor>(
17
17
  selector,
18
- (integrationApp) => integrationApp.flow(selector),
18
+ (integrationApp) => (selector ? integrationApp.flow(selector) : undefined),
19
19
  )
20
20
 
21
21
  async function apply(integrationKeys: string[]): Promise<Flow[]> {
22
22
  const result = await accessor?.apply(integrationKeys)
23
23
  await refresh()
24
+ /* FIXME: strictNullCheck temporary fix */
25
+ // @ts-expect-error TS(2322): Type 'Flow[] | undefined' is not assignable to typ... Remove this comment to see the full error message
24
26
  return result
25
27
  }
26
28
 
@@ -5,10 +5,13 @@ import {
5
5
  OpenFlowInstanceConfigurationOptions,
6
6
  RunFlowOptions,
7
7
  UpdateFlowInstanceRequest,
8
+ CreateFlowInstanceRequest,
8
9
  } from '@integration-app/sdk'
9
10
  import { useElement } from '../hooks/useElement'
10
11
 
11
- export function useFlowInstance(selector: string | FlowInstanceSelector) {
12
+ export function useFlowInstance(
13
+ selector: string | FlowInstanceSelector | undefined,
14
+ ) {
12
15
  const {
13
16
  item: flowInstance,
14
17
  accessor,
@@ -17,9 +20,11 @@ export function useFlowInstance(selector: string | FlowInstanceSelector) {
17
20
  } = useElement<
18
21
  FlowInstance,
19
22
  UpdateFlowInstanceRequest,
20
- UpdateFlowInstanceRequest,
23
+ CreateFlowInstanceRequest,
21
24
  FlowInstanceAccessor
22
- >(selector, (integrationApp) => integrationApp.flowInstance(selector))
25
+ >(selector, (integrationApp) =>
26
+ selector ? integrationApp.flowInstance(selector) : undefined,
27
+ )
23
28
 
24
29
  async function enable() {
25
30
  await accessor?.enable()
@@ -1,7 +1,7 @@
1
1
  import { FlowRun, FlowRunAccessor } from '@integration-app/sdk'
2
2
  import { useElement } from '../hooks/useElement'
3
3
 
4
- export function useFlowRun(id: string) {
4
+ export function useFlowRun(id: string | undefined) {
5
5
  const {
6
6
  item: flowRun,
7
7
  archive,
@@ -9,7 +9,7 @@ export function useFlowRun(id: string) {
9
9
  error,
10
10
  loading,
11
11
  } = useElement<FlowRun, never, never, FlowRunAccessor>(id, (integrationApp) =>
12
- integrationApp.flowRun(id),
12
+ id ? integrationApp.flowRun(id) : undefined,
13
13
  )
14
14
 
15
15
  return {
@@ -1,5 +1,5 @@
1
1
  import { IntegrationAppClient } from '@integration-app/sdk'
2
- import AwesomeDebouncePromise from 'awesome-debounce-promise'
2
+ import AwesomeDebouncePromise from '_modules/awesome-debounce-promise'
3
3
  import { useIntegrationApp } from 'contexts/integration-app-context'
4
4
  import useSWR from 'swr'
5
5
 
@@ -36,7 +36,7 @@ export function useElement<
36
36
  selector: any,
37
37
  accessorGenerator: (
38
38
  integrationAppClient: IntegrationAppClient,
39
- ) => ElementAccessor,
39
+ ) => ElementAccessor | undefined,
40
40
  ) {
41
41
  const integrationApp = useIntegrationApp()
42
42
 
@@ -48,40 +48,44 @@ export function useElement<
48
48
  }
49
49
  const elementKey = JSON.stringify(elementKeyData)
50
50
 
51
- if (!elementStateCache.has(elementKey)) {
52
- elementStateCache.set(elementKey, {
53
- updatedLocally: false,
54
- savingToServer: false,
55
- debouncedPut: AwesomeDebouncePromise(async (data) => {
56
- elementState.updatedLocally = false
57
- elementState.savingToServer = true
58
-
59
- try {
60
- const result = await accessor?.put(data)
61
- if (!elementState.updatedLocally) {
62
- // Update savingToSever so that cached versions in each hook are updated when they react to 'mutate' below
63
- // Yes, this duplicates the one in `finally`, but but the time that one is called it's too late since `mutate` already did its job.
64
- elementState.savingToServer = false
65
- // When we received updated state of the element,
66
- // apply it to the context as long as we didn't make any other changes locally
67
- // meanwhile.
68
- await mutate(result, false)
69
- }
70
- } catch (e) {
71
- elementState.updatedLocally = true
72
- throw e
73
- } finally {
51
+ const elementState: ElementState = elementStateCache.get(elementKey) ?? {
52
+ updatedLocally: false,
53
+ savingToServer: false,
54
+ debouncedPut: AwesomeDebouncePromise(async (data) => {
55
+ elementState.updatedLocally = false
56
+ elementState.savingToServer = true
57
+
58
+ try {
59
+ /* FIXME: strictNullCheck temporary fix */
60
+ // @ts-expect-error TS(2722): Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
61
+ const result = await accessor?.put(data)
62
+ if (!elementState.updatedLocally) {
63
+ // Update savingToSever so that cached versions in each hook are updated when they react to 'mutate' below
64
+ // Yes, this duplicates the one in `finally`, but by the time that one is called it's too late since `mutate` already did its job.
74
65
  elementState.savingToServer = false
66
+ // When we received updated state of the element,
67
+ // apply it to the context as long as we didn't make any other changes locally
68
+ // meanwhile.
69
+ await mutate(result, false)
75
70
  }
76
- }, 500),
77
- })
71
+ } catch (e) {
72
+ elementState.updatedLocally = true
73
+ throw e
74
+ } finally {
75
+ elementState.savingToServer = false
76
+ }
77
+ }, 500),
78
78
  }
79
79
 
80
- const elementState = elementStateCache.get(elementKey)
80
+ if (!elementStateCache.has(elementKey)) {
81
+ elementStateCache.set(elementKey, elementState)
82
+ }
81
83
 
82
- const accessor = integrationApp ? accessorGenerator(integrationApp) : null
84
+ const accessor = integrationApp
85
+ ? accessorGenerator(integrationApp)
86
+ : undefined
83
87
 
84
- const swrKey = accessor && selector ? `element:${elementKey}` : null // do not fetch anything if selector or accessor is not defined
88
+ const swrKey = accessor && selector ? `element:${elementKey}` : undefined // do not fetch anything if selector or accessor is not defined
85
89
 
86
90
  const {
87
91
  data: item,
@@ -98,12 +102,16 @@ export function useElement<
98
102
  const refreshing = isValidating
99
103
 
100
104
  async function refresh(): Promise<Element> {
105
+ /* FIXME: strictNullCheck temporary fix */
106
+ // @ts-expect-error TS(2322): Type 'Awaited<Element> | undefined' is not assigna... Remove this comment to see the full error message
101
107
  return await mutate()
102
108
  }
103
109
 
104
110
  async function put(data: UpdateRequest) {
105
111
  if (!accessor?.put) {
106
112
  throw new Error(
113
+ /* FIXME: strictNullCheck temporary fix */
114
+ // @ts-expect-error TS(2531): Object is possibly 'null'.
107
115
  `"put method is not supported for accessor ${accessor.constructor.name}`,
108
116
  )
109
117
  }
@@ -113,7 +121,7 @@ export function useElement<
113
121
  // We don't know which fields are "innate" for the element and should stay
114
122
  // and which should be removed by put, so we'll do a simple patch.
115
123
  // We'll update data with actual value from the server after put is done.
116
- const newLocalData = {
124
+ const newLocalData: any = {
117
125
  ...item,
118
126
  ...data,
119
127
  }
@@ -137,6 +145,8 @@ export function useElement<
137
145
  return
138
146
  }
139
147
 
148
+ /* FIXME: strictNullCheck temporary fix */
149
+ // @ts-expect-error TS(2345): Argument of type '{ archivedAt: string; }' is not ... Remove this comment to see the full error message
140
150
  await mutate({ ...item, archivedAt: new Date().toISOString() }, false)
141
151
  await accessor?.archive()
142
152
  await mutate()
@@ -145,7 +155,7 @@ export function useElement<
145
155
  async function create(data: CreateRequest) {
146
156
  if (!accessor?.create) {
147
157
  throw new Error(
148
- `"create method is not supported for accessor ${accessor.constructor.name}`,
158
+ `"create method is not supported for accessor ${accessor?.constructor.name}`,
149
159
  )
150
160
  }
151
161
 
@@ -160,6 +170,7 @@ export function useElement<
160
170
  item,
161
171
 
162
172
  loading,
173
+
163
174
  saving: elementState.updatedLocally || elementState.savingToServer,
164
175
 
165
176
  error,
@@ -21,11 +21,15 @@ export function useElements<Item>(route: string, query = {}) {
21
21
  })}`
22
22
 
23
23
  // reached the end
24
+ /* FIXME: strictNullCheck temporary fix */
25
+ // @ts-expect-error TS(2531): Object is possibly 'null'.
24
26
  if (previousPageData.items?.length < LIMIT) return null
25
27
 
26
28
  return `/${route}?${qs.stringify({
27
29
  ...query,
28
30
  limit: LIMIT,
31
+ /* FIXME: strictNullCheck temporary fix */
32
+ // @ts-expect-error TS(2531): Object is possibly 'null'.
29
33
  cursor: previousPageData.cursor,
30
34
  })}`
31
35
  }
@@ -43,6 +47,8 @@ export function useElements<Item>(route: string, query = {}) {
43
47
  const refreshing = isValidating
44
48
 
45
49
  async function loadMore() {
50
+ /* FIXME: strictNullCheck temporary fix */
51
+ // @ts-expect-error TS(2532): Object is possibly 'undefined'.
46
52
  const hasMoreToLoad = data[size - 1]?.items?.length === LIMIT
47
53
 
48
54
  if (hasMoreToLoad) {
package/src/index.tsx CHANGED
@@ -17,7 +17,6 @@ export { useDataSource } from './data-sources/useDataSource.js'
17
17
  export { useDataSourceEvents } from './data-sources/useDataSourceEvents.js'
18
18
  export { useDataSourceInstance } from './data-sources/useDataSourceInstance.js'
19
19
  export { useDataSourceInstanceCollection } from './data-sources/useDataSourceInstanceCollection.js'
20
- export { useDataSourceInstanceLocations } from './data-sources/useDataSourceInstanceLocations.js'
21
20
  export { useDataSourceInstances } from './data-sources/useDataSourceInstances.js'
22
21
  export { useDataSources } from './data-sources/useDataSources.js'
23
22
 
@@ -27,6 +26,11 @@ export { useAppEventType } from './app-events/useAppEventType.js'
27
26
  export { useAppEventTypes } from './app-events/useAppEventTypes.js'
28
27
  export { useAppEvents } from './app-events/useAppEvents.js'
29
28
 
29
+ export { useAppDataSchema } from './app-data-schemas/useAppDataSchema.js'
30
+ export { useAppDataSchemas } from './app-data-schemas/useAppDataSchemas.js'
31
+ export { useAppDataSchemaInstance } from './app-data-schemas/useAppDataSchemaInstance.js'
32
+ export { useAppDataSchemaInstances } from './app-data-schemas/useAppDataSchemaInstances.js'
33
+
30
34
  export { useFlow } from './flows/useFlow.js'
31
35
  export { useFlows } from './flows/useFlows.js'
32
36
 
@@ -6,13 +6,15 @@ import {
6
6
  } from '@integration-app/sdk'
7
7
  import { useElement } from '../hooks/useElement'
8
8
 
9
- export function useIntegration(id: string) {
9
+ export function useIntegration(idOrKey: string | undefined) {
10
10
  const { item: integration, ...rest } = useElement<
11
11
  Integration,
12
12
  UpdateIntegrationRequest,
13
13
  CreateIntegrationRequest,
14
14
  IntegrationAccessor
15
- >(id, (integrationApp) => integrationApp.integration(id))
15
+ >(idOrKey, (integrationApp) =>
16
+ idOrKey ? integrationApp.integration(idOrKey) : undefined,
17
+ )
16
18
 
17
19
  return { integration, ...rest }
18
20
  }
package/tsconfig.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "target": "es2018",
5
- "lib": ["es2019", "DOM"],
5
+ "lib": ["es2019", "dom", "dom.iterable"],
6
6
  "strict": true,
7
+ "strictNullChecks": true,
7
8
  "outDir": "./dist",
8
9
  "baseUrl": "./src",
9
10
  "jsx": "react-jsx",
10
-
11
11
  "declaration": true,
12
12
  "declarationDir": "./dist/dts"
13
13
  },
@@ -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
@@ -1,41 +0,0 @@
1
- import {
2
- DataDirectoryListResponse,
3
- DataSourceInstance,
4
- } from '@integration-app/sdk'
5
- import { useIntegrationApp } from '../contexts/integration-app-context'
6
- import useSWR from 'swr'
7
- import qs from 'query-string'
8
-
9
- export function useDataSourceInstanceLocations(
10
- dataSourceInstance: DataSourceInstance,
11
- args?: {
12
- path?: string
13
- cursor?: string
14
- },
15
- ) {
16
- const integrationApp = useIntegrationApp()
17
-
18
- const { data, error, isLoading, mutate } = useSWR<DataDirectoryListResponse>(
19
- dataSourceInstance
20
- ? `${dataSourceInstance.id}/locations?${qs.stringify(args)}`
21
- : null,
22
- () =>
23
- integrationApp
24
- .dataSourceInstance(dataSourceInstance.id)
25
- .getLocations(args),
26
- )
27
-
28
- async function refresh() {
29
- return await mutate()
30
- }
31
-
32
- const locations = data?.locations ?? []
33
-
34
- return {
35
- locations,
36
-
37
- refresh,
38
- error,
39
- loading: isLoading,
40
- }
41
- }