@uniformdev/tms-sdk 20.48.1-alpha.28 → 20.48.1-alpha.33.sha-eb3f272086
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.d.mts +19 -11
- package/dist/index.d.ts +19 -11
- package/dist/index.esm.js +733 -35
- package/dist/index.js +716 -37
- package/dist/index.mjs +733 -35
- package/package.json +12 -9
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,151 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
|
|
28
|
+
var require_yocto_queue = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
var Node = class {
|
|
32
|
+
/// value;
|
|
33
|
+
/// next;
|
|
34
|
+
constructor(value) {
|
|
35
|
+
this.value = value;
|
|
36
|
+
this.next = void 0;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var Queue = class {
|
|
40
|
+
// TODO: Use private class fields when targeting Node.js 12.
|
|
41
|
+
// #_head;
|
|
42
|
+
// #_tail;
|
|
43
|
+
// #_size;
|
|
44
|
+
constructor() {
|
|
45
|
+
this.clear();
|
|
46
|
+
}
|
|
47
|
+
enqueue(value) {
|
|
48
|
+
const node = new Node(value);
|
|
49
|
+
if (this._head) {
|
|
50
|
+
this._tail.next = node;
|
|
51
|
+
this._tail = node;
|
|
52
|
+
} else {
|
|
53
|
+
this._head = node;
|
|
54
|
+
this._tail = node;
|
|
55
|
+
}
|
|
56
|
+
this._size++;
|
|
57
|
+
}
|
|
58
|
+
dequeue() {
|
|
59
|
+
const current = this._head;
|
|
60
|
+
if (!current) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._head = this._head.next;
|
|
64
|
+
this._size--;
|
|
65
|
+
return current.value;
|
|
66
|
+
}
|
|
67
|
+
clear() {
|
|
68
|
+
this._head = void 0;
|
|
69
|
+
this._tail = void 0;
|
|
70
|
+
this._size = 0;
|
|
71
|
+
}
|
|
72
|
+
get size() {
|
|
73
|
+
return this._size;
|
|
74
|
+
}
|
|
75
|
+
*[Symbol.iterator]() {
|
|
76
|
+
let current = this._head;
|
|
77
|
+
while (current) {
|
|
78
|
+
yield current.value;
|
|
79
|
+
current = current.next;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
module.exports = Queue;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
|
|
88
|
+
var require_p_limit = __commonJS({
|
|
89
|
+
"../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
|
|
90
|
+
"use strict";
|
|
91
|
+
var Queue = require_yocto_queue();
|
|
92
|
+
var pLimit2 = (concurrency) => {
|
|
93
|
+
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
94
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
95
|
+
}
|
|
96
|
+
const queue = new Queue();
|
|
97
|
+
let activeCount = 0;
|
|
98
|
+
const next = () => {
|
|
99
|
+
activeCount--;
|
|
100
|
+
if (queue.size > 0) {
|
|
101
|
+
queue.dequeue()();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const run = async (fn, resolve, ...args) => {
|
|
105
|
+
activeCount++;
|
|
106
|
+
const result = (async () => fn(...args))();
|
|
107
|
+
resolve(result);
|
|
108
|
+
try {
|
|
109
|
+
await result;
|
|
110
|
+
} catch (e) {
|
|
111
|
+
}
|
|
112
|
+
next();
|
|
113
|
+
};
|
|
114
|
+
const enqueue = (fn, resolve, ...args) => {
|
|
115
|
+
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
116
|
+
(async () => {
|
|
117
|
+
await Promise.resolve();
|
|
118
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
119
|
+
queue.dequeue()();
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
};
|
|
123
|
+
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
124
|
+
enqueue(fn, resolve, ...args);
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperties(generator, {
|
|
127
|
+
activeCount: {
|
|
128
|
+
get: () => activeCount
|
|
129
|
+
},
|
|
130
|
+
pendingCount: {
|
|
131
|
+
get: () => queue.size
|
|
132
|
+
},
|
|
133
|
+
clearQueue: {
|
|
134
|
+
value: () => {
|
|
135
|
+
queue.clear();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return generator;
|
|
140
|
+
};
|
|
141
|
+
module.exports = pLimit2;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
1
145
|
// src/collectTranslationPayload.ts
|
|
2
146
|
import {
|
|
3
147
|
bindVariables,
|
|
148
|
+
CANVAS_BLOCK_PARAM_TYPE as CANVAS_BLOCK_PARAM_TYPE2,
|
|
4
149
|
walkNodeTree as walkNodeTree2
|
|
5
150
|
} from "@uniformdev/canvas";
|
|
6
151
|
import { isRichTextValue as isRichTextValue2, isRichTextValueConsideredEmpty as isRichTextValueConsideredEmpty2 } from "@uniformdev/richtext";
|
|
@@ -15,7 +160,11 @@ var SUPPORTED_PARAM_TYPES = {
|
|
|
15
160
|
};
|
|
16
161
|
|
|
17
162
|
// src/richText/renderAsTranslatableXml.ts
|
|
18
|
-
import {
|
|
163
|
+
import {
|
|
164
|
+
getRichTextListItemValue,
|
|
165
|
+
getRichTextTagsFromTextFormat,
|
|
166
|
+
isRichTextNodeType
|
|
167
|
+
} from "@uniformdev/richtext";
|
|
19
168
|
var REF_ATTRIBUTE_NAME = "ref";
|
|
20
169
|
function renderAsTranslatableXml(root) {
|
|
21
170
|
if (!root) {
|
|
@@ -73,8 +222,23 @@ var getPropsAsBase64 = (node, ignoreProps) => {
|
|
|
73
222
|
props[key] = node[key];
|
|
74
223
|
}
|
|
75
224
|
});
|
|
225
|
+
applyMissingSerializedDefaults(node.type, props);
|
|
76
226
|
return btoa(JSON.stringify(props));
|
|
77
227
|
};
|
|
228
|
+
function applyMissingSerializedDefaults(nodeType, props) {
|
|
229
|
+
if (props.version === void 0) {
|
|
230
|
+
props.version = 1;
|
|
231
|
+
}
|
|
232
|
+
if ((nodeType === "text" || nodeType === "tab") && props.format === void 0) {
|
|
233
|
+
props.format = 0;
|
|
234
|
+
} else if (nodeType === "list" && props.start === void 0) {
|
|
235
|
+
props.start = 1;
|
|
236
|
+
} else if (nodeType === "listitem" && props.value === void 0) {
|
|
237
|
+
props.value = 1;
|
|
238
|
+
} else if (nodeType === "tablecell" && props.headerState === void 0) {
|
|
239
|
+
props.headerState = 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
78
242
|
var getNodeMetaAttributesString = (node) => {
|
|
79
243
|
const metadata = {};
|
|
80
244
|
if (isRichTextNodeType(node, "text")) {
|
|
@@ -95,7 +259,10 @@ var getNodeMetaAttributesString = (node) => {
|
|
|
95
259
|
metadata["tag"] = node.tag;
|
|
96
260
|
}
|
|
97
261
|
} else if (isRichTextNodeType(node, "listitem")) {
|
|
98
|
-
|
|
262
|
+
const value = getRichTextListItemValue(node.value);
|
|
263
|
+
if (typeof value === "number") {
|
|
264
|
+
metadata["value"] = String(value);
|
|
265
|
+
}
|
|
99
266
|
}
|
|
100
267
|
if (!Object.keys(metadata).length) {
|
|
101
268
|
return "";
|
|
@@ -109,6 +276,7 @@ var getNodeMetaAttributesString = (node) => {
|
|
|
109
276
|
|
|
110
277
|
// src/translationHelpers.ts
|
|
111
278
|
import {
|
|
279
|
+
CANVAS_BLOCK_PARAM_TYPE,
|
|
112
280
|
walkNodeTree
|
|
113
281
|
} from "@uniformdev/canvas";
|
|
114
282
|
import { isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
|
|
@@ -287,6 +455,9 @@ var processComponentTranslation = ({
|
|
|
287
455
|
});
|
|
288
456
|
return { updated };
|
|
289
457
|
};
|
|
458
|
+
var isNestedParameterType = (type) => {
|
|
459
|
+
return type === CANVAS_BLOCK_PARAM_TYPE;
|
|
460
|
+
};
|
|
290
461
|
var processParameterTranslation = ({
|
|
291
462
|
uniformSourceLocale,
|
|
292
463
|
uniformTargetLocale,
|
|
@@ -297,6 +468,14 @@ var processParameterTranslation = ({
|
|
|
297
468
|
if (originalParameter.type !== parameter.type) {
|
|
298
469
|
return { updated: false };
|
|
299
470
|
}
|
|
471
|
+
if (isNestedParameterType(originalParameter.type)) {
|
|
472
|
+
return processNestedParameterTranslation({
|
|
473
|
+
uniformSourceLocale,
|
|
474
|
+
uniformTargetLocale,
|
|
475
|
+
originalParameter,
|
|
476
|
+
parameter
|
|
477
|
+
});
|
|
478
|
+
}
|
|
300
479
|
if (!originalParameter.locales && originalParameter.value === void 0) {
|
|
301
480
|
return { updated: false };
|
|
302
481
|
}
|
|
@@ -309,7 +488,7 @@ var processParameterTranslation = ({
|
|
|
309
488
|
left: originalParameterSource,
|
|
310
489
|
right: sourceValue
|
|
311
490
|
});
|
|
312
|
-
const isTargetValueUntouched = isSameParameterValue({
|
|
491
|
+
const isTargetValueUntouched = originalTargetValue === void 0 ? true : isSameParameterValue({
|
|
313
492
|
parameterType: originalParameter.type,
|
|
314
493
|
left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
|
|
315
494
|
right: originalTargetValue
|
|
@@ -341,6 +520,39 @@ var processParameterTranslation = ({
|
|
|
341
520
|
}
|
|
342
521
|
return { updated: false };
|
|
343
522
|
};
|
|
523
|
+
var processNestedParameterTranslation = ({
|
|
524
|
+
uniformSourceLocale,
|
|
525
|
+
uniformTargetLocale,
|
|
526
|
+
originalParameter,
|
|
527
|
+
parameter
|
|
528
|
+
}) => {
|
|
529
|
+
let updated = false;
|
|
530
|
+
if (originalParameter.type == CANVAS_BLOCK_PARAM_TYPE && Array.isArray(originalParameter.value) && Array.isArray(parameter.value)) {
|
|
531
|
+
const originalValue = originalParameter.value;
|
|
532
|
+
const translatedValue = parameter.value;
|
|
533
|
+
for (const translatedBlock of translatedValue) {
|
|
534
|
+
if (!translatedBlock._id || !translatedBlock.type) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
const originalBlock = originalValue.find(
|
|
538
|
+
(b) => b._id === translatedBlock._id && b.type === translatedBlock.type
|
|
539
|
+
);
|
|
540
|
+
if (!originalBlock) {
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
const { updated: blockUpdated } = processComponentTranslation({
|
|
544
|
+
uniformSourceLocale,
|
|
545
|
+
uniformTargetLocale,
|
|
546
|
+
originalNode: originalBlock,
|
|
547
|
+
translatedComponent: translatedBlock
|
|
548
|
+
});
|
|
549
|
+
if (blockUpdated) {
|
|
550
|
+
updated = true;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return { updated };
|
|
555
|
+
};
|
|
344
556
|
var processOverrideTranslation = ({
|
|
345
557
|
uniformSourceLocale,
|
|
346
558
|
uniformTargetLocale,
|
|
@@ -453,7 +665,8 @@ var collectTranslationPayload = ({
|
|
|
453
665
|
uniformReleaseId,
|
|
454
666
|
targetLang,
|
|
455
667
|
entity,
|
|
456
|
-
entityType
|
|
668
|
+
entityType,
|
|
669
|
+
config = {}
|
|
457
670
|
}) => {
|
|
458
671
|
if (!uniformSourceLocale || !uniformTargetLocale || !targetLang || !entity) {
|
|
459
672
|
return createErrorResult2("invalid-args");
|
|
@@ -477,16 +690,22 @@ var collectTranslationPayload = ({
|
|
|
477
690
|
},
|
|
478
691
|
components: {}
|
|
479
692
|
};
|
|
480
|
-
walkNodeTree2(entity, ({ node, actions }) => {
|
|
693
|
+
walkNodeTree2(entity, ({ node, actions, ancestorsAndSelf }) => {
|
|
694
|
+
var _a;
|
|
481
695
|
if (!node.type || !node._id) {
|
|
482
696
|
actions.stopProcessingDescendants();
|
|
483
697
|
return;
|
|
484
698
|
}
|
|
699
|
+
if (((_a = ancestorsAndSelf.at(0)) == null ? void 0 : _a.type) === "block") {
|
|
700
|
+
actions.stopProcessingDescendants();
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
485
703
|
const { _id, type, parameters, _overrides } = collectFromNode({
|
|
486
704
|
uniformSourceLocale,
|
|
487
705
|
uniformTargetLocale,
|
|
488
706
|
node,
|
|
489
|
-
deep: false
|
|
707
|
+
deep: false,
|
|
708
|
+
config
|
|
490
709
|
});
|
|
491
710
|
if (parameters || _overrides) {
|
|
492
711
|
payload.components[node._id] = {
|
|
@@ -503,7 +722,8 @@ var collectFromNode = ({
|
|
|
503
722
|
uniformSourceLocale,
|
|
504
723
|
uniformTargetLocale,
|
|
505
724
|
node,
|
|
506
|
-
deep
|
|
725
|
+
deep,
|
|
726
|
+
config
|
|
507
727
|
}) => {
|
|
508
728
|
var _a, _b, _c;
|
|
509
729
|
const collectedParameters = {};
|
|
@@ -513,12 +733,24 @@ var collectFromNode = ({
|
|
|
513
733
|
const entryFields = "fields" in node ? node.fields : void 0;
|
|
514
734
|
Object.entries((_a = componentParameters != null ? componentParameters : entryFields) != null ? _a : {}).forEach(([paramKey, param]) => {
|
|
515
735
|
var _a2, _b2;
|
|
736
|
+
if (isNestedParameterType(param.type)) {
|
|
737
|
+
const nestedParam = collectNestedParameter({
|
|
738
|
+
param,
|
|
739
|
+
uniformSourceLocale,
|
|
740
|
+
uniformTargetLocale,
|
|
741
|
+
config
|
|
742
|
+
});
|
|
743
|
+
if (nestedParam) {
|
|
744
|
+
collectedParameters[paramKey] = nestedParam;
|
|
745
|
+
}
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
516
748
|
const sourceLocaleValue = (_a2 = param.locales) == null ? void 0 : _a2[uniformSourceLocale];
|
|
517
749
|
const targetLocaleValue = (_b2 = param.locales) == null ? void 0 : _b2[uniformTargetLocale];
|
|
518
750
|
if (!canTranslateParameterValue(param, sourceLocaleValue)) {
|
|
519
751
|
return;
|
|
520
752
|
}
|
|
521
|
-
if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
753
|
+
if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
522
754
|
return;
|
|
523
755
|
}
|
|
524
756
|
collectedParameters[paramKey] = {
|
|
@@ -526,7 +758,7 @@ var collectFromNode = ({
|
|
|
526
758
|
locales: {
|
|
527
759
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
528
760
|
[TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
|
|
529
|
-
[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
|
|
761
|
+
[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
|
|
530
762
|
}
|
|
531
763
|
};
|
|
532
764
|
});
|
|
@@ -541,7 +773,8 @@ var collectFromNode = ({
|
|
|
541
773
|
uniformSourceLocale,
|
|
542
774
|
uniformTargetLocale,
|
|
543
775
|
node: slotComponent,
|
|
544
|
-
deep: true
|
|
776
|
+
deep: true,
|
|
777
|
+
config
|
|
545
778
|
});
|
|
546
779
|
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
547
780
|
if (hasContent) {
|
|
@@ -554,23 +787,37 @@ var collectFromNode = ({
|
|
|
554
787
|
Object.entries((_c = node._overrides) != null ? _c : {}).forEach(([overrideKey, override]) => {
|
|
555
788
|
var _a2, _b2;
|
|
556
789
|
Object.entries((_a2 = override.parameters) != null ? _a2 : {}).forEach(([paramKey, param]) => {
|
|
557
|
-
var _a3, _b3, _c2, _d, _e;
|
|
558
|
-
|
|
559
|
-
|
|
790
|
+
var _a3, _b3, _c2, _d, _e, _f, _g, _h;
|
|
791
|
+
if (isNestedParameterType(param.type)) {
|
|
792
|
+
const nestedParam = collectNestedParameter({
|
|
793
|
+
param,
|
|
794
|
+
uniformSourceLocale,
|
|
795
|
+
uniformTargetLocale,
|
|
796
|
+
config
|
|
797
|
+
});
|
|
798
|
+
if (nestedParam) {
|
|
799
|
+
(_a3 = collectedOverrides[overrideKey]) != null ? _a3 : collectedOverrides[overrideKey] = {};
|
|
800
|
+
(_c2 = (_b3 = collectedOverrides[overrideKey]).parameters) != null ? _c2 : _b3.parameters = {};
|
|
801
|
+
collectedOverrides[overrideKey].parameters[paramKey] = nestedParam;
|
|
802
|
+
}
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const sourceLocaleValue = (_d = param.locales) == null ? void 0 : _d[uniformSourceLocale];
|
|
806
|
+
const targetLocaleValue = (_e = param.locales) == null ? void 0 : _e[uniformTargetLocale];
|
|
560
807
|
if (!canTranslateParameterValue(param, sourceLocaleValue)) {
|
|
561
808
|
return;
|
|
562
809
|
}
|
|
563
|
-
if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
810
|
+
if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
564
811
|
return;
|
|
565
812
|
}
|
|
566
|
-
(
|
|
567
|
-
(
|
|
813
|
+
(_f = collectedOverrides[overrideKey]) != null ? _f : collectedOverrides[overrideKey] = {};
|
|
814
|
+
(_h = (_g = collectedOverrides[overrideKey]).parameters) != null ? _h : _g.parameters = {};
|
|
568
815
|
collectedOverrides[overrideKey].parameters[paramKey] = {
|
|
569
816
|
type: param.type,
|
|
570
817
|
locales: {
|
|
571
818
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
572
819
|
[TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
|
|
573
|
-
[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
|
|
820
|
+
[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
|
|
574
821
|
}
|
|
575
822
|
};
|
|
576
823
|
});
|
|
@@ -586,7 +833,8 @@ var collectFromNode = ({
|
|
|
586
833
|
node: slotComponent,
|
|
587
834
|
// keep tree structure for `Slot Sections`
|
|
588
835
|
// to store whole `override` content in scope of current component
|
|
589
|
-
deep: true
|
|
836
|
+
deep: true,
|
|
837
|
+
config
|
|
590
838
|
});
|
|
591
839
|
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
592
840
|
if (hasContent) {
|
|
@@ -609,6 +857,42 @@ var collectFromNode = ({
|
|
|
609
857
|
_overrides: hasOverrides ? collectedOverrides : void 0
|
|
610
858
|
};
|
|
611
859
|
};
|
|
860
|
+
var collectNestedParameter = ({
|
|
861
|
+
param,
|
|
862
|
+
uniformSourceLocale,
|
|
863
|
+
uniformTargetLocale,
|
|
864
|
+
config
|
|
865
|
+
}) => {
|
|
866
|
+
if (param.type === CANVAS_BLOCK_PARAM_TYPE2 && Array.isArray(param.value)) {
|
|
867
|
+
const blockValue = param.value;
|
|
868
|
+
const collectedBlocks = [];
|
|
869
|
+
for (const blockEntry of blockValue) {
|
|
870
|
+
if (!blockEntry._id || !blockEntry.type) {
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
const collectedNode = collectFromNode({
|
|
874
|
+
uniformSourceLocale,
|
|
875
|
+
uniformTargetLocale,
|
|
876
|
+
node: blockEntry,
|
|
877
|
+
deep: false,
|
|
878
|
+
config
|
|
879
|
+
});
|
|
880
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides;
|
|
881
|
+
if (hasContent) {
|
|
882
|
+
collectedNode.slots = void 0;
|
|
883
|
+
collectedBlocks.push(collectedNode);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (collectedBlocks.length === 0) {
|
|
887
|
+
return void 0;
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
type: CANVAS_BLOCK_PARAM_TYPE2,
|
|
891
|
+
value: collectedBlocks
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
return void 0;
|
|
895
|
+
};
|
|
612
896
|
var canTranslateParameterValue = (parameter, value) => {
|
|
613
897
|
if (parameter.type === SUPPORTED_PARAM_TYPES.text) {
|
|
614
898
|
if (typeof value !== "string" || !value) {
|
|
@@ -661,6 +945,421 @@ var preprocessTargetValue = (parameter, value) => {
|
|
|
661
945
|
|
|
662
946
|
// src/getCompositionForTranslation.ts
|
|
663
947
|
import { CANVAS_DRAFT_STATE } from "@uniformdev/canvas";
|
|
948
|
+
|
|
949
|
+
// ../context/dist/api/api.mjs
|
|
950
|
+
var import_p_limit = __toESM(require_p_limit(), 1);
|
|
951
|
+
var __defProp2 = Object.defineProperty;
|
|
952
|
+
var __typeError = (msg) => {
|
|
953
|
+
throw TypeError(msg);
|
|
954
|
+
};
|
|
955
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
956
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
957
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
958
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
959
|
+
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);
|
|
960
|
+
var defaultLimitPolicy = (0, import_p_limit.default)(6);
|
|
961
|
+
var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
|
|
962
|
+
var ApiClientError = class _ApiClientError extends Error {
|
|
963
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
964
|
+
super(
|
|
965
|
+
`${errorMessage}
|
|
966
|
+
${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
|
|
967
|
+
);
|
|
968
|
+
__publicField(this, "errorMessage", errorMessage);
|
|
969
|
+
__publicField(this, "fetchMethod", fetchMethod);
|
|
970
|
+
__publicField(this, "fetchUri", fetchUri);
|
|
971
|
+
__publicField(this, "statusCode", statusCode);
|
|
972
|
+
__publicField(this, "statusText", statusText);
|
|
973
|
+
__publicField(this, "requestId", requestId);
|
|
974
|
+
Object.setPrototypeOf(this, _ApiClientError.prototype);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
|
|
978
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
979
|
+
super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
|
|
980
|
+
Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
var ApiClient = class _ApiClient {
|
|
984
|
+
constructor(options) {
|
|
985
|
+
__publicField(this, "options");
|
|
986
|
+
var _a, _b, _c, _d, _e;
|
|
987
|
+
if (!options.apiKey && !options.bearerToken) {
|
|
988
|
+
throw new Error("You must provide an API key or a bearer token");
|
|
989
|
+
}
|
|
990
|
+
let leFetch = options.fetch;
|
|
991
|
+
if (!leFetch) {
|
|
992
|
+
if (typeof window !== "undefined") {
|
|
993
|
+
leFetch = window.fetch.bind(window);
|
|
994
|
+
} else if (typeof fetch !== "undefined") {
|
|
995
|
+
leFetch = fetch;
|
|
996
|
+
} else {
|
|
997
|
+
throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
this.options = {
|
|
1001
|
+
...options,
|
|
1002
|
+
fetch: leFetch,
|
|
1003
|
+
apiHost: this.ensureApiHost(options.apiHost),
|
|
1004
|
+
apiKey: (_a = options.apiKey) != null ? _a : null,
|
|
1005
|
+
projectId: (_b = options.projectId) != null ? _b : null,
|
|
1006
|
+
bearerToken: (_c = options.bearerToken) != null ? _c : null,
|
|
1007
|
+
limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
|
|
1008
|
+
bypassCache: (_e = options.bypassCache) != null ? _e : false
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
async apiClient(fetchUri, options) {
|
|
1012
|
+
return (await this.apiClientWithResponse(fetchUri, options)).body;
|
|
1013
|
+
}
|
|
1014
|
+
async apiClientWithResponse(fetchUri, options) {
|
|
1015
|
+
return this.options.limitPolicy(async () => {
|
|
1016
|
+
var _a, _b;
|
|
1017
|
+
const coreHeaders = this.options.apiKey ? {
|
|
1018
|
+
"x-api-key": this.options.apiKey
|
|
1019
|
+
} : {
|
|
1020
|
+
Authorization: `Bearer ${this.options.bearerToken}`
|
|
1021
|
+
};
|
|
1022
|
+
if (this.options.bypassCache) {
|
|
1023
|
+
coreHeaders["x-bypass-cache"] = "true";
|
|
1024
|
+
}
|
|
1025
|
+
const { fetch: fetch2, signal } = this.options;
|
|
1026
|
+
const callApi = () => fetch2(fetchUri.toString(), {
|
|
1027
|
+
...options,
|
|
1028
|
+
signal,
|
|
1029
|
+
headers: {
|
|
1030
|
+
...options == null ? void 0 : options.headers,
|
|
1031
|
+
...coreHeaders
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
const apiResponse = await handleRateLimits(callApi);
|
|
1035
|
+
if (!apiResponse.ok) {
|
|
1036
|
+
let message = "";
|
|
1037
|
+
try {
|
|
1038
|
+
const responseText = await apiResponse.text();
|
|
1039
|
+
try {
|
|
1040
|
+
const parsed = JSON.parse(responseText);
|
|
1041
|
+
if (parsed.errorMessage) {
|
|
1042
|
+
message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
|
|
1043
|
+
} else {
|
|
1044
|
+
message = responseText;
|
|
1045
|
+
}
|
|
1046
|
+
} catch (e) {
|
|
1047
|
+
message = responseText;
|
|
1048
|
+
}
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
message = `General error`;
|
|
1051
|
+
}
|
|
1052
|
+
if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
|
|
1053
|
+
throw new BearerTokenNotValidOrExpiredError(
|
|
1054
|
+
message,
|
|
1055
|
+
(_a = options == null ? void 0 : options.method) != null ? _a : "GET",
|
|
1056
|
+
fetchUri.toString(),
|
|
1057
|
+
apiResponse.status,
|
|
1058
|
+
apiResponse.statusText,
|
|
1059
|
+
_ApiClient.getRequestId(apiResponse)
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
throw new ApiClientError(
|
|
1063
|
+
message,
|
|
1064
|
+
(_b = options == null ? void 0 : options.method) != null ? _b : "GET",
|
|
1065
|
+
fetchUri.toString(),
|
|
1066
|
+
apiResponse.status,
|
|
1067
|
+
apiResponse.statusText,
|
|
1068
|
+
_ApiClient.getRequestId(apiResponse)
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
if (options == null ? void 0 : options.expectNoContent) {
|
|
1072
|
+
return { response: apiResponse, body: null };
|
|
1073
|
+
}
|
|
1074
|
+
return {
|
|
1075
|
+
response: apiResponse,
|
|
1076
|
+
body: await apiResponse.json()
|
|
1077
|
+
};
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
createUrl(path, queryParams, hostOverride) {
|
|
1081
|
+
const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
|
|
1082
|
+
Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
|
|
1083
|
+
var _a;
|
|
1084
|
+
if (typeof value !== "undefined" && value !== null) {
|
|
1085
|
+
url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
return url;
|
|
1089
|
+
}
|
|
1090
|
+
ensureApiHost(apiHost) {
|
|
1091
|
+
if (!apiHost) return "https://uniform.app";
|
|
1092
|
+
if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
|
|
1093
|
+
throw new Error('Your apiHost must start with "http"');
|
|
1094
|
+
}
|
|
1095
|
+
if (apiHost.indexOf("/", 8) > -1) {
|
|
1096
|
+
throw new Error("Your apiHost must not contain a path element after the domain");
|
|
1097
|
+
}
|
|
1098
|
+
if (apiHost.indexOf("?") > -1) {
|
|
1099
|
+
throw new Error("Your apiHost must not contain a query string");
|
|
1100
|
+
}
|
|
1101
|
+
if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
|
|
1102
|
+
apiHost = apiHost.substring(0, apiHost.length - 1);
|
|
1103
|
+
}
|
|
1104
|
+
return apiHost;
|
|
1105
|
+
}
|
|
1106
|
+
static getRequestId(response) {
|
|
1107
|
+
const apigRequestId = response.headers.get("apigw-requestid");
|
|
1108
|
+
if (apigRequestId) {
|
|
1109
|
+
return apigRequestId;
|
|
1110
|
+
}
|
|
1111
|
+
return void 0;
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
async function handleRateLimits(callApi) {
|
|
1115
|
+
var _a;
|
|
1116
|
+
const backoffRetries = 5;
|
|
1117
|
+
let backoffRetriesLeft = backoffRetries;
|
|
1118
|
+
let response;
|
|
1119
|
+
while (backoffRetriesLeft > 0) {
|
|
1120
|
+
response = await callApi();
|
|
1121
|
+
if (response.status !== 429) {
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
let resetWait = 0;
|
|
1125
|
+
try {
|
|
1126
|
+
const responseClone = response.clone();
|
|
1127
|
+
const dateHeader = responseClone.headers.get("date");
|
|
1128
|
+
const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
|
|
1129
|
+
const body = await responseClone.json();
|
|
1130
|
+
const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
|
|
1131
|
+
if (typeof serverTime === "number" && typeof resetTime === "number") {
|
|
1132
|
+
resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
|
|
1133
|
+
}
|
|
1134
|
+
} catch (e) {
|
|
1135
|
+
}
|
|
1136
|
+
const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
|
|
1137
|
+
const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
|
|
1138
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
|
|
1139
|
+
backoffRetriesLeft -= 1;
|
|
1140
|
+
}
|
|
1141
|
+
return response;
|
|
1142
|
+
}
|
|
1143
|
+
var _url;
|
|
1144
|
+
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
1145
|
+
constructor(options) {
|
|
1146
|
+
super(options);
|
|
1147
|
+
}
|
|
1148
|
+
/** Fetches all aggregates for a project */
|
|
1149
|
+
async get(options) {
|
|
1150
|
+
const { projectId } = this.options;
|
|
1151
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
|
|
1152
|
+
return await this.apiClient(fetchUri);
|
|
1153
|
+
}
|
|
1154
|
+
/** Updates or creates (based on id) an Aggregate */
|
|
1155
|
+
async upsert(body) {
|
|
1156
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
|
|
1157
|
+
await this.apiClient(fetchUri, {
|
|
1158
|
+
method: "PUT",
|
|
1159
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1160
|
+
expectNoContent: true
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
/** Deletes an Aggregate */
|
|
1164
|
+
async remove(body) {
|
|
1165
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
|
|
1166
|
+
await this.apiClient(fetchUri, {
|
|
1167
|
+
method: "DELETE",
|
|
1168
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1169
|
+
expectNoContent: true
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
1174
|
+
__privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
|
|
1175
|
+
var _url2;
|
|
1176
|
+
var _DimensionClient = class _DimensionClient2 extends ApiClient {
|
|
1177
|
+
constructor(options) {
|
|
1178
|
+
super(options);
|
|
1179
|
+
}
|
|
1180
|
+
/** Fetches the known score dimensions for a project */
|
|
1181
|
+
async get(options) {
|
|
1182
|
+
const { projectId } = this.options;
|
|
1183
|
+
const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
|
|
1184
|
+
return await this.apiClient(fetchUri);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
_url2 = /* @__PURE__ */ new WeakMap();
|
|
1188
|
+
__privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
|
|
1189
|
+
var _url3;
|
|
1190
|
+
var _valueUrl;
|
|
1191
|
+
var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
|
|
1192
|
+
constructor(options) {
|
|
1193
|
+
super(options);
|
|
1194
|
+
}
|
|
1195
|
+
/** Fetches all enrichments and values for a project, grouped by category */
|
|
1196
|
+
async get(options) {
|
|
1197
|
+
const { projectId } = this.options;
|
|
1198
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
|
|
1199
|
+
return await this.apiClient(fetchUri);
|
|
1200
|
+
}
|
|
1201
|
+
/** Updates or creates (based on id) an enrichment category */
|
|
1202
|
+
async upsertCategory(body) {
|
|
1203
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
|
|
1204
|
+
await this.apiClient(fetchUri, {
|
|
1205
|
+
method: "PUT",
|
|
1206
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1207
|
+
expectNoContent: true
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
/** Deletes an enrichment category */
|
|
1211
|
+
async removeCategory(body) {
|
|
1212
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
|
|
1213
|
+
await this.apiClient(fetchUri, {
|
|
1214
|
+
method: "DELETE",
|
|
1215
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1216
|
+
expectNoContent: true
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
/** Updates or creates (based on id) an enrichment value within an enrichment category */
|
|
1220
|
+
async upsertValue(body) {
|
|
1221
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
|
|
1222
|
+
await this.apiClient(fetchUri, {
|
|
1223
|
+
method: "PUT",
|
|
1224
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1225
|
+
expectNoContent: true
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
/** Deletes an enrichment value within an enrichment category. The category is left alone. */
|
|
1229
|
+
async removeValue(body) {
|
|
1230
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
|
|
1231
|
+
await this.apiClient(fetchUri, {
|
|
1232
|
+
method: "DELETE",
|
|
1233
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1234
|
+
expectNoContent: true
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
_url3 = /* @__PURE__ */ new WeakMap();
|
|
1239
|
+
_valueUrl = /* @__PURE__ */ new WeakMap();
|
|
1240
|
+
__privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
|
|
1241
|
+
__privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
|
|
1242
|
+
var _url4;
|
|
1243
|
+
var _ManifestClient = class _ManifestClient2 extends ApiClient {
|
|
1244
|
+
constructor(options) {
|
|
1245
|
+
super(options);
|
|
1246
|
+
}
|
|
1247
|
+
/** Fetches the Context manifest for a project */
|
|
1248
|
+
async get(options) {
|
|
1249
|
+
const { projectId } = this.options;
|
|
1250
|
+
const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
|
|
1251
|
+
return await this.apiClient(fetchUri);
|
|
1252
|
+
}
|
|
1253
|
+
/** Publishes the Context manifest for a project */
|
|
1254
|
+
async publish() {
|
|
1255
|
+
const { projectId } = this.options;
|
|
1256
|
+
const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
|
|
1257
|
+
await this.apiClient(fetchUri, {
|
|
1258
|
+
method: "POST",
|
|
1259
|
+
expectNoContent: true
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
_url4 = /* @__PURE__ */ new WeakMap();
|
|
1264
|
+
__privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
|
|
1265
|
+
var _url5;
|
|
1266
|
+
var _QuirkClient = class _QuirkClient2 extends ApiClient {
|
|
1267
|
+
constructor(options) {
|
|
1268
|
+
super(options);
|
|
1269
|
+
}
|
|
1270
|
+
/** Fetches all Quirks for a project */
|
|
1271
|
+
async get(options) {
|
|
1272
|
+
const { projectId } = this.options;
|
|
1273
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
|
|
1274
|
+
return await this.apiClient(fetchUri);
|
|
1275
|
+
}
|
|
1276
|
+
/** Updates or creates (based on id) a Quirk */
|
|
1277
|
+
async upsert(body) {
|
|
1278
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
|
|
1279
|
+
await this.apiClient(fetchUri, {
|
|
1280
|
+
method: "PUT",
|
|
1281
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1282
|
+
expectNoContent: true
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
/** Deletes a Quirk */
|
|
1286
|
+
async remove(body) {
|
|
1287
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
|
|
1288
|
+
await this.apiClient(fetchUri, {
|
|
1289
|
+
method: "DELETE",
|
|
1290
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1291
|
+
expectNoContent: true
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
_url5 = /* @__PURE__ */ new WeakMap();
|
|
1296
|
+
__privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
|
|
1297
|
+
var _url6;
|
|
1298
|
+
var _SignalClient = class _SignalClient2 extends ApiClient {
|
|
1299
|
+
constructor(options) {
|
|
1300
|
+
super(options);
|
|
1301
|
+
}
|
|
1302
|
+
/** Fetches all Signals for a project */
|
|
1303
|
+
async get(options) {
|
|
1304
|
+
const { projectId } = this.options;
|
|
1305
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
|
|
1306
|
+
return await this.apiClient(fetchUri);
|
|
1307
|
+
}
|
|
1308
|
+
/** Updates or creates (based on id) a Signal */
|
|
1309
|
+
async upsert(body) {
|
|
1310
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
|
|
1311
|
+
await this.apiClient(fetchUri, {
|
|
1312
|
+
method: "PUT",
|
|
1313
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1314
|
+
expectNoContent: true
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
/** Deletes a Signal */
|
|
1318
|
+
async remove(body) {
|
|
1319
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
|
|
1320
|
+
await this.apiClient(fetchUri, {
|
|
1321
|
+
method: "DELETE",
|
|
1322
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1323
|
+
expectNoContent: true
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
_url6 = /* @__PURE__ */ new WeakMap();
|
|
1328
|
+
__privateAdd(_SignalClient, _url6, "/api/v2/signal");
|
|
1329
|
+
var _url7;
|
|
1330
|
+
var _TestClient = class _TestClient2 extends ApiClient {
|
|
1331
|
+
constructor(options) {
|
|
1332
|
+
super(options);
|
|
1333
|
+
}
|
|
1334
|
+
/** Fetches all Tests for a project */
|
|
1335
|
+
async get(options) {
|
|
1336
|
+
const { projectId } = this.options;
|
|
1337
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
|
|
1338
|
+
return await this.apiClient(fetchUri);
|
|
1339
|
+
}
|
|
1340
|
+
/** Updates or creates (based on id) a Test */
|
|
1341
|
+
async upsert(body) {
|
|
1342
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
|
|
1343
|
+
await this.apiClient(fetchUri, {
|
|
1344
|
+
method: "PUT",
|
|
1345
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1346
|
+
expectNoContent: true
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
/** Deletes a Test */
|
|
1350
|
+
async remove(body) {
|
|
1351
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
|
|
1352
|
+
await this.apiClient(fetchUri, {
|
|
1353
|
+
method: "DELETE",
|
|
1354
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1355
|
+
expectNoContent: true
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
_url7 = /* @__PURE__ */ new WeakMap();
|
|
1360
|
+
__privateAdd(_TestClient, _url7, "/api/v2/test");
|
|
1361
|
+
|
|
1362
|
+
// src/getCompositionForTranslation.ts
|
|
664
1363
|
var getCompositionForTranslation = async ({
|
|
665
1364
|
canvasClient,
|
|
666
1365
|
compositionId,
|
|
@@ -670,16 +1369,19 @@ var getCompositionForTranslation = async ({
|
|
|
670
1369
|
if (!compositionId) {
|
|
671
1370
|
return void 0;
|
|
672
1371
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
1372
|
+
try {
|
|
1373
|
+
const composition = await canvasClient.get({
|
|
1374
|
+
compositionId,
|
|
1375
|
+
releaseId: releaseId ? releaseId : void 0,
|
|
1376
|
+
state
|
|
1377
|
+
});
|
|
1378
|
+
return composition ? composition : void 0;
|
|
1379
|
+
} catch (error) {
|
|
1380
|
+
if (error instanceof ApiClientError && error.statusCode === 404) {
|
|
1381
|
+
return void 0;
|
|
1382
|
+
}
|
|
1383
|
+
throw error;
|
|
1384
|
+
}
|
|
683
1385
|
};
|
|
684
1386
|
|
|
685
1387
|
// src/getEntryForTranslation.ts
|
|
@@ -694,14 +1396,10 @@ var getEntryForTranslation = async ({
|
|
|
694
1396
|
if (!entryId) {
|
|
695
1397
|
return void 0;
|
|
696
1398
|
}
|
|
697
|
-
const entriesResponse = await contentClient.
|
|
1399
|
+
const entriesResponse = await contentClient.list({
|
|
698
1400
|
entryIDs: [entryId],
|
|
699
1401
|
releaseId: releaseId ? releaseId : void 0,
|
|
700
1402
|
limit: 1,
|
|
701
|
-
withComponentIDs: true,
|
|
702
|
-
skipDataResolution: true,
|
|
703
|
-
skipOverridesResolution: true,
|
|
704
|
-
skipPatternResolution: true,
|
|
705
1403
|
pattern,
|
|
706
1404
|
state
|
|
707
1405
|
});
|
|
@@ -830,7 +1528,7 @@ var defaultUpdateComposition = async ({
|
|
|
830
1528
|
canvasClient,
|
|
831
1529
|
composition
|
|
832
1530
|
}) => {
|
|
833
|
-
await canvasClient.
|
|
1531
|
+
await canvasClient.save(composition);
|
|
834
1532
|
return true;
|
|
835
1533
|
};
|
|
836
1534
|
|
|
@@ -958,7 +1656,7 @@ var defaultUpdateEntry = async ({
|
|
|
958
1656
|
contentClient,
|
|
959
1657
|
entry
|
|
960
1658
|
}) => {
|
|
961
|
-
await contentClient.
|
|
1659
|
+
await contentClient.save(entry);
|
|
962
1660
|
return true;
|
|
963
1661
|
};
|
|
964
1662
|
|