Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup JSR stuff #414

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .github/FUNDING.yml
williamhorning marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@

# 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
github: [lucsoft]
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@db/mongo",
"version": "0.33.0",
"version": "0.34.0",
"exports": {
".": "./mod.ts",
"./client": "./src/client.ts",
Expand Down
6 changes: 3 additions & 3 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export {
Timestamp,
UUID,
} 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";
31 changes: 31 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/**
* @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,
Expand Down
4 changes: 2 additions & 2 deletions src/auth/base.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/auth/scram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { type AuthContext, AuthPlugin } from "./base.ts";
import { pbkdf2 } from "./pbkdf2.ts";

type CryptoMethod = "sha1" | "sha256";
Expand Down
6 changes: 3 additions & 3 deletions src/auth/x509.ts
Original file line number Diff line number Diff line change
@@ -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 { type AuthContext, AuthPlugin } from "./base.ts";

export interface X509Command extends Document {
authenticate: number;
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/collection/commands/aggregate.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/collection/commands/find.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/collection/commands/list_indexes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CommandCursor, WireProtocol } from "../../protocol/mod.ts";
import { CommandCursor, type WireProtocol } from "../../protocol/mod.ts";

interface ListIndexesCursorContext {
dbName: string;
Expand Down
6 changes: 3 additions & 3 deletions src/collection/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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;
Expand Down
6 changes: 3 additions & 3 deletions src/database.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
10 changes: 5 additions & 5 deletions src/gridfs/bucket.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/gridfs/indexes.ts
Original file line number Diff line number Diff line change
@@ -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<T extends Document>(
index: IndexOptions,
Expand Down
6 changes: 3 additions & 3 deletions src/gridfs/upload.ts
Original file line number Diff line number Diff line change
@@ -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<File>;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/cursor.ts
Original file line number Diff line number Diff line change
@@ -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<T> {
id: bigint | number | string;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/handshake.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/message.ts
Original file line number Diff line number Diff line change
@@ -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 { type MessageHeader, OpCode, setHeader } from "./header.ts";

type MessageFlags = number;

Expand Down
10 changes: 7 additions & 3 deletions src/protocol/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {
MongoDriverError,
MongoErrorInfo,
type MongoErrorInfo,
MongoServerError,
} 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,
type Message,
serializeMessage,
} from "./message.ts";

interface CommandTask {
requestId: number;
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Binary,
BSONRegExp,
Decimal128,
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/types/geospatial.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Document } from "../types.ts";
import {
import type { Document } from "../types.ts";
import type {
GeoJsonObject,
GeometryCollection,
GeometryObject,
Expand Down
6 changes: 3 additions & 3 deletions src/types/gridfs.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/saslprep/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/saslprep/sparse_bitfield.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page, Pager } 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/srv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConnectOptions } from "../types.ts";
import type { ConnectOptions } from "../types.ts";
import { parseSrvUrl } from "./uri.ts";

enum AllowedOption {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/uri.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/01_auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Database } from "../../mod.ts";
import type { Database } from "../../mod.ts";
import {
cleanUsername,
clientFirstMessageBare,
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/03_crud.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading
Loading