insite-db 2.2.1 → 2.2.2
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/index.js +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{MongoClient as B}from"mongodb";function p(e=1,t=4){let r=" ".repeat(t),o={};Error.captureStackTrace(o,p);let n=o.stack.replace(/^Error\W+/m,"").replaceAll(/^\s+/gm,"").split(`
|
|
2
2
|
`).slice(e).join(`
|
|
3
|
-
${r}`);return`${r}${n}`}function m(){}function M(e,t=0,r={}){let{leading:o=!1,trailing:n=!0}=r,{maxWait:s=1/0}=r,i,c,x,C,w,d,
|
|
3
|
+
${r}`);return`${r}${n}`}function m(){}function M(e,t=0,r={}){let{leading:o=!1,trailing:n=!0}=r,{maxWait:s=1/0}=r,i,c,x,C,w,d,f,y,$=async()=>{let u=Date.now();u>=x?(i=void 0,x=void 0,clearTimeout(c),typeof f=="function"&&await f(),l.resolve(y),l.promise.isResolved=!0,d=o):(clearTimeout(i),i=setTimeout($,x-u))},S=Number.isFinite(s)?()=>{f===a&&(f=!1),a(),c=setTimeout(S,s)}:null;async function a(){return y=await e.apply(C,w)}o&&typeof o=="boolean"&&(o=a),d=o,n&&typeof n=="boolean"&&(n=a),f=n;let l=Object.assign(function(...u){return w=u,C=this,x=Date.now()+t,f=n,l.promise.isResolved&&(l.promise=Object.assign(new Promise(k=>{l.resolve=k,typeof d=="function"&&(d(),d=!1,f===a&&(f=!1)),i||(i=setTimeout($,t),S&&(c=setTimeout(S,s)))}),{isResolved:!1})),l.promise},{callback:e,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:m,run:a,clear:async u=>{clearTimeout(i),i=void 0,clearTimeout(c),l.promise.isResolved=!0,l.resolve(u?await a():y)}});return l}M.noop=Object.assign(()=>{},{callback:m,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:m,run:m,clear:m});function v(e,t,r,o,n=!0){return Array.isArray(e)&&(e=e.length),typeof o!="string"&&(n=o??!0,o=r),(n?`${e}\xA0`:"")+v.raw(e,t,r,o)}v.raw=(e,t,r,o=r)=>{e=Math.abs(e);let n=e%10,s=e%100;return n===1&&s!==11?t:n>=2&&n<=4&&!(s>=12&&s<=15)?r:o};function O(e,t){let r={...e};for(let o of t)delete r[o];return r}import{ObjectId as j}from"mongodb";function Co(){return new j().toString()}function T(e){let t=[];switch(e.operationType){case"insert":case"replace":t.push("fullDocument:",e.fullDocument);break;case"update":t.push("_id:",e.documentKey._id,`
|
|
4
4
|
`,"updateDescription:",e.updateDescription);break;case"delete":t.push("_id:",e.documentKey._id);break;default:t.push(e)}console.info("\u{1F33F}\u{1F38F}",`\x1B[1m${this.parent.collectionName}\x1B[0m`,`\x1B[3m${e.operationType}\x1B[0m`,...t)}function b(e){console.error(`\u{1F33F}\u2757\uFE0F MongoDB ${this.parent.collectionName} Change Stream:
|
|
5
5
|
`,e.stack)}var g=class extends Map{constructor(t){super(),this.db=t}db;#e=new Map;#t=new Map;#o=new Map;async ensure(t,r={}){let{db:o}=this,n=this.get(t)??await this.#e.get(t);if(!n){let{promise:s,resolve:i}=Promise.withResolvers();if(this.#e.set(t,s),(await o.listCollections({name:t},{nameOnly:!0}).toArray()).length?n=o.collection(t):(n=await o.createCollection(t,{...r.schema&&{validator:{$jsonSchema:r.schema}},...r.blockCompressor&&{storageEngine:{wiredTiger:{configString:`block_compressor=${r.blockCompressor}`}}}}),delete r.schema,delete r.blockCompressor),r.watch!==!1){let c=n.watch(void 0,{fullDocument:r.fullDocument===!1?void 0:"updateLookup"});(process.env.NODE_ENV==="development"?r.quiet!==!0:!r.quiet)&&c.on("change",T),c.on("error",b),n.changeStream=c}this.set(t,n),this[t]=n,i(n),this.#e.delete(t)}return r.schema&&(this.#t.has(t)?console.warn(`\u{1F33F}\u26A0\uFE0F Attempt to set schema for the \x1B[1m${t}\x1B[22m collection at
|
|
6
6
|
${p()}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-db",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "MongoDB for inSite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
|
-
"packageManager": "bun@1.2.
|
|
8
|
+
"packageManager": "bun@1.2.7",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
11
|
"build": "bun .conveyer.js",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nesvet/n": "^1.1.
|
|
27
|
-
"mongodb": "^6.
|
|
26
|
+
"@nesvet/n": "^1.1.28",
|
|
27
|
+
"mongodb": "^6.15.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@nesvet/conveyer": "^2.5.
|
|
31
|
-
"@nesvet/eslint-config": "^2.0.
|
|
30
|
+
"@nesvet/conveyer": "^2.5.1",
|
|
31
|
+
"@nesvet/eslint-config": "^2.0.51",
|
|
32
32
|
"@types/json-schema": "^7.0.15",
|
|
33
|
-
"@types/node": "^22.13.
|
|
33
|
+
"@types/node": "^22.13.14",
|
|
34
34
|
"typescript": "^5.8.2"
|
|
35
35
|
}
|
|
36
36
|
}
|