@uniformdev/canvas 20.49.2 → 20.49.3-alpha.47
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 +3674 -2232
- package/dist/index.d.ts +3674 -2232
- package/dist/index.esm.js +481 -648
- package/dist/index.js +495 -631
- package/dist/index.mjs +481 -648
- package/package.json +11 -13
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_api19.ApiClientError,
|
|
401
49
|
BatchEntry: () => BatchEntry,
|
|
402
50
|
BlockFormatError: () => BlockFormatError,
|
|
403
51
|
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
|
@@ -459,19 +107,23 @@ __export(src_exports, {
|
|
|
459
107
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
|
460
108
|
IntegrationPropertyEditorsClient: () => IntegrationPropertyEditorsClient,
|
|
461
109
|
LOCALE_DYNAMIC_INPUT_NAME: () => LOCALE_DYNAMIC_INPUT_NAME,
|
|
110
|
+
LabelClient: () => LabelClient,
|
|
462
111
|
LocaleClient: () => LocaleClient,
|
|
463
112
|
PLACEHOLDER_ID: () => PLACEHOLDER_ID,
|
|
464
113
|
PreviewClient: () => PreviewClient,
|
|
465
114
|
ProjectClient: () => ProjectClient,
|
|
466
115
|
PromptClient: () => PromptClient,
|
|
116
|
+
REFERENCE_DATA_TYPE_ID: () => REFERENCE_DATA_TYPE_ID,
|
|
467
117
|
RelationshipClient: () => RelationshipClient,
|
|
468
118
|
ReleaseClient: () => ReleaseClient,
|
|
469
119
|
ReleaseContentsClient: () => ReleaseContentsClient,
|
|
470
120
|
RouteClient: () => RouteClient,
|
|
471
121
|
SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
|
|
122
|
+
SELECT_QUERY_PREFIX: () => SELECT_QUERY_PREFIX,
|
|
472
123
|
UncachedCanvasClient: () => UncachedCanvasClient,
|
|
473
124
|
UncachedCategoryClient: () => UncachedCategoryClient,
|
|
474
125
|
UncachedContentClient: () => UncachedContentClient,
|
|
126
|
+
UncachedLabelClient: () => UncachedLabelClient,
|
|
475
127
|
UniqueBatchEntries: () => UniqueBatchEntries,
|
|
476
128
|
WorkflowClient: () => WorkflowClient,
|
|
477
129
|
autoFixParameterGroups: () => autoFixParameterGroups,
|
|
@@ -518,6 +170,7 @@ __export(src_exports, {
|
|
|
518
170
|
isAllowedReferrer: () => isAllowedReferrer,
|
|
519
171
|
isAssetParamValue: () => isAssetParamValue,
|
|
520
172
|
isAssetParamValueItem: () => isAssetParamValueItem,
|
|
173
|
+
isAwaitingReadyMessage: () => isAwaitingReadyMessage,
|
|
521
174
|
isComponentActionMessage: () => isComponentActionMessage,
|
|
522
175
|
isComponentPlaceholderId: () => isComponentPlaceholderId,
|
|
523
176
|
isContextStorageUpdatedMessage: () => isContextStorageUpdatedMessage,
|
|
@@ -533,6 +186,7 @@ __export(src_exports, {
|
|
|
533
186
|
isRootEntryReference: () => isRootEntryReference,
|
|
534
187
|
isSelectComponentMessage: () => isSelectComponentMessage,
|
|
535
188
|
isSelectParameterMessage: () => isSelectParameterMessage,
|
|
189
|
+
isSessionPendingMessage: () => isSessionPendingMessage,
|
|
536
190
|
isSuggestComponentMessage: () => isSuggestComponentMessage,
|
|
537
191
|
isSystemComponentDefinition: () => isSystemComponentDefinition,
|
|
538
192
|
isTriggerCompositionActionMessage: () => isTriggerCompositionActionMessage,
|
|
@@ -547,191 +201,33 @@ __export(src_exports, {
|
|
|
547
201
|
localize: () => localize,
|
|
548
202
|
mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
|
|
549
203
|
mapSlotToTestVariations: () => mapSlotToTestVariations,
|
|
204
|
+
matchesProjectionPattern: () => matchesProjectionPattern,
|
|
550
205
|
mergeAssetConfigWithDefaults: () => mergeAssetConfigWithDefaults,
|
|
551
206
|
nullLimitPolicy: () => nullLimitPolicy,
|
|
552
207
|
parseComponentPlaceholderId: () => parseComponentPlaceholderId,
|
|
553
208
|
parseVariableExpression: () => parseVariableExpression,
|
|
209
|
+
projectionToQuery: () => projectionToQuery,
|
|
210
|
+
queryToProjection: () => queryToProjection,
|
|
554
211
|
version: () => version,
|
|
555
212
|
walkNodeTree: () => walkNodeTree,
|
|
556
213
|
walkPropertyValues: () => walkPropertyValues
|
|
557
214
|
});
|
|
558
|
-
module.exports = __toCommonJS(
|
|
215
|
+
module.exports = __toCommonJS(index_exports);
|
|
559
216
|
|
|
560
217
|
// src/CanvasClient.ts
|
|
561
218
|
var import_api2 = require("@uniformdev/context/api");
|
|
562
219
|
|
|
563
220
|
// src/enhancement/createLimitPolicy.ts
|
|
564
221
|
var import_api = require("@uniformdev/context/api");
|
|
565
|
-
var import_p_limit = __toESM(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
var import_retry = __toESM(require_retry2(), 1);
|
|
569
|
-
var networkErrorMsgs = /* @__PURE__ */ new Set([
|
|
570
|
-
"Failed to fetch",
|
|
571
|
-
// Chrome
|
|
572
|
-
"NetworkError when attempting to fetch resource.",
|
|
573
|
-
// Firefox
|
|
574
|
-
"The Internet connection appears to be offline.",
|
|
575
|
-
// Safari
|
|
576
|
-
"Network request failed",
|
|
577
|
-
// `cross-fetch`
|
|
578
|
-
"fetch failed"
|
|
579
|
-
// Undici (Node.js)
|
|
580
|
-
]);
|
|
581
|
-
var AbortError = class extends Error {
|
|
582
|
-
constructor(message) {
|
|
583
|
-
super();
|
|
584
|
-
if (message instanceof Error) {
|
|
585
|
-
this.originalError = message;
|
|
586
|
-
({ message } = message);
|
|
587
|
-
} else {
|
|
588
|
-
this.originalError = new Error(message);
|
|
589
|
-
this.originalError.stack = this.stack;
|
|
590
|
-
}
|
|
591
|
-
this.name = "AbortError";
|
|
592
|
-
this.message = message;
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
var decorateErrorWithCounts = (error, attemptNumber, options) => {
|
|
596
|
-
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
597
|
-
error.attemptNumber = attemptNumber;
|
|
598
|
-
error.retriesLeft = retriesLeft;
|
|
599
|
-
return error;
|
|
600
|
-
};
|
|
601
|
-
var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
|
|
602
|
-
var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
|
|
603
|
-
async function pRetry(input, options) {
|
|
604
|
-
return new Promise((resolve, reject) => {
|
|
605
|
-
options = {
|
|
606
|
-
onFailedAttempt() {
|
|
607
|
-
},
|
|
608
|
-
retries: 10,
|
|
609
|
-
...options
|
|
610
|
-
};
|
|
611
|
-
const operation = import_retry.default.operation(options);
|
|
612
|
-
operation.attempt(async (attemptNumber) => {
|
|
613
|
-
try {
|
|
614
|
-
resolve(await input(attemptNumber));
|
|
615
|
-
} catch (error) {
|
|
616
|
-
if (!(error instanceof Error)) {
|
|
617
|
-
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
if (error instanceof AbortError) {
|
|
621
|
-
operation.stop();
|
|
622
|
-
reject(error.originalError);
|
|
623
|
-
} else if (error instanceof TypeError && !isNetworkError(error.message)) {
|
|
624
|
-
operation.stop();
|
|
625
|
-
reject(error);
|
|
626
|
-
} else {
|
|
627
|
-
decorateErrorWithCounts(error, attemptNumber, options);
|
|
628
|
-
try {
|
|
629
|
-
await options.onFailedAttempt(error);
|
|
630
|
-
} catch (error2) {
|
|
631
|
-
reject(error2);
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
if (!operation.retry(error)) {
|
|
635
|
-
reject(operation.mainError());
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
if (options.signal && !options.signal.aborted) {
|
|
641
|
-
options.signal.addEventListener("abort", () => {
|
|
642
|
-
operation.stop();
|
|
643
|
-
const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
|
|
644
|
-
reject(reason instanceof Error ? reason : getDOMException(reason));
|
|
645
|
-
}, {
|
|
646
|
-
once: true
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// ../../node_modules/.pnpm/p-throttle@5.0.0/node_modules/p-throttle/index.js
|
|
653
|
-
var AbortError2 = class extends Error {
|
|
654
|
-
constructor() {
|
|
655
|
-
super("Throttled function aborted");
|
|
656
|
-
this.name = "AbortError";
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
function pThrottle({ limit, interval, strict }) {
|
|
660
|
-
if (!Number.isFinite(limit)) {
|
|
661
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
662
|
-
}
|
|
663
|
-
if (!Number.isFinite(interval)) {
|
|
664
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
|
665
|
-
}
|
|
666
|
-
const queue = /* @__PURE__ */ new Map();
|
|
667
|
-
let currentTick = 0;
|
|
668
|
-
let activeCount = 0;
|
|
669
|
-
function windowedDelay() {
|
|
670
|
-
const now = Date.now();
|
|
671
|
-
if (now - currentTick > interval) {
|
|
672
|
-
activeCount = 1;
|
|
673
|
-
currentTick = now;
|
|
674
|
-
return 0;
|
|
675
|
-
}
|
|
676
|
-
if (activeCount < limit) {
|
|
677
|
-
activeCount++;
|
|
678
|
-
} else {
|
|
679
|
-
currentTick += interval;
|
|
680
|
-
activeCount = 1;
|
|
681
|
-
}
|
|
682
|
-
return currentTick - now;
|
|
683
|
-
}
|
|
684
|
-
const strictTicks = [];
|
|
685
|
-
function strictDelay() {
|
|
686
|
-
const now = Date.now();
|
|
687
|
-
if (strictTicks.length < limit) {
|
|
688
|
-
strictTicks.push(now);
|
|
689
|
-
return 0;
|
|
690
|
-
}
|
|
691
|
-
const earliestTime = strictTicks.shift() + interval;
|
|
692
|
-
if (now >= earliestTime) {
|
|
693
|
-
strictTicks.push(now);
|
|
694
|
-
return 0;
|
|
695
|
-
}
|
|
696
|
-
strictTicks.push(earliestTime);
|
|
697
|
-
return earliestTime - now;
|
|
698
|
-
}
|
|
699
|
-
const getDelay = strict ? strictDelay : windowedDelay;
|
|
700
|
-
return (function_) => {
|
|
701
|
-
const throttled = function(...args) {
|
|
702
|
-
if (!throttled.isEnabled) {
|
|
703
|
-
return (async () => function_.apply(this, args))();
|
|
704
|
-
}
|
|
705
|
-
let timeout;
|
|
706
|
-
return new Promise((resolve, reject) => {
|
|
707
|
-
const execute = () => {
|
|
708
|
-
resolve(function_.apply(this, args));
|
|
709
|
-
queue.delete(timeout);
|
|
710
|
-
};
|
|
711
|
-
timeout = setTimeout(execute, getDelay());
|
|
712
|
-
queue.set(timeout, reject);
|
|
713
|
-
});
|
|
714
|
-
};
|
|
715
|
-
throttled.abort = () => {
|
|
716
|
-
for (const timeout of queue.keys()) {
|
|
717
|
-
clearTimeout(timeout);
|
|
718
|
-
queue.get(timeout)(new AbortError2());
|
|
719
|
-
}
|
|
720
|
-
queue.clear();
|
|
721
|
-
strictTicks.splice(0, strictTicks.length);
|
|
722
|
-
};
|
|
723
|
-
throttled.isEnabled = true;
|
|
724
|
-
return throttled;
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// src/enhancement/createLimitPolicy.ts
|
|
222
|
+
var import_p_limit = __toESM(require("p-limit"));
|
|
223
|
+
var import_p_retry = __toESM(require("p-retry"));
|
|
224
|
+
var import_p_throttle = __toESM(require("p-throttle"));
|
|
729
225
|
function createLimitPolicy({
|
|
730
226
|
throttle = { interval: 1e3, limit: 10 },
|
|
731
|
-
retry
|
|
227
|
+
retry = { retries: 1, factor: 1.66 },
|
|
732
228
|
limit = 10
|
|
733
229
|
}) {
|
|
734
|
-
const throttler = throttle ?
|
|
230
|
+
const throttler = throttle ? (0, import_p_throttle.default)(throttle) : null;
|
|
735
231
|
const limiter = limit ? (0, import_p_limit.default)(limit) : null;
|
|
736
232
|
return function limitPolicy(func) {
|
|
737
233
|
let currentFunc = async () => await func();
|
|
@@ -743,13 +239,13 @@ function createLimitPolicy({
|
|
|
743
239
|
const limitFunc = currentFunc;
|
|
744
240
|
currentFunc = () => limiter(limitFunc);
|
|
745
241
|
}
|
|
746
|
-
if (
|
|
242
|
+
if (retry) {
|
|
747
243
|
const retryFunc = currentFunc;
|
|
748
|
-
currentFunc = () =>
|
|
749
|
-
...
|
|
244
|
+
currentFunc = () => (0, import_p_retry.default)(retryFunc, {
|
|
245
|
+
...retry,
|
|
750
246
|
onFailedAttempt: async (error) => {
|
|
751
|
-
if (
|
|
752
|
-
await
|
|
247
|
+
if (retry.onFailedAttempt) {
|
|
248
|
+
await retry.onFailedAttempt(error);
|
|
753
249
|
}
|
|
754
250
|
if (error instanceof import_api.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
755
251
|
throw error;
|
|
@@ -762,20 +258,52 @@ function createLimitPolicy({
|
|
|
762
258
|
}
|
|
763
259
|
var nullLimitPolicy = async (func) => await func();
|
|
764
260
|
|
|
765
|
-
// src/
|
|
766
|
-
var
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
261
|
+
// src/projection/types.ts
|
|
262
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
263
|
+
|
|
264
|
+
// src/projection/projectionToQuery.ts
|
|
265
|
+
function appendCsv(out, key, values) {
|
|
266
|
+
if (values === void 0) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
out[key] = values.join(",");
|
|
270
|
+
}
|
|
271
|
+
function projectionToQuery(spec) {
|
|
272
|
+
const out = {};
|
|
273
|
+
if (!spec) {
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
const { fields, fieldTypes, slots } = spec;
|
|
277
|
+
const p = SELECT_QUERY_PREFIX;
|
|
278
|
+
if (fields) {
|
|
279
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
280
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
281
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
282
|
+
if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
|
|
283
|
+
out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (fieldTypes) {
|
|
287
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
288
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
289
|
+
}
|
|
290
|
+
if (slots) {
|
|
291
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
292
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
293
|
+
if (typeof slots.depth === "number") {
|
|
294
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
295
|
+
}
|
|
296
|
+
if (slots.named) {
|
|
297
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
298
|
+
for (const slotName of slotNames) {
|
|
299
|
+
const named = slots.named[slotName];
|
|
300
|
+
if (named && typeof named.depth === "number") {
|
|
301
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return out;
|
|
779
307
|
}
|
|
780
308
|
|
|
781
309
|
// src/CanvasClient.ts
|
|
@@ -793,17 +321,24 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
793
321
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
794
322
|
async getCompositionList(params = {}) {
|
|
795
323
|
const { projectId } = this.options;
|
|
796
|
-
const { resolveData, filters, ...originParams } = params;
|
|
797
|
-
const rewrittenFilters =
|
|
324
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
325
|
+
const rewrittenFilters = (0, import_api2.rewriteFiltersForApi)(filters);
|
|
326
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
798
327
|
if (!resolveData) {
|
|
799
|
-
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
328
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
329
|
+
...originParams,
|
|
330
|
+
projectId,
|
|
331
|
+
...rewrittenFilters,
|
|
332
|
+
...rewrittenSelect
|
|
333
|
+
});
|
|
800
334
|
return this.apiClient(fetchUri);
|
|
801
335
|
}
|
|
802
336
|
const edgeParams = {
|
|
803
337
|
...originParams,
|
|
804
338
|
projectId,
|
|
805
339
|
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
806
|
-
...rewrittenFilters
|
|
340
|
+
...rewrittenFilters,
|
|
341
|
+
...rewrittenSelect
|
|
807
342
|
};
|
|
808
343
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
809
344
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
@@ -963,15 +498,21 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
|
|
|
963
498
|
}
|
|
964
499
|
getEntries(options) {
|
|
965
500
|
const { projectId } = this.options;
|
|
966
|
-
const { skipDataResolution, filters, ...params } = options;
|
|
967
|
-
const rewrittenFilters =
|
|
501
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
502
|
+
const rewrittenFilters = (0, import_api4.rewriteFiltersForApi)(filters);
|
|
503
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
968
504
|
if (skipDataResolution) {
|
|
969
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
505
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
506
|
+
...params,
|
|
507
|
+
...rewrittenFilters,
|
|
508
|
+
...rewrittenSelect,
|
|
509
|
+
projectId
|
|
510
|
+
});
|
|
970
511
|
return this.apiClient(url);
|
|
971
512
|
}
|
|
972
513
|
const edgeUrl = this.createUrl(
|
|
973
514
|
__privateGet(_ContentClient, _entriesUrl),
|
|
974
|
-
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
|
515
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
975
516
|
this.edgeApiHost
|
|
976
517
|
);
|
|
977
518
|
return this.apiClient(
|
|
@@ -1300,6 +841,7 @@ var EDGE_CACHE_DISABLED = -1;
|
|
|
1300
841
|
var ASSET_PARAMETER_TYPE = "asset";
|
|
1301
842
|
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
|
1302
843
|
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
|
844
|
+
var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
|
|
1303
845
|
|
|
1304
846
|
// src/utils/guards.ts
|
|
1305
847
|
function isRootEntryReference(root) {
|
|
@@ -1378,9 +920,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1378
920
|
let bufferStartIndex = 0;
|
|
1379
921
|
let bufferEndIndex = 0;
|
|
1380
922
|
let tokenCount = 0;
|
|
1381
|
-
const handleToken = (token, type) => {
|
|
923
|
+
const handleToken = (token, type, offset) => {
|
|
1382
924
|
tokenCount++;
|
|
1383
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
925
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1384
926
|
};
|
|
1385
927
|
let state = "text";
|
|
1386
928
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1391,7 +933,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1391
933
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1392
934
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1393
935
|
bufferEndIndex -= escapeCharacter.length;
|
|
1394
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
936
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1395
937
|
return tokenCount;
|
|
1396
938
|
}
|
|
1397
939
|
bufferStartIndex = index;
|
|
@@ -1400,12 +942,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1400
942
|
}
|
|
1401
943
|
if (state === "variable") {
|
|
1402
944
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1403
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
945
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1404
946
|
return tokenCount;
|
|
1405
947
|
}
|
|
1406
948
|
bufferStartIndex = bufferEndIndex;
|
|
1407
949
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1408
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
950
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1409
951
|
return tokenCount;
|
|
1410
952
|
}
|
|
1411
953
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1423,7 +965,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1423
965
|
state = "text";
|
|
1424
966
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1425
967
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1426
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
968
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1427
969
|
return tokenCount;
|
|
1428
970
|
}
|
|
1429
971
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1437,7 +979,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1437
979
|
bufferStartIndex -= variablePrefix.length;
|
|
1438
980
|
}
|
|
1439
981
|
if (bufferStartIndex < serialized.length) {
|
|
1440
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
982
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1441
983
|
}
|
|
1442
984
|
return tokenCount;
|
|
1443
985
|
}
|
|
@@ -1458,7 +1000,7 @@ function hasReferencedVariables(value) {
|
|
|
1458
1000
|
|
|
1459
1001
|
// src/enhancement/walkNodeTree.ts
|
|
1460
1002
|
function walkNodeTree(node, visitor, options) {
|
|
1461
|
-
var _a, _b;
|
|
1003
|
+
var _a, _b, _c;
|
|
1462
1004
|
const componentQueue = [
|
|
1463
1005
|
{
|
|
1464
1006
|
ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
|
|
@@ -1466,12 +1008,14 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1466
1008
|
}
|
|
1467
1009
|
];
|
|
1468
1010
|
const childContexts = /* @__PURE__ */ new Map();
|
|
1011
|
+
const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
|
|
1012
|
+
const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
|
|
1469
1013
|
do {
|
|
1470
|
-
const currentQueueEntry =
|
|
1014
|
+
const currentQueueEntry = takeNext();
|
|
1471
1015
|
if (!currentQueueEntry) continue;
|
|
1472
1016
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
|
1473
1017
|
let visitDescendants = true;
|
|
1474
|
-
let descendantContext = (
|
|
1018
|
+
let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
|
|
1475
1019
|
let visitorInfo;
|
|
1476
1020
|
if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
|
|
1477
1021
|
visitorInfo = {
|
|
@@ -1658,39 +1202,11 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1658
1202
|
continue;
|
|
1659
1203
|
}
|
|
1660
1204
|
const slots = "slots" in currentComponent.node && currentComponent.node.slots;
|
|
1661
|
-
|
|
1662
|
-
const slotKeys = Object.keys(slots);
|
|
1663
|
-
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
|
1664
|
-
const slotKey = slotKeys[slotIndex];
|
|
1665
|
-
const components = slots[slotKey];
|
|
1666
|
-
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
|
1667
|
-
const enqueueingComponent = components[componentIndex];
|
|
1668
|
-
const parentSlotIndexFn = () => {
|
|
1669
|
-
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1670
|
-
(x) => x === enqueueingComponent
|
|
1671
|
-
);
|
|
1672
|
-
return result;
|
|
1673
|
-
};
|
|
1674
|
-
componentQueue.push({
|
|
1675
|
-
ancestorsAndSelf: [
|
|
1676
|
-
{
|
|
1677
|
-
type: "slot",
|
|
1678
|
-
node: enqueueingComponent,
|
|
1679
|
-
parentSlot: slotKey,
|
|
1680
|
-
parentSlotIndexFn
|
|
1681
|
-
},
|
|
1682
|
-
...currentQueueEntry.ancestorsAndSelf
|
|
1683
|
-
],
|
|
1684
|
-
context: descendantContext
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1205
|
+
const childEntries = [];
|
|
1689
1206
|
const properties = getPropertiesValue(currentComponent.node);
|
|
1690
1207
|
if (properties) {
|
|
1691
1208
|
const propertyEntries = Object.entries(properties);
|
|
1692
|
-
for (
|
|
1693
|
-
const [propKey, propObject] = propertyEntries[propIndex];
|
|
1209
|
+
for (const [propKey, propObject] of propertyEntries) {
|
|
1694
1210
|
if (!isNestedNodeType(propObject.type)) {
|
|
1695
1211
|
continue;
|
|
1696
1212
|
}
|
|
@@ -1710,13 +1226,12 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1710
1226
|
continue;
|
|
1711
1227
|
}
|
|
1712
1228
|
}
|
|
1713
|
-
const blocks = (
|
|
1714
|
-
for (
|
|
1715
|
-
const enqueueingBlock = blocks[blockIndex];
|
|
1229
|
+
const blocks = (_c = propObject.value) != null ? _c : [];
|
|
1230
|
+
for (const enqueueingBlock of blocks) {
|
|
1716
1231
|
const blockIndexFn = () => {
|
|
1717
1232
|
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
|
1718
1233
|
};
|
|
1719
|
-
|
|
1234
|
+
childEntries.push({
|
|
1720
1235
|
ancestorsAndSelf: [
|
|
1721
1236
|
{
|
|
1722
1237
|
type: "block",
|
|
@@ -1731,6 +1246,36 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1731
1246
|
}
|
|
1732
1247
|
}
|
|
1733
1248
|
}
|
|
1249
|
+
if (slots) {
|
|
1250
|
+
const slotKeys = Object.keys(slots);
|
|
1251
|
+
for (const slotKey of slotKeys) {
|
|
1252
|
+
const components = slots[slotKey];
|
|
1253
|
+
for (const enqueueingComponent of components) {
|
|
1254
|
+
const parentSlotIndexFn = () => {
|
|
1255
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1256
|
+
(x) => x === enqueueingComponent
|
|
1257
|
+
);
|
|
1258
|
+
return result;
|
|
1259
|
+
};
|
|
1260
|
+
childEntries.push({
|
|
1261
|
+
ancestorsAndSelf: [
|
|
1262
|
+
{
|
|
1263
|
+
type: "slot",
|
|
1264
|
+
node: enqueueingComponent,
|
|
1265
|
+
parentSlot: slotKey,
|
|
1266
|
+
parentSlotIndexFn
|
|
1267
|
+
},
|
|
1268
|
+
...currentQueueEntry.ancestorsAndSelf
|
|
1269
|
+
],
|
|
1270
|
+
context: descendantContext
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (order === "dfs") {
|
|
1276
|
+
childEntries.reverse();
|
|
1277
|
+
}
|
|
1278
|
+
componentQueue.push(...childEntries);
|
|
1734
1279
|
} while (componentQueue.length > 0);
|
|
1735
1280
|
}
|
|
1736
1281
|
function isNestedNodeType(type) {
|
|
@@ -2156,7 +1701,7 @@ function getLocaleMatch(index, locale, greedy) {
|
|
|
2156
1701
|
}
|
|
2157
1702
|
const match = index[locale];
|
|
2158
1703
|
if (match === void 0 && greedy) {
|
|
2159
|
-
return Object.values(index)
|
|
1704
|
+
return Object.values(index).find((value) => value !== void 0);
|
|
2160
1705
|
}
|
|
2161
1706
|
return match;
|
|
2162
1707
|
}
|
|
@@ -2419,11 +1964,34 @@ var stringOperatorEvaluators = {
|
|
|
2419
1964
|
endswith: endsWithEvaluator,
|
|
2420
1965
|
empty: emptyEvaluator
|
|
2421
1966
|
};
|
|
1967
|
+
var numericOperatorEvaluators = {
|
|
1968
|
+
gt: (left, right) => left > right,
|
|
1969
|
+
lt: (left, right) => left < right
|
|
1970
|
+
};
|
|
1971
|
+
function evaluateNumericOperator(criteria, matchValue) {
|
|
1972
|
+
const { op, value } = criteria;
|
|
1973
|
+
const evaluator = numericOperatorEvaluators[op];
|
|
1974
|
+
if (!evaluator) {
|
|
1975
|
+
return null;
|
|
1976
|
+
}
|
|
1977
|
+
if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
const leftNum = Number(matchValue);
|
|
1981
|
+
const rightNum = Number(value);
|
|
1982
|
+
if (isNaN(leftNum) || isNaN(rightNum)) {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
return evaluator(leftNum, rightNum);
|
|
1986
|
+
}
|
|
2422
1987
|
function evaluateStringMatch(criteria, matchValue, allow) {
|
|
2423
1988
|
const { op, value } = criteria;
|
|
2424
1989
|
if (allow && !allow.has(op)) {
|
|
2425
1990
|
return null;
|
|
2426
1991
|
}
|
|
1992
|
+
if (op in numericOperatorEvaluators) {
|
|
1993
|
+
return evaluateNumericOperator(criteria, matchValue);
|
|
1994
|
+
}
|
|
2427
1995
|
let opMatch = op;
|
|
2428
1996
|
const negation = op.startsWith("!");
|
|
2429
1997
|
if (negation) {
|
|
@@ -2472,17 +2040,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
|
|
|
2472
2040
|
"endswith",
|
|
2473
2041
|
"!endswith",
|
|
2474
2042
|
"empty",
|
|
2475
|
-
"!empty"
|
|
2043
|
+
"!empty",
|
|
2044
|
+
"gt",
|
|
2045
|
+
"lt"
|
|
2476
2046
|
]);
|
|
2477
2047
|
var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
|
|
2048
|
+
function toStringValue(value) {
|
|
2049
|
+
if (typeof value === "string") {
|
|
2050
|
+
return value;
|
|
2051
|
+
}
|
|
2052
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
2053
|
+
return String(value);
|
|
2054
|
+
}
|
|
2055
|
+
return "";
|
|
2056
|
+
}
|
|
2057
|
+
function toStringCriteriaValue(value) {
|
|
2058
|
+
if (Array.isArray(value)) {
|
|
2059
|
+
return value.map((v) => toStringValue(v));
|
|
2060
|
+
}
|
|
2061
|
+
return toStringValue(value);
|
|
2062
|
+
}
|
|
2063
|
+
function isUnbound(value) {
|
|
2064
|
+
if (value === void 0 || value === null) {
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
if (typeof value === "string") {
|
|
2068
|
+
return hasReferencedVariables(value) > 0;
|
|
2069
|
+
}
|
|
2070
|
+
return false;
|
|
2071
|
+
}
|
|
2478
2072
|
function createDynamicTokenVisibilityRule() {
|
|
2479
2073
|
return {
|
|
2480
2074
|
[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
|
|
2481
|
-
|
|
2482
|
-
if (
|
|
2075
|
+
const { source, value } = criterion;
|
|
2076
|
+
if (isUnbound(source)) {
|
|
2483
2077
|
return null;
|
|
2484
2078
|
}
|
|
2485
|
-
|
|
2079
|
+
const stringSource = toStringValue(source);
|
|
2080
|
+
const stringValue = toStringCriteriaValue(value);
|
|
2081
|
+
const stringCriterion = {
|
|
2082
|
+
...criterion,
|
|
2083
|
+
value: stringValue
|
|
2084
|
+
};
|
|
2085
|
+
return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
|
|
2486
2086
|
}
|
|
2487
2087
|
};
|
|
2488
2088
|
}
|
|
@@ -2541,8 +2141,7 @@ function extractLocales({ component }) {
|
|
|
2541
2141
|
return variations;
|
|
2542
2142
|
}
|
|
2543
2143
|
function localize(options) {
|
|
2544
|
-
const nodes = options
|
|
2545
|
-
const locale = options.locale;
|
|
2144
|
+
const { nodes, locale, keepLocalesFor } = options;
|
|
2546
2145
|
if (!locale) {
|
|
2547
2146
|
return;
|
|
2548
2147
|
}
|
|
@@ -2550,7 +2149,7 @@ function localize(options) {
|
|
|
2550
2149
|
walkNodeTree(nodes, (context) => {
|
|
2551
2150
|
const { type, node, actions } = context;
|
|
2552
2151
|
if (type !== "component") {
|
|
2553
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2152
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2554
2153
|
return;
|
|
2555
2154
|
}
|
|
2556
2155
|
const result = evaluateWalkTreeNodeVisibility({
|
|
@@ -2571,7 +2170,7 @@ function localize(options) {
|
|
|
2571
2170
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
|
2572
2171
|
replaceComponent.forEach((component) => {
|
|
2573
2172
|
removeLocaleProperty(component);
|
|
2574
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
|
2173
|
+
localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2575
2174
|
});
|
|
2576
2175
|
const [first, ...rest] = replaceComponent;
|
|
2577
2176
|
actions.replace(first);
|
|
@@ -2582,7 +2181,7 @@ function localize(options) {
|
|
|
2582
2181
|
actions.remove();
|
|
2583
2182
|
}
|
|
2584
2183
|
} else {
|
|
2585
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2184
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2586
2185
|
}
|
|
2587
2186
|
});
|
|
2588
2187
|
}
|
|
@@ -2601,7 +2200,7 @@ function removeLocaleProperty(component) {
|
|
|
2601
2200
|
}
|
|
2602
2201
|
}
|
|
2603
2202
|
}
|
|
2604
|
-
function localizeProperties(node, locale, rules) {
|
|
2203
|
+
function localizeProperties(node, locale, rules, keepLocalesFor) {
|
|
2605
2204
|
const properties = getPropertiesValue(node);
|
|
2606
2205
|
if (!properties) {
|
|
2607
2206
|
return void 0;
|
|
@@ -2620,10 +2219,16 @@ function localizeProperties(node, locale, rules) {
|
|
|
2620
2219
|
if (currentLocaleConditionalValues !== void 0) {
|
|
2621
2220
|
propertyValue.conditions = currentLocaleConditionalValues;
|
|
2622
2221
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2222
|
+
const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
|
|
2223
|
+
if (!preserveLocales) {
|
|
2224
|
+
delete propertyValue.locales;
|
|
2225
|
+
delete propertyValue.localesConditions;
|
|
2226
|
+
}
|
|
2625
2227
|
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
|
2626
|
-
|
|
2228
|
+
const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
|
|
2229
|
+
if (!hasLocales) {
|
|
2230
|
+
delete properties[propertyId];
|
|
2231
|
+
}
|
|
2627
2232
|
}
|
|
2628
2233
|
});
|
|
2629
2234
|
evaluateWalkTreePropertyCriteria({
|
|
@@ -2750,10 +2355,47 @@ _baseUrl = new WeakMap();
|
|
|
2750
2355
|
__privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
2751
2356
|
var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
|
|
2752
2357
|
|
|
2753
|
-
// src/
|
|
2358
|
+
// src/LabelClient.ts
|
|
2754
2359
|
var import_api9 = require("@uniformdev/context/api");
|
|
2360
|
+
var LABELS_URL = "/api/v1/labels";
|
|
2361
|
+
var LabelClient = class extends import_api9.ApiClient {
|
|
2362
|
+
/** Fetches labels for the current project. */
|
|
2363
|
+
async getLabels(options) {
|
|
2364
|
+
const { projectId } = this.options;
|
|
2365
|
+
const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
|
|
2366
|
+
return await this.apiClient(fetchUri);
|
|
2367
|
+
}
|
|
2368
|
+
/** Updates or creates a label. */
|
|
2369
|
+
async upsertLabel(body) {
|
|
2370
|
+
const { projectId } = this.options;
|
|
2371
|
+
const fetchUri = this.createUrl(LABELS_URL);
|
|
2372
|
+
await this.apiClient(fetchUri, {
|
|
2373
|
+
method: "PUT",
|
|
2374
|
+
body: JSON.stringify({ ...body, projectId }),
|
|
2375
|
+
expectNoContent: true
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
/** Deletes a label by id. */
|
|
2379
|
+
async removeLabel(options) {
|
|
2380
|
+
const { projectId } = this.options;
|
|
2381
|
+
const fetchUri = this.createUrl(LABELS_URL);
|
|
2382
|
+
await this.apiClient(fetchUri, {
|
|
2383
|
+
method: "DELETE",
|
|
2384
|
+
body: JSON.stringify({ ...options, projectId }),
|
|
2385
|
+
expectNoContent: true
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
};
|
|
2389
|
+
var UncachedLabelClient = class extends LabelClient {
|
|
2390
|
+
constructor(options) {
|
|
2391
|
+
super({ ...options, bypassCache: true });
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
|
|
2395
|
+
// src/LocaleClient.ts
|
|
2396
|
+
var import_api10 = require("@uniformdev/context/api");
|
|
2755
2397
|
var localesUrl = "/api/v1/locales";
|
|
2756
|
-
var LocaleClient = class extends
|
|
2398
|
+
var LocaleClient = class extends import_api10.ApiClient {
|
|
2757
2399
|
constructor(options) {
|
|
2758
2400
|
super(options);
|
|
2759
2401
|
}
|
|
@@ -2808,6 +2450,12 @@ var isSelectComponentMessage = (message) => {
|
|
|
2808
2450
|
var isReadyMessage = (message) => {
|
|
2809
2451
|
return message.type === "ready";
|
|
2810
2452
|
};
|
|
2453
|
+
var isSessionPendingMessage = (message) => {
|
|
2454
|
+
return message.type === "session-pending";
|
|
2455
|
+
};
|
|
2456
|
+
var isAwaitingReadyMessage = (message) => {
|
|
2457
|
+
return message.type === "awaiting-ready";
|
|
2458
|
+
};
|
|
2811
2459
|
var isComponentActionMessage = (message) => {
|
|
2812
2460
|
return message.type === "trigger-component-action";
|
|
2813
2461
|
};
|
|
@@ -2910,6 +2558,14 @@ var createCanvasChannel = ({
|
|
|
2910
2558
|
};
|
|
2911
2559
|
postMessage(message);
|
|
2912
2560
|
};
|
|
2561
|
+
const sessionPending = () => {
|
|
2562
|
+
const message = { type: "session-pending" };
|
|
2563
|
+
postMessage(message);
|
|
2564
|
+
};
|
|
2565
|
+
const awaitingReady = () => {
|
|
2566
|
+
const message = { type: "awaiting-ready" };
|
|
2567
|
+
postMessage(message);
|
|
2568
|
+
};
|
|
2913
2569
|
const on = (types, handler) => {
|
|
2914
2570
|
const handlerId = ++handlerCounter;
|
|
2915
2571
|
handlers[handlerId] = {
|
|
@@ -3109,6 +2765,8 @@ var createCanvasChannel = ({
|
|
|
3109
2765
|
return {
|
|
3110
2766
|
broadcastTo: broadcastToItems,
|
|
3111
2767
|
ready,
|
|
2768
|
+
sessionPending,
|
|
2769
|
+
awaitingReady,
|
|
3112
2770
|
destroy,
|
|
3113
2771
|
addBroadcastTarget,
|
|
3114
2772
|
triggerComponentAction,
|
|
@@ -3139,10 +2797,10 @@ var createCanvasChannel = ({
|
|
|
3139
2797
|
};
|
|
3140
2798
|
|
|
3141
2799
|
// src/PreviewClient.ts
|
|
3142
|
-
var
|
|
2800
|
+
var import_api11 = require("@uniformdev/context/api");
|
|
3143
2801
|
var previewUrlsUrl = "/api/v1/preview-urls";
|
|
3144
2802
|
var previewViewportsUrl = "/api/v1/preview-viewports";
|
|
3145
|
-
var PreviewClient = class extends
|
|
2803
|
+
var PreviewClient = class extends import_api11.ApiClient {
|
|
3146
2804
|
constructor(options) {
|
|
3147
2805
|
super(options);
|
|
3148
2806
|
}
|
|
@@ -3205,9 +2863,9 @@ var PreviewClient = class extends import_api10.ApiClient {
|
|
|
3205
2863
|
};
|
|
3206
2864
|
|
|
3207
2865
|
// src/ProjectClient.ts
|
|
3208
|
-
var
|
|
3209
|
-
var _url2;
|
|
3210
|
-
var _ProjectClient = class _ProjectClient extends
|
|
2866
|
+
var import_api12 = require("@uniformdev/context/api");
|
|
2867
|
+
var _url2, _projectsUrl;
|
|
2868
|
+
var _ProjectClient = class _ProjectClient extends import_api12.ApiClient {
|
|
3211
2869
|
constructor(options) {
|
|
3212
2870
|
super({ ...options, bypassCache: true });
|
|
3213
2871
|
}
|
|
@@ -3216,6 +2874,15 @@ var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
|
|
|
3216
2874
|
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2), { ...options });
|
|
3217
2875
|
return await this.apiClient(fetchUri);
|
|
3218
2876
|
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Fetches projects grouped by team.
|
|
2879
|
+
* When teamId is provided, returns a single team with its projects.
|
|
2880
|
+
* When omitted, returns all accessible teams and their projects.
|
|
2881
|
+
*/
|
|
2882
|
+
async getProjects(options) {
|
|
2883
|
+
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
|
|
2884
|
+
return await this.apiClient(fetchUri);
|
|
2885
|
+
}
|
|
3219
2886
|
/** Updates or creates (based on id) a Project */
|
|
3220
2887
|
async upsert(body) {
|
|
3221
2888
|
const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
|
|
@@ -3235,13 +2902,197 @@ var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
|
|
|
3235
2902
|
}
|
|
3236
2903
|
};
|
|
3237
2904
|
_url2 = new WeakMap();
|
|
2905
|
+
_projectsUrl = new WeakMap();
|
|
3238
2906
|
__privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
2907
|
+
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
3239
2908
|
var ProjectClient = _ProjectClient;
|
|
3240
2909
|
|
|
2910
|
+
// src/projection/matchesProjectionPattern.ts
|
|
2911
|
+
var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
|
|
2912
|
+
var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
|
|
2913
|
+
function isValidProjectionPattern(pattern) {
|
|
2914
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
2915
|
+
return false;
|
|
2916
|
+
}
|
|
2917
|
+
if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
|
|
2918
|
+
return false;
|
|
2919
|
+
}
|
|
2920
|
+
return true;
|
|
2921
|
+
}
|
|
2922
|
+
function compilePattern(pattern) {
|
|
2923
|
+
let regexSource = "^";
|
|
2924
|
+
for (const ch of pattern) {
|
|
2925
|
+
if (ch === "*") {
|
|
2926
|
+
regexSource += ".*";
|
|
2927
|
+
} else {
|
|
2928
|
+
regexSource += ch.replace(REGEX_METACHAR, "\\$&");
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
regexSource += "$";
|
|
2932
|
+
return new RegExp(regexSource);
|
|
2933
|
+
}
|
|
2934
|
+
var PATTERN_CACHE_MAX = 1024;
|
|
2935
|
+
var patternRegexCache = /* @__PURE__ */ new Map();
|
|
2936
|
+
function matchesProjectionPattern(pattern, value) {
|
|
2937
|
+
let re = patternRegexCache.get(pattern);
|
|
2938
|
+
if (re === void 0) {
|
|
2939
|
+
if (!isValidProjectionPattern(pattern)) {
|
|
2940
|
+
throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
|
|
2941
|
+
}
|
|
2942
|
+
re = compilePattern(pattern);
|
|
2943
|
+
if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
|
|
2944
|
+
const oldest = patternRegexCache.keys().next().value;
|
|
2945
|
+
if (oldest !== void 0) patternRegexCache.delete(oldest);
|
|
2946
|
+
}
|
|
2947
|
+
patternRegexCache.set(pattern, re);
|
|
2948
|
+
}
|
|
2949
|
+
return re.test(value);
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
// src/projection/queryToProjection.ts
|
|
2953
|
+
var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
|
|
2954
|
+
var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
|
|
2955
|
+
function toStringValue2(value) {
|
|
2956
|
+
if (Array.isArray(value)) {
|
|
2957
|
+
return value.join(",");
|
|
2958
|
+
}
|
|
2959
|
+
return value;
|
|
2960
|
+
}
|
|
2961
|
+
function parseCsv(value) {
|
|
2962
|
+
const str = toStringValue2(value);
|
|
2963
|
+
if (!str) {
|
|
2964
|
+
return [];
|
|
2965
|
+
}
|
|
2966
|
+
return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
2967
|
+
}
|
|
2968
|
+
function parseDepth(value, key) {
|
|
2969
|
+
const str = toStringValue2(value);
|
|
2970
|
+
if (str === void 0 || str === "") {
|
|
2971
|
+
throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
|
|
2972
|
+
}
|
|
2973
|
+
if (!/^\d+$/.test(str)) {
|
|
2974
|
+
throw new Error(
|
|
2975
|
+
`Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
|
|
2976
|
+
);
|
|
2977
|
+
}
|
|
2978
|
+
return Number(str);
|
|
2979
|
+
}
|
|
2980
|
+
function parseBlockDepth(value, key) {
|
|
2981
|
+
const str = toStringValue2(value);
|
|
2982
|
+
if (str === "preserveAll") {
|
|
2983
|
+
return "preserveAll";
|
|
2984
|
+
}
|
|
2985
|
+
if (str === void 0 || str === "" || !/^\d+$/.test(str)) {
|
|
2986
|
+
throw new Error(
|
|
2987
|
+
`Invalid select projection: '${key}' must be a non-negative integer or 'preserveAll' (got ${JSON.stringify(str)})`
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
return Number(str);
|
|
2991
|
+
}
|
|
2992
|
+
function extractSelectKeys(source) {
|
|
2993
|
+
if (source instanceof URLSearchParams) {
|
|
2994
|
+
let out2;
|
|
2995
|
+
for (const [key, value] of source.entries()) {
|
|
2996
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
2997
|
+
out2 != null ? out2 : out2 = {};
|
|
2998
|
+
out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
|
|
2999
|
+
}
|
|
3000
|
+
return out2;
|
|
3001
|
+
}
|
|
3002
|
+
let out;
|
|
3003
|
+
for (const key in source) {
|
|
3004
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3005
|
+
out != null ? out : out = {};
|
|
3006
|
+
out[key] = source[key];
|
|
3007
|
+
}
|
|
3008
|
+
return out;
|
|
3009
|
+
}
|
|
3010
|
+
function queryToProjection(source) {
|
|
3011
|
+
var _a, _b, _c, _d, _e;
|
|
3012
|
+
if (!source) {
|
|
3013
|
+
return void 0;
|
|
3014
|
+
}
|
|
3015
|
+
const query = extractSelectKeys(source);
|
|
3016
|
+
if (!query) {
|
|
3017
|
+
return void 0;
|
|
3018
|
+
}
|
|
3019
|
+
const spec = {};
|
|
3020
|
+
for (const [rawKey, value] of Object.entries(query)) {
|
|
3021
|
+
const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
|
|
3022
|
+
const namedMatch = SLOTS_NAMED_KEY.exec(key);
|
|
3023
|
+
if (namedMatch) {
|
|
3024
|
+
const [, slotName, operator2] = namedMatch;
|
|
3025
|
+
if (operator2 !== "depth") {
|
|
3026
|
+
throw new Error(
|
|
3027
|
+
`Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
|
|
3031
|
+
const named = (_b = slots.named) != null ? _b : slots.named = {};
|
|
3032
|
+
named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
|
|
3033
|
+
continue;
|
|
3034
|
+
}
|
|
3035
|
+
const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
|
|
3036
|
+
if (!topMatch) {
|
|
3037
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3038
|
+
}
|
|
3039
|
+
const [, bucket, operator] = topMatch;
|
|
3040
|
+
if (bucket === "fields") {
|
|
3041
|
+
const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
|
|
3042
|
+
switch (operator) {
|
|
3043
|
+
case "only":
|
|
3044
|
+
fields.only = parseCsv(value);
|
|
3045
|
+
break;
|
|
3046
|
+
case "except":
|
|
3047
|
+
fields.except = parseCsv(value);
|
|
3048
|
+
break;
|
|
3049
|
+
case "locales":
|
|
3050
|
+
fields.locales = parseCsv(value);
|
|
3051
|
+
break;
|
|
3052
|
+
case "blockDepth":
|
|
3053
|
+
fields.blockDepth = parseBlockDepth(value, rawKey);
|
|
3054
|
+
break;
|
|
3055
|
+
default:
|
|
3056
|
+
throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
|
|
3057
|
+
}
|
|
3058
|
+
} else if (bucket === "fieldTypes") {
|
|
3059
|
+
const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
|
|
3060
|
+
switch (operator) {
|
|
3061
|
+
case "only":
|
|
3062
|
+
fieldTypes.only = parseCsv(value);
|
|
3063
|
+
break;
|
|
3064
|
+
case "except":
|
|
3065
|
+
fieldTypes.except = parseCsv(value);
|
|
3066
|
+
break;
|
|
3067
|
+
default:
|
|
3068
|
+
throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
|
|
3069
|
+
}
|
|
3070
|
+
} else if (bucket === "slots") {
|
|
3071
|
+
const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
|
|
3072
|
+
switch (operator) {
|
|
3073
|
+
case "only":
|
|
3074
|
+
slots.only = parseCsv(value);
|
|
3075
|
+
break;
|
|
3076
|
+
case "except":
|
|
3077
|
+
slots.except = parseCsv(value);
|
|
3078
|
+
break;
|
|
3079
|
+
case "depth":
|
|
3080
|
+
slots.depth = parseDepth(value, rawKey);
|
|
3081
|
+
break;
|
|
3082
|
+
default:
|
|
3083
|
+
throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
|
|
3084
|
+
}
|
|
3085
|
+
} else {
|
|
3086
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
return spec;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3241
3092
|
// src/PromptClient.ts
|
|
3242
|
-
var
|
|
3093
|
+
var import_api13 = require("@uniformdev/context/api");
|
|
3243
3094
|
var PromptsUrl = "/api/v1/prompts";
|
|
3244
|
-
var PromptClient = class extends
|
|
3095
|
+
var PromptClient = class extends import_api13.ApiClient {
|
|
3245
3096
|
constructor(options) {
|
|
3246
3097
|
super(options);
|
|
3247
3098
|
}
|
|
@@ -3272,9 +3123,9 @@ var PromptClient = class extends import_api12.ApiClient {
|
|
|
3272
3123
|
};
|
|
3273
3124
|
|
|
3274
3125
|
// src/RelationshipClient.ts
|
|
3275
|
-
var
|
|
3126
|
+
var import_api14 = require("@uniformdev/context/api");
|
|
3276
3127
|
var RELATIONSHIPS_URL = "/api/v1/relationships";
|
|
3277
|
-
var RelationshipClient = class extends
|
|
3128
|
+
var RelationshipClient = class extends import_api14.ApiClient {
|
|
3278
3129
|
constructor(options) {
|
|
3279
3130
|
super(options);
|
|
3280
3131
|
this.get = async (options) => {
|
|
@@ -3286,9 +3137,9 @@ var RelationshipClient = class extends import_api13.ApiClient {
|
|
|
3286
3137
|
};
|
|
3287
3138
|
|
|
3288
3139
|
// src/ReleaseClient.ts
|
|
3289
|
-
var
|
|
3140
|
+
var import_api15 = require("@uniformdev/context/api");
|
|
3290
3141
|
var releasesUrl = "/api/v1/releases";
|
|
3291
|
-
var ReleaseClient = class extends
|
|
3142
|
+
var ReleaseClient = class extends import_api15.ApiClient {
|
|
3292
3143
|
constructor(options) {
|
|
3293
3144
|
super(options);
|
|
3294
3145
|
}
|
|
@@ -3328,9 +3179,9 @@ var ReleaseClient = class extends import_api14.ApiClient {
|
|
|
3328
3179
|
};
|
|
3329
3180
|
|
|
3330
3181
|
// src/ReleaseContentsClient.ts
|
|
3331
|
-
var
|
|
3182
|
+
var import_api16 = require("@uniformdev/context/api");
|
|
3332
3183
|
var releaseContentsUrl2 = "/api/v1/release-contents";
|
|
3333
|
-
var ReleaseContentsClient = class extends
|
|
3184
|
+
var ReleaseContentsClient = class extends import_api16.ApiClient {
|
|
3334
3185
|
constructor(options) {
|
|
3335
3186
|
super(options);
|
|
3336
3187
|
}
|
|
@@ -3352,9 +3203,9 @@ var ReleaseContentsClient = class extends import_api15.ApiClient {
|
|
|
3352
3203
|
};
|
|
3353
3204
|
|
|
3354
3205
|
// src/RouteClient.ts
|
|
3355
|
-
var
|
|
3206
|
+
var import_api17 = require("@uniformdev/context/api");
|
|
3356
3207
|
var ROUTE_URL = "/api/v1/route";
|
|
3357
|
-
var RouteClient = class extends
|
|
3208
|
+
var RouteClient = class extends import_api17.ApiClient {
|
|
3358
3209
|
constructor(options) {
|
|
3359
3210
|
var _a;
|
|
3360
3211
|
if (!options.limitPolicy) {
|
|
@@ -3366,7 +3217,9 @@ var RouteClient = class extends import_api16.ApiClient {
|
|
|
3366
3217
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
3367
3218
|
async getRoute(options) {
|
|
3368
3219
|
const { projectId } = this.options;
|
|
3369
|
-
const
|
|
3220
|
+
const { select, ...rest } = options != null ? options : {};
|
|
3221
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
3222
|
+
const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
|
|
3370
3223
|
return await this.apiClient(
|
|
3371
3224
|
fetchUri,
|
|
3372
3225
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
@@ -3530,7 +3383,9 @@ var getParameterAttributes = ({
|
|
|
3530
3383
|
|
|
3531
3384
|
// src/utils/isAllowedReferrer.ts
|
|
3532
3385
|
var isAllowedReferrer = (referrer) => {
|
|
3533
|
-
return Boolean(
|
|
3386
|
+
return Boolean(
|
|
3387
|
+
referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
|
|
3388
|
+
);
|
|
3534
3389
|
};
|
|
3535
3390
|
|
|
3536
3391
|
// src/utils/isSystemComponentDefinition.ts
|
|
@@ -3726,15 +3581,15 @@ function handleRichTextNodeBinding(object, options) {
|
|
|
3726
3581
|
}
|
|
3727
3582
|
|
|
3728
3583
|
// src/index.ts
|
|
3729
|
-
var
|
|
3584
|
+
var import_api19 = require("@uniformdev/context/api");
|
|
3730
3585
|
|
|
3731
3586
|
// src/.version.ts
|
|
3732
|
-
var version = "20.
|
|
3587
|
+
var version = "20.74.3";
|
|
3733
3588
|
|
|
3734
3589
|
// src/WorkflowClient.ts
|
|
3735
|
-
var
|
|
3590
|
+
var import_api18 = require("@uniformdev/context/api");
|
|
3736
3591
|
var workflowsUrl = "/api/v1/workflows";
|
|
3737
|
-
var WorkflowClient = class extends
|
|
3592
|
+
var WorkflowClient = class extends import_api18.ApiClient {
|
|
3738
3593
|
constructor(options) {
|
|
3739
3594
|
super(options);
|
|
3740
3595
|
}
|
|
@@ -3765,7 +3620,7 @@ var WorkflowClient = class extends import_api17.ApiClient {
|
|
|
3765
3620
|
};
|
|
3766
3621
|
|
|
3767
3622
|
// src/index.ts
|
|
3768
|
-
var CanvasClientError =
|
|
3623
|
+
var CanvasClientError = import_api19.ApiClientError;
|
|
3769
3624
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3770
3625
|
0 && (module.exports = {
|
|
3771
3626
|
ASSETS_SOURCE_CUSTOM_URL,
|
|
@@ -3839,19 +3694,23 @@ var CanvasClientError = import_api18.ApiClientError;
|
|
|
3839
3694
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
|
3840
3695
|
IntegrationPropertyEditorsClient,
|
|
3841
3696
|
LOCALE_DYNAMIC_INPUT_NAME,
|
|
3697
|
+
LabelClient,
|
|
3842
3698
|
LocaleClient,
|
|
3843
3699
|
PLACEHOLDER_ID,
|
|
3844
3700
|
PreviewClient,
|
|
3845
3701
|
ProjectClient,
|
|
3846
3702
|
PromptClient,
|
|
3703
|
+
REFERENCE_DATA_TYPE_ID,
|
|
3847
3704
|
RelationshipClient,
|
|
3848
3705
|
ReleaseClient,
|
|
3849
3706
|
ReleaseContentsClient,
|
|
3850
3707
|
RouteClient,
|
|
3851
3708
|
SECRET_QUERY_STRING_PARAM,
|
|
3709
|
+
SELECT_QUERY_PREFIX,
|
|
3852
3710
|
UncachedCanvasClient,
|
|
3853
3711
|
UncachedCategoryClient,
|
|
3854
3712
|
UncachedContentClient,
|
|
3713
|
+
UncachedLabelClient,
|
|
3855
3714
|
UniqueBatchEntries,
|
|
3856
3715
|
WorkflowClient,
|
|
3857
3716
|
autoFixParameterGroups,
|
|
@@ -3898,6 +3757,7 @@ var CanvasClientError = import_api18.ApiClientError;
|
|
|
3898
3757
|
isAllowedReferrer,
|
|
3899
3758
|
isAssetParamValue,
|
|
3900
3759
|
isAssetParamValueItem,
|
|
3760
|
+
isAwaitingReadyMessage,
|
|
3901
3761
|
isComponentActionMessage,
|
|
3902
3762
|
isComponentPlaceholderId,
|
|
3903
3763
|
isContextStorageUpdatedMessage,
|
|
@@ -3913,6 +3773,7 @@ var CanvasClientError = import_api18.ApiClientError;
|
|
|
3913
3773
|
isRootEntryReference,
|
|
3914
3774
|
isSelectComponentMessage,
|
|
3915
3775
|
isSelectParameterMessage,
|
|
3776
|
+
isSessionPendingMessage,
|
|
3916
3777
|
isSuggestComponentMessage,
|
|
3917
3778
|
isSystemComponentDefinition,
|
|
3918
3779
|
isTriggerCompositionActionMessage,
|
|
@@ -3927,10 +3788,13 @@ var CanvasClientError = import_api18.ApiClientError;
|
|
|
3927
3788
|
localize,
|
|
3928
3789
|
mapSlotToPersonalizedVariations,
|
|
3929
3790
|
mapSlotToTestVariations,
|
|
3791
|
+
matchesProjectionPattern,
|
|
3930
3792
|
mergeAssetConfigWithDefaults,
|
|
3931
3793
|
nullLimitPolicy,
|
|
3932
3794
|
parseComponentPlaceholderId,
|
|
3933
3795
|
parseVariableExpression,
|
|
3796
|
+
projectionToQuery,
|
|
3797
|
+
queryToProjection,
|
|
3934
3798
|
version,
|
|
3935
3799
|
walkNodeTree,
|
|
3936
3800
|
walkPropertyValues
|