dotcms 0.0.17 → 0.0.19

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 (166) hide show
  1. package/README.md +72 -10
  2. package/dotcms.d.ts.map +1 -0
  3. package/esm2020/dotcms.mjs +5 -0
  4. package/esm2020/index.mjs +36 -0
  5. package/esm2020/lib/api/DotApiAuthorization.mjs +42 -0
  6. package/esm2020/lib/api/DotApiConfiguration.mjs +27 -0
  7. package/esm2020/lib/api/DotApiContent.mjs +52 -0
  8. package/esm2020/lib/api/DotApiContentType.mjs +28 -0
  9. package/esm2020/lib/api/DotApiElasticSearch.mjs +32 -0
  10. package/esm2020/lib/api/DotApiEvent.mjs +16 -0
  11. package/esm2020/lib/api/DotApiForm.mjs +18 -0
  12. package/esm2020/lib/api/DotApiLanguage.mjs +24 -0
  13. package/esm2020/lib/api/DotApiNavigation.mjs +29 -0
  14. package/esm2020/lib/api/DotApiPage.mjs +50 -0
  15. package/esm2020/lib/api/DotApiSite.mjs +26 -0
  16. package/esm2020/lib/api/DotApiWidget.mjs +28 -0
  17. package/esm2020/lib/models/DotCMSAuthorization.model.mjs +2 -0
  18. package/esm2020/lib/models/DotCMSConfiguration.model.mjs +2 -0
  19. package/esm2020/lib/models/DotCMSContent.model.mjs +2 -0
  20. package/esm2020/lib/models/DotCMSElasticSearch.model.mjs +2 -0
  21. package/esm2020/lib/models/DotCMSError.model.mjs +2 -0
  22. package/esm2020/lib/models/DotCMSEvent.model.mjs +2 -0
  23. package/esm2020/lib/models/DotCMSForm.model.mjs +2 -0
  24. package/esm2020/lib/models/DotCMSHttpClient.model.mjs +2 -0
  25. package/esm2020/lib/models/DotCMSLanguage.model.mjs +2 -0
  26. package/esm2020/lib/models/DotCMSNavigation.model.mjs +2 -0
  27. package/esm2020/lib/models/DotCMSPage.model.mjs +2 -0
  28. package/esm2020/lib/models/DotCMSPageFormat.model.mjs +2 -0
  29. package/esm2020/lib/models/DotCMSSite.model.mjs +2 -0
  30. package/esm2020/lib/models/index.mjs +14 -0
  31. package/esm2020/lib/utils/DotCMSHttpClient.mjs +10 -0
  32. package/esm2020/lib/utils/getEsQuery.mjs +35 -0
  33. package/esm2020/lib/utils/request.mjs +42 -0
  34. package/{public_api.d.ts → index.d.ts} +1 -0
  35. package/index.d.ts.map +1 -0
  36. package/lib/api/DotApiAuthorization.d.ts +1 -0
  37. package/lib/api/DotApiAuthorization.d.ts.map +1 -0
  38. package/lib/api/DotApiConfiguration.d.ts +1 -0
  39. package/lib/api/DotApiConfiguration.d.ts.map +1 -0
  40. package/lib/api/DotApiContent.d.ts +1 -0
  41. package/lib/api/DotApiContent.d.ts.map +1 -0
  42. package/lib/api/DotApiContentType.d.ts +2 -1
  43. package/lib/api/DotApiContentType.d.ts.map +1 -0
  44. package/lib/api/DotApiElasticSearch.d.ts +1 -0
  45. package/lib/api/DotApiElasticSearch.d.ts.map +1 -0
  46. package/lib/api/DotApiEvent.d.ts +1 -0
  47. package/lib/api/DotApiEvent.d.ts.map +1 -0
  48. package/lib/api/DotApiForm.d.ts +2 -1
  49. package/lib/api/DotApiForm.d.ts.map +1 -0
  50. package/lib/api/DotApiLanguage.d.ts +4 -3
  51. package/lib/api/DotApiLanguage.d.ts.map +1 -0
  52. package/lib/api/DotApiNavigation.d.ts +2 -1
  53. package/lib/api/DotApiNavigation.d.ts.map +1 -0
  54. package/lib/api/DotApiPage.d.ts +1 -0
  55. package/lib/api/DotApiPage.d.ts.map +1 -0
  56. package/lib/api/DotApiSite.d.ts +1 -0
  57. package/lib/api/DotApiSite.d.ts.map +1 -0
  58. package/lib/api/DotApiWidget.d.ts +1 -0
  59. package/lib/api/DotApiWidget.d.ts.map +1 -0
  60. package/lib/models/DotCMSAuthorization.model.d.ts +1 -0
  61. package/lib/models/DotCMSAuthorization.model.d.ts.map +1 -0
  62. package/lib/models/DotCMSConfiguration.model.d.ts +1 -0
  63. package/lib/models/DotCMSConfiguration.model.d.ts.map +1 -0
  64. package/lib/models/DotCMSContent.model.d.ts +1 -0
  65. package/lib/models/DotCMSContent.model.d.ts.map +1 -0
  66. package/lib/models/DotCMSElasticSearch.model.d.ts +1 -0
  67. package/lib/models/DotCMSElasticSearch.model.d.ts.map +1 -0
  68. package/lib/models/DotCMSError.model.d.ts +1 -0
  69. package/lib/models/DotCMSError.model.d.ts.map +1 -0
  70. package/lib/models/DotCMSEvent.model.d.ts +1 -0
  71. package/lib/models/DotCMSEvent.model.d.ts.map +1 -0
  72. package/lib/models/DotCMSForm.model.d.ts +1 -0
  73. package/lib/models/DotCMSForm.model.d.ts.map +1 -0
  74. package/lib/models/DotCMSHttpClient.model.d.ts +4 -1
  75. package/lib/models/DotCMSHttpClient.model.d.ts.map +1 -0
  76. package/lib/models/DotCMSLanguage.model.d.ts +1 -0
  77. package/lib/models/DotCMSLanguage.model.d.ts.map +1 -0
  78. package/lib/models/DotCMSNavigation.model.d.ts +1 -0
  79. package/lib/models/DotCMSNavigation.model.d.ts.map +1 -0
  80. package/lib/models/DotCMSPage.model.d.ts +1 -0
  81. package/lib/models/DotCMSPage.model.d.ts.map +1 -0
  82. package/lib/models/DotCMSPageFormat.model.d.ts +1 -0
  83. package/lib/models/DotCMSPageFormat.model.d.ts.map +1 -0
  84. package/lib/models/DotCMSSite.model.d.ts +1 -0
  85. package/lib/models/DotCMSSite.model.d.ts.map +1 -0
  86. package/lib/models/index.d.ts +1 -0
  87. package/lib/models/index.d.ts.map +1 -0
  88. package/lib/utils/DotCMSHttpClient.d.ts +1 -0
  89. package/lib/utils/DotCMSHttpClient.d.ts.map +1 -0
  90. package/lib/utils/getEsQuery.d.ts +1 -0
  91. package/lib/utils/getEsQuery.d.ts.map +1 -0
  92. package/lib/utils/request.d.ts +2 -1
  93. package/lib/utils/request.d.ts.map +1 -0
  94. package/package.json +22 -14
  95. package/bundles/dotcms.umd.js +0 -1152
  96. package/bundles/dotcms.umd.js.map +0 -1
  97. package/bundles/dotcms.umd.min.js +0 -2
  98. package/bundles/dotcms.umd.min.js.map +0 -1
  99. package/dotcms.d.ts +0 -4
  100. package/dotcms.metadata.json +0 -1
  101. package/esm2015/dotcms.js +0 -10
  102. package/esm2015/lib/api/DotApiAuthorization.js +0 -55
  103. package/esm2015/lib/api/DotApiConfiguration.js +0 -43
  104. package/esm2015/lib/api/DotApiContent.js +0 -96
  105. package/esm2015/lib/api/DotApiContentType.js +0 -53
  106. package/esm2015/lib/api/DotApiElasticSearch.js +0 -47
  107. package/esm2015/lib/api/DotApiEvent.js +0 -26
  108. package/esm2015/lib/api/DotApiForm.js +0 -37
  109. package/esm2015/lib/api/DotApiLanguage.js +0 -52
  110. package/esm2015/lib/api/DotApiNavigation.js +0 -45
  111. package/esm2015/lib/api/DotApiPage.js +0 -68
  112. package/esm2015/lib/api/DotApiSite.js +0 -43
  113. package/esm2015/lib/api/DotApiWidget.js +0 -43
  114. package/esm2015/lib/models/DotCMSAuthorization.model.js +0 -18
  115. package/esm2015/lib/models/DotCMSConfiguration.model.js +0 -34
  116. package/esm2015/lib/models/DotCMSContent.model.js +0 -22
  117. package/esm2015/lib/models/DotCMSElasticSearch.model.js +0 -80
  118. package/esm2015/lib/models/DotCMSError.model.js +0 -14
  119. package/esm2015/lib/models/DotCMSEvent.model.js +0 -14
  120. package/esm2015/lib/models/DotCMSForm.model.js +0 -28
  121. package/esm2015/lib/models/DotCMSHttpClient.model.js +0 -18
  122. package/esm2015/lib/models/DotCMSLanguage.model.js +0 -20
  123. package/esm2015/lib/models/DotCMSNavigation.model.js +0 -32
  124. package/esm2015/lib/models/DotCMSPage.model.js +0 -468
  125. package/esm2015/lib/models/DotCMSPageFormat.model.js +0 -12
  126. package/esm2015/lib/models/DotCMSSite.model.js +0 -312
  127. package/esm2015/lib/models/index.js +0 -6
  128. package/esm2015/lib/utils/DotCMSHttpClient.js +0 -26
  129. package/esm2015/lib/utils/getEsQuery.js +0 -47
  130. package/esm2015/lib/utils/request.js +0 -79
  131. package/esm2015/public_api.js +0 -77
  132. package/esm5/dotcms.js +0 -10
  133. package/esm5/lib/api/DotApiAuthorization.js +0 -82
  134. package/esm5/lib/api/DotApiConfiguration.js +0 -63
  135. package/esm5/lib/api/DotApiContent.js +0 -152
  136. package/esm5/lib/api/DotApiContentType.js +0 -75
  137. package/esm5/lib/api/DotApiElasticSearch.js +0 -72
  138. package/esm5/lib/api/DotApiEvent.js +0 -42
  139. package/esm5/lib/api/DotApiForm.js +0 -54
  140. package/esm5/lib/api/DotApiLanguage.js +0 -80
  141. package/esm5/lib/api/DotApiNavigation.js +0 -68
  142. package/esm5/lib/api/DotApiPage.js +0 -108
  143. package/esm5/lib/api/DotApiSite.js +0 -60
  144. package/esm5/lib/api/DotApiWidget.js +0 -66
  145. package/esm5/lib/models/DotCMSAuthorization.model.js +0 -18
  146. package/esm5/lib/models/DotCMSConfiguration.model.js +0 -34
  147. package/esm5/lib/models/DotCMSContent.model.js +0 -22
  148. package/esm5/lib/models/DotCMSElasticSearch.model.js +0 -80
  149. package/esm5/lib/models/DotCMSError.model.js +0 -14
  150. package/esm5/lib/models/DotCMSEvent.model.js +0 -14
  151. package/esm5/lib/models/DotCMSForm.model.js +0 -28
  152. package/esm5/lib/models/DotCMSHttpClient.model.js +0 -18
  153. package/esm5/lib/models/DotCMSLanguage.model.js +0 -20
  154. package/esm5/lib/models/DotCMSNavigation.model.js +0 -32
  155. package/esm5/lib/models/DotCMSPage.model.js +0 -468
  156. package/esm5/lib/models/DotCMSPageFormat.model.js +0 -12
  157. package/esm5/lib/models/DotCMSSite.model.js +0 -312
  158. package/esm5/lib/models/index.js +0 -6
  159. package/esm5/lib/utils/DotCMSHttpClient.js +0 -29
  160. package/esm5/lib/utils/getEsQuery.js +0 -31
  161. package/esm5/lib/utils/request.js +0 -86
  162. package/esm5/public_api.js +0 -77
  163. package/fesm2015/dotcms.js +0 -723
  164. package/fesm2015/dotcms.js.map +0 -1
  165. package/fesm5/dotcms.js +0 -972
  166. package/fesm5/dotcms.js.map +0 -1
package/fesm5/dotcms.js DELETED
@@ -1,972 +0,0 @@
1
- import fetch from 'node-fetch';
2
- import { __awaiter, __generator, __rest, __assign, __values } from 'tslib';
3
-
4
- /**
5
- * @fileoverview added by tsickle
6
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
7
- */
8
- /**
9
- * @param {?} data
10
- * @return {?}
11
- */
12
- function getErrorMessage(data) {
13
- if (data["errors"]) {
14
- return data["errors"][0].message;
15
- }
16
- if (data["error"]) {
17
- return data["error"];
18
- }
19
- }
20
- /**
21
- * DotCMS Authentication handler to intereact with {\@link https://dotcms.com/docs/latest/rest-api-authentication | Authentication API}
22
- *
23
- */
24
- var /**
25
- * DotCMS Authentication handler to intereact with {\@link https://dotcms.com/docs/latest/rest-api-authentication | Authentication API}
26
- *
27
- */
28
- DotApiAuthorization = /** @class */ (function () {
29
- function DotApiAuthorization() {
30
- }
31
- /**
32
- * Given user, password and expiration date to get a DotCMS Autorization Token
33
- */
34
- /**
35
- * Given user, password and expiration date to get a DotCMS Autorization Token
36
- * @param {?} params
37
- * @return {?}
38
- */
39
- DotApiAuthorization.prototype.getToken = /**
40
- * Given user, password and expiration date to get a DotCMS Autorization Token
41
- * @param {?} params
42
- * @return {?}
43
- */
44
- function (params) {
45
- var _this = this;
46
- var user = params.user, password = params.password, expirationDays = params.expirationDays, host = params.host;
47
- return fetch((host || '') + "/api/v1/authentication/api-token", {
48
- method: 'POST',
49
- headers: {
50
- 'Content-Type': 'application/json'
51
- },
52
- body: JSON.stringify({
53
- user: user,
54
- password: password,
55
- expirationDays: expirationDays || 10
56
- })
57
- }).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
58
- var data;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0: return [4 /*yield*/, res.json()];
62
- case 1:
63
- data = _a.sent();
64
- if (res.status === 200) {
65
- return [2 /*return*/, data.entity.token];
66
- }
67
- throw /** @type {?} */ ({
68
- message: getErrorMessage(data),
69
- statusCode: res.status
70
- });
71
- }
72
- });
73
- }); });
74
- };
75
- return DotApiAuthorization;
76
- }());
77
-
78
- /**
79
- * @fileoverview added by tsickle
80
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
81
- */
82
- /**
83
- * Get the information of DotCMS configuration
84
- *
85
- */
86
- var /**
87
- * Get the information of DotCMS configuration
88
- *
89
- */
90
- DotApiConfiguration = /** @class */ (function () {
91
- function DotApiConfiguration(httpClient) {
92
- this.dotCMSHttpClient = httpClient;
93
- }
94
- // TODO: CATCH THIS ERROR
95
- /**
96
- * @return {?}
97
- */
98
- DotApiConfiguration.prototype.get = /**
99
- * @return {?}
100
- */
101
- function () {
102
- var _this = this;
103
- return this.dotCMSHttpClient
104
- .request({
105
- url: '/api/v1/configuration'
106
- })
107
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
108
- var data, _a;
109
- return __generator(this, function (_b) {
110
- switch (_b.label) {
111
- case 0:
112
- if (!(response.status === 200)) return [3 /*break*/, 2];
113
- return [4 /*yield*/, response.json()];
114
- case 1:
115
- data = _b.sent();
116
- return [2 /*return*/, data.entity];
117
- case 2:
118
- _a = {};
119
- return [4 /*yield*/, response.text()];
120
- case 3: throw /** @type {?} */ (_a.message = _b.sent(),
121
- _a.statusCode = response.status,
122
- _a);
123
- }
124
- });
125
- }); });
126
- };
127
- return DotApiConfiguration;
128
- }());
129
-
130
- /**
131
- * @fileoverview added by tsickle
132
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
133
- */
134
- /**
135
- * @param {?} params
136
- * @return {?}
137
- */
138
- function getEsQuery(params) {
139
- var contentType = params.contentType, _a = params.queryParams, languageId = _a.languageId, sortResultsBy = _a.sortResultsBy, sortOrder1 = _a.sortOrder1, offset = _a.offset, pagination = _a.pagination, itemsPerPage = _a.itemsPerPage, numberOfResults = _a.numberOfResults, detailedSearchQuery = _a.detailedSearchQuery;
140
- /** @type {?} */
141
- var paginationQuery = ",\n \"from\": OFFSETVALUE,\n \"size\": SIZEPERPAGE";
142
- /** @type {?} */
143
- var query = "{\n \"query\": {\n \"bool\": {\n \"must\": {\n \"query_string\" : {\n \"query\" : \"+contentType:CONTENTTYPE +languageId:LANGUAGEIDVALUE " + (detailedSearchQuery ||
144
- '') + "\"\n }\n }\n }\n },\n \"sort\" : [\n { \"SORTBYVALUE\" : {\"order\" : \"SORTTYPEVALUE\"}}\n ]\n " + (pagination || numberOfResults ? paginationQuery : '') + "\n }";
145
- /** @type {?} */
146
- var esParams = {
147
- CONTENTTYPE: contentType,
148
- LANGUAGEIDVALUE: languageId || '1',
149
- SORTBYVALUE: sortResultsBy || 'title_dotraw',
150
- SORTTYPEVALUE: sortOrder1 || 'asc',
151
- OFFSETVALUE: offset || '0',
152
- SIZEPERPAGE: pagination ? itemsPerPage || 20 : numberOfResults || 40
153
- };
154
- Object.keys(esParams).forEach(function (key) {
155
- query = query.replace(key, esParams[key]);
156
- });
157
- return query;
158
- }
159
-
160
- /**
161
- * @fileoverview added by tsickle
162
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
163
- */
164
- /**
165
- * Request content from DotCMS using the {\@link https://dotcms.com/docs/latest/elasticsearch-rest-api | Elastic Search API}
166
- *
167
- */
168
- var /**
169
- * Request content from DotCMS using the {\@link https://dotcms.com/docs/latest/elasticsearch-rest-api | Elastic Search API}
170
- *
171
- */
172
- DotApiElasticSearch = /** @class */ (function () {
173
- function DotApiElasticSearch(httpClient) {
174
- this.dotCMSHttpClient = httpClient;
175
- }
176
- /**
177
- * Provide the content type and the elastic search query and get the results contentlets and elastic search information
178
- *
179
- */
180
- /**
181
- * Provide the content type and the elastic search query and get the results contentlets and elastic search information
182
- *
183
- * @param {?} params
184
- * @return {?}
185
- */
186
- DotApiElasticSearch.prototype.search = /**
187
- * Provide the content type and the elastic search query and get the results contentlets and elastic search information
188
- *
189
- * @param {?} params
190
- * @return {?}
191
- */
192
- function (params) {
193
- var _this = this;
194
- return this.dotCMSHttpClient
195
- .request({
196
- url: '/api/es/search',
197
- method: 'POST',
198
- body: getEsQuery(params)
199
- })
200
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
201
- var _a;
202
- return __generator(this, function (_b) {
203
- switch (_b.label) {
204
- case 0:
205
- if (response.status === 200) {
206
- return [2 /*return*/, response.json()];
207
- }
208
- _a = {};
209
- return [4 /*yield*/, response.text()];
210
- case 1: throw /** @type {?} */ (_a.message = _b.sent(),
211
- _a.statusCode = response.status,
212
- _a);
213
- }
214
- });
215
- }); });
216
- };
217
- return DotApiElasticSearch;
218
- }());
219
-
220
- /**
221
- * @fileoverview added by tsickle
222
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
223
- */
224
- /**
225
- * Emit custom events for the DotCMS Edit Mode
226
- *
227
- */
228
- var /**
229
- * Emit custom events for the DotCMS Edit Mode
230
- *
231
- */
232
- DotApiEvent = /** @class */ (function () {
233
- function DotApiEvent() {
234
- }
235
- /**
236
- * @param {?} params
237
- * @return {?}
238
- */
239
- DotApiEvent.prototype.emit = /**
240
- * @param {?} params
241
- * @return {?}
242
- */
243
- function (params) {
244
- var name = params.name, data = params.data;
245
- /** @type {?} */
246
- var customEvent = window.top.document.createEvent('CustomEvent');
247
- customEvent.initCustomEvent('ng-event', false, false, {
248
- name: name,
249
- data: data
250
- });
251
- window.top.document.dispatchEvent(customEvent);
252
- };
253
- return DotApiEvent;
254
- }());
255
-
256
- /**
257
- * @fileoverview added by tsickle
258
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
259
- */
260
- /**
261
- * Get DotCMS {\@link https://dotcms.com/docs/latest/adding-and-editing-languages | Language code}
262
- *
263
- */
264
- var /**
265
- * Get DotCMS {\@link https://dotcms.com/docs/latest/adding-and-editing-languages | Language code}
266
- *
267
- */
268
- DotApiLanguage = /** @class */ (function () {
269
- function DotApiLanguage(appConfig) {
270
- this.dotAppConfig = appConfig;
271
- }
272
- /**
273
- * @param {?} langCode
274
- * @return {?}
275
- */
276
- DotApiLanguage.prototype.getId = /**
277
- * @param {?} langCode
278
- * @return {?}
279
- */
280
- function (langCode) {
281
- return __awaiter(this, void 0, void 0, function () {
282
- var languages, language;
283
- return __generator(this, function (_a) {
284
- switch (_a.label) {
285
- case 0: return [4 /*yield*/, this.getLanguages()];
286
- case 1:
287
- languages = _a.sent();
288
- language = languages.find(function (lang) { return lang.languageCode === langCode; });
289
- return [2 /*return*/, language ? "" + language.id : null];
290
- }
291
- });
292
- });
293
- };
294
- /**
295
- * @return {?}
296
- */
297
- DotApiLanguage.prototype.getLanguages = /**
298
- * @return {?}
299
- */
300
- function () {
301
- return __awaiter(this, void 0, void 0, function () {
302
- var _a;
303
- return __generator(this, function (_b) {
304
- switch (_b.label) {
305
- case 0:
306
- if (this._languagesConf) {
307
- return [2 /*return*/, this._languagesConf];
308
- }
309
- _a = this;
310
- return [4 /*yield*/, this.dotAppConfig
311
- .get()
312
- .then(function (data) { return data.languages; })];
313
- case 1:
314
- _a._languagesConf = _b.sent();
315
- return [2 /*return*/, this._languagesConf];
316
- }
317
- });
318
- });
319
- };
320
- return DotApiLanguage;
321
- }());
322
-
323
- /**
324
- * @fileoverview added by tsickle
325
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
326
- */
327
- /**
328
- * Retrieve information about the dotCMS file and folder tree with the {\@link https://dotcms.com/docs/latest/navigation-rest-api | Navigation REST API }
329
- *
330
- */
331
- var /**
332
- * Retrieve information about the dotCMS file and folder tree with the {\@link https://dotcms.com/docs/latest/navigation-rest-api | Navigation REST API }
333
- *
334
- */
335
- DotApiNavigation = /** @class */ (function () {
336
- function DotApiNavigation(httpClient) {
337
- this.dotCMSHttpClient = httpClient;
338
- }
339
- /**
340
- * @param {?=} deep
341
- * @param {?=} location
342
- * @return {?}
343
- */
344
- DotApiNavigation.prototype.get = /**
345
- * @param {?=} deep
346
- * @param {?=} location
347
- * @return {?}
348
- */
349
- function (deep, location) {
350
- var _this = this;
351
- if (deep === void 0) { deep = '2'; }
352
- if (location === void 0) { location = '/'; }
353
- return this.dotCMSHttpClient
354
- .request({
355
- url: "/api/v1/nav/" + location + "?depth=" + deep
356
- })
357
- .then(function (res) { return __awaiter(_this, void 0, void 0, function () {
358
- var data, _a;
359
- return __generator(this, function (_b) {
360
- switch (_b.label) {
361
- case 0:
362
- if (!(res.status === 200)) return [3 /*break*/, 2];
363
- return [4 /*yield*/, res.json()];
364
- case 1:
365
- data = _b.sent();
366
- return [2 /*return*/, /** @type {?} */ (data.entity)];
367
- case 2:
368
- _a = {};
369
- return [4 /*yield*/, res.text()];
370
- case 3: throw /** @type {?} */ (_a.message = _b.sent(),
371
- _a.statusCode = res.status,
372
- _a);
373
- }
374
- });
375
- }); });
376
- };
377
- return DotApiNavigation;
378
- }());
379
-
380
- /**
381
- * @fileoverview added by tsickle
382
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
383
- */
384
- /**
385
- * Allow easy interaction with {\@link https://dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas | DotCMS Page API}
386
- *
387
- */
388
- var /**
389
- * Allow easy interaction with {\@link https://dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas | DotCMS Page API}
390
- *
391
- */
392
- DotApiPage = /** @class */ (function () {
393
- function DotApiPage(httpClient, appLanguage) {
394
- this.dotCMSHttpClient = httpClient;
395
- this.dotAppLanguage = appLanguage;
396
- }
397
- /**
398
- * Given the page url and the language return a {@link DotCMSPageAsset}
399
- *
400
- */
401
- /**
402
- * Given the page url and the language return a {\@link DotCMSPageAsset}
403
- *
404
- * @param {?} params
405
- * @param {?=} format
406
- * @return {?}
407
- */
408
- DotApiPage.prototype.get = /**
409
- * Given the page url and the language return a {\@link DotCMSPageAsset}
410
- *
411
- * @param {?} params
412
- * @param {?=} format
413
- * @return {?}
414
- */
415
- function (params, format) {
416
- if (format === void 0) { format = "json" /* JSON */; }
417
- return __awaiter(this, void 0, void 0, function () {
418
- var _a, _b, _c;
419
- var _this = this;
420
- return __generator(this, function (_d) {
421
- switch (_d.label) {
422
- case 0:
423
- if (!params.language) return [3 /*break*/, 4];
424
- _a = [{}, params];
425
- _b = {};
426
- if (!isNaN(/** @type {?} */ (params.language))) return [3 /*break*/, 2];
427
- return [4 /*yield*/, this.dotAppLanguage.getId(params.language)];
428
- case 1:
429
- _c = _d.sent();
430
- return [3 /*break*/, 3];
431
- case 2:
432
- _c = params.language;
433
- _d.label = 3;
434
- case 3:
435
- params = __assign.apply(void 0, _a.concat([(_b.language = _c, _b)]));
436
- _d.label = 4;
437
- case 4:
438
- params = __assign({}, params, { url: "/api/v1/page/" + format + params.url });
439
- return [2 /*return*/, this.dotCMSHttpClient.request(params).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
440
- var data, response, error;
441
- return __generator(this, function (_a) {
442
- switch (_a.label) {
443
- case 0:
444
- if (!(res.status === 200)) return [3 /*break*/, 2];
445
- return [4 /*yield*/, res.json()];
446
- case 1:
447
- data = _a.sent();
448
- return [2 /*return*/, /** @type {?} */ (data.entity)];
449
- case 2: return [4 /*yield*/, res.text()];
450
- case 3:
451
- response = _a.sent();
452
- try {
453
- error = {
454
- statusCode: res.status,
455
- message: JSON.parse(response).message
456
- };
457
- }
458
- catch (_b) {
459
- error = {
460
- statusCode: res.status,
461
- message: response
462
- };
463
- }
464
- throw error;
465
- }
466
- });
467
- }); })];
468
- }
469
- });
470
- });
471
- };
472
- return DotApiPage;
473
- }());
474
-
475
- /**
476
- * @fileoverview added by tsickle
477
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
478
- */
479
- /**
480
- * Get information from {\@link https://dotcms.com/docs/latest/multi-site-management | DotCMS Sites}
481
- */
482
- var /**
483
- * Get information from {\@link https://dotcms.com/docs/latest/multi-site-management | DotCMS Sites}
484
- */
485
- DotApiSite = /** @class */ (function () {
486
- function DotApiSite(httpClient) {
487
- this.dotCMSHttpClient = httpClient;
488
- }
489
- /**
490
- * @return {?}
491
- */
492
- DotApiSite.prototype.getCurrentSite = /**
493
- * @return {?}
494
- */
495
- function () {
496
- var _this = this;
497
- return this.dotCMSHttpClient
498
- .request({
499
- url: "/api/v1/site/currentSite"
500
- })
501
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
502
- var data, _a, map, site, _b;
503
- return __generator(this, function (_c) {
504
- switch (_c.label) {
505
- case 0:
506
- if (!(response.status === 200)) return [3 /*break*/, 2];
507
- return [4 /*yield*/, response.json()];
508
- case 1:
509
- data = _c.sent();
510
- _a = data.entity, map = _a.map, site = __rest(_a, ["map"]);
511
- return [2 /*return*/, /** @type {?} */ (site)];
512
- case 2:
513
- _b = {};
514
- return [4 /*yield*/, response.text()];
515
- case 3: throw /** @type {?} */ (_b.message = _c.sent(),
516
- _b.statusCode = response.status,
517
- _b);
518
- }
519
- });
520
- }); });
521
- };
522
- return DotApiSite;
523
- }());
524
-
525
- /**
526
- * @fileoverview added by tsickle
527
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
528
- */
529
- /**
530
- * DotCMS {\@link https://dotcms.com/docs/latest/widgets | widgets handler}
531
- */
532
- var /**
533
- * DotCMS {\@link https://dotcms.com/docs/latest/widgets | widgets handler}
534
- */
535
- DotApiWidget = /** @class */ (function () {
536
- function DotApiWidget(httpClient) {
537
- this.dotCMSHttpClient = httpClient;
538
- }
539
- /**
540
- * Get the widght HTML strong with it identifier
541
- *
542
- */
543
- /**
544
- * Get the widght HTML strong with it identifier
545
- *
546
- * @param {?} widgetId
547
- * @return {?}
548
- */
549
- DotApiWidget.prototype.getHtml = /**
550
- * Get the widght HTML strong with it identifier
551
- *
552
- * @param {?} widgetId
553
- * @return {?}
554
- */
555
- function (widgetId) {
556
- var _this = this;
557
- return this.dotCMSHttpClient
558
- .request({
559
- url: "/api/widget/id/" + widgetId
560
- })
561
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
562
- var _a;
563
- return __generator(this, function (_b) {
564
- switch (_b.label) {
565
- case 0:
566
- if (response.status === 200) {
567
- return [2 /*return*/, response.text()];
568
- }
569
- _a = {};
570
- return [4 /*yield*/, response.text()];
571
- case 1: throw /** @type {?} */ (_a.message = _b.sent(),
572
- _a.statusCode = response.status,
573
- _a);
574
- }
575
- });
576
- }); });
577
- };
578
- return DotApiWidget;
579
- }());
580
-
581
- /**
582
- * @fileoverview added by tsickle
583
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
584
- */
585
- /**
586
- * @param {?} language
587
- * @param {?} hostId
588
- * @return {?}
589
- */
590
- function getQueryParams(language, hostId) {
591
- /** @type {?} */
592
- var result = language || hostId ? '?' : '';
593
- if (language) {
594
- result += "language_id=" + language;
595
- if (hostId) {
596
- result += '&';
597
- }
598
- }
599
- if (hostId) {
600
- result += "host_id=" + hostId;
601
- }
602
- return result;
603
- }
604
- /**
605
- * @param {?} params
606
- * @param {?} config
607
- * @return {?}
608
- */
609
- function getUrl(params, config) {
610
- return __awaiter(this, void 0, void 0, function () {
611
- var host;
612
- return __generator(this, function (_a) {
613
- host = config.host || '';
614
- return [2 /*return*/, "" + host + params.url + getQueryParams(params.language, config.hostId)];
615
- });
616
- });
617
- }
618
- /**
619
- * @param {?} params
620
- * @return {?}
621
- */
622
- function shouldAppendBody(params) {
623
- return params.method === 'POST' && !!params.body;
624
- }
625
- /**
626
- * @param {?} params
627
- * @param {?} config
628
- * @return {?}
629
- */
630
- function getOpts(params, config) {
631
- /** @type {?} */
632
- var opts = {
633
- method: params.method || 'GET',
634
- headers: {
635
- Authorization: "Bearer " + config.token,
636
- 'Content-type': 'application/json'
637
- }
638
- };
639
- if (shouldAppendBody(params)) {
640
- opts = __assign({}, opts, { body: params.body });
641
- }
642
- return opts;
643
- }
644
- /**
645
- * @param {?} params
646
- * @param {?} config
647
- * @return {?}
648
- */
649
- function request(params, config) {
650
- return __awaiter(this, void 0, void 0, function () {
651
- var url, opts;
652
- return __generator(this, function (_a) {
653
- switch (_a.label) {
654
- case 0: return [4 /*yield*/, getUrl(params, config)];
655
- case 1:
656
- url = _a.sent();
657
- opts = getOpts(params, config);
658
- return [2 /*return*/, fetch(url, opts)];
659
- }
660
- });
661
- });
662
- }
663
-
664
- /**
665
- * @fileoverview added by tsickle
666
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
667
- */
668
- var DotCMSHttpClient = /** @class */ (function () {
669
- function DotCMSHttpClient(config) {
670
- this._config = config;
671
- }
672
- /**
673
- * @param {?} params
674
- * @return {?}
675
- */
676
- DotCMSHttpClient.prototype.request = /**
677
- * @param {?} params
678
- * @return {?}
679
- */
680
- function (params) {
681
- return request(params, this._config);
682
- };
683
- return DotCMSHttpClient;
684
- }());
685
-
686
- /**
687
- * @fileoverview added by tsickle
688
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
689
- */
690
- /**
691
- * @param {?} params
692
- * @return {?}
693
- */
694
- function populateQueryUrl(params) {
695
- var e_1, _a, e_2, _b;
696
- /** @type {?} */
697
- var url = '';
698
- /** @type {?} */
699
- var attrs = {
700
- depth: "/depth/" + params.options.depth,
701
- limit: "/limit/" + params.options.limit,
702
- offset: "/offset/" + params.options.offset,
703
- orderBy: "/orderby/" + params.options.orderBy
704
- };
705
- if (params.queryParams) {
706
- try {
707
- for (var _c = __values(Object.keys(params.queryParams)), _d = _c.next(); !_d.done; _d = _c.next()) {
708
- var key = _d.value;
709
- url += "+" + key + ":" + params.queryParams[key] + "%20";
710
- }
711
- }
712
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
713
- finally {
714
- try {
715
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
716
- }
717
- finally { if (e_1) throw e_1.error; }
718
- }
719
- }
720
- try {
721
- for (var _e = __values(Object.keys(params.options)), _f = _e.next(); !_f.done; _f = _e.next()) {
722
- var key = _f.value;
723
- url += attrs[key];
724
- }
725
- }
726
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
727
- finally {
728
- try {
729
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
730
- }
731
- finally { if (e_2) throw e_2.error; }
732
- }
733
- return url;
734
- }
735
- /**
736
- * Query/Save/Publish the information of DotCMS Content
737
- *
738
- */
739
- var /**
740
- * Query/Save/Publish the information of DotCMS Content
741
- *
742
- */
743
- DotApiContent = /** @class */ (function () {
744
- function DotApiContent(httpClient) {
745
- this.dotCMSHttpClient = httpClient;
746
- }
747
- /**
748
- * @param {?} params
749
- * @return {?}
750
- */
751
- DotApiContent.prototype.query = /**
752
- * @param {?} params
753
- * @return {?}
754
- */
755
- function (params) {
756
- /** @type {?} */
757
- var url = "/api/content/query/+contentType:" + params.contentType + "%20" + populateQueryUrl(params);
758
- return this.doRequest(url, null, 'GET');
759
- };
760
- /**
761
- * @template Content
762
- * @param {?} params
763
- * @return {?}
764
- */
765
- DotApiContent.prototype.save = /**
766
- * @template Content
767
- * @param {?} params
768
- * @return {?}
769
- */
770
- function (params) {
771
- return this.doRequest('/api/content/save/1', params);
772
- };
773
- /**
774
- * @template Content
775
- * @param {?} params
776
- * @return {?}
777
- */
778
- DotApiContent.prototype.publish = /**
779
- * @template Content
780
- * @param {?} params
781
- * @return {?}
782
- */
783
- function (params) {
784
- return this.doRequest('/api/content/publish/1', params);
785
- };
786
- /**
787
- * @template Content
788
- * @param {?} url
789
- * @param {?=} params
790
- * @param {?=} httpMethod
791
- * @return {?}
792
- */
793
- DotApiContent.prototype.doRequest = /**
794
- * @template Content
795
- * @param {?} url
796
- * @param {?=} params
797
- * @param {?=} httpMethod
798
- * @return {?}
799
- */
800
- function (url, params, httpMethod) {
801
- if (httpMethod === void 0) { httpMethod = 'POST'; }
802
- return __awaiter(this, void 0, void 0, function () {
803
- var response, _a;
804
- return __generator(this, function (_b) {
805
- switch (_b.label) {
806
- case 0: return [4 /*yield*/, this.dotCMSHttpClient.request({
807
- url: url,
808
- method: httpMethod,
809
- body: params ? JSON.stringify(params) : ''
810
- })];
811
- case 1:
812
- response = _b.sent();
813
- if (!(response.status !== 200)) return [3 /*break*/, 3];
814
- _a = {};
815
- return [4 /*yield*/, response.text()];
816
- case 2: throw /** @type {?} */ (_a.message = _b.sent(),
817
- _a.statusCode = response.status,
818
- _a);
819
- case 3: return [2 /*return*/, response];
820
- }
821
- });
822
- });
823
- };
824
- return DotApiContent;
825
- }());
826
-
827
- /**
828
- * @fileoverview added by tsickle
829
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
830
- */
831
- /**
832
- * Get the information of DotCMS contentTypes
833
- *
834
- */
835
- var /**
836
- * Get the information of DotCMS contentTypes
837
- *
838
- */
839
- DotApiContentType = /** @class */ (function () {
840
- function DotApiContentType(httpClient) {
841
- this.dotCMSHttpClient = httpClient;
842
- }
843
- /**
844
- * @param {?} contentTypeId
845
- * @return {?}
846
- */
847
- DotApiContentType.prototype.get = /**
848
- * @param {?} contentTypeId
849
- * @return {?}
850
- */
851
- function (contentTypeId) {
852
- return __awaiter(this, void 0, void 0, function () {
853
- var response, _a, data;
854
- return __generator(this, function (_b) {
855
- switch (_b.label) {
856
- case 0: return [4 /*yield*/, this.dotCMSHttpClient.request({
857
- url: "/api/v1/contenttype/id/" + contentTypeId
858
- })];
859
- case 1:
860
- response = _b.sent();
861
- if (!(response.status !== 200)) return [3 /*break*/, 3];
862
- _a = {};
863
- return [4 /*yield*/, response.text()];
864
- case 2: throw /** @type {?} */ (_a.message = _b.sent(),
865
- _a.statusCode = response.status,
866
- _a);
867
- case 3: return [4 /*yield*/, response.json()];
868
- case 4:
869
- data = _b.sent();
870
- return [2 /*return*/, data.entity];
871
- }
872
- });
873
- });
874
- };
875
- /**
876
- * @param {?} contentTypeId
877
- * @return {?}
878
- */
879
- DotApiContentType.prototype.getLayout = /**
880
- * @param {?} contentTypeId
881
- * @return {?}
882
- */
883
- function (contentTypeId) {
884
- return this.get(contentTypeId).then(function (contentType) {
885
- return contentType.layout;
886
- });
887
- };
888
- return DotApiContentType;
889
- }());
890
-
891
- /**
892
- * @fileoverview added by tsickle
893
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
894
- */
895
- /**
896
- * Creates and provide methods to render a DotCMS Form
897
- *
898
- */
899
- var /**
900
- * Creates and provide methods to render a DotCMS Form
901
- *
902
- */
903
- DotApiForm = /** @class */ (function () {
904
- function DotApiForm(dotApiContentType, formConfig) {
905
- this.dotApiContentType = dotApiContentType;
906
- this.formConfig = formConfig;
907
- }
908
- /**
909
- * Render form on provided html element
910
- * @memberof DotApiForm
911
- */
912
- /**
913
- * Render form on provided html element
914
- * \@memberof DotApiForm
915
- * @return {?}
916
- */
917
- DotApiForm.prototype.get = /**
918
- * Render form on provided html element
919
- * \@memberof DotApiForm
920
- * @return {?}
921
- */
922
- function () {
923
- return __awaiter(this, void 0, void 0, function () {
924
- return __generator(this, function (_a) {
925
- return [2 /*return*/, this.dotApiContentType.get(this.formConfig.identifier)];
926
- });
927
- });
928
- };
929
- return DotApiForm;
930
- }());
931
-
932
- /**
933
- * @fileoverview added by tsickle
934
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
935
- */
936
- /** @type {?} */
937
- var initDotCMS = function (config) {
938
- /** @type {?} */
939
- var httpClient = new DotCMSHttpClient(config);
940
- /** @type {?} */
941
- var apiConfig = new DotApiConfiguration(httpClient);
942
- /** @type {?} */
943
- var apiLanguage = new DotApiLanguage(apiConfig);
944
- /** @type {?} */
945
- var content = new DotApiContent(httpClient);
946
- /** @type {?} */
947
- var dotApiContentType = new DotApiContentType(httpClient);
948
- return {
949
- auth: new DotApiAuthorization(),
950
- config: apiConfig,
951
- content: content,
952
- contentType: new DotApiContentType(httpClient),
953
- esSearch: new DotApiElasticSearch(httpClient),
954
- event: new DotApiEvent(),
955
- form: function (formConfig) { return new DotApiForm(dotApiContentType, formConfig); },
956
- language: apiLanguage,
957
- nav: new DotApiNavigation(httpClient),
958
- page: new DotApiPage(httpClient, apiLanguage),
959
- site: new DotApiSite(httpClient),
960
- widget: new DotApiWidget(httpClient),
961
- httpClient: httpClient
962
- };
963
- };
964
-
965
- /**
966
- * @fileoverview added by tsickle
967
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
968
- */
969
-
970
- export { initDotCMS };
971
-
972
- //# sourceMappingURL=dotcms.js.map