script.io.js 2026.124.153 → 2026.124.357
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/node_packages/script.js +63 -127
- package/package.json +1 -1
package/node_packages/script.js
CHANGED
|
@@ -550,84 +550,6 @@ Define (Function.hash, "require", function () { Function.hash.crypto.api = requi
|
|
|
550
550
|
Define (Function.hash, "crypto", function () {});
|
|
551
551
|
Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
|
|
552
552
|
|
|
553
|
-
/**
|
|
554
|
-
* appwrite
|
|
555
|
-
*
|
|
556
|
-
* title
|
|
557
|
-
* description
|
|
558
|
-
* sub description
|
|
559
|
-
*
|
|
560
|
-
* xxx://xxx.xxx.xxx/xxx
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
Define (Function, "appwrite", function () {});
|
|
564
|
-
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
565
|
-
|
|
566
|
-
Define (Function.appwrite, "db", class {
|
|
567
|
-
constructor (config, json) {
|
|
568
|
-
this.config = config;
|
|
569
|
-
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
570
|
-
this.json = json || {}
|
|
571
|
-
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
572
|
-
}
|
|
573
|
-
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
Define (Function.appwrite.db, "select", class {
|
|
577
|
-
constructor (db, collection) {
|
|
578
|
-
this.db = db;
|
|
579
|
-
this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
|
|
580
|
-
this.option = {sort: {}, offset: 0, limit: 5000}
|
|
581
|
-
}
|
|
582
|
-
sort (sort) {
|
|
583
|
-
return this;
|
|
584
|
-
}
|
|
585
|
-
limit () {
|
|
586
|
-
if (arguments.length > 1) { this.option.offset = arguments [0]; this.option.limit = arguments [1]; }
|
|
587
|
-
else if (arguments.length) { this.option.offset = 0; this.option.limit = arguments [0]; }
|
|
588
|
-
else { this.option.offset = 0; this.option.limit = 5000; }
|
|
589
|
-
return this;
|
|
590
|
-
}
|
|
591
|
-
find (filter = {}) {
|
|
592
|
-
var serial;
|
|
593
|
-
if (typeof filter !== "object") filter = {serial: (serial = filter)}
|
|
594
|
-
var __ = function (db) {
|
|
595
|
-
return new Promise (async function (resolve, reject) {
|
|
596
|
-
var data;
|
|
597
|
-
var error = false;
|
|
598
|
-
var database, result, queries = [];
|
|
599
|
-
if (serial) queries = [Function.appwrite.api.Query.limit (1)]
|
|
600
|
-
else {
|
|
601
|
-
if (db.option.limit) queries.push (Function.appwrite.api.Query.limit (db.option.limit));
|
|
602
|
-
}
|
|
603
|
-
/*
|
|
604
|
-
try {
|
|
605
|
-
database = new Function.appwrite.api.Databases (db.db.client);
|
|
606
|
-
result = await database.listDocuments ({
|
|
607
|
-
databaseId: db.db.config.id,
|
|
608
|
-
collectionId: db.collection.id,
|
|
609
|
-
queries,
|
|
610
|
-
total: true,
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
catch (e) { error = true; console.log (e); }
|
|
614
|
-
if (error === false) {
|
|
615
|
-
data = result.documents.map (function (data) { return data; }).select (filter);
|
|
616
|
-
data = db.collection.json.select (filter).implode (data);
|
|
617
|
-
}
|
|
618
|
-
//*/
|
|
619
|
-
setTimeout (function () {
|
|
620
|
-
resolve ({error, data});
|
|
621
|
-
}, 1000)
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
return __ (this);
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
|
|
629
|
-
Define (Function.appwrite.db.collection, "object", {});
|
|
630
|
-
|
|
631
553
|
/**
|
|
632
554
|
* xxx
|
|
633
555
|
*
|
|
@@ -1036,7 +958,7 @@ Function.owl.carousel ["flash"] = {
|
|
|
1036
958
|
}
|
|
1037
959
|
|
|
1038
960
|
/**
|
|
1039
|
-
*
|
|
961
|
+
* appwrite
|
|
1040
962
|
*
|
|
1041
963
|
* title
|
|
1042
964
|
* description
|
|
@@ -1045,60 +967,74 @@ Function.owl.carousel ["flash"] = {
|
|
|
1045
967
|
* xxx://xxx.xxx.xxx/xxx
|
|
1046
968
|
*/
|
|
1047
969
|
|
|
1048
|
-
Define (Function, "
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
request.domain = request.http.domain;
|
|
1058
|
-
request.param = function param (param) { return request.params [param] || ""; }
|
|
1059
|
-
request.param.query = function param (query) { return request.http.queries [query] || ""; }
|
|
1060
|
-
}
|
|
1061
|
-
if ("visitor") {
|
|
1062
|
-
var ip_address = request.headers ["x-real-ip"] || "127.0.0.1";
|
|
1063
|
-
var country_code = request.headers ["x-vercel-ip-country"] || "";
|
|
1064
|
-
var country_name = "";
|
|
1065
|
-
var country_region = request.headers ["x-vercel-ip-country-region"] || "";
|
|
1066
|
-
var country_city_code = "";
|
|
1067
|
-
var country_city_name = request.headers ["x-vercel-ip-city"] || "";
|
|
1068
|
-
var country_timezone = request.headers ["x-vercel-ip-timezone"] || "";
|
|
1069
|
-
var coordinate_latitude = request.headers ["x-vercel-ip-latitude"] || "";
|
|
1070
|
-
var coordinate_longitude = request.headers ["x-vercel-ip-longitude"] || "";
|
|
1071
|
-
request.visitor = {
|
|
1072
|
-
ip: {address: ip_address},
|
|
1073
|
-
country: {code: country_code, name: country_name, region: country_region, city: {name: country_city_name}, timezone: country_timezone, coordinate: {latitude: coordinate_latitude, longitude: coordinate_longitude}},
|
|
1074
|
-
browser: request.header ("user-agent"),
|
|
1075
|
-
}
|
|
970
|
+
Define (Function, "appwrite", function () {});
|
|
971
|
+
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
972
|
+
|
|
973
|
+
Define (Function.appwrite, "db", class {
|
|
974
|
+
constructor (config, json) {
|
|
975
|
+
this.config = config;
|
|
976
|
+
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
977
|
+
this.json = json || {}
|
|
978
|
+
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
1076
979
|
}
|
|
1077
|
-
|
|
1078
|
-
request.db = function () {}
|
|
1079
|
-
request.instance = function () {}
|
|
1080
|
-
request.theme = function () {}
|
|
980
|
+
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
1081
981
|
});
|
|
1082
982
|
|
|
1083
|
-
Define (Function.
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
983
|
+
Define (Function.appwrite.db, "select", class {
|
|
984
|
+
constructor (db, collection) {
|
|
985
|
+
this.db = db;
|
|
986
|
+
this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
|
|
987
|
+
this.prop = {filter: {}, sort: {}, offset: 0, limit: 5000}
|
|
988
|
+
}
|
|
989
|
+
sort (sort) {
|
|
990
|
+
return this;
|
|
991
|
+
}
|
|
992
|
+
limit () {
|
|
993
|
+
if (arguments.length > 1) { this.prop.offset = arguments [0]; this.prop.limit = arguments [1]; }
|
|
994
|
+
else if (arguments.length) { this.prop.offset = 0; this.prop.limit = arguments [0]; }
|
|
995
|
+
else { this.prop.offset = 0; this.prop.limit = 5000; }
|
|
996
|
+
return this;
|
|
997
|
+
}
|
|
998
|
+
find (filter = {}) {
|
|
999
|
+
this.prop.filter = filter;
|
|
1000
|
+
return this;
|
|
1001
|
+
}
|
|
1002
|
+
query () {
|
|
1003
|
+
var serial;
|
|
1004
|
+
if (typeof this.prop.filter !== "object") this.prop.filter = {serial: (serial = this.prop.filter)}
|
|
1005
|
+
var __ = function (db) {
|
|
1006
|
+
return new Promise (async function (resolve, reject) {
|
|
1007
|
+
var data;
|
|
1008
|
+
var error = false;
|
|
1009
|
+
var database, result, query = [];
|
|
1010
|
+
if (serial) query = [Function.appwrite.api.Query.limit (1)]
|
|
1011
|
+
else {
|
|
1012
|
+
if (db.prop.limit) query.push (Function.appwrite.api.Query.limit (db.prop.limit));
|
|
1013
|
+
}
|
|
1014
|
+
try {
|
|
1015
|
+
database = new Function.appwrite.api.Databases (db.db.client);
|
|
1016
|
+
result = await database.listDocuments ({
|
|
1017
|
+
databaseId: db.db.config.id,
|
|
1018
|
+
collectionId: db.collection.id,
|
|
1019
|
+
queries: query,
|
|
1020
|
+
total: true,
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
catch (e) { if (error = true) console.log (e); }
|
|
1024
|
+
if (error === false) {
|
|
1025
|
+
data = result.documents.map (function (data) { return data; }).select (db.prop.filter);
|
|
1026
|
+
data = db.collection.json.select (db.prop.filter).implode (data);
|
|
1027
|
+
}
|
|
1028
|
+
resolve ({error, data});
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return __ (this);
|
|
1098
1032
|
}
|
|
1099
|
-
response.db = function () {}
|
|
1100
1033
|
});
|
|
1101
1034
|
|
|
1035
|
+
Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
|
|
1036
|
+
Define (Function.appwrite.db.collection, "object", {});
|
|
1037
|
+
|
|
1102
1038
|
/**
|
|
1103
1039
|
* xxx
|
|
1104
1040
|
*
|