@uniformdev/canvas 20.50.2-alpha.146 → 20.50.2-alpha.167
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 +3399 -2415
- package/dist/index.d.ts +3399 -2415
- package/dist/index.esm.js +1075 -737
- package/dist/index.js +1088 -718
- package/dist/index.mjs +1075 -737
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -8,9 +8,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
8
8
|
var __typeError = (msg) => {
|
|
9
9
|
throw TypeError(msg);
|
|
10
10
|
};
|
|
11
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
-
};
|
|
14
11
|
var __export = (target, all) => {
|
|
15
12
|
for (var name in all)
|
|
16
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -36,358 +33,9 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
36
33
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
37
34
|
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);
|
|
38
35
|
|
|
39
|
-
// ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
|
|
40
|
-
var require_yocto_queue = __commonJS({
|
|
41
|
-
"../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
|
|
42
|
-
"use strict";
|
|
43
|
-
var Node = class {
|
|
44
|
-
/// value;
|
|
45
|
-
/// next;
|
|
46
|
-
constructor(value) {
|
|
47
|
-
this.value = value;
|
|
48
|
-
this.next = void 0;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var Queue = class {
|
|
52
|
-
// TODO: Use private class fields when targeting Node.js 12.
|
|
53
|
-
// #_head;
|
|
54
|
-
// #_tail;
|
|
55
|
-
// #_size;
|
|
56
|
-
constructor() {
|
|
57
|
-
this.clear();
|
|
58
|
-
}
|
|
59
|
-
enqueue(value) {
|
|
60
|
-
const node = new Node(value);
|
|
61
|
-
if (this._head) {
|
|
62
|
-
this._tail.next = node;
|
|
63
|
-
this._tail = node;
|
|
64
|
-
} else {
|
|
65
|
-
this._head = node;
|
|
66
|
-
this._tail = node;
|
|
67
|
-
}
|
|
68
|
-
this._size++;
|
|
69
|
-
}
|
|
70
|
-
dequeue() {
|
|
71
|
-
const current = this._head;
|
|
72
|
-
if (!current) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
this._head = this._head.next;
|
|
76
|
-
this._size--;
|
|
77
|
-
return current.value;
|
|
78
|
-
}
|
|
79
|
-
clear() {
|
|
80
|
-
this._head = void 0;
|
|
81
|
-
this._tail = void 0;
|
|
82
|
-
this._size = 0;
|
|
83
|
-
}
|
|
84
|
-
get size() {
|
|
85
|
-
return this._size;
|
|
86
|
-
}
|
|
87
|
-
*[Symbol.iterator]() {
|
|
88
|
-
let current = this._head;
|
|
89
|
-
while (current) {
|
|
90
|
-
yield current.value;
|
|
91
|
-
current = current.next;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
module2.exports = Queue;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
|
|
100
|
-
var require_p_limit = __commonJS({
|
|
101
|
-
"../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
|
|
102
|
-
"use strict";
|
|
103
|
-
var Queue = require_yocto_queue();
|
|
104
|
-
var pLimit2 = (concurrency) => {
|
|
105
|
-
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
106
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
107
|
-
}
|
|
108
|
-
const queue = new Queue();
|
|
109
|
-
let activeCount = 0;
|
|
110
|
-
const next = () => {
|
|
111
|
-
activeCount--;
|
|
112
|
-
if (queue.size > 0) {
|
|
113
|
-
queue.dequeue()();
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const run = async (fn, resolve, ...args) => {
|
|
117
|
-
activeCount++;
|
|
118
|
-
const result = (async () => fn(...args))();
|
|
119
|
-
resolve(result);
|
|
120
|
-
try {
|
|
121
|
-
await result;
|
|
122
|
-
} catch (e) {
|
|
123
|
-
}
|
|
124
|
-
next();
|
|
125
|
-
};
|
|
126
|
-
const enqueue = (fn, resolve, ...args) => {
|
|
127
|
-
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
128
|
-
(async () => {
|
|
129
|
-
await Promise.resolve();
|
|
130
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
131
|
-
queue.dequeue()();
|
|
132
|
-
}
|
|
133
|
-
})();
|
|
134
|
-
};
|
|
135
|
-
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
136
|
-
enqueue(fn, resolve, ...args);
|
|
137
|
-
});
|
|
138
|
-
Object.defineProperties(generator, {
|
|
139
|
-
activeCount: {
|
|
140
|
-
get: () => activeCount
|
|
141
|
-
},
|
|
142
|
-
pendingCount: {
|
|
143
|
-
get: () => queue.size
|
|
144
|
-
},
|
|
145
|
-
clearQueue: {
|
|
146
|
-
value: () => {
|
|
147
|
-
queue.clear();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
return generator;
|
|
152
|
-
};
|
|
153
|
-
module2.exports = pLimit2;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
158
|
-
var require_retry_operation = __commonJS({
|
|
159
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
|
|
160
|
-
"use strict";
|
|
161
|
-
function RetryOperation(timeouts, options) {
|
|
162
|
-
if (typeof options === "boolean") {
|
|
163
|
-
options = { forever: options };
|
|
164
|
-
}
|
|
165
|
-
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
166
|
-
this._timeouts = timeouts;
|
|
167
|
-
this._options = options || {};
|
|
168
|
-
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
169
|
-
this._fn = null;
|
|
170
|
-
this._errors = [];
|
|
171
|
-
this._attempts = 1;
|
|
172
|
-
this._operationTimeout = null;
|
|
173
|
-
this._operationTimeoutCb = null;
|
|
174
|
-
this._timeout = null;
|
|
175
|
-
this._operationStart = null;
|
|
176
|
-
this._timer = null;
|
|
177
|
-
if (this._options.forever) {
|
|
178
|
-
this._cachedTimeouts = this._timeouts.slice(0);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
module2.exports = RetryOperation;
|
|
182
|
-
RetryOperation.prototype.reset = function() {
|
|
183
|
-
this._attempts = 1;
|
|
184
|
-
this._timeouts = this._originalTimeouts.slice(0);
|
|
185
|
-
};
|
|
186
|
-
RetryOperation.prototype.stop = function() {
|
|
187
|
-
if (this._timeout) {
|
|
188
|
-
clearTimeout(this._timeout);
|
|
189
|
-
}
|
|
190
|
-
if (this._timer) {
|
|
191
|
-
clearTimeout(this._timer);
|
|
192
|
-
}
|
|
193
|
-
this._timeouts = [];
|
|
194
|
-
this._cachedTimeouts = null;
|
|
195
|
-
};
|
|
196
|
-
RetryOperation.prototype.retry = function(err) {
|
|
197
|
-
if (this._timeout) {
|
|
198
|
-
clearTimeout(this._timeout);
|
|
199
|
-
}
|
|
200
|
-
if (!err) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
204
|
-
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
205
|
-
this._errors.push(err);
|
|
206
|
-
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
this._errors.push(err);
|
|
210
|
-
var timeout = this._timeouts.shift();
|
|
211
|
-
if (timeout === void 0) {
|
|
212
|
-
if (this._cachedTimeouts) {
|
|
213
|
-
this._errors.splice(0, this._errors.length - 1);
|
|
214
|
-
timeout = this._cachedTimeouts.slice(-1);
|
|
215
|
-
} else {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
var self = this;
|
|
220
|
-
this._timer = setTimeout(function() {
|
|
221
|
-
self._attempts++;
|
|
222
|
-
if (self._operationTimeoutCb) {
|
|
223
|
-
self._timeout = setTimeout(function() {
|
|
224
|
-
self._operationTimeoutCb(self._attempts);
|
|
225
|
-
}, self._operationTimeout);
|
|
226
|
-
if (self._options.unref) {
|
|
227
|
-
self._timeout.unref();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
self._fn(self._attempts);
|
|
231
|
-
}, timeout);
|
|
232
|
-
if (this._options.unref) {
|
|
233
|
-
this._timer.unref();
|
|
234
|
-
}
|
|
235
|
-
return true;
|
|
236
|
-
};
|
|
237
|
-
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
238
|
-
this._fn = fn;
|
|
239
|
-
if (timeoutOps) {
|
|
240
|
-
if (timeoutOps.timeout) {
|
|
241
|
-
this._operationTimeout = timeoutOps.timeout;
|
|
242
|
-
}
|
|
243
|
-
if (timeoutOps.cb) {
|
|
244
|
-
this._operationTimeoutCb = timeoutOps.cb;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
var self = this;
|
|
248
|
-
if (this._operationTimeoutCb) {
|
|
249
|
-
this._timeout = setTimeout(function() {
|
|
250
|
-
self._operationTimeoutCb();
|
|
251
|
-
}, self._operationTimeout);
|
|
252
|
-
}
|
|
253
|
-
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
254
|
-
this._fn(this._attempts);
|
|
255
|
-
};
|
|
256
|
-
RetryOperation.prototype.try = function(fn) {
|
|
257
|
-
console.log("Using RetryOperation.try() is deprecated");
|
|
258
|
-
this.attempt(fn);
|
|
259
|
-
};
|
|
260
|
-
RetryOperation.prototype.start = function(fn) {
|
|
261
|
-
console.log("Using RetryOperation.start() is deprecated");
|
|
262
|
-
this.attempt(fn);
|
|
263
|
-
};
|
|
264
|
-
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
265
|
-
RetryOperation.prototype.errors = function() {
|
|
266
|
-
return this._errors;
|
|
267
|
-
};
|
|
268
|
-
RetryOperation.prototype.attempts = function() {
|
|
269
|
-
return this._attempts;
|
|
270
|
-
};
|
|
271
|
-
RetryOperation.prototype.mainError = function() {
|
|
272
|
-
if (this._errors.length === 0) {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
var counts = {};
|
|
276
|
-
var mainError = null;
|
|
277
|
-
var mainErrorCount = 0;
|
|
278
|
-
for (var i = 0; i < this._errors.length; i++) {
|
|
279
|
-
var error = this._errors[i];
|
|
280
|
-
var message = error.message;
|
|
281
|
-
var count = (counts[message] || 0) + 1;
|
|
282
|
-
counts[message] = count;
|
|
283
|
-
if (count >= mainErrorCount) {
|
|
284
|
-
mainError = error;
|
|
285
|
-
mainErrorCount = count;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return mainError;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
|
|
294
|
-
var require_retry = __commonJS({
|
|
295
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
|
|
296
|
-
"use strict";
|
|
297
|
-
var RetryOperation = require_retry_operation();
|
|
298
|
-
exports2.operation = function(options) {
|
|
299
|
-
var timeouts = exports2.timeouts(options);
|
|
300
|
-
return new RetryOperation(timeouts, {
|
|
301
|
-
forever: options && (options.forever || options.retries === Infinity),
|
|
302
|
-
unref: options && options.unref,
|
|
303
|
-
maxRetryTime: options && options.maxRetryTime
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
exports2.timeouts = function(options) {
|
|
307
|
-
if (options instanceof Array) {
|
|
308
|
-
return [].concat(options);
|
|
309
|
-
}
|
|
310
|
-
var opts = {
|
|
311
|
-
retries: 10,
|
|
312
|
-
factor: 2,
|
|
313
|
-
minTimeout: 1 * 1e3,
|
|
314
|
-
maxTimeout: Infinity,
|
|
315
|
-
randomize: false
|
|
316
|
-
};
|
|
317
|
-
for (var key in options) {
|
|
318
|
-
opts[key] = options[key];
|
|
319
|
-
}
|
|
320
|
-
if (opts.minTimeout > opts.maxTimeout) {
|
|
321
|
-
throw new Error("minTimeout is greater than maxTimeout");
|
|
322
|
-
}
|
|
323
|
-
var timeouts = [];
|
|
324
|
-
for (var i = 0; i < opts.retries; i++) {
|
|
325
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
326
|
-
}
|
|
327
|
-
if (options && options.forever && !timeouts.length) {
|
|
328
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
329
|
-
}
|
|
330
|
-
timeouts.sort(function(a, b) {
|
|
331
|
-
return a - b;
|
|
332
|
-
});
|
|
333
|
-
return timeouts;
|
|
334
|
-
};
|
|
335
|
-
exports2.createTimeout = function(attempt, opts) {
|
|
336
|
-
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
337
|
-
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
|
|
338
|
-
timeout = Math.min(timeout, opts.maxTimeout);
|
|
339
|
-
return timeout;
|
|
340
|
-
};
|
|
341
|
-
exports2.wrap = function(obj, options, methods) {
|
|
342
|
-
if (options instanceof Array) {
|
|
343
|
-
methods = options;
|
|
344
|
-
options = null;
|
|
345
|
-
}
|
|
346
|
-
if (!methods) {
|
|
347
|
-
methods = [];
|
|
348
|
-
for (var key in obj) {
|
|
349
|
-
if (typeof obj[key] === "function") {
|
|
350
|
-
methods.push(key);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
for (var i = 0; i < methods.length; i++) {
|
|
355
|
-
var method = methods[i];
|
|
356
|
-
var original = obj[method];
|
|
357
|
-
obj[method] = function retryWrapper(original2) {
|
|
358
|
-
var op = exports2.operation(options);
|
|
359
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
360
|
-
var callback = args.pop();
|
|
361
|
-
args.push(function(err) {
|
|
362
|
-
if (op.retry(err)) {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
if (err) {
|
|
366
|
-
arguments[0] = op.mainError();
|
|
367
|
-
}
|
|
368
|
-
callback.apply(this, arguments);
|
|
369
|
-
});
|
|
370
|
-
op.attempt(function() {
|
|
371
|
-
original2.apply(obj, args);
|
|
372
|
-
});
|
|
373
|
-
}.bind(obj, original);
|
|
374
|
-
obj[method].options = options;
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
381
|
-
var require_retry2 = __commonJS({
|
|
382
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
|
|
383
|
-
"use strict";
|
|
384
|
-
module2.exports = require_retry();
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
|
|
388
36
|
// src/index.ts
|
|
389
|
-
var
|
|
390
|
-
__export(
|
|
37
|
+
var index_exports = {};
|
|
38
|
+
__export(index_exports, {
|
|
391
39
|
ASSETS_SOURCE_CUSTOM_URL: () => ASSETS_SOURCE_CUSTOM_URL,
|
|
392
40
|
ASSETS_SOURCE_UNIFORM: () => ASSETS_SOURCE_UNIFORM,
|
|
393
41
|
ASSET_PARAMETER_TYPE: () => ASSET_PARAMETER_TYPE,
|
|
@@ -397,7 +45,7 @@ __export(src_exports, {
|
|
|
397
45
|
ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
|
|
398
46
|
ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
|
|
399
47
|
ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
|
|
400
|
-
ApiClientError: () =>
|
|
48
|
+
ApiClientError: () => import_api27.ApiClientError,
|
|
401
49
|
BatchEntry: () => BatchEntry,
|
|
402
50
|
BlockFormatError: () => BlockFormatError,
|
|
403
51
|
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
|
@@ -439,7 +87,11 @@ __export(src_exports, {
|
|
|
439
87
|
CanvasClientError: () => CanvasClientError,
|
|
440
88
|
CategoryClient: () => CategoryClient,
|
|
441
89
|
ChildEnhancerBuilder: () => ChildEnhancerBuilder,
|
|
90
|
+
ComponentDefinitionClient: () => ComponentDefinitionClient,
|
|
91
|
+
CompositionDeliveryClient: () => CompositionDeliveryClient,
|
|
92
|
+
CompositionManagementClient: () => CompositionManagementClient,
|
|
442
93
|
ContentClient: () => ContentClient,
|
|
94
|
+
ContentTypeClient: () => ContentTypeClient,
|
|
443
95
|
DataSourceClient: () => DataSourceClient,
|
|
444
96
|
DataTypeClient: () => DataTypeClient,
|
|
445
97
|
EDGE_CACHE_DISABLED: () => EDGE_CACHE_DISABLED,
|
|
@@ -449,6 +101,8 @@ __export(src_exports, {
|
|
|
449
101
|
EMPTY_COMPOSITION: () => EMPTY_COMPOSITION,
|
|
450
102
|
EnhancerBuilder: () => EnhancerBuilder,
|
|
451
103
|
EntityReleasesClient: () => EntityReleasesClient,
|
|
104
|
+
EntryDeliveryClient: () => EntryDeliveryClient,
|
|
105
|
+
EntryManagementClient: () => EntryManagementClient,
|
|
452
106
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
|
453
107
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
454
108
|
IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
|
|
@@ -471,6 +125,7 @@ __export(src_exports, {
|
|
|
471
125
|
ReleaseContentsClient: () => ReleaseContentsClient,
|
|
472
126
|
RouteClient: () => RouteClient,
|
|
473
127
|
SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
|
|
128
|
+
SELECT_QUERY_PREFIX: () => SELECT_QUERY_PREFIX,
|
|
474
129
|
UncachedCanvasClient: () => UncachedCanvasClient,
|
|
475
130
|
UncachedCategoryClient: () => UncachedCategoryClient,
|
|
476
131
|
UncachedContentClient: () => UncachedContentClient,
|
|
@@ -552,191 +207,33 @@ __export(src_exports, {
|
|
|
552
207
|
localize: () => localize,
|
|
553
208
|
mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
|
|
554
209
|
mapSlotToTestVariations: () => mapSlotToTestVariations,
|
|
210
|
+
matchesProjectionPattern: () => matchesProjectionPattern,
|
|
555
211
|
mergeAssetConfigWithDefaults: () => mergeAssetConfigWithDefaults,
|
|
556
212
|
nullLimitPolicy: () => nullLimitPolicy,
|
|
557
213
|
parseComponentPlaceholderId: () => parseComponentPlaceholderId,
|
|
558
214
|
parseVariableExpression: () => parseVariableExpression,
|
|
215
|
+
projectionToQuery: () => projectionToQuery,
|
|
216
|
+
queryToProjection: () => queryToProjection,
|
|
559
217
|
version: () => version,
|
|
560
218
|
walkNodeTree: () => walkNodeTree,
|
|
561
219
|
walkPropertyValues: () => walkPropertyValues
|
|
562
220
|
});
|
|
563
|
-
module.exports = __toCommonJS(
|
|
221
|
+
module.exports = __toCommonJS(index_exports);
|
|
564
222
|
|
|
565
|
-
// src/
|
|
223
|
+
// src/CategoryClient.ts
|
|
566
224
|
var import_api2 = require("@uniformdev/context/api");
|
|
567
225
|
|
|
568
226
|
// src/enhancement/createLimitPolicy.ts
|
|
569
227
|
var import_api = require("@uniformdev/context/api");
|
|
570
|
-
var import_p_limit = __toESM(
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
var import_retry = __toESM(require_retry2(), 1);
|
|
574
|
-
var networkErrorMsgs = /* @__PURE__ */ new Set([
|
|
575
|
-
"Failed to fetch",
|
|
576
|
-
// Chrome
|
|
577
|
-
"NetworkError when attempting to fetch resource.",
|
|
578
|
-
// Firefox
|
|
579
|
-
"The Internet connection appears to be offline.",
|
|
580
|
-
// Safari
|
|
581
|
-
"Network request failed",
|
|
582
|
-
// `cross-fetch`
|
|
583
|
-
"fetch failed"
|
|
584
|
-
// Undici (Node.js)
|
|
585
|
-
]);
|
|
586
|
-
var AbortError = class extends Error {
|
|
587
|
-
constructor(message) {
|
|
588
|
-
super();
|
|
589
|
-
if (message instanceof Error) {
|
|
590
|
-
this.originalError = message;
|
|
591
|
-
({ message } = message);
|
|
592
|
-
} else {
|
|
593
|
-
this.originalError = new Error(message);
|
|
594
|
-
this.originalError.stack = this.stack;
|
|
595
|
-
}
|
|
596
|
-
this.name = "AbortError";
|
|
597
|
-
this.message = message;
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
var decorateErrorWithCounts = (error, attemptNumber, options) => {
|
|
601
|
-
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
602
|
-
error.attemptNumber = attemptNumber;
|
|
603
|
-
error.retriesLeft = retriesLeft;
|
|
604
|
-
return error;
|
|
605
|
-
};
|
|
606
|
-
var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
|
|
607
|
-
var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
|
|
608
|
-
async function pRetry(input, options) {
|
|
609
|
-
return new Promise((resolve, reject) => {
|
|
610
|
-
options = {
|
|
611
|
-
onFailedAttempt() {
|
|
612
|
-
},
|
|
613
|
-
retries: 10,
|
|
614
|
-
...options
|
|
615
|
-
};
|
|
616
|
-
const operation = import_retry.default.operation(options);
|
|
617
|
-
operation.attempt(async (attemptNumber) => {
|
|
618
|
-
try {
|
|
619
|
-
resolve(await input(attemptNumber));
|
|
620
|
-
} catch (error) {
|
|
621
|
-
if (!(error instanceof Error)) {
|
|
622
|
-
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
if (error instanceof AbortError) {
|
|
626
|
-
operation.stop();
|
|
627
|
-
reject(error.originalError);
|
|
628
|
-
} else if (error instanceof TypeError && !isNetworkError(error.message)) {
|
|
629
|
-
operation.stop();
|
|
630
|
-
reject(error);
|
|
631
|
-
} else {
|
|
632
|
-
decorateErrorWithCounts(error, attemptNumber, options);
|
|
633
|
-
try {
|
|
634
|
-
await options.onFailedAttempt(error);
|
|
635
|
-
} catch (error2) {
|
|
636
|
-
reject(error2);
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
if (!operation.retry(error)) {
|
|
640
|
-
reject(operation.mainError());
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
if (options.signal && !options.signal.aborted) {
|
|
646
|
-
options.signal.addEventListener("abort", () => {
|
|
647
|
-
operation.stop();
|
|
648
|
-
const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
|
|
649
|
-
reject(reason instanceof Error ? reason : getDOMException(reason));
|
|
650
|
-
}, {
|
|
651
|
-
once: true
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// ../../node_modules/.pnpm/p-throttle@5.0.0/node_modules/p-throttle/index.js
|
|
658
|
-
var AbortError2 = class extends Error {
|
|
659
|
-
constructor() {
|
|
660
|
-
super("Throttled function aborted");
|
|
661
|
-
this.name = "AbortError";
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
function pThrottle({ limit, interval, strict }) {
|
|
665
|
-
if (!Number.isFinite(limit)) {
|
|
666
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
667
|
-
}
|
|
668
|
-
if (!Number.isFinite(interval)) {
|
|
669
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
|
670
|
-
}
|
|
671
|
-
const queue = /* @__PURE__ */ new Map();
|
|
672
|
-
let currentTick = 0;
|
|
673
|
-
let activeCount = 0;
|
|
674
|
-
function windowedDelay() {
|
|
675
|
-
const now = Date.now();
|
|
676
|
-
if (now - currentTick > interval) {
|
|
677
|
-
activeCount = 1;
|
|
678
|
-
currentTick = now;
|
|
679
|
-
return 0;
|
|
680
|
-
}
|
|
681
|
-
if (activeCount < limit) {
|
|
682
|
-
activeCount++;
|
|
683
|
-
} else {
|
|
684
|
-
currentTick += interval;
|
|
685
|
-
activeCount = 1;
|
|
686
|
-
}
|
|
687
|
-
return currentTick - now;
|
|
688
|
-
}
|
|
689
|
-
const strictTicks = [];
|
|
690
|
-
function strictDelay() {
|
|
691
|
-
const now = Date.now();
|
|
692
|
-
if (strictTicks.length < limit) {
|
|
693
|
-
strictTicks.push(now);
|
|
694
|
-
return 0;
|
|
695
|
-
}
|
|
696
|
-
const earliestTime = strictTicks.shift() + interval;
|
|
697
|
-
if (now >= earliestTime) {
|
|
698
|
-
strictTicks.push(now);
|
|
699
|
-
return 0;
|
|
700
|
-
}
|
|
701
|
-
strictTicks.push(earliestTime);
|
|
702
|
-
return earliestTime - now;
|
|
703
|
-
}
|
|
704
|
-
const getDelay = strict ? strictDelay : windowedDelay;
|
|
705
|
-
return (function_) => {
|
|
706
|
-
const throttled = function(...args) {
|
|
707
|
-
if (!throttled.isEnabled) {
|
|
708
|
-
return (async () => function_.apply(this, args))();
|
|
709
|
-
}
|
|
710
|
-
let timeout;
|
|
711
|
-
return new Promise((resolve, reject) => {
|
|
712
|
-
const execute = () => {
|
|
713
|
-
resolve(function_.apply(this, args));
|
|
714
|
-
queue.delete(timeout);
|
|
715
|
-
};
|
|
716
|
-
timeout = setTimeout(execute, getDelay());
|
|
717
|
-
queue.set(timeout, reject);
|
|
718
|
-
});
|
|
719
|
-
};
|
|
720
|
-
throttled.abort = () => {
|
|
721
|
-
for (const timeout of queue.keys()) {
|
|
722
|
-
clearTimeout(timeout);
|
|
723
|
-
queue.get(timeout)(new AbortError2());
|
|
724
|
-
}
|
|
725
|
-
queue.clear();
|
|
726
|
-
strictTicks.splice(0, strictTicks.length);
|
|
727
|
-
};
|
|
728
|
-
throttled.isEnabled = true;
|
|
729
|
-
return throttled;
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
// src/enhancement/createLimitPolicy.ts
|
|
228
|
+
var import_p_limit = __toESM(require("p-limit"));
|
|
229
|
+
var import_p_retry = __toESM(require("p-retry"));
|
|
230
|
+
var import_p_throttle = __toESM(require("p-throttle"));
|
|
734
231
|
function createLimitPolicy({
|
|
735
232
|
throttle = { interval: 1e3, limit: 10 },
|
|
736
|
-
retry
|
|
233
|
+
retry = { retries: 1, factor: 1.66 },
|
|
737
234
|
limit = 10
|
|
738
235
|
}) {
|
|
739
|
-
const throttler = throttle ?
|
|
236
|
+
const throttler = throttle ? (0, import_p_throttle.default)(throttle) : null;
|
|
740
237
|
const limiter = limit ? (0, import_p_limit.default)(limit) : null;
|
|
741
238
|
return function limitPolicy(func) {
|
|
742
239
|
let currentFunc = async () => await func();
|
|
@@ -748,13 +245,13 @@ function createLimitPolicy({
|
|
|
748
245
|
const limitFunc = currentFunc;
|
|
749
246
|
currentFunc = () => limiter(limitFunc);
|
|
750
247
|
}
|
|
751
|
-
if (
|
|
248
|
+
if (retry) {
|
|
752
249
|
const retryFunc = currentFunc;
|
|
753
|
-
currentFunc = () =>
|
|
754
|
-
...
|
|
250
|
+
currentFunc = () => (0, import_p_retry.default)(retryFunc, {
|
|
251
|
+
...retry,
|
|
755
252
|
onFailedAttempt: async (error) => {
|
|
756
|
-
if (
|
|
757
|
-
await
|
|
253
|
+
if (retry.onFailedAttempt) {
|
|
254
|
+
await retry.onFailedAttempt(error);
|
|
758
255
|
}
|
|
759
256
|
if (error instanceof import_api.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
760
257
|
throw error;
|
|
@@ -767,9 +264,697 @@ function createLimitPolicy({
|
|
|
767
264
|
}
|
|
768
265
|
var nullLimitPolicy = async (func) => await func();
|
|
769
266
|
|
|
770
|
-
// src/
|
|
771
|
-
var
|
|
772
|
-
var
|
|
267
|
+
// src/CategoryClient.ts
|
|
268
|
+
var CATEGORIES_URL = "/api/v1/categories";
|
|
269
|
+
var CategoryClient = class extends import_api2.ApiClient {
|
|
270
|
+
constructor(options) {
|
|
271
|
+
if (!options.limitPolicy) {
|
|
272
|
+
options.limitPolicy = createLimitPolicy({});
|
|
273
|
+
}
|
|
274
|
+
super(options);
|
|
275
|
+
}
|
|
276
|
+
/** Fetches a list of categories created in given project */
|
|
277
|
+
async list(options) {
|
|
278
|
+
const { projectId } = this.options;
|
|
279
|
+
const fetchUri = this.createUrl("/api/v1/categories", { ...options, projectId });
|
|
280
|
+
return await this.apiClient(fetchUri);
|
|
281
|
+
}
|
|
282
|
+
/** @deprecated Use {@link list} instead. */
|
|
283
|
+
async getCategories(options) {
|
|
284
|
+
return this.list(options);
|
|
285
|
+
}
|
|
286
|
+
/** Updates or creates a category, also used to re-order them */
|
|
287
|
+
async save(categories) {
|
|
288
|
+
const { projectId } = this.options;
|
|
289
|
+
const fetchUri = this.createUrl(CATEGORIES_URL);
|
|
290
|
+
return await this.apiClient(fetchUri, {
|
|
291
|
+
method: "PUT",
|
|
292
|
+
body: JSON.stringify({ categories, projectId }),
|
|
293
|
+
expectNoContent: true
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** @deprecated Use {@link save} instead. */
|
|
297
|
+
async upsertCategories(categories) {
|
|
298
|
+
return this.save(categories);
|
|
299
|
+
}
|
|
300
|
+
/** Deletes a category */
|
|
301
|
+
async remove(options) {
|
|
302
|
+
const { projectId } = this.options;
|
|
303
|
+
const fetchUri = this.createUrl(CATEGORIES_URL);
|
|
304
|
+
return await this.apiClient(fetchUri, {
|
|
305
|
+
method: "DELETE",
|
|
306
|
+
body: JSON.stringify({ projectId, categoryId: options.categoryId }),
|
|
307
|
+
expectNoContent: true
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/** @deprecated Use {@link remove} instead. */
|
|
311
|
+
async removeCategory(options) {
|
|
312
|
+
return this.remove(options);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var UncachedCategoryClient = class extends CategoryClient {
|
|
316
|
+
constructor(options) {
|
|
317
|
+
super({ ...options, bypassCache: true });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/clients/ComponentDefinitionClient.ts
|
|
322
|
+
var import_api4 = require("@uniformdev/context/api");
|
|
323
|
+
|
|
324
|
+
// src/clients/ContentClientBase.ts
|
|
325
|
+
var import_api3 = require("@uniformdev/context/api");
|
|
326
|
+
var CANONICAL_FORMAT = "canonical";
|
|
327
|
+
var ContentClientBase = class extends import_api3.ApiClient {
|
|
328
|
+
constructor(options, defaultBypassCache) {
|
|
329
|
+
var _a, _b;
|
|
330
|
+
super({
|
|
331
|
+
...options,
|
|
332
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
333
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// src/clients/ComponentDefinitionClient.ts
|
|
339
|
+
var DEFINITIONS_URL = "/api/v1/canvas-definitions";
|
|
340
|
+
var ComponentDefinitionClient = class extends ContentClientBase {
|
|
341
|
+
constructor(options) {
|
|
342
|
+
super(
|
|
343
|
+
options,
|
|
344
|
+
/* defaultBypassCache */
|
|
345
|
+
true
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
/** Fetches one component definition by id (throws `ApiClientError(404)` if absent). */
|
|
349
|
+
async get(args) {
|
|
350
|
+
var _a;
|
|
351
|
+
const url = this.createUrl(DEFINITIONS_URL, {
|
|
352
|
+
componentId: args.componentId,
|
|
353
|
+
projectId: this.options.projectId
|
|
354
|
+
});
|
|
355
|
+
const res = await this.apiClient(url);
|
|
356
|
+
const definition = (_a = res.componentDefinitions) == null ? void 0 : _a[0];
|
|
357
|
+
if (!definition) {
|
|
358
|
+
throw new import_api4.ApiClientError("Component definition not found", "GET", url.toString(), 404, "Not Found");
|
|
359
|
+
}
|
|
360
|
+
return definition;
|
|
361
|
+
}
|
|
362
|
+
/** Fetches a list of component definitions. */
|
|
363
|
+
list(args) {
|
|
364
|
+
const url = this.createUrl(DEFINITIONS_URL, { ...args, projectId: this.options.projectId });
|
|
365
|
+
return this.apiClient(url);
|
|
366
|
+
}
|
|
367
|
+
/** Creates or updates a component definition. */
|
|
368
|
+
async save(def) {
|
|
369
|
+
const url = this.createUrl(DEFINITIONS_URL);
|
|
370
|
+
await this.apiClient(url, {
|
|
371
|
+
method: "PUT",
|
|
372
|
+
body: JSON.stringify({ ...def, projectId: this.options.projectId }),
|
|
373
|
+
expectNoContent: true
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/** Deletes a component definition. */
|
|
377
|
+
async remove(args) {
|
|
378
|
+
const url = this.createUrl(DEFINITIONS_URL);
|
|
379
|
+
await this.apiClient(url, {
|
|
380
|
+
method: "DELETE",
|
|
381
|
+
body: JSON.stringify({ ...args, projectId: this.options.projectId }),
|
|
382
|
+
expectNoContent: true
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// src/clients/CompositionDeliveryClient.ts
|
|
388
|
+
var import_api5 = require("@uniformdev/context/api");
|
|
389
|
+
|
|
390
|
+
// src/projection/types.ts
|
|
391
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
392
|
+
|
|
393
|
+
// src/projection/projectionToQuery.ts
|
|
394
|
+
function appendCsv(out, key, values) {
|
|
395
|
+
if (values === void 0) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
out[key] = values.join(",");
|
|
399
|
+
}
|
|
400
|
+
function projectionToQuery(spec) {
|
|
401
|
+
const out = {};
|
|
402
|
+
if (!spec) {
|
|
403
|
+
return out;
|
|
404
|
+
}
|
|
405
|
+
const { fields, fieldTypes, slots } = spec;
|
|
406
|
+
const p = SELECT_QUERY_PREFIX;
|
|
407
|
+
if (fields) {
|
|
408
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
409
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
410
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
411
|
+
}
|
|
412
|
+
if (fieldTypes) {
|
|
413
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
414
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
415
|
+
}
|
|
416
|
+
if (slots) {
|
|
417
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
418
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
419
|
+
if (typeof slots.depth === "number") {
|
|
420
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
421
|
+
}
|
|
422
|
+
if (slots.named) {
|
|
423
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
424
|
+
for (const slotName of slotNames) {
|
|
425
|
+
const named = slots.named[slotName];
|
|
426
|
+
if (named && typeof named.depth === "number") {
|
|
427
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/utils/constants.ts
|
|
436
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
437
|
+
var CANVAS_TEST_TYPE = "$test";
|
|
438
|
+
var CANVAS_LOCALIZATION_TYPE = "$localization";
|
|
439
|
+
var CANVAS_SLOT_SECTION_TYPE = "$slotSection";
|
|
440
|
+
var CANVAS_INTENT_TAG_PARAM = "intentTag";
|
|
441
|
+
var CANVAS_LOCALE_TAG_PARAM = "locale";
|
|
442
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
443
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
444
|
+
var CANVAS_TEST_SLOT = "test";
|
|
445
|
+
var CANVAS_LOCALIZATION_SLOT = "localized";
|
|
446
|
+
var CANVAS_SLOT_SECTION_SLOT = "$slotSectionItems";
|
|
447
|
+
var CANVAS_SLOT_SECTION_NAME_PARAM = "name";
|
|
448
|
+
var CANVAS_SLOT_SECTION_MIN_PARAM = "min";
|
|
449
|
+
var CANVAS_SLOT_SECTION_MAX_PARAM = "max";
|
|
450
|
+
var CANVAS_SLOT_SECTION_GROUP_TYPE_PARAM = "groupType";
|
|
451
|
+
var CANVAS_SLOT_SECTION_SPECIFIC_PARAM = "specific";
|
|
452
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
453
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
454
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
455
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
456
|
+
var CANVAS_PERSONALIZATION_EVENT_NAME_PARAM = "trackingEventName";
|
|
457
|
+
var CANVAS_PERSONALIZATION_ALGORITHM_PARAM = "algorithm";
|
|
458
|
+
var CANVAS_PERSONALIZATION_ALGORITHM_TYPE = "pzAlgorithm";
|
|
459
|
+
var CANVAS_PERSONALIZATION_TAKE_PARAM = "count";
|
|
460
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
461
|
+
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
462
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
463
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
464
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
465
|
+
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
466
|
+
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
467
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
468
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
469
|
+
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
|
470
|
+
var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
|
|
471
|
+
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
|
472
|
+
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
|
473
|
+
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
|
474
|
+
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
|
475
|
+
var PLACEHOLDER_ID = "placeholder";
|
|
476
|
+
var EMPTY_COMPOSITION = {
|
|
477
|
+
_id: "_empty_composition_id",
|
|
478
|
+
_name: "An empty composition used for contextual editing",
|
|
479
|
+
type: "_empty_composition_type"
|
|
480
|
+
};
|
|
481
|
+
var EDGE_MIN_CACHE_TTL = 10;
|
|
482
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
483
|
+
var EDGE_DEFAULT_CACHE_TTL = 30;
|
|
484
|
+
var EDGE_CACHE_DISABLED = -1;
|
|
485
|
+
var ASSET_PARAMETER_TYPE = "asset";
|
|
486
|
+
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
|
487
|
+
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
|
488
|
+
var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
|
|
489
|
+
|
|
490
|
+
// src/clients/compositionHelpers.ts
|
|
491
|
+
function resolveCompositionSelector(args) {
|
|
492
|
+
if ("compositionId" in args) {
|
|
493
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
494
|
+
return {
|
|
495
|
+
readOptions,
|
|
496
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
497
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
498
|
+
versionId,
|
|
499
|
+
hasCompositionId: true,
|
|
500
|
+
pinnedEdition: editionId !== void 0
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/clients/DeliveryClientBase.ts
|
|
507
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
508
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
509
|
+
constructor(options) {
|
|
510
|
+
var _a;
|
|
511
|
+
super(
|
|
512
|
+
options,
|
|
513
|
+
/* defaultBypassCache */
|
|
514
|
+
false
|
|
515
|
+
);
|
|
516
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
517
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
518
|
+
}
|
|
519
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
520
|
+
coerceDiagnostics(diagnostics) {
|
|
521
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// src/clients/CompositionDeliveryClient.ts
|
|
526
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
527
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
528
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
529
|
+
constructor(options) {
|
|
530
|
+
super(options);
|
|
531
|
+
}
|
|
532
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
533
|
+
get(args) {
|
|
534
|
+
var _a;
|
|
535
|
+
const { diagnostics, select, ...rest } = args;
|
|
536
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
537
|
+
const url = this.createUrl(
|
|
538
|
+
EDGE_SINGLE_URL,
|
|
539
|
+
{
|
|
540
|
+
...readOptions,
|
|
541
|
+
...projectionToQuery(select),
|
|
542
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
543
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
544
|
+
compositionId,
|
|
545
|
+
versionId,
|
|
546
|
+
projectId: this.options.projectId,
|
|
547
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
548
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
549
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
550
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
551
|
+
},
|
|
552
|
+
this.edgeApiHost
|
|
553
|
+
);
|
|
554
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
555
|
+
}
|
|
556
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
557
|
+
list(args = {}) {
|
|
558
|
+
var _a;
|
|
559
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
560
|
+
const url = this.createUrl(
|
|
561
|
+
EDGE_LIST_URL,
|
|
562
|
+
{
|
|
563
|
+
...rest,
|
|
564
|
+
...(0, import_api5.rewriteFiltersForApi)(filters),
|
|
565
|
+
...projectionToQuery(select),
|
|
566
|
+
projectId: this.options.projectId,
|
|
567
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
568
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
569
|
+
},
|
|
570
|
+
this.edgeApiHost
|
|
571
|
+
);
|
|
572
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
// src/clients/CompositionManagementClient.ts
|
|
577
|
+
var import_api6 = require("@uniformdev/context/api");
|
|
578
|
+
|
|
579
|
+
// src/clients/resolveManagementEditions.ts
|
|
580
|
+
function resolveManagementEditions({
|
|
581
|
+
explicit,
|
|
582
|
+
pinnedEdition,
|
|
583
|
+
hasId,
|
|
584
|
+
hasLocale
|
|
585
|
+
}) {
|
|
586
|
+
if (explicit) {
|
|
587
|
+
return explicit;
|
|
588
|
+
}
|
|
589
|
+
if (pinnedEdition) {
|
|
590
|
+
return "raw";
|
|
591
|
+
}
|
|
592
|
+
if (!hasId) {
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
return hasLocale ? "auto" : "raw";
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/clients/CompositionManagementClient.ts
|
|
599
|
+
var CANVAS_URL = "/api/v1/canvas";
|
|
600
|
+
var CANVAS_HISTORY_URL = "/api/v1/canvas-history";
|
|
601
|
+
var CompositionManagementClient = class extends ContentClientBase {
|
|
602
|
+
constructor(options) {
|
|
603
|
+
super(
|
|
604
|
+
options,
|
|
605
|
+
/* defaultBypassCache */
|
|
606
|
+
true
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Fetches one composition in canonical shape (throws `ApiClientError(404)` if
|
|
611
|
+
* absent).
|
|
612
|
+
*/
|
|
613
|
+
get(args) {
|
|
614
|
+
var _a;
|
|
615
|
+
const { select, ...selectorArgs } = args;
|
|
616
|
+
const { readOptions, compositionId, versionId, hasCompositionId, pinnedEdition } = resolveCompositionSelector(selectorArgs);
|
|
617
|
+
const url = this.createUrl(CANVAS_URL, {
|
|
618
|
+
format: CANONICAL_FORMAT,
|
|
619
|
+
// Caller-supplied shaping flags and non-id selector keys ride along and
|
|
620
|
+
// override the format alias server-side.
|
|
621
|
+
...readOptions,
|
|
622
|
+
...projectionToQuery(select),
|
|
623
|
+
// A pinned edition is folded into compositionId; there is no editionId
|
|
624
|
+
// query param on this endpoint.
|
|
625
|
+
compositionId,
|
|
626
|
+
versionId,
|
|
627
|
+
projectId: this.options.projectId,
|
|
628
|
+
state: (_a = args.state) != null ? _a : CANVAS_DRAFT_STATE,
|
|
629
|
+
editions: resolveManagementEditions({
|
|
630
|
+
explicit: readOptions.editions,
|
|
631
|
+
pinnedEdition,
|
|
632
|
+
hasId: hasCompositionId,
|
|
633
|
+
hasLocale: readOptions.locale != null
|
|
634
|
+
})
|
|
635
|
+
});
|
|
636
|
+
return this.apiClient(url);
|
|
637
|
+
}
|
|
638
|
+
/** Fetches a list of compositions in canonical shape. */
|
|
639
|
+
list(args = {}) {
|
|
640
|
+
var _a;
|
|
641
|
+
const { filters, select, ...rest } = args;
|
|
642
|
+
const url = this.createUrl(CANVAS_URL, {
|
|
643
|
+
format: CANONICAL_FORMAT,
|
|
644
|
+
...rest,
|
|
645
|
+
...(0, import_api6.rewriteFiltersForApi)(filters),
|
|
646
|
+
...projectionToQuery(select),
|
|
647
|
+
projectId: this.options.projectId,
|
|
648
|
+
state: (_a = args.state) != null ? _a : CANVAS_DRAFT_STATE
|
|
649
|
+
});
|
|
650
|
+
return this.apiClient(url);
|
|
651
|
+
}
|
|
652
|
+
/** Creates or updates a composition. Returns the new `x-modified-at` timestamp. */
|
|
653
|
+
async save(body, opts) {
|
|
654
|
+
const url = this.createUrl(CANVAS_URL);
|
|
655
|
+
const headers = {};
|
|
656
|
+
if (opts == null ? void 0 : opts.ifUnmodifiedSince) {
|
|
657
|
+
headers["x-if-unmodified-since"] = opts.ifUnmodifiedSince;
|
|
658
|
+
}
|
|
659
|
+
const { response } = await this.apiClientWithResponse(url, {
|
|
660
|
+
method: "PUT",
|
|
661
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
662
|
+
expectNoContent: true,
|
|
663
|
+
headers
|
|
664
|
+
});
|
|
665
|
+
return { modified: response.headers.get("x-modified-at") };
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Saves the draft and publishes in one call (two PUTs). The optimistic
|
|
669
|
+
* concurrency guard, if any, applies to the draft write.
|
|
670
|
+
*/
|
|
671
|
+
async saveAndPublish(body, opts) {
|
|
672
|
+
await this.save({ ...body, state: CANVAS_DRAFT_STATE }, opts);
|
|
673
|
+
return this.save({ ...body, state: CANVAS_PUBLISHED_STATE });
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Removes only the published state, leaving the draft intact. Scoped to a
|
|
677
|
+
* single edition when `editionId` is supplied; otherwise unpublishes all editions.
|
|
678
|
+
* To unpublish only the base edition, pass editionId and compositionId as the same value.
|
|
679
|
+
*/
|
|
680
|
+
async unpublish(selector) {
|
|
681
|
+
await this.deleteComposition({ ...selector, state: CANVAS_PUBLISHED_STATE });
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Deletes across all states. Scoped to a single edition when `editionId` is
|
|
685
|
+
* supplied; otherwise deletes all states and editions.
|
|
686
|
+
* Use `unpublish` to drop only the published state.
|
|
687
|
+
*/
|
|
688
|
+
async remove(selector) {
|
|
689
|
+
await this.deleteComposition(selector);
|
|
690
|
+
}
|
|
691
|
+
/** Fetches historical versions of a composition or pattern. */
|
|
692
|
+
history(args) {
|
|
693
|
+
const url = this.createUrl(CANVAS_HISTORY_URL, { ...args, projectId: this.options.projectId });
|
|
694
|
+
return this.apiClient(url);
|
|
695
|
+
}
|
|
696
|
+
async deleteComposition(body) {
|
|
697
|
+
const url = this.createUrl(CANVAS_URL);
|
|
698
|
+
await this.apiClient(url, {
|
|
699
|
+
method: "DELETE",
|
|
700
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
701
|
+
expectNoContent: true
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// src/clients/ContentTypeClient.ts
|
|
707
|
+
var import_api7 = require("@uniformdev/context/api");
|
|
708
|
+
var CONTENT_TYPES_URL = "/api/v1/content-types";
|
|
709
|
+
var ContentTypeClient = class extends ContentClientBase {
|
|
710
|
+
constructor(options) {
|
|
711
|
+
super(
|
|
712
|
+
options,
|
|
713
|
+
/* defaultBypassCache */
|
|
714
|
+
true
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
/** Fetches one content type by id (throws `ApiClientError(404)` if absent). */
|
|
718
|
+
async get(args) {
|
|
719
|
+
var _a;
|
|
720
|
+
const url = this.createUrl(CONTENT_TYPES_URL, {
|
|
721
|
+
contentTypeIDs: [args.contentTypeId],
|
|
722
|
+
limit: 1,
|
|
723
|
+
projectId: this.options.projectId
|
|
724
|
+
});
|
|
725
|
+
const res = await this.apiClient(url);
|
|
726
|
+
const contentType = (_a = res.contentTypes) == null ? void 0 : _a[0];
|
|
727
|
+
if (!contentType) {
|
|
728
|
+
throw new import_api7.ApiClientError("Content type not found", "GET", url.toString(), 404, "Not Found");
|
|
729
|
+
}
|
|
730
|
+
return contentType;
|
|
731
|
+
}
|
|
732
|
+
/** Fetches a list of content types. */
|
|
733
|
+
list(args) {
|
|
734
|
+
const url = this.createUrl(CONTENT_TYPES_URL, { ...args, projectId: this.options.projectId });
|
|
735
|
+
return this.apiClient(url);
|
|
736
|
+
}
|
|
737
|
+
/** Creates or updates a content type. */
|
|
738
|
+
async save(body, opts = {}) {
|
|
739
|
+
const url = this.createUrl(CONTENT_TYPES_URL);
|
|
740
|
+
let contentType = body.contentType;
|
|
741
|
+
if (typeof contentType.slugSettings === "object" && contentType.slugSettings !== null && Object.keys(contentType.slugSettings).length === 0) {
|
|
742
|
+
const { slugSettings: _omitEmptySlugSettings, ...rest } = contentType;
|
|
743
|
+
contentType = rest;
|
|
744
|
+
}
|
|
745
|
+
await this.apiClient(url, {
|
|
746
|
+
method: "PUT",
|
|
747
|
+
body: JSON.stringify({ ...body, contentType, projectId: this.options.projectId }),
|
|
748
|
+
expectNoContent: true,
|
|
749
|
+
headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/** Deletes a content type. */
|
|
753
|
+
async remove(args) {
|
|
754
|
+
const url = this.createUrl(CONTENT_TYPES_URL);
|
|
755
|
+
await this.apiClient(url, {
|
|
756
|
+
method: "DELETE",
|
|
757
|
+
body: JSON.stringify({ ...args, projectId: this.options.projectId }),
|
|
758
|
+
expectNoContent: true
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/clients/EntryDeliveryClient.ts
|
|
764
|
+
var import_api9 = require("@uniformdev/context/api");
|
|
765
|
+
|
|
766
|
+
// src/clients/entryHelpers.ts
|
|
767
|
+
var import_api8 = require("@uniformdev/context/api");
|
|
768
|
+
function resolveEntrySelector(args) {
|
|
769
|
+
if ("entryId" in args) {
|
|
770
|
+
const { entryId, editionId, versionId, ...readOptions2 } = args;
|
|
771
|
+
return {
|
|
772
|
+
readOptions: readOptions2,
|
|
773
|
+
entryIDs: [editionId != null ? editionId : entryId],
|
|
774
|
+
versionId,
|
|
775
|
+
pinnedEdition: editionId !== void 0
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
const { slug, ...readOptions } = args;
|
|
779
|
+
return { readOptions, slug, pinnedEdition: false };
|
|
780
|
+
}
|
|
781
|
+
function unwrapSingleEntry(res, url) {
|
|
782
|
+
var _a;
|
|
783
|
+
const entry = (_a = res.entries) == null ? void 0 : _a[0];
|
|
784
|
+
if (!entry) {
|
|
785
|
+
throw new import_api8.ApiClientError("Entry not found", "GET", url.toString(), 404, "Not Found");
|
|
786
|
+
}
|
|
787
|
+
return entry;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// src/clients/EntryDeliveryClient.ts
|
|
791
|
+
var ENTRIES_URL = "/api/v1/entries";
|
|
792
|
+
var EntryDeliveryClient = class extends DeliveryClientBase {
|
|
793
|
+
constructor(options) {
|
|
794
|
+
super(options);
|
|
795
|
+
}
|
|
796
|
+
/** Fetches exactly one entry by id or slug (throws `ApiClientError(404)` if absent). */
|
|
797
|
+
async get(args) {
|
|
798
|
+
var _a, _b;
|
|
799
|
+
const { diagnostics, select, ...rest } = args;
|
|
800
|
+
const { entryIDs, slug, versionId, pinnedEdition, readOptions } = resolveEntrySelector(rest);
|
|
801
|
+
const url = this.createUrl(
|
|
802
|
+
ENTRIES_URL,
|
|
803
|
+
{
|
|
804
|
+
...readOptions,
|
|
805
|
+
...projectionToQuery(select),
|
|
806
|
+
projectId: this.options.projectId,
|
|
807
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
808
|
+
entryIDs,
|
|
809
|
+
slug,
|
|
810
|
+
versionId,
|
|
811
|
+
// A pinned edition is fetched exactly; otherwise locale-best.
|
|
812
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
813
|
+
// An id lookup wants that exact entity regardless of type, so default the
|
|
814
|
+
// pattern filter to 'any' (origin default `false` would 404 a pattern id).
|
|
815
|
+
// Scoped to id lookups; slug reads keep the origin default. Explicit
|
|
816
|
+
// `pattern` overrides via the `...readOptions` spread above.
|
|
817
|
+
pattern: (_b = args.pattern) != null ? _b : entryIDs ? "any" : void 0,
|
|
818
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
819
|
+
},
|
|
820
|
+
this.edgeApiHost
|
|
821
|
+
);
|
|
822
|
+
const res = await this.apiClient(url, this.edgeRequestInit);
|
|
823
|
+
return unwrapSingleEntry(res, url);
|
|
824
|
+
}
|
|
825
|
+
/** Fetches a list of entries, optionally filtered. */
|
|
826
|
+
list(args = {}) {
|
|
827
|
+
var _a;
|
|
828
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
829
|
+
const url = this.createUrl(
|
|
830
|
+
ENTRIES_URL,
|
|
831
|
+
{
|
|
832
|
+
...rest,
|
|
833
|
+
...(0, import_api9.rewriteFiltersForApi)(filters),
|
|
834
|
+
...projectionToQuery(select),
|
|
835
|
+
projectId: this.options.projectId,
|
|
836
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
837
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
838
|
+
},
|
|
839
|
+
this.edgeApiHost
|
|
840
|
+
);
|
|
841
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
// src/clients/EntryManagementClient.ts
|
|
846
|
+
var import_api10 = require("@uniformdev/context/api");
|
|
847
|
+
var ENTRIES_URL2 = "/api/v1/entries";
|
|
848
|
+
var ENTRIES_HISTORY_URL = "/api/v1/entries-history";
|
|
849
|
+
var EntryManagementClient = class extends ContentClientBase {
|
|
850
|
+
constructor(options) {
|
|
851
|
+
super(
|
|
852
|
+
options,
|
|
853
|
+
/* defaultBypassCache */
|
|
854
|
+
true
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Fetches one entry by id or slug in canonical shape (throws
|
|
859
|
+
* `ApiClientError(404)` if absent).
|
|
860
|
+
*/
|
|
861
|
+
async get(args) {
|
|
862
|
+
var _a, _b;
|
|
863
|
+
const { select, ...selectorArgs } = args;
|
|
864
|
+
const { entryIDs, slug, versionId, readOptions, pinnedEdition } = resolveEntrySelector(selectorArgs);
|
|
865
|
+
const url = this.createUrl(ENTRIES_URL2, {
|
|
866
|
+
format: CANONICAL_FORMAT,
|
|
867
|
+
...readOptions,
|
|
868
|
+
...projectionToQuery(select),
|
|
869
|
+
projectId: this.options.projectId,
|
|
870
|
+
state: (_a = args.state) != null ? _a : CANVAS_DRAFT_STATE,
|
|
871
|
+
editions: resolveManagementEditions({
|
|
872
|
+
explicit: readOptions.editions,
|
|
873
|
+
pinnedEdition,
|
|
874
|
+
hasId: entryIDs != null,
|
|
875
|
+
hasLocale: readOptions.locale != null
|
|
876
|
+
}),
|
|
877
|
+
// An id lookup wants that exact entity regardless of type, so default the
|
|
878
|
+
// pattern filter to 'any' (origin default `false` would 404 a pattern id).
|
|
879
|
+
// Scoped to id lookups; slug reads keep the origin default. Explicit
|
|
880
|
+
// `pattern` overrides via the `...readOptions` spread above.
|
|
881
|
+
pattern: (_b = args.pattern) != null ? _b : entryIDs ? "any" : void 0,
|
|
882
|
+
entryIDs,
|
|
883
|
+
slug,
|
|
884
|
+
versionId
|
|
885
|
+
});
|
|
886
|
+
const res = await this.apiClient(url);
|
|
887
|
+
return unwrapSingleEntry(res, url);
|
|
888
|
+
}
|
|
889
|
+
/** Fetches a list of entries in canonical shape. */
|
|
890
|
+
list(args = {}) {
|
|
891
|
+
var _a;
|
|
892
|
+
const { filters, select, ...rest } = args;
|
|
893
|
+
const url = this.createUrl(ENTRIES_URL2, {
|
|
894
|
+
format: CANONICAL_FORMAT,
|
|
895
|
+
...rest,
|
|
896
|
+
...(0, import_api10.rewriteFiltersForApi)(filters),
|
|
897
|
+
...projectionToQuery(select),
|
|
898
|
+
projectId: this.options.projectId,
|
|
899
|
+
state: (_a = args.state) != null ? _a : CANVAS_DRAFT_STATE
|
|
900
|
+
});
|
|
901
|
+
return this.apiClient(url);
|
|
902
|
+
}
|
|
903
|
+
/** Creates or updates an entry. Returns the new `x-modified-at` timestamp. */
|
|
904
|
+
async save(body, opts) {
|
|
905
|
+
const url = this.createUrl(ENTRIES_URL2);
|
|
906
|
+
const headers = {};
|
|
907
|
+
if (opts == null ? void 0 : opts.ifUnmodifiedSince) {
|
|
908
|
+
headers["x-if-unmodified-since"] = opts.ifUnmodifiedSince;
|
|
909
|
+
}
|
|
910
|
+
const { response } = await this.apiClientWithResponse(url, {
|
|
911
|
+
method: "PUT",
|
|
912
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
913
|
+
expectNoContent: true,
|
|
914
|
+
headers
|
|
915
|
+
});
|
|
916
|
+
return { modified: response.headers.get("x-modified-at") };
|
|
917
|
+
}
|
|
918
|
+
/** Saves the draft and publishes in one call (two PUTs). */
|
|
919
|
+
async saveAndPublish(body, opts) {
|
|
920
|
+
await this.save({ ...body, state: CANVAS_DRAFT_STATE }, opts);
|
|
921
|
+
return this.save({ ...body, state: CANVAS_PUBLISHED_STATE });
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Removes only the published state, leaving the draft intact. Scoped to a
|
|
925
|
+
* single edition when `editionId` is supplied; otherwise unpublishes all editions.
|
|
926
|
+
* To unpublish only the base edition, pass editionId and entryId as the same value.
|
|
927
|
+
*/
|
|
928
|
+
async unpublish(selector) {
|
|
929
|
+
await this.deleteEntry({ ...selector, state: CANVAS_PUBLISHED_STATE });
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Deletes across all states. Scoped to a single edition when `editionId` is
|
|
933
|
+
* supplied; otherwise deletes all states and editions.
|
|
934
|
+
* Use `unpublish` to drop only the published state.
|
|
935
|
+
*/
|
|
936
|
+
async remove(selector) {
|
|
937
|
+
await this.deleteEntry(selector);
|
|
938
|
+
}
|
|
939
|
+
/** Fetches historical versions of an entry. */
|
|
940
|
+
history(args) {
|
|
941
|
+
const url = this.createUrl(ENTRIES_HISTORY_URL, { ...args, projectId: this.options.projectId });
|
|
942
|
+
return this.apiClient(url);
|
|
943
|
+
}
|
|
944
|
+
async deleteEntry(body) {
|
|
945
|
+
const url = this.createUrl(ENTRIES_URL2);
|
|
946
|
+
await this.apiClient(url, {
|
|
947
|
+
method: "DELETE",
|
|
948
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
949
|
+
expectNoContent: true
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// src/clients/deprecated/CanvasClient.ts
|
|
955
|
+
var import_api11 = require("@uniformdev/context/api");
|
|
956
|
+
var CANVAS_URL2 = "/api/v1/canvas";
|
|
957
|
+
var CanvasClient = class extends import_api11.ApiClient {
|
|
773
958
|
constructor(options) {
|
|
774
959
|
var _a;
|
|
775
960
|
if (!options.limitPolicy) {
|
|
@@ -782,17 +967,24 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
782
967
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
783
968
|
async getCompositionList(params = {}) {
|
|
784
969
|
const { projectId } = this.options;
|
|
785
|
-
const { resolveData, filters, ...originParams } = params;
|
|
786
|
-
const rewrittenFilters = (0,
|
|
970
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
971
|
+
const rewrittenFilters = (0, import_api11.rewriteFiltersForApi)(filters);
|
|
972
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
787
973
|
if (!resolveData) {
|
|
788
|
-
const fetchUri = this.createUrl(
|
|
974
|
+
const fetchUri = this.createUrl(CANVAS_URL2, {
|
|
975
|
+
...originParams,
|
|
976
|
+
projectId,
|
|
977
|
+
...rewrittenFilters,
|
|
978
|
+
...rewrittenSelect
|
|
979
|
+
});
|
|
789
980
|
return this.apiClient(fetchUri);
|
|
790
981
|
}
|
|
791
982
|
const edgeParams = {
|
|
792
983
|
...originParams,
|
|
793
984
|
projectId,
|
|
794
985
|
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
795
|
-
...rewrittenFilters
|
|
986
|
+
...rewrittenFilters,
|
|
987
|
+
...rewrittenSelect
|
|
796
988
|
};
|
|
797
989
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
798
990
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
@@ -827,7 +1019,7 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
827
1019
|
}) {
|
|
828
1020
|
const { projectId } = this.options;
|
|
829
1021
|
if (skipDataResolution) {
|
|
830
|
-
return this.apiClient(this.createUrl(
|
|
1022
|
+
return this.apiClient(this.createUrl(CANVAS_URL2, { ...params, projectId }));
|
|
831
1023
|
}
|
|
832
1024
|
const edgeParams = {
|
|
833
1025
|
...params,
|
|
@@ -839,7 +1031,7 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
839
1031
|
}
|
|
840
1032
|
/** Updates or creates a Canvas component definition */
|
|
841
1033
|
async updateComposition(body, options) {
|
|
842
|
-
const fetchUri = this.createUrl(
|
|
1034
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
843
1035
|
const headers = {};
|
|
844
1036
|
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
845
1037
|
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
@@ -854,7 +1046,7 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
854
1046
|
}
|
|
855
1047
|
/** Deletes a Canvas component definition */
|
|
856
1048
|
async removeComposition(body) {
|
|
857
|
-
const fetchUri = this.createUrl(
|
|
1049
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
858
1050
|
const { projectId } = this.options;
|
|
859
1051
|
await this.apiClient(fetchUri, {
|
|
860
1052
|
method: "DELETE",
|
|
@@ -893,53 +1085,10 @@ var UncachedCanvasClient = class extends CanvasClient {
|
|
|
893
1085
|
}
|
|
894
1086
|
};
|
|
895
1087
|
|
|
896
|
-
// src/
|
|
897
|
-
var
|
|
898
|
-
var CATEGORIES_URL = "/api/v1/categories";
|
|
899
|
-
var CategoryClient = class extends import_api3.ApiClient {
|
|
900
|
-
constructor(options) {
|
|
901
|
-
if (!options.limitPolicy) {
|
|
902
|
-
options.limitPolicy = createLimitPolicy({});
|
|
903
|
-
}
|
|
904
|
-
super(options);
|
|
905
|
-
}
|
|
906
|
-
/** Fetches all categories created in given project */
|
|
907
|
-
async getCategories(options) {
|
|
908
|
-
const { projectId } = this.options;
|
|
909
|
-
const fetchUri = this.createUrl("/api/v1/categories", { ...options, projectId });
|
|
910
|
-
return await this.apiClient(fetchUri);
|
|
911
|
-
}
|
|
912
|
-
/** Updates or creates a category, also used to re-order them */
|
|
913
|
-
async upsertCategories(categories) {
|
|
914
|
-
const { projectId } = this.options;
|
|
915
|
-
const fetchUri = this.createUrl(CATEGORIES_URL);
|
|
916
|
-
return await this.apiClient(fetchUri, {
|
|
917
|
-
method: "PUT",
|
|
918
|
-
body: JSON.stringify({ categories, projectId }),
|
|
919
|
-
expectNoContent: true
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
/** Deletes a category */
|
|
923
|
-
async removeCategory(options) {
|
|
924
|
-
const { projectId } = this.options;
|
|
925
|
-
const fetchUri = this.createUrl(CATEGORIES_URL);
|
|
926
|
-
return await this.apiClient(fetchUri, {
|
|
927
|
-
method: "DELETE",
|
|
928
|
-
body: JSON.stringify({ projectId, categoryId: options.categoryId }),
|
|
929
|
-
expectNoContent: true
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
var UncachedCategoryClient = class extends CategoryClient {
|
|
934
|
-
constructor(options) {
|
|
935
|
-
super({ ...options, bypassCache: true });
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
// src/ContentClient.ts
|
|
940
|
-
var import_api4 = require("@uniformdev/context/api");
|
|
1088
|
+
// src/clients/deprecated/ContentClient.ts
|
|
1089
|
+
var import_api12 = require("@uniformdev/context/api");
|
|
941
1090
|
var _contentTypesUrl, _entriesUrl;
|
|
942
|
-
var _ContentClient = class _ContentClient extends
|
|
1091
|
+
var _ContentClient = class _ContentClient extends import_api12.ApiClient {
|
|
943
1092
|
constructor(options) {
|
|
944
1093
|
var _a;
|
|
945
1094
|
super(options);
|
|
@@ -952,15 +1101,21 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
|
|
|
952
1101
|
}
|
|
953
1102
|
getEntries(options) {
|
|
954
1103
|
const { projectId } = this.options;
|
|
955
|
-
const { skipDataResolution, filters, ...params } = options;
|
|
956
|
-
const rewrittenFilters = (0,
|
|
1104
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
1105
|
+
const rewrittenFilters = (0, import_api12.rewriteFiltersForApi)(filters);
|
|
1106
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
957
1107
|
if (skipDataResolution) {
|
|
958
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
1108
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
1109
|
+
...params,
|
|
1110
|
+
...rewrittenFilters,
|
|
1111
|
+
...rewrittenSelect,
|
|
1112
|
+
projectId
|
|
1113
|
+
});
|
|
959
1114
|
return this.apiClient(url);
|
|
960
1115
|
}
|
|
961
1116
|
const edgeUrl = this.createUrl(
|
|
962
1117
|
__privateGet(_ContentClient, _entriesUrl),
|
|
963
|
-
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
|
1118
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
964
1119
|
this.edgeApiHost
|
|
965
1120
|
);
|
|
966
1121
|
return this.apiClient(
|
|
@@ -1040,27 +1195,31 @@ var UncachedContentClient = class extends ContentClient {
|
|
|
1040
1195
|
};
|
|
1041
1196
|
|
|
1042
1197
|
// src/DataSourceClient.ts
|
|
1043
|
-
var
|
|
1198
|
+
var import_api13 = require("@uniformdev/context/api");
|
|
1044
1199
|
var dataSourceUrl = "/api/v1/data-source";
|
|
1045
1200
|
var dataSourcesUrl = "/api/v1/data-sources";
|
|
1046
|
-
var DataSourceClient = class extends
|
|
1201
|
+
var DataSourceClient = class extends import_api13.ApiClient {
|
|
1047
1202
|
constructor(options) {
|
|
1048
1203
|
super(options);
|
|
1049
1204
|
}
|
|
1050
|
-
/** Fetches
|
|
1205
|
+
/** Fetches a single DataSource by id (with decrypted secrets). */
|
|
1051
1206
|
async get(options) {
|
|
1052
1207
|
const { projectId } = this.options;
|
|
1053
1208
|
const fetchUri = this.createUrl(dataSourceUrl, { ...options, projectId });
|
|
1054
1209
|
return await this.apiClient(fetchUri);
|
|
1055
1210
|
}
|
|
1056
|
-
/** Fetches
|
|
1057
|
-
async
|
|
1211
|
+
/** Fetches the list of DataSources for a project (secrets masked). */
|
|
1212
|
+
async list(options) {
|
|
1058
1213
|
const { projectId } = this.options;
|
|
1059
1214
|
const fetchUri = this.createUrl(dataSourcesUrl, { ...options, projectId });
|
|
1060
1215
|
return await this.apiClient(fetchUri);
|
|
1061
1216
|
}
|
|
1217
|
+
/** @deprecated Use {@link list} instead. */
|
|
1218
|
+
async getList(options) {
|
|
1219
|
+
return this.list(options);
|
|
1220
|
+
}
|
|
1062
1221
|
/** Updates or creates (based on id) a DataSource */
|
|
1063
|
-
async
|
|
1222
|
+
async save(body) {
|
|
1064
1223
|
const fetchUri = this.createUrl(dataSourceUrl);
|
|
1065
1224
|
await this.apiClient(fetchUri, {
|
|
1066
1225
|
method: "PUT",
|
|
@@ -1068,6 +1227,10 @@ var DataSourceClient = class extends import_api5.ApiClient {
|
|
|
1068
1227
|
expectNoContent: true
|
|
1069
1228
|
});
|
|
1070
1229
|
}
|
|
1230
|
+
/** @deprecated Use {@link save} instead. */
|
|
1231
|
+
async upsert(body) {
|
|
1232
|
+
return this.save(body);
|
|
1233
|
+
}
|
|
1071
1234
|
/** Deletes a DataSource */
|
|
1072
1235
|
async remove(body) {
|
|
1073
1236
|
const fetchUri = this.createUrl(dataSourceUrl);
|
|
@@ -1080,20 +1243,24 @@ var DataSourceClient = class extends import_api5.ApiClient {
|
|
|
1080
1243
|
};
|
|
1081
1244
|
|
|
1082
1245
|
// src/DataTypeClient.ts
|
|
1083
|
-
var
|
|
1246
|
+
var import_api14 = require("@uniformdev/context/api");
|
|
1084
1247
|
var _url;
|
|
1085
|
-
var _DataTypeClient = class _DataTypeClient extends
|
|
1248
|
+
var _DataTypeClient = class _DataTypeClient extends import_api14.ApiClient {
|
|
1086
1249
|
constructor(options) {
|
|
1087
1250
|
super(options);
|
|
1088
1251
|
}
|
|
1089
|
-
/** Fetches
|
|
1090
|
-
async
|
|
1252
|
+
/** Fetches a list of DataTypes for a project */
|
|
1253
|
+
async list(options) {
|
|
1091
1254
|
const { projectId } = this.options;
|
|
1092
1255
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url), { ...options, projectId });
|
|
1093
1256
|
return await this.apiClient(fetchUri);
|
|
1094
1257
|
}
|
|
1258
|
+
/** @deprecated Use {@link list} instead. */
|
|
1259
|
+
async get(options) {
|
|
1260
|
+
return this.list(options);
|
|
1261
|
+
}
|
|
1095
1262
|
/** Updates or creates (based on id) a DataType */
|
|
1096
|
-
async
|
|
1263
|
+
async save(body) {
|
|
1097
1264
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
|
1098
1265
|
await this.apiClient(fetchUri, {
|
|
1099
1266
|
method: "PUT",
|
|
@@ -1101,6 +1268,10 @@ var _DataTypeClient = class _DataTypeClient extends import_api6.ApiClient {
|
|
|
1101
1268
|
expectNoContent: true
|
|
1102
1269
|
});
|
|
1103
1270
|
}
|
|
1271
|
+
/** @deprecated Use {@link save} instead. */
|
|
1272
|
+
async upsert(body) {
|
|
1273
|
+
return this.save(body);
|
|
1274
|
+
}
|
|
1104
1275
|
/** Deletes a DataType */
|
|
1105
1276
|
async remove(body) {
|
|
1106
1277
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
|
@@ -1236,61 +1407,6 @@ function getComponentPath(ancestorsAndSelf) {
|
|
|
1236
1407
|
return `.${path.join(".")}`;
|
|
1237
1408
|
}
|
|
1238
1409
|
|
|
1239
|
-
// src/utils/constants.ts
|
|
1240
|
-
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1241
|
-
var CANVAS_TEST_TYPE = "$test";
|
|
1242
|
-
var CANVAS_LOCALIZATION_TYPE = "$localization";
|
|
1243
|
-
var CANVAS_SLOT_SECTION_TYPE = "$slotSection";
|
|
1244
|
-
var CANVAS_INTENT_TAG_PARAM = "intentTag";
|
|
1245
|
-
var CANVAS_LOCALE_TAG_PARAM = "locale";
|
|
1246
|
-
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1247
|
-
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1248
|
-
var CANVAS_TEST_SLOT = "test";
|
|
1249
|
-
var CANVAS_LOCALIZATION_SLOT = "localized";
|
|
1250
|
-
var CANVAS_SLOT_SECTION_SLOT = "$slotSectionItems";
|
|
1251
|
-
var CANVAS_SLOT_SECTION_NAME_PARAM = "name";
|
|
1252
|
-
var CANVAS_SLOT_SECTION_MIN_PARAM = "min";
|
|
1253
|
-
var CANVAS_SLOT_SECTION_MAX_PARAM = "max";
|
|
1254
|
-
var CANVAS_SLOT_SECTION_GROUP_TYPE_PARAM = "groupType";
|
|
1255
|
-
var CANVAS_SLOT_SECTION_SPECIFIC_PARAM = "specific";
|
|
1256
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1257
|
-
var CANVAS_PUBLISHED_STATE = 64;
|
|
1258
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1259
|
-
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1260
|
-
var CANVAS_PERSONALIZATION_EVENT_NAME_PARAM = "trackingEventName";
|
|
1261
|
-
var CANVAS_PERSONALIZATION_ALGORITHM_PARAM = "algorithm";
|
|
1262
|
-
var CANVAS_PERSONALIZATION_ALGORITHM_TYPE = "pzAlgorithm";
|
|
1263
|
-
var CANVAS_PERSONALIZATION_TAKE_PARAM = "count";
|
|
1264
|
-
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1265
|
-
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1266
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1267
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1268
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1269
|
-
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1270
|
-
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1271
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1272
|
-
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1273
|
-
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
|
1274
|
-
var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
|
|
1275
|
-
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
|
1276
|
-
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
|
1277
|
-
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
|
1278
|
-
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
|
1279
|
-
var PLACEHOLDER_ID = "placeholder";
|
|
1280
|
-
var EMPTY_COMPOSITION = {
|
|
1281
|
-
_id: "_empty_composition_id",
|
|
1282
|
-
_name: "An empty composition used for contextual editing",
|
|
1283
|
-
type: "_empty_composition_type"
|
|
1284
|
-
};
|
|
1285
|
-
var EDGE_MIN_CACHE_TTL = 10;
|
|
1286
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1287
|
-
var EDGE_DEFAULT_CACHE_TTL = 30;
|
|
1288
|
-
var EDGE_CACHE_DISABLED = -1;
|
|
1289
|
-
var ASSET_PARAMETER_TYPE = "asset";
|
|
1290
|
-
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
|
1291
|
-
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
|
1292
|
-
var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
|
|
1293
|
-
|
|
1294
1410
|
// src/utils/guards.ts
|
|
1295
1411
|
function isRootEntryReference(root) {
|
|
1296
1412
|
return root.type === "root" && isEntryData(root.node);
|
|
@@ -2589,8 +2705,7 @@ function extractLocales({ component }) {
|
|
|
2589
2705
|
return variations;
|
|
2590
2706
|
}
|
|
2591
2707
|
function localize(options) {
|
|
2592
|
-
const nodes = options
|
|
2593
|
-
const locale = options.locale;
|
|
2708
|
+
const { nodes, locale, keepLocalesFor } = options;
|
|
2594
2709
|
if (!locale) {
|
|
2595
2710
|
return;
|
|
2596
2711
|
}
|
|
@@ -2598,7 +2713,7 @@ function localize(options) {
|
|
|
2598
2713
|
walkNodeTree(nodes, (context) => {
|
|
2599
2714
|
const { type, node, actions } = context;
|
|
2600
2715
|
if (type !== "component") {
|
|
2601
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2716
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2602
2717
|
return;
|
|
2603
2718
|
}
|
|
2604
2719
|
const result = evaluateWalkTreeNodeVisibility({
|
|
@@ -2619,7 +2734,7 @@ function localize(options) {
|
|
|
2619
2734
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
|
2620
2735
|
replaceComponent.forEach((component) => {
|
|
2621
2736
|
removeLocaleProperty(component);
|
|
2622
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
|
2737
|
+
localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2623
2738
|
});
|
|
2624
2739
|
const [first, ...rest] = replaceComponent;
|
|
2625
2740
|
actions.replace(first);
|
|
@@ -2630,7 +2745,7 @@ function localize(options) {
|
|
|
2630
2745
|
actions.remove();
|
|
2631
2746
|
}
|
|
2632
2747
|
} else {
|
|
2633
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2748
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2634
2749
|
}
|
|
2635
2750
|
});
|
|
2636
2751
|
}
|
|
@@ -2649,7 +2764,7 @@ function removeLocaleProperty(component) {
|
|
|
2649
2764
|
}
|
|
2650
2765
|
}
|
|
2651
2766
|
}
|
|
2652
|
-
function localizeProperties(node, locale, rules) {
|
|
2767
|
+
function localizeProperties(node, locale, rules, keepLocalesFor) {
|
|
2653
2768
|
const properties = getPropertiesValue(node);
|
|
2654
2769
|
if (!properties) {
|
|
2655
2770
|
return void 0;
|
|
@@ -2668,10 +2783,16 @@ function localizeProperties(node, locale, rules) {
|
|
|
2668
2783
|
if (currentLocaleConditionalValues !== void 0) {
|
|
2669
2784
|
propertyValue.conditions = currentLocaleConditionalValues;
|
|
2670
2785
|
}
|
|
2671
|
-
|
|
2672
|
-
|
|
2786
|
+
const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
|
|
2787
|
+
if (!preserveLocales) {
|
|
2788
|
+
delete propertyValue.locales;
|
|
2789
|
+
delete propertyValue.localesConditions;
|
|
2790
|
+
}
|
|
2673
2791
|
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
|
2674
|
-
|
|
2792
|
+
const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
|
|
2793
|
+
if (!hasLocales) {
|
|
2794
|
+
delete properties[propertyId];
|
|
2795
|
+
}
|
|
2675
2796
|
}
|
|
2676
2797
|
});
|
|
2677
2798
|
evaluateWalkTreePropertyCriteria({
|
|
@@ -2739,24 +2860,28 @@ function walkPropertyValues(property, visitor) {
|
|
|
2739
2860
|
}
|
|
2740
2861
|
|
|
2741
2862
|
// src/EntityReleasesClient.ts
|
|
2742
|
-
var
|
|
2743
|
-
var
|
|
2744
|
-
var EntityReleasesClient = class extends
|
|
2863
|
+
var import_api15 = require("@uniformdev/context/api");
|
|
2864
|
+
var entityReleasesUrl = "/api/v1/entity-releases";
|
|
2865
|
+
var EntityReleasesClient = class extends import_api15.ApiClient {
|
|
2745
2866
|
constructor(options) {
|
|
2746
2867
|
super(options);
|
|
2747
2868
|
}
|
|
2748
2869
|
/** Fetches entity across all releases (and base) */
|
|
2749
|
-
async
|
|
2870
|
+
async list(options) {
|
|
2750
2871
|
const { projectId } = this.options;
|
|
2751
|
-
const fetchUri = this.createUrl(
|
|
2872
|
+
const fetchUri = this.createUrl(entityReleasesUrl, { ...options, projectId });
|
|
2752
2873
|
return await this.apiClient(fetchUri);
|
|
2753
2874
|
}
|
|
2875
|
+
/** @deprecated Use {@link list} instead. */
|
|
2876
|
+
async get(options) {
|
|
2877
|
+
return this.list(options);
|
|
2878
|
+
}
|
|
2754
2879
|
};
|
|
2755
2880
|
|
|
2756
2881
|
// src/IntegrationPropertyEditorsClient.ts
|
|
2757
|
-
var
|
|
2882
|
+
var import_api16 = require("@uniformdev/context/api");
|
|
2758
2883
|
var _baseUrl;
|
|
2759
|
-
var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient extends
|
|
2884
|
+
var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient extends import_api16.ApiClient {
|
|
2760
2885
|
constructor(options) {
|
|
2761
2886
|
super(options);
|
|
2762
2887
|
this.teamId = options.teamId;
|
|
@@ -2799,17 +2924,21 @@ __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-p
|
|
|
2799
2924
|
var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
|
|
2800
2925
|
|
|
2801
2926
|
// src/LabelClient.ts
|
|
2802
|
-
var
|
|
2927
|
+
var import_api17 = require("@uniformdev/context/api");
|
|
2803
2928
|
var LABELS_URL = "/api/v1/labels";
|
|
2804
|
-
var LabelClient = class extends
|
|
2805
|
-
/** Fetches labels for the current project. */
|
|
2806
|
-
async
|
|
2929
|
+
var LabelClient = class extends import_api17.ApiClient {
|
|
2930
|
+
/** Fetches a list of labels for the current project. */
|
|
2931
|
+
async list(options) {
|
|
2807
2932
|
const { projectId } = this.options;
|
|
2808
2933
|
const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
|
|
2809
2934
|
return await this.apiClient(fetchUri);
|
|
2810
2935
|
}
|
|
2936
|
+
/** @deprecated Use {@link list} instead. */
|
|
2937
|
+
async getLabels(options) {
|
|
2938
|
+
return this.list(options);
|
|
2939
|
+
}
|
|
2811
2940
|
/** Updates or creates a label. */
|
|
2812
|
-
async
|
|
2941
|
+
async save(body) {
|
|
2813
2942
|
const { projectId } = this.options;
|
|
2814
2943
|
const fetchUri = this.createUrl(LABELS_URL);
|
|
2815
2944
|
await this.apiClient(fetchUri, {
|
|
@@ -2818,8 +2947,12 @@ var LabelClient = class extends import_api9.ApiClient {
|
|
|
2818
2947
|
expectNoContent: true
|
|
2819
2948
|
});
|
|
2820
2949
|
}
|
|
2950
|
+
/** @deprecated Use {@link save} instead. */
|
|
2951
|
+
async upsertLabel(body) {
|
|
2952
|
+
return this.save(body);
|
|
2953
|
+
}
|
|
2821
2954
|
/** Deletes a label by id. */
|
|
2822
|
-
async
|
|
2955
|
+
async remove(options) {
|
|
2823
2956
|
const { projectId } = this.options;
|
|
2824
2957
|
const fetchUri = this.createUrl(LABELS_URL);
|
|
2825
2958
|
await this.apiClient(fetchUri, {
|
|
@@ -2828,6 +2961,10 @@ var LabelClient = class extends import_api9.ApiClient {
|
|
|
2828
2961
|
expectNoContent: true
|
|
2829
2962
|
});
|
|
2830
2963
|
}
|
|
2964
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2965
|
+
async removeLabel(options) {
|
|
2966
|
+
return this.remove(options);
|
|
2967
|
+
}
|
|
2831
2968
|
};
|
|
2832
2969
|
var UncachedLabelClient = class extends LabelClient {
|
|
2833
2970
|
constructor(options) {
|
|
@@ -2836,20 +2973,24 @@ var UncachedLabelClient = class extends LabelClient {
|
|
|
2836
2973
|
};
|
|
2837
2974
|
|
|
2838
2975
|
// src/LocaleClient.ts
|
|
2839
|
-
var
|
|
2976
|
+
var import_api18 = require("@uniformdev/context/api");
|
|
2840
2977
|
var localesUrl = "/api/v1/locales";
|
|
2841
|
-
var LocaleClient = class extends
|
|
2978
|
+
var LocaleClient = class extends import_api18.ApiClient {
|
|
2842
2979
|
constructor(options) {
|
|
2843
2980
|
super(options);
|
|
2844
2981
|
}
|
|
2845
|
-
/** Fetches
|
|
2846
|
-
async
|
|
2982
|
+
/** Fetches a list of locales for a project */
|
|
2983
|
+
async list(options) {
|
|
2847
2984
|
const { projectId } = this.options;
|
|
2848
2985
|
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
|
2849
2986
|
return await this.apiClient(fetchUri);
|
|
2850
2987
|
}
|
|
2988
|
+
/** @deprecated Use {@link list} instead. */
|
|
2989
|
+
async get(options) {
|
|
2990
|
+
return this.list(options);
|
|
2991
|
+
}
|
|
2851
2992
|
/** Updates or creates (based on id) a locale */
|
|
2852
|
-
async
|
|
2993
|
+
async save(body) {
|
|
2853
2994
|
const fetchUri = this.createUrl(localesUrl);
|
|
2854
2995
|
await this.apiClient(fetchUri, {
|
|
2855
2996
|
method: "PUT",
|
|
@@ -2857,6 +2998,10 @@ var LocaleClient = class extends import_api10.ApiClient {
|
|
|
2857
2998
|
expectNoContent: true
|
|
2858
2999
|
});
|
|
2859
3000
|
}
|
|
3001
|
+
/** @deprecated Use {@link save} instead. */
|
|
3002
|
+
async upsert(body) {
|
|
3003
|
+
return this.save(body);
|
|
3004
|
+
}
|
|
2860
3005
|
/** Deletes a locale */
|
|
2861
3006
|
async remove(body) {
|
|
2862
3007
|
const fetchUri = this.createUrl(localesUrl);
|
|
@@ -3240,10 +3385,10 @@ var createCanvasChannel = ({
|
|
|
3240
3385
|
};
|
|
3241
3386
|
|
|
3242
3387
|
// src/PreviewClient.ts
|
|
3243
|
-
var
|
|
3388
|
+
var import_api19 = require("@uniformdev/context/api");
|
|
3244
3389
|
var previewUrlsUrl = "/api/v1/preview-urls";
|
|
3245
3390
|
var previewViewportsUrl = "/api/v1/preview-viewports";
|
|
3246
|
-
var PreviewClient = class extends
|
|
3391
|
+
var PreviewClient = class extends import_api19.ApiClient {
|
|
3247
3392
|
constructor(options) {
|
|
3248
3393
|
super(options);
|
|
3249
3394
|
}
|
|
@@ -3306,9 +3451,9 @@ var PreviewClient = class extends import_api11.ApiClient {
|
|
|
3306
3451
|
};
|
|
3307
3452
|
|
|
3308
3453
|
// src/ProjectClient.ts
|
|
3309
|
-
var
|
|
3454
|
+
var import_api20 = require("@uniformdev/context/api");
|
|
3310
3455
|
var _url2, _projectsUrl;
|
|
3311
|
-
var _ProjectClient = class _ProjectClient extends
|
|
3456
|
+
var _ProjectClient = class _ProjectClient extends import_api20.ApiClient {
|
|
3312
3457
|
constructor(options) {
|
|
3313
3458
|
super({ ...options, bypassCache: true });
|
|
3314
3459
|
}
|
|
@@ -3322,20 +3467,28 @@ var _ProjectClient = class _ProjectClient extends import_api12.ApiClient {
|
|
|
3322
3467
|
* When teamId is provided, returns a single team with its projects.
|
|
3323
3468
|
* When omitted, returns all accessible teams and their projects.
|
|
3324
3469
|
*/
|
|
3325
|
-
async
|
|
3470
|
+
async list(options) {
|
|
3326
3471
|
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
|
|
3327
3472
|
return await this.apiClient(fetchUri);
|
|
3328
3473
|
}
|
|
3474
|
+
/** @deprecated Use {@link list} instead. */
|
|
3475
|
+
async getProjects(options) {
|
|
3476
|
+
return this.list(options);
|
|
3477
|
+
}
|
|
3329
3478
|
/** Updates or creates (based on id) a Project */
|
|
3330
|
-
async
|
|
3479
|
+
async save(body) {
|
|
3331
3480
|
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
|
|
3332
3481
|
return await this.apiClient(fetchUri, {
|
|
3333
3482
|
method: "PUT",
|
|
3334
3483
|
body: JSON.stringify({ ...body })
|
|
3335
3484
|
});
|
|
3336
3485
|
}
|
|
3486
|
+
/** @deprecated Use {@link save} instead. */
|
|
3487
|
+
async upsert(body) {
|
|
3488
|
+
return this.save(body);
|
|
3489
|
+
}
|
|
3337
3490
|
/** Deletes a Project */
|
|
3338
|
-
async
|
|
3491
|
+
async remove(body) {
|
|
3339
3492
|
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
|
|
3340
3493
|
await this.apiClient(fetchUri, {
|
|
3341
3494
|
method: "DELETE",
|
|
@@ -3343,6 +3496,10 @@ var _ProjectClient = class _ProjectClient extends import_api12.ApiClient {
|
|
|
3343
3496
|
expectNoContent: true
|
|
3344
3497
|
});
|
|
3345
3498
|
}
|
|
3499
|
+
/** @deprecated Use {@link remove} instead. */
|
|
3500
|
+
async delete(body) {
|
|
3501
|
+
return this.remove(body);
|
|
3502
|
+
}
|
|
3346
3503
|
};
|
|
3347
3504
|
_url2 = new WeakMap();
|
|
3348
3505
|
_projectsUrl = new WeakMap();
|
|
@@ -3350,10 +3507,177 @@ __privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
|
3350
3507
|
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
3351
3508
|
var ProjectClient = _ProjectClient;
|
|
3352
3509
|
|
|
3510
|
+
// src/projection/matchesProjectionPattern.ts
|
|
3511
|
+
var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
|
|
3512
|
+
var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
|
|
3513
|
+
function isValidProjectionPattern(pattern) {
|
|
3514
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
3515
|
+
return false;
|
|
3516
|
+
}
|
|
3517
|
+
if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
|
|
3518
|
+
return false;
|
|
3519
|
+
}
|
|
3520
|
+
return true;
|
|
3521
|
+
}
|
|
3522
|
+
function compilePattern(pattern) {
|
|
3523
|
+
let regexSource = "^";
|
|
3524
|
+
for (const ch of pattern) {
|
|
3525
|
+
if (ch === "*") {
|
|
3526
|
+
regexSource += ".*";
|
|
3527
|
+
} else {
|
|
3528
|
+
regexSource += ch.replace(REGEX_METACHAR, "\\$&");
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
regexSource += "$";
|
|
3532
|
+
return new RegExp(regexSource);
|
|
3533
|
+
}
|
|
3534
|
+
var PATTERN_CACHE_MAX = 1024;
|
|
3535
|
+
var patternRegexCache = /* @__PURE__ */ new Map();
|
|
3536
|
+
function matchesProjectionPattern(pattern, value) {
|
|
3537
|
+
let re = patternRegexCache.get(pattern);
|
|
3538
|
+
if (re === void 0) {
|
|
3539
|
+
if (!isValidProjectionPattern(pattern)) {
|
|
3540
|
+
throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
|
|
3541
|
+
}
|
|
3542
|
+
re = compilePattern(pattern);
|
|
3543
|
+
if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
|
|
3544
|
+
const oldest = patternRegexCache.keys().next().value;
|
|
3545
|
+
if (oldest !== void 0) patternRegexCache.delete(oldest);
|
|
3546
|
+
}
|
|
3547
|
+
patternRegexCache.set(pattern, re);
|
|
3548
|
+
}
|
|
3549
|
+
return re.test(value);
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3552
|
+
// src/projection/queryToProjection.ts
|
|
3553
|
+
var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
|
|
3554
|
+
var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
|
|
3555
|
+
function toStringValue2(value) {
|
|
3556
|
+
if (Array.isArray(value)) {
|
|
3557
|
+
return value.join(",");
|
|
3558
|
+
}
|
|
3559
|
+
return value;
|
|
3560
|
+
}
|
|
3561
|
+
function parseCsv(value) {
|
|
3562
|
+
const str = toStringValue2(value);
|
|
3563
|
+
if (!str) {
|
|
3564
|
+
return [];
|
|
3565
|
+
}
|
|
3566
|
+
return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
3567
|
+
}
|
|
3568
|
+
function parseDepth(value, key) {
|
|
3569
|
+
const str = toStringValue2(value);
|
|
3570
|
+
if (str === void 0 || str === "") {
|
|
3571
|
+
throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
|
|
3572
|
+
}
|
|
3573
|
+
if (!/^\d+$/.test(str)) {
|
|
3574
|
+
throw new Error(
|
|
3575
|
+
`Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
|
|
3576
|
+
);
|
|
3577
|
+
}
|
|
3578
|
+
return Number(str);
|
|
3579
|
+
}
|
|
3580
|
+
function extractSelectKeys(source) {
|
|
3581
|
+
if (source instanceof URLSearchParams) {
|
|
3582
|
+
let out2;
|
|
3583
|
+
for (const [key, value] of source.entries()) {
|
|
3584
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3585
|
+
out2 != null ? out2 : out2 = {};
|
|
3586
|
+
out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
|
|
3587
|
+
}
|
|
3588
|
+
return out2;
|
|
3589
|
+
}
|
|
3590
|
+
let out;
|
|
3591
|
+
for (const key in source) {
|
|
3592
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3593
|
+
out != null ? out : out = {};
|
|
3594
|
+
out[key] = source[key];
|
|
3595
|
+
}
|
|
3596
|
+
return out;
|
|
3597
|
+
}
|
|
3598
|
+
function queryToProjection(source) {
|
|
3599
|
+
var _a, _b, _c, _d, _e;
|
|
3600
|
+
if (!source) {
|
|
3601
|
+
return void 0;
|
|
3602
|
+
}
|
|
3603
|
+
const query = extractSelectKeys(source);
|
|
3604
|
+
if (!query) {
|
|
3605
|
+
return void 0;
|
|
3606
|
+
}
|
|
3607
|
+
const spec = {};
|
|
3608
|
+
for (const [rawKey, value] of Object.entries(query)) {
|
|
3609
|
+
const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
|
|
3610
|
+
const namedMatch = SLOTS_NAMED_KEY.exec(key);
|
|
3611
|
+
if (namedMatch) {
|
|
3612
|
+
const [, slotName, operator2] = namedMatch;
|
|
3613
|
+
if (operator2 !== "depth") {
|
|
3614
|
+
throw new Error(
|
|
3615
|
+
`Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
|
|
3616
|
+
);
|
|
3617
|
+
}
|
|
3618
|
+
const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
|
|
3619
|
+
const named = (_b = slots.named) != null ? _b : slots.named = {};
|
|
3620
|
+
named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
|
|
3621
|
+
continue;
|
|
3622
|
+
}
|
|
3623
|
+
const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
|
|
3624
|
+
if (!topMatch) {
|
|
3625
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3626
|
+
}
|
|
3627
|
+
const [, bucket, operator] = topMatch;
|
|
3628
|
+
if (bucket === "fields") {
|
|
3629
|
+
const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
|
|
3630
|
+
switch (operator) {
|
|
3631
|
+
case "only":
|
|
3632
|
+
fields.only = parseCsv(value);
|
|
3633
|
+
break;
|
|
3634
|
+
case "except":
|
|
3635
|
+
fields.except = parseCsv(value);
|
|
3636
|
+
break;
|
|
3637
|
+
case "locales":
|
|
3638
|
+
fields.locales = parseCsv(value);
|
|
3639
|
+
break;
|
|
3640
|
+
default:
|
|
3641
|
+
throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
|
|
3642
|
+
}
|
|
3643
|
+
} else if (bucket === "fieldTypes") {
|
|
3644
|
+
const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
|
|
3645
|
+
switch (operator) {
|
|
3646
|
+
case "only":
|
|
3647
|
+
fieldTypes.only = parseCsv(value);
|
|
3648
|
+
break;
|
|
3649
|
+
case "except":
|
|
3650
|
+
fieldTypes.except = parseCsv(value);
|
|
3651
|
+
break;
|
|
3652
|
+
default:
|
|
3653
|
+
throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
|
|
3654
|
+
}
|
|
3655
|
+
} else if (bucket === "slots") {
|
|
3656
|
+
const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
|
|
3657
|
+
switch (operator) {
|
|
3658
|
+
case "only":
|
|
3659
|
+
slots.only = parseCsv(value);
|
|
3660
|
+
break;
|
|
3661
|
+
case "except":
|
|
3662
|
+
slots.except = parseCsv(value);
|
|
3663
|
+
break;
|
|
3664
|
+
case "depth":
|
|
3665
|
+
slots.depth = parseDepth(value, rawKey);
|
|
3666
|
+
break;
|
|
3667
|
+
default:
|
|
3668
|
+
throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
|
|
3669
|
+
}
|
|
3670
|
+
} else {
|
|
3671
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
return spec;
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3353
3677
|
// src/PromptClient.ts
|
|
3354
|
-
var
|
|
3678
|
+
var import_api21 = require("@uniformdev/context/api");
|
|
3355
3679
|
var PromptsUrl = "/api/v1/prompts";
|
|
3356
|
-
var PromptClient = class extends
|
|
3680
|
+
var PromptClient = class extends import_api21.ApiClient {
|
|
3357
3681
|
constructor(options) {
|
|
3358
3682
|
super(options);
|
|
3359
3683
|
}
|
|
@@ -3384,34 +3708,42 @@ var PromptClient = class extends import_api13.ApiClient {
|
|
|
3384
3708
|
};
|
|
3385
3709
|
|
|
3386
3710
|
// src/RelationshipClient.ts
|
|
3387
|
-
var
|
|
3711
|
+
var import_api22 = require("@uniformdev/context/api");
|
|
3388
3712
|
var RELATIONSHIPS_URL = "/api/v1/relationships";
|
|
3389
|
-
var RelationshipClient = class extends
|
|
3713
|
+
var RelationshipClient = class extends import_api22.ApiClient {
|
|
3390
3714
|
constructor(options) {
|
|
3391
3715
|
super(options);
|
|
3392
|
-
this.
|
|
3716
|
+
this.list = async (options) => {
|
|
3393
3717
|
const { projectId } = this.options;
|
|
3394
3718
|
const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
|
|
3395
3719
|
return this.apiClient(url);
|
|
3396
3720
|
};
|
|
3721
|
+
/** @deprecated Use {@link list} instead. */
|
|
3722
|
+
this.get = async (options) => {
|
|
3723
|
+
return this.list(options);
|
|
3724
|
+
};
|
|
3397
3725
|
}
|
|
3398
3726
|
};
|
|
3399
3727
|
|
|
3400
3728
|
// src/ReleaseClient.ts
|
|
3401
|
-
var
|
|
3729
|
+
var import_api23 = require("@uniformdev/context/api");
|
|
3402
3730
|
var releasesUrl = "/api/v1/releases";
|
|
3403
|
-
var ReleaseClient = class extends
|
|
3731
|
+
var ReleaseClient = class extends import_api23.ApiClient {
|
|
3404
3732
|
constructor(options) {
|
|
3405
3733
|
super(options);
|
|
3406
3734
|
}
|
|
3407
|
-
/** Fetches
|
|
3408
|
-
async
|
|
3735
|
+
/** Fetches a list of releases for a project */
|
|
3736
|
+
async list(options) {
|
|
3409
3737
|
const { projectId } = this.options;
|
|
3410
3738
|
const fetchUri = this.createUrl(releasesUrl, { ...options, projectId });
|
|
3411
3739
|
return await this.apiClient(fetchUri);
|
|
3412
3740
|
}
|
|
3741
|
+
/** @deprecated Use {@link list} instead. */
|
|
3742
|
+
async get(options) {
|
|
3743
|
+
return this.list(options);
|
|
3744
|
+
}
|
|
3413
3745
|
/** Updates or creates (based on id) a release */
|
|
3414
|
-
async
|
|
3746
|
+
async save(body) {
|
|
3415
3747
|
const fetchUri = this.createUrl(releasesUrl);
|
|
3416
3748
|
await this.apiClient(fetchUri, {
|
|
3417
3749
|
method: "PUT",
|
|
@@ -3419,6 +3751,10 @@ var ReleaseClient = class extends import_api15.ApiClient {
|
|
|
3419
3751
|
expectNoContent: true
|
|
3420
3752
|
});
|
|
3421
3753
|
}
|
|
3754
|
+
/** @deprecated Use {@link save} instead. */
|
|
3755
|
+
async upsert(body) {
|
|
3756
|
+
return this.save(body);
|
|
3757
|
+
}
|
|
3422
3758
|
/** Deletes a release */
|
|
3423
3759
|
async remove(body) {
|
|
3424
3760
|
const fetchUri = this.createUrl(releasesUrl);
|
|
@@ -3440,21 +3776,25 @@ var ReleaseClient = class extends import_api15.ApiClient {
|
|
|
3440
3776
|
};
|
|
3441
3777
|
|
|
3442
3778
|
// src/ReleaseContentsClient.ts
|
|
3443
|
-
var
|
|
3444
|
-
var
|
|
3445
|
-
var ReleaseContentsClient = class extends
|
|
3779
|
+
var import_api24 = require("@uniformdev/context/api");
|
|
3780
|
+
var releaseContentsUrl = "/api/v1/release-contents";
|
|
3781
|
+
var ReleaseContentsClient = class extends import_api24.ApiClient {
|
|
3446
3782
|
constructor(options) {
|
|
3447
3783
|
super(options);
|
|
3448
3784
|
}
|
|
3449
|
-
/** Fetches
|
|
3450
|
-
async
|
|
3785
|
+
/** Fetches a list of entities added to a release */
|
|
3786
|
+
async list(options) {
|
|
3451
3787
|
const { projectId } = this.options;
|
|
3452
|
-
const fetchUri = this.createUrl(
|
|
3788
|
+
const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
|
|
3453
3789
|
return await this.apiClient(fetchUri);
|
|
3454
3790
|
}
|
|
3791
|
+
/** @deprecated Use {@link list} instead. */
|
|
3792
|
+
async get(options) {
|
|
3793
|
+
return this.list(options);
|
|
3794
|
+
}
|
|
3455
3795
|
/** Removes a release content from a release */
|
|
3456
3796
|
async remove(body) {
|
|
3457
|
-
const fetchUri = this.createUrl(
|
|
3797
|
+
const fetchUri = this.createUrl(releaseContentsUrl);
|
|
3458
3798
|
await this.apiClient(fetchUri, {
|
|
3459
3799
|
method: "DELETE",
|
|
3460
3800
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
@@ -3464,9 +3804,9 @@ var ReleaseContentsClient = class extends import_api16.ApiClient {
|
|
|
3464
3804
|
};
|
|
3465
3805
|
|
|
3466
3806
|
// src/RouteClient.ts
|
|
3467
|
-
var
|
|
3807
|
+
var import_api25 = require("@uniformdev/context/api");
|
|
3468
3808
|
var ROUTE_URL = "/api/v1/route";
|
|
3469
|
-
var RouteClient = class extends
|
|
3809
|
+
var RouteClient = class extends import_api25.ApiClient {
|
|
3470
3810
|
constructor(options) {
|
|
3471
3811
|
var _a;
|
|
3472
3812
|
if (!options.limitPolicy) {
|
|
@@ -3475,15 +3815,27 @@ var RouteClient = class extends import_api17.ApiClient {
|
|
|
3475
3815
|
super(options);
|
|
3476
3816
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
3477
3817
|
}
|
|
3478
|
-
/**
|
|
3479
|
-
|
|
3818
|
+
/**
|
|
3819
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
3820
|
+
*
|
|
3821
|
+
* An optional `select` projection applies to the resolved composition when
|
|
3822
|
+
* the route matches one; redirect / notFound responses pass through
|
|
3823
|
+
* untouched.
|
|
3824
|
+
*/
|
|
3825
|
+
async get(options) {
|
|
3480
3826
|
const { projectId } = this.options;
|
|
3481
|
-
const
|
|
3827
|
+
const { select, ...rest } = options != null ? options : {};
|
|
3828
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
3829
|
+
const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
|
|
3482
3830
|
return await this.apiClient(
|
|
3483
3831
|
fetchUri,
|
|
3484
3832
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
3485
3833
|
);
|
|
3486
3834
|
}
|
|
3835
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
3836
|
+
async getRoute(options) {
|
|
3837
|
+
return this.get(options);
|
|
3838
|
+
}
|
|
3487
3839
|
};
|
|
3488
3840
|
|
|
3489
3841
|
// src/types/locales.ts
|
|
@@ -3838,26 +4190,30 @@ function handleRichTextNodeBinding(object, options) {
|
|
|
3838
4190
|
}
|
|
3839
4191
|
|
|
3840
4192
|
// src/index.ts
|
|
3841
|
-
var
|
|
4193
|
+
var import_api27 = require("@uniformdev/context/api");
|
|
3842
4194
|
|
|
3843
4195
|
// src/.version.ts
|
|
3844
|
-
var version = "20.
|
|
4196
|
+
var version = "20.71.0";
|
|
3845
4197
|
|
|
3846
4198
|
// src/WorkflowClient.ts
|
|
3847
|
-
var
|
|
4199
|
+
var import_api26 = require("@uniformdev/context/api");
|
|
3848
4200
|
var workflowsUrl = "/api/v1/workflows";
|
|
3849
|
-
var WorkflowClient = class extends
|
|
4201
|
+
var WorkflowClient = class extends import_api26.ApiClient {
|
|
3850
4202
|
constructor(options) {
|
|
3851
4203
|
super(options);
|
|
3852
4204
|
}
|
|
3853
|
-
/** Fetches workflows for a project */
|
|
3854
|
-
async
|
|
4205
|
+
/** Fetches a list of workflows for a project */
|
|
4206
|
+
async list(options) {
|
|
3855
4207
|
const { projectId } = this.options;
|
|
3856
4208
|
const fetchUri = this.createUrl(workflowsUrl, { ...options, projectId });
|
|
3857
4209
|
return await this.apiClient(fetchUri);
|
|
3858
4210
|
}
|
|
4211
|
+
/** @deprecated Use {@link list} instead. */
|
|
4212
|
+
async get(options) {
|
|
4213
|
+
return this.list(options);
|
|
4214
|
+
}
|
|
3859
4215
|
/** Updates or creates a workflow definition */
|
|
3860
|
-
async
|
|
4216
|
+
async save(body) {
|
|
3861
4217
|
const fetchUri = this.createUrl(workflowsUrl);
|
|
3862
4218
|
await this.apiClient(fetchUri, {
|
|
3863
4219
|
method: "PUT",
|
|
@@ -3865,6 +4221,10 @@ var WorkflowClient = class extends import_api18.ApiClient {
|
|
|
3865
4221
|
expectNoContent: true
|
|
3866
4222
|
});
|
|
3867
4223
|
}
|
|
4224
|
+
/** @deprecated Use {@link save} instead. */
|
|
4225
|
+
async upsert(body) {
|
|
4226
|
+
return this.save(body);
|
|
4227
|
+
}
|
|
3868
4228
|
/** Deletes a workflow definition */
|
|
3869
4229
|
async remove(body) {
|
|
3870
4230
|
const fetchUri = this.createUrl(workflowsUrl);
|
|
@@ -3877,7 +4237,7 @@ var WorkflowClient = class extends import_api18.ApiClient {
|
|
|
3877
4237
|
};
|
|
3878
4238
|
|
|
3879
4239
|
// src/index.ts
|
|
3880
|
-
var CanvasClientError =
|
|
4240
|
+
var CanvasClientError = import_api27.ApiClientError;
|
|
3881
4241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3882
4242
|
0 && (module.exports = {
|
|
3883
4243
|
ASSETS_SOURCE_CUSTOM_URL,
|
|
@@ -3931,7 +4291,11 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
3931
4291
|
CanvasClientError,
|
|
3932
4292
|
CategoryClient,
|
|
3933
4293
|
ChildEnhancerBuilder,
|
|
4294
|
+
ComponentDefinitionClient,
|
|
4295
|
+
CompositionDeliveryClient,
|
|
4296
|
+
CompositionManagementClient,
|
|
3934
4297
|
ContentClient,
|
|
4298
|
+
ContentTypeClient,
|
|
3935
4299
|
DataSourceClient,
|
|
3936
4300
|
DataTypeClient,
|
|
3937
4301
|
EDGE_CACHE_DISABLED,
|
|
@@ -3941,6 +4305,8 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
3941
4305
|
EMPTY_COMPOSITION,
|
|
3942
4306
|
EnhancerBuilder,
|
|
3943
4307
|
EntityReleasesClient,
|
|
4308
|
+
EntryDeliveryClient,
|
|
4309
|
+
EntryManagementClient,
|
|
3944
4310
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
|
3945
4311
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
3946
4312
|
IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
|
|
@@ -3963,6 +4329,7 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
3963
4329
|
ReleaseContentsClient,
|
|
3964
4330
|
RouteClient,
|
|
3965
4331
|
SECRET_QUERY_STRING_PARAM,
|
|
4332
|
+
SELECT_QUERY_PREFIX,
|
|
3966
4333
|
UncachedCanvasClient,
|
|
3967
4334
|
UncachedCategoryClient,
|
|
3968
4335
|
UncachedContentClient,
|
|
@@ -4044,10 +4411,13 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
4044
4411
|
localize,
|
|
4045
4412
|
mapSlotToPersonalizedVariations,
|
|
4046
4413
|
mapSlotToTestVariations,
|
|
4414
|
+
matchesProjectionPattern,
|
|
4047
4415
|
mergeAssetConfigWithDefaults,
|
|
4048
4416
|
nullLimitPolicy,
|
|
4049
4417
|
parseComponentPlaceholderId,
|
|
4050
4418
|
parseVariableExpression,
|
|
4419
|
+
projectionToQuery,
|
|
4420
|
+
queryToProjection,
|
|
4051
4421
|
version,
|
|
4052
4422
|
walkNodeTree,
|
|
4053
4423
|
walkPropertyValues
|