@looker/embed-services 23.8.1

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 (43) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/lib/EmbedUrl.d.ts +32 -0
  4. package/lib/EmbedUrl.js +91 -0
  5. package/lib/EmbedUrl.js.map +1 -0
  6. package/lib/EntityService.d.ts +9 -0
  7. package/lib/EntityService.js +15 -0
  8. package/lib/EntityService.js.map +1 -0
  9. package/lib/ItemList.d.ts +37 -0
  10. package/lib/ItemList.js +77 -0
  11. package/lib/ItemList.js.map +1 -0
  12. package/lib/ServiceFactory.d.ts +9 -0
  13. package/lib/ServiceFactory.js +46 -0
  14. package/lib/ServiceFactory.js.map +1 -0
  15. package/lib/ThemeService.d.ts +12 -0
  16. package/lib/ThemeService.js +102 -0
  17. package/lib/ThemeService.js.map +1 -0
  18. package/lib/esm/EmbedUrl.js +91 -0
  19. package/lib/esm/EmbedUrl.js.map +1 -0
  20. package/lib/esm/EntityService.js +15 -0
  21. package/lib/esm/EntityService.js.map +1 -0
  22. package/lib/esm/ItemList.js +77 -0
  23. package/lib/esm/ItemList.js.map +1 -0
  24. package/lib/esm/ServiceFactory.js +46 -0
  25. package/lib/esm/ServiceFactory.js.map +1 -0
  26. package/lib/esm/ThemeService.js +102 -0
  27. package/lib/esm/ThemeService.js.map +1 -0
  28. package/lib/esm/index.js +39 -0
  29. package/lib/esm/index.js.map +1 -0
  30. package/lib/esm/test-utils/index.js +17 -0
  31. package/lib/esm/test-utils/index.js.map +1 -0
  32. package/lib/esm/test-utils/utils.js +38 -0
  33. package/lib/esm/test-utils/utils.js.map +1 -0
  34. package/lib/index.d.ts +3 -0
  35. package/lib/index.js +39 -0
  36. package/lib/index.js.map +1 -0
  37. package/lib/test-utils/index.d.ts +1 -0
  38. package/lib/test-utils/index.js +17 -0
  39. package/lib/test-utils/index.js.map +1 -0
  40. package/lib/test-utils/utils.d.ts +10 -0
  41. package/lib/test-utils/utils.js +38 -0
  42. package/lib/test-utils/utils.js.map +1 -0
  43. package/package.json +49 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ ## [23.8.1](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.8.0...embed-services-v23.8.1) (2023-05-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * base class for all services ([#1295](https://github.com/looker-open-source/sdk-codegen/issues/1295)) ([b51f782](https://github.com/looker-open-source/sdk-codegen/commit/b51f782b4da04581e6ef262d26453430916580a8))
9
+ * embed url service ([#1297](https://github.com/looker-open-source/sdk-codegen/issues/1297)) ([0f71acf](https://github.com/looker-open-source/sdk-codegen/commit/0f71acf083043e7056f65b34acd56a617438e4be))
10
+ * QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
11
+ * SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
12
+ * singleton factory and theme service ([#1298](https://github.com/looker-open-source/sdk-codegen/issues/1298)) ([18af00b](https://github.com/looker-open-source/sdk-codegen/commit/18af00b9894b9c19597c3e868161e04b387df20b))
13
+
14
+
15
+ ### Dependencies
16
+
17
+ * The following workspace dependencies were updated
18
+ * dependencies
19
+ * @looker/sdk bumped from ^23.8.0 to ^23.8.1
20
+ * devDependencies
21
+ * @looker/sdk-node bumped from ^23.8.0 to ^23.8.1
22
+
23
+ ## 23.8.0 (2023-05-11)
24
+
25
+
26
+ ### Features
27
+
28
+ * base class for all services ([#1295](https://github.com/looker-open-source/sdk-codegen/issues/1295)) ([b51f782](https://github.com/looker-open-source/sdk-codegen/commit/b51f782b4da04581e6ef262d26453430916580a8))
29
+ * embed url service ([#1297](https://github.com/looker-open-source/sdk-codegen/issues/1297)) ([0f71acf](https://github.com/looker-open-source/sdk-codegen/commit/0f71acf083043e7056f65b34acd56a617438e4be))
30
+ * QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
31
+ * SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
32
+ * singleton factory and theme service ([#1298](https://github.com/looker-open-source/sdk-codegen/issues/1298)) ([18af00b](https://github.com/looker-open-source/sdk-codegen/commit/18af00b9894b9c19597c3e868161e04b387df20b))
33
+
34
+
35
+ ### Dependencies
36
+
37
+ * The following workspace dependencies were updated
38
+ * dependencies
39
+ * @looker/sdk bumped from ^23.6.0 to ^23.8.0
40
+ * devDependencies
41
+ * @looker/sdk-node bumped from ^23.4.0 to ^23.8.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Looker Data Sciences, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ export declare enum ContentType {
2
+ Look = "look",
3
+ Explore = "explore",
4
+ Dashboard = "dashboard",
5
+ Invalid = "invalid"
6
+ }
7
+ export interface IEmbedUrl {
8
+ readonly url: string;
9
+ readonly path: string;
10
+ readonly searchParams: Record<string, string>;
11
+ readonly isDashboard: boolean;
12
+ readonly isExplore: boolean;
13
+ readonly isLook: boolean;
14
+ readonly contentType: ContentType;
15
+ readonly isThemable: boolean;
16
+ embedUrl(includeSearchParams: boolean, overrides: Record<string, any>): string;
17
+ }
18
+ export declare class EmbedUrl implements IEmbedUrl {
19
+ private _url;
20
+ readonly path: string;
21
+ readonly searchParams: Record<string, string>;
22
+ readonly isDashboard: boolean;
23
+ readonly isExplore: boolean;
24
+ readonly isLook: boolean;
25
+ readonly isThemable: boolean;
26
+ readonly contentType: ContentType;
27
+ private readonly _embedUrl;
28
+ constructor(url?: string);
29
+ get url(): string;
30
+ protected type(): ContentType;
31
+ embedUrl(includeSearchParams?: boolean, overrides?: Record<string, any>): string;
32
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EmbedUrl = exports.ContentType = void 0;
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
+ var ContentType = function (ContentType) {
11
+ ContentType["Look"] = "look";
12
+ ContentType["Explore"] = "explore";
13
+ ContentType["Dashboard"] = "dashboard";
14
+ ContentType["Invalid"] = "invalid";
15
+ return ContentType;
16
+ }({});
17
+ exports.ContentType = ContentType;
18
+ var THEMABLE_CONTENT = [ContentType.Dashboard, ContentType.Explore];
19
+ class EmbedUrl {
20
+ constructor() {
21
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.href;
22
+ _defineProperty(this, "_url", void 0);
23
+ _defineProperty(this, "path", void 0);
24
+ _defineProperty(this, "searchParams", void 0);
25
+ _defineProperty(this, "isDashboard", void 0);
26
+ _defineProperty(this, "isExplore", void 0);
27
+ _defineProperty(this, "isLook", void 0);
28
+ _defineProperty(this, "isThemable", void 0);
29
+ _defineProperty(this, "contentType", void 0);
30
+ _defineProperty(this, "_embedUrl", void 0);
31
+ this._url = new URL(url);
32
+ this.searchParams = Object.fromEntries(this._url.searchParams);
33
+ this.path = this._url.pathname;
34
+ this.isDashboard = /^(\/embed)?\/dashboards\//i.test(this.path);
35
+ this.isExplore = /^(\/embed)?\/explore\//i.test(this.path);
36
+ this.isLook = /^(\/embed)?\/looks\//i.test(this.path);
37
+ this.contentType = this.type();
38
+ if (this.path.startsWith('/embed/')) {
39
+ this._embedUrl = "".concat(this._url.origin).concat(this._url.pathname);
40
+ } else {
41
+ this._embedUrl = "".concat(this._url.origin, "/embed").concat(this._url.pathname);
42
+ }
43
+ this.isThemable = THEMABLE_CONTENT.includes(this.contentType);
44
+ }
45
+ get url() {
46
+ return this._url.href;
47
+ }
48
+ type() {
49
+ var type;
50
+ if (this.isLook) {
51
+ type = ContentType.Look;
52
+ } else if (this.isExplore) {
53
+ type = ContentType.Explore;
54
+ } else if (this.isDashboard) {
55
+ type = ContentType.Dashboard;
56
+ } else {
57
+ type = ContentType.Invalid;
58
+ }
59
+ return type;
60
+ }
61
+ embedUrl() {
62
+ var includeSearchParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
63
+ var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
+ if (this.contentType === ContentType.Invalid) {
65
+ throw new Error('Invalid content type');
66
+ }
67
+ var embedUrlParams = includeSearchParams ? this.searchParams : {};
68
+ if (overrides) {
69
+ Object.entries(overrides).forEach(_ref => {
70
+ var [key, value] = _ref;
71
+ var overrideValue = value;
72
+ if (typeof value === 'object') {
73
+ overrideValue = JSON.stringify(value);
74
+ }
75
+ if (key === 'theme' && overrideValue === 'Looker') {
76
+ delete embedUrlParams.theme;
77
+ } else {
78
+ embedUrlParams[key] = overrideValue;
79
+ }
80
+ });
81
+ }
82
+ var searchString = '';
83
+ if (Object.keys(embedUrlParams).length > 0) {
84
+ searchString = '?' + new URLSearchParams(embedUrlParams).toString();
85
+ }
86
+ var url = new URL("".concat(this._embedUrl).concat(searchString));
87
+ return url.href;
88
+ }
89
+ }
90
+ exports.EmbedUrl = EmbedUrl;
91
+ //# sourceMappingURL=EmbedUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbedUrl.js","names":["ContentType","exports","THEMABLE_CONTENT","Dashboard","Explore","EmbedUrl","constructor","url","arguments","length","undefined","window","location","href","_defineProperty","_url","URL","searchParams","Object","fromEntries","path","pathname","isDashboard","test","isExplore","isLook","contentType","type","startsWith","_embedUrl","concat","origin","isThemable","includes","Look","Invalid","embedUrl","includeSearchParams","overrides","Error","embedUrlParams","entries","forEach","_ref","key","value","overrideValue","JSON","stringify","theme","searchString","keys","URLSearchParams","toString"],"sources":["../src/EmbedUrl.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport enum ContentType {\n Look = 'look',\n Explore = 'explore',\n Dashboard = 'dashboard',\n Invalid = 'invalid',\n}\n\nconst THEMABLE_CONTENT: ContentType[] = [\n ContentType.Dashboard,\n ContentType.Explore,\n]\n\nexport interface IEmbedUrl {\n readonly url: string\n readonly path: string\n readonly searchParams: Record<string, string>\n readonly isDashboard: boolean\n readonly isExplore: boolean\n readonly isLook: boolean\n readonly contentType: ContentType\n readonly isThemable: boolean\n embedUrl(includeSearchParams: boolean, overrides: Record<string, any>): string\n}\n\n/**\n * A class for use when implementer requires components to be context aware\n */\nexport class EmbedUrl implements IEmbedUrl {\n /** Current url */\n private _url: URL\n /** Path of the current page */\n readonly path: string\n /** Search string of the current url */\n readonly searchParams: Record<string, string>\n /** Determines whether the current URL is for a Dashboard */\n readonly isDashboard: boolean\n /** Determines whether the current URL is for an Explore */\n readonly isExplore: boolean\n /** Determines whether the current URl is for a Look */\n readonly isLook: boolean\n /** Determines if current URL represents themable content */\n readonly isThemable: boolean\n /** Type of content the URL represents */\n readonly contentType: ContentType\n private readonly _embedUrl: string\n\n constructor(url = window.location.href) {\n this._url = new URL(url)\n this.searchParams = Object.fromEntries(this._url.searchParams)\n this.path = this._url.pathname\n this.isDashboard = /^(\\/embed)?\\/dashboards\\//i.test(this.path)\n this.isExplore = /^(\\/embed)?\\/explore\\//i.test(this.path)\n this.isLook = /^(\\/embed)?\\/looks\\//i.test(this.path)\n this.contentType = this.type()\n\n if (this.path.startsWith('/embed/')) {\n this._embedUrl = `${this._url.origin}${this._url.pathname}`\n } else {\n this._embedUrl = `${this._url.origin}/embed${this._url.pathname}`\n }\n\n this.isThemable = THEMABLE_CONTENT.includes(this.contentType)\n }\n\n get url() {\n return this._url.href\n }\n\n protected type() {\n let type: ContentType\n if (this.isLook) {\n type = ContentType.Look\n } else if (this.isExplore) {\n type = ContentType.Explore\n } else if (this.isDashboard) {\n type = ContentType.Dashboard\n } else {\n type = ContentType.Invalid\n }\n return type\n }\n\n /**\n * Builds the embed target url\n * @param includeSearchParams switch determining whether to include search params from target url\n * @param overrides any search key values to include in embed url e.g. 'k1=v1&k2=v2'\n */\n embedUrl(includeSearchParams = false, overrides: Record<string, any> = {}) {\n if (this.contentType === ContentType.Invalid) {\n throw new Error('Invalid content type')\n }\n\n const embedUrlParams = includeSearchParams ? this.searchParams : {}\n\n if (overrides) {\n Object.entries(overrides).forEach(([key, value]) => {\n let overrideValue = value\n if (typeof value === 'object') {\n overrideValue = JSON.stringify(value)\n }\n if (key === 'theme' && overrideValue === 'Looker') {\n delete embedUrlParams.theme\n } else {\n embedUrlParams[key] = overrideValue\n }\n })\n }\n\n let searchString = ''\n if (Object.keys(embedUrlParams).length > 0) {\n searchString = '?' + new URLSearchParams(embedUrlParams).toString()\n }\n\n const url = new URL(`${this._embedUrl}${searchString}`)\n return url.href\n }\n}\n"],"mappings":";;;;;;;;;IA0BYA,WAAW,aAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAAAC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAOvB,IAAME,gBAA+B,GAAG,CACtCF,WAAW,CAACG,SAAS,EACrBH,WAAW,CAACI,OAA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H,KAAK,CAAC;QACvC;QACA,IAAID,GAAG,KAAK,OAAO,IAAIE,aAAa,KAAK,QAAQ,EAAE;UACjD,OAAON,cAAc,CAACS,KAAK;QAC7B,CAAC,MAAM;UACLT,cAAc,CAACI,GAAG,CAAC,GAAGE,aAAa;QACrC;MACF,CAAC,CAAC;IACJ;IAEA,IAAII,YAAY,GAAG,EAAE;IACrB,IAAIhC,MAAM,CAACiC,IAAI,CAACX,cAAc,CAAC,CAAC/B,MAAM,GAAG,CAAC,EAAE;MAC1CyC,YAAY,GAAG,GAAG,GAAG,IAAIE,eAAe,CAACZ,cAAc,CAAC,CAACa,QAAQ,EAAE;IACrE;IAEA,IAAM9C,GAAG,GAAG,IAAIS,GAAG,IAAAc,MAAA,CAAI,IAAI,CAACD,SAAS,EAAAC,MAAA,CAAGoB,YAAY,EAAG;IACvD,OAAO3C,GAAG,CAACM,IAAI;EACjB;AACF;AAACZ,OAAA,CAAAI,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,9 @@
1
+ import type { IAPIMethods } from '@looker/sdk-rtl';
2
+ export interface IEmbedService {
3
+ get sdk(): IAPIMethods;
4
+ }
5
+ export declare abstract class EntityService implements IEmbedService {
6
+ sdk: IAPIMethods;
7
+ readonly timeToLive: number;
8
+ constructor(sdk: IAPIMethods, timeToLive?: number);
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EntityService = void 0;
7
+ class EntityService {
8
+ constructor(sdk) {
9
+ var timeToLive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 900;
10
+ this.sdk = sdk;
11
+ this.timeToLive = timeToLive;
12
+ }
13
+ }
14
+ exports.EntityService = EntityService;
15
+ //# sourceMappingURL=EntityService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityService.js","names":["EntityService","constructor","sdk","timeToLive","arguments","length","undefined","exports"],"sources":["../src/EntityService.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IAPIMethods } from '@looker/sdk-rtl'\n\nexport interface IEmbedService {\n /** Instantiated browser sdk */\n get sdk(): IAPIMethods\n}\n\nexport abstract class EntityService implements IEmbedService {\n /**\n *\n * @param sdk\n * @param timeToLive\n */\n constructor(public sdk: IAPIMethods, readonly timeToLive = 900) {}\n}\n"],"mappings":";;;;;;AAiCO,MAAeA,aAAa,CAA0B;EAM3DC,WAAWA,CAAQC,GAAgB,EAA6B;IAAA,IAAlBC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,KAA3CF,GAAgB,GAAhBA,GAAgB;IAAA,KAAWC,UAAU,GAAVA,UAAU;EAAS;AACnE;AAACI,OAAA,CAAAP,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,37 @@
1
+ import type { IAPIMethods } from '@looker/sdk-rtl';
2
+ import { EntityService } from './EntityService';
3
+ export declare const DEFAULT_TTL = 900;
4
+ export interface GetOptions {
5
+ useCache?: boolean;
6
+ [key: string]: any;
7
+ }
8
+ export interface IItemList<T> {
9
+ readonly timeToLive: number;
10
+ items: T[];
11
+ readonly expiresAt: number;
12
+ index(key?: keyof T): ItemList<T>;
13
+ indexedItems: Record<string, T>;
14
+ expired(): boolean;
15
+ setExpiration(): void;
16
+ clearIfExpired(): void;
17
+ find(key: keyof T | Array<keyof T>, value: any): T | undefined;
18
+ }
19
+ export interface IEntityService<T> extends IItemList<T> {
20
+ get(id: string, options?: GetOptions): Promise<T>;
21
+ set(id: string, item: T): Promise<T>;
22
+ getAll(...options: any[]): Promise<IItemList<T>>;
23
+ delete(id: string): void;
24
+ }
25
+ export declare abstract class ItemList<T extends Record<string, any>> extends EntityService implements IItemList<T> {
26
+ items: T[];
27
+ indexedItems: Record<string, T>;
28
+ expiresAt: number;
29
+ private keyField;
30
+ constructor(sdk: IAPIMethods, timeToLive?: number);
31
+ index(key?: keyof T): this;
32
+ setExpiration(): void;
33
+ expired(): boolean;
34
+ clearIfExpired(): void;
35
+ find(key: keyof T | Array<keyof T>, expression: string): T | undefined;
36
+ getCacheDefault(options?: GetOptions): boolean | undefined;
37
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ItemList = exports.DEFAULT_TTL = void 0;
7
+ var _EntityService = require("./EntityService");
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ var DEFAULT_TTL = 900;
12
+ exports.DEFAULT_TTL = DEFAULT_TTL;
13
+ class ItemList extends _EntityService.EntityService {
14
+ constructor(sdk) {
15
+ var timeToLive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_TTL;
16
+ super(sdk, timeToLive);
17
+ _defineProperty(this, "items", []);
18
+ _defineProperty(this, "indexedItems", {});
19
+ _defineProperty(this, "expiresAt", 0);
20
+ _defineProperty(this, "keyField", 'id');
21
+ }
22
+ index() {
23
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.keyField;
24
+ this.keyField = key;
25
+ this.indexedItems = {};
26
+ this.items.forEach(el => {
27
+ if (el && el !== null && el !== void 0 && el[this.keyField]) {
28
+ this.indexedItems[el[this.keyField]] = el;
29
+ }
30
+ });
31
+ return this;
32
+ }
33
+ setExpiration() {
34
+ this.expiresAt = Date.now() + this.timeToLive * 1000;
35
+ }
36
+ expired() {
37
+ return this.expiresAt <= Date.now();
38
+ }
39
+ clearIfExpired() {
40
+ if (this.expired()) {
41
+ this.items = [];
42
+ this.indexedItems = {};
43
+ }
44
+ }
45
+ find(key, expression) {
46
+ var result;
47
+ var keys;
48
+ if (typeof key === 'string') {
49
+ keys = [key];
50
+ } else {
51
+ keys = key;
52
+ }
53
+ var rx;
54
+ try {
55
+ rx = new RegExp(expression, 'i');
56
+ for (var _item of this.items) {
57
+ for (var k of keys) {
58
+ var _item$k;
59
+ var match = (_item$k = _item[k]) === null || _item$k === void 0 ? void 0 : _item$k.toString().match(rx);
60
+ if (match) {
61
+ result = _item;
62
+ return result;
63
+ }
64
+ }
65
+ }
66
+ return result;
67
+ } catch (e) {
68
+ throw new Error(e);
69
+ }
70
+ }
71
+ getCacheDefault(options) {
72
+ var cache = options && 'useCache' in options ? options.useCache : true;
73
+ return cache;
74
+ }
75
+ }
76
+ exports.ItemList = ItemList;
77
+ //# sourceMappingURL=ItemList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemList.js","names":["_EntityService","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","DEFAULT_TTL","exports","ItemList","EntityService","constructor","sdk","timeToLive","arguments","length","index","keyField","indexedItems","items","forEach","el","setExpiration","expiresAt","Date","now","expired","clearIfExpired","find","expression","result","keys","rx","RegExp","item","k","_item$k","match","toString","e","Error","getCacheDefault","options","cache","useCache"],"sources":["../src/ItemList.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport { EntityService } from './EntityService'\n\nexport const DEFAULT_TTL = 900 // 15 minutes\n\nexport interface GetOptions {\n useCache?: boolean\n [key: string]: any\n}\n\nexport interface IItemList<T> {\n /** Cache time to live in seconds, defaults to 15 minutes */\n readonly timeToLive: number\n items: T[]\n readonly expiresAt: number\n index(key?: keyof T): ItemList<T>\n indexedItems: Record<string, T>\n expired(): boolean\n setExpiration(): void\n clearIfExpired(): void\n find(key: keyof T | Array<keyof T>, value: any): T | undefined\n}\n\nexport interface IEntityService<T> extends IItemList<T> {\n get(id: string, options?: GetOptions): Promise<T>\n set(id: string, item: T): Promise<T>\n getAll(...options: any[]): Promise<IItemList<T>>\n delete(id: string): void\n}\n\nexport abstract class ItemList<T extends Record<string, any>>\n extends EntityService\n implements IItemList<T>\n{\n /** Cached items */\n items: T[] = []\n /** An indexed collection of items */\n indexedItems: Record<string, T> = {}\n /** Time when cache expires */\n expiresAt = 0\n /** Key to index by */\n private keyField = 'id'\n\n constructor(sdk: IAPIMethods, timeToLive = DEFAULT_TTL) {\n super(sdk, timeToLive)\n }\n\n /**\n * Creates an indexed collection from the cached items\n */\n index(key: keyof T = this.keyField) {\n this.keyField = key as string\n this.indexedItems = {}\n this.items.forEach((el) => {\n if (el && el?.[this.keyField]) {\n this.indexedItems[el[this.keyField]] = el\n }\n })\n return this\n }\n\n /** Computes the expiration time based on timeToLive */\n setExpiration() {\n this.expiresAt = Date.now() + this.timeToLive * 1000\n }\n\n /**\n * Determines if the cache has expired\n */\n expired() {\n return this.expiresAt <= Date.now()\n }\n\n /**\n * Ejects cache if expired\n */\n clearIfExpired() {\n if (this.expired()) {\n this.items = []\n this.indexedItems = {}\n }\n }\n\n /**\n * Searches the collection for an item with the specified key/value pair\n * @param key or keys to search\n * @param expression to match\n */\n find(key: keyof T | Array<keyof T>, expression: string): T | undefined {\n let result: T | undefined\n let keys: Array<keyof T>\n\n if (typeof key === 'string') {\n keys = [key]\n } else {\n keys = key as Array<keyof T>\n }\n\n let rx: RegExp\n try {\n rx = new RegExp(expression, 'i')\n\n for (const item of this.items) {\n for (const k of keys) {\n const match = item[k]?.toString().match(rx)\n if (match) {\n result = item as T\n return result\n }\n }\n }\n return result\n } catch (e: any) {\n throw new Error(e)\n }\n }\n\n /**\n * Gets the cache option value if present, otherwise defaults to true\n * @param options to check\n */\n getCacheDefault(options?: GetOptions) {\n const cache = options && 'useCache' in options ? options.useCache : true\n return cache\n }\n}\n"],"mappings":";;;;;;AA2BA,IAAAA,cAAA,GAAAC,OAAA;AAA+C,SAAAC,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAExC,IAAMU,WAAW,GAAG,GAAG;AAAAC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AA2BvB,MAAeE,QAAQ,SACpBC,4BAAa,CAEvB;EAUEC,WAAWA,CAACC,GAAgB,EAA4B;IAAA,IAA1BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAZ,SAAA,GAAAY,SAAA,MAAGP,WAAW;IACpD,KAAK,CAACK,GAAG,EAAEC,UAAU,CAAC;IAAA7B,eAAA,gBATX,EAAE;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AAU;IACd,IAAI;MACFA,EAAE,GAAG,IAAIC,MAAM,CAACJ,UAAU,EAAE,GAAG,CAAC;MAEhC,KAAK,IAAMK,KAAI,IAAI,IAAI,CAACf,KAAK,EAAE;QAC7B,KAAK,IAAMgB,CAAC,IAAIJ,IAAI,EAAE;UAAA,IAAAK,OAAA;UACpB,IAAMC,KAAK,IAAAD,OAAA,GAAGF,KAAI,CAACC,CAAC,CAAC,cAAAC,OAAA,uBAAPA,OAAA,CAASE,QAAQ,EAAE,CAACD,KAAK,CAACL,EAAE,CAAC;UAC3C,IAAIK,KAAK,EAAE;YACTP,MAAM,GAAGI,KAAS;YAClB,OAAOJ,MAAM;UACf;QACF;MACF;MACA,OAAOA,MAAM;IACf,CAAC,CAAC,OAAOS,CAAM,EAAE;MACf,MAAM,IAAIC,KAAK,CAACD,CAAC,CAAC;IACpB;EACF;EAMAE,eAAeA,CAACC,OAAoB,EAAE;IACpC,IAAMC,KAAK,GAAGD,OAAO,IAAI,UAAU,IAAIA,OAAO,GAAGA,OAAO,CAACE,QAAQ,GAAG,IAAI;IACxE,OAAOD,KAAK;EACd;AACF;AAACnC,OAAA,CAAAC,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,9 @@
1
+ import type { IAPIMethods } from '@looker/sdk-rtl';
2
+ export declare type ServiceCreatorFunc<T> = (sdk: IAPIMethods, timeToLive?: number) => T;
3
+ export interface IServiceFactory {
4
+ get<T>(serviceName: string): T;
5
+ register<T>(serviceName: string, serviceCreator: ServiceCreatorFunc<T>, timeToLive?: number): void;
6
+ }
7
+ export declare function createFactory(sdk: IAPIMethods): void;
8
+ export declare function getFactory(): IServiceFactory;
9
+ export declare function destroyFactory(): void;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFactory = createFactory;
7
+ exports.destroyFactory = destroyFactory;
8
+ exports.getFactory = getFactory;
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ class ServiceFactory {
13
+ constructor(sdk) {
14
+ this.sdk = sdk;
15
+ _defineProperty(this, "servicesMap", {});
16
+ }
17
+ get(serviceName) {
18
+ var service = this.servicesMap[serviceName];
19
+ if (!service) {
20
+ throw new Error("Service ".concat(serviceName, " not found"));
21
+ }
22
+ return service;
23
+ }
24
+ register(serviceName, serviceCreator, timeToLive) {
25
+ var service = this.servicesMap[serviceName];
26
+ if (!service) {
27
+ service = serviceCreator(this.sdk, timeToLive);
28
+ this.servicesMap[serviceName] = service;
29
+ }
30
+ return service;
31
+ }
32
+ }
33
+ var factory;
34
+ function createFactory(sdk) {
35
+ factory = new ServiceFactory(sdk);
36
+ }
37
+ function getFactory() {
38
+ if (!factory) {
39
+ throw new Error('Factory must be created with an SDK.');
40
+ }
41
+ return factory;
42
+ }
43
+ function destroyFactory() {
44
+ factory = undefined;
45
+ }
46
+ //# sourceMappingURL=ServiceFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceFactory.js","names":["ServiceFactory","constructor","sdk","_defineProperty","get","serviceName","service","servicesMap","Error","concat","register","serviceCreator","timeToLive","factory","createFactory","getFactory","destroyFactory","undefined"],"sources":["../src/ServiceFactory.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IAPIMethods } from '@looker/sdk-rtl'\n\nexport type ServiceCreatorFunc<T> = (sdk: IAPIMethods, timeToLive?: number) => T\n\nexport interface IServiceFactory {\n get<T>(serviceName: string): T\n register<T>(\n serviceName: string,\n serviceCreator: ServiceCreatorFunc<T>,\n timeToLive?: number\n ): void\n}\n\n/**\n * A factory for registering and maintaining services\n */\nclass ServiceFactory implements IServiceFactory {\n servicesMap: Record<string, any> = {}\n constructor(private sdk: IAPIMethods) {}\n\n get<T>(serviceName: string): T {\n const service = this.servicesMap[serviceName]\n if (!service) {\n throw new Error(`Service ${serviceName} not found`)\n }\n return service\n }\n\n /**\n * Registers or creates a service\n * @param serviceName name of service.\n * @param serviceCreator function that creates the service.\n * @param timeToLive in seconds, for the service cache. Defaults to 15 minutes.\n */\n register<T>(\n serviceName: string,\n serviceCreator: ServiceCreatorFunc<T>,\n timeToLive?: number\n ) {\n let service = this.servicesMap[serviceName]\n if (!service) {\n service = serviceCreator(this.sdk, timeToLive)\n this.servicesMap[serviceName] = service\n }\n return service\n }\n}\n\nlet factory: IServiceFactory | undefined\n\n/**\n * Helper method for creating a singleton factory\n * @param sdk\n */\nexport function createFactory(sdk: IAPIMethods) {\n factory = new ServiceFactory(sdk)\n}\n\n/**\n * Helper method for getting the factory\n */\nexport function getFactory() {\n if (!factory) {\n throw new Error('Factory must be created with an SDK.')\n }\n return factory\n}\n\n/**\n * Helper method for destroying the factory\n */\nexport function destroyFactory() {\n factory = undefined\n}\n"],"mappings":";;;;;;;;;;;AAyCA,MAAMA,cAAc,CAA4B;EAE9CC,WAAWA,CAASC,GAAgB,EAAE;IAAA,KAAlBA,GAAgB,GAAhBA,GAAgB;IAAAC,eAAA,sBADD,CAAC,CAAC;EACE;EAEvCC,GAAGA,CAAIC,WAAmB,EAAK;IAC7B,IAAMC,OAAO,GAAG,IAAI,CAACC,WAAW,CAACF,WAAW,CAAC;IAC7C,IAAI,CAACC,OAAO,EAAE;MACZ,MAAM,IAAIE,KAAK,YAAAC,MAAA,CAAYJ,WAAW,gBAAa;IACrD;IACA,OAAOC,OAAO;EAChB;EAQAI,QAAQA,CACNL,WAAmB,EACnBM,cAAqC,EACrCC,UAAmB,EACnB;IACA,IAAIN,OAAO,GAAG,IAAI,CAACC,WAAW,CAACF,WAAW,CAAC;IAC3C,IAAI,CAACC,OAAO,EAAE;MACZA,OAAO,GAAGK,cAAc,CAAC,IAAI,CAACT,GAAG,EAAEU,UAAU,CAAC;MAC9C,IAAI,CAACL,WAAW,CAACF,WAAW,CAAC,GAAGC,OAAO;IACzC;IACA,OAAOA,OAAO;EAChB;AACF;AAEA,IAAIO,OAAoC;AAMjC,SAASC,aAAaA,CAACZ,GAAgB,EAAE;EAC9CW,OAAO,GAAG,IAAIb,cAAc,CAACE,GAAG,CAAC;AACnC;AAKO,SAASa,UAAUA,CAAA,EAAG;EAC3B,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIL,KAAK,CAAC,sCAAsC,CAAC;EACzD;EACA,OAAOK,OAAO;AAChB;AAKO,SAASG,cAAcA,CAAA,EAAG;EAC/BH,OAAO,GAAGI,SAAS;AACrB"}
@@ -0,0 +1,12 @@
1
+ import type { ITheme } from '@looker/sdk';
2
+ import type { IEntityService, IItemList, GetOptions } from './ItemList';
3
+ import type { ServiceCreatorFunc } from './ServiceFactory';
4
+ export interface IThemeService extends IItemList<ITheme>, IEntityService<ITheme> {
5
+ defaultTheme?: ITheme;
6
+ getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>;
7
+ load(options?: GetOptions): Promise<IThemeService>;
8
+ }
9
+ export declare const THEME_SERVICE_NAME = "ThemeService";
10
+ export declare const themeServiceCreator: ServiceCreatorFunc<IThemeService>;
11
+ export declare const registerThemeService: (timeToLive?: number | undefined) => void;
12
+ export declare const getThemeService: () => IThemeService;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.themeServiceCreator = exports.registerThemeService = exports.getThemeService = exports.THEME_SERVICE_NAME = void 0;
7
+ var _sdk = require("@looker/sdk");
8
+ var _ItemList = require("./ItemList");
9
+ var _ServiceFactory = require("./ServiceFactory");
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ class ThemeService extends _ItemList.ItemList {
16
+ constructor() {
17
+ super(...arguments);
18
+ _defineProperty(this, "defaultTheme", void 0);
19
+ }
20
+ get(id, options) {
21
+ var _this = this;
22
+ return _asyncToGenerator(function* () {
23
+ var cache = _this.getCacheDefault(options);
24
+ _this.clearIfExpired();
25
+ var item = _this.indexedItems[id];
26
+ if (cache && item) {
27
+ return item;
28
+ }
29
+ item = yield _this.sdk.ok((0, _sdk.theme)(_this.sdk, id, options === null || options === void 0 ? void 0 : options.fields));
30
+ if (item) {
31
+ _this.items = [..._this.items, item];
32
+ _this.index();
33
+ _this.setExpiration();
34
+ }
35
+ return item;
36
+ })();
37
+ }
38
+ getAll(options) {
39
+ var _this2 = this;
40
+ return _asyncToGenerator(function* () {
41
+ if (_this2.getCacheDefault(options) && !_this2.expired()) {
42
+ return _this2;
43
+ }
44
+ yield _this2.load(options);
45
+ return _this2;
46
+ })();
47
+ }
48
+ set(id, item) {
49
+ var _this3 = this;
50
+ return _asyncToGenerator(function* () {
51
+ _this3.clearIfExpired();
52
+ var theme = yield _this3.sdk.ok((0, _sdk.update_theme)(_this3.sdk, id, item));
53
+ if (theme) {
54
+ _this3.items = [..._this3.items, theme];
55
+ _this3.index();
56
+ _this3.setExpiration();
57
+ }
58
+ return theme;
59
+ })();
60
+ }
61
+ getDefaultTheme(ts) {
62
+ var _this4 = this;
63
+ return _asyncToGenerator(function* () {
64
+ if (_this4.expired()) {
65
+ _this4.defaultTheme = yield _this4.sdk.ok((0, _sdk.default_theme)(_this4.sdk, ts));
66
+ }
67
+ return _this4.defaultTheme;
68
+ })();
69
+ }
70
+ delete(id) {
71
+ var _this5 = this;
72
+ return _asyncToGenerator(function* () {
73
+ _this5.clearIfExpired();
74
+ yield _this5.sdk.ok((0, _sdk.delete_theme)(_this5.sdk, id));
75
+ _this5.items = _this5.items.filter(item => item.id !== id);
76
+ _this5.index();
77
+ })();
78
+ }
79
+ load(options) {
80
+ var _this6 = this;
81
+ return _asyncToGenerator(function* () {
82
+ yield _this6.getDefaultTheme();
83
+ _this6.items = yield _this6.sdk.ok((0, _sdk.all_themes)(_this6.sdk, options === null || options === void 0 ? void 0 : options.fields));
84
+ _this6.index();
85
+ _this6.setExpiration();
86
+ return _this6;
87
+ })();
88
+ }
89
+ }
90
+ var THEME_SERVICE_NAME = 'ThemeService';
91
+ exports.THEME_SERVICE_NAME = THEME_SERVICE_NAME;
92
+ var themeServiceCreator = (sdk, timeToLive) => {
93
+ return new ThemeService(sdk, timeToLive);
94
+ };
95
+ exports.themeServiceCreator = themeServiceCreator;
96
+ var registerThemeService = timeToLive => {
97
+ (0, _ServiceFactory.getFactory)().register(THEME_SERVICE_NAME, themeServiceCreator, timeToLive);
98
+ };
99
+ exports.registerThemeService = registerThemeService;
100
+ var getThemeService = () => (0, _ServiceFactory.getFactory)().get(THEME_SERVICE_NAME);
101
+ exports.getThemeService = getThemeService;
102
+ //# sourceMappingURL=ThemeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeService.js","names":["_sdk","require","_ItemList","_ServiceFactory","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","_defineProperty","obj","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","res","call","TypeError","Number","ThemeService","ItemList","constructor","get","id","options","_this","cache","getCacheDefault","clearIfExpired","item","indexedItems","sdk","ok","theme","fields","items","index","setExpiration","getAll","_this2","expired","load","set","_this3","update_theme","getDefaultTheme","ts","_this4","defaultTheme","default_theme","delete","_this5","delete_theme","filter","_this6","all_themes","THEME_SERVICE_NAME","exports","themeServiceCreator","timeToLive","registerThemeService","getFactory","register","getThemeService"],"sources":["../src/ThemeService.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { ITheme } from '@looker/sdk'\nimport {\n all_themes,\n default_theme,\n delete_theme,\n theme,\n update_theme,\n} from '@looker/sdk'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport { ItemList } from './ItemList'\nimport type { IEntityService, IItemList, GetOptions } from './ItemList'\nimport type { ServiceCreatorFunc } from './ServiceFactory'\nimport { getFactory } from './ServiceFactory'\n\nexport interface IThemeService\n extends IItemList<ITheme>,\n IEntityService<ITheme> {\n defaultTheme?: ITheme\n getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>\n load(options?: GetOptions): Promise<IThemeService>\n}\n\nclass ThemeService extends ItemList<ITheme> implements IThemeService {\n public defaultTheme?: ITheme\n\n /**\n * Get theme by id\n * @param id of theme to retrieve\n * @param options to get\n */\n async get(id: string, options?: GetOptions): Promise<Partial<ITheme>> {\n // TODO: implement logic to check if requested fields are already cached.\n const cache = this.getCacheDefault(options)\n this.clearIfExpired()\n let item = this.indexedItems[id]\n\n if (cache && item) {\n return item\n }\n\n item = await this.sdk.ok(theme(this.sdk, id, options?.fields))\n\n if (item) {\n this.items = [...this.items, item]\n this.index()\n this.setExpiration()\n }\n return item\n }\n\n /**\n * Get all themes, including the default theme\n * @param options to get\n */\n async getAll(options?: GetOptions) {\n if (this.getCacheDefault(options) && !this.expired()) {\n return this\n }\n await this.load(options)\n return this\n }\n\n /**\n * Updates a theme\n * @param id id of theme to update\n * @param item with updated fields\n */\n async set(id: string, item: ITheme) {\n this.clearIfExpired()\n const theme = await this.sdk.ok(update_theme(this.sdk, id, item))\n if (theme) {\n this.items = [...this.items, theme]\n this.index()\n this.setExpiration()\n }\n return theme\n }\n\n /**\n * Gets the default theme\n * @param ts Timestamp representing the target datetime for the active period. Defaults to 'now'\n */\n async getDefaultTheme(ts?: Date) {\n if (this.expired()) {\n this.defaultTheme = await this.sdk.ok(default_theme(this.sdk, ts))\n }\n return this.defaultTheme as ITheme\n }\n\n /**\n * Deletes a theme\n * @param id of theme to delete\n */\n async delete(id: string) {\n this.clearIfExpired()\n await this.sdk.ok(delete_theme(this.sdk, id))\n this.items = this.items.filter((item) => item.id !== id)\n this.index()\n }\n\n /**\n * Retrieves all themes and the default theme\n */\n async load(options?: GetOptions) {\n await this.getDefaultTheme()\n this.items = await this.sdk.ok(all_themes(this.sdk, options?.fields))\n this.index()\n this.setExpiration()\n return this\n }\n}\n\nexport const THEME_SERVICE_NAME = 'ThemeService'\n\n/**\n * A theme service creator helper function\n * @param sdk\n * @param timeToLive in seconds for the cache\n */\nexport const themeServiceCreator: ServiceCreatorFunc<IThemeService> = (\n sdk: IAPIMethods,\n timeToLive?: number\n) => {\n return new ThemeService(sdk, timeToLive)\n}\n\n/**\n * Creates and registers the theme service with the service factory\n * @param timeToLive in seconds for the cache\n */\nexport const registerThemeService = (timeToLive?: number) => {\n getFactory().register(THEME_SERVICE_NAME, themeServiceCreator, timeToLive)\n}\n\n/**\n * Gets the the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