@progress/sitefinity-webservices-sdk 0.3.0 → 1.0.2

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 (201) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +19 -0
  3. package/ci/pipelines/ci.yml +219 -0
  4. package/config/helpers.js +0 -6
  5. package/config/webpack.common.js +1 -3
  6. package/config/webpack.dev.js +2 -9
  7. package/config/webpack.prod.js +5 -6
  8. package/dist/docs/.nojekyll +1 -0
  9. package/dist/docs/assets/highlight.css +57 -0
  10. package/dist/docs/assets/icons.css +1043 -0
  11. package/dist/docs/assets/icons.png +0 -0
  12. package/dist/docs/assets/icons@2x.png +0 -0
  13. package/dist/docs/assets/main.js +52 -0
  14. package/dist/docs/assets/search.js +1 -0
  15. package/dist/docs/assets/style.css +1413 -0
  16. package/dist/docs/assets/{images/widgets.png → widgets.png} +0 -0
  17. package/dist/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  18. package/dist/docs/classes/BlobBuilder.BlobBuilder-1.html +7 -0
  19. package/dist/docs/classes/Data.Data-1.html +65 -0
  20. package/dist/docs/classes/Expression.BinaryExpression.html +1 -0
  21. package/dist/docs/classes/Expression.ComplexExpression.html +1 -0
  22. package/dist/docs/classes/Expression.ExpressionBase.html +1 -0
  23. package/dist/docs/classes/OrderProperty.OrderProperty-1.html +1 -0
  24. package/dist/docs/classes/Query.Query-1.html +33 -0
  25. package/dist/docs/classes/QueryBase.QueryBase-1.html +7 -0
  26. package/dist/docs/classes/QueryBuilder.QueryBuilder-1.html +1 -0
  27. package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +17 -0
  28. package/dist/docs/classes/Requests_BatchRequest.Transaction.html +17 -0
  29. package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +1 -0
  30. package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +1 -0
  31. package/dist/docs/classes/Requests_Request.CreateRequest.html +1 -0
  32. package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +1 -0
  33. package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +1 -0
  34. package/dist/docs/classes/Requests_Request.DeleteRequest.html +1 -0
  35. package/dist/docs/classes/Requests_Request.GetByIdRequest.html +1 -0
  36. package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +1 -0
  37. package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +1 -0
  38. package/dist/docs/classes/Requests_Request.GetRequest.html +1 -0
  39. package/dist/docs/classes/Requests_Request.UpdateRequest.html +1 -0
  40. package/dist/docs/classes/Requests_Request.UploadRequest.html +1 -0
  41. package/dist/docs/classes/Requests_RequestBase.RequestBase.html +1 -0
  42. package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +1 -0
  43. package/dist/docs/classes/Sitefinity.Sitefinity-1.html +5 -0
  44. package/dist/docs/classes/WhereQuery.WhereQuery-1.html +31 -0
  45. package/dist/docs/classes/utils.utils-1.html +1 -0
  46. package/dist/docs/index.html +54 -242
  47. package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +1 -0
  48. package/dist/docs/interfaces/Data.CreateRequestOptions.html +1 -0
  49. package/dist/docs/interfaces/Data.OperationsRequestOptions.html +1 -0
  50. package/dist/docs/interfaces/Data.PropertyRequestOptions.html +1 -0
  51. package/dist/docs/interfaces/Data.RequestOptionsBase.html +1 -0
  52. package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +1 -0
  53. package/dist/docs/interfaces/Data.UpdateRequestOptions.html +1 -0
  54. package/dist/docs/interfaces/Data.UploadRequestOptions.html +1 -0
  55. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +1 -0
  56. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +1 -0
  57. package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +1 -0
  58. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +1 -0
  59. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +1 -0
  60. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +1 -0
  61. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +1 -0
  62. package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +1 -0
  63. package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +5 -0
  64. package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +1 -0
  65. package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +1 -0
  66. package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +1 -0
  67. package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +1 -0
  68. package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +1 -0
  69. package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +1 -0
  70. package/dist/docs/interfaces/Sitefinity.SDKOptions.html +9 -0
  71. package/dist/docs/interfaces/Sitefinity.Token.html +1 -0
  72. package/dist/docs/interfaces/Sitefinity.TypeOptions.html +13 -0
  73. package/dist/docs/modules/BlobBuilder.html +1 -0
  74. package/dist/docs/modules/Data.html +1 -0
  75. package/dist/docs/modules/Expression.html +1 -0
  76. package/dist/docs/modules/OrderProperty.html +1 -0
  77. package/dist/docs/modules/Query.html +1 -0
  78. package/dist/docs/modules/QueryBase.html +1 -0
  79. package/dist/docs/modules/QueryBuilder.html +1 -0
  80. package/dist/docs/modules/Requests_BatchRequest.html +1 -0
  81. package/dist/docs/modules/Requests_ExecutableRequest.html +1 -0
  82. package/dist/docs/modules/Requests_Request.html +1 -0
  83. package/dist/docs/modules/Requests_RequestBase.html +1 -0
  84. package/dist/docs/modules/Requests_RequestFactory.html +1 -0
  85. package/dist/docs/modules/Sitefinity.html +1 -0
  86. package/dist/docs/modules/WhereQuery.html +1 -0
  87. package/dist/docs/modules/constants.html +1 -0
  88. package/dist/docs/modules/utils.html +1 -0
  89. package/dist/docs/modules.html +1 -0
  90. package/dist/samples.html +33 -81
  91. package/dist/sitefinity-webservices-sdk.d.ts +16 -0
  92. package/dist/sitefinity-webservices-sdk.js +1140 -1734
  93. package/dist/sitefinity-webservices-sdk.js.map +1 -1
  94. package/dist/sitefinity-webservices-sdk.min.js +2 -16
  95. package/dist/sitefinity-webservices-sdk.min.js.LICENSE.txt +14 -0
  96. package/dist/src/BlobBuilder.d.ts +14 -0
  97. package/dist/src/Data.d.ts +144 -0
  98. package/dist/src/Expression.d.ts +19 -0
  99. package/dist/src/OrderProperty.d.ts +8 -0
  100. package/dist/src/Query.d.ts +59 -0
  101. package/dist/src/QueryBase.d.ts +18 -0
  102. package/dist/src/QueryBuilder.d.ts +13 -0
  103. package/dist/src/Requests/BatchRequest.d.ts +146 -0
  104. package/dist/src/Requests/ExecutableRequest.d.ts +20 -0
  105. package/dist/src/Requests/Request.d.ts +88 -0
  106. package/dist/src/Requests/RequestBase.d.ts +28 -0
  107. package/dist/src/Requests/RequestFactory.d.ts +22 -0
  108. package/dist/src/Sitefinity.d.ts +66 -0
  109. package/dist/src/WhereQuery.d.ts +68 -0
  110. package/dist/src/constants.d.ts +55 -0
  111. package/dist/src/utils.d.ts +16 -0
  112. package/karma.conf.js +29 -0
  113. package/package-lock.json +16108 -6805
  114. package/package.json +28 -10
  115. package/sitefinity-webservices-sdk.ts +16 -0
  116. package/src/BlobBuilder.ts +7 -12
  117. package/src/Data.spec.ts +160 -0
  118. package/src/Data.ts +132 -207
  119. package/src/Expression.ts +0 -1
  120. package/src/OrderProperty.ts +4 -5
  121. package/src/Query.ts +52 -78
  122. package/src/QueryBase.ts +21 -47
  123. package/src/QueryBuilder.ts +68 -83
  124. package/src/Requests/BatchRequest.ts +312 -335
  125. package/src/Requests/ExecutableRequest.ts +46 -73
  126. package/src/Requests/Request.ts +134 -260
  127. package/src/Requests/RequestBase.ts +161 -0
  128. package/src/Requests/RequestFactory.ts +36 -54
  129. package/src/Requests/request.spec.ts +108 -0
  130. package/src/Sitefinity.spec.ts +418 -0
  131. package/src/Sitefinity.ts +77 -146
  132. package/src/WhereQuery.ts +52 -112
  133. package/src/constants.ts +58 -39
  134. package/src/utils.ts +17 -14
  135. package/template.html +33 -35
  136. package/tsconfig.json +8 -1
  137. package/type.txt +1 -1
  138. package/config/html.conf.json +0 -5
  139. package/dist/docs/assets/css/main.css +0 -865
  140. package/dist/docs/assets/css/main.css.map +0 -7
  141. package/dist/docs/assets/images/icons.png +0 -0
  142. package/dist/docs/assets/images/icons@2x.png +0 -0
  143. package/dist/docs/assets/js/main.js +0 -5
  144. package/dist/docs/assets/js/search.js +0 -3
  145. package/dist/docs/classes/_authentication_.authentication.html +0 -527
  146. package/dist/docs/classes/_blobbuilder_.blobbuilder.html +0 -351
  147. package/dist/docs/classes/_data_.data.html +0 -974
  148. package/dist/docs/classes/_expression_.binaryexpression.html +0 -450
  149. package/dist/docs/classes/_expression_.complexexpression.html +0 -374
  150. package/dist/docs/classes/_expression_.expressionbase.html +0 -336
  151. package/dist/docs/classes/_orderproperty_.orderproperty.html +0 -381
  152. package/dist/docs/classes/_query_.query.html +0 -896
  153. package/dist/docs/classes/_querybase_.querybase.html +0 -518
  154. package/dist/docs/classes/_querybuilder_.querybuilder.html +0 -493
  155. package/dist/docs/classes/_requests_batchrequest_.batchrequest.html +0 -1511
  156. package/dist/docs/classes/_requests_batchrequest_.transaction.html +0 -804
  157. package/dist/docs/classes/_requests_executablerequest_.executablerequest.html +0 -549
  158. package/dist/docs/classes/_requests_request_.createrelatedrequest.html +0 -689
  159. package/dist/docs/classes/_requests_request_.createrequest.html +0 -680
  160. package/dist/docs/classes/_requests_request_.deleterelatedbyidrequest.html +0 -687
  161. package/dist/docs/classes/_requests_request_.deleterelatedrequest.html +0 -673
  162. package/dist/docs/classes/_requests_request_.deleterequest.html +0 -666
  163. package/dist/docs/classes/_requests_request_.getbyidrequest.html +0 -666
  164. package/dist/docs/classes/_requests_request_.getrelatedbyidrequest.html +0 -687
  165. package/dist/docs/classes/_requests_request_.getrelatedrequest.html +0 -673
  166. package/dist/docs/classes/_requests_request_.getrequest.html +0 -658
  167. package/dist/docs/classes/_requests_request_.requestbase.html +0 -687
  168. package/dist/docs/classes/_requests_request_.updaterequest.html +0 -686
  169. package/dist/docs/classes/_requests_request_.uploadrequest.html +0 -715
  170. package/dist/docs/classes/_requests_requestfactory_.requestfactory.html +0 -724
  171. package/dist/docs/classes/_sitefinity_.sitefinity.html +0 -521
  172. package/dist/docs/classes/_utils_.utils.html +0 -597
  173. package/dist/docs/classes/_wherequery_.wherequery.html +0 -992
  174. package/dist/docs/globals.html +0 -238
  175. package/dist/docs/modules/_authentication_.html +0 -225
  176. package/dist/docs/modules/_blobbuilder_.html +0 -225
  177. package/dist/docs/modules/_constants_.html +0 -528
  178. package/dist/docs/modules/_contenttypes_.html +0 -248
  179. package/dist/docs/modules/_data_.html +0 -225
  180. package/dist/docs/modules/_expression_.html +0 -233
  181. package/dist/docs/modules/_headers_.html +0 -328
  182. package/dist/docs/modules/_httpmethods_.html +0 -288
  183. package/dist/docs/modules/_main_.html +0 -209
  184. package/dist/docs/modules/_orderproperty_.html +0 -225
  185. package/dist/docs/modules/_query_.html +0 -225
  186. package/dist/docs/modules/_querybase_.html +0 -225
  187. package/dist/docs/modules/_querybuilder_.html +0 -247
  188. package/dist/docs/modules/_requests_batchrequest_.html +0 -265
  189. package/dist/docs/modules/_requests_executablerequest_.html +0 -296
  190. package/dist/docs/modules/_requests_request_.html +0 -333
  191. package/dist/docs/modules/_requests_requestfactory_.html +0 -247
  192. package/dist/docs/modules/_sitefinity_.html +0 -225
  193. package/dist/docs/modules/_utils_.html +0 -225
  194. package/dist/docs/modules/_wherequery_.html +0 -247
  195. package/dist/index.html +0 -474
  196. package/src/Authentication.ts +0 -96
  197. package/src/ContentTypes.ts +0 -5
  198. package/src/Headers.ts +0 -12
  199. package/src/HttpMethods.ts +0 -9
  200. package/src/main.ts +0 -2
  201. package/version.txt +0 -1
package/dist/index.html DELETED
@@ -1,474 +0,0 @@
1
- <!DOCTYPE html>
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <title></title>
5
- <script type="text/javascript" src="sitefinity-webservices-sdk.js"></script></head>
6
- <body>
7
- <script>
8
-
9
- function clearHtmlMessages() {
10
- document.getElementById("message").innerHTML = "";
11
- document.getElementById("container").innerHTML = "";
12
- document.getElementById("containerErr").innerHTML = "";
13
- }
14
-
15
- window.onload = function () {
16
-
17
- var links = document.getElementsByTagName('input');
18
-
19
- for (var i = 0; i < links.length; i++) {
20
- if(links[i].hasAttribute("onclick"))
21
- links[i].addEventListener('click', clearHtmlMessages, false);
22
- };
23
-
24
- }
25
-
26
- var query = new Sitefinity.Query();
27
-
28
- var query0 = query.where().and().endsWith("Title", "Record").done().or().startsWith('Title', 'asd').done().done();
29
- var query1 = query.where().or().endsWith("Record", "Title").ne('age', '15').eq('Content', 'test').done().done();
30
- var query2 = query.where().and().endsWith("Title", "Record").done().done();
31
- var query3 = query.where().endsWith("Record", "Title").or().ne('age', '15').eq('Content', 'test').done().done();
32
- var query4 = query.where().not().endsWith("Record", "Title").done().and().not().eq('Content', 'test').done().done().done();
33
- var query5 = query.where().not().and().endsWith("Record", "Title").eq('Content', 'test').done().done().done();
34
- var query6 = query.select("Id", "Title", "Content").expand('Tags').order("Title desc").where().ne('Title', 'zzz').eq('Title', 'newTitle').done()//.count();
35
- var query7 = query.order("Title desc").where().eq('Title', 'newTitleUPDATE1').done().select("Title", "Content");
36
- var query8 = query.where().eq('Title', 'newTitleN11').done();
37
- var query9 = query.where().eq('Title', null).done();
38
- var query10 = query.count();
39
-
40
- var queryIDs = query.select('Id');
41
- console.log(query0.build());
42
- console.log(query1.build());
43
- console.log(query2.build());
44
- console.log(query3.build());
45
- console.log(query4.build());
46
- console.log(query5.build());
47
- console.log(query6.build());
48
- console.log(query7.build());
49
- console.log(query8.build());
50
- console.log(query9.build());
51
- console.log(query10.build());
52
- //Create Item
53
- var newsItem = {
54
- "Title": 'newTitleN11',
55
- "UrlName": "newUrlName" + new Date().getTime(),
56
- "Content": "new content",
57
- "Summary": "new summary"
58
- };
59
-
60
- //Update Item
61
- var newsItemUpdate = {
62
- "Title": 'newTitleUPDATE!TEST'
63
- };
64
-
65
- var entitySet = "newsitems";
66
-
67
- var sitefinityUrl = "http://localhost"
68
- //Replace my_sandbox_location with the location of the server you are using
69
- var options = {
70
- serviceUrl: sitefinityUrl + "/api/default/",
71
- handlers: {
72
- failureCb: function() {
73
- console.log("Global error occured");
74
- },
75
- successCb: function() {
76
- console.log("Success executing request");
77
- }
78
- }
79
- }
80
-
81
- // operation data
82
- var action = {
83
- action: "Publish",
84
- actionParameters: {
85
- Title: "SomeTitle",
86
- PublicationDate: "2016-06-21T06:26:32.7439661Z",
87
- ExpirationDate: "2016-06-21T06:26:32.7439661Z"
88
- }
89
- };
90
-
91
- // Sitefinity object
92
- var sf = new Sitefinity(options);
93
- sf.authentication.setToken("");
94
-
95
- var inputElement = document.getElementById('getGuid');
96
- var that = this;
97
- // Success and Failure CB's
98
- var successCb = function (data) {
99
- document.getElementById("container").innerHTML = JSON.stringify(data);
100
- }
101
-
102
- var successCbBatch = function(data) {
103
- document.getElementById("container").innerHTML = JSON.stringify(data);
104
- }
105
-
106
- var failureCb = function (data) {
107
- if (data.status == 404) {
108
- document.getElementById("message").innerHTML = "You can use some of these items.";
109
- var data = sf.data(entitySet);
110
- data.get({
111
- query: queryIDs,
112
- successCb: successCb
113
- });
114
- }
115
- document.getElementById("containerErr").innerHTML = JSON.stringify(data.responseText);
116
- }
117
-
118
- var dataOptions = {
119
- urlName: entitySet,
120
- providerName: "OpenAccessDataProvider",
121
- cultureName: "en"
122
- }
123
-
124
- function requestGet() {
125
- var data = sf.data(dataOptions);
126
- data.get({
127
- query: null,
128
- successCb: successCb
129
- });
130
- }
131
-
132
- function requestGetCount(inline) {
133
- var data = sf.data(dataOptions);
134
- data.get({
135
- query: query.count(inline),
136
- successCb: successCb
137
- });
138
- }
139
-
140
- function requestGetSingle() {
141
- var data = sf.data(dataOptions);
142
- data.getSingle({
143
- key: getGuid(),
144
- query: null,
145
- successCb: successCb,
146
- failureCb: failureCb
147
- });
148
- }
149
-
150
- function requestGetRelated() {
151
- var data = sf.data(dataOptions);
152
- data.getRelated({
153
- key: getGuid(),
154
- navigationProperty: "Tags",
155
- successCb: successCb,
156
- failureCb: failureCb
157
- });
158
- }
159
-
160
- function requestUpdate() {
161
- var data = sf.data(dataOptions);
162
- data.update({
163
- key: getGuid(),
164
- data: newsItemUpdate,
165
- //saveTemp: true,
166
- successCb: successCb,
167
- failureCb: failureCb
168
- });
169
- }
170
-
171
- function requestCreate() {
172
- var data = sf.data(dataOptions);
173
- data.create({
174
- data: newsItem,
175
- successCb: successCb,
176
- failureCb: failureCb
177
- });
178
- }
179
-
180
- function requestDelete() {
181
- var data = sf.data(dataOptions);
182
- data.destroy({
183
- key: getGuid(),
184
- successCb: successCb,
185
- failureCb: failureCb
186
- });
187
- }
188
-
189
- function requestOperation() {
190
- var data = sf.data(dataOptions);
191
-
192
- data.operation({
193
- key: getGuid(),
194
- data: action,
195
- successCb: successCb,
196
- failureCb: failureCb
197
- });
198
- }
199
-
200
- function requestOperationAction() {
201
- var data = sf.data(dataOptions);
202
-
203
- data.getOperations({
204
- data: action,
205
- successCb: successCb,
206
- failureCb: failureCb
207
- });
208
- }
209
-
210
- function requestOperationActionSingle() {
211
- var data = sf.data(dataOptions);
212
-
213
- data.getOperations({
214
- key: getGuid(),
215
- data: action,
216
- successCb: successCb,
217
- failureCb: failureCb
218
- });
219
- }
220
-
221
- function requestCreateRelated() {
222
- var data = sf.data(dataOptions);
223
- var createRefLink = "http://localhost:8097/api/odata/flatTaxa(" + getRelatedGuid() + ")";
224
- data.createRelated({
225
- key: getGuid(),
226
- navigationProperty: "Tags",
227
- link: createRefLink,
228
- successCb: successCb,
229
- failureCb: failureCb
230
- });
231
- }
232
-
233
- function requestDeleteRelated() {
234
- var data = sf.data(dataOptions);
235
- data.destroyRelated({
236
- key: getGuid(),
237
- navigationProperty: "Tags",
238
- successCb: successCb,
239
- failureCb: failureCb
240
- });
241
- }
242
-
243
- function requestBatch() {
244
- /*data.getProperty({
245
- key: id,
246
- property: "Title",
247
- successCb: successCb,
248
- failureCb: failureCb
249
- });
250
-
251
- data.getRelated({
252
- key: id,
253
- navigationProperty: "Tags",
254
- successCb: successCb,
255
- failureCb: failureCb
256
- });
257
-
258
- */
259
-
260
- var batch = sf.batch(successCbBatch, failureCb);
261
-
262
- batch.get({
263
- entitySet: entitySet,
264
- query: query8
265
- });
266
-
267
- var transaction = batch.beginTransaction();
268
-
269
- var createId = transaction.create({
270
- entitySet: entitySet,
271
- data: newsItem
272
- });
273
-
274
- batch.endTransaction(transaction);
275
-
276
- var transaction2 = batch.beginTransaction();
277
-
278
- var createId2 = transaction2.create({
279
- entitySet: entitySet,
280
- data: newsItem
281
- });
282
-
283
- var updateId2 = transaction2.update({
284
- entitySet: entitySet,
285
- saveTemp: true,
286
- key: createId2,
287
- data: newsItemUpdate
288
- });
289
-
290
- var operation2 = transaction2.operation({
291
- entitySet: entitySet,
292
- key: createId2,
293
- data: action
294
- });
295
-
296
- batch.endTransaction(transaction2);
297
-
298
- batch.get({
299
- entitySet: entitySet
300
- });
301
-
302
- batch.execute();
303
- }
304
-
305
- function upload() {
306
- /*
307
- Headers:
308
- Content-Type: image/jpeg
309
- Content-Encoding: base64
310
- in a changeset with Content-ID's
311
- first request is post with image binary data
312
- second is patch with content id of first and for data {Title: "" , UrlName: ""}
313
- third is post (create ref to the album) with content id of first, navigation property of the album and link to this album
314
- used parameters:
315
- 1. entitySet of document/image/video
316
- 2. binary data of the file
317
- 3. additional data for the file
318
- 2 and 3 can be combined in one data object as
319
- data {
320
- file: file, // take content type from file.type
321
- fileDescription: {fileDescription}
322
- }
323
-
324
- 4. navigationProperty/library: ""
325
- 5. link: "" to the album/library
326
- */
327
-
328
- /*
329
- Total 3 requests: UploadRequest, UpdateRequest, CreateRelationRequest
330
- Content-Type for create request is like Content-type: image/jpeg (file type).
331
- */
332
-
333
- var photo = document.getElementById("photo");
334
- var file = photo.files[0];
335
-
336
- var imageData = {
337
- "Title": file.name,
338
- "UrlName": file.name
339
- };
340
- var ready = false;
341
- var result = '';
342
-
343
- var that = this;
344
- var check = function () {
345
- if (ready === true) {
346
- //encode to base64 from binary string
347
- result = btoa(result)
348
-
349
- var data = sf.data({
350
- urlName: "images"
351
- });
352
- data.upload({ /* POST */
353
- data: {
354
- content: result, /* images, documents or videos */
355
- contentType: "image/jpeg",
356
- name: "test.jpg",
357
- payload: {
358
- Title: "Test",
359
- UrlName: "test"
360
- },
361
- uploadProperties: {
362
- ParentId: "4BA7AD46-F29B-4E65-BE17-9BF7CE5BA1FB"
363
- }
364
- },
365
- successCb: successCb,
366
- failureCb: failureCb
367
- });
368
-
369
- return;
370
- }
371
- setTimeout(check, 1000);
372
- }
373
-
374
- check();
375
-
376
- // read file
377
- var reader = new FileReader();
378
- reader.onloadend = function (event) {
379
- result = event.target.result
380
- ready = true;
381
- }
382
-
383
- reader.readAsBinaryString(file);
384
- }
385
-
386
- function getGuid() {
387
- var inputElement = document.getElementById('getGuid');
388
- return inputElement.value;
389
- }
390
-
391
- function getRelatedGuid() {
392
- var inputElement = document.getElementById('getRelatedGuid');
393
- return inputElement.value;
394
- }
395
-
396
- function login(username, password) {
397
- var url = sitefinityUrl + "/Sitefinity/Authenticate/OpenID/connect/token";
398
- var data = {
399
- username: username,
400
- password: password,
401
- grant_type: "password",
402
- scope: "openid",
403
- client_id: "iris",
404
- client_secret: "secret"
405
- };
406
-
407
- var body = "";
408
- Object.keys(data).forEach(key => {
409
- if (body.length) {
410
- body += "&";
411
- }
412
- body += key + "=";
413
- body += encodeURIComponent(data[key]);
414
- });
415
-
416
- var xhr = new XMLHttpRequest();
417
-
418
- xhr.open("POST", url, true);
419
- xhr.addEventListener("load", () => {
420
- if (xhr.status == 200) {
421
- let token = JSON.parse(xhr.responseText);
422
-
423
- let tokenObj = {
424
- type: token.token_type,
425
- value: token.access_token
426
- };
427
-
428
- sf.authentication.setToken(tokenObj);
429
- }
430
- });
431
-
432
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
433
-
434
- xhr.send(body);
435
- }
436
-
437
- </script>
438
- Usage: <br /><code>
439
- <b>
440
- sf = new Sitefinity(options);<br />data = sf.data(entitySet);<br />data.get(); data.destroy ...
441
- <br />data.batch(successCb, failureCb).get().Update...done(); content id's starts from 0 to n ('get' is 0 'update' is 1 etc.).
442
- </b>
443
- </code><br /><br />
444
- <input type="button" value="login" onclick="login()" />
445
- <input type="button" value="requestGet" onclick="requestGet()" />
446
- <input type="button" value="requestGetCountInline" onclick="requestGetCount(true)" />
447
- <input type="button" value="requestGetCount" onclick="requestGetCount(false)" />
448
- <input type="button" value="requestGetSingle" onclick="requestGetSingle()" />
449
- <input type="button" value="requestGetRelated" onclick="requestGetRelated()" />
450
- <input type="button" value="requestUpdate" onclick="requestUpdate()" />
451
- <input type="button" value="requestCreate" onclick="requestCreate()" />
452
- <input type="button" value="requestCreateRelated" onclick="requestCreateRelated()" />
453
- <input type="button" value="requestDelete" onclick="requestDelete()" />
454
- <input type="button" value="requestDeleteRelated" onclick="requestDeleteRelated()" />
455
- <input type="button" value="requestBatch" onclick="requestBatch()" />
456
- <input type="button" value="requestOperation" onclick="requestOperation()" />
457
- <input type="button" value="requestOperationAction" onclick="requestOperationAction()" />
458
- <input type="button" value="requestOperationActionSingle" onclick="requestOperationActionSingle()" />
459
- <br />
460
- <br />
461
- <input type="text" id="getGuid" value="00000000-0000-0000-0000-000000000000" size="50" />
462
- <span>related ID</span><input type="text" id="getRelatedGuid" value="00000000-0000-0000-0000-000000000000" size="50" />
463
- <br />
464
- <br />
465
- <input type="file" name="photo" id="photo">
466
- <input type="button" value="Upload" onclick="upload()">
467
- <div id="some_container_div"></div>
468
- <br />
469
- <br />
470
- <div id="message" style="color: blue; border: 1px solid;"></div>
471
- <div id="container" style="color: green; border: 1px solid;"></div>
472
- <div id="containerErr" style="color: red; border: 1px solid;"></div>
473
- </body>
474
- </html>
@@ -1,96 +0,0 @@
1
- /**
2
- * @class Authentication
3
- * @classdesc The constructor of the Authentication object. This object is used for authenticating a user to Sitefinity.
4
- * @param {object} options - An object containing configuration options for the {@Link Authentication} object.
5
- * @param {string} options.serviceUrl - Your service url that points to the configured instance of Sitefinity service.
6
- */
7
- export class Authentication {
8
- private _token: any;
9
- private _serviceUrl: string;
10
- private factory: any;
11
-
12
- constructor(options) {
13
- this._token = null;
14
- this._serviceUrl = options.serviceUrl;
15
- this.factory = options.factory;
16
- }
17
-
18
- /**
19
- * Logins the user. A service call is made to login the user. If the call is successful and the service returns a token, this token is cached in the {@link Authentication} object.
20
- * @memberOf Authentication
21
- * @instance
22
- * @param {string} username - The username.
23
- * @param {string} password - The password.
24
- * @param {Function} [success] - The success handler of the method.
25
- * @param {Function} [failure] - The error handler of the method.
26
- * @deprecated This method is deprecated and should not be used with versions of sitefinity >= 10.0
27
- * @example
28
- * sf.authentication.login("username", "password", successCb, failureCb);
29
- */
30
- login(username: string, password: string, success: any, failure: any) {
31
- var that = this;
32
- var request = this.factory.create({
33
- data: {
34
- username: username,
35
- password: password
36
- },
37
- urlOptions: {
38
- baseUrl: that._serviceUrl + 'login'
39
- },
40
- successCb: function (data) {
41
- that.setToken(data.value);
42
- if (typeof success === 'function')
43
- success(data.value);
44
- },
45
- failureCb: failure
46
- });
47
-
48
- request._execute();
49
- }
50
-
51
- /**
52
- * Logouts the user.
53
- * @memberOf Authentication
54
- * @instance
55
- * @param {Function} [success] - The success handler of the method.
56
- * @param {Function} [failure] - The error handler of the method.
57
- * @deprecated This method is deprecated and should not be used with versions of sitefinity >= 10.0
58
- */
59
- logout(success: any, failure: any) {
60
- var that = this;
61
- var request = this.factory.create({
62
- urlOptions: {
63
- baseUrl: that._serviceUrl + 'logout',
64
- token: that.getToken()
65
- },
66
- successCb: function (data) {
67
- that.setToken(null);
68
- if (typeof success === 'function')
69
- success(data);
70
- },
71
- failureCb: failure
72
- });
73
- request._execute();
74
- }
75
-
76
-
77
- /**
78
- * Sets the authentication token.
79
- * @memberOf Authentication
80
- * @instance
81
- * @param {string} token - The token, which will be used for authentication.
82
- */
83
- setToken(token: any) {
84
- this._token = token;
85
- }
86
-
87
- /**
88
- * Gets the authentication token.
89
- * @memberOf Authentication
90
- * @instance
91
- * @returns {string}
92
- */
93
- getToken() {
94
- return this._token;
95
- }
96
- }
@@ -1,5 +0,0 @@
1
- const contentTypes = {
2
- json: "application/json"
3
- }
4
-
5
- export default contentTypes;
package/src/Headers.ts DELETED
@@ -1,12 +0,0 @@
1
- export var headerNames = {
2
- contentType: "Content-Type",
3
- authorization: "Authorization",
4
- contentEncoding: "Content-Encoding",
5
-
6
- operation: "X-Operation",
7
- properties: "X-Sf-Properties",
8
- fileName: "X-File-Name",
9
- serviceRequest: "X-SF-Service-Request",
10
- choicesBinaryRepresentation: "X-SF-Binary-Choice-Representation",
11
- integrationMode: "X-SF-Integration-Mode"
12
- }
@@ -1,9 +0,0 @@
1
- const methods = {
2
- Get: "GET",
3
- Put: "PUT",
4
- Post: "POST",
5
- Patch: "PATCH",
6
- Delete: "DELETE"
7
- };
8
-
9
- export default methods;
package/src/main.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Sitefinity } from "./Sitefinity";
2
- module.exports = Sitefinity;
package/version.txt DELETED
@@ -1 +0,0 @@
1
- 0.3.0