@progress/sitefinity-webservices-sdk 0.3.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc.js +19 -0
- package/ci/pipelines/ci.yml +219 -0
- package/config/helpers.js +0 -6
- package/config/webpack.common.js +1 -3
- package/config/webpack.dev.js +2 -9
- package/config/webpack.prod.js +5 -6
- package/dist/docs/.nojekyll +1 -0
- package/dist/docs/assets/highlight.css +57 -0
- package/dist/docs/assets/icons.css +1043 -0
- package/dist/docs/assets/icons.png +0 -0
- package/dist/docs/assets/icons@2x.png +0 -0
- package/dist/docs/assets/main.js +52 -0
- package/dist/docs/assets/search.js +1 -0
- package/dist/docs/assets/style.css +1413 -0
- package/dist/docs/assets/{images/widgets.png → widgets.png} +0 -0
- package/dist/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/dist/docs/classes/BlobBuilder.BlobBuilder-1.html +7 -0
- package/dist/docs/classes/Data.Data-1.html +65 -0
- package/dist/docs/classes/Expression.BinaryExpression.html +1 -0
- package/dist/docs/classes/Expression.ComplexExpression.html +1 -0
- package/dist/docs/classes/Expression.ExpressionBase.html +1 -0
- package/dist/docs/classes/OrderProperty.OrderProperty-1.html +1 -0
- package/dist/docs/classes/Query.Query-1.html +33 -0
- package/dist/docs/classes/QueryBase.QueryBase-1.html +7 -0
- package/dist/docs/classes/QueryBuilder.QueryBuilder-1.html +1 -0
- package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +17 -0
- package/dist/docs/classes/Requests_BatchRequest.Transaction.html +17 -0
- package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.CreateRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.UpdateRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.UploadRequest.html +1 -0
- package/dist/docs/classes/Requests_RequestBase.RequestBase.html +1 -0
- package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +1 -0
- package/dist/docs/classes/Sitefinity.Sitefinity-1.html +5 -0
- package/dist/docs/classes/WhereQuery.WhereQuery-1.html +31 -0
- package/dist/docs/classes/utils.utils-1.html +1 -0
- package/dist/docs/index.html +54 -242
- package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.CreateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.OperationsRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.PropertyRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.RequestOptionsBase.html +1 -0
- package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.UpdateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.UploadRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +5 -0
- package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +1 -0
- package/dist/docs/interfaces/Sitefinity.SDKOptions.html +9 -0
- package/dist/docs/interfaces/Sitefinity.Token.html +1 -0
- package/dist/docs/interfaces/Sitefinity.TypeOptions.html +13 -0
- package/dist/docs/modules/BlobBuilder.html +1 -0
- package/dist/docs/modules/Data.html +1 -0
- package/dist/docs/modules/Expression.html +1 -0
- package/dist/docs/modules/OrderProperty.html +1 -0
- package/dist/docs/modules/Query.html +1 -0
- package/dist/docs/modules/QueryBase.html +1 -0
- package/dist/docs/modules/QueryBuilder.html +1 -0
- package/dist/docs/modules/Requests_BatchRequest.html +1 -0
- package/dist/docs/modules/Requests_ExecutableRequest.html +1 -0
- package/dist/docs/modules/Requests_Request.html +1 -0
- package/dist/docs/modules/Requests_RequestBase.html +1 -0
- package/dist/docs/modules/Requests_RequestFactory.html +1 -0
- package/dist/docs/modules/Sitefinity.html +1 -0
- package/dist/docs/modules/WhereQuery.html +1 -0
- package/dist/docs/modules/constants.html +1 -0
- package/dist/docs/modules/utils.html +1 -0
- package/dist/docs/modules.html +1 -0
- package/dist/samples.html +33 -81
- package/dist/sitefinity-webservices-sdk.d.ts +16 -0
- package/dist/sitefinity-webservices-sdk.js +1139 -1738
- package/dist/sitefinity-webservices-sdk.js.map +1 -1
- package/dist/sitefinity-webservices-sdk.min.js +2 -16
- package/dist/sitefinity-webservices-sdk.min.js.LICENSE.txt +14 -0
- package/dist/src/BlobBuilder.d.ts +14 -0
- package/dist/src/Data.d.ts +144 -0
- package/dist/src/Expression.d.ts +19 -0
- package/dist/src/OrderProperty.d.ts +8 -0
- package/dist/src/Query.d.ts +59 -0
- package/dist/src/QueryBase.d.ts +18 -0
- package/dist/src/QueryBuilder.d.ts +13 -0
- package/dist/src/Requests/BatchRequest.d.ts +146 -0
- package/dist/src/Requests/ExecutableRequest.d.ts +20 -0
- package/dist/src/Requests/Request.d.ts +88 -0
- package/dist/src/Requests/RequestBase.d.ts +28 -0
- package/dist/src/Requests/RequestFactory.d.ts +22 -0
- package/dist/src/Sitefinity.d.ts +66 -0
- package/dist/src/WhereQuery.d.ts +68 -0
- package/dist/src/constants.d.ts +55 -0
- package/dist/src/utils.d.ts +16 -0
- package/karma.conf.js +29 -0
- package/package-lock.json +16108 -6805
- package/package.json +28 -10
- package/sitefinity-webservices-sdk.ts +16 -0
- package/src/BlobBuilder.ts +7 -12
- package/src/Data.spec.ts +160 -0
- package/src/Data.ts +132 -207
- package/src/Expression.ts +0 -1
- package/src/OrderProperty.ts +4 -5
- package/src/Query.ts +52 -78
- package/src/QueryBase.ts +21 -47
- package/src/QueryBuilder.ts +64 -82
- package/src/Requests/BatchRequest.ts +312 -335
- package/src/Requests/ExecutableRequest.ts +46 -73
- package/src/Requests/Request.ts +134 -260
- package/src/Requests/RequestBase.ts +161 -0
- package/src/Requests/RequestFactory.ts +36 -54
- package/src/Requests/request.spec.ts +108 -0
- package/src/Sitefinity.spec.ts +451 -0
- package/src/Sitefinity.ts +77 -146
- package/src/WhereQuery.ts +52 -112
- package/src/constants.ts +58 -39
- package/src/utils.ts +16 -16
- package/template.html +33 -35
- package/tsconfig.json +8 -1
- package/version.txt +1 -1
- package/config/html.conf.json +0 -5
- package/dist/docs/assets/css/main.css +0 -865
- package/dist/docs/assets/css/main.css.map +0 -7
- package/dist/docs/assets/images/icons.png +0 -0
- package/dist/docs/assets/images/icons@2x.png +0 -0
- package/dist/docs/assets/js/main.js +0 -5
- package/dist/docs/assets/js/search.js +0 -3
- package/dist/docs/classes/_authentication_.authentication.html +0 -527
- package/dist/docs/classes/_blobbuilder_.blobbuilder.html +0 -351
- package/dist/docs/classes/_data_.data.html +0 -974
- package/dist/docs/classes/_expression_.binaryexpression.html +0 -450
- package/dist/docs/classes/_expression_.complexexpression.html +0 -374
- package/dist/docs/classes/_expression_.expressionbase.html +0 -336
- package/dist/docs/classes/_orderproperty_.orderproperty.html +0 -381
- package/dist/docs/classes/_query_.query.html +0 -896
- package/dist/docs/classes/_querybase_.querybase.html +0 -518
- package/dist/docs/classes/_querybuilder_.querybuilder.html +0 -496
- package/dist/docs/classes/_requests_batchrequest_.batchrequest.html +0 -1511
- package/dist/docs/classes/_requests_batchrequest_.transaction.html +0 -804
- package/dist/docs/classes/_requests_executablerequest_.executablerequest.html +0 -549
- package/dist/docs/classes/_requests_request_.createrelatedrequest.html +0 -689
- package/dist/docs/classes/_requests_request_.createrequest.html +0 -680
- package/dist/docs/classes/_requests_request_.deleterelatedbyidrequest.html +0 -687
- package/dist/docs/classes/_requests_request_.deleterelatedrequest.html +0 -673
- package/dist/docs/classes/_requests_request_.deleterequest.html +0 -666
- package/dist/docs/classes/_requests_request_.getbyidrequest.html +0 -666
- package/dist/docs/classes/_requests_request_.getrelatedbyidrequest.html +0 -687
- package/dist/docs/classes/_requests_request_.getrelatedrequest.html +0 -673
- package/dist/docs/classes/_requests_request_.getrequest.html +0 -658
- package/dist/docs/classes/_requests_request_.requestbase.html +0 -687
- package/dist/docs/classes/_requests_request_.updaterequest.html +0 -686
- package/dist/docs/classes/_requests_request_.uploadrequest.html +0 -715
- package/dist/docs/classes/_requests_requestfactory_.requestfactory.html +0 -724
- package/dist/docs/classes/_sitefinity_.sitefinity.html +0 -521
- package/dist/docs/classes/_utils_.utils.html +0 -597
- package/dist/docs/classes/_wherequery_.wherequery.html +0 -992
- package/dist/docs/globals.html +0 -238
- package/dist/docs/modules/_authentication_.html +0 -225
- package/dist/docs/modules/_blobbuilder_.html +0 -225
- package/dist/docs/modules/_constants_.html +0 -528
- package/dist/docs/modules/_contenttypes_.html +0 -248
- package/dist/docs/modules/_data_.html +0 -225
- package/dist/docs/modules/_expression_.html +0 -233
- package/dist/docs/modules/_headers_.html +0 -328
- package/dist/docs/modules/_httpmethods_.html +0 -288
- package/dist/docs/modules/_main_.html +0 -209
- package/dist/docs/modules/_orderproperty_.html +0 -225
- package/dist/docs/modules/_query_.html +0 -225
- package/dist/docs/modules/_querybase_.html +0 -225
- package/dist/docs/modules/_querybuilder_.html +0 -247
- package/dist/docs/modules/_requests_batchrequest_.html +0 -265
- package/dist/docs/modules/_requests_executablerequest_.html +0 -296
- package/dist/docs/modules/_requests_request_.html +0 -333
- package/dist/docs/modules/_requests_requestfactory_.html +0 -247
- package/dist/docs/modules/_sitefinity_.html +0 -225
- package/dist/docs/modules/_utils_.html +0 -225
- package/dist/docs/modules/_wherequery_.html +0 -247
- package/dist/index.html +0 -474
- package/src/Authentication.ts +0 -96
- package/src/ContentTypes.ts +0 -5
- package/src/Headers.ts +0 -12
- package/src/HttpMethods.ts +0 -9
- package/src/main.ts +0 -2
package/src/Sitefinity.ts
CHANGED
|
@@ -1,183 +1,114 @@
|
|
|
1
1
|
import { RequestFactory } from './Requests/RequestFactory';
|
|
2
|
-
import { Authentication } from './Authentication';
|
|
3
2
|
import { Data } from './Data';
|
|
4
3
|
import { Query } from './Query';
|
|
5
4
|
import { utils } from './utils';
|
|
5
|
+
import { ResponseHandlers } from "./Requests/ExecutableRequest";
|
|
6
|
+
import { BatchRequest } from "./Requests/BatchRequest";
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
* @class Sitefinity
|
|
9
|
-
* @classdesc The constructor of the Sitefinity JavaScript SDK. This is the entry point for the SDK.
|
|
10
|
-
* @property {Object} authentication - The authentication object used for authenticating to Sitefinity. See {@link Authentication}
|
|
11
|
-
* @param {object} options - An object containing configuration options for the Setup object.
|
|
12
|
-
* @param {string} options.serviceUrl - Your service url that points to the configured instance of Sitefinity service.
|
|
13
|
-
* @param {string} options.siteId - The ID of the site, for which the query will be executed.
|
|
14
|
-
* @param {string} options.handlers - The global handlers for request execution
|
|
15
|
-
* @param {string} options.handlers.successCb - The success handler.
|
|
16
|
-
* @param {string} options.handlers.failureCb - The failure handler.
|
|
17
|
-
*/
|
|
18
8
|
export class Sitefinity {
|
|
9
|
+
public static Query: typeof Query = Query;
|
|
10
|
+
|
|
19
11
|
private factory: RequestFactory;
|
|
20
|
-
private
|
|
21
|
-
private profileUrl: string;
|
|
12
|
+
private baseUrl: string;
|
|
22
13
|
private siteId: string;
|
|
23
|
-
public static Query: typeof Query = Query;
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The constructor of the Sitefinity JavaScript SDK. This is the entry point for the SDK.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: SDKOptions) {
|
|
19
|
+
this.baseUrl = options.baseUrl;
|
|
27
20
|
this.siteId = options.siteId;
|
|
28
|
-
this.factory = new RequestFactory(
|
|
29
|
-
handlers: options.handlers,
|
|
30
|
-
enableUnlimitedChoices: options.enableUnlimitedChoices,
|
|
31
|
-
integrationMode: options.integrationMode
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
this.authentication = new Authentication({
|
|
35
|
-
serviceUrl: this.profileUrl,
|
|
36
|
-
factory: this.factory
|
|
37
|
-
});
|
|
21
|
+
this.factory = new RequestFactory(options);
|
|
38
22
|
}
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* @param {string} [options.providerName] - The name of the provider. If empty the default provider for the site will be used.
|
|
47
|
-
* @param {string} [options.cultureName] - The name of the culture. If empty the default culture for the site will be used.
|
|
48
|
-
* @example
|
|
49
|
-
* var data = sf.data({
|
|
50
|
-
* urlName: "newsitems",
|
|
51
|
-
* providerName: "OpenAccessDataProvider",
|
|
52
|
-
* cultureName: "en"
|
|
53
|
-
* });
|
|
54
|
-
* @returns {Data}
|
|
55
|
-
*/
|
|
56
|
-
data(options: any) {
|
|
57
|
-
var optionsServiceUrl = options.serviceUrl ? utils.addTrailingSlash(options.serviceUrl) : options.serviceUrl;
|
|
58
|
-
var dataOptions = {
|
|
59
|
-
baseUrl: optionsServiceUrl || this.profileUrl,
|
|
60
|
-
SFParams: {
|
|
61
|
-
provider: options.providerName,
|
|
62
|
-
culture: options.cultureName,
|
|
63
|
-
siteId: options.siteId || this.siteId
|
|
64
|
-
},
|
|
24
|
+
data(options: TypeOptions): Data {
|
|
25
|
+
const urlOptions: TypeOptions = {
|
|
26
|
+
baseUrl: utils.addTrailingSlash(options.baseUrl || this.baseUrl),
|
|
27
|
+
provider: options.provider,
|
|
28
|
+
culture: options.culture,
|
|
29
|
+
siteId: options.siteId || this.siteId,
|
|
65
30
|
additionalQueryParams: options.additionalQueryParams,
|
|
66
|
-
entitySet: options.
|
|
31
|
+
entitySet: options.entitySet
|
|
67
32
|
}
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
return new Data(dataOptions, this.factory);
|
|
34
|
+
return new Data(urlOptions, this.factory);
|
|
71
35
|
}
|
|
72
36
|
|
|
73
|
-
|
|
74
|
-
* Creates a new {@link BatchRequest} class. OData batch requests -> {@link http://docs.oasis-open.org/odata/odata/v4.0/os/part1-protocol/odata-v4.0-os-part1-protocol.html#_Toc372793748}
|
|
75
|
-
* @memberOf Sitefinity
|
|
76
|
-
* @instance
|
|
77
|
-
* @param {Function} success - The success callback of the batch execution.
|
|
78
|
-
* @param {string} options.urlName - The URL name of the type..
|
|
79
|
-
* @param {string} [options.providerName] - The name of the provider. If empty the default provider for the site will be used.
|
|
80
|
-
* @param {string} [options.cultureName] - The name of the culture. If empty the default culture for the site will be used.
|
|
81
|
-
* @example
|
|
82
|
-
* var sf = new Sitefinity({
|
|
83
|
-
* serviceUrl: 'http://mydomain/route/service/'
|
|
84
|
-
* });
|
|
85
|
-
*
|
|
86
|
-
* var batch = sf.batch(successCbBatch, failureCb);
|
|
87
|
-
* batch.get({
|
|
88
|
-
* entitySet: entitySet,
|
|
89
|
-
* query: query8
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* var transaction = batch.beginTransaction();
|
|
93
|
-
* var createId = transaction.create({
|
|
94
|
-
* entitySet: entitySet,
|
|
95
|
-
* data: newsItem
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* batch.endTransaction(transaction);
|
|
99
|
-
*
|
|
100
|
-
* var transaction2 = batch.beginTransaction();
|
|
101
|
-
* var createId2 = transaction2.create({
|
|
102
|
-
* entitySet: entitySet,
|
|
103
|
-
* data: newsItem
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
106
|
-
* var updateId2 = transaction2.update({
|
|
107
|
-
* entitySet: entitySet,
|
|
108
|
-
* key: createId2,
|
|
109
|
-
* data: newsItemUpdate
|
|
110
|
-
* });
|
|
111
|
-
*
|
|
112
|
-
* batch.endTransaction(transaction2);
|
|
113
|
-
*
|
|
114
|
-
* batch.get({
|
|
115
|
-
* entitySet: entitySet
|
|
116
|
-
* });
|
|
117
|
-
*
|
|
118
|
-
* batch.execute();
|
|
119
|
-
* @returns {BatchRequest}
|
|
120
|
-
*/
|
|
121
|
-
batch(success: any, failure: any, progress: any, options: any) {
|
|
122
|
-
if (typeof progress !== 'function') {
|
|
123
|
-
options = progress;
|
|
124
|
-
progress = null;
|
|
125
|
-
}
|
|
126
|
-
|
|
37
|
+
batch(success?: Function, failure?: Function, progress?: Function, options?: TypeOptions): BatchRequest {
|
|
127
38
|
if (!options)
|
|
128
39
|
options = {};
|
|
129
40
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var optionsServiceUrl = options.serviceUrl ? utils.addTrailingSlash(options.serviceUrl) : options.serviceUrl;
|
|
133
|
-
var batch = this.factory.batch({
|
|
41
|
+
const batch = this.factory.batch({
|
|
134
42
|
successCb: success,
|
|
135
43
|
failureCb: failure,
|
|
136
44
|
progressCb: progress,
|
|
137
45
|
urlOptions: {
|
|
138
|
-
baseUrl:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
siteId: options.siteId || this.siteId
|
|
143
|
-
},
|
|
46
|
+
baseUrl: utils.addTrailingSlash(options.baseUrl || this.baseUrl),
|
|
47
|
+
provider: options.provider,
|
|
48
|
+
culture: options.culture,
|
|
49
|
+
siteId: options.siteId || this.siteId,
|
|
144
50
|
additionalQueryParams: options.additionalQueryParams
|
|
145
51
|
}
|
|
146
52
|
});
|
|
147
53
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return batch.beginTransaction();
|
|
151
|
-
}
|
|
54
|
+
return batch;
|
|
55
|
+
}
|
|
152
56
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Sets the authentication token.
|
|
59
|
+
*/
|
|
60
|
+
setToken(token: Token) {
|
|
61
|
+
this.factory.token = token;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
156
64
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
65
|
+
interface OptionsBase {
|
|
66
|
+
/**
|
|
67
|
+
* Your service url that points to the configured instance of Sitefinity service.
|
|
68
|
+
*/
|
|
69
|
+
baseUrl?: string;
|
|
160
70
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
71
|
+
/**
|
|
72
|
+
* The ID of the site, for which the queries will be executed.
|
|
73
|
+
*/
|
|
74
|
+
siteId?: string;
|
|
75
|
+
}
|
|
164
76
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Defines an object containing configuration options for the SDK object.
|
|
79
|
+
*/
|
|
80
|
+
export interface SDKOptions extends OptionsBase {
|
|
81
|
+
/**
|
|
82
|
+
* The global handlers for request execution
|
|
83
|
+
*/
|
|
84
|
+
handlers?: ResponseHandlers;
|
|
168
85
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
86
|
+
enableUnlimitedChoices?: boolean;
|
|
87
|
+
integrationMode?: boolean;
|
|
88
|
+
}
|
|
172
89
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Defines an object containing configuration options related to a specific type.
|
|
92
|
+
*/
|
|
93
|
+
export interface TypeOptions extends OptionsBase {
|
|
94
|
+
/**
|
|
95
|
+
* The URL name of the type.
|
|
96
|
+
*/
|
|
97
|
+
entitySet?: string;
|
|
176
98
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The name of the provider. If empty the default provider for the site will be used.
|
|
101
|
+
*/
|
|
102
|
+
provider?: string;
|
|
180
103
|
|
|
181
|
-
|
|
182
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The name of the culture. If empty the default culture for the site will be used.
|
|
106
|
+
*/
|
|
107
|
+
culture?: string;
|
|
108
|
+
additionalQueryParams?: { [key: string]: string };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface Token {
|
|
112
|
+
type: string;
|
|
113
|
+
value: string;
|
|
183
114
|
}
|
package/src/WhereQuery.ts
CHANGED
|
@@ -1,198 +1,138 @@
|
|
|
1
1
|
import { ComplexExpression, BinaryExpression } from './Expression';
|
|
2
|
-
|
|
2
|
+
import { EXPRESSION_TYPE } from "./constants";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @class WhereQuery
|
|
7
|
-
* @protected
|
|
5
|
+
* A fluent API operation for creating a filter for a query by chaining different rules.
|
|
8
6
|
*/
|
|
9
|
-
export class WhereQuery {
|
|
10
|
-
|
|
7
|
+
export class WhereQuery<QueryType> {
|
|
11
8
|
private expression: ComplexExpression;
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
constructor(private parent: QueryType, type: string = EXPRESSION_TYPE.and) {
|
|
13
11
|
this.expression = new ComplexExpression(type, []);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Adds an `and` clause to the current condition and returns it for further chaining.
|
|
18
|
-
* @method and
|
|
19
|
-
* @memberOf WhereQuery.prototype
|
|
20
|
-
* @returns {WhereQuery}
|
|
21
16
|
*/
|
|
22
|
-
and(): WhereQuery {
|
|
23
|
-
return new WhereQuery(this,
|
|
17
|
+
and(): WhereQuery<WhereQuery<QueryType>> {
|
|
18
|
+
return new WhereQuery(this, EXPRESSION_TYPE.and);
|
|
24
19
|
}
|
|
20
|
+
|
|
25
21
|
/**
|
|
26
22
|
* Adds an `or` clause to the current condition and returns it for further chaining.
|
|
27
|
-
* @method or
|
|
28
|
-
* @memberOf WhereQuery.prototype
|
|
29
|
-
* @returns {WhereQuery}
|
|
30
23
|
*/
|
|
31
|
-
or(): WhereQuery {
|
|
32
|
-
return new WhereQuery(this,
|
|
24
|
+
or(): WhereQuery<WhereQuery<QueryType>> {
|
|
25
|
+
return new WhereQuery(this, EXPRESSION_TYPE.or);
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
29
|
* Adds an `any` clause to the current condition and returns it for further chaining.
|
|
37
|
-
* @method any
|
|
38
|
-
* @memberOf WhereQuery.prototype
|
|
39
|
-
* @returns {WhereQuery}
|
|
40
30
|
*/
|
|
41
|
-
any(): WhereQuery {
|
|
42
|
-
return new WhereQuery(this,
|
|
31
|
+
any(): WhereQuery<WhereQuery<QueryType>> {
|
|
32
|
+
return new WhereQuery(this, EXPRESSION_TYPE.any);
|
|
43
33
|
}
|
|
34
|
+
|
|
44
35
|
/**
|
|
45
36
|
* Adds a `not` clause to the current condition and returns it for further chaining.
|
|
46
|
-
* @method not
|
|
47
|
-
* @memberOf WhereQuery.prototype
|
|
48
|
-
* @returns {WhereQuery}
|
|
49
37
|
*/
|
|
50
|
-
not(): WhereQuery {
|
|
51
|
-
return new WhereQuery(this,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private _simple(type: string, parameter: string, constant: any, caseSensitive: boolean = true): WhereQuery {
|
|
55
|
-
var currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
|
|
56
|
-
var subExpressions = this.expression.getExpressions();
|
|
57
|
-
subExpressions.push(currentExpr);
|
|
58
|
-
|
|
59
|
-
if (this.expression.getType() === OperatorType.not && subExpressions.length > 1)
|
|
60
|
-
throw new Error("Invalid operators count!");
|
|
61
|
-
|
|
62
|
-
return this;
|
|
38
|
+
not(): WhereQuery<WhereQuery<QueryType>> {
|
|
39
|
+
return new WhereQuery(this, EXPRESSION_TYPE.not);
|
|
63
40
|
}
|
|
64
41
|
|
|
65
42
|
/**
|
|
66
43
|
* Adds a condition that a field must be equal to a specific value.
|
|
67
|
-
* @method eq
|
|
68
|
-
* @memberOf WhereQuery.prototype
|
|
69
|
-
* @param {string} field Field name.
|
|
70
|
-
* @param {*} value Comparison value (to which the fields must be equal).
|
|
71
|
-
* @returns {WhereQuery}
|
|
72
44
|
*/
|
|
73
|
-
eq(parameter: string, constant: any): WhereQuery {
|
|
74
|
-
return this.
|
|
45
|
+
eq(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
46
|
+
return this.simple(EXPRESSION_TYPE.eq, parameter, constant);
|
|
75
47
|
}
|
|
48
|
+
|
|
76
49
|
/**
|
|
77
50
|
* Adds a condition that a field must *not* be equal to a specific value.
|
|
78
|
-
* @method ne
|
|
79
|
-
* @memberOf WhereQuery.prototype
|
|
80
|
-
* @param {string} field Field name.
|
|
81
|
-
* @param {*} value Comparison value (to which the field must not be equal).
|
|
82
|
-
* @returns {WhereQuery}
|
|
83
51
|
*/
|
|
84
|
-
ne(parameter: string, constant: any): WhereQuery {
|
|
85
|
-
return this.
|
|
52
|
+
ne(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
53
|
+
return this.simple(EXPRESSION_TYPE.ne, parameter, constant);
|
|
86
54
|
}
|
|
55
|
+
|
|
87
56
|
/**
|
|
88
57
|
* Adds a condition that a field must be `greater than` a certain value. Applicable to Number, String, and Date fields.
|
|
89
|
-
* @method gt
|
|
90
|
-
* @memberOf WhereQuery.prototype
|
|
91
|
-
* @param {string} field Field name.
|
|
92
|
-
* @param {*} value Comparison value (that the field should be greater than).
|
|
93
|
-
* @returns {WhereQuery}
|
|
94
58
|
*/
|
|
95
59
|
gt(parameter: string, constant: any) {
|
|
96
|
-
return this.
|
|
60
|
+
return this.simple(EXPRESSION_TYPE.gt, parameter, constant);
|
|
97
61
|
}
|
|
62
|
+
|
|
98
63
|
/**
|
|
99
64
|
* Adds a condition that a field must be `greater than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
100
|
-
* @method gte
|
|
101
|
-
* @memberOf WhereQuery.prototype
|
|
102
|
-
* @param {string} field Field name.
|
|
103
|
-
* @param {*} value Comparison value (that the field should be greater than or equal to).
|
|
104
|
-
* @returns {WhereQuery}
|
|
105
65
|
*/
|
|
106
66
|
gte(parameter: string, constant: any) {
|
|
107
|
-
return this.
|
|
67
|
+
return this.simple(EXPRESSION_TYPE.ge, parameter, constant);
|
|
108
68
|
}
|
|
69
|
+
|
|
109
70
|
/**
|
|
110
71
|
* Adds a condition that a field must be `less than` a certain value. Applicable to Number, String, and Date fields.
|
|
111
|
-
* @method lt
|
|
112
|
-
* @memberOf WhereQuery.prototype
|
|
113
|
-
* @param {string} field Field name.
|
|
114
|
-
* @param {*} value Comparison value (that the field should be less than).
|
|
115
|
-
* @returns {WhereQuery}
|
|
116
72
|
*/
|
|
117
73
|
lt(parameter: string, constant: any) {
|
|
118
|
-
return this.
|
|
74
|
+
return this.simple(EXPRESSION_TYPE.lt, parameter, constant);
|
|
119
75
|
}
|
|
76
|
+
|
|
120
77
|
/**
|
|
121
78
|
* Adds a condition that a field must be `less than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
122
|
-
* @method lte
|
|
123
|
-
* @memberOf WhereQuery.prototype
|
|
124
|
-
* @param {string} field Field name.
|
|
125
|
-
* @param {*} value Comparison value (that the field should be less than or equal to).
|
|
126
|
-
* @returns {WhereQuery}
|
|
127
79
|
*/
|
|
128
80
|
lte(parameter: string, constant: any) {
|
|
129
|
-
return this.
|
|
81
|
+
return this.simple(EXPRESSION_TYPE.le, parameter, constant);
|
|
130
82
|
}
|
|
83
|
+
|
|
131
84
|
/**
|
|
132
85
|
* Adds a condition that a field value must *start* with a specified string.
|
|
133
|
-
* @method startsWith
|
|
134
|
-
* @memberOf WhereQuery.prototype
|
|
135
|
-
* @param {string} field Field name.
|
|
136
|
-
* @param {string} value The string that the field should start with.
|
|
137
|
-
* @param {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
|
|
138
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
139
|
-
* @returns {WhereQuery}
|
|
140
86
|
*/
|
|
141
|
-
startsWith(parameter: string, constant: any, caseSensitive
|
|
142
|
-
return this.
|
|
87
|
+
startsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
88
|
+
return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);
|
|
143
89
|
}
|
|
144
90
|
|
|
145
91
|
/**
|
|
146
92
|
* Adds a condition that a field value must *contain* a specified string.
|
|
147
|
-
* @method startsWith
|
|
148
|
-
* @memberOf WhereQuery.prototype
|
|
149
|
-
* @param {string} field Field name.
|
|
150
|
-
* @param {string} value The string that the field should start with.
|
|
151
|
-
* @param {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
|
|
152
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
153
|
-
* @returns {WhereQuery}
|
|
154
93
|
*/
|
|
155
|
-
contains(parameter: string, constant: any, caseSensitive
|
|
156
|
-
return this.
|
|
94
|
+
contains(parameter: string, constant: any, caseSensitive = true) {
|
|
95
|
+
return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);
|
|
157
96
|
}
|
|
158
97
|
|
|
159
98
|
/**
|
|
160
99
|
* Adds a condition that a field value must *end* with a specified string.
|
|
161
|
-
* @method endsWith
|
|
162
|
-
* @memberOf WhereQuery.prototype
|
|
163
|
-
* @param {string} field Field name.
|
|
164
|
-
* @param {string} value The string that the field should end with.
|
|
165
|
-
* @param {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
|
|
166
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
167
|
-
* @returns {WhereQuery}
|
|
168
100
|
*/
|
|
169
|
-
endsWith(parameter: string, constant: any, caseSensitive
|
|
170
|
-
return this.
|
|
101
|
+
endsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
102
|
+
return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);
|
|
171
103
|
}
|
|
172
104
|
|
|
173
105
|
/**
|
|
174
106
|
* Ends the definition of the current WhereQuery. You need to call this method in order to continue with the definition of the parent {@link QueryBase}. All other `WhereQuery` methods return the current instance of `WhereQuery` to allow chaining.
|
|
175
|
-
* @method done
|
|
176
|
-
* @memberOf WhereQuery.prototype
|
|
177
|
-
* @returns {Query}
|
|
178
107
|
*/
|
|
179
|
-
done() {
|
|
108
|
+
done(): QueryType {
|
|
180
109
|
if (this.parent instanceof WhereQuery) {
|
|
181
|
-
this.parent.
|
|
110
|
+
this.parent.addComplexExpression(this);
|
|
182
111
|
// TODO: If has and() || or() must call done() twice
|
|
183
|
-
if (this.expression.getType() ===
|
|
112
|
+
if (this.expression.getType() === EXPRESSION_TYPE.not)
|
|
184
113
|
return this.parent;
|
|
185
114
|
}
|
|
186
115
|
|
|
187
116
|
return this.parent;
|
|
188
117
|
}
|
|
189
118
|
|
|
190
|
-
|
|
119
|
+
getExpression(): ComplexExpression {
|
|
191
120
|
return this.expression;
|
|
192
121
|
}
|
|
193
122
|
|
|
194
|
-
private
|
|
195
|
-
|
|
123
|
+
private simple(type: string, parameter: string, constant: any, caseSensitive = true): WhereQuery<QueryType> {
|
|
124
|
+
const currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
|
|
125
|
+
const subExpressions = this.expression.getExpressions();
|
|
126
|
+
subExpressions.push(currentExpr);
|
|
127
|
+
|
|
128
|
+
if (this.expression.getType() === EXPRESSION_TYPE.not && subExpressions.length > 1)
|
|
129
|
+
throw new Error("Invalid operators count!");
|
|
130
|
+
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private addComplexExpression(subQuery: WhereQuery<QueryType>): void {
|
|
135
|
+
const subExpression = subQuery.getExpression();
|
|
196
136
|
this.expression.getExpressions().push(subExpression);
|
|
197
137
|
}
|
|
198
138
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,41 +1,60 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
export const EXPRESSION_TYPE = {
|
|
2
|
+
query: 1,
|
|
3
|
+
where: 100,
|
|
4
|
+
and: 'and',
|
|
5
|
+
or: 'or',
|
|
6
|
+
not: 'not',
|
|
7
|
+
eq: 'eq',
|
|
8
|
+
ne: 'ne',
|
|
9
|
+
lt: 'lt',
|
|
10
|
+
le: 'le',
|
|
11
|
+
gt: 'gt',
|
|
12
|
+
ge: 'ge',
|
|
13
|
+
any: 'any',
|
|
14
|
+
contains: 'contains',
|
|
15
|
+
startsWith: 'startsWith',
|
|
16
|
+
endsWith: 'endsWith'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ODATA_PARAMS = {
|
|
20
|
+
$filter: '$filter',
|
|
21
|
+
$select: '$select',
|
|
22
|
+
$expand: '$expand',
|
|
23
|
+
$orderby: '$orderby',
|
|
24
|
+
$skip: '$skip',
|
|
25
|
+
$top: '$top',
|
|
26
|
+
$count: '$count',
|
|
27
|
+
$search: '$search'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const SF_PARAMS = {
|
|
31
|
+
provider: 'sf_provider',
|
|
32
|
+
culture: 'sf_culture',
|
|
33
|
+
siteId: 'sf_site',
|
|
34
|
+
fallbackParams: "sf_fallback_prop_names",
|
|
35
|
+
parentId: "parentId"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const HEADER_NAMES = {
|
|
39
|
+
contentType: "Content-Type",
|
|
40
|
+
authorization: "Authorization",
|
|
41
|
+
contentEncoding: "Content-Encoding",
|
|
42
|
+
operation: "X-Operation",
|
|
43
|
+
properties: "X-Sf-Properties",
|
|
44
|
+
fileName: "X-File-Name",
|
|
45
|
+
serviceRequest: "X-SF-Service-Request",
|
|
46
|
+
choicesBinaryRepresentation: "X-SF-Binary-Choice-Representation",
|
|
47
|
+
integrationMode: "X-SF-Integration-Mode"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const HTTP_METHODS = {
|
|
51
|
+
get: "GET",
|
|
52
|
+
put: "PUT",
|
|
53
|
+
post: "POST",
|
|
54
|
+
patch: "PATCH",
|
|
55
|
+
delete: "DELETE"
|
|
39
56
|
};
|
|
40
57
|
|
|
41
|
-
export
|
|
58
|
+
export const CONTENT_TYPES = {
|
|
59
|
+
json: "application/json"
|
|
60
|
+
}
|