@cratis/arc 23.1.0 → 23.3.0

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.
Files changed (166) hide show
  1. package/availability/Availability.ts +80 -0
  2. package/availability/AvailabilityReason.ts +9 -0
  3. package/availability/AvailableParts.ts +30 -0
  4. package/availability/ObserveAvailableParts.ts +24 -0
  5. package/availability/UnavailablePart.ts +19 -0
  6. package/availability/for_Availability/when_asking_whether_a_part_is_available/and_nothing_is_known_yet.ts +11 -0
  7. package/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_it_by_name.ts +11 -0
  8. package/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_its_slice.ts +22 -0
  9. package/availability/for_Availability/when_everything_is_available.ts +8 -0
  10. package/availability/for_Availability/when_filtering/and_some_items_are_not_available.ts +16 -0
  11. package/availability/index.ts +9 -0
  12. package/availability/isNotAvailable.ts +14 -0
  13. package/commands/CommandResult.ts +32 -0
  14. package/commands/ICommandResult.ts +6 -0
  15. package/commands/for_CommandResult/when_the_command_is_forbidden.ts +24 -0
  16. package/commands/for_CommandResult/when_the_failure_is_retryable.ts +24 -0
  17. package/commands/for_CommandResult/when_the_part_is_not_available.ts +28 -0
  18. package/dist/cjs/availability/Availability.d.ts +26 -0
  19. package/dist/cjs/availability/Availability.d.ts.map +1 -0
  20. package/dist/cjs/availability/Availability.js +62 -0
  21. package/dist/cjs/availability/Availability.js.map +1 -0
  22. package/dist/cjs/availability/AvailabilityReason.d.ts +2 -0
  23. package/dist/cjs/availability/AvailabilityReason.d.ts.map +1 -0
  24. package/dist/cjs/availability/AvailabilityReason.js +12 -0
  25. package/dist/cjs/availability/AvailabilityReason.js.map +1 -0
  26. package/dist/cjs/availability/AvailableParts.d.ts +11 -0
  27. package/dist/cjs/availability/AvailableParts.d.ts.map +1 -0
  28. package/dist/cjs/availability/AvailableParts.js +55 -0
  29. package/dist/cjs/availability/AvailableParts.js.map +1 -0
  30. package/dist/cjs/availability/ObserveAvailableParts.d.ts +11 -0
  31. package/dist/cjs/availability/ObserveAvailableParts.d.ts.map +1 -0
  32. package/dist/cjs/availability/ObserveAvailableParts.js +24 -0
  33. package/dist/cjs/availability/ObserveAvailableParts.js.map +1 -0
  34. package/dist/cjs/availability/UnavailablePart.d.ts +7 -0
  35. package/dist/cjs/availability/UnavailablePart.d.ts.map +1 -0
  36. package/dist/cjs/availability/index.d.ts +7 -0
  37. package/dist/cjs/availability/index.d.ts.map +1 -0
  38. package/dist/cjs/availability/index.js +18 -0
  39. package/dist/cjs/availability/index.js.map +1 -0
  40. package/dist/cjs/availability/isNotAvailable.d.ts +5 -0
  41. package/dist/cjs/availability/isNotAvailable.d.ts.map +1 -0
  42. package/dist/cjs/availability/isNotAvailable.js +17 -0
  43. package/dist/cjs/availability/isNotAvailable.js.map +1 -0
  44. package/dist/cjs/commands/CommandResult.d.ts +5 -0
  45. package/dist/cjs/commands/CommandResult.d.ts.map +1 -1
  46. package/dist/cjs/commands/CommandResult.js +20 -0
  47. package/dist/cjs/commands/CommandResult.js.map +1 -1
  48. package/dist/cjs/commands/ICommandResult.d.ts +1 -0
  49. package/dist/cjs/commands/ICommandResult.d.ts.map +1 -1
  50. package/dist/cjs/index.d.ts +2 -1
  51. package/dist/cjs/index.d.ts.map +1 -1
  52. package/dist/cjs/index.js +14 -12
  53. package/dist/cjs/index.js.map +1 -1
  54. package/dist/cjs/queries/IQueryResult.d.ts +2 -0
  55. package/dist/cjs/queries/IQueryResult.d.ts.map +1 -1
  56. package/dist/cjs/queries/QueryInstanceCache.d.ts.map +1 -1
  57. package/dist/cjs/queries/QueryInstanceCache.js +2 -2
  58. package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
  59. package/dist/cjs/queries/QueryResult.d.ts +4 -0
  60. package/dist/cjs/queries/QueryResult.d.ts.map +1 -1
  61. package/dist/cjs/queries/QueryResult.js +4 -0
  62. package/dist/cjs/queries/QueryResult.js.map +1 -1
  63. package/dist/cjs/queries/QueryResultWithState.d.ts +3 -1
  64. package/dist/cjs/queries/QueryResultWithState.d.ts.map +1 -1
  65. package/dist/cjs/queries/QueryResultWithState.js +6 -2
  66. package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
  67. package/dist/esm/availability/Availability.d.ts +26 -0
  68. package/dist/esm/availability/Availability.d.ts.map +1 -0
  69. package/dist/esm/availability/Availability.js +60 -0
  70. package/dist/esm/availability/Availability.js.map +1 -0
  71. package/dist/esm/availability/AvailabilityReason.d.ts +2 -0
  72. package/dist/esm/availability/AvailabilityReason.d.ts.map +1 -0
  73. package/dist/esm/availability/AvailabilityReason.js +10 -0
  74. package/dist/esm/availability/AvailabilityReason.js.map +1 -0
  75. package/dist/esm/availability/AvailableParts.d.ts +11 -0
  76. package/dist/esm/availability/AvailableParts.d.ts.map +1 -0
  77. package/dist/esm/availability/AvailableParts.js +52 -0
  78. package/dist/esm/availability/AvailableParts.js.map +1 -0
  79. package/dist/esm/availability/ObserveAvailableParts.d.ts +11 -0
  80. package/dist/esm/availability/ObserveAvailableParts.d.ts.map +1 -0
  81. package/dist/esm/availability/ObserveAvailableParts.js +22 -0
  82. package/dist/esm/availability/ObserveAvailableParts.js.map +1 -0
  83. package/dist/esm/availability/UnavailablePart.d.ts +7 -0
  84. package/dist/esm/availability/UnavailablePart.d.ts.map +1 -0
  85. package/dist/esm/availability/UnavailablePart.js +2 -0
  86. package/dist/esm/availability/UnavailablePart.js.map +1 -0
  87. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_nothing_is_known_yet.d.ts +2 -0
  88. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_nothing_is_known_yet.d.ts.map +1 -0
  89. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_nothing_is_known_yet.js +7 -0
  90. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_nothing_is_known_yet.js.map +1 -0
  91. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_it_by_name.d.ts +2 -0
  92. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_it_by_name.d.ts.map +1 -0
  93. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_it_by_name.js +7 -0
  94. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_it_by_name.js.map +1 -0
  95. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_its_slice.d.ts +2 -0
  96. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_its_slice.d.ts.map +1 -0
  97. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_its_slice.js +18 -0
  98. package/dist/esm/availability/for_Availability/when_asking_whether_a_part_is_available/and_the_server_lists_its_slice.js.map +1 -0
  99. package/dist/esm/availability/for_Availability/when_everything_is_available.d.ts +2 -0
  100. package/dist/esm/availability/for_Availability/when_everything_is_available.d.ts.map +1 -0
  101. package/dist/esm/availability/for_Availability/when_everything_is_available.js +5 -0
  102. package/dist/esm/availability/for_Availability/when_everything_is_available.js.map +1 -0
  103. package/dist/esm/availability/for_Availability/when_filtering/and_some_items_are_not_available.d.ts +2 -0
  104. package/dist/esm/availability/for_Availability/when_filtering/and_some_items_are_not_available.d.ts.map +1 -0
  105. package/dist/esm/availability/for_Availability/when_filtering/and_some_items_are_not_available.js +12 -0
  106. package/dist/esm/availability/for_Availability/when_filtering/and_some_items_are_not_available.js.map +1 -0
  107. package/dist/esm/availability/index.d.ts +7 -0
  108. package/dist/esm/availability/index.d.ts.map +1 -0
  109. package/dist/esm/availability/index.js +9 -0
  110. package/dist/esm/availability/index.js.map +1 -0
  111. package/dist/esm/availability/isNotAvailable.d.ts +5 -0
  112. package/dist/esm/availability/isNotAvailable.d.ts.map +1 -0
  113. package/dist/esm/availability/isNotAvailable.js +15 -0
  114. package/dist/esm/availability/isNotAvailable.js.map +1 -0
  115. package/dist/esm/commands/CommandResult.d.ts +5 -0
  116. package/dist/esm/commands/CommandResult.d.ts.map +1 -1
  117. package/dist/esm/commands/CommandResult.js +20 -0
  118. package/dist/esm/commands/CommandResult.js.map +1 -1
  119. package/dist/esm/commands/ICommandResult.d.ts +1 -0
  120. package/dist/esm/commands/ICommandResult.d.ts.map +1 -1
  121. package/dist/esm/commands/for_CommandResult/when_the_command_is_forbidden.d.ts +2 -0
  122. package/dist/esm/commands/for_CommandResult/when_the_command_is_forbidden.d.ts.map +1 -0
  123. package/dist/esm/commands/for_CommandResult/when_the_command_is_forbidden.js +20 -0
  124. package/dist/esm/commands/for_CommandResult/when_the_command_is_forbidden.js.map +1 -0
  125. package/dist/esm/commands/for_CommandResult/when_the_failure_is_retryable.d.ts +2 -0
  126. package/dist/esm/commands/for_CommandResult/when_the_failure_is_retryable.d.ts.map +1 -0
  127. package/dist/esm/commands/for_CommandResult/when_the_failure_is_retryable.js +20 -0
  128. package/dist/esm/commands/for_CommandResult/when_the_failure_is_retryable.js.map +1 -0
  129. package/dist/esm/commands/for_CommandResult/when_the_part_is_not_available.d.ts +2 -0
  130. package/dist/esm/commands/for_CommandResult/when_the_part_is_not_available.d.ts.map +1 -0
  131. package/dist/esm/commands/for_CommandResult/when_the_part_is_not_available.js +24 -0
  132. package/dist/esm/commands/for_CommandResult/when_the_part_is_not_available.js.map +1 -0
  133. package/dist/esm/index.d.ts +2 -1
  134. package/dist/esm/index.d.ts.map +1 -1
  135. package/dist/esm/index.js +14 -12
  136. package/dist/esm/index.js.map +1 -1
  137. package/dist/esm/queries/IQueryResult.d.ts +2 -0
  138. package/dist/esm/queries/IQueryResult.d.ts.map +1 -1
  139. package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -1
  140. package/dist/esm/queries/QueryInstanceCache.js +2 -2
  141. package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
  142. package/dist/esm/queries/QueryResult.d.ts +4 -0
  143. package/dist/esm/queries/QueryResult.d.ts.map +1 -1
  144. package/dist/esm/queries/QueryResult.js +4 -0
  145. package/dist/esm/queries/QueryResult.js.map +1 -1
  146. package/dist/esm/queries/QueryResultWithState.d.ts +3 -1
  147. package/dist/esm/queries/QueryResultWithState.d.ts.map +1 -1
  148. package/dist/esm/queries/QueryResultWithState.js +6 -2
  149. package/dist/esm/queries/QueryResultWithState.js.map +1 -1
  150. package/dist/esm/queries/for_QueryResult/when_the_failure_is_retryable.d.ts +2 -0
  151. package/dist/esm/queries/for_QueryResult/when_the_failure_is_retryable.d.ts.map +1 -0
  152. package/dist/esm/queries/for_QueryResult/when_the_failure_is_retryable.js +20 -0
  153. package/dist/esm/queries/for_QueryResult/when_the_failure_is_retryable.js.map +1 -0
  154. package/dist/esm/queries/for_QueryResult/when_the_part_is_not_available.d.ts +2 -0
  155. package/dist/esm/queries/for_QueryResult/when_the_part_is_not_available.d.ts.map +1 -0
  156. package/dist/esm/queries/for_QueryResult/when_the_part_is_not_available.js +21 -0
  157. package/dist/esm/queries/for_QueryResult/when_the_part_is_not_available.js.map +1 -0
  158. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  159. package/index.ts +2 -0
  160. package/package.json +11 -1
  161. package/queries/IQueryResult.ts +12 -0
  162. package/queries/QueryInstanceCache.ts +4 -0
  163. package/queries/QueryResult.ts +10 -0
  164. package/queries/QueryResultWithState.ts +4 -0
  165. package/queries/for_QueryResult/when_the_failure_is_retryable.ts +24 -0
  166. package/queries/for_QueryResult/when_the_part_is_not_available.ts +25 -0
@@ -0,0 +1,80 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { UnavailablePart } from './UnavailablePart.js';
5
+
6
+ /**
7
+ * Something a client can ask about: the full name of a command or read model on the server, or a generated proxy
8
+ * (class or instance) that carries the slice it belongs to.
9
+ */
10
+ export type AvailabilityPart =
11
+ | string
12
+ | { readonly sliceLocation?: { readonly module: string; readonly feature: string; readonly slice: string } }
13
+ | { readonly constructor: { readonly sliceLocation?: { readonly module: string; readonly feature: string; readonly slice: string } } };
14
+
15
+ /**
16
+ * Represents what is available to the current context, from the last decision the server reported.
17
+ *
18
+ * Everything the server does not list is available. Until the first decision has arrived nothing is known, and
19
+ * nothing is reported as available, so a client never shows a part it has not been told it may show.
20
+ */
21
+ export class Availability {
22
+ /** An availability that has not heard from the server yet. */
23
+ static readonly unknown: Availability = new Availability([], false);
24
+
25
+ /** An availability that treats every part as available, for hosts that do not use availability. */
26
+ static readonly everything: Availability = new Availability([], true);
27
+
28
+ /**
29
+ * Initializes a new instance of {@link Availability}.
30
+ * @param unavailable The parts the server reported as not available.
31
+ * @param isKnown Whether a decision has arrived.
32
+ */
33
+ constructor(readonly unavailable: readonly UnavailablePart[], readonly isKnown: boolean = true) {
34
+ }
35
+
36
+ /**
37
+ * Determines whether a part is available.
38
+ * @param part The full name of a command or read model, or a generated proxy. A proxy is matched by the slice it
39
+ * belongs to, so every part of a slice is hidden together, which is how navigation and screens are decided.
40
+ * @returns True when the part is available; false when it is not, or when nothing is known yet.
41
+ */
42
+ isAvailable(part: AvailabilityPart): boolean {
43
+ if (!this.isKnown) {
44
+ return false;
45
+ }
46
+
47
+ if (typeof part === 'string') {
48
+ return !this.unavailable.some(_ => _.name === part);
49
+ }
50
+
51
+ const location = sliceLocationOf(part);
52
+ if (location === undefined || (location.module === '' && location.feature === '' && location.slice === '')) {
53
+ return true;
54
+ }
55
+
56
+ return !this.unavailable.some(_ => _.module === location.module && _.feature === location.feature && _.slice === location.slice);
57
+ }
58
+
59
+ /**
60
+ * Keeps the items whose part is available.
61
+ * @param items The items, for example navigation entries.
62
+ * @param partOf Gets the part an item belongs to; an item without one is always kept.
63
+ * @returns The items that are available.
64
+ */
65
+ filter<TItem>(items: readonly TItem[], partOf: (item: TItem) => AvailabilityPart | undefined): TItem[] {
66
+ return items.filter(item => {
67
+ const part = partOf(item);
68
+ return part === undefined || this.isAvailable(part);
69
+ });
70
+ }
71
+ }
72
+
73
+ function sliceLocationOf(part: Exclude<AvailabilityPart, string>): { module: string; feature: string; slice: string } | undefined {
74
+ const own = (part as { sliceLocation?: { module: string; feature: string; slice: string } }).sliceLocation;
75
+ if (own !== undefined) {
76
+ return own;
77
+ }
78
+
79
+ return (part as { constructor?: { sliceLocation?: { module: string; feature: string; slice: string } } }).constructor?.sliceLocation;
80
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * The authorization failure reason of a command or query result when its part of the application is not available
6
+ * to the caller. It is distinct from being forbidden: availability decides whether a part exists for the caller at
7
+ * all, authorization decides what the caller may do in it.
8
+ */
9
+ export const NotAvailable = 'NotAvailable';
@@ -0,0 +1,30 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { field } from '@cratis/fundamentals';
5
+ import { UnavailablePart } from './UnavailablePart.js';
6
+
7
+ /**
8
+ * The part of an unavailable-parts message that names one part. Matches {@link UnavailablePart}.
9
+ */
10
+ export class UnavailablePartModel implements UnavailablePart {
11
+ @field(String)
12
+ name = '';
13
+
14
+ @field(String)
15
+ module = '';
16
+
17
+ @field(String)
18
+ feature = '';
19
+
20
+ @field(String)
21
+ slice = '';
22
+ }
23
+
24
+ /**
25
+ * What is not available to the current context, as the server reports it. Everything not listed is available.
26
+ */
27
+ export class AvailableParts {
28
+ @field(UnavailablePartModel, true)
29
+ unavailable: UnavailablePartModel[] = [];
30
+ }
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ObservableQueryFor } from '../queries/ObservableQueryFor.js';
5
+ import { ParameterDescriptor } from '../reflection/ParameterDescriptor.js';
6
+ import { AvailableParts } from './AvailableParts.js';
7
+
8
+ /**
9
+ * Observes what is not available to the current context. It reports the current decision first and again every time
10
+ * it changes, so an open session updates without a reload.
11
+ */
12
+ export class ObserveAvailableParts extends ObservableQueryFor<AvailableParts> {
13
+ readonly route = '/.cratis/availability';
14
+ readonly defaultValue = new AvailableParts();
15
+ readonly parameterDescriptors: ParameterDescriptor[] = [];
16
+
17
+ get requiredRequestParameters(): string[] {
18
+ return [];
19
+ }
20
+
21
+ constructor() {
22
+ super(AvailableParts, false);
23
+ }
24
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * Represents a command or read model that is not available to the current context.
6
+ */
7
+ export interface UnavailablePart {
8
+ /** The name of the part: the full name of its command or read model type on the server. */
9
+ readonly name: string;
10
+
11
+ /** The module of the slice the part belongs to; empty when it has none. */
12
+ readonly module: string;
13
+
14
+ /** The feature of the slice the part belongs to; empty when it has none. */
15
+ readonly feature: string;
16
+
17
+ /** The slice the part belongs to; empty when it has none. */
18
+ readonly slice: string;
19
+ }
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Availability } from '../../Availability.js';
5
+
6
+ describe('when asking whether a part is available and nothing is known yet', () => {
7
+ const availability = Availability.unknown;
8
+
9
+ it('should not report a name as available', () => availability.isAvailable('Fleet.Quality.ScoresReadModel').should.be.false);
10
+ it('should not report a proxy as available', () => availability.isAvailable({ sliceLocation: { module: 'Fleet', feature: 'Quality', slice: 'Scores' } }).should.be.false);
11
+ });
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Availability } from '../../Availability.js';
5
+
6
+ describe('when asking whether a part is available and the server lists it by name', () => {
7
+ const availability = new Availability([{ name: 'Fleet.Quality.ResetScore', module: 'Fleet', feature: 'Quality', slice: 'ResetScore' }]);
8
+
9
+ it('should report the listed part as not available', () => availability.isAvailable('Fleet.Quality.ResetScore').should.be.false);
10
+ it('should report another part as available', () => availability.isAvailable('Fleet.Quality.Scores').should.be.true);
11
+ });
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Availability } from '../../Availability.js';
5
+
6
+ describe('when asking whether a part is available and the server lists its slice', () => {
7
+ const availability = new Availability([{ name: 'Fleet.Quality.Scores.Query', module: 'Fleet', feature: 'Quality', slice: 'Scores' }]);
8
+ class UnavailableProxy {
9
+ static readonly sliceLocation = { module: 'Fleet', feature: 'Quality', slice: 'Scores' };
10
+ }
11
+ class AvailableProxy {
12
+ static readonly sliceLocation = { module: 'Fleet', feature: 'Billing', slice: 'Invoices' };
13
+ }
14
+ class UnlocatedProxy {
15
+ static readonly sliceLocation = { module: '', feature: '', slice: '' };
16
+ }
17
+
18
+ it('should report a proxy class of that slice as not available', () => availability.isAvailable(UnavailableProxy).should.be.false);
19
+ it('should report an instance of a proxy of that slice as not available', () => availability.isAvailable(new UnavailableProxy()).should.be.false);
20
+ it('should report a proxy of another slice as available', () => availability.isAvailable(AvailableProxy).should.be.true);
21
+ it('should report a proxy with no slice as available', () => availability.isAvailable(UnlocatedProxy).should.be.true);
22
+ });
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Availability } from '../Availability.js';
5
+
6
+ describe('when everything is available', () => {
7
+ it('should report any part as available', () => Availability.everything.isAvailable('Fleet.Quality.Scores').should.be.true);
8
+ });
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Availability } from '../../Availability.js';
5
+
6
+ describe('when filtering and some items are not available', () => {
7
+ const availability = new Availability([{ name: 'Fleet.Quality.Scores', module: 'Fleet', feature: 'Quality', slice: 'Scores' }]);
8
+ const items = [
9
+ { title: 'Scores', part: 'Fleet.Quality.Scores' },
10
+ { title: 'Invoices', part: 'Fleet.Billing.Invoices' },
11
+ { title: 'Home', part: undefined as string | undefined }
12
+ ];
13
+ const result = availability.filter(items, _ => _.part);
14
+
15
+ it('should drop the item that is not available', () => result.map(_ => _.title).should.deep.equal(['Invoices', 'Home']));
16
+ });
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ export * from './AvailabilityReason.js';
5
+ export * from './isNotAvailable.js';
6
+ export * from './UnavailablePart.js';
7
+ export * from './AvailableParts.js';
8
+ export * from './ObserveAvailableParts.js';
9
+ export * from './Availability.js';
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { NotAvailable } from './AvailabilityReason.js';
5
+
6
+ /**
7
+ * Determines whether a command or query result was refused because its part of the application is not available to
8
+ * the caller. This is not the same as being forbidden: the caller is not told whether it would have been allowed.
9
+ * @param result The result of a command or a query.
10
+ * @returns True when the part is not available.
11
+ */
12
+ export function isNotAvailable(result: { readonly isAuthorized: boolean; readonly authorizationFailureReason?: string }): boolean {
13
+ return !result.isAuthorized && result.authorizationFailureReason === NotAvailable;
14
+ }
@@ -4,6 +4,7 @@
4
4
  import { Guid } from '@cratis/fundamentals';
5
5
  import { ICommandResult } from './ICommandResult.js';
6
6
  import { ValidationResult } from '../validation/ValidationResult.js';
7
+ import { isNotAvailable } from '../availability/isNotAvailable.js';
7
8
  import { Constructor, JsonSerializer } from '@cratis/fundamentals';
8
9
 
9
10
  /**
@@ -26,6 +27,11 @@ type OnException = (messages: string[], stackTrace: string) => void;
26
27
  */
27
28
  type OnUnauthorized = () => void;
28
29
 
30
+ /**
31
+ * Delegate type for the onNotAvailable callback.
32
+ */
33
+ type OnNotAvailable = () => void;
34
+
29
35
  /**
30
36
  * Delegate type for the onValidationFailure callback.
31
37
  */
@@ -48,6 +54,7 @@ type ServerCommandResult = {
48
54
  exceptionMessages: string[];
49
55
  exceptionStackTrace: string;
50
56
  authorizationFailureReason: string;
57
+ isRetryable?: boolean;
51
58
 
52
59
  /* eslint-disable @typescript-eslint/no-explicit-any */
53
60
  response: any;
@@ -136,6 +143,9 @@ export class CommandResult<TResponse = object> implements ICommandResult<TRespon
136
143
  /** @inheritdoc */
137
144
  readonly authorizationFailureReason: string;
138
145
 
146
+ /** @inheritdoc */
147
+ readonly isRetryable: boolean;
148
+
139
149
  /** @inheritdoc */
140
150
  readonly response?: TResponse;
141
151
 
@@ -155,6 +165,8 @@ export class CommandResult<TResponse = object> implements ICommandResult<TRespon
155
165
  this.exceptionMessages = result.exceptionMessages;
156
166
  this.exceptionStackTrace = result.exceptionStackTrace;
157
167
  this.authorizationFailureReason = result.authorizationFailureReason;
168
+ // Older servers do not report retryable failures; none of their results are.
169
+ this.isRetryable = result.isRetryable ?? false;
158
170
 
159
171
  if (result.response !== undefined && result.response !== null) {
160
172
  const isPrimitive = responseInstanceType === String || responseInstanceType === Number || responseInstanceType === Boolean;
@@ -220,6 +232,26 @@ export class CommandResult<TResponse = object> implements ICommandResult<TRespon
220
232
  return this;
221
233
  }
222
234
 
235
+ /**
236
+ * Gets whether the command was refused because its part of the application is not available to the caller.
237
+ * This is not the same as being forbidden: the caller is not told whether it would have been allowed.
238
+ */
239
+ get isNotAvailable(): boolean {
240
+ return isNotAvailable(this);
241
+ }
242
+
243
+ /**
244
+ * Set up a callback for when the command was refused because its part of the application is not available.
245
+ * @param {OnNotAvailable} callback The callback to call when the command was not available.
246
+ * @returns {CommandResult} The instance of the command result.
247
+ */
248
+ onNotAvailable(callback: OnNotAvailable): CommandResult<TResponse> {
249
+ if (this.isNotAvailable) {
250
+ callback();
251
+ }
252
+ return this;
253
+ }
254
+
223
255
  /**
224
256
  * Set up a callback for when the command had validation errors.
225
257
  * @param {OnSuccess} callback The callback to call when the command was invalid.
@@ -48,6 +48,12 @@ import { ValidationResult } from '../validation/ValidationResult.js';
48
48
  */
49
49
  readonly authorizationFailureReason: string;
50
50
 
51
+ /**
52
+ * Gets whether the failure is temporary and the same command can succeed when retried. It is never a denial.
53
+ * Servers that do not report it are read as false.
54
+ */
55
+ readonly isRetryable?: boolean;
56
+
51
57
  /**
52
58
  * Gets the stack trace if there was an exception.
53
59
  */
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { CommandResult } from '../CommandResult.js';
5
+
6
+ describe('when the command is forbidden for another reason', () => {
7
+ const result = new CommandResult({
8
+ correlationId: '00000000-0000-0000-0000-000000000000',
9
+ isSuccess: false,
10
+ isAuthorized: false,
11
+ isValid: true,
12
+ hasExceptions: false,
13
+ validationResults: [],
14
+ exceptionMessages: [],
15
+ exceptionStackTrace: '',
16
+ authorizationFailureReason: 'ModuleNotEntitled',
17
+ response: null
18
+ }, Object, false);
19
+ let notAvailableCalled = false;
20
+ result.onNotAvailable(() => notAvailableCalled = true);
21
+
22
+ it('should not say it is not available', () => result.isNotAvailable.should.be.false);
23
+ it('should not call the not available callback', () => notAvailableCalled.should.be.false);
24
+ });
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { CommandResult } from '../CommandResult.js';
5
+
6
+ describe('when the server reports a retryable failure', () => {
7
+ const result = new CommandResult({
8
+ correlationId: '00000000-0000-0000-0000-000000000000',
9
+ isSuccess: false,
10
+ isAuthorized: true,
11
+ isValid: true,
12
+ hasExceptions: true,
13
+ validationResults: [],
14
+ exceptionMessages: ['Availability could not be determined. Retry the request.'],
15
+ exceptionStackTrace: '',
16
+ authorizationFailureReason: '',
17
+ isRetryable: true,
18
+ response: null
19
+ }, Object, false);
20
+
21
+ it('should be retryable', () => result.isRetryable.should.be.true);
22
+ it('should not be a denial', () => result.isAuthorized.should.be.true);
23
+ it('should not say it is not available', () => result.isNotAvailable.should.be.false);
24
+ });
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { CommandResult } from '../CommandResult.js';
5
+ import { NotAvailable } from '../../availability/AvailabilityReason.js';
6
+
7
+ describe('when the command is refused because its part is not available', () => {
8
+ const result = new CommandResult({
9
+ correlationId: '00000000-0000-0000-0000-000000000000',
10
+ isSuccess: false,
11
+ isAuthorized: false,
12
+ isValid: true,
13
+ hasExceptions: false,
14
+ validationResults: [],
15
+ exceptionMessages: [],
16
+ exceptionStackTrace: '',
17
+ authorizationFailureReason: NotAvailable,
18
+ response: null
19
+ }, Object, false);
20
+ let notAvailableCalled = false;
21
+ let unauthorizedCalled = false;
22
+ result.onNotAvailable(() => notAvailableCalled = true).onUnauthorized(() => unauthorizedCalled = true);
23
+
24
+ it('should say it is not available', () => result.isNotAvailable.should.be.true);
25
+ it('should not be a retryable failure', () => result.isRetryable.should.be.false);
26
+ it('should call the not available callback', () => notAvailableCalled.should.be.true);
27
+ it('should still count as unauthorized', () => unauthorizedCalled.should.be.true);
28
+ });
@@ -0,0 +1,26 @@
1
+ import { UnavailablePart } from './UnavailablePart.js';
2
+ export type AvailabilityPart = string | {
3
+ readonly sliceLocation?: {
4
+ readonly module: string;
5
+ readonly feature: string;
6
+ readonly slice: string;
7
+ };
8
+ } | {
9
+ readonly constructor: {
10
+ readonly sliceLocation?: {
11
+ readonly module: string;
12
+ readonly feature: string;
13
+ readonly slice: string;
14
+ };
15
+ };
16
+ };
17
+ export declare class Availability {
18
+ readonly unavailable: readonly UnavailablePart[];
19
+ readonly isKnown: boolean;
20
+ static readonly unknown: Availability;
21
+ static readonly everything: Availability;
22
+ constructor(unavailable: readonly UnavailablePart[], isKnown?: boolean);
23
+ isAvailable(part: AvailabilityPart): boolean;
24
+ filter<TItem>(items: readonly TItem[], partOf: (item: TItem) => AvailabilityPart | undefined): TItem[];
25
+ }
26
+ //# sourceMappingURL=Availability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Availability.d.ts","sourceRoot":"","sources":["../../../availability/Availability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,MAAM,MAAM,gBAAgB,GACtB,MAAM,GACN;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC1G;IAAE,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;YAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAQ3I,qBAAa,YAAY;IAYT,QAAQ,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO;IAVvF,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAA+B;IAGpE,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAA8B;IAOtE,YAAqB,WAAW,EAAE,SAAS,eAAe,EAAE,EAAW,OAAO,GAAE,OAAc,EAC7F;IAQD,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAe3C;IAQD,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,gBAAgB,GAAG,SAAS,GAAG,KAAK,EAAE,CAKrG;CACJ"}
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Represents what is available to the current context, from the last decision the server reported.
7
+ *
8
+ * Everything the server does not list is available. Until the first decision has arrived nothing is known, and
9
+ * nothing is reported as available, so a client never shows a part it has not been told it may show.
10
+ */ class Availability {
11
+ unavailable;
12
+ isKnown;
13
+ /** An availability that has not heard from the server yet. */ static unknown = new Availability([], false);
14
+ /** An availability that treats every part as available, for hosts that do not use availability. */ static everything = new Availability([], true);
15
+ /**
16
+ * Initializes a new instance of {@link Availability}.
17
+ * @param unavailable The parts the server reported as not available.
18
+ * @param isKnown Whether a decision has arrived.
19
+ */ constructor(unavailable, isKnown = true){
20
+ this.unavailable = unavailable;
21
+ this.isKnown = isKnown;
22
+ }
23
+ /**
24
+ * Determines whether a part is available.
25
+ * @param part The full name of a command or read model, or a generated proxy. A proxy is matched by the slice it
26
+ * belongs to, so every part of a slice is hidden together, which is how navigation and screens are decided.
27
+ * @returns True when the part is available; false when it is not, or when nothing is known yet.
28
+ */ isAvailable(part) {
29
+ if (!this.isKnown) {
30
+ return false;
31
+ }
32
+ if (typeof part === 'string') {
33
+ return !this.unavailable.some((_)=>_.name === part);
34
+ }
35
+ const location = sliceLocationOf(part);
36
+ if (location === undefined || location.module === '' && location.feature === '' && location.slice === '') {
37
+ return true;
38
+ }
39
+ return !this.unavailable.some((_)=>_.module === location.module && _.feature === location.feature && _.slice === location.slice);
40
+ }
41
+ /**
42
+ * Keeps the items whose part is available.
43
+ * @param items The items, for example navigation entries.
44
+ * @param partOf Gets the part an item belongs to; an item without one is always kept.
45
+ * @returns The items that are available.
46
+ */ filter(items, partOf) {
47
+ return items.filter((item)=>{
48
+ const part = partOf(item);
49
+ return part === undefined || this.isAvailable(part);
50
+ });
51
+ }
52
+ }
53
+ function sliceLocationOf(part) {
54
+ const own = part.sliceLocation;
55
+ if (own !== undefined) {
56
+ return own;
57
+ }
58
+ return part.constructor?.sliceLocation;
59
+ }
60
+
61
+ exports.Availability = Availability;
62
+ //# sourceMappingURL=Availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Availability.js","sources":["../../../availability/Availability.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { UnavailablePart } from './UnavailablePart.js';\n\n/**\n * Something a client can ask about: the full name of a command or read model on the server, or a generated proxy\n * (class or instance) that carries the slice it belongs to.\n */\nexport type AvailabilityPart =\n | string\n | { readonly sliceLocation?: { readonly module: string; readonly feature: string; readonly slice: string } }\n | { readonly constructor: { readonly sliceLocation?: { readonly module: string; readonly feature: string; readonly slice: string } } };\n\n/**\n * Represents what is available to the current context, from the last decision the server reported.\n *\n * Everything the server does not list is available. Until the first decision has arrived nothing is known, and\n * nothing is reported as available, so a client never shows a part it has not been told it may show.\n */\nexport class Availability {\n /** An availability that has not heard from the server yet. */\n static readonly unknown: Availability = new Availability([], false);\n\n /** An availability that treats every part as available, for hosts that do not use availability. */\n static readonly everything: Availability = new Availability([], true);\n\n /**\n * Initializes a new instance of {@link Availability}.\n * @param unavailable The parts the server reported as not available.\n * @param isKnown Whether a decision has arrived.\n */\n constructor(readonly unavailable: readonly UnavailablePart[], readonly isKnown: boolean = true) {\n }\n\n /**\n * Determines whether a part is available.\n * @param part The full name of a command or read model, or a generated proxy. A proxy is matched by the slice it\n * belongs to, so every part of a slice is hidden together, which is how navigation and screens are decided.\n * @returns True when the part is available; false when it is not, or when nothing is known yet.\n */\n isAvailable(part: AvailabilityPart): boolean {\n if (!this.isKnown) {\n return false;\n }\n\n if (typeof part === 'string') {\n return !this.unavailable.some(_ => _.name === part);\n }\n\n const location = sliceLocationOf(part);\n if (location === undefined || (location.module === '' && location.feature === '' && location.slice === '')) {\n return true;\n }\n\n return !this.unavailable.some(_ => _.module === location.module && _.feature === location.feature && _.slice === location.slice);\n }\n\n /**\n * Keeps the items whose part is available.\n * @param items The items, for example navigation entries.\n * @param partOf Gets the part an item belongs to; an item without one is always kept.\n * @returns The items that are available.\n */\n filter<TItem>(items: readonly TItem[], partOf: (item: TItem) => AvailabilityPart | undefined): TItem[] {\n return items.filter(item => {\n const part = partOf(item);\n return part === undefined || this.isAvailable(part);\n });\n }\n}\n\nfunction sliceLocationOf(part: Exclude<AvailabilityPart, string>): { module: string; feature: string; slice: string } | undefined {\n const own = (part as { sliceLocation?: { module: string; feature: string; slice: string } }).sliceLocation;\n if (own !== undefined) {\n return own;\n }\n\n return (part as { constructor?: { sliceLocation?: { module: string; feature: string; slice: string } } }).constructor?.sliceLocation;\n}\n"],"names":["Availability","unknown","everything","isKnown","unavailable","isAvailable","part","some","_","name","location","sliceLocationOf","undefined","module","feature","slice","filter","items","partOf","item","own","sliceLocation"],"mappings":";;AAAA;AACA;AAaA;;;;;AAKC,IACM,MAAMA,YAAAA,CAAAA;;;AACT,mEACA,OAAgBC,OAAAA,GAAwB,IAAID,YAAAA,CAAa,EAAE,EAAE,KAAA,CAAA;AAE7D,wGACA,OAAgBE,UAAAA,GAA2B,IAAIF,YAAAA,CAAa,EAAE,EAAE,IAAA,CAAA;AAEhE;;;;AAIC,QACD,YAAY,WAAgD,EAAE,OAASG,GAAmB,IAAI,CAAE;aAA3EC,WAAAA,GAAAA,WAAAA;aAAkDD,OAAAA,GAAAA,OAAAA;AACvE,IAAA;AAEA;;;;;QAMAE,WAAAA,CAAYC,IAAsB,EAAW;AACzC,QAAA,IAAI,CAAC,IAAI,CAACH,OAAO,EAAE;YACf,OAAO,KAAA;AACX,QAAA;QAEA,IAAI,OAAOG,SAAS,QAAA,EAAU;YAC1B,OAAO,CAAC,IAAI,CAACF,WAAW,CAACG,IAAI,CAACC,CAAAA,CAAAA,GAAKA,CAAAA,CAAEC,IAAI,KAAKH,IAAAA,CAAAA;AAClD,QAAA;AAEA,QAAA,MAAMI,WAAWC,eAAAA,CAAgBL,IAAAA,CAAAA;AACjC,QAAA,IAAII,QAAAA,KAAaE,SAAAA,IAAcF,QAAAA,CAASG,MAAM,KAAK,EAAA,IAAMH,QAAAA,CAASI,OAAO,KAAK,EAAA,IAAMJ,QAAAA,CAASK,KAAK,KAAK,EAAA,EAAK;YACxG,OAAO,IAAA;AACX,QAAA;QAEA,OAAO,CAAC,IAAI,CAACX,WAAW,CAACG,IAAI,CAACC,CAAAA,CAAAA,GAAKA,CAAAA,CAAEK,MAAM,KAAKH,SAASG,MAAM,IAAIL,CAAAA,CAAEM,OAAO,KAAKJ,QAAAA,CAASI,OAAO,IAAIN,CAAAA,CAAEO,KAAK,KAAKL,QAAAA,CAASK,KAAK,CAAA;AACnI,IAAA;AAEA;;;;;AAKC,QACDC,MAAAA,CAAcC,KAAuB,EAAEC,MAAqD,EAAW;QACnG,OAAOD,KAAAA,CAAMD,MAAM,CAACG,CAAAA,IAAAA,GAAAA;AAChB,YAAA,MAAMb,OAAOY,MAAAA,CAAOC,IAAAA,CAAAA;AACpB,YAAA,OAAOb,IAAAA,KAASM,SAAAA,IAAa,IAAI,CAACP,WAAW,CAACC,IAAAA,CAAAA;AAClD,QAAA,CAAA,CAAA;AACJ,IAAA;AACJ;AAEA,SAASK,gBAAgBL,IAAuC,EAAA;IAC5D,MAAMc,GAAAA,GAAM,IAACd,CAAgFe,aAAa;AAC1G,IAAA,IAAID,QAAQR,SAAAA,EAAW;QACnB,OAAOQ,GAAAA;AACX,IAAA;IAEA,OAAQd,IAAAA,CAAkG,WAAW,EAAEe,aAAAA;AAC3H;;"}
@@ -0,0 +1,2 @@
1
+ export declare const NotAvailable = "NotAvailable";
2
+ //# sourceMappingURL=AvailabilityReason.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvailabilityReason.d.ts","sourceRoot":"","sources":["../../../availability/AvailabilityReason.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The authorization failure reason of a command or query result when its part of the application is not available
7
+ * to the caller. It is distinct from being forbidden: availability decides whether a part exists for the caller at
8
+ * all, authorization decides what the caller may do in it.
9
+ */ const NotAvailable = 'NotAvailable';
10
+
11
+ exports.NotAvailable = NotAvailable;
12
+ //# sourceMappingURL=AvailabilityReason.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvailabilityReason.js","sources":["../../../availability/AvailabilityReason.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The authorization failure reason of a command or query result when its part of the application is not available\n * to the caller. It is distinct from being forbidden: availability decides whether a part exists for the caller at\n * all, authorization decides what the caller may do in it.\n */\nexport const NotAvailable = 'NotAvailable';\n"],"names":["NotAvailable"],"mappings":";;AAAA;AACA;AAEA;;;;IAKO,MAAMA,YAAAA,GAAe;;"}
@@ -0,0 +1,11 @@
1
+ import { UnavailablePart } from './UnavailablePart.js';
2
+ export declare class UnavailablePartModel implements UnavailablePart {
3
+ name: string;
4
+ module: string;
5
+ feature: string;
6
+ slice: string;
7
+ }
8
+ export declare class AvailableParts {
9
+ unavailable: UnavailablePartModel[];
10
+ }
11
+ //# sourceMappingURL=AvailableParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvailableParts.d.ts","sourceRoot":"","sources":["../../../availability/AvailableParts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,qBAAa,oBAAqB,YAAW,eAAe;IAExD,IAAI,SAAM;IAGV,MAAM,SAAM;IAGZ,OAAO,SAAM;IAGb,KAAK,SAAM;CACd;AAKD,qBAAa,cAAc;IAEvB,WAAW,EAAE,oBAAoB,EAAE,CAAM;CAC5C"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var fundamentals = require('@cratis/fundamentals');
4
+
5
+ function _ts_decorate(decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
8
+ r = Reflect.decorate(decorators, target, key, desc);
9
+ } else {
10
+ for(var i = decorators.length - 1; i >= 0; i--){
11
+ if (d = decorators[i]) {
12
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
+ }
14
+ }
15
+ }
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ }
18
+ function _ts_metadata(metadataKey, metadataValue) {
19
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
20
+ return Reflect.metadata(metadataKey, metadataValue);
21
+ }
22
+ }
23
+ /**
24
+ * The part of an unavailable-parts message that names one part. Matches {@link UnavailablePart}.
25
+ */ class UnavailablePartModel {
26
+ name = '';
27
+ module = '';
28
+ feature = '';
29
+ slice = '';
30
+ }
31
+ _ts_decorate([
32
+ fundamentals.field(String)
33
+ ], UnavailablePartModel.prototype, "name", void 0);
34
+ _ts_decorate([
35
+ fundamentals.field(String)
36
+ ], UnavailablePartModel.prototype, "module", void 0);
37
+ _ts_decorate([
38
+ fundamentals.field(String)
39
+ ], UnavailablePartModel.prototype, "feature", void 0);
40
+ _ts_decorate([
41
+ fundamentals.field(String)
42
+ ], UnavailablePartModel.prototype, "slice", void 0);
43
+ /**
44
+ * What is not available to the current context, as the server reports it. Everything not listed is available.
45
+ */ class AvailableParts {
46
+ unavailable = [];
47
+ }
48
+ _ts_decorate([
49
+ fundamentals.field(UnavailablePartModel, true),
50
+ _ts_metadata("design:type", Array)
51
+ ], AvailableParts.prototype, "unavailable", void 0);
52
+
53
+ exports.AvailableParts = AvailableParts;
54
+ exports.UnavailablePartModel = UnavailablePartModel;
55
+ //# sourceMappingURL=AvailableParts.js.map