@wix/data 1.0.0

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