@talxis/base-controls 1.2406.13 → 1.2406.15

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.
@@ -1,3413 +1 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { useRef, useState, useEffect } from 'react';
3
- import { useComponent } from './hooks/useComponent.js';
4
- import { mergeStyleSets, useTheme, Link, ContextualMenuItemType } from '@fluentui/react';
5
- import { TagPicker } from '@talxis/react-components/dist/components/TagPicker';
6
- import { Text } from '@fluentui/react/lib/Text';
7
- import { useMouseOver } from './hooks/useMouseOver.js';
8
- import { CommandBarButton } from '@fluentui/react/lib/components/Button/CommandBarButton/CommandBarButton';
9
- import { useFocusIn } from './hooks/useFocusIn.js';
10
- import { useComponentSizing } from './hooks/useComponentSizing.js';
11
-
12
- /******************************************************************************
13
- Copyright (c) Microsoft Corporation.
14
-
15
- Permission to use, copy, modify, and/or distribute this software for any
16
- purpose with or without fee is hereby granted.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
- PERFORMANCE OF THIS SOFTWARE.
25
- ***************************************************************************** */
26
-
27
- function __decorate(decorators, target, key, desc) {
28
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
- return c > 3 && r && Object.defineProperty(target, key, r), r;
32
- }
33
-
34
- function __awaiter(thisArg, _arguments, P, generator) {
35
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
- return new (P || (P = Promise))(function (resolve, reject) {
37
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
- step((generator = generator.apply(thisArg, _arguments || [])).next());
41
- });
42
- }
43
-
44
- const lookupTranslations = {
45
- search: {
46
- 1033: "Search",
47
- 1029: "Vyhledejte"
48
- },
49
- newRecord: {
50
- 1033: "New record",
51
- 1029: "Nový záznam"
52
- },
53
- searching: {
54
- 1033: "Searching...",
55
- 1029: "Hledám..."
56
- },
57
- noRecordsFound: {
58
- 1033: "No records found",
59
- 1029: "Nebyly nalezeny žádné záznamy"
60
- },
61
- resultsFrom: {
62
- 1033: "Results from:",
63
- 1029: "Výsledky z:"
64
- },
65
- noName: {
66
- 1033: "(No Name)",
67
- 1029: "(Bez názvu)"
68
- }
69
- };
70
-
71
- //@ts-nocheck
72
- var Sdk;
73
- (function (Sdk) {
74
- (function (FetchXml) {
75
- var attribute_1, filter_1, linkEntity_1, order_1, value_1;
76
- let attribute = attribute_1 = class attribute {
77
- /**
78
- * Contains the data for a fetchXml attribute element.
79
- * @param name The logical name of the attribute
80
- */
81
- constructor(name) {
82
- this._build = null;
83
- this._addedBy = null;
84
- this._alias = null;
85
- this._aggregate = null;
86
- this._groupBy = null;
87
- this._dateGrouping = null;
88
- this._userTimeZone = null;
89
- //new keyword not required
90
- if (!(this instanceof attribute_1)) {
91
- return new attribute_1(name);
92
- }
93
- this.name = name;
94
- }
95
- /**
96
- *Gets or sets logical name of the attribute
97
- */
98
- get name() {
99
- return this._name;
100
- }
101
- set name(value) {
102
- if (!Util.isString(value)) {
103
- throw new Error("Sdk.FetchXml.attribute name property must be an string.");
104
- }
105
- this._name = value;
106
- }
107
- /**
108
- *Gets or sets the build of the attribute
109
- */
110
- get build() {
111
- return this._build;
112
- }
113
- set build(value) {
114
- if (!Util.isEnumMemberOrNull(Build, value)) {
115
- throw new Error("Sdk.FetchXml.attribute build property must be an Sdk.FetchXml.Build value or null.");
116
- }
117
- this._build = value;
118
- }
119
- /**
120
- *Gets or sets the addedBy property of the attribute
121
- */
122
- get addedBy() {
123
- return this._addedBy;
124
- }
125
- set addedBy(value) {
126
- if (!Util.isStringOrNull(value)) {
127
- throw new Error("Sdk.FetchXml.attribute addedBy property must be an string value or null.");
128
- }
129
- this._addedBy = value;
130
- }
131
- /**
132
- *Gets or sets the alias property of the attribute
133
- */
134
- get alias() {
135
- return this._alias;
136
- }
137
- set alias(value) {
138
- if (!Util.isStringOrNull(value)) {
139
- throw new Error("Sdk.FetchXml.attribute alias property must be an string value or null.");
140
- }
141
- this._alias = value;
142
- }
143
- /**
144
- *Gets or sets the aggregate property of the attribute
145
- */
146
- get aggregate() {
147
- return this._aggregate;
148
- }
149
- set aggregate(value) {
150
- if (!Util.isEnumMemberOrNull(Aggregate, value)) {
151
- throw new Error("Sdk.FetchXml.attribute aggregate property must be an Sdk.FetchXml.Aggregate value or null.");
152
- }
153
- this._aggregate = value;
154
- }
155
- /**
156
- *Gets or sets the groupBy property of the attribute
157
- */
158
- get groupBy() {
159
- return this._groupBy;
160
- }
161
- set groupBy(value) {
162
- if (!Util.isBooleanOrNull(value)) {
163
- throw new Error("Sdk.FetchXml.attribute groupBy property must be an boolean value or null.");
164
- }
165
- this._groupBy = value;
166
- }
167
- /**
168
- * Gets or sets the dateGrouping property of the attribute
169
- */
170
- get dateGrouping() {
171
- return this._dateGrouping;
172
- }
173
- set dateGrouping(value) {
174
- if (!Util.isEnumMemberOrNull(DateGrouping, value)) {
175
- throw new Error("Sdk.FetchXml.attribute dateGrouping property must be an Sdk.FetchXml.DateGrouping value or null.");
176
- }
177
- this._dateGrouping = value;
178
- }
179
- /**
180
- *Gets or sets the userTimeZone property of the attribute
181
- */
182
- get userTimeZone() {
183
- return this._userTimeZone;
184
- }
185
- set userTimeZone(value) {
186
- if (!Util.isBooleanOrNull(value)) {
187
- throw new Error("Sdk.FetchXml.attribute userTimeZone property must be an boolean value or null.");
188
- }
189
- this._userTimeZone = value;
190
- }
191
- /** @description Sets the name property of the attribute attribute
192
- * @param {string} name The name value to apply to the attribute
193
- * @returns {Sdk.FetchXml.attribute}
194
- */
195
- setName(name) {
196
- this.name = name;
197
- return this;
198
- }
199
- /** @description Sets the build property of the build attribute
200
- * @param {Sdk.FetchXml.Build | null} build The build value to apply to the attribute
201
- * @returns {Sdk.FetchXml.attribute}
202
- */
203
- setBuild(build) {
204
- (build) ? this.build = build : this.build = null;
205
- return this;
206
- }
207
- /** @description Sets the addedBy property of the attribute attribute
208
- * @param {string | null} addedBy The addedBy value to apply to the attribute
209
- * @returns {Sdk.FetchXml.attribute}
210
- */
211
- setAddedBy(addedBy) {
212
- (addedBy) ? this.addedBy = addedBy : this.addedBy = null;
213
- return this;
214
- }
215
- /** @description Sets the alias property of the attribute attribute
216
- * @param {string} alias The alias value to apply to the attribute
217
- * @returns {Sdk.FetchXml.attribute}
218
- */
219
- setAlias(alias) {
220
- (alias) ? this.alias = alias : this.alias = null;
221
- return this;
222
- }
223
- /** @description Sets the aggregate property of the attribute attribute
224
- * @param {Sdk.FetchXml.Aggregate | null } aggregate The aggregate value to apply to the attribute
225
- * @returns {Sdk.FetchXml.attribute}
226
- */
227
- setAggregate(aggregate) {
228
- (aggregate) ? this.aggregate = aggregate : this.aggregate = null;
229
- return this;
230
- }
231
- /** @description Sets the groupBy property of the attribute attribute
232
- * @param {boolean | null} groupBy The groupBy value to apply to the attribute
233
- * @returns {Sdk.FetchXml.attribute}
234
- */
235
- setGroupBy(groupBy) {
236
- (groupBy) ? this.groupBy = groupBy : groupBy = null;
237
- return this;
238
- }
239
- /** @description Sets the dateGrouping property of the attribute attribute
240
- * @param {Sdk.FetchXml.DateGrouping | null} dateGrouping The dateGrouping value to apply to the attribute
241
- * @returns {Sdk.FetchXml.attribute}
242
- */
243
- setDateGrouping(dateGrouping) {
244
- (dateGrouping) ? this.dateGrouping = dateGrouping : this.dateGrouping = null;
245
- return this;
246
- }
247
- /** @description Sets the userTimeZone property of the attribute attribute
248
- * @param {boolean | null} userTimeZone The userTimeZone value to apply to the attribute
249
- * @returns {Sdk.FetchXml.attribute}
250
- */
251
- setUserTimeZone(userTimeZone) {
252
- (userTimeZone) ? this.userTimeZone = userTimeZone : this.userTimeZone = null;
253
- return this;
254
- }
255
- //Internal use only
256
- toXml(doc) {
257
- var aNode = doc.createElement("attribute");
258
- aNode.setAttribute("name", this.name);
259
- if (this.build) {
260
- aNode.setAttribute("build", this.build);
261
- }
262
- if (this.addedBy) {
263
- aNode.setAttribute("addedby", this.addedBy);
264
- }
265
- if (this.alias) {
266
- aNode.setAttribute("alias", this.alias);
267
- }
268
- if (this.aggregate) {
269
- aNode.setAttribute("aggregate", this.aggregate);
270
- }
271
- if (Util.isBoolean(this.groupBy)) {
272
- aNode.setAttribute("groupby", (this.groupBy) ? "true" : "false");
273
- }
274
- if (this.dateGrouping) {
275
- aNode.setAttribute("dategrouping", this.dateGrouping);
276
- }
277
- if (Util.isBoolean(this.userTimeZone)) {
278
- aNode.setAttribute("usertimezone", (this.userTimeZone) ? "true" : "false");
279
- }
280
- return aNode;
281
- }
282
- //Internal use only
283
- static attributeFromXml(xml) {
284
- var attObj = new attribute_1(xml.attributes.getNamedItem("name").nodeValue);
285
- Util.parseAttributes(xml, attObj, (attObj, name, value) => {
286
- switch (name) {
287
- case "build":
288
- case "alias":
289
- case "aggregate":
290
- attObj[name] = value;
291
- break;
292
- case "addedby":
293
- attObj.addedBy = value;
294
- break;
295
- case "dategrouping":
296
- attObj.dateGrouping = value;
297
- break;
298
- case "groupby":
299
- attObj.groupBy = Util.convertFetchBoolType(value);
300
- case "usertimezone":
301
- attObj.userTimeZone = Util.convertFetchBoolType(value);
302
- break;
303
- }
304
- });
305
- return attObj;
306
- }
307
- };
308
- attribute = attribute_1 = __decorate([
309
- sealed
310
- ], attribute);
311
- FetchXml.attribute = attribute;
312
- let condition = class condition {
313
- /**
314
- * Contains the data for a fetchXml condition element.
315
- * @param attribute The attribute to evaluate in the condition
316
- * @param operator The operator to use when evaluating the attribute
317
- * @param [values] The value(s) to apply in the comparison.
318
- */
319
- constructor(attribute, operator, values) {
320
- this._aggregate = null;
321
- this._alias = null;
322
- this._attribute = null;
323
- this._column = null;
324
- this._entityname = null;
325
- this._operator = null;
326
- this._rowAggregate = null;
327
- this._uihidden = null;
328
- this._uiname = null;
329
- this._uitype = null;
330
- this._values = [];
331
- //New keyword not required in JS
332
- if (!(this instanceof Sdk.FetchXml.condition)) {
333
- return new Sdk.FetchXml.condition(attribute, operator, values);
334
- }
335
- if (attribute && operator) {
336
- this.attribute = attribute;
337
- this.operator = operator;
338
- }
339
- else {
340
- throw new Error("Sdk.FetchXml.condition constructor parameters attribute and operator are required.");
341
- }
342
- if (values)
343
- this.values = values;
344
- }
345
- /**
346
- * Gets or sets the aggregate value to apply to the condition.
347
- */
348
- get aggregate() {
349
- return this._aggregate;
350
- }
351
- set aggregate(value) {
352
- this._aggregate = value;
353
- }
354
- /**
355
- * Gets or sets the alias value to apply to the condition.
356
- */
357
- get alias() {
358
- return this._alias;
359
- }
360
- set alias(value) {
361
- this._alias = value;
362
- }
363
- /**
364
- * Gets or sets the attribute value to apply to the condition.
365
- */
366
- get attribute() {
367
- return this._attribute;
368
- }
369
- set attribute(value) {
370
- this._attribute = value;
371
- }
372
- /**
373
- * Gets or sets the column attribute value to apply to the condition.
374
- */
375
- get column() {
376
- return this._column;
377
- }
378
- set column(value) {
379
- this._column = value;
380
- }
381
- /**
382
- * Gets or sets the entityname attribute value to apply to the condition.
383
- */
384
- get entityname() {
385
- return this._entityname;
386
- }
387
- set entityname(value) {
388
- this._entityname = value;
389
- }
390
- /**
391
- * Gets or sets the operator attribute value to apply to the condition.
392
- */
393
- get operator() {
394
- return this._operator;
395
- }
396
- set operator(value) {
397
- this._operator = value;
398
- }
399
- /**
400
- * Gets or sets the rowAggregate attribute value to apply to the condition.
401
- */
402
- get rowAggregate() {
403
- return this._rowAggregate;
404
- }
405
- set rowAggregate(value) {
406
- this._rowAggregate = value;
407
- }
408
- /**
409
- * Gets or sets the uihidden attribute value to apply to the condition.
410
- */
411
- get uihidden() {
412
- return this._uihidden;
413
- }
414
- set uihidden(value) {
415
- this._uihidden = value;
416
- }
417
- /**
418
- * Gets or sets the uiname attribute value to apply to the condition.
419
- */
420
- get uiname() {
421
- return this._uiname;
422
- }
423
- set uiname(value) {
424
- this._uiname = value;
425
- }
426
- /**
427
- * Gets or sets the uitype attribute value to apply to the condition.
428
- */
429
- get uitype() {
430
- return this._uitype;
431
- }
432
- set uitype(value) {
433
- this._uitype = value;
434
- }
435
- /**
436
- * Gets or sets the array of values to be applied to the query results
437
- */
438
- get values() {
439
- return this._values;
440
- }
441
- set values(value) {
442
- if (!Sdk.FetchXml.Util.isValueArrayOrNull(value)) {
443
- throw new Error("Sdk.FetchXml.condition.values must be an array of Sdk.FetchXml.value or null.");
444
- }
445
- if (value == null) {
446
- this._values = [];
447
- }
448
- else {
449
- this._values = value;
450
- }
451
- }
452
- //Internal use only
453
- get hash() {
454
- var s = this._attribute.concat(this._operator, (this._aggregate ? this._aggregate : ""), (this._alias ? this._alias : ""), (this._column ? this._column : ""), (this._entityname ? this._entityname : ""), (this._rowAggregate ? this._rowAggregate : ""), (Sdk.FetchXml.Util.isNullOrUndefined(this._uihidden) ? "" : this._uihidden.toString()), (this._uiname ? this._uiname : ""), (this._uitype ? this._uitype : ""), Sdk.FetchXml.Util.getCollectionHash(this._values));
455
- return s.hashCode();
456
- }
457
- /** @description Sets the value of the condition attribute
458
- * @param {string} attribute The attribute to evaluate in the condition.
459
- * @returns {Sdk.FetchXml.condition}
460
- */
461
- setAttribute(attributeName) {
462
- this.attribute = attributeName;
463
- return this;
464
- }
465
- /** @description Sets the value of the condition attribute
466
- * @param {Sdk.FetchXml.Operator} operator The operator to use when evaluating the attribute.
467
- * @returns {Sdk.FetchXml.condition}
468
- */
469
- setOperator(operator) {
470
- this.operator = operator;
471
- return this;
472
- }
473
- /** @description Sets the value of the condition operator
474
- * @param {Array} values The the value(s) to apply in the comparison.
475
- * @returns {Sdk.FetchXml.condition}
476
- */
477
- setValues(values) {
478
- this.values = values;
479
- return this;
480
- }
481
- /** @description Adds a value to the values to apply in the comparison
482
- * @param {Sdk.FetchXml.value | any} value The the value to add to the values.
483
- * @returns {Sdk.FetchXml.condition}
484
- */
485
- addValue(value) {
486
- if (Sdk.FetchXml.Util.isValue(value)) {
487
- this.values.push(value);
488
- }
489
- else {
490
- this.values.push(new Sdk.FetchXml.value(value));
491
- }
492
- return this;
493
- }
494
- /** @description Removes any values from the values collection by reference
495
- * @param {Sdk.FetchXml.value} value The value to remove from the values collection
496
- * @returns {Sdk.FetchXml.condition}
497
- */
498
- removeValueByRef(value) {
499
- if (!Sdk.FetchXml.Util.isValue(value)) {
500
- throw new Error("Sdk.FetchXml.condition removeValueByRef method value parameter must be an Sdk.FetchXml.value.");
501
- }
502
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.values, value);
503
- return this;
504
- }
505
- /** @description Removes all matching values from the values collection
506
- * @param {Sdk.FetchXml.value} value The value to remove from the values collection
507
- * @returns {Sdk.FetchXml.condition}
508
- */
509
- removeValue(value) {
510
- if (!Sdk.FetchXml.Util.isValue(value)) {
511
- throw new Error("Sdk.FetchXml.condition removeValue method value parameter must be an Sdk.FetchXml.value.");
512
- }
513
- Sdk.FetchXml.Util.removeCollectionValue(this.values, value);
514
- return this;
515
- }
516
- /** @description Removes all any values from the values collection with the specified value property
517
- * @param {object} value The value to remove from the values collection
518
- * @returns {Sdk.FetchXml.condition}
519
- */
520
- removeValueByValue(value) {
521
- Sdk.FetchXml.Util.removeCollectionValueByProperty(this.values, "value", value);
522
- return this;
523
- }
524
- /** @description Sets the Aggregate to apply in the condition
525
- * @param {Sdk.FetchXml.Aggregate} aggregate The Aggregate to apply in the condition
526
- * @returns {Sdk.FetchXml.condition}
527
- */
528
- setAggregate(aggregate) {
529
- this.aggregate = aggregate;
530
- return this;
531
- }
532
- /** @description Sets the Alias to apply in the condition
533
- * @param {string} alias The alias to apply in the condition
534
- * @returns {Sdk.FetchXml.condition}
535
- */
536
- setAlias(alias) {
537
- this.alias = alias;
538
- return this;
539
- }
540
- /** @description Sets the Column to apply in the condition
541
- * @param {string} column The column to apply in the condition
542
- * @returns {Sdk.FetchXml.condition}
543
- */
544
- setColumn(column) {
545
- this.column = column;
546
- return this;
547
- }
548
- /** @description Sets the entityname to apply in the condition
549
- * @param {string} entityname The entityname to apply in the condition
550
- * @returns {Sdk.FetchXml.condition}
551
- */
552
- setEntityname(entityname) {
553
- this.entityname = entityname;
554
- return this;
555
- }
556
- /** @description Sets the rowAggregate to apply in the condition
557
- * @param {Sdk.FetchXml.RowAggregate} rowAggregate The rowAggregate to apply in the condition
558
- * @returns {Sdk.FetchXml.condition}
559
- */
560
- setRowAggregate(rowAggregate) {
561
- this.rowAggregate = rowAggregate;
562
- return this;
563
- }
564
- /** @description Sets the uihidden to apply in the condition
565
- * @param {boolean | null} uihidden The uihidden to apply in the condition
566
- * @returns {Sdk.FetchXml.condition}
567
- */
568
- setUIhidden(uihidden) {
569
- this.uihidden = uihidden;
570
- return this;
571
- }
572
- /** @description Sets the uiname to apply in the condition
573
- * @param {string} uihidden The uiname to apply in the condition
574
- * @returns {Sdk.FetchXml.condition}
575
- */
576
- setUIname(uiname) {
577
- this.uiname = uiname;
578
- return this;
579
- }
580
- /** @description Sets the uitype to apply in the condition
581
- * @param {string} uitype The uitype to apply in the condition
582
- * @returns {Sdk.FetchXml.condition}
583
- */
584
- setUItype(uitype) {
585
- this.uitype = uitype;
586
- return this;
587
- }
588
- //Internal use only
589
- toXml(doc) {
590
- var cNode = doc.createElement("condition");
591
- if (this.aggregate) {
592
- cNode.setAttribute("aggregate", this.aggregate);
593
- }
594
- if (this.alias) {
595
- cNode.setAttribute("alias", this.alias);
596
- }
597
- if (this.attribute) {
598
- cNode.setAttribute("attribute", this.attribute);
599
- }
600
- if (this.column) {
601
- cNode.setAttribute("column", this.column);
602
- }
603
- if (this.entityname) {
604
- cNode.setAttribute("entityname", this.entityname);
605
- }
606
- if (this.operator) {
607
- cNode.setAttribute("operator", this.operator);
608
- }
609
- if (this.rowAggregate) {
610
- cNode.setAttribute("rowAggregate", this.rowAggregate);
611
- }
612
- if (Sdk.FetchXml.Util.isBoolean(this.uihidden)) {
613
- cNode.setAttribute("uihidden", this.uihidden.toString());
614
- }
615
- if (this.uiname) {
616
- cNode.setAttribute("uiname", this.uiname);
617
- }
618
- if (this.uitype) {
619
- cNode.setAttribute("uitype", this.uitype);
620
- }
621
- /*
622
- Note from fetch.xsd:
623
- The attribute "value" is used for all operators that compare to a single value (for example, eq).
624
- The element "value" is used for operators that compare to multiple values (for example, in).
625
- Some operators require neither the attribute "value" or the element "value" (for example, null).
626
-
627
- Groupings below are guesses and not confirmed.
628
- */
629
- switch (this.operator) {
630
- //Operators used for single values
631
- case "begins-with":
632
- case "ends-with":
633
- case "eq":
634
- case "ge":
635
- case "gt":
636
- case "last-x-days":
637
- case "last-x-fiscal-periods":
638
- case "last-x-fiscal-years":
639
- case "last-x-hours":
640
- case "last-x-months":
641
- case "last-x-weeks":
642
- case "last-x-years":
643
- case "last-year":
644
- case "le":
645
- case "like":
646
- case "lt":
647
- case "ne":
648
- case "neq": //Is this the same as 'ne'?
649
- case "next-x-days":
650
- case "next-x-fiscal-periods":
651
- case "next-x-fiscal-years":
652
- case "next-x-hours":
653
- case "next-x-months":
654
- case "next-x-weeks":
655
- case "next-x-years":
656
- case "not-begin-with":
657
- case "not-end-with":
658
- case "not-like":
659
- case "olderthan-x-days":
660
- case "olderthan-x-hours":
661
- case "olderthan-x-minutes":
662
- case "olderthan-x-months":
663
- case "olderthan-x-weeks":
664
- case "olderthan-x-years":
665
- case "on":
666
- case "on-or-after":
667
- case "on-or-before":
668
- case "in-fiscal-period":
669
- case "in-fiscal-year":
670
- if (this.values.length == 1) {
671
- cNode.setAttribute("value", this.values[0].value);
672
- }
673
- else {
674
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
675
- throw new Error("Sdk.FetchXml.condition values property must contain single value when the Sdk.FetchXml.Operator." + enumPropertyName + " operator is used.");
676
- }
677
- break;
678
- //Operators used for multiple values
679
- case "between":
680
- case "in":
681
- case "not-between":
682
- case "not-in":
683
- case "in-fiscal-period-and-year":
684
- case "in-or-after-fiscal-period-and-year":
685
- case "in-or-before-fiscal-period-and-year":
686
- if (this.values.length > 1) {
687
- this.values.forEach(function (v) {
688
- cNode.appendChild(v.toXml(doc));
689
- });
690
- }
691
- else {
692
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
693
- throw new Error("Sdk.FetchXml.condition values property must contain multiple values when the Sdk.FetchXml.Operator." + enumPropertyName + " operator is used.");
694
- }
695
- break;
696
- //Operators that require no values
697
- case "above":
698
- case "eq-businessid":
699
- case "eq-or-above":
700
- case "eq-or-under":
701
- case "eq-userid": //?
702
- case "eq-userlanguage": //?
703
- case "eq-useroruserhierarchy":
704
- case "eq-useroruserhierarchyandteams":
705
- case "eq-useroruserteams":
706
- case "eq-userteams":
707
- case "last-fiscal-period":
708
- case "last-fiscal-year":
709
- case "last-month":
710
- case "last-seven-days":
711
- case "last-week":
712
- case "ne-businessid": //?
713
- case "ne-userid": //?
714
- case "next-fiscal-period":
715
- case "next-fiscal-year":
716
- case "next-month":
717
- case "next-seven-days":
718
- case "next-week":
719
- case "next-year":
720
- case "not-null":
721
- case "not-under":
722
- case "null":
723
- case "this-fiscal-period":
724
- case "this-fiscal-year":
725
- case "this-month":
726
- case "this-week":
727
- case "this-year":
728
- case "today":
729
- case "tomorrow":
730
- case "under":
731
- case "yesterday":
732
- //No value required
733
- if (this.values.length > 0) {
734
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
735
- console.log("Sdk.FetchXml.condition doesn't require values when the Sdk.FetchXml.Operator.%s operator is used. The values passed were ignored.", enumPropertyName);
736
- }
737
- break;
738
- default:
739
- throw new Error(this.operator + " is an unexpected Sdk.FetchXml.Operator value.");
740
- }
741
- return cNode;
742
- }
743
- //Internal use only
744
- static conditionFromXml(xml) {
745
- var attributeName = xml.attributes.getNamedItem("attribute").nodeValue;
746
- var operator = xml.attributes.getNamedItem("operator").nodeValue;
747
- var conditionObj = new Sdk.FetchXml.condition(attributeName, operator);
748
- Sdk.FetchXml.Util.parseAttributes(xml, conditionObj, (conditionObj, name, value) => {
749
- switch (name) {
750
- case "column":
751
- case "entityname":
752
- case "aggregate":
753
- case "alias":
754
- case "uiname":
755
- case "uitype":
756
- conditionObj[name] = value;
757
- break;
758
- case "rowaggregate":
759
- conditionObj.rowAggregate = value;
760
- break;
761
- case "uihidden":
762
- conditionObj.uihidden = Util.convertFetchBoolType(value);
763
- break;
764
- case "value":
765
- conditionObj.addValue(value);
766
- break;
767
- }
768
- });
769
- for (var i = 0; i < xml.childNodes.length; i++) {
770
- if (xml.childNodes[i].nodeName == "value") {
771
- conditionObj.addValue(value.valueFromXml(xml.childNodes[i]));
772
- }
773
- }
774
- return conditionObj;
775
- }
776
- };
777
- condition = __decorate([
778
- sealed
779
- ], condition);
780
- FetchXml.condition = condition;
781
- let entity = class entity {
782
- /**
783
- * Contains the data for a fetchXml entity element.
784
- * @param name The logical name of the attribute
785
- * @param [attributes] The attributes to include with the entity
786
- * @param [orders] The orders to apply to the query
787
- * @param [filters] The filters to apply to the query
788
- */
789
- constructor(name, attributes, orders, filters) {
790
- this._allAttributes = null;
791
- this._attributes = [];
792
- this._orders = [];
793
- this._linkEntities = [];
794
- this._filters = [];
795
- if (!(this instanceof Sdk.FetchXml.entity)) {
796
- return new Sdk.FetchXml.entity(name, attributes, orders, filters);
797
- }
798
- this.name = name;
799
- if (attributes)
800
- this.attributes = attributes;
801
- if (orders)
802
- this.orders = orders;
803
- if (filters)
804
- this.filters = filters;
805
- }
806
- /**
807
- * Gets or sets whether all attributes for the entity should be returned
808
- */
809
- get allAttributes() {
810
- return this._allAttributes;
811
- }
812
- set allAttributes(value) {
813
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
814
- throw new Error("Sdk.FetchXml.entity.allAttributes must be a boolean value or null.");
815
- }
816
- this._allAttributes = value;
817
- }
818
- /**
819
- * Gets or sets the array of attribute of the entity to be returned in the query results
820
- */
821
- get attributes() {
822
- return this._attributes;
823
- }
824
- set attributes(value) {
825
- if (!Sdk.FetchXml.Util.isAttributeArrayOrNull(value)) {
826
- throw new Error("Sdk.FetchXml.entity.attributes must be an array of Sdk.FetchXml.attribute or null.");
827
- }
828
- if (value == null) {
829
- this._attributes = [];
830
- }
831
- else {
832
- this._attributes = value;
833
- }
834
- }
835
- /**
836
- * Gets or sets the array of attribute of the entity to be returned in the query results
837
- */
838
- get orders() {
839
- return this._orders;
840
- }
841
- set orders(value) {
842
- if (!Sdk.FetchXml.Util.isOrderArrayOrNull(value)) {
843
- throw new Error("Sdk.FetchXml.entity.orders must be an array of Sdk.FetchXml.order or null.");
844
- }
845
- if (value == null) {
846
- this._orders = [];
847
- }
848
- else {
849
- this._orders = value;
850
- }
851
- }
852
- /**
853
- * Gets or sets the array of related entities to be returned in the query results
854
- */
855
- get linkEntities() {
856
- return this._linkEntities;
857
- }
858
- set linkEntities(value) {
859
- if (!Sdk.FetchXml.Util.isLinkEntityArrayOrNull(value)) {
860
- throw new Error("Sdk.FetchXml.entity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");
861
- }
862
- if (value == null) {
863
- this._linkEntities = [];
864
- }
865
- else {
866
- this._linkEntities = value;
867
- }
868
- }
869
- /**
870
- * Gets or sets the array of filters to be applied to the query results
871
- */
872
- get filters() {
873
- return this._filters;
874
- }
875
- set filters(value) {
876
- if (!Sdk.FetchXml.Util.isFilterArrayOrNull(value)) {
877
- throw new Error("Sdk.FetchXml.entity.filters must be an array of Sdk.FetchXml.filter or null.");
878
- }
879
- if (value == null) {
880
- this._filters = [];
881
- }
882
- else {
883
- this._filters = value;
884
- }
885
- }
886
- /**
887
- * Gets or sets the logical name of the entity
888
- */
889
- get name() {
890
- return this._name;
891
- }
892
- set name(value) {
893
- if (!Sdk.FetchXml.Util.isString(value)) {
894
- throw new Error("Sdk.FetchXml.entity.name must be a string.");
895
- }
896
- this._name = value;
897
- }
898
- /** @description Adds an attribute to the attribute collection
899
- * @param {Sdk.FetchXml.attribute | string} attributeOrAttributeName the attribute or attribute name to add
900
- * @returns {Sdk.FetchXml.entity}
901
- */
902
- addAttribute(attributeOrAttributeName) {
903
- if (Sdk.FetchXml.Util.isString(attributeOrAttributeName)) {
904
- // Some saved queries have duplicate attributes defined, so this is a bit more strict than it has to be.
905
- var exists = false;
906
- this.attributes.forEach(function (a) {
907
- if (a.name == attributeOrAttributeName) {
908
- exists = true;
909
- }
910
- });
911
- if (!exists) {
912
- this.attributes.push(new Sdk.FetchXml.attribute(attributeOrAttributeName));
913
- }
914
- return this;
915
- }
916
- if (Sdk.FetchXml.Util.isAttribute(attributeOrAttributeName)) {
917
- var exists = false;
918
- this.attributes.forEach(function (a) {
919
- if (a.name == attributeOrAttributeName.name) {
920
- exists = true;
921
- }
922
- });
923
- if (!exists) {
924
- this.attributes.push(attributeOrAttributeName);
925
- }
926
- }
927
- else {
928
- throw new Error("Sdk.FetchXml.entity addAttribute method attributeOrAttributeName parameter must be an Sdk.FetchXml.attribute or a string value.");
929
- }
930
- return this;
931
- }
932
- /** @description Removes an attribute from the attributes collection by name
933
- * @param {string} attributeName The name of the attribute to remove
934
- * @returns {Sdk.FetchXml.entity}
935
- */
936
- removeAttributeByName(attributeName) {
937
- Sdk.FetchXml.Util.removeCollectionValueByProperty(this.attributes, "name", attributeName);
938
- }
939
- /** @description Removes an attribute from the attributes collection by reference
940
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove
941
- * @returns {Sdk.FetchXml.entity}
942
- */
943
- removeAttributeByRef(attribute) {
944
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.attributes, attribute);
945
- }
946
- /** @description Removes an attribute from the attributes collection
947
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove
948
- * @returns {Sdk.FetchXml.entity}
949
- */
950
- removeAttribute(attribute) {
951
- Sdk.FetchXml.Util.removeCollectionValue(this.attributes, attribute);
952
- }
953
- /** @description Adds an order to the orders collection
954
- * @param {Sdk.FetchXml.order | string} orderOrAttribute The order to add to the attributes collection or the Attribute property of a new order to create
955
- * @param {boolean} descending Whether the order is descending. True if descending, otherwise false
956
- * @param {string} alias The alias to set for the order
957
- * @returns {Sdk.FetchXml.entity}
958
- */
959
- addOrder(orderOrAttribute, descending, alias) {
960
- if (Sdk.FetchXml.Util.isOrder(orderOrAttribute)) {
961
- this.orders.push(orderOrAttribute);
962
- return this;
963
- }
964
- if (Sdk.FetchXml.Util.isString(orderOrAttribute)) {
965
- this.orders.push(new Sdk.FetchXml.order(orderOrAttribute, descending, alias));
966
- }
967
- else {
968
- throw new Error("Sdk.FetchXml.entity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.");
969
- }
970
- return this;
971
- }
972
- /** @description Removes a order from the orders collection by reference
973
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
974
- * @returns {Sdk.FetchXml.entity}
975
- */
976
- removeOrderByRef(order) {
977
- if (!Sdk.FetchXml.Util.isOrder(order)) {
978
- throw new Error("Sdk.FetchXml.entity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");
979
- }
980
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.orders, order);
981
- return this;
982
- }
983
- /** @description Removes a order from the orders collection by value
984
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
985
- * @returns {Sdk.FetchXml.entity}
986
- */
987
- removeOrder(order) {
988
- if (!Sdk.FetchXml.Util.isOrder(order)) {
989
- throw new Error("Sdk.FetchXml.entity removeOrder method order parameter must be an Sdk.FetchXml.order.");
990
- }
991
- Sdk.FetchXml.Util.removeCollectionValue(this.orders, order);
992
- return this;
993
- }
994
- /** @description Sets the name property of the entity element
995
- * @param {string} name The name value to apply to the entity
996
- * @returns {Sdk.FetchXml.entity}
997
- */
998
- setName(name) {
999
- this.name = name;
1000
- return this;
1001
- }
1002
- /** @description Sets the allAttributes property of the entity
1003
- * @param {boolean} [allAttributes] The allAttributes value to apply to the entity. The default is true;
1004
- * @returns {Sdk.FetchXml.entity}
1005
- */
1006
- setAllAttributes(allAttributes) {
1007
- if (Sdk.FetchXml.Util.isBoolean(allAttributes)) {
1008
- this.allAttributes = allAttributes;
1009
- }
1010
- else {
1011
- if (Sdk.FetchXml.Util.isNullOrUndefined(allAttributes)) {
1012
- this.allAttributes = true;
1013
- }
1014
- else {
1015
- throw new Error("Sdk.FetchXml.entity setAllAttributes method allAttributes parameter must be a boolean value or null.");
1016
- }
1017
- }
1018
- return this;
1019
- }
1020
- /** @description Adds an linkEntity to the linkEntities collection
1021
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to add to the entity
1022
- * @returns {Sdk.FetchXml.entity}
1023
- */
1024
- addLinkEntity(linkEntity) {
1025
- if (Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1026
- this.linkEntities.push(linkEntity);
1027
- return this;
1028
- }
1029
- else {
1030
- throw new Error("Sdk.FetchXml.entity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.");
1031
- }
1032
- }
1033
- /** @description Removes a linkEntity from the linkEntities collection by reference
1034
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
1035
- * @returns {Sdk.FetchXml.entity}
1036
- */
1037
- removeLinkEntityByRef(linkEntity) {
1038
- if (!Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1039
- throw new Error("Sdk.FetchXml.entity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
1040
- }
1041
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.linkEntities, linkEntity);
1042
- return this;
1043
- }
1044
- /** @description Removes a linkEntity from the linkEntities collection by value
1045
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
1046
- * @returns {Sdk.FetchXml.entity}
1047
- */
1048
- removeLinkEntity(linkEntity) {
1049
- if (!Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1050
- throw new Error("Sdk.FetchXml.entity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
1051
- }
1052
- Sdk.FetchXml.Util.removeCollectionValue(this.linkEntities, linkEntity);
1053
- return this;
1054
- }
1055
- /** @description Adds an filter to the filters collection
1056
- * @param {Sdk.FetchXml.filter} filter The filter to add to the entity
1057
- * @returns {Sdk.FetchXml.entity}
1058
- */
1059
- addFilter(filter) {
1060
- if (Sdk.FetchXml.Util.isFilter(filter)) {
1061
- this.filters.push(filter);
1062
- return this;
1063
- }
1064
- else {
1065
- throw new Error("Sdk.FetchXml.entity addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
1066
- }
1067
- }
1068
- /** @description Removes a filter from the filters collection by reference
1069
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
1070
- * @returns {Sdk.FetchXml.entity}
1071
- */
1072
- removeFilterByRef(filter) {
1073
- if (!Sdk.FetchXml.Util.isFilter(filter)) {
1074
- throw new Error("Sdk.FetchXml.entity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
1075
- }
1076
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.filters, filter);
1077
- return this;
1078
- }
1079
- /** @description Removes a filter from the filters collection by value
1080
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
1081
- * @returns {Sdk.FetchXml.entity}
1082
- */
1083
- removeFilter(filter) {
1084
- if (!Sdk.FetchXml.Util.isFilter(filter)) {
1085
- throw new Error("Sdk.FetchXml.entity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
1086
- }
1087
- Sdk.FetchXml.Util.removeCollectionValue(this.filters, filter);
1088
- return this;
1089
- }
1090
- //internal use only
1091
- toXml(doc) {
1092
- var entityNode = doc.createElement("entity");
1093
- if (this.allAttributes) {
1094
- entityNode.appendChild(doc.createElement("all-attributes"));
1095
- }
1096
- else {
1097
- this.attributes.forEach(function (a, i) {
1098
- entityNode.appendChild(a.toXml(doc));
1099
- });
1100
- }
1101
- this.orders.forEach(function (o, i) {
1102
- entityNode.appendChild(o.toXml(doc));
1103
- });
1104
- this.linkEntities.forEach(function (l, i) {
1105
- entityNode.appendChild(l.toXml(doc));
1106
- });
1107
- this.filters.forEach(function (f, i) {
1108
- entityNode.appendChild(f.toXml(doc));
1109
- });
1110
- //Is required so no need to check
1111
- entityNode.setAttribute("name", this.name);
1112
- return entityNode;
1113
- }
1114
- //Internal use only
1115
- static entityFromXml(xml) {
1116
- var entityObj = new Sdk.FetchXml.entity(xml.attributes.getNamedItem("name").nodeValue);
1117
- entityObj.allAttributes = (xml.getElementsByTagName("all-attributes").length == 1);
1118
- for (var i = 0; i < xml.childNodes.length; i++) {
1119
- if (xml.childNodes[i].nodeName == "attribute") {
1120
- entityObj.addAttribute(attribute.attributeFromXml(xml.childNodes[i]));
1121
- }
1122
- if (xml.childNodes[i].nodeName == "order") {
1123
- entityObj.addOrder(order.orderFromXml(xml.childNodes[i]));
1124
- }
1125
- if (xml.childNodes[i].nodeName == "link-entity") {
1126
- entityObj.addLinkEntity(linkEntity.linkEntityFromXml(xml.childNodes[i]));
1127
- }
1128
- if (xml.childNodes[i].nodeName == "filter") {
1129
- entityObj.addFilter(filter.filterFromXml(xml.childNodes[i]));
1130
- }
1131
- }
1132
- return entityObj;
1133
- }
1134
- };
1135
- entity = __decorate([
1136
- sealed
1137
- ], entity);
1138
- FetchXml.entity = entity;
1139
- let fetch = class fetch {
1140
- /**
1141
- * Contains the data for a fetchXml fetch element.
1142
- * @param entity The entity that is being queried
1143
- */
1144
- constructor(entity) {
1145
- this._aggregate = null;
1146
- this._count = null;
1147
- this._distinct = null;
1148
- this._mapping = null;
1149
- this._minActiveRowVersion = null;
1150
- this._noLock = null;
1151
- this._order = null;
1152
- this._outputFormat = null;
1153
- this._page = null;
1154
- this._pagingCookie = null;
1155
- this._returnTotalRecordCount = null;
1156
- this._top = null;
1157
- this._utcOffset = null;
1158
- this._version = null;
1159
- //new keyword not required
1160
- if (!(this instanceof Sdk.FetchXml.fetch)) {
1161
- return new Sdk.FetchXml.fetch(entity);
1162
- }
1163
- if (entity)
1164
- this.entity = entity;
1165
- }
1166
- /**
1167
- * Gets or sets the aggregate attribute of the fetch element.
1168
- */
1169
- get aggregate() {
1170
- return this._aggregate;
1171
- }
1172
- set aggregate(value) {
1173
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1174
- throw new Error("Sdk.FetchXml.fetch.aggregate must be a boolean value or null.");
1175
- }
1176
- this._aggregate = value;
1177
- }
1178
- /**
1179
- * Gets or sets the count attribute of the fetch element.
1180
- */
1181
- get count() {
1182
- return this._count;
1183
- }
1184
- set count(value) {
1185
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1186
- throw new Error("Sdk.FetchXml.fetch.count must be a number value or null.");
1187
- }
1188
- this._count = value;
1189
- }
1190
- /**
1191
- * Gets or sets the distinct attribute of the fetch element.
1192
- */
1193
- get distinct() {
1194
- return this._distinct;
1195
- }
1196
- set distinct(value) {
1197
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1198
- throw new Error("Sdk.FetchXml.fetch.distinct must be a boolean value or null.");
1199
- }
1200
- this._distinct = value;
1201
- }
1202
- /**
1203
- * Gets or sets the entity attribute of the fetch element.
1204
- */
1205
- get entity() {
1206
- return this._entity;
1207
- }
1208
- set entity(value) {
1209
- if (!Sdk.FetchXml.Util.isEntity(value)) {
1210
- throw new Error("Sdk.FetchXml.fetch.entity must be a Sdk.FetchXml.entity value.");
1211
- }
1212
- this._entity = value;
1213
- }
1214
- /**
1215
- * Gets or sets the mapping attribute of the fetch element.
1216
- */
1217
- get mapping() {
1218
- return this._mapping;
1219
- }
1220
- set mapping(value) {
1221
- if (!Sdk.FetchXml.Util.isEnumMemberOrNull(Sdk.FetchXml.Mapping, value)) {
1222
- throw new Error("Sdk.FetchXml.fetch.mapping must be a Sdk.FetchXml.Mapping value or null.");
1223
- }
1224
- this._mapping = value;
1225
- }
1226
- /**
1227
- * Gets or sets the minActiveRowVersion attribute of the fetch element.
1228
- */
1229
- get minActiveRowVersion() {
1230
- return this._minActiveRowVersion;
1231
- }
1232
- set minActiveRowVersion(value) {
1233
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1234
- throw new Error("Sdk.FetchXml.fetch.minActiveRowVersion must be a boolean value or null.");
1235
- }
1236
- this._minActiveRowVersion = value;
1237
- }
1238
- /**
1239
- * Gets or sets the noLock attribute of the fetch element.
1240
- */
1241
- get noLock() {
1242
- return this._noLock;
1243
- }
1244
- set noLock(value) {
1245
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1246
- throw new Error("Sdk.FetchXml.fetch.noLock must be a boolean value or null.");
1247
- }
1248
- this._noLock = value;
1249
- }
1250
- /**
1251
- * Gets or sets the order attribute of the fetch element.
1252
- */
1253
- get order() {
1254
- return this._order;
1255
- }
1256
- set order(value) {
1257
- if (!Sdk.FetchXml.Util.isOrderOrNull(value)) {
1258
- throw new Error("Sdk.FetchXml.fetch.order must be a Sdk.FetchXml.order value or null.");
1259
- }
1260
- this._order = value;
1261
- }
1262
- /**
1263
- * Gets or sets the outputFormat attribute of the fetch element.
1264
- */
1265
- get outputFormat() {
1266
- return this._outputFormat;
1267
- }
1268
- set outputFormat(value) {
1269
- if (!Sdk.FetchXml.Util.isEnumMemberOrNull(Sdk.FetchXml.OutputFormat, value)) {
1270
- throw new Error("Sdk.FetchXml.fetch.outputFormat must be a Sdk.FetchXml.OutputFormat value or null.");
1271
- }
1272
- this._outputFormat = value;
1273
- }
1274
- /**
1275
- * Gets or sets the page attribute of the fetch element.
1276
- */
1277
- get page() {
1278
- return this._page;
1279
- }
1280
- set page(value) {
1281
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1282
- throw new Error("Sdk.FetchXml.fetch.page must be a number value or null.");
1283
- }
1284
- this._page = value;
1285
- }
1286
- /**
1287
- * Gets or sets the pagingCookie attribute of the fetch element.
1288
- */
1289
- get pagingCookie() {
1290
- return this._pagingCookie;
1291
- }
1292
- set pagingCookie(value) {
1293
- if (!Sdk.FetchXml.Util.isStringOrNull(value)) {
1294
- throw new Error("Sdk.FetchXml.fetch.pagingCookie must be a string value or null.");
1295
- }
1296
- this._pagingCookie = value;
1297
- }
1298
- /**
1299
- * Gets or sets the returnTotalRecordCount attribute of the fetch element.
1300
- */
1301
- get returnTotalRecordCount() {
1302
- return this._returnTotalRecordCount;
1303
- }
1304
- set returnTotalRecordCount(value) {
1305
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1306
- throw new Error("Sdk.FetchXml.fetch.returnTotalRecordCount must be a boolean value or null.");
1307
- }
1308
- this._returnTotalRecordCount = value;
1309
- }
1310
- /**
1311
- * Gets or sets the top attribute of the fetch element.
1312
- */
1313
- get top() {
1314
- return this._top;
1315
- }
1316
- set top(value) {
1317
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1318
- throw new Error("Sdk.FetchXml.fetch.top must be a number value or null.");
1319
- }
1320
- this._top = value;
1321
- }
1322
- /**
1323
- * Gets or sets the utcOffset attribute of the fetch element.
1324
- */
1325
- get utcOffset() {
1326
- return this._utcOffset;
1327
- }
1328
- set utcOffset(value) {
1329
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1330
- throw new Error("Sdk.FetchXml.fetch.utcOffset must be a number value or null.");
1331
- }
1332
- this._utcOffset = value;
1333
- }
1334
- /**
1335
- * Gets or sets the version attribute of the fetch element.
1336
- */
1337
- get version() {
1338
- return this._version;
1339
- }
1340
- set version(value) {
1341
- if (!Sdk.FetchXml.Util.isStringOrNull(value)) {
1342
- throw new Error("Sdk.FetchXml.fetch.version must be a string value or null.");
1343
- }
1344
- this._version = value;
1345
- }
1346
- /** @description Sets the aggregate attribute of the fetch element
1347
- * @param {boolean | null} aggregate The aggregate value to apply to the fetch element
1348
- * @returns {Sdk.FetchXml.fetch}
1349
- */
1350
- setAggregate(aggregate) {
1351
- (aggregate) ? this.aggregate = aggregate : this.aggregate = null;
1352
- return this;
1353
- }
1354
- /** @description Sets the count attribute of the fetch element
1355
- * @param {number | null} count The count value to apply to the fetch element
1356
- * @returns {Sdk.FetchXml.fetch}
1357
- */
1358
- setCount(count) {
1359
- (count) ? this.count = count : this.count = null;
1360
- return this;
1361
- }
1362
- /** @description Sets the distinct attribute of the fetch element
1363
- * @param {boolean | null} distinct The distinct value to apply to the fetch element
1364
- * @returns {Sdk.FetchXml.fetch}
1365
- */
1366
- setDistinct(distinct) {
1367
- (distinct) ? this.distinct = distinct : this.distinct = null;
1368
- return this;
1369
- }
1370
- /** @description Sets the aggregate entity of the fetch element
1371
- * @param {Sdk.FetchXml.entity} entity The entity value to apply to the fetch element
1372
- * @returns {Sdk.FetchXml.fetch}
1373
- */
1374
- setEntity(entity) {
1375
- this.entity = entity;
1376
- return this;
1377
- }
1378
- /** @description Sets the mapping attribute of the fetch element
1379
- * @param {Sdk.FetchXml.Mapping} mapping The mapping value to apply to the fetch element
1380
- * @returns {Sdk.FetchXml.fetch}
1381
- */
1382
- setMapping(mapping) {
1383
- (mapping) ? this.mapping = mapping : this.mapping = null;
1384
- return this;
1385
- }
1386
- /** @description Sets the minActiveRowVersion attribute of the fetch element
1387
- * @param {boolean | null} minActiveRowVersion The minActiveRowVersion value to apply to the fetch element
1388
- * @returns {Sdk.FetchXml.fetch}
1389
- */
1390
- setMinActiveRowVersion(minActiveRowVersion) {
1391
- (minActiveRowVersion) ? this.minActiveRowVersion = minActiveRowVersion : this.minActiveRowVersion = null;
1392
- return this;
1393
- }
1394
- /** @description Sets the noLock attribute of the fetch element
1395
- * @param {boolean | null} noLock The noLock value to apply to the fetch element
1396
- * @returns {Sdk.FetchXml.fetch}
1397
- */
1398
- setNoLock(noLock = null) {
1399
- this.noLock = noLock;
1400
- return this;
1401
- }
1402
- /** @description Sets the order attribute of the fetch element
1403
- * @param {Sdk.FetchXml.order | null} order The order value to apply to the fetch element
1404
- * @returns {Sdk.FetchXml.fetch}
1405
- */
1406
- setOrder(order = null) {
1407
- this.order = order;
1408
- return this;
1409
- }
1410
- /** @description Sets the outputFormat attribute of the fetch element
1411
- * @param {Sdk.FetchXml.OutputFormat | null} outputFormat The outputFormat value to apply to the fetch element
1412
- * @returns {Sdk.FetchXml.fetch}
1413
- */
1414
- setOutputFormat(outputFormat) {
1415
- (outputFormat) ? this.outputFormat = outputFormat : this.outputFormat = null;
1416
- return this;
1417
- }
1418
- /** @description Sets the page attribute of the fetch element
1419
- * @param {number | null} page The page value to apply to the fetch element
1420
- * @returns {Sdk.FetchXml.fetch}
1421
- */
1422
- setPage(page) {
1423
- (page) ? this.page = page : this.page = null;
1424
- return this;
1425
- }
1426
- /** @description Sets the pagingCookie attribute of the fetch element
1427
- * @param {string | null} pagingCookie The pagingCookie value to apply to the fetch element
1428
- * @returns {Sdk.FetchXml.fetch}
1429
- */
1430
- setPagingCookie(pagingCookie = null) {
1431
- this.pagingCookie = pagingCookie;
1432
- return this;
1433
- }
1434
- /** @description Sets the returnTotalRecordCount attribute of the fetch element
1435
- * @param {boolean} returnTotalRecordCount The returnTotalRecordCount value to apply to the fetch element
1436
- * @returns {Sdk.FetchXml.fetch}
1437
- */
1438
- setReturnTotalRecordCount(returnTotalRecordCount) {
1439
- (returnTotalRecordCount) ? this.returnTotalRecordCount = returnTotalRecordCount : this.returnTotalRecordCount = null;
1440
- return this;
1441
- }
1442
- /** @description Sets the top attribute of the fetch element
1443
- * @param {number | null} top The top value to apply to the fetch element
1444
- * @returns {Sdk.FetchXml.fetch}
1445
- */
1446
- setTop(top) {
1447
- (top) ? this.top = top : this.top = null;
1448
- return this;
1449
- }
1450
- /** @description Sets the utcOffset attribute of the fetch element
1451
- * @param {number | null} utcOffset The utcOffset value to apply to the fetch element
1452
- * @returns {Sdk.FetchXml.fetch}
1453
- */
1454
- setUtcOffset(utcOffset) {
1455
- (utcOffset) ? this.utcOffset = utcOffset : this.utcOffset = null;
1456
- return this;
1457
- }
1458
- /** @description Sets the version attribute of the fetch element
1459
- * @param {string | null} version The version value to apply to the fetch element
1460
- * @returns {Sdk.FetchXml.fetch}
1461
- */
1462
- setVersion(version) {
1463
- (version) ? this.version = version : this.version = null;
1464
- return this;
1465
- }
1466
- /**
1467
- * Serializes the fetch query into a FetchXML string
1468
- */
1469
- toXml() {
1470
- var root = "<fetch />";
1471
- var doc = new DOMParser().parseFromString(root, "text/xml");
1472
- if (this.version) {
1473
- doc.documentElement.setAttribute("version", this.version);
1474
- }
1475
- if (this.outputFormat) {
1476
- doc.documentElement.setAttribute("output-format", this.outputFormat);
1477
- }
1478
- if (this.mapping) {
1479
- doc.documentElement.setAttribute("mapping", this.mapping);
1480
- }
1481
- if (this.aggregate) {
1482
- doc.documentElement.setAttribute("aggregate", (this.aggregate) ? "true" : "false");
1483
- }
1484
- if (this.count) {
1485
- doc.documentElement.setAttribute("count", this.count.toString());
1486
- }
1487
- if (this.distinct) {
1488
- doc.documentElement.setAttribute("distinct", (this.distinct) ? "true" : "false");
1489
- }
1490
- if (this.entity) {
1491
- doc.documentElement.appendChild(this.entity.toXml(doc));
1492
- }
1493
- if (this.minActiveRowVersion) {
1494
- doc.documentElement.setAttribute("min-active-row-version", (this.minActiveRowVersion) ? "true" : "false");
1495
- }
1496
- if (this.noLock) {
1497
- doc.documentElement.setAttribute("no-lock", (this.noLock) ? "true" : "false");
1498
- }
1499
- if (this.order) {
1500
- doc.documentElement.appendChild(this.order.toXml(doc));
1501
- }
1502
- if (this.page) {
1503
- doc.documentElement.setAttribute("page", this.page.toString());
1504
- }
1505
- if (this.pagingCookie) {
1506
- doc.documentElement.setAttribute("paging-cookie", this.pagingCookie); //Does this need special handling?
1507
- }
1508
- if (this.returnTotalRecordCount) {
1509
- doc.documentElement.setAttribute("returntotalrecordcount", (this.returnTotalRecordCount) ? "true" : "false");
1510
- }
1511
- if (this.top) {
1512
- doc.documentElement.setAttribute("top", this.top.toString());
1513
- }
1514
- if (this.utcOffset) {
1515
- doc.documentElement.setAttribute("utc-offset", this.utcOffset.toString());
1516
- }
1517
- return new XMLSerializer().serializeToString(doc);
1518
- }
1519
- /**
1520
- * Instantiates a fetch object from a fetchXml string
1521
- * @param xml A FetchXML string
1522
- * @returns Sdk.FetchXml.fetch
1523
- */
1524
- static fromXml(xml) {
1525
- var doc = new DOMParser().parseFromString(xml, "text/xml");
1526
- var fetchObj = new Sdk.FetchXml.fetch();
1527
- var errorMessage = "The XML string is not a valid fetchXML document";
1528
- if (doc.documentElement.localName == "fetch") {
1529
- Sdk.FetchXml.Util.parseAttributes(doc.documentElement, fetchObj, (fetchObj, name, value) => {
1530
- switch (name) {
1531
- case "count":
1532
- case "top":
1533
- case "page":
1534
- fetchObj[name] = parseInt(value, 10);
1535
- break;
1536
- case "utc-offset":
1537
- if (!isNaN(value)) {
1538
- fetchObj.utcOffset = parseInt(value, 10);
1539
- }
1540
- else {
1541
- fetchObj.utcOffset = null;
1542
- }
1543
- break;
1544
- case "paging-cookie":
1545
- fetchObj.pagingCookie = value;
1546
- break;
1547
- case "min-active-row-version":
1548
- fetchObj.minActiveRowVersion = (value == "true") ? true : false;
1549
- break;
1550
- case "output-format":
1551
- fetchObj.outputFormat = value;
1552
- break;
1553
- case "returntotalrecordcount":
1554
- fetchObj.returnTotalRecordCount = (value == "true") ? true : false;
1555
- break;
1556
- case "no-lock":
1557
- fetchObj.noLock = (value == "true") ? true : false;
1558
- break;
1559
- case "aggregate": //xs:boolean
1560
- case "distinct":
1561
- fetchObj[name] = (value == "true") ? true : false;
1562
- break;
1563
- default:
1564
- fetchObj[name] = value;
1565
- break;
1566
- }
1567
- });
1568
- for (var i = 0; i < doc.documentElement.childNodes.length; i++) {
1569
- if (doc.documentElement.childNodes[i].nodeName == "entity") {
1570
- fetchObj.entity = Sdk.FetchXml.entity.entityFromXml(doc.documentElement.childNodes[i]);
1571
- }
1572
- if (doc.documentElement.childNodes[i].nodeName == "order") {
1573
- fetchObj.order = Sdk.FetchXml.order.orderFromXml(doc.documentElement.childNodes[i]);
1574
- }
1575
- }
1576
- }
1577
- else {
1578
- throw new Error(errorMessage);
1579
- }
1580
- return fetchObj;
1581
- }
1582
- };
1583
- fetch = __decorate([
1584
- sealed
1585
- ], fetch);
1586
- FetchXml.fetch = fetch;
1587
- let filter = filter_1 = class filter {
1588
- /** @description Contains the data for a fetchXml filter element.
1589
- * @param [type] The type of filter: 'and' or 'or'. Default is 'and'
1590
- * @param [conditions] An array of Sdk.FetchXml.condition to apply to the filter
1591
- * @param [filters] An array of Sdk.FetchXml.filter to apply to the filter
1592
- * @property conditions Gets or sets the array of Sdk.FetchXml.condition to apply in the filter
1593
- * @property filters Gets or sets the array of Sdk.FetchXml.filter to apply to the filter
1594
- * @property type Gets or sets the type of filter.
1595
- * @property isQuickFindFields Gets or sets the isQuickFindFields property of the filter
1596
- * @returns {Sdk.FetchXml.filter}
1597
- */
1598
- constructor(type, conditions, filters) {
1599
- this._conditions = [];
1600
- this._filters = [];
1601
- this._type = null;
1602
- this._isQuickFindFields = null;
1603
- //new keyword is not required in JS
1604
- if (!(this instanceof filter_1)) {
1605
- return new filter_1(type, conditions, filters);
1606
- }
1607
- if (type)
1608
- this.type = type;
1609
- if (conditions)
1610
- this.conditions = conditions;
1611
- if (filters)
1612
- this.filters = filters;
1613
- }
1614
- /**
1615
- * Gets or sets the array of condition to be applied to the query results
1616
- */
1617
- get conditions() {
1618
- return this._conditions;
1619
- }
1620
- set conditions(value) {
1621
- if (!Util.isFilterArrayOrNull(value)) {
1622
- throw new Error("Sdk.FetchXml.filter.conditions must be an array of Sdk.FetchXml.condition or null.");
1623
- }
1624
- if (value == null) {
1625
- this._conditions = [];
1626
- }
1627
- else {
1628
- this._conditions = value;
1629
- }
1630
- }
1631
- /**
1632
- * Gets or sets the array of filters to be applied to the query results
1633
- */
1634
- get filters() {
1635
- return this._filters;
1636
- }
1637
- set filters(value) {
1638
- if (!Util.isFilterArrayOrNull(value)) {
1639
- throw new Error("Sdk.FetchXml.filter.filters must be an array of Sdk.FetchXml.filter or null.");
1640
- }
1641
- if (value == null) {
1642
- this._filters = [];
1643
- }
1644
- else {
1645
- this._filters = value;
1646
- }
1647
- }
1648
- /**
1649
- * Gets or sets the type property of the filter
1650
- */
1651
- get type() {
1652
- return this._type;
1653
- }
1654
- set type(value) {
1655
- this._type = value;
1656
- }
1657
- /**
1658
- * Gets or sets the isQuickFindFields property of the filter
1659
- */
1660
- get isQuickFindFields() {
1661
- return this._isQuickFindFields;
1662
- }
1663
- set isQuickFindFields(value) {
1664
- this._isQuickFindFields = value;
1665
- }
1666
- /** @description Adds a condition to the conditions collection
1667
- * @param {Sdk.FetchXml.attribute | Sdk.FetchXml.condition} attributeOrCondition When Sdk.FetchXml.condition the condition is added.
1668
- When Sdk.FetchXml.attribute, the attribute property of a new condition
1669
- * @param {Sdk.FetchXml.Operator} [operator] The operator property for a new condition. Required when the first parameter is an Sdk.FetchXml.attribute
1670
- * @param {Array} [values] The values to compare for a new condition.
1671
- * @returns {Sdk.FetchXml.filter}
1672
- */
1673
- addCondition(attributeOrCondition, operator, values) {
1674
- if (Util.isCondition(attributeOrCondition)) {
1675
- this.conditions.push(attributeOrCondition);
1676
- }
1677
- else {
1678
- this.conditions.push(new condition(attributeOrCondition, operator, values));
1679
- }
1680
- return this;
1681
- }
1682
- /** @description Removes a condition from the conditions collection by reference
1683
- * @param {Sdk.FetchXml.condition} condition The condition to remove from the conditions collection
1684
- * @returns {Sdk.FetchXml.filter}
1685
- */
1686
- removeConditionByRef(condition) {
1687
- if (!Util.isCondition(condition)) {
1688
- throw new Error("Sdk.FetchXml.filter removeConditionByRef method condition parameter must be an Sdk.FetchXml.condition.");
1689
- }
1690
- Util.removeCollectionValueByRef(this.conditions, condition);
1691
- return this;
1692
- }
1693
- /** @description Removes a condition from the conditions collection by value
1694
- * @param {Sdk.FetchXml.condition} condition The condition to remove from the conditions collection
1695
- * @returns {Sdk.FetchXml.filter}
1696
- */
1697
- removeCondition(condition) {
1698
- if (!Util.isCondition(condition)) {
1699
- throw new Error("Sdk.FetchXml.filter removeCondition method condition parameter must be an Sdk.FetchXml.condition.");
1700
- }
1701
- Util.removeCollectionValue(this.conditions, condition);
1702
- return this;
1703
- }
1704
- /** @description Adds a filter to the filters collection
1705
- * @param {Sdk.FetchXml.filter} filter The filter to add to the filters collectio
1706
- * @returns {Sdk.FetchXml.filter}
1707
- */
1708
- addFilter(filter) {
1709
- if (Util.isFilter(filter)) {
1710
- this.filters.push(filter);
1711
- }
1712
- else {
1713
- throw new Error("Sdk.FetchXml.filter addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
1714
- }
1715
- return this;
1716
- }
1717
- /** @description Removes all references to a filter object
1718
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collectio
1719
- * @returns {Sdk.FetchXml.filter}
1720
- */
1721
- removeFilterByRef(filter) {
1722
- if (!Util.isFilter(filter)) {
1723
- throw new Error("Sdk.FetchXml.filter removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
1724
- }
1725
- Util.removeCollectionValueByRef(this.filters, filter);
1726
- return this;
1727
- }
1728
- /** @description Removes all matching filters from the filters collection
1729
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collectio
1730
- * @returns {Sdk.FetchXml.filter}
1731
- */
1732
- removeFilter(filter) {
1733
- if (!Util.isFilter(filter)) {
1734
- throw new Error("Sdk.FetchXml.filter removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
1735
- }
1736
- Util.removeCollectionValue(this.filters, filter);
1737
- return this;
1738
- }
1739
- /** @description Sets the isQuickFindFields property
1740
- * @param {boolean | null} value The value to set
1741
- * @returns {Sdk.FetchXml.filter}
1742
- */
1743
- setIsQuickFindFields(value) {
1744
- this.isQuickFindFields = value;
1745
- return this;
1746
- }
1747
- /** @description Sets the type property
1748
- * @param {Sdk.FetchXml.FilterType} value The value to set
1749
- * @returns {Sdk.FetchXml.filter}
1750
- */
1751
- setType(value) {
1752
- this.type = value;
1753
- return this;
1754
- }
1755
- //Internal use only
1756
- toXml(doc) {
1757
- var fNode = doc.createElement("filter");
1758
- if (this.type) {
1759
- fNode.setAttribute("type", this.type);
1760
- }
1761
- if (Util.isBoolean(this.isQuickFindFields)) {
1762
- fNode.setAttribute("isquickfindfields", this.isQuickFindFields.toString());
1763
- }
1764
- this.conditions.forEach(function (c) {
1765
- fNode.appendChild(c.toXml(doc));
1766
- });
1767
- this.filters.forEach(function (f) {
1768
- fNode.appendChild(f.toXml(doc));
1769
- });
1770
- return fNode;
1771
- }
1772
- static filterFromXml(xml) {
1773
- var filterObj = new filter_1();
1774
- Util.parseAttributes(xml, filterObj, (filterObj, name, value) => {
1775
- switch (name) {
1776
- case "type":
1777
- filterObj.type = value;
1778
- break;
1779
- case "isquickfindfields":
1780
- filterObj.isQuickFindFields = (value == "true" || value == "1") ? true : false;
1781
- break;
1782
- }
1783
- });
1784
- for (var i = 0; i < xml.childNodes.length; i++) {
1785
- if (xml.childNodes[i].nodeName == "condition") {
1786
- filterObj.addCondition(condition.conditionFromXml(xml.childNodes[i]));
1787
- }
1788
- if (xml.childNodes[i].nodeName == "filter") {
1789
- filterObj.addFilter(filter_1.filterFromXml(xml.childNodes[i]));
1790
- }
1791
- }
1792
- return filterObj;
1793
- }
1794
- };
1795
- filter = filter_1 = __decorate([
1796
- sealed
1797
- ], filter);
1798
- FetchXml.filter = filter;
1799
- let linkEntity = linkEntity_1 = class linkEntity {
1800
- /**
1801
- * Contains the data for a fetchXml link-entity element.
1802
- * @param name The logical name of the entity
1803
- * @param from The from property of the linkEntity
1804
- * @param to The to property of the linkEntity
1805
- * @param linktype The linktype property of the linkEntity
1806
- * @param alias The alias property of the linkEntity
1807
- */
1808
- constructor(name, from, to, linktype, alias) {
1809
- this._name = null;
1810
- this._alias = null;
1811
- this._from = null;
1812
- this._intersect = null;
1813
- this._linktype = null;
1814
- this._to = null;
1815
- this._visible = null;
1816
- this._allAttributes = null;
1817
- this._attributes = [];
1818
- this._orders = [];
1819
- this._linkEntities = [];
1820
- this._filters = [];
1821
- if (!(this instanceof linkEntity_1)) {
1822
- return new linkEntity_1(name, from, to, linktype, alias);
1823
- }
1824
- this.name = name;
1825
- if (from)
1826
- this.from = from;
1827
- if (to)
1828
- this.to = to;
1829
- if (linktype)
1830
- this.linktype = linktype;
1831
- if (alias)
1832
- this.alias = alias;
1833
- }
1834
- /**
1835
- * Gets or sets the name property of the linkEntity
1836
- */
1837
- get name() {
1838
- return this._name;
1839
- }
1840
- set name(value) {
1841
- this._name = value;
1842
- }
1843
- /**
1844
- * Gets or sets the alias property of the linkEntity
1845
- */
1846
- get alias() {
1847
- return this._alias;
1848
- }
1849
- set alias(value) {
1850
- this._alias = value;
1851
- }
1852
- /**
1853
- * Gets or sets the from property of the linkEntity
1854
- */
1855
- get from() {
1856
- return this._from;
1857
- }
1858
- set from(value) {
1859
- this._from = value;
1860
- }
1861
- /**
1862
- * Gets or sets the intersect property of the linkEntity
1863
- */
1864
- get intersect() {
1865
- return this._intersect;
1866
- }
1867
- set intersect(value) {
1868
- this._intersect = value;
1869
- }
1870
- /**
1871
- * Gets or sets the linktype property of the linkEntity
1872
- */
1873
- get linktype() {
1874
- return this._linktype;
1875
- }
1876
- set linktype(value) {
1877
- this._linktype = value;
1878
- }
1879
- /**
1880
- * Gets or sets the to property of the linkEntity
1881
- */
1882
- get to() {
1883
- return this._to;
1884
- }
1885
- set to(value) {
1886
- this._to = value;
1887
- }
1888
- /**
1889
- * Gets or sets the visible property of the linkEntity
1890
- */
1891
- get visible() {
1892
- return this._visible;
1893
- }
1894
- set visible(value) {
1895
- this._visible = value;
1896
- }
1897
- /**
1898
- * Gets or sets the allAttributes property of the linkEntity
1899
- */
1900
- get allAttributes() {
1901
- return this._allAttributes;
1902
- }
1903
- set allAttributes(value) {
1904
- this._allAttributes = value;
1905
- }
1906
- /**
1907
- * Gets or sets the array of attribute of the entity to be returned in the query results
1908
- */
1909
- get attributes() {
1910
- return this._attributes;
1911
- }
1912
- set attributes(value) {
1913
- if (!Util.isAttributeArrayOrNull(value)) {
1914
- throw new Error("Sdk.FetchXml.linkEntity.attributes must be an array of Sdk.FetchXml.attribute or null.");
1915
- }
1916
- if (value == null) {
1917
- this._attributes = [];
1918
- }
1919
- else {
1920
- this._attributes = value;
1921
- }
1922
- }
1923
- /**
1924
- * Gets or sets the array of attribute of the entity to be returned in the query results
1925
- */
1926
- get orders() {
1927
- return this._orders;
1928
- }
1929
- set orders(value) {
1930
- if (!Util.isOrderArrayOrNull(value)) {
1931
- throw new Error("Sdk.FetchXml.linkEntity.orders must be an array of Sdk.FetchXml.order or null.");
1932
- }
1933
- if (value == null) {
1934
- this._orders = [];
1935
- }
1936
- else {
1937
- this._orders = value;
1938
- }
1939
- }
1940
- /**
1941
- * Gets or sets the array of linkEntity to be applied to the query results
1942
- */
1943
- get linkEntities() {
1944
- return this._linkEntities;
1945
- }
1946
- set linkEntities(value) {
1947
- if (!Util.isLinkEntityArrayOrNull(value)) {
1948
- throw new Error("Sdk.FetchXml.linkEntity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");
1949
- }
1950
- if (value == null) {
1951
- this._linkEntities = [];
1952
- }
1953
- else {
1954
- this._linkEntities = value;
1955
- }
1956
- }
1957
- /**
1958
- * Gets or sets the array of filters to be applied to the query results
1959
- */
1960
- get filters() {
1961
- return this._filters;
1962
- }
1963
- set filters(value) {
1964
- if (!Util.isFilterArrayOrNull(value)) {
1965
- throw new Error("Sdk.FetchXml.linkEntity.filters must be an array of Sdk.FetchXml.filter or null.");
1966
- }
1967
- if (value == null) {
1968
- this._filters = [];
1969
- }
1970
- else {
1971
- this._filters = value;
1972
- }
1973
- }
1974
- //Internal use only
1975
- get hash() {
1976
- var s = this._name.concat((this._alias ? this._alias : ""), (this._from ? this._from : ""), (Util.isNullOrUndefined(this._intersect) ? "" : this._intersect.toString()), (this._linktype ? this._linktype : ""), (this._to ? this._to : ""), (Util.isNullOrUndefined(this._visible) ? "" : this._visible.toString()), (Util.isNullOrUndefined(this._allAttributes) ? "" : this._allAttributes.toString()), (Util.getCollectionHash(this._attributes)), (Util.getCollectionHash(this._orders)), (Util.getCollectionHash(this._linkEntities)), (Util.getCollectionHash(this._filters)));
1977
- return s.hashCode();
1978
- }
1979
- /** @description Sets the alias property of the linkEntity attribute
1980
- * @param {string} alias The alias value to apply to the linkEntity
1981
- * @returns {Sdk.FetchXml.linkEntity}
1982
- */
1983
- setAlias(alias) {
1984
- this.alias = alias;
1985
- return this;
1986
- }
1987
- /** @description Sets the from property of the linkEntity attribute
1988
- * @param {string} from The from value to apply to the linkEntity
1989
- * @returns {Sdk.FetchXml.linkEntity}
1990
- */
1991
- setFrom(from) {
1992
- this.from = from;
1993
- return this;
1994
- }
1995
- /** @description Sets the intersect property of the linkEntity attribute
1996
- * @param {boolean | null} intersect The intersect value to apply to the linkEntity
1997
- * @returns {Sdk.FetchXml.linkEntity}
1998
- */
1999
- setIntersect(intersect) {
2000
- this.intersect = intersect;
2001
- return this;
2002
- }
2003
- /** @description Sets the name property of the linkEntity attribute
2004
- * @param {string} name The name value to apply to the linkEntity
2005
- * @returns {Sdk.FetchXml.linkEntity}
2006
- */
2007
- setName(name) {
2008
- this.name = name;
2009
- return this;
2010
- }
2011
- /** @description Sets the to property of the linkEntity attribute
2012
- * @param {string} to The to value to apply to the linkEntity
2013
- * @returns {Sdk.FetchXml.linkEntity}
2014
- */
2015
- setTo(to) {
2016
- this.to = to;
2017
- return this;
2018
- }
2019
- /** @description Sets the visible property of the linkEntity attribute
2020
- * @param {boolean | null} visible The visible value to apply to the linkEntity
2021
- * @returns {Sdk.FetchXml.linkEntity}
2022
- */
2023
- setVisible(visible) {
2024
- this.visible = visible;
2025
- return this;
2026
- }
2027
- /** @description Sets the allAttributes property of the linkEntity attribute
2028
- * @param {boolean} allAttributes The allAttributes value to apply to the linkEntity
2029
- * @returns {Sdk.FetchXml.linkEntity}
2030
- */
2031
- setAllAttributes(allAttributes) {
2032
- this.allAttributes = allAttributes;
2033
- return this;
2034
- }
2035
- /** @description Adds an linkEntity to the linkEntities collection
2036
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to add to the linkEntities collection
2037
- * @returns {Sdk.FetchXml.linkEntity}
2038
- */
2039
- addLinkEntity(linkEntity) {
2040
- if (Util.isLinkEntity(linkEntity)) {
2041
- this.linkEntities.push(linkEntity);
2042
- return this;
2043
- }
2044
- throw new Error("Sdk.FetchXml.linkEntity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.");
2045
- }
2046
- /** @description Removes a linkEntity from the linkEntities collection by reference
2047
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
2048
- * @returns {Sdk.FetchXml.linkEntity}
2049
- */
2050
- removeLinkEntityByRef(linkEntity) {
2051
- if (!Util.isLinkEntity(linkEntity)) {
2052
- throw new Error("Sdk.FetchXml.linkEntity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
2053
- }
2054
- Util.removeCollectionValueByRef(this.linkEntities, linkEntity);
2055
- return this;
2056
- }
2057
- /** @description Removes a linkEntity from the linkEntities collection by value
2058
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
2059
- * @returns {Sdk.FetchXml.linkEntity}
2060
- */
2061
- removeLinkEntity(linkEntity) {
2062
- if (!Util.isLinkEntity(linkEntity)) {
2063
- throw new Error("Sdk.FetchXml.linkEntity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
2064
- }
2065
- Util.removeCollectionValue(this.linkEntities, linkEntity);
2066
- return this;
2067
- }
2068
- /** @description Adds an attribute to the attributes collection
2069
- * @param {Sdk.FetchXml.attribute | string} attribute The attribute to add to the attributes collectio
2070
- * @returns {Sdk.FetchXml.linkEntity}
2071
- */
2072
- addAttribute(attribute) {
2073
- if (Util.isAttribute(attribute)) {
2074
- this.attributes.push(attribute);
2075
- return this;
2076
- }
2077
- if (Util.isString(attribute)) {
2078
- this.attributes.push(new attribute(attribute));
2079
- return this;
2080
- }
2081
- throw new Error("Sdk.FetchXml.linkEntity addAttribute method attribute parameter must be a Sdk.FetchXml.attribute value or a string.");
2082
- }
2083
- /** @description Removes a attribute from the attributes collection by reference
2084
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove from the attributes collection
2085
- * @returns {Sdk.FetchXml.linkEntity}
2086
- */
2087
- removeAttributeByRef(attribute) {
2088
- if (!Util.isAttribute(attribute)) {
2089
- throw new Error("Sdk.FetchXml.linkEntity removeAttributeByRef method attribute parameter must be an Sdk.FetchXml.attribute.");
2090
- }
2091
- Util.removeCollectionValueByRef(this.attributes, attribute);
2092
- return this;
2093
- }
2094
- /** @description Removes a attribute from the attributes collection by value
2095
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove from the attributes collection
2096
- * @returns {Sdk.FetchXml.linkEntity}
2097
- */
2098
- removeAttribute(attribute) {
2099
- if (!Util.isAttribute(attribute)) {
2100
- throw new Error("Sdk.FetchXml.linkEntity removeAttribute method attribute parameter must be an Sdk.FetchXml.attribute.");
2101
- }
2102
- Util.removeCollectionValue(this.attributes, attribute);
2103
- return this;
2104
- }
2105
- /** @description Removes a attribute from the attributes collection by name
2106
- * @param {string} attributeName Name of the attribute to remove from the attributes collection
2107
- * @returns {Sdk.FetchXml.linkEntity}
2108
- */
2109
- removeAttributeByName(attributeName) {
2110
- if (!Util.isString(attributeName)) {
2111
- throw new Error("Sdk.FetchXml.linkEntity removeAttributeByName method attributeName parameter must be a string.");
2112
- }
2113
- Util.removeCollectionValueByProperty(this.attributes, "name", attributeName);
2114
- return this;
2115
- }
2116
- /** @description Adds an order to the orders collection
2117
- * @param {Sdk.FetchXml.order | string} orderOrAttribute The order to add to the attributes collection or the Attribute property of a new order to create
2118
- * @param {boolean} [descending] Whether the order is descending. True if descending, otherwise false
2119
- * @param {string} [alias] The alias to set for the order
2120
- * @returns {Sdk.FetchXml.linkEntity}
2121
- */
2122
- addOrder(orderOrAttribute, descending, alias) {
2123
- if (Util.isOrder(orderOrAttribute)) {
2124
- this.orders.push(orderOrAttribute);
2125
- return this;
2126
- }
2127
- if (Util.isString(orderOrAttribute)) {
2128
- this.orders.push(new order(orderOrAttribute, descending, alias));
2129
- return this;
2130
- }
2131
- throw new Error("Sdk.FetchXml.linkEntity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.");
2132
- }
2133
- /** @description Removes a order from the orders collection by reference
2134
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
2135
- * @returns {Sdk.FetchXml.linkEntity}
2136
- */
2137
- removeOrderByRef(order) {
2138
- if (!Util.isOrder(order)) {
2139
- throw new Error("Sdk.FetchXml.linkEntity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");
2140
- }
2141
- Util.removeCollectionValueByRef(this.orders, order);
2142
- return this;
2143
- }
2144
- /** @description Removes a order from the orders collection by value
2145
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
2146
- * @returns {Sdk.FetchXml.linkEntity}
2147
- */
2148
- removeOrder(order) {
2149
- if (!Util.isOrder(order)) {
2150
- throw new Error("Sdk.FetchXml.linkEntity removeOrder method order parameter must be an Sdk.FetchXml.order.");
2151
- }
2152
- Util.removeCollectionValue(this.orders, order);
2153
- return this;
2154
- }
2155
- /** @description Adds an filter to the filters collection
2156
- * @param {Sdk.FetchXml.filter} filter The filter to add to the filters collection
2157
- * @returns {Sdk.FetchXml.linkEntity}
2158
- */
2159
- addFilter(filter) {
2160
- if (Util.isFilter(filter)) {
2161
- this.filters.push(filter);
2162
- return this;
2163
- }
2164
- throw new Error("Sdk.FetchXml.linkEntity addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
2165
- }
2166
- /** @description Removes a filter from the filters collection by reference
2167
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
2168
- * @returns {Sdk.FetchXml.linkEntity}
2169
- */
2170
- removeFilterByRef(filter) {
2171
- if (!Util.isFilter(filter)) {
2172
- throw new Error("Sdk.FetchXml.linkEntity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
2173
- }
2174
- Util.removeCollectionValueByRef(this.filters, filter);
2175
- return this;
2176
- }
2177
- /** @description Removes a filter from the filters collection by value
2178
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
2179
- * @returns {Sdk.FetchXml.linkEntity}
2180
- */
2181
- removeFilter(filter) {
2182
- if (!Util.isFilter(filter)) {
2183
- throw new Error("Sdk.FetchXml.linkEntity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
2184
- }
2185
- Util.removeCollectionValue(this.filters, filter);
2186
- return this;
2187
- }
2188
- //Internal use only
2189
- toXml(doc) {
2190
- var leNode = doc.createElement("link-entity");
2191
- if (this.alias) {
2192
- leNode.setAttribute("alias", this.alias);
2193
- }
2194
- if (this.allAttributes) {
2195
- leNode.appendChild(doc.createElement("all-attributes"));
2196
- }
2197
- if (this.from) {
2198
- leNode.setAttribute("from", this.from);
2199
- }
2200
- if (Util.isBoolean(this.intersect)) {
2201
- leNode.setAttribute("intersect", this.intersect.toString());
2202
- }
2203
- if (this.linktype) {
2204
- leNode.setAttribute("link-type", this.linktype);
2205
- }
2206
- if (this.name) {
2207
- leNode.setAttribute("name", this.name);
2208
- }
2209
- if (this.to) {
2210
- leNode.setAttribute("to", this.to);
2211
- }
2212
- if (Util.isBoolean(this.visible)) {
2213
- leNode.setAttribute("visible", this.visible.toString());
2214
- }
2215
- this.attributes.forEach(function (a) {
2216
- leNode.appendChild(a.toXml(doc));
2217
- });
2218
- this.orders.forEach(function (o) {
2219
- leNode.appendChild(o.toXml(doc));
2220
- });
2221
- this.linkEntities.forEach(function (l) {
2222
- leNode.appendChild(l.toXml(doc));
2223
- });
2224
- this.filters.forEach(function (f) {
2225
- leNode.appendChild(f.toXml(doc));
2226
- });
2227
- return leNode;
2228
- }
2229
- static linkEntityFromXml(xml) {
2230
- var name = xml.attributes.getNamedItem("name").nodeValue;
2231
- var linkEntityObj = new linkEntity_1(name);
2232
- linkEntityObj.allAttributes = (xml.getElementsByTagName("all-attributes").length == 1);
2233
- Util.parseAttributes(xml, linkEntityObj, (linkEntityObj, name, value) => {
2234
- switch (name) {
2235
- case "to":
2236
- case "from":
2237
- case "alias":
2238
- linkEntityObj[name] = value;
2239
- break;
2240
- case "link-type":
2241
- linkEntityObj.linktype = value;
2242
- break;
2243
- case "visible":
2244
- case "intersect":
2245
- linkEntityObj[name] = (value == "true") ? true : false;
2246
- break;
2247
- }
2248
- });
2249
- for (var i = 0; i < xml.childNodes.length; i++) {
2250
- if (xml.childNodes[i].nodeName == "attribute") {
2251
- linkEntityObj.addAttribute(attribute.attributeFromXml(xml.childNodes[i]));
2252
- }
2253
- if (xml.childNodes[i].nodeName == "order") {
2254
- linkEntityObj.addOrder(order.orderFromXml(xml.childNodes[i]));
2255
- }
2256
- if (xml.childNodes[i].nodeName == "filter") {
2257
- linkEntityObj.addFilter(filter.filterFromXml(xml.childNodes[i]));
2258
- }
2259
- if (xml.childNodes[i].nodeName == "link-entity") {
2260
- linkEntityObj.addLinkEntity(linkEntity_1.linkEntityFromXml(xml.childNodes[i]));
2261
- }
2262
- }
2263
- return linkEntityObj;
2264
- }
2265
- };
2266
- linkEntity = linkEntity_1 = __decorate([
2267
- sealed
2268
- ], linkEntity);
2269
- FetchXml.linkEntity = linkEntity;
2270
- let order = order_1 = class order {
2271
- /**
2272
- * Contains the data for a fetchXml order element.
2273
- * @param attribute The logical name of the attribute
2274
- * @param descending Whether the order is decending. Default is false
2275
- * @param alias The alias to apply to the order
2276
- */
2277
- constructor(attribute, descending, alias) {
2278
- this._attribute = null;
2279
- this._descending = null;
2280
- this._alias = null;
2281
- // new keyword not required in JS
2282
- if (!(this instanceof order_1)) {
2283
- return new order_1(attribute, descending, alias);
2284
- }
2285
- if (attribute)
2286
- this.attribute = attribute;
2287
- if (descending)
2288
- this.descending = descending;
2289
- if (alias)
2290
- this.alias = alias;
2291
- }
2292
- /**
2293
- * Gets or sets logical name of the attribute
2294
- */
2295
- get attribute() {
2296
- return this._attribute;
2297
- }
2298
- set attribute(value) {
2299
- this._attribute = value;
2300
- }
2301
- /**
2302
- *Gets or sets whether the order is descending. Default is false
2303
- */
2304
- get descending() {
2305
- return this._descending;
2306
- }
2307
- set descending(value) {
2308
- this._descending = value;
2309
- }
2310
- /**
2311
- * Gets or sets the alias property of the order
2312
- */
2313
- get alias() {
2314
- return this._alias;
2315
- }
2316
- set alias(value) {
2317
- this._alias = value;
2318
- }
2319
- //Internal use only
2320
- get hash() {
2321
- var s = "".concat((this._attribute ? this._attribute : ""), (this._alias ? this._alias : ""), this._descending.toString());
2322
- return s.hashCode();
2323
- }
2324
- /** @description Sets the attribute property of the order attribute
2325
- * @param {string} attribute The attribute value to apply to the order
2326
- * @returns {Sdk.FetchXml.order}
2327
- */
2328
- setAttribute(attribute) {
2329
- this.attribute = attribute;
2330
- return this;
2331
- }
2332
- /** @description Sets the alias property of the order attribute
2333
- * @param {string} alias The alias value to apply to the order
2334
- * @returns {Sdk.FetchXml.order}
2335
- */
2336
- setAlias(alias) {
2337
- this.alias = alias;
2338
- return this;
2339
- }
2340
- /** @description Sets the descending property of the order attribute
2341
- * @param {boolean | null} descending The descending value to apply to the order
2342
- * @returns {Sdk.FetchXml.order}
2343
- */
2344
- setDescending(descending) {
2345
- this.descending = descending;
2346
- return this;
2347
- }
2348
- //Internal use only
2349
- toXml(doc) {
2350
- var orderNode = doc.createElement("order");
2351
- if (this.attribute) {
2352
- orderNode.setAttribute("attribute", this.attribute);
2353
- }
2354
- if (this.alias) {
2355
- orderNode.setAttribute("alias", this.alias);
2356
- }
2357
- if (!Util.isNullOrUndefined(this.descending)) {
2358
- orderNode.setAttribute("descending", this.descending.toString());
2359
- }
2360
- return orderNode;
2361
- }
2362
- static orderFromXml(xml) {
2363
- var orderObj = new order_1();
2364
- Util.parseAttributes(xml, orderObj, (orderObj, name, value) => {
2365
- switch (name) {
2366
- case "attribute":
2367
- orderObj.attribute = value;
2368
- break;
2369
- case "alias":
2370
- orderObj.alias = value;
2371
- break;
2372
- case "descending":
2373
- orderObj.descending = (value == "true") ? true : false;
2374
- break;
2375
- }
2376
- });
2377
- return orderObj;
2378
- }
2379
- };
2380
- order = order_1 = __decorate([
2381
- sealed
2382
- ], order);
2383
- FetchXml.order = order;
2384
- let value = value_1 = class value {
2385
- /**
2386
- * Contains the data for a fetchXml value element.
2387
- * @param value The the value of the value
2388
- * @param [uiname] The uiname for the value
2389
- * @param [uitype] The uitype for the value
2390
- */
2391
- constructor(value, uiname, uitype) {
2392
- this._value = null;
2393
- this._uiname = null;
2394
- this._uitype = null;
2395
- //New keyword not required in JS
2396
- if (!(this instanceof Sdk.FetchXml.value)) {
2397
- return new value(value, uiname, uitype);
2398
- }
2399
- if (value)
2400
- this.value = value;
2401
- if (uiname)
2402
- this.uiname = uiname;
2403
- if (uitype)
2404
- this.uitype = uitype;
2405
- }
2406
- /**
2407
- * Gets or sets the value for the value.
2408
- */
2409
- get value() {
2410
- return this._value;
2411
- }
2412
- set value(value) {
2413
- this._value = value;
2414
- }
2415
- /**
2416
- * Gets or sets the uiname to apply to the value
2417
- */
2418
- get uiname() {
2419
- return this._uiname;
2420
- }
2421
- set uiname(value) {
2422
- this._uiname = value;
2423
- }
2424
- /**
2425
- * Gets or sets the uitype to apply to the value
2426
- */
2427
- get uitype() {
2428
- return this._uitype;
2429
- }
2430
- set uitype(value) {
2431
- this._uitype = value;
2432
- }
2433
- /** @description Sets the value to apply in the value
2434
- * @param {string} value The value to apply in the value
2435
- * @returns {Sdk.FetchXml.value}
2436
- */
2437
- setValue(value) {
2438
- this.value = value;
2439
- return this;
2440
- }
2441
- /** @description Sets the uiname to apply in the value
2442
- * @param {string} uiname The uiname to apply in the value
2443
- * @returns {Sdk.FetchXml.value}
2444
- */
2445
- setUIname(value) {
2446
- this.uiname = value;
2447
- return this;
2448
- }
2449
- /** @description Sets the uitype to apply in the value
2450
- * @param {string} uitype The uitype to apply in the value
2451
- * @returns {Sdk.FetchXml.value}
2452
- */
2453
- setUItype(value) {
2454
- this.uitype = value;
2455
- return this;
2456
- }
2457
- //Internal use only
2458
- toXml(doc) {
2459
- var vNode = doc.createElement("value");
2460
- if (this.uitype) {
2461
- vNode.setAttribute("uitype", this.uitype);
2462
- }
2463
- if (this.uiname) {
2464
- vNode.setAttribute("uiname", this.uiname);
2465
- }
2466
- vNode.appendChild(doc.createTextNode(this.value));
2467
- return vNode;
2468
- }
2469
- static valueFromXml(xml) {
2470
- var valueObj = new value_1(xml.textContent);
2471
- Util.parseAttributes(xml, valueObj, (object, name, value) => {
2472
- switch (name) {
2473
- case "uiname":
2474
- case "uitype":
2475
- object[name] = value;
2476
- break;
2477
- }
2478
- });
2479
- return valueObj;
2480
- }
2481
- };
2482
- value = value_1 = __decorate([
2483
- sealed
2484
- ], value);
2485
- FetchXml.value = value;
2486
- class Util {
2487
- static isBoolean(obj) {
2488
- return (typeof obj === "boolean");
2489
- }
2490
- static isBooleanOrNull(obj) {
2491
- return (Util.isNull(obj) || Util.isBoolean(obj));
2492
- }
2493
- static isNumber(obj) {
2494
- return (typeof (obj) === "number");
2495
- }
2496
- static isNumberOrNull(obj) {
2497
- return (Util.isNull(obj) || Util.isNumber(obj));
2498
- }
2499
- static isNull(obj) {
2500
- return (obj === null);
2501
- }
2502
- static isNullOrUndefined(obj) {
2503
- return (obj === null || typeof obj == "undefined");
2504
- }
2505
- static isEnumMember(enumType, obj) {
2506
- for (var i in enumType) {
2507
- if (obj === enumType[i]) {
2508
- return true;
2509
- }
2510
- }
2511
- return false;
2512
- }
2513
- static isEnumMemberOrNull(enumType, obj) {
2514
- return (Util.isNull(obj) || Util.isEnumMember(enumType, obj));
2515
- }
2516
- static isString(obj) {
2517
- return (typeof obj === "string");
2518
- }
2519
- static isStringOrNull(obj) {
2520
- return (Util.isNull(obj) || Util.isString(obj));
2521
- }
2522
- static isOrder(obj) {
2523
- return (obj instanceof order);
2524
- }
2525
- static isOrderOrNull(obj) {
2526
- return (Util.isNull(obj) || Util.isOrder(obj));
2527
- }
2528
- static isOrderArray(obj) {
2529
- if (Array.isArray(obj)) {
2530
- obj.forEach(function (item) {
2531
- if (!Util.isOrder(item)) {
2532
- return false;
2533
- }
2534
- });
2535
- return true;
2536
- }
2537
- return false;
2538
- }
2539
- static isOrderArrayOrNull(obj) {
2540
- return (Util.isNull(obj) || Util.isOrderArray(obj));
2541
- }
2542
- static isEntity(obj) {
2543
- return (obj instanceof entity);
2544
- }
2545
- static isAttribute(obj) {
2546
- return (obj instanceof attribute);
2547
- }
2548
- static isAttributeArray(obj) {
2549
- if (Array.isArray(obj)) {
2550
- obj.forEach(function (item) {
2551
- if (!Util.isAttribute(item)) {
2552
- return false;
2553
- }
2554
- });
2555
- return true;
2556
- }
2557
- return false;
2558
- }
2559
- static isAttributeArrayOrNull(obj) {
2560
- return (Util.isNull(obj) || Util.isAttributeArray(obj));
2561
- }
2562
- static isLinkEntity(obj) {
2563
- return (obj instanceof linkEntity);
2564
- }
2565
- static isLinkEntityOrNull(obj) {
2566
- return (Util.isNull(obj) || Util.isLinkEntity(obj));
2567
- }
2568
- static isLinkEntityArray(obj) {
2569
- if (Array.isArray(obj)) {
2570
- obj.forEach(function (item) {
2571
- if (!Util.isLinkEntity(item)) {
2572
- return false;
2573
- }
2574
- });
2575
- return true;
2576
- }
2577
- return false;
2578
- }
2579
- static isLinkEntityArrayOrNull(obj) {
2580
- return (Util.isNull(obj) || Util.isLinkEntityArray(obj));
2581
- }
2582
- static isFilter(obj) {
2583
- return (obj instanceof filter);
2584
- }
2585
- static isFilterOrNull(obj) {
2586
- return (Util.isNull(obj) || Util.isFilter(obj));
2587
- }
2588
- static isFilterArray(obj) {
2589
- if (Array.isArray(obj)) {
2590
- obj.forEach(function (item) {
2591
- if (!Util.isFilter(item)) {
2592
- return false;
2593
- }
2594
- });
2595
- return true;
2596
- }
2597
- return false;
2598
- }
2599
- static isFilterArrayOrNull(obj) {
2600
- return (Util.isNull(obj) || Util.isFilterArray(obj));
2601
- }
2602
- static isCondition(obj) {
2603
- return (obj instanceof condition);
2604
- }
2605
- static isConditionOrNull(obj) {
2606
- return (Util.isNull(obj) || Util.isCondition(obj));
2607
- }
2608
- static isConditionArray(obj) {
2609
- if (Array.isArray(obj)) {
2610
- obj.forEach(function (item) {
2611
- if (!Util.isCondition(item)) {
2612
- return false;
2613
- }
2614
- });
2615
- return true;
2616
- }
2617
- return false;
2618
- }
2619
- static isConditionArrayOrNull(obj) {
2620
- return (Util.isNull(obj) || Util.isConditionArray(obj));
2621
- }
2622
- static isValue(obj) {
2623
- return (obj instanceof value);
2624
- }
2625
- static isValueOrNull(obj) {
2626
- return (Util.isNull(obj) || Util.isValue(obj));
2627
- }
2628
- static isValueArray(obj) {
2629
- if (Array.isArray(obj)) {
2630
- var returnValue = true;
2631
- obj.forEach(function (item) {
2632
- if (!Util.isValue(item)) {
2633
- returnValue = false;
2634
- }
2635
- });
2636
- return returnValue;
2637
- }
2638
- return false;
2639
- }
2640
- static isValueArrayOrNull(obj) {
2641
- return (Util.isNull(obj) || Util.isValueArray(obj));
2642
- }
2643
- static getEnumNameFromValue(enumtype, value) {
2644
- for (var i in enumtype) {
2645
- if (enumtype[i] == value) {
2646
- return i;
2647
- }
2648
- }
2649
- }
2650
- static getCollectionHash(collection) {
2651
- var ch = [];
2652
- collection.forEach(function (c) {
2653
- ch.push(c.hash);
2654
- });
2655
- return ch.join();
2656
- }
2657
- static removeCollectionValue(collection, value) {
2658
- Util.removeCollectionValueByProperty(collection, "hash", value);
2659
- }
2660
- static removeCollectionValueByProperty(collection, propertyName, value) {
2661
- var matches = [];
2662
- collection.forEach(function (b, i) {
2663
- //Check if same values
2664
- if (b[propertyName] == value[propertyName]) {
2665
- matches.push(b);
2666
- }
2667
- });
2668
- matches.forEach(function (m) {
2669
- Util.removeCollectionValueByRef(collection, m);
2670
- });
2671
- }
2672
- static removeCollectionValueByRef(collection, value) {
2673
- var indexes = [];
2674
- collection.forEach(function (a, i) {
2675
- //check if same object
2676
- if (a === value) {
2677
- indexes.push(i);
2678
- }
2679
- });
2680
- if (indexes.length > 0) {
2681
- //Removing in reverse order
2682
- for (var i = indexes.length - 1; i >= 0; i--) {
2683
- collection.splice(indexes[i], 1);
2684
- }
2685
- }
2686
- }
2687
- static convertFetchBoolType(value) {
2688
- switch (value) {
2689
- case "true":
2690
- case "1":
2691
- return true;
2692
- case "false":
2693
- case "0":
2694
- return false;
2695
- default:
2696
- throw new Error("Unexpected FetchBoolType value");
2697
- }
2698
- }
2699
- static parseAttributes(xml, object, switchFunction) {
2700
- var atts = xml.attributes;
2701
- for (var i = 0; i < atts.length; i++) {
2702
- var name = atts[i].nodeName;
2703
- var value = atts[i].nodeValue;
2704
- switchFunction(object, name, value);
2705
- }
2706
- }
2707
- }
2708
- FetchXml.Util = Util;
2709
- let Mapping = class Mapping {
2710
- };
2711
- Mapping.Internal = "internal";
2712
- Mapping.Logical = "logical";
2713
- Mapping = __decorate([
2714
- frozen
2715
- ], Mapping);
2716
- FetchXml.Mapping = Mapping;
2717
- let OutputFormat = class OutputFormat {
2718
- };
2719
- OutputFormat.Ado = "xml-ado";
2720
- OutputFormat.Auto = "xml-auto";
2721
- OutputFormat.Elements = "xml-elements";
2722
- OutputFormat.Raw = "xml-raw";
2723
- OutputFormat.Platform = "xml-platform";
2724
- OutputFormat = __decorate([
2725
- frozen
2726
- ], OutputFormat);
2727
- FetchXml.OutputFormat = OutputFormat;
2728
- let Build = class Build {
2729
- };
2730
- Build.OnePoint504021 = "1.504021";
2731
- Build.OnePoint003017 = "1.003017";
2732
- Build = __decorate([
2733
- frozen
2734
- ], Build);
2735
- FetchXml.Build = Build;
2736
- let Aggregate = class Aggregate {
2737
- };
2738
- Aggregate.Count = "count";
2739
- Aggregate.CountColumn = "countcolumn";
2740
- Aggregate.Sum = "sum";
2741
- Aggregate.Avg = "avg";
2742
- Aggregate.Min = "min";
2743
- Aggregate.Max = "max";
2744
- Aggregate = __decorate([
2745
- frozen
2746
- ], Aggregate);
2747
- FetchXml.Aggregate = Aggregate;
2748
- let RowAggregate = class RowAggregate {
2749
- };
2750
- RowAggregate.Countchildren = "countchildren";
2751
- RowAggregate = __decorate([
2752
- frozen
2753
- ], RowAggregate);
2754
- FetchXml.RowAggregate = RowAggregate;
2755
- let DateGrouping = class DateGrouping {
2756
- };
2757
- DateGrouping.Day = "day";
2758
- DateGrouping.Week = "week";
2759
- DateGrouping.Month = "month";
2760
- DateGrouping.Quarter = "quarter";
2761
- DateGrouping.Year = "year";
2762
- DateGrouping.FiscalPeriod = "fiscal-period";
2763
- DateGrouping.FiscalYear = "fiscal-year";
2764
- DateGrouping = __decorate([
2765
- frozen
2766
- ], DateGrouping);
2767
- FetchXml.DateGrouping = DateGrouping;
2768
- let Operator = class Operator {
2769
- };
2770
- /** Returns all records in referenced record's hierarchical ancestry line.*/
2771
- Operator.Above = "above";
2772
- /** The string occurs at the beginning of another string.*/
2773
- Operator.BeginsWith = "begins-with";
2774
- /** The value is between two values.*/
2775
- Operator.Between = "between";
2776
- /** The string ends with another string.*/
2777
- Operator.EndsWith = "ends-with";
2778
- /** The values are compared for equality. */
2779
- Operator.Equal = "eq";
2780
- /** The value is equal to the specified business ID. */
2781
- Operator.EqualBusinessId = "eq-businessid";
2782
- /** Returns the referenced record and all records above it in the hierarchy.*/
2783
- Operator.EqualOrAbove = "eq-or-above";
2784
- /** Returns the referenced record and all records below it in the hierarchy.*/
2785
- Operator.EqualOrUnder = "eq-or-under";
2786
- /** The value is equal to the specified user ID.*/
2787
- Operator.EqualUserId = "eq-userid";
2788
- /** The value is equal to the language for the user. */
2789
- Operator.EqualUserLanguage = "eq-userlanguage";
2790
- /** When hierarchical security models are used; Equals current user or his reporting hierarchy*/
2791
- Operator.EqualUserOrUserHierarchy = "eq-useroruserhierarchy";
2792
- /** When hierarchical security models are used; Equals current user and his teams or his reporting hierarchy and their teams*/
2793
- Operator.EqualUserOrUserHierarchyAndTeams = "eq-useroruserhierarchyandteams";
2794
- /** The record is owned by a user or teams that the user is a member of.*/
2795
- Operator.EqualUserOrUserTeams = "eq-useroruserteams";
2796
- /** The record is owned by teams that the user is a member of.*/
2797
- Operator.EqualUserTeams = "eq-userteams";
2798
- /** The value is greater than or equal to the compared value.*/
2799
- Operator.GreaterOrEqual = "ge";
2800
- /** The value is greater than the compared value.*/
2801
- Operator.GreaterThan = "gt";
2802
- /** The value exists in a list of values.*/
2803
- Operator.In = "in";
2804
- /** The value is within the specified fiscal period.*/
2805
- Operator.InFiscalPeriod = "in-fiscal-period";
2806
- /** The value is within the specified fiscal period and year.*/
2807
- Operator.InFiscalPeriodAndYear = "in-fiscal-period-and-year";
2808
- /** The value is within the specified year.*/
2809
- Operator.InFiscalYear = "in-fiscal-year";
2810
- /** The value is within or after the specified fiscal period and year.*/
2811
- Operator.InOrAfterFiscalPeriodAndYear = "in-or-after-fiscal-period-and-year";
2812
- /** The value is within or before the specified fiscal period and year.*/
2813
- Operator.InOrBeforeFiscalPeriodAndYear = "in-or-before-fiscal-period-and-year";
2814
- /** The value is within the last fiscal period.*/
2815
- Operator.LastFiscalPeriod = "last-fiscal-period";
2816
- /** The value is within the last fiscal year.*/
2817
- Operator.LastFiscalYear = "last-fiscal-year";
2818
- /** The value is within the last month*/
2819
- Operator.LastMonth = "last-month";
2820
- /** The value is within last seven days.*/
2821
- Operator.LastSevenDays = "last-seven-days";
2822
- /** The value is within the previous week*/
2823
- Operator.LastWeek = "last-week";
2824
- /** The value is within last X days.*/
2825
- Operator.LastXDays = "last-x-days";
2826
- /** The value is within the last X fiscal periods.*/
2827
- Operator.LastXFiscalPeriods = "last-x-fiscal-periods";
2828
- /** The value is within the last X fiscal years.*/
2829
- Operator.LastXFiscalYears = "last-x-fiscal-years";
2830
- /** The value is within the last X hours.*/
2831
- Operator.LastXHours = "last-x-hours";
2832
- /** The value is within the last X months.*/
2833
- Operator.LastXMonths = "last-x-months";
2834
- /** The value is within the last X weeks.*/
2835
- Operator.LastXWeeks = "last-x-weeks";
2836
- /** The value is within the last X years.*/
2837
- Operator.LastXYears = "last-x-years";
2838
- /** The value is within the last year.*/
2839
- Operator.LastYear = "last-year";
2840
- /** The value is less than or equal to the compared value.*/
2841
- Operator.LessOrEqual = "le";
2842
- /** The character string is matched to the specified pattern.*/
2843
- Operator.Like = "like";
2844
- /** The value is less than the compared value.*/
2845
- Operator.LessThan = "lt";
2846
- /** The two values are not equal.*/
2847
- Operator.NotEqual = "ne";
2848
- /** The value is not equal to the specified business ID.*/
2849
- Operator.NotEqualBusinessId = "ne-businessid";
2850
- /** The value is not equal to the specified user ID.*/
2851
- Operator.NotEqualUserId = "ne-userid";
2852
- /** Not Equal To*/
2853
- Operator.Neq = "neq"; //Is this the same as 'ne'?
2854
- /** The value is within the next fiscal period.*/
2855
- Operator.NextFiscalPeriod = "next-fiscal-period";
2856
- /** The value is within the next fiscal year.*/
2857
- Operator.NextFiscalYear = "next-fiscal-year";
2858
- /** The value is within the next month.*/
2859
- Operator.NextMonth = "next-month";
2860
- /** The value is within the next seven days.*/
2861
- Operator.NextSevenDays = "next-seven-days";
2862
- /** The value is within the next week.*/
2863
- Operator.NextWeek = "next-week";
2864
- /** The value is within the X days.*/
2865
- Operator.NextXDays = "next-x-days";
2866
- /** The value is within the next X fiscal periods.*/
2867
- Operator.NextXFiscalPeriods = "next-x-fiscal-periods";
2868
- /** The value is within the next X fiscal years.*/
2869
- Operator.NextXFiscalYears = "next-x-fiscal-years";
2870
- /** The value is within the next X hours.*/
2871
- Operator.NextXHours = "next-x-hours";
2872
- /** The value is within the next X nonths.*/
2873
- Operator.NextXMonths = "next-x-months";
2874
- /** The value is within the next X weeks.*/
2875
- Operator.NextXWeeks = "next-x-weeks";
2876
- /** The value is within the next X years.*/
2877
- Operator.NextXYears = "next-x-years";
2878
- /** The value is within the next year.*/
2879
- Operator.NextYear = "next-year";
2880
- /** The string does not begin with another string.*/
2881
- Operator.NotBeginWith = "not-begin-with";
2882
- /** The value is not between two values.*/
2883
- Operator.NotBetween = "not-between";
2884
- /** The string does not end with another string.*/
2885
- Operator.NotEndWith = "not-end-with";
2886
- /** The given value is not matched to a value in a subquery or a list.*/
2887
- Operator.NotIn = "not-in";
2888
- /** The character string does not match the specified pattern.*/
2889
- Operator.NotLike = "not-like";
2890
- /** The value is not null.*/
2891
- Operator.NotNull = "not-null";
2892
- /** Returns all records not below the referenced record in the hierarchy*/
2893
- Operator.NotUnder = "not-under";
2894
- /** The value is null.*/
2895
- Operator.Null = "null";
2896
- /** The value is older than the specified number of days. */
2897
- Operator.OlderThanXDays = "olderthan-x-days";
2898
- /** The value is older than the specified number of hours. */
2899
- Operator.OlderThanXHours = "olderthan-x-hours";
2900
- /** The value is older than the specified number of minutes. */
2901
- Operator.OlderThanXMinutes = "olderthan-x-minutes";
2902
- /** The value is older than the specified number of months. */
2903
- Operator.OlderThanXMonths = "olderthan-x-months";
2904
- /** The value is older than the specified number of weeks. */
2905
- Operator.OlderThanXWeeks = "olderthan-x-weeks";
2906
- /** The value is older than the specified number of years. */
2907
- Operator.OlderThanXYears = "olderthan-x-years";
2908
- /** The value is on a specified date.*/
2909
- Operator.On = "on";
2910
- /** The value is on or after a specified date.*/
2911
- Operator.OnOrAfter = "on-or-after";
2912
- /** The value is on or before a specified date.*/
2913
- Operator.OnOrBefore = "on-or-before";
2914
- /** The value is within the current fiscal period.*/
2915
- Operator.ThisFiscalPeriod = "this-fiscal-period";
2916
- /** The value is within the current fiscal year.*/
2917
- Operator.ThisFiscalYear = "this-fiscal-year";
2918
- /** The value is within the current month.*/
2919
- Operator.ThisMonth = "this-month";
2920
- /** The value is within the current week.*/
2921
- Operator.ThisWeek = "this-week";
2922
- /** The value is within the current year.*/
2923
- Operator.ThisYear = "this-year";
2924
- /** The value equals today’s date.*/
2925
- Operator.Today = "today";
2926
- /** The value equals tomorrow’s date.*/
2927
- Operator.Tomorrow = "tomorrow";
2928
- /** Returns all child records below the referenced record in the hierarchy*/
2929
- Operator.Under = "under";
2930
- /** The value equals yesterday’s date.*/
2931
- Operator.Yesterday = "yesterday";
2932
- Operator = __decorate([
2933
- frozen
2934
- ], Operator);
2935
- FetchXml.Operator = Operator;
2936
- let FilterType = class FilterType {
2937
- };
2938
- FilterType.And = "and";
2939
- FilterType.Or = "or";
2940
- FilterType = __decorate([
2941
- frozen
2942
- ], FilterType);
2943
- FetchXml.FilterType = FilterType;
2944
- })(Sdk.FetchXml || (Sdk.FetchXml = {}));
2945
- })(Sdk || (Sdk = {}));
2946
- function sealed(constructor) {
2947
- Object.seal(constructor);
2948
- Object.seal(constructor.prototype);
2949
- }
2950
- function frozen(constructor) {
2951
- Object.freeze(constructor);
2952
- Object.freeze(constructor.prototype);
2953
- }
2954
- String.prototype.hashCode = function () {
2955
- let hash = 0;
2956
- if (this.length == 0)
2957
- return hash.toString();
2958
- for (let i = 0; i < this.length; i++) {
2959
- let char = this.charCodeAt(i);
2960
- hash = ((hash << 5) - hash) + char;
2961
- hash = hash & hash; // Convert to 32bit integer
2962
- }
2963
- return hash.toString();
2964
- };
2965
-
2966
- const useFetchXml = (context) => {
2967
- const cachedFetchXml = useRef({});
2968
- const get = (viewId) => __awaiter(void 0, void 0, void 0, function* () {
2969
- if (!cachedFetchXml.current[viewId]) {
2970
- cachedFetchXml.current[viewId] = context.webAPI.retrieveRecord('savedquery', viewId, '?$select=fetchxml');
2971
- }
2972
- return (yield cachedFetchXml.current[viewId]).fetchxml;
2973
- });
2974
- const applyLookupQuery = (entity, fetchXml, query) => __awaiter(void 0, void 0, void 0, function* () {
2975
- if (!query) {
2976
- return fetchXml;
2977
- }
2978
- const metadata = yield entity.metadata;
2979
- const xmlObject = Sdk.FetchXml.fetch.fromXml(fetchXml);
2980
- xmlObject.entity.addFilter(new Sdk.FetchXml.filter(Sdk.FetchXml.FilterType.Or, [
2981
- new Sdk.FetchXml.condition(metadata.PrimaryNameAttribute, Sdk.FetchXml.Operator.Like, [new Sdk.FetchXml.value(`%${query}%`)])
2982
- ]));
2983
- return xmlObject.toXml();
2984
- });
2985
- return [get, applyLookupQuery];
2986
- };
2987
-
2988
- const useLookup = (props) => {
2989
- const targets = props.parameters.value.attributes.Targets;
2990
- const boundValue = props.parameters.value.raw;
2991
- const context = props.context;
2992
- const { labels, onNotifyOutputChanged } = useComponent('Lookup', props, lookupTranslations);
2993
- const [getFetchXml, applyLookupQuery] = useFetchXml(context);
2994
- const [entities, setEntities] = useState(() => {
2995
- return targets.map(target => {
2996
- return {
2997
- entityName: target,
2998
- selected: targets.length === 1 ? true : false,
2999
- metadata: props.context.utils.getEntityMetadata(target, []),
3000
- };
3001
- });
3002
- });
3003
- const selectedEntity = entities.find(x => x.selected);
3004
- const selectEntity = (entityName) => {
3005
- setEntities([...entities].map(entity => {
3006
- return {
3007
- entityName: entity.entityName,
3008
- metadata: entity.metadata,
3009
- selected: entity.entityName === entityName
3010
- };
3011
- }));
3012
- };
3013
- const selectRecords = (records) => {
3014
- onNotifyOutputChanged({
3015
- value: records
3016
- });
3017
- };
3018
- const getSearchFetchXml = (entityName, query) => __awaiter(void 0, void 0, void 0, function* () {
3019
- const response = (yield props.parameters.value.getAllViews(entityName)).find(x => x.isDefault);
3020
- if (!(response === null || response === void 0 ? void 0 : response.viewId)) {
3021
- throw new Error(`Entity ${entityName} does not have a default view id!`);
3022
- }
3023
- let fetchXml = response === null || response === void 0 ? void 0 : response.fetchXml;
3024
- if (!fetchXml) {
3025
- fetchXml = yield getFetchXml(response.viewId);
3026
- }
3027
- return applyLookupQuery(entities.find(x => x.entityName === entityName), fetchXml, query);
3028
- });
3029
- const getSearchResults = (query) => __awaiter(void 0, void 0, void 0, function* () {
3030
- if (props.onSearch) {
3031
- return props.onSearch(selectedEntity ? [selectedEntity === null || selectedEntity === void 0 ? void 0 : selectedEntity.entityName] : targets, query);
3032
- }
3033
- const fetchXmlMap = new Map();
3034
- if (selectedEntity) {
3035
- fetchXmlMap.set(selectedEntity.entityName, getSearchFetchXml(selectedEntity.entityName, query));
3036
- }
3037
- else {
3038
- for (const entity of targets) {
3039
- fetchXmlMap.set(entity, getSearchFetchXml(entity, query));
3040
- }
3041
- }
3042
- yield Promise.all(fetchXmlMap.values());
3043
- const responsePromiseMap = new Map();
3044
- for (const [entityName, fetchXml] of fetchXmlMap) {
3045
- responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((yield fetchXml))}`));
3046
- }
3047
- yield Promise.all(responsePromiseMap.values());
3048
- const result = [];
3049
- for (const [entityName, response] of responsePromiseMap) {
3050
- for (const entity of (yield response).entities) {
3051
- const entityMetadata = yield entities.find(x => x.entityName === entityName).metadata;
3052
- result.push({
3053
- entityType: entityName,
3054
- id: entity[entityMetadata.PrimaryIdAttribute],
3055
- name: entity[entityMetadata.PrimaryNameAttribute]
3056
- });
3057
- }
3058
- }
3059
- return result;
3060
- });
3061
- const createRecord = (entityName) => __awaiter(void 0, void 0, void 0, function* () {
3062
- const result = yield context.navigation.openForm({
3063
- entityName: entityName,
3064
- useQuickCreateForm: true
3065
- });
3066
- if (!result.savedEntityReference) {
3067
- return;
3068
- }
3069
- onNotifyOutputChanged({
3070
- value: result.savedEntityReference
3071
- });
3072
- });
3073
- const deselectRecord = (record) => {
3074
- const map = new Map(boundValue.map(value => [value.id, value]));
3075
- map.delete(record.id);
3076
- onNotifyOutputChanged({
3077
- value: [...map.values()]
3078
- });
3079
- };
3080
- return [
3081
- boundValue, entities, labels, {
3082
- create: createRecord,
3083
- deselect: deselectRecord,
3084
- select: selectRecords
3085
- },
3086
- selectEntity,
3087
- getSearchResults
3088
- ];
3089
- };
3090
-
3091
- const getTargetSelectorStyles = (theme) => {
3092
- return mergeStyleSets({
3093
- targetSelector: {
3094
- display: 'flex',
3095
- paddingLeft: 8,
3096
- paddingRight: 8,
3097
- paddingBottom: 8,
3098
- gap: 8,
3099
- paddingTop: 8,
3100
- '>span': {
3101
- lineHeight: 15,
3102
- minWidth: 'fit-content',
3103
- color: theme.semanticColors.listText,
3104
- fontWeight: 600
3105
- }
3106
- },
3107
- targetSelectorLinks: {
3108
- display: 'flex',
3109
- gap: 5,
3110
- flexWrap: 'wrap'
3111
- },
3112
- targetSelectorLink: {
3113
- color: theme.palette.blackTranslucent40,
3114
- '&[data-selected="true"]': {
3115
- color: theme.semanticColors.link,
3116
- fontWeight: 600
3117
- }
3118
- },
3119
- });
3120
- };
3121
- const getHeight = (height) => {
3122
- if (height === -1 || height === 0) {
3123
- return undefined;
3124
- }
3125
- return height;
3126
- };
3127
- const getLookupStyles = (theme, isSingleSelect, height) => {
3128
- const _height = getHeight(height);
3129
- return mergeStyleSets({
3130
- root: {
3131
- '[class*="TALXIS__tag-picker__search-btn"][class*="TALXIS__tag-picker__search-btn"]': {
3132
- top: 0,
3133
- bottom: 0,
3134
- margin: `auto 0`,
3135
- right: 5
3136
- },
3137
- '[data-navigation-enabled="true"]': {
3138
- '> span > div > span': {
3139
- color: theme.semanticColors.link,
3140
- cursor: 'pointer',
3141
- },
3142
- ':hover': {
3143
- textDecoration: 'underline',
3144
- cursor: 'pointer !important'
3145
- }
3146
- },
3147
- '.ms-BasePicker-itemsWrapper .ms-CommandBar': {
3148
- height: _height && isSingleSelect ? _height - 6 : undefined
3149
- },
3150
- '.ms-BasePicker-text': {
3151
- minHeight: _height !== null && _height !== void 0 ? _height : 36,
3152
- height: 'min-content',
3153
- paddingRight: !isSingleSelect ? 36 : undefined,
3154
- alignItems: 'baseline',
3155
- 'input': {
3156
- alignSelf: 'center'
3157
- },
3158
- '.hover-only': {
3159
- animationName: 'none'
3160
- },
3161
- '::after': {
3162
- inset: '0px !important'
3163
- }
3164
- }
3165
- },
3166
- suggestions: {
3167
- '.ms-Suggestions-title': {
3168
- padding: 0,
3169
- display: 'flex',
3170
- flexDirection: 'column',
3171
- }
3172
- },
3173
- createRecordBtn: {
3174
- height: 38,
3175
- width: '100%',
3176
- '.ms-Button-menuIcon': {
3177
- display: 'none'
3178
- },
3179
- '>.ms-Button-flexContainer.ms-Button-flexContainer': {
3180
- justifyContent: 'flex-start'
3181
- },
3182
- '.ms-Button-textContainer': {
3183
- flexGrow: 'initial',
3184
- '>span': {
3185
- fontWeight: 600,
3186
- }
3187
- }
3188
- }
3189
- });
3190
- };
3191
-
3192
- const useLoadedEntities = (entities) => {
3193
- const [loadedEntities, setLoadedEntities] = useState(null);
3194
- useEffect(() => {
3195
- (() => __awaiter(void 0, void 0, void 0, function* () {
3196
- setLoadedEntities(yield Promise.all(entities.map((entity) => __awaiter(void 0, void 0, void 0, function* () {
3197
- return {
3198
- entityName: entity.entityName,
3199
- selected: entity.selected,
3200
- metadata: yield entity.metadata
3201
- };
3202
- }))));
3203
- }))();
3204
- }, [entities]);
3205
- return [loadedEntities];
3206
- };
3207
-
3208
- const TargetSelector = (props) => {
3209
- const { labels, entities, onEntitySelected } = Object.assign({}, props);
3210
- const [loadedEntities] = useLoadedEntities(entities);
3211
- const theme = useTheme();
3212
- const styles = getTargetSelectorStyles(theme);
3213
- return (jsxs("div", Object.assign({ className: styles.targetSelector }, { children: [jsxs(Text, Object.assign({ variant: 'small' }, { children: [labels.resultsFrom(), " "] })), jsxs("div", Object.assign({ className: styles.targetSelectorLinks }, { children: [jsx(Link, Object.assign({ onClick: () => onEntitySelected(null), className: styles.targetSelectorLink, "data-selected": !entities.find(x => x.selected) }, { children: "All" })), loadedEntities &&
3214
- jsx(Fragment, { children: loadedEntities.map((entity) => {
3215
- return jsx(Link, Object.assign({ className: styles.targetSelectorLink, "data-selected": entity.selected, onClick: () => onEntitySelected(entity.entityName) }, { children: entity.metadata.DisplayName }));
3216
- }) })] }))] })));
3217
- };
3218
-
3219
- const RecordCreator = (props) => {
3220
- const { labels, entities, onCreateRecord } = Object.assign({}, props);
3221
- const [loadedEntities] = useLoadedEntities(entities);
3222
- const theme = useTheme();
3223
- const styles = getLookupStyles(theme, 0);
3224
- const selectedEntity = entities.find(x => x.selected);
3225
- return (jsx(CommandBarButton, { className: styles.createRecordBtn, iconProps: {
3226
- iconName: 'Add'
3227
- }, onClick: selectedEntity ? () => onCreateRecord(selectedEntity.entityName) : undefined, menuProps: !selectedEntity ? {
3228
- calloutProps: {
3229
- coverTarget: false
3230
- },
3231
- isBeakVisible: true,
3232
- items: loadedEntities ? (() => {
3233
- const items = [{
3234
- key: 'header',
3235
- itemType: ContextualMenuItemType.Header,
3236
- text: 'Vyberte tabulku'
3237
- }];
3238
- return [...items, ...loadedEntities.map(entity => {
3239
- return {
3240
- key: entity.entityName,
3241
- text: entity.metadata.DisplayName,
3242
- onClick: () => onCreateRecord(entity.entityName)
3243
- };
3244
- })];
3245
- })() : []
3246
- } : undefined, text: labels.newRecord() }));
3247
- };
3248
-
3249
- const Lookup = (props) => {
3250
- var _a, _b;
3251
- const context = props.context;
3252
- const ref = useRef(null);
3253
- const componentRef = useRef(null);
3254
- const itemLimit = ((_a = props.parameters.MultipleEnabled) === null || _a === void 0 ? void 0 : _a.raw) === true ? Infinity : 1;
3255
- const theme = useTheme();
3256
- const { height } = useComponentSizing(props.context.mode);
3257
- const styles = getLookupStyles(theme, itemLimit === 1, height);
3258
- const [value, entities, labels, records, selectEntity, getSearchResults] = useLookup(props);
3259
- const mouseOver = useMouseOver(ref);
3260
- const isFocused = useFocusIn(ref);
3261
- const firstRenderRef = useRef(true);
3262
- const shouldFocusRef = useRef(false);
3263
- useEffect(() => {
3264
- if (firstRenderRef.current) {
3265
- firstRenderRef.current = false;
3266
- return;
3267
- }
3268
- //@ts-ignore
3269
- if (componentRef.current.state.suggestionsVisible) {
3270
- //if the suggestions callout is open and the selected target changes, refresh the results
3271
- forceSearch();
3272
- }
3273
- }, [entities]);
3274
- useEffect(() => {
3275
- const onKeyPress = (ev) => {
3276
- var _a;
3277
- if (ev.key === 'Backspace') {
3278
- const picker = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector('[class*="TALXIS__tag-picker__root"]');
3279
- if ((document.activeElement === picker) && value.length === 1) {
3280
- records.select(undefined);
3281
- setTimeout(() => {
3282
- var _a;
3283
- (_a = componentRef.current) === null || _a === void 0 ? void 0 : _a.focusInput();
3284
- }, 200);
3285
- }
3286
- }
3287
- };
3288
- document.addEventListener('keydown', onKeyPress);
3289
- return () => {
3290
- document.removeEventListener('keydown', onKeyPress);
3291
- };
3292
- }, [value]);
3293
- useEffect(() => {
3294
- var _a;
3295
- if (((_a = props.parameters.AutoFocus) === null || _a === void 0 ? void 0 : _a.raw) === true) {
3296
- focus();
3297
- }
3298
- }, []);
3299
- const focus = () => {
3300
- var _a, _b, _c, _d;
3301
- if (((_b = (_a = componentRef.current) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) === itemLimit) {
3302
- //@ts-ignore
3303
- (_c = ref.current) === null || _c === void 0 ? void 0 : _c.querySelector('[class*="TALXIS__tag-picker__root"]').focus();
3304
- return;
3305
- }
3306
- (_d = componentRef.current) === null || _d === void 0 ? void 0 : _d.focusInput();
3307
- };
3308
- const forceSearch = () => __awaiter(void 0, void 0, void 0, function* () {
3309
- //@ts-ignore - We need to use internal methods to show and fill the suggestions on entity change
3310
- componentRef.current.suggestionStore.updateSuggestions([]);
3311
- //@ts-ignore - ^^same as above
3312
- componentRef.current.setState({
3313
- suggestionsVisible: true,
3314
- suggestionsLoading: true,
3315
- });
3316
- //@ts-ignore - ^^same as above
3317
- const results = yield onResolveSuggestions(componentRef.current.input.current.value);
3318
- //@ts-ignore - ^^same as above
3319
- componentRef.current.updateSuggestionsList(results);
3320
- //@ts-ignore - ^^same above
3321
- componentRef.current.setState({
3322
- isMostRecentlyUsedVisible: false,
3323
- suggestionsVisible: true,
3324
- moreSuggestionsAvailable: false,
3325
- });
3326
- });
3327
- const isComponentActive = () => {
3328
- return mouseOver || isFocused;
3329
- };
3330
- const onResolveSuggestions = (filter, selectedItems) => __awaiter(void 0, void 0, void 0, function* () {
3331
- var _c;
3332
- //TODO: onResolveSuggestions gets called when the record gets selected resulting in unnecessary call
3333
- const results = yield getSearchResults(filter);
3334
- const suggestions = [];
3335
- for (const result of results) {
3336
- if (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.find(x => x.key === result.id)) {
3337
- continue;
3338
- }
3339
- const metadata = yield ((_c = entities.find(x => x.entityName === result.entityType)) === null || _c === void 0 ? void 0 : _c.metadata);
3340
- suggestions.push({
3341
- key: result.id,
3342
- text: result.name || labels.noName(),
3343
- secondaryText: metadata === null || metadata === void 0 ? void 0 : metadata.DisplayName,
3344
- 'data-entity': result.entityType
3345
- });
3346
- }
3347
- return suggestions;
3348
- });
3349
- return (jsx("div", Object.assign({ className: styles.root, ref: ref }, { children: jsx(TagPicker, { componentRef: componentRef, resolveDelay: 200, stackItems: itemLimit === 1, errorMessage: props.parameters.value.errorMessage, pickerCalloutProps: {
3350
- className: styles.suggestions,
3351
- }, pickerSuggestionsProps: {
3352
- loadingText: labels.searching(),
3353
- noResultsFoundText: labels.noRecordsFound(),
3354
- //@ts-ignore
3355
- suggestionsHeaderText: jsxs(Fragment, { children: [((_b = props.parameters.IsInlineNewEnabled) === null || _b === void 0 ? void 0 : _b.raw) !== false &&
3356
- jsx(RecordCreator, { labels: labels, entities: entities, onCreateRecord: records.create }), props.parameters.value.attributes.Targets.length > 1 &&
3357
- jsx(TargetSelector, { labels: labels, entities: entities, onEntitySelected: (entityName) => {
3358
- selectEntity(entityName);
3359
- } })] })
3360
- }, transparent: !isComponentActive() && itemLimit === 1, onChange: (items) => {
3361
- records.select(items === null || items === void 0 ? void 0 : items.map(item => {
3362
- return {
3363
- entityType: item['data-entity'],
3364
- id: item.key,
3365
- name: item.text
3366
- };
3367
- }));
3368
- }, searchBtnProps: {
3369
- iconProps: {
3370
- iconName: 'Search'
3371
- }
3372
- }, selectedItems: value.map(lookup => {
3373
- var _a;
3374
- return {
3375
- key: lookup.id,
3376
- text: lookup.name || labels.noName(),
3377
- 'data-entity': lookup.entityType,
3378
- 'data-navigation-enabled': ((_a = props.parameters.EnableNavigation) === null || _a === void 0 ? void 0 : _a.raw) !== false,
3379
- onClick: () => {
3380
- var _a;
3381
- if (((_a = props.parameters.EnableNavigation) === null || _a === void 0 ? void 0 : _a.raw) === false) {
3382
- return;
3383
- }
3384
- context.navigation.openForm({
3385
- entityName: lookup.entityType,
3386
- entityId: lookup.id
3387
- });
3388
- },
3389
- deleteButtonProps: isComponentActive() || itemLimit > 1 ? {
3390
- key: 'delete',
3391
- iconProps: {
3392
- iconName: 'ChromeClose',
3393
- styles: {
3394
- root: {
3395
- fontSize: 12,
3396
- width: 16,
3397
- color: `${theme.palette.black} !important`
3398
- }
3399
- }
3400
- },
3401
- onClick: () => {
3402
- shouldFocusRef.current = false;
3403
- records.deselect(lookup);
3404
- setTimeout(() => {
3405
- focus();
3406
- }, 200);
3407
- }
3408
- } : undefined
3409
- };
3410
- }), itemLimit: itemLimit, onResolveSuggestions: onResolveSuggestions }) })));
3411
- };
3412
-
3413
- export { Lookup as L, __awaiter as _ };
1
+ import{jsxs as t,jsx as e,Fragment as i}from"react/jsx-runtime";import{useRef as r,useState as s,useEffect as n}from"react";import{useComponent as l}from"./hooks/useComponent.js";import{mergeStyleSets as a,useTheme as o,Link as u,ContextualMenuItemType as h}from"@fluentui/react";import{TagPicker as c}from"@talxis/react-components/dist/components/TagPicker";import{Text as d}from"@fluentui/react/lib/Text";import{useMouseOver as m}from"./hooks/useMouseOver.js";import{CommandBarButton as g}from"@fluentui/react/lib/components/Button/CommandBarButton/CommandBarButton";import{useFocusIn as f}from"./hooks/useFocusIn.js";import{useComponentSizing as y}from"./hooks/useComponentSizing.js";function p(t,e,i,r){var s,n=arguments.length,l=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(l=(n<3?s(l):n>3?s(e,i,l):s(e,i))||l);return n>3&&l&&Object.defineProperty(e,i,l),l}function b(t,e,i,r){return new(i||(i=Promise))((function(s,n){function l(t){try{o(r.next(t))}catch(t){n(t)}}function a(t){try{o(r.throw(t))}catch(t){n(t)}}function o(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(l,a)}o((r=r.apply(t,e||[])).next())}))}const v={search:{1033:"Search",1029:"Vyhledejte"},newRecord:{1033:"New record",1029:"Nový záznam"},searching:{1033:"Searching...",1029:"Hledám..."},noRecordsFound:{1033:"No records found",1029:"Nebyly nalezeny žádné záznamy"},resultsFrom:{1033:"Results from:",1029:"Výsledky z:"},noName:{1033:"(No Name)",1029:"(Bez názvu)"}};var k;function F(t){Object.seal(t),Object.seal(t.prototype)}function X(t){Object.freeze(t),Object.freeze(t.prototype)}!function(t){!function(e){var i,r,s,n,l;let a=i=class attribute{constructor(t){if(this._build=null,this._addedBy=null,this._alias=null,this._aggregate=null,this._groupBy=null,this._dateGrouping=null,this._userTimeZone=null,!(this instanceof i))return new i(t);this.name=t}get name(){return this._name}set name(t){if(!Util.isString(t))throw new Error("Sdk.FetchXml.attribute name property must be an string.");this._name=t}get build(){return this._build}set build(t){if(!Util.isEnumMemberOrNull(b,t))throw new Error("Sdk.FetchXml.attribute build property must be an Sdk.FetchXml.Build value or null.");this._build=t}get addedBy(){return this._addedBy}set addedBy(t){if(!Util.isStringOrNull(t))throw new Error("Sdk.FetchXml.attribute addedBy property must be an string value or null.");this._addedBy=t}get alias(){return this._alias}set alias(t){if(!Util.isStringOrNull(t))throw new Error("Sdk.FetchXml.attribute alias property must be an string value or null.");this._alias=t}get aggregate(){return this._aggregate}set aggregate(t){if(!Util.isEnumMemberOrNull(v,t))throw new Error("Sdk.FetchXml.attribute aggregate property must be an Sdk.FetchXml.Aggregate value or null.");this._aggregate=t}get groupBy(){return this._groupBy}set groupBy(t){if(!Util.isBooleanOrNull(t))throw new Error("Sdk.FetchXml.attribute groupBy property must be an boolean value or null.");this._groupBy=t}get dateGrouping(){return this._dateGrouping}set dateGrouping(t){if(!Util.isEnumMemberOrNull(w,t))throw new Error("Sdk.FetchXml.attribute dateGrouping property must be an Sdk.FetchXml.DateGrouping value or null.");this._dateGrouping=t}get userTimeZone(){return this._userTimeZone}set userTimeZone(t){if(!Util.isBooleanOrNull(t))throw new Error("Sdk.FetchXml.attribute userTimeZone property must be an boolean value or null.");this._userTimeZone=t}setName(t){return this.name=t,this}setBuild(t){return this.build=t||null,this}setAddedBy(t){return this.addedBy=t||null,this}setAlias(t){return this.alias=t||null,this}setAggregate(t){return this.aggregate=t||null,this}setGroupBy(t){return t?this.groupBy=t:t=null,this}setDateGrouping(t){return this.dateGrouping=t||null,this}setUserTimeZone(t){return this.userTimeZone=t||null,this}toXml(t){var e=t.createElement("attribute");return e.setAttribute("name",this.name),this.build&&e.setAttribute("build",this.build),this.addedBy&&e.setAttribute("addedby",this.addedBy),this.alias&&e.setAttribute("alias",this.alias),this.aggregate&&e.setAttribute("aggregate",this.aggregate),Util.isBoolean(this.groupBy)&&e.setAttribute("groupby",this.groupBy?"true":"false"),this.dateGrouping&&e.setAttribute("dategrouping",this.dateGrouping),Util.isBoolean(this.userTimeZone)&&e.setAttribute("usertimezone",this.userTimeZone?"true":"false"),e}static attributeFromXml(t){var e=new i(t.attributes.getNamedItem("name").nodeValue);return Util.parseAttributes(t,e,((t,e,i)=>{switch(e){case"build":case"alias":case"aggregate":t[e]=i;break;case"addedby":t.addedBy=i;break;case"dategrouping":t.dateGrouping=i;break;case"groupby":t.groupBy=Util.convertFetchBoolType(i);case"usertimezone":t.userTimeZone=Util.convertFetchBoolType(i)}})),e}};a=i=p([F],a),e.attribute=a;let o=class condition{constructor(e,i,r){if(this._aggregate=null,this._alias=null,this._attribute=null,this._column=null,this._entityname=null,this._operator=null,this._rowAggregate=null,this._uihidden=null,this._uiname=null,this._uitype=null,this._values=[],!(this instanceof t.FetchXml.condition))return new t.FetchXml.condition(e,i,r);if(!e||!i)throw new Error("Sdk.FetchXml.condition constructor parameters attribute and operator are required.");this.attribute=e,this.operator=i,r&&(this.values=r)}get aggregate(){return this._aggregate}set aggregate(t){this._aggregate=t}get alias(){return this._alias}set alias(t){this._alias=t}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get column(){return this._column}set column(t){this._column=t}get entityname(){return this._entityname}set entityname(t){this._entityname=t}get operator(){return this._operator}set operator(t){this._operator=t}get rowAggregate(){return this._rowAggregate}set rowAggregate(t){this._rowAggregate=t}get uihidden(){return this._uihidden}set uihidden(t){this._uihidden=t}get uiname(){return this._uiname}set uiname(t){this._uiname=t}get uitype(){return this._uitype}set uitype(t){this._uitype=t}get values(){return this._values}set values(e){if(!t.FetchXml.Util.isValueArrayOrNull(e))throw new Error("Sdk.FetchXml.condition.values must be an array of Sdk.FetchXml.value or null.");this._values=null==e?[]:e}get hash(){return this._attribute.concat(this._operator,this._aggregate?this._aggregate:"",this._alias?this._alias:"",this._column?this._column:"",this._entityname?this._entityname:"",this._rowAggregate?this._rowAggregate:"",t.FetchXml.Util.isNullOrUndefined(this._uihidden)?"":this._uihidden.toString(),this._uiname?this._uiname:"",this._uitype?this._uitype:"",t.FetchXml.Util.getCollectionHash(this._values)).hashCode()}setAttribute(t){return this.attribute=t,this}setOperator(t){return this.operator=t,this}setValues(t){return this.values=t,this}addValue(e){return t.FetchXml.Util.isValue(e)?this.values.push(e):this.values.push(new t.FetchXml.value(e)),this}removeValueByRef(e){if(!t.FetchXml.Util.isValue(e))throw new Error("Sdk.FetchXml.condition removeValueByRef method value parameter must be an Sdk.FetchXml.value.");return t.FetchXml.Util.removeCollectionValueByRef(this.values,e),this}removeValue(e){if(!t.FetchXml.Util.isValue(e))throw new Error("Sdk.FetchXml.condition removeValue method value parameter must be an Sdk.FetchXml.value.");return t.FetchXml.Util.removeCollectionValue(this.values,e),this}removeValueByValue(e){return t.FetchXml.Util.removeCollectionValueByProperty(this.values,"value",e),this}setAggregate(t){return this.aggregate=t,this}setAlias(t){return this.alias=t,this}setColumn(t){return this.column=t,this}setEntityname(t){return this.entityname=t,this}setRowAggregate(t){return this.rowAggregate=t,this}setUIhidden(t){return this.uihidden=t,this}setUIname(t){return this.uiname=t,this}setUItype(t){return this.uitype=t,this}toXml(e){var i=e.createElement("condition");switch(this.aggregate&&i.setAttribute("aggregate",this.aggregate),this.alias&&i.setAttribute("alias",this.alias),this.attribute&&i.setAttribute("attribute",this.attribute),this.column&&i.setAttribute("column",this.column),this.entityname&&i.setAttribute("entityname",this.entityname),this.operator&&i.setAttribute("operator",this.operator),this.rowAggregate&&i.setAttribute("rowAggregate",this.rowAggregate),t.FetchXml.Util.isBoolean(this.uihidden)&&i.setAttribute("uihidden",this.uihidden.toString()),this.uiname&&i.setAttribute("uiname",this.uiname),this.uitype&&i.setAttribute("uitype",this.uitype),this.operator){case"begins-with":case"ends-with":case"eq":case"ge":case"gt":case"last-x-days":case"last-x-fiscal-periods":case"last-x-fiscal-years":case"last-x-hours":case"last-x-months":case"last-x-weeks":case"last-x-years":case"last-year":case"le":case"like":case"lt":case"ne":case"neq":case"next-x-days":case"next-x-fiscal-periods":case"next-x-fiscal-years":case"next-x-hours":case"next-x-months":case"next-x-weeks":case"next-x-years":case"not-begin-with":case"not-end-with":case"not-like":case"olderthan-x-days":case"olderthan-x-hours":case"olderthan-x-minutes":case"olderthan-x-months":case"olderthan-x-weeks":case"olderthan-x-years":case"on":case"on-or-after":case"on-or-before":case"in-fiscal-period":case"in-fiscal-year":if(1!=this.values.length){var r=t.FetchXml.Util.getEnumNameFromValue(t.FetchXml.Operator,this.operator);throw new Error("Sdk.FetchXml.condition values property must contain single value when the Sdk.FetchXml.Operator."+r+" operator is used.")}i.setAttribute("value",this.values[0].value);break;case"between":case"in":case"not-between":case"not-in":case"in-fiscal-period-and-year":case"in-or-after-fiscal-period-and-year":case"in-or-before-fiscal-period-and-year":if(!(this.values.length>1)){r=t.FetchXml.Util.getEnumNameFromValue(t.FetchXml.Operator,this.operator);throw new Error("Sdk.FetchXml.condition values property must contain multiple values when the Sdk.FetchXml.Operator."+r+" operator is used.")}this.values.forEach((function(t){i.appendChild(t.toXml(e))}));break;case"above":case"eq-businessid":case"eq-or-above":case"eq-or-under":case"eq-userid":case"eq-userlanguage":case"eq-useroruserhierarchy":case"eq-useroruserhierarchyandteams":case"eq-useroruserteams":case"eq-userteams":case"last-fiscal-period":case"last-fiscal-year":case"last-month":case"last-seven-days":case"last-week":case"ne-businessid":case"ne-userid":case"next-fiscal-period":case"next-fiscal-year":case"next-month":case"next-seven-days":case"next-week":case"next-year":case"not-null":case"not-under":case"null":case"this-fiscal-period":case"this-fiscal-year":case"this-month":case"this-week":case"this-year":case"today":case"tomorrow":case"under":case"yesterday":if(this.values.length>0){r=t.FetchXml.Util.getEnumNameFromValue(t.FetchXml.Operator,this.operator);console.log("Sdk.FetchXml.condition doesn't require values when the Sdk.FetchXml.Operator.%s operator is used. The values passed were ignored.",r)}break;default:throw new Error(this.operator+" is an unexpected Sdk.FetchXml.Operator value.")}return i}static conditionFromXml(e){var i=e.attributes.getNamedItem("attribute").nodeValue,r=e.attributes.getNamedItem("operator").nodeValue,s=new t.FetchXml.condition(i,r);t.FetchXml.Util.parseAttributes(e,s,((t,e,i)=>{switch(e){case"column":case"entityname":case"aggregate":case"alias":case"uiname":case"uitype":t[e]=i;break;case"rowaggregate":t.rowAggregate=i;break;case"uihidden":t.uihidden=Util.convertFetchBoolType(i);break;case"value":t.addValue(i)}}));for(var n=0;n<e.childNodes.length;n++)"value"==e.childNodes[n].nodeName&&s.addValue(g.valueFromXml(e.childNodes[n]));return s}};o=p([F],o),e.condition=o;let u=class entity{constructor(e,i,r,s){if(this._allAttributes=null,this._attributes=[],this._orders=[],this._linkEntities=[],this._filters=[],!(this instanceof t.FetchXml.entity))return new t.FetchXml.entity(e,i,r,s);this.name=e,i&&(this.attributes=i),r&&(this.orders=r),s&&(this.filters=s)}get allAttributes(){return this._allAttributes}set allAttributes(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.entity.allAttributes must be a boolean value or null.");this._allAttributes=e}get attributes(){return this._attributes}set attributes(e){if(!t.FetchXml.Util.isAttributeArrayOrNull(e))throw new Error("Sdk.FetchXml.entity.attributes must be an array of Sdk.FetchXml.attribute or null.");this._attributes=null==e?[]:e}get orders(){return this._orders}set orders(e){if(!t.FetchXml.Util.isOrderArrayOrNull(e))throw new Error("Sdk.FetchXml.entity.orders must be an array of Sdk.FetchXml.order or null.");this._orders=null==e?[]:e}get linkEntities(){return this._linkEntities}set linkEntities(e){if(!t.FetchXml.Util.isLinkEntityArrayOrNull(e))throw new Error("Sdk.FetchXml.entity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");this._linkEntities=null==e?[]:e}get filters(){return this._filters}set filters(e){if(!t.FetchXml.Util.isFilterArrayOrNull(e))throw new Error("Sdk.FetchXml.entity.filters must be an array of Sdk.FetchXml.filter or null.");this._filters=null==e?[]:e}get name(){return this._name}set name(e){if(!t.FetchXml.Util.isString(e))throw new Error("Sdk.FetchXml.entity.name must be a string.");this._name=e}addAttribute(e){if(t.FetchXml.Util.isString(e)){var i=!1;return this.attributes.forEach((function(t){t.name==e&&(i=!0)})),i||this.attributes.push(new t.FetchXml.attribute(e)),this}if(!t.FetchXml.Util.isAttribute(e))throw new Error("Sdk.FetchXml.entity addAttribute method attributeOrAttributeName parameter must be an Sdk.FetchXml.attribute or a string value.");i=!1;return this.attributes.forEach((function(t){t.name==e.name&&(i=!0)})),i||this.attributes.push(e),this}removeAttributeByName(e){t.FetchXml.Util.removeCollectionValueByProperty(this.attributes,"name",e)}removeAttributeByRef(e){t.FetchXml.Util.removeCollectionValueByRef(this.attributes,e)}removeAttribute(e){t.FetchXml.Util.removeCollectionValue(this.attributes,e)}addOrder(e,i,r){if(t.FetchXml.Util.isOrder(e))return this.orders.push(e),this;if(!t.FetchXml.Util.isString(e))throw new Error("Sdk.FetchXml.entity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.");return this.orders.push(new t.FetchXml.order(e,i,r)),this}removeOrderByRef(e){if(!t.FetchXml.Util.isOrder(e))throw new Error("Sdk.FetchXml.entity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");return t.FetchXml.Util.removeCollectionValueByRef(this.orders,e),this}removeOrder(e){if(!t.FetchXml.Util.isOrder(e))throw new Error("Sdk.FetchXml.entity removeOrder method order parameter must be an Sdk.FetchXml.order.");return t.FetchXml.Util.removeCollectionValue(this.orders,e),this}setName(t){return this.name=t,this}setAllAttributes(e){if(t.FetchXml.Util.isBoolean(e))this.allAttributes=e;else{if(!t.FetchXml.Util.isNullOrUndefined(e))throw new Error("Sdk.FetchXml.entity setAllAttributes method allAttributes parameter must be a boolean value or null.");this.allAttributes=!0}return this}addLinkEntity(e){if(t.FetchXml.Util.isLinkEntity(e))return this.linkEntities.push(e),this;throw new Error("Sdk.FetchXml.entity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.")}removeLinkEntityByRef(e){if(!t.FetchXml.Util.isLinkEntity(e))throw new Error("Sdk.FetchXml.entity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");return t.FetchXml.Util.removeCollectionValueByRef(this.linkEntities,e),this}removeLinkEntity(e){if(!t.FetchXml.Util.isLinkEntity(e))throw new Error("Sdk.FetchXml.entity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");return t.FetchXml.Util.removeCollectionValue(this.linkEntities,e),this}addFilter(e){if(t.FetchXml.Util.isFilter(e))return this.filters.push(e),this;throw new Error("Sdk.FetchXml.entity addFilter method filter parameter must be a Sdk.FetchXml.filter value.")}removeFilterByRef(e){if(!t.FetchXml.Util.isFilter(e))throw new Error("Sdk.FetchXml.entity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");return t.FetchXml.Util.removeCollectionValueByRef(this.filters,e),this}removeFilter(e){if(!t.FetchXml.Util.isFilter(e))throw new Error("Sdk.FetchXml.entity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");return t.FetchXml.Util.removeCollectionValue(this.filters,e),this}toXml(t){var e=t.createElement("entity");return this.allAttributes?e.appendChild(t.createElement("all-attributes")):this.attributes.forEach((function(i,r){e.appendChild(i.toXml(t))})),this.orders.forEach((function(i,r){e.appendChild(i.toXml(t))})),this.linkEntities.forEach((function(i,r){e.appendChild(i.toXml(t))})),this.filters.forEach((function(i,r){e.appendChild(i.toXml(t))})),e.setAttribute("name",this.name),e}static entityFromXml(e){var i=new t.FetchXml.entity(e.attributes.getNamedItem("name").nodeValue);i.allAttributes=1==e.getElementsByTagName("all-attributes").length;for(var r=0;r<e.childNodes.length;r++)"attribute"==e.childNodes[r].nodeName&&i.addAttribute(a.attributeFromXml(e.childNodes[r])),"order"==e.childNodes[r].nodeName&&i.addOrder(m.orderFromXml(e.childNodes[r])),"link-entity"==e.childNodes[r].nodeName&&i.addLinkEntity(d.linkEntityFromXml(e.childNodes[r])),"filter"==e.childNodes[r].nodeName&&i.addFilter(c.filterFromXml(e.childNodes[r]));return i}};u=p([F],u),e.entity=u;let h=class fetch{constructor(e){if(this._aggregate=null,this._count=null,this._distinct=null,this._mapping=null,this._minActiveRowVersion=null,this._noLock=null,this._order=null,this._outputFormat=null,this._page=null,this._pagingCookie=null,this._returnTotalRecordCount=null,this._top=null,this._utcOffset=null,this._version=null,!(this instanceof t.FetchXml.fetch))return new t.FetchXml.fetch(e);e&&(this.entity=e)}get aggregate(){return this._aggregate}set aggregate(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.fetch.aggregate must be a boolean value or null.");this._aggregate=e}get count(){return this._count}set count(e){if(!t.FetchXml.Util.isNumberOrNull(e))throw new Error("Sdk.FetchXml.fetch.count must be a number value or null.");this._count=e}get distinct(){return this._distinct}set distinct(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.fetch.distinct must be a boolean value or null.");this._distinct=e}get entity(){return this._entity}set entity(e){if(!t.FetchXml.Util.isEntity(e))throw new Error("Sdk.FetchXml.fetch.entity must be a Sdk.FetchXml.entity value.");this._entity=e}get mapping(){return this._mapping}set mapping(e){if(!t.FetchXml.Util.isEnumMemberOrNull(t.FetchXml.Mapping,e))throw new Error("Sdk.FetchXml.fetch.mapping must be a Sdk.FetchXml.Mapping value or null.");this._mapping=e}get minActiveRowVersion(){return this._minActiveRowVersion}set minActiveRowVersion(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.fetch.minActiveRowVersion must be a boolean value or null.");this._minActiveRowVersion=e}get noLock(){return this._noLock}set noLock(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.fetch.noLock must be a boolean value or null.");this._noLock=e}get order(){return this._order}set order(e){if(!t.FetchXml.Util.isOrderOrNull(e))throw new Error("Sdk.FetchXml.fetch.order must be a Sdk.FetchXml.order value or null.");this._order=e}get outputFormat(){return this._outputFormat}set outputFormat(e){if(!t.FetchXml.Util.isEnumMemberOrNull(t.FetchXml.OutputFormat,e))throw new Error("Sdk.FetchXml.fetch.outputFormat must be a Sdk.FetchXml.OutputFormat value or null.");this._outputFormat=e}get page(){return this._page}set page(e){if(!t.FetchXml.Util.isNumberOrNull(e))throw new Error("Sdk.FetchXml.fetch.page must be a number value or null.");this._page=e}get pagingCookie(){return this._pagingCookie}set pagingCookie(e){if(!t.FetchXml.Util.isStringOrNull(e))throw new Error("Sdk.FetchXml.fetch.pagingCookie must be a string value or null.");this._pagingCookie=e}get returnTotalRecordCount(){return this._returnTotalRecordCount}set returnTotalRecordCount(e){if(!t.FetchXml.Util.isBooleanOrNull(e))throw new Error("Sdk.FetchXml.fetch.returnTotalRecordCount must be a boolean value or null.");this._returnTotalRecordCount=e}get top(){return this._top}set top(e){if(!t.FetchXml.Util.isNumberOrNull(e))throw new Error("Sdk.FetchXml.fetch.top must be a number value or null.");this._top=e}get utcOffset(){return this._utcOffset}set utcOffset(e){if(!t.FetchXml.Util.isNumberOrNull(e))throw new Error("Sdk.FetchXml.fetch.utcOffset must be a number value or null.");this._utcOffset=e}get version(){return this._version}set version(e){if(!t.FetchXml.Util.isStringOrNull(e))throw new Error("Sdk.FetchXml.fetch.version must be a string value or null.");this._version=e}setAggregate(t){return this.aggregate=t||null,this}setCount(t){return this.count=t||null,this}setDistinct(t){return this.distinct=t||null,this}setEntity(t){return this.entity=t,this}setMapping(t){return this.mapping=t||null,this}setMinActiveRowVersion(t){return this.minActiveRowVersion=t||null,this}setNoLock(t=null){return this.noLock=t,this}setOrder(t=null){return this.order=t,this}setOutputFormat(t){return this.outputFormat=t||null,this}setPage(t){return this.page=t||null,this}setPagingCookie(t=null){return this.pagingCookie=t,this}setReturnTotalRecordCount(t){return this.returnTotalRecordCount=t||null,this}setTop(t){return this.top=t||null,this}setUtcOffset(t){return this.utcOffset=t||null,this}setVersion(t){return this.version=t||null,this}toXml(){var t=(new DOMParser).parseFromString("<fetch />","text/xml");return this.version&&t.documentElement.setAttribute("version",this.version),this.outputFormat&&t.documentElement.setAttribute("output-format",this.outputFormat),this.mapping&&t.documentElement.setAttribute("mapping",this.mapping),this.aggregate&&t.documentElement.setAttribute("aggregate",this.aggregate?"true":"false"),this.count&&t.documentElement.setAttribute("count",this.count.toString()),this.distinct&&t.documentElement.setAttribute("distinct",this.distinct?"true":"false"),this.entity&&t.documentElement.appendChild(this.entity.toXml(t)),this.minActiveRowVersion&&t.documentElement.setAttribute("min-active-row-version",this.minActiveRowVersion?"true":"false"),this.noLock&&t.documentElement.setAttribute("no-lock",this.noLock?"true":"false"),this.order&&t.documentElement.appendChild(this.order.toXml(t)),this.page&&t.documentElement.setAttribute("page",this.page.toString()),this.pagingCookie&&t.documentElement.setAttribute("paging-cookie",this.pagingCookie),this.returnTotalRecordCount&&t.documentElement.setAttribute("returntotalrecordcount",this.returnTotalRecordCount?"true":"false"),this.top&&t.documentElement.setAttribute("top",this.top.toString()),this.utcOffset&&t.documentElement.setAttribute("utc-offset",this.utcOffset.toString()),(new XMLSerializer).serializeToString(t)}static fromXml(e){var i=(new DOMParser).parseFromString(e,"text/xml"),r=new t.FetchXml.fetch;if("fetch"!=i.documentElement.localName)throw new Error("The XML string is not a valid fetchXML document");t.FetchXml.Util.parseAttributes(i.documentElement,r,((t,e,i)=>{switch(e){case"count":case"top":case"page":t[e]=parseInt(i,10);break;case"utc-offset":isNaN(i)?t.utcOffset=null:t.utcOffset=parseInt(i,10);break;case"paging-cookie":t.pagingCookie=i;break;case"min-active-row-version":t.minActiveRowVersion="true"==i;break;case"output-format":t.outputFormat=i;break;case"returntotalrecordcount":t.returnTotalRecordCount="true"==i;break;case"no-lock":t.noLock="true"==i;break;case"aggregate":case"distinct":t[e]="true"==i;break;default:t[e]=i}}));for(var s=0;s<i.documentElement.childNodes.length;s++)"entity"==i.documentElement.childNodes[s].nodeName&&(r.entity=t.FetchXml.entity.entityFromXml(i.documentElement.childNodes[s])),"order"==i.documentElement.childNodes[s].nodeName&&(r.order=t.FetchXml.order.orderFromXml(i.documentElement.childNodes[s]));return r}};h=p([F],h),e.fetch=h;let c=r=class filter{constructor(t,e,i){if(this._conditions=[],this._filters=[],this._type=null,this._isQuickFindFields=null,!(this instanceof r))return new r(t,e,i);t&&(this.type=t),e&&(this.conditions=e),i&&(this.filters=i)}get conditions(){return this._conditions}set conditions(t){if(!Util.isFilterArrayOrNull(t))throw new Error("Sdk.FetchXml.filter.conditions must be an array of Sdk.FetchXml.condition or null.");this._conditions=null==t?[]:t}get filters(){return this._filters}set filters(t){if(!Util.isFilterArrayOrNull(t))throw new Error("Sdk.FetchXml.filter.filters must be an array of Sdk.FetchXml.filter or null.");this._filters=null==t?[]:t}get type(){return this._type}set type(t){this._type=t}get isQuickFindFields(){return this._isQuickFindFields}set isQuickFindFields(t){this._isQuickFindFields=t}addCondition(t,e,i){return Util.isCondition(t)?this.conditions.push(t):this.conditions.push(new o(t,e,i)),this}removeConditionByRef(t){if(!Util.isCondition(t))throw new Error("Sdk.FetchXml.filter removeConditionByRef method condition parameter must be an Sdk.FetchXml.condition.");return Util.removeCollectionValueByRef(this.conditions,t),this}removeCondition(t){if(!Util.isCondition(t))throw new Error("Sdk.FetchXml.filter removeCondition method condition parameter must be an Sdk.FetchXml.condition.");return Util.removeCollectionValue(this.conditions,t),this}addFilter(t){if(!Util.isFilter(t))throw new Error("Sdk.FetchXml.filter addFilter method filter parameter must be a Sdk.FetchXml.filter value.");return this.filters.push(t),this}removeFilterByRef(t){if(!Util.isFilter(t))throw new Error("Sdk.FetchXml.filter removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");return Util.removeCollectionValueByRef(this.filters,t),this}removeFilter(t){if(!Util.isFilter(t))throw new Error("Sdk.FetchXml.filter removeFilter method filter parameter must be an Sdk.FetchXml.filter.");return Util.removeCollectionValue(this.filters,t),this}setIsQuickFindFields(t){return this.isQuickFindFields=t,this}setType(t){return this.type=t,this}toXml(t){var e=t.createElement("filter");return this.type&&e.setAttribute("type",this.type),Util.isBoolean(this.isQuickFindFields)&&e.setAttribute("isquickfindfields",this.isQuickFindFields.toString()),this.conditions.forEach((function(i){e.appendChild(i.toXml(t))})),this.filters.forEach((function(i){e.appendChild(i.toXml(t))})),e}static filterFromXml(t){var e=new r;Util.parseAttributes(t,e,((t,e,i)=>{switch(e){case"type":t.type=i;break;case"isquickfindfields":t.isQuickFindFields="true"==i||"1"==i}}));for(var i=0;i<t.childNodes.length;i++)"condition"==t.childNodes[i].nodeName&&e.addCondition(o.conditionFromXml(t.childNodes[i])),"filter"==t.childNodes[i].nodeName&&e.addFilter(r.filterFromXml(t.childNodes[i]));return e}};c=r=p([F],c),e.filter=c;let d=s=class linkEntity{constructor(t,e,i,r,n){if(this._name=null,this._alias=null,this._from=null,this._intersect=null,this._linktype=null,this._to=null,this._visible=null,this._allAttributes=null,this._attributes=[],this._orders=[],this._linkEntities=[],this._filters=[],!(this instanceof s))return new s(t,e,i,r,n);this.name=t,e&&(this.from=e),i&&(this.to=i),r&&(this.linktype=r),n&&(this.alias=n)}get name(){return this._name}set name(t){this._name=t}get alias(){return this._alias}set alias(t){this._alias=t}get from(){return this._from}set from(t){this._from=t}get intersect(){return this._intersect}set intersect(t){this._intersect=t}get linktype(){return this._linktype}set linktype(t){this._linktype=t}get to(){return this._to}set to(t){this._to=t}get visible(){return this._visible}set visible(t){this._visible=t}get allAttributes(){return this._allAttributes}set allAttributes(t){this._allAttributes=t}get attributes(){return this._attributes}set attributes(t){if(!Util.isAttributeArrayOrNull(t))throw new Error("Sdk.FetchXml.linkEntity.attributes must be an array of Sdk.FetchXml.attribute or null.");this._attributes=null==t?[]:t}get orders(){return this._orders}set orders(t){if(!Util.isOrderArrayOrNull(t))throw new Error("Sdk.FetchXml.linkEntity.orders must be an array of Sdk.FetchXml.order or null.");this._orders=null==t?[]:t}get linkEntities(){return this._linkEntities}set linkEntities(t){if(!Util.isLinkEntityArrayOrNull(t))throw new Error("Sdk.FetchXml.linkEntity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");this._linkEntities=null==t?[]:t}get filters(){return this._filters}set filters(t){if(!Util.isFilterArrayOrNull(t))throw new Error("Sdk.FetchXml.linkEntity.filters must be an array of Sdk.FetchXml.filter or null.");this._filters=null==t?[]:t}get hash(){return this._name.concat(this._alias?this._alias:"",this._from?this._from:"",Util.isNullOrUndefined(this._intersect)?"":this._intersect.toString(),this._linktype?this._linktype:"",this._to?this._to:"",Util.isNullOrUndefined(this._visible)?"":this._visible.toString(),Util.isNullOrUndefined(this._allAttributes)?"":this._allAttributes.toString(),Util.getCollectionHash(this._attributes),Util.getCollectionHash(this._orders),Util.getCollectionHash(this._linkEntities),Util.getCollectionHash(this._filters)).hashCode()}setAlias(t){return this.alias=t,this}setFrom(t){return this.from=t,this}setIntersect(t){return this.intersect=t,this}setName(t){return this.name=t,this}setTo(t){return this.to=t,this}setVisible(t){return this.visible=t,this}setAllAttributes(t){return this.allAttributes=t,this}addLinkEntity(t){if(Util.isLinkEntity(t))return this.linkEntities.push(t),this;throw new Error("Sdk.FetchXml.linkEntity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.")}removeLinkEntityByRef(t){if(!Util.isLinkEntity(t))throw new Error("Sdk.FetchXml.linkEntity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");return Util.removeCollectionValueByRef(this.linkEntities,t),this}removeLinkEntity(t){if(!Util.isLinkEntity(t))throw new Error("Sdk.FetchXml.linkEntity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");return Util.removeCollectionValue(this.linkEntities,t),this}addAttribute(t){if(Util.isAttribute(t))return this.attributes.push(t),this;if(Util.isString(t))return this.attributes.push(new t(t)),this;throw new Error("Sdk.FetchXml.linkEntity addAttribute method attribute parameter must be a Sdk.FetchXml.attribute value or a string.")}removeAttributeByRef(t){if(!Util.isAttribute(t))throw new Error("Sdk.FetchXml.linkEntity removeAttributeByRef method attribute parameter must be an Sdk.FetchXml.attribute.");return Util.removeCollectionValueByRef(this.attributes,t),this}removeAttribute(t){if(!Util.isAttribute(t))throw new Error("Sdk.FetchXml.linkEntity removeAttribute method attribute parameter must be an Sdk.FetchXml.attribute.");return Util.removeCollectionValue(this.attributes,t),this}removeAttributeByName(t){if(!Util.isString(t))throw new Error("Sdk.FetchXml.linkEntity removeAttributeByName method attributeName parameter must be a string.");return Util.removeCollectionValueByProperty(this.attributes,"name",t),this}addOrder(t,e,i){if(Util.isOrder(t))return this.orders.push(t),this;if(Util.isString(t))return this.orders.push(new m(t,e,i)),this;throw new Error("Sdk.FetchXml.linkEntity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.")}removeOrderByRef(t){if(!Util.isOrder(t))throw new Error("Sdk.FetchXml.linkEntity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");return Util.removeCollectionValueByRef(this.orders,t),this}removeOrder(t){if(!Util.isOrder(t))throw new Error("Sdk.FetchXml.linkEntity removeOrder method order parameter must be an Sdk.FetchXml.order.");return Util.removeCollectionValue(this.orders,t),this}addFilter(t){if(Util.isFilter(t))return this.filters.push(t),this;throw new Error("Sdk.FetchXml.linkEntity addFilter method filter parameter must be a Sdk.FetchXml.filter value.")}removeFilterByRef(t){if(!Util.isFilter(t))throw new Error("Sdk.FetchXml.linkEntity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");return Util.removeCollectionValueByRef(this.filters,t),this}removeFilter(t){if(!Util.isFilter(t))throw new Error("Sdk.FetchXml.linkEntity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");return Util.removeCollectionValue(this.filters,t),this}toXml(t){var e=t.createElement("link-entity");return this.alias&&e.setAttribute("alias",this.alias),this.allAttributes&&e.appendChild(t.createElement("all-attributes")),this.from&&e.setAttribute("from",this.from),Util.isBoolean(this.intersect)&&e.setAttribute("intersect",this.intersect.toString()),this.linktype&&e.setAttribute("link-type",this.linktype),this.name&&e.setAttribute("name",this.name),this.to&&e.setAttribute("to",this.to),Util.isBoolean(this.visible)&&e.setAttribute("visible",this.visible.toString()),this.attributes.forEach((function(i){e.appendChild(i.toXml(t))})),this.orders.forEach((function(i){e.appendChild(i.toXml(t))})),this.linkEntities.forEach((function(i){e.appendChild(i.toXml(t))})),this.filters.forEach((function(i){e.appendChild(i.toXml(t))})),e}static linkEntityFromXml(t){var e=t.attributes.getNamedItem("name").nodeValue,i=new s(e);i.allAttributes=1==t.getElementsByTagName("all-attributes").length,Util.parseAttributes(t,i,((t,e,i)=>{switch(e){case"to":case"from":case"alias":t[e]=i;break;case"link-type":t.linktype=i;break;case"visible":case"intersect":t[e]="true"==i}}));for(var r=0;r<t.childNodes.length;r++)"attribute"==t.childNodes[r].nodeName&&i.addAttribute(a.attributeFromXml(t.childNodes[r])),"order"==t.childNodes[r].nodeName&&i.addOrder(m.orderFromXml(t.childNodes[r])),"filter"==t.childNodes[r].nodeName&&i.addFilter(c.filterFromXml(t.childNodes[r])),"link-entity"==t.childNodes[r].nodeName&&i.addLinkEntity(s.linkEntityFromXml(t.childNodes[r]));return i}};d=s=p([F],d),e.linkEntity=d;let m=n=class order{constructor(t,e,i){if(this._attribute=null,this._descending=null,this._alias=null,!(this instanceof n))return new n(t,e,i);t&&(this.attribute=t),e&&(this.descending=e),i&&(this.alias=i)}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get descending(){return this._descending}set descending(t){this._descending=t}get alias(){return this._alias}set alias(t){this._alias=t}get hash(){return"".concat(this._attribute?this._attribute:"",this._alias?this._alias:"",this._descending.toString()).hashCode()}setAttribute(t){return this.attribute=t,this}setAlias(t){return this.alias=t,this}setDescending(t){return this.descending=t,this}toXml(t){var e=t.createElement("order");return this.attribute&&e.setAttribute("attribute",this.attribute),this.alias&&e.setAttribute("alias",this.alias),Util.isNullOrUndefined(this.descending)||e.setAttribute("descending",this.descending.toString()),e}static orderFromXml(t){var e=new n;return Util.parseAttributes(t,e,((t,e,i)=>{switch(e){case"attribute":t.attribute=i;break;case"alias":t.alias=i;break;case"descending":t.descending="true"==i}})),e}};m=n=p([F],m),e.order=m;let g=l=class value{constructor(e,i,r){if(this._value=null,this._uiname=null,this._uitype=null,!(this instanceof t.FetchXml.value))return new e(e,i,r);e&&(this.value=e),i&&(this.uiname=i),r&&(this.uitype=r)}get value(){return this._value}set value(t){this._value=t}get uiname(){return this._uiname}set uiname(t){this._uiname=t}get uitype(){return this._uitype}set uitype(t){this._uitype=t}setValue(t){return this.value=t,this}setUIname(t){return this.uiname=t,this}setUItype(t){return this.uitype=t,this}toXml(t){var e=t.createElement("value");return this.uitype&&e.setAttribute("uitype",this.uitype),this.uiname&&e.setAttribute("uiname",this.uiname),e.appendChild(t.createTextNode(this.value)),e}static valueFromXml(t){var e=new l(t.textContent);return Util.parseAttributes(t,e,((t,e,i)=>{switch(e){case"uiname":case"uitype":t[e]=i}})),e}};g=l=p([F],g),e.value=g;class Util{static isBoolean(t){return"boolean"==typeof t}static isBooleanOrNull(t){return Util.isNull(t)||Util.isBoolean(t)}static isNumber(t){return"number"==typeof t}static isNumberOrNull(t){return Util.isNull(t)||Util.isNumber(t)}static isNull(t){return null===t}static isNullOrUndefined(t){return null==t}static isEnumMember(t,e){for(var i in t)if(e===t[i])return!0;return!1}static isEnumMemberOrNull(t,e){return Util.isNull(e)||Util.isEnumMember(t,e)}static isString(t){return"string"==typeof t}static isStringOrNull(t){return Util.isNull(t)||Util.isString(t)}static isOrder(t){return t instanceof m}static isOrderOrNull(t){return Util.isNull(t)||Util.isOrder(t)}static isOrderArray(t){return!!Array.isArray(t)&&(t.forEach((function(t){if(!Util.isOrder(t))return!1})),!0)}static isOrderArrayOrNull(t){return Util.isNull(t)||Util.isOrderArray(t)}static isEntity(t){return t instanceof u}static isAttribute(t){return t instanceof a}static isAttributeArray(t){return!!Array.isArray(t)&&(t.forEach((function(t){if(!Util.isAttribute(t))return!1})),!0)}static isAttributeArrayOrNull(t){return Util.isNull(t)||Util.isAttributeArray(t)}static isLinkEntity(t){return t instanceof d}static isLinkEntityOrNull(t){return Util.isNull(t)||Util.isLinkEntity(t)}static isLinkEntityArray(t){return!!Array.isArray(t)&&(t.forEach((function(t){if(!Util.isLinkEntity(t))return!1})),!0)}static isLinkEntityArrayOrNull(t){return Util.isNull(t)||Util.isLinkEntityArray(t)}static isFilter(t){return t instanceof c}static isFilterOrNull(t){return Util.isNull(t)||Util.isFilter(t)}static isFilterArray(t){return!!Array.isArray(t)&&(t.forEach((function(t){if(!Util.isFilter(t))return!1})),!0)}static isFilterArrayOrNull(t){return Util.isNull(t)||Util.isFilterArray(t)}static isCondition(t){return t instanceof o}static isConditionOrNull(t){return Util.isNull(t)||Util.isCondition(t)}static isConditionArray(t){return!!Array.isArray(t)&&(t.forEach((function(t){if(!Util.isCondition(t))return!1})),!0)}static isConditionArrayOrNull(t){return Util.isNull(t)||Util.isConditionArray(t)}static isValue(t){return t instanceof g}static isValueOrNull(t){return Util.isNull(t)||Util.isValue(t)}static isValueArray(t){if(Array.isArray(t)){var e=!0;return t.forEach((function(t){Util.isValue(t)||(e=!1)})),e}return!1}static isValueArrayOrNull(t){return Util.isNull(t)||Util.isValueArray(t)}static getEnumNameFromValue(t,e){for(var i in t)if(t[i]==e)return i}static getCollectionHash(t){var e=[];return t.forEach((function(t){e.push(t.hash)})),e.join()}static removeCollectionValue(t,e){Util.removeCollectionValueByProperty(t,"hash",e)}static removeCollectionValueByProperty(t,e,i){var r=[];t.forEach((function(t,s){t[e]==i[e]&&r.push(t)})),r.forEach((function(e){Util.removeCollectionValueByRef(t,e)}))}static removeCollectionValueByRef(t,e){var i=[];if(t.forEach((function(t,r){t===e&&i.push(r)})),i.length>0)for(var r=i.length-1;r>=0;r--)t.splice(i[r],1)}static convertFetchBoolType(t){switch(t){case"true":case"1":return!0;case"false":case"0":return!1;default:throw new Error("Unexpected FetchBoolType value")}}static parseAttributes(t,e,i){for(var r=t.attributes,s=0;s<r.length;s++){i(e,r[s].nodeName,r[s].nodeValue)}}}e.Util=Util;let f=class Mapping{};f.Internal="internal",f.Logical="logical",f=p([X],f),e.Mapping=f;let y=class OutputFormat{};y.Ado="xml-ado",y.Auto="xml-auto",y.Elements="xml-elements",y.Raw="xml-raw",y.Platform="xml-platform",y=p([X],y),e.OutputFormat=y;let b=class Build{};b.OnePoint504021="1.504021",b.OnePoint003017="1.003017",b=p([X],b),e.Build=b;let v=class Aggregate{};v.Count="count",v.CountColumn="countcolumn",v.Sum="sum",v.Avg="avg",v.Min="min",v.Max="max",v=p([X],v),e.Aggregate=v;let k=class RowAggregate{};k.Countchildren="countchildren",k=p([X],k),e.RowAggregate=k;let w=class DateGrouping{};w.Day="day",w.Week="week",w.Month="month",w.Quarter="quarter",w.Year="year",w.FiscalPeriod="fiscal-period",w.FiscalYear="fiscal-year",w=p([X],w),e.DateGrouping=w;let E=class Operator{};E.Above="above",E.BeginsWith="begins-with",E.Between="between",E.EndsWith="ends-with",E.Equal="eq",E.EqualBusinessId="eq-businessid",E.EqualOrAbove="eq-or-above",E.EqualOrUnder="eq-or-under",E.EqualUserId="eq-userid",E.EqualUserLanguage="eq-userlanguage",E.EqualUserOrUserHierarchy="eq-useroruserhierarchy",E.EqualUserOrUserHierarchyAndTeams="eq-useroruserhierarchyandteams",E.EqualUserOrUserTeams="eq-useroruserteams",E.EqualUserTeams="eq-userteams",E.GreaterOrEqual="ge",E.GreaterThan="gt",E.In="in",E.InFiscalPeriod="in-fiscal-period",E.InFiscalPeriodAndYear="in-fiscal-period-and-year",E.InFiscalYear="in-fiscal-year",E.InOrAfterFiscalPeriodAndYear="in-or-after-fiscal-period-and-year",E.InOrBeforeFiscalPeriodAndYear="in-or-before-fiscal-period-and-year",E.LastFiscalPeriod="last-fiscal-period",E.LastFiscalYear="last-fiscal-year",E.LastMonth="last-month",E.LastSevenDays="last-seven-days",E.LastWeek="last-week",E.LastXDays="last-x-days",E.LastXFiscalPeriods="last-x-fiscal-periods",E.LastXFiscalYears="last-x-fiscal-years",E.LastXHours="last-x-hours",E.LastXMonths="last-x-months",E.LastXWeeks="last-x-weeks",E.LastXYears="last-x-years",E.LastYear="last-year",E.LessOrEqual="le",E.Like="like",E.LessThan="lt",E.NotEqual="ne",E.NotEqualBusinessId="ne-businessid",E.NotEqualUserId="ne-userid",E.Neq="neq",E.NextFiscalPeriod="next-fiscal-period",E.NextFiscalYear="next-fiscal-year",E.NextMonth="next-month",E.NextSevenDays="next-seven-days",E.NextWeek="next-week",E.NextXDays="next-x-days",E.NextXFiscalPeriods="next-x-fiscal-periods",E.NextXFiscalYears="next-x-fiscal-years",E.NextXHours="next-x-hours",E.NextXMonths="next-x-months",E.NextXWeeks="next-x-weeks",E.NextXYears="next-x-years",E.NextYear="next-year",E.NotBeginWith="not-begin-with",E.NotBetween="not-between",E.NotEndWith="not-end-with",E.NotIn="not-in",E.NotLike="not-like",E.NotNull="not-null",E.NotUnder="not-under",E.Null="null",E.OlderThanXDays="olderthan-x-days",E.OlderThanXHours="olderthan-x-hours",E.OlderThanXMinutes="olderthan-x-minutes",E.OlderThanXMonths="olderthan-x-months",E.OlderThanXWeeks="olderthan-x-weeks",E.OlderThanXYears="olderthan-x-years",E.On="on",E.OnOrAfter="on-or-after",E.OnOrBefore="on-or-before",E.ThisFiscalPeriod="this-fiscal-period",E.ThisFiscalYear="this-fiscal-year",E.ThisMonth="this-month",E.ThisWeek="this-week",E.ThisYear="this-year",E.Today="today",E.Tomorrow="tomorrow",E.Under="under",E.Yesterday="yesterday",E=p([X],E),e.Operator=E;let _=class FilterType{};_.And="and",_.Or="or",_=p([X],_),e.FilterType=_}(t.FetchXml||(t.FetchXml={}))}(k||(k={})),String.prototype.hashCode=function(){let t=0;if(0==this.length)return t.toString();for(let e=0;e<this.length;e++){t=(t<<5)-t+this.charCodeAt(e),t&=t}return t.toString()};const w=t=>{const e=t.parameters.value.attributes.Targets,i=t.parameters.value.raw,n=t.context,{labels:a,onNotifyOutputChanged:o}=l("Lookup",t,v),[u,h]=(t=>{const e=r({});return[i=>b(void 0,void 0,void 0,(function*(){return e.current[i]||(e.current[i]=t.webAPI.retrieveRecord("savedquery",i,"?$select=fetchxml")),(yield e.current[i]).fetchxml})),(t,e,i)=>b(void 0,void 0,void 0,(function*(){if(!i)return e;const r=yield t.metadata,s=k.FetchXml.fetch.fromXml(e);return s.entity.addFilter(new k.FetchXml.filter(k.FetchXml.FilterType.Or,[new k.FetchXml.condition(r.PrimaryNameAttribute,k.FetchXml.Operator.Like,[new k.FetchXml.value(`%${i}%`)])])),s.toXml()}))]})(n),[c,d]=s((()=>e.map((i=>({entityName:i,selected:1===e.length,metadata:t.context.utils.getEntityMetadata(i,[])}))))),m=c.find((t=>t.selected)),g=(e,i)=>b(void 0,void 0,void 0,(function*(){const r=(yield t.parameters.value.getAllViews(e)).find((t=>t.isDefault));if(!(null==r?void 0:r.viewId))throw new Error(`Entity ${e} does not have a default view id!`);let s=null==r?void 0:r.fetchXml;return s||(s=yield u(r.viewId)),h(c.find((t=>t.entityName===e)),s,i)}));return[i,c,a,{create:t=>b(void 0,void 0,void 0,(function*(){const e=yield n.navigation.openForm({entityName:t,useQuickCreateForm:!0});e.savedEntityReference&&o({value:e.savedEntityReference})})),deselect:t=>{const e=new Map(i.map((t=>[t.id,t])));e.delete(t.id),o({value:[...e.values()]})},select:t=>{o({value:t})}},t=>{d([...c].map((e=>({entityName:e.entityName,metadata:e.metadata,selected:e.entityName===t}))))},i=>b(void 0,void 0,void 0,(function*(){if(t.onSearch)return t.onSearch(m?[null==m?void 0:m.entityName]:e,i);const r=new Map;if(m)r.set(m.entityName,g(m.entityName,i));else for(const t of e)r.set(t,g(t,i));yield Promise.all(r.values());const s=new Map;for(const[t,e]of r)s.set(t,n.webAPI.retrieveMultipleRecords(t,`?$top=25&fetchXml=${encodeURIComponent(yield e)}`));yield Promise.all(s.values());const l=[];for(const[t,e]of s)for(const i of(yield e).entities){const e=yield c.find((e=>e.entityName===t)).metadata;l.push({entityType:t,id:i[e.PrimaryIdAttribute],name:i[e.PrimaryNameAttribute]})}return l}))]},E=(t,e,i)=>{const r=(t=>{if(-1!==t&&0!==t)return t})(i);return a({root:{'[class*="TALXIS__tag-picker__search-btn"][class*="TALXIS__tag-picker__search-btn"]':{top:0,bottom:0,margin:"auto 0",right:5},'[data-navigation-enabled="true"]':{"> span > div > span":{color:t.semanticColors.link,cursor:"pointer"},":hover":{textDecoration:"underline",cursor:"pointer !important"}},".ms-BasePicker-itemsWrapper .ms-CommandBar":{height:r&&e?r-6:void 0},".ms-BasePicker-text":{minHeight:null!=r?r:36,height:"min-content",paddingRight:e?void 0:36,alignItems:"baseline",input:{alignSelf:"center"},".hover-only":{animationName:"none"},"::after":{inset:"0px !important"}}},suggestions:{".ms-Suggestions-title":{padding:0,display:"flex",flexDirection:"column"}},createRecordBtn:{height:38,width:"100%",".ms-Button-menuIcon":{display:"none"},">.ms-Button-flexContainer.ms-Button-flexContainer":{justifyContent:"flex-start"},".ms-Button-textContainer":{flexGrow:"initial",">span":{fontWeight:600}}}})},_=t=>{const[e,i]=s(null);return n((()=>{b(void 0,void 0,void 0,(function*(){i(yield Promise.all(t.map((t=>b(void 0,void 0,void 0,(function*(){return{entityName:t.entityName,selected:t.selected,metadata:yield t.metadata}}))))))}))}),[t]),[e]},N=r=>{const{labels:s,entities:n,onEntitySelected:l}=Object.assign({},r),[h]=_(n),c=(t=>a({targetSelector:{display:"flex",paddingLeft:8,paddingRight:8,paddingBottom:8,gap:8,paddingTop:8,">span":{lineHeight:15,minWidth:"fit-content",color:t.semanticColors.listText,fontWeight:600}},targetSelectorLinks:{display:"flex",gap:5,flexWrap:"wrap"},targetSelectorLink:{color:t.palette.blackTranslucent40,'&[data-selected="true"]':{color:t.semanticColors.link,fontWeight:600}}}))(o());return t("div",Object.assign({className:c.targetSelector},{children:[t(d,Object.assign({variant:"small"},{children:[s.resultsFrom()," "]})),t("div",Object.assign({className:c.targetSelectorLinks},{children:[e(u,Object.assign({onClick:()=>l(null),className:c.targetSelectorLink,"data-selected":!n.find((t=>t.selected))},{children:"All"})),h&&e(i,{children:h.map((t=>e(u,Object.assign({className:c.targetSelectorLink,"data-selected":t.selected,onClick:()=>l(t.entityName)},{children:t.metadata.DisplayName}))))})]}))]}))},A=t=>{const{labels:i,entities:r,onCreateRecord:s}=Object.assign({},t),[n]=_(r),l=o(),a=E(l,0),u=r.find((t=>t.selected));return e(g,{className:a.createRecordBtn,iconProps:{iconName:"Add"},onClick:u?()=>s(u.entityName):void 0,menuProps:u?void 0:{calloutProps:{coverTarget:!1},isBeakVisible:!0,items:n?[{key:"header",itemType:h.Header,text:"Vyberte tabulku"},...n.map((t=>({key:t.entityName,text:t.metadata.DisplayName,onClick:()=>s(t.entityName)})))]:[]},text:i.newRecord()})},U=s=>{var l,a;const u=s.context,h=r(null),d=r(null),g=!0===(null===(l=s.parameters.MultipleEnabled)||void 0===l?void 0:l.raw)?1/0:1,p=o(),{height:v}=y(s.context.mode),k=E(p,1===g,v),[F,X,_,U,S,O]=w(s),x=m(h),C=f(h),B=r(!0),R=r(!1);n((()=>{B.current?B.current=!1:d.current.state.suggestionsVisible&&T()}),[X]),n((()=>{const t=t=>{var e;if("Backspace"===t.key){const t=null===(e=h.current)||void 0===e?void 0:e.querySelector('[class*="TALXIS__tag-picker__root"]');document.activeElement===t&&1===F.length&&(U.select(void 0),setTimeout((()=>{var t;null===(t=d.current)||void 0===t||t.focusInput()}),200))}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}}),[F]),n((()=>{var t;!0===(null===(t=s.parameters.AutoFocus)||void 0===t?void 0:t.raw)&&V()}),[]);const V=()=>{var t,e,i,r;(null===(e=null===(t=d.current)||void 0===t?void 0:t.items)||void 0===e?void 0:e.length)!==g?null===(r=d.current)||void 0===r||r.focusInput():null===(i=h.current)||void 0===i||i.querySelector('[class*="TALXIS__tag-picker__root"]').focus()},T=()=>b(void 0,void 0,void 0,(function*(){d.current.suggestionStore.updateSuggestions([]),d.current.setState({suggestionsVisible:!0,suggestionsLoading:!0});const t=yield q(d.current.input.current.value);d.current.updateSuggestionsList(t),d.current.setState({isMostRecentlyUsedVisible:!1,suggestionsVisible:!0,moreSuggestionsAvailable:!1})})),L=()=>x||C,q=(t,e)=>b(void 0,void 0,void 0,(function*(){var i;const r=yield O(t),s=[];for(const t of r){if(null==e?void 0:e.find((e=>e.key===t.id)))continue;const r=yield null===(i=X.find((e=>e.entityName===t.entityType)))||void 0===i?void 0:i.metadata;s.push({key:t.id,text:t.name||_.noName(),secondaryText:null==r?void 0:r.DisplayName,"data-entity":t.entityType})}return s}));return e("div",Object.assign({className:k.root,ref:h},{children:e(c,{componentRef:d,resolveDelay:200,stackItems:1===g,errorMessage:s.parameters.value.errorMessage,pickerCalloutProps:{className:k.suggestions},pickerSuggestionsProps:{loadingText:_.searching(),noResultsFoundText:_.noRecordsFound(),suggestionsHeaderText:t(i,{children:[!1!==(null===(a=s.parameters.IsInlineNewEnabled)||void 0===a?void 0:a.raw)&&e(A,{labels:_,entities:X,onCreateRecord:U.create}),s.parameters.value.attributes.Targets.length>1&&e(N,{labels:_,entities:X,onEntitySelected:t=>{S(t)}})]})},transparent:!L()&&1===g,onChange:t=>{U.select(null==t?void 0:t.map((t=>({entityType:t["data-entity"],id:t.key,name:t.text}))))},searchBtnProps:{iconProps:{iconName:"Search"}},selectedItems:F.map((t=>{var e;return{key:t.id,text:t.name||_.noName(),"data-entity":t.entityType,"data-navigation-enabled":!1!==(null===(e=s.parameters.EnableNavigation)||void 0===e?void 0:e.raw),onClick:()=>{var e;!1!==(null===(e=s.parameters.EnableNavigation)||void 0===e?void 0:e.raw)&&u.navigation.openForm({entityName:t.entityType,entityId:t.id})},deleteButtonProps:L()||g>1?{key:"delete",iconProps:{iconName:"ChromeClose",styles:{root:{fontSize:12,width:16,color:`${p.palette.black} !important`}}},onClick:()=>{R.current=!1,U.deselect(t),setTimeout((()=>{V()}),200)}}:void 0}})),itemLimit:g,onResolveSuggestions:q})}))};export{U as L,b as _};