@uniformdev/tms-sdk 20.72.3-alpha.5 → 20.72.3-alpha.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,8 +20,134 @@ var __copyProps = (to, from, except, desc) => {
15
20
  }
16
21
  return to;
17
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
18
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
32
 
33
+ // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
34
+ var require_yocto_queue = __commonJS({
35
+ "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
36
+ "use strict";
37
+ var Node = class {
38
+ /// value;
39
+ /// next;
40
+ constructor(value) {
41
+ this.value = value;
42
+ this.next = void 0;
43
+ }
44
+ };
45
+ var Queue = class {
46
+ // TODO: Use private class fields when targeting Node.js 12.
47
+ // #_head;
48
+ // #_tail;
49
+ // #_size;
50
+ constructor() {
51
+ this.clear();
52
+ }
53
+ enqueue(value) {
54
+ const node = new Node(value);
55
+ if (this._head) {
56
+ this._tail.next = node;
57
+ this._tail = node;
58
+ } else {
59
+ this._head = node;
60
+ this._tail = node;
61
+ }
62
+ this._size++;
63
+ }
64
+ dequeue() {
65
+ const current = this._head;
66
+ if (!current) {
67
+ return;
68
+ }
69
+ this._head = this._head.next;
70
+ this._size--;
71
+ return current.value;
72
+ }
73
+ clear() {
74
+ this._head = void 0;
75
+ this._tail = void 0;
76
+ this._size = 0;
77
+ }
78
+ get size() {
79
+ return this._size;
80
+ }
81
+ *[Symbol.iterator]() {
82
+ let current = this._head;
83
+ while (current) {
84
+ yield current.value;
85
+ current = current.next;
86
+ }
87
+ }
88
+ };
89
+ module2.exports = Queue;
90
+ }
91
+ });
92
+
93
+ // ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
94
+ var require_p_limit = __commonJS({
95
+ "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
96
+ "use strict";
97
+ var Queue = require_yocto_queue();
98
+ var pLimit2 = (concurrency) => {
99
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
100
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
101
+ }
102
+ const queue = new Queue();
103
+ let activeCount = 0;
104
+ const next = () => {
105
+ activeCount--;
106
+ if (queue.size > 0) {
107
+ queue.dequeue()();
108
+ }
109
+ };
110
+ const run = async (fn, resolve, ...args) => {
111
+ activeCount++;
112
+ const result = (async () => fn(...args))();
113
+ resolve(result);
114
+ try {
115
+ await result;
116
+ } catch (e) {
117
+ }
118
+ next();
119
+ };
120
+ const enqueue = (fn, resolve, ...args) => {
121
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
122
+ (async () => {
123
+ await Promise.resolve();
124
+ if (activeCount < concurrency && queue.size > 0) {
125
+ queue.dequeue()();
126
+ }
127
+ })();
128
+ };
129
+ const generator = (fn, ...args) => new Promise((resolve) => {
130
+ enqueue(fn, resolve, ...args);
131
+ });
132
+ Object.defineProperties(generator, {
133
+ activeCount: {
134
+ get: () => activeCount
135
+ },
136
+ pendingCount: {
137
+ get: () => queue.size
138
+ },
139
+ clearQueue: {
140
+ value: () => {
141
+ queue.clear();
142
+ }
143
+ }
144
+ });
145
+ return generator;
146
+ };
147
+ module2.exports = pLimit2;
148
+ }
149
+ });
150
+
20
151
  // src/index.ts
21
152
  var index_exports = {};
22
153
  __export(index_exports, {
@@ -805,6 +936,421 @@ var preprocessTargetValue = (parameter, value) => {
805
936
 
806
937
  // src/getCompositionForTranslation.ts
807
938
  var import_canvas3 = require("@uniformdev/canvas");
939
+
940
+ // ../context/dist/api/api.mjs
941
+ var import_p_limit = __toESM(require_p_limit(), 1);
942
+ var __defProp2 = Object.defineProperty;
943
+ var __typeError = (msg) => {
944
+ throw TypeError(msg);
945
+ };
946
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
947
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
948
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
949
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
950
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
951
+ var defaultLimitPolicy = (0, import_p_limit.default)(6);
952
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
953
+ var ApiClientError = class _ApiClientError extends Error {
954
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
955
+ super(
956
+ `${errorMessage}
957
+ ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
958
+ );
959
+ __publicField(this, "errorMessage", errorMessage);
960
+ __publicField(this, "fetchMethod", fetchMethod);
961
+ __publicField(this, "fetchUri", fetchUri);
962
+ __publicField(this, "statusCode", statusCode);
963
+ __publicField(this, "statusText", statusText);
964
+ __publicField(this, "requestId", requestId);
965
+ Object.setPrototypeOf(this, _ApiClientError.prototype);
966
+ }
967
+ };
968
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
969
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
970
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
971
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
972
+ }
973
+ };
974
+ var ApiClient = class _ApiClient {
975
+ constructor(options) {
976
+ __publicField(this, "options");
977
+ var _a, _b, _c, _d, _e;
978
+ if (!options.apiKey && !options.bearerToken) {
979
+ throw new Error("You must provide an API key or a bearer token");
980
+ }
981
+ let leFetch = options.fetch;
982
+ if (!leFetch) {
983
+ if (typeof window !== "undefined") {
984
+ leFetch = window.fetch.bind(window);
985
+ } else if (typeof fetch !== "undefined") {
986
+ leFetch = fetch;
987
+ } else {
988
+ throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
989
+ }
990
+ }
991
+ this.options = {
992
+ ...options,
993
+ fetch: leFetch,
994
+ apiHost: this.ensureApiHost(options.apiHost),
995
+ apiKey: (_a = options.apiKey) != null ? _a : null,
996
+ projectId: (_b = options.projectId) != null ? _b : null,
997
+ bearerToken: (_c = options.bearerToken) != null ? _c : null,
998
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
999
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
1000
+ };
1001
+ }
1002
+ async apiClient(fetchUri, options) {
1003
+ return (await this.apiClientWithResponse(fetchUri, options)).body;
1004
+ }
1005
+ async apiClientWithResponse(fetchUri, options) {
1006
+ return this.options.limitPolicy(async () => {
1007
+ var _a, _b;
1008
+ const coreHeaders = this.options.apiKey ? {
1009
+ "x-api-key": this.options.apiKey
1010
+ } : {
1011
+ Authorization: `Bearer ${this.options.bearerToken}`
1012
+ };
1013
+ if (this.options.bypassCache) {
1014
+ coreHeaders["x-bypass-cache"] = "true";
1015
+ }
1016
+ const { fetch: fetch2, signal } = this.options;
1017
+ const callApi = () => fetch2(fetchUri.toString(), {
1018
+ ...options,
1019
+ signal,
1020
+ headers: {
1021
+ ...options == null ? void 0 : options.headers,
1022
+ ...coreHeaders
1023
+ }
1024
+ });
1025
+ const apiResponse = await handleRateLimits(callApi);
1026
+ if (!apiResponse.ok) {
1027
+ let message = "";
1028
+ try {
1029
+ const responseText = await apiResponse.text();
1030
+ try {
1031
+ const parsed = JSON.parse(responseText);
1032
+ if (parsed.errorMessage) {
1033
+ message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
1034
+ } else {
1035
+ message = responseText;
1036
+ }
1037
+ } catch (e) {
1038
+ message = responseText;
1039
+ }
1040
+ } catch (e) {
1041
+ message = `General error`;
1042
+ }
1043
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
1044
+ throw new BearerTokenNotValidOrExpiredError(
1045
+ message,
1046
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
1047
+ fetchUri.toString(),
1048
+ apiResponse.status,
1049
+ apiResponse.statusText,
1050
+ _ApiClient.getRequestId(apiResponse)
1051
+ );
1052
+ }
1053
+ throw new ApiClientError(
1054
+ message,
1055
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
1056
+ fetchUri.toString(),
1057
+ apiResponse.status,
1058
+ apiResponse.statusText,
1059
+ _ApiClient.getRequestId(apiResponse)
1060
+ );
1061
+ }
1062
+ if (options == null ? void 0 : options.expectNoContent) {
1063
+ return { response: apiResponse, body: null };
1064
+ }
1065
+ return {
1066
+ response: apiResponse,
1067
+ body: await apiResponse.json()
1068
+ };
1069
+ });
1070
+ }
1071
+ createUrl(path, queryParams, hostOverride) {
1072
+ const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
1073
+ Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
1074
+ var _a;
1075
+ if (typeof value !== "undefined" && value !== null) {
1076
+ url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
1077
+ }
1078
+ });
1079
+ return url;
1080
+ }
1081
+ ensureApiHost(apiHost) {
1082
+ if (!apiHost) return "https://uniform.app";
1083
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
1084
+ throw new Error('Your apiHost must start with "http"');
1085
+ }
1086
+ if (apiHost.indexOf("/", 8) > -1) {
1087
+ throw new Error("Your apiHost must not contain a path element after the domain");
1088
+ }
1089
+ if (apiHost.indexOf("?") > -1) {
1090
+ throw new Error("Your apiHost must not contain a query string");
1091
+ }
1092
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
1093
+ apiHost = apiHost.substring(0, apiHost.length - 1);
1094
+ }
1095
+ return apiHost;
1096
+ }
1097
+ static getRequestId(response) {
1098
+ const apigRequestId = response.headers.get("apigw-requestid");
1099
+ if (apigRequestId) {
1100
+ return apigRequestId;
1101
+ }
1102
+ return void 0;
1103
+ }
1104
+ };
1105
+ async function handleRateLimits(callApi) {
1106
+ var _a;
1107
+ const backoffRetries = 5;
1108
+ let backoffRetriesLeft = backoffRetries;
1109
+ let response;
1110
+ while (backoffRetriesLeft > 0) {
1111
+ response = await callApi();
1112
+ if (response.status !== 429) {
1113
+ break;
1114
+ }
1115
+ let resetWait = 0;
1116
+ try {
1117
+ const responseClone = response.clone();
1118
+ const dateHeader = responseClone.headers.get("date");
1119
+ const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
1120
+ const body = await responseClone.json();
1121
+ const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
1122
+ if (typeof serverTime === "number" && typeof resetTime === "number") {
1123
+ resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
1124
+ }
1125
+ } catch (e) {
1126
+ }
1127
+ const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
1128
+ const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
1129
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
1130
+ backoffRetriesLeft -= 1;
1131
+ }
1132
+ return response;
1133
+ }
1134
+ var _url;
1135
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
1136
+ constructor(options) {
1137
+ super(options);
1138
+ }
1139
+ /** Fetches all aggregates for a project */
1140
+ async get(options) {
1141
+ const { projectId } = this.options;
1142
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
1143
+ return await this.apiClient(fetchUri);
1144
+ }
1145
+ /** Updates or creates (based on id) an Aggregate */
1146
+ async upsert(body) {
1147
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
1148
+ await this.apiClient(fetchUri, {
1149
+ method: "PUT",
1150
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1151
+ expectNoContent: true
1152
+ });
1153
+ }
1154
+ /** Deletes an Aggregate */
1155
+ async remove(body) {
1156
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
1157
+ await this.apiClient(fetchUri, {
1158
+ method: "DELETE",
1159
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1160
+ expectNoContent: true
1161
+ });
1162
+ }
1163
+ };
1164
+ _url = /* @__PURE__ */ new WeakMap();
1165
+ __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
1166
+ var _url2;
1167
+ var _DimensionClient = class _DimensionClient2 extends ApiClient {
1168
+ constructor(options) {
1169
+ super(options);
1170
+ }
1171
+ /** Fetches the known score dimensions for a project */
1172
+ async get(options) {
1173
+ const { projectId } = this.options;
1174
+ const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
1175
+ return await this.apiClient(fetchUri);
1176
+ }
1177
+ };
1178
+ _url2 = /* @__PURE__ */ new WeakMap();
1179
+ __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
1180
+ var _url3;
1181
+ var _valueUrl;
1182
+ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
1183
+ constructor(options) {
1184
+ super(options);
1185
+ }
1186
+ /** Fetches all enrichments and values for a project, grouped by category */
1187
+ async get(options) {
1188
+ const { projectId } = this.options;
1189
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
1190
+ return await this.apiClient(fetchUri);
1191
+ }
1192
+ /** Updates or creates (based on id) an enrichment category */
1193
+ async upsertCategory(body) {
1194
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
1195
+ await this.apiClient(fetchUri, {
1196
+ method: "PUT",
1197
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1198
+ expectNoContent: true
1199
+ });
1200
+ }
1201
+ /** Deletes an enrichment category */
1202
+ async removeCategory(body) {
1203
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
1204
+ await this.apiClient(fetchUri, {
1205
+ method: "DELETE",
1206
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1207
+ expectNoContent: true
1208
+ });
1209
+ }
1210
+ /** Updates or creates (based on id) an enrichment value within an enrichment category */
1211
+ async upsertValue(body) {
1212
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
1213
+ await this.apiClient(fetchUri, {
1214
+ method: "PUT",
1215
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1216
+ expectNoContent: true
1217
+ });
1218
+ }
1219
+ /** Deletes an enrichment value within an enrichment category. The category is left alone. */
1220
+ async removeValue(body) {
1221
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
1222
+ await this.apiClient(fetchUri, {
1223
+ method: "DELETE",
1224
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1225
+ expectNoContent: true
1226
+ });
1227
+ }
1228
+ };
1229
+ _url3 = /* @__PURE__ */ new WeakMap();
1230
+ _valueUrl = /* @__PURE__ */ new WeakMap();
1231
+ __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
1232
+ __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
1233
+ var _url4;
1234
+ var _ManifestClient = class _ManifestClient2 extends ApiClient {
1235
+ constructor(options) {
1236
+ super(options);
1237
+ }
1238
+ /** Fetches the Context manifest for a project */
1239
+ async get(options) {
1240
+ const { projectId } = this.options;
1241
+ const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
1242
+ return await this.apiClient(fetchUri);
1243
+ }
1244
+ /** Publishes the Context manifest for a project */
1245
+ async publish() {
1246
+ const { projectId } = this.options;
1247
+ const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
1248
+ await this.apiClient(fetchUri, {
1249
+ method: "POST",
1250
+ expectNoContent: true
1251
+ });
1252
+ }
1253
+ };
1254
+ _url4 = /* @__PURE__ */ new WeakMap();
1255
+ __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
1256
+ var _url5;
1257
+ var _QuirkClient = class _QuirkClient2 extends ApiClient {
1258
+ constructor(options) {
1259
+ super(options);
1260
+ }
1261
+ /** Fetches all Quirks for a project */
1262
+ async get(options) {
1263
+ const { projectId } = this.options;
1264
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
1265
+ return await this.apiClient(fetchUri);
1266
+ }
1267
+ /** Updates or creates (based on id) a Quirk */
1268
+ async upsert(body) {
1269
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
1270
+ await this.apiClient(fetchUri, {
1271
+ method: "PUT",
1272
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1273
+ expectNoContent: true
1274
+ });
1275
+ }
1276
+ /** Deletes a Quirk */
1277
+ async remove(body) {
1278
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
1279
+ await this.apiClient(fetchUri, {
1280
+ method: "DELETE",
1281
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1282
+ expectNoContent: true
1283
+ });
1284
+ }
1285
+ };
1286
+ _url5 = /* @__PURE__ */ new WeakMap();
1287
+ __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
1288
+ var _url6;
1289
+ var _SignalClient = class _SignalClient2 extends ApiClient {
1290
+ constructor(options) {
1291
+ super(options);
1292
+ }
1293
+ /** Fetches all Signals for a project */
1294
+ async get(options) {
1295
+ const { projectId } = this.options;
1296
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
1297
+ return await this.apiClient(fetchUri);
1298
+ }
1299
+ /** Updates or creates (based on id) a Signal */
1300
+ async upsert(body) {
1301
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
1302
+ await this.apiClient(fetchUri, {
1303
+ method: "PUT",
1304
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1305
+ expectNoContent: true
1306
+ });
1307
+ }
1308
+ /** Deletes a Signal */
1309
+ async remove(body) {
1310
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
1311
+ await this.apiClient(fetchUri, {
1312
+ method: "DELETE",
1313
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1314
+ expectNoContent: true
1315
+ });
1316
+ }
1317
+ };
1318
+ _url6 = /* @__PURE__ */ new WeakMap();
1319
+ __privateAdd(_SignalClient, _url6, "/api/v2/signal");
1320
+ var _url7;
1321
+ var _TestClient = class _TestClient2 extends ApiClient {
1322
+ constructor(options) {
1323
+ super(options);
1324
+ }
1325
+ /** Fetches all Tests for a project */
1326
+ async get(options) {
1327
+ const { projectId } = this.options;
1328
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
1329
+ return await this.apiClient(fetchUri);
1330
+ }
1331
+ /** Updates or creates (based on id) a Test */
1332
+ async upsert(body) {
1333
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
1334
+ await this.apiClient(fetchUri, {
1335
+ method: "PUT",
1336
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1337
+ expectNoContent: true
1338
+ });
1339
+ }
1340
+ /** Deletes a Test */
1341
+ async remove(body) {
1342
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
1343
+ await this.apiClient(fetchUri, {
1344
+ method: "DELETE",
1345
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1346
+ expectNoContent: true
1347
+ });
1348
+ }
1349
+ };
1350
+ _url7 = /* @__PURE__ */ new WeakMap();
1351
+ __privateAdd(_TestClient, _url7, "/api/v2/test");
1352
+
1353
+ // src/getCompositionForTranslation.ts
808
1354
  var getCompositionForTranslation = async ({
809
1355
  canvasClient,
810
1356
  compositionId,
@@ -814,16 +1360,19 @@ var getCompositionForTranslation = async ({
814
1360
  if (!compositionId) {
815
1361
  return void 0;
816
1362
  }
817
- const composition = await canvasClient.getCompositionById({
818
- compositionId,
819
- releaseId: releaseId ? releaseId : void 0,
820
- withComponentIDs: true,
821
- skipDataResolution: true,
822
- skipOverridesResolution: true,
823
- skipPatternResolution: true,
824
- state
825
- });
826
- return composition ? composition : void 0;
1363
+ try {
1364
+ const composition = await canvasClient.get({
1365
+ compositionId,
1366
+ releaseId: releaseId ? releaseId : void 0,
1367
+ state
1368
+ });
1369
+ return composition ? composition : void 0;
1370
+ } catch (error) {
1371
+ if (error instanceof ApiClientError && error.statusCode === 404) {
1372
+ return void 0;
1373
+ }
1374
+ throw error;
1375
+ }
827
1376
  };
828
1377
 
829
1378
  // src/getEntryForTranslation.ts
@@ -838,14 +1387,10 @@ var getEntryForTranslation = async ({
838
1387
  if (!entryId) {
839
1388
  return void 0;
840
1389
  }
841
- const entriesResponse = await contentClient.getEntries({
1390
+ const entriesResponse = await contentClient.list({
842
1391
  entryIDs: [entryId],
843
1392
  releaseId: releaseId ? releaseId : void 0,
844
1393
  limit: 1,
845
- withComponentIDs: true,
846
- skipDataResolution: true,
847
- skipOverridesResolution: true,
848
- skipPatternResolution: true,
849
1394
  pattern,
850
1395
  state
851
1396
  });
@@ -974,7 +1519,7 @@ var defaultUpdateComposition = async ({
974
1519
  canvasClient,
975
1520
  composition
976
1521
  }) => {
977
- await canvasClient.updateComposition(composition);
1522
+ await canvasClient.save(composition);
978
1523
  return true;
979
1524
  };
980
1525
 
@@ -1102,7 +1647,7 @@ var defaultUpdateEntry = async ({
1102
1647
  contentClient,
1103
1648
  entry
1104
1649
  }) => {
1105
- await contentClient.upsertEntry(entry);
1650
+ await contentClient.save(entry);
1106
1651
  return true;
1107
1652
  };
1108
1653