@dashx/react-native 0.1.24 → 0.1.25
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/index.js +45 -4
- package/ios/DashX.m +1 -0
- package/ios/DashX.swift +10 -0
- package/ios/Network.swift +5 -1
- package/package.json +8 -1
package/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
2
|
+
import { parseFilterObject, toContentSingleton } from './utils'
|
|
3
|
+
import {
|
|
4
|
+
prepareExternalAsset,
|
|
5
|
+
queryExternalAsset,
|
|
6
|
+
uploadExternalAsset,
|
|
7
|
+
} from './utils/RestAPIClient'
|
|
2
8
|
|
|
3
9
|
import ContentOptionsBuilder from './ContentOptionsBuilder'
|
|
4
|
-
import { parseFilterObject, toContentSingleton } from './utils'
|
|
5
10
|
|
|
6
11
|
const { DashX } = NativeModules
|
|
7
12
|
const dashXEventEmitter = new NativeEventEmitter(DashX)
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
//TODO Get connection config from Android layer as well
|
|
15
|
+
const { identify, track, fetchContent, searchContent, getConnectionConfig } =
|
|
16
|
+
DashX
|
|
10
17
|
|
|
11
18
|
// Handle overloads at JS, because Native modules doesn't allow that
|
|
12
19
|
// https://github.com/facebook/react-native/issues/19116
|
|
@@ -20,10 +27,14 @@ DashX.identify = (options) => {
|
|
|
20
27
|
|
|
21
28
|
DashX.track = (event, data) => track(event, data || null)
|
|
22
29
|
|
|
30
|
+
DashX.getConnectionConfig = () => {
|
|
31
|
+
return getConnectionConfig()
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
DashX.searchContent = (contentType, options) => {
|
|
24
35
|
if (!options) {
|
|
25
|
-
return new ContentOptionsBuilder(
|
|
26
|
-
|
|
36
|
+
return new ContentOptionsBuilder((wrappedOptions) =>
|
|
37
|
+
searchContent(contentType, wrappedOptions)
|
|
27
38
|
)
|
|
28
39
|
}
|
|
29
40
|
|
|
@@ -42,6 +53,36 @@ DashX.fetchContent = (contentType, options) => {
|
|
|
42
53
|
return fetchContent(contentType, options)
|
|
43
54
|
}
|
|
44
55
|
|
|
56
|
+
DashX.uploadExternalAsset = async (file, externalColumnId) => {
|
|
57
|
+
const connectionConfig = await getConnectionConfig()
|
|
58
|
+
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
uploadExternalAsset(
|
|
61
|
+
file,
|
|
62
|
+
externalColumnId,
|
|
63
|
+
connectionConfig,
|
|
64
|
+
resolve,
|
|
65
|
+
reject
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
DashX.prepareExternalAsset = async (externalColumnId) => {
|
|
71
|
+
const connectionConfig = await getConnectionConfig()
|
|
72
|
+
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
prepareExternalAsset(externalColumnId, connectionConfig, resolve, reject)
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
DashX.externalAsset = async (assetId) => {
|
|
79
|
+
const connectionConfig = await getConnectionConfig()
|
|
80
|
+
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
queryExternalAsset(assetId, connectionConfig, resolve, reject)
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
45
86
|
DashX.onMessageReceived = (callback) =>
|
|
46
87
|
dashXEventEmitter.addListener('messageReceived', callback)
|
|
47
88
|
|
package/ios/DashX.m
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
@interface RCT_EXTERN_MODULE(DashX, RCTEventEmitter)
|
|
5
5
|
RCT_EXTERN_METHOD(setLogLevel:(NSInteger *)to)
|
|
6
6
|
RCT_EXTERN_METHOD(setup:(NSDictionary *)options)
|
|
7
|
+
RCT_EXTERN_METHOD(getConnectionConfig:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
7
8
|
RCT_EXTERN_METHOD(identify:(NSString *)uid options:(NSDictionary *)options)
|
|
8
9
|
RCT_EXTERN_METHOD(setIdentityToken:(NSString *)identityToken)
|
|
9
10
|
RCT_EXTERN_METHOD(reset)
|
package/ios/DashX.swift
CHANGED
|
@@ -56,6 +56,16 @@ class DashX: RCTEventEmitter {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
@objc(getConnectionConfig:rejecter:)
|
|
60
|
+
func getConnectionConfig(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
61
|
+
return resolve([
|
|
62
|
+
"baseUri": Network.shared.getBaseUri(),
|
|
63
|
+
"publicKey": ConfigInterceptor.shared.publicKey,
|
|
64
|
+
"targetEnvironment": ConfigInterceptor.shared.targetEnvironment,
|
|
65
|
+
"identityToken": ConfigInterceptor.shared.identityToken,
|
|
66
|
+
])
|
|
67
|
+
}
|
|
68
|
+
|
|
59
69
|
@objc(identify:options:)
|
|
60
70
|
func identify(_ uid: String?, _ options: NSDictionary?) {
|
|
61
71
|
try? dashXClient.identify(uid, withOptions: options)
|
package/ios/Network.swift
CHANGED
|
@@ -9,6 +9,10 @@ class Network {
|
|
|
9
9
|
self.baseUri = to
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
func getBaseUri() -> String {
|
|
13
|
+
return self.baseUri
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
private(set) lazy var apollo: ApolloClient = {
|
|
13
17
|
let client = URLSessionClient()
|
|
14
18
|
let cache = InMemoryNormalizedCache()
|
|
@@ -23,7 +27,7 @@ class Network {
|
|
|
23
27
|
}()
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
class NetworkInterceptorProvider:
|
|
30
|
+
class NetworkInterceptorProvider: DefaultInterceptorProvider {
|
|
27
31
|
override func interceptors<Operation: GraphQLOperation>(for operation: Operation) -> [ApolloInterceptor] {
|
|
28
32
|
var interceptors = super.interceptors(for: operation)
|
|
29
33
|
interceptors.insert(ConfigInterceptor.shared, at: 0)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashx/react-native",
|
|
3
3
|
"title": "DashX React Native",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.25",
|
|
5
5
|
"description": "DashX SDK for React Native",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -35,7 +35,14 @@
|
|
|
35
35
|
"react-native": ">=0.59.0-rc.0 <1.0.x"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"eslint": "^8.21.0",
|
|
39
|
+
"eslint-plugin-react": "^7.30.1",
|
|
40
|
+
"get-file-object-from-local-path": "^1.0.2",
|
|
38
41
|
"react": "^16.11.0",
|
|
39
42
|
"react-native": "^0.62.0-rc.2"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"axios": "^0.27.2",
|
|
46
|
+
"rn-fetch-blob": "^0.12.0"
|
|
40
47
|
}
|
|
41
48
|
}
|