insite-db 2.0.0 → 2.0.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/bun.lockb +0 -0
- package/dist/Collections.d.ts +1 -1
- package/dist/Collections.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/Collections.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class InSiteCollections extends Map<string, InSiteCollection> {
|
|
|
7
7
|
ensure<Doc extends Document>(name: string, options: {
|
|
8
8
|
watch: false;
|
|
9
9
|
} & InSiteCollectionOptions): Promise<InSiteCollection<Doc>>;
|
|
10
|
-
ensure<Doc extends Document>(name: string, options
|
|
10
|
+
ensure<Doc extends Document>(name: string, options?: {
|
|
11
11
|
watch?: true;
|
|
12
12
|
} & InSiteCollectionOptions): Promise<InSiteWatchedCollection<Doc>>;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collections.d.ts","sourceRoot":"","sources":["../src/Collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsC,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EACX,gBAAgB,EAChB,uBAAuB,EACvB,QAAQ,EACR,uBAAuB,EACvB,MAAM,SAAS,CAAC;AAqBjB,qBAAa,iBAAkB,SAAQ,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;gBACvD,EAAE,EAAE,QAAQ;IAOxB,EAAE,EAAE,QAAQ,CAAC;IAEb,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,CAAC;IAEpC,MAAM,CAAC,GAAG,SAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/H,MAAM,CAAC,GAAG,SAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Collections.d.ts","sourceRoot":"","sources":["../src/Collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsC,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EACX,gBAAgB,EAChB,uBAAuB,EACvB,QAAQ,EACR,uBAAuB,EACvB,MAAM,SAAS,CAAC;AAqBjB,qBAAa,iBAAkB,SAAQ,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;gBACvD,EAAE,EAAE,QAAQ;IAOxB,EAAE,EAAE,QAAQ,CAAC;IAEb,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,CAAC;IAEpC,MAAM,CAAC,GAAG,SAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/H,MAAM,CAAC,GAAG,SAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;CAyC7I"}
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/connect.ts", "../src/Collections.ts", "../src/extensions/Collection.ts", "../src/utils.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { MongoClient } from \"mongodb\";\nimport { InSiteCollections } from \"./Collections\";\nimport type { InSiteDB, Options } from \"./types\";\n\n\nexport async function connect({ url, name, ...mongoClientOptions }: Options) {\n\t\n\tif (/localhost/.test(url))\n\t\turl = url.replace(/localhost/, \"127.0.0.1\");\n\t\n\tconst client = new MongoClient(url, {\n\t\tmaxPoolSize: 100,\n\t\t...mongoClientOptions\n\t});\n\t\n\ttry {\n\t\tawait client.connect();\n\t\tconsole.info(\"\uD83C\uDF3F Mongo Client connected to\", url.replace(/(?<=\\/\\/)[^:]+?:[^@]+@/, \"\").replace(/[/?][^/]*$/, \"\"));\n\t} catch (error) {\n\t\tconsole.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo Client connection: \", error);\n\t}\n\t\n\tclient\n\t\t.on(\"close\", () => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB socket closed\"))\n\t\t.on(\"error\", error => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB:\", error))\n\t\t.on(\"parseError\", error => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB parse:\", error))\n\t\t.on(\"reconnect\", () => console.info(\"\uD83C\uDF3F Mongo DB reconnected\"))\n\t\t.on(\"timeout\", () => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB timeout\"));\n\t\n\tconst db = client.db(name) as InSiteDB;\n\t\n\tconst collections = new InSiteCollections(db);\n\t\n\treturn {\n\t\tclient,\n\t\tdb,\n\t\tcollections\n\t};\n}\n", "import type { ChangeStream, ChangeStreamDocument, Document } from \"mongodb\";\nimport type {\n\tInSiteCollection,\n\tInSiteCollectionOptions,\n\tInSiteDB,\n\tInSiteWatchedCollection\n} from \"./types\";\n\n\n/** @this ChangeStream */\nfunction handleChangeStreamChange(this: ChangeStream, next: ChangeStreamDocument) {\n\t\n\tif (process.env.NODE_ENV === \"development\")\n\t\tconsole.log(\"Change stream change\", (this.parent as InSiteWatchedCollection).collectionName, next);\n\t\n\tfor (const listener of (this.parent as InSiteWatchedCollection).changeListeners!)\n\t\tlistener(next);\n\t\n}\n\n/** @this ChangeStream */\nfunction handleChangeStreamError(this: ChangeStream, error: Error) {\n\tconsole.error(`\uD83C\uDF3F\u2757\uFE0F Mongo ${(this.parent as InSiteWatchedCollection).collectionName} Change Stream:\\n`, error.stack);\n\t\n}\n\n\nexport class InSiteCollections extends Map<string, InSiteCollection> {\n\tconstructor(db: InSiteDB) {\n\t\tsuper();\n\t\t\n\t\tthis.db = db;\n\t\t\n\t}\n\t\n\tdb: InSiteDB;\n\t\n\t[key: string]: InSiteCollection | unknown;\n\t\n\tasync ensure<Doc extends Document>(name: string, options: { watch: false } & InSiteCollectionOptions): Promise<InSiteCollection<Doc>>;\n\tasync ensure<Doc extends Document>(name: string, options
|
|
4
|
+
"sourcesContent": ["import { MongoClient } from \"mongodb\";\nimport { InSiteCollections } from \"./Collections\";\nimport type { InSiteDB, Options } from \"./types\";\n\n\nexport async function connect({ url, name, ...mongoClientOptions }: Options) {\n\t\n\tif (/localhost/.test(url))\n\t\turl = url.replace(/localhost/, \"127.0.0.1\");\n\t\n\tconst client = new MongoClient(url, {\n\t\tmaxPoolSize: 100,\n\t\t...mongoClientOptions\n\t});\n\t\n\ttry {\n\t\tawait client.connect();\n\t\tconsole.info(\"\uD83C\uDF3F Mongo Client connected to\", url.replace(/(?<=\\/\\/)[^:]+?:[^@]+@/, \"\").replace(/[/?][^/]*$/, \"\"));\n\t} catch (error) {\n\t\tconsole.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo Client connection: \", error);\n\t}\n\t\n\tclient\n\t\t.on(\"close\", () => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB socket closed\"))\n\t\t.on(\"error\", error => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB:\", error))\n\t\t.on(\"parseError\", error => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB parse:\", error))\n\t\t.on(\"reconnect\", () => console.info(\"\uD83C\uDF3F Mongo DB reconnected\"))\n\t\t.on(\"timeout\", () => console.error(\"\uD83C\uDF3F\u2757\uFE0F Mongo DB timeout\"));\n\t\n\tconst db = client.db(name) as InSiteDB;\n\t\n\tconst collections = new InSiteCollections(db);\n\t\n\treturn {\n\t\tclient,\n\t\tdb,\n\t\tcollections\n\t};\n}\n", "import type { ChangeStream, ChangeStreamDocument, Document } from \"mongodb\";\nimport type {\n\tInSiteCollection,\n\tInSiteCollectionOptions,\n\tInSiteDB,\n\tInSiteWatchedCollection\n} from \"./types\";\n\n\n/** @this ChangeStream */\nfunction handleChangeStreamChange(this: ChangeStream, next: ChangeStreamDocument) {\n\t\n\tif (process.env.NODE_ENV === \"development\")\n\t\tconsole.log(\"Change stream change\", (this.parent as InSiteWatchedCollection).collectionName, next);\n\t\n\tfor (const listener of (this.parent as InSiteWatchedCollection).changeListeners!)\n\t\tlistener(next);\n\t\n}\n\n/** @this ChangeStream */\nfunction handleChangeStreamError(this: ChangeStream, error: Error) {\n\tconsole.error(`\uD83C\uDF3F\u2757\uFE0F Mongo ${(this.parent as InSiteWatchedCollection).collectionName} Change Stream:\\n`, error.stack);\n\t\n}\n\n\nexport class InSiteCollections extends Map<string, InSiteCollection> {\n\tconstructor(db: InSiteDB) {\n\t\tsuper();\n\t\t\n\t\tthis.db = db;\n\t\t\n\t}\n\t\n\tdb: InSiteDB;\n\t\n\t[key: string]: InSiteCollection | unknown;\n\t\n\tasync ensure<Doc extends Document>(name: string, options: { watch: false } & InSiteCollectionOptions): Promise<InSiteCollection<Doc>>;\n\tasync ensure<Doc extends Document>(name: string, options?: { watch?: true } & InSiteCollectionOptions): Promise<InSiteWatchedCollection<Doc>>;\n\tasync ensure(name: string, options: InSiteCollectionOptions = {}) {\n\t\t\n\t\tconst { db } = this;\n\t\t\n\t\tlet collection = this.get(name);\n\t\t\n\t\tif (!collection) {\n\t\t\tif ((await db.listCollections({ name }, { nameOnly: true }).toArray()).length)\n\t\t\t\tcollection = db.collection(name);\n\t\t\telse {\n\t\t\t\tcollection = await db.createCollection(name, {\n\t\t\t\t\t...options.jsonSchema && { validator: { $jsonSchema: options.jsonSchema } },\n\t\t\t\t\t...options.blockCompressor && { storageEngine: { wiredTiger: { configString: `block_compressor=${options.blockCompressor}` } } }\n\t\t\t\t});\n\t\t\t\tdelete options.jsonSchema;\n\t\t\t\tdelete options.blockCompressor;\n\t\t\t}\n\t\t\t\n\t\t\tthis.set(name, collection);\n\t\t\tthis[name] = collection;\n\t\t\t\n\t\t\tif (options.watch !== false) {\n\t\t\t\tcollection.changeListeners = new Set();\n\t\t\t\t\n\t\t\t\tcollection.changeStream =\n\t\t\t\t\tcollection.watch(undefined, { fullDocument: options.fullDocument === false ? undefined : \"updateLookup\" })\n\t\t\t\t\t\t.on(\"change\", handleChangeStreamChange)\n\t\t\t\t\t\t.on(\"error\", handleChangeStreamError);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (options.jsonSchema)\n\t\t\tawait db.command({\n\t\t\t\tcollMod: name,\n\t\t\t\t...options.jsonSchema && { validator: { $jsonSchema: options.jsonSchema } }\n\t\t\t});\n\t\t\n\t\treturn collection;\n\t}\n\t\n}\n", "import { type ChangeStreamDocument, Collection } from \"mongodb\";\nimport { InSiteCollectionIndexes } from \"../types\";\n\n\ndeclare module \"mongodb\" {\n\texport interface Collection<TSchema> { // eslint-disable-line no-shadow\n\t\tchangeListeners?: Set<(listener: ChangeStreamDocument<TSchema>) => void>;\n\t\tchangeStream?: ChangeStream<TSchema>;\n\t\tensureIndexes(indexesToEnsure: InSiteCollectionIndexes): Promise<void>;\n\t}\n}\n\n\nCollection.prototype.ensureIndexes = async function (indexesToEnsure) {\n\t\n\t// const existingIndexes = await this.indexes();\n\t\n\t// TODO:\n\t\n\ttry {\n\t\tfor (const indexToEnsure of indexesToEnsure)\n\t\t\tawait this.createIndex(...indexToEnsure);\n\t} catch {}\n\t\n};\n", "import { ObjectId } from \"mongodb\";\n\n\nexport function newObjectIdString() {\n\treturn (new ObjectId()).toString();\n}\n", "export type { InSiteCollections } from \"./Collections\";\nexport * from \"./connect\";\nexport * from \"./extensions\";\nexport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,EAAG,SAAS,CAClC,CCAA,WAAc",
|
|
6
6
|
"names": ["MongoClient", "handleChangeStreamChange", "next", "listener", "handleChangeStreamError", "error", "InSiteCollections", "db", "name", "options", "collection", "connect", "url", "name", "mongoClientOptions", "client", "MongoClient", "error", "db", "collections", "InSiteCollections", "Collection", "indexesToEnsure", "indexToEnsure", "ObjectId", "newObjectIdString"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-db",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.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.1.
|
|
8
|
+
"packageManager": "bun@1.1.22",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
11
|
"build": "bun .conveyer.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"mongodb": "^6.8.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@nesvet/conveyer": "^2.2.
|
|
29
|
+
"@nesvet/conveyer": "^2.2.4",
|
|
30
30
|
"@nesvet/eslint-config": "^2.0.24",
|
|
31
31
|
"@types/json-schema": "^7.0.15",
|
|
32
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^22.1.0",
|
|
33
33
|
"typescript": "^5.5.4"
|
|
34
34
|
}
|
|
35
35
|
}
|