@alwatr/nitrobase-engine 9.3.0 → 9.4.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/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/nitrobase-engine v9.
|
|
2
|
-
import{delay as H}from"@alwatr/delay";import{exitHook as k}from"@alwatr/exit-hook";import{getStoreId as U,getStorePath as X}from"@alwatr/nitrobase-helper";import{CollectionReference as V,DocumentReference as Y}from"@alwatr/nitrobase-reference";import{StoreFileType as O,StoreFileExtension as L,Region as D}from"@alwatr/nitrobase-types";import{existsSync as A,readJson as $,resolve as W,unlink as J,writeJson as j}from"@alwatr/node-fs";import{createLogger as G}from"@alwatr/logger";var B=G("@alwatr/nitrobase-engine");q:B.logFileModule?.("alwatr-nitrobase");class Z{config;static version="9.
|
|
1
|
+
/* 📦 @alwatr/nitrobase-engine v9.4.0 */
|
|
2
|
+
import{delay as H}from"@alwatr/delay";import{exitHook as k}from"@alwatr/exit-hook";import{getStoreId as U,getStorePath as X}from"@alwatr/nitrobase-helper";import{CollectionReference as V,DocumentReference as Y}from"@alwatr/nitrobase-reference";import{StoreFileType as O,StoreFileExtension as L,Region as D}from"@alwatr/nitrobase-types";import{existsSync as A,readJson as $,resolve as W,unlink as J,writeJson as j}from"@alwatr/node-fs";import{createLogger as G}from"@alwatr/logger";var B=G("@alwatr/nitrobase-engine");q:B.logFileModule?.("alwatr-nitrobase");class Z{config;static version="9.4.0";static rootDbStat__={name:".nitrobase",region:D.Secret,type:O.Collection,extension:L.Json,changeDebounce:40};rootDb__;cacheReferences__={};constructor(q){this.config=q;this.storeChanged_=this.storeChanged_.bind(this),B.logMethodArgs?.("new",q),this.config.defaultChangeDebounce??=40,this.rootDb__=this.loadRootDb__(),k(this.exitHook__.bind(this))}hasStore(q){let z=U(q),K=this.rootDb__.hasItem(z);return B.logMethodFull?.("hasStore",z,K),K}newDocument(q,z){return B.logMethodArgs?.("newDocument",q),this.newStoreFile__({...q,type:O.Document},z)}newCollection(q){return B.logMethodArgs?.("newCollection",q),this.newStoreFile__({...q,type:O.Collection})}newStoreFile__(q,z){B.logMethodArgs?.("newStoreFile__",q),q.changeDebounce??=this.config.defaultChangeDebounce;let K;if(q.type===O.Document){if(z===void 0)throw B.accident("newStoreFile__","document_data_required",q),Error("document_data_required",{cause:q});K=Y.newRefFromData(q,z,this.storeChanged_)}else if(q.type===O.Collection)K=V.newRefFromData(q,this.storeChanged_);else throw B.accident("newStoreFile__","store_file_type_not_supported",q),Error("store_file_type_not_supported",{cause:q});if(this.rootDb__.hasItem(K.id))throw B.accident("newStoreFile__","store_file_already_defined",q),Error("store_file_already_defined",{cause:q});this.rootDb__.addItem(K.id,q),this.cacheReferences__[K.id]=K,this.storeChanged_(K)}async openDocument(q){let z=U(q);if(B.logMethodArgs?.("openDocument",z),Object.hasOwn(this.cacheReferences__,z)){if(!(this.cacheReferences__[z]instanceof Y))throw B.accident("openDocument","document_wrong_type",z),Error("document_wrong_type",{cause:z});return this.cacheReferences__[z]}if(!this.rootDb__.hasItem(z))throw B.accident("openDocument","document_not_found",z),Error("document_not_found",{cause:z});let K=this.rootDb__.getItemData(z);if(K.type!=O.Document)throw B.accident("openDocument","document_wrong_type",z),Error("document_wrong_type",{cause:z});let Q=await this.readContext__(K),M=Y.newRefFromContext(Q,this.storeChanged_);return this.cacheReferences__[z]=M,M}async openCollection(q){let z=U(q);if(B.logMethodArgs?.("openCollection",z),Object.hasOwn(this.cacheReferences__,z)){if(!(this.cacheReferences__[z]instanceof V))throw B.accident("openCollection","collection_wrong_type",z),Error("collection_wrong_type",{cause:z});return this.cacheReferences__[z]}if(!this.rootDb__.hasItem(z))throw B.accident("openCollection","collection_not_found",z),Error("collection_not_found",{cause:z});let K=this.rootDb__.getItemData(z);if(K.type!=O.Collection)throw B.accident("openCollection","collection_wrong_type",z),Error("collection_not_found",{cause:z});let Q=await this.readContext__(K),M=V.newRefFromContext(Q,this.storeChanged_);return this.cacheReferences__[z]=M,M}unloadStore(q){let z=U(q);B.logMethodArgs?.("unloadStore",z);let K=this.cacheReferences__[z];if(K===void 0)return;if(K.hasUnprocessedChanges_===!0)K.updateDelayed_=!1,this.storeChanged_(K);delete this.cacheReferences__[z]}async removeStore(q){let z=U(q);if(B.logMethodArgs?.("removeStore",z),!this.rootDb__.hasItem(z))throw B.accident("removeStore","document_not_found",z),Error("document_not_found",{cause:z});let K=this.cacheReferences__[z];if(K!==void 0)K.freeze=!0,K.updateDelayed_=!1,K.hasUnprocessedChanges_=!1,delete this.cacheReferences__[z];let Q=X(this.rootDb__.getItemData(z));this.rootDb__.removeItem(z),await H.by(0);try{await J(W(this.config.rootPath,Q))}catch(M){B.error("removeStore","remove_file_failed",M,{id:q,path:Q})}}async saveAll(){B.logMethod?.("saveAll");for(let q of Object.values(this.cacheReferences__))if(q.hasUnprocessedChanges_===!0&&q.freeze!==!0)q.updateDelayed_=!1,await this.storeChanged_(q)}async readContext__(q){if(typeof q!=="string")q=X(q);B.logMethodArgs?.("readContext__",q),B.time?.(`readContext__time(${q})`);let z=await $(W(this.config.rootPath,q));return B.timeEnd?.(`readContext__time(${q})`),z}writeContext__(q,z){if(typeof q!=="string")q=X(q);return B.logMethodArgs?.("writeContext__",q),j(W(this.config.rootPath,q),z)}async storeChanged_(q){B.logMethodArgs?.("storeChanged__",q.id);let z=q.getStoreMeta().rev;try{if(await this.writeContext__(q.path,q.getFullContext_()),z===q.getStoreMeta().rev)q.hasUnprocessedChanges_=!1}catch(K){B.error("storeChanged__","write_context_failed",{id:q.id,error:K})}}loadRootDb__(){B.logMethod?.("loadRootDb__");let q=W(this.config.rootPath,X(Z.rootDbStat__));if(!A(q)){if(this.config.errorWhenNotInitialized===!0)throw Error("store_not_found",{cause:"Nitrobase not initialized"});return B.banner("Initialize new alwatr-nitrobase"),V.newRefFromData(Z.rootDbStat__,this.storeChanged_)}let z=$(q,!0);return V.newRefFromContext(z,this.storeChanged_,"root-db")}exitHook__(){B.logMethod?.("exitHook__");for(let q of Object.values(this.cacheReferences__))if(B.logProperty?.(`StoreFile.${q.id}.hasUnprocessedChanges`,q.hasUnprocessedChanges_),q.hasUnprocessedChanges_===!0&&q.freeze!==!0)B.incident?.("exitHook__","rescue_unsaved_context",{id:q.id}),j(W(this.config.rootPath,q.path),q.getFullContext_(),!0),q.hasUnprocessedChanges_=!1}getStoreList(){return B.logMethod?.("getStoreList"),this.rootDb__.values()}}export{Z as AlwatrNitrobase};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=CEDC0624DAEB1BB164756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import {createLogger} from '@alwatr/logger';\n\n\nexport const logger = /* #__PURE__ */ createLogger(__package_name__);\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAAA,gBAAQ,sBACR,mBAAQ,0BACR,qBAAQ,kBAAY,iCACpB,8BAAQ,uBAAqB,oCAC7B,wBACE,wBACA,YACA,gCAQF,qBAAQ,cAAY,aAAU,YAAS,eAAQ,wBCf/C,uBAAQ,uBAGD,IAAM,EAAyB,EAAa,0BAAgB,EDiBnE,EAAc,EAAO,gBAAgB,kBAAkB,EAgChD,MAAM,CAAgB,CA0CC,aApCL,SAAU,cAKT,cAA8B,CACpD,KAAM,aACN,OAAQ,EAAO,OACf,KAAM,EAAc,WACpB,UAAW,EAAmB,KAC9B,eAAgB,EAClB,EAMQ,SAKA,kBAA4E,CAAC,EAcrF,WAAW,CAAiB,EAA+B,CAA/B,cAC1B,KAAK,cAAgB,KAAK,cAAc,KAAK,IAAI,EAEjD,EAAO,gBAAgB,MAAO,CAAM,EACpC,KAAK,OAAO,wBAA0B,GACtC,KAAK,SAAW,KAAK,aAAa,EAClC,EAAS,KAAK,WAAW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AAc,aAAa,EAAI,2BAA4B,EAAI,sBAAsB,EACxF,EAAI,yBAA2B,IAAQ,EAAI,SAAW,GACxD,EAAO,WAAW,aAAc,yBAA0B,CAAC,GAAI,EAAI,EAAE,CAAC,EACtE,EAAU,EAAQ,KAAK,OAAO,SAAU,EAAI,IAAI,EAAG,EAAI,gBAAgB,EAAG,EAAI,EAC9E,EAAI,uBAAyB,GAgB5B,YAAY,EAAuD,CAExE,OADA,EAAO,YAAY,cAAc,EAC1B,KAAK,SAAS,OAAO,EAEhC",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "CEDC0624DAEB1BB164756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/nitrobase-engine",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"description": "Nitrobase is a blazingly fast, lightweight database built on JSON. It stores data entirely in memory for lightning-quick access, while also providing a JSON file backup for persistence. You can easily serve your data over the web using our high-performance accelerated Nginx server.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@alwatr/delay": "9.
|
|
25
|
-
"@alwatr/exit-hook": "9.
|
|
26
|
-
"@alwatr/logger": "9.
|
|
27
|
-
"@alwatr/nitrobase-helper": "^9.
|
|
28
|
-
"@alwatr/nitrobase-reference": "^9.
|
|
29
|
-
"@alwatr/nitrobase-types": "^9.
|
|
30
|
-
"@alwatr/node-fs": "9.
|
|
24
|
+
"@alwatr/delay": "9.4.0",
|
|
25
|
+
"@alwatr/exit-hook": "9.4.0",
|
|
26
|
+
"@alwatr/logger": "9.4.0",
|
|
27
|
+
"@alwatr/nitrobase-helper": "^9.4.0",
|
|
28
|
+
"@alwatr/nitrobase-reference": "^9.4.0",
|
|
29
|
+
"@alwatr/nitrobase-types": "^9.4.0",
|
|
30
|
+
"@alwatr/node-fs": "9.4.0",
|
|
31
31
|
"@alwatr/type-helper": "9.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@alwatr/nano-build": "9.3.0",
|
|
35
|
-
"@alwatr/standard": "9.
|
|
35
|
+
"@alwatr/standard": "9.4.0",
|
|
36
36
|
"@alwatr/type-helper": "workspace:*",
|
|
37
37
|
"@types/node": "^24.12.2",
|
|
38
38
|
"typescript": "^6.0.2"
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
+
"prettier": "@alwatr/nanolib/prettier-config",
|
|
66
67
|
"keywords": [
|
|
67
68
|
"alwatr",
|
|
68
69
|
"data",
|
|
@@ -76,6 +77,5 @@
|
|
|
76
77
|
"storage",
|
|
77
78
|
"typescript"
|
|
78
79
|
],
|
|
79
|
-
"
|
|
80
|
-
"gitHead": "adf6d486667eefee42dfc87938e3af96f87c4738"
|
|
80
|
+
"gitHead": "662f1047fc2a1b53a00902028d6cebfd04b52dd5"
|
|
81
81
|
}
|