@nativescript/appwrite
Advanced tools
Comparing version
@@ -0,1 +1,2 @@ | ||
export declare function dataDeserialize(nativeData?: any): any; | ||
export declare class Client { | ||
@@ -2,0 +3,0 @@ private _native; |
import { Utils } from '@nativescript/core'; | ||
export function dataDeserialize(nativeData) { | ||
if (nativeData === null || typeof nativeData !== 'object') { | ||
return nativeData; | ||
} | ||
let store; | ||
switch (nativeData.getClass().getName()) { | ||
case 'java.lang.String': { | ||
return String(nativeData); | ||
} | ||
case 'java.lang.Boolean': { | ||
return String(nativeData) === 'true'; | ||
} | ||
case 'java.lang.Float': | ||
case 'java.lang.Integer': | ||
case 'java.lang.Long': | ||
case 'java.lang.Double': | ||
case 'java.lang.Short': { | ||
return Number(nativeData); | ||
} | ||
case 'org.json.JSONArray': { | ||
store = []; | ||
for (let j = 0; j < nativeData.length(); j++) { | ||
store[j] = dataDeserialize(nativeData.get(j)); | ||
} | ||
break; | ||
} | ||
case 'org.json.JSONObject': { | ||
store = {}; | ||
const i = nativeData.keys(); | ||
let key; | ||
while (i.hasNext()) { | ||
key = i.next(); | ||
store[key] = dataDeserialize(nativeData.get(key)); | ||
} | ||
break; | ||
} | ||
case 'androidx.collection.SimpleArrayMap': { | ||
const count = nativeData.size(); | ||
for (let l = 0; l < count; l++) { | ||
const key = nativeData.keyAt(l); | ||
store[key] = dataDeserialize(nativeData.get(key)); | ||
} | ||
break; | ||
} | ||
case 'com.google.gson.internal.LinkedTreeMap': | ||
case 'androidx.collection.ArrayMap': | ||
case 'android.os.Bundle': | ||
case 'java.util.HashMap': | ||
case 'java.util.Map': { | ||
store = {}; | ||
const keys = nativeData.keySet().toArray(); | ||
for (let k = 0; k < keys.length; k++) { | ||
const key = keys[k]; | ||
store[key] = dataDeserialize(nativeData.get(key)); | ||
} | ||
break; | ||
} | ||
default: | ||
if (typeof nativeData === 'object' && nativeData instanceof java.util.List) { | ||
const array = []; | ||
const size = nativeData.size(); | ||
for (let i = 0, n = size; i < n; i++) { | ||
array[i] = dataDeserialize(nativeData.get(i)); | ||
} | ||
store = array; | ||
} | ||
else { | ||
store = null; | ||
} | ||
break; | ||
} | ||
return store; | ||
} | ||
export class Client { | ||
@@ -112,3 +185,3 @@ constructor() { | ||
get labels() { | ||
return Utils.dataDeserialize(this.native.getLabels()); | ||
return dataDeserialize(this.native.getLabels()); | ||
} | ||
@@ -134,3 +207,3 @@ get mfa() { | ||
get prefs() { | ||
return Utils.dataDeserialize(this.native.getPrefs); | ||
return dataDeserialize(this.native.getPrefs()); | ||
} | ||
@@ -160,3 +233,3 @@ get registration() { | ||
toJSON() { | ||
return Utils.dataDeserialize(this.native.toMap()); | ||
return dataDeserialize(this.native.toMap()); | ||
} | ||
@@ -256,3 +329,3 @@ } | ||
get data() { | ||
return Utils.dataDeserialize(this.native.getData()); | ||
return dataDeserialize(this.native.getData()); | ||
} | ||
@@ -266,3 +339,3 @@ get databaseId() { | ||
get permissions() { | ||
return Utils.dataDeserialize(this.native.getPermissions()); | ||
return dataDeserialize(this.native.getPermissions()); | ||
} | ||
@@ -434,3 +507,3 @@ get updatedAt() { | ||
get factors() { | ||
return Utils.dataDeserialize(this.native.getFactors()); | ||
return dataDeserialize(this.native.getFactors()); | ||
} | ||
@@ -437,0 +510,0 @@ get id() { |
{ | ||
"name": "@nativescript/appwrite", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "Appwrite SDK for NativeScript", | ||
@@ -5,0 +5,0 @@ "main": "index", |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
137600
3.58%1753
4.41%1
Infinity%