@looker/sdk-rtl 21.6.1 → 21.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +55 -62
  2. package/README.md +101 -1
  3. package/lib/CSRFSession.js +2 -2
  4. package/lib/CSRFSession.js.map +1 -1
  5. package/lib/apiMethods.d.ts +2 -19
  6. package/lib/apiMethods.js +4 -4
  7. package/lib/apiMethods.js.map +1 -1
  8. package/lib/apiSettings.d.ts +1 -1
  9. package/lib/apiSettings.js +3 -4
  10. package/lib/apiSettings.js.map +1 -1
  11. package/lib/authSession.js +2 -2
  12. package/lib/authSession.js.map +1 -1
  13. package/lib/authToken.js +2 -2
  14. package/lib/authToken.js.map +1 -1
  15. package/lib/baseTransport.d.ts +4 -3
  16. package/lib/baseTransport.js +57 -2
  17. package/lib/baseTransport.js.map +1 -1
  18. package/lib/browser.js.map +1 -1
  19. package/lib/browserServices.js +2 -2
  20. package/lib/browserServices.js.map +1 -1
  21. package/lib/browserSession.d.ts +1 -1
  22. package/lib/browserSession.js +4 -4
  23. package/lib/browserSession.js.map +1 -1
  24. package/lib/browserTransport.d.ts +3 -4
  25. package/lib/browserTransport.js +98 -80
  26. package/lib/browserTransport.js.map +1 -1
  27. package/lib/constants.d.ts +7 -4
  28. package/lib/constants.js +5 -10
  29. package/lib/constants.js.map +1 -1
  30. package/lib/cryptoHash.js.map +1 -1
  31. package/lib/delimArray.d.ts +1 -1
  32. package/lib/delimArray.js +2 -2
  33. package/lib/delimArray.js.map +1 -1
  34. package/lib/errorDoc.d.ts +3 -3
  35. package/lib/errorDoc.js +7 -10
  36. package/lib/errorDoc.js.map +1 -1
  37. package/lib/esm/CSRFSession.js +6 -13
  38. package/lib/esm/CSRFSession.js.map +1 -1
  39. package/lib/esm/apiMethods.js +9 -17
  40. package/lib/esm/apiMethods.js.map +1 -1
  41. package/lib/esm/apiSettings.js +20 -32
  42. package/lib/esm/apiSettings.js.map +1 -1
  43. package/lib/esm/authSession.js +6 -13
  44. package/lib/esm/authSession.js.map +1 -1
  45. package/lib/esm/authToken.js +3 -10
  46. package/lib/esm/authToken.js.map +1 -1
  47. package/lib/esm/baseTransport.js +61 -13
  48. package/lib/esm/baseTransport.js.map +1 -1
  49. package/lib/esm/browser.js +17 -192
  50. package/lib/esm/browser.js.map +1 -1
  51. package/lib/esm/browserServices.js +8 -15
  52. package/lib/esm/browserServices.js.map +1 -1
  53. package/lib/esm/browserSession.js +12 -19
  54. package/lib/esm/browserSession.js.map +1 -1
  55. package/lib/esm/browserTransport.js +104 -94
  56. package/lib/esm/browserTransport.js.map +1 -1
  57. package/lib/esm/constants.js +8 -22
  58. package/lib/esm/constants.js.map +1 -1
  59. package/lib/esm/cryptoHash.js.map +1 -1
  60. package/lib/esm/delimArray.js +3 -10
  61. package/lib/esm/delimArray.js.map +1 -1
  62. package/lib/esm/errorDoc.js +10 -20
  63. package/lib/esm/errorDoc.js.map +1 -1
  64. package/lib/esm/extensionSession.js +3 -10
  65. package/lib/esm/extensionSession.js.map +1 -1
  66. package/lib/esm/extensionTransport.js +8 -12
  67. package/lib/esm/extensionTransport.js.map +1 -1
  68. package/lib/esm/index.js +22 -236
  69. package/lib/esm/index.js.map +1 -1
  70. package/lib/esm/lookerSDKError.js +9 -19
  71. package/lib/esm/lookerSDKError.js.map +1 -1
  72. package/lib/esm/oauthSession.js +15 -22
  73. package/lib/esm/oauthSession.js.map +1 -1
  74. package/lib/esm/paging.js +11 -23
  75. package/lib/esm/paging.js.map +1 -1
  76. package/lib/esm/platformServices.js.map +1 -1
  77. package/lib/esm/proxySession.js +6 -13
  78. package/lib/esm/proxySession.js.map +1 -1
  79. package/lib/esm/sleep.js +14 -0
  80. package/lib/esm/sleep.js.map +1 -0
  81. package/lib/esm/testUtils/index.js +1 -16
  82. package/lib/esm/testUtils/index.js.map +1 -1
  83. package/lib/esm/testUtils/testUtils.js +20 -26
  84. package/lib/esm/testUtils/testUtils.js.map +1 -1
  85. package/lib/esm/transport.js +122 -57
  86. package/lib/esm/transport.js.map +1 -1
  87. package/lib/extensionSession.d.ts +1 -1
  88. package/lib/extensionSession.js +2 -2
  89. package/lib/extensionSession.js.map +1 -1
  90. package/lib/extensionTransport.d.ts +3 -3
  91. package/lib/extensionTransport.js +7 -4
  92. package/lib/extensionTransport.js.map +1 -1
  93. package/lib/index.d.ts +1 -0
  94. package/lib/index.js +11 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/lookerSDKError.d.ts +1 -1
  97. package/lib/lookerSDKError.js +9 -13
  98. package/lib/lookerSDKError.js.map +1 -1
  99. package/lib/oauthSession.d.ts +6 -4
  100. package/lib/oauthSession.js +7 -7
  101. package/lib/oauthSession.js.map +1 -1
  102. package/lib/paging.d.ts +5 -6
  103. package/lib/paging.js +4 -6
  104. package/lib/paging.js.map +1 -1
  105. package/lib/platformServices.js.map +1 -1
  106. package/lib/proxySession.d.ts +1 -1
  107. package/lib/proxySession.js.map +1 -1
  108. package/lib/sleep.d.ts +1 -0
  109. package/lib/sleep.js +20 -0
  110. package/lib/sleep.js.map +1 -0
  111. package/lib/testUtils/index.js.map +1 -1
  112. package/lib/testUtils/testUtils.js +16 -11
  113. package/lib/testUtils/testUtils.js.map +1 -1
  114. package/lib/transport.d.ts +64 -17
  115. package/lib/transport.js +113 -20
  116. package/lib/transport.js.map +1 -1
  117. package/package.json +5 -13
package/CHANGELOG.md CHANGED
@@ -5,197 +5,190 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [21.6.1](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.6.0...sdk-rtl-v21.6.1) (2023-06-15)
8
+ ## [21.6.4](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.6.3...sdk-rtl-v21.6.4) (2025-03-11)
9
9
 
10
10
 
11
11
  ### Bug Fixes
12
12
 
13
- * use new CDN for errorcodes repository ([#1320](https://github.com/looker-open-source/sdk-codegen/issues/1320)) ([df40441](https://github.com/looker-open-source/sdk-codegen/commit/df40441cb1f187df5469f834486f8ff4de82c266))
13
+ * add new generators for the TypeScript SDK ([#1563](https://github.com/looker-open-source/sdk-codegen/issues/1563)) ([86ab782](https://github.com/looker-open-source/sdk-codegen/commit/86ab7820c4ca095be20e219c5bd19ef3bfc3f030))
14
14
 
15
- ## [21.6.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.5.0...sdk-rtl-v21.6.0) (2023-02-22)
15
+ ## [21.6.3](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.6.2...sdk-rtl-v21.6.3) (2024-09-14)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * 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))
21
+
22
+ ## [21.6.2](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.6.1...sdk-rtl-v21.6.2) (2024-09-11)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * 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)
16
28
 
29
+ ## [21.6.1](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.6.0...sdk-rtl-v21.6.1) (2023-06-15)
30
+
31
+ ### Bug Fixes
32
+
33
+ - use new CDN for errorcodes repository ([#1320](https://github.com/looker-open-source/sdk-codegen/issues/1320)) ([df40441](https://github.com/looker-open-source/sdk-codegen/commit/df40441cb1f187df5469f834486f8ff4de82c266))
34
+
35
+ ## [21.6.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.5.0...sdk-rtl-v21.6.0) (2023-02-22)
17
36
 
18
37
  ### Features
19
38
 
20
- * keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
39
+ - keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
21
40
 
22
41
  ## [21.5.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.4.0...sdk-rtl-v21.5.0) (2022-12-09)
23
42
 
24
-
25
43
  ### Features
26
44
 
27
- * add request time tracking ([#1223](https://www.github.com/looker-open-source/sdk-codegen/issues/1223)) ([2aefe06](https://www.github.com/looker-open-source/sdk-codegen/commit/2aefe064d668e02f3af95202e4667036cba01979))
45
+ - add request time tracking ([#1223](https://www.github.com/looker-open-source/sdk-codegen/issues/1223)) ([2aefe06](https://www.github.com/looker-open-source/sdk-codegen/commit/2aefe064d668e02f3af95202e4667036cba01979))
28
46
 
29
47
  ## [21.4.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.4...sdk-rtl-v21.4.0) (2022-09-21)
30
48
 
31
-
32
49
  ### Features
33
50
 
34
- * error code document retrieval ([#1136](https://www.github.com/looker-open-source/sdk-codegen/issues/1136)) ([305966b](https://www.github.com/looker-open-source/sdk-codegen/commit/305966b943e8dc6fde08d58cbb36febcbae5733f))
35
- * error document retrieval in API Explorer ([#1161](https://www.github.com/looker-open-source/sdk-codegen/issues/1161)) ([89a94e1](https://www.github.com/looker-open-source/sdk-codegen/commit/89a94e167b8a3e1aa662c0b5de7c585b3eac2f13))
36
-
51
+ - error code document retrieval ([#1136](https://www.github.com/looker-open-source/sdk-codegen/issues/1136)) ([305966b](https://www.github.com/looker-open-source/sdk-codegen/commit/305966b943e8dc6fde08d58cbb36febcbae5733f))
52
+ - error document retrieval in API Explorer ([#1161](https://www.github.com/looker-open-source/sdk-codegen/issues/1161)) ([89a94e1](https://www.github.com/looker-open-source/sdk-codegen/commit/89a94e167b8a3e1aa662c0b5de7c585b3eac2f13))
37
53
 
38
54
  ### Bug Fixes
39
55
 
40
- * add ErrorDoc class to the Kotlin SDK ([#1143](https://www.github.com/looker-open-source/sdk-codegen/issues/1143)) ([20fbd31](https://www.github.com/looker-open-source/sdk-codegen/commit/20fbd31939e0ff88b9be3fdcf260176069143925))
41
- * add field details for SDK error ([#1134](https://www.github.com/looker-open-source/sdk-codegen/issues/1134)) ([ef1c96d](https://www.github.com/looker-open-source/sdk-codegen/commit/ef1c96d9bc1ae7c27b6ec4b07c7d33f04930d2a7))
42
- * add field details for SDK error ([#1141](https://www.github.com/looker-open-source/sdk-codegen/issues/1141)) ([9af3092](https://www.github.com/looker-open-source/sdk-codegen/commit/9af30928417e773b6e23a539012bdf9381490a13))
43
- * IErrorDetail fields should not be null ([#1146](https://www.github.com/looker-open-source/sdk-codegen/issues/1146)) ([44274b4](https://www.github.com/looker-open-source/sdk-codegen/commit/44274b4a3974ff4b946a9a0f3209c70cd77b245e))
56
+ - add ErrorDoc class to the Kotlin SDK ([#1143](https://www.github.com/looker-open-source/sdk-codegen/issues/1143)) ([20fbd31](https://www.github.com/looker-open-source/sdk-codegen/commit/20fbd31939e0ff88b9be3fdcf260176069143925))
57
+ - add field details for SDK error ([#1134](https://www.github.com/looker-open-source/sdk-codegen/issues/1134)) ([ef1c96d](https://www.github.com/looker-open-source/sdk-codegen/commit/ef1c96d9bc1ae7c27b6ec4b07c7d33f04930d2a7))
58
+ - add field details for SDK error ([#1141](https://www.github.com/looker-open-source/sdk-codegen/issues/1141)) ([9af3092](https://www.github.com/looker-open-source/sdk-codegen/commit/9af30928417e773b6e23a539012bdf9381490a13))
59
+ - IErrorDetail fields should not be null ([#1146](https://www.github.com/looker-open-source/sdk-codegen/issues/1146)) ([44274b4](https://www.github.com/looker-open-source/sdk-codegen/commit/44274b4a3974ff4b946a9a0f3209c70cd77b245e))
44
60
 
45
61
  ### [21.3.4](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.3...sdk-rtl-v21.3.4) (2022-07-07)
46
62
 
47
-
48
63
  ### Bug Fixes
49
64
 
50
- * correct HTTP status code values ([#1101](https://www.github.com/looker-open-source/sdk-codegen/issues/1101)) ([3d0f902](https://www.github.com/looker-open-source/sdk-codegen/commit/3d0f902b67d6384c08641579ae959829c78d1994))
65
+ - correct HTTP status code values ([#1101](https://www.github.com/looker-open-source/sdk-codegen/issues/1101)) ([3d0f902](https://www.github.com/looker-open-source/sdk-codegen/commit/3d0f902b67d6384c08641579ae959829c78d1994))
51
66
 
52
67
  ### [21.3.3](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.2...sdk-rtl-v21.3.3) (2022-04-07)
53
68
 
54
-
55
69
  ### Bug Fixes
56
70
 
57
- * encodeParam doc tweak to republish ([#1050](https://www.github.com/looker-open-source/sdk-codegen/issues/1050)) ([512bc81](https://www.github.com/looker-open-source/sdk-codegen/commit/512bc81865a9f5cbf8fafb83f41dfc2e8629ff3b))
71
+ - encodeParam doc tweak to republish ([#1050](https://www.github.com/looker-open-source/sdk-codegen/issues/1050)) ([512bc81](https://www.github.com/looker-open-source/sdk-codegen/commit/512bc81865a9f5cbf8fafb83f41dfc2e8629ff3b))
58
72
 
59
73
  ### [21.3.2](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.1...sdk-rtl-v21.3.2) (2022-04-07)
60
74
 
61
-
62
75
  ### Bug Fixes
63
76
 
64
- * encodeParam returned [object Object] for object types ([#1047](https://www.github.com/looker-open-source/sdk-codegen/issues/1047)) ([eccc1db](https://www.github.com/looker-open-source/sdk-codegen/commit/eccc1dbb3d64f36e6a06d71a1c3da37d972abd3a))
77
+ - encodeParam returned [object Object] for object types ([#1047](https://www.github.com/looker-open-source/sdk-codegen/issues/1047)) ([eccc1db](https://www.github.com/looker-open-source/sdk-codegen/commit/eccc1dbb3d64f36e6a06d71a1c3da37d972abd3a))
65
78
 
66
79
  ### [21.3.1](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.2.0...sdk-rtl-v21.3.1) (2022-01-27)
67
80
 
68
-
69
81
  ### Features
70
82
 
71
- * add http method to IRawResponse ([#925](https://www.github.com/looker-open-source/sdk-codegen/issues/925)) ([25cef47](https://www.github.com/looker-open-source/sdk-codegen/commit/25cef47fa61a5f15565560b48f5e0c45a0cd9b44))
72
-
83
+ - add http method to IRawResponse ([#925](https://www.github.com/looker-open-source/sdk-codegen/issues/925)) ([25cef47](https://www.github.com/looker-open-source/sdk-codegen/commit/25cef47fa61a5f15565560b48f5e0c45a0cd9b44))
73
84
 
74
85
  ### Bug Fixes
75
86
 
76
- * rtl IError type ([#928](https://www.github.com/looker-open-source/sdk-codegen/issues/928)) ([7d8f906](https://www.github.com/looker-open-source/sdk-codegen/commit/7d8f906f4b10b5e915df292fcf30d1eb456c3463))
77
- * **sdk-rtl/src/delimArray:** Fixed issue with single element number array ([#927](https://www.github.com/looker-open-source/sdk-codegen/issues/927)) ([6e94d73](https://www.github.com/looker-open-source/sdk-codegen/commit/6e94d73f88fb6c2f3138818967f4e8cb49ff89e6))
87
+ - rtl IError type ([#928](https://www.github.com/looker-open-source/sdk-codegen/issues/928)) ([7d8f906](https://www.github.com/looker-open-source/sdk-codegen/commit/7d8f906f4b10b5e915df292fcf30d1eb456c3463))
88
+ - **sdk-rtl/src/delimArray:** Fixed issue with single element number array ([#927](https://www.github.com/looker-open-source/sdk-codegen/issues/927)) ([6e94d73](https://www.github.com/looker-open-source/sdk-codegen/commit/6e94d73f88fb6c2f3138818967f4e8cb49ff89e6))
78
89
 
79
90
  ### [21.3.1](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.0...sdk-rtl-v21.3.1) (2021-12-20)
80
91
 
81
-
82
92
  ### Bug Fixes
83
93
 
84
- * rtl IError type ([#928](https://www.github.com/looker-open-source/sdk-codegen/issues/928)) ([7d8f906](https://www.github.com/looker-open-source/sdk-codegen/commit/7d8f906f4b10b5e915df292fcf30d1eb456c3463))
94
+ - rtl IError type ([#928](https://www.github.com/looker-open-source/sdk-codegen/issues/928)) ([7d8f906](https://www.github.com/looker-open-source/sdk-codegen/commit/7d8f906f4b10b5e915df292fcf30d1eb456c3463))
85
95
 
86
96
  ## [21.3.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.2.0...sdk-rtl-v21.3.0) (2021-12-16)
87
97
 
88
-
89
98
  ### Features
90
99
 
91
- * add http method to IRawResponse ([#925](https://www.github.com/looker-open-source/sdk-codegen/issues/925)) ([25cef47](https://www.github.com/looker-open-source/sdk-codegen/commit/25cef47fa61a5f15565560b48f5e0c45a0cd9b44))
100
+ - add http method to IRawResponse ([#925](https://www.github.com/looker-open-source/sdk-codegen/issues/925)) ([25cef47](https://www.github.com/looker-open-source/sdk-codegen/commit/25cef47fa61a5f15565560b48f5e0c45a0cd9b44))
92
101
 
93
102
  ## [21.2.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.1.1...sdk-rtl-v21.2.0) (2021-11-10)
94
103
 
95
-
96
104
  ### Features
97
105
 
98
- * create @looker/extension-utils ([#886](https://www.github.com/looker-open-source/sdk-codegen/issues/886)) ([9d1720d](https://www.github.com/looker-open-source/sdk-codegen/commit/9d1720d9a4cec00c45195dd9c716d9a2a929264f))
106
+ - create @looker/extension-utils ([#886](https://www.github.com/looker-open-source/sdk-codegen/issues/886)) ([9d1720d](https://www.github.com/looker-open-source/sdk-codegen/commit/9d1720d9a4cec00c45195dd9c716d9a2a929264f))
99
107
 
100
108
  ### [21.1.1](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.1.0...sdk-rtl-v21.1.1) (2021-10-27)
101
109
 
102
-
103
110
  ### Bug Fixes
104
111
 
105
- * another TS SDK error handling tweak ([#873](https://www.github.com/looker-open-source/sdk-codegen/issues/873)) ([1c04952](https://www.github.com/looker-open-source/sdk-codegen/commit/1c049527e22926fa7fe0ae011ab4595520005e2f))
112
+ - another TS SDK error handling tweak ([#873](https://www.github.com/looker-open-source/sdk-codegen/issues/873)) ([1c04952](https://www.github.com/looker-open-source/sdk-codegen/commit/1c049527e22926fa7fe0ae011ab4595520005e2f))
106
113
 
107
114
  ## [21.1.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.20...sdk-rtl-v21.1.0) (2021-10-19)
108
115
 
109
-
110
116
  ### Features
111
117
 
112
- * closest path match for API Explorer ([#811](https://www.github.com/looker-open-source/sdk-codegen/issues/811)) ([45fd26f](https://www.github.com/looker-open-source/sdk-codegen/commit/45fd26fb0f325fa90edfec72f835ed3a79b9afeb))
118
+ - closest path match for API Explorer ([#811](https://www.github.com/looker-open-source/sdk-codegen/issues/811)) ([45fd26f](https://www.github.com/looker-open-source/sdk-codegen/commit/45fd26fb0f325fa90edfec72f835ed3a79b9afeb))
113
119
 
114
120
  ### [21.0.20](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.19...sdk-rtl-v21.0.20) (2021-09-01)
115
121
 
116
-
117
122
  ### Features
118
123
 
119
- * http response explorer for RunIt ([#800](https://www.github.com/looker-open-source/sdk-codegen/issues/800)) ([3f273ea](https://www.github.com/looker-open-source/sdk-codegen/commit/3f273ea7f849dafece8f4f5f60558021ecd41705))
120
-
124
+ - http response explorer for RunIt ([#800](https://www.github.com/looker-open-source/sdk-codegen/issues/800)) ([3f273ea](https://www.github.com/looker-open-source/sdk-codegen/commit/3f273ea7f849dafece8f4f5f60558021ecd41705))
121
125
 
122
126
  ### Bug Fixes
123
127
 
124
- * placate TypeScript 4.4 ([#809](https://www.github.com/looker-open-source/sdk-codegen/issues/809)) ([6509c17](https://www.github.com/looker-open-source/sdk-codegen/commit/6509c17da655be1fb7d51d0275b9e198aa6ae929))
128
+ - placate TypeScript 4.4 ([#809](https://www.github.com/looker-open-source/sdk-codegen/issues/809)) ([6509c17](https://www.github.com/looker-open-source/sdk-codegen/commit/6509c17da655be1fb7d51d0275b9e198aa6ae929))
125
129
 
126
130
  ### [21.0.19](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.18...sdk-rtl-v21.0.19) (2021-07-30)
127
131
 
128
-
129
132
  ### Bug Fixes
130
133
 
131
- * support response observer chaining ([025618c](https://www.github.com/looker-open-source/sdk-codegen/commit/025618c806efc1664b4f573248ad5a64d6cee3e3))
134
+ - support response observer chaining ([025618c](https://www.github.com/looker-open-source/sdk-codegen/commit/025618c806efc1664b4f573248ad5a64d6cee3e3))
132
135
 
133
136
  ### [21.0.18](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.17...sdk-rtl-v21.0.18) (2021-07-09)
134
137
 
135
-
136
138
  ### Bug Fixes
137
139
 
138
- * browserTransport.ts retains ok: false now ([#745](https://www.github.com/looker-open-source/sdk-codegen/issues/745)) ([451481c](https://www.github.com/looker-open-source/sdk-codegen/commit/451481c62cdc986c860c582e4a77e3e887c6a732))
140
+ - browserTransport.ts retains ok: false now ([#745](https://www.github.com/looker-open-source/sdk-codegen/issues/745)) ([451481c](https://www.github.com/looker-open-source/sdk-codegen/commit/451481c62cdc986c860c582e4a77e3e887c6a732))
139
141
 
140
142
  ### [21.0.17](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.16...sdk-rtl-v21.0.17) (2021-07-08)
141
143
 
142
-
143
144
  ### Bug Fixes
144
145
 
145
- * add a test to additional query param required bug ([#741](https://www.github.com/looker-open-source/sdk-codegen/issues/741)) ([0cbe656](https://www.github.com/looker-open-source/sdk-codegen/commit/0cbe656aaf53f6f92fafcc62eeb573e0ff2d0a19))
146
- * check HTTP status code for TS SDK "ok" toggle ([#739](https://www.github.com/looker-open-source/sdk-codegen/issues/739)) ([3ed6af7](https://www.github.com/looker-open-source/sdk-codegen/commit/3ed6af78b2cb9610b3386ff851013a93fff40f54))
146
+ - add a test to additional query param required bug ([#741](https://www.github.com/looker-open-source/sdk-codegen/issues/741)) ([0cbe656](https://www.github.com/looker-open-source/sdk-codegen/commit/0cbe656aaf53f6f92fafcc62eeb573e0ff2d0a19))
147
+ - check HTTP status code for TS SDK "ok" toggle ([#739](https://www.github.com/looker-open-source/sdk-codegen/issues/739)) ([3ed6af7](https://www.github.com/looker-open-source/sdk-codegen/commit/3ed6af78b2cb9610b3386ff851013a93fff40f54))
147
148
 
148
149
  ### [21.0.16](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.15...sdk-rtl-v21.0.16) (2021-07-02)
149
150
 
150
-
151
151
  ### Bug Fixes
152
152
 
153
- * explain pager and pageAll sdk param better ([#736](https://www.github.com/looker-open-source/sdk-codegen/issues/736)) ([a93a9b1](https://www.github.com/looker-open-source/sdk-codegen/commit/a93a9b1ded0acddeaf051e7a2fed5132c1cb5c0c))
153
+ - explain pager and pageAll sdk param better ([#736](https://www.github.com/looker-open-source/sdk-codegen/issues/736)) ([a93a9b1](https://www.github.com/looker-open-source/sdk-codegen/commit/a93a9b1ded0acddeaf051e7a2fed5132c1cb5c0c))
154
154
 
155
155
  ### [21.0.15](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.14...sdk-rtl-v21.0.15) (2021-07-01)
156
156
 
157
-
158
157
  ### Bug Fixes
159
158
 
160
- * paging parsing issues ([#728](https://www.github.com/looker-open-source/sdk-codegen/issues/728)) ([f8eec43](https://www.github.com/looker-open-source/sdk-codegen/commit/f8eec43bdfbe337d41b1da02c127d690c8815ed3))
159
+ - paging parsing issues ([#728](https://www.github.com/looker-open-source/sdk-codegen/issues/728)) ([f8eec43](https://www.github.com/looker-open-source/sdk-codegen/commit/f8eec43bdfbe337d41b1da02c127d690c8815ed3))
161
160
 
162
161
  ### [21.0.14](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.13...sdk-rtl-v21.0.14) (2021-06-30)
163
162
 
164
-
165
163
  ### Features
166
164
 
167
- * paging results for the Typescript SDK ([#698](https://www.github.com/looker-open-source/sdk-codegen/issues/698)) ([537eb57](https://www.github.com/looker-open-source/sdk-codegen/commit/537eb579b9c6d95d600f455a187e6d7b9bf700ef))
165
+ - paging results for the Typescript SDK ([#698](https://www.github.com/looker-open-source/sdk-codegen/issues/698)) ([537eb57](https://www.github.com/looker-open-source/sdk-codegen/commit/537eb579b9c6d95d600f455a187e6d7b9bf700ef))
168
166
 
169
167
  ### [21.0.13](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.12...sdk-rtl-v21.0.13) (2021-05-05)
170
168
 
171
-
172
169
  ### Bug Fixes
173
170
 
174
- * use "TypeScript" and "JavaScript" everywhere ([#644](https://www.github.com/looker-open-source/sdk-codegen/issues/644)) ([c15031c](https://www.github.com/looker-open-source/sdk-codegen/commit/c15031cee189556adbd9e18641e7c992e86e3611))
171
+ - use "TypeScript" and "JavaScript" everywhere ([#644](https://www.github.com/looker-open-source/sdk-codegen/issues/644)) ([c15031c](https://www.github.com/looker-open-source/sdk-codegen/commit/c15031cee189556adbd9e18641e7c992e86e3611))
175
172
 
176
173
  ### [21.0.12](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.11...sdk-rtl-v21.0.12) (2021-04-15)
177
174
 
178
-
179
175
  ### Features
180
176
 
181
- * TypeScript SDK tree-shaking support ([#580](https://www.github.com/looker-open-source/sdk-codegen/issues/580)) ([8b7f2f0](https://www.github.com/looker-open-source/sdk-codegen/commit/8b7f2f00ab1a765a04bd460a1ca88e9b7bd66a98))
182
-
177
+ - TypeScript SDK tree-shaking support ([#580](https://www.github.com/looker-open-source/sdk-codegen/issues/580)) ([8b7f2f0](https://www.github.com/looker-open-source/sdk-codegen/commit/8b7f2f00ab1a765a04bd460a1ca88e9b7bd66a98))
183
178
 
184
179
  ### Bug Fixes
185
180
 
186
- * TypeScript OAuth test ([#597](https://www.github.com/looker-open-source/sdk-codegen/issues/597)) ([d84d1fc](https://www.github.com/looker-open-source/sdk-codegen/commit/d84d1fc976b52f01981592eacb3abc8e1aab9f1f))
181
+ - TypeScript OAuth test ([#597](https://www.github.com/looker-open-source/sdk-codegen/issues/597)) ([d84d1fc](https://www.github.com/looker-open-source/sdk-codegen/commit/d84d1fc976b52f01981592eacb3abc8e1aab9f1f))
187
182
 
188
183
  ### [21.0.11](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.10...sdk-rtl-v21.0.11) (2021-04-02)
189
184
 
190
-
191
185
  ### Features
192
186
 
193
- * Added --versions option to the code generator ([#514](https://www.github.com/looker-open-source/sdk-codegen/issues/514)) ([ee6f3e8](https://www.github.com/looker-open-source/sdk-codegen/commit/ee6f3e8f55e300df1a75c9be89b47f067bc08dee))
194
-
187
+ - Added --versions option to the code generator ([#514](https://www.github.com/looker-open-source/sdk-codegen/issues/514)) ([ee6f3e8](https://www.github.com/looker-open-source/sdk-codegen/commit/ee6f3e8f55e300df1a75c9be89b47f067bc08dee))
195
188
 
196
189
  ### Bug Fixes
197
190
 
198
- * TypeScript SDK generator import logic ([#547](https://www.github.com/looker-open-source/sdk-codegen/issues/547)) ([c5aa033](https://www.github.com/looker-open-source/sdk-codegen/commit/c5aa033c749a2db8a0f98d5b8f49dc287fad06a2))
191
+ - TypeScript SDK generator import logic ([#547](https://www.github.com/looker-open-source/sdk-codegen/issues/547)) ([c5aa033](https://www.github.com/looker-open-source/sdk-codegen/commit/c5aa033c749a2db8a0f98d5b8f49dc287fad06a2))
199
192
 
200
193
  ## [21.0.8]
201
194
 
package/README.md CHANGED
@@ -4,4 +4,104 @@ The Looker TypeScript/JavaScript SDK depends on the runtime code in this package
4
4
 
5
5
  The source code in this package is almost all completely generic REST request/response processing code.
6
6
 
7
- The `@looker/sdk` package is updated with every Looker release. This package has a much longer update/release cycle.
7
+ The `@looker/sdk` and `@looker/sdk-node` packages are updated with every Looker release. This package has a much longer update/release cycle.
8
+
9
+ ## HTTP request behavior options
10
+
11
+ The Browser and Node transport layers can be configured with both SDK-wide settings and request-specific optional properties that modify the
12
+ behavior of a request. These properties are documented in [`ITransportSettings`](src/transport.ts).
13
+
14
+ When initializing the SDK, these values configure the default behavior for every HTTP request.
15
+ The behavior of any specific request can be modified by passing different values in the `options` property of the request method.
16
+ Some of these request configuration properties are further explained below.
17
+
18
+ ### timeout
19
+
20
+ If not explicitly configured, the HTTP request `timeout` period is 120 seconds, which is supported in both Node and Browser transport layers via an
21
+ [`AbortSignal.timeout()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static) instance created for each HTTP request.
22
+
23
+ To override the timeout period for a long-running HTTP request, pass a `timeout` override value in the `options` parameter for a request.
24
+
25
+ ```ts
26
+ const xp = new BrowserTransport({ maxTries: 1 } as ITransportSettings);
27
+ const response = await xp.request(
28
+ 'GET',
29
+ 'https://my.slow.page',
30
+ undefined,
31
+ undefined,
32
+ undefined,
33
+ {
34
+ timeout: 15 * 60, // 15 minute timeout
35
+ }
36
+ );
37
+ ```
38
+
39
+ ### signal
40
+
41
+ The `signal` property is an optional [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) argument to pass to a transport's request method. This property
42
+ can be used to cancel a request via programmatic or UI control. The following example is adapted from [browserTransport.spec.ts](src/browserTransport.spec.ts):
43
+
44
+ ```ts
45
+ // times out request in 250 ms via AbortSignal "cancellation"
46
+ const xp = new BrowserTransport({ maxTries: 1 } as ITransportSettings);
47
+ const signal = AbortSignal.timeout(250);
48
+ await expect(
49
+ xp.request(
50
+ 'GET',
51
+ 'https://timeout.in?ms=2000',
52
+ undefined,
53
+ undefined,
54
+ undefined,
55
+ {
56
+ signal,
57
+ }
58
+ )
59
+ ).rejects.toThrowError('The operation was aborted.');
60
+ ```
61
+
62
+ ### maxTries
63
+
64
+ To enable automatic retries on request methods, set `maxTries` to a number > 1.
65
+
66
+ If `maxTries` is > 1 and the HTTP response is a `202`, `429`, or `503`, an [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff)
67
+ will be used until a success response is received or `maxTries` is exceeded.
68
+
69
+ The waiting period before the retry will use the number of seconds provided in a [`Retry-After header`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) if found.
70
+
71
+ **NOTE**: Automatic retry on `202` varies from the suggestion made in Microsoft's [long-running operations](https://github.com/microsoft/api-guidelines/blob/vNext/graph/patterns/long-running-operations.md)
72
+ design pattern, where `202` is not considered a retryable response.
73
+
74
+ ### waitHandler
75
+
76
+ The `waitHandler` property is a [`Waitable`](src/transport.ts) callback that can be used to provide custom messaging and handling of the waiting period between automatic retries. This currently has
77
+ an alpha status, meaning it is subject to change or removal without notice.
78
+
79
+ ```ts
80
+ /** Alpha: Properties for an async Waitable retry handler */
81
+ export interface IWait {
82
+ /** HTTP request that responded with a retry code */
83
+ request: IRawRequest;
84
+ /** HTTP response that is a retry */
85
+ response: IRawResponse;
86
+ /** Attempt number for the retry */
87
+ attempt: number;
88
+ /** Time in milliseconds to wait before retrying */
89
+ waitMS: number;
90
+ }
91
+
92
+ /** Alpha: Response from a Waitable function */
93
+ export interface IWaitResponse {
94
+ /** cancel, retry, or error are the allowed responses for the retryable waiter */
95
+ response: 'cancel' | 'retry' | 'error';
96
+ /** Optional reason for the response */
97
+ reason?: string;
98
+ }
99
+
100
+ /** Alpha: Waitable function override for retrying an HTTP request */
101
+ export type Waitable = (waiting: IWait) => Promise<IWaitResponse>;
102
+ ```
103
+
104
+ ### verify_ssl
105
+
106
+ Setting `verify_ssl` to `false` will disable SSL certificate verification. **THIS IS NOT RECOMMENDED** and should only be used in development scenarios where self-signed certificates are used locally.
107
+ The default value for`verify_ssl` is `true`.
@@ -9,8 +9,8 @@ var _authSession = require("./authSession");
9
9
  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); } }
10
10
  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); }); }; }
11
11
  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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
13
+ 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); }
14
14
  class CSRFSession extends _authSession.AuthSession {
15
15
  constructor(settings, transport) {
16
16
  super(settings, transport || new _browserTransport.BrowserTransport(settings));
@@ -1 +1 @@
1
- {"version":3,"file":"CSRFSession.js","names":["_browserTransport","require","_authSession","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","CSRFSession","AuthSession","constructor","settings","transport","BrowserTransport","activeToken","_activeToken","meta","document","head","querySelector","content","getToken","_this","isAuthenticated","token","authenticate","props","_this2","headers","exports"],"sources":["../src/CSRFSession.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 { IApiSettings } from './apiSettings'\nimport type { IRequestProps, ITransport } from './transport'\nimport { BrowserTransport } from './browserTransport'\nimport { AuthSession } from './authSession'\n\n/**\n * CSRFSession is only for use within the Looker UI or a script that\n * executes in the Looker UI. Not for use by third party web apps. Looker UI web\n * service endpoints require that requests must contain a CSRF token to block third\n * party request forgeries. The actual login state is conveyed via encrypted browser\n * cookies exclusive to the looker domain, which the browser implicitly includes on\n * all web requests to looker UI web service.\n */\nexport class CSRFSession extends AuthSession {\n _activeToken = ''\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new BrowserTransport(settings))\n }\n\n get activeToken() {\n if (!this._activeToken) {\n const meta = document.head.querySelector(\n '[name=csrf-token]'\n ) as HTMLMetaElement\n this._activeToken = meta ? meta.content : ''\n }\n return this._activeToken\n }\n\n async getToken() {\n return this.activeToken\n }\n\n /**\n * Returns true if the same origin browser session has a CRSF token established\n * that can be used for API authentication\n */\n isAuthenticated() {\n const token = this.activeToken\n if (!token) return false\n return true\n }\n\n /**\n * Authenticates a request with the CSRF token if it is active\n *\n * @param props Request properties to decorate\n */\n async authenticate(props: IRequestProps) {\n const token = this.activeToken\n if (token) props.headers['X-CSRF-TOKEN'] = token\n return props\n }\n}\n"],"mappings":";;;;;;AA4BA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA2C,SAAAE,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;AAAA,SAAAC,gBAAAC,GAAA,EAAAjB,G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;EAC1B;EAEMM,QAAQA,CAAA,EAAG;IAAA,IAAAC,KAAA;IAAA,OAAAzC,iBAAA;MACf,OAAOyC,KAAI,CAACR,WAAW;IAAA;EACzB;EAMAS,eAAeA,CAAA,EAAG;IAChB,IAAMC,KAAK,GAAG,IAAI,CAACV,WAAW;IAC9B,IAAI,CAACU,KAAK,EAAE,OAAO,KAAK;IACxB,OAAO,IAAI;EACb;EAOMC,YAAYA,CAACC,KAAoB,EAAE;IAAA,IAAAC,MAAA;IAAA,OAAA9C,iBAAA;MACvC,IAAM2C,KAAK,GAAGG,MAAI,CAACb,WAAW;MAC9B,IAAIU,KAAK,EAAEE,KAAK,CAACE,OAAO,CAAC,cAAc,CAAC,GAAGJ,KAAK;MAChD,OAAOE,KAAK;IAAA;EACd;AACF;AAACG,OAAA,CAAArB,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"file":"CSRFSession.js","names":["_browserTransport","require","_authSession","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","CSRFSession","AuthSession","constructor","settings","transport","BrowserTransport","activeToken","_activeToken","meta","document","head","querySelector","content","getToken","_this","isAuthenticated","token","authenticate","props","_this2","headers","exports"],"sources":["../src/CSRFSession.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 { IApiSettings } from './apiSettings';\nimport type { IRequestProps, ITransport } from './transport';\nimport { BrowserTransport } from './browserTransport';\nimport { AuthSession } from './authSession';\n\n/**\n * CSRFSession is only for use within the Looker UI or a script that\n * executes in the Looker UI. Not for use by third party web apps. Looker UI web\n * service endpoints require that requests must contain a CSRF token to block third\n * party request forgeries. The actual login state is conveyed via encrypted browser\n * cookies exclusive to the looker domain, which the browser implicitly includes on\n * all web requests to looker UI web service.\n */\nexport class CSRFSession extends AuthSession {\n _activeToken = '';\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new BrowserTransport(settings));\n }\n\n get activeToken() {\n if (!this._activeToken) {\n const meta = document.head.querySelector(\n '[name=csrf-token]'\n ) as HTMLMetaElement;\n this._activeToken = meta ? meta.content : '';\n }\n return this._activeToken;\n }\n\n async getToken() {\n return this.activeToken;\n }\n\n /**\n * Returns true if the same origin browser session has a CRSF token established\n * that can be used for API authentication\n */\n isAuthenticated() {\n const token = this.activeToken;\n if (!token) return false;\n return true;\n }\n\n /**\n * Authenticates a request with the CSRF token if it is active\n *\n * @param props Request properties to decorate\n */\n async authenticate(props: IRequestProps) {\n const token = this.activeToken;\n if (token) props.headers['X-CSRF-TOKEN'] = token;\n return props;\n }\n}\n"],"mappings":";;;;;;AA4BA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA4C,SAAAE,mBAAAC,G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,CAAC,GAAGJ,KAAK;MAChD,OAAOE,KAAK;IAAC;EACf;AACF;AAACG,OAAA,CAAArB,WAAA,GAAAA,WAAA"}
@@ -1,23 +1,6 @@
1
- import type { Readable } from 'readable-stream';
2
- import type { Authenticator, HttpMethod, ITransportSettings, SDKResponse, Values } from './transport';
1
+ import type { Authenticator, HttpMethod, IAPIMethods, ITransportSettings, SDKResponse, Values } from './transport';
3
2
  import type { IAuthSession } from './authSession';
4
3
  export declare const functionalSdk: (authSession: IAuthSession, apiVersion: string, sdkVersion: string) => APIMethods;
5
- export interface IAPIMethods {
6
- authSession: IAuthSession;
7
- sdkVersion: string;
8
- apiPath: string;
9
- apiVersion: string;
10
- ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>): Promise<TSuccess>;
11
- makePath(path: string, options: Partial<ITransportSettings>, authenticator?: Authenticator): string;
12
- authRequest<TSuccess, TError>(method: HttpMethod, path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
13
- authStream<T>(callback: (readable: Readable) => Promise<T>, method: HttpMethod, path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<T>;
14
- get<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
15
- head<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
16
- delete<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
17
- post<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
18
- put<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
19
- patch<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
20
- }
21
4
  export declare class APIMethods implements IAPIMethods {
22
5
  authSession: IAuthSession;
23
6
  sdkVersion: string;
@@ -32,7 +15,7 @@ export declare class APIMethods implements IAPIMethods {
32
15
  ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>): Promise<TSuccess>;
33
16
  makePath(path: string, options: Partial<ITransportSettings>, authenticator?: Authenticator): string;
34
17
  authRequest<TSuccess, TError>(method: HttpMethod, path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
35
- authStream<T>(callback: (readable: Readable) => Promise<T>, method: HttpMethod, path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<T>;
18
+ authStream<T>(callback: (response: Response) => Promise<T>, method: HttpMethod, path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<T>;
36
19
  get<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
37
20
  head<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
38
21
  delete<TSuccess, TError>(path: string, queryParams?: Values, body?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
package/lib/apiMethods.js CHANGED
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.functionalSdk = exports.APIMethods = void 0;
7
7
  var _transport = require("./transport");
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
  var functionalSdk = (authSession, apiVersion, sdkVersion) => {
16
16
  var sdk = new APIMethods(authSession, sdkVersion);
17
17
  sdk.apiVersion = apiVersion;
@@ -1 +1 @@
1
- {"version":3,"file":"apiMethods.js","names":["_transport","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","obj","_toPropertyKey","configurable","writable","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","res","call","TypeError","Number","functionalSdk","authSession","apiVersion","sdkVersion","sdk","APIMethods","apiPath","settings","base_url","exports","constructor","agentTag","concat","agentPrefix","_apiPath","Error","_apiVersion","create","type","ok","promise","sdkOk","makePath","path","options","authenticator","match","base","authRequest","method","queryParams","body","_this","init","authenticate","transport","request","authStream","callback","_this2","stream","get","_this3","head","_this4","delete","_this5","post","_this6","put","_this7","patch","_this8"],"sources":["../src/apiMethods.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 { Readable } from 'readable-stream'\nimport type {\n Authenticator,\n HttpMethod,\n ITransportSettings,\n SDKResponse,\n Values,\n} from './transport'\nimport { agentPrefix, sdkOk } from './transport'\nimport type { IAuthSession } from './authSession'\n\n/**\n * Creates an \"sdk\" to be used with the TypeScript SDK's funcs.ts file\n * @param authSession authentication session\n * @param apiVersion version of API to use (e.g. \"3.1\" or \"4.0\")\n * @param sdkVersion Looker release version (e.g. \"21.4\")\n */\nexport const functionalSdk = (\n authSession: IAuthSession,\n apiVersion: string,\n sdkVersion: string\n) => {\n const sdk = new APIMethods(authSession, sdkVersion)\n sdk.apiVersion = apiVersion\n sdk.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + apiVersion\n return sdk\n}\n\nexport interface IAPIMethods {\n authSession: IAuthSession\n sdkVersion: string\n apiPath: string\n apiVersion: string\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n ok<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n ): Promise<TSuccess>\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ): string\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n\n /** Make a GET request */\n get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a HEAD request */\n head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a DELETE request */\n delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a POST request */\n post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PUT request */\n put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PATCH request */\n patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n}\n\nexport class APIMethods implements IAPIMethods {\n private _apiPath = ''\n private _apiVersion = ''\n\n /**\n * Initialize the APIMethods wrapper\n * @param authSession authentication management session\n * @param sdkVersion version of the SDK for agent tagging\n */\n constructor(public authSession: IAuthSession, public sdkVersion: string) {\n if (\n !('agentTag' in authSession.settings && authSession.settings.agentTag)\n ) {\n // Initialize agentTag if it's not already explicitly set\n authSession.settings.agentTag = `${agentPrefix} ${sdkVersion}`\n }\n }\n\n get apiPath() {\n return this._apiPath\n }\n\n set apiPath(value: string) {\n if (this._apiPath) {\n throw new Error(\n `API Path is set to \"${this._apiPath}\" and cannot be reassigned`\n )\n }\n this._apiPath = value\n }\n\n get apiVersion() {\n return this._apiVersion\n }\n\n set apiVersion(value: string) {\n // API version can only be set once for the instance\n if (this._apiVersion) {\n throw new Error(\n `API Version is set to \"${this._apiVersion}\" and cannot be reassigned`\n )\n }\n this._apiVersion = value\n }\n\n /** A helper method for constructing with a type as a param\n *\n * Example:\n * APIMethods.create(Looker40SDK, authSession)\n *\n * @param type\n * @param authSession\n */\n static create<T extends APIMethods>(\n type: new (authSession: IAuthSession) => T,\n authSession: IAuthSession\n ): T {\n // eslint-disable-next-line new-cap\n return new type(authSession)\n }\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n async ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>) {\n return sdkOk<TSuccess, TError>(promise)\n }\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ) {\n if (path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) return path\n // is this an API-versioned call?\n const base = authenticator ? this.apiPath : options.base_url\n return `${base}${path}` // path was relative\n }\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n async authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.request<TSuccess, TError>(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n )\n }\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n async authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.stream<T>(\n callback,\n method,\n path,\n queryParams,\n body,\n (init: any) => {\n return this.authSession.authenticate(init)\n },\n options\n )\n }\n\n // // dynamically evaluate a template string\n // macro(template: string, vars: any) {\n // // replace {foo} from spec path with ${foo} for template string\n // template = template.replace(/{/gi, '${')\n // return new Function('return `+ template +`;').call(vars)\n // }\n //\n // pathify(path: string, pathParams?: any) {\n // if (!pathParams) return path\n // if (path.indexOf('{') < 0) return path\n // return this.macro(path, pathParams)\n // }\n\n /** Make a GET request */\n async get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'GET',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a HEAD request */\n async head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'HEAD',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a DELETE request */\n async delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'DELETE',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a POST request */\n async post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'POST',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PUT request */\n async put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PUT',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PATCH request */\n async patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PATCH',\n path,\n queryParams,\n body,\n options\n )\n }\n}\n"],"mappings":";;;;;;AAkCA,IAAAA,UAAA,GAAAC,OAAA;AAAgD,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,IAAAC,eAAA,CAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAoB,cAAA,CAA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ACH;AACF;AAACf,OAAA,CAAAJ,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"file":"apiMethods.js","names":["_transport","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","obj","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","functionalSdk","authSession","apiVersion","sdkVersion","sdk","APIMethods","apiPath","settings","base_url","exports","constructor","agentTag","concat","agentPrefix","_apiPath","Error","_apiVersion","create","type","ok","promise","sdkOk","makePath","path","options","authenticator","match","base","authRequest","method","queryParams","body","_this","init","authenticate","transport","request","authStream","callback","_this2","stream","get","_this3","head","_this4","delete","_this5","post","_this6","put","_this7","patch","_this8"],"sources":["../src/apiMethods.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 {\n Authenticator,\n HttpMethod,\n IAPIMethods,\n ITransportSettings,\n SDKResponse,\n Values,\n} from './transport';\nimport { agentPrefix, sdkOk } from './transport';\nimport type { IAuthSession } from './authSession';\n\n/**\n * Creates an \"sdk\" to be used with the TypeScript SDK's funcs.ts file\n * @param authSession authentication session\n * @param apiVersion version of API to use (e.g. \"4.0\")\n * @param sdkVersion Looker release version (e.g. \"21.4\")\n */\nexport const functionalSdk = (\n authSession: IAuthSession,\n apiVersion: string,\n sdkVersion: string\n) => {\n const sdk = new APIMethods(authSession, sdkVersion);\n sdk.apiVersion = apiVersion;\n sdk.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + apiVersion;\n return sdk;\n};\n\nexport class APIMethods implements IAPIMethods {\n private _apiPath = '';\n private _apiVersion = '';\n\n /**\n * Initialize the APIMethods wrapper\n * @param authSession authentication management session\n * @param sdkVersion version of the SDK for agent tagging\n */\n constructor(public authSession: IAuthSession, public sdkVersion: string) {\n if (\n !('agentTag' in authSession.settings && authSession.settings.agentTag)\n ) {\n // Initialize agentTag if it's not already explicitly set\n authSession.settings.agentTag = `${agentPrefix} ${sdkVersion}`;\n }\n }\n\n get apiPath() {\n return this._apiPath;\n }\n\n set apiPath(value: string) {\n if (this._apiPath) {\n throw new Error(\n `API Path is set to \"${this._apiPath}\" and cannot be reassigned`\n );\n }\n this._apiPath = value;\n }\n\n get apiVersion() {\n return this._apiVersion;\n }\n\n set apiVersion(value: string) {\n // API version can only be set once for the instance\n if (this._apiVersion) {\n throw new Error(\n `API Version is set to \"${this._apiVersion}\" and cannot be reassigned`\n );\n }\n this._apiVersion = value;\n }\n\n /** A helper method for constructing with a type as a param\n *\n * Example:\n * APIMethods.create(Looker40SDK, authSession)\n *\n * @param type\n * @param authSession\n */\n static create<T extends APIMethods>(\n type: new (authSession: IAuthSession) => T,\n authSession: IAuthSession\n ): T {\n // eslint-disable-next-line new-cap\n return new type(authSession);\n }\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n async ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>) {\n return sdkOk<TSuccess, TError>(promise);\n }\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ) {\n if (path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) return path;\n // is this an API-versioned call?\n const base = authenticator ? this.apiPath : options.base_url;\n return `${base}${path}`; // path was relative\n }\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n async authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n options = { ...this.authSession.settings, ...options };\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init);\n };\n path = this.makePath(path, options, authenticator);\n return this.authSession.transport.request<TSuccess, TError>(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n }\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param callback for streaming\n * @param method of HTTP request\n * @param path HTTP path\n * @param queryParams\n * @param body\n * @param options to override\n */\n async authStream<T>(\n callback: (response: Response) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T> {\n options = { ...this.authSession.settings, ...options };\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init);\n };\n path = this.makePath(path, options, authenticator);\n return this.authSession.transport.stream<T>(\n callback,\n method,\n path,\n queryParams,\n body,\n (init: any) => {\n return this.authSession.authenticate(init);\n },\n options\n );\n }\n\n // // dynamically evaluate a template string\n // macro(template: string, vars: any) {\n // // replace {foo} from spec path with ${foo} for template string\n // template = template.replace(/{/gi, '${')\n // return new Function('return `+ template +`;').call(vars)\n // }\n //\n // pathify(path: string, pathParams?: any) {\n // if (!pathParams) return path\n // if (path.indexOf('{') < 0) return path\n // return this.macro(path, pathParams)\n // }\n\n /** Make a GET request */\n async get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'GET',\n path,\n queryParams,\n body,\n options\n );\n }\n\n /** Make a HEAD request */\n async head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'HEAD',\n path,\n queryParams,\n body,\n options\n );\n }\n\n /** Make a DELETE request */\n async delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'DELETE',\n path,\n queryParams,\n body,\n options\n );\n }\n\n /** Make a POST request */\n async post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'POST',\n path,\n queryParams,\n body,\n options\n );\n }\n\n /** Make a PUT request */\n async put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PUT',\n path,\n queryParams,\n body,\n options\n );\n }\n\n /** Make a PATCH request */\n async patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PATCH',\n path,\n queryParams,\n body,\n options\n );\n }\n}\n"],"mappings":";;;;;;AAkCA,IAAAA,UAAA,GAAAC,OAAA;AAAiD,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAA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AU,EACVP,OAAqC,EACG;IAAA,IAAA4B,MAAA;IAAA,OAAAtE,iBAAA;MACxC,OAAOsE,MAAI,CAACxB,WAAW,CACrB,OAAO,EACPL,IAAI,EACJO,WAAW,EACXC,IAAI,EACJP,OACF,CAAC;IAAC;EACJ;AACF;AAACf,OAAA,CAAAJ,UAAA,GAAAA,UAAA"}
@@ -3,7 +3,7 @@ export interface IValueSettings {
3
3
  [name: string]: string;
4
4
  }
5
5
  export declare const ApiConfigMap: (envPrefix: string) => IValueSettings;
6
- export declare const strBadConfiguration: string;
6
+ export declare const strBadConfiguration = "TS-SDK configuration error:\nMissing required configuration values like base_url\n";
7
7
  export interface IApiSection {
8
8
  [key: string]: string;
9
9
  }