@aneuhold/core-ts-db-lib 1.0.4 → 1.0.6
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 +6 -0
- package/lib/documents/BaseDocument.d.ts +2 -2
- package/lib/documents/BaseDocument.d.ts.map +1 -1
- package/lib/documents/BaseDocument.js +9 -0
- package/lib/documents/BaseDocumentWithOwner.d.ts +1 -0
- package/lib/documents/BaseDocumentWithOwner.d.ts.map +1 -0
- package/lib/documents/BaseDocumentWithOwner.js +1 -0
- package/lib/documents/BaseDocumentWithType.d.ts +5 -0
- package/lib/documents/BaseDocumentWithType.d.ts.map +1 -0
- package/lib/documents/BaseDocumentWithType.js +9 -0
- package/lib/documents/BaseDocumentWithUserId.d.ts +10 -0
- package/lib/documents/BaseDocumentWithUserId.d.ts.map +1 -0
- package/lib/documents/BaseDocumentWithUserId.js +13 -0
- package/lib/documents/common/ApiKey.d.ts +2 -2
- package/lib/documents/common/ApiKey.d.ts.map +1 -1
- package/lib/documents/common/ApiKey.js +3 -3
- package/lib/documents/common/User.d.ts +1 -1
- package/lib/documents/common/User.d.ts.map +1 -1
- package/lib/documents/common/User.js +6 -1
- package/lib/documents/dashboard/UserConfig.d.ts +17 -0
- package/lib/documents/dashboard/UserConfig.d.ts.map +1 -0
- package/lib/documents/dashboard/UserConfig.js +23 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,3 +3,9 @@
|
|
|
3
3
|

|
|
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
|
|
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
|
|
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,
|
|
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 @@
|
|
|
1
|
+
//# sourceMappingURL=BaseDocumentWithOwner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDocumentWithOwner.d.ts","sourceRoot":"","sources":["../../src/documents/BaseDocumentWithOwner.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ObjectId } from 'bson';
|
|
2
|
+
import BaseDocument from './BaseDocument';
|
|
3
|
+
/**
|
|
4
|
+
* A base document type that has a user ID associated with it. This is useful
|
|
5
|
+
* for filtering on all documents that a user has access to.
|
|
6
|
+
*/
|
|
7
|
+
export default abstract class BaseDocumentWithUserId extends BaseDocument {
|
|
8
|
+
abstract userId: ObjectId;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=BaseDocumentWithUserId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDocumentWithUserId.d.ts","sourceRoot":"","sources":["../../src/documents/BaseDocumentWithUserId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,sBAAuB,SAAQ,YAAY;IACvE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A base document type that has a user ID associated with it. This is useful
|
|
9
|
+
* for filtering on all documents that a user has access to.
|
|
10
|
+
*/
|
|
11
|
+
class BaseDocumentWithUserId extends BaseDocument_1.default {
|
|
12
|
+
}
|
|
13
|
+
exports.default = BaseDocumentWithUserId;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ObjectId } from 'bson';
|
|
2
2
|
import BaseDocument from '../BaseDocument';
|
|
3
|
+
import BaseDocumentWithUserId from '../BaseDocumentWithUserId';
|
|
3
4
|
/**
|
|
4
5
|
* A document containing an API key for a particular user. This is stored
|
|
5
6
|
* separately from the {@link User} document to enhance security a bit.
|
|
6
7
|
*/
|
|
7
|
-
export default class ApiKey
|
|
8
|
-
_id: ObjectId;
|
|
8
|
+
export default class ApiKey extends BaseDocument implements BaseDocumentWithUserId {
|
|
9
9
|
/**
|
|
10
10
|
* The API key for the user. This is indexed in the DB.
|
|
11
11
|
*/
|
|
@@ -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;
|
|
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;AAC3C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MACnB,SAAQ,YACR,YAAW,sBAAsB;IAEjC;;OAEG;IACH,GAAG,sDAAuB;IAE1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;gBACS,MAAM,EAAE,QAAQ;CAI7B"}
|
|
@@ -3,14 +3,13 @@ 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
14
|
* The API key for the user. This is indexed in the DB.
|
|
16
15
|
*/
|
|
@@ -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
|
|
8
|
+
export default class User extends BaseDocument {
|
|
9
9
|
_id: ObjectId;
|
|
10
10
|
userName: string;
|
|
11
11
|
password?: 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,
|
|
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,12 +1,16 @@
|
|
|
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;
|
|
@@ -19,6 +23,7 @@ class User {
|
|
|
19
23
|
* Constructs a new {@link User} with default values.
|
|
20
24
|
*/
|
|
21
25
|
constructor(userName) {
|
|
26
|
+
super();
|
|
22
27
|
this.userName = userName;
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ObjectId } from 'bson';
|
|
2
|
+
import BaseDocumentWithType from '../BaseDocumentWithType';
|
|
3
|
+
import BaseDocumentWithUserId from '../BaseDocumentWithUserId';
|
|
4
|
+
export default class DashboardUserConfig extends BaseDocumentWithType implements BaseDocumentWithUserId {
|
|
5
|
+
static docType: string;
|
|
6
|
+
docType: string;
|
|
7
|
+
/**
|
|
8
|
+
* The owner of this config.
|
|
9
|
+
*/
|
|
10
|
+
userId: ObjectId;
|
|
11
|
+
/**
|
|
12
|
+
* Whether or not to enable dev mode for the user.
|
|
13
|
+
*/
|
|
14
|
+
enableDevMode: boolean;
|
|
15
|
+
constructor(ownerId: ObjectId);
|
|
16
|
+
}
|
|
17
|
+
//# 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,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAE/D,MAAM,CAAC,OAAO,OAAO,mBACnB,SAAQ,oBACR,YAAW,sBAAsB;IAEjC,MAAM,CAAC,OAAO,SAAgB;IAE9B,OAAO,SAA+B;IAEtC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;IACH,aAAa,UAAS;gBAEV,OAAO,EAAE,QAAQ;CAI9B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
static docType = 'userConfig';
|
|
9
|
+
docType = DashboardUserConfig.docType;
|
|
10
|
+
/**
|
|
11
|
+
* The owner of this config.
|
|
12
|
+
*/
|
|
13
|
+
userId;
|
|
14
|
+
/**
|
|
15
|
+
* Whether or not to enable dev mode for the user.
|
|
16
|
+
*/
|
|
17
|
+
enableDevMode = false;
|
|
18
|
+
constructor(ownerId) {
|
|
19
|
+
super();
|
|
20
|
+
this.userId = ownerId;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = DashboardUserConfig;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import BaseDocument from './documents/BaseDocument';
|
|
2
|
+
import BaseDocumentWithType from './documents/BaseDocumentWithType';
|
|
3
|
+
import BaseDocumentWithUserId from './documents/BaseDocumentWithUserId';
|
|
2
4
|
import ApiKey from './documents/common/ApiKey';
|
|
3
5
|
import User from './documents/common/User';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
+
import DashboardUserConfig from './documents/dashboard/UserConfig';
|
|
7
|
+
export { User, ApiKey, DashboardUserConfig, BaseDocument, BaseDocumentWithType, BaseDocumentWithUserId };
|
|
8
|
+
export type {};
|
|
6
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,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,EACpB,sBAAsB,EACvB,CAAC;AAGF,YAAY,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,16 @@ 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.BaseDocumentWithUserId = 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;
|
|
11
|
+
const BaseDocumentWithUserId_1 = __importDefault(require("./documents/BaseDocumentWithUserId"));
|
|
12
|
+
exports.BaseDocumentWithUserId = BaseDocumentWithUserId_1.default;
|
|
7
13
|
const ApiKey_1 = __importDefault(require("./documents/common/ApiKey"));
|
|
8
14
|
exports.ApiKey = ApiKey_1.default;
|
|
9
15
|
const User_1 = __importDefault(require("./documents/common/User"));
|
|
10
16
|
exports.User = User_1.default;
|
|
17
|
+
const UserConfig_1 = __importDefault(require("./documents/dashboard/UserConfig"));
|
|
18
|
+
exports.DashboardUserConfig = UserConfig_1.default;
|