Skip to content

Commit

Permalink
slim deps/transistion to bson only; update readme; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanBulmer committed Jul 20, 2024
1 parent caef334 commit cacb04d
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { User } from "jsr:@codr/models@^1";
git clone [email protected]:CodrJS/models.git

# Cache deno dependencies
deno cache
deno cache ./mod.ts

# Format, lint, and test the code
deno fmt
Expand Down
5 changes: 5 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/models/Annotation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import { Base, type IBase } from "./Base.ts";
import type { AtLeast } from "../types/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Audit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import type { IBase } from "./Base.ts";
import type { ActionCode, ResourceCode } from "../types/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Authorization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import { Base, type IBase } from "./Base.ts";
import type { ActionCode, AtLeast, ResourceCode } from "../types/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectId } from "npm:mongodb";
import { ObjectId } from "npm:bson";
import type { AtLeast } from "../types/mod.ts";

export interface IBase<Kind extends string> {
Expand Down
2 changes: 1 addition & 1 deletion src/models/Dataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import type { AtLeast, Flags } from "../types/mod.ts";
import { Base, type IBase } from "./Base.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import { Base, type IBase } from "./Base.ts";
import type { AtLeast, Flags } from "../types/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import type { AtLeast, MessageType } from "../types/mod.ts";
import { Base, type IBase } from "./Base.ts";

Expand Down
3 changes: 2 additions & 1 deletion src/models/Organization.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { AtLeast } from "../types/mod.ts";
import { Base, type IBase } from "./Base.ts";

interface OrganizationFlags {
Expand Down Expand Up @@ -34,7 +35,7 @@ export class Organization extends Base<"Organization"> {
name,
slug,
domains,
}: IOrganization) {
}: AtLeast<IOrganization, "createdBy" | "domains" | "name" | "slug">) {
super({
_id,
__v,
Expand Down
2 changes: 1 addition & 1 deletion src/models/Profile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import { Base, type IBase } from "./Base.ts";
import type { User } from "./User.ts";
import type { AtLeast } from "../types/mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/models/Project.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import type { AtLeast, Flags, TaskType } from "../types/mod.ts";
import { Base, type IBase } from "./Base.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/Sample.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";
import { Base, type IBase } from "./Base.ts";
import type { AtLeast } from "../types/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Base, type IBase } from "./Base.ts";
import type { AtLeast, UserEnum } from "../types/mod.ts";
import type { ObjectId } from "npm:mongodb";
import type { ObjectId } from "npm:bson";

export interface IUser extends IBase<"User"> {
organizationId: ObjectId;
Expand Down
6 changes: 0 additions & 6 deletions tests/add.test.ts

This file was deleted.

26 changes: 26 additions & 0 deletions tests/organization.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { assert, assertEquals } from "jsr:@std/assert";
import { Organization } from "../mod.ts";
import { ObjectId } from "npm:bson";

Deno.test("Create organziation", function createOrganization() {
const createdBy: ObjectId = new ObjectId();
const org = new Organization({
domains: ["localhost:3000"],
name: "Demo Account",
flags: {
isActive: true,
isDeleted: false,
isDemo: true,
},
slug: "demo",
createdBy,
});

assertEquals(org.toJSON().name, "Demo Account");
assertEquals(org.toJSON().slug, "demo");
assertEquals(org.toJSON().createdBy.toString(), createdBy.toString());
assertEquals(org.toJSON().flags.isActive, true);
assertEquals(org.toJSON().flags.isDeleted, false);
assertEquals(org.toJSON().flags.isDemo, true);
assert(org.toJSON().domains.includes("localhost:3000"));
});

0 comments on commit cacb04d

Please sign in to comment.