@integration-app/react 0.3.1 → 0.3.3
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.
- package/dist/index.d.ts +167 -91
- package/dist/index.js +106 -42
- package/dist/index.js.map +1 -1
- package/dist/index.module.d.ts +167 -91
- package/dist/index.module.mjs +101 -43
- package/dist/index.module.mjs.map +1 -1
- package/dist/index.umd.d.ts +167 -91
- package/dist/index.umd.js +107 -43
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/_modules/README.txt +1 -0
- package/src/_modules/awesome-debounce-promise.ts +8 -0
- package/src/actions/useAction.ts +4 -2
- package/src/actions/useActionInstance.ts +6 -2
- package/src/app-data-schemas/useAppDataSchema.ts +20 -0
- package/src/app-data-schemas/useAppDataSchemaInstance.ts +43 -0
- package/src/app-data-schemas/useAppDataSchemaInstances.ts +19 -0
- package/src/app-data-schemas/useAppDataSchemas.ts +11 -0
- package/src/app-events/useAppEventSubscription.ts +7 -5
- package/src/app-events/useAppEventType.ts +4 -2
- package/src/contexts/integration-app-context.tsx +6 -0
- package/src/customers/useCustomer.ts +19 -0
- package/src/customers/useCustomers.ts +11 -0
- package/src/data-collections/useDataCollectionSpec.ts +5 -2
- package/src/data-links/useDataLinkTable.ts +4 -2
- package/src/data-links/useDataLinkTableInstance.ts +2 -2
- package/src/data-sources/useDataSource.ts +6 -2
- package/src/data-sources/useDataSourceInstance.ts +10 -2
- package/src/data-sources/useDataSourceInstanceLocations.ts +3 -1
- package/src/field-mappings/useFieldMapping.ts +8 -2
- package/src/field-mappings/useFieldMappingInstance.ts +4 -2
- package/src/flows/useFlow.ts +4 -2
- package/src/flows/useFlowInstance.ts +6 -2
- package/src/flows/useFlowRun.ts +2 -2
- package/src/hooks/useElement.tsx +44 -31
- package/src/hooks/useElements.tsx +6 -0
- package/src/index.tsx +8 -0
- package/src/integrations/useConnectorSpec.ts +4 -2
- package/tsconfig.json +2 -2
@@ -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(
|
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
|
-
>(
|
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) => {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import {
|
2
|
+
User,
|
3
|
+
UpdateUserRequest,
|
4
|
+
CreateUserRequest,
|
5
|
+
UserAccessor,
|
6
|
+
UserSelector,
|
7
|
+
} from '@integration-app/sdk'
|
8
|
+
import { useElement } from '../hooks/useElement'
|
9
|
+
|
10
|
+
export function useCustomer(selector: UserSelector | string | undefined) {
|
11
|
+
const { item: customer, ...rest } = useElement<
|
12
|
+
User,
|
13
|
+
UpdateUserRequest,
|
14
|
+
CreateUserRequest,
|
15
|
+
UserAccessor
|
16
|
+
>(selector, (c) => (selector ? c.customer(selector) : undefined))
|
17
|
+
|
18
|
+
return { customer, ...rest }
|
19
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { User, FindUsersQuery } from '@integration-app/sdk'
|
2
|
+
import { useElements } from '../hooks/useElements'
|
3
|
+
|
4
|
+
export function useCustomers(query?: FindUsersQuery) {
|
5
|
+
const { ...rest } = useElements<User>('users', query)
|
6
|
+
|
7
|
+
return {
|
8
|
+
customers: rest.items,
|
9
|
+
...rest,
|
10
|
+
}
|
11
|
+
}
|
@@ -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
|
-
() =>
|
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) =>
|
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(
|
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) =>
|
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)
|
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
import { useElement } from '../hooks/useElement'
|
15
15
|
|
16
16
|
export function useDataSourceInstance(
|
17
|
-
selector: string | DataSourceInstanceSelector,
|
17
|
+
selector: string | DataSourceInstanceSelector | undefined,
|
18
18
|
) {
|
19
19
|
const {
|
20
20
|
item: dataSourceInstance,
|
@@ -26,7 +26,9 @@ export function useDataSourceInstance(
|
|
26
26
|
UpdateDataSourceInstanceRequest,
|
27
27
|
CreateDataSourceInstanceRequest,
|
28
28
|
DataSourceInstanceAccessor
|
29
|
-
>(selector, (integrationApp) =>
|
29
|
+
>(selector, (integrationApp) =>
|
30
|
+
selector ? integrationApp.dataSourceInstance(selector) : undefined,
|
31
|
+
)
|
30
32
|
|
31
33
|
async function setup() {
|
32
34
|
await accessor?.setup()
|
@@ -86,14 +88,20 @@ export function useDataSourceInstance(
|
|
86
88
|
}
|
87
89
|
|
88
90
|
async function createRecord(request?: DataCollectionCreateRequest) {
|
91
|
+
/* FIXME: strictNullCheck temporary fix */
|
92
|
+
// @ts-expect-error TS(2345): Argument of type 'DataCollectionCreateRequest | un... Remove this comment to see the full error message
|
89
93
|
return accessor?.createRecord(request)
|
90
94
|
}
|
91
95
|
|
92
96
|
async function updateRecord(request?: DataCollectionUpdateRequest) {
|
97
|
+
/* FIXME: strictNullCheck temporary fix */
|
98
|
+
// @ts-expect-error TS(2345): Argument of type 'DataCollectionUpdateRequest | un... Remove this comment to see the full error message
|
93
99
|
return accessor?.updateRecord(request)
|
94
100
|
}
|
95
101
|
|
96
102
|
async function deleteRecord(id?: string) {
|
103
|
+
/* FIXME: strictNullCheck temporary fix */
|
104
|
+
// @ts-expect-error TS(2345): Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message
|
97
105
|
return accessor?.deleteRecord(id)
|
98
106
|
}
|
99
107
|
|
@@ -17,7 +17,9 @@ export function useDataSourceInstanceLocations(
|
|
17
17
|
|
18
18
|
const { data, error, isLoading, mutate } = useSWR<DataDirectoryListResponse>(
|
19
19
|
dataSourceInstance
|
20
|
-
?
|
20
|
+
? /* FIXME: strictNullCheck temporary fix */
|
21
|
+
// @ts-expect-error TS(2345): Argument of type '{ path?: string | undefined; cur... Remove this comment to see the full error message
|
22
|
+
`${dataSourceInstance.id}/locations?${qs.stringify(args)}`
|
21
23
|
: null,
|
22
24
|
() =>
|
23
25
|
integrationApp
|
@@ -7,7 +7,9 @@ import {
|
|
7
7
|
} from '@integration-app/sdk'
|
8
8
|
import { useElement } from '../hooks/useElement'
|
9
9
|
|
10
|
-
export function useFieldMapping(
|
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) =>
|
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) =>
|
24
|
+
>(selector, (integrationApp) =>
|
25
|
+
selector ? integrationApp.fieldMappingInstance(selector) : undefined,
|
26
|
+
)
|
25
27
|
|
26
28
|
async function setup() {
|
27
29
|
await accessor?.setup()
|
package/src/flows/useFlow.ts
CHANGED
@@ -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
|
|
@@ -8,7 +8,9 @@ import {
|
|
8
8
|
} from '@integration-app/sdk'
|
9
9
|
import { useElement } from '../hooks/useElement'
|
10
10
|
|
11
|
-
export function useFlowInstance(
|
11
|
+
export function useFlowInstance(
|
12
|
+
selector: string | FlowInstanceSelector | undefined,
|
13
|
+
) {
|
12
14
|
const {
|
13
15
|
item: flowInstance,
|
14
16
|
accessor,
|
@@ -19,7 +21,9 @@ export function useFlowInstance(selector: string | FlowInstanceSelector) {
|
|
19
21
|
UpdateFlowInstanceRequest,
|
20
22
|
UpdateFlowInstanceRequest,
|
21
23
|
FlowInstanceAccessor
|
22
|
-
>(selector, (integrationApp) =>
|
24
|
+
>(selector, (integrationApp) =>
|
25
|
+
selector ? integrationApp.flowInstance(selector) : undefined,
|
26
|
+
)
|
23
27
|
|
24
28
|
async function enable() {
|
25
29
|
await accessor?.enable()
|
package/src/flows/useFlowRun.ts
CHANGED
@@ -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 {
|
package/src/hooks/useElement.tsx
CHANGED
@@ -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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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 but 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
|
-
}
|
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
|
-
|
80
|
+
if (!elementStateCache.has(elementKey)) {
|
81
|
+
elementStateCache.set(elementKey, elementState)
|
82
|
+
}
|
81
83
|
|
82
|
-
const accessor = integrationApp
|
84
|
+
const accessor = integrationApp
|
85
|
+
? accessorGenerator(integrationApp)
|
86
|
+
: undefined
|
83
87
|
|
84
|
-
const swrKey = accessor && selector ? `element:${elementKey}` :
|
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,6 +155,8 @@ export function useElement<
|
|
145
155
|
async function create(data: CreateRequest) {
|
146
156
|
if (!accessor?.create) {
|
147
157
|
throw new Error(
|
158
|
+
/* FIXME: strictNullCheck temporary fix */
|
159
|
+
// @ts-expect-error TS(2531): Object is possibly 'null'.
|
148
160
|
`"create method is not supported for accessor ${accessor.constructor.name}`,
|
149
161
|
)
|
150
162
|
}
|
@@ -160,6 +172,7 @@ export function useElement<
|
|
160
172
|
item,
|
161
173
|
|
162
174
|
loading,
|
175
|
+
|
163
176
|
saving: elementState.updatedLocally || elementState.savingToServer,
|
164
177
|
|
165
178
|
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
@@ -27,6 +27,11 @@ export { useAppEventType } from './app-events/useAppEventType.js'
|
|
27
27
|
export { useAppEventTypes } from './app-events/useAppEventTypes.js'
|
28
28
|
export { useAppEvents } from './app-events/useAppEvents.js'
|
29
29
|
|
30
|
+
export { useAppDataSchema } from './app-data-schemas/useAppDataSchema.js'
|
31
|
+
export { useAppDataSchemas } from './app-data-schemas/useAppDataSchemas.js'
|
32
|
+
export { useAppDataSchemaInstance } from './app-data-schemas/useAppDataSchemaInstance.js'
|
33
|
+
export { useAppDataSchemaInstances } from './app-data-schemas/useAppDataSchemaInstances.js'
|
34
|
+
|
30
35
|
export { useFlow } from './flows/useFlow.js'
|
31
36
|
export { useFlows } from './flows/useFlows.js'
|
32
37
|
|
@@ -48,6 +53,9 @@ export { useActions } from './actions/useActions.js'
|
|
48
53
|
|
49
54
|
export { useScreen } from './screens/useScreen.js'
|
50
55
|
|
56
|
+
export { useCustomer } from './customers/useCustomer.js'
|
57
|
+
export { useCustomers } from './customers/useCustomers.js'
|
58
|
+
|
51
59
|
export { useDataCollectionSpec } from './data-collections/useDataCollectionSpec.js'
|
52
60
|
|
53
61
|
export { DataForm } from '@integration-app/sdk'
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { ConnectionSpec } from '@integration-app/sdk'
|
2
|
-
import { useIntegrationApp } from '../contexts/integration-app-context'
|
3
2
|
import useSWR from 'swr'
|
3
|
+
import { useIntegrationApp } from '../contexts/integration-app-context'
|
4
4
|
|
5
5
|
export function useConnectorSpec(integrationIdOrKey: string) {
|
6
6
|
const integrationApp = useIntegrationApp()
|
7
7
|
|
8
8
|
const { data, isLoading, error } = useSWR<ConnectionSpec>(
|
9
|
-
|
9
|
+
integrationIdOrKey
|
10
|
+
? `/integrations/${integrationIdOrKey}/connector-spec`
|
11
|
+
: undefined,
|
10
12
|
() => integrationApp.integration(integrationIdOrKey).getConnectorSpec(),
|
11
13
|
)
|
12
14
|
|
package/tsconfig.json
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
"extends": "../tsconfig.json",
|
3
3
|
"compilerOptions": {
|
4
4
|
"target": "es2018",
|
5
|
-
"lib": ["es2019", "
|
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
|
},
|