@singularsystems/neo-core 0.10.66 → 0.10.69
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/dist/AppServices/Config/ConfigModel.d.ts +3 -2
- package/dist/AppServices/Config/ConfigModel.js +11 -0
- package/dist/AppServices/Config/ConfigService.js +2 -5
- package/dist/Model/Decorators.d.ts +6 -3
- package/dist/Model/Decorators.js +9 -4
- package/dist/Model/ModelBase.d.ts +1 -1
- package/dist/Model/ModelBase.js +1 -1
- package/dist/Model/PropertyInfo.d.ts +2 -0
- package/dist/Model/PropertyInstance.d.ts +35 -1
- package/dist/Model/PropertyInstance.js +58 -0
- package/dist/Model/index.d.ts +2 -1
- package/dist/Model/index.js +2 -1
- package/dist/NumberUtils.d.ts +12 -5
- package/dist/NumberUtils.js +46 -11
- package/dist/Security/IAuthenticationService.d.ts +5 -0
- package/dist/Security/Oidc/OidcAuthService.d.ts +8 -1
- package/dist/Security/Oidc/OidcAuthService.js +28 -1
- package/dist/Security/Oidc/OidcTypes.d.ts +23 -6
- package/dist/Validation/Validators/IModelValidator.d.ts +6 -2
- package/dist/Validation/Validators/ModelValidator.d.ts +1 -0
- package/dist/Validation/Validators/ModelValidator.js +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface IConfigModel {
|
|
2
|
-
baseUrl: string;
|
|
2
|
+
readonly baseUrl: string;
|
|
3
3
|
/**
|
|
4
4
|
* True by default if the NODE_ENV environment variable is "development".
|
|
5
5
|
**/
|
|
@@ -12,9 +12,10 @@ export interface IConfigModel {
|
|
|
12
12
|
initialise(): void;
|
|
13
13
|
}
|
|
14
14
|
export default class ConfigModel implements IConfigModel {
|
|
15
|
-
|
|
15
|
+
private _baseUrl;
|
|
16
16
|
isDevelopment: boolean;
|
|
17
17
|
isTest: boolean;
|
|
18
18
|
get isTestOrDevelopment(): boolean;
|
|
19
|
+
get baseUrl(): string;
|
|
19
20
|
initialise(): void;
|
|
20
21
|
}
|
|
@@ -10,6 +10,17 @@ var ConfigModel = /** @class */ (function () {
|
|
|
10
10
|
enumerable: false,
|
|
11
11
|
configurable: true
|
|
12
12
|
});
|
|
13
|
+
Object.defineProperty(ConfigModel.prototype, "baseUrl", {
|
|
14
|
+
get: function () {
|
|
15
|
+
if (!this._baseUrl) {
|
|
16
|
+
var baseTag = document.getElementsByTagName('base')[0];
|
|
17
|
+
this._baseUrl = baseTag ? baseTag.getAttribute("href") || "" : "";
|
|
18
|
+
}
|
|
19
|
+
return this._baseUrl;
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
13
24
|
ConfigModel.prototype.initialise = function () {
|
|
14
25
|
};
|
|
15
26
|
return ConfigModel;
|
|
@@ -8,13 +8,11 @@ var ConfigService = /** @class */ (function () {
|
|
|
8
8
|
}
|
|
9
9
|
ConfigService.prototype.loadConfig = function (path) {
|
|
10
10
|
return __awaiter(this, void 0, void 0, function () {
|
|
11
|
-
var
|
|
11
|
+
var timestamp, response, error_1;
|
|
12
12
|
return __generator(this, function (_a) {
|
|
13
13
|
switch (_a.label) {
|
|
14
14
|
case 0:
|
|
15
|
-
|
|
16
|
-
baseUrl = baseTag ? baseTag.getAttribute("href") || "" : "";
|
|
17
|
-
path = path !== null && path !== void 0 ? path : "".concat(baseUrl, "/config.json");
|
|
15
|
+
path = path !== null && path !== void 0 ? path : "".concat(this.config.baseUrl, "/config.json");
|
|
18
16
|
_a.label = 1;
|
|
19
17
|
case 1:
|
|
20
18
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -25,7 +23,6 @@ var ConfigService = /** @class */ (function () {
|
|
|
25
23
|
// The raw parsed json objects properties are copied into the config model.
|
|
26
24
|
// It is up to the config model to transform its properties if required (in the initialise method).
|
|
27
25
|
Object.assign(this.config, response.data);
|
|
28
|
-
this.config.baseUrl = baseUrl;
|
|
29
26
|
this.config.initialise();
|
|
30
27
|
return [2 /*return*/, this.config];
|
|
31
28
|
case 3:
|
|
@@ -4,9 +4,12 @@ export declare function Display(name: string): (type: any, propertyKey: string)
|
|
|
4
4
|
export declare function Date(timeZoneSerialisation?: TimeZoneFormat): (type: any, propertyKey: string, descriptor?: PropertyDescriptor) => void;
|
|
5
5
|
/** Indicates that this is an integer number property. Editors will be restricted to integer numeric input. */
|
|
6
6
|
export declare function Integer(): (type: any, propertyKey: string) => void;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Indicates that this is a float number property.
|
|
9
|
+
* Editors will be restricted to float numeric input.
|
|
10
|
+
* @param decimals No of decimals allowed when storing this value. Used when binding to this property from a supporting ui component. If not specified, this will be determined from the format string. */
|
|
11
|
+
export declare function Float(decimals?: number): (type: any, propertyKey: string) => void;
|
|
12
|
+
/** Indicates that this is a decimal property (decimal type from the decimal.js-light package). */
|
|
10
13
|
export declare function Decimal(): (type: any, propertyKey: string) => void;
|
|
11
14
|
/** Indicates that this is a nullable boolean property. */
|
|
12
15
|
export declare function NullableBoolean(): (type: any, propertyKey: string) => void;
|
package/dist/Model/Decorators.js
CHANGED
|
@@ -24,13 +24,18 @@ export function Integer() {
|
|
|
24
24
|
getOrAddPropertyInfo(type, propertyKey).propertyType = DataType.Int;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Indicates that this is a float number property.
|
|
29
|
+
* Editors will be restricted to float numeric input.
|
|
30
|
+
* @param decimals No of decimals allowed when storing this value. Used when binding to this property from a supporting ui component. If not specified, this will be determined from the format string. */
|
|
31
|
+
export function Float(decimals) {
|
|
29
32
|
return function (type, propertyKey) {
|
|
30
|
-
getOrAddPropertyInfo(type, propertyKey)
|
|
33
|
+
var propertyInfo = getOrAddPropertyInfo(type, propertyKey);
|
|
34
|
+
propertyInfo.propertyType = DataType.Float;
|
|
35
|
+
propertyInfo.allowedDecimals = decimals;
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
|
-
/** Indicates that this is a decimal property. */
|
|
38
|
+
/** Indicates that this is a decimal property (decimal type from the decimal.js-light package). */
|
|
34
39
|
export function Decimal() {
|
|
35
40
|
return function (type, propertyKey) {
|
|
36
41
|
getOrAddPropertyInfo(type, propertyKey).propertyType = DataType.Decimal;
|
|
@@ -83,6 +83,6 @@ export default abstract class ModelBase extends BindableBase implements IModelBa
|
|
|
83
83
|
* Add custom business rules. Note, this will be called once per type and should be treated as static.
|
|
84
84
|
*/
|
|
85
85
|
protected addBusinessRules(validationRules: ValidationRules<this>): void;
|
|
86
|
-
/** The server side
|
|
86
|
+
/** The server side type name used to find this type. Include the namespace if there is more than one type with the same name. */
|
|
87
87
|
static typeName: string | null;
|
|
88
88
|
}
|
package/dist/Model/ModelBase.js
CHANGED
|
@@ -147,7 +147,7 @@ var ModelBase = /** @class */ (function (_super) {
|
|
|
147
147
|
*/
|
|
148
148
|
ModelBase.prototype.addBusinessRules = function (validationRules) {
|
|
149
149
|
};
|
|
150
|
-
/** The server side
|
|
150
|
+
/** The server side type name used to find this type. Include the namespace if there is more than one type with the same name. */
|
|
151
151
|
ModelBase.typeName = null;
|
|
152
152
|
__decorate([
|
|
153
153
|
NoTracking(SerialiseType.Never),
|
|
@@ -33,6 +33,8 @@ export default class PropertyInfo {
|
|
|
33
33
|
relationType: RelationType;
|
|
34
34
|
/** Data type of the property. */
|
|
35
35
|
propertyType: DataType;
|
|
36
|
+
/** No of decimals to allow when binding to this property from a supporting ui component. If not specified, this will be determined from the format string. */
|
|
37
|
+
allowedDecimals?: number;
|
|
36
38
|
/** This will change the default behaviour about how a control sets this properties value. */
|
|
37
39
|
allowNulls: boolean;
|
|
38
40
|
/** Options for the onChanged event */
|
|
@@ -37,7 +37,7 @@ export declare class PropertyAccessor implements IPropertyInstance {
|
|
|
37
37
|
attachedTo: any;
|
|
38
38
|
propertyInfo: PropertyInfo;
|
|
39
39
|
private propertyName;
|
|
40
|
-
|
|
40
|
+
protected constructor(attachedTo: any, propertyInfo: PropertyInfo);
|
|
41
41
|
sortValue: any;
|
|
42
42
|
get uniqueID(): string;
|
|
43
43
|
get validator(): IPropertyValidator;
|
|
@@ -46,3 +46,37 @@ export declare class PropertyAccessor implements IPropertyInstance {
|
|
|
46
46
|
get peek(): any;
|
|
47
47
|
static create<T>(model: T, property: keyof T): PropertyAccessor;
|
|
48
48
|
}
|
|
49
|
+
interface ITemporaryPropertyOptions<TValue> {
|
|
50
|
+
/** Name of the property. Should be a valid js property name. */
|
|
51
|
+
name?: string;
|
|
52
|
+
/** Label to show in editors using this property. */
|
|
53
|
+
label?: string;
|
|
54
|
+
/** On changed function if you want the property to be writable. */
|
|
55
|
+
onChanged?: (value: TValue) => void;
|
|
56
|
+
}
|
|
57
|
+
export declare class TemporaryProperty<TValue = any> extends PropertyAccessor {
|
|
58
|
+
private valueAccessor;
|
|
59
|
+
private onChanged?;
|
|
60
|
+
constructor(attachedTo: any, valueAccessor: () => TValue, options?: ITemporaryPropertyOptions<TValue>);
|
|
61
|
+
get value(): TValue;
|
|
62
|
+
set value(value: TValue);
|
|
63
|
+
get peek(): TValue;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a temporary property if you need a neo editor to show a computed value, and cannot use the meta object on a neo model.
|
|
67
|
+
* The property should be attached to a component class instance, and the property should be passed as the editors `bind` prop.
|
|
68
|
+
*
|
|
69
|
+
* E.g.
|
|
70
|
+
* In component class:
|
|
71
|
+
* ```typescript
|
|
72
|
+
* this.myProperty = createProperty(this, ...);
|
|
73
|
+
* ```
|
|
74
|
+
* In render method:
|
|
75
|
+
* ```jsx
|
|
76
|
+
* <Neo.FormGroup bind={this.myProperty} />
|
|
77
|
+
* ```
|
|
78
|
+
* @param host The instance this property is stored on, usually `this`.
|
|
79
|
+
* @param valueAccessor Function that returns the property value.
|
|
80
|
+
*/
|
|
81
|
+
export declare function createProperty<TValue>(host: any, valueAccessor: () => TValue, options?: ITemporaryPropertyOptions<TValue>): TemporaryProperty<TValue>;
|
|
82
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
1
2
|
import { EmptyValidator } from '../Validation/Validators/IPropertyValidator';
|
|
2
3
|
import PropertyInfo from './PropertyInfo';
|
|
3
4
|
import { Utils } from '../Utils';
|
|
@@ -111,3 +112,60 @@ var PropertyAccessor = /** @class */ (function () {
|
|
|
111
112
|
return PropertyAccessor;
|
|
112
113
|
}());
|
|
113
114
|
export { PropertyAccessor };
|
|
115
|
+
var TemporaryProperty = /** @class */ (function (_super) {
|
|
116
|
+
__extends(TemporaryProperty, _super);
|
|
117
|
+
function TemporaryProperty(attachedTo, valueAccessor, options) {
|
|
118
|
+
var _this = this;
|
|
119
|
+
var _a, _b;
|
|
120
|
+
var propertyInfo = new PropertyInfo((_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : Utils.uuidv4());
|
|
121
|
+
propertyInfo.displayName = (_b = options === null || options === void 0 ? void 0 : options.label) !== null && _b !== void 0 ? _b : "";
|
|
122
|
+
propertyInfo.isReadOnly = (options === null || options === void 0 ? void 0 : options.onChanged) === undefined;
|
|
123
|
+
_this = _super.call(this, attachedTo, propertyInfo) || this;
|
|
124
|
+
_this.valueAccessor = valueAccessor;
|
|
125
|
+
_this.onChanged = options === null || options === void 0 ? void 0 : options.onChanged;
|
|
126
|
+
return _this;
|
|
127
|
+
}
|
|
128
|
+
Object.defineProperty(TemporaryProperty.prototype, "value", {
|
|
129
|
+
get: function () {
|
|
130
|
+
return this.valueAccessor();
|
|
131
|
+
},
|
|
132
|
+
set: function (value) {
|
|
133
|
+
if (this.onChanged) {
|
|
134
|
+
this.onChanged(value);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
throw Error("Cannot set value of temporary property ".concat(this.propertyInfo.propertyName));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
enumerable: false,
|
|
141
|
+
configurable: true
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(TemporaryProperty.prototype, "peek", {
|
|
144
|
+
get: function () {
|
|
145
|
+
return this.value;
|
|
146
|
+
},
|
|
147
|
+
enumerable: false,
|
|
148
|
+
configurable: true
|
|
149
|
+
});
|
|
150
|
+
return TemporaryProperty;
|
|
151
|
+
}(PropertyAccessor));
|
|
152
|
+
export { TemporaryProperty };
|
|
153
|
+
/**
|
|
154
|
+
* Creates a temporary property if you need a neo editor to show a computed value, and cannot use the meta object on a neo model.
|
|
155
|
+
* The property should be attached to a component class instance, and the property should be passed as the editors `bind` prop.
|
|
156
|
+
*
|
|
157
|
+
* E.g.
|
|
158
|
+
* In component class:
|
|
159
|
+
* ```typescript
|
|
160
|
+
* this.myProperty = createProperty(this, ...);
|
|
161
|
+
* ```
|
|
162
|
+
* In render method:
|
|
163
|
+
* ```jsx
|
|
164
|
+
* <Neo.FormGroup bind={this.myProperty} />
|
|
165
|
+
* ```
|
|
166
|
+
* @param host The instance this property is stored on, usually `this`.
|
|
167
|
+
* @param valueAccessor Function that returns the property value.
|
|
168
|
+
*/
|
|
169
|
+
export function createProperty(host, valueAccessor, options) {
|
|
170
|
+
return new TemporaryProperty(host, valueAccessor, options);
|
|
171
|
+
}
|
package/dist/Model/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { IBindableBase, IModelBase, NeoModelConstructor, PlainObject, PlainTrackedObject, PartialPlainObject, PartialPlainNonTrackedObject, TransformMetaType, IMakeBindableOptions } from './IModelBase';
|
|
2
2
|
export { ILookupBase } from './LookupBase';
|
|
3
3
|
export { IPropertyInstance, PropertyAccessor } from './PropertyInstance';
|
|
4
|
+
import PropertyInfo from './PropertyInfo';
|
|
4
5
|
export { IObservableValue, ObservableValue } from './ObservableValue';
|
|
5
6
|
export { ObservableProperty } from './ObservableProperty';
|
|
6
7
|
export { ISelectedItem } from './Misc';
|
|
7
8
|
export { ModelFieldInfo, IModelFieldInfoContainer } from './ModelFieldInfo';
|
|
8
9
|
import * as GraphTraverser from './ModelGraphTraverser';
|
|
9
|
-
export { GraphTraverser };
|
|
10
|
+
export { GraphTraverser, PropertyInfo };
|
|
10
11
|
export { AuditValues, AuditValuesBase } from './BaseModels/AuditValues';
|
|
11
12
|
export { FileDescriptorBase } from './BaseModels/FileDescriptorBase';
|
|
12
13
|
export { ReasonedUserEvent } from './BaseModels/ReasonedUserEvent';
|
package/dist/Model/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { PropertyAccessor } from './PropertyInstance';
|
|
2
|
+
import PropertyInfo from './PropertyInfo';
|
|
2
3
|
export { ObservableValue } from './ObservableValue';
|
|
3
4
|
export { ObservableProperty } from './ObservableProperty';
|
|
4
5
|
export { ModelFieldInfo } from './ModelFieldInfo';
|
|
5
6
|
import * as GraphTraverser from './ModelGraphTraverser';
|
|
6
|
-
export { GraphTraverser };
|
|
7
|
+
export { GraphTraverser, PropertyInfo };
|
|
7
8
|
// Base Models
|
|
8
9
|
export { AuditValues, AuditValuesBase } from './BaseModels/AuditValues';
|
|
9
10
|
export { FileDescriptorBase } from './BaseModels/FileDescriptorBase';
|
package/dist/NumberUtils.d.ts
CHANGED
|
@@ -16,26 +16,33 @@ export default class NumberUtils {
|
|
|
16
16
|
/** If values typed into numeric editors should be divided by 100 when stored. */
|
|
17
17
|
static transformPercent: boolean;
|
|
18
18
|
static initialise(): void;
|
|
19
|
-
/** Gets a format string for the pre-defined number format.
|
|
20
|
-
|
|
19
|
+
/** Gets a format string for the pre-defined number format.
|
|
20
|
+
* @param displayDecimals No of decimals to display if using a decimals format.
|
|
21
|
+
*/
|
|
22
|
+
static getFormatString(format: NumberFormat, currencySymbol?: string, displayDecimals?: number): string;
|
|
21
23
|
/**
|
|
22
24
|
* Formats a number into a string that can be parsed back to a number. E.g. without currency symbol or group separators
|
|
23
25
|
* @param number js number
|
|
24
26
|
* @param format Format string including group separators / currency symbol. This is used to get the number of decimal to display.
|
|
25
27
|
* @param hasExternalPercentSymbol True if this is a percent, but the format string doesn't contain a % symbol.
|
|
28
|
+
* @param maxDecimals Max no of decimals supported by the value. For percentages this should be 2 more than the no of displayed decimals.
|
|
26
29
|
*/
|
|
27
|
-
static formatRaw(number: number, format: string, hasExternalPercentSymbol?: boolean): string;
|
|
30
|
+
static formatRaw(number: number, format: string, hasExternalPercentSymbol?: boolean, maxDecimals?: number): string;
|
|
28
31
|
/**
|
|
29
32
|
* Rounds a number, getting the precision from the format string
|
|
30
33
|
* @param hasExternalPercentSymbol True if this is a percent, but the format string doesn't contain a % symbol.
|
|
31
34
|
*/
|
|
32
|
-
static roundUsingFormat
|
|
35
|
+
static roundUsingFormat(number: number, formatString: string, hasExternalPercentSymbol?: boolean): number;
|
|
36
|
+
/**
|
|
37
|
+
* Rounds a number to the nearest no of decimals.
|
|
38
|
+
*/
|
|
39
|
+
static round<T extends number | Decimal>(number: T, decimals: number): T;
|
|
33
40
|
/**
|
|
34
41
|
* Returns the number of decimal places in a format string.
|
|
35
42
|
* @param formatString Format string.
|
|
36
43
|
* @param value Value if the negative format string is different to positive.
|
|
37
44
|
*/
|
|
38
|
-
static getDecimalPlaces
|
|
45
|
+
static getDecimalPlaces(formatString: string, value?: number): number;
|
|
39
46
|
private static getDecimalsFormatPart;
|
|
40
47
|
/**
|
|
41
48
|
* Converts a number to a string using the specified format.
|
package/dist/NumberUtils.js
CHANGED
|
@@ -24,9 +24,23 @@ var NumberUtils = /** @class */ (function () {
|
|
|
24
24
|
NumberUtils.numberFormats[NumberFormat.CurrencyNoDecimals] = "_#,##0;(_#,##0)";
|
|
25
25
|
NumberUtils.numberFormats[NumberFormat.CurrencyDecimals] = "_#,##0.00;(_#,##0.00)";
|
|
26
26
|
};
|
|
27
|
-
/** Gets a format string for the pre-defined number format.
|
|
28
|
-
|
|
27
|
+
/** Gets a format string for the pre-defined number format.
|
|
28
|
+
* @param displayDecimals No of decimals to display if using a decimals format.
|
|
29
|
+
*/
|
|
30
|
+
NumberUtils.getFormatString = function (format, currencySymbol, displayDecimals) {
|
|
31
|
+
if (displayDecimals === void 0) { displayDecimals = 2; }
|
|
29
32
|
var formatString = NumberUtils.numberFormats[format];
|
|
33
|
+
if ((format & 0x0100) === 0x0100) {
|
|
34
|
+
if (displayDecimals === 0) {
|
|
35
|
+
formatString = formatString.replace(/.00/g, "");
|
|
36
|
+
}
|
|
37
|
+
else if (displayDecimals === 1) {
|
|
38
|
+
formatString = formatString.replace(/.00/g, ".0");
|
|
39
|
+
}
|
|
40
|
+
else if (displayDecimals > 2) {
|
|
41
|
+
formatString = formatString.replace(/.00/g, ".00" + "#".repeat(displayDecimals - 2));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
30
44
|
return formatString.replace(/_/g, currencySymbol || NumberUtils.defaultCurrencySymbol);
|
|
31
45
|
};
|
|
32
46
|
/**
|
|
@@ -34,15 +48,19 @@ var NumberUtils = /** @class */ (function () {
|
|
|
34
48
|
* @param number js number
|
|
35
49
|
* @param format Format string including group separators / currency symbol. This is used to get the number of decimal to display.
|
|
36
50
|
* @param hasExternalPercentSymbol True if this is a percent, but the format string doesn't contain a % symbol.
|
|
51
|
+
* @param maxDecimals Max no of decimals supported by the value. For percentages this should be 2 more than the no of displayed decimals.
|
|
37
52
|
*/
|
|
38
|
-
NumberUtils.formatRaw = function (number, format, hasExternalPercentSymbol) {
|
|
53
|
+
NumberUtils.formatRaw = function (number, format, hasExternalPercentSymbol, maxDecimals) {
|
|
39
54
|
var parts = format.split(";");
|
|
40
55
|
var isPercent = format.indexOf("%") >= 0 || hasExternalPercentSymbol;
|
|
41
56
|
if (isPercent && NumberUtils.transformPercent) {
|
|
42
57
|
number *= 100;
|
|
43
58
|
isPercent = false; //Don't allow extra precision below.
|
|
59
|
+
if (maxDecimals !== undefined) {
|
|
60
|
+
maxDecimals -= 2;
|
|
61
|
+
}
|
|
44
62
|
}
|
|
45
|
-
var positive = "#0" + NumberUtils.getDecimalsFormatPart(parts[0], isPercent), negative = "-#0" + NumberUtils.getDecimalsFormatPart(parts[1] ? parts[1] : parts[0], isPercent);
|
|
63
|
+
var positive = "#0" + NumberUtils.getDecimalsFormatPart(parts[0], isPercent, maxDecimals), negative = "-#0" + NumberUtils.getDecimalsFormatPart(parts[1] ? parts[1] : parts[0], isPercent, maxDecimals);
|
|
46
64
|
return NumberUtils.format(number, positive + ";" + negative);
|
|
47
65
|
};
|
|
48
66
|
/**
|
|
@@ -54,6 +72,12 @@ var NumberUtils = /** @class */ (function () {
|
|
|
54
72
|
if (formatString.indexOf("%") >= 0 || hasExternalPercentSymbol) {
|
|
55
73
|
decimals += 2;
|
|
56
74
|
}
|
|
75
|
+
return this.round(number, decimals);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Rounds a number to the nearest no of decimals.
|
|
79
|
+
*/
|
|
80
|
+
NumberUtils.round = function (number, decimals) {
|
|
57
81
|
if (number instanceof Globals.decimalType) {
|
|
58
82
|
// Round away from zero.
|
|
59
83
|
return number.toDecimalPlaces(decimals, Decimal.ROUND_HALF_UP);
|
|
@@ -82,16 +106,27 @@ var NumberUtils = /** @class */ (function () {
|
|
|
82
106
|
}
|
|
83
107
|
return 0;
|
|
84
108
|
};
|
|
85
|
-
NumberUtils.getDecimalsFormatPart = function (formatString, isPercent) {
|
|
109
|
+
NumberUtils.getDecimalsFormatPart = function (formatString, isPercent, maxDecimals) {
|
|
86
110
|
if (isPercent === void 0) { isPercent = false; }
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
var decimalsPart = "";
|
|
112
|
+
var startIndex = formatString.indexOf(".");
|
|
113
|
+
var endIndex = Math.max(formatString.lastIndexOf("0"), formatString.lastIndexOf("#"));
|
|
114
|
+
if (startIndex >= 0 && endIndex > 0) {
|
|
115
|
+
decimalsPart = formatString.substring(startIndex, endIndex + 1) + (isPercent ? "##" : "");
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
decimalsPart = isPercent ? ".##" : "";
|
|
119
|
+
}
|
|
120
|
+
if (maxDecimals !== undefined && maxDecimals > 0) {
|
|
121
|
+
// If the format string has less decimals than maxDecimals, then add # characters on the end.
|
|
122
|
+
if (!decimalsPart) {
|
|
123
|
+
decimalsPart = ".";
|
|
124
|
+
}
|
|
125
|
+
if (decimalsPart.length - 1 < maxDecimals) {
|
|
126
|
+
decimalsPart += "#".repeat(maxDecimals - (decimalsPart.length - 1));
|
|
92
127
|
}
|
|
93
128
|
}
|
|
94
|
-
return
|
|
129
|
+
return decimalsPart;
|
|
95
130
|
};
|
|
96
131
|
NumberUtils.format = function (number, format, currencySymbol) {
|
|
97
132
|
if (number instanceof Globals.decimalType) {
|
|
@@ -9,6 +9,11 @@ export default interface IAuthenticationService {
|
|
|
9
9
|
* Load a user from session storage if there is a stored token.
|
|
10
10
|
*/
|
|
11
11
|
loadUserFromSession(): Promise<IUser | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the user is signed in, and if not, redirects to login.
|
|
14
|
+
* Returns true if the user is logged in.
|
|
15
|
+
*/
|
|
16
|
+
ensureSignedIn(redirectLocal?: string): boolean;
|
|
12
17
|
/**
|
|
13
18
|
* Starts the sign in process
|
|
14
19
|
* @param redirectLocal The path to redirect to after calling endSignIn
|
|
@@ -20,6 +20,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
20
20
|
constructor(userManager: IUserManager, axios: AxiosInstance);
|
|
21
21
|
loadUserFromToken(): Promise<TUser | null>;
|
|
22
22
|
loadUserFromSession(): Promise<TUser | null>;
|
|
23
|
+
ensureSignedIn(redirectLocal?: string): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* Redirect to identity server to get the auth token.
|
|
25
26
|
* @param redirectPath Local path to redirect to once login is complete.
|
|
@@ -40,7 +41,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
40
41
|
protected createUser(user: IOidcUser): OidcUser;
|
|
41
42
|
private onUserUnloaded;
|
|
42
43
|
private setUser;
|
|
43
|
-
signinSilent(): Promise<IOidcUser>;
|
|
44
|
+
signinSilent(): Promise<IOidcUser | null>;
|
|
44
45
|
beginSignOut(): void;
|
|
45
46
|
endSignOut(): Promise<any>;
|
|
46
47
|
signOutLocal(): void;
|
|
@@ -57,4 +58,10 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
57
58
|
revocation_endpoint: string;
|
|
58
59
|
introspection_endpoint: string;
|
|
59
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* If this is a silent sign in (based on the current uri), `endSignInSilent()` is called on the oidc client, and this method returns true.
|
|
63
|
+
* This should be called on startup of your app. If this returns true, don't continue with startup, since this iframe will be shortly disposed.
|
|
64
|
+
* @param silentRedirectRoute The app relative path used for silent sign in callbacks.
|
|
65
|
+
*/
|
|
66
|
+
static isSilentSignIn(silentRedirectRoute: string): boolean;
|
|
60
67
|
}
|
|
@@ -21,7 +21,10 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
21
21
|
this.userManager = userManager;
|
|
22
22
|
this.userManager.events.addUserLoaded(this.onUserLoaded.bind(this));
|
|
23
23
|
this.userManager.events.addUserUnloaded(this.onUserUnloaded.bind(this));
|
|
24
|
-
this.userManager.
|
|
24
|
+
if (!this.userManager.settings.automaticSilentRenew) {
|
|
25
|
+
// If automaticSilentRenew is set to true, then the user manager will handle automatic renewal.
|
|
26
|
+
this.userManager.events.addAccessTokenExpiring(this.signinSilent.bind(this));
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
OidcAuthService.prototype.loadUserFromToken = function () {
|
|
27
30
|
return this.loadUserFromSession();
|
|
@@ -43,6 +46,16 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
43
46
|
});
|
|
44
47
|
});
|
|
45
48
|
};
|
|
49
|
+
OidcAuthService.prototype.ensureSignedIn = function (redirectLocal) {
|
|
50
|
+
var settings = this.userManager.settings;
|
|
51
|
+
if (!this.isAuthenticated &&
|
|
52
|
+
(!settings.redirect_uri || !window.location.href.startsWith(settings.redirect_uri)) &&
|
|
53
|
+
(!settings.silent_redirect_uri || !window.location.href.startsWith(settings.silent_redirect_uri))) {
|
|
54
|
+
this.beginSignIn(redirectLocal);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
46
59
|
/**
|
|
47
60
|
* Redirect to identity server to get the auth token.
|
|
48
61
|
* @param redirectPath Local path to redirect to once login is complete.
|
|
@@ -175,6 +188,20 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
175
188
|
introspection_endpoint: identityServerUrl + "/connect/introspect"
|
|
176
189
|
};
|
|
177
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* If this is a silent sign in (based on the current uri), `endSignInSilent()` is called on the oidc client, and this method returns true.
|
|
193
|
+
* This should be called on startup of your app. If this returns true, don't continue with startup, since this iframe will be shortly disposed.
|
|
194
|
+
* @param silentRedirectRoute The app relative path used for silent sign in callbacks.
|
|
195
|
+
*/
|
|
196
|
+
OidcAuthService.isSilentSignIn = function (silentRedirectRoute) {
|
|
197
|
+
var config = Misc.Globals.appService.get(NeoTypes.Config.ConfigModel);
|
|
198
|
+
var silentRedirectUri = "".concat(window.location.origin).concat(config.baseUrl).concat(silentRedirectRoute);
|
|
199
|
+
if (window.location.href.startsWith(silentRedirectUri)) {
|
|
200
|
+
Misc.Globals.appService.get(NeoTypes.Security.AuthenticationService).endSignInSilent();
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
178
205
|
__decorate([
|
|
179
206
|
Observable(),
|
|
180
207
|
__metadata("design:type", Object)
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
export interface IOidcUser {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A JSON Web Token (JWT). Only provided if `openid` scope was requested.
|
|
4
|
+
* The application can access the data decoded by using the `profile` property.
|
|
5
|
+
*/
|
|
6
|
+
id_token?: string;
|
|
7
|
+
/** Typically "Bearer" */
|
|
3
8
|
token_type: string;
|
|
9
|
+
/**
|
|
10
|
+
* The requested access token returned from the OIDC provider. The application can use this token to
|
|
11
|
+
* authenticate itself to the secured resource.
|
|
12
|
+
*/
|
|
4
13
|
access_token: string;
|
|
14
|
+
/** The scopes that the requested access token is valid for. */
|
|
15
|
+
scope?: string;
|
|
5
16
|
profile: any;
|
|
6
|
-
expires_at
|
|
17
|
+
expires_at?: number;
|
|
7
18
|
/** State passed to IDS which is returned to us. */
|
|
8
19
|
state: any;
|
|
9
20
|
readonly expired: boolean | undefined;
|
|
10
21
|
}
|
|
11
22
|
export interface IUserManager {
|
|
12
23
|
events: IUserManagerEvents;
|
|
24
|
+
settings: IUserManagerSettings;
|
|
13
25
|
signinRedirect(args?: any): Promise<any>;
|
|
14
26
|
signinRedirectCallback(url?: string): Promise<IOidcUser>;
|
|
15
27
|
signoutRedirect(args?: any): Promise<any>;
|
|
16
28
|
signoutRedirectCallback(url?: string): Promise<any>;
|
|
17
|
-
signinSilent(args?: any): Promise<IOidcUser>;
|
|
29
|
+
signinSilent(args?: any): Promise<IOidcUser | null>;
|
|
18
30
|
signinSilentCallback(url?: string): Promise<any>;
|
|
19
31
|
clearStaleState(): Promise<void>;
|
|
20
32
|
getUser(): Promise<IOidcUser | null>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
}
|
|
34
|
+
export interface IUserManagerSettings {
|
|
35
|
+
/** The redirect URI of your client application to receive a response from the OIDC/OAuth2 provider */
|
|
36
|
+
redirect_uri?: string;
|
|
37
|
+
/** Flag to indicate if there should be an automatic attempt to renew the access token prior to its expiration */
|
|
38
|
+
automaticSilentRenew?: boolean;
|
|
39
|
+
/** The URL for the page containing the code handling the silent renew */
|
|
40
|
+
silent_redirect_uri?: string;
|
|
24
41
|
}
|
|
25
42
|
export interface IUserManagerEvents {
|
|
26
43
|
addUserLoaded(callback: (...ev: any[]) => void): void;
|
|
@@ -3,11 +3,15 @@ import { ValidationDisplayMode } from '../Misc';
|
|
|
3
3
|
import { IInvalidObject } from './ModelValidator';
|
|
4
4
|
import { IRule } from '../Rules';
|
|
5
5
|
import { IRuleResult } from '../RuleContext';
|
|
6
|
+
import { RuleSeverity } from '../ValidationState';
|
|
6
7
|
export default interface IModelValidator {
|
|
8
|
+
/** Causes all errors to be displayed regardless of ValidationDisplayMode. */
|
|
7
9
|
forceShowErrors: boolean;
|
|
8
|
-
isValid: boolean;
|
|
10
|
+
readonly isValid: boolean;
|
|
11
|
+
/** The max current severity of all rules in this object. */
|
|
12
|
+
readonly severity: RuleSeverity;
|
|
9
13
|
/**
|
|
10
|
-
* Gets the broken rules for this object. If you need the summary for an object graph, use Validation.getValidationSummary()
|
|
14
|
+
* Gets the broken rules for this object (not it's children). If you need the summary for an object graph, use Validation.getValidationSummary()
|
|
11
15
|
*/
|
|
12
16
|
getBrokenRules(): IInvalidObject;
|
|
13
17
|
/**
|
|
@@ -23,6 +23,7 @@ export default class ModelValidator implements IModelValidator {
|
|
|
23
23
|
forceShowErrors: boolean;
|
|
24
24
|
get ruleState(): ContainerValidationState;
|
|
25
25
|
get isValid(): boolean;
|
|
26
|
+
get severity(): import("../ValidationState").RuleSeverity;
|
|
26
27
|
private checkRules;
|
|
27
28
|
/**
|
|
28
29
|
* Gets the broken rules for this object. If you need the summary for an object graph, use Validation.getValidationSummary()
|
|
@@ -63,6 +63,13 @@ var ModelValidator = /** @class */ (function () {
|
|
|
63
63
|
enumerable: false,
|
|
64
64
|
configurable: true
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(ModelValidator.prototype, "severity", {
|
|
67
|
+
get: function () {
|
|
68
|
+
return this.ruleState.severity;
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
66
73
|
ModelValidator.prototype.checkRules = function () {
|
|
67
74
|
var _this = this;
|
|
68
75
|
this._ruleState = new ContainerValidationState();
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { EnumHelper } from './Model/EnumHelper';
|
|
|
11
11
|
import { MenuUtils } from './Components/ContextMenu/MenuUtils';
|
|
12
12
|
import FileUtils from "./FileUtils";
|
|
13
13
|
import { runInTask } from './Components/TaskRunner/Decorators';
|
|
14
|
+
import { createProperty } from "./Model/PropertyInstance";
|
|
14
15
|
import * as Attributes from './Model/Decorators';
|
|
15
16
|
import * as Rules from './Validation/Decorators';
|
|
16
17
|
import * as AppServices from './AppServices';
|
|
@@ -28,7 +29,7 @@ import * as Validation from './Validation';
|
|
|
28
29
|
import * as Views from './Views/IViewBase';
|
|
29
30
|
declare const NotifyUtils: Components.INotificationHelper;
|
|
30
31
|
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
31
|
-
export { runInTask };
|
|
32
|
+
export { runInTask, createProperty };
|
|
32
33
|
export { default as ModelBase } from './Model/ModelBase';
|
|
33
34
|
export { default as ValueObject } from './Model/ValueObject';
|
|
34
35
|
export { LookupBase } from './Model/LookupBase';
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { EnumHelper } from './Model/EnumHelper';
|
|
|
12
12
|
import { MenuUtils } from './Components/ContextMenu/MenuUtils';
|
|
13
13
|
import FileUtils from "./FileUtils";
|
|
14
14
|
import { runInTask } from './Components/TaskRunner/Decorators';
|
|
15
|
+
import { createProperty } from "./Model/PropertyInstance";
|
|
15
16
|
// Namespaced exports from 1 file
|
|
16
17
|
import * as Attributes from './Model/Decorators';
|
|
17
18
|
import * as Rules from './Validation/Decorators';
|
|
@@ -34,7 +35,7 @@ var NotifyUtils = new NotificationHelper();
|
|
|
34
35
|
// Types
|
|
35
36
|
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
36
37
|
// Functions
|
|
37
|
-
export { runInTask };
|
|
38
|
+
export { runInTask, createProperty };
|
|
38
39
|
export { default as ModelBase } from './Model/ModelBase';
|
|
39
40
|
export { default as ValueObject } from './Model/ValueObject';
|
|
40
41
|
export { LookupBase } from './Model/LookupBase';
|