@dashx/react-native 1.1.0 → 1.1.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.
Files changed (136) hide show
  1. package/README.md +79 -7
  2. package/android/.gitignore +10 -0
  3. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.dex +0 -0
  4. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXReactNativeModule.dex +0 -0
  5. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/MessageReceivedEventHolder.dex +0 -0
  6. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/ReactNativeLibraryInfoProvider.dex +0 -0
  7. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils$WhenMappings.dex +0 -0
  8. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils.dex +0 -0
  9. package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  10. package/android/build/.transforms/f3c6049e7ab4bb564c79f3a246b8575e/transformed/classes/classes_dex/classes.dex +0 -0
  11. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +16 -0
  12. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  13. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  14. package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/services/com.dashx.android.DashXLibraryInfoProvider +1 -0
  15. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +31 -5
  16. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +16 -0
  17. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.class +0 -0
  18. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/DashXReactNativeModule.class +0 -0
  19. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/MessageReceivedEventHolder.class +0 -0
  20. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/ReactNativeLibraryInfoProvider.class +0 -0
  21. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/util/Utils$WhenMappings.class +0 -0
  22. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/util/Utils.class +0 -0
  23. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  24. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  25. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  26. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  27. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  28. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  29. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  30. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  48. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
  49. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
  50. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  51. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  52. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  53. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  54. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  55. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  56. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  57. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  58. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  59. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  60. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  61. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  62. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  63. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  64. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  65. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  66. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  67. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  68. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  69. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  70. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  71. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  72. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  73. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  74. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
  75. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  76. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  77. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  78. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  79. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  80. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  81. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  82. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  83. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  84. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  85. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  86. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  87. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  88. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  89. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  90. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  91. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  92. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  93. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  94. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  95. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  96. package/android/build/outputs/logs/manifest-merger-debug-report.txt +25 -3
  97. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  98. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.class +0 -0
  99. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/DashXReactNativeModule.class +0 -0
  100. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/MessageReceivedEventHolder.class +0 -0
  101. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/ReactNativeLibraryInfoProvider.class +0 -0
  102. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/util/Utils$WhenMappings.class +0 -0
  103. package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/util/Utils.class +0 -0
  104. package/android/build.gradle +6 -4
  105. package/android/src/main/AndroidManifest.xml +15 -3
  106. package/android/src/main/java/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.kt +72 -0
  107. package/android/src/main/java/com/dashx/rn/sdk/DashXReactNativeModule.kt +97 -19
  108. package/android/src/main/java/com/dashx/rn/sdk/MessageReceivedEventHolder.kt +14 -0
  109. package/android/src/main/java/com/dashx/rn/sdk/ReactNativeLibraryInfoProvider.kt +8 -0
  110. package/android/src/main/java/com/dashx/rn/sdk/util/Utils.kt +14 -0
  111. package/android/src/main/resources/META-INF/services/com.dashx.android.DashXLibraryInfoProvider +1 -0
  112. package/index.d.ts +129 -0
  113. package/index.js +124 -63
  114. package/ios/DashXEventEmitter.swift +3 -2
  115. package/ios/DashXRCTAppDelegate.swift +38 -0
  116. package/ios/DashXReactNative.mm +4 -0
  117. package/ios/DashXReactNative.swift +15 -3
  118. package/package.json +7 -12
  119. package/yarn.lock +1555 -2562
  120. package/ContentOptionsBuilder.js +0 -62
  121. package/android/build/.transforms/103e3bf16f310520880af8bd348f4f94/results.bin +0 -1
  122. package/android/build/.transforms/103e3bf16f310520880af8bd348f4f94/transformed/classes/classes_dex/classes.dex +0 -0
  123. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/results.bin +0 -1
  124. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/BuildConfig.dex +0 -0
  125. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXPackage.dex +0 -0
  126. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXReactNativeModule.dex +0 -0
  127. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/ArrayUtil$1.dex +0 -0
  128. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/ArrayUtil.dex +0 -0
  129. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/MapUtil$1.dex +0 -0
  130. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/MapUtil.dex +0 -0
  131. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils$WhenMappings.dex +0 -0
  132. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils.dex +0 -0
  133. package/android/build/.transforms/1a91a107d670af17a51b8ccf1674f99e/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  134. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  135. package/utils/RestAPIClient.js +0 -154
  136. package/utils.js +0 -21
@@ -1,62 +0,0 @@
1
- import { parseFilterObject, toContentSingleton } from './utils'
2
-
3
- class Builder {
4
- constructor(callback) {
5
- this.options = {}
6
- this.callback = callback
7
- }
8
-
9
- limit(by) {
10
- this.options.limit = by
11
- return this
12
- }
13
-
14
- filter(by) {
15
- this.options.filter = parseFilterObject(by)
16
- return this
17
- }
18
-
19
- order(by) {
20
- this.options.order = by
21
- return this
22
- }
23
-
24
- language(to) {
25
- this.options.language = to
26
- return this
27
- }
28
-
29
- fields(identifiers) {
30
- this.options.fields = identifiers
31
- return this
32
- }
33
-
34
- include(identifiers) {
35
- this.options.include = identifiers
36
- return this
37
- }
38
-
39
- exclude(identifiers) {
40
- this.options.exclude = identifiers
41
- return this
42
- }
43
-
44
- preview() {
45
- this.options.preview = true
46
- return this
47
- }
48
-
49
- all(withOptions) {
50
- this.options = { ...this.options, ...withOptions, returnType: 'all' }
51
- return this.callback(this.options)
52
- }
53
-
54
- async one(withOptions) {
55
- this.options = { ...this.options, ...withOptions, returnType: 'one' }
56
- const data = await this.callback(this.options)
57
-
58
- return toContentSingleton(data)
59
- }
60
- }
61
-
62
- export default Builder
@@ -1 +0,0 @@
1
- o/bundleLibRuntimeToDirDebug
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/gulshan/Work/dashx-demo-react-native/node_modules/@dashx/react-native/android/src/main/assets"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/gulshan/Work/dashx-demo-react-native/node_modules/@dashx/react-native/android/src/debug/assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/gulshan/Work/dashx-demo-react-native/node_modules/@dashx/react-native/android/build/intermediates/shader_assets/debug/compileDebugShaders/out"/></dataSet></merger>
@@ -1,154 +0,0 @@
1
- import { Platform } from 'react-native'
2
- import RNFetchBlob from 'rn-fetch-blob'
3
- import axios from 'axios'
4
-
5
- /** Prepare headers headers for the authenticated calls */
6
- const getNetworkHeaders = (config, customHeaders) => {
7
- return {
8
- 'X-Public-Key': `${config.publicKey}`,
9
- //TODO Include identity token as well in the request in future. Currently backend returns "incorrect format" error
10
- // "X-Identity-Token": `${config.identityToken}`,
11
- 'X-Target-Environment': `${config.targetEnvironment}`,
12
- Accept: '*/*',
13
- ...customHeaders,
14
- }
15
- }
16
-
17
- const getNetworkRequestData = (config, customHeaders = {}) => {
18
- return {
19
- url: config.baseUri,
20
- headers: getNetworkHeaders(config, customHeaders),
21
- }
22
- }
23
-
24
- export const prepareExternalAsset = async (externalColumnId, config) => {
25
- const request = {
26
- ...getNetworkRequestData(config),
27
- method: 'POST',
28
- data: {
29
- query: `mutation PrepareExternalAsset($input: PrepareExternalAssetInput!) {
30
- prepareExternalAsset(input: $input) {
31
- id
32
- installationId
33
- externalColumnId
34
- storageProviderId
35
- status
36
- data
37
- createdAt
38
- updatedAt
39
- }
40
- }`,
41
- variables: {
42
- input: {
43
- externalColumnId,
44
- },
45
- },
46
- },
47
- }
48
-
49
- const response = await axios.request(request)
50
-
51
- return response?.data?.data?.prepareExternalAsset
52
- }
53
-
54
- export const queryExternalAsset = async (assetId, config) => {
55
- const response = await axios.request({
56
- ...getNetworkRequestData(config),
57
- method: 'POST',
58
- data: {
59
- query: `query ExternalAsset($id: ID!) {
60
- externalAsset(id: $id) {
61
- id
62
- status
63
- data
64
- }
65
- }`,
66
- variables: {
67
- id: assetId,
68
- },
69
- },
70
- })
71
-
72
- return response?.data?.data?.externalAsset
73
- }
74
-
75
- export const uploadFile = async (url, file, config) => {
76
- if (!file || Object.keys(file).length === 0) {
77
- throw new Error('File is empty')
78
- }
79
-
80
- let { uri, path, type } = file
81
- const uriTransformer = Platform.select({
82
- ios: () => (uri || path).replace('file://', ''),
83
- android: () => {
84
- return uri || path
85
- },
86
- })
87
-
88
- const fileName =
89
- file.filename || file.name || `${(uri || path).split('/').pop()}`
90
-
91
- const transformedFile = {
92
- filename: fileName,
93
- name: fileName,
94
- uri: uriTransformer(),
95
- type,
96
- }
97
-
98
- const response = await RNFetchBlob.fetch(
99
- 'PUT',
100
- config.baseUri,
101
- getNetworkHeaders(config, { type }),
102
- RNFetchBlob.wrap(transformedFile.uri)
103
- )
104
- return response.data?.data
105
- }
106
-
107
- const pollTillAssetIsReady = async (assetId, config, retryCount) => {
108
- return new Promise(function (resolve, reject) {
109
- const retryWindowMillis = 3000
110
-
111
- function queryAssetWithRetryTimeout(retry) {
112
- if (retry === 0) {
113
- return resolve({ id: assetId })
114
- }
115
-
116
- queryExternalAsset(assetId, config)
117
- .then((assetResponse) => {
118
- if (assetResponse?.status === 'ready') {
119
- resolve(assetResponse)
120
- } else {
121
- setTimeout(function () {
122
- queryAssetWithRetryTimeout(retry - 1)
123
- }, retryWindowMillis)
124
- }
125
- })
126
- .catch(reject)
127
- }
128
-
129
- queryAssetWithRetryTimeout(retryCount)
130
- })
131
- }
132
-
133
- export const uploadExternalAsset = async (
134
- file,
135
- externalColumnId,
136
- config,
137
- onSuccess,
138
- onFailure
139
- ) => {
140
- try {
141
- const preparedAsset = await prepareExternalAsset(externalColumnId, config)
142
-
143
- const uploadUrl = preparedAsset?.data?.upload?.url,
144
- assetId = preparedAsset?.id
145
-
146
- await uploadFile(uploadUrl, file, config)
147
-
148
- const response = await pollTillAssetIsReady(assetId, config, 10)
149
-
150
- onSuccess(response)
151
- } catch (error) {
152
- onFailure(error)
153
- }
154
- }
package/utils.js DELETED
@@ -1,21 +0,0 @@
1
- export function parseFilterObject(filterObject) {
2
- const filterBy = {}
3
-
4
- Object.keys(filterObject).forEach((key) => {
5
- if (key.startsWith('_')) {
6
- filterBy[key.substring(1)] = filterObject[key]
7
- return
8
- }
9
-
10
- filterBy.data = {
11
- [key]: filterObject[key],
12
- ...filterBy.data
13
- }
14
- })
15
-
16
- return filterBy
17
- }
18
-
19
- export function toContentSingleton(contentList) {
20
- return Array.isArray(contentList) ? contentList[0] : null
21
- }