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

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
@@ -1,3 +1,5 @@
1
1
  # Personal Core Database Library
2
2
 
3
+ ![npm](https://img.shields.io/npm/v/%40aneuhold%2Fcore-ts-db-lib)
4
+
3
5
  This is used to export types used in various places for database interactions in personal projects.
@@ -0,0 +1,22 @@
1
+ import { ObjectId } from 'bson';
2
+ import BaseDocument from '../BaseDocument';
3
+ /**
4
+ * A document containing an API key for a particular user. This is stored
5
+ * separately from the {@link User} document to enhance security a bit.
6
+ */
7
+ export default class ApiKey implements BaseDocument {
8
+ _id: ObjectId;
9
+ /**
10
+ * The API key for the user.
11
+ */
12
+ key: `${string}-${string}-${string}-${string}-${string}`;
13
+ /**
14
+ * The user ID that this key is for. This field is indexed in the database.
15
+ */
16
+ userId: ObjectId;
17
+ /**
18
+ * Constructs a new {@link ApiKey} for the provided user.
19
+ */
20
+ constructor(userId: ObjectId);
21
+ }
22
+ //# sourceMappingURL=ApiKey.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,29 @@
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 bson_1 = require("bson");
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ /**
9
+ * A document containing an API key for a particular user. This is stored
10
+ * separately from the {@link User} document to enhance security a bit.
11
+ */
12
+ class ApiKey {
13
+ _id = new bson_1.ObjectId();
14
+ /**
15
+ * The API key for the user.
16
+ */
17
+ key = crypto_1.default.randomUUID();
18
+ /**
19
+ * The user ID that this key is for. This field is indexed in the database.
20
+ */
21
+ userId;
22
+ /**
23
+ * Constructs a new {@link ApiKey} for the provided user.
24
+ */
25
+ constructor(userId) {
26
+ this.userId = userId;
27
+ }
28
+ }
29
+ exports.default = ApiKey;
@@ -8,6 +8,7 @@ import BaseDocument from '../BaseDocument';
8
8
  export default class User implements BaseDocument {
9
9
  _id: ObjectId;
10
10
  userName: string;
11
+ password?: string;
11
12
  email?: string;
12
13
  auth: {
13
14
  googleId?: string;
@@ -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,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,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"}
@@ -9,6 +9,7 @@ const bson_1 = require("bson");
9
9
  class User {
10
10
  _id = new bson_1.ObjectId();
11
11
  userName;
12
+ password;
12
13
  email;
13
14
  auth = {};
14
15
  /**
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import BaseDocument from './documents/BaseDocument';
2
+ import ApiKey from './documents/common/ApiKey';
2
3
  import User from './documents/common/User';
3
- export { User };
4
+ export { User, ApiKey };
4
5
  export type { BaseDocument };
5
6
  //# 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,IAAI,MAAM,yBAAyB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,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,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"}
package/lib/index.js CHANGED
@@ -3,6 +3,8 @@ 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.User = void 0;
6
+ exports.ApiKey = exports.User = void 0;
7
+ const ApiKey_1 = __importDefault(require("./documents/common/ApiKey"));
8
+ exports.ApiKey = ApiKey_1.default;
7
9
  const User_1 = __importDefault(require("./documents/common/User"));
8
10
  exports.User = User_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aneuhold/core-ts-db-lib",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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,6 +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
32
  "test": "jest"
32
33
  },
33
34
  "dependencies": {