@limetech/lime-web-components 5.38.1 → 5.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/core/idle.d.ts +25 -0
  3. package/dist/core/idle.d.ts.map +1 -0
  4. package/dist/core/idle.js +7 -0
  5. package/dist/core/index.d.ts +1 -0
  6. package/dist/core/index.d.ts.map +1 -1
  7. package/dist/core/index.js +1 -0
  8. package/dist/es5/core/idle.js +4 -0
  9. package/dist/es5/core/index.js +1 -0
  10. package/dist/es5/index.js +1 -0
  11. package/dist/es5/limetype/find-limetype-by-label.js +8 -0
  12. package/dist/es5/limetype/find-limetype-by-label.spec.js +47 -0
  13. package/dist/es5/limetype/get-properties-by-type.js +7 -0
  14. package/dist/es5/limetype/get-properties-by-type.spec.js +36 -0
  15. package/dist/es5/limetype/get-property-by-label.js +8 -0
  16. package/dist/es5/limetype/get-property-by-label.spec.js +33 -0
  17. package/dist/es5/limetype/get-property-by-name.js +7 -0
  18. package/dist/es5/limetype/get-property-by-name.spec.js +31 -0
  19. package/dist/es5/limetype/has-label.js +7 -0
  20. package/dist/es5/limetype/has-label.spec.js +30 -0
  21. package/dist/es5/limetype/index.js +5 -0
  22. package/dist/es5/poller/factory.js +2 -0
  23. package/dist/es5/poller/index.js +6 -0
  24. package/dist/es5/poller/poller.js +2 -0
  25. package/dist/es5/poller/types.js +5 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -0
  29. package/dist/limetype/find-limetype-by-label.d.ts +42 -0
  30. package/dist/limetype/find-limetype-by-label.d.ts.map +1 -0
  31. package/dist/limetype/find-limetype-by-label.js +43 -0
  32. package/dist/limetype/find-limetype-by-label.spec.d.ts +2 -0
  33. package/dist/limetype/find-limetype-by-label.spec.d.ts.map +1 -0
  34. package/dist/limetype/find-limetype-by-label.spec.js +44 -0
  35. package/dist/limetype/get-properties-by-type.d.ts +16 -0
  36. package/dist/limetype/get-properties-by-type.d.ts.map +1 -0
  37. package/dist/limetype/get-properties-by-type.js +16 -0
  38. package/dist/limetype/get-properties-by-type.spec.d.ts +2 -0
  39. package/dist/limetype/get-properties-by-type.spec.d.ts.map +1 -0
  40. package/dist/limetype/get-properties-by-type.spec.js +31 -0
  41. package/dist/limetype/get-property-by-label.d.ts +16 -0
  42. package/dist/limetype/get-property-by-label.d.ts.map +1 -0
  43. package/dist/limetype/get-property-by-label.js +17 -0
  44. package/dist/limetype/get-property-by-label.spec.d.ts +2 -0
  45. package/dist/limetype/get-property-by-label.spec.d.ts.map +1 -0
  46. package/dist/limetype/get-property-by-label.spec.js +26 -0
  47. package/dist/limetype/get-property-by-name.d.ts +17 -0
  48. package/dist/limetype/get-property-by-name.d.ts.map +1 -0
  49. package/dist/limetype/get-property-by-name.js +17 -0
  50. package/dist/limetype/get-property-by-name.spec.d.ts +2 -0
  51. package/dist/limetype/get-property-by-name.spec.d.ts.map +1 -0
  52. package/dist/limetype/get-property-by-name.spec.js +26 -0
  53. package/dist/limetype/has-label.d.ts +29 -0
  54. package/dist/limetype/has-label.d.ts.map +1 -0
  55. package/dist/limetype/has-label.js +29 -0
  56. package/dist/limetype/has-label.spec.d.ts +2 -0
  57. package/dist/limetype/has-label.spec.d.ts.map +1 -0
  58. package/dist/limetype/has-label.spec.js +31 -0
  59. package/dist/limetype/index.d.ts +5 -0
  60. package/dist/limetype/index.d.ts.map +1 -1
  61. package/dist/limetype/index.js +5 -0
  62. package/dist/poller/factory.d.ts +49 -0
  63. package/dist/poller/factory.d.ts.map +1 -0
  64. package/dist/poller/factory.js +1 -0
  65. package/dist/poller/index.d.ts +4 -0
  66. package/dist/poller/index.d.ts.map +1 -0
  67. package/dist/poller/index.js +3 -0
  68. package/dist/poller/poller.d.ts +49 -0
  69. package/dist/poller/poller.d.ts.map +1 -0
  70. package/dist/poller/poller.js +1 -0
  71. package/dist/poller/types.d.ts +15 -0
  72. package/dist/poller/types.d.ts.map +1 -0
  73. package/dist/poller/types.js +3 -0
  74. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [5.40.0](https://github.com/Lundalogik/lime-web-components/compare/v5.39.0...v5.40.0) (2024-11-21)
2
+
3
+
4
+ ### Features
5
+
6
+
7
+ * **limetype:** add helper functions for working with limetypes ([70c0cba](https://github.com/Lundalogik/lime-web-components/commit/70c0cbadc3e23794b8236d973ebf789803e71d02))
8
+
9
+ ## [5.39.0](https://github.com/Lundalogik/lime-web-components/compare/v5.38.1...v5.39.0) (2024-11-21)
10
+
11
+
12
+ ### Features
13
+
14
+
15
+ * **core:** add event that dispatches current idle status of the user ([c625b0f](https://github.com/Lundalogik/lime-web-components/commit/c625b0f7d5349f97577cfbec77f4fe27f92814f3)), closes [Lundalogik/crm-feature#4482](https://github.com/Lundalogik/crm-feature/issues/4482)
16
+ * **poller:** add poller and poller factory ([7a59130](https://github.com/Lundalogik/lime-web-components/commit/7a59130906a3de4c2a7dda58ffd0f6b16fabffc8)), closes [Lundalogik/crm-feature#4482](https://github.com/Lundalogik/crm-feature/issues/4482)
17
+
1
18
  ## [5.38.1](https://github.com/Lundalogik/lime-web-components/compare/v5.38.0...v5.38.1) (2024-10-28)
2
19
 
3
20
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The user's idle state. When set to `active` the user is actively using the
3
+ * application. When set to `idle`, the user has either minimized the
4
+ * application or not used it actively for a while.
5
+ * @beta
6
+ * @group Core
7
+ */
8
+ export type IdleState = 'active' | 'idle';
9
+ /**
10
+ * The event emitted by {@link EventDispatcher} when the user's idle state
11
+ * changes
12
+ * @beta
13
+ * @group Core
14
+ */
15
+ export type IdleStateChangeEvent = CustomEvent<{
16
+ state: IdleState;
17
+ }>;
18
+ /**
19
+ * Name of the event emitted by {@link EventDispatcher} when the user's idle
20
+ * state changes
21
+ * @beta
22
+ * @group Core
23
+ */
24
+ export declare const IdleStateEventName: "idle-state";
25
+ //# sourceMappingURL=idle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle.d.ts","sourceRoot":"","sources":["../../src/core/idle.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAAwB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Name of the event emitted by {@link EventDispatcher} when the user's idle
3
+ * state changes
4
+ * @beta
5
+ * @group Core
6
+ */
7
+ export const IdleStateEventName = 'idle-state';
@@ -5,4 +5,5 @@ export * from './plugin-loader';
5
5
  export * from './state';
6
6
  export * from './decorators';
7
7
  export * from './metadata';
8
+ export * from './idle';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
@@ -5,3 +5,4 @@ export * from './plugin-loader';
5
5
  export * from './state';
6
6
  export * from './decorators';
7
7
  export * from './metadata';
8
+ export * from './idle';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdleStateEventName = void 0;
4
+ exports.IdleStateEventName = 'idle-state';
@@ -8,3 +8,4 @@ tslib_1.__exportStar(require("./plugin-loader"), exports);
8
8
  tslib_1.__exportStar(require("./state"), exports);
9
9
  tslib_1.__exportStar(require("./decorators"), exports);
10
10
  tslib_1.__exportStar(require("./metadata"), exports);
11
+ tslib_1.__exportStar(require("./idle"), exports);
package/dist/es5/index.js CHANGED
@@ -27,3 +27,4 @@ tslib_1.__exportStar(require("./conditionregistry"), exports);
27
27
  tslib_1.__exportStar(require("./view"), exports);
28
28
  tslib_1.__exportStar(require("./webcomponent"), exports);
29
29
  tslib_1.__exportStar(require("./notification-service"), exports);
30
+ tslib_1.__exportStar(require("./poller"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findLimetypeByLabel = void 0;
4
+ var _1 = require(".");
5
+ var findLimetypeByLabel = function (label) { return function (limetypes) {
6
+ return Object.values(limetypes).find((0, _1.hasLabel)(label));
7
+ }; };
8
+ exports.findLimetypeByLabel = findLimetypeByLabel;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var company_1 = require("../testing/limetypes/company");
5
+ var person_1 = require("../testing/limetypes/person");
6
+ var find_limetype_by_label_1 = require("./find-limetype-by-label");
7
+ describe('findLimetypeByLabel', function () {
8
+ var limetypes = {
9
+ company: tslib_1.__assign({}, company_1.company),
10
+ person: tslib_1.__assign({}, person_1.person),
11
+ };
12
+ it('returns a function', function () {
13
+ var result = (0, find_limetype_by_label_1.findLimetypeByLabel)('person');
14
+ expect(typeof result).toBe('function');
15
+ });
16
+ describe('when the label exists', function () {
17
+ it('returns the correct limetype', function () {
18
+ var findUser = (0, find_limetype_by_label_1.findLimetypeByLabel)('person');
19
+ var result = findUser(limetypes);
20
+ expect(result).toStrictEqual(person_1.person);
21
+ });
22
+ });
23
+ describe('when the label does not exist', function () {
24
+ it('returns undefined', function () {
25
+ var findNonexistent = (0, find_limetype_by_label_1.findLimetypeByLabel)('nonexistent');
26
+ var result = findNonexistent(limetypes);
27
+ expect(result).toBeUndefined();
28
+ });
29
+ });
30
+ describe('when the limetypes object is empty', function () {
31
+ it('returns undefined', function () {
32
+ var findUser = (0, find_limetype_by_label_1.findLimetypeByLabel)('person');
33
+ var result = findUser({});
34
+ expect(result).toBeUndefined();
35
+ });
36
+ });
37
+ describe('when the input is invalid', function () {
38
+ it('throws an error if limetypes is null', function () {
39
+ var findUser = (0, find_limetype_by_label_1.findLimetypeByLabel)('person');
40
+ expect(function () { return findUser(null); }).toThrow();
41
+ });
42
+ it('throws an error if limetypes is undefined', function () {
43
+ var findUser = (0, find_limetype_by_label_1.findLimetypeByLabel)('person');
44
+ expect(function () { return findUser(undefined); }).toThrow();
45
+ });
46
+ });
47
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropertiesByType = void 0;
4
+ function getPropertiesByType(limetype, type) {
5
+ return Object.values(limetype.properties).filter(function (property) { return property.type === type; });
6
+ }
7
+ exports.getPropertiesByType = getPropertiesByType;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var person_1 = require("../testing/limetypes/person");
5
+ var get_properties_by_type_1 = require("./get-properties-by-type");
6
+ describe('getPropertiesByType', function () {
7
+ it('retrieves all properties of a specified type', function () {
8
+ var result = (0, get_properties_by_type_1.getPropertiesByType)(tslib_1.__assign({}, person_1.person), 'string');
9
+ expect(result).toStrictEqual([
10
+ person_1.person.properties.firstname,
11
+ person_1.person.properties.lastname,
12
+ person_1.person.properties.name,
13
+ person_1.person.properties.position,
14
+ ]);
15
+ });
16
+ it('returns an empty array if no properties match the type', function () {
17
+ var result = (0, get_properties_by_type_1.getPropertiesByType)(tslib_1.__assign({}, person_1.person), 'integer');
18
+ expect(result).toStrictEqual([]);
19
+ });
20
+ describe('edge cases', function () {
21
+ it('returns an empty array if limetype has no properties', function () {
22
+ var emptyLimetype = {
23
+ label: 'empty',
24
+ properties: {},
25
+ };
26
+ var result = (0, get_properties_by_type_1.getPropertiesByType)(emptyLimetype, 'string');
27
+ expect(result).toStrictEqual([]);
28
+ });
29
+ it('throws an error if limetype is null or undefined', function () {
30
+ expect(function () { return (0, get_properties_by_type_1.getPropertiesByType)(null, 'string'); }).toThrow();
31
+ expect(function () {
32
+ return (0, get_properties_by_type_1.getPropertiesByType)(undefined, 'string');
33
+ }).toThrow();
34
+ });
35
+ });
36
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropertyByLabel = void 0;
4
+ var _1 = require(".");
5
+ function getPropertyByLabel(limetype, label) {
6
+ return Object.values(limetype.properties).find((0, _1.hasLabel)(label));
7
+ }
8
+ exports.getPropertyByLabel = getPropertyByLabel;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var person_1 = require("../testing/limetypes/person");
5
+ var get_property_by_label_1 = require("./get-property-by-label");
6
+ describe('getPropertyByLabel', function () {
7
+ it('retrieves a property by its label', function () {
8
+ var result = (0, get_property_by_label_1.getPropertyByLabel)(tslib_1.__assign({}, person_1.person), 'primaryemailaddress');
9
+ expect(result).toStrictEqual(person_1.person.properties.email);
10
+ });
11
+ it('returns undefined if no property matches the label', function () {
12
+ var result = (0, get_property_by_label_1.getPropertyByLabel)(tslib_1.__assign({}, person_1.person), 'nonexistent');
13
+ expect(result).toBeUndefined();
14
+ });
15
+ describe('edge cases', function () {
16
+ it('returns undefined if limetype has no properties', function () {
17
+ var emptyLimetype = {
18
+ label: 'empty',
19
+ properties: {},
20
+ };
21
+ var result = (0, get_property_by_label_1.getPropertyByLabel)(emptyLimetype, 'primaryemailaddress');
22
+ expect(result).toBeUndefined();
23
+ });
24
+ it('throws an error if limetype is null or undefined', function () {
25
+ expect(function () {
26
+ return (0, get_property_by_label_1.getPropertyByLabel)(null, 'primaryemailaddress');
27
+ }).toThrow();
28
+ expect(function () {
29
+ return (0, get_property_by_label_1.getPropertyByLabel)(undefined, 'primaryemailaddress');
30
+ }).toThrow();
31
+ });
32
+ });
33
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropertyByName = void 0;
4
+ function getPropertyByName(limetype, propertyName) {
5
+ return limetype.properties[propertyName];
6
+ }
7
+ exports.getPropertyByName = getPropertyByName;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var person_1 = require("../testing/limetypes/person");
5
+ var get_property_by_name_1 = require("./get-property-by-name");
6
+ describe('getPropertyByName', function () {
7
+ it('retrieves a property by its name', function () {
8
+ var result = (0, get_property_by_name_1.getPropertyByName)(tslib_1.__assign({}, person_1.person), 'email');
9
+ expect(result).toStrictEqual(person_1.person.properties.email);
10
+ });
11
+ it('returns `undefined` if the property does not exist', function () {
12
+ var result = (0, get_property_by_name_1.getPropertyByName)(tslib_1.__assign({}, person_1.person), 'age');
13
+ expect(result).toBeUndefined();
14
+ });
15
+ describe('edge cases', function () {
16
+ it('returns undefined if limetype has no properties', function () {
17
+ var emptyLimetype = {
18
+ label: 'Empty',
19
+ properties: {},
20
+ };
21
+ var result = (0, get_property_by_name_1.getPropertyByName)(emptyLimetype, 'email');
22
+ expect(result).toBeUndefined();
23
+ });
24
+ it('throws an error if limetype is null or undefined', function () {
25
+ expect(function () { return (0, get_property_by_name_1.getPropertyByName)(null, 'email'); }).toThrow();
26
+ expect(function () {
27
+ return (0, get_property_by_name_1.getPropertyByName)(undefined, 'email');
28
+ }).toThrow();
29
+ });
30
+ });
31
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasLabel = void 0;
4
+ var hasLabel = function (label) { return function (object) {
5
+ return (object === null || object === void 0 ? void 0 : object.label) === label;
6
+ }; };
7
+ exports.hasLabel = hasLabel;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var person_1 = require("../testing/limetypes/person");
4
+ var has_label_1 = require("./has-label");
5
+ describe('hasLabel', function () {
6
+ it('returns true if the object has the specified label', function () {
7
+ var checkLabel = (0, has_label_1.hasLabel)('primaryemailaddress');
8
+ expect(checkLabel(person_1.person.properties.email)).toBe(true);
9
+ });
10
+ it('returns false if the object does not have the specified label', function () {
11
+ var checkLabel = (0, has_label_1.hasLabel)('firstname');
12
+ expect(checkLabel(person_1.person.properties.email)).toBe(false);
13
+ });
14
+ it('returns false if the object is undefined', function () {
15
+ var checkLabel = (0, has_label_1.hasLabel)('firstname');
16
+ expect(checkLabel(undefined)).toBe(false);
17
+ });
18
+ describe('edge cases', function () {
19
+ it('returns false if the object has no label property', function () {
20
+ var obj = { type: 'string' };
21
+ var checkLabel = (0, has_label_1.hasLabel)('firstname');
22
+ expect(checkLabel(obj)).toBe(false);
23
+ });
24
+ it.skip('returns false if the label is an empty string', function () {
25
+ var obj = { label: '', type: 'string' };
26
+ var checkLabel = (0, has_label_1.hasLabel)('');
27
+ expect(checkLabel(obj)).toBe(false);
28
+ });
29
+ });
30
+ });
@@ -7,3 +7,8 @@ tslib_1.__exportStar(require("./property"), exports);
7
7
  tslib_1.__exportStar(require("./repository"), exports);
8
8
  tslib_1.__exportStar(require("./types"), exports);
9
9
  tslib_1.__exportStar(require("./decorator"), exports);
10
+ tslib_1.__exportStar(require("./find-limetype-by-label"), exports);
11
+ tslib_1.__exportStar(require("./get-properties-by-type"), exports);
12
+ tslib_1.__exportStar(require("./get-property-by-label"), exports);
13
+ tslib_1.__exportStar(require("./get-property-by-name"), exports);
14
+ tslib_1.__exportStar(require("./has-label"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./factory"), exports);
5
+ tslib_1.__exportStar(require("./poller"), exports);
6
+ tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var platform_1 = require("../core/platform");
4
+ var SERVICE_NAME = 'pollerFactory';
5
+ platform_1.PlatformServiceName.PollerFactory = SERVICE_NAME;
package/dist/index.d.ts CHANGED
@@ -46,4 +46,5 @@ export * from './conditionregistry';
46
46
  export * from './view';
47
47
  export * from './webcomponent';
48
48
  export * from './notification-service';
49
+ export * from './poller';
49
50
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -46,3 +46,4 @@ export * from './conditionregistry';
46
46
  export * from './view';
47
47
  export * from './webcomponent';
48
48
  export * from './notification-service';
49
+ export * from './poller';
@@ -0,0 +1,42 @@
1
+ import { LimeType } from '.';
2
+ /**
3
+ * Creates a function to find a limetype by its label in a collection of limetypes.
4
+ *
5
+ * The returned function searches through a collection of limetypes and returns
6
+ * the first one that matches the given label. This function is typically used
7
+ * to generate a callback for decorators or other higher-order logic.
8
+ *
9
+ * @param label - The label of the limetype to find.
10
+ * @returns A function that takes a collection of limetypes and returns the first
11
+ * limetype that matches the label, or `undefined` if no match is found.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { findLimetypeByLabel } from '@limetech/lime-web-components';
16
+ *
17
+ * const limetypes = {
18
+ * company: { label: 'company', properties: {} },
19
+ * person: { label: 'person', properties: {} },
20
+ * };
21
+ *
22
+ * const findPersonLimetype = findLimetypeByLabel('person');
23
+ * const personLimetype = findPersonLimetype(limetypes);
24
+ * console.log(personLimetype); // { label: 'person', properties: {} }
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Using `findLimetypeByLabel` as a callback for a decorator
30
+ * import { findLimetypeByLabel, SelectLimeTypes } from '@limetech/lime-web-components';
31
+ *
32
+ * @SelectLimeTypes({
33
+ * map: [findLimetypeByLabel('person')],
34
+ * })
35
+ * private personLimetype: LimeType;
36
+ * ```
37
+ *
38
+ * @public
39
+ * @group Lime types
40
+ */
41
+ export declare const findLimetypeByLabel: (label: string) => (limetypes: Record<string, LimeType>) => LimeType;
42
+ //# sourceMappingURL=find-limetype-by-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-limetype-by-label.d.ts","sourceRoot":"","sources":["../../src/limetype/find-limetype-by-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,GAAG,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,UACpB,MAAM,iBAAiB,OAAO,MAAM,EAAE,QAAQ,CAAC,aAEtD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { hasLabel } from '.';
2
+ /**
3
+ * Creates a function to find a limetype by its label in a collection of limetypes.
4
+ *
5
+ * The returned function searches through a collection of limetypes and returns
6
+ * the first one that matches the given label. This function is typically used
7
+ * to generate a callback for decorators or other higher-order logic.
8
+ *
9
+ * @param label - The label of the limetype to find.
10
+ * @returns A function that takes a collection of limetypes and returns the first
11
+ * limetype that matches the label, or `undefined` if no match is found.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { findLimetypeByLabel } from '@limetech/lime-web-components';
16
+ *
17
+ * const limetypes = {
18
+ * company: { label: 'company', properties: {} },
19
+ * person: { label: 'person', properties: {} },
20
+ * };
21
+ *
22
+ * const findPersonLimetype = findLimetypeByLabel('person');
23
+ * const personLimetype = findPersonLimetype(limetypes);
24
+ * console.log(personLimetype); // { label: 'person', properties: {} }
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Using `findLimetypeByLabel` as a callback for a decorator
30
+ * import { findLimetypeByLabel, SelectLimeTypes } from '@limetech/lime-web-components';
31
+ *
32
+ * @SelectLimeTypes({
33
+ * map: [findLimetypeByLabel('person')],
34
+ * })
35
+ * private personLimetype: LimeType;
36
+ * ```
37
+ *
38
+ * @public
39
+ * @group Lime types
40
+ */
41
+ export const findLimetypeByLabel = (label) => (limetypes) => {
42
+ return Object.values(limetypes).find(hasLabel(label));
43
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=find-limetype-by-label.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-limetype-by-label.spec.d.ts","sourceRoot":"","sources":["../../src/limetype/find-limetype-by-label.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import { company } from '../testing/limetypes/company';
2
+ import { person } from '../testing/limetypes/person';
3
+ import { findLimetypeByLabel } from './find-limetype-by-label';
4
+ describe('findLimetypeByLabel', () => {
5
+ const limetypes = {
6
+ company: Object.assign({}, company),
7
+ person: Object.assign({}, person),
8
+ };
9
+ it('returns a function', () => {
10
+ const result = findLimetypeByLabel('person');
11
+ expect(typeof result).toBe('function');
12
+ });
13
+ describe('when the label exists', () => {
14
+ it('returns the correct limetype', () => {
15
+ const findUser = findLimetypeByLabel('person');
16
+ const result = findUser(limetypes);
17
+ expect(result).toStrictEqual(person);
18
+ });
19
+ });
20
+ describe('when the label does not exist', () => {
21
+ it('returns undefined', () => {
22
+ const findNonexistent = findLimetypeByLabel('nonexistent');
23
+ const result = findNonexistent(limetypes);
24
+ expect(result).toBeUndefined();
25
+ });
26
+ });
27
+ describe('when the limetypes object is empty', () => {
28
+ it('returns undefined', () => {
29
+ const findUser = findLimetypeByLabel('person');
30
+ const result = findUser({});
31
+ expect(result).toBeUndefined();
32
+ });
33
+ });
34
+ describe('when the input is invalid', () => {
35
+ it('throws an error if limetypes is null', () => {
36
+ const findUser = findLimetypeByLabel('person');
37
+ expect(() => findUser(null)).toThrow();
38
+ });
39
+ it('throws an error if limetypes is undefined', () => {
40
+ const findUser = findLimetypeByLabel('person');
41
+ expect(() => findUser(undefined)).toThrow();
42
+ });
43
+ });
44
+ });
@@ -0,0 +1,16 @@
1
+ import { LimeProperty, LimeType, PropertyType } from '.';
2
+ /**
3
+ * Retrieves all properties of a specific type from a limetype.
4
+ *
5
+ * This function filters the properties of a limetype and returns
6
+ * those that match the specified property type.
7
+ *
8
+ * @param limetype - The limetype containing the properties.
9
+ * @param type - The type of properties to retrieve.
10
+ * @returns An array of properties that match the specified type.
11
+ *
12
+ * @public
13
+ * @group Lime types
14
+ */
15
+ export declare function getPropertiesByType(limetype: LimeType, type: PropertyType): LimeProperty[];
16
+ //# sourceMappingURL=get-properties-by-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-properties-by-type.d.ts","sourceRoot":"","sources":["../../src/limetype/get-properties-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,YAAY,GACnB,YAAY,EAAE,CAIhB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Retrieves all properties of a specific type from a limetype.
3
+ *
4
+ * This function filters the properties of a limetype and returns
5
+ * those that match the specified property type.
6
+ *
7
+ * @param limetype - The limetype containing the properties.
8
+ * @param type - The type of properties to retrieve.
9
+ * @returns An array of properties that match the specified type.
10
+ *
11
+ * @public
12
+ * @group Lime types
13
+ */
14
+ export function getPropertiesByType(limetype, type) {
15
+ return Object.values(limetype.properties).filter((property) => property.type === type);
16
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get-properties-by-type.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-properties-by-type.spec.d.ts","sourceRoot":"","sources":["../../src/limetype/get-properties-by-type.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { person } from '../testing/limetypes/person';
2
+ import { getPropertiesByType } from './get-properties-by-type';
3
+ describe('getPropertiesByType', () => {
4
+ it('retrieves all properties of a specified type', () => {
5
+ const result = getPropertiesByType(Object.assign({}, person), 'string');
6
+ expect(result).toStrictEqual([
7
+ person.properties.firstname,
8
+ person.properties.lastname,
9
+ person.properties.name,
10
+ person.properties.position,
11
+ ]);
12
+ });
13
+ it('returns an empty array if no properties match the type', () => {
14
+ const result = getPropertiesByType(Object.assign({}, person), 'integer');
15
+ expect(result).toStrictEqual([]);
16
+ });
17
+ describe('edge cases', () => {
18
+ it('returns an empty array if limetype has no properties', () => {
19
+ const emptyLimetype = {
20
+ label: 'empty',
21
+ properties: {},
22
+ };
23
+ const result = getPropertiesByType(emptyLimetype, 'string');
24
+ expect(result).toStrictEqual([]);
25
+ });
26
+ it('throws an error if limetype is null or undefined', () => {
27
+ expect(() => getPropertiesByType(null, 'string')).toThrow();
28
+ expect(() => getPropertiesByType(undefined, 'string')).toThrow();
29
+ });
30
+ });
31
+ });
@@ -0,0 +1,16 @@
1
+ import { LimeProperty, LimeType } from '.';
2
+ /**
3
+ * Retrieves a property from a limetype by its label.
4
+ *
5
+ * This function searches through the properties of a given limetype
6
+ * and returns the first property that matches the specified label.
7
+ *
8
+ * @param limetype - The limetype containing the properties.
9
+ * @param label - The label of the property to retrieve.
10
+ * @returns The property with the specified label, or `undefined` if no match is found.
11
+ *
12
+ * @public
13
+ * @group Lime types
14
+ */
15
+ export declare function getPropertyByLabel(limetype: LimeType, label: string): LimeProperty | undefined;
16
+ //# sourceMappingURL=get-property-by-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-property-by-label.d.ts","sourceRoot":"","sources":["../../src/limetype/get-property-by-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,GACd,YAAY,GAAG,SAAS,CAE1B"}
@@ -0,0 +1,17 @@
1
+ import { hasLabel } from '.';
2
+ /**
3
+ * Retrieves a property from a limetype by its label.
4
+ *
5
+ * This function searches through the properties of a given limetype
6
+ * and returns the first property that matches the specified label.
7
+ *
8
+ * @param limetype - The limetype containing the properties.
9
+ * @param label - The label of the property to retrieve.
10
+ * @returns The property with the specified label, or `undefined` if no match is found.
11
+ *
12
+ * @public
13
+ * @group Lime types
14
+ */
15
+ export function getPropertyByLabel(limetype, label) {
16
+ return Object.values(limetype.properties).find(hasLabel(label));
17
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get-property-by-label.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-property-by-label.spec.d.ts","sourceRoot":"","sources":["../../src/limetype/get-property-by-label.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { person } from '../testing/limetypes/person';
2
+ import { getPropertyByLabel } from './get-property-by-label';
3
+ describe('getPropertyByLabel', () => {
4
+ it('retrieves a property by its label', () => {
5
+ const result = getPropertyByLabel(Object.assign({}, person), 'primaryemailaddress');
6
+ expect(result).toStrictEqual(person.properties.email);
7
+ });
8
+ it('returns undefined if no property matches the label', () => {
9
+ const result = getPropertyByLabel(Object.assign({}, person), 'nonexistent');
10
+ expect(result).toBeUndefined();
11
+ });
12
+ describe('edge cases', () => {
13
+ it('returns undefined if limetype has no properties', () => {
14
+ const emptyLimetype = {
15
+ label: 'empty',
16
+ properties: {},
17
+ };
18
+ const result = getPropertyByLabel(emptyLimetype, 'primaryemailaddress');
19
+ expect(result).toBeUndefined();
20
+ });
21
+ it('throws an error if limetype is null or undefined', () => {
22
+ expect(() => getPropertyByLabel(null, 'primaryemailaddress')).toThrow();
23
+ expect(() => getPropertyByLabel(undefined, 'primaryemailaddress')).toThrow();
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,17 @@
1
+ import { LimeProperty, LimeType } from '.';
2
+ /**
3
+ * Retrieves a property from a limetype by its name.
4
+ *
5
+ * This function extracts a specific property from a given limetype
6
+ * based on the property's name.
7
+ *
8
+ * @param limetype - The limetype containing the properties.
9
+ * @param propertyName - The name of the property to retrieve.
10
+ * @returns The property with the specified name.
11
+ * @throws Will throw an error if the property name does not exist in the limetype.
12
+ *
13
+ * @public
14
+ * @group Lime types
15
+ */
16
+ export declare function getPropertyByName(limetype: LimeType, propertyName: string): LimeProperty;
17
+ //# sourceMappingURL=get-property-by-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-property-by-name.d.ts","sourceRoot":"","sources":["../../src/limetype/get-property-by-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,GACrB,YAAY,CAEd"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Retrieves a property from a limetype by its name.
3
+ *
4
+ * This function extracts a specific property from a given limetype
5
+ * based on the property's name.
6
+ *
7
+ * @param limetype - The limetype containing the properties.
8
+ * @param propertyName - The name of the property to retrieve.
9
+ * @returns The property with the specified name.
10
+ * @throws Will throw an error if the property name does not exist in the limetype.
11
+ *
12
+ * @public
13
+ * @group Lime types
14
+ */
15
+ export function getPropertyByName(limetype, propertyName) {
16
+ return limetype.properties[propertyName];
17
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get-property-by-name.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-property-by-name.spec.d.ts","sourceRoot":"","sources":["../../src/limetype/get-property-by-name.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { person } from '../testing/limetypes/person';
2
+ import { getPropertyByName } from './get-property-by-name';
3
+ describe('getPropertyByName', () => {
4
+ it('retrieves a property by its name', () => {
5
+ const result = getPropertyByName(Object.assign({}, person), 'email');
6
+ expect(result).toStrictEqual(person.properties.email);
7
+ });
8
+ it('returns `undefined` if the property does not exist', () => {
9
+ const result = getPropertyByName(Object.assign({}, person), 'age');
10
+ expect(result).toBeUndefined();
11
+ });
12
+ describe('edge cases', () => {
13
+ it('returns undefined if limetype has no properties', () => {
14
+ const emptyLimetype = {
15
+ label: 'Empty',
16
+ properties: {},
17
+ };
18
+ const result = getPropertyByName(emptyLimetype, 'email');
19
+ expect(result).toBeUndefined();
20
+ });
21
+ it('throws an error if limetype is null or undefined', () => {
22
+ expect(() => getPropertyByName(null, 'email')).toThrow();
23
+ expect(() => getPropertyByName(undefined, 'email')).toThrow();
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,29 @@
1
+ import { LimeProperty, LimeType } from '.';
2
+ /**
3
+ * Creates a function to check if a given object has a specific label.
4
+ *
5
+ * The returned function takes an object (a `LimeType` or `LimeProperty`) and
6
+ * checks whether it contains the specified label. This function is typically
7
+ * used as a callback for array methods like `.find` or `.filter`.
8
+ *
9
+ * @param label - The label to check for.
10
+ * @returns A function that takes an optional object and returns `true` if the label matches, or `false` otherwise.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { hasLabel } from '@limetech/lime-web-components';
15
+ *
16
+ * const properties = [
17
+ * { label: 'name', type: 'string' },
18
+ * { label: 'email', type: 'string' },
19
+ * ];
20
+ *
21
+ * const emailProperty = properties.find(hasLabel('email'));
22
+ * console.log(emailProperty); // { label: 'email', type: 'string' }
23
+ * ```
24
+ *
25
+ * @public
26
+ * @group Lime types
27
+ */
28
+ export declare const hasLabel: (label: string) => (object?: LimeType | LimeProperty) => boolean;
29
+ //# sourceMappingURL=has-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-label.d.ts","sourceRoot":"","sources":["../../src/limetype/has-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,QAAQ,UACT,MAAM,eAAe,QAAQ,GAAG,YAAY,YAEnD,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Creates a function to check if a given object has a specific label.
3
+ *
4
+ * The returned function takes an object (a `LimeType` or `LimeProperty`) and
5
+ * checks whether it contains the specified label. This function is typically
6
+ * used as a callback for array methods like `.find` or `.filter`.
7
+ *
8
+ * @param label - The label to check for.
9
+ * @returns A function that takes an optional object and returns `true` if the label matches, or `false` otherwise.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { hasLabel } from '@limetech/lime-web-components';
14
+ *
15
+ * const properties = [
16
+ * { label: 'name', type: 'string' },
17
+ * { label: 'email', type: 'string' },
18
+ * ];
19
+ *
20
+ * const emailProperty = properties.find(hasLabel('email'));
21
+ * console.log(emailProperty); // { label: 'email', type: 'string' }
22
+ * ```
23
+ *
24
+ * @public
25
+ * @group Lime types
26
+ */
27
+ export const hasLabel = (label) => (object) => {
28
+ return (object === null || object === void 0 ? void 0 : object.label) === label;
29
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=has-label.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-label.spec.d.ts","sourceRoot":"","sources":["../../src/limetype/has-label.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { person } from '../testing/limetypes/person';
2
+ import { hasLabel } from './has-label';
3
+ describe('hasLabel', () => {
4
+ it('returns true if the object has the specified label', () => {
5
+ const checkLabel = hasLabel('primaryemailaddress');
6
+ expect(checkLabel(person.properties.email)).toBe(true);
7
+ });
8
+ it('returns false if the object does not have the specified label', () => {
9
+ const checkLabel = hasLabel('firstname');
10
+ expect(checkLabel(person.properties.email)).toBe(false);
11
+ });
12
+ it('returns false if the object is undefined', () => {
13
+ const checkLabel = hasLabel('firstname');
14
+ expect(checkLabel(undefined)).toBe(false);
15
+ });
16
+ describe('edge cases', () => {
17
+ it('returns false if the object has no label property', () => {
18
+ const obj = { type: 'string' };
19
+ const checkLabel = hasLabel('firstname');
20
+ expect(checkLabel(obj)).toBe(false);
21
+ });
22
+ // At the moment, if both the label and the search string are empty
23
+ // strings, the function will return true.
24
+ // That's probably a mistake? /Ads
25
+ it.skip('returns false if the label is an empty string', () => {
26
+ const obj = { label: '', type: 'string' };
27
+ const checkLabel = hasLabel('');
28
+ expect(checkLabel(obj)).toBe(false);
29
+ });
30
+ });
31
+ });
@@ -4,4 +4,9 @@ export * from './property';
4
4
  export * from './repository';
5
5
  export * from './types';
6
6
  export * from './decorator';
7
+ export * from './find-limetype-by-label';
8
+ export * from './get-properties-by-type';
9
+ export * from './get-property-by-label';
10
+ export * from './get-property-by-name';
11
+ export * from './has-label';
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limetype/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limetype/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -4,3 +4,8 @@ export * from './property';
4
4
  export * from './repository';
5
5
  export * from './types';
6
6
  export * from './decorator';
7
+ export * from './find-limetype-by-label';
8
+ export * from './get-properties-by-type';
9
+ export * from './get-property-by-label';
10
+ export * from './get-property-by-name';
11
+ export * from './has-label';
@@ -0,0 +1,49 @@
1
+ import { IdleState } from '../core';
2
+ import { Poller } from './poller';
3
+ /**
4
+ * Factory for creating pollers.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const poller = factory.create(
9
+ * async () => fetchDataFromAPI(),
10
+ * 60000 // Polling every 1 minute
11
+ * );
12
+ *
13
+ * const unsubscribe = poller.subscribe((data) => {
14
+ * console.log('Received data:', data);
15
+ * });
16
+ *
17
+ * unsubscribe();
18
+ * ```
19
+ * @beta
20
+ * @group Poller
21
+ */
22
+ export interface PollerFactory {
23
+ /**
24
+ * Creates a generic poller
25
+ *
26
+ * @param callback - An asynchronous function that will be executed
27
+ * periodically by the poller.
28
+ * @param intervalMs - The interval, in milliseconds, at which the callback
29
+ * should be executed.
30
+ * @returns the poller
31
+ */
32
+ create<T>(callback: () => Promise<T>, intervalMs: number): Poller<T>;
33
+ /**
34
+ * Creates a poller that executes its callback based on the users idle
35
+ * status
36
+ *
37
+ * @param callback - An asynchronous function that will be executed
38
+ * periodically by the poller based on the users idle status.
39
+ * @param intervalMs - The interval, in milliseconds, at which the callback
40
+ * should be executed.
41
+ * @param idleState - The idle state when the poller is active. When set to
42
+ * `active`, the poller will only execute while the user is actively using
43
+ * the application. When set to `idle`, the poller will only execute while
44
+ * the user is idle. Default value is `active`.
45
+ * @returns the poller
46
+ */
47
+ createIdlePoller<T>(callback: () => Promise<T>, intervalMs: number, idleState?: IdleState): Poller<T>;
48
+ }
49
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/poller/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAErE;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,CAAC,EACd,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,SAAS,GACtB,MAAM,CAAC,CAAC,CAAC,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './factory';
2
+ export * from './poller';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/poller/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './factory';
2
+ export * from './poller';
3
+ export * from './types';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A generic interface for a poller that periodically executes a callback and
3
+ * notifies subscribers of the result. The poller manages its lifecycle
4
+ * automatically, ensuring that polling starts when the first subscriber
5
+ * registers and stops when the last subscriber unsubscribes.
6
+ *
7
+ * The poller caches the most recent value from the callback and immediately
8
+ * delivers it to any new subscriber without waiting for the next polling
9
+ * cycle. This ensures that subscribers always receive the latest available
10
+ * data as soon as they register.
11
+ *
12
+ * Consumers are only concerned with subscribing to updates. The poller
13
+ * implementation handles polling intervals, error management, and subscriber
14
+ * lifecycle internally, making it simple and reliable for end users.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Add a subscriber
19
+ * const unsubscribe = poller.subscribe((result) => {
20
+ * console.log('Received data:', result);
21
+ * });
22
+ *
23
+ * // Remove the subscriber
24
+ * unsubscribe();
25
+ * ```
26
+ * @beta
27
+ * @group Poller
28
+ */
29
+ export interface Poller<T> {
30
+ /**
31
+ * Subscribes a callback to receive updates from the poller.
32
+ *
33
+ * When the first subscriber registers, the poller automatically starts
34
+ * polling. Any new subscriber immediately receives the latest cached value,
35
+ * and all subscribers are notified of subsequent polling results.
36
+ *
37
+ * @param callback - A function that will be called with the latest value
38
+ * from the poller callback. If no value is available, the callback will
39
+ * receive `undefined`.
40
+ * @returns A function to unsubscribe from the poller.
41
+ */
42
+ subscribe(callback: (value?: T) => void): () => void;
43
+ /**
44
+ * Immediately forces the poller to trigger its callback and reset the
45
+ * internal timer
46
+ */
47
+ trigger(): void;
48
+ }
49
+ //# sourceMappingURL=poller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../src/poller/poller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAErD;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CACnB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { PollerFactory as PollerFactoryService } from './factory';
2
+ declare const SERVICE_NAME = "pollerFactory";
3
+ declare module '../core/platform' {
4
+ interface PlatformServiceNameType {
5
+ /**
6
+ * @see {@link PollerFactoryService}
7
+ */
8
+ PollerFactory: typeof SERVICE_NAME;
9
+ }
10
+ interface LimeWebComponentPlatform {
11
+ get(name: PlatformServiceNameType['PollerFactory']): PollerFactoryService;
12
+ }
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/poller/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGlE,QAAA,MAAM,YAAY,kBAAkB,CAAC;AAIrC,OAAO,QAAQ,kBAAkB,CAAC;IAC9B,UAAU,uBAAuB;QAC7B;;WAEG;QACH,aAAa,EAAE,OAAO,YAAY,CAAC;KACtC;IAED,UAAU,wBAAwB;QAC9B,GAAG,CACC,IAAI,EAAE,uBAAuB,CAAC,eAAe,CAAC,GAC/C,oBAAoB,CAAC;KAC3B;CACJ"}
@@ -0,0 +1,3 @@
1
+ import { PlatformServiceName } from '../core/platform';
2
+ const SERVICE_NAME = 'pollerFactory';
3
+ PlatformServiceName.PollerFactory = SERVICE_NAME;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-web-components",
3
- "version": "5.38.1",
3
+ "version": "5.40.0",
4
4
  "description": "Lime Web Components",
5
5
  "author": "Lime Technologies",
6
6
  "license": "Apache-2.0",
@@ -30,10 +30,10 @@
30
30
  "dependencies": {
31
31
  "@stencil/core": "^2.22.3",
32
32
  "rxjs": "^7.8.1",
33
- "tslib": "^2.8.0"
33
+ "tslib": "^2.8.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@commitlint/config-conventional": "^19.5.0",
36
+ "@commitlint/config-conventional": "^19.6.0",
37
37
  "@microsoft/api-extractor": "^7.47.11",
38
38
  "@types/jest": "^27.5.0",
39
39
  "@typescript-eslint/eslint-plugin": "^7.5.0",