@aneuhold/core-ts-db-lib 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -3,3 +3,9 @@
3
3
  ![npm](https://img.shields.io/npm/v/%40aneuhold%2Fcore-ts-db-lib)
4
4
 
5
5
  This is used to export types used in various places for database interactions in personal projects.
6
+
7
+ ## Document structure
8
+
9
+ Project-specific documents can be held in a single collection. So those should inherit from the `BaseDocumentWithType` class.
10
+
11
+ When different document types are held under a specific collection, they should get their own folder.
@@ -1,9 +1,9 @@
1
- import { ObjectId, Document } from 'bson';
1
+ import { ObjectId } from 'bson';
2
2
  /**
3
3
  * A base document which other types that will be stored in a document DB can
4
4
  * inherit from.
5
5
  */
6
- export default interface BaseDocument extends Document {
6
+ export default abstract class BaseDocument extends Document {
7
7
  _id: ObjectId;
8
8
  }
9
9
  //# sourceMappingURL=BaseDocument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDocument.d.ts","sourceRoot":"","sources":["../../src/documents/BaseDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,OAAO,WAAW,YAAa,SAAQ,QAAQ;IACpD,GAAG,EAAE,QAAQ,CAAC;CACf"}
1
+ {"version":3,"file":"BaseDocument.d.ts","sourceRoot":"","sources":["../../src/documents/BaseDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,YAAa,SAAQ,QAAQ;IACzD,GAAG,WAAkB;CACtB"}
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bson_1 = require("bson");
4
+ /**
5
+ * A base document which other types that will be stored in a document DB can
6
+ * inherit from.
7
+ */
8
+ class BaseDocument extends Document {
9
+ _id = new bson_1.ObjectId();
10
+ }
11
+ exports.default = BaseDocument;
@@ -0,0 +1,5 @@
1
+ import BaseDocument from './BaseDocument';
2
+ export default abstract class BaseDocumentWithType extends BaseDocument {
3
+ abstract docType: string;
4
+ }
5
+ //# sourceMappingURL=BaseDocumentWithType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseDocumentWithType.d.ts","sourceRoot":"","sources":["../../src/documents/BaseDocumentWithType.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,oBAAqB,SAAQ,YAAY;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseDocument_1 = __importDefault(require("./BaseDocument"));
7
+ class BaseDocumentWithType extends BaseDocument_1.default {
8
+ }
9
+ exports.default = BaseDocumentWithType;
@@ -4,10 +4,9 @@ import BaseDocument from '../BaseDocument';
4
4
  * A document containing an API key for a particular user. This is stored
5
5
  * separately from the {@link User} document to enhance security a bit.
6
6
  */
7
- export default class ApiKey implements BaseDocument {
8
- _id: ObjectId;
7
+ export default class ApiKey extends BaseDocument {
9
8
  /**
10
- * The API key for the user.
9
+ * The API key for the user. This is indexed in the DB.
11
10
  */
12
11
  key: `${string}-${string}-${string}-${string}-${string}`;
13
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKey.d.ts","sourceRoot":"","sources":["../../../src/documents/common/ApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,YAAW,YAAY;IACjD,GAAG,WAAkB;IAErB;;OAEG;IACH,GAAG,sDAAuB;IAE1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;gBACS,MAAM,EAAE,QAAQ;CAG7B"}
1
+ {"version":3,"file":"ApiKey.d.ts","sourceRoot":"","sources":["../../../src/documents/common/ApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,YAAY;IAC9C;;OAEG;IACH,GAAG,sDAAuB;IAE1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;gBACS,MAAM,EAAE,QAAQ;CAI7B"}
@@ -3,16 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const bson_1 = require("bson");
7
6
  const crypto_1 = __importDefault(require("crypto"));
7
+ const BaseDocument_1 = __importDefault(require("../BaseDocument"));
8
8
  /**
9
9
  * A document containing an API key for a particular user. This is stored
10
10
  * separately from the {@link User} document to enhance security a bit.
11
11
  */
12
- class ApiKey {
13
- _id = new bson_1.ObjectId();
12
+ class ApiKey extends BaseDocument_1.default {
14
13
  /**
15
- * The API key for the user.
14
+ * The API key for the user. This is indexed in the DB.
16
15
  */
17
16
  key = crypto_1.default.randomUUID();
18
17
  /**
@@ -23,6 +22,7 @@ class ApiKey {
23
22
  * Constructs a new {@link ApiKey} for the provided user.
24
23
  */
25
24
  constructor(userId) {
25
+ super();
26
26
  this.userId = userId;
27
27
  }
28
28
  }
@@ -5,7 +5,7 @@ import BaseDocument from '../BaseDocument';
5
5
  * other documents that need to reference a user, instead of cluttering the
6
6
  * key user information.
7
7
  */
8
- export default class User implements BaseDocument {
8
+ export default class User extends BaseDocument {
9
9
  _id: ObjectId;
10
10
  userName: string;
11
11
  password?: string;
@@ -13,6 +13,9 @@ export default class User implements BaseDocument {
13
13
  auth: {
14
14
  googleId?: string;
15
15
  };
16
+ projectAccess: {
17
+ dashboard: boolean;
18
+ };
16
19
  /**
17
20
  * Constructs a new {@link User} with default values.
18
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/documents/common/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,YAAY;IAC/C,GAAG,WAAkB;IAErB,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAM;IAEP;;OAEG;gBACS,QAAQ,EAAE,MAAM;CAG7B"}
1
+ {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/documents/common/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,GAAG,WAAkB;IAErB,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAM;IAEP,aAAa;;MAEX;IAEF;;OAEG;gBACS,QAAQ,EAAE,MAAM;CAI7B"}
@@ -1,21 +1,29 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const bson_1 = require("bson");
7
+ const BaseDocument_1 = __importDefault(require("../BaseDocument"));
4
8
  /**
5
9
  * A standard user of all personal projects. This should be linked to from
6
10
  * other documents that need to reference a user, instead of cluttering the
7
11
  * key user information.
8
12
  */
9
- class User {
13
+ class User extends BaseDocument_1.default {
10
14
  _id = new bson_1.ObjectId();
11
15
  userName;
12
16
  password;
13
17
  email;
14
18
  auth = {};
19
+ projectAccess = {
20
+ dashboard: true
21
+ };
15
22
  /**
16
23
  * Constructs a new {@link User} with default values.
17
24
  */
18
25
  constructor(userName) {
26
+ super();
19
27
  this.userName = userName;
20
28
  }
21
29
  }
@@ -0,0 +1,6 @@
1
+ import BaseDocumentWithType from '../BaseDocumentWithType';
2
+ export default class DashboardUserConfig extends BaseDocumentWithType {
3
+ docType: string;
4
+ enableDevMode: boolean;
5
+ }
6
+ //# sourceMappingURL=UserConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserConfig.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/UserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,oBAAoB;IACnE,OAAO,SAAgB;IAEvB,aAAa,UAAS;CACvB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseDocumentWithType_1 = __importDefault(require("../BaseDocumentWithType"));
7
+ class DashboardUserConfig extends BaseDocumentWithType_1.default {
8
+ docType = 'userConfig';
9
+ enableDevMode = false;
10
+ }
11
+ exports.default = DashboardUserConfig;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import BaseDocument from './documents/BaseDocument';
2
+ import BaseDocumentWithType from './documents/BaseDocumentWithType';
2
3
  import ApiKey from './documents/common/ApiKey';
3
4
  import User from './documents/common/User';
4
- export { User, ApiKey };
5
- export type { BaseDocument };
5
+ import DashboardUserConfig from './documents/dashboard/UserConfig';
6
+ export { User, ApiKey, DashboardUserConfig, BaseDocument, BaseDocumentWithType };
7
+ export type {};
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAGxB,YAAY,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AAGnE,OAAO,EACL,IAAI,EACJ,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACrB,CAAC;AAGF,YAAY,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -3,8 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ApiKey = exports.User = void 0;
6
+ exports.BaseDocumentWithType = exports.BaseDocument = exports.DashboardUserConfig = exports.ApiKey = exports.User = void 0;
7
+ const BaseDocument_1 = __importDefault(require("./documents/BaseDocument"));
8
+ exports.BaseDocument = BaseDocument_1.default;
9
+ const BaseDocumentWithType_1 = __importDefault(require("./documents/BaseDocumentWithType"));
10
+ exports.BaseDocumentWithType = BaseDocumentWithType_1.default;
7
11
  const ApiKey_1 = __importDefault(require("./documents/common/ApiKey"));
8
12
  exports.ApiKey = ApiKey_1.default;
9
13
  const User_1 = __importDefault(require("./documents/common/User"));
10
14
  exports.User = User_1.default;
15
+ const UserConfig_1 = __importDefault(require("./documents/dashboard/UserConfig"));
16
+ exports.DashboardUserConfig = UserConfig_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aneuhold/core-ts-db-lib",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A core database library used for personal projects",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "link:local": "cd lib && yarn link",
29
29
  "unlink:local": "cd lib && yarn unlink",
30
30
  "upgrade:all": "yarn upgrade --latest",
31
- "upgrade:core": "yarn upgrade --latest @aneuhold",
31
+ "upgrade:core": "yarn upgrade --latest --pattern @aneuhold",
32
32
  "test": "jest"
33
33
  },
34
34
  "dependencies": {