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