@wix/wix-data-items-common 1.0.52
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/README.md +8 -0
- package/dist/cjs/api/ApiClient.js +186 -0
- package/dist/cjs/api/ApiClient.js.map +1 -0
- package/dist/cjs/api/QueryBase.js +200 -0
- package/dist/cjs/api/QueryBase.js.map +1 -0
- package/dist/cjs/api/QueryValidator.js +36 -0
- package/dist/cjs/api/QueryValidator.js.map +1 -0
- package/dist/cjs/api/WixDataAggregate.js +4 -0
- package/dist/cjs/api/WixDataAggregate.js.map +1 -0
- package/dist/cjs/api/WixDataApi.js +800 -0
- package/dist/cjs/api/WixDataApi.js.map +1 -0
- package/dist/cjs/api/WixDataFilter.js +2 -0
- package/dist/cjs/api/WixDataFilter.js.map +1 -0
- package/dist/cjs/api/WixDataPatch.js +139 -0
- package/dist/cjs/api/WixDataPatch.js.map +1 -0
- package/dist/cjs/api/WixDataQuery.js +4 -0
- package/dist/cjs/api/WixDataQuery.js.map +1 -0
- package/dist/cjs/api/WixDataResult.js +4 -0
- package/dist/cjs/api/WixDataResult.js.map +1 -0
- package/dist/cjs/api/common.js +14 -0
- package/dist/cjs/api/common.js.map +1 -0
- package/dist/cjs/api/errors.js +67 -0
- package/dist/cjs/api/errors.js.map +1 -0
- package/dist/cjs/api/impl/WixDataAggregateImpl.js +193 -0
- package/dist/cjs/api/impl/WixDataAggregateImpl.js.map +1 -0
- package/dist/cjs/api/impl/WixDataQueryImpl.js +116 -0
- package/dist/cjs/api/impl/WixDataQueryImpl.js.map +1 -0
- package/dist/cjs/api/impl/WixDataResultImpl.js +111 -0
- package/dist/cjs/api/impl/WixDataResultImpl.js.map +1 -0
- package/dist/cjs/api/index.js +32 -0
- package/dist/cjs/api/index.js.map +1 -0
- package/dist/cjs/api/types.js +2 -0
- package/dist/cjs/api/types.js.map +1 -0
- package/dist/cjs/errors/base-validator.js +92 -0
- package/dist/cjs/errors/base-validator.js.map +1 -0
- package/dist/cjs/errors/errors.js +155 -0
- package/dist/cjs/errors/errors.js.map +1 -0
- package/dist/cjs/errors/index.js +15 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/validations.js +91 -0
- package/dist/cjs/errors/validations.js.map +1 -0
- package/dist/cjs/external-types.d.js +2 -0
- package/dist/cjs/external-types.d.js.map +1 -0
- package/dist/cjs/filter/FilterTree.js +154 -0
- package/dist/cjs/filter/FilterTree.js.map +1 -0
- package/dist/cjs/filter/WithFilter.js +2 -0
- package/dist/cjs/filter/WithFilter.js.map +1 -0
- package/dist/cjs/filter/filterBuilder.js +53 -0
- package/dist/cjs/filter/filterBuilder.js.map +1 -0
- package/dist/cjs/filter/filterMixin.js +144 -0
- package/dist/cjs/filter/filterMixin.js.map +1 -0
- package/dist/cjs/filter/index.js +16 -0
- package/dist/cjs/filter/index.js.map +1 -0
- package/dist/cjs/index.js +120 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/sort/sortMixin.js +79 -0
- package/dist/cjs/sort/sortMixin.js.map +1 -0
- package/dist/cjs/test-types.d.js +2 -0
- package/dist/cjs/test-types.d.js.map +1 -0
- package/dist/cjs/types/api.js +4 -0
- package/dist/cjs/types/api.js.map +1 -0
- package/dist/cjs/types/data-item-types.js +46 -0
- package/dist/cjs/types/data-item-types.js.map +1 -0
- package/dist/cjs/types/error.js +2 -0
- package/dist/cjs/types/error.js.map +1 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/base64url.js +51 -0
- package/dist/cjs/utils/base64url.js.map +1 -0
- package/dist/cjs/utils/clone.js +21 -0
- package/dist/cjs/utils/clone.js.map +1 -0
- package/dist/cjs/utils/codec.js +64 -0
- package/dist/cjs/utils/codec.js.map +1 -0
- package/dist/cjs/utils/field-key-utils.js +18 -0
- package/dist/cjs/utils/field-key-utils.js.map +1 -0
- package/dist/cjs/utils/index.js +25 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/type-utils.js +54 -0
- package/dist/cjs/utils/type-utils.js.map +1 -0
- package/dist/esm/api/ApiClient.js +174 -0
- package/dist/esm/api/ApiClient.js.map +1 -0
- package/dist/esm/api/QueryBase.js +117 -0
- package/dist/esm/api/QueryBase.js.map +1 -0
- package/dist/esm/api/QueryValidator.js +32 -0
- package/dist/esm/api/QueryValidator.js.map +1 -0
- package/dist/esm/api/WixDataAggregate.js +2 -0
- package/dist/esm/api/WixDataAggregate.js.map +1 -0
- package/dist/esm/api/WixDataApi.js +829 -0
- package/dist/esm/api/WixDataApi.js.map +1 -0
- package/dist/esm/api/WixDataFilter.js +2 -0
- package/dist/esm/api/WixDataFilter.js.map +1 -0
- package/dist/esm/api/WixDataPatch.js +134 -0
- package/dist/esm/api/WixDataPatch.js.map +1 -0
- package/dist/esm/api/WixDataQuery.js +2 -0
- package/dist/esm/api/WixDataQuery.js.map +1 -0
- package/dist/esm/api/WixDataResult.js +2 -0
- package/dist/esm/api/WixDataResult.js.map +1 -0
- package/dist/esm/api/common.js +10 -0
- package/dist/esm/api/common.js.map +1 -0
- package/dist/esm/api/errors.js +52 -0
- package/dist/esm/api/errors.js.map +1 -0
- package/dist/esm/api/impl/WixDataAggregateImpl.js +214 -0
- package/dist/esm/api/impl/WixDataAggregateImpl.js.map +1 -0
- package/dist/esm/api/impl/WixDataQueryImpl.js +119 -0
- package/dist/esm/api/impl/WixDataQueryImpl.js.map +1 -0
- package/dist/esm/api/impl/WixDataResultImpl.js +100 -0
- package/dist/esm/api/impl/WixDataResultImpl.js.map +1 -0
- package/dist/esm/api/index.js +5 -0
- package/dist/esm/api/index.js.map +1 -0
- package/dist/esm/api/types.js +2 -0
- package/dist/esm/api/types.js.map +1 -0
- package/dist/esm/errors/base-validator.js +71 -0
- package/dist/esm/errors/base-validator.js.map +1 -0
- package/dist/esm/errors/errors.js +147 -0
- package/dist/esm/errors/errors.js.map +1 -0
- package/dist/esm/errors/index.js +5 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/errors/validations.js +114 -0
- package/dist/esm/errors/validations.js.map +1 -0
- package/dist/esm/filter/FilterTree.js +148 -0
- package/dist/esm/filter/FilterTree.js.map +1 -0
- package/dist/esm/filter/WithFilter.js +2 -0
- package/dist/esm/filter/WithFilter.js.map +1 -0
- package/dist/esm/filter/filterBuilder.js +43 -0
- package/dist/esm/filter/filterBuilder.js.map +1 -0
- package/dist/esm/filter/filterMixin.js +137 -0
- package/dist/esm/filter/filterMixin.js.map +1 -0
- package/dist/esm/filter/index.js +5 -0
- package/dist/esm/filter/index.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/sort/sortMixin.js +74 -0
- package/dist/esm/sort/sortMixin.js.map +1 -0
- package/dist/esm/types/api.js +2 -0
- package/dist/esm/types/api.js.map +1 -0
- package/dist/esm/types/data-item-types.js +35 -0
- package/dist/esm/types/data-item-types.js.map +1 -0
- package/dist/esm/types/error.js +2 -0
- package/dist/esm/types/error.js.map +1 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/base64url.js +57 -0
- package/dist/esm/utils/base64url.js.map +1 -0
- package/dist/esm/utils/clone.js +18 -0
- package/dist/esm/utils/clone.js.map +1 -0
- package/dist/esm/utils/codec.js +60 -0
- package/dist/esm/utils/codec.js.map +1 -0
- package/dist/esm/utils/field-key-utils.js +14 -0
- package/dist/esm/utils/field-key-utils.js.map +1 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/type-utils.js +40 -0
- package/dist/esm/utils/type-utils.js.map +1 -0
- package/dist/types/api/ApiClient.d.ts +30 -0
- package/dist/types/api/ApiClient.d.ts.map +1 -0
- package/dist/types/api/QueryBase.d.ts +111 -0
- package/dist/types/api/QueryBase.d.ts.map +1 -0
- package/dist/types/api/QueryValidator.d.ts +12 -0
- package/dist/types/api/QueryValidator.d.ts.map +1 -0
- package/dist/types/api/WixDataAggregate.d.ts +320 -0
- package/dist/types/api/WixDataAggregate.d.ts.map +1 -0
- package/dist/types/api/WixDataApi.d.ts +52 -0
- package/dist/types/api/WixDataApi.d.ts.map +1 -0
- package/dist/types/api/WixDataFilter.d.ts +424 -0
- package/dist/types/api/WixDataFilter.d.ts.map +1 -0
- package/dist/types/api/WixDataPatch.d.ts +80 -0
- package/dist/types/api/WixDataPatch.d.ts.map +1 -0
- package/dist/types/api/WixDataQuery.d.ts +702 -0
- package/dist/types/api/WixDataQuery.d.ts.map +1 -0
- package/dist/types/api/WixDataResult.d.ts +144 -0
- package/dist/types/api/WixDataResult.d.ts.map +1 -0
- package/dist/types/api/common.d.ts +3 -0
- package/dist/types/api/common.d.ts.map +1 -0
- package/dist/types/api/errors.d.ts +12 -0
- package/dist/types/api/errors.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataAggregateImpl.d.ts +76 -0
- package/dist/types/api/impl/WixDataAggregateImpl.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataQueryImpl.d.ts +72 -0
- package/dist/types/api/impl/WixDataQueryImpl.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataResultImpl.d.ts +34 -0
- package/dist/types/api/impl/WixDataResultImpl.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +11 -0
- package/dist/types/api/index.d.ts.map +1 -0
- package/dist/types/api/types.d.ts +163 -0
- package/dist/types/api/types.d.ts.map +1 -0
- package/dist/types/errors/base-validator.d.ts +28 -0
- package/dist/types/errors/base-validator.d.ts.map +1 -0
- package/dist/types/errors/errors.d.ts +108 -0
- package/dist/types/errors/errors.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +5 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/validations.d.ts +25 -0
- package/dist/types/errors/validations.d.ts.map +1 -0
- package/dist/types/filter/FilterTree.d.ts +56 -0
- package/dist/types/filter/FilterTree.d.ts.map +1 -0
- package/dist/types/filter/WithFilter.d.ts +470 -0
- package/dist/types/filter/WithFilter.d.ts.map +1 -0
- package/dist/types/filter/filterBuilder.d.ts +105 -0
- package/dist/types/filter/filterBuilder.d.ts.map +1 -0
- package/dist/types/filter/filterMixin.d.ts +61 -0
- package/dist/types/filter/filterMixin.d.ts.map +1 -0
- package/dist/types/filter/index.d.ts +8 -0
- package/dist/types/filter/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sort/sortMixin.d.ts +46 -0
- package/dist/types/sort/sortMixin.d.ts.map +1 -0
- package/dist/types/types/api.d.ts +36 -0
- package/dist/types/types/api.d.ts.map +1 -0
- package/dist/types/types/data-item-types.d.ts +1448 -0
- package/dist/types/types/data-item-types.d.ts.map +1 -0
- package/dist/types/types/error.d.ts +23 -0
- package/dist/types/types/error.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/base64url.d.ts +2 -0
- package/dist/types/utils/base64url.d.ts.map +1 -0
- package/dist/types/utils/clone.d.ts +2 -0
- package/dist/types/utils/clone.d.ts.map +1 -0
- package/dist/types/utils/codec.d.ts +3 -0
- package/dist/types/utils/codec.d.ts.map +1 -0
- package/dist/types/utils/field-key-utils.d.ts +2 -0
- package/dist/types/utils/field-key-utils.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/type-utils.d.ts +11 -0
- package/dist/types/utils/type-utils.d.ts.map +1 -0
- package/package.json +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# wix-data-items-common
|
|
2
|
+
|
|
3
|
+
Library flow package generated with Yoshi.
|
|
4
|
+
|
|
5
|
+
## Useful URLs
|
|
6
|
+
|
|
7
|
+
- [Yoshi Library Flow Docs](https://bo.wix.com/pages/yoshi/docs/library-flow/overview)
|
|
8
|
+
- [Falcon Packages Guide Docs](https://dev.wix.com/docs/rnd-general/devex/falcon/guide/packages)
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.ApiClient = void 0;
|
|
6
|
+
exports.apiRequestInterceptor = apiRequestInterceptor;
|
|
7
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _errors = require("../errors");
|
|
10
|
+
var _errors2 = require("./errors");
|
|
11
|
+
const SUPPORTS_GET_METHOD = {
|
|
12
|
+
'com.wixpress.cloud.data.api.data.DataItemService.QueryDataItems': true
|
|
13
|
+
};
|
|
14
|
+
function apiRequestInterceptor(allowGet) {
|
|
15
|
+
return request => {
|
|
16
|
+
const preferGet = allowGet && SUPPORTS_GET_METHOD[request.methodFqn ?? ''];
|
|
17
|
+
const data = (0, _utils.encode)(request.data);
|
|
18
|
+
if (preferGet) {
|
|
19
|
+
// https://github.com/wix-private/server-infra/tree/master/framework/grpc/rest#complex-requests-messages-with-get-mappings
|
|
20
|
+
const url = `${request.url}?.r=${(0, _utils.base64url)(data)}`;
|
|
21
|
+
if (url.length <= 2048) {
|
|
22
|
+
return {
|
|
23
|
+
...request,
|
|
24
|
+
method: 'GET',
|
|
25
|
+
url,
|
|
26
|
+
data: undefined
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...request,
|
|
32
|
+
data
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
class ApiClient {
|
|
37
|
+
constructor(clientFactory, allowGet) {
|
|
38
|
+
(0, _defineProperty2.default)(this, "httpApiClient", void 0);
|
|
39
|
+
this.httpApiClient = clientFactory(apiRequestInterceptor(allowGet));
|
|
40
|
+
}
|
|
41
|
+
async getDataItem(r) {
|
|
42
|
+
return this.withErrorHandling(async () => {
|
|
43
|
+
const response = await this.httpApiClient.getDataItem(r);
|
|
44
|
+
return (0, _utils.decode)(response.data);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async insertDataItem(r) {
|
|
48
|
+
return this.withErrorHandling(async () => {
|
|
49
|
+
const response = await this.httpApiClient.insertDataItem(r);
|
|
50
|
+
return (0, _utils.decode)(response.data);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async saveDataItem(r) {
|
|
54
|
+
return this.withErrorHandling(async () => {
|
|
55
|
+
const response = await this.httpApiClient.saveDataItem(r);
|
|
56
|
+
return (0, _utils.decode)(response.data);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async updateDataItem(r) {
|
|
60
|
+
return this.withErrorHandling(async () => {
|
|
61
|
+
const response = await this.httpApiClient.updateDataItem(r);
|
|
62
|
+
return (0, _utils.decode)(response.data);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async patchDataItem(r) {
|
|
66
|
+
return this.withErrorHandling(async () => {
|
|
67
|
+
const response = await this.httpApiClient.patchDataItem(r);
|
|
68
|
+
return (0, _utils.decode)(response.data);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async bulkPatchDataItems(r) {
|
|
72
|
+
return this.withErrorHandling(async () => {
|
|
73
|
+
const response = await this.httpApiClient.bulkPatchDataItems(r);
|
|
74
|
+
return (0, _utils.decode)(response.data);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async removeDataItem(r) {
|
|
78
|
+
return this.withErrorHandling(async () => {
|
|
79
|
+
const response = await this.httpApiClient.removeDataItem(r);
|
|
80
|
+
return (0, _utils.decode)(response.data);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async countDataItems(r) {
|
|
84
|
+
return this.withErrorHandling(async () => {
|
|
85
|
+
const response = await this.httpApiClient.countDataItems(r);
|
|
86
|
+
return (0, _utils.decode)(response.data);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async queryDistinctValues(r) {
|
|
90
|
+
return this.withErrorHandling(async () => {
|
|
91
|
+
const response = await this.httpApiClient.queryDistinctValues(r);
|
|
92
|
+
return (0, _utils.decode)(response.data);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async queryDataItems(r) {
|
|
96
|
+
return this.withErrorHandling(async () => {
|
|
97
|
+
const response = await this.httpApiClient.queryDataItems(r);
|
|
98
|
+
return (0, _utils.decode)(response.data);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async aggregateDataItems(r) {
|
|
102
|
+
return this.withErrorHandling(async () => {
|
|
103
|
+
const response = await this.httpApiClient.aggregateDataItems(r);
|
|
104
|
+
return (0, _utils.decode)(response.data);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async bulkInsertDataItems(r) {
|
|
108
|
+
return this.withErrorHandling(async () => {
|
|
109
|
+
const response = await this.httpApiClient.bulkInsertDataItems(r);
|
|
110
|
+
return (0, _utils.decode)(response.data);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async bulkUpdateDataItems(r) {
|
|
114
|
+
return this.withErrorHandling(async () => {
|
|
115
|
+
const response = await this.httpApiClient.bulkUpdateDataItems(r);
|
|
116
|
+
return (0, _utils.decode)(response.data);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async bulkSaveDataItems(r) {
|
|
120
|
+
return this.withErrorHandling(async () => {
|
|
121
|
+
const response = await this.httpApiClient.bulkSaveDataItems(r);
|
|
122
|
+
return (0, _utils.decode)(response.data);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async bulkRemoveDataItems(r) {
|
|
126
|
+
return this.withErrorHandling(async () => {
|
|
127
|
+
const response = await this.httpApiClient.bulkRemoveDataItems(r);
|
|
128
|
+
return (0, _utils.decode)(response.data);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async queryReferencedDataItems(r) {
|
|
132
|
+
return this.withErrorHandling(async () => {
|
|
133
|
+
const response = await this.httpApiClient.queryReferencedDataItems(r);
|
|
134
|
+
return (0, _utils.decode)(response.data);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async bulkInsertDataItemReferences(r) {
|
|
138
|
+
return this.withErrorHandling(async () => {
|
|
139
|
+
const response = await this.httpApiClient.bulkInsertDataItemReferences(r);
|
|
140
|
+
return (0, _utils.decode)(response.data);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async replaceDataItemReferences(r) {
|
|
144
|
+
return this.withErrorHandling(async () => {
|
|
145
|
+
const response = await this.httpApiClient.replaceDataItemReferences(r);
|
|
146
|
+
return (0, _utils.decode)(response.data);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async bulkRemoveDataItemReferences(r) {
|
|
150
|
+
return this.withErrorHandling(async () => {
|
|
151
|
+
const response = await this.httpApiClient.bulkRemoveDataItemReferences(r);
|
|
152
|
+
return (0, _utils.decode)(response.data);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async isReferencedDataItem(r) {
|
|
156
|
+
return this.withErrorHandling(async () => {
|
|
157
|
+
const response = await this.httpApiClient.isReferencedDataItem(r);
|
|
158
|
+
return (0, _utils.decode)(response.data);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async truncateDataItems(r) {
|
|
162
|
+
return this.withErrorHandling(async () => {
|
|
163
|
+
const response = await this.httpApiClient.truncateDataItems(r);
|
|
164
|
+
return (0, _utils.decode)(response.data);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async withErrorHandling(call) {
|
|
168
|
+
try {
|
|
169
|
+
return await call();
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if ((0, _errors2.isHttpError)(error)) {
|
|
172
|
+
var _error$response, _error$response2;
|
|
173
|
+
if (((_error$response = error.response) == null ? void 0 : _error$response.status) === 413) {
|
|
174
|
+
throw (0, _errors.wixDataError)(_errors.messages.payloadIsTooLarge(), 'WDE0109');
|
|
175
|
+
}
|
|
176
|
+
const parsedError = (0, _errors2.parseError)((_error$response2 = error.response) == null ? void 0 : _error$response2.data);
|
|
177
|
+
if (parsedError) {
|
|
178
|
+
throw parsedError;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
throw (0, _errors.wixDataError)(_errors.messages.internalError('Unknown error.'), _errors.codes.UnknownError);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ApiClient = ApiClient;
|
|
186
|
+
//# sourceMappingURL=ApiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","_errors","_errors2","SUPPORTS_GET_METHOD","apiRequestInterceptor","allowGet","request","preferGet","methodFqn","data","serializeDates","url","base64url","length","method","undefined","ApiClient","constructor","clientFactory","_defineProperty2","default","httpApiClient","getDataItem","r","withErrorHandling","response","parseDates","insertDataItem","saveDataItem","updateDataItem","patchDataItem","bulkPatchDataItems","removeDataItem","countDataItems","queryDistinctValues","queryDataItems","aggregateDataItems","bulkInsertDataItems","bulkUpdateDataItems","bulkSaveDataItems","bulkRemoveDataItems","queryReferencedDataItems","bulkInsertDataItemReferences","replaceDataItemReferences","bulkRemoveDataItemReferences","isReferencedDataItem","truncateDataItems","call","error","isHttpError","_error$response","_error$response2","status","wixDataError","messages","payloadIsTooLarge","parsedError","parseError","internalError","codes","UnknownError","exports"],"sources":["../../../src/api/ApiClient.ts"],"sourcesContent":["import type {\n HttpApiClient,\n RequestInterceptor,\n Request,\n HttpApiClientFactory,\n} from '../types/api'\nimport {\n decode as parseDates,\n encode as serializeDates,\n base64url,\n} from '../utils'\nimport { messages, wixDataError, codes } from '../errors'\n\nimport { isHttpError, parseError } from './errors'\nimport {\n AggregateDataItemsRequest,\n AggregateDataItemsResponse,\n BulkInsertDataItemReferencesRequest,\n BulkInsertDataItemReferencesResponse,\n BulkInsertDataItemsRequest,\n BulkInsertDataItemsResponse,\n BulkPatchDataItemsRequest,\n BulkPatchDataItemsResponse,\n BulkRemoveDataItemReferencesRequest,\n BulkRemoveDataItemReferencesResponse,\n BulkRemoveDataItemsRequest,\n BulkRemoveDataItemsResponse,\n BulkSaveDataItemsRequest,\n BulkSaveDataItemsResponse,\n BulkUpdateDataItemsRequest,\n BulkUpdateDataItemsResponse,\n CountDataItemsRequest,\n CountDataItemsResponse,\n GetDataItemRequest,\n GetDataItemResponse,\n InsertDataItemRequest,\n InsertDataItemResponse,\n IsReferencedDataItemRequest,\n IsReferencedDataItemResponse,\n PatchDataItemRequest,\n PatchDataItemResponse,\n QueryDataItemsRequest,\n QueryDataItemsResponse,\n QueryDistinctValuesRequest,\n QueryDistinctValuesResponse,\n QueryReferencedDataItemsRequest,\n QueryReferencedDataItemsResponse,\n RemoveDataItemRequest,\n RemoveDataItemResponse,\n ReplaceDataItemReferencesRequest,\n ReplaceDataItemReferencesResponse,\n SaveDataItemRequest,\n SaveDataItemResponse,\n TruncateDataItemsRequest,\n TruncateDataItemsResponse,\n UpdateDataItemRequest,\n UpdateDataItemResponse,\n} from '../types/data-item-types'\n\nconst SUPPORTS_GET_METHOD: Record<string, boolean> = {\n 'com.wixpress.cloud.data.api.data.DataItemService.QueryDataItems': true,\n}\n\nexport function apiRequestInterceptor<R extends Request>(\n allowGet: boolean\n): RequestInterceptor<R> {\n return (request) => {\n const preferGet = allowGet && SUPPORTS_GET_METHOD[request.methodFqn ?? '']\n const data = serializeDates(request.data)\n if (preferGet) {\n // https://github.com/wix-private/server-infra/tree/master/framework/grpc/rest#complex-requests-messages-with-get-mappings\n const url = `${request.url}?.r=${base64url(data)}`\n if (url.length <= 2048) {\n return {\n ...request,\n method: 'GET',\n url,\n data: undefined,\n }\n }\n }\n return { ...request, data }\n }\n}\n\nexport class ApiClient {\n private httpApiClient: HttpApiClient\n\n constructor(clientFactory: HttpApiClientFactory<any>, allowGet: boolean) {\n this.httpApiClient = clientFactory(apiRequestInterceptor(allowGet))\n }\n\n async getDataItem(r: GetDataItemRequest): Promise<GetDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.getDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async insertDataItem(\n r: InsertDataItemRequest\n ): Promise<InsertDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.insertDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async saveDataItem(r: SaveDataItemRequest): Promise<SaveDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.saveDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async updateDataItem(\n r: UpdateDataItemRequest\n ): Promise<UpdateDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.updateDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async patchDataItem(r: PatchDataItemRequest): Promise<PatchDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.patchDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async bulkPatchDataItems(\n r: BulkPatchDataItemsRequest\n ): Promise<BulkPatchDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkPatchDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async removeDataItem(\n r: RemoveDataItemRequest\n ): Promise<RemoveDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.removeDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async countDataItems(\n r: CountDataItemsRequest\n ): Promise<CountDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.countDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async queryDistinctValues(\n r: QueryDistinctValuesRequest\n ): Promise<QueryDistinctValuesResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.queryDistinctValues(r)\n return parseDates(response.data)\n })\n }\n\n async queryDataItems(\n r: QueryDataItemsRequest\n ): Promise<QueryDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.queryDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async aggregateDataItems(\n r: AggregateDataItemsRequest\n ): Promise<AggregateDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.aggregateDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async bulkInsertDataItems(\n r: BulkInsertDataItemsRequest\n ): Promise<BulkInsertDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkInsertDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async bulkUpdateDataItems(\n r: BulkUpdateDataItemsRequest\n ): Promise<BulkUpdateDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkUpdateDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async bulkSaveDataItems(\n r: BulkSaveDataItemsRequest\n ): Promise<BulkSaveDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkSaveDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async bulkRemoveDataItems(\n r: BulkRemoveDataItemsRequest\n ): Promise<BulkRemoveDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkRemoveDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async queryReferencedDataItems(\n r: QueryReferencedDataItemsRequest\n ): Promise<QueryReferencedDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.queryReferencedDataItems(r)\n return parseDates(response.data)\n })\n }\n\n async bulkInsertDataItemReferences(\n r: BulkInsertDataItemReferencesRequest\n ): Promise<BulkInsertDataItemReferencesResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkInsertDataItemReferences(r)\n return parseDates(response.data)\n })\n }\n\n async replaceDataItemReferences(\n r: ReplaceDataItemReferencesRequest\n ): Promise<ReplaceDataItemReferencesResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.replaceDataItemReferences(r)\n return parseDates(response.data)\n })\n }\n\n async bulkRemoveDataItemReferences(\n r: BulkRemoveDataItemReferencesRequest\n ): Promise<BulkRemoveDataItemReferencesResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.bulkRemoveDataItemReferences(r)\n return parseDates(response.data)\n })\n }\n\n async isReferencedDataItem(\n r: IsReferencedDataItemRequest\n ): Promise<IsReferencedDataItemResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.isReferencedDataItem(r)\n return parseDates(response.data)\n })\n }\n\n async truncateDataItems(\n r: TruncateDataItemsRequest\n ): Promise<TruncateDataItemsResponse> {\n return this.withErrorHandling(async () => {\n const response = await this.httpApiClient.truncateDataItems(r)\n return parseDates(response.data)\n })\n }\n\n private async withErrorHandling<T>(call: () => T): Promise<T> {\n try {\n return await call()\n } catch (error: unknown) {\n if (isHttpError(error)) {\n if (error.response?.status === 413) {\n throw wixDataError(messages.payloadIsTooLarge(), 'WDE0109')\n }\n const parsedError = parseError(error.response?.data)\n if (parsedError) {\n throw parsedError\n }\n }\n throw wixDataError(\n messages.internalError('Unknown error.'),\n codes.UnknownError\n )\n }\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AA8CA,MAAMG,mBAA4C,GAAG;EACnD,iEAAiE,EAAE;AACrE,CAAC;AAEM,SAASC,qBAAqBA,CACnCC,QAAiB,EACM;EACvB,OAAQC,OAAO,IAAK;IAClB,MAAMC,SAAS,GAAGF,QAAQ,IAAIF,mBAAmB,CAACG,OAAO,CAACE,SAAS,IAAI,EAAE,CAAC;IAC1E,MAAMC,IAAI,GAAG,IAAAC,aAAc,EAACJ,OAAO,CAACG,IAAI,CAAC;IACzC,IAAIF,SAAS,EAAE;MACb;MACA,MAAMI,GAAG,GAAI,GAAEL,OAAO,CAACK,GAAI,OAAM,IAAAC,gBAAS,EAACH,IAAI,CAAE,EAAC;MAClD,IAAIE,GAAG,CAACE,MAAM,IAAI,IA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IAAAC,mBAAU,GAAAN,gBAAA,GAACH,KAAK,CAACvB,QAAQ,qBAAd0B,gBAAA,CAAgB1C,IAAI,CAAC;QACpD,IAAI+C,WAAW,EAAE;UACf,MAAMA,WAAW;QACnB;MACF;MACA,MAAM,IAAAH,oBAAY,EAChBC,gBAAQ,CAACI,aAAa,CAAC,gBAAgB,CAAC,EACxCC,aAAK,CAACC,YACR,CAAC;IACH;EACF;AACF;AAACC,OAAA,CAAA7C,SAAA,GAAAA,SAAA"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.QueryBase = void 0;
|
|
6
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
|
+
var _filter = require("../filter");
|
|
8
|
+
var _sortMixin = require("../sort/sortMixin");
|
|
9
|
+
var _common = require("./common");
|
|
10
|
+
class QueryBase {
|
|
11
|
+
constructor(origin) {
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
(0, _defineProperty2.default)(this, "filterBuilder", void 0);
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
(0, _defineProperty2.default)(this, "sort", void 0);
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
(0, _defineProperty2.default)(this, "collectionName", void 0);
|
|
24
|
+
// filterMethod: WithFilter<Self>['filterMethod'] allows keeping type signature while capturing
|
|
25
|
+
// all args as an array
|
|
26
|
+
(0, _defineProperty2.default)(this, "eq", (...args) => {
|
|
27
|
+
return this.withFilter('eq', args);
|
|
28
|
+
});
|
|
29
|
+
(0, _defineProperty2.default)(this, "ne", (...args) => {
|
|
30
|
+
return this.withFilter('ne', args);
|
|
31
|
+
});
|
|
32
|
+
(0, _defineProperty2.default)(this, "ge", (...args) => {
|
|
33
|
+
return this.withFilter('ge', args);
|
|
34
|
+
});
|
|
35
|
+
(0, _defineProperty2.default)(this, "gt", (...args) => {
|
|
36
|
+
return this.withFilter('gt', args);
|
|
37
|
+
});
|
|
38
|
+
(0, _defineProperty2.default)(this, "gte", (...args) => {
|
|
39
|
+
return this.withFilter('gte', args);
|
|
40
|
+
});
|
|
41
|
+
(0, _defineProperty2.default)(this, "le", (...args) => {
|
|
42
|
+
return this.withFilter('le', args);
|
|
43
|
+
});
|
|
44
|
+
(0, _defineProperty2.default)(this, "lt", (...args) => {
|
|
45
|
+
return this.withFilter('lt', args);
|
|
46
|
+
});
|
|
47
|
+
(0, _defineProperty2.default)(this, "lte", (...args) => {
|
|
48
|
+
return this.withFilter('lte', args);
|
|
49
|
+
});
|
|
50
|
+
(0, _defineProperty2.default)(this, "isNotEmpty", (...args) => {
|
|
51
|
+
return this.withFilter('isNotEmpty', args);
|
|
52
|
+
});
|
|
53
|
+
(0, _defineProperty2.default)(this, "isEmpty", (...args) => {
|
|
54
|
+
return this.withFilter('isEmpty', args);
|
|
55
|
+
});
|
|
56
|
+
(0, _defineProperty2.default)(this, "startsWith", (...args) => {
|
|
57
|
+
return this.withFilter('startsWith', args);
|
|
58
|
+
});
|
|
59
|
+
(0, _defineProperty2.default)(this, "endsWith", (...args) => {
|
|
60
|
+
return this.withFilter('endsWith', args);
|
|
61
|
+
});
|
|
62
|
+
(0, _defineProperty2.default)(this, "contains", (...args) => {
|
|
63
|
+
return this.withFilter('contains', args);
|
|
64
|
+
});
|
|
65
|
+
(0, _defineProperty2.default)(this, "hasSome", (...args) => {
|
|
66
|
+
return this.withFilter('hasSome', args);
|
|
67
|
+
});
|
|
68
|
+
(0, _defineProperty2.default)(this, "in", (...args) => {
|
|
69
|
+
return this.withFilter('in', args);
|
|
70
|
+
});
|
|
71
|
+
(0, _defineProperty2.default)(this, "hasAll", (...args) => {
|
|
72
|
+
return this.withFilter('hasAll', args);
|
|
73
|
+
});
|
|
74
|
+
(0, _defineProperty2.default)(this, "exists", (...args) => {
|
|
75
|
+
return this.withFilter('exists', args);
|
|
76
|
+
});
|
|
77
|
+
(0, _defineProperty2.default)(this, "or", (...args) => {
|
|
78
|
+
// @ts-expect-error
|
|
79
|
+
return this.withFilter('or', args.map(this.extractFilter));
|
|
80
|
+
});
|
|
81
|
+
(0, _defineProperty2.default)(this, "and", (...args) => {
|
|
82
|
+
// @ts-expect-error
|
|
83
|
+
return this.withFilter('and', args.map(this.extractFilter));
|
|
84
|
+
});
|
|
85
|
+
(0, _defineProperty2.default)(this, "not", (...args) => {
|
|
86
|
+
// @ts-expect-error
|
|
87
|
+
return this.withFilter('not', args.map(this.extractFilter));
|
|
88
|
+
});
|
|
89
|
+
(0, _defineProperty2.default)(this, "between", (...args) => {
|
|
90
|
+
return this.withFilter('between', args);
|
|
91
|
+
});
|
|
92
|
+
this.collectionName = origin.collectionName;
|
|
93
|
+
this.filterBuilder = (origin == null ? void 0 : origin.filterBuilder) ?? (0, _common.filterBuilder)({
|
|
94
|
+
filterTree: {}
|
|
95
|
+
});
|
|
96
|
+
this.sort = (origin == null ? void 0 : origin.sort) ?? new _sortMixin.Sort();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
// --- filter ---
|
|
104
|
+
|
|
105
|
+
get filterTree() {
|
|
106
|
+
return this.filterBuilder.filterTree;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
setFilterModel(filterTree) {
|
|
113
|
+
const filter = (0, _common.filterBuilder)({
|
|
114
|
+
filterTree,
|
|
115
|
+
invalidArguments: (0, _filter.validateFilterTree)(filterTree)
|
|
116
|
+
});
|
|
117
|
+
return this.copy({
|
|
118
|
+
filterBuilder: filter
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
getFilterModel() {
|
|
126
|
+
return this.filterBuilder.build();
|
|
127
|
+
}
|
|
128
|
+
withFilter(filter, args) {
|
|
129
|
+
return this.copy({
|
|
130
|
+
filterBuilder: this.filterBuilder[filter].apply(this.filterBuilder, args)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
extractFilter(value) {
|
|
134
|
+
return value != null && value.filterBuilder ? value.filterBuilder : value;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- sort ---
|
|
138
|
+
|
|
139
|
+
get orderBy() {
|
|
140
|
+
return this.sort.orderBy;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Adds a sort to a query or sort, sorting by the specified properties in ascending order.
|
|
145
|
+
*
|
|
146
|
+
* The `ascending()` function refines this query in ascending order of the specified properties. If you specify more
|
|
147
|
+
* than one property, ascending() sorts the results in ascending order by each property in the order they are listed.
|
|
148
|
+
*
|
|
149
|
+
* You can sort the following types:
|
|
150
|
+
* - Number: Sorts numerically.
|
|
151
|
+
* - Date: Sorts by date and time.
|
|
152
|
+
* - String: Sorts lexicographically, so `"abc"` comes after `"XYZ"`.
|
|
153
|
+
* - Reference: Compares by the ID of the referenced item as a String.
|
|
154
|
+
*
|
|
155
|
+
* If a property contains a number as a String, that value will be sorted alphabetically and not numerically.
|
|
156
|
+
* Items that do not have a value for the specified sort property are ranked lowest.
|
|
157
|
+
* @public
|
|
158
|
+
* @documentationMaturity preview
|
|
159
|
+
* @param fields - The properties used in the sort.
|
|
160
|
+
* @requiredField fields
|
|
161
|
+
* @returns An object representing the refined query.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
ascending(...fields) {
|
|
165
|
+
return this.copy({
|
|
166
|
+
sort: this.sort.ascending(...fields)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Adds a sort to a query or sort, sorting by the specified properties in descending order.
|
|
172
|
+
*
|
|
173
|
+
* The `descending()` function refines this query to sort in descending order of the specified properties. If you
|
|
174
|
+
* specify more than one property, descending() sorts the results in descending order by each property in the order
|
|
175
|
+
* they are listed.
|
|
176
|
+
*
|
|
177
|
+
* You can sort the following types:
|
|
178
|
+
*
|
|
179
|
+
* Number: Sorts numerically.
|
|
180
|
+
* - Date: Sorts by date and time.
|
|
181
|
+
* - String: Sorts lexicographically, so `"abc"` comes before `"XYZ"`.
|
|
182
|
+
* - Reference: Compares by the ID of the referenced item as a String.
|
|
183
|
+
*
|
|
184
|
+
* If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items
|
|
185
|
+
* that do not have a value for the specified sort property are ranked lowest.
|
|
186
|
+
* @public
|
|
187
|
+
* @documentationMaturity preview
|
|
188
|
+
* @param fields - The properties used in the sort.
|
|
189
|
+
* @requiredField fields
|
|
190
|
+
* @returns An object representing the refined query.
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
descending(...fields) {
|
|
194
|
+
return this.copy({
|
|
195
|
+
sort: this.sort.descending(...fields)
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.QueryBase = QueryBase;
|
|
200
|
+
//# sourceMappingURL=QueryBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_filter","require","_sortMixin","_common","QueryBase","constructor","origin","_defineProperty2","default","args","withFilter","map","extractFilter","collectionName","filterBuilder","filterTree","sort","Sort","setFilterModel","filter","invalidArguments","validateFilterTree","copy","getFilterModel","build","apply","value","orderBy","ascending","fields","descending","exports"],"sources":["../../../src/api/QueryBase.ts"],"sourcesContent":["import {\n WithFilter,\n PlatformizedFilterBuilder,\n validateFilterTree,\n FilterTree,\n} from '../filter'\nimport { Sort } from '../sort/sortMixin'\nimport { filterBuilder } from './common'\n\nexport abstract class QueryBase<Self extends WithFilter<Self>>\n implements WithFilter<Self>\n{\n /**\n * @internal\n */\n protected readonly filterBuilder: PlatformizedFilterBuilder\n\n /**\n * @internal\n */\n protected readonly sort: Sort\n\n /**\n * @internal\n */\n readonly collectionName: string\n\n protected constructor(origin: {\n collectionName: string\n filterBuilder?: PlatformizedFilterBuilder\n sort?: Sort\n }) {\n this.collectionName = origin.collectionName\n this.filterBuilder =\n origin?.filterBuilder ?? filterBuilder({ filterTree: {} })\n this.sort = origin?.sort ?? new Sort()\n }\n\n /**\n * @internal\n */\n protected abstract copy(params: {\n filterBuilder?: PlatformizedFilterBuilder\n sort?: Sort\n }): Self\n\n // --- filter ---\n\n abstract get invalidArguments(): string[]\n\n get filterTree(): Record<string, any> {\n return this.filterBuilder.filterTree\n }\n\n /**\n * @internal\n */\n setFilterModel(filterTree: Record<string, any>): Self {\n const filter = filterBuilder({\n filterTree,\n invalidArguments: validateFilterTree(filterTree),\n })\n return this.copy({ filterBuilder: filter })\n }\n\n /**\n * @internal\n */\n getFilterModel(): FilterTree {\n return this.filterBuilder.build()\n }\n\n private withFilter<F extends keyof PlatformizedFilterBuilder>(\n filter: F,\n args: Parameters<PlatformizedFilterBuilder[F]>\n ): Self {\n return this.copy({\n filterBuilder: this.filterBuilder[filter].apply(this.filterBuilder, args),\n })\n }\n\n // filterMethod: WithFilter<Self>['filterMethod'] allows keeping type signature while capturing\n // all args as an array\n\n eq: WithFilter<Self>['eq'] = (...args) => {\n return this.withFilter('eq', args)\n }\n ne: WithFilter<Self>['ne'] = (...args) => {\n return this.withFilter('ne', args)\n }\n ge: WithFilter<Self>['ge'] = (...args) => {\n return this.withFilter('ge', args)\n }\n gt: WithFilter<Self>['gt'] = (...args) => {\n return this.withFilter('gt', args)\n }\n gte: WithFilter<Self>['gte'] = (...args) => {\n return this.withFilter('gte', args)\n }\n le: WithFilter<Self>['le'] = (...args) => {\n return this.withFilter('le', args)\n }\n lt: WithFilter<Self>['lt'] = (...args) => {\n return this.withFilter('lt', args)\n }\n lte: WithFilter<Self>['lte'] = (...args) => {\n return this.withFilter('lte', args)\n }\n isNotEmpty: WithFilter<Self>['isNotEmpty'] = (...args) => {\n return this.withFilter('isNotEmpty', args)\n }\n isEmpty: WithFilter<Self>['isEmpty'] = (...args) => {\n return this.withFilter('isEmpty', args)\n }\n startsWith: WithFilter<Self>['startsWith'] = (...args) => {\n return this.withFilter('startsWith', args)\n }\n endsWith: WithFilter<Self>['endsWith'] = (...args) => {\n return this.withFilter('endsWith', args)\n }\n contains: WithFilter<Self>['contains'] = (...args) => {\n return this.withFilter('contains', args)\n }\n hasSome: WithFilter<Self>['hasSome'] = (...args) => {\n return this.withFilter('hasSome', args)\n };\n in: WithFilter<Self>['in'] = (...args) => {\n return this.withFilter('in', args)\n }\n hasAll: WithFilter<Self>['hasAll'] = (...args) => {\n return this.withFilter('hasAll', args)\n }\n exists: WithFilter<Self>['exists'] = (...args) => {\n return this.withFilter('exists', args)\n }\n or: WithFilter<Self>['or'] = (...args) => {\n // @ts-expect-error\n return this.withFilter('or', args.map(this.extractFilter))\n }\n and: WithFilter<Self>['and'] = (...args) => {\n // @ts-expect-error\n return this.withFilter('and', args.map(this.extractFilter))\n }\n not: WithFilter<Self>['not'] = (...args) => {\n // @ts-expect-error\n return this.withFilter('not', args.map(this.extractFilter))\n }\n between: WithFilter<Self>['between'] = (...args) => {\n return this.withFilter('between', args)\n }\n\n private extractFilter(value: any): any {\n return value?.filterBuilder ? value.filterBuilder : value\n }\n\n // --- sort ---\n\n get orderBy(): { [field: string]: 'asc' | 'desc' }[] {\n return this.sort.orderBy\n }\n\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in ascending order.\n *\n * The `ascending()` function refines this query in ascending order of the specified properties. If you specify more\n * than one property, ascending() sorts the results in ascending order by each property in the order they are listed.\n *\n * You can sort the following types:\n * - Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes after `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n ascending(...fields: string[]): Self\n ascending(fields: string[]): Self\n\n ascending(...fields: any) {\n return this.copy({ sort: this.sort.ascending(...fields) })\n }\n\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in descending order.\n *\n * The `descending()` function refines this query to sort in descending order of the specified properties. If you\n * specify more than one property, descending() sorts the results in descending order by each property in the order\n * they are listed.\n *\n * You can sort the following types:\n *\n * Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items\n * that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n descending(...fields: string[]): Self\n descending(fields: string[]): Self\n\n descending(...fields: any) {\n return this.copy({ sort: this.sort.descending(...fields) })\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAeG,SAAS,CAE/B;EAgBYC,WAAWA,CAACC,MAIrB,EAAE;IAnBH;AACF;AACA;IAFE,IAAAC,gBAAA,CAAAC,OAAA;IAKA;AACF;AACA;IAFE,IAAAD,gBAAA,CAAAC,OAAA;IAKA;AACF;AACA;IAFE,IAAAD,gBAAA,CAAAC,OAAA;IA2DA;IACA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,cAE6B,CAAC,GAAGC,IAAI,KAAK;MACxC,OAAO,IAAI,CAACC,UAAU,CAAC,IAAI,EAAED,IAAI,CAAC;IACpC,CAAC;IAAA,IAAAF,gBAAA,CAAAC,OAAA,cAC4B,CAAC,GAAGC,IAAI,KAAK;MACxC,O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AC;MACfR,aAAa,EAAE,IAAI,CAACA,aAAa,CAACK,MAAM,CAAC,CAACM,KAAK,CAAC,IAAI,CAACX,aAAa,EAAEL,IAAI;IAC1E,CAAC,CAAC;EACJ;EAwEQG,aAAaA,CAACc,KAAU,EAAO;IACrC,OAAOA,KAAK,YAALA,KAAK,CAAEZ,aAAa,GAAGY,KAAK,CAACZ,aAAa,GAAGY,KAAK;EAC3D;;EAEA;;EAEA,IAAIC,OAAOA,CAAA,EAA0C;IACnD,OAAO,IAAI,CAACX,IAAI,CAACW,OAAO;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAIEC,SAASA,CAAC,GAAGC,MAAW,EAAE;IACxB,OAAO,IAAI,CAACP,IAAI,CAAC;MAAEN,IAAI,EAAE,IAAI,CAACA,IAAI,CAACY,SAAS,CAAC,GAAGC,MAAM;IAAE,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAIEC,UAAUA,CAAC,GAAGD,MAAW,EAAE;IACzB,OAAO,IAAI,CAACP,IAAI,CAAC;MAAEN,IAAI,EAAE,IAAI,CAACA,IAAI,CAACc,UAAU,CAAC,GAAGD,MAAM;IAAE,CAAC,CAAC;EAC7D;AACF;AAACE,OAAA,CAAA3B,SAAA,GAAAA,SAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.QueryValidator = void 0;
|
|
6
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var _errors = require("../errors");
|
|
9
|
+
const MAX_SAFE_INTEGER = 9007199254740991;
|
|
10
|
+
class QueryValidator extends _errors.AggregatingValidator {
|
|
11
|
+
constructor(operatorName, previousInvalidArguments) {
|
|
12
|
+
super(previousInvalidArguments);
|
|
13
|
+
(0, _defineProperty2.default)(this, "operatorName", void 0);
|
|
14
|
+
this.operatorName = operatorName;
|
|
15
|
+
}
|
|
16
|
+
_isNumber(specifier, operand) {
|
|
17
|
+
return this.addValidation(() => (0, _utils.isNumber)(operand), () => _errors.messages.queryValidations.isNumber(this.operatorName, specifier, operand));
|
|
18
|
+
}
|
|
19
|
+
isPositiveNumber(operand) {
|
|
20
|
+
return this._isNumber('positive', operand).addValidation(() => !Number.isNaN(operand) && operand > 0, () => _errors.messages.queryValidations.isPositiveNumber(this.operatorName, operand));
|
|
21
|
+
}
|
|
22
|
+
isNonNegativeNumber(operand) {
|
|
23
|
+
return this._isNumber('non-negative', operand).addValidation(() => !Number.isNaN(operand) && operand >= 0, () => _errors.messages.queryValidations.isNonNegativeNumber(this.operatorName, operand));
|
|
24
|
+
}
|
|
25
|
+
isInteger(operand) {
|
|
26
|
+
return this.addValidation(() => !Number.isNaN(operand) && Number.isFinite(operand) && Number.isInteger(operand) && operand < MAX_SAFE_INTEGER && operand > -MAX_SAFE_INTEGER, () => _errors.messages.queryValidations.isInteger(this.operatorName, operand));
|
|
27
|
+
}
|
|
28
|
+
notGreaterThan(operand, value) {
|
|
29
|
+
return this.addValidation(() => operand <= value, () => _errors.messages.queryValidations.notGreaterThan(this.operatorName, operand, value));
|
|
30
|
+
}
|
|
31
|
+
nonEmptyString(operand) {
|
|
32
|
+
return this.addValidation(() => typeof operand === 'string' && operand.length > 0, () => _errors.messages.queryValidations.isNonEmptyString(this.operatorName));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.QueryValidator = QueryValidator;
|
|
36
|
+
//# sourceMappingURL=QueryValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","_errors","MAX_SAFE_INTEGER","QueryValidator","AggregatingValidator","constructor","operatorName","previousInvalidArguments","_defineProperty2","default","_isNumber","specifier","operand","addValidation","isNumber","messages","queryValidations","isPositiveNumber","Number","isNaN","isNonNegativeNumber","isInteger","isFinite","notGreaterThan","value","nonEmptyString","length","isNonEmptyString","exports"],"sources":["../../../src/api/QueryValidator.ts"],"sourcesContent":["import { isNumber } from '../utils'\nimport { AggregatingValidator, messages } from '../errors'\n\nconst MAX_SAFE_INTEGER = 9007199254740991\n\nexport class QueryValidator extends AggregatingValidator {\n operatorName: any\n\n constructor(operatorName: string, previousInvalidArguments: string[]) {\n super(previousInvalidArguments)\n this.operatorName = operatorName\n }\n\n _isNumber(specifier: string, operand: any) {\n return this.addValidation(\n () => isNumber(operand),\n () =>\n messages.queryValidations.isNumber(\n this.operatorName,\n specifier,\n operand\n )\n )\n }\n\n isPositiveNumber(operand: number) {\n return this._isNumber('positive', operand).addValidation(\n () => !Number.isNaN(operand) && operand > 0,\n () =>\n messages.queryValidations.isPositiveNumber(this.operatorName, operand)\n )\n }\n\n isNonNegativeNumber(operand: number) {\n return this._isNumber('non-negative', operand).addValidation(\n () => !Number.isNaN(operand) && operand >= 0,\n () =>\n messages.queryValidations.isNonNegativeNumber(\n this.operatorName,\n operand\n )\n )\n }\n\n isInteger(operand: number) {\n return this.addValidation(\n () =>\n !Number.isNaN(operand) &&\n Number.isFinite(operand) &&\n Number.isInteger(operand) &&\n operand < MAX_SAFE_INTEGER &&\n operand > -MAX_SAFE_INTEGER,\n () => messages.queryValidations.isInteger(this.operatorName, operand)\n )\n }\n\n notGreaterThan(operand: number, value: number) {\n return this.addValidation(\n () => operand <= value,\n () =>\n messages.queryValidations.notGreaterThan(\n this.operatorName,\n operand,\n value\n )\n )\n }\n\n nonEmptyString(operand: any) {\n return this.addValidation(\n () => typeof operand === 'string' && operand.length > 0,\n () => messages.queryValidations.isNonEmptyString(this.operatorName)\n )\n }\n}\n"],"mappings":";;;;;;AAAA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tBM,MAAM,CAACI,QAAQ,CAACV,OAAO,CAAC,IACxBM,MAAM,CAACG,SAAS,CAACT,OAAO,CAAC,IACzBA,OAAO,GAAGV,gBAAgB,IAC1BU,OAAO,GAAG,CAACV,gBAAgB,EAC7B,MAAMa,gBAAQ,CAACC,gBAAgB,CAACK,SAAS,CAAC,IAAI,CAACf,YAAY,EAAEM,OAAO,CACtE,CAAC;EACH;EAEAW,cAAcA,CAACX,OAAe,EAAEY,KAAa,EAAE;IAC7C,OAAO,IAAI,CAACX,aAAa,CACvB,MAAMD,OAAO,IAAIY,KAAK,EACtB,MACET,gBAAQ,CAACC,gBAAgB,CAACO,cAAc,CACtC,IAAI,CAACjB,YAAY,EACjBM,OAAO,EACPY,KACF,CACJ,CAAC;EACH;EAEAC,cAAcA,CAACb,OAAY,EAAE;IAC3B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAM,OAAOD,OAAO,KAAK,QAAQ,IAAIA,OAAO,CAACc,MAAM,GAAG,CAAC,EACvD,MAAMX,gBAAQ,CAACC,gBAAgB,CAACW,gBAAgB,CAAC,IAAI,CAACrB,YAAY,CACpE,CAAC;EACH;AACF;AAACsB,OAAA,CAAAzB,cAAA,GAAAA,cAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/api/WixDataAggregate.ts"],"sourcesContent":["import { WixDataFilter } from './WixDataFilter'\nimport { WixDataReadOptions } from './types'\nimport { WixDataResult } from './WixDataResult'\n\n/**\n * @builder\n */\nexport interface WixDataAggregate {\n /**\n * Refines a `WixDataAggregate` to contain the sum from each aggregation group.\n *\n * The `sum()` function refines a `WixDataAggregate` to contain the sum of the\n * values from the specified property for each aggregated group or from the\n * whole collection if no group is defined.\n *\n * When the aggregation is `run()`, the returned `WixDataAggregateResult`\n * object contains an item for each group with the following key:value pairs:\n * - If a value was passed for the optional `projectedName`, the key is named\n * using that value. Otherwise, the key is named using the following format:\n * `\"propertyNameSum\"`, where `propertyName` is the name of the specified property.\n * - The value is the sum of the values found in the specified property.\n *\n * Sums can only be calculated on properties of type Number.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param fieldName - The property in which to find the sum.\n * @requiredField fieldName\n * @param projectedField - The name of the property in the aggregation results containing the sum.\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n sum(fieldName: string, projectedField?: string): WixDataAggregate\n\n /**\n * Refines a `WixDataAggregate` to only contain the average value from each aggregation group.\n *\n * The `avg()` function refines a `WixDataAggregate` to contain the average\n * value from the specified property for each aggregated group or from the\n * whole collection if no group is defined.\n *\n * When the aggregation is `run()`, the returned `WixDataAggregateResult`\n * object contains an item for each group with the following key:value pairs:\n * - If a value was passed for the optional `projectedName`, the key is named\n * using that value. Otherwise, the key is named using the following format:\n * `\"propertyNameAvg\"`, where `propertyName` is the name of the specified property.\n * - The value is the average of the values found in the specified property.\n *\n * Averages can only be calculated on properties of type Number.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param fieldName - The property in which to find the average value.\n * @requiredField fieldName\n * @param projectedField - The name of the property in the aggregation results containing the average value.\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n avg(fieldName: string, projectedField?: string): WixDataAggregate\n\n /**\n * Refines a `WixDataAggregate` to only contain the minimum value from each aggregation group.\n *\n * The `min()` function refines a `WixDataAggregate` to contain the minimum\n * value from the specified property for each aggregated group or from the\n * whole collection if no group is defined.\n *\n * When the aggregation is `run()`, the returned `WixDataAggregateResult`\n * object contains an item for each group with the following key:value pairs:\n * - If a value was passed for the optional `projectedName`, the key is named\n * using that value. Otherwise, the key is named using the following format:\n * `\"propertyNameMin\"`, where `propertyName` is the name of the specified property.\n * - The value is the minimum value found in the specified property.\n *\n * The following types of properties can be compared to determine a minimum value:\n * - Number: Compares numerically.\n * - Date and Time: Compares JavaScript Date objects.\n * - Text: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Rich Text: Compares HTML source as text.\n * - URL: Compares as text.\n * - Image: Compares image source as text.\n * - Video: Compares video source as text.\n * - Document: Compares document source as text.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param fieldName - The property in which to find the minimum value.\n * @requiredField fieldName\n * @param projectedField - The name of the property in the aggregation results containing the minimum value.\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n min(fieldName: string, projectedField?: string): WixDataAggregate\n\n /**\n * Refines a `WixDataAggregate` to only contain the maximum value from each aggregation group.\n *\n * The `max()` function refines a `WixDataAggregate` to contain the maximum\n * value from the specified property for each aggregated group or from the\n * whole collection if no group is defined.\n *\n * When the aggregation is `run()`, the returned `WixDataAggregateResult`\n * object contains an item for each group with the following key:value pairs:\n * - If a value was passed for the optional `projectedName`, the key is named\n * using that value. Otherwise, the key is named using the following format:\n * `\"propertyNameMax\"`, where `propertyName` is the name of the specified property.\n * - The value is the maximum value found in the specified property.\n *\n * The following types of properties can be compared to determine a maximum value:\n * - Number: Compares numerically.\n * - Date and Time: Compares JavaScript Date objects.\n * - Text: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Rich Text: Compares HTML source as text.\n * - URL: Compares as text.\n * - Image: Compares image source as text.\n * - Video: Compares video source as text.\n * - Document: Compares document source as text.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param fieldName - The property in which to find the maximum value.\n * @requiredField fieldName\n * @param projectedField - The name of the property in the aggregation results containing the maximum value.\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n max(fieldName: string, projectedField?: string): WixDataAggregate\n\n /**\n * Refines a `WixDataAggregate` to contain the item count of each group in the aggregation.\n *\n * The `count()` function refines a `WixDataAggregate` to contain the item\n * count in each of the aggregate's groups.\n *\n * When the aggregation is `run()`, the returned `WixDataAggregateResult`\n * object contains items with the following additional key:value pair:\n * - The key is named `\"count\"`.\n * - The value is the count of items aggregated in the group.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param projectedField - The name of the property in the aggregation results containing the count value.\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n count(projectedField?: string): WixDataAggregate\n\n /**\n * Filters out items from being used in an aggregation.\n *\n * The `filter()` function refines a `WixDataAggregate` so that it only\n * includes items from the aggregate's collection which match the specified\n * filter criteria.\n *\n * To create a filter, use the wix-data `filter()` function.\n *\n * Filtering using `filter()` takes place before grouping is performed on the\n * aggregation. To filter grouped results, use the `having()` function.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param filterBuilder - The filter to use to filter out items from being used in the aggregation.\n * @requiredField filterBuilder\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n filter(filterBuilder: WixDataFilter): WixDataAggregate\n\n /**\n * Groups items together in an aggregation.\n *\n * The `group()` function refines a `WixDataAggregate` so that its items are\n * grouped by the specified property or properties.\n *\n * You can perform aggregations on the groups using the following functions:\n * - `avg()`\n * - `count()`\n * - `max()`\n * - `min()`\n * - `sum()`\n *\n * To filter grouped results, use the `having()` function.\n *\n * > **Notes:**\n * > - Aggregations can only be used on collections you have created. They cannot be used on [Wix App Collections](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code).\n * > - You can only call the `group()` function once per aggregate query.\n * @public\n * @documentationMaturity preview\n * @param fieldName - The property or properties to group on.\n * @requiredField fieldName\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n group(...fieldName: string[]): WixDataAggregate\n\n /**\n * Filters out groups from being returned from an aggregation.\n *\n * The `having()` function refines a `WixDataAggregate` so that it only\n * includes groups from the aggregate's grouping which match the specified\n * filter criteria.\n *\n * To create a filter, use the wix-data `filter()` function.\n *\n * Filtering using `having()` takes place after grouping is performed on the\n * aggregation. To filter items before grouping, use the `filter()` function.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param filterBuilder - The filter to use to filter out groups from being returned from the aggregation.\n * @requiredField filterBuilder\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n having(filterBuilder: WixDataFilter): WixDataAggregate\n\n /**\n * Limits the number of items or groups the aggregation returns.\n *\n * The `limit()` function defines the number of results an aggregation returns in each\n * page. Only one page of results is retrieved at a time. The `next()`\n * function is used to navigate the pages of a query result.\n *\n * By default, `limit` is set to `50`.\n *\n * The maximum value that `limit()` can accept is `1000`.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param limitNumber - The number of items or groups to return.\n * @requiredField limitNumber\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n limit(limitNumber: number): WixDataAggregate\n\n /**\n * Sets the number of items or groups to skip before returning aggregation results.\n *\n * The `skip()` function defines the number of results to skip in the aggregation\n * results before returning new aggregation results.\n *\n * For example, if you perform an aggregation on a collection and 10 groups match\n * your aggregation, but you set `skip` to 3, the results returned will skip\n * the first 3 groups that match and return the 4th through 10th items.\n *\n * By default, `skip` is set to 0.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param skipNumber - The number of items or groups to skip in the aggregation results before returning the results.\n * @requiredField skipNumber\n * @returns A `WixDataAggregate` object representing the refined aggregation.\n */\n skip(skipNumber: number): WixDataAggregate\n\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in descending order.\n *\n * The `descending()` function refines this query to sort in descending order of the specified properties. If you\n * specify more than one property, descending() sorts the results in descending order by each property in the order\n * they are listed.\n *\n * You can sort the following types:\n *\n * Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items\n * that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n descending(...fields: string[]): WixDataAggregate\n\n descending(fields: string[]): WixDataAggregate\n\n descending(...fields: any): WixDataAggregate\n\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in ascending order.\n *\n * The `ascending()` function refines this query in ascending order of the specified properties. If you specify more\n * than one property, ascending() sorts the results in ascending order by each property in the order they are listed.\n *\n * You can sort the following types:\n * - Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes after `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n ascending(...fields: string[]): WixDataAggregate\n\n ascending(fields: string[]): WixDataAggregate\n\n ascending(...fields: any): WixDataAggregate\n\n /**\n * Runs the aggregation and returns the results.\n *\n * The `run()` function returns a Promise that resolves to the results found\n * by the aggregation and some information about the results.\n *\n * > **Note:** Aggregations can only be used on collections you have created. They cannot be\n * > used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections).\n * @public\n * @documentationMaturity preview\n * @param options - Options to use when running an aggregation.\n * @returns A Promise that resolves to the results of the aggregation.\n */\n run(options?: WixDataReadOptions): Promise<WixDataResult<Record<string, any>>>\n}\n"],"mappings":""}
|