@uniformdev/canvas 20.50.2-alpha.149 → 20.50.2-alpha.180
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 +1667 -1205
- package/dist/index.d.ts +1667 -1205
- package/dist/index.esm.js +262 -561
- package/dist/index.js +270 -543
- package/dist/index.mjs +262 -561
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,560 +1,25 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
1
|
var __typeError = (msg) => {
|
|
8
2
|
throw TypeError(msg);
|
|
9
3
|
};
|
|
10
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
4
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
30
5
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
31
6
|
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);
|
|
32
7
|
|
|
33
|
-
// ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
|
|
34
|
-
var require_yocto_queue = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var Node = class {
|
|
38
|
-
/// value;
|
|
39
|
-
/// next;
|
|
40
|
-
constructor(value) {
|
|
41
|
-
this.value = value;
|
|
42
|
-
this.next = void 0;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var Queue = class {
|
|
46
|
-
// TODO: Use private class fields when targeting Node.js 12.
|
|
47
|
-
// #_head;
|
|
48
|
-
// #_tail;
|
|
49
|
-
// #_size;
|
|
50
|
-
constructor() {
|
|
51
|
-
this.clear();
|
|
52
|
-
}
|
|
53
|
-
enqueue(value) {
|
|
54
|
-
const node = new Node(value);
|
|
55
|
-
if (this._head) {
|
|
56
|
-
this._tail.next = node;
|
|
57
|
-
this._tail = node;
|
|
58
|
-
} else {
|
|
59
|
-
this._head = node;
|
|
60
|
-
this._tail = node;
|
|
61
|
-
}
|
|
62
|
-
this._size++;
|
|
63
|
-
}
|
|
64
|
-
dequeue() {
|
|
65
|
-
const current = this._head;
|
|
66
|
-
if (!current) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this._head = this._head.next;
|
|
70
|
-
this._size--;
|
|
71
|
-
return current.value;
|
|
72
|
-
}
|
|
73
|
-
clear() {
|
|
74
|
-
this._head = void 0;
|
|
75
|
-
this._tail = void 0;
|
|
76
|
-
this._size = 0;
|
|
77
|
-
}
|
|
78
|
-
get size() {
|
|
79
|
-
return this._size;
|
|
80
|
-
}
|
|
81
|
-
*[Symbol.iterator]() {
|
|
82
|
-
let current = this._head;
|
|
83
|
-
while (current) {
|
|
84
|
-
yield current.value;
|
|
85
|
-
current = current.next;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
module.exports = Queue;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
|
|
94
|
-
var require_p_limit = __commonJS({
|
|
95
|
-
"../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
|
|
96
|
-
"use strict";
|
|
97
|
-
var Queue = require_yocto_queue();
|
|
98
|
-
var pLimit2 = (concurrency) => {
|
|
99
|
-
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
100
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
101
|
-
}
|
|
102
|
-
const queue = new Queue();
|
|
103
|
-
let activeCount = 0;
|
|
104
|
-
const next = () => {
|
|
105
|
-
activeCount--;
|
|
106
|
-
if (queue.size > 0) {
|
|
107
|
-
queue.dequeue()();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const run = async (fn, resolve, ...args) => {
|
|
111
|
-
activeCount++;
|
|
112
|
-
const result = (async () => fn(...args))();
|
|
113
|
-
resolve(result);
|
|
114
|
-
try {
|
|
115
|
-
await result;
|
|
116
|
-
} catch (e) {
|
|
117
|
-
}
|
|
118
|
-
next();
|
|
119
|
-
};
|
|
120
|
-
const enqueue = (fn, resolve, ...args) => {
|
|
121
|
-
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
122
|
-
(async () => {
|
|
123
|
-
await Promise.resolve();
|
|
124
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
125
|
-
queue.dequeue()();
|
|
126
|
-
}
|
|
127
|
-
})();
|
|
128
|
-
};
|
|
129
|
-
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
130
|
-
enqueue(fn, resolve, ...args);
|
|
131
|
-
});
|
|
132
|
-
Object.defineProperties(generator, {
|
|
133
|
-
activeCount: {
|
|
134
|
-
get: () => activeCount
|
|
135
|
-
},
|
|
136
|
-
pendingCount: {
|
|
137
|
-
get: () => queue.size
|
|
138
|
-
},
|
|
139
|
-
clearQueue: {
|
|
140
|
-
value: () => {
|
|
141
|
-
queue.clear();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return generator;
|
|
146
|
-
};
|
|
147
|
-
module.exports = pLimit2;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
152
|
-
var require_retry_operation = __commonJS({
|
|
153
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
154
|
-
"use strict";
|
|
155
|
-
function RetryOperation(timeouts, options) {
|
|
156
|
-
if (typeof options === "boolean") {
|
|
157
|
-
options = { forever: options };
|
|
158
|
-
}
|
|
159
|
-
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
160
|
-
this._timeouts = timeouts;
|
|
161
|
-
this._options = options || {};
|
|
162
|
-
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
163
|
-
this._fn = null;
|
|
164
|
-
this._errors = [];
|
|
165
|
-
this._attempts = 1;
|
|
166
|
-
this._operationTimeout = null;
|
|
167
|
-
this._operationTimeoutCb = null;
|
|
168
|
-
this._timeout = null;
|
|
169
|
-
this._operationStart = null;
|
|
170
|
-
this._timer = null;
|
|
171
|
-
if (this._options.forever) {
|
|
172
|
-
this._cachedTimeouts = this._timeouts.slice(0);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
module.exports = RetryOperation;
|
|
176
|
-
RetryOperation.prototype.reset = function() {
|
|
177
|
-
this._attempts = 1;
|
|
178
|
-
this._timeouts = this._originalTimeouts.slice(0);
|
|
179
|
-
};
|
|
180
|
-
RetryOperation.prototype.stop = function() {
|
|
181
|
-
if (this._timeout) {
|
|
182
|
-
clearTimeout(this._timeout);
|
|
183
|
-
}
|
|
184
|
-
if (this._timer) {
|
|
185
|
-
clearTimeout(this._timer);
|
|
186
|
-
}
|
|
187
|
-
this._timeouts = [];
|
|
188
|
-
this._cachedTimeouts = null;
|
|
189
|
-
};
|
|
190
|
-
RetryOperation.prototype.retry = function(err) {
|
|
191
|
-
if (this._timeout) {
|
|
192
|
-
clearTimeout(this._timeout);
|
|
193
|
-
}
|
|
194
|
-
if (!err) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
198
|
-
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
199
|
-
this._errors.push(err);
|
|
200
|
-
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
this._errors.push(err);
|
|
204
|
-
var timeout = this._timeouts.shift();
|
|
205
|
-
if (timeout === void 0) {
|
|
206
|
-
if (this._cachedTimeouts) {
|
|
207
|
-
this._errors.splice(0, this._errors.length - 1);
|
|
208
|
-
timeout = this._cachedTimeouts.slice(-1);
|
|
209
|
-
} else {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
var self = this;
|
|
214
|
-
this._timer = setTimeout(function() {
|
|
215
|
-
self._attempts++;
|
|
216
|
-
if (self._operationTimeoutCb) {
|
|
217
|
-
self._timeout = setTimeout(function() {
|
|
218
|
-
self._operationTimeoutCb(self._attempts);
|
|
219
|
-
}, self._operationTimeout);
|
|
220
|
-
if (self._options.unref) {
|
|
221
|
-
self._timeout.unref();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
self._fn(self._attempts);
|
|
225
|
-
}, timeout);
|
|
226
|
-
if (this._options.unref) {
|
|
227
|
-
this._timer.unref();
|
|
228
|
-
}
|
|
229
|
-
return true;
|
|
230
|
-
};
|
|
231
|
-
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
232
|
-
this._fn = fn;
|
|
233
|
-
if (timeoutOps) {
|
|
234
|
-
if (timeoutOps.timeout) {
|
|
235
|
-
this._operationTimeout = timeoutOps.timeout;
|
|
236
|
-
}
|
|
237
|
-
if (timeoutOps.cb) {
|
|
238
|
-
this._operationTimeoutCb = timeoutOps.cb;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
var self = this;
|
|
242
|
-
if (this._operationTimeoutCb) {
|
|
243
|
-
this._timeout = setTimeout(function() {
|
|
244
|
-
self._operationTimeoutCb();
|
|
245
|
-
}, self._operationTimeout);
|
|
246
|
-
}
|
|
247
|
-
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
248
|
-
this._fn(this._attempts);
|
|
249
|
-
};
|
|
250
|
-
RetryOperation.prototype.try = function(fn) {
|
|
251
|
-
console.log("Using RetryOperation.try() is deprecated");
|
|
252
|
-
this.attempt(fn);
|
|
253
|
-
};
|
|
254
|
-
RetryOperation.prototype.start = function(fn) {
|
|
255
|
-
console.log("Using RetryOperation.start() is deprecated");
|
|
256
|
-
this.attempt(fn);
|
|
257
|
-
};
|
|
258
|
-
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
259
|
-
RetryOperation.prototype.errors = function() {
|
|
260
|
-
return this._errors;
|
|
261
|
-
};
|
|
262
|
-
RetryOperation.prototype.attempts = function() {
|
|
263
|
-
return this._attempts;
|
|
264
|
-
};
|
|
265
|
-
RetryOperation.prototype.mainError = function() {
|
|
266
|
-
if (this._errors.length === 0) {
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
var counts = {};
|
|
270
|
-
var mainError = null;
|
|
271
|
-
var mainErrorCount = 0;
|
|
272
|
-
for (var i = 0; i < this._errors.length; i++) {
|
|
273
|
-
var error = this._errors[i];
|
|
274
|
-
var message = error.message;
|
|
275
|
-
var count = (counts[message] || 0) + 1;
|
|
276
|
-
counts[message] = count;
|
|
277
|
-
if (count >= mainErrorCount) {
|
|
278
|
-
mainError = error;
|
|
279
|
-
mainErrorCount = count;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return mainError;
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
|
|
288
|
-
var require_retry = __commonJS({
|
|
289
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
|
|
290
|
-
"use strict";
|
|
291
|
-
var RetryOperation = require_retry_operation();
|
|
292
|
-
exports.operation = function(options) {
|
|
293
|
-
var timeouts = exports.timeouts(options);
|
|
294
|
-
return new RetryOperation(timeouts, {
|
|
295
|
-
forever: options && (options.forever || options.retries === Infinity),
|
|
296
|
-
unref: options && options.unref,
|
|
297
|
-
maxRetryTime: options && options.maxRetryTime
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
exports.timeouts = function(options) {
|
|
301
|
-
if (options instanceof Array) {
|
|
302
|
-
return [].concat(options);
|
|
303
|
-
}
|
|
304
|
-
var opts = {
|
|
305
|
-
retries: 10,
|
|
306
|
-
factor: 2,
|
|
307
|
-
minTimeout: 1 * 1e3,
|
|
308
|
-
maxTimeout: Infinity,
|
|
309
|
-
randomize: false
|
|
310
|
-
};
|
|
311
|
-
for (var key in options) {
|
|
312
|
-
opts[key] = options[key];
|
|
313
|
-
}
|
|
314
|
-
if (opts.minTimeout > opts.maxTimeout) {
|
|
315
|
-
throw new Error("minTimeout is greater than maxTimeout");
|
|
316
|
-
}
|
|
317
|
-
var timeouts = [];
|
|
318
|
-
for (var i = 0; i < opts.retries; i++) {
|
|
319
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
320
|
-
}
|
|
321
|
-
if (options && options.forever && !timeouts.length) {
|
|
322
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
323
|
-
}
|
|
324
|
-
timeouts.sort(function(a, b) {
|
|
325
|
-
return a - b;
|
|
326
|
-
});
|
|
327
|
-
return timeouts;
|
|
328
|
-
};
|
|
329
|
-
exports.createTimeout = function(attempt, opts) {
|
|
330
|
-
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
331
|
-
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
|
|
332
|
-
timeout = Math.min(timeout, opts.maxTimeout);
|
|
333
|
-
return timeout;
|
|
334
|
-
};
|
|
335
|
-
exports.wrap = function(obj, options, methods) {
|
|
336
|
-
if (options instanceof Array) {
|
|
337
|
-
methods = options;
|
|
338
|
-
options = null;
|
|
339
|
-
}
|
|
340
|
-
if (!methods) {
|
|
341
|
-
methods = [];
|
|
342
|
-
for (var key in obj) {
|
|
343
|
-
if (typeof obj[key] === "function") {
|
|
344
|
-
methods.push(key);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
for (var i = 0; i < methods.length; i++) {
|
|
349
|
-
var method = methods[i];
|
|
350
|
-
var original = obj[method];
|
|
351
|
-
obj[method] = function retryWrapper(original2) {
|
|
352
|
-
var op = exports.operation(options);
|
|
353
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
354
|
-
var callback = args.pop();
|
|
355
|
-
args.push(function(err) {
|
|
356
|
-
if (op.retry(err)) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (err) {
|
|
360
|
-
arguments[0] = op.mainError();
|
|
361
|
-
}
|
|
362
|
-
callback.apply(this, arguments);
|
|
363
|
-
});
|
|
364
|
-
op.attempt(function() {
|
|
365
|
-
original2.apply(obj, args);
|
|
366
|
-
});
|
|
367
|
-
}.bind(obj, original);
|
|
368
|
-
obj[method].options = options;
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
375
|
-
var require_retry2 = __commonJS({
|
|
376
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
|
|
377
|
-
"use strict";
|
|
378
|
-
module.exports = require_retry();
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
|
|
382
8
|
// src/CanvasClient.ts
|
|
383
9
|
import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
|
|
384
10
|
|
|
385
11
|
// src/enhancement/createLimitPolicy.ts
|
|
386
|
-
var import_p_limit = __toESM(require_p_limit());
|
|
387
12
|
import { ApiClientError } from "@uniformdev/context/api";
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
var networkErrorMsgs = /* @__PURE__ */ new Set([
|
|
392
|
-
"Failed to fetch",
|
|
393
|
-
// Chrome
|
|
394
|
-
"NetworkError when attempting to fetch resource.",
|
|
395
|
-
// Firefox
|
|
396
|
-
"The Internet connection appears to be offline.",
|
|
397
|
-
// Safari
|
|
398
|
-
"Network request failed",
|
|
399
|
-
// `cross-fetch`
|
|
400
|
-
"fetch failed"
|
|
401
|
-
// Undici (Node.js)
|
|
402
|
-
]);
|
|
403
|
-
var AbortError = class extends Error {
|
|
404
|
-
constructor(message) {
|
|
405
|
-
super();
|
|
406
|
-
if (message instanceof Error) {
|
|
407
|
-
this.originalError = message;
|
|
408
|
-
({ message } = message);
|
|
409
|
-
} else {
|
|
410
|
-
this.originalError = new Error(message);
|
|
411
|
-
this.originalError.stack = this.stack;
|
|
412
|
-
}
|
|
413
|
-
this.name = "AbortError";
|
|
414
|
-
this.message = message;
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
var decorateErrorWithCounts = (error, attemptNumber, options) => {
|
|
418
|
-
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
419
|
-
error.attemptNumber = attemptNumber;
|
|
420
|
-
error.retriesLeft = retriesLeft;
|
|
421
|
-
return error;
|
|
422
|
-
};
|
|
423
|
-
var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
|
|
424
|
-
var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
|
|
425
|
-
async function pRetry(input, options) {
|
|
426
|
-
return new Promise((resolve, reject) => {
|
|
427
|
-
options = {
|
|
428
|
-
onFailedAttempt() {
|
|
429
|
-
},
|
|
430
|
-
retries: 10,
|
|
431
|
-
...options
|
|
432
|
-
};
|
|
433
|
-
const operation = import_retry.default.operation(options);
|
|
434
|
-
operation.attempt(async (attemptNumber) => {
|
|
435
|
-
try {
|
|
436
|
-
resolve(await input(attemptNumber));
|
|
437
|
-
} catch (error) {
|
|
438
|
-
if (!(error instanceof Error)) {
|
|
439
|
-
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (error instanceof AbortError) {
|
|
443
|
-
operation.stop();
|
|
444
|
-
reject(error.originalError);
|
|
445
|
-
} else if (error instanceof TypeError && !isNetworkError(error.message)) {
|
|
446
|
-
operation.stop();
|
|
447
|
-
reject(error);
|
|
448
|
-
} else {
|
|
449
|
-
decorateErrorWithCounts(error, attemptNumber, options);
|
|
450
|
-
try {
|
|
451
|
-
await options.onFailedAttempt(error);
|
|
452
|
-
} catch (error2) {
|
|
453
|
-
reject(error2);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
if (!operation.retry(error)) {
|
|
457
|
-
reject(operation.mainError());
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
if (options.signal && !options.signal.aborted) {
|
|
463
|
-
options.signal.addEventListener("abort", () => {
|
|
464
|
-
operation.stop();
|
|
465
|
-
const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
|
|
466
|
-
reject(reason instanceof Error ? reason : getDOMException(reason));
|
|
467
|
-
}, {
|
|
468
|
-
once: true
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// ../../node_modules/.pnpm/p-throttle@5.0.0/node_modules/p-throttle/index.js
|
|
475
|
-
var AbortError2 = class extends Error {
|
|
476
|
-
constructor() {
|
|
477
|
-
super("Throttled function aborted");
|
|
478
|
-
this.name = "AbortError";
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
function pThrottle({ limit, interval, strict }) {
|
|
482
|
-
if (!Number.isFinite(limit)) {
|
|
483
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
484
|
-
}
|
|
485
|
-
if (!Number.isFinite(interval)) {
|
|
486
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
|
487
|
-
}
|
|
488
|
-
const queue = /* @__PURE__ */ new Map();
|
|
489
|
-
let currentTick = 0;
|
|
490
|
-
let activeCount = 0;
|
|
491
|
-
function windowedDelay() {
|
|
492
|
-
const now = Date.now();
|
|
493
|
-
if (now - currentTick > interval) {
|
|
494
|
-
activeCount = 1;
|
|
495
|
-
currentTick = now;
|
|
496
|
-
return 0;
|
|
497
|
-
}
|
|
498
|
-
if (activeCount < limit) {
|
|
499
|
-
activeCount++;
|
|
500
|
-
} else {
|
|
501
|
-
currentTick += interval;
|
|
502
|
-
activeCount = 1;
|
|
503
|
-
}
|
|
504
|
-
return currentTick - now;
|
|
505
|
-
}
|
|
506
|
-
const strictTicks = [];
|
|
507
|
-
function strictDelay() {
|
|
508
|
-
const now = Date.now();
|
|
509
|
-
if (strictTicks.length < limit) {
|
|
510
|
-
strictTicks.push(now);
|
|
511
|
-
return 0;
|
|
512
|
-
}
|
|
513
|
-
const earliestTime = strictTicks.shift() + interval;
|
|
514
|
-
if (now >= earliestTime) {
|
|
515
|
-
strictTicks.push(now);
|
|
516
|
-
return 0;
|
|
517
|
-
}
|
|
518
|
-
strictTicks.push(earliestTime);
|
|
519
|
-
return earliestTime - now;
|
|
520
|
-
}
|
|
521
|
-
const getDelay = strict ? strictDelay : windowedDelay;
|
|
522
|
-
return (function_) => {
|
|
523
|
-
const throttled = function(...args) {
|
|
524
|
-
if (!throttled.isEnabled) {
|
|
525
|
-
return (async () => function_.apply(this, args))();
|
|
526
|
-
}
|
|
527
|
-
let timeout;
|
|
528
|
-
return new Promise((resolve, reject) => {
|
|
529
|
-
const execute = () => {
|
|
530
|
-
resolve(function_.apply(this, args));
|
|
531
|
-
queue.delete(timeout);
|
|
532
|
-
};
|
|
533
|
-
timeout = setTimeout(execute, getDelay());
|
|
534
|
-
queue.set(timeout, reject);
|
|
535
|
-
});
|
|
536
|
-
};
|
|
537
|
-
throttled.abort = () => {
|
|
538
|
-
for (const timeout of queue.keys()) {
|
|
539
|
-
clearTimeout(timeout);
|
|
540
|
-
queue.get(timeout)(new AbortError2());
|
|
541
|
-
}
|
|
542
|
-
queue.clear();
|
|
543
|
-
strictTicks.splice(0, strictTicks.length);
|
|
544
|
-
};
|
|
545
|
-
throttled.isEnabled = true;
|
|
546
|
-
return throttled;
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// src/enhancement/createLimitPolicy.ts
|
|
13
|
+
import pLimit from "p-limit";
|
|
14
|
+
import pRetry from "p-retry";
|
|
15
|
+
import pThrottle from "p-throttle";
|
|
551
16
|
function createLimitPolicy({
|
|
552
17
|
throttle = { interval: 1e3, limit: 10 },
|
|
553
|
-
retry
|
|
18
|
+
retry = { retries: 1, factor: 1.66 },
|
|
554
19
|
limit = 10
|
|
555
20
|
}) {
|
|
556
21
|
const throttler = throttle ? pThrottle(throttle) : null;
|
|
557
|
-
const limiter = limit ? (
|
|
22
|
+
const limiter = limit ? pLimit(limit) : null;
|
|
558
23
|
return function limitPolicy(func) {
|
|
559
24
|
let currentFunc = async () => await func();
|
|
560
25
|
if (throttler) {
|
|
@@ -565,13 +30,13 @@ function createLimitPolicy({
|
|
|
565
30
|
const limitFunc = currentFunc;
|
|
566
31
|
currentFunc = () => limiter(limitFunc);
|
|
567
32
|
}
|
|
568
|
-
if (
|
|
33
|
+
if (retry) {
|
|
569
34
|
const retryFunc = currentFunc;
|
|
570
35
|
currentFunc = () => pRetry(retryFunc, {
|
|
571
|
-
...
|
|
36
|
+
...retry,
|
|
572
37
|
onFailedAttempt: async (error) => {
|
|
573
|
-
if (
|
|
574
|
-
await
|
|
38
|
+
if (retry.onFailedAttempt) {
|
|
39
|
+
await retry.onFailedAttempt(error);
|
|
575
40
|
}
|
|
576
41
|
if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
577
42
|
throw error;
|
|
@@ -584,6 +49,51 @@ function createLimitPolicy({
|
|
|
584
49
|
}
|
|
585
50
|
var nullLimitPolicy = async (func) => await func();
|
|
586
51
|
|
|
52
|
+
// src/projection/types.ts
|
|
53
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
54
|
+
|
|
55
|
+
// src/projection/projectionToQuery.ts
|
|
56
|
+
function appendCsv(out, key, values) {
|
|
57
|
+
if (values === void 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
out[key] = values.join(",");
|
|
61
|
+
}
|
|
62
|
+
function projectionToQuery(spec) {
|
|
63
|
+
const out = {};
|
|
64
|
+
if (!spec) {
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
const { fields, fieldTypes, slots } = spec;
|
|
68
|
+
const p = SELECT_QUERY_PREFIX;
|
|
69
|
+
if (fields) {
|
|
70
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
71
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
72
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
73
|
+
}
|
|
74
|
+
if (fieldTypes) {
|
|
75
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
76
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
77
|
+
}
|
|
78
|
+
if (slots) {
|
|
79
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
80
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
81
|
+
if (typeof slots.depth === "number") {
|
|
82
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
83
|
+
}
|
|
84
|
+
if (slots.named) {
|
|
85
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
86
|
+
for (const slotName of slotNames) {
|
|
87
|
+
const named = slots.named[slotName];
|
|
88
|
+
if (named && typeof named.depth === "number") {
|
|
89
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
587
97
|
// src/CanvasClient.ts
|
|
588
98
|
var CANVAS_URL = "/api/v1/canvas";
|
|
589
99
|
var CanvasClient = class extends ApiClient {
|
|
@@ -599,17 +109,24 @@ var CanvasClient = class extends ApiClient {
|
|
|
599
109
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
600
110
|
async getCompositionList(params = {}) {
|
|
601
111
|
const { projectId } = this.options;
|
|
602
|
-
const { resolveData, filters, ...originParams } = params;
|
|
112
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
603
113
|
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
114
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
604
115
|
if (!resolveData) {
|
|
605
|
-
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
116
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
117
|
+
...originParams,
|
|
118
|
+
projectId,
|
|
119
|
+
...rewrittenFilters,
|
|
120
|
+
...rewrittenSelect
|
|
121
|
+
});
|
|
606
122
|
return this.apiClient(fetchUri);
|
|
607
123
|
}
|
|
608
124
|
const edgeParams = {
|
|
609
125
|
...originParams,
|
|
610
126
|
projectId,
|
|
611
127
|
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
612
|
-
...rewrittenFilters
|
|
128
|
+
...rewrittenFilters,
|
|
129
|
+
...rewrittenSelect
|
|
613
130
|
};
|
|
614
131
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
615
132
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
@@ -769,15 +286,21 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
|
|
|
769
286
|
}
|
|
770
287
|
getEntries(options) {
|
|
771
288
|
const { projectId } = this.options;
|
|
772
|
-
const { skipDataResolution, filters, ...params } = options;
|
|
289
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
773
290
|
const rewrittenFilters = rewriteFiltersForApi2(filters);
|
|
291
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
774
292
|
if (skipDataResolution) {
|
|
775
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
293
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
294
|
+
...params,
|
|
295
|
+
...rewrittenFilters,
|
|
296
|
+
...rewrittenSelect,
|
|
297
|
+
projectId
|
|
298
|
+
});
|
|
776
299
|
return this.apiClient(url);
|
|
777
300
|
}
|
|
778
301
|
const edgeUrl = this.createUrl(
|
|
779
302
|
__privateGet(_ContentClient, _entriesUrl),
|
|
780
|
-
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
|
303
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
781
304
|
this.edgeApiHost
|
|
782
305
|
);
|
|
783
306
|
return this.apiClient(
|
|
@@ -2406,8 +1929,7 @@ function extractLocales({ component }) {
|
|
|
2406
1929
|
return variations;
|
|
2407
1930
|
}
|
|
2408
1931
|
function localize(options) {
|
|
2409
|
-
const nodes = options
|
|
2410
|
-
const locale = options.locale;
|
|
1932
|
+
const { nodes, locale, keepLocalesFor } = options;
|
|
2411
1933
|
if (!locale) {
|
|
2412
1934
|
return;
|
|
2413
1935
|
}
|
|
@@ -2415,7 +1937,7 @@ function localize(options) {
|
|
|
2415
1937
|
walkNodeTree(nodes, (context) => {
|
|
2416
1938
|
const { type, node, actions } = context;
|
|
2417
1939
|
if (type !== "component") {
|
|
2418
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
1940
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2419
1941
|
return;
|
|
2420
1942
|
}
|
|
2421
1943
|
const result = evaluateWalkTreeNodeVisibility({
|
|
@@ -2436,7 +1958,7 @@ function localize(options) {
|
|
|
2436
1958
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
|
2437
1959
|
replaceComponent.forEach((component) => {
|
|
2438
1960
|
removeLocaleProperty(component);
|
|
2439
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
|
1961
|
+
localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2440
1962
|
});
|
|
2441
1963
|
const [first, ...rest] = replaceComponent;
|
|
2442
1964
|
actions.replace(first);
|
|
@@ -2447,7 +1969,7 @@ function localize(options) {
|
|
|
2447
1969
|
actions.remove();
|
|
2448
1970
|
}
|
|
2449
1971
|
} else {
|
|
2450
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
1972
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2451
1973
|
}
|
|
2452
1974
|
});
|
|
2453
1975
|
}
|
|
@@ -2466,7 +1988,7 @@ function removeLocaleProperty(component) {
|
|
|
2466
1988
|
}
|
|
2467
1989
|
}
|
|
2468
1990
|
}
|
|
2469
|
-
function localizeProperties(node, locale, rules) {
|
|
1991
|
+
function localizeProperties(node, locale, rules, keepLocalesFor) {
|
|
2470
1992
|
const properties = getPropertiesValue(node);
|
|
2471
1993
|
if (!properties) {
|
|
2472
1994
|
return void 0;
|
|
@@ -2485,10 +2007,16 @@ function localizeProperties(node, locale, rules) {
|
|
|
2485
2007
|
if (currentLocaleConditionalValues !== void 0) {
|
|
2486
2008
|
propertyValue.conditions = currentLocaleConditionalValues;
|
|
2487
2009
|
}
|
|
2488
|
-
|
|
2489
|
-
|
|
2010
|
+
const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
|
|
2011
|
+
if (!preserveLocales) {
|
|
2012
|
+
delete propertyValue.locales;
|
|
2013
|
+
delete propertyValue.localesConditions;
|
|
2014
|
+
}
|
|
2490
2015
|
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
|
2491
|
-
|
|
2016
|
+
const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
|
|
2017
|
+
if (!hasLocales) {
|
|
2018
|
+
delete properties[propertyId];
|
|
2019
|
+
}
|
|
2492
2020
|
}
|
|
2493
2021
|
});
|
|
2494
2022
|
evaluateWalkTreePropertyCriteria({
|
|
@@ -3167,6 +2695,173 @@ __privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
|
3167
2695
|
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
3168
2696
|
var ProjectClient = _ProjectClient;
|
|
3169
2697
|
|
|
2698
|
+
// src/projection/matchesProjectionPattern.ts
|
|
2699
|
+
var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
|
|
2700
|
+
var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
|
|
2701
|
+
function isValidProjectionPattern(pattern) {
|
|
2702
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
2703
|
+
return false;
|
|
2704
|
+
}
|
|
2705
|
+
if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
|
|
2706
|
+
return false;
|
|
2707
|
+
}
|
|
2708
|
+
return true;
|
|
2709
|
+
}
|
|
2710
|
+
function compilePattern(pattern) {
|
|
2711
|
+
let regexSource = "^";
|
|
2712
|
+
for (const ch of pattern) {
|
|
2713
|
+
if (ch === "*") {
|
|
2714
|
+
regexSource += ".*";
|
|
2715
|
+
} else {
|
|
2716
|
+
regexSource += ch.replace(REGEX_METACHAR, "\\$&");
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
regexSource += "$";
|
|
2720
|
+
return new RegExp(regexSource);
|
|
2721
|
+
}
|
|
2722
|
+
var PATTERN_CACHE_MAX = 1024;
|
|
2723
|
+
var patternRegexCache = /* @__PURE__ */ new Map();
|
|
2724
|
+
function matchesProjectionPattern(pattern, value) {
|
|
2725
|
+
let re = patternRegexCache.get(pattern);
|
|
2726
|
+
if (re === void 0) {
|
|
2727
|
+
if (!isValidProjectionPattern(pattern)) {
|
|
2728
|
+
throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
|
|
2729
|
+
}
|
|
2730
|
+
re = compilePattern(pattern);
|
|
2731
|
+
if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
|
|
2732
|
+
const oldest = patternRegexCache.keys().next().value;
|
|
2733
|
+
if (oldest !== void 0) patternRegexCache.delete(oldest);
|
|
2734
|
+
}
|
|
2735
|
+
patternRegexCache.set(pattern, re);
|
|
2736
|
+
}
|
|
2737
|
+
return re.test(value);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
// src/projection/queryToProjection.ts
|
|
2741
|
+
var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
|
|
2742
|
+
var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
|
|
2743
|
+
function toStringValue2(value) {
|
|
2744
|
+
if (Array.isArray(value)) {
|
|
2745
|
+
return value.join(",");
|
|
2746
|
+
}
|
|
2747
|
+
return value;
|
|
2748
|
+
}
|
|
2749
|
+
function parseCsv(value) {
|
|
2750
|
+
const str = toStringValue2(value);
|
|
2751
|
+
if (!str) {
|
|
2752
|
+
return [];
|
|
2753
|
+
}
|
|
2754
|
+
return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
2755
|
+
}
|
|
2756
|
+
function parseDepth(value, key) {
|
|
2757
|
+
const str = toStringValue2(value);
|
|
2758
|
+
if (str === void 0 || str === "") {
|
|
2759
|
+
throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
|
|
2760
|
+
}
|
|
2761
|
+
if (!/^\d+$/.test(str)) {
|
|
2762
|
+
throw new Error(
|
|
2763
|
+
`Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
|
|
2764
|
+
);
|
|
2765
|
+
}
|
|
2766
|
+
return Number(str);
|
|
2767
|
+
}
|
|
2768
|
+
function extractSelectKeys(source) {
|
|
2769
|
+
if (source instanceof URLSearchParams) {
|
|
2770
|
+
let out2;
|
|
2771
|
+
for (const [key, value] of source.entries()) {
|
|
2772
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
2773
|
+
out2 != null ? out2 : out2 = {};
|
|
2774
|
+
out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
|
|
2775
|
+
}
|
|
2776
|
+
return out2;
|
|
2777
|
+
}
|
|
2778
|
+
let out;
|
|
2779
|
+
for (const key in source) {
|
|
2780
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
2781
|
+
out != null ? out : out = {};
|
|
2782
|
+
out[key] = source[key];
|
|
2783
|
+
}
|
|
2784
|
+
return out;
|
|
2785
|
+
}
|
|
2786
|
+
function queryToProjection(source) {
|
|
2787
|
+
var _a, _b, _c, _d, _e;
|
|
2788
|
+
if (!source) {
|
|
2789
|
+
return void 0;
|
|
2790
|
+
}
|
|
2791
|
+
const query = extractSelectKeys(source);
|
|
2792
|
+
if (!query) {
|
|
2793
|
+
return void 0;
|
|
2794
|
+
}
|
|
2795
|
+
const spec = {};
|
|
2796
|
+
for (const [rawKey, value] of Object.entries(query)) {
|
|
2797
|
+
const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
|
|
2798
|
+
const namedMatch = SLOTS_NAMED_KEY.exec(key);
|
|
2799
|
+
if (namedMatch) {
|
|
2800
|
+
const [, slotName, operator2] = namedMatch;
|
|
2801
|
+
if (operator2 !== "depth") {
|
|
2802
|
+
throw new Error(
|
|
2803
|
+
`Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
|
|
2807
|
+
const named = (_b = slots.named) != null ? _b : slots.named = {};
|
|
2808
|
+
named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
|
|
2809
|
+
continue;
|
|
2810
|
+
}
|
|
2811
|
+
const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
|
|
2812
|
+
if (!topMatch) {
|
|
2813
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
2814
|
+
}
|
|
2815
|
+
const [, bucket, operator] = topMatch;
|
|
2816
|
+
if (bucket === "fields") {
|
|
2817
|
+
const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
|
|
2818
|
+
switch (operator) {
|
|
2819
|
+
case "only":
|
|
2820
|
+
fields.only = parseCsv(value);
|
|
2821
|
+
break;
|
|
2822
|
+
case "except":
|
|
2823
|
+
fields.except = parseCsv(value);
|
|
2824
|
+
break;
|
|
2825
|
+
case "locales":
|
|
2826
|
+
fields.locales = parseCsv(value);
|
|
2827
|
+
break;
|
|
2828
|
+
default:
|
|
2829
|
+
throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
|
|
2830
|
+
}
|
|
2831
|
+
} else if (bucket === "fieldTypes") {
|
|
2832
|
+
const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
|
|
2833
|
+
switch (operator) {
|
|
2834
|
+
case "only":
|
|
2835
|
+
fieldTypes.only = parseCsv(value);
|
|
2836
|
+
break;
|
|
2837
|
+
case "except":
|
|
2838
|
+
fieldTypes.except = parseCsv(value);
|
|
2839
|
+
break;
|
|
2840
|
+
default:
|
|
2841
|
+
throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
|
|
2842
|
+
}
|
|
2843
|
+
} else if (bucket === "slots") {
|
|
2844
|
+
const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
|
|
2845
|
+
switch (operator) {
|
|
2846
|
+
case "only":
|
|
2847
|
+
slots.only = parseCsv(value);
|
|
2848
|
+
break;
|
|
2849
|
+
case "except":
|
|
2850
|
+
slots.except = parseCsv(value);
|
|
2851
|
+
break;
|
|
2852
|
+
case "depth":
|
|
2853
|
+
slots.depth = parseDepth(value, rawKey);
|
|
2854
|
+
break;
|
|
2855
|
+
default:
|
|
2856
|
+
throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
|
|
2857
|
+
}
|
|
2858
|
+
} else {
|
|
2859
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
return spec;
|
|
2863
|
+
}
|
|
2864
|
+
|
|
3170
2865
|
// src/PromptClient.ts
|
|
3171
2866
|
import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
|
|
3172
2867
|
var PromptsUrl = "/api/v1/prompts";
|
|
@@ -3295,7 +2990,9 @@ var RouteClient = class extends ApiClient16 {
|
|
|
3295
2990
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
3296
2991
|
async getRoute(options) {
|
|
3297
2992
|
const { projectId } = this.options;
|
|
3298
|
-
const
|
|
2993
|
+
const { select, ...rest } = options != null ? options : {};
|
|
2994
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
2995
|
+
const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
|
|
3299
2996
|
return await this.apiClient(
|
|
3300
2997
|
fetchUri,
|
|
3301
2998
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
@@ -3658,7 +3355,7 @@ function handleRichTextNodeBinding(object, options) {
|
|
|
3658
3355
|
import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
|
|
3659
3356
|
|
|
3660
3357
|
// src/.version.ts
|
|
3661
|
-
var version = "20.
|
|
3358
|
+
var version = "20.71.1";
|
|
3662
3359
|
|
|
3663
3360
|
// src/WorkflowClient.ts
|
|
3664
3361
|
import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
|
|
@@ -3779,6 +3476,7 @@ export {
|
|
|
3779
3476
|
ReleaseContentsClient,
|
|
3780
3477
|
RouteClient,
|
|
3781
3478
|
SECRET_QUERY_STRING_PARAM,
|
|
3479
|
+
SELECT_QUERY_PREFIX,
|
|
3782
3480
|
UncachedCanvasClient,
|
|
3783
3481
|
UncachedCategoryClient,
|
|
3784
3482
|
UncachedContentClient,
|
|
@@ -3860,10 +3558,13 @@ export {
|
|
|
3860
3558
|
localize,
|
|
3861
3559
|
mapSlotToPersonalizedVariations,
|
|
3862
3560
|
mapSlotToTestVariations,
|
|
3561
|
+
matchesProjectionPattern,
|
|
3863
3562
|
mergeAssetConfigWithDefaults,
|
|
3864
3563
|
nullLimitPolicy,
|
|
3865
3564
|
parseComponentPlaceholderId,
|
|
3866
3565
|
parseVariableExpression,
|
|
3566
|
+
projectionToQuery,
|
|
3567
|
+
queryToProjection,
|
|
3867
3568
|
version,
|
|
3868
3569
|
walkNodeTree,
|
|
3869
3570
|
walkPropertyValues
|