@developer_tribe/react-native-comnyx 0.10.11 → 0.10.13
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/README.md +1 -1
- package/android/build.gradle +0 -1
- package/lib/commonjs/api/api.js +6 -3
- package/lib/commonjs/api/api.js.map +1 -1
- package/lib/commonjs/register/index.js +7 -0
- package/lib/commonjs/register/index.js.map +1 -1
- package/lib/commonjs/register/init.js +16 -3
- package/lib/commonjs/register/init.js.map +1 -1
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/api/api.js +6 -3
- package/lib/module/api/api.js.map +1 -1
- package/lib/module/register/index.js +1 -0
- package/lib/module/register/index.js.map +1 -1
- package/lib/module/register/init.js +17 -3
- package/lib/module/register/init.js.map +1 -1
- package/lib/module/version.js +5 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/src/api/api.d.ts +1 -1
- package/lib/typescript/src/api/api.d.ts.map +1 -1
- package/lib/typescript/src/register/index.d.ts +1 -0
- package/lib/typescript/src/register/index.d.ts.map +1 -1
- package/lib/typescript/src/register/init.d.ts +21 -1
- package/lib/typescript/src/register/init.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +2 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +6 -15
- package/react-native.config.js +1 -7
- package/src/api/api.ts +10 -3
- package/src/register/index.ts +1 -0
- package/src/register/init.ts +29 -7
- package/src/version.ts +2 -0
package/README.md
CHANGED
package/android/build.gradle
CHANGED
package/lib/commonjs/api/api.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.isLoginCalled = isLoginCalled;
|
|
|
10
10
|
exports.setLoginForAxios = setLoginForAxios;
|
|
11
11
|
exports.setLogoutForAxios = setLogoutForAxios;
|
|
12
12
|
var _axios = _interopRequireDefault(require("axios"));
|
|
13
|
+
var _version = require("../version.js");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
const axiosInstance = exports.axiosInstance = _axios.default.create({
|
|
15
16
|
baseURL: 'https://api.comnyx.com',
|
|
@@ -19,14 +20,16 @@ const axiosInstance = exports.axiosInstance = _axios.default.create({
|
|
|
19
20
|
timeout: 1000
|
|
20
21
|
});
|
|
21
22
|
function isInitCalled() {
|
|
22
|
-
return !!axiosInstance.defaults.headers.common
|
|
23
|
+
return !!axiosInstance.defaults.headers.common['project-id'];
|
|
23
24
|
}
|
|
24
25
|
function isLoginCalled() {
|
|
25
26
|
return !!axiosInstance.defaults.headers.common['external-id'];
|
|
26
27
|
}
|
|
27
|
-
function initApi(
|
|
28
|
+
function initApi(projectId, baseURL) {
|
|
28
29
|
axiosInstance.defaults.headers.common['Content-Type'] = 'application/json';
|
|
29
|
-
|
|
30
|
+
// We need to remove any special characters that may be accidentally included when copying and pasting the project ID.
|
|
31
|
+
axiosInstance.defaults.headers.common['project-id'] = projectId.replace(/\n/g, '').trim();
|
|
32
|
+
axiosInstance.defaults.headers.common['user-agent'] = `react-native-comnyx/${_version.VERSION} (React Native)`;
|
|
30
33
|
axiosInstance.defaults.baseURL = baseURL || axiosInstance.defaults.baseURL;
|
|
31
34
|
}
|
|
32
35
|
function setLoginForAxios(externalId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_axios","_interopRequireDefault","require","e","__esModule","default","axiosInstance","exports","axios","create","baseURL","headers","timeout","isInitCalled","defaults","common","
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","_version","e","__esModule","default","axiosInstance","exports","axios","create","baseURL","headers","timeout","isInitCalled","defaults","common","isLoginCalled","initApi","projectId","replace","trim","VERSION","setLoginForAxios","externalId","setLogoutForAxios"],"sourceRoot":"../../../src","sources":["api/api.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAAqC,SAAAD,uBAAAG,CAAA,WAAAA,CAA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,aAAa,CAAC,GAAG,IAAI;AAC7D","ignoreList":[]}
|
|
@@ -4,10 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Comnyx = void 0;
|
|
7
|
+
Object.defineProperty(exports, "VERSION", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _version.VERSION;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
var _login = require("./login.js");
|
|
8
14
|
var _collectData = require("./collectData.js");
|
|
9
15
|
var _logout = require("./logout.js");
|
|
10
16
|
var _init = require("./init.js");
|
|
17
|
+
var _version = require("../version.js");
|
|
11
18
|
const Comnyx = exports.Comnyx = {
|
|
12
19
|
init: _init.init,
|
|
13
20
|
login: _login.login,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_login","require","_collectData","_logout","_init","Comnyx","exports","init","login","logout","collectData"],"sourceRoot":"../../../src","sources":["register/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_login","require","_collectData","_logout","_init","_version","Comnyx","exports","init","login","logout","collectData"],"sourceRoot":"../../../src","sources":["register/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEO,MAAMK,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACpBE,IAAI,EAAEA,UAAI;EACVC,KAAK,EAAEA,YAAK;EACZC,MAAM,EAAEA,cAAM;EACdC,WAAW,EAAEA;AACf,CAAC","ignoreList":[]}
|
|
@@ -5,10 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.init = init;
|
|
7
7
|
var _api = require("../api/api.js");
|
|
8
|
+
/**
|
|
9
|
+
* Options for initializing the Comnyx SDK
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the Comnyx SDK with the provided options
|
|
14
|
+
* @param initOptions - Configuration options for initialization
|
|
15
|
+
* @throws {Error} When token is provided (deprecated) or projectId is missing
|
|
16
|
+
*/
|
|
8
17
|
function init(initOptions) {
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
// Token parameter is deprecated and no longer used
|
|
19
|
+
if (initOptions.token) {
|
|
20
|
+
throw new Error('App token is no longer supported and has been removed');
|
|
21
|
+
}
|
|
22
|
+
if (!initOptions.projectId) {
|
|
23
|
+
throw new Error('Project ID is required');
|
|
11
24
|
}
|
|
12
|
-
(0, _api.initApi)(initOptions.
|
|
25
|
+
(0, _api.initApi)(initOptions.projectId, initOptions._baseURL);
|
|
13
26
|
}
|
|
14
27
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","init","initOptions","token","Error","initApi","
|
|
1
|
+
{"version":3,"names":["_api","require","init","initOptions","token","Error","projectId","initApi","_baseURL"],"sourceRoot":"../../../src","sources":["register/init.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACO,SAASC,IAAIA,CAACC,WAAwB,EAAE;EAC7C;EACA,IAAIA,WAAW,CAACC,KAAK,EAAE;IACrB,MAAM,IAAIC,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EACA,IAAI,CAACF,WAAW,CAACG,SAAS,EAAE;IAC1B,MAAM,IAAID,KAAK,CAAC,wBAAwB,CAAC;EAC3C;EAEA,IAAAE,YAAO,EAACJ,WAAW,CAACG,SAAS,EAAEH,WAAW,CAACK,QAAQ,CAAC;AACtD","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VERSION","exports"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAS","ignoreList":[]}
|
package/lib/module/api/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import { VERSION } from "../version.js";
|
|
4
5
|
const axiosInstance = axios.create({
|
|
5
6
|
baseURL: 'https://api.comnyx.com',
|
|
6
7
|
headers: {
|
|
@@ -9,14 +10,16 @@ const axiosInstance = axios.create({
|
|
|
9
10
|
timeout: 1000
|
|
10
11
|
});
|
|
11
12
|
export function isInitCalled() {
|
|
12
|
-
return !!axiosInstance.defaults.headers.common
|
|
13
|
+
return !!axiosInstance.defaults.headers.common['project-id'];
|
|
13
14
|
}
|
|
14
15
|
export function isLoginCalled() {
|
|
15
16
|
return !!axiosInstance.defaults.headers.common['external-id'];
|
|
16
17
|
}
|
|
17
|
-
export function initApi(
|
|
18
|
+
export function initApi(projectId, baseURL) {
|
|
18
19
|
axiosInstance.defaults.headers.common['Content-Type'] = 'application/json';
|
|
19
|
-
|
|
20
|
+
// We need to remove any special characters that may be accidentally included when copying and pasting the project ID.
|
|
21
|
+
axiosInstance.defaults.headers.common['project-id'] = projectId.replace(/\n/g, '').trim();
|
|
22
|
+
axiosInstance.defaults.headers.common['user-agent'] = `react-native-comnyx/${VERSION} (React Native)`;
|
|
20
23
|
axiosInstance.defaults.baseURL = baseURL || axiosInstance.defaults.baseURL;
|
|
21
24
|
}
|
|
22
25
|
export function setLoginForAxios(externalId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["axios","axiosInstance","create","baseURL","headers","timeout","isInitCalled","defaults","common","
|
|
1
|
+
{"version":3,"names":["axios","VERSION","axiosInstance","create","baseURL","headers","timeout","isInitCalled","defaults","common","isLoginCalled","initApi","projectId","replace","trim","setLoginForAxios","externalId","setLogoutForAxios"],"sourceRoot":"../../../src","sources":["api/api.ts"],"mappings":";;AAAA,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I;AAC7D;AAEA,SAASP,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["login","collectData","logout","init","Comnyx"],"sourceRoot":"../../../src","sources":["register/index.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,YAAS;AAC/B,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,IAAI,QAAQ,WAAQ;
|
|
1
|
+
{"version":3,"names":["login","collectData","logout","init","VERSION","Comnyx"],"sourceRoot":"../../../src","sources":["register/index.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,YAAS;AAC/B,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,OAAO,QAAQ,eAAY;AAEpC,OAAO,MAAMC,MAAM,GAAG;EACpBF,IAAI,EAAEA,IAAI;EACVH,KAAK,EAAEA,KAAK;EACZE,MAAM,EAAEA,MAAM;EACdD,WAAW,EAAEA;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { initApi } from "../api/api.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for initializing the Comnyx SDK
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the Comnyx SDK with the provided options
|
|
11
|
+
* @param initOptions - Configuration options for initialization
|
|
12
|
+
* @throws {Error} When token is provided (deprecated) or projectId is missing
|
|
13
|
+
*/
|
|
4
14
|
export function init(initOptions) {
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
// Token parameter is deprecated and no longer used
|
|
16
|
+
if (initOptions.token) {
|
|
17
|
+
throw new Error('App token is no longer supported and has been removed');
|
|
18
|
+
}
|
|
19
|
+
if (!initOptions.projectId) {
|
|
20
|
+
throw new Error('Project ID is required');
|
|
7
21
|
}
|
|
8
|
-
initApi(initOptions.
|
|
22
|
+
initApi(initOptions.projectId, initOptions._baseURL);
|
|
9
23
|
}
|
|
10
24
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initApi","init","initOptions","token","Error","
|
|
1
|
+
{"version":3,"names":["initApi","init","initOptions","token","Error","projectId","_baseURL"],"sourceRoot":"../../../src","sources":["register/init.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,eAAY;;AAEpC;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAACC,WAAwB,EAAE;EAC7C;EACA,IAAIA,WAAW,CAACC,KAAK,EAAE;IACrB,MAAM,IAAIC,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EACA,IAAI,CAACF,WAAW,CAACG,SAAS,EAAE;IAC1B,MAAM,IAAID,KAAK,CAAC,wBAAwB,CAAC;EAC3C;EAEAJ,OAAO,CAACE,WAAW,CAACG,SAAS,EAAEH,WAAW,CAACI,QAAQ,CAAC;AACtD","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VERSION"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,SAAS","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const axiosInstance: import("axios").AxiosInstance;
|
|
2
2
|
export declare function isInitCalled(): boolean;
|
|
3
3
|
export declare function isLoginCalled(): boolean;
|
|
4
|
-
export declare function initApi(
|
|
4
|
+
export declare function initApi(projectId: string, baseURL?: string): void;
|
|
5
5
|
export declare function setLoginForAxios(externalId: string): void;
|
|
6
6
|
export declare function setLogoutForAxios(): void;
|
|
7
7
|
export { axiosInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa,+BAMjB,CAAC;AAEH,wBAAgB,YAAY,YAE3B;AAED,wBAAgB,aAAa,YAE5B;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAS1D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,QAElD;AAED,wBAAgB,iBAAiB,SAEhC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/register/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/register/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,eAAO,MAAM,MAAM;;;;;CAKlB,CAAC"}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for initializing the Comnyx SDK
|
|
3
|
+
*/
|
|
1
4
|
interface InitOptions {
|
|
2
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Token parameter is no longer used and will be removed in a future version
|
|
7
|
+
*/
|
|
8
|
+
token?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The project ID for your Comnyx project
|
|
11
|
+
*/
|
|
12
|
+
projectId: string;
|
|
13
|
+
/**
|
|
14
|
+
* The base URL for the Comnyx API
|
|
15
|
+
* @remarks Not recommended for production use - only for development purposes
|
|
16
|
+
*/
|
|
17
|
+
_baseURL?: string;
|
|
3
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the Comnyx SDK with the provided options
|
|
21
|
+
* @param initOptions - Configuration options for initialization
|
|
22
|
+
* @throws {Error} When token is provided (deprecated) or projectId is missing
|
|
23
|
+
*/
|
|
4
24
|
export declare function init(initOptions: InitOptions): void;
|
|
5
25
|
export {};
|
|
6
26
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/register/init.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/register/init.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,UAAU,WAAW;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,QAU5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developer_tribe/react-native-comnyx",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"description": "React Native chat component with integrated support panel, enabling real-time customer communication and efficient agent workflow management.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -38,25 +38,13 @@
|
|
|
38
38
|
"!**/__mocks__",
|
|
39
39
|
"!**/.*"
|
|
40
40
|
],
|
|
41
|
-
"codegenConfig": {
|
|
42
|
-
"name": "RNComnyxSpec",
|
|
43
|
-
"type": "modules",
|
|
44
|
-
"jsSrcsDir": "src",
|
|
45
|
-
"outputDir": {
|
|
46
|
-
"ios": "ios/generated",
|
|
47
|
-
"android": "android/generated"
|
|
48
|
-
},
|
|
49
|
-
"android": {
|
|
50
|
-
"javaPackageName": "com.comnyx"
|
|
51
|
-
},
|
|
52
|
-
"includesGeneratedCode": true
|
|
53
|
-
},
|
|
54
41
|
"scripts": {
|
|
55
42
|
"test": "jest --config jest.config.ts",
|
|
56
43
|
"typecheck": "tsc",
|
|
57
44
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
58
45
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
59
46
|
"prepare": "bob build",
|
|
47
|
+
"generate-version": "node -e \"const fs = require('fs'); const { version } = require('./package.json'); fs.writeFileSync('./src/version.ts', '// This file is auto-generated. Do not edit manually.\\nexport const VERSION = \\'' + version + '\\';\\n');\"",
|
|
60
48
|
"release": "release-it"
|
|
61
49
|
},
|
|
62
50
|
"keywords": [
|
|
@@ -87,7 +75,7 @@
|
|
|
87
75
|
"@testing-library/react-native": "^13.2.0",
|
|
88
76
|
"@types/jest": "^29.5.5",
|
|
89
77
|
"@types/react": "^18.2.44",
|
|
90
|
-
"axios": "1.
|
|
78
|
+
"axios": "1.10.0",
|
|
91
79
|
"commitlint": "^19.6.1",
|
|
92
80
|
"del-cli": "^5.1.0",
|
|
93
81
|
"eslint": "^8.51.0",
|
|
@@ -143,6 +131,9 @@
|
|
|
143
131
|
"name": "angular"
|
|
144
132
|
}
|
|
145
133
|
}
|
|
134
|
+
},
|
|
135
|
+
"hooks": {
|
|
136
|
+
"after:bump": "yarn generate-version"
|
|
146
137
|
}
|
|
147
138
|
},
|
|
148
139
|
"eslintConfig": {
|
package/react-native.config.js
CHANGED
package/src/api/api.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
import { VERSION } from '../version';
|
|
3
|
+
|
|
2
4
|
const axiosInstance = axios.create({
|
|
3
5
|
baseURL: 'https://api.comnyx.com',
|
|
4
6
|
headers: {
|
|
@@ -8,16 +10,21 @@ const axiosInstance = axios.create({
|
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
export function isInitCalled() {
|
|
11
|
-
return !!axiosInstance.defaults.headers.common
|
|
13
|
+
return !!axiosInstance.defaults.headers.common['project-id'];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export function isLoginCalled() {
|
|
15
17
|
return !!axiosInstance.defaults.headers.common['external-id'];
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
export function initApi(
|
|
20
|
+
export function initApi(projectId: string, baseURL?: string) {
|
|
19
21
|
axiosInstance.defaults.headers.common['Content-Type'] = 'application/json';
|
|
20
|
-
|
|
22
|
+
// We need to remove any special characters that may be accidentally included when copying and pasting the project ID.
|
|
23
|
+
axiosInstance.defaults.headers.common['project-id'] = projectId
|
|
24
|
+
.replace(/\n/g, '')
|
|
25
|
+
.trim();
|
|
26
|
+
axiosInstance.defaults.headers.common['user-agent'] =
|
|
27
|
+
`react-native-comnyx/${VERSION} (React Native)`;
|
|
21
28
|
axiosInstance.defaults.baseURL = baseURL || axiosInstance.defaults.baseURL;
|
|
22
29
|
}
|
|
23
30
|
|
package/src/register/index.ts
CHANGED
package/src/register/init.ts
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import { initApi } from '../api/api';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Options for initializing the Comnyx SDK
|
|
5
|
+
*/
|
|
3
6
|
interface InitOptions {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Token parameter is no longer used and will be removed in a future version
|
|
9
|
+
*/
|
|
10
|
+
token?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The project ID for your Comnyx project
|
|
13
|
+
*/
|
|
14
|
+
projectId: string;
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The base URL for the Comnyx API
|
|
18
|
+
* @remarks Not recommended for production use - only for development purposes
|
|
19
|
+
*/
|
|
20
|
+
_baseURL?: string;
|
|
9
21
|
}
|
|
10
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the Comnyx SDK with the provided options
|
|
25
|
+
* @param initOptions - Configuration options for initialization
|
|
26
|
+
* @throws {Error} When token is provided (deprecated) or projectId is missing
|
|
27
|
+
*/
|
|
11
28
|
export function init(initOptions: InitOptions) {
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
// Token parameter is deprecated and no longer used
|
|
30
|
+
if (initOptions.token) {
|
|
31
|
+
throw new Error('App token is no longer supported and has been removed');
|
|
32
|
+
}
|
|
33
|
+
if (!initOptions.projectId) {
|
|
34
|
+
throw new Error('Project ID is required');
|
|
14
35
|
}
|
|
15
|
-
|
|
36
|
+
|
|
37
|
+
initApi(initOptions.projectId, initOptions._baseURL);
|
|
16
38
|
}
|
package/src/version.ts
ADDED