@partium/react-native-sdk 14.0.0
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/LICENSE.txt +100 -0
- package/README.md +9 -0
- package/core/index.d.ts +2 -0
- package/core/index.js +2 -0
- package/core/models/rn-p-file.d.ts +8 -0
- package/core/models/rn-p-file.js +2 -0
- package/core/services/rn-device-status.service.d.ts +27 -0
- package/core/services/rn-device-status.service.js +2 -0
- package/core/services/rn-file-transfer.service.d.ts +45 -0
- package/core/services/rn-file-transfer.service.js +2 -0
- package/core/services/rn-file.service.d.ts +10 -0
- package/core/services/rn-file.service.js +2 -0
- package/core/services/rn-local-storage.service.d.ts +72 -0
- package/core/services/rn-local-storage.service.js +2 -0
- package/index.d.ts +10 -0
- package/index.js +2 -0
- package/package.json +41 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
|
|
3
|
+
Partium Source Code License, by Partium, Inc. DBA Partium ("Licensor")
|
|
4
|
+
|
|
5
|
+
License. Licensor hereby grants the person ("You" or "Licensee") accessing or
|
|
6
|
+
using the Partium software and associated documentation files to which this
|
|
7
|
+
license is attached (the "Software", being the Partium App or SDK), a limited,
|
|
8
|
+
royalty-free, non-transferable and non-sublicensable right (a) to install and
|
|
9
|
+
use the Software in order to develop, test and prototype Your applications as
|
|
10
|
+
a Partium Integration Project ("Partium Project"), including non-transferable
|
|
11
|
+
rights to use, copy and modify the Software as necessary to integrate the
|
|
12
|
+
Software into the Your own applications and (b) to distribute and sublicense
|
|
13
|
+
the use of the Software, with or without modifications, to Your clients only
|
|
14
|
+
as part of Your applications for a Partium Project. Distribution and/or public
|
|
15
|
+
communication of the Software to Your clients are permitted only if the
|
|
16
|
+
Software is embedded in the Licensee's own applications as part of a Partium
|
|
17
|
+
Project. As an exception to the above license, you may not extract, reproduce
|
|
18
|
+
modify or use except as part of this Software the UAPARSER.JS which is part of
|
|
19
|
+
and/or downloaded and installed as the Software.
|
|
20
|
+
|
|
21
|
+
Licensee undertakings. Licensee agrees that (a) it will not remove any
|
|
22
|
+
proprietary notices on the Software; (b) it will maintain the confidentiality
|
|
23
|
+
of the Software, (c) it will only use the Software as part of a Partium
|
|
24
|
+
Project and shall not distribute the Software in any form or under any
|
|
25
|
+
agreement that allows it to be reused by any application other than Licensee's
|
|
26
|
+
applications in a Partium Project; and (d) it will not use the Software to
|
|
27
|
+
build or form part of any product that competes with the Partium product or
|
|
28
|
+
technologies as described in the associated documentation or at
|
|
29
|
+
https://partium.io.
|
|
30
|
+
|
|
31
|
+
Reservation of rights. Except as expressly licensed hereunder, Licensor and
|
|
32
|
+
its own licensors retain all ownership and intellectual property rights to the
|
|
33
|
+
Software.
|
|
34
|
+
|
|
35
|
+
Disclaimer. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, (A) THE
|
|
36
|
+
SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
37
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF SATISFACTORY QUALITY,
|
|
38
|
+
OR FITNESS FOR A PARTICULAR PURPOSE; AND (B) IN NO EVENT SHALL THE LICENSOR BE
|
|
39
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
40
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
41
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
42
|
+
|
|
43
|
+
Data collection: The Software contains certain features that trigger tracking
|
|
44
|
+
events in the Partium cloud-service. These events are used for understanding
|
|
45
|
+
usage, improve technology, but also to provide to customer statistics (as
|
|
46
|
+
requested by them in product configuration). As delivered by Licensor, the
|
|
47
|
+
Software does not collect any personal data.
|
|
48
|
+
|
|
49
|
+
Export Controls. Export laws and regulations of the United States and any
|
|
50
|
+
other relevant local export laws and regulations apply to the Software. You
|
|
51
|
+
agree that such export control laws govern Your use of the Software (including
|
|
52
|
+
technical data) and any services deliverables provided under this agreement,
|
|
53
|
+
and You agree to comply with all such export laws and regulations (including
|
|
54
|
+
"deemed export" and "deemed re-export" regulations). You agree that no data,
|
|
55
|
+
information, program and/or materials resulting from Software or services (or
|
|
56
|
+
direct products thereof) will be exported, directly or indirectly, in
|
|
57
|
+
violation of these laws, or will be used for any purpose prohibited by these
|
|
58
|
+
laws including, without limitation, nuclear, chemical, or biological weapons
|
|
59
|
+
proliferation, or development of missile technology. Accordingly, You confirm:
|
|
60
|
+
- You will not download, provide, make available or otherwise export or
|
|
61
|
+
re-export the Software, directly or indirectly, to countries prohibited by
|
|
62
|
+
applicable laws and regulations nor to citizens, nationals, or residents of
|
|
63
|
+
those countries.
|
|
64
|
+
- You are not listed on the United States Department of Treasury lists of
|
|
65
|
+
Specially Designated Nationals and Blocked Persons, Specially Designated
|
|
66
|
+
Terrorists, and Specially Designated Narcotic Traffickers, nor are You listed
|
|
67
|
+
on the United States Department of Commerce Table of Denial Orders.
|
|
68
|
+
- You will not download or otherwise export or re-export the Software,
|
|
69
|
+
directly or indirectly, to persons on the above mentioned lists.
|
|
70
|
+
|
|
71
|
+
No support. The Licensor does not provide any support under this license.
|
|
72
|
+
Support may be provided under a separate service agreement with Licensor.
|
|
73
|
+
Updates may be provided at Licensor's discretion.
|
|
74
|
+
|
|
75
|
+
Term and Termination. This license is for the term of Your service agreement
|
|
76
|
+
with Licensor and shall automatically terminate without notice if You fail to
|
|
77
|
+
comply with any of the terms of this license or the service agreement with
|
|
78
|
+
Licensor, in which case You shall promptly stop using and destroy all copies
|
|
79
|
+
of the Software.
|
|
80
|
+
|
|
81
|
+
Third-Party components (including open source). The Software requires the use
|
|
82
|
+
of third-party software (open source or other) that is not provided with the
|
|
83
|
+
Software (as indicated in the Software documentation or listed dependencies).
|
|
84
|
+
Licensor may provide certain notices to Licensee in the Software documentation,
|
|
85
|
+
readmes or notice files in connection with such third-party software.
|
|
86
|
+
Third-party software is licensed to Licensee under the terms of the corresponding
|
|
87
|
+
software license indicated in the documentation or the repository of the listed
|
|
88
|
+
dependencies (provided to Licensee and downloaded with the dependency software
|
|
89
|
+
code). Licensee's rights to use such software are not restricted in any way by
|
|
90
|
+
this license.
|
|
91
|
+
|
|
92
|
+
Applicable Law and Jurisdiction. This Agreement is governed by the substantive
|
|
93
|
+
and procedural laws of Delaware (US), and Licensee and Licensor, agree to
|
|
94
|
+
submit to the exclusive jurisdiction of, and venue in, the courts of Delaware
|
|
95
|
+
in any dispute arising out of or relating to this Agreement.
|
|
96
|
+
|
|
97
|
+
Notices. For any questions concerning this license, or to contact the Licensor
|
|
98
|
+
for any reason, please write to support@partium.io
|
|
99
|
+
|
|
100
|
+
Version 4: 15 July 2024
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Partium Find SDK for React Native
|
|
2
|
+
|
|
3
|
+
The *Partium Find SDK* enables seamless integration of Partium’s parts and materials search capabilities into React Native-based applications. It supports multiple search modalities, including text, image, and multi-modal search, and offers advanced features like hierarchy navigation (Bill of Materials) and attribute-based filtering.
|
|
4
|
+
|
|
5
|
+
The Find SDK enables efficient spare part search, retrieval of relevant results, and seamless integration of those results into applications through an intuitive interface. Additional information about material and part search with Partium, along with user interface examples and usage guidelines, is available in the [Partium Help Center](https://www.partium.io/help-center/material-and-part-search).
|
|
6
|
+
|
|
7
|
+
# Installation & Usage
|
|
8
|
+
|
|
9
|
+
For complete installation instructions and code samples, please visit the Partium [Developer Center](https://developer.partium.io/). Access requires credentials; please contact your Partium representative for access. If you don’t yet have a contact, reach out to us via [Partium.io](https://www.partium.io/contact).
|
package/core/index.d.ts
ADDED
package/core/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,i,t){void 0===t&&(t=i);var c=Object.getOwnPropertyDescriptor(r,i);c&&!("get"in c?!r.__esModule:c.writable||c.configurable)||(c={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(e,t,c)}:function(e,r,i,t){void 0===t&&(t=i),e[t]=r[i]}),__exportStar=this&&this.__exportStar||function(e,r){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(r,i)||__createBinding(r,e,i)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./models/rn-p-file"),exports);const js_sdk_1=require("@partium/js-sdk"),core_1=require("@partium/js-sdk/core"),rn_local_storage_service_1=require("./services/rn-local-storage.service"),rn_device_status_service_1=require("./services/rn-device-status.service"),rn_file_transfer_service_1=require("./services/rn-file-transfer.service"),rn_file_service_1=require("./services/rn-file.service"),origInit=js_sdk_1.Partium.init;js_sdk_1.Partium.init=function(e){return console.log("Initializing Partium..."),origInit(Object.assign(e,{authenticationConfig:e.authenticationConfig,httpsClientService:e.httpsClientService||core_1.AxiosHttpsClientService,fileTransferService:e.fileTransferService||rn_file_transfer_service_1.RNFileTransferService,localStorageService:e.localStorageService||rn_local_storage_service_1.RNLocalStorageService,deviceStatusService:e.deviceStatusService||rn_device_status_service_1.RNDeviceStatusService,fileService:e.fileService||rn_file_service_1.RNFileService}))};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { PFile } from "@partium/js-sdk/core";
|
|
3
|
+
export declare class RNPFile extends PFile {
|
|
4
|
+
localFilePath: string;
|
|
5
|
+
constructor(localFilePath: string);
|
|
6
|
+
supportsMultipartUpload(): boolean;
|
|
7
|
+
appendToFormData(name: string, formData: FormData): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RNPFile=void 0;const core_1=require("@partium/js-sdk/core");class RNPFile extends core_1.PFile{constructor(e){super(),this.localFilePath=e}supportsMultipartUpload(){return!1}appendToFormData(e,r){throw new Error("Multipart requests are not supported on this platform")}}exports.RNPFile=RNPFile;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { DeviceInfo, DeviceStatusService } from '@partium/js-sdk/core';
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the DeviceStatusService for ReactNative applications.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RNDeviceStatusService extends DeviceStatusService {
|
|
7
|
+
/**
|
|
8
|
+
* Returns Promise that resolves with true if connection to a network is available.
|
|
9
|
+
* (Usually the internet, but for intranet-only systems it can also be only intranet)
|
|
10
|
+
*
|
|
11
|
+
* ATTENTION:
|
|
12
|
+
* For Android it is required to allow to access the network state in the AndroidManifest.xml:
|
|
13
|
+
* <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
14
|
+
*
|
|
15
|
+
* @returns promise that resolves with true or false, depending on network-connection is available or not
|
|
16
|
+
*/
|
|
17
|
+
isConnectionAvailable(): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns Promise that resolves with a DeviceInfo object, containing
|
|
20
|
+
* information about the device and the installation.
|
|
21
|
+
* Used for logging.
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise that resolves with DeviceInfo
|
|
24
|
+
*/
|
|
25
|
+
getDeviceInfo(): Promise<DeviceInfo>;
|
|
26
|
+
private getConnectivityType;
|
|
27
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(a,o){function r(e){try{_(i.next(e))}catch(e){o(e)}}function c(e){try{_(i.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,c)}_((i=i.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RNDeviceStatusService=void 0;const core_1=require("@partium/js-sdk/core"),netinfo_1=require("@react-native-community/netinfo"),react_native_device_info_1=require("react-native-device-info"),RNLocalize=require("react-native-localize");class RNDeviceStatusService extends core_1.DeviceStatusService{isConnectionAvailable(){return __awaiter(this,void 0,void 0,(function*(){return!!(yield netinfo_1.default.fetch()).isConnected}))}getDeviceInfo(){return __awaiter(this,void 0,void 0,(function*(){let e;const t=(0,react_native_device_info_1.getModel)(),n=yield(0,react_native_device_info_1.getManufacturer)(),i=yield(0,react_native_device_info_1.getInstallerPackageName)(),a=RNLocalize.getLocales().length>0?RNLocalize.getLocales()[0].languageTag:"",o=yield this.getConnectivityType();try{e=(0,react_native_device_info_1.getUniqueId)()}catch(t){e=null}return(null==e?void 0:e.then)?(e=yield e,e="string"==typeof e?e:null):"string"!=typeof e&&(e=null),new core_1.DeviceInfo({deviceId:e,manufacturer:n,model:t,os:(0,react_native_device_info_1.getSystemName)(),osVersion:(0,react_native_device_info_1.getSystemVersion)(),deviceType:(0,react_native_device_info_1.getDeviceType)(),deviceLanguage:a,appVersionCode:(0,react_native_device_info_1.getVersion)(),appVersionName:(0,react_native_device_info_1.getBuildNumber)(),appId:i,connectivityType:o})}))}getConnectivityType(){return __awaiter(this,void 0,void 0,(function*(){const e=yield netinfo_1.default.fetch();switch(e.type){case netinfo_1.NetInfoStateType.cellular:switch(e.details.cellularGeneration){case"2g":return"Cell 2G";case"3g":return"Cell 3G";case"4g":return"Cell 4G";case"4g":return"Cellular"}case netinfo_1.NetInfoStateType.wifi:return"WiFi";case netinfo_1.NetInfoStateType.bluetooth:return"Bluetooth";case netinfo_1.NetInfoStateType.ethernet:return"Ethernet";case netinfo_1.NetInfoStateType.wimax:return"wimax";case netinfo_1.NetInfoStateType.vpn:return"VPN";case netinfo_1.NetInfoStateType.other:return"Other network connection";case netinfo_1.NetInfoStateType.none:return"No network connection";case netinfo_1.NetInfoStateType.unknown:default:return"Unknown connection"}}))}}exports.RNDeviceStatusService=RNDeviceStatusService;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { RNPFile } from "../models/rn-p-file";
|
|
4
|
+
import { DownloadStatus, FileTransferService, UploadStatus } from "@partium/js-sdk/core";
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of the FileTransferService for providing basic file-transfer
|
|
7
|
+
* functionality, such as upload and download, for browser-based applications.
|
|
8
|
+
*
|
|
9
|
+
* In an error case all the functions will return an SDK_ERROR_CODE.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RNFileTransferService extends FileTransferService {
|
|
12
|
+
private deviceStatusService;
|
|
13
|
+
onCreate(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Upload the file from file-system to the given url and emit the upload status and
|
|
16
|
+
* progress during the upload-process.
|
|
17
|
+
*
|
|
18
|
+
* @param fileToUpload RNPFile object that wraps the file-path to upload
|
|
19
|
+
* @param uploadUrl the target upload url (must be publicly available without authentication)
|
|
20
|
+
* @returns Observable that emits the UploadStatus
|
|
21
|
+
*/
|
|
22
|
+
uploadFile(fileToUpload: RNPFile, uploadUrl: string): Observable<UploadStatus>;
|
|
23
|
+
/**
|
|
24
|
+
* Downloads a file to file-system.
|
|
25
|
+
*
|
|
26
|
+
* @param url the file-url to download
|
|
27
|
+
* @returns Observable that emits the DownloadStatus and resolves with a JsPFile that wraps the file-blob
|
|
28
|
+
*/
|
|
29
|
+
downloadFile(url: string): Observable<DownloadStatus>;
|
|
30
|
+
/**
|
|
31
|
+
* Process common errors that occur during the file-transfer process.
|
|
32
|
+
* If the error is more specific it is passed on.
|
|
33
|
+
*
|
|
34
|
+
* @param error the error object
|
|
35
|
+
*/
|
|
36
|
+
private processError;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the upload/download-response contains error-information.
|
|
39
|
+
* Return an error, if there is one, or null otherwise.
|
|
40
|
+
*
|
|
41
|
+
* @param response the response, received from up- or download with react-native-fs
|
|
42
|
+
* @returns null an SdkError, if there was an error, or null if everything is fine
|
|
43
|
+
*/
|
|
44
|
+
private checkResponseError;
|
|
45
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,r,o,t){return new(o||(o=Promise))((function(n,s){function c(e){try{_(t.next(e))}catch(e){s(e)}}function i(e){try{_(t.throw(e))}catch(e){s(e)}}function _(e){var r;e.done?n(e.value):(r=e.value,r instanceof o?r:new o((function(e){e(r)}))).then(c,i)}_((t=t.apply(e,r||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RNFileTransferService=void 0;const rxjs_1=require("rxjs"),rn_p_file_1=require("../models/rn-p-file"),core_1=require("@partium/js-sdk/core"),RNFS=require("react-native-fs");class RNFileTransferService extends core_1.FileTransferService{constructor(){super(...arguments),this.deviceStatusService=void 0}onCreate(){super.onCreate(),this.deviceStatusService=this.serviceProvider.getService(core_1.DeviceStatusService)}uploadFile(e,r){return new rxjs_1.Observable((o=>{RNFS.exists(e.localFilePath).then((t=>{if(!t)return void o.error(new core_1.SdkError(core_1.SDK_ERROR_CODES.FILE_NOT_FOUND,{},`File ${e.localFilePath} could not be found.`));const n=new XMLHttpRequest;n.open("PUT",r),n.setRequestHeader("Content-Type","image/jpg");var s=this;n.onreadystatechange=function(){if(4===n.readyState){const e=s.checkResponseError(n.response);e?o.error(e):(o.next({status:core_1.TRANSFER_STATUS.TRANSFER_FINISHED,progress:100}),o.complete())}},n.upload&&(n.upload.onprogress=function(e){if(e.lengthComputable){var r=Math.round(e.loaded/e.total*100);r=Math.min(r,99),o.next({status:core_1.TRANSFER_STATUS.TRANSFERRING,progress:r})}}),n.send({uri:e.localFilePath,type:"image/jpeg",name:"img name"})}))}))}downloadFile(e){let r=e.split("/").slice(-1)[0].split("?")[0],o=RNFS.TemporaryDirectoryPath;return o+=`/${r}`,new rxjs_1.Observable((r=>{RNFS.downloadFile({fromUrl:e,toFile:o,begin:()=>{},progress:e=>{let o=Math.round(100*e.bytesWritten/e.contentLength);o=Math.min(o,99),r.next({status:core_1.TRANSFER_STATUS.TRANSFERRING,progress:o,file:null})}}).promise.then((e=>{const t=this.checkResponseError(e);t?r.error(t):(r.next({status:core_1.TRANSFER_STATUS.TRANSFER_FINISHED,progress:100,file:new rn_p_file_1.RNPFile(o)}),r.complete())})).catch((e=>{console.log("Error while downloading file: ",e),this.processError(e).then((e=>{r.error(e)}))}))}))}processError(e){return __awaiter(this,void 0,void 0,(function*(){if(console.log("Error:",e),e instanceof core_1.SdkError)return e;return(yield this.deviceStatusService.isConnectionAvailable())?"ENOENT"===e.code||"EUNSPECIFIED"===e.code?new core_1.SdkError(core_1.SDK_ERROR_CODES.NOT_FOUND,e,e.message):new core_1.SdkError(core_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e):new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_INTERNET,e)}))}checkResponseError(e){switch(e instanceof XMLHttpRequest?e.status:e.statusCode){case 200:case 201:case 202:return;case 400:return new core_1.SdkError(core_1.SDK_ERROR_CODES.BAD_REQUEST,{});case 401:return new core_1.SdkError(core_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,{});case 403:return new core_1.SdkError(core_1.SDK_ERROR_CODES.FORBIDDEN,{});case 404:return new core_1.SdkError(core_1.SDK_ERROR_CODES.NOT_FOUND,{});case 500:return new core_1.SdkError(core_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,{});case 501:return new core_1.SdkError(core_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,{});case 502:return new core_1.SdkError(core_1.SDK_ERROR_CODES.BAD_GATEWAY,{});case 503:return new core_1.SdkError(core_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,{});case 504:return new core_1.SdkError(core_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,{})}}}exports.RNFileTransferService=RNFileTransferService;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { FileService, PFileType } from '@partium/js-sdk/core';
|
|
3
|
+
import { RNPFile } from '../models/rn-p-file';
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of the FileService for React Native Applications.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RNFileService extends FileService {
|
|
8
|
+
getFileType(pFile: RNPFile): Promise<PFileType>;
|
|
9
|
+
getImageDimensions(pFile: RNPFile): Promise<[number, number]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(a,n){function c(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,o)}l((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RNFileService=void 0;const react_native_1=require("react-native"),react_native_file_type_1=require("react-native-file-type"),core_1=require("@partium/js-sdk/core");class RNFileService extends core_1.FileService{getFileType(e){return __awaiter(this,void 0,void 0,(function*(){const{mime:t}=yield(0,react_native_file_type_1.default)(e.localFilePath);switch(t.replace(/\/.*/,"")){case"image":return core_1.PFileType.IMAGE;case"text":return core_1.PFileType.TEXT;default:return core_1.PFileType.UNKNOWN}}))}getImageDimensions(e){return new Promise(((t,i)=>{react_native_1.Image.getSize(e.localFilePath,((e,i)=>t([e,i])),i)}))}}exports.RNFileService=RNFileService;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { KeyPrefixParams, LocalStorageService, ServiceProvider } from '@partium/js-sdk/core';
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the LocalStorageService for React Native Applications.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RNLocalStorageService extends LocalStorageService {
|
|
7
|
+
constructor(serviceProvider: ServiceProvider);
|
|
8
|
+
/**
|
|
9
|
+
* Sets the value of the pair identified by key to value, creating a new
|
|
10
|
+
* key/value pair if none existed for key previously.
|
|
11
|
+
*
|
|
12
|
+
* @param key the key to identify the pair
|
|
13
|
+
* @param value the value as string
|
|
14
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
15
|
+
* @returns promise that resolves as soon as the value is stored
|
|
16
|
+
*/
|
|
17
|
+
setItem(key: string, value: string, keyPrefixParams?: KeyPrefixParams): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Sets a series of key-value pairs
|
|
20
|
+
*
|
|
21
|
+
* @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']]
|
|
22
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
23
|
+
* @returns promise that resolves as soon as all pairs are stored
|
|
24
|
+
*/
|
|
25
|
+
setItems(keyValuePairs: [string, string][], keyPrefixParams?: KeyPrefixParams): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the current value associated with the given key, or null if the given
|
|
28
|
+
* key does not exist in the list associated with the object.
|
|
29
|
+
*
|
|
30
|
+
* @param key the key to identify the pair
|
|
31
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
32
|
+
* @returns string-value of the item stored by the given key, or null if not found
|
|
33
|
+
*/
|
|
34
|
+
getItem(key: string, keyPrefixParams?: KeyPrefixParams): Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the current value for each of the given keys, or null if the given
|
|
37
|
+
* keys does not exist in the list associated with the object.
|
|
38
|
+
*
|
|
39
|
+
* @param keys array of keys to retrieve
|
|
40
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
41
|
+
* @returns array of string-values of the items stored by the given keys, or null if not found
|
|
42
|
+
*/
|
|
43
|
+
getItems(keys: string[], keyPrefixParams?: KeyPrefixParams): Promise<string[] | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns all key-value pairs
|
|
46
|
+
*
|
|
47
|
+
* @returns array of string-value of all the stored items
|
|
48
|
+
*/
|
|
49
|
+
getAll(): Promise<[string, string][]>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete a key-value pair
|
|
52
|
+
*
|
|
53
|
+
* @param key the key to identify the pair
|
|
54
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
55
|
+
*/
|
|
56
|
+
deleteItem(key: string, keyPrefixParams?: KeyPrefixParams): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a series of key-value pairs
|
|
59
|
+
*
|
|
60
|
+
* @param keys the keys to identify the pairs
|
|
61
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
62
|
+
*/
|
|
63
|
+
deleteItems(keys: string[], keyPrefixParams?: KeyPrefixParams): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns true if an item with the given key exists, false otherwise.
|
|
66
|
+
*
|
|
67
|
+
* @param key the key to identify the item
|
|
68
|
+
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
69
|
+
* @returns true if the item exists, false otherwise
|
|
70
|
+
*/
|
|
71
|
+
hasItem(key: string, keyPrefixParams?: KeyPrefixParams): Promise<boolean>;
|
|
72
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,a){return new(r||(r=Promise))((function(i,n){function o(e){try{u(a.next(e))}catch(e){n(e)}}function s(e){try{u(a.throw(e))}catch(e){n(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((a=a.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RNLocalStorageService=void 0;const core_1=require("@partium/js-sdk/core"),async_storage_1=require("@react-native-async-storage/async-storage");class RNLocalStorageService extends core_1.LocalStorageService{constructor(e){super(e)}setItem(e,t){return __awaiter(this,arguments,void 0,(function*(e,t,r={userEmail:!0,organizationName:!0}){if(e)return async_storage_1.default.setItem(this.getPrefixedKey(e,r),t)}))}setItems(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){if(e.length>0)return async_storage_1.default.multiSet(e.map((([e,r])=>[this.getPrefixedKey(e,t),r])))}))}getItem(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){return async_storage_1.default.getItem(this.getPrefixedKey(e,t)).then((e=>e||""))}))}getItems(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){return Promise.all(e.map((e=>this.getItem(e,t))))}))}getAll(){return __awaiter(this,void 0,void 0,(function*(){let e=[];const t=yield async_storage_1.default.getAllKeys();for(let r of t){const t=yield async_storage_1.default.getItem(r);e.push([r,t])}return e}))}deleteItem(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){return async_storage_1.default.removeItem(this.getPrefixedKey(e,t))}))}deleteItems(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){const r=e.map((e=>async_storage_1.default.removeItem(this.getPrefixedKey(e,t))));yield Promise.all(r)}))}hasItem(e){return __awaiter(this,arguments,void 0,(function*(e,t={userEmail:!0,organizationName:!0}){return null!==(yield this.getItem(e,t))}))}}exports.RNLocalStorageService=RNLocalStorageService;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
export * from './core';
|
|
3
|
+
export * from '@partium/js-sdk/core';
|
|
4
|
+
export * from '@partium/js-sdk/find';
|
|
5
|
+
export * from '@partium/js-sdk/data';
|
|
6
|
+
export * from '@partium/js-sdk/user-data';
|
|
7
|
+
export * from '@partium/js-sdk/ocr';
|
|
8
|
+
export * from '@partium/js-sdk/management';
|
|
9
|
+
export * from '@partium/js-sdk/catalog';
|
|
10
|
+
export { Partium, INITIALIZATION_STATUS } from '@partium/js-sdk';
|
package/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.INITIALIZATION_STATUS=exports.Partium=void 0,__exportStar(require("./core"),exports),__exportStar(require("@partium/js-sdk/core"),exports),__exportStar(require("@partium/js-sdk/find"),exports),__exportStar(require("@partium/js-sdk/data"),exports),__exportStar(require("@partium/js-sdk/user-data"),exports),__exportStar(require("@partium/js-sdk/ocr"),exports),__exportStar(require("@partium/js-sdk/management"),exports),__exportStar(require("@partium/js-sdk/catalog"),exports);var js_sdk_1=require("@partium/js-sdk");Object.defineProperty(exports,"Partium",{enumerable:!0,get:function(){return js_sdk_1.Partium}}),Object.defineProperty(exports,"INITIALIZATION_STATUS",{enumerable:!0,get:function(){return js_sdk_1.INITIALIZATION_STATUS}});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@partium/react-native-sdk",
|
|
3
|
+
"version": "14.0.0",
|
|
4
|
+
"description": "The Partium Find SDK enables integration of Partium’s parts and materials search capabilities into React Native-based applications.",
|
|
5
|
+
"author": "Partium Inc.",
|
|
6
|
+
"license": "See LICENSE.txt",
|
|
7
|
+
"typings": "index.d.ts",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"partium find sdk",
|
|
10
|
+
"part search",
|
|
11
|
+
"material search",
|
|
12
|
+
"visual search",
|
|
13
|
+
"image search",
|
|
14
|
+
"text search",
|
|
15
|
+
"semantic search",
|
|
16
|
+
"bill of materials search"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "npx rimraf -- node_modules package-lock.json && npm i"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@partium/js-sdk": "14.0.0",
|
|
23
|
+
"rxjs": "~7.8.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/react-native": "~0.73.0",
|
|
27
|
+
"react-native": "~0.75.2",
|
|
28
|
+
"typescript": "~5.5.4"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@react-native-async-storage/async-storage": "~2.0.0",
|
|
32
|
+
"@react-native-community/netinfo": "~11.3.2",
|
|
33
|
+
"react-native": "*",
|
|
34
|
+
"react-native-device-info": "~11.1.0",
|
|
35
|
+
"react-native-file-type": "~1.0.0",
|
|
36
|
+
"react-native-fs": "~2.20.0",
|
|
37
|
+
"react-native-image-picker": "~7.1.2",
|
|
38
|
+
"react-native-localize": "~3.2.1",
|
|
39
|
+
"rxjs": "~7.8.1"
|
|
40
|
+
}
|
|
41
|
+
}
|