@nmshd/runtime 2.0.0-beta.20 → 2.0.0-beta.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.
@@ -448,11 +448,11 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
448
448
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
449
449
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
450
450
  exports.buildInformation = {
451
- version: "2.0.0-beta.20",
452
- build: "106",
453
- date: "2022-08-25T08:33:05+00:00",
454
- commit: "9d3977f9788c489ac4a353b0fc4c183a35b8a365",
455
- dependencies: {"@js-soft/docdb-querytranslator":"1.1.0","@js-soft/logging-abstractions":"1.0.0","@js-soft/ts-serval":"2.0.4","@js-soft/ts-utils":"^2.2.2","@nmshd/consumption":"2.0.0-beta.10","@nmshd/content":"2.0.0-beta.13","@nmshd/crypto":"2.0.1","@nmshd/transport":"2.0.0-beta.4","ajv":"^8.11.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","luxon":"^3.0.1","qrcode":"1.5.1","reflect-metadata":"0.1.13","ts-simple-nameof":"1.3.1","typescript-ioc":"3.2.2"},
451
+ version: "2.0.0-beta.21",
452
+ build: "107",
453
+ date: "2022-09-05T12:27:48+00:00",
454
+ commit: "085c7c588c9938e918820540abd82c9fec4170b3",
455
+ dependencies: {"@js-soft/docdb-querytranslator":"1.1.0","@js-soft/logging-abstractions":"1.0.0","@js-soft/ts-serval":"2.0.4","@js-soft/ts-utils":"^2.2.2","@nmshd/consumption":"2.0.0-beta.11","@nmshd/content":"2.0.0-beta.13","@nmshd/crypto":"2.0.1","@nmshd/transport":"2.0.0-beta.4","ajv":"^8.11.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","luxon":"^3.0.3","qrcode":"1.5.1","reflect-metadata":"0.1.13","ts-simple-nameof":"1.3.1","typescript-ioc":"3.2.2"},
456
456
  libraries: {
457
457
  serval: ts_serval_1.buildInformation,
458
458
  consumption: consumption_1.buildInformation,
@@ -710,7 +710,11 @@ let DataViewExpander = class DataViewExpander {
710
710
  async expandRelationshipTemplateDTO(template) {
711
711
  let onNewRelationship;
712
712
  let onExistingRelationship;
713
- let name = "i18n://dvo.template.name";
713
+ const createdBy = await this.expandAddress(template.createdBy);
714
+ const type = template.isOwn ? "RelationshipTemplateDVO" : "PeerRelationshipTemplateDVO";
715
+ let name = template.isOwn ? "i18n://dvo.template.outgoing.name" : "i18n://dvo.template.incoming.name";
716
+ const description = template.isOwn ? "i18n://dvo.template.outgoing.description" : "i18n://dvo.template.incoming.description";
717
+ let expandedLocalRequest;
714
718
  if (template.content["@type"] === "RelationshipTemplateBody") {
715
719
  const templateBody = content_1.RelationshipTemplateBody.from(template.content).toJSON();
716
720
  if (templateBody.title) {
@@ -718,20 +722,28 @@ let DataViewExpander = class DataViewExpander {
718
722
  }
719
723
  let localRequest;
720
724
  if (!template.isOwn) {
721
- const onNewRelationshipRequest = await this.consumption.incomingRequests.getRequests({
725
+ const incomingRequestResult = await this.consumption.incomingRequests.getRequests({
722
726
  query: {
723
- "source.reference": template.id
727
+ "source.reference": template.id,
728
+ status: consumption_1.LocalRequestStatus.ManualDecisionRequired
724
729
  }
725
730
  });
726
- localRequest = onNewRelationshipRequest.value[0];
727
- return {
728
- name,
729
- type: "PeerRelationshipTemplateDVO",
730
- date: template.createdAt,
731
- ...template,
732
- createdBy: await this.expandAddress(template.createdBy),
733
- onNewRelationship: await this.expandLocalRequestDTO(localRequest)
734
- };
731
+ if (incomingRequestResult.value.length > 0) {
732
+ localRequest = incomingRequestResult.value[0];
733
+ expandedLocalRequest = await this.expandLocalRequestDTO(localRequest);
734
+ }
735
+ else {
736
+ const completedRequestResult = await this.consumption.incomingRequests.getRequests({
737
+ query: {
738
+ "source.reference": template.id,
739
+ status: [consumption_1.LocalRequestStatus.Decided, consumption_1.LocalRequestStatus.Completed]
740
+ }
741
+ });
742
+ if (completedRequestResult.value.length > 0) {
743
+ localRequest = completedRequestResult.value[0];
744
+ expandedLocalRequest = await this.expandLocalRequestDTO(localRequest);
745
+ }
746
+ }
735
747
  }
736
748
  onNewRelationship = await this.expandRequest(templateBody.onNewRelationship);
737
749
  if (templateBody.onExistingRelationship) {
@@ -740,10 +752,12 @@ let DataViewExpander = class DataViewExpander {
740
752
  }
741
753
  return {
742
754
  name,
743
- type: "RelationshipTemplateDVO",
755
+ description,
756
+ type,
744
757
  date: template.createdAt,
745
758
  ...template,
746
- createdBy: await this.expandAddress(template.createdBy),
759
+ createdBy,
760
+ request: expandedLocalRequest,
747
761
  onNewRelationship,
748
762
  onExistingRelationship
749
763
  };
@@ -983,10 +997,12 @@ let DataViewExpander = class DataViewExpander {
983
997
  }
984
998
  const directionLabel = request.isOwn ? "outgoing" : "incoming";
985
999
  const statusText = `i18n://dvo.localRequest.status.${request.status}`;
1000
+ const response = request.response ? await this.expandLocalResponseDTO(request.response, request) : undefined;
986
1001
  // TODO: Wait for request.title from content and use it
1002
+ const requestIdOutOfResponse = request.response ? request.response.content.requestId : "";
987
1003
  return {
988
1004
  ...request,
989
- id: request.id,
1005
+ id: request.id ? request.id : requestIdOutOfResponse,
990
1006
  content: requestDVO,
991
1007
  items: requestDVO.items,
992
1008
  name: `i18n://dvo.localRequest.${directionLabel}.name`,
@@ -996,7 +1012,7 @@ let DataViewExpander = class DataViewExpander {
996
1012
  createdBy: request.isOwn ? this.expandSelf() : peerDVO,
997
1013
  decider: request.isOwn ? peerDVO : this.expandSelf(),
998
1014
  peer: peerDVO,
999
- response: request.response ? await this.expandLocalResponseDTO(request.response, request) : undefined,
1015
+ response,
1000
1016
  statusText: statusText,
1001
1017
  isDecidable
1002
1018
  };
@@ -1403,7 +1419,8 @@ let DataViewExpander = class DataViewExpander {
1403
1419
  items: expandedAttributes,
1404
1420
  nameMap: stringByType,
1405
1421
  changes: changes,
1406
- changeCount: changes.length
1422
+ changeCount: changes.length,
1423
+ templateId: relationship.template.id
1407
1424
  };
1408
1425
  }
1409
1426
  async expandRelationshipDTO(relationship) {
@@ -5524,7 +5541,7 @@ const ajv_formats_1 = __importDefault(__webpack_require__(/*! ajv-formats */ "./
5524
5541
  class SchemaRepository {
5525
5542
  constructor() {
5526
5543
  this.jsonSchemas = new Map();
5527
- this.compiler = new ajv_1.default({ allErrors: true });
5544
+ this.compiler = new ajv_1.default({ allErrors: true, allowUnionTypes: true });
5528
5545
  (0, ajv_formats_1.default)(this.compiler);
5529
5546
  (0, ajv_errors_1.default)(this.compiler);
5530
5547
  }
@@ -35765,7 +35782,8 @@ function clone$1(dur, alts, clear = false) {
35765
35782
  ...(alts.values || {})
35766
35783
  },
35767
35784
  loc: dur.loc.clone(alts.loc),
35768
- conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
35785
+ conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
35786
+ matrix: alts.matrix || dur.matrix
35769
35787
  };
35770
35788
  return new Duration(conf);
35771
35789
  }
@@ -35804,7 +35822,7 @@ function normalizeValues(matrix, vals) {
35804
35822
  *
35805
35823
  * Here is a brief overview of commonly used methods and getters in Duration:
35806
35824
  *
35807
- * * **Creation** To create a Duration, use {@link Duration#fromMillis}, {@link Duration#fromObject}, or {@link Duration#fromISO}.
35825
+ * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
35808
35826
  * * **Unit values** See the {@link Duration#years}, {@link Duration#months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, {@link Duration#seconds}, {@link Duration#milliseconds} accessors.
35809
35827
  * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
35810
35828
  * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, {@link Duration#shiftTo}, and {@link Duration#negate}.
@@ -35820,10 +35838,16 @@ class Duration {
35820
35838
  */
35821
35839
  constructor(config) {
35822
35840
  const accurate = config.conversionAccuracy === "longterm" || false;
35841
+ let matrix = accurate ? accurateMatrix : casualMatrix;
35842
+
35843
+ if (config.matrix) {
35844
+ matrix = config.matrix;
35845
+ }
35823
35846
  /**
35824
35847
  * @access private
35825
35848
  */
35826
35849
 
35850
+
35827
35851
  this.values = config.values;
35828
35852
  /**
35829
35853
  * @access private
@@ -35844,7 +35868,7 @@ class Duration {
35844
35868
  * @access private
35845
35869
  */
35846
35870
 
35847
- this.matrix = accurate ? accurateMatrix : casualMatrix;
35871
+ this.matrix = matrix;
35848
35872
  /**
35849
35873
  * @access private
35850
35874
  */
@@ -35883,7 +35907,8 @@ class Duration {
35883
35907
  * @param {Object} [opts=[]] - options for creating this Duration
35884
35908
  * @param {string} [opts.locale='en-US'] - the locale to use
35885
35909
  * @param {string} opts.numberingSystem - the numbering system to use
35886
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
35910
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
35911
+ * @param {string} [opts.matrix=Object] - the custom conversion system to use
35887
35912
  * @return {Duration}
35888
35913
  */
35889
35914
 
@@ -35896,7 +35921,8 @@ class Duration {
35896
35921
  return new Duration({
35897
35922
  values: normalizeObject(obj, Duration.normalizeUnit),
35898
35923
  loc: Locale.fromObject(opts),
35899
- conversionAccuracy: opts.conversionAccuracy
35924
+ conversionAccuracy: opts.conversionAccuracy,
35925
+ matrix: opts.matrix
35900
35926
  });
35901
35927
  }
35902
35928
  /**
@@ -35928,7 +35954,8 @@ class Duration {
35928
35954
  * @param {Object} opts - options for parsing
35929
35955
  * @param {string} [opts.locale='en-US'] - the locale to use
35930
35956
  * @param {string} opts.numberingSystem - the numbering system to use
35931
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
35957
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
35958
+ * @param {string} [opts.matrix=Object] - the preset conversion system to use
35932
35959
  * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
35933
35960
  * @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
35934
35961
  * @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
@@ -35952,7 +35979,8 @@ class Duration {
35952
35979
  * @param {Object} opts - options for parsing
35953
35980
  * @param {string} [opts.locale='en-US'] - the locale to use
35954
35981
  * @param {string} opts.numberingSystem - the numbering system to use
35955
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
35982
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
35983
+ * @param {string} [opts.matrix=Object] - the conversion system to use
35956
35984
  * @see https://en.wikipedia.org/wiki/ISO_8601#Times
35957
35985
  * @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
35958
35986
  * @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
@@ -36283,7 +36311,7 @@ class Duration {
36283
36311
  * Scale this Duration by the specified amount. Return a newly-constructed Duration.
36284
36312
  * @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
36285
36313
  * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
36286
- * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
36314
+ * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
36287
36315
  * @return {Duration}
36288
36316
  */
36289
36317
 
@@ -36341,20 +36369,18 @@ class Duration {
36341
36369
  reconfigure({
36342
36370
  locale,
36343
36371
  numberingSystem,
36344
- conversionAccuracy
36372
+ conversionAccuracy,
36373
+ matrix
36345
36374
  } = {}) {
36346
36375
  const loc = this.loc.clone({
36347
36376
  locale,
36348
36377
  numberingSystem
36349
- }),
36350
- opts = {
36351
- loc
36378
+ });
36379
+ const opts = {
36380
+ loc,
36381
+ matrix,
36382
+ conversionAccuracy
36352
36383
  };
36353
-
36354
- if (conversionAccuracy) {
36355
- opts.conversionAccuracy = conversionAccuracy;
36356
- }
36357
-
36358
36384
  return clone$1(this, opts);
36359
36385
  }
36360
36386
  /**
@@ -36628,10 +36654,10 @@ function validateStartEnd(start, end) {
36628
36654
  *
36629
36655
  * Here is a brief overview of the most commonly used methods and getters in Interval:
36630
36656
  *
36631
- * * **Creation** To create an Interval, use {@link Interval#fromDateTimes}, {@link Interval#after}, {@link Interval#before}, or {@link Interval#fromISO}.
36657
+ * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
36632
36658
  * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
36633
36659
  * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}.
36634
- * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval#merge}, {@link Interval#xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
36660
+ * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
36635
36661
  * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
36636
36662
  * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}.
36637
36663
  */
@@ -38072,7 +38098,6 @@ function expandMacroTokens(tokens, locale) {
38072
38098
  * @private
38073
38099
  */
38074
38100
 
38075
-
38076
38101
  function explainFromTokens(locale, input, format) {
38077
38102
  const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
38078
38103
  units = tokens.map(t => unitForToken(t, locale)),
@@ -38668,7 +38693,7 @@ function lastOpts(argList) {
38668
38693
  *
38669
38694
  * Here is a brief overview of the most commonly used functionality it provides:
38670
38695
  *
38671
- * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime#local}, {@link DateTime#utc}, and (most flexibly) {@link DateTime#fromObject}. To create one from a standard string format, use {@link DateTime#fromISO}, {@link DateTime#fromHTTP}, and {@link DateTime#fromRFC2822}. To create one from a custom string format, use {@link DateTime#fromFormat}. To create one from a native JS date, use {@link DateTime#fromJSDate}.
38696
+ * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
38672
38697
  * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month},
38673
38698
  * {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
38674
38699
  * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
@@ -39207,6 +39232,19 @@ class DateTime {
39207
39232
  static parseFormatForOpts(formatOpts, localeOpts = {}) {
39208
39233
  const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
39209
39234
  return !tokenList ? null : tokenList.map(t => t ? t.val : null).join("");
39235
+ }
39236
+ /**
39237
+ * Produce the the fully expanded format token for the locale
39238
+ * Does NOT quote characters, so quoted tokens will not round trip correctly
39239
+ * @param fmt
39240
+ * @param localeOpts
39241
+ * @returns {string}
39242
+ */
39243
+
39244
+
39245
+ static expandFormat(fmt, localeOpts = {}) {
39246
+ const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
39247
+ return expanded.map(t => t.val).join("");
39210
39248
  } // INFO
39211
39249
 
39212
39250
  /**
@@ -39899,8 +39937,8 @@ class DateTime {
39899
39937
  * @param {Object} opts - opts to override the configuration options on this DateTime
39900
39938
  * @example DateTime.now().toLocaleString(); //=> 4/20/2017
39901
39939
  * @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
39902
- * @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
39903
39940
  * @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
39941
+ * @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
39904
39942
  * @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
39905
39943
  * @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
39906
39944
  * @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
@@ -39937,7 +39975,7 @@ class DateTime {
39937
39975
  * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
39938
39976
  * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
39939
39977
  * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
39940
- * @param {boolean} [opts.extendedZone=true] - add the time zone format extension
39978
+ * @param {boolean} [opts.extendedZone=false] - add the time zone format extension
39941
39979
  * @param {string} [opts.format='extended'] - choose between the basic and extended format
39942
39980
  * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
39943
39981
  * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
@@ -40642,7 +40680,7 @@ function friendlyDateTime(dateTimeish) {
40642
40680
  }
40643
40681
  }
40644
40682
 
40645
- const VERSION = "3.0.1";
40683
+ const VERSION = "3.0.3";
40646
40684
 
40647
40685
  exports.DateTime = DateTime;
40648
40686
  exports.Duration = Duration;