From fce5636cc54a05acb728625234169b8e74bf5292 Mon Sep 17 00:00:00 2001 From: Jersey Date: Wed, 15 May 2024 21:55:19 -0400 Subject: [PATCH 1/4] cleanup JSR score by automating publishing, adding docs, and fixing imports --- .github/FUNDING.yml | 13 +-------- .github/workflows/ci.yml | 2 +- .github/workflows/jsr.yml | 36 +++++++++++++++++++++++ deps.ts | 12 ++++---- mod.ts | 39 ++++++++++++++++++++++--- src/auth/base.ts | 4 +-- src/auth/scram.ts | 6 ++-- src/auth/x509.ts | 6 ++-- src/client.ts | 2 +- src/cluster.ts | 2 +- src/collection/collection.ts | 4 +-- src/collection/commands/aggregate.ts | 4 +-- src/collection/commands/find.ts | 4 +-- src/collection/commands/list_indexes.ts | 2 +- src/collection/commands/update.ts | 8 ++--- src/database.ts | 6 ++-- src/gridfs/bucket.ts | 10 +++---- src/gridfs/indexes.ts | 6 ++-- src/gridfs/upload.ts | 6 ++-- src/protocol/cursor.ts | 4 +-- src/protocol/handshake.ts | 4 +-- src/protocol/message.ts | 4 +-- src/protocol/protocol.ts | 6 ++-- src/types.ts | 6 ++-- src/types/geospatial.ts | 4 +-- src/types/gridfs.ts | 6 ++-- src/utils/saslprep/mod.ts | 2 +- src/utils/saslprep/sparse_bitfield.ts | 2 +- src/utils/srv.ts | 2 +- src/utils/uri.ts | 2 +- tests/cases/01_auth.ts | 2 +- tests/cases/03_crud.ts | 4 +-- tests/cases/04_indexes.ts | 2 +- tests/cases/06_gridfs.ts | 2 +- tests/cases/08_find_cursor.ts | 2 +- tests/cases/09_geospatial_types.ts | 8 ++--- tests/common.ts | 2 +- 37 files changed, 146 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/jsr.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index eee68b70..715cb74b 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,14 +1,3 @@ - -# These are supported funding model platforms - github: [erfanium] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username custom: - - https://github.com/denodrivers/deno_mongo/discussions/358 \ No newline at end of file + - https://github.com/denodrivers/deno_mongo/discussions/358 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcc8e2d8..d29829ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: # Lint & Format - name: Lint & Format TS run: | - deno lint --ignore=./bson/bson.d.ts + deno lint deno fmt --check # Start MongoDB diff --git a/.github/workflows/jsr.yml b/.github/workflows/jsr.yml new file mode 100644 index 00000000..6e91d513 --- /dev/null +++ b/.github/workflows/jsr.yml @@ -0,0 +1,36 @@ +name: jsr + +on: + release: + types: [published] + +jobs: + publish: + name: ubuntu-latest + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: read + id-token: write + + steps: + - name: Setup Environment + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Clone repository + uses: actions/checkout@v2 + + - name: Install Deno + uses: denolib/setup-deno@master + with: + deno-version: 1.x.x + + - name: Log versions + run: | + deno --version + + - name: Publish to JSR + run: | + deno publish \ No newline at end of file diff --git a/deps.ts b/deps.ts index ba33cc6a..8fbe5019 100644 --- a/deps.ts +++ b/deps.ts @@ -1,21 +1,21 @@ export { - Binary, BSONRegExp, BSONSymbol, + Binary, Code, DBRef, Decimal128, - deserialize, Double, Int32, Long, MaxKey, MinKey, ObjectId, - serialize, Timestamp, UUID, + deserialize, + serialize } from "jsr:@lucsoft/web-bson@^0.3.1"; -export { crypto as stdCrypto } from "jsr:@std/crypto@^0.220.1/crypto"; -export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.220.1/base64"; -export { encodeHex } from "jsr:@std/encoding@^0.220.1/hex"; +export { crypto as stdCrypto } from "jsr:@std/crypto@^0.224.0/crypto"; +export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.224.0/base64"; +export { encodeHex } from "jsr:@std/encoding@^0.224.0/hex"; diff --git a/mod.ts b/mod.ts index 3bf7a1aa..96090c10 100644 --- a/mod.ts +++ b/mod.ts @@ -1,8 +1,38 @@ +/** + * @module + * + * # deno_mongo + * + * **deno_mongo** is a **MongoDB** driver for Deno which also supports Deno Deploy. + * + * ## ATTENTION + * + * Deno has support for npm modules now, so you can also use `npm:mongodb`. + * See [this](https://github.com/denodrivers/mongo/issues/380) for more details. + * + * ## Usage + * + * Replace `version` with the latest version of the driver. + * + * ```ts + * import { MongoClient } from 'jsr:@db/mongo@version'; + * ``` + * + * See [the README](https://github.com/denodrivers/mongo) for more examples. + * + * ## Other community resources and examples + * + * - [atlas_sdk](https://deno.land/x/atlas_sdk) - TypeSafe MongoDB Atlas SDK + * - [dangoDB](https://github.com/oslabs-beta/dangoDB) - MongoDB ORM for Deno + * - [deno-deploy-mongo](https://github.com/erfanium/deno-deploy-mongo) - A simple app with Deno, MongoDB, and Oak using MongoDB Atlas + * - [deno_rest](https://github.com/vicky-gonsalves/deno_rest) - An Oak-based template for RESTful APIs using this driver + * - [denomongo-unittest-utils](https://github.com/Gang-of-Fork/denomongo-unittest-utils) - Mock collection for unit tests + * + */ + export { - Binary, BSONRegExp, - BSONSymbol, - Code, + BSONSymbol, Binary, Code, DBRef, Decimal128, Double, @@ -12,10 +42,11 @@ export { MinKey, ObjectId, Timestamp, - UUID, + UUID } from "./deps.ts"; export { MongoClient } from "./src/client.ts"; export { Collection } from "./src/collection/mod.ts"; export { Database } from "./src/database.ts"; export { GridFSBucket } from "./src/gridfs/bucket.ts"; export * from "./src/types.ts"; + diff --git a/src/auth/base.ts b/src/auth/base.ts index 2a8117e1..8d79c347 100644 --- a/src/auth/base.ts +++ b/src/auth/base.ts @@ -1,5 +1,5 @@ -import { WireProtocol } from "../protocol/mod.ts"; -import { ConnectOptions, Credential, Document } from "../types.ts"; +import type { WireProtocol } from "../protocol/mod.ts"; +import type { ConnectOptions, Credential, Document } from "../types.ts"; export abstract class AuthPlugin { abstract auth(authContext: AuthContext): Document; diff --git a/src/auth/scram.ts b/src/auth/scram.ts index 09383c1a..f199ed6a 100644 --- a/src/auth/scram.ts +++ b/src/auth/scram.ts @@ -6,11 +6,11 @@ import { stdCrypto, } from "../../deps.ts"; import { MongoDriverError } from "../error.ts"; -import { HandshakeDocument } from "../protocol/handshake.ts"; +import type { HandshakeDocument } from "../protocol/handshake.ts"; import { driverMetadata } from "../protocol/mod.ts"; -import { Credential, Document } from "../types.ts"; +import type { Credential, Document } from "../types.ts"; import { saslprep } from "../utils/saslprep/mod.ts"; -import { AuthContext, AuthPlugin } from "./base.ts"; +import { AuthPlugin, type AuthContext } from "./base.ts"; import { pbkdf2 } from "./pbkdf2.ts"; type CryptoMethod = "sha1" | "sha256"; diff --git a/src/auth/x509.ts b/src/auth/x509.ts index 4a23666f..92ee3abd 100644 --- a/src/auth/x509.ts +++ b/src/auth/x509.ts @@ -1,7 +1,7 @@ -import { HandshakeDocument } from "../protocol/handshake.ts"; +import type { HandshakeDocument } from "../protocol/handshake.ts"; import { driverMetadata } from "../protocol/mod.ts"; -import { Credential, Document } from "../types.ts"; -import { AuthContext, AuthPlugin } from "./base.ts"; +import type { Credential, Document } from "../types.ts"; +import { AuthPlugin, type AuthContext } from "./base.ts"; export interface X509Command extends Document { authenticate: number; diff --git a/src/client.ts b/src/client.ts index 3ba94bb2..70905007 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,7 +1,7 @@ import { Cluster } from "./cluster.ts"; import { Database } from "./database.ts"; import { MongoDriverError } from "./error.ts"; -import { +import type { BuildInfo, ConnectOptions, Document, diff --git a/src/cluster.ts b/src/cluster.ts index 29996a01..49b9f545 100644 --- a/src/cluster.ts +++ b/src/cluster.ts @@ -1,7 +1,7 @@ import { AuthContext, ScramAuthPlugin, X509AuthPlugin } from "./auth/mod.ts"; import { MongoDriverError } from "./error.ts"; import { WireProtocol } from "./protocol/mod.ts"; -import { ConnectOptions, Server } from "./types.ts"; +import type { ConnectOptions, Server } from "./types.ts"; export class Cluster { #options: ConnectOptions; diff --git a/src/collection/collection.ts b/src/collection/collection.ts index 25c3e1d9..9770e59d 100644 --- a/src/collection/collection.ts +++ b/src/collection/collection.ts @@ -4,8 +4,8 @@ import { MongoInvalidArgumentError, MongoServerError, } from "../error.ts"; -import { WireProtocol } from "../protocol/mod.ts"; -import { +import type { WireProtocol } from "../protocol/mod.ts"; +import type { AggregateOptions, AggregatePipeline, CountOptions, diff --git a/src/collection/commands/aggregate.ts b/src/collection/commands/aggregate.ts index 9e5325cf..a50dfa43 100644 --- a/src/collection/commands/aggregate.ts +++ b/src/collection/commands/aggregate.ts @@ -1,6 +1,6 @@ import { CommandCursor } from "../../protocol/cursor.ts"; -import { WireProtocol } from "../../protocol/protocol.ts"; -import { AggregateOptions, Document } from "../../types.ts"; +import type { WireProtocol } from "../../protocol/protocol.ts"; +import type { AggregateOptions, Document } from "../../types.ts"; interface AggregateCursorContext { dbName: string; diff --git a/src/collection/commands/find.ts b/src/collection/commands/find.ts index c9df5bb2..ea2fac47 100644 --- a/src/collection/commands/find.ts +++ b/src/collection/commands/find.ts @@ -1,5 +1,5 @@ -import { CommandCursor, WireProtocol } from "../../protocol/mod.ts"; -import { Document, FindOptions } from "../../types.ts"; +import { CommandCursor, type WireProtocol } from "../../protocol/mod.ts"; +import type { Document, FindOptions } from "../../types.ts"; interface FindCursorContext { dbName: string; diff --git a/src/collection/commands/list_indexes.ts b/src/collection/commands/list_indexes.ts index 38253392..17c244b0 100644 --- a/src/collection/commands/list_indexes.ts +++ b/src/collection/commands/list_indexes.ts @@ -1,4 +1,4 @@ -import { CommandCursor, WireProtocol } from "../../protocol/mod.ts"; +import { CommandCursor, type WireProtocol } from "../../protocol/mod.ts"; interface ListIndexesCursorContext { dbName: string; diff --git a/src/collection/commands/update.ts b/src/collection/commands/update.ts index 0b09a283..12e5f996 100644 --- a/src/collection/commands/update.ts +++ b/src/collection/commands/update.ts @@ -1,7 +1,7 @@ -import { ObjectId } from "../../../deps.ts"; -import { WireProtocol } from "../../protocol/mod.ts"; -import { Document, UpdateOptions } from "../../types.ts"; - +import type { ObjectId } from "../../../deps.ts"; +import type { WireProtocol } from "../../protocol/mod.ts"; +import type { Document, UpdateOptions } from "../../types.ts"; + interface UpdateResponse { ok: number; nModified: number; diff --git a/src/database.ts b/src/database.ts index 941533db..8081ef2c 100644 --- a/src/database.ts +++ b/src/database.ts @@ -1,12 +1,12 @@ -import { Cluster } from "./cluster.ts"; +import type { Cluster } from "./cluster.ts"; import { Collection } from "./collection/mod.ts"; import { CommandCursor } from "./protocol/mod.ts"; -import { +import type { CreateCollectionOptions, CreateUserOptions, Document, } from "./types.ts"; -import { WriteConcern } from "./types/read_write_concern.ts"; +import type { WriteConcern } from "./types/read_write_concern.ts"; interface ListCollectionsReponse { cursor: { diff --git a/src/gridfs/bucket.ts b/src/gridfs/bucket.ts index e8d8f30e..0cd6dce9 100644 --- a/src/gridfs/bucket.ts +++ b/src/gridfs/bucket.ts @@ -1,10 +1,10 @@ import { ObjectId } from "../../deps.ts"; -import { Collection } from "../collection/collection.ts"; -import { FindCursor } from "../collection/commands/find.ts"; -import { Database } from "../database.ts"; +import type { Collection } from "../collection/collection.ts"; +import type { FindCursor } from "../collection/commands/find.ts"; +import type { Database } from "../database.ts"; import { MongoRuntimeError } from "../error.ts"; -import { Filter } from "../types.ts"; -import { +import type { Filter } from "../types.ts"; +import type { Chunk, File, FileId, diff --git a/src/gridfs/indexes.ts b/src/gridfs/indexes.ts index a93b3761..2638d3a8 100644 --- a/src/gridfs/indexes.ts +++ b/src/gridfs/indexes.ts @@ -1,6 +1,6 @@ -import { Collection } from "../collection/collection.ts"; -import { Document, IndexOptions } from "../types.ts"; -import { Chunk, File } from "../types/gridfs.ts"; +import type { Collection } from "../collection/collection.ts"; +import type { Document, IndexOptions } from "../types.ts"; +import type { Chunk, File } from "../types/gridfs.ts"; async function ensureIndex( index: IndexOptions, diff --git a/src/gridfs/upload.ts b/src/gridfs/upload.ts index 708b0489..a0600e99 100644 --- a/src/gridfs/upload.ts +++ b/src/gridfs/upload.ts @@ -1,6 +1,6 @@ -import { Binary, ObjectId } from "../../deps.ts"; -import { Collection } from "../collection/mod.ts"; -import { Chunk, File, GridFSUploadOptions } from "../types/gridfs.ts"; +import { Binary, type ObjectId } from "../../deps.ts"; +import type { Collection } from "../collection/mod.ts"; +import type { Chunk, File, GridFSUploadOptions } from "../types/gridfs.ts"; export interface BucketInfo { filesCollection: Collection; diff --git a/src/protocol/cursor.ts b/src/protocol/cursor.ts index 301f9ffc..416cbd44 100644 --- a/src/protocol/cursor.ts +++ b/src/protocol/cursor.ts @@ -1,7 +1,7 @@ import { Long } from "../../deps.ts"; -import { Document } from "../types.ts"; +import type { Document } from "../types.ts"; import { parseNamespace } from "../utils/ns.ts"; -import { WireProtocol } from "./protocol.ts"; +import type { WireProtocol } from "./protocol.ts"; export interface CommandCursorOptions { id: bigint | number | string; diff --git a/src/protocol/handshake.ts b/src/protocol/handshake.ts index 38c13f88..4120e014 100644 --- a/src/protocol/handshake.ts +++ b/src/protocol/handshake.ts @@ -1,5 +1,5 @@ -import { Document } from "../types.ts"; -import { WireProtocol } from "./protocol.ts"; +import type { Document } from "../types.ts"; +import type { WireProtocol } from "./protocol.ts"; export const driverMetadata = { driver: { diff --git a/src/protocol/message.ts b/src/protocol/message.ts index 296ec531..bcd994ab 100644 --- a/src/protocol/message.ts +++ b/src/protocol/message.ts @@ -1,6 +1,6 @@ import { deserialize, serialize } from "../../deps.ts"; -import { Document } from "../types.ts"; -import { MessageHeader, OpCode, setHeader } from "./header.ts"; +import type { Document } from "../types.ts"; +import { OpCode, setHeader, type MessageHeader } from "./header.ts"; type MessageFlags = number; diff --git a/src/protocol/protocol.ts b/src/protocol/protocol.ts index e83ca426..d60fa51c 100644 --- a/src/protocol/protocol.ts +++ b/src/protocol/protocol.ts @@ -1,12 +1,12 @@ import { MongoDriverError, - MongoErrorInfo, MongoServerError, + type MongoErrorInfo, } from "../error.ts"; -import { Document } from "../types.ts"; +import type { Document } from "../types.ts"; import { handshake } from "./handshake.ts"; import { parseHeader } from "./header.ts"; -import { deserializeMessage, Message, serializeMessage } from "./message.ts"; +import { deserializeMessage, serializeMessage, type Message } from "./message.ts"; interface CommandTask { requestId: number; diff --git a/src/types.ts b/src/types.ts index ebc0413c..a54c3a46 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { +import type { Binary, BSONRegExp, Decimal128, @@ -8,14 +8,14 @@ import { ObjectId, Timestamp, } from "../deps.ts"; -import { +import type { $geoAny, $geoMultiPolygon, $geoPolygon, CenterSpecifier, ShapeOperator, } from "./types/geospatial.ts"; -import { WriteConcern } from "./types/read_write_concern.ts"; +import type { WriteConcern } from "./types/read_write_concern.ts"; /** * The types used by the MongoDB driver. diff --git a/src/types/geospatial.ts b/src/types/geospatial.ts index baf4e2ab..6a1c578b 100644 --- a/src/types/geospatial.ts +++ b/src/types/geospatial.ts @@ -1,5 +1,5 @@ -import { Document } from "../types.ts"; -import { +import type { Document } from "../types.ts"; +import type { GeoJsonObject, GeometryCollection, GeometryObject, diff --git a/src/types/gridfs.ts b/src/types/gridfs.ts index 17b72d3c..b3982601 100644 --- a/src/types/gridfs.ts +++ b/src/types/gridfs.ts @@ -1,6 +1,6 @@ -import { Binary, ObjectId } from "../../deps.ts"; -import { Document, ReadPreference } from "../types.ts"; -import { ReadConcern, WriteConcern } from "../types/read_write_concern.ts"; +import type { Binary, ObjectId } from "../../deps.ts"; +import type { Document, ReadPreference } from "../types.ts"; +import type { ReadConcern, WriteConcern } from "../types/read_write_concern.ts"; export type FileId = ObjectId; diff --git a/src/utils/saslprep/mod.ts b/src/utils/saslprep/mod.ts index 7489f458..d3deecb2 100644 --- a/src/utils/saslprep/mod.ts +++ b/src/utils/saslprep/mod.ts @@ -3,7 +3,7 @@ //ORIGINAL PROJECT AND LICENSE IN: https://github.com/chiefbiiko/sparse-bitfield //ORIGINAL PROJECT AND LICENSE IN: https://github.com/chiefbiiko/memory-pager import { loadCodePoints } from "./load_code_points.ts"; -import { Bitfield } from "./sparse_bitfield.ts"; +import type { Bitfield } from "./sparse_bitfield.ts"; const { unassigned_code_points, diff --git a/src/utils/saslprep/sparse_bitfield.ts b/src/utils/saslprep/sparse_bitfield.ts index d4787b6e..0f5d6a05 100644 --- a/src/utils/saslprep/sparse_bitfield.ts +++ b/src/utils/saslprep/sparse_bitfield.ts @@ -1,4 +1,4 @@ -import { Page, Pager } from "./memory_pager.ts"; +import { Pager, type Page } from "./memory_pager.ts"; /** Is the given number a power of two? */ function powerOfTwo(x: number): boolean { diff --git a/src/utils/srv.ts b/src/utils/srv.ts index b97fd70f..6b6f54fc 100644 --- a/src/utils/srv.ts +++ b/src/utils/srv.ts @@ -1,4 +1,4 @@ -import { ConnectOptions } from "../types.ts"; +import type { ConnectOptions } from "../types.ts"; import { parseSrvUrl } from "./uri.ts"; enum AllowedOption { diff --git a/src/utils/uri.ts b/src/utils/uri.ts index 1907acdc..2dbf556e 100644 --- a/src/utils/uri.ts +++ b/src/utils/uri.ts @@ -1,5 +1,5 @@ // mongodb://username:password@example.com:27017,example2.com:27017,...,example.comN:27017/database?key=value&keyN=valueN -import { ConnectOptions, Credential, Server } from "../types.ts"; +import type { ConnectOptions, Credential, Server } from "../types.ts"; import { Srv } from "./srv.ts"; interface Parts { diff --git a/tests/cases/01_auth.ts b/tests/cases/01_auth.ts index 74d2a7ae..12fb4e3b 100644 --- a/tests/cases/01_auth.ts +++ b/tests/cases/01_auth.ts @@ -1,4 +1,4 @@ -import { Database } from "../../mod.ts"; +import type { Database } from "../../mod.ts"; import { cleanUsername, clientFirstMessageBare, diff --git a/tests/cases/03_crud.ts b/tests/cases/03_crud.ts index ff20b5af..7beb539a 100644 --- a/tests/cases/03_crud.ts +++ b/tests/cases/03_crud.ts @@ -1,9 +1,9 @@ -import { Database, MongoClient, ObjectId } from "../../mod.ts"; +import type { Database, MongoClient, ObjectId } from "../../mod.ts"; import { MongoInvalidArgumentError, MongoServerError, } from "../../src/error.ts"; -import { CreateCollectionOptions } from "../../src/types.ts"; +import type { CreateCollectionOptions } from "../../src/types.ts"; import { cleanTestDb, getTestDb } from "../common.ts"; import { afterEach, diff --git a/tests/cases/04_indexes.ts b/tests/cases/04_indexes.ts index 1bf53504..38a1660e 100644 --- a/tests/cases/04_indexes.ts +++ b/tests/cases/04_indexes.ts @@ -1,4 +1,4 @@ -import { Collection, Database, Document, MongoClient } from "../../mod.ts"; +import type { Collection, Database, Document, MongoClient } from "../../mod.ts"; import { cleanTestDb, getTestDb } from "../common.ts"; import { afterEach, diff --git a/tests/cases/06_gridfs.ts b/tests/cases/06_gridfs.ts index df53e8d7..97632ce2 100644 --- a/tests/cases/06_gridfs.ts +++ b/tests/cases/06_gridfs.ts @@ -1,4 +1,4 @@ -import { GridFSBucket, MongoClient } from "../../mod.ts"; +import { GridFSBucket, type MongoClient } from "../../mod.ts"; import { getClient } from "../common.ts"; import { afterAll, diff --git a/tests/cases/08_find_cursor.ts b/tests/cases/08_find_cursor.ts index 787ed791..cf6bb038 100644 --- a/tests/cases/08_find_cursor.ts +++ b/tests/cases/08_find_cursor.ts @@ -1,5 +1,5 @@ import { FindCursor } from "../../src/collection/commands/find.ts"; -import { WireProtocol } from "../../src/protocol/protocol.ts"; +import type { WireProtocol } from "../../src/protocol/protocol.ts"; import { assertEquals, describe, it } from "../deps.ts"; describe("find cursor", () => { diff --git a/tests/cases/09_geospatial_types.ts b/tests/cases/09_geospatial_types.ts index a59abf51..f1b59d70 100644 --- a/tests/cases/09_geospatial_types.ts +++ b/tests/cases/09_geospatial_types.ts @@ -1,7 +1,7 @@ -import { type Database } from "../../mod.ts"; -import { type Collection } from "../../src/collection/collection.ts"; -import { Geometry, GeometryObject, Point } from "../../src/types/geojson.ts"; -import { +import type { Database } from "../../mod.ts"; +import type { Collection } from "../../src/collection/collection.ts"; +import type { Geometry, GeometryObject, Point } from "../../src/types/geojson.ts"; +import type { $box, $center, $centerSphere, diff --git a/tests/common.ts b/tests/common.ts index 33a67371..43820bcb 100644 --- a/tests/common.ts +++ b/tests/common.ts @@ -1,4 +1,4 @@ -import { Database, MongoClient } from "../mod.ts"; +import { MongoClient, type Database } from "../mod.ts"; const hostname = "127.0.0.1"; From 5b473b305ee1ba30bd9b06a9586e5eb5eb5eb047 Mon Sep 17 00:00:00 2001 From: Jersey Date: Wed, 15 May 2024 21:57:13 -0400 Subject: [PATCH 2/4] also bump the version --- deno.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 9863f3cd..fb831e48 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@db/mongo", - "version": "0.33.0", + "version": "0.34.0", "exports": { ".": "./mod.ts", "./client": "./src/client.ts", From 9fbf1c38ed89bcda95ca99391d3bf86eb44ae46f Mon Sep 17 00:00:00 2001 From: Jersey Date: Wed, 15 May 2024 21:59:09 -0400 Subject: [PATCH 3/4] actually format the code --- deps.ts | 6 +++--- mod.ts | 28 +++++++++++++-------------- src/auth/scram.ts | 2 +- src/auth/x509.ts | 2 +- src/collection/commands/update.ts | 2 +- src/protocol/message.ts | 2 +- src/protocol/protocol.ts | 8 ++++++-- src/utils/saslprep/sparse_bitfield.ts | 2 +- tests/cases/09_geospatial_types.ts | 6 +++++- tests/common.ts | 2 +- 10 files changed, 34 insertions(+), 26 deletions(-) diff --git a/deps.ts b/deps.ts index 8fbe5019..a70a811f 100644 --- a/deps.ts +++ b/deps.ts @@ -1,20 +1,20 @@ export { + Binary, BSONRegExp, BSONSymbol, - Binary, Code, DBRef, Decimal128, + deserialize, Double, Int32, Long, MaxKey, MinKey, ObjectId, + serialize, Timestamp, UUID, - deserialize, - serialize } from "jsr:@lucsoft/web-bson@^0.3.1"; export { crypto as stdCrypto } from "jsr:@std/crypto@^0.224.0/crypto"; export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.224.0/base64"; diff --git a/mod.ts b/mod.ts index 96090c10..32bf8286 100644 --- a/mod.ts +++ b/mod.ts @@ -1,38 +1,39 @@ /** * @module - * + * * # deno_mongo - * + * * **deno_mongo** is a **MongoDB** driver for Deno which also supports Deno Deploy. - * + * * ## ATTENTION - * + * * Deno has support for npm modules now, so you can also use `npm:mongodb`. * See [this](https://github.com/denodrivers/mongo/issues/380) for more details. - * + * * ## Usage - * + * * Replace `version` with the latest version of the driver. - * + * * ```ts * import { MongoClient } from 'jsr:@db/mongo@version'; * ``` - * + * * See [the README](https://github.com/denodrivers/mongo) for more examples. - * + * * ## Other community resources and examples - * + * * - [atlas_sdk](https://deno.land/x/atlas_sdk) - TypeSafe MongoDB Atlas SDK * - [dangoDB](https://github.com/oslabs-beta/dangoDB) - MongoDB ORM for Deno * - [deno-deploy-mongo](https://github.com/erfanium/deno-deploy-mongo) - A simple app with Deno, MongoDB, and Oak using MongoDB Atlas * - [deno_rest](https://github.com/vicky-gonsalves/deno_rest) - An Oak-based template for RESTful APIs using this driver * - [denomongo-unittest-utils](https://github.com/Gang-of-Fork/denomongo-unittest-utils) - Mock collection for unit tests - * */ export { + Binary, BSONRegExp, - BSONSymbol, Binary, Code, + BSONSymbol, + Code, DBRef, Decimal128, Double, @@ -42,11 +43,10 @@ export { MinKey, ObjectId, Timestamp, - UUID + UUID, } from "./deps.ts"; export { MongoClient } from "./src/client.ts"; export { Collection } from "./src/collection/mod.ts"; export { Database } from "./src/database.ts"; export { GridFSBucket } from "./src/gridfs/bucket.ts"; export * from "./src/types.ts"; - diff --git a/src/auth/scram.ts b/src/auth/scram.ts index f199ed6a..22a84d25 100644 --- a/src/auth/scram.ts +++ b/src/auth/scram.ts @@ -10,7 +10,7 @@ import type { HandshakeDocument } from "../protocol/handshake.ts"; import { driverMetadata } from "../protocol/mod.ts"; import type { Credential, Document } from "../types.ts"; import { saslprep } from "../utils/saslprep/mod.ts"; -import { AuthPlugin, type AuthContext } from "./base.ts"; +import { type AuthContext, AuthPlugin } from "./base.ts"; import { pbkdf2 } from "./pbkdf2.ts"; type CryptoMethod = "sha1" | "sha256"; diff --git a/src/auth/x509.ts b/src/auth/x509.ts index 92ee3abd..c246e481 100644 --- a/src/auth/x509.ts +++ b/src/auth/x509.ts @@ -1,7 +1,7 @@ import type { HandshakeDocument } from "../protocol/handshake.ts"; import { driverMetadata } from "../protocol/mod.ts"; import type { Credential, Document } from "../types.ts"; -import { AuthPlugin, type AuthContext } from "./base.ts"; +import { type AuthContext, AuthPlugin } from "./base.ts"; export interface X509Command extends Document { authenticate: number; diff --git a/src/collection/commands/update.ts b/src/collection/commands/update.ts index 12e5f996..35bea5a4 100644 --- a/src/collection/commands/update.ts +++ b/src/collection/commands/update.ts @@ -1,7 +1,7 @@ import type { ObjectId } from "../../../deps.ts"; import type { WireProtocol } from "../../protocol/mod.ts"; import type { Document, UpdateOptions } from "../../types.ts"; - + interface UpdateResponse { ok: number; nModified: number; diff --git a/src/protocol/message.ts b/src/protocol/message.ts index bcd994ab..38ec7215 100644 --- a/src/protocol/message.ts +++ b/src/protocol/message.ts @@ -1,6 +1,6 @@ import { deserialize, serialize } from "../../deps.ts"; import type { Document } from "../types.ts"; -import { OpCode, setHeader, type MessageHeader } from "./header.ts"; +import { type MessageHeader, OpCode, setHeader } from "./header.ts"; type MessageFlags = number; diff --git a/src/protocol/protocol.ts b/src/protocol/protocol.ts index d60fa51c..fcf039bb 100644 --- a/src/protocol/protocol.ts +++ b/src/protocol/protocol.ts @@ -1,12 +1,16 @@ import { MongoDriverError, - MongoServerError, type MongoErrorInfo, + MongoServerError, } from "../error.ts"; import type { Document } from "../types.ts"; import { handshake } from "./handshake.ts"; import { parseHeader } from "./header.ts"; -import { deserializeMessage, serializeMessage, type Message } from "./message.ts"; +import { + deserializeMessage, + type Message, + serializeMessage, +} from "./message.ts"; interface CommandTask { requestId: number; diff --git a/src/utils/saslprep/sparse_bitfield.ts b/src/utils/saslprep/sparse_bitfield.ts index 0f5d6a05..af0e75ff 100644 --- a/src/utils/saslprep/sparse_bitfield.ts +++ b/src/utils/saslprep/sparse_bitfield.ts @@ -1,4 +1,4 @@ -import { Pager, type Page } from "./memory_pager.ts"; +import { type Page, Pager } from "./memory_pager.ts"; /** Is the given number a power of two? */ function powerOfTwo(x: number): boolean { diff --git a/tests/cases/09_geospatial_types.ts b/tests/cases/09_geospatial_types.ts index f1b59d70..7bfb8fbd 100644 --- a/tests/cases/09_geospatial_types.ts +++ b/tests/cases/09_geospatial_types.ts @@ -1,6 +1,10 @@ import type { Database } from "../../mod.ts"; import type { Collection } from "../../src/collection/collection.ts"; -import type { Geometry, GeometryObject, Point } from "../../src/types/geojson.ts"; +import type { + Geometry, + GeometryObject, + Point, +} from "../../src/types/geojson.ts"; import type { $box, $center, diff --git a/tests/common.ts b/tests/common.ts index 43820bcb..bb378523 100644 --- a/tests/common.ts +++ b/tests/common.ts @@ -1,4 +1,4 @@ -import { MongoClient, type Database } from "../mod.ts"; +import { type Database, MongoClient } from "../mod.ts"; const hostname = "127.0.0.1"; From 23abc22bcd362191b94377e6ff97c00e562ecc05 Mon Sep 17 00:00:00 2001 From: William Horning Date: Fri, 17 May 2024 07:33:35 -0400 Subject: [PATCH 4/4] update funding based on discussions --- .github/FUNDING.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 715cb74b..bdb613b9 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1 @@ -github: [erfanium] -custom: - - https://github.com/denodrivers/deno_mongo/discussions/358 +github: [lucsoft]