@uniformdev/next-app-router 20.7.1-alpha.118

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.
@@ -0,0 +1,1397 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
34
+ var require_yocto_queue = __commonJS({
35
+ "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
36
+ "use strict";
37
+ var Node = class {
38
+ /// value;
39
+ /// next;
40
+ constructor(value) {
41
+ this.value = value;
42
+ this.next = void 0;
43
+ }
44
+ };
45
+ var Queue = class {
46
+ // TODO: Use private class fields when targeting Node.js 12.
47
+ // #_head;
48
+ // #_tail;
49
+ // #_size;
50
+ constructor() {
51
+ this.clear();
52
+ }
53
+ enqueue(value) {
54
+ const node = new Node(value);
55
+ if (this._head) {
56
+ this._tail.next = node;
57
+ this._tail = node;
58
+ } else {
59
+ this._head = node;
60
+ this._tail = node;
61
+ }
62
+ this._size++;
63
+ }
64
+ dequeue() {
65
+ const current = this._head;
66
+ if (!current) {
67
+ return;
68
+ }
69
+ this._head = this._head.next;
70
+ this._size--;
71
+ return current.value;
72
+ }
73
+ clear() {
74
+ this._head = void 0;
75
+ this._tail = void 0;
76
+ this._size = 0;
77
+ }
78
+ get size() {
79
+ return this._size;
80
+ }
81
+ *[Symbol.iterator]() {
82
+ let current = this._head;
83
+ while (current) {
84
+ yield current.value;
85
+ current = current.next;
86
+ }
87
+ }
88
+ };
89
+ module2.exports = Queue;
90
+ }
91
+ });
92
+
93
+ // ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
94
+ var require_p_limit = __commonJS({
95
+ "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
96
+ "use strict";
97
+ var Queue = require_yocto_queue();
98
+ var pLimit2 = (concurrency) => {
99
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
100
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
101
+ }
102
+ const queue = new Queue();
103
+ let activeCount = 0;
104
+ const next = () => {
105
+ activeCount--;
106
+ if (queue.size > 0) {
107
+ queue.dequeue()();
108
+ }
109
+ };
110
+ const run = async (fn, resolve, ...args) => {
111
+ activeCount++;
112
+ const result = (async () => fn(...args))();
113
+ resolve(result);
114
+ try {
115
+ await result;
116
+ } catch (e) {
117
+ }
118
+ next();
119
+ };
120
+ const enqueue = (fn, resolve, ...args) => {
121
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
122
+ (async () => {
123
+ await Promise.resolve();
124
+ if (activeCount < concurrency && queue.size > 0) {
125
+ queue.dequeue()();
126
+ }
127
+ })();
128
+ };
129
+ const generator = (fn, ...args) => new Promise((resolve) => {
130
+ enqueue(fn, resolve, ...args);
131
+ });
132
+ Object.defineProperties(generator, {
133
+ activeCount: {
134
+ get: () => activeCount
135
+ },
136
+ pendingCount: {
137
+ get: () => queue.size
138
+ },
139
+ clearQueue: {
140
+ value: () => {
141
+ queue.clear();
142
+ }
143
+ }
144
+ });
145
+ return generator;
146
+ };
147
+ module2.exports = pLimit2;
148
+ }
149
+ });
150
+
151
+ // src/component.ts
152
+ var component_exports = {};
153
+ __export(component_exports, {
154
+ UniformRichText: () => UniformRichText,
155
+ UniformSlot: () => UniformSlot,
156
+ UniformText: () => UniformText,
157
+ createClientUniformContext: () => import_next_app_router_client2.createClientUniformContext,
158
+ getUniformSlot: () => getUniformSlot,
159
+ useInitUniformContext: () => import_next_app_router_client2.useInitUniformContext,
160
+ useQuirks: () => import_next_app_router_client2.useQuirks,
161
+ useScores: () => import_next_app_router_client2.useScores,
162
+ useUniformContext: () => import_next_app_router_client2.useUniformContext
163
+ });
164
+ module.exports = __toCommonJS(component_exports);
165
+
166
+ // src/components/getUniformSlot.ts
167
+ var getUniformSlot = ({ slot, children }) => {
168
+ const resolved = [];
169
+ if (slot) {
170
+ for (let i = 0; i < slot.items.length; i++) {
171
+ const child = slot.items[i];
172
+ if (!child) continue;
173
+ if (!children) {
174
+ resolved.push(child.component);
175
+ } else {
176
+ const result = children({
177
+ child: child.component,
178
+ _id: child._id,
179
+ key: `inner-${i}`,
180
+ slotName: slot.name,
181
+ slotIndex: i
182
+ });
183
+ resolved.push(result);
184
+ }
185
+ }
186
+ }
187
+ return resolved.length > 0 ? resolved : void 0;
188
+ };
189
+
190
+ // src/components/UniformSlot.tsx
191
+ var UniformSlot = ({ slot, children }) => {
192
+ const resolved = [];
193
+ if (slot) {
194
+ for (let i = 0; i < slot.items.length; i++) {
195
+ const child = slot.items[i];
196
+ if (!children) {
197
+ resolved.push(child.component);
198
+ } else {
199
+ const result = children({
200
+ child: child.component,
201
+ _id: child._id,
202
+ key: `inner-${i}`,
203
+ slotName: slot.name,
204
+ slotIndex: i
205
+ });
206
+ resolved.push(result);
207
+ }
208
+ }
209
+ }
210
+ return resolved.length > 0 ? resolved : null;
211
+ };
212
+
213
+ // src/component.ts
214
+ var import_next_app_router_client2 = require("@uniformdev/next-app-router-client");
215
+
216
+ // ../context/dist/api/api.mjs
217
+ var import_p_limit = __toESM(require_p_limit(), 1);
218
+ var __defProp2 = Object.defineProperty;
219
+ var __typeError = (msg) => {
220
+ throw TypeError(msg);
221
+ };
222
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
223
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
224
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
225
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
226
+ 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);
227
+ var defaultLimitPolicy = (0, import_p_limit.default)(6);
228
+ var ApiClientError = class _ApiClientError extends Error {
229
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
230
+ super(
231
+ `${errorMessage}
232
+ ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
233
+ );
234
+ this.errorMessage = errorMessage;
235
+ this.fetchMethod = fetchMethod;
236
+ this.fetchUri = fetchUri;
237
+ this.statusCode = statusCode;
238
+ this.statusText = statusText;
239
+ this.requestId = requestId;
240
+ Object.setPrototypeOf(this, _ApiClientError.prototype);
241
+ }
242
+ };
243
+ var ApiClient = class _ApiClient {
244
+ constructor(options) {
245
+ __publicField(this, "options");
246
+ var _a, _b, _c, _d, _e;
247
+ if (!options.apiKey && !options.bearerToken) {
248
+ throw new Error("You must provide an API key or a bearer token");
249
+ }
250
+ let leFetch = options.fetch;
251
+ if (!leFetch) {
252
+ if (typeof window !== "undefined") {
253
+ leFetch = window.fetch.bind(window);
254
+ } else if (typeof fetch !== "undefined") {
255
+ leFetch = fetch;
256
+ } else {
257
+ throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
258
+ }
259
+ }
260
+ this.options = {
261
+ ...options,
262
+ fetch: leFetch,
263
+ apiHost: this.ensureApiHost(options.apiHost),
264
+ apiKey: (_a = options.apiKey) != null ? _a : null,
265
+ projectId: (_b = options.projectId) != null ? _b : null,
266
+ bearerToken: (_c = options.bearerToken) != null ? _c : null,
267
+ limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
268
+ bypassCache: (_e = options.bypassCache) != null ? _e : false
269
+ };
270
+ }
271
+ async apiClient(fetchUri, options) {
272
+ return (await this.apiClientWithResponse(fetchUri, options)).body;
273
+ }
274
+ async apiClientWithResponse(fetchUri, options) {
275
+ return this.options.limitPolicy(async () => {
276
+ var _a;
277
+ const coreHeaders = this.options.apiKey ? {
278
+ "x-api-key": this.options.apiKey
279
+ } : {
280
+ Authorization: `Bearer ${this.options.bearerToken}`
281
+ };
282
+ if (this.options.bypassCache) {
283
+ coreHeaders["x-bypass-cache"] = "true";
284
+ }
285
+ const { fetch: fetch2, signal } = this.options;
286
+ const callApi = () => fetch2(fetchUri.toString(), {
287
+ ...options,
288
+ signal,
289
+ headers: {
290
+ ...options == null ? void 0 : options.headers,
291
+ ...coreHeaders
292
+ }
293
+ });
294
+ const apiResponse = await handleRateLimits(callApi);
295
+ if (!apiResponse.ok) {
296
+ let message = "";
297
+ try {
298
+ const responseText = await apiResponse.text();
299
+ try {
300
+ const parsed = JSON.parse(responseText);
301
+ if (parsed.errorMessage) {
302
+ message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
303
+ } else {
304
+ message = responseText;
305
+ }
306
+ } catch (e) {
307
+ message = responseText;
308
+ }
309
+ } catch (e) {
310
+ message = `General error`;
311
+ }
312
+ throw new ApiClientError(
313
+ message,
314
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
315
+ fetchUri.toString(),
316
+ apiResponse.status,
317
+ apiResponse.statusText,
318
+ _ApiClient.getRequestId(apiResponse)
319
+ );
320
+ }
321
+ if (options == null ? void 0 : options.expectNoContent) {
322
+ return { response: apiResponse, body: null };
323
+ }
324
+ return {
325
+ response: apiResponse,
326
+ body: await apiResponse.json()
327
+ };
328
+ });
329
+ }
330
+ createUrl(path, queryParams, hostOverride) {
331
+ const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
332
+ Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
333
+ var _a;
334
+ if (typeof value !== "undefined" && value !== null) {
335
+ url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
336
+ }
337
+ });
338
+ return url;
339
+ }
340
+ ensureApiHost(apiHost) {
341
+ if (!apiHost) return "https://uniform.app";
342
+ if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
343
+ throw new Error('Your apiHost must start with "http"');
344
+ }
345
+ if (apiHost.indexOf("/", 8) > -1) {
346
+ throw new Error("Your apiHost must not contain a path element after the domain");
347
+ }
348
+ if (apiHost.indexOf("?") > -1) {
349
+ throw new Error("Your apiHost must not contain a query string");
350
+ }
351
+ if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
352
+ apiHost = apiHost.substring(0, apiHost.length - 1);
353
+ }
354
+ return apiHost;
355
+ }
356
+ static getRequestId(response) {
357
+ const apigRequestId = response.headers.get("apigw-requestid");
358
+ if (apigRequestId) {
359
+ return apigRequestId;
360
+ }
361
+ return void 0;
362
+ }
363
+ };
364
+ async function handleRateLimits(callApi) {
365
+ var _a;
366
+ const backoffRetries = 5;
367
+ let backoffRetriesLeft = backoffRetries;
368
+ let response;
369
+ while (backoffRetriesLeft > 0) {
370
+ response = await callApi();
371
+ if (response.status !== 429) {
372
+ break;
373
+ }
374
+ let resetWait = 0;
375
+ try {
376
+ const responseClone = response.clone();
377
+ const dateHeader = responseClone.headers.get("date");
378
+ const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
379
+ const body = await responseClone.json();
380
+ const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
381
+ if (typeof serverTime === "number" && typeof resetTime === "number") {
382
+ resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
383
+ }
384
+ } catch (e) {
385
+ }
386
+ const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
387
+ const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
388
+ await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
389
+ backoffRetriesLeft -= 1;
390
+ }
391
+ return response;
392
+ }
393
+ var _url;
394
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
395
+ constructor(options) {
396
+ super(options);
397
+ }
398
+ /** Fetches all aggregates for a project */
399
+ async get(options) {
400
+ const { projectId } = this.options;
401
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
402
+ return await this.apiClient(fetchUri);
403
+ }
404
+ /** Updates or creates (based on id) an Aggregate */
405
+ async upsert(body) {
406
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
407
+ await this.apiClient(fetchUri, {
408
+ method: "PUT",
409
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
410
+ expectNoContent: true
411
+ });
412
+ }
413
+ /** Deletes an Aggregate */
414
+ async remove(body) {
415
+ const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
416
+ await this.apiClient(fetchUri, {
417
+ method: "DELETE",
418
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
419
+ expectNoContent: true
420
+ });
421
+ }
422
+ };
423
+ _url = /* @__PURE__ */ new WeakMap();
424
+ __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
425
+ var _url2;
426
+ var _DimensionClient = class _DimensionClient2 extends ApiClient {
427
+ constructor(options) {
428
+ super(options);
429
+ }
430
+ /** Fetches the known score dimensions for a project */
431
+ async get(options) {
432
+ const { projectId } = this.options;
433
+ const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
434
+ return await this.apiClient(fetchUri);
435
+ }
436
+ };
437
+ _url2 = /* @__PURE__ */ new WeakMap();
438
+ __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
439
+ var _url3;
440
+ var _valueUrl;
441
+ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
442
+ constructor(options) {
443
+ super(options);
444
+ }
445
+ /** Fetches all enrichments and values for a project, grouped by category */
446
+ async get(options) {
447
+ const { projectId } = this.options;
448
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
449
+ return await this.apiClient(fetchUri);
450
+ }
451
+ /** Updates or creates (based on id) an enrichment category */
452
+ async upsertCategory(body) {
453
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
454
+ await this.apiClient(fetchUri, {
455
+ method: "PUT",
456
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
457
+ expectNoContent: true
458
+ });
459
+ }
460
+ /** Deletes an enrichment category */
461
+ async removeCategory(body) {
462
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
463
+ await this.apiClient(fetchUri, {
464
+ method: "DELETE",
465
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
466
+ expectNoContent: true
467
+ });
468
+ }
469
+ /** Updates or creates (based on id) an enrichment value within an enrichment category */
470
+ async upsertValue(body) {
471
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
472
+ await this.apiClient(fetchUri, {
473
+ method: "PUT",
474
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
475
+ expectNoContent: true
476
+ });
477
+ }
478
+ /** Deletes an enrichment value within an enrichment category. The category is left alone. */
479
+ async removeValue(body) {
480
+ const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
481
+ await this.apiClient(fetchUri, {
482
+ method: "DELETE",
483
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
484
+ expectNoContent: true
485
+ });
486
+ }
487
+ };
488
+ _url3 = /* @__PURE__ */ new WeakMap();
489
+ _valueUrl = /* @__PURE__ */ new WeakMap();
490
+ __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
491
+ __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
492
+ var _url4;
493
+ var _ManifestClient = class _ManifestClient2 extends ApiClient {
494
+ constructor(options) {
495
+ super(options);
496
+ }
497
+ /** Fetches the Context manifest for a project */
498
+ async get(options) {
499
+ const { projectId } = this.options;
500
+ const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
501
+ return await this.apiClient(fetchUri);
502
+ }
503
+ /** Publishes the Context manifest for a project */
504
+ async publish() {
505
+ const { projectId } = this.options;
506
+ const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
507
+ await this.apiClient(fetchUri, {
508
+ method: "POST",
509
+ expectNoContent: true
510
+ });
511
+ }
512
+ };
513
+ _url4 = /* @__PURE__ */ new WeakMap();
514
+ __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
515
+ var _url5;
516
+ var _QuirkClient = class _QuirkClient2 extends ApiClient {
517
+ constructor(options) {
518
+ super(options);
519
+ }
520
+ /** Fetches all Quirks for a project */
521
+ async get(options) {
522
+ const { projectId } = this.options;
523
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
524
+ return await this.apiClient(fetchUri);
525
+ }
526
+ /** Updates or creates (based on id) a Quirk */
527
+ async upsert(body) {
528
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
529
+ await this.apiClient(fetchUri, {
530
+ method: "PUT",
531
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
532
+ expectNoContent: true
533
+ });
534
+ }
535
+ /** Deletes a Quirk */
536
+ async remove(body) {
537
+ const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
538
+ await this.apiClient(fetchUri, {
539
+ method: "DELETE",
540
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
541
+ expectNoContent: true
542
+ });
543
+ }
544
+ };
545
+ _url5 = /* @__PURE__ */ new WeakMap();
546
+ __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
547
+ var _url6;
548
+ var _SignalClient = class _SignalClient2 extends ApiClient {
549
+ constructor(options) {
550
+ super(options);
551
+ }
552
+ /** Fetches all Signals for a project */
553
+ async get(options) {
554
+ const { projectId } = this.options;
555
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
556
+ return await this.apiClient(fetchUri);
557
+ }
558
+ /** Updates or creates (based on id) a Signal */
559
+ async upsert(body) {
560
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
561
+ await this.apiClient(fetchUri, {
562
+ method: "PUT",
563
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
564
+ expectNoContent: true
565
+ });
566
+ }
567
+ /** Deletes a Signal */
568
+ async remove(body) {
569
+ const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
570
+ await this.apiClient(fetchUri, {
571
+ method: "DELETE",
572
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
573
+ expectNoContent: true
574
+ });
575
+ }
576
+ };
577
+ _url6 = /* @__PURE__ */ new WeakMap();
578
+ __privateAdd(_SignalClient, _url6, "/api/v2/signal");
579
+ var _url7;
580
+ var _TestClient = class _TestClient2 extends ApiClient {
581
+ constructor(options) {
582
+ super(options);
583
+ }
584
+ /** Fetches all Tests for a project */
585
+ async get(options) {
586
+ const { projectId } = this.options;
587
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
588
+ return await this.apiClient(fetchUri);
589
+ }
590
+ /** Updates or creates (based on id) a Test */
591
+ async upsert(body) {
592
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
593
+ await this.apiClient(fetchUri, {
594
+ method: "PUT",
595
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
596
+ expectNoContent: true
597
+ });
598
+ }
599
+ /** Deletes a Test */
600
+ async remove(body) {
601
+ const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
602
+ await this.apiClient(fetchUri, {
603
+ method: "DELETE",
604
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
605
+ expectNoContent: true
606
+ });
607
+ }
608
+ };
609
+ _url7 = /* @__PURE__ */ new WeakMap();
610
+ __privateAdd(_TestClient, _url7, "/api/v2/test");
611
+
612
+ // ../canvas/dist/index.mjs
613
+ var __create2 = Object.create;
614
+ var __defProp3 = Object.defineProperty;
615
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
616
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
617
+ var __getProtoOf2 = Object.getPrototypeOf;
618
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
619
+ var __typeError2 = (msg) => {
620
+ throw TypeError(msg);
621
+ };
622
+ var __commonJS2 = (cb, mod) => function __require() {
623
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
624
+ };
625
+ var __copyProps2 = (to, from, except, desc) => {
626
+ if (from && typeof from === "object" || typeof from === "function") {
627
+ for (let key of __getOwnPropNames2(from))
628
+ if (!__hasOwnProp2.call(to, key) && key !== except)
629
+ __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
630
+ }
631
+ return to;
632
+ };
633
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
634
+ // If the importer is in node compatibility mode or this is not an ESM
635
+ // file that has been converted to a CommonJS file using a Babel-
636
+ // compatible transform (i.e. "__esModule" has not been set), then set
637
+ // "default" to the CommonJS "module.exports" for node compatibility.
638
+ isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
639
+ mod
640
+ ));
641
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
642
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
643
+ var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
644
+ var require_yocto_queue2 = __commonJS2({
645
+ "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
646
+ "use strict";
647
+ var Node = class {
648
+ /// value;
649
+ /// next;
650
+ constructor(value) {
651
+ this.value = value;
652
+ this.next = void 0;
653
+ }
654
+ };
655
+ var Queue = class {
656
+ // TODO: Use private class fields when targeting Node.js 12.
657
+ // #_head;
658
+ // #_tail;
659
+ // #_size;
660
+ constructor() {
661
+ this.clear();
662
+ }
663
+ enqueue(value) {
664
+ const node = new Node(value);
665
+ if (this._head) {
666
+ this._tail.next = node;
667
+ this._tail = node;
668
+ } else {
669
+ this._head = node;
670
+ this._tail = node;
671
+ }
672
+ this._size++;
673
+ }
674
+ dequeue() {
675
+ const current = this._head;
676
+ if (!current) {
677
+ return;
678
+ }
679
+ this._head = this._head.next;
680
+ this._size--;
681
+ return current.value;
682
+ }
683
+ clear() {
684
+ this._head = void 0;
685
+ this._tail = void 0;
686
+ this._size = 0;
687
+ }
688
+ get size() {
689
+ return this._size;
690
+ }
691
+ *[Symbol.iterator]() {
692
+ let current = this._head;
693
+ while (current) {
694
+ yield current.value;
695
+ current = current.next;
696
+ }
697
+ }
698
+ };
699
+ module2.exports = Queue;
700
+ }
701
+ });
702
+ var require_p_limit2 = __commonJS2({
703
+ "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
704
+ "use strict";
705
+ var Queue = require_yocto_queue2();
706
+ var pLimit2 = (concurrency) => {
707
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
708
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
709
+ }
710
+ const queue = new Queue();
711
+ let activeCount = 0;
712
+ const next = () => {
713
+ activeCount--;
714
+ if (queue.size > 0) {
715
+ queue.dequeue()();
716
+ }
717
+ };
718
+ const run = async (fn, resolve, ...args) => {
719
+ activeCount++;
720
+ const result = (async () => fn(...args))();
721
+ resolve(result);
722
+ try {
723
+ await result;
724
+ } catch (e) {
725
+ }
726
+ next();
727
+ };
728
+ const enqueue = (fn, resolve, ...args) => {
729
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
730
+ (async () => {
731
+ await Promise.resolve();
732
+ if (activeCount < concurrency && queue.size > 0) {
733
+ queue.dequeue()();
734
+ }
735
+ })();
736
+ };
737
+ const generator = (fn, ...args) => new Promise((resolve) => {
738
+ enqueue(fn, resolve, ...args);
739
+ });
740
+ Object.defineProperties(generator, {
741
+ activeCount: {
742
+ get: () => activeCount
743
+ },
744
+ pendingCount: {
745
+ get: () => queue.size
746
+ },
747
+ clearQueue: {
748
+ value: () => {
749
+ queue.clear();
750
+ }
751
+ }
752
+ });
753
+ return generator;
754
+ };
755
+ module2.exports = pLimit2;
756
+ }
757
+ });
758
+ var require_retry_operation = __commonJS2({
759
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
760
+ "use strict";
761
+ function RetryOperation(timeouts, options) {
762
+ if (typeof options === "boolean") {
763
+ options = { forever: options };
764
+ }
765
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
766
+ this._timeouts = timeouts;
767
+ this._options = options || {};
768
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
769
+ this._fn = null;
770
+ this._errors = [];
771
+ this._attempts = 1;
772
+ this._operationTimeout = null;
773
+ this._operationTimeoutCb = null;
774
+ this._timeout = null;
775
+ this._operationStart = null;
776
+ this._timer = null;
777
+ if (this._options.forever) {
778
+ this._cachedTimeouts = this._timeouts.slice(0);
779
+ }
780
+ }
781
+ module2.exports = RetryOperation;
782
+ RetryOperation.prototype.reset = function() {
783
+ this._attempts = 1;
784
+ this._timeouts = this._originalTimeouts.slice(0);
785
+ };
786
+ RetryOperation.prototype.stop = function() {
787
+ if (this._timeout) {
788
+ clearTimeout(this._timeout);
789
+ }
790
+ if (this._timer) {
791
+ clearTimeout(this._timer);
792
+ }
793
+ this._timeouts = [];
794
+ this._cachedTimeouts = null;
795
+ };
796
+ RetryOperation.prototype.retry = function(err) {
797
+ if (this._timeout) {
798
+ clearTimeout(this._timeout);
799
+ }
800
+ if (!err) {
801
+ return false;
802
+ }
803
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
804
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
805
+ this._errors.push(err);
806
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
807
+ return false;
808
+ }
809
+ this._errors.push(err);
810
+ var timeout = this._timeouts.shift();
811
+ if (timeout === void 0) {
812
+ if (this._cachedTimeouts) {
813
+ this._errors.splice(0, this._errors.length - 1);
814
+ timeout = this._cachedTimeouts.slice(-1);
815
+ } else {
816
+ return false;
817
+ }
818
+ }
819
+ var self = this;
820
+ this._timer = setTimeout(function() {
821
+ self._attempts++;
822
+ if (self._operationTimeoutCb) {
823
+ self._timeout = setTimeout(function() {
824
+ self._operationTimeoutCb(self._attempts);
825
+ }, self._operationTimeout);
826
+ if (self._options.unref) {
827
+ self._timeout.unref();
828
+ }
829
+ }
830
+ self._fn(self._attempts);
831
+ }, timeout);
832
+ if (this._options.unref) {
833
+ this._timer.unref();
834
+ }
835
+ return true;
836
+ };
837
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
838
+ this._fn = fn;
839
+ if (timeoutOps) {
840
+ if (timeoutOps.timeout) {
841
+ this._operationTimeout = timeoutOps.timeout;
842
+ }
843
+ if (timeoutOps.cb) {
844
+ this._operationTimeoutCb = timeoutOps.cb;
845
+ }
846
+ }
847
+ var self = this;
848
+ if (this._operationTimeoutCb) {
849
+ this._timeout = setTimeout(function() {
850
+ self._operationTimeoutCb();
851
+ }, self._operationTimeout);
852
+ }
853
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
854
+ this._fn(this._attempts);
855
+ };
856
+ RetryOperation.prototype.try = function(fn) {
857
+ console.log("Using RetryOperation.try() is deprecated");
858
+ this.attempt(fn);
859
+ };
860
+ RetryOperation.prototype.start = function(fn) {
861
+ console.log("Using RetryOperation.start() is deprecated");
862
+ this.attempt(fn);
863
+ };
864
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
865
+ RetryOperation.prototype.errors = function() {
866
+ return this._errors;
867
+ };
868
+ RetryOperation.prototype.attempts = function() {
869
+ return this._attempts;
870
+ };
871
+ RetryOperation.prototype.mainError = function() {
872
+ if (this._errors.length === 0) {
873
+ return null;
874
+ }
875
+ var counts = {};
876
+ var mainError = null;
877
+ var mainErrorCount = 0;
878
+ for (var i = 0; i < this._errors.length; i++) {
879
+ var error = this._errors[i];
880
+ var message = error.message;
881
+ var count = (counts[message] || 0) + 1;
882
+ counts[message] = count;
883
+ if (count >= mainErrorCount) {
884
+ mainError = error;
885
+ mainErrorCount = count;
886
+ }
887
+ }
888
+ return mainError;
889
+ };
890
+ }
891
+ });
892
+ var require_retry = __commonJS2({
893
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
894
+ "use strict";
895
+ var RetryOperation = require_retry_operation();
896
+ exports2.operation = function(options) {
897
+ var timeouts = exports2.timeouts(options);
898
+ return new RetryOperation(timeouts, {
899
+ forever: options && (options.forever || options.retries === Infinity),
900
+ unref: options && options.unref,
901
+ maxRetryTime: options && options.maxRetryTime
902
+ });
903
+ };
904
+ exports2.timeouts = function(options) {
905
+ if (options instanceof Array) {
906
+ return [].concat(options);
907
+ }
908
+ var opts = {
909
+ retries: 10,
910
+ factor: 2,
911
+ minTimeout: 1 * 1e3,
912
+ maxTimeout: Infinity,
913
+ randomize: false
914
+ };
915
+ for (var key in options) {
916
+ opts[key] = options[key];
917
+ }
918
+ if (opts.minTimeout > opts.maxTimeout) {
919
+ throw new Error("minTimeout is greater than maxTimeout");
920
+ }
921
+ var timeouts = [];
922
+ for (var i = 0; i < opts.retries; i++) {
923
+ timeouts.push(this.createTimeout(i, opts));
924
+ }
925
+ if (options && options.forever && !timeouts.length) {
926
+ timeouts.push(this.createTimeout(i, opts));
927
+ }
928
+ timeouts.sort(function(a, b) {
929
+ return a - b;
930
+ });
931
+ return timeouts;
932
+ };
933
+ exports2.createTimeout = function(attempt, opts) {
934
+ var random = opts.randomize ? Math.random() + 1 : 1;
935
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
936
+ timeout = Math.min(timeout, opts.maxTimeout);
937
+ return timeout;
938
+ };
939
+ exports2.wrap = function(obj, options, methods) {
940
+ if (options instanceof Array) {
941
+ methods = options;
942
+ options = null;
943
+ }
944
+ if (!methods) {
945
+ methods = [];
946
+ for (var key in obj) {
947
+ if (typeof obj[key] === "function") {
948
+ methods.push(key);
949
+ }
950
+ }
951
+ }
952
+ for (var i = 0; i < methods.length; i++) {
953
+ var method = methods[i];
954
+ var original = obj[method];
955
+ obj[method] = function retryWrapper(original2) {
956
+ var op = exports2.operation(options);
957
+ var args = Array.prototype.slice.call(arguments, 1);
958
+ var callback = args.pop();
959
+ args.push(function(err) {
960
+ if (op.retry(err)) {
961
+ return;
962
+ }
963
+ if (err) {
964
+ arguments[0] = op.mainError();
965
+ }
966
+ callback.apply(this, arguments);
967
+ });
968
+ op.attempt(function() {
969
+ original2.apply(obj, args);
970
+ });
971
+ }.bind(obj, original);
972
+ obj[method].options = options;
973
+ }
974
+ };
975
+ }
976
+ });
977
+ var require_retry2 = __commonJS2({
978
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
979
+ "use strict";
980
+ module2.exports = require_retry();
981
+ }
982
+ });
983
+ var import_p_limit2 = __toESM2(require_p_limit2());
984
+ var import_retry = __toESM2(require_retry2(), 1);
985
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
986
+ function rewriteFilters(filters) {
987
+ return Object.entries(filters != null ? filters : {}).reduce(
988
+ (acc, [key, value]) => {
989
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
990
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
991
+ return {
992
+ ...acc,
993
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
994
+ };
995
+ },
996
+ {}
997
+ );
998
+ }
999
+ var _contentTypesUrl;
1000
+ var _entriesUrl;
1001
+ var _ContentClient = class _ContentClient2 extends ApiClient {
1002
+ constructor(options) {
1003
+ var _a;
1004
+ super(options);
1005
+ this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
1006
+ }
1007
+ getContentTypes(options) {
1008
+ const { projectId } = this.options;
1009
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1010
+ return this.apiClient(fetchUri);
1011
+ }
1012
+ getEntries(options) {
1013
+ const { projectId } = this.options;
1014
+ const { skipDataResolution, filters, ...params } = options;
1015
+ const rewrittenFilters = rewriteFilters(filters);
1016
+ if (skipDataResolution) {
1017
+ const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1018
+ return this.apiClient(url);
1019
+ }
1020
+ const edgeUrl = this.createUrl(
1021
+ __privateGet2(_ContentClient2, _entriesUrl),
1022
+ { ...this.getEdgeOptions(params), ...rewrittenFilters },
1023
+ this.edgeApiHost
1024
+ );
1025
+ return this.apiClient(
1026
+ edgeUrl,
1027
+ this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
1028
+ );
1029
+ }
1030
+ /** Fetches historical versions of an entry */
1031
+ async getEntryHistory(options) {
1032
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
1033
+ ...options,
1034
+ projectId: this.options.projectId
1035
+ });
1036
+ return this.apiClient(historyUrl);
1037
+ }
1038
+ async upsertContentType(body, opts = {}) {
1039
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1040
+ if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1041
+ delete body.contentType.slugSettings;
1042
+ }
1043
+ await this.apiClient(fetchUri, {
1044
+ method: "PUT",
1045
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1046
+ expectNoContent: true,
1047
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
1048
+ });
1049
+ }
1050
+ async upsertEntry(body, options) {
1051
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1052
+ const headers = {};
1053
+ if (options == null ? void 0 : options.ifUnmodifiedSince) {
1054
+ headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
1055
+ }
1056
+ const { response } = await this.apiClientWithResponse(fetchUri, {
1057
+ method: "PUT",
1058
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1059
+ expectNoContent: true,
1060
+ headers
1061
+ });
1062
+ return { modified: response.headers.get("x-modified-at") };
1063
+ }
1064
+ async deleteContentType(body) {
1065
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1066
+ await this.apiClient(fetchUri, {
1067
+ method: "DELETE",
1068
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1069
+ expectNoContent: true
1070
+ });
1071
+ }
1072
+ async deleteEntry(body) {
1073
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1074
+ await this.apiClient(fetchUri, {
1075
+ method: "DELETE",
1076
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1077
+ expectNoContent: true
1078
+ });
1079
+ }
1080
+ getEdgeOptions(options) {
1081
+ const { projectId } = this.options;
1082
+ const { skipDataResolution, ...params } = options;
1083
+ return {
1084
+ projectId,
1085
+ ...params,
1086
+ diagnostics: typeof options.diagnostics === "boolean" ? options.diagnostics : options.diagnostics === "no-data" ? "no-data" : void 0
1087
+ };
1088
+ }
1089
+ };
1090
+ _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1091
+ _entriesUrl = /* @__PURE__ */ new WeakMap();
1092
+ __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1093
+ __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1094
+ var _url8;
1095
+ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1096
+ constructor(options) {
1097
+ super(options);
1098
+ }
1099
+ /** Fetches all DataTypes for a project */
1100
+ async get(options) {
1101
+ const { projectId } = this.options;
1102
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1103
+ return await this.apiClient(fetchUri);
1104
+ }
1105
+ /** Updates or creates (based on id) a DataType */
1106
+ async upsert(body) {
1107
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1108
+ await this.apiClient(fetchUri, {
1109
+ method: "PUT",
1110
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1111
+ expectNoContent: true
1112
+ });
1113
+ }
1114
+ /** Deletes a DataType */
1115
+ async remove(body) {
1116
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1117
+ await this.apiClient(fetchUri, {
1118
+ method: "DELETE",
1119
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1120
+ expectNoContent: true
1121
+ });
1122
+ }
1123
+ };
1124
+ _url8 = /* @__PURE__ */ new WeakMap();
1125
+ __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1126
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1127
+ var _baseUrl;
1128
+ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends ApiClient {
1129
+ constructor(options) {
1130
+ super(options);
1131
+ this.teamId = options.teamId;
1132
+ }
1133
+ /**
1134
+ * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1135
+ */
1136
+ get(options) {
1137
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1138
+ ...options,
1139
+ teamId: this.teamId
1140
+ });
1141
+ return this.apiClient(fetchUri);
1142
+ }
1143
+ /**
1144
+ * Creates or updates a custom AI property editor on a Mesh app.
1145
+ */
1146
+ async deploy(body) {
1147
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1148
+ await this.apiClient(fetchUri, {
1149
+ method: "PUT",
1150
+ body: JSON.stringify({ ...body, teamId: this.teamId }),
1151
+ expectNoContent: true
1152
+ });
1153
+ }
1154
+ /**
1155
+ * Removes a custom AI property editor from a Mesh app.
1156
+ */
1157
+ async delete(body) {
1158
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1159
+ await this.apiClient(fetchUri, {
1160
+ method: "DELETE",
1161
+ body: JSON.stringify({ ...body, teamId: this.teamId }),
1162
+ expectNoContent: true
1163
+ });
1164
+ }
1165
+ };
1166
+ _baseUrl = /* @__PURE__ */ new WeakMap();
1167
+ __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1168
+ var _url22;
1169
+ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1170
+ constructor(options) {
1171
+ super({ ...options, bypassCache: true });
1172
+ }
1173
+ /** Fetches single Project */
1174
+ async get(options) {
1175
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1176
+ return await this.apiClient(fetchUri);
1177
+ }
1178
+ /** Updates or creates (based on id) a Project */
1179
+ async upsert(body) {
1180
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1181
+ return await this.apiClient(fetchUri, {
1182
+ method: "PUT",
1183
+ body: JSON.stringify({ ...body })
1184
+ });
1185
+ }
1186
+ /** Deletes a Project */
1187
+ async delete(body) {
1188
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1189
+ await this.apiClient(fetchUri, {
1190
+ method: "DELETE",
1191
+ body: JSON.stringify({ ...body }),
1192
+ expectNoContent: true
1193
+ });
1194
+ }
1195
+ };
1196
+ _url22 = /* @__PURE__ */ new WeakMap();
1197
+ __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1198
+ var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
1199
+ var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
1200
+ var ATTRIBUTE_PARAMETER_TYPE = "data-uniform-parameter-type";
1201
+
1202
+ // src/components/UniformRichText.tsx
1203
+ var import_richtext6 = require("@uniformdev/richtext");
1204
+ var import_react12 = __toESM(require("react"));
1205
+
1206
+ // src/components/UniformRichTextNode.tsx
1207
+ var import_richtext5 = require("@uniformdev/richtext");
1208
+ var import_react11 = __toESM(require("react"));
1209
+
1210
+ // src/components/nodes/AssetRichTextNode.tsx
1211
+ var import_react = __toESM(require("react"));
1212
+ var AssetRichTextNode = ({ node }) => {
1213
+ var _a, _b;
1214
+ const { __asset } = node;
1215
+ if (__asset === void 0) {
1216
+ return null;
1217
+ }
1218
+ if (__asset.type === "image") {
1219
+ return /* @__PURE__ */ import_react.default.createElement("figure", null, /* @__PURE__ */ import_react.default.createElement("img", { src: __asset.fields.url.value, alt: (_a = __asset.fields.title) == null ? void 0 : _a.value }), ((_b = __asset.fields.description) == null ? void 0 : _b.value) ? /* @__PURE__ */ import_react.default.createElement("figcaption", null, __asset.fields.description.value) : null);
1220
+ }
1221
+ if (__asset.type === "video") {
1222
+ return /* @__PURE__ */ import_react.default.createElement("video", { src: __asset.fields.url.value, controls: true });
1223
+ }
1224
+ if (__asset.type === "audio") {
1225
+ return /* @__PURE__ */ import_react.default.createElement("audio", { src: __asset.fields.url.value, controls: true });
1226
+ }
1227
+ return null;
1228
+ };
1229
+
1230
+ // src/components/nodes/HeadingRichTextNode.tsx
1231
+ var import_react2 = __toESM(require("react"));
1232
+ var HeadingRichTextNode = ({ children, node }) => {
1233
+ const { tag } = node;
1234
+ const HTag = tag != null ? tag : "h1";
1235
+ return /* @__PURE__ */ import_react2.default.createElement(HTag, null, children);
1236
+ };
1237
+
1238
+ // src/components/nodes/LinebreakRichTextNode.tsx
1239
+ var import_react3 = __toESM(require("react"));
1240
+ var LinebreakRichTextNode = () => {
1241
+ return /* @__PURE__ */ import_react3.default.createElement("br", null);
1242
+ };
1243
+
1244
+ // src/components/nodes/LinkRichTextNode.tsx
1245
+ var import_richtext = require("@uniformdev/richtext");
1246
+ var import_react4 = __toESM(require("react"));
1247
+ var LinkRichTextNode = ({ children, node }) => {
1248
+ const { link } = node;
1249
+ return /* @__PURE__ */ import_react4.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
1250
+ };
1251
+
1252
+ // src/components/nodes/ListItemRichTextNode.tsx
1253
+ var import_react5 = __toESM(require("react"));
1254
+ var ListItemRichTextNode = ({ children, node }) => {
1255
+ const { value } = node;
1256
+ return /* @__PURE__ */ import_react5.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
1257
+ };
1258
+
1259
+ // src/components/nodes/ListRichTextNode.tsx
1260
+ var import_react6 = __toESM(require("react"));
1261
+ var ListRichTextNode = ({ children, node }) => {
1262
+ const { tag, start } = node;
1263
+ const ListTag = tag != null ? tag : "ul";
1264
+ return /* @__PURE__ */ import_react6.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
1265
+ };
1266
+
1267
+ // src/components/nodes/ParagraphRichTextNode.tsx
1268
+ var import_richtext2 = require("@uniformdev/richtext");
1269
+ var import_react7 = __toESM(require("react"));
1270
+ var ParagraphRichTextNode = ({ children, node }) => {
1271
+ const { format, direction } = node;
1272
+ return /* @__PURE__ */ import_react7.default.createElement(
1273
+ "p",
1274
+ {
1275
+ dir: (0, import_richtext2.isPureDirection)(direction) ? direction : void 0,
1276
+ style: (0, import_richtext2.isPureTextAlign)(format) ? { textAlign: format } : void 0
1277
+ },
1278
+ children
1279
+ );
1280
+ };
1281
+
1282
+ // src/components/nodes/TableCellRichTextNode.tsx
1283
+ var import_richtext3 = require("@uniformdev/richtext");
1284
+ var import_react8 = __toESM(require("react"));
1285
+ var TableCellRichTextNode = ({ children, node }) => {
1286
+ const { headerState } = node;
1287
+ const TableCellTag = (0, import_richtext3.getRichTextTagFromTableCellHeaderState)(headerState);
1288
+ return /* @__PURE__ */ import_react8.default.createElement(TableCellTag, null, children);
1289
+ };
1290
+
1291
+ // src/components/nodes/TabRichTextNode.tsx
1292
+ var import_react9 = __toESM(require("react"));
1293
+ var TabRichTextNode = () => {
1294
+ return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, " ");
1295
+ };
1296
+
1297
+ // src/components/nodes/TextRichTextNode.tsx
1298
+ var import_richtext4 = require("@uniformdev/richtext");
1299
+ var import_react10 = __toESM(require("react"));
1300
+ var TextRichTextNode = ({ node }) => {
1301
+ const { text, format } = node;
1302
+ const tags = (0, import_richtext4.getRichTextTagsFromTextFormat)(format);
1303
+ return /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ import_react10.default.createElement(Tag, null, children), text) : text);
1304
+ };
1305
+
1306
+ // src/components/UniformRichTextNode.tsx
1307
+ function UniformRichTextNode({ node, ...props }) {
1308
+ var _a;
1309
+ if (!(0, import_richtext5.isRichTextNode)(node)) return null;
1310
+ let NodeRenderer = (_a = props.resolveRichTextRenderer) == null ? void 0 : _a.call(props, node);
1311
+ if (typeof NodeRenderer === "undefined") {
1312
+ NodeRenderer = resolveRichTextDefaultRenderer(node);
1313
+ }
1314
+ if (!NodeRenderer) {
1315
+ return null;
1316
+ }
1317
+ const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ import_react11.default.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
1318
+ return /* @__PURE__ */ import_react11.default.createElement(NodeRenderer, { node }, children);
1319
+ }
1320
+ var rendererMap = /* @__PURE__ */ new Map([
1321
+ ["heading", HeadingRichTextNode],
1322
+ ["linebreak", LinebreakRichTextNode],
1323
+ ["link", LinkRichTextNode],
1324
+ ["list", ListRichTextNode],
1325
+ ["listitem", ListItemRichTextNode],
1326
+ ["paragraph", ParagraphRichTextNode],
1327
+ ["quote", ({ children }) => /* @__PURE__ */ import_react11.default.createElement("blockquote", null, children)],
1328
+ [
1329
+ "code",
1330
+ ({ children }) => /* @__PURE__ */ import_react11.default.createElement("pre", null, /* @__PURE__ */ import_react11.default.createElement("code", null, children))
1331
+ ],
1332
+ ["root", ({ children }) => /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, children)],
1333
+ ["text", TextRichTextNode],
1334
+ ["tab", TabRichTextNode],
1335
+ [
1336
+ "table",
1337
+ ({ children }) => /* @__PURE__ */ import_react11.default.createElement("table", null, /* @__PURE__ */ import_react11.default.createElement("tbody", null, children))
1338
+ ],
1339
+ ["tablerow", ({ children }) => /* @__PURE__ */ import_react11.default.createElement("tr", null, children)],
1340
+ ["tablecell", TableCellRichTextNode],
1341
+ ["asset", AssetRichTextNode]
1342
+ ]);
1343
+ var resolveRichTextDefaultRenderer = (node) => {
1344
+ return rendererMap.get(node.type);
1345
+ };
1346
+
1347
+ // src/components/UniformRichText.tsx
1348
+ var UniformRichText = import_react12.default.forwardRef(function UniformRichText2({
1349
+ component,
1350
+ resolveRichTextRenderer,
1351
+ as: Tag = "div",
1352
+ parameter,
1353
+ placeholder,
1354
+ ...props
1355
+ }, ref) {
1356
+ var _a;
1357
+ const isContextualEditing = (_a = parameter == null ? void 0 : parameter._contextualEditing) != null ? _a : false;
1358
+ if (!parameter) {
1359
+ return null;
1360
+ }
1361
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameter.parameterId }) : placeholder;
1362
+ const value = parameter.value;
1363
+ if (!value || !(0, import_richtext6.isRichTextValue)(value)) return null;
1364
+ if (!isContextualEditing && (0, import_richtext6.isRichTextValueConsideredEmpty)(value)) return null;
1365
+ return Tag === null ? /* @__PURE__ */ import_react12.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ import_react12.default.createElement(
1366
+ Tag,
1367
+ {
1368
+ ref,
1369
+ ...props,
1370
+ ...isContextualEditing ? {
1371
+ [ATTRIBUTE_COMPONENT_ID]: component._id,
1372
+ [ATTRIBUTE_PARAMETER_ID]: parameter.parameterId,
1373
+ [ATTRIBUTE_PARAMETER_TYPE]: "richText"
1374
+ } : {}
1375
+ },
1376
+ (0, import_richtext6.isRichTextValueConsideredEmpty)(value) ? /* @__PURE__ */ import_react12.default.createElement("p", null, /* @__PURE__ */ import_react12.default.createElement("i", null, computedPlaceholder)) : /* @__PURE__ */ import_react12.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
1377
+ );
1378
+ });
1379
+
1380
+ // src/components/UniformText.tsx
1381
+ var import_next_app_router_client = require("@uniformdev/next-app-router-client");
1382
+ var import_react13 = __toESM(require("react"));
1383
+ var UniformText = (props) => {
1384
+ return /* @__PURE__ */ import_react13.default.createElement(import_next_app_router_client.ClientUniformText, { ...props });
1385
+ };
1386
+ // Annotate the CommonJS export names for ESM import in node:
1387
+ 0 && (module.exports = {
1388
+ UniformRichText,
1389
+ UniformSlot,
1390
+ UniformText,
1391
+ createClientUniformContext,
1392
+ getUniformSlot,
1393
+ useInitUniformContext,
1394
+ useQuirks,
1395
+ useScores,
1396
+ useUniformContext
1397
+ });