@wix/data 1.0.90 → 1.0.91
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/build/cjs/context.d.ts +4 -4
- package/build/cjs/context.js +4 -4
- package/build/cjs/context.js.map +1 -1
- package/build/cjs/index.d.ts +4 -4
- package/build/cjs/index.js +4 -4
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/meta.d.ts +4 -4
- package/build/cjs/meta.js +4 -4
- package/build/cjs/meta.js.map +1 -1
- package/build/es/context.d.ts +4 -4
- package/build/es/context.js +4 -4
- package/build/es/context.js.map +1 -1
- package/build/es/index.d.ts +4 -4
- package/build/es/index.js +4 -4
- package/build/es/index.js.map +1 -1
- package/build/es/meta.d.ts +4 -4
- package/build/es/meta.js +4 -4
- package/build/es/meta.js.map +1 -1
- package/package.json +14 -9
- package/build/cjs/index.typings.d.ts +0 -4
- package/build/cjs/index.typings.js +0 -31
- package/build/cjs/index.typings.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.context.d.ts +0 -7
- package/build/cjs/src/data-v1-external-database-connection.context.js +0 -90
- package/build/cjs/src/data-v1-external-database-connection.context.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.http.d.ts +0 -28
- package/build/cjs/src/data-v1-external-database-connection.http.js +0 -393
- package/build/cjs/src/data-v1-external-database-connection.http.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.meta.d.ts +0 -23
- package/build/cjs/src/data-v1-external-database-connection.meta.js +0 -127
- package/build/cjs/src/data-v1-external-database-connection.meta.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.public.d.ts +0 -46
- package/build/cjs/src/data-v1-external-database-connection.public.js +0 -46
- package/build/cjs/src/data-v1-external-database-connection.public.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.types.d.ts +0 -321
- package/build/cjs/src/data-v1-external-database-connection.types.js +0 -88
- package/build/cjs/src/data-v1-external-database-connection.types.js.map +0 -1
- package/build/cjs/src/data-v1-external-database-connection.universal.d.ts +0 -433
- package/build/cjs/src/data-v1-external-database-connection.universal.js +0 -452
- package/build/cjs/src/data-v1-external-database-connection.universal.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.context.d.ts +0 -7
- package/build/cjs/src/data-v2-data-collection.context.js +0 -90
- package/build/cjs/src/data-v2-data-collection.context.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.http.d.ts +0 -36
- package/build/cjs/src/data-v2-data-collection.http.js +0 -494
- package/build/cjs/src/data-v2-data-collection.http.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.meta.d.ts +0 -21
- package/build/cjs/src/data-v2-data-collection.meta.js +0 -123
- package/build/cjs/src/data-v2-data-collection.meta.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.public.d.ts +0 -313
- package/build/cjs/src/data-v2-data-collection.public.js +0 -58
- package/build/cjs/src/data-v2-data-collection.public.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.types.d.ts +0 -1460
- package/build/cjs/src/data-v2-data-collection.types.js +0 -197
- package/build/cjs/src/data-v2-data-collection.types.js.map +0 -1
- package/build/cjs/src/data-v2-data-collection.universal.d.ts +0 -1626
- package/build/cjs/src/data-v2-data-collection.universal.js +0 -677
- package/build/cjs/src/data-v2-data-collection.universal.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.context.d.ts +0 -23
- package/build/cjs/src/data-v2-data-item.context.js +0 -362
- package/build/cjs/src/data-v2-data-item.context.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.http.d.ts +0 -225
- package/build/cjs/src/data-v2-data-item.http.js +0 -948
- package/build/cjs/src/data-v2-data-item.http.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.meta.d.ts +0 -39
- package/build/cjs/src/data-v2-data-item.meta.js +0 -427
- package/build/cjs/src/data-v2-data-item.meta.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.public.d.ts +0 -31
- package/build/cjs/src/data-v2-data-item.public.js +0 -137
- package/build/cjs/src/data-v2-data-item.public.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.types.d.ts +0 -980
- package/build/cjs/src/data-v2-data-item.types.js +0 -27
- package/build/cjs/src/data-v2-data-item.types.js.map +0 -1
- package/build/cjs/src/data-v2-data-item.universal.d.ts +0 -1823
- package/build/cjs/src/data-v2-data-item.universal.js +0 -1639
- package/build/cjs/src/data-v2-data-item.universal.js.map +0 -1
- package/build/cjs/src/data-v2-index.context.d.ts +0 -5
- package/build/cjs/src/data-v2-index.context.js +0 -56
- package/build/cjs/src/data-v2-index.context.js.map +0 -1
- package/build/cjs/src/data-v2-index.http.d.ts +0 -28
- package/build/cjs/src/data-v2-index.http.js +0 -367
- package/build/cjs/src/data-v2-index.http.js.map +0 -1
- package/build/cjs/src/data-v2-index.meta.d.ts +0 -15
- package/build/cjs/src/data-v2-index.meta.js +0 -85
- package/build/cjs/src/data-v2-index.meta.js.map +0 -1
- package/build/cjs/src/data-v2-index.public.d.ts +0 -23
- package/build/cjs/src/data-v2-index.public.js +0 -28
- package/build/cjs/src/data-v2-index.public.js.map +0 -1
- package/build/cjs/src/data-v2-index.types.d.ts +0 -174
- package/build/cjs/src/data-v2-index.types.js +0 -35
- package/build/cjs/src/data-v2-index.types.js.map +0 -1
- package/build/cjs/src/data-v2-index.universal.d.ts +0 -237
- package/build/cjs/src/data-v2-index.universal.js +0 -274
- package/build/cjs/src/data-v2-index.universal.js.map +0 -1
- package/build/es/index.typings.d.ts +0 -4
- package/build/es/index.typings.js +0 -5
- package/build/es/index.typings.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.context.d.ts +0 -7
- package/build/es/src/data-v1-external-database-connection.context.js +0 -82
- package/build/es/src/data-v1-external-database-connection.context.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.http.d.ts +0 -28
- package/build/es/src/data-v1-external-database-connection.http.js +0 -385
- package/build/es/src/data-v1-external-database-connection.http.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.meta.d.ts +0 -23
- package/build/es/src/data-v1-external-database-connection.meta.js +0 -96
- package/build/es/src/data-v1-external-database-connection.meta.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.public.d.ts +0 -46
- package/build/es/src/data-v1-external-database-connection.public.js +0 -30
- package/build/es/src/data-v1-external-database-connection.public.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.types.d.ts +0 -321
- package/build/es/src/data-v1-external-database-connection.types.js +0 -85
- package/build/es/src/data-v1-external-database-connection.types.js.map +0 -1
- package/build/es/src/data-v1-external-database-connection.universal.d.ts +0 -433
- package/build/es/src/data-v1-external-database-connection.universal.js +0 -421
- package/build/es/src/data-v1-external-database-connection.universal.js.map +0 -1
- package/build/es/src/data-v2-data-collection.context.d.ts +0 -7
- package/build/es/src/data-v2-data-collection.context.js +0 -82
- package/build/es/src/data-v2-data-collection.context.js.map +0 -1
- package/build/es/src/data-v2-data-collection.http.d.ts +0 -36
- package/build/es/src/data-v2-data-collection.http.js +0 -486
- package/build/es/src/data-v2-data-collection.http.js.map +0 -1
- package/build/es/src/data-v2-data-collection.meta.d.ts +0 -21
- package/build/es/src/data-v2-data-collection.meta.js +0 -92
- package/build/es/src/data-v2-data-collection.meta.js.map +0 -1
- package/build/es/src/data-v2-data-collection.public.d.ts +0 -313
- package/build/es/src/data-v2-data-collection.public.js +0 -30
- package/build/es/src/data-v2-data-collection.public.js.map +0 -1
- package/build/es/src/data-v2-data-collection.types.d.ts +0 -1460
- package/build/es/src/data-v2-data-collection.types.js +0 -194
- package/build/es/src/data-v2-data-collection.types.js.map +0 -1
- package/build/es/src/data-v2-data-collection.universal.d.ts +0 -1626
- package/build/es/src/data-v2-data-collection.universal.js +0 -646
- package/build/es/src/data-v2-data-collection.universal.js.map +0 -1
- package/build/es/src/data-v2-data-item.context.d.ts +0 -23
- package/build/es/src/data-v2-data-item.context.js +0 -338
- package/build/es/src/data-v2-data-item.context.js.map +0 -1
- package/build/es/src/data-v2-data-item.http.d.ts +0 -225
- package/build/es/src/data-v2-data-item.http.js +0 -924
- package/build/es/src/data-v2-data-item.http.js.map +0 -1
- package/build/es/src/data-v2-data-item.meta.d.ts +0 -39
- package/build/es/src/data-v2-data-item.meta.js +0 -380
- package/build/es/src/data-v2-data-item.meta.js.map +0 -1
- package/build/es/src/data-v2-data-item.public.d.ts +0 -31
- package/build/es/src/data-v2-data-item.public.js +0 -109
- package/build/es/src/data-v2-data-item.public.js.map +0 -1
- package/build/es/src/data-v2-data-item.types.d.ts +0 -980
- package/build/es/src/data-v2-data-item.types.js +0 -24
- package/build/es/src/data-v2-data-item.types.js.map +0 -1
- package/build/es/src/data-v2-data-item.universal.d.ts +0 -1823
- package/build/es/src/data-v2-data-item.universal.js +0 -1592
- package/build/es/src/data-v2-data-item.universal.js.map +0 -1
- package/build/es/src/data-v2-index.context.d.ts +0 -5
- package/build/es/src/data-v2-index.context.js +0 -50
- package/build/es/src/data-v2-index.context.js.map +0 -1
- package/build/es/src/data-v2-index.http.d.ts +0 -28
- package/build/es/src/data-v2-index.http.js +0 -361
- package/build/es/src/data-v2-index.http.js.map +0 -1
- package/build/es/src/data-v2-index.meta.d.ts +0 -15
- package/build/es/src/data-v2-index.meta.js +0 -56
- package/build/es/src/data-v2-index.meta.js.map +0 -1
- package/build/es/src/data-v2-index.public.d.ts +0 -23
- package/build/es/src/data-v2-index.public.js +0 -19
- package/build/es/src/data-v2-index.public.js.map +0 -1
- package/build/es/src/data-v2-index.types.d.ts +0 -174
- package/build/es/src/data-v2-index.types.js +0 -32
- package/build/es/src/data-v2-index.types.js.map +0 -1
- package/build/es/src/data-v2-index.universal.d.ts +0 -237
- package/build/es/src/data-v2-index.universal.js +0 -245
- package/build/es/src/data-v2-index.universal.js.map +0 -1
|
@@ -1,1592 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { serializer, transformError, resolveQueryFieldsTransformationPaths, } from '@wix/metro-runtime/velo';
|
|
11
|
-
import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
|
|
12
|
-
import * as ambassadorWixDataV2DataItem from './data-v2-data-item.http';
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import { wrapWithQueryBuilder } from '@wix/motion-edm-autogen-query-wrapper';
|
|
15
|
-
const _toVeloEntity = '$';
|
|
16
|
-
const _fromVeloEntity = '$';
|
|
17
|
-
export var Environment;
|
|
18
|
-
(function (Environment) {
|
|
19
|
-
Environment["LIVE"] = "LIVE";
|
|
20
|
-
Environment["SANDBOX"] = "SANDBOX";
|
|
21
|
-
})(Environment || (Environment = {}));
|
|
22
|
-
export var Action;
|
|
23
|
-
(function (Action) {
|
|
24
|
-
Action["UNKNOWN_ACTION"] = "UNKNOWN_ACTION";
|
|
25
|
-
Action["INSERTED"] = "INSERTED";
|
|
26
|
-
Action["UPDATED"] = "UPDATED";
|
|
27
|
-
})(Action || (Action = {}));
|
|
28
|
-
export var SortOrder;
|
|
29
|
-
(function (SortOrder) {
|
|
30
|
-
SortOrder["ASC"] = "ASC";
|
|
31
|
-
SortOrder["DESC"] = "DESC";
|
|
32
|
-
})(SortOrder || (SortOrder = {}));
|
|
33
|
-
export var BulkActionType;
|
|
34
|
-
(function (BulkActionType) {
|
|
35
|
-
BulkActionType["UNKNOWN_ACTION_TYPE"] = "UNKNOWN_ACTION_TYPE";
|
|
36
|
-
BulkActionType["INSERT"] = "INSERT";
|
|
37
|
-
BulkActionType["UPDATE"] = "UPDATE";
|
|
38
|
-
BulkActionType["DELETE"] = "DELETE";
|
|
39
|
-
})(BulkActionType || (BulkActionType = {}));
|
|
40
|
-
const _aggregateDataItemsRequest = {};
|
|
41
|
-
const _aggregateDataItemsResponse = {};
|
|
42
|
-
const _bulkInsertDataItemReferencesRequest = {};
|
|
43
|
-
const _bulkInsertDataItemReferencesResponse = {};
|
|
44
|
-
const _bulkInsertDataItemsRequest = {};
|
|
45
|
-
const _bulkInsertDataItemsResponse = {};
|
|
46
|
-
const _bulkRemoveDataItemReferencesRequest = {};
|
|
47
|
-
const _bulkRemoveDataItemReferencesResponse = {};
|
|
48
|
-
const _bulkRemoveDataItemsRequest = {};
|
|
49
|
-
const _bulkRemoveDataItemsResponse = {};
|
|
50
|
-
const _bulkSaveDataItemsRequest = {};
|
|
51
|
-
const _bulkSaveDataItemsResponse = {};
|
|
52
|
-
const _bulkUpdateDataItemsRequest = {};
|
|
53
|
-
const _bulkUpdateDataItemsResponse = {};
|
|
54
|
-
const _countDataItemsRequest = {};
|
|
55
|
-
const _countDataItemsResponse = {};
|
|
56
|
-
const _getDataItemRequest = {};
|
|
57
|
-
const _getDataItemResponse = {};
|
|
58
|
-
const _insertDataItemReferenceRequest = {};
|
|
59
|
-
const _insertDataItemReferenceResponse = {};
|
|
60
|
-
const _insertDataItemRequest = {};
|
|
61
|
-
const _insertDataItemResponse = {};
|
|
62
|
-
const _isReferencedDataItemRequest = {};
|
|
63
|
-
const _isReferencedDataItemResponse = {};
|
|
64
|
-
const _queryDataItemsRequest = {};
|
|
65
|
-
const _queryDataItemsResponse = {};
|
|
66
|
-
const _queryDistinctValuesRequest = {};
|
|
67
|
-
const _queryDistinctValuesResponse = {};
|
|
68
|
-
const _queryReferencedDataItemsRequest = {};
|
|
69
|
-
const _queryReferencedDataItemsResponse = {};
|
|
70
|
-
const _removeDataItemReferenceRequest = {};
|
|
71
|
-
const _removeDataItemReferenceResponse = {};
|
|
72
|
-
const _removeDataItemRequest = {};
|
|
73
|
-
const _removeDataItemResponse = {};
|
|
74
|
-
const _replaceDataItemReferencesRequest = {};
|
|
75
|
-
const _replaceDataItemReferencesResponse = {};
|
|
76
|
-
const _saveDataItemRequest = {};
|
|
77
|
-
const _saveDataItemResponse = {};
|
|
78
|
-
const _truncateDataItemsRequest = {};
|
|
79
|
-
const _truncateDataItemsResponse = {};
|
|
80
|
-
const _updateDataItemRequest = {};
|
|
81
|
-
const _updateDataItemResponse = {};
|
|
82
|
-
/**
|
|
83
|
-
* Adds an item to a collection.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* An item can only be inserted into an existing connection.
|
|
87
|
-
* You can create a new collection using the Data Collections API.
|
|
88
|
-
*
|
|
89
|
-
* When an item is inserted into a collection, the item's ID is automatically assigned a random value.
|
|
90
|
-
* You can optionally provide a custom ID in `dataItem.id` when inserting the item.
|
|
91
|
-
* If you specify an ID that already exists in the collection, the insertion will fail.
|
|
92
|
-
*
|
|
93
|
-
* If `options.dataItem.data` is empty, a new item is created with no data fields.
|
|
94
|
-
* @public
|
|
95
|
-
* @documentationMaturity preview
|
|
96
|
-
* @requiredField options
|
|
97
|
-
* @requiredField options.dataCollectionId
|
|
98
|
-
* @requiredField options.dataItem
|
|
99
|
-
* @param options - Options for adding an item to a collection.
|
|
100
|
-
* @permissionScope Write Data Items
|
|
101
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
102
|
-
* @applicableIdentity APP
|
|
103
|
-
*/
|
|
104
|
-
export function insertDataItem(options) {
|
|
105
|
-
var _a, _b, _c;
|
|
106
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
107
|
-
const requestTransformation = {
|
|
108
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
109
|
-
dataItem: '$[0].dataItem',
|
|
110
|
-
};
|
|
111
|
-
const responseTransformation = '$';
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
114
|
-
const { toAmbassadorRequest } = serializer({
|
|
115
|
-
rootSchema: _insertDataItemRequest,
|
|
116
|
-
depSchemas: {},
|
|
117
|
-
fqdnTransformation: {
|
|
118
|
-
paths: [...['dataItem']],
|
|
119
|
-
transformation: _fromVeloEntity,
|
|
120
|
-
},
|
|
121
|
-
customTransformation: requestTransformation,
|
|
122
|
-
});
|
|
123
|
-
const { fromJSON } = serializer({
|
|
124
|
-
rootSchema: _insertDataItemResponse,
|
|
125
|
-
depSchemas: {},
|
|
126
|
-
fqdnTransformation: {
|
|
127
|
-
paths: [...['dataItem']],
|
|
128
|
-
transformation: _toVeloEntity,
|
|
129
|
-
},
|
|
130
|
-
customTransformation: responseTransformation,
|
|
131
|
-
});
|
|
132
|
-
const payload = toAmbassadorRequest([options], ['dataItem.data']);
|
|
133
|
-
const reqOpts = ambassadorWixDataV2DataItem.insertDataItem(payload);
|
|
134
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
135
|
-
try {
|
|
136
|
-
const result = yield httpClient.request(reqOpts);
|
|
137
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
138
|
-
return fromJSON(result.data, ['dataItem.data']);
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
const transformedError = sdkTransformError(err, {
|
|
142
|
-
spreadPathsToArguments: {},
|
|
143
|
-
explicitPathsToArguments: {
|
|
144
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
145
|
-
dataItem: '$[0].dataItem',
|
|
146
|
-
},
|
|
147
|
-
singleArgumentUnchanged: false,
|
|
148
|
-
}, ['options']);
|
|
149
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
150
|
-
throw transformedError;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Updates an item in a collection.
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* This function replaces the data item's existing data with the payload provided in `options.dataItem.data` in the request.
|
|
159
|
-
*
|
|
160
|
-
* To update an item, you need to specify an item ID and a collection ID.
|
|
161
|
-
* If an item is found in the specified collection with the specified ID, that item is updated.
|
|
162
|
-
* If the collection doesn't contain an item with that ID, the request fails.
|
|
163
|
-
*
|
|
164
|
-
* When an item is updated, its `data._updatedDate` field is changed to the current date and time.
|
|
165
|
-
*
|
|
166
|
-
* > **Note:**
|
|
167
|
-
* > After an item is updated, it only contains the fields included in the `options.dataItem.data` payload in the `updateDataItem()` call.
|
|
168
|
-
* > If the existing item has fields with values and those fields aren't included in the updated item, their values are lost.
|
|
169
|
-
* @param _id - Data item ID.
|
|
170
|
-
* @public
|
|
171
|
-
* @documentationMaturity preview
|
|
172
|
-
* @requiredField _id
|
|
173
|
-
* @requiredField options
|
|
174
|
-
* @requiredField options.dataCollectionId
|
|
175
|
-
* @requiredField options.dataItem
|
|
176
|
-
* @param options - Options for updating an item in a collection.
|
|
177
|
-
* @permissionScope Write Data Items
|
|
178
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
179
|
-
* @applicableIdentity APP
|
|
180
|
-
*/
|
|
181
|
-
export function updateDataItem(_id, options) {
|
|
182
|
-
var _a, _b, _c;
|
|
183
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
184
|
-
const requestTransformation = {
|
|
185
|
-
dataItem: { '*': '$[1].dataItem', id: '$[0]' },
|
|
186
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
187
|
-
};
|
|
188
|
-
const responseTransformation = '$';
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
const { httpClient, sideEffects } = arguments[2];
|
|
191
|
-
const { toAmbassadorRequest } = serializer({
|
|
192
|
-
rootSchema: _updateDataItemRequest,
|
|
193
|
-
depSchemas: {},
|
|
194
|
-
fqdnTransformation: {
|
|
195
|
-
paths: [...['dataItem']],
|
|
196
|
-
transformation: _fromVeloEntity,
|
|
197
|
-
},
|
|
198
|
-
customTransformation: requestTransformation,
|
|
199
|
-
});
|
|
200
|
-
const { fromJSON } = serializer({
|
|
201
|
-
rootSchema: _updateDataItemResponse,
|
|
202
|
-
depSchemas: {},
|
|
203
|
-
fqdnTransformation: {
|
|
204
|
-
paths: [...['dataItem']],
|
|
205
|
-
transformation: _toVeloEntity,
|
|
206
|
-
},
|
|
207
|
-
customTransformation: responseTransformation,
|
|
208
|
-
});
|
|
209
|
-
const payload = toAmbassadorRequest([_id, options], ['dataItem.data']);
|
|
210
|
-
const reqOpts = ambassadorWixDataV2DataItem.updateDataItem(payload);
|
|
211
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
212
|
-
try {
|
|
213
|
-
const result = yield httpClient.request(reqOpts);
|
|
214
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
215
|
-
return fromJSON(result.data, ['dataItem.data']);
|
|
216
|
-
}
|
|
217
|
-
catch (err) {
|
|
218
|
-
const transformedError = sdkTransformError(err, {
|
|
219
|
-
spreadPathsToArguments: { dataItem: '$[1].dataItem' },
|
|
220
|
-
explicitPathsToArguments: {
|
|
221
|
-
'dataItem.id': '$[0]',
|
|
222
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
223
|
-
},
|
|
224
|
-
singleArgumentUnchanged: false,
|
|
225
|
-
}, ['_id', 'options']);
|
|
226
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
227
|
-
throw transformedError;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Inserts or updates an item in a collection.
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* The `saveDataItem()` function inserts or updates the specified item, depending on whether it already exists in the collection.
|
|
236
|
-
*
|
|
237
|
-
* + If you don't provide an ID, a new item is created.
|
|
238
|
-
*
|
|
239
|
-
* + If you provide an ID that does not exist in the collection, a new item is created with that ID.
|
|
240
|
-
*
|
|
241
|
-
* + If an item with the ID you provide already exists in the collection, that item is updated. When an item is updated, its `data._updatedDate` field is changed to the current date and time.
|
|
242
|
-
*
|
|
243
|
-
* > **Note:** When you provide an item with an ID that already exists in the collection, the payload you provide in `options.dataItem.data` replaces the existing item with that ID.
|
|
244
|
-
* > This means that the item's previous fields and values are lost.
|
|
245
|
-
* @public
|
|
246
|
-
* @documentationMaturity preview
|
|
247
|
-
* @requiredField options
|
|
248
|
-
* @requiredField options.dataCollectionId
|
|
249
|
-
* @requiredField options.dataItem
|
|
250
|
-
* @param options - Options for saving an item in a collection.
|
|
251
|
-
* @permissionScope Write Data Items
|
|
252
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
253
|
-
* @applicableIdentity APP
|
|
254
|
-
*/
|
|
255
|
-
export function saveDataItem(options) {
|
|
256
|
-
var _a, _b, _c;
|
|
257
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
258
|
-
const requestTransformation = {
|
|
259
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
260
|
-
dataItem: '$[0].dataItem',
|
|
261
|
-
};
|
|
262
|
-
const responseTransformation = '$';
|
|
263
|
-
// @ts-ignore
|
|
264
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
265
|
-
const { toAmbassadorRequest } = serializer({
|
|
266
|
-
rootSchema: _saveDataItemRequest,
|
|
267
|
-
depSchemas: {},
|
|
268
|
-
fqdnTransformation: {
|
|
269
|
-
paths: [...['dataItem']],
|
|
270
|
-
transformation: _fromVeloEntity,
|
|
271
|
-
},
|
|
272
|
-
customTransformation: requestTransformation,
|
|
273
|
-
});
|
|
274
|
-
const { fromJSON } = serializer({
|
|
275
|
-
rootSchema: _saveDataItemResponse,
|
|
276
|
-
depSchemas: {},
|
|
277
|
-
fqdnTransformation: {
|
|
278
|
-
paths: [...['dataItem']],
|
|
279
|
-
transformation: _toVeloEntity,
|
|
280
|
-
},
|
|
281
|
-
customTransformation: responseTransformation,
|
|
282
|
-
});
|
|
283
|
-
const payload = toAmbassadorRequest([options], ['dataItem.data']);
|
|
284
|
-
const reqOpts = ambassadorWixDataV2DataItem.saveDataItem(payload);
|
|
285
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
286
|
-
try {
|
|
287
|
-
const result = yield httpClient.request(reqOpts);
|
|
288
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
289
|
-
return fromJSON(result.data, ['dataItem.data']);
|
|
290
|
-
}
|
|
291
|
-
catch (err) {
|
|
292
|
-
const transformedError = sdkTransformError(err, {
|
|
293
|
-
spreadPathsToArguments: {},
|
|
294
|
-
explicitPathsToArguments: {
|
|
295
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
296
|
-
dataItem: '$[0].dataItem',
|
|
297
|
-
},
|
|
298
|
-
singleArgumentUnchanged: false,
|
|
299
|
-
}, ['options']);
|
|
300
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
301
|
-
throw transformedError;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Retrieves an item from a collection.
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* > **Note**: When calling `getDataItem()` following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
310
|
-
* @param dataItemId - ID of the data item to retrieve.
|
|
311
|
-
* @public
|
|
312
|
-
* @documentationMaturity preview
|
|
313
|
-
* @requiredField dataItemId
|
|
314
|
-
* @requiredField options.dataCollectionId
|
|
315
|
-
* @param options - Options for retrieving an item from a collection.
|
|
316
|
-
* @permissionScope Read Data Items
|
|
317
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
318
|
-
* @applicableIdentity APP
|
|
319
|
-
* @returns Retrieved item.
|
|
320
|
-
*/
|
|
321
|
-
export function getDataItem(dataItemId, options) {
|
|
322
|
-
var _a, _b, _c;
|
|
323
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
324
|
-
const requestTransformation = {
|
|
325
|
-
dataItemId: '$[0]',
|
|
326
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
327
|
-
consistentRead: '$[1].consistentRead',
|
|
328
|
-
language: '$[1].language',
|
|
329
|
-
};
|
|
330
|
-
const responseTransformation = '$.dataItem';
|
|
331
|
-
// @ts-ignore
|
|
332
|
-
const { httpClient, sideEffects } = arguments[2];
|
|
333
|
-
const { toAmbassadorRequest } = serializer({
|
|
334
|
-
rootSchema: _getDataItemRequest,
|
|
335
|
-
depSchemas: {},
|
|
336
|
-
fqdnTransformation: {
|
|
337
|
-
paths: [],
|
|
338
|
-
transformation: _fromVeloEntity,
|
|
339
|
-
},
|
|
340
|
-
customTransformation: requestTransformation,
|
|
341
|
-
});
|
|
342
|
-
const { fromJSON } = serializer({
|
|
343
|
-
rootSchema: _getDataItemResponse,
|
|
344
|
-
depSchemas: {},
|
|
345
|
-
fqdnTransformation: {
|
|
346
|
-
paths: [...['dataItem']],
|
|
347
|
-
transformation: _toVeloEntity,
|
|
348
|
-
},
|
|
349
|
-
customTransformation: responseTransformation,
|
|
350
|
-
});
|
|
351
|
-
const payload = toAmbassadorRequest([dataItemId, options], []);
|
|
352
|
-
const reqOpts = ambassadorWixDataV2DataItem.getDataItem(payload);
|
|
353
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
354
|
-
try {
|
|
355
|
-
const result = yield httpClient.request(reqOpts);
|
|
356
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
357
|
-
return fromJSON(result.data, ['dataItem.data']);
|
|
358
|
-
}
|
|
359
|
-
catch (err) {
|
|
360
|
-
const transformedError = sdkTransformError(err, {
|
|
361
|
-
spreadPathsToArguments: {},
|
|
362
|
-
explicitPathsToArguments: {
|
|
363
|
-
dataItemId: '$[0]',
|
|
364
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
365
|
-
consistentRead: '$[1].consistentRead',
|
|
366
|
-
language: '$[1].language',
|
|
367
|
-
},
|
|
368
|
-
singleArgumentUnchanged: false,
|
|
369
|
-
}, ['dataItemId', 'options']);
|
|
370
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
371
|
-
throw transformedError;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Removes an item from a collection.
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* If any items in other collections reference the removed item in reference or multi-reference fields, those fields are cleared.
|
|
380
|
-
*
|
|
381
|
-
* > **Note:**
|
|
382
|
-
* > Once an item has been removed from a collection, it can't be restored.
|
|
383
|
-
* @param dataItemId - ID of the item to remove.
|
|
384
|
-
* @public
|
|
385
|
-
* @documentationMaturity preview
|
|
386
|
-
* @requiredField dataItemId
|
|
387
|
-
* @requiredField options
|
|
388
|
-
* @requiredField options.dataCollectionId
|
|
389
|
-
* @param options - Options for removing an item from a collection.
|
|
390
|
-
* @permissionScope Write Data Items
|
|
391
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
392
|
-
* @applicableIdentity APP
|
|
393
|
-
*/
|
|
394
|
-
export function removeDataItem(dataItemId, options) {
|
|
395
|
-
var _a, _b, _c;
|
|
396
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
397
|
-
const requestTransformation = {
|
|
398
|
-
dataItemId: '$[0]',
|
|
399
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
400
|
-
};
|
|
401
|
-
const responseTransformation = '$';
|
|
402
|
-
// @ts-ignore
|
|
403
|
-
const { httpClient, sideEffects } = arguments[2];
|
|
404
|
-
const { toAmbassadorRequest } = serializer({
|
|
405
|
-
rootSchema: _removeDataItemRequest,
|
|
406
|
-
depSchemas: {},
|
|
407
|
-
fqdnTransformation: {
|
|
408
|
-
paths: [],
|
|
409
|
-
transformation: _fromVeloEntity,
|
|
410
|
-
},
|
|
411
|
-
customTransformation: requestTransformation,
|
|
412
|
-
});
|
|
413
|
-
const { fromJSON } = serializer({
|
|
414
|
-
rootSchema: _removeDataItemResponse,
|
|
415
|
-
depSchemas: {},
|
|
416
|
-
fqdnTransformation: {
|
|
417
|
-
paths: [...['dataItem']],
|
|
418
|
-
transformation: _toVeloEntity,
|
|
419
|
-
},
|
|
420
|
-
customTransformation: responseTransformation,
|
|
421
|
-
});
|
|
422
|
-
const payload = toAmbassadorRequest([dataItemId, options], []);
|
|
423
|
-
const reqOpts = ambassadorWixDataV2DataItem.removeDataItem(payload);
|
|
424
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
425
|
-
try {
|
|
426
|
-
const result = yield httpClient.request(reqOpts);
|
|
427
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
428
|
-
return fromJSON(result.data, ['dataItem.data']);
|
|
429
|
-
}
|
|
430
|
-
catch (err) {
|
|
431
|
-
const transformedError = sdkTransformError(err, {
|
|
432
|
-
spreadPathsToArguments: {},
|
|
433
|
-
explicitPathsToArguments: {
|
|
434
|
-
dataItemId: '$[0]',
|
|
435
|
-
dataCollectionId: '$[1].dataCollectionId',
|
|
436
|
-
},
|
|
437
|
-
singleArgumentUnchanged: false,
|
|
438
|
-
}, ['dataItemId', 'options']);
|
|
439
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
440
|
-
throw transformedError;
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Removes all items from a collection.
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* If any items in other collections reference the removed items in reference or multi-reference fields, those fields are cleared.
|
|
449
|
-
*
|
|
450
|
-
* > **Note:**
|
|
451
|
-
* > Once items have been removed from a collection, they can't be restored.
|
|
452
|
-
* @public
|
|
453
|
-
* @documentationMaturity preview
|
|
454
|
-
* @requiredField options
|
|
455
|
-
* @requiredField options.dataCollectionId
|
|
456
|
-
* @param options - Options for truncating data items from a collection.
|
|
457
|
-
* @permissionScope Write Data Items
|
|
458
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
459
|
-
* @applicableIdentity APP
|
|
460
|
-
*/
|
|
461
|
-
export function truncateDataItems(options) {
|
|
462
|
-
var _a, _b, _c;
|
|
463
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
464
|
-
const requestTransformation = { dataCollectionId: '$[0].dataCollectionId' };
|
|
465
|
-
const responseTransformation = '$';
|
|
466
|
-
// @ts-ignore
|
|
467
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
468
|
-
const { toAmbassadorRequest } = serializer({
|
|
469
|
-
rootSchema: _truncateDataItemsRequest,
|
|
470
|
-
depSchemas: {},
|
|
471
|
-
fqdnTransformation: {
|
|
472
|
-
paths: [],
|
|
473
|
-
transformation: _fromVeloEntity,
|
|
474
|
-
},
|
|
475
|
-
customTransformation: requestTransformation,
|
|
476
|
-
});
|
|
477
|
-
const { fromJSON } = serializer({
|
|
478
|
-
rootSchema: _truncateDataItemsResponse,
|
|
479
|
-
depSchemas: {},
|
|
480
|
-
fqdnTransformation: {
|
|
481
|
-
paths: [],
|
|
482
|
-
transformation: _toVeloEntity,
|
|
483
|
-
},
|
|
484
|
-
customTransformation: responseTransformation,
|
|
485
|
-
});
|
|
486
|
-
const payload = toAmbassadorRequest([options], []);
|
|
487
|
-
const reqOpts = ambassadorWixDataV2DataItem.truncateDataItems(payload);
|
|
488
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
489
|
-
try {
|
|
490
|
-
const result = yield httpClient.request(reqOpts);
|
|
491
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
492
|
-
}
|
|
493
|
-
catch (err) {
|
|
494
|
-
const transformedError = sdkTransformError(err, {
|
|
495
|
-
spreadPathsToArguments: {},
|
|
496
|
-
explicitPathsToArguments: { dataCollectionId: '$[0].dataCollectionId' },
|
|
497
|
-
singleArgumentUnchanged: false,
|
|
498
|
-
}, ['options']);
|
|
499
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
500
|
-
throw transformedError;
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Creates a query to retrieve items from a database collection.
|
|
506
|
-
*
|
|
507
|
-
* The `queryDataItems()` function builds a query to retrieve data items from a collection and returns a `DataItemsQueryBuilder` object.
|
|
508
|
-
*
|
|
509
|
-
* The returned object contains the query definition which is typically used to run the query using the `find()` function.
|
|
510
|
-
*
|
|
511
|
-
* You can refine the query by chaining `DataItemsQueryBuilder` functions onto the query. `DataItemsQueryBuilder` functions enable you to sort, filter, and control the results that `queryDataItems()` returns.
|
|
512
|
-
*
|
|
513
|
-
* The `queryDataItems()` function runs with the following `DataItemsQueryBuilder` defaults that you can override:
|
|
514
|
-
*
|
|
515
|
-
* + `skip`: 0
|
|
516
|
-
* + `limit`: 50
|
|
517
|
-
* + `descending`: by `_createdDate`
|
|
518
|
-
*
|
|
519
|
-
* The functions that are chained to `queryDataItems()` are applied in the order they are called. For example, if you sort on an `age` field in ascending order and then on a `name` field in descending order, the results are sorted first by the age of the items and then, if there are multiple results with the same age, the items are sorted by name in descending order, per age value.
|
|
520
|
-
*
|
|
521
|
-
* If the collection that you are querying has references to other collections, by default the data from referenced collections is not retrieved. To get the data from referenced items, specify them in the `options.includeReferencedItems` parameter.
|
|
522
|
-
*
|
|
523
|
-
* > **Note**: When calling `queryDataItems()` following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
* @public
|
|
527
|
-
* @documentationMaturity preview
|
|
528
|
-
* @requiredField options.options.dataCollectionId
|
|
529
|
-
* @param options - Options for querying data items.
|
|
530
|
-
* @permissionScope Read Data Items
|
|
531
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
532
|
-
* @applicableIdentity APP
|
|
533
|
-
*/
|
|
534
|
-
export function queryDataItems(options) {
|
|
535
|
-
const requestTransformation = { '*': '$[1]', query: '$[0]' };
|
|
536
|
-
const responseTransformation = {
|
|
537
|
-
items: '$.dataItems',
|
|
538
|
-
pagingMetadata: '$.pagingMetadata',
|
|
539
|
-
};
|
|
540
|
-
// @ts-ignore
|
|
541
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
542
|
-
const { toAmbassadorRequest } = serializer({
|
|
543
|
-
rootSchema: _queryDataItemsRequest,
|
|
544
|
-
depSchemas: {},
|
|
545
|
-
fqdnTransformation: {
|
|
546
|
-
paths: [],
|
|
547
|
-
transformation: _fromVeloEntity,
|
|
548
|
-
},
|
|
549
|
-
customTransformation: requestTransformation,
|
|
550
|
-
});
|
|
551
|
-
const { fromJSON } = serializer({
|
|
552
|
-
rootSchema: _queryDataItemsResponse,
|
|
553
|
-
depSchemas: {},
|
|
554
|
-
fqdnTransformation: {
|
|
555
|
-
paths: [...['Array#dataItems']],
|
|
556
|
-
transformation: _toVeloEntity,
|
|
557
|
-
},
|
|
558
|
-
customTransformation: responseTransformation,
|
|
559
|
-
});
|
|
560
|
-
return wrapWithQueryBuilder({
|
|
561
|
-
func: (payload) => __awaiter(this, void 0, void 0, function* () {
|
|
562
|
-
var _a, _b, _c;
|
|
563
|
-
const reqOpts = ambassadorWixDataV2DataItem.queryDataItems(Object.assign(Object.assign({}, payload), options));
|
|
564
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
565
|
-
try {
|
|
566
|
-
const result = yield httpClient.request(reqOpts);
|
|
567
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
568
|
-
return result;
|
|
569
|
-
}
|
|
570
|
-
catch (err) {
|
|
571
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
572
|
-
throw err;
|
|
573
|
-
}
|
|
574
|
-
}),
|
|
575
|
-
requestTransformer: (...args) => toAmbassadorRequest(args, []),
|
|
576
|
-
responseTransformer: ({ data }) => fromJSON(data, ['dataItems.data']),
|
|
577
|
-
errorTransformer: (err) => {
|
|
578
|
-
const transformedError = transformError(err, requestTransformation);
|
|
579
|
-
throw transformedError;
|
|
580
|
-
},
|
|
581
|
-
pagingMethod: 'OFFSET',
|
|
582
|
-
transformationPaths: resolveQueryFieldsTransformationPaths(_toVeloEntity),
|
|
583
|
-
})({ cursorWithEmptyFilterAndSort: true });
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Runs an aggregation on a data collection and returns the resulting list of items.
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
* An aggregation enables you to perform certain calculations on your collection data, or on groups of items that you define, to retrieve meaningful summaries.
|
|
590
|
-
* You can also add paging, filtering, and sorting preferences to your aggregation to retrieve exactly what you need.
|
|
591
|
-
* @public
|
|
592
|
-
* @documentationMaturity preview
|
|
593
|
-
* @requiredField options.dataCollectionId
|
|
594
|
-
* @param options - Options for running an aggregation.
|
|
595
|
-
* @permissionScope Read Data Items
|
|
596
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
597
|
-
* @applicableIdentity APP
|
|
598
|
-
*/
|
|
599
|
-
export function aggregateDataItems(options) {
|
|
600
|
-
var _a, _b, _c;
|
|
601
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
602
|
-
const requestTransformation = {
|
|
603
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
604
|
-
initialFilter: '$[0].initialFilter',
|
|
605
|
-
aggregation: '$[0].aggregation',
|
|
606
|
-
finalFilter: '$[0].finalFilter',
|
|
607
|
-
paging: '$[0].paging',
|
|
608
|
-
cursorPaging: '$[0].cursorPaging',
|
|
609
|
-
sort: '$[0].sort',
|
|
610
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
611
|
-
consistentRead: '$[0].consistentRead',
|
|
612
|
-
language: '$[0].language',
|
|
613
|
-
};
|
|
614
|
-
const responseTransformation = '$';
|
|
615
|
-
// @ts-ignore
|
|
616
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
617
|
-
const { toAmbassadorRequest } = serializer({
|
|
618
|
-
rootSchema: _aggregateDataItemsRequest,
|
|
619
|
-
depSchemas: {},
|
|
620
|
-
fqdnTransformation: {
|
|
621
|
-
paths: [],
|
|
622
|
-
transformation: _fromVeloEntity,
|
|
623
|
-
},
|
|
624
|
-
customTransformation: requestTransformation,
|
|
625
|
-
});
|
|
626
|
-
const { fromJSON } = serializer({
|
|
627
|
-
rootSchema: _aggregateDataItemsResponse,
|
|
628
|
-
depSchemas: {},
|
|
629
|
-
fqdnTransformation: {
|
|
630
|
-
paths: [],
|
|
631
|
-
transformation: _toVeloEntity,
|
|
632
|
-
},
|
|
633
|
-
customTransformation: responseTransformation,
|
|
634
|
-
});
|
|
635
|
-
const payload = toAmbassadorRequest([options], []);
|
|
636
|
-
const reqOpts = ambassadorWixDataV2DataItem.aggregateDataItems(payload);
|
|
637
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
638
|
-
try {
|
|
639
|
-
const result = yield httpClient.request(reqOpts);
|
|
640
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
641
|
-
return fromJSON(result.data, []);
|
|
642
|
-
}
|
|
643
|
-
catch (err) {
|
|
644
|
-
const transformedError = sdkTransformError(err, {
|
|
645
|
-
spreadPathsToArguments: {},
|
|
646
|
-
explicitPathsToArguments: {
|
|
647
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
648
|
-
initialFilter: '$[0].initialFilter',
|
|
649
|
-
aggregation: '$[0].aggregation',
|
|
650
|
-
finalFilter: '$[0].finalFilter',
|
|
651
|
-
paging: '$[0].paging',
|
|
652
|
-
cursorPaging: '$[0].cursorPaging',
|
|
653
|
-
sort: '$[0].sort',
|
|
654
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
655
|
-
consistentRead: '$[0].consistentRead',
|
|
656
|
-
language: '$[0].language',
|
|
657
|
-
},
|
|
658
|
-
singleArgumentUnchanged: false,
|
|
659
|
-
}, ['options']);
|
|
660
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
661
|
-
throw transformedError;
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Counts the number of items in a data collection that match the provided filtering preferences.
|
|
667
|
-
*
|
|
668
|
-
* > **Note**: When calling `countDataItems()` following an update to your collection, the result returned may not reflect the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
669
|
-
* @public
|
|
670
|
-
* @documentationMaturity preview
|
|
671
|
-
* @requiredField options.dataCollectionId
|
|
672
|
-
* @param options - Options for counting the number of items in a data collection.
|
|
673
|
-
* @permissionScope Read Data Items
|
|
674
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
675
|
-
* @applicableIdentity APP
|
|
676
|
-
*/
|
|
677
|
-
export function countDataItems(options) {
|
|
678
|
-
var _a, _b, _c;
|
|
679
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
680
|
-
const requestTransformation = {
|
|
681
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
682
|
-
filter: '$[0].filter',
|
|
683
|
-
consistentRead: '$[0].consistentRead',
|
|
684
|
-
language: '$[0].language',
|
|
685
|
-
};
|
|
686
|
-
const responseTransformation = '$';
|
|
687
|
-
// @ts-ignore
|
|
688
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
689
|
-
const { toAmbassadorRequest } = serializer({
|
|
690
|
-
rootSchema: _countDataItemsRequest,
|
|
691
|
-
depSchemas: {},
|
|
692
|
-
fqdnTransformation: {
|
|
693
|
-
paths: [],
|
|
694
|
-
transformation: _fromVeloEntity,
|
|
695
|
-
},
|
|
696
|
-
customTransformation: requestTransformation,
|
|
697
|
-
});
|
|
698
|
-
const { fromJSON } = serializer({
|
|
699
|
-
rootSchema: _countDataItemsResponse,
|
|
700
|
-
depSchemas: {},
|
|
701
|
-
fqdnTransformation: {
|
|
702
|
-
paths: [],
|
|
703
|
-
transformation: _toVeloEntity,
|
|
704
|
-
},
|
|
705
|
-
customTransformation: responseTransformation,
|
|
706
|
-
});
|
|
707
|
-
const payload = toAmbassadorRequest([options], []);
|
|
708
|
-
const reqOpts = ambassadorWixDataV2DataItem.countDataItems(payload);
|
|
709
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
710
|
-
try {
|
|
711
|
-
const result = yield httpClient.request(reqOpts);
|
|
712
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
713
|
-
return fromJSON(result.data, []);
|
|
714
|
-
}
|
|
715
|
-
catch (err) {
|
|
716
|
-
const transformedError = sdkTransformError(err, {
|
|
717
|
-
spreadPathsToArguments: {},
|
|
718
|
-
explicitPathsToArguments: {
|
|
719
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
720
|
-
filter: '$[0].filter',
|
|
721
|
-
consistentRead: '$[0].consistentRead',
|
|
722
|
-
language: '$[0].language',
|
|
723
|
-
},
|
|
724
|
-
singleArgumentUnchanged: false,
|
|
725
|
-
}, ['options']);
|
|
726
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
727
|
-
throw transformedError;
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Retrieves a list of distinct values for a given field in all items that match a query, without duplicates.
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
* As with `queryDataItems()`, this endpoint retrieves items based on the filtering, sorting, and paging preferences you provide.
|
|
736
|
-
* However, `queryDistinctValues()` doesn't return all of the full items that match the query.
|
|
737
|
-
* Rather, it returns all unique values of the field you specify in `options.fieldName` for items that match the query.
|
|
738
|
-
* If more than one item has the same value for that field, that value appears only once.
|
|
739
|
-
*
|
|
740
|
-
* For more details on using queries, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).
|
|
741
|
-
*
|
|
742
|
-
* > **Note**: When calling `queryDistinctValues()` following an update to your collection, the data retrieved may not reflect the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
743
|
-
* @public
|
|
744
|
-
* @documentationMaturity preview
|
|
745
|
-
* @requiredField options.dataCollectionId
|
|
746
|
-
* @param options - Options for querying distinct values.
|
|
747
|
-
* @permissionScope Read Data Items
|
|
748
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
749
|
-
* @applicableIdentity APP
|
|
750
|
-
*/
|
|
751
|
-
export function queryDistinctValues(options) {
|
|
752
|
-
var _a, _b, _c;
|
|
753
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
754
|
-
const requestTransformation = {
|
|
755
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
756
|
-
fieldName: '$[0].fieldName',
|
|
757
|
-
filter: '$[0].filter',
|
|
758
|
-
order: '$[0].order',
|
|
759
|
-
paging: '$[0].paging',
|
|
760
|
-
cursorPaging: '$[0].cursorPaging',
|
|
761
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
762
|
-
consistentRead: '$[0].consistentRead',
|
|
763
|
-
language: '$[0].language',
|
|
764
|
-
};
|
|
765
|
-
const responseTransformation = '$';
|
|
766
|
-
// @ts-ignore
|
|
767
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
768
|
-
const { toAmbassadorRequest } = serializer({
|
|
769
|
-
rootSchema: _queryDistinctValuesRequest,
|
|
770
|
-
depSchemas: {},
|
|
771
|
-
fqdnTransformation: {
|
|
772
|
-
paths: [],
|
|
773
|
-
transformation: _fromVeloEntity,
|
|
774
|
-
},
|
|
775
|
-
customTransformation: requestTransformation,
|
|
776
|
-
});
|
|
777
|
-
const { fromJSON } = serializer({
|
|
778
|
-
rootSchema: _queryDistinctValuesResponse,
|
|
779
|
-
depSchemas: {},
|
|
780
|
-
fqdnTransformation: {
|
|
781
|
-
paths: [],
|
|
782
|
-
transformation: _toVeloEntity,
|
|
783
|
-
},
|
|
784
|
-
customTransformation: responseTransformation,
|
|
785
|
-
});
|
|
786
|
-
const payload = toAmbassadorRequest([options], []);
|
|
787
|
-
const reqOpts = ambassadorWixDataV2DataItem.queryDistinctValues(payload);
|
|
788
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
789
|
-
try {
|
|
790
|
-
const result = yield httpClient.request(reqOpts);
|
|
791
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
792
|
-
return fromJSON(result.data, []);
|
|
793
|
-
}
|
|
794
|
-
catch (err) {
|
|
795
|
-
const transformedError = sdkTransformError(err, {
|
|
796
|
-
spreadPathsToArguments: {},
|
|
797
|
-
explicitPathsToArguments: {
|
|
798
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
799
|
-
fieldName: '$[0].fieldName',
|
|
800
|
-
filter: '$[0].filter',
|
|
801
|
-
order: '$[0].order',
|
|
802
|
-
paging: '$[0].paging',
|
|
803
|
-
cursorPaging: '$[0].cursorPaging',
|
|
804
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
805
|
-
consistentRead: '$[0].consistentRead',
|
|
806
|
-
language: '$[0].language',
|
|
807
|
-
},
|
|
808
|
-
singleArgumentUnchanged: false,
|
|
809
|
-
}, ['options']);
|
|
810
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
811
|
-
throw transformedError;
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Adds multiple items to a collection.
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
* When each item is inserted into a collection, its ID is automatically assigned a random value.
|
|
820
|
-
* You can optionally provide your own ID when inserting the item. If you specify an ID that already exists in the collection, the insertion will fail.
|
|
821
|
-
* @public
|
|
822
|
-
* @documentationMaturity preview
|
|
823
|
-
* @requiredField options.dataCollectionId
|
|
824
|
-
* @requiredField options.dataItems
|
|
825
|
-
* @param options - Options for adding multiple items to a collection.
|
|
826
|
-
* @permissionScope Write Data Items
|
|
827
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
828
|
-
* @applicableIdentity APP
|
|
829
|
-
*/
|
|
830
|
-
export function bulkInsertDataItems(options) {
|
|
831
|
-
var _a, _b, _c;
|
|
832
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
833
|
-
const requestTransformation = {
|
|
834
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
835
|
-
dataItems: '$[0].dataItems',
|
|
836
|
-
returnEntity: '$[0].returnEntity',
|
|
837
|
-
};
|
|
838
|
-
const responseTransformation = '$';
|
|
839
|
-
// @ts-ignore
|
|
840
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
841
|
-
const { toAmbassadorRequest } = serializer({
|
|
842
|
-
rootSchema: _bulkInsertDataItemsRequest,
|
|
843
|
-
depSchemas: {},
|
|
844
|
-
fqdnTransformation: {
|
|
845
|
-
paths: [...['Array#dataItems']],
|
|
846
|
-
transformation: _fromVeloEntity,
|
|
847
|
-
},
|
|
848
|
-
customTransformation: requestTransformation,
|
|
849
|
-
});
|
|
850
|
-
const { fromJSON } = serializer({
|
|
851
|
-
rootSchema: _bulkInsertDataItemsResponse,
|
|
852
|
-
depSchemas: {},
|
|
853
|
-
fqdnTransformation: {
|
|
854
|
-
paths: [...['Array#results.dataItem']],
|
|
855
|
-
transformation: _toVeloEntity,
|
|
856
|
-
},
|
|
857
|
-
customTransformation: responseTransformation,
|
|
858
|
-
});
|
|
859
|
-
const payload = toAmbassadorRequest([options], ['dataItems.data']);
|
|
860
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkInsertDataItems(payload);
|
|
861
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
862
|
-
try {
|
|
863
|
-
const result = yield httpClient.request(reqOpts);
|
|
864
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
865
|
-
return fromJSON(result.data, ['results.dataItem.data']);
|
|
866
|
-
}
|
|
867
|
-
catch (err) {
|
|
868
|
-
const transformedError = sdkTransformError(err, {
|
|
869
|
-
spreadPathsToArguments: {},
|
|
870
|
-
explicitPathsToArguments: {
|
|
871
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
872
|
-
dataItems: '$[0].dataItems',
|
|
873
|
-
returnEntity: '$[0].returnEntity',
|
|
874
|
-
},
|
|
875
|
-
singleArgumentUnchanged: false,
|
|
876
|
-
}, ['options']);
|
|
877
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
878
|
-
throw transformedError;
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Updates multiple items in a collection.
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
* This function replaces each specified data item's existing data with the payload provided in the request.
|
|
887
|
-
*
|
|
888
|
-
* Each item in the request must include an ID. If an item is found in the specified collection with
|
|
889
|
-
* the same ID, that item is updated. If the collection doesn't contain an item with that ID, the update fails.
|
|
890
|
-
*
|
|
891
|
-
* When an item is updated, its `data._updatedDate` field is changed to the current date and time.
|
|
892
|
-
*
|
|
893
|
-
* > **Note:**
|
|
894
|
-
* > After each item is updated, it only contains the fields included in the request. If the existing item has fields with values and those fields
|
|
895
|
-
* > aren't included in the updated item, their values are lost.
|
|
896
|
-
* @public
|
|
897
|
-
* @documentationMaturity preview
|
|
898
|
-
* @requiredField options.dataCollectionId
|
|
899
|
-
* @requiredField options.dataItems
|
|
900
|
-
* @param options - Options for updating multiple items in a collection.
|
|
901
|
-
* @permissionScope Write Data Items
|
|
902
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
903
|
-
* @applicableIdentity APP
|
|
904
|
-
*/
|
|
905
|
-
export function bulkUpdateDataItems(options) {
|
|
906
|
-
var _a, _b, _c;
|
|
907
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
908
|
-
const requestTransformation = {
|
|
909
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
910
|
-
dataItems: '$[0].dataItems',
|
|
911
|
-
returnEntity: '$[0].returnEntity',
|
|
912
|
-
};
|
|
913
|
-
const responseTransformation = '$';
|
|
914
|
-
// @ts-ignore
|
|
915
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
916
|
-
const { toAmbassadorRequest } = serializer({
|
|
917
|
-
rootSchema: _bulkUpdateDataItemsRequest,
|
|
918
|
-
depSchemas: {},
|
|
919
|
-
fqdnTransformation: {
|
|
920
|
-
paths: [...['Array#dataItems']],
|
|
921
|
-
transformation: _fromVeloEntity,
|
|
922
|
-
},
|
|
923
|
-
customTransformation: requestTransformation,
|
|
924
|
-
});
|
|
925
|
-
const { fromJSON } = serializer({
|
|
926
|
-
rootSchema: _bulkUpdateDataItemsResponse,
|
|
927
|
-
depSchemas: {},
|
|
928
|
-
fqdnTransformation: {
|
|
929
|
-
paths: [...['Array#results.dataItem']],
|
|
930
|
-
transformation: _toVeloEntity,
|
|
931
|
-
},
|
|
932
|
-
customTransformation: responseTransformation,
|
|
933
|
-
});
|
|
934
|
-
const payload = toAmbassadorRequest([options], ['dataItems.data']);
|
|
935
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkUpdateDataItems(payload);
|
|
936
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
937
|
-
try {
|
|
938
|
-
const result = yield httpClient.request(reqOpts);
|
|
939
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
940
|
-
return fromJSON(result.data, ['results.dataItem.data']);
|
|
941
|
-
}
|
|
942
|
-
catch (err) {
|
|
943
|
-
const transformedError = sdkTransformError(err, {
|
|
944
|
-
spreadPathsToArguments: {},
|
|
945
|
-
explicitPathsToArguments: {
|
|
946
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
947
|
-
dataItems: '$[0].dataItems',
|
|
948
|
-
returnEntity: '$[0].returnEntity',
|
|
949
|
-
},
|
|
950
|
-
singleArgumentUnchanged: false,
|
|
951
|
-
}, ['options']);
|
|
952
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
953
|
-
throw transformedError;
|
|
954
|
-
}
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* Inserts or updates multiple items in a collection.
|
|
959
|
-
*
|
|
960
|
-
*
|
|
961
|
-
* This function inserts or updates each item provided, depending on whether it already exists in the collection. For each item:
|
|
962
|
-
*
|
|
963
|
-
* + If you don't provide an ID, a new item is created.
|
|
964
|
-
*
|
|
965
|
-
* + If you provide an ID that doesn't exist in the collection, a new item is created with that ID.
|
|
966
|
-
*
|
|
967
|
-
* + If an item with the ID you provide already exists in the collection, that item is updated. When an item is updated, its `data._updatedDate` field is changed to the current date and time.
|
|
968
|
-
*
|
|
969
|
-
* > **Note:** When you provide an item with an ID that already exists in the collection, the item you provide completely replaces the existing item with that ID.
|
|
970
|
-
* > This means that all of the item's previous fields and values are lost.
|
|
971
|
-
* @public
|
|
972
|
-
* @documentationMaturity preview
|
|
973
|
-
* @requiredField options.dataCollectionId
|
|
974
|
-
* @requiredField options.dataItems
|
|
975
|
-
* @param options - Options for saving multiple items in a collection.
|
|
976
|
-
* @permissionScope Write Data Items
|
|
977
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
978
|
-
* @applicableIdentity APP
|
|
979
|
-
*/
|
|
980
|
-
export function bulkSaveDataItems(options) {
|
|
981
|
-
var _a, _b, _c;
|
|
982
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
983
|
-
const requestTransformation = {
|
|
984
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
985
|
-
dataItems: '$[0].dataItems',
|
|
986
|
-
returnEntity: '$[0].returnEntity',
|
|
987
|
-
};
|
|
988
|
-
const responseTransformation = '$';
|
|
989
|
-
// @ts-ignore
|
|
990
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
991
|
-
const { toAmbassadorRequest } = serializer({
|
|
992
|
-
rootSchema: _bulkSaveDataItemsRequest,
|
|
993
|
-
depSchemas: {},
|
|
994
|
-
fqdnTransformation: {
|
|
995
|
-
paths: [...['Array#dataItems']],
|
|
996
|
-
transformation: _fromVeloEntity,
|
|
997
|
-
},
|
|
998
|
-
customTransformation: requestTransformation,
|
|
999
|
-
});
|
|
1000
|
-
const { fromJSON } = serializer({
|
|
1001
|
-
rootSchema: _bulkSaveDataItemsResponse,
|
|
1002
|
-
depSchemas: {},
|
|
1003
|
-
fqdnTransformation: {
|
|
1004
|
-
paths: [...['Array#results.dataItem']],
|
|
1005
|
-
transformation: _toVeloEntity,
|
|
1006
|
-
},
|
|
1007
|
-
customTransformation: responseTransformation,
|
|
1008
|
-
});
|
|
1009
|
-
const payload = toAmbassadorRequest([options], ['dataItems.data']);
|
|
1010
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkSaveDataItems(payload);
|
|
1011
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1012
|
-
try {
|
|
1013
|
-
const result = yield httpClient.request(reqOpts);
|
|
1014
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1015
|
-
return fromJSON(result.data, ['results.dataItem.data']);
|
|
1016
|
-
}
|
|
1017
|
-
catch (err) {
|
|
1018
|
-
const transformedError = sdkTransformError(err, {
|
|
1019
|
-
spreadPathsToArguments: {},
|
|
1020
|
-
explicitPathsToArguments: {
|
|
1021
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1022
|
-
dataItems: '$[0].dataItems',
|
|
1023
|
-
returnEntity: '$[0].returnEntity',
|
|
1024
|
-
},
|
|
1025
|
-
singleArgumentUnchanged: false,
|
|
1026
|
-
}, ['options']);
|
|
1027
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1028
|
-
throw transformedError;
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Removes multiple items from a collection.
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
* If any items in other collections reference the removed items in reference or multi-reference fields, those fields are cleared.
|
|
1037
|
-
*
|
|
1038
|
-
* > **Note:** Once an item has been removed from a collection, it can't be restored.
|
|
1039
|
-
* @public
|
|
1040
|
-
* @documentationMaturity preview
|
|
1041
|
-
* @requiredField options
|
|
1042
|
-
* @requiredField options.dataCollectionId
|
|
1043
|
-
* @requiredField options.dataItemIds
|
|
1044
|
-
* @param options - Options for removing multiple items from a collection.
|
|
1045
|
-
* @permissionScope Write Data Items
|
|
1046
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1047
|
-
* @applicableIdentity APP
|
|
1048
|
-
*/
|
|
1049
|
-
export function bulkRemoveDataItems(options) {
|
|
1050
|
-
var _a, _b, _c;
|
|
1051
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1052
|
-
const requestTransformation = {
|
|
1053
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1054
|
-
dataItemIds: '$[0].dataItemIds',
|
|
1055
|
-
};
|
|
1056
|
-
const responseTransformation = '$';
|
|
1057
|
-
// @ts-ignore
|
|
1058
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1059
|
-
const { toAmbassadorRequest } = serializer({
|
|
1060
|
-
rootSchema: _bulkRemoveDataItemsRequest,
|
|
1061
|
-
depSchemas: {},
|
|
1062
|
-
fqdnTransformation: {
|
|
1063
|
-
paths: [],
|
|
1064
|
-
transformation: _fromVeloEntity,
|
|
1065
|
-
},
|
|
1066
|
-
customTransformation: requestTransformation,
|
|
1067
|
-
});
|
|
1068
|
-
const { fromJSON } = serializer({
|
|
1069
|
-
rootSchema: _bulkRemoveDataItemsResponse,
|
|
1070
|
-
depSchemas: {},
|
|
1071
|
-
fqdnTransformation: {
|
|
1072
|
-
paths: [...['Array#results.dataItem']],
|
|
1073
|
-
transformation: _toVeloEntity,
|
|
1074
|
-
},
|
|
1075
|
-
customTransformation: responseTransformation,
|
|
1076
|
-
});
|
|
1077
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1078
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkRemoveDataItems(payload);
|
|
1079
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1080
|
-
try {
|
|
1081
|
-
const result = yield httpClient.request(reqOpts);
|
|
1082
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1083
|
-
return fromJSON(result.data, ['results.dataItem.data']);
|
|
1084
|
-
}
|
|
1085
|
-
catch (err) {
|
|
1086
|
-
const transformedError = sdkTransformError(err, {
|
|
1087
|
-
spreadPathsToArguments: {},
|
|
1088
|
-
explicitPathsToArguments: {
|
|
1089
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1090
|
-
dataItemIds: '$[0].dataItemIds',
|
|
1091
|
-
},
|
|
1092
|
-
singleArgumentUnchanged: false,
|
|
1093
|
-
}, ['options']);
|
|
1094
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1095
|
-
throw transformedError;
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Retrieves the full items referenced in the specified field of an item.
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
* Reference and multi-reference fields refer to items in different collections.
|
|
1104
|
-
* Use this function to retrieve the full details of the referenced items themselves.
|
|
1105
|
-
*
|
|
1106
|
-
* For example, suppose you have a **Movies** collection with an **Actors** field that contains references to items in a **People** collection.
|
|
1107
|
-
* Querying the **Movies** collection using `queryReferencedDataItems()` returns the relevant **People** items referenced in the **Actors** field of the specified **Movie** item.
|
|
1108
|
-
* This gives you information from the **People** collection about each of the actors in the specified movie.
|
|
1109
|
-
*
|
|
1110
|
-
* > **Note**: When calling `queryReferencedDataItems()` following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
1111
|
-
* @public
|
|
1112
|
-
* @documentationMaturity preview
|
|
1113
|
-
* @requiredField options.dataCollectionId
|
|
1114
|
-
* @param options - Options for querying referenced data items.
|
|
1115
|
-
* @permissionScope Read Data Items
|
|
1116
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
1117
|
-
* @applicableIdentity APP
|
|
1118
|
-
*/
|
|
1119
|
-
export function queryReferencedDataItems(options) {
|
|
1120
|
-
var _a, _b, _c;
|
|
1121
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1122
|
-
const requestTransformation = {
|
|
1123
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1124
|
-
referringItemId: '$[0].referringItemId',
|
|
1125
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1126
|
-
order: '$[0].order',
|
|
1127
|
-
paging: '$[0].paging',
|
|
1128
|
-
cursorPaging: '$[0].cursorPaging',
|
|
1129
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
1130
|
-
consistentRead: '$[0].consistentRead',
|
|
1131
|
-
language: '$[0].language',
|
|
1132
|
-
};
|
|
1133
|
-
const responseTransformation = '$';
|
|
1134
|
-
// @ts-ignore
|
|
1135
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1136
|
-
const { toAmbassadorRequest } = serializer({
|
|
1137
|
-
rootSchema: _queryReferencedDataItemsRequest,
|
|
1138
|
-
depSchemas: {},
|
|
1139
|
-
fqdnTransformation: {
|
|
1140
|
-
paths: [],
|
|
1141
|
-
transformation: _fromVeloEntity,
|
|
1142
|
-
},
|
|
1143
|
-
customTransformation: requestTransformation,
|
|
1144
|
-
});
|
|
1145
|
-
const { fromJSON } = serializer({
|
|
1146
|
-
rootSchema: _queryReferencedDataItemsResponse,
|
|
1147
|
-
depSchemas: {},
|
|
1148
|
-
fqdnTransformation: {
|
|
1149
|
-
paths: [...['Array#results.dataItem']],
|
|
1150
|
-
transformation: _toVeloEntity,
|
|
1151
|
-
},
|
|
1152
|
-
customTransformation: responseTransformation,
|
|
1153
|
-
});
|
|
1154
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1155
|
-
const reqOpts = ambassadorWixDataV2DataItem.queryReferencedDataItems(payload);
|
|
1156
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1157
|
-
try {
|
|
1158
|
-
const result = yield httpClient.request(reqOpts);
|
|
1159
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1160
|
-
return fromJSON(result.data, ['results.dataItem.data']);
|
|
1161
|
-
}
|
|
1162
|
-
catch (err) {
|
|
1163
|
-
const transformedError = sdkTransformError(err, {
|
|
1164
|
-
spreadPathsToArguments: {},
|
|
1165
|
-
explicitPathsToArguments: {
|
|
1166
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1167
|
-
referringItemId: '$[0].referringItemId',
|
|
1168
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1169
|
-
order: '$[0].order',
|
|
1170
|
-
paging: '$[0].paging',
|
|
1171
|
-
cursorPaging: '$[0].cursorPaging',
|
|
1172
|
-
returnTotalCount: '$[0].returnTotalCount',
|
|
1173
|
-
consistentRead: '$[0].consistentRead',
|
|
1174
|
-
language: '$[0].language',
|
|
1175
|
-
},
|
|
1176
|
-
singleArgumentUnchanged: false,
|
|
1177
|
-
}, ['options']);
|
|
1178
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1179
|
-
throw transformedError;
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Checks whether a field in a referring item contains a reference to a specified item.
|
|
1185
|
-
*
|
|
1186
|
-
* > **Note**: When calling `isReferencedDataItem()` following an update to your collection, the result returned may not reflect the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
1187
|
-
* @public
|
|
1188
|
-
* @documentationMaturity preview
|
|
1189
|
-
* @requiredField options.dataCollectionId
|
|
1190
|
-
* @requiredField options.referencedItemId
|
|
1191
|
-
* @requiredField options.referringItemFieldName
|
|
1192
|
-
* @requiredField options.referringItemId
|
|
1193
|
-
* @param options - Options for checking whether a field contains a reference to an item.
|
|
1194
|
-
* @permissionScope Read Data Items
|
|
1195
|
-
* @permissionScopeId SCOPE.DC-DATA.READ
|
|
1196
|
-
* @applicableIdentity APP
|
|
1197
|
-
*/
|
|
1198
|
-
export function isReferencedDataItem(options) {
|
|
1199
|
-
var _a, _b, _c;
|
|
1200
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1201
|
-
const requestTransformation = {
|
|
1202
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1203
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1204
|
-
referringItemId: '$[0].referringItemId',
|
|
1205
|
-
referencedItemId: '$[0].referencedItemId',
|
|
1206
|
-
consistentRead: '$[0].consistentRead',
|
|
1207
|
-
};
|
|
1208
|
-
const responseTransformation = '$';
|
|
1209
|
-
// @ts-ignore
|
|
1210
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1211
|
-
const { toAmbassadorRequest } = serializer({
|
|
1212
|
-
rootSchema: _isReferencedDataItemRequest,
|
|
1213
|
-
depSchemas: {},
|
|
1214
|
-
fqdnTransformation: {
|
|
1215
|
-
paths: [],
|
|
1216
|
-
transformation: _fromVeloEntity,
|
|
1217
|
-
},
|
|
1218
|
-
customTransformation: requestTransformation,
|
|
1219
|
-
});
|
|
1220
|
-
const { fromJSON } = serializer({
|
|
1221
|
-
rootSchema: _isReferencedDataItemResponse,
|
|
1222
|
-
depSchemas: {},
|
|
1223
|
-
fqdnTransformation: {
|
|
1224
|
-
paths: [],
|
|
1225
|
-
transformation: _toVeloEntity,
|
|
1226
|
-
},
|
|
1227
|
-
customTransformation: responseTransformation,
|
|
1228
|
-
});
|
|
1229
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1230
|
-
const reqOpts = ambassadorWixDataV2DataItem.isReferencedDataItem(payload);
|
|
1231
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1232
|
-
try {
|
|
1233
|
-
const result = yield httpClient.request(reqOpts);
|
|
1234
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1235
|
-
return fromJSON(result.data, []);
|
|
1236
|
-
}
|
|
1237
|
-
catch (err) {
|
|
1238
|
-
const transformedError = sdkTransformError(err, {
|
|
1239
|
-
spreadPathsToArguments: {},
|
|
1240
|
-
explicitPathsToArguments: {
|
|
1241
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1242
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1243
|
-
referringItemId: '$[0].referringItemId',
|
|
1244
|
-
referencedItemId: '$[0].referencedItemId',
|
|
1245
|
-
consistentRead: '$[0].consistentRead',
|
|
1246
|
-
},
|
|
1247
|
-
singleArgumentUnchanged: false,
|
|
1248
|
-
}, ['options']);
|
|
1249
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1250
|
-
throw transformedError;
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
/**
|
|
1255
|
-
* Inserts a reference in the specified field in an item in a collection.
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1258
|
-
* A reference in `options.dataItemReference` specifies a referring item's ID, the field in which to insert the reference, and the ID of the referenced item.
|
|
1259
|
-
* @public
|
|
1260
|
-
* @documentationMaturity preview
|
|
1261
|
-
* @requiredField options.dataCollectionId
|
|
1262
|
-
* @requiredField options.dataItemReference.referencedItemId
|
|
1263
|
-
* @requiredField options.dataItemReference.referringItemFieldName
|
|
1264
|
-
* @requiredField options.dataItemReference.referringItemId
|
|
1265
|
-
* @param options - Options for inserting a reference.
|
|
1266
|
-
* @permissionScope Write Data Items
|
|
1267
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1268
|
-
* @applicableIdentity APP
|
|
1269
|
-
*/
|
|
1270
|
-
export function insertDataItemReference(options) {
|
|
1271
|
-
var _a, _b, _c;
|
|
1272
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1273
|
-
const requestTransformation = {
|
|
1274
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1275
|
-
dataItemReference: '$[0].dataItemReference',
|
|
1276
|
-
};
|
|
1277
|
-
const responseTransformation = '$';
|
|
1278
|
-
// @ts-ignore
|
|
1279
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1280
|
-
const { toAmbassadorRequest } = serializer({
|
|
1281
|
-
rootSchema: _insertDataItemReferenceRequest,
|
|
1282
|
-
depSchemas: {},
|
|
1283
|
-
fqdnTransformation: {
|
|
1284
|
-
paths: [],
|
|
1285
|
-
transformation: _fromVeloEntity,
|
|
1286
|
-
},
|
|
1287
|
-
customTransformation: requestTransformation,
|
|
1288
|
-
});
|
|
1289
|
-
const { fromJSON } = serializer({
|
|
1290
|
-
rootSchema: _insertDataItemReferenceResponse,
|
|
1291
|
-
depSchemas: {},
|
|
1292
|
-
fqdnTransformation: {
|
|
1293
|
-
paths: [],
|
|
1294
|
-
transformation: _toVeloEntity,
|
|
1295
|
-
},
|
|
1296
|
-
customTransformation: responseTransformation,
|
|
1297
|
-
});
|
|
1298
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1299
|
-
const reqOpts = ambassadorWixDataV2DataItem.insertDataItemReference(payload);
|
|
1300
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1301
|
-
try {
|
|
1302
|
-
const result = yield httpClient.request(reqOpts);
|
|
1303
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1304
|
-
return fromJSON(result.data, []);
|
|
1305
|
-
}
|
|
1306
|
-
catch (err) {
|
|
1307
|
-
const transformedError = sdkTransformError(err, {
|
|
1308
|
-
spreadPathsToArguments: {},
|
|
1309
|
-
explicitPathsToArguments: {
|
|
1310
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1311
|
-
dataItemReference: '$[0].dataItemReference',
|
|
1312
|
-
},
|
|
1313
|
-
singleArgumentUnchanged: false,
|
|
1314
|
-
}, ['options']);
|
|
1315
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1316
|
-
throw transformedError;
|
|
1317
|
-
}
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* Removes the specified reference from the specified field.
|
|
1322
|
-
* @public
|
|
1323
|
-
* @documentationMaturity preview
|
|
1324
|
-
* @requiredField options
|
|
1325
|
-
* @requiredField options.dataCollectionId
|
|
1326
|
-
* @requiredField options.dataItemReference
|
|
1327
|
-
* @requiredField options.dataItemReference.referencedItemId
|
|
1328
|
-
* @requiredField options.dataItemReference.referringItemFieldName
|
|
1329
|
-
* @requiredField options.dataItemReference.referringItemId
|
|
1330
|
-
* @param options - Options for removing a reference.
|
|
1331
|
-
* @permissionScope Write Data Items
|
|
1332
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1333
|
-
* @applicableIdentity APP
|
|
1334
|
-
*/
|
|
1335
|
-
export function removeDataItemReference(options) {
|
|
1336
|
-
var _a, _b, _c;
|
|
1337
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1338
|
-
const requestTransformation = {
|
|
1339
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1340
|
-
dataItemReference: '$[0].dataItemReference',
|
|
1341
|
-
};
|
|
1342
|
-
const responseTransformation = '$';
|
|
1343
|
-
// @ts-ignore
|
|
1344
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1345
|
-
const { toAmbassadorRequest } = serializer({
|
|
1346
|
-
rootSchema: _removeDataItemReferenceRequest,
|
|
1347
|
-
depSchemas: {},
|
|
1348
|
-
fqdnTransformation: {
|
|
1349
|
-
paths: [],
|
|
1350
|
-
transformation: _fromVeloEntity,
|
|
1351
|
-
},
|
|
1352
|
-
customTransformation: requestTransformation,
|
|
1353
|
-
});
|
|
1354
|
-
const { fromJSON } = serializer({
|
|
1355
|
-
rootSchema: _removeDataItemReferenceResponse,
|
|
1356
|
-
depSchemas: {},
|
|
1357
|
-
fqdnTransformation: {
|
|
1358
|
-
paths: [],
|
|
1359
|
-
transformation: _toVeloEntity,
|
|
1360
|
-
},
|
|
1361
|
-
customTransformation: responseTransformation,
|
|
1362
|
-
});
|
|
1363
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1364
|
-
const reqOpts = ambassadorWixDataV2DataItem.removeDataItemReference(payload);
|
|
1365
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1366
|
-
try {
|
|
1367
|
-
const result = yield httpClient.request(reqOpts);
|
|
1368
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1369
|
-
return fromJSON(result.data, []);
|
|
1370
|
-
}
|
|
1371
|
-
catch (err) {
|
|
1372
|
-
const transformedError = sdkTransformError(err, {
|
|
1373
|
-
spreadPathsToArguments: {},
|
|
1374
|
-
explicitPathsToArguments: {
|
|
1375
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1376
|
-
dataItemReference: '$[0].dataItemReference',
|
|
1377
|
-
},
|
|
1378
|
-
singleArgumentUnchanged: false,
|
|
1379
|
-
}, ['options']);
|
|
1380
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1381
|
-
throw transformedError;
|
|
1382
|
-
}
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Inserts one or more references in the specified fields of items in a collection.
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
* This endpoint adds one or more references to a collection.
|
|
1390
|
-
* Each new reference in `options.dataItemReferences` specifies a referring item's ID, the field in which to insert the reference, and the ID of the referenced item.
|
|
1391
|
-
* @public
|
|
1392
|
-
* @documentationMaturity preview
|
|
1393
|
-
* @requiredField options.dataCollectionId
|
|
1394
|
-
* @requiredField options.dataItemReferences
|
|
1395
|
-
* @requiredField options.dataItemReferences.referencedItemId
|
|
1396
|
-
* @requiredField options.dataItemReferences.referringItemFieldName
|
|
1397
|
-
* @requiredField options.dataItemReferences.referringItemId
|
|
1398
|
-
* @param options - Options for inserting one or more references.
|
|
1399
|
-
* @permissionScope Write Data Items
|
|
1400
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1401
|
-
* @applicableIdentity APP
|
|
1402
|
-
*/
|
|
1403
|
-
export function bulkInsertDataItemReferences(options) {
|
|
1404
|
-
var _a, _b, _c;
|
|
1405
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1406
|
-
const requestTransformation = {
|
|
1407
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1408
|
-
dataItemReferences: '$[0].dataItemReferences',
|
|
1409
|
-
returnEntity: '$[0].returnEntity',
|
|
1410
|
-
};
|
|
1411
|
-
const responseTransformation = '$';
|
|
1412
|
-
// @ts-ignore
|
|
1413
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1414
|
-
const { toAmbassadorRequest } = serializer({
|
|
1415
|
-
rootSchema: _bulkInsertDataItemReferencesRequest,
|
|
1416
|
-
depSchemas: {},
|
|
1417
|
-
fqdnTransformation: {
|
|
1418
|
-
paths: [],
|
|
1419
|
-
transformation: _fromVeloEntity,
|
|
1420
|
-
},
|
|
1421
|
-
customTransformation: requestTransformation,
|
|
1422
|
-
});
|
|
1423
|
-
const { fromJSON } = serializer({
|
|
1424
|
-
rootSchema: _bulkInsertDataItemReferencesResponse,
|
|
1425
|
-
depSchemas: {},
|
|
1426
|
-
fqdnTransformation: {
|
|
1427
|
-
paths: [],
|
|
1428
|
-
transformation: _toVeloEntity,
|
|
1429
|
-
},
|
|
1430
|
-
customTransformation: responseTransformation,
|
|
1431
|
-
});
|
|
1432
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1433
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkInsertDataItemReferences(payload);
|
|
1434
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1435
|
-
try {
|
|
1436
|
-
const result = yield httpClient.request(reqOpts);
|
|
1437
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1438
|
-
return fromJSON(result.data, []);
|
|
1439
|
-
}
|
|
1440
|
-
catch (err) {
|
|
1441
|
-
const transformedError = sdkTransformError(err, {
|
|
1442
|
-
spreadPathsToArguments: {},
|
|
1443
|
-
explicitPathsToArguments: {
|
|
1444
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1445
|
-
dataItemReferences: '$[0].dataItemReferences',
|
|
1446
|
-
returnEntity: '$[0].returnEntity',
|
|
1447
|
-
},
|
|
1448
|
-
singleArgumentUnchanged: false,
|
|
1449
|
-
}, ['options']);
|
|
1450
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1451
|
-
throw transformedError;
|
|
1452
|
-
}
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Removes one or more references.
|
|
1457
|
-
* @public
|
|
1458
|
-
* @documentationMaturity preview
|
|
1459
|
-
* @requiredField options
|
|
1460
|
-
* @requiredField options.dataCollectionId
|
|
1461
|
-
* @requiredField options.dataItemReferences
|
|
1462
|
-
* @requiredField options.dataItemReferences.referencedItemId
|
|
1463
|
-
* @requiredField options.dataItemReferences.referringItemFieldName
|
|
1464
|
-
* @requiredField options.dataItemReferences.referringItemId
|
|
1465
|
-
* @param options - Options for removing one or more references.
|
|
1466
|
-
* @permissionScope Write Data Items
|
|
1467
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1468
|
-
* @applicableIdentity APP
|
|
1469
|
-
*/
|
|
1470
|
-
export function bulkRemoveDataItemReferences(options) {
|
|
1471
|
-
var _a, _b, _c;
|
|
1472
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1473
|
-
const requestTransformation = {
|
|
1474
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1475
|
-
dataItemReferences: '$[0].dataItemReferences',
|
|
1476
|
-
};
|
|
1477
|
-
const responseTransformation = '$';
|
|
1478
|
-
// @ts-ignore
|
|
1479
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1480
|
-
const { toAmbassadorRequest } = serializer({
|
|
1481
|
-
rootSchema: _bulkRemoveDataItemReferencesRequest,
|
|
1482
|
-
depSchemas: {},
|
|
1483
|
-
fqdnTransformation: {
|
|
1484
|
-
paths: [],
|
|
1485
|
-
transformation: _fromVeloEntity,
|
|
1486
|
-
},
|
|
1487
|
-
customTransformation: requestTransformation,
|
|
1488
|
-
});
|
|
1489
|
-
const { fromJSON } = serializer({
|
|
1490
|
-
rootSchema: _bulkRemoveDataItemReferencesResponse,
|
|
1491
|
-
depSchemas: {},
|
|
1492
|
-
fqdnTransformation: {
|
|
1493
|
-
paths: [],
|
|
1494
|
-
transformation: _toVeloEntity,
|
|
1495
|
-
},
|
|
1496
|
-
customTransformation: responseTransformation,
|
|
1497
|
-
});
|
|
1498
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1499
|
-
const reqOpts = ambassadorWixDataV2DataItem.bulkRemoveDataItemReferences(payload);
|
|
1500
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1501
|
-
try {
|
|
1502
|
-
const result = yield httpClient.request(reqOpts);
|
|
1503
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1504
|
-
return fromJSON(result.data, []);
|
|
1505
|
-
}
|
|
1506
|
-
catch (err) {
|
|
1507
|
-
const transformedError = sdkTransformError(err, {
|
|
1508
|
-
spreadPathsToArguments: {},
|
|
1509
|
-
explicitPathsToArguments: {
|
|
1510
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1511
|
-
dataItemReferences: '$[0].dataItemReferences',
|
|
1512
|
-
},
|
|
1513
|
-
singleArgumentUnchanged: false,
|
|
1514
|
-
}, ['options']);
|
|
1515
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1516
|
-
throw transformedError;
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
* Replaces references in a specified field of a specified data item.
|
|
1522
|
-
*
|
|
1523
|
-
*
|
|
1524
|
-
* This function replaces the existing reference or references contained in the field specified in `options.referringItemFieldName` within the data item specified in `options.referringItemId`.
|
|
1525
|
-
* The function removes existing references and in their place it adds references to the items specified in `options.newReferencedItemIds`.
|
|
1526
|
-
*
|
|
1527
|
-
* > **Note:** If you pass an empty array in `options.newReferencedItemIds`, all existing references are removed.
|
|
1528
|
-
* @public
|
|
1529
|
-
* @documentationMaturity preview
|
|
1530
|
-
* @requiredField options.dataCollectionId
|
|
1531
|
-
* @requiredField options.referringItemFieldName
|
|
1532
|
-
* @requiredField options.referringItemId
|
|
1533
|
-
* @param options - Options for replacing references.
|
|
1534
|
-
* @permissionScope Write Data Items
|
|
1535
|
-
* @permissionScopeId SCOPE.DC-DATA.WRITE
|
|
1536
|
-
* @applicableIdentity APP
|
|
1537
|
-
*/
|
|
1538
|
-
export function replaceDataItemReferences(options) {
|
|
1539
|
-
var _a, _b, _c;
|
|
1540
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
1541
|
-
const requestTransformation = {
|
|
1542
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1543
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1544
|
-
referringItemId: '$[0].referringItemId',
|
|
1545
|
-
newReferencedItemIds: '$[0].newReferencedItemIds',
|
|
1546
|
-
};
|
|
1547
|
-
const responseTransformation = '$';
|
|
1548
|
-
// @ts-ignore
|
|
1549
|
-
const { httpClient, sideEffects } = arguments[1];
|
|
1550
|
-
const { toAmbassadorRequest } = serializer({
|
|
1551
|
-
rootSchema: _replaceDataItemReferencesRequest,
|
|
1552
|
-
depSchemas: {},
|
|
1553
|
-
fqdnTransformation: {
|
|
1554
|
-
paths: [],
|
|
1555
|
-
transformation: _fromVeloEntity,
|
|
1556
|
-
},
|
|
1557
|
-
customTransformation: requestTransformation,
|
|
1558
|
-
});
|
|
1559
|
-
const { fromJSON } = serializer({
|
|
1560
|
-
rootSchema: _replaceDataItemReferencesResponse,
|
|
1561
|
-
depSchemas: {},
|
|
1562
|
-
fqdnTransformation: {
|
|
1563
|
-
paths: [],
|
|
1564
|
-
transformation: _toVeloEntity,
|
|
1565
|
-
},
|
|
1566
|
-
customTransformation: responseTransformation,
|
|
1567
|
-
});
|
|
1568
|
-
const payload = toAmbassadorRequest([options], []);
|
|
1569
|
-
const reqOpts = ambassadorWixDataV2DataItem.replaceDataItemReferences(payload);
|
|
1570
|
-
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
1571
|
-
try {
|
|
1572
|
-
const result = yield httpClient.request(reqOpts);
|
|
1573
|
-
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1574
|
-
return fromJSON(result.data, []);
|
|
1575
|
-
}
|
|
1576
|
-
catch (err) {
|
|
1577
|
-
const transformedError = sdkTransformError(err, {
|
|
1578
|
-
spreadPathsToArguments: {},
|
|
1579
|
-
explicitPathsToArguments: {
|
|
1580
|
-
dataCollectionId: '$[0].dataCollectionId',
|
|
1581
|
-
referringItemFieldName: '$[0].referringItemFieldName',
|
|
1582
|
-
referringItemId: '$[0].referringItemId',
|
|
1583
|
-
newReferencedItemIds: '$[0].newReferencedItemIds',
|
|
1584
|
-
},
|
|
1585
|
-
singleArgumentUnchanged: false,
|
|
1586
|
-
}, ['options']);
|
|
1587
|
-
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1588
|
-
throw transformedError;
|
|
1589
|
-
}
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
//# sourceMappingURL=data-v2-data-item.universal.js.map
|