@thisisagile/easy 7.40.10 → 7.41.2

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
@@ -261,9 +261,20 @@ The `When` class is a utility that is usually exposed through the `when()` funct
261
261
  The `reject()` method is used to reject the chain, so it will not execute any of its following statements. The `reject()` method accept any error type. A special case is made for `when().not.isValid`. This statement validates the subject of the `when`, and reject with the results (an instance of `Results`) if no parameter is passed to `reject()`.
262
262
 
263
263
  ## Authentication and Authorization
264
- Access to endpoints is configured using the `@requires` decorator group.
265
- If multiple decorators are added, all conditions must be met to access the endpoint.
264
+ Access to endpoints is configured using the `@requires` decorator group. If multiple decorators are added, all conditions must be met to access the endpoint. A resource class (which is the main entry to an **easy** service) with security decorators is shown in the following example.
266
265
 
267
- To use these decorators, the generic `security` middleware must be loaded first.
268
- In most cases, it should be added to the `pre` list of handlers of a service.
266
+ @route(ProductUri.Products)
267
+ export class ProductsResource {
268
+ constructor(readonly manage = new ManageProduct()) {}
269
+
270
+ @get()
271
+ @requires.useCase(UseCase.ViewProduct)
272
+ search = (req: Req): Promise<List<Product>> => this.manage.search(req.q);
273
+
274
+ @post()
275
+ @requires.useCase(UseCase.ManageProduct)
276
+ add = (req: Req): Promise<Product> => this.manage.add(req.body as Json);
277
+ }
278
+
279
+ To use these decorators, the generic `security` middleware must be loaded first. In most cases, it should be added to the `pre` list of handlers of a service.
269
280
  The security middleware takes an optional configuration object, which is documented [in code](packages/easy-express/src/express/SecurityHandler.ts).
@@ -1,6 +1,6 @@
1
1
  import { Value } from '../../types';
2
2
  import { Moment } from 'moment';
3
- export declare type DateTimeUnit = 'years' | 'quarters' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds';
3
+ export declare type DateTimeUnit = 'year' | 'years' | 'y' | 'quarter' | 'quarters' | 'Q' | 'month' | 'months' | 'M' | 'week' | 'weeks' | 'w' | 'day' | 'days' | 'd' | 'hour' | 'hours' | 'h' | 'minute' | 'minutes' | 'm' | 'second' | 'seconds' | 's' | 'millisecond' | 'milliseconds' | 'ms';
4
4
  export declare class DateTime extends Value<string | undefined> {
5
5
  constructor(value?: string | number | Date, format?: string);
6
6
  static get now(): DateTime;
@@ -13,6 +13,8 @@ export declare class DateTime extends Value<string | undefined> {
13
13
  add: (n: number, unit?: DateTimeUnit) => DateTime;
14
14
  subtract: (n: number, unit?: DateTimeUnit) => DateTime;
15
15
  diff: (other: DateTime, unit?: DateTimeUnit) => number;
16
+ startOf: (unit: DateTimeUnit) => DateTime;
17
+ endOf: (unit: DateTimeUnit) => DateTime;
16
18
  toString(): string;
17
19
  toLocale(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
18
20
  toDate(): Date | undefined;
@@ -12,6 +12,8 @@ class DateTime extends types_1.Value {
12
12
  this.add = (n, unit = 'days') => new DateTime(this.utc.add(n, unit).toISOString());
13
13
  this.subtract = (n, unit = 'days') => new DateTime(this.utc.subtract(n, unit).toISOString());
14
14
  this.diff = (other, unit = 'days') => this.utc.diff(other.utc, unit);
15
+ this.startOf = (unit) => new DateTime(this.utc.startOf(unit).toISOString());
16
+ this.endOf = (unit) => new DateTime(this.utc.endOf(unit).toISOString());
15
17
  }
16
18
  static get now() {
17
19
  return new DateTime(moment_1.default.utc().toISOString());
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../../src/domain/values/DateTime.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAsD;AACtD,oDAAwC;AAaxC,MAAa,QAAS,SAAQ,aAAyB;IACrD,YAAY,KAA8B,EAAE,MAAe;QACzD,KAAK,CAAC,IAAA,aAAK,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE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AC,CAAC;IAChD,CAAC;IAED,QAAQ,CAAC,EAAY;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,EAAY;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IAYD,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,UAA6B,OAAO,EAAE,UAAsC,EAAE;QACrF,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;CACF;AAtDD,4BAsDC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "7.40.10",
3
+ "version": "7.41.2",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "7.40.10",
34
+ "@thisisagile/easy-test": "7.41.2",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.5",
37
37
  "@types/validator": "^13.6.6"
@@ -2,15 +2,16 @@ import { isDefined, tryTo, Value } from '../../types';
2
2
  import moment, { Moment } from 'moment';
3
3
 
4
4
  export type DateTimeUnit =
5
- 'years'
6
- | 'quarters'
7
- | 'months'
8
- | 'weeks'
9
- | 'days'
10
- | 'hours'
11
- | 'minutes'
12
- | 'seconds'
13
- | 'milliseconds';
5
+ 'year' | 'years' | 'y' |
6
+ 'quarter' | 'quarters' | 'Q' |
7
+ 'month' | 'months' | 'M' |
8
+ 'week' | 'weeks' | 'w' |
9
+ 'day' | 'days' | 'd' |
10
+ 'hour' | 'hours' | 'h' |
11
+ 'minute' | 'minutes' | 'm' |
12
+ 'second' | 'seconds' | 's' |
13
+ 'millisecond' | 'milliseconds' | 'ms';
14
+
14
15
 
15
16
  export class DateTime extends Value<string | undefined> {
16
17
  constructor(value?: string | number | Date, format?: string) {
@@ -51,6 +52,10 @@ export class DateTime extends Value<string | undefined> {
51
52
 
52
53
  diff = (other: DateTime, unit: DateTimeUnit = 'days'): number => this.utc.diff(other.utc, unit);
53
54
 
55
+ startOf = (unit: DateTimeUnit): DateTime => new DateTime(this.utc.startOf(unit).toISOString())
56
+
57
+ endOf = (unit: DateTimeUnit): DateTime => new DateTime(this.utc.endOf(unit).toISOString())
58
+
54
59
  toString(): string {
55
60
  return this.value ?? '';
56
61
  }