@alwatr/nitrobase-engine 7.2.0 → 7.2.1
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/CHANGELOG.md +11 -0
- package/README.md +4 -4
- package/dist/main.cjs +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.2.1](https://github.com/Alwatr/nitrobase/compare/v7.2.0...v7.2.1) (2024-09-29)
|
|
7
|
+
|
|
8
|
+
### Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* **deps-dev:** bump @types/node in the development-dependencies group ([9b146d2](https://github.com/Alwatr/nitrobase/commit/9b146d2f6cf7d1d79a2a6f46a5e8f50e7fb2ac75)) by @dependabot[bot]
|
|
11
|
+
* **engine:** change the license to AGPL-3.0 ([f9d89d5](https://github.com/Alwatr/nitrobase/commit/f9d89d5de592b4df397c9b15156166aed90fa8d1)) by @ArmanAsadian
|
|
12
|
+
|
|
13
|
+
### Dependencies update
|
|
14
|
+
|
|
15
|
+
* update ([90a0fe1](https://github.com/Alwatr/nitrobase/commit/90a0fe146eb703c183c116776d7c5748918282da)) by @
|
|
16
|
+
|
|
6
17
|
## [7.2.0](https://github.com/Alwatr/nitrobase/compare/v7.1.1...v7.2.0) (2024-09-24)
|
|
7
18
|
|
|
8
19
|
### Code Refactoring
|
package/README.md
CHANGED
|
@@ -80,10 +80,10 @@ The following companies, organizations, and individuals support Nitrobase ongoin
|
|
|
80
80
|
|
|
81
81
|
[](https://exirstudio.com)
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
### Contributing
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
Contributions are welcome! Please read our [contribution guidelines](https://github.com/Alwatr/.github/blob/next/CONTRIBUTING.md) before submitting a pull request.
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
### License
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
This project is licensed under the [AGPL-3.0 License](LICENSE).
|
package/dist/main.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/nitrobase-engine v7.2.
|
|
2
|
-
"use strict";var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var S=(_,e)=>{for(var t in e)h(_,t,{get:e[t],enumerable:!0})},b=(_,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of w(e))!D.call(_,i)&&i!==t&&h(_,i,{get:()=>e[i],enumerable:!(n=p(e,i))||n.enumerable});return _};var x=_=>b(h({},"__esModule",{value:!0}),_);var y={};S(y,{AlwatrNitrobase:()=>f});module.exports=x(y);var u=require("@alwatr/logger"),o=(0,u.definePackage)("@alwatr/nitrobase-engine","7.2.
|
|
1
|
+
/* @alwatr/nitrobase-engine v7.2.1 */
|
|
2
|
+
"use strict";var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var S=(_,e)=>{for(var t in e)h(_,t,{get:e[t],enumerable:!0})},b=(_,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of w(e))!D.call(_,i)&&i!==t&&h(_,i,{get:()=>e[i],enumerable:!(n=p(e,i))||n.enumerable});return _};var x=_=>b(h({},"__esModule",{value:!0}),_);var y={};S(y,{AlwatrNitrobase:()=>f});module.exports=x(y);var u=require("@alwatr/logger"),o=(0,u.definePackage)("@alwatr/nitrobase-engine","7.2.1");var g=require("@alwatr/exit-hook"),s=require("@alwatr/nitrobase-helper"),a=require("@alwatr/nitrobase-reference"),c=require("@alwatr/nitrobase-types"),r=require("@alwatr/node-fs"),m=require("@alwatr/wait");o.logModule?.("alwatr-nitrobase");var d=class d{constructor(e){this.config__=e;this.cacheReferences__={};var t;o.logMethodArgs?.("new",e),(t=this.config__).defaultChangeDebounce??(t.defaultChangeDebounce=40),this.rootDb__=this.loadRootDb__(),(0,g.exitHook)(this.exitHook__.bind(this))}hasStore(e){let t=(0,s.getStoreId)(e),n=this.rootDb__.hasItem(t);return o.logMethodFull?.("hasStore",t,n),n}newDocument(e,t=null){return o.logMethodArgs?.("newDocument",e),this.newStoreFile_({...e,type:c.StoreFileType.Document},t)}newCollection(e,t=null){return o.logMethodArgs?.("newCollection",e),this.newStoreFile_({...e,type:c.StoreFileType.Collection},t)}newStoreFile_(e,t=null){o.logMethodArgs?.("newStoreFile_",e),e.changeDebounce??(e.changeDebounce=this.config__.defaultChangeDebounce);let n;if(e.type===c.StoreFileType.Document)n=a.DocumentReference.newRefFromData(e,t,this.storeChanged_.bind(this));else if(e.type===c.StoreFileType.Collection)n=a.CollectionReference.newRefFromData(e,t,this.storeChanged_.bind(this));else throw o.accident("newStoreFile_","store_file_type_not_supported",e),new Error("store_file_type_not_supported",{cause:e});if(this.rootDb__.hasItem(n.id))throw o.accident("newStoreFile_","store_file_already_defined",e),new Error("store_file_already_defined",{cause:e});this.rootDb__.addItem(n.id,e),this.cacheReferences__[n.id]=n,this.storeChanged_(n)}async openDocument(e){let t=(0,s.getStoreId)(e);if(o.logMethodArgs?.("openDocument",t),Object.hasOwn(this.cacheReferences__,t)){if(!(this.cacheReferences__[t]instanceof a.DocumentReference))throw o.accident("openDocument","document_wrong_type",t),new Error("document_wrong_type",{cause:t});return this.cacheReferences__[t]}if(!this.rootDb__.hasItem(t))throw o.accident("openDocument","document_not_found",t),new Error("document_not_found",{cause:t});let n=this.rootDb__.getItemData(t);if(n.type!=c.StoreFileType.Document)throw o.accident("openDocument","document_wrong_type",t),new Error("document_wrong_type",{cause:t});let i=await this.readContext__(n),l=a.DocumentReference.newRefFromContext(i,this.storeChanged_.bind(this));return this.cacheReferences__[t]=l,l}async openCollection(e){let t=(0,s.getStoreId)(e);if(o.logMethodArgs?.("openCollection",t),Object.hasOwn(this.cacheReferences__,t)){if(!(this.cacheReferences__[t]instanceof a.CollectionReference))throw o.accident("openCollection","collection_wrong_type",t),new Error("collection_wrong_type",{cause:t});return this.cacheReferences__[t]}if(!this.rootDb__.hasItem(t))throw o.accident("openCollection","collection_not_found",t),new Error("collection_not_found",{cause:t});let n=this.rootDb__.getItemData(t);if(n.type!=c.StoreFileType.Collection)throw o.accident("openCollection","collection_wrong_type",t),new Error("collection_not_found",{cause:t});let i=await this.readContext__(n),l=a.CollectionReference.newRefFromContext(i,this.storeChanged_.bind(this));return this.cacheReferences__[t]=l,l}unloadStore(e){let t=(0,s.getStoreId)(e);o.logMethodArgs?.("unloadStore",t);let n=this.cacheReferences__[t];n!==void 0&&(n.hasUnprocessedChanges_===!0&&(n.updateDelayed_=!1,this.storeChanged_(n)),delete this.cacheReferences__[t])}async removeStore(e){let t=(0,s.getStoreId)(e);if(o.logMethodArgs?.("removeStore",t),!this.rootDb__.hasItem(t))throw o.accident("removeStore","document_not_found",t),new Error("document_not_found",{cause:t});let n=this.cacheReferences__[t];n!==void 0&&(n.freeze=!0,n.updateDelayed_=!1,n.hasUnprocessedChanges_=!1,delete this.cacheReferences__[t]);let i=(0,s.getStorePath)(this.rootDb__.getItemData(t));this.rootDb__.removeItem(t),await(0,m.waitForTimeout)(0);try{await(0,r.unlink)((0,r.resolve)(this.config__.rootPath,i))}catch(l){o.error("removeStore","remove_file_failed",l,{id:e,path:i})}}async saveAll(){o.logMethod?.("saveAll");for(let e of Object.values(this.cacheReferences__))e.hasUnprocessedChanges_===!0&&e.freeze!==!0&&(e.updateDelayed_=!1,await this.storeChanged_(e))}async readContext__(e){typeof e!="string"&&(e=(0,s.getStorePath)(e)),o.logMethodArgs?.("readContext__",e),o.time?.(`readContext__time(${e})`);let t=await(0,r.readJson)((0,r.resolve)(this.config__.rootPath,e));return o.timeEnd?.(`readContext__time(${e})`),t}writeContext__(e,t){return typeof e!="string"&&(e=(0,s.getStorePath)(e)),o.logMethodArgs?.("writeContext__",e),(0,r.writeJson)((0,r.resolve)(this.config__.rootPath,e),t)}async storeChanged_(e){o.logMethodArgs?.("storeChanged__",e.id);let t=e.getStoreMeta().rev;try{await this.writeContext__(e.path,e.getFullContext_()),t===e.getStoreMeta().rev&&(e.hasUnprocessedChanges_=!1)}catch(n){o.error("storeChanged__","write_context_failed",{id:e.id,error:n})}}loadRootDb__(){o.logMethod?.("loadRootDb__");let e=(0,r.resolve)(this.config__.rootPath,(0,s.getStorePath)(d.rootDbStat__));if(!(0,r.existsSync)(e)){if(this.config__.errorWhenNotInitialized===!0)throw new Error("store_not_found",{cause:"Nitrobase not initialized"});return o.banner("Initialize new alwatr-nitrobase"),a.CollectionReference.newRefFromData(d.rootDbStat__,null,this.storeChanged_.bind(this))}let t=(0,r.readJson)(e,!0);return a.CollectionReference.newRefFromContext(t,this.storeChanged_.bind(this),"root-db")}exitHook__(){o.logMethod?.("exitHook__");for(let e of Object.values(this.cacheReferences__))o.logProperty?.(`StoreFile.${e.id}.hasUnprocessedChanges`,e.hasUnprocessedChanges_),e.hasUnprocessedChanges_===!0&&e.freeze!==!0&&(o.incident?.("exitHook__","rescue_unsaved_context",{id:e.id}),(0,r.writeJson)((0,r.resolve)(this.config__.rootPath,e.path),e.getFullContext_(),!0),e.hasUnprocessedChanges_=!1)}getStoreList(){return o.logMethod?.("getStoreList"),this.rootDb__.values()}};d.version="7.2.1",d.rootDbStat__={name:".nitrobase",region:c.Region.Secret,type:c.StoreFileType.Collection,extension:c.StoreFileExtension.Json,changeDebounce:40};var f=d;0&&(module.exports={AlwatrNitrobase});
|
|
3
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/nitrobase-engine v7.2.
|
|
2
|
-
import{definePackage as C}from"@alwatr/logger";var o=C("@alwatr/nitrobase-engine","7.2.
|
|
1
|
+
/* @alwatr/nitrobase-engine v7.2.1 */
|
|
2
|
+
import{definePackage as C}from"@alwatr/logger";var o=C("@alwatr/nitrobase-engine","7.2.1");import{exitHook as p}from"@alwatr/exit-hook";import{getStoreId as a,getStorePath as d}from"@alwatr/nitrobase-helper";import{CollectionReference as _,DocumentReference as h}from"@alwatr/nitrobase-reference";import{StoreFileType as i,StoreFileExtension as w,Region as D}from"@alwatr/nitrobase-types";import{existsSync as S,readJson as f,resolve as l,unlink as b,writeJson as u}from"@alwatr/node-fs";import{waitForTimeout as x}from"@alwatr/wait";o.logModule?.("alwatr-nitrobase");var s=class s{constructor(e){this.config__=e;this.cacheReferences__={};var t;o.logMethodArgs?.("new",e),(t=this.config__).defaultChangeDebounce??(t.defaultChangeDebounce=40),this.rootDb__=this.loadRootDb__(),p(this.exitHook__.bind(this))}hasStore(e){let t=a(e),n=this.rootDb__.hasItem(t);return o.logMethodFull?.("hasStore",t,n),n}newDocument(e,t=null){return o.logMethodArgs?.("newDocument",e),this.newStoreFile_({...e,type:i.Document},t)}newCollection(e,t=null){return o.logMethodArgs?.("newCollection",e),this.newStoreFile_({...e,type:i.Collection},t)}newStoreFile_(e,t=null){o.logMethodArgs?.("newStoreFile_",e),e.changeDebounce??(e.changeDebounce=this.config__.defaultChangeDebounce);let n;if(e.type===i.Document)n=h.newRefFromData(e,t,this.storeChanged_.bind(this));else if(e.type===i.Collection)n=_.newRefFromData(e,t,this.storeChanged_.bind(this));else throw o.accident("newStoreFile_","store_file_type_not_supported",e),new Error("store_file_type_not_supported",{cause:e});if(this.rootDb__.hasItem(n.id))throw o.accident("newStoreFile_","store_file_already_defined",e),new Error("store_file_already_defined",{cause:e});this.rootDb__.addItem(n.id,e),this.cacheReferences__[n.id]=n,this.storeChanged_(n)}async openDocument(e){let t=a(e);if(o.logMethodArgs?.("openDocument",t),Object.hasOwn(this.cacheReferences__,t)){if(!(this.cacheReferences__[t]instanceof h))throw o.accident("openDocument","document_wrong_type",t),new Error("document_wrong_type",{cause:t});return this.cacheReferences__[t]}if(!this.rootDb__.hasItem(t))throw o.accident("openDocument","document_not_found",t),new Error("document_not_found",{cause:t});let n=this.rootDb__.getItemData(t);if(n.type!=i.Document)throw o.accident("openDocument","document_wrong_type",t),new Error("document_wrong_type",{cause:t});let c=await this.readContext__(n),r=h.newRefFromContext(c,this.storeChanged_.bind(this));return this.cacheReferences__[t]=r,r}async openCollection(e){let t=a(e);if(o.logMethodArgs?.("openCollection",t),Object.hasOwn(this.cacheReferences__,t)){if(!(this.cacheReferences__[t]instanceof _))throw o.accident("openCollection","collection_wrong_type",t),new Error("collection_wrong_type",{cause:t});return this.cacheReferences__[t]}if(!this.rootDb__.hasItem(t))throw o.accident("openCollection","collection_not_found",t),new Error("collection_not_found",{cause:t});let n=this.rootDb__.getItemData(t);if(n.type!=i.Collection)throw o.accident("openCollection","collection_wrong_type",t),new Error("collection_not_found",{cause:t});let c=await this.readContext__(n),r=_.newRefFromContext(c,this.storeChanged_.bind(this));return this.cacheReferences__[t]=r,r}unloadStore(e){let t=a(e);o.logMethodArgs?.("unloadStore",t);let n=this.cacheReferences__[t];n!==void 0&&(n.hasUnprocessedChanges_===!0&&(n.updateDelayed_=!1,this.storeChanged_(n)),delete this.cacheReferences__[t])}async removeStore(e){let t=a(e);if(o.logMethodArgs?.("removeStore",t),!this.rootDb__.hasItem(t))throw o.accident("removeStore","document_not_found",t),new Error("document_not_found",{cause:t});let n=this.cacheReferences__[t];n!==void 0&&(n.freeze=!0,n.updateDelayed_=!1,n.hasUnprocessedChanges_=!1,delete this.cacheReferences__[t]);let c=d(this.rootDb__.getItemData(t));this.rootDb__.removeItem(t),await x(0);try{await b(l(this.config__.rootPath,c))}catch(r){o.error("removeStore","remove_file_failed",r,{id:e,path:c})}}async saveAll(){o.logMethod?.("saveAll");for(let e of Object.values(this.cacheReferences__))e.hasUnprocessedChanges_===!0&&e.freeze!==!0&&(e.updateDelayed_=!1,await this.storeChanged_(e))}async readContext__(e){typeof e!="string"&&(e=d(e)),o.logMethodArgs?.("readContext__",e),o.time?.(`readContext__time(${e})`);let t=await f(l(this.config__.rootPath,e));return o.timeEnd?.(`readContext__time(${e})`),t}writeContext__(e,t){return typeof e!="string"&&(e=d(e)),o.logMethodArgs?.("writeContext__",e),u(l(this.config__.rootPath,e),t)}async storeChanged_(e){o.logMethodArgs?.("storeChanged__",e.id);let t=e.getStoreMeta().rev;try{await this.writeContext__(e.path,e.getFullContext_()),t===e.getStoreMeta().rev&&(e.hasUnprocessedChanges_=!1)}catch(n){o.error("storeChanged__","write_context_failed",{id:e.id,error:n})}}loadRootDb__(){o.logMethod?.("loadRootDb__");let e=l(this.config__.rootPath,d(s.rootDbStat__));if(!S(e)){if(this.config__.errorWhenNotInitialized===!0)throw new Error("store_not_found",{cause:"Nitrobase not initialized"});return o.banner("Initialize new alwatr-nitrobase"),_.newRefFromData(s.rootDbStat__,null,this.storeChanged_.bind(this))}let t=f(e,!0);return _.newRefFromContext(t,this.storeChanged_.bind(this),"root-db")}exitHook__(){o.logMethod?.("exitHook__");for(let e of Object.values(this.cacheReferences__))o.logProperty?.(`StoreFile.${e.id}.hasUnprocessedChanges`,e.hasUnprocessedChanges_),e.hasUnprocessedChanges_===!0&&e.freeze!==!0&&(o.incident?.("exitHook__","rescue_unsaved_context",{id:e.id}),u(l(this.config__.rootPath,e.path),e.getFullContext_(),!0),e.hasUnprocessedChanges_=!1)}getStoreList(){return o.logMethod?.("getStoreList"),this.rootDb__.values()}};s.version="7.2.1",s.rootDbStat__={name:".nitrobase",region:D.Secret,type:i.Collection,extension:w.Json,changeDebounce:40};var g=s;export{g as AlwatrNitrobase};
|
|
3
3
|
//# sourceMappingURL=main.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/nitrobase-engine",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.1",
|
|
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
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"require": "./dist/main.cjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"license": "
|
|
30
|
+
"license": "AGPL-3.0-only",
|
|
31
31
|
"files": [
|
|
32
32
|
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
|
|
33
33
|
"!demo/**/*"
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"@alwatr/exit-hook": "^1.0.16",
|
|
64
64
|
"@alwatr/flat-string": "^1.0.23",
|
|
65
65
|
"@alwatr/logger": "^3.2.14",
|
|
66
|
-
"@alwatr/nitrobase-helper": "^7.2.
|
|
67
|
-
"@alwatr/nitrobase-reference": "^7.2.
|
|
68
|
-
"@alwatr/nitrobase-types": "^7.2.
|
|
66
|
+
"@alwatr/nitrobase-helper": "^7.2.1",
|
|
67
|
+
"@alwatr/nitrobase-reference": "^7.2.1",
|
|
68
|
+
"@alwatr/nitrobase-types": "^7.2.1",
|
|
69
69
|
"@alwatr/node-fs": "^1.0.13",
|
|
70
70
|
"@alwatr/wait": "^1.1.16"
|
|
71
71
|
},
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@alwatr/prettier-config": "^1.0.4",
|
|
75
75
|
"@alwatr/tsconfig-base": "^1.2.0",
|
|
76
76
|
"@alwatr/type-helper": "^1.2.6",
|
|
77
|
-
"@types/node": "^22.
|
|
77
|
+
"@types/node": "^22.7.4",
|
|
78
78
|
"typescript": "^5.6.2"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "519fd869ca85fe593f863b29cc945554f28dc870"
|
|
81
81
|
}
|