@integration-app/react 2.0.1 → 2.0.2
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/package.json +17 -9
- package/DEVELOPMENT.md +0 -82
- package/bundle-tests/test-frameworks/README.md +0 -4
- package/bundle-tests/test-frameworks/cra5react17/package-lock.json +0 -30749
- package/bundle-tests/test-frameworks/cra5react17/package.json +0 -42
- package/bundle-tests/test-frameworks/cra5react17/patches/react-scripts+5.0.0.patch +0 -15
- package/bundle-tests/test-frameworks/cra5react17/public/favicon.ico +0 -0
- package/bundle-tests/test-frameworks/cra5react17/public/index.html +0 -43
- package/bundle-tests/test-frameworks/cra5react17/public/logo192.png +0 -0
- package/bundle-tests/test-frameworks/cra5react17/public/logo512.png +0 -0
- package/bundle-tests/test-frameworks/cra5react17/public/manifest.json +0 -25
- package/bundle-tests/test-frameworks/cra5react17/public/robots.txt +0 -3
- package/bundle-tests/test-frameworks/cra5react17/src/IntegrationsTest.jsx +0 -42
- package/bundle-tests/test-frameworks/cra5react17/src/index.tsx +0 -10
- package/bundle-tests/test-frameworks/cra5react17/src/react-app-env.d.ts +0 -1
- package/bundle-tests/test-frameworks/cra5react17/tsconfig.json +0 -26
- package/bundle-tests/test-frameworks/cra5react18/package-lock.json +0 -30328
- package/bundle-tests/test-frameworks/cra5react18/package.json +0 -38
- package/bundle-tests/test-frameworks/cra5react18/public/favicon.ico +0 -0
- package/bundle-tests/test-frameworks/cra5react18/public/index.html +0 -43
- package/bundle-tests/test-frameworks/cra5react18/public/logo192.png +0 -0
- package/bundle-tests/test-frameworks/cra5react18/public/logo512.png +0 -0
- package/bundle-tests/test-frameworks/cra5react18/public/manifest.json +0 -25
- package/bundle-tests/test-frameworks/cra5react18/public/robots.txt +0 -3
- package/bundle-tests/test-frameworks/cra5react18/src/IntegrationsTest.jsx +0 -42
- package/bundle-tests/test-frameworks/cra5react18/src/index.tsx +0 -10
- package/bundle-tests/test-frameworks/cra5react18/src/logo.svg +0 -1
- package/bundle-tests/test-frameworks/cra5react18/src/react-app-env.d.ts +0 -1
- package/bundle-tests/test-frameworks/cra5react18/tsconfig.json +0 -26
- package/bundle-tests/test-frameworks/next12react17/next.config.js +0 -6
- package/bundle-tests/test-frameworks/next12react17/package.json +0 -18
- package/bundle-tests/test-frameworks/next12react17/pages/_app.js +0 -5
- package/bundle-tests/test-frameworks/next12react17/pages/index.js +0 -5
- package/bundle-tests/test-frameworks/next12react17/src/IntegrationsTest.jsx +0 -25
- package/bundle-tests/test-frameworks/next12react18/next.config.js +0 -6
- package/bundle-tests/test-frameworks/next12react18/package.json +0 -18
- package/bundle-tests/test-frameworks/next12react18/pages/_app.js +0 -5
- package/bundle-tests/test-frameworks/next12react18/pages/index.js +0 -5
- package/bundle-tests/test-frameworks/next12react18/src/IntegrationsTest.jsx +0 -41
- package/bundle-tests/test-frameworks/next13react18/app/layout.tsx +0 -18
- package/bundle-tests/test-frameworks/next13react18/app/page.tsx +0 -5
- package/bundle-tests/test-frameworks/next13react18/next-env.d.ts +0 -5
- package/bundle-tests/test-frameworks/next13react18/next.config.js +0 -6
- package/bundle-tests/test-frameworks/next13react18/package.json +0 -22
- package/bundle-tests/test-frameworks/next13react18/src/IntegrationsTest.tsx +0 -43
- package/bundle-tests/test-frameworks/next13react18/src/IntegrationsTestReact.tsx +0 -28
- package/bundle-tests/test-frameworks/next13react18/src/IntegrationsTestSdk.tsx +0 -19
- package/bundle-tests/test-frameworks/next13react18/tsconfig.json +0 -34
- package/bundle-tests/test-frameworks/parcel2react17/package.json +0 -21
- package/bundle-tests/test-frameworks/parcel2react17/src/IntegrationsTest.js +0 -41
- package/bundle-tests/test-frameworks/parcel2react17/src/index.html +0 -12
- package/bundle-tests/test-frameworks/parcel2react17/src/index.js +0 -12
- package/bundle-tests/test-frameworks/parcel2react18/package.json +0 -21
- package/bundle-tests/test-frameworks/parcel2react18/src/IntegrationsTest.js +0 -41
- package/bundle-tests/test-frameworks/parcel2react18/src/index.html +0 -12
- package/bundle-tests/test-frameworks/parcel2react18/src/index.js +0 -11
- package/bundle-tests/test-frameworks/vite3react17/index.html +0 -12
- package/bundle-tests/test-frameworks/vite3react17/package.json +0 -26
- package/bundle-tests/test-frameworks/vite3react17/src/IntegrationsTest.tsx +0 -41
- package/bundle-tests/test-frameworks/vite3react17/src/main.tsx +0 -10
- package/bundle-tests/test-frameworks/vite3react17/src/vite-env.d.ts +0 -1
- package/bundle-tests/test-frameworks/vite3react17/tsconfig.json +0 -25
- package/bundle-tests/test-frameworks/vite3react17/tsconfig.node.json +0 -10
- package/bundle-tests/test-frameworks/vite3react17/vite.config.ts +0 -7
- package/bundle-tests/test-frameworks/vite4react17/index.html +0 -12
- package/bundle-tests/test-frameworks/vite4react17/package.json +0 -26
- package/bundle-tests/test-frameworks/vite4react17/src/IntegrationsTest.tsx +0 -41
- package/bundle-tests/test-frameworks/vite4react17/src/main.tsx +0 -10
- package/bundle-tests/test-frameworks/vite4react17/src/vite-env.d.ts +0 -1
- package/bundle-tests/test-frameworks/vite4react17/tsconfig.json +0 -25
- package/bundle-tests/test-frameworks/vite4react17/tsconfig.node.json +0 -10
- package/bundle-tests/test-frameworks/vite4react17/vite.config.ts +0 -7
- package/bundle-tests/test-frameworks/vite4react18/index.html +0 -12
- package/bundle-tests/test-frameworks/vite4react18/package.json +0 -26
- package/bundle-tests/test-frameworks/vite4react18/src/IntegrationsTest.tsx +0 -41
- package/bundle-tests/test-frameworks/vite4react18/src/main.tsx +0 -11
- package/bundle-tests/test-frameworks/vite4react18/src/vite-env.d.ts +0 -1
- package/bundle-tests/test-frameworks/vite4react18/tsconfig.json +0 -25
- package/bundle-tests/test-frameworks/vite4react18/tsconfig.node.json +0 -10
- package/bundle-tests/test-frameworks/vite4react18/vite.config.ts +0 -7
- package/bundle-tests/test-package/package.json +0 -10
- package/bundle-tests/test-package/test-cjs.js +0 -11
- package/bundle-tests/test-package/test-esm.mjs +0 -11
- package/bundle-tests/test-package/test-umd.js +0 -25
- package/bundle-tests/test-package/test.sh +0 -30
- package/src/_modules/README.txt +0 -1
- package/src/_modules/awesome-debounce-promise.ts +0 -8
- package/src/contexts/index.tsx +0 -4
- package/src/contexts/integration-app-context.tsx +0 -61
- package/src/hooks/actions/useAction.ts +0 -37
- package/src/hooks/actions/useActionInstance.ts +0 -60
- package/src/hooks/actions/useActionInstances.ts +0 -11
- package/src/hooks/actions/useActions.ts +0 -11
- package/src/hooks/app-data-schemas/useAppDataSchema.ts +0 -20
- package/src/hooks/app-data-schemas/useAppDataSchemaInstance.ts +0 -43
- package/src/hooks/app-data-schemas/useAppDataSchemaInstances.ts +0 -19
- package/src/hooks/app-data-schemas/useAppDataSchemas.ts +0 -11
- package/src/hooks/app-events/useAppEventSubscription.ts +0 -22
- package/src/hooks/app-events/useAppEventSubscriptions.ts +0 -19
- package/src/hooks/app-events/useAppEventType.ts +0 -20
- package/src/hooks/app-events/useAppEventTypes.ts +0 -11
- package/src/hooks/app-events/useAppEvents.ts +0 -11
- package/src/hooks/customers/useCustomer.ts +0 -19
- package/src/hooks/customers/useCustomers.ts +0 -11
- package/src/hooks/data-collections/useDataCollectionSpec.ts +0 -30
- package/src/hooks/data-form/index.tsx +0 -3
- package/src/hooks/data-links/useDataLinkTable.ts +0 -20
- package/src/hooks/data-links/useDataLinkTableInstance.ts +0 -39
- package/src/hooks/data-links/useDataLinkTableInstances.ts +0 -19
- package/src/hooks/data-links/useDataLinkTables.ts +0 -11
- package/src/hooks/data-sources/useDataSource.ts +0 -39
- package/src/hooks/data-sources/useDataSourceInstance.ts +0 -105
- package/src/hooks/data-sources/useDataSourceInstanceCollection.ts +0 -29
- package/src/hooks/data-sources/useDataSourceInstances.ts +0 -17
- package/src/hooks/data-sources/useDataSources.ts +0 -11
- package/src/hooks/external-events/useExternalEventSubscription.ts +0 -60
- package/src/hooks/external-events/useExternalEventSubscriptions.ts +0 -19
- package/src/hooks/field-mappings/useFieldMapping.ts +0 -39
- package/src/hooks/field-mappings/useFieldMappingInstance.ts +0 -56
- package/src/hooks/field-mappings/useFieldMappingInstances.ts +0 -19
- package/src/hooks/field-mappings/useFieldMappings.ts +0 -11
- package/src/hooks/flows/useFlow.ts +0 -35
- package/src/hooks/flows/useFlowInstance.ts +0 -79
- package/src/hooks/flows/useFlowInstances.ts +0 -11
- package/src/hooks/flows/useFlowRun.ts +0 -24
- package/src/hooks/flows/useFlowRuns.ts +0 -11
- package/src/hooks/flows/useFlows.ts +0 -11
- package/src/hooks/integrations/useConnection.ts +0 -21
- package/src/hooks/integrations/useConnections.ts +0 -12
- package/src/hooks/integrations/useConnectorSpec.ts +0 -16
- package/src/hooks/integrations/useIntegration.ts +0 -20
- package/src/hooks/integrations/useIntegrations.ts +0 -12
- package/src/hooks/scenarios/useScenario.tsx +0 -20
- package/src/hooks/scenarios/useScenarios.tsx +0 -11
- package/src/hooks/screens/useScreen.ts +0 -19
- package/src/hooks/useElement.tsx +0 -199
- package/src/hooks/useElements.tsx +0 -108
- package/src/hooks/useIntegrationAppSWR.tsx +0 -13
- package/src/hooks/useIntegrationElement.tsx +0 -19
- package/src/index.tsx +0 -70
- package/tsconfig.json +0 -40
- /package/dist/{index.module.d.ts → index.module.d.mts} +0 -0
package/src/hooks/useElement.tsx
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { IntegrationAppClient } from '@integration-app/sdk'
|
|
2
|
-
import AwesomeDebouncePromise from '_modules/awesome-debounce-promise'
|
|
3
|
-
import { useIntegrationApp } from 'contexts/integration-app-context'
|
|
4
|
-
import useSWR from 'swr'
|
|
5
|
-
|
|
6
|
-
interface ElementState {
|
|
7
|
-
debouncedPut: (data) => Promise<void>
|
|
8
|
-
updatedLocally: boolean
|
|
9
|
-
currentPutRequests: number[]
|
|
10
|
-
savingToServer: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const elementStateCache = new Map<string, ElementState>()
|
|
14
|
-
|
|
15
|
-
export interface BaseElementAccessor<Element, UpdateRequest, CreateRequest> {
|
|
16
|
-
getUniqueIdentifier?(): string
|
|
17
|
-
|
|
18
|
-
get(): Promise<Element>
|
|
19
|
-
|
|
20
|
-
patch?(data: Partial<UpdateRequest>): Promise<Element>
|
|
21
|
-
|
|
22
|
-
put?(data: UpdateRequest): Promise<Element>
|
|
23
|
-
|
|
24
|
-
archive?(): Promise<void>
|
|
25
|
-
|
|
26
|
-
create?(data: CreateRequest): Promise<Element>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function useElement<
|
|
30
|
-
Element,
|
|
31
|
-
UpdateRequest,
|
|
32
|
-
CreateRequest,
|
|
33
|
-
ElementAccessor extends BaseElementAccessor<
|
|
34
|
-
Element,
|
|
35
|
-
UpdateRequest,
|
|
36
|
-
CreateRequest
|
|
37
|
-
>,
|
|
38
|
-
>(
|
|
39
|
-
selector: any,
|
|
40
|
-
accessorGenerator: (
|
|
41
|
-
integrationAppClient: IntegrationAppClient,
|
|
42
|
-
) => ElementAccessor | undefined,
|
|
43
|
-
) {
|
|
44
|
-
const integrationApp = useIntegrationApp()
|
|
45
|
-
|
|
46
|
-
// To make sure all instances of useElement with the same IntegrationAppClient and selector
|
|
47
|
-
// are synchronized, we cache them using selector and token as a key
|
|
48
|
-
const elementKeyData: any = {
|
|
49
|
-
token: integrationApp?.token,
|
|
50
|
-
selector,
|
|
51
|
-
}
|
|
52
|
-
const elementKey = JSON.stringify(elementKeyData)
|
|
53
|
-
|
|
54
|
-
const elementState: ElementState = elementStateCache.get(elementKey) ?? {
|
|
55
|
-
updatedLocally: false,
|
|
56
|
-
savingToServer: false,
|
|
57
|
-
currentPutRequests: [], // Save current put requests to not update local state until all of them are done
|
|
58
|
-
debouncedPut: AwesomeDebouncePromise(async (data) => {
|
|
59
|
-
const requestId = Math.random()
|
|
60
|
-
elementState.currentPutRequests.push(requestId)
|
|
61
|
-
elementState.updatedLocally = false
|
|
62
|
-
elementState.savingToServer = true
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
66
|
-
// @ts-expect-error TS(2722): Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
|
|
67
|
-
const result = await accessor?.put(data)
|
|
68
|
-
|
|
69
|
-
elementState.currentPutRequests =
|
|
70
|
-
elementState.currentPutRequests.filter((id) => id !== requestId)
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
!elementState.updatedLocally &&
|
|
74
|
-
elementState.currentPutRequests.length === 0
|
|
75
|
-
) {
|
|
76
|
-
// Update savingToSever so that cached versions in each hook are updated when they react to 'mutate' below
|
|
77
|
-
// 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.
|
|
78
|
-
elementState.savingToServer = false
|
|
79
|
-
// When we received updated state of the element,
|
|
80
|
-
// apply it to the context as long as we didn't make any other changes locally
|
|
81
|
-
// meanwhile.
|
|
82
|
-
await mutate(result, false)
|
|
83
|
-
}
|
|
84
|
-
} catch (e) {
|
|
85
|
-
elementState.updatedLocally = true
|
|
86
|
-
throw e
|
|
87
|
-
} finally {
|
|
88
|
-
elementState.savingToServer = false
|
|
89
|
-
}
|
|
90
|
-
}, 500),
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!elementStateCache.has(elementKey)) {
|
|
94
|
-
elementStateCache.set(elementKey, elementState)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const accessor = integrationApp
|
|
98
|
-
? accessorGenerator(integrationApp)
|
|
99
|
-
: undefined
|
|
100
|
-
|
|
101
|
-
const swrKey = accessor && selector ? `element:${elementKey}` : undefined // do not fetch anything if selector or accessor is not defined
|
|
102
|
-
|
|
103
|
-
const {
|
|
104
|
-
data: item,
|
|
105
|
-
mutate,
|
|
106
|
-
error,
|
|
107
|
-
isLoading,
|
|
108
|
-
isValidating,
|
|
109
|
-
} = useSWR(swrKey, () => accessor?.get(), {
|
|
110
|
-
// pause revalidation if update is in progress to not overwrite local changes
|
|
111
|
-
isPaused: () => elementState.updatedLocally || elementState.savingToServer,
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
const loading = isLoading
|
|
115
|
-
const refreshing = isValidating
|
|
116
|
-
|
|
117
|
-
async function refresh(): Promise<Element> {
|
|
118
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
119
|
-
// @ts-expect-error TS(2322): Type 'Awaited<Element> | undefined' is not assigna... Remove this comment to see the full error message
|
|
120
|
-
return await mutate()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function put(data: UpdateRequest) {
|
|
124
|
-
if (!accessor?.put) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
127
|
-
// @ts-expect-error TS(2531): Object is possibly 'null'.
|
|
128
|
-
`"put method is not supported for accessor ${accessor.constructor.name}`,
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
elementState.updatedLocally = true
|
|
133
|
-
|
|
134
|
-
// We don't know which fields are "innate" for the element and should stay
|
|
135
|
-
// and which should be removed by put, so we'll do a simple patch.
|
|
136
|
-
// We'll update data with actual value from the server after put is done.
|
|
137
|
-
const newLocalData: any = {
|
|
138
|
-
...item,
|
|
139
|
-
...data,
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
await mutate(newLocalData, false)
|
|
143
|
-
|
|
144
|
-
await elementState.debouncedPut(data)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function patch(data: Partial<UpdateRequest>) {
|
|
148
|
-
const newData = {
|
|
149
|
-
...item,
|
|
150
|
-
...data,
|
|
151
|
-
} as UpdateRequest
|
|
152
|
-
|
|
153
|
-
return put(newData)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async function archive() {
|
|
157
|
-
if (!accessor?.archive) {
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
162
|
-
// @ts-expect-error TS(2345): Argument of type '{ archivedAt: string; }' is not ... Remove this comment to see the full error message
|
|
163
|
-
await mutate({ ...item, archivedAt: new Date().toISOString() }, false)
|
|
164
|
-
await accessor?.archive()
|
|
165
|
-
await mutate()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function create(data: CreateRequest) {
|
|
169
|
-
if (!accessor?.create) {
|
|
170
|
-
throw new Error(
|
|
171
|
-
`"create method is not supported for accessor ${accessor?.constructor.name}`,
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const result = await accessor?.create(data)
|
|
176
|
-
|
|
177
|
-
return await mutate(result)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
accessor,
|
|
182
|
-
|
|
183
|
-
item,
|
|
184
|
-
|
|
185
|
-
loading,
|
|
186
|
-
|
|
187
|
-
saving: elementState.updatedLocally || elementState.savingToServer,
|
|
188
|
-
|
|
189
|
-
error,
|
|
190
|
-
|
|
191
|
-
refresh,
|
|
192
|
-
refreshing,
|
|
193
|
-
|
|
194
|
-
create,
|
|
195
|
-
patch,
|
|
196
|
-
put,
|
|
197
|
-
archive,
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { useIntegrationApp } from '../contexts/integration-app-context'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
import { PaginationResponse } from '@integration-app/sdk'
|
|
4
|
-
import useSWRInfinite from 'swr/infinite'
|
|
5
|
-
import qs from 'query-string'
|
|
6
|
-
|
|
7
|
-
export function useElements<Item>(route: string, query: any = {}) {
|
|
8
|
-
const integrationApp = useIntegrationApp()
|
|
9
|
-
|
|
10
|
-
const limit = query.limit ?? 25
|
|
11
|
-
|
|
12
|
-
// Add token hash to keys to make sure that the cache is invalidated when the token changes
|
|
13
|
-
const tokenHash = hashCode(integrationApp.token)
|
|
14
|
-
|
|
15
|
-
function getKey(
|
|
16
|
-
page: number,
|
|
17
|
-
previousPageData: PaginationResponse<Item> | null,
|
|
18
|
-
) {
|
|
19
|
-
// first page, we don't have `previousPageData`
|
|
20
|
-
if (page === 0)
|
|
21
|
-
return `/${route}?${qs.stringify({
|
|
22
|
-
...query,
|
|
23
|
-
limit,
|
|
24
|
-
hash: tokenHash,
|
|
25
|
-
})}`
|
|
26
|
-
|
|
27
|
-
// reached the end
|
|
28
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
29
|
-
// @ts-expect-error TS(2531): Object is possibly 'null'.
|
|
30
|
-
if (previousPageData.items?.length < limit) return null
|
|
31
|
-
|
|
32
|
-
return `/${route}?${qs.stringify({
|
|
33
|
-
...query,
|
|
34
|
-
limit,
|
|
35
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
36
|
-
// @ts-expect-error TS(2531): Object is possibly 'null'.
|
|
37
|
-
cursor: previousPageData.cursor,
|
|
38
|
-
hash: tokenHash,
|
|
39
|
-
})}`
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const [loadingMore, setIsLoadingMore] = useState(false)
|
|
43
|
-
|
|
44
|
-
const { data, size, setSize, isLoading, error, mutate, isValidating } =
|
|
45
|
-
useSWRInfinite<PaginationResponse<Item>>(getKey, (url) =>
|
|
46
|
-
integrationApp.get(url),
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const items = data ? data.map((page) => page.items).flat() : []
|
|
50
|
-
|
|
51
|
-
const loading = isLoading
|
|
52
|
-
const refreshing = isValidating
|
|
53
|
-
|
|
54
|
-
async function loadMore() {
|
|
55
|
-
/* FIXME: strictNullCheck temporary fix */
|
|
56
|
-
// @ts-expect-error TS(2532): Object is possibly 'undefined'.
|
|
57
|
-
const hasMoreToLoad = data[size - 1]?.items?.length === limit
|
|
58
|
-
|
|
59
|
-
if (hasMoreToLoad) {
|
|
60
|
-
setIsLoadingMore(true)
|
|
61
|
-
await setSize(size + 1)
|
|
62
|
-
setIsLoadingMore(false)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function refresh() {
|
|
67
|
-
await mutate()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
items,
|
|
72
|
-
|
|
73
|
-
refresh,
|
|
74
|
-
refreshing,
|
|
75
|
-
|
|
76
|
-
loadMore,
|
|
77
|
-
loadingMore,
|
|
78
|
-
|
|
79
|
-
loading,
|
|
80
|
-
|
|
81
|
-
error,
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Returns a hash code for a string.
|
|
87
|
-
* (Compatible to Java's String.hashCode())
|
|
88
|
-
*
|
|
89
|
-
* The hash code for a string object is computed as
|
|
90
|
-
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
|
|
91
|
-
* using number arithmetic, where s[i] is the i th character
|
|
92
|
-
* of the given string, n is the length of the string,
|
|
93
|
-
* and ^ indicates exponentiation.
|
|
94
|
-
* (The hash value of the empty string is zero.)
|
|
95
|
-
*
|
|
96
|
-
* @param {string} s a string
|
|
97
|
-
* @return {number} a hash code value for the given string.
|
|
98
|
-
*/
|
|
99
|
-
function hashCode(s: string | undefined) {
|
|
100
|
-
if (!s) {
|
|
101
|
-
return 0
|
|
102
|
-
}
|
|
103
|
-
const l = s.length
|
|
104
|
-
let h = 0,
|
|
105
|
-
i = 0
|
|
106
|
-
if (l > 0) while (i < l) h = ((h << 5) - h + s.charCodeAt(i++)) | 0
|
|
107
|
-
return h
|
|
108
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import useSWR from 'swr'
|
|
2
|
-
import { useIntegrationApp } from '../contexts/integration-app-context'
|
|
3
|
-
|
|
4
|
-
export function useIntegrationAppSWR(path: string, options?: any) {
|
|
5
|
-
const client = useIntegrationApp()
|
|
6
|
-
|
|
7
|
-
const fetcher = async () => {
|
|
8
|
-
const response = await client.get(path, options)
|
|
9
|
-
return response
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return useSWR(client ? path : undefined, fetcher, options)
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseElementAccessor, useElement } from './useElement'
|
|
2
|
-
|
|
3
|
-
export function useIntegrationElement<
|
|
4
|
-
Element,
|
|
5
|
-
UpdateRequest,
|
|
6
|
-
CreateRequest,
|
|
7
|
-
T extends BaseElementAccessor<Element, UpdateRequest, CreateRequest>,
|
|
8
|
-
>(accessor: T) {
|
|
9
|
-
if (!accessor.getUniqueIdentifier) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
'This accessor can not be used for with `useIntegrationElement` hook. Method `getUniqueIdentifier` is missing.',
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return useElement<Element, UpdateRequest, CreateRequest, T>(
|
|
16
|
-
accessor.getUniqueIdentifier(),
|
|
17
|
-
() => accessor,
|
|
18
|
-
)
|
|
19
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* Re-export everything from @integration-app/sdk */
|
|
2
|
-
export * from '@integration-app/sdk'
|
|
3
|
-
|
|
4
|
-
export * from './contexts/index.js'
|
|
5
|
-
|
|
6
|
-
export { useIntegrationAppSWR } from './hooks/useIntegrationAppSWR.js'
|
|
7
|
-
|
|
8
|
-
export { useConnection } from './hooks/integrations/useConnection.js'
|
|
9
|
-
export { useConnections } from './hooks/integrations/useConnections.js'
|
|
10
|
-
export { useConnectorSpec } from './hooks/integrations/useConnectorSpec.js'
|
|
11
|
-
export { useIntegration } from './hooks/integrations/useIntegration.js'
|
|
12
|
-
export { useIntegrations } from './hooks/integrations/useIntegrations.js'
|
|
13
|
-
|
|
14
|
-
export { useFieldMapping } from './hooks/field-mappings/useFieldMapping.js'
|
|
15
|
-
export { useFieldMappingInstance } from './hooks/field-mappings/useFieldMappingInstance.js'
|
|
16
|
-
export { useFieldMappingInstances } from './hooks/field-mappings/useFieldMappingInstances.js'
|
|
17
|
-
export { useFieldMappings } from './hooks/field-mappings/useFieldMappings.js'
|
|
18
|
-
|
|
19
|
-
export { useDataSource } from './hooks/data-sources/useDataSource.js'
|
|
20
|
-
export { useDataSourceInstance } from './hooks/data-sources/useDataSourceInstance.js'
|
|
21
|
-
export { useDataSourceInstanceCollection } from './hooks/data-sources/useDataSourceInstanceCollection.js'
|
|
22
|
-
export { useDataSourceInstances } from './hooks/data-sources/useDataSourceInstances.js'
|
|
23
|
-
export { useDataSources } from './hooks/data-sources/useDataSources.js'
|
|
24
|
-
|
|
25
|
-
export { useAppEventSubscription } from './hooks/app-events/useAppEventSubscription.js'
|
|
26
|
-
export { useAppEventSubscriptions } from './hooks/app-events/useAppEventSubscriptions.js'
|
|
27
|
-
export { useAppEventType } from './hooks/app-events/useAppEventType.js'
|
|
28
|
-
export { useAppEventTypes } from './hooks/app-events/useAppEventTypes.js'
|
|
29
|
-
export { useAppEvents } from './hooks/app-events/useAppEvents.js'
|
|
30
|
-
|
|
31
|
-
export { useAppDataSchema } from './hooks/app-data-schemas/useAppDataSchema.js'
|
|
32
|
-
export { useAppDataSchemas } from './hooks/app-data-schemas/useAppDataSchemas.js'
|
|
33
|
-
export { useAppDataSchemaInstance } from './hooks/app-data-schemas/useAppDataSchemaInstance.js'
|
|
34
|
-
export { useAppDataSchemaInstances } from './hooks/app-data-schemas/useAppDataSchemaInstances.js'
|
|
35
|
-
|
|
36
|
-
export { useFlow } from './hooks/flows/useFlow.js'
|
|
37
|
-
export { useFlows } from './hooks/flows/useFlows.js'
|
|
38
|
-
|
|
39
|
-
export { useFlowInstance } from './hooks/flows/useFlowInstance.js'
|
|
40
|
-
export { useFlowInstances } from './hooks/flows/useFlowInstances.js'
|
|
41
|
-
|
|
42
|
-
export { useFlowRun } from './hooks/flows/useFlowRun.js'
|
|
43
|
-
export { useFlowRuns } from './hooks/flows/useFlowRuns.js'
|
|
44
|
-
|
|
45
|
-
export { useDataLinkTable } from './hooks/data-links/useDataLinkTable.js'
|
|
46
|
-
export { useDataLinkTableInstance } from './hooks/data-links/useDataLinkTableInstance.js'
|
|
47
|
-
export { useDataLinkTableInstances } from './hooks/data-links/useDataLinkTableInstances.js'
|
|
48
|
-
export { useDataLinkTables } from './hooks/data-links/useDataLinkTables.js'
|
|
49
|
-
|
|
50
|
-
export { useAction } from './hooks/actions/useAction.js'
|
|
51
|
-
export { useActionInstance } from './hooks/actions/useActionInstance.js'
|
|
52
|
-
export { useActionInstances } from './hooks/actions/useActionInstances.js'
|
|
53
|
-
export { useActions } from './hooks/actions/useActions.js'
|
|
54
|
-
|
|
55
|
-
export { useScreen } from './hooks/screens/useScreen.js'
|
|
56
|
-
|
|
57
|
-
export { useCustomer } from './hooks/customers/useCustomer.js'
|
|
58
|
-
export { useCustomers } from './hooks/customers/useCustomers.js'
|
|
59
|
-
|
|
60
|
-
export { useScenario } from './hooks/scenarios/useScenario.js'
|
|
61
|
-
export { useScenarios } from './hooks/scenarios/useScenarios.js'
|
|
62
|
-
|
|
63
|
-
export { useDataCollectionSpec } from './hooks/data-collections/useDataCollectionSpec.js'
|
|
64
|
-
|
|
65
|
-
export { useExternalEventSubscriptions } from './hooks/external-events/useExternalEventSubscriptions.js'
|
|
66
|
-
export { useExternalEventSubscription } from './hooks/external-events/useExternalEventSubscription.js'
|
|
67
|
-
|
|
68
|
-
export { DataForm } from '@integration-app/sdk'
|
|
69
|
-
|
|
70
|
-
export { useIntegrationElement } from './hooks/useIntegrationElement.js'
|
package/tsconfig.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es2018",
|
|
5
|
-
"lib": ["es2019", "dom", "dom.iterable"],
|
|
6
|
-
"strict": true,
|
|
7
|
-
"strictNullChecks": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"baseUrl": "./src",
|
|
10
|
-
"jsx": "react-jsx",
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationDir": "./dist/dts"
|
|
13
|
-
},
|
|
14
|
-
"include": [
|
|
15
|
-
"./src/**/*.ts",
|
|
16
|
-
"./src/**/*.tsx",
|
|
17
|
-
],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"node_modules",
|
|
20
|
-
],
|
|
21
|
-
"typedocOptions": {
|
|
22
|
-
"entryPointStrategy": "resolve",
|
|
23
|
-
"entryPoints": ["src/index.tsx"],
|
|
24
|
-
"basePath": "src",
|
|
25
|
-
"readme": "none",
|
|
26
|
-
"out": "_docs",
|
|
27
|
-
"exclude": "**/*+(.test|.d).ts",
|
|
28
|
-
"sort": ["source-order"],
|
|
29
|
-
"name": "Integration App React",
|
|
30
|
-
"customCss": "../typedocStyles.css",
|
|
31
|
-
"includeVersion": true,
|
|
32
|
-
"githubPages": false,
|
|
33
|
-
"navigationLinks": {
|
|
34
|
-
"Console": "http://console.integration.app",
|
|
35
|
-
"SDK": "http://console.integration.app/ref/sdk",
|
|
36
|
-
"REST API": "https://api-reference.integration.app"
|
|
37
|
-
},
|
|
38
|
-
"internalModule": "@integration-app/react"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
File without changes
|