@aneuhold/core-ts-db-lib 1.0.20 → 1.0.21

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.
@@ -2,6 +2,7 @@ import { ObjectId } from 'bson';
2
2
  import BaseDocumentWithType from '../BaseDocumentWithType';
3
3
  import RequiredUserId from '../../schemas/required-refs/RequiredUserId';
4
4
  import { DocumentValidator } from '../../schemas/validators/DocumentValidator';
5
+ import { RecurrenceInfo } from '../../embedded-types/dashboard/task/RecurrenceInfo';
5
6
  export declare const validateDashboardTask: DocumentValidator<DashboardTask>;
6
7
  /**
7
8
  * Gets all the children task IDs for the given parent task IDs.
@@ -48,6 +49,7 @@ export default class DashboardTask extends BaseDocumentWithType implements Requi
48
49
  * double check for this when displaying things.
49
50
  */
50
51
  sharedWith: ObjectId[];
52
+ recurrenceInfo?: RecurrenceInfo;
51
53
  title: string;
52
54
  completed: boolean;
53
55
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAE/E,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,aAAa,CAmBlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,iBACxB,aAAa,EAAE,iBACd,QAAQ,EAAE,KACxB,QAAQ,EA2BV,CAAC;AAyBF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,OAAO,aACnB,SAAQ,oBACR,YAAW,cAAc;IAEzB,MAAM,CAAC,OAAO,SAAU;IAExB,OAAO,SAAyB;IAEhC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEj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CAAC;IAEhC,KAAK,SAAM;IAEX,SAAS,UAAS;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;IAExB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,OAAc;IAEzB;;OAEG;IACH,eAAe,OAAc;IAE7B,SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB,OAAO,CAAC,EAAE,IAAI,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAM;IAEpB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAa;gBAEjB,OAAO,EAAE,QAAQ;CAI9B"}
@@ -7,6 +7,7 @@ exports.getDashboardTaskChildrenIds = exports.validateDashboardTask = void 0;
7
7
  const bson_1 = require("bson");
8
8
  const BaseDocumentWithType_1 = __importDefault(require("../BaseDocumentWithType"));
9
9
  const ValidateUtil_1 = __importDefault(require("../../schemas/validators/ValidateUtil"));
10
+ const RecurrenceInfo_1 = require("../../embedded-types/dashboard/task/RecurrenceInfo");
10
11
  const validateDashboardTask = (task) => {
11
12
  const errors = [];
12
13
  const validate = new ValidateUtil_1.default(task, errors);
@@ -15,12 +16,14 @@ const validateDashboardTask = (task) => {
15
16
  validate.boolean('completed', exampleTask.completed);
16
17
  validate.optionalString('description');
17
18
  validate.array('sharedWith', exampleTask.sharedWith);
19
+ validate.optionalObject('recurrenceInfo');
18
20
  validate.array('tags', exampleTask.tags);
19
21
  validate.string('category', exampleTask.category);
20
22
  validate.object('createdDate', exampleTask.createdDate);
21
23
  validate.object('lastUpdatedDate', exampleTask.lastUpdatedDate);
22
24
  validate.optionalObject('startDate');
23
25
  validate.optionalObject('dueDate');
26
+ (0, RecurrenceInfo_1.validateRecurrenceInfo)(task, errors);
24
27
  return { updatedDoc: task, errors };
25
28
  };
26
29
  exports.validateDashboardTask = validateDashboardTask;
@@ -105,6 +108,7 @@ class DashboardTask extends BaseDocumentWithType_1.default {
105
108
  * double check for this when displaying things.
106
109
  */
107
110
  sharedWith = [];
111
+ recurrenceInfo;
108
112
  title = '';
109
113
  completed = false;
110
114
  /**
@@ -0,0 +1,62 @@
1
+ import DashboardTask from '../../../documents/dashboard/Task';
2
+ export declare function validateRecurrenceInfo(task: DashboardTask, errors: string[]): void;
3
+ export type RecurrenceInfo = {
4
+ frequency: RecurrenceFrequency;
5
+ recurrenceBasis: RecurrenceBasis;
6
+ recurrenceEffect: RecurrenceEffect;
7
+ };
8
+ export type RecurrenceFrequency = {
9
+ type: RecurrenceFrequencyType;
10
+ everyXTimeUnit?: {
11
+ timeUnit: 'day' | 'week' | 'month' | 'year';
12
+ /**
13
+ * The number of time units that should pass before the task recurs.
14
+ */
15
+ x: number;
16
+ };
17
+ /**
18
+ * The set of week days that the task should recur on. This is 0-6 with 0
19
+ * being Sunday.
20
+ */
21
+ weekDaySet?: Set<number>;
22
+ everyXWeekdayOfMonth?: {
23
+ weekDay: number;
24
+ /**
25
+ * The week of the month that the task should recur on. This is 0-4 with 0
26
+ * being the first week of the month. If this is 'last', then it will
27
+ * recur on the last week of the month.
28
+ */
29
+ weekOfMonth: number | 'last';
30
+ };
31
+ };
32
+ export declare enum RecurrenceFrequencyType {
33
+ everyXTimeUnit = "everyXTimeUnit",
34
+ weekDaySet = "weekDaySet",
35
+ everyXWeekdayOfMonth = "everyXWeekdayOfMonth",
36
+ lastDayOfMonth = "lastDayOfMonth"
37
+ }
38
+ /**
39
+ * The basis of date movement for a recurring task.
40
+ */
41
+ export declare enum RecurrenceBasis {
42
+ startDate = "startDate",
43
+ dueDate = "dueDate"
44
+ }
45
+ export declare enum RecurrenceEffect {
46
+ /**
47
+ * Automatically refreshes the task when the {@link RecurrenceBasis} triggers.
48
+ */
49
+ rollOnBasis = "rollOnBasis",
50
+ /**
51
+ * Moves the task forward from the completed date and doesn't reset the task
52
+ * when the {@link RecurrenceBasis} triggers.
53
+ */
54
+ rollOnCompletion = "rollOnCompletion",
55
+ /**
56
+ * When the {@link RecurrenceBasis} triggers, and the current task isn't
57
+ * completed, makes a duplicate task and clears {@link RecurrenceInfo} on
58
+ * the original task.
59
+ */
60
+ stack = "stack"
61
+ }
62
+ //# sourceMappingURL=RecurrenceInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecurrenceInfo.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/RecurrenceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAE9D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAwB3E;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,eAAe,EAAE,eAAe,CAAC;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,cAAc,CAAC,EAAE;QACf,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;QAC5C;;WAEG;QACH,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,oBAAoB,CAAC,EAAE;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB;;;;WAIG;QACH,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,oBAAY,uBAAuB;IACjC,cAAc,mBAAmB;IACjC,UAAU,eAAe;IACzB,oBAAoB,yBAAyB;IAC7C,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,gBAAgB,qBAAqB;IACrC;;;;OAIG;IACH,KAAK,UAAU;CAChB"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurrenceEffect = exports.RecurrenceBasis = exports.RecurrenceFrequencyType = exports.validateRecurrenceInfo = void 0;
4
+ function validateRecurrenceInfo(task, errors) {
5
+ const recurrenceErrors = [];
6
+ if (!task.recurrenceInfo) {
7
+ return;
8
+ }
9
+ if (!task.recurrenceInfo.frequency) {
10
+ recurrenceErrors.push('RecurrenceInfo frequency is required.');
11
+ }
12
+ if (!task.recurrenceInfo.recurrenceBasis) {
13
+ recurrenceErrors.push('RecurrenceInfo recurrenceBasis is required.');
14
+ }
15
+ if (!task.recurrenceInfo.recurrenceEffect) {
16
+ recurrenceErrors.push('RecurrenceInfo recurrenceEffect is required.');
17
+ }
18
+ // Write more if this later if there are any changes to the data model so it
19
+ // can be correctly converted.
20
+ if (recurrenceErrors.length > 0) {
21
+ // eslint-disable-next-line no-param-reassign
22
+ task.recurrenceInfo = undefined;
23
+ }
24
+ errors.push(...recurrenceErrors);
25
+ }
26
+ exports.validateRecurrenceInfo = validateRecurrenceInfo;
27
+ var RecurrenceFrequencyType;
28
+ (function (RecurrenceFrequencyType) {
29
+ RecurrenceFrequencyType["everyXTimeUnit"] = "everyXTimeUnit";
30
+ RecurrenceFrequencyType["weekDaySet"] = "weekDaySet";
31
+ RecurrenceFrequencyType["everyXWeekdayOfMonth"] = "everyXWeekdayOfMonth";
32
+ RecurrenceFrequencyType["lastDayOfMonth"] = "lastDayOfMonth";
33
+ })(RecurrenceFrequencyType || (exports.RecurrenceFrequencyType = RecurrenceFrequencyType = {}));
34
+ /**
35
+ * The basis of date movement for a recurring task.
36
+ */
37
+ var RecurrenceBasis;
38
+ (function (RecurrenceBasis) {
39
+ RecurrenceBasis["startDate"] = "startDate";
40
+ RecurrenceBasis["dueDate"] = "dueDate";
41
+ })(RecurrenceBasis || (exports.RecurrenceBasis = RecurrenceBasis = {}));
42
+ var RecurrenceEffect;
43
+ (function (RecurrenceEffect) {
44
+ /**
45
+ * Automatically refreshes the task when the {@link RecurrenceBasis} triggers.
46
+ */
47
+ RecurrenceEffect["rollOnBasis"] = "rollOnBasis";
48
+ /**
49
+ * Moves the task forward from the completed date and doesn't reset the task
50
+ * when the {@link RecurrenceBasis} triggers.
51
+ */
52
+ RecurrenceEffect["rollOnCompletion"] = "rollOnCompletion";
53
+ /**
54
+ * When the {@link RecurrenceBasis} triggers, and the current task isn't
55
+ * completed, makes a duplicate task and clears {@link RecurrenceInfo} on
56
+ * the original task.
57
+ */
58
+ RecurrenceEffect["stack"] = "stack";
59
+ })(RecurrenceEffect || (exports.RecurrenceEffect = RecurrenceEffect = {}));
package/lib/index.d.ts CHANGED
@@ -4,8 +4,9 @@ import ApiKey, { validateApiKey } from './documents/common/ApiKey';
4
4
  import User, { UserCTO, validateUser } from './documents/common/User';
5
5
  import DashboardTask, { getDashboardTaskChildrenIds, validateDashboardTask } from './documents/dashboard/Task';
6
6
  import DashboardUserConfig, { validateDashboardUserConfig } from './documents/dashboard/UserConfig';
7
+ import { RecurrenceBasis, RecurrenceEffect, RecurrenceFrequency, RecurrenceFrequencyType, RecurrenceInfo } from './embedded-types/dashboard/task/RecurrenceInfo';
7
8
  import RequiredUserId from './schemas/required-refs/RequiredUserId';
8
9
  import { DocumentValidator } from './schemas/validators/DocumentValidator';
9
- export { User, validateUser, ApiKey, validateApiKey, DashboardUserConfig, validateDashboardUserConfig, DashboardTask, validateDashboardTask, getDashboardTaskChildrenIds, BaseDocument, BaseDocumentWithType, RequiredUserId };
10
- export type { DocumentValidator, UserCTO };
10
+ export { User, validateUser, ApiKey, validateApiKey, DashboardUserConfig, validateDashboardUserConfig, DashboardTask, RecurrenceFrequencyType, RecurrenceBasis, RecurrenceEffect, validateDashboardTask, getDashboardTaskChildrenIds, BaseDocument, BaseDocumentWithType, RequiredUserId };
11
+ export type { DocumentValidator, UserCTO, RecurrenceInfo, RecurrenceFrequency };
11
12
  //# 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,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,aAAa,EAAE,EACpB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,EACb,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACf,CAAC;AAGF,YAAY,EAAE,iBAAiB,EAAE,OAAO,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,EAAE,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,aAAa,EAAE,EACpB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACf,MAAM,gDAAgD,CAAC;AACxD,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACf,CAAC;AAGF,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.RequiredUserId = exports.BaseDocumentWithType = exports.BaseDocument = exports.getDashboardTaskChildrenIds = exports.validateDashboardTask = exports.DashboardTask = exports.validateDashboardUserConfig = exports.DashboardUserConfig = exports.validateApiKey = exports.ApiKey = exports.validateUser = exports.User = void 0;
29
+ exports.RequiredUserId = exports.BaseDocumentWithType = exports.BaseDocument = exports.getDashboardTaskChildrenIds = exports.validateDashboardTask = exports.RecurrenceEffect = exports.RecurrenceBasis = exports.RecurrenceFrequencyType = exports.DashboardTask = exports.validateDashboardUserConfig = exports.DashboardUserConfig = exports.validateApiKey = exports.ApiKey = exports.validateUser = exports.User = void 0;
30
30
  const BaseDocument_1 = __importDefault(require("./documents/BaseDocument"));
31
31
  exports.BaseDocument = BaseDocument_1.default;
32
32
  const BaseDocumentWithType_1 = __importDefault(require("./documents/BaseDocumentWithType"));
@@ -44,5 +44,9 @@ Object.defineProperty(exports, "validateDashboardTask", { enumerable: true, get:
44
44
  const UserConfig_1 = __importStar(require("./documents/dashboard/UserConfig"));
45
45
  exports.DashboardUserConfig = UserConfig_1.default;
46
46
  Object.defineProperty(exports, "validateDashboardUserConfig", { enumerable: true, get: function () { return UserConfig_1.validateDashboardUserConfig; } });
47
+ const RecurrenceInfo_1 = require("./embedded-types/dashboard/task/RecurrenceInfo");
48
+ Object.defineProperty(exports, "RecurrenceBasis", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceBasis; } });
49
+ Object.defineProperty(exports, "RecurrenceEffect", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceEffect; } });
50
+ Object.defineProperty(exports, "RecurrenceFrequencyType", { enumerable: true, get: function () { return RecurrenceInfo_1.RecurrenceFrequencyType; } });
47
51
  const RequiredUserId_1 = __importDefault(require("./schemas/required-refs/RequiredUserId"));
48
52
  exports.RequiredUserId = RequiredUserId_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aneuhold/core-ts-db-lib",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "A core database library used for personal projects",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",