@microsoft/1ds-core-js 3.2.11 → 4.0.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 (95) hide show
  1. package/README.md +1 -1
  2. package/bundle/es5/ms.core-4.0.0.gbl.js +6221 -0
  3. package/bundle/es5/ms.core-4.0.0.gbl.js.map +1 -0
  4. package/bundle/es5/ms.core-4.0.0.gbl.min.js +7 -0
  5. package/bundle/es5/ms.core-4.0.0.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.core-4.0.0.integrity.json +46 -0
  7. package/bundle/es5/ms.core-4.0.0.js +6225 -0
  8. package/bundle/es5/ms.core-4.0.0.js.map +1 -0
  9. package/bundle/es5/ms.core-4.0.0.min.js +7 -0
  10. package/bundle/es5/ms.core-4.0.0.min.js.map +1 -0
  11. package/bundle/es5/ms.core.gbl.js +6221 -0
  12. package/bundle/es5/ms.core.gbl.js.map +1 -0
  13. package/bundle/es5/ms.core.gbl.min.js +7 -0
  14. package/bundle/es5/ms.core.gbl.min.js.map +1 -0
  15. package/bundle/es5/ms.core.integrity.json +46 -0
  16. package/bundle/es5/ms.core.js +6225 -0
  17. package/bundle/es5/ms.core.js.map +1 -0
  18. package/bundle/es5/ms.core.min.js +7 -0
  19. package/bundle/es5/ms.core.min.js.map +1 -0
  20. package/{bundle → dist/es5}/ms.core.js +3790 -2967
  21. package/dist/es5/ms.core.js.map +1 -0
  22. package/dist/es5/ms.core.min.js +7 -0
  23. package/dist/es5/ms.core.min.js.map +1 -0
  24. package/dist-es5/AppInsightsCore.js +91 -0
  25. package/dist-es5/AppInsightsCore.js.map +1 -0
  26. package/{dist-esm/src → dist-es5}/BaseCore.js +18 -11
  27. package/dist-es5/BaseCore.js.map +1 -0
  28. package/{dist-esm/src → dist-es5}/DataModels.js +1 -1
  29. package/{dist-esm/src → dist-es5}/Enums.js +3 -26
  30. package/dist-es5/Enums.js.map +1 -0
  31. package/{dist-esm/src → dist-es5}/Index.js +9 -14
  32. package/dist-es5/Index.js.map +1 -0
  33. package/{dist-esm/src → dist-es5}/InternalConstants.js +1 -3
  34. package/{dist-esm/src → dist-es5}/InternalConstants.js.map +1 -1
  35. package/{dist-esm/src → dist-es5}/Utils.js +19 -144
  36. package/dist-es5/Utils.js.map +1 -0
  37. package/{dist-esm/src → dist-es5}/ValueSanitizer.js +39 -3
  38. package/dist-es5/ValueSanitizer.js.map +1 -0
  39. package/package.json +16 -9
  40. package/tsconfig.json +5 -3
  41. package/types/1ds-core-js.d.ts +1106 -0
  42. package/types/1ds-core-js.namespaced.d.ts +1102 -0
  43. package/bundle/ms.core-3.2.11.gbl.js +0 -5378
  44. package/bundle/ms.core-3.2.11.gbl.js.map +0 -1
  45. package/bundle/ms.core-3.2.11.gbl.min.js +0 -7
  46. package/bundle/ms.core-3.2.11.gbl.min.js.map +0 -1
  47. package/bundle/ms.core-3.2.11.integrity.json +0 -46
  48. package/bundle/ms.core-3.2.11.js +0 -5381
  49. package/bundle/ms.core-3.2.11.js.map +0 -1
  50. package/bundle/ms.core-3.2.11.min.js +0 -7
  51. package/bundle/ms.core-3.2.11.min.js.map +0 -1
  52. package/bundle/ms.core.gbl.js +0 -5378
  53. package/bundle/ms.core.gbl.js.map +0 -1
  54. package/bundle/ms.core.gbl.min.js +0 -7
  55. package/bundle/ms.core.gbl.min.js.map +0 -1
  56. package/bundle/ms.core.integrity.json +0 -46
  57. package/bundle/ms.core.js.map +0 -1
  58. package/bundle/ms.core.min.js +0 -7
  59. package/bundle/ms.core.min.js.map +0 -1
  60. package/dist/ms.core.js +0 -1305
  61. package/dist/ms.core.js.map +0 -1
  62. package/dist/ms.core.min.js +0 -7
  63. package/dist/ms.core.min.js.map +0 -1
  64. package/dist-esm/src/AppInsightsCore.d.ts +0 -15
  65. package/dist-esm/src/AppInsightsCore.js +0 -114
  66. package/dist-esm/src/AppInsightsCore.js.map +0 -1
  67. package/dist-esm/src/BaseCore.d.ts +0 -13
  68. package/dist-esm/src/BaseCore.js.map +0 -1
  69. package/dist-esm/src/DataModels.d.ts +0 -273
  70. package/dist-esm/src/ESPromise.d.ts +0 -110
  71. package/dist-esm/src/ESPromise.js +0 -286
  72. package/dist-esm/src/ESPromise.js.map +0 -1
  73. package/dist-esm/src/ESPromiseScheduler.d.ts +0 -36
  74. package/dist-esm/src/ESPromiseScheduler.js +0 -274
  75. package/dist-esm/src/ESPromiseScheduler.js.map +0 -1
  76. package/dist-esm/src/Enums.d.ts +0 -356
  77. package/dist-esm/src/Enums.js.map +0 -1
  78. package/dist-esm/src/Index.d.ts +0 -19
  79. package/dist-esm/src/Index.js.map +0 -1
  80. package/dist-esm/src/InternalConstants.d.ts +0 -6
  81. package/dist-esm/src/Utils.d.ts +0 -190
  82. package/dist-esm/src/Utils.js.map +0 -1
  83. package/dist-esm/src/ValueSanitizer.d.ts +0 -40
  84. package/dist-esm/src/ValueSanitizer.js.map +0 -1
  85. package/src/AppInsightsCore.ts +0 -135
  86. package/src/BaseCore.ts +0 -72
  87. package/src/DataModels.ts +0 -297
  88. package/src/ESPromise.ts +0 -365
  89. package/src/ESPromiseScheduler.ts +0 -328
  90. package/src/Enums.ts +0 -386
  91. package/src/Index.ts +0 -81
  92. package/src/InternalConstants.ts +0 -16
  93. package/src/Utils.ts +0 -565
  94. package/src/ValueSanitizer.ts +0 -285
  95. /package/{dist-esm/src → dist-es5}/DataModels.js.map +0 -0
@@ -1,285 +0,0 @@
1
- import { isNullOrUndefined, isString, objForEachKey } from "@microsoft/applicationinsights-core-js";
2
- import {
3
- FieldValueSanitizerFunc, FieldValueSanitizerTypes, IEventProperty, IFieldSanitizerDetails, IFieldValueSanitizerProvider, IValueSanitizer
4
- } from "./DataModels";
5
- import { FieldValueSanitizerType } from "./Enums";
6
- import { STR_EMPTY } from "./InternalConstants";
7
- import { getFieldValueType, isValueAssigned, isValueKind } from "./Utils";
8
-
9
- interface ISanitizerMapValue {
10
- canHandle: boolean;
11
- handler?: IValueSanitizer;
12
- fieldHandler?: IFieldValueSanitizerProvider;
13
- }
14
-
15
- export class ValueSanitizer implements IValueSanitizer {
16
-
17
- public static getFieldType = getFieldValueType;
18
-
19
- /**
20
- * Add a value sanitizer as a fallback sanitizer if this sanitizer can't handle the path/name.
21
- */
22
- public addSanitizer: (sanitizer: IValueSanitizer) => void;
23
-
24
- /**
25
- * Adds a field sanitizer to the evaluation list
26
- */
27
- public addFieldSanitizer: (fieldSanitizer: IFieldValueSanitizerProvider) => void;
28
-
29
- /**
30
- * Does this field value sanitizer handle this path / field combination
31
- * @param path - The field path
32
- * @param name - The name of the field
33
- */
34
- public handleField: (path: string, name: string) => boolean;
35
-
36
- /**
37
- * Sanitizes the value. It checks the that the property name and value are valid. It also
38
- * checks/populates the correct type and pii of the property value.
39
- * @param path - The root path of the property
40
- * @param name - The property name.
41
- * @param value - The property value or an IEventProperty containing value, type ,pii and customer content.
42
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
43
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
44
- */
45
- public value: (path: string, name: string, value: FieldValueSanitizerTypes, stringifyObjects?: boolean) => IEventProperty | null;
46
-
47
- /**
48
- * Sanitizes the Property. It checks the that the property name and value are valid. It also
49
- * checks/populates the correct type and pii of the property value.
50
- * @param path - The root path of the property
51
- * @param name - The property name.
52
- * @param property - The property value or an IEventProperty containing value, type ,pii and customer content.
53
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
54
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
55
- */
56
- public property: (path: string, name: string, property: IEventProperty, stringifyObjects?: boolean) => IEventProperty | null;
57
-
58
- constructor(fieldSanitizerProvider?: IFieldValueSanitizerProvider) {
59
- let _self = this;
60
-
61
- // To aid with performance this is a lookup map to check if the field value sanitizer supports this field
62
- let _sanitizerMap: { [path: string]: { [field: string]: ISanitizerMapValue } } = {};
63
- let _sanitizers: IValueSanitizer[] = [];
64
- let _fieldSanitizers: IFieldValueSanitizerProvider[] = [];
65
- if (fieldSanitizerProvider) {
66
- _fieldSanitizers.push(fieldSanitizerProvider);
67
- }
68
-
69
- function _getFieldSanitizer(path: string, name: string): ISanitizerMapValue {
70
- let result: ISanitizerMapValue;
71
- let fieldLookup = _sanitizerMap[path];
72
- if (fieldLookup) {
73
- result = fieldLookup[name];
74
- }
75
-
76
- if (!result && result !== null) {
77
- // Null is a valid result indicating that the value sanitizer does not support this field
78
- if (isString(path) && isString(name)) {
79
- if (_fieldSanitizers.length > 0) {
80
- for (let lp = 0; lp < _fieldSanitizers.length; lp++) {
81
- if (_fieldSanitizers[lp].handleField(path, name)) {
82
- result = {
83
- canHandle: true, // This instance will handle so we won't assign the handler
84
- fieldHandler: _fieldSanitizers[lp]
85
- };
86
- break;
87
- }
88
- }
89
- } else if (_sanitizers.length === 0) {
90
- // Special use-case where there is no sanitizer to pass on to, so just resolving the field
91
- // and returning the resulting value (same as sanitizeProperty())
92
- result = {
93
- canHandle: true
94
- };
95
- }
96
- }
97
-
98
- // We still don't have a handler so lets lookup the providers
99
- if (!result && result !== null) {
100
- // Setting the result to null -- which means we and any contained sanitizers can't handle this field
101
- result = null;
102
- for (let lp = 0; lp < _sanitizers.length; lp++) {
103
- if (_sanitizers[lp].handleField(path, name)) {
104
- result = {
105
- canHandle: true,
106
- handler: _sanitizers[lp],
107
- fieldHandler: null
108
- };
109
- break;
110
- }
111
- }
112
- }
113
-
114
- if (!fieldLookup) {
115
- fieldLookup = _sanitizerMap[path] = {};
116
- }
117
-
118
- fieldLookup[name] = result;
119
- }
120
-
121
- return result;
122
- }
123
-
124
- _self.addSanitizer = (newSanitizer: IValueSanitizer) => {
125
- if (newSanitizer) {
126
- _sanitizers.push(newSanitizer);
127
- // Invalidate any previously mapped fields
128
- _sanitizerMap = {};
129
- }
130
- };
131
-
132
- _self.addFieldSanitizer = (fieldSanitizer: IFieldValueSanitizerProvider) => {
133
- if (fieldSanitizer) {
134
- _fieldSanitizers.push(fieldSanitizer);
135
- // Invalidate any previously mapped fields
136
- _sanitizerMap = {};
137
- }
138
- };
139
-
140
- _self.handleField = (path: string, name: string): boolean => {
141
- let mapValue: ISanitizerMapValue = _getFieldSanitizer(path, name);
142
- return mapValue ? mapValue.canHandle : false;
143
- };
144
-
145
- _self.value = (path: string, name: string, value: FieldValueSanitizerTypes, stringifyObjects?: boolean): IEventProperty | null => {
146
- let mapValue: ISanitizerMapValue = _getFieldSanitizer(path, name);
147
- if (mapValue && mapValue.canHandle) {
148
- if (!mapValue || !mapValue.canHandle) {
149
- return null;
150
- }
151
-
152
- if (mapValue.handler) {
153
- // This value sanitizer can't handle this field so pass it only the next one
154
- return mapValue.handler.value(path, name, value, stringifyObjects);
155
- }
156
-
157
- // Check that property is valid
158
- if (!isString(name) || isNullOrUndefined(value) || (value as any) === STR_EMPTY) {
159
- return null;
160
- }
161
-
162
- let property = null;
163
- let fieldType = getFieldValueType(value);
164
-
165
- if ((fieldType & FieldValueSanitizerType.EventProperty) === FieldValueSanitizerType.EventProperty) {
166
- let subType = fieldType & ~FieldValueSanitizerType.EventProperty;
167
- property = value as IEventProperty;
168
- if (!isValueAssigned(property.value) ||
169
- (subType !== FieldValueSanitizerType.String &&
170
- subType !== FieldValueSanitizerType.Number &&
171
- subType !== FieldValueSanitizerType.Boolean &&
172
- (subType & FieldValueSanitizerType.Array) !== FieldValueSanitizerType.Array)) {
173
-
174
- // Not a supported IEventProperty type to be able to sanitize
175
- return null;
176
- }
177
- } else if (fieldType === FieldValueSanitizerType.String ||
178
- fieldType === FieldValueSanitizerType.Number ||
179
- fieldType === FieldValueSanitizerType.Boolean ||
180
- (fieldType & FieldValueSanitizerType.Array) === FieldValueSanitizerType.Array) {
181
- // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.
182
- property = _convertToProperty(path, name, value);
183
- } else if (fieldType === FieldValueSanitizerType.Object) {
184
- property = _convertToProperty(path, name, !!stringifyObjects ? JSON.stringify(value) : value);
185
- }
186
-
187
- if (property) {
188
- return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);
189
- }
190
- }
191
-
192
- return null;
193
- };
194
-
195
- _self.property = (path: string, name: string, property: IEventProperty, stringifyObjects?: boolean): IEventProperty | null => {
196
- let mapValue: ISanitizerMapValue = _getFieldSanitizer(path, name);
197
- if (!mapValue || !mapValue.canHandle) {
198
- return null;
199
- }
200
-
201
- // Check that property is valid
202
- if (!isString(name) || isNullOrUndefined(property) || !isValueAssigned(property.value)) {
203
- return null;
204
- }
205
-
206
- let fieldType: FieldValueSanitizerType = getFieldValueType(property.value);
207
- if (fieldType === FieldValueSanitizerType.NotSet) {
208
- // Not a supported field that we can sanitize or serialize
209
- return null;
210
- }
211
-
212
- return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);
213
- };
214
-
215
- function _handleProperty(mapValue: ISanitizerMapValue, path: string, name: string, fieldType: FieldValueSanitizerType,
216
- property: IEventProperty, stringifyObjects?: boolean): IEventProperty | null {
217
-
218
- if (mapValue.handler) {
219
- // This value sanitizer can't handle this field so pass it only the next one
220
- return mapValue.handler.property(path, name, property, stringifyObjects);
221
- }
222
-
223
- // If either pii or cc is set convert value to string (since only string pii/cc is allowed).
224
- // If the value is a complex type like an array that can't be converted to string we will drop
225
- // the property.
226
- if (!isNullOrUndefined(property.kind)) {
227
- if ((fieldType & FieldValueSanitizerType.Array) === FieldValueSanitizerType.Array || !isValueKind(property.kind)) {
228
- return null;
229
- }
230
-
231
- // Convert the value to a string and assign back to the original value
232
- property.value = property.value.toString();
233
- }
234
-
235
- return _callFieldSanitizer(mapValue.fieldHandler, path, name, fieldType, property);
236
- }
237
-
238
- function _convertToProperty(path: string, name: string, value: any): IEventProperty | null {
239
- if (isValueAssigned(value)) {
240
- return { value: value } as IEventProperty;
241
- }
242
-
243
- return null;
244
- }
245
-
246
- function _callFieldSanitizer(fieldProvider: IFieldValueSanitizerProvider, path: string, name: string, theType: FieldValueSanitizerType, property: IEventProperty) {
247
- if (property && fieldProvider) {
248
- let sanitizer: FieldValueSanitizerFunc = fieldProvider.getSanitizer(path, name, theType, property.kind, property.propertyType);
249
- if (sanitizer) {
250
- // This is where we the field will call the handler to "scrub" the value. This the primary hook for the ClientHashing Plugin to
251
- // be able to apply the hashFunc() / Sha256 conversion of the properties value
252
- if (theType === FieldValueSanitizerType.Object) {
253
- // Special case of an embedded object (ext.metadata, data.properties)
254
- let newValue: any = { };
255
- let propValue = property.value;
256
- objForEachKey(propValue, (propKey, theValue) => {
257
- let newPath = path + "." + name;
258
- if (isValueAssigned(theValue)) {
259
- let newProp = _convertToProperty(newPath, propKey, theValue);
260
- newProp = _callFieldSanitizer(fieldProvider, newPath, propKey, getFieldValueType(theValue), newProp);
261
- if (newProp) {
262
- newValue[propKey] = newProp.value;
263
- }
264
- }
265
- });
266
-
267
- property.value = newValue;
268
- } else {
269
- let details: IFieldSanitizerDetails = {
270
- path: path,
271
- name: name,
272
- type: theType,
273
- prop: property,
274
- sanitizer: _self
275
- };
276
-
277
- property = sanitizer.call(_self, details);
278
- }
279
- }
280
- }
281
-
282
- return property;
283
- }
284
- }
285
- }
File without changes