@looker/embed-services 23.20.0 → 24.2.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## [23.20.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.18.0...embed-services-v23.20.0) (2023-11-30)
3
+ ## [24.2.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v24.0.0...embed-services-v24.2.0) (2024-02-21)
4
4
 
5
5
 
6
6
  ### Miscellaneous Chores
@@ -12,11 +12,11 @@
12
12
 
13
13
  * The following workspace dependencies were updated
14
14
  * dependencies
15
- * @looker/sdk bumped from ^23.18.0 to ^23.20.0
15
+ * @looker/sdk bumped from 24.0.0 to 24.2.0
16
16
  * devDependencies
17
- * @looker/sdk-node bumped from ^23.18.0 to ^23.20.0
17
+ * @looker/sdk-node bumped from 24.0.0 to 24.2.0
18
18
 
19
- ## [23.18.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.16.0...embed-services-v23.18.0) (2023-11-22)
19
+ ## [24.0.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.20.1...embed-services-v24.0.0) (2024-02-03)
20
20
 
21
21
 
22
22
  ### Miscellaneous Chores
@@ -28,111 +28,141 @@
28
28
 
29
29
  * The following workspace dependencies were updated
30
30
  * dependencies
31
- * @looker/sdk bumped from ^23.16.0 to ^23.18.0
31
+ * @looker/sdk bumped from 23.20.1 to 24.0.0
32
32
  * devDependencies
33
- * @looker/sdk-node bumped from ^23.16.0 to ^23.18.0
34
-
35
- ## [23.16.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.14.1...embed-services-v23.16.0) (2023-09-21)
33
+ * @looker/sdk-node bumped from 23.20.1 to 24.0.0
36
34
 
35
+ ## [23.20.1](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.20.0...embed-services-v23.20.1) (2023-12-19)
37
36
 
38
37
  ### Miscellaneous Chores
39
38
 
40
- * **embed-services:** Synchronize undefined versions
39
+ - **embed-services:** Synchronize undefined versions
40
+
41
+ ### Dependencies
41
42
 
43
+ - The following workspace dependencies were updated
44
+ - dependencies
45
+ - @looker/sdk bumped from ^23.20.0 to ^23.20.1
46
+ - devDependencies
47
+ - @looker/sdk-node bumped from ^23.20.0 to ^23.20.1
48
+
49
+ ## [23.20.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.18.0...embed-services-v23.20.0) (2023-11-30)
50
+
51
+ ### Miscellaneous Chores
52
+
53
+ - **embed-services:** Synchronize undefined versions
42
54
 
43
55
  ### Dependencies
44
56
 
45
- * The following workspace dependencies were updated
46
- * dependencies
47
- * @looker/sdk bumped from ^23.14.1 to ^23.16.0
48
- * devDependencies
49
- * @looker/sdk-node bumped from ^23.14.1 to ^23.16.0
57
+ - The following workspace dependencies were updated
58
+ - dependencies
59
+ - @looker/sdk bumped from ^23.18.0 to ^23.20.0
60
+ - devDependencies
61
+ - @looker/sdk-node bumped from ^23.18.0 to ^23.20.0
50
62
 
51
- ## [23.14.1](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.12.0...embed-services-v23.14.1) (2023-08-15)
63
+ ## [23.18.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.16.0...embed-services-v23.18.0) (2023-11-22)
64
+
65
+ ### Miscellaneous Chores
66
+
67
+ - **embed-services:** Synchronize undefined versions
68
+
69
+ ### Dependencies
70
+
71
+ - The following workspace dependencies were updated
72
+ - dependencies
73
+ - @looker/sdk bumped from ^23.16.0 to ^23.18.0
74
+ - devDependencies
75
+ - @looker/sdk-node bumped from ^23.16.0 to ^23.18.0
52
76
 
77
+ ## [23.16.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.14.1...embed-services-v23.16.0) (2023-09-21)
53
78
 
54
79
  ### Miscellaneous Chores
55
80
 
56
- * **embed-services:** Synchronize undefined versions
81
+ - **embed-services:** Synchronize undefined versions
82
+
83
+ ### Dependencies
84
+
85
+ - The following workspace dependencies were updated
86
+ - dependencies
87
+ - @looker/sdk bumped from ^23.14.1 to ^23.16.0
88
+ - devDependencies
89
+ - @looker/sdk-node bumped from ^23.14.1 to ^23.16.0
57
90
 
91
+ ## [23.14.1](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.12.0...embed-services-v23.14.1) (2023-08-15)
92
+
93
+ ### Miscellaneous Chores
94
+
95
+ - **embed-services:** Synchronize undefined versions
58
96
 
59
97
  ### Dependencies
60
98
 
61
- * The following workspace dependencies were updated
62
- * dependencies
63
- * @looker/sdk bumped from ^23.12.0 to ^23.14.1
64
- * devDependencies
65
- * @looker/sdk-node bumped from ^23.12.0 to ^23.14.1
99
+ - The following workspace dependencies were updated
100
+ - dependencies
101
+ - @looker/sdk bumped from ^23.12.0 to ^23.14.1
102
+ - devDependencies
103
+ - @looker/sdk-node bumped from ^23.12.0 to ^23.14.1
66
104
 
67
105
  ## [23.12.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.10.0...embed-services-v23.12.0) (2023-07-17)
68
106
 
69
-
70
107
  ### Miscellaneous Chores
71
108
 
72
- * **embed-services:** Synchronize undefined versions
73
-
109
+ - **embed-services:** Synchronize undefined versions
74
110
 
75
111
  ### Dependencies
76
112
 
77
- * The following workspace dependencies were updated
78
- * dependencies
79
- * @looker/sdk bumped from ^23.10.0 to ^23.12.0
80
- * devDependencies
81
- * @looker/sdk-node bumped from ^23.10.0 to ^23.12.0
113
+ - The following workspace dependencies were updated
114
+ - dependencies
115
+ - @looker/sdk bumped from ^23.10.0 to ^23.12.0
116
+ - devDependencies
117
+ - @looker/sdk-node bumped from ^23.10.0 to ^23.12.0
82
118
 
83
119
  ## [23.10.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v23.8.1...embed-services-v23.10.0) (2023-06-15)
84
120
 
85
-
86
121
  ### Features
87
122
 
88
- * minor tweaks to embed-components and embed-services ([#1315](https://github.com/looker-open-source/sdk-codegen/issues/1315)) ([f3c5fc4](https://github.com/looker-open-source/sdk-codegen/commit/f3c5fc44a6161c0aab519527a4feb68e1f826bce))
89
-
123
+ - minor tweaks to embed-components and embed-services ([#1315](https://github.com/looker-open-source/sdk-codegen/issues/1315)) ([f3c5fc4](https://github.com/looker-open-source/sdk-codegen/commit/f3c5fc44a6161c0aab519527a4feb68e1f826bce))
90
124
 
91
125
  ### Dependencies
92
126
 
93
- * The following workspace dependencies were updated
94
- * dependencies
95
- * @looker/sdk-rtl bumped from ^21.6.0 to ^21.6.1
96
- * @looker/sdk bumped from ^23.8.1 to ^23.10.0
97
- * devDependencies
98
- * @looker/sdk-node bumped from ^23.8.1 to ^23.10.0
127
+ - The following workspace dependencies were updated
128
+ - dependencies
129
+ - @looker/sdk-rtl bumped from ^21.6.0 to ^21.6.1
130
+ - @looker/sdk bumped from ^23.8.1 to ^23.10.0
131
+ - devDependencies
132
+ - @looker/sdk-node bumped from ^23.8.1 to ^23.10.0
99
133
 
100
134
  ## [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)
101
135
 
102
-
103
136
  ### Features
104
137
 
105
- * 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))
106
- * 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))
107
- * QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
108
- * SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
109
- * 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))
110
-
138
+ - 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))
139
+ - 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))
140
+ - QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
141
+ - SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
142
+ - 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))
111
143
 
112
144
  ### Dependencies
113
145
 
114
- * The following workspace dependencies were updated
115
- * dependencies
116
- * @looker/sdk bumped from ^23.8.0 to ^23.8.1
117
- * devDependencies
118
- * @looker/sdk-node bumped from ^23.8.0 to ^23.8.1
146
+ - The following workspace dependencies were updated
147
+ - dependencies
148
+ - @looker/sdk bumped from ^23.8.0 to ^23.8.1
149
+ - devDependencies
150
+ - @looker/sdk-node bumped from ^23.8.0 to ^23.8.1
119
151
 
120
152
  ## 23.8.0 (2023-05-11)
121
153
 
122
-
123
154
  ### Features
124
155
 
125
- * 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))
126
- * 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))
127
- * QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
128
- * SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
129
- * 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))
130
-
156
+ - 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))
157
+ - 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))
158
+ - QuickEmbed component ([#1306](https://github.com/looker-open-source/sdk-codegen/issues/1306)) ([4c78712](https://github.com/looker-open-source/sdk-codegen/commit/4c78712d44fb32dbdc0690a6121bc35086dec44a))
159
+ - SelectTheme component ([#1300](https://github.com/looker-open-source/sdk-codegen/issues/1300)) ([95c0da6](https://github.com/looker-open-source/sdk-codegen/commit/95c0da628d1d22fae2c6968f988047bfacc5fd01))
160
+ - 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))
131
161
 
132
162
  ### Dependencies
133
163
 
134
- * The following workspace dependencies were updated
135
- * dependencies
136
- * @looker/sdk bumped from ^23.6.0 to ^23.8.0
137
- * devDependencies
138
- * @looker/sdk-node bumped from ^23.4.0 to ^23.8.0
164
+ - The following workspace dependencies were updated
165
+ - dependencies
166
+ - @looker/sdk bumped from ^23.6.0 to ^23.8.0
167
+ - devDependencies
168
+ - @looker/sdk-node bumped from ^23.4.0 to ^23.8.0
package/lib/EmbedUrl.js CHANGED
@@ -5,16 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.EmbedUrl = exports.ContentType = void 0;
7
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) {
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ var ContentType = exports.ContentType = function (ContentType) {
11
11
  ContentType["Look"] = "look";
12
12
  ContentType["Explore"] = "explore";
13
13
  ContentType["Dashboard"] = "dashboard";
14
14
  ContentType["Invalid"] = "invalid";
15
15
  return ContentType;
16
16
  }({});
17
- exports.ContentType = ContentType;
18
17
  var THEMABLE_CONTENT = [ContentType.Dashboard, ContentType.Explore];
19
18
  class EmbedUrl {
20
19
  constructor() {
@@ -1 +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 /** Current url */\n readonly url: string\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 /** Type of content the URL represents */\n readonly contentType: ContentType\n /** Determines if current URL represents themable content */\n readonly isThemable: boolean\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: 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 private _url: URL\n readonly path: string\n readonly searchParams: Record<string, string>\n readonly isDashboard: boolean\n readonly isExplore: boolean\n readonly isLook: boolean\n readonly isThemable: boolean\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 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,OAAO,CACpB;AA8BM,MAAMC,QAAQ,CAAsB;EAWzCC,WAAWA,CAAA,EAA6B;IAAA,IAA5BC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,MAAM,CAACC,QAAQ,CAACC,IAAI;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACpC,IAAI,CAACC,IAAI,GAAG,IAAIC,GAAG,CAACT,GAAG,CAAC;IACxB,IAAI,CAACU,YAAY,GAAGC,MAAM,CAACC,WAAW,CAAC,IAAI,CAACJ,IAAI,CAACE,YAAY,CAAC;IAC9D,IAAI,CAACG,IAAI,GAAG,IAAI,CAACL,IAAI,CAACM,QAAQ;IAC9B,IAAI,CAACC,WAAW,GAAG,4BAA4B,CAACC,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC/D,IAAI,CAACI,SAAS,GAAG,yBAAyB,CAACD,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC1D,IAAI,CAACK,MAAM,GAAG,uBAAuB,CAACF,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC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I,CAACkB,WAAW,KAAK1B,WAAW,CAACmC,OAAO,EAAE;MAC5C,MAAM,IAAII,KAAK,CAAC,sBAAsB,CAAC;IACzC;IAEA,IAAMC,cAAc,GAAGH,mBAAmB,GAAG,IAAI,CAACpB,YAAY,GAAG,CAAC,CAAC;IAEnE,IAAIqB,SAAS,EAAE;MACbpB,MAAM,CAACuB,OAAO,CAACH,SAAS,CAAC,CAACI,OAAO,CAACC,IAAA,IAAkB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QAC7C,IAAIG,aAAa,GAAGD,KAAK;QACzB,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;UAC7BC,aAAa,GAAGC,IAAI,CAACC,SAAS,CAACH,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,CAAC,CAAC;IACrE;IAEA,IAAM9C,GAAG,GAAG,IAAIS,GAAG,IAAAc,MAAA,CAAI,IAAI,CAACD,SAAS,EAAAC,MAAA,CAAGoB,YAAY,CAAE,CAAC;IACvD,OAAO3C,GAAG,CAACM,IAAI;EACjB;AACF;AAACZ,OAAA,CAAAI,QAAA,GAAAA,QAAA"}
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 /** Current url */\n readonly url: string;\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 /** Type of content the URL represents */\n readonly contentType: ContentType;\n /** Determines if current URL represents themable content */\n readonly isThemable: boolean;\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(\n includeSearchParams: boolean,\n overrides: Record<string, any>\n ): string;\n}\n\n/**\n * A class for use when implementer requires components to be context aware\n */\nexport class EmbedUrl implements IEmbedUrl {\n private _url: URL;\n readonly path: string;\n readonly searchParams: Record<string, string>;\n readonly isDashboard: boolean;\n readonly isExplore: boolean;\n readonly isLook: boolean;\n readonly isThemable: boolean;\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 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,GAAAC,OAAA,CAAAD,WAAA,aAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOvB,IAAME,gBAA+B,GAAG,CACtCF,WAAW,CAACG,SAAS,EACrBH,WAAW,CAACI,OAAO,CACpB;AAiCM,MAAMC,QAAQ,CAAsB;EAWzCC,WAAWA,CAAA,EAA6B;IAAA,IAA5BC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,MAAM,CAACC,QAAQ,CAACC,IAAI;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACpC,IAAI,CAACC,IAAI,GAAG,IAAIC,GAAG,CAACT,GAAG,CAAC;IACxB,IAAI,CAACU,YAAY,GAAGC,MAAM,CAACC,WAAW,CAAC,IAAI,CAACJ,IAAI,CAACE,YAAY,CAAC;IAC9D,IAAI,CAACG,IAAI,GAAG,IAAI,CAACL,IAAI,CAACM,QAAQ;IAC9B,IAAI,CAACC,WAAW,GAAG,4BAA4B,CAACC,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC/D,IAAI,CAACI,SAAS,GAAG,yBAAyB,CAACD,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC1D,IAAI,CAACK,MAAM,GAAG,uBAAuB,CAACF,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IACrD,IAAI,CAACM,WAAW,GAAG,IAAI,C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C,OAAO,EAAE;MAC5C,MAAM,IAAII,KAAK,CAAC,sBAAsB,CAAC;IACzC;IAEA,IAAMC,cAAc,GAAGH,mBAAmB,GAAG,IAAI,CAACpB,YAAY,GAAG,CAAC,CAAC;IAEnE,IAAIqB,SAAS,EAAE;MACbpB,MAAM,CAACuB,OAAO,CAACH,SAAS,CAAC,CAACI,OAAO,CAACC,IAAA,IAAkB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QAC7C,IAAIG,aAAa,GAAGD,KAAK;QACzB,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;UAC7BC,aAAa,GAAGC,IAAI,CAACC,SAAS,CAACH,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,CAAC,CAAC;IACrE;IAEA,IAAM9C,GAAG,GAAG,IAAIS,GAAG,IAAAc,MAAA,CAAI,IAAI,CAACD,SAAS,EAAAC,MAAA,CAAGoB,YAAY,CAAE,CAAC;IACvD,OAAO3C,GAAG,CAACM,IAAI;EACjB;AACF;AAACZ,OAAA,CAAAI,QAAA,GAAAA,QAAA"}
@@ -1 +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"}
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(\n public sdk: IAPIMethods,\n readonly timeToLive = 900\n ) {}\n}\n"],"mappings":";;;;;;AAiCO,MAAeA,aAAa,CAA0B;EAM3DC,WAAWA,CACFC,GAAgB,EAEvB;IAAA,IADSC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,KADlBF,GAAgB,GAAhBA,GAAgB;IAAA,KACdC,UAAU,GAAVA,UAAU;EAClB;AACL;AAACI,OAAA,CAAAP,aAAA,GAAAA,aAAA"}
package/lib/ItemList.d.ts CHANGED
@@ -5,7 +5,7 @@ export interface GetOptions {
5
5
  useCache?: boolean;
6
6
  [key: string]: any;
7
7
  }
8
- export interface IItemList<T> {
8
+ export interface IItemList<T extends Record<string, any>> {
9
9
  readonly timeToLive: number;
10
10
  items: T[];
11
11
  readonly expiresAt: number;
@@ -17,7 +17,7 @@ export interface IItemList<T> {
17
17
  find(key: keyof T | Array<keyof T>, value: any): T | undefined;
18
18
  getCacheDefault(options?: GetOptions): boolean;
19
19
  }
20
- export interface IEntityService<T> extends IItemList<T> {
20
+ export interface IEntityService<T extends Record<string, any>> extends IItemList<T> {
21
21
  get(id: string, options?: GetOptions): Promise<T>;
22
22
  set(id: string, item: T): Promise<T>;
23
23
  getAll(...options: any[]): Promise<IItemList<T>>;
package/lib/ItemList.js CHANGED
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ItemList = exports.DEFAULT_TTL = void 0;
7
7
  var _EntityService = require("./EntityService");
8
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;
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ var DEFAULT_TTL = exports.DEFAULT_TTL = 900;
13
12
  class ItemList extends _EntityService.EntityService {
14
13
  constructor(sdk) {
15
14
  var timeToLive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_TTL;
@@ -1 +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 /** Cached items */\n items: T[]\n /** Expiration time */\n readonly expiresAt: number\n /** Creates an indexed collection from the cached items */\n index(key?: keyof T): ItemList<T>\n /** An indexed collection of items */\n indexedItems: Record<string, T>\n /** Determines if the cache has expired */\n expired(): boolean\n /** Computes the expiration time based on timeToLive */\n setExpiration(): void\n /** Ejects cache if expired */\n clearIfExpired(): void\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>, value: any): T | undefined\n /**\n * Gets the cache option value if present, otherwise defaults to true\n * @param options to check\n */\n getCacheDefault(options?: GetOptions): boolean\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 items: T[] = []\n indexedItems: Record<string, T> = {}\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 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 setExpiration() {\n this.expiresAt = Date.now() + this.timeToLive * 1000\n }\n\n expired() {\n return this.expiresAt <= Date.now()\n }\n\n clearIfExpired() {\n if (this.expired()) {\n this.items = []\n this.indexedItems = {}\n }\n }\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 try {\n const 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 getCacheDefault(options?: GetOptions) {\n const cache =\n options && 'useCache' in options && options.useCache !== undefined\n ? options.useCache\n : 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;AA4CvB,MAAeE,QAAQ,SACpBC,4BAAa,CAEvB;EAOEC,WAAWA,CAACC,GAAgB,EAA4B;IAAA,IAA1BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAZ,SAAA,GAAAY,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3B6C,IAAI,GAAG,CAAC7C,GAAG,CAAC;IACd,CAAC,MAAM;MACL6C,IAAI,GAAG7C,GAAqB;IAC9B;IAEA,IAAI;MACF,IAAM8C,EAAE,GAAG,IAAIC,MAAM,CAACJ,UAAU,EAAE,GAAG,CAAC;MAEtC,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,CAAC,CAAC,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;EAEAE,eAAeA,CAACC,OAAoB,EAAE;IACpC,IAAMC,KAAK,GACTD,OAAO,IAAI,UAAU,IAAIA,OAAO,IAAIA,OAAO,CAACE,QAAQ,KAAK1C,SAAS,GAC9DwC,OAAO,CAACE,QAAQ,GAChB,IAAI;IACV,OAAOD,KAAK;EACd;AACF;AAACnC,OAAA,CAAAC,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"file":"ItemList.js","names":["_EntityService","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","DEFAULT_TTL","exports","ItemList","EntityService","constructor","sdk","timeToLive","arguments","length","undefined","index","keyField","indexedItems","items","forEach","el","setExpiration","expiresAt","Date","now","expired","clearIfExpired","find","expression","result","keys","rx","RegExp","item","k","_item$k","match","toString","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 extends Record<string, any>> {\n /** Cache time to live in seconds, defaults to 15 minutes */\n readonly timeToLive: number;\n /** Cached items */\n items: T[];\n /** Expiration time */\n readonly expiresAt: number;\n /** Creates an indexed collection from the cached items */\n index(key?: keyof T): ItemList<T>;\n /** An indexed collection of items */\n indexedItems: Record<string, T>;\n /** Determines if the cache has expired */\n expired(): boolean;\n /** Computes the expiration time based on timeToLive */\n setExpiration(): void;\n /** Ejects cache if expired */\n clearIfExpired(): void;\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>, value: any): T | undefined;\n /**\n * Gets the cache option value if present, otherwise defaults to true\n * @param options to check\n */\n getCacheDefault(options?: GetOptions): boolean;\n}\n\nexport interface IEntityService<T extends Record<string, any>>\n 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 items: T[] = [];\n indexedItems: Record<string, T> = {};\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 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 setExpiration() {\n this.expiresAt = Date.now() + this.timeToLive * 1000;\n }\n\n expired() {\n return this.expiresAt <= Date.now();\n }\n\n clearIfExpired() {\n if (this.expired()) {\n this.items = [];\n this.indexedItems = {};\n }\n }\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 try {\n const 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 getCacheDefault(options?: GetOptions) {\n const cache =\n options && 'useCache' in options && options.useCache !== undefined\n ? options.useCache\n : true;\n return cache;\n }\n}\n"],"mappings":";;;;;;AA2BA,IAAAA,cAAA,GAAAC,OAAA;AAAgD,SAAAC,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAA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CAACL,EAAE,CAAC;UAC3C,IAAIK,KAAK,EAAE;YACTP,MAAM,GAAGI,KAAS;YAClB,OAAOJ,MAAM;UACf;QACF;MACF;MACA,OAAOA,MAAM;IACf,CAAC,CAAC,OAAO9B,CAAM,EAAE;MACf,MAAM,IAAIuC,KAAK,CAACvC,CAAC,CAAC;IACpB;EACF;EAEAwC,eAAeA,CAACC,OAAoB,EAAE;IACpC,IAAMC,KAAK,GACTD,OAAO,IAAI,UAAU,IAAIA,OAAO,IAAIA,OAAO,CAACE,QAAQ,KAAK5B,SAAS,GAC9D0B,OAAO,CAACE,QAAQ,GAChB,IAAI;IACV,OAAOD,KAAK;EACd;AACF;AAACnC,OAAA,CAAAC,QAAA,GAAAA,QAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { IAPIMethods } from '@looker/sdk-rtl';
2
- export declare type ServiceCreatorFunc<T> = (sdk: IAPIMethods, timeToLive?: number) => T;
2
+ export type ServiceCreatorFunc<T> = (sdk: IAPIMethods, timeToLive?: number) => T;
3
3
  export interface IServiceFactory {
4
4
  get<T>(serviceName: string): T;
5
5
  register<T>(serviceName: string, serviceCreator: ServiceCreatorFunc<T>, timeToLive?: number): void;
@@ -7,8 +7,8 @@ exports.createFactory = createFactory;
7
7
  exports.destroyFactory = destroyFactory;
8
8
  exports.getFactory = getFactory;
9
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); }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
11
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
12
  class ServiceFactory {
13
13
  constructor(sdk) {
14
14
  this.sdk = sdk;
@@ -1 +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 /**\n * Retrieves a service\n * @param serviceName to retrieve\n */\n get<T>(serviceName: string): T\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 ): 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 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":";;;;;;;;;;;AAmDA,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,eAAY,CAAC;IACrD;IACA,OAAOC,OAAO;EAChB;EAEAI,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"}
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> = (\n sdk: IAPIMethods,\n timeToLive?: number\n) => T;\n\nexport interface IServiceFactory {\n /**\n * Retrieves a service\n * @param serviceName to retrieve\n */\n get<T>(serviceName: string): T;\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 ): 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 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":";;;;;;;;;;;AAsDA,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,eAAY,CAAC;IACrD;IACA,OAAOC,OAAO;EAChB;EAEAI,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"}
@@ -1,5 +1,5 @@
1
1
  import type { ITheme } from '@looker/sdk';
2
- import type { IEntityService, IItemList, GetOptions } from './ItemList';
2
+ import type { GetOptions, IEntityService, IItemList } from './ItemList';
3
3
  import type { ServiceCreatorFunc } from './ServiceFactory';
4
4
  export interface IThemeService extends IItemList<ITheme>, IEntityService<ITheme> {
5
5
  defaultTheme?: ITheme;
@@ -8,5 +8,5 @@ export interface IThemeService extends IItemList<ITheme>, IEntityService<ITheme>
8
8
  }
9
9
  export declare const THEME_SERVICE_NAME = "ThemeService";
10
10
  export declare const themeServiceCreator: ServiceCreatorFunc<IThemeService>;
11
- export declare const registerThemeService: (timeToLive?: number | undefined) => void;
11
+ export declare const registerThemeService: (timeToLive?: number) => void;
12
12
  export declare const getThemeService: () => IThemeService;
@@ -10,8 +10,8 @@ var _ServiceFactory = require("./ServiceFactory");
10
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
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
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); }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
15
  class ThemeService extends _ItemList.ItemList {
16
16
  constructor() {
17
17
  super(...arguments);
@@ -87,8 +87,7 @@ class ThemeService extends _ItemList.ItemList {
87
87
  })();
88
88
  }
89
89
  }
90
- var THEME_SERVICE_NAME = 'ThemeService';
91
- exports.THEME_SERVICE_NAME = THEME_SERVICE_NAME;
90
+ var THEME_SERVICE_NAME = exports.THEME_SERVICE_NAME = 'ThemeService';
92
91
  var themeServiceCreator = (sdk, timeToLive) => {
93
92
  return new ThemeService(sdk, timeToLive);
94
93
  };
@@ -1 +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 /**\n * Gets the default theme\n * @param ts Timestamp representing the target datetime for the active period. Defaults to 'now'\n */\n getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>\n /**\n * Retrieves all themes and the default theme\n */\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 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 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 theme service registered with the service factory\n */\nexport const getThemeService = () =>\n getFactory().get<IThemeService>(THEME_SERVICE_NAME)\n"],"mappings":";;;;;;AA0BA,IAAAA,IAAA,GAAAC,OAAA;AAQA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,eAAA,GAAAF,OAAA;AAA6C,SAAAG,mBAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,GAAA,EAAAC,GAAA,cAAAC,IAAA,GAAAP,GAAA,CAAAK,GAAA,EAAAC,GAAA,OAAAE,KAAA,GAAAD,IAAA,CAAAC,KAAA,WAAAC,KAAA,IAAAP,MAAA,CAA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MAC/B,MAAM8D,MAAI,CAACT,eAAe,CAAC,CAAC;MAC5BS,MAAI,CAACnB,KAAK,SAASmB,MAAI,CAACvB,GAAG,CAACC,EAAE,CAAC,IAAAuB,eAAU,EAACD,MAAI,CAACvB,GAAG,EAAEP,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEU,MAAM,CAAC,CAAC;MACrEoB,MAAI,CAAClB,KAAK,CAAC,CAAC;MACZkB,MAAI,CAACjB,aAAa,CAAC,CAAC;MACpB,OAAOiB,MAAI;IAAA;EACb;AACF;AAEO,IAAME,kBAAkB,GAAG,cAAc;AAAAC,OAAA,CAAAD,kBAAA,GAAAA,kBAAA;AAOzC,IAAME,mBAAsD,GAAGA,CACpE3B,GAAgB,EAChB4B,UAAmB,KAChB;EACH,OAAO,IAAIxC,YAAY,CAACY,GAAG,EAAE4B,UAAU,CAAC;AAC1C,CAAC;AAAAF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAMM,IAAME,oBAAoB,GAAID,UAAmB,IAAK;EAC3D,IAAAE,0BAAU,EAAC,CAAC,CAACC,QAAQ,CAACN,kBAAkB,EAAEE,mBAAmB,EAAEC,UAAU,CAAC;AAC5E,CAAC;AAAAF,OAAA,CAAAG,oBAAA,GAAAA,oBAAA;AAKM,IAAMG,eAAe,GAAGA,CAAA,KAC7B,IAAAF,0BAAU,EAAC,CAAC,CAACvC,GAAG,CAAgBkC,kBAAkB,CAAC;AAAAC,OAAA,CAAAM,eAAA,GAAAA,eAAA"}
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","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","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 { GetOptions, IEntityService, IItemList } 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 /**\n * Gets the default theme\n * @param ts Timestamp representing the target datetime for the active period. Defaults to 'now'\n */\n getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>;\n /**\n * Retrieves all themes and the default theme\n */\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 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 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 theme service registered with the service factory\n */\nexport const getThemeService = () =>\n getFactory().get<IThemeService>(THEME_SERVICE_NAME);\n"],"mappings":";;;;;;AA0BA,IAAAA,IAAA,GAAAC,OAAA;AAQA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,eAAA,GAAAF,OAAA;AAA8C,SAAAG,mBAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,GAAA,EAAAC,GAAA,cAAAC,IAAA,GAAAP,GAAA,CAAAK,GAAA,EAAAC,GAAA,OAAAE,KAAA,GAAAD,IAAA,CAAAC,KAAA,WAAAC,KAAA,IAAAP,MAAA,CAAAO,KAAA,iBAAAF,IAAA,CAAAG,IAAA,IAAAT,OAAA,CAAAO,KAAA,YAAAG,OAAA,CAAAV,OAAA,CAAAO,KAAA,EAAAI,IAAA,CAAAT,KAAA,EAAAC,MAAA;AAAA,SAAAS,kBAAAC,EAAA,6BAAAC,IAAA,SAAAC,IAAA,GAAAC,SAAA,aAAAN,OAAA,WAAAV,OAAA,EAAAC,MAAA,QAAAF,GAAA,GAAAc,EAAA,CAAAI,KAAA,CAAAH,IAAA,EAAAC,IAAA,YAAAb,MAAAK,KAAA,IAAAT,kBAAA,CAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,UAAAI,KAAA,cAAAJ,OAAAe,GAAA,IAAApB,kBAAA,CAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,WAAAe,GAAA,KAAAhB,KAAA,CAAAiB,SAAA;A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AID,UAAmB,IAAK;EAC3D,IAAAE,0BAAU,EAAC,CAAC,CAACC,QAAQ,CAACN,kBAAkB,EAAEE,mBAAmB,EAAEC,UAAU,CAAC;AAC5E,CAAC;AAACF,OAAA,CAAAG,oBAAA,GAAAA,oBAAA;AAKK,IAAMG,eAAe,GAAGA,CAAA,KAC7B,IAAAF,0BAAU,EAAC,CAAC,CAACvC,GAAG,CAAgBkC,kBAAkB,CAAC;AAACC,OAAA,CAAAM,eAAA,GAAAA,eAAA"}
@@ -1,6 +1,6 @@
1
1
  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; }
2
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
- 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); }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  export var ContentType = function (ContentType) {
5
5
  ContentType["Look"] = "look";
6
6
  ContentType["Explore"] = "explore";
@@ -1 +1 @@
1
- {"version":3,"file":"EmbedUrl.js","names":["ContentType","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 /** Current url */\n readonly url: string\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 /** Type of content the URL represents */\n readonly contentType: ContentType\n /** Determines if current URL represents themable content */\n readonly isThemable: boolean\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: 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 private _url: URL\n readonly path: string\n readonly searchParams: Record<string, string>\n readonly isDashboard: boolean\n readonly isExplore: boolean\n readonly isLook: boolean\n readonly isThemable: boolean\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 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":";;;AA0BA,WAAYA,WAAW,aAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOvB,IAAMC,gBAA+B,GAAG,CACtCD,WAAW,CAACE,SAAS,EACrBF,WAAW,CAACG,OAAO,CACpB;AA8BD,OAAO,MAAMC,QAAQ,CAAsB;EAWzCC,WAAWA,CAAA,EAA6B;IAAA,IAA5BC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,MAAM,CAACC,QAAQ,CAACC,IAAI;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACpC,IAAI,CAACC,IAAI,GAAG,IAAIC,GAAG,CAACT,GAAG,CAAC;IACxB,IAAI,CAACU,YAAY,GAAGC,MAAM,CAACC,WAAW,CAAC,IAAI,CAACJ,IAAI,CAACE,YAAY,CAAC;IAC9D,IAAI,CAACG,IAAI,GAAG,IAAI,CAACL,IAAI,CAACM,QAAQ;IAC9B,IAAI,CAACC,WAAW,GAAG,4BAA4B,CAACC,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC/D,IAAI,CAACI,SAAS,GAAG,yBAAyB,CAACD,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IAC1D,IAAI,CAACK,MAAM,GAAG,uBAAuB,CAACF,IAAI,CAAC,IAAI,CAACH,IAAI,CAAC;IACrD,IAAI,CAACM,WAAW,GAAG,IAAI,CAACC,IAAI,CAAC,CAAC;IAE9B,IAAI,IAAI,CAACP,IAAI,CAACQ,UAAU,CAAC,SAAS,CAAC,EAAE;MACnC,IAAI,CAACC,SAAS,MAAAC,MAAA,CAAM,IAAI,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AC;IAEnE,IAAIqB,SAAS,EAAE;MACbpB,MAAM,CAACuB,OAAO,CAACH,SAAS,CAAC,CAACI,OAAO,CAACC,IAAA,IAAkB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QAC7C,IAAIG,aAAa,GAAGD,KAAK;QACzB,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;UAC7BC,aAAa,GAAGC,IAAI,CAACC,SAAS,CAACH,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,CAAC,CAAC;IACrE;IAEA,IAAM9C,GAAG,GAAG,IAAIS,GAAG,IAAAc,MAAA,CAAI,IAAI,CAACD,SAAS,EAAAC,MAAA,CAAGoB,YAAY,CAAE,CAAC;IACvD,OAAO3C,GAAG,CAACM,IAAI;EACjB;AACF"}
1
+ {"version":3,"file":"EmbedUrl.js","names":["ContentType","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 /** Current url */\n readonly url: string;\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 /** Type of content the URL represents */\n readonly contentType: ContentType;\n /** Determines if current URL represents themable content */\n readonly isThemable: boolean;\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(\n includeSearchParams: boolean,\n overrides: Record<string, any>\n ): string;\n}\n\n/**\n * A class for use when implementer requires components to be context aware\n */\nexport class EmbedUrl implements IEmbedUrl {\n private _url: URL;\n readonly path: string;\n readonly searchParams: Record<string, string>;\n readonly isDashboard: boolean;\n readonly isExplore: boolean;\n readonly isLook: boolean;\n readonly isThemable: boolean;\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 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":";;;AA0BA,WAA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A,IAAkB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QAC7C,IAAIG,aAAa,GAAGD,KAAK;QACzB,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;UAC7BC,aAAa,GAAGC,IAAI,CAACC,SAAS,CAACH,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,CAAC,CAAC;IACrE;IAEA,IAAM9C,GAAG,GAAG,IAAIS,GAAG,IAAAc,MAAA,CAAI,IAAI,CAACD,SAAS,EAAAC,MAAA,CAAGoB,YAAY,CAAE,CAAC;IACvD,OAAO3C,GAAG,CAACM,IAAI;EACjB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityService.js","names":["EntityService","constructor","sdk","timeToLive","arguments","length","undefined"],"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":"AAiCA,OAAO,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"}
1
+ {"version":3,"file":"EntityService.js","names":["EntityService","constructor","sdk","timeToLive","arguments","length","undefined"],"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(\n public sdk: IAPIMethods,\n readonly timeToLive = 900\n ) {}\n}\n"],"mappings":"AAiCA,OAAO,MAAeA,aAAa,CAA0B;EAM3DC,WAAWA,CACFC,GAAgB,EAEvB;IAAA,IADSC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,KADlBF,GAAgB,GAAhBA,GAAgB;IAAA,KACdC,UAAU,GAAVA,UAAU;EAClB;AACL"}
@@ -1,6 +1,6 @@
1
1
  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; }
2
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
- 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); }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  import { EntityService } from './EntityService';
5
5
  export var DEFAULT_TTL = 900;
6
6
  export class ItemList extends EntityService {
@@ -1 +1 @@
1
- {"version":3,"file":"ItemList.js","names":["EntityService","DEFAULT_TTL","ItemList","constructor","sdk","timeToLive","arguments","length","undefined","_defineProperty","index","key","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 /** Cached items */\n items: T[]\n /** Expiration time */\n readonly expiresAt: number\n /** Creates an indexed collection from the cached items */\n index(key?: keyof T): ItemList<T>\n /** An indexed collection of items */\n indexedItems: Record<string, T>\n /** Determines if the cache has expired */\n expired(): boolean\n /** Computes the expiration time based on timeToLive */\n setExpiration(): void\n /** Ejects cache if expired */\n clearIfExpired(): void\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>, value: any): T | undefined\n /**\n * Gets the cache option value if present, otherwise defaults to true\n * @param options to check\n */\n getCacheDefault(options?: GetOptions): boolean\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 items: T[] = []\n indexedItems: Record<string, T> = {}\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 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 setExpiration() {\n this.expiresAt = Date.now() + this.timeToLive * 1000\n }\n\n expired() {\n return this.expiresAt <= Date.now()\n }\n\n clearIfExpired() {\n if (this.expired()) {\n this.items = []\n this.indexedItems = {}\n }\n }\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 try {\n const 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 getCacheDefault(options?: GetOptions) {\n const cache =\n options && 'useCache' in options && options.useCache !== undefined\n ? options.useCache\n : true\n return cache\n }\n}\n"],"mappings":";;;AA2BA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,IAAMC,WAAW,GAAG,GAAG;AA4C9B,OAAO,MAAeC,QAAQ,SACpBF,aAAa,CAEvB;EAOEG,WAAWA,CAACC,GAAgB,EAA4B;IAAA,IAA1BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGL,WAAW;IACpD,KAAK,CAACG,GAAG,EAAEC,UAAU,CAAC;IAAAI,eAAA,gBAPX,EAAE;IAAAA,eAAA,uBACmB,CAAC,CAAC;IAAAA,eAAA,oBACxB,CAAC;IAAAA,eAAA,mBAEM,IAAI;EAIvB;EAEAC,KAAKA,CAAA,EAA+B;IAAA,IAA9BC,GAAY,GAAAL,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACM,QAAQ;IAChC,IAAI,CAACA,QAAQ,GAAGD,GAAa;IAC7B,IAAI,CAACE,YAAY,GAAG,CAAC,CAAC;IACtB,IAAI,CAACC,KAAK,CAACC,OAAO,CAAEC,EAAE,IAAK;MACzB,IAAIA,EAAE,IAAIA,EAAE,aAAFA,EAAE,eAAFA,EAAE,CAAG,IAAI,CAACJ,QAAQ,CAAC,EAAE;QAC7B,IAAI,CAACC,YAAY,CAACG,EAAE,CAAC,IAAI,CAACJ,QAAQ,CAAC,CAAC,GAAGI,EAAE;MAC3C;IACF,CAAC,CAAC;IACF,OAAO,IAAI;EACb;EAEAC,aAAaA,CAAA,EAAG;IACd,IAAI,CAACC,SAAS,G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/B,SAAS,GAC9D6B,OAAO,CAACE,QAAQ,GAChB,IAAI;IACV,OAAOD,KAAK;EACd;AACF"}
1
+ {"version":3,"file":"ItemList.js","names":["EntityService","DEFAULT_TTL","ItemList","constructor","sdk","timeToLive","arguments","length","undefined","_defineProperty","index","key","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 extends Record<string, any>> {\n /** Cache time to live in seconds, defaults to 15 minutes */\n readonly timeToLive: number;\n /** Cached items */\n items: T[];\n /** Expiration time */\n readonly expiresAt: number;\n /** Creates an indexed collection from the cached items */\n index(key?: keyof T): ItemList<T>;\n /** An indexed collection of items */\n indexedItems: Record<string, T>;\n /** Determines if the cache has expired */\n expired(): boolean;\n /** Computes the expiration time based on timeToLive */\n setExpiration(): void;\n /** Ejects cache if expired */\n clearIfExpired(): void;\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>, value: any): T | undefined;\n /**\n * Gets the cache option value if present, otherwise defaults to true\n * @param options to check\n */\n getCacheDefault(options?: GetOptions): boolean;\n}\n\nexport interface IEntityService<T extends Record<string, any>>\n 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 items: T[] = [];\n indexedItems: Record<string, T> = {};\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 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 setExpiration() {\n this.expiresAt = Date.now() + this.timeToLive * 1000;\n }\n\n expired() {\n return this.expiresAt <= Date.now();\n }\n\n clearIfExpired() {\n if (this.expired()) {\n this.items = [];\n this.indexedItems = {};\n }\n }\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 try {\n const 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 getCacheDefault(options?: GetOptions) {\n const cache =\n options && 'useCache' in options && options.useCache !== undefined\n ? options.useCache\n : true;\n return cache;\n }\n}\n"],"mappings":";;;AA2BA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,IAAMC,WAAW,GAAG,GAAG;AA6C9B,OAAO,MAAeC,QAAQ,SACpBF,aAAa,CAEvB;EAOEG,WAAWA,CAACC,GAAgB,EAA4B;IAAA,IAA1BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGL,WAAW;IACpD,KAAK,CAACG,GAAG,EAAEC,UAAU,CAAC;IAACI,eAAA,gBAPZ,EAAE;IAAAA,eAAA,uBACmB,CAAC,CAAC;IAAAA,eAAA,oBACxB,CAAC;IAAAA,eAAA,mBAEM,IAAI;EAIvB;EAEAC,KAAKA,CAAA,EAA+B;IAAA,IAA9BC,GAAY,GAAAL,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACM,QAAQ;IAChC,IAAI,CAACA,QAAQ,GAAGD,GAAa;IAC7B,IAAI,CAACE,YAAY,GAAG,CAAC,CAAC;IACtB,IAAI,CAACC,KAAK,CAACC,OAAO,CAAEC,EAAE,IAAK;MACzB,IAAIA,EAAE,IAAIA,EAAE,aAAFA,EAAE,eAAFA,EAAE,CAAG,IAAI,CAACJ,QAAQ,CAAC,EAAE;QAC7B,IAAI,CAACC,YAAY,CAACG,EAAE,CAAC,IAAI,CAACJ,QAAQ,CAAC,CAAC,GAAGI,EAAE;MAC3C;IACF,CAAC,CAAC;IACF,OAAO,IAAI;EACb;EAEAC,aAAaA,CAAA,EAAG;IACd,IAAI,CAACC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACf,UAAU,GAAG,IAAI;EACtD;EAEAgB,OAAOA,CA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@@
1
1
  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; }
2
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
- 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); }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  class ServiceFactory {
5
5
  constructor(sdk) {
6
6
  this.sdk = sdk;
@@ -1 +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 /**\n * Retrieves a service\n * @param serviceName to retrieve\n */\n get<T>(serviceName: string): T\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 ): 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 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":";;;AAmDA,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,eAAY,CAAC;IACrD;IACA,OAAOC,OAAO;EAChB;EAEAI,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;AAMxC,OAAO,SAASC,aAAaA,CAACZ,GAAgB,EAAE;EAC9CW,OAAO,GAAG,IAAIb,cAAc,CAACE,GAAG,CAAC;AACnC;AAKA,OAAO,SAASa,UAAUA,CAAA,EAAG;EAC3B,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIL,KAAK,CAAC,sCAAsC,CAAC;EACzD;EACA,OAAOK,OAAO;AAChB;AAKA,OAAO,SAASG,cAAcA,CAAA,EAAG;EAC/BH,OAAO,GAAGI,SAAS;AACrB"}
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> = (\n sdk: IAPIMethods,\n timeToLive?: number\n) => T;\n\nexport interface IServiceFactory {\n /**\n * Retrieves a service\n * @param serviceName to retrieve\n */\n get<T>(serviceName: string): T;\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 ): 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 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":";;;AAsDA,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,eAAY,CAAC;IACrD;IACA,OAAOC,OAAO;EAChB;EAEAI,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;AAMxC,OAAO,SAASC,aAAaA,CAACZ,GAAgB,EAAE;EAC9CW,OAAO,GAAG,IAAIb,cAAc,CAACE,GAAG,CAAC;AACnC;AAKA,OAAO,SAASa,UAAUA,CAAA,EAAG;EAC3B,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIL,KAAK,CAAC,sCAAsC,CAAC;EACzD;EACA,OAAOK,OAAO;AAChB;AAKA,OAAO,SAASG,cAAcA,CAAA,EAAG;EAC/BH,OAAO,GAAGI,SAAS;AACrB"}
@@ -1,8 +1,8 @@
1
1
  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); } }
2
2
  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); }); }; }
3
3
  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; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- 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); }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
6
  import { all_themes, default_theme, delete_theme, theme, update_theme } from '@looker/sdk';
7
7
  import { ItemList } from './ItemList';
8
8
  import { getFactory } from './ServiceFactory';
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeService.js","names":["all_themes","default_theme","delete_theme","theme","update_theme","ItemList","getFactory","ThemeService","constructor","arguments","_defineProperty","get","id","options","_this","_asyncToGenerator","cache","getCacheDefault","clearIfExpired","item","indexedItems","sdk","ok","fields","items","index","setExpiration","getAll","_this2","expired","load","set","_this3","getDefaultTheme","ts","_this4","defaultTheme","delete","_this5","filter","_this6","THEME_SERVICE_NAME","themeServiceCreator","timeToLive","registerThemeService","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 /**\n * Gets the default theme\n * @param ts Timestamp representing the target datetime for the active period. Defaults to 'now'\n */\n getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>\n /**\n * Retrieves all themes and the default theme\n */\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 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 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 theme service registered with the service factory\n */\nexport const getThemeService = () =>\n getFactory().get<IThemeService>(THEME_SERVICE_NAME)\n"],"mappings":";;;;;AA0BA,SACEA,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,KAAK,EACLC,YAAY,QACP,aAAa;AAEpB,SAASC,QAAQ,QAAQ,YAAY;AAGrC,SAASC,UAAU,QAAQ,kBAAkB;AAiB7C,MAAMC,YAAY,SAASF,QAAQ,CAAkC;EAAAG,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;EAAA;EAQ7DC,GAAGA,CAACC,EAAU,EAAEC,OAAoB,EAA4B;IAAA,IAAAC,KAAA;IAAA,OAAAC,iBAAA;MAEpE,IAAMC,KAAK,GAAGF,KAAI,CAACG,eAAe,CAACJ,OAAO,CAAC;MAC3CC,KAAI,CAACI,cAAc,CAAC,CAAC;MACrB,IAAIC,IAAI,GAAGL,KAAI,CAACM,YAAY,CAACR,EAAE,CAAC;MAEhC,IAAII,KAAK,IAAIG,IAAI,EAAE;QACjB,OAAOA,IAAI;MACb;MAEAA,IAAI,SAASL,KAAI,CAACO,GAAG,CAACC,EAAE,CAACnB,KAAK,CAACW,KAAI,CAACO,GAAG,EAAET,EAAE,EAAEC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEU,MAAM,CAAC,CAAC;MAE9D,IAAIJ,IAAI,EAAE;QACRL,KAAI,CAACU,KAAK,GAAG,CAAC,GAAGV,KAAI,CAACU,KAAK,EAAEL,IAAI,CAA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vB,iBAAA;MACvBuB,MAAI,CAACpB,cAAc,CAAC,CAAC;MACrB,MAAMoB,MAAI,CAACjB,GAAG,CAACC,EAAE,CAACpB,YAAY,CAACoC,MAAI,CAACjB,GAAG,EAAET,EAAE,CAAC,CAAC;MAC7C0B,MAAI,CAACd,KAAK,GAAGc,MAAI,CAACd,KAAK,CAACe,MAAM,CAAEpB,IAAI,IAAKA,IAAI,CAACP,EAAE,KAAKA,EAAE,CAAC;MACxD0B,MAAI,CAACb,KAAK,CAAC,CAAC;IAAA;EACd;EAEMK,IAAIA,CAACjB,OAAoB,EAAE;IAAA,IAAA2B,MAAA;IAAA,OAAAzB,iBAAA;MAC/B,MAAMyB,MAAI,CAACP,eAAe,CAAC,CAAC;MAC5BO,MAAI,CAAChB,KAAK,SAASgB,MAAI,CAACnB,GAAG,CAACC,EAAE,CAACtB,UAAU,CAACwC,MAAI,CAACnB,GAAG,EAAER,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEU,MAAM,CAAC,CAAC;MACrEiB,MAAI,CAACf,KAAK,CAAC,CAAC;MACZe,MAAI,CAACd,aAAa,CAAC,CAAC;MACpB,OAAOc,MAAI;IAAA;EACb;AACF;AAEA,OAAO,IAAMC,kBAAkB,GAAG,cAAc;AAOhD,OAAO,IAAMC,mBAAsD,GAAGA,CACpErB,GAAgB,EAChBsB,UAAmB,KAChB;EACH,OAAO,IAAIpC,YAAY,CAACc,GAAG,EAAEsB,UAAU,CAAC;AAC1C,CAAC;AAMD,OAAO,IAAMC,oBAAoB,GAAID,UAAmB,IAAK;EAC3DrC,UAAU,CAAC,CAAC,CAACuC,QAAQ,CAACJ,kBAAkB,EAAEC,mBAAmB,EAAEC,UAAU,CAAC;AAC5E,CAAC;AAKD,OAAO,IAAMG,eAAe,GAAGA,CAAA,KAC7BxC,UAAU,CAAC,CAAC,CAACK,GAAG,CAAgB8B,kBAAkB,CAAC"}
1
+ {"version":3,"file":"ThemeService.js","names":["all_themes","default_theme","delete_theme","theme","update_theme","ItemList","getFactory","ThemeService","constructor","arguments","_defineProperty","get","id","options","_this","_asyncToGenerator","cache","getCacheDefault","clearIfExpired","item","indexedItems","sdk","ok","fields","items","index","setExpiration","getAll","_this2","expired","load","set","_this3","getDefaultTheme","ts","_this4","defaultTheme","delete","_this5","filter","_this6","THEME_SERVICE_NAME","themeServiceCreator","timeToLive","registerThemeService","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 { GetOptions, IEntityService, IItemList } 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 /**\n * Gets the default theme\n * @param ts Timestamp representing the target datetime for the active period. Defaults to 'now'\n */\n getDefaultTheme(ts?: Date, options?: GetOptions): Promise<ITheme>;\n /**\n * Retrieves all themes and the default theme\n */\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 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 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 theme service registered with the service factory\n */\nexport const getThemeService = () =>\n getFactory().get<IThemeService>(THEME_SERVICE_NAME);\n"],"mappings":";;;;;AA0BA,SACEA,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,KAAK,EACLC,YAAY,QACP,aAAa;AAEpB,SAASC,QAAQ,QAAQ,YAAY;AAGrC,SAASC,UAAU,QAAQ,kBAAkB;AAiB7C,MAAMC,YAAY,SAASF,QAAQ,CAAkC;EAAAG,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;EAAA;EAQ7DC,GAAGA,CAACC,EAAU,EAAEC,OAAoB,EAA4B;IAAA,IAAAC,KAAA;IAAA,OAAAC,iBAAA;MAEpE,IAAMC,KAAK,GAAGF,KAAI,CAACG,eAAe,CAACJ,OAAO,CAAC;MAC3CC,KAAI,CAACI,cAAc,CAAC,CAAC;MACrB,IAAIC,IAAI,GAAGL,KAAI,CAACM,YAAY,CAACR,EAAE,CAAC;MAEhC,IAAII,KAAK,IAAIG,IAAI,EAAE;QACjB,OAAOA,IAAI;MACb;MAEAA,IAAI,SAASL,KAAI,CAACO,GAAG,CAACC,EAAE,CAACnB,KAAK,CAACW,KAAI,CAACO,GAAG,EAAET,EAAE,EAAEC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEU,MAAM,CAAC,CAAC;MAE9D,IAAIJ,IAAI,EAAE;QACRL,KAAI,CAACU,KAAK,GAAG,CAAC,GAAGV,KAAI,CAACU,KAAK,EAAEL,IAAI,CAAC;QAClCL,KAAI,CAACW,K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T 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 */\nexport * from './EmbedUrl'\nexport * from './ServiceFactory'\nexport * from './ThemeService'\n"],"mappings":"AAyBA,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.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 */\nexport * from './EmbedUrl';\nexport * from './ServiceFactory';\nexport * from './ThemeService';\n"],"mappings":"AAyBA,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/test-utils/index.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 */\nexport * from './utils'\n"],"mappings":"AAyBA,cAAc,SAAS"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/test-utils/index.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 */\nexport * from './utils';\n"],"mappings":"AAyBA,cAAc,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["path","fs","environmentPrefix","NodeSession","NodeSettingsIniFile","homeToRoost","getRootPath","join","__dirname","rootFile","fileName","arguments","length","undefined","localIni","process","env","LOOKERSDK_INI","settings","session","timeout","TestConfig","testFile","testPath","dataFile","concat","testData","JSON","parse","readFileSync"],"sources":["../../../src/test-utils/utils.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 path from 'path'\nimport * as fs from 'fs'\nimport { environmentPrefix } from '@looker/sdk'\nimport { NodeSession, NodeSettingsIniFile } from '@looker/sdk-node'\n\nconst homeToRoost = '../../../../'\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost)\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName)\nconst localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini')\n\nconst settings = new NodeSettingsIniFile(environmentPrefix, localIni, 'Looker')\nexport const session = new NodeSession(settings)\n\nexport const timeout = 3600000 // 1 hr\n\ninterface ITestConfig {\n testData: any\n}\n\nexport const TestConfig = (): ITestConfig => {\n const testFile = 'data.yml.json'\n const testPath = rootFile('test/')\n const dataFile = `${testPath}${testFile}`\n const testData = JSON.parse(fs.readFileSync(dataFile, 'utf-8'))\n return {\n testData,\n }\n}\n"],"mappings":"AAyBA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAO,KAAKC,EAAE,MAAM,IAAI;AACxB,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,kBAAkB;AAEnE,IAAMC,WAAW,GAAG,cAAc;AAElC,OAAO,IAAMC,WAAW,GAAGA,CAAA,KAAMN,IAAI,CAACO,IAAI,CAACC,SAAS,EAAEH,WAAW,CAAC;AAClE,OAAO,IAAMI,QAAQ,GAAG,SAAXA,QAAQA,CAAA;EAAA,IAAIC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,OAAKX,IAAI,CAACO,IAAI,CAACD,WAAW,CAAC,CAAC,EAAEI,QAAQ,CAAC;AAAA;AAC7E,IAAMI,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,aAAa,IAAIR,QAAQ,CAAC,YAAY,CAAC;AAEpE,IAAMS,QAAQ,GAAG,IAAId,mBAAmB,CAACF,iBAAiB,EAAEY,QAAQ,EAAE,QAAQ,CAAC;AAC/E,OAAO,IAAMK,OAAO,GAAG,IAAIhB,WAAW,CAACe,QAAQ,CAAC;AAEhD,OAAO,IAAME,OAAO,GAAG,OAAO;AAM9B,OAAO,IAAMC,UAAU,GAAGA,CAAA,KAAmB;EAC3C,IAAMC,QAAQ,GAAG,eAAe;EAChC,IAAMC,QAAQ,GAAGd,QAAQ,CAAC,OAAO,CAAC;EAClC,IAAMe,QAAQ,MAAAC,MAAA,CAAMF,QAAQ,EAAAE,MAAA,CAAGH,QAAQ,CAAE;EACzC,IAAMI,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAAC3B,EAAE,CAAC4B,YAAY,CAACL,QAAQ,EAAE,OAAO,CAAC,CAAC;EAC/D,OAAO;IACLE;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"utils.js","names":["path","fs","environmentPrefix","NodeSession","NodeSettingsIniFile","homeToRoost","getRootPath","join","__dirname","rootFile","fileName","arguments","length","undefined","localIni","process","env","LOOKERSDK_INI","settings","session","timeout","TestConfig","testFile","testPath","dataFile","concat","testData","JSON","parse","readFileSync"],"sources":["../../../src/test-utils/utils.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 path from 'path';\nimport * as fs from 'fs';\nimport { environmentPrefix } from '@looker/sdk';\nimport { NodeSession, NodeSettingsIniFile } from '@looker/sdk-node';\n\nconst homeToRoost = '../../../../';\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost);\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName);\nconst localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini');\n\nconst settings = new NodeSettingsIniFile(environmentPrefix, localIni, 'Looker');\nexport const session = new NodeSession(settings);\n\nexport const timeout = 3600000; // 1 hr\n\ninterface ITestConfig {\n testData: any;\n}\n\nexport const TestConfig = (): ITestConfig => {\n const testFile = 'data.yml.json';\n const testPath = rootFile('test/');\n const dataFile = `${testPath}${testFile}`;\n const testData = JSON.parse(fs.readFileSync(dataFile, 'utf-8'));\n return {\n testData,\n };\n};\n"],"mappings":"AAyBA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAO,KAAKC,EAAE,MAAM,IAAI;AACxB,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,kBAAkB;AAEnE,IAAMC,WAAW,GAAG,cAAc;AAElC,OAAO,IAAMC,WAAW,GAAGA,CAAA,KAAMN,IAAI,CAACO,IAAI,CAACC,SAAS,EAAEH,WAAW,CAAC;AAClE,OAAO,IAAMI,QAAQ,GAAG,SAAXA,QAAQA,CAAA;EAAA,IAAIC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,OAAKX,IAAI,CAACO,IAAI,CAACD,WAAW,CAAC,CAAC,EAAEI,QAAQ,CAAC;AAAA;AAC7E,IAAMI,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,aAAa,IAAIR,QAAQ,CAAC,YAAY,CAAC;AAEpE,IAAMS,QAAQ,GAAG,IAAId,mBAAmB,CAACF,iBAAiB,EAAEY,QAAQ,EAAE,QAAQ,CAAC;AAC/E,OAAO,IAAMK,OAAO,GAAG,IAAIhB,WAAW,CAACe,QAAQ,CAAC;AAEhD,OAAO,IAAME,OAAO,GAAG,OAAO;AAM9B,OAAO,IAAMC,UAAU,GAAGA,CAAA,KAAmB;EAC3C,IAAMC,QAAQ,GAAG,eAAe;EAChC,IAAMC,QAAQ,GAAGd,QAAQ,CAAC,OAAO,CAAC;EAClC,IAAMe,QAAQ,MAAAC,MAAA,CAAMF,QAAQ,EAAAE,MAAA,CAAGH,QAAQ,CAAE;EACzC,IAAMI,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAAC3B,EAAE,CAAC4B,YAAY,CAACL,QAAQ,EAAE,OAAO,CAAC,CAAC;EAC/D,OAAO;IACLE;EACF,CAAC;AACH,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_EmbedUrl","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ServiceFactory","_ThemeService"],"sources":["../src/index.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 */\nexport * from './EmbedUrl'\nexport * from './ServiceFactory'\nexport * from './ThemeService'\n"],"mappings":";;;;;AAyBA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,eAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,eAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,eAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,eAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,aAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,aAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,aAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,aAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":["_EmbedUrl","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ServiceFactory","_ThemeService"],"sources":["../src/index.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 W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version":3,"file":"index.js","names":["_utils","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../src/test-utils/index.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 */\nexport * from './utils'\n"],"mappings":";;;;;AAyBA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":["_utils","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../src/test-utils/index.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 */\nexport * from './utils';\n"],"mappings":";;;;;AAyBA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
@@ -8,23 +8,20 @@ var _path = _interopRequireDefault(require("path"));
8
8
  var fs = _interopRequireWildcard(require("fs"));
9
9
  var _sdk = require("@looker/sdk");
10
10
  var _sdkNode = require("@looker/sdk-node");
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  var homeToRoost = '../../../../';
15
15
  var getRootPath = () => _path.default.join(__dirname, homeToRoost);
16
16
  exports.getRootPath = getRootPath;
17
- var rootFile = function rootFile() {
17
+ var rootFile = exports.rootFile = function rootFile() {
18
18
  var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
19
19
  return _path.default.join(getRootPath(), fileName);
20
20
  };
21
- exports.rootFile = rootFile;
22
21
  var localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini');
23
22
  var settings = new _sdkNode.NodeSettingsIniFile(_sdk.environmentPrefix, localIni, 'Looker');
24
- var session = new _sdkNode.NodeSession(settings);
25
- exports.session = session;
26
- var timeout = 3600000;
27
- exports.timeout = timeout;
23
+ var session = exports.session = new _sdkNode.NodeSession(settings);
24
+ var timeout = exports.timeout = 3600000;
28
25
  var TestConfig = () => {
29
26
  var testFile = 'data.yml.json';
30
27
  var testPath = rootFile('test/');
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_path","_interopRequireDefault","require","fs","_interopRequireWildcard","_sdk","_sdkNode","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","homeToRoost","getRootPath","path","join","__dirname","exports","rootFile","fileName","arguments","length","undefined","localIni","process","env","LOOKERSDK_INI","settings","NodeSettingsIniFile","environmentPrefix","session","NodeSession","timeout","TestConfig","testFile","testPath","dataFile","concat","testData","JSON","parse","readFileSync"],"sources":["../../src/test-utils/utils.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 path from 'path'\nimport * as fs from 'fs'\nimport { environmentPrefix } from '@looker/sdk'\nimport { NodeSession, NodeSettingsIniFile } from '@looker/sdk-node'\n\nconst homeToRoost = '../../../../'\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost)\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName)\nconst localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini')\n\nconst settings = new NodeSettingsIniFile(environmentPrefix, localIni, 'Looker')\nexport const session = new NodeSession(settings)\n\nexport const timeout = 3600000 // 1 hr\n\ninterface ITestConfig {\n testData: any\n}\n\nexport const TestConfig = (): ITestConfig => {\n const testFile = 'data.yml.json'\n const testPath = rootFile('test/')\n const dataFile = `${testPath}${testFile}`\n const testData = JSON.parse(fs.readFileSync(dataFile, 'utf-8'))\n return {\n testData,\n }\n}\n"],"mappings":";;;;;;AAyBA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,EAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAmE,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,E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AAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,OAAKN,aAAI,CAACC,IAAI,CAACF,WAAW,CAAC,CAAC,EAAEM,QAAQ,CAAC;AAAA;AAAAF,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAC7E,IAAMK,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,aAAa,IAAIR,QAAQ,CAAC,YAAY,CAAC;AAEpE,IAAMS,QAAQ,GAAG,IAAIC,4BAAmB,CAACC,sBAAiB,EAAEN,QAAQ,EAAE,QAAQ,CAAC;AACxE,IAAMO,OAAO,GAAG,IAAIC,oBAAW,CAACJ,QAAQ,CAAC;AAAAV,OAAA,CAAAa,OAAA,GAAAA,OAAA;AAEzC,IAAME,OAAO,GAAG,OAAO;AAAAf,OAAA,CAAAe,OAAA,GAAAA,OAAA;AAMvB,IAAMC,UAAU,GAAGA,CAAA,KAAmB;EAC3C,IAAMC,QAAQ,GAAG,eAAe;EAChC,IAAMC,QAAQ,GAAGjB,QAAQ,CAAC,OAAO,CAAC;EAClC,IAAMkB,QAAQ,MAAAC,MAAA,CAAMF,QAAQ,EAAAE,MAAA,CAAGH,QAAQ,CAAE;EACzC,IAAMI,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACtD,EAAE,CAACuD,YAAY,CAACL,QAAQ,EAAE,OAAO,CAAC,CAAC;EAC/D,OAAO;IACLE;EACF,CAAC;AACH,CAAC;AAAArB,OAAA,CAAAgB,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"file":"utils.js","names":["_path","_interopRequireDefault","require","fs","_interopRequireWildcard","_sdk","_sdkNode","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","homeToRoost","getRootPath","path","join","__dirname","exports","rootFile","fileName","arguments","length","undefined","localIni","process","env","LOOKERSDK_INI","settings","NodeSettingsIniFile","environmentPrefix","session","NodeSession","timeout","TestConfig","testFile","testPath","dataFile","concat","testData","JSON","parse","readFileSync"],"sources":["../../src/test-utils/utils.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 path from 'path';\nimport * as fs from 'fs';\nimport { environmentPrefix } from '@looker/sdk';\nimport { NodeSession, NodeSettingsIniFile } from '@looker/sdk-node';\n\nconst homeToRoost = '../../../../';\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost);\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName);\nconst localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini');\n\nconst settings = new NodeSettingsIniFile(environmentPrefix, localIni, 'Looker');\nexport const session = new NodeSession(settings);\n\nexport const timeout = 3600000; // 1 hr\n\ninterface ITestConfig {\n testData: any;\n}\n\nexport const TestConfig = (): ITestConfig => {\n const testFile = 'data.yml.json';\n const testPath = rootFile('test/');\n const dataFile = `${testPath}${testFile}`;\n const testData = JSON.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,YAAY,CAACL,QAAQ,EAAE,OAAO,CAAC,CAAC;EAC/D,OAAO;IACLE;EACF,CAAC;AACH,CAAC;AAACrB,OAAA,CAAAgB,UAAA,GAAAA,UAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/embed-services",
3
- "version": "23.20.0",
3
+ "version": "24.2.0",
4
4
  "description": "Looker Embed Services",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -34,16 +34,16 @@
34
34
  },
35
35
  "homepage": "https://github.com/looker-open-source/sdk-codegen/tree/master/packages/embed-services",
36
36
  "devDependencies": {
37
- "@looker/sdk-node": "^23.20.0"
37
+ "@looker/sdk-node": "24.2.0"
38
38
  },
39
39
  "dependencies": {
40
- "@looker/sdk": "^23.20.0",
41
- "@looker/sdk-rtl": "^21.6.1"
40
+ "@looker/sdk": "24.2.0",
41
+ "@looker/sdk-rtl": "21.6.1"
42
42
  },
43
43
  "keywords": [
44
44
  "Looker",
45
45
  "Embed",
46
46
  "Embed Services"
47
47
  ],
48
- "gitHead": "6ddfe7d939143e194e58cdba4e58e016dd208105"
48
+ "gitHead": "03ab16f5fccfc3030b1963297bb5502873a9c3f0"
49
49
  }