@looker/embed-services 24.14.0 → 24.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [24.16.1](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v24.16.0...embed-services-v24.16.1) (2024-09-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fix release 24.16.2 ([#1505](https://github.com/looker-open-source/sdk-codegen/issues/1505)) ([1cd1806](https://github.com/looker-open-source/sdk-codegen/commit/1cd180615901d2daf1fb112b41f2a72d2caacf61))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @looker/sdk-rtl bumped from 21.6.2 to 21.6.3
16
+ * @looker/sdk bumped from 24.16.0 to 24.16.1
17
+ * devDependencies
18
+ * @looker/sdk-node bumped from 24.16.0 to 24.16.1
19
+
20
+ ## [24.16.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v24.14.0...embed-services-v24.16.0) (2024-09-11)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * Remove the requests package from the TypeScript SDK ([#1491](https://github.com/looker-open-source/sdk-codegen/issues/1491)) ([670377c](https://github.com/looker-open-source/sdk-codegen/commit/670377c46a546bbd8dcc6679b8aeb041da1b4670)), closes [#1439](https://github.com/looker-open-source/sdk-codegen/issues/1439)
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @looker/sdk-rtl bumped from 21.6.1 to 21.6.2
33
+ * @looker/sdk bumped from 24.14.0 to 24.16.0
34
+ * devDependencies
35
+ * @looker/sdk-node bumped from 24.14.0 to 24.16.0
36
+
3
37
  ## [24.14.0](https://github.com/looker-open-source/sdk-codegen/compare/embed-services-v24.12.1...embed-services-v24.14.0) (2024-08-12)
4
38
 
5
39
 
@@ -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(\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"}
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 +1 @@
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,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,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GAAAO,MAAA,EAAAV,CAAA;AAEzC,IAAMW,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,GAAG;AA6CvB,MAAeE,QAAQ,SACpBC,4BAAa,CAEvB;EAOEC,WAAWA,CAACC,GAAgB,EAA4B;IAAA,IAA1BC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAA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AAE;MAC3B4C,IAAI,GAAG,CAAC5C,GAAG,CAAC;IACd,CAAC,MAAM;MACL4C,IAAI,GAAG5C,GAAqB;IAC9B;IAEA,IAAI;MACF,IAAM6C,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,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
+ {"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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AACD,KAAK,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 +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","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,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M,CAAExB,IAAI,IAAKA,IAAI,CAACN,EAAE,KAAKA,EAAE,CAAC;MACxD4B,MAAI,CAACf,KAAK,CAAC,CAAC;IAAC;EACf;EAEMK,IAAIA,CAACjB,OAAoB,EAAE;IAAA,IAAA8B,MAAA;IAAA,OAAA9D,iBAAA;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;IAAC;EACd;AACF;AAEO,IAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,cAAc;AAOzC,IAAME,mBAAsD,GAAGA,CACpE3B,GAAgB,EAChB4B,UAAmB,KAChB;EACH,OAAO,IAAIxC,YAAY,CAACY,GAAG,EAAE4B,UAAU,CAAC;AAC1C,CAAC;AAACF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAMK,IAAME,oBAAoB,GAAID,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
+ {"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,EAAA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3B,GAAgB,EAChB4B,UAAmB,KAChB;EACH,OAAO,IAAIxC,YAAY,CAACY,GAAG,EAAE4B,UAAU,CAAC;AAC1C,CAAC;AAACF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAMK,IAAME,oBAAoB,GAAID,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 +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(\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
+ {"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 +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 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,CAAC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,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,KAAK/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,CAACC,EAAE,IAAI;MACvB,IAAIA,EAAE,IAAIA,EAAE,aAAFA,EAAE,eAAFA,EAAE,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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,KAAK/B,SAAS,GAC9D6B,OAAO,CAACE,QAAQ,GAChB,IAAI;IACV,OAAOD,KAAK;EACd;AACF"}
@@ -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 { 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,C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AG,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,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AC1C,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/embed-services",
3
- "version": "24.14.0",
3
+ "version": "24.16.1",
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": "24.14.0"
37
+ "@looker/sdk-node": "24.16.1"
38
38
  },
39
39
  "dependencies": {
40
- "@looker/sdk": "24.14.0",
41
- "@looker/sdk-rtl": "21.6.1"
40
+ "@looker/sdk": "24.16.1",
41
+ "@looker/sdk-rtl": "21.6.3"
42
42
  },
43
43
  "keywords": [
44
44
  "Looker",
45
45
  "Embed",
46
46
  "Embed Services"
47
47
  ],
48
- "gitHead": "0c6b5c02305ad67f559213a281667ba5cbb3b3c3"
48
+ "gitHead": "f95fdcebe3e11b4cf1c7d07e26a6b8a153bd074f"
49
49
  }